diff --git a/SingleSource/Regression/C/CMakeLists.txt b/SingleSource/Regression/C/CMakeLists.txt index 3f224e2768..ea4479a8f1 100644 --- a/SingleSource/Regression/C/CMakeLists.txt +++ b/SingleSource/Regression/C/CMakeLists.txt @@ -3,6 +3,8 @@ if(ARCH MATCHES "x86" OR ARCH MATCHES "riscv" OR ARCH MATCHES "AArch64" OR ARCH MATCHES "ARM" OR ARCH MATCHES "LoongArch") add_subdirectory(gcc-c-torture) + add_subdirectory(gcc-dg) + add_subdirectory(gcc-vect) endif() list(APPEND LDFLAGS -lm) diff --git a/SingleSource/Regression/C/bic-bitmask.h b/SingleSource/Regression/C/bic-bitmask.h new file mode 100644 index 0000000000..faf80b974d --- /dev/null +++ b/SingleSource/Regression/C/bic-bitmask.h @@ -0,0 +1,43 @@ +#include + +#ifndef N +#define N 65 +#endif + +#ifndef TYPE +#define TYPE uint32_t +#endif + +#ifndef DEBUG +#define DEBUG 0 +#endif + +#define BASE ((TYPE) -1 < 0 ? -126 : 4) + +int main () +{ + TYPE a[N]; + TYPE b[N]; + + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 13; + b[i] = BASE + i * 13; + if (DEBUG) + printf ("%d: 0x%x\n", i, a[i]); + } + + fun1 (a, N); + fun2 (b, N); + + for (int i = 0; i < N; ++i) + { + if (DEBUG) + printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]); + + if (a[i] != b[i]) + __builtin_abort (); + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-c-torture/CMakeLists.txt b/SingleSource/Regression/C/gcc-c-torture/CMakeLists.txt index 89de769b64..5442d3ebf9 100644 --- a/SingleSource/Regression/C/gcc-c-torture/CMakeLists.txt +++ b/SingleSource/Regression/C/gcc-c-torture/CMakeLists.txt @@ -1,64 +1,5 @@ -# The following cause errors if they are passed to clang via CFLAGS -set(CLANG_ERRORING_CFLAGS - "-fno-early-inlining" - "-fno-ira-share-spill-slots" - "-ftree-loop-distribution" - "-fno-tree-bit-ccp" - "-fno-tree-coalesce-vars" -) - -# This pulls out options in dg-options into `${Variable}` -function(gcc_torture_dg_options_cflags Variable File) - # Some files have dg-options which we need to pick up. These should be in - # the first line but often aren't. - # - # We also need to be careful not to pick up target-specific dg-options. - set(DG_CFLAGS) - - file(STRINGS ${File} FileLines) - foreach(FileLine ${FileLines}) - # Looking for `dg-options "..."` or `dg-additional-options "..."` without - # `{ target` afterwards (ignoring spaces). - if(FileLine MATCHES "dg-(additional-)?options ({ )?\"([^\"]*)\"( })?(.*)") - # This is needed to turn the string into a list of CFLAGS - separate_arguments(FILE_CFLAGS UNIX_COMMAND ${CMAKE_MATCH_3}) - # This does the negative lookahead for `{ target` anywhere in the rest of - # the line - if(NOT ${CMAKE_MATCH_5} MATCHES "{ +target") - list(APPEND DG_CFLAGS ${FILE_CFLAGS}) - endif() - endif() - endforeach() - - # Remove any flags that will make clang error - if (DG_CFLAGS) - list(REMOVE_ITEM DG_CFLAGS ${CLANG_ERRORING_CFLAGS}) - endif() - - # Set the parent scope variable - set(${Variable} ${DG_CFLAGS} PARENT_SCOPE) -endfunction() - -function(gcc_torture_execute_test File) - cmake_parse_arguments(_TORTURE "" "PREFIX" "CFLAGS;LDFLAGS" ${ARGN}) - # There are a few tests with duplicate filenames, and CMake wants all target - # names to be unique, so we add a disambiguator to the target name. The - # disambiguator is based upon the directory structure, swapping `/` for `-`. - get_filename_component(Name ${File} NAME_WE) - set(_target "${_TORTURE_PREFIX}-${Name}") - - gcc_torture_dg_options_cflags(DG_CFLAGS ${File}) - - # Add any flags that were requested - list(APPEND CFLAGS ${DG_CFLAGS} ${_TORTURE_CFLAGS}) - list(APPEND LDFLAGS ${_TORTURE_LDFLAGS}) - - llvm_test_executable_no_test(${_target} ${File}) - llvm_test_run() - - llvm_add_test_for_target(${_target}) -endfunction() +include(${CMAKE_CURRENT_SOURCE_DIR}/../../DgOptions.txt) file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") -add_subdirectory(execute) \ No newline at end of file +add_subdirectory(execute) diff --git a/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt b/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt index 4788755c81..d509402eb4 100644 --- a/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt +++ b/SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt @@ -1,8 +1,5 @@ add_subdirectory(ieee) -# GCC C Torture Suite is conventionally run without warnings -list(APPEND CFLAGS -Wno-implicit-int -Wno-int-conversion -Wno-implicit-function-declaration -w) - set(TestsToSkip) ## @@ -383,6 +380,7 @@ foreach(File ${TestFiles}) # Add Test Target gcc_torture_execute_test(${File} + DG_DO_DEFAULT "run" PREFIX "GCC-C-execute" CFLAGS ${MaybeCFlags} LDFLAGS ${MaybeLDFlags}) diff --git a/SingleSource/Regression/C/gcc-dg/20000108-1.c b/SingleSource/Regression/C/gcc-dg/20000108-1.c new file mode 100644 index 0000000000..4391be2ad8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20000108-1.c @@ -0,0 +1,20 @@ +/* Copyright (C) 2000 Free Software Foundation. + + by Alexandre Oliva */ + +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +extern void abort (void); + +void foo () {} /* unused, but essential to trigger the bug */ + +int main () { + int i; + /* use asms to prevent optimizations */ + /* i = -1; */ asm ("" : "=r" (i) : "0" (-1)); + /* i = 1; */ asm ("" : "=r" (i) : "0" (i ? 1 : 2)); + if (i != 1) + abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20000111-1.c b/SingleSource/Regression/C/gcc-dg/20000111-1.c new file mode 100644 index 0000000000..a042656d56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20000111-1.c @@ -0,0 +1,17 @@ +/* Copyright (C) 2000 Free Software Foundation. + + by Alexandre Oliva */ + +/* { dg-do compile } */ + +__inline int +foo (int **q) { + return *q && **q; +} + +void +bar () { + int **p; + if (foo (p)) + do_something (); +} diff --git a/SingleSource/Regression/C/gcc-dg/20000623-1.c b/SingleSource/Regression/C/gcc-dg/20000623-1.c new file mode 100644 index 0000000000..bbc8c10ee0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20000623-1.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-strict-aliasing" } */ + +extern void exit (int); +extern void abort (void); + +struct foos { int l; }; +int foo; +static struct foos *getfoo(void); +int main (void) +{ + struct foos *f = getfoo(); + f->l = 1; + foo = 2; + if (f->l == 1) + abort(); + exit(0); +} +static struct foos *getfoo(void) +{ return (struct foos *)&foo; } diff --git a/SingleSource/Regression/C/gcc-dg/20000629-1.c b/SingleSource/Regression/C/gcc-dg/20000629-1.c new file mode 100644 index 0000000000..b8c7f286d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20000629-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +void foo(register char *p) +{ + char c, *q, *sp; + while (1) { + *p++=0; + sp=p+1; + c=*sp; + *p++=0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20000707-1.c b/SingleSource/Regression/C/gcc-dg/20000707-1.c new file mode 100644 index 0000000000..85a3315c4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20000707-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-require-effective-target label_values } */ + +extern void foo(void *here); +extern inline void bar(void) +{ + __label__ here; + foo(&&here); +here: + ; +} + +void baz(void) +{ + bar(); +} diff --git a/SingleSource/Regression/C/gcc-dg/20000906-1.c b/SingleSource/Regression/C/gcc-dg/20000906-1.c new file mode 100644 index 0000000000..90d09d4dba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20000906-1.c @@ -0,0 +1,78 @@ +/* { dg-do run } */ + +/* Testcase distilled from glibc's nss_parse_service_list in nss/nsswitch.c + It can't be distilled further. Fails with `-O2' for i[3456]86. */ + +/* this simulates a bounded-pointer type. */ +struct ucharp { unsigned char *v, *l, *h; }; + +/* this simulates bounded-pointer check prior to pointer dereference. */ +#define AREF(var, idx) ((((((((var).v+(idx)) < (var).l) \ + || (((var).v+(idx)+1) > (var).h))) \ + && (__builtin_trap (), 0)), \ + (var).v)[(idx)]) + +struct list +{ + struct list *next; +}; + +struct list * +alloc_list (void) +{ + static struct list l; + return &l; +} + +int one = 1; + +void +foo (struct ucharp cp, struct ucharp lp, struct list **nextp) +{ + while (1) + { + struct list *list; + while (AREF (lp, 0) && AREF (cp, AREF (lp, 0))) + ++lp.v; + list = alloc_list (); + while (AREF (cp, AREF (lp, 0))) + ++lp.v; + if (AREF (lp, 0) == one) + do + ++lp.v; + while (AREF (lp, 0) && AREF (cp, AREF (lp, 0))); + /* The above AREF (cp, ...) fails because the pseudo created to + hold cp.v holds garbage, having never been set. + The easiest way to see the problem is to compile wiht `-O2 -da' + then look at *.09.loop. Search for something like this: + + Hoisted regno 183 r/o from (mem/s:SI (reg:SI 16 argp) 10) + Replaced reg 91, deleting init_insn (213). + + Now, look for the use of reg 91, which has no set. */ + + *nextp = list; + nextp = &list->next; + if (!*lp.v) + break; + } +} + +extern void exit (int); + +int +main (void) +{ + static unsigned char cp0[] = "\0\0\0\0"; + struct ucharp cp = { cp0, cp0, cp0 + sizeof (cp0) }; + + static unsigned char lp0[] = "\1\1\0\0"; + struct ucharp lp = { lp0, lp0, lp0 + sizeof (lp0) }; + + struct list list; + struct list *nextp = &list; + + foo (cp, lp, &nextp); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20000926-1.c b/SingleSource/Regression/C/gcc-dg/20000926-1.c new file mode 100644 index 0000000000..e70596f08f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20000926-1.c @@ -0,0 +1,27 @@ +/* Copyright (C) 2000 Free Software Foundation. + by William Cohen */ + +/* { dg-do compile } */ +/* { dg-options "" } */ +#include + +struct PDATA +{ + unsigned int Dummy:(sizeof(int)*CHAR_BIT); + const char* PName; +}; + +typedef struct PDATA P_DATA; + +struct PLAYBOOK { + const char * BookName; + P_DATA Play[0]; +}; + +struct PLAYBOOK playbook = +{ + "BookName", + { + { 1, "PName0" }, /* { dg-warning "(excess elements)|(near initialization)" } */ + } +}; diff --git a/SingleSource/Regression/C/gcc-dg/20001009-1.c b/SingleSource/Regression/C/gcc-dg/20001009-1.c new file mode 100644 index 0000000000..580e4b4d30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001009-1.c @@ -0,0 +1,48 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ +/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */ + +extern void foo (void *a, double x, double y); +void +bar (void *a, double b, double c, double d, double e, double f, double g, double h, double i, double j, double k[6]) +{ + double l, m, n, o, p; + double q, r, s, t, u; + double x, y, v, w; + double z = 0.5 * j; + double aa; + l = b - 3 * d; + m = 4 * f; + n = f - h; + q = c + 3 * g - i; + r = 2 * (e - 2 * g + i); + s = g - i; + if (l != 0.0) + { + aa = 0.0; + o = (- m + aa); + p = (- m - aa); + if (o > 0.0) + { + x = ((b-h)*o + 3*(d+h)*o + 3*(f-h)*o); + y = ((c-i)*o + 3*(e+i)*o + 3*(g-i)*o); + foo (a, z, w); + foo (a, -z, w); + } + if (p > 0.0) + { + x = ((b+3*f-h)*p + 3*(d-2*f+h)*p + 3*p); + y = ((c+3*g-i)*p + 3*(e-2*g+i)*p + 3*p); + v = x * k[0] + y * k[2]; + w = x * k[1] + y * k[3]; + foo (a, z, w); + foo (a, - z, w); + } + } + if (q != 0.0) + { + aa = 0.0; + t = (- r + aa) / (2 * q); + u = (- r - aa) / (2 * q); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20001012-1.c b/SingleSource/Regression/C/gcc-dg/20001012-1.c new file mode 100644 index 0000000000..c59169b274 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001012-1.c @@ -0,0 +1,19 @@ +/* { dg-do run { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +extern void abort (void); +extern void exit (int); + +double +foo (void) +{ + return (__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x3f800000UL }).__d); +} + +int +main () +{ + if (foo() != 1.0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20001012-2.c b/SingleSource/Regression/C/gcc-dg/20001012-2.c new file mode 100644 index 0000000000..e7a4fb8da7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001012-2.c @@ -0,0 +1,38 @@ +/* { dg-do run { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ +/* { dg-require-effective-target alloca } */ + +extern void abort (void); +extern void exit (int); + +void foo (char *x, const char *y, ...) +{ +} + +double bar (const char *x, long y) +{ + return 0.0; +} + +typedef __SIZE_TYPE__ size_t; +extern size_t strlen (const char *); + +double baz (const char *x) +{ + if (x[0] != '\0') + { + char y[6 + strlen (x)]; + foo (y, "FOO", x); + return bar (y, 0); + } + + return (__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x3f800000UL }).__d); +} + +int +main () +{ + if (baz("") != 1.0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20001023-1.c b/SingleSource/Regression/C/gcc-dg/20001023-1.c new file mode 100644 index 0000000000..10cb272593 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001023-1.c @@ -0,0 +1,62 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fomit-frame-pointer" } */ + +extern void abort (void); +extern void exit (int); + +unsigned char a[256], b[256], c[256], d[256]; + +void foo(unsigned char *x, int y, unsigned char *z) +{ +} + +void bar(int x, ...) +{ +} + +void baz(int y) +{ + if (y != 0x10) + abort(); +} + +void test(int x, unsigned char *y) +{ + unsigned char g,h,j, k[5],l[5], m[30]; + int i; + + bar(x, y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7], y[8], y[9]); + for (i = 5; --i >= 0; ) + k[i] = y[5 + i] ^ a[i] ^ c[i]; + + foo(&m[29], sizeof m, k); + g = d[x] ^ c[x]; + bar(x, d[x], x, c[x]); + baz(g); + for (i = 5, h = 0; --i >= 0; h = y[i]) + { + j = m[25 + i] ^ y[i]; + j = b[j] ^ g; + k[i] = c[j] ^ h; + } + for (i = 5, h = 0; --i >= 0; h = k[i]) + { + j = m[20 + i] ^ k[i]; + j = b[j] ^ g; + l[i] = c[j] ^ h; + } + for (i = 5, h = 0; --i >= 0; h = l[i]) { + j = m[15 + i] ^ l[i]; + j = b[j] ^ g; + j = c[j] ^ h; + k[i] = a[j] ^ c[j]; + } +} + +int main() +{ + c[4] = 0xdc; + d[4] = 0xcc; + test(4, a); + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20001108-1.c b/SingleSource/Regression/C/gcc-dg/20001108-1.c new file mode 100644 index 0000000000..1fc3e98e1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001108-1.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fomit-frame-pointer" } */ + +extern void abort (void); +extern void exit (int); + +void die (long) __attribute__ ((noreturn)); + +void die (long e) +{ + abort (); + for (;;); +} + +long foo (double i) +{ + if (i != 2.0) + abort (); + return 26; +} + +long bar (long i, double x) +{ + if (x < 0) die (1); + return foo (x); +} + +int +main() +{ + if (bar (0, 2.0) != 26) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20001116-1.c b/SingleSource/Regression/C/gcc-dg/20001116-1.c new file mode 100644 index 0000000000..8b1e919c66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001116-1.c @@ -0,0 +1,11 @@ +/* This looks like a warning test, but it's actually a regression test for a + nasty ICE due to messed up parser context. Problem originally found + during bootstrap; this is synthetic. -zw */ +/* { dg-do compile } + { dg-options -Wempty-body } */ + +void foo (int x) +{ + if (x) + ; /* { dg-warning "empty body in an" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20001117-1.c b/SingleSource/Regression/C/gcc-dg/20001117-1.c new file mode 100644 index 0000000000..1b24300da8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001117-1.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -finstrument-functions" } */ +/* { dg-require-effective-target return_address } */ + +extern void abort (void); +extern void exit (int); + +double +foo (double a, double b) +{ + double c; + if (0.0 < a) + c = a; + else if (b > 0.0) + c = 0.0; + else + return 0; + return 2.0 * (b - c); +} + +int main () +{ + if (foo (1.0, 4.0) != 6.0) + abort (); + exit (0); +} + +/* Abort on non-NULL CALL_SITE to ensure that __builtin_return_address + was expanded properly. */ +void __attribute__((no_instrument_function)) +__cyg_profile_func_enter(void *this_fn, void *call_site) +{ + if (call_site == (void *)0) + abort (); +} + +void __attribute__((no_instrument_function)) +__cyg_profile_func_exit(void *this_fn, void *call_site) +{ + if (call_site == (void *)0) + abort (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/20001201-1.c b/SingleSource/Regression/C/gcc-dg/20001201-1.c new file mode 100644 index 0000000000..195801a418 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001201-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ +char *s = +"0123456789101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100103106109112115118121124127130133136139142145148151154157160163166169172175178181184187190193196199202205208211214217220223226229232235238241244247250253256259262265268271274277280283286289292295298301304307310313316319322325328331334337340343346349352355358361364367370373376379382385388391394397400403406409412415418421424427430433436439442445448451454457460463466469472475478481484487490493496499502" +"505x"; /* { dg-bogus "greater than the minimum length" } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/20001228-1.c b/SingleSource/Regression/C/gcc-dg/20001228-1.c new file mode 100644 index 0000000000..49aec96174 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20001228-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math -O2" } */ + +typedef struct +{ + float vs_data[75], vs_peak[75], vs_peak_speed[75]; + int vs_refresh_delay; + int vs_doublesize; +} Vis; + +void vis_timeout_func(Vis * vis) +{ + if (vis->vs_peak[0] < 0.0) + vis->vs_peak[0] = 0.0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20010202-1.c b/SingleSource/Regression/C/gcc-dg/20010202-1.c new file mode 100644 index 0000000000..5f789042eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20010202-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target i?86-*-* sparc*-*-* x86_64-*-* } } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); + +typedef enum { false, true } __attribute__ ((packed)) boolean; +typedef struct { + enum { + A0 = 0, A1 = 1, A2 = 2 + } __attribute__((packed)) A:3; + enum { + B0 = 0, B1 = 1, B2 = 2 + } __attribute__((packed)) B:3; + boolean C:1; + boolean D:1; + unsigned char :8; +} foo; +foo x = { A2, B1, false, true }; + +int main(void) +{ + if (sizeof (foo) != 2 || __alignof__ (foo) != 1) + abort (); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20010405-1.c b/SingleSource/Regression/C/gcc-dg/20010405-1.c new file mode 100644 index 0000000000..b4d57a5d81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20010405-1.c @@ -0,0 +1,19 @@ +__inline__ double bar(double *x) +{ + static double a; + a = *x >= 0 ? *x : -*x; + return a; +} + +int main(void) +{ + extern double bar(); + double a; + static double b; + int r; + for (r = 1; r < 3; r++) { + a = 1.0; + b = bar(&a); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20010516-1.c b/SingleSource/Regression/C/gcc-dg/20010516-1.c new file mode 100644 index 0000000000..fbafe98e49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20010516-1.c @@ -0,0 +1,8 @@ +/* { dg-options "-fshow-column" } */ + +void +foo() +{ + char d; + __asm volatile ( "" :: "m"(&d)); /* { dg-error "34:" "non-lvalue" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20010622-1.c b/SingleSource/Regression/C/gcc-dg/20010622-1.c new file mode 100644 index 0000000000..dc4b28ccb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20010622-1.c @@ -0,0 +1,11 @@ +/* Test for segfault doing -Wsequence-point processing on an empty + statement expression. */ +/* Origin: PR c/3259 from . */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +void +f (void) +{ + ({ }); +} diff --git a/SingleSource/Regression/C/gcc-dg/20010822-1.c b/SingleSource/Regression/C/gcc-dg/20010822-1.c new file mode 100644 index 0000000000..b1c1cd45a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20010822-1.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* { dg-options "-Os" } */ + +extern void abort (void); + +void foo (unsigned long x) +{ +} + +typedef struct a { + volatile unsigned int a1, a2, a3, a4, a5; +} *A; +typedef struct { + volatile unsigned int b1, b2, b3, b4, b5; +} *B; +struct C { + void *c1, *c2; + A c3; + unsigned char c4; +}; + +void +bar (struct C *c, unsigned int *d) +{ + *d = *d | 1; + ((c->c4 >= 2) + ? (*(volatile unsigned int *) ((void *)(&((A)c->c3)->a5)) = *d) + : (*(volatile unsigned int *) ((void *)(&((B)c->c3)->b5)) = *d)); + + foo (50); +} + +int main (void) +{ + struct a a; + struct C c; + unsigned int d = 8; + c.c3 = &a; + c.c4 = 0; + bar (&c, &d); + if (a.a5 != 9) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20010912-1.c b/SingleSource/Regression/C/gcc-dg/20010912-1.c new file mode 100644 index 0000000000..bf81e3bac8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20010912-1.c @@ -0,0 +1,48 @@ +/* { dg-do run { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +extern void abort (void); +extern void exit (int); + +int bar (int x, char **y) +{ + if (x != 56) + abort (); + if (**y != 'a') + abort (); + *y = "def"; + return 1; +} + +int baz (int x, char **y) +{ + if (x != 56) + abort (); + if (**y != 'a') + abort (); + return 26; +} + +int foo (int x, char *y) +{ + int a; + char *b = y; + a = bar (x, &y); + if (a) + { + y = b; + a = baz (x, &y); + } + if (a) + return a; + + baz (x, &y); + return 0; +} + +int main () +{ + if (foo (56, "abc") != 26) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20011008-1.c b/SingleSource/Regression/C/gcc-dg/20011008-1.c new file mode 100644 index 0000000000..e3991471a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20011008-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -fshow-column" } */ + +struct { int; int q; } a; /* { dg-warning "13:does not declare anything" } */ +struct { union {int x;}; int q; } b; +struct { struct {int x;}; int q; } c; +union { union {int x;}; int q; } d; +union { struct {int x;}; int q; } e; diff --git a/SingleSource/Regression/C/gcc-dg/20011008-2.c b/SingleSource/Regression/C/gcc-dg/20011008-2.c new file mode 100644 index 0000000000..0ea0229ba5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20011008-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +extern void abort (void); +extern void exit (int); + +struct { union {int x; int y;}; int q; } b; +union { struct {int x;}; int q; } e; + +int +main() +{ + b.y = 10; + b.x = 15; + if (b.y != 15) + abort(); + + e.x = 10; + e.q = 15; + if (e.x != 15) + abort(); + + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20011015-1.c b/SingleSource/Regression/C/gcc-dg/20011015-1.c new file mode 100644 index 0000000000..0b751bf409 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20011015-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -std=gnu99" } */ + +char foo (char *x) +{ + return *x; +} + +void bar (char *x) +{ + void *arr[foo (x)] __attribute__((unused)); +} + +void baz (char *x) +{ + bar (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/20011021-1.c b/SingleSource/Regression/C/gcc-dg/20011021-1.c new file mode 100644 index 0000000000..2d567a7538 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20011021-1.c @@ -0,0 +1,45 @@ +/* Test for various initializer warnings being suppressed by use of + designated initializers. */ + +/* { dg-do compile } */ +/* { dg-options "-std=c99 -W -Wall -Wtraditional" } */ + + +struct t +{ + int a; + int b; /* { dg-message "note: 'b' declared here" } */ + int c; +}; + +union u +{ + int n; + float i; +}; + +struct multilevel +{ + int x; + struct t t; + union u u; + union u v; + char *f; /* { dg-line multilevel_f } */ +}; + +struct t T0 = { 1 }; /* { dg-warning "missing init" } */ + +struct t T1 = { .a = 1 }; /* { dg-bogus "(missing|near) init" } */ + +union u U0 = { 1 }; /* { dg-warning "initialization of union" } */ +union u U1 = { .i = 1 }; /* { dg-bogus "initialization of union" } */ + +struct multilevel M = +{ + 12, + { .b = 3 }, /* { dg-bogus "missing init" } */ + { 4 }, /* { dg-warning "initialization of union" } */ + { .n = 9 }, /* { dg-bogus "initialization of union" } */ + /* "string here" */ +}; /* { dg-warning "missing init" } */ +/* { dg-message "declared here" "near init" { target *-*-* } multilevel_f } */ diff --git a/SingleSource/Regression/C/gcc-dg/20011130-1.c b/SingleSource/Regression/C/gcc-dg/20011130-1.c new file mode 100644 index 0000000000..60a2738fc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20011130-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -g -finline-limit=100" } */ + +#define WORK(x, y) __asm__ ("" : "=r" (x) : "0" (x)); y += x + 26 +#define SOME_WORK(x, y) WORK(x, y); WORK(x, y); WORK(x, y); WORK(x, y) +#define MORE_WORK(x, y) SOME_WORK(x, y); SOME_WORK(x, y); SOME_WORK(x, y) +#define EVEN_MORE_WORK(x, y) MORE_WORK(x, y); MORE_WORK(x, y); MORE_WORK(x, y) +#define LOTS_OF_WORK(x, y) EVEN_MORE_WORK(x, y); EVEN_MORE_WORK(x, y) + +static int __attribute__((unused)) foo (int x) +{ + inline int bar (int x) + { + int y; + y = x; + LOTS_OF_WORK(x, y); + LOTS_OF_WORK(x, y); + LOTS_OF_WORK(x, y); + LOTS_OF_WORK(x, y); + LOTS_OF_WORK(x, y); + LOTS_OF_WORK(x, y); + return y; + } + return bar(x); +} diff --git a/SingleSource/Regression/C/gcc-dg/20011214-1.c b/SingleSource/Regression/C/gcc-dg/20011214-1.c new file mode 100644 index 0000000000..dd05798fab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20011214-1.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +extern void abort (void); +extern void exit (int); + +#define small __attribute__((mode(QI))) int +int main() +{ + int x, y = 0x400; + + x = (small) y; /* { dg-bogus "ignored" } */ + if (sizeof (small) != sizeof (char)) /* { dg-bogus "ignored" } */ + abort (); + if (sizeof (x) != sizeof (char) && x == y) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020103-1.c b/SingleSource/Regression/C/gcc-dg/20020103-1.c new file mode 100644 index 0000000000..4209486b81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020103-1.c @@ -0,0 +1,39 @@ +/* Verify that constant equivalences get reloaded properly, either by being + spilled to the stack, or regenerated, but not dropped to memory. */ +/* { dg-do compile { target { { i?86-*-* rs6000-*-* alpha*-*-* x86_64-*-* } || { powerpc*-*-* && ilp32 } } } } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fpic -fno-omit-frame-pointer -fno-asynchronous-unwind-tables" } */ +/* { dg-final { scan-assembler-not "LC\[0-9\]" } } */ + +/* Clobber all call-saved registers that can hold a pointer value. */ +#if defined(__i386__) +#define clobber \ + asm volatile("#asm" : : : "si", "di") +#elif defined(__powerpc__) || defined(__PPC__) || defined(__ppc__) || defined(__POWERPC__) || defined(PPC) || defined (_IBMR2) || defined (__ppc) +#define clobber \ + asm volatile("#asm" : : : "14", "15", "16", "17", "18", "19", "20", \ + "21", "22", "23", "24", "25", "26", "27", "28", "29") +#elif defined(__alpha__) +#define clobber \ + asm volatile("#asm" : : : "$9", "$10", "$11", "$12", "$13", "$14", \ + "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", "$f9") +#elif defined(__x86_64__) +#define clobber \ + asm volatile("#asm" : : : "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11") +#else +#error no clobber macro defined +#endif + +extern void f1(int, int, int); +extern void f2(int*, int*, int*); + +extern int ext; +static int loc_small; +static int loc_big[100]; + +void bar(void) +{ + f1(ext, loc_small, loc_big[0]); + clobber; + f2(&ext, &loc_small, &loc_big[0]); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020104-1.c b/SingleSource/Regression/C/gcc-dg/20020104-1.c new file mode 100644 index 0000000000..be36a7427a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020104-1.c @@ -0,0 +1,22 @@ +/* Test whether statement with no effect warnings are not given for last + statements inside of statement expression. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wall" } */ + +void bar (char *p, char *q); + +int main() +{ + char foo [32], *p; + + ({ + void *s = (foo); + __builtin_memset (s, '\0', sizeof (foo)); + s; /* { dg-warning "no effect" "statement with no effect warning" } */ + s; /* { dg-bogus "no effect" "bogus statement with no effect warning" } */ + }); + p = foo; + p; /* { dg-warning "no effect" "statement with no effect warning" } */ + bar (foo, p); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020108-1.c b/SingleSource/Regression/C/gcc-dg/20020108-1.c new file mode 100644 index 0000000000..89ffcaa12b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020108-1.c @@ -0,0 +1,17 @@ +/* This testcase failed on i686 because (const_int -1) was changed into + (const_int 0xffff) when storing it into SImode pseudo, but was not + converted back to (const_int -1) when returning from store_expr, + even though target was (subreg:HI (reg/v:SI indx)). But (const_int 0xffff) + is not valid general_operand in HImode. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + + +void +foo (unsigned short *cp) +{ + unsigned short indx; + + *cp = indx = 0xFFFF; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020115-1.c b/SingleSource/Regression/C/gcc-dg/20020115-1.c new file mode 100644 index 0000000000..9d4ea5491f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020115-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +/* Test attributes in function arguments. */ +/* Origin: Aldy Hernandez . */ + +#define blah __attribute__((__mode__(QI))) + +extern void bar(int *); + +void foo (blah int abc) +{ + + int b[sizeof(abc) == 1 ? 1 : -1]; + bar (b); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020116-1.c b/SingleSource/Regression/C/gcc-dg/20020116-1.c new file mode 100644 index 0000000000..d554675bc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020116-1.c @@ -0,0 +1,16 @@ +/* This testcase ICEd on Alpha because ldq_u argument was not subject to + small_symbolic_mem_operand splitting. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -fpic -mexplicit-relocs -mcpu=ev4" { target alpha*-*-* } } */ + +static char a; +char *b; + +void foo (void) +{ + register char *c; + + c = b; + *c = a; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020122-1.c b/SingleSource/Regression/C/gcc-dg/20020122-1.c new file mode 100644 index 0000000000..b13752f645 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020122-1.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2002 Free Software Foundation. + by Hans-Peter Nilsson */ + +/* { dg-do compile } */ + +typedef struct + { + unsigned short s; + } t; + +struct u + { + t v; + }; + +int +foo (struct u *uu) +{ + int i = ((unsigned int) ((uu->v) & 42)); /* { dg-error "invalid operands to binary" } */ + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020122-2.c b/SingleSource/Regression/C/gcc-dg/20020122-2.c new file mode 100644 index 0000000000..684ea5cff7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020122-2.c @@ -0,0 +1,42 @@ +/* This test was supplied with PR target/5379. It caused the compiler + to get a segmentation fault. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */ +/* { dg-additional-options "-march=athlon" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern int access( char* ); +extern int strcmp(const char *s1, const char *s2); +extern int a(); +char* foocp(); + +void +_KDE_IceGetPoValidAuthIndices (protocol_name, num_indices_ret, indices_ret) +const char *protocol_name; +int *num_indices_ret; +int *indices_ret; +{ + int auth_file; + char *filename; + int index_ret, i; + + if (!(filename = foocp ())) + return; + + if (access (filename)) + return; + + if (auth_file = access (filename)) + return; + + for (;;) + { + if (strcmp (protocol_name, protocol_name) == 0 ) + { + for (i = 0; i < *num_indices_ret; i++) + if (index_ret == indices_ret[i]) + break; + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/20020122-3.c b/SingleSource/Regression/C/gcc-dg/20020122-3.c new file mode 100644 index 0000000000..e39bd23a5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020122-3.c @@ -0,0 +1,15 @@ +/* Check that the combination of -Os and -fprefetch-loop-arrays does not + cause the compiler to crash, which it originally did on i?86. + Warnings are turned off because not all targets support prefetch. */ + +/* { dg-do compile } */ +/* { dg-options "-Os -fprefetch-loop-arrays -w" } */ +/* { dg-options "-Os -fprefetch-loop-arrays -mtune=pentium3 -w" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +int foo (int *p, int n) +{ + int i, r; + for (i = 0; i < n; i++) + r += p[i]; + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020122-4.c b/SingleSource/Regression/C/gcc-dg/20020122-4.c new file mode 100644 index 0000000000..50aef19509 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020122-4.c @@ -0,0 +1,11 @@ +/* Alpha -msmall-data didn't transform (mem (symbol_ref)) to + (mem (lo_sum pic (symbol_ref))) within an asm at the right time. */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +void foo() +{ + static int test; + int dummy; + asm volatile ("" : "=m"(test), "=r"(dummy) : "m"(test)); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020201-1.c b/SingleSource/Regression/C/gcc-dg/20020201-1.c new file mode 100644 index 0000000000..1cb2a87880 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020201-1.c @@ -0,0 +1,38 @@ +/* Check that arc profiling instrumentation code does not cause problems for + a program that calls functions that are likely to be in a shared library. + This was added to check the fix for PR target/5469, which prevents arc + profiling code from being inserted between a call and the restore of the + call-clobbered global pointer. */ + +/* { dg-options "-fprofile-arcs" } */ +/* { dg-do run { target native } } */ + +#include + +int globvar; + +void +leave (int i) +{ + if (i != 0) + abort (); + exit (0); +} + +void +doit () +{ + srand (12); + globvar = rand (); + if (rand () > 0) + globvar = 0; + leave (globvar); +} + +int +main () +{ + doit (); +} + +/* { dg-final { cleanup-coverage-files } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20020206-1.c b/SingleSource/Regression/C/gcc-dg/20020206-1.c new file mode 100644 index 0000000000..4b3d0fc767 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020206-1.c @@ -0,0 +1,45 @@ +/* This code is from the beginning of combine_reloads in reload.c in + GCC 3.1-20020117, with simplifications. It compiled incorrectly + for -O2 -fprefetch-loop-arrays for ix86 targets. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -mtune=pentium3 -w" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + + +struct reload +{ + int first_member; + int out; + int final_member; +}; + +int n_reloads; +struct reload rld[10]; + +static int +combine_reloads () +{ + int i; + int output_reload = -1; + int secondary_out = -1; + + for (i = 0; i < n_reloads; i++) + if (rld[i].out != 0) + { + if (output_reload >= 0) + return output_reload; + output_reload = i; + } + return output_reload; +} + +int +main () +{ + n_reloads = 4; + rld[2].out = 2; + if (combine_reloads () != 2) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020210-1.c b/SingleSource/Regression/C/gcc-dg/20020210-1.c new file mode 100644 index 0000000000..369963b25b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020210-1.c @@ -0,0 +1,28 @@ +/* This used to fail on H8/300 due to incorrect specification of pushi1. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -fomit-frame-pointer" { target h8300-*-* } } */ + +extern void abort (void); +extern void exit (int); + +void +bar (int a, int b, int c, int d, int e) +{ + if (d != 1) + abort (); +} + +void +foo (int a, int b, int c, int d, int e) +{ + bar (a, b, c, d, e); +} + +int +main () +{ + foo (0, 0, 0, 1, 2); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020219-1.c b/SingleSource/Regression/C/gcc-dg/20020219-1.c new file mode 100644 index 0000000000..055b5b935e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020219-1.c @@ -0,0 +1,50 @@ +/* PR c/4389 + This testcase failed because host_integerp (x, 0) was returning + 1 even for constants bigger than 2^31. It fails under hppa + hpux without -mdisable-indexing because the pointer x - 1 is used + as the base address of an indexed load. Because the struct A is not + actually allocated, x - 1 lies in the text segment and this causes + the wrong space register to be selected for the load. It fails on + IA64 hpux in ILP32 mode because extending x - 1 before adding the + array offset gives a different answer then adding first and then + extending. The underlying problem is the same as with hppa, x - 1 is + not a legal data address. It also fails on x32 targets for the + same reason. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mdisable-indexing" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "" { aarch64*-*-* && ilp32 } } */ +/* { dg-skip-if "" { "ia64-*-hpux*" } "*" "-mlp64" } */ +/* { dg-skip-if "" { { i?86-*-* x86_64-*-* } && x32 } } */ + +/* Disable the test entirely for 16-bit targets. */ +#if __INT_MAX__ > 32767 + +extern void abort (void); +extern void exit (int); +struct A { + int a[10000][10000]; +}; +int b[2] = { 213151, 0 }; + +void foo (struct A *x, int y) +{ + if (x->a[9999][9999] != x->a[y][y]) + abort (); + if (x->a[9999][9999] != 213151) + abort (); +} + +int main (void) +{ + struct A *x; + asm ("" : "=r" (x) : "0" (&b[1])); + foo (x - 1, 9999); + exit (0); +} + +#else + +int main () { return 0; } + +#endif /* __INT_MAX__ */ diff --git a/SingleSource/Regression/C/gcc-dg/20020220-1.c b/SingleSource/Regression/C/gcc-dg/20020220-1.c new file mode 100644 index 0000000000..aa948aa15e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020220-1.c @@ -0,0 +1,19 @@ +/* PR c++/4574 + This testcase ICEd because expand_and did not handle VOIDmode + CONST_DOUBLE arguments. */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +struct A { + unsigned long long b : 8; + unsigned long long c : 18; +}; + +int main() +{ + struct A a; + long long l; + + l = a.c = 0x123456789aULL; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020220-2.c b/SingleSource/Regression/C/gcc-dg/20020220-2.c new file mode 100644 index 0000000000..95606703cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020220-2.c @@ -0,0 +1,12 @@ +/* PR c/4697 + Test whether operand has no effect warning is given for compound + expression. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wunused" } */ + +int b; +int foo (int a) +{ + a = a + 1, 5 * b; /* { dg-warning "right-hand operand of comma expression has no effect" } */ + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020222-1.c b/SingleSource/Regression/C/gcc-dg/20020222-1.c new file mode 100644 index 0000000000..d2cf5fe6aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020222-1.c @@ -0,0 +1,34 @@ +/* PR optimization/5747 + This testcase ICEd on sparc because move_movables created new pseudos, + but did not update reg info which load_mems needed. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -fPIC" { target fpic } } */ + +extern void foo (void); +static char a[256]; + +void +bar (void) +{ + unsigned int i; + static int b = 0; + int c; + + if (b == 0) + { + b = 1; + foo (); + c = 0; + for (i = 0; i < 10; i++) + a[i + '0'] = c++; + for (i = 'A'; i <= 'Z'; i++) + a[i] = c++; + a['$'] = c++; + a['%'] = c++; + a['.'] = c++; + a['_'] = c++; + for (i = 'a'; i <= 'z'; i++) + a[i] = c++; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20020310-1.c b/SingleSource/Regression/C/gcc-dg/20020310-1.c new file mode 100644 index 0000000000..09b83225ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020310-1.c @@ -0,0 +1,55 @@ +/* PR optimization/5844 + This testcase was miscompiled because of an rtx sharing bug. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=i586" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-xfail-if "doesn't support self-referential initializers" { nvptx-*-* } } */ + +struct A +{ + struct A *a; + int b; +}; + +struct B +{ + struct A *c; + unsigned int d; +}; + +struct A p = { &p, -1 }; +struct B q = { &p, 0 }; + +extern void abort (void); +extern void exit (int); + +struct B * +foo (void) +{ + return &q; +} + +void +bar (void) +{ + struct B *e = foo (); + struct A *f = e->c; + int g = f->b; + + if (++g == 0) + { + e->d++; + e->c = f->a; + } + + f->b = g; +} + +int +main () +{ + bar (); + if (p.b != 0 || q.d != 1 || q.c != &p) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020312-1.c b/SingleSource/Regression/C/gcc-dg/20020312-1.c new file mode 100644 index 0000000000..978401862a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020312-1.c @@ -0,0 +1,10 @@ +/* This testcase ICEd on alpha because of an unrecognized insn formed + by conditional move optimization using an incorrect mode. */ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math" } */ + +char* +barf (double x) +{ + return (x<0.0) ? "foo" : "bar"; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020312-2.c b/SingleSource/Regression/C/gcc-dg/20020312-2.c new file mode 100644 index 0000000000..92bc150df0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020312-2.c @@ -0,0 +1,182 @@ +/* PR 5878. + + We ICEd in verify_local_live_at_start because we incorrectly forced + the PIC register live between BAR and BAZ. We did this because the + definition of PIC_OFFSET_TABLE_REGNUM was incorrectly not INVALID_REGNUM + when !flag_pic for most targets. */ + +/* { dg-do run } */ +/* { dg-options "-O -fno-pic" } */ +/* { dg-additional-options "-no-pie" { target pie_enabled } } */ +/* { dg-require-effective-target nonlocal_goto } */ +/* { dg-skip-if "" { arm*-*-uclinuxfdpiceabi } "*" "" } */ + +extern void abort (void); + +#if defined(__alpha__) +/* PIC register is $29, but is used even without -fpic. */ +#elif defined(__arc__) +# define PIC_REG "26" +#elif defined(__arm__) +# define PIC_REG "9" +#elif defined(AVR) +/* No pic register. */ +#elif defined(__cris__) +# define PIC_REG "0" +#elif defined(__epiphany__) +#define PIC_REG "r28" +#elif defined(__fr30__) +/* No pic register. */ +#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) +/* No pic register. */ +#elif defined(_IBMR2) +/* No pic register. */ +#elif defined(__i386__) +# define PIC_REG "ebx" +#elif defined(__ia64__) +/* PIC register is r1, but is used even without -fpic. */ +#elif defined(__lm32__) +/* No pic register. */ +#elif defined(__loongarch__) +/* No pic register. */ +#elif defined(__M32R__) +/* No pic register. */ +#elif defined(__m68k__) +# define PIC_REG "a5" +#elif defined(__mc68hc1x__) +/* No pic register. */ +#elif defined(__mcore__) +/* No pic register. */ +#elif defined(__MICROBLAZE__) +# define PIC_REG "r20" +#elif defined(__mips__) +/* PIC register is $28, but is used even without -fpic. */ +#elif defined(__MMIX__) +/* No pic register. */ +#elif defined(__mn10300__) +/* No pic register. */ +#elif defined(__moxie__) +/* No pic register. */ +#elif defined(__nds32__) +/* No pic register. */ +#elif defined(__nios2__) +/* No pic register. */ +#elif defined(__hppa__) +/* PIC register is %r27 or %r19, but is used even without -fpic. */ +#elif defined(__pdp11__) +/* No pic register. */ +#elif defined(__powerpc__) || defined(__PPC__) || defined(__POWERPC__) || defined (__ppc) +# ifdef __MACH__ +# define PIC_REG "31" +# else +# define PIC_REG "30" +# endif +#elif defined(__riscv) +/* No pic register. */ +#elif defined(__RX__) +/* No pic register. */ +#elif defined(__s390__) +# define PIC_REG "12" +#elif defined(__sparc__) +# define PIC_REG "l7" +#elif defined(__tile__) +# define PIC_REG "r51" +#elif defined(__TMS320C6X__) +# define PIC_REG "B14" +#elif defined(__v850) +/* No pic register. */ +#elif defined(__vax__) +/* No pic register. */ +#elif defined(__VISIUM__) +/* No pic register. */ +#elif defined(__xstormy16__) +/* No pic register. */ +#elif defined(__XTENSA__) +/* No pic register. */ +#elif defined(__sh__) +# define PIC_REG "r12" +#elif defined(__x86_64__) +/* No pic register. */ +#elif defined(__m32c__) +/* No pic register. */ +#elif defined (__frv__) +# ifdef __FRV_FDPIC__ +# define PIC_REG "gr15" +# else +# define PIC_REG "gr17" +#endif +#elif defined (__aarch64__) +/* No pic register -- yet. */ +#elif defined(__RL78__) +/* No pic register. */ +#elif defined(__MSP430__) +/* No pic register. */ +#elif defined (__nvptx__) +/* No pic register. */ +#elif defined (__csky__) +/* Pic register is r28, but some cores only have r0-r15. */ +# if defined (__CK807__) || defined (__CK810__) +# define PIC_REG "r28" +# endif +#elif defined (__or1k__) +/* No pic register. */ +#elif defined (__AMDGCN__) +/* No pic register. */ +#elif defined(__PRU__) +/* No pic register. */ +#else +# error "Modify the test for your target." +#endif + +#if defined PIC_REG && !defined __PIC__ && !defined __pic__ +register void *reg __asm__(PIC_REG); +#else +/* We really need a global register variable set to the PIC register + to expose the bug. Oh well, let the test case not fail. */ +static void *reg; +#endif + +void * __attribute__((noinline)) +dummy (void *x) +{ + return x; +} + +void +f (void) +{ + goto *dummy (&&bar); + for (;;) + { + foo: + reg = (void *) 1; + if (!reg) + goto baz; + reg = &&foo; + } + + bar: + baz: + reg = 0; +} + +int +main() +{ + void *old_reg = reg; + reg = (void *) 1; + + f (); + + /* Additionally test that the prologue/epilogue properly does *not* + save and restore global registers. Not possible when the PIC + register is in a register window, of course. On Darwin, you can't + call library routines from non-PIC code. */ +#if !defined (__sparc__) && !defined(__MACH__) + if (reg) + abort (); +#endif + + reg = old_reg; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020319-1.c b/SingleSource/Regression/C/gcc-dg/20020319-1.c new file mode 100644 index 0000000000..46a756d775 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020319-1.c @@ -0,0 +1,10 @@ +/* PR optimization/5999 + This testcase ICEd because one a/b -> a * (1/b) optimization + did not handle complex divides. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +__complex__ double foo (__complex__ double x, __complex__ double y) +{ + return x / y; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020411-1.c b/SingleSource/Regression/C/gcc-dg/20020411-1.c new file mode 100644 index 0000000000..55ca2997c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020411-1.c @@ -0,0 +1,54 @@ +/* PR c/6223 + This testcase ICEd in internal check because a constant was not truncated + for its mode. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#if __INT_MAX__ > 32767 + +typedef struct +{ + unsigned a : 16; + unsigned b : 16; + unsigned c : 5; + unsigned d : 2; + unsigned e : 1; + unsigned f : 4; + unsigned g : 1; + unsigned h : 1; + unsigned i : 1; + unsigned j : 1; +} T; + +inline void +foo (T *x, unsigned int y) +{ + if ((x->j = (y >= 0x100000))) + y >>= 12; + x->a = y; + x->f = (y >> 16); +} + +void __attribute__((noinline)) +bar (T *x) +{ +} + +void +baz (unsigned int x, unsigned char y) +{ + T t; + + foo (&t, x - 1); + t.e = 1; + t.c = y; + t.g = 0; + t.h = 0; + t.i = (y & 0x40) != 0; + if (x == 1) + foo (&t, 1); + bar (&t); +} + +#endif /* __INT_MAX__ */ diff --git a/SingleSource/Regression/C/gcc-dg/20020415-1.c b/SingleSource/Regression/C/gcc-dg/20020415-1.c new file mode 100644 index 0000000000..46a1bbddc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020415-1.c @@ -0,0 +1,36 @@ +/* PR target/6303 + This testcase ICEd because s390 did not define + ASM_SIMPLIFY_DWARF_ADDR hook. */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic -g" } */ +/* { dg-require-effective-target alloca } */ + +static inline char * +bar (unsigned long x, char *y) +{ + extern const char ext[]; + const char *a = ext; + char *b = y; + + do *--b = a[x % 10]; while ((x /= 10) != 0); + return b; +} + +struct A { char *p, *q; }; +struct B { int r, s; }; + +int +foo (struct A *a, const struct B *b) +{ + char c[(b->r > b->s) ? b->r : b->s]; + char *d = &c[sizeof c]; + register char *e; + + e = bar (b->r, d); + while (e < d) + { + register const int f = *e++; + if (((a->p >= a->q) ? 1 : (unsigned char) (*a->p++ = f)) == -1) + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20020418-1.c b/SingleSource/Regression/C/gcc-dg/20020418-1.c new file mode 100644 index 0000000000..456967fdd3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020418-1.c @@ -0,0 +1,27 @@ +/* PR optimization/5887 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -msse -ffast-math" { target i?86-*-* x86_64-*-* } } */ +/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ + +void bar (float *a, float *b); + +void foo (char *x) +{ + float a, b; + char c[256]; + int i, j; + + bar (&a, &b); + for (i = 0; i < 256; i++) + { + float v = a; + if (v < 0.0f) v = 0.0f; + if (v < 255.0f) v = 255.0f; + c[i] = v; + a += b; + } + + for (j = 0; j < 256; j++) + x[j] = c[j]; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020418-2.c b/SingleSource/Regression/C/gcc-dg/20020418-2.c new file mode 100644 index 0000000000..56094e71cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020418-2.c @@ -0,0 +1,21 @@ +/* PR optimization/6010 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-all-loops" } */ +/* { dg-options "-O2 -funroll-all-loops -march=pentium3" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +void bar (float); + +void foo (float y, unsigned long z) +{ + int b; + float c = y; + + for (b = 0; b < z; b++) + { + bar (c); + if (c == y) + c = -y; + else + c = y; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20020425-1.c b/SingleSource/Regression/C/gcc-dg/20020425-1.c new file mode 100644 index 0000000000..7783c8870c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020425-1.c @@ -0,0 +1,15 @@ +/* PR c/2161: parser stack overflow. */ +/* { dg-do compile } */ +/* { dg-timeout-factor 4.0 } */ + +#define ONE else if (0) { } +#define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +void foo() +{ + if (0) { } + /* 11,000 else if's. */ + THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU +} diff --git a/SingleSource/Regression/C/gcc-dg/20020426-2.c b/SingleSource/Regression/C/gcc-dg/20020426-2.c new file mode 100644 index 0000000000..96517f7b84 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020426-2.c @@ -0,0 +1,177 @@ +/* PR optimization/6475 + Distilled from zlib sources. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -frename-registers -fomit-frame-pointer -fPIC -mtune=i686" { target { { i?86-*-* x86_64-*-* } && { ia32 && fpic } } } } */ +/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ + +extern void exit (int); + +typedef struct +{ + union + { + struct + { + unsigned char a3; + unsigned char a4; + } a2; + unsigned int a5; + } a0; + unsigned int a1; +} A; + +static int +foo (unsigned int *b, unsigned int n, unsigned int s, const unsigned int *d, + const unsigned int *e, A **t, unsigned int *m, A *hp, unsigned int *hn, + unsigned int *v) +{ + unsigned int a, c[15 + 1], f; + int g, h; + unsigned int i, j, k; + int l; + unsigned int ee; + unsigned int *p; + A *q, r, *u[15]; + int w; + unsigned int x[15 + 1], *xx; + int y; + unsigned int z; + p = c; + *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0; + *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0; + *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0; + *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0; + p = b; + i = n; + do + c[*p++]++; + while (--i); + if (c[0] == n) + { + *t = (A *) 0; + *m = 0; + return 0; + } + l = *m; + for (j = 1; j <= 15; j++) + if (c[j]) + break; + k = j; + if ((unsigned int) l < j) + l = j; + for (i = 15; i; i--) + if (c[i]) + break; + g = i; + if ((unsigned int) l > i) + l = i; + *m = l; + for (y = 1 << j; j < i; j++, y <<= 1) + if ((y -= c[j]) < 0) + return -3; + if ((y -= c[i]) < 0) + return -3; + c[i] += y; + x[1] = j = 0; + p = c + 1; + xx = x + 2; + while (--i) + *xx++ = (j += *p++); + p = b; + i = 0; + do + if ((j = *p++) != 0) + v[x[j]++] = i; + while (++i < n); + n = x[g]; + x[0] = i = 0; + p = v; + h = -1; + w = -l; + u[0] = (A *) 0; + q = (A *) 0; + z = 0; + for (; k <= g; k++) + { + a = c[k]; + while (a--) + { + while (k > w + l) + { + h++; + w += l; + z = g - w; + z = z > (unsigned int) l ? l : z; + if ((f = 1 << (j = k - w)) > a + 1) + { + f -= a + 1; + xx = c + k; + if (j < z) + while (++j < z) + { + if ((f <<= 1) <= *++xx) + break; + f -= *xx; + } + } + z = 1 << j; + if (*hn + z > 1440) + return -3; + u[h] = q = hp + *hn; + *hn += z; + if (h) + { + x[h] = i; + r.a0.a2.a4 = (unsigned char) l; + r.a0.a2.a3 = (unsigned char) j; + j = i >> (w - l); + r.a1 = (unsigned int) (q - u[h - 1] - j); + u[h - 1][j] = r; + } + else + *t = q; + } + r.a0.a2.a4 = (unsigned char) (k - w); + if (p >= v + n) + r.a0.a2.a3 = 128 + 64; + else if (*p < s) + { + r.a0.a2.a3 = (unsigned char) (*p < 256 ? 0 : 32 + 64); + r.a1 = *p++; + } + else + { + r.a0.a2.a3 = (unsigned char) (e[*p - s] + 16 + 64); + r.a1 = d[*p++ - s]; + } + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) + q[j] = r; + for (j = 1 << (k - 1); i & j; j >>= 1) + i ^= j; + i ^= j; + ee = (1 << w) - 1; + while ((i & ee) != x[h]) + { + h--; + w -= l; + ee = (1 << w) - 1; + } + } + } + return y != 0 && g != 1 ? (-5) : 0; +} + +unsigned int a[19] = { 3, 4, 0, 2, 2, [17] = 3, 3 }; +unsigned int d[19]; +A h[1440]; + +int +main (void) +{ + unsigned int b = 0, c = 0; + A *e = 0; + foo (a, 19, 19, 0, 0, &e, &b, h, &c, d); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020430-1.c b/SingleSource/Regression/C/gcc-dg/20020430-1.c new file mode 100644 index 0000000000..f48bb672aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020430-1.c @@ -0,0 +1,196 @@ +/* PR opt/6516 */ +/* On x86, something about the structure of this function prevented + cross-jumping from combining the three arms of the switch statement + until the last moment. After which we did not delete dead code, + which left a reference to the deleted ADDR_VEC. */ + +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -frename-registers -fpic" } */ +/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */ + +typedef unsigned long XID; +typedef XID Window; +typedef void Display; +typedef unsigned long Time; + +typedef struct { + int type; + unsigned long serial; + int send_event; + Display *display; + Window window; + Window root; + Window subwindow; + Time time; + int x, y; + int x_root, y_root; + unsigned int state; + unsigned int button; + int same_screen; +} XButtonEvent; +typedef struct { + int type; + unsigned long serial; + int send_event; + Display *display; + Window window; + Window root; + Window subwindow; + Time time; + int x, y; + int x_root, y_root; + unsigned int state; + char is_hint; + int same_screen; +} XMotionEvent; +typedef struct { + int type; + unsigned long serial; + int send_event; + Display *display; + Window window; + Window root; + Window subwindow; + Time time; + int x, y; + int x_root, y_root; + int mode; + int detail; + int same_screen; + int focus; + unsigned int state; +} XCrossingEvent; +typedef union _XEvent { + int type; + XButtonEvent xbutton; + XMotionEvent xmotion; + XCrossingEvent xcrossing; +} XEvent; + +typedef struct { + int width, height; + Display *display; +} Screen; +typedef struct _CorePart { + Screen *screen; +} CorePart; +typedef struct _WidgetRec { + CorePart core; +} WidgetRec; +typedef struct _WidgetRec *Widget; + +typedef struct _SmeRec *SmeObject; +typedef struct _SimpleMenuPart { + SmeObject entry_set; +} SimpleMenuPart; +typedef struct _SimpleMenuRec { + SimpleMenuPart simple_menu; +} SimpleMenuRec; +typedef struct _SimpleMenuRec* SimpleMenuWidget; + +typedef short Position; +typedef unsigned short Dimension; +typedef char Boolean; + +typedef struct _RectObjPart { + Position x, y; + Dimension width, height; + Dimension border_width; + Boolean managed; + Boolean sensitive; + Boolean ancestor_sensitive; +}RectObjPart; +typedef struct _RectObjRec { + RectObjPart rectangle; +} RectObjRec; +typedef struct _RectObjRec *RectObj; + +SmeObject DoGetEventEntry(); +int XtWidgetToApplicationContext(); +void XtAppError(); +void Unhighlight(); +void XtMoveWidget(); +void XWarpPointer(); + +SmeObject +GetEventEntry(Widget w, XEvent *event) +{ + int x_loc, y_loc, x_root; + SimpleMenuWidget smw = (SimpleMenuWidget)w; + SmeObject entry; + int warp, move; + switch (event->type) { + case 6: + x_loc = event->xmotion.x; + y_loc = event->xmotion.y; + x_root = event->xmotion.x_root; + break; + case 7: + case 8: + x_loc = event->xcrossing.x; + y_loc = event->xcrossing.y; + x_root = event->xcrossing.x_root; + break; + case 4: + case 5: + x_loc = event->xbutton.x; + y_loc = event->xbutton.y; + x_root = event->xbutton.x_root; + break; + default: + XtAppError(XtWidgetToApplicationContext(w), + "Unknown event type in GetEventEntry()."); + return (((void *)0)); + } + if (x_loc < 0 || x_loc >= (((RectObj)smw)->rectangle.width) || + y_loc < 0 || y_loc >= (((RectObj)smw)->rectangle.height)) + return (((void *)0)); + if (x_root == ((((w)->core.screen))->width) - 1 && + (((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width)) > x_root) { + warp = -8; + if (smw->simple_menu.entry_set) { + entry = DoGetEventEntry(w, + (((RectObj)smw->simple_menu.entry_set)->rectangle.x) + + (((RectObj)smw->simple_menu.entry_set)->rectangle.width) + 1, + y_loc); + Unhighlight(w, event, ((void *)0), ((void *)0)); + if (entry) { + warp = -(int)(((RectObj)entry)->rectangle.width) >> 1; + move = x_loc - (((RectObj)entry)->rectangle.width) - (((RectObj)entry)->rectangle.x) + (((RectObj)w)->rectangle.border_width); + } + else { + warp = 0; + move = ((((w)->core.screen))->width) - + ((((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width) << 1)); + } + } + else { + warp = 0; + move = ((((w)->core.screen))->width) - + ((((RectObj)w)->rectangle.x) + (((RectObj)w)->rectangle.width) + ((((RectObj)w)->rectangle.border_width) << 1)); + } + } + else if (x_root == 0 && (((RectObj)w)->rectangle.x) < 0) { + warp = 8; + if (smw->simple_menu.entry_set) { + entry = DoGetEventEntry(w, (((RectObj)smw->simple_menu.entry_set)->rectangle.x) - 1, + y_loc); + Unhighlight(w, event, ((void *)0), ((void *)0)); + if (entry) { + warp = (((RectObj)entry)->rectangle.width) >> 1; + move = x_loc - (((RectObj)entry)->rectangle.x); + } + else + move = x_loc + (((RectObj)w)->rectangle.border_width); + } + else + move = x_loc + (((RectObj)w)->rectangle.border_width); + } + else + move = warp = 0; + if (move) + XtMoveWidget(w, (((RectObj)w)->rectangle.x) + move, (((RectObj)w)->rectangle.y)); + if (warp) + XWarpPointer((((w)->core.screen)->display), 0L, 0L, 0, 0, 0, 0, warp, 0); + return (DoGetEventEntry(w, x_loc, y_loc)); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020503-1.c b/SingleSource/Regression/C/gcc-dg/20020503-1.c new file mode 100644 index 0000000000..e13cf954ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020503-1.c @@ -0,0 +1,11 @@ +/* PR target/6542 + This testcase caused ICE on SPARC because the function uses no registers + after optimizing, so even if -mflat make all registers not permitted + for leaf functions, the function was still leaf, but LEAF_REG_REMAP + returned -1 for some registers (like %o0). */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -mflat" { target sparc*-*-* } } */ + +void foo (char *a, char *b, char *c, char *d) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/20020517-1.c b/SingleSource/Regression/C/gcc-dg/20020517-1.c new file mode 100644 index 0000000000..74c6b3e6ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020517-1.c @@ -0,0 +1,28 @@ +/* This testcase caused ICE in do_SUBST on IA-32, because 0xf6 constant + was not sign-extended for QImode. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#include + +void abort (void); +void exit (int); + +void foo (void) +{ + int i; + char *p; + + p = (char *) &i; + *p = -10; + if (* (unsigned char *) p != 0x100 - 10) + abort (); +} + +int main (void) +{ + if (UCHAR_MAX == 255) + foo (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020525-1.c b/SingleSource/Regression/C/gcc-dg/20020525-1.c new file mode 100644 index 0000000000..7db44f0b2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020525-1.c @@ -0,0 +1,24 @@ +/* PR optimization/6703 + Origin: Glen Nakamura */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); + +void foo (int *x, int y) +{ + __builtin_memset (x, 0, y); +} + +int main () +{ + int x[2] = { -1, -1 }; + + if (x[1] != -1) + abort (); + foo (x, sizeof (int) + 1); + if (x[1] == -1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20020527-1.c b/SingleSource/Regression/C/gcc-dg/20020527-1.c new file mode 100644 index 0000000000..6f963ed9f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020527-1.c @@ -0,0 +1,54 @@ +/* PR c/6660 + Test whether an unnamed field with user defined type - struct or union is + accepted. */ +/* { dg-do compile } */ +/* { dg-options "-fms-extensions" } */ + +typedef struct { + unsigned short a; + unsigned short b; +} __attribute__ ((__packed__)) A; + +typedef struct B_ { + unsigned int c; + unsigned int d; +} B; + +typedef struct C_ { + B; + unsigned int e; + unsigned int f; +} C; + +typedef C D; + +typedef struct { + A; + D; + struct { + unsigned short g; + unsigned short h; + } __attribute__ ((__packed__)); + union { + int i; + long j; + }; + int k; +} __attribute__ ((__packed__)) E; + +E x; + +void foo (void) +{ + x.a = 1; + x.b = 2; + x.c = 3; + x.d = 4; + x.e = 5; + x.f = 6; + x.g = 7; + x.h = 8; + x.i = 9; + x.j = 10; + x.k = 11; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020530-1.c b/SingleSource/Regression/C/gcc-dg/20020530-1.c new file mode 100644 index 0000000000..b2d0ecda51 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020530-1.c @@ -0,0 +1,20 @@ +/* PR c/6809 + Test -fverbose-asm with unnamed fields. */ +/* { dg-do compile } */ +/* { dg-options "-fverbose-asm" } */ + +typedef union U +{ + struct + { + unsigned int a; + int b; + }; + long long c; +} *T; + +int foo (T x) +{ + int r = x->a + x->b; + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020607-1.c b/SingleSource/Regression/C/gcc-dg/20020607-1.c new file mode 100644 index 0000000000..afad78d8cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020607-1.c @@ -0,0 +1,40 @@ +/* PR middle-end/6950 + gcc 3.0.4 mistakenly set lhs.low to 0 at the beginning of the num_eq + expansion; it should use a temporary. +/* { dg-do run } */ + +typedef struct cpp_num cpp_num; +struct cpp_num +{ + long high; + long low; + char overflow; +}; + +#define num_eq(num1, num2) (num1.low == num2.low && num1.high == num2.high) + +static cpp_num +num_equality_op (lhs, rhs) + cpp_num lhs, rhs; +{ + lhs.low = num_eq (lhs, rhs); + lhs.high = 0; + lhs.overflow = 0; + return lhs; +} + +int main() +{ + cpp_num a = { 1, 2 }; + cpp_num b = { 3, 4 }; + + cpp_num result = num_equality_op (a, b); + if (result.low) + return 1; + + result = num_equality_op (a, a); + if (!result.low) + return 2; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20020607-2.c b/SingleSource/Regression/C/gcc-dg/20020607-2.c new file mode 100644 index 0000000000..239aa9b388 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020607-2.c @@ -0,0 +1,74 @@ +/* Copyright (C) 2002 Free Software Foundation. + + Test for correctness of floating point comparisons. + + Written by Roger Sayle, 3rd June 2002. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void abort (void); + +int test1 (double x, int ok) +{ + if ((x - 1.0) > 0.0) + { + if (!ok) abort (); + } + else + if (ok) abort (); +} + +int test1f (float x, int ok) +{ + if ((x - 1.0f) > 0.0f) + { + if (!ok) abort (); + } + else + if (ok) abort (); +} + +int test2 (double x, int ok) +{ + if ((x + 1.0) < 0.0) + { + if (!ok) abort (); + } + else + if (ok) abort (); +} + +int test2f (float x, int ok) +{ + if ((x + 1.0f) < 0.0f) + { + if (!ok) abort (); + } + else + if (ok) abort (); +} + + +int +main () +{ + test1 (-2.0, 0); + test1 ( 0.0, 0); + test1 ( 2.0, 1); + + test1f (-2.0f, 0); + test1f ( 0.0f, 0); + test1f ( 2.0f, 1); + + test2 (-2.0, 1); + test2 ( 0.0, 0); + test2 ( 2.0, 0); + + test2f (-2.0f, 1); + test2f ( 0.0f, 0); + test2f ( 2.0f, 0); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20020919-1.c b/SingleSource/Regression/C/gcc-dg/20020919-1.c new file mode 100644 index 0000000000..38add3a45f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20020919-1.c @@ -0,0 +1,258 @@ +/* Copyright (C) 2002 Free Software Foundation. + by Hans-Peter Nilsson + + Making sure that asm clobbers conflicting with asm-declared input + operands are detected: ``You may not write a clobber description in a + way that overlaps with an input or output operand''. + + You must be this tall ---> fit two long longs in asm-declared registers + to enter this amusement. */ + +/* { dg-do compile { target alpha*-*-* cris-*-* i?86-*-* mmix-*-* powerpc*-*-* rs6000-*-* x86_64-*-* } } */ +/* { dg-options "-O2" } */ + +/* Constructed examples; input/output (same register), output, input, and + input and output (different registers). */ + +/* The long longs are used to test overlap for multi-register + registers. REG2 and REG4 must be the second halves (defined as + higher-numbered parts) of REG1 and REG3 respectively when two registers + are needed. */ + +#if defined (__alpha__) +# define REG1 "$1" +# define REG2 "$2" +#elif defined (__CRIS__) +# define REG1 "r10" +# define REG2 "r11" +# define REG3 "r12" +# define REG4 "r13" +# define REG5 "r9" +#elif defined (__i386__) +# define REG1 "%eax" +# define REG2 "%edx" +/* On Darwin -fpic is on by default, so don't use %ebx. */ +# define REG3 "%esi" +# define REG4 "%edi" +#elif defined (__MMIX__) +# define REG1 "$8" +# define REG2 "$9" +#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \ + || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2) \ + || defined (__ppc) +# define REG1 "6" +# define REG2 "7" +# if !defined(_ARCH_PPC64) +# define REG3 "8" +# define REG4 "9" +# endif +#elif defined (__x86_64__) +# define REG1 "rax" +# define REG2 "rdx" +#endif + +/* For readability of the tests. */ +#ifdef REG3 +# define REG1a REG1 +# define REG1b REG2 +# define REG2a REG3 +# define REG2b REG4 +#else +# define REG1a REG1 +# define REG1b REG1 +# define REG2a REG2 +# define REG2b REG2 +#endif + +/* REG5 is just another reg if there is one; the difference to REG4 is to + keep the original set of registers for CRIS. */ +#ifndef REG5 +#define REG5 REG2b +#endif + +void * +foo (void *p) +{ + register void *q asm (REG1) = p; + asm ("foo1 %0" : "=r" (q) : "0" (q) : REG1); /* { dg-error "conflict" } */ + return q; +} + +void * +nfoo (void *p) +{ + register void *q asm (REG1) = p; + asm ("foo1 %0" : "=r" (q) : "0" (q) : REG2); + return q; +} + +long long +foolla (long long llp) +{ + register long long ll asm (REG1a) = llp; + asm ("foo1a %0" : "=r" (ll) : "0" (ll) : REG1a); /* { dg-error "conflict" } */ + return ll; +} + +long long +nfoolla (long long llp) +{ + register long long ll asm (REG1a) = llp; + asm ("foo1a %0" : "=r" (ll) : "0" (ll) : REG2a); + return ll; +} + +long long +foollb (long long llp) +{ + register long long ll asm (REG1a) = llp; + asm ("foo1b %0" : "=r" (ll) : "0" (ll) : REG1b); /* { dg-error "conflict" } */ + return ll; +} + +void * +bar (void *p) +{ + register void *q asm (REG1); + register void *w asm (REG2) = p; + asm ("bar1 %1,%0" : "=r" (q) : "r" (w) : REG1); /* { dg-error "conflict" } */ + return q; +} + +long long +barlla (long long llp) +{ + register long long ll asm (REG1a); + register long long mm asm (REG2a) = llp; + asm ("bar1a %1,%0" : "=r" (ll) : "r" (mm) : REG1b); /* { dg-error "conflict" } */ + return ll; +} + +long long +barllb (long long llp) +{ + register long long ll asm (REG1a); + register long long mm asm (REG2a) = llp; + asm ("bar1b %1,%0" : "=r" (ll) : "r" (mm) : REG2b); /* { dg-error "conflict" } */ + return ll; +} + +void * +foobar (void *p) +{ + register void *q asm (REG1); + register void *w asm (REG2) = p; + asm ("foobar1 %1,%0" : "=r" (q) : "r" (w) : REG2); /* { dg-error "conflict" } */ + return q; +} + +void * +nfoobar (void *p) +{ + register void *q asm (REG1); + register void *w = p; + asm ("foobar1 %1,%0" : "=r" (q) : "r" (w) : REG2); + return q; +} + +long long +foobarlla (long long llp) +{ + register long long ll asm (REG1a); + register long long mm asm (REG2a) = llp; + asm ("foobar1a %1,%0" : "=r" (ll) : "r" (mm) : REG1b); /* { dg-error "conflict" } */ + return ll; +} + +long long +nfoobarlla (long long llp) +{ + register long long ll asm (REG1a); + register long long mm = llp; + asm ("foobar1a %1,%0" : "=r" (ll) : "r" (mm) : REG2a); + return ll; +} + +long long +foobarllb (long long llp) +{ + register long long ll asm (REG1a); + register long long mm asm (REG2a) = llp; + asm ("foobar1b %1,%0" : "=r" (ll) : "r" (mm) : REG2b); /* { dg-error "conflict" } */ + return ll; +} + +long long +nfoobarllb (long long llp) +{ + register long long ll asm (REG1a); + register long long mm = llp; + asm ("foobar1b %1,%0" : "=r" (ll) : "r" (mm) : REG2b); + return ll; +} + +void * +baz (void *p) +{ + register void *q asm (REG1); + register void *w asm (REG2) = p; + asm ("baz1 %1,%0" : "=r" (q) : "r" (w) : REG1, REG2); /* { dg-error "conflict" } */ + return q; +} + +void * +nbaz (void *p) +{ + register void *q; + register void *w = p; + asm ("baz1 %1,%0" : "=r" (q) : "r" (w) : REG1, REG2); + return q; +} + +void * +nbaz2 (void *p) +{ + register void *q asm (REG1); + register void *w asm (REG2) = p; + asm ("baz1 %1,%0" : "=r" (q) : "r" (w)); + return q; +} + +long long +bazlla (long long llp) +{ + register long long ll asm (REG1a); + register long long mm asm (REG2a) = llp; + asm ("baz1a %1,%0" : "=r" (ll) : "r" (mm) : REG1a, REG2a); /* { dg-error "conflict" } */ + return ll; +} + +long long +bazllb (long long llp) +{ + register long long ll asm (REG1a); + register long long mm asm (REG2a) = llp; + asm ("baz2a %1,%0" : "=r" (ll) : "r" (mm) : REG1b, REG2b); /* { dg-error "conflict" } */ + return ll; +} + +/* Real-world example of bug. */ + +#ifdef _WIN64 +typedef unsigned int loc_size_t __attribute__ ((mode (DI))); +#else +typedef __SIZE_TYPE__ loc_size_t; +#endif + +struct stat; +int +_dl_stat (const char *file_name, struct stat *buf) +{ + register long a asm (REG1) = (long) (loc_size_t) file_name; + register long b asm (REG2) = (long) (loc_size_t) buf; + + asm volatile ("movu.w %1,$r9\n\tbreak 13" : "=r" (a) : "g" (106), "0" (a), "r" (b) : REG1, REG5); /* { dg-error "conflict" } */ + if (a >= 0) + return (int) a; + return (int) -1; +} diff --git a/SingleSource/Regression/C/gcc-dg/20021006-1.c b/SingleSource/Regression/C/gcc-dg/20021006-1.c new file mode 100644 index 0000000000..92df2c57f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20021006-1.c @@ -0,0 +1,27 @@ +/* PR target/7559 + This testcase was miscompiled on x86-64 due to wrong access to the struct + members. */ + +extern void abort(void); + +struct A { + long x; +}; + +struct R { + struct A a, b; +}; + +struct R R = { + {100}, {200} +}; + +void f(struct R r) { + if (r.a.x != R.a.x || r.b.x != R.b.x) + abort(); +} + +int main() { + f(R); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20021014-1.c b/SingleSource/Regression/C/gcc-dg/20021014-1.c new file mode 100644 index 0000000000..e43f7b297c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20021014-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-require-profiling "-p" } */ +/* { dg-options "-O2 -p" } */ +/* { dg-options "-O2 -p -static" { target hppa*-*-hpux* } } */ +/* { dg-error "profiler" "No profiler support" { target xstormy16-*-* } 0 } */ +/* { dg-message "" "consider using `-pg' instead of `-p' with gprof(1)" { target *-*-freebsd* } 0 } */ + +extern void abort (void); +extern void exit (int); + +int foo (void) +{ + int bar (int x) + { + return x + 3; + } + return bar (1) + bar (2); +} + +int main (void) +{ + if (foo () != 9) + abort (); + exit (0); +} + +/* { dg-final { cleanup-profile-file } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20021018-1.c b/SingleSource/Regression/C/gcc-dg/20021018-1.c new file mode 100644 index 0000000000..bbc8895668 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20021018-1.c @@ -0,0 +1,29 @@ +/* { dg-do run { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +extern void abort (void); +extern void exit (int); + +#if __INT_MAX__ >= 2147483647L +static const long foo [10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + +long __attribute__((noinline)) +bar (int x) +{ + return foo [x - 0x6ffffffa]; +} + +int +main (void) +{ + if (bar (0x6ffffffc) != 2) + abort (); + exit (0); +} +#else +int +main (void) +{ + exit (0); +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/20021023-1.c b/SingleSource/Regression/C/gcc-dg/20021023-1.c new file mode 100644 index 0000000000..855b2cc1ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20021023-1.c @@ -0,0 +1,24 @@ +/* This testcase ICEd on x86-64 because LABEL_REF + small const was not + considered as local_symbolic_operand. */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +typedef __builtin_va_list va_list; + +static unsigned int +foo (void *a, float b, const char *c, va_list d, void *e) +{ + return -1; +} + +unsigned int +bar (void *a, float b, const char *c, ...) +{ + va_list args; + unsigned int d; + + __builtin_va_start (args, c); + d = foo (a, b, c, args, a); + __builtin_va_end (args); + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/20021029-1.c b/SingleSource/Regression/C/gcc-dg/20021029-1.c new file mode 100644 index 0000000000..f5ddecb7c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20021029-1.c @@ -0,0 +1,20 @@ +/* Test whether difference of local labels doesn't force + variables into writable sections. */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ +/* { dg-additional-options "-G0" { target nios2-*-* } } */ +/* { dg-final { scan-assembler-not ".data.rel.ro.local" } } */ +/* { dg-final { scan-assembler-symbol-section {^_?ar} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target indirect_jumps } */ + +int foo (int a) +{ + static const int ar[] = { &&l1 - &&l1, &&l2 - &&l1 }; + void *p = &&l1 + ar[a]; + goto *p; + l1: + return 1; + l2: + return 2; +} diff --git a/SingleSource/Regression/C/gcc-dg/20021029-2.c b/SingleSource/Regression/C/gcc-dg/20021029-2.c new file mode 100644 index 0000000000..e99342478c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20021029-2.c @@ -0,0 +1,14 @@ +/* Test whether variables with relocations aren't put into + mergeable sections even with -fmerge-all-constants. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fmerge-all-constants" } */ +/* { dg-final { scan-assembler-not ".rodata.cst" } } */ + +int foo (int a) +{ + static void * const ar[] = { &&l2 }; + void *p = ar[a]; + goto *p; +l2: + return 2; +} diff --git a/SingleSource/Regression/C/gcc-dg/20021116-1.c b/SingleSource/Regression/C/gcc-dg/20021116-1.c new file mode 100644 index 0000000000..4d3afc7b47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20021116-1.c @@ -0,0 +1,31 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +void ** +foo (void **x, int y, void *z) +{ + switch (y) + { + case 162: + *x = z; + break; + case 164: + *x = z; + break; + case 165: + *x = z; + break; + case 166: + *x = z; + break; + case 163: + *x = z; + break; + default: + goto out; + } + return x; + +out: + return (void **) 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030107-1.c b/SingleSource/Regression/C/gcc-dg/20030107-1.c new file mode 100644 index 0000000000..91640807ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030107-1.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-fprofile-arcs" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +extern void bar(void) __attribute__((noreturn)); +int foo (void) { bar(); } diff --git a/SingleSource/Regression/C/gcc-dg/20030120-1.c b/SingleSource/Regression/C/gcc-dg/20030120-1.c new file mode 100644 index 0000000000..2d3e2ce658 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030120-1.c @@ -0,0 +1,9 @@ +/* PR 7154 */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O -fpic" } */ + +const int x[1]={ 1 }; +void foo(int i, int *p) +{ + asm volatile("" : "+r"(i) : "m" (x[0]), "r"(p)); +} diff --git a/SingleSource/Regression/C/gcc-dg/20030204-1.c b/SingleSource/Regression/C/gcc-dg/20030204-1.c new file mode 100644 index 0000000000..6b8ea4daa9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030204-1.c @@ -0,0 +1,17 @@ +/* PR optimization/8555 */ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -funroll-loops" } */ +/* { dg-options "-march=pentium3 -O -ffast-math -funroll-loops" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + + +float foo (float *a, int i) +{ + int j; + float x = a[j = i - 1], y; + + for (j = i; --j >= 0; ) + if ((y = a[j]) > x) + x = y; + + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030213-1.c b/SingleSource/Regression/C/gcc-dg/20030213-1.c new file mode 100644 index 0000000000..35bfe22fe2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030213-1.c @@ -0,0 +1,36 @@ +/* Testcase for http://gcc.gnu.org/ml/gcc-patches/2003-02/msg01017.html */ +/* { dg-do link { target fpic } } */ +/* { dg-options "-O -fpic" } */ + +int *g; + +int main (void) +{ + switch (*g) + { + case 0: + { + switch (*g) + { + case 0: *g = 1; break; + case 1: + case 2: *g = 1; break; + case 3: + case 4: *g = 1; break; + } + break; + } + case 1: + { + switch (*g) + { + case 0: *g = 1; break; + case 1: + case 2: *g = 1; break; + case 3: + case 4: *g = 1; break; + } + } + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030225-1.c b/SingleSource/Regression/C/gcc-dg/20030225-1.c new file mode 100644 index 0000000000..97a436b4ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030225-1.c @@ -0,0 +1,101 @@ +/* PR target/9732 + This testcase segfaulted on PPC because PIC_OFFSET_TABLE_REGNUM was no + fixed register. + Distilled from the xvid sources by Guillaume Morin + and Benjamin Herrenschmidt . */ +/* { dg-do run { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ + +extern void exit (int); + +#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */ +#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */ +#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */ +#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */ +#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */ +#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */ + + +/* private data */ +static short iclip[1024]; /* clipping table */ +static short *iclp; + +void +idct_int32(short *const block) +{ + static short *blk; + static long i; + static long X0, X1, X2, X3, X4, X5, X6, X7, X8; + + for (i = 0; i < 8; i++) /* idct columns */ + { + blk = block + i; + /* shortcut */ + if (! ((X1 = (blk[8 * 4] << 8)) | (X2 = blk[8 * 6]) + | (X3 = blk[8 * 2]) | (X4 = blk[8 * 1]) | (X5 = blk[8 * 7]) + | (X6 = blk[8 * 5]) | (X7 = blk[8 * 3]))) + { + blk[8 * 0] = blk[8 * 1] = blk[8 * 2] = + blk[8 * 3] = blk[8 * 4] = + blk[8 * 5] = blk[8 * 6] = blk[8 * 7] = + iclp[(blk[8 * 0] + 32) >> 6]; + continue; + } + X0 = (blk[8 * 0] << 8) + 8192; + + /* first stage */ + X8 = W7 * (X4 + X5) + 4; + X4 = (X8 + (W1 - W7) * X4) >> 3; + X5 = (X8 - (W1 + W7) * X5) >> 3; + X8 = W3 * (X6 + X7) + 4; + X6 = (X8 - (W3 - W5) * X6) >> 3; + X7 = (X8 - (W3 + W5) * X7) >> 3; + + /* second stage */ + X8 = X0 + X1; + X0 -= X1; + X1 = W6 * (X3 + X2) + 4; + X2 = (X1 - (W2 + W6) * X2) >> 3; + X3 = (X1 + (W2 - W6) * X3) >> 3; + X1 = X4 + X6; + X4 -= X6; + X6 = X5 + X7; + X5 -= X7; + + /* third stage */ + X7 = X8 + X3; + X8 -= X3; + X3 = X0 + X2; + X0 -= X2; + X2 = (181 * (X4 + X5) + 128) >> 8; + X4 = (181 * (X4 - X5) + 128) >> 8; + + /* fourth stage */ + blk[8 * 0] = iclp[(X7 + X1) >> 14]; + blk[8 * 1] = iclp[(X3 + X2) >> 14]; + blk[8 * 2] = iclp[(X0 + X4) >> 14]; + blk[8 * 3] = iclp[(X8 + X6) >> 14]; + blk[8 * 4] = iclp[(X8 - X6) >> 14]; + blk[8 * 5] = iclp[(X0 - X4) >> 14]; + blk[8 * 6] = iclp[(X3 - X2) >> 14]; + blk[8 * 7] = iclp[(X7 - X1) >> 14]; + } +} /* end function idct_int32(block) */ + + +int main(void) { + int i; + unsigned short tab[64]; + + for (i = 0 ; i < 64 ; ++i) + { + tab[i] = (1+(int) (65535)*8000/(2147483647+1.0)); + } + + iclp = iclip + 512; + for (i = -512; i < 512; i++) + iclp[i] = (i < -256) ? -256 : ((i > 255) ? 255 : i); + + idct_int32((short *) tab); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20030309-1.c b/SingleSource/Regression/C/gcc-dg/20030309-1.c new file mode 100644 index 0000000000..2431bc1b52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030309-1.c @@ -0,0 +1,42 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +struct A0 { int x; }; +struct A1 { int x; int y[1]; }; +struct A2 { int x; int y[2]; }; +struct A3 { int x; int y[3]; }; +struct A4 { int x; int y[4]; }; + +void *s; +int u; + +int +main (void) +{ + int x; + void *t = s; + + switch (u) + { + case 0: + x = ((struct A0 *) t)->x; + break; + case 1: + x = ((struct A1 *) t)->x; + break; + case 2: + x = ((struct A2 *) t)->x; + break; + case 3: + x = ((struct A3 *) t)->x; + break; + case 4: + x = ((struct A4 *) t)->x; + break; + default: + x = 0; + break; + } + + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030321-1.c b/SingleSource/Regression/C/gcc-dg/20030321-1.c new file mode 100644 index 0000000000..1150c7f761 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030321-1.c @@ -0,0 +1,18 @@ +/* This used to ICE on s390 due to displacement overflow + when accessing the low-order subword. */ + +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct array +{ + char align[4092]; + long long elem[2] __attribute__ ((__packed__)); /* { dg-warning "attribute ignored" "" { target default_packed } } */ +}; + +long long +test (struct array *array, int i) +{ + return array->elem[i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030323-1.c b/SingleSource/Regression/C/gcc-dg/20030323-1.c new file mode 100644 index 0000000000..8a563ec5eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030323-1.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +/* PR c/8224 */ +/* Contributed by Mikulas Patocka */ + +extern void abort (void); + +unsigned f (int x) +{ + return (unsigned) (x / 2) / 2; +} + +unsigned f1 (int x) +{ + unsigned xx = x / 2; + return xx / 2; +} + +int main () +{ + if (f1 (-5) != f (-5)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030324-1.c b/SingleSource/Regression/C/gcc-dg/20030324-1.c new file mode 100644 index 0000000000..67db669fda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030324-1.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-options "-O -fstrict-aliasing -fgcse" } */ + +/* PR optimization/10087 */ +/* Contributed by Peter van Hoof */ + +extern void abort(void); + +void b(int*,int*); + +typedef struct { + double T1; + char c; +} S; + +int main(void) +{ + int i,j; + double s; + + S x1[2][2]; + S *x[2] = { x1[0], x1[1] }; + S **E = x; + + for( i=0; i < 2; i++ ) + for( j=0; j < 2; j++ ) + E[j][i].T1 = 1; + + for( i=0; i < 2; i++ ) + for( j=0; j < 2; j++ ) + s = E[j][i].T1; + + b(&j,&i); + if (s != 1) + abort (); + return 0; +} + +void b(int *i, int *j) {} diff --git a/SingleSource/Regression/C/gcc-dg/20030331-2.c b/SingleSource/Regression/C/gcc-dg/20030331-2.c new file mode 100644 index 0000000000..5dc164fc4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030331-2.c @@ -0,0 +1,13 @@ +// { dg-options "" } +/* { dg-require-effective-target alloca } */ + +extern int printf (const char *, ...); + +int foo() { + int yd; + float in[1][yd]; + + void bar() { + printf("%p\n",in[0]); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20030414-1.c b/SingleSource/Regression/C/gcc-dg/20030414-1.c new file mode 100644 index 0000000000..9ba595318d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030414-1.c @@ -0,0 +1,39 @@ +/* PR target/10377 + Distilled by Hans-Peter Nilsson from ncurses-5.3 infocmp.c. + Copyright (C) 2003 Free Software Foundation. */ + +/* { dg-do assemble } */ +/* { dg-options "-O2 -fPIC" { target *-*-*gnu* } } */ + +extern int f2 (char *, char *); +extern char *ss[]; +extern char *cc; +void +f1 (char *dd, char *bb) +{ + char *sp = bb + 1; + char *ap; + int i; + char *ee = 0; + char *cp; + + for (i = 0, cp = cc; i < 42; i++) + if (cp) + { + if (f2 (dd, "xx") || f2 (ss[i], "xx") || f2 (ss[i], "yy")) + if (bb < cp) + continue; + ee = ss[i]; + break; + } + + if (!ee) + for (ap = cc; *ap; ap++) + if (f2(ap, sp)) + { + ee = ap; + break; + } + + cc = ee; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030414-2.c b/SingleSource/Regression/C/gcc-dg/20030414-2.c new file mode 100644 index 0000000000..f4eb8bf36e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030414-2.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding (c1 - x) op c2 into x swap(op) c1-c2 + doesn't break anything. + + Written by Roger Sayle, 27th March 2003. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void abort (void); + +int foo(double x) +{ + return (10.0 - x) > 3.0; +} + +int bar (double x) +{ + return (10.0 - x) == 5.0; +} + +int main() +{ + if (foo (8.0)) + abort (); + + if (! foo (6.0)) + abort (); + + if (bar (1.0)) + abort (); + + if (! bar (5.0)) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030612-1.c b/SingleSource/Regression/C/gcc-dg/20030612-1.c new file mode 100644 index 0000000000..00db20a22b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030612-1.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int A, B; + +void foo() +{ + long x = 3; + (void)({ + A = B + x + ((1) - 1); + return; /* { dg-warning "statement-expressions should end with a non-void expression" "" { xfail *-*-* } } */ + }); +} + +int +main() +{ + B = 5; + foo(); + if (A != 8) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030612-2.c b/SingleSource/Regression/C/gcc-dg/20030612-2.c new file mode 100644 index 0000000000..f9f212caba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030612-2.c @@ -0,0 +1,20 @@ +/* Derived from PR middle-end/168. */ + +/* { dg-do compile } */ +/* { dg-options "-W" } */ + +extern void foo (); + +unsigned char uc; +unsigned short int usi; +unsigned int ui; + + +void bar() +{ + if (uc + usi >= ui) /* { dg-bogus "between signed and unsigned" } */ + foo (); + if (uc * usi >= ui) /* { dg-bogus "between signed and unsigned" } */ + foo (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030625-1.c b/SingleSource/Regression/C/gcc-dg/20030625-1.c new file mode 100644 index 0000000000..4e78ae4ac7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030625-1.c @@ -0,0 +1,9 @@ +/* Testcase from http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02557.html */ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +typedef struct _foo foo; +struct _foo { + struct _moo moo; /* { dg-error "moo" "has incomplete type" } */ +}; + diff --git a/SingleSource/Regression/C/gcc-dg/20030626-1.c b/SingleSource/Regression/C/gcc-dg/20030626-1.c new file mode 100644 index 0000000000..3a96786fef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030626-1.c @@ -0,0 +1,18 @@ +/* PR optimization/11210 */ +/* Originator: Guido Classen */ +/* Reduced testcase by Falk Hueffner */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +/* Verify that the constant expressions folder doesn't + throw away the cast operation in the comparison. */ + +struct str { + int head; + signed char data[8]; +}; + +int foo(struct str t) +{ + return t.data[0] || (unsigned char) t.data[2] != 130; /* { dg-bogus "comparison is always 1" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20030627-1.c b/SingleSource/Regression/C/gcc-dg/20030627-1.c new file mode 100644 index 0000000000..4135f71e3c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030627-1.c @@ -0,0 +1,20 @@ +/* This tests whether non-offsettable memory operands are reloaded + correctly in certain corner cases on s390 targets. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +void test_inout (char *bd, int xd, char *bs, int xs) +{ + *(long long *)(bd + xd + 4093) = *(long long *)(bs + xs + 4093); +} + +void test_in (char *bd, int xd, char *bs, int xs) +{ + *(long long *)(bd + xd) = *(long long *)(bs + xs + 4093); +} + +void test_out (char *bd, int xd, char *bs, int xs) +{ + *(long long *)(bd + xd + 4093) = *(long long *)(bs + xs); +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030702-1.c b/SingleSource/Regression/C/gcc-dg/20030702-1.c new file mode 100644 index 0000000000..ee03f71a7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030702-1.c @@ -0,0 +1,12 @@ +/* This tests whether REG_ALWAYS_RETURN notes are handled + correctly in combine. */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic -fprofile-arcs" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +int fork (void); + +void test (void) +{ + fork (); +} diff --git a/SingleSource/Regression/C/gcc-dg/20030707-1.c b/SingleSource/Regression/C/gcc-dg/20030707-1.c new file mode 100644 index 0000000000..cd3e88ebbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030707-1.c @@ -0,0 +1,16 @@ +/* Derived from PR target/10979. */ +/* This testcase used to ICE on x86. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +void t(double); +double atan2(double,double); + +void temp(double *c) +{ + double c2 = 8; + double s2 = 0; + *c = atan2(s2,c2); + t(1/s2); +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030708-1.c b/SingleSource/Regression/C/gcc-dg/20030708-1.c new file mode 100644 index 0000000000..344bb4e18d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030708-1.c @@ -0,0 +1,14 @@ +/* PR c/11420 */ +/* { dg-do link { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +void (* volatile fn) (void); +static void foo (void) +{ +} + +int main (void) +{ + fn = foo; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030711-1.c b/SingleSource/Regression/C/gcc-dg/20030711-1.c new file mode 100644 index 0000000000..e8691961f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030711-1.c @@ -0,0 +1,36 @@ +/* Test whether strncmp has not been "optimized" into memcmp + nor any code with memcmp semantics. */ +/* { dg-do run { target mmap } } */ +/* { dg-options "-O2" } */ +#include +#include +#include +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_ANON +#define MAP_ANON 0 +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif +#include + +void __attribute__((noinline)) test (const char *p) +{ + if (__builtin_strncmp (p, "abcdefghijklmnopq", 17) == 0) + abort (); +} + +int main (void) +{ + char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) + return 0; + if (munmap (p + 65536, 65536) < 0) + return 0; + __builtin_memcpy (p + 65536 - 5, "abcd", 5); + test (p + 65536 - 5); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030717-1.c b/SingleSource/Regression/C/gcc-dg/20030717-1.c new file mode 100644 index 0000000000..6a7f6de6f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030717-1.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int zero (void) +{ + return 0; +} + +int one (void) +{ + return 1; +} + +int main (void) +{ + int i = 1; + int r = (i ? one : zero)(); + if (r != 1) + abort(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030721-1.c b/SingleSource/Regression/C/gcc-dg/20030721-1.c new file mode 100644 index 0000000000..5e8ed0b434 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030721-1.c @@ -0,0 +1,41 @@ +/* { dg-options "-O2" } */ +/* PR optimization/11536 */ +/* Origin: samal@kam.mff.cuni.cz */ +/* Testcase by Andrew Pinski */ + +/* Verify that the loop optimizer doesn't use moving targets + to calculate the number of iterations of a loop. */ + +extern void abort(void); + +void foo(int) __attribute__((__noinline__)); + +void foo(int i) +{ + abort(); +} + +int main() +{ + int i; + int first= 0; + int last= 0; + + while (last<3) { + last = first; + + while (first<=last) { + first++; + + for (i=0;i<3;i++) + last++; + + if (last>10) + return 0; + } + + foo(first); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030804-1.c b/SingleSource/Regression/C/gcc-dg/20030804-1.c new file mode 100644 index 0000000000..cbc66474a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030804-1.c @@ -0,0 +1,75 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding of mathematical expressions doesn't + break anything. + + Written by Roger Sayle, 3rd August 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void link_error(void); + +void test(double x) +{ + if (x+x != 2.0*x) + link_error (); + if (x+x != x*2.0) + link_error (); + + if (x+x+x != 3.0*x) + link_error (); + if (x+x+x != x*3.0) + link_error (); + + if ((x+x)+x != 3.0*x) + link_error (); + if ((x+x)+x != x*3.0) + link_error (); + + if (x+(x+x) != 3.0*x) + link_error (); + if (x+(x+x) != x*3.0) + link_error (); + + if (x+4.0*x != 5.0*x) + link_error (); + if (x+4.0*x != x*5.0) + link_error (); + if (x+x*4.0 != 5.0*x) + link_error (); + if (x+x*4.0 != x*5.0) + link_error (); + if (4.0*x+x != 5.0*x) + link_error (); + if (4.0*x+x != x*5.0) + link_error (); + if (x*4.0+x != 5.0*x) + link_error (); + if (x*4.0+x != x*5.0) + link_error (); + + if (3.0*x + 5.0*x != 8.0*x) + link_error (); + if (3.0*x + 5.0*x != x*8.0) + link_error (); + if (x*3.0 + 5.0*x != 8.0*x) + link_error (); + if (x*3.0 + 5.0*x != x*8.0) + link_error (); + if (3.0*x + x*5.0 != 8.0*x) + link_error (); + if (3.0*x + x*5.0 != x*8.0) + link_error (); + if (x*3.0 + x*5.0 != 8.0*x) + link_error (); + if (x*3.0 + x*5.0 != x*8.0) + link_error (); +} + +int main() +{ + test(2.0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030805-1.c b/SingleSource/Regression/C/gcc-dg/20030805-1.c new file mode 100644 index 0000000000..286b922ea0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030805-1.c @@ -0,0 +1,23 @@ +/* Test that gcc understands that the call to g might clobber i. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -fgnu89-inline" } */ + +__inline int f () +{ + static int i; + int i2 = i; + i = i2 + 1; + return i; +} + +int g () { return f (); } + +int main () +{ + if (f() != 1 + || g() != 2 + || f() != 3) + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030815-1.c b/SingleSource/Regression/C/gcc-dg/20030815-1.c new file mode 100644 index 0000000000..7bf21bd468 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030815-1.c @@ -0,0 +1,18 @@ +/* Test completion of incomplete types. + There used to be a bug where some types from incomplete + list were accidentally lost. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef struct a E; +typedef struct b F; +typedef struct c G; +typedef struct d H; +struct a { int a; }; +struct c { int c; }; +struct d { int d; }; +struct b { int b; }; +int se = sizeof (E); +int sf = sizeof (F); +int sg = sizeof (G); +int sh = sizeof (H); diff --git a/SingleSource/Regression/C/gcc-dg/20030820-1.c b/SingleSource/Regression/C/gcc-dg/20030820-1.c new file mode 100644 index 0000000000..f86fb3978f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030820-1.c @@ -0,0 +1,13 @@ +/* PR middle-end/11984 */ +/* The following program used to ICE in fold because we didn't check + whether the constants we were reassociating were integer constants + before calling tree_int_cst_lt. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double f(double x) +{ + return 1.0 - x - 0.1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030826-1.c b/SingleSource/Regression/C/gcc-dg/20030826-1.c new file mode 100644 index 0000000000..b344ad2dcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030826-1.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding of mathematical expressions doesn't + break anything. + + Written by Roger Sayle, 24th August 2003. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +void abort(void); + +double foo(double x) +{ + return 12.0/(x*3.0); +} + +double bar(double x) +{ + return (3.0/x)*4.0; +} + +int main() +{ + if (foo(2.0) != 2.0) + abort (); + + if (bar(2.0) != 6.0) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20030826-2.c b/SingleSource/Regression/C/gcc-dg/20030826-2.c new file mode 100644 index 0000000000..552c77e7e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030826-2.c @@ -0,0 +1,64 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fomit-frame-pointer" } */ +/* { dg-options "-O2 -fomit-frame-pointer -march=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern void abort (void); +extern void exit (int); + +struct S +{ + int *a; + unsigned char *b, c; +}; + +int u, v, w; + +void +foo (unsigned short x) +{ + u += x; +} + +int +bar (struct S **x, int *y) +{ + w += *y; + *y = w + 25; + return 0; +} + +int +baz (struct S **x) +{ + struct S *y = *x; + unsigned char *a = y->b; + + foo (*a); + + if (__builtin_expect (y->c != 0 || y->a == &v, 0)) + return 1; + + if (__builtin_expect (*a == 1, 0)) + { + int a, b = bar (x, &a); + + if (a) + return b; + } + + return 0; +} + +int +main (void) +{ + struct S a, *b = &a; + unsigned char c; + + __builtin_memset (b, 0, sizeof (a)); + a.a = &v; + a.b = &c; + if (baz (&b) != 1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20030906-1.c b/SingleSource/Regression/C/gcc-dg/20030906-1.c new file mode 100644 index 0000000000..c416f55ee7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030906-1.c @@ -0,0 +1,21 @@ +/* Bug 9862 -- Spurious warnings with -finline-functions. + Copyright (C) 2003 Free Software Foundation Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-O -finline-functions -Wreturn-type" } */ + +extern int i; +extern int foo (void); +extern int bar (void); + +int foo (void) +{ + if( i ) return 0; + else return 1; +} + +int bar (void) +{ + if( i ) return; /* { dg-warning "'return' with no value, in function returning non-void" } */ + else return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/20030906-2.c b/SingleSource/Regression/C/gcc-dg/20030906-2.c new file mode 100644 index 0000000000..1191133e6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20030906-2.c @@ -0,0 +1,21 @@ +/* Bug 9862 -- Spurious warnings with -finline-functions. + Copyright (C) 2003 Free Software Foundation Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-O -finline-functions -Wreturn-type" } */ + +extern int i; +extern int foo (void); +extern int bar (void); + +int foo (void) +{ + if( i ) return; /* { dg-warning "'return' with no value, in function returning non-void" } */ + else return 1; +} + +int bar (void) +{ + if( i ) return 0; + else return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/20031002-1.c b/SingleSource/Regression/C/gcc-dg/20031002-1.c new file mode 100644 index 0000000000..57a31ed7f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031002-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void generic_sendmsg (char *fmt, ...) +{ + __builtin_next_arg(fmt); +} + +void generic_sendstat() +{ + double t; + + generic_sendmsg("F %3.2f", t); +} diff --git a/SingleSource/Regression/C/gcc-dg/20031012-1.c b/SingleSource/Regression/C/gcc-dg/20031012-1.c new file mode 100644 index 0000000000..24a68d0e3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031012-1.c @@ -0,0 +1,18 @@ +/* { dg-options "-Waddress" } */ +/* Origin: Andrew Morton */ +/* Warn if a function address of a non-weak function is used + as a truth value. */ +/* See thread starting at http://gcc.gnu.org/ml/gcc/2003-10/msg00414.html */ + +void foo(void) +{} + +void bar(void) +{} + +int main() { + if (foo) /* { dg-warning "" } */ + bar(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20031102-1.c b/SingleSource/Regression/C/gcc-dg/20031102-1.c new file mode 100644 index 0000000000..b50434feff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031102-1.c @@ -0,0 +1,37 @@ +/* PR optimization/12799 */ +/* Origin: Pratap Subrahmanyam */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* Verify that reload_cse_move2add doesn't add unexpected CLOBBERs. */ + +extern void abort(void); + +int loo = 1; + +__inline__ char InlineFunc(void) +{ + return __builtin_expect(!!(loo == 1), 1); +} + +int FooBar(void) +{ + int i; + int var1 = InlineFunc() ? 2046 : 1023; + int var2 = InlineFunc() ? 512 : 1024; + + for (i = 0; i < var1; i++) + ; + + if (InlineFunc() && var2 != 512) + abort(); + + return 0; +} + +int main(void) +{ + return FooBar(); +} diff --git a/SingleSource/Regression/C/gcc-dg/20031111-1.c b/SingleSource/Regression/C/gcc-dg/20031111-1.c new file mode 100644 index 0000000000..f4de52257b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031111-1.c @@ -0,0 +1,13 @@ +/* Make sure that dead code isn't eliminated too early, avoiding + detection of errors. */ +/* { dg-do compile } */ + +void foo(void) +{ + if (0) + break; /* { dg-error "" } */ + if (1) + ; + else + continue; /* { dg-error "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20031201-1.c b/SingleSource/Regression/C/gcc-dg/20031201-1.c new file mode 100644 index 0000000000..91f2d9ddf7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031201-1.c @@ -0,0 +1,20 @@ +/* PR optimization/12628 */ +/* The following test used to ICE in init_alias_analysis because the + given command line options meant that reg_scan wasn't (re)run before + the jump bypassing pass. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-expensive-optimizations" } */ + +int outbuf[100]; +int outcnt; +int bi_buf; +void send_bits(void) +{ + bi_buf = 0; + outbuf[outcnt++] = 8; + outbuf[outcnt++] = 8; + if (outcnt) + bi_buf = 1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20031201-2.c b/SingleSource/Regression/C/gcc-dg/20031201-2.c new file mode 100644 index 0000000000..c32b5ebd2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031201-2.c @@ -0,0 +1,41 @@ +/* PR optimization/11634 */ + +/* The following code used to ICE in verify_local_live_at_start on + PA when compiled with -O2. The cause was that split_all_insns was + not updating liveness information when deleting no-op moves that + had REG_UNUSED notes. */ + +/* { dg-do compile { target hppa*-*-* } } */ +/* { dg-options "-O2" } */ + +void *f(void *s); +void H5T_conv_vlen (unsigned long long nelmts, unsigned char *bg_ptr) +{ + long long seq_len; + unsigned long long bg_seq_len = 0; + unsigned src_base_size, dst_base_size; + void *tmp_buf = 0; + unsigned tmp_buf_size = 0; + unsigned long long elmtno; + for (elmtno = 0; elmtno < nelmts; elmtno++) + { + unsigned char *tmp = bg_ptr; + bg_seq_len = *tmp; + if (bg_seq_len > 0 + && tmp_buf_size < + (unsigned) (bg_seq_len * + (src_base_size > dst_base_size + ? src_base_size + : dst_base_size))) + { + tmp_buf_size = + (unsigned) (bg_seq_len * + (src_base_size > dst_base_size + ? src_base_size + : dst_base_size)); + } + if (bg_seq_len < seq_len) + f ((unsigned char *) tmp_buf + dst_base_size * bg_seq_len); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/20031202-1.c b/SingleSource/Regression/C/gcc-dg/20031202-1.c new file mode 100644 index 0000000000..a5e78456ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031202-1.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern void abort (void); +extern void exit (int); + +struct A { char p[6]; } __attribute__((packed)); +struct B { + struct A a; + void * const b; + struct A const * const c; + struct A const *d; +}; + +char v; + +int __attribute__((noinline)) +foo (struct B *b) +{ + int i; + for (i = 0; i < 6; ++i) + if (b->a.p[i]) + abort (); + if (b->b != &v || b->c || b->d) + abort (); + return 12; +} + +int __attribute__((noinline)) +bar (void *x) +{ + __asm __volatile ("" : "=r" (x) : "0" (x)); + struct B y = { .b = x, .c = (void *) 0 }; + return foo (&y) + 1; +} + +int +main (void) +{ + if (bar (&v) != 13) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20031216-1.c b/SingleSource/Regression/C/gcc-dg/20031216-1.c new file mode 100644 index 0000000000..7c706d86be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031216-1.c @@ -0,0 +1,39 @@ +/* This used to abort due to a loop bug on s390*. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -fPIC" { target s390*-*-* } } */ + +extern void abort (void); + +int count = 0; +char *str; + +void test (int flag) +{ + char *p; + + for (;;) + { + if (count > 5) + return; + + p = "test"; + + if (flag) + count++; + + str = p; + } +} + +int main (void) +{ + test (1); + + if (str[0] != 't') + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20031218-1.c b/SingleSource/Regression/C/gcc-dg/20031218-1.c new file mode 100644 index 0000000000..87cc1059fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031218-1.c @@ -0,0 +1,19 @@ +/* Orgin: v.haisman@sh.cvut.cz + Reduced by: Wolfgang Bangerth + PR debug/12923 ICE in gen_subprogram_die with -O1 -g + The problem was that this just to ICE with -O1 -g. */ + +/* { dg-do compile } */ +/* { dg-options "-O -g" } */ + +struct S { + unsigned n; +}; + +inline void foo (struct S * mx) { + mx->n = 1; +} + +void bar () { + foo (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20031218-2.c b/SingleSource/Regression/C/gcc-dg/20031218-2.c new file mode 100644 index 0000000000..497c963d27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031218-2.c @@ -0,0 +1,12 @@ +/* Orgin: Richard Sandiford + PR debug/12923 ICE in gen_subprogram_die with -O2 -g + The problem was that this just to ICE with -O2 -g. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +int f1 (int y) +{ + int f2() { return y; } + return f2(); +} diff --git a/SingleSource/Regression/C/gcc-dg/20031218-3.c b/SingleSource/Regression/C/gcc-dg/20031218-3.c new file mode 100644 index 0000000000..0bae456b8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031218-3.c @@ -0,0 +1,14 @@ +/* Orgin: Chris Demetriou + PR debug/12923 ICE in gen_subprogram_die with -O2 -g + The problem was that this just to ICE with -O2 -g. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +extern __SIZE_TYPE__ strlen (const char *); + +int x (char *s) +{ + int y () { return (strlen (s)); } + return y (s); +} diff --git a/SingleSource/Regression/C/gcc-dg/20031222-1.c b/SingleSource/Regression/C/gcc-dg/20031222-1.c new file mode 100644 index 0000000000..b0d1a2dc43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031222-1.c @@ -0,0 +1,18 @@ +/* PR c/9163 */ +/* The following test used to ICE after an error message in C99 mode + because GCC was trying to expand the tree to rtl. */ + +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + + + +void f () +{ + for (; int ; ); /* { dg-error "" } */ +} + +void foo () +{ + while (int i); /* { dg-error "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20031223-1.c b/SingleSource/Regression/C/gcc-dg/20031223-1.c new file mode 100644 index 0000000000..c529739e7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20031223-1.c @@ -0,0 +1,12 @@ +/* PR c/11995 */ +/* The following test used to ICE after an error message + because GCC was trying to expand the trees to rtl. */ + +/* { dg-do compile } */ +/* { dg-options "-std=c17 -pedantic-errors" } */ + +void f () +{ + l: int; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" "not stmt" } */ + /* { dg-error "useless type name in empty declaration" "type name" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20040123-1.c b/SingleSource/Regression/C/gcc-dg/20040123-1.c new file mode 100644 index 0000000000..2a73382dd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040123-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "abort" } } */ + +extern void abort (void); +extern char a[]; + +void foo (void) +{ + if ((void *) a == (void *) 0x4000UL) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/20040127-1.c b/SingleSource/Regression/C/gcc-dg/20040127-1.c new file mode 100644 index 0000000000..0ea6062a5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040127-1.c @@ -0,0 +1,24 @@ +/* PR target/10904 */ +/* Origin: */ + +/* Verify that the register allocator correctly aligns + floating-point registers on SPARC64. */ + +/* { dg-do assemble } */ +/* { dg-options "-O2" } */ + +extern int foo1(); +extern int foo2(); + +void foo(int n, int b) +{ + int i, a; + + foo1(); + + a = (long)(b * ((double) 0.1)); + + for (i=0; i < n; i++) { + foo2(a); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20040127-2.c b/SingleSource/Regression/C/gcc-dg/20040127-2.c new file mode 100644 index 0000000000..ec76226078 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040127-2.c @@ -0,0 +1,33 @@ +/* PR target/13058 */ +/* Origin: Lloyd Parkes */ +/* Reduced testcase by Falk Hueffner */ + +/* Verify that the register allocator correctly aligns + floating-point registers on SPARC64. */ + +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +void Get16u(); +typedef struct { int ThumbnailSize; } ImageInfo_t; + +double ConvertAnyFormat(void) +{ + return 0; +} + +void ProcessExifDir(ImageInfo_t *ImageInfoP, int NumDirEntries) +{ + unsigned int ThumbnailSize; + + for (; NumDirEntries;) { + Get16u(); + switch (NumDirEntries) { + case 0x0201: + case 0x0202: + ThumbnailSize = ConvertAnyFormat(); + } + } + + ImageInfoP->ThumbnailSize = ThumbnailSize; +} diff --git a/SingleSource/Regression/C/gcc-dg/20040202-1.c b/SingleSource/Regression/C/gcc-dg/20040202-1.c new file mode 100644 index 0000000000..f0f4e74109 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040202-1.c @@ -0,0 +1,8 @@ +/* PR middle-end/13325 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n); +void f (void *dest, const void *src) { + memcpy (dest, src, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20040203-1.c b/SingleSource/Regression/C/gcc-dg/20040203-1.c new file mode 100644 index 0000000000..59c824ea47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040203-1.c @@ -0,0 +1,17 @@ +/* PR/13994; bug_cond2 was rejected on gcc up to version 3.4.x */ +/* { dg-do compile }*/ +/* { dg-options "-std=gnu89" }*/ + +struct s { char c[1]; }; +struct s a; + +int bug_if(void) { if (a.c) return 1; else return 0; } +int bug_while(void) { while (a.c); } +int bug_do_while(void) { do ; while (a.c); } +int bug_for(void) { for ( ; a.c; ) ; } +int bug_or(void) { return (a.c || 1); } +int bug_and(void) { return (a.c && 1); } +int bug_cond(void) { return (a.c ? 1 : 0); } +char *bug_cond2(void) { return (a.c ? : 0); } +int bug_not(void) { return !a.c; } +int bug_bool(void) { return (_Bool) a.c; } diff --git a/SingleSource/Regression/C/gcc-dg/20040206-1.c b/SingleSource/Regression/C/gcc-dg/20040206-1.c new file mode 100644 index 0000000000..c9c776f0bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040206-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -W -Wall" } */ +/* PR c/13127 + On the tree-ssa this used to warn about an anonymous + uninitialized variable. + + The warning about "no return statement in function + returning non-void" is PR 13000. */ + +static int foo (int a __attribute__((unused)) ) { } /* { dg-warning "no return statement" } */ +int main (void) { return foo (0); } diff --git a/SingleSource/Regression/C/gcc-dg/20040217-1.c b/SingleSource/Regression/C/gcc-dg/20040217-1.c new file mode 100644 index 0000000000..7ca7388fe7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040217-1.c @@ -0,0 +1,19 @@ +/* This used to ICE on s390x due to a bug in simplify_if_then_else. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern void use (int); +void test (void) +{ + union + { + unsigned long ul; + signed char sc; + } u; + + u.sc = 8; + u.sc &= 25; + + use (u.sc); +} + diff --git a/SingleSource/Regression/C/gcc-dg/20040219-1.c b/SingleSource/Regression/C/gcc-dg/20040219-1.c new file mode 100644 index 0000000000..1c9254a980 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040219-1.c @@ -0,0 +1,75 @@ +/* Testing save/restore of floating point caller-save registers, on ia64 + this resulted in bad code. Not all targets will use caller-save regs. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -minline-float-divide-max-throughput" { target ia64-*-* } } */ + +/* Testing save/restore of floating point caller-save registers on ia64. */ + +extern void abort (void); + +double foo(double a, double b, double c) +{ + return (a+b+c); +} + +int +main () +{ + double f1, f2, f3, f4, f5, f6, f7, f8, f9,f10; + double f11,f12,f13,f14,f15,f16,f17,f18,f19,f20; + double f21,f22,f23,f24,f25,f26,f27,f28,f29,f30; + double x; + int i,j,k; + + f1 = 0.1; f2 = 0.2; f3 = 0.3; f4 = 0.4; f5 = 0.5; + f6 = 0.6; f7 = 0.7; f8 = 0.8; f9 = 0.9; f10 = 1.0; + f11 = 1.1; f12 = 1.2; f13 = 1.3; f14 = 1.4; f15 = 1.5; + f16 = 1.6; f17 = 1.7; f18 = 1.8; f19 = 1.9; f20 = 2.0; + f21 = 2.1; f22 = 2.2; f23 = 2.3; f24 = 2.4; f25 = 2.5; + f26 = 2.6; f27 = 2.7; f28 = 2.8; f29 = 2.9; f30 = 3.0; + + i = (int) foo(1.0,1.0,1.0); + while (i > 0) { + f1 = f2 / f3 * f30; + f2 = f3 / f4 * f30; + f3 = f4 / f5 * f30; + f4 = f5 / f6 * f30; + f5 = f6 / f7 * f30; + f6 = f7 / f8 * f30; + f7 = f8 / f9 * f30; + f8 = f9 / f10 * f30; + f9 = f10 / f11 * f30; + f10 = f11 / f12 * f30; + f11 = f12 / f13 * f30; + f12 = f13 / f14 * f25; + f13 = f14 / f15 * f30; + f14 = f15 / f16 * f30; + f15 = f16 / f17 * f30; + f16 = f17 / f18 * f30; + f17 = f18 / f19 * f30; + f18 = f19 / f20 * f30; + f19 = f20 / f21 * f30; + f20 = f21 / f22 * f20; + f21 = f22 / f23 * f30; + f22 = f23 / f24 * f30; + f23 = f24 / f25 * f30; + f24 = f25 / f26 * f30; + f25 = f26 / f27 * f30; + f26 = f27 / f28 * f30; + f27 = f28 / f29 * f30; + f28 = f29 / f30 * f30; + f29 = f30 / f1 * f30; + f30 = f1 / f2 * f30; + x = foo(f1,f2,f3); + i = i - 1; + } + x = (f1+f2+f3+f4+f5+f6+f7+f8+f9+f10) * + (f11+f12+f13+f14+f15+f16+f17+f18+f19+f20) * + (f21+f22+f23+f24+f25+f26+f27+f28+f29+f30); + + /* Exact value is not needed, on IA64 it is massively off. */ + if (x < 19503.0 || x > 19504.0) abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20040223-1.c b/SingleSource/Regression/C/gcc-dg/20040223-1.c new file mode 100644 index 0000000000..ae0924ef28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040223-1.c @@ -0,0 +1,41 @@ +/* GCC was not warning about taking the address of parameters or + fields of struct parameters when returning them. */ +/* PR c/14156 */ + +/* { dg-do compile } */ + + +int * f( int a) +{ + return &a;/* { dg-warning "address" } */ +} + +int * g() +{ + int b = 0; + return &b;/* { dg-warning "address" } */ +} + +struct ll +{ + int i; +}; + +int *h(struct ll c) +{ + return &c.i;/* { dg-warning "address" } */ +} + + +struct ll d; + +int *i() +{ + return &d.i;/* { dg-bogus "address" } */ +} + + +int *j(struct ll *c) +{ + return &c->i; /* { dg-bogus "address" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20040305-2.c b/SingleSource/Regression/C/gcc-dg/20040305-2.c new file mode 100644 index 0000000000..ffaf353e37 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040305-2.c @@ -0,0 +1,49 @@ +/* PR target/14262 */ +/* { dg-do run } */ + +extern void abort (void); + +typedef char ACS; +typedef char LSM; +typedef char PANEL; +typedef char DRIVE; +typedef struct { + ACS acs; + LSM lsm; +} LSMID; +typedef struct { + LSMID lsm_id; + PANEL panel; +} PANELID; +typedef struct { + PANELID panel_id; + DRIVE drive; +} DRIVEID; + +void sub (DRIVEID driveid) +{ + if (driveid.drive != 1) + abort (); + if (driveid.panel_id.panel != 2) + abort (); + if (driveid.panel_id.lsm_id.lsm != 3) + abort (); + if (driveid.panel_id.lsm_id.acs != 4) + abort (); +} + +int main(void) +{ + DRIVEID driveid; + + driveid.drive = 1; + driveid.panel_id.panel = 2; + driveid.panel_id.lsm_id.lsm = 3; + driveid.panel_id.lsm_id.acs = 4; + + sub(driveid); + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/20040306-1.c b/SingleSource/Regression/C/gcc-dg/20040306-1.c new file mode 100644 index 0000000000..8cac8697d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040306-1.c @@ -0,0 +1,22 @@ +/* This used to ICE due to a reload bug on s390*. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */ + +typedef struct test +{ + unsigned short pad; + unsigned char type[6]; +} t; + +extern void set (t *a, t *b, t *c, t *d, t *e, t *f, t *g, t *h, + t *i, t *j, t *k, t *l, t *m, t *n, t *o, t *p); +extern void use (t a, t b, t c, t d, t e, t f, t g, t h, + t i, t j, t k, t l, t m, t n, t o, t p); +void test (void) +{ + t a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p; + set (&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p); + use (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p); +} diff --git a/SingleSource/Regression/C/gcc-dg/20040309-1.c b/SingleSource/Regression/C/gcc-dg/20040309-1.c new file mode 100644 index 0000000000..736150731c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040309-1.c @@ -0,0 +1,17 @@ +/* Test integer mod on ia64. There was a bug in the inline integer + division code. */ + +/* { dg-do run } */ +/* { dg-options "-minline-int-divide-max-throughput" { target ia64-*-* } } */ + +extern void abort (void); + +volatile int i = 10; +volatile int j = 10; + +int main() +{ + int k = i % j; + if (k != 0) abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20040310-1.c b/SingleSource/Regression/C/gcc-dg/20040310-1.c new file mode 100644 index 0000000000..104e98d088 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040310-1.c @@ -0,0 +1,34 @@ +/* This caused cc1 to segfault on s390x-ibm-linux + due to a bug in if_then_else_cond (combine.c). */ + +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +extern void use (unsigned int x); + +int main (void) +{ + union + { + unsigned int x; + unsigned long pad; + } A; + + struct + { + unsigned int x : 1; + } B; + + A.x = 1; + B.x = 1; + A.x /= B.x; + use (A.x); + + A.x = 1; + B.x = 1; + B.x /= A.x; + use (B.x); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20040311-2.c b/SingleSource/Regression/C/gcc-dg/20040311-2.c new file mode 100644 index 0000000000..9dfbb9947a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040311-2.c @@ -0,0 +1,36 @@ +/* PR target/14533 */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +void bar (char *, int); + +extern char b[]; +extern int d, e; +struct S +{ + struct S *m; + int n; +} **g; + +void +foo (int x, char *y) +{ + struct S *h; + int k = 1, l; + +again: + for (h = *g; h != (struct S *) g; h = h->m) + { + if (k == 0 && h->n & 0x100000); + l = y - b; + if (e) + bar (b, l); + if (d) + bar (b, l); + } + if (k) + { + k = 0; + goto again; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20040322-1.c b/SingleSource/Regression/C/gcc-dg/20040322-1.c new file mode 100644 index 0000000000..139511262e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040322-1.c @@ -0,0 +1,4 @@ +/* PR c/14069 */ +/* { dg-do compile } */ +struct S { int a; char b[]; char *c; }; /* { dg-error "" "flexible array member not" } */ +struct S s = { .b = "foo", .c = .b }; /* { dg-error "" "parse error before" } */ diff --git a/SingleSource/Regression/C/gcc-dg/20040331-1.c b/SingleSource/Regression/C/gcc-dg/20040331-1.c new file mode 100644 index 0000000000..4cef3d3297 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040331-1.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + struct { int count: 2; } s = { -2 }; + while (s.count-- != -2) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20040409-1.c b/SingleSource/Regression/C/gcc-dg/20040409-1.c new file mode 100644 index 0000000000..dc9206a0ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040409-1.c @@ -0,0 +1,4 @@ +/* This tests to make sure that the attribute noreturn + can be used on function pointers. */ + +int (*temp) (void) __attribute__((noreturn)); diff --git a/SingleSource/Regression/C/gcc-dg/20040609-1.c b/SingleSource/Regression/C/gcc-dg/20040609-1.c new file mode 100644 index 0000000000..ef181476e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040609-1.c @@ -0,0 +1,73 @@ +/* PRs target/15569, rtl-optimization/15681 */ +/* { dg-do compile } */ +/* { dg-options "-Os -frename-registers" } */ +/* { dg-options "-mconstant-gp -Os -frename-registers" { target ia64-*-* } } */ + +struct S { struct S *a, *b; }; +struct T { struct S e; unsigned long a; int b, c; void *d; } f; + +unsigned long f1 (unsigned long); +void f2 (int, struct T *); +void *f3 (void *); +unsigned long volatile g; + +static void +f4 (struct T *p) +{ + f1 (f1 (((unsigned long) g - p->a) >> 20)); +} + +static struct T * +f5 (void) +{ + struct T *g, *p; + struct T *q = 0; + for (g = p = &f; (g = p = (struct T *) (g->e.a)) != &f;) + if (p->b) + { + f4 (p); + if (p->c & 0x80000) + return p; + } + return q; +} + +static void +f6 (struct T *p) +{ + f2 (9, p); +} + +static inline void * +f7 (struct T *t) +{ + void *d; + d = t->d; + if (d) + d = f3 (d); + return d; +} + +static void * +f8 (struct T *p) +{ + void *d = f7 (p); + if (!d) + return 0; + f6 (p); + return d; +} + +static void +f9 (void) +{ + struct T *p; + p = f5 (); + f8 (p); +} + +void +test (void) +{ + f9 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/20040622-2.c b/SingleSource/Regression/C/gcc-dg/20040622-2.c new file mode 100644 index 0000000000..e62ec36d43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040622-2.c @@ -0,0 +1,12 @@ +/* { dg-do link } */ +/* { dg-require-effective-target ptr32plus } */ +/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ +/* This validates codegen for [r1+32760] on Darwin. */ +void f(char x[32688], double *y, double *z) __attribute__((noinline)); +void f(char x[32688], double *y, double *z) {} +main() { + char x[32688]; + double y, z; + y = z = 3.0; + f(x, &y, &z); +} diff --git a/SingleSource/Regression/C/gcc-dg/20040625-1.c b/SingleSource/Regression/C/gcc-dg/20040625-1.c new file mode 100644 index 0000000000..0a576a5b64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040625-1.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-mminimal-toc" { target { { powerpc*-*-* && lp64 } || { powerpc-ibm-aix* } } } } */ + +extern void abort (void); +extern void exit (int); + +double __attribute__((noinline)) +foo (void) +{ + return 16441577472.0; +} + +double __attribute__((noinline)) +bar (double x) +{ + return x; +} + +int __attribute__((noinline)) +test (void) +{ + double x = foo (); + x = bar (x); + x /= 1024L * 1024L * 1024L; + x *= 70; + x = x < 70 ? x : 70; + x += 30; + return x; +} + +int main (void) +{ + if (test () != 100) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20040627-1.c b/SingleSource/Regression/C/gcc-dg/20040627-1.c new file mode 100644 index 0000000000..2b4f09fefc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040627-1.c @@ -0,0 +1,42 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern void link_error (void); + + +void test(int x) +{ + if ((x & ~x) != 0) + link_error (); + if ((~x & x) != 0) + link_error (); + + if ((x ^ ~x) != -1) + link_error (); + if ((~x ^ x) != -1) + link_error (); + + if ((x | ~x) != -1) + link_error (); + if ((~x | x) != -1) + link_error (); + + if (x && !x) + link_error (); + if (!x && x) + link_error (); + + if (!(x || !x)) + link_error (); + if (!(!x || x)) + link_error (); +} + +int main() +{ + test (0); + test (1); + test (-1); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/20040910-1.c b/SingleSource/Regression/C/gcc-dg/20040910-1.c new file mode 100644 index 0000000000..ff772ab57b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040910-1.c @@ -0,0 +1,2 @@ +/* Tests error recovery for invalid code. */ +__attribute__((foo) int f (){} /* { dg-error "(parse error|syntax error|expected '\\)') before 'int'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/20040916-1.c b/SingleSource/Regression/C/gcc-dg/20040916-1.c new file mode 100644 index 0000000000..fbea9e385b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040916-1.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* PR17513 - we hit a bug where EDGE_EXECUTABLE was not cleared on + successors of the entry block. This lead to a flow verification + error much later in the compilation (after gcse). */ +typedef unsigned char uint8; +typedef unsigned int uint32; + +uint32 marker = 0; +uint8 *buff = 0; +uint32 bsize = 0; + +extern int foo (void); + +uint32 +bar (void) +{ + int len, d; + + for (;;) + { + if (foo () == 0) + return (0); + + switch (marker) + { + case 0xfe: + { + len |= (*buff++); + bsize -= 2; + + while (len > 0) + { + d = *buff++; + len--; + } + } + break; + default: + break; + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/20040920-1.c b/SingleSource/Regression/C/gcc-dg/20040920-1.c new file mode 100644 index 0000000000..a38ff88893 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20040920-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +int bob; +struct a +{ + int foo; +}; +int main(void) +{ + struct a bar; + bob(5); /* { dg-error "called object 'bob' is not a function" } */ + bar.foo(); /* { dg-error "called object 'bar.foo' is not a function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20041014-1.c b/SingleSource/Regression/C/gcc-dg/20041014-1.c new file mode 100644 index 0000000000..699844074e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20041014-1.c @@ -0,0 +1,10 @@ +/* PR c/17023 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f(a, b) + int a; + int b[({ void h() {} 1; })]; /* { dg-error "braced-group" } */ +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/20041104-1.c b/SingleSource/Regression/C/gcc-dg/20041104-1.c new file mode 100644 index 0000000000..b4d359d1e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20041104-1.c @@ -0,0 +1,18 @@ +/* This testcase exposed the same bug as PR 15342. */ +/* { dg-options "-O2 -frename-registers -fno-schedule-insns" } */ + +void *memcpy (void *, const void *, __SIZE_TYPE__); + +void f (int n, int (*x)[4]) +{ + while (n--) + { + int f = x[0][0]; + if (f <= 0) + memcpy (&x[1], &x[0], sizeof (x[0])); + else + memcpy (&x[f], &x[0], sizeof (x[0])); + f = x[0][2]; + x[0][1] = f; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20041106-1.c b/SingleSource/Regression/C/gcc-dg/20041106-1.c new file mode 100644 index 0000000000..95579ff3ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20041106-1.c @@ -0,0 +1,31 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-solaris* *-*-uclinux* } } */ +/* { dg-options -O2 } */ + +#include +#include +#include +#include + +struct S { long x __attribute__((packed)); }; /* { dg-warning "attribute ignored" "" { target default_packed } } */ +volatile long sink; + +void foo (struct S *s) +{ + sink = s->x; +} + +int main () +{ + size_t ps = getpagesize (); + char *ptr, *page; + struct S *s; + + ptr = malloc (3*ps); + page = (char *)(((__UINTPTR_TYPE__)ptr + (ps - 1)) & -ps); + munmap (page + ps, ps); + + s = (struct S *)(page + ps - sizeof(struct S)); + foo(s); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20041122-1.c b/SingleSource/Regression/C/gcc-dg/20041122-1.c new file mode 100644 index 0000000000..b2120f8154 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20041122-1.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/18611 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fmove-loop-invariants" } */ + +void dumpCineonChannelInfo (); +typedef struct { + int channels_per_image; + int channel[8]; +} CineonImageInformation; +void +dumpCineonImageInfo(CineonImageInformation* imageInfo) { + + int i; + for (i = 0; i < imageInfo->channels_per_image; ++i) { + dumpCineonChannelInfo(&imageInfo->channel[i]); + } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/20041213-1.c b/SingleSource/Regression/C/gcc-dg/20041213-1.c new file mode 100644 index 0000000000..490b6bc187 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20041213-1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-fshow-column -std=gnu89" } */ +/* test redeclarations with void and implicit int */ +extern foo1(); /* { dg-message "8:note: previous declaration" } */ +extern void foo1(); /* { dg-error "13:conflicting types" } */ + +extern void foo2(); /* { dg-message "13:note: previous declaration" } */ +extern foo2(); /* { dg-error "8:conflicting types" } */ + +void foo3() {} /* { dg-message "6:note: previous definition" } */ +extern foo3(); /* { dg-error "8:conflicting types" } */ + +extern foo4(); /* { dg-message "8:note: previous declaration" } */ +void foo4() {} /* { dg-error "6:conflicting types" } */ + +extern void foo5(); /* { dg-message "13:note: previous declaration" } */ +foo5() {} /* { dg-warning "1:conflicting types" } */ + +foo6() {} /* { dg-message "1:note: previous definition" } */ +extern void foo6(); /* { dg-error "13:conflicting types" } */ + +foo7() {} /* { dg-message "1:note: previous definition" } */ +void foo7() {} /* { dg-error "6:conflicting types" } */ + +void foo8() {} /* { dg-message "6:note: previous definition" } */ +foo8() {} /* { dg-error "1:conflicting types" } */ + +int use9() { foo9(); } /* { dg-message "note: previous implicit declaration" } */ +extern void foo9(); /* { dg-warning "13:conflicting types" } */ + +int use10() { foo10(); } /* { dg-message "note: previous implicit declaration" } */ +void foo10() {} /* { dg-warning "6:conflicting types" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/20041219-1.c b/SingleSource/Regression/C/gcc-dg/20041219-1.c new file mode 100644 index 0000000000..4fdc9540d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20041219-1.c @@ -0,0 +1,47 @@ +/* PR18191 Struct member is not getting default-initialized. + Origin: Grigory Zagorodnev */ + +/* { dg-do run } */ + +extern int printf (__const char *__restrict __format, ...); + +typedef struct S { + const char* s; + int i; +} S; + +void +foo (void) +{ + S dummy[2]; + unsigned i; + + /* Put some garbage on the stack. */ + for (i = 0; i < sizeof(dummy); i++) + ((char *)&dummy)[i] = -1; +} + +int +bar (void) +{ + /* Allocate object on the stack. */ + S obj[2] = { {"m0"}, {"m1"} }; + + /* Assume fields those not explicitly initialized + are default initialized to 0 [8.5.1/7 and 8.5/5]. */ + if (obj[0].i == 0) + return 0; + else + { + printf("Failed: obj[0].i == '%d', expecting '0'\n", obj[0].i); + return 1; + } +} + +int +main (void) +{ + foo(); + return bar(); +} + diff --git a/SingleSource/Regression/C/gcc-dg/20050105-1.c b/SingleSource/Regression/C/gcc-dg/20050105-1.c new file mode 100644 index 0000000000..58a75150bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050105-1.c @@ -0,0 +1,31 @@ +/* PR rtl-optimization/18861 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int +foo (int code) +{ + if (code >= 3) + switch (code) + { + case 3: return 4; + case 4: return 3; + case 5: return 6; + case 6: return 7; + case 7: return 8; + case 8: return 5; + default: abort (); + } + switch (code) + { + case 3: return 4; + case 4: return 3; + case 5: return 6; + case 6: return 7; + case 7: return 8; + case 8: return 5; + default: abort (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20050105-2.c b/SingleSource/Regression/C/gcc-dg/20050105-2.c new file mode 100644 index 0000000000..02ac1596b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050105-2.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/18828 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +extern void abort (void); + +void foo (int x, ...) +{ + va_list ap; + if (x != 21) + abort (); + va_start (ap, x); + va_end (ap); +} + +void bar (int x, ...) +{ + va_list ap; + x++; + va_start (ap, x); + va_end (ap); +} + +void baz (int x, ...) +{ + va_list ap; + x = 0; + va_start (ap, x); + va_end (ap); +} diff --git a/SingleSource/Regression/C/gcc-dg/20050111-1.c b/SingleSource/Regression/C/gcc-dg/20050111-1.c new file mode 100644 index 0000000000..0ad256fec4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050111-1.c @@ -0,0 +1,21 @@ +/* PR middle-end/19084, rtl-optimization/19348 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +unsigned int +foo (unsigned long long x) +{ + unsigned int u; + + if (x == 0) + return 0; + u = (unsigned int) (x >> 32); + return u; +} + +unsigned long long +bar (unsigned short x) +{ + return (unsigned long long) x << 32; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050111-2.c b/SingleSource/Regression/C/gcc-dg/20050111-2.c new file mode 100644 index 0000000000..17e59ce968 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050111-2.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/15139 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-loops" } */ + +void +foo (double **a, double **z) +{ + long int i, j; + double d = -1.0; + + for (i = 0; i < 6; i++) + for (j = 0; j < 5; j++) + d = z[i][j] > d ? z[i][j] : d; + + for (i = 0; i < 6; i++) + for (j = 0; j < 5; j++) + z[i][j] /= d; + + for (i = 0; i < 5; i++) + a[i][j] = z[i][j]; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050121-1.c b/SingleSource/Regression/C/gcc-dg/20050121-1.c new file mode 100644 index 0000000000..e7bfdafeb5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050121-1.c @@ -0,0 +1,9 @@ +/* I accidentally broke this while developing a patch for PR 13000, + and didn't notice since the testsuite didn't catch it -- ian */ +/* { dg-do compile } */ + +void foo() +{ + return; + break; /* { dg-error "break statement not within" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20050121-2.c b/SingleSource/Regression/C/gcc-dg/20050121-2.c new file mode 100644 index 0000000000..6a6092c900 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050121-2.c @@ -0,0 +1,67 @@ +/* PR middle-end/19551 */ +/* { dg-options "-O2" } */ +/* { dg-do link } */ + +extern void abort (); + +#define T(type, name) \ +extern __attribute__((pure)) _Complex type \ +foo_c##name (int x); \ + \ +void \ +bar_c##name (type *x) \ +{ \ + type f = __real foo_c##name (5); \ + if (0) *x = f; \ +} \ + \ +void \ +baz_c##name (type *x) \ +{ \ + type f = __imag foo_c##name (5); \ + if (0) *x = f; \ +} \ + \ +extern __attribute__((pure)) type \ +foo_##name (int x); \ + \ +void \ +bar_##name (type *x) \ +{ \ + type f = foo_##name (5); \ + if (0) *x = f; \ +} + +typedef long double ldouble_t; +typedef long long llong; + +T (float, float) +T (double, double) +T (long double, ldouble_t) +T (char, char) +T (short, short) +T (int, int) +T (long, long) +T (long long, llong) +#undef T + +int +main (void) +{ +#define T(type, name) \ + { \ + type var = 0; \ + bar_c##name (&var); \ + baz_c##name (&var); \ + bar_##name (&var); \ + } + T (float, float) + T (double, double) + T (long double, ldouble_t) + T (char, char) + T (short, short) + T (int, int) + T (long, long) + T (long long, llong) + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050209-1.c b/SingleSource/Regression/C/gcc-dg/20050209-1.c new file mode 100644 index 0000000000..0a62ce3518 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050209-1.c @@ -0,0 +1,5 @@ +/* Test for infinite loop in parser error recovery. From Serge + Belyshev on IRC. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +int f() { return 1); } /* { dg-error "parse|syntax|expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/20050307-1.c b/SingleSource/Regression/C/gcc-dg/20050307-1.c new file mode 100644 index 0000000000..0e8dac69a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050307-1.c @@ -0,0 +1,52 @@ +/* PR target/20322 */ + +extern void abort (void); + +typedef unsigned long T; +typedef struct +{ + T a, b; + unsigned char c, d; +} S; + +#define M (sizeof (T) * 4) + +S __attribute__((noinline)) +foo (T x, T y) +{ + S e; + T f[2], g; + + e.b = (x & (~(T) 0 >> M)) * (y & (~(T) 0 >> M)); + e.a = (x >> M) * (y >> M); + + f[0] = (x & (~(T) 0 >> M)) * (y >> M); + f[1] = (x >> M) * (y & (~(T) 0 >> M)); + + g = e.b; + e.b += (f[0] & (~(T) 0 >> M)) << M; + if (e.b < g) + e.a++; + + g = e.b; + e.b += (f[1] & (~(T) 0 >> M)) << M; + if (e.b < g) + e.a++; + + e.a += (f[0] >> M); + e.a += (f[1] >> M); + e.c = 1; + e.d = 0; + + return e; +} + +int +main (void) +{ + T x = 1UL << (M * 2 - 1); + S y = foo (1, x); + if (y.a || y.b != x || y.c != 1 || y.d) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050309-1.c b/SingleSource/Regression/C/gcc-dg/20050309-1.c new file mode 100644 index 0000000000..46b27f82e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050309-1.c @@ -0,0 +1,41 @@ +/* This caused an ICE on s390 due to incorrect secondary + output reloads. */ + +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O2 -fprofile-generate" } */ + +void lookup (); +int hash (); +void error (); + +char * +test(char *ret, int *counter, void *schema, + const char* name, const char *namespace, + void *node, int topLevel) +{ + char buf[30]; + int val; + + if (counter == 0) return 0; + if (schema == 0) return 0; + if (name == 0) return 0; + + __builtin_memset (ret, 0, 100); + lookup (schema, name, -1); + val = hash (schema, name, namespace, name, ret); + if (val == 0) return ret; + + if (topLevel != 0) + { + error (1, 0, 0, node, "%s", name); + return 0; + } + + __snprintf_chk (buf, 29, 1, 30, "#eCont %d", ++*counter); + val = hash (schema, name, buf, namespace, ret); + if (val == 0) return ret; + + error (1, 0, 0, node, "%s", name); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050321-1.c b/SingleSource/Regression/C/gcc-dg/20050321-1.c new file mode 100644 index 0000000000..79f62a3260 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050321-1.c @@ -0,0 +1,26 @@ +/* This caused an ICE on powerpc-linux-gnu due to not + up-to-date life info (PR middle-end/20177). */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fmodulo-sched" } */ +extern void * malloc (__SIZE_TYPE__); + +struct s { + int k; +}; + +int n; +struct s *a1, *(*use)[]; +float (*vector)[]; + +void +foo (float *V) +{ + int i, used = 0; + + vector = malloc (i * sizeof (float)); + while ((*use)[used] != a1) + used += 1; + for (i = 0; i < n; i++) + *V += (*vector)[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050321-2.c b/SingleSource/Regression/C/gcc-dg/20050321-2.c new file mode 100644 index 0000000000..1c5575bde2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050321-2.c @@ -0,0 +1,55 @@ +/* This testcase could not assemble on ppc32, because the compiler assumed + the huge ADDR_DIFF_VEC will be emitted into rodata section, yet because + of some notes inserted between jump table's CODE_LABEL and the jump table + it ended up in the .text section and thus shorten_branches couldn't + figure out branch to lab is too far. */ +/* { dg-do link { target fpic } } */ +/* { dg-options "-g1 -fpic" } */ +/* { dg-require-effective-target int32plus } */ + +#define A(n) \ + case n##1: return n##1 * 131 + 63; \ + case n##3: return n##3 * 1231 + 182; \ + case n##5: return n##5 * 351 + 1; \ + case n##7: return n##7 * 312 + 61; \ + case n##9: return n##9 * 17 - 1; +#define B(n) \ +A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) \ +A(n##5) A(n##6) A(n##7) A(n##8) A(n##9) +#define C(n) \ +B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) \ +B(n##5) B(n##6) B(n##7) B(n##8) B(n##9) +#define D(n) \ +C(n##0) C(n##1) B(n##20) B(n##21) B(n##22) + +int +foo (int x) +{ + { +lab:; + int a = x; + while (a < 60000) + { + int b = a; + { + int c = b; + switch (c) + { + D(1) + default: break; + } + } + a += 10000; + if (a == 4168) + goto lab; + } + } + return x; +} + +int +main (void) +{ + foo (71); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050325-1.c b/SingleSource/Regression/C/gcc-dg/20050325-1.c new file mode 100644 index 0000000000..db288ee8f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050325-1.c @@ -0,0 +1,20 @@ +/* PR 20249 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fprofile-arcs" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +extern int *g (int x, void* y); +extern void fg (long long x, int y); + +static void +ff (int y, long long z) +{ + fg (z, 1); +} + +void +f () +{ + g (42, ff); +} diff --git a/SingleSource/Regression/C/gcc-dg/20050330-1.c b/SingleSource/Regression/C/gcc-dg/20050330-1.c new file mode 100644 index 0000000000..69b5f9dcfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050330-1.c @@ -0,0 +1,14 @@ +/* This test is a reduced test case for a bug that caused + ICE while bootstrapping with -fmodulo-sched on powerpc-apple-darwin + related to (PR middle-end/20177). */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fmodulo-sched" } */ + +void +foo ( const char *bytes, int len , char *buf) +{ + int i; + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050330-2.c b/SingleSource/Regression/C/gcc-dg/20050330-2.c new file mode 100644 index 0000000000..f2562a8cb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050330-2.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O2 -fprofile-generate" } */ + +struct S +{ + int a; + void **b; +}; + +void +foo (struct S *x, int y) +{ + if (!x) + return; + if (y >= x->a) + return; + x->a--; + for (; y < x->a; y++) + x->b[y] = x->b[y + 1]; + x->b[x->a] = (void *) 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050503-1.c b/SingleSource/Regression/C/gcc-dg/20050503-1.c new file mode 100644 index 0000000000..57dfefcf07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050503-1.c @@ -0,0 +1,50 @@ +/* PR middle-end/21265 + Test whether tail call information is propagated through builtin + expanders. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { { i?86-*-* x86_64-*-* } && { ia32 && { ! nonpic } } } } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; + +#define F(n, rettype, name, args, callargs) \ +extern rettype name args; \ +rettype test##n args \ +{ \ + return name callargs; \ +} +#define F1(n, rettype, name, t1, callargs) \ + F (n, rettype, name, (t1 a1), callargs) +#define F2(n, rettype, name, t1, t2, callargs) \ + F (n, rettype, name, (t1 a1, t2 a2), callargs) +#define F3(n, rettype, name, t1, t2, t3, callargs) \ + F (n, rettype, name, (t1 a1, t2 a2, t3 a3), callargs) + +F3 (1a, void *, memcpy, void *, const void *, size_t, (a1, a2, a3)) +F3 (1b, void *, memcpy, void *, const void *, size_t, (a1, a2, 10)) +F3 (2a, void *, mempcpy, void *, const void *, size_t, (a1, a2, a3)) +F3 (2b, void *, mempcpy, void *, const void *, size_t, (a1, a2, 10)) +F3 (3a, void *, memmove, void *, const void *, size_t, (a1, a2, a3)) +F3 (3b, void *, memmove, void *, const void *, size_t, (a1, "abcdefghijklmno", a3)) +F3 (4a, void *, memset, void *, int, size_t, (a1, a2, a3)) +F3 (4b, void *, memset, void *, int, size_t, (a1, a2, 156)) +F3 (4c, void *, memset, void *, int, size_t, (a1, 0, a3)) +F3 (4d, void *, memset, void *, int, size_t, (a1, 0, 10000)) +F3 (5a, int, memcmp, const void *, const void *, size_t, (a1, a2, a3)) +F3 (5b, int, memcmp, const void *, const void *, size_t, (a1, "abcdefghijkl", a3)) +F2 (6, char *, strcpy, char *, const char *, (a1, a2)) +F2 (7, char *, stpcpy, char *, const char *, (a1, a2)) +F3 (8, char *, strncpy, char *, const char *, size_t, (a1, a2, a3)) +F3 (9, char *, stpncpy, char *, const char *, size_t, (a1, a2, a3)) +F2 (10, char *, strcat, char *, const char *, (a1, a2)) +F3 (11, char *, strncat, char *, const char *, size_t, (a1, a2, a3)) +F1 (12a, size_t, strlen, const char *, (a1)) +F1 (12b, size_t, strlen, const char *, ("foobar")) +F2 (13a, int, strcmp, const char *, const char *, (a1, a2)) +F2 (13b, int, strcmp, const char *, const char *, (a1, "abcdefghijklm")) +F3 (14a, int, strncmp, const char *, const char *, size_t, (a1, a2, a3)) +F3 (14b, int, strncmp, const char *, const char *, size_t, (a1, "abcdefghijklm", 10)) +F2 (15, char *, strchr, const char *, int, (a1, a2)) + +/* All the calls above should be tail call optimized on i?86/x86-64. */ +/* { dg-final { scan-assembler-not "call" { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20050517-1.c b/SingleSource/Regression/C/gcc-dg/20050517-1.c new file mode 100644 index 0000000000..856fda206b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050517-1.c @@ -0,0 +1,8 @@ +/* Tree PRE is going to transform this so that it doesn't call cos on the + d = 0 path, and in doing so, it needs to regenerate the cos call. + This was ICE'ing due to an overly strict check on what it knew how + to regenerate. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ +double cos(double); +double f(double d, double i, int j) { if (j == 1) d = 0; return d * cos(i); } diff --git a/SingleSource/Regression/C/gcc-dg/20050527-1.c b/SingleSource/Regression/C/gcc-dg/20050527-1.c new file mode 100644 index 0000000000..1b32324471 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050527-1.c @@ -0,0 +1,55 @@ +/* PR c/21536 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +typedef __SIZE_TYPE__ size_t; +extern void *malloc (size_t); +extern void free (void *); + +void * +foo (int x, int y) +{ + void *d = malloc (x * y * sizeof (double)); + double (*e)[x][y] = d; + x += 10; + y += 10; + if (x > 18) + (*e)[x - 12][y - 12] = 0.0; + else + (*e)[x - 11][y - 11] = 1.0; + return d; +} + +void * +bar (int x, int y) +{ + void *d = malloc (x * y * sizeof (double)); + struct S + { + double (*e)[x][y]; + double (*f)[x][y]; + } s; + s.e = d; + s.f = d; + x += 10; + y += 10; + if (x > 18) + (*s.e)[x - 12][y - 12] = 0.0; + else + (*s.e)[x - 11][y - 11] = 1.0; + if (x > 16) + (*s.f)[x - 13][y - 13] = 0.0; + else + (*s.f)[x - 14][y - 14] = 1.0; + return d; +} + +int +main () +{ + void *d1 = foo (10, 10); + void *d2 = bar (10, 10); + free (d1); + free (d2); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050603-2.c b/SingleSource/Regression/C/gcc-dg/20050603-2.c new file mode 100644 index 0000000000..a135e3ea1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050603-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "no stdlib.h in eBPF" { bpf-*-* } } */ +#include +struct s { + unsigned short f: 16; + unsigned short y: 8; + unsigned short g: 2; + unsigned int x; +}; + +void set (struct s*, int) __attribute__((noinline)); +void set (struct s* p, int flags) { + p->g = flags << 1; +} + +int +main() { + struct s foo = {0 , 0, 3, 0}; + set (&foo, -1); + if (foo.g != 2) + abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050607-1.c b/SingleSource/Regression/C/gcc-dg/20050607-1.c new file mode 100644 index 0000000000..83c0967480 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050607-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target trampolines } */ +/* { dg-options "-Wpadded" } +/* The struct internally constructed for the nested function should + not result in a warning from -Wpadded. */ +extern int baz(int (*) (int)); +int foo(void) +{ + int k = 3; + int bar(int x) { + return x + k; + } + return baz(bar); +} diff --git a/SingleSource/Regression/C/gcc-dg/20050620-1.c b/SingleSource/Regression/C/gcc-dg/20050620-1.c new file mode 100644 index 0000000000..befdd96365 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050620-1.c @@ -0,0 +1,15 @@ +/* PR middle-end/22028 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo (void) +{ + struct { int i[]; } u; /* { dg-error "flexible array member" } */ +} + +void +bar (void) +{ + struct { struct a b; } c; /* { dg-error "has incomplete type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20050629-1.c b/SingleSource/Regression/C/gcc-dg/20050629-1.c new file mode 100644 index 0000000000..99d9ce823b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050629-1.c @@ -0,0 +1,298 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ +/* { dg-skip-if "too many arguments in function call" { bpf-*-* } } */ + +/* This file was automatically reduced from tree-ssa-operands.c. It + contains many warnings, but it exposes a copy propagation bug that + is somewhat difficult to reproduce otherwise. */ + +__extension__ typedef __SIZE_TYPE__ size_t; + extern void fancy_abort (const char *, int, const char *) __attribute__ ((__noreturn__)); + typedef union tree_node *tree; + enum tree_code { + TREE_LIST, ARRAY_TYPE, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, STRING_CST, LT_EXPR, GE_EXPR, LABEL_EXPR, ASM_EXPR, SSA_NAME, }; + enum tree_code_class { + tcc_type, tcc_reference, tcc_expression }; + extern const enum tree_code_class tree_code_type[]; + extern const unsigned char tree_code_length[]; + struct tree_common { + union tree_ann_d *ann; + __extension__ enum tree_code code : 8; + }; + struct tree_string { + char str[1]; + }; + struct tree_list { + tree purpose; + tree value; + }; + struct tree_exp { + tree operands[1]; + }; + typedef struct ssa_use_operand_d { + struct ssa_use_operand_d* prev; + struct ssa_use_operand_d* next; + tree stmt; + tree * use; + } + ssa_use_operand_t; + struct tree_ssa_name { + struct ssa_use_operand_d imm_uses; + }; + union tree_node { + struct tree_common common; + struct tree_string string; + struct tree_list list; + struct tree_exp exp; + struct tree_ssa_name ssa_name; + }; + typedef struct bitmap_head_def *bitmap; + typedef union varray_data_tag { + char c[1]; + int i[1]; + tree * tp[1]; + } + varray_data; + struct varray_head_tag { + size_t num_elements; + size_t elements_used; + varray_data data; + }; + typedef struct varray_head_tag *varray_type; + extern void varray_check_failed (varray_type, size_t, const char *, int, const char *) __attribute__ ((__noreturn__)); + typedef ssa_use_operand_t *use_operand_p; + struct use_optype_d { + struct use_optype_d *next; + struct ssa_use_operand_d use_ptr; + }; + typedef struct use_optype_d *use_optype_p; + struct ssa_operand_memory_d { + char mem[(2048 - sizeof (void *))]; + }; + struct stmt_operands_d { + struct use_optype_d * use_ops; + }; + struct ptr_info_def { + tree name_mem_tag; + }; + typedef struct subvar *subvar_t; + struct var_ann_d { + size_t uid; + }; + struct stmt_ann_d { + unsigned modified : 1; + struct stmt_operands_d operands; + bitmap addresses_taken; + }; + typedef struct var_ann_d *var_ann_t; + typedef struct stmt_ann_d *stmt_ann_t; + static __inline__ var_ann_t var_ann (tree t) { + } + static __inline__ stmt_ann_t stmt_ann (tree t) { + ((void)(!(is_gimple_stmt (t)) ? fancy_abort ("/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-flow-inline.h", 55, __FUNCTION__), 0 : 0)); + return (stmt_ann_t) t->common.ann; + } + static __inline__ unsigned char stmt_modified_p (tree t) { + stmt_ann_t ann = stmt_ann (t); + return ann ? ann->modified : 1; + } + static __inline__ void delink_imm_use (ssa_use_operand_t *linknode) { + if (linknode->prev == ((void *)0)) return; + linknode->prev->next = linknode->next; + linknode->next->prev = linknode->prev; + linknode->prev = ((void *)0); + linknode->next = ((void *)0); + } + static __inline__ void link_imm_use_to_list (ssa_use_operand_t *linknode, ssa_use_operand_t *list) { + linknode->prev = list; + linknode->next = list->next; + list->next = linknode; + } + static __inline__ void link_imm_use (ssa_use_operand_t *linknode, tree def) { + ssa_use_operand_t *root; + if (!def || ((enum tree_code) (def)->common.code) != SSA_NAME) linknode->prev = ((void *)0); + else { + root = &(__extension__ ({ const tree __t = (def); if (((enum tree_code) (__t)->common.code) != (SSA_NAME)) tree_check_failed (__t, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-flow-inline.h", 222, __FUNCTION__, (SSA_NAME), 0); __t; } +)->ssa_name.imm_uses); + link_imm_use_to_list (linknode, root); + } + } + static __inline__ void link_imm_use_stmt (ssa_use_operand_t *linknode, tree def, tree stmt) { + link_imm_use (linknode, def); + } + struct ggc_root_tab { + }; + struct opbuild_list_d { + varray_type vars; + varray_type uid; + varray_type next; + int first; + unsigned num; + }; + static struct opbuild_list_d build_uses; + static struct opbuild_list_d build_v_may_defs; + static struct ssa_operand_memory_d *operand_memory = ((void *)0); + static unsigned operand_memory_index; + static use_optype_p free_uses = ((void *)0); + static __inline__ int opbuild_next (struct opbuild_list_d *list, int prev) { + return __extension__ (*({ + varray_type const _va = (list->next); + const size_t _n = (prev); + if (_n >= _va->num_elements) varray_check_failed (_va, _n, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 323, __FUNCTION__); + &_va->data.i[_n]; + } +)); + } + static __inline__ tree * opbuild_elem_real (struct opbuild_list_d *list, int elem) { + return __extension__ (*({ + varray_type const _va = (list->vars); + const size_t _n = (elem); + if (_n >= _va->num_elements) varray_check_failed (_va, _n, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 332, __FUNCTION__); + &_va->data.tp[_n]; + } +)); + } + static __inline__ void opbuild_clear (struct opbuild_list_d *list) { + ((list->vars)->elements_used = 0); + ((list->next)->elements_used = 0); + } + static __inline__ void * ssa_operand_alloc (unsigned size) { + char *ptr; + if (operand_memory_index + size >= (2048 - sizeof (void *))) { + ptr = ggc_alloc_stat (sizeof (struct ssa_operand_memory_d) ); + } + ptr = &(operand_memory->mem[operand_memory_index]); + return ptr; + } + static __inline__ void correct_use_link (use_operand_p ptr, tree stmt) { + use_operand_p prev; + tree root; + prev = ptr->prev; + if (prev) { + unsigned char stmt_mod = 1; + while (stmt_mod) { while (prev->stmt == stmt || prev->stmt == ((void *)0)) prev = prev->prev; if (prev->use == ((void *)0)) stmt_mod = 0; else if ((stmt_mod = stmt_modified_p (prev->stmt))) prev = prev->prev; } + if (prev->use == ((void *)0)) root = prev->stmt; + else root = *(prev->use); + if (root == *(ptr->use)) return; + } + delink_imm_use (ptr); + link_imm_use (ptr, *(ptr->use)); + } + static __inline__ struct use_optype_d * alloc_use (void) { + struct use_optype_d *ret; + { + free_uses = free_uses->next; + } + ret = (struct use_optype_d *)ssa_operand_alloc (sizeof (struct use_optype_d)); + return ret; + } + static __inline__ void finalize_ssa_use_ops (tree stmt) { + int new_i; + struct use_optype_d *old_ops, *ptr, *last; + tree * old_base; + struct use_optype_d new_list; + last = &new_list; + if (old_ops) old_base = ((old_ops)->use_ptr.use); + while (old_ops && new_i != -1) { + tree * new_base = opbuild_elem_real (&build_uses, (new_i)); + if (old_base == new_base) { last->next = old_ops; last = old_ops; correct_use_link ((&((last)->use_ptr)), stmt); old_ops = old_ops->next; new_i = opbuild_next (&build_uses, new_i); } + else if (old_base < new_base) { use_operand_p use_p = (&((old_ops)->use_ptr)); delink_imm_use (use_p); old_ops = old_ops->next; ptr->next = free_uses; } + else { ptr = alloc_use (); (ptr)->use_ptr.use = (opbuild_elem_real (&build_uses, (new_i))); link_imm_use_stmt (&((ptr)->use_ptr), *(opbuild_elem_real (&build_uses, (new_i))), (stmt)); new_i = opbuild_next (&build_uses, new_i); } + if (old_ops) old_base = ((old_ops)->use_ptr.use); + } + for ( ; + new_i != -1; + new_i = opbuild_next (&build_uses, new_i)) { + ptr = alloc_use (); + (ptr)->use_ptr.use = (opbuild_elem_real (&build_uses, (new_i))); + link_imm_use_stmt (&((ptr)->use_ptr), *(opbuild_elem_real (&build_uses, (new_i))), (stmt)); + } + { + { use_operand_p use_p = (&((ptr)->use_ptr)); delink_imm_use (use_p); } + } + (stmt_ann (stmt)->operands.use_ops) = new_list.next; + { + unsigned x = 0; + for (ptr = (stmt_ann (stmt)->operands.use_ops); + ptr; + ptr = ptr->next) x++; + } + } + finalize_ssa_uses (tree stmt) { + { + unsigned x; + ((void)(!(*(opbuild_elem_real (&build_uses, x)) != stmt) ? fancy_abort ("/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 581, __FUNCTION__), 0 : 0)); + } + finalize_ssa_use_ops (stmt); + opbuild_clear (&build_uses); + } + finalize_ssa_v_may_def_ops (tree stmt) { + int new_i; + { + } + for ( ; + new_i != -1; + new_i = opbuild_next (&build_v_may_defs, new_i)) { + } + { + } + } + get_expr_operands (tree stmt, tree *expr_p, int flags) { + enum tree_code code; + tree expr = *expr_p; + { + { subvar_t svars; if (var_can_have_subvars (expr) && (svars = get_subvars_for_var (expr))) { } { } } + { { if (code == LT_EXPR || code == GE_EXPR) { swap_tree_operands (stmt, &__extension__ (*({const tree __t = __extension__ ({ const tree __t = (expr); char const __c = tree_code_type[(int) (((enum tree_code) (__t)->common.code))]; if (!((__c) >= tcc_reference && (__c) <= tcc_expression)) tree_class_check_failed (__t, tcc_expression, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1435, __FUNCTION__); __t; }); const int __i = (0); if (__i < 0 || __i >= tree_code_length[(int) (((enum tree_code) (__t)->common.code))]) tree_operand_check_failed (__i, ((enum tree_code) (__t)->common.code), "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1435, __FUNCTION__); &__t->exp.operands[__i]; })), &__extension__ (*({const tree __t = __extension__ ({ const tree __t = (expr); char const __c = tree_code_type[(int) (((enum tree_code) (__t)->common.code))]; if (!((__c) >= tcc_reference && (__c) <= tcc_expression)) tree_class_check_failed (__t, tcc_expression, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1436, __FUNCTION__); __t; }); const int __i = (1); if (__i < 0 || __i >= tree_code_length[(int) (((enum tree_code) (__t)->common.code))]) tree_operand_check_failed (__i, ((enum tree_code) (__t)->common.code), "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1436, __FUNCTION__); &__t->exp.operands[__i]; }))); } { } } } + } + } + get_asm_expr_operands (tree stmt) { + int noutputs = list_length (__extension__ (*({ +const tree __t = __extension__ ({ const tree __t = (__extension__ ({ const tree __t = (stmt); if (((enum tree_code) (__t)->common.code) != (ASM_EXPR)) tree_check_failed (__t, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1495, __FUNCTION__, (ASM_EXPR), 0); __t; })); char const __c = tree_code_type[(int) (((enum tree_code) (__t)->common.code))]; if (!((__c) >= tcc_reference && (__c) <= tcc_expression)) tree_class_check_failed (__t, tcc_expression, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1495, __FUNCTION__); __t; } +); + const int __i = (1); + if (__i < 0 || __i >= tree_code_length[(int) (((enum tree_code) (__t)->common.code))]) tree_operand_check_failed (__i, ((enum tree_code) (__t)->common.code), "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1495, __FUNCTION__); + &__t->exp.operands[__i]; + } +))); + const char **oconstraints = (const char **) __builtin_alloca((noutputs) * sizeof (const char *)); + int i; + tree link; + const char *constraint; + unsigned char allows_mem, allows_reg, is_inout; + { + oconstraints[i] = constraint = ((const char *)(__extension__ ({ const tree __t = ((__extension__ ({ const tree __t = ((__extension__ ({ const tree __t = (link); if (((enum tree_code) (__t)->common.code) != (TREE_LIST)) tree_check_failed (__t, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1506, __FUNCTION__, (TREE_LIST), 0); __t; })->list.purpose)); if (((enum tree_code) (__t)->common.code) != (TREE_LIST)) tree_check_failed (__t, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1506, __FUNCTION__, (TREE_LIST), 0); __t; })->list.value)); if (((enum tree_code) (__t)->common.code) != (STRING_CST)) tree_check_failed (__t, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1506, __FUNCTION__, (STRING_CST), 0); __t; } +)->string.str)); + parse_output_constraint (&constraint, i, 0, 0, &allows_mem, &allows_reg, &is_inout); + } + } + get_indirect_ref_operands (tree stmt, tree expr, int flags) { + tree *pptr = &__extension__ (*({ +const tree __t = __extension__ ({ const tree __t = (expr); char const __c = tree_code_type[(int) (((enum tree_code) (__t)->common.code))]; if (!((__c) >= tcc_reference && (__c) <= tcc_expression)) tree_class_check_failed (__t, tcc_expression, "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1591, __FUNCTION__); __t; } +); + const int __i = (0); + if (__i < 0 || __i >= tree_code_length[(int) (((enum tree_code) (__t)->common.code))]) tree_operand_check_failed (__i, ((enum tree_code) (__t)->common.code), "/home/cygnus/dnovillo/gcc/src.ppc64/gcc/tree-ssa-operands.c", 1591, __FUNCTION__); + &__t->exp.operands[__i]; + } +)); + tree ptr = *pptr; + { + struct ptr_info_def *pi = ((void *)0); + if (((enum tree_code) (ptr)->common.code) == SSA_NAME && pi->name_mem_tag) { } + } + } + note_addressable (tree var, stmt_ann_t s_ann) { + subvar_t svars; + { + if (var_can_have_subvars (var) && (svars = get_subvars_for_var (var))) bitmap_set_bit (s_ann->addresses_taken, var_ann (var)->uid); + } + } + const struct ggc_root_tab gt_ggc_r_gt_tree_ssa_operands_h[] = { + { + &operand_memory, } +, { + } +, { + } +, { + } +, }; diff --git a/SingleSource/Regression/C/gcc-dg/20050702-1.c b/SingleSource/Regression/C/gcc-dg/20050702-1.c new file mode 100644 index 0000000000..ce151d3613 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050702-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* We going into an infinite loop in fold because we + were mishandling the return value of + fold_to_nonsharp_ineq_using_bound. */ +_Bool f(); +void g(int); +void h (int old_size) +{ + int new_size = old_size, i; + g(old_size - 1); + i = 0; + while (i < old_size - 1) + { + if (f()) + { + i++; + continue; + } + while (i < old_size - 1) + i++; + } + g(new_size); +} diff --git a/SingleSource/Regression/C/gcc-dg/20050811-1.c b/SingleSource/Regression/C/gcc-dg/20050811-1.c new file mode 100644 index 0000000000..e74a14f192 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050811-1.c @@ -0,0 +1,19 @@ +/* Test whether -fdump-rtl-all-graph doesn't crash. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-all-graph" } */ + +int foo (void) +{ + return 6; +} + +int bar (int x) +{ + if (x < 0) + return foo () + 8; + else if (x > 0) + return 2 * foo (); + else + return foo (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/20050811-2.c b/SingleSource/Regression/C/gcc-dg/20050811-2.c new file mode 100644 index 0000000000..fab8de1545 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050811-2.c @@ -0,0 +1,19 @@ +/* Test whether graph dumping doesn't crash. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-postreload-graph" } */ + +int foo (void) +{ + return 6; +} + +int bar (int x) +{ + if (x < 0) + return foo () + 8; + else if (x > 0) + return 2 * foo (); + else + return foo (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/20050826-1.c b/SingleSource/Regression/C/gcc-dg/20050826-1.c new file mode 100644 index 0000000000..9595236cf9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050826-1.c @@ -0,0 +1,52 @@ +/* Test whether strncmp has not been "optimized" into memcmp + nor any code with memcmp semantics. */ +/* { dg-do run { target mmap } } */ +/* { dg-options "-O2" } */ +#include +#include +#include +/* Darwin spells this differently */ +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_ANON +#define MAP_ANON 0 +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif +#include + + struct Flags { + int filler[18]; + unsigned int a:14; + unsigned int b:14; + unsigned int c:1; + unsigned int d:1; + unsigned int e:1; + unsigned int f:1; + }; +static void __attribute__((noinline)) set (struct Flags *); +static void set (struct Flags *fp) +{ + fp->b = 5; + fp->d = 1; +} + +static int __attribute__((noinline)) bar (int); +static int bar(int x) { return !(x==1); } +int main (void) +{ + char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + struct Flags *fp; + if (p == MAP_FAILED) + return 0; + if (munmap (p + 65536, 65536) < 0) + return 0; + fp = (struct Flags*)(p + 65536 - sizeof(struct Flags)); + set(fp); + if (fp->b > 0) + return (bar(fp->d)); + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050922-1.c b/SingleSource/Regression/C/gcc-dg/20050922-1.c new file mode 100644 index 0000000000..982f82011b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050922-1.c @@ -0,0 +1,47 @@ +/* This revealed a bug when rotates are expanded into + two shifts. */ + +/* { dg-do run } */ +/* { dg-options "-O1 -std=c99" } */ + +extern void abort (void); + +#if __INT_MAX__ == 2147483647 +typedef unsigned int uint32_t; +#elif __LONG_MAX__ == 2147483647 +typedef unsigned long uint32_t; +#else +#error unable to find 32-bit integer type +#endif + +uint32_t +f (uint32_t *S, int j) +{ + uint32_t A, B, k, L[2] = {1234, 5678}; + int i, m; + + A = B = 0; + for (i = 0; i < j; i++) + { + k = (S[i] + A + B) & 0xffffffffL; + A = S[i] = + ((k << (3 & 0x1f)) | ((k & 0xffffffff) >> (32 - (3 & 0x1f)))); + + m = (int) (A + B); + k = (L[i] + A + B) & 0xffffffffL; + B = L[i] = + ((k << (m & 0x1f)) | ((k & 0xffffffff) >> (32 - (m & 0x1f)))); + } + return L[0] + L[1]; +} + +int +main () +{ + uint32_t S[2] = {0xffff, 0xffffff}; + + if (f (S,2)!= 1392607300) + abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20050922-2.c b/SingleSource/Regression/C/gcc-dg/20050922-2.c new file mode 100644 index 0000000000..2e8db829e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20050922-2.c @@ -0,0 +1,34 @@ +/* 20050922-1.c does not trigger the expand_shift rotate bug on sh4-elf, but + this does. */ + +/* { dg-do run } */ +/* { dg-options "-O1 -std=c99" } */ + +extern void abort (void); +extern void exit (int); + +#if __INT_MAX__ == 2147483647 +typedef unsigned int uint32_t; +#elif __LONG_MAX__ == 2147483647 +typedef unsigned long uint32_t; +#else +#error unable to find 32-bit integer type +#endif + +#define rotl(x,n) (((x) << ((int)(n))) | ((x) >> (32 - (int)(n)))) + +uint32_t +f (uint32_t a, uint32_t b) +{ + + b = rotl (a, b & 31); + return b; +} + +int +main () +{ + if (f(2,31) != 1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20051201-1.c b/SingleSource/Regression/C/gcc-dg/20051201-1.c new file mode 100644 index 0000000000..c029205457 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20051201-1.c @@ -0,0 +1,27 @@ +/* This failed with profiling due to a missing check in + tree_flow_call_edges_add. */ + +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O1 -fprofile-generate -Wno-attributes" } */ + +static __attribute__ ((always_inline)) void +baz () +{ +} + +static __attribute__ ((always_inline)) int +bar () +{ + out: + baz (); + goto out; +} + +int +foo () +{ + long res; + + res = bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/20051207-1.c b/SingleSource/Regression/C/gcc-dg/20051207-1.c new file mode 100644 index 0000000000..326fb0271a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20051207-1.c @@ -0,0 +1,5 @@ +/* GCC doesn't generate any .eh_frame data for this TU itself, so it + shouldn't warn about "a" conflicting with the built-in idea of + .eh_frame, even if it thinks that .eh_frame should be read-only. */ +/* { dg-require-named-sections "" } */ +int a __attribute__((section (".eh_frame"))) = 1; diff --git a/SingleSource/Regression/C/gcc-dg/20051207-2.c b/SingleSource/Regression/C/gcc-dg/20051207-2.c new file mode 100644 index 0000000000..8a8708794a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20051207-2.c @@ -0,0 +1,5 @@ +/* GCC doesn't generate any .eh_frame data for this TU itself, so it + shouldn't warn about "a" conflicting with the built-in idea of + .eh_frame, even if it thinks that .eh_frame should be read-write. */ +/* { dg-require-named-sections "" } */ +const int a __attribute__((section (".eh_frame"))) = 1; diff --git a/SingleSource/Regression/C/gcc-dg/20051207-3.c b/SingleSource/Regression/C/gcc-dg/20051207-3.c new file mode 100644 index 0000000000..3d4b2a48c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20051207-3.c @@ -0,0 +1,7 @@ +/* GCC doesn't generate any .eh_frame data for this TU itself, so it + shouldn't warn about "a" conflicting with the built-in idea of + .eh_frame. The warning therefore belongs on the second decl. */ +/* { dg-options "-fno-unit-at-a-time" } */ +/* { dg-require-named-sections "" } */ +int a __attribute__((section (".eh_frame"))) = 1; +const int b __attribute__((section (".eh_frame"))) = 1; /* { dg-error "section type conflict" } */ diff --git a/SingleSource/Regression/C/gcc-dg/20060410.c b/SingleSource/Regression/C/gcc-dg/20060410.c new file mode 100644 index 0000000000..b4d00cb991 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20060410.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +/* Make sure we didn't eliminate foo because we thought it was unused. */ + +struct foo +{ + int i; +}; + +int bar (void) +{ + return ((struct foo *)0x1234)->i; +} + +/* { dg-final { scan-assembler "foo" { xfail nvptx-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20060419-1.c b/SingleSource/Regression/C/gcc-dg/20060419-1.c new file mode 100644 index 0000000000..754774162a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20060419-1.c @@ -0,0 +1,4 @@ +struct T { + unsigned char f[1] __attribute__((packed)); /* { dg-warning "ignored for field of type.*unsigned char\\\[1\\\]" } */ + unsigned char g[14] __attribute__((packed)); /* { dg-warning "ignored for field of type.*unsigned char\\\[14\\\]" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/20060425-1.c b/SingleSource/Regression/C/gcc-dg/20060425-1.c new file mode 100644 index 0000000000..7d899b2bba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20060425-1.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +/* This failed because if conversion didn't handle insv patterns properly. */ + +void abort (void); + +union y +{ + int a; + unsigned short b; +}; + +void __attribute__ ((noinline)) +bar (unsigned short u, union y v) +{ + if (u != 1) + abort (); +} + +void __attribute__ ((noinline)) +foo (int check) +{ + union y x; + + if (check != 0) + x.b = 1; + else + x.b = 2; + bar (x.b, x); +} + +int +main () +{ + foo (1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20060425-2.c b/SingleSource/Regression/C/gcc-dg/20060425-2.c new file mode 100644 index 0000000000..2a5e131a10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20060425-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +double +crashme (double v, double *p) +{ + if (v < 0. && *p == 1.) + v = 0.; + return v; +} diff --git a/SingleSource/Regression/C/gcc-dg/20060801-1.c b/SingleSource/Regression/C/gcc-dg/20060801-1.c new file mode 100644 index 0000000000..c036acbec8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20060801-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-fPIC" } */ +char *ptr = 0; +char array[100]; +void +f() +{ + ptr = &array[0x100000000ULL]; /* A 33-bit constant. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/20061026.c b/SingleSource/Regression/C/gcc-dg/20061026.c new file mode 100644 index 0000000000..fa8069ce4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20061026.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ +/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ + +/* This testcase failed on s390. The frame size for function f will be + exactly 32768 bytes. The back end has to recognize that this is to + large for a 16bit constant and therefore should reserve the literal + pool base pointer. */ + +void g (); + +int f () { + char a[32608]; + + g (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/20061109-1.c b/SingleSource/Regression/C/gcc-dg/20061109-1.c new file mode 100644 index 0000000000..2ba30bf84e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20061109-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target { int32plus } } } */ +/* { dg-options "-O1" } */ + +/* This assignment might be implemented with a mem copy from the + literal pool with two BLKmode operands. This produced an ICE on S/390 + since simplify_subreg was called for such a BLKmode operand. */ + +struct a +{ + unsigned int b:24; +}; + +void +foo (struct a *t) +{ + t->b = 32; +} diff --git a/SingleSource/Regression/C/gcc-dg/20061109-2.c b/SingleSource/Regression/C/gcc-dg/20061109-2.c new file mode 100644 index 0000000000..30be434d53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20061109-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +/* This assignment might be implemented with a mem copy from the + literal pool with two BLKmode operands. This produced an ICE on S/390 + since simplify_subreg was called for such a BLKmode operand. */ + +struct a +{ + unsigned long b:24; +}; + +void +foo (struct a *t) +{ + t->b = 32; +} diff --git a/SingleSource/Regression/C/gcc-dg/20061124-1.c b/SingleSource/Regression/C/gcc-dg/20061124-1.c new file mode 100644 index 0000000000..26c35f75a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20061124-1.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* This testcase failed on s390 because no compare instruction for + the check of FLAG was emitted. */ + +unsigned short int count = 0; +int flag = 1; + +extern void abort (void); +extern void exit (int); + +int +main () +{ + __sync_add_and_fetch (&count, -1); + + if (!flag) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/20061127-1.c b/SingleSource/Regression/C/gcc-dg/20061127-1.c new file mode 100644 index 0000000000..0b70a5ae2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20061127-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O1 -fPIC" } */ + +/* PR target/29319 */ + +extern void abort(void); +static char l_info[100]; + +void +bug1 (unsigned long tag) +{ + char *info = l_info; + info[tag - 0x100000000 + 1] = 1; +} + +void +bug2 (unsigned long tag) +{ + char *info = l_info; + info[tag - 0x700000000 + 2] = 2; +} + +void +bug3 (unsigned long tag) +{ + char *info = l_info; + info[tag - 0x100000000 + 1] = 3; +} diff --git a/SingleSource/Regression/C/gcc-dg/20070112-1.c b/SingleSource/Regression/C/gcc-dg/20070112-1.c new file mode 100644 index 0000000000..bd78335676 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20070112-1.c @@ -0,0 +1,24 @@ +/* We used to ICE on this testcase: the address of bad_spill_regs is + only taken in a phi node, which we missed and cleared its TREE_ADDRESSABLE + flag. This gets revealed when the loop is completely unrolled, thus + exposing the addresses as ordinary statements. */ + +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + + +typedef unsigned HARD_REG_SET[2]; +static HARD_REG_SET bad_spill_regs; + +void +order_regs_for_reload () +{ + register int i; + + register unsigned *scan_tp_ = bad_spill_regs; + + for (i = 0; i < 2; i++) + *scan_tp_++ = 0; + + bad_spill_regs[0] |= 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/20070507-1.c b/SingleSource/Regression/C/gcc-dg/20070507-1.c new file mode 100644 index 0000000000..684002f6f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20070507-1.c @@ -0,0 +1,103 @@ +/* This failed on s390x due to bug in loop.c. + loop.c failed to remove a REG_EQUAL note when + hoisting an insn from a loop body. */ + +/* { dg-options "-O3 -fPIC" } */ +/* { dg-do run { target fpic } } */ + +typedef __SIZE_TYPE__ size_t; +int memcmp(const void *s1, const void *s2, size_t n); + +typedef struct +{ + char name[30]; + int a; +} LOCAL; + +int global = 0; +int sy = 1; +int subroutine_offset; + +LOCAL local = { "local", 0 }; +LOCAL keywords = { "keywords", 1 }; +int local_table = 0; +int keywords_table = 0; + +void __attribute__((noinline)) bar (char *p_buffer) +{ + p_buffer[255] = 1; +} + +int __attribute__((noinline)) foo (char *p_str1) +{ + global = 1; + return 1; +} + +int __attribute__((noinline)) loop_next (int *p_table, char *p_table_head) +{ + static int loop_next = 0; + + if (loop_next == 1) + return 1; + + loop_next = 1; + return 0; +} + +int +main () +{ + char buffer[256]; + int ende = 0; + int index; + int local_base = 2; + + keywords.a = 1; + for (sy = 0;; sy++) + { + for (index = 1;;) + { + bar (buffer); + if (buffer[sy] != 0) + { + ende = 1; + break; + }; + if (foo (buffer)) + { + keywords.a += index - 1; + break; + } + index++; + } + if (ende) + break; + } + + subroutine_offset = 0; + + for (;;) + { + if (loop_next (&keywords_table, (char*)&keywords)) + break; + + if ((!memcmp (keywords.name, "+++", 3))) + local_base = 100; + else + local_base = 0; + + if ((!memcmp (keywords.name, "+++", 3))) + subroutine_offset += local_table; + + for (;;) + { + if (loop_next (&local_table, (char*)&local)) + break;; + if ((local.a == 0)) + continue;; + foo (local.name); + } + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20070725-1.c b/SingleSource/Regression/C/gcc-dg/20070725-1.c new file mode 100644 index 0000000000..07b609cf8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20070725-1.c @@ -0,0 +1,64 @@ +/* This used to fail due to a ifcombine problem wrecking 64bit + checks. Fixed with rev. 126876. */ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +struct tree_base +{ + unsigned code:16; + + unsigned side_effects_flag:1; + unsigned constant_flag:1; + unsigned addressable_flag:1; + unsigned volatile_flag:1; + unsigned readonly_flag:1; + unsigned unsigned_flag:1; + unsigned asm_written_flag:1; + unsigned nowarning_flag:1; + + unsigned used_flag:1; + unsigned nothrow_flag:1; + unsigned static_flag:1; + unsigned public_flag:1; + unsigned private_flag:1; + unsigned protected_flag:1; + unsigned deprecated_flag:1; + unsigned invariant_flag:1; + + unsigned lang_flag_0:1; + unsigned lang_flag_1:1; + unsigned lang_flag_2:1; + unsigned lang_flag_3:1; + unsigned lang_flag_4:1; + unsigned lang_flag_5:1; + unsigned lang_flag_6:1; + unsigned visited:1; + + unsigned spare1:16; + unsigned spare2:8; + unsigned long a; +}; + +int +foo (struct tree_base *rhs) +{ + if (({const struct tree_base* __t = (rhs); __t;})->readonly_flag + && (rhs)->static_flag) + return 1; + + return 0; +} + +extern void abort (void); + +int +main () +{ + struct tree_base t; + + t.readonly_flag = t.static_flag = 0; + if (foo (&t)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20080615-1.c b/SingleSource/Regression/C/gcc-dg/20080615-1.c new file mode 100644 index 0000000000..bce9476cdd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20080615-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-w -O2" } */ + +static int *see_bb_splay_ar = ((void *) 0); +static void +see_merge_and_eliminate_extensions (void) +{ + int i = 0; + printf ("* Phase 2: Merge and eliminate locally redundant extensions. *\n"); + splay_tree_foreach (see_bb_splay_ar[i], ((void *) 0), ((void *) 0)); +} +static void +see_main (void) +{ + int i = 0; + see_merge_and_eliminate_extensions (); + printf ("Searching register properties in bb %d\n", i); +} +gate_handle_see (void) +{ +} +rest_of_handle_see (void) +{ + see_main (); +} diff --git a/SingleSource/Regression/C/gcc-dg/20080820.c b/SingleSource/Regression/C/gcc-dg/20080820.c new file mode 100644 index 0000000000..badab9a797 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20080820.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-fshow-column -fms-extensions -pedantic -std=gnu89" } */ + +struct { struct a { int x; }; int bar; } hot; /* { dg-warning "29:ISO C90 doesn't support unnamed" } */ diff --git a/SingleSource/Regression/C/gcc-dg/20081223-1.c b/SingleSource/Regression/C/gcc-dg/20081223-1.c new file mode 100644 index 0000000000..e5184e044e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20081223-1.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-flto -ffat-lto-objects" { target lto } } */ + +typedef struct foo_ foo_t; +foo_t bar; /* { dg-error "storage size of 'bar' isn't known" } */ diff --git a/SingleSource/Regression/C/gcc-dg/20090902-1.c b/SingleSource/Regression/C/gcc-dg/20090902-1.c new file mode 100644 index 0000000000..6120ee9070 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20090902-1.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +#define STRING(x) #x +char buf[] = STRING(L'\x123'); diff --git a/SingleSource/Regression/C/gcc-dg/20090922-1.c b/SingleSource/Regression/C/gcc-dg/20090922-1.c new file mode 100644 index 0000000000..62045cbbd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20090922-1.c @@ -0,0 +1,65 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -funroll-loops -std=gnu99" } */ + +struct S +{ + unsigned long s1; + int **s2; +}; +struct T +{ + unsigned long t1, t2; +}; +struct U +{ + int u1, u2; + unsigned long u3; +}; +struct V +{ + int v1, v3; + struct T *v2; + struct U *v4; +}; +struct W +{ + int w1; + struct V **w2; +}; +struct S *foo1 (void); +int *foo2 (void); + +void +test (struct W *w) +{ + for (int i = 0; i < w->w1; i++) + { + struct V *v = w->w2[i]; + struct S *t = foo1 (); + if (!t) + for (int j; j < v->v1;) + { + struct T *q = &v->v2[j]; + t += (q->t2 - q->t1) * 45000L; + } + for (; v->v3;) + { + struct U *v4 = (struct U *) &v->v4; + if (v4->u1 && v4->u2 >= 0 && v4->u2) + { + int *s = foo2 (); + if (!s) + for (int k = 0; k <= v4->u2; k++) + { + struct T *q = &v->v2[k]; + if (k == v4->u2) + v4->u3 += (q->t1) * 1000000; + } + t->s2[t->s1] = s; + } + } + int *s = foo2 (); + if (!t) + t->s2[t->s1] = s; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20100906-1.c b/SingleSource/Regression/C/gcc-dg/20100906-1.c new file mode 100644 index 0000000000..042ba99c53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20100906-1.c @@ -0,0 +1,49 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -fno-short-enums -Wl,--no-enum-size-warning" {target arm_eabi} } */ + +/* This testcase got misoptimized by combine due to a wrong setting of + subst_low_luid in try_combine. */ + +enum rtx_code { + A, B +}; + +void abort (void); + +struct rtx_def { + __extension__ enum rtx_code code:16; +}; +typedef struct rtx_def *rtx; + +void __attribute__((noinline)) +add_constraint (unsigned char is_a) +{ + if (is_a) + abort (); +} + +void __attribute__((noinline)) +foo (rtx defn) +{ + switch (defn->code) + { + case A: + case B: + add_constraint (defn->code == A); + break; + default: + break; + } +} + +int +main () +{ + struct rtx_def r; + + r.code = B; + + foo (&r); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20101010-1.c b/SingleSource/Regression/C/gcc-dg/20101010-1.c new file mode 100644 index 0000000000..2067012ebc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20101010-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-crossjumping" } */ +/* { dg-require-effective-target alloca } */ + +int bar1 (); +int bar2 (); + +int foo (void) +{ + int len; + if (bar1 (&len)) + { + char devpath [len]; + if (bar2 (devpath) == len) + return len; + } + return -1; +} diff --git a/SingleSource/Regression/C/gcc-dg/20101013-1.c b/SingleSource/Regression/C/gcc-dg/20101013-1.c new file mode 100644 index 0000000000..4422e761f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20101013-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(int a) +{ + int x = (a & (~15)) / 16; + return x; +} + +/* { dg-final { scan-tree-dump ">>" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20111216-1.c b/SingleSource/Regression/C/gcc-dg/20111216-1.c new file mode 100644 index 0000000000..7f9395e41e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20111216-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fexceptions -fnon-call-exceptions" } */ +/* { dg-require-effective-target exceptions } */ + +extern void f2 () __attribute__ ((noreturn)); +void +f1 () +{ + unsigned char a[8]; + unsigned int i; + + for (i = 0; i < 8; i++) + { + if (i > 8) + f2 (); + a[i] = i <= 8; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/20111227-2.c b/SingleSource/Regression/C/gcc-dg/20111227-2.c new file mode 100644 index 0000000000..2de29b91be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20111227-2.c @@ -0,0 +1,45 @@ +/* Testcase derived from 20111227-1.c to ensure that REE is combining + redundant zero extends with zero extend to wider mode. */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-fdump-rtl-ree -O -free" } */ + +extern void abort (void); + +unsigned short s; +unsigned int i; +unsigned long l; +unsigned char v = -1; + +void __attribute__((noinline,noclone)) +bar (int t) +{ + if (t == 2 && s != 0xff) + abort (); + if (t == 1 && i != 0xff) + abort (); + if (t == 0 && l != 0xff) + abort (); +} + +void __attribute__((noinline,noclone)) +foo (unsigned char *a, int t) +{ + unsigned char r = v; + + if (t == 2) + s = (unsigned short) r; + else if (t == 1) + i = (unsigned int) r; + else if (t == 0) + l = (unsigned long) r; + bar (t); +} + +int main(void) +{ + foo (&v, 0); + foo (&v, 1); + foo (&v, 2); + return 0; +} +/* { dg-final { scan-rtl-dump "Elimination opportunities = 3 realized = 3" "ree" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20111227-3.c b/SingleSource/Regression/C/gcc-dg/20111227-3.c new file mode 100644 index 0000000000..f1bd35911a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20111227-3.c @@ -0,0 +1,45 @@ +/* Testcase derived from 20111227-1.c to ensure that REE is combining + redundant sign extends with sign extend to wider mode. */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-fdump-rtl-ree -O -free" } */ + +extern void abort (void); + +signed short s; +signed int i; +signed long l; +signed char v = -1; + +void __attribute__((noinline,noclone)) +bar (int t) +{ + if (t == 2 && s != -1) + abort (); + if (t == 1 && i != -1) + abort (); + if (t == 0 && l != -1) + abort (); +} + +void __attribute__((noinline,noclone)) +foo (signed char *a, int t) +{ + signed char r = v; + + if (t == 2) + s = (signed short) r; + else if (t == 1) + i = (signed int) r; + else if (t == 0) + l = (signed long) r; + bar (t); +} + +int main(void) +{ + foo (&v, 0); + foo (&v, 1); + foo (&v, 2); + return 0; +} +/* { dg-final { scan-rtl-dump "Elimination opportunities = 3 realized = 3" "ree" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20141029-1.c b/SingleSource/Regression/C/gcc-dg/20141029-1.c new file mode 100644 index 0000000000..4a5d92efa7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20141029-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-volatile-bitfields -fdump-rtl-final" } */ + +#define PERIPH (*(volatile struct system_periph *)0x81234) + +struct system_periph { + union { + unsigned short WORD; + struct { + unsigned short a:1; + unsigned short b:1; + unsigned short :5; + unsigned short c:1; + unsigned short :8; + } BIT; + } ALL; +} __attribute__((aligned(2))); + +void +foo() +{ + while (1) + { + PERIPH.ALL.BIT.a = 1; + } +} +/* { dg-final { scan-rtl-dump-times "mem/v(/.)*:HI" 4 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20150120-1.c b/SingleSource/Regression/C/gcc-dg/20150120-1.c new file mode 100644 index 0000000000..18906c47a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20150120-1.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +/* x + (x & 1) -> (x + 1) & ~1 */ +int +fn1 (int x) +{ + return x + (x & 1); +} +int +fn2 (int x) +{ + return (x & 1) + x; +} +int +fn3 (int x) +{ + return x + (1 & x); +} +int +fn4 (int x) +{ + return (1 & x) + x; +} +unsigned int +fn5 (unsigned int x) +{ + return x + (x & 1); +} +unsigned int +fn6 (unsigned int x) +{ + return (x & 1) + x; +} +unsigned int +fn7 (unsigned int x) +{ + return x + (x % 2); +} +unsigned int +fn8 (unsigned int x) +{ + return (x % 2) + x; +} +unsigned int +fn9 (unsigned int x) +{ + return (1LL & x) + x; +} + +/* { dg-final { scan-tree-dump-times "x \\+ 1" 9 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20150120-2.c b/SingleSource/Regression/C/gcc-dg/20150120-2.c new file mode 100644 index 0000000000..976b6548e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20150120-2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +/* x & ~(x & y) -> x & ~y */ +int fn1 (int x, int y) +{ + return x & ~(x & y); +} +int fn2 (int x, int y) +{ + return ~(x & y) & x; +} +int fn3 (int x, int y) +{ + return x & ~(y & x); +} +int fn4 (int x, int y) +{ + return ~(y & x) & x; +} +int fn5 (int z) +{ + return z & ~(z & 3); +} +int fn6 (int z) +{ + return ~(z & 3) & z; +} + + +/* { dg-final { scan-tree-dump-times "~y & x" 4 "original" } } */ +/* { dg-final { scan-tree-dump-times "z & -4" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20150120-3.c b/SingleSource/Regression/C/gcc-dg/20150120-3.c new file mode 100644 index 0000000000..322556f4ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20150120-3.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +/* x | ~(x | y) -> x | ~y */ +int fn1 (int x, int y) +{ + return x | ~(x | y); +} +int fn2 (int x, int y) +{ + return ~(x | y) | x; +} +int fn3 (int x, int y) +{ + return x | ~(y | x); +} +int fn4 (int x, int y) +{ + return ~(y | x) | x; +} +int fn5 (int z) +{ + return z | ~(z | 3); +} +int fn6 (int z) +{ + return ~(z | 3) | z; +} + + +/* { dg-final { scan-tree-dump-times "~y \\| x" 4 "original" } } */ +/* { dg-final { scan-tree-dump-times "z \\| -4" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/20150306-1.c b/SingleSource/Regression/C/gcc-dg/20150306-1.c new file mode 100644 index 0000000000..55caf3b93c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20150306-1.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fstrict-volatile-bitfields" } */ + +struct s +{ + char x : 8; + unsigned int y : 31; +} __attribute__((packed)); + +volatile struct s global; + +int +main () +{ + global.y = 0x7FFFFFFF; + if (global.y != 0x7FFFFFFF) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/20161219.c b/SingleSource/Regression/C/gcc-dg/20161219.c new file mode 100644 index 0000000000..93ea8d2364 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/20161219.c @@ -0,0 +1,30 @@ +/* { dg-do assemble } */ +/* { dg-options "-O1 -w" } */ + +static long long a[9]; +int b, c, d, e, g; + +static int +fn1 (int *p1) +{ + b = 1; + for (; b >= 0; b--) + { + d = 0; + for (;; d++) + { + e && (a[d] = 0); + if (*p1) + break; + c = (int) a; + } + } + return 0; +} + +int +main () +{ + int f = fn1 ((int *) f); + return f; +} diff --git a/SingleSource/Regression/C/gcc-dg/54455.c b/SingleSource/Regression/C/gcc-dg/54455.c new file mode 100644 index 0000000000..281c8620a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/54455.c @@ -0,0 +1,26 @@ +/* PR rtl-optimization/54455 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fschedule-insns -fselective-scheduling --param max-sched-extend-regions-iters=2" } */ +/* { dg-require-effective-target scheduling } */ + +extern void fn1 (void), fn2 (void); + +static inline __attribute__((always_inline)) int +foo (int *x, long y) +{ + asm goto ("" : : "r" (x), "r" (y) : "memory" : lab); + return 0; +lab: + return 1; +} + +void +bar (int *x) +{ + if (foo (x, 23)) + fn1 (); + else + fn2 (); + + foo (x, 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/920413-1.c b/SingleSource/Regression/C/gcc-dg/920413-1.c new file mode 100644 index 0000000000..c2699fe33b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/920413-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional -std=gnu89" } */ + +int +x (b) +{ + return + 4294967295U /* { dg-warning "width of integer|traditional C rejects" } */ + / (unsigned long) b; +} diff --git a/SingleSource/Regression/C/gcc-dg/940409-1.c b/SingleSource/Regression/C/gcc-dg/940409-1.c new file mode 100644 index 0000000000..2d20b891f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/940409-1.c @@ -0,0 +1,6 @@ +/* GCC should allow struct S to be in a register. */ +/* { dg-do compile } */ + +struct S { volatile int field; }; +int f (register struct S arg); /* { dg-bogus "volatile field" "with arg" } */ +int g (register struct S); /* { dg-bogus "volatile field" "no arg" } */ diff --git a/SingleSource/Regression/C/gcc-dg/940510-1.c b/SingleSource/Regression/C/gcc-dg/940510-1.c new file mode 100644 index 0000000000..46183831d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/940510-1.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -pedantic" } */ +struct { int a[]; } x = { 0 }; /* { dg-warning "ISO C90 does not support flexible array members" } */ +/* { dg-error "flexible array member in a struct with no named members" "" { target *-*-* } .-1 } */ + diff --git a/SingleSource/Regression/C/gcc-dg/951130-1.c b/SingleSource/Regression/C/gcc-dg/951130-1.c new file mode 100644 index 0000000000..60013e267c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/951130-1.c @@ -0,0 +1,5 @@ +/* { dg-do compile } + { dg-options "-Werror" } */ + +unsigned long long x = -(unsigned long long)(-(long long) + (((unsigned long long)0 - 1) >> 1) - 1); diff --git a/SingleSource/Regression/C/gcc-dg/980502-1.c b/SingleSource/Regression/C/gcc-dg/980502-1.c new file mode 100644 index 0000000000..f06491cd96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/980502-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile }*/ +/* { dg-options "-O2" } */ + +char *const f(void) +{ + char *const line = "/dev/ptyXX"; + line[8] = 1; + return line; +} diff --git a/SingleSource/Regression/C/gcc-dg/980523-1.c b/SingleSource/Regression/C/gcc-dg/980523-1.c new file mode 100644 index 0000000000..970b57c597 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/980523-1.c @@ -0,0 +1,53 @@ +/* { dg-do run { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +extern void exit (int); + +void foo1(int a, char *b, int c) +{ + c =a+c+234; +} + +int foo2(int d) +{ + return d*d; +} + +int bar1, bar2, bar3; +char * bar4; + +int main(void) { + int h; + bar1 = foo2(1); + bar2 = foo2(1); + + h = foo2(1); + foo1(1, "a", foo2(1)); + foo1(bar1, "a", foo2(1)); + foo2(1); + + h = foo2(1); + bar3 = 1; + bar4 = "a"; + foo1(1, "n", foo2(1)); + foo1(1, "o", foo2(1)); + foo1(1, "p", foo2(1)); + foo1(bar1, "a", foo2(1)); + + bar3 = h; + bar4 = "b"; foo1(bar1, "b", foo2(1)); + foo1(1, "q", foo2(1)); + bar4 = "c"; foo1(1, "c", foo2(1)); + bar4 = "d"; foo1(1, "d", foo2(1)); + bar4 = "e"; foo1(1, "e", foo2(1)); + bar4 = "f"; foo1(1, "f", foo2(1)); + bar4 = "g"; foo1(1, "g", foo2(1)); + bar4 = "h"; foo1(1, "h", foo2(1)); + bar4 = "i"; foo1(1, "i", foo2(1)); + bar4 = "j"; foo1(1, "j", foo2(1)); + bar4 = "k"; foo1(1, "k", foo2(1)); + bar4 = "l"; foo1(1, "l", foo2(1)); + bar4 = "m"; + foo1(bar2, "m", foo2(1)); + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/980526-1.c b/SingleSource/Regression/C/gcc-dg/980526-1.c new file mode 100644 index 0000000000..6ab9db6793 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/980526-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +int +test(void) +{ + double value, maxValue = - (__extension__ ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) { __l: 0x7ff0000000000000ULL }).__d) ; + int idx, maxIdx = 1; + + for (idx = 1; idx < 22; idx++) { + if (value > maxValue) { + maxValue = value; + maxIdx = idx; + } + } + return 0 ; +} diff --git a/SingleSource/Regression/C/gcc-dg/980816-1.c b/SingleSource/Regression/C/gcc-dg/980816-1.c new file mode 100644 index 0000000000..d4f59c40c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/980816-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int +div_and_round_double (lden_orig, hden_orig) + int lden_orig, hden_orig; +{ + int quo[4]; + register int i; + unsigned int work; + register unsigned int carry = 0; + int lden = lden_orig; + int hden = hden_orig; + neg_double (&lden, &hden); + for (i = 4 - 1; i >= 0; i--) + { + quo[i] = work / (unsigned int ) lden; + carry = work % (unsigned int ) lden; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/990213-1.c b/SingleSource/Regression/C/gcc-dg/990213-1.c new file mode 100644 index 0000000000..a7c9f24898 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/990213-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-W -Wall -Werror" } */ + +static inline int unused_fn(int dummyarg) +{ + return dummyarg*dummyarg; +} + +int main() +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/990506-0.c b/SingleSource/Regression/C/gcc-dg/990506-0.c new file mode 100644 index 0000000000..901dfa1e23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/990506-0.c @@ -0,0 +1,9 @@ +/* Verify that a diagnostic is issued without crashing due to + --enable-checking catching a bug in the C front end. */ +/* { dg-do compile } */ +x() +{ + foo (i); + /* { dg-error "undeclared" "undeclared-variable message" { target *-*-* } .-1 } */ + /* { dg-message "function it appears in" "reminder message" { target *-*-* } .-2 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/CMakeLists.txt b/SingleSource/Regression/C/gcc-dg/CMakeLists.txt new file mode 100644 index 0000000000..8c0a3554f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/CMakeLists.txt @@ -0,0 +1,2978 @@ +include(${CMAKE_CURRENT_SOURCE_DIR}/../../DgOptions.txt) + +set(TestsToSkip) + +## +## Main Test Blacklist for Clang +## + +# Tests with features unsupported by Clang (usually GCC extensions) +# (Big list of naughty tests) +file(GLOB UnsupportedTests CONFIGURE_DEPENDS + # skip tests that include dg-error, dg-bogus or other error-checking + # or gcc emits warning but clang shows error + dg-test-1.c + lvalue-6.c + Wmissing-field-initializers-2.c + attr-copy.c + redecl-7.c + pr64223-2.c + c2x-typeof-2.c + Wc99-c11-compat-7.c + Wstrict-aliasing-bogus-ref-all-2.c + spellcheck-stdbool.c + pr101171.c + pr83373.c + uninit-pr65244-2.c + 20081223-1.c + Wrestrict-11.c + Warray-bounds-18.c + parse-else-error-3.c + pr49899.c + no-asm-3.c + pointer-arith-4.c + spellcheck-options-6.c + anon-struct-15.c + large-size-array-3.c + declspec-9.c + c99-array-lval-1.c + diag-aka-3.c + init-bad-3.c + pr22458-1.c + c99-idem-qual-2.c + uninit-pred-7_d.c + uninit-pr61112.c + missing-field-init-1.c + c11-static-assert-8.c + Warray-bounds-39.c + va-arg-4.c + c99-return-1.c + Wimplicit-function-declaration-c89-default.c + decl-8.c + pr13804-1.c + Wrestrict-8.c + pr65658.c + c2x-empty-init-2.c + builtin-redefine.c + overflow-warn-2.c + Wtype-limits-no.c + pr69819.c + large-size-array.c + bitint-32.c + Warray-bounds-80.c + pr67580.c + uninit-27-gimple.c + pr71514.c + uninit-pred-8_a.c + Wtraditional-conversion.c + cast-lvalue-2.c + pr99578-3.c + c2x-attr-deprecated-3.c + c90-vla-1.c + Wshadow-compatible-local-1.c + c11-unproto-1.c + c99-typespec-1.c + Wstringop-overflow-65.c + c99-func-2.c + pr84853.c + pr71362.c + Wunused-var-6.c + Warray-bounds-20.c + inline-21.c + uninit-pred-9_a.c + c90-idem-qual-2.c + assign-warn-1.c + atomic-pr51256.c + Warray-bounds-77.c + utf-badconcat2.c + enum-incomplete-3.c + gnu89-dupqual-1.c + 20031111-1.c + wtr-union-init-3.c + vla-init-2.c + c99-bool-2.c + pr17424-1.c + c2x-old-style-definition-2.c + assign-warn-3.c + spellcheck-options-5.c + 20020919-1.c + pr40946.c + gnu99-static-1.c + extra-semi-3.c + c90-array-lval-4.c + pr15698-3.c + pr93582.c + gnu99-const-expr-1.c + pr107805-2.c + attr-access-4.c + unused-5.c + stdckdint-2.c + redecl-4.c + anon-struct-13.c + Warray-bounds-21.c + c11-thread-local-2.c + c90-complit-2.c + Warray-bounds-flex-arrays-3.c + c90-noreturn-1.c + pr94726.c + pr20368-3.c + inline-12.c + c99-init-2.c + pr67964.c + pr107618.c + pr39323-1.c + pr69650.c + Wlogical-op-1.c + Wstringop-overflow-4.c + sync-fetch.c + pr99578-2.c + pr48524.c + c11-floatn-2.c + pr17301-1.c + divbyzero.c + driver-specs.c + spellcheck-transposition.c + two-types-5.c + Wstrict-flex-arrays.c + gnu99-const-expr-3.c + binary-constants-4.c + c99-left-shift-3.c + pr25559.c + uninit-pred-3_d.c + pr27528.c + attr-copy-2.c + decl-2.c + Wstringop-overflow-21-novec.c + init-string-2.c + pr30949.c + Wstrict-overflow-24.c + warn-1.c + uninit-pred-11.c + pr93577-1.c + c99-array-nonobj-1.c + spellcheck-inttypes.c + spellcheck-options-15.c + uninit-pred-8_d.c + pr81854.c + darwin-comm-1.c + c99-static-assert-1.c + ucnid-7-utf8.c + attr-unavailable-6.c + nodfp-1.c + array-3.c + pr77521.c + gimplefe-error-4.c + wtr-aggr-init-1.c + ucnid-8.c + Wzero-length-array-bounds-2.c + uninit-28-gimple.c + pr69554-1.c + bitint-27.c + cond-constqual-1.c + c90-return-1.c + c90-typedef-1.c + atomic-op-6.c + comp-goto-3.c + wcaselabel-1.c + pr63477.c + c99-thread-local-1.c + always_inline.c + pr65050.c + diag-aka-2.c + Wreturn-type2.c + c99-flex-array-typedef-3.c + declspec-18.c + c2x-attr-noreturn-2.c + march.c + uninit-1-O0.c + attr-access.c + declspec-13.c + Wstringop-truncation-2.c + union-3.c + two-types-10.c + Winfinite-recursion-3.c + c90-align-1.c + uninit-pred-9_b.c + Wstringop-truncation-4.c + Warray-bounds-88.c + pr87600-2.c + c11-fordecl-1.c + pr48552-1.c + pr51034.c + c90-const-expr-3.c + uninit-pr65244-1.c + label-decl-4.c + declspec-11.c + intmax_t-1.c + pure-2.c + Warray-bounds-27.c + Wstringop-overflow-51.c + Wc99-c11-compat-6.c + c2x-complit-8.c + inline-5.c + Warray-bounds-7.c + m-un-1.c + c90-restrict-1.c + const-1.c + uninit-pred-8_b.c + c90-idem-qual-3.c + diagnostic-input-charset-1.c + pr66066-2.c + pr36093.c + 20041213-1.c + pr18596-2.c + pr56724-1.c + assign-warn-2.c + wtypequal.c + Wsequence-point-pr18050.c + uninit-30-gimple.c + c99-vla-jump-1.c + pr60797.c + auto-type-2.c + pr60915.c + wmain.c + c90-init-1.c + pr82112.c + fixits.c + Warray-bounds-67.c + c11-empty-init-1.c + Wstrict-aliasing-bogus-upcast.c + vla-init-4.c + two-types-4.c + c2x-thread-local-2.c + c11-atomic-3.c + .CMakeLists.txt.swp + stmt-expr-3.c + funroll-loops-all.c + pr66618.c + c99-typedef-1.c + c99-vla-jump-4.c + attr-unavailable-4.c + gnu2x-attrs-1.c + c2x-qual-5.c + gimplefe-error-13.c + attr-aligned-2.c + asm-scope-1.c + register-var-3.c + pr101419.c + parse-decl-after-label.c + register-var-2.c + 20031223-1.c + c11-attr-syntax-1.c + parse-else-error.c + nofixed-point-2.c + pr37261.c + pr14963.c + fixits-pr84852-1.c + c99-main-1.c + pr61053.c + Wtype-limits.c + noreturn-2.c + builtin-choose-expr-2.c + 20041014-1.c + decl-3.c + inline4.c + pr53265.c + uninit-pr55060.c + uninit-10-O0.c + spellcheck-fields-2.c + c99-restrict-1.c + c11-floatn-1.c + enum-redef-1.c + c99-vla-jump-3.c + pr30551-5.c + pr69483.c + 20040223-1.c + builtins-28.c + Werror-10.c + c99-impl-int-2.c + attr-assume-2.c + uninit-A.c + Warray-bounds-38.c + pr20368-1.c + sizeof-1.c + pr98029.c + switch-7.c + pr70859-2.c + Wdeclaration-after-statement-3.c + uninit-pr65686.c + c90-const-expr-11.c + Warray-bounds-12.c + Winfinite-recursion-5.c + c90-array-lval-8.c + c99-vla-1.c + c90-array-lval-6.c + c90-const-expr-6.c + c99-array-lval-8.c + Wmissing-field-initializers-3.c + c99-atomic-1.c + pr7356-2.c + 20020122-1.c + c90-typespec-1.c + Warray-bounds-37.c + pr98271.c + bss.c + gnu2x-stdarg-1.c + init-excess-3.c + c90-hexfloat-1.c + vla-init-5.c + Wstrict-flex-arrays-3.c + Wunused-value-2.c + Wstrict-aliasing-bogus-struct-included.c + compound-literal-cast-lvalue-1.c + pr61692.c + pr80468.c + Wdangling-pointer-pr106868.c + c2x-attr-syntax-6.c + dollar.c + pr65345-3.c + diagnostic-range-static-assert.c + c90-flex-array-1.c + two-types-7.c + gnu2x-utf8str.c + c11-pointer-float-1.c + spellcheck-options-17.c + pr30260.c + Warray-bounds-23.c + simd-1.c + old-style-prom-3.c + switch-2.c + Wstringop-overflow-63.c + c11-anon-struct-2.c + pr35441.c + Wvla-parameter-13.c + pr57149.c + dremf-type-compat-3.c + Wpointer-arith.c + Wimplicit-int-2.c + sync-fetch-bool.c + c2x-nullptr-3.c + parser-pr28152.c + redecl-14.c + pr51644.c + c90-func-1.c + attr-access-3.c + pr20245-1.c + pr35445.c + case-const-3.c + gimplefe-error-5.c + c2x-attr-fallthrough-3.c + c99-const-expr-9.c + attr-ifunc-2.c + decl-1.c + pr13519-1.c + uninit-4.c + pr89340.c + pr108375-2.c + uninit-3.c + Wcxx-compat-8.c + pr29254.c + two-types-2.c + pr35440.c + Wredundant-decls-1.c + pr30551-4.c + cast-1.c + c11-binary-constants-2.c + uninit-6-O0.c + Wparentheses-1.c + gnu99-init-2.c + Wvla-3.c + c2x-auto-3.c + c2x-constexpr-6.c + Wstringop-overflow-21.c + compare1.c + pr35334.c + pr85045.c + pr83595.c + pr55570.c + floatn-errs.c + uninit-pred-6_a.c + missing-field-init-2.c + c99-tag-1.c + c90-static-1.c + c99-flex-array-typedef-5.c + union-cast-2.c + pr104506-2.c + c11-fordecl-2.c + cast-qual-1.c + init-desig-obs-1.c + pr105331.c + Warray-parameter-6.c + c11-enum-1.c + c11-parm-omit-1.c + pr66618-2.c + c2x-attr-maybe_unused-3.c + pr43082.c + Wmissing-parameter-type-no.c + Wbuiltin-declaration-mismatch-16.c + Werror-5.c + opts-5.c + pr59827.c + Werror-1.c + c99-flex-array-typedef-1.c + Wrestrict-23.c + spellcheck-options-11.c + c90-array-lval-5.c + pr32370.c + switch-5.c + c99-init-6.c + uninit-18.c + pr80163.c + builtin-stringop-chk-9.c + pr15698-5.c + label-decl-3.c + builtin-inf-1.c + spellcheck-identifiers.c + pr105149.c + Warray-bounds-56.c + uninit-pr89230-1.c + bitfld-14.c + pr79983.c + spellcheck-params-2.c + c99-flex-array-5.c + bitint-14.c + Wint-in-bool-context-4.c + va-arg-pack-len-2.c + c99-restrict-3.c + redecl-5.c + Wc90-c99-compat-8.c + c99-idem-qual-3.c + c2x-attr-maybe_unused-4.c + typespec-1.c + c99-tag-2.c + 20011214-1.c + c90-idem-qual-1.c + decl-9.c + pr67784-2.c + uninit-11-O0.c + init-undef-1.c + c2x-attr-noreturn-3.c + opts-6.c + pr81795.c + asm-qual-1.c + pr52904.c + nonnull-6.c + struct-parse-1.c + noreturn-7.c + Warray-bounds-flex-arrays-6.c + spellcheck-options-22.c + c99-flex-array-2.c + gimplefe-error-9.c + declspec-17.c + attr-assume-3.c + transparent-union-2.c + c11-complit-1.c + c99-idem-qual-1.c + pr15698-2.c + ucnid-8-utf8.c + sequence-pt-1.c + mtune.c + cast-pretty-print-1.c + c2x-enum-3.c + Wmissing-field-initializers-4.c + parser-pr28152-2.c + c2x-attr-nodiscard-3.c + 20001201-1.c + Wunused-var-4.c + anon-struct-8.c + qual-return-9.c + 20031222-1.c + uninit-H.c + array-5.c + pr15236.c + c2x-enum-4.c + vla-6.c + Warray-bounds-16.c + pr14475.c + pr61096-2.c + c2x-thread-local-1.c + 20050620-1.c + atomic-invalid.c + vla-19.c + pr20672-1.c + two-types-1.c + auto-init-pr104550-1.c + vla-init-3.c + pr57287.c + lvalue-9.c + c99-const-expr-2.c + nested-func-1.c + builtins-68.c + pr80776-1.c + c99-array-lval-6.c + c99-complex-1.c + compare8.c + c99-arraydecl-1.c + c11-generic-2.c + spellcheck-options-23.c + builtin-clear-padding-2.c + uninit-suppress.c + pr104506-1.c + pr79412.c + attr-unavailable-5.c + pr36901-4.c + 20030625-1.c + pr18725.c + asm-8.c + pr109412.c + gnu2x-attr-syntax-2.c + pr64766.c + pr36227.c + c99-vla-jump-5.c + Wshadow-1.c + pr11492.c + pr61096-1.c + opts-3.c + bitfld-8.c + c90-anon-struct-1.c + c90-dupqual-1.c + utf-badconcat.c + Wno-all.c + nested-func-6.c + c2x-unproto-1.c + misc-column.c + 940409-1.c + nest.c + encoding-issues-unicode.c + struct-empty-3.c + pr51321.c + Wc90-c99-compat-12.c + compare9.c + auto-init-pr102276-2.c + Warray-parameter-9.c + c2x-nullptr-6.c + Wstringop-overflow-19.c + declspec-5.c + array-11.c + c99-tag-4.c + spellcheck-options-16.c + pr20368-2.c + func-outside-2.c + Wrestrict-9.c + qual-return-5.c + cast-2.c + nonnull-2.c + Wattributes-10.c + cast-lvalue-1.c + pr16194.c + uninit-5.c + union-cast-4.c + pr91134.c + Wstrict-overflow-26.c + typedef-init.c + 20040910-1.c + uninit-1.c + nofixed-point-1.c + pr56724-3.c + init-bad-5.c + pr18809-1.c + pr95141.c + Warray-bounds-59.c + nested-func-2.c + init-bad-1.c + parm-forwdecl-1.c + warn-strnlen-no-nul.c + c2x-digit-separators-3.c + pr79677.c + pr26632.c + Wstringop-overflow-72.c + pr84628.c + uninit-pred-2_c.c + qual-component-1.c + boolcomplex-1.c + auto-init-pr104550-2.c + pr97882.c + init-desig-obs-3.c + Wswitch-error.c + Wstringop-overread-6.c + c99-fordecl-3.c + pr48062.c + pr78957.c + c99-impl-int-1.c + diagnostic-token-ranges.c + c99-array-lval-5.c + gimplefe-error-6.c + redecl-10.c + pr93577-5.c + builtin-protos-1.c + pr86835.c + struct-parse-2.c + uninit-6.c + bitfld-1.c + c99-complit-2.c + spellcheck-options-9.c + utf8-2.c + nested-redef-1.c + pr77323.c + decl-4.c + pr61861.c + pr100834.c + two-types-8.c + Warray-bounds-57.c + Wrestrict-25.c + stmt-expr-label-2.c + const-2.c + Wshadow-local-2.c + diag-aka-5a.c + bitfld-22.c + array-2.c + mismatch-decl-1.c + c2x-complit-5.c + pr96377-1.c + pr66066-3.c + declspec-10.c + struct-semi-3.c + attr-mode-1.c + redecl-2.c + uninit-2.c + c2x-attr-maybe_unused-2.c + gnu89-const-expr-2.c + c99-func-4.c + pr25801.c + spellcheck-options-3.c + compound-literal-1.c + Wswitch-unreachable-1.c + spellcheck-params.c + c99-flex-array-typedef-7.c + uninit-H-O0.c + overflow-warn-7.c + inline-25.c + fltconst-pedantic-dfp.c + missing-symbol-3.c + label-compound-stmt-1.c + pr44061.c + pr63626.c + bitfld-12.c + gnu2x-enum-1.c + c99-noreturn-1.c + pr51721.c + uninit-pr106155-1.c + diag-aka-1.c + pointer-array-atomic.c + c11-static-assert-4.c + inline3.c + initpri2.c + parm-forwdecl-3.c + inline-14.c + c99-impl-decl-1.c + bitfld-2.c + c11-labels-3.c + opts-1.c + case-bogus-1.c + vla-25.c + pr61240.c + Wreturn-local-addr-9.c + concat.c + nested-func-3.c + setjmp-1.c + always_inline3.c + func-args-1.c + init-bad-9.c + uninit-B-2.c + old-style-then-proto-1.c + Wparentheses-11.c + pointer-arith-8.c + Warray-bounds-flex-arrays-5.c + alias-3.c + c2x-old-style-definition-6.c + funcdef-storage-1.c + pragma-message.c + pr63877.c + attr-weakref-5.c + Werror-7.c + Warray-bounds-35.c + pr66066-1.c + darwin-cfstring-format-1.c + strict-flex-array-1.c + empty-source-3.c + uninit-pr105109.c + simd-6.c + attr-vector_size.c + pragma-diag-4.c + c99-const-expr-12.c + c99-anon-struct-1.c + two-types-3.c + parse-else-error-4.c + Warray-bounds-flex-arrays-1.c + union-duplicate-field.c + declspec-7.c + pr93577-2.c + pr39084.c + 20040920-1.c + c11-generic-3.c + diagnostic-input-utf8-bom.c + pragma-diag-10.c + attr-assume-4.c + spellcheck-options-14.c + pr108043.c + uninit-pr59970.c + compare7.c + declspec-8.c + multiple-overflow-warn-2.c + pr96377-5.c + alias-12.c + pr30551-2.c + concat2.c + opts-7.c + Wstringop-overflow-39.c + c99-left-shift-2.c + attr-section.c + pure-3.c + c90-atomic-1.c + attr-malloc.c + bitint-15.c + gnu99-const-expr-4.c + parse-decl-after-if.c + Warray-bounds-44.c + pr23075.c + Walloc-size-larger-than-16.c + Wcomplain-wrong-lang-3.c + Wunused-value-3.c + c99-flex-array-3.c + pr94963.c + c99-const-expr-10.c + pr90760.c + enum-const-3.c + c99-const-expr-14.c + asm-qual-3.c + c99-vla-jump-2.c + attr-access-read-write.c + c99-const-expr-3.c + attr-assume_aligned-2.c + func-args-2.c + fixits-pr84852-2.c + pr65345-1.c + pr110699.c + diagnostic-range-bad-called-object.c + pr69900.c + c11-static-assert-2.c + c99-const-expr-5.c + redecl-13.c + Wuse-after-free-3.c + pr8788-1.c + utf-dflt.c + struct-in-proto-1.c + diag-aka-4.c + pr15698-8.c + uninit-pr20644-O0.c + 20020104-1.c + c90-array-lval-2.c + pr48552-2.c + Warray-bounds-17.c + bitfld-7.c + c90-arraydecl-1.c + parm-mismatch-1.c + pr27953.c + pr64417.c + gimplefe-error-10.c + sso-5.c + parse-error-1.c + redecl-11.c + pr68320.c + c11-align-4.c + 20010516-1.c + Werror-implicit-function-declaration.c + qual-return-7.c + pr22231.c + uninit-pred-10.c + cast-3.c + 20040322-1.c + Wcxx-compat-21.c + two-types-6.c + inline1.c + declspec-6.c + compare2.c + Wvla-7.c + builtin-assume-aligned-2.c + c2x-attr-deprecated-4.c + asm-6.c + encoding-issues-bytes.c + spellcheck-options-19.c + utf-array.c + pr15698-4.c + ucnid-13.c + c11-align-3.c + Wattributes-2.c + uninit-pr61409.c + c11-align-9.c + spellcheck-options-24.c + pr104506-3.c + no-asm-4.c + c99-complex-3.c + gimplefe-error-7.c + Warray-bounds-42.c + pointer-arith-1.c + spellcheck-stdlib.c + c11-unproto-2.c + vla-init-1.c + c2x-no-dfp-1.c + c90-const-expr-1.c + pr100547.c + Wzero-length-array-bounds-3.c + stmt-expr-label-1.c + 20021014-1.c + 20050209-1.c + c99-flex-array-7.c + uninit-pr61869.c + bconstp-4.c + c11-noreturn-5.c + array-9.c + darwin-cfstring-2.c + vla-8.c + Wrestrict-21.c + anon-struct-5.c + pr93577-3.c + pr107805-1.c + Wstringop-overflow-43.c + pr93573-1.c + c99-align-1.c + readonly-loc.c + parm-impl-decl-2.c + bad-dereference.c + multiple-overflow-warn-3.c + Wswitch-enum-error.c + Wstringop-overflow-pr106904.c + pr59940.c + register-var-1.c + simd-4.c + large-size-array-6.c + diag-sanity.c + declspec-4.c + init-bad-8.c + auto-init-pr102276-1.c + pr63748.c + pr97463.c + Warray-bounds-13.c + pr40340-4.c + c99-tag-3.c + Warray-bounds-25.c + c2x-attr-deprecated-2.c + Wstringop-overflow-61.c + unordered-1.c + Wstring-compare-2.c + redecl-16.c + call-diag-2.c + Wvla-larger-than-5.c + pr89350.c + visibility-13.c + Wstringop-overread-3.c + fltconst-double-pedantic-2.c + anon-struct-14.c + uninit-pred-6_b.c + Wvla-parameter-9.c + c99-static-1.c + redecl-18.c + pr35742.c + anon-struct-9.c + bitint-1.c + c11-stdarg-1.c + Warray-bounds-11.c + pr90082.c + c99-const-expr-8.c + Wvla-parameter-3.c + overflow-warn-1.c + no-asm-2.c + init-bad-2.c + c2x-qual-4.c + attr-access-read-only.c + c90-const-expr-7.c + c11-typedef-1.c + Wfatal-2.c + vla-18.c + gnu2x-empty-init-2.c + pr105676.c + c2x-concat-1.c + Wdesignated-init.c + c11-align-8.c + c99-array-lval-2.c + attr-weakref-2.c + asm-7.c + Wnonnull-7.c + c2x-unproto-2.c + spellcheck-options-4.c + c90-longlong-1.c + alias-13.c + fold-nonneg-1.c + cleanup-1.c + pointer-arith-2.c + gnu-cond-expr-3.c + pr39464.c + pr36901-3.c + Wmissing-field-initializers-1.c + attr-access-write-only.c + bitint-21.c + c11-static-assert-3.c + comp-goto-6.c + c2x-attr-fallthrough-2.c + c99-intconst-2.c + c2x-enum-7.c + Werror-11.c + spellcheck-options-12.c + c99-const-expr-7.c + Wfatal.c + large-size-array-4.c + spellcheck-typenames.c + enum3.c + c2x-digit-separators-2.c + pr109238.c + spellcheck-options-7.c + pr79730.c + sso-4.c + redecl-3.c + pr63549.c + pr89061.c + Wshadow-2.c + Wstringop-overflow-66.c + Wimplicit-function-declaration-c99-pedantic.c + pr93573-2.c + bitfld-11.c + overflow-warn-4.c + pr18164.c + Winfinite-recursion-4.c + pr30551-3.c + pr40340-3.c + pr17188-1.c + c2x-has-c-attribute-4.c + atomic-pr81231.c + parse-error-3.c + Wvla-parameter-12.c + spellcheck-options-20.c + c90-array-lval-7.c + c2x-static-assert-2.c + Wstringop-overflow-32.c + pr64778.c + pr17730-1.c + pr67088.c + Wstringop-truncation-5.c + 940510-1.c + c2x-old-style-definition-4.c + c99-init-5.c + struct-incompl-1.c + c99-const-expr-11.c + variable-sized-type-flex-array.c + c2x-qual-6.c + simd-1b.c + auto-init-pr104550-3.c + Warray-bounds-24.c + c2x-binary-constants-3.c + uninit-pr101912.c + enum-incomplete-1.c + c99-flex-array-1.c + Warray-bounds-87.c + spellcheck-options-10.c + attr-aligned.c + bitfld-13.c + lvalue-4.c + array-10.c + pr17301-2.c + asm-10.c + Wattributes-8.c + uninit-pred-4_a.c + pr15360-1.c + Wno-pointer-sign.c + spellcheck-options-2.c + c99-longlong-1.c + incomplete-typedef-1.c + pr14765-1.c + Wmissing-field-initializers-5.c + cast-qual-2.c + c2x-utf8str.c + Werror-4.c + enum-compat-1.c + pr8927-1.c + spellcheck-stdint.c + gnu2x-auto-1.c + bad-binary-ops.c + array-14.c + alias-4.c + switch-A.c + march-generic.c + lvalue-8.c + no-asm-1.c + c11-floatn-3.c + pr53532.c + cond-lvalue-1.c + pr65901.c + pr22308-1.c + c2x-attr-syntax-3.c + Wstringop-truncation.c + redecl-25.c + utf32-4.c + pr58893.c + c90-array-lval-3.c + return-type-2.c + Wstrict-aliasing-bogus-never-dereferenced.c + builtin-tgmath-err-1.c + Wtype-limits-Wextra.c + pr83620.c + lvalue1.c + asm-wide-1.c + c11-uni-string-2.c + redecl-21.c + c90-enum-comma-1.c + Wbuiltin-declaration-mismatch-11.c + label-decl-2.c + pr53196-1.c + pragma-diag-3.c + array-12.c + pointer-array-quals-2.c + Warray-parameter-2.c + c90-static-assert-1.c + Wstringop-overflow-30.c + c99-hexfloat-1.c + attr-copy-4.c + inline-9.c + pr99990.c + unclosed-init.c + Wreturn-local-addr.c + pr35442.c + builtin-complex-err-2.c + compound-lvalue-1.c + do-empty.c + 20050121-1.c + Warray-bounds-48.c + c99-flex-array-typedef-8.c + c2x-enum-2.c + attr-unavailable-2.c + Warray-bounds-14.c + gimplefe-error-1.c + gnu89-const-expr-1.c + c2x-attr-fallthrough-5.c + c99-array-lval-4.c + gimplefe-error-14.c + array-8.c + ordered-comparison-3.c + utf-array-short-wchar.c + cwsc0.c + uninit-pred-7_a.c + always_inline2.c + pr84953.c + uninit-5-O0.c + pr100680.c + c99-arraydecl-3.c + c90-complit-1.c + c90-fordecl-1.c + pr69796.c + c99-init-3.c + Wcomplain-wrong-lang-4.c + uninit-pred-12.c + gnu99-const-expr-2.c + uninit-11.c + Warray-bounds-46.c + Warray-bounds-15.c + gimplefe-error-15.c + union-cast-3.c + pr36774-1.c + label-decl-1.c + spellcheck-fields.c + c99-arraydecl-2.c + 20051207-3.c + c90-const-expr-8.c + enum-incomplete-4.c + uninit-pred-3_c.c + pr94436.c + pr89525.c + c99-fordecl-2.c + pr34088.c + Wstringop-overflow-86.c + sso-2.c + pr64223-1.c + spellcheck-options-1.c + pr108375-1.c + uninit-3-O0.c + c90-const-expr-9.c + Wstring-compare.c + c11-floatn-4.c + noreturn-1.c + compare3.c + gimplefe-error-11.c + pr84721.c + c90-complex-1.c + proto-1.c + pragma-diag-2.c + long-long-typespec-1.c + simd-2.c + stmt-expr-label-3.c + attr-unavailable-1.c + trunc-1.c + pointer-array-quals-1.c + cast-function-1.c + Wstringop-truncation-3.c + builtins-error.c + pr88568.c + Wfree-nonheap-object.c + pr105175.c + old-style-param-1.c + uninit-8.c + pr69627.c + call-diag-1.c + c90-thread-local-1.c + gnu90-const-expr-1.c + c2x-unproto-4.c + pr69974.c + c2x-utf8char-3.c + setjmp-5.c + c99-const-expr-6.c + funcdef-var-1.c + pr53196-2.c + redecl-22.c + pr27428-1.c + Walloca-2.c + large-size-array-5.c + noreturn-6.c + pr57287-2.c + atomic-fetch-bool.c + uninit-pred-3_a.c + pr56989.c + pr37561.c + Wstrict-aliasing-bogus-const-ptr-nonconst-ptr.c + attr-alloc_align-2.c + uninit-9-O0.c + attr-alias-5.c + c99-compare-incomplete-2.c + pr29521-2.c + asm-qual-2.c + pr67432.c + init-empty-3.c + pr36997.c + spellcheck-fields-3.c + declspec-1.c + c2x-attr-nodiscard-2.c + redecl-19.c + pr97932.c + typedef-var-2.c + pr87309.c + funcdef-var-2.c + c11-typeof-3.c + pr68090.c + pr41842.c + pr87811.c + spellcheck-options-8.c + sso-1.c + uninit-A-O0.c + inline5.c + redecl-1.c + pr54355.c + c2x-constexpr-9.c + Wcomplain-wrong-lang-5.c + uninit-pr101494.c + pr54113.c + pr68533.c + pr43211.c + lvalue-3.c + Wstringop-overflow-34.c + c11-enum-4.c + pr64709.c + vla-11.c + pr28419.c + decl-nospec-3.c + pr87811-2.c + pr15698-7.c + array-7.c + pr105080.c + comp-goto-5.c + uninit-pr107839.c + c2x-stdarg-3.c + anon-struct-11.c + Wrestrict-15.c + attr-error-1.c + store_merging_12.c + c99-left-shift-1.c + for-1.c + pr42611.c + uninit-9.c + pr45079.c + attr-aligned-3.c + darwin-aligned-globals.c + two-types-9.c + parm-incomplete-1.c + sso-3.c + pr93577-6.c + utf-dflt2.c + uninit-pred-6_c.c + builtin-complex-err-1.c + c90-mixdecl-1.c + pr45750.c + c90-const-expr-5.c + c2x-attr-syntax-7.c + Warray-bounds-flex-arrays-4.c + pr99578-1.c + pr53037-4.c + 20030612-2.c + Warray-bounds-61.c + c99-hexfloat-3.c + Wrestrict-18.c + gimplefe-error-2.c + spellcheck-identifiers-4.c + redecl-8.c + pr94705.c + pr97955.c + c90-const-expr-2.c + pr18596-3.c + builtin-arith-overflow-4.c + 20011021-1.c + pragma-diag-7.c + 990506-0.c + uninit-pr78295.c + builtin-constant_p-1.c + pr63543.c + Wuse-after-free-pr109123.c + addr_builtin-1.c + stack-usage-2.c + pr65228.c + pr80776-2.c + pr91195.c + qual-return-3.c + Werror-13.c + pr94968.c + ivdep.c + init-string-1.c + Wuse-after-free-pr109170.c + redecl-23.c + gimplefe-error-12.c + uninit-pred-2_a.c + darwin-cfstring-1.c + pr24293.c + spellcheck-options-18.c + Wstringop-overflow-10.c + multiple-overflow-warn-1.c + pr84095.c + Warray-bounds-flex-arrays-2.c + decl-10.c + pointer-arith-3.c + Wstringop-truncation-8.c + spellcheck-options-13.c + c2x-constexpr-3.c + uninit-10.c + uninit-21.c + missing-symbol-2.c + bitfld-10.c + ucnid-13-utf8.c + Wdangling-pointer-4.c + large-size-array-2.c + Wdouble-promotion.c + uninit-pred-6_d.c + unused-9.c + c99-complex-2.c + c2x-constexpr-7.c + binary-constants-3.c + uninit-24.c + pr107787.c + ifelse-1.c + pr37529.c + uninit-pred-6_e.c + pr62294.c + uninit-B-O0-2.c + pr84772.c + redecl-20.c + pr18596-1.c + pr96377-3.c + fltconst-1.c + c2x-attr-fallthrough-6.c + simd-5.c + pr101172.c + pr21419.c + pr40989.c + Wstringop-overflow-41.c + pr84100.c + va-arg-2.c + array-const-3.c + uninit-pr65178.c + enum-mode-1.c + c2x-static-assert-4.c + pragma-diag-1.c + pr109409.c + switch-3.c + asm-1.c + pr35635.c + c90-const-expr-10.c + uninit-pred-8_c.c + spellcheck-pr83056.c + vla-20.c + lvalue-2.c + reg-vol-struct-1.c + uninit-2-O0.c + pr29736.c + gimplefe-error-8.c + c11-align-5.c + c90-array-lval-1.c + uninit-4-O0.c + ucnid-7.c + uninit-8-O0.c + va-arg-pack-1.c + c90-impl-decl-1.c + c99-dupqual-1.c + spellcheck-options-21.c + param-type-mismatch.c + Warray-bounds-4.c + unused-6-no.c + init-bad-4.c + pr35443.c + Wstrict-flex-arrays-2.c + redecl-24.c + Werror-6.c + pr61162-2.c + Werror-12.c + c99-bool-1.c + c11-anon-struct-3.c + pr7356.c + Wuse-after-free.c + parse-else-error-2.c + pr37772.c + float-range-2.c + declspec-3-no.c + c2x-attr-syntax-5.c + c99-flex-array-typedef-2.c + overflow-warn-3.c + pr56980.c + Warray-bounds-79.c + utf16-4.c + array-15.c + Wincompatible-pointer-types-1.c + attr-unavailable-3.c + uninit-pred-5_a.c + c11-noreturn-3.c + sizeof-2.c + redecl-12.c + c17-nullptr-2.c + bitfld-21.c + diag-aka-5b.c + pr93577-4.c + lvalue-7.c + atomic-param.c + pr43783.c + uninit-pr63660.c + pr35746.c + uninit-pr81782.c + pr36774-2.c + uninit-pred-4_b.c + gnu11-typeof-4.c + parse-error-2.c + Warray-bounds-26.c + gimplefe-error-3.c + comp-return-1.c + pr34965.c + Warray-bounds-47.c + 20030626-1.c + pr70859.c + builtin-tgmath-err-2.c + Walloca-16.c + Wrestrict-4.c + Wattributes-6.c + Wbuiltin-declaration-mismatch-12.c + Wmissing-braces-fixits.c + Wrestrict-19.c + Wvla-larger-than-3.c + atomic-invalid-2.c + attr-alloc_align-4.c + attr-alloc_size-12.c + attr-assume_aligned-4.c + attr-weakref-3.c + attr-weakref-4.c + bad-pragma-locations.c + builtin-prefetch-1.c + c11-atomic-4.c + c11-complit-2.c + c11-atomic-1.c + c99-fordecl-2.c + c99-fordecl-3.c + c11-stdarg-2.c + c11-stdarg-3.c + pr102009.c + c2x-fordecl-3.c + declspec-15.c + declspec-16.c + fltconst-double-pedantic-1.c + dll-9.c + inline-11.c + inline-8.c + init-excess-1.c + parm-forwdecl-2.c + parm-impl-decl-1.c + parm-impl-decl-3.c + pr100791.c + pr105140.c + pr105635.c + pr105853.c + pr19984.c + pr29521.c + pr30551-6.c + pr30551.c + pr35899.c + pr37645.c + pr56167.c + pr56724-2.c + pr61077.c + pr67730.c + pr79788-1.c + pr79788-2.c + pr87483.c + pr89410-2.c + pr90648.c + pr98198.c + pr99136.c + pr99323-2.c + predict-1.c + profile-info-section.c + redecl-15.c + struct-semi-4.c + visibility-7.c + warn-nsstring.c + winline-10.c + attr-alloc_size.c + pr99323-1.c + c11-fordecl-3.c + init-bad-6.c + + + # cannot cust 0 to nullptr_t + c2x-nullptr-1.c + + # qualifer not lost by ternary (pre C2x) + c11-qual-1.c + + # undefined fenv functions (library issue?) + bitint-29.c + bitint-30.c + pr95115.c + pr110755.c + + ### BOOL_MAX not defined BOOL_WIDTH != 1 + c2x-bool-limits-1.c + # __float80/128 is not supported on this target + const-float128-ped.c + const-float80-ped.c + # "CR_DECIMAL_DIG not defined" + cr-decimal-dig-3.c + + # pragma GCC + associative-math-1.c + associative-math-2.c + + # pragma init & fini + pragma-init-fini.c + + # Skip darwin only test + darwin-minversion-2.c + darwin-20040812-1.c + darwin-minversion-3.c + darwin-comm.c + darwin-minversion-4.c + darwin-ld-1.c + darwin-minversion-5.c + darwin-ld-20040809-1.c + darwin-minversion-6.c + darwin-ld-20040809-2.c + darwin-minversion-7.c + darwin-ld-20040828-1.c + darwin-minversion-8.c + darwin-ld-20040828-2.c + darwin-minversion-9.c + darwin-ld-20040828-3.c + darwin-minversion-link.c + darwin-ld-2.c + darwin-sections.c + darwin-ld-3.c + darwin-segaddr.c + darwin-ld-4.c + darwin-version-1.c + darwin-ld-5.c + darwin-weakimport-1.c + darwin-minversion-10.c + darwin-weakimport-2.c + darwin-minversion-11.c + darwin-weakimport-3.c + darwin-minversion-12.c + darwin-weakref-1.c + darwin-minversion-1.c + attr-weakref-1-darwin.c + framework-1.c + framework-2.c + + # Skip solaris2 only test + c99-math-long-double-1.c + c99-math-double-1.c + c99-math-float-1.c + + # bad return type + 20030906-1.c + 20030906-2.c + diagnostic-range-bad-return.c + + # Clang not support vector size not an integral multiple of component size + vshift-7.c + + # GCC Extension: Nested functions + 20011130-1.c + 20030331-2.c + 20031218-2.c + 20031218-3.c + 20050607-1.c + cleanup-7.c + inline-28.c + inline-29.c + inline-30.c + nested-func-4.c + nested-func-5.c + nested-func-7.c + nested-func-8.c + nested-func-9.c + nested-func-10.c + nested-func-11.c + nested-func-12.c + Wswitch-unreachable-2.c + Wunused-local-typedefs.c + non-local-goto-1.c + non-local-goto-2.c + wtr-func-def-1.c + trampoline-1.c + pr23547.c + pr30045.c + pr49994-1.c + pr59011.c + pr59920-3.c + pr18963-1.c + pr79255.c + pr89342.c + pr94780.c + pr79494.c + pr89045.c + Wshadow-4.c + Wtrampolines.c + Wunused-var-1.c + attr-externally-visible-2.c + pr94842.c + nested-vla-2.c + nested-vla-3.c + pr102273.c + pr105972.c + pr106421.c + pr106465.c + qual-return-8.c + + # Variable length arrays in structs + 20050527-1.c + packed-vla.c + pr19345.c + pr27301.c + pr30189.c + pr33238.c + pr47766.c + pr51990-2.c + pr83844.c + vla-2.c + vla-22.c + pr51990.c + pr34457-1.c + pr51628-18.c + pr51628-19.c + Wstringop-overflow-15.c + Warray-bounds-50.c + Wrestrict.c + Wrestrict-17.c + Warray-bounds-51-novec.c + Warray-bounds-51.c + Warray-bounds-22.c + Wrestrict-24.c + builtin-clear-padding-1.c + builtin-dynamic-object-size-0.c + nested-vla-1.c + pr109450-1.c + pr109450-2.c + pr70418.c + pr99122-1.c + pr99122-2.c + pr99122-3.c + typename-vla-3.c + typename-vla-4.c + typename-vla-6.c + vla-stexp-1.c + vla-stexp-2.c + vla-stexp-5.c + vla-stexp-8.c + typename-vla-5.c + + # GCC Extension: __builtin_* + pr28796-1.c + pr28796-2.c + pr29215.c + pr32041.c + pr38338.c + pr44539.c + pr46251.c + pr48826.c + pr49994-3.c + pr50251.c + pr52691.c + pr61773.c + pr62090.c + pr62090-2.c + pr64252.c + pr71478.c + pr78768.c + pr78775.c + pr78902.c + pr78973-2.c + pr79538.c + pr79715.c + pr80020.c + pr81650.c + pr82123.c + pr82274-2.c + pr82916.c + pr83198.c + pr84068.c + pr84503-1.c + pr85414.c + pr85512.c + pr87024.c + pr87490.c + pr89435.c + pr89521-2.c + pr89795.c + pr90037.c + pr90898.c + pr91014.c + pr91069.c + pr93376.c + pr93412.c + pr93430.c + pr93986.c + pr94189.c + sibcall-6.c + predict-16.c + nextafter-1.c + nextafter-2.c + nextafter-3.c + nextafter-4.c + strlenopt-83.c + strlenopt-84.c + strlenopt-85.c + strlenopt-86.c + Walloca-3.c + Walloca-4.c + Walloca-8.c + Walloca-9.c + Walloca-10.c + Walloc-size-larger-than.c + Walloc-size-larger-than-1.c + Walloc-size-larger-than-2.c + Walloc-size-larger-than-3.c + Walloc-size-larger-than-4.c + Walloc-size-larger-than-5.c + Walloc-size-larger-than-6.c + Walloc-size-larger-than-7.c + Walloc-size-larger-than-8.c + Walloc-size-larger-than-9.c + Walloc-size-larger-than-10.c + Walloc-size-larger-than-11.c + Walloc-size-larger-than-12.c + Walloc-size-larger-than-13.c + Walloc-size-larger-than-14.c + Walloc-size-larger-than-15.c + Walloc-size-larger-than-17.c + Wc90-c99-compat-4.c + Wstringop-overflow-22.c + Wmissing-attributes.c + Wstringop-overflow-28.c + va-arg-pack-2.c + va-arg-pack-len-1.c + fold-bcopy.c + attr-copy-6.c + attr-copy-7.c + attr-copy-8.c + builtin-has-attribute.c + builtin-return-1.c + gnu2x-builtins-no-dfp-1.c + builtin-apply4.c + builtins-43.c + builtins-44.c + builtin-apply1.c + builtin-apply2.c + builtin-apply3.c + builtin-apply4.c + 20001117-1.c + 20031002-1.c + attr-alloc_size-6.c + attr-alloc_size-7.c + attr-alloc_size-8.c + attr-alloc_size-9.c + builtin-alloc-size.c + builtin-stringop-chk-5.c + builtin-stringop-chk-8.c + Wstringop-truncation-6.c + spec-barrier-3.c + builtins-12.c + builtins-55.c + builtins-57.c + fold-convround-1.c + pr84503-2.c + webizer.c + builtin-tgmath-1.c + builtin-tgmath-2.c + builtin-tgmath-3.c + Wbuiltin-declaration-mismatch-3.c + nonnull-3.c + fold-perm.c + Wunused-var-3.c + builtins-nonnull.c + builtins-1.c + pr89520-2.c + strlenopt-42.c + string-opt-1.c + pr89520-1.c + builtins-45.c + builtins-85.c + builtins-59.c + builtins-60.c + pr68474.c + pr54346.c + pr100239.c + pr102897.c + pr105591.c + pr104389.c + + # GCC Ext: __attribute__((__vector_size__)) + pr106063.c + pr109230.c + pr109583.c + pr96377-4.c + pr96377-6.c + vshift-6.c + + # GCC Ext: __attribute__ scalar_storage_order + sso-17.c + + + # clang doesn't guarantee tail calls for self calls + sibcall-*.c + + # semicolon in function args + pr109970.c + + # __builtin_clz redefined with a different type + pr100521.c + pr100790.c + + # 1st 2 args of '__builtin_shufflevector' must have the same type + pr100887.c + pr101294.c + + # Skip the test case that need ${srcdir} defined by GCC scripts + pr33919.c + + # Test cases need gnu99 extension + vla-12.c + vla-14.c + vla-15.c + pragma-align-2.c + pr56078.c + Wc99-c11-compat-4.c + Wparentheses-10.c + fltconst-2.c + gnu99-init-1.c + inline-7.c + noreturn-5.c + pr18502-1.c + utf-inc-init.c + utf-type.c + utf16-1.c + utf16-2.c + utf16-3.c + utf32-1.c + utf32-2.c + utf32-3.c + utf-cvt.c + binary-constants-1.c + dll-7.c + + # Test cases need gnu89 extension + 20040203-1.c + anon-struct-3.c + inline-6.c + gnu89-init-1.c + gnu89-init-2.c + gnu89-init-3.c + gnu89-init-4.c + dll-6.c + fail_always_inline2.c + + # Test case need gnu90 extension + Wc90-c99-compat-5.c + Wc90-c99-compat-7.c + + # Test case need gnu11 extension + gnu11-*.c + + # Test case need gnu2x extension + gnu2x-*.c + bitint-12.c + bitint-17.c + bitint-28.c + + # GCC ext __typeof_unqual__ + c11-typeof-2.c + + + # Skip the test case need scan gcc's MD pattern + old-style-asm-1.c + + # Skip the test cases need gcc's marco, __GCC_IEC_559 + iec-559-macros-1.c + iec-559-macros-2.c + iec-559-macros-3.c + iec-559-macros-4.c + iec-559-macros-5.c + iec-559-macros-6.c + iec-559-macros-7.c + iec-559-macros-8.c + iec-559-macros-9.c + c99-predef-1.c + + # malloc attribute with arguments + Wmismatched-dealloc.c + Wmismatched-dealloc-2.c + Wmismatched-dealloc-3.c + + # clang doesn't support declaration and } after goto label + c11-labels-1.c + c11-labels-2.c + c2x-labels-*.c + pr100349.c + + + # clang doesn't support comma in preprocessor define + bitint-31.c + + # preprocessor version macros __STDC_VERSION* not defined + c2x-has-c-attribute-2.c + c2x-limits-1.c + c2x-stdarg-5.c + c2x-stdatomic-1.c + c2x-stddef-1.c + c2x-stdint-1.c + + # __NO_SIGNED_ZEROS__ not defined + no-signed-zeros-*.c + + # __NO_TRAPPING_MATH__ not defined + no-trapping-math-*.c + + # "__RECIPROCAL_MATH__ not defined" + reciprocal-math-*.c + + # __ROUNDING_MATH__ not defined + rounding-math-*.c + + # GCC --help=X + opts-8.c + + # C2x UTF-8 string not unsigned char * + c2x-utf8str-type.c + + # clang has incomplete C2x typeof implementation + c2x-typeof-1.c + + # clang does not support unsigned bitfields + bitfld-9.c + + # Clang won't define __NO_MATH_ERRNO__ marco, when using + # -fno-math-errno or -fmath-errno or -ffast-math. + no-math-errno-1.c + no-math-errno-2.c + no-math-errno-3.c + no-math-errno-4.c + + # Clang not support GNU decimal type extension + pr105173.c + pr105263.c + pr107686.c + pr105376.c + pr96370.c + pr96579.c + pr98099.c + pr57371-5.c + + # Clang can support -fleading-underscore option + unwind-1.c + + # gcov tests + gcov-info-to-gcda.c + # gimple tests + gimplefe-*.c + pr109732.c + pr81192.c + pr95582.c + pr98211.c + gimplefe-10.c + gimplefe-11.c + gimplefe-12.c + gimplefe-13.c + gimplefe-14.c + gimplefe-15.c + gimplefe-16.c + gimplefe-17.c + gimplefe-18.c + gimplefe-19.c + gimplefe-1.c + gimplefe-20.c + gimplefe-21.c + gimplefe-22.c + gimplefe-23.c + gimplefe-24.c + gimplefe-25.c + gimplefe-26.c + gimplefe-27.c + gimplefe-28.c + gimplefe-29.c + gimplefe-2.c + gimplefe-30.c + gimplefe-31.c + gimplefe-32.c + gimplefe-33.c + gimplefe-34.c + gimplefe-35.c + gimplefe-36.c + gimplefe-37.c + gimplefe-38.c + gimplefe-39.c + gimplefe-3.c + gimplefe-42.c + gimplefe-43.c + gimplefe-44.c + gimplefe-4.c + gimplefe-5.c + gimplefe-6.c + gimplefe-7.c + gimplefe-8.c + gimplefe-9.c + uninit-25-gimple.c + uninit-29-gimple.c + uninit-31-gimple.c + uninit-pr90394-1-gimple.c + pr80170.c + pr90726.c + pr93820-2.c + + # Clang not support fold non-constant strlen relational expressions + strlenopt-81.c + + # clang does not support c2x constexpr + c2x-constexpr-1.c + c2x-constexpr-2a.c + c2x-constexpr-2b.c + c2x-constexpr-4.c + c2x-constexpr-5.c + c2x-constexpr-8.c + bitint-2.c + + # Using C2X features in C11 + c11-complit-3.c + c11-floatn-5.c + c11-floatn-6.c + c11-floatn-8.c + + + # clang doesn't support c2x storage class specifiers + c2x-complit-*.c + + # C2x enumeration + c2x-enum-*.c + + # C2x __STDC_VERSION_* + c2x-float-13.c + + # C2x INFINITY/NAN not in float.h + c2x-float-2.c + c2x-float-3.c + c2x-float-4.c + c2x-float-5.c + + # FLT/DBL_IS_IEC_60559 / FLT/DBL_SNAN + c2x-float-10.c + c2x-float-6.c + c2x-float-7a.c + c2x-float-7b.c + c2x-float-7c.c + + + # gnu::asume + attr-assume-1.c + + # Clang not support "IBM1047" codeset + strlenopt-56.c + c2x-utf8char-2.c + + # Clang not support iso-8859-* codeset + ucnid-9-utf8.c + utf8-1.c + ucnid-9.c + ucnid-5.c + + # Clang not support -finput-charset=latin1 + ucnid-16-utf8.c + + # Clang not support -fallow-parameterless-variadic-functions + va-arg-5.c + c2x-stdarg-1.c + c2x-stdarg-2.c + + # stddef.h not included + c2x-nullptr-5.c + + # Clang didn't define INTX_WIDTH in clang/lib/Headers/stdint.h + stdint-width-1.c + stdint-width-2.c + + # Clang didn't define INT_FAST16_MIN in clang/lib/Headers/stdint.h + c99-stdint-7.c + + # Clang didn't define CHAR_WIDTH in clang/lib/Headers/limit.h + limits-width-1.c + limits-width-2.c + + # Clang not support -fsso-struct= + sso-6.c + sso-7.c + sso-8.c + sso-10.c + + # Clang not support for vector enum type + pr87286.c + + # Clang not support _Atomic qualifier syntax properly yet + Warray-bounds-90.c + typeof-2.c + pr65345-2.c + Wtype-limits2.c + Wstringop-overflow-77.c + Wstringop-overflow-78.c + bitint-18.c + c2x-qual-7.c + lvalue-11.c + + # Clang not support --specs= + spec-options.c + + # Clang not allow dwo section contain any relocations. + # dwo section will be created for split dwarf debut section. + pr79342.c + pr86064.c + pr86459.c + + # Clang not support apply restrict type qualifier with typedef + c99-restrict-2.c + + # GCC expect to show warning when -fprofile-use with no profile files, + # but Clang will show error. + pr51957-1.c + pr80747.c + pr40209.c + Wmissing-profile.c + pr32773.c + + # GCC expect -Wno-c11-c2x-compat could disable warning message, + # but Clang will show error. + c11-attr-syntax-3.c + + # GCc expect builtin math function could to constant folding + # but clang can't do it now. + builtins-32.c + + # Clang not support initializer element is a compile-time constant + Wc90-c99-compat-6.c + c11-complex-1.c + fold-reassoc-3.c + pr14649-1.c + pr36901-1.c + pr36901-2.c + pr55019.c + pr83801.c + + # Clang not support non-ASCII characters outside of literals and identifiers + ucnid-5-utf8.c + ucnid-15-utf8.c + + # Clang not support -fprofile-generate -fprofile-use in the same command + # line + pr26570.c + + # Clang not support __attribute__((no_reorder) attribute + noreorder.c + noreorder2.c + noreorder4.c + + # clang does not support __attribuite__((alias(...))) on typedef + attr-alias-4.c + + # Clang not allow probability argument to __builtin_expect_with_probability + # outside the range [0.0, 1.0] + pr87811-3.c + + # Clang not support __FLT128_MAX__ + pr88074-2.c + + # Clang can't not detect address of vector element defined by typedef + pr85376.c + fold-cvect.c + + # Clang not support 'd' on floating constant + # https://github.com/Unidata/netcdf-c/issues/811 + pr79574-2.c + Wunsuffixed-float-constants-1.c + + # Clang will expect second parameter of 'main' (argument array) must + # be of type 'char **' + pr78582.c + pr83415.c + + # Clang will treat _setjmp as builtin instead of the declaration in + # the test case + pr71084.c + + # Clang syntax error of static_assert + pr61817-1.c + pr61817-2.c + c11-static-assert-1.c + c11-static-assert-5.c + c11-static-assert-6.c + c11-static-assert-7.c + c11-static-assert-9.c + c11-static-assert-10.c + + # Clang will define nan as builtin functions + builtins-35.c + + # Clang will not define __SIG_ATOMIC_TYPE__ + c99-stdint-5.c + + # Clang not support parameter references not allowed in naked functions + pr44290-1.c + + # Clang will show integer literal is too large to be represented in any + # integer type error message + pr82765.c + + # GCC expect that function could be removed by compile time # but clang can't + builtins-10.c + builtins-11.c + builtins-18.c + builtins-19.c + builtins-20.c + builtins-26.c + builtins-27.c + builtins-31.c + builtins-41.c + builtins-52.c + builtins-54.c + builtins-65.c + builtin-bswap-12.c + pr102950.c + pr42461.c + 20050121-2.c + + # Clang not support _FloatX + float128-align.c + float32x-align.c + floatn-arithconv.c + float128-typeof.c + float32x-typeof.c + float128x-align.c + float64-align.c + float-range-1.c + float128x-typeof.c + float64-typeof.c + float-range-3.c + float16-align.c + float64x-align.c + float-range-4.c + float16-typeof.c + float64x-typeof.c + float-range-5.c + float32-align.c + float-exact-1.c + float32-typeof.c + bitint-35.c + c2x-floatn-*.c + pr104511.c + pr105211.c + pr105250.c + pr107967-1.c + pr107967-2.c + pr107967-3.c + + # '-fsignaling-nans' is not supported + pr105414.c + + # Clang not support some GNU inline asm syntax + Woverlength-strings-pedantic-c89-asm.c + Woverlength-strings-pedantic-c90-asm.c + Woverlength-strings-pedantic-c99-asm.c + builtin-unreachable-1.c + asm-2.c + asm-3.c + asm-4.c + asm-a.c + pr44290-2.c + asm-pr24146.c + + # Clang will generate __muloti4 which only contain in compiler-rt + # not in libgcc + pr82274-1.c + + # Clang will need profiling library libclang_rt.profile-riscv64.a + # from compiler-rt + pr48770.c + 20020201-1.c + profile-generate-1.c + profile-generate-2.c + profile-generate-3.c + + # Clang not support the argument of __builtin_assume_aligned is variable + builtin-assume-aligned-1.c + + # clang does not support '__builtin_clear_padding + bitint-16.c + + # __builtin_bswap128 not defined + builtin-bswap-11.c + + # builtin functions must be directly called + builtin-dynamic-object-size-19.c + pr59630.c + pr69156.c + pr98330.c + + # Clang not support u8 identifier + c2x-utf8char-1.c + + # Clang not support GCC mcount profiling + pr43643.c + pr32450.c + aru-2.c + + # Clang not support -fno-keep-inline-dllexport + dll-10.c + dll-11.c + dll-12.c + + # Clang required weakref declaration must also have an alias attribute + attr-weakref-1.c + + # Clang has differrent builtin argument type for __atomic_is_lock_free + atomic-noinline.c + atomic-noinline-aux.c + atomic-lockfree.c + atomic-lockfree-aux.c + + # Clang have different behavior of __builtin_object_size and + # __builtin_offsetof + builtin-object-size-*.c + builtin-dynamic-object-size-*.c + pr101836*.c + strict-flex-array-3.c + + # Clang not support GNU "cleanup" attribute + cleanup-5.c + cleanup-8.c + cleanup-9.c + cleanup-10.c + cleanup-11.c + cleanup-12.c + cleanup-13.c + + # Clang not support GNU parameter forward declarations + parm-forwdecl-4.c + + # Clang not support define the function name already is clang's builtin + atomic-generic.c + atomic-generic-aux.c + + # Some macros won't define by Clang + c2x-float-1.c + builtin-arith-overflow-3.c + c99-stdint-6.c + c99-stdint-7.c + c99-stdint-8.c + cr-decimal-dig-1.c + c90-float-1.c + + # Clang not support -fplan9-extensions + anon-struct-12.c + + # Clang not support -fpermitted-flt-eval-methods + fpermitted-flt-eval-methods_1.c + fpermitted-flt-eval-methods_2.c + fpermitted-flt-eval-methods_3.c + fpermitted-flt-eval-methods_4.c + + # Clang not support get address with _Alignas + c11-align-7.c + + # Clang not allow __attribute__((alloc_size(n))) with function of no + # arguments + attr-alloc_size-2.c + + # Clang not support __float80 + const-float80.c + + # Ignore the case because LLVM could not determine __builtin_constant_p(x) + # at compile time in this case. + # __builtin_constant_p (x) will return 1 if x could determine as constant + # at compile time. + addr_equal-1.c + + # Clang preprocessor have different behavior + c90-hexfloat-2.c + + # Clang not support -fstack-protector-explicit + stackprotectexplicit1.c + + # Clang not support GNU ifunc attribute + attr-ifunc-1.c + attr-ifunc-3.c + attr-ifunc-4.c + attr-ifunc-5.c + + # attributes between extern and type + c2x-align-1.c + + # attribute cannot be applied to a statement + c2x-attr-maybe_unused-1.c + c2x-attr-syntax-2.c + + # clang does not support C2x type inference + c2x-auto-*.c + + # clang does not support C2x Storage-class specifiers for compound literals + c2x-complit-*.c + gnu2x-complit-*.c + + + # C2x removal of for declation restriction, not supported by clang + c2x-fordecl-1.c + + + # Skip mingw/cygwin only tests + bf-ms-attrib.c + + # In the following case, it seems that clang will take ptr alias to &b + # according to the asm line, but GCC think they are not alias + # + # int *b; + # int main() { + # float **ptr; + # asm ("":"=r"(ptr):"0"(&b)); + # b=NULL; + # *ptr=(float*)(size_t)1; + # if (b) + # __builtin_abort (); + # return 0; + # } + alias-14.c + + # If there are only weak symbol functions with the same name in each compile + # unit, GCC expect to pick the function within the same compile unit + # But Clang didn't. Clang will assert abort() in localalias-2.c:tt() + localalias.c + localalias-2.c + + # GCC expect the sign of foo (0.0 / -5.0, 10) in the test case will change + # with the flag -fvariable-expansion-in-unroller. But clang doesn't support + # the flag. + pr30957-1.c + + # GCC has -fexcess-precision=standard as a way to force well-defined + # precision for cast and assignment operations. But clang doesn't support + # the flag. + pr61441.c + + # The floating multiplication in the test case may geneate negative zeros. + # With the -fno-signed-zeros flag, GCC will eliminate the signed zeros + # But clang won't which make the floating zero comparison return false + pr88598-3.c + + # The test case compile with -Ofast will enable -fno-signed-zeros. + # GCC will eliminate the negative zores. But clang won't. + sinatan-1.c + + # Clang not support some GNU openmp syntax + pr88071.c + + # Disable the time consuming test cases. + memcmp-1.c + pr59605-2.c + + # Infinite loops are UB in C11 + pr78185.c + + + # -INT_MIN is undefined behaviour + signbit-6.c + + # Clang-15 no support old style definition + c2x-old-style-definition-*.c + Wold-style-definition-2.c + + # Skip h8300 target test + kpice1.c + + + # skip tests that include subfolders not ported yet + pr81588.c + pr77664.c + pr81621.c + pr84225.c + pr86979.c + pr88676.c + + # These tests require effective target `sync_int_128_runtime`. But + # infact, there is no backend in GCC that provides this target + # requirement, therefore we should always skip them. + atomic-compare-exchange-5.c + atomic-load-5.c + atomic-store-5.c + atomic-store-6.c + atomic-op-5.c + + # Clang doesn't support the `p` asm constraint + pr58805.c + + # This test uses inline assembly, but doesn't restrict itself to a + # specific backend. Unlike GCC, Clangs `asm` implementation cares + # about the actual instruction inside the quotes, so we would have + # to port it to every possible backend. + pr43564.c + + # We don't support the GNU BitInt decimal type + bitint-10.c + + # Attempt to declare a global register variable + pr34351.c + pr57104.c + + # -m32 specific + attr-ms_struct-1.c + attr-ms_struct-2.c + + # Weird architectures only + bf-spl1.c + + # Something to do with neted functions + cwsc1.c + + # Wrong `-march` option for Clang + profile-update-warning.c + + # LLVM expects us to mark variables as volatile if we want to + re-read them after longjmp'ing back + setjmp-3.c + setjmp-4.c + + # Stack protector + ssp-1.c + ssp-2.c +) + +list(APPEND TestsToSkip ${UnsupportedTests}) + +# Tests where clang currently has bugs or issues +file(GLOB FailingTests CONFIGURE_DEPENDS + pr59992.c + pr78547.c + pr89314.c + pr87985.c + pr85180.c + strlenopt-55.c + stack-check-16.c + c99-intconst-1.c + transparent-union-6.c + 20020425-1.c + Wnonnull-2.c + Wnonnull-3.c + + # Temporary skip LTO test cases until we enabled the feature + pr30762-1.c + pr31529-1.c + pr43157.c + pr34668-1.c + pr43557-1.c + initpri3.c + pr97172-2.c + + # "foo" == __func__ optimized to true + c99-func-3.c + + # clang crashes + pr105094.c + vla-stexp-4.c + vla-stexp-6.c + vla-stexp-7.c +) +list(APPEND TestsToSkip ${FailingTests}) + +# RISC-V Test Blacklist +if(ARCH MATCHES "riscv") + file(GLOB RISCVTestsToSkip CONFIGURE_DEPENDS + # No backend support for __builtin_longjmp/__builtin_setjmp + setjmp-2.c + setjmp-3.c + setjmp-4.c + setjmp-6.c + pr26983.c + pr56727-2.c + Winfinite-recursion.c + Winfinite-recursion-2.c + pr101156.c + + # RISCV target not support split stack + split-1.c + split-2.c + split-3.c + split-4.c + split-5.c + split-6.c + split-7.c + split-8.c + pr79499.c + pr84300.c + + # The test cases for several backends but not for riscv + pr31866.c + pr89313.c + pr87600-1.c + 20020103-1.c + bf-spl1.c + + # Support clz only when Zbb extension enabled + pr43564.c + + # RISCV not support -fsanitize=thread yet + pr55702.c + pr57104.c + + # RISCV not support -fstack-protector yet + ssp-1.c + ssp-2.c + + # Invalid output constraint for RISCV + pr58805.c + + # PIE not default enabled + pie-5.c + + # RISCV not support atomic operations on "int_128" values + atomic-store-6.c + atomic-compare-exchange-5.c + atomic-op-5.c + + # RISCV not support __float128 + const-float128.c + + # RISCV not support atomic operation with width 1 and 2. + atomic-exchange-1.c + atomic-exchange-2.c + atomic-op-1.c + atomic-op-2.c + atomic-compare-exchange-1.c + atomic-compare-exchange-2.c + + # RISCV not support c99 tgmath. + c99-tgmath-1.c + c99-tgmath-2.c + c99-tgmath-3.c + c99-tgmath-4.c + + # RISCV does not support `__bf16` + pr107262.c + ) + + if (LIBC MATCHES "musl") + file(GLOB TestsToSkipForMuslLibc + # Musl defines some things that this disallows + c99-float-1.c + + # No memcpy_chk + strlenopt-2f.c + strlenopt-14gf.c + + # PIE defined + pie-6.c + 20020312-2.c + + # Not support issignaling + pr59833.c + ) + list(APPEND TestsToSkip ${TestsToSkipForMuslLibc}) + endif() + + if (ARCH MATCHES "riscv32") + file(GLOB RISCV32TestsToSkip CONFIGURE_DEPENDS + # No support for __int128 on rv32 + pr67029.c + pr68835-1.c + pr68835-2.c + pr69535.c + pr69896.c + pr70219.c + pr70326.c + pr76783.c + pr78526.c + pr78540.c + pr78547.c + pr78575.c + pr78644-1.c + pr78644-2.c + pr81281-3.c + pr82274-1.c + pr82274-2.c + pr83424.c + pr84068.c + pr84614.c + pr84670-1.c + pr85195.c + pr85257.c + pr85376.c + pr85412.c + pr85414.c + pr85467.c + pr87047.c + pr87054.c + pr87874.c + pr88563.c + pr88594.c + pr89037.c + pr91860-4.c + pr93210.c + pr93376.c + pr93412.c + wide-shift-128.c + atomic-exchange-5.c + pr64807.c + + + # No support for __atomic_exchange_8 on rv32 + atomic-exchange-4.c + di-longlong64-sync-1.c + di-sync-multithread.c + atomic-compare-exchange-4.c + atomic-load-4.c + atomic-store-4.c + atomic-op-4.c + + # Array too large + pr82389.c + ) + + list(APPEND RISCVTestsToSkip ${RISCV32TestsToSkip}) + endif() + + list(APPEND TestsToSkip ${RISCVTestsToSkip}) +endif() + +# x86-only Tests +if(NOT ARCH MATCHES "x86") + file(GLOB X86OnlyTests CONFIGURE_DEPENDS + zero_bits_compound-1.c + zero_bits_compound-2.c + wrapped-binop-simplify.c + visibility-11.c + asm-b.c + union-5.c + pr56990.c + pr59020.c + pr34351.c + pr85388-1.c + pr85388-2.c + pr85388-3.c + pr85388-4.c + pr85388-5.c + pr85388-6.c + profile-update-warning.c + atomic-store-5.c + atomic-load-5.c + attr-ms_struct-1.c + attr-ms_struct-2.c + macro-fusion-1.c + macro-fusion-2.c + bf-ms-layout.c + bf-ms-layout-4.c + ) + + list(APPEND TestsToSkip ${X86OnlyTests}) +endif() + +# arm-only Tests +if(NOT ARCH MATCHES "arm") + file(GLOB armOnlyTests CONFIGURE_DEPENDS + pr94269.c + pr106621.c + ) + + list(APPEND TestsToSkip ${armOnlyTests}) +endif() + +# aarch64-only Tests +if(NOT ARCH MATCHES "aarch64") + file(GLOB aarch64OnlyTests CONFIGURE_DEPENDS + pr94784.c + ) + + list(APPEND TestsToSkip ${aarch64OnlyTests}) +endif() + +# mips-only Tests +if(NOT ARCH MATCHES "mips") + file(GLOB mipsOnlyTests CONFIGURE_DEPENDS + delay-slot-1.c + ) + + list(APPEND TestsToSkip ${mipsOnlyTests}) +endif() + +# powerpc-only Tests +if(NOT ARCH MATCHES "powerpc") + file(GLOB POWERPCOnlyTests CONFIGURE_DEPENDS + var-expand3.c + ) + + list(APPEND TestsToSkip ${POWERPCOnlyTests}) +endif() + +# mmix-only Tests +if(NOT ARCH MATCHES "mmix") + file(GLOB mmixOnlyTests CONFIGURE_DEPENDS + mmix-1.c + ) + + list(APPEND TestsToSkip ${mmixOnlyTests}) +endif() + +# Skip the test cases non-supported for non-linux targets +if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux") + file(GLOB TestsToSkipForNonLinux + struct-ret-3.c + 20050826-1.c + 20030711-1.c + strncmp-2.c + di-sync-multithread.c + atomic-exchange-5.c + pr55430.c + pr59833.c + pr65408.c + pr78185.c + pr83047.c + pr85388-1.c + pr85388-3.c + pr85388-4.c + split-1.c + split-3.c + split-4.c + pthread-init-1.c + pthread-init-2.c + pie-link.c + # Picolibc not support print format with %n. + pr78965.c + ) + list(APPEND TestsToSkip ${TestsToSkipForNonLinux}) +endif() + +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + file(GLOB TestsToSkipForLinux + # PIE defined + pie-6.c + ) + list(APPEND TestsToSkip ${TestsToSkipForLinux}) +endif() + +if(FEATURE_ATOMIC MATCHES "OFF") + file(GLOB TestsToSkipForNonAtomic + pr37908.c + atomic-compare-exchange-1.c + atomic-compare-exchange-2.c + atomic-compare-exchange-3.c + atomic-exchange-1.c + atomic-exchange-2.c + atomic-exchange-3.c + atomic-fence.c + atomic-flag.c + atomic-load-1.c + atomic-load-2.c + atomic-load-3.c + atomic-op-1.c + atomic-op-2.c + atomic-op-3.c + atomic-op-optimize.c + atomic-store-1.c + atomic-store-2.c + atomic-store-3.c + ia64-sync-1.c + ia64-sync-2.c + ia64-sync-3.c + ia64-sync-4.c + sync-1.c + sync-2.c + sync-3.c + pr54087.c + pr86314.c + pr94368.c + predict-18.c + 20061124-1.c + ) + list(APPEND TestsToSkip ${TestsToSkipForNonAtomic}) +endif() + +if (NOT MARCH MATCHES "f") + file (GLOB TestsToSkipForNonFPU + complex-5.c + c99-math-float-1.c + c99-math-double-1.c + c99-math-long-double-1.c + ) + list(APPEND TestsToSkip ${TestsToSkipForNonFPU}) +endif() + +## +## Tests that require extra CFLAGS in Clang +## + +# Tests that require libm (-lm ldflag) +file(GLOB TestRequiresLibM CONFIGURE_DEPENDS + pow-sqrt-1.c + pow-sqrt-2.c + pow-sqrt-3.c + sinatan-1.c + pr43419.c + pr36017.c + pr82004.c + pr91734.c + pr41963.c + builtins-6.c +) + +# Tests that require libatomic (-latomic ldflag) +file(GLOB TestRequiresLibAtomic CONFIGURE_DEPENDS + atomic-exchange-5.c +) + +# Tests that require '__declspec' attributes +file(GLOB TestRequiresDECLSPEC CONFIGURE_DEPENDS + dll-10a.c + dll-11.c + dll-1.c + dll-4.c + dll-6.c + dll-8.c + dll-10.c + dll-12a.c + dll-2.c + dll-5.c + dll-7a.c + dll-9a.c + dll-11a.c + dll-12.c + dll-3.c + dll-6a.c + dll-7.c + dll-9.c + visibility-10.c +) + +if (CMAKE_C_COMPILER_ID MATCHES "GNU") + list(APPEND TestsToSkip ${TestRequiresDECLSPEC}) +endif() + +# Skip time consumed tests +if(TEST_SUITE_TEST_MODE MATCHES "fast-run") + file(GLOB TimeConsumingTests CONFIGURE_DEPENDS + pr43058.c + unroll-and-jam.c + pr83323.c + cdce1.c + pow-sqrt-1.c + pow-sqrt-2.c + pow-sqrt-3.c + ) + + list(APPEND TestsToSkip ${TimeConsumingTests}) +endif() + +# Skip fixed opt level tests when there are extra cflags +if(EXTRA_CFLAGS MATCHES "") + file(GLOB OptFixedTests CONFIGURE_DEPENDS + # opts-2.c expect -O0 but --extra-cflags may change the opt level. + opts-2.c + ) + + list(APPEND TestsToSkip ${OptFixedTests}) +endif() + +# Tests that require -Wno-return-type +file(GLOB TestRequiresWNoReturnType CONFIGURE_DEPENDS + pr83585.c +) + +# Tests that require -ffixed-point +file (GLOB TestRequiresFFixedPoint CONFIGURE_DEPENDS + pr103248.c +) + +# Tests that use varargs on segmented stacks, and are not supported by +# the platform +if(ARCH MATCHES "x86" OR ARCH MATCHES "arm") + file(GLOB UnsupportedTests CONFIGURE_DEPENDS + split-6.c + split-3.c + pr85388-5.c + pr85388-3.c + ) +endif() + +list(APPEND TestsToSkip ${UnsupportedTests}) + +## +## Test target setup +## + +file(GLOB TestFiles CONFIGURE_DEPENDS + *.c +) +foreach(TestToSkip ${TestsToSkip}) + list(REMOVE_ITEM TestFiles ${TestToSkip}) +endforeach() + +foreach(File ${TestFiles}) + set(MaybeCFlags) + set(MaybeLDFlags) + + # Add Test-specific CFLAGS/LDFLAGS here + + if(${File} IN_LIST TestRequiresLibM) + list(APPEND MaybeLDFlags "-lm") + endif() + + if(${File} IN_LIST TestRequiresLibAtomic) + list(APPEND MaybeLDFlags "-latomic") + endif() + + if(${File} IN_LIST TestRequiresDECLSPEC) + list(APPEND MaybeCFlags "-fdeclspec") + endif() + + if(${File} IN_LIST TestRequiresWNoReturnType) + list(APPEND MaybeCFlags "-Wno-return-type") + endif() + + if(${File} IN_LIST TestRequiresFFixedPoint) + list(APPEND MaybeCFlags "-ffixed-point") + endif() + + # Add Test Target + gcc_torture_execute_test(${File} + DG_DO_DEFAULT "compile" + PREFIX "GCC-DG" + CFLAGS ${MaybeCFlags} + LDFLAGS ${MaybeLDFlags}) + +endforeach() + diff --git a/SingleSource/Regression/C/gcc-dg/O16384.c b/SingleSource/Regression/C/gcc-dg/O16384.c new file mode 100644 index 0000000000..32e17d4e68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/O16384.c @@ -0,0 +1,15 @@ +/* Test insane -O argument. */ +/* { dg-do compile } */ +/* { dg-options "-O16384" } */ + +__attribute__((__optimize__(16396), __noinline__)) void +foo (void) +{ +} + +int +main (void) +{ + foo (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/PR68002.c b/SingleSource/Regression/C/gcc-dg/PR68002.c new file mode 100644 index 0000000000..b61b0950f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/PR68002.c @@ -0,0 +1,7 @@ +/* Ensure static functions can be kept. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fkeep-static-functions" } */ + +static void bar () { } + +/* { dg-final { scan-assembler "bar" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wabsolute-value.c b/SingleSource/Regression/C/gcc-dg/Wabsolute-value.c new file mode 100644 index 0000000000..e3717f9b94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wabsolute-value.c @@ -0,0 +1,57 @@ +/* PR c/89425 - -Wabsolute-value warns in dead subexpressions + { dg-do compile } + { dg-options "-Wabsolute-value -ftrack-macro-expansion=0" } */ + +struct Vals +{ + signed char sc; + signed short ss; + signed int si; + signed long sl; + signed long long sll; + + unsigned char uc; + unsigned short us; + unsigned int ui; + unsigned long ul; + unsigned long long ull; + + float f; + double d; + long double ld; +}; + +#define abs(x) __builtin_abs (x) +#define labs(x) __builtin_labs (x) +#define llabs(x) __builtin_llabs (x) + +#define fabsf(x) __builtin_fabsf (x) +#define fabs(x) __builtin_fabs (x) + + +void tst_warn (struct Vals *p) +{ + /* Verify that "-Wabsolute-value is issued for subexpressions + that are evaluated. */ + + p->uc = 0 ? abs (p->sc) : abs (p->uc); /* { dg-warning "\\\[-Wabsolute-value]" } */ + p->us = 0 ? abs (p->ss) : abs (p->us); /* { dg-warning "\\\[-Wabsolute-value]" } */ + p->ui = 0 ? abs (p->si) : abs (p->ui); /* { dg-warning "\\\[-Wabsolute-value]" } */ + p->ul = 0 ? labs (p->sl) : labs (p->ul); /* { dg-warning "\\\[-Wabsolute-value]" } */ + p->ull = 0 ? llabs (p->sll) : llabs (p->ull); /* { dg-warning "\\\[-Wabsolute-value]" } */ + + p->d = 0 ? fabs (p->d) : fabsf (p->d); /* { dg-warning "\\\[-Wabsolute-value]" } */ +} + +void tst_no_warn (struct Vals *p) +{ + /* Verify that "-Wabsolute-value is not issued for subexpressions + that are not evaluated. */ + + p->uc = 0 ? abs (p->uc) : abs (p->sc); + p->us = 0 ? abs (p->us) : abs (p->ss); + p->ui = 0 ? abs (p->ui) : abs (p->si); + p->ul = 0 ? labs (p->ul) : labs (p->sl); + p->ull = 0 ? llabs (p->ull) : llabs (p->sll); + p->d = 0 ? fabsf (p->d) : fabs (p->d); +} diff --git a/SingleSource/Regression/C/gcc-dg/Waddress-2.c b/SingleSource/Regression/C/gcc-dg/Waddress-2.c new file mode 100644 index 0000000000..4d927f6769 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Waddress-2.c @@ -0,0 +1,24 @@ +/* PR c/48778 */ +/* { dg-do compile } */ +/* { dg-options "-Waddress" } */ + +#define NULL ((void *) 0) + +#define M1(b) ((b) != NULL ? 0 : (b)) +#define M2(b) ((b) == NULL ? 0 : (b)) +#define M3(b) (NULL != (b) ? 0 : (b)) +#define M4(b) (NULL == (b) ? 0 : (b)) + +int +func (int b) +{ + if (M1 (&b) > 0) + return 1; + if (M2 (&b) > 0) + return 2; + if (M3 (&b) > 0) + return 3; + if (M4 (&b) > 0) + return 4; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Waddress-3.c b/SingleSource/Regression/C/gcc-dg/Waddress-3.c new file mode 100644 index 0000000000..c404f6bf65 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Waddress-3.c @@ -0,0 +1,35 @@ +/* PR c/102103 - missing warning comparing array address to null + { dg-do compile } + { dg-options "-Wall" } */ + +typedef _Complex float Cflt; + +extern Cflt cf, cfa[], cfa2[][2]; + +Cflt *pcf (void); + +void T (int); + +void test_complex (Cflt *p, int i) +{ + T (&__real__ cf == 0); // { dg-warning "address of '__real__ cf'" } + T (&__imag__ cf == 0); // { dg-warning "address of '__imag__ cf'" } + + T (0 != &__real__ cf); // { dg-warning "-Waddress" } + T (0 != &__imag__ cf); // { dg-warning "-Waddress" } + + T (&__real__ cfa[0] == 0); // { dg-warning "-Waddress" } + T (&__imag__ cfa[1] == 0); // { dg-warning "-Waddress" } + + T (0 != &__real__ cfa2[i][i]); // { dg-warning "-Waddress" } + T (0 != &__imag__ cfa2[i][i]); // { dg-warning "-Waddress" } + + T (0 == &__real__ *p); // { dg-warning "-Waddress" } + T (0 == &__imag__ *p); // { dg-warning "-Waddress" } + + T (0 == &__real__ p[i]); // { dg-warning "-Waddress" } + T (0 == &__imag__ p[i]); // { dg-warning "-Waddress" } + + T (&__real__ *pcf () == 0); // { dg-warning "-Waddress" } + T (0 != &__imag__ *pcf ()); // { dg-warning "-Waddress" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Waddress.c b/SingleSource/Regression/C/gcc-dg/Waddress.c new file mode 100644 index 0000000000..b26e7b1f32 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Waddress.c @@ -0,0 +1,10 @@ +/* PR c/36299 */ +/* { dg-do compile } */ +/* { dg-options "-Waddress" } */ + +int +foo(void) +{ + char a[1]; + return a == 0; // { dg-warning "-Waddress" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wall.c b/SingleSource/Regression/C/gcc-dg/Wall.c new file mode 100644 index 0000000000..8984847178 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wall.c @@ -0,0 +1,9 @@ +/* PR 30437: Test -Wall + Don't change this without changing Wno-all.c as well. */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +void foo(int a) +{ + 5 * (a == 1) | (a == 2); /* { dg-warning "no effect" "no effect" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-1.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-1.c new file mode 100644 index 0000000000..2e0b76554f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-1.c @@ -0,0 +1,19 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-options "-O -Walloc-size-larger-than=1KB -ftrack-macro-expansion=0" } */ + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + unsigned n = 0; + T (__builtin_malloc (n)); + + n = 1024; /* 1 kibibyte (KB or KiB) */ + T (__builtin_malloc (n)); + + n = 1025; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1025. exceeds maximum object size 1024" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-10.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-10.c new file mode 100644 index 0000000000..559309d553 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-10.c @@ -0,0 +1,27 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile { target lp64 } } + { dg-options "-O -Walloc-size-larger-than=1PiB -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = (size_t)1024 * 1024 * 1024 * 1024 * 1024; /* 1 pebibyte (PiB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1125899906842625. exceeds maximum object size 1125899906842624" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-11.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-11.c new file mode 100644 index 0000000000..41e523c695 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-11.c @@ -0,0 +1,27 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile { target lp64 } } + { dg-options "-O -Walloc-size-larger-than=1PB -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = (size_t)1000 * 1000 * 1000 * 1000 * 1000; /* 1 petabyte (PB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1000000000000001. exceeds maximum object size 1000000000000000" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-12.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-12.c new file mode 100644 index 0000000000..24269a8a10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-12.c @@ -0,0 +1,27 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile { target lp64 } } + { dg-options "-O -Walloc-size-larger-than=1EiB -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = (size_t)1024 * 1024 * 1024 * 1024 * 1024 * 1024; /* 1 exbibyte (EiB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1152921504606846977. exceeds maximum object size 1152921504606846976" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-13.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-13.c new file mode 100644 index 0000000000..b96e3892bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-13.c @@ -0,0 +1,27 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile { target lp64 } } + { dg-options "-O -Walloc-size-larger-than=1EB -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = (size_t)1000 * 1000 * 1000 * 1000 * 1000 * 1000; /* 1 exabyte (EB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1000000000000000001. exceeds maximum object size 1000000000000000000" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-14.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-14.c new file mode 100644 index 0000000000..e632e2236a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-14.c @@ -0,0 +1,30 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-options "-O -Walloc-size-larger-than=123456789123456789123456789123456789 -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +/* Verify that an exceedingly large -Walloc-size-larger-than argument + with no suffix is accepted and treated as infinite. */ + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); + + n = __SIZE_MAX__ - 1; + T (__builtin_malloc (n)); + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-15.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-15.c new file mode 100644 index 0000000000..b699cc09c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-15.c @@ -0,0 +1,30 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-options "-O -Walloc-size-larger-than=123456789123456789123456789123456789gb -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +/* Verify that an exceeingly large -Walloc-size-larger-than argument + with a valid suffic is accepted and treated as infinite. */ + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); + + n = __SIZE_MAX__ - 1; + T (__builtin_malloc (n)); + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-16.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-16.c new file mode 100644 index 0000000000..d035cbb9c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-16.c @@ -0,0 +1,9 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + Verify that an invalid argument to -Walloc-size-larger-than is diagnosed. + { dg-do compile } + { dg-options "-Walloc-size-larger-than=1zb -Walloca-larger-than=2kbytes -Wvla-larger-than=3MIBZ" } */ + + +/* { dg-error "argument to '-Walloc-size-larger-than=' should be a non-negative integer optionally followed by a size unit" "" { target *-*-* } 0 } + { dg-error "argument to '-Walloca-larger-than=' should be a non-negative integer optionally followed by a size unit" "" { target *-*-* } 0 } + { dg-error "argument to '-Wvla-larger-than=' should be a non-negative integer optionally followed by a size unit" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-17.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-17.c new file mode 100644 index 0000000000..752371af2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-17.c @@ -0,0 +1,27 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-options "-O -Wno-alloc-size-larger-than -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); + + n = __SIZE_MAX__ - 1; + T (__builtin_malloc (n)); + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-18.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-18.c new file mode 100644 index 0000000000..7888cb1b1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-18.c @@ -0,0 +1,94 @@ +/* PR tree-optimization/88372 - alloc_size attribute is ignored + on function pointers + Verify that calls via function pointers declared alloc_size + with zero or excessive size trigger either -Walloc-zero or + -Walloc-size-larger-than warnings. + { dg-do compile } + { dg-require-effective-target indirect_calls } + { dg-options "-O2 -Wall -Walloc-zero -ftrack-macro-expansion=0" } */ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) + +typedef __SIZE_TYPE__ size_t; + + +void sink (void*); + +#define T(call) sink (call) + +ATTR (alloc_size (1)) void* (*ai1)(int, int); +ATTR (alloc_size (2)) void* (*ai2)(int, int); +ATTR (alloc_size (1, 2)) void* (*ai1_2)(int, int); + +ATTR (alloc_size (1)) void* (*asz1)(size_t, size_t); +ATTR (alloc_size (2)) void* (*asz2)(size_t, size_t); +ATTR (alloc_size (1, 2)) void* (*asz1_2)(size_t, size_t); + + +void test_alloc_ptr_zero (void) +{ + T (asz1 (0, 0)); /* { dg-warning "argument 1 value is zero" } */ + T (asz1 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + T (asz1 (1, 0)); + T (asz1 (1, 1)); + + T (asz2 (0, 0)); /* { dg-warning "argument 2 value is zero" } */ + T (asz2 (0, 1)); + T (asz2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + T (asz2 (1, 1)); + + T (asz1_2 (0, 0)); /* { dg-warning "argument \[12\] value is zero" } */ + T (asz1_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + T (asz1_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + T (asz1_2 (1, 1)); +} + + +void test_alloc_ptr_negative (int n) +{ + T (ai1 (-1, -1)); /* { dg-warning "argument 1 value .-1. is negative" } */ + T (ai1 (-2, 1)); /* { dg-warning "argument 1 value .-2. is negative" } */ + T (ai1 ( 1, -1)); + T (ai1 ( 1, 1)); + + T (ai2 (-1, -3)); /* { dg-warning "argument 2 value .-3. is negative" } */ + T (ai2 (-1, 1)); + T (ai2 ( 1, -4)); /* { dg-warning "argument 2 value .-4. is negative" } */ + T (ai2 ( 1, 1)); + + T (ai1_2 (-5, -6)); /* { dg-warning "argument \[12\] value .-\[56\]. is negative" } */ + T (ai1_2 ( 1, -7)); /* { dg-warning "argument 2 value .-7. is negative" } */ + T (ai1_2 (-8, 1)); /* { dg-warning "argument 1 value .-8. is negative" } */ + T (ai1_2 ( 1, 1)); + + if (n > -1) + n = -1; + + /* Also verify a simple range. */ + T (ai1_2 ( 1, n)); /* { dg-warning "argument 2 range \\\[-\[0-9\]+, -1] is negative" } */ + T (ai1_2 ( n, 1)); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, -1] is negative" } */ +} + +void test_alloc_ptr_too_big (void) +{ + size_t x = (__SIZE_MAX__ >> 1) + 1; + size_t y = __SIZE_MAX__ / 5; + + T (asz1 (x, x)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds" } */ + T (asz1 (x, 1)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds" } */ + T (asz1 (1, x)); + T (asz1 (1, 1)); + + T (asz2 (x, x)); /* { dg-warning "argument 2 value .\[0-9\]+. exceeds" } */ + T (asz2 (x, 1)); + T (asz2 (1, x)); /* { dg-warning "argument 2 value .\[0-9\]+. exceeds" } */ + T (asz2 (1, 1)); + + T (asz1_2 (x, x)); /* { dg-warning "argument \[12\] value .\[0-9\]+. exceeds" } */ + T (asz1_2 (y, 3)); /* { dg-warning "product .\[0-9\]+ \\\* 3. of arguments 1 and 2 exceeds" } */ + T (asz1_2 (y, y)); /* { dg-warning "product .\[0-9\]+ \\\* \[0-9\]+. of arguments 1 and 2 exceeds" } */ + T (asz1_2 (1, x)); /* { dg-warning "argument 2 value .\[0-9\]+. exceeds" } */ + T (asz1_2 (x, 1)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds" } */ + T (asz1_2 (1, 1)); + +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-2.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-2.c new file mode 100644 index 0000000000..1ded37b0b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-2.c @@ -0,0 +1,20 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-options "-O -Walloc-size-larger-than=1KiB -ftrack-macro-expansion=0" } +*/ + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + unsigned n = 0; + T (__builtin_malloc (n)); + + n = 1024; /* 1 kibibyte (KB or KiB) */ + T (__builtin_malloc (n)); + + n = 1025; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1025. exceeds maximum object size 1024" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-3.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-3.c new file mode 100644 index 0000000000..500ddbf7c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-3.c @@ -0,0 +1,19 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-options "-O -Walloc-size-larger-than=1kB -ftrack-macro-expansion=0" } */ + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + unsigned n = 0; + T (__builtin_malloc (n)); + + n = 1000; /* 1 kilobyte (kB, not to be confused with KB or KiB) */ + T (__builtin_malloc (n)); + + n = 1001; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1001. exceeds maximum object size 1000" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-4.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-4.c new file mode 100644 index 0000000000..54e43cd9e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-4.c @@ -0,0 +1,20 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-require-effective-target size32plus } + { dg-options "-O -Walloc-size-larger-than=1MiB -ftrack-macro-expansion=0" } */ + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + unsigned n = 0; + T (__builtin_malloc (n)); + + n = 1024 * 1024; /* 1 mebibyte (MiB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1048577. exceeds maximum object size 1048576" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-5.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-5.c new file mode 100644 index 0000000000..774c4cf271 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-5.c @@ -0,0 +1,26 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-require-effective-target size32plus } + { dg-options "-O -Walloc-size-larger-than=1MB -ftrack-macro-expansion=0" } */ + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + __SIZE_TYPE__ n = 0; + T (__builtin_malloc (n)); + + n = 1000 * 1000; /* 1 megabyte (MB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1000001. exceeds maximum object size 1000000" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size 1000000" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size 1000000" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-6.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-6.c new file mode 100644 index 0000000000..2dfc6632b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-6.c @@ -0,0 +1,26 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-require-effective-target size32plus } + { dg-options "-O -Walloc-size-larger-than=1GiB -ftrack-macro-expansion=0" } */ + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + __SIZE_TYPE__ n = 0; + T (__builtin_malloc (n)); + + n = 1024 * 1024 * 1024; /* 1 gigibyte (GiB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1073741825. exceeds maximum object size 1073741824" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-7.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-7.c new file mode 100644 index 0000000000..2cc517fab5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-7.c @@ -0,0 +1,26 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-require-effective-target size32plus } + { dg-options "-O -Walloc-size-larger-than=1GB -ftrack-macro-expansion=0" } */ + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + __SIZE_TYPE__ n = 0; + T (__builtin_malloc (n)); + + n = 1000 * 1000 * 1000; /* 1 gigabyte (GB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1000000001. exceeds maximum object size 1000000000" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-8.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-8.c new file mode 100644 index 0000000000..4f84a027d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-8.c @@ -0,0 +1,27 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile { target lp64 } } + { dg-options "-O -Walloc-size-larger-than=1TiB -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = (size_t)1024 * 1024 * 1024 * 1024; /* 1 tebibyte (TiB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1099511627777. exceeds maximum object size 1099511627776" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-9.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-9.c new file mode 100644 index 0000000000..f3927f1456 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than-9.c @@ -0,0 +1,27 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile { target lp64 } } + { dg-options "-O -Walloc-size-larger-than=1TB -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + size_t n = 0; + T (__builtin_malloc (n)); + + n = (size_t)1000 * 1000 * 1000 * 1000; /* 1 terabyte (TB) */ + T (__builtin_malloc (n)); + + n += 1; + T (__builtin_malloc (n)); /* { dg-warning "argument 1 value .1000000000001. exceeds maximum object size 1000000000000" } */ + + n = __PTRDIFF_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ + + n = __SIZE_MAX__; + T (__builtin_malloc (n)); /* { dg-warning "exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than.c b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than.c new file mode 100644 index 0000000000..8096ff1d3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloc-size-larger-than.c @@ -0,0 +1,13 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-options "-Walloc-size-larger-than=0 -ftrack-macro-expansion=0" } */ + +void sink (void*); + +#define T(x) sink (x) + +void f (void) +{ + T (__builtin_malloc (0)); + T (__builtin_malloc (1)); /* { dg-warning "argument 1 value .1. exceeds maximum object size 0" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-1.c b/SingleSource/Regression/C/gcc-dg/Walloca-1.c new file mode 100644 index 0000000000..37ee191218 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-1.c @@ -0,0 +1,64 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=2000 -O2 -ftrack-macro-expansion=0" } */ + +#define alloca __builtin_alloca + +typedef __SIZE_TYPE__ size_t; +extern size_t strlen(const char *); + +extern void useit (char *); + +int num; + +void foo1 (size_t len, size_t len2, size_t len3) +{ + int i; + + for (i=0; i < 123; ++i) + { + char *s = alloca (566); /* { dg-warning "'alloca' within a loop" } */ + useit (s); + } + + char *s = alloca (123); + useit (s); // OK, constant argument to alloca + + s = alloca (num); // { dg-warning "\(may be too large|unbounded use\)" } + useit (s); + + s = alloca (30000); /* { dg-warning "is too large" } */ + useit (s); + + if (len < 2000) + { + s = alloca(len); // OK, bounded + useit (s); + } + + if (len + len2 < 2000) // OK, bounded + { + s = alloca(len + len2); + useit (s); + } + + if (len3 <= 2001) + { + s = alloca(len3); /* { dg-warning "may be too large" } */ + useit(s); + } +} + +void foo2 (__SIZE_TYPE__ len) +{ + // Test that a direct call to __builtin_alloca_with_align is not confused + // with a VLA. + void *p = __builtin_alloca_with_align (len, 8); // { dg-warning "unbounded use of 'alloca'" } + useit (p); +} + +void foo3 (unsigned char a) +{ + if (a == 0) + useit (__builtin_alloca (a)); // { dg-warning "argument to 'alloca' is zero" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-10.c b/SingleSource/Regression/C/gcc-dg/Walloca-10.c new file mode 100644 index 0000000000..6b127cce2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-10.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=2000 -O2" } */ + +// Test when the conditionals are incorrectly reversed. + +void f (void *); +void foo (__SIZE_TYPE__ len) +{ + void *p; + if (len < 500) + p = __builtin_malloc (len); + else + p = __builtin_alloca (len); // { dg-warning "argument to .alloca. may be too large" } + f (p); +} + +void bar (__SIZE_TYPE__ len) +{ + void *p; + if (len > 500) + p = __builtin_alloca (len); // { dg-warning "argument to .alloca. may be too large" } + else + p = __builtin_malloc (len); + f (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-11.c b/SingleSource/Regression/C/gcc-dg/Walloca-11.c new file mode 100644 index 0000000000..8484f9c778 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-11.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca -O2" } */ + +// Make sure we don't warn on VLA with -Walloca. + +void f (void*); + +void h1 (unsigned n) +{ + int a [n]; + f (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-12.c b/SingleSource/Regression/C/gcc-dg/Walloca-12.c new file mode 100644 index 0000000000..d2d9413ab1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-12.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=128 -O2" } */ + +void f (void*); + +void g (unsigned int n) +{ + if (n == 7) + n = 11; + f (__builtin_alloca (n)); /* { dg-warning "may be too large" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-13.c b/SingleSource/Regression/C/gcc-dg/Walloca-13.c new file mode 100644 index 0000000000..d3af0c5039 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-13.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=100 -O2" } */ + +void f (void*); + +void g (int *p, int *q) +{ + __SIZE_TYPE__ n = (__SIZE_TYPE__)(p - q); + if (n < 100) + f (__builtin_alloca (n)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-14.c b/SingleSource/Regression/C/gcc-dg/Walloca-14.c new file mode 100644 index 0000000000..51362b2d6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-14.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/80109 */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-skip-if "small address space" { "pdp11-*-*" } } */ +/* { dg-options "-O2 -Walloca-larger-than=126812070" { target ptr32plus } } */ +/* { dg-options "-O2 -Walloca-larger-than=12070" { target { ! ptr32plus } } } */ + +void +g (int *p) +{ + extern void f (void *); + + void *q = __builtin_alloca (p); /* { dg-warning "passing argument 1" } */ + /* { dg-warning "unbounded use of 'alloca'" "unbounded" { target *-*-* } .-1 } */ + f (q); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-15.c b/SingleSource/Regression/C/gcc-dg/Walloca-15.c new file mode 100644 index 0000000000..f34ffd98b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-15.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=128 -O2" } */ + +typedef __SIZE_TYPE__ size_t; + +void bar (void*); + +void foo1 (size_t len) +{ + bar (__builtin_alloca_with_align_and_max (len, 8, 128)); +} + +void foo2 (size_t len) +{ + bar (__builtin_alloca_with_align_and_max (len, 8, 256)); /* { dg-warning "may be too large" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-16.c b/SingleSource/Regression/C/gcc-dg/Walloca-16.c new file mode 100644 index 0000000000..7e16caacbf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-16.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/84224 */ +/* { dg-do compile } */ +/* { dg-prune-output "conflicting types for built-in" } */ +/* { dg-options "-O0 -Walloca" } */ + +void *alloca (); +__typeof__(alloca ()) a () { return alloca (); } + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-2.c b/SingleSource/Regression/C/gcc-dg/Walloca-2.c new file mode 100644 index 0000000000..c81813e0da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-2.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=2000 -O2" } */ + +void f (void *); + +void +g1 (int n) +{ + void *p; + if (n > 0 && n < 2000) + p = __builtin_alloca (n); // { dg-bogus "unbounded use of 'alloca'" "" } + else + p = __builtin_malloc (n); + f (p); +} + +void +g2 (int n) +{ + void *p; + if (n < 2000) + p = __builtin_alloca (n); // { dg-warning "may be too large" } + else + p = __builtin_malloc (n); + f (p); +} + +void +g3 (int n) +{ + void *p; + if (n > 0 && n < 3000) + { + p = __builtin_alloca (n); // { dg-warning "may be too large" } + } + else + p = __builtin_malloc (n); + f (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-3.c b/SingleSource/Regression/C/gcc-dg/Walloca-3.c new file mode 100644 index 0000000000..b8000ff124 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-3.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=2000 -O2" } */ + +void f (void *); + +__SIZE_TYPE__ LIMIT; + +// Warn when there is an alloca bound, but it is an unknown bound. + +void +g1 (__SIZE_TYPE__ n) +{ + void *p; + if (n < LIMIT) + p = __builtin_alloca (n); // { dg-warning "may be too large" } + else + p = __builtin_malloc (n); + f (p); +} + +// Similar to the above, but do not get confused by the upcast. + +unsigned short SHORT_LIMIT; +void +g2 (unsigned short n) +{ + void *p; + if (n < SHORT_LIMIT) + p = __builtin_alloca (n); // { dg-warning "may be too large" } + else + p = __builtin_malloc (n); + f (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-4.c b/SingleSource/Regression/C/gcc-dg/Walloca-4.c new file mode 100644 index 0000000000..1fbed597b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=5000 -O2" } */ + + char * + _i18n_number_rewrite (char *w, char *rear_ptr) +{ + + char *src; + _Bool use_alloca = (((rear_ptr - w) * sizeof (char)) < 4096U); + if (use_alloca) + src = (char *) __builtin_alloca ((rear_ptr - w) * sizeof (char)); + else + src = (char *) __builtin_malloc ((rear_ptr - w) * sizeof (char)); + return src; +} + +/* { dg-prune-output "-Wreturn-local-addr" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-5.c b/SingleSource/Regression/C/gcc-dg/Walloca-5.c new file mode 100644 index 0000000000..73c72960c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-5.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=123 -O2" } */ +/* { dg-xfail-if "Currently broken but Andrew's work should fix this" { *-*-* } } */ + +/* The argument to alloca ends up having a range of 0..MAXINT(32bits), + so we think we have a range because of the upcast. Consequently, + we warn with "alloca may be too large", but we should technically + warn with "unbounded use of alloca". + + We currently drill through casts to figure this stuff out, but we + get confused because it's not just a cast. It's a cast, plus a + multiply. + + : + # RANGE [0, 4294967295] NONZERO 4294967295 + _1 = (long unsigned int) something_4(D); + # RANGE [0, 34359738360] NONZERO 34359738360 + _2 = _1 * 8; + _3 = __builtin_alloca (_2); + + I don't know whether it's even worth such fine-grained warnings. + Perhaps we should generically warn everywhere with "alloca may be + too large". + + I'm hoping that this particular case will be easier to diagnose with + Andrew's work. */ + +void useit(void *); +void foobar(unsigned int something) +{ + useit(__builtin_alloca (something * sizeof (const char *))); // { dg-warning "unbounded use of alloca" "" { xfail *-*-* } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-6.c b/SingleSource/Regression/C/gcc-dg/Walloca-6.c new file mode 100644 index 0000000000..ebe08aec83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-6.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=256 -O2" } */ + +void f (void*); +void g (__SIZE_TYPE__ n) +{ + // No warning on this case. Range is easily determinable. + if (n > 0 && n < 256) + f (__builtin_alloca (n)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-7.c b/SingleSource/Regression/C/gcc-dg/Walloca-7.c new file mode 100644 index 0000000000..11c38c18fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-7.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca -O0" } */ + +extern void f(void *); + +void foo(void) +{ + // Test that strict -Walloca works even without optimization. + f (__builtin_alloca(500)); // { dg-warning "use of 'alloca'" } +} + +void bar(void) +{ + // Test that we warn on alloca() calls, not just __builtin_alloca calls. + extern void *alloca(__SIZE_TYPE__); + f (alloca (123)); // { dg-warning "use of 'alloca'" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-8.c b/SingleSource/Regression/C/gcc-dg/Walloca-8.c new file mode 100644 index 0000000000..b64af09179 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-8.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=2000 -O2" } */ + +void *p; +void +foo (__SIZE_TYPE__ len) +{ + if (len < 2000 / sizeof (void *)) + p = __builtin_alloca (len * sizeof (void *)); + else + p = __builtin_malloc (len * sizeof (void *)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-9.c b/SingleSource/Regression/C/gcc-dg/Walloca-9.c new file mode 100644 index 0000000000..b82324a737 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-9.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca-larger-than=5000 -O2" } */ + +extern void useit(char *); + +int +foobar (unsigned short length) +{ + char *pbuf; + __SIZE_TYPE__ size = (__SIZE_TYPE__) length; + + if (size < 4032) + pbuf = (char *) __builtin_alloca(size); + else + pbuf = (char *) __builtin_malloc (size); + + useit(pbuf); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-2.c b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-2.c new file mode 100644 index 0000000000..88572d9452 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-2.c @@ -0,0 +1,25 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + Verify that alloca() calls in loops are not diagnosed by default. + { dg-do compile } + { dg-require-effective-target alloca } + { dg-options "-O2 -ftrack-macro-expansion=0" } */ + +extern void* alloca (__SIZE_TYPE__); + +void sink (void*); + +#define T(x) sink (x) + +void test_alloca (unsigned n) +{ + /* Verify that alloca(0) is not diagnosed in a loop either. */ + for (unsigned i = 0; i < n; ++i) + T (alloca (0)); + + /* Verify no warnings for the loops below. */ + for (unsigned i = 0; i < n; ++i) + T (alloca (1)); + + for (unsigned i = 1; i < n; ++i) + T (alloca (n)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-3.c b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-3.c new file mode 100644 index 0000000000..6f8ede04c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-3.c @@ -0,0 +1,38 @@ +/* PR middle-end/94004 - missing -Walloca on calls to alloca due + to -Wno-system-headers + { dg-do compile } + { dg-options "-O2 -Wall -Walloca-larger-than=8 -ftrack-macro-expansion=0" } + { dg-require-effective-target alloca } */ + +#include "Walloca-larger-than-3.h" + +void sink (void*, ...); + +void call_builtin_alloca (int n) +{ + if (n < 9) + n = 9; + void *p = __builtin_alloca (n); // { dg-warning "\\\[-Walloca-larger-than" } + sink (p, 0); +} + +void call_alloca_sys_hdr (int n) +{ + if (n < 9) + n = 9; + void *p = alloca (n); // { dg-warning "\\\[-Walloca-larger-than" } + sink (p, 1); +} + +static inline void inline_call_alloca (int n) +{ + if (n > 9) + n = 9; + void *p = alloca (n); // { dg-warning "\\\[-Walloca-larger-than" } + sink (p, 2); +} + +void make_inlined_call (void) +{ + inline_call_alloca (10); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-3.h b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-3.h new file mode 100644 index 0000000000..ca5a84cff4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-3.h @@ -0,0 +1,9 @@ +#if __has_include () +# include +#endif + +#ifndef alloca + /* Simulate a definition in a system header. */ +# pragma GCC system_header +# define alloca(n) __builtin_alloca (n) +#endif diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-4.c b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-4.c new file mode 100644 index 0000000000..aac8b9732f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than-4.c @@ -0,0 +1,19 @@ +/* PR middle-end/100425 - missing -Walloca-larger-than with -O0 + { dg-do compile } + { dg-options "-O0 -Wall -Walloca-larger-than=128" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +void* alloca (size_t); + +void sink (void*); + +void warn_alloca_too_large (void) +{ + sink (alloca (1)); + sink (alloca (128)); + sink (alloca (129)); // { dg-warning "\\\[-Walloca-larger-than" } + sink (alloca (128 + 2)); // { dg-warning "\\\[-Walloca-larger-than" } + sink (alloca (1024)); // { dg-warning "\\\[-Walloca-larger-than" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Walloca-larger-than.c b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than.c new file mode 100644 index 0000000000..32ee15ff9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walloca-larger-than.c @@ -0,0 +1,27 @@ +/* PR middle-end/82063 - issues with arguments enabled by -Wall + { dg-do compile } + { dg-require-effective-target alloca } + { dg-options "-O2 -Walloca-larger-than=0 -Wvla-larger-than=0 -ftrack-macro-expansion=0" } */ + +extern void* alloca (__SIZE_TYPE__); + +void sink (void*); + +#define T(x) sink (x) + +void test_alloca (void) +{ + /* Verify that alloca(0) is diagnosed even if the limit is zero. */ + T (alloca (0)); /* { dg-warning "argument to .alloca. is zero" } */ + T (alloca (1)); /* { dg-warning "argument to .alloca. is too large" } */ +} + +void test_vla (unsigned n) +{ + /* VLAs smaller than 32 bytes are optimized into ordinary arrays. */ + if (n < 1 || 99 < n) + n = 1; + + char a[n]; /* { dg-warning "argument to variable-length array " } */ + T (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walways-true-1.c b/SingleSource/Regression/C/gcc-dg/Walways-true-1.c new file mode 100644 index 0000000000..4aa5d39abb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walways-true-1.c @@ -0,0 +1,57 @@ +/* Test -Waddress for testing an address against NULL. + Origin: Ian Lance Taylor . */ + +/* { dg-do compile } */ +/* { dg-options "-Waddress -fshow-column" } */ + +extern int foo (int); + +int i; + +void +bar (int a) +{ + lab: + if (foo) /* { dg-warning "7:always evaluate as" "correct warning" } */ + foo (0); + if (foo (1)) + ; + if (&i) /* { dg-warning "7:always evaluate as" "correct warning" } */ + foo (2); + if (i) + foo (3); + if (&a) /* { dg-warning "7:always evaluate as" "correct warning" } */ + foo (4); + if (a) + foo (5); + if (&&lab) /* { dg-warning "7:always evaluate as" "correct warning" } */ + foo (6); + if (foo == 0) /* { dg-warning "11:the comparison will always evaluate as 'false'" "correct warning" } */ + foo (7); + if (foo (1) == 0) + foo (8); + if (&i == 0) /* { dg-warning "10:the comparison will always evaluate as 'false'" "correct warning" } */ + foo (9); + if (i == 0) + foo (10); + if (&a == 0) /* { dg-warning "10:the comparison will always evaluate as 'false'" "correct warning" } */ + foo (11); + if (a == 0) + foo (12); + if (&&lab == 0) /* { dg-warning "13:the comparison will always evaluate as 'false'" "correct warning" } */ + foo (13); + if (0 == foo) /* { dg-warning "9:the comparison will always evaluate as 'false'" "correct warning" } */ + foo (14); + if (0 == foo (1)) + foo (15); + if (0 == &i) /* { dg-warning "9:the comparison will always evaluate as 'false'" "correct warning" } */ + foo (16); + if (0 == i) + foo (17); + if (0 == &a) /* { dg-warning "9:the comparison will always evaluate as 'false'" "correct warning" } */ + foo (18); + if (0 == a) + foo (19); + if (0 == &&lab) /* { dg-warning "9:the comparison will always evaluate as 'false'" "correct warning" } */ + foo (20); +} diff --git a/SingleSource/Regression/C/gcc-dg/Walways-true-2.c b/SingleSource/Regression/C/gcc-dg/Walways-true-2.c new file mode 100644 index 0000000000..ae3262b687 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Walways-true-2.c @@ -0,0 +1,60 @@ +/* Make sure we don't assume that a weak symbol is always non-NULL. + This is just like Walways-true-1.C, except that it uses a weak + symbol. + Origin: Ian Lance Taylor . */ + +/* { dg-do compile } */ +/* { dg-options "-Waddress" } */ +/* { dg-require-weak "" } */ + +extern int foo (int) __attribute__ ((weak)); + +extern int i __attribute__ ((weak)); + +void +bar (int a) +{ + lab: + if (foo) + foo (0); + if (foo (1)) + ; + if (&i) + foo (2); + if (i) + foo (3); + if (&a) /* { dg-warning "always evaluate as" "correct warning" } */ + foo (4); + if (a) + foo (5); + if (&&lab) /* { dg-warning "always evaluate as" "correct warning" } */ + foo (6); + if (foo == 0) + foo (7); + if (foo (1) == 0) + foo (8); + if (&i == 0) + foo (9); + if (i == 0) + foo (10); + if (&a == 0) /* { dg-warning "the comparison will always evaluate as 'false'" "correct warning" } */ + foo (11); + if (a == 0) + foo (12); + if (&&lab == 0) /* { dg-warning "the comparison will always evaluate as 'false'" "correct warning" } */ + foo (13); + if (0 == foo) + foo (14); + if (0 == foo (1)) + foo (15); + if (0 == &i) + foo (16); + if (0 == i) + foo (17); + if (0 == &a) /* { dg-warning "the comparison will always evaluate as 'false'" "correct warning" } */ + foo (18); + if (0 == a) + foo (19); + if (0 == &&lab) /* { dg-warning "the comparison will always evaluate as 'false'" "correct warning" } */ + foo (20); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-10.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-10.c new file mode 100644 index 0000000000..5fd6e6f1a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-10.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ + +int f(unsigned len, int buflen) +{ + unsigned taillen; + unsigned slen; + unsigned i; + int b[17]; /* needed <= 17 to trigger Warning */ + int j = 0; /* needed to trigger Warning */ + + b[0] = 0; + taillen= buflen & 7; /* taillen [0..7] */ + + if(taillen) { /* taillen [1..7] */ + slen= 8 - taillen; /* slen [7..1] */ + if (lenj[4] = 1; // flexible array member + h0->j[4] = 1; // zero-sized array extension + h1->j[4] = 1; /* { dg-bogus "subscript 4 is above array bound" } */ + h3->j[4] = 1; /* { dg-warning "subscript 4 is above array bound" } */ + + struct h0b* h0b = malloc(sizeof(struct h) + 3 * sizeof(int)); + struct h1b* h1b = malloc(sizeof(struct h1b) + 3 * sizeof(int)); + struct h3b* h3b = malloc(sizeof(struct h3b)); +// h0b->j[4] = 1; + h1b->j[4] = 1;; /* { dg-warning "subscript 4 is above array bound" } */ + h3b->j[4] = 1;; /* { dg-warning "subscript 4 is above array bound" } */ + + // make sure nothing gets optimized away + bar(*a); + bar(c); + bar(e); + bar(f.f); + bar(h1->j); + bar(h3->j); + bar(h3b->j); + bar(h1b->j); + bar(h->j); + bar(h0->j); +} + diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-12.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-12.c new file mode 100644 index 0000000000..ef26c6596b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-12.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ +/* { dg-additional-options "-mssse3" { target x86_64-*-* i?86-*-* } } */ + +void foo(short a[], short m) +{ + int i, j; + int f1[10]; + short nc; + + nc = m + 1; + if (nc > 3) + { + for (i = 0; i <= nc; i++) + { + f1[i] = f1[i] + 1; + } + } + + for (i = 0, j = m; i < nc; i++, j--) + { + a[i] = f1[i]; /* { dg-bogus "above array bounds" } */ + a[j] = i; + } + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-13.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-13.c new file mode 100644 index 0000000000..7b40a83887 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-13.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ + +extern char *bar[17]; + +int foo(int argc, char **argv) +{ + int i; + int n = 0; + + for (i = 0; i < argc; i++) + n++; + + for (i = 0; i < argc; i++) + argv[i] = bar[i + n]; /* { dg-bogus "above array bounds" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-14.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-14.c new file mode 100644 index 0000000000..f3a33f9c7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-14.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +int a[10]; +int foo1 (int i) +{ + if (i < 0 || i > 9) + return a[i]; /* { dg-warning "outside array bounds" } */ + return 0; +} +int foo2 (int i) +{ + if (i < 0 || i > 8) + return a[i]; /* { dg-bogus "outside array bounds" } */ + return 0; +} +int *foo3 (int i) +{ + if (i < 0 || i > 10) + return &a[i]; /* { dg-warning "outside array bounds" } */ + return (void *)0; +} +int *foo4 (int i) +{ + if (i < 0 || i > 9) + return &a[i]; /* { dg-bogus "outside array bounds" } */ + return (void *)0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-15.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-15.c new file mode 100644 index 0000000000..f50e5ee7cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-15.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +int a[10]; +int *foo1 (int i) +{ + return &a[10]; /* { dg-bogus "above array bounds" } */ +} +int *foo2 (int i) +{ + return &a[11]; /* { dg-warning "above array bounds" } */ +} +int foo3 (int i) +{ + return a[9]; /* { dg-bogus "above array bounds" } */ +} +int foo4 (int i) +{ + return a[10]; /* { dg-warning "above array bounds" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-16.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-16.c new file mode 100644 index 0000000000..20008f6fee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-16.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ + +typedef struct foo { + unsigned char foo_size; + int buf[4]; + const char* bar; +} foo; + +const foo *get_foo(int index); + +static int foo_loop(const foo *myfoo) { + int i; + if (myfoo->foo_size < 3) + return 0; + for (i = 0; i < myfoo->foo_size; i++) { + if (myfoo->buf[i] != 1) /* { dg-bogus "above array bounds" } */ + return 0; + } + + return 1; +} + +static int run_foo(void) { + int i; + for (i = 0; i < 1; i++) { + const foo *myfoo = get_foo(i); + if (foo_loop(myfoo)) + return 0; + } + return -1; +} + +typedef struct hack { + int (*func)(void); +} hack; + +hack myhack = { + .func = run_foo, +}; diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-17.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-17.c new file mode 100644 index 0000000000..e790037feb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-17.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +char *y; +void foo (int sysnum) +{ + static char *x[] = {}; + int nsyscalls = sizeof x / sizeof x[0]; + if (sysnum < 0 || sysnum >= nsyscalls) + return; + else + y = x[sysnum]; /* { dg-bogus "above array bounds" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-18.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-18.c new file mode 100644 index 0000000000..092363aea3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-18.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds -Wno-stringop-overflow" } */ + +typedef struct +{ + int len; + char data[1]; +} rec; + +int +p(rec *r, int len); + +int +f (char prm1, char prm2) +{ + char buf[10]; + + rec *r1 = (rec *)&buf; + + r1->len = 10; + r1->data[0] = prm1; + r1->data[1] = prm2; /* { dg-bogus "above array bounds" } */ + + return p(r1, r1->len); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-19.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-19.c new file mode 100644 index 0000000000..e2f9661cde --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-19.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/59124 */ +/* { dg-options "-O3 -Warray-bounds" } */ + +unsigned baz[6]; + +void foo(unsigned *bar, unsigned n) +{ + unsigned i, j; + + if (n > 6) + n = 6; + + for (i = 1; i < n; i++) + for (j = i - 1; j > 0; j--) + bar[j - 1] = baz[j - 1]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-2.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-2.c new file mode 100644 index 0000000000..796483e0e4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* Test that -Warray-bounds is enabled by -Wall */ +/* { dg-options "-O2 -Wall" } */ + +int a[10]; + +int* f(void) { + + a[-1] = 0; /* { dg-warning "array subscript" } */ + + return a; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-20.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-20.c new file mode 100644 index 0000000000..727b7997ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-20.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +int t[1]; +int fct (int r, long e) +{ + int d = 0; + if (r == 4) + r = 1; + if (e < -52) + d = r == 0 ? 1 : 2; + else + { + int i, n = 53; + if (__builtin_expect (e < 0, 0)) + n += e; + for (i = 1 ; i < n / 64 + 1 ; i++) + t[i] = 0; /* { dg-bogus "array bounds" } */ + } + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-21.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-21.c new file mode 100644 index 0000000000..759944fc00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-21.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +int t[1]; +int a (void); +int fct (int r, long e, int neg) +{ + int d = 0; + if (r == 4) + r = neg ? 3 : 2; + if (__builtin_expect(e < -52, 0)) + d = r == 0 && a () ? 1 : 2; + else + { + int i, n = 53; + if (e < 0) + n += e; + for (i = 1 ; i < n / 64 + 1 ; i++) + d = t[i]; /* { dg-bogus "array bounds" } */ + } + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-22.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-22.c new file mode 100644 index 0000000000..8165140ef4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-22.c @@ -0,0 +1,96 @@ +/* PR tree-optimization/82588 - missing -Warray-bounds on an excessively + large index + { dg-do compile } + { dg-require-effective-target alloca } + { dg-options "-O2 -Warray-bounds -ftrack-macro-expansion=0" } */ + +#define SIZE_MAX __SIZE_MAX__ +#define DIFF_MAX __PTRDIFF_MAX__ +#define DIFF_MIN (-DIFF_MAX - 1) + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +static ptrdiff_t signed_value (void) +{ + extern volatile ptrdiff_t signed_value_source; + return signed_value_source; +} + +static ptrdiff_t signed_range (ptrdiff_t min, ptrdiff_t max) +{ + ptrdiff_t val = signed_value (); + return val < min || max < val ? min : val; +} + +typedef struct AX { int n; char ax[]; } AX; + +typedef struct A1 { int i; char a1[1]; } A1; +typedef struct B { int i; struct A1 a1x[]; } B; + +void sink (int, ...); + +#define T(expr) sink (0, (expr)) + +void test_vla (unsigned m, unsigned n) +{ + char vla1[m]; + + T (vla1[DIFF_MIN]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds" "vla" } */ + T (vla1[-1]); /* { dg-warning "array subscript -1 is below array bounds" "vla" } */ + T (vla1[0]); + T (vla1[1]); + T (vla1[m - 1]); + /* It would be nice to diagnose this. */ + T (vla1[m]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "bug 82608" { xfail *-*-*} } */ + T (vla1[DIFF_MAX - 1]); + T (vla1[DIFF_MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "vla" } */ + + ptrdiff_t i = signed_range (DIFF_MAX - 1, DIFF_MAX); + T (vla1[i]); + + char vla2[m][n]; + + T (vla2[0][DIFF_MIN]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds" "vla" } */ + T (vla2[0][-1]); /* { dg-warning "array subscript -1 is below array bounds" "vla" } */ + T (vla2[0][0]); + T (vla2[1][1]); + T (vla2[m - 1][n - 1]); + /* It would be nice to diagnose this. */ + T (vla2[m][0]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "bug 82608" { xfail *-*-*} } */ + T (vla2[m + 1][0]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "bug 82608" { xfail *-*-*} } */ + T (vla2[0][n]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "bug 82608" { xfail *-*-*} } */ + T (vla2[0][n + 1]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "bug 82608" { xfail *-*-*} } */ + T (vla2[m][n]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "bug 82608" { xfail *-*-*} } */ + T (vla2[m + 1][n + 1]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "bug 82608" { xfail *-*-*} } */ + + T (vla2[0][DIFF_MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "vla" } */ + T (vla2[DIFF_MAX][0]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "vla" { xfail *-*-* } } */ + T (vla2[DIFF_MAX][DIFF_MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "vla" } */ + + struct S256 { char a[256]; } vla3[m]; + + T (vla3[DIFF_MIN].a[0]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds" "vla" } */ + T (vla3[-1].a[0]); /* { dg-warning "array subscript -1 is below array bounds" "vla" } */ + T (vla3[0].a[0]); + T (vla3[1].a[0]); + T (vla3[m - 1].a[0]); + T (vla3[DIFF_MAX / 256 - 1].a[0]); + T (vla3[DIFF_MAX / 256].a[0]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "vla" } */ + + i = signed_range (DIFF_MAX / 256 - 1, DIFF_MAX); + T (vla3[i].a[0]); + + i = signed_range (DIFF_MAX / 256, DIFF_MAX); + T (vla3[i].a[0]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "vla" } */ + + struct VLA { char vla[n]; } x; + + T (x.vla[DIFF_MIN]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds" "vla" } */ + T (x.vla[-1]); /* { dg-warning "array subscript -1 is below array bounds" "vla" } */ + T (x.vla[0]); + T (x.vla[1]); + T (x.vla[n - 1]); + T (x.vla[DIFF_MAX - 1]); + T (x.vla[DIFF_MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds" "vla" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-23.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-23.c new file mode 100644 index 0000000000..2addc35831 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-23.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +int main() +{ + unsigned i, j, a[10] = {0}; + + for (j = 23; j < 25; j++){ + for (i = j / 8; i --> 0;) a[i] = 0; /* { dg-bogus "array bounds" } */ + for (i = 1; i --> 0;) __builtin_printf("%u", a[i]); + } + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-24.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-24.c new file mode 100644 index 0000000000..3563173764 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-24.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ + +int foo(unsigned order) +{ + int c[3] = {1, 2, 3}; + unsigned i, j; + for (i = 1; i < order; i++) { + for (j = 0; j < i / 2; j++) { + c[j] += c[i] * c[i-j-1]; /* { dg-bogus "array bounds" } */ + c[i-j-1] += c[i] * c[j]; /* { dg-bogus "array bounds" } */ + } + } + return c[0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-25.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-25.c new file mode 100644 index 0000000000..37fb9ccf4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-25.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/83446 - Bootstrap failed on i686 + { dg-do compile } + { dg-options "-O2 -Warray-bounds" } */ + +char a[4]; + +void f0i (void *d, int n) +{ + if (n < 0) n = 0; + + __builtin_memcpy (d, a + sizeof a - n, n); +} + +void f0L (void *d, long n) +{ + if (n < 0) n = 0; + + __builtin_memcpy (d, a + sizeof a - n, n); +} + +void f0u (void *d, unsigned n) +{ + if (n < 0) n = 1; + + __builtin_memcpy (d, a + sizeof a - n, n); /* { dg-bogus "\\\[-Warray-bounds" } */ +} + +void f1lu (void *d, unsigned long n) +{ + if (n < 1) n = 1; + + __builtin_memcpy (d, a + sizeof a - n, n); /* { dg-bogus "\\\[-Warray-bounds" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-26.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-26.c new file mode 100644 index 0000000000..85bdb3ea14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-26.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +struct Rec { + unsigned char data[1]; // actually variable length +}; + +union U { + unsigned char buf[42]; + struct Rec rec; +}; + +int Load() +{ + union U u; + return u.rec.data[1]; /* { dg-bogus "array bound" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-27.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-27.c new file mode 100644 index 0000000000..98c9439bbf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-27.c @@ -0,0 +1,35 @@ +/* { dg-do compile } + { dg-options "-O2 -Wall -Wextra -Warray-bounds -Wrestrict" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void* restrict, const void* restrict, size_t); + +extern void sink (void*, ...); + +struct Data { + size_t n; + void *p; +}; + +void test_copy (void) +{ + struct Data d; + sink (&d); + + char dp1[sizeof d + 1]; + char d2x[2 * sizeof d]; + char d2xp1[2 * sizeof d + 1]; + + /* During development the following would incorrectly trigger: + warning: 'memcpy' forming offset [17, 25] is out of the bounds [0, 16] + of object ‘d’ with type 'struct Data' [-Warray-bounds] + that wasn't caught by the test suite. Make sure it is. */ + memcpy (&dp1, d.p, sizeof dp1); /* { dg-bogus "\\\[-Warray-bounds" } */ + + /* Likewise. */ + memcpy (&d2x, d.p, sizeof d2x); /* { dg-bogus "\\\[-Warray-bounds" } */ + memcpy (&d2xp1, d.p, sizeof d2xp1); /* { dg-bogus "\\\[-Warray-bounds" } */ + + sink (&d, &dp1, &d2x, &d2xp1); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-28.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-28.c new file mode 100644 index 0000000000..c63c70ad38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-28.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/48560 - -Warray-bounds fails to detect the out of + bound array access + { dg-do compile } + { dg-options "-O2 -Warray-bounds" } */ + +char foo1 (int i) +{ + static char s[] = "foo"; + switch (i) + { + case 30: + return s[30]; /* { dg-warning "array subscript 30 is above array bounds" } */ + } + return s[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-29.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-29.c new file mode 100644 index 0000000000..44e5bd3612 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-29.c @@ -0,0 +1,150 @@ +/* PR tree-optimization/83776: missing -Warray-bounds indexing past the end + of a string literal + Test to exercise warnings for computations of otherwise in-bounds indices + into strings that temporarily exceed the bounds of the string. + { dg-do compile } + { dg-options "-O2 -Warray-bounds=2 -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define MAX DIFF_MAX +#define MIN DIFF_MIN + +typedef __WCHAR_TYPE__ wchar_t; + +void sink (int, ...); + +#define T(expr) sink (0, expr) + +void test_narrow (void) +{ + int i = SR (1, 2); + + const char *p0 = "12"; + const char *p1 = p0 + i; /* points at '2' or beyond */ + const char *p2 = p1 + i; /* points at '\0' or beyond */ + const char *p3 = p2 + i; /* points just past the end */ + const char *p4 = p3 + i; /* invalid */ + + T (p0[-1]); /* { dg-warning "array subscript \(-1|\[0-9\]+) is outside array bounds of .char\\\[3]." } */ + T (p0[0]); + T (p0[1]); + T (p0[2]); + T (p0[3]); /* { dg-warning "array subscript 3 is outside array bounds of .char\\\[3]." } */ + + T (&p0[-1]); /* { dg-warning "array subscript \(-1|\[0-9\]+) is \(above|below|outside\) array bounds of .char\\\[3]." } */ + T (&p0[0]); + T (&p0[1]); + T (&p0[2]); + T (&p0[3]); + T (&p0[4]); /* { dg-warning "array subscript 4 is \(above|outside\) array bounds of .char\\\[3]." } */ + + T (p1[-3]); /* { dg-warning "array subscript \\\[-2, -1] is outside array bounds of .char\\\[3]." } */ + T (p1[-2]); + T (p1[-1]); + T (p1[ 0]); + T (p1[ 1]); + T (p1[ 2]); /* { dg-warning "array subscript 3 is outside array bounds of .char\\\[3]." } */ + T (p1[ 3]); /* { dg-warning "array subscript \\\[4, 5] is outside array bounds of .char\\\[3]." } */ + + T (&p1[-3]); /* { dg-warning "array subscript \\\[-2, -1] is outside array bounds of .char\\\[3]." "bug" { xfail *-*-* } } */ + T (&p1[-2]); + T (&p1[-1]); + T (&p1[ 0]); + T (&p1[ 1]); + T (&p1[ 2]); + T (&p1[ 3]); /* { dg-warning "array subscript \\\[4, 6] is outside array bounds of .char\\\[3]." "bug" { xfail *-*-* } } */ + + T (p2[-4]); /* { dg-warning "subscript \\\[-2, -1\\\] is outside array bounds of .char\\\[3]." } */ + T (p2[-3]); + T (p2[-2]); + T (p2[-1]); + T (p2[ 0]); + + /* Even though the lower bound of p3's offsets is in bounds, in order + to subtract 4 from p3 and get a dereferenceable pointer its value + would have to be out-of-bounds. */ + T (p3[-4]); /* { dg-warning "array subscript -1 is outside array bounds of .char\\\[3]." } */ + T (p3[-3]); + T (p3[-2]); + T (p3[-1]); + T (p3[ 0]); /* { dg-warning "array subscript 3 is outside array bounds of .char\\\[3]." } */ + + T (p4[-4]); /* { dg-warning "intermediate array offset 4 is outside array bounds of .char\\\[3]." } */ + T (p4[-3]); /* { dg-warning "intermediate array offset 4 is outside array bounds of .char\\\[3]." } */ + T (p4[-2]); /* { dg-warning "intermediate array offset 4 is outside array bounds of .char\\\[3]." } */ + + /* The final subscripts below are invalid. */ + T (p4[-1]); /* { dg-warning "array subscript 3 is outside array bounds of .char\\\[3]." } */ + T (p4[ 0]); /* { dg-warning "array subscript \\\[4, 5] is outside array bounds of .char\\\[3]." } */ +} + + +void test_narrow_vflow (void) +{ + int i = SR (DIFF_MAX - 2, DIFF_MAX); + int j = SR (1, DIFF_MAX); + + const char *p0 = "123"; + const char *p1 = p0 + i; /* points at '2' or beyond */ + const char *p2 = p1 + i; /* points at '\0' or beyond */ + const char *p3 = p2 + i; /* points just past the end */ + const char *p4 = p3 + i; /* invalid */ +} + + +void test_wide (void) +{ + int i = SR (1, 2); + + const wchar_t *p0 = L"123"; + const wchar_t *p1 = p0 + i; /* points at L'2' or beyond */ + const wchar_t *p2 = p1 + i; /* points at L'3' or beyond */ + const wchar_t *p3 = p2 + i; /* points at L'\0' or beyond */ + const wchar_t *p4 = p3 + i; /* points just past the end */ + const wchar_t *p5 = p4 + i; /* invalid */ + + T (p0[0]); + T (p0[1]); + T (p0[2]); + T (p0[3]); + T (p0[4]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */ + + T (p1[-1]); + T (p1[ 0]); + T (p1[ 1]); + T (p1[ 2]); + T (p1[ 3]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */ + + T (&p1[-1]); + T (&p1[ 0]); + T (&p1[ 1]); + T (&p1[ 2]); + T (&p1[ 3]); + T (&p1[ 4]); /* { dg-warning "array subscript \\\[5, 6] is outside array bounds of .\[a-z \]+\\\[4]." "bug" { xfail *-*-* } } */ + + T (p2[-5]); /* { dg-warning "array subscript \\\[-3, -1] is outside array bounds of .\[a-z \]+\\\[4]." } */ + T (p2[-4]); + T (p2[-3]); + T (p2[-2]); + T (p2[-1]); + T (p2[ 0]); + + /* Even though the lower bound of p3's offsets is in bounds, in order + to subtract 5 from p3 and get a dereferenceable pointer its value + would have to be out-of-bounds. */ + T (p3[-5]); /* { dg-warning "array subscript \\\[-2, -1\\\] is outside array bounds of .\[a-z \]+\\\[4]." } */ + T (p3[-4]); + T (p3[-3]); + T (p3[-2]); + T (p3[-1]); + T (p3[ 0]); + T (p3[ 1]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */ + + T (p4[-5]); /* { dg-warning "array subscript -1 is outside array bounds of .\[a-z \]+\\\[4]." } */ + T (p4[-4]); + T (p4[-3]); + T (p4[-2]); + T (p4[-1]); + T (p4[ 0]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-3.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-3.c new file mode 100644 index 0000000000..f119502f02 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-3.c @@ -0,0 +1,109 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ +/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ +/* based on PR 31227 */ + +typedef __SIZE_TYPE__ size_t; + +extern size_t strlen (const char *); + +struct iovec +{ + void *iov_base; + size_t iov_len; +}; + +struct S +{ + const char *abday[7]; + const char *day[7]; + const char *abmon[12]; + const char *mon[12]; + const char *am_pm[2]; +}; + +extern void foo (size_t, struct iovec *); + +void +bar (struct S *time) +{ + struct iovec iov[43]; + size_t cnt; + iov[0].iov_base = (void *) "abc"; + iov[0].iov_len = 3; + + iov[1].iov_base = (void *) "def"; + iov[1].iov_len = 3; + + for (cnt = 0; cnt < 7; ++cnt) + { + iov[2 + cnt].iov_base = (void *) (time->abday[cnt] ?: ""); + iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1; + } + + for (; cnt < 14; ++cnt) + { + iov[2 + cnt].iov_base = (void *) (time->day[cnt - 7] ?: ""); + iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1; + } + + for (; cnt < 26; ++cnt) + { + iov[2 + cnt].iov_base = (void *) (time->abmon[cnt - 14] ?: ""); + iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1; + } + + for (; cnt < 38; ++cnt) + { + iov[2 + cnt].iov_base = (void *) (time->mon[cnt - 26] ?: ""); + iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1; + } + + for (; cnt < 40; ++cnt) + { + iov[2 + cnt].iov_base = (void *) (time->am_pm[cnt - 38] ?: ""); + iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1; + } + + foo (2 + cnt, iov); +} + +struct malloc_chunk { + long prev_size; + long size; + struct malloc_chunk* fd; + struct malloc_chunk* bk; +}; +typedef struct malloc_chunk* mchunkptr; +struct malloc_state { + mchunkptr top; + mchunkptr last_remainder; + mchunkptr bins[128 * 2 - 2]; +}; +#define bin_at(m, i) \ + (mchunkptr) (((char *) &((m)->bins[((i) - 1) * 2])) \ + - __builtin_offsetof (struct malloc_chunk, fd)) + +void malloc_init_state(struct malloc_state *av) +{ + int i; + mchunkptr bin; + + for (i = 1; i < 128; ++i) { + bin = bin_at(av,i); + bin->fd = bin->bk = bin; + } +} + +typedef unsigned short WCHAR; +typedef WCHAR *LPWSTR; + +static void g(LPWSTR dest, int len) { + dest[len-1] = 0; +} + +void f() { + WCHAR szPathW[260]; + + g(szPathW, 260); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-30.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-30.c new file mode 100644 index 0000000000..b837ad0c36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-30.c @@ -0,0 +1,200 @@ +/* PR tree-optimization/84047 - missing -Warray-bounds on an out-of-bounds + index into an array + { dg-do compile } + { dg-options "-O2 -Warray-bounds=2 -ftrack-macro-expansion=0" } + { dg-skip-if "too many arguments in function call" { bpf-*-* } } */ + +#include "range.h" + +#define MAX DIFF_MAX +#define MIN DIFF_MIN + +void sink (int, ...); + +#define T(...) sink (0, __VA_ARGS__) + +void test_global_char_array (void) +{ + extern char gcar1[1]; + char *p = gcar1; + + T (p[MIN]); /* { dg-warning "subscript -\[0-9\]+ is outside array bounds of .char\\\[1]." } */ + T (p[-1]); /* { dg-warning "subscript -1 is outside array bounds of .char\\\[1]." } */ + T (p[0]); + T (p[1]); /* { dg-warning "subscript 1 is outside array bounds of .char\\\[1]." } */ + T (p[MAX]); /* { dg-warning "subscript \[0-9\]+ is outside array bounds of .char\\\[1]." } */ + + T (&p[MIN]); /* { dg-warning "subscript -\[0-9\]+ is \(below|outside\) array bounds of .char\\\[1]." } */ + T (&p[-1]); /* { dg-warning "subscript -1 is \(below|outside\) array bounds of .char\\\[1]." } */ + T (&p[0]); + T (&p[1]); + T (&p[2]); /* { dg-warning "subscript 2 is \(above|outside\) array bounds of .char\\\[1]." } */ + T (&p[MAX]); /* { dg-warning "subscript \[0-9\]+ is \(above|outside\) array bounds of .char\\\[1]." } */ + + extern char gcar3[3]; + char *q = gcar3; + + T (q[MIN]); /* { dg-warning "subscript -\[0-9\]+ is outside array bounds of .char\\\[3]." } */ + T (q[-1]); /* { dg-warning "subscript -1 is outside array bounds of .char\\\[3]." } */ + T (q[0]); + T (q[1]); + T (q[2]); + T (q[3]); /* { dg-warning "subscript 3 is outside array bounds of .char\\\[3]." } */ + T (q[MAX]); /* { dg-warning "subscript \[0-9\]+ is outside array bounds of .char\\\[3]." } */ + + T (&q[MIN]); /* { dg-warning "subscript -\[0-9\]+ is \(below|outside\) array bounds of .char\\\[3]." } */ + T (&q[-1]); /* { dg-warning "subscript -1 is \(below|outside\) array bounds of .char\\\[3]." } */ + T (&q[0]); + T (&q[1]); + T (&q[2]); + T (&q[3]); + T (&q[4]); /* { dg-warning "subscript 4 is \(above|outside\) array bounds of .char\\\[3]." } */ + T (&q[MAX]); /* { dg-warning "subscript \[0-9\]+ is \(above|outside\) array bounds of .char\\\[3]." } */ +} + + +void test_global_int_array (void) +{ + /* Use smaller values to prevent false negatives due to undetected + integer overflow/wrapping. */ + ptrdiff_t min = MIN / sizeof (int); + ptrdiff_t max = MAX / sizeof (int); + + extern int giar1[1]; + extern int giar3[3]; + + int *p = giar1; + + T (p[min]); /* { dg-warning "subscript -\[0-9\]+ is outside array bounds of .int\\\[1]." } */ + T (p[-1]); /* { dg-warning "subscript -1 is outside array bounds of .int\\\[1]." } */ + T (p[0]); + T (p[1]); /* { dg-warning "subscript 1 is outside array bounds of .int\\\[1]." } */ + T (p[max]); /* { dg-warning "subscript \[0-9\]+ is outside array bounds of .int\\\[1]." } */ + + T (&p[min]); /* { dg-warning "subscript -\[0-9\]+ is \(below|outside\) array bounds of .int\\\[1]." } */ + T (&p[-1]); /* { dg-warning "subscript -1 is \(below|outside\) array bounds of .int\\\[1]." } */ + T (&p[0], &p[1]); + T (&p[2]); /* { dg-warning "subscript 2 is \(above|outside\) array bounds of .int\\\[1]." } */ + T (&p[max]); /* { dg-warning "subscript \[0-9\]+ is \(above|outside\) array bounds of .int\\\[1]." } */ + + int *q = giar3; + + T (q[min]); /* { dg-warning "subscript -\[0-9\]+ is outside array bounds of .int\\\[3]." } */ + T (q[-1]); /* { dg-warning "subscript -1 is outside array bounds of .int\\\[3]." } */ + T (q[0]); + T (q[1]); + T (q[2]); + T (q[3]); /* { dg-warning "subscript 3 is outside array bounds of .int\\\[3]." } */ + T (q[max]); /* { dg-warning "subscript \[0-9\]+ is outside array bounds of .int\\\[3]." } */ + + T (&q[min]); /* { dg-warning "subscript -\[0-9\]+ is \(below|outside\) array bounds of .int\\\[3]." } */ + T (&q[-1]); /* { dg-warning "subscript -1 is \(below|outside\) array bounds of .int\\\[3]." } */ + T (&q[0]); + T (&q[1]); + T (&q[2]); + T (&q[3]); + T (&q[4]); /* { dg-warning "subscript 4 is \(above|outside\) array bounds of .int\\\[3]." } */ + T (&q[max]); /* { dg-warning "subscript \[0-9\]+ is \(above|outside\) array bounds of .int\\\[3]." } */ +} + + +void test_global_short_2dim_array (void) +{ + extern short giar3_5[3][5]; + + short *p = giar3_5[0]; + + /* The access below isn't diagnosed because the reference is transformed + into MEM_REF (short*, &giar3_5, 0), i.e., *giar3_5[0][0]. */ + T (p[MIN]); /* { dg-warning "subscript -\[0-9\]+ is outside array bounds of .short int\\\[3]" "bug" { xfail *-*-*} } */ + T (p[-1]); /* { dg-warning "subscript -1 is outside array bounds of .short int\\\[3]" } */ + T (p[0]); + T (p[1]); + T (p[2]); + T (p[15]); /* { dg-warning "subscript 15 is outside array bounds of .short int\\\[3]" } */ + T (p[MAX]); /* { dg-warning "subscript -?\[0-9\]+ is outside array bounds of .short int\\\[3]" } */ + + T (&p[MIN]); /* { dg-warning "subscript -\[0-9\]+ is \(below|outside\) array bounds of .short int\\\[3]" "bug" { xfail *-*-* } } */ + T (&p[-1]); /* { dg-warning "subscript -1 is \(below|outside\) array bounds of .short int\\\[3]" } */ + T (&p[0]); + T (&p[1]); + T (&p[2]); + T (&p[3]); + T (&p[16]); /* { dg-warning "subscript 16 is \(above|outside\) array bounds of .short int\\\[3]" "pr??????" { xfail *-*-* } } */ + T (&p[MAX]); /* { dg-warning "subscript -?\[0-9\]+ is \(above|outside\) array bounds of .short int\\\[3]" } */ +} + + +void test_local_char_array (void) +{ + char ar1[1] = { 1 }; + char *p = ar1; + + T (p[MIN]); /* { dg-warning "subscript -\[0-9\]+ is outside array bounds of .char\\\[1]." } */ + T (p[-1]); /* { dg-warning "subscript -1 is outside array bounds of .char\\\[1]." } */ + T (p[0]); + T (p[1]); /* { dg-warning "subscript 1 is outside array bounds of .char\\\[1]." } */ + T (p[MAX]); /* { dg-warning "subscript \[0-9\]+ is outside array bounds of .char\\\[1]." } */ + + T (&p[MIN]); /* { dg-warning "subscript -\[0-9\]+ is \(below|outside\) array bounds of .char\\\[1]." } */ + T (&p[-1]); /* { dg-warning "subscript -1 is \(below|outside\) array bounds of .char\\\[1]." } */ + T (&p[0]); + T (&p[1]); + T (&p[2]); /* { dg-warning "subscript 2 is \(above|outside\) array bounds of .char\\\[1]." } */ + T (&p[MAX]); /* { dg-warning "subscript \[0-9\]+ is \(above|outside\) array bounds of .char\\\[1]." } */ + + char ar3[3] = { 1, 2, 3 }; + p = ar3; + + T (p[MIN]); /* { dg-warning "subscript -\[0-9\]+ is outside array bounds of .char\\\[3]." } */ + T (p[-1]); /* { dg-warning "subscript -1 is outside array bounds of .char\\\[3]." } */ + T (p[0]); + T (p[1]); + T (p[2]); + T (p[3]); /* { dg-warning "subscript 3 is outside array bounds of .char\\\[3]." } */ + T (p[MAX]); /* { dg-warning "subscript \[0-9\]+ is outside array bounds of .char\\\[3]." } */ + + T (&p[MIN]); /* { dg-warning "subscript -\[0-9\]+ is \(below|outside\) array bounds of .char\\\[3]." } */ + T (&p[-1]); /* { dg-warning "subscript -1 is \(below|outside\) array bounds of .char\\\[3]." } */ + T (&p[0]); + T (&p[1]); + T (&p[2]); + T (&p[3]); + T (&p[4]); /* { dg-warning "subscript 4 is \(above|outside\) array bounds of .char\\\[3]." } */ + T (&p[MAX]); /* { dg-warning "subscript \[0-9\]+ is \(above|outside\) array bounds of .char\\\[3]." } */ +} + +struct S +{ + int a[2], b[3]; +} s [4]; + +void test_struct_array_cst (void) +{ + T (s[0].a[0] + s[0].a[1] + s[0].b[0] + s[0].b[1] + s[0].b[2] + s[0].b[2] + + s[1].a[0] + s[1].a[1] + s[1].b[0] + s[1].b[1] + s[1].b[2] + s[1].b[2] + + s[2].a[0] + s[2].a[1] + s[2].b[0] + s[2].b[1] + s[2].b[2] + s[2].b[2] + + s[3].a[0] + s[3].a[1] + s[3].b[0] + s[3].b[1] + s[3].b[2] + s[3].b[2]); + + T (&s[0].a[2], + &s[0].b[3], + &s[1].a[2], + &s[1].b[3], + &s[2].a[2], + &s[2].b[3], + &s[3].a[2], + &s[3].b[3]); + + T (s[0].a[2]); /* { dg-warning "subscript 2 is above array bounds of .int\\\[2\\\]." } */ + T (s[0].b[3]); /* { dg-warning "subscript 3 is above array bounds of .int\\\[3\\\]." } */ + T (s[1].a[2]); /* { dg-warning "subscript 2 is above array bounds of .int\\\[2\\\]." } */ + T (s[1].b[3]); /* { dg-warning "subscript 3 is above array bounds of .int\\\[3\\\]." } */ + T (s[2].a[2]); /* { dg-warning "subscript 2 is above array bounds of .int\\\[2\\\]." } */ + T (s[2].b[3]); /* { dg-warning "subscript 3 is above array bounds of .int\\\[3\\\]." } */ + T (s[3].a[2]); /* { dg-warning "subscript 2 is above array bounds of .int\\\[2\\\]." } */ + T (s[3].b[3]); /* { dg-warning "subscript 3 is above array bounds of .int\\\[3\\\]." } */ + + T (s[4].a[0]); /* { dg-warning "subscript 4 is above array bounds of .struct S\\\[4\\\]." } */ + T (s[4].a[2]); /* { dg-warning "subscript 4 is above array bounds of .struct S\\\[4\\\]." } */ + /* { dg-warning "subscript 2 is above array bounds of .int\\\[2\\\]." "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-31.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-31.c new file mode 100644 index 0000000000..921461a549 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-31.c @@ -0,0 +1,248 @@ +/* PR tree-optimization/83776: missing -Warray-bounds indexing past the end + of a string literal + Test to exercise detection of out-of-bounds indices into narrow string + literals. + { dg-do compile } + { dg-options "-O2 -Warray-bounds -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define MAX DIFF_MAX +#define MIN DIFF_MIN + +#define S1 "1" +#define S3 "123" +#define S7 "1234567" +#define S8 "12345678" +#define S9 "123456789" + +void sink (int, ...); + +#define T(expr) sink (0, expr) + + +void narrow_direct_cst (void) +{ + T (S1[MIN]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds of .char\\\[2]" "bug 86611" { xfail lp64 } } */ + T (S1[-1]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[2]" } */ + T (S1[0]); + T (S1[1]); + T (S1[2]); /* { dg-warning "array subscript 2 is above array bounds of .char\\\[2]" } */ + T (S1[MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds of .char\\\[2]" } */ + + T (&S1[MIN]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds of .char\\\[2]" } */ + T (&S1[-1]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[2]" } */ + T (&S1[0]); + T (&S1[2]); + T (&S1[3]); /* { dg-warning "array subscript 3 is above array bounds of .char\\\[2]" } */ + T (&S1[MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds of .char\\\[2]" } */ + + T (S9[MIN]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds of .char\\\[10]" "xfail lp64" { xfail lp64 } } */ + T (S9[-1]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[10]" } */ + T (S9[9]); + T (S9[10]); /* { dg-warning "array subscript 10 is above array bounds of .char\\\[10]" } */ + T (S9[11]); /* { dg-warning "array subscript 11 is above array bounds of .char\\\[10]" } */ + T (S9[MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds of .char\\\[10]" } */ + + T (&S9[MIN]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds of .char\\\[10]" } */ + T (&S9[-1]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[10]" } */ + T (&S9[9]); + T (&S9[10]); + T (&S9[11]); /* { dg-warning "array subscript 11 is above array bounds of .char\\\[10]" } */ + T (&S9[MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds of .char\\\[10]" } */ +} + +void narrow_ptr_deref_cst (void) +{ + const char *p = S8 + 9; + + T (*(p + MIN)); /* { dg-warning "array subscript -\[0-9\]+ is outside array bounds of .char\\\[9]." } */ + T (*(p - 10)); /* { dg-warning "array subscript -1 is outside array bounds of .char\\\[9]." } */ + T (*(p - 9)); + T (*(p - 1)); + T (*p); /* { dg-warning "array subscript 9 is outside array bounds of .char\\\[9]." } */ + T (*(p + 1)); /* { dg-warning "array subscript 10 is outside array bounds of .char\\\[9]." } */ + T (*(p + 2)); /* { dg-warning "array subscript 11 is outside array bounds of .char\\\[9]." } */ +} + +void narrow_ptr_index_cst (void) +{ + const char *p = S7; + + T (p[MIN + 1]); /* { dg-warning "array subscript -\[0-9\]+ is outside array bounds of .char\\\[8]." "bug 86611" { xfail lp64 } } */ + T (p[-1]); /* { dg-warning "array subscript -1 is outside array bounds of .char\\\[8]." } */ + T (p[0]); + T (p[1]); + T (p[8]); /* { dg-warning "array subscript 8 is outside array bounds of .char\\\[8]." } */ + T (p[99]); /* { dg-warning "array subscript 99 is outside array bounds of .char\\\[8]." } */ + T (p[MAX]); /* { dg-warning "array subscript \[0-9\]+ is outside array bounds of .char\\\[8]." } */ + + T (&p[MIN + 1]); /* { dg-warning "array subscript -\[0-9\]+ is \(below|outside\) array bounds of .char\\\[8]." } */ + T (&p[-1]); /* { dg-warning "array subscript -1 is \(below|outside\) array bounds of .char\\\[8]." } */ + T (&p[0]); + T (&p[1]); + T (&p[8]); + T (&p[9]); /* { dg-warning "array subscript 9 is \(above|outside\) array bounds of .char\\\[8]." } */ + T (&p[99]); /* { dg-warning "array subscript 99 is \(above|outside\) array bounds of .char\\\[8]." } */ + T (&p[MAX]); /* { dg-warning "array subscript \[0-9\]+ is \(above|outside\) array bounds of .char\\\[8]." } */ + + const char *q = S8 + 4; + T (q[MIN + 1]); /* { dg-warning "array subscript -?\[0-9\]+ is outside array bounds of .char\\\[9]." "bug 86611" { xfail lp64 } } */ + T (q[-5]); /* { dg-warning "array subscript -1 is outside array bounds of .char\\\[9]." } */ + T (q[-4]); + T (q[0]); + T (q[1]); + T (q[3]); + T (q[4]); + T (q[5]); /* { dg-warning "array subscript 9 is outside array bounds of .char\\\[9]." } */ + T (q[99]); /* { dg-warning "array subscript 103 is outside array bounds of .char\\\[9]." } */ + T (q[MAX - 4]); /* { dg-warning "array subscript \[0-9\]+ is outside array bounds of .char\\\[9]." } */ + T (q[MAX - 3]); /* { dg-warning "array subscript -?\[0-9\]+ is outside array bounds of .char\\\[9]." "bug 86611" { xfail lp64 } } */ + + T (&q[MIN + 1]); /* { dg-warning "array subscript -?\[0-9\]+ is \(below|outside\) array bounds of .char\\\[9]." } */ + T (&q[-5]); /* { dg-warning "array subscript -1 is \(below|outside\) array bounds of .char\\\[9]." } */ + T (&q[-4]); + T (&q[0]); + T (&q[1]); + T (&q[5]); + T (&q[6]); /* { dg-warning "array subscript 10 is \(above|outside\) array bounds of .char\\\[9]." } */ + T (&q[99]); /* { dg-warning "array subscript 103 is \(above|outside\) array bounds of .char\\\[9]." } */ + T (&q[MAX - 4]); /* { dg-warning "array subscript \[0-9\]+ is \(above|outside\) array bounds of .char\\\[9]." } */ + T (&q[MAX - 3]); /* { dg-warning "array subscript -?\[0-9\]+ is \(below|outside\) array bounds of .char\\\[9]." } */ +} + + +void narrow_direct_range (ptrdiff_t i, size_t j) +{ + T (S3[i]); + T (S9[j]); + + T (S3[SR (MIN, -1)]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[4]" } */ + T (S3[SR (MIN, 0)]); + T (S3[SR (-2, -1)]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[4]" } */ + T (S3[SR (1, 2)]); + T (S3[SR (1, 999)]); + T (S3[SR (2, 999)]); + T (S3[SR (3, 999)]); + T (S3[SR (4, 999)]); /* { dg-warning "array subscript 4 is above array bounds of .char\\\[4]" } */ + + T (&S3[SR (MIN, -1)]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[4]" } */ + T (&S3[SR (MIN, 0)]); + T (&S3[SR (-2, -1)]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[4]" } */ + T (&S3[SR (1, 2)]); + T (&S3[SR (1, 999)]); + T (&S3[SR (2, 999)]); + T (&S3[SR (4, 999)]); + T (&S3[SR (5, 999)]); /* { dg-warning "array subscript 5 is above array bounds of .char\\\[4]" } */ + + T (S9[SR (MIN, -9)]); /* { dg-warning "array subscript -9 is below array bounds of .char\\\[10]" } */ + T (S9[SR (MIN, -1)]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[10]" } */ + T (S9[SR (MIN, 0)]); + T (S9[SR (-2, -1)]); /* { dg-warning "array subscript -1 is below array bounds of .char\\\[10]" } */ + T (S9[SR (1, 2)]); + T (S9[SR (1, 9)]); + T (S9[SR (1, 999)]); + T (S9[SR (9, 999)]); + T (S9[SR (10, 999)]); /* { dg-warning "array subscript 10 is above array bounds of .char\\\[10]" } */ + T (S9[SR (99, MAX)]); /* { dg-warning "array subscript 99 is above array bounds of .char\\\[10]" } */ +} + + +void narrow_ptr_deref_range (ptrdiff_t i, size_t j) +{ + const char *p; + + p = S1 + i; + T (*p); + + p = S1 + j; + T (*p); + + p = S1 + SR (-999, 999); + T (*p); + + p = S1 + SR (-1, 1); + T (*p); + + p = S1 + SR (-1, 0); + T (*p); + + p = S1 + SR (0, 1); + T (*p); + + p = S1 + SR (1, 2); + T (*p); + + p = S1 + SR (2, 3); + T (*p); /* { dg-warning "array subscript 2 is outside array bounds of .char\\\[2]." } */ + + p = S1 + SR (9, 99); + T (*p); /* { dg-warning "array subscript \\\[9, 99] is outside array bounds of .char\\\[2]." } */ + + p = S8 + SR (-999, 999); + T (*p); + + p = S8 + SR (-9, -1); + T (*p); /* { dg-warning "array subscript \\\[-9, -1] is outside array bounds of .char\\\[9]." } */ + + p = S8 + SR (-9, 0); + T (*p); + + p = S8 + SR (-9, 9); + T (*p); + + p = S8 + SR (-9, 123); + T (*p); + + p = S8 + SR (8, 123); + T (*p); + + p = S8 + SR (9, 123); + T (*p); /* { dg-warning "array subscript 9 is outside array bounds of .char\\\[9]." } */ + + { + const char *p1 = S3 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + + T (*p1); + T (*p2); + T (*p3); + T (*p4); + T (*p5); + } + + { + i = SR (1, 2); + + const char *p1 = S3 + SR (1, DIFF_MAX - 1); + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + + T (*p1); + T (*p2); + T (*p3); + T (*p4); /* { dg-warning "array subscript 4 is outside array bounds of .char\\\[4]." } */ + T (*p5); /* { dg-warning "array subscript \\\[5, \[0-9\]+] is outside array bounds of .char\\\[4]." } */ + } +} + + +void narrow_ptr_index_range (void) +{ + const char *p; + + p = S7; + T (p[SR (-9, -1)]); /* { dg-warning "array subscript \\\[-9, -1] is outside array bounds of .char\\\[8]." } */ + T (p[SR (-8, 0)]); + T (p[SR (0, MAX)]); + T (p[SR (1, 9)]); + T (p[SR (8, 9)]); /* { dg-warning "array subscript 8 is outside array bounds of .char\\\[8]." } */ + + p = S7 + SR (4, 6); + T (p[5]); /* { dg-warning "array subscript \\\[9, 11] is outside array bounds of .char\\\[8]." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-32.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-32.c new file mode 100644 index 0000000000..02dac65221 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-32.c @@ -0,0 +1,184 @@ +/* PR tree-optimization/83776: missing -Warray-bounds indexing past the end + of a string literal + Test to exercise indices into wide string literals. + { dg-do compile } + { dg-options "-O2 -Warray-bounds -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define MAX DIFF_MAX +#define MIN DIFF_MIN + +typedef __WCHAR_TYPE__ wchar_t; + +#define W2 L"12" +#define W3 L"123" +#define W4 L"1234" +#define W7 L"1234567" +#define W8 L"12345678" +#define W9 L"123456789" + +void sink (int); + +#define T(expr) sink (expr) + + +void wide_direct_cst (void) +{ + T (W9[MIN]); /* { dg-warning "array subscript -\[0-9\]+ is below array bounds of .\[a-z \]+\\\[10]" "bug 86611" { xfail ilp32 } } */ + T (W9[-1]); /* { dg-warning "array subscript -1 is below array bounds of .\[a-z \]+\\\[10]" } */ + T (W9[11]); /* { dg-warning "array subscript 11 is above array bounds of .\[a-z \]+\\\[10]" } */ + T (W9[MAX]); /* { dg-warning "array subscript \[0-9\]+ is above array bounds of .\[a-z \]+\\\[10]" } */ +} + +void wide_ptr_deref_cst (void) +{ + const wchar_t *p = W8 + 9; + T (*p); /* { dg-warning "array subscript 9 is outside array bounds of .\[a-z \]+\\\[9]." } */ + T (p[1]); /* { dg-warning "array subscript 10 is outside array bounds of .\[a-z \]+\\\[9]." } */ + T (p[99]); /* { dg-warning "array subscript 108 is outside array bounds of .\[a-z \]+\\\[9]." } */ +} + +void wide_ptr_index_cst (void) +{ + const wchar_t *p = W7; + + T (p[1]); + T (p[8]); /* { dg-warning "array subscript 8 is outside array bounds of .\[a-z \]+\\\[8]." } */ + T (p[99]); /* { dg-warning "array subscript 99 is outside array bounds of .\[a-z \]+\\\[8]." } */ + T (p[MAX]); /* { dg-warning "array subscript -?\[0-9\]+ is outside array bounds of .\[a-z \]+\\\[8]." } */ +} + + +void wide_direct_range (ptrdiff_t i, size_t j) +{ + T (W9[i]); + T (W9[j]); + + T (W9[SR (MIN, -9)]); /* { dg-warning "array subscript -9 is below array bounds of .\[a-z \]+\\\[10]" } */ + T (W9[SR (MIN, -1)]); /* { dg-warning "array subscript -1 is below array bounds of .\[a-z \]+\\\[10]" } */ + T (W9[SR (MIN, 0)]); + T (W9[SR (-2, -1)]); /* { dg-warning "array subscript -1 is below array bounds of .\[a-z \]+\\\[10]" } */ + T (W9[SR (1, 2)]); + T (W9[SR (1, 9)]); + T (W9[SR (1, 999)]); + T (W9[SR (9, 999)]); + T (W9[SR (10, 999)]); /* { dg-warning "array subscript 10 is above array bounds of .\[a-z \]+\\\[10]" } */ + T (W9[SR (99, MAX)]); /* { dg-warning "array subscript 99 is above array bounds of .\[a-z \]+\\\[10]" } */ +} + +void wide_ptr_deref_range (ptrdiff_t i, size_t j) +{ + const wchar_t *p; + + p = W8 + i; + T (*p); + + p = W8 + j; + T (*p); + + p = W8 + SR (-9, -1); + T (*p); /* { dg-warning "array subscript \\\[-9, -1] is outside array bounds of .\[a-z \]+\\\[9]." } */ + + p = W8 + SR (-9, 0); + T (*p); + + p = W8 + SR (-9, 9); + T (*p); + + p = W8 + SR (9, 123); + T (*p); /* { dg-warning "array subscript 9 is outside array bounds of .\[a-z \]+\\\[9]." } */ +} + +void wide_ptr_index_range (void) +{ + const wchar_t *p; + + p = W7; + T (p[SR (-9, -1)]); /* { dg-warning "array subscript \\\[-9, -1] is outside array bounds of .\[a-z \]+\\\[8]." } */ + T (p[SR (-8, 0)]); + T (p[SR (0, MAX)]); + T (p[SR (1, 9)]); + T (p[SR (8, 9)]); /* { dg-warning "array subscript 8 is outside array bounds of .\[a-z \]+\\\[8]." } */ + + p = W7 + SR (4, 6); + T (p[5]); /* { dg-warning "array subscript \\\[9, 11] is outside array bounds of .\[a-z \]+\\\[8]." } */ +} + +void wide_ptr_index_range_1 (void) +{ + { + int i = SR (1, 2); + const wchar_t *p1 = W2 + i; + + T (p1[0]); + } + { + int i = SR (1, 2); + const wchar_t *p1 = W2 + i; + + T (p1[1]); + } + { + int i = SR (1, 2); + const wchar_t *p1 = W2 + i; + + T (p1[2]); /* { dg-warning "array subscript 3 is outside array bounds of .\[a-z \]+\\\[3]." } */ + } +} + +void wide_ptr_index_range_chain (void) +{ + int i = SR (1, 2); + { + const wchar_t *p1 = W2 + i; + const wchar_t *p2 = p1 + i; + const wchar_t *p3 = p2 + i; + + T (p1[-3]); /* { dg-warning "array subscript \\\[-2, -1] is outside array bounds of .\[a-z \]+\\\[3]." } */ + T (p1[-2]); + T (p1[-1]); + T (p1[0]); + T (p1[1]); + T (p1[2]); /* { dg-warning "array subscript 3 is outside array bounds of .\[a-z \]+\\\[3]." } */ + + T (p2[-5]); /* { dg-warning "array subscript \\\[-3, -2] is outside array bounds of .\[a-z \]+\\\[3]." } */ + T (p2[-4]); /* { dg-warning "array subscript \\\[-2, -1] is outside array bounds of .\[a-z \]+\\\[3]." } */ + T (p2[-1]); + T (p2[0]); + T (p2[1]); /* { dg-warning "array subscript 3 is outside array bounds of .\[a-z \]+\\\[3]." } */ + + T (p3[0]); /* { dg-warning "array subscript 3 is outside array bounds of .\[a-z \]+\\\[3]." } */ + T (p3[1]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[3]." } */ + T (p3[9999]); /* { dg-warning "array subscript 10002 is outside array bounds of .\[a-z \]+\\\[3]." "" { target size20plus} } */ + /* { dg-warning "array subscript \\\[-6382, -6379] is outside array bounds of .\[a-z \]+\\\[3]." "" { target { ! size20plus } } .-1 } */ + /* Large offsets are indistinguishable from negative values. */ + T (p3[DIFF_MAX]); /* { dg-warning "array subscript" "bug" { xfail *-*-* } } */ + } + + { + const wchar_t *p1 = W3 + i; + const wchar_t *p2 = p1 + i; + const wchar_t *p3 = p2 + i; + const wchar_t *p4 = p3 + i; + + T (p1[-3]); /* { dg-warning "array subscript \\\[-2, -1] is outside array bounds of .\[a-z \]+\\\[4]." } */ + T (p1[-2]); + T (p1[1]); + T (p1[2]); + T (p1[3]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */ + + T (p3[1]); /* { dg-warning "array subscript 4 is outside array bounds of .\[a-z \]+\\\[4]." } */ + } +} + +void wide_ptr_index_range_4 (void) +{ + int i = SR (1, 2); + const wchar_t *p1 = W4 + i; + const wchar_t *p2 = p1 + i; + const wchar_t *p3 = p2 + i; + const wchar_t *p4 = p3 + i; + + T (p4[1]); /* { dg-warning "array subscript 5 is outside array bounds of .\[a-z \]+\\\[5]." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-33.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-33.c new file mode 100644 index 0000000000..13efabe33b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-33.c @@ -0,0 +1,37 @@ +/* PR tree-optimization/86741 - ICE in -Warray-bounds indexing into + an object of incomplete type + { dg-do compile } + { dg-options "-O2 -Wall" } */ +/* { dg-skip-if "acessing data memory with program memory address" { "avr-*-*" } } */ + +struct S +{ + int s; +}; + +void f (void); + +void test_void (void) +{ + extern void v; + struct S *b = (struct S*)&v; + if (b->s) + f (); +} + +void test_incomplete_enum (void) +{ + extern enum E e; + struct S *b = (struct S*)&e; + if (b->s) + f (); +} + +void test_func (void) +{ + struct S *b = (struct S*)&f; + if (b->s) + f (); +} + +/* { dg-prune-output "taking address of expression of type .void." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-34.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-34.c new file mode 100644 index 0000000000..1b2a098ad8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-34.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/86650 - -Warray-bounds missing inlining context + { dg-do compile } + { dg-options "-O2 -Warray-bounds" } */ + +int a[3]; /* { dg-message "while referencing .a." } */ +int x; + +inline void foo (int i) +{ + a[i + 1] = 123; /* { dg-warning "\\\[-Warray-bounds" } */ +} + +int bar (void) +{ + foo (3); + + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-35.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-35.c new file mode 100644 index 0000000000..b3ad362520 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-35.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/87072 - g++6.2.0 false warning: array subscript + is above array bounds, with misleading line number + { dg-do compile } + { dg-options "-O3 -Wall" } */ + +int a[10]; + +void f (unsigned n) +{ + for (unsigned j = 0; j < n; j++) { + for (unsigned k = 0; k < j; k++) + a[j] += k; /* { dg-bogus "\\\[-Warray-bounds]" } */ + a[j] += j; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-36.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-36.c new file mode 100644 index 0000000000..c47d7815c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-36.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/84053] missing -Warray-bounds accessing + a local array across inlined function boundaries + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +static int deref (const int *p, int i) +{ + return p[i]; // { dg-warning "array subscript \\\[3, \[0-9\]+] is outside array bounds of .int\\\[2\\\]." "ilp32" { xfail ilp32 } } + + // There should also be an inlining context here. PR 86650 tracks + // its absence. +} + +static int deref_3_plus (const int *p, int i) +{ + if (i < 3) + i = 3; + + return deref (p, i); +} + +int deref_a (int i) +{ + int a[] = { 2, 3 }; + + return deref_3_plus (a, i); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-37.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-37.c new file mode 100644 index 0000000000..57d218a4fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-37.c @@ -0,0 +1,47 @@ +/* PR tree-optimization/88800 - Spurious -Werror=array-bounds for non-taken + branch + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern void* memmove (void*, const void*, __SIZE_TYPE__); + +struct A +{ + const char *s; + int n; +}; + +void f (void*); + +struct B +{ + char d[5]; + int n; +}; + +__attribute__ ((always_inline)) inline void +g (struct B *p, struct A a) +{ + int i = a.n; + if (i <= 5) + p->n = i; + else { + p->n = -1; + f (p); + } + + if (p->n >= 0) + memmove (p->d, a.s, a.n); /* { dg-bogus "\\\[-Warray-bounds" } */ +} + +void h (void) +{ + char c[8] = ""; + + struct A a; + a.s = c; + a.n = 8; + + struct B b; + g (&b, a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-38.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-38.c new file mode 100644 index 0000000000..c9aa0eb817 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-38.c @@ -0,0 +1,30 @@ +/* PR middle-end/88273 - bogus warning: 'memcpy' offset [-527, -529] + is out of the bounds [0, 16] + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +void *q; + +size_t x, y; + +inline void f (char *p, int i, size_t j) +{ + size_t n = y ? y : j; + + p += x - i; + + __builtin_memcpy (q, p, n); /* { dg-bogus "bounds" } */ + + x = n; +} + +void g (void) +{ + struct { char a[16]; } s; + + f (q, 0, sizeof s); + + f (s.a, 33 * sizeof s, 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-39.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-39.c new file mode 100644 index 0000000000..cb00fa9c47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-39.c @@ -0,0 +1,151 @@ +/* PR middle-end/88956 - ICE: Floating point exception on a memcpy from + an zero-length constant array + Verify both that memory and string calls with a zero-length array + don't cause an ICE, and also that they emit warnings. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define NOIPA __attribute__ ((noipa)) + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); +extern void* memmove (void*, const void*, size_t); +extern char* strcpy (char*, const char*); +extern char* strncpy (char*, const char*, size_t); + +const char s0[0] = { }; +const char s0_0[0][0] = { }; +const char s0_1[0][1] = { }; +const char s1_0[1][0] = { }; + +char d[4]; + +NOIPA void* test_memcpy_s0_1 (void *d) +{ + return memcpy (d, s0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_s0_2 (void *d) +{ + return memcpy (d, s0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_s0_0_1 (void *d) +{ + return memcpy (d, s0_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_s0_0_2 (void *d) +{ + return memcpy (d, s0_0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + + +NOIPA void* test_memcpy_s0_1_1 (void *d) +{ + return memcpy (d, s0_1, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_s0_1_2 (void *d) +{ + return memcpy (d, s0_1, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + + +NOIPA void* test_memcpy_s1_0_1 (void *d) +{ + return memcpy (d, s1_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_s1_0_2 (void *d) +{ + return memcpy (d, s1_0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + + +NOIPA void* test_memmove_s0_1 (void *d) +{ + return memmove (d, s0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memmove_s0_2 (void *d) +{ + return memmove (d, s0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memmove_s0_0_1 (void *d) +{ + return memmove (d, s0_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memmove_s0_0_2 (void *d) +{ + return memmove (d, s0_0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + + +struct Empty { }; +const struct Empty e = { }; +const struct Empty e0[0] = { }; +const struct Empty e0_0[0][0] = { }; +const struct Empty e0_1[0][1] = { }; +const struct Empty e1_0[1][0] = { }; + +NOIPA void* test_memcpy_e_1 (void *d) +{ + return memcpy (d, &e, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_e0_1 (void *d) +{ + return memcpy (d, e0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_e0_0_1 (void *d) +{ + return memcpy (d, e0_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_e0_1_1 (void *d) +{ + return memcpy (d, e0_1, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA void* test_memcpy_e1_0_1 (void *d) +{ + return memcpy (d, e1_0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + + +NOIPA char* +test_strcpy_s0 (char *d) /* { dg-bogus "-Warray-bounds" "pr101679" { xfail *-*-* } } */ +{ + return strcpy (d, s0); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA char* test_strcpy_s0_0 (char *d) +{ + return strcpy (d, s0_0[0]); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + + +NOIPA char* test_strncpy_s0_1 (char *d) +{ + return strncpy (d, s0, 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA char* test_strncpy_s0_2 (char *d) +{ + return strncpy (d, s0, 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA char* test_strncpy_s0_0_1 (char *d) +{ + return strncpy (d, s0_0[0], 1); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} + +NOIPA char* test_strncpy_s0_0_2 (char *d) +{ + return strncpy (d, s0_0[0], 2); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-4.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-4.c new file mode 100644 index 0000000000..71526f27ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-4.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +typedef unsigned int DWORD; + +static void g(DWORD * p, int n) +{ + int i; + + for (i = 0; i < n && !p[n - 1]; i++); /* { dg-bogus "subscript is above array bounds" } */ +} + +void f() { + DWORD arr[8]; + + g(arr, 4); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-40.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-40.c new file mode 100644 index 0000000000..c389d96a98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-40.c @@ -0,0 +1,73 @@ +/* PR middle-end/88771 - Misleading -Werror=array-bounds error + Verify that the warning issued for calls to "bounded" string + functions when -Wstringop-overflow is disabled is -Warray-bounds + with the right wording. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-overflow -Wno-stringop-overread" } */ + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); +extern void* memmove (void*, const void*, size_t); +extern void* memset (void*, int, size_t); + +extern char* stpncpy (char*, const char*, size_t); + +extern char* strncat (char*, const char*, size_t); +extern char* strncpy (char*, const char*, size_t); + +extern char* strndup (const char*, size_t); + +extern int strncmp (const char*, const char*, size_t); +extern int strncasecmp (const char*, const char*, size_t); + +extern size_t strnlen (const char*, size_t); + +extern char *d; +extern const char *s; + + +void test_memcpy (void) +{ + memcpy (d, s, SIZE_MAX); /* { dg-warning ".memcpy. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */ +} + +void test_memmove (void) +{ + memmove (d, s, SIZE_MAX - 1); /* { dg-warning ".memmove. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */ +} + +void test_memset (void) +{ + memset (d, 0, SIZE_MAX - 2); /* { dg-warning ".memset. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */ +} + + +char* test_stpncpy (void) +{ + return stpncpy (d, s, SIZE_MAX - 4); /* { dg-warning ".stpncpy. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */ +} + + +void test_strncat (void) +{ + strncat (d, s, SIZE_MAX - 3); /* { dg-warning ".strncat. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */ +} + +void test_strncpy (void) +{ + strncpy (d, s, SIZE_MAX - 4); /* { dg-warning ".strncpy. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */ +} + +char* test_strndup (void) +{ + return strndup (s, SIZE_MAX - 5); /* { dg-warning ".strndup. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" "bug" { xfail *-*-* } } */ +} + +size_t test_strnlen (void) +{ + return strnlen (s, SIZE_MAX - 6); /* { dg-warning ".strnlen. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" "bug" { xfail *-*-* } } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-41.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-41.c new file mode 100644 index 0000000000..3b3693f088 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-41.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/89662- -Warray-bounds ICE on void* arithmetic + { dg-do compile } + { dg-require-effective-target alloca } + { dg-options "-O2 -Wall" } */ + +static void* vptr (void *c) +{ + return c; +} + +void sink (void*); + +void test_vptr_arith_vla_cst (void) +{ + int n = 1; + char c[n]; + sink (vptr (c) - 1); /* { dg-warning "\\\[-Warray-bounds" } */ +} + +void test_vptr_arith_vla_range (int n) +{ + if (n < 1 || 4 < n) + return; + + char c[n]; + sink (vptr (c) - 1); /* { dg-warning "\\\[-Warray-bounds" "pr82608" { xfail *-*-* } } */ +} + +void test_vptr_arith_vla_var (int n) +{ + char c[n]; + sink (vptr (c) - 1); /* { dg-warning "\\\[-Warray-bounds" "pr82608" { xfail *-*-* } } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-42.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-42.c new file mode 100644 index 0000000000..005e1459df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-42.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/89720 - Spurious -Warray-bounds warning on a range + with max < min + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void f (char*, int); + +#if __SIZEOF_POINTER__ == 8 + +void g (__INT64_TYPE__ i) +{ + char a[65536] = ""; + char *p = a + (i & (__INT64_TYPE__)0xffffffff3fffffffLL); + f (p, *(p - 6)); /* { dg-bogus "\\\[-Warray-bounds" } */ +} + +#elif __SIZEOF_POINTER__ == 4 + +void h (__INT32_TYPE__ i) +{ + char a[65536] = ""; + char *p = a + (i & (__INT32_TYPE__)0x8fffffffLL); + f (p, *(p - 6)); /* { dg-bogus "\\\[-Warray-bounds" } */ +} + +#endif diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-43.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-43.c new file mode 100644 index 0000000000..43a8331578 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-43.c @@ -0,0 +1,122 @@ +/* Test to verify that --param ssa_name_def_chain_limit can be used to + limit the maximum number of SSA_NAME assignments the warning follows. + { dg-do compile } + { dg-options "-O2 -Wall --param ssa-name-def-chain-limit=4" } */ + +#define NOIPA __attribute__ ((noipa)) + +const char a9[] = "123456789"; + +void sink (const char*, ...); + +NOIPA int g2 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + + sink (p0, p1, p2); + + return p2[8]; // { dg-warning "\\\[-Warray-bounds" } +} + +NOIPA int g3 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + + sink (p0, p1, p2, p3); + + return p3[7]; // { dg-warning "\\\[-Warray-bounds" } +} + +NOIPA int g4 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + + sink (p0, p1, p2, p3, p4); + + return p4[6]; // { dg-warning "\\\[-Warray-bounds" } +} + +NOIPA int g5 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + + sink (p0, p1, p2, p3, p4, p5); + + return p5[5]; +} + +NOIPA int g6 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + const char *p6 = p5 + i; + + sink (p0, p1, p2, p3, p4, p5, p6); + + return p6[4]; +} + +NOIPA int g7 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + const char *p6 = p5 + i; + const char *p7 = p6 + i; + + sink (p0, p1, p2, p3, p4, p5, p6, p7); + + return p7[3]; +} + +NOIPA int g8 (int i) +{ + if (i < 1) i = 1; + + const char *p0 = a9; + const char *p1 = p0 + i; + const char *p2 = p1 + i; + const char *p3 = p2 + i; + const char *p4 = p3 + i; + const char *p5 = p4 + i; + const char *p6 = p5 + i; + const char *p7 = p6 + i; + const char *p8 = p7 + i; + + sink (p0, p1, p2, p3, p4, p5, p6, p7, p8); + + return p8[2]; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-44.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-44.c new file mode 100644 index 0000000000..709d0046b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-44.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +int foo(unsigned int state, unsigned char * p, unsigned int p_len) +{ + static char const pattern[] = "abcd"; + static unsigned const pattern_length = sizeof(pattern) - 1; + + if (p_len == 1) { + return state; + } + + if (state < pattern_length && + p_len == (pattern_length - state) && + (!__builtin_constant_p(p_len) ? + __builtin_memcmp(p, pattern + state, p_len) : + ((unsigned char*)p)[6] == ((unsigned char*)pattern + state)[6] /* { dg-bogus "array bounds" } */ + )) { + + return 4; + } + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-45.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-45.c new file mode 100644 index 0000000000..e21452fdf2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-45.c @@ -0,0 +1,330 @@ +/* PR middle-end/91631 - buffer overflow into an array member of a declared + object not detected + Test to verify that past-the-end accesses by string functions to member + arrays by-reference objects are diagnosed. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-unused-local-typedefs -ftrack-macro-expansion=0" } */ + +extern char* strcpy (char*, const char*); +extern char* strcat (char*, const char*); + +void sink (void*, ...); + +#define S36 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + +#define S(N) (S36 + sizeof (S36) - N - 1) + +/* In the test macro, prevent the strcpy to memcpy transformation + by using a local array initialized with the string literal. Without + it, GCC transforms the strcpy call with memcpy which (unfortunately) + permits accesses that cross subobject boundaries. */ +#define T(dst, ncpy, ncat) \ + do { \ + const char a[] = S36; \ + strcpy (dst, a + sizeof a - ncpy - 1); \ + const char b[] = S36; \ + strcat (dst, b + sizeof b - ncat - 1); \ + sink (dst); \ + } while (0) + + +struct MemArrays +{ + char a7[7]; // { dg-message "'a7' declared here" } + char a4[4]; // { dg-message "'a4' declared here" } + char a3[3]; // { dg-message "'a3' declared here" } +}; + +struct MemArrays gma; + +void strcat_value (void) +{ + T (gma.a7, 1, 1); + T (gma.a7, 1, 5); + T (gma.a7, 1, 6); // { dg-warning "'strcat' offset 7 from the object at 'gma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + T (gma.a7, 1, 7); // { dg-warning "'strcat' offset \\\[7, 8] from the object at 'gma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + + T (gma.a7, 2, 1); + T (gma.a7, 2, 4); + T (gma.a7, 2, 5); // { dg-warning "'strcat' offset 7 from the object at 'gma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + T (gma.a7, 2, 6); // { dg-warning "'strcat' offset \\\[7, 8] from the object at 'gma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + + T (gma.a7, 5, 1); + T (gma.a7, 5, 2); // { dg-warning "'strcat' offset 7 from the object at 'gma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + + T (gma.a4, 1, 1); + T (gma.a4, 1, 2); + T (gma.a4, 1, 3); // { dg-warning "'strcat' offset 11 from the object at 'gma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 7" } + T (gma.a4, 1, 4); // { dg-warning "'strcat' offset \\\[11, 12] from the object at 'gma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 7" } + + T (gma.a4, 2, 3); // { dg-warning "'strcat' offset \\\[11, 12] from the object at 'gma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 7" } + + T (gma.a3, 1, 1); + T (gma.a3, 1, 2); // { dg-warning "'strcat' offset 14 from the object at 'gma' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset 11" } +} + + +void strcat_ref (struct MemArrays *pma) +{ + T (pma->a7, 1, 1); + T (pma->a7, 1, 5); + T (pma->a7, 1, 6); // { dg-warning "'strcat' offset 7 from the object at 'pma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + T (pma->a7, 1, 7); // { dg-warning "'strcat' offset \\\[7, 8] from the object at 'pma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + + T (pma->a7, 2, 1); + T (pma->a7, 2, 4); + T (pma->a7, 2, 5); // { dg-warning "'strcat' offset 7 from the object at 'pma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + T (pma->a7, 2, 6); // { dg-warning "'strcat' offset \\\[7, 8] from the object at 'pma' is out of the bounds of referenced subobject 'a7' with type 'char\\\[7]' at offset 0" } + + T (pma->a4, 1, 1); + T (pma->a4, 1, 2); + T (pma->a4, 1, 3); // { dg-warning "'strcat' offset 11 from the object at 'pma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 7" } + T (pma->a4, 1, 4); // { dg-warning "'strcat' offset \\\[11, 12] from the object at 'pma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 7" } + + T (pma->a4, 2, 3); // { dg-warning "'strcat' offset \\\[11, 12] from the object at 'pma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 7" } + + T (pma->a3, 1, 1); + T (pma->a3, 1, 2); // { dg-warning "'strcat' offset 14 from the object at 'pma' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset 11" } +} + + +#define T2(dst1, dst2, ncpy, ncat) \ + do { \ + const char a[] = S36; \ + strcpy (dst1, a + sizeof a - ncpy - 1); \ + const char b[] = S36; \ + strcat (dst2, b + sizeof b - ncat - 1); \ + sink (dst1, dst2); \ + } while (0) + +struct ArraysOfMemArrays +{ + struct MemArrays ma3[3]; +} a3[3]; + +void strcat_arrays_of_arrays_value (void) +{ + T2 (a3[0].ma3[0].a7, a3[0].ma3[0].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (a3[0].ma3[0].a7, a3[0].ma3[1].a7, 6, 6); + T2 (a3[0].ma3[0].a7, a3[0].ma3[2].a7, 6, 6); + + T2 (a3[0].ma3[1].a7, a3[0].ma3[0].a7, 6, 6); + T2 (a3[0].ma3[1].a7, a3[0].ma3[1].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (a3[0].ma3[1].a7, a3[0].ma3[2].a7, 6, 6); + + T2 (a3[0].ma3[2].a7, a3[0].ma3[0].a7, 6, 6); + T2 (a3[0].ma3[2].a7, a3[0].ma3[1].a7, 6, 6); + T2 (a3[0].ma3[2].a7, a3[0].ma3[2].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + + T2 (a3[0].ma3[0].a7, a3[1].ma3[0].a7, 6, 6); + T2 (a3[0].ma3[0].a7, a3[1].ma3[1].a7, 6, 6); + T2 (a3[0].ma3[0].a7, a3[1].ma3[2].a7, 6, 6); + + T2 (a3[0].ma3[1].a7, a3[1].ma3[0].a7, 6, 6); + T2 (a3[0].ma3[1].a7, a3[1].ma3[1].a7, 6, 6); + T2 (a3[0].ma3[1].a7, a3[1].ma3[2].a7, 6, 6); + + T2 (a3[0].ma3[2].a7, a3[1].ma3[0].a7, 6, 6); + T2 (a3[0].ma3[2].a7, a3[1].ma3[1].a7, 6, 6); + T2 (a3[0].ma3[2].a7, a3[1].ma3[2].a7, 6, 6); + + T2 (a3[0].ma3[0].a7, a3[2].ma3[0].a7, 6, 6); + T2 (a3[0].ma3[0].a7, a3[2].ma3[1].a7, 6, 6); + T2 (a3[0].ma3[0].a7, a3[2].ma3[2].a7, 6, 6); + + T2 (a3[0].ma3[1].a7, a3[2].ma3[0].a7, 6, 6); + T2 (a3[0].ma3[1].a7, a3[2].ma3[1].a7, 6, 6); + T2 (a3[0].ma3[1].a7, a3[2].ma3[2].a7, 6, 6); + + T2 (a3[0].ma3[2].a7, a3[2].ma3[0].a7, 6, 6); + T2 (a3[0].ma3[2].a7, a3[2].ma3[1].a7, 6, 6); + T2 (a3[0].ma3[2].a7, a3[2].ma3[2].a7, 6, 6); + + + T2 (a3[1].ma3[0].a7, a3[0].ma3[0].a7, 6, 6); + T2 (a3[1].ma3[0].a7, a3[0].ma3[1].a7, 6, 6); + T2 (a3[1].ma3[0].a7, a3[0].ma3[2].a7, 6, 6); + + T2 (a3[1].ma3[1].a7, a3[0].ma3[0].a7, 6, 6); + T2 (a3[1].ma3[1].a7, a3[0].ma3[1].a7, 6, 6); + T2 (a3[1].ma3[1].a7, a3[0].ma3[2].a7, 6, 6); + + T2 (a3[1].ma3[2].a7, a3[0].ma3[0].a7, 6, 6); + T2 (a3[1].ma3[2].a7, a3[0].ma3[1].a7, 6, 6); + T2 (a3[1].ma3[2].a7, a3[0].ma3[2].a7, 6, 6); + + T2 (a3[1].ma3[0].a7, a3[1].ma3[0].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (a3[1].ma3[0].a7, a3[1].ma3[1].a7, 6, 6); + T2 (a3[1].ma3[0].a7, a3[1].ma3[2].a7, 6, 6); + + T2 (a3[1].ma3[1].a7, a3[1].ma3[0].a7, 6, 6); + T2 (a3[1].ma3[1].a7, a3[1].ma3[1].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (a3[1].ma3[1].a7, a3[1].ma3[2].a7, 6, 6); + + T2 (a3[1].ma3[2].a7, a3[1].ma3[0].a7, 6, 6); + T2 (a3[1].ma3[2].a7, a3[1].ma3[1].a7, 6, 6); + T2 (a3[1].ma3[2].a7, a3[1].ma3[2].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + + T2 (a3[1].ma3[0].a7, a3[2].ma3[0].a7, 6, 6); + T2 (a3[1].ma3[0].a7, a3[2].ma3[1].a7, 6, 6); + T2 (a3[1].ma3[0].a7, a3[2].ma3[2].a7, 6, 6); + + T2 (a3[1].ma3[1].a7, a3[2].ma3[0].a7, 6, 6); + T2 (a3[1].ma3[1].a7, a3[2].ma3[1].a7, 6, 6); + T2 (a3[1].ma3[1].a7, a3[2].ma3[2].a7, 6, 6); + + T2 (a3[1].ma3[2].a7, a3[2].ma3[0].a7, 6, 6); + T2 (a3[1].ma3[2].a7, a3[2].ma3[1].a7, 6, 6); + T2 (a3[1].ma3[2].a7, a3[2].ma3[2].a7, 6, 6); + + + T2 (a3[2].ma3[0].a7, a3[0].ma3[0].a7, 6, 6); + T2 (a3[2].ma3[0].a7, a3[0].ma3[1].a7, 6, 6); + T2 (a3[2].ma3[0].a7, a3[0].ma3[2].a7, 6, 6); + + T2 (a3[2].ma3[1].a7, a3[0].ma3[0].a7, 6, 6); + T2 (a3[2].ma3[1].a7, a3[0].ma3[1].a7, 6, 6); + T2 (a3[2].ma3[1].a7, a3[0].ma3[2].a7, 6, 6); + + T2 (a3[2].ma3[2].a7, a3[0].ma3[0].a7, 6, 6); + T2 (a3[2].ma3[2].a7, a3[0].ma3[1].a7, 6, 6); + T2 (a3[2].ma3[2].a7, a3[0].ma3[2].a7, 6, 6); + + T2 (a3[2].ma3[0].a7, a3[1].ma3[0].a7, 6, 6); + T2 (a3[2].ma3[0].a7, a3[1].ma3[1].a7, 6, 6); + T2 (a3[2].ma3[0].a7, a3[1].ma3[2].a7, 6, 6); + + T2 (a3[2].ma3[1].a7, a3[1].ma3[0].a7, 6, 6); + T2 (a3[2].ma3[1].a7, a3[1].ma3[1].a7, 6, 6); + T2 (a3[2].ma3[1].a7, a3[1].ma3[2].a7, 6, 6); + + T2 (a3[2].ma3[2].a7, a3[1].ma3[0].a7, 6, 6); + T2 (a3[2].ma3[2].a7, a3[1].ma3[1].a7, 6, 6); + T2 (a3[2].ma3[2].a7, a3[1].ma3[2].a7, 6, 6); + + T2 (a3[2].ma3[0].a7, a3[2].ma3[0].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (a3[2].ma3[0].a7, a3[2].ma3[1].a7, 6, 6); + T2 (a3[2].ma3[0].a7, a3[2].ma3[2].a7, 6, 6); + + T2 (a3[2].ma3[1].a7, a3[2].ma3[0].a7, 6, 6); + T2 (a3[2].ma3[1].a7, a3[2].ma3[1].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (a3[2].ma3[1].a7, a3[2].ma3[2].a7, 6, 6); + + T2 (a3[2].ma3[2].a7, a3[2].ma3[0].a7, 6, 6); + T2 (a3[2].ma3[2].a7, a3[2].ma3[1].a7, 6, 6); + T2 (a3[2].ma3[2].a7, a3[2].ma3[2].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } +} + + +void strcat_arrays_of_arrays_ref (struct ArraysOfMemArrays *p) +{ + T2 (p[0].ma3[0].a7, p[0].ma3[0].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (p[0].ma3[0].a7, p[0].ma3[1].a7, 6, 6); + T2 (p[0].ma3[0].a7, p[0].ma3[2].a7, 6, 6); + + T2 (p[0].ma3[1].a7, p[0].ma3[0].a7, 6, 6); + T2 (p[0].ma3[1].a7, p[0].ma3[1].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (p[0].ma3[1].a7, p[0].ma3[2].a7, 6, 6); + + T2 (p[0].ma3[2].a7, p[0].ma3[0].a7, 6, 6); + T2 (p[0].ma3[2].a7, p[0].ma3[1].a7, 6, 6); + T2 (p[0].ma3[2].a7, p[0].ma3[2].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + + T2 (p[0].ma3[0].a7, p[1].ma3[0].a7, 6, 6); + T2 (p[0].ma3[0].a7, p[1].ma3[1].a7, 6, 6); + T2 (p[0].ma3[0].a7, p[1].ma3[2].a7, 6, 6); + + T2 (p[0].ma3[1].a7, p[1].ma3[0].a7, 6, 6); + T2 (p[0].ma3[1].a7, p[1].ma3[1].a7, 6, 6); + T2 (p[0].ma3[1].a7, p[1].ma3[2].a7, 6, 6); + + T2 (p[0].ma3[2].a7, p[1].ma3[0].a7, 6, 6); + T2 (p[0].ma3[2].a7, p[1].ma3[1].a7, 6, 6); + T2 (p[0].ma3[2].a7, p[1].ma3[2].a7, 6, 6); + + T2 (p[0].ma3[0].a7, p[2].ma3[0].a7, 6, 6); + T2 (p[0].ma3[0].a7, p[2].ma3[1].a7, 6, 6); + T2 (p[0].ma3[0].a7, p[2].ma3[2].a7, 6, 6); + + T2 (p[0].ma3[1].a7, p[2].ma3[0].a7, 6, 6); + T2 (p[0].ma3[1].a7, p[2].ma3[1].a7, 6, 6); + T2 (p[0].ma3[1].a7, p[2].ma3[2].a7, 6, 6); + + T2 (p[0].ma3[2].a7, p[2].ma3[0].a7, 6, 6); + T2 (p[0].ma3[2].a7, p[2].ma3[1].a7, 6, 6); + T2 (p[0].ma3[2].a7, p[2].ma3[2].a7, 6, 6); + + + T2 (p[1].ma3[0].a7, p[0].ma3[0].a7, 6, 6); + T2 (p[1].ma3[0].a7, p[0].ma3[1].a7, 6, 6); + T2 (p[1].ma3[0].a7, p[0].ma3[2].a7, 6, 6); + + T2 (p[1].ma3[1].a7, p[0].ma3[0].a7, 6, 6); + T2 (p[1].ma3[1].a7, p[0].ma3[1].a7, 6, 6); + T2 (p[1].ma3[1].a7, p[0].ma3[2].a7, 6, 6); + + T2 (p[1].ma3[2].a7, p[0].ma3[0].a7, 6, 6); + T2 (p[1].ma3[2].a7, p[0].ma3[1].a7, 6, 6); + T2 (p[1].ma3[2].a7, p[0].ma3[2].a7, 6, 6); + + T2 (p[1].ma3[0].a7, p[1].ma3[0].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (p[1].ma3[0].a7, p[1].ma3[1].a7, 6, 6); + T2 (p[1].ma3[0].a7, p[1].ma3[2].a7, 6, 6); + + T2 (p[1].ma3[1].a7, p[1].ma3[0].a7, 6, 6); + T2 (p[1].ma3[1].a7, p[1].ma3[1].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (p[1].ma3[1].a7, p[1].ma3[2].a7, 6, 6); + + T2 (p[1].ma3[2].a7, p[1].ma3[0].a7, 6, 6); + T2 (p[1].ma3[2].a7, p[1].ma3[1].a7, 6, 6); + T2 (p[1].ma3[2].a7, p[1].ma3[2].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + + T2 (p[1].ma3[0].a7, p[2].ma3[0].a7, 6, 6); + T2 (p[1].ma3[0].a7, p[2].ma3[1].a7, 6, 6); + T2 (p[1].ma3[0].a7, p[2].ma3[2].a7, 6, 6); + + T2 (p[1].ma3[1].a7, p[2].ma3[0].a7, 6, 6); + T2 (p[1].ma3[1].a7, p[2].ma3[1].a7, 6, 6); + T2 (p[1].ma3[1].a7, p[2].ma3[2].a7, 6, 6); + + T2 (p[1].ma3[2].a7, p[2].ma3[0].a7, 6, 6); + T2 (p[1].ma3[2].a7, p[2].ma3[1].a7, 6, 6); + T2 (p[1].ma3[2].a7, p[2].ma3[2].a7, 6, 6); + + + T2 (p[2].ma3[0].a7, p[0].ma3[0].a7, 6, 6); + T2 (p[2].ma3[0].a7, p[0].ma3[1].a7, 6, 6); + T2 (p[2].ma3[0].a7, p[0].ma3[2].a7, 6, 6); + + T2 (p[2].ma3[1].a7, p[0].ma3[0].a7, 6, 6); + T2 (p[2].ma3[1].a7, p[0].ma3[1].a7, 6, 6); + T2 (p[2].ma3[1].a7, p[0].ma3[2].a7, 6, 6); + + T2 (p[2].ma3[2].a7, p[0].ma3[0].a7, 6, 6); + T2 (p[2].ma3[2].a7, p[0].ma3[1].a7, 6, 6); + T2 (p[2].ma3[2].a7, p[0].ma3[2].a7, 6, 6); + + T2 (p[2].ma3[0].a7, p[1].ma3[0].a7, 6, 6); + T2 (p[2].ma3[0].a7, p[1].ma3[1].a7, 6, 6); + T2 (p[2].ma3[0].a7, p[1].ma3[2].a7, 6, 6); + + T2 (p[2].ma3[1].a7, p[1].ma3[0].a7, 6, 6); + T2 (p[2].ma3[1].a7, p[1].ma3[1].a7, 6, 6); + T2 (p[2].ma3[1].a7, p[1].ma3[2].a7, 6, 6); + + T2 (p[2].ma3[2].a7, p[1].ma3[0].a7, 6, 6); + T2 (p[2].ma3[2].a7, p[1].ma3[1].a7, 6, 6); + T2 (p[2].ma3[2].a7, p[1].ma3[2].a7, 6, 6); + + T2 (p[2].ma3[0].a7, p[2].ma3[0].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (p[2].ma3[0].a7, p[2].ma3[1].a7, 6, 6); + T2 (p[2].ma3[0].a7, p[2].ma3[2].a7, 6, 6); + + T2 (p[2].ma3[1].a7, p[2].ma3[0].a7, 6, 6); + T2 (p[2].ma3[1].a7, p[2].ma3[1].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } + T2 (p[2].ma3[1].a7, p[2].ma3[2].a7, 6, 6); + + T2 (p[2].ma3[2].a7, p[2].ma3[0].a7, 6, 6); + T2 (p[2].ma3[2].a7, p[2].ma3[1].a7, 6, 6); + T2 (p[2].ma3[2].a7, p[2].ma3[2].a7, 6, 6); // { dg-warning "\\\[-Warray-bounds" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-46.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-46.c new file mode 100644 index 0000000000..4effe5c205 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-46.c @@ -0,0 +1,252 @@ +/* PR middle-end/91631 - buffer overflow into an array member of a declared + object not detected + Test to verify that past-the-end accesses by string functions to member + arrays by-reference objects are diagnosed. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-unused-local-typedefs -Wno-stringop-overflow -ftrack-macro-expansion=0" } + { dg-require-effective-target alloca } */ + +#define SA(expr) typedef int StaticAssert [2 * !!(expr) - 1] + +typedef __SIZE_TYPE__ size_t; + +extern char* strcpy (char*, const char*); +extern char* strncpy (char*, const char*, size_t); + +void sink (void*); + +struct MA17 +{ + char pad[4]; + char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8], a9[9], a10[10]; + char a11[11], a12[12], a13[13], a14[14], a15[15], a16[16], a17[17], ax[]; +}; + +extern struct MA17 gma; +extern struct MA17 gma2[2]; + +struct MA17 igma_3 = { .ax = { 1, 2, 3 } }; +struct MA17 igma2_[2]; + +#define S36 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + +#define S(N) (S36 + sizeof (S36) - N - 1) + +/* In the test macro, prevent the strcpy to memcpy transformation + by using a local array initialized with the string literal. Without + it, GCC transforms the strcpy call with memcpy which (unfortunately) + permits accesses that cross subobject boundaries. */ +#define T(dst, n) \ + do { \ + const char a[] = S36; \ + strcpy (dst, a + sizeof a - n - 1); \ + sink (dst); \ + } while (0) + +void strcpy_global (void) +{ + T (gma.a1, 0); + T (gma.a1, 1); // { dg-warning "'strcpy' offset 5 from the object at 'gma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 4" } + T (gma.a1, 4); // { dg-warning "'strcpy' offset \\\[5, 8] from the object at 'gma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 4" } + + T (gma.a2, 1); + T (gma.a2, 2); // { dg-warning "'strcpy' offset 7 from the object at 'gma' is out of the bounds of referenced subobject 'a2' with type 'char\\\[2]' at offset 5" } + + T (gma.a3, 2); + T (gma.a3, 3); // { dg-warning "'strcpy' offset 10 from the object at 'gma' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset 7" } + + T (gma.a4, 3); + T (gma.a4, 4); // { dg-warning "'strcpy' offset 14 from the object at 'gma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 10" } + + T (gma.a5, 4); + T (gma.a5, 5); // { dg-warning "'strcpy' offset 19 from the object at 'gma' is out of the bounds of referenced subobject 'a5' with type 'char\\\[5]' at offset 14" } + + SA (__builtin_offsetof (struct MA17, a17) == 140); + + T (gma.a17, 16); + T (gma.a17, 17); // { dg-warning "'strcpy' offset 157 from the object at 'gma' is out of the bounds of referenced subobject 'a17' with type 'char\\\[17]' at offset 140" } + + SA (__builtin_offsetof (struct MA17, ax) == 157); + // GCC allows static initialization of flexible array members of + // non-local objects. Verify that writing into one that may be + // initialized in another translation unit isn't diagnosed. */ + T (gma.ax, 0); // { dg-bogus "\\\[-Warray-bounds" } +} + + +void strcpy_global_array (void) +{ + T (gma2[0].a1, 0); + T (gma2[0].a1, 1); // { dg-warning "'strcpy' offset 5 from the object at 'gma2' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 4" } + T (gma2[0].a1, 4); // { dg-warning "'strcpy' offset \\\[5, 8] from the object at 'gma2' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 4" } + + T (gma2[0].a2, 1); + T (gma2[0].a2, 2); // { dg-warning "'strcpy' offset 7 from the object at 'gma2' is out of the bounds of referenced subobject 'a2' with type 'char\\\[2]' at offset 5" } + + T (gma2[0].a3, 2); + T (gma2[0].a3, 3); // { dg-warning "'strcpy' offset 10 from the object at 'gma2' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset 7" } + + T (gma2[0].a4, 3); + T (gma2[0].a4, 4); // { dg-warning "'strcpy' offset 14 from the object at 'gma2' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 10" } + + T (gma2[0].a5, 4); + T (gma2[0].a5, 5); // { dg-warning "'strcpy' offset 19 from the object at 'gma2' is out of the bounds of referenced subobject 'a5' with type 'char\\\[5]' at offset 14" } + + T (gma2[0].a17, 16); + T (gma2[0].a17, 17); // { dg-warning "'strcpy' offset 157 from the object at 'gma2' is out of the bounds of referenced subobject 'a17' with type 'char\\\[17]' at offset 140" } + + /* GMA2 is external but because it's an array its definition in another + translation unit may not provide an initializer for the flexible array + member. Verify that a warning is issued for access to it. */ + T (gma2[0].ax, 1); // { dg-warning "'strcpy' offset \\\[157, 158] from the object at 'gma2' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 157" } + T (gma2[0].ax, 7); // { dg-warning "'strcpy' offset \\\[157, 164] from the object at 'gma2' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 157" } + + /* IGMA2_ is internal and provides no definition for the flexible array + member. Verify that a warning is issued for out-of-bounds accesses + to it. */ + T (igma2_[0].ax, 1); // { dg-warning "'strcpy' offset \\\[157, 158] from the object at 'igma2_' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 157" } + + T (igma_3.ax, 0); + T (igma_3.ax, 1); + T (igma_3.ax, 1); + T (igma_3.ax, 3); // { dg-warning " offset 160 " } + T (igma_3.ax, 9); // { dg-warning " offset \\\[160, 166] " } +} + + +void strcpy_local (void) +{ + struct MA17 lma; + + T (lma.a1, 0); + T (lma.a1, 1); // { dg-warning "'strcpy' offset 5 from the object at 'lma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 4" } + T (lma.a1, 4); // { dg-warning "'strcpy' offset \\\[5, 8] from the object at 'lma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 4" } + + T (lma.a2, 1); + T (lma.a2, 2); // { dg-warning "'strcpy' offset 7 from the object at 'lma' is out of the bounds of referenced subobject 'a2' with type 'char\\\[2]' at offset 5" } + + T (lma.a3, 2); + T (lma.a3, 3); // { dg-warning "'strcpy' offset 10 from the object at 'lma' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset 7" } + + T (lma.a4, 3); + T (lma.a4, 4); // { dg-warning "'strcpy' offset 14 from the object at 'lma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 10" } + + T (lma.a5, 4); + T (lma.a5, 5); // { dg-warning "'strcpy' offset 19 from the object at 'lma' is out of the bounds of referenced subobject 'a5' with type 'char\\\[5]' at offset 14" } + + T (lma.a17, 16); + T (lma.a17, 17); // { dg-warning "'strcpy' offset 157 from the object at 'lma' is out of the bounds of referenced subobject 'a17' with type 'char\\\[17]' at offset 140" } + + T (lma.ax, 0); // { dg-warning "'strcpy' offset 157 from the object at 'lma' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 157" } +} + + +void strcpy_ref (struct MA17 *pma) +{ + T (pma->a1, 0); + T (pma->a1, 1); // { dg-warning "'strcpy' offset 5 from the object at 'pma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 4" } + T (pma->a1, 4); // { dg-warning "'strcpy' offset \\\[5, 8] from the object at 'pma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 4" } + + T (pma->a2, 1); + T (pma->a2, 2); // { dg-warning "'strcpy' offset 7 from the object at 'pma' is out of the bounds of referenced subobject 'a2' with type 'char\\\[2]' at offset 5" } + + T (pma->a3, 2); + T (pma->a3, 3); // { dg-warning "'strcpy' offset 10 from the object at 'pma' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset 7" } + + T (pma->a4, 3); + T (pma->a4, 4); // { dg-warning "'strcpy' offset 14 from the object at 'pma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 10" } + + T (pma->a5, 4); + T (pma->a5, 5); // { dg-warning "'strcpy' offset 19 from the object at 'pma' is out of the bounds of referenced subobject 'a5' with type 'char\\\[5]' at offset 14" } + + T (pma->a17, 16); + T (pma->a17, 17); // { dg-warning "'strcpy' offset 157 from the object at 'pma' is out of the bounds of referenced subobject 'a17' with type 'char\\\[17]' at offset 140" } + + T (pma->ax, 0); + T ((*pma).ax, 8); + T (pma[0].ax, 9); + + SA (__builtin_offsetof (struct MA17, a1) == 4 + && sizeof (struct MA17) == 157); + + T (pma[1].a1, 0); + T (pma[1].a1, 1); // { dg-warning "'strcpy' offset 162 from the object at 'pma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 161" } + T (pma[1].a1, 4); // { dg-warning "'strcpy' offset \\\[162, 165] from the object at 'pma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset 161" } + + T (pma[1].a2, 1); + T (pma[1].a2, 2); // { dg-warning "'strcpy' offset 164 from the object at 'pma' is out of the bounds of referenced subobject 'a2' with type 'char\\\[2]' at offset 162" } + + T (pma[1].a3, 2); + T (pma[1].a3, 3); // { dg-warning "'strcpy' offset 167 from the object at 'pma' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset 164" } + + T (pma[1].a4, 3); + T (pma[1].a4, 4); // { dg-warning "'strcpy' offset 171 from the object at 'pma' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset 167" } + + T (pma[1].a5, 4); + T (pma[1].a5, 5); // { dg-warning "'strcpy' offset 176 from the object at 'pma' is out of the bounds of referenced subobject 'a5' with type 'char\\\[5]' at offset 171" } + + T (pma[1].a17, 16); + T (pma[1].a17, 17); // { dg-warning "'strcpy' offset 314 from the object at 'pma' is out of the bounds of referenced subobject 'a17' with type 'char\\\[17]' at offset 297" } + + /* Since PMA points to an array of structs, accessing the flexible + member of any of the elements of the array except for the last one + would necessarily access a part of the next element of the enclosing + array. The warning assumes that PMA doesn't point to the last element + of the array which could in theory have nonzero elements without + overlapping other objects. */ + T (pma[1].ax, 0); // { dg-warning "'strcpy' offset 314 from the object at 'pma' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 314" } + T ((pma + 1)->ax, 1); // { dg-warning "'strcpy' offset \\\[314, 315] from the object at 'pma' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 314" } + T ((pma + 1)[1].ax, 2); // { dg-warning "'strcpy' offset \\\[471, 473] from the object at 'pma' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 471" } + T ((*(pma + 2)).ax, 2); // { dg-warning "'strcpy' offset \\\[471, 473] from the object at 'pma' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 471" } + T (pma[3].ax, 9); // { dg-warning "'strcpy' offset \\\[628, 637] from the object at 'pma' is out of the bounds of referenced subobject 'ax' with type 'char\\\[]' at offset 628" } + + T (pma[-1].a1, 0); + T (pma[-1].a1, 1); // { dg-warning "'strcpy' offset -152 from the object at 'pma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset -153" } + T (pma[-1].a1, 4); // { dg-warning "'strcpy' offset \\\[-152, -149] from the object at 'pma' is out of the bounds of referenced subobject 'a1' with type 'char\\\[1]' at offset -153" } +} + +struct MA3 +{ + char a4[4]; // { dg-message "'a4' declared here" } + char a3[3]; // { dg-message "'a3' declared here" } + char c; +}; + +void strcpy_ref_note (struct MA17 *pma, struct MA3 *pma3) +{ + T (pma3[-1].a4, 0); + T (pma3[-1].a4, 1); + T (pma3[-1].a4, 2); + T (pma3[-1].a4, 3); + T (pma3[-1].a4, 4); // { dg-warning "'strcpy' offset -4 from the object at 'pma3' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset -8" } + T (pma3[-1].a4, 5); // { dg-warning "'strcpy' offset \\\[-4, -3] from the object at 'pma3' is out of the bounds of referenced subobject 'a4' with type 'char\\\[4]' at offset -8" } + + T (pma3[-1].a3, 0); + T (pma3[-1].a3, 1); + T (pma3[-1].a3, 2); + T (pma3[-1].a3, 3); // { dg-warning "'strcpy' offset -1 from the object at 'pma3' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset -4" } + T (pma3[-1].a3, 4); // { dg-warning "'strcpy' offset \\\[-1, 0] from the object at 'pma3' is out of the bounds of referenced subobject 'a3' with type 'char\\\[3]' at offset -4" } +} + + +void strncpy_vla_member (unsigned n) +{ + struct VarLenStruct { + char a4[4], an[n], bn[n]; + } x; + + sink (&x); + + strncpy (x.bn, x.a4, sizeof x.bn); + sink (&x); + + strncpy (x.a4, x.bn, sizeof x.a4); + x.a4[sizeof x.a4 - 1] = '\0'; + sink (&x); + + strncpy (x.a4, x.bn, n); + sink (&x); + + strncpy (x.an, x.bn, sizeof x.bn); /* { dg-bogus "\\\[-Warray-bounds" } */ + sink (&x); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-47.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-47.c new file mode 100644 index 0000000000..848ef36516 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-47.c @@ -0,0 +1,429 @@ +/* PR middle-end/91830 - Bogus -Warray-bounds on strcpy into a member + of a subobject compiling binutils + { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-overflow -ftrack-macro-expansion=0" } */ + +extern char* strcpy (char*, const char*); +extern void sink (void*); + +#define S36 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + +#define S(N) (S36 + sizeof (S36) - N - 1) + +/* In the test macro, prevent the strcpy to memcpy transformation + by using a local array initialized with the string literal. Without + it, GCC transforms the strcpy call with memcpy which (unfortunately) + permits accesses that cross subobject boundaries. */ +#define T(obj, mem, n) \ + do { \ + struct A *pa = &obj; \ + const char a[] = S36; \ + strcpy (pa->mem, a + sizeof a - n - 1); \ + sink (&obj); \ + } while (0) + + +struct A { char a[3]; char b[5]; }; +struct B { char c[7]; struct A a; struct A a2[2]; }; + +extern struct B b[]; + +void array_nowarn (int i) +{ + struct B *pb = b; + + T (pb[0].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[1].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[123].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[i].a, a, 0); + T (pb[i].a, a, 1); + T (pb[i].a, a, 2); + + + T (pb[0].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a, b, 0); + T (pb[i].a, b, 1); + T (pb[i].a, b, 2); + T (pb[i].a, b, 3); + T (pb[i].a, b, 4); + + + T (pb[0].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a2[0], b, 0); + T (pb[i].a2[0], b, 1); + T (pb[i].a2[0], b, 2); + T (pb[i].a2[0], b, 3); + T (pb[i].a2[0], b, 4); + + T (pb[i].a2[1], b, 0); + T (pb[i].a2[1], b, 1); + T (pb[i].a2[1], b, 2); + T (pb[i].a2[1], b, 3); + T (pb[i].a2[1], b, 4); +} + +void array_warn (int i) +{ + struct B *pb = b; + + T (pb[0].a, a, 3); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a, a, 4); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a, a, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a, a, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a, a, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a, a, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a, a, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, a, 8); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + + T (pb[0].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a, b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + + T (pb[0].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + T (pb[0].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } +} + +void ptr_nowarn (struct B *pb, int i) +{ + T (pb[-123].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[-123].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[-123].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[-2].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[-2].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[-2].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[-1].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[-1].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[-1].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[0].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[1].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[123].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a, a, 2); // { dg-bogus "\\\[-W" } + + T (pb[i].a, a, 0); // { dg-bogus "\\\[-W" } + T (pb[i].a, a, 1); // { dg-bogus "\\\[-W" } + T (pb[i].a, a, 2); // { dg-bogus "\\\[-W" } + + + T (pb[-123].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[-123].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[-123].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[-123].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[-123].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-2].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[-2].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[-2].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[-2].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[-2].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-1].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[-1].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[-1].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[-1].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[-1].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[0].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a, b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a, b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a, b, 0); + T (pb[i].a, b, 1); + T (pb[i].a, b, 2); + T (pb[i].a, b, 3); + T (pb[i].a, b, 4); + + + T (pb[-123].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-2].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-1].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[0].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a2[0], b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a2[0], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a2[0], b, 0); + T (pb[i].a2[0], b, 1); + T (pb[i].a2[0], b, 2); + T (pb[i].a2[0], b, 3); + T (pb[i].a2[0], b, 4); + + T (pb[-123].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-123].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-2].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-2].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[-1].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[-1].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[0].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[0].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[0].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[0].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[0].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[1].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[1].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[1].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[1].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[1].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[123].a2[1], b, 0); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 1); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 2); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 3); // { dg-bogus "\\\[-W" } + T (pb[123].a2[1], b, 4); // { dg-bogus "\\\[-W" } + + T (pb[i].a2[1], b, 0); + T (pb[i].a2[1], b, 1); + T (pb[i].a2[1], b, 2); + T (pb[i].a2[1], b, 3); + T (pb[i].a2[1], b, 4); + + T (pb[i].a2[i], b, 0); + T (pb[i].a2[i], b, 1); + T (pb[i].a2[i], b, 2); + T (pb[i].a2[i], b, 3); + T (pb[i].a2[i], b, 4); +} + +void ptr_warn (struct B *pb, int i) +{ + T (pb[-987].a, a, 8); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-654].a, a, 7); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-2].a, a, 6); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-2].a, a, 5); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-1].a, a, 3); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-1].a, a, 4); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[0].a, a, 3); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a, a, 4); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a, a, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a, a, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a, a, 7); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a, a, 8); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a, a, 3); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, a, 4); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, a, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + + T (pb[-987].a, b, 10); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-654].a, b, 9); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-2].a, b, 8); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-2].a, b, 7); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-1].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-1].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[0].a, b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a, b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a, b, 7); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a, b, 8); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a, b, 9); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a, b, 10); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a, b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a, b, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + + T (pb[-987].a2[0], b, 10); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-654].a2[0], b, 9); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-2].a2[0], b, 8); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-2].a2[0], b, 7); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-1].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-1].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[0].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a2[0], b, 7); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a2[0], b, 8); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a2[0], b, 9); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a2[0], b, 10); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a2[0], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[0], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[0], b, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + T (pb[-987].a2[1], b, 10); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-654].a2[1], b, 9); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-2].a2[1], b, 8); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-2].a2[1], b, 7); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[-1].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + T (pb[-1].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[0].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" } + T (pb[0].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[1].a2[1], b, 7); // { dg-warning "\\\[-Warray-bounds" } + T (pb[1].a2[1], b, 8); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[789].a2[1], b, 9); // { dg-warning "\\\[-Warray-bounds" } + T (pb[789].a2[1], b, 10); // { dg-warning "\\\[-Warray-bounds" } + + T (pb[i].a2[1], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[1], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[1], b, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + + T (pb[i].a2[i], b, 5); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[i], b, 6); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } + T (pb[i].a2[i], b, 7); // { dg-warning "\\\[-Warray-bounds" "pr91848" { xfail *-*-* } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-48-novec.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-48-novec.c new file mode 100644 index 0000000000..5cae856620 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-48-novec.c @@ -0,0 +1,366 @@ +/* PR middle-end/91647 - missing -Warray-bounds accessing a zero-length array + of a declared object + { dg-do "compile" } + { dg-options "-O2 -Wall -fno-tree-vectorize" } + { dg-require-effective-target alloca } */ + +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; + +void sink (void*); + +/* Exercise a true flexible member. */ + +struct AX +{ + int32_t n; + int16_t ax[]; // { dg-message "while referencing 'ax'" "member" } +}; + +static void warn_ax_local (struct AX *p) +{ + p->ax[0] = 0; // { dg-warning "\\\[-Warray-bounds" } + p->ax[1] = 1; // { dg-warning "\\\[-Warray-bounds" } +} + +static void nowarn_ax_extern (struct AX *p) +{ + p->ax[0] = 0; p->ax[99] = 99; p->ax[999] = 999; p->ax[9999] = 9999; +} + +static void warn_ax_local_buf (struct AX *p) +{ + p->ax[0] = 4; p->ax[1] = 5; + + p->ax[2] = 6; // { dg-warning "\\\[-Warray-bounds" } + p->ax[3] = 7; // { dg-warning "\\\[-Warray-bounds" } + p->ax[4] = 8; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_ax_extern_buf (struct AX *p) +{ + p->ax[0] = 9; p->ax[1] = 10; p->ax[2] = 11; + + p->ax[3] = 12; // { dg-warning "\\\[-Warray-bounds" } + p->ax[4] = 13; // { dg-warning "\\\[-Warray-bounds" } + p->ax[5] = 14; // { dg-warning "\\\[-Warray-bounds" } +} + +static void nowarn_ax_extern_bufx (struct AX *p) +{ + p->ax[0] = 0; p->ax[99] = 99; p->ax[999] = 999; p->ax[9999] = 9999; +} + +static void nowarn_ax_ref (struct AX *p) +{ + p->ax[0] = 0; p->ax[99] = 99; p->ax[999] = 999; p->ax[9999] = 9999; +} + +void test_ax (struct AX *p, unsigned n) +{ + { + struct AX sax; // { dg-message "defined here" "struct definition" } + warn_ax_local (&sax); + sink (&sax); + } + + { + extern + struct AX xsax; + nowarn_ax_extern (&xsax); + sink (&xsax); + } + + { + /* Verify out-of-bounds access to the local BUF is diagnosed. */ + char ax_buf_p2[sizeof (struct AX) + 2 * sizeof (int16_t)]; + warn_ax_local_buf ((struct AX*) ax_buf_p2); + sink (ax_buf_p2); + } + + { + /* Verify out-of-bounds access to the extern BUF with a known + bound is diagnosed. */ + extern char ax_buf_p3[sizeof (struct AX) + 3 * sizeof (int16_t)]; + warn_ax_extern_buf ((struct AX*) ax_buf_p3); + sink (ax_buf_p3); + } + + { + /* Verify that accesses to BUFX with an unknown bound are not + diagnosed. */ + extern char bufx[]; + nowarn_ax_extern_bufx ((struct AX*) bufx); + sink (bufx); + } + + { + /* Verify that accesses to BUFN with a runtime bound are not + diagnosed. */ + char bufn[n]; + nowarn_ax_extern_bufx ((struct AX*) bufn); + sink (bufn); + } + + nowarn_ax_ref (p); +} + + +/* Exercise a zero-length trailing member array. It's the same as above + except that extern declarations with no definitions are considered to + have zero elements (they can't be initialized to have any). */ + +struct A0 +{ + int32_t n; + int16_t a0[0]; // { dg-message "while referencing 'a0'" "member" } +}; + +static void warn_a0_local (struct A0 *p) +{ + p->a0[0] = 0; // { dg-warning "\\\[-Warray-bounds" } + p->a0[1] = 1; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a0_extern (struct A0 *p) +{ + p->a0[0] = 2; // { dg-warning "\\\[-Warray-bounds" } + p->a0[1] = 3; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a0_local_buf (struct A0 *p) +{ + p->a0[0] = 4; p->a0[1] = 5; + + p->a0[2] = 6; // { dg-warning "\\\[-Warray-bounds" } + p->a0[3] = 7; // { dg-warning "\\\[-Warray-bounds" } + p->a0[4] = 8; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a0_extern_buf (struct A0 *p) +{ + p->a0[0] = 9; p->a0[1] = 10; p->a0[2] = 11; + + p->a0[3] = 12; // { dg-warning "\\\[-Warray-bounds" } + p->a0[4] = 13; // { dg-warning "\\\[-Warray-bounds" } + p->a0[5] = 14; // { dg-warning "\\\[-Warray-bounds" } +} + +static void nowarn_a0_extern_bufx (struct A0 *p) +{ + p->a0[0] = 0; p->a0[99] = 99; p->a0[999] = 999; p->a0[9999] = 9999; +} + +static void nowarn_a0_ref (struct A0 *p) +{ + p->a0[0] = 0; p->a0[99] = 99; p->a0[999] = 999; p->a0[9999] = 9999; +} + +void test_a0 (struct A0 *p, unsigned n) +{ + { + struct A0 sa0; // { dg-message "defined here" "struct definition" } + warn_a0_local (&sa0); + sink (&sa0); + } + + { + extern + struct A0 xsa0; // { dg-message "defined here" "struct definition" } + warn_a0_extern (&xsa0); + sink (&xsa0); + } + + { + /* Verify out-of-bounds access to the local BUF is diagnosed. */ + char a0_buf_p2[sizeof (struct A0) + 2 * sizeof (int16_t)]; + warn_a0_local_buf ((struct A0*) a0_buf_p2); + sink (a0_buf_p2); + } + + { + /* Verify out-of-bounds access to the extern BUF with a known + bound is diagnosed. */ + extern char a0_buf_p3[sizeof (struct A0) + 3 * sizeof (int16_t)]; + warn_a0_extern_buf ((struct A0*) a0_buf_p3); + sink (a0_buf_p3); + } + + { + /* Verify that accesses to BUFX with an unknown bound are not + diagnosed. */ + extern char bufx[]; + nowarn_a0_extern_bufx ((struct A0*) bufx); + sink (bufx); + } + + { + /* Verify that accesses to BUFN with a runtime bound are not + diagnosed. */ + char bufn[n]; + nowarn_a0_extern_bufx ((struct A0*) bufn); + sink (bufn); + } + + nowarn_a0_ref (p); +} + + +/* Exercise a one-element trailing member array. It's the same as above + except that it has exactly one element. */ + +struct A1 +{ + int32_t n; + int16_t a1[1]; // { dg-message "while referencing 'a1'" } +}; + +static void warn_a1_local_noinit (struct A1 *p) +{ + p->a1[0] = 0; + p->a1[1] = 1; // { dg-warning "\\\[-Warray-bounds" } + p->a1[2] = 2; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a1_extern (struct A1 *p) +{ + p->a1[0] = 0; + p->a1[1] = 1; // { dg-warning "\\\[-Warray-bounds" } + p->a1[2] = 2; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a1_init (struct A1 *p) +{ + p->a1[0] = 0; + p->a1[1] = 1; // { dg-warning "\\\[-Warray-bounds" } + p->a1[2] = 2; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a1_local_buf (struct A1 *p) +{ + p->a1[0] = 0; p->a1[1] = 1; p->a1[2] = 2; + + p->a1[3] = 3; // { dg-warning "\\\[-Warray-bounds" "" { target default_packed } } + p->a1[4] = 4; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a1_extern_buf (struct A1 *p) +{ + p->a1[0] = 0; p->a1[1] = 1; p->a1[2] = 2; p->a1[3] = 3; + + p->a1[4] = 4; // { dg-warning "\\\[-Warray-bounds" "" { target default_packed } } + p->a1[5] = 5; // { dg-warning "\\\[-Warray-bounds" } +} + +static void nowarn_a1_extern_bufx (struct A1 *p) +{ + p->a1[0] = 0; p->a1[99] = 99; p->a1[999] = 999; p->a1[9999] = 9999; +} + +static void nowarn_a1_ref (struct A1 *p) +{ + p->a1[0] = 0; p->a1[99] = 99; p->a1[999] = 999; p->a1[9999] = 9999; +} + +void test_a1 (struct A1 *p, unsigned n) +{ + { + struct A1 a1; + warn_a1_local_noinit (&a1); + sink (&a1); + } + + { + extern struct A1 a1x; + warn_a1_extern (&a1x); + sink (&a1x); +} + { + struct A1 a1 = { 0, { 1 } }; + warn_a1_init (&a1); + sink (&a1); + } + + { + /* Verify out-of-bounds access to the local BUF is diagnosed. */ + char buf_p2[sizeof (struct A1) + 2 * sizeof (int16_t)]; + warn_a1_local_buf ((struct A1*) buf_p2); + sink (buf_p2); + } + + { + /* Verify out-of-bounds access to the extern BUF with a known + bound is diagnosed. */ + extern char a1_buf_p3[sizeof (struct A1) + 3 * sizeof (int16_t)]; + warn_a1_extern_buf ((struct A1*) a1_buf_p3); + sink (a1_buf_p3); + } + + { + /* Verify that accesses to BUFX with an unknown bound are not + diagnosed. */ + extern char bufx[]; + nowarn_a1_extern_bufx ((struct A1*) bufx); + sink (bufx); + } + + { + /* Verify that accesses to BUFN with a runtime bound are not + diagnosed. */ + char bufn[n]; + nowarn_a1_extern_bufx ((struct A1*) bufn); + sink (bufn); + } + + nowarn_a1_ref (p); +} + + +/* Exercise a two-element trailing member array. It's treated + the same as an interior array member. */ + +struct A2 +{ + int32_t n; + int16_t a2[2]; // { dg-message "while referencing 'a2'" } +}; + +static void warn_a2_noinit (struct A2 *p) +{ + p->a2[0] = 0; p->a2[1] = 1; + + p->a2[2] = 2; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a2_init (struct A2 *p) +{ + p->a2[0] = 0; p->a2[1] = 1; + + p->a2[2] = 2; // { dg-warning "\\\[-Warray-bounds" } + p->a2[9] = 9; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a2_ref (struct A2 *p) +{ + p->a2[0] = 0; p->a2[1] = 1; + + p->a2[2] = 2; // { dg-warning "\\\[-Warray-bounds" } + p->a2[9] = 9; // { dg-warning "\\\[-Warray-bounds" } +} + +void test_a2 (struct A2 *p) +{ + { + struct A2 a2; + warn_a2_noinit (&a2); + sink (&a2); + } + + { + struct A2 a2 = { 0, { 1, 2 } }; + warn_a2_init (&a2); + sink (&a2); + } + + warn_a2_ref (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-48.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-48.c new file mode 100644 index 0000000000..e9203140a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-48.c @@ -0,0 +1,372 @@ +/* PR middle-end/91647 - missing -Warray-bounds accessing a zero-length array + of a declared object + { dg-do "compile" } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +/* pr102706: disabled warnings because the now-disabled conditions for the + bogus warnings to come up do not take cost analysis into account, and often + come up wrong. */ +/* { dg-additional-options "-Wno-stringop-overflow" } */ + +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; + +void sink (void*); + +/* Exercise a true flexible member. */ + +struct AX +{ + int32_t n; + int16_t ax[]; // { dg-message "while referencing 'ax'" "member" } +}; + +static void warn_ax_local (struct AX *p) +{ + p->ax[0] = 0; // { dg-warning "\\\[-Warray-bounds" } + p->ax[1] = 1; // { dg-warning "\\\[-Warray-bounds" } +} + +static void nowarn_ax_extern (struct AX *p) +{ + p->ax[0] = 0; p->ax[99] = 99; p->ax[999] = 999; p->ax[9999] = 9999; +} + +static void warn_ax_local_buf (struct AX *p) +{ + p->ax[0] = 4; p->ax[1] = 5; // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" } + // { xfail { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } + + p->ax[2] = 6; // { dg-warning "\\\[-Warray-bounds" } + p->ax[3] = 7; // { dg-warning "\\\[-Warray-bounds" } + p->ax[4] = 8; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_ax_extern_buf (struct AX *p) +{ + p->ax[0] = 9; p->ax[1] = 10; p->ax[2] = 11; + + p->ax[3] = 12; // { dg-warning "\\\[-Warray-bounds" } + p->ax[4] = 13; // { dg-warning "\\\[-Warray-bounds" } + p->ax[5] = 14; // { dg-warning "\\\[-Warray-bounds" } +} + +static void nowarn_ax_extern_bufx (struct AX *p) +{ + p->ax[0] = 0; p->ax[99] = 99; p->ax[999] = 999; p->ax[9999] = 9999; +} + +static void nowarn_ax_ref (struct AX *p) +{ + p->ax[0] = 0; p->ax[99] = 99; p->ax[999] = 999; p->ax[9999] = 9999; +} + +void test_ax (struct AX *p, unsigned n) +{ + { + struct AX sax; // { dg-message "defined here" "struct definition" } + warn_ax_local (&sax); + sink (&sax); + } + + { + extern + struct AX xsax; + nowarn_ax_extern (&xsax); + sink (&xsax); + } + + { + /* Verify out-of-bounds access to the local BUF is diagnosed. */ + char ax_buf_p2[sizeof (struct AX) + 2 * sizeof (int16_t)]; + warn_ax_local_buf ((struct AX*) ax_buf_p2); + sink (ax_buf_p2); + } + + { + /* Verify out-of-bounds access to the extern BUF with a known + bound is diagnosed. */ + extern char ax_buf_p3[sizeof (struct AX) + 3 * sizeof (int16_t)]; + warn_ax_extern_buf ((struct AX*) ax_buf_p3); + sink (ax_buf_p3); + } + + { + /* Verify that accesses to BUFX with an unknown bound are not + diagnosed. */ + extern char bufx[]; + nowarn_ax_extern_bufx ((struct AX*) bufx); + sink (bufx); + } + + { + /* Verify that accesses to BUFN with a runtime bound are not + diagnosed. */ + char bufn[n]; + nowarn_ax_extern_bufx ((struct AX*) bufn); + sink (bufn); + } + + nowarn_ax_ref (p); +} + + +/* Exercise a zero-length trailing member array. It's the same as above + except that extern declarations with no definitions are considered to + have zero elements (they can't be initialized to have any). */ + +struct A0 +{ + int32_t n; + int16_t a0[0]; // { dg-message "while referencing 'a0'" "member" } +}; + +static void warn_a0_local (struct A0 *p) +{ + p->a0[0] = 0; // { dg-warning "\\\[-Warray-bounds" } + p->a0[1] = 1; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a0_extern (struct A0 *p) +{ + p->a0[0] = 2; // { dg-warning "\\\[-Warray-bounds" } + p->a0[1] = 3; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a0_local_buf (struct A0 *p) +{ + p->a0[0] = 4; p->a0[1] = 5; // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" } + // { xfail { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } + + p->a0[2] = 6; // { dg-warning "\\\[-Warray-bounds" } + p->a0[3] = 7; // { dg-warning "\\\[-Warray-bounds" } + p->a0[4] = 8; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a0_extern_buf (struct A0 *p) +{ + p->a0[0] = 9; p->a0[1] = 10; p->a0[2] = 11; + + p->a0[3] = 12; // { dg-warning "\\\[-Warray-bounds" } + p->a0[4] = 13; // { dg-warning "\\\[-Warray-bounds" } + p->a0[5] = 14; // { dg-warning "\\\[-Warray-bounds" } +} + +static void nowarn_a0_extern_bufx (struct A0 *p) +{ + p->a0[0] = 0; p->a0[99] = 99; p->a0[999] = 999; p->a0[9999] = 9999; +} + +static void nowarn_a0_ref (struct A0 *p) +{ + p->a0[0] = 0; p->a0[99] = 99; p->a0[999] = 999; p->a0[9999] = 9999; +} + +void test_a0 (struct A0 *p, unsigned n) +{ + { + struct A0 sa0; // { dg-message "defined here" "struct definition" } + warn_a0_local (&sa0); + sink (&sa0); + } + + { + extern + struct A0 xsa0; // { dg-message "defined here" "struct definition" } + warn_a0_extern (&xsa0); + sink (&xsa0); + } + + { + /* Verify out-of-bounds access to the local BUF is diagnosed. */ + char a0_buf_p2[sizeof (struct A0) + 2 * sizeof (int16_t)]; + warn_a0_local_buf ((struct A0*) a0_buf_p2); + sink (a0_buf_p2); + } + + { + /* Verify out-of-bounds access to the extern BUF with a known + bound is diagnosed. */ + extern char a0_buf_p3[sizeof (struct A0) + 3 * sizeof (int16_t)]; + warn_a0_extern_buf ((struct A0*) a0_buf_p3); + sink (a0_buf_p3); + } + + { + /* Verify that accesses to BUFX with an unknown bound are not + diagnosed. */ + extern char bufx[]; + nowarn_a0_extern_bufx ((struct A0*) bufx); + sink (bufx); + } + + { + /* Verify that accesses to BUFN with a runtime bound are not + diagnosed. */ + char bufn[n]; + nowarn_a0_extern_bufx ((struct A0*) bufn); + sink (bufn); + } + + nowarn_a0_ref (p); +} + + +/* Exercise a one-element trailing member array. It's the same as above + except that it has exactly one element. */ + +struct A1 +{ + int32_t n; + __attribute__ ((aligned (4))) + int16_t a1[1]; // { dg-message "while referencing 'a1'" } +}; + +static void warn_a1_local_noinit (struct A1 *p) +{ + p->a1[0] = 0; + p->a1[1] = 1; // { dg-warning "\\\[-Warray-bounds" } + p->a1[2] = 2; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a1_extern (struct A1 *p) +{ + p->a1[0] = 0; + p->a1[1] = 1; // { dg-warning "\\\[-Warray-bounds" } + p->a1[2] = 2; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a1_init (struct A1 *p) +{ + p->a1[0] = 0; + p->a1[1] = 1; // { dg-warning "\\\[-Warray-bounds" } + p->a1[2] = 2; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a1_local_buf (struct A1 *p) +{ + p->a1[0] = 0; p->a1[1] = 1; p->a1[2] = 2; p->a1[3] = 3; + + p->a1[4] = 4; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a1_extern_buf (struct A1 *p) +{ + p->a1[0] = 0; p->a1[1] = 1; p->a1[2] = 2; p->a1[3] = 3; p->a1[4] = 4; + + p->a1[5] = 5; // { dg-warning "\\\[-Warray-bounds" } +} + +static void nowarn_a1_extern_bufx (struct A1 *p) +{ + p->a1[0] = 0; p->a1[99] = 99; p->a1[999] = 999; p->a1[9999] = 9999; +} + +static void nowarn_a1_ref (struct A1 *p) +{ + p->a1[0] = 0; p->a1[99] = 99; p->a1[999] = 999; p->a1[9999] = 9999; +} + +void test_a1 (struct A1 *p, unsigned n) +{ + { + struct A1 a1; + warn_a1_local_noinit (&a1); + sink (&a1); + } + + { + extern struct A1 a1x; + warn_a1_extern (&a1x); + sink (&a1x); +} + { + struct A1 a1 = { 0, { 1 } }; + warn_a1_init (&a1); + sink (&a1); + } + + { + /* Verify out-of-bounds access to the local BUF is diagnosed. */ + char buf_p2[sizeof (struct A1) + 2 * sizeof (int16_t)]; + warn_a1_local_buf ((struct A1*) buf_p2); + sink (buf_p2); + } + + { + /* Verify out-of-bounds access to the extern BUF with a known + bound is diagnosed. */ + extern char a1_buf_p3[sizeof (struct A1) + 3 * sizeof (int16_t)]; + warn_a1_extern_buf ((struct A1*) a1_buf_p3); + sink (a1_buf_p3); + } + + { + /* Verify that accesses to BUFX with an unknown bound are not + diagnosed. */ + extern char bufx[]; + nowarn_a1_extern_bufx ((struct A1*) bufx); + sink (bufx); + } + + { + /* Verify that accesses to BUFN with a runtime bound are not + diagnosed. */ + char bufn[n]; + nowarn_a1_extern_bufx ((struct A1*) bufn); + sink (bufn); + } + + nowarn_a1_ref (p); +} + + +/* Exercise a two-element trailing member array. It's treated + the same as an interior array member. */ + +struct A2 +{ + int32_t n; + int16_t a2[2]; // { dg-message "while referencing 'a2'" } +}; + +static void warn_a2_noinit (struct A2 *p) +{ + p->a2[0] = 0; p->a2[1] = 1; + + p->a2[2] = 2; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a2_init (struct A2 *p) +{ + p->a2[0] = 0; p->a2[1] = 1; + + p->a2[2] = 2; // { dg-warning "\\\[-Warray-bounds" } + p->a2[9] = 9; // { dg-warning "\\\[-Warray-bounds" } +} + +static void warn_a2_ref (struct A2 *p) +{ + p->a2[0] = 0; p->a2[1] = 1; + + p->a2[2] = 2; // { dg-warning "\\\[-Warray-bounds" } + p->a2[9] = 9; // { dg-warning "\\\[-Warray-bounds" } +} + +void test_a2 (struct A2 *p) +{ + { + struct A2 a2; + warn_a2_noinit (&a2); + sink (&a2); + } + + { + struct A2 a2 = { 0, { 1, 2 } }; + warn_a2_init (&a2); + sink (&a2); + } + + warn_a2_ref (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-49.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-49.c new file mode 100644 index 0000000000..9335f1507e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-49.c @@ -0,0 +1,125 @@ +/* PR middle-end/91647 - missing -Warray-bounds accessing a zero-length array + of a declared object + { dg-do "compile" } + { dg-options "-O2 -Wall" } */ + +struct __attribute__ ((aligned (16))) A16 +{ + __INT64_TYPE__ i8; + __INT16_TYPE__ i2; + __INT16_TYPE__ a2[]; +}; + +struct A16 a0 = { }; + +void test_a0 (void) +{ + // The first three elements fit in the tail padding. + a0.a2[0] = 0; a0.a2[1] = 1; a0.a2[2] = 2; + + a0.a2[3] = 3; // { dg-warning "array subscript 3 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 3 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a1 = { .a2 = { 1 } }; + +void test_a1 (void) +{ + a1.a2[0] = 0; a1.a2[1] = 1; a1.a2[2] = 2; + + a1.a2[3] = 3; // { dg-warning "array subscript 3 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 3 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a2 = { .a2 = { 1, 2 } }; + +void test_a2 (void) +{ + a2.a2[0] = 0; a2.a2[1] = 1; a2.a2[2] = 2; + + a2.a2[3] = 3; // { dg-warning "array subscript 3 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 3 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a3 = { .a2 = { 1, 2, 3 } }; + +void test_a3 (void) +{ + a3.a2[0] = 0; a3.a2[1] = 1; a3.a2[2] = 2; + + a3.a2[3] = 3; // { dg-warning "array subscript 3 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 3 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a4 = { .a2 = { 1, 2, 3, 4 } }; + +void test_a4 (void) +{ + a4.a2[0] = 0; a4.a2[1] = 1; a4.a2[2] = 2; a4.a2[3] = 3; + + a4.a2[4] = 4; // { dg-warning "array subscript 4 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 4 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a5 = { .a2 = { 1, 2, 3, 4, 5 } }; + +void test_a5 (void) +{ + a5.a2[0] = 0; a5.a2[1] = 1; a5.a2[2] = 2; a5.a2[3] = 3; a5.a2[4] = 4; + + a5.a2[5] = 5; // { dg-warning "array subscript 5 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 5 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a6 = { .a2 = { 1, 2, 3, 4, 5, 6 } }; + +void test_a6 (void) +{ + a6.a2[0] = 0; a6.a2[1] = 1; a6.a2[2] = 2; a6.a2[3] = 3; a6.a2[4] = 4; + a6.a2[5] = 5; + + a6.a2[6] = 6; // { dg-warning "array subscript 6 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 6 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a7 = { .a2 = { 1, 2, 3, 4, 5, 6, 7 } }; + +void test_a7 (void) +{ + a7.a2[0] = 0; a7.a2[1] = 1; a7.a2[2] = 2; a7.a2[3] = 3; a7.a2[4] = 4; + a7.a2[5] = 5; a7.a2[5] = 5; a7.a2[6] = 6; + + a7.a2[7] = 7; // { dg-warning "array subscript 7 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 7 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a8 = { .a2 = { 1, 2, 3, 4, 5, 6, 7, 8 } }; + +void test_a8 (void) +{ + a8.a2[0] = 0; a8.a2[1] = 1; a8.a2[2] = 2; a8.a2[3] = 3; a8.a2[4] = 4; + a8.a2[5] = 5; a8.a2[5] = 5; a8.a2[6] = 6; a8.a2[7] = 7; + + a8.a2[8] = 8; // { dg-warning "array subscript 8 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 8 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} + + +struct A16 a9 = { .a2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 } }; + +void test_a9 (void) +{ + a8.a2[0] = 8; a8.a2[1] = 7; a8.a2[2] = 6; a8.a2[3] = 5; a8.a2[4] = 4; + a8.a2[5] = 3; a8.a2[5] = 2; a8.a2[6] = 1; a8.a2[7] = 0; + + a8.a2[9] = 8; // { dg-warning "array subscript 9 is above array bounds of 'short int\\\[]'" "" { target { ! short_eq_int } } } + // { dg-warning "array subscript 9 is above array bounds of 'int\\\[]'" "" { target { short_eq_int } } .-1 } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-5.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-5.c new file mode 100644 index 0000000000..ba9cd2aa03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-5.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wall" } */ +/* based on PR 37861 */ + +extern int printf (__const char *__restrict __format, ...); + +static int f2(char formatstr[10][100]) +{ + int anz; + for( anz = 0; anz < 10; ++anz ) { + printf( "%d %s\n", anz, formatstr[anz] ); + } + return anz; +} + + +static char formatstr[10][100]; +int main( void ) +{ + int anz; + anz = f2(formatstr); + printf( " %d\n",anz); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-50.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-50.c new file mode 100644 index 0000000000..05c89b2d87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-50.c @@ -0,0 +1,115 @@ +/* PR middle-end/92349 - ICE in -Warray-bounds on a VLA member + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*, ...); + +void mem_vla_cst_store_idx (void) +{ + int n = 3; + + struct { + char a[n], b; + } s; + + char *p = s.a; + + s.a[0] = 0; + s.b = 0; + + *++p = 1; + *++p = 2; + + sink (&s, p); +} + +void mem_vla_range_store_idx (int n) +{ + if (n < 3 || 4 < n) + n = 3; + + struct { + char a[n], b; + } s; + + char *p = s.a; + + s.a[0] = 0; + s.b = 0; + + *++p = 1; + *++p = 2; + + sink (&s, p); +} + +void mem_vla_var_store_idx (size_t n) +{ + struct { + char a[n], b; + } s; + + char *p = s.a; + + s.a[0] = 0; + s.b = 0; + + *++p = 1; + *++p = 2; + + sink (&s, p); +} + + +void mem_vla_cst_store_ptr (void) +{ + int n = 3; + + struct { + char a[n], b; + } s; + + char *p = s.a; + + *p++ = __LINE__; + *p++ = __LINE__; + *p++ = __LINE__; + + sink (&s, p); +} + +void mem_vla_range_store_ptr (int n) +{ + if (n < 3 || 4 < n) + n = 3; + + struct { + char a[n], b; + } s; + + char *p = s.a; + + *p++ = __LINE__; + *p++ = __LINE__; + *p++ = __LINE__; + + sink (&s, p); +} + +void mem_vla_var_store_ptr (size_t n) +{ + struct { + char a[n], b; + } s; + + char *p = s.a; + + *p++ = __LINE__; + *p++ = __LINE__; + *p++ = __LINE__; + + sink (&s, p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-51-novec.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-51-novec.c new file mode 100644 index 0000000000..ef8056d9b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-51-novec.c @@ -0,0 +1,21 @@ +/* PR middle-end/92333 - missing variable name referencing VLA in warnings + PR middle-end/82608 - missing -Warray-bounds on an out-of-bounds VLA index + { dg-do compile } + { dg-options "-O2 -Wall -fno-tree-vectorize" } */ + +void sink (void*); + +void test_struct_char_vla_location (void) +{ + unsigned nelts = 7; + + struct { + char cvla[nelts]; // { dg-message "declared here|while referencing" } + } s; + + s.cvla[0] = __LINE__; + s.cvla[nelts - 1] = 0; + s.cvla[nelts] = 0; // { dg-warning "\\\[-Warray-bounds" } + + sink (&s); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-51.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-51.c new file mode 100644 index 0000000000..7519b0fed7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-51.c @@ -0,0 +1,62 @@ +/* PR middle-end/92333 - missing variable name referencing VLA in warnings + PR middle-end/82608 - missing -Warray-bounds on an out-of-bounds VLA index + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-additional-options "-mtune=generic" { target { i?86-*-* x86_64-*-* } } } */ + +void sink (void*); + +void test_char_vla_location (void) +{ + unsigned nelts = 7; + + char vla[nelts]; // { dg-message "declared here|while referencing" } + + vla[0] = __LINE__; + vla[nelts] = 0; // { dg-warning "\\\[-Warray-bounds" } + + sink (vla); +} + +void test_int_vla_location (void) +{ + unsigned nelts = 7; + + int vla[nelts]; // { dg-message "declared here|while referencing" } + + vla[0] = __LINE__; + vla[nelts] = 1; // { dg-warning "\\\[-Warray-bounds" } + + sink (vla); +} + +void test_struct_char_vla_location (void) +{ + unsigned nelts = 7; + + struct { + char cvla[nelts]; // { dg-message "declared here|while referencing" } + } s; + + s.cvla[0] = __LINE__; + s.cvla[nelts - 1] = 0; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2qi_store_align } } } + s.cvla[nelts] = 0; // { dg-warning "\\\[-Warray-bounds" } + + sink (&s); +} + + +void test_struct_int_vla_location (void) +{ + unsigned nelts = 7; + + struct { + int ivla[nelts]; // { dg-message "declared here|while referencing" } + } s; + + s.ivla[0] = __LINE__; + s.ivla[nelts - 1] = 0; + s.ivla[nelts] = 0; // { dg-warning "\\\[-Warray-bounds" } + + sink (&s); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-52.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-52.c new file mode 100644 index 0000000000..d3aab3cbe9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-52.c @@ -0,0 +1,100 @@ +/* PR middle-end/92341 - missing -Warray-bounds indexing past the end + of a compound literal + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-__INT_MAX__ - 1) + +void sink (int, ...); + + +#define T(...) sink (__LINE__, (__VA_ARGS__)) + + +void direct_idx_cst (void) +{ + T ((int[]){ }[-1]); // { dg-warning "array subscript -1 is outside array bounds of 'int\\\[0]'" } + T ((int[]){ }[0]); // { dg-warning "array subscript 0 is outside array bounds of 'int\\\[0]'" } + T ((int[]){ }[1]); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[0]'" } + + T ((int[]){ 1 }[-1]); // { dg-warning "array subscript -1 is below array bounds of 'int\\\[1]'" } + T ((int[]){ 1 }[0]); + T ((int[]){ 1 }[1]); // { dg-warning "array subscript 1 is above array bounds of 'int\\\[1]'" } + T ((int[]){ 1 }[INT_MIN]); // { dg-warning "array subscript -\[0-9\]+ is below array bounds of 'int\\\[1]'" } + T ((int[]){ 1 }[INT_MAX]); // { dg-warning "array subscript \[0-9\]+ is above array bounds of 'int\\\[1]'" } + T ((int[]){ 1 }[SIZE_MAX]); // { dg-warning "array subscript \[0-9\]+ is above array bounds of 'int\\\[1]'" } +} + + +void direct_idx_var (int i) +{ + T ((char[]){ }[i]); // { dg-warning "array subscript i is outside array bounds of 'char\\\[0]'" } + T ((int[]){ }[i]); // { dg-warning "array subscript i is outside array bounds of 'int\\\[0]'" } +} + + +void direct_idx_range (void) +{ + ptrdiff_t i = SR (-2, -1); + + T ((int[]){ 1 }[i]); // { dg-warning "array subscript \[ \n\r]+ is outside array bounds of 'int\\\[0]'" "pr?????" { xfail *-*-* } } +} + + +#undef T +#define T(idx, ...) do { \ + int *p = (__VA_ARGS__); \ + sink (p[idx]); \ + } while (0) + +void ptr_idx_cst (void) +{ + T (-1, (int[]){ }); // { dg-warning "array subscript -1 is outside array bounds of 'int\\\[0]'" } + T ( 0, (int[]){ }); // { dg-warning "array subscript 0 is outside array bounds of 'int\\\[0]'" } + T (+1, (int[]){ }); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[0]'" } + + T (-1, (int[]){ 1 }); // { dg-warning "array subscript -1 is outside array bounds of 'int\\\[1]'" } + T ( 0, (int[]){ 1 }); + T (+1, (int[]){ 1 }); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[1]'" } + T (INT_MIN, (int[]){ 1 }); // { dg-warning "array subscript -\[0-9\]+ is outside array bounds of 'int\\\[1]'" "lp64" { xfail { ilp32 || avr-*-* } } } + T (INT_MAX, (int[]){ 1 }); // { dg-warning "array subscript \[0-9\]+ is outside array bounds of 'int\\\[1]'" "not-ilp32" { target { ! { ilp32 || avr-*-* } } } } + // { dg-warning "array subscript -1 is outside array bounds of 'int\\\[1]'" "ilp32-or-avr" { target { ilp32 || avr-*-* } } .-1 } + T (SIZE_MAX, (int[]){ 1 }); // { dg-warning "array subscript -?\[0-9\]+ is outside array bounds of 'int\\\[1]'" } +} + + +void ptr_idx_var (int i) +{ + T (i, (int[]){ }); // { dg-warning "array subscript \[^\n\r\]+ is outside array bounds of 'int\\\[0]'" } + T (i, (int[]){ 1 }); + T (i, (int[]){ i, 1 }); +} + +void ptr_idx_range (void) +{ + ptrdiff_t i = SR (-2, -1); + + T (i, (int[]){ }); // { dg-warning "array subscript \\\[-2, -1] is outside array bounds of 'int\\\[0]'" } + T (i, (int[]){ 1 }); // { dg-warning "array subscript \\\[-2, -1] is outside array bounds of 'int\\\[1]'" } + T (i, (int[]){ i }); // { dg-warning "array subscript \\\[-2, -1] is outside array bounds of 'int\\\[1]'" } + + i = SR (0, 1); + + T (i, (int[]){ }); // { dg-warning "array subscript 0 is outside array bounds of 'int\\\[0]'" } + T (i, (int[]){ 1 }); + + i = SR (1, 2); + T (i, (int[]){ 1 }); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[1]'" } + + i = SR (2, 3); + T (i, (int[]){ 1, 2, 3 }); + + i = SR (3, 4); + T (i, (int[]){ 2, 3, 4 }); // { dg-warning "array subscript 3 is outside array bounds of 'int\\\[3]'" } +} + +/* Some of the invalid accesses above also trigger -Wuninitialized. + { dg-prune-output "\\\[-Wuninitialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-53.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-53.c new file mode 100644 index 0000000000..591cca28d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-53.c @@ -0,0 +1,100 @@ +/* PR middle-end/92341 - missing -Warray-bounds indexing past the end + of a compound literal + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-__INT_MAX__ - 1) + +void sink (int, ...); + + +#define T(...) sink (__LINE__, (__VA_ARGS__)) + + +void direct_idx_cst (void) +{ + T ((int[]){ }[-1]); // { dg-warning "array subscript -1 is outside array bounds of 'int\\\[0]'" } + T ((int[]){ }[0]); // { dg-warning "array subscript 0 is outside array bounds of 'int\\\[0]'" } + T ((int[]){ }[1]); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[0]'" } + + T ((int[]){ 1 }[-1]); // { dg-warning "array subscript -1 is below array bounds of 'int\\\[1]'" } + T ((int[]){ 1 }[0]); + T ((int[]){ 1 }[1]); // { dg-warning "array subscript 1 is above array bounds of 'int\\\[1]'" } + T ((int[]){ 1 }[INT_MIN]); // { dg-warning "array subscript -\[0-9\]+ is below array bounds of 'int\\\[1]'" } + T ((int[]){ 1 }[INT_MAX]); // { dg-warning "array subscript \[0-9\]+ is above array bounds of 'int\\\[1]'" } + T ((int[]){ 1 }[SIZE_MAX]); // { dg-warning "array subscript \[0-9\]+ is above array bounds of 'int\\\[1]'" } +} + + +void direct_idx_var (int i) +{ + T ((char[]){ }[i]); // { dg-warning "array subscript i is outside array bounds of 'char\\\[0]'" } + T ((int[]){ }[i]); // { dg-warning "array subscript i is outside array bounds of 'int\\\[0]'" } +} + + +void direct_idx_range (void) +{ + ptrdiff_t i = SR (-2, -1); + + T ((int[]){ 1 }[i]); // { dg-warning "array subscript \[ \n\r]+ is outside array bounds of 'int\\\[0]'" "pr?????" { xfail *-*-* } } +} + + +#undef T +#define T(idx, ...) do { \ + int *p = (__VA_ARGS__); \ + sink (p[idx]); \ + } while (0) + +void ptr_idx_cst (void) +{ + T (-1, (int[]){ }); // { dg-warning "array subscript -1 is outside array bounds of 'int\\\[0]'" } + T ( 0, (int[]){ }); // { dg-warning "array subscript 0 is outside array bounds of 'int\\\[0]'" } + T (+1, (int[]){ }); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[0]'" } + + T (-1, (int[]){ 1 }); // { dg-warning "array subscript -1 is outside array bounds of 'int\\\[1]'" } + T ( 0, (int[]){ 1 }); + T (+1, (int[]){ 1 }); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[1]'" } + T (INT_MIN, (int[]){ 1 }); // { dg-warning "array subscript -\[0-9\]+ is outside array bounds of 'int\\\[1]'" "pr92381" { xfail ilp32 } } + T (INT_MAX, (int[]){ 1 }); // { dg-warning "array subscript \[0-9\]+ is outside array bounds of 'int\\\[1]'" "pr92381" { xfail ilp32 } } + // { dg-warning "array subscript -\[0-9\]+ is outside array bounds of 'int\\\[1]'" "" { target ilp32 } .-1 } + T (SIZE_MAX, (int[]){ 1 }); // { dg-warning "array subscript -?\[0-9\]+ is outside array bounds of 'int\\\[1]'" } +} + + +void ptr_idx_var (int i) +{ + T (i, (int[]){ }); // { dg-warning "array subscript \[^\n\r\]+ is outside array bounds of 'int\\\[0]'" } + T (i, (int[]){ 1 }); + T (i, (int[]){ i, 1 }); +} + +void ptr_idx_range (void) +{ + ptrdiff_t i = SR (-2, -1); + + T (i, (int[]){ }); // { dg-warning "array subscript \\\[-2, -1] is outside array bounds of 'int\\\[0]'" } + T (i, (int[]){ 1 }); // { dg-warning "array subscript \\\[-2, -1] is outside array bounds of 'int\\\[1]'" } + T (i, (int[]){ i }); // { dg-warning "array subscript \\\[-2, -1] is outside array bounds of 'int\\\[1]'" } + + i = SR (0, 1); + + T (i, (int[]){ }); // { dg-warning "array subscript 0 is outside array bounds of 'int\\\[0]'" } + T (i, (int[]){ 1 }); + + i = SR (1, 2); + T (i, (int[]){ 1 }); // { dg-warning "array subscript 1 is outside array bounds of 'int\\\[1]'" } + + i = SR (2, 3); + T (i, (int[]){ 1, 2, 3 }); + + i = SR (3, 4); + T (i, (int[]){ 2, 3, 4 }); // { dg-warning "array subscript 3 is outside array bounds of 'int\\\[3]'" } +} + +/* Some of the invalid accesses above also trigger -Wuninitialized. + { dg-prune-output "\\\[-Wuninitialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-54.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-54.c new file mode 100644 index 0000000000..5df5710c1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-54.c @@ -0,0 +1,26 @@ +/* PR middle-end/82612 - missing -Warray-bounds on a non-zero offset + from the address of a non-array object + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +int i; +int f0 (void) +{ + int *p = &i; + return p[2]; // { dg-warning "-Warray-bounds" } +} + +int f1 (int j) +{ + int i = j; + int *p = &i; + return p[2]; // { dg-warning "-Warray-bounds" } +} + +int f2 (int i) +{ + int *p = &i; + return p[2]; // { dg-warning "-Warray-bounds" } +} + +/* { dg-prune-output "-Wuninitialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-55.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-55.c new file mode 100644 index 0000000000..b7dfe70685 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-55.c @@ -0,0 +1,28 @@ +/* PR middle-end/92373 - ICE in -Warray-bounds on access to member array + in an initialized char buffer + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void sink (void*); + +struct S +{ + char data[1]; +}; + +char a[6] = { }; + +int f (void) +{ + struct S *p = (struct S*)a; + return p->data[4]; + +} + +void g (void) +{ + char b[6] = { }; + struct S *p = (struct S*)b; + p->data[4] = 0; + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-56.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-56.c new file mode 100644 index 0000000000..04c26a659a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-56.c @@ -0,0 +1,90 @@ +/* PR middle-end/91582 - missing heap overflow detection for strcpy + + The -Warray-bounds instances here probably should be replaced by + -Wstringop-overflow when it detects these overflows (see also + the xfails in Wstringop-overflow-25.c). + + { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-overflow -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) +#define NOIPA ATTR (noipa) + +extern void* malloc (size_t); +extern char* strcpy (char*, const char*); + +void sink (void*); + +#define S36 "0123456789abcdefghijklmnopqrstuvwxyz" +#define S(N) (S36 + sizeof S36 - N - 1) + +struct Flex +{ + char n, ax[]; +}; + +extern struct Flex fx; +struct Flex f1 = { 1, { 1 } }; +struct Flex f2 = { 2, { 1, 2 } }; +struct Flex f3 = { 3, { 1, 2, 3 } }; + +#define T(src, f) do { \ + char *s = src; \ + char *d = f.ax; \ + strcpy (d, s); \ + sink (&f); \ + } while (0) + +NOIPA void test_strcpy_flexarray (void) +{ + T (S (0), fx); // { dg-bogus "\\\[-Warray-bounds" "pr92815" } + T (S (9), fx); // { dg-bogus "\\\[-Warray-bounds" "pr92815" } + + T (S (0), f1); + T (S (1), f1); // { dg-warning "\\\[-Warray-bounds" } + + T (S (0), f2); + T (S (1), f2); + T (S (2), f2); // { dg-warning "\\\[-Warray-bounds" } + + T (S (0), f3); + T (S (2), f3); + T (S (3), f3); // { dg-warning "\\\[-Warray-bounds" } + T (S (9), f3); // { dg-warning "\\\[-Warray-bounds" } +} + +#undef T +#define T(T, src, n) do { \ + char *s = src; \ + typedef struct { T n, ax[]; } Flex; \ + Flex *p = (Flex*)malloc (sizeof *p + n); \ + char *d = (char*)p->ax; \ + strcpy (d, s); \ + sink (p); \ + } while (0) + +NOIPA void test_strcpy_malloc_flexarray (void) +{ + size_t r_0_1 = UR (0, 1); + + T (char, S (0), r_0_1); + T (char, S (1), r_0_1); // { dg-warning "\\\[-Warray-bounds" } + + size_t r_1_2 = UR (1, 2); + + T (char, S (0), r_1_2); + T (char, S (1), r_1_2); + T (char, S (2), r_1_2); // { dg-warning "\\\[-Warray-bounds" } + + size_t r_2_3 = UR (2, 3); + + T (char, S (0), r_2_3); + T (char, S (2), r_2_3); + T (char, S (3), r_2_3); // { dg-warning "\\\[-Warray-bounds" } + T (char, S (9), r_2_3); // { dg-warning "\\\[-Warray-bounds" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-57.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-57.c new file mode 100644 index 0000000000..97e9ce47bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-57.c @@ -0,0 +1,53 @@ +/* PR middle-end/92323 - bogus -Warray-bounds after unrolling despite + __builtin_unreachable + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct S { int a[5]; } s; + +void sink (void*); + +#pragma GCC optimize "2" + +void f_O2 (unsigned n, struct S *p) +{ + for (unsigned i = 1; i < n - 1; ++i) + s.a[i - 1] = p->a[i]; // { dg-bogus "\\\[-Warray-bounds" } + + if (n < 4 || n > 5) + __builtin_unreachable (); +} + +void g_O2 (unsigned n, struct S *p) +{ + if (n < 4 || n > 5) + __builtin_unreachable (); + + for (unsigned i = 1; i < n - 1; ++i) + s.a[i - 1] = p->a[i]; +} + + +// Also exercise -O3 with loop unrolling for good measure. + +#pragma GCC optimize "3" + +struct T { int a[6]; } t; + +void f_O3 (unsigned n, struct T *p) +{ + for (unsigned i = 1; i < n - 1; ++i) + t.a[i - 1] = p->a[i]; // { dg-bogus "\\\[-Warray-bounds" } + + if (n < 5 || n > 6) + __builtin_unreachable (); +} + +void g_O3 (unsigned n, struct T *p) +{ + if (n < 5 || n > 6) + __builtin_unreachable (); + + for (unsigned i = 1; i < n - 1; ++i) + s.a[i - 1] = p->a[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-58.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-58.c new file mode 100644 index 0000000000..616145b65a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-58.c @@ -0,0 +1,81 @@ +/* { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-overread" } */ + +typedef __SIZE_TYPE__ size_t; + +extern size_t strlen (const char*); + +void sink (size_t); + +struct A0 { char i, a[0]; }; + +extern struct A0 ea0; + +void fa0_extern (void) +{ + sink (strlen (ea0.a - 2)); // { dg-warning "\\\[-Warray-bounds" } + sink (strlen (ea0.a - 1)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } } + sink (strlen (ea0.a)); // valid just-past-the-end offset + sink (strlen (ea0.a + 1)); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } +} + +static struct A0 sa0 = { 0 }; + +void fa0_static (void) +{ + sink (strlen (sa0.a - 2)); // { dg-warning "\\\[-Warray-bounds" } + sink (strlen (sa0.a - 1)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } } + sink (strlen (sa0.a)); // valid just-past-the-end offset + sink (strlen (sa0.a + 1)); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } +} + + +struct Ax { char i, a[]; }; + +extern struct Ax ax; + +void fax_extern (void) +{ + sink (strlen (ax.a - 2)); // { dg-warning "\\\[-Warray-bounds" "pr93514" } + sink (strlen (ax.a - 1)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } } + sink (strlen (ax.a)); + sink (strlen (ax.a + 123)); +} + +static struct Ax ax0 = { 0, { 0 } }; +static struct Ax ax1 = { 1, { 1, 0 } }; +static struct Ax ax2 = { 2, { 2, 1, 0 } }; +static struct Ax ax3 = { 3, { 3, 2, 1, 0 } }; + +void fax_static (void) +{ + sink (strlen (ax0.a - 2)); // { dg-warning "\\\[-Warray-bounds" } + sink (strlen (ax0.a - 1)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } } + sink (strlen (ax0.a)); + sink (strlen (ax0.a + 1)); // valid just-past-the-end offset + sink (strlen (ax0.a + 2)); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } + + sink (strlen (ax1.a - 2)); // { dg-warning "\\\[-Warray-bounds" } + sink (strlen (ax1.a - 1)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } } + sink (strlen (ax1.a)); + sink (strlen (ax1.a + 1)); + sink (strlen (ax1.a + 2)); // valid just-past-the-end offset + sink (strlen (ax1.a + 3)); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } + + sink (strlen (ax2.a - 2)); // { dg-warning "\\\[-Warray-bounds" } + sink (strlen (ax2.a - 1)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } } + sink (strlen (ax2.a)); + sink (strlen (ax2.a + 1)); + sink (strlen (ax2.a + 2)); + sink (strlen (ax2.a + 3)); // valid just-past-the-end offset + sink (strlen (ax2.a + 4)); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } + + sink (strlen (ax3.a - 2)); // { dg-warning "\\\[-Warray-bounds" } + sink (strlen (ax3.a - 1)); // { dg-warning "\\\[-Warray-bounds" "pr93514" { xfail *-*-* } } + sink (strlen (ax3.a)); + sink (strlen (ax3.a + 1)); + sink (strlen (ax3.a + 2)); + sink (strlen (ax3.a + 3)); + sink (strlen (ax3.a + 4)); // valid just-past-the-end offset + sink (strlen (ax3.a + 5)); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-59.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-59.c new file mode 100644 index 0000000000..99b18fce75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-59.c @@ -0,0 +1,30 @@ +/* PR middle-end/94647 - bogus -Warray-bounds on strncpy into a larger + member array from a smaller array + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern char* strncpy (char*, const char*, size_t); + + +char a4[4], a8[8]; + +void nowarn_nonmeber (void) +{ + /* The following would deserve a warning if A4 were known not to be + nul-terminated (or declared with attribute nonstring). */ + strncpy (a8, a4, sizeof a8); +} +struct S +{ + char a4[4], a8[8]; +}; + +void nowarn_member (struct S *p, struct S *q) +{ + /* The following would deserve a warning if A4 were known either + not to be nul-terminated (e.g., declared nonstring) or to be + uninitialized. */ + strncpy (p->a8, p->a4, sizeof p->a8); // { dg-bogus "\\\[-Warray-bounds" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-6.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-6.c new file mode 100644 index 0000000000..44a513bba4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-6.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wall" } */ +/* based on PR 37861 */ + +extern int printf (__const char *__restrict __format, ...); + +static int f3(int v) +{ + int i,j = 0; + for (i = 0; i <= v; i++) + j++; + return j; +} + +static int f2(char formatstr[10][100]) { + printf( "%d %s\n", 0, formatstr[f3(0)] ); + printf( "%d %s\n", 1, formatstr[f3(1)] ); + printf( "%d %s\n", 2, formatstr[f3(2)] ); + printf( "%d %s\n", 3, formatstr[f3(3)] ); + return 3; +} + +static char formatstr[10][100]; +int main( void ) { + int anz; + anz = f2(formatstr); + printf( " %d\n",anz); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-61.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-61.c new file mode 100644 index 0000000000..5b66cdc0aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-61.c @@ -0,0 +1,190 @@ +/* PR middle-end/94940 - spurious -Warray-bounds for a zero length array + member of union + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern int n; + +extern union Ua3_a0 { + int a3[3]; + int a2[2]; // can only alias a3[0 - 2] + int a1[1]; // can alias all of the union + int a0[0]; // ditto +} ua3_a0; + +void test_ua3_ua0_a0 (int i) +{ + ua3_a0.a0[0] = 0; // { dg-bogus "\\\[-Warray-bounds" } + ua3_a0.a0[1] = 0; // { dg-bogus "\\\[-Warray-bounds" } + ua3_a0.a0[2] = 0; // { dg-bogus "\\\[-Warray-bounds" } + ua3_a0.a0[3] = 0; // { dg-warning "\\\[-Warray-bounds" } + ua3_a0.a0[4] = 0; // { dg-warning "\\\[-Warray-bounds" } + ua3_a0.a0[i] = 0; // { dg-bogus "\\\[-Warray-bounds" } + + if (i < __LINE__) + i = 5; + ua3_a0.a0[i] = 0; // { dg-warning "\\\[-Warray-bounds" } + + if (i > -1) + i = -1; + ua3_a0.a0[i] = 0; // { dg-warning "\\\[-Warray-bounds" } +} + +void test_ua3_ua0_a1 (int i) +{ + /* Abusing one-element array members the same way as those of + length zero is discouraged but so far acceted without warnings. + This should change at some point. */ + + ua3_a0.a1[0] = 0; + ua3_a0.a1[1] = 0; + ua3_a0.a1[2] = 0; + ua3_a0.a1[3] = 0; // { dg-warning "\\\[-Warray-bounds" } + ua3_a0.a1[i] = 0; + + if (i > -1) + i = -1; + ua3_a0.a1[i] = 0; // { dg-warning "\\\[-Warray-bounds" } + + if (i < 7) + i = 7; + ua3_a0.a1[i] = 0; // { dg-warning "\\\[-Warray-bounds" } +} + +void test_ua3_ua0_a2 (int i) +{ + ua3_a0.a2[0] = 0; + ua3_a0.a2[1] = 0; + ua3_a0.a2[2] = 0; // { dg-warning "\\\[-Warray-bounds" } + ua3_a0.a2[i] = 0; + + if (i < __LINE__) + i = __LINE__; + ua3_a0.a2[i] = 0; // { dg-warning "\\\[-Warray-bounds" } + + if (i > -1) + i = -1; + ua3_a0.a2[i] = 0; // { dg-warning "\\\[-Warray-bounds" } +} + + +extern union Ua2_a3 { + int a2[2]; // can only alias a3[0 - 1] + int a3[3]; +} ua2_a3; + +void test_ua2_ua3 (int i) +{ + ua2_a3.a2[0] = 0; // { dg-bogus "\\\[-Warray-bounds" } + ua2_a3.a2[1] = 0; // { dg-bogus "\\\[-Warray-bounds" } + ua2_a3.a2[2] = 0; // { dg-warning "\\\[-Warray-bounds" } + ua2_a3.a2[i] = 0; + + if (i < __LINE__) + i = __LINE__; + ua2_a3.a2[i] = 0; // { dg-warning "\\\[-Warray-bounds" } +} + + +extern struct SUa2_a0 { + union Ua2_a0 { + int a2[2]; + int a0[0]; + } u; +} sua2_a0; + +void test_sua2_sua0 (int i) +{ + n += sua2_a0.u.a0[0]; + n += sua2_a0.u.a0[1]; + n += sua2_a0.u.a0[2]; // { dg-warning "\\\[-Warray-bounds" } + n += sua2_a0.u.a0[i]; + + if (i < __LINE__) + i = __LINE__; + n += sua2_a0.u.a0[i]; // { dg-warning "\\\[-Warray-bounds" } +} + +void test_sua2_sua0_ptr (int i) +{ + union Ua2_a0 *p = &sua2_a0.u; + + n += p->a0[0]; + n += p->a0[1]; + n += p->a0[2]; // { dg-warning "\\\[-Warray-bounds" } + n += p->a0[i]; +} + + +extern struct SUSa3_a0 { + union USa3_a0 { + struct { + int a3[3]; + } s; + int a2[2]; // can alias s.a3[0 - 2] + int a1[1]; // can alias s.a3[0 - 2] + int a0[0]; // can alias s.a3[0] + } u; +} susa3_ua0; + +void test_susa3_sua0 (int i, int j) +{ + n += susa3_ua0.u.a0[0]; + n += susa3_ua0.u.a0[1]; + n += susa3_ua0.u.a0[2]; + n += susa3_ua0.u.a0[3]; // { dg-warning "\\\[-Warray-bounds" } +} + +void test_susa3_sua0_ptr (int i, int j) +{ + union USa3_a0 *p = &susa3_ua0.u; + n += p->a0[0]; + n += p->a0[1]; + n += p->a0[2]; + n += p->a0[3]; // { dg-warning "\\\[-Warray-bounds" } +} + +void test_susa3_sua1 (int i) +{ + n += susa3_ua0.u.a1[0]; + n += susa3_ua0.u.a1[1]; + n += susa3_ua0.u.a1[2]; + n += susa3_ua0.u.a1[3]; // { dg-warning "\\\[-Warray-bounds" } + + if (i < __LINE__) + i = __LINE__; + n += susa3_ua0.u.a1[i]; // { dg-warning "\\\[-Warray-bounds" } +} + +void test_susa3_sua2 (void) +{ + n += susa3_ua0.u.a2[0]; + n += susa3_ua0.u.a2[1]; + n += susa3_ua0.u.a2[2]; // { dg-warning "\\\[-Warray-bounds" } + n += susa3_ua0.u.a2[3]; // { dg-warning "\\\[-Warray-bounds" } +} + + +extern struct { + union { + struct { + int a3[3]; + } s1; + struct { + int a0[0]; + } s2; + } u; +} susa3_usa0; + +void test_susi3_susi0 (int i) +{ + n += susa3_usa0.u.s2.a0[0]; + n += susa3_usa0.u.s2.a0[1]; + n += susa3_usa0.u.s2.a0[2]; + n += susa3_usa0.u.s2.a0[3]; // { dg-warning "\\\[-Warray-bounds" } + n += susa3_usa0.u.s2.a0[i]; + + if (i < __LINE__) + i = __LINE__; + n += susa3_usa0.u.s2.a0[i]; // { dg-warning "\\\[-Warray-bounds" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-62.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-62.c new file mode 100644 index 0000000000..c2421aac1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-62.c @@ -0,0 +1,130 @@ +/* PR tree-optimization/84079 - missing -Warray-bounds taking the address + of past-the-end element of a multidimensional array + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +void sink (int, ...); + +#define T(type, dims, inxs) \ + do { \ + type a dims; \ + sink (__LINE__, &a inxs); \ + } while (0) + + +void test_char_1_1 (int i0, int i1, int i2) +{ +#undef DIMS +#define DIMS [1][1] + + T (char, DIMS, [0]); + T (char, DIMS, [1]); + T (char, DIMS, [2]); // { dg-warning "subscript 2 is above array bounds of 'char\\\[1]\\\[1]'" } + + T (char, DIMS, [0][0]); + T (char, DIMS, [0][1]); + T (char, DIMS, [0][2]); // { dg-warning "subscript 2 is above array bounds of 'char\\\[1]'" } + + T (char, DIMS, [1][0]); // { dg-warning "subscript 1 is above array bounds of 'char\\\[1]\\\[1]'" } + T (char, DIMS, [1][1]); // { dg-warning "subscript 1 is above array bounds of 'char\\\[1]\\\[1]'" } + T (char, DIMS, [1][2]); // { dg-warning "subscript 2 is above array bounds of 'char\\\[1]'" } + + // Exercise ranges. + if (i0 < 0) i0 = 0; + if (i1 < 1) i1 = 1; + if (i2 < 2) i2 = 2; + + T (char, DIMS, [i0]); + T (char, DIMS, [i1]); + T (char, DIMS, [i2]); // { dg-warning "subscript 2 is above array bounds of 'char\\\[1]\\\[1]" } + + T (char, DIMS, [i0][i0]); + T (char, DIMS, [i0][i1]); + T (char, DIMS, [i1][i0]); // { dg-warning "subscript 1 is above array bounds of 'char\\\[1]\\\[1]'" } + T (char, DIMS, [i1][i1]); // { dg-warning "subscript 1 is above array bounds of 'char\\\[1]\\\[1]'" } + T (char, DIMS, [i1][i2]); // { dg-warning "subscript 2 is above array bounds of 'char\\\[1]'" } +} + + +void test_int_3_5 (int i0, int i1, int i2, int i3, int i4, int i5, int i6) +{ +#undef DIMS +#define DIMS [3][5] + + T (int, DIMS, [0]); + T (int, DIMS, [3]); + T (int, DIMS, [4]); // { dg-warning "subscript 4 is above array bounds of 'int\\\[3]\\\[5]'" } + + T (int, DIMS, [0][0]); + T (int, DIMS, [0][5]); + T (int, DIMS, [0][6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } + + T (int, DIMS, [1][0]); + T (int, DIMS, [1][5]); + T (int, DIMS, [1][6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } + + T (int, DIMS, [3][0]); // { dg-warning "subscript 3 is above array bounds of 'int\\\[3]\\\[5]'" } + T (int, DIMS, [3][5]); // { dg-warning "subscript 3 is above array bounds of 'int\\\[3]\\\[5]'" } + T (int, DIMS, [3][6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } + + // Exercise ranges. + if (i0 < 0) i0 = 0; + if (i1 < 1) i1 = 1; + if (i2 < 2) i2 = 2; + if (i3 < 3) i3 = 3; + if (i4 < 4) i4 = 4; + if (i5 < 5) i5 = 5; + if (i6 < 6) i6 = 6; + + T (int, DIMS, [i0]); + T (int, DIMS, [i3]); + T (int, DIMS, [i4]); // { dg-warning "subscript 4 is above array bounds of 'int\\\[3]\\\[5]" } + + T (int, DIMS, [i0][i0]); + T (int, DIMS, [i0][i5]); + T (int, DIMS, [i0][i6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } + + T (int, DIMS, [i1][i0]); + T (int, DIMS, [i1][i5]); + T (int, DIMS, [i1][i6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } + + T (int, DIMS, [i3][i0]); // { dg-warning "subscript 3 is above array bounds of 'int\\\[3]\\\[5]'" } + T (int, DIMS, [i3][i5]); // { dg-warning "subscript 3 is above array bounds of 'int\\\[3]\\\[5]'" } + T (int, DIMS, [i3][i6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } +} + + +void test_int_2_3_4_5 (void) +{ +#undef DIMS +#define DIMS [2][3][4][5] + + T (int, DIMS, [0]); + T (int, DIMS, [2]); + T (int, DIMS, [3]); // { dg-warning "subscript 3 is above array bounds of 'int\\\[2]\\\[3]\\\[4]\\\[5]'" } + + T (int, DIMS, [0][0]); + T (int, DIMS, [0][3]); + T (int, DIMS, [0][4]); // { dg-warning "subscript 4 is above array bounds of 'int\\\[3]\\\[4]\\\[5]'" } + T (int, DIMS, [0][9]); // { dg-warning "subscript 9 is above array bounds of 'int\\\[3]\\\[4]\\\[5]'" } + + T (int, DIMS, [0][0][0]); + T (int, DIMS, [0][0][4]); + T (int, DIMS, [0][0][5]); // { dg-warning "subscript 5 is above array bounds of 'int\\\[4]\\\[5]'" } + + T (int, DIMS, [0][0][0][0]); + T (int, DIMS, [0][0][0][5]); + T (int, DIMS, [0][0][0][6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } + + T (int, DIMS, [0][0][1][0]); + T (int, DIMS, [0][0][1][5]); + T (int, DIMS, [0][0][1][6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } + + T (int, DIMS, [0][0][3][0]); + T (int, DIMS, [0][0][3][5]); + T (int, DIMS, [0][0][3][6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } + + T (int, DIMS, [0][0][1][0]); + T (int, DIMS, [0][0][1][5]); + T (int, DIMS, [0][0][1][6]); // { dg-warning "subscript 6 is above array bounds of 'int\\\[5]'" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-63.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-63.c new file mode 100644 index 0000000000..530e2c5645 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-63.c @@ -0,0 +1,54 @@ +/* PR middle-end/94195 - missing warning reading a smaller object via + an lvalue of a larger type + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +typedef __INT16_TYPE__ int16_t; +typedef __SIZE_TYPE__ size_t; + +void* alloca (size_t); + +void sink (void*); + + +void byte_store_to_decl (void) +{ + struct S6 { char a[6]; } s; // { dg-message "at offset 6 into object 's' of size 6" "note" } + + char *p = (char*)&s; + + p[0] = 0; p[1] = 1; p[2] = 2; p[3] = 3; p[4] = 4; p[5] = 5; + p[6] = 6; // { dg-warning "array subscript 6 is outside array bounds of 'struct S6\\\[1]" } + + sink (&s); +} + + +void word_store_to_decl (void) +{ + struct S6 { char a[6]; } s; // { dg-message "at offset 5 into object 's' of size 6" "note" } + + char *p = (char*)&s; + + int16_t *q = (int16_t*)(p + 1); + + q[0] = 0; q[1] = 1; + q[2] = 2; // { dg-warning "array subscript 'int16_t {aka short int}\\\[2]' is partly outside array bounds of 'struct S6\\\[1]'" } + + sink (&s); +} + + +void word_store_to_alloc (void) +{ + struct S6 { char a[6]; } *p; + p = alloca (sizeof *p); // { dg-message "at offset 5 into object of size 6 allocated by 'alloca'" "note" } + + int16_t *q = (int16_t*)((char*)p + 1); + + q[0] = 0; q[1] = 1; + q[2] = 2; // { dg-warning "array subscript 'int16_t {aka short int}\\\[2]' is partly outside array bounds of 'unsigned char\\\[6]'" } + + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-64.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-64.c new file mode 100644 index 0000000000..f5ebc3dd4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-64.c @@ -0,0 +1,60 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + + Verify that out-of-bounds accesses to array arguments are diagnosed, + both to ordinary array parameters with constant bounds and to array + parameters declared static. This is the converse of what PR 50584 + asks for. + + { dg-do compile } + { dg-options "-O2 -Wall -Warray-parameter -Wno-vla-parameter" } */ + +#define NOIPA __attribute__ ((noipa)) + +void sink (void*, ...); + +#define T(...) sink (0, __VA_ARGS__) + + +NOIPA void fca1 (char a[1]) +{ + T (a[0]); + T (a[1]); // { dg-warning "-Warray-bounds" } +} + +NOIPA void fcas1 (char a[static 1]) +{ + T (a[0]); + T (a[1]); // { dg-warning "-Warray-bounds" } +} + +NOIPA void fca2 (char a[2]) +{ + T (a[0]); T (a[1]); + T (a[2]); // { dg-warning "-Warray-bounds" } +} + +NOIPA void fcas2 (char a[static 2]) +{ + T (a[0]); T (a[1]); + T (a[2]); // { dg-warning "-Warray-bounds" } +} + +NOIPA void fca3 (char a[3]) +{ + T (a[0]); T (a[1]); T (a[2]); + T (a[3]); // { dg-warning "-Warray-bounds" } +} + +NOIPA void fcas3 (char a[static 3]) +{ + T (a[0]); T (a[1]); T (a[2]); + T (a[3]); // { dg-warning "-Warray-bounds" } +} + + +NOIPA void fca1_1 (char a[1][1]) +{ + T (a[0][0]); + T (a[0][1]); // { dg-warning "-Warray-bounds" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-65.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-65.c new file mode 100644 index 0000000000..6bd50d0f87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-65.c @@ -0,0 +1,202 @@ +/* PR middle-end/84051 - missing -Warray-bounds on an out-of-bounds access + via an array pointer + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +void sink (void*, ...); +#define T(x) sink (0, x) + +void +test_note (int (*pia3)[3]) // { dg-message "while referencing 'pia3'" } +{ + int i = 0; + T ((*pia3)[i++]); + T ((*pia3)[i++]); + T ((*pia3)[i++]); + T ((*pia3)[i++]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'int\\\[3]'" } + T ((*pia3)[i++]); // { dg-warning "array subscript 4 is (above|outside) array bounds of 'int\\\[3]'" } + + { + /* Regrettably, the following isn't diagnosed because it's represented + the same as the possibly valid access below: + MEM[(int *)a_1(D) + 36B] = 0; */ + int *p0 = pia3[0]; + T (p0[3]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'int\\\[3]'" "pr?????" { xfail *-*-* } } + + int *p1 = pia3[3]; + T (p1[0]); // okay + } +} + +void test_a1_cst (_Bool (*pba0)[0], char (*pca1)[1], + short (*psa2)[2], int (*pia3)[3]) +{ + T ((*pba0)[-1]); // { dg-warning "array subscript -1 is (above|outside) array bounds of '_Bool\\\[0]'" } + T ((*pba0)[0]); // { dg-warning "array subscript 0 is (above|outside) array bounds of '_Bool\\\[0]'" } + T ((*pba0)[1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of '_Bool\\\[0]'" } + T ((*pba0)[2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of '_Bool\\\[0]'" } + T ((*pba0)[12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of '_Bool\\\[0]'" } + + T ((*pca1)[-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'char\\\[1]'" } + T ((*pca1)[0]); + T ((*pca1)[1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of 'char\\\[1]'" } + T ((*pca1)[2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'char\\\[1]'" } + T ((*pca1)[123]); // { dg-warning "array subscript 123 is (above|outside) array bounds of 'char\\\[1]'" } + + T ((*psa2)[-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'short int\\\[2]'" } + T ((*psa2)[0]); + T ((*psa2)[1]); + T ((*psa2)[2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'short int\\\[2]'" } + T ((*psa2)[1234]); // { dg-warning "array subscript 1234 is (above|outside) array bounds of 'short int\\\[2]'" } + + T ((*pia3)[-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'int\\\[3]'" } + T ((*pia3)[0]); + T ((*pia3)[1]); + T ((*pia3)[2]); + T ((*pia3)[3]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'int\\\[3]'" } + T ((*pia3)[12345]); // { dg-warning "array subscript 12345 is (above|outside) array bounds of 'int\\\[3]'" } +} + + +void test_a2_cst (_Bool (*pba0_1)[0][1], char (*pca1_2)[1][2], + short (*psa2_3)[2][3], int (*pia3_4)[3][4]) +{ + T ((*pba0_1)[-1][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of '_Bool\\\[1]'" } + T ((*pba0_1)[-1][0]); // { dg-warning "array subscript -1 is (above|outside) array bounds of '_Bool\\\[0]\\\[1]'" } + + T ((*pba0_1)[0][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of '_Bool\\\[1]'" } + T ((*pba0_1)[0][0]); // { dg-warning "array subscript 0 is (above|outside) array bounds of '_Bool\\\[0]\\\[1]'" } + T ((*pba0_1)[0][1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of '_Bool\\\[1]'" } + T ((*pba0_1)[0][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of '_Bool\\\[1]'" } + T ((*pba0_1)[0][12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of '_Bool\\\[1]'" } + + T ((*pba0_1)[1][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of '_Bool\\\[1]'" } + T ((*pba0_1)[1][0]); // { dg-warning "array subscript 1 is (above|outside) array bounds of '_Bool\\\[0]\\\[1]'" } + T ((*pba0_1)[1][1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of '_Bool\\\[1]'" } + T ((*pba0_1)[1][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of '_Bool\\\[1]'" } + T ((*pba0_1)[1][12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of '_Bool\\\[1]'" } + + + T ((*pca1_2)[0][0]); + T ((*pca1_2)[0][1]); + T ((*pca1_2)[0][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'char\\\[2]'" } + + T ((*pca1_2)[1][0]); // { dg-warning "array subscript 1 is (above|outside) array bounds of 'char\\\[1]\\\[2]'" } + T ((*pca1_2)[1][1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of 'char\\\[1]\\\[2]'" } + T ((*pca1_2)[1][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'char\\\[2]'" } + + + T ((*psa2_3)[0][0]); + T ((*psa2_3)[0][1]); + T ((*psa2_3)[0][2]); + T ((*psa2_3)[0][3]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'short int\\\[3]'" } + + T ((*psa2_3)[1][0]); + T ((*psa2_3)[1][1]); + T ((*psa2_3)[1][2]); + T ((*psa2_3)[1][3]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'short int\\\[3]'" } + + T ((*psa2_3)[2][0]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'short int\\\[2]\\\[3]'" } + T ((*psa2_3)[2][1]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'short int\\\[2]\\\[3]'" } + T ((*psa2_3)[2][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'short int\\\[2]\\\[3]'" } + T ((*psa2_3)[2][3]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'short int\\\[3]'" } + + + T ((*pia3_4)[0][0]); + T ((*pia3_4)[0][1]); + T ((*pia3_4)[0][2]); + T ((*pia3_4)[0][3]); + T ((*pia3_4)[0][4]); // { dg-warning "array subscript 4 is (above|outside) array bounds of 'int\\\[4]'" } + + T ((*pia3_4)[1][0]); + T ((*pia3_4)[1][1]); + T ((*pia3_4)[1][2]); + T ((*pia3_4)[1][3]); + T ((*pia3_4)[1][4]); // { dg-warning "array subscript 4 is (above|outside) array bounds of 'int\\\[4]'" } + + T ((*pia3_4)[2][0]); + T ((*pia3_4)[2][1]); + T ((*pia3_4)[2][2]); + T ((*pia3_4)[2][3]); + T ((*pia3_4)[2][4]); // { dg-warning "array subscript 4 is (above|outside) array bounds of 'int\\\[4]'" } + + T ((*pia3_4)[3][0]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'int\\\[3]\\\[4]'" } + T ((*pia3_4)[3][1]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'int\\\[3]\\\[4]'" } + T ((*pia3_4)[3][2]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'int\\\[3]\\\[4]'" } + T ((*pia3_4)[3][3]); // { dg-warning "array subscript 3 is (above|outside) array bounds of 'int\\\[3]\\\[4]'" } + T ((*pia3_4)[3][4]); // { dg-warning "array subscript 4 is (above|outside) array bounds of 'int\\\[4]'" } +} + + +typedef int IA4[4]; +typedef IA4 IA3_4[3]; + +void test_a2_var (IA3_4 *pia3_4) +{ + { + IA4 *pia4 = &(*pia3_4)[0]; + + T ((*pia4)[-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'IA4'" } + T ((*pia4)[0]); + T ((*pia4)[1]); + T ((*pia4)[2]); + T ((*pia4)[3]); + T ((*pia4)[4]); // { dg-warning "array subscript 4 is (above|outside) array bounds of 'IA4'" } + } + + { + IA4 *pia4 = &(*pia3_4)[1]; + + T ((*pia4)[-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'IA4'" } + T ((*pia4)[0]); + T ((*pia4)[1]); + T ((*pia4)[2]); + T ((*pia4)[3]); + T ((*pia4)[4]); // { dg-warning "array subscript 4 is (above|outside) array bounds of 'IA4'" } + } + + { + IA4 *pia4 = &(*pia3_4)[2]; + + T ((*pia4)[-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'IA4'" } + T ((*pia4)[0]); + T ((*pia4)[1]); + T ((*pia4)[2]); + T ((*pia4)[3]); + T ((*pia4)[4]); // { dg-warning "array subscript 4 is (above|outside) array bounds of 'IA4'" } + } + + { + IA4 *pia4 = &(*pia3_4)[3]; + + T ((*pia4)[-1]); // { dg-warning "\\\[-Warray-bounds" } + /* The following aren't diagnosed unless N itself is out of bounds + because thanks to the MEM_REF they're indistinguishable from + possibly valid accesses: + MEM[(int[4] *)pia3_4_2(D) + 48B][N]; */ + T ((*pia4)[0]); // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + T ((*pia4)[1]); // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + T ((*pia4)[2]); // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + T ((*pia4)[3]); // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + T ((*pia4)[4]); // { dg-warning "\\\[-Warray-bounds" } + } +} + + +struct S { IA3_4 *pia3_4; }; +typedef struct S S5[5]; +typedef S5 S5_7[7]; + +void test_s5_7 (S5_7 *ps5_7) +{ + { + S5 *ps5 = &(*ps5_7)[0]; + T ((*ps5)[0]); + T ((*(*ps5)[0].pia3_4)[0][0]); + T ((*(*ps5)[0].pia3_4)[2][3]); + T ((*(*ps5)[0].pia3_4)[2][4]); // { dg-warning "array subscript 4 is above array bounds of 'IA4'" } + + T ((*(*ps5)[1].pia3_4)[2][3]); + T ((*(*ps5)[5].pia3_4)[2][3]); // { dg-warning "array subscript 5 is above array bounds of 'S5'" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-66.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-66.c new file mode 100644 index 0000000000..6ab3398c76 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-66.c @@ -0,0 +1,257 @@ +/* PR middle-end/82608 - missing -Warray-bounds on an out-of-bounds VLA index + { dg-do compile } + { dg-options "-O2 -Wall -Wno-uninitialized -ftrack-macro-expansion=0" } + { dg-require-effective-target alloca } */ + +#include "range.h" + +typedef __INT16_TYPE__ int16_t; + +#define alloca(n) __builtin_alloca (n) + +void* calloc (size_t, size_t); +void* malloc (size_t); + +void sink (void*, ...); +#define sink(...) sink (0, __VA_ARGS__) + +#define T(x) (sink (x)) + +__attribute__ ((alloc_size (1))) void* alloc (size_t); + + +void test_alloca_cst (void) +{ + { + char *p = alloca (1); + sink (p); + T (p[0]); + T (p[1]); // { dg-warning "subscript 1 is outside array bounds of 'char\\\[1\\\]'" } + } + + { + char *p = alloca (2); + sink (p); + T (p[0]), T (p[1]); + T (p[2]); // { dg-warning "subscript 2 is outside array bounds of 'char\\\[2\\\]'" } + } + + { + char *p = alloca (3); + sink (p); + T (p[0]), T (p[1]), T (p[2]); + T (p[3]); // { dg-warning "subscript 3 is outside array bounds of 'char\\\[3\\\]'" } + } +} + + +void test_alloca_char_range (int i, unsigned n, size_t sz) +{ + { + // Be sure to exercise signed as well as unsigned arguments. + char *p = alloca (i); + sink (p); + T (p[0]), T (p[1]), T (p[12345]); + T (p[-1]); // { dg-warning "subscript -1 is outside array bounds of 'char\\\[" } + } + + { + char *p = alloca (n); + sink (p); + T (p[0]), T (p[1]), T (p[12345]); + T (p[-1]); // { dg-warning "subscript -1 is outside array bounds of 'char\\\[" } + } + + { + char *p = alloca (sz); + sink (p); + T (p[0]), T (p[1]), T (p[23456]); + T (p[-1]); // { dg-warning "subscript -1 is outside array bounds of 'char\\\[" } + } + + { + char *p = alloca (UR (0, 1)); + sink (p); + T (p[0]); + T (p[1]); // { dg-warning "subscript 1 is outside array bounds of 'char\\\[1\\\]'" } + } + + { + char *p = alloca (UR (0, 2)); + sink (p); + sink (p[0], p[1]); + sink (p[2]); // { dg-warning "subscript 2 is outside array bounds of 'char\\\[2\\\]'" } + } + + { + char *p = alloca (UR (0, 3)); + sink (p); + T (p[0]), T (p[1]), T (p[2]); + T (p[3]); // { dg-warning "subscript 3 is outside array bounds of 'char\\\[3\\\]'" } + } + + { + char *p = alloca (UR (1, 3)); + sink (p); + T (p[0]), T (p[1]), T (p[2]); + T (p[3]); // { dg-warning "subscript 3 is outside array bounds of 'char\\\[3\\\]'" } + } + + { + char *p = alloca (UR (2, 3)); + sink (p); + T (p[0]), T (p[1]), T (p[2]); + T (p[3]); // { dg-warning "subscript 3 is outside array bounds of 'char\\\[3\\\]'" } + } +} + + +void test_alloca_int16_range (unsigned n) +{ + int16_t *p; + { + p = alloca (n); // { dg-message "allocated by " } + sink (p); + T (p[0]), T (p[1]), T (p[12345]); + T (p[-1]); // { dg-warning "subscript -1 is outside array bounds of 'int16_t\\\[" } + } + + { + p = alloca (UR (0, 1)); // { dg-message "at offset \\d+ into object of size \\\[0, 1] allocated by '__builtin_alloca'" "note" } + sink (p); + T (p[0]); // { dg-warning "subscript 'int16_t {aka short int}\\\[0\\\]' is partly outside array bounds of 'unsigned char\\\[1]'" } + T (p[1]); // { dg-warning "subscript 1 is outside array bounds of 'int16_t\\\[0]'" } + } + + { + p = alloca (UR (0, 2)); // { dg-message "at offset \\d+ into object of size \\\[0, 2] allocated by '__builtin_alloca'" "note" } + sink (p); + sink (p[0]); + sink (p[1]); // { dg-warning "subscript 1 is outside array bounds of 'int16_t\\\[1]'" } + sink (p[2]); // { dg-warning "subscript 2 is outside array bounds of 'int16_t\\\[1\\\]'" } + } + + { + p = alloca (UR (0, 3)); // { dg-message "at offset \\d+ into object of size \\\[0, 3] allocated by '__builtin_alloca'" "note" } + sink (p); + T (p[0]); + T (p[1]); // { dg-warning "subscript 'int16_t {aka short int}\\\[1\\\]' is partly outside array bounds of 'unsigned char\\\[3]'" } + T (p[2]); // { dg-warning "subscript 2 is outside array bounds of 'int16_t\\\[1\\\]'" } + T (p[3]); // { dg-warning "subscript 3 is outside array bounds of 'int16_t\\\[1\\\]'" } + } + + { + p = alloca (UR (1, 3)); // { dg-message "at offset 1|2|3 into object of size \\\[1, 3] allocated by '__builtin_alloca'" "note" } + sink (p); + T (p[0]); + T (p[1]); // { dg-warning "subscript 'int16_t {aka short int}\\\[1\\\]' is partly outside array bounds of 'unsigned char\\\[3]'" } + T (p[2]); // { dg-warning "subscript 2 is outside array bounds of 'int16_t\\\[1\\\]'" } + T (p[3]); // { dg-warning "subscript 3 is outside array bounds of 'int16_t\\\[1\\\]'" } + } + + { + p = alloca (UR (2, 3)); // { dg-message "at offset 2|4 into object of size \\\[2, 3] allocated by '__builtin_alloca'" "note" } + sink (p); + T (p[0]); + T (p[1]); // { dg-warning "subscript 'int16_t {aka short int}\\\[1\\\]' is partly outside array bounds of 'unsigned char\\\[3]'" } + T (p[2]); // { dg-warning "subscript 2 is outside array bounds of 'int16_t\\\[1\\\]'" } + T (p[3]); // { dg-warning "subscript 3 is outside array bounds of 'int16_t\\\[1\\\]'" } + } + + { + p = alloca (UR (3, 4)); // { dg-message "at offset 4|6 into object of size \\\[3, 4] allocated by '__builtin_alloca'" "note" } + sink (p); + T (p[0]); + T (p[1]); + T (p[2]); // { dg-warning "subscript 2 is outside array bounds of 'int16_t\\\[2\\\]'" } + T (p[3]); // { dg-warning "subscript 3 is outside array bounds of 'int16_t\\\[2\\\]'" } + } +} + + +void test_vla_cst (void) +{ + int n = 1; + { + char a[n]; + sink (a); + T (a[0]); + T (a[1]); // { dg-warning "subscript 1 is (above|outside) array bounds " } + } + + { + n = 2; + char a[n]; + sink (a); + T (a[0]), T (a[1]); + T (a[2]); // { dg-warning "subscript 2 is (above|outside) array bounds " } + } + + { + n = 3; + char a[n], *p = a; + sink (p); + T (p[0]), T (p[1]), T (p[2]); + T (p[3]); // { dg-warning "subscript 3 is (above|outside) array bounds " } + } +} + + +void test_vla_char_range (int i, unsigned n, size_t sz) +{ + { + char a[i]; + sink (a); + T (a[0]), T (a[1]), T (a[12345]); + T (a[-1]); // { dg-warning "subscript -1 is (below|outside) array bounds of 'char\\\[" } + } + + { + char a[n]; + sink (a); + T (a[0]), T (a[1]), T (a[12345]); + T (a[-1]); // { dg-warning "subscript -1 is (below|outside) array bounds of 'char\\\[" } + } + + { + char a[sz]; + sink (a); + T (a[0]), T (a[1]), T (a[23456]); + T (a[-1]); // { dg-warning "subscript -1 is (below|outside) array bounds of 'char\\\[" } + } + + { + char a[UR (0, 1)]; + sink (a); + T (a[0]); + T (a[1]); // { dg-warning "subscript 1 is outside array bounds of 'char\\\[1\\\]'" "pr82608" { xfail *-*-* } } + } + + { + char a[UR (0, 2)]; + sink (a); + sink (a[0], a[1]); + sink (a[2]); // { dg-warning "subscript 2 is outside array bounds of 'char\\\[2\\\]'" "pr82608" { xfail *-*-* } } + } + + { + char a[UR (0, 3)]; + sink (a); + T (a[0]), T (a[1]), T (a[2]); + T (a[3]); // { dg-warning "subscript 3 is outside array bounds of 'char\\\[3\\\]'" "pr82608" { xfail *-*-* } } + } + + { + char a[UR (1, 3)]; + sink (a); + T (a[0]), T (a[1]), T (a[2]); + T (a[3]); // { dg-warning "subscript 3 is outside array bounds of 'char\\\[3\\\]'" "pr82608" { xfail *-*-* } } + } + + { + char a[UR (2, 3)]; + sink (a); + T (a[0]), T (a[1]), T (a[2]); + T (a[3]); // { dg-warning "subscript 3 is outside array bounds of 'char\\\[3\\\]'" "pr82608" { xfail *-*-* } } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-67.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-67.c new file mode 100644 index 0000000000..a9b9ff7d2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-67.c @@ -0,0 +1,36 @@ +/* Verify warnings fpr accesses to trailing one-element array members + of a struct that's a member of either a struct or a union. Both + are obviously undefined but GCC relies on these hacks so the test + verifies that -Warray-bounds doesn't trigger for it. + { do-do compile } + { dg-options "-O2 -Wall" } */ + + +typedef union tree_node *tree; + +struct tree_exp { int i; tree operands[1]; }; + +union tree_node +{ + struct tree_exp exp; +}; + +tree test_nowarn (tree t) +{ + return t->exp.operands[3]; // { dg-bogus "\\\[-Warray-bounds" } +} + + +typedef struct shrub_node *shrub; + +struct shrub_exp { int i; shrub operands[1]; }; + +struct shrub_node +{ + struct shrub_exp exp; +}; + +shrub test_warn (shrub s) +{ + return s->exp.operands[3]; // { dg-warning "\\\[-Warray-bounds" "pr96346" { xfail *-*-* } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-68.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-68.c new file mode 100644 index 0000000000..d661669547 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-68.c @@ -0,0 +1,118 @@ +/* PR middle-end/97391 - bogus -Warray-bounds accessing a multidimensional + array parameter + { dg-do compile } + { dg-options "-O2 -Wall" } */ + + +void nowarn_access_loop_idx (char a[3][5]) +{ + for (int i = 0; i < 3; i++) + for (int j = 0; j < 5; j++) + a[i][j] = 0; +} + +void warn_access_loop_idx (char a[3][5]) +{ + for (int i = 0; i < 3; i++) + for (int j = 0; j < 5; j++) + a[j][i] = 0; // { dg-warning "\\\[-Warray-bounds" } +} + + +void nowarn_access_cst_idx (int a[5][7][9]) +{ + a[0][0][0] = __LINE__; + a[0][0][8] = __LINE__; + + a[0][6][0] = __LINE__; + a[0][6][8] = __LINE__; + + a[4][0][0] = __LINE__; + a[4][0][8] = __LINE__; + a[4][6][8] = __LINE__; +} + + +void test_ptr_access_cst_idx (int a[5][7][9]) +{ + int *p = &a[0][0][0]; + + p[0] = __LINE__; + p[8] = __LINE__; + + /* The following access should trigger a warning but it's represented + the same as the valid access in + p = a[0][1][0]; + p[1] = __LINE__; + both as + MEM[(int *)a_1(D) + 36B] = __LINE__; */ + + p[9] = __LINE__; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + + p[315] = __LINE__; + // { dg-warning "subscript 315 is outside array bounds of 'int\\\[5]\\\[7]\\\[9]'" "pr97425" { xfail *-*-* } .-1 } + // { dg-warning "subscript 315 is outside array bounds " "" { target *-*-* } .-2 } + + p = &a[0][6][0]; + p[0] = __LINE__; + p[8] = __LINE__; + + p = &a[4][6][0]; + p[0] = __LINE__; + p[8] = __LINE__; +} + + +void warn_access_cst_idx (int a[5][7][9]) +{ + a[0][0][9] = __LINE__; // { dg-warning "subscript 9 is above array bounds of 'int\\\[9]'" } + a[0][7][0] = __LINE__; // { dg-warning "subscript 7 is above array bounds of 'int\\\[7]\\\[9]'" } + a[5][0][0] = __LINE__; + // { dg-warning "subscript 5 is outside array bounds of 'int\\\[5]\\\[7]\\\[9]'" "pr97425" { xfail *-*-* } .-1 } + // { dg-warning "subscript \\d+ is outside array bounds" "" { target *-*-* } .-2 } +} + + +void test_ptrarray_access_cst_idx (int (*pa)[5][7][9]) +{ + (*pa)[0][0][0] = __LINE__; + (*pa)[0][0][8] = __LINE__; + (*pa)[0][0][9] = __LINE__; // { dg-warning "subscript 9 is above array bounds of 'int\\\[9]'" } + + (*pa)[0][6][0] = __LINE__; + (*pa)[0][7][0] = __LINE__; // { dg-warning "subscript 7 is above array bounds of 'int\\\[7]\\\[9]'" } + (*pa)[0][8][0] = __LINE__; // { dg-warning "subscript 8 is above array bounds of 'int\\\[7]\\\[9]'" } + + (*pa)[4][6][8] = __LINE__; + (*pa)[5][0][0] = __LINE__; // { dg-warning "subscript 5 is above array bounds of 'int\\\[5]\\\[7]\\\[9]'" } +} + + +void test_ptr_ptrarray_access_cst_idx (int (*pa)[5][7][9]) +{ + int *p = &(*pa)[0][0][0]; + + p[0] = __LINE__; + p[8] = __LINE__; + + /* The following access should trigger a warning but it's represented + the same as the valid access in + p = a[0][1][0]; + p[1] = __LINE__; + both as + MEM[(int *)a_1(D) + 36B] = __LINE__; */ + + p[9] = __LINE__; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + + p[315] = __LINE__; // { dg-warning "\\\[-Warray-bounds" "pr97429" { xfail *-*-* } } + + p = &(*pa)[0][6][0]; + p[0] = __LINE__; + p[8] = __LINE__; + + p = &(*pa)[4][6][0]; + p[0] = __LINE__; + p[8] = __LINE__; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-69.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-69.c new file mode 100644 index 0000000000..80503f8d21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-69.c @@ -0,0 +1,74 @@ +/* Verify that storing a bigger vector into smaller space is diagnosed. + { dg-do compile } + { dg-options "-O2 -Warray-bounds -Wno-stringop-overflow" } */ + +typedef __INT16_TYPE__ int16_t; +typedef __attribute__ ((__vector_size__ (32))) char C32; + +typedef __attribute__ ((__vector_size__ (64))) int16_t I16_64; + +void sink (void*); + + +void nowarn_c32 (char c) +{ + extern char nowarn_a32[32]; + + void *p = nowarn_a32; + *(C32*)p = (C32){ c }; + sink (p); + + char a32[32]; + p = a32; + *(C32*)p = (C32){ c }; + sink (p); +} + +/* The invalid stores below are diagnosed by -Warray-bounds only + because it doesn't use compute_objsize(). If/when that changes + the function might need adjusting to avoid the hack put in place + to avoid false positives due to vectorization. */ + +void warn_c32 (char c) +{ + extern char warn_a32[32]; // { dg-message "'warn_a32'" "note" } + + void *p = warn_a32 + 1; + *(C32*)p = (C32){ c }; // { dg-warning "\\\[-Warray-bounds" } + + /* Verify a local variable too. */ + char a32[32]; // { dg-message "'a32'" } + p = a32 + 1; + *(C32*)p = (C32){ c }; // { dg-warning "\\\[-Warray-bounds" } + sink (p); +} + + +void nowarn_i16_64 (int16_t i) +{ + extern char nowarn_a64[64]; + + void *p = nowarn_a64; + I16_64 *q = (I16_64*)p; + *q = (I16_64){ i }; + + char a64[64]; + q = (I16_64*)a64; + *q = (I16_64){ i }; + sink (q); +} + +void warn_i16_64 (int16_t i) +{ + extern char warn_a64[64]; // { dg-message "'warn_a64'" } + + void *p = warn_a64 + 1; + I16_64 *q = (I16_64*)p; + *q = (I16_64){ i }; // { dg-warning "\\\[-Warray-bounds" } + + char a64[64]; // { dg-message "'a64'" } + p = a64 + 1; + q = (I16_64*)p; + *q = (I16_64){ i }; // { dg-warning "\\\[-Warray-bounds" } + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-7.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-7.c new file mode 100644 index 0000000000..a32492ccc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-7.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +char *p; + +int main() +{ + p = ""; + if (p[0] == 0 + || (p[0] == '_' && p[1] == 0)) /* { dg-bogus "array bounds" } */ + return 0; + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-70.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-70.c new file mode 100644 index 0000000000..087e255599 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-70.c @@ -0,0 +1,18 @@ +/* PR middle-end/97556 - ICE on excessively large index into a multidimensional + array + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define SIZE_MAX __SIZE_MAX__ + +typedef __SIZE_TYPE__ size_t; + +char a[1][3]; + +void f (int c) +{ + size_t i = c ? SIZE_MAX / 2 : SIZE_MAX; + a[i][0] = 0; // { dg-warning "\\\[-Warray-bounds" } +} + +// { dg-prune-output "\\\[-Wstringop-overflow=" } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-71.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-71.c new file mode 100644 index 0000000000..425bb12290 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-71.c @@ -0,0 +1,7 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define IGNORE '1' +#include "Warray-bounds-71.h" diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-71.h b/SingleSource/Regression/C/gcc-dg/Warray-bounds-71.h new file mode 100644 index 0000000000..89d1068a26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-71.h @@ -0,0 +1,46 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +int a[4]; + +void f1 (int *p, int i) +{ +#pragma GCC diagnostic push +#if IGNORE == '1' +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + p[i + 1] = 0; +#pragma GCC diagnostic pop +} + +void f2 (int *p, int i) +{ +#pragma GCC diagnostic push +#if IGNORE == '2' +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + f1 (p + 1, i + 1); +#pragma GCC diagnostic pop +} + +void f3 (int *p, int i) +{ +#pragma GCC diagnostic push +#if IGNORE == '3' +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + f2 (p + 1, i + 1); +#pragma GCC diagnostic pop +} + +void f4 (void) +{ +#pragma GCC diagnostic push +#if IGNORE == '4' +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + f3 (a, 1); +#pragma GCC diagnostic pop +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-72.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-72.c new file mode 100644 index 0000000000..eb3f664c0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-72.c @@ -0,0 +1,7 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define IGNORE '2' +#include "Warray-bounds-71.h" diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-73.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-73.c new file mode 100644 index 0000000000..50e2083529 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-73.c @@ -0,0 +1,7 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define IGNORE '3' +#include "Warray-bounds-71.h" diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-74.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-74.c new file mode 100644 index 0000000000..c59a876e07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-74.c @@ -0,0 +1,7 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define IGNORE '4' +#include "Warray-bounds-71.h" diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-75.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-75.c new file mode 100644 index 0000000000..306b1768b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-75.c @@ -0,0 +1,12 @@ +/* Sanity test for Warray-bounds-7[1-4].c. Also verify the expected + inlining stack. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#include "Warray-bounds-71.h" + +// { dg-regexp "In function 'f1'," "In function f1" { target *-*-* } 0 } +// { dg-regexp "inlined from 'f2' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f2" { target *-*-* } 0 } +// { dg-regexp "inlined from 'f3' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f3" { target *-*-* } 0 } +// { dg-regexp "inlined from 'f4' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f4" { target *-*-* } 0 } +// { dg-message "Warray-bounds-71.h:\\d+:\\d+: warning: array subscript 6 is outside array bounds of 'int\\\[4]'" "warning" { target *-*-* } 0 } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-76.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-76.c new file mode 100644 index 0000000000..6711dc45f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-76.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/86650 - -Warray-bounds missing inlining context + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +static void f0 (int *p, int i) +{ + p[i] = 0; // { dg-warning "\\\[-Warray-bounds" } +} + +// Expect two instances of the text below: +// { dg-regexp "In function 'f0'," "first f0 prefix" { target *-*-* } 0 } +// { dg-regexp "In function 'f0'," "second f0 prefix" { target *-*-* } 0 } + +static void f1 (int *p, int i) { f0 (p + 1, i + 1); } +static void f2 (int *p, int i) { f1 (p + 1, i + 1); } + +extern int a2[2]; // { dg-note "'a2'" } + +void foo (void) +{ + f1 (a2 + 1, 1); +} + +// { dg-regexp " +inlined from 'foo' at \[^:\]+Warray-bounds-76.c:21:\\d+:" "inlined from foo" } + +extern int a3[3]; // { dg-note "'a3'" } + +void bar (void) +{ + f2 (a3 + 1, 1); +} + +// { dg-regexp " +inlined from 'f1' at \[^:\]+Warray-bounds-76.c:14:\\d+," "inlined from f1" } +// { dg-regexp " +inlined from 'f2' at \[^:\]+Warray-bounds-76.c:15:\\d+," "inlined from f2" } +// { dg-regexp " +inlined from 'bar' at \[^:\]+Warray-bounds-76.c:30:\\d+:" "inlined from bar" } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-77.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-77.c new file mode 100644 index 0000000000..6487613374 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-77.c @@ -0,0 +1,135 @@ +/* PR middle-end/100137 - -Warray-bounds false positive on varying offset + plus negative + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern char ax[], a1[1], a2[2], a3[3], a4[4], a5[5]; + +int* ptr; +#define X (*ptr++) + + +__attribute__ ((noipa)) void +array_plus_var_minus_cstint (int i, int j) +{ + { + const char *p = ax; + p += i; + X = p[-1]; + X = p[-123]; + } + + { + const char *p = a1; + p += i; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-3]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = a2; + p += i; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-3]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = a3; + p += i; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = a4; + p += i; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-4]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = a5; + p += i; + p += j; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-4]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-5]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + } +} + + +__attribute__ ((noipa)) void +array_plus_var_minus_cstlong (long i, long j) +{ + { + const char *p = ax; + p += i; + X = p[-1]; + X = p[-123]; + } + + { + const char *p = a1; + p += i; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-3]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = a2; + p += i; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-3]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = a3; + p += i; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = a4; + p += i; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-4]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + X = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = a5; + p += i; + p += j; + X = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-3]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-4]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-5]; // { dg-bogus "\\\[-Warray-bounds" } + X = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-78.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-78.c new file mode 100644 index 0000000000..73c335fd8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-78.c @@ -0,0 +1,109 @@ +/* PR tree-optimization/99475 - bogus -Warray-bounds accessing an array + element of empty structs + { dg-do compile } + { dg-options "-O2 -Wall -Wno-strict-aliasing" } */ + +typedef _Bool bool; + +#define NOIPA __attribute__ ((noipa)) + +struct S { }; + +extern struct S sa3[3]; +extern struct S sa2_3[2][3]; +extern struct S sa3_4_5[3][4][5]; + +void sink (void*); + + +NOIPA void access_sa3 (void) +{ + ((bool*)sa3)[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + ((bool*)sa3)[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + ((bool*)sa3)[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + ((bool*)sa3)[3] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } +} + +NOIPA void access_sa3_ptr (void) +{ + bool *p = (bool*)&sa3[0]; + + p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[3] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } +} + +NOIPA void access_sa2_3_ptr (void) +{ + bool *p = (bool*)&sa2_3[0][0]; + + p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[6] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } +} + +NOIPA void access_sa3_4_5_ptr (struct S s, int i) +{ + bool *p = (bool*)&sa3_4_5[0][0][0]; + + p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[60] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } +} + + +NOIPA void access_vla3 (struct S s, unsigned n) +{ + struct S vla3[3 < n ? 3 : n]; + + ((bool*)vla3)[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + ((bool*)vla3)[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + ((bool*)vla3)[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + ((bool*)vla3)[3] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + + sink (vla3); +} + +NOIPA void access_vla3_ptr (struct S s, unsigned n) +{ + struct S vla3[3 < n ? 3 : n]; + bool *p = (bool*)&vla3[0]; + + p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[3] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + + sink (vla3); +} + +NOIPA void access_vla2_3_ptr (struct S s, unsigned n) +{ + struct S vla2_3[2 < n ? 2 : n][3 < n ? 3 : n]; + bool *p = (bool*)&vla2_3[0][0]; + + p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[6] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + + sink (vla2_3); +} + +NOIPA void access_vla3_4_5_ptr (struct S s, unsigned n) +{ + struct S vla3_4_5[3 < n ? 3 : n][4 < n ? 4 : n][5 < n ? 5 : n]; + bool *p = (bool*)&vla3_4_5[0][0][0]; + + p[0] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + p[60] = __LINE__; // { dg-warning "\\\[-Warray-bounds" } + + sink (vla3_4_5); +} + +// { dg-prune-output "empty struct has size 0 in C" } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-79.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-79.c new file mode 100644 index 0000000000..b44ac9d3aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-79.c @@ -0,0 +1,112 @@ +/* PR tree-optimization/99475 - bogus -Warray-bounds accessing an array + element of empty structs + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct S +{ +#if SOME_CONFIG_MACRO + /* Suppose the contents are empty in the development configuration + but non-empty in others. Out of bounds accesses to elements of + the arrays below should be diagnosed in all configurations, + including when S is empty, even if they are folded away. */ + int member; +#endif +}; + +extern struct S sa3[3]; +extern struct S sa2_3[2][3]; +extern struct S sa3_4_5[3][4][5]; + +void sink (void*); + + +void access_sa3 (void) +{ + sa3[0] = (struct S){ }; + sa3[1] = (struct S){ }; + sa3[2] = (struct S){ }; + sa3[3] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } +} + +void access_sa3_ptr (void) +{ + struct S *p = &sa3[0]; + + p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[3] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } +} + +void access_sa2_3_ptr (void) +{ + struct S *p = &sa2_3[0][0]; + + p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[6] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } +} + +void access_sa3_4_5_ptr (struct S s, int i) +{ + struct S *p = &sa3_4_5[0][0][0]; + + p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[60] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } +} + + +void access_vla3 (struct S s, unsigned n) +{ + struct S vla3[3 < n ? 3 : n]; + + vla3[0] = (struct S){ }; + vla3[1] = (struct S){ }; + vla3[2] = (struct S){ }; + vla3[3] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + + sink (vla3); +} + +void access_vla3_ptr (struct S s, unsigned n) +{ + struct S vla3[3 < n ? 3 : n]; + struct S *p = &vla3[0]; + + p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[3] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + + sink (vla3); +} + +void access_vla2_3_ptr (struct S s, unsigned n) +{ + struct S vla2_3[2 < n ? 2 : n][3 < n ? 3 : n]; + struct S *p = &vla2_3[0][0]; + + p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[6] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + + sink (vla2_3); +} + +void access_vla3_4_5_ptr (struct S s, unsigned n) +{ + struct S vla3_4_5[3 < n ? 3 : n][4 < n ? 4 : n][5 < n ? 5 : n]; + struct S *p = &vla3_4_5[0][0][0]; + + p[0] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[1] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[2] = (struct S){ }; // { dg-bogus "\\\[-Warray-bounds" } + p[60] = (struct S){ }; // { dg-warning "\\\[-Warray-bounds" "pr?????" { xfail *-*-* } } + + sink (vla3_4_5); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-8.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-8.c new file mode 100644 index 0000000000..85839f3f07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-8.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wall" } */ +/* based on PR 43833 */ + +extern unsigned char data[5]; + +unsigned char +foo (char *str) +{ + int i, j; + unsigned char c = 0; + + for (i = 0; i < 8; i++) + { + j = i * 5; + if ((j % 8) > 3) + c |= data[(j / 8) + 1]; + } + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-80.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-80.c new file mode 100644 index 0000000000..4ef32fbbfc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-80.c @@ -0,0 +1,96 @@ +/* PR tree-optimization/101397 - spurious warning writing to the result + of stpcpy minus 1 + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +char* stpcpy (char*, const char*); + +void sink (int, ...); + +extern char ax[], a3[3], a5[5], *s; + +volatile int x; + +void test_stpcpy (int i) +{ + { + char *p = stpcpy (ax, s); + x = p[-9]; // { dg-bogus "\\\[-Warray-bounds" } + x = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + x = p[ 0]; + x = p[+9]; + } + + { + char *p = stpcpy (a3, s); + x = p[-2]; // { dg-bogus "\\\[-Warray-bounds" } + x = p[-1]; // { dg-bogus "\\\[-Warray-bounds" } + } + + { + char *p = stpcpy (a3, s); + x = p[-3]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-2], p[-1], p[0], p[1], p[2]); + x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + /* Stpcpy always returns a pointer to the copied nul (which must + exist) and never a past-the-end pointer. As a result, P below + is in [a5, a5 + 4]. */ + char *p = stpcpy (a5, s); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = stpcpy (a5 + 1, s); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3]); + x = p[ 4]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = stpcpy (a5 + 2, s); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2]); + x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = stpcpy (a5 + 3, s); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1]); + x = p[ 2]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + /* Because strlen (a3) is at most 2, the stpcpy call must return + a pointer in the range [ax, ax + 2], and so -3 is necessarily + out of bounds. */ + char *p = stpcpy (ax, a3); + p[-3] = 1; // { dg-warning "\\\[-Warray-bounds" } + } + + { + if (i >= 0) + i = -1; + + char *p = stpcpy (a3, s); + x = p[i]; // { dg-bogus "\\\[-Warray-bounds" } + } + + { + if (i >= -3) + i = -3; + + char *p = stpcpy (a3, s); + p[i] = 1; // { dg-warning "\\\[-Warray-bounds" } + } + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-81.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-81.c new file mode 100644 index 0000000000..27e725d298 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-81.c @@ -0,0 +1,302 @@ +/* PR tree-optimization/101397 - spurious warning writing to the result + of stpcpy minus 1 + Verify warnings for indexing into a pointer returned from stpncpy. + The call stpncpy(S1, S2, N) returns the address of the copy of + the first NUL is it exists or &S1[N] otherwise. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-truncation" } */ + +typedef __SIZE_TYPE__ size_t; + +void* calloc (size_t, size_t); +char* stpncpy (char*, const char*, size_t); + +void sink (int, ...); + +extern char ax[], a3[3], a5[5], a7[7], a9[9], *s; + +volatile int x; + +/* Verify warnings for indexing into the result of stpncpy with a source + pointing to an array of unknown bound. */ + +void test_stpncpy_from_ptr (int i, int n) +{ + { + // P is in [ax, ax + 5]. + char *p = stpncpy (ax, s, 5); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-5], p[-1], p[0], p[9]); + } + + { + // P is in [a5, a5 + 3]. + char *p = stpncpy (a5, s, 3); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0]); + sink (p[ 1], p[ 2], p[ 3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // P is in [ax, ax + 4]. + char *p = stpncpy (a5, s, 4); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[ 1], p[ 2], p[ 3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // P is in [ax, ax + 5]. + char *p = stpncpy (a5, s, n); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[ 1], p[ 2], p[ 3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // P is in [ax, ax + 4]. + char *p = stpncpy (a5, s, 4); + + if (i > -1) i = -1; + x = p[i]; + + if (i > -2) i = -2; + x = p[i]; + + if (i > -3) i = -3; + x = p[i]; + + if (i > -4) i = -4; + x = p[i]; + + if (i > -5) i = -5; + x = p[i]; // { dg-warning "\\\[-Warray-bounds" } + } +} + +/* Verify warnings for indexing into the result of stpncpy with a source + an array of size 5. */ + +void test_stpncpy_from_a5 (int i, int n, int n3_9) +{ + { + // The returned pointer is in [ax, ax + 3]. + char *p = stpncpy (ax, a5, 3); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0], p[1], p[99]); + } + + { + // The returned pointer is in [ax, ax + 5]. + char *p = stpncpy (ax, a5, 5); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-5]; + x = p[-1]; + x = p[ 0]; + x = p[ 9]; + } + + { + //The returned pointer is in [ax, ax + 5] even though n is not known. + char *p = stpncpy (ax, a5, n); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-5], p[-4], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[9], p[99]); + } + + + { + // The returned pointer is in [a3, a3 + 3]. + char *p = stpncpy (a3, a5, 3); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0]); + sink (p[ 1], p[ 2]); + x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // The returned pointer is in [a3, a3 + 3]. + char *p = stpncpy (a3, a5, n); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0]); + sink (p[ 1], p[ 2]); + x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + if (n3_9 < 3 || 9 < n3_9) + n3_9 = 3; + + // The returned pointer is in [a3, a3 + 3]. + char *p = stpncpy (a3, a5, n3_9); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0]); + sink (p[ 1], p[ 2]); + x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = stpncpy (a3, a5, 3); + + if (i > -1) i = -1; + x = p[i]; + + if (i > -2) i = -2; + x = p[i]; + + if (i > -3) i = -3; + x = p[i]; + + if (i > -4) i = -4; + x = p[i]; // { dg-warning "\\\[-Warray-bounds" } + } +} + + +/* Verify warnings for indexing into the result of stpncpy with a source + an array of size 7. */ + +void test_stpncpy_from_a7 (int i, int n, int n3_9) +{ + { + // The returned pointer is ax + 5. + char *p = stpncpy (ax, a7, 5); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-5]; + x = p[-1]; + x = p[ 0]; + x = p[ 9]; + } + + { + //The returned pointer is in [ax, ax + 7] even though n is not known. + char *p = stpncpy (ax, a7, n); + x = p[-8]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-7], p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]); + } + + + { + // The returned pointer is in [a5, a5 + 3]. + char *p = stpncpy (a5, a7, 3); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // The returned pointer is a5 + 4. + char *p = stpncpy (a5, a7, 4); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // The returned pointer is in [a5, a5 + 5]. + char *p = stpncpy (a5, a7, n); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + if (n3_9 < 3 || 9 < n3_9) + n3_9 = 3; + + // The returned pointer is in [a5, a5 + 5]. + char *p = stpncpy (a5, a7, n3_9); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = stpncpy (a5, a7, 4); + + if (i > -1) i = -1; + x = p[i]; + + if (i > -2) i = -2; + x = p[i]; + + if (i > -3) i = -3; + x = p[i]; + + if (i > -4) i = -4; + x = p[i]; + + if (i > -5) i = -5; + x = p[i]; // { dg-warning "\\\[-Warray-bounds" } + } +} + + +void test_stpncpy_from_a5_to_allocated (int i, int n, int n5_7, int n3_9) +{ + if (n5_7 < 5 || 7 < n5_7) + n5_7 = 5; + + { + char *d = calloc (n5_7, 1); + char *p = stpncpy (d, s, n); + x = p[-8]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-7], p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *d = calloc (n5_7, 1); + char *p = stpncpy (d, a3, n); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *d = calloc (n5_7, 1); + char *p = stpncpy (d, a5, n); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *d = calloc (n5_7, 1); + char *p = stpncpy (d, a9, n); + x = p[-8]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-7], p[-6], p[-5], p[-3], p[-4], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *d = calloc (n5_7, 1); + char *p = stpncpy (d, a3, n3_9); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *d = calloc (n5_7, 1); + char *p = stpncpy (d, a9, n3_9); + x = p[-8]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-7], p[-6], p[-5], p[-4], p[-4], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-82.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-82.c new file mode 100644 index 0000000000..b5dd919dce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-82.c @@ -0,0 +1,258 @@ +/* PR tree-optimization/101397 - spurious warning writing to the result + of stpcpy minus 1 + Verify warnings for indexing into a pointer returned from mempcpy. + The call mempcpy(S1, S2, N) returns &S1[N]. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +void* mempcpy (void*, const void*, size_t); + +extern char ax[], a3[3], a5[5], a7[7], *s; + +volatile int x; + +/* Verify warnings for indexing into the result of mempcpy with a source + pointing to an array of unknown bound. */ + +void test_mempcpy_from_ptr (int i) +{ + { + char *p = mempcpy (ax, s, 5); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-5]; + x = p[-1]; + x = p[ 0]; + x = p[ 9]; + } + + { + char *p = mempcpy (a5, s, 3); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-3]; + x = p[-2]; + x = p[-1]; + x = p[ 0]; + x = p[ 1]; + x = p[ 2]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = mempcpy (a5, s, 4); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-4]; + x = p[-3]; + x = p[-2]; + x = p[-1]; + x = p[ 0]; + x = p[ 1]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = mempcpy (a5, s, 4); + + if (i > -1) i = -1; + x = p[i]; + + if (i > -2) i = -2; + x = p[i]; + + if (i > -3) i = -3; + x = p[i]; + + if (i > -4) i = -4; + x = p[i]; + + if (i > -5) i = -5; + x = p[i]; // { dg-warning "\\\[-Warray-bounds" } + } +} + +/* Verify warnings for indexing into the result of mempcpy with a source + an array of size 5. */ + +void test_mempcpy_from_a5 (int i, int n, int n3_9) +{ + { + // The returned pointer is ax + 3 as specified by the bound. + char *p = mempcpy (ax, a5, 3); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-3]; + x = p[-2]; + x = p[ 0]; + x = p[ 1]; + x = p[ 2]; + } + + { + // The returned pointer is ax + 5. + char *p = mempcpy (ax, a5, 5); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-5]; + x = p[-1]; + x = p[ 0]; + x = p[ 9]; + } + + { + //The returned pointer is in [ax, ax + 5] even though n is not known. + char *p = mempcpy (ax, a5, n); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-5]; + x = p[-1]; + x = p[ 0]; + x = p[ 9]; + } + + + { + // The returned pointer is a3 + 3. + char *p = mempcpy (a3, a5, 3); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-3]; + x = p[-1]; + x = p[ 0]; // { dg-warning "\\\[-Warray-bounds" } + x = p[ 1]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // The returned pointer is in [a3, a3 + 3]. + char *p = mempcpy (a3, a5, n); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-3]; + x = p[-2]; + x = p[-1]; + x = p[ 0]; + x = p[ 2]; + x = p[ 3]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + if (n3_9 < 3 || 9 < n3_9) + n3_9 = 3; + + // The returned pointer is a3. + char *p = mempcpy (a3, a5, n3_9); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-3]; + x = p[-2]; + x = p[-1]; + x = p[ 0]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = mempcpy (a3, a5, 3); + + if (i > -1) i = -1; + x = p[i]; + + if (i > -2) i = -2; + x = p[i]; + + if (i > -3) i = -3; + x = p[i]; + + if (i > -4) i = -4; + x = p[i]; // { dg-warning "\\\[-Warray-bounds" } + } +} + + +/* Verify warnings for indexing into the result of mempcpy with a source + an array of size 7. */ + +void test_mempcpy_from_a7 (int i, int n, int n3_9) +{ + { + // The returned pointer is ax + 5. + char *p = mempcpy (ax, a7, 5); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-5]; + x = p[-1]; + x = p[ 0]; + x = p[ 9]; + } + + { + //The returned pointer is in [ax, ax + 7] even though n is not known. + char *p = mempcpy (ax, a7, n); + x = p[-8]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-7]; + x = p[-1]; + x = p[ 0]; + x = p[ 9]; + } + + + { + // The returned pointer is a5 + 3 as specified by the bound. + char *p = mempcpy (a5, a7, 3); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-3]; + x = p[-2]; + x = p[ 0]; + x = p[ 1]; + x = p[ 2]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // The returned pointer is a5 + 4. + char *p = mempcpy (a5, a7, 4); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-4]; + x = p[-3]; + x = p[-2]; + x = p[-1]; + x = p[ 0]; + x = p[ 1]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // The returned pointer is in [a5, a5 + 5]. + char *p = mempcpy (a5, a7, n); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-5]; + x = p[-3]; + x = p[-2]; + x = p[-1]; + x = p[ 0]; + x = p[ 4]; + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + if (n3_9 < 3 || 9 < n3_9) + n3_9 = 3; + + // The returned pointer is in [a5 + 3, a5 + 5]. + char *p = mempcpy (a5, a7, n3_9); + x = p[-6]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-5]; + x = p[-3]; + x = p[-2]; + x = p[-1]; + x = p[ 0]; + x = p[ 1]; + x = p[ 2]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = mempcpy (a5, a7, 4); + + if (i > -1) i = -1; + x = p[i]; + + if (i > -2) i = -2; + x = p[i]; + + if (i > -3) i = -3; + x = p[i]; + + if (i > -4) i = -4; + x = p[i]; + + if (i > -5) i = -5; + x = p[i]; // { dg-warning "\\\[-Warray-bounds" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-83.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-83.c new file mode 100644 index 0000000000..b1d02eaffc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-83.c @@ -0,0 +1,172 @@ +/* PR tree-optimization/101397 - spurious warning writing to the result + of stpcpy minus 1 + Verify warnings for indexing into a pointer returned from stpncpy. + The call stpncpy(S1, S2, N) returns the address of the copy of + the first NUL is it exists or &S1[N] otherwise. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-truncation" } */ + +typedef __SIZE_TYPE__ size_t; + +__attribute__ ((alloc_size (1))) const void* alloc (size_t); + +void* memchr (const void*, int, size_t); + +void sink (int, ...); + +extern char ax[], a3[3], a5[5], a7[7], a9[9]; + +volatile int x; + +/* Verify warnings for indexing into the result of memchr. */ + +void test_memchr (int i, int n, int n3_5, int n3_9) +{ + { + /* Because memchr never returns a past-the-end pointer the result + below is in [ax, ax + 4]. */ + const char *p = memchr (ax, x, 5); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + x = p[-4]; + x = p[-1]; + x = p[ 0]; + x = p[ 9]; + } + + { + // The returned pointer is in [ax, ax + n]. + const char *p = memchr (ax, x, n); + sink (p[-99], p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[99]); + } + + + { + // The returned pointer is in [a5, a5 + 2]. + const char *p = memchr (a5, x, 3); + x = p[-3]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // The returned pointer is a5 + 4. + const char *p = memchr (a5, x, 4); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + // The returned pointer is in [a5, a5 + 4]. + const char *p = memchr (a5, x, n); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + if (n3_5 < 3 || 5 < n3_5) + n3_5 = 3; + + // The returned pointer is in [a7, a7 + 4]. + const char *p = memchr (a7, x, n3_5); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + if (n3_9 < 3 || 9 < n3_9) + n3_9 = 3; + + // The returned pointer is in [a5, a5 + 4]. + const char *p = memchr (a5, x, n3_9); + x = p[-5]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *p = memchr (a5, x, 4); + + if (i > -1) i = -1; + x = p[i]; + + if (i > -2) i = -2; + x = p[i]; + + if (i > -3) i = -3; + x = p[i]; + + if (i > -4) i = -4; + x = p[i]; // { dg-warning "\\\[-Warray-bounds" } + } +} + + +void test_memchr_in_allocated (int i, int n, int n5_7, int n3_9) +{ + if (n5_7 < 5 || 7 < n5_7) + n5_7 = 5; + + { + const char *s = alloc (n5_7); + const char *p = memchr (s, x, n); + x = p[-7]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-6], p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *s = alloc (n5_7); + const char *p = memchr (s, x, n); + x = p[-7]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *s = alloc (n5_7); + const char *p = memchr (s, x, n); + x = p[-7]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *s = alloc (n5_7); + const char *p = memchr (s, x, n); + x = p[-7]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-6], p[-5], p[-3], p[-4], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *s = alloc (n5_7); + const char *p = memchr (s, x, n3_9); + x = p[-7]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-6], p[-5], p[-4], p[-3], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + const char *s = alloc (n5_7); + const char *p = memchr (s, x, n3_9); + x = p[-7]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-6], p[-5], p[-4], p[-4], p[-2], p[-1], p[0]); + sink (p[1], p[2], p[3], p[4], p[5], p[6]); + x = p[7]; // { dg-warning "\\\[-Warray-bounds" } + } + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-84.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-84.c new file mode 100644 index 0000000000..b9350d79eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-84.c @@ -0,0 +1,65 @@ +/* PR tree-optimization/101397 - spurious warning writing to the result + of stpcpy minus 1 + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +char* strcpy (char*, const char*); + +void sink (int, ...); + +extern char ax[], a3[3], a5[5], *s; + +volatile int x; + +void test_strcpy (int i) +{ + { + char *p = strcpy (ax, s); + x = p[-1]; // { dg-warning "\\\[-Warray-bounds" } + x = p[ 0]; + x = p[+9]; + } + + { + char *p = strcpy (a3, s); + x = p[-1]; // { dg-warning "\\\[-Warray-bounds" } + x = p[0]; + x = p[1]; + x = p[2]; + x = p[3]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = strcpy (a5, s); + x = p[-1]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[0], p[1], p[2], p[3], p[4]); + x = p[ 5]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = strcpy (a5 + 1, s); + x = p[-2]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-1], p[0], p[1], p[2], p[3]); + x = p[4]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = strcpy (a5 + 2, s); + x = p[-3]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-2], p[-1], p[0], p[1], p[2]); + x = p[3]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = strcpy (a5 + 3, s); + x = p[-4]; // { dg-warning "\\\[-Warray-bounds" } + sink (p[-3], p[-2], p[-1], p[0], p[1]); + x = p[2]; // { dg-warning "\\\[-Warray-bounds" } + } + + { + char *p = strcpy (ax, a3); + p[-1] = 1; // { dg-warning "\\\[-Warray-bounds" } + sink (p[0], p[1], p[2], p[9], p[99]); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-85.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-85.c new file mode 100644 index 0000000000..0ee71200cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-85.c @@ -0,0 +1,30 @@ +/* PR middle-end/101601 - [12 Regression] -Warray-bounds triggers error: + arrays of functions are not meaningful + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef void Fvv (void); + +extern Fvv* pf; // { dg-message "'pf'" } + +void f (void*); + +void test_funptr (void) +{ + f (&pf); + f (&pf + 1); + f (&pf + 2); // { dg-warning "subscript 2 is outside array bounds of 'void \\\(\\\*\\\[1]\\\)\\\(void\\\)'" } +} + +typedef int Fii_ (int, ...); + +extern Fii_* pfa[3]; // { dg-message "'pfa'" } + +void test_funptr_array (void) +{ + f (pfa); + f (pfa + 1); + f (pfa + 2); + f (pfa + 3); + f (pfa + 4); // { dg-warning "subscript 4 is outside array bounds of 'int \\\(\\\*\\\[3]\\\)\\\(int, ...\\\)'" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-87.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-87.c new file mode 100644 index 0000000000..a5457807c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-87.c @@ -0,0 +1,48 @@ +/* PR middle-end/101671 - pr83510 fails with -Os because threader confuses + -Warray-bounds + { dg-do compile } + { dg-options "-Os -Wall" } */ + +extern int f (void); +extern void sink (unsigned int); + +unsigned int a[10]; + +static unsigned int g (int i, int j) +{ + if (i == 9) + return j; + else if (i == 10) + return a[i]; // no warning here + return 0; +} + +void test_g (int j) +{ + for (int i = 0; i < 10; i++) + { + if (f ()) + sink (g (i, j)); + } +} + +static unsigned int h (int i, int j) +{ + switch (i) + { + case 9: + return j; + case 10: + return a[i]; // { dg-bogus "-Warray-bounds" "pr101671" } + } + return 0; +} + +void test_h (int j) +{ + for (int i = 0; i < 10; i++) + { + if (f ()) + sink (h (i, j)); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-88.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-88.c new file mode 100644 index 0000000000..8cee8d2857 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-88.c @@ -0,0 +1,134 @@ +/* PR middle-end/101977 - bogus -Warray-bounds on a negative index into + a parameter in conditional with null + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct A { int i; }; +struct B { struct A a1; struct A a2; }; + + +void nowarn_p_0_0 (struct A *p, int i) +{ + struct A *q = i < 0 ? p : 0 < i ? (struct A*)0 : 0; + struct B *r = (struct B*)((char *)q - __builtin_offsetof (struct B, a2)); + r->a1.i = 0; +} + +void nowarn_0_p_0 (struct A *p, int i) +{ + struct A *q = i < 0 ? 0 : 0 < i ? p : 0; + struct B *r = (struct B*)((char *)q - __builtin_offsetof (struct B, a2)); + r->a1.i = 0; // { dg-bogus "-Warray-bounds" } +} + +void nowarn_0_0_p (struct A *p, int i) +{ + struct A *q = i < 0 ? 0 : 0 < i ? 0 : p; + struct B *r = (struct B*)((char *)q - __builtin_offsetof (struct B, a2)); + r->a1.i = 0; // { dg-bogus "-Warray-bounds" } +} + + +void nowarn_p_q_0 (struct A *p, struct A *q, int i) +{ + struct A *r = i < 0 ? p : 0 < i ? q : 0; + struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2)); + s->a1.i = 0; // { dg-bogus "-Warray-bounds" } +} + +void nowarn_p_0_q (struct A *p, struct A *q, int i) +{ + struct A *r = i < 0 ? p : 0 < i ? 0 : q; + struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2)); + s->a1.i = 0; // { dg-bogus "-Warray-bounds" } +} + +void nowarn_0_p_q (struct A *p, struct A *q, int i) +{ + struct A *r = i < 0 ? 0 : 0 < i ? p : q; + struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2)); + s->a1.i = 0; +} + + +void nowarn_p_q_r (struct A *p, struct A *q, struct A *r, int i) +{ + struct A *s = i < 0 ? p : 0 < i ? q : r; + struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2)); + t->a1.i = 0; +} + + +extern struct B b1, b2, b3; + +void nowarn_p_b1_0 (struct A *p, int i) +{ + struct A *r = i < 0 ? p : 0 < i ? &b1.a2 : 0; + struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2)); + s->a1.i = 0; // { dg-bogus "-Warray-bounds" } +} + +void nowarn_p_0_b1 (struct A *p, int i) +{ + struct A *r = i < 0 ? p : 0 < i ? 0 : &b1.a2; + struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2)); + s->a1.i = 0; // { dg-bogus "-Warray-bounds" } +} + +void nowarn_0_p_b1 (struct A *p, int i) +{ + struct A *r = i < 0 ? 0 : 0 < i ? p : &b1.a2; + struct B *s = (struct B*)((char *)r - __builtin_offsetof (struct B, a2)); + s->a1.i = 0; +} + + +void nowarn_p_b1_b2 (struct A *p, int i) +{ + struct A *s = i < 0 ? p : 0 < i ? &b1.a2 : &b2.a2; + struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2)); + t->a1.i = 0; +} + +void nowarn_b1_p_b2 (struct A *p, int i) +{ + struct A *s = i < 0 ? &b1.a2 : 0 < i ? p : &b2.a2; + struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2)); + t->a1.i = 0; +} + +void nowarn_b1_b2_p (struct A *p, int i) +{ + struct A *s = i < 0 ? &b1.a2 : 0 < i ? &b2.a2 : p; + struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2)); + t->a1.i = 0; +} + +void nowarn_b1_b2_b3 (struct A *p, int i) +{ + struct A *s = i < 0 ? &b1.a2 : 0 < i ? &b2.a2 : &b3.a2; + struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2)); + t->a1.i = 0; +} + + +void nowarn_0_b1_b2 (int i) +{ + struct A *s = i < 0 ? 0 : 0 < i ? &b1.a2 : &b2.a2; + struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2)); + t->a1.i = 0; +} + +void warn_b1_0_b2 (int i) +{ + struct A *s = i < 0 ? &b1.a2 : 0 < i ? 0 : &b2.a2; + struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2)); + t->a1.i = 0; +} + +void warn_b1_b2_0 (int i) +{ + struct A *s = i < 0 ? &b1.a2 : 0 < i ? &b2.a2 : 0; + struct B *t = (struct B*)((char *)s - __builtin_offsetof (struct B, a2)); + t->a1.i = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-89.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-89.c new file mode 100644 index 0000000000..2604f65e6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-89.c @@ -0,0 +1,139 @@ +/* Verify warnings and notes for MIN_EXPRs involving either pointers + to distinct objects or one to a known object and the other to + an unknown one. The relational expressions are strictly invalid + but that should be diagnosed by a separate warning. + { dg-do compile } + { dg-options "-O2 -Warray-bounds -Wno-stringop-overflow" } */ + +/* Verify the note points to the larger of the two objects and mentions + the offset into it (alhough the offset would ideally be a part of + the warning). */ +extern char a3[3]; +extern char a5[5]; // { dg-message "at offset 5 into object 'a5' of size 5" "note" } + +void min_a3_a5 (int i) +{ + char *p = a3 + i; + char *q = a5 + i; + + /* The relational expression below is invalid and should be diagnosed + by its own warning independently of -Warray-bounds. */ + char *d = p < q ? p : q; + + d[4] = 0; + + /* Verify the type in the warning corresponds to the larger of the two + objects. */ + d[5] = 0; // { dg-warning "subscript 5 is outside array bounds of 'char\\\[5]'" } +} + + +// Same as above but with the larger array as the first MIN_EXPR operand. +extern char b4[4]; +extern char b6[6]; // { dg-message "at offset 6 into object 'b6' of size 6" "note" } + +void min_b6_b4 (int i) +{ + char *p = b6 + i; + char *q = b4 + i; + char *d = p < q ? p : q; + + d[5] = 0; + d[6] = 0; // { dg-warning "subscript 6 is outside array bounds of 'char\\\[6]'" } +} + + +/* Same as above but with the first MIN_EXPR operand pointing to an unknown + object. */ +extern char c7[7]; // { dg-message "at offset 7 into object 'c7' of size 7" "note" } + +void min_p_c7 (char *p, int i) +{ + char *q = c7 + i; + char *d = p < q ? p : q; + + d[6] = 0; + d[7] = 0; // { dg-warning "subscript 7 is outside array bounds of 'char\\\[7]'" } +} + + +/* Same as above but with the second MIN_EXPR operand pointing to an unknown + object. */ +extern char d8[8]; // { dg-message "at offset 8 into object 'd8' of size 8" "note" } + +void min_d8_p (char *q, int i) +{ + char *p = d8 + i; + char *d = p < q ? p : q; + + d[7] = 0; + d[8] = 0; // { dg-warning "subscript 8 is outside array bounds of 'char\\\[8]'" } +} + + +/* The following are diagnosed by -Wstringop-overflow but, as a result + of PR 101374, not by -Warray-bounds. */ + +struct A3_5 +{ + char a3[3]; + char a5[5]; // { dg-message "at offset 5 into object 'a5' of size 5" "note" { xfail *-*-* } } +}; + +void min_A3_A5 (int i, struct A3_5 *pa3_5) +{ + char *p = pa3_5->a3 + i; + char *q = pa3_5->a5 + i; + + char *d = p < q ? p : q; + + // d[4] = 0; + d[5] = 0; // { dg-warning "subscript 5 is outside array bounds of 'char\\\[5]'" "pr??????" { xfail *-*-* } } +} + + +struct B4_B6 +{ + char b4[4]; + char b6[6]; // { dg-message "at offset 6 into object 'b6' of size 6" "note" { xfail *-*-* } } +}; + +void min_B6_B4 (int i, struct B4_B6 *pb4_b6) +{ + char *p = pb4_b6->b6 + i; + char *q = pb4_b6->b4 + i; + char *d = p < q ? p : q; + + d[5] = 0; + d[6] = 0; // { dg-warning "subscript 6 is outside array bounds of 'char\\\[6]'" "pr??????" { xfail *-*-* } } +} + + +struct C7 +{ + char c7[7]; // { dg-message "at offset 7 into object 'c7' of size 7" "note" { xfail *-*-* } } +}; + +void min_p_C7 (char *p, int i, struct C7 *pc7) +{ + char *q = pc7->c7 + i; + char *d = p < q ? p : q; + + d[6] = 0; + d[7] = 0; // { dg-warning "subscript 7 is outside array bounds of 'char\\\[7]'" "pr??????" { xfail *-*-* } } +} + + +struct D8 +{ + char d8[8]; // { dg-message "at offset 8 into object 'd8' of size 8" "note" { xfail *-*-* } } +}; + +void min_D8_p (char *q, int i, struct D8 *pd8) +{ + char *p = pd8->d8 + i; + char *d = p < q ? p : q; + + d[7] = 0; + d[8] = 0; // { dg-warning "subscript 8 is outside array bounds of 'char\\\[8]'" "pr??????" { xfail *-*-* } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-9.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-9.c new file mode 100644 index 0000000000..92bcd4e5ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-9.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ + +int a[8]; + +void +test(unsigned int n) +{ + unsigned int i; + unsigned int j; + if (n<8) + for (j=0;jc[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */ + /*{ dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_1->c[2] = 2; /* { dg-bogus "array subscript " } */ + trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */ + trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-2.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-2.c new file mode 100644 index 0000000000..55b7535424 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-2.c @@ -0,0 +1,41 @@ +/* Test -fstrict-flex-arrays + -Warray-bounds + -Wstrict-flex-arrays. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=2 -Warray-bounds" } */ + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */ + /*{ dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_1->c[2] = 2; /* { dg-warning "array subscript 2 is above array bounds of" } */ + /* { dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */ + trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-3.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-3.c new file mode 100644 index 0000000000..abdf8f15c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-3.c @@ -0,0 +1,42 @@ +/* Test -fstrict-flex-arrays + -Warray-bounds + -Wstrict-flex-arrays. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=3 -Warray-bounds" } */ + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */ + /*{ dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_1->c[2] = 2; /*{ dg-warning "array subscript 2 is above array bounds of" } */ + /* { dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_0->c[1] = 1; /*{ dg-warning "array subscript 1 is outside array bounds of" } */ + /* { dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_flex->c[10] = 10; /* { dg-bogus "array subscript" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-4.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-4.c new file mode 100644 index 0000000000..82b38ff1ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-4.c @@ -0,0 +1,40 @@ +/* Test -fstrict-flex-arrays + -Warray-bounds=2 + -Wstrict-flex-arrays. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=1 -Warray-bounds=2" } */ + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */ + /*{ dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_1->c[2] = 2; /* { dg-bogus "array subscript " } */ + trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */ + trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-5.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-5.c new file mode 100644 index 0000000000..dca02288be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-5.c @@ -0,0 +1,41 @@ +/* Test -fstrict-flex-arrays + -Warray-bounds=2 + -Wstrict-flex-arrays. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=2 -Warray-bounds=2" } */ + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */ + /*{ dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_1->c[2] = 2; /*{ dg-warning "array subscript 2 is above array bounds of" } */ + /* { dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_0->c[1] = 1; /* { dg-bogus "array subscript " } */ + trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-6.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-6.c new file mode 100644 index 0000000000..fc9f73b453 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds-flex-arrays-6.c @@ -0,0 +1,42 @@ +/* Test -fstrict-flex-arrays + -Warray-bounds=2 + -Wstrict-flex-arrays. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=3 -Warray-bounds=2" } */ + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + normal->c[5] = 5; /*{ dg-warning "array subscript 5 is above array bounds of" } */ + /*{ dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_1->c[2] = 2; /*{ dg-warning "array subscript 2 is above array bounds of" } */ + /* { dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_0->c[1] = 1; /*{ dg-warning "array subscript 1 is outside array bounds of" } */ + /* { dg-warning "should not be used as a flexible array member" "" { target *-*-* } .-1 } */ + trailing_flex->c[10] = 10; /* { dg-bogus "array subscript " } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-bounds.c b/SingleSource/Regression/C/gcc-dg/Warray-bounds.c new file mode 100644 index 0000000000..925f562bcd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-bounds.c @@ -0,0 +1,101 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +int a[10]; + +static inline int n(void) { + __SIZE_TYPE__ strlen(const char *s); + return strlen("12345"); +} + +void g(int *p); +void h(int p); + +void bar (void *); + +int* f(void) { + int b[10]; + int i; + struct { + int c[10]; + } c; + + a[-1] = 0; /* { dg-warning "6:array subscript" } */ + a[ 0] = 0; + a[ 1] = 0; + + + a[ 9] = 0; + a[10] = 0; /* { dg-warning "6:array subscript" } */ + a[11] = 0; /* { dg-warning "6:array subscript" } */ + bar (a); + a[2 * n() - 11] = 1; /* { dg-warning "6:array subscript" } */ + a[2 * n() - 10] = 1; + a[2 * n() - 1] = 1; + a[2 * n() - 0] = 1; /* { dg-warning "6:array subscript" } */ + bar (a); + + b[-1] = 0; /* { dg-warning "6:array subscript" } */ + b[ 0] = 0; + b[ 1] = 0; + b[ 9] = 0; + b[10] = 0; /* { dg-warning "6:array subscript" } */ + b[11] = 0; /* { dg-warning "6:array subscript" } */ + bar (b); + b[2 * n() - 11] = 1; /* { dg-warning "6:array subscript" } */ + b[2 * n() - 10] = 1; + b[2 * n() - 1] = 1; + b[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */ + + c.c[-1] = 0; /* { dg-warning "8:array subscript" } */ + c.c[ 0] = 0; + c.c[ 1] = 0; + c.c[ 9] = 0; + c.c[10] = 0; /* { dg-warning "8:array subscript" } */ + c.c[11] = 0; /* { dg-warning "8:array subscript" } */ + bar (&c); + c.c[2 * n() - 11] = 1; /* { dg-warning "8:array subscript" } */ + c.c[2 * n() - 10] = 1; + c.c[2 * n() - 1] = 1; + c.c[2 * n() - 0] = 1; /* { dg-warning "8:array subscript" } */ + + g(&a[8]); + g(&a[9]); + g(&a[10]); + g(&a[11]); /* { dg-warning "array subscript" } */ + g(&a[-30]+10); /* { dg-warning "array subscript" } */ + g(&a[-30]+30); + + g(&b[10]); + g(&c.c[10]); + g(&b[11]); /* { dg-warning "array subscript" } */ + g(&c.c[11]); /* { dg-warning "array subscript" } */ + + g(&a[0]); + g(&b[0]); + g(&c.c[0]); + + g(&a[-1]); /* { dg-warning "array subscript" } */ + g(&b[-1]); /* { dg-warning "array subscript" } */ + h(sizeof a[-1]); + h(sizeof a[10]); + h(sizeof b[-1]); + h(sizeof b[10]); + h(sizeof c.c[-1]); + h(sizeof c.c[10]); + + if (10 < 10) + a[10] = 0; + if (10 < 10) + b[10] = 0; + if (-1 >= 0) + c.c[-1] = 0; + + for (i = 20; i < 30; ++i) + a[i] = 1; /* { dg-warning "15:array subscript" } */ + + bar (b); + bar (&c); + return a; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-10.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-10.c new file mode 100644 index 0000000000..378f8afbd3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-10.c @@ -0,0 +1,20 @@ +/* PR c/102759 - ICE calling a function taking an argument redeclared + without a prototype. + { dg-do compile } + { dg-options "-Wall" } */ + +void f (void) +{ + void gia (int[2]); + void g (); +} + +/* Redeclaring the g(int[]) above without a prototype loses it. */ +void gia (); +void g (int[2]); + +void h (void ) +{ + gia (gia); + gia (g); +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-11.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-11.c new file mode 100644 index 0000000000..8ca1b55bd2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-11.c @@ -0,0 +1,24 @@ +/* PR c/101702 - ICE on invalid function redeclaration + { dg-do compile } + { dg-options "-Wall" } */ + +typedef __INTPTR_TYPE__ intptr_t; + +#define copysign(x, y) __builtin_copysign (x, y) + +void f0 (double[!copysign (~2, 3)]); + +void f1 (double[!copysign (~2, 3)]); +void f1 (double[1]); // { dg-warning "-Warray-parameter" } + +void f2 (int[(int)+1.0]); +void f2 (int[(int)+1.1]); + +/* Also verify that equivalent expressions don't needlessly cause false + positives or negatives. */ +struct S { int a[1]; }; +extern struct S *sp; + +void f3 (int[(intptr_t)((char*)sp->a - (char*)sp)]); +void f3 (int[(intptr_t)((char*)&sp->a[0] - (char*)sp)]); +void f3 (int[(intptr_t)((char*)&sp->a[1] - (char*)sp)]); // { dg-warning "-Warray-parameter" } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-2.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-2.c new file mode 100644 index 0000000000..88f20e203c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-2.c @@ -0,0 +1,45 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + { dg-do compile } + { dg-options "-Wall" } */ + +// Reduced from Glibc. + +typedef struct FILE FILE; + +int vfprintf (FILE*, const char*, __builtin_va_list); +int vfprintf (FILE*, const char*, __builtin_va_list); // { dg-bogus "-Warray-parameter" } +int vfprintf (FILE*, const char*, __builtin_va_list); + +int vfscanf (FILE*, const char*, __builtin_va_list); +int vfscanf (FILE*, const char*, __builtin_va_list); // { dg-bogus "-Warray-parameter" } +int vfscanf (FILE*, const char*, __builtin_va_list); + + +/* Verify that mismatches in array/to pointer to va_list are still + diagnosed. */ + +int fva (__builtin_va_list); +int fva (__builtin_va_list); + +int fpva_a1 (__builtin_va_list*); +int fpva_a1 (__builtin_va_list[1]); // { dg-warning "\\\[-Warray-parameter" } + +int fpva_a_ (__builtin_va_list*); +int fpva_a_ (__builtin_va_list[]); +int fpva_a_ (__builtin_va_list*); +int fpva_a_ (__builtin_va_list[]); + +/* Also verify that a mismatch between a pointer and a one-element + array are diagnosed. This is pervasive in Glibc headers but + making an exception for it would leave no way to express + the requirement that a function take at least one argument + by reference. */ + +struct __jmp_buf_tag; +int __sigsetjmp (struct __jmp_buf_tag*, int); + +struct __jmp_buf_tag { }; +typedef struct __jmp_buf_tag jmp_buf[1]; + +int __sigsetjmp (struct __jmp_buf_tag[1], int); // { dg-warning "\\\[-Warray-parameter" } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-3-novec.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-3-novec.c new file mode 100644 index 0000000000..5089d55539 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-3-novec.c @@ -0,0 +1,16 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + { dg-do compile } + { dg-options "-Wall -Warray-parameter=1" } */ + +/* Also verify that -Warray-bounds doesn't trigger for ordinary array + parameters... */ +#pragma GCC optimize ("2,no-tree-vectorize") + +/* ...but does for static arrays. */ +__attribute__ ((noipa)) void +gcas3 (char a[static 3]) +{ + a[0] = 0; a[1] = 1; a[2] = 2; + a[3] = 3; // { dg-warning "\\\[-Warray-bounds" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-3.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-3.c new file mode 100644 index 0000000000..b888511ce1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-3.c @@ -0,0 +1,89 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + { dg-do compile } + { dg-options "-Wall -Warray-parameter=1" } */ + +/* Verify that at level 1 mismatches in the bounds of ordinary array + parameters don't trigger -Warray-parameter. */ +void fax (int[]); +void fax (int[0]); +void fax (int[1]); +void fax (int[2]); +void fax (int[3]); + +/* Same as above but starting with an array with a specified bound. */ +void gax (int[3]); +void gax (int[2]); +void gax (int[1]); +void gax (int[0]); +void gax (int[]); + +/* Same for multidimensional arrays. */ +void fax_y (int[][3]); +void fax_y (int[0][3]); +void fax_y (int[1][3]); +void fax_y (int[2][3]); +void fax_y (int[3][3]); + +/* Same as above but starting with an array with a specified bound. */ +void gax_y (int[3][5]); +void gax_y (int[2][5]); +void gax_y (int[1][5]); +void gax_y (int[0][5]); +void gax_y (int[][5]); + +/* Exercise VLAs with a mismatch in the bound for an ordinary array. */ +void fvlax_y (int n, int[][n]); +void fvlax_y (int n, int[0][n]); +void fvlax_y (int n, int[1][n]); +void fvlax_y (int n, int[2][n]); +void fvlax_y (int n, int[3][n]); + +void fvlaxn_y (int n, int[][n]); +void fvlaxn_y (int n, int[0][n]); +void fvlaxn_y (int n, int[1][n]); +void fvlaxn_y (int n, int[2][n]); +void fvlaxn_y (int n, int[3][n]); + +void fvlaxx_y (int[][*]); +void fvlaxx_y (int[0][*]); +void fvlaxx_y (int[1][*]); +void fvlaxx_y (int[2][*]); +void fvlaxx_y (int[3][*]); + +/* Verify that mismatches in the bounds of array parameters declared + static do trigger -Warray-parameter. */ +void fas1 (int[static 1]); // { dg-message "previously declared as 'int\\\[static 1]'" } +void fas1 (int[static 2]); // { dg-warning "\\\[-Warray-parameter=" } + + +/* Also verify that -Warray-bounds doesn't trigger for ordinary array + parameters... */ +#pragma GCC optimize ("2") + +__attribute__ ((noipa)) void +gca3 (char a[3]) +{ + a[0] = 0; a[1] = 1; a[2] = 2; a[3] = 3; +} + +__attribute__ ((noipa)) void +gia3 (int a[3]) +{ + a[0] = 0; a[1] = 1; a[2] = 2; a[3] = 3; +} + +/* ...but does for static arrays. */ +__attribute__ ((noipa)) void +gcas3 (char a[static 3]) +{ + a[0] = 0; a[1] = 1; a[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v4qi_store_unalign } } } + a[3] = 3; // { dg-warning "\\\[-Warray-bounds" } +} + +__attribute__ ((noipa)) void +gias3 (int a[static 3]) +{ + a[0] = 0; a[1] = 1; a[2] = 2; + a[3] = 3; // { dg-warning "\\\[-Warray-bounds" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-4.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-4.c new file mode 100644 index 0000000000..b702d730a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-4.c @@ -0,0 +1,119 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + Verify warnings for multidimensional arrays, including mismatches + in bounds of arrays of VLAs. (Mismatches in variable bounds are + diagnosed by -Wvla-parameter.) + { dg-do compile } + { dg-options "-Wall -Warray-parameter=2" } */ + +// Verify that equivalent forms don't tigger a warning. + +typedef int IA1[1]; +typedef int IA1x_[][1]; +typedef int IA1x0[0][1]; + +void fia_x1 (int[][1]); +void fia_x1 (IA1[0]); +void fia_x1 (IA1x_); +void fia_x1 (IA1x0); +void fia_x1 (int[0][1]); +void fia_x1 (int[static 0][1]); + +// Same as above one more time. +void fia_x1 (int[][1]); +void fia_x1 (IA1[0]); +void fia_x1 (IA1x_); +void fia_x1 (IA1x0); +void fia_x1 (int[0][1]); +void fia_x1 (int[static 0][1]); + + +void fia1x1 (int[1][1]); +void fia1x1 (int[1][1]); +void fia1x1 (int[static 1][1]); + +void fia2x1 (int[2][1]); +void fia2x1 (int[2][1]); +void fia2x1 (int[static 2][1]); + +void fia1x2 (int[1][2]); +void fia1x2 (int[1][2]); +void fia1x2 (int[static 1][2]); + +void fia1x1_2x1 (int[1][1]); // { dg-message "previously declared as 'int\\\[1]\\\[1]'" } +void fia1x1_2x1 (int[2][1]); // { dg-warning "\\\[-Warray-parameter" } +void fia1x1_2x1 (int[static 1][1]); +void fia1x1_2x1 (int[static 2][1]); // { dg-warning "\\\[-Warray-parameter" } + + +void fia2x1_1x1 (int[2][1]); // { dg-message "previously declared as 'int\\\[2]\\\[1]'" } +void fia2x1_1x1 (int[1][1]); // { dg-warning "\\\[-Warray-parameter" } +void fia2x1_1x1 (int[2][1]); +void fia2x1_1x1 (int[static 1][1]); // { dg-warning "\\\[-Warray-parameter" } +void fia2x1_1x1 (int[static 2][1]); + + +extern int n1, n2; + +void fca_xn1 (char[][n1]); +void fca_xn1 (char[0][n1]); +void fca_xn1 (char[static 0][n1]); + +void fca1xn1_2xn1 (char[1][n1]); +void fca1xn1_2xn1 (char[2][n1]); // { dg-warning "\\\[-Warray-parameter" } +void fca1xn1_2xn1 (char[1][n1]); +void fca1xn1_2xn1 (char[static 1][n1]); +void fca1xn1_2xn1 (char[static 2][n1]); // { dg-warning "\\\[-Warray-parameter" } + + +/* Exercise VLAs with a mismatch in the bound for an ordinary array. */ +void fvlax_y (int n, int[][n]); +void fvlax_y (int n, int[0][n]); +void fvlax_y (int n, int[1][n]); // { dg-warning "argument 2 of type 'int\\\[1]\\\[n]' with mismatched bound" } +void fvlax_y (int n, int[2][n]); // { dg-warning "argument 2 of type 'int\\\[2]\\\[n]' with mismatched bound" } +void fvlax_y (int n, int[3][n]); // { dg-warning "argument 2 of type 'int\\\[3]\\\[n]' with mismatched bound" } + +void fvlaxn_y (int n, int[][n]); +void fvlaxn_y (int n, int[0][n]); +void fvlaxn_y (int n, int[1][n]); // { dg-warning "\\\[-Warray-parameter" } +void fvlaxn_y (int n, int[2][n]); // { dg-warning "\\\[-Warray-parameter" } +void fvlaxn_y (int n, int[3][n]); // { dg-warning "\\\[-Warray-parameter" } + +void fvlaxx_y (int[][*]); +void fvlaxx_y (int[0][*]); +void fvlaxx_y (int[1][*]); // { dg-warning "\\\[-Warray-parameter" } +void fvlaxx_y (int[2][*]); // { dg-warning "\\\[-Warray-parameter" } +void fvlaxx_y (int[3][*]); // { dg-warning "\\\[-Warray-parameter" } + + +// Verify an array of pointers to an array of function pointers. + +void ffpa7_5 (void (* (* (* [7])[5])(void))(void)); +// { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[7]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 } +void ffpa7_5 (void (* (* (* [6])[5])(void))(void)); +// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[6]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 } +void ffpa7_5 (void (* (* (* [])[5])(void))(void)); +// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[]\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 } +void ffpa7_5 (void (* (* (* (*))[5])(void))(void)); +// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\*\\\)\\\[5]\\\)\\\(void\\\)\\\)\\\(void\\\)' declared as a pointer" "" { target *-*-* } .-1 } + +// Same as above but with array of pointers to a VLA of function pointers. +void ffpa7_n1 (void (* (* (* [7])[n1])(void))(void)); +// { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[7]\\\)\\\[n1]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 } +void ffpa7_n1 (void (* (* (* [8])[n1])(void))(void)); +// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[8]\\\)\\\[n1]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 } + +void ffpa9_x (void (* (* (* [9])[*])(void))(void)); +// { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[9]\\\)\\\[\\\*]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "pr?????" { xfail *-*-* } .-1 } +// { dg-message "previously declared as 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[9]\\\)\\\[0]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "" { target *-*-* } .-2 } +void ffpa9_x (void (* (* (* [8])[*])(void))(void)); +// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[8]\\\)\\\[\\\*]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "pr?????" { xfail *-*-* } .-1 } +// { dg-warning "argument 1 of type 'void \\\(\\\* ?\\\(\\\* ?\\\(\\\*\\\[8]\\\)\\\[0]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-2 } + +/* Verify a three-dimensional array of pointers to two-dimensional arrays + of pointers to function pointers. */ + +void ffpa7_5_3 (void (* (* (* (* [7])[5])[3])(void))(void)); +// { dg-message "previously declared as 'void ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\[7]\\\)\\\[5]\\\)\\\[3]\\\)\\\(void\\\)\\\)\\\(void\\\)'" "note" { target *-*-* } .-1 } +void ffpa7_5_3 (void (* (* (* (* [1])[5])[3])(void))(void)); +// { dg-warning "argument 1 of type 'void ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\(\\\* ?\\\[1]\\\)\\\[5]\\\)\\\[3]\\\)\\\(void\\\)\\\)\\\(void\\\)' with mismatched bound" "" { target *-*-* } .-1 } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-5.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-5.c new file mode 100644 index 0000000000..6e89bf0c80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-5.c @@ -0,0 +1,14 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + Verify that -Warray-parameter diagnoses mismatches in bounds of + arrays between redeclarations of the same function and with pointer + parameters pointing to those arrays. + { dg-do compile } + { dg-options "-Wall -Warray-parameter" } */ + +void fa_x (int (*)[]); // { dg-message "previously declared as 'int \\\(\\\*\\\)\\\[]'" } +void fa_x (int (*)[2]); // { dg-warning "\\\[-Warray-parameter" } +void fa_x (int (*)[2]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[2]'" } + +void fa_2 (int (*)[2]); // { dg-message "previously declared as 'int \\\(\\\*\\\)\\\[2]'" } +void fa_2 (int (*)[]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[]'" } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-6.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-6.c new file mode 100644 index 0000000000..609dac96bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-6.c @@ -0,0 +1,9 @@ +/* PR c/97131 - ICE: Segmentation fault in warn_parm_ptrarray_mismatch + { dg-do compile } + { dg-options "-Wall" } */ + +struct bm { }; + +void ms (struct bm (*at)[1]) { } + +void ms (int f1) { } // { dg-error "conflicting types for 'ms'" } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-7.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-7.c new file mode 100644 index 0000000000..4863045be7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-7.c @@ -0,0 +1,25 @@ +/* PR c/97206 - ICE in composite_type on declarations of a similar array types + { dg-do compile } + { dg-options "-Wall" } */ + +__attribute__((__access__(__write_only__, 1))) void +f1 (char* restrict); + +void f1 (char*); + +char a1[]; +char a1[] = { }; + + +void f2 (char[restrict]); +void f2 (char*); + +char a2[]; +char a2[] = { }; + + +void f3 (char*); +void f3 (char[const]); + +extern const char a3[]; +extern const char a3[1]; diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-8.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-8.c new file mode 100644 index 0000000000..b152702b84 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-8.c @@ -0,0 +1,36 @@ +/* Verify that combinations of array type qualifiers render correctly. + { dg-do compile } + { dg-options "-Warray-parameter" } */ + +void fatm (int[_Atomic 1]); // { dg-message "previously declared as 'int\\\[_Atomic 1]" } +void fatm (int[_Atomic 2]); // { dg-warning "argument 1 of type 'int\\\[_Atomic 2]' with mismatched bound" } + + +void fcst (int[const 2]); // { dg-message "previously declared as 'int\\\[const 2]" } +void fcst (int[const 3]); // { dg-warning "argument 1 of type 'int\\\[const 3]' with mismatched bound" } + + +void frst (int[restrict 3]); // { dg-message "previously declared as 'int\\\[restrict 3]" } +void frst (int[restrict 4]); // { dg-warning "argument 1 of type 'int\\\[restrict 4]' with mismatched bound" } + +void fvol (int[volatile 4]); // { dg-message "previously declared as 'int\\\[volatile 4]" } +void fvol (int[volatile 5]); // { dg-warning "argument 1 of type 'int\\\[volatile 5]' with mismatched bound" } + + +void fcr (int[const restrict 1]); // { dg-message "previously declared as 'int\\\[\(const restrict|restrict const\) 1]" } +void fcr (int[restrict volatile 2]); // { dg-warning "argument 1 of type 'int\\\[\(restrict volatile|volatile restrict\) 2]' with mismatched bound" } +void fcr (int[const restrict volatile 3]); // { dg-warning "argument 1 of type 'int\\\[const volatile restrict 3]' with mismatched bound" } + + +extern int n; + +void fcx_n (int [const 1][n]); // { dg-message "previously declared as 'int\\\[const 1]\\\[n]'" "note" } +void fcx_n (int [restrict 2][n]); // { dg-warning "argument 1 of type 'int\\\[restrict 2]\\\[n]' with mismatched bound" } + + +extern int n1, n2; + +/* The mismatch in the array bound should be diagnosed but the mismatch + in the VLA should not be without -Wvla-parameter. */ +void fc3_n1 (int [const 3][n1]); // { dg-message "previously declared as 'int\\\[const 3]\\\[n1]'" "note" } +void fc3_n1 (int [const 5][n2]); // { dg-warning "argument 1 of type 'int\\\[const 5]\\\[n2]' with mismatched bound" } diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter-9.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter-9.c new file mode 100644 index 0000000000..b5d3d963c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter-9.c @@ -0,0 +1,54 @@ +/* PR c/99420 - bogus -Warray-parameter on a function redeclaration + in function scope + { dg-do compile } + { dg-options "-Wall" } */ + +extern int a1[1], a2[2], a3[3], a4[4]; + +void fa1 (int [1]); // { dg-message "previously declared as 'int\\\[1]'" } +void fa1 (int [1]); + + +void nested_decl (void) +{ + void fa2 (int [2]); + + fa2 (a1); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + fa2 (a2); + fa2 (a3); + + void fa3 (int [3]); + + fa3 (a2); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + fa3 (a3); +} + + +void nested_redecl (void) +{ + void fa1 (int [2]); // { dg-warning "argument 1 of type 'int\\\[2]' with mismatched bound" } + + fa1 (a1 + 1); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + fa1 (a1); + + void fa2 (int [2]); // { dg-bogus "\\\[-Warray-parameter" } + + fa2 (a1); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + fa2 (a2); + fa2 (a3); + + void fa3 (int [3]); // { dg-bogus "\\\[-Warray-parameter" } + + fa3 (a2); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + fa3 (a3); + + void fa4 (int [4]); +} + +void fa4 (int [5]); // { dg-warning "\\\[-Warray-parameter" } + +void call_fa4 (void) +{ + fa4 (a4); + fa4 (a3); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Warray-parameter.c b/SingleSource/Regression/C/gcc-dg/Warray-parameter.c new file mode 100644 index 0000000000..6c5195a31b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Warray-parameter.c @@ -0,0 +1,187 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + Verify that -Warray-parameter diagnoses mismatches in array (and + pointer) arrguments between redeclarations of the same function. + Also verify that the array/pointer argument form in a mismatched + redeclaration doesn't override the form in the initial declaration. + { dg-do compile } + { dg-options "-Wall -Warray-parameter -Wno-vla-parameter" } */ + +/* Redclarations with the same or equivalent array form should not + be dianosed. T[0] is diagnosed by -Wpedantic for being invalid + C so there's little point in also warning for the difference in + array form. */ +void f1vpp (void**); +void f1vpp (void*[]); +void f1vpp (void*[0]); + +void f1ia_ (int[]); +void f1ia_ (int[]); +void f1ia_ (int[0]); +/* Verify the unused attribute still has an effect. */ +void f1ia_ (int a[0] __attribute__ ((unused))) { } +void f1ia_ (int[]); + +void f1ia_p (int[]); +void f1ia_p (int*); +void f1ia_p (int *p __attribute__ ((unused))) { } +void f1ia_p (int[]); + +void f1p_ia (const int*); +void f1p_ia (const int[]); +void f1p_ia (const int *p __attribute__ ((unused))) { } +void f1p_ia (const int[]); + +void f1ia1 (int[1]); +void f1ia1 (int[1]); +void f1ia1 (int[2 - 1]); + +void f1ias2 (int[static 2]); +void f1ias2 (int[static 2]); +void f1ias2 (int[static 1 + 1]); +void f1ias2 (int a[static 3 - 1]) { (void)&a; } + +void f1ipa_ (int*[]); +void f1ipa_ (int*[]); +void f1ipa_ (int*[0]); + +void f1ia1_x (int[1]); // { dg-message "previously declared as 'int\\\[1]'" } +void f1ia1_x (int[]); // { dg-warning "argument 1 of type 'int\\\[]' with mismatched bound" } +void f1ia1_x (int[]); // { dg-warning "argument 1 of type 'int\\\[]' with mismatched bound" } +void f1ia1_x (int[1]); +void f1ia1_x (int[2]); // { dg-warning "argument 1 of type 'int\\\[2]' with mismatched bound" } +void f1ia1_x (int[1]); +void f1ia1_x (int[3]); // { dg-warning "argument 1 of type 'int\\\[3]' with mismatched bound" } +void f1ia1_x (int a[1] __attribute__ ((unused))) { } + + +void f1ias2_s3 (int[static 2]); // { dg-message "previously declared as 'int\\\[static 2]'" } +void f1ias2_s3 (int[static 3]); // { dg-warning "argument 1 of type 'int\\\[static 3]' with mismatched bound" } +/* Verify the unused attribute still has an effect and doesn't interfere + with the warning. */ +void f1ias2_s3 (int a[static 3] __attribute__ ((unused))) { } // { dg-warning "argument 1 of type 'int\\\[static 3]' with mismatched bound" } + + +/* Ordinary T[N] and T[static N] forms are both effectively treated + the same but strictly have different meanings so they are diagnosed. + It might be worth splitting the warning into two levels and having + only the higher level treat the ordinary form as T[static N]. */ + +void f1ia3_s4 (int[3]); // { dg-message "previously declared as 'int\\\[3]'" } +void f1ia3_s4 (int[static 4]); // { dg-warning "argument 1 of type 'int\\\[static 4]' with mismatched bound" } +void f1ia3_s4 (int[3]); + + +void f1ias4_5 (int[static 4]); // { dg-message "previously declared as 'int\\\[static 4]'" } +void f1ias4_5 (int[5]); // { dg-warning "argument 1 of type 'int\\\[5]' with mismatched bound" } +void f1ias4_5 (int[static 4]); + + +void f1ia_1 (int[]); // { dg-message "previously declared as 'int\\\[]'" } +void f1ia_1 (int[1]); // { dg-warning "argument 1 of type 'int\\\[1]' with mismatched bound" } +void f1ia_1 (int[]); + + +void f1ca_ (char[]); // { dg-message "previously declared as 'char\\\[]'" } +void f1ca_ (char[2]); // { dg-warning "argument 1 of type 'char\\\[2]' with mismatched bound" } +void f1ca_ (char[]); + + +void f1csp (const short*); // { dg-message "previously declared as 'const short int ?\\\*'" } +void f1csp (const short[3]); // { dg-warning "argument 1 of type 'const short int\\\[3]' with mismatched bound" } +void f1csp (const short*); + + +void f1ia2 (int[2]); // { dg-message "previously declared as 'int\\\[2]'" } +void f1ia2 (int[1]); // { dg-warning "argument 1 of type 'int\\\[1]' with mismatched bound" } +void f1ia2 (int[2]); + + +void f1cvla2 (const volatile long[3]); // { dg-message "previously declared as 'const volatile long int\\\[3]'" } +void f1cvla2 (const volatile long[2]); // { dg-warning "argument 1 of type 'const volatile long int\\\[2]' with mismatched bound" } +void f1cvla2 (const volatile long[3]); +void f1cvla2 (const volatile long[restrict 4]); // { dg-warning "argument 1 of type 'const volatile long int\\\[restrict 4]' with mismatched bound" } + + +void f1afa4 (_Atomic float[3]); // { dg-message "previously declared as an array '_Atomic float ?\\\[3]'" } +void f1afa4 (_Atomic float*); // { dg-warning "argument 1 of type '_Atomic float ?\\\*' declared as a pointer" } +void f1afa4 (_Atomic float[3]); + +void f1ipa1_a2 (int*[1]); // { dg-message "previously declared as 'int \\\*\\\[1]'" } +void f1ipa1_a2 (int*[2]); // { dg-warning "argument 1 of type 'int \\\*\\\[2]' with mismatched bound" } +void f1ipa1_a2 (int*[1]); + + +typedef int IAx[]; +typedef int IA1[1]; +typedef int IA2[2]; +typedef int IA3[3]; + +// The message should differentiate between the [] form and *. +void f1IAx_A1 (IAx); // { dg-message "previously declared as 'int\\\[]'" "pr?????" { xfail *-*-* } } + // { dg-message "previously declared as 'int *\\\*'" "note" { target *-*-* } .-1 } +void f1IAx_A1 (IA1); // { dg-message "argument 1 of type 'int\\\[1]' with mismatched bound" } + +void f1IA1_A2 (IA1); // { dg-message "previously declared as 'int\\\[1]'" } +void f1IA1_A2 (IA2); // { dg-warning "argument 1 of type 'int\\\[2]' with mismatched bound" } +void f1IA1_A2 (IA1); +void f1IA1_A2 (int[2]); // { dg-warning "argument 1 of type 'int\\\[2]' with mismatched bound" } + + +void f1IA1_A3 (IA1 ia1); // { dg-message "previously declared as 'int\\\[1]'" } +void f1IA1_A3 (IA3 ia3); // { dg-warning "argument 1 of type 'int\\\[3]' with mismatched bound" } +void f1IA1_A3 (IA1 ia1); + + +void f1IA2_A3 (IA2 a); // { dg-message "previously declared as 'int\\\[2]'" } +void f1IA2_A3 (IA3 a); // { dg-warning "argument 1 of type 'int\\\[3]' with mismatched bound" } +void f1IA2_A3 (IA2 a); + + +// Verify multiple array arguments. + +void f2a2_a3_3_3 (int[2], int[3]); // { dg-message "previously declared as 'int\\\[2]'" } +void f2a2_a3_3_3 (int[2], int[3]); +void f2a2_a3_3_3 (int[3], int[3]); // { dg-warning "argument 1 of type 'int\\\[3]' with mismatched bound" } + + +void f2a2_a3_2_4 (int[2], int[3]); // { dg-message "previously declared as 'int\\\[3]'" } +void f2a2_a3_2_4 (int[2], int[4]); // { dg-warning "argument 2 of type 'int\\\[4]' with mismatched bound" } + + +/* Verify that pointers to arrays and arrays of arrays are differentiated + the same way as pointers and arrays of other types. */ +typedef IA1 *PA1; + +void fpia1 (IA1*); // { dg-message "previously declared as 'int ?\\(\\\*\\)\\\[1]'" } +void fpia1 (IA1[1]); // { dg-warning "argument 1 of type 'int\\\[1]\\\[1]' with mismatched bound" } +void fpia1 (PA1); +void fpia1 (int(*)[1]); +void fpia1 (int[][1]); + +void f1vpa1 (void*[][1]); +void f1vpa1 (void*[0][1]); + +/* Verify arrays of pointers. */ +void vaip1 (int (*[3])); // { dg-message "previously declared as 'int *\\\*\\\[3]'" } +void vaip1 (int (*[5])); // { dg-warning "argument 1 of type 'int *\\\*\\\[5]' with mismatched bound" } +void vaip1 (int (*[3])); +void vaip1 (int (*[])); // { dg-warning "argument 1 of type 'int *\\\*\\\[]' with mismatched bound" } +void vaip1 (int (*[3])); + +/* Verify that attributes with arrays don't cause unwanted warnings and + don't suppress intended ones. */ + +#define ALIGN(N)__attribute__ ((aligned (__alignof__ (char[N])))) + +void fatipa2 (int (* ALIGN (3)[2])); // { dg-message "previously declared as 'int \\\*\\\[2]'" } +void fatipa2 (int (* ALIGN (4)[2])); +void fatipa2 (int (* ALIGN (5)[2])); +void fatipa2 (int (* ALIGN (7)[3])); // { dg-warning "argument 1 of type 'int \\\*\\\[3]' with mismatched bound" } + +void fatiap (int (* ALIGN (3))[2]); +void fatiap (int (* ALIGN (5))[2]); + + +void fatipa3 (int (* ALIGN (1) (* ALIGN (2))[3])); +void fatipa3 (int (* ALIGN (1) (* ALIGN (2))[3])); diff --git a/SingleSource/Regression/C/gcc-dg/Wattribute-alias.c b/SingleSource/Regression/C/gcc-dg/Wattribute-alias.c new file mode 100644 index 0000000000..12774e8283 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattribute-alias.c @@ -0,0 +1,57 @@ +/* PR middle-end/81824 - Warn for missing attributes with function aliases + { dg-do compile } + { dg-require-ifunc "" } + { dg-options "-Wall -Wattribute-alias=2" } */ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) + + +void +target_no_nothrow (void) /* { dg-message ".alias_nothrow. target declared here" } */ +{ } + +ATTR (alias ("target_no_nothrow"), nothrow) void +alias_nothrow (void); /* { dg-warning ".alias_nothrow. specifies more restrictive attribute than its target .target_no_nothrow.: .nothrow." } */ + + +#pragma GCC diagnostic push "-Wattribute-alias" +#pragma GCC diagnostic ignored "-Wattribute-alias" +ATTR (alias ("target_no_nothrow"), nothrow) void +alias_nothrow_ignored (void); +#pragma GCC diagnostic pop "-Wattribute-alias" + + +ATTR (pure) int +alias_pure (void); + +int +target_no_pure (void) /* { dg-message ".alias_pure. target declared here" } */ +{ return 0; } + +ATTR (alias ("target_no_pure")) int +alias_pure (void); /* { dg-warning ".alias_pure. specifies more restrictive attribute than its target .target_no_pure.: .pure." } */ + + +ATTR (const) int +alias_const (void); + +int +target_pure (void) /* { dg-message ".alias_const. target declared here" } */ +{ return 0; } + +ATTR (alias ("target_pure")) int +alias_const (void); /* { dg-warning ".alias_const. specifies more restrictive attribute than its target .target_pure.: .const." } */ + + +/* There is no obvious relationship between the attributes on an ifunc + resolver and those on its aliases. Verify that mismatches between + aliases and ifunc resolvers do not trigger warnings. */ + +typedef int F (void); + +ATTR (pure, leaf) F* resolve_to_const (void) +{ return alias_const; } + +ATTR (ifunc ("resolve_to_const")) F alias_no_const_ifunc; +ATTR (const, ifunc ("resolve_to_const")) F alias_const_ifunc; +ATTR (ifunc ("resolve_to_const")) int alias_no_leaf_ifunc (void); diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-1.c b/SingleSource/Regression/C/gcc-dg/Wattributes-1.c new file mode 100644 index 0000000000..29e07e4127 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-1.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options -Wattributes } */ + +void __attribute__((dj)) foo() { } /* { dg-warning "attribute directive ignored" } */ + +int j __attribute__((unrecognized)); /* { dg-warning "attribute directive ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-10.c b/SingleSource/Regression/C/gcc-dg/Wattributes-10.c new file mode 100644 index 0000000000..c40fe65d43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-10.c @@ -0,0 +1,28 @@ +/* PR middle-end/86453 - error: type variant differs by TYPE_PACKED in + free_lang_data since r255469 + { dg-do compile } + { dg-options "-Wall -ftrack-macro-expansion=0" } + { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +#define A(expr) do { int a[1 - 2 * !(expr)]; (void)&a; } while (0) + +struct S +{ + int* __attribute__ ((aligned (16))) paligned; + int* __attribute__ ((packed)) ppacked; /* { dg-warning ".packed. attribute ignored for type .int \\\*." } */ + + int* __attribute__ ((aligned (16), packed)) qaligned; /* { dg-warning "ignoring attribute .packed. because it conflicts with attribute .aligned." } */ + int* __attribute__ ((packed, aligned (16))) qpacked; /* { dg-warning ".packed. attribute ignored for type .int \\\*." } */ +} s; /* { dg-error "alignment of 's' is greater" "" { target pdp11*-*-* } } */ + + +void test (void) +{ + /* Verify that attributes reported ignored really are ignored + and not applied. */ + + A (__alignof__ (s.paligned) == 16); + A (__alignof__ (s.ppacked) < 16); + A (__alignof__ (s.qaligned) == 16); + A (__alignof__ (s.qpacked) == __alignof__ (s.paligned)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-2.c b/SingleSource/Regression/C/gcc-dg/Wattributes-2.c new file mode 100644 index 0000000000..6918704202 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-2.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options -Wno-attributes } */ + +void __attribute__((dj)) foo() { } /* { dg-bogus "attribute directive ignored" } */ + +int j __attribute__((unrecognized)); /* { dg-bogus "attribute directive ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-3.c b/SingleSource/Regression/C/gcc-dg/Wattributes-3.c new file mode 100644 index 0000000000..59d14c7b92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-3.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ + +void __attribute__((dj)) foo() { } /* { dg-warning "attribute directive ignored" } */ + +int j __attribute__((unrecognized)); /* { dg-warning "attribute directive ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-4.c b/SingleSource/Regression/C/gcc-dg/Wattributes-4.c new file mode 100644 index 0000000000..abda5a30b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-4.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ + +int __attribute__((optimize("no-lto"))) main(void){return 0;} /* { dg-warning "bad option" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-5.c b/SingleSource/Regression/C/gcc-dg/Wattributes-5.c new file mode 100644 index 0000000000..34483391e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-5.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options -Wattributes } */ + +void __attribute__((_foobar)) foo() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((_xformat__)) foo2() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((xformat__)) foo3() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((__xformat)) foo4() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((_)) foo5() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((_)) foo6() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((__)) foo7() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((___)) foo8() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((____)) foo9() { } /* { dg-warning "attribute directive ignored" } */ +void __attribute__((_____)) foo10() { } /* { dg-warning "attribute directive ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-6.c b/SingleSource/Regression/C/gcc-dg/Wattributes-6.c new file mode 100644 index 0000000000..978f3f938e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-6.c @@ -0,0 +1,466 @@ +/* { dg-do compile } + { dg-options "-Wall -Wattributes -ftrack-macro-expansion=0" } */ + +#define ATTR(attrlist) __attribute__ (attrlist) + +/* Exercise the handling of the mutually exclusive attributes + aligned and packed on a type definition. */ + +/* Pointless but benign. */ +struct ATTR ((aligned, aligned)) +AlignedAligned { int i; }; + +/* Aligned followed by packed on a type and vice versa has a valid use: + to decrease the alignment of a type to the specified boundary. */ +struct ATTR ((aligned, packed)) +AlignedPacked { int i; }; + +struct ATTR ((packed, aligned)) +PackedAligned { int i; }; + +struct ATTR ((aligned (2))) +AlignedMemberPacked +{ + int ATTR ((packed)) i; // { dg-warning "attribute ignored" "" { target default_packed } } +}; + +struct ATTR ((packed)) +PackedMemberAligned +{ + int ATTR ((aligned (2))) i; +}; + +/* Silly but benign. */ +struct ATTR ((packed, packed)) +PackedPacked { int i; }; + + +/* Exercise the handling of the mutually exclusive attributes + aligned and packed on a function declaration. */ + +void ATTR ((aligned (8), packed)) +faligned8_1 (void); /* { dg-warning "ignoring attribute .packed. because it conflicts with attribute .aligned." } */ + +void ATTR ((aligned (8))) +faligned8_2 (void); /* { dg-message "previous declaration here" } */ + +void ATTR ((packed)) +faligned8_2 (void); /* { dg-warning "ignoring attribute .packed. because it conflicts with attribute .aligned." } */ + +/* Exercise the handling of the mutually exclusive attributes + always_inline and noinline (in that order). */ + +inline void ATTR ((always_inline)) +falways_inline1 (void); + +inline void ATTR ((__always_inline__)) +falways_inline1 (void); + +/* Verify that repeating attribute always_inline on the same declaration + doesn't trigger a warning. */ +inline void ATTR ((always_inline, __always_inline__)) +falways_inline1 (void); + +/* Verify that repeating attribute always_inline on a distinct declaration + doesn't trigger a warning. */ +inline void ATTR ((always_inline)) +falways_inline1 (void); /* { dg-message "previous declaration here" } */ + +/* Verify a warning for noinline conflict. */ +void ATTR ((noinline)) +falways_inline1 (void) { } /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */ + +/* And again. */ +void ATTR ((always_inline)) +falways_inline1 (void); + + +/* Exercise the handling of the mutually exclusive attributes + noinline and always_inline (in that order). */ + +void ATTR ((noinline)) +fnoinline1 (void); + +void ATTR ((__noinline__)) +fnoinline1 (void); + +/* Verify that repeating attribute noinline on the same declaration + doesn't trigger a warning. */ +void ATTR ((noinline, __noinline__)) +fnoinline1 (void); + +/* Verify that repeating attribute noinline on a distinct declaration + doesn't trigger a warning. */ +void ATTR ((noinline)) +fnoinline1 (void); /* { dg-message "previous declaration here" } */ + +/* Verify a warning for always_inline conflict. */ +void ATTR ((always_inline)) +fnoinline1 (void) { } /* { dg-warning "ignoring attribute .always_inline. because it conflicts with attribute .noinline." } */ + /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */ + /* { dg-note "previous definition" "" { target *-*-* } .-2 } */ + +/* Verify a warning for gnu_inline conflict. */ +inline void ATTR ((gnu_inline)) +fnoinline1 (void); /* { dg-warning "ignoring attribute .gnu_inline. because it conflicts with attribute .noinline." } */ + /* { dg-warning "follows declaration with attribute .noinline." "inline noinline" { target *-*-* } .-1 } */ + +/* And again. */ +void ATTR ((noinline)) +fnoinline1 (void); /* { dg-warning "follows inline declaration" } */ + + +/* Exercise the handling of the mutually exclusive attributes + noreturn and warn_unused_result. */ + +int ATTR ((__noreturn__)) +fnoret1 (void); + +int ATTR ((noreturn)) +fnoret1 (void); /* { dg-message "previous declaration here" } */ + +int ATTR ((warn_unused_result)) +fnoret1 (void); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */ + +/* Verify that repeating attribute noreturn doesn't trigger a warning. */ +int ATTR ((noreturn)) fnoret1 (void); + +int call_noret1 (void) +{ + /* Verify that attribute warn_unused_result was, in fact, ignored + on the second declaration of fnoret1. */ + fnoret1 (); +} + +int ATTR ((noreturn, warn_unused_result)) +fnoret2 (void); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */ + +/* Verify that repeating attribute noreturn doesn't trigger a warning. */ +int ATTR ((noreturn)) fnoret2 (void); + +int call_noret2 (void) +{ + /* Verify that attribute warn_unused_result was, in fact, ignored + on the second declaration of fnoret2. */ + fnoret2 (); +} + +/* Verify that attribute noreturn isn't diagnosed on a declaration + that was previously declared warn_unused_result and that attribute + was dropped (because the function returs void). */ + +void ATTR ((warn_unused_result)) +fnorety6 (void); /* { dg-warning ".warn_unused_result. attribute ignored" } */ + +void ATTR ((noreturn)) +fnoret6 (void); + + +/* Exercise the handling of the mutually exclusive attributes + noreturn and alloc_align. */ + +void* ATTR ((noreturn)) +fnoret_alloc_align1 (int); /* { dg-message "previous declaration here" } */ + +void* ATTR ((alloc_align (1))) +fnoret_alloc_align1 (int); /* { dg-warning "ignoring attribute .alloc_align. because it conflicts with attribute .noreturn." } */ + +void* ATTR ((noreturn, alloc_align (1))) +fnoret_alloc_align2 (int); /* { dg-warning "ignoring attribute .alloc_align. because it conflicts with attribute .noreturn." } */ + + +void* ATTR ((noreturn)) ATTR ((alloc_align (1))) +fnoret_alloc_align3 (int); /* { dg-warning "ignoring attribute .alloc_align. because it conflicts with attribute .noreturn." } */ + + +void* ATTR ((alloc_align (1))) +falloc_align_noret1 (int); /* { dg-message "previous declaration here" } */ + +void* ATTR ((noreturn)) +falloc_align_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .alloc_align." } */ + + +void* ATTR ((alloc_align (1), noreturn)) +falloc_align_noret2 (int); /* { dg-warning "ignoring attribute .(noreturn|alloc_align). because it conflicts with attribute .(alloc_align|noreturn)." } */ + +void* ATTR ((alloc_align (1))) ATTR ((noreturn)) +falloc_align_noret3 (int); /* { dg-warning "ignoring attribute .(noreturn|alloc_align). because it conflicts with attribute .(noreturn|alloc_align)." } */ + + +/* Exercise the handling of the mutually exclusive attributes + noreturn and alloc_size. */ + +void* ATTR ((noreturn)) +fnoret_alloc_size1 (int); /* { dg-message "previous declaration here" } */ + +void* ATTR ((alloc_size (1))) +fnoret_alloc_size1 (int); /* { dg-warning "ignoring attribute .alloc_size. because it conflicts with attribute .noreturn." } */ + +void* ATTR ((noreturn, alloc_size (1))) +fnoret_alloc_size2 (int); /* { dg-warning "ignoring attribute .alloc_size. because it conflicts with attribute .noreturn." } */ + + +void* ATTR ((noreturn)) ATTR ((alloc_size (1))) +fnoret_alloc_size3 (int); /* { dg-warning "ignoring attribute .alloc_size. because it conflicts with attribute .noreturn." } */ + + +void* ATTR ((alloc_size (1))) +falloc_size_noret1 (int); /* { dg-message "previous declaration here" } */ + +void* ATTR ((noreturn)) +falloc_size_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .alloc_size." } */ + + +void* ATTR ((alloc_size (1), noreturn)) +falloc_size_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .alloc_size." } */ + +void* ATTR ((alloc_size (1))) ATTR ((noreturn)) +falloc_size_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .alloc_size." } */ + + +/* Exercise the handling of the mutually exclusive attributes + noreturn and const. */ + +int ATTR ((noreturn)) +fnoret_const1 (int); /* { dg-message "previous declaration here" } */ + +int ATTR ((const)) +fnoret_const1 (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */ + +/* Unfortunately, attributes on a single declarations may not be processed + in the same order as specified... */ +int ATTR ((noreturn, const)) +fnoret_const2 (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */ + + +int ATTR ((noreturn)) ATTR ((const)) +fnoret_const3 (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */ + + +int ATTR ((const)) +fconst_noret1 (int); /* { dg-message "previous declaration here" } */ + +int ATTR ((noreturn)) +fconst_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .const." } */ + + +int ATTR ((const, noreturn)) +fconst_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .const." } */ + +int ATTR ((const)) ATTR ((noreturn)) +fconst_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .const." } */ + + +/* Exercise the handling of the mutually exclusive attributes + noreturn and malloc. */ + +void* ATTR ((noreturn)) +fnoret_malloc1 (int); /* { dg-message "previous declaration here" } */ + +void* ATTR ((malloc)) +fnoret_malloc1 (int); /* { dg-warning "ignoring attribute .malloc. because it conflicts with attribute .noreturn." } */ + +/* Unfortunately, attributes on a single declarations may not be processed + in the same order as specified... */ +void* ATTR ((noreturn, malloc)) +fnoret_malloc2 (int); /* { dg-warning "ignoring attribute .malloc. because it conflicts with attribute .noreturn." } */ + + +void* ATTR ((noreturn)) ATTR ((malloc)) +fnoret_malloc3 (int); /* { dg-warning "ignoring attribute .malloc. because it conflicts with attribute .noreturn." } */ + + +void* ATTR ((__malloc__)) +fmalloc_noret1 (int); + +void* ATTR ((malloc)) +fmalloc_noret1 (int); /* { dg-message "previous declaration here" } */ + +void* ATTR ((noreturn)) +fmalloc_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .malloc." } */ + + +void* ATTR ((malloc, noreturn)) +fmalloc_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .malloc." } */ + +void* ATTR ((malloc)) ATTR ((noreturn)) +fmalloc_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .malloc." } */ + + +/* Exercise the handling of the mutually exclusive attributes + noreturn and pure. */ + +int ATTR ((noreturn)) +fnoret_pure1 (int); /* { dg-message "previous declaration here" } */ + +int ATTR ((pure)) +fnoret_pure1 (int); /* { dg-warning "ignoring attribute .pure. because it conflicts with attribute .noreturn." } */ + +/* Unfortunately, attributes on a single declarations may not be processed + in the same order as specified... */ +int ATTR ((noreturn, pure)) +fnoret_pure2 (int); /* { dg-warning "ignoring attribute .pure. because it conflicts with attribute .noreturn." } */ + + +int ATTR ((noreturn)) ATTR ((pure)) +fnoret_pure3 (int); /* { dg-warning "ignoring attribute .pure. because it conflicts with attribute .noreturn." } */ + + +int ATTR ((__pure__)) +fpure_noret1 (int); + +int ATTR ((pure)) +fpure_noret1 (int); /* { dg-message "previous declaration here" } */ + +int ATTR ((noreturn)) +fpure_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .pure." } */ + + +int ATTR ((pure, noreturn)) +fpure_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .pur." } */ + +int ATTR ((pure)) ATTR ((noreturn)) +fpure_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .pure." } */ + + +/* Exercise the handling of the mutually exclusive attributes + noreturn and returns_twice. */ + +int ATTR ((noreturn)) +fnoret_returns_twice1 (int); /* { dg-message "previous declaration here" } */ + +int ATTR ((returns_twice)) +fnoret_returns_twice1 (int); /* { dg-warning "ignoring attribute .returns_twice. because it conflicts with attribute .noreturn." } */ + +/* Unfortunately, attributes on a single declarations may not be processed + in the same order as specified... */ +int ATTR ((noreturn, returns_twice)) +fnoret_returns_twice2 (int); /* { dg-warning "ignoring attribute .returns_twice. because it conflicts with attribute .noreturn." } */ + + +int ATTR ((noreturn)) ATTR ((returns_twice)) +fnoret_returns_twice3 (int); /* { dg-warning "ignoring attribute .returns_twice. because it conflicts with attribute .noreturn." } */ + + +int ATTR ((returns_twice)) +freturns_twice_noret1 (int); /* { dg-message "previous declaration here" } */ + +int ATTR ((noreturn)) +freturns_twice_noret1 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .returns_twice." } */ + + +int ATTR ((returns_twice, noreturn)) +freturns_twice_noret2 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .returns_twice." } */ + +int ATTR ((returns_twice)) ATTR ((noreturn)) +freturns_twice_noret3 (int); /* { dg-warning "ignoring attribute .noreturn. because it conflicts with attribute .returns_twice." } */ + + +/* Exercise the interaction of multiple combinations of mutually + exclusive attributes specified on distinct declarations. */ + +inline int ATTR ((always_inline)) +finline_cold_noreturn (int); + +inline int ATTR ((cold)) +finline_cold_noreturn (int); + +inline int ATTR ((noreturn)) +finline_cold_noreturn (int); /* { dg-note "previous declaration here" } */ + +inline int ATTR ((noinline)) +finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */ + /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */ + +inline int ATTR ((hot)) +finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .hot. because it conflicts with attribute .cold." } */ + /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */ + +inline int ATTR ((warn_unused_result)) +finline_cold_noreturn (int); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */ + +inline int ATTR ((always_inline)) +finline_cold_noreturn (int); + +/* Expect no warning for the missing return statement below because + the function is noreturn. */ +inline int ATTR ((noreturn)) +finline_cold_noreturn (int i) { (void)&i; __builtin_abort (); } + + +/* Exercise the interaction of multiple combinations of mutually + exclusive attributes with some specified on the same declaration + and some on distinct declarations. */ + +inline int ATTR ((always_inline, hot)) +finline_hot_noret_align (int); /* { dg-note "previous declaration here" } */ + +inline int ATTR ((noreturn, noinline)) +finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */ + /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */ + +inline int ATTR ((cold, aligned (8))) +finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .cold. because it conflicts with attribute .hot." } */ + /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */ + +inline int ATTR ((warn_unused_result)) +finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .warn_unused_result. because it conflicts with attribute .noreturn." } */ + /* { dg-note "previous declaration here" "" { target *-*-* } .-1 } */ + +inline int ATTR ((aligned (4))) + finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(8\\)." "" { target { ! { hppa*64*-*-* } } } } */ + +inline int ATTR ((aligned (8))) +finline_hot_noret_align (int); /* { dg-note "previous declaration here" } */ + +inline int ATTR ((const)) +finline_hot_noret_align (int); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .noreturn." } */ + +/* Expect no warning for the missing return statement below because + the function is noreturn. */ +inline int ATTR ((noreturn)) +finline_hot_noret_align (int i) { (void)&i; __builtin_abort (); } + + +/* Expect a warning about conflicting alignment but without + other declarations inbetween. */ +inline int ATTR ((aligned (32))) +finline_align (int); /* { dg-note "previous declaration here" } */ + +inline int ATTR ((aligned (4))) +finline_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(32\\)." "" } */ + +inline int ATTR ((noreturn)) +finline_align (int i) { (void)&i; __builtin_abort (); } + + +/* Expect no note that would refer to the same declaration. */ +inline int ATTR ((aligned (32), aligned (4))) +finline_double_align (int); /* { dg-warning "ignoring attribute .aligned \\(4\\). because it conflicts with attribute .aligned \\(32\\)." } */ + +inline int ATTR ((noreturn)) +finline_double_align (int i) { (void)&i; __builtin_abort (); } + + +/* Exercise variable attributes. */ + +extern int ATTR ((common)) +decl_common1; /* { dg-message "previous declaration here" } */ + +extern int ATTR ((nocommon)) +decl_common1; /* { dg-warning "ignoring attribute .nocommon. because it conflicts with attribute .common." } */ + + +extern int ATTR ((nocommon)) +decl_common2; /* { dg-message "previous declaration here" } */ + +extern int ATTR ((common)) +decl_common2; /* { dg-warning "ignoring attribute .common. because it conflicts with attribute .nocommon." } */ + + +extern int ATTR ((common, nocommon)) +decl_common3; /* { dg-warning "ignoring attribute .nocommon. because it conflicts with attribute .common." } */ + + +extern int ATTR ((common, nocommon)) +decl_common4; /* { dg-warning "ignoring attribute .nocommon. because it conflicts with attribute .common." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-7.c b/SingleSource/Regression/C/gcc-dg/Wattributes-7.c new file mode 100644 index 0000000000..0904742b01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-7.c @@ -0,0 +1,74 @@ +/* PR c/81566 - invalid attribute aligned accepted on functions + { dg-do compile } + { dg-options "-Wall -Wattributes -ftrack-macro-expansion=0" } */ + +#define ATTR(list) __attribute__ (list) +#define ALIGN(n) ATTR ((aligned (n))) + +/* It's okay to increase the alignment of a function. */ + +void ALIGN (16) ALIGN (32) +falign32_1 (void); + +void ALIGN (16) falign32_2 (void); +void ALIGN (32) falign32_2 (void); + +void falign32_2 (void) { } + +void ALIGN (32) falign32_2 (void); + +/* It's not okay to decrease it. */ + +void ALIGN (32) ALIGN (16) +falign64_3 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */ + +void ALIGN (32) +falign64_3 (void); + +void falign64_3 (void); + +void falign64_3 (void) { } + + +void ALIGN (32) +falign64_4 (void); /* { dg-message "previous declaration here" } */ + +void ALIGN (16) +falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */ + +void ALIGN (32) +falign64_4 (void); /* { dg-message "previous declaration here" } */ + +void ALIGN (16) +falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */ + +void ALIGN (64) +falign64_4 (void); + +void ALIGN (32) +falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(32\\). because it conflicts with attribute .aligned \\(64\\)." } */ + +void falign64_4 (void); + +void ALIGN (64) +falign64_4 (void) { } + +void falign64_4 (void); + +void ALIGN (64) +falign64_4 (void); + + +void ATTR ((aligned (16), aligned (32))) +falign64_5 (void); + +void ATTR ((aligned (32), aligned (64))) +falign64_5 (void); + +void ATTR ((aligned (16), aligned (32), aligned (64))) +falign64_5 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(64\\)." } */ + /* { dg-warning "ignoring attribute .aligned \\(32\\). because it conflicts with attribute .aligned \\(64\\)." "" { target *-*-* } .-1 } */ + + +void ATTR ((aligned (16), aligned (32), aligned (16))) +falign64_6 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wattributes-8.c b/SingleSource/Regression/C/gcc-dg/Wattributes-8.c new file mode 100644 index 0000000000..8f5483e2d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wattributes-8.c @@ -0,0 +1,40 @@ +/* PR middle-end/84108 - incorrect -Wattributes warning for packed/aligned + conflict on struct members + { dg-do compile } + { dg-options "-Wall -Wattributes" } */ + +#define ATTR(list) __attribute__ (list) +#define ASSERT(e) _Static_assert (e, #e) + +/* GCC is inconsistent in how it treats attribute aligned between + variable and member declarations. Attribute aligned alone is + sufficient to reduce a variable's alignment requirement but + the attribute must be paired with packed to have the same + effect on a member. Worse, declaring a variable both aligned + and packed emits a warning. */ + +/* Avoid exercising this since emitting a warning for these given + the requirement for members seems like a misfeature: + int a ATTR ((packed, aligned (2))); // -Wattributes + int b ATTR ((aligned (2), packed)); // -Wattributes + ASSERT (_Alignof (a) == 2); + ASSERT (_Alignof (b) == 2); */ + +int c ATTR ((aligned (2))); // okay (reduces alignment) +ASSERT (_Alignof (c) == 2); + +struct { + int a ATTR ((packed, aligned (2))); /* { dg-bogus "\\\[-Wattributes" "" { target { ! default_packed } } } */ + /* { dg-warning "attribute ignored" "" { target { default_packed } } .-1 } */ + int b ATTR ((aligned (2), packed)); /* { dg-bogus "\\\[-Wattributes" "" { target { ! default_packed } } } */ + /* { dg-warning "attribute ignored" "" { target { default_packed } } .-1 } */ + + /* Avoid exercising this since the attribute has no effect yet + there is no warning. + int c ATTR ((aligned (2))); // missing warning? */ +} s; + +ASSERT (_Alignof (s.a) == 2); +ASSERT (_Alignof (s.b) == 2); + +/* ASSERT (_Alignof (s.c) == 4); */ diff --git a/SingleSource/Regression/C/gcc-dg/Wbad-function-cast-1.c b/SingleSource/Regression/C/gcc-dg/Wbad-function-cast-1.c new file mode 100644 index 0000000000..4a0547f0b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbad-function-cast-1.c @@ -0,0 +1,51 @@ +/* Test operation of -Wbad-function-cast. Bug 6980 complained of the + wording of the diagnostic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wbad-function-cast" } */ + +void vf(void); +int if1(void); +char if2(void); +long if3(void); +float rf1(void); +double rf2(void); +_Complex double cf(void); +enum e { E1 } ef(void); +_Bool bf(void); +char *pf1(void); +int *pf2(void); + +void +foo(void) +{ + /* Casts to void types are always OK. */ + (void)vf(); + (void)if1(); + (void)cf(); + (const void)bf(); + /* Casts to the same type or similar types are OK. */ + (int)if1(); + (long)if2(); + (char)if3(); + (float)rf1(); + (long double)rf2(); + (_Complex float)cf(); + (enum f { F1 })ef(); + (_Bool)bf(); + (void *)pf1(); + (char *)pf2(); + /* Casts to types with different TREE_CODE (which is how this + warning has been defined) are not OK, except for casts to void + types. */ + (float)if1(); /* { dg-warning "cast from function call of type 'int' to non-matching type 'float'" } */ + (double)if2(); /* { dg-warning "cast from function call of type 'char' to non-matching type 'double'" } */ + (_Bool)if3(); /* { dg-warning "cast from function call of type 'long int' to non-matching type '_Bool'" } */ + (int)rf1(); /* { dg-warning "cast from function call of type 'float' to non-matching type 'int'" } */ + (long)rf2(); /* { dg-warning "cast from function call of type 'double' to non-matching type 'long int'" } */ + (double)cf(); /* { dg-warning "cast from function call of type 'complex double' to non-matching type 'double'" } */ + (int)ef(); /* { dg-warning "cast from function call of type 'enum e' to non-matching type 'int'" } */ + (int)bf(); /* { dg-warning "cast from function call of type '_Bool' to non-matching type 'int'" } */ + (__SIZE_TYPE__)pf1(); /* { dg-warning "cast from function call of type 'char \\*' to non-matching type '\[^\\n\]*'" } */ + (__PTRDIFF_TYPE__)pf2(); /* { dg-warning "cast from function call of type 'int \\*' to non-matching type '\[^\\n\]*'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbool-operation-1.c b/SingleSource/Regression/C/gcc-dg/Wbool-operation-1.c new file mode 100644 index 0000000000..b24e763983 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbool-operation-1.c @@ -0,0 +1,16 @@ +/* PR c/77490 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int +fn (_Bool b) +{ + int r = 0; + + r += b++; /* { dg-warning "increment of a boolean expression" } */ + r += ++b; /* { dg-warning "increment of a boolean expression" } */ + r += b--; /* { dg-warning "decrement of a boolean expression" } */ + r += --b; /* { dg-warning "decrement of a boolean expression" } */ + + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-10.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-10.c new file mode 100644 index 0000000000..58de1d48b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-10.c @@ -0,0 +1,10 @@ +/* PR c/86308 - ICE in verify_gimple calling an invalid index() declaration + { dg-do compile } + { dg-options "-Wall" } */ + +int index (int, int); /* { dg-warning "conflicting types for built-in function .index.; expected .char \\\*\\\(const char \\\*, int\\\)." } */ + +int foo (const short *a) +{ + return a[index (0, 0)]; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-11.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-11.c new file mode 100644 index 0000000000..0c62c61faf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-11.c @@ -0,0 +1,21 @@ +/* PR c/86125 */ +/* { dg-do compile } */ +/* { dg-options "-Wbuiltin-declaration-mismatch -Wextra -Wno-ignored-qualifiers" } */ + +typedef __SIZE_TYPE__ size_t; +struct FILE; +struct tm; +struct fenv_t; +struct fexcept_t; +typedef struct FILE FILE; +typedef struct fenv_t fenv_t; +typedef struct fexcept_t fexcept_t; +typedef const int cint; +size_t strftime (char *__restrict, const size_t, const char *__restrict, /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ + const struct tm *__restrict) __attribute__((nothrow)); +int fprintf (struct FILE *, const char *const, ...); /* { dg-bogus "mismatch in argument 2 type of built-in function" } */ +cint putc (int, struct FILE *); /* { dg-bogus "mismatch in return type of built-in function" } */ +cint fegetenv (fenv_t *); /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ +cint fesetenv (const fenv_t *); /* { dg-bogus "mismatch in return type of built-in function" } */ +int fegetexceptflag (fexcept_t *, const int); /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ +int fesetexceptflag (const fexcept_t *, const int); /* { dg-bogus "mismatch in argument 1 type of built-in function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-12.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-12.c new file mode 100644 index 0000000000..f12ef6afb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-12.c @@ -0,0 +1,8 @@ +/* Verify that declaring the __clear_cache and __builtin_prefetch + intrinsic functions with the wrong signature is diagnosed. + { dg-do compile } + { dg-options "-Wbuiltin-declaration-mismatch -Wextra" } */ + +extern void __clear_cache (char*, char*); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + +void __builtin_prefetch (const char *, ...); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-13.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-13.c new file mode 100644 index 0000000000..f21f407e18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-13.c @@ -0,0 +1,78 @@ +/* PR middle-end/93926 - ICE on a built-in redeclaration returning an integer + instead of a pointer + { dg-do compile } + { dg-options "-Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +void* ret_calloc (size_t n1, size_t n2) +{ + extern size_t calloc (size_t, size_t); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return (void *) calloc (n1, n2); +} + +void* ret_malloc (size_t n) +{ + extern size_t malloc (size_t); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return (void *) malloc (n); +} + +void* ret_realloc (void *p, size_t n) +{ + extern size_t realloc (void *p, size_t); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return (void *) realloc (p, n); +} + +void* ret_strdup (const char *s) +{ + extern size_t strdup (const char*); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return (void *) strdup (s); +} + +void* ret_strndup (const char *s, size_t n) +{ + extern size_t + strndup (const char*, size_t); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return (void *) strndup (s, n); +} + +// For good measure also exerise strcmp return type (not part of the bug). + +char* ret_strcmp (const char *s, const char *t) +{ + extern char* + strcmp (const char*, const char*); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return strcmp (s, t); +} + +// Exercise warnings for pointer/integer mismatches in argument types +// (also not part of the bug). + +char* ret_strcat (size_t s, const char *t) +{ + extern char* + strcat (size_t, const char*); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return strcat (s, t); +} + +char* ret_strcpy (char *s, size_t t) +{ + extern char* strcpy (char*, size_t); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return strcpy (s, t); +} + +char* ret_strncpy (char *s, const char *t, size_t n) +{ + extern char* + strncpy (char*, size_t, const char*); // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } + + return strncpy (s, n, t); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-14.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-14.c new file mode 100644 index 0000000000..cc536d7143 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-14.c @@ -0,0 +1,77 @@ +/* PR c/94040 - ICE on a call to an invalid redeclaration of strftime + { dg-do compile } + { dg-options "-Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +struct tm; + +size_t strftime (char *, size_t, int *, struct tm *); // { dg-warning "-Wbuiltin-declaration-mismatch" } + +size_t call_strftime (char *d, size_t n, int *f, struct tm *t) +{ + size_t r = 0; + r += strftime (0, 0, 0, 0); + r += strftime (d, 0, 0, 0); + r += strftime (d, n, 0, 0); + r += strftime (d, n, f, 0); + r += strftime (d, n, f, t); + return r; +} + + +char* strchr (char*, char*); // { dg-warning "-Wbuiltin-declaration-mismatch" } + +// Verify that missing/extra qualifiers aren't diagnosed without -Wextra. + +int strcmp (char*, char*); +int strncmp (volatile char*, volatile char*, size_t); + +// Verify that a difference in pointers is diagnosed. + +size_t strlen (const char**); +// { dg-warning "-Wbuiltin-declaration-mismatch" "pointer" { target *-*-* } .-1 } + + size_t strnlen (const char* const*, size_t); +// { dg-warning "-Wbuiltin-declaration-mismatch" "pointer" { target *-*-* } .-1 } + + +// Verify that calls to the compatibly-redeclared built-ins are treated +// as those to the built-ins and diagnosed. + +int test_builtin_calls (size_t n) +{ + int r = 0; + r += strcmp ((char*)0, ""); // { dg-warning "\\\[-Wnonnull]" } + r += strcmp ("", (char*)0); // { dg-warning "\\\[-Wnonnull]" } + + r += strncmp ((char*)0, "", n); // { dg-warning "\\\[-Wnonnull]" } + r += strncmp ("", (char*)0, n); // { dg-warning "\\\[-Wnonnull]" } + + return r; +} + + +// Verify that calls to the incompatibly-redeclared built-ins are not +// treated as those to the built-ins by the middle-end. It doesn't +// matter if the front-end diagnoses them but the middle-end should +// not because it shouldn't recognize them as built-ins. + +#pragma GCC optimize "2" + +size_t test_nonbuiltin_calls (char *s, int c) +{ + void *null = 0; + + char *r; + r = strchr ((char*)null, s); + r = strchr (r, (char*)null); + *s = *r; // use the result + + size_t n = 0; + n += strftime (0, 0, 0, 0); + n += strlen ((const char**)null); + n += strnlen ((const char**)null, n); + + return n; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-15.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-15.c new file mode 100644 index 0000000000..3c32a5fc54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-15.c @@ -0,0 +1,56 @@ +/* PR c/94040 - ICE on a call to an invalid redeclaration of strftime + { dg-do compile } + { dg-options "-Wall -Wextra" } */ + +typedef __SIZE_TYPE__ size_t; + +struct tm; + +size_t strftime (const char *, size_t, char *, struct tm *); +// { dg-warning "-Wbuiltin-declaration-mismatch" "arg 1" { target *-*-* } .-1 } + +// Verify that missing/extra qualifiers are diagnosed with -Wextra. + +int strcmp (char*, const char*); +// { dg-warning "-Wbuiltin-declaration-mismatch" "arg 1" { target *-*-* } .-1 } + +int strncmp (const char*, volatile char*, size_t); +// { dg-warning "-Wbuiltin-declaration-mismatch" "arg 2" { target *-*-* } .-1 } + +size_t strlen (char*); +// { dg-warning "-Wbuiltin-declaration-mismatch" "arg 1" { target *-*-* } .-1 } + + +// Verify that calls to built-ins declared with missing/extra qualifiers +// are still treated as those to built-ins by the front-end. + +int test_builtin_calls_fe (size_t n) +{ + int r = 0; + r += strcmp ((char*)0, ""); // { dg-warning "\\\[-Wnonnull]" } + r += strcmp ("", (char*)0); // { dg-warning "\\\[-Wnonnull]" } + + r += strncmp ((char*)0, "", n); // { dg-warning "\\\[-Wnonnull]" } + r += strncmp ("", (char*)0, n); // { dg-warning "\\\[-Wnonnull]" } + + r += strlen ((char*)0); // { dg-warning "\\\[-Wnonnull]" } + return r; +} + + +// Ditto but by the middle-end. + +#pragma GCC optimize "2" + +int test_builtin_calls_me (void) +{ + char *null1 = 0; + char *null2 = null1; + char *null3 = null2; + + int r = 0; + r += strcmp (null1, "123"); // { dg-warning "\\\[-Wnonnull]" } + r += strncmp ("2345", null2, 4); // { dg-warning "\\\[-Wnonnull]" } + r += strlen (null3); // { dg-warning "\\\[-Wnonnull]" } + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-16.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-16.c new file mode 100644 index 0000000000..494fff9ec6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-16.c @@ -0,0 +1,12 @@ +/* PR c/96596 - ICE on a declaration of a built-in with invalid array + argument + { dg-do compile } */ + +void __builtin_abort (int[foo]); /* { dg-error "'foo' undeclared" } */ +void __builtin_trap (int[__SIZE_MAX__]); /* { dg-error "size of unnamed array is too large" } */ +void __builtin_unreachable (int[][]); /* { dg-error "array type has incomplete element type" } */ + +void __builtin_exit (int, int[+]); /* { dg-error "expected expression before" } */ + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-2.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-2.c new file mode 100644 index 0000000000..9d75cd8669 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-2.c @@ -0,0 +1,25 @@ +/* PR c/83656 - missing -Wbuiltin-declaration-mismatch on declaration + without prototype + { dg-do compile } + { dg-options "-Wall -Wextra" } */ + +typedef __SIZE_TYPE__ size_t; + +/* Verify that ordinary library built-ins are not diagnosed with -Wextra + when they take no arguments (except in cases of return type mismatches). + This is in anticipation that C may some day adopt the same syntax as + C++ for declaring functions that take no arguments. */ + +void abort (); + +/* Verify that ordinary library built-ins are diagnosed with -Wextra + when they take arguments. */ + +void* memcpy (); /* { dg-warning "declaration of built-in function .memcpy. without a prototype; expected .void \\\*\\\(void \\\*, const void \\\*, \(long \)*unsigned int\\\)." } */ +void* memset (); /* { dg-warning "declaration of built-in function .memset. without a prototype; expected .void \\\*\\\(void \\\*, int, *\(long \)*unsigned int\\\)." } */ +size_t strlen (); /* { dg-warning "declaration of built-in function .strlen. without a prototype; expected .\(long \)*unsigned int\\\(const char \\\*\\\)." } */ + +/* Variadic built-ins are diagnosed even without -Wextra (they are, + in fact, diagnosed by default). */ +int printf (); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" } */ +int sprintf (); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-3.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-3.c new file mode 100644 index 0000000000..f2ec325954 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-3.c @@ -0,0 +1,116 @@ +/* PR c/83656 - missing -Wbuiltin-declaration-mismatch on declaration + without prototype + { dg-do compile } + { dg-options "-Wbuiltin-declaration-mismatch" } */ + +typedef __SIZE_TYPE__ size_t; + +/* Built-ins declared without a prototype are not diagnosed by default + (without -Wextra) except when their return type doesn't match. */ +int abort (); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" } */ + +/* Built-ins declared without a prototype are not diagnosed without -Wextra. */ +void exit (); +void* memcpy (); +void* memset (); + + +void test_call_abort (void) +{ + /* Verify that a valid call to abort() is not diagnosed. */ + abort (); + + /* Unfortunately, the incompatible declaration above makes GCC "forget" + that abort() is a built-in and so the invalid calls below aren't + diagnosed. The only saving grace is that the invalid declaration + that differs in the return type is diagnosed by default. */ + abort (1); /* { dg-warning "too many arguments to built-in function .abort. expecting 0" "pr?????" { xfail *-*-* } } */ + + abort (1, 2); /* { dg-warning "too many arguments" "pr?????" { xfail *-*-* } } */ +} + + +void test_call_exit (void) +{ + /* Verify that valid calls to exit are not diagnosed. */ + exit ('\0'); + exit (0); + + /* Also verify calls to the built-in. */ + __builtin_exit ('\0'); + __builtin_exit (0); + __builtin_exit (0.0); + + exit (); /* { dg-warning "too few arguments to built-in function 'exit' expecting 1" } */ + + exit (1, 2); /* { dg-warning "too many arguments" } */ + + /* Verify that passing incompatible arguments triggers a warning. */ + exit (""); /* { dg-warning "\\\[-Wint-conversion]" } */ + + struct S { int i; } s = { 0 }; + exit (s); /* { dg-warning "incompatible type for argument 1" } */ +} + + +void test_call_memcpy (void *p, const void *q, size_t n) +{ + memcpy (p, q, n); + + memcpy (); /* { dg-warning "too few arguments to built-in function 'memcpy' expecting 3" } */ + + memcpy (p); /* { dg-warning "too few arguments to built-in function 'memcpy' expecting 3" } */ + + memcpy (p, q); /* { dg-warning "too few arguments to built-in function 'memcpy' expecting 3" } */ + + memcpy (q, p, n); /* { dg-warning "\\\[-Wdiscarded-qualifiers]" } */ + + memcpy (p, n, q); /* { dg-warning "\\\[-Wint-conversion]" } */ + + memcpy (p, q, n, 0); /* { dg-warning "too many arguments to built-in function 'memcpy' expecting 3" } */ +} + + +typedef void* (memcpy_t)(void*, const void*, size_t); +typedef void* (memset_t)(void*, int, size_t); + +void test_init (void) +{ + /* Verify that initialization of a pointer by the address of a built-in + function of a matching type declared without a prototype doesn't + trigger a warning... */ + memset_t *pmemset = memset; + + /* ...but initialization by the address of an incompatible built-in + does even without -Wextra. */ + memcpy_t *pmemcpy = memset; /* { dg-warning "\\\[-Wincompatible-pointer-types]" } */ +} + + +void test_assign (void) +{ + /* Same as above but for assignment. */ + memset_t *pmemset; + pmemset = memset; + + memcpy_t *pmemcpy; + pmemcpy = memset; /* { dg-warning "\\\[-Wincompatible-pointer-types]" } */ +} + + +/* Verify that passing built-ins declared without a prototype to + functions that expect a pointer to a function of a specific type + is diagnosed. Ditto for return statements. */ + +void take_memcpy (memcpy_t*); +void take_any (int, ...); + +memset_t* pass_args (int i) +{ + take_memcpy (memcpy); + take_memcpy (memset); /* { dg-warning "\\\[-Wincompatible-pointer-types]" } */ + + take_any (0, i ? memcpy : memset); /* { dg-warning "\\\[-Wincompatible-pointer-types]" } */ + + return memcpy; /* { dg-warning "\\\[-Wincompatible-pointer-types]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-4.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-4.c new file mode 100644 index 0000000000..e845b43c07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-4.c @@ -0,0 +1,153 @@ +/* PR c/83656 - missing -Wbuiltin-declaration-mismatch on declaration + without prototype + { dg-do compile } + { dg-options "-Wbuiltin-declaration-mismatch" } */ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +char c; +signed char sc; +unsigned char uc; +short si; +unsigned short usi; +int i; +unsigned ui; +long li; +unsigned long uli; + +size_t szi; +typedef size_t SizeType; +SizeType szti; + +ptrdiff_t diffi; + +enum E { e0 } e; + +float f; +double d; +long double ld; + + +/* Verify warnings for undefined calls to built-ins expecting integer + arguments. */ + +int abs (); /* { dg-message "built-in .abs. declared here" } */ + +void test_integer_conversion_abs (void) +{ + i = abs (c); + i = abs (sc); + i = abs (uc); + + i = abs (si); + i = abs (usi); /* { dg-warning ".abs. argument 1 promotes to .unsigned int. where .int. is expected in a call to built-in function declared without prototype" "" { target short_eq_int } } */ + + i = abs (i); + i = abs (ui); /* { dg-warning ".abs. argument 1 type is .unsigned int. where .int. is expected in a call to built-in function declared without prototype" } */ + + /* Verify that the same call as above but to the built-in doesn't + trigger a warning. */ + i = __builtin_abs (ui); + + i = abs (li); /* { dg-warning ".abs. argument 1 type is .long int. where .int. is expected in a call to built-in function declared without prototype" } */ + i = abs (uli); /* { dg-warning ".abs. argument 1 type is .long unsigned int. where .int. is expected in a call to built-in function declared without prototype" } */ + + i = abs (e0); + i = abs (e); + + i = abs (-1.0); /* { dg-warning ".abs. argument 1 type is .double. where .int. is expected in a call to built-in function declared without prototype" } */ + i = abs (f); /* { dg-warning ".abs. argument 1 promotes to .double. where .int. is expected in a call to built-in function declared without prototype" } */ + i = abs (ld); /* { dg-warning ".abs. argument 1 type is .long double. where .int. is expected in a call to built-in function declared without prototype" } */ + + /* Verify that the same call as above but to the built-in doesn't + trigger a warning. */ + i = __builtin_abs (ld); +} + + +extern void* memset (); + +void test_integer_conversion_memset (void *d) +{ + memset (d, 0, sizeof (int)); + memset (d, '\0', szi); + memset (d, i, szti); + + /* Passing a ptrdiff_t where size_t is expected may not be unsafe + but because GCC may emits suboptimal code for such calls warning + for them helps improve efficiency. */ + memset (d, 0, diffi); /* { dg-warning ".memset. argument 3 promotes to .ptrdiff_t. {aka .\(long \)?\(int\)?\(__int20\)?.} where .\(long \)?\(__int20 \)?unsigned\( int\)?. is expected" } */ + + memset (d, 0, 2.0); /* { dg-warning ".memset. argument 3 type is .double. where '\(long \)?\(__int20 \)?unsigned\( int\)?' is expected" } */ + + /* Verify that the same call as above but to the built-in doesn't + trigger a warning. */ + __builtin_memset (d, 0.0, 4.0); +} + + +/* Verify warnings for undefined calls to built-ins expecting floating + arguments. */ + +double fabs (); /* { dg-message "built-in .fabs. declared here" } */ + +/* Expect a warning for fabsf below because even a float argument promotes + to double. Unfortunately, invalid calls to fabsf() are not diagnosed. */ +float fabsf (); /* { dg-warning "conflicting types for built-in function .fabsf.; expected .float\\\(float\\\)." } */ +long double fabsl (); /* { dg-message "built-in .fabsl. declared here" } */ + +void test_real_conversion_fabs (void) +{ + d = fabs (c); /* { dg-warning ".fabs. argument 1 promotes to .int. where .double. is expected in a call to built-in function declared without prototype" } */ + + d = fabs (i); /* { dg-warning ".fabs. argument 1 type is .int. where .double. is expected in a call to built-in function declared without prototype" } */ + + d = fabs (li); /* { dg-warning ".fabs. argument 1 type is .long int. where .double. is expected in a call to built-in function declared without prototype" } */ + + /* In C, the type of an enumeration constant is int. */ + d = fabs (e0); /* { dg-warning ".fabs. argument 1 type is .int. where .double. is expected in a call to built-in function declared without prototype" } */ + + d = fabs (e); /* { dg-warning ".fabs. argument 1 type is .enum E. where .double. is expected in a call to built-in function declared without prototype" "ordinary enum" { target { ! short_enums } } } */ + /* { dg-warning ".fabs. argument 1 promotes to .int. where .double. is expected in a call to built-in function declared without prototype" "size 1 enum" { target short_enums } .-1 } */ + + /* No warning here since float is promoted to double. */ + d = fabs (f); + + d = fabs (ld); /* { dg-warning ".fabs. argument 1 type is .long double. where .double. is expected in a call to built-in function declared without prototype" } */ + + d = fabsf (c); /* { dg-warning ".fabsf. argument 1 promotes to .int. where .float. is expected in a call to built-in function declared without prototype" "pr87890" { xfail *-*-* } } */ + + d = fabsl (c); /* { dg-warning ".fabsl. argument 1 promotes to .int. where .long double. is expected in a call to built-in function declared without prototype" } */ + + d = fabsl (f); /* { dg-warning ".fabsl. argument 1 promotes to .double. where .long double. is expected in a call to built-in function declared without prototype" } */ + + /* Verify that the same call as above but to the built-in doesn't + trigger a warning. */ + d = __builtin_fabsl (f); +} + +/* Verify warnings for calls to a two-argument real function. */ + +double pow (); /* { dg-message "built-in .pow. declared here" } */ + +void test_real_conversion_pow (void) +{ + d = pow (2.0, 2.0); + d = pow (d, 3.0); + d = pow (d, d); + + d = pow (2, 3.0); /* { dg-warning ".pow. argument 1 type is .int. where .double. is expected in a call to built-in function declared without prototype" } */ + d = pow (3.0, 2); /* { dg-warning ".pow. argument 2 type is .int. where .double. is expected in a call to built-in function declared without prototype" } */ +} + + +/* Verify warnings for calls that discard qualifiers. */ + +extern void* memcpy (); + +void test_qual_conversion_memcpy (void *d, const void *s) +{ + memcpy (d, s, sizeof (int)); + memcpy (s, d, sizeof (int)); /* { dg-warning "passing argument 1 of .memcpy. discards 'const' qualifier from pointer target type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-5.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-5.c new file mode 100644 index 0000000000..9cac927775 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-5.c @@ -0,0 +1,19 @@ +/* PR testsuite/88098 - FAIL: gcc.dg/Wbuiltin-declaration-mismatch-4.c + { dg-do compile } + { dg-options "-Wbuiltin-declaration-mismatch -fshort-enums" } */ + +int abs (); +double fabs (); /* { dg-message "built-in .fabs. declared here" } */ + +enum E { e0 } e; + +int i; +double d; + +void test_short_enums (void) +{ + /* enum e promotes to int. */ + i = abs (e); + + d = fabs (e); /* { dg-warning ".fabs. argument 1 promotes to .int. where .double. is expected in a call to built-in function declared without prototype" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-6.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-6.c new file mode 100644 index 0000000000..32af9febfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-6.c @@ -0,0 +1,18 @@ +/* PR c/86125 - missing -Wbuiltin-declaration-mismatch on a mismatched + return type + Verify that declarations of file I/O built-ins with an arbitrary + object pointer do not trigger -Wbuiltin-declaration-mismatch. + { dg-do compile } + { dg-options "-Wbuiltin-declaration-mismatch -Wextra" } */ + +typedef __SIZE_TYPE__ size_t; + +struct StdioFile; + +int fprintf (struct StdioFile*, const char*, ...); +int vfprintf (struct StdioFile*, const char*, __builtin_va_list); +int fputc (int, struct StdioFile*); +int fputs (const char*, struct StdioFile*); +int fscanf (struct StdioFile*, const char*, ...); +int vfscanf (struct StdioFile*, const char*, __builtin_va_list); +size_t fwrite (const void*, size_t, size_t, struct StdioFile*); diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-7.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-7.c new file mode 100644 index 0000000000..ba2fec9dee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-7.c @@ -0,0 +1,26 @@ +/* PR c/86125 - missing -Wbuiltin-declaration-mismatch on a mismatched + return type + Verify that a declaration of vfprintf() with withe the wrong last + argument triggers -Wbuiltin-declaration-mismatch even without -Wextra. + { dg-do compile { target { { lp64 || ilp32 } || llp64 } } } + { dg-options "-Wbuiltin-declaration-mismatch" } */ + +struct StdioFile; + +typedef __SIZE_TYPE__ size_t; + +struct StdioFile; + +int fprintf (struct StdioFile*, const char*); /* { dg-warning "conflicting types for built-in function .fprintf.; expected .int\\\(\[a-z_\]+ \\\*, const char \\\*, \.\.\.\\\)." } */ + +int vfprintf (struct StdioFile*, const char*, ...); /* { dg-warning "conflicting types for built-in function .vfprintf.; expected .int\\\(\[a-z_\]+ \\\*, const char \\\*, \[^\n\r,\\\)\]+\\\)." } */ + +int fputc (char, struct StdioFile*); /* { dg-warning "conflicting types for built-in function .fputc.; expected .int\\\(int, void \\\*\\\)." } */ + +unsigned long long fputs (const char*, struct StdioFile*); /* { dg-warning "conflicting types for built-in function .fputs.; expected .int\\\(const char \\\*, \[a-z_\]+ \\\*\\\)." } */ + +int fscanf (struct StdioFile*, const char*, size_t, ...); /* { dg-warning "conflicting types for built-in function .fscanf.; expected .int\\\(\[a-z_\]+ \\\*, const char \\\*, \.\.\.\\\)." } */ + +int vfscanf (struct StdioFile*, const char*, ...); /* { dg-warning "conflicting types for built-in function .vfscanf.; expected .int\\\(\[a-z_\]+ \\\*, const char \\\*, \[^\n\r,\\\)\]+\\\)." } */ + +size_t fwrite (const void*, size_t, size_t, struct StdioFile); /* { dg-warning "conflicting types for built-in function .fwrite.; expected .\(long \)*unsigned int\\\(const void \\\*, \(long \)*unsigned int, *\(long \)*unsigned int, *\[a-z_\]+ \\\*\\\)." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-8.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-8.c new file mode 100644 index 0000000000..d06af6528f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-8.c @@ -0,0 +1,26 @@ +/* PR c/86125 - missing -Wbuiltin-declaration-mismatch on a mismatched + return type + Verify that declarations of file I/O built-ins with different + definitions of struct FILE triggers -Wbuiltin-declaration-mismatch + when -Wextra is specified. + { dg-do compile } + { dg-options "-Wall -Wbuiltin-declaration-mismatch" } */ + +struct FooFile; +int fputc (int, struct FooFile*); + +typedef struct FooFile AlsoFooFile; +int fprintf (AlsoFooFile*, const char*, ...); + +typedef AlsoFooFile* FooFilePtr; +int fscanf (FooFilePtr, const char*, ...); + +/* No warning here (-Wextra not specified). */ +struct BarFile; +int vfprintf (struct BarFile*, const char*, __builtin_va_list); + + +/* Set -Wextra and verify -Wbuiltin-declaration-mismatch is issued. */ +#pragma GCC diagnostic warning "-Wextra" + +int fputs (const char*, struct BarFile*); /* { dg-warning "mismatch in argument 2 type of built-in function .fputs.; expected .struct FooFile \\\*." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-9.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-9.c new file mode 100644 index 0000000000..82db8fe33d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-9.c @@ -0,0 +1,16 @@ +/* PR c/88886 - ice in get_constant, at c-family/c-format.c:292 + { dg-do compile } + { dg-options "-Wall" } */ + +int sscanf (long, unsigned[], ...); /* { dg-warning "conflicting types for built-in function .sscanf.; expected .int\\\(const char \\\*, const char \\\*, ...\\\)." } */ + +void a (void) +{ + sscanf (0, + "" /* { dg-warning "passing argument 2 of .sscanf. from incompatible pointer type" } */ + ); +} + +/* The invalid scanf call may also trigger: + { dg-prune-output "accessing 4 bytes in a region of size 1" } + { dg-prune-output "accessing 2 bytes in a region of size 1" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-ignore.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-ignore.c new file mode 100644 index 0000000000..732c23f91b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch-ignore.c @@ -0,0 +1,11 @@ +/* Check -Wbuiltin-declaration-mismatch can be ignored with pragma. */ +/* { dg-do compile } + { dg-options "-Wno-implicit-function-declaration -Wno-int-conversion -Wbuiltin-declaration-mismatch" } */ + +#pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch" +int foo (const char *str) +{ + int i; + sscanf (str, "%d", &i); + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch.c b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch.c new file mode 100644 index 0000000000..ed66fd3626 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wbuiltin-declaration-mismatch.c @@ -0,0 +1,23 @@ +/* PR c/83656 - missing -Wbuiltin-declaration-mismatch on declaration + without prototype + { dg-do compile } + { dg-options "-Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +/* Verify that ordinary library built-ins are not diagnosed with -Wall + (or by default) whether or not they take arguments (even though they + should be). */ + +void abort (); +void* memcpy (); +void* memset (); +size_t strlen (); + +/* Verify mismatches in return types are diagnosed. */ +int exit (); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" } */ + +/* Variadic built-ins are diagnosed with -Wall (they are, in fact, + diagnosed by default). */ +int printf (); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" } */ +int sprintf (); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wc++-compat.c b/SingleSource/Regression/C/gcc-dg/Wc++-compat.c new file mode 100644 index 0000000000..aa435be9f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc++-compat.c @@ -0,0 +1,9 @@ +/* Copyright (C) 2005 Free Software Foundation. + + by Gabriel Dos Reis */ + +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +extern const int foo = 42; + diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-1.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-1.c new file mode 100644 index 0000000000..15e71e8f8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-1.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -Wpedantic -Wc90-c99-compat" } */ + +_Bool b; /* { dg-warning "ISO C90 does not support boolean types" } */ +_Complex double c = __builtin_complex (0.0, 0.0); /* { dg-warning "ISO C90 does not support complex types" } */ +long long l; /* { dg-warning "ISO C90 does not support .long long." } */ +struct A { int i; char a[]; }; /* { dg-warning "ISO C90 does not support flexible array members" } */ +struct { long int b: 2; } s; /* { dg-warning "type of bit-field .b. is a GCC extension" } */ +const const int i; /* { dg-warning "duplicate .const." } */ +volatile volatile v; /* { dg-warning "duplicate .volatile." } */ + +struct S { int a[2]; }; +extern struct S foo (void); + +#define V(v, ...) (v, __VA_ARGS) /* { dg-warning "anonymous variadic macros were introduced in C99" } */ + +enum { E, }; /* { dg-warning "comma at end of enumerator list" } */ + +void fn1 (char [*]); /* { dg-warning "ISO C90 does not support .\\\[\\\*\\\]. array declarators" } */ + +void +fn2 (char x[static 4]) /* { dg-warning "ISO C90 does not support .static. or type qualifiers" } */ +{ + int i = (int) { 1 }; /* { dg-warning "ISO C90 forbids compound literals" } */ + struct A a = { .i = 3 }; /* { dg-warning "ISO C90 forbids specifying subobject to initialize" } */ +} + +void +fn3 (int n) +{ + n = 3; + int i; /* { dg-warning "ISO C90 forbids mixed declarations and code" } */ +} + +void +fn4 (int n) +{ + n = 3; + __extension__ int i; /* { dg-warning "ISO C90 forbids mixed declarations and code" } */ +} + +void +fn5 (void) +{ + (foo ()).a[0]; /* { dg-warning "ISO C90 forbids subscripting non-lvalue array" } */ +} + +#define F(a) a + +void +fn6 (void) +{ + F(); /* { dg-warning "invoking macro F argument" } */ +} + +void fn7 (int n, int a[n]); /* { dg-warning "ISO C90 forbids variable length array .a." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-10.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-10.c new file mode 100644 index 0000000000..c419ec52be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-10.c @@ -0,0 +1,12 @@ +/* PR c/85318 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -Wc90-c99-compat -pedantic-errors" } */ + +extern void bar (int); + +void +foo (int n) +{ + for (int i = 0; i < n; i++) /* { dg-warning "ISO C90 does not support .for. loop" } */ + bar (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-11.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-11.c new file mode 100644 index 0000000000..12f9d27b7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-11.c @@ -0,0 +1,12 @@ +/* PR c/85318 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -Wc90-c99-compat -Wno-pedantic" } */ + +extern void bar (int); + +void +foo (int n) +{ + for (int i = 0; i < n; i++) /* { dg-warning "ISO C90 does not support .for. loop" } */ + bar (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-12.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-12.c new file mode 100644 index 0000000000..37f2e85423 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-12.c @@ -0,0 +1,12 @@ +/* PR c/85318 */ +/* { dg-do compile } */ +/* { dg-options "-Wpedantic" } */ + +extern void bar (int); + +void +foo (int n) +{ + for (int i = 0; i < n; i++) /* { dg-bogus "ISO C90 does not support .for. loop" } */ + bar (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-2.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-2.c new file mode 100644 index 0000000000..d00f0df89f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-2.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wc90-c99-compat -pedantic-errors" } */ + +_Bool b; /* { dg-warning "ISO C90 does not support boolean types" } */ +_Complex double c = __builtin_complex (0.0, 0.0); /* { dg-warning "ISO C90 does not support complex types" } */ +long long l; /* { dg-warning "ISO C90 does not support .long long." } */ +struct A { int i; char a[]; }; /* { dg-warning "ISO C90 does not support flexible array members" } */ +struct { long int b: 2; } s; /* { dg-warning "type of bit-field .b. is a GCC extension" } */ +const const int i; /* { dg-warning "duplicate .const." } */ +volatile volatile int v; /* { dg-warning "duplicate .volatile." } */ + +struct S { int a[2]; }; +extern struct S foo (void); + +#define V(v, ...) (v, __VA_ARGS) /* { dg-warning "anonymous variadic macros were introduced in C99" } */ + +enum { E, }; /* { dg-warning "comma at end of enumerator list" } */ + +void fn1 (char [*]); /* { dg-warning "ISO C90 does not support .\\\[\\\*\\\]. array declarators" } */ + +void +fn2 (char x[static 4]) /* { dg-warning "ISO C90 does not support .static. or type qualifiers" } */ +{ + int i = (int) { 1 }; /* { dg-warning "ISO C90 forbids compound literals" } */ + struct A a = { .i = 3 }; /* { dg-warning "ISO C90 forbids specifying subobject to initialize" } */ +} + +void +fn3 (int n) +{ + n = 3; + int i; /* { dg-warning "ISO C90 forbids mixed declarations and code" } */ +} + +void +fn4 (int n) +{ + n = 3; + __extension__ int i; /* { dg-warning "ISO C90 forbids mixed declarations and code" } */ +} + +void +fn5 (void) +{ + (foo ()).a[0]; /* { dg-warning "ISO C90 forbids subscripting non-lvalue array" } */ +} + +#define F(a) a + +void +fn6 (void) +{ + F(); /* { dg-warning "invoking macro F argument" } */ +} + +void fn7 (int n, int a[n]); /* { dg-warning "ISO C90 forbids variable length array .a." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-3.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-3.c new file mode 100644 index 0000000000..78f012c48a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-3.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -Wc90-c99-compat -pedantic-errors" } */ + +_Bool b; /* { dg-warning "ISO C90 does not support boolean types" } */ +_Complex double c = __builtin_complex (0.0, 0.0); /* { dg-warning "ISO C90 does not support complex types" } */ +long long l; /* { dg-warning "ISO C90 does not support .long long." } */ +struct A { int i; char a[]; }; /* { dg-warning "ISO C90 does not support flexible array members" } */ +struct { long int b: 2; } s; /* { dg-warning "type of bit-field .b. is a GCC extension" } */ +const const int i; /* { dg-warning "duplicate .const." } */ +volatile volatile int v; /* { dg-warning "duplicate .volatile." } */ + +struct S { int a[2]; }; +extern struct S foo (void); + +#define V(v, ...) (v, __VA_ARGS) /* { dg-warning "anonymous variadic macros were introduced in C99" } */ + +enum { E, }; /* { dg-warning "comma at end of enumerator list" } */ + +void fn1 (char [*]); /* { dg-warning "ISO C90 does not support .\\\[\\\*\\\]. array declarators" } */ + +void +fn2 (char x[static 4]) /* { dg-warning "ISO C90 does not support .static. or type qualifiers" } */ +{ + int i = (int) { 1 }; /* { dg-warning "ISO C90 forbids compound literals" } */ + struct A a = { .i = 3 }; /* { dg-warning "ISO C90 forbids specifying subobject to initialize" } */ +} + +void +fn3 (int n) +{ + n = 3; + int i; /* { dg-warning "ISO C90 forbids mixed declarations and code" } */ +} + +void +fn4 (int n) +{ + n = 3; + __extension__ int i; /* { dg-warning "ISO C90 forbids mixed declarations and code" } */ +} + +void +fn5 (void) +{ + (foo ()).a[0]; /* { dg-warning "ISO C90 forbids subscripting non-lvalue array" } */ +} + +#define F(a) a + +void +fn6 (void) +{ + F(); /* { dg-warning "invoking macro F argument" } */ +} + +void fn7 (int n, int a[n]); /* { dg-warning "ISO C90 forbids variable length array .a." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-4.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-4.c new file mode 100644 index 0000000000..97ee84c1dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-4.c @@ -0,0 +1,54 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -Wpedantic -Wno-c90-c99-compat" } */ + +_Bool b; +_Complex double c = __builtin_complex (0.0, 0.0); +long long l; +struct A { int i; char a[]; }; +struct { long int b: 2; } s; +const const int i; +volatile volatile int v; + +struct S { int a[2]; }; +extern struct S foo (void); + +enum { E, }; + +void fn1 (char [*]); + +void +fn2 (char x[static 4]) +{ + int i = (int) { 1 }; + struct A a = { .i = 3 }; +} + +void +fn3 (int n) +{ + n = 3; + int i; +} + +void +fn4 (int n) +{ + n = 3; + __extension__ int i; +} + +void +fn5 (void) +{ + (foo ()).a[0]; +} + +#define F(a) a + +void +fn6 (void) +{ + F(); +} + +void fn7 (int n, int a[n]); diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-5.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-5.c new file mode 100644 index 0000000000..f41e960d87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-5.c @@ -0,0 +1,54 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -pedantic-errors -Wno-c90-c99-compat" } */ + +_Bool b; +_Complex double c = __builtin_complex (0.0, 0.0); +long long l; +struct A { int i; char a[]; }; +struct { long int b: 2; } s; +const const int i; +volatile volatile int v; + +struct S { int a[2]; }; +extern struct S foo (void); + +enum { E, }; + +void fn1 (char [*]); + +void +fn2 (char x[static 4]) +{ + int i = (int) { 1 }; + struct A a = { .i = 3 }; +} + +void +fn3 (int n) +{ + n = 3; + int i; +} + +void +fn4 (int n) +{ + n = 3; + __extension__ int i; +} + +void +fn5 (void) +{ + (foo ()).a[0]; +} + +#define F(a) a + +void +fn6 (void) +{ + F(); +} + +void fn7 (int n, int a[n]); diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-6.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-6.c new file mode 100644 index 0000000000..8728cd9be9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-6.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -Wc90-c99-compat" } */ + +__extension__ _Bool b; +__extension__ _Complex double c = __builtin_complex (0.0, 0.0); +__extension__ long long l; +__extension__ struct A { int i; char a[]; }; +__extension__ struct { long int b: 2; } s; +__extension__ const const int i; +__extension__ volatile volatile int v; +__extension__ struct S { int a[2]; }; +extern struct S foo (void); +__extension__ enum { E, }; +__extension__ void fn1 (char [*]); + +__extension__ void +fn2 (char x[static 4]) +{ + int i = (int) { 1 }; + struct A a = { .i = 3 }; +} + +__extension__ void +fn5 (void) +{ + (foo ()).a[0]; +} + +__extension__ void fn7 (int n, int a[n]); diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-7.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-7.c new file mode 100644 index 0000000000..fbf0b0d59c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-7.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -Wpedantic -Wc90-c99-compat -Wno-long-long -Wno-declaration-after-statement -Wno-vla" } */ + +long long l; + +void +fn3 (int n) +{ + n = 3; + int i; +} + +void fn7 (int n, int a[n]); diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-8.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-8.c new file mode 100644 index 0000000000..5e7a5725a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-8.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -pedantic-errors -Wc90-c99-compat" } */ + +_Bool b; /* { dg-error "ISO C90 does not support boolean types" } */ +_Complex double c = __builtin_complex (0.0, 0.0); /* { dg-error "ISO C90 does not support complex types" } */ +long long l; /* { dg-error "ISO C90 does not support .long long." } */ +struct A { int i; char a[]; }; /* { dg-error "ISO C90 does not support flexible array members" } */ +struct { long int b: 2; } s; /* { dg-error "type of bit-field .b. is a GCC extension" } */ +const const int i; /* { dg-error "duplicate .const." } */ +volatile volatile v; /* { dg-error "duplicate .volatile." } */ + +struct S { int a[2]; }; +extern struct S foo (void); + +#define V(v, ...) (v, __VA_ARGS) /* { dg-error "anonymous variadic macros were introduced in C99" } */ + +enum { E, }; /* { dg-error "comma at end of enumerator list" } */ + +void fn1 (char [*]); /* { dg-error "ISO C90 does not support .\\\[\\\*\\\]. array declarators" } */ + +void +fn2 (char x[static 4]) /* { dg-error "ISO C90 does not support .static. or type qualifiers" } */ +{ + int i = (int) { 1 }; /* { dg-error "ISO C90 forbids compound literals" } */ + struct A a = { .i = 3 }; /* { dg-error "ISO C90 forbids specifying subobject to initialize" } */ +} + +void +fn3 (int n) +{ + n = 3; + int i; /* { dg-error "ISO C90 forbids mixed declarations and code" } */ +} + +void +fn4 (int n) +{ + n = 3; + __extension__ int i; /* { dg-error "ISO C90 forbids mixed declarations and code" } */ +} + +void +fn5 (void) +{ + (foo ()).a[0]; /* { dg-error "ISO C90 forbids subscripting non-lvalue array" } */ +} + +#define F(a) a + +void +fn6 (void) +{ + F(); /* { dg-error "invoking macro F argument" } */ +} + +void fn7 (int n, int a[n]); /* { dg-error "ISO C90 forbids variable length array .a." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-9.c b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-9.c new file mode 100644 index 0000000000..8bd996c8c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc90-c99-compat-9.c @@ -0,0 +1,12 @@ +/* PR c/85318 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wc90-c99-compat -pedantic-errors" } */ + +extern void bar (int); + +void +foo (int n) +{ + for (int i = 0; i < n; i++) /* { dg-warning "ISO C90 does not support .for. loop" } */ + bar (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-1.c b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-1.c new file mode 100644 index 0000000000..58fc5b8f45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -pedantic -Wc99-c11-compat" } */ + +struct S { int i; struct { int a; }; }; /* { dg-warning "ISO C90 doesn.t support unnamed structs/unions" } */ +_Noreturn void foo (void); /* { dg-warning "ISO C90 does not support ._Noreturn." } */ +typedef int A; +typedef int A; /* { dg-warning "redefinition of typedef .A." } */ +_Thread_local int i; /* { dg-warning "ISO C90 does not support ._Thread_local." } */ +_Static_assert (1, "foo"); /* { dg-warning "ISO C90 does not support ._Static_assert." } */ +_Atomic int a; /* { dg-warning "ISO C90 does not support the ._Atomic. qualifier" } */ +_Alignas (int) int aa; /* { dg-warning "ISO C90 does not support ._Alignas." } */ +enum e { E = _Alignof (double) }; /* { dg-warning "ISO C90 does not support ._Alignof." } */ + +void +fn (int n) +{ + _Generic (n, int: 0); /* { dg-warning "ISO C90 does not support ._Generic." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-2.c b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-2.c new file mode 100644 index 0000000000..9d1aa8180b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic -Wc99-c11-compat" } */ + +struct S { int i; struct { int a; }; }; /* { dg-warning "ISO C99 doesn.t support unnamed structs/unions" } */ +_Noreturn void foo (void); /* { dg-warning "ISO C99 does not support ._Noreturn." } */ +typedef int A; +typedef int A; /* { dg-warning "redefinition of typedef .A." } */ +_Thread_local int i; /* { dg-warning "ISO C99 does not support ._Thread_local." } */ +_Static_assert (1, "foo"); /* { dg-warning "ISO C99 does not support ._Static_assert." } */ +_Atomic int a; /* { dg-warning "ISO C99 does not support the ._Atomic. qualifier" } */ +_Alignas (int) int aa; /* { dg-warning "ISO C99 does not support ._Alignas." } */ +enum e { E = _Alignof (double) }; /* { dg-warning "ISO C99 does not support ._Alignof." } */ + +void +fn (int n) +{ + _Generic (n, int: 0); /* { dg-warning "ISO C99 does not support ._Generic." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-3.c b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-3.c new file mode 100644 index 0000000000..64e24f8083 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -pedantic-errors -Wc99-c11-compat" } */ + +struct S { int i; struct { int a; }; }; /* { dg-warning "ISO C99 doesn.t support unnamed structs/unions" } */ +_Noreturn void foo (void); /* { dg-warning "ISO C99 does not support ._Noreturn." } */ +typedef int A; +typedef int A; /* { dg-warning "redefinition of typedef .A." } */ +_Thread_local int i; /* { dg-warning "ISO C99 does not support ._Thread_local." } */ +_Static_assert (1, "foo"); /* { dg-warning "ISO C99 does not support ._Static_assert." } */ +_Atomic int a; /* { dg-warning "ISO C99 does not support the ._Atomic. qualifier" } */ +_Alignas (int) int aa; /* { dg-warning "ISO C99 does not support ._Alignas." } */ +enum e { E = _Alignof (double) }; /* { dg-warning "ISO C99 does not support ._Alignof." } */ + +void +fn (int n) +{ + _Generic (n, int: 0); /* { dg-warning "ISO C99 does not support ._Generic." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-4.c b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-4.c new file mode 100644 index 0000000000..511ccee42d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors -Wno-c99-c11-compat" } */ + +struct S { int i; struct { int a; }; }; +_Noreturn void foo (void); +typedef int A; +typedef int A; +_Thread_local int i; +_Static_assert (1, "foo"); +_Atomic int a; +_Alignas (int) int aa; +enum e { E = _Alignof (double) }; + +void +fn (int n) +{ + _Generic (n, int: 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-5.c b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-5.c new file mode 100644 index 0000000000..ce9698c007 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-5.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -Wc99-c11-compat" } */ + +__extension__ struct S { int i; struct { int a; }; }; +__extension__ _Noreturn void foo (void); +typedef int A; +__extension__ typedef int A; +__extension__ _Thread_local int i; +__extension__ _Static_assert (1, "foo"); +__extension__ _Atomic int a; +__extension__ _Alignas (int) int aa; +enum e { E = __extension__ _Alignof (double) }; + +void +fn (int n) +{ + __extension__ _Generic (n, int: 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-6.c b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-6.c new file mode 100644 index 0000000000..07d7582f24 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-6.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -pedantic-errors -Wc99-c11-compat" } */ + +struct S { int i; struct { int a; }; }; /* { dg-error "ISO C90 doesn.t support unnamed structs/unions" } */ +_Noreturn void foo (void); /* { dg-error "ISO C90 does not support ._Noreturn." } */ +typedef int A; +typedef int A; /* { dg-error "redefinition of typedef .A." } */ +_Thread_local int i; /* { dg-error "ISO C90 does not support ._Thread_local." } */ +_Static_assert (1, "foo"); /* { dg-error "ISO C90 does not support ._Static_assert." } */ +_Atomic int a; /* { dg-error "ISO C90 does not support the ._Atomic. qualifier" } */ +_Alignas (int) int aa; /* { dg-error "ISO C90 does not support ._Alignas." } */ +enum e { E = _Alignof (double) }; /* { dg-error "ISO C90 does not support ._Alignof." } */ + +void +fn (int n) +{ + _Generic (n, int: 0); /* { dg-error "ISO C90 does not support ._Generic." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-7.c b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-7.c new file mode 100644 index 0000000000..a7033c9284 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wc99-c11-compat-7.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors -Wc99-c11-compat" } */ + +struct S { int i; struct { int a; }; }; /* { dg-error "ISO C99 doesn.t support unnamed structs/unions" } */ +_Noreturn void foo (void); /* { dg-error "ISO C99 does not support ._Noreturn." } */ +typedef int A; +typedef int A; /* { dg-error "redefinition of typedef .A." } */ +_Thread_local int i; /* { dg-error "ISO C99 does not support ._Thread_local." } */ +_Static_assert (1, "foo"); /* { dg-error "ISO C99 does not support ._Static_assert." } */ +_Atomic int a; /* { dg-error "ISO C99 does not support the ._Atomic. qualifier" } */ +_Alignas (int) int aa; /* { dg-error "ISO C99 does not support ._Alignas." } */ +enum e { E = _Alignof (double) }; /* { dg-error "ISO C99 does not support ._Alignof." } */ + +void +fn (int n) +{ + _Generic (n, int: 0); /* { dg-error "ISO C99 does not support ._Generic." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wchar-subscripts-1.c b/SingleSource/Regression/C/gcc-dg/Wchar-subscripts-1.c new file mode 100644 index 0000000000..3f5adeb31d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wchar-subscripts-1.c @@ -0,0 +1,29 @@ +/* Test -Wchar-subscripts. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wchar-subscripts" } */ + +extern int a[]; +int *p; +char c; +signed char sc; +unsigned char uc; + +void +f (void) +{ + a[sc]; + a[uc]; + sc[a]; + uc[a]; + p[sc]; + p[uc]; + sc[p]; + uc[p]; + a[c]; /* { dg-warning "array subscript has type 'char'" } */ + p[c]; /* { dg-warning "array subscript has type 'char'" } */ + /* -Wchar-subscripts does not warn if the char is not syntactically + the subscript. */ + c[a]; + c[p]; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wchar-subscripts.c b/SingleSource/Regression/C/gcc-dg/Wchar-subscripts.c new file mode 100644 index 0000000000..acc6d23578 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wchar-subscripts.c @@ -0,0 +1,12 @@ +/* Copyright (C) 2005 Free Software Foundation. + + by Gabriel Dos Reis */ + +/* { dg-do compile } */ +/* { dg-options "-Wchar-subscripts" } */ + +int main(void) +{ + int ary[256] = { 0 }; + return ary['a']; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-1.c b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-1.c new file mode 100644 index 0000000000..71016e05ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-1.c @@ -0,0 +1,2 @@ +/* { dg-options -Wctad-maybe-unsupported } and '-Wcomplain-wrong-lang' enabled by default: + { dg-warning {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-2.c b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-2.c new file mode 100644 index 0000000000..ba2192dd2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-2.c @@ -0,0 +1,2 @@ +/* { dg-options {-Wcomplain-wrong-lang -Wctad-maybe-unsupported} } + { dg-warning {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-3.c b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-3.c new file mode 100644 index 0000000000..36bf748e53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-3.c @@ -0,0 +1,2 @@ +/* { dg-options {-Wctad-maybe-unsupported -Wno-complain-wrong-lang} } + { dg-bogus {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-4.c b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-4.c new file mode 100644 index 0000000000..af185f86fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-4.c @@ -0,0 +1,2 @@ +/* { dg-options {-Wno-complain-wrong-lang -Wctad-maybe-unsupported} } + { dg-bogus {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-5.c b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-5.c new file mode 100644 index 0000000000..dc0a42c629 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcomplain-wrong-lang-5.c @@ -0,0 +1,2 @@ +/* { dg-options {-Wcomplain-wrong-lang -Wctad-maybe-unsupported -Wno-complain-wrong-lang} } + { dg-bogus {command-line option '-Wctad-maybe-unsupported' is valid for C\+\+/ObjC\+\+ but not for C} {} { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-3.c b/SingleSource/Regression/C/gcc-dg/Wconversion-3.c new file mode 100644 index 0000000000..d102d169d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-3.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wconversion" } */ + +unsigned f(unsigned a) { return a + -1; } /* { dg-warning "conversion" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-4.c b/SingleSource/Regression/C/gcc-dg/Wconversion-4.c new file mode 100644 index 0000000000..ddd19879fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-4.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned f(unsigned a) { return a + -1; } + diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-5.c b/SingleSource/Regression/C/gcc-dg/Wconversion-5.c new file mode 100644 index 0000000000..e54fe1a8ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-5.c @@ -0,0 +1,35 @@ +/* PR c++/34198 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wconversion" } */ + +signed char sc; +unsigned char uc; +short int ss; +unsigned short int us; +int si; +unsigned int ui; + +void test1 (void) +{ + int a = uc & 0xff; + int b = sc & 0x7f; + int c = 0xff & uc; + int d = 0x7f & sc; + int e = uc & sc; + unsigned char f = (int) uc; + signed char g = (int) sc; + unsigned char h = (unsigned int) (short int) uc; + signed char i = (int) (unsigned short int) sc; /* { dg-warning "conversion from .int. to .signed char. may change value" "" { target { int32plus } } } */ + unsigned char j = (unsigned int) (short int) us; /* { dg-warning "may change value" } */ + signed char k = (int) (unsigned short int) ss; /* { dg-warning "may change value" } */ +} + +void test2 (void) +{ + signed char a = (unsigned char) sc; /* { dg-warning "may change the sign" } */ + unsigned char b = (signed char) uc; /* { dg-warning "may change the sign" } */ + signed char c = (int) (unsigned char) sc; /* { dg-warning "may change the sign" } */ + unsigned char d = (int) (signed char) uc; /* { dg-warning "may change the sign" } */ + int e = (unsigned int) si; /* { dg-warning "may change the sign" } */ + unsigned int f = (int) ui; /* { dg-warning "may change the sign" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-complex-c99.c b/SingleSource/Regression/C/gcc-dg/Wconversion-complex-c99.c new file mode 100644 index 0000000000..e8bc9db237 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-complex-c99.c @@ -0,0 +1,138 @@ +/* PR c/48956: Test for diagnostics for implicit conversions from complex + to real types and narrowing conversions of complex types. */ + +/* Architecture restrictions taken from Wconversion-real-integer.c. + Likewise, the magic value 16777217. */ + +/* { dg-do compile } */ +/* { dg-skip-if "doubles are floats,ints are 16bits" { "avr-*-*" } } */ +/* { dg-options " -std=c99 -pedantic -Wconversion " } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-require-effective-target double64plus } */ + +/* A number which does not fit into float. */ +#define MAX_FLOAT_PLUS 16777217. + +/* Other types could be added, but that won't affect test coverage. */ +void ffloatc (float _Complex); +void fdoublec (double _Complex); + +void ffloat (float); +void fdouble (double); + +void fsi (int); +void fui (unsigned); + +float _Complex vfloatc; +double _Complex vdoublec; + +float vfloat; +double vdouble; + +int vsi; +unsigned vui; + +/* Check implicit conversions of complex values to reals. */ +void +var_complex_to_real (void) +{ + float _Complex floatc = 0.; + double _Complex doublec = 0.; + + ffloatc (floatc); + fdoublec (doublec); + vfloatc = floatc; + vdoublec = doublec; + + ffloat (floatc); /* { dg-warning "conversion" } */ + fdouble (floatc); /* { dg-warning "conversion" } */ + vfloat = floatc; /* { dg-warning "conversion" } */ + vdouble = floatc; /* { dg-warning "conversion" } */ + + ffloat (doublec); /* { dg-warning "conversion" } */ + fdouble (doublec); /* { dg-warning "conversion" } */ + vfloat = doublec; /* { dg-warning "conversion" } */ + vdouble = doublec; /* { dg-warning "conversion" } */ +} + +/* Check implicit narrowing conversions of complex values. */ +void +var_complex_narrowing (void) +{ + float _Complex floatc = 0.; + double _Complex doublec = 0.; + + vdoublec = floatc; + vfloatc = doublec; /* { dg-warning "conversion from .complex double. to .complex float. may change value" } */ + + fdoublec (floatc); + ffloatc (doublec); /* { dg-warning "conversion from .complex double. to .complex float. may change value" } */ +} + +/* Check implicit conversions of complex values to integers. */ +void +var_complex_to_int (void) +{ + float _Complex floatc = 0.; + double _Complex doublec = 0.; + + fsi (floatc); /* { dg-warning "conversion" } */ + fui (floatc); /* { dg-warning "conversion" } */ + vsi = floatc; /* { dg-warning "conversion" } */ + vui = floatc; /* { dg-warning "conversion" } */ + + fsi (doublec); /* { dg-warning "conversion" } */ + fui (doublec); /* { dg-warning "conversion" } */ + vsi = doublec; /* { dg-warning "conversion" } */ + vui = doublec; /* { dg-warning "conversion" } */ +} + +/* Check implicit conversion of constant complex values to floats. */ +void +const_complex_to_real (void) +{ + ffloat (__builtin_complex (0., 1.)); /* { dg-warning "conversion" } */ + fdouble (__builtin_complex (0., 1.)); /* { dg-warning "conversion" } */ + + vfloat = __builtin_complex (0., 1.); /* { dg-warning "conversion" } */ + vdouble = __builtin_complex (0., 1.); /* { dg-warning "conversion" } */ + + vfloat = __builtin_complex (1., 0.) + __builtin_complex (1., 0.); + vdouble = __builtin_complex (0., 0.) * __builtin_complex (1., 1.); + ffloat (__builtin_complex (1., 0.) + __builtin_complex (1., 0.)); + fdouble (__builtin_complex (1., 0.) + __builtin_complex (1., 0.)); + + vfloat = __builtin_complex (MAX_FLOAT_PLUS, 0.); /* { dg-warning "float-conversion" } */ + ffloat (__builtin_complex (MAX_FLOAT_PLUS, 0.)); /* { dg-warning "float-conversion" } */ +} + +/* Check implicit conversion of constant complex values to integers. */ +void +const_complex_to_int (void) +{ + vsi = __builtin_complex (-1., 0.); + vui = __builtin_complex (1., 0.); + fsi (__builtin_complex (-1., 0.)); + fui (__builtin_complex (1., 0.)); + + vui = __builtin_complex (-1., 0.); /* { dg-warning "overflow" } */ + fui (__builtin_complex (-1., 0.)); /* { dg-warning "overflow" } */ + + vsi = __builtin_complex (0.5, 0.); /* { dg-warning "float-conversion" } */ + fui (__builtin_complex (0.5, 0.)); /* { dg-warning "float-conversion" } */ + + vsi = __builtin_complex (-0.5, 0.); /* { dg-warning "float-conversion" } */ + fui (__builtin_complex (-0.5, 0.)); /* { dg-warning "float-conversion" } */ +} + +/* Check implicit narrowing conversion of constant complex values to. */ +void +const_complex_narrowing (void) +{ + ffloatc (__builtin_complex (-100., 100.)); + + ffloatc (__builtin_complex (MAX_FLOAT_PLUS, 0.)); /* { dg-warning "float-conversion" } */ + ffloatc (__builtin_complex (0., MAX_FLOAT_PLUS)); /* { dg-warning "float-conversion" } */ + ffloatc (__builtin_complex (MAX_FLOAT_PLUS, MAX_FLOAT_PLUS)); /* { dg-warning "float-conversion" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-complex-gnu.c b/SingleSource/Regression/C/gcc-dg/Wconversion-complex-gnu.c new file mode 100644 index 0000000000..d4583508d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-complex-gnu.c @@ -0,0 +1,127 @@ +/* PR c/48956: Test for diagnostics for implicit conversions involving complex + types. See also Wconversion-complex-c99.c. + + These tests cover integer complex values (which are GNU extensions). */ + +/* { dg-do compile } */ +/* { dg-skip-if "doubles are floats,ints are 16bits" { "avr-*-*" } } */ +/* { dg-options " -std=gnu99 -Wconversion " } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-require-effective-target double64plus } */ + +#include + +void fsi (int); +void fui (unsigned); +void ffloat (float); +int vsi; +unsigned int vui; +float vfloat; + +void fsic (int _Complex); +void fuic (unsigned _Complex); +void ffloatc (float _Complex); +int _Complex vsic; +unsigned _Complex vuic; +float _Complex vfloatc; + +/* Check implicit conversions of float complex-domain values to integer + complex-domain types. */ +void +var_float_to_int (void) +{ + double _Complex doublec = 0.; + + fsic (doublec); /* { dg-warning "conversion" } */ + fuic (doublec); /* { dg-warning "conversion" } */ + + vsic = doublec; /* { dg-warning "conversion" } */ + vuic = doublec; /* { dg-warning "conversion" } */ +} + +/* Check implicit conversions of integer complex-domain values to integer + real-domain types. */ +void +var_complex_to_real (void) +{ + int _Complex ic = 0; + unsigned _Complex uc = 0; + unsigned long long _Complex ullc = 0; + + fsic (ic); + fuic (uc); + vsic = ic; + vuic = uc; + + fsi (ic); /* { dg-warning "conversion" } */ + vsi = ic; /* { dg-warning "conversion" } */ + fui (uc); /* { dg-warning "conversion" } */ + vui = uc; /* { dg-warning "conversion" } */ + + fuic (ullc); /* { dg-warning "conversion" } */ + vuic = ullc; /* { dg-warning "conversion" } */ + + fui (ic); /* { dg-warning "conversion" } */ + vui = ic; /* { dg-warning "conversion" } */ +} + +/* Check implicit conversions of float complex-domain constants to integer + types. */ +void +const_float_to_int (void) +{ + fsic (1. - 1.i); + fuic (1. + 1.i); + vsic = 1. - 1.i; + vuic = 1. + 1.i; + + fsic (0.5 + 0.i); /* { dg-warning "conversion" } */ + vsic = 0.5 + 0.i; /* { dg-warning "conversion" } */ + fuic (0.5 + 0.i); /* { dg-warning "conversion" } */ +} + +/* Check implicit conversions of integer complex-domain constants to integer + types. */ +void +const_complex_int_to_real_int (void) +{ + fsi (-1 + 0i); + fui (1 + 0i); + vsi = -1 + 0i; + vui = 1 + 0i; + + fui (1 + 1i); /* { dg-warning "conversion" } */ + vui = 1 + 1i; /* { dg-warning "conversion" } */ + + fui (UINT_MAX + 1ull + 0i); /* { dg-warning "conversion" } */ + vui = UINT_MAX + 1ull + 0i; /* { dg-warning "conversion" } */ + + ffloat (UINT_MAX + 0i); /* { dg-warning "conversion" } */ + vfloat = UINT_MAX + 0i; /* { dg-warning "conversion" } */ +} + +void +const_complex_int_narrowing (void) +{ + fsic (1 - 1i); + fuic (1 + 1i); + vsic = 1 - 1i; + vuic = 1 + 1i; + + fuic (UINT_MAX + 1ull + 1i); /* { dg-warning "conversion" } */ + fuic ((UINT_MAX + 1ull) * 1i); /* { dg-warning "conversion" } */ + fuic ((UINT_MAX + 1ull) + (UINT_MAX + 1ull) * 1i); /* { dg-warning "conversion" } */ + + vuic = (UINT_MAX + 1ull) * 1i; /* { dg-warning "conversion" } */ + vuic = (UINT_MAX + 1ull) + 1i; /* { dg-warning "conversion" } */ + vuic = (UINT_MAX + 1ull) + (UINT_MAX + 1ull) * 1i; /* { dg-warning "conversion" } */ + + ffloatc (UINT_MAX * 1i); /* { dg-warning "conversion" } */ + ffloatc (UINT_MAX + 1i); /* { dg-warning "conversion" } */ + ffloatc (UINT_MAX + UINT_MAX * 1i); /* { dg-warning "conversion" } */ + + vfloatc = UINT_MAX * 1i; /* { dg-warning "conversion" } */ + vfloatc = UINT_MAX + 1i; /* { dg-warning "conversion" } */ + vfloatc = UINT_MAX + UINT_MAX * 1i; /* { dg-warning "conversion" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-integer-no-sign.c b/SingleSource/Regression/C/gcc-dg/Wconversion-integer-no-sign.c new file mode 100644 index 0000000000..c17d502d8f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-integer-no-sign.c @@ -0,0 +1,96 @@ +/* Test for diagnostics for implicit conversions between integer types + These tests come from gcc/testsuite/gcc.dg/overflow-warn-2.c */ + +/* { dg-do compile } */ +/* { dg-options "-std=c99 -fsigned-char -Wconversion -Wno-sign-conversion" } */ + +#include + +void fsc (signed char sc); +void fuc (unsigned char uc); +unsigned fui (unsigned int ui); +void fsi (signed int ui); + +void h (int x) +{ + unsigned int ui = 3; + int si = 3; + unsigned char uc = 3; + signed char sc = 3; + + uc = ui; /* { dg-warning "conversion" } */ + uc = si; /* { dg-warning "conversion" } */ + sc = ui; /* { dg-warning "conversion" } */ + sc = si; /* { dg-warning "conversion" } */ + fuc (ui); /* { dg-warning "conversion" } */ + fuc (si); /* { dg-warning "conversion" } */ + fsc (ui); /* { dg-warning "conversion" } */ + fsc (si); /* { dg-warning "conversion" } */ + + fsi (si); + fui (ui); + fsi (uc); + si = uc; + fui (uc); + ui = uc; + fui ('A'); + ui = 'A'; + fsi ('A'); + si = 'A'; + fuc ('A'); + uc = 'A'; + + uc = x ? 1U : -1; /* { dg-warning "conversion" } */ + uc = x ? SCHAR_MIN : 1U; /* { dg-warning "conversion" } */ + uc = x ? 1 : -1; /* Warned by -Wsign-conversion. */ + uc = x ? SCHAR_MIN : 1; /* Warned by -Wsign-conversion. */ + ui = x ? 1U : -1; /* Warned by -Wsign-conversion. */ + ui = x ? INT_MIN : 1U; /* Warned by -Wsign-conversion. */ + ui = ui ? SCHAR_MIN : 1U; /* Warned by -Wsign-conversion. */ + ui = 1U * -1; /* Warned by -Wsign-conversion. */ + ui = ui + INT_MIN; /* Warned by -Wsign-conversion. */ + ui = x ? 1 : -1; /* Warned by -Wsign-conversion. */ + ui = ui ? SCHAR_MIN : 1; /* Warned by -Wsign-conversion. */ + + fuc (-1); /* Warned by -Wsign-conversion. */ + uc = -1; /* Warned by -Wsign-conversion. */ + fui (-1); /* Warned by -Wsign-conversion. */ + ui = -1; /* Warned by -Wsign-conversion. */ + fuc ('\xa0'); /* Warned by -Wsign-conversion. */ + uc = '\xa0'; /* Warned by -Wsign-conversion. */ + fui ('\xa0'); /* Warned by -Wsign-conversion. */ + ui = '\xa0'; /* Warned by -Wsign-conversion. */ + fsi ((unsigned) INT_MAX + 1U); /* Warned by -Wsign-conversion. */ + si = (unsigned) INT_MAX + 1U; /* Warned by -Wsign-conversion. */ + + + fsi (UINT_MAX - 1); /* Warned by -Wsign-conversion. */ + si = UINT_MAX - 1; /* Warned by -Wsign-conversion. */ + fsi (UINT_MAX - 1U); /* Warned by -Wsign-conversion. */ + si = UINT_MAX - 1U; /* Warned by -Wsign-conversion. */ + fsi (UINT_MAX/3U); + si = UINT_MAX/3U; + fsi (UINT_MAX/3); + si = UINT_MAX/3; + fui (UINT_MAX - 1); + ui = UINT_MAX - 1; + + uc = (unsigned char) -1; + ui = -1 * (1 * -1); + ui = (unsigned) -1; + + fsc (uc); /* Warned by -Wsign-conversion. */ + sc = uc; /* Warned by -Wsign-conversion. */ + fuc (sc); /* Warned by -Wsign-conversion. */ + uc = sc; /* Warned by -Wsign-conversion. */ + fsi (ui); /* Warned by -Wsign-conversion. */ + si = ui; /* Warned by -Wsign-conversion. */ + fui (si); /* Warned by -Wsign-conversion. */ + ui = si; /* Warned by -Wsign-conversion. */ + fui (sc); /* Warned by -Wsign-conversion. */ + ui = sc; /* Warned by -Wsign-conversion. */ +} + +unsigned fui (unsigned a) { return a + -1; } /* Warned by -Wsign-conversion. */ + + diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-integer.c b/SingleSource/Regression/C/gcc-dg/Wconversion-integer.c new file mode 100644 index 0000000000..cf7745cf83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-integer.c @@ -0,0 +1,98 @@ +/* Test for diagnostics for implicit conversions between integer types + These tests come from gcc/testsuite/gcc.dg/overflow-warn-2.c */ + +/* { dg-do compile } */ +/* { dg-options "-std=c99 -fsigned-char -Wconversion" } */ + +#include + +void fsc (signed char sc); +void fuc (unsigned char uc); +unsigned fui (unsigned int ui); +void fsi (signed int ui); + +void h (int x) +{ + unsigned int ui = 3; + int si = 3; + unsigned char uc = 3; + signed char sc = 3; + + uc = ui; /* { dg-warning "conversion" } */ + uc = si; /* { dg-warning "conversion" } */ + sc = ui; /* { dg-warning "conversion" } */ + sc = si; /* { dg-warning "conversion" } */ + fuc (ui); /* { dg-warning "conversion" } */ + fuc (si); /* { dg-warning "conversion" } */ + fsc (ui); /* { dg-warning "conversion" } */ + fsc (si); /* { dg-warning "conversion" } */ + + fsi (si); + fui (ui); + fsi (uc); + si = uc; + fui (uc); + ui = uc; + fui ('A'); + ui = 'A'; + fsi ('A'); + si = 'A'; + fuc ('A'); + uc = 'A'; + + uc = x ? 1U : -1; /* { dg-warning "conversion from .unsigned int. to .unsigned char." } */ + /* { dg-warning "unsigned conversion" "implicit" { target *-*-* } .-1 } */ + uc = x ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion" } */ + /* { dg-warning "conversion from .unsigned int. to .unsigned char." "implicit" { target *-*-* } .-1 } */ + uc = x ? 1 : -1; /* { dg-warning "signed conversion" } */ + uc = x ? SCHAR_MIN : 1; /* { dg-warning "signed conversion" } */ + ui = x ? 1U : -1; /* { dg-warning "signed conversion" } */ + ui = x ? INT_MIN : 1U; /* { dg-warning "signed conversion" } */ + ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "signed conversion" } */ + ui = 1U * -1; /* { dg-warning "signed conversion" } */ + ui = ui + INT_MIN; /* { dg-warning "signed conversion" } */ + ui = x ? 1 : -1; /* { dg-warning "signed conversion" } */ + ui = ui ? SCHAR_MIN : 1; /* { dg-warning "signed conversion" } */ + + fuc (-1); /* { dg-warning "signed conversion" } */ + uc = -1; /* { dg-warning "signed conversion" } */ + fui (-1); /* { dg-warning "signed conversion" } */ + ui = -1; /* { dg-warning "signed conversion" } */ + fuc ('\xa0'); /* { dg-warning "signed conversion" } */ + uc = '\xa0'; /* { dg-warning "signed conversion" } */ + fui ('\xa0');/* { dg-warning "signed conversion" } */ + ui = '\xa0'; /* { dg-warning "signed conversion" } */ + fsi (0x80000000); /* { dg-warning "conversion" } */ + si = 0x80000000; /* { dg-warning "conversion" } */ + + + fsi (UINT_MAX - 1); /* { dg-warning "conversion" } */ + si = UINT_MAX - 1; /* { dg-warning "conversion" } */ + fsi (UINT_MAX - 1U); /* { dg-warning "conversion" } */ + si = UINT_MAX - 1U; /* { dg-warning "conversion" } */ + fsi (UINT_MAX/3U); + si = UINT_MAX/3U; + fsi (UINT_MAX/3); + si = UINT_MAX/3; + fui (UINT_MAX - 1); + ui = UINT_MAX - 1; + + uc = (unsigned char) -1; + ui = -1 * (1 * -1); + ui = (unsigned) -1; + + fsc (uc); /* { dg-warning "conversion" } */ + sc = uc; /* { dg-warning "conversion" } */ + fuc (sc); /* { dg-warning "conversion" } */ + uc = sc; /* { dg-warning "conversion" } */ + fsi (ui); /* { dg-warning "conversion" } */ + si = ui; /* { dg-warning "conversion" } */ + fui (si); /* { dg-warning "conversion" } */ + ui = si; /* { dg-warning "conversion" } */ + fui (sc); /* { dg-warning "conversion" } */ + ui = sc; /* { dg-warning "conversion" } */ +} + +unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "signed conversion" } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-pr34389.c b/SingleSource/Regression/C/gcc-dg/Wconversion-pr34389.c new file mode 100644 index 0000000000..1a43368026 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-pr34389.c @@ -0,0 +1,55 @@ +/* PR 34389 */ +/* { dg-do compile } */ +/* { dg-options "-Wconversion -Wsign-conversion" } */ +/* { dg-require-effective-target int32plus } */ + +short mask1(short x) +{ + short y = 0x7fff; + return x & y; +} + +short mask2(short ssx) +{ + short ssy; + short ssz; + + ssz = ((int)ssx) & 0x7fff; + ssy = ((int)ssx) | 0x7fff; + ssz = ((int)ssx) ^ 0x7fff; + return ssx & 0x7fff; +} + +short mask3(int si, unsigned int ui) +{ + short ss; + unsigned short us; + + ss = si & 0x7fff; + ss = si & 0xAAAA; /* { dg-warning "conversion" } */ + ss = ui & 0x7fff; + ss = ui & 0xAAAA; /* { dg-warning "conversion" } */ + + us = si & 0x7fff; + us = si & 0xAAAA; /* { dg-warning "conversion" } */ + us = ui & 0x7fff; + us = ui & 0xAAAA; /* 0xAAAA is zero-extended, thus it masks the + upper bits of 'ui' making it fit in 'us'. */ + + return ss; +} + +short mask4(int x, int y) +{ + return x & y; /* { dg-warning "conversion" } */ +} + +short mask5(int x) +{ + return x & -1; /* { dg-warning "conversion" } */ +} + +short mask6(short x) +{ + return x & -1; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wconversion-real-integer.c b/SingleSource/Regression/C/gcc-dg/Wconversion-real-integer.c new file mode 100644 index 0000000000..92e6987d9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wconversion-real-integer.c @@ -0,0 +1,113 @@ +/* Test for diagnostics for Wconversion between floating-point and + integers. */ + +/* { dg-do compile } */ +/* { dg-skip-if "doubles are floats,ints are 16bits" { "avr-*-*" } } */ +/* { dg-options "-std=c99 -Wconversion" } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-require-effective-target double64plus } */ +#include + +void fsi (signed int x); +void fui (unsigned int x); +void ffloat (float x); +void fdouble (double x); + +float vfloat; +double vdouble; + +void h (void) +{ + unsigned int ui = 3; + int si = 3; + unsigned char uc = 3; + signed char sc = 3; + float f = 3; + double d = 3; + + fsi (3.1f); /* { dg-warning "conversion" } */ + si = 3.1f; /* { dg-warning "conversion" } */ + fsi (3.1); /* { dg-warning "conversion" } */ + si = 3.1; /* { dg-warning "conversion" } */ + fsi (d); /* { dg-warning "conversion" } */ + si = d; /* { dg-warning "conversion" } */ + fui (-1.0); /* { dg-warning "overflow" } */ + ui = -1.0; /* { dg-warning "overflow" } */ + ffloat (INT_MAX); /* { dg-warning "conversion" } */ + vfloat = INT_MAX; /* { dg-warning "conversion" } */ + ffloat (16777217); /* { dg-warning "conversion" } */ + vfloat = 16777217; /* { dg-warning "conversion" } */ + ffloat (si); /* { dg-warning "conversion" } */ + vfloat = si; /* { dg-warning "conversion" } */ + ffloat (ui); /* { dg-warning "conversion" } */ + vfloat = ui; /* { dg-warning "conversion" } */ + + fsi (3); + si = 3; + fsi (3.0f); + si = 3.0f; + fsi (3.0); + si = 3.0; + fsi (16777217.0f); + si = 16777217.0f; + fsi ((int) 3.1); + si = (int) 3.1; + ffloat (3U); + vfloat = 3U; + ffloat (3); + vfloat = 3; + ffloat (INT_MIN); + vfloat = INT_MIN; + ffloat (uc); + vfloat = uc; + ffloat (sc); + vfloat = sc; + + fdouble (UINT_MAX); + vdouble = UINT_MAX; + fdouble (ui); + vdouble = ui; + fdouble (si); + vdouble = si; +} + + +void fss (signed short x); +void fus (unsigned short x); +void fsc (signed char x); +void fuc (unsigned char x); + +void h2 (void) +{ + unsigned short int us; + short int ss; + unsigned char uc; + signed char sc; + + fss (4294967294.0); /* { dg-warning "conversion" } */ + ss = 4294967294.0; /* { dg-warning "conversion" } */ + fss (-4294967294.0); /* { dg-warning "conversion" } */ + ss = -4294967294.0; /* { dg-warning "conversion" } */ + fus (4294967294.0); /* { dg-warning "conversion" } */ + us = 4294967294.0; /* { dg-warning "conversion" } */ + fus (-4294967294.0); /* { dg-warning "conversion" } */ + us = -4294967294.0; /* { dg-warning "conversion" } */ + + fsc (500.0); /* { dg-warning "conversion" } */ + sc = 500.0; /* { dg-warning "conversion" } */ + fsc (-500.0); /* { dg-warning "conversion" } */ + sc = -500.0; /* { dg-warning "conversion" } */ + fuc (500.0); /* { dg-warning "conversion" } */ + uc = 500.0; /* { dg-warning "conversion" } */ + fuc (-500.0); /* { dg-warning "conversion" } */ + uc = -500.0; /* { dg-warning "conversion" } */ + + fss (500.0); + ss = 500.0; + fss (-500.0); + ss = -500.0; + fus (500.0); + us = 500.0; + fus (-500.0); /* { dg-warning "conversion" } */ + us = -500.0; /* { dg-warning "conversion" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-1.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-1.c new file mode 100644 index 0000000000..91500421e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-1.c @@ -0,0 +1,11 @@ +/* PR c/21759 */ +/* { dg-options "-Wc++-compat" } */ + +int +main(void) +{ + void *p = 0; + int *q = p; /* { dg-warning "not permitted" } */ + double* t = (void *)0; + return p != q; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-10.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-10.c new file mode 100644 index 0000000000..0f1d037bfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-10.c @@ -0,0 +1,73 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +struct s1 { int f; }; +typedef int s2; +void +f1 () +{ + typedef int s1; + struct s2 { int f; }; +} + +struct s3 { int f; }; +typedef struct s3 s3; + +typedef struct s4 s4; +struct s4 { int f; }; + +struct s5 { int f; }; /* { dg-message "note: originally defined here" } */ +typedef int s5; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + +typedef int s6; /* { dg-message "note: originally defined here" } */ +struct s6 { int f; }; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + +void +f2 () +{ + struct s7 { int f; }; /* { dg-message "note: originally defined here" } */ + typedef int s7; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + + typedef int s8; /* { dg-message "note: originally defined here" } */ + struct s8 { int f; }; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + + struct s9 { int f; }; + { typedef int s9; } + + typedef int s10; + { struct s10 { int f; }; } +} + +enum e1 { A }; +typedef int e2; +void +f3 () +{ + typedef int e1; + enum e2 { B }; +} + +enum e3 { C }; +typedef enum e3 e3; + +enum e5 { E }; /* { dg-message "note: originally defined here" } */ +typedef int e5; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + +typedef int e6; /* { dg-message "note: originally defined here" } */ +enum e6 { F }; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + +void +f4 () +{ + enum e7 { G }; /* { dg-message "note: originally defined here" } */ + typedef int e7; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + + typedef int e8; /* { dg-message "note: originally defined here" } */ + enum e8 { H }; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + + enum e9 { I }; + { typedef int e9; } + + typedef int e10; + { enum e10 { J }; } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-11.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-11.c new file mode 100644 index 0000000000..8818338ad5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-11.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +#include + +enum E { A }; + +extern void f2 (int); +void +f1 (int n, ...) +{ + va_list ap; + + va_start (ap, n); + f2 (va_arg (ap, int)); + f2 (va_arg (ap, _Bool)); /* { dg-warning "promoted" } */ + f2 (va_arg (ap, enum E)); /* { dg-warning "promoted" } */ +} + +/* Match extra informative notes. */ +/* { dg-message "note:" "expected" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-12.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-12.c new file mode 100644 index 0000000000..9061ee67cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-12.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-short-enums -Wc++-compat" } */ + +enum E { A }; + +enum E v; +unsigned int *p = &v; /* { dg-warning "incompatible in C\[+\]\[+\]" } */ + +void foo(unsigned int); +void (*pfn)(enum E) = &foo; /* { dg-warning "incompatible in C\[+\]\[+\]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-13.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-13.c new file mode 100644 index 0000000000..1882396446 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-13.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +int and; /* { dg-warning "operator" } */ +int and_eq; /* { dg-warning "operator" } */ +int bitand; /* { dg-warning "operator" } */ +int bitor; /* { dg-warning "operator" } */ +int compl; /* { dg-warning "operator" } */ +int not; /* { dg-warning "operator" } */ +int not_eq; /* { dg-warning "operator" } */ +int or; /* { dg-warning "operator" } */ +int or_eq; /* { dg-warning "operator" } */ +int xor; /* { dg-warning "operator" } */ +int xor_eq; /* { dg-warning "operator" } */ + +#define M1 and /* { dg-warning "operator" } */ +#define M2 and_eq /* { dg-warning "operator" } */ +#define M3 bitand /* { dg-warning "operator" } */ +#define M4 bitor /* { dg-warning "operator" } */ +#define M5 compl /* { dg-warning "operator" } */ +#define M6 not /* { dg-warning "operator" } */ +#define M7 not_eq /* { dg-warning "operator" } */ +#define M8 or /* { dg-warning "operator" } */ +#define M9 or_eq /* { dg-warning "operator" } */ +#define M10 xor /* { dg-warning "operator" } */ +#define M11 xor_eq /* { dg-warning "operator" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-14.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-14.c new file mode 100644 index 0000000000..23783711be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-14.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +char a1[] = "a"; +char a2[1] = "a"; /* { dg-warning "C\[+\]\[+\]" } */ +char a3[2] = "a"; diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-15.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-15.c new file mode 100644 index 0000000000..82a76ec4d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-15.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +typedef int myint1; +typedef int myint2; +typedef int myint3; +struct s1 +{ + myint1 myint1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + myint2 *myint2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + int myint3; + struct s2 + { + myint3 f2; /* { dg-warning "C\[+\]\[+\]" } */ + } f1; +}; + +struct s3 +{ + int myint1; + struct s4 + { + int myint1; + } f1; + struct s5 + { + int myint1; + struct s6 + { + myint1 f4; /* { dg-warning "C\[+\]\[+\]" } */ + } f3; + } f2; +}; diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-16.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-16.c new file mode 100644 index 0000000000..51b503bf60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-16.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +struct { int f1; } g1; /* { dg-warning "C\[+\]\[+\]" } */ +static struct { int f2; } g2; +struct s { int f3; } g3; +union { int f4; } g4; /* { dg-warning "C\[+\]\[+\]" } */ +static union { int f5; } g5; +union u { int f6; } g6; +enum { A } g7; /* { dg-warning "C\[+\]\[+\]" } */ +static enum { B } g8; +enum E { C } g9; diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-17.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-17.c new file mode 100644 index 0000000000..78760d641f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-17.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +const int v1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +const char * const v2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +struct s { int f1; int f2; }; +const struct s v3; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +const int v4 = 1; +const char * const v5 = 0; +const struct s v6 = { 0, 0 }; +const struct s v7 = { 0 }; +void +f() +{ + const int v11; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + const char * const v12; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + const struct s v13; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + const int v14 = 1; + const char * const v15 = 0; + const struct s v16 = { 0, 0 }; + const struct s v17 = { 0 }; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-18.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-18.c new file mode 100644 index 0000000000..9ae2d770a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-18.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +enum E1 { A }; +enum E2 { B }; +int +f1 (int i) +{ + return (int) (i ? A : B); /* { dg-warning "invalid in C\[+\]\[+\]" } */ +} +extern enum E1 f2(); +int +f3 (int i) +{ + return (int) (i ? f2 () : B); /* { dg-warning "invalid in C\[+\]\[+\]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-19.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-19.c new file mode 100644 index 0000000000..120ccf5c07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-19.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +int v1; /* { dg-message "previous declaration" } */ +int v1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +int v2; /* { dg-message "previous declaration" } */ +int v2 = 1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +extern int v3; +int v3; /* { dg-message "previous declaration" } */ +int v3 = 1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +extern int v4; +int v4 = 1; +static int v5; /* { dg-message "previous declaration" } */ +static int v5; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +static int v6; /* { dg-message "previous declaration" } */ +static int v6 = 1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +int v7; +extern int v7; +int v8 = 1; +extern int v8; diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-2.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-2.c new file mode 100644 index 0000000000..4578bece10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-2.c @@ -0,0 +1,38 @@ +/* { dg-options "-Wc++-compat" } */ + +_Bool foo; /* This is okay. */ +int bool; /* { dg-warning "5:keyword" } */ +int catch; /* { dg-warning "5:keyword" } */ +int char16_t; /* { dg-warning "5:keyword" } */ +int char32_t; /* { dg-warning "5:keyword" } */ +int class; /* { dg-warning "5:keyword" } */ +int const_cast; /* { dg-warning "5:keyword" } */ +int constexpr; /* { dg-warning "5:keyword" } */ +int decltype; /* { dg-warning "5:keyword" } */ +int delete; /* { dg-warning "5:keyword" } */ +int dynamic_cast; /* { dg-warning "5:keyword" } */ +int explicit; /* { dg-warning "5:keyword" } */ +int export; /* { dg-warning "5:keyword" } */ +int false; /* { dg-warning "5:keyword" } */ +int friend; /* { dg-warning "5:keyword" } */ +int mutable; /* { dg-warning "5:keyword" } */ +int namespace; /* { dg-warning "5:keyword" } */ +int new; /* { dg-warning "5:keyword" } */ +int nullptr; /* { dg-warning "5:keyword" } */ +int operator; /* { dg-warning "5:keyword" } */ +int private; /* { dg-warning "5:keyword" } */ +int protected; /* { dg-warning "5:keyword" } */ +int public; /* { dg-warning "5:keyword" } */ +int reinterpret_cast; /* { dg-warning "5:keyword" } */ +int static_assert; /* { dg-warning "5:keyword" } */ +int static_cast; /* { dg-warning "5:keyword" } */ +int template; /* { dg-warning "5:keyword" } */ +int this; /* { dg-warning "5:keyword" } */ +int throw; /* { dg-warning "5:keyword" } */ +int true; /* { dg-warning "5:keyword" } */ +int try; /* { dg-warning "5:keyword" } */ +int typename; /* { dg-warning "5:keyword" } */ +int typeid; /* { dg-warning "5:keyword" } */ +int using; /* { dg-warning "5:keyword" } */ +int virtual; /* { dg-warning "5:keyword" } */ +int wchar_t; diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-20.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-20.c new file mode 100644 index 0000000000..af774acc81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-20.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +typedef struct s { const int i; } s; /* { dg-message "should be initialized" } */ +union u {const int a; double b;}; /* { dg-message "should be initialized" } */ +struct ts { int a; s v;}; +struct ta { int a; s v[2];}; + +void f () +{ + s v1; /* { dg-warning "uninitialized const member in" } */ + s va[2]; /* { dg-warning "uninitialized const member in" } */ + union u v2; /* { dg-warning "uninitialized const member in" } */ + struct ts v3; /* { dg-warning "uninitialized const member in" } */ + struct ta ta[2]; /* { dg-warning "uninitialized const member in" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-21.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-21.c new file mode 100644 index 0000000000..183f0f1798 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-21.c @@ -0,0 +1,25 @@ +/* PR c/44772 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +typedef enum { E1, E2 } E; + +typedef struct +{ + E e; + union + { + int i; + char *c; + }; /* { dg-bogus "as both field and typedef name" } */ +} S; + +S s; + +typedef int T; + +struct U +{ + T t; + union { int i; }; /* { dg-bogus "as both field and typedef name" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-22.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-22.c new file mode 100644 index 0000000000..60b05ca93f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-22.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +struct A {}; /* { dg-warning "empty struct has size 0 in C" } */ +union B {}; /* { dg-warning "empty union has size 0 in C" } */ +struct C { struct D {}; int x; }; /* { dg-warning "empty struct has size 0 in C|declaration does not declare anything" } */ +struct E { union F {}; int x; }; /* { dg-warning "empty union has size 0 in C|declaration does not declare anything" } */ +union G { union H {}; int x; }; /* { dg-warning "empty union has size 0 in C|declaration does not declare anything" } */ +union I { struct J {}; int x; }; /* { dg-warning "empty struct has size 0 in C|declaration does not declare anything" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-3.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-3.c new file mode 100644 index 0000000000..306167314e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-3.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +enum E1 { A, B, C }; +enum E2 { D, E, F }; +extern void f2 (enum E1); + +void +f1 () +{ + int a = A; + enum E1 e1; + enum E2 e2; + + f2 (0); /* { dg-warning "invalid in C\[+\]\[+\]" } */ + f2 (A); + f2 (D); /* { dg-warning "invalid in C\[+\]\[+\]" } */ + f2 (a); /* { dg-warning "invalid in C\[+\]\[+\]" } */ + f2 (e1); + f2 (e2); /* { dg-warning "invalid in C\[+\]\[+\]" } */ + f2 ((A)); + f2 (a ? A : B); + f2 ((enum E1) 0); + f2 ((enum E1) D); + f2 ((enum E1) a); + f2 ((enum E1) e2); +} + +struct s1 { enum E1 e1 : 3; }; +struct s2 { enum E2 e2 : 3; }; + +void +f3 (struct s1 sv1, struct s2 sv2) +{ + f2 (sv1.e1); + f2 (sv2.e2); /* { dg-warning "invalid in C\[+\]\[+\]" } */ +} + +void +f4 (struct s1 *pv1, struct s2 *pv2) +{ + f2 (pv1->e1); + f2 (pv2->e2); /* { dg-warning "invalid in C\[+\]\[+\]" } */ +} + +/* Match all extra informative notes. */ +/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-4.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-4.c new file mode 100644 index 0000000000..a294ffe0b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-4.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +enum E1 { A, B, C }; +enum E2 { D, E, F }; + +enum E1 g1; +enum E2 g2; + +void +f1 () +{ + int a; + int d; + enum E1 e1; + enum E2 e2; + a = A; + a = !B; + d = E; + e1 = A; + e1 = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + e1 = 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + e1 = (enum E1) 0; + e1 = (enum E2) 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + e1 = e2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + e1 = g1; + e1 = g2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + e2 = A; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + e2 = D; +} + +struct s { enum E1 e1 : 3; }; + +void +f2 (struct s sv) +{ + sv.e1 = A; + sv.e1 = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + g1 = sv.e1; + g2 = sv.e1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +} + +void +f3 (struct s *pv) +{ + pv->e1 = A; + pv->e1 = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + g1 = pv->e1; + g2 = pv->e1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-5.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-5.c new file mode 100644 index 0000000000..d7b2f96a6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-5.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +enum E1 { A, B, C }; +enum E2 { D, E, F }; + +int f1() { return A; } + +struct s { enum E1 e1 : 3; enum E2 e2 : 4; }; + +enum E1 +f2 (int i, struct s sv, struct s *pv) +{ + int a; + enum E1 e1 = B; + enum E2 e2 = E; + switch (i) + { + case 0: + return A; + case 1: + return D; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + case 2: + return 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + case 3: + return (enum E1) 1; + case 4: + return (enum E2) 2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + case 5: + return e1; + case 6: + return e2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + case 7: + return pv->e1; + case 8: + return sv.e1; + case 9: + return pv->e2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + case 10: + return sv.e2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + case 11: + return 1, A; + default: + return C; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-6.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-6.c new file mode 100644 index 0000000000..eee6768f0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-6.c @@ -0,0 +1,112 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +enum E1 { A, B, C }; +enum E2 { D, E, F }; + +enum E1 v1a = A; +enum E1 v1b = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +enum E1 v1c = 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +enum E1 v1d = (enum E1) 0; +enum E1 v1e = (enum E2) 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + +enum E2 v2a; + +enum E1 a1[] = +{ + A, + D, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + 0, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + (enum E1) 0, + (enum E2) 0, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + A +}; + +struct s1 +{ + enum E1 e1; +}; + +struct s1 a2[] = +{ + { A }, + { D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { (enum E1) 0 }, + { (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { A } +}; + +struct s1 a3[] = +{ + [ 5 ] = { .e1 = A }, + [ 4 ] = { .e1 = D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + [ 3 ] = { .e1 = 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + [ 2 ] = { .e1 = (enum E1) 0 }, + [ 1 ] = { .e1 = (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + [ 0 ] = { .e1 = A } +}; + +struct s2 +{ + enum E1 e1 : 3; +}; + +struct s2 a4[] = +{ + { A }, + { D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { (enum E1) 0 }, + { (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { A } +}; + +struct s2 a5[] = +{ + [ 5 ] = { .e1 = A }, + [ 4 ] = { .e1 = D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + [ 3 ] = { .e1 = 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + [ 2 ] = { .e1 = (enum E1) 0 }, + [ 1 ] = { .e1 = (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + [ 0 ] = { .e1 = A } +}; + +void +f(enum E1 e1, enum E2 e2, struct s1 vs1, struct s1 *vp1) +{ + enum E1 va1[] = { + e1, + e2, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + v1a, + v2a, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + vs1.e1, + vp1->e1, + e1 ? e1 : e1, + (0, e1) + }; + + struct s1 va2[] = { + { e1 }, + { e2 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { v1a }, + { v2a }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { vs1.e1 }, + { vp1->e1 }, + { e1 ? e1 : e1 }, + { (0, e1) } + }; + + struct s2 va3[] = { + { e1 }, + { e2 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { v1a }, + { v2a }, /* { dg-warning "invalid in C\[+\]\[+\]" } */ + { vs1.e1 }, + { vp1->e1 }, + { e1 ? e1 : e1 }, + { (0, e1) } + }; +} + +/* Match all extra informative notes. */ +/* { dg-message "near initialization for" "expected" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-7.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-7.c new file mode 100644 index 0000000000..bccbd1107b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-7.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +struct s1 +{ + enum e1 /* { dg-message "note: enum type defined here" } */ + { + A, /* { dg-message "note: enum constant defined here" } */ + B + } f1; + struct s2 /* { dg-message "note: struct defined here" } */ + { + struct s3 /* { dg-message "note: struct defined here" } */ + { + enum e1 f3; + struct s1 *p1; + struct s2 *p2; + struct s3 *p3; + } f2; + union u1 /* { dg-message "note: union defined here" } */ + { + int f4; + } f5; + struct s3 f6; + } f7; + struct s2 f8; + enum e1 f9; +}; + +struct s1 v1; +enum e1 v2; /* { dg-warning "not visible in C\[+\]\[+\]" } */ +struct s2 v3; /* { dg-warning "not visible in C\[+\]\[+\]" } */ +struct s3 v4; /* { dg-warning "not visible in C\[+\]\[+\]" } */ +union u1 v5; /* { dg-warning "not visible in C\[+\]\[+\]" } */ +int i = A; /* { dg-warning "not visible in C\[+\]\[+\]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-8.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-8.c new file mode 100644 index 0000000000..9627dced34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-8.c @@ -0,0 +1,67 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +struct s1 +{ + enum e1 /* { dg-message "note: enum type defined here" } */ + { + A = sizeof (struct s2 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */ + B + } f1; +}; +struct s2 v1; /* Don't issue another warning about s2. */ +enum e1 v2; /* { dg-warning "not visible in C\[+\]\[+\]" } */ + +enum e2 +{ + C = sizeof (struct s3 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */ + D = __alignof__ (struct s4 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */ + E +}; + +struct s3 v3; +int v4 = C; + +enum e3 +{ + F = sizeof (struct t3), /* { dg-bogus "invalid in C\[+\]\[+\]" } */ + /* { dg-error "invalid application of 'sizeof'" "" { target *-*-* } .-1 } */ + G = __alignof__ (struct t4), /* { dg-bogus "invalid in C\[+\]\[+\]" } */ + /* { dg-error "invalid application of '__alignof__'" "" { target *-*-* } .-1 } */ + H +}; + +__typeof__ (struct s5 { int i; }) v5; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +__typeof__ (struct t5) w5; /* { dg-bogus "invalid in C\[+\]\[+\]" } */ + /* { dg-error "storage size of 'w5' isn't known" "" { target *-*-* } .-1 } */ + +int +f1 (struct s1 *p) +{ + return ((struct s6 { int j; } *) p)->j; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +} + +void * +f2 (struct s1 *p) +{ + return ((struct t6 *) p); /* { dg-bogus "invalid in C\[+\]\[+\]" } */ +} + +int +f3 (struct s1 *p) +{ + return (__extension__ (struct s7 { int j; } *)p)->j; +} + +int +f4 () +{ + return (struct s8 { int i; }) { 0 }.i; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +} + +void * +f5 () +{ + return &((struct t8) { }); /* { dg-warning "invalid in C\[+\]\[+\]" } */ + /* { dg-error "invalid use of undefined type" "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wcxx-compat-9.c b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-9.c new file mode 100644 index 0000000000..8a3867c11c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wcxx-compat-9.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +enum e { FIRST, LAST }; + +extern void f2 (enum e); + +void +f1 () +{ + enum e v; + + for (v = FIRST; v < LAST; ++v) /* { dg-warning "invalid in C\[+\]\[+\]" } */ + f2 (v); + for (v = FIRST; v < LAST; v++) /* { dg-warning "invalid in C\[+\]\[+\]" } */ + f2 (v); + for (v = LAST; v > FIRST; --v) /* { dg-warning "invalid in C\[+\]\[+\]" } */ + f2 (v); + for (v = LAST; v > FIRST; v--) /* { dg-warning "invalid in C\[+\]\[+\]" } */ + f2 (v); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-2.c b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-2.c new file mode 100644 index 0000000000..0170263949 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-2.c @@ -0,0 +1,82 @@ +/* Exercise conditional C-only uses of dangling pointers with optimization. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memchr (const void*, int, size_t); +extern char* strchr (const char*, int); + +void sink (void*, ...); + + +void nowarn_compound_literal (int i, int j) +{ + { + int *p = i ? (int[]){ 1, 2, 3 } : (int[]){ 4, 5, 6 }; + sink (p); + } + { + int a[] = { 1, 2, 3 }; + int *q = i ? (int[]){ 4, 5, 6 } : a; + int *p = &q[1]; + sink (p); + } + { + int *p = i ? (int[]){ 1, 2, 3 } : (int[]){ 4, 5, 6 }; + int *q = __builtin_memchr (p, 2, 3 * sizeof *p); + sink (q); + } + { + int a[] = { i, i + 1, i + 2, 3 }; + int *p = i ? (int[]){ j, j + 1, j + 2, 3 } : a; + int *q = __builtin_memchr (p, 3, 4 * sizeof *p); + sink (q); + } +} + + +void warn_maybe_compound_literal (int i, int j) +{ + int a[] = { 1, 2, 3 }, *p; + { + p = i ? (int[]){ 4, 5, 6 } : a; + } + // When the 'p' is optimized away it's not mentioned in the warning. + sink (p); // { dg-warning "dangling pointer \('p' \)?to an unnamed temporary may be used" } +} + + +void warn_maybe_compound_literal_memchr (int i, int j, int x) +{ + int a[] = { 1, 2, 3 }, *p; + { + int *q = i ? (int[]){ 4, 5, 6 } : a; + p = memchr (q, x, 3 * sizeof *q); + } + sink (p); // { dg-warning "dangling pointer 'p' to an unnamed temporary may be used" } +} + + +void warn_maybe_array (int i, int j) +{ + int a[] = { 1, 2, 3 }, *p; + { + int b[] = { 4, 5, 6 }; + p = i ? a : b; + } + // When the 'p' is optimized away it's not mentioned in the warning. + sink (p); // { dg-warning "dangling pointer \('p' \)?to 'b' may be used" } +} + + +void warn_maybe_array_memchr (int i, int j, int x) +{ + int a[] = { 1, 2, 3 }, *p; + { + int b[] = { 4, 5, 6 }; + int *q = i ? a : b; + p = memchr (q, x, 3 * sizeof *q); + } + sink (p); // { dg-warning "dangling pointer 'p' to 'b' may be used" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-3.c b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-3.c new file mode 100644 index 0000000000..01859303fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-3.c @@ -0,0 +1,92 @@ +/* PR tree-optimization/104715 - false dangling pointer with strstr + Vertify that using pointers that have become dangling after they were + passed to and returned from strstr is diagnosed. + { dg-do compile } + { dg-options "-Wall" } */ + +extern char* strstr (const char*, const char*); + +void sink (const void*); + +void nowarn_strstr_static (const char *s) +{ + char *t1; + + { + static const char a[] = "abc"; + t1 = strstr (a, s); + sink (t1); + } + + sink (t1); +} + + +void nowarn_strstr_lit (const char *s) +{ + char *t2; + + { + t2 = strstr ("def", s); + sink (t2); + } + + sink (t2); +} + + +void warn_strstr_comp_lit (const char *s) +{ + char *t3; + + { + const char *a = + (char[]){ '1', '\0' }; // { dg-message "unnamed temporary defined here" } + t3 = strstr (a, s); + sink (t3); + } + + sink (t3); // { dg-warning "using dangling pointer 't3' to an unnamed temporary" } +} + + +void warn_strstr_arg (const char *s) +{ + char *t4; + + { + char a[] = "1"; // { dg-message "'a' declared here" } + t4 = strstr (a, s); + sink (t4); + } + + sink (t4); // { dg-warning "using dangling pointer 't4' to 'a'" } +} + + +void warn_strstr_arg_plus_cst (const char *s) +{ + char *t5; + + { + char a[] = "12"; // { dg-message "'a' declared here" } + t5 = strstr (a + 1, s); + sink (t5); + } + + sink (t5); // { dg-warning "using dangling pointer 't5' to 'a'" } +} + + +void warn_strstr_arg_plus_var (const char *s, int i) +{ + char *t6; + + { + char a[] = "123"; // { dg-message "'a' declared here" } + t6 = strstr (a + i, s); + sink (t6++); + } + + sink (t6); // { dg-warning "using dangling pointer 't6' to 'a'" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-4.c b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-4.c new file mode 100644 index 0000000000..36c8da5113 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-4.c @@ -0,0 +1,22 @@ +/* PR middle-end/104761 - bogus -Wdangling-pointer with cleanup and infinite loop + { dg-do compile } + { dg-options "-O -Wall" } */ + +typedef struct { int i; } S; + +void f (S **); + +int g (int); + +void nowarn (int x) +{ + S s = { 0 }; + + __attribute__((__cleanup__ (f))) S *p = 0; + + if (x) + { + g (s.i); // { dg-bogus "-Wdangling-pointer" } + for ( ; ; ); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-pr106868.c b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-pr106868.c new file mode 100644 index 0000000000..f782a5e07a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer-pr106868.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wdangling-pointer" } */ + +void alloc(void **p); +void false_dangling(char **p) +{ + { + void *q; + alloc(&q); + *p = q; + } + char *a = __builtin_memcpy(*p, "", 1); + *a = 0; /* { dg-bogus "dangling" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdangling-pointer.c b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer.c new file mode 100644 index 0000000000..89e222038d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdangling-pointer.c @@ -0,0 +1,76 @@ +/* Exercise basic C-only cases of -Wdangling-pointer. + { dg-do compile } + { dg-options "-O0 -Wall" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memchr (const void*, int, size_t); +extern char* strchr (const char*, int); + +void sink (const void*, ...); + + +void nowarn_compound_literal (int i) +{ + { + int *p = (int[]){ 1, 2, 3 }; + sink (p); + } + { + int *q = (int[]){ 1, 2, 3 }; + int *p = &q[1]; + sink (p); + } + { + int *p = __builtin_memchr ((int[]){ 1, 2, 3 }, 2, 3 * sizeof *p); + sink (p); + } + { + int *p = __builtin_memchr ((int[]){ i, i + 1 }, 3, 2 * sizeof *p); + sink (p); + } +} + + +void warn_compound_literal (int i) +{ + int *p; + { + p = (int[]){ 1, 2, 3 }; // { dg-message "unnamed temporary" }, + } + sink (p); // { dg-warning "using dangling pointer 'p' to an unnamed temporary" } + + { + int *q = + (int[]){ 1, 2, 3 }; // { dg-message "unnamed temporary" }, + p = &q[1]; + } + sink (p); // { dg-warning "using dangling pointer 'p' to an unnamed temporary" } + { + p = (int*)memchr ( + (int[]){ 1, 2, 3 }, // { dg-message "unnamed temporary" } + 2, 3 * sizeof *p); + } + sink (p); // { dg-warning "using dangling pointer 'p' to an unnamed temporary" } + + { + p = (int*)memchr ( + (int[]){ i, i + 1 },// { dg-message "unnamed temporary" } + 3, 2 * sizeof *p); + } + sink (p); // { dg-warning "using dangling pointer 'p' to an unnamed temporary" } +} + + +void warn_store_compound_literal (int **p) +{ + int *q = (int[]) { 1, 2, 3 }; + p[0] = q; // { dg-warning "storing the address" } +} + +void warn_store_vla (int n, int **p) +{ + int a[n]; + p[1] = &a[1]; // { dg-warning "-Wdangling-pointer" "pr??????" { xfail *-*-* } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-1.c b/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-1.c new file mode 100644 index 0000000000..64a173a9c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-1.c @@ -0,0 +1,26 @@ +/* Test for -Wdeclaration-after-statement emitting warnings when no + standard-specifying option is given. See also c9?-mixdecl-*. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-Wdeclaration-after-statement" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int i = 0; + if (i != 0) + abort (); + i++; + if (i != 1) + abort (); + int j = i; /* { dg-warning "" "declaration after statement" } */ + if (j != 1) + abort (); + struct foo { int i0; } k = { 4 }; /* { dg-warning "" "declaration after statement" } */ + if (k.i0 != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-2.c b/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-2.c new file mode 100644 index 0000000000..ac89bbc268 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-2.c @@ -0,0 +1,26 @@ +/* Test for C99 mixed declarations and code giving warnings, not error with + -Wdeclaration-after-statement. See also c9?-mixdecl-*. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=c99 -pedantic-errors -Wdeclaration-after-statement" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int i = 0; + if (i != 0) + abort (); + i++; + if (i != 1) + abort (); + int j = i; /* { dg-warning "" "declaration-after-statement" } */ + if (j != 1) + abort (); + struct foo { int i0; } k = { 4 }; /* { dg-warning "" "declaration-after-statement" } */ + if (k.i0 != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-3.c b/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-3.c new file mode 100644 index 0000000000..f001edf203 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-3.c @@ -0,0 +1,24 @@ +/* PR 35058: -Werror= works only with some warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic -Werror=declaration-after-statement" } */ +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int i = 0; + if (i != 0) + abort (); + i++; + if (i != 1) + abort (); + int j = i; /* { dg-error "" "declaration-after-statement" } */ + if (j != 1) + abort (); + struct foo { int i0; } k = { 4 }; /* { dg-error "" "declaration-after-statement" } */ + if (k.i0 != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-4.c b/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-4.c new file mode 100644 index 0000000000..c01d8bc6cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdeclaration-after-statement-4.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c90 -pedantic -Wno-declaration-after-statement" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int i = 0; + if (i != 0) + abort (); + i++; + if (i != 1) + abort (); + int j = i; + if (j != 1) + abort (); + struct foo { int i0; } k = { 4 }; + if (k.i0 != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wdesignated-init-2.c b/SingleSource/Regression/C/gcc-dg/Wdesignated-init-2.c new file mode 100644 index 0000000000..d5edfba64c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdesignated-init-2.c @@ -0,0 +1,15 @@ +/* PR c/59855 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +struct S { + int a; + union { + int b; + int c; + }; +} __attribute__((designated_init)); + +struct S s1 = { .a = 0, .b = 0 }; +struct S s2 = { 0, 0 }; /* { dg-warning "(positional|near initialization)" } */ +struct S s3 = { .a = 5, 0 }; /* { dg-warning "(positional|near initialization)" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wdesignated-init.c b/SingleSource/Regression/C/gcc-dg/Wdesignated-init.c new file mode 100644 index 0000000000..b9ca572206 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdesignated-init.c @@ -0,0 +1,107 @@ +/* PR c/59855 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +typedef int vvv __attribute__((designated_init)); /* { dg-error "only valid" } */ + +union U { + int a; + double b; +} __attribute__((designated_init)); /* { dg-error "only valid" } */ + +enum E { ONE, TWO } __attribute__((designated_init)); /* { dg-error "only valid" } */ + +struct Pok { + int x; + int y; +}; + +struct Des { + int x; + int y; +} __attribute__ ((designated_init)); + +struct Des d1 = { 5, 5 }; /* { dg-warning "(positional|near initialization)" } */ +struct Des d2 = { .x = 5, .y = 5 }; +struct Des d3 = { .x = 5, 5 }; /* { dg-warning "(positional|near initialization)" } */ + +struct Des fd1 (void) +{ + return (struct Des) { 5, 5 }; /* { dg-warning "(positional|near initialization)" } */ +} + +struct Des fd2 (void) +{ + return (struct Des) { .x = 5, .y = 5 }; +} + +struct Des fd3 (void) +{ + return (struct Des) { .x = 5, 5 }; /* { dg-warning "(positional|near initialization)" } */ +} + +struct Wrap { + struct Pok p; + struct Des d; +} __attribute__ ((designated_init)); + +struct Wrap w1 = { { 0, 1 }, { 2, 3} }; /* { dg-warning "(positional|near initialization)" } */ +struct Wrap w2 = { .p = { 0, 1 }, { 2, 3} }; /* { dg-warning "(positional|near initialization)" } */ +struct Wrap w3 = { .p = { 0, 1 }, .d = { 2, 3} }; /* { dg-warning "(positional|near initialization)" } */ +struct Wrap w4 = { { 0, 1 }, .d = { 2, 3} }; /* { dg-warning "(positional|near initialization)" } */ +struct Wrap w5 = { .p = { 0, 1 }, .d = { .x = 2, .y = 3} }; + +struct Wrap w6 = { { 0, 1 }, .d.x = 2, .d.y = 3 }; /* { dg-warning "(positional|near initialization)" } */ +struct Wrap w7 = { .p = { 0, 1 }, .d.x = 2, .d.y = 3 }; +struct Wrap w8 = { .p = { 0, 1 }, .d = { 2, 0 }, .d.y = 3 }; /* { dg-warning "(positional|near initialization)" } */ +struct Wrap w9 = { .p = { 0, 1 }, .d = { .x = 2 }, .d.y = 3 }; + +struct Wrap fw1 (void) +{ + return (struct Wrap) { { 0, 1 }, { 2, 3} }; /* { dg-warning "(positional|near initialization)" } */ +}; + +struct Wrap fw2 (void) +{ + return (struct Wrap) { .p = { 0, 1 }, { 2, 3} }; /* { dg-warning "(positional|near initialization)" } */ +} + +struct Wrap fw3 (void) +{ + return (struct Wrap) { .p = { 0, 1 }, .d = { 2, 3} }; /* { dg-warning "(positional|near initialization)" } */ +} + +struct Wrap fw4 (void) +{ + return (struct Wrap) { { 0, 1 }, .d = { 2, 3} }; /* { dg-warning "(positional|near initialization)" } */ +} + +struct Wrap fw5 (void) +{ + return (struct Wrap) { .p = { 0, 1 }, .d = { .x = 2, .y = 3} }; +} + +struct Wrap fw6 (void) +{ + return (struct Wrap) { { 0, 1 }, .d.x = 2, .d.y = 3 }; /* { dg-warning "(positional|near initialization)" } */ +} + +struct Wrap fw7 (void) +{ + return (struct Wrap) { .p = { 0, 1 }, .d.x = 2, .d.y = 3 }; +} + +struct Wrap fw8 (void) +{ + return (struct Wrap) { .p = { 0, 1 }, .d = { 2, 0 }, .d.y = 3 }; /* { dg-warning "(positional|near initialization)" } */ +} + +struct Wrap fw9 (void) +{ + return (struct Wrap) { .p = { 0, 1 }, .d = { .x = 2 }, .d.y = 3 }; +} + +struct Des da[] = { + { .x = 1, .y = 2 }, + { 5, 5 } /* { dg-warning "(positional|near initialization)" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/Wdouble-promotion.c b/SingleSource/Regression/C/gcc-dg/Wdouble-promotion.c new file mode 100644 index 0000000000..d7a61899f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wdouble-promotion.c @@ -0,0 +1,104 @@ +/* { dg-do compile } */ +/* { dg-options "-Wdouble-promotion" } */ + +#include + +/* Some targets do not provide so we define I ourselves. */ +#define I 1.0iF +#define ID ((_Complex double)I) + +float f; +double d; +int i; +long double ld; +_Complex float cf; +_Complex double cd; +_Complex long double cld; +size_t s; + +extern void unprototyped_fn (); +extern void varargs_fn (int, ...); +extern void double_fn (double); +extern float float_fn (void); + +void +usual_arithmetic_conversions(void) +{ + float local_f; + _Complex float local_cf; + + /* Values of type "float" are implicitly converted to "double" or + "long double" due to use in arithmetic with "double" or "long + double" operands. */ + local_f = f + 1.0; /* { dg-warning "implicit" } */ + local_f = f - d; /* { dg-warning "implicit" } */ + local_f = 1.0f * 1.0; /* { dg-warning "implicit" } */ + local_f = 1.0f / d; /* { dg-warning "implicit" } */ + + local_cf = cf + 1.0; /* { dg-warning "implicit" } */ + local_cf = cf - d; /* { dg-warning "implicit" } */ + local_cf = cf + 1.0 * ID; /* { dg-warning "implicit" } */ + local_cf = cf - cd; /* { dg-warning "implicit" } */ + + local_f = i ? f : d; /* { dg-warning "implicit" } */ + i = f == d; /* { dg-warning "implicit" } */ + i = d != f; /* { dg-warning "implicit" } */ +} + +void +default_argument_promotion (void) +{ + /* Because there is no prototype, "f" is promoted to "double". */ + unprototyped_fn (f); /* { dg-warning "implicit" } */ + undeclared_fn (f); /* { dg-warning "implicit" } */ + /* Because "f" is part of the variable argument list, it is promoted + to "double". */ + varargs_fn (1, f); /* { dg-warning "implicit" } */ +} + +/* There is no warning when an explicit cast is used to perform the + conversion. */ + +void +casts (void) +{ + float local_f; + _Complex float local_cf; + + local_f = (double)f + 1.0; /* { dg-bogus "implicit" } */ + local_f = (double)f - d; /* { dg-bogus "implicit" } */ + local_f = (double)1.0f + 1.0; /* { dg-bogus "implicit" } */ + local_f = (double)1.0f - d; /* { dg-bogus "implicit" } */ + + local_cf = (_Complex double)cf + 1.0; /* { dg-bogus "implicit" } */ + local_cf = (_Complex double)cf - d; /* { dg-bogus "implicit" } */ + local_cf = (_Complex double)cf + 1.0 * ID; /* { dg-bogus "implicit" } */ + local_cf = (_Complex double)cf - cd; /* { dg-bogus "implicit" } */ + + local_f = i ? (double)f : d; /* { dg-bogus "implicit" } */ + i = (double)f == d; /* { dg-bogus "implicit" } */ + i = d != (double)f; /* { dg-bogus "implicit" } */ +} + +/* There is no warning on conversions that occur in assignment (and + assignment-like) contexts. */ + +void +assignments (void) +{ + d = f; /* { dg-bogus "implicit" } */ + double_fn (f); /* { dg-bogus "implicit" } */ + d = float_fn (); /* { dg-bogus "implicit" } */ +} + +/* There is no warning in non-evaluated contexts. */ + +void +non_evaluated (void) +{ + s = sizeof (f + 1.0); /* { dg-bogus "implicit" } */ + s = __alignof__ (f + 1.0); /* { dg-bogus "implicit" } */ + d = (__typeof__(f + 1.0))f; /* { dg-bogus "implicit" } */ + s = sizeof (i ? f : d); /* { dg-bogus "implicit" } */ + s = sizeof (unprototyped_fn (f)); /* { dg-bogus "implicit" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wduplicate-decl-specifier-c11.c b/SingleSource/Regression/C/gcc-dg/Wduplicate-decl-specifier-c11.c new file mode 100644 index 0000000000..c2db525aaf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wduplicate-decl-specifier-c11.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wduplicate-decl-specifier" } */ + +typedef _Atomic int AT1; +#define AT2 _Atomic int + +void +foo (void) +{ + _Atomic AT1 x1; + _Atomic AT2 x2; + AT1 _Atomic x3; + AT2 _Atomic x4; + _Atomic int _Atomic x5; /* { dg-warning "duplicate ._Atomic." } */ +} + +void a1(_Atomic AT1 t) { } +void a2(_Atomic AT2 t) { } +void a3(AT1 _Atomic t) { } +void a4(AT2 _Atomic t) { } +void a5(_Atomic int _Atomic t) { } /* { dg-warning "duplicate ._Atomic." } */ + +typedef _Atomic AT1 AAT1; +typedef _Atomic AT2 AAT2; +typedef AT1 _Atomic AT1A; +typedef AT2 _Atomic AT2A; +typedef _Atomic int _Atomic AIA; /* { dg-warning "duplicate ._Atomic." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wduplicate-decl-specifier.c b/SingleSource/Regression/C/gcc-dg/Wduplicate-decl-specifier.c new file mode 100644 index 0000000000..d7a3919649 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wduplicate-decl-specifier.c @@ -0,0 +1,63 @@ +/* PR43651 */ +/* { dg-do compile } */ +/* { dg-options "-Wduplicate-decl-specifier" } */ + +typedef const int CT1; +#define CT2 const int +typedef volatile int VT1; +#define VT2 volatile int +typedef char *restrict RT1; +#define RT2 char *restrict + +void +foo (void) +{ + const CT1 x1; + const CT2 x2; + CT1 const x3; + CT2 const x4; + const int const x5; /* { dg-warning "duplicate .const." } */ + const int *const x6; + volatile VT1 y1; + volatile VT2 y2; + VT1 volatile y3; + VT2 volatile y4; + volatile int volatile y5; /* { dg-warning "duplicate .volatile." } */ + volatile int *volatile y6; + RT1 restrict r1; + RT2 restrict r2; + restrict RT1 r3; + /* "restrict RT2" is invalid */ + char *restrict restrict r4; /* { dg-warning "duplicate .restrict." } */ + char *restrict *restrict r5; +} + +void c1(const CT1 t) { } +void c2(const CT2 t) { } +void c3(CT1 const t) { } +void c4(CT2 const t) { } +void c5(const int const t) { } /* { dg-warning "duplicate .const." } */ +void v1(volatile VT1 t) { } +void v2(volatile VT2 t) { } +void v3(VT1 volatile t) { } +void v4(VT2 volatile t) { } +void v5(volatile int volatile t) { } /* { dg-warning "duplicate .volatile." } */ +void r1(restrict RT1 t) { } +void r2(RT1 restrict t) { } +void r3(RT2 restrict t) { } +void r4(char *restrict restrict t) { } /* { dg-warning "duplicate .restrict." } */ + +typedef const CT1 CCT1; +typedef const CT2 CCT2; +typedef CT1 const CT1C; +typedef CT2 const CT2C; +typedef const int const CIC; /* { dg-warning "duplicate .const." } */ +typedef volatile VT1 VVT1; +typedef volatile VT2 VVT2; +typedef VT1 volatile VT1V; +typedef VT2 volatile VT2V; +typedef volatile int volatile VIV; /* { dg-warning "duplicate .volatile." } */ +typedef RT1 restrict RT1R; +typedef RT2 restrict RT2R; +typedef restrict RT1 RRT1; +typedef int *restrict restrict IRR; /* { dg-warning "duplicate .restrict." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wenum-compare-1.c b/SingleSource/Regression/C/gcc-dg/Wenum-compare-1.c new file mode 100644 index 0000000000..dd321e0f64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wenum-compare-1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-Wenum-compare" } */ +enum E1 { A, B, C }; +enum E2 { D, E, F }; +extern void f2 (); +void +f1 () +{ + int a = A; + int d = D; + enum E1 e1 = A; + enum E2 e2 = D; + if (A > D) /* { dg-warning "comparison between .enum E1. and .enum E2." } */ + f2 (); + if (e1 > e2) /* { dg-warning "comparison between .enum E1. and .enum E2." } */ + f2 (); + if (e1 > e2 + 1) + f2 (); + if (A > 0) + f2 (); + if (e1 > 0) + f2 (); + if (A + D > 0) + f2 (); + if (e1 > 0) + f2 (); + if (A + D > 0) + f2 (); + if ((int) A > D) + f2 (); + if ((int) e1 > e2) + f2 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wenum-conversion.c b/SingleSource/Regression/C/gcc-dg/Wenum-conversion.c new file mode 100644 index 0000000000..86033399b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wenum-conversion.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Wenum-conversion" } */ + +enum X { x1, x2 }; +enum Y { y1, y2 }; + +enum X obj = y1; /* { dg-warning "implicit conversion from .enum Y. to .enum X." } */ +enum Y obj2 = y1; + +enum X obj3; +void foo() +{ + obj3 = y2; /* { dg-warning "implicit conversion from .enum Y. to .enum X." } */ +} + +void bar(enum X); +void f(void) +{ + bar (y1); /* { dg-warning "implicit conversion from .enum Y. to .enum X." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-1.c b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-1.c new file mode 100644 index 0000000000..629801833d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-1.c @@ -0,0 +1,43 @@ +/* PR c/105131 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -fno-short-enums" } */ + +enum E { E1 = -1, E2 = 0, E3 = 1 }; + +int foo(void); /* { dg-message "previous declaration" } */ +enum E foo(void) { return E2; } /* { dg-warning "conflicting types" } */ + +void bar(int); /* { dg-message "previous declaration" } */ +void bar(enum E); /* { dg-warning "conflicting types" } */ + +extern int arr[10]; /* { dg-message "previous declaration" } */ +extern enum E arr[10]; /* { dg-warning "conflicting types" } */ + +extern int i; /* { dg-message "previous declaration" } */ +extern enum E i; /* { dg-warning "conflicting types" } */ + +extern int *p; /* { dg-message "previous declaration" } */ +extern enum E *p; /* { dg-warning "conflicting types" } */ + +enum E foo2(void) { return E2; } /* { dg-message "previous definition" } */ +int foo2(void); /* { dg-warning "conflicting types" } */ + +void bar2(enum E); /* { dg-message "previous declaration" } */ +void bar2(int); /* { dg-warning "conflicting types" } */ + +extern enum E arr2[10]; /* { dg-message "previous declaration" } */ +extern int arr2[10]; /* { dg-warning "conflicting types" } */ + +extern enum E i2; /* { dg-message "previous declaration" } */ +extern int i2; /* { dg-warning "conflicting types" } */ + +extern enum E *p2; /* { dg-message "previous declaration" } */ +extern int *p2; /* { dg-warning "conflicting types" } */ + +enum F { F1 = -1, F2, F3 } __attribute__ ((__packed__)); + +enum F fn1(void); /* { dg-message "previous declaration" } */ +signed char fn1(void); /* { dg-warning "conflicting types" } */ + +signed char fn2(void); /* { dg-message "previous declaration" } */ +enum F fn2(void); /* { dg-warning "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-2.c b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-2.c new file mode 100644 index 0000000000..e5f75003d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-2.c @@ -0,0 +1,43 @@ +/* PR c/105131 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -fno-short-enums" } */ + +enum E { E1 = 0, E2, E3 }; + +unsigned int foo(void); /* { dg-message "previous declaration" } */ +enum E foo(void) { return E2; } /* { dg-warning "conflicting types" } */ + +void bar(unsigned int); /* { dg-message "previous declaration" } */ +void bar(enum E); /* { dg-warning "conflicting types" } */ + +extern enum E arr[10]; /* { dg-message "previous declaration" } */ +extern unsigned int arr[10]; /* { dg-warning "conflicting types" } */ + +extern unsigned int i; /* { dg-message "previous declaration" } */ +extern enum E i; /* { dg-warning "conflicting types" } */ + +extern unsigned int *p; /* { dg-message "previous declaration" } */ +extern enum E *p; /* { dg-warning "conflicting types" } */ + +enum E foo2(void) { return E2; } /* { dg-message "previous definition" } */ +unsigned int foo2(void); /* { dg-warning "conflicting types" } */ + +void bar2(enum E); /* { dg-message "previous declaration" } */ +void bar2(unsigned int); /* { dg-warning "conflicting types" } */ + +extern unsigned int arr2[10]; /* { dg-message "previous declaration" } */ +extern enum E arr2[10]; /* { dg-warning "conflicting types" } */ + +extern enum E i2; /* { dg-message "previous declaration" } */ +extern unsigned int i2; /* { dg-warning "conflicting types" } */ + +extern enum E *p2; /* { dg-message "previous declaration" } */ +extern unsigned int *p2; /* { dg-warning "conflicting types" } */ + +enum F { F1 = 1u, F2, F3 } __attribute__ ((__packed__)); + +enum F fn1(void); /* { dg-message "previous declaration" } */ +unsigned char fn1(void); /* { dg-warning "conflicting types" } */ + +unsigned char fn2(void); /* { dg-message "previous declaration" } */ +enum F fn2(void); /* { dg-warning "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-3.c b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-3.c new file mode 100644 index 0000000000..4ddbeb152d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-3.c @@ -0,0 +1,43 @@ +/* PR c/105131 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat -fno-short-enums" } */ + +enum E { E1 = -1, E2 = 0, E3 = 1 }; + +int foo(void); /* { dg-message "previous declaration" } */ +enum E foo(void) { return E2; } /* { dg-warning "conflicting types" } */ + +void bar(int); /* { dg-message "previous declaration" } */ +void bar(enum E); /* { dg-warning "conflicting types" } */ + +extern int arr[10]; /* { dg-message "previous declaration" } */ +extern enum E arr[10]; /* { dg-warning "conflicting types" } */ + +extern int i; /* { dg-message "previous declaration" } */ +extern enum E i; /* { dg-warning "conflicting types" } */ + +extern int *p; /* { dg-message "previous declaration" } */ +extern enum E *p; /* { dg-warning "conflicting types" } */ + +enum E foo2(void) { return E2; } /* { dg-message "previous definition" } */ +int foo2(void); /* { dg-warning "conflicting types" } */ + +void bar2(enum E); /* { dg-message "previous declaration" } */ +void bar2(int); /* { dg-warning "conflicting types" } */ + +extern enum E arr2[10]; /* { dg-message "previous declaration" } */ +extern int arr2[10]; /* { dg-warning "conflicting types" } */ + +extern enum E i2; /* { dg-message "previous declaration" } */ +extern int i2; /* { dg-warning "conflicting types" } */ + +extern enum E *p2; /* { dg-message "previous declaration" } */ +extern int *p2; /* { dg-warning "conflicting types" } */ + +enum F { F1 = -1, F2, F3 } __attribute__ ((__packed__)); + +enum F fn1(void); /* { dg-message "previous declaration" } */ +signed char fn1(void); /* { dg-warning "conflicting types" } */ + +signed char fn2(void); /* { dg-message "previous declaration" } */ +enum F fn2(void); /* { dg-warning "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-4.c b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-4.c new file mode 100644 index 0000000000..fcaca28345 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-4.c @@ -0,0 +1,5 @@ +/* PR c/105131 */ +/* { dg-do compile } */ +/* { dg-options "-fno-short-enums" } */ + +#include "Wenum-int-mismatch-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-5.c b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-5.c new file mode 100644 index 0000000000..db24fd32f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wenum-int-mismatch-5.c @@ -0,0 +1,5 @@ +/* PR c/105131 */ +/* { dg-do compile } */ +/* { dg-options "-fno-short-enums" } */ + +#include "Wenum-int-mismatch-2.c" diff --git a/SingleSource/Regression/C/gcc-dg/Werror-1.c b/SingleSource/Regression/C/gcc-dg/Werror-1.c new file mode 100644 index 0000000000..88553e7a15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Waddress -Wattributes -Werror -fshow-column" } */ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* This is the first in a series of test cases that test the + interaction between -Wfoo, -Werror, -Werror=foo, and #pragma GCC + diagnostic error foo. This one has all the bits we're testing, the + others are subsets of this one. */ + +#pragma GCC diagnostic error "-Waddress" + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-error ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error "7:.* will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-10.c b/SingleSource/Regression/C/gcc-dg/Werror-10.c new file mode 100644 index 0000000000..c5b2b4bfc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-10.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes -Werror" } */ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* Make sure #pragma can work with -Werror. */ + +#pragma GCC diagnostic error "-Waddress" + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-error ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error ".* will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-11.c b/SingleSource/Regression/C/gcc-dg/Werror-11.c new file mode 100644 index 0000000000..6e44219f6e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-11.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes -Werror" } */ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* Make sure #pragma can override -Werror. */ + +#pragma GCC diagnostic warning "-Waddress" + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-error ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning ".* will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-12.c b/SingleSource/Regression/C/gcc-dg/Werror-12.c new file mode 100644 index 0000000000..a87bf6977a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-12.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes -Waddress" } */ + +/* Make sure #pragma can override -Wfoo. */ + +#pragma GCC diagnostic ignored "-Waddress" + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-warning "attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-bogus "true" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-13.c b/SingleSource/Regression/C/gcc-dg/Werror-13.c new file mode 100644 index 0000000000..3a02b7ea2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-13.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Werror=error -Werror=p, -Werror=l, -Werror=fatal-errors -Werror=vla2 -Wno-error=misleading-indentation2" } */ +/* { dg-error "'-Wp,' is not an option that controls warnings" "" { target *-*-* } 0 } */ +/* { dg-error "'-Wl,' is not an option that controls warnings" "" { target *-*-* } 0 } */ +/* { dg-error "'-Werror' is not an option that controls warnings" "" { target *-*-* } 0 } */ +/* { dg-error "'-Wfatal-errors' is not an option that controls warnings" "" { target *-*-* } 0 } */ +/* { dg-error "'-Werror=vla2': no option '-Wvla2'; did you mean '-Wvla." "" { target *-*-* } 0 } */ +/* { dg-error "'-Wno-error=misleading-indentation2': no option '-Wmisleading-indentation2'; did you mean '-Wmisleading-indentation'" "" { target *-*-* } 0 } */ + +int i; diff --git a/SingleSource/Regression/C/gcc-dg/Werror-2.c b/SingleSource/Regression/C/gcc-dg/Werror-2.c new file mode 100644 index 0000000000..32a7b331ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* This one is the baseline. Make sure with no option we get no + warnings. */ + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-warning ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-3.c b/SingleSource/Regression/C/gcc-dg/Werror-3.c new file mode 100644 index 0000000000..76e0680cb5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-3.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Waddress -Wattributes" } */ + +/* Make sure the command line option enables the warning. */ + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-warning ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning ".* will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-4.c b/SingleSource/Regression/C/gcc-dg/Werror-4.c new file mode 100644 index 0000000000..85505230b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes" } */ +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ +/* Make sure the pragma enables the error. */ + +#pragma GCC diagnostic error "-Waddress" + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-warning "attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error "will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-5.c b/SingleSource/Regression/C/gcc-dg/Werror-5.c new file mode 100644 index 0000000000..8e90193669 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-5.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Waddress -Wattributes -Werror" } */ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* Make sure -Werror turns warnings in to errors. */ + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-error ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error ".* will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-6.c b/SingleSource/Regression/C/gcc-dg/Werror-6.c new file mode 100644 index 0000000000..0818ae3291 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-6.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes -Werror=address" } */ +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ +/* Make sure -Werror=foo emits an error and not a warning */ + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-warning ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-error ".* will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-7.c b/SingleSource/Regression/C/gcc-dg/Werror-7.c new file mode 100644 index 0000000000..ce28cdc78b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-7.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Waddress -Werror -Wno-error=address -Wattributes" } */ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +/* Make sure -Wno-error= overrides -Werror. */ + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-error ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning ".* will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-8.c b/SingleSource/Regression/C/gcc-dg/Werror-8.c new file mode 100644 index 0000000000..9698593a2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-8.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-Wattributes" } */ + +/* Make sure #pragma can enable a warning. */ + +#pragma GCC diagnostic warning "-Waddress" + +void grill (); +void __attribute__((dj)) bar() { } /* { dg-warning ".* attribute directive ignored" } */ + +int i; + +void +foo () +{ + if (&i) /* { dg-warning ".* will always evaluate as 'true'" } */ + grill (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Werror-implicit-function-declaration.c b/SingleSource/Regression/C/gcc-dg/Werror-implicit-function-declaration.c new file mode 100644 index 0000000000..3261fc0d94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Werror-implicit-function-declaration.c @@ -0,0 +1,8 @@ +/* Test the legacy option -Werror-implicit-function-declaration */ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -Werror-implicit-function-declaration" } */ +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ +void f(void) +{ + puts("Hello"); /* { dg-error "implicit declaration of function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wfatal-2.c b/SingleSource/Regression/C/gcc-dg/Wfatal-2.c new file mode 100644 index 0000000000..796fc8be41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfatal-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-Woverflow -Wdiv-by-zero -Werror -Wfatal-errors" } */ +#include + +int i = INT_MAX + 1; /* { dg-error "integer overflow in expression" } */ +int k = 1 / 0; +int j = INT_MIN - 1; +/* { dg-message "being treated as errors" "treated as errors" { target *-*-* } 0 } */ +/* { dg-message "terminated due to -Wfatal-errors" "terminated" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wfatal.c b/SingleSource/Regression/C/gcc-dg/Wfatal.c new file mode 100644 index 0000000000..6438d54e13 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfatal.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Woverflow -Werror=div-by-zero -Wfatal-errors" } */ +#include + +int i = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +int k = 1 / 0; /* { dg-error "division by zero" } */ +int j = INT_MIN - 1; +/* { dg-message "some warnings being treated as errors" "treated as errors" {target "*-*-*"} 0 } */ +/* { dg-message "terminated due to -Wfatal-errors" "terminated" { target *-*-* } 0 } */ + + + diff --git a/SingleSource/Regression/C/gcc-dg/Wfloat-equal-1.c b/SingleSource/Regression/C/gcc-dg/Wfloat-equal-1.c new file mode 100644 index 0000000000..1b23611bdc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfloat-equal-1.c @@ -0,0 +1,10 @@ +/* PR c/19999 */ +/* { dg-do compile } */ +/* { dg-options "-Wfloat-equal" } */ + +double a, b; +_Complex double c, d; +int f(void) { return a == b; } /* { dg-warning "comparing floating-point" } */ +int g(void) { return c == d; } /* { dg-warning "comparing floating-point" } */ +int h(void) { return a != b; } /* { dg-warning "comparing floating-point" } */ +int i(void) { return c != d; } /* { dg-warning "comparing floating-point" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wformat-overflow1.c b/SingleSource/Regression/C/gcc-dg/Wformat-overflow1.c new file mode 100644 index 0000000000..cf9766fae1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wformat-overflow1.c @@ -0,0 +1,28 @@ +/* + { dg-do compile } + { dg-options "-Wformat-overflow -std=c2x" } +*/ + +extern int sprintf (char* restrict, const char* restrict, ...); + +void test_warn () { + + int n = __INT_MAX__; + char dst [5] = {0}; + sprintf (dst, "%b", n); /* { dg-warning "-Wformat-overflow" } */ + + sprintf (dst, "%#b", n); /* { dg-warning "-Wformat-overflow" } */ + +} + +void test_no_warn () { + + char dst [5] = {0}; + int n = 8; + sprintf (dst, "%b", n); + + char another_dst [34] = {0}; + n = __INT_MAX__; + sprintf (another_dst, "%#b", n); + +} diff --git a/SingleSource/Regression/C/gcc-dg/Wframe-address-in-Wall.c b/SingleSource/Regression/C/gcc-dg/Wframe-address-in-Wall.c new file mode 100644 index 0000000000..70da9c8048 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wframe-address-in-Wall.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +/* Verify that -Wframe-address is included in -Wall. */ + +void* test_builtin_address (unsigned i) +{ + void* const ba[] = { + __builtin_frame_address (4), /* { dg-warning "builtin_frame_address" } */ + __builtin_return_address (4) /* { dg-warning "builtin_return_address" } */ + }; + + return ba [i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wframe-address.c b/SingleSource/Regression/C/gcc-dg/Wframe-address.c new file mode 100644 index 0000000000..29bdfa371d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wframe-address.c @@ -0,0 +1,55 @@ +/* { dg-do compile } */ +/* { dg-options "-Wframe-address" } */ +/* { dg-additional-options "-mbackchain" { target { s390*-*-* } } } */ + +void* __attribute__ ((noclone, noinline)) +test_builtin_frame_address (unsigned i) +{ + void* const fa[] = { + __builtin_frame_address (0), + __builtin_frame_address (1), /* { dg-warning "builtin_frame_address" } */ + __builtin_frame_address (2), /* { dg-warning "builtin_frame_address" } */ + __builtin_frame_address (3), /* { dg-warning "builtin_frame_address" } */ + __builtin_frame_address (4) /* { dg-warning "builtin_frame_address" } */ + }; + + return fa [i]; +} + + +void* __attribute__ ((noclone, noinline)) +test_builtin_return_address (unsigned i) +{ + void* const ra[] = { + __builtin_return_address (0), + __builtin_return_address (1), /* { dg-warning "builtin_return_address" } */ + __builtin_return_address (2), /* { dg-warning "builtin_return_address" } */ + __builtin_return_address (3), /* { dg-warning "builtin_return_address" } */ + __builtin_return_address (4) /* { dg-warning "builtin_return_address" } */ + }; + return ra [i]; +} + + +int main (void) +{ + test_builtin_frame_address (0); + + test_builtin_return_address (0); + + void* const a[] = { + __builtin_frame_address (0), + __builtin_frame_address (1), /* { dg-warning "builtin_frame_address" } */ + __builtin_frame_address (2), /* { dg-warning "builtin_frame_address" } */ + __builtin_frame_address (3), /* { dg-warning "builtin_frame_address" } */ + __builtin_frame_address (4), /* { dg-warning "builtin_frame_address" } */ + + __builtin_return_address (0), + __builtin_return_address (1), /* { dg-warning "builtin_return_address" } */ + __builtin_return_address (2), /* { dg-warning "builtin_return_address" } */ + __builtin_return_address (3), /* { dg-warning "builtin_return_address" } */ + __builtin_return_address (4) /* { dg-warning "builtin_return_address" } */ + }; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wframe-larger-than-2.c b/SingleSource/Regression/C/gcc-dg/Wframe-larger-than-2.c new file mode 100644 index 0000000000..d7068d04ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wframe-larger-than-2.c @@ -0,0 +1,20 @@ +/* Exercise -Wframe-larger-than= with a byte-size suffix. + { dg-do compile } + { dg-options "-O -Wframe-larger-than=1KB" } + { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ + +extern void f (void*, ...); + +void frame_size_912 (void) +{ + char a[512]; + char b[400]; + f (a, b); +} + +void frame_size_1025 (void) +{ + char a[512]; + char b[513]; + f (a, b); +} /* { dg-warning "frame size of \[0-9\]+ bytes is larger than 1024 bytes" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wframe-larger-than-3.c b/SingleSource/Regression/C/gcc-dg/Wframe-larger-than-3.c new file mode 100644 index 0000000000..ae5b2f497c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wframe-larger-than-3.c @@ -0,0 +1,11 @@ +/* PR 90983/manual documents `-Wno-stack-usage` flag, but it is unrecognized + { dg-do compile } + { dg-options "-Wall -Wframe-larger-than=123 -Wno-frame-larger-than" } */ + +void f (void*); + +void g (void) +{ + char a [1234]; + f (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wframe-larger-than.c b/SingleSource/Regression/C/gcc-dg/Wframe-larger-than.c new file mode 100644 index 0000000000..8a40cf36df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wframe-larger-than.c @@ -0,0 +1,14 @@ +/* Test -Wframe-larger-than for warning + when the frame size is bigger than specified. + Origin: Seongbae Park */ + +/* { dg-do compile } */ +/* { dg-options "-Wframe-larger-than=2048" } */ +/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ + +extern void func(char *); + +void foo (void) { + char array[4096]; + func(array); +} /* { dg-warning "the frame size of .* bytes is larger than 2048 bytes" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-2.c b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-2.c new file mode 100644 index 0000000000..e9316a5d23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-2.c @@ -0,0 +1,280 @@ +/* PR ????? - No warning on attempts to access free object + Verify that attempting to reallocate unallocated objects referenced + either directly or through pointers is diagnosed. + { dg-do compile } + { dg-options "-O2 -Wall -Wfree-nonheap-object" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +extern void free (void*); +extern void* alloca (size_t); +extern void* realloc (void*, size_t); + +void sink (void*, ...); + +extern void* eparr[]; +extern char *eptr; + +extern size_t n; + + +void nowarn_realloc (void *p, size_t n) +{ + char *q = realloc (p, n); + sink (q); + + q = realloc (0, n); + sink (q); + + q = realloc (q, n * 2); + sink (q); +} + +/* Verify that calling realloc on a pointer to an unknown object minus + some nonzero offset isn't diagnosed, but a pointer plus a positive + offset is (a positive offset cannot point at the beginning). */ + +void test_realloc_offset (char *p1, char *p2, char *p3, size_t n, int i) +{ + char *q; + q = realloc (p1 - 1, n); + sink (q); + + q = realloc (p2 + 1, n); // { dg-warning "'realloc' called on pointer 'p2' with nonzero offset 1" } + sink (q); + + q = realloc (p3 + i, n); + sink (q); +} + +void warn_realloc_extern_arr (void) +{ + extern char ecarr[]; // { gg-message "declared here" } + char *p = ecarr; + char *q = realloc (p, n); // { dg-warning "'realloc' called on unallocated object 'ecarr'" } + sink (q); +} + +void warn_realloc_extern_arr_offset (int i) +{ + extern char ecarr[]; + char *p = ecarr + i; + char *q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); +} + + +void warn_realloc_string (int i) +{ + char *p, *q; + { + p = "123"; + sink (p); + q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + { + p = "234" + 1; + sink (p); + q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + { + p = "123" + i; + sink (p); + q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } +} + + +void warn_realloc_alloca (int n, int i) +{ + char *p, *q; + { + p = alloca (n); + sink (p); + q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + { + p = (char*)alloca (n + 1); + sink (p); + q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + { + p = (char*)alloca (n + 2) + i; + sink (p); + q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } +} + + +void warn_realloc_local_arr (int i) +{ + char *q; + { + char a[4]; + sink (a); + q = realloc (a, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + + { + char b[5]; + sink (b); + q = realloc (b + 1, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + + { + char c[6]; + sink (c); + q = realloc (&c[2], n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + + { + char d[7]; + sink (d); + q = realloc (&d[i], n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } +} + +void warn_realloc_vla (int n1, int n2, int i) +{ + char *q; + { + char vla[n1]; + sink (vla); + q = realloc (vla, n2); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + + { + char vlb[n1 + 1]; + sink (vlb); + q = realloc (vlb + 1, n2);// { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + + { + char vlc[n1 + 2]; + sink (vlc); + q = realloc (&vlc[2], n2);// { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } + + { + char vld[7]; + sink (vld); + q = realloc (&vld[i], n2);// { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); + } +} + +void nowarn_realloc_extern_ptrarr (void) +{ + char *q = realloc (*eparr, n); + sink (q); +} + +void nowarn_realloc_extern_ptrarr_offset (int i) +{ + char *p = eparr[i]; + char *q = realloc (p, n); + sink (q); +} + + +void warn_realloc_extern_ptrarr (void) +{ + char *q = realloc (eparr, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); +} + +void warn_realloc_extern_ptrarr_offset (int i) +{ + void *p = eparr + i; + void *q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); +} + + +void nowarn_realloc_extern_ptr (void) +{ + char *q = realloc (eptr, n); + sink (q); +} + +void nowarn_realloc_extern_ptr_offset (int i) +{ + char *p = eptr + i; + char *q = realloc (p, n); + sink (q); +} + + +void warn_realloc_extern_ptr_pos_offset (int i) +{ + if (i <= 0) + i = 1; + + char *p = eptr + i; + char *q = realloc (p, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); +} + + +void nowarn_realloc_parm_offset (char *p, int i) +{ + char *q = p + i; + q = realloc (q, n); + sink (q); +} + +void nowarn_realloc_parm_neg_offset (char *p, int i) +{ + if (i >= 0) + i = -1; + + char *q = p + i; + q = realloc (q, n); + sink (q); +} + +void warn_realloc_parm_pos_offset (char *p, int i) +{ + if (i <= 0) + i = 1; + + char *q = p + i; + q = realloc (q, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); +} + +void nowarn_realloc_deref_parm_pos_offset (void **p, int i) +{ + if (i <= 0) + i = 1; + + // The offset is from p, not *p. + void *q = *(p + i); + q = realloc (q, n); + sink (q); +} + +void warn_realloc_deref_parm_pos_offset (void **p, int i) +{ + if (i <= 0) + i = 1; + + // Unlike in the function above the offset is from *p. + void *q = *p + i; + q = realloc (q, n); // { dg-warning "\\\[-Wfree-nonheap-object" } + sink (q); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-3.c b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-3.c new file mode 100644 index 0000000000..a472b93fb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-3.c @@ -0,0 +1,57 @@ +/* PR ????? - No warning on attempts to access free object + Verify that freeing unallocated objects referenced indirectly through + pointers obtained from function calls is diagnosed. + { dg-do compile } + { dg-options "-O2 -Wall -Wfree-nonheap-object" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void free (void*); +extern char* memchr (const void*, int, size_t); +extern char* strchr (const char*, int); + +void sink (void*, ...); + +extern char ecarr[]; +extern void* eparr[]; + +extern char *eptr; + + +void warn_free_memchr_ecarr (int x, size_t n) +{ + char *p = memchr (ecarr, x, n); + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +void warn_free_memchr_ecarr_offset (int i, int j, int x, size_t n) +{ + char *p = memchr (ecarr + i, x, n); + char *q = p + j; + sink (p, q); + free (q); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + + +void warn_free_memchr_local_arr (int x, size_t n) +{ + char a[8]; + sink (a); + + char *p = memchr (a, x, n); + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +void warn_free_memchr_local_arr_offset (int i, int j, int x, size_t n) +{ + char a[8]; + sink (a); + + char *p = memchr (a + i, x, n); + char *q = p + j; + sink (p, q); + free (q); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-4.c b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-4.c new file mode 100644 index 0000000000..e459b247d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-4.c @@ -0,0 +1,107 @@ +/* PR middle-end/98664 - inconsistent --Wfree-nonheap-object for inlined + calls to system headers + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +# 7 "Wfree-nonheap-object-4.h" 1 3 + +struct A +{ + void *p; +}; + +static void f0 (struct A *p, void *q) { p->p = q; } +static void f1 (struct A *p, void *q) { f0 (p, q); } +static void f2 (struct A *p, void *q) { f1 (p, q); } + +static void g0 (struct A *p) +{ + __builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +static void g1 (struct A *p) { g0 (p); } +static void g2 (struct A *p) { g1 (p); } + +# 26 "Wfree-nonheap-object-4.c" + +#define NOIPA __attribute__ ((noipa)) + +extern int array[]; // { dg-message "declared here" "note on line 29" } + +/* Verify the warning is issued even for calls in a system header inlined + into a function outside the header. */ + +NOIPA void warn_g0 (struct A *p) +{ + int *q = array + 1; + + f0 (p, q); + g0 (p); +} + +// { dg-message "inlined from 'warn_g0'" "note on line 42" { target *-*-* } 0 } + + +/* Also verify the warning can be suppressed. */ + +NOIPA void nowarn_g0 (struct A *p) +{ + int *q = array + 2; + + f0 (p, q); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + g0 (p); +#pragma GCC diagnostic pop +} + + +NOIPA void warn_g1 (struct A *p) +{ + int *q = array + 3; + + f1 (p, q); + g1 (p); +} + +// { dg-message "inlined from 'g1'" "note on line 68" { target *-*-* } 0 } +// { dg-message "inlined from 'warn_g1'" "note on line 69" { target *-*-* } 0 } + + +NOIPA void nowarn_g1 (struct A *p) +{ + int *q = array + 4; + + f1 (p, q); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + g1 (p); +#pragma GCC diagnostic pop +} + + +NOIPA void warn_g2 (struct A *p) +{ + int *q = array + 5; + + f2 (p, q); + g2 (p); +} + +// { dg-message "inlined from 'g2'" "note on line 93" { target *-*-* } 0 } +// { dg-message "inlined from 'warn_g2'" "note on line 94" { target *-*-* } 0 } + + +NOIPA void nowarn_g2 (struct A *p) +{ + int *q = array + 6; + + f2 (p, q); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + g2 (p); +#pragma GCC diagnostic pop +} diff --git a/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-5.c b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-5.c new file mode 100644 index 0000000000..026cd45f09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-5.c @@ -0,0 +1,46 @@ +/* Similar to Wfree-nonheap-object-4.c but without system headers: + verify that warnings for the same call site from distinct callers + include the correct function names in the inlining stack. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct A +{ + void *p; +}; + +static void f0 (struct A *p) +{ + __builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +// Expect two instances of the text below: +// { dg-regexp "In function 'f0'," "first f0 prefix" { target *-*-* } 0 } +// { dg-regexp "In function 'f0'," "second f0 prefix" { target *-*-* } 0 } + +static void f1 (struct A *p) { f0 (p); } +static void f2 (struct A *p) { f1 (p); } + +extern int array[]; +// Also expect two instances of the note: +// { dg-regexp "declared here" "first note on line 24" { target *-*-* } .-2 } +// { dg-regexp "declared here" "second note on line 24" { target *-*-* } .-3 } + +void foo (struct A *p) +{ + p->p = array + 1; + f0 (p); +} + +// { dg-regexp " +inlined from 'foo' at \[^:\]+Wfree-nonheap-object-5.c:32:\\d+:" "note on line 32" } + + +void bar (struct A *p) +{ + p->p = array + 2; + f2 (p); +} + +// { dg-regexp " +inlined from 'f1' at \[^:\]+Wfree-nonheap-object-5.c:21:\\d+," "inlined from f1" } +// { dg-regexp " +inlined from 'f2' at \[^:\]+Wfree-nonheap-object-5.c:22:\\d+," "inlined from f2" } +// { dg-regexp " +inlined from 'bar' at \[^:\]+Wfree-nonheap-object-5.c:41:\\d+:" "inlined from bar" } diff --git a/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-6.c b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-6.c new file mode 100644 index 0000000000..c109558838 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-6.c @@ -0,0 +1,49 @@ +/* Similar to Wfree-nonheap-object-5.c but with attribute artificial: + verify that warnings for the same call site from distinct callers + include the correct function names in the inlining stack. + { dg-do compile } + { dg-options "-O1 -Wall" } */ + +struct A +{ + void *p; +}; + +__attribute__ ((always_inline, artificial)) +inline void f0 (struct A *p) +{ + __builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +// Expect two instances of the text below: +// { dg-regexp "In function 'f0'," "first f0 prefix" { target *-*-* } 0 } +// { dg-regexp "In function 'f0'," "second f0 prefix" { target *-*-* } 0 } + +__attribute__ ((always_inline, artificial)) +inline void f1 (struct A *p) { f0 (p); } +__attribute__ ((always_inline, artificial)) +inline void f2 (struct A *p) { f1 (p); } + +extern int array[]; +// Also expect two instances of the note: +// { dg-regexp "declared here" "first note for array" { target *-*-* } .-2 } +// { dg-regexp "declared here" "second note for array" { target *-*-* } .-3 } + +void foo (struct A *p) +{ + p->p = array + 1; + f0 (p); +} + +// { dg-regexp " +inlined from 'foo' at \[^:\]+Wfree-nonheap-object-6.c:35:\\d+:" "inlined from foo" } + + +void bar (struct A *p) +{ + p->p = array + 2; + f2 (p); +} + +// { dg-regexp " +inlined from 'f1' at \[^:\]+Wfree-nonheap-object-6.c:23:\\d+," "inlined from f1" } +// { dg-regexp " +inlined from 'f2' at \[^:\]+Wfree-nonheap-object-6.c:25:\\d+," "inlined from f2" } +// { dg-regexp " +inlined from 'bar' at \[^:\]+Wfree-nonheap-object-6.c:44:\\d+:" "inlined from bar" } diff --git a/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-7.c b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-7.c new file mode 100644 index 0000000000..6116bfa4d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object-7.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wfree-nonheap-object" } */ + +struct local_caches *get_local_caches_lcs; +void *calloc(long, long); +void *realloc(); + +struct local_caches { + int *t_mem_caches; +}; + +struct local_caches *get_local_caches() { + if (get_local_caches_lcs) + return get_local_caches_lcs; + get_local_caches_lcs = calloc(1, 0); + return get_local_caches_lcs; +} + +void libtrace_ocache_free() { + struct local_caches lcs = *get_local_caches(), __trans_tmp_1 = lcs; + { + struct local_caches *lcs = &__trans_tmp_1; + lcs->t_mem_caches += 10; + __trans_tmp_1.t_mem_caches = realloc(__trans_tmp_1.t_mem_caches, sizeof(int)); // { dg-warning "called on pointer (?:(?!PHI).)*nonzero offset" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object.c b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object.c new file mode 100644 index 0000000000..c7c668043a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wfree-nonheap-object.c @@ -0,0 +1,274 @@ +/* PR ????? - No warning on attempts to access free object + Verify that freeing unallocated objects referenced either directly + or through pointers is diagnosed. In most cases this doesn't require + optimization. + { dg-do compile } + { dg-options "-Wall -Wfree-nonheap-object" } + { dg-require-effective-target alloca } */ + +typedef __INTPTR_TYPE__ intptr_t; +typedef __SIZE_TYPE__ size_t; + +extern void free (void*); +extern void* malloc (size_t); +extern void* realloc (void *p, size_t); + +void sink (void*, ...); + +extern char ecarr[]; +extern void* eparr[]; + +extern char *eptr; + +void* source (void); + +void nowarn_free (void *p, void **pp, size_t n, intptr_t iptr) +{ + free (p); + + p = 0; + free (p); + + p = malloc (n); + sink (p); + free (p); + + p = malloc (n); + sink (p); + + p = realloc (p, n * 2); + sink (p); + free (p); + + free ((void*)iptr); + + p = source (); + free (p); + + p = source (); + p = (char*)p - 1; + free (p); + + free (*pp); +} + +void warn_free_extern_arr (void) +{ + free (ecarr); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +void warn_free_extern_arr_offset (int i) +{ + char *p = ecarr + i; + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + + +void warn_free_cstint (void) +{ + void *p = (void*)1; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + + +void warn_free_func (void) +{ + void *p = warn_free_func; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + + +void warn_free_string (int i) +{ + { + char *p = "123"; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } + { + char *p = "234" + 1; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } + { + char *p = "345" + i; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } + + if (i >= 0) + { + char *p = "456" + i; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } +} + +void warn_free_local_arr (int i) +{ + { + char a[4]; + sink (a); + free (a); // { dg-warning "\\\[-Wfree-nonheap-object" } + } + { + char b[5]; + sink (b); + + char *p = b + 1; + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } + { + char c[6]; + sink (c); + + char *p = c + i; + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } +} + + +void warn_free_vla (int n, int i) +{ + { + int vla[n], *p = vla; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } + + { + int vla[n + 1], *p = vla + 1; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } + { + int vla[n + 2], *p = vla + i; + sink (p); + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } + } +} + + +void nowarn_free_extern_ptrarr (void) +{ + free (*eparr); +} + +void nowarn_free_extern_ptrarr_offset (int i) +{ + char *p = eparr[i]; + free (p); +} + + +void warn_free_extern_ptrarr (void) +{ + free (eparr); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +void warn_free_extern_ptrarr_offset (int i) +{ + void *p = &eparr[i]; + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + + +void nowarn_free_local_ptrarr (int i) +{ + void* a[4]; + sink (a); + free (a[0]); + free (a[1]); + free (a[i]); +} + + +void nowarn_free_extern_ptr (void) +{ + free (eptr); +} + +void nowarn_free_extern_ptr_offset (int i) +{ + char *p = eptr + i; + free (p); +} + +void nowarn_free_parm_offset (char *p, int i) +{ + char *q = p + i; + free (q); +} + +void nowarn_free_parm_neg_offset (char *p, int i) +{ + if (i >= 0) + i = -1; + + char *q = p + i; + free (q); +} + +struct Members +{ + char a[4], *p, *q; +}; + +extern struct Members em; + +void nowarn_free_member_ptr (struct Members *pm, int i) +{ + char *p = em.p; + free (p); + p = em.q + i; + free (p); + + free (pm->q); + p = pm->p; + free (pm); + free (p); +} + +void nowarn_free_struct_cast (intptr_t *p) +{ + struct Members *q = (struct Members*)*p; + if (q->p == 0) + free (q); // { dg-bogus "\\\[-Wfree-nonheap-object" } +} + + +void warn_free_member_array (void) +{ + char *p = em.a; + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +void warn_free_member_array_off (int i) +{ + char *p = em.a + i; + free (p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + + +// Range information requires optimization. +#pragma GCC optimize "1" + +void warn_free_extern_ptr_pos_offset (int i) +{ + if (i <= 0) + i = 1; + + char *q = eptr + i; + free (q); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +void warn_free_parm_pos_offset (char *p, int i) +{ + if (i <= 0) + i = 1; + + char *q = p + i; + free (q); // { dg-warning "\\\[-Wfree-nonheap-object" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-fallthrough-1.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-fallthrough-1.c new file mode 100644 index 0000000000..f8b54f5237 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-fallthrough-1.c @@ -0,0 +1,22 @@ +/* PR c/7652 */ +/* { dg-do compile } */ +/* { dg-options "-Wimplicit-fallthrough -Wdeclaration-after-statement" } */ + +/* Test we don't print bogus "mixed declarations and code" warning. */ + +int +f (int b) +{ + switch (b) + { + case 0: + b++; + __attribute__((fallthrough)); + case 1: + b--; + __attribute__((unused)) int a; /* { dg-warning "mixed declarations and code" } */ + case 2: + break; + } + return 99; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89-default.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89-default.c new file mode 100644 index 0000000000..c725ffaca4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89-default.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89" } */ + +void f(void) +{ + puts("Hello"); /* { dg-bogus "warning: implicit declaration of function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89-pedantic.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89-pedantic.c new file mode 100644 index 0000000000..5491aea793 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89-pedantic.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -pedantic-errors -Wimplicit-function-declaration" } */ + +void f(void) +{ + puts("Hello"); /* { dg-warning "implicit declaration of function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89.c new file mode 100644 index 0000000000..441899edb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c89.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -Wimplicit-function-declaration" } */ + +void f(void) +{ + puts("Hello"); /* { dg-warning "implicit declaration of function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c99-pedantic.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c99-pedantic.c new file mode 100644 index 0000000000..05cca9a2b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c99-pedantic.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors -Wall" } */ + +void f(void) +{ + puts("Hello"); /* { dg-error "implicit declaration of function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c99.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c99.c new file mode 100644 index 0000000000..254f7e70e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-function-declaration-c99.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +void f(void) +{ + puts("Hello"); /* { dg-warning "implicit declaration of function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-int-1.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-int-1.c new file mode 100644 index 0000000000..4a96e8f505 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-int-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +static l; /* { dg-warning "type defaults to" } */ + +foo (a) /* { dg-warning "return type defaults to" } */ +/* { dg-warning "type of .a. defaults to .int." "type" { target *-*-* } .-1 } */ +{ + auto p; /* { dg-warning "type defaults to" } */ + typedef bar; /* { dg-warning "type defaults to" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-int-2.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-int-2.c new file mode 100644 index 0000000000..4ff16f3673 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-int-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +static l; /* { dg-error "type defaults to" } */ + +foo (a) /* { dg-error "return type defaults to" } */ +/* { dg-error "type of .a. defaults to .int." "type" { target *-*-* } .-1 } */ +{ + auto p; /* { dg-error "type defaults to" } */ + typedef bar; /* { dg-error "type defaults to" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-int-3.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-int-3.c new file mode 100644 index 0000000000..654ce736c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-int-3.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -Wno-implicit-int" } */ + +static l; + +foo (a) +{ + auto p; + typedef bar; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wimplicit-int-4.c b/SingleSource/Regression/C/gcc-dg/Wimplicit-int-4.c new file mode 100644 index 0000000000..c9c6e8e5e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wimplicit-int-4.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-implicit -Wimplicit-int" } */ + +static l; /* { dg-warning "type defaults to" } */ + +foo (a) /* { dg-warning "return type defaults to" } */ +/* { dg-warning "type of .a. defaults to .int." "type" { target *-*-* } .-1 } */ +{ + auto p; /* { dg-warning "type defaults to" } */ + typedef bar; /* { dg-warning "type defaults to" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wincompatible-pointer-types-1.c b/SingleSource/Regression/C/gcc-dg/Wincompatible-pointer-types-1.c new file mode 100644 index 0000000000..4ae7b1d99c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wincompatible-pointer-types-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +void f (int, ...); + +int +f1 (void) +{ + int (*x) (); + x = f; /* { dg-error "assignment to 'int \\(\\*\\)\\(\\)' from incompatible pointer type 'void \\(\\*\\)\\(int, \.\.\.\\)'" } */ + return x (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wincompatible-pointer-types.c b/SingleSource/Regression/C/gcc-dg/Wincompatible-pointer-types.c new file mode 100644 index 0000000000..e765b27609 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wincompatible-pointer-types.c @@ -0,0 +1,21 @@ +/* PR c/58286 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-incompatible-pointer-types" } */ + +void +fn2 (short *s, long *l) +{ +} + +unsigned * +fn1 (void) +{ + int (*fpi) (int); + int (*fpd) (double) = fpi; + fpi = fpd; + char *di; + float *dp = &di; + di = dp; + fn2 (dp, di); + return dp; +} diff --git a/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-2.c b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-2.c new file mode 100644 index 0000000000..23483122a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-2.c @@ -0,0 +1,252 @@ +/* PR middle-end/88232 - Please implement -Winfinite-recursion + Exercise warning with optimization. Same as -Winfinite-recursion.c + plus mutually recursive calls that depend on inlining. + { dg-do compile } + { dg-options "-O2 -Wall -Winfinite-recursion" } */ + +#define NORETURN __attribute__ ((noreturn)) + +typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void exit (int); + +extern int ei; +int (*pfi_v)(void); + + +/* Make sure the warning doesn't assume every call has a DECL. */ + +int nowarn_pfi_v (void) +{ + return pfi_v (); +} + + +int warn_fi_v (void) // { dg-warning "-Winfinite-recursion" } +{ + return warn_fi_v (); // { dg-message "recursive call" } +} + +/* Verify #pragma suppression works. */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winfinite-recursion" + +int suppress_warn_fi_v (void) +{ + return warn_fi_v (); +} + +#pragma GCC diagnostic pop + +int nowarn_fi_v (void) +{ + if (ei++ == 0) + return nowarn_fi_v (); + return 0; +} + + +int warn_if_i (int i) // { dg-warning "-Winfinite-recursion" } +{ + if (i > 0) + return warn_if_i (--i); // { dg-message "recursive call" } + else if (i < 0) + return warn_if_i (-i); // { dg-message "recursive call" } + else + return warn_if_i (7); // { dg-message "recursive call" } +} + + +int nowarn_if_i (int i) +{ + if (i > 0) + return nowarn_if_i (--i); + else if (i < 0) + return nowarn_if_i (-i); + else + return -1; +} + +int nowarn_switch (int i, int a[]) +{ + switch (i) + { + case 0: return nowarn_switch (a[3], a + 1); + case 1: return nowarn_switch (a[5], a + 2); + case 2: return nowarn_switch (a[7], a + 3); + case 3: return nowarn_switch (a[9], a + 4); + } + return 77; +} + +int warn_switch (int i, int a[]) // { dg-warning "-Winfinite-recursion" } +{ + switch (i) + { + case 0: return warn_switch (a[3], a + 1); + case 1: return warn_switch (a[5], a + 2); + case 2: return warn_switch (a[7], a + 3); + case 3: return warn_switch (a[9], a + 4); + default: return warn_switch (a[1], a + 5); + } +} + +NORETURN void fnoreturn (void); + +/* Verify there's no warning for a function that doesn't return. */ +int nowarn_call_noret (void) +{ + fnoreturn (); +} + +int warn_call_noret_r (void) // { dg-warning "-Winfinite-recursion" } +{ + warn_call_noret_r (); // { dg-message "recursive call" } + fnoreturn (); +} + +/* Verify a warning even though the abort() call would prevent the infinite + recursion. There's no good way to tell the two cases apart and letting + a simple abort prevent the warning would make it ineffective in cases + where it's the result of assert() expansion and not meant to actually + prevent recursion. */ + +int +warn_noret_call_abort_r (char *s, int n) // { dg-warning "-Winfinite-recursion" } +{ + if (!s) + abort (); + + if (n > 7) + abort (); + + return n + warn_noret_call_abort_r (s, n - 1); // { dg-message "recursive call" } +} + +/* Verify that a warning is not issued for an apparently infinitely + recursive function like the one above where the recursion would be + prevented by a call to a noreturn function if the recursive function + is itself declared noreturn. */ + +NORETURN void nowarn_noret_call_abort_r (int n) +{ + if (n > 7) + abort (); + + nowarn_noret_call_abort_r (n - 1); +} + +int warn_call_abort_r (int n) // { dg-warning "-Winfinite-recursion" } +{ + n += warn_call_abort_r (n - 1); // { dg-message "recursive call" } + if (n > 7) // unreachable + abort (); + return n; +} + + +/* And again with exit() for good measure. */ + +int warn_call_exit_r (int n) // { dg-warning "-Winfinite-recursion" } +{ + n += warn_call_exit_r (n - 1); // { dg-message "recursive call" } + if (n > 7) + exit (0); + return n; +} + +struct __jmp_buf_tag { }; +typedef struct __jmp_buf_tag jmp_buf[1]; + +extern jmp_buf jmpbuf; + +/* A call to longjmp() breaks infinite recursion. Verify it suppresses + the warning. */ + +int nowarn_call_longjmp_r (int n) +{ + if (n > 7) + __builtin_longjmp (jmpbuf, 1); + return n + nowarn_call_longjmp_r (n - 1); +} + +int warn_call_longjmp_r (int n) // { dg-warning "-Winfinite-recursion" } +{ + n += warn_call_longjmp_r (n - 1); // { dg-message "recursive call" } + if (n > 7) + __builtin_longjmp (jmpbuf, 1); + return n; +} + + +struct __sigjmp_buf_tag { }; +typedef struct __sigjmp_buf_tag sigjmp_buf[1]; + +extern sigjmp_buf sigjmpbuf; + +/* GCC has no __builtin_siglongjmp(). */ +extern void siglongjmp (sigjmp_buf, int); + +/* A call to longjmp() breaks infinite recursion. Verify it suppresses + the warning. */ + +int nowarn_call_siglongjmp_r (int n) +{ + if (n > 7) + siglongjmp (sigjmpbuf, 1); + return n + nowarn_call_siglongjmp_r (n - 1); +} + + +int nowarn_while_do_call_r (int n) +{ + int z = 0; + while (n) + z += nowarn_while_do_call_r (n--); + return z; +} + +int warn_do_while_call_r (int n) // { dg-warning "-Winfinite-recursion" } +{ + int z = 0; + do + z += warn_do_while_call_r (n); // { dg-message "recursive call" } + while (--n); + return z; +} + + +/* Verify warnings for a naive replacement of a built-in fucntion. */ + +void* malloc (size_t n) // { dg-warning "-Winfinite-recursion" } +{ + size_t *p = + (size_t*)__builtin_malloc (n + sizeof n); // { dg-message "recursive call" } + *p = n; + return p + 1; +} + + +int nowarn_fact (int n) +{ + return n ? n * nowarn_fact (n - 1) : 1; +} + + +static int fi_v (void); + +/* It would seem preferable to issue the warning for the extern function + but as it happens it's the static function that's inlined into a recursive + call to itself and warn_call_fi_v() expands to a call to it. */ + +int warn_call_fi_v (void) // { dg-warning "-Winfinite-recursion" "" { xfail *-*-* } } +{ + return fi_v (); // { dg-message "recursive call" } +} + +static int fi_v (void) // { dg-warning "-Winfinite-recursion" } +{ + return warn_call_fi_v (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-3.c b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-3.c new file mode 100644 index 0000000000..9205422041 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-3.c @@ -0,0 +1,18 @@ +/* PR c/104633 */ +/* { dg-do compile } */ +/* { dg-options "-Winfinite-recursion" } */ + +typedef __SIZE_TYPE__ size_t; +int memcmp (const void *, const void *, size_t); + +extern inline __attribute__((always_inline, gnu_inline)) int +memcmp (const void *p, const void *q, size_t size) /* { dg-bogus "infinite recursion detected" } */ +{ + return __builtin_memcmp (p, q, size); /* { dg-bogus "recursive call" } */ +} + +int +foo (const void *p, const void *q, size_t size) +{ + return memcmp (p, q, size); +} diff --git a/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-4.c b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-4.c new file mode 100644 index 0000000000..e9a2bb675d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-4.c @@ -0,0 +1,19 @@ +/* PR c/104633 */ +/* { dg-do compile } */ +/* { dg-options "-Winfinite-recursion" } */ + +typedef __SIZE_TYPE__ size_t; +int memcmp (const void *, const void *, size_t); +__typeof (memcmp) __memcmp_alias __asm ("memcmp"); + +extern inline __attribute__((always_inline, gnu_inline)) int +memcmp (const void *p, const void *q, size_t size) /* { dg-bogus "infinite recursion detected" } */ +{ + return __memcmp_alias (p, q, size); /* { dg-bogus "recursive call" } */ +} + +int +foo (const void *p, const void *q, size_t size) +{ + return memcmp (p, q, size); +} diff --git a/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-5.c b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-5.c new file mode 100644 index 0000000000..1c3d1b48f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion-5.c @@ -0,0 +1,18 @@ +/* PR c/104633 */ +/* { dg-do compile } */ +/* { dg-options "-Winfinite-recursion" } */ + +typedef __SIZE_TYPE__ size_t; +int memcmp (const void *, const void *, size_t); + +extern inline __attribute__((always_inline, gnu_inline)) int +memcmp (const void *p, const void *q, size_t size) /* { dg-warning "infinite recursion detected" } */ +{ /* { dg-error "inlining failed in call to" "" { target *-*-* } .-1 } */ + return memcmp (p, q, size); /* { dg-message "recursive call" } */ +} /* { dg-message "called from here" "" { target *-*-* } .-1 } */ + +int +foo (const void *p, const void *q, size_t size) +{ + return memcmp (p, q, size); +} diff --git a/SingleSource/Regression/C/gcc-dg/Winfinite-recursion.c b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion.c new file mode 100644 index 0000000000..e3253567d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Winfinite-recursion.c @@ -0,0 +1,227 @@ +/* PR middle-end/88232 - Please implement -Winfinite-recursion + Verify simple cases without optimization. + { dg-do compile } + { dg-options "-Wall -Winfinite-recursion" } */ + +#define NORETURN __attribute__ ((noreturn)) + +typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void exit (int); + +extern int ei; +int (*pfi_v)(void); + + +/* Make sure the warning doesn't assume every call has a DECL. */ + +int nowarn_pfi_v (void) +{ + return pfi_v (); +} + + +int warn_fi_v (void) // { dg-warning "-Winfinite-recursion" } +{ + return warn_fi_v (); // { dg-message "recursive call" } +} + +/* Verify #pragma suppression works. */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winfinite-recursion" + +int suppress_warn_fi_v (void) +{ + return warn_fi_v (); +} + +#pragma GCC diagnostic pop + + +int nowarn_fi_v (void) +{ + if (ei++ == 0) + return nowarn_fi_v (); + return 0; +} + +int warn_if_i (int i) // { dg-warning "-Winfinite-recursion" } +{ + if (i > 0) + return warn_if_i (--i); // { dg-message "recursive call" } + else if (i < 0) + return warn_if_i (-i); // { dg-message "recursive call" } + else + return warn_if_i (7); // { dg-message "recursive call" } +} + + +int nowarn_if_i (int i) +{ + if (i > 0) + return nowarn_if_i (--i); + else if (i < 0) + return nowarn_if_i (-i); + else + return -1; +} + +int nowarn_switch (int i, int a[]) +{ + switch (i) + { + case 0: return nowarn_switch (a[3], a + 1); + case 1: return nowarn_switch (a[5], a + 2); + case 2: return nowarn_switch (a[7], a + 3); + case 3: return nowarn_switch (a[9], a + 4); + } + return 77; +} + +int warn_switch (int i, int a[]) // { dg-warning "-Winfinite-recursion" } +{ + switch (i) + { + case 0: return warn_switch (a[3], a + 1); + case 1: return warn_switch (a[5], a + 2); + case 2: return warn_switch (a[7], a + 3); + case 3: return warn_switch (a[9], a + 4); + default: return warn_switch (a[1], a + 5); + } +} + +NORETURN void fnoreturn (void); + +/* Verify there's no warning for a function that doesn't return. */ +int nowarn_call_noret (void) +{ + fnoreturn (); +} + +int warn_call_noret_r (void) // { dg-warning "-Winfinite-recursion" } +{ + warn_call_noret_r (); // { dg-message "recursive call" } + fnoreturn (); +} + +/* Verify a warning even though the abort() call would prevent the infinite + recursion. There's no good way to tell the two cases apart and letting + a simple abort prevent the warning would make it ineffective in cases + where it's the result of assert() expansion and not meant to actually + prevent recursion. */ + +int +warn_noret_call_abort_r (char *s, int n) // { dg-warning "-Winfinite-recursion" } +{ + if (!s) + abort (); + + if (n > 7) + abort (); + + return n + warn_noret_call_abort_r (s, n - 1); // { dg-message "recursive call" } +} + +/* Verify that a warning is not issued for an apparently infinitely + recursive function like the one above where the recursion would be + prevented by a call to a noreturn function if the recursive function + is itself declared noreturn. */ + +NORETURN void nowarn_noret_call_abort_r (int n) +{ + if (n > 7) + abort (); + + nowarn_noret_call_abort_r (n - 1); +} + +int warn_call_abort_r (int n) // { dg-warning "-Winfinite-recursion" } +{ + n += warn_call_abort_r (n - 1); // { dg-message "recursive call" } + if (n > 7) // unreachable + abort (); + return n; +} + + +/* And again with exit() for good measure. */ + +int warn_call_exit_r (int n) // { dg-warning "-Winfinite-recursion" } +{ + n += warn_call_exit_r (n - 1); // { dg-message "recursive call" } + if (n > 7) + exit (0); + return n; +} + +struct __jmp_buf_tag { }; +typedef struct __jmp_buf_tag jmp_buf[1]; + +extern jmp_buf jmpbuf; + +/* A call to longjmp() breaks infinite recursion. Verify it suppresses + the warning. */ + +int nowarn_call_longjmp_r (int n) +{ + if (n > 7) + __builtin_longjmp (jmpbuf, 1); + return n + nowarn_call_longjmp_r (n - 1); +} + +int warn_call_longjmp_r (int n) // { dg-warning "-Winfinite-recursion" } +{ + n += warn_call_longjmp_r (n - 1); // { dg-message "recursive call" } + if (n > 7) + __builtin_longjmp (jmpbuf, 1); + return n; +} + + +struct __sigjmp_buf_tag { }; +typedef struct __sigjmp_buf_tag sigjmp_buf[1]; + +extern sigjmp_buf sigjmpbuf; + +/* GCC has no __builtin_siglongjmp(). */ +extern void siglongjmp (sigjmp_buf, int); + +/* A call to longjmp() breaks infinite recursion. Verify it suppresses + the warning. */ + +int nowarn_call_siglongjmp_r (int n) +{ + if (n > 7) + siglongjmp (sigjmpbuf, 1); + return n + nowarn_call_siglongjmp_r (n - 1); +} + + +int nowarn_while_do_call_r (int n) +{ + int z = 0; + while (n) + z += nowarn_while_do_call_r (n--); + return z; +} + +int warn_do_while_call_r (int n) // { dg-warning "-Winfinite-recursion" } +{ + int z = 0; + do + z += warn_do_while_call_r (n); // { dg-message "recursive call" } + while (--n); + return z; +} + +/* Verify warnings for a naive replacement of a built-in fucntion. */ + +void* malloc (size_t n) // { dg-warning "-Winfinite-recursion" } +{ + size_t *p = + (size_t*)__builtin_malloc (n + sizeof n); // { dg-message "recursive call" } + *p = n; + return p + 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wint-conversion-2.c b/SingleSource/Regression/C/gcc-dg/Wint-conversion-2.c new file mode 100644 index 0000000000..bf590a7bcd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wint-conversion-2.c @@ -0,0 +1,12 @@ +/* PR middle-end/86202 - ICE in get_range_info calling an invalid memcpy() + declaration */ +/* { dg-do compile } */ +/* { dg-options "-Wint-conversion" } */ + +void *memcpy (void *, void *, __SIZE_TYPE__ *); /* { dg-warning "conflicting types for built-in function .memcpy." } */ +void *a, *b; +void f (void) +{ + long unsigned int c = 0; + memcpy (a, b, c); /* { dg-warning "passing argument" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wint-conversion.c b/SingleSource/Regression/C/gcc-dg/Wint-conversion.c new file mode 100644 index 0000000000..1b7a03e431 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wint-conversion.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-int-conversion" } */ + +int fn1 (int *), *fn2 (int); + +int +fn1 (int *p) +{ + int i = p; + i = p; + fn2 (p); + return p; +} + +int * +fn2 (int i) +{ + int *p = i; + p = i; + fn1 (i); + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wint-in-bool-context-4.c b/SingleSource/Regression/C/gcc-dg/Wint-in-bool-context-4.c new file mode 100644 index 0000000000..0e96dd7bd7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wint-in-bool-context-4.c @@ -0,0 +1,35 @@ +/* PR c/102245 */ +/* { dg-options "-Wint-in-bool-context" } */ +/* { dg-do compile } */ + +_Bool test1(_Bool x) +{ + return !(x << 0); /* { dg-warning "boolean context" } */ +} + +_Bool test2(_Bool x) +{ + return !(x << 1); /* { dg-warning "boolean context" } */ +} + +_Bool test3(_Bool x, int y) +{ + return !(x << y); /* { dg-warning "boolean context" } */ +} + +_Bool test4(int x, int y) +{ + return !(x << y); /* { dg-warning "boolean context" } */ +} + +_Bool test5(int x, int y) +{ + return !((x << y) << 0); /* { dg-warning "boolean context" } */ +} + +int test6(_Bool x) +{ + int v = 0; + return (v & ~1L) | (1L & (x << 0)); /* { dg-bogus "boolean context" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wjump-misses-init-1.c b/SingleSource/Regression/C/gcc-dg/Wjump-misses-init-1.c new file mode 100644 index 0000000000..71809be593 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wjump-misses-init-1.c @@ -0,0 +1,156 @@ +/* { dg-do compile } */ +/* { dg-options "-Wjump-misses-init -Wno-switch-unreachable" } */ +int +f1 (int a) +{ + if (a > 0) + { + int i = 7; /* { dg-message "here" } */ + lab: /* { dg-message "here" } */ + return a; + } + else + { + if (a < 0) + goto lab; /* { dg-warning "jump" } */ + return 1; + } +} + +int +f2 (int a) +{ + if (a > 0) + { + if (a < 0) + goto lab; /* { dg-warning "jump" } */ + return 1; + } + else + { + int i = 7; /* { dg-message "here" } */ + lab: /* { dg-message "here" } */ + return a; + } +} + +int +f3 (int a) +{ + if (a > 0) + { + static int i = 7; + lab: + return a; + } + else + { + if (a < 0) + goto lab; + return 1; + } +} + +int +f4 (int a) +{ + if (a > 0) + { + if (a < 0) + goto lab; + return 1; + } + else + { + static int i = 7; + lab: + return a; + } +} + +int +f5 (int a) +{ + if (a > 0) + { + int b = 1; + if (a < 0) + goto lab; + } + lab: + return a; +} + +int +f6 (int a) +{ + if (a > 0) + { + lab: + return a; + } + else + { + int b = 1; + goto lab; + } +} + +int +f7 (int a) +{ + switch (a) /* { dg-message "switch" } */ + { + int b = 1; /* { dg-message "here" } */ + + case 1: /* { dg-warning "jump" } */ + return a; + } +} + +int +f8 (int a) +{ + switch (a) /* { dg-message "switch" } */ + { + int b = 1; /* { dg-message "here" } */ + + case 1: /* { dg-warning "jump" } */ + goto lab; + } + lab: + return a; +} + +int +f9 (int a) +{ + switch (a) + { + case 0: + { + int b = 1; + return b; + } + case 1: + return a; + } +} + +int +f10 (int a) +{ + switch (a) + { + case 0: + { + int b = 1; + goto lab; + } + + case 1: + goto lab; + } + lab: + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wjump-misses-init-2.c b/SingleSource/Regression/C/gcc-dg/Wjump-misses-init-2.c new file mode 100644 index 0000000000..042c02aa7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wjump-misses-init-2.c @@ -0,0 +1,52 @@ +/* { dg-do compile } */ +/* { dg-options "-Wjump-misses-init -std=c99" } */ +extern void f1 (); +int +f2 (int a) +{ + switch (a) /* { dg-message "switch" } */ + { + case 1: + f1 (); + int v2 = 3; /* { dg-message "here" } */ + case 2: /* { dg-warning "jump" } */ + if (v2 == 7) + f1 (); + } + return 0; +} + +int +f3 (int i) +{ + if (i) + goto bad; /* { dg-warning "jump" } */ + int a = f2 (i); /* { dg-message "here" } */ + bad: /* { dg-message "here" } */ + return a; +} + +int +f4 (int a) +{ + switch (a) + { + case 1: + f1 (); + static int v2 = 3; + case 2: + if (v2 == 7) + f1 (); + } + return 0; +} + +int +f5 (int i) +{ + if (i) + goto bad; + static int a = 6; + bad: + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wlarger-than.c b/SingleSource/Regression/C/gcc-dg/Wlarger-than.c new file mode 100644 index 0000000000..609a7ae4ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wlarger-than.c @@ -0,0 +1,10 @@ +/* Copyright (C) 2000 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-Wlarger-than-32768" } */ + +/* -Wlarger-than with functions returning void used to segfault. + Source: PR 602, testsuite-ized by Neil Booth 21 Jan 2000. */ + +static void foo (void) {} + diff --git a/SingleSource/Regression/C/gcc-dg/Wlarger-than2.c b/SingleSource/Regression/C/gcc-dg/Wlarger-than2.c new file mode 100644 index 0000000000..eac67f48b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wlarger-than2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-Wlarger-than=8" } */ +static void foo (void) +{ + char buf[9]; /* { dg-warning "size of.*9 bytes" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wlarger-than3.c b/SingleSource/Regression/C/gcc-dg/Wlarger-than3.c new file mode 100644 index 0000000000..17af07b72e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wlarger-than3.c @@ -0,0 +1,13 @@ +/* Exercise -Wlarger-than= with a byte-size suffix. + { dg-do compile } + { dg-skip-if "small address space" { "pdp11-*-*" } { "avr-*-*" } } + { dg-options "-Wlarger-than=1MiB" } */ + +#define MB (1000 * 1000) /* MegaByte */ +#define MiB (1024 * 1024) /* MebiByte */ + +char megabyte[MB]; +char membibyte[MiB]; + +char megabyte_plus_1[MB + 1]; +char membibyte_plus_1[MiB + 1]; /* { dg-warning "size of .membibyte_plus_1. 1048577 bytes exceeds maximum object size 1048576" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wlarger-than4.c b/SingleSource/Regression/C/gcc-dg/Wlarger-than4.c new file mode 100644 index 0000000000..dd936c671c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wlarger-than4.c @@ -0,0 +1,5 @@ +/* PR 90983/manual documents `-Wno-stack-usage` flag, but it is unrecognized + { dg-do compile } + { dg-options "-Wall -Wlarger-than=123 -Wno-larger-than" } */ + +char a [1234]; diff --git a/SingleSource/Regression/C/gcc-dg/Wlogical-op-1.c b/SingleSource/Regression/C/gcc-dg/Wlogical-op-1.c new file mode 100644 index 0000000000..462b90beaf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wlogical-op-1.c @@ -0,0 +1,77 @@ +/* + { dg-do compile } + { dg-options "-Wlogical-op" } +*/ + +enum { a, ba, b }; + +enum testenum { t1, t2}; + +extern int c; +extern char bool_a, bool_b; + +extern int testa(); + +void foo() +{ + if ( testa() && b ) /* { dg-warning "logical" } */ + (void)testa(); + + if ( c && b ) /* { dg-warning "logical" } */ + (void)testa(); + + if ( c && 0x42 ) /* { dg-warning "logical" } */ + (void)testa(); + + if ( c && 0x80 >>6) /* { dg-warning "logical" } */ + (void)testa(); + + + if ( b && c == a ) /* { dg-bogus "logical" } */ + (void)testa(); + + if ( 1 && c ) /* { dg-bogus "logical" } */ + (void)testa(); + + if ( t2 && b ) /* { dg-bogus "logical" } */ + (void)testa(); + + if ( 0 && c == a ) /* { dg-bogus "logical" } */ + (void)testa(); + + if ( b && 1 ) /* { dg-bogus "logical" } */ + (void)testa(); +} + + +void bar() +{ + if ( testa() || b ) /* { dg-warning "logical" } */ + (void)testa(); + + if ( c || b ) /* { dg-warning "logical" } */ + (void)testa(); + + if ( c || 0x42 ) /* { dg-warning "logical" } */ + (void) testa(); + + if ( c || 0x80 >>6) /* { dg-warning "logical" } */ + (void)testa(); + + + if ( b || c == a ) /* { dg-bogus "logical" } */ + (void)testa(); + + if ( 1 || c ) /* { dg-bogus "logical" } */ + (void)testa(); + + if ( t2 || b ) /* { dg-bogus "logical" } */ + (void)testa(); + + if ( 0 || c == a ) /* { dg-bogus "logical" } */ + (void)testa(); + + if ( b || 1 ) /* { dg-bogus "logical" } */ + (void)testa(); +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc-2.c b/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc-2.c new file mode 100644 index 0000000000..c303d2f177 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc-2.c @@ -0,0 +1,142 @@ +/* PR middle-end/94527 - Add an attribute that marks a function as freeing + an object + Verify that attribute malloc with one or two arguments has the expected + effect on diagnostics. + { dg-options "-Wall -ftrack-macro-expansion=0" } */ + +#define A(...) __attribute__ ((malloc (__VA_ARGS__), noipa)) + +typedef __SIZE_TYPE__ size_t; +typedef struct A A; +typedef struct B B; + +/* A pointer returned by any of the four functions must be deallocated + either by dealloc() or by realloc_{A,B}(). */ +A (__builtin_free) A* alloc_A (int); +A (__builtin_free) B* alloc_B (int); +A (__builtin_free) A* realloc_A (A *p, int n) { return p; } +A (__builtin_free) B* realloc_B (B *p, int n) { return p; } + +A (realloc_A) A* alloc_A (int); +A (realloc_B) B* alloc_B (int); +A (realloc_A) A* realloc_A (A*, int); +A (realloc_B) B* realloc_B (B*, int); + +void dealloc (void*); +A (dealloc) void* alloc (int); + +void sink (void*); +void* source (void); + +void test_alloc_A (void) +{ + { + void *p = alloc_A (1); + p = realloc_A (p, 2); + __builtin_free (p); + } + + { + void *p = alloc_A (1); + /* Verify that calling realloc doesn't trigger a warning even though + alloc_A is not directly associated with it. */ + p = __builtin_realloc (p, 2); + sink (p); + } + + { + void *p = alloc_A (1); // { dg-message "returned from 'alloc_A'" } + dealloc (p); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } + + { + /* Because alloc_A() and realloc_B() share free() as a deallocator + they must also be valid as each other's deallocators. */ + void *p = alloc_A (1); + p = realloc_B ((B*)p, 2); + __builtin_free (p); + } + + { + void *p = alloc_A (1); + p = realloc_A (p, 2); + p = __builtin_realloc (p, 3); + __builtin_free (p); + } +} + + +void test_realloc_A (void *ptr) +{ + { + void *p = realloc_A (0, 1); + p = realloc_A (p, 2); + __builtin_free (p); + } + + { + void *p = realloc_A (ptr, 2); + p = realloc_A (p, 2); + __builtin_free (p); + } + + { + void *p = realloc_A (0, 3); + p = __builtin_realloc (p, 2); + sink (p); + } + + { + void *p = realloc_A (0, 4); // { dg-message "returned from 'realloc_A'" } + dealloc (p); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } + + { + /* Because realloc_A() and realloc_B() share free() as a deallocator + they must also be valid as each other's deallocators. */ + void *p = realloc_A (0, 5); + p = realloc_B ((B*)p, 2); + __builtin_free (p); + } + + { + void *p = realloc_A (0, 6); + p = realloc_A ((A*)p, 2); + p = __builtin_realloc (p, 3); + __builtin_free (p); + } +} + + +void test_realloc (void) +{ + extern void free (void*); + extern void* realloc (void*, size_t); + + { + void *p = realloc (source (), 1); + p = realloc_A (p, 2); + __builtin_free (p); + } + + { + void *p = realloc (source (), 2); + p = realloc_A (p, 2); + free (p); + } + + { + void *p = realloc (source (), 3); + free (p); + } + + { + void *p = realloc (source (), 4); + __builtin_free (p); + } + + { + void *p = realloc (source (), 5); // { dg-message "returned from 'realloc'" } + dealloc (p); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc-3.c b/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc-3.c new file mode 100644 index 0000000000..302900662c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc-3.c @@ -0,0 +1,270 @@ +/* Verify that Glibc declarations are handled correctly + { dg-do compile } + { dg-options "-Wall" } */ + +#define A(...) __attribute__ ((malloc (__VA_ARGS__), noipa)) + +typedef __SIZE_TYPE__ size_t; + +/* All functions with the same standard deallocator are associated + with each other. */ +void free (void*); +void* calloc (size_t, size_t); +void* malloc (size_t); +void* realloc (void*, size_t); + +A (__builtin_free) void* aligned_alloc (size_t, size_t); + +/* Like realloc(), reallocarray() is both an allocator and a deallocator. + It must be associated with both free() and with itself, but nothing + else. */ +A (__builtin_free) void* reallocarray (void*, size_t, size_t); +A (reallocarray) void* reallocarray (void*, size_t, size_t); + +A (__builtin_free) extern char *canonicalize_file_name (const char*); + + +void dealloc (void*); +A (dealloc) void* alloc (size_t); + + +void sink (void*); +void* source (void); + + +void test_builtin_aligned_alloc (void *p) +{ + { + void *q = __builtin_aligned_alloc (1, 2); + sink (q); + __builtin_free (q); + } + + { + void *q = __builtin_aligned_alloc (1, 2); + sink (q); + free (q); + } + + { + void *q = __builtin_aligned_alloc (1, 2); + q = __builtin_realloc (q, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_aligned_alloc (1, 2); + q = realloc (q, 3); + sink (q); + free (q); + } + + { + void *q; + q = __builtin_aligned_alloc (1, 2); // { dg-message "returned from '__builtin_aligned_alloc'" } + sink (q); + dealloc (q); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_aligned_alloc (void *p) +{ + { + void *q = aligned_alloc (1, 2); + sink (q); + __builtin_free (q); + } + + { + void *q = aligned_alloc (1, 2); + sink (q); + free (q); + } + + { + void *q = aligned_alloc (1, 2); + q = __builtin_realloc (q, 3); + sink (q); + free (q); + } + + { + void *q = aligned_alloc (1, 2); + q = realloc (q, 3); + sink (q); + free (q); + } + + { + void *q = aligned_alloc (1, 2); // { dg-message "returned from 'aligned_alloc'" } + sink (q); + dealloc (q); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_reallocarray (void *p) +{ + { + void *q = __builtin_aligned_alloc (1, 2); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = aligned_alloc (1, 2); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_calloc (1, 2); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = calloc (1, 2); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_malloc (1); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = malloc (1); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_realloc (p, 1); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + p = source (); + void *q = realloc (p, 1); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_strdup ("abc"); + q = reallocarray (q, 3, 4); + sink (q); + free (q); + } + + { + void *q = __builtin_strndup ("abcd", 3); + q = reallocarray (q, 4, 5); + sink (q); + free (q); + } + + { + void *q = source (); + q = reallocarray (q, 5, 6); + sink (q); + free (q); + } + + { + void *q = alloc (1); // { dg-message "returned from 'alloc'" } + q = reallocarray (q, 6, 7); // { dg-warning "'reallocarray' called on pointer returned from a mismatched allocation function" } + sink (q); + free (q); + } + + { + p = source (); + void *q = reallocarray (p, 7, 8); + q = __builtin_realloc (q, 9); + sink (q); + free (q); + } + + { + p = source (); + void *q = reallocarray (p, 7, 8); + q = realloc (q, 9); + sink (q); + free (q); + } + + { + p = source (); + void *q = reallocarray (p, 8, 9); + q = reallocarray (q, 3, 4); + sink (q); + free (q); + } + + { + p = source (); + void *q = reallocarray (p, 9, 10); + q = reallocarray (q, 3, 4); + sink (q); + dealloc (q); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_canonicalize_filename (void *p) +{ + { + void *q = canonicalize_file_name ("a"); + sink (q); + __builtin_free (q); + } + + { + void *q = canonicalize_file_name ("b"); + sink (q); + free (q); + } + + { + void *q = canonicalize_file_name ("c"); + q = __builtin_realloc (q, 2); + sink (q); + free (q); + } + + { + void *q = canonicalize_file_name ("d"); + q = realloc (q, 3); + sink (q); + free (q); + } + + { + void *q = canonicalize_file_name ("e"); + q = reallocarray (q, 4, 5); + sink (q); + free (q); + } + + { + void *q; + q = canonicalize_file_name ("f"); // { dg-message "returned from 'canonicalize_file_name'" } + sink (q); + dealloc (q); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc.c b/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc.c new file mode 100644 index 0000000000..6336efa559 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmismatched-dealloc.c @@ -0,0 +1,327 @@ +/* PR middle-end/94527 - Add an attribute that marks a function as freeing + an object + Verify that attribute malloc with one or two arguments has the expected + effect on diagnostics. + { dg-options "-Wall -ftrack-macro-expansion=0" } */ + +#define A(...) __attribute__ ((malloc (__VA_ARGS__))) + +typedef struct FILE FILE; +typedef __SIZE_TYPE__ size_t; + +void free (void*); +void* malloc (size_t); +void* realloc (void*, size_t); + +/* Declare functions with the minimum attributes malloc how they're + likely going to be declared in . */ + int fclose (FILE*); +A (fclose) FILE* fdopen (int); +A (fclose) FILE* fopen (const char*, const char*); +A (fclose) FILE* fmemopen(void *, size_t, const char *); +A (fclose) FILE* freopen (const char*, const char*, FILE*); +A (freopen, 3) FILE* freopen (const char*, const char*, FILE*); +A (fclose) FILE* tmpfile (void); + +A (fclose) FILE* open_memstream (char**, size_t*); +A (fclose) FILE* open_wmemstream (char**, size_t*); + + int pclose (FILE*); +A (pclose) FILE* popen (const char*, const char*); + + void release (void*); +A (release) FILE* acquire (void); + +void sink (FILE*); + + +void nowarn_fdopen (void) +{ + { + FILE *q = fdopen (0); + if (!q) + return; + + fclose (q); + } + + { + FILE *q = fdopen (0); + if (!q) + return; + + q = freopen ("1", "r", q); + fclose (q); + } + + { + FILE *q = fdopen (0); + if (!q) + return; + + sink (q); + } +} + + +void warn_fdopen (void) +{ + { + FILE *q = fdopen (0); // { dg-message "returned from 'fdopen'" "note" } + sink (q); + release (q); // { dg-warning "'release' called on pointer returned from a mismatched allocation function" } + } + { + FILE *q = fdopen (0); // { dg-message "returned from 'fdopen'" "note" } + sink (q); + free (q); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *q = fdopen (0); // { dg-message "returned from 'fdopen'" "note" } + sink (q); + q = realloc (q, 7); // { dg-warning "'realloc' called on pointer returned from a mismatched allocation function" } + sink (q); + } +} + + +void nowarn_fopen (void) +{ + { + FILE *q = fopen ("1", "r"); + sink (q); + fclose (q); + } + + { + FILE *q = fopen ("2", "r"); + sink (q); + q = freopen ("3", "r", q); + sink (q); + fclose (q); + } + + { + FILE *q = fopen ("4", "r"); + sink (q); + } +} + + +void warn_fopen (void) +{ + { + FILE *q = fopen ("1", "r"); + sink (q); + release (q); // { dg-warning "'release' called on pointer returned from a mismatched allocation function" } + } + { + FILE *q = fdopen (0); + sink (q); + free (q); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *q = fdopen (0); + sink (q); + q = realloc (q, 7); // { dg-warning "'realloc' called on pointer returned from a mismatched allocation function" } + sink (q); + } +} + + +void test_freopen (FILE *p[]) +{ + { + FILE *q = freopen ("1", "r", p[0]); + sink (q); + fclose (q); + } + { + FILE *q = freopen ("2", "r", p[1]); + sink (q); + q = freopen ("3", "r", q); + sink (q); + fclose (q); + } + + { + FILE *q; + q = freopen ("3", "r", p[2]); // { dg-message "returned from 'freopen'" } + sink (q); + q = realloc (q, 7); // { dg-warning "'realloc' called on pointer returned from a mismatched allocation function" } + sink (q); + } +} + + +void test_tmpfile (void) +{ + { + FILE *p = tmpfile (); + sink (p); + fclose (p); + } + + { + FILE *p = tmpfile (); + sink (p); + p = freopen ("1", "r", p); + sink (p); + fclose (p); + } + + { + FILE *p = tmpfile (); // { dg-message "returned from 'tmpfile'" "note" } + sink (p); + pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_open_memstream (char **bufp, size_t *sizep) +{ + { + FILE *p = open_memstream (bufp, sizep); + sink (p); + fclose (p); + } + + { + FILE *p = open_memstream (bufp, sizep); + sink (p); + p = freopen ("1", "r", p); + sink (p); + fclose (p); + } + + { + FILE *p; + p = open_memstream (bufp, sizep); // { dg-message "returned from 'open_memstream'" "note" } + sink (p); + pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p; + p = open_memstream (bufp, sizep); // { dg-message "returned from 'open_memstream'" "note" } + sink (p); + free (p); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p; + p = open_memstream (bufp, sizep); // { dg-message "returned from 'open_memstream'" "note" } + sink (p); + release (p); // { dg-warning "'release' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_open_wmemstream (char **bufp, size_t *sizep) +{ + { + FILE *p = open_wmemstream (bufp, sizep); + sink (p); + fclose (p); + } + + { + FILE *p = open_wmemstream (bufp, sizep); + sink (p); + p = freopen ("1", "r", p); + sink (p); + fclose (p); + } + + { + FILE *p; + p = open_wmemstream (bufp, sizep); // { dg-message "returned from 'open_wmemstream'" "note" } + sink (p); + pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p; + p = open_wmemstream (bufp, sizep); // { dg-message "returned from 'open_wmemstream'" "note" } + sink (p); + free (p); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p; + p = open_wmemstream (bufp, sizep); // { dg-message "returned from 'open_wmemstream'" "note" } + sink (p); + release (p); // { dg-warning "'release' called on pointer returned from a mismatched allocation function" } + } +} + + +void warn_malloc (void) +{ + { + FILE *p = malloc (100); // { dg-message "returned from 'malloc'" "note" } + sink (p); + fclose (p); // { dg-warning "'fclose' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p = malloc (100); // { dg-message "returned from 'malloc'" "note" } + sink (p); + p = freopen ("1", "r", p);// { dg-warning "'freopen' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p = malloc (100); // { dg-message "returned from 'malloc'" "note" } + sink (p); + pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_acquire (void) +{ + { + FILE *p = acquire (); + release (p); + } + + { + FILE *p = acquire (); + sink (p); + release (p); + } + + { + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } + sink (p); + fclose (p); // { dg-warning "'fclose' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } + sink (p); + pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } + sink (p); + p = freopen ("1", "r", p); // { dg-warning "'freopen' called on pointer returned from a mismatched allocation function" } + sink (p); + } + + { + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } + sink (p); + free (p); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } + sink (p); + p = realloc (p, 123); // { dg-warning "'realloc' called on pointer returned from a mismatched allocation function" } + sink (p); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-attributes.c b/SingleSource/Regression/C/gcc-dg/Wmissing-attributes.c new file mode 100644 index 0000000000..049a4c095b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-attributes.c @@ -0,0 +1,96 @@ +/* PR middle-end/81824 - Warn for missing attributes with function aliases + { dg-do compile } + { dg-require-alias "" } + { dg-options "-Wall" } */ + +#define ATTR(list) __attribute__ (list) + + +int alias_no_const (void); + +ATTR ((const)) int +target_const (void) /* { dg-message ".alias_no_const. target declared here" } */ +{ return 0; } + +ATTR ((alias ("target_const"))) int +alias_no_const (void); /* { dg-warning ".alias_no_const. specifies less restrictive attribute than its target .target_const.: .const." } */ + + +ATTR ((alloc_size (1), malloc)) void* +target_malloc (int n) /* { dg-message ".alias_no_malloc. target declared here" } */ +{ return __builtin_malloc (n); } + +ATTR ((alias ("target_malloc"))) void* +alias_no_malloc (int); /* { dg-warning ".alias_no_malloc. specifies less restrictive attributes than its target .target_malloc.: .alloc_size., .malloc." } */ + + +ATTR ((leaf)) int +target_leaf (void) /* { dg-message ".alias_no_leaf. target declared here" } */ +{ return 0; } + +ATTR ((alias ("target_leaf"))) int +alias_no_leaf (void); /* { dg-warning ".alias_no_leaf. specifies less restrictive attribute than its target .target_leaf.: .leaf." } */ + + +/* Verify that attributes noclone, noinline, and noipa on the target + don't cause a warning for aliases without the attribute. */ + +ATTR ((noclone)) int +target_noclone (void) +{ return 0; } + +ATTR ((alias ("target_noclone"))) int +alias_no_noclone (void); + + +ATTR ((noipa)) int +target_noipa (void) +{ return 0; } + +ATTR ((alias ("target_noipa"))) int +alias_no_noipa (void); + + +ATTR ((noinline)) int +target_noinline (void) +{ return 0; } + +ATTR ((alias ("target_noinline"))) int +alias_no_noinline (void); + + +ATTR ((nothrow)) int +target_nothrow (void) /* { dg-message ".alias_no_nothrow. target declared here" } */ +{ return 0; } + +ATTR ((alias ("target_nothrow"))) int +alias_no_nothrow (void); /* { dg-warning ".alias_no_nothrow. specifies less restrictive attribute than its target .target_nothrow.: .nothrow." } */ + + +/* Verify that attribute weak on the target doesn't cause and isn't + mentioned in a warning for aliases without the attribute. */ + +ATTR ((weak)) int +target_weak (void) +{ return 0; } + +ATTR ((alias ("target_weak"))) int +alias_no_weak (void); + + +ATTR ((nothrow, weak)) int +target_nothrow_weak (void) /* { dg-message ".alias_nothrow_no_weak. target declared here" } */ +{ return 0; } + +ATTR ((alias ("target_nothrow_weak"))) int +alias_nothrow_no_weak (void); /* { dg-warning ".alias_nothrow_no_weak. specifies less restrictive attribute than its target .target_nothrow_weak.: .nothrow." } */ + + +/* Verify that __typeof__ doesn't include attributes. */ + +ATTR ((cold)) int +target_cold (void) +{ return 0; } + +__typeof__ (target_cold) ATTR ((alias ("target_cold"))) +alias_cold; /* { dg-warning ".alias_cold. specifies less restrictive attribute than its target .target_cold.: .cold." } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-braces-fixits.c b/SingleSource/Regression/C/gcc-dg/Wmissing-braces-fixits.c new file mode 100644 index 0000000000..2cce217369 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-braces-fixits.c @@ -0,0 +1,189 @@ +/* { dg-options "-Wmissing-braces -fdiagnostics-show-caret" } */ + +struct sf2 { int i; int j; }; +struct sf3 { int i; int j; int k; }; +struct sa2 { int arr[2]; }; +struct sa3 { int arr[3]; }; + +int arr_12[12] = \ + { 0, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11}; + +int arr_12_1[12][1] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + {} {} {} {} {} {} + 6, 7, 8, 9, 10, 11}; + {} {} {} {} { } { } + { dg-end-multiline-output "" } */ + +int arr_1_12[1][12] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + { + 6, 7, 8, 9, 10, 11}; + } + { dg-end-multiline-output "" } */ + +int arr_2_6[2][6] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + { } + 6, 7, 8, 9, 10, 11}; + { } + { dg-end-multiline-output "" } */ + +int arr_2_2_3[2][2][3] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + {{ } { }} + 6, 7, 8, 9, 10, 11}; + {{ } { }} + { dg-end-multiline-output "" } */ + +int arr_2_3_2[2][3][2] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + {{ } { } { }} + 6, 7, 8, 9, 10, 11}; + {{ } { } { }} + { dg-end-multiline-output "" } */ + +int arr_6_2[6][2] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + { } { } { } + 6, 7, 8, 9, 10, 11}; + { } { } { } + { dg-end-multiline-output "" } */ + +int arr_3_2_2[3][2][2] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + {{ } { }}{{ } + 6, 7, 8, 9, 10, 11}; + { }}{{ } { }} + { dg-end-multiline-output "" } */ + +int arr_3_4[3][4] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + { } { + 6, 7, 8, 9, 10, 11}; + } { } + { dg-end-multiline-output "" } */ + +int arr_4_3[4][3] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + { } { } + 6, 7, 8, 9, 10, 11}; + { } { } + { dg-end-multiline-output "" } */ + +int arr_2_1_6[2][1][6] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + {{ }} + 6, 7, 8, 9, 10, 11}; + {{ }} + { dg-end-multiline-output "" } */ + +struct sf2 arr_6_sf2[6] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + { } { } { } + 6, 7, 8, 9, 10, 11}; + { } { } { } + { dg-end-multiline-output "" } */ + +struct sf3 arr_4_sf3[4] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + { } { } + 6, 7, 8, 9, 10, 11}; + { } { } + { dg-end-multiline-output "" } */ + +struct sa2 arr_6_sa2[6] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + {{ }}{{ }}{{ }} + 6, 7, 8, 9, 10, 11}; + {{ }}{{ }}{{ }} + { dg-end-multiline-output "" } */ + +struct sa3 arr_4_sa3[4] = \ + { 0, 1, 2, 3, 4, 5, /* { dg-warning "missing braces around initializer" } */ + 6, 7, 8, 9, 10, 11}; + /* { dg-begin-multiline-output "" } + { 0, 1, 2, 3, 4, 5, + ^ + {{ }}{{ }} + 6, 7, 8, 9, 10, 11}; + {{ }}{{ }} + { dg-end-multiline-output "" } */ + +/* PR c/81405. */ +int a5[][0][0] = { 1, 2 }; /* { dg-line pr_81405 } */ + + /* { dg-warning "missing braces around initializer" "" { target c } pr_81405 } */ + /* { dg-begin-multiline-output "" } + int a5[][0][0] = { 1, 2 }; + ^ + { ----- + {{1}}}}, {{{2 }} + { dg-end-multiline-output "" } */ + + /* { dg-warning "excess elements" "" { target c } pr_81405 } */ + /* { dg-begin-multiline-output "" } + int a5[][0][0] = { 1, 2 }; + ^ + { dg-end-multiline-output "" } */ + /* { dg-begin-multiline-output "" } + int a5[][0][0] = { 1, 2 }; + ^ + { dg-end-multiline-output "" } */ + /* { dg-begin-multiline-output "" } + int a5[][0][0] = { 1, 2 }; + ^~~ + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-1.c b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-1.c new file mode 100644 index 0000000000..fbcca44db5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-1.c @@ -0,0 +1,22 @@ +/* PR c/82283 */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-field-initializers" } */ + +struct A { + int *a; + int b; +}; + +struct B { + struct A a; +}; + +struct B data1 = { + .a.a = &(int){ 0 }, + .a.b = 13 /* { dg-bogus "missing initializer" } */ +}; + +struct B data2 = { + .a.b = 0, + .a.a = & (int) { 0 } +}; diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-2.c b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-2.c new file mode 100644 index 0000000000..cb42968a49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-2.c @@ -0,0 +1,11 @@ +/* PR c/84685 */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-field-initializers" } */ + +struct T { + int a; + int *b; + int c; +}; + +struct T t = { .b = (int[]){1} }; /* { dg-bogus "missing initializer" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-3.c b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-3.c new file mode 100644 index 0000000000..5512d97d12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-3.c @@ -0,0 +1,24 @@ +/* PR c/84685 */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-field-initializers" } */ + +struct T +{ + int a; + int *b; + int c; + int d; + int *e; + int f; + int g; + int h; +}; + +struct T foo(int bar); + +struct T foo(int bar) +{ + struct T t = { .b = (int[]){ 1 }, .e = (int[]){ 2 } }; /* { dg-bogus "missing initializer" } */ + t.c = bar; + return t; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-4.c b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-4.c new file mode 100644 index 0000000000..57e4e4d337 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-4.c @@ -0,0 +1,43 @@ +/* PR c/82283 */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-field-initializers" } */ + +struct a { + int b; +}; + +struct c { + struct a d; + int e; +}; + +void f (struct c *); + +void +g (void) +{ + struct c h = {.d = (struct a){0}}; /* { dg-bogus "missing initializer" } */ + f(&h); +} + +struct { + struct { + int a; + int b; + } c[1]; +} d = { + .c[0].a = 1, + .c[0].b = 1, /* { dg-bogus "missing initializer" } */ +}; + +struct test_t { + int value1; + int value2; +}; + +struct test_t test[] = { + [0].value1 = 1, + [0].value2 = 2, /* { dg-bogus "missing initializer" } */ + [1].value1 = 10, + [1].value2 = 20 /* { dg-bogus "missing initializer" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-5.c b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-5.c new file mode 100644 index 0000000000..7cf5df1776 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-field-initializers-5.c @@ -0,0 +1,22 @@ +/* PR c/82283 */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-field-initializers" } */ + +struct foo { + const char *a1; + const char * const *a2; + void *a3; + void *a4; +}; + +const char *aux[] = { "y", 0 }; + +struct foo a = { + .a1 = "x", + .a2 = (const char * const []){ "y", 0 }, +}; /* { dg-bogus "missing initializer" } */ + +struct foo b = { + .a2 = (const char * const []){ "y", 0 }, + .a1 = "x", +}; diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type-Wextra.c b/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type-Wextra.c new file mode 100644 index 0000000000..37e1a571bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type-Wextra.c @@ -0,0 +1,7 @@ +/* Test -Wmissing-parameter-type is enabled by -Wextra */ +/* { dg-do compile } */ +/* { dg-options "-Wextra" } */ + +int foo(bar) { return bar;} /* { dg-warning "type of 'bar' defaults to 'int'" } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type-no.c b/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type-no.c new file mode 100644 index 0000000000..45e5e42c0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type-no.c @@ -0,0 +1,7 @@ +/* Test that we can disable -Wmissing-parameter-type */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra -Wno-missing-parameter-type -std=gnu89" } */ + +int foo(bar) { return bar;} /* { dg-bogus "type of 'bar' defaults to 'int'" } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type.c b/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type.c new file mode 100644 index 0000000000..8ec94e2caf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-parameter-type.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-parameter-type" } */ + +int foo(bar) { return bar; } /* { dg-warning "type of 'bar' defaults to 'int'" } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-profile.c b/SingleSource/Regression/C/gcc-dg/Wmissing-profile.c new file mode 100644 index 0000000000..6ef1ac16c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-profile.c @@ -0,0 +1,5 @@ +/* PR gcov-profile/86957 */ +/* { dg-do compile } */ +/* { dg-options "-fprofile-use" } */ + +void foo () { } /* { dg-warning "profile count data file not found" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wmissing-variable-declarations.c b/SingleSource/Regression/C/gcc-dg/Wmissing-variable-declarations.c new file mode 100644 index 0000000000..b292dbe8c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wmissing-variable-declarations.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-variable-declarations" } */ + +int b0; /* { dg-warning "no previous declaration for 'b0'" } */ + +int b1 = 1; /* { dg-warning "no previous declaration for 'b1'" } */ + +int b2; /* { dg-warning "no previous declaration for 'b2'" } */ +int b2 = 2; + +struct { + int g0; +} b3; /* { dg-warning "no previous declaration for 'b3'" } */ + +int b4; /* { dg-warning "no previous declaration for 'b4'" } */ +int b4 = 3; +extern int b4; + +static int g1; + +void g2(void); + +extern int g3; +int g3; +int g3 = 4; + +struct g4 { + int g5; +}; + +void g6(void) { + int g7; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnested-externs-1.c b/SingleSource/Regression/C/gcc-dg/Wnested-externs-1.c new file mode 100644 index 0000000000..5c4b5ddd8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnested-externs-1.c @@ -0,0 +1,22 @@ +/* Test -Wnested-externs. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wnested-externs" } */ + +int a; +static int b; +extern int c; +void f0(void); +static void f1(void); + +void +g(void) +{ + extern int a; /* { dg-warning "nested extern declaration of 'a'" } */ + extern int b; /* { dg-warning "nested extern declaration of 'b'" } */ + extern int c; /* { dg-warning "nested extern declaration of 'c'" } */ + extern int d; /* { dg-warning "nested extern declaration of 'd'" } */ + extern void f0(void); /* { dg-warning "nested extern declaration of 'f0'" } */ + extern void f1(void); /* { dg-warning "nested extern declaration of 'f1'" } */ + extern void f2(void); /* { dg-warning "nested extern declaration of 'f2'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnested-externs-2.c b/SingleSource/Regression/C/gcc-dg/Wnested-externs-2.c new file mode 100644 index 0000000000..77bed5faf3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnested-externs-2.c @@ -0,0 +1,11 @@ +/* PR c/70791 */ +/* { dg-do compile } */ +/* { dg-options "-Wnested-externs" } */ + +void +bar (void) +{ + extern int i; /* { dg-warning "14:nested extern declaration of 'i'" } */ + extern short foo (void); /* { dg-warning "16:nested extern declaration of 'foo'" } */ + extern struct S *s; /* { dg-warning "20:nested extern declaration of 's'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wno-all.c b/SingleSource/Regression/C/gcc-dg/Wno-all.c new file mode 100644 index 0000000000..de55bbcdac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wno-all.c @@ -0,0 +1,10 @@ +/* PR 30437: Test negative of -Wall + Don't change this without changing Wall.c as well. */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wno-all" } */ + +void foo(int a) +{ + 5 * (a == 1) | (a == 2); /* { dg-bogus "no effect" "no effect" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wno-attribute-warning.c b/SingleSource/Regression/C/gcc-dg/Wno-attribute-warning.c new file mode 100644 index 0000000000..2475304757 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wno-attribute-warning.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Werror -Wno-error=attribute-warning" } */ + +int f1(void) __attribute__ ((warning("Please avoid f1"))); +int func1(void) +{ + return f1(); /* { dg-warning "'f1' declared with attribute warning: Please avoid f1" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wno-c++-compat.c b/SingleSource/Regression/C/gcc-dg/Wno-c++-compat.c new file mode 100644 index 0000000000..1fda016e66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wno-c++-compat.c @@ -0,0 +1,9 @@ +/* Copyright (C) 2005 Free Software Foundation. + + by Gabriel Dos Reis */ + +/* { dg-do compile } */ +/* { dg-options "-Wno-c++-compat" } */ + +extern const int foo = 42; /* { dg-warning "initialized and declared" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/Wno-frame-address.c b/SingleSource/Regression/C/gcc-dg/Wno-frame-address.c new file mode 100644 index 0000000000..a97ec402b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wno-frame-address.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-skip-if "Cannot access arbitrary stack frames" { arm*-*-* amdgpu-*-* avr-*-* hppa*-*-* ia64-*-* visium-*-* csky-*-* msp430-*-* cris-*-* mmix-*-* pru-*-* } } */ +/* { dg-options "-Werror" } */ +/* { dg-additional-options "-mbackchain" { target { s390*-*-* } } } */ + +/* Verify that -Wframe-address is not enabled by default by enabling + -Werror and verifying the test still compiles. */ +#include "Wframe-address.c" diff --git a/SingleSource/Regression/C/gcc-dg/Wno-pointer-sign.c b/SingleSource/Regression/C/gcc-dg/Wno-pointer-sign.c new file mode 100644 index 0000000000..780c9d4e20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wno-pointer-sign.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-pointer-sign" } */ + +void f1(long *); +void f2(unsigned long *); + +int main() +{ + long *lp; + unsigned long *ulp; + char *cp; + unsigned char *ucp; + signed char *scp; + + ulp = lp; /* { dg-bogus " pointer targets in assignment differ in signedness" } */ + lp = ulp; /* { dg-bogus " pointer targets in assignment differ in signedness" } */ + f1(ulp); /* { dg-bogus " differ in signedness" } */ + f2(lp); /* { dg-bogus " differ in signedness" } */ + + cp = ucp; /* { dg-bogus " pointer targets in assignment differ in signedness" } */ + cp = scp; /* { dg-bogus " pointer targets in assignment differ in signedness" } */ + ucp = scp; /* { dg-bogus " pointer targets in assignment differ in signedness" } */ + ucp = cp; /* { dg-bogus " pointer targets in assignment differ in signedness" } */ + scp = ucp; /* { dg-bogus " pointer targets in assignment differ in signedness" } */ + scp = cp; /* { dg-bogus " pointer targets in assignment differ in signedness" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnonnull-2.c b/SingleSource/Regression/C/gcc-dg/Wnonnull-2.c new file mode 100644 index 0000000000..d870473d5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnonnull-2.c @@ -0,0 +1,55 @@ +/* PR middle-end/80936 - bcmp, bcopy, and bzero not declared nonnull + Verify that -Wnonnull is issued for calls with constant null pointers + with no optimization. + { dg-do compile } + { dg-options "-O0 -Wall" } */ + +void zero0 (void *p, unsigned n) +{ + __builtin_memset (0, 0, n); // { dg-warning "\\\[-Wnonnull]" } +} + +void zero1 (void *p, unsigned n) +{ + __builtin_bzero (0, n); // { dg-warning "\\\[-Wnonnull]" } +} + +void copy0 (void *p, const void *q, unsigned n) +{ + __builtin_memcpy (0, q, n); // { dg-warning "\\\[-Wnonnull]" } +} + +void copy1 (void *p, const void *q, unsigned n) +{ + __builtin_memcpy (0, q, n); // { dg-warning "\\\[-Wnonnull]" } +} + +void copy2 (void *p, const void *q, unsigned n) +{ + __builtin_bcopy (q, 0, n); // { dg-warning "\\\[-Wnonnull]" } +} + +void copy3 (void *p, const void *q, unsigned n) +{ + __builtin_bcopy (q, 0, n); // { dg-warning "\\\[-Wnonnull]" } +} + +int cmp0 (const void *p, const void *q, unsigned n) +{ + return __builtin_memcmp (0, q, n); // { dg-warning "\\\[-Wnonnull]" } +} + +int cmp1 (const void *p, const void *q, unsigned n) +{ + return __builtin_memcmp (0, q, n); // { dg-warning "\\\[-Wnonnull]" } +} + +int cmp2 (const void *p, const void *q, unsigned n) +{ + return __builtin_bcmp (0, q, n); // { dg-warning "\\\[-Wnonnull]" } +} + +int cmp3 (const void *p, const void *q, unsigned n) +{ + return __builtin_bcmp (p, 0, n); // { dg-warning "\\\[-Wnonnull]" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnonnull-3.c b/SingleSource/Regression/C/gcc-dg/Wnonnull-3.c new file mode 100644 index 0000000000..ad016df933 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnonnull-3.c @@ -0,0 +1,71 @@ +/* PR middle-end/80936 - bcmp, bcopy, and bzero not declared nonnull + Verify that with optimization, -Wnonnull is issued for calls with + non-constant arguments determined to be null. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define NOIPA __attribute__ ((noipa)) + +NOIPA void zero0 (void *p, unsigned n) +{ + if (p == 0) + __builtin_memset (p, 0, n); // { dg-warning "\\\[-Wnonnull]" } +} + +NOIPA void zero1 (void *p, unsigned n) +{ + if (p == 0) + __builtin_bzero (p, n); // { dg-warning "\\\[-Wnonnull]" } +} + +NOIPA void copy0 (void *p, const void *q, unsigned n) +{ + if (p == 0) + __builtin_memcpy (p, q, n); // { dg-warning "\\\[-Wnonnull]" } +} + +NOIPA void copy1 (void *p, const void *q, unsigned n) +{ + if (q == 0) + __builtin_memcpy (p, q, n); // { dg-warning "\\\[-Wnonnull]" } +} + +NOIPA void copy2 (void *p, const void *q, unsigned n) +{ + if (p == 0) + __builtin_bcopy (q, p, n); // { dg-warning "\\\[-Wnonnull]" } +} + +NOIPA void copy3 (void *p, const void *q, unsigned n) +{ + if (q == 0) + __builtin_bcopy (q, p, n); // { dg-warning "\\\[-Wnonnull]" } +} + +NOIPA int cmp0 (const void *p, const void *q, unsigned n) +{ + if (p == 0) + return __builtin_memcmp (p, q, n); // { dg-warning "\\\[-Wnonnull]" } + return 0; +} + +NOIPA int cmp1 (const void *p, const void *q, unsigned n) +{ + if (q == 0) + return __builtin_memcmp (p, q, n); // { dg-warning "\\\[-Wnonnull]" } + return 0; +} + +NOIPA int cmp2 (const void *p, const void *q, unsigned n) +{ + if (p == 0) + return __builtin_bcmp (p, q, n); // { dg-warning "\\\[-Wnonnull]" } + return 0; +} + +NOIPA int cmp3 (const void *p, const void *q, unsigned n) +{ + if (q == 0) + return __builtin_bcmp (p, q, n); // { dg-warning "\\\[-Wnonnull]" } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnonnull-4.c b/SingleSource/Regression/C/gcc-dg/Wnonnull-4.c new file mode 100644 index 0000000000..2c1c45a985 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnonnull-4.c @@ -0,0 +1,173 @@ +/* PR middle-end/97188 - ICE passing a null VLA to a function expecting + at least one element + { dg-do compile } + { dg-options "-O -Wall -ftrack-macro-expansion=0" } */ + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) + +/* Exercise passing nul to a one-dimensional VLA argument. */ + +void test_fca_n (int r_m1) +{ + extern void fca_n (int n, char[n]); // { dg-message "in a call to function 'fca_n'" "note" } + +#define T(n) fca_n (n, 0) + + int min = INT_MIN; + int max = INT_MAX; + if (r_m1 >= 0) + r_m1 = -1; + + // Verify negative bounds. + T (min); // { dg-warning "bound argument 1 value -\\d+ is negative for a variable length array argument 2 of type 'char\\\[n]'" } + T (r_m1); // { dg-warning "bound argument 1 value \\\[-\\d+, -1] is negative for a variable length array argument 2 of type 'char\\\[n]" } + T ( -1); // { dg-warning "bound argument 1 value -1 is negative for a variable length array argument 2 of type 'char\\\[n]" } + + T ( 0); + + // Verify positive bounds. + T ( 1); // { dg-warning "argument 2 of variable length array 'char\\\[n]' is null but the corresponding bound argument 1 value is 1" } + T ( 9); // { dg-warning "argument 2 of variable length array 'char\\\[n]' is null but the corresponding bound argument 1 value is 9" } + T (max); // { dg-warning "argument 2 of variable length array 'char\\\[n]' is null but the corresponding bound argument 1 value is \\d+" } +} + + +/* Exercise passing nul to an array with unspecified bound of VLAs. */ + +void test_fsa_x_n (int r_m1) +{ + extern void fsa_x_n (int n, short[][n]); // { dg-message "in a call to function 'fsa_x_n'" "note" } + +#undef T +#define T(n) fsa_x_n (n, 0) + + int min = INT_MIN; + int max = INT_MAX; + if (r_m1 >= 0) + r_m1 = -1; + + // Verify negative bounds. + T (min); // { dg-warning "bound argument 1 value -\\d+ is negative for a variable length array argument 2 of type 'short int\\\[]\\\[n]'" } + T (r_m1); // { dg-warning "bound argument 1 value \\\[-\\d+, -1] is negative for a variable length array argument 2 of type 'short int\\\[]\\\[n]" } + T ( -1); // { dg-warning "bound argument 1 value -1 is negative for a variable length array argument 2 of type 'short int\\\[]\\\[n]" } + + T ( 0); + + // Verify positive bounds. + T ( 1); // { dg-warning "argument 2 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 1 value is 1" } + T ( 9); // { dg-warning "argument 2 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 1 value is 9" } + T (max); // { dg-warning "argument 2 of variable length array 'short int\\\[]\\\[n]' is null but the corresponding bound argument 1 value is \\d+" } +} + + +/* Exercise passing nul to an array of a single VLA. */ + +void test_fia_1_n (int r_m1) +{ + extern void fia_1_n (int n, int[1][n]); // { dg-message "in a call to function 'fia_1_n'" "note" } + +#undef T +#define T(n) fia_1_n (n, 0) + + int min = INT_MIN; + int max = INT_MAX; + if (r_m1 >= 0) + r_m1 = -1; + + // Verify negative bounds. + T (min); // { dg-warning "bound argument 1 value -\\d+ is negative for a variable length array argument 2 of type 'int\\\[1]\\\[n]'" } + T (r_m1); // { dg-warning "bound argument 1 value \\\[-\\d+, -1] is negative for a variable length array argument 2 of type 'int\\\[1]\\\[n]" } + T ( -1); // { dg-warning "bound argument 1 value -1 is negative for a variable length array argument 2 of type 'int\\\[1]\\\[n]" } + + T ( 0); + + // Verify positive bounds. + T ( 1); // { dg-warning "argument 2 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 1 value is 1" } + T ( 9); // { dg-warning "argument 2 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 1 value is 9" } + T (max); // { dg-warning "argument 2 of variable length array 'int\\\[1]\\\[n]' is null but the corresponding bound argument 1 value is \\d+" } +} + + +/* Exercise passing nul to an array of three VLAs. */ + +void test_fla_3_n (int r_m1) +{ + extern void fla_3_n (int n, long[3][n]); // { dg-message "in a call to function 'fla_3_n'" "note" } + +#undef T +#define T(n) fla_3_n (n, 0) + + int min = INT_MIN; + int max = INT_MAX; + if (r_m1 >= 0) + r_m1 = -1; + + // Verify negative bounds. + T (min); // { dg-warning "bound argument 1 value -\\d+ is negative for a variable length array argument 2 of type 'long int\\\[3]\\\[n]'" } + T (r_m1); // { dg-warning "bound argument 1 value \\\[-\\d+, -1] is negative for a variable length array argument 2 of type 'long int\\\[3]\\\[n]" } + T ( -1); // { dg-warning "bound argument 1 value -1 is negative for a variable length array argument 2 of type 'long int\\\[3]\\\[n]" } + + T ( 0); + + // Verify positive bounds. + T ( 1); // { dg-warning "argument 2 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 1 value is 1" } + T ( 9); // { dg-warning "argument 2 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 1 value is 9" } + T (max); // { dg-warning "argument 2 of variable length array 'long int\\\[3]\\\[n]' is null but the corresponding bound argument 1 value is \\d+" } +} + + +/* Exercise passing nul to a VLA of five-element arrays. */ + +void test_fda_n_5 (int r_m1) +{ + extern void fda_n_5 (int n, double[n][5]);// { dg-message "in a call to function 'fda_n_5'" "note" } + +#undef T +#define T(n) fda_n_5 (n, 0) + + int min = INT_MIN; + int max = INT_MAX; + if (r_m1 >= 0) + r_m1 = -1; + + // Verify negative bounds. + T (min); // { dg-warning "bound argument 1 value -\\d+ is negative for a variable length array argument 2 of type 'double\\\[n]\\\[5]'" } + T (r_m1); // { dg-warning "bound argument 1 value \\\[-\\d+, -1] is negative for a variable length array argument 2 of type 'double\\\[n]\\\[5]" } + T ( -1); // { dg-warning "bound argument 1 value -1 is negative for a variable length array argument 2 of type 'double\\\[n]\\\[5]" } + + T ( 0); + + // Verify positive bounds. + T ( 1); // { dg-warning "argument 2 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 1 value is 1" } + T ( 9); // { dg-warning "argument 2 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 1 value is 9" } + T (max); // { dg-warning "argument 2 of variable length array 'double\\\[n]\\\[5]' is null but the corresponding bound argument 1 value is \\d+" } +} + + +/* Exercise passing nul to a two-dimensional VLA. */ + +void test_fca_n_n (int r_m1) +{ + extern void fca_n_n (int n, char[n][n]); // { dg-message "in a call to function 'fca_n_n'" "note" } + +#undef T +#define T(n) fca_n_n (n, 0) + + int min = INT_MIN; + int max = INT_MAX; + if (r_m1 >= 0) + r_m1 = -1; + + // Verify negative bounds. + T (min); // { dg-warning "bound argument 1 value -\\d+ is negative for a variable length array argument 2 of type 'char\\\[n]\\\[n]'" } + T (r_m1); // { dg-warning "bound argument 1 value \\\[-\\d+, -1] is negative for a variable length array argument 2 of type 'char\\\[n]\\\[n]" } + T ( -1); // { dg-warning "bound argument 1 value -1 is negative for a variable length array argument 2 of type 'char\\\[n]\\\[n]" } + + T ( 0); + + // Verify positive bounds. + T ( 1); // { dg-warning "argument 2 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 1 value is 1" } + T ( 9); // { dg-warning "argument 2 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 1 value is 9" } + T (max); // { dg-warning "argument 2 of variable length array 'char\\\[n]\\\[n]' is null but the corresponding bound argument 1 value is \\d+" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnonnull-5.c b/SingleSource/Regression/C/gcc-dg/Wnonnull-5.c new file mode 100644 index 0000000000..ef6ed54c3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnonnull-5.c @@ -0,0 +1,53 @@ +/* PR middle-end/97552 - missing waning passing null to a VLA argument + declared [static] + { dg-do compile } + { dg-options "-Wall" } */ + +#define A(...) __attribute__ ((__VA_ARGS__)) + +void fptr_array (int(*)[0]); + +void fstatic_array (int[static 0]); +void A (nonnull) fnonnull_static_array (int [static 0]); + +void fvla (int n, int [n]); +void A (nonnull) fnonnull_vla (int n, int [n]); + +void fstatic_vla (int n, int [static n]); +void A (nonnull) fnonnull_static_vla (int n, int [static n]); + + +void test_null (void) +{ + fptr_array (0); + fptr_array (&(int[0]){ }); + + fstatic_array (0); // { dg-warning "\\\[-Wnonnull" } + fnonnull_static_array (0); // { dg-warning "\\\[-Wnonnull" } + + fvla (0, 0); + fnonnull_vla (0, 0); // { dg-warning "\\\[-Wnonnull" } + + fstatic_vla (0, 0); // { dg-warning "\\\[-Wnonnull" } + fnonnull_static_vla (0, 0); // { dg-warning "\\\[-Wnonnull" } +} + + +#pragma GCC optimize ("1") + +void test_null_optimized (void) +{ + int (*pa)[0] = 0; + fptr_array (pa); + + int *p = 0; + + fstatic_array (p); // { dg-warning "\\\[-Wnonnull" } + fnonnull_static_array (p); // { dg-warning "\\\[-Wnonnull" } + + fvla (0, p); + fnonnull_vla (0, p); // { dg-warning "\\\[-Wnonnull" } + + fstatic_vla (0, p); // { dg-warning "\\\[-Wnonnull" } + fnonnull_static_vla (0, p); // { dg-warning "\\\[-Wnonnull" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnonnull-6.c b/SingleSource/Regression/C/gcc-dg/Wnonnull-6.c new file mode 100644 index 0000000000..48f09da996 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnonnull-6.c @@ -0,0 +1,93 @@ +/* Verify that attribute nonnull on global and local function declarations + or those to pointers to functions is merged. + { dg-do compile } + { dg-options "-Wall" } */ + +void fnonnull_local_local (void) +{ + extern __attribute__ ((nonnull)) void fnonnull1 (void*); + + fnonnull1 (0); // { dg-warning "\\\[-Wnonnull" } +} + +void gnonnull_local_local (void) +{ + extern void fnonnull1 (void*); + + fnonnull1 (0); // { dg-warning "\\\[-Wnonnull" } +} + + +void fnonnull_local_global (void) +{ + extern __attribute__ ((nonnull)) void fnonnull2 (void*); + + fnonnull2 (0); // { dg-warning "\\\[-Wnonnull" } +} + +extern void fnonnull2 (void*); + +void gnonnull_local_global (void) +{ + fnonnull2 (0); // { dg-warning "\\\[-Wnonnull" } +} + + +extern __attribute__ ((nonnull)) void fnonnull3 (void*); + +void fnonnull_global_local (void) +{ + fnonnull3 (0); // { dg-warning "\\\[-Wnonnull" } +} + +void gnonnull_global_local (void) +{ + extern void fnonnull3 (void*); + + fnonnull3 (0); // { dg-warning "\\\[-Wnonnull" } +} + + +void pfnonnull_local_local (void) +{ + extern __attribute__ ((nonnull)) void (*pfnonnull1) (void*); + + pfnonnull1 (0); // { dg-warning "\\\[-Wnonnull" } +} + +void gpnonnull_local_local (void) +{ + extern void (*pfnonnull1) (void*); + + pfnonnull1 (0); // { dg-warning "\\\[-Wnonnull" "pr?????" { xfail *-*-* } } +} + + +void pfnonnull_local_global (void) +{ + extern __attribute__ ((nonnull)) void (*pfnonnull2) (void*); + + pfnonnull2 (0); // { dg-warning "\\\[-Wnonnull" } +} + +extern void (*pfnonnull2) (void*); + +void gpnonnull_local_global (void) +{ + pfnonnull2 (0); // { dg-warning "\\\[-Wnonnull" "pr?????" { xfail *-*-* } } +} + + +extern __attribute__ ((nonnull)) void (*pfnonnull3) (void*); + +void pfnonnull_global_local (void) +{ + pfnonnull3 (0); // { dg-warning "\\\[-Wnonnull" } +} + +void gpnonnull_global_local (void) +{ + extern void (*pfnonnull3) (void*); + + pfnonnull3 (0); // { dg-warning "\\\[-Wnonnull" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnonnull-7.c b/SingleSource/Regression/C/gcc-dg/Wnonnull-7.c new file mode 100644 index 0000000000..e7b331a904 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnonnull-7.c @@ -0,0 +1,15 @@ +/* PR middle-end/101216 - spurious notes for function calls + { dg-do compile } + { dg-options "-O2 -w" } */ + +__attribute__ ((access (write_only, 1, 2))) char* +getcwd (char *, __SIZE_TYPE__); + +char* f (void) +{ + char a[8]; + return getcwd (0, 8); +} + +/* Expect no messages of any kind on output. + { dg-bogus "" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wnonnull-8.c b/SingleSource/Regression/C/gcc-dg/Wnonnull-8.c new file mode 100644 index 0000000000..02871a7668 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnonnull-8.c @@ -0,0 +1,14 @@ +/* PR c/108986 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +void +foo (int a[static 7]) +{ +} + +int +main () +{ + foo ((int *) 0); /* { dg-warning "argument 1 to 'int\\\[static 7\\\]' is null where non-null expected" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wnonnull.c b/SingleSource/Regression/C/gcc-dg/Wnonnull.c new file mode 100644 index 0000000000..0ed06aabe6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wnonnull.c @@ -0,0 +1,44 @@ +/* PR tree-optimization/83369 - Missing diagnostics during inlining + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern __SIZE_TYPE__ strlen (const char *__s) + __attribute ((pure)) __attribute ((nonnull (1))); +extern void *memcpy (void *__restrict __dest, const void *__restrict __src, + __SIZE_TYPE__ __n) __attribute ((nonnull (1, 2))); + +char buf[100]; + +struct Test +{ + const char* s1; + const char* s2; +}; + +__attribute ((nonnull (1, 2))) +inline char* +my_strcpy (char *restrict dst, const char *restrict src, __SIZE_TYPE__ size) +{ + __SIZE_TYPE__ len = strlen (src); /* { dg-warning "argument 1 null where non-null expected" } */ + if (len < size) + memcpy (dst, src, len + 1); /* { dg-warning "argument 2 null where non-null expected" } */ + else + { + memcpy (dst, src, size - 1); /* { dg-warning "argument 2 null where non-null expected" } */ + dst[size - 1] = '\0'; + } + return dst; +} + +void test (struct Test* test) +{ + if (test->s1) + my_strcpy (buf, test->s1, sizeof buf); + else if (test->s2) + my_strcpy (buf, test->s2, sizeof buf); + else + my_strcpy (buf, test->s2, sizeof buf); +} + +/* Verify that the inlining context is printed for -Wnonnull: + { dg-message "function .my_strcpy..*inlined from .test." "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wobjsize-1.c b/SingleSource/Regression/C/gcc-dg/Wobjsize-1.c new file mode 100644 index 0000000000..988b8bcbf3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wobjsize-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wno-array-bounds" } */ + +#include "Wobjsize-1.h" + +char buf[6]; + +int main(int argc, char **argv) +{ + strcpy (buf,"hello "); + return 0; +} + +/* { dg-warning "\\\[-Wstringop-overflow" "warning" { target *-*-* } 0 } + { dg-message "file included" "included" { target *-*-* } 0 } + { dg-message "inlined from" "inlined" { target *-*-* } 0 } + + The test might emit two warnings, one for the strcpy call and + another for the inlined call to __builtin___strcpy_chk() called + from strcpy(). + { dg-prune-output "writing 7 bytes into a region of size 6" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wobjsize-1.h b/SingleSource/Regression/C/gcc-dg/Wobjsize-1.h new file mode 100644 index 0000000000..a879f6db99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wobjsize-1.h @@ -0,0 +1,8 @@ +#pragma GCC system_header + +extern __inline __attribute__ ((__always_inline__,__artificial__,__gnu_inline__)) char * +__attribute__ ((__nothrow__)) strcpy (char *__restrict __dest, __const char *__restrict __src) +{ + return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wold-style-definition-1.c b/SingleSource/Regression/C/gcc-dg/Wold-style-definition-1.c new file mode 100644 index 0000000000..01d3ffbea7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wold-style-definition-1.c @@ -0,0 +1,24 @@ +/* Test for warning about old-style function definition. */ + +/* Origin: Andreas Jaeger */ +/* { dg-do compile } */ +/* { dg-options "-Wold-style-definition -std=gnu89" } */ + +void +bar (a) int a; { } /* { dg-warning "old-style function definition" } */ + +void bar1 () {} /* { dg-warning "old-style function definition" } */ + +extern void bar2 (void); + +void bar2 () {} /* { dg-warning "old-style function definition" } */ + +extern void bar3 (int); + +void bar3 (a) {} /* { dg-warning "old-style function definition" } */ + +void bar4 (a) {} /* { dg-warning "old-style function definition" } */ + +void bar5 (int a) {} + +void bar6 (void) {} diff --git a/SingleSource/Regression/C/gcc-dg/Wold-style-definition-2.c b/SingleSource/Regression/C/gcc-dg/Wold-style-definition-2.c new file mode 100644 index 0000000000..8e297c9641 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wold-style-definition-2.c @@ -0,0 +1,10 @@ +/* PR c/12466 + Test for not warning about ellipsises with -Wold-style-definition. */ + +/* Origin: Kelley Cook */ +/* { dg-do compile } */ +/* { dg-options "-Wold-style-definition" } */ + +void bar1 ( ... ) {} + +void bar2 (int a, ... ) {} diff --git a/SingleSource/Regression/C/gcc-dg/Woverflow-1.c b/SingleSource/Regression/C/gcc-dg/Woverflow-1.c new file mode 100644 index 0000000000..064af4561e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverflow-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +int foo = INT_MAX + 1; /* { dg-warning "integer overflow" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/Woverflow-2.c b/SingleSource/Regression/C/gcc-dg/Woverflow-2.c new file mode 100644 index 0000000000..44368b66f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverflow-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Woverflow" } */ + +#include + +int foo = INT_MAX + 1; /* { dg-warning "integer overflow" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/Woverflow-3.c b/SingleSource/Regression/C/gcc-dg/Woverflow-3.c new file mode 100644 index 0000000000..73a021b594 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverflow-3.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-overflow" } */ + +#include + +int foo = INT_MAX + 1; + diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-asm.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-asm.c new file mode 100644 index 0000000000..45373bc1a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-asm.c @@ -0,0 +1,47 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c89 -pedantic" } */ + +#define TEN " " +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +__asm__ (HUN HUN HUN HUN HUN TEN); + +/* C99's minimum-maximum is 4095. */ +__asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + +void +f (void) +{ + /* C89's minimum-maximum is 509. */ + __asm__ (HUN HUN HUN HUN HUN TEN); + __asm__ (HUN HUN HUN HUN HUN TEN : : ); + __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label); + + /* C99's minimum-maximum is 4095. */ + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : : ); + __asm__ goto ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : : : : label); + + label: ; +} diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-ext.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-ext.c new file mode 100644 index 0000000000..09b8079d55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-ext.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c89 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = __extension__ HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-no.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-no.c new file mode 100644 index 0000000000..a2ccbddf25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89-no.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c89 -pedantic -Wno-overlength-strings" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89.c new file mode 100644 index 0000000000..9370acf844 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c89.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c89 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; /* { dg-warning "greater than" } */ + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; /* { dg-warning "greater than" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90-asm.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90-asm.c new file mode 100644 index 0000000000..b5523bc890 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90-asm.c @@ -0,0 +1,48 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c90 -pedantic" } */ + +#define TEN " " +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +__asm__ (HUN HUN HUN HUN HUN TEN); + +/* C99's minimum-maximum is 4095. */ +__asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + +void +f (void) +{ + /* C89's minimum-maximum is 509. */ + __asm__ (HUN HUN HUN HUN HUN TEN); + __asm__ (HUN HUN HUN HUN HUN TEN : :); + __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label); + + /* C99's minimum-maximum is 4095. */ + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : :); + __asm__ goto ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : : : : label); + + label: ; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90-ext.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90-ext.c new file mode 100644 index 0000000000..6fbaebef34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90-ext.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c90 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = __extension__ HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90.c new file mode 100644 index 0000000000..94264f3b14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c90.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c90 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; /* { dg-warning "greater than" } */ + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; /* { dg-warning "greater than" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-asm.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-asm.c new file mode 100644 index 0000000000..8840e38bdc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-asm.c @@ -0,0 +1,48 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c99 -pedantic" } */ + +#define TEN " " +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +__asm__ (HUN HUN HUN HUN HUN TEN); + +/* C99's minimum-maximum is 4095. */ +__asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + +void +f (void) +{ + /* C89's minimum-maximum is 509. */ + __asm__ (HUN HUN HUN HUN HUN TEN); + __asm__ (HUN HUN HUN HUN HUN TEN : :); + __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label); + + /* C99's minimum-maximum is 4095. */ + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"); + __asm__ ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : :); + __asm__ goto ( + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456" : : : : label); + + label: ; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-ext.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-ext.c new file mode 100644 index 0000000000..93d5e4600f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-ext.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c99 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = __extension__ + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-no.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-no.c new file mode 100644 index 0000000000..a44a21409b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99-no.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c99 -pedantic -Wno-overlength-strings" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99.c new file mode 100644 index 0000000000..e7f512192f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings-pedantic-c99.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "-std=c99 -pedantic" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; /* { dg-warning "greater than" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Woverlength-strings.c b/SingleSource/Regression/C/gcc-dg/Woverlength-strings.c new file mode 100644 index 0000000000..d02e18ea29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverlength-strings.c @@ -0,0 +1,19 @@ +/* -Woverlength-strings complains about string constants which are too long + for the C standard's "minimum maximum" limits. It is off by default, + but implied by -pedantic. */ + +/* { dg-options "" } */ + +#define TEN "xxxxxxxxxx" +#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN +#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN + +/* C89's minimum-maximum is 509. */ +const char x510[] = HUN HUN HUN HUN HUN TEN; + +/* C99's minimum-maximum is 4095. */ +const char x4096[] = + THO THO THO THO /* 4000 */ + TEN TEN TEN TEN TEN /* 4050 */ + TEN TEN TEN TEN /* 4090 */ + "123456"; diff --git a/SingleSource/Regression/C/gcc-dg/Woverride-init-1.c b/SingleSource/Regression/C/gcc-dg/Woverride-init-1.c new file mode 100644 index 0000000000..b01d8a29dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverride-init-1.c @@ -0,0 +1,28 @@ +/* Test for warnings for overriding designated initializers: + -Woverride-init. Bug 24010. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Woverride-init" } */ + +struct s { int a; int b; int c; }; +union u { char a; long long b; }; + +struct s s0 = { + .a = 1, + .b = 2, + .a = 3, /* { dg-warning "initialized field overwritten" } */ + 4, /* { dg-warning "initialized field overwritten" } */ + 5 +}; + +union u u0 = { + .a = 1, + .b = 2, /* { dg-warning "initialized field overwritten" } */ + .a = 3 }; /* { dg-warning "initialized field overwritten" } */ + +int a[5] = { + [0] = 1, + [1] = 2, + [0] = 3, /* { dg-warning "initialized field overwritten" } */ + [2] = 4 +}; diff --git a/SingleSource/Regression/C/gcc-dg/Woverride-init-2.c b/SingleSource/Regression/C/gcc-dg/Woverride-init-2.c new file mode 100644 index 0000000000..d0ece89eb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverride-init-2.c @@ -0,0 +1,28 @@ +/* Test for warnings for overriding designated initializers: + -Wextra. Bug 24010. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wextra" } */ + +struct s { int a; int b; int c; }; +union u { char a; long long b; }; + +struct s s0 = { + .a = 1, + .b = 2, + .a = 3, /* { dg-warning "initialized field overwritten" } */ + 4, /* { dg-warning "initialized field overwritten" } */ + 5 +}; + +union u u0 = { + .a = 1, + .b = 2, /* { dg-warning "initialized field overwritten" } */ + .a = 3 }; /* { dg-warning "initialized field overwritten" } */ + +int a[5] = { + [0] = 1, + [1] = 2, + [0] = 3, /* { dg-warning "initialized field overwritten" } */ + [2] = 4 +}; diff --git a/SingleSource/Regression/C/gcc-dg/Woverride-init-3.c b/SingleSource/Regression/C/gcc-dg/Woverride-init-3.c new file mode 100644 index 0000000000..3fec7385d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverride-init-3.c @@ -0,0 +1,29 @@ +/* Test for warnings for overriding designated initializers: not + warned for with -Wextra -Wno-override-init. Bug 24010. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wextra -Wno-override-init" } */ + +struct s { int a; int b; int c; }; +union u { char a; long long b; }; + +struct s s0 = { + .a = 1, + .b = 2, + .a = 3, + 4, + 5 +}; + +union u u0 = { + .a = 1, + .b = 2, + .a = 3 +}; + +int a[5] = { + [0] = 1, + [1] = 2, + [0] = 3, + [2] = 4 +}; diff --git a/SingleSource/Regression/C/gcc-dg/Woverride-init-side-effects-1.c b/SingleSource/Regression/C/gcc-dg/Woverride-init-side-effects-1.c new file mode 100644 index 0000000000..50f198d7fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverride-init-side-effects-1.c @@ -0,0 +1,25 @@ +/* PR c/64918 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S { int m, n; }; +union U { short s; long int l; }; + +void +foo (int i) +{ + int a[] = { + [0] = ++i, + [1] = i, + [0] = 42 /* { dg-warning "initialized field with side-effects overwritten" } */ + }; + struct S s = { + .n = ++i, + .m = i, + .n = i /* { dg-warning "initialized field with side-effects overwritten" } */ + }; + union U u = { + .s = i--, + .l = 42 /* { dg-warning "initialized field with side-effects overwritten" } */ + }; +} diff --git a/SingleSource/Regression/C/gcc-dg/Woverride-init-side-effects-2.c b/SingleSource/Regression/C/gcc-dg/Woverride-init-side-effects-2.c new file mode 100644 index 0000000000..5927189f00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Woverride-init-side-effects-2.c @@ -0,0 +1,25 @@ +/* PR c/64918 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-override-init-side-effects" } */ + +struct S { int m, n; }; +union U { short s; long int l; }; + +void +foo (int i) +{ + int a[] = { + [0] = ++i, + [1] = i, + [0] = 42 + }; + struct S s = { + .n = ++i, + .m = i, + .n = i + }; + union U u = { + .s = i--, + .l = 42 + }; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpadded.c b/SingleSource/Regression/C/gcc-dg/Wpadded.c new file mode 100644 index 0000000000..70fcd79a6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpadded.c @@ -0,0 +1,14 @@ +/* Source: EMC. */ + +/* { dg-do compile } */ +/* -fpack-struct is necessary because the warning expected requires the initial + packing to be larger than 1, which cannot be guaranteed for all targets. + We won't get a warning anyway if the target has "packed" structure + layout. */ +/* { dg-options "-Wpadded -fpack-struct=8" } */ +/* { dg-additional-options "-mno-ms-bitfields" { target *-*-mingw* } } */ + +struct foo { + char bar; + long baz; /* { dg-warning "padding struct to align" "" { target { ! default_packed } } } */ +} futz; diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-1.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-1.c new file mode 100644 index 0000000000..d6e86eb489 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-1.c @@ -0,0 +1,15 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ +/* { dg-options -Wparentheses } */ + +/* Source: Neil Booth, 1 Nov 2001. PR 3170, 3422 - bogus warnings + about suggesting parentheses. */ + +int foo (int a, int b) +{ + int c = (a && b) || 0; /* { dg-bogus "suggest parentheses" } */ + c = a && b || 0; /* { dg-warning "suggest parentheses" } */ + + return (a && b && 1) || 0; /* { dg-bogus "suggest parentheses" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-10.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-10.c new file mode 100644 index 0000000000..aafcae2ad3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-10.c @@ -0,0 +1,42 @@ +/* Test operation of -Wparentheses. Warnings for assignments used as + truth-values shouldn't apply other than for plain assignment. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses -std=gnu99" } */ + +int foo (int); + +int a, b, c; +_Bool d; + +void +bar (void) +{ + if (a += b) + foo (0); + if (a -= a) + foo (1); + if (b *= c) + foo (2); + else + foo (3); + if (b /= b) + foo (4); + else + foo (5); + while (c %= b) + foo (6); + while (c <<= c) + foo (7); + do foo (8); while (a >>= b); + do foo (9); while (a &= a); + for (;c ^= b;) + foo (10); + for (;c |= c;) + foo (11); + d = a += b; + foo (12); + d = a -= a; + foo (13); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-11.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-11.c new file mode 100644 index 0000000000..8858a7fb3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-11.c @@ -0,0 +1,258 @@ +/* PR 7543. Test operation of -Wparentheses. Precedence warnings. + !a | b and !a & b. */ +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int foo (int); + +int +bar (int a, int b, int c) +{ + foo (!a & b); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b < c)); + foo (!a & (b > c)); + foo (!a & (b == c)); + foo (!a & (b != c)); + foo (!a & (b <= c)); + foo (!a & (b >= c)); + foo (!a & (b && c)); + foo (!a & (b || c)); + foo (!a & !b); + foo (!(a & b)); + foo ((!a) & b); + foo (!a & 2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 < c)); + foo (!a & (2 > c)); + foo (!a & (2 == c)); + foo (!a & (2 != c)); + foo (!a & (2 <= c)); + foo (!a & (2 >= c)); + foo (!a & (2 && c)); + foo (!a & (2 || c)); + foo (!a & !2); + foo (!(a & 2)); + foo ((!a) & 2); + foo (!1 & 2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 < c)); + foo (!1 & (2 > c)); + foo (!1 & (2 == c)); + foo (!1 & (2 != c)); + foo (!1 & (2 <= c)); + foo (!1 & (2 >= c)); + foo (!1 & (2 && c)); + foo (!1 & (2 || c)); + foo (!1 & !2); + foo (!(1 & 2)); + + foo (!a | b); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b < c)); + foo (!a | (b > c)); + foo (!a | (b == c)); + foo (!a | (b != c)); + foo (!a | (b <= c)); + foo (!a | (b >= c)); + foo (!a | (b && c)); + foo (!a | (b || c)); + foo (!a | !b); + foo (!(a | b)); + foo ((!a) | b); + foo (!a | 2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 < c)); + foo (!a | (2 > c)); + foo (!a | (2 == c)); + foo (!a | (2 != c)); + foo (!a | (2 <= c)); + foo (!a | (2 >= c)); + foo (!a | (2 && c)); + foo (!a | (2 || c)); + foo (!a | !2); + foo (!(a | 2)); + foo ((!a) | 2); + foo (!1 | 2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 < c)); + foo (!1 | (2 > c)); + foo (!1 | (2 == c)); + foo (!1 | (2 != c)); + foo (!1 | (2 <= c)); + foo (!1 | (2 >= c)); + foo (!1 | (2 && c)); + foo (!1 | (2 || c)); + foo (!1 | !2); + foo (!(1 | 2)); + foo ((!1) | 2); + + foo (b & !a); /* { dg-bogus "parentheses" "bogus warning" } */ + foo ((b < c) & !a); + foo ((b > c) & !a); + foo ((b == c) & !a); + foo ((b != c) & !a); + foo ((b <= c) & !a); + foo ((b >= c) & !a); + foo ((b && c) & !a); + foo ((b || c) & !a); + foo (!b & !a); + foo (!(b & a)); + foo (b & (!a)); + foo (2 & !a); /* { dg-bogus "parentheses" "correct warning" } */ + foo ((2 < c) & !a); + foo ((2 > c) & !a); + foo ((2 == c) & !a); + foo ((2 != c) & !a); + foo ((2 <= c) & !a); + foo ((2 >= c) & !a); + foo ((2 && c) & !a); + foo ((2 || c) & !a); + foo (!2 & !a); + foo (!(2 & a)); + foo (2 & (!a)); + foo (2 & !1); /* { dg-bogus "parentheses" "correct warning" } */ + foo ((2 < c) & !1); + foo ((2 > c) & !1); + foo ((2 == c) & !1); + foo ((2 != c) & !1); + foo ((2 <= c) & !1); + foo ((2 >= c) & !1); + foo ((2 && c) & !1); + foo ((2 || c) & !1); + foo (!2 & !1); + foo (!(2 & 1)); + + foo (b | !a); /* { dg-bogus "parentheses" "correct warning" } */ + foo ((b < c) | !a); + foo ((b > c) | !a); + foo ((b == c) | !a); + foo ((b != c) | !a); + foo ((b <= c) | !a); + foo ((b >= c) | !a); + foo ((b && c) | !a); + foo ((b || c) | !a); + foo (!b | !a); + foo (!(b | a)); + foo (b | (!a)); + foo (2 | !a); /* { dg-bogus "parentheses" "correct warning" } */ + foo ((2 < c) | !a); + foo ((2 > c) | !a); + foo ((2 == c) | !a); + foo ((2 != c) | !a); + foo ((2 <= c) | !a); + foo ((2 >= c) | !a); + foo ((2 && c) | !a); + foo ((2 || c) | !a); + foo (!2 | !a); + foo (!(2 | a)); + foo (2 | (!a)); + foo (2 | !1); /* { dg-bogus "parentheses" "correct warning" } */ + foo ((2 < c) | !1); + foo ((2 > c) | !1); + foo ((2 == c) | !1); + foo ((2 != c) | !1); + foo ((2 <= c) | !1); + foo ((2 >= c) | !1); + foo ((2 && c) | !1); + foo ((2 || c) | !1); + foo (!2 | !1); + foo (!(2 | 1)); + foo (2 | (!1)); +} + +int +baz (int a, int b, int c) +{ + foo (!a & (b << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b = c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & ~b); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (b | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & 2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a & (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 & (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b = c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | ~b); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (b | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!a | (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 << c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 >> c));/* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 + c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 - c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (c = 2)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | ~2); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 & c)); /* { dg-warning "parentheses" "correct warning" } */ + foo (!1 | (2 | c)); /* { dg-warning "parentheses" "correct warning" } */ + foo ((b << c) & !a); + foo ((b >> c) & !a); + foo ((b + c) & !a); + foo ((b - c) & !a); + foo ((b = c) & !a); + foo (~b & !a); + foo ((b & c) & !a); + foo ((b | c) & !a); + foo ((2 << c) & !a); + foo ((2 >> c) & !a); + foo ((2 + c) & !a); + foo ((2 - c) & !a); + foo ((c = 2) & !a); + foo (~2 & !a); + foo ((2 & c) & !a); + foo ((2 | c) & !a); + foo ((2 << c) & !1); + foo ((2 >> c) & !1); + foo ((2 + c) & !1); + foo ((2 - c) & !1); + foo ((c = 2) & !1); + foo (~2 & !1); + foo ((2 & c) & !1); + foo ((2 | c) & !1); + foo ((b << c) | !a); + foo ((b >> c) | !a); + foo ((b + c) | !a); + foo ((b - c) | !a); + foo ((b = c) | !a); + foo (~b | !a); + foo ((b & c) | !a); + foo ((b | c) | !a); + foo ((2 << c) | !a); + foo ((2 >> c) | !a); + foo ((2 + c) | !a); + foo ((2 - c) | !a); + foo ((c = 2) | !a); + foo (~2 | !a); + foo ((2 & c) | !a); + foo ((2 | c) | !a); + foo ((2 << c) | !1); + foo ((2 >> c) | !1); + foo ((2 + c) | !1); + foo ((2 - c) | !1); + foo ((c = 2) | !1); + foo (~2 | !1); + foo ((2 & c) | !1); + foo ((2 | c) | !1); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-12.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-12.c new file mode 100644 index 0000000000..7832415f1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-12.c @@ -0,0 +1,135 @@ +/* PR c/70436 */ +/* { dg-options "-Wparentheses" } */ + +int a, b, c; +void bar (void); +void baz (void); + +void +foo (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + for (;;) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + while (1) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + while (1) + for (;;) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + while (1) + while (1) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + if (b) + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + else + bar (); + + if (a) /* { dg-warning "ambiguous" } */ + for (;;) + if (b) + while (1) + if (a) + bar (); + else + baz (); + else + bar (); + + if (a) /* { dg-warning "ambiguous" } */ + for (;;) + if (b) + while (1) + { + if (a) { bar (); } else { baz (); } + } + else + bar (); + + if (a) + for (;;) + if (b) + bar (); + else + baz (); + else bar (); + + if (a) + while (1) + if (b) + bar (); + else + baz (); + else bar (); + + if (a) + for (;;) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + for (;;) + if (b) + bar (); + } + else baz (); + + if (a) + do + if (b) bar (); else baz (); + while (b); + + if (a) + do + if (b) bar (); + while (b); + else baz (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-13.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-13.c new file mode 100644 index 0000000000..9837ba566d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-13.c @@ -0,0 +1,67 @@ +/* PR c/70436 */ +/* { dg-options "-Wparentheses" } */ + +int a, b, c; +void bar (int); + +void +foo (void) +{ + if (a) /* { dg-warning "ambiguous" } */ + if (b) + { + if (c) + bar (0); + } + else + bar (1); + + if (a > 0) + if (a > 1) + if (a > 2) + if (a > 3) + if (a > 4) + if (a > 5) /* { dg-warning "ambiguous" } */ + if (a > 6) + while (1) + bar (0); + else + bar (1); + + if (a) /* { dg-warning "ambiguous" } */ + if (b) + switch (c); + else + bar (1); + + switch (a) + { + default: + if (b) /* { dg-warning "ambiguous" } */ + if (c) + for (;;) + bar (0); + else + bar (1); + } + + if (a) /* { dg-warning "ambiguous" } */ + if (a) + { + bar (2); + } + else + bar (3); + + if (a) + do if (b) bar (4); while (1); + else bar (5); + + do + { + if (a) + if (b) /* { dg-warning "ambiguous" } */ + if (c) for (;;) bar (6); + else bar (7); + } while (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-14.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-14.c new file mode 100644 index 0000000000..36dedf7147 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-14.c @@ -0,0 +1,11 @@ +/* PR c/71926 */ +/* { dg-options "-Wparentheses" } */ + +int +f (void) +{ + int a = 1, b = 2, c = 3, d = 4; + if (a = 2 || (b != 3 && c != 4 && d != 5)) /* { dg-warning "7:suggest parentheses" } */ + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-2.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-2.c new file mode 100644 index 0000000000..51038c2d71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-2.c @@ -0,0 +1,121 @@ +/* Test operation of -Wparentheses. Warnings for X<=Y<=Z should be + there rather than hidden in -Wextra. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int foo (int); + +int +bar (int a, int b, int c) +{ + foo (a <= b <= c); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((a <= b) <= c); + foo (a <= (b <= c)); + foo (1 <= 2 <= c); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((1 <= 2) <= c); + foo (1 <= (2 <= c)); + foo (1 <= 2 <= 3); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((1 <= 2) <= 3); + foo (1 <= (2 <= 3)); + foo (a > b > c); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((a > b) > c); + foo (a > (b > c)); + foo (1 > 2 > c); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((1 > 2) > c); + foo (1 > (2 > c)); + foo (1 > 2 > 3); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((1 > 2) > 3); + foo (1 > (2 > 3)); + foo (a < b <= c); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((a < b) <= c); + foo (a < (b <= c)); + foo (1 < 2 <= c); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((1 < 2) <= c); + foo (1 < (2 <= c)); + foo (1 < 2 <= 3); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((1 < 2) <= 3); + foo (1 < (2 <= 3)); + foo (a <= b > c); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((a <= b) > c); + foo (a <= (b > c)); + foo (1 <= 2 > c); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((1 <= 2) > c); + foo (1 <= (2 > c)); + foo (1 <= 2 > 3); /* { dg-warning "mathematical meaning" "correct warning" } */ + foo ((1 <= 2) > 3); + foo (1 <= (2 > 3)); + foo (a <= b == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a <= b) == c); + foo (a <= (b == c)); + foo (1 <= 2 == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 <= 2) == c); + foo (1 <= (2 == c)); + foo (1 <= 2 == 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 <= 2) == 3); + foo (1 <= (2 == 3)); + foo (a != b != c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a != b) != c); + foo (a != (b != c)); + foo (1 != 2 != c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 != 2) != c); + foo (1 != (2 != c)); + foo (1 != 2 != 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 != 2) != 3); + foo (1 != (2 != 3)); + foo (a < b == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a < b) == c); + foo (a < (b == c)); + foo (a > b == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a > b) == c); + foo (a > (b == c)); + foo (a == b < c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a == b) < c); + foo (a == (b < c)); + foo (a == b > c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a == b) > c); + foo (a == (b > c)); + foo (a == b == c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a == b) == c); + foo (a == (b == c)); + foo (1 == 2 == 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 == 2) == 3); + foo (1 == (2 == 3)); + foo (1 < 2 == 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 < 2) == 3); + foo (1 < (2 == 3)); + foo (1 > 2 == 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 > 2) == 3); + foo (1 > (2 == 3)); + foo (1 == 2 < 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 == 2) < 3); + foo (1 == (2 < 3)); + foo (1 == 2 > 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 == 2) > 3); + foo (1 == (2 > 3)); + foo (a < b != c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a < b) != c); + foo (a < (b != c)); + foo (a > b != c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a > b) != c); + foo (a > (b != c)); + foo (a != b < c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a != b) < c); + foo (a != (b < c)); + foo (a != b > c); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((a != b) > c); + foo (a != (b > c)); + foo (1 < 2 != 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 < 2) != 3); + foo (1 < (2 != 3)); + foo (1 > 2 != 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 > 2) != 3); + foo (1 > (2 != 3)); + foo (1 != 2 < 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 != 2) < 3); + foo (1 != (2 < 3)); + foo (1 != 2 > 3); /* { dg-warning "suggest parentheses around comparison" "correct warning" } */ + foo ((1 != 2) > 3); + foo (1 != (2 > 3)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-3.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-3.c new file mode 100644 index 0000000000..64899887c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-3.c @@ -0,0 +1,68 @@ +/* Test operation of -Wparentheses. Warnings for assignments used as + truth-values. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses -std=gnu99" } */ + +int foo (int); + +int a, b, c; +_Bool d; + +int +bar (void) +{ + if (a = b) /* { dg-warning "assignment" "correct warning" } */ + foo (0); + if ((a = b)) + foo (1); + if (a = a) /* { dg-warning "assignment" "correct warning" } */ + foo (2); + if ((a = a)) + foo (3); + if (b = c) /* { dg-warning "assignment" "correct warning" } */ + foo (4); + else + foo (5); + if ((b = c)) + foo (6); + else + foo (7); + if (b = b) /* { dg-warning "assignment" "correct warning" } */ + foo (8); + else + foo (9); + if ((b = b)) + foo (10); + else + foo (11); + while (c = b) /* { dg-warning "assignment" "correct warning" } */ + foo (12); + while ((c = b)) + foo (13); + while (c = c) /* { dg-warning "assignment" "correct warning" } */ + foo (14); + while ((c = c)) + foo (15); + do foo (16); while (a = b); /* { dg-warning "assignment" "correct warning" } */ + do foo (17); while ((a = b)); + do foo (18); while (a = a); /* { dg-warning "assignment" "correct warning" } */ + do foo (19); while ((a = a)); + for (;c = b;) /* { dg-warning "assignment" "correct warning" } */ + foo (20); + for (;(c = b);) + foo (21); + for (;c = c;) /* { dg-warning "assignment" "correct warning" } */ + foo (22); + for (;(c = c);) + foo (23); + d = a = b; /* { dg-warning "assignment" "correct warning" } */ + foo (24); + d = (a = b); + foo (25); + d = a = a; /* { dg-warning "assignment" "correct warning" } */ + foo (26); + d = (a = a); + foo (27); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-4.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-4.c new file mode 100644 index 0000000000..dfc9d1008e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-4.c @@ -0,0 +1,85 @@ +/* Test operation of -Wparentheses. Precedence warnings. + or - + inside shift. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int foo (int); + +int +bar (int a, int b, int c) +{ + foo (a + b << c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a + b) << c); + foo (a + (b << c)); + foo (1 + 2 << c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) << c); + foo (1 + (2 << c)); + foo (1 + 2 << 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) << 3); + foo (1 + (2 << 3)); + foo (a << b + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a << b) + c); + foo (a << (b + c)); + foo (1 << 2 + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 << 2) + c); + foo (1 << (2 + c)); + foo (1 << 2 + 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 << 2) + 3); + foo (1 << (2 + 3)); + foo (a + b >> c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a + b) >> c); + foo (a + (b >> c)); + foo (1 + 2 >> c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) >> c); + foo (1 + (2 >> c)); + foo (1 + 2 >> 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) >> 3); + foo (1 + (2 >> 3)); + foo (a >> b + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a >> b) + c); + foo (a >> (b + c)); + foo (1 >> 2 + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 >> 2) + c); + foo (1 >> (2 + c)); + foo (1 >> 2 + 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 >> 2) + 3); + foo (1 >> (2 + 3)); + foo (a - b << c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a - b) << c); + foo (a - (b << c)); + foo (6 - 5 << c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((6 - 5) << c); + foo (6 - (5 << c)); + foo (6 - 5 << 4); /* { dg-warning "parentheses" "correct warning" } */ + foo ((6 - 5) << 4); + foo (6 - (5 << 4)); + foo (a << b - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a << b) - c); + foo (a << (b - c)); + foo (6 << 5 - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((6 << 5) - c); + foo (6 << (5 - c)); + foo (6 << 5 - 4); /* { dg-warning "parentheses" "correct warning" } */ + foo ((6 << 5) - 4); + foo (6 << (5 - 4)); + foo (a - b >> c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a - b) >> c); + foo (a - (b >> c)); + foo (6 - 5 >> c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((6 - 5) >> c); + foo (6 - (5 >> c)); + foo (6 - 5 >> 4); /* { dg-warning "parentheses" "correct warning" } */ + foo ((6 - 5) >> 4); + foo (6 - (5 >> 4)); + foo (a >> b - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a >> b) - c); + foo (a >> (b - c)); + foo (6 >> 5 - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((6 >> 5) - c); + foo (6 >> (5 - c)); + foo (6 >> 5 - 4); /* { dg-warning "parentheses" "correct warning" } */ + foo ((6 >> 5) - 4); + foo (6 >> (5 - 4)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-5.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-5.c new file mode 100644 index 0000000000..49c65c21a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-5.c @@ -0,0 +1,31 @@ +/* Test operation of -Wparentheses. Precedence warnings. && inside + ||. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int foo (int); + +int +bar (int a, int b, int c) +{ + foo (a && b || c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a && b) || c); + foo (a && (b || c)); + foo (1 && 2 || c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 && 2) || c); + foo (1 && (2 || c)); + foo (1 && 2 || 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 && 2) || 3); + foo (1 && (2 || 3)); + foo (a || b && c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a || b) && c); + foo (a || (b && c)); + foo (1 || 2 && c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 || 2) && c); + foo (1 || (2 && c)); + foo (1 || 2 && 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 || 2) && 3); + foo (1 || (2 && 3)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-6.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-6.c new file mode 100644 index 0000000000..260b6adebe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-6.c @@ -0,0 +1,121 @@ +/* Test operation of -Wparentheses. Precedence warnings. & or ^ or + + or - or comparison inside |. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int foo (int); + +int +bar (int a, int b, int c) +{ + foo (a & b | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a & b) | c); + foo (a & (b | c)); + foo (1 & 2 | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) | c); + foo (1 & (2 | c)); + foo (1 & 2 | 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) | 3); + foo (1 & (2 | 3)); + foo (a | b & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a | b) & c); + foo (a | (b & c)); + foo (1 | 2 & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) & c); + foo (1 | (2 & c)); + foo (1 | 2 & 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) & 3); + foo (1 | (2 & 3)); + foo (a ^ b | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a ^ b) | c); + foo (a ^ (b | c)); + foo (1 ^ 2 | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) | c); + foo (1 ^ (2 | c)); + foo (1 ^ 2 | 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) | 3); + foo (1 ^ (2 | 3)); + foo (a | b ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a | b) ^ c); + foo (a | (b ^ c)); + foo (1 | 2 ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) ^ c); + foo (1 | (2 ^ c)); + foo (1 | 0x2 ^ 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) ^ 3); + foo (1 | (0x2 ^ 3)); + foo (a + b | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a + b) | c); + foo (a + (b | c)); + foo (1 + 2 | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) | c); + foo (1 + (2 | c)); + foo (1 + 2 | 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) | 3); + foo (1 + (2 | 3)); + foo (a | b + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a | b) + c); + foo (a | (b + c)); + foo (1 | 2 + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) + c); + foo (1 | (2 + c)); + foo (1 | 2 + 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) + 3); + foo (1 | (2 + 3)); + foo (a - b | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a - b) | c); + foo (a - (b | c)); + foo (1 - 2 | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 - 2) | c); + foo (1 - (2 | c)); + foo (1 - 2 | 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 - 2) | 3); + foo (1 - (2 | 3)); + foo (a | b - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a | b) - c); + foo (a | (b - c)); + foo (1 | 2 - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) - c); + foo (1 | (2 - c)); + foo (1 | 2 - 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) - 3); + foo (1 | (2 - 3)); + foo (a > b | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a > b) | c); + foo (a > (b | c)); + foo (1 > 2 | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 > 2) | c); + foo (1 > (2 | c)); + foo (1 > 2 | 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 > 2) | 3); + foo (1 > (2 | 3)); + foo (a | b > c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a | b) > c); + foo (a | (b > c)); + foo (1 | 2 > c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) > c); + foo (1 | (2 > c)); + foo (1 | 2 > 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) > 3); + foo (1 | (2 > 3)); + foo (a <= b | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a <= b) | c); + foo (a <= (b | c)); + foo (1 <= 2 | c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 <= 2) | c); + foo (1 <= (2 | c)); + foo (1 <= 2 | 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 <= 2) | 3); + foo (1 <= (2 | 3)); + foo (a | b <= c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a | b) <= c); + foo (a | (b <= c)); + foo (1 | 2 <= c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) <= c); + foo (1 | (2 <= c)); + foo (1 | 2 <= 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 | 2) <= 3); + foo (1 | (2 <= 3)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-7.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-7.c new file mode 100644 index 0000000000..6805094d29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-7.c @@ -0,0 +1,121 @@ +/* Test operation of -Wparentheses. Precedence warnings. & or + or - + or comparison inside ^. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int foo (int); + +int +bar (int a, int b, int c) +{ + foo (a & b ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a & b) ^ c); + foo (a & (b ^ c)); + foo (1 & 2 ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) ^ c); + foo (1 & (2 ^ c)); + foo (1 & 2 ^ 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) ^ 3); + foo (1 & (0x2 ^ 3)); + foo (a ^ b & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a ^ b) & c); + foo (a ^ (b & c)); + foo (1 ^ 2 & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) & c); + foo (1 ^ (2 & c)); + foo (1 ^ 2 & 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) & 3); + foo (1 ^ (2 & 3)); + foo (a + b ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a + b) ^ c); + foo (a + (b ^ c)); + foo (1 + 2 ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) ^ c); + foo (1 + (2 ^ c)); + foo (1 + 2 ^ 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) ^ 3); + foo (1 + (0x2 ^ 3)); + foo (a ^ b + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a ^ b) + c); + foo (a ^ (b + c)); + foo (1 ^ 2 + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) + c); + foo (1 ^ (2 + c)); + foo (1 ^ 2 + 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) + 3); + foo (1 ^ (2 + 3)); + foo (a - b ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a - b) ^ c); + foo (a - (b ^ c)); + foo (1 - 2 ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 - 2) ^ c); + foo (1 - (2 ^ c)); + foo (1 - 2 ^ 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 - 2) ^ 3); + foo (1 - (0x2 ^ 3)); + foo (a ^ b - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a ^ b) - c); + foo (a ^ (b - c)); + foo (1 ^ 2 - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) - c); + foo (1 ^ (2 - c)); + foo (1 ^ 2 - 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) - 3); + foo (1 ^ (2 - 3)); + foo (a >= b ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a >= b) ^ c); + foo (a >= (b ^ c)); + foo (1 >= 2 ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 >= 2) ^ c); + foo (1 >= (2 ^ c)); + foo (1 >= 2 ^ 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 >= 2) ^ 3); + foo (1 >= (0x2 ^ 3)); + foo (a ^ b >= c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a ^ b) >= c); + foo (a ^ (b >= c)); + foo (1 ^ 2 >= c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) >= c); + foo (1 ^ (2 >= c)); + foo (1 ^ 2 >= 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) >= 3); + foo (1 ^ (2 >= 3)); + foo (a == b ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a == b) ^ c); + foo (a == (b ^ c)); + foo (1 == 2 ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 == 2) ^ c); + foo (1 == (2 ^ c)); + foo (1 == 2 ^ 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 == 2) ^ 3); + foo (1 == (0x2 ^ 3)); + foo (a ^ b == c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a ^ b) == c); + foo (a ^ (b == c)); + foo (1 ^ 2 == c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) == c); + foo (1 ^ (2 == c)); + foo (1 ^ 2 == 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) == 3); + foo (1 ^ (2 == 3)); + foo (a < b ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a < b) ^ c); + foo (a < (b ^ c)); + foo (1 < 2 ^ c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 < 2) ^ c); + foo (1 < (2 ^ c)); + foo (1 < 2 ^ 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 < 2) ^ 3); + foo (1 < (0x2 ^ 3)); + foo (a ^ b < c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a ^ b) < c); + foo (a ^ (b < c)); + foo (1 ^ 2 < c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) < c); + foo (1 ^ (2 < c)); + foo (1 ^ 2 < 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 ^ 2) < 3); + foo (1 ^ (2 < 3)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-8.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-8.c new file mode 100644 index 0000000000..ff34ee0a52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-8.c @@ -0,0 +1,103 @@ +/* Test operation of -Wparentheses. Precedence warnings. + or - or + comparison inside &. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int foo (int); + +int +bar (int a, int b, int c) +{ + foo (a + b & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a + b) & c); + foo (a + (b & c)); + foo (1 + 2 & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) & c); + foo (1 + (2 & c)); + foo (1 + 2 & 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 + 2) & 3); + foo (1 + (2 & 3)); + foo (a & b + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a & b) + c); + foo (a & (b + c)); + foo (1 & 2 + c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) + c); + foo (1 & (2 + c)); + foo (1 & 2 + 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) + 3); + foo (1 & (2 + 3)); + foo (a - b & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a - b) & c); + foo (a - (b & c)); + foo (1 - 2 & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 - 2) & c); + foo (1 - (2 & c)); + foo (1 - 2 & 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 - 2) & 3); + foo (1 - (2 & 3)); + foo (a & b - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a & b) - c); + foo (a & (b - c)); + foo (1 & 2 - c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) - c); + foo (1 & (2 - c)); + foo (1 & 2 - 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) - 3); + foo (1 & (2 - 3)); + foo (a < b & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a < b) & c); + foo (a < (b & c)); + foo (1 < 2 & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 < 2) & c); + foo (1 < (2 & c)); + foo (1 < 2 & 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 < 2) & 3); + foo (1 < (2 & 3)); + foo (a & b < c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a & b) < c); + foo (a & (b < c)); + foo (1 & 2 < c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) < c); + foo (1 & (2 < c)); + foo (1 & 2 < 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) < 3); + foo (1 & (2 < 3)); + foo (a == b & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a == b) & c); + foo (a == (b & c)); + foo (1 == 2 & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 == 2) & c); + foo (1 == (2 & c)); + foo (1 == 2 & 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 == 2) & 3); + foo (1 == (2 & 3)); + foo (a & b == c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a & b) == c); + foo (a & (b == c)); + foo (1 & 2 == c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) == c); + foo (1 & (2 == c)); + foo (1 & 2 == 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) == 3); + foo (1 & (2 == 3)); + foo (a != b & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a != b) & c); + foo (a != (b & c)); + foo (1 != 2 & c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 != 2) & c); + foo (1 != (2 & c)); + foo (1 != 2 & 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 != 2) & 3); + foo (1 != (2 & 3)); + foo (a & b != c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((a & b) != c); + foo (a & (b != c)); + foo (1 & 2 != c); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) != c); + foo (1 & (2 != c)); + foo (1 & 2 != 3); /* { dg-warning "parentheses" "correct warning" } */ + foo ((1 & 2) != 3); + foo (1 & (2 != 3)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wparentheses-9.c b/SingleSource/Regression/C/gcc-dg/Wparentheses-9.c new file mode 100644 index 0000000000..0fff6ea1aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wparentheses-9.c @@ -0,0 +1,61 @@ +/* Test operation of -Wparentheses. Warnings for ambiguous else. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int foo (int); + +int a, b, c; + +int +bar (void) +{ + if (a) + foo (0); + if (b) + foo (1); + else + foo (2); + if (c) /* { dg-warning "ambiguous" "correct warning" } */ + if (a) + foo (3); + else + foo (4); + if (a) + if (c) + foo (5); + if (a) + if (b) /* { dg-warning "ambiguous" "correct warning" } */ + if (c) + foo (6); + else + foo (7); + if (a) /* { dg-warning "ambiguous" "correct warning" } */ + if (b) + if (c) + foo (8); + else + foo (9); + else + foo (10); + if (a) + if (b) + if (c) + foo (11); + else + foo (12); + else + foo (13); + else + foo (14); + if (a) { + if (b) + if (c) + foo (15); + else + foo (16); + else + foo (17); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-arith.c b/SingleSource/Regression/C/gcc-dg/Wpointer-arith.c new file mode 100644 index 0000000000..2d5b0cee3c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-arith.c @@ -0,0 +1,11 @@ +/* PR 35058: -Werror= works only with some warnings. */ +/* { dg-do compile } */ +/* { dg-options "-Werror=pointer-arith" } */ +void *a; + +void *test(){ + int x=5; + if(a) a++; /* { dg-error "wrong type argument to increment" } */ + return a+x; /* { dg-error "pointer of type" } */ +} +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-sign-Wall-no.c b/SingleSource/Regression/C/gcc-dg/Wpointer-sign-Wall-no.c new file mode 100644 index 0000000000..23df20721c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-sign-Wall-no.c @@ -0,0 +1,9 @@ +/* This is from PR c/25892. See Wpointer-sign.c for more details. */ + +/* { dg-options "-Wno-pointer-sign -Wall" } */ + +void foo(unsigned long* ulp); + +void bar(long* lp) { + foo(lp); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-sign-Wall.c b/SingleSource/Regression/C/gcc-dg/Wpointer-sign-Wall.c new file mode 100644 index 0000000000..843885fe27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-sign-Wall.c @@ -0,0 +1,10 @@ +/* This is from PR c/25892. See Wpointer-sign.c for more details. */ + +/* { dg-options "-Wall" } */ + +void foo(unsigned long* ulp); /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ + + +void bar(long* lp) { + foo(lp); /* { dg-warning "differ in signedness" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-sign-pedantic-no.c b/SingleSource/Regression/C/gcc-dg/Wpointer-sign-pedantic-no.c new file mode 100644 index 0000000000..d4f597fe79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-sign-pedantic-no.c @@ -0,0 +1,9 @@ +/* This is from PR c/25892. See Wpointer-sign.c for more details. */ + +/* { dg-options "-Wno-pointer-sign -pedantic" } */ + +void foo(unsigned long* ulp); + +void bar(long* lp) { + foo(lp); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-sign-pedantic.c b/SingleSource/Regression/C/gcc-dg/Wpointer-sign-pedantic.c new file mode 100644 index 0000000000..ab1130d66f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-sign-pedantic.c @@ -0,0 +1,9 @@ +/* This is from PR c/25892. See Wpointer-sign.c for more details. */ + +/* { dg-options "-pedantic" } */ + +void foo(unsigned long* ulp);/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" } */ + +void bar(long* lp) { + foo(lp); /* { dg-warning "differ in signedness" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-sign.c b/SingleSource/Regression/C/gcc-dg/Wpointer-sign.c new file mode 100644 index 0000000000..74cdbe4bc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-sign.c @@ -0,0 +1,13 @@ +/* This is from PR c/25892. The SC promised RMS that -Wpointer-sign + would be off by default in GCC 4.1 to avoid inconvenient warnings + while compiling GNU Emacs. It should be enabled with -Wall and/or + -pedantic, though. Make sure it's off by default in this test (so + use dg-options "" to avoid passing -pedantic-errors). */ + +/* { dg-options "" } */ + +void foo(unsigned long* ulp); + +void bar(long* lp) { + foo(lp); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-1.c b/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-1.c new file mode 100644 index 0000000000..ff011c75d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-1.c @@ -0,0 +1,12 @@ +/* Test -Wpointer-to-int-cast - on by default. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void *p; + +char +f (void) +{ + return (char) p; /* { dg-warning "cast from pointer to integer of different size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-2.c b/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-2.c new file mode 100644 index 0000000000..9ece965d60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-2.c @@ -0,0 +1,12 @@ +/* Test -Wpointer-to-int-cast. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wpointer-to-int-cast" } */ + +void *p; + +char +f (void) +{ + return (char) p; /* { dg-warning "cast from pointer to integer of different size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-3.c b/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-3.c new file mode 100644 index 0000000000..c82ca5cf5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpointer-to-int-cast-3.c @@ -0,0 +1,21 @@ +/* Test -Wno-pointer-to-int-cast. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wno-pointer-to-int-cast" } */ + +void *p; + +char +f (void) +{ + return (char) p; +} + + +char c; + +void * +g (void) +{ + return (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wpragmas-1.c b/SingleSource/Regression/C/gcc-dg/Wpragmas-1.c new file mode 100644 index 0000000000..139519ea17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wpragmas-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +#pragma GCC push_options +#pragma GCC optimize ("-fno-lto") /* { dg-warning "bad option" } */ +int main(void){return 0;} +#pragma GCC pop_options + +/* ??? The FEs still apply the pragma string as optimize attribute to + all functions thus the diagnostic will be repeated for each function + affected. */ +/* { dg-message "bad option" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wredundant-decls-1.c b/SingleSource/Regression/C/gcc-dg/Wredundant-decls-1.c new file mode 100644 index 0000000000..c38c7b5540 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wredundant-decls-1.c @@ -0,0 +1,7 @@ +/* PR 16684: no redundant declaration warnings should issue the first + time a built-in function is declared. + { dg-do compile } + { dg-options "-Wredundant-decls" } */ + +void *malloc (__SIZE_TYPE__); /* { dg-bogus "redundant" } */ +void *malloc (__SIZE_TYPE__); /* { dg-warning "redundant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wredundant-decls-2.c b/SingleSource/Regression/C/gcc-dg/Wredundant-decls-2.c new file mode 100644 index 0000000000..27c8e5d9f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wredundant-decls-2.c @@ -0,0 +1,27 @@ +/* Test for -Wredundant-decls warnings */ +/* { dg-do compile } */ +/* { dg-options "-Wredundant-decls" } */ + +int j = 5; /* { dg-message "5:note: previous" } */ +int j; /* { dg-warning "5:redundant" } */ + +static int k; +static int k = 5; /* { dg-message "12:note: previous" } */ +static int k; /* { dg-warning "12:redundant" } */ + +static int l = 5; /* { dg-message "12:note: previous" } */ +static int l; /* { dg-warning "12:redundant" } */ + +static int m; /* { dg-message "12:note: previous" } */ +static int m; /* { dg-warning "12:redundant" } */ +static int m = 5; + +int n; /* { dg-message "5:note: previous" } */ +int n; /* { dg-warning "5:redundant" } */ +int n = 5; + +static int o; +static int o = 5; + +int p; +int p = 5; diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-10.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-10.c new file mode 100644 index 0000000000..7dcbf89066 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-10.c @@ -0,0 +1,120 @@ +/* PR tree-optimization/84526 - ICE in generic_overlap + { dg-do compile } + { dg-options "-O2 -Wrestrict" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void* restrict, const void* restrict, size_t); +extern char* strcat (char* restrict, const char* restrict); +extern char* strcpy (char* restrict, const char* restrict); +extern char* strncat (char* restrict, const char* restrict, size_t); +extern char* strncpy (char* restrict, const char* restrict, size_t); + +struct +{ + char a[1]; +} b; + +int i; +size_t n; + +void __attribute__ ((noclone, noinline)) +test_arr_memcpy_1 (void) +{ + memcpy (&b.a[i], b.a, n); +} + +void __attribute__ ((noclone, noinline)) +test_arr_memcpy_2 (void) +{ + memcpy (b.a, &b.a[i], n); +} + +void __attribute__ ((noclone, noinline)) +test_arr_strcat_1 (void) +{ + strcat (&b.a[i], b.a); /* { dg-warning "\\\[-Wrestrict" } */ +} + +void __attribute__ ((noclone, noinline)) +test_arr_strcat_2 (void) +{ + strcat (b.a, &b.a[i]); /* { dg-warning "\\\[-Wrestrict" } */ +} + +void __attribute__ ((noclone, noinline)) +test_arr_strncat_1 (void) +{ + strncat (&b.a[i], b.a, n); /* { dg-warning "\\\[-Wrestrict" } */ +} + +void __attribute__ ((noclone, noinline)) +test_arr_strncat_2 (void) +{ + strncat (b.a, &b.a[i], n); /* { dg-warning "\\\[-Wrestrict" } */ +} + +void __attribute__ ((noclone, noinline)) +test_arr_strcpy_1 (void) +{ + strcpy (&b.a[i], b.a); /* { dg-warning "\\\[-Wrestrict" } */ +} + +void __attribute__ ((noclone, noinline)) +test_arr_strcpy_2 (void) +{ + strcpy (b.a, &b.a[i]); /* { dg-warning "\\\[-Wrestrict" } */ +} + + +struct S { + int a; + char b[10]; +} d; + +void __attribute__ ((noclone, noinline)) +test_obj_memcpy_1 (void) +{ + memcpy (d.b, (char *) &d, n); +} + +void __attribute__ ((noclone, noinline)) +test_obj_memcpy_2 (void) +{ + memcpy ((char *) &d, d.b, n); +} + +void __attribute__ ((noclone, noinline)) +test_obj_strcpy_1 (void) +{ + strcpy (d.b, (char *) &d); +} + +void __attribute__ ((noclone, noinline)) +test_obj_strcpy_2 (void) +{ + strcpy ((char *) &d, d.b); +} + +void __attribute__ ((noclone, noinline)) +test_obj_strncat_1 (void) +{ + strncat (d.b, (char *) &d, n); /* { dg-warning "\\\[-Wrestrict" } */ +} + +void __attribute__ ((noclone, noinline)) +test_obj_strncat_2 (void) +{ + strncat ((char *) &d, d.b, n); /* { dg-warning "\\\[-Wrestrict" } */ +} + +void __attribute__ ((noclone, noinline)) +test_obj_strncpy_1 (void) +{ + strncpy (d.b, (char *) &d, n); +} + +void test_obj_strncpy_2 (void) +{ + strncpy ((char *) &d, d.b, n); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-11.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-11.c new file mode 100644 index 0000000000..07b9cddad4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-11.c @@ -0,0 +1,206 @@ +/* PR tree-optimization/84526 - ICE in generic_overlap + Unrelated to the ICE but rather to PR 84095 that introduced it, verify + that calls to strncpy involving multidimensional arrays of structs don't + trigger false positive -Wrestrict warnings. + { dg-do compile } + { dg-options "-O2 -Wrestrict -ftrack-macro-expansion=0" } + { dg-skip-if "too many arguments in function call" { bpf-*-* } } */ + +typedef __SIZE_TYPE__ size_t; + +extern char* strcpy (char*, const char*); + +struct MemArrays +{ + char a1[4]; + char a2[4][4]; + char a3[4][4][4]; +} ma1[4], ma2[4][4], ma3[4][4][4]; + +#define T(dst, src) do { \ + strcpy (src, "123"); \ + strcpy (dst, src); \ + } while (0) + + +void test_ma1_cst (const char *s) +{ + T (ma1[0].a1, ma1[0].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + T (ma1[0].a1, ma1[1].a1); + T (ma1[0].a1, ma1[2].a1); + T (ma1[0].a1, ma1[3].a1); + + T (ma1[0].a1, ma1[0].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + T (ma1[1].a1, ma1[0].a1); + T (ma1[2].a1, ma1[0].a1); + T (ma1[3].a1, ma1[0].a1); +} + + +void test_ma1_var_cst (const char *s, int i) +{ + T (ma1[i].a1, ma1[0].a1); + T (ma1[i].a1, ma1[1].a1); + T (ma1[i].a1, ma1[2].a1); + T (ma1[i].a1, ma1[3].a1); + + T (ma1[0].a1, ma1[i].a1); + T (ma1[1].a1, ma1[i].a1); + T (ma1[2].a1, ma1[i].a1); + T (ma1[3].a1, ma1[i].a1); +} + + +void test_ma1_var_var (const char *s, int i, int j) +{ + T (ma1[i].a1, ma1[j].a1); + T (ma1[i].a1, ma1[j].a1); + T (ma1[i].a1, ma1[j].a1); + T (ma1[i].a1, ma1[j].a1); + + T (ma1[i].a1, ma1[j].a1); + T (ma1[i].a1, ma1[j].a1); + T (ma1[i].a1, ma1[j].a1); + T (ma1[i].a1, ma1[j].a1); +} + + +void test_ma2_cst (const char *s) +{ + T (ma2[0][0].a1, ma2[0][0].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + T (ma2[0][0].a1, ma2[0][1].a1); + T (ma2[0][0].a1, ma2[0][2].a1); + T (ma2[0][0].a1, ma2[0][3].a1); + + T (ma2[0][0].a1, ma2[1][0].a1); + T (ma2[0][0].a1, ma2[1][1].a1); + T (ma2[0][0].a1, ma2[1][2].a1); + T (ma2[0][0].a1, ma2[1][3].a1); + + T (ma2[0][0].a1, ma2[2][0].a1); + T (ma2[0][0].a1, ma2[2][1].a1); + T (ma2[0][0].a1, ma2[2][2].a1); + T (ma2[0][0].a1, ma2[2][3].a1); + + T (ma2[0][0].a1, ma2[3][0].a1); + T (ma2[0][0].a1, ma2[3][1].a1); + T (ma2[0][0].a1, ma2[3][2].a1); + T (ma2[0][0].a1, ma2[3][3].a1); + + + T (ma2[0][1].a1, ma2[0][0].a1); + T (ma2[0][1].a1, ma2[0][1].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + T (ma2[0][1].a1, ma2[0][2].a1); + T (ma2[0][1].a1, ma2[0][3].a1); + + T (ma2[0][1].a1, ma2[1][0].a1); + T (ma2[0][1].a1, ma2[1][1].a1); + T (ma2[0][1].a1, ma2[1][2].a1); + T (ma2[0][1].a1, ma2[1][3].a1); + + T (ma2[0][1].a1, ma2[2][0].a1); + T (ma2[0][1].a1, ma2[2][1].a1); + T (ma2[0][1].a1, ma2[2][2].a1); + T (ma2[0][1].a1, ma2[2][3].a1); + + T (ma2[0][1].a1, ma2[3][0].a1); + T (ma2[0][1].a1, ma2[3][1].a1); + T (ma2[0][1].a1, ma2[3][2].a1); + T (ma2[0][1].a1, ma2[3][3].a1); + + + T (ma2[0][2].a1, ma2[0][0].a1); + T (ma2[0][2].a1, ma2[0][1].a1); + T (ma2[0][2].a1, ma2[0][2].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + T (ma2[0][2].a1, ma2[0][3].a1); + + T (ma2[0][2].a1, ma2[1][0].a1); + T (ma2[0][2].a1, ma2[1][1].a1); + T (ma2[0][2].a1, ma2[1][2].a1); + T (ma2[0][2].a1, ma2[1][3].a1); + + T (ma2[0][2].a1, ma2[2][0].a1); + T (ma2[0][2].a1, ma2[2][1].a1); + T (ma2[0][2].a1, ma2[2][2].a1); + T (ma2[0][2].a1, ma2[2][3].a1); + + T (ma2[0][2].a1, ma2[3][0].a1); + T (ma2[0][2].a1, ma2[3][1].a1); + T (ma2[0][2].a1, ma2[3][2].a1); + T (ma2[0][2].a1, ma2[3][3].a1); + + + T (ma2[0][3].a1, ma2[0][0].a1); + T (ma2[0][3].a1, ma2[0][1].a1); + T (ma2[0][3].a1, ma2[0][2].a1); + T (ma2[0][3].a1, ma2[0][3].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + + T (ma2[0][3].a1, ma2[1][0].a1); + T (ma2[0][3].a1, ma2[1][1].a1); + T (ma2[0][3].a1, ma2[1][2].a1); + T (ma2[0][3].a1, ma2[1][3].a1); + + T (ma2[0][3].a1, ma2[2][0].a1); + T (ma2[0][3].a1, ma2[2][1].a1); + T (ma2[0][3].a1, ma2[2][2].a1); + T (ma2[0][3].a1, ma2[2][3].a1); + + T (ma2[0][3].a1, ma2[3][0].a1); + T (ma2[0][3].a1, ma2[3][1].a1); + T (ma2[0][3].a1, ma2[3][2].a1); + T (ma2[0][3].a1, ma2[3][3].a1); +} + + +void test_ma2_var (int i0, int j0, int i1, int j1) +{ + T (ma2[i0][j0].a1, ma2[i0][j0].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + + T (ma2[i0][j0].a1, ma2[i0][j1].a1); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (ma2[i0][j0].a1, ma2[i1][j1].a1); /* { dg-bogus "\\\[-Wrestrict]" } */ + + T (ma2[0][0].a2[i0], ma2[0][0].a2[j0]); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (ma2[0][i0].a2[0], ma2[0][i1].a2[0]); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (ma2[i0][0].a2[0], ma2[i1][0].a2[0]); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (ma2[i0][j0].a2[0], ma2[i1][j1].a2[0]); /* { dg-bogus "\\\[-Wrestrict]" } */ +} + + +void test_p2_var (struct MemArrays **p2, int i0, int j0, int i1, int j1) +{ + T (p2[i0][j0].a1, p2[i0][j0].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + + T (p2[i0][j0].a1, p2[i0][j1].a1); + T (p2[i0][j0].a1, p2[i1][j1].a1); + + T (p2[0][0].a2[i0], p2[0][0].a2[j0]); + T (p2[0][i0].a2[0], p2[0][i1].a2[0]); + T (p2[i0][0].a2[0], p2[i1][0].a2[0]); + T (p2[i0][j0].a2[0], p2[i1][j1].a2[0]); +} + + +void test_ma3_cst (const char *s) +{ + T (ma3[0][0][0].a1, ma3[0][0][0].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + T (ma3[0][0][0].a1, ma3[0][0][3].a1); + + T (ma3[0][0][0].a1, ma3[0][1][0].a1); + T (ma3[0][0][0].a1, ma3[0][1][3].a1); + T (ma3[0][0][0].a1, ma3[1][0][0].a1); + T (ma3[0][0][0].a1, ma3[1][0][3].a1); + T (ma3[0][0][0].a1, ma3[3][0][3].a1); + T (ma3[0][0][0].a1, ma3[3][3][3].a1); +} + + +void test_ma3_var (const char *s, + int i0, int j0, int k0, + int i1, int j1, int k1) +{ + T (ma3[i0][j0][k0].a1, ma3[i0][j0][k0].a1); /* { dg-warning "\\\[-Wrestrict]" } */ + + T (ma3[i0][j0][k0].a1, ma3[i0][j0][k1].a1); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (ma3[i0][j0][k0].a1, ma3[i0][j1][k1].a1); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (ma3[i0][j0][k0].a1, ma3[i1][j1][k1].a1); /* { dg-bogus "\\\[-Wrestrict]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-12.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-12.c new file mode 100644 index 0000000000..84ab6b50d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-12.c @@ -0,0 +1,66 @@ +/* PR tree-optimization/83456 - -Wrestrict false positive on + a non-overlapping memcpy in an inline function + { dg-do compile } + { dg-options "-O2 -Wrestrict -ftrack-macro-expansion=0" } */ + +extern void* memcpy (void*, const void*, __SIZE_TYPE__); + +/* Test case from comment #0. */ + +inline void pr83456_comment0 (void *d, void *s, unsigned N) +{ + if (s != d) + memcpy (d, s, N); +} + +void call_pr83456_comment0 (void* src) +{ + pr83456_comment0 (src, src, 1); +} + + +/* Test case from comment #1. */ + +char a[4]; + +void pr83456_comment1 (unsigned n) +{ + for (int i = 0; i < 1; i++) + { + if (!i) + continue; + + memcpy (a, a, n); + } +} + +/* Test case from comment #2. */ + +struct netdevice { + void *priv; +}; + +struct ip_tunnel { + struct netdevice *dev; + int ip6rd[3]; +}; + +struct sit_net { + struct netdevice *fb_tunnel_dev; +}; + +void ipip6_tunnel_clone_6rd (struct netdevice *dev, struct sit_net *sitn) +{ + struct ip_tunnel *t = dev->priv; + if (t->dev == sitn->fb_tunnel_dev) + return; + + struct ip_tunnel *t0 = sitn->fb_tunnel_dev->priv; + memcpy(&t->ip6rd, &t0->ip6rd, sizeof(t->ip6rd)); +} + +void sit_init_net (struct sit_net *sitn, struct netdevice *fb_tunnel_dev) +{ + sitn->fb_tunnel_dev = fb_tunnel_dev; + ipip6_tunnel_clone_6rd (sitn->fb_tunnel_dev, sitn); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-13.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-13.c new file mode 100644 index 0000000000..e4f00c7f2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-13.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/83519 - missing -Wrestrict on an overlapping + strcpy to a non-member array + { dg-do compile } + { dg-options "-O2 -Wall -Wrestrict" } */ + +extern char* stpcpy (char*, const char*); // work around bug 82429 + +struct S { char a[17]; }; + +void f (struct S *p, const char *s) +{ + __builtin_strcpy (p->a, "0123456789abcdef"); + + __builtin_strcpy (p->a, p->a + 4); /* { dg-warning "\\\[-Wrestrict]" } */ +} + +char a[17]; + +void g (const char *s) +{ + __builtin_strcpy (a, "0123456789abcdef"); + + __builtin_strcpy (a, a + 4); /* { dg-warning "\\\[-Wrestrict]" } */ +} + +void h (const char *s) +{ + char a[17]; + + __builtin_strcpy (a, "0123456789abcdef"); + + __builtin_strcpy (a, a + 4); /* { dg-warning "\\\[-Wrestrict]" } */ + + extern void sink (void*); + sink (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-14.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-14.c new file mode 100644 index 0000000000..b919fa644d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-14.c @@ -0,0 +1,221 @@ +/* PR tree-optimization/83456 - -Wrestrict false positive on a non-overlapping + memcpy in an inline function + Verify that calls to built-in functions are diagnosed when the pointer + arguments to their restrict-qualified parameters are the same (the absence + of the false positives reported in PR 83456 is tested in Wrestrict-12.c. + { dg-do compile } + { dg-options "-O2 -Wall -Wrestrict -Wno-stringop-truncation" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void* restrict, const void* restrict, size_t); +extern void* mempcpy (void* restrict, const void* restrict, size_t); +extern char* stpncpy (char* restrict, const char* restrict, size_t); +extern char* stpcpy (char* restrict, const char* restrict); +extern char* strncat (char* restrict, const char* restrict, size_t); +extern char* strcat (char* restrict, const char* restrict); +extern char* strncpy (char* restrict, const char* restrict, size_t); +extern char* strcpy (char* restrict, const char* restrict); + +struct S +{ + char a[4]; + char *p; +} s; + +void sink (void*); + +void test_memcpy (char *p, struct S *q, size_t n) +{ + /* The behavior of memcpy() is undefined only when when copying takes + place between overlapping objects. Since a call with a size of zero + does nothing, it should not be diagnosed. */ + memcpy (p, p, 0); + sink (p); + + memcpy (p, p, 1); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + memcpy (p, p, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + memcpy (q->a, q->a, 0); + sink (q); + + memcpy (q->p, q->p, 1); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + memcpy (&q->a[0], q->a, n); /* { dg-warning "\\\[-Wrestrict]" "bug ????" { xfail *-*-* } } */ + sink (q); + + memcpy (q, q->a, n); /* { dg-warning "\\\[-Wrestrict]" "bug ????" { xfail *-*-* } } */ + sink (q); +} + +void test_mempcpy (char *p, struct S *q, size_t n) +{ + mempcpy (p, p, 0); + sink (p); + + mempcpy (p, p, 1); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + mempcpy (p, p, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + mempcpy (q->a, q->a, 0); + sink (q); + + mempcpy (q->p, q->p, 1); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + mempcpy (&q->a[0], q->a, n); /* { dg-warning "\\\[-Wrestrict]" "bug ????" { xfail *-*-* } } */ + sink (q); + + mempcpy (q, q->a, n); /* { dg-warning "\\\[-Wrestrict]" "bug ????" { xfail *-*-* } } */ + sink (q); +} + +void test_strncat (char *p, struct S *q, size_t n) +{ + strncat (p, p, 0); + sink (p); + + strncat (p, p, 1); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strncat (p, p, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strncat (q->a, q->a, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strncat (&q->a[0], &q->a[0], n);/* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strncat (q->a, &q->a[0], n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strncat (q->p, &q->p[0], n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); +} + +void test_strcat (char *p, struct S *q, size_t n) +{ + strcat (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strcat (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strcat (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strcat (q->a, q->a); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strcat (&q->a[0], &q->a[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strcat (q->a, &q->a[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strcat (q->p, &q->p[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); +} + +void test_stpncpy (char *p, struct S *q, size_t n) +{ + stpncpy (p, p, 0); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + stpncpy (p, p, 1); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + stpncpy (p, p, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + stpncpy (q->a, q->a, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + stpncpy (&q->a[0], &q->a[0], n);/* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + stpncpy (q->a, &q->a[0], n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + stpncpy (q->p, &q->p[0], n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); +} + +void test_stpcpy (char *p, struct S *q, size_t n) +{ + stpcpy (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + stpcpy (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + stpcpy (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + stpcpy (q->a, q->a); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + stpcpy (&q->a[0], &q->a[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + stpcpy (q->a, &q->a[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + stpcpy (q->p, &q->p[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); +} + +void test_strncpy (char *p, struct S *q, size_t n) +{ + strncpy (p, p, 0); + sink (p); + + strncpy (p, p, 1); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strncpy (p, p, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strncpy (q->a, q->a, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strncpy (&q->a[0], &q->a[0], n);/* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strncpy (q->a, &q->a[0], n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strncpy (q->p, &q->p[0], n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); +} + +void test_strcpy (char *p, struct S *q, size_t n) +{ + strcpy (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strcpy (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strcpy (p, p); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (p); + + strcpy (q->a, q->a); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strcpy (&q->a[0], &q->a[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strcpy (q->a, &q->a[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); + + strcpy (q->p, &q->p[0]); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (q); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-15.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-15.c new file mode 100644 index 0000000000..b0b30a2bae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-15.c @@ -0,0 +1,38 @@ +/* PR 85365 - -Wrestrict false positives with -fsanitize=undefined + { dg-do compile } + { dg-options "-O2 -Wrestrict -fsanitize=undefined" } */ + +typedef __SIZE_TYPE__ size_t; + +char *strcpy (char *, const char *); +char *strcat (char *, const char *); + +size_t strlen (char *); + +extern char a[], b[], d[]; + +size_t t1 (char *g, int i) +{ + /* The following exercises the handling in gimple-fold.c. */ + strcpy (g + 4, i ? b : a); /* { dg-bogus "\\\[-Wrestrict]" } */ + return strlen (g + 4); +} + +void t2 (char *g, int i) +{ + strcpy (g + 4, i ? b : a); /* { dg-bogus "\\\[-Wrestrict]" } */ + strcat (g + 4, d); +} + +void t3 (char *g, int i) +{ + /* The following exercises the handling in gimple-ssa-warn-restrict.c. */ + strcat (g + 4, i ? b : a); /* { dg-bogus "\\\[-Wrestrict]" } */ + strcat (g + 4, d); +} + +void t4 (char *p, char *q) +{ + strcpy (p, q); /* { dg-bogus "\\\[-Wrestrict]" } */ + strcat (p, q + 32); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-16.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-16.c new file mode 100644 index 0000000000..196d2c5cbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-16.c @@ -0,0 +1,88 @@ +/* PR tree-optimization/85753 - missing -Wrestrict on memcpy into a member + array + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#define memcpy __builtin_memcpy + +char a[16]; + +struct { char a[16]; } x; + +/* Exercise aggregate types. */ + +void test_aggr_idx_nowarn (int i, int j) +{ + memcpy (&a[i], &a[j], 7); + memcpy (&x.a[i], &x.a[j], 7); +} + +void test_aggr_idx_warn (int i, int j) +{ + memcpy (&a[i], &a[j], 9); /* { dg-warning "\\\[-Wrestrict" } */ + memcpy (&x.a[i], &x.a[j], 9); /* { dg-warning "\\\[-Wrestrict" } */ +} + +void test_aggr_off_nowarn (int i, int j) +{ + memcpy (a + i, a + j, 5); + memcpy (x.a + i, x.a + j, 5); +} + +void test_aggr_off_warn (int i, int j) +{ + memcpy (a + i, a + j, 9); /* { dg-warning "\\\[-Wrestrict" } */ + memcpy (x.a + i, x.a + j, 9); /* { dg-warning "\\\[-Wrestrict" } */ +} + + +void sink (void*); + +#define T(call) sink (call) + + +/* Also exercise basic types. */ + +#ifdef __UINT32_TYPE__ + +__UINT32_TYPE__ i32; + +void test_basic_32 (int i, int j) +{ + char *p = (char*)&i32; + + T (memcpy (&p[i], &p[j], 1)); + T (memcpy (&p[i], &p[j], 2)); + T (memcpy (&p[i], &p[j], 3)); /* { dg-warning "\\\[-Wrestrict" } */ + + T (memcpy (p + i, p + j, 1)); + T (memcpy (p + i, p + j, 2)); + T (memcpy (p + i, p + j, 3)); /* { dg-warning "\\\[-Wrestrict" } */ +} + +#endif + +#ifdef __UINT64_TYPE__ + +__UINT64_TYPE__ i64; + +void test_basic_64 (int i, int j) +{ + char *p = (char*)&i64; + + T (memcpy (&p[i], &p[j], 1)); + T (memcpy (&p[i], &p[j], 2)); + T (memcpy (&p[i], &p[j], 3)); + T (memcpy (&p[i], &p[j], 5)); /* { dg-warning "\\\[-Wrestrict" } */ + T (memcpy (&p[i], &p[j], 6)); /* { dg-warning "\\\[-Wrestrict" } */ + T (memcpy (&p[i], &p[j], 7)); /* { dg-warning "\\\[-Wrestrict" } */ + + T (memcpy (p + i, p + j, 1)); + T (memcpy (p + i, p + j, 2)); + T (memcpy (p + i, p + j, 3)); + T (memcpy (p + i, p + j, 5)); /* { dg-warning "\\\[-Wrestrict" } */ + T (memcpy (p + i, p + j, 6)); /* { dg-warning "\\\[-Wrestrict" } */ + T (memcpy (p + i, p + j, 7)); /* { dg-warning "\\\[-Wrestrict" } */ +} + +#endif diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-17.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-17.c new file mode 100644 index 0000000000..4e7259734b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-17.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on + a variable-length struct + { dg-do compile } + { dg-require-effective-target alloca } + { dg-options "-O2 -Wall" } */ + +int f (int n) +{ + typedef struct { int a[n]; } S; + + S a; + __attribute__ ((noinline)) S g (void) { return a; } + + a.a[0] = 1; + a.a[9] = 2; + + S b; + b = g (); + + return b.a[0] == 1 && b.a[9] == 2; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-18.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-18.c new file mode 100644 index 0000000000..dbad9566bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-18.c @@ -0,0 +1,37 @@ +/* PR tree-optimization/86196 - Bogus -Wrestrict on memcpy between array + elements at unequal indices + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); + +struct S +{ + int n; + void * p; +}; + +/* Test case submitted in the PR. */ + +void pr86196_c0 (struct S * a, size_t n) +{ + for (size_t i = 0, j = 0; i != n; ++i) + { + if (a[i].n == 0) + { + if (i != j) + memcpy (&a[j], &a[i], sizeof (struct S)); /* { dg-bogus "\\\[-Wrestrict" } */ + ++j; + } + } +} + +/* Reduced test case. */ + +void pr86196_c1 (struct S *a, int i, int j) +{ + if (i != j) + memcpy (&a[j], &a[i], sizeof (struct S)); /* { dg-bogus "\\\[-Wrestrict" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-19.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-19.c new file mode 100644 index 0000000000..d4750537c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-19.c @@ -0,0 +1,32 @@ +/* PR middle-end/89934 - ICE on a call with fewer arguments to strncpy + declared without prototype + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +char *strncpy (); + +char* f0 (char *s) +{ + return strncpy (); +} + +char* f1 (char *s) +{ + return strncpy (s); +} + +char* f2 (char *s) +{ + return strncpy (s, s + 1); /* ICE here. */ +} + +void f3 (char *s, size_t n, const char *t) +{ + strncpy (s, n, t); + strncpy (n, s, t); +} + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } + { dg-prune-output "\\\[-Wint-conversion]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-2.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-2.c new file mode 100644 index 0000000000..d73e144170 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-2.c @@ -0,0 +1,41 @@ +/* Test to verify that the temporary doesn't trigger a bogus -Warray-bounds + warning. Distilled from libat_exchange_large_inplace in libatomic/gexch.c. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef typeof (sizeof 0) size_t; + +extern void *memcpy (void*, const void*, size_t); + +void libat_exchange_large_inplace (size_t n, void *mptr, void *vptr) +{ + char temp[1024]; + + size_t i = 0; + + for (i = 0; n >= 1024; i += 1024, n -= 1024) + { + memcpy (temp, mptr + i, 1024); + + /* The memcpy call below results in the following: + unsigned long ivtmp.7; + + ivtmp.7_4 = (unsigned long) mptr_9(D); + ... + + # ivtmp.7_22 = PHI + ... + _1 = (void *) ivtmp.7_22; + ... + memcpy (_1, _2, 1024); + + Treating _1 as a pointer results in the bogus: + warning: 'memcpy' offset 0 is out of the bounds [0, 8] of object 'ivtmp.7' with type 'long unsigned int' [-Warray-bounds] + memcpy (mptr + i, vptr + i, 1024); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + memcpy (mptr + i, vptr + i, 1024); + + memcpy (vptr + i, temp, 1024); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-20.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-20.c new file mode 100644 index 0000000000..a2d29887c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-20.c @@ -0,0 +1,41 @@ +/* PR c/84919 - bogus -Wrestrict on sprintf %p with destination as argument + { dg-do compile } + -O2 isn't strictly necessary but setting also verifies that the sprintf/ + strlen pass doesn't warn with non-constant arguments. + { dg-options "-O2 -Wall" } */ + +extern int sprintf (char* restrict, const char* restrict, ...); +extern int snprintf (char* restrict, __SIZE_TYPE__, const char* restrict, ...); + +char a[32]; + +void test_warn (char *p) +{ + a[0] = 0; + sprintf (a, "a=%s", a); /* { dg-warning "-Wrestrict" } */ + + p = a; + char *q = p + 3; + sprintf (p, "a=%s", q); /* { dg-warning "-Wrestrict" } */ +} + +void test_nowarn_front_end (char *d) +{ + sprintf (d, "%p", d); + snprintf (d, 32, "%p", d); + + sprintf (a, "p=%p", a); + snprintf (a, sizeof a, "%p", a); +} + +void test_nowarn_sprintf_pass (char *d) +{ + char *q = d; + + sprintf (d, "p=%p", q); + snprintf (d, 32, "p=%p", q); + + q = a; + sprintf (a, "a=%p", q); + snprintf (a, sizeof a, "a=%p", q); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-21.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-21.c new file mode 100644 index 0000000000..e300663758 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-21.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wrestrict" } */ + +static char * +str_numth(char *dest, char *num, int type) +{ + if (dest != num) + __builtin_strcpy(dest, num); /* { dg-bogus "is the same" } */ + __builtin_strcat(dest, "foo"); + return dest; +} + +void +DCH_to_char(char *in, char *out, int collid) +{ + char *s = out; + str_numth(s, s, 42); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-22.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-22.c new file mode 100644 index 0000000000..46f507b56b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-22.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wrestrict" } */ + +void test_memcpy_warn (char *d, unsigned n) +{ + for (unsigned i = n; i < 30; ++i) + if (i > 10) + __builtin_memcpy (d, d + 2, i); /* { dg-warning "overlaps" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-23.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-23.c new file mode 100644 index 0000000000..c7a828bb8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-23.c @@ -0,0 +1,146 @@ +/* PR tree-optimization/102238 - missing -Wrestrict on sprintf formatting + a struct member into enclosing object + { dg-do compile } + { dg-options "-O2 -Wall -Wno-format-overflow" } */ + +extern int sprintf (char*, const char*, ...); + +extern void sink (void*, ...); + +struct A +{ + char a[4]; +}; + +struct B +{ + struct A a1, a2; +}; + +extern struct B eb; + +enum { B_a2_a_off = __builtin_offsetof (struct B, a2.a) }; + + +void test_warn_src_decl_plus (void) +{ + { + char *s = (char*)&eb + B_a2_a_off; + char *d = eb.a2.a; + sprintf (d, "%s", s); // { dg-warning "overlaps" } + } + + { + // If strlen (s) > 0 there is overlap with a[1]. + char *s = (char*)&eb + B_a2_a_off + 1; + char *d = eb.a2.a; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + } + + { + // strlen (s) must be at most 1 so there can be no overlap with a. + char *s = (char*)&eb + B_a2_a_off + 2; + char *d = eb.a2.a; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" } + } + + { + // strlen (s) must be at most 0 so there can be no overlap with a. + char *s = (char*)&eb + B_a2_a_off + 3; + char *d = eb.a2.a; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" } + } +} + + +void test_warn_src_ptr_plus (struct B *p) +{ + { + char *s = (char*)p + B_a2_a_off; + char *d = p->a2.a; + sprintf (d, "%s", s); // { dg-warning "overlaps" } + } + + { + // If strlen (s) > 0 there is overlap with a[1]. + char *s = (char*)p + B_a2_a_off + 1; + char *d = p->a2.a; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + } + + { + // strlen (s) must be at most 1 so there can be no overlap with a. + char *s = (char*)p + B_a2_a_off + 2; + char *d = p->a2.a; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" } + } + + { + // strlen (s) must be at most 0 so there can be no overlap with a. + char *s = (char*)p + B_a2_a_off + 3; + char *d = p->a2.a; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" } + } +} + + +void test_warn_dst_decl_plus (void) +{ + { + char *s = eb.a2.a; + char *d = (char*)&eb + B_a2_a_off; + sprintf (d, "%s", s); // { dg-warning "overlaps" } + } + + { + // If strlen (a) > 0 there is overlap with a[1]. + char *s = eb.a2.a; + char *d = (char*)&eb + B_a2_a_off + 1; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + } + + { + // If strlen (a) > 1 there is overlap with a[2]. + char *s = eb.a2.a; + char *d = (char*)&eb + B_a2_a_off + 2; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + } + + { + // If strlen (a) > 2 there is overlap with a[3]. + char *s = eb.a2.a; + char *d = (char*)&eb + B_a2_a_off + 3; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + } +} + + +void test_warn_dst_ptr_plus (struct B *p) +{ + { + char *s = p->a2.a; + char *d = (char*)p + B_a2_a_off; + sprintf (d, "%s", s); // { dg-warning "overlaps" } + } + + { + // If strlen (a) > 0 there is overlap with a[1]. + char *s = p->a2.a; + char *d = (char*)p + B_a2_a_off + 1; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + } + + { + // If strlen (a) > 1 there is overlap with a[2]. + char *s = p->a2.a; + char *d = (char*)p + B_a2_a_off + 2; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + } + + { + // If strlen (a) > 2 there is overlap with a[3]. + char *s = p->a2.a; + char *d = (char*)p + B_a2_a_off + 3; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-24.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-24.c new file mode 100644 index 0000000000..d224d80f87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-24.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/105604 - ICE: in tree_to_shwi with vla in struct + and sprintf + { dg-do compile } + { dg-options "-O2 -Wall -Wrestrict" } */ + +extern int sprintf (char*, const char*, ...); + +extern void* sink (void*, ...); + +struct { + long users; + long size; + char *data; +} * main_trans; + +void *main___trans_tmp_1; + +int users = 0; + +void test (void) +{ + struct { + long users; + long size; + char *data; + int links[users]; + char buf[]; + } *trans = sink (0); + + trans->data = trans->buf; + main___trans_tmp_1 = trans; + main_trans = main___trans_tmp_1; + sprintf (main_trans->data, "test"); + sink (main_trans->data); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-25.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-25.c new file mode 100644 index 0000000000..a15f56d742 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-25.c @@ -0,0 +1,165 @@ +/* PR tree-optimization/105604 - ICE: in tree_to_shwi with vla in struct + and sprintf + { dg-do compile } + { dg-options "-O2 -Wall -Wrestrict" } */ + +extern int sprintf (char*, const char*, ...); + +void* sink (void*); + + +void sprintf_S_a8_an_bn (int n, int i, int j) +{ + struct { + char a8[8], an[n], bn[n]; + } *p = sink (0); + + { + char *d = p->a8 + i; + char *s = p->a8; + sprintf (d, "%s", s); // { dg-warning "argument 3 may overlap" } + sink (p); + } + + { + char *d = p->a8; + char *s = p->a8 + j; + sprintf (d, "%s", s); // { dg-warning "argument 3 may overlap" } + sink (p); + } + + { + char *d = p->a8 + i; + char *s = p->a8 + j; + sprintf (d, "%s", s); // { dg-warning "argument 3 may overlap" } + sink (p); + } + + { + char *d = p->a8 + i; + char *s = p->an; + sprintf (d, "%s", s); + sink (p); + } + + { + char *d = p->a8; + char *s = p->an + j; + sprintf (d, "%s", s); + sink (p); + } + + { + char *d = p->a8 + i; + char *s = p->an + j; + sprintf (d, "%s", s); + sink (p); + } + + { + /* The IL makes it impossible to rule out an overlap between + p->a8 + i and p->bn + i so the "may overlap" warning triggers. */ + char *d = p->a8 + i; + char *s = p->bn; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" "pr??????" { xfail *-*-* } } + sink (p); + } + + { + char *d = p->a8; + char *s = p->bn + j; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" "pr??????" { xfail *-*-* } } + sink (p); + } + + { + char *d = p->a8 + i; + char *s = p->bn + j; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" "pr??????" { xfail *-*-* } } + sink (p); + } + + { + char *d = p->an + i; + char *s = p->bn; + sprintf (d, "%s", s); + sink (p); + } + + { + char *d = p->an; + char *s = p->bn + j; + sprintf (d, "%s", s); + sink (p); + } + + { + char *d = p->an + i; + char *s = p->bn + j; + sprintf (d, "%s", s); + sink (p); + } + + { + char *d = p->an + i; + char *s = p->a8; + sprintf (d, "%s", s); + sink (p); + } + + { + char *d = p->an; + char *s = p->a8 + j; + sprintf (d, "%s", s); + sink (p); + } + + { + char *d = p->an + i; + char *s = p->a8 + j; + sprintf (d, "%s", s); + sink (p); + } + + { + char *d = p->bn + i; + char *s = p->a8; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" "pr??????" { xfail *-*-* } } + sink (p); + } + + { + char *d = p->bn; + char *s = p->a8 + j; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" "pr??????" { xfail *-*-* } } + sink (p); + } + + { + char *d = p->bn + i; + char *s = p->a8 + j; + sprintf (d, "%s", s); // { dg-bogus "-Wrestrict" "pr??????" { xfail *-*-* } } + sink (p); + } + + { + char *d = p->bn + i; + char *s = p->bn; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + sink (p); + } + + { + char *d = p->bn; + char *s = p->bn + j; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + sink (p); + } + + { + char *d = p->bn + i; + char *s = p->bn + j; + sprintf (d, "%s", s); // { dg-warning "may overlap" } + sink (p); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-26.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-26.c new file mode 100644 index 0000000000..a10c426a08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-26.c @@ -0,0 +1,114 @@ +/* Verify that sprintf calls with arrays or struct of arrays don't + cause -Wrestrict false positives. + { dg-do compile } + { dg-options "-O2 -Wall -Wrestrict -ftrack-macro-expansion=0" } */ + +#define sprintf(d, f, ...) (sprintf (d, f, __VA_ARGS__), sink (d)) + +extern void sink (void*, ...); +extern int (sprintf) (char*, const char*, ...); + +extern char ca[][2][8]; + +void test_array_of_arrays (void) +{ + sprintf (ca[0][0], "%s", ca[0][0]); // { dg-warning "-Wrestrict" } + sprintf (ca[0][0], "%s", ca[0][1]); + sprintf (ca[0][0], "%s", ca[1][0]); + sprintf (ca[0][0], "%s", ca[1][1]); + + sprintf (ca[0][1], "%s", ca[0][0]); + sprintf (ca[0][1], "%s", ca[0][1]); // { dg-warning "-Wrestrict" } + sprintf (ca[0][1], "%s", ca[1][0]); + sprintf (ca[0][1], "%s", ca[1][1]); + + sprintf (ca[1][0], "%s", ca[0][0]); + sprintf (ca[1][0], "%s", ca[0][1]); + sprintf (ca[1][0], "%s", ca[1][0]); // { dg-warning "-Wrestrict" } + sprintf (ca[1][0], "%s", ca[1][1]); + + sprintf (ca[1][1], "%s", ca[0][0]); + sprintf (ca[1][1], "%s", ca[0][1]); + sprintf (ca[1][1], "%s", ca[1][0]); + sprintf (ca[1][1], "%s", ca[1][1]); // { dg-warning "-Wrestrict" } +} + + +struct A +{ + char a[2][2][8]; + char b[2][2][8]; + char c[2][2][8]; +}; + +extern struct A aa[][2]; + +void test_array_of_structs (void) +{ + // Verify that calls with the same elements of the same array trigger + // warnings as expected. + sprintf (aa[0][0].a[0][0], "%s", aa[0][0].a[0][0]); // { dg-warning "-Wrestrict" } + sprintf (aa[0][0].a[0][1], "%s", aa[0][0].a[0][1]); // { dg-warning "-Wrestrict" } + sprintf (aa[0][0].a[1][0], "%s", aa[0][0].a[1][0]); // { dg-warning "-Wrestrict" } + sprintf (aa[0][0].a[1][1], "%s", aa[0][0].a[1][1]); // { dg-warning "-Wrestrict" } + sprintf (aa[0][1].a[0][0], "%s", aa[0][1].a[0][0]); // { dg-warning "-Wrestrict" } + sprintf (aa[0][1].a[0][1], "%s", aa[0][1].a[0][1]); // { dg-warning "-Wrestrict" } + sprintf (aa[0][1].a[1][0], "%s", aa[0][1].a[1][0]); // { dg-warning "-Wrestrict" } + sprintf (aa[0][1].a[1][1], "%s", aa[0][1].a[1][1]); // { dg-warning "-Wrestrict" } + sprintf (aa[1][0].a[0][0], "%s", aa[1][0].a[0][0]); // { dg-warning "-Wrestrict" } + sprintf (aa[1][0].a[0][1], "%s", aa[1][0].a[0][1]); // { dg-warning "-Wrestrict" } + sprintf (aa[1][0].a[1][0], "%s", aa[1][0].a[1][0]); // { dg-warning "-Wrestrict" } + sprintf (aa[1][0].a[1][1], "%s", aa[1][0].a[1][1]); // { dg-warning "-Wrestrict" } + sprintf (aa[1][1].a[0][0], "%s", aa[1][1].a[0][0]); // { dg-warning "-Wrestrict" } + sprintf (aa[1][1].a[0][1], "%s", aa[1][1].a[0][1]); // { dg-warning "-Wrestrict" } + sprintf (aa[1][1].a[1][0], "%s", aa[1][1].a[1][0]); // { dg-warning "-Wrestrict" } + sprintf (aa[1][1].a[1][1], "%s", aa[1][1].a[1][1]); // { dg-warning "-Wrestrict" } + +#define NOWARN() + + // Exhaustively verify that calls with different elements of the same + // array don't cause false positives. +#undef NOWARN +#define NOWARN(D, S) \ + sprintf (D[0][0], "%s", S[0][0]); \ + sprintf (D[0][0], "%s", S[0][1]); \ + sprintf (D[0][0], "%s", S[1][0]); \ + sprintf (D[0][0], "%s", S[1][1]); \ + sprintf (D[0][1], "%s", S[0][0]); \ + sprintf (D[0][1], "%s", S[0][1]); \ + sprintf (D[0][1], "%s", S[1][0]); \ + sprintf (D[0][1], "%s", S[1][1]); \ + sprintf (D[1][0], "%s", S[0][0]); \ + sprintf (D[1][0], "%s", S[0][1]); \ + sprintf (D[1][0], "%s", S[1][0]); \ + sprintf (D[1][0], "%s", S[1][1]); \ + sprintf (D[1][1], "%s", S[0][0]); \ + sprintf (D[1][1], "%s", S[0][1]); \ + sprintf (D[1][1], "%s", S[1][0]); \ + sprintf (D[1][1], "%s", S[1][1]) + + NOWARN (aa[0][0].a, aa[0][1].a); + NOWARN (aa[0][0].a, aa[1][0].a); + NOWARN (aa[0][0].a, aa[1][1].a); + + NOWARN (aa[0][1].a, aa[0][0].a); + NOWARN (aa[0][1].a, aa[1][0].a); + NOWARN (aa[0][1].a, aa[1][1].a); + + NOWARN (aa[1][0].a, aa[0][0].a); + NOWARN (aa[1][0].a, aa[0][1].a); + NOWARN (aa[1][0].a, aa[1][1].a); + +#define NOWARN_MEM(M1, M2) \ + NOWARN (aa[0][0].M1, aa[0][0].M2); \ + NOWARN (aa[0][0].M1, aa[0][1].M2); \ + NOWARN (aa[0][0].M1, aa[1][0].M2); \ + NOWARN (aa[0][0].M1, aa[1][1].M2) + + NOWARN_MEM (a, b); + NOWARN_MEM (a, c); + NOWARN_MEM (b, a); + NOWARN_MEM (b, c); + NOWARN_MEM (c, a); + NOWARN_MEM (c, b); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-3.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-3.c new file mode 100644 index 0000000000..1204111ea3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-3.c @@ -0,0 +1,17 @@ +/* Test to verify that the call below with the out-of-bounds offset + doesn't trigger an internal assertion and is diagnosed. + { dg-do compile } + { dg-options "-O2 -Wrestrict" } */ + +#define DIFF_MAX __PTRDIFF_MAX__ + +void test_no_ice (int *d, __PTRDIFF_TYPE__ i, __SIZE_TYPE__ n) +{ + if (i < DIFF_MAX / sizeof *d - 1 || DIFF_MAX / sizeof *d + 2 < i) + i = DIFF_MAX / sizeof *d - 1; + + if (n < DIFF_MAX) + n = DIFF_MAX / sizeof *d; + + __builtin_strncpy ((char*)(d + i), (char*)d, n); /* { dg-warning "\\\[-Wrestrict]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-4.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-4.c new file mode 100644 index 0000000000..a95960e751 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-4.c @@ -0,0 +1,113 @@ +/* PR tree-optimization/83603 - ICE in builtin_memref at + gcc/gimple-ssa-warn-restrict.c:238 + Test to verify that invalid calls to built-in functions declared + without a prototype don't cause an ICE. + { dg-do compile } + { dg-prune-output "conflicting types for built-in" } + { dg-options "-O2 -Warray-bounds -Wrestrict" } */ + +void* memcpy (); +void* memmove (); +char* stpcpy (); +char* strcat (); +char* strcpy (); +char* strncat (); +char* strncpy (); + +void* test_memcpy_0 () +{ + return memcpy (); +} + +void* test_memcpy_1 (void *d) +{ + return memcpy (d); +} + +void* test_memcpy_2 (void *d, const void *s) +{ + return memcpy (d, s); +} + + +void* test_memmove_0 () +{ + return memmove (); +} + +void* test_memmove_1 (void *d) +{ + return memmove (d); +} + +void* test_memmove_2 (void *d, const void *s) +{ + return memmove (d, s); +} + + +void* test_stpcpy_0 () +{ + return stpcpy (); +} + +void* test_stpcpy_1 (char *d) +{ + return stpcpy (d); +} + + +char* test_strcat_0 () +{ + return strcat (); +} + +char* test_strcat_1 (char *d) +{ + return strcat (d); +} + + +void* test_strcpy_0 () +{ + return strcpy (); +} + +void* test_strcpy_1 (char *d) +{ + return strcpy (d); +} + + +char* test_strncat_0 () +{ + return strncat (); +} + +char* test_strncat_1 (char *d) +{ + return strncat (d); +} + +char* test_strncat_2 (char *d, const char *s) +{ + return strncat (d, s); +} + + +void* test_strncpy_0 () +{ + return strncpy (); +} + +void* test_strncpy_1 (char *d) +{ + return strncpy (d); +} + +void* test_strncpy_2 (char *d, const char *s) +{ + return strncpy (d, s); +} + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-5.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-5.c new file mode 100644 index 0000000000..21e190129e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-5.c @@ -0,0 +1,38 @@ +/* PR tree-optimization/83655 - ICE on an invalid call to memcpy declared + with no prototype + Test to verify that valid calls to common restrict-qualified built-in + functions declared with no prototype are checked for overlap, and that + invalid calls are ignored. + { dg-do compile } + { dg-options "-O2 -Wrestrict" } */ + +void* memcpy (); +char* strncpy (); + +#if __cplusplus +} /* extern "C" */ +#endif + +void test_memcpy_warn (char *d) +{ + memcpy (d, d + 2, 3); /* { dg-warning "accessing 3 bytes at offsets 0 and 2 overlaps 1 byte at offset 2" } */ +} + +void test_memcpy_nowarn (char *d) +{ + memcpy (d, d + 2, ""); +} + + +void test_strncpy_warn (char *d) +{ + strncpy (d + 1, d + 3, 5); /* { dg-warning "accessing 5 bytes at offsets 1 and 3 overlaps between 1 and 2 bytes at offset 3" } */ +} + +void test_strncpy_nowarn (char *d) +{ + strncpy (d + 1, d + 3, ""); +} + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } + { dg-prune-output "\\\[-Wint-conversion]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-6.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-6.c new file mode 100644 index 0000000000..d1ef1a3e60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-6.c @@ -0,0 +1,66 @@ +/* PR tree-optimization/83640 - ice in generic_overlap, at + gimple-ssa-warn-restrict.c:814 + Test to verify that a pointer offset range whose upper bound is less + than its lower bound (when interpreted as a signed integer) is handled + correctly. + { dg-do compile } + { dg-options "-O2 -Wrestrict" } */ + +#include "range.h" + +extern char* strcpy (char*, const char*); +extern char* stpcpy (char*, const char*); + +void sink (void*); + +void warn_2_smax_p2 (void) +{ + char a[7] = "01234"; + + char *d = a; + + ptrdiff_t i = UR (2, DIFF_MAX + (size_t)2); + + strcpy (d, d + i); /* { dg-warning "accessing between 1 and 4 bytes at offsets 0 and \\\[2, 7] may overlap up to 2 bytes at offset \\\[2, 3]" } */ + + sink (d); +} + +void nowarn_3_smax_p2 (void) +{ + char a[7] = "12345"; + + char *d = a; + + ptrdiff_t i = UR (3, DIFF_MAX + (size_t)2); + + strcpy (d, d + i); + + sink (d); +} + +void warn_2u_smax_p2 (void) +{ + char a[7] = "23456"; + + char *d = a; + + size_t i = UR (2, DIFF_MAX + (size_t)2); + + strcpy (d, d + i); /* { dg-warning "accessing between 1 and 4 bytes at offsets 0 and \\\[2, 7] may overlap up to 2 bytes at offset \\\[2, 3]" } */ + + sink (d); +} + +void nowarn_3u_smax_p2 (void) +{ + char a[7] = "34567"; + + char *d = a; + + size_t i = UR (3, DIFF_MAX + (size_t)2); + + strcpy (d, d + i); + + sink (d); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-7.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-7.c new file mode 100644 index 0000000000..5be5e0bd05 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-7.c @@ -0,0 +1,51 @@ +/* PR tree-optimization/83698 - bogus offset in -Wrestrict messages for + strcat of unknown strings + { dg-do compile } + { dg-options "-O2 -Wrestrict -ftrack-macro-expansion=0" } */ + +extern char* strcat (char*, const char*); + +void sink (char*); + +#define T(d, s) sink (strcat (d, s)) + +extern char arr[]; + + +void test_strcat_array_cst_offset (void) +{ + T (arr, arr + 1); /* { dg-warning "accessing 2 or more bytes at offsets 0 and 1 may overlap 1 byte at offset 1" } */ + T (arr, arr + 2); /* { dg-warning "accessing 3 or more bytes at offsets 0 and 2 may overlap 1 byte at offset 2" } */ + T (arr, arr + 13); /* { dg-warning "accessing 14 or more bytes at offsets 0 and 13 may overlap 1 byte at offset 13" } */ + + T (arr + 1, arr); /* { dg-warning "accessing 2 or more bytes at offsets 1 and 0 may overlap 1 byte at offset 1" } */ + T (arr + 17, arr + 11); /* { dg-warning "accessing 7 or more bytes at offsets 17 and 11 may overlap 1 byte at offset 17" } */ + T (arr + 36, arr + 20); /* { dg-warning "accessing 17 or more bytes at offsets 36 and 20 may overlap 1 byte at offset 36" } */ +} + +void test_strcat_ptr_cst_offset (char *d) +{ + T (d - 12, d + 34); /* { dg-warning "accessing 47 or more bytes at offsets -12 and 34 may overlap 1 byte at offset 34" } */ + T (d + 12, d + 34); /* { dg-warning "accessing 23 or more bytes at offsets 12 and 34 may overlap 1 byte at offset 34" } */ + T (d + 20, d + 36); /* { dg-warning "accessing 17 or more bytes at offsets 20 and 36 may overlap 1 byte at offset 36" } */ +} + +void test_strcat_array_var_offset (int i, int j) +{ + T (arr + i, arr); /* { dg-warning "accessing 1 or more bytes at offsets \\\[0, \[0-9\]+] and 0 may overlap 1 byte at offset \\\[0, \[0-9\]+]" } */ + T (arr, arr + j); /* { dg-warning "accessing 1 or more bytes at offsets 0 and \\\[0, \[0-9\]+] may overlap 1 byte at offset \\\[0, \[0-9\]+]" } */ + T (arr + i, arr + j); /* { dg-warning "accessing 1 or more bytes at offsets \\\[0, \[0-9\]+] and \\\[0, \[0-9\]+] may overlap 1 byte at offset \\\[0, \[0-9\]+]" } */ + + T (arr + i, arr + 5); /* { dg-warning "accessing 6 or more bytes at offsets \\\[0, \[0-9\]+] and 5 may overlap 1 byte at offset \\\[5, \[0-9\]+]" } */ + T (arr + 7, arr + j); /* { dg-warning "accessing 8 or more bytes at offsets 7 and \\\[0, \[0-9\]+] may overlap 1 byte at offset \\\[7, \[0-9\]+]" } */ +} + +void test_strcat_ptr_var_offset (char *d, int i, int j) +{ + T (d + i, d); /* { dg-warning "accessing \[0-9\]+ or more bytes at offsets \\\[-\[0-9\]+, \[0-9\]+] and 0 may overlap 1 byte at offset \\\[0, \[0-9\]+]" } */ + T (d, d + j); /* { dg-warning "accessing \[0-9\]+ or more bytes at offsets 0 and \\\[-\[0-9\]+, \[0-9\]+] may overlap 1 byte at offset \\\[0, \[0-9\]+]" } */ + T (d + i, d + j); /* { dg-warning "accessing 1 or more bytes at offsets \\\[-\[0-9\]+, \[0-9\]+] and \\\[-\[0-9\]+, \[0-9\]+] may overlap 1 byte at offset \\\[-\[0-9\]+, \[0-9\]+]" } */ + + T (d + i, d + 3); /* { dg-warning "accessing \[0-9\]+ or more bytes at offsets \\\[-\[0-9\]+, \[0-9\]+] and 3 may overlap 1 byte at offset \\\[3, \[0-9\]+]" } */ + T (d + 9, d + j); /* { dg-warning "accessing \[0-9\]+ or more bytes at offsets 9 and \\\[-\[0-9\]+, \[0-9\]+] may overlap 1 byte at offset \\\[9, \[0-9\]+]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-8.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-8.c new file mode 100644 index 0000000000..62e8bbc302 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-8.c @@ -0,0 +1,118 @@ +/* PR tree-optimization/84095 - false-positive -Wrestrict warnings for + memcpy within array + { dg-do compile } + { dg-options "-O2 -Wrestrict -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void* restrict, const void* restrict, size_t); + +void foo (void *); + +#define T(d, s, n) do { memcpy (d, s, n); foo (d); } while (0) + +struct S1 { char c; } a8_1[8]; + +void test_1_dim_var (int i, int j) +{ + /* Variable destination index and constant source index. */ + T (&a8_1[i], &a8_1[0], 1); + T (&a8_1[i], &a8_1[0], 2); + T (&a8_1[i], &a8_1[0], 3); + T (&a8_1[i], &a8_1[0], 4); + + T (&a8_1[i], &a8_1[0], 5); /* { dg-warning "accessing 5 bytes at offsets \\\[0, 8] and 0 overlaps between 2 and 5 bytes at offset \\\[0, 3\\\]" } */ + T (&a8_1[i], &a8_1[0], 6); /* { dg-warning "accessing 6 bytes at offsets \\\[0, 8] and 0 overlaps between 4 and 6 bytes at offset \\\[0, 2\\\]" } */ + T (&a8_1[i], &a8_1[0], 7); /* { dg-warning "accessing 7 bytes at offsets \\\[0, 8] and 0 overlaps between 6 and 7 bytes at offset \\\[0, 1\\\]" } */ + T (&a8_1[i], &a8_1[0], 8); /* { dg-warning "accessing 8 bytes at offsets \\\[0, 8] and 0 overlaps 8 bytes at offset 0" } */ + + /* The following is diagnosed by -Warray-bounds when it's enabled + rather than by -Wrestrict. */ + T (&a8_1[i], &a8_1[0], 9); /* { dg-warning "accessing 9 bytes at offsets \\\[0, 8] and 0 overlaps 9 bytes at offset 0" } */ + + /* Same as above but with constant destination index and variable + source index. */ + T (&a8_1[0], &a8_1[i], 1); + T (&a8_1[0], &a8_1[i], 2); + T (&a8_1[0], &a8_1[i], 3); + T (&a8_1[0], &a8_1[i], 4); + + T (&a8_1[0], &a8_1[i], 5); /* { dg-warning "accessing 5 bytes at offsets 0 and \\\[0, 8] overlaps between 2 and 5 bytes at offset \\\[0, 3\\\]" } */ + T (&a8_1[0], &a8_1[i], 6); /* { dg-warning "accessing 6 bytes at offsets 0 and \\\[0, 8] overlaps between 4 and 6 bytes at offset \\\[0, 2\\\]" } */ + T (&a8_1[0], &a8_1[i], 7); /* { dg-warning "accessing 7 bytes at offsets 0 and \\\[0, 8] overlaps between 6 and 7 bytes at offset \\\[0, 1\\\]" } */ + T (&a8_1[0], &a8_1[i], 8); /* { dg-warning "accessing 8 bytes at offsets 0 and \\\[0, 8] overlaps 8 bytes at offset 0" } */ + T (&a8_1[0], &a8_1[i], 9); /* { dg-warning "accessing 9 bytes at offsets 0 and \\\[0, 8] overlaps 9 bytes at offset 0" } */ + + + /* Variable destination and source indices. */ + T (&a8_1[i], &a8_1[j], 1); + T (&a8_1[i], &a8_1[j], 2); + T (&a8_1[i], &a8_1[j], 3); + T (&a8_1[i], &a8_1[j], 4); + + T (&a8_1[i], &a8_1[j], 5); /* { dg-warning "accessing 5 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps between 2 and 5 bytes at offset \\\[0, 3\\\]" } */ + T (&a8_1[i], &a8_1[j], 6); /* { dg-warning "accessing 6 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps between 4 and 6 bytes at offset \\\[0, 2\\\]" } */ + T (&a8_1[i], &a8_1[j], 7); /* { dg-warning "accessing 7 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps between 6 and 7 bytes at offset \\\[0, 1\\\]" } */ + T (&a8_1[i], &a8_1[j], 8); /* { dg-warning "accessing 8 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps 8 bytes at offset 0" } */ + + /* The following is diagnosed by -Warray-bounds when it's enabled + rather than by -Wrestrict. */ + T (&a8_1[i], &a8_1[j], 9); /* { dg-warning "accessing 9 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps 9 bytes at offset 0" } */ +} + +struct S4 { char a4[4]; } a2_4[2]; + +void test_2_dim (int i, int j) +{ + T (&a2_4[i], &a2_4[0], 1); + T (&a2_4[i], &a2_4[0], 4); + + T (&a2_4[i], &a2_4[0], 5); /* { dg-warning "accessing 5 bytes at offsets \\\[0, 8] and 0 overlaps between 2 and 5 bytes at offset \\\[0, 3]" } */ + T (&a2_4[i], &a2_4[0], 6); /* { dg-warning "accessing 6 bytes at offsets \\\[0, 8] and 0 overlaps between 4 and 6 bytes at offset \\\[0, 2]" } */ + T (&a2_4[i], &a2_4[0], 7); /* { dg-warning "accessing 7 bytes at offsets \\\[0, 8] and 0 overlaps between 6 and 7 bytes at offset \\\[0, 1]" } */ + T (&a2_4[i], &a2_4[0], 8); /* { dg-warning "accessing 8 bytes at offsets \\\[0, 8] and 0 overlaps 8 bytes at offset 0" } */ + + T (a2_4[i].a4, a2_4[0].a4, 1); + T (a2_4[i].a4, a2_4[0].a4, 4); + + T (a2_4[i].a4, a2_4[0].a4, 5); /* { dg-warning "accessing 5 bytes at offsets \\\[0, 8] and 0 overlaps between 2 and 5 bytes at offset \\\[0, 3]" } */ + T (a2_4[i].a4, a2_4[0].a4, 8); /* { dg-warning "accessing 8 bytes at offsets \\\[0, 8] and 0 overlaps 8 bytes at offset 0" } */ + + T (a2_4[i].a4, a2_4[j].a4, 1); + T (a2_4[i].a4, a2_4[j].a4, 4); + + /* The destination and source offsets printed below ignore the size + of the copy and only indicate the values that are valid for each + of the destination and source arguments on its own, without + considering the size of the overlapping access. */ + T (a2_4[i].a4, a2_4[j].a4, 5); /* { dg-warning "accessing 5 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps between 2 and 5 bytes at offset \\\[0, 3]" } */ + T (a2_4[i].a4, a2_4[j].a4, 8); /* { dg-warning "accessing 8 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps 8 bytes at offset 0" } */ + + /* Same as above but referencing the first elements of each array. */ + T (&a2_4[i].a4[0], &a2_4[j].a4[0], 1); + T (&a2_4[i].a4[0], &a2_4[j].a4[0], 4); + + T (&a2_4[i].a4[0], &a2_4[j].a4[0], 5); /* { dg-warning "accessing 5 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps between 2 and 5 bytes at offset \\\[0, 3]" } */ + T (&a2_4[i].a4[0], &a2_4[j].a4[0], 8); /* { dg-warning "accessing 8 bytes at offsets \\\[0, 8] and \\\[0, 8] overlaps 8 bytes at offset 0" } */ + + T (&a2_4[i].a4[0], &a2_4[j].a4[1], 3); + T (&a2_4[i].a4[0], &a2_4[j].a4[2], 2); + T (&a2_4[i].a4[0], &a2_4[j].a4[3], 1); +} + +struct { int i; } a2[2][8]; + +void test_single_2_dim_major (int i) +{ + memcpy (&a2[i], &a2[0], sizeof *a2); /* { dg-bogus "\\\[-Wrestrict]" } */ +} + +void test_single_2_dim_minor (int i) +{ + memcpy (&a2[i][0], &a2[0][0], sizeof a2[0][0]); /* { dg-bogus "\\\[-Wrestrict]" } */ +} + +void test_single_2_dim_major_minor (int i, int j) +{ + memcpy (&a2[i][j], &a2[0][0], sizeof a2[0][0]); /* { dg-bogus "\\\[-Wrestrict]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict-9.c b/SingleSource/Regression/C/gcc-dg/Wrestrict-9.c new file mode 100644 index 0000000000..878fc811bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict-9.c @@ -0,0 +1,315 @@ +/* PR tree-optimization/84095 - false-positive -Wrestrict warnings for + strcpy within array + { dg-do compile } + { dg-options "-O2 -Wrestrict -Wno-stringop-overflow -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void* restrict, const void* restrict, size_t); +extern char* strcpy (char* restrict, const char* restrict); + +#define T(d, s) strcpy (d, s) + +struct MemArrays { + char pad[8]; + char a2[3][9]; + char a3[3][4][9]; +} a[2]; + +struct NestedMemArrays { + struct MemArrays ma; + struct MemArrays ma1[2]; +} nma[2]; + +/* Use a variable as the source of a copy to verify that VAR_DECL + is handled correctly when it's the source of GIMPLE assignment. */ +const char *str = "1234567"; + +void test_obj_2_dim_const (void) +{ + const char *s = strcpy (a[0].a2[0], "1234567"); + + T (a[0].a2[1], s); + T (a[0].a2[2], s); + + /* Ideally, the offsets in the warning below would be relative to + the beginning of the accessed array member. Unfortunately, when + the offset is represented as + MEM_REF (char[9], A, offsetof (struct MemArrays, A[0].A2[0]) + 1) + as it is in this instance it's difficult to determine the member + that is being accessed and tease out from the MEM_REF the offset + as it appears in the source. As a result, the warning mentions + the offset from the beginning of A instead. This is suboptimal + and should be fixed, either by printing the correct offsets or + by mentioning the base object that the offset is relative to. */ + T (a[0].a2[0] + 1, s); /* { dg-warning "accessing 8 bytes at offsets \(1|9\) and \(0|8\) overlaps 7 bytes at offset \(1|9\)." } */ + T (a[0].a2[1] + 2, s); + T (a[0].a2[2] + 3, s); + + T (a[1].a2[0], s); + T (a[1].a2[1], s); + T (a[1].a2[2], s); + + T (a[1].a2[0] + 1, s); + T (a[1].a2[1] + 2, s); + T (a[1].a2[2] + 3, s); +} + +void test_obj_nested_2_dim_const (void) +{ + const char *s = strcpy (nma[0].ma.a2[0], str); + + T (nma[0].ma.a2[1], s); + T (nma[0].ma.a2[2], s); + + T (nma[0].ma.a2[0] + 1, s); /* { dg-warning "accessing 8 bytes at offsets 1 and 0 overlaps 7 bytes at offset 1" "bug " { xfail *-*-* } } */ + T (nma[0].ma.a2[1] + 2, s); + T (nma[0].ma.a2[2] + 3, s); + + T (nma[1].ma.a2[1], s); + T (nma[1].ma.a2[2], s); + + T (nma[1].ma.a2[0] + 1, s); + T (nma[1].ma.a2[1] + 2, s); + T (nma[1].ma.a2[2] + 3, s); + + + T (nma[0].ma1[0].a2[1], s); + T (nma[0].ma1[0].a2[2], s); + + T (nma[0].ma1[0].a2[0] + 1, s); + T (nma[0].ma1[0].a2[1] + 2, s); + T (nma[0].ma1[0].a2[2] + 3, s); + + T (nma[1].ma1[0].a2[1], s); + T (nma[1].ma1[0].a2[2], s); + + T (nma[1].ma1[0].a2[0] + 1, s); + T (nma[1].ma1[0].a2[1] + 2, s); + T (nma[1].ma1[0].a2[2] + 3, s); +} + +void test_obj_2_dim_var (int i, int j) +{ + const char *s = memcpy (a[0].a2[0], "1234567", 8); + + T (a[i].a2[0], s); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (a[i].a2[1], s); + T (a[i].a2[2], s); + + T (a[i].a2[0] + 1, s); + T (a[i].a2[1] + 1, s); + T (a[i].a2[2] + 1, s); + + T (a[0].a2[i], s); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (a[1].a2[i], s); + + T (a[i].a2[0] + j, s); + T (a[i].a2[1] + j, s); + T (a[i].a2[2] + j, s); + + T (a[0].a2[i] + 1, s); + T (a[1].a2[i] + 1, s); + + T (a[0].a2[i] + j, s); + T (a[1].a2[i] + j, s); + + if (i < 0 || 1 < i) + i = 1; + + T (a[i].a2[0], s); + T (a[i].a2[1], s); + T (a[i].a2[2], s); + + T (a[i].a2[0] + 1, s); + T (a[i].a2[1] + 1, s); + T (a[i].a2[2] + 1, s); + + T (a[0].a2[i], s); + T (a[1].a2[i], s); + + T (a[i].a2[0] + j, s); + T (a[i].a2[1] + j, s); + T (a[i].a2[2] + j, s); + + T (a[0].a2[i] + 1, s); + T (a[1].a2[i] + 1, s); + + T (a[0].a2[i] + j, s); + T (a[1].a2[i] + j, s); +} + +void test_obj_nested_2_dim_var (int i, int j) +{ + const char *s = strcpy (nma[0].ma.a2[0], "1234567"); + + T (nma[i].ma.a2[0], s); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (nma[i].ma.a2[1], s); + T (nma[i].ma.a2[2], s); + + T (nma[i].ma.a2[0] + 1, s); + T (nma[i].ma.a2[1] + 1, s); + T (nma[i].ma.a2[2] + 1, s); + + T (nma[0].ma.a2[i], s); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (nma[1].ma.a2[i], s); + + T (nma[i].ma.a2[0] + j, s); + T (nma[i].ma.a2[1] + j, s); + T (nma[i].ma.a2[2] + j, s); + + T (nma[0].ma.a2[i] + 1, s); + T (nma[1].ma.a2[i] + 1, s); + + T (nma[0].ma.a2[i] + j, s); + T (nma[1].ma.a2[i] + j, s); +} + +void test_ref_2_dim_const (struct MemArrays *p) +{ + strcpy (p[0].a2[0], "1234567"); + const char *s = p[0].a2[0]; + + T (p[0].a2[1], s); + T (p[0].a2[2], s); + + T (p[1].a2[0], s); + T (p[1].a2[1], s); + T (p[1].a2[2], s); +} + +void test_ref_2_dim_var (struct MemArrays *p, int i, int j) +{ + strcpy (p[0].a2[0], "1234567"); + const char *s = p[0].a2[0]; + + T (p[i].a2[0], s); /* { dg-bogus "\\\[-Wrestrict]" } */ + T (p[i].a2[1], s); + T (p[i].a2[2], s); + + T (p[0].a2[i], s); + T (p[1].a2[i], s); + + T (p[i].a2[0] + j, s); + T (p[i].a2[1] + j, s); + T (p[i].a2[2] + j, s); + + T (p[0].a2[i] + j, s); + T (p[1].a2[i] + j, s); +} + +void test_obj_3_dim_var (int i, int j) +{ + strcpy (a[0].a3[0][0], "1234567"); + const char *s = a[0].a3[0][0]; + + T (a[0].a3[0][i], s); + T (a[0].a3[1][i], s); + T (a[0].a3[2][i], s); + + T (a[1].a3[0][i], s); + T (a[1].a3[1][i], s); + T (a[1].a3[2][i], s); + + T (a[0].a3[i][0], s); /* { dg-bogus "\\\[-Wrestrict\]" } */ + T (a[0].a3[i][1], s); + T (a[0].a3[i][2], s); + + T (a[1].a3[i][0], s); + T (a[1].a3[i][1], s); + T (a[1].a3[i][2], s); + + T (a[i].a3[0][0], s); /* { dg-bogus "\\\[-Wrestrict\]" } */ + T (a[i].a3[0][1], s); + T (a[i].a3[0][2], s); + + T (a[i].a3[1][0], s); + T (a[i].a3[1][1], s); + T (a[i].a3[1][2], s); + + T (a[i].a3[2][0], s); + T (a[i].a3[2][1], s); + T (a[i].a3[2][2], s); + + + T (a[0].a3[0][i] + 1, s); + T (a[0].a3[1][i] + 1, s); + T (a[0].a3[2][i] + 1, s); + + T (a[1].a3[0][i] + 1, s); + T (a[1].a3[1][i] + 1, s); + T (a[1].a3[2][i] + 1, s); + + + T (a[0].a3[0][i] + j, s); + T (a[0].a3[1][i] + j, s); + T (a[0].a3[2][i] + j, s); + + T (a[1].a3[0][i] + j, s); + T (a[1].a3[1][i] + j, s); + T (a[1].a3[2][i] + j, s); + + T (a[0].a3[i][0] + j, s); + T (a[0].a3[i][1] + j, s); + T (a[0].a3[i][2] + j, s); + + T (a[1].a3[i][0] + j, s); + T (a[1].a3[i][1] + j, s); + T (a[1].a3[i][2] + j, s); + + T (a[i].a3[0][0] + j, s); + T (a[i].a3[0][1] + j, s); + T (a[i].a3[0][2] + j, s); + + T (a[i].a3[1][0] + j, s); + T (a[i].a3[1][1] + j, s); + T (a[i].a3[1][2] + j, s); + + T (a[i].a3[2][0] + j, s); + T (a[i].a3[2][1] + j, s); + T (a[i].a3[2][2] + j, s); +} + +void test_obj_3_dim_const (struct MemArrays *p) +{ + strcpy (p[0].a3[0][0], "1234567"); + const char *s = p[0].a3[0][0]; + + T (p[0].a3[0][1], s); + T (p[0].a3[0][2], s); + T (p[0].a3[0][3], s); + + T (p[0].a3[0][1] + 1, s); + T (p[0].a3[0][2] + 1, s); + T (p[0].a3[0][3] + 1, s); + + T (p[0].a3[1][0], s); + T (p[0].a3[1][1], s); + T (p[0].a3[1][2], s); + T (p[0].a3[1][3], s); + + T (p[0].a3[1][0] + 1, s); + T (p[0].a3[1][1] + 1, s); + T (p[0].a3[1][2] + 1, s); + T (p[0].a3[1][3] + 1, s); + + T (p[0].a3[2][0], s); + T (p[0].a3[2][1], s); + T (p[0].a3[2][2], s); + T (p[0].a3[2][3], s); + + T (p[1].a3[0][0], s); + T (p[1].a3[0][1], s); + T (p[1].a3[0][2], s); + T (p[1].a3[0][3], s); + + T (p[1].a3[1][0], s); + T (p[1].a3[1][1], s); + T (p[1].a3[1][2], s); + T (p[1].a3[1][3], s); + + T (p[1].a3[2][0], s); + T (p[1].a3[2][1], s); + T (p[1].a3[2][2], s); + T (p[1].a3[2][3], s); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wrestrict.c b/SingleSource/Regression/C/gcc-dg/Wrestrict.c new file mode 100644 index 0000000000..266443fe25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wrestrict.c @@ -0,0 +1,35 @@ +/* Test to verify that VLAs are handled gracefully by -Wrestrict + { dg-do compile } + { dg-options "-O2 -Wrestrict" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +#define memcpy(d, s, n) __builtin_memcpy (d, s, n) +#define strcpy(d, s) __builtin_strcpy (d, s) + +void test_vla (void *d, const char *s1, const char *s2, int i, size_t n) +{ + char a[n]; + char b[n]; + + strcpy (a, s1); + strcpy (b, s2); + + memcpy (d, i ? a : b, n); +} + + +void test_vla_member (void *d, const char *s1, const char *s2, int i, size_t n) +{ + struct S + { + char a[n]; + char b[n]; + } s; + + strcpy (s.a, s1); + strcpy (s.b, s2); + + memcpy (d, i ? s.a : s.b, n); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-10.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-10.c new file mode 100644 index 0000000000..ddd2c36cf1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-10.c @@ -0,0 +1,56 @@ +/* PR c/71924 - missing -Wreturn-local-addr returning alloca result + Test reduced from libstdc++-v3/testsuite/ext/ext_pointer/1.cc. + It verifies that iteration in find_implicit_erroneous_behavior + in gimple-ssa-isolate-path.c terminates under specific conditions. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __UINTPTR_TYPE__ uintptr_t; + +struct A { int i; }; +struct P { uintptr_t d; }; + +static inline struct A* get (const struct P *p) +{ + if (p->d == 1) + return 0; + + return (struct A*)((uintptr_t)p + p->d); +} + +static inline void set (struct P *p, struct A* q) +{ + /* The basic block below would cause an infinite loop in + find_implicit_erroneous_behavior due to assuming the DUPLICATE + pointer returned from isolate_path would distinct from the one + passed to it. (Replacing the if statement with the ternary ?: + expression did not have this effect (it gets optimized early + on). + [local count: 1073741823]: + # _14 = PHI <0B(2), &MEM [(void *)&a + 4B](3)> + _2 = _14->i; + if (_2 != 2) + goto ; [0.00%] + else + goto ; [100.00%] + */ + if (!q) + p->d = 1; + else + p->d = (uintptr_t)(q) - (uintptr_t)(p); +} + +void f (void) +{ + struct A a[2] = { { 1 }, { 2 } }; + + struct P p, q; + set (&p, a); + set (&q, get (&p)); + + set (&q, get (&q) + 0); + set (&q, get (&q) + 1); + + if (get (&q)[0].i != get (&p)[1].i) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-2.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-2.c new file mode 100644 index 0000000000..9273690fef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-2.c @@ -0,0 +1,294 @@ +/* PR c/71924 - missing -Wreturn-local-addr returning alloca result + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) + +struct A { int a, b, c; }; +struct B { int a, b, c[]; }; + +void sink (void*, ...); + +ATTR (noipa) void* +return_alloca (int n) +{ + void *p = __builtin_alloca (n); + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_alloca_index_cst (int n) +{ + int *p = (int*)__builtin_alloca (n); + p = &p[1]; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_alloca_plus_cst (int n) +{ + int *p = (int*)__builtin_alloca (n); + p += 1; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_alloca_plus_var (int n, int i) +{ + char *p = (char*)__builtin_alloca (n); + p += i; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_alloca_member_1 (int n) +{ + struct A *p = (struct A*)__builtin_alloca (n); + sink (&p->a); + return &p->a; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_alloca_member_2 (int n) +{ + struct A *p = (struct A*)__builtin_alloca (n); + sink (&p->b); + return &p->b; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_alloca_flexarray (int n) +{ + struct B *p = (struct B*)__builtin_alloca (n); + sink (p->c); + return p->c; /* { dg-warning "function returns address of local" } */ +} + + +ATTR (noipa) void* +return_array (void) +{ + int a[32]; + void *p = a; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_array_index_cst (void) +{ + int a[32]; + void *p = &a[2]; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_array_plus_cst (void) +{ + int a[32]; + void *p = a + 2; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_array_plus_var (int i) +{ + int a[32]; + void *p = a + i; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_array_member_1 (void) +{ + struct A a[2]; + int *p = &a[1].a; + sink (a, p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_array_member_2 (void) +{ + struct A a[32]; + int *p = &a[1].b; + sink (a, p); + return p; /* { dg-warning "function returns address of local" } */ +} + + +ATTR (noipa) void* +return_vla (int n) +{ + char a[n]; + void *p = a; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_vla_index_cst (int n) +{ + char a[n]; + char *p = &a[3]; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_vla_plus_cst (int n) +{ + char a[n]; + char *p = a + 3; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_vla_index_var (int n, int i) +{ + char a[n]; + char *p = &a[i]; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_vla_plus_var (int n, int i) +{ + char a[n]; + char *p = a + i; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_vla_member_1 (int n, int i) +{ + struct A a[n]; + void *p = &a[i].a; + sink (a, p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_vla_member_2 (int n, int i) +{ + struct A a[n]; + void *p = &a[i].b; + sink (a, p); + return p; /* { dg-warning "function returns address of local" } */ +} + + +ATTR (noipa) void* +return_alloca_or_alloca (int n, int i) +{ + void *p = i ? __builtin_alloca (n * i) : __builtin_alloca (n); + sink (p); + /* The warning here should really be "function returns". */ + return p; /* { dg-warning "function (returns|may return) address of local" } */ +} + +ATTR (noipa) void* +return_alloca_or_alloca_2 (int n, int i) +{ + void *p0 = __builtin_alloca (n); + void *p1 = __builtin_alloca (n * 2); + void *p = i ? p0 : p1; + sink (p0, p1, p); + /* Same as above. */ + return p; /* { dg-warning "function (returns|may return) address of local" } */ +} + +ATTR (noipa) void* +return_array_or_array (int i) +{ + int a[5]; + int b[7]; + void *p = i ? a : b; + sink (a, b, p); + /* The warning here should really be "function returns". */ + return p; /* { dg-warning "function (returns|may return) address of local" } */ +} + +ATTR (noipa) void* +return_array_or_array_plus_var (int i, int j) +{ + int a[5]; + int b[7]; + + void *p0 = a + i; + void *p1 = b + j; + + void *p = i < j ? p0 : p1; + sink (a, b, p0, p1, p); + /* The warning here should really be "function returns". */ + return p; /* { dg-warning "function (returns|may return) address of local" } */ +} + +extern int global[32]; + +ATTR (noipa) void* +may_return_global_or_alloca (int n, int i) +{ + void *p = i ? global : __builtin_alloca (n); + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} + + +ATTR (noipa) void* +may_return_global_or_alloca_plus_cst (int n, int i) +{ + int *p = i ? global : (int*)__builtin_alloca (n); + p += 7; + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +may_return_global_or_array (int n, int i) +{ + int a[32]; + void *p = i ? global : a; + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +may_return_global_or_array_plus_cst (int n, int i) +{ + int a[32]; + int *p = i ? global : a; + p += 4; + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +may_return_global_or_vla (int n, int i) +{ + int a[n]; + void *p = i ? global : a; + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +may_return_global_or_vla_plus_cst (int n, int i) +{ + int a[n]; + int *p = i ? global : a; + p += 4; + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-3.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-3.c new file mode 100644 index 0000000000..e922888a4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-3.c @@ -0,0 +1,249 @@ +/* PR c/71924 - missing -Wreturn-local-addr returning alloca result + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) + +typedef __INTPTR_TYPE__ intptr_t; + +struct A { int a, b, c; }; +struct B { int a, b, c[]; }; + +extern int g1[5], g2[5], g3[5], g4[5], g5[5]; + +void sink (void*, ...); + +/* Verify that a pointer difference expression is handled correctly + even when converted to a pointer. */ + +ATTR (noipa) void* +return_local_diff_cst (void) +{ + int a[5]; + void *p = (void*)(&a[4] - &a[1]); + return p; +} + +ATTR (noipa) void* +return_local_diff_var (int i, int j) +{ + int a[5]; + void *p = (void*)(&a[j] - &a[i]); + return p; +} + +ATTR (noipa) void* +return_2_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + void *p = i < 0 ? a : b; + return p; /* { dg-warning "function returns address of local" } */ +} + +/* Verify that returning the address of a local converted to intptr_t + is not diagnosed (see bug 90737 for a case the front-end gets wrong). */ + +ATTR (noipa) intptr_t +return_int_2_locals (int i) +{ + int a[1]; + int b[2]; + void *p = i < 0 ? a : b; + return (intptr_t)p; +} + +/* Verify that a conditional expression with a pointer first operand + is handled correctly. */ + +ATTR (noipa) void* +return_2_locals_ptrcond (void *q) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + void *p = q ? a : b; + return p; /* { dg-warning "function returns address of local" } */ +} + +/* Verify that a preincrement expression with a pointer operand is + handled correctly. */ + +ATTR (noipa) void* +return_2_locals_ptrinc (void *q) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int *p = q ? a : b; + return ++p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_3_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + + void *p = i < 0 ? a : 0 < i ? c : b; + return p; /* { dg-warning "function returns address of local" } */ +} + +/* Verify that a conditional expression with a pointer first operand + is handled correctly. */ + +ATTR (noipa) void* +return_3_locals_ptrcond (void *p, void *q) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + + void *r = q ? r ? a : b : c; + return r; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_5_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + int d[4]; /* { dg-message "declared here" } */ + int e[5]; /* { dg-message "declared here" } */ + + void *p = i < -1 ? a : i < 0 ? b : 1 < i ? e : 0 < i ? d : c; + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_1_global_4_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + int d[4]; /* { dg-message "declared here" } */ + + void *p = i < -1 ? a : i < 0 ? b : 1 < i ? g1 : 0 < i ? d : c; + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_2_globals_3_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + + void *p = i < -1 ? a : i < 0 ? b : 1 < i ? g1 : 0 < i ? g2 : c; + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_3_globals_2_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + void *p = i < -1 ? a : i < 0 ? b : 1 < i ? g1 : 0 < i ? g2 : g3; + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_4_globals_1_local (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + + void *p = i < -1 ? a : i < 0 ? g1 : 1 < i ? g2 : 0 < i ? g4 : g3; + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_all_globals (int i) +{ + void *p = i < -1 ? g1 : i < 0 ? g2 : 1 < i ? g3 : 0 < i ? g5 : g4; + return p; +} + + +ATTR (noipa) void* +return_2_alloca_local_cstoff (int n, int i) +{ + int *a = __builtin_alloca (n); /* { dg-message "declared here" } */ + int *b = __builtin_alloca (n); /* { dg-message "declared here" } */ + int *p = i < 0 ? a : b; + p += 1; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_alloca_local_cstoff (int n, int i) +{ + int *a = __builtin_alloca (n); /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int *p = i < 0 ? a : b; + p += 1; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_local_alloca_cstoff (int n, int i) +{ + int a[2]; /* { dg-message "declared here" } */ + int *b = __builtin_alloca (n); /* { dg-message "declared here" } */ + int *p = i < 0 ? a : b; + p += 1; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_2_locals_cstoff (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int *p = i < 0 ? a : b; + p += 1; + sink (p); + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_2_globals_3_locals_cstoff (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + + int *p = i < -1 ? a : i < 0 ? b : 1 < i ? g1 : 0 < i ? g2 : c; + p += 1; + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_3_globals_alloca_local_varoff (int n, int i, int j) +{ + int *a = __builtin_alloca (n); /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + int *p = i < -1 ? a : i < 0 ? b : 1 < i ? g1 : 0 < i ? g2 : g3; + p += j; + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_3_globals_2_locals_varoff (int i, int j) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + int *p = i < -1 ? a : i < 0 ? b : 1 < i ? g1 : 0 < i ? g2 : g3; + p += j; + sink (p); + return p; /* { dg-warning "function may return address of local" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-4.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-4.c new file mode 100644 index 0000000000..4a3b07ba02 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-4.c @@ -0,0 +1,371 @@ +/* PR c/71924 - missing -Wreturn-local-addr returning alloca result + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) + +struct A { int a, b, c; }; +struct B { int a, b, c[]; }; + +extern int g1[5], g2[5], g3[5], g4[5], g5[5]; + +void sink (void*, ...); + +ATTR (noipa) void* +return_2_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + void *p = b; + if (i < 0) + p = a; + + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_2_locals_after_2_globals (int i, int j) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + int *p; + if (i < 0) + p = g1; + else + p = g2; + + sink (p); + + if (j < 0) + p = a; + else + p = b; + + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_3_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + + void *p = b + 1; + if (i < 0) + p = a; + else if (0 < i) + p = c + 2; + + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_5_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + int d[4]; /* { dg-message "declared here" } */ + int e[5]; /* { dg-message "declared here" } */ + + void *p = &c[2]; + if (i < -1) + p = a; + else if (i < 0) + p = &b[1]; + else if (1 < i) + p = &e[4]; + else if (0 < i) + p = &d[3]; + + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_5_locals_switch (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + int d[4]; /* { dg-message "declared here" } */ + int e[5]; /* { dg-message "declared here" } */ + + void *p = 0; + + switch (i) + { + case 0: p = &a[1]; break; + case 1: p = &b[2]; break; + case 2: p = &c[3]; break; + case 3: p = &d[4]; break; + default: p = &e[5]; break; + } + + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_1_global_4_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + int d[4]; /* { dg-message "declared here" } */ + + void *p = c; + if (i < -1) + sink (p = a); + else if (i < 0) + sink (p = b); + else if (1 < i) + sink (p = g1); + else if (0 < i) + sink (p = d); + + sink (p, a, b, c, d); + + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_1_global_4_locals_switch (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + int d[4]; /* { dg-message "declared here" } */ + + void *p = 0; + + switch (i) + { + case 0: p = &a[0]; break; + case 1: p = &b[1]; break; + case 2: p = &c[2]; break; + case 3: p = &d[3]; break; + } + + sink (p); + + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_2_globals_3_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + + void *p = c; + if (i < -1) + p = a; + else if (i < 0) + p = b; + else if (1 < i) + p = g1; + else if (0 < i) + p = g2; + + sink (p); + + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_3_globals_2_locals (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + void *p = g3; + if (i < -1) + p = a; + else if (i < 0) + p = b; + else if (1 < i) + p = g1; + else if (0 < i) + p = g2; + + sink (p); + + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_4_globals_1_local (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + + void *p = g3; + if (i < -1) + p = a; + else if (i < 0) + p = g1; + else if (1 < i) + p = g2; + else if (0 < i) + p = g4; + + sink (p); + + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_all_globals (int i) +{ + void *p = g4; + if (i < -1) + p = g1; + else if (i < 0) + p = g2; + else if (1 < i) + p = g3; + else if (0 < i) + p = g5; + return p; +} + + +ATTR (noipa) void* +return_2_alloca_local_cstoff (int n, int i) +{ + int *a = __builtin_alloca (n); /* { dg-message "declared here" } */ + int *b = __builtin_alloca (n); /* { dg-message "declared here" } */ + int *p = i < 0 ? a : b; + + p += 1; + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_alloca_local_cstoff (int n, int i) +{ + int *a = __builtin_alloca (n); /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + int *p = b; + if (i < 0) + p = a; + + p += 1; + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_local_alloca_cstoff (int n, int i) +{ + int a[2]; /* { dg-message "declared here" } */ + int *b = __builtin_alloca (n); /* { dg-message "declared here" } */ + int *p = b; + if (i < 0) + p = a; + + p += 1; + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_2_locals_cstoff (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + int *p = b; + if (i < 0) + p = a; + + p += 1; + sink (p); + + return p; /* { dg-warning "function returns address of local" } */ +} + +ATTR (noipa) void* +return_2_globals_3_locals_cstoff (int i) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + int c[3]; /* { dg-message "declared here" } */ + + int *p = c; + if (i < -1) + p = a; + else if (i < 0) + p = b; + else if (1 < i) + p = g1; + else if (0 < i) + p = g2; + + p += 1; + sink (p); + + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_3_globals_alloca_local_varoff (int n, int i, int j) +{ + int *a = __builtin_alloca (n); /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + int *p = g3; + if (i < -1) + p = a; + else if (i < 0) + p = b; + else if (1 < i) + p = g1; + else if (0 < i) + p = g2; + + p += j; + sink (p); + + return p; /* { dg-warning "function may return address of local" } */ +} + +ATTR (noipa) void* +return_3_globals_2_locals_varoff (int i, int j) +{ + int a[1]; /* { dg-message "declared here" } */ + int b[2]; /* { dg-message "declared here" } */ + + int *p = g3; + if (i < -1) + p = a; + else if (i < 0) + p = b; + else if (1 < i) + p = g1; + else if (0 < i) + p = g2; + + p += j; + sink (p); + + return p; /* { dg-warning "function may return address of local" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-5.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-5.c new file mode 100644 index 0000000000..bdf1cd40c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-5.c @@ -0,0 +1,40 @@ +/* PR c/71924 - missing -Wreturn-local-addr returning alloca result + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void sink (void*); + +void* loop_idx (int x) +{ + char a[32]; /* { dg-message "declared here" } */ + char *p = a; + + sink (a); + + int i; + for (i = 0; i != 32; ++i) + if (p[i] == x) + break; + + p = i < 32 ? &p[i] : 0; + return p; /* { dg-warning "may return address of local variable" } */ +} + + +void* loop_ptr (int i, int x) +{ + char a[32]; /* { dg-message "declared here" } */ + char *p; + + sink (a); + + /* The warning for the statement below would ideally be a "returns" + because it definitely returns the address of a, but when both + returns get merged into one we end up with a "may return". */ + for (p = a; *p; ++p) + if (*p == x) + return p; /* { dg-warning "(returns|may return) address of local variable" "missing location" { xfail *-*-* } } */ + /* { dg-warning "(returns|may return) address of local variable" "pr90735" { target *-*-* } 0 } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-6.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-6.c new file mode 100644 index 0000000000..844660ff01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-6.c @@ -0,0 +1,204 @@ +/* PR c/71924 - missing -Wreturn-local-addr returning alloca result + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +void* memcpy (void*, const void*, size_t); +void* mempcpy (void*, const void*, size_t); +void* memmove (void*, const void*, size_t); + +char* stpcpy (char*, const char*); +char* stpncpy (char*, const char*, size_t); + +size_t strlen (const char*); +size_t strnlen (const char*, size_t); + +char* strcat (char*, const char*); +char* strncat (char*, const char*, size_t); + +char* strcpy (char*, const char*); +char* strncpy (char*, const char*, size_t); + +char* strdup (const char*); + +char* strchr (const char*, int); +char* strrchr (const char*, int); +char* strstr (const char*, const char*); + +void sink (void*, ...); + + +void* return_memcpy (const void *s, unsigned n) +{ + char a[n]; /* { dg-message "declared here" } */ + void *p = memcpy (a, s, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +void* return_memcpy_cst (const void *s, unsigned n) +{ + char a[n]; /* { dg-message "declared here" } */ + void *p = memcpy (a + 1, s, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +void* return_memcpy_var (const void *s, unsigned n, int i) +{ + char a[n]; /* { dg-message "declared here" } */ + void *p = memcpy (a + i, s, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +void* return_mempcpy (const void *s, unsigned n) +{ + char a[n]; /* { dg-message "declared here" } */ + void *p = mempcpy (a, s, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +void* return_memmove_cst (unsigned n) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + void *p = memmove (a + 1, a, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +void* return_memmove_var (unsigned n, int i) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + void *p = memmove (a + i, a, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_stpcpy (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + char *p = stpcpy (a, s); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_stpncpy (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + char *p = stpncpy (a, s, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strcat (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + char *p = strcat (a, s); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strncat (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + char *p = strncat (a, s, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ + +} +char* return_strcpy (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + char *p = strcpy (a, s); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strcpy_plus_strlen (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + char *p = strcpy (a, s); + sink (p); + p += strlen (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strcpy_cst_plus_strlen (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + char *p = strcpy (a + 1, s); + sink (p); + p += strlen (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strcpy_var_plus_strlen (unsigned n, const char *s, int i) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + char *p = strcpy (a + i, s); + sink (p); + p += strlen (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strncpy (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + char *p = strncpy (a, s, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strncpy_plus_strnlen (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + char *p = strncpy (a, s, n); + p += strnlen (p, n); + sink (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strdup (unsigned n) +{ + char a[n]; + sink (a); + char *p = strdup (a); + return p; +} + +char* return_strchr (unsigned n, int c) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + char *p = strchr (a, c); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strstr (unsigned n, const char *s) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + char *p = strstr (a, s); + if (p) + p += strlen (p); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ +} + +char* return_strrchr (unsigned n, int c) +{ + char a[n]; /* { dg-message "declared here" } */ + sink (a); + char *p = strrchr (a, c); + return p; /* { dg-warning "\\\[-Wreturn-local-addr]" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-7.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-7.c new file mode 100644 index 0000000000..ac1fb769ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-7.c @@ -0,0 +1,50 @@ +/* Test to verify that a PHI with a COND_EXPR argument in a return + statement is handled correctly. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern struct S s; + +void* f (int n) +{ + void *p; + int x = 0; + + for (int i = n; i >= 0; i--) + { + p = &s; + if (p == (void*)-1) + x = 1; + else if (p) + return p; + } + + /* The return statement below ends up with the following IL: + [local count: 59055800]: + # x_10 = PHI <1(5), 0(2)> + _5 = x_10 != 0 ? -1B : 0B; + + [local count: 114863532]: + # _3 = PHI <&s(4), _5(6), &s(3)> + return _3; */ + return x ? (void*)-1 : 0; +} + +void* g (int n) +{ + void *p; + int x = 0; /* { dg-message "declared here" } */ + + for (int i = n; i >= 0; i--) + { + p = &s; + if (p == (void*)-1) + x = 1; + else if (p) + return p; + } + + /* The return statement below does not reference a COND_EXPR argument. */ + return x ? &x : 0; /* { dg-warning "may return address of local variable" "missing location" { xfail *-*-* } } */ + /* { dg-warning "may return address of local variable" "pr90735" { target *-*-* } 0 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-8.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-8.c new file mode 100644 index 0000000000..98a3805b5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-8.c @@ -0,0 +1,88 @@ +/* Test to verify that a MAX_EXPR and MIN_EXPR in a return statement + is handled correctly and that all local variables whose address + is or may be returned are identified. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +char* sink (char*, ...); + +void* test_max_2 (void) +{ + char c; /* { dg-message "declared here" } */ + + char *p = sink (&c); + + void *q = p > &c ? p : &c; /* MAX_EXPR */ + return q; /* { dg-warning "\\\[-Wreturn-local-addr" } */ +} + +void* test_max_3 (void) +{ + char c; /* { dg-message "declared here" } */ + char d; /* { dg-message "declared here" } */ + + char *p = sink (&c, &d); + + void *q = p < &c ? &c < &d ? &d : &c : p; + return q; /* { dg-warning "\\\[-Wreturn-local-addr" } */ +} + +void* test_min_2 (void) +{ + char c; /* { dg-message "declared here" } */ + + char *p = sink (&c); + + void *q = p < &c ? p : &c; /* MIN_EXPR" */ + return q; /* { dg-warning "\\\[-Wreturn-local-addr" } */ +} + +void* test_min_3 (void) +{ + char c; /* { dg-message "declared here" } */ + char d; /* { dg-message "declared here" } */ + + char *p = sink (&c, &d); + + void *q = p > &c ? &c > &d ? &d : &c : p; + return q; /* { dg-warning "\\\[-Wreturn-local-addr" } */ +} + +void* test_min_2_phi (int i) +{ + char a; /* { dg-message "declared here" } */ + + char *p = &a; + char *q = sink (&a); + p = p < q ? p : q; + if (i == 1) + return p; + /* { dg-warning "may return address of local variable" "missing location" { xfail *-*-* } } */ + else + return q; +} + +void* test_min_3_phi (int i) +{ + char a; /* { dg-message "declared here" } */ + char b; /* { dg-message "declared here" } */ + + char *p0 = &a; + char *p1 = &b; + char *p2 = sink (&a, &b); + char *p3 = sink (&a, &b); + + char *p4 = p2 < p0 ? p2 : p0; + char *p5 = p3 < p1 ? p3 : p1; + + if (i == 1) + /* { dg-warning "may return address of local variable" "missing location" { xfail *-*-* } } */ + return p4; + else + /* { dg-warning "may return address of local variable" "missing location" { xfail *-*-* } } */ + return p5; +} + +/* The directive below "swallows" warnings for both test_min_2_phi + and test_min_3_phi. + { dg-warning "may return address of local variable" "pr90735" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-9.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-9.c new file mode 100644 index 0000000000..d24f911e9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr-9.c @@ -0,0 +1,73 @@ +/* PR c/71924 - missing -Wreturn-local-addr returning alloca result + Test derived from gcc.c-torture/execute/20071108-1.c. It shows + a false positive at -Os caused by the jump threading/vrp1 pass. + { dg-do compile } + { dg-options "-Os -fdump-tree-optimized" } */ + +struct S +{ + int i; +}; + +void* f (void); + +__attribute__ ((noinline)) +struct S* g (int i) +{ + struct S *p = f (), q; + + if (p == 0) + p = &q; + + p->i = i; + + if (p == &q) + p = 0; + + /* With -Os the warning pass sees: + + ... + + # p_1 = PHI <&q(2), p_5(3)> + p_1->i = i_6(D); + if (&q == p_1) + goto ; [14.90%] + else + goto ; [85.10%] + + + + + # p_2 = PHI <0B(4), p_1(5)> + q ={v} {CLOBBER}; + return p_2; + } + + which leads to: */ + return p; /* { dg-bogus "may return address of local variable" "" { xfail *-*-* } } */ + + /* Whereas as -O2 the pass sees: + + + p_5 = f (); + if (p_5 == 0B) + goto ; [30.00%] + else + goto ; [70.00%] + + + # p_2 = PHI <0B(5), p_5(4)> + q ={v} {CLOBBER}; + return p_2; + + + p_5->i = i_6(D); + goto ; [100.00%] + + + q.i = i_6(D); + goto ; [100.00%] + } + + and no warning. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr.c b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr.c new file mode 100644 index 0000000000..d496d205e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-local-addr.c @@ -0,0 +1,9 @@ +/* { dg-do assemble } */ +/* { dg-options "-Werror=return-local-addr" } */ +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +int* bad() +{ + int x = 0; + return &x; /* { dg-error "address of local variable" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-type.c b/SingleSource/Regression/C/gcc-dg/Wreturn-type.c new file mode 100644 index 0000000000..a122e5291f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-type.c @@ -0,0 +1,5 @@ +/* PR c++/4872 */ +/* { dg-do compile } */ +/* { dg-options "-Wreturn-type" } */ + +static inline int f() {} /* { dg-warning "return" "missing return" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-type2.c b/SingleSource/Regression/C/gcc-dg/Wreturn-type2.c new file mode 100644 index 0000000000..781414a1ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-type2.c @@ -0,0 +1,9 @@ +/* Test for cases that should not get the unconditional warning about + missing return. */ +/* { dg-do compile } */ + +extern void abort (void); + +f() {} /* { dg-bogus "" "no return warning" } */ +int g() { abort (); } /* { dg-bogus "" "no return warning" } */ +int main() {} /* { dg-bogus "" "no return warning" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wreturn-type3.c b/SingleSource/Regression/C/gcc-dg/Wreturn-type3.c new file mode 100644 index 0000000000..93596b399f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wreturn-type3.c @@ -0,0 +1,54 @@ +/* Verify that attribute noreturn on global and local function declarations + is merged. + { dg-do compile } + { dg-options "-Wall" } */ + +int fnr_local_local (void) +{ + __attribute__ ((noreturn)) void fnr1 (void); + + fnr1 (); + // no return, no warning (good) +} + +int gnr_local_local (void) +{ + void fnr1 (void); + + fnr1 (); + // no return, no warning (good) +} + + +int fnr_local_global (void) +{ + __attribute__ ((noreturn)) void fnr2 (void); + + fnr2 (); + // no return, no warning (good) +} + +void fnr2 (void); + +int gnr_local_global (void) +{ + fnr2 (); + // no return, no warning (good) +} + + +__attribute__ ((noreturn)) void fnr3 (void); + +int fnr_global_local (void) +{ + fnr3 (); + // no return, no warning (good) +} + +int gnr_global_local (void) +{ + void fnr3 (void); + + fnr3 (); + // no return, no warning (good) +} diff --git a/SingleSource/Regression/C/gcc-dg/Wsequence-point-pr18050.c b/SingleSource/Regression/C/gcc-dg/Wsequence-point-pr18050.c new file mode 100644 index 0000000000..63aecd0f3e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wsequence-point-pr18050.c @@ -0,0 +1,24 @@ +/* PR 18050 : bogus warning with -Wsequence-point */ +/* { dg-do compile } */ +/* { dg-options "-Wsequence-point" } */ + +struct x +{ + int i; +}; +void bar(struct x*, int *); + +void foo(struct x *y) +{ + bar(y++, &y->i); /* { dg-warning "operation on 'y' may be undefined" } */ +} + +void zz(int a, int *b) +{ + *b = a; +} + +void baz(void) { + int a = 5; + zz(++a, &a); /* { dg-bogus "operation on 'a' may be undefined" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-1.c b/SingleSource/Regression/C/gcc-dg/Wshadow-1.c new file mode 100644 index 0000000000..0d15aac59c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-1.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-Wshadow -pedantic-errors" } */ + +/* Source: Neil Booth, 5 Dec 2001. */ + +int decl1; /* { dg-message "shadowed declaration" } */ +void foo (double decl1) /* { dg-warning "shadows a global decl" } */ +{ +} + +void foo1 (int d) /* { dg-message "note: previous definition" } */ +{ + double d; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "redeclared as different" "" { target *-*-* } .-1 } */ +} + +void foo2 (int d) /* { dg-message "shadowed declaration" } */ +{ + { + double d; /* { dg-warning "shadows a parameter" } */ + } +} + +void foo3 () +{ + int local; /* { dg-message "shadowed declaration" } */ + { + int local; /* { dg-warning "shadows a previous local" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-2.c b/SingleSource/Regression/C/gcc-dg/Wshadow-2.c new file mode 100644 index 0000000000..b0c051271e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-2.c @@ -0,0 +1,10 @@ +/* Bogus warning for a double declaration of the same extern variable, + first at file scope, then at block scope. PR 13129. */ + +/* { dg-options "-Wshadow" } */ + +extern struct foo bar; +void dummy() +{ + extern struct foo bar; /* { dg-bogus "shadows" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-3.c b/SingleSource/Regression/C/gcc-dg/Wshadow-3.c new file mode 100644 index 0000000000..0fa41bca30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-3.c @@ -0,0 +1,21 @@ +/* Test warnings for shadowing in function prototype scope: generally + useless but of use if the parameter is used within the scope. Bug + 529. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -Wshadow" } */ + +int v; /* { dg-message "shadowed declaration" } */ +int f1(int v); +int f2(int v, int x[v]); /* { dg-warning "declaration of 'v' shadows a global declaration" } */ +int f3(int v, int y[sizeof(v)]); /* { dg-warning "declaration of 'v' shadows a global declaration" } */ +int f4(int v) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */ +int f5(int v, int x[v]) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */ +int f6(int x) { return 0; } +int f7(v) int v; { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */ +int f8(v, w) int v; int w[v]; { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */ +int f9(x) int x; { return 0; } +int f10(v) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */ +int f11(int a, int b(int a)); +int f12(int a, int b(int a, int x[a])); /* { dg-warning "declaration of 'a' shadows a parameter" } */ +/* { dg-message "shadowed declaration" "outer parm" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-4.c b/SingleSource/Regression/C/gcc-dg/Wshadow-4.c new file mode 100644 index 0000000000..f3b986fa60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-4.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-Wshadow -Wsystem-headers" } */ + +#include "Wshadow-4.h" +extern void index2 (void); /* { dg-message "declaration is here" } */ + +void foo (double index1, + double index2) +{ +} + +void foo1 (void) +{ + double index1; + double index2; +} + +void foo2 (void) +{ + { + double index1; + double index2; + } +} + +void foo3 (void) +{ + void (*index1)(void); /* { dg-warning "shadows" } */ + void (*index2)(void); /* { dg-warning "shadows" } */ +} + +void foo4 (void) +{ + void index1(void) {}; /* { dg-warning "shadows" } */ + void index2(void) {}; /* { dg-warning "shadows" } */ +} + +/* { dg-message "declaration is here" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-4.h b/SingleSource/Regression/C/gcc-dg/Wshadow-4.h new file mode 100644 index 0000000000..5a44ca452c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-4.h @@ -0,0 +1,3 @@ +#pragma GCC system_header +extern void index1 (void); + diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-compatible-local-1.c b/SingleSource/Regression/C/gcc-dg/Wshadow-compatible-local-1.c new file mode 100644 index 0000000000..ed7b2e45ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-compatible-local-1.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-Wshadow=compatible-local" } */ + +struct Bar { +}; + +struct Bar bar; /* { dg-bogus "shadowed declaration" } */ + +int val; /* { dg-bogus "shadowed declaration" } */ + +int func1(int x) { /* { dg-bogus "shadowed declaration" } */ + int val; /* { dg-bogus "shadows a global" } */ + val = x; + return val; +} + +int func2(int i) { + int a = 3; /* { dg-message "shadowed declaration" } */ + int j; /* { dg-message "shadowed declaration" } */ + + for (j = 0; j < i; ++j) { + int a = j; /* { dg-warning "shadows a previous local" } */ + int j = a + 1; /* { dg-warning "shadows a previous local" } */ + func1(j); + } + + return a; +} + +void func4() { + struct Bar bar; /* { dg-bogus "shadowed declaration" } */ + if (val) { + int bar; /* { dg-bogus "shadows a previous local" } */ + func1(bar); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-local-1.c b/SingleSource/Regression/C/gcc-dg/Wshadow-local-1.c new file mode 100644 index 0000000000..161f9941fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-local-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Wshadow=local" } */ + +int decl1; /* should not warn */ +void foo (double decl1) /* should not warn */ +{ +} + +void foo2 (int d) /* { dg-message "shadowed declaration" } */ +{ + { + double d; /* { dg-warning "shadows a parameter" } */ + } +} + +void foo3 () +{ + int local; /* { dg-message "shadowed declaration" } */ + { + int local; /* { dg-warning "shadows a previous local" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-local-2.c b/SingleSource/Regression/C/gcc-dg/Wshadow-local-2.c new file mode 100644 index 0000000000..55ff978a12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-local-2.c @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-options "-Wshadow=local" } */ + +struct Bar { +}; + +struct Bar bar; /* { dg-bogus "shadowed declaration" } */ + +int val; /* { dg-bogus "shadowed declaration" } */ + +int func1(int x) { /* { dg-bogus "shadowed declaration" } */ + int val; /* { dg-bogus "shadows a global" } */ + val = x; + return val; +} + +int func2(int i) { + int a = 3; /* { dg-message "shadowed declaration" } */ + int j; /* { dg-message "shadowed declaration" } */ + + for (j = 0; j < i; ++j) { + int a = j; /* { dg-warning "shadows a previous local" } */ + int j = a + 1; /* { dg-warning "shadows a previous local" } */ + func1(j); + } + + return a; +} + +int func3() { + int bar; /* { dg-bogus "shadows a global" } */ + float func1 = 0.3; /* { dg-bogus "shadows a global" } */ + + if (func1 > 1) + bar = 2; + else + bar = 1; + return bar; +} + +void func4() { + struct Bar bar; /* { dg-message "shadowed declaration" } */ + /* { dg-bogus "shadows a global" "" { target *-*-* } .-1 } */ + + if (val) { + int bar; /* { dg-warning "shadows a previous local" } */ + func1(bar); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wshadow-local-3.c b/SingleSource/Regression/C/gcc-dg/Wshadow-local-3.c new file mode 100644 index 0000000000..429df37f54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wshadow-local-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-shadow" } */ + +void func() { + int i; + { + int i; /* should not warn */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wsign-compare-1.c b/SingleSource/Regression/C/gcc-dg/Wsign-compare-1.c new file mode 100644 index 0000000000..b40bc6c5fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wsign-compare-1.c @@ -0,0 +1,83 @@ +/* PR c/81417 */ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare -fdiagnostics-show-caret" } */ + +unsigned int +f0 (int x, unsigned int y) +{ + return x ? y : -1; /* { dg-warning "18:operand of '\\?:' changes signedness from 'int' to 'unsigned int'" } */ +/* { dg-begin-multiline-output "" } + return x ? y : -1; + ^~ + { dg-end-multiline-output "" } */ +} + +unsigned int +f1 (int xxx, unsigned int yyy) +{ + return xxx ? yyy : -1; /* { dg-warning "22:operand of '\\?:' changes signedness from 'int' to 'unsigned int'" } */ +/* { dg-begin-multiline-output "" } + return xxx ? yyy : -1; + ^~ + { dg-end-multiline-output "" } */ +} + +unsigned int +f2 (int xxx, unsigned int yyy) +{ + return xxx ? -1 : yyy; /* { dg-warning "16:operand of '\\?:' changes signedness from 'int' to 'unsigned int'" } */ +/* { dg-begin-multiline-output "" } + return xxx ? -1 : yyy; + ^~ + { dg-end-multiline-output "" } */ +} + +unsigned int +f3 (unsigned int yyy) +{ + return yyy ?: -1; /* { dg-warning "17:operand of '\\?:' changes signedness from 'int' to 'unsigned int'" } */ +/* { dg-begin-multiline-output "" } + return yyy ?: -1; + ^~ + { dg-end-multiline-output "" } */ +} + +unsigned int +f4 (int xxx, unsigned yyy, short uuu) +{ + return xxx ? yyy : uuu; /* { dg-warning "22:operand of '\\?:' changes signedness from 'short int' to 'unsigned int'" } */ +/* { dg-begin-multiline-output "" } + return xxx ? yyy : uuu; + ^~~ + { dg-end-multiline-output "" } */ +} + +unsigned int +f5 (int xxx, unsigned yyy, short uuu) +{ + return xxx ? uuu : yyy; /* { dg-warning "16:operand of '\\?:' changes signedness from 'short int' to 'unsigned int'" } */ +/* { dg-begin-multiline-output "" } + return xxx ? uuu : yyy; + ^~~ + { dg-end-multiline-output "" } */ +} + +unsigned int +f6 (int xxx, unsigned yyy, signed char uuu) +{ + return xxx ? yyy : uuu; /* { dg-warning "22:operand of '\\?:' changes signedness from 'signed char' to 'unsigned int'" } */ +/* { dg-begin-multiline-output "" } + return xxx ? yyy : uuu; + ^~~ + { dg-end-multiline-output "" } */ +} + +unsigned int +f7 (int xxx, unsigned yyy, signed char uuu) +{ + return xxx ? uuu : yyy; /* { dg-warning "16:operand of '\\?:' changes signedness from 'signed char' to 'unsigned int'" } */ +/* { dg-begin-multiline-output "" } + return xxx ? uuu : yyy; + ^~~ + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wsign-conversion.c b/SingleSource/Regression/C/gcc-dg/Wsign-conversion.c new file mode 100644 index 0000000000..b2affd0191 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wsign-conversion.c @@ -0,0 +1,98 @@ +/* Test for diagnostics for implicit conversions between signed and + unsigned integer types. + These tests come from gcc/testsuite/gcc.dg/overflow-warn-2.c */ + +/* { dg-do compile } */ +/* { dg-options "-std=c99 -fsigned-char -Wsign-conversion" } */ +#include + +void fsc (signed char sc); +void fuc (unsigned char uc); +unsigned fui (unsigned int ui); +void fsi (signed int ui); +void fsi32 (__INT32_TYPE__ ui); + +void h (int x) +{ + unsigned int ui = 3; + int si = 3; + __INT32_TYPE__ si32 = 3; + unsigned char uc = 3; + signed char sc = 3; + + uc = ui; + uc = si; + sc = ui; + sc = si; + fuc (ui); + fuc (si); + fsc (ui); + fsc (si); + + fsi (si); + fui (ui); + fsi (uc); + si = uc; + fui (uc); + ui = uc; + fui ('A'); + ui = 'A'; + fsi ('A'); + si = 'A'; + fuc ('A'); + uc = 'A'; + + uc = x ? 1U : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-1. to .\[0-9\]+." } */ + uc = x ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-\[0-9\]+. to .\[0-9\]+." } */ + uc = x ? 1 : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-1." } */ + uc = x ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-\[0-9\]+." } */ + ui = x ? 1U : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-1. to .\[0-9\]+." } */ + ui = x ? INT_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-\[0-9\]+. to .\[0-9\]+." } */ + ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ + ui = 1U * -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ + ui = ui + INT_MIN; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ + ui = x ? 1 : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes the value of .-1." } */ + ui = ui ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes the value of " } */ + + fuc (-1); /* { dg-warning "unsigned conversion" } */ + uc = -1; /* { dg-warning "unsigned conversion" } */ + fui (-1); /* { dg-warning "unsigned conversion" } */ + ui = -1; /* { dg-warning "unsigned conversion" } */ + fuc ('\xa0'); /* { dg-warning "unsigned conversion" } */ + uc = '\xa0'; /* { dg-warning "unsigned conversion" } */ + fui ('\xa0');/* { dg-warning "unsigned conversion" } */ + ui = '\xa0'; /* { dg-warning "unsigned conversion" } */ + fsi32 (0x80000000); /* { dg-warning "signed conversion" } */ + si32 = 0x80000000; /* { dg-warning "signed conversion" } */ + + + fsi (UINT_MAX - 1); /* { dg-warning "conversion" } */ + si = UINT_MAX - 1; /* { dg-warning "conversion" } */ + fsi (UINT_MAX - 1U); /* { dg-warning "conversion" } */ + si = UINT_MAX - 1U; /* { dg-warning "conversion" } */ + fsi (UINT_MAX/3U); + si = UINT_MAX/3U; + fsi (UINT_MAX/3); + si = UINT_MAX/3; + fui (UINT_MAX - 1); + ui = UINT_MAX - 1; + + uc = (unsigned char) -1; + ui = -1 * (1 * -1); + ui = (unsigned) -1; + + fsc (uc); /* { dg-warning "conversion" } */ + sc = uc; /* { dg-warning "conversion" } */ + fuc (sc); /* { dg-warning "conversion" } */ + uc = sc; /* { dg-warning "conversion" } */ + fsi (ui); /* { dg-warning "conversion" } */ + si = ui; /* { dg-warning "conversion" } */ + fui (si); /* { dg-warning "conversion" } */ + ui = si; /* { dg-warning "conversion" } */ + fui (sc); /* { dg-warning "conversion" } */ + ui = sc; /* { dg-warning "conversion" } */ +} + +unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value" } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/Wsizeof-pointer-memaccess1.c b/SingleSource/Regression/C/gcc-dg/Wsizeof-pointer-memaccess1.c new file mode 100644 index 0000000000..5aea89a087 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wsizeof-pointer-memaccess1.c @@ -0,0 +1,466 @@ +/* Test -Wsizeof-pointer-memaccess warnings. */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wno-array-bounds -Wno-sizeof-array-argument -Wno-stringop-overflow -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; +extern void bzero (void *, size_t); +extern void bcopy (void *, const void *, size_t); +extern int bcmp (const void *, const void *, size_t); + +struct A { short a, b; int c, d; long e, f; }; +typedef struct A TA; +typedef struct A *PA; +typedef TA *PTA; +struct B {}; +typedef struct B TB; +typedef struct B *PB; +typedef TB *PTB; +typedef int X[3][3][3]; + +int +f1 (void *x, int z) +{ + struct A a, *pa1 = &a; + TA *pa2 = &a; + PA pa3 = &a; + PTA pa4 = &a; + bzero (&a, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + bzero (pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bzero (pa2, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bzero (pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bzero (pa4, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bzero (pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bzero (pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bzero (pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bzero (pa4, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + bcopy (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + bcopy (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bcopy (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bcopy (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bcopy (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bcopy (x, pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bcopy (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bcopy (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bcopy (x, pa4, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + bcopy (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + bcopy (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + bcopy (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + bcopy (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + bcopy (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + bcopy (pa1, x, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + bcopy (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + bcopy (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + bcopy (pa4, x, sizeof (__typeof (pa4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + + z += bcmp (&a, x, sizeof (&a)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */ + z += bcmp (pa1, x, sizeof (pa1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += bcmp (pa2, x, sizeof pa2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += bcmp (pa3, x, sizeof (pa3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += bcmp (pa4, x, sizeof pa4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += bcmp (pa1, x, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (pa2, x, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (pa3, x, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + + z += bcmp (x, &a, sizeof (&a)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */ + z += bcmp (x, pa1, sizeof (pa1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, pa2, sizeof pa2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, pa3, sizeof (pa3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, pa4, sizeof pa4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, pa1, sizeof (struct A *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (x, pa2, sizeof (PTA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (x, pa3, sizeof (PA)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + + z += bcmp (x, (&a), (sizeof (&a))); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */ + z += bcmp (x, (pa1), (sizeof (pa1))); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, (pa2), (sizeof pa2)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, (pa3), (sizeof (pa3))); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, (pa4), (sizeof pa4)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, (pa1), (sizeof (struct A *)));/* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (x, (pa2), (sizeof (PTA))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (x, (pa3), (sizeof (PA))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + + /* These are correct, no warning. */ + bzero (&a, sizeof a); + bzero (&a, sizeof (a)); + bzero (&a, sizeof (struct A)); + bzero (&a, sizeof (const struct A)); + bzero (&a, sizeof (volatile struct A)); + bzero (&a, sizeof (volatile const struct A)); + bzero (&a, sizeof (TA)); + bzero (&a, sizeof (__typeof (*&a))); + bzero (pa1, sizeof (*pa1)); + bzero (pa2, sizeof (*pa3)); + bzero (pa3, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + bzero ((void *) &a, sizeof (&a)); + bzero ((char *) &a, sizeof (&a)); + bzero (&a, sizeof (&a) + 0); + bzero (&a, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + bcopy (x, &a, sizeof a); + bcopy (x, &a, sizeof (a)); + bcopy (x, &a, sizeof (struct A)); + bcopy (x, &a, sizeof (const struct A)); + bcopy (x, &a, sizeof (volatile struct A)); + bcopy (x, &a, sizeof (volatile const struct A)); + bcopy (x, &a, sizeof (TA)); + bcopy (x, &a, sizeof (__typeof (*&a))); + bcopy (x, pa1, sizeof (*pa1)); + bcopy (x, pa2, sizeof (*pa3)); + bcopy (x, pa3, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + bcopy (x, (void *) &a, sizeof (&a)); + bcopy (x, (char *) &a, sizeof (&a)); + bcopy (x, &a, sizeof (&a) + 0); + bcopy (x, &a, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + bcopy (&a, x, sizeof a); + bcopy (&a, x, sizeof (a)); + bcopy (&a, x, sizeof (struct A)); + bcopy (&a, x, sizeof (const struct A)); + bcopy (&a, x, sizeof (volatile struct A)); + bcopy (&a, x, sizeof (volatile const struct A)); + bcopy (&a, x, sizeof (TA)); + bcopy (&a, x, sizeof (__typeof (*&a))); + bcopy (pa1, x, sizeof (*pa1)); + bcopy (pa2, x, sizeof (*pa3)); + bcopy (pa3, x, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + bcopy ((void *) &a, x, sizeof (&a)); + bcopy ((char *) &a, x, sizeof (&a)); + bcopy (&a, x, sizeof (&a) + 0); + bcopy (&a, x, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + z += bcmp (&a, x, sizeof a); + z += bcmp (&a, x, sizeof (a)); + z += bcmp (&a, x, sizeof (struct A)); + z += bcmp (&a, x, sizeof (const struct A)); + z += bcmp (&a, x, sizeof (volatile struct A)); + z += bcmp (&a, x, sizeof (volatile const struct A)); + z += bcmp (&a, x, sizeof (TA)); + z += bcmp (&a, x, sizeof (__typeof (*&a))); + z += bcmp (pa1, x, sizeof (*pa1)); + z += bcmp (pa2, x, sizeof (*pa3)); + z += bcmp (pa3, x, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + z += bcmp ((void *) &a, x, sizeof (&a)); + z += bcmp ((char *) &a, x, sizeof (&a)); + z += bcmp (&a, x, sizeof (&a) + 0); + z += bcmp (&a, x, 0 + sizeof (&a)); + + /* These are correct, no warning. */ + z += bcmp (x, &a, sizeof a); + z += bcmp (x, &a, sizeof (a)); + z += bcmp (x, &a, sizeof (struct A)); + z += bcmp (x, &a, sizeof (const struct A)); + z += bcmp (x, &a, sizeof (volatile struct A)); + z += bcmp (x, &a, sizeof (volatile const struct A)); + z += bcmp (x, &a, sizeof (TA)); + z += bcmp (x, &a, sizeof (__typeof (*&a))); + z += bcmp (x, pa1, sizeof (*pa1)); + z += bcmp (x, pa2, sizeof (*pa3)); + z += bcmp (x, pa3, sizeof (__typeof (*pa3))); + /* These are probably broken, but obfuscated, no warning. */ + z += bcmp (x, (void *) &a, sizeof (&a)); + z += bcmp (x, (char *) &a, sizeof (&a)); + z += bcmp (x, &a, sizeof (&a) + 0); + z += bcmp (x, &a, 0 + sizeof (&a)); + + return z; +} + +int +f2 (void *x, int z) +{ + struct B b, *pb1 = &b; + TB *pb2 = &b; + PB pb3 = &b; + PTB pb4 = &b; + bzero (&b, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + bzero (pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bzero (pb2, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bzero (pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bzero (pb4, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bzero (pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bzero (pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bzero (pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bzero (pb4, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + bcopy (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + bcopy (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bcopy (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bcopy (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bcopy (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + bcopy (x, pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bcopy (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bcopy (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + bcopy (x, pb4, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the destination; expected \[^\n\r\]* or an explicit length" } */ + + bcopy (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + bcopy (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + bcopy (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + bcopy (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + bcopy (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + bcopy (pb1, x, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + bcopy (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + bcopy (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + bcopy (pb4, x, sizeof (__typeof (pb4))); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the source; expected \[^\n\r\]* or an explicit length" } */ + + z += bcmp (&b, x, sizeof (&b)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */ + z += bcmp (pb1, x, sizeof (pb1)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += bcmp (pb2, x, sizeof pb2); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += bcmp (pb3, x, sizeof (pb3)); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += bcmp (pb4, x, sizeof pb4); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + z += bcmp (pb1, x, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (pb2, x, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (pb3, x, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the first source; expected \[^\n\r\]* or an explicit length" } */ + + z += bcmp (x, &b, sizeof (&b)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */ + z += bcmp (x, pb1, sizeof (pb1)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, pb2, sizeof pb2); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, pb3, sizeof (pb3)); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, pb4, sizeof pb4); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + z += bcmp (x, pb1, sizeof (struct B *)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (x, pb2, sizeof (PTB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + z += bcmp (x, pb3, sizeof (PB)); /* { dg-warning "call is the same pointer type \[^\n\r\]* as the second source; expected \[^\n\r\]* or an explicit length" } */ + + /* These are correct, no warning. */ + bzero (&b, sizeof b); + bzero (&b, sizeof (b)); + bzero (&b, sizeof (struct B)); + bzero (&b, sizeof (const struct B)); + bzero (&b, sizeof (volatile struct B)); + bzero (&b, sizeof (volatile const struct B)); + bzero (&b, sizeof (TB)); + bzero (&b, sizeof (__typeof (*&b))); + bzero (pb1, sizeof (*pb1)); + bzero (pb2, sizeof (*pb3)); + bzero (pb3, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + bzero ((void *) &b, sizeof (&b)); + bzero ((char *) &b, sizeof (&b)); + bzero (&b, sizeof (&b) + 0); + bzero (&b, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + bcopy (x, &b, sizeof b); + bcopy (x, &b, sizeof (b)); + bcopy (x, &b, sizeof (struct B)); + bcopy (x, &b, sizeof (const struct B)); + bcopy (x, &b, sizeof (volatile struct B)); + bcopy (x, &b, sizeof (volatile const struct B)); + bcopy (x, &b, sizeof (TB)); + bcopy (x, &b, sizeof (__typeof (*&b))); + bcopy (x, pb1, sizeof (*pb1)); + bcopy (x, pb2, sizeof (*pb3)); + bcopy (x, pb3, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + bcopy (x, (void *) &b, sizeof (&b)); + bcopy (x, (char *) &b, sizeof (&b)); + bcopy (x, &b, sizeof (&b) + 0); + bcopy (x, &b, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + bcopy (&b, x, sizeof b); + bcopy (&b, x, sizeof (b)); + bcopy (&b, x, sizeof (struct B)); + bcopy (&b, x, sizeof (const struct B)); + bcopy (&b, x, sizeof (volatile struct B)); + bcopy (&b, x, sizeof (volatile const struct B)); + bcopy (&b, x, sizeof (TB)); + bcopy (&b, x, sizeof (__typeof (*&b))); + bcopy (pb1, x, sizeof (*pb1)); + bcopy (pb2, x, sizeof (*pb3)); + bcopy (pb3, x, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + bcopy ((void *) &b, x, sizeof (&b)); + bcopy ((char *) &b, x, sizeof (&b)); + bcopy (&b, x, sizeof (&b) + 0); + bcopy (&b, x, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + z += bcmp (&b, x, sizeof b); + z += bcmp (&b, x, sizeof (b)); + z += bcmp (&b, x, sizeof (struct B)); + z += bcmp (&b, x, sizeof (const struct B)); + z += bcmp (&b, x, sizeof (volatile struct B)); + z += bcmp (&b, x, sizeof (volatile const struct B)); + z += bcmp (&b, x, sizeof (TB)); + z += bcmp (&b, x, sizeof (__typeof (*&b))); + z += bcmp (pb1, x, sizeof (*pb1)); + z += bcmp (pb2, x, sizeof (*pb3)); + z += bcmp (pb3, x, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + z += bcmp ((void *) &b, x, sizeof (&b)); + z += bcmp ((char *) &b, x, sizeof (&b)); + z += bcmp (&b, x, sizeof (&b) + 0); + z += bcmp (&b, x, 0 + sizeof (&b)); + + /* These are correct, no warning. */ + z += bcmp (x, &b, sizeof b); + z += bcmp (x, &b, sizeof (b)); + z += bcmp (x, &b, sizeof (struct B)); + z += bcmp (x, &b, sizeof (const struct B)); + z += bcmp (x, &b, sizeof (volatile struct B)); + z += bcmp (x, &b, sizeof (volatile const struct B)); + z += bcmp (x, &b, sizeof (TB)); + z += bcmp (x, &b, sizeof (__typeof (*&b))); + z += bcmp (x, pb1, sizeof (*pb1)); + z += bcmp (x, pb2, sizeof (*pb3)); + z += bcmp (x, pb3, sizeof (__typeof (*pb3))); + /* These are probably broken, but obfuscated, no warning. */ + z += bcmp (x, (void *) &b, sizeof (&b)); + z += bcmp (x, (char *) &b, sizeof (&b)); + z += bcmp (x, &b, sizeof (&b) + 0); + z += bcmp (x, &b, 0 + sizeof (&b)); + + return z; +} + +int +f3 (void *x, char *y, int z, X w) +{ + unsigned char *y1 = (unsigned char *) __builtin_alloca (z + 16); + char buf1[7]; + signed char buf2[z + 32]; + long buf3[17]; + int *buf4[9]; + signed char *y2 = buf2; + char c; + char *y3; + bzero (y, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + bzero (y1, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + bzero (y2, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + bzero (&c, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + bzero (w, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + + bcopy (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + bcopy (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + bcopy (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the destination; did you mean to provide an explicit length" } */ + bcopy (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the destination; did you mean to remove the addressof" } */ + bcopy (x, w, sizeof w); /* { dg-warning "call is the same expression as the destination; did you mean to dereference it" } */ + + bcopy (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + bcopy (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + bcopy (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the source; did you mean to provide an explicit length" } */ + bcopy (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the source; did you mean to remove the addressof" } */ + bcopy (w, x, sizeof w); /* { dg-warning "call is the same expression as the source; did you mean to dereference it" } */ + + z += bcmp (y, x, sizeof (y)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */ + z += bcmp (y1, x, sizeof (y1)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */ + z += bcmp (y2, x, sizeof (y2)); /* { dg-warning "call is the same expression as the first source; did you mean to provide an explicit length" } */ + z += bcmp (&c, x, sizeof (&c)); /* { dg-warning "call is the same expression as the first source; did you mean to remove the addressof" } */ + z += bcmp (w, x, sizeof w); /* { dg-warning "call is the same expression as the first source; did you mean to dereference it" } */ + + z += bcmp (x, y, sizeof (y)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */ + z += bcmp (x, y1, sizeof (y1)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */ + z += bcmp (x, y2, sizeof (y2)); /* { dg-warning "call is the same expression as the second source; did you mean to provide an explicit length" } */ + z += bcmp (x, &c, sizeof (&c)); /* { dg-warning "call is the same expression as the second source; did you mean to remove the addressof" } */ + z += bcmp (x, w, sizeof w); /* { dg-warning "call is the same expression as the second source; did you mean to dereference it" } */ + + /* These are correct, no warning. */ + bzero (y, sizeof (*y)); + bzero (y1, sizeof (*y2)); + bzero (buf1, sizeof buf1); + bzero (buf3, sizeof (buf3)); + bzero (&buf3[0], sizeof (buf3)); + bzero (&buf4[0], sizeof (buf4)); + bzero (w, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + bzero ((void *) y, sizeof (y)); + bzero ((char *) y1, sizeof (y2)); + bzero (y, sizeof (y) + 0); + bzero (y1, 0 + sizeof (y2)); + bzero ((void *) &c, sizeof (&c)); + bzero ((signed char *) &c, sizeof (&c)); + bzero (&c, sizeof (&c) + 0); + bzero (&c, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + bcopy (x, y, sizeof (*y)); + bcopy (x, y1, sizeof (*y2)); + bcopy (x, buf1, sizeof buf1); + bcopy (x, buf3, sizeof (buf3)); + bcopy (x, &buf3[0], sizeof (buf3)); + bcopy (x, &buf4[0], sizeof (buf4)); + bcopy (y, &y3, sizeof (y3)); + bcopy (y, (char *) &y3, sizeof (y3)); + bcopy (x, w, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + bcopy (x, (void *) y, sizeof (y)); + bcopy (x, (char *) y1, sizeof (y2)); + bcopy (x, y, sizeof (y) + 0); + bcopy (x, y1, 0 + sizeof (y2)); + bcopy (x, (void *) &c, sizeof (&c)); + bcopy (x, (signed char *) &c, sizeof (&c)); + bcopy (x, &c, sizeof (&c) + 0); + bcopy (x, &c, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + bcopy (y, x, sizeof (*y)); + bcopy (y1, x, sizeof (*y2)); + bcopy (buf1, x, sizeof buf1); + bcopy (buf3, x, sizeof (buf3)); + bcopy (&buf3[0], x, sizeof (buf3)); + bcopy (&buf4[0], x, sizeof (buf4)); + bcopy (&y3, y, sizeof (y3)); + bcopy ((char *) &y3, y, sizeof (y3)); + bcopy (w, x, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + bcopy ((void *) y, x, sizeof (y)); + bcopy ((char *) y1, x, sizeof (y2)); + bcopy (y, x, sizeof (y) + 0); + bcopy (y1, x, 0 + sizeof (y2)); + bcopy ((void *) &c, x, sizeof (&c)); + bcopy ((signed char *) &c, x, sizeof (&c)); + bcopy (&c, x, sizeof (&c) + 0); + bcopy (&c, x, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + z += bcmp (y, x, sizeof (*y)); + z += bcmp (y1, x, sizeof (*y2)); + z += bcmp (buf1, x, sizeof buf1); + z += bcmp (buf3, x, sizeof (buf3)); + z += bcmp (&buf3[0], x, sizeof (buf3)); + z += bcmp (&buf4[0], x, sizeof (buf4)); + z += bcmp (&y3, y, sizeof (y3)); + z += bcmp ((char *) &y3, y, sizeof (y3)); + z += bcmp (w, x, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + z += bcmp ((void *) y, x, sizeof (y)); + z += bcmp ((char *) y1, x, sizeof (y2)); + z += bcmp (y, x, sizeof (y) + 0); + z += bcmp (y1, x, 0 + sizeof (y2)); + z += bcmp ((void *) &c, x, sizeof (&c)); + z += bcmp ((signed char *) &c, x, sizeof (&c)); + z += bcmp (&c, x, sizeof (&c) + 0); + z += bcmp (&c, x, 0 + sizeof (&c)); + + /* These are correct, no warning. */ + z += bcmp (x, y, sizeof (*y)); + z += bcmp (x, y1, sizeof (*y2)); + z += bcmp (x, buf1, sizeof buf1); + z += bcmp (x, buf3, sizeof (buf3)); + z += bcmp (x, &buf3[0], sizeof (buf3)); + z += bcmp (x, &buf4[0], sizeof (buf4)); + z += bcmp (y, &y3, sizeof (y3)); + z += bcmp (y, (char *) &y3, sizeof (y3)); + z += bcmp (x, w, sizeof (X)); + /* These are probably broken, but obfuscated, no warning. */ + z += bcmp (x, (void *) y, sizeof (y)); + z += bcmp (x, (char *) y1, sizeof (y2)); + z += bcmp (x, y, sizeof (y) + 0); + z += bcmp (x, y1, 0 + sizeof (y2)); + z += bcmp (x, (void *) &c, sizeof (&c)); + z += bcmp (x, (signed char *) &c, sizeof (&c)); + z += bcmp (x, &c, sizeof (&c) + 0); + z += bcmp (x, &c, 0 + sizeof (&c)); + + return z; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstack-usage.c b/SingleSource/Regression/C/gcc-dg/Wstack-usage.c new file mode 100644 index 0000000000..11e3a27b66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstack-usage.c @@ -0,0 +1,15 @@ +/* PR 90983/manual documents `-Wno-stack-usage` flag, but it is unrecognized + { dg-do compile } + { dg-options "-Wall -Wstack-usage=123 -Wno-stack-usage" } + { dg-require-effective-target alloca } */ + +void f (void*); + +void g (int n) +{ + if (n < 1234) + n = 1234; + + char a [n]; + f (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-const-ptr-nonconst-ptr.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-const-ptr-nonconst-ptr.c new file mode 100644 index 0000000000..8a5dcd8e2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-const-ptr-nonconst-ptr.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-aliasing -fstrict-aliasing" } */ + +const int* foo (void) +{ + int *i; + const int** cpi = (const int**) &i; /* { dg-bogus "const vs. non-const" } */ + i = 0; + return *cpi; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-never-dereferenced.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-never-dereferenced.c new file mode 100644 index 0000000000..fd3f767ac8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-never-dereferenced.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-aliasing -fstrict-aliasing" } */ + + +int foo () +{ + int x = 10; + int *p; + float *q; + + q = (float*) &x; /* { dg-bogus "not referenced" } */ + + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-pta-1.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-pta-1.c new file mode 100644 index 0000000000..a48827474d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-pta-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct S { int *p; int *q; }; + +void foo (struct S *); + +int bar (int b) +{ + struct S s; + int *p; + float f; + foo (&s); + if (b) + p = s.q; + else + p = (int *)&f; + return *p; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-ref-all-2.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-ref-all-2.c new file mode 100644 index 0000000000..b1bee33c38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-ref-all-2.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-options "-O2 -Wall -mabi=altivec" { target { { powerpc*-*-linux* } && ilp32 } } } */ +/* { dg-options "-O2 -Wall -msse2" { target { i?86-*-* x86_64-*-* } } } */ + +typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__)); + +extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm_load_si128 (__m128i const *__P) +{ + return *__P; +} + +static const short __attribute__((__aligned__(16))) tbl[8] = +{ 1, 2, 3, 4, 5, 6, 7, 8}; + + +__m128i get_vec(void) +{ + __m128i ret; + + ret = _mm_load_si128((__m128i *)tbl); /* { dg-bogus "type-punning" } */ + + return ret; +} + +/* Ignore a warning that is irrelevant to the purpose of this test. */ +/* { dg-prune-output ".*GCC vector returned by reference.*" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-ref-all.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-ref-all.c new file mode 100644 index 0000000000..7e8d177156 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-ref-all.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct g { long a; }; +unsigned long f(struct g *a) { return *(unsigned long *)&a->a; } + +struct A +{ + void *a; +}; + +int g(const struct A *x, long *y) +{ + typedef long __attribute__ ((may_alias)) long_a; + *y = *(const long_a *) (&x->a); + return 1; +} + +void *a; + +int +f0 (long *y) +{ + *y = *(const long *) &a; /* { dg-warning "will break" } */ + return 1; +} + +int +f1 (long *y) +{ + typedef long __attribute__ ((may_alias)) long_a; + *y = *(const long_a *) &a; + return 1; +} + +int +f2 (long *y) +{ + *y = *(const long *) &a; /* { dg-warning "will break" } */ + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-struct-included.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-struct-included.c new file mode 100644 index 0000000000..382fecd6f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-struct-included.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-aliasing -fstrict-aliasing" } */ + + +struct U +{ + float f; + int i; +}; + + +int foo () +{ + struct U u; + float *pf = (float*)&u; /* { dg-bogus "float included in struct U" } */ + *pf = 2.0; + return u.i; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-upcast.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-upcast.c new file mode 100644 index 0000000000..cb70838809 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-upcast.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct a { + int i; +}; +struct b { + struct a a; + int j; +}; +int main(void) +{ + static struct b b; + struct a *ap=(struct a *)&b; + return ((struct b *)&ap->i)->j; /* { dg-bogus "will break strict-aliasing" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-vla-1.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-vla-1.c new file mode 100644 index 0000000000..87f5ef9d17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-bogus-vla-1.c @@ -0,0 +1,11 @@ +/* PR 41673: bogus -Wstrict-aliasing warning from VLA dereference. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -O2 -Wall" } */ +/* { dg-require-effective-target alloca } */ + +int main(int argc, char *argv[]) +{ + float x[argc]; + float y[argc]; + return 0 == __builtin_memcpy(y, x, argc * sizeof(*x)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-converted-assigned.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-converted-assigned.c new file mode 100644 index 0000000000..c44fc429a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-converted-assigned.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-aliasing -fstrict-aliasing" } */ + + +int foo() +{ + int i; + *(long*)&i = 0; /* { dg-warning "type-punn" "type-punn" } */ + /* These messages are only expected for lp64, but fail there. When they + pass for lp64, replace "xfail *-*-*" with "target lp64". */ + /* { dg-message "does break strict-aliasing" "break" { xfail *-*-* } .-3 } */ + /* { dg-message "initialized" "init" { xfail *-*-* } .-4 } */ + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-float-ptr-int-obj.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-float-ptr-int-obj.c new file mode 100644 index 0000000000..b90fb76c28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-float-ptr-int-obj.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wstrict-aliasing -fstrict-aliasing" } */ + +extern int flag; + +int foo() { + + int x; + int y = 9; + float* q; + float* r; + + if (flag) { + q = (float*) &x; /* { dg-message "initialized" "" { xfail *-*-* } } */ + } else { + q = (float*) &y; /* { dg-message "initialized" "" { xfail *-*-* } } */ + } + + *q = 1.0; /* { dg-warning "does break strict-aliasing" "" { xfail *-*-* } } */ + + return x; + +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-struct-with-char-member.c b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-struct-with-char-member.c new file mode 100644 index 0000000000..0da9a16378 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-aliasing-struct-with-char-member.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct a { + int i; + char c; +}; +struct b { + float f; + float g; +}; +int main(void) +{ + static struct b b; + return ((struct a *)&b)->i; /* { dg-warning "will break strict-aliasing" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays-2.c b/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays-2.c new file mode 100644 index 0000000000..befc604f19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays-2.c @@ -0,0 +1,39 @@ +/* Test -Wstrict-flex-arrays. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=2" } */ + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + normal->c[5] = 5; /*{ dg-warning "should not be used as a flexible array member" } */ + trailing_1->c[2] = 2; /* { dg-warning "should not be used as a flexible array member" } */ + trailing_0->c[1] = 1; /* { dg-bogus "should not be used as a flexible array member" } */ + trailing_flex->c[10] = 10; /* { dg-bogus "should not be used as a flexible array member" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays-3.c b/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays-3.c new file mode 100644 index 0000000000..cc37a092c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays-3.c @@ -0,0 +1,39 @@ +/* Test -Wstrict-flex-arrays. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=3" } */ + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + normal->c[5] = 5; /*{ dg-warning "should not be used as a flexible array member" } */ + trailing_1->c[2] = 2; /* { dg-warning "should not be used as a flexible array member" } */ + trailing_0->c[1] = 1; /* { dg-warning "should not be used as a flexible array member" } */ + trailing_flex->c[10] = 10; /* { dg-bogus "should not be used as a flexible array member" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays.c b/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays.c new file mode 100644 index 0000000000..735b23a1dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-flex-arrays.c @@ -0,0 +1,39 @@ +/* Test -Wstrict-flex-arrays. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-flex-arrays -fstrict-flex-arrays=1" } */ + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + normal->c[5] = 5; /*{ dg-warning "should not be used as a flexible array member" } */ + trailing_1->c[2] = 2; /* { dg-bogus "should not be used as a flexible array member" } */ + trailing_0->c[1] = 1; /* { dg-bogus "should not be used as a flexible array member" } */ + trailing_flex->c[10] = 10; /* { dg-bogus "should not be used as a flexible array member" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-1.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-1.c new file mode 100644 index 0000000000..068bfe4944 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=3" } */ + +/* Source: Ian Lance Taylor. Based on strict-overflow-1.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i) +{ + return i - 5 < 10; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-10.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-10.c new file mode 100644 index 0000000000..d2c259728c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-10.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=1" } */ + +/* Source: Ian Lance Taylor. */ + +int +foo (int i) +{ + return __builtin_abs (i) >= 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-11.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-11.c new file mode 100644 index 0000000000..3caf1cb6f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-11.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=1" } */ + +/* Based on strict-overflow-5.c. */ + +/* We can only unroll when using strict overflow semantics. But we + don't issue a warning for relying on undefined overflow in + loops. */ + +int foo (int i) +{ + int index; + int r=0; + + for (index = i; index <= i+4; index+=2) + r++; + + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-12.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-12.c new file mode 100644 index 0000000000..2837ce3a44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-12.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-6.c. */ + +/* VRP test. This turns into an infinite loop when using strict + overflow semantics. */ + +int +foo () +{ + int i, bits; + for (i = 1, bits = 1; i > 0; i += i) /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */ + ++bits; + return bits; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-13.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-13.c new file mode 100644 index 0000000000..8691cd82fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-13.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-6.c. */ + +/* VRP test. This turns into an infinite loop (depending on what + bigtime_test does), but at least we warn about it. */ + +extern int bigtime_test (int); +int +foo () +{ + int j; + for (j = 1; 0 < j; j *= 2) /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */ + if (! bigtime_test (j)) + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-14.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-14.c new file mode 100644 index 0000000000..dda07ea733 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-14.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=4" } */ + +/* Source: Ian Lance Taylor. */ + +int +foo (int j) +{ + int i; + int sum = 0; + + for (i = 1; i < j; i += i) + sum += i / 16; /* { dg-warning "assuming signed overflow does not occur" "" { xfail *-*-* } } */ + return sum; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-15.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-15.c new file mode 100644 index 0000000000..c9e275c0bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-15.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=4" } */ + +/* Source: Ian Lance Taylor. */ + +int +foo (int j) +{ + int i; + int sum = 0; + + for (i = 1; i < j; i += i) + sum += __builtin_abs (i); /* { dg-warning "assuming signed overflow does not occur" "" { xfail *-*-* } } */ + return sum; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-16.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-16.c new file mode 100644 index 0000000000..e8c31cf504 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-16.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */ + +/* From PR 31522. */ + +int f (int x) { + int y; + if (x <= 4) y = 1; + else y = x / 4; + return y <= 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-17.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-17.c new file mode 100644 index 0000000000..5625bc2a7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-17.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */ + +/* This erroneously gave an overflow warning. */ + +extern void bar (char); +void +foo (char *s) +{ + int len, i; + + for (len = 1; len < 5000; ++len) + { + for (i = 0; i < len; ++i) + { + if (s[i] != '\0') + bar (s[i]); + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-18.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-18.c new file mode 100644 index 0000000000..8c8ddcf2b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-18.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */ + +/* Warn about an overflow when folding i > 0, p->a - p->b can be larger + than INT_MAX and thus i can wrap. */ + +struct c { unsigned int a; unsigned int b; }; +extern void bar (struct c *); +int +foo (struct c *p) +{ + int i; + int sum = 0; + + for (i = 0; i < p->a - p->b; ++i) + { + /* See PR80511 for the XFAIL. */ + if (i > 0) /* { dg-warning "signed overflow" "" { xfail *-*-* } } */ + sum += 2; + bar (p); + } + return sum; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-19.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-19.c new file mode 100644 index 0000000000..daf98b0ce6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-19.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */ + +/* Don't warn about an overflow when threading jumps. We used to get + a warning from comparing bounds generated by VRP. */ + +int +bar(int a, int b, int n) +{ + if (b > a) + n = a - b; + if (a >= b) + n = 1; + return n; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-2.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-2.c new file mode 100644 index 0000000000..2112571cab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2" } */ + +/* Source: Ian Lance Taylor. Based on strict-overflow-1.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i) +{ + return i - 5 < 10; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-20.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-20.c new file mode 100644 index 0000000000..ae2db93c61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-20.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */ + +/* Don't warn about an overflow in a copied loop header. We used to + get a warning in value numbering. This is PR 33565. */ + +void do_something (); + +void f (int m, int n) +{ + int j; + + for (j = m; j < m + 10 && j < n; j ++) + do_something (j); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-21.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-21.c new file mode 100644 index 0000000000..82a61d966f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-21.c @@ -0,0 +1,12 @@ +/* PR 32102: -Wall stomps on -Wstrict-overflow */ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2 -Wall" } */ +int +foo () +{ + int i, bits; + for (i = 1, bits = 1; i > 0; i += i) /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */ + ++bits; + return bits; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-22.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-22.c new file mode 100644 index 0000000000..4b8438733e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-22.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=3" } */ + +/* Source: Ian Lance Taylor. Based on strict-overflow-6.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (char* p) +{ + return p + 1000 < p; /* { dg-warning "assuming pointer wraparound does not occur" "correct warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-23.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-23.c new file mode 100644 index 0000000000..16014bb15c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-23.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-overflow" } */ + +unsigned int +do_scrolling (unsigned int window_size, unsigned int writecost) +{ + unsigned int i = window_size; + + int terminal_window_p = 0; + unsigned int queue = 0; + + for (i = window_size; i; i--) + { + if (writecost < i) + ++queue; + else if (writecost & 1) + terminal_window_p = 1; + } + + if (queue > 0) + { + if (!terminal_window_p) + { + terminal_window_p = 1; + } + } + + if (terminal_window_p) + return 100; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-24.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-24.c new file mode 100644 index 0000000000..05e8dd1448 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-24.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2" } */ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ +#pragma GCC diagnostic error "-Wstrict-overflow" + +int +foo (int i) +{ + return __builtin_abs (i) >= 0; /* { dg-error "assuming signed overflow does not occur" "correct warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-25.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-25.c new file mode 100644 index 0000000000..0091644637 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-25.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=3" } */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int x, int y) +{ + return x - y < 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-26.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-26.c new file mode 100644 index 0000000000..ef805b56d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-26.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-overflow" } */ + +int +f (int i, int j) +{ + unsigned int c = 0; + if (i < j) + { + unsigned int n = j - i; + unsigned int i; + for (i = 0; i < n; i++) /* { dg-bogus "signed overflow" } */ + c++; + } + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-27.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-27.c new file mode 100644 index 0000000000..e2cdcbcb07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-27.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O3 -Wstrict-overflow=2 -Werror" } */ + +typedef __SIZE_TYPE__ size_t; +extern char *strtok_r (char *__restrict __s, const char *__restrict __delim, + char **__restrict __save_ptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3))); +extern const unsigned short int **__ctype_b_loc (void) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); +extern int *DEBUGLEVEL_CLASS; +size_t debug_num_classes = 0; +void debug_parse_param(char *param); +void +debug_parse_levels(const char *params_str, size_t str_len) +{ + char str[str_len+1]; + char *tok, *saveptr; + size_t i; + tok = strtok_r(str, " \t,\n\r", &saveptr); + if (((*__ctype_b_loc ())[(int) ((tok[0]))])) + tok = strtok_r(((void *)0), " \t,\n\r", &saveptr); + else + DEBUGLEVEL_CLASS[0] = 0; + for (i = 0 +1; i < debug_num_classes; i++) + DEBUGLEVEL_CLASS[i] = DEBUGLEVEL_CLASS[0]; + while (tok != ((void *)0) ) + debug_parse_param(tok); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-3.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-3.c new file mode 100644 index 0000000000..22f6a56a99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=4" } */ + +/* Source: Ian Lance Taylor. Based on strict-overflow-2.c. */ + +/* We can only simplify the division when using strict overflow + semantics. */ + +int +foo (int i) +{ + return (i * 100) / 10; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-4.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-4.c new file mode 100644 index 0000000000..e880bef45f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-4.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=3" } */ + +/* Source: Ian Lance Taylor. Based on strict-overflow-2.c. */ + +/* We can only simplify the division when using strict overflow + semantics. */ + +int +foo (int i) +{ + return (i * 100) / 10; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-5.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-5.c new file mode 100644 index 0000000000..9af0adb993 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-5.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=3" } */ + +/* Source: Ian Lance Taylor. Based on strict-overflow-3.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i, int j) +{ + return i + 100 < j + 1000; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-6.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-6.c new file mode 100644 index 0000000000..c3a160c600 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-6.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2" } */ + +/* Source: Ian Lance Taylor. Based on strict-overflow-3.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i, int j) +{ + return i + 100 < j + 1000; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-7.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-7.c new file mode 100644 index 0000000000..401cbc3c98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-7.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */ + +/* Source: Ian Lance Taylor. */ + +int +foo (int i) +{ + return i + 10 > i; /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-8.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-8.c new file mode 100644 index 0000000000..566729fe30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-8.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wall -Wno-strict-overflow" } */ + +/* Source: Ian Lance Taylor. */ + +int +foo (int i) +{ + return i + 10 > i; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-9.c b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-9.c new file mode 100644 index 0000000000..425a121d5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstrict-overflow-9.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2" } */ + +/* Source: Ian Lance Taylor. */ + +int +foo (int i) +{ + return __builtin_abs (i) >= 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstring-compare-2.c b/SingleSource/Regression/C/gcc-dg/Wstring-compare-2.c new file mode 100644 index 0000000000..e6ca2a6999 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstring-compare-2.c @@ -0,0 +1,127 @@ +/* PR tree-optimization/90879 - fold zero-equality of strcmp between + a longer string and a smaller array + Test for a warning for strcmp of a longer string against smaller + array. + { dg-do compile } + { dg-options "-O2 -Wall -Wstring-compare -Wno-stringop-truncation -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); + +extern int strcmp (const char*, const char*); +extern size_t strlen (const char*); +extern char* strcpy (char*, const char*); +extern char* strncpy (char*, const char*, size_t); +extern int strncmp (const char*, const char*, size_t); + +void sink (int, ...); +#define sink(...) sink (__LINE__, __VA_ARGS__) + + +extern char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8], a9[9]; + +#define T(a, b) sink (0 == strcmp (a, b)) + + +void test_string_cst (void) +{ + const char *s1 = "1", *s2 = "12"; + + T (s1, a1); // { dg-warning ".strcmp. of a string of length 1 and an array of size 1 evaluates to nonzero" } + T (s1, a2); + T (s1, a3); + + T (a1, s1); // { dg-warning ".strcmp. of a string of length 1 and an array of size 1 evaluates to nonzero" } + T (a2, s1); + T (a3, s1); + + T (s2, a1); // { dg-warning ".strcmp. of a string of length 2 and an array of size 1 evaluates to nonzero" } + T (s2, a2); // { dg-warning ".strcmp. of a string of length 2 and an array of size 2 evaluates to nonzero" } + T (s2, a3); + + T (a1, s2); // { dg-warning ".strcmp. of a string of length 2 and an array of size 1 evaluates to nonzero" } + T (a2, s2); // { dg-warning ".strcmp. of a string of length 2 and an array of size 2 evaluates to nonzero" } + T (a3, s2); +} + + +void test_string_cst_off_cst (void) +{ + const char *s1 = "1", *s2 = "12", *s3 = "123", *s4 = "1234"; + + T (s1, a2 + 1); // { dg-warning ".strcmp. of a string of length 1 and an array of size 1 evaluates to nonzero" } + T (a2 + 1, s1); // { dg-warning ".strcmp. of a string of length 1 and an array of size 1 evaluates to nonzero" } + + + T (s3 + 1, a2); // { dg-warning ".strcmp. of a string of length 2 and an array of size 2 evaluates to nonzero" } + T (s3 + 1, a3); + + T (s2, a4 + 1); + T (s2, a4 + 2); // { dg-warning ".strcmp. of a string of length 2 and an array of size 2 evaluates to nonzero" } + + T (s4, a4 + 1); // { dg-warning ".strcmp. of a string of length 4 and an array of size 3 evaluates to nonzero" } + T (s3, a5 + 1); +} + + +/* Use strncpy below rather than memcpy until PR 91183 is resolved. */ + +#undef T +#define T(s, n, a) \ + do { \ + char arr[32]; \ + sink (arr); \ + strncpy (arr, s, n < 0 ? strlen (s) + 1: n); \ + sink (0 == strcmp (arr, a)); \ + } while (0) + +void test_string_exact_length (void) +{ + const char *s1 = "1", *s2 = "12"; + + T (s1, -1, a1); // { dg-warning ".strcmp. of a string of length 1 and an array of size 1 evaluates to nonzero" } + T (s1, -1, a2); + T (s1, -1, a3); + + T (s2, -1, a1); // { dg-warning ".strcmp. of a string of length 2 and an array of size 1 evaluates to nonzero" } + T (s2, -1, a2); // { dg-warning ".strcmp. of a string of length 2 and an array of size 2 evaluates to nonzero" } + T (s2, -1, a3); +} + + +void test_string_min_length (void) +{ + const char *s1 = "1", *s2 = "12"; + + T (s1, 1, a1); // { dg-warning ".strcmp. of a string of length 1 or more and an array of size 1 evaluates to nonzero" } + T (s1, 1, a2); + T (s1, 1, a3); + + T (s2, 2, a1); // { dg-warning ".strcmp. of a string of length 2 or more and an array of size 1 evaluates to nonzero" } + T (s2, 2, a2); // { dg-warning ".strcmp. of a string of length 2 or more and an array of size 2 evaluates to nonzero" } + T (s2, 2, a3); +} + + +int test_strncmp_str_lit_var (const char *s, long n) +{ + if (strncmp (s, "123456", n) == 0) // { dg-bogus "\\\[-Wstring-compare" } + return 1; + + return 0; +} + +int test_strlen_strncmp_str_lit_var (const char *s, long n) +{ + if (__builtin_strlen (s) < n) + return -1; + + if (n == 6) + if (strncmp (s, "123456", n) == 0) // { dg-bogus "\\\[-Wstring-compare" } + return 1; + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/Wstring-compare-3.c b/SingleSource/Regression/C/gcc-dg/Wstring-compare-3.c new file mode 100644 index 0000000000..6d0d5be9d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstring-compare-3.c @@ -0,0 +1,106 @@ +/* PR middle-end/95673 - missing -Wstring-compare for an impossible strncmp test + { dg-do compile } + { dg-options "-O2 -Wall -Wstring-compare -Wno-stringop-overread -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +extern int strcmp (const char*, const char*); +extern int strncmp (const char*, const char*, size_t); + +void sink (int, ...); + +extern char a3[3]; + +int nowarn_strcmp_one_use_ltz (int c) +{ + const char *s = c ? "1234" : a3; + int n = strcmp (s, "123"); + return n < 0; +} + + +int nowarn_strcmp_one_use_eqnz (int c) +{ + const char *s = c ? "12345" : a3; + int n = strcmp (s, "123"); + return n == 1; +} + + +int warn_strcmp_one_use_eqz (int c) +{ + const char *s = c ? "123456" : a3; + int n = strcmp (s, "123"); // { dg-warning "'strcmp' of a string of length 3 and an array of size 3 evaluates to nonzero" } + return n == 0; // { dg-message "in this expression" } +} + + +int warn_strcmp_one_use_bang (int c) +{ + const char *s = c ? "1234567" : a3; + int n = strcmp (s, "123"); // { dg-warning "'strcmp' of a string of length 3 and an array of size 3 evaluates to nonzero" } + return !n; // { dg-message "in this expression" } +} + + +int warn_strcmp_one_use_bang_bang (int c) +{ + const char *s = c ? "12345678" : a3; + int n = strcmp (s, "123"); // { dg-warning "'strcmp' of a string of length 3 and an array of size 3 evaluates to nonzero" } + return !!n; // { dg-message "in this expression" } +} + + +_Bool warn_one_use_bool (int c) +{ + const char *s = c ? "123456789" : a3; + int n = strcmp (s, "123"); // { dg-warning "'strcmp' of a string of length 3 and an array of size 3 evaluates to nonzero" } + return (_Bool)n; // { dg-message "in this expression" } +} + + +int warn_strcmp_one_use_cond (int c) +{ + const char *s = c ? "1234567890" : a3; + int n = strcmp (s, "123"); // { dg-warning "'strcmp' of a string of length 3 and an array of size 3 evaluates to nonzero" } + return n ? 3 : 5; // { dg-message "in this expression" } +} + + +int nowarn_strcmp_multiple_uses (int c) +{ + const char *s = c ? "1234" : a3; + int n = strcmp (s, "123"); + sink (n < 0); + sink (n > 0); + sink (n <= 0); + sink (n >= 0); + sink (n + 1); + return n; +} + + +int warn_strcmp_multiple_uses (int c) +{ + const char *s = c ? "12345" : a3; + int n = strcmp (s, "123"); // { dg-warning "'strcmp' of a string of length 3 and an array of size 3 evaluates to nonzero" } + sink (n < 0); + sink (n > 0); + sink (n <= 0); + sink (n >= 0); + sink (n == 0); // { dg-message "in this expression" } + return n; +} + + +int warn_strncmp_multiple_uses (int c) +{ + const char *s = a3; + int n = strncmp (s, "1234", 4); // { dg-warning "'strncmp' of a string of length 4, an array of size 3 and bound of 4 evaluates to nonzero" } + sink (n < 0); + sink (n > 0); + sink (n <= 0); + sink (n >= 0); + sink (n == 0); // { dg-message "in this expression" } + return n; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstring-compare.c b/SingleSource/Regression/C/gcc-dg/Wstring-compare.c new file mode 100644 index 0000000000..239bbfe514 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstring-compare.c @@ -0,0 +1,182 @@ +/* PR tree-optimization/90879 - fold zero-equality of strcmp between + a longer string and a smaller array + { dg-do compile } + { dg-options "-O2 -Wall -Wextra -ftrack-macro-expansion=0" } */ + +#include "strlenopt.h" + +#define T(a, b) sink (0 == strcmp (a, b), a, b) + +void sink (int, ...); + +struct S { char a4[4], c; }; + +extern char a4[4]; +extern char a5[5]; +extern char b4[4]; + +/* Verify that comparison of string literals with arrays with unknown + content but size that prevents them from comparing equal is diagnosed. */ + +void strcmp_array_lit (void) +{ + if (strcmp (a4, "1234")) // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" } + // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 } + sink (0, a4); + + int cmp; + cmp = strcmp (a4, "1234"); // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" } + if (cmp) // { dg-message "in this expression" } + sink (0, a4); + + T (a4, "4321"); // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero " } + T (a4, "12345"); // { dg-warning "length 5 and an array of size 4 " } + T (a4, "123456"); // { dg-warning "length 6 and an array of size 4 " } + T ("1234", a4); // { dg-warning "length 4 and an array of size 4 " } + T ("12345", a4); // { dg-warning "length 5 and an array of size 4 " } + T ("123456", a4); // { dg-warning "length 6 and an array of size 4 " } +} + + +void strcmp_array_pstr (void) +{ + const char *s4 = "1234"; + + { + if (strcmp (a4, s4)) // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" } + // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 } + sink (1, a4); + else + sink (0, a4); + } + + { + int c; + c = strcmp (a4, s4); // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" } + if (c) // { dg-message "in this expression" } + sink (1, a4); + else + sink (0, a4); + } + + const char *t4 = "4321"; + const char *s5 = "12345"; + const char *s6 = "123456"; + + T (a4, t4); // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero " } + T (a4, s5); // { dg-warning "length 5 and an array of size 4 " } + T (a4, s6); // { dg-warning "length 6 and an array of size 4 " } + T (s4, a4); // { dg-warning "length 4 and an array of size 4 " } + T (s5, a4); // { dg-warning "length 5 and an array of size 4 " } + T (s6, a4); // { dg-warning "length 6 and an array of size 4 " } +} + + +void strcmp_array_cond_pstr (int i) +{ + const char *s4 = i ? "1234" : "4321"; + T (a4, s4); // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero " } + T (a5, s4); +} + +void strcmp_array_copy (void) +{ + char s[8]; + + { + strcpy (s, "1234"); + if (strcmp (a4, s)) // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" } + // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 } + sink (1, a4); + else + sink (0, a4); + } + + { + strcpy (s, "1234"); + + int c; + c = strcmp (a4, s); // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero" } + if (c) // { dg-message "in this expression" } + sink (1, a4); + else + sink (0, a4); + } + + strcpy (s, "4321"); + T (a4, s); // { dg-warning "'strcmp' of a string of length 4 and an array of size 4 evaluates to nonzero " } + strcpy (s, "12345"); + T (a4, s); // { dg-warning "length 5 and an array of size 4 " } + strcpy (s, "123456"); + T (a4, s); // { dg-warning "length 6 and an array of size 4 " } + strcpy (s, "4321"); + T (s, a4); // { dg-warning "length 4 and an array of size 4 " } + strcpy (s, "54321"); + T (s, a4); // { dg-warning "length 5 and an array of size 4 " } + strcpy (s, "654321"); + T (s, a4); // { dg-warning "length 6 and an array of size 4 " } +} + + +void strcmp_member_array_lit (const struct S *p) +{ + // Not handled due to the fix for PR 92756. + T (p->a4, "1234"); // { dg-warning "length 4 and an array of size 4 " "pr92765" { xfail *-*-* } } +} + + +#undef T +#define T(a, b, n) sink (0 == strncmp (a, b, n), a, b) + +void strncmp_array_lit (void) +{ + if (strncmp (a4, "12345", 5)) // { dg-warning "'strncmp' of a string of length 5, an array of size 4 and bound of 5 evaluates to nonzero" } + // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 } + sink (0, a4); + + int cmp; + cmp = strncmp (a4, "54321", 5); // { dg-warning "'strncmp' of a string of length 5, an array of size 4 and bound of 5 evaluates to nonzero" } + if (cmp) // { dg-message "in this expression" } + sink (0, a4); + + // Verify no warning when the bound is the same as the array size. + T (a4, "4321", 4); + T (a4, "654321", 4); + + T (a4, "12345", 5); // { dg-warning "length 5, an array of size 4 and bound of 5 " } + T (a4, "123456", 6); // { dg-warning "length 6, an array of size 4 and bound of 6" } + + T ("1234", a4, 4); + T ("12345", a4, 4); + + T ("12345", a4, 5); // { dg-warning "length 5, an array of size 4 and bound of 5 " } + T ("123456", a4, 6); // { dg-warning "length 6, an array of size 4 and bound of 6 " } +} + + +void strncmp_strarray_copy (void) +{ + { + char a[] = "1234"; + char b[6]; + strcpy (b, "12345"); + if (strncmp (a, b, 5)) // { dg-warning "'strncmp' of strings of length 4 and 5 and bound of 5 evaluates to nonzero" } + // { dg-bogus "in this expression" "unwanted note" { target *-*-* } .-1 } + sink (0, a, b); + } + + { + char a[] = "4321"; + char b[6]; + strcpy (b, "54321"); + int cmp; + cmp = strncmp (a, b, 5); // { dg-warning "'strncmp' of strings of length 4 and 5 and bound of 5 evaluates to nonzero" } + if (cmp) // { dg-message "in this expression" } + sink (0, a, b); + } + + strcpy (a4, "abc"); + T (a4, "54321", 5); // { dg-warning "'strncmp' of strings of length 3 and 5 and bound of 5 evaluates to nonzero " } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-1.c b/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-1.c new file mode 100644 index 0000000000..97e317644d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-1.c @@ -0,0 +1,29 @@ +/* PR c/7776 */ +/* { dg-do compile } */ +/* { dg-options "-Waddress" } */ + +int test1(char *ptr) +{ + return ptr == "foo"; /* { dg-warning "comparison with string" } */ +} + +int test2() +{ + return "foo" != (const char*)0; +} + +int test3() +{ + return "foo" == (const char*)0; +} + +int test4() +{ + return (const char*)0 != "foo"; +} + +int test5() +{ + return (const char*)0 == "foo"; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-2.c b/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-2.c new file mode 100644 index 0000000000..3eb91eeca4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-2.c @@ -0,0 +1,29 @@ +/* PR c/7776 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int test1(char *ptr) +{ + return ptr == "foo"; /* { dg-warning "comparison with string" } */ +} + +int test2() +{ + return "foo" != (const char*)0; +} + +int test3() +{ + return "foo" == (const char*)0; +} + +int test4() +{ + return (const char*)0 != "foo"; +} + +int test5() +{ + return (const char*)0 == "foo"; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-3.c b/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-3.c new file mode 100644 index 0000000000..f700a51a87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-3.c @@ -0,0 +1,29 @@ +/* PR c/7776 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int test1(char *ptr) +{ + return ptr == "foo"; +} + +int test2() +{ + return "foo" != (const char*)0; +} + +int test3() +{ + return "foo" == (const char*)0; +} + +int test4() +{ + return (const char*)0 != "foo"; +} + +int test5() +{ + return (const char*)0 == "foo"; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-4.c b/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-4.c new file mode 100644 index 0000000000..f2a711aeb7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstring-literal-comparison-4.c @@ -0,0 +1,29 @@ +/* PR c/7776 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wno-address" } */ + +int test1(char *ptr) +{ + return ptr == "foo"; +} + +int test2() +{ + return "foo" != (const char*)0; +} + +int test3() +{ + return "foo" == (const char*)0; +} + +int test4() +{ + return (const char*)0 != "foo"; +} + +int test5() +{ + return (const char*)0 == "foo"; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-10.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-10.c new file mode 100644 index 0000000000..bace08ad5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-10.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/89500 - ICE: tree check: expected integer_cst, + have ssa_name in get_len + { dg-do compile } + { dg-options "-O2 -Wstringop-overflow -Wstringop-truncation" } */ + +void +foo (char *a) +{ + char b[16] = "abcdefg"; + __builtin_strncpy (a, b, __builtin_strlen (b)); /* { dg-warning "specified bound depends on the length of the source argument" } */ +} + +void +bar (char *a) +{ + char b[16] = "abcdefg"; + __builtin_strncpy (a, b, __builtin_strnlen (b, 8)); /* { dg-warning "specified bound depends on the length of the source argument" } */ +} + +void +baz (char *a) +{ + char b[16] = "abcdefg"; + __builtin_strncpy (a, b, __builtin_strnlen (b, 7)); /* { dg-bogus "specified bound depends on the length of the source argument" } */ +} + +void fill (char *); + +void +qux (char *a) +{ + char b[16]; + fill (b); + __builtin_memcpy (b, "abcdefg", 7); + __builtin_strncpy (a, b, __builtin_strnlen (b, 8)); /* { dg-bogus "specified bound depends on the length of the source argument" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-11.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-11.c new file mode 100644 index 0000000000..cf536527fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-11.c @@ -0,0 +1,321 @@ +/* PR tree-optimization/89350 - Wrong -Wstringop-overflow warning + on a variable offset from the end of an array + Test exercising -Wstringop-truncation with -Wall. + -Wstringop-truncation is disabled to avoid warnings for strncpy + calls whose bound matches the size of the destination getting + in the way of -Wstringop-overflow. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-truncation -ftrack-macro-expansion=0" } */ + +#include "range.h" + +extern void* memcpy (void*, const void*, size_t); +extern void* memset (void*, int, size_t); +extern char* strcpy (char*, const char*); +extern char* strncpy (char*, const char*, size_t); + +void sink (void*); + +#define CAT(pfx, line) pfx ## line +#define CONCAT(pfx, line) CAT (pfx, line) +#define UNIQ_NAME(pfx) CONCAT (pfx, __LINE__) + +/* Exercise a call to memset with a distinct destination object each + time to prevent GCC from reusing the destination pointer in later + tests. */ +#define T(off1, off2, n) \ + do { \ + extern char UNIQ_NAME (ga)[7]; \ + char *d = UNIQ_NAME (ga) + off1; \ + d += off2; \ + memset (d, 0, n); \ + sink (d); \ + } while (0) + + +/* Exercise calls to memset with a destination pointer pointing to + an array plus constant offset plus variable offset, in that order. */ + +void test_memset_array_cst_range_off (void) +{ + T (1, SR (-7, 7), 7); + T (1, SR (-1, 1), 7); + T (1, SR (-1, 1), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (1, SR ( 1, 2), 1); + T (1, SR ( 1, 2), 5); + + T (1, SR ( 0, 1), 6); + T (1, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (2, SR (-7, 7), 7); + T (2, SR (-2, 7), 7); + T (2, SR (-1, 1), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (2, SR (-1, 1), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (2, SR ( 1, 2), 1); + T (2, SR ( 1, 2), 3); + T (2, SR ( 1, 2), 4); + T (2, SR ( 1, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */ + T (2, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (7, UR (-7, 0), 7); + T (7, UR (-7, 0), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (7, UR (-3, 2), 3); + T (7, UR (-2, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +/* Exercise calls to memset with a destination pointer pointing to + an array plus variable offset plus constant offset. */ + +void test_memset_array_range_cst_off (void) +{ + T (SR (-7, 7), 1, 7); + T (SR (-1, 1), 1, 7); + T (SR (-1, 1), 1, 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */ + T (SR ( 1, 2), 1, 1); + T (SR ( 1, 2), 1, 5); + + T (SR ( 0, 1), 1, 6); + T (UR ( 1, 2), 1, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (SR (-7, 7), 2, 7); + T (SR (-1, 1), 2, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (SR (-1, 1), 2, 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (SR ( 1, 2), 2, 1); + T (SR ( 1, 2), 2, 3); + T (SR ( 1, 2), 2, 4); + T (SR ( 1, 2), 2, 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (SR ( 0, 1), 2, 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (UR ( 1, 2), 2, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +void test_memset_array_range_range_off (void) +{ + T (UR (0, 1), UR (0, 1), 7); + T (UR (3, 5), UR (2, 7), 1); + T (UR (3, 7), UR (2, 9), 2); + T (UR (3, 9), UR (2, 9), 3); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (UR (0, 1), UR (1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +#undef T +#define T(off1, off2, n) \ + do { \ + extern char UNIQ_NAME (ga)[7]; \ + char *d = UNIQ_NAME (ga) + off1; \ + d += off2; \ + memcpy (d, s, n); \ + sink (d); \ + } while (0) + + +void test_memcpy_array_cst_range_off (const void *s) +{ + T (1, SR (-7, 7), 7); + T (1, SR (-1, 1), 7); + T (1, SR (-1, 1), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (1, SR ( 1, 2), 1); + T (1, SR ( 1, 2), 5); + + T (1, SR ( 0, 1), 6); + T (1, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (2, SR (-7, 7), 7); + T (2, SR (-2, 7), 7); + T (2, SR (-1, 1), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (2, SR (-1, 1), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (2, SR ( 1, 2), 1); + T (2, SR ( 1, 2), 3); + T (2, SR ( 1, 2), 4); + T (2, SR ( 1, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */ + T (2, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (7, UR (-7, 0), 7); + T (7, UR (-7, 0), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (7, UR (-3, 2), 3); + T (7, UR (-2, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +void test_memcpy_array_range_cst_off (const void *s) +{ + T (SR (-7, 7), 1, 7); + T (SR (-1, 1), 1, 7); + T (SR (-1, 1), 1, 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */ + T (SR ( 1, 2), 1, 1); + T (SR ( 1, 2), 1, 5); + + T (SR ( 0, 1), 1, 6); + T (UR ( 1, 2), 1, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (SR (-7, 7), 2, 7); + T (SR (-1, 1), 2, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (SR (-1, 1), 2, 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (SR ( 1, 2), 2, 1); + T (SR ( 1, 2), 2, 3); + T (SR ( 1, 2), 2, 4); + T (SR ( 1, 2), 2, 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (SR ( 0, 1), 2, 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (UR ( 1, 2), 2, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +void test_memcpy_array_range_range_off (const void *s) +{ + T (UR (0, 1), UR (0, 1), 7); + T (UR (3, 5), UR (2, 7), 1); + T (UR (3, 7), UR (2, 9), 2); + T (UR (3, 9), UR (2, 9), 3); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (UR (0, 1), UR (1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +#undef T +#define T(off1, off2, n) \ + do { \ + extern char UNIQ_NAME (ga)[7]; \ + char *d = UNIQ_NAME (ga) + off1; \ + d += off2; \ + const char str[] = "0123456789"; \ + const char *s = str + sizeof str - 1 - n; \ + strcpy (d, s); \ + sink (d); \ + } while (0) + + +void test_strcpy_array_cst_range_off (void) +{ + T (1, SR (-7, 7), 6); + T (1, SR (-1, 1), 6); + T (1, SR (-1, 1), 8); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (1, SR ( 1, 2), 0); + T (1, SR ( 1, 2), 4); + + T (1, SR ( 0, 1), 5); + T (1, UR ( 1, 2), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (2, SR (-7, 7), 6); + T (2, SR (-2, 7), 6); + T (2, SR (-1, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (2, SR (-1, 1), 8); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (2, SR ( 1, 2), 0); + T (2, SR ( 1, 2), 2); + T (2, SR ( 1, 2), 3); + T (2, SR ( 1, 2), 4); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (2, SR ( 0, 1), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */ + T (2, UR ( 1, 2), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (7, UR (-7, 0), 6); + T (7, UR (-7, 0), 8); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (7, UR (-3, 2), 2); + T (7, UR (-2, 2), 4); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +void test_strcpy_array_range_cst_off (const char *s) +{ + T (SR (-7, 7), 1, 6); + T (SR (-1, 1), 1, 6); + T (SR (-1, 1), 1, 8); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */ + T (SR ( 1, 2), 1, 0); + T (SR ( 1, 2), 1, 1); + T (SR ( 1, 2), 1, 4); + + T (SR ( 0, 1), 1, 5); + T (UR ( 1, 2), 1, 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (SR (-7, 7), 2, 6); + T (SR (-1, 1), 2, 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (SR (-1, 1), 2, 8); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (SR ( 1, 2), 2, 0); + T (SR ( 1, 2), 2, 1); + T (SR ( 1, 2), 2, 2); + T (SR ( 1, 2), 2, 3); + T (SR ( 1, 2), 2, 4); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (SR ( 0, 1), 2, 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (UR ( 1, 2), 2, 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +#undef T +#define T(off1, off2, n) \ + do { \ + extern char UNIQ_NAME (ga)[7]; \ + char *d = UNIQ_NAME (ga) + off1; \ + d += off2; \ + strncpy (d, s, n); \ + sink (d); \ + } while (0) + + +void test_strncpy_array_cst_range_off (const char *s) +{ + T (1, SR (-7, 7), 7); + T (1, SR (-1, 1), 7); + T (1, SR (-1, 1), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (1, SR ( 1, 2), 1); + T (1, SR ( 1, 2), 5); + + T (1, SR ( 0, 1), 6); + T (1, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (2, SR ( -7, 7), 7); + T (2, SR ( -1, 1), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (2, SR ( -1, 1), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (2, SR ( 1, 2), 1); + T (2, SR ( 1, 2), 3); + T (2, SR ( 1, 2), 4); + T (2, SR ( 1, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (2, SR ( 0, 1), 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */ + T (2, UR ( 1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (7, UR (-7, 0), 7); + T (7, UR (-7, 0), 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (7, UR (-3, 2), 3); + T (7, UR (-2, 2), 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +void test_strncpy_array_range_cst_off (const char *s) +{ + T (SR (-7, 7), 1, 7); + T (SR (-1, 1), 1, 7); + T (SR (-1, 1), 1, 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr89428" } */ + T (SR ( 1, 2), 1, 1); + T (SR ( 1, 2), 1, 5); + + T (SR ( 0, 1), 1, 6); + T (UR ( 1, 2), 1, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (SR (-7, 7), 2, 7); + T (SR (-1, 1), 2, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (SR (-1, 1), 2, 9); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (SR ( 1, 2), 2, 1); + T (SR ( 1, 2), 2, 3); + T (SR ( 1, 2), 2, 4); + T (SR ( 1, 2), 2, 5); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (SR ( 0, 1), 2, 6); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + + T (UR ( 1, 2), 2, 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} + + +void test_strncpy_array_range_range_off (const char *s) +{ + T (UR (0, 1), UR (0, 1), 7); + T (UR (3, 5), UR (2, 7), 1); + T (UR (3, 7), UR (2, 9), 2); + T (UR (3, 9), UR (2, 9), 3); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + T (UR (0, 1), UR (1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-12.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-12.c new file mode 100644 index 0000000000..1ba7720988 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-12.c @@ -0,0 +1,121 @@ +/* PR tree-optimization/89350 - Wrong -Wstringop-overflow warning + on a variable offset from the end of an array + Test exercising -Wstringop-truncation alone, with -Warray-bounds + explicitly disabled. + { dg-do compile } + { dg-options "-O2 -Wno-array-bounds -Wstringop-overflow -ftrack-macro-expansion=0" } */ + +#include "range.h" + +extern void* memcpy (void*, const void*, size_t); +extern void* memset (void*, int, size_t); + +void sink (void*); + +extern char ga7[7]; + + +#define T(d, n) (memcpy ((d), s, (n)), sink (d)) + +void test_memcpy_array_cst_range_off (const void *s) +{ + char *d = ga7 + 1; + + T (d + UR (1, 2), 1); + T (d + UR (1, 2), 5); + + T (d + UR (0, 1), 6); + T (d + UR (0, 1), 7); /* { dg-warning ".memcpy. writing 7 bytes into a region of size 6 overflows the destination" "pr89428" } */ + T (d + UR (1, 2), 6); /* { dg-warning ".memcpy. writing 6 bytes into a region of size 5 overflows the destination" } */ + T (d + UR (1, 2), 7); /* { dg-warning "writing 7 bytes into a region of size 5 " } */ + + T (d + SR (-3, -2), 1); /* { dg-warning "writing 1 byte into a region of size 0 " } */ + T (d + SR (-2, -1), 1); + T (d + SR (-2, -1), 2); /* { dg-warning "writing 2 bytes into a region of size 7 " "pr89428" { xfail *-*-* } } */ + T (d + SR (-2, -1), 9); /* { dg-warning "writing 9 bytes into a region of size 7 " } */ + + d = ga7 + 7; + T (d + SR (-7, -6), 1); + T (d + SR (-7, -1), 1); + T (d + SR (-2, -1), 3); /* { dg-warning "writing 3 bytes into a region of size 2 " } */ + + T (d + UR (1, 2), 1); /* { dg-warning "writing 1 byte into a region of size 0 " } */ +} + + +void test_memcpy_array_range_range_off (const void *s) +{ + char *d = ga7 + UR (0, 1); + T (d + SR (-1, 0), 1); + T (d + SR (-1, 0), 7); + T (d + SR (-1, 0), 8); /* { dg-warning "writing 8 bytes into a region of size 7 " } */ + T (d + SR (-1, 0), 9); /* { dg-warning "writing 9 bytes into a region of size 7 " "pr89350" } */ +} + + +#undef T +#define T(d, n) (memset ((d), 0, (n)), sink (d)) + +void test_memset_array_unsigned_off (void) +{ + char *d = ga7 + 1; + + T (d + UR (1, 2), 1); + T (d + UR (1, 2), 5); + + T (d + UR (0, 1), 6); + T (d + UR (0, 1), 7); /* { dg-warning ".memset. writing 7 bytes into a region of size 6 overflows the destination" "pr89428" } */ + T (d + UR (1, 2), 6); /* { dg-warning ".memset. writing 6 bytes into a region of size 5 overflows the destination" } */ + T (d + UR (1, 2), 7); /* { dg-warning "writing 7 bytes into a region of size 5 " } */ + + T (d + SR (-3, -2), 1); /* { dg-warning "writing 1 byte into a region of size 0 " } */ + T (d + SR (-2, -1), 1); + T (d + SR (-2, -1), 2); /* { dg-warning "writing 2 bytes into a region of size 7 " "pr89428" { xfail *-*-* } } */ + T (d + SR (-2, -1), 9); /* { dg-warning "writing 9 bytes into a region of size 7 " } */ + + d = ga7 + 7; + T (d + SR (-7, -6), 1); + T (d + SR (-7, -1), 1); + T (d + SR (-2, -1), 3); /* { dg-warning "writing 3 bytes into a region of size 2 " } */ + + T (d + UR (1, 2), 1); /* { dg-warning "writing 1 byte into a region of size 0 " } */ +} + + + +struct MemArray { char a7[7], a3[3], c; }; + +extern struct MemArray gma; + +void test_memset_memarray (void) +{ + char *d = gma.a7 + 1; + + T (d + UR (1, 2), 1); + T (d + UR (1, 2), 5); + + T (d + UR (0, 1), 6); + T (d + UR (0, 1), 7); /* { dg-warning ".memset. writing 6 bytes into a region of size 5 overflows the destination" "pr89428" { xfail *-*-* } } */ + T (d + UR (1, 2), 6); /* { dg-warning ".memset. writing 6 bytes into a region of size 5 overflows the destination" "pr89350" { xfail *-*-* } } */ + T (d + UR (1, 2), 7); /* { dg-warning "writing 7 bytes into a region of size 5 " "pr85350" { xfail *-*-* } } */ + +} + + +#undef T +#define T(d, n) (memcpy ((d), s, (n)), sink (d)) + +void test_memcpy_array_signed_off (const void *s) +{ + char *d = ga7 + 1; + + T (d + SR (-7, 7), 7); + T (d + SR (-1, 1), 7); + T (d + SR (-1, 1), 9); /* { dg-warning "writing 9 bytes into a region of size " } */ + T (d + SR (-1, 2), 9); /* { dg-warning "writing 9 bytes into a region of size " } */ + T (d + SR (1, 2), 1); + T (d + SR (1, 2), 5); + + T (d + SR (0, 1), 6); + T (d + UR (1, 2), 7); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-13.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-13.c new file mode 100644 index 0000000000..bd513151ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-13.c @@ -0,0 +1,40 @@ +/* PR middle-end/89957 - ICE calling strnlen with an int128_t bound + in a known range + PR middle-end/89911 - ICE on a call with no arguments to strnlen + declared with no prototype + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern size_t strnlen (); + +size_t f0 (void) +{ + return strnlen (); /* { dg-warning "too few arguments to built-in function 'strnlen'" } */ +} + +size_t f1 (const char *s) +{ + return strnlen (s); /* { dg-warning "too few arguments to built-in function 'strnlen'" } */ +} + +size_t f2 (const char *s) +{ + return strnlen (s, s); /* { dg-warning "\\\[-Wint-conversion]" } */ +} + +#if __SIZEOF_INT128__ == 16 + +size_t fi128 (const char *s, __int128_t n) +{ + if (n < 0) + n = 0; + + /* PR middle-end/89957 */ + return strnlen (s, n); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" "int128" { target int128 } } */ +} + +#endif + +/* { dg-prune-output "\\\[-Wint-conversion]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-14-novec.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-14-novec.c new file mode 100644 index 0000000000..de39eaaeb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-14-novec.c @@ -0,0 +1,16 @@ +/* Test to verify that past-the-end multibyte writes via lvalues of wider + types than char are diagnosed. + { dg-do compile } + { dg-require-effective-target int32plus } + { dg-options "-O2 -fno-tree-vectorize -Wall -Wno-array-bounds" } */ + +typedef __INT16_TYPE__ int16_t; + +char a4[4], a8[8], a16[16]; + +void test_int16 (void) +{ + char *p = a4 + 1; + *(int16_t*)p = 0; + *(int16_t*)(p + 2) = 0; // { dg-warning "writing 2 bytes into a region of size 1" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-14.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-14.c new file mode 100644 index 0000000000..3d1d9e54d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-14.c @@ -0,0 +1,57 @@ +/* Test to verify that past-the-end multibyte writes via lvalues of wider + types than char are diagnosed. + { dg-do compile } + { dg-require-effective-target int32plus } + { dg-options "-O2 -Wall -Wno-array-bounds" } + { dg-additional-options "-mtune=generic" { target { i?86-*-* x86_64-*-* } } } */ + +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; +typedef __INT64_TYPE__ int64_t; +typedef __SIZE_TYPE__ size_t; + +void* memcpy (void*, const void*, size_t); +char* strcpy (char*, const char*); + +char a4[4], a8[8], a16[16]; + +const char s4[] = "1234"; +const char t4[] = "4321"; + +void test_memcpy_cond (int i) +{ + char *p = a4 + 1; + const char *q = i ? s4 : t4; + // On strictly aligned target the call below is left unchanged and + // triggers (inaccurately) a -Warray-bounds. The test suppresses + // the warning above, which then lets -Wstringop-overrflow detect + // the overflow just before expansion. + // On other targets it's transformed into a store of a 4-byte integer + // which is detected by -Wstringop-overrflow in the strlen pass (i.e., + // before it gets to expansion). + memcpy (p, q, 4); // { dg-warning "writing 4 bytes into a region of size 3" } +} + + +void test_int16 (void) +{ + char *p = a4 + 1; + *(int16_t*)p = 0; // { dg-warning "writing 4 bytes into a region of size 3" "pr102706" { target { vect_slp_v2hi_store_unalign } } } + *(int16_t*)(p + 2) = 0; // { dg-warning "writing 2 bytes into a region of size 1" "pr102706" { xfail { vect_slp_v2hi_store_unalign } } } +} + + +void test_int32 (void) +{ + char *p = a8 + 3; + *(int32_t*)p = 0; + *(int32_t*)(p + 2) = 0; // { dg-warning "writing 4 bytes into a region of size 3" } +} + + +void test_int64 (void) +{ + char *p = a16 + 5; + *(int64_t*)p = 0; + *(int64_t*)(p + 5) = 0; // { dg-warning "writing 8 bytes into a region of size 6" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-15.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-15.c new file mode 100644 index 0000000000..f7dcb94dc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-15.c @@ -0,0 +1,73 @@ +/* PR middle-end/91458 - inconsistent warning for writing past the end + of an array member + Verify that the -Wstringop-overflow detection doesn't cause an ICE + for either kind of VLAs (member and non-member). + Diagnosing the accesses is the subject of pr82608. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds" } + { dg-require-effective-target alloca } */ + +void sink (void*); + +void vla_unbounded (int n) +{ + char a[n]; + + a[0] = 0; + a[1] = 1; + a[n] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } } + + sink (&a); +} + +void vla_bounded (int n) +{ + if (n > 32) + n = 32; + + char a[n]; + + a[0] = 0; + a[1] = 1; + a[31] = 31; + + sink (&a); + + a[n] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } } + a[32] = 32; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } + a[69] = 69; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } + + sink (&a); +} + + +void member_vla_unbounded (int n) +{ + struct S { char i, a[n]; } s; + + s.a[0] = 0; + s.a[1] = 1; + s.a[n] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } } + + sink (&s); +} + +void member_vla_bounded (int n) +{ + if (n > 32) + n = 32; + + struct S { char i, a[n]; } s; + + s.a[0] = 0; + s.a[1] = 1; + s.a[31] = 31; + + sink (&s); + + s.a[n] = n; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" { xfail *-*-* } } + s.a[32] = 32; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } + s.a[69] = 69; // { dg-warning "\\\[-Wstringop-overflow" "pr82608" } + + sink (&s); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-16.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-16.c new file mode 100644 index 0000000000..11fb05e730 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-16.c @@ -0,0 +1,21 @@ +/* PR middle-end/91599 - GCC does not say where warning is happening + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct charseq { + unsigned char bytes[0]; // { dg-message "while referencing|object declared here" } +}; + +struct locale_ctype_t { + struct charseq *mboutdigits[10]; +}; + +void ctype_finish (struct locale_ctype_t *ctype) +{ + long unsigned int cnt; + for (cnt = 0; cnt < 20; ++cnt) { + static struct charseq replace[2]; + replace[0].bytes[1] = '\0'; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + ctype->mboutdigits[cnt] = &replace[0]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-17.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-17.c new file mode 100644 index 0000000000..9c05d04f90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-17.c @@ -0,0 +1,19 @@ +/* Test to verify that -Wstringop-overflow mentions the referenced object + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +static void copy_n (char *d, const char *s, int n) +{ + while (n--) + *d++ = *s++; + *d = 0; // { dg-warning "writing 1 byte into a region of size 0" } +} + +void sink (void*); + +void call_copy_n (const char *s) +{ + char a[7]; // { dg-message "at offset 7 into destination object 'a'" } + copy_n (a, "1234567", 7); + sink (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-18.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-18.c new file mode 100644 index 0000000000..7866b585b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-18.c @@ -0,0 +1,239 @@ +/* PR middle-end/91977 - missing -Wstringop-overflow on memcpy into + a pointer plus offset + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +#define NOIPA __attribute__ ((noipa)) +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT (a, b) + +#define S3 "123" +#define S4 "1234" + +char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8]; +char b1[1], b2[2], b3[3], b4[4], b5[5], b6[6], b7[7], b8[8]; + +#define T(dst, src, off, n) \ + NOIPA void CAT (test_on_line_, __LINE__) (const void *s) \ + { \ + __builtin_memcpy (dst + off, src, n); \ + } typedef void dummy_type + +T (a4, s, 0, 1); +T (a4, s, 1, 1); +T (a4, s, 2, 1); +T (a4, s, 3, 1); +T (a4, s, 4, 1); // { dg-warning "writing 1 byte into a region of size 0" } + +T (a4, s, 0, 2); +T (a4, s, 1, 2); +T (a4, s, 2, 2); +T (a4, s, 3, 2); // { dg-warning "writing 2 bytes into a region of size 1" } +T (a4, s, 4, 2); // { dg-warning "writing 2 bytes into a region of size 0" } + +T (a4, s, 0, 3); +T (a4, s, 1, 3); +T (a4, s, 2, 3); // { dg-warning "writing 3 bytes into a region of size 2" } +T (a4, s, 3, 3); // { dg-warning "writing 3 bytes into a region of size 1" } +T (a4, s, 4, 3); // { dg-warning "writing 3 bytes into a region of size 0" } + +T (a4, s, 0, 4); +T (a4, s, 1, 4); // { dg-warning "writing 4 bytes into a region of size 3" } +T (a4, s, 2, 4); // { dg-warning "writing 4 bytes into a region of size 2" } +T (a4, s, 3, 4); // { dg-warning "writing 4 bytes into a region of size 1" } +T (a4, s, 4, 4); // { dg-warning "writing 4 bytes into a region of size 0" } + +T (a7, s, 3, 3); +T (a7, s, 4, 3); +T (a7, s, 5, 3); // { dg-warning "writing 3 bytes into a region of size 2" } +T (a7, s, 6, 3); // { dg-warning "writing 3 bytes into a region of size 1" } +T (a7, s, 7, 3); // { dg-warning "writing 3 bytes into a region of size 0" } + +T (a7, s, 3, 4); +T (a7, s, 4, 4); // { dg-warning "writing 4 bytes into a region of size 3" } +T (a7, s, 5, 4); // { dg-warning "writing 4 bytes into a region of size 2" } +T (a7, s, 6, 4); // { dg-warning "writing 4 bytes into a region of size 1" } +T (a7, s, 7, 4); // { dg-warning "writing 4 bytes into a region of size 0" } + +T (a7, s, 1, 6); +T (a7, s, 2, 6); // { dg-warning "writing 6 bytes into a region of size 5" } +T (a7, s, 3, 6); // { dg-warning "writing 6 bytes into a region of size 4" } +T (a7, s, 4, 6); // { dg-warning "writing 6 bytes into a region of size 3" } +T (a7, s, 5, 6); // { dg-warning "writing 6 bytes into a region of size 2" } +T (a7, s, 6, 6); // { dg-warning "writing 6 bytes into a region of size 1" } +T (a7, s, 7, 6); // { dg-warning "writing 6 bytes into a region of size 0" } + +T (a8, s, 1, 7); +T (a8, s, 2, 7); // { dg-warning "writing 7 bytes into a region of size 6" } +T (a8, s, 3, 7); // { dg-warning "writing 7 bytes into a region of size 5" } +T (a8, s, 4, 7); // { dg-warning "writing 7 bytes into a region of size 4" } +T (a8, s, 5, 7); // { dg-warning "writing 7 bytes into a region of size 3" } +T (a8, s, 6, 7); // { dg-warning "writing 7 bytes into a region of size 2" } +T (a8, s, 7, 7); // { dg-warning "writing 7 bytes into a region of size 1" } +T (a8, s, 8, 7); // { dg-warning "writing 7 bytes into a region of size 0" } + +#undef T +#define T(dst, src, off, n) \ + NOIPA void CAT (test_on_line_, __LINE__) (const void *s) \ + { \ + char *d = dst + off; \ + __builtin_memcpy (d, src, n); \ + } typedef void dummy_type + +T (a4, s, 0, 1); +T (a4, s, 1, 1); +T (a4, s, 2, 1); +T (a4, s, 3, 1); +T (a4, s, 4, 1); // { dg-warning "writing 1 byte into a region of size 0" } + +T (a4, s, 0, 2); +T (a4, s, 1, 2); +T (a4, s, 2, 2); +T (a4, s, 3, 2); // { dg-warning "writing 2 bytes into a region of size 1" } +T (a4, s, 4, 2); // { dg-warning "writing 2 bytes into a region of size 0" } + +T (a4, s, 0, 3); +T (a4, s, 1, 3); +T (a4, s, 2, 3); // { dg-warning "writing 3 bytes into a region of size 2" } +T (a4, s, 3, 3); // { dg-warning "writing 3 bytes into a region of size 1" } +T (a4, s, 4, 3); // { dg-warning "writing 3 bytes into a region of size 0" } + +T (a4, s, 0, 4); +T (a4, s, 1, 4); // { dg-warning "writing 4 bytes into a region of size 3" } +T (a4, s, 2, 4); // { dg-warning "writing 4 bytes into a region of size 2" } +T (a4, s, 3, 4); // { dg-warning "writing 4 bytes into a region of size 1" } +T (a4, s, 4, 4); // { dg-warning "writing 4 bytes into a region of size 0" } + +T (a7, s, 3, 3); +T (a7, s, 4, 3); +T (a7, s, 5, 3); // { dg-warning "writing 3 bytes into a region of size 2" } +T (a7, s, 6, 3); // { dg-warning "writing 3 bytes into a region of size 1" } +T (a7, s, 7, 3); // { dg-warning "writing 3 bytes into a region of size 0" } + +T (a7, s, 3, 4); +T (a7, s, 4, 4); // { dg-warning "writing 4 bytes into a region of size 3" } +T (a7, s, 5, 4); // { dg-warning "writing 4 bytes into a region of size 2" } +T (a7, s, 6, 4); // { dg-warning "writing 4 bytes into a region of size 1" } +T (a7, s, 7, 4); // { dg-warning "writing 4 bytes into a region of size 0" } + +T (a7, s, 1, 6); +T (a7, s, 2, 6); // { dg-warning "writing 6 bytes into a region of size 5" } +T (a7, s, 3, 6); // { dg-warning "writing 6 bytes into a region of size 4" } +T (a7, s, 4, 6); // { dg-warning "writing 6 bytes into a region of size 3" } +T (a7, s, 5, 6); // { dg-warning "writing 6 bytes into a region of size 2" } +T (a7, s, 6, 6); // { dg-warning "writing 6 bytes into a region of size 1" } +T (a7, s, 7, 6); // { dg-warning "writing 6 bytes into a region of size 0" } + +#undef T +#define T(dst, src, init, off, n) \ + NOIPA void CAT (test_on_line_, __LINE__) (void) \ + { \ + __builtin_strcpy (src, init); \ + char *d = dst + off; \ + __builtin_memcpy (d, src, n); \ + } typedef void dummy_type + + +T (a6, b6, S4, 0, 4); +T (a6, b6, S4, 1, 4); +T (a6, b6, S4, 2, 4); +T (a6, b6, S4, 3, 4); // { dg-warning "writing 4 bytes into a region of size 3" } */ +T (a6, b6, S4, 4, 4); // { dg-warning "writing 4 bytes into a region of size 2" } */ +T (a6, b6, S4, 5, 4); // { dg-warning "writing 4 bytes into a region of size 1" } */ +T (a6, b6, S4, 6, 4); // { dg-warning "writing 4 bytes into a region of size 0" } */ + +T (a7, b7, S4, 0, 4); +T (a7, b7, S4, 1, 4); +T (a7, b7, S4, 2, 4); +T (a7, b7, S4, 3, 4); +T (a7, b7, S4, 4, 4); // { dg-warning "writing 4 bytes into a region of size 3" } */ +T (a7, b7, S4, 5, 4); // { dg-warning "writing 4 bytes into a region of size 2" } */ +T (a7, b7, S4, 6, 4); // { dg-warning "writing 4 bytes into a region of size 1" } */ +T (a7, b7, S4, 7, 4); // { dg-warning "writing 4 bytes into a region of size 0" } */ + +T (a8, b4, S3, 0, 4); +T (a8, b4, S3, 1, 4); +T (a8, b4, S3, 2, 4); +T (a8, b4, S3, 3, 4); +T (a8, b4, S3, 4, 4); +T (a8, b4, S3, 5, 4); // { dg-warning "writing 4 bytes into a region of size 3" } */ +T (a8, b4, S3, 6, 4); // { dg-warning "writing 4 bytes into a region of size 2" } */ +T (a8, b4, S3, 7, 4); // { dg-warning "writing 4 bytes into a region of size 1" } */ +T (a8, b4, S3, 8, 4); // { dg-warning "writing 4 bytes into a region of size 0" } */ + +T (a8, b8, S3, 0, 4); +T (a8, b8, S3, 1, 4); +T (a8, b8, S3, 2, 4); +T (a8, b8, S3, 3, 4); +T (a8, b8, S3, 4, 4); +T (a8, b8, S3, 5, 4); // { dg-warning "writing 4 bytes into a region of size 3" } */ +T (a8, b8, S3, 6, 4); // { dg-warning "writing 4 bytes into a region of size 2" } */ +T (a8, b8, S3, 7, 4); // { dg-warning "writing 4 bytes into a region of size 1" } */ +T (a8, b8, S3, 8, 4); // { dg-warning "writing 4 bytes into a region of size 0" } */ + +T (a8, b8, S4, 0, 4); +T (a8, b8, S4, 1, 4); +T (a8, b8, S4, 2, 4); +T (a8, b8, S4, 3, 4); +T (a8, b8, S4, 4, 4); +T (a8, b8, S4, 5, 4); // { dg-warning "writing 4 bytes into a region of size 3" } */ +T (a8, b8, S4, 6, 4); // { dg-warning "writing 4 bytes into a region of size 2" } */ +T (a8, b8, S4, 7, 4); // { dg-warning "writing 4 bytes into a region of size 1" } */ +T (a8, b8, S4, 8, 4); // { dg-warning "writing 4 bytes into a region of size 0" } */ + +T (a8, b8, S4, 0, 5); +T (a8, b8, S4, 1, 5); +T (a8, b8, S4, 2, 5); +T (a8, b8, S4, 3, 5); +T (a8, b8, S4, 4, 5); // { dg-warning "writing 5 bytes into a region of size 4" } */ +T (a8, b8, S4, 5, 5); // { dg-warning "writing 5 bytes into a region of size 3" } */ +T (a8, b8, S4, 6, 5); // { dg-warning "writing 5 bytes into a region of size 2" } */ +T (a8, b8, S4, 7, 5); // { dg-warning "writing 5 bytes into a region of size 1" } */ +T (a8, b8, S4, 8, 5); // { dg-warning "writing 5 bytes into a region of size 0" } */ + +T (a8, b8, S4, 0, 6); +T (a8, b8, S4, 1, 6); +T (a8, b8, S4, 2, 6); +T (a8, b8, S4, 3, 6); // { dg-warning "writing 6 bytes into a region of size 5" } */ +T (a8, b8, S4, 4, 6); // { dg-warning "writing 6 bytes into a region of size 4" } */ +T (a8, b8, S4, 5, 6); // { dg-warning "writing 6 bytes into a region of size 3" } */ +T (a8, b8, S4, 6, 6); // { dg-warning "writing 6 bytes into a region of size 2" } */ +T (a8, b8, S4, 7, 6); // { dg-warning "writing 6 bytes into a region of size 1" } */ +T (a8, b8, S4, 8, 6); // { dg-warning "writing 6 bytes into a region of size 0" } */ + + +#undef T +#define T(dst, init, off, n) \ + NOIPA void CAT (test_on_line_, __LINE__) (char *src) \ + { \ + __builtin_strcpy (src, init); \ + char *d = dst + off; \ + __builtin_memcpy (d, src, n); \ + } typedef void dummy_type + +T (a6, S4, 0, 4); +T (a6, S4, 1, 4); +T (a6, S4, 2, 4); +T (a6, S4, 3, 4); // { dg-warning "writing 4 bytes into a region of size 3" } */ +T (a6, S4, 4, 4); // { dg-warning "writing 4 bytes into a region of size 2" } */ +T (a6, S4, 5, 4); // { dg-warning "writing 4 bytes into a region of size 1" } */ +T (a6, S4, 6, 4); // { dg-warning "writing 4 bytes into a region of size 0" } */ + +T (a7, S4, 0, 4); +T (a7, S4, 1, 4); +T (a7, S4, 2, 4); +T (a7, S4, 3, 4); +T (a7, S4, 4, 4); // { dg-warning "writing 4 bytes into a region of size 3" } */ +T (a7, S4, 5, 4); // { dg-warning "writing 4 bytes into a region of size 2" } */ +T (a7, S4, 6, 4); // { dg-warning "writing 4 bytes into a region of size 1" } */ +T (a7, S4, 7, 4); // { dg-warning "writing 4 bytes into a region of size 0" } */ + +T (a8, S3, 0, 4); +T (a8, S3, 1, 4); +T (a8, S3, 2, 4); +T (a8, S3, 3, 4); +T (a8, S3, 4, 4); +T (a8, S3, 5, 4); // { dg-warning "writing 4 bytes into a region of size 3" } */ +T (a8, S3, 6, 4); // { dg-warning "writing 4 bytes into a region of size 2" } */ +T (a8, S3, 7, 4); // { dg-warning "writing 4 bytes into a region of size 1" } */ +T (a8, S3, 8, 4); // { dg-warning "writing 4 bytes into a region of size 0" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-19.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-19.c new file mode 100644 index 0000000000..cf866b3f1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-19.c @@ -0,0 +1,27 @@ +/* PR middle-end/92014 - bogus warning: writing 8 bytes into a region + of size 1 in timezone/zic.c + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct +{ + char *s1, *s2; + char c; +} z; + + +void f (char **a, int i, int j) +{ + char * cp = __builtin_strchr (a[i], '%'); + + if (cp && *++cp != 's') + return; + + z.s1 = __builtin_strdup (a[i]); + if (!z.s1) __builtin_abort (); + + z.s2 = __builtin_strdup (a[j]); + if (!z.s2) __builtin_abort (); + + z.c = cp ? *cp : '\0'; // { dg-bogus "\\\[-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-2.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-2.c new file mode 100644 index 0000000000..6e3e2ca082 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-2.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/83508 - c-c++-common/Wrestrict.c fails since r255836 + Test to verify that only one of -Wrestrict and -Wstringop-overflow is + issued for a problem where either would be appropriate. + { dg-do compile } + { dg-options "-O2 -Wrestrict -Wstringop-overflow" } */ + +#define DIFF_MAX __PTRDIFF_MAX__ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +void f (ptrdiff_t i, size_t n) +{ + if (i < DIFF_MAX - 2 || DIFF_MAX - 1 > i) + i = DIFF_MAX - 2; + + if (n < 4 || 5 < n) + n = 4; + + char a[8] = "012"; + + /* The following could very well be diagnosed by -Wstringop-overflow + instead but there's no way to verify that only one of the two + warnings is issued and the choice of -Wrestrict simply reflects + the fact that -Wrestrict runs before -Wstringop-overflow. */ + __builtin_strncpy (a + i, a, n); /* { dg-warning "\\\[-Wrestrict]" } */ + sink (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-20.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-20.c new file mode 100644 index 0000000000..4a6fe8ea35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-20.c @@ -0,0 +1,40 @@ +/* PR tree-optimization/92226 - live nul char store to array eliminated + Test to verify warnings are issued for overflow detected thanks to + the enhancement committed on top of the fix for PR 92226. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +#include "strlenopt.h" + +#define NOIPA __attribute__ ((noipa)) + +#define T(MIN, MAX, SIZE, IDX) \ + NOIPA void \ + test_ ## MIN ## _ ## MAX ## _ ## SIZE ## _ ## IDX (const char *s) \ + { \ + size_t len = strlen (s); \ + if (MIN <= len && len <= MAX) \ + { \ + extern char d[]; \ + strcpy (d, s); \ + d[IDX] = 0; \ + extern char a ## SIZE[SIZE]; \ + strcpy (a ## SIZE, d); \ + } \ + } typedef void dummy_type + + +T (2, 2, 1, 0); +T (2, 2, 1, 1); // { dg-warning "writing 2 bytes into a region of size 1" } +T (2, 2, 1, 2); // { dg-warning "writing 3 bytes into a region of size 1" } + +T (2, 3, 1, 0); +T (2, 3, 1, 1); // { dg-warning "writing 2 bytes into a region of size 1" } +T (2, 3, 1, 2); // { dg-warning "writing 3 bytes into a region of size 1" "" { xfail *-*-*} } +T (2, 3, 1, 3); // { dg-warning "writing 4 bytes into a region of size 1" "" { xfail *-*-* } } + +T (5, 7, 3, 1); +T (5, 7, 3, 2); +T (5, 7, 3, 3); // { dg-warning "writing 4 bytes into a region of size 3" } +T (5, 7, 3, 4); // { dg-warning "writing 5 bytes into a region of size 3" } +T (5, 7, 3, 5); // { dg-warning "writing 6 bytes into a region of size 3" "" { xfail *-*-* } } diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-21-novec.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-21-novec.c new file mode 100644 index 0000000000..6f83548e90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-21-novec.c @@ -0,0 +1,34 @@ +/* PR middle-end/92312 - bogus -Wstringop-overflow storing into a trailing + array backed by larger buffer + { dg-do compile } + { dg-options "-O2 -fno-tree-vectorize -Wall -Wno-array-bounds" } */ + +struct S0 { char a, b[0]; }; + +void sink (void*); + +void test_store_zero_length (int i) +{ + char a[3]; + struct S0 *p = (struct S0*)a; + p->a = 0; + p->b[0] = 0; + p->b[1] = 1; // { dg-bogus "\\\[-Wstringop-overflow" } + p->b[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" } + p->b[i] = 2; + sink (p); +} + +struct Sx { char a, b[]; }; + +void test_store_flexarray (int i) +{ + char a[3]; + struct Sx *p = (struct Sx*)a; + p->a = 0; + p->b[0] = 0; + p->b[1] = 1; // { dg-bogus "\\\[-Wstringop-overflow" } + p->b[2] = 1; // { dg-warning "\\\[-Wstringop-overflow" } + p->b[i] = 2; + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-21.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-21.c new file mode 100644 index 0000000000..4cd3c1b4f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-21.c @@ -0,0 +1,59 @@ +/* PR middle-end/92312 - bogus -Wstringop-overflow storing into a trailing + array backed by larger buffer + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds" } */ + +struct S0 { char a, b[0]; }; + +void sink (void*); + +void test_memset_zero_length (void) +{ + char a[3]; + struct S0 *p = (struct S0*)a; + p->a = 0; + __builtin_memset (p->b, 0, 2); + sink (p); + + __builtin_memset (p->b, 0, 3); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); +} + +void test_store_zero_length (int i) +{ + char a[3]; + struct S0 *p = (struct S0*)a; + p->a = 0; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v4qi_store_align } } } + p->b[0] = 0; + p->b[1] = 1; // { dg-bogus "\\\[-Wstringop-overflow" } + p->b[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { xfail { vect_slp_v4qi_store_align } } } + p->b[i] = 2; + sink (p); +} + + +struct Sx { char a, b[]; }; + +void test_memset_flexarray (int i) +{ + char a[3]; + struct Sx *p = (struct Sx*)a; + p->a = 0; + __builtin_memset (p->b, 0, 2); + sink (p); + + __builtin_memset (p->b, 0, 3); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); +} + +void test_store_flexarray (int i) +{ + char a[3]; + struct Sx *p = (struct Sx*)a; + p->a = 0; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v4qi_store_align } } } + p->b[0] = 0; + p->b[1] = 1; // { dg-bogus "\\\[-Wstringop-overflow" } + p->b[2] = 1; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { xfail { vect_slp_v4qi_store_align } } } + p->b[i] = 2; + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-22.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-22.c new file mode 100644 index 0000000000..764b199027 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-22.c @@ -0,0 +1,272 @@ +/* { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-truncation -ftrack-macro-expansion=0" } */ + +#define NULL (void*)0 + +const char a[] = { 'a', 'b', 'c', 'd' }; +const char b[] = { 'a', '\0', 'c', '\0', 'e' }; + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT (a, b) + +typedef struct FILE FILE; +extern FILE *fp; + +extern char *d; +extern const char *s; +extern int n; + +#define T(func, ...) \ + __attribute__ ((noipa)) void \ + CAT (test_ ## func, __LINE__) (void) \ + { \ + sink (0, __builtin_ ## func (__VA_ARGS__), d, s, n); \ + } typedef void dummy_type + +void sink (void*, ...); + + +// Exercise string functions. +T (index, a, 'x'); // { dg-warning "missing terminating nul" "index" } +T (index, a, *s); // { dg-warning "missing terminating nul" "index" } + +T (index, b, '0'); +T (index, b + 1, '1'); +T (index, b + 2, '2'); +T (index, b + 3, '3'); +T (index, b + 4, '4'); // { dg-warning "missing terminating nul" "index" } + +T (rindex, a, 'x'); // { dg-warning "missing terminating nul" "rindex" } +T (rindex, a, *s); // { dg-warning "missing terminating nul" "rindex" } + +T (rindex, b, '0'); +T (rindex, b + 1, '1'); +T (rindex, b + 2, '2'); +T (rindex, b + 3, '3'); +T (rindex, b + 4, '4'); // { dg-warning "missing terminating nul" "rindex" } + +T (stpcpy, d, a); // { dg-warning "missing terminating nul" "stpcpy" } + +T (stpncpy, d, a, 4); +T (stpncpy, d, a, 5); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "stpncpy" } +T (stpncpy, d, a, n); + +/* When the offset into an unterminated array isn't known and the bound + is less than the size of the array it suggests the access may be + constrained just right. When the bound is exactly equal to the size + of the array, then the offset would have to be zero for the access to + be safe, so a warning is justified. Otherwise, the bound is too small + and the access is definitely unsafe. */ +T (stpncpy, d, a + n, 3); +T (stpncpy, d, a + n, 4); // { dg-warning "specified bound 4 may exceed the size of at most 4 of unterminated array" "stpncpy" } +T (stpncpy, d, a + n, 5); // { dg-warning "specified bound 5 exceeds the size of at most 4 of unterminated array" "stpncpy" } + +T (stpncpy, d, b, 4); +T (stpncpy, d, b, 5); +T (stpncpy, d, b, n); + +T (stpncpy, d, b + 1, 4); +T (stpncpy, d, b + 1, 5); +T (stpncpy, d, b + 1, n); + +T (stpncpy, d, b + 3, 4); +T (stpncpy, d, b + 3, 5); +T (stpncpy, d, b + 3, n); + +T (stpncpy, d, b + 4, 1); +T (stpncpy, d, b + 4, 2); // { dg-warning "specified bound 2 exceeds the size 1 of unterminated array" "stpncpy" } +T (stpncpy, d, b + 4, n); +/* The following might be worth warning about since it's only safe with + n < 4. */ +T (stpncpy, d, b + n, 5); + +T (strcasecmp, a, "ab"); // { dg-warning "missing terminating nul" "strcasecmp" } +T (strcasecmp, a, s); // { dg-warning "missing terminating nul" "strcasecmp" } +T (strcasecmp, a, b); // { dg-warning "missing terminating nul" "strcasecmp" } +T (strcasecmp, b, b + 1); +T (strcasecmp, b, b + 2); +T (strcasecmp, b, b + 3); +T (strcasecmp, b, b + 4); // { dg-warning "missing terminating nul" "strcasecmp" } + +T (strcat, d, a); // { dg-warning "missing terminating nul" "strcat" } + +T (strncat, d, a, 4); +T (strncat, d, a, 5); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "strncat" } +T (strncat, d, a, n); + +T (strncat, d, b, n); +T (strncat, d, b + 1, n); +T (strncat, d, b + 2, n); +T (strncat, d, b + 3, n); +T (strncat, d, b + 4, 0); +T (strncat, d, b + 4, 1); +T (strncat, d, b + 4, 2); // { dg-warning "specified bound 2 exceeds the size 1 of unterminated array" "strncat" } +/* The following should probably trigger a warning since it's only safe + when n < 2, makes little sense with n == 0, and not much more with + n == 1. */ +T (strncat, d, b + 4, n); // { dg-warning "missing terminating nul" "strncat" { xfail *-*-* } } + +T (strchr, a, 'x'); // { dg-warning "missing terminating nul" "strchr" } +T (strchr, a, *s); // { dg-warning "missing terminating nul" "strchr" } + +T (strcmp, a, "ab"); // { dg-warning "missing terminating nul" "strcmp" } +T (strcmp, "bc", a); // { dg-warning "missing terminating nul" "strcmp" } +T (strcmp, a, s); // { dg-warning "missing terminating nul" "strcmp" } +T (strcmp, s, a); // { dg-warning "missing terminating nul" "strcmp" } + +T (strcmp, a, b); // { dg-warning "missing terminating nul" "strcmp" } +/* Even though most likely safe in reality because b[1] is nul, + the following is strictly undefined because a is not a string. + The warning is not issued because GCC folds the call to (int)*a. */ +T (strcmp, a, b + 1); // { dg-warning "missing terminating nul" "bug" { xfail *-*-* } } + +T (strncmp, a, "ab", 4); +T (strncmp, "bc", a, 4); +T (strncmp, a, a, 4); +T (strncmp, a, s, 4); +T (strncmp, s, a, 4); + +/* The warning below is not issued because GCC folds strncmp calls with + the same arguments to zero before it checks for the missing nul. */ +T (strncmp, a, a, 5); // { dg-warning "missing terminating nul" "pr92624" { xfail *-*-*} } +T (strncmp, a, s, 5); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "strcmp" } +T (strncmp, s, a, 5); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "strcmp" } + +T (strcpy, d, a); // { dg-warning "missing terminating nul" "strcpy" } + +T (strcspn, a, s); // { dg-warning "missing terminating nul" "strcspn" } +T (strcspn, s, a); // { dg-warning "missing terminating nul" "strcspn" } + +T (strspn, a, s); // { dg-warning "missing terminating nul" "strcspn" } +T (strspn, s, a); // { dg-warning "missing terminating nul" "strcspn" } + +T (strdup, a); // { dg-warning "missing terminating nul" "strdup" } + +T (strndup, a, 4); +T (strndup, a, 5); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "strndup" } +T (strndup, b + 3, 2); +T (strndup, b + 4, 1); +T (strndup, b + 4, 2); // { dg-warning "specified bound 2 exceeds the size 1 of unterminated array" "strndup" } + +T (strlen, a); // { dg-warning "missing terminating nul" "strlen" } + +T (strnlen, a, 4); +T (strnlen, a, 5); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "strnlen" } +T (strnlen, a, n); + +T (strpbrk, s, a); // { dg-warning "missing terminating nul" "strpbrk" } + +T (strrchr, a, 'x'); // { dg-warning "missing terminating nul" "strrchr" } +T (strrchr, a, *s); // { dg-warning "missing terminating nul" "strrchr" } + +T (strstr, a, "cde"); // { dg-warning "missing terminating nul" "strstr" } +T (strstr, a, s); // { dg-warning "missing terminating nul" "strstr" } + + +// Exercise a few string checking functions. +T (__stpcpy_chk, d, a, -1); // { dg-warning "missing terminating nul" "stpcpy" } + + +T (__stpncpy_chk, d, a, 4, -1); +T (__stpncpy_chk, d, a, 5, -1); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "stpncpy_chk" } +T (__stpncpy_chk, d, a, n, -1); + +T (__stpncpy_chk, d, a + n, 3, -1); +T (__stpncpy_chk, d, a + n, 4, -1); // { dg-warning "specified bound 4 may exceed the size of at most 4 of unterminated array" "stpncpy_chk" } +T (__stpncpy_chk, d, a + n, 5, -1); // { dg-warning "specified bound 5 exceeds the size of at most 4 of unterminated array" "stpncpy_chk" } + +T (__stpncpy_chk, d, b, 4, -1); +T (__stpncpy_chk, d, b, 5, -1); +T (__stpncpy_chk, d, b, n, -1); + +T (__stpncpy_chk, d, b + 1, 4, -1); +T (__stpncpy_chk, d, b + 1, 5, -1); +T (__stpncpy_chk, d, b + 1, n, -1); + +T (__stpncpy_chk, d, b + 3, 4, -1); +T (__stpncpy_chk, d, b + 3, 5, -1); +T (__stpncpy_chk, d, b + 3, n, -1); + +T (__stpncpy_chk, d, b + 4, 1, -1); +T (__stpncpy_chk, d, b + 4, 2, -1); // { dg-warning "specified bound 2 exceeds the size 1 of unterminated array" "stpncpy_chk" } +T (__stpncpy_chk, d, b + 4, n, -1); + + +T (__strncat_chk, d, a, 4, -1); +T (__strncat_chk, d, a, 5, -1); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "strncat_chk" } +T (__strncat_chk, d, a, n, -1); + +T (__strncat_chk, d, a + n, 3, -1); +T (__strncat_chk, d, a + n, 4, -1); // { dg-warning "specified bound 4 may exceed the size of at most 4 of unterminated array" "strncat_chk" } +T (__strncat_chk, d, a + n, 5, -1); // { dg-warning "specified bound 5 exceeds the size of at most 4 of unterminated array" "strncat_chk" } + +T (__strncat_chk, d, b, 4, -1); +T (__strncat_chk, d, b, 5, -1); +T (__strncat_chk, d, b, n, -1); + +T (__strncat_chk, d, b + 1, 4, -1); +T (__strncat_chk, d, b + 1, 5, -1); +T (__strncat_chk, d, b + 1, n, -1); + +T (__strncat_chk, d, b + 3, 4, -1); +T (__strncat_chk, d, b + 3, 5, -1); +T (__strncat_chk, d, b + 3, n, -1); + +T (__strncat_chk, d, b + 4, 1, -1); +T (__strncat_chk, d, b + 4, 2, -1); // { dg-warning "specified bound 2 exceeds the size 1 of unterminated array" "strncat_chk" } +T (__strncat_chk, d, b + 4, n, -1); + + +T (__strncpy_chk, d, a, 4, -1); +T (__strncpy_chk, d, a, 5, -1); // { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" "strncpy_chk" } +T (__strncpy_chk, d, a, n, -1); + +T (__strncpy_chk, d, a + n, 3, -1); +T (__strncpy_chk, d, a + n, 4, -1); // { dg-warning "specified bound 4 may exceed the size of at most 4 of unterminated array" "strncpy_chk" } +T (__strncpy_chk, d, a + n, 5, -1); // { dg-warning "specified bound 5 exceeds the size of at most 4 of unterminated array" "strncpy_chk" } + +T (__strncpy_chk, d, b, 4, -1); +T (__strncpy_chk, d, b, 5, -1); +T (__strncpy_chk, d, b, n, -1); + +T (__strncpy_chk, d, b + 1, 4, -1); +T (__strncpy_chk, d, b + 1, 5, -1); +T (__strncpy_chk, d, b + 1, n, -1); + +T (__strncpy_chk, d, b + 3, 4, -1); +T (__strncpy_chk, d, b + 3, 5, -1); +T (__strncpy_chk, d, b + 3, n, -1); + +T (__strncpy_chk, d, b + 4, 1, -1); +T (__strncpy_chk, d, b + 4, 2, -1); // { dg-warning "specified bound 2 exceeds the size 1 of unterminated array" "strncpy" } +T (__strncpy_chk, d, b + 4, n, -1); + + +// Exercise some stdio functions. +T (printf, a); // { dg-warning "unterminated format string" "printf" } +T (printf, "%s", a); // { dg-warning "not a nul-terminated string" "printf" } +T (sprintf, d, "%s", a); // { dg-warning "not a nul-terminated string" "sprintf" } +T (snprintf, d, n, "%s", a); // { dg-warning "not a nul-terminated string" "sprintf" } + +T (__sprintf_chk, d, 0, -1, "%s", a); // { dg-warning "not a nul-terminated string" "sprintf" } +T (__snprintf_chk, d, n, 0, -1, "%s", a); // { dg-warning "not a nul-terminated string" "sprintf" } + +T (fputs, a, fp); // { dg-warning "missing terminating nul" "fputs" } +T (fputs_unlocked, a, fp); // { dg-warning "missing terminating nul" "fputs_unlocked" } +T (puts, a); // { dg-warning "missing terminating nul" "puts" } +T (puts_unlocked, a); // { dg-warning "missing terminating nul" "puts_unlocked" } + + + +// Exerise exec functions. +T (execl, a, s, NULL); // { dg-warning "missing terminating nul" "execl" } +T (execle, a, s, NULL, NULL); // { dg-warning "missing terminating nul" "execle" } +T (execlp, a, s, NULL); // { dg-warning "missing terminating nul" "execlp" } + +T (execv, a, &d); // { dg-warning "missing terminating nul" "execv" } +T (execve, a, &d, &d); // { dg-warning "missing terminating nul" "execve" } +T (execvp, a, &d); // { dg-warning "missing terminating nul" "execvp" } + +T (gettext, a); // { dg-warning "missing terminating nul" "gettext" } + +T (strfmon, d, n, a); // { dg-warning "unterminated format string" "strfmon" } diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-23.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-23.c new file mode 100644 index 0000000000..0da916ad99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-23.c @@ -0,0 +1,181 @@ +/* PR middle-end/83859 - attribute to establish relation between parameters + for buffer and its size + Test to verify that with optimization enabled, -Wstringop-overflow + warnings are issued for calls to user-defined functions with attribute + access and with non-constant out-of-bounds arguments. + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) + +#define RDONLY(...) __attribute__ ((access (read_only, __VA_ARGS__))) +#define WRONLY(...) __attribute__ ((access (write_only, __VA_ARGS__))) +#define RDWR(...) __attribute__ ((access (read_write, __VA_ARGS__))) + +typedef __INT32_TYPE__ int32_t; + +/* Exercise null pointer detection. */ + +RDONLY (2, 1) void +rd2_1 (int, const void*); // { dg-message "in a call to function 'rd2_1' declared with attribute 'access \\\(read_only, 2, 1\\\)" "note" } + +void test_rd2_1 (void) +{ + { + void *null = 0; + void *p = &null; + + rd2_1 (0, null); + rd2_1 (1, p); + } + + { + void *null = 0; + rd2_1 (1, null); // { dg-warning "argument 2 is null but the corresponding size argument 1 value is 1" } + } + + { + void *null = 0; + /* Ideally the message would say "range" for a range and "value" + for a singular value but using the same reduces the complexity + of the code and keeps down the number of messages that need to + be translated, withot sacrificing (too much) clarity. */ + rd2_1 (SR (1, 2), null); // { dg-warning "argument 2 is null but the corresponding size argument 1 range|value is \\\[1, 2]" } + } +} + +WRONLY (3, 1) void +wr3_1 (int, int, void*); // { dg-message "in a call to function 'wr3_1' declared with attribute 'access \\\(write_only, 3, 1\\\)" } + +void test_wr3_1 (void) +{ + { + void *null = 0; + void *p = &null; + + wr3_1 (SR (0, 1), 0, null); + wr3_1 (SR (1, 1), 0, p); + } + + void *null = 0; + + wr3_1 (SR (1, 2), 1, null); // { dg-warning "argument 3 is null but the corresponding size argument 1 range|value is \\\[1, 2]" } +} + + +WRONLY (2, 1) void +wr2_1 (int, void*); + +void test_wrd2_1 (int n) +{ + wr2_1 (0, 0); + wr2_1 (SR (-1, 1), 0); + wr2_1 (SR (0, 1), 0); + wr2_1 (SR (1, 2), 0); // { dg-warning "argument 2 is null but the corresponding size argument 1 range|value is \\\[1, 2]" } + + /* This should probably be diagnosed but to avoid false positives + caused by jump threading and such it would have to be done + earlier than it is now. */ + wr2_1 (n, 0); // { dg-warning "argument 2 is null" "unimplemented" { xfail *-*-* } } +} + + +/* Exercise pointer to an incomplete type other than void. */ + +struct Incomplete; +extern struct Incomplete inc; + +extern char ax[]; + +WRONLY (1, 2) void +wr1_2_inc (struct Incomplete*, unsigned); + +void test_wr1_2_inc (struct Incomplete *pinc, unsigned n) +{ + wr1_2_inc (0, 0); + wr1_2_inc (0, 1); // { dg-warning "argument 1 is null but the corresponding size argument 2 value is 1" } + + wr1_2_inc (pinc, 1); + wr1_2_inc (&inc, 1); + + wr1_2_inc (pinc, 123); + wr1_2_inc (&inc, 456); + + char a3[3]; + pinc = (struct Incomplete*)a3; + wr1_2_inc (pinc, SR (3, 4)); + wr1_2_inc (pinc, SR (4, 5)); + // { dg-warning "'wr1_2_inc' writing between 4 and 5 bytes into a region of size 3" "small buffer cast to incomplete" { target *-*-* } .-1 } + + pinc = (struct Incomplete*)ax; + wr1_2_inc (pinc, SR (123, 456)); + + char vla[n]; + pinc = (struct Incomplete*)vla; + wr1_2_inc (pinc, SR (345, 456)); +} + + +RDONLY (1, 3) WRONLY (2, 4) void +rd1_3_wr2_4 (const void*, void*, int, int); + +void test_rd1_3_wr2_4 (const void *s, void *d, int n1, int n2) +{ + rd1_3_wr2_4 (s, d, 1, 2); + rd1_3_wr2_4 (s, d, 123, 456); + rd1_3_wr2_4 (s, d, INT_MAX, INT_MAX); + rd1_3_wr2_4 (s, d, -1, 2); // { dg-warning "argument 3 value -1 is negative" } + + const int ir_min_m1 = SR (INT_MIN, -1); + rd1_3_wr2_4 (s, d, ir_min_m1, 2); // { dg-warning "argument 3 range|value \\\[-\[0-9\]+, -1] is negative" } + + rd1_3_wr2_4 (s, d, SR (-1, 0), 2); + rd1_3_wr2_4 (s, d, SR (INT_MIN, INT_MAX), 2); + + rd1_3_wr2_4 (s, d, n1, n2); + + + const char s11[11] = "0123456789"; + + rd1_3_wr2_4 (s11, d, 11, n2); + rd1_3_wr2_4 (s11, d, 12, n2); // { dg-warning "'rd1_3_wr2_4' reading 12 bytes from a region of size 11" } + + rd1_3_wr2_4 (s11, d, SR (0, 11), n2); + rd1_3_wr2_4 (s11, d, SR (0, 12), n2); + rd1_3_wr2_4 (s11, d, SR (11, 12), n2); + rd1_3_wr2_4 (s11, d, SR (11, INT_MAX), n2); + rd1_3_wr2_4 (s11, d, SR (12, 13), n2); // { dg-warning "'rd1_3_wr2_4' reading between 12 and 13 bytes from a region of size 11" } + + char d4[4]; + rd1_3_wr2_4 (s, d4, n1, 4); + rd1_3_wr2_4 (s, d4, n1, 5); // { dg-warning "'rd1_3_wr2_4' writing 5 bytes into a region of size 4" } + + rd1_3_wr2_4 (s11, d4, SR (12, 13), SR (5, 6)); + // { dg-warning "'rd1_3_wr2_4' reading between 12 and 13 bytes from a region of size 11" "read" { target *-*-* } .-1 } + // { dg-warning "'rd1_3_wr2_4' writing between 5 and 6 bytes into a region of size 4" "read" { target *-*-* } .-2 } +} + + +/* Verify that function pointers are handled. */ + +RDONLY (1) void (*pfrd1)(const void*, const void*); + +void test_pfrd1 (void) +{ + pfrd1 ("" + SR (0, 9), "" + SR (1, 9)); + pfrd1 ("" + SR (1, 2), ""); // { dg-warning "reading 1 byte from a region of size 0" } +} + + +WRONLY (4, 3) void (*pfwr4_3)(int, const char*, int, int32_t*); + +void test_pfwr4_3 (void) +{ + int32_t i; + pfwr4_3 (3, "", 0, &i + SR (0, 9)); + pfwr4_3 (5, "", 1, &i + SR (1, 2)); // { dg-warning "writing 4 bytes into a region of size 0" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-24.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-24.c new file mode 100644 index 0000000000..049d1c6981 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-24.c @@ -0,0 +1,204 @@ +/* PR middle-end/83859 - attribute to establish relation between parameters + for buffer and its size + Test to verify that -Wstringop-overflow warnings are issued even with + no optimization for calls to user-defined functions with attribute + access and with constant out-of-bounds arguments. + { dg-do compile } + { dg-options "-O0 -Wall" } */ + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) + +#define rdonly __attribute__ ((access (read_only))) +#define RDONLY(...) __attribute__ ((access (read_only, __VA_ARGS__))) +#define WRONLY(...) __attribute__ ((access (write_only, __VA_ARGS__))) +#define RDWR(...) __attribute__ ((access (read_write, __VA_ARGS__))) + +typedef __INT32_TYPE__ int32_t; + +extern const char s1[1], s2[2], s3[3]; +extern char d1[1], d2[2], d3[3]; + +/* Exercise that null pointers are allowed in functions declared with + the attribute without a size operand. */ + +RDONLY (1) void +rd1_int (const int32_t*); // { dg-message "in a call to function 'rd1_int' declared with attribute 'access \\\(read_only, 1\\\)'" "note" } + +void test_rd1_int (void) +{ + rd1_int (0); + + int32_t i = 0; + rd1_int (&i); + + rd1_int ((int32_t*)s1); // { dg-warning "reading 4 bytes from a region of size 1" } +} + +/* Exercise null pointer detection in functions declared with + the attribute and with non-zero size. */ + +RDONLY (2, 1) void +rd2_1 (int, const void*); // { dg-message "in a call to function 'rd2_1' declared with attribute 'access \\\(read_only, 2, 1\\\)" "note" } + +void test_rd2_1 (void) +{ + rd2_1 (0, 0); + rd2_1 (1, ""); + rd2_1 (1, 0); // { dg-warning "argument 2 is null but the corresponding size argument 1 value is 1" } +} + +WRONLY (3, 1) void +wr3_1 (int, int, void*); // { dg-message "in a call to function 'wr3_1' declared with attribute 'access \\\(write_only, 3, 1\\\)" "note" } + +void test_wr3_1 (void) +{ + wr3_1 (0, 0, 0); + wr3_1 (1, 0, d1); + wr3_1 (2, 1, 0); // { dg-warning "argument 3 is null but the corresponding size argument 1 value is 2" } +} + + +/* Exercise pointer to an incomplete type other than void. */ + +struct Incomplete; +extern struct Incomplete inc; + +RDONLY (1) void +rd_inc (const struct Incomplete*); + +void test_rd_inc (const struct Incomplete *pinc) +{ + rd_inc (0); + + rd_inc (pinc); + rd_inc ((const struct Incomplete*)s1); + + rd_inc ((const struct Incomplete*)&s1[1]); + // { dg-warning "'rd_inc' reading 1 byte from a region of size 0" "past-the-end pointer" { target *-*-* } .-1 } +} + +RDONLY (1, 2) void +rd1_2_inc (const struct Incomplete*, unsigned); + +void test_rd1_2_inc (const struct Incomplete *pinc) +{ + rd1_2_inc (0, 0); + rd1_2_inc (0, 1); // { dg-warning "argument 1 is null but the corresponding size argument 2 value is 1" } + + rd1_2_inc (pinc, 1); + rd1_2_inc (&inc, 1); + + rd1_2_inc (pinc, 123); + rd1_2_inc (&inc, 456); + + rd1_2_inc ((const struct Incomplete*)s3, 4); + // { dg-warning "'rd1_2_inc' reading 4 bytes from a region of size 3" "small buffer cast to incomplete" { target *-*-* } .-1 } +} + + +/* Verify the handling of two attributes sharing the same size operand . */ + +RDONLY (1, 3) WRONLY (2, 3) void +rd1_3_wr2_3 (const void*, void*, int); + +void test_rd1_3_wr2_3 (void) +{ + rd1_3_wr2_3 (s1, d1, 0); + rd1_3_wr2_3 (s1, d1, 1); + + rd1_3_wr2_3 (s1, d1, 2); + // { dg-warning "'rd1_3_wr2_3' reading 2 bytes from a region of size 1" "read" { target *-*-* } .-1 } + // { dg-warning "'rd1_3_wr2_3' writing 2 bytes into a region of size 1" "write" { target *-*-* } .-2 } + + rd1_3_wr2_3 (s1, d2, 2); + // { dg-warning "'rd1_3_wr2_3' reading 2 bytes from a region of size 1" "read" { target *-*-* } .-1 } + + rd1_3_wr2_3 (s2, d1, 2); + // { dg-warning "'rd1_3_wr2_3' writing 2 bytes into a region of size 1" "write" { target *-*-* } .-1 } +} + + +/* Verify the handling of multiple attributes of the same kind with + out-of-order operands. */ + +RDONLY (1, 6) RDONLY (2, 5) RDONLY (3, 4) void +rd1_6_2_5_3_4 (const void *s1, const void *s2, const void *s3, + int n3, int n2, int n1); + +void test_rd1_6_2_5_3_4 (void) +{ + rd1_6_2_5_3_4 (s1, s2, s3, 4, 2, 1); // { dg-warning "reading 4 bytes from a region of size 3" } + rd1_6_2_5_3_4 (s1, s2, s3, 3, 5, 1); // { dg-warning "reading 5 bytes from a region of size 2" } + rd1_6_2_5_3_4 (s1, s2, s3, 3, 2, 6); // { dg-warning "reading 6 bytes from a region of size 1" } +} + + +/* Verify the handling of multiple attributes of different kinds with + out-of-order operands. */ + +RDONLY (1, 6) WRONLY (2, 5) RDONLY (3, 4) void +rd1_6_wr2_5_rd3_4 (const void *s1, void *d2, const void *s3, + int n3, int n2, int n1); + +void test_rd1_6_wr2_5_rd3_4 (void) +{ + rd1_6_wr2_5_rd3_4 (s1, d2, s3, 7, 2, 1); // { dg-warning "reading 7 bytes from a region of size 3" } + rd1_6_wr2_5_rd3_4 (s1, d2, s3, 3, 8, 1); // { dg-warning "writing 8 bytes into a region of size 2" } + rd1_6_wr2_5_rd3_4 (s1, d2, s3, 3, 2, 9); // { dg-warning "reading 9 bytes from a region of size 1" } +} + + +RDONLY (6, 1) WRONLY (5, 2) RDWR (4, 3) void +rd6_1_wr5_2_rd4_3 (int n1, int n2, int n3, + void *d3, void *d2, const void *s1); + +void test_rd6_1_wr5_2_rd4_3 (void) +{ + rd6_1_wr5_2_rd4_3 (7, 2, 1, d1, d2, s3); // { dg-warning "reading 7 bytes from a region of size 3" } + rd6_1_wr5_2_rd4_3 (3, 8, 1, d1, d2, s3); // { dg-warning "writing 8 bytes into a region of size 2" } + rd6_1_wr5_2_rd4_3 (3, 2, 9, d1, d2, s3); // { dg-warning "accessing 9 bytes in a region of size 1" } +} + + +RDONLY (1, 3) WRONLY (2, 4) void +rd1_3_wr2_4 (const void*, void*, int, int); + +void test_rd1_3_wr2_4 (const void *s, void *d, int n1, int n2) +{ + rd1_3_wr2_4 (s, d, 1, 2); + rd1_3_wr2_4 (s, d, 123, 456); + rd1_3_wr2_4 (s, d, INT_MAX, INT_MAX); + rd1_3_wr2_4 (s, d, -1, 2); // { dg-warning "argument 3 value -1 is negative" } + + const char s11[11] = "0123456789"; + + rd1_3_wr2_4 (s11, d, 11, n2); + rd1_3_wr2_4 (s11, d, 12, n2); // { dg-warning "'rd1_3_wr2_4' reading 12 bytes from a region of size 11" } +} + + +/* Verify that function pointers are handled. */ + +RDONLY (1) void (*pfrd1)(const void*, const void*); + +void test_pfrd1 (void) +{ + pfrd1 (0, 0); + pfrd1 ("", ""); + + pfrd1 ("", "" + 1); + pfrd1 ("" + 1, ""); // { dg-warning "reading 1 byte from a region of size 0" } +} + + +WRONLY (4, 3) void (*pfwr4_3)(int, const char*, int, int32_t*); + +void test_pfwr4_3 (void) +{ + pfwr4_3 (0, 0, 0, 0); + + int32_t i; + pfwr4_3 (3, "", 0, &i + 1); + pfwr4_3 (5, "", 1, &i + 1); // { dg-warning "writing 4 bytes into a region of size 0" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-25.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-25.c new file mode 100644 index 0000000000..bc60958757 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-25.c @@ -0,0 +1,384 @@ +/* PR middle-end/91582 - missing heap overflow detection for strcpy + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } + { dg-require-effective-target alloca } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) +#define NOIPA ATTR (noipa) + +extern void* alloca (size_t); +extern void* calloc (size_t, size_t); +extern void* malloc (size_t); + +extern ATTR (alloc_size (1), malloc) void* + alloc1 (size_t, int); +extern ATTR (alloc_size (2), malloc) void* + alloc2 (int, size_t); +extern ATTR (alloc_size (2, 4), malloc) void* + alloc2_4 (int, size_t, int, size_t); + +extern char* strcpy (char*, const char*); + +void sink (void*); + +#define S36 "0123456789abcdefghijklmnopqrstuvwxyz" +#define S(N) (S36 + sizeof S36 - N - 1) + +#define T(src, alloc) do { \ + char *s = src; \ + char *d = alloc; \ + strcpy (d, s); \ + sink (d); \ + } while (0) + + +NOIPA void test_strcpy_alloca (size_t n) +{ + size_t r_0_1 = UR (0, 1); + size_t r_1_2 = UR (1, 2); + size_t r_2_3 = UR (2, 3); + + T (S (0), alloca (r_0_1)); + T (S (1), alloca (r_0_1)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloca (r_1_2)); + T (S (1), alloca (r_1_2)); + T (S (2), alloca (r_1_2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloca (r_2_3)); + T (S (2), alloca (r_2_3)); + T (S (3), alloca (r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + T (S (9), alloca (r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + + size_t r_2_smax = UR (2, SIZE_MAX); + T (S (0), alloca (r_2_smax)); + T (S (1), alloca (r_2_smax)); + T (S (2), alloca (r_2_smax)); + T (S (3), alloca (r_2_smax * 2)); + T (S (4), alloca (r_2_smax * 2 + 1)); + + T (S (1), alloca (n)); + T (S (2), alloca (n + 1)); + T (S (9), alloca (n * 2 + 1)); + + int r_imin_imax = SR (INT_MIN, INT_MAX); + T (S (1), alloca (r_imin_imax)); + T (S (2), alloca (r_imin_imax + 1)); + T (S (9), alloca (r_imin_imax * 2 + 1)); + + int r_0_imax = SR (0, INT_MAX); + T (S (1), alloca (r_0_imax)); + T (S (2), alloca (r_0_imax + 1)); + T (S (9), alloca (r_0_imax * 2 + 1)); + + int r_1_imax = SR (1, INT_MAX); + T (S (1), alloca (r_1_imax)); + T (S (2), alloca (r_1_imax + 1)); + T (S (9), alloca (r_1_imax * 2 + 1)); + + ptrdiff_t r_dmin_dmax = SR (DIFF_MIN, DIFF_MAX); + T (S (1), alloca (r_dmin_dmax)); + T (S (2), alloca (r_dmin_dmax + 1)); + T (S (9), alloca (r_dmin_dmax * 2 + 1)); +} + +NOIPA void test_strcpy_calloc (void) +{ + size_t r_1_2 = UR (1, 2); + size_t r_2_3 = UR (2, 3); + + T (S (0), calloc (r_1_2, 1)); + T (S (1), calloc (r_1_2, 1)); + T (S (2), calloc (r_1_2, 1)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (2), calloc (r_2_3, 1)); + T (S (3), calloc (r_2_3, 1)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), calloc (1, r_1_2)); + T (S (1), calloc (1, r_1_2)); + T (S (2), calloc (1, r_1_2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (2), calloc (1, r_2_3)); + T (S (3), calloc (1, r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), calloc (r_1_2, 2)); + T (S (1), calloc (r_1_2, 2)); + T (S (2), calloc (r_1_2, 2)); + T (S (3), calloc (r_1_2, 2)); + T (S (4), calloc (r_1_2, 2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), calloc (r_2_3, 2)); + T (S (1), calloc (r_2_3, 2)); + T (S (2), calloc (r_2_3, 2)); + T (S (5), calloc (r_2_3, 2)); + T (S (6), calloc (r_2_3, 2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), calloc (r_1_2, 2)); + T (S (1), calloc (r_1_2, 2)); + T (S (2), calloc (r_1_2, 2)); + T (S (3), calloc (r_1_2, 2)); + T (S (4), calloc (r_1_2, 2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), calloc (r_2_3, 2)); + T (S (1), calloc (r_2_3, 2)); + T (S (2), calloc (r_2_3, 2)); + T (S (5), calloc (r_2_3, 2)); + T (S (6), calloc (r_2_3, 2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), calloc (r_1_2, r_2_3)); + T (S (1), calloc (r_1_2, r_2_3)); + T (S (2), calloc (r_1_2, r_2_3)); + T (S (3), calloc (r_1_2, r_2_3)); + T (S (4), calloc (r_1_2, r_2_3)); + T (S (5), calloc (r_1_2, r_2_3)); + T (S (6), calloc (r_1_2, r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + T (S (9), calloc (r_1_2, r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + + size_t r_2_dmax = UR (2, DIFF_MAX); + T (S (0), calloc (0, r_2_dmax)); // { dg-warning "\\\[-Wstringop-overflow" } + T (S (0), calloc (1, r_2_dmax)); + T (S (9), calloc (2, r_2_dmax)); + + T (S (0), calloc (r_2_dmax, r_2_dmax)); + T (S (9), calloc (r_2_dmax, r_2_dmax)); + + size_t r_2_smax = UR (2, SIZE_MAX); + T (S (0), calloc (r_2_smax, 1)); + T (S (9), calloc (r_2_smax, 2)); + + T (S (0), calloc (r_2_smax, r_2_smax)); + T (S (9), calloc (r_2_smax, r_2_smax)); +} + + +NOIPA void test_strcpy_malloc (void) +{ + size_t r_0_1 = UR (0, 1); + size_t r_1_2 = UR (1, 2); + size_t r_2_3 = UR (2, 3); + + T (S (0), malloc (r_0_1)); + T (S (1), malloc (r_0_1)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), malloc (r_1_2)); + T (S (1), malloc (r_1_2)); + T (S (2), malloc (r_1_2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), malloc (r_2_3)); + T (S (2), malloc (r_2_3)); + T (S (3), malloc (r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + T (S (9), malloc (r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } +} + + +NOIPA void test_strcpy_alloc1 (void) +{ + size_t r_0_1 = UR (0, 1); + size_t r_1_2 = UR (1, 2); + size_t r_2_3 = UR (2, 3); + +#define alloc1(n) alloc1 (n, 1) + + T (S (0), alloc1 (r_0_1)); + T (S (1), alloc1 (r_0_1)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc1 (r_1_2)); + T (S (1), alloc1 (r_1_2)); + T (S (2), alloc1 (r_1_2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc1 (r_2_3)); + T (S (2), alloc1 (r_2_3)); + T (S (3), alloc1 (r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + T (S (9), alloc1 (r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } +} + +NOIPA void test_strcpy_alloc2 (void) +{ + size_t r_0_1 = UR (0, 1); + size_t r_1_2 = UR (1, 2); + size_t r_2_3 = UR (2, 3); + +#define alloc2(n) alloc2 (1, n) + + T (S (0), alloc1 (r_0_1)); + T (S (1), alloc1 (r_0_1)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc1 (r_1_2)); + T (S (1), alloc1 (r_1_2)); + T (S (2), alloc1 (r_1_2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc1 (r_2_3)); + T (S (2), alloc1 (r_2_3)); + T (S (3), alloc1 (r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + T (S (9), alloc1 (r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } +} + + +NOIPA void test_strcpy_alloc2_4 (void) +{ + size_t r_1_2 = UR (1, 2); + size_t r_2_3 = UR (2, 3); + +#define alloc2_4(n1, n2) alloc2_4 (1, n1, 2, n2) + + T (S (0), alloc2_4 (r_1_2, 1)); + T (S (1), alloc2_4 (r_1_2, 1)); + T (S (2), alloc2_4 (r_1_2, 1)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (2), alloc2_4 (r_2_3, 1)); + T (S (3), alloc2_4 (r_2_3, 1)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc2_4 (1, r_1_2)); + T (S (1), alloc2_4 (1, r_1_2)); + T (S (2), alloc2_4 (1, r_1_2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (2), alloc2_4 (1, r_2_3)); + T (S (3), alloc2_4 (1, r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc2_4 (r_1_2, 2)); + T (S (1), alloc2_4 (r_1_2, 2)); + T (S (2), alloc2_4 (r_1_2, 2)); + T (S (3), alloc2_4 (r_1_2, 2)); + T (S (4), alloc2_4 (r_1_2, 2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc2_4 (r_2_3, 2)); + T (S (1), alloc2_4 (r_2_3, 2)); + T (S (2), alloc2_4 (r_2_3, 2)); + T (S (5), alloc2_4 (r_2_3, 2)); + T (S (6), alloc2_4 (r_2_3, 2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc2_4 (r_1_2, 2)); + T (S (1), alloc2_4 (r_1_2, 2)); + T (S (2), alloc2_4 (r_1_2, 2)); + T (S (3), alloc2_4 (r_1_2, 2)); + T (S (4), alloc2_4 (r_1_2, 2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc2_4 (r_2_3, 2)); + T (S (1), alloc2_4 (r_2_3, 2)); + T (S (2), alloc2_4 (r_2_3, 2)); + T (S (5), alloc2_4 (r_2_3, 2)); + T (S (6), alloc2_4 (r_2_3, 2)); // { dg-warning "\\\[-Wstringop-overflow" } + + T (S (0), alloc2_4 (r_1_2, r_2_3)); + T (S (1), alloc2_4 (r_1_2, r_2_3)); + T (S (2), alloc2_4 (r_1_2, r_2_3)); + T (S (3), alloc2_4 (r_1_2, r_2_3)); + T (S (4), alloc2_4 (r_1_2, r_2_3)); + T (S (5), alloc2_4 (r_1_2, r_2_3)); + T (S (6), alloc2_4 (r_1_2, r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + T (S (9), alloc2_4 (r_1_2, r_2_3)); // { dg-warning "\\\[-Wstringop-overflow" } + + size_t r_2_dmax = UR (2, DIFF_MAX); + T (S (0), alloc2_4 (r_2_dmax, r_2_dmax)); + T (S (9), alloc2_4 (r_2_dmax, r_2_dmax)); + + size_t r_2_smax = UR (2, SIZE_MAX); + T (S (0), alloc2_4 (r_2_smax, r_2_smax)); + T (S (9), alloc2_4 (r_2_smax, r_2_smax)); +} + +#undef T +#define T(T, src, n) do { \ + char *s = src; \ + T vla[n]; \ + char *d = (char*)vla; \ + strcpy (d, s); \ + sink (vla); \ + } while (0) + +// Hack around PR 92829. +#define XUR(min, max) \ + (++idx, (vals[idx] < min || max < vals[idx] ? min : vals[idx])) + +NOIPA void test_strcpy_vla (const size_t vals[]) +{ + size_t idx = 0; + + size_t r_0_1 = XUR (0, 1); + size_t r_1_2 = XUR (1, 2); + size_t r_2_3 = XUR (2, 3); + + T (char, S (0), r_0_1); + T (char, S (1), r_0_1); // { dg-warning "\\\[-Wstringop-overflow" } + + T (char, S (0), r_1_2); + T (char, S (1), r_1_2); + T (char, S (2), r_1_2); // { dg-warning "\\\[-Wstringop-overflow" } + + T (char, S (0), r_2_3); + T (char, S (2), r_2_3); + T (char, S (3), r_2_3); // { dg-warning "\\\[-Wstringop-overflow" } + T (char, S (9), r_2_3); // { dg-warning "\\\[-Wstringop-overflow" } + +#ifdef __INT16_TYPE__ + typedef __INT16_TYPE__ int16_t; + + T (int16_t, S (0), r_1_2); + T (int16_t, S (2), r_1_2); + T (int16_t, S (3), r_1_2); + T (int16_t, S (4), r_1_2); // { dg-warning "\\\[-Wstringop-overflow" } + T (int16_t, S (5), r_1_2); // { dg-warning "\\\[-Wstringop-overflow" } + T (int16_t, S (9), r_1_2); // { dg-warning "\\\[-Wstringop-overflow" } + + T (int16_t, S (0), r_2_3); + T (int16_t, S (2), r_2_3); + T (int16_t, S (3), r_2_3); + T (int16_t, S (4), r_2_3); + T (int16_t, S (5), r_2_3); + T (int16_t, S (6), r_2_3); // { dg-warning "\\\[-Wstringop-overflow" } +#endif + +#ifdef __INT32_TYPE__ + typedef __INT32_TYPE__ int32_t; + + T (int32_t, S ( 0), r_2_3); + T (int32_t, S ( 2), r_2_3); + T (int32_t, S ( 3), r_2_3); + T (int32_t, S ( 4), r_2_3); + T (int32_t, S ( 5), r_2_3); + T (int32_t, S ( 6), r_2_3); + T (int32_t, S (11), r_2_3); + T (int32_t, S (12), r_2_3); // { dg-warning "\\\[-Wstringop-overflow" } + T (int32_t, S (36), r_2_3); // { dg-warning "\\\[-Wstringop-overflow" } +#endif +} + + +struct Flex +{ + char n, ax[]; +}; + +#undef T +#define T(T, src, n) do { \ + char *s = src; \ + typedef struct { T n, ax[]; } Flex; \ + Flex *p = (Flex*)malloc (sizeof *p + n); \ + char *d = (char*)p->ax; \ + strcpy (d, s); \ + sink (p); \ + } while (0) + +NOIPA void test_strcpy_malloc_flexarray (void) +{ + size_t r_0_1 = UR (0, 1); + size_t r_1_2 = UR (1, 2); + size_t r_2_3 = UR (2, 3); + + T (char, S (0), r_0_1); + T (char, S (1), r_0_1); // { dg-warning "\\\[-Wstringop-overflow" "pr92814" } + + T (char, S (0), r_1_2); + T (char, S (1), r_1_2); + T (char, S (2), r_1_2); // { dg-warning "\\\[-Wstringop-overflow" "pr92814" } + + T (char, S (0), r_2_3); + T (char, S (2), r_2_3); + T (char, S (3), r_2_3); // { dg-warning "\\\[-Wstringop-overflow" "pr92814" } + T (char, S (9), r_2_3); // { dg-warning "\\\[-Wstringop-overflow" "pr92814" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-26.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-26.c new file mode 100644 index 0000000000..4e8765eedb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-26.c @@ -0,0 +1,20 @@ +/* PR middle-end/79221 - missing -Wstringop-overflow= on a strcat overflow + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern char* strcat (char*, const char*); + +char d[3]; + +void f (int i) +{ + const char *s = i < 0 ? "01234567" : "89abcd"; + strcat (d, s); // { dg-warning "'strcat' writing between 7 and 9 bytes into a region of size 3" } */ +} + + +void g (int i) +{ + const char *s = i < 0 ? "12345678" : "87654321"; + strcat (d, s); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-27.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-27.c new file mode 100644 index 0000000000..607c27989a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-27.c @@ -0,0 +1,292 @@ +/* PR middle-end/91582 - missing heap overflow detection for strcpy + PR middle-end/85484 - missing -Wstringop-overflow for strcpy with + a string of non-const length + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* calloc (size_t, size_t); +extern void* malloc (size_t); +extern void* memcpy (void*, const void*, size_t); +extern void* memset (void*, int, size_t); +extern char* strcpy (char*, const char*); +extern size_t strlen (const char*); + +void sink (void*); + + +void test_memcpy_nowarn (const void *s, int i, size_t n) +{ + sink (memcpy (calloc (1, 1), s, 1)); + sink (memcpy (calloc (1, 2), s, 1)); + sink (memcpy (calloc (2, 1), s, 1)); + sink (memcpy (calloc (3, 1), s, 2)); + sink (memcpy (calloc (3, 1), "12", 2)); + sink (memcpy (calloc (3, 1), s, 3)); + sink (memcpy (calloc (3, 1), "12", 3)); + sink (memcpy (calloc (i, 1), s, 1)); + sink (memcpy (calloc (n, 1), s, 1)); + sink (memcpy (calloc (1, n), "", 1)); + sink (memcpy (calloc (1, i), "", 1)); + sink (memcpy (calloc (i, 1), "123", 3)); + sink (memcpy (calloc (n, 1), "123", 3)); + sink (memcpy (calloc (1, i), "123456", 7)); + sink (memcpy (calloc (1, n), "123456", 7)); + sink (memcpy (calloc (n, 1), s, 12345)); + sink (memcpy (calloc (1, n), s, n - 1)); + sink (memcpy (calloc (n, 1), s, n)); + + sink (memcpy ((char*)calloc (1, 1) + i, "123", 1)); + sink (memcpy ((char*)calloc (n, 1) + i, "123", n)); + + sink (memcpy ((char*)calloc (1, 1) + i, s, 1)); + sink (memcpy ((char*)calloc (n, 1) + i, s, n)); + + sink (memcpy (malloc (1), s, 1)); + sink (memcpy (malloc (2), s, 1)); + sink (memcpy (malloc (3), s, 2)); + sink (memcpy (malloc (3), "12", 2)); + sink (memcpy (malloc (3), s, 3)); + sink (memcpy (malloc (3), "12", 3)); + sink (memcpy (malloc (n), s, 1)); + sink (memcpy (malloc (n), "", 1)); + sink (memcpy (malloc (n), "123", 3)); + sink (memcpy (malloc (n), "123456", 7)); + sink (memcpy (malloc (n), s, 12345)); + sink (memcpy (malloc (n), s, n - 1)); + sink (memcpy (malloc (n), s, n)); + + { + const int a[] = { 1, 2, 3, 4 }; + void *p = (char*)malloc (sizeof a); + memcpy (p, a, sizeof a); + sink (p); + } + + { + const int a[] = { 1, 2, 3, 4, 5 }; + size_t nelts = sizeof a / sizeof *a; + int vla[nelts]; + memcpy (vla, a, nelts * sizeof *vla); + sink (vla); + } +} + + +void test_memcpy_warn (const int *s, size_t n) +{ + { + void *p = (char*)malloc (0); + memcpy (p, s, 1); // { dg-warning "writing 1 byte into a region of size 0" } + sink (p); + } + + { + void *p = (char*)malloc (1); + memcpy (p, s, 2); // { dg-warning "writing 2 bytes into a region of size 1" } + sink (p); + } + + { + void *p = (char*)malloc (2); + memcpy (p, s, 3); // { dg-warning "writing 3 bytes into a region of size 2" } + sink (p); + } + + { + void *p = (char*)malloc (3); + memcpy (p, s, 4); // { dg-warning "writing 4 bytes into a region of size 3" } + sink (p); + } + + { + const int a[] = { 1, 2, 3, 4 }; + void *p = (char*)malloc (sizeof *a); + memcpy (p, a, sizeof a); // { dg-warning "" } + sink (p); + } + + { + const int a[] = { 1, 2, 3, 4, 5 }; + size_t nelts = sizeof a / sizeof *a; + char vla[nelts]; + memcpy (vla, a, nelts * sizeof *a); // { dg-warning "" } + sink (vla); + } + + { + void *p = malloc (n); + memcpy (p, s, n * sizeof *s); // { dg-warning "\\\[-Wstringop-overflow" "" { xfail *-*-* } } + sink (p); + } +} + +void test_memset_nowarn (int x, size_t n) +{ + sink (memset (calloc (1, 1), x, 1)); + sink (memset (calloc (1, 2), x, 1)); + sink (memset (calloc (2, 1), x, 1)); + sink (memset (calloc (3, 1), x, 2)); + sink (memset (calloc (3, 1), x, 3)); + sink (memset (calloc (n, 1), x, 1)); + sink (memset (calloc (n, 1), x, 12345)); + sink (memset (calloc (1, n), x, n - 1)); + sink (memset (calloc (n, 1), x, n)); + + sink (memset (malloc (1), x, 1)); + sink (memset (malloc (2), x, 1)); + sink (memset (malloc (3), x, 2)); + sink (memset (malloc (3), x, 3)); + sink (memset (malloc (n), x, 1)); + sink (memset (malloc (n), x, 12345)); + sink (memset (malloc (n), x, n - 1)); + sink (memset (malloc (n), x, n)); + + { + const int a[] = { 1, 2, 3, 4 }; + void *p = (char*)malloc (sizeof a); + memset (p, x, sizeof a); + sink (p); + } + + { + const int a[] = { 1, 2, 3, 4, 5 }; + size_t nelts = sizeof a / sizeof *a; + int vla[nelts]; + memset (vla, x, nelts * sizeof *vla); + sink (vla); + } +} + + +void test_memset_warn (int x, size_t n) +{ + { + void *p = (char*)malloc (0); + memset (p, x, 1); // { dg-warning "writing 1 byte into a region of size 0" } + sink (p); + } + + { + void *p = (char*)malloc (1); + memset (p, x, 2); // { dg-warning "writing 2 bytes into a region of size 1" } + sink (p); + } + + { + void *p = (char*)malloc (2); + memset (p, x, 3); // { dg-warning "writing 3 bytes into a region of size 2" } + sink (p); + } + + { + void *p = (char*)malloc (3); + memset (p, x, 4); // { dg-warning "writing 4 bytes into a region of size 3" } + sink (p); + } + + { + const int a[] = { 1, 2, 3, 4 }; + void *p = (char*)malloc (sizeof *a); + memset (p, 0, sizeof a); // { dg-warning "" } + sink (p); + } + + { + const int a[] = { 1, 2, 3, 4, 5 }; + size_t nelts = sizeof a / sizeof *a; + char vla[nelts]; + memset (vla, 0, nelts * sizeof *a); // { dg-warning "" } + sink (vla); + } + + { + void *p = malloc (n); + memset (p, x, n * sizeof (int)); // { dg-warning "\\\[-Wstringop-overflow" "" { xfail *-*-* } } + sink (p); + } +} + + +void test_strcpy_nowarn (const char *s) +{ + { + const char a[] = "12"; + int n = strlen (a); + char *t = (char*)calloc (2, n); + strcpy (t, a); + sink (t); + } + + { + const char a[] = "123"; + unsigned n = strlen (a) + 1; + char *t = (char*)calloc (n, 1); + strcpy (t, a); + sink (t); + } + + { + const char a[] = "1234"; + size_t n = strlen (a) * 2; + char *t = (char*)malloc (n); + strcpy (t, a); + sink (t); + } + + { + const char a[] = "1234"; + size_t len = strlen (a) + 1; + char vla[len]; + strcpy (vla, a); + sink (vla); + } + + { + size_t n = strlen (s) + 1; + char *t = (char*)malloc (n); + strcpy (t, s); + sink (t); + } +} + + +void test_strcpy_warn (const char *s) +{ + { + const char a[] = "123"; + /* Verify that using signed int for the strlen result works (i.e., + that the conversion from signed int to size_t doesn't prevent + the detection. */ + int n = strlen (a); + char *t = (char*)calloc (n, 1); // { dg-message "destination object of size 3 allocated by 'calloc'" "note" } + strcpy (t, a); // { dg-warning "writing 4 bytes into a region of size (between 0 and )?3 " } + + sink (t); + } + + { + const char a[] = "1234"; + size_t n = strlen (a); + char *t = (char*)malloc (n); // { dg-message "destination object of size 4 allocated by 'malloc'" "note" } + strcpy (t, a); // { dg-warning "writing 5 bytes into a region of size (between 0 and )?4 " } + sink (t); + } + + // Exercise PR middle-end/85484. + { + size_t len = strlen (s); + char vla[len]; // { dg-message "destination object 'vla'" "vla note" } + strcpy (vla, s); // { dg-warning "writing one too many bytes into a region of a size that depends on 'strlen'" } + sink (vla); + } + + { + size_t n = strlen (s); + char *t = (char*)malloc (n); // { dg-message "allocated by 'malloc'" "malloc note" } + strcpy (t, s); // { dg-warning "writing one too many bytes into a region of a size that depends on 'strlen'" } + sink (t); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-28.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-28.c new file mode 100644 index 0000000000..f3e31fbade --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-28.c @@ -0,0 +1,233 @@ +/* PR middle-end/91582 - missing heap overflow detection for strcpy + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) +#define NOIPA ATTR (noipa) + +extern void* alloca (size_t); +extern void* calloc (size_t, size_t); +extern void* malloc (size_t); + +extern ATTR (alloc_size (1), malloc) char* alloc1 (size_t); +extern ATTR (alloc_size (1, 2), malloc) char* alloc2 (size_t, size_t); + +extern char* strcpy (char*, const char*); + +void sink (void*, ...); + + +/* Verify warning in stores to an object of variable size N in a known + range, at an offset (N + I) with a constant I. */ + +void same_size_and_offset_idx_cst (void) +{ +#define T(size, off, idx) do { \ + size_t n_ = size; \ + ptrdiff_t i_ = idx; \ + char *p_ = alloc1 (n_); \ + p_ += off; \ + p_[i_] = 0; \ + sink (p_); \ + } while (0) + + { + const size_t n = UR (2, 3); + + T (n, n, -4); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset \\\[-2, -1] into destination object of size \\\[2, 3] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + T (n, n, -3); + T (n, n, -2); + T (n, n, -1); + T (n, n, 0); + T (n, n, 1); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset 3 into destination object of size \\\[2, 3] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + } + + { + const size_t n = UR (3, 4); + + T (n, n, -5); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset \\\[-2, -1] into destination object of size \\\[3, 4] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + T (n, n, -4); + T (n, n, -3); + T (n, n, -2); + T (n, n, -1); + T (n, n, 0); + T (n, n, 1); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset 4 into destination object of size \\\[3, 4] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + } + + { + const size_t n = UR (5, SIZE_MAX - 2); + T (n, n, -1); + T (n, n, -1); + T (n, n, -1); + T (n, n, -1); + } +} + + +/* Verify warning in stores to an object of variable size N in a known + range, at an offset (M + I) with a variable M in some range and + constant I. */ + +void different_size_and_offset_idx_cst (void) +{ + { + const size_t n = UR (2, 3); + const size_t i = UR (1, 2); + + T (n, i, -4); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset \\\[-3, -2] into destination object of size \\\[2, 3] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + T (n, i, -3); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset \\\[-2, -1] into destination object of size \\\[2, 3] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + T (n, i, -2); + T (n, i, -1); + T (n, i, 0); + T (n, i, 1); + T (n, i, 2); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset 3 into destination object of size \\\[2, 3] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + } + + { + const size_t n = UR (3, 4); + const size_t i = UR (2, 5); + + T (n, i, -6); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset \\\[-4, -2] into destination object of size \\\[3, 4] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + + /* The offset -5 is necessarily invalid even if the sum (i - 5) is (or + could be) in bounds because it implies that the intermediate offset + (p + i) is out of bounds. */ + T (n, i, -5); // { dg-warning "writing 1 byte into a region of size 0 " } + T (n, i, -4); + T (n, i, -3); + T (n, i, -2); + T (n, i, -1); + T (n, i, 0); + T (n, i, 1); + T (n, i, 2); // { dg-warning "writing 1 byte into a region of size 0" } + // { dg-message "at offset 4 into destination object of size \\\[3, 4] allocated by 'alloc1'" "note" { target *-*-* } .-1 } + } +} + + +/* Verify warning in stores to an object of variable size N in a known + range, at an offset (M + I) with a variable M in some range and + constant I. */ +void different_size_and_offset_idx_var (void) +{ + { + const size_t n = UR (3, 4); + const size_t i = UR (1, 2); + + T (n, i, SR (DIFF_MIN, 0)); + T (n, i, SR ( -3, 0)); + T (n, i, SR ( -1, 0)); + T (n, i, SR ( 0, 1)); + T (n, i, SR ( 1, 2)); + T (n, i, SR ( 2, 3)); + T (n, i, SR ( 3, 4)); // { dg-warning "\\\[-Wstringop-overflow" } + // { dg-message "at offset 4 into destination object of size \\\[3, 4] allocated by 'alloc1'" "pr92940 note: offset addition" { target *-*-* } .-1 } + } +} + + +void ptr_add_2 (int n, int i0, int i1) +{ + if (n < 1 || 2 < n) n = 2; + + if (i0 < 0 || 1 < i0) i0 = 0; + if (i1 < 1 || 2 < i1) i1 = 1; + + char *p = (char*)__builtin_malloc (n); + char *q = p; + + q += i0; + q[0] = 0; // p[0] + q += i1; + q[0] = 1; // p[1] // { dg-warning "\\\[-Wstringop-overflow" "" { target { vect_slp_v2qi_store_unalign } } } + q[1] = 2; // p[2] // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } + + sink (p, q); +} + +void ptr_add_3 (int n, int i0, int i1, int i2) +{ + if (n < 3 || 4 < n) n = 3; + + if (i0 < 0 || 1 < i0) i0 = 0; + if (i1 < 1 || 2 < i1) i1 = 1; + if (i2 < 2 || 3 < i2) i2 = 2; + + char *p = (char*)__builtin_malloc (n); + char *q = p; + + q += i0; + q[0] = 0; // p[0] + q += i1; + q[0] = 1; // p[1] + q[1] = 2; // p[2] + q += i2; + q[0] = 3; // p[3] // { dg-warning "\\\[-Wstringop-overflow" "" { target { vect_slp_v2qi_store_unalign } } } + q[1] = 4; // p[4] // { dg-warning "\\\[-Wstringop-overflow" "" { xfail { vect_slp_v2qi_store_unalign } } } + + sink (p, q); +} + +void ptr_add_4 (int n, int i0, int i1, int i2, int i3) +{ + if (n < 7 || 8 < n) n = 7; + + if (i0 < 0 || 1 < i0) i0 = 0; + if (i1 < 1 || 2 < i1) i1 = 1; + if (i2 < 2 || 3 < i2) i2 = 2; + if (i3 < 3 || 4 < i3) i3 = 3; + + char *p = (char*)__builtin_malloc (n); + char *q = p; + + q += i0; + q[0] = 0; // p[0] + q += i1; + q[0] = 1; // p[1] + q[1] = 2; // p[2] + q += i2; + q[0] = 3; // p[3] + q[1] = 4; // p[4] + q[2] = 5; // p[5] + q += i3; + q[0] = 6; // p[6] + q[1] = 7; // p[7] + q[2] = 8; // p[8] // { dg-warning "\\\[-Wstringop-overflow" } + + sink (p, q); +} + +void ptr_sub_from_end (int n, int i0, int i1, int i2, int i3) +{ + if (n < 1 || 2 < n) n = 2; + + char *p = (char*)__builtin_malloc (n); + char *q = p; + + // The following isn't diagnosed due to a bug/limitation. + q += n; // N=1 N=2 + q[-1] = 0; // p[0] p[1] + q[-2] = 1; // p[-1] p[0] + q[-3] = 2; // p[-2] p[-1] // { dg-warning "\\\[-Wstringop-overflow" "pr92939: negative offset from end" } + + /* The following isn't diagnosed because the warning doesn't recognize + the index below as necessarily having the same value as the size + argument to malloc. All it considers is the range. */ + q[0] = 2; // { dg-warning "\\\[-Wstringop-overflow" "pr92937: store just past the end" { xfail *-*-* } } + q[1] = 3; // { dg-warning "\\\[-Wstringop-overflow" } + + sink (p, q); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-29.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-29.c new file mode 100644 index 0000000000..f13abbd7ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-29.c @@ -0,0 +1,66 @@ +/* PR middle-end/91582 - missing heap overflow detection for strcpy + Verify calls via function pointers. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +typedef __attribute__ ((alloc_size (1))) char* allocfn_t (unsigned); + +extern allocfn_t allocfn; + +void sink (void*); + +void direct_call (void) +{ + char *q = allocfn (0); // { dg-message "object of size 0 allocated by 'allocfn'" "note" } + q[0] = 0; // { dg-warning "\\\[-Wstringop-overflow" } + sink (q); +} + + +void local_ptr_call (void) +{ + allocfn_t *ptr = allocfn; + char *q = ptr (1); // { dg-message "at offset -1 into destination object of size 1 allocated by 'allocfn'" "note" } + q[0] = 0; + q[-1] = 0; // { dg-warning "\\\[-Wstringop-overflow" } + sink (q); +} + + +void global_ptr_call (void) +{ + extern allocfn_t *ptralloc; + + allocfn_t *ptr = ptralloc; + char *q = ptr (2); // { dg-message "at offset 3 into destination object of size 2 allocated by 'ptralloc'" "note" } + q[0] = 0; + q[1] = 1; + q[3] = 3; // { dg-warning "\\\[-Wstringop-overflow" } + sink (q); +} + +void global_ptr_array_call (void) +{ + extern allocfn_t * (arralloc[]); + + allocfn_t *ptr = arralloc[0]; + char *q = ptr (2); // { dg-message "at offset 3 into destination object of size 2 allocated by 'ptr'" "note" } + q[0] = 1; + q[1] = 2; + q[3] = 3; // { dg-warning "\\\[-Wstringop-overflow" } + sink (q); +} + + +struct S { allocfn_t *ptralloc; }; + +void member_ptr_call (struct S *p) +{ + char *q = p->ptralloc (3); // { dg-message "at offset 5 into destination object of size 3 allocated by 'ptralloc'" "note" } + q[0] = 0; + q[1] = 1; + q[2] = 2; + q[5] = 0; // { dg-warning "\\\[-Wstringop-overflow" } + sink (q); +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-3.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-3.c new file mode 100644 index 0000000000..6c8cbf3898 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-3.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/84238 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target alloca } */ + +char a[1]; +int b; +char *strncpy (char *, char *, __SIZE_TYPE__); +void +c () +{ + char d[b]; + strncpy (a, &d[3], 3); /* { dg-warning "writing 3 bytes into a region of size 1" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-30.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-30.c new file mode 100644 index 0000000000..a9eee9902d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-30.c @@ -0,0 +1,80 @@ +/* PR middle-end/93200 - spurious -Wstringop-overflow due to assignment + vectorization to multiple members + { dg-do compile } + { dg-options "-O3 -Wall" } */ + +typedef __INT8_TYPE__ int8_t; +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; +typedef __INT64_TYPE__ int64_t; + +struct A { char b, c; }; +struct B1A { int8_t i8; struct A a; }; +struct B2A { int16_t i16; struct A a; }; +struct B3A { int16_t i16; int8_t i8; struct A a; }; +struct B4A { int64_t i64; struct A a; }; + +void ba1 (struct B1A *p) +{ + p->a.b = 0; p->a.c = 1; +} + +void b2a (struct B2A *p) +{ + /* This results in: + vector(2) char *vectp.14_6 = &p_2(D)->a.b; + MEM [(char *)vectp.14_6] = { 4, 5 }; */ + + p->a.b = 4; // { dg-bogus "-Wstringop-overflow" } + p->a.c = 5; +} + +void b3a (struct B3A *p) +{ + p->a.b = 4; p->a.c = 5; +} + +void b4a (struct B4A *p) +{ + /* This results in: + vector(2) char *vectp.22_6 = &p_2(D)->a.b; + MEM [(char *)vectp.22_6] = { 6, 7 }; */ + + p->a.b = 6; // { dg-bogus "-Wstringop-overflow" } + p->a.c = 7; +} + + +struct Aa { char a[2], b[2]; }; +struct B1Aa { int8_t i8; struct Aa a; }; +struct B2Aa { int16_t i16; struct Aa a; }; +struct B3Aa { int16_t i16; int8_t i8; struct Aa a; }; +struct B4Aa { int64_t i64; struct Aa a; }; + +void b1aa (struct B1Aa *p) +{ + p->a.a[0] = 0; p->a.a[1] = 1; + p->a.b[0] = 0; p->a.b[1] = 1; +} + +void b2aa (struct B2Aa *p) +{ + p->a.a[0] = 2; p->a.a[1] = 3; + p->a.b[0] = 2; p->a.b[1] = 3; +} + +void b3aa (struct B3Aa *p) +{ + p->a.a[0] = 4; p->a.a[1] = 5; + p->a.b[0] = 4; p->a.b[1] = 5; +} + +void b4aa (struct B4Aa *p) +{ + /* This results in: + vector(4) char *vectp.36_8 = &p_2(D)->a.a[0]; + MEM [(char *)vectp.36_8] = { 6, 7, 6, 7 }; */ + + p->a.a[0] = 6; p->a.a[1] = 7; + p->a.b[0] = 6; p->a.b[1] = 7; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-31.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-31.c new file mode 100644 index 0000000000..24be256a54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-31.c @@ -0,0 +1,40 @@ +/* PR middle-end/93646 - confusing -Wstringop-truncation on strncat where + -Wstringop-overflow is expected + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern __SIZE_TYPE__ strlen (const char*); +extern char* strncat (char*, const char*, __SIZE_TYPE__); + + +char a[4]; + + +void f0 (char *d, const char *s) +{ + strncat (d, s, strlen (s)); // { dg-warning "specified bound depends on the length of the source argument" } + /* { dg-message "function 'f0'.*inlined from 'f1'" "inlining stack" { target *-*-* } 0 } */ + + // Prevent f0 from being replaced by g0. + *d = 'f'; +} + +void f1 (const char *s) +{ + f0 (a, s); +} + + +static void g0 (char *d, const char *s) +{ + strncat (d, s, strlen (s)); // { dg-warning "specified bound 3 equals source length" } + /* { dg-message "function 'g0'.*inlined from 'g1'" "inlining stack" { target *-*-* } 0 } */ + + // Prevent g0 from being replaced by f0. + *d = 'g'; +} + +void g1 (void) +{ + g0 (a, "123"); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-32.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-32.c new file mode 100644 index 0000000000..e5939567a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-32.c @@ -0,0 +1,51 @@ +/* PR middle-end/93829 - bogus -Wstringop-overflow on memcpy of a struct + with a pointer member from another with a long string + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern void* memcpy (void*, const void*, __SIZE_TYPE__); + +#define S40 "0123456789012345678901234567890123456789" + +const char s40[] = S40; + +struct S +{ + const void *p, *q, *r; +} s, sa[2]; + + +void test_lit_decl (void) +{ + struct S t = { 0, S40, 0 }; + + memcpy (&s, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" } +} + +void test_str_decl (void) +{ + struct S t = { 0, s40, 0 }; + + memcpy (&s, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" } +} + + +void test_lit_ssa (int i) +{ + if (i < 1) + i = 1; + struct S *p = &sa[i]; + struct S t = { 0, S40, 0 }; + + memcpy (p, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" } +} + +void test_str_ssa (int i) +{ + if (i < 1) + i = 1; + struct S *p = &sa[i]; + struct S t = { 0, s40, 0 }; + + memcpy (p, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-33.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-33.c new file mode 100644 index 0000000000..d4f7956c42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-33.c @@ -0,0 +1,40 @@ +/* PR middle-end/82456 - missing -Wstringop-overflow on strcpy reading past + the end of an array + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void fcst (char *d) +{ + char a[2] = "0"; + + __builtin_strcpy (d, a + 3); // { dg-warning "\\\[-W(array-bounds|stringop-overread)" } +} + +void frng (char *d, int i) +{ + char a[2] = "0"; + + if (i < 3) + i = 3; + + __builtin_strcpy (d, a + i); // { dg-warning "\\\[-W(array-bounds|stringop-overread)" } +} + +void gcst (char *d) +{ + char a[2] = "0"; + + __builtin_strcpy (d, a + 2); // { dg-warning "\\\[-W(array-bounds|stringop-overread)" } +} + +void grng (char *d, int i) +{ + char a[2] = "0"; + + if (i < 2) + i = 2; + + __builtin_strcpy (d, a + i); // { dg-warning "\\\[-W(array-bounds|stringop-overread)" } +} + +/* { dg-prune-output "-Wuninitialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-34.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-34.c new file mode 100644 index 0000000000..d9ca3447eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-34.c @@ -0,0 +1,252 @@ +/* PR middle-end/95353 - spurious -Wstringop-overflow writing to a trailing + array plus offset + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +struct S0 { char n, a[0]; }; + + +void s0_nowarn_cstidx (struct S0 *p) +{ + char *q = p->a; + q[1] = __LINE__; + q[9] = __LINE__; +} + +void s0_nowarn_cstoff_cstidx (struct S0 *p) +{ + char *q = p->a + 1; + q[1] = __LINE__; + q[9] = __LINE__; +} + +void s0_nowarn_varoff_cstdix (struct S0 *p, int i) +{ + char *q = p->a + i; + q[1] = __LINE__; // { dg-bogus "\\\[-Wstringop-overflow" } + q[9] = __LINE__; // { dg-bogus "\\\[-Wstringop-overflow" } +} + +void s0_nowarn_cstoff_varidx (struct S0 *p, int i) +{ + char *q = p->a + 1; + q[i] = __LINE__; +} + +void s0_nowarn_varoff_varidx (struct S0 *p, int i, int j) +{ + char *q = p->a + i; + q[j] = __LINE__; // { dg-bogus "\\\[-Wstringop-overflow" } +} + + +/* Accesses past the end of a trailing array with one element is + discouraged but still reluctantly not diagnosed. This should + change. */ + +struct S1 { char n, a[1]; }; + + +void s1_nowarn_cstidx (struct S1 *p) +{ + char *q = p->a; + q[1] = __LINE__; + q[9] = __LINE__; +} + +void s1_nowarn_cstoff_cstidx (struct S1 *p) +{ + char *q = p->a + 1; + q[1] = __LINE__; + q[9] = __LINE__; +} + +void s1_nowarn_varoff_cstdix (struct S1 *p, int i) +{ + char *q = p->a + i; + q[1] = __LINE__; // { dg-bogus "\\\[-Wstringop-overflow" } + q[9] = __LINE__; // { dg-bogus "\\\[-Wstringop-overflow" } +} + +void s1_nowarn_cstoff_varidx (struct S1 *p, int i) +{ + char *q = p->a + 1; + q[i] = __LINE__; +} + +void s1_nowarn_varoff_varidx (struct S1 *p, int i, int j) +{ + char *q = p->a + i; + q[j] = __LINE__; +} + + +/* Accesses past the end of a trailing array with more than one + element should be diagnosed but aren't yet because the MEM_REF + makes the out-of-bounds accesses indistinguishable from valid + ones to subsequent elements of the array pointed by P. */ + +struct S2 { char n, a[2]; }; + + +void s2_warn_cstidx (struct S2 *p) +{ + char *q = p->a; + + /* The following invalid store is represented as + MEM[(char *)p_1(D) + 3B] = __LINE__; + which is indistinguishable from the valid + q = &p[1].n; q[0] = __LINE__; + */ + q[2] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" "pr?????" { xfail *-*-* } } +} + +void s2_warn_cstoff_cstidx (struct S2 *p) +{ + char *q = p->a + 1; + q[1] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" "pr?????" { xfail *-*-* } } +} + +void s2_warn_varoff_cstdix (struct S2 *p, int i) +{ + char *q = p->a + i; + q[2] = __LINE__; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } +} + +void s2_warn_cstoff_varidx (struct S2 *p, int i) +{ + char *q = p->a + 1; + q[i] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" "pr?????" { xfail *-*-* } } +} + +void s2_warn_varoff_varidx (struct S2 *p, int i, int j) +{ + char *q = p->a + i; + q[j] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" "pr?????" { xfail *-*-* } } +} + + +/* Verify that none of these triggers a bogus warning (not tested + elsewhere but triggered during bootstrap). */ + +void s2_nowarn_varidx_int (struct S2 *p, int i) +{ + extern struct S2 s2; + extern struct S2 s2a[]; + + s2.a[i - 1] = __LINE__; + s2.a[i] = __LINE__; + s2.a[i + 1] = __LINE__; + + s2a[i].a[i - 1] = __LINE__; + s2a[i].a[i] = __LINE__; + s2a[i].a[i + 1] = __LINE__; + + p[i].a[i - 1] = __LINE__; + p[i].a[i] = __LINE__; + p[i].a[i + 1] = __LINE__; + + char *q = p->a; + q[i - 1] = __LINE__; + q[i] = __LINE__; + q[i + 1] = __LINE__; +} + +/* Same as above but with a size_t index in range [1, SIZE_MAX]. */ + +void* s2_nowarn_varidx_size (struct S2 *p, size_t i, size_t j) +{ + extern struct S2 s2; + extern struct S2 s2a[]; + struct S2 *ps2 = __builtin_malloc (3 * sizeof *ps2); + + s2.a[i - 1] = __LINE__; + s2.a[i] = __LINE__; + s2.a[i + 1] = __LINE__; + + s2a[i].a[i - 1] = __LINE__; + s2a[i].a[i] = __LINE__; + s2a[i].a[i + 1] = __LINE__; + + p[i].a[i - 1] = __LINE__; + p[i].a[i] = __LINE__; + p[i].a[i + 1] = __LINE__; + + ps2->a[i - 1] = __LINE__; + ps2->a[i] = __LINE__; + ps2->a[i + 1] = __LINE__; + + char *q = p->a; + q[i - 1] = __LINE__; + q[i] = __LINE__; + q[i + 1] = __LINE__; + + if (j == 0) + return ps2; + + s2.a[j - 1] = __LINE__; + s2.a[j] = __LINE__; + s2.a[j + 1] = __LINE__; + + s2a[j].a[j - 1] = __LINE__; + s2a[j].a[j] = __LINE__; + s2a[j].a[j + 1] = __LINE__; + + p[j].a[j - 1] = __LINE__; + p[j].a[j] = __LINE__; + p[j].a[j + 1] = __LINE__; + + ps2->a[j - 1] = __LINE__; + ps2->a[j] = __LINE__; + ps2->a[j + 1] = __LINE__; + + q = p->a; + q[j - 1] = __LINE__; + q[j] = __LINE__; + q[j + 1] = __LINE__; + + return ps2; +} + +/* Verify that accesses to an interior zero-length array are diagnosed. */ + +struct Si0 { char c, a[0], d; }; + +void si0_warn_cstidx (struct Si0 *p) +{ + // These are indistinguishable from valid accesses to p->d: + // MEM[(char *)p_1(D) + 1B] = 0; + char *q = p->a; + q[1] = __LINE__; // { dg-warning "writing 1 byte into a region of size 0" "pr?????" { xfail *-*-* } } + q[9] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" "pr?????" { xfail *-*-* } } +} + +void si0_warn_cstoff_cstidx (struct Si0 *p) +{ + // Like those above, these too are indistinguishable from valid accesses + // to p->d. + char *q = p->a + 1; + q[1] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" "pr?????" { xfail *-*-* } } + q[9] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" "pr?????" { xfail *-*-* } } +} + +void si0_warn_varoff_cstdix (struct Si0 *p, int i) +{ + char *q = p->a + i; + q[1] = __LINE__; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + q[9] = __LINE__; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } +} + +void si0_warn_cstoff_varidx (struct Si0 *p, int i) +{ + char *q = p->a + 1; + q[i] = __LINE__; // { dg-warning "\\\[-Wstringop-overflow" "pr?????" { xfail *-*-* } } +} + +void si0_warn_varoff_varidx (struct Si0 *p, int i, int j) +{ + char *q = p->a + i; + q[j] = __LINE__; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-35.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-35.c new file mode 100644 index 0000000000..612137ee46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-35.c @@ -0,0 +1,76 @@ +/* Verify that calls to strcpy to write to an element of an array of pointers + are not diagnosed (due to mistakenly using the size of the array as that + of the destination). + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef char A1[1]; +typedef char A2[2]; +typedef char A3[3]; +typedef char A4[4]; +typedef char A5[5]; +typedef char A6[6]; +typedef char A7[7]; +typedef char A8[8]; +typedef char A9[9]; +typedef char A10[10]; + +A1* pa1[3]; +A2* pa2[3]; +A3* pa3[3]; +A4* pa4[3]; +A5* pa5[3]; +A6* pa6[3]; +A7* pa7[3]; +A8* pa8[3]; +A9* pa9[3]; +A10* pa10[3]; + +void nowarn_a1_1 (int i) +{ + __builtin_strcpy (*pa1[0], ""); + __builtin_strcpy (*pa1[1], ""); + __builtin_strcpy (*pa1[i], ""); +} + +void nowarn_a2_2 (int i) +{ + __builtin_strcpy (*pa2[0], "1"); + __builtin_strcpy (*pa2[1], "2"); + __builtin_strcpy (*pa2[i], "3"); +} + +void nowarn_a3_3 (int i) +{ + __builtin_strcpy (*pa3[0], "12"); + __builtin_strcpy (*pa3[1], "23"); + __builtin_strcpy (*pa3[i], "34"); +} + +void nowarn_a4_4 (int i) +{ + __builtin_strcpy (*pa4[0], "123"); + __builtin_strcpy (*pa4[1], "234"); + __builtin_strcpy (*pa4[i], "345"); +} + +void nowarn_a5_5 (int i) +{ + __builtin_strcpy (*pa5[0], "1234"); + __builtin_strcpy (*pa5[1], "2345"); + __builtin_strcpy (*pa5[i], "3456"); +} + +void nowarn_a6_6 (int i) +{ + __builtin_strcpy (*pa6[0], "12345"); + __builtin_strcpy (*pa6[1], "23456"); + __builtin_strcpy (*pa6[1], "34567"); +} + +void nowarn_a10_10 (int i) +{ + __builtin_strcpy (*pa10[0], "0123456789"); + __builtin_strcpy (*pa10[1], "1234567890"); + __builtin_strcpy (*pa10[i], "2345678909"); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-36.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-36.c new file mode 100644 index 0000000000..3f0874dc5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-36.c @@ -0,0 +1,24 @@ +/* Verify that casts between pointers and integers don't trigger false + positives. Test derived from Glibc's _dl_allocate_tls_storage() in + dl-tls.c. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __UINTPTR_TYPE__ uintptr_t; + +size_t a; +size_t s; + +void* _dl_allocate_tls_storage (void) +{ + void *p = __builtin_malloc (s + a + sizeof (void *)); + + char *q = (char *)(__builtin_constant_p (a) && (((a - 1) & a) == 0) + ? ((((uintptr_t)p) + a - 1) & ~(a - 1)) + : (((((uintptr_t)p) + (a - 1)) / a) * a)); + + char *r = q + s - sizeof (int[4]); + __builtin_memset (r, '\0', sizeof (int[4])); + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-37.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-37.c new file mode 100644 index 0000000000..d9cf32d878 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-37.c @@ -0,0 +1,247 @@ +/* Verify that -Wstringop-overflow detects writing past the end of each + individual element of a multidimensional array. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -Wno-stringop-truncation" } */ + +#define CONCAT(x, y) x ## y +#define CAT(name, line) CONCAT (name, line) +#define UNIQ_NAME(name) CAT (name, __LINE__) + +typedef __SIZE_TYPE__ size_t; + +extern void* malloc (size_t); +extern char* strncpy (char*, const char*, size_t); + +extern char a2_2_8[2][2][8]; + +void nowarn_a2_2_8 (const char *s) +{ + // The following trigger -Wstringop-truncation. + strncpy (a2_2_8[0][0], s, 8); + strncpy (a2_2_8[0][1], s, 8); + strncpy (a2_2_8[1][0], s, 8); + strncpy (a2_2_8[1][1], s, 8); +} + +void warn_a2_2_8 (const char *s) +{ + strncpy (a2_2_8[0][0], s, 9); // { dg-warning "writing 9 bytes into a region of size 8 " } + strncpy (a2_2_8[0][1], s, 9); // { dg-warning "writing 9 bytes into a region of size 8 " } + strncpy (a2_2_8[1][0], s, 9); // { dg-warning "writing 9 bytes into a region of size 8 " } + strncpy (a2_2_8[1][1], s, 9); // { dg-warning "writing 9 bytes into a region of size 8 " } +} + + +extern char a2_3_5[2][3][5]; + +void nowarn_a2_3_5 (const char *s) +{ + // The following trigger -Wstringop-truncation. + strncpy (a2_3_5[0][0], s, 5); + strncpy (a2_3_5[0][1], s, 5); + strncpy (a2_3_5[0][2], s, 5); + strncpy (a2_3_5[1][0], s, 5); + strncpy (a2_3_5[1][1], s, 5); + strncpy (a2_3_5[1][2], s, 5); +} + +void warn_a2_3_5 (const char *s) +{ + strncpy (a2_3_5[0][0], s, 6); // { dg-warning "writing 6 bytes into a region of size 5 " } + strncpy (a2_3_5[0][1], s, 7); // { dg-warning "writing 7 bytes into a region of size 5 " } + strncpy (a2_3_5[1][0], s, 8); // { dg-warning "writing 8 bytes into a region of size 5 " } + strncpy (a2_3_5[1][1], s, 9); // { dg-warning "writing 9 bytes into a region of size 5 " } +} + + +void* nowarn_malloc_3_5 (const char *s, unsigned n) +{ + if (n < 3 || 5 < n) + n = 3; + char *p = (char*)malloc (n); + strncpy (p + 1, s, 4); + return p; +} + +void* warn_malloc_3_5 (const char *s, unsigned n) +{ + if (n < 3 || 5 < n) + n = 3; + char *p = (char*)malloc (n); // { dg-message "at offset 1 into destination object of size \\\[3, 5] allocated by 'malloc'" "note" } + // The size below should be a range like the one above. + strncpy (p + 1, s, 5); // { dg-warning "writing 5 bytes into a region of size 4 " } + return p; +} + + +typedef __attribute__ ((alloc_size (1, 2))) void* UsrAlloc (int, int); + +void* nowarn_use_alloc_3_5 (UsrAlloc *usr_alloc, const char *s, unsigned n) +{ + if (n < 3 || 5 < n) + n = 3; + char *p = (char*)usr_alloc (n, 3); + strncpy (p + 1, s, 14); + return p; +} + +void* warn_usr_alloc_3_5 (UsrAlloc *usr_alloc, const char *s, unsigned n) +{ + if (n < 3 || 5 < n) + n = 3; + char *p = (char*)usr_alloc (n, 3); // { dg-message "at offset 1 into destination object of size \\\[9, 15] allocated by 'usr_alloc'" "note" } + // The size below should be a range like the one above. + strncpy (p + 1, s, 15); // { dg-warning "writing 15 bytes into a region of size 14 " } + return p; +} + +struct S +{ + char a2_3_4[2][3][4]; + char a3_4_5[3][4][5]; +}; + +extern struct S sa[]; + +void nowarn_sa_cstidx_cstsize (const char* const s[]) +{ + strncpy (sa[0].a2_3_4[0][0], s[0], 4); + strncpy (sa[0].a2_3_4[0][1], s[1], 4); + strncpy (sa[0].a2_3_4[0][2], s[2], 4); + + strncpy (sa[0].a2_3_4[1][0], s[3], 4); + strncpy (sa[0].a2_3_4[1][1], s[4], 4); + strncpy (sa[0].a2_3_4[1][2], s[5], 4); + + strncpy (sa[1].a2_3_4[0][0], s[6], 4); + strncpy (sa[1].a2_3_4[0][1], s[7], 4); + strncpy (sa[1].a2_3_4[0][2], s[8], 4); + + strncpy (sa[1].a2_3_4[1][0], s[9], 4); + strncpy (sa[1].a2_3_4[1][1], s[10], 4); + strncpy (sa[1].a2_3_4[1][2], s[11], 4); +} + +void warn_sa_cstidx_cstsize (const char* const s[]) +{ + strncpy (sa[0].a2_3_4[0][0], s[0], 5); // { dg-warning "writing 5 bytes into a region of size 4 " } + strncpy (sa[0].a2_3_4[0][1], s[1], 6); // { dg-warning "writing 6 bytes into a region of size 4 " } + strncpy (sa[0].a2_3_4[0][2], s[2], 7); // { dg-warning "writing 7 bytes into a region of size 4 " } + + strncpy (sa[0].a2_3_4[1][0], s[3], 5); // { dg-warning "writing 5 bytes into a region of size 4 " } + strncpy (sa[0].a2_3_4[1][1], s[4], 6); // { dg-warning "writing 6 bytes into a region of size 4 " } + strncpy (sa[0].a2_3_4[1][2], s[5], 7); // { dg-warning "writing 7 bytes into a region of size 4 " } + + strncpy (sa[1].a2_3_4[0][0], s[6], 5); // { dg-warning "writing 5 bytes into a region of size 4 " } + strncpy (sa[1].a2_3_4[0][1], s[7], 6); // { dg-warning "writing 6 bytes into a region of size 4 " } + strncpy (sa[1].a2_3_4[0][2], s[8], 7); // { dg-warning "writing 7 bytes into a region of size 4 " } + + strncpy (sa[1].a2_3_4[1][0], s[9], 5); // { dg-warning "writing 5 bytes into a region of size 4 " } + strncpy (sa[1].a2_3_4[1][1], s[10], 6); // { dg-warning "writing 6 bytes into a region of size 4 " } + strncpy (sa[1].a2_3_4[1][2], s[11], 7); // { dg-warning "writing 7 bytes into a region of size 4 " } +} + +void nowarn_sa_cstidx_varsize (const char* const s[], unsigned n) +{ + strncpy (sa[0].a2_3_4[0][0], s[0], n); + strncpy (sa[0].a2_3_4[0][1], s[1], n); + strncpy (sa[0].a2_3_4[0][2], s[2], n); + + strncpy (sa[0].a2_3_4[1][0], s[3], n); + strncpy (sa[0].a2_3_4[1][1], s[4], n); + strncpy (sa[0].a2_3_4[1][2], s[5], n); + + strncpy (sa[1].a2_3_4[0][0], s[6], n); + strncpy (sa[1].a2_3_4[0][1], s[7], n); + strncpy (sa[1].a2_3_4[0][2], s[8], n); + + strncpy (sa[1].a2_3_4[1][0], s[9], n); + strncpy (sa[1].a2_3_4[1][1], s[10], n); + strncpy (sa[1].a2_3_4[1][2], s[11], n); +} + +void nowarn_sa_loop (const char* const s[], unsigned n) +{ + for (unsigned i0 = 0; i0 != 5; ++i0) + for (unsigned i1 = 0; i1 != 3; ++i1) + for (unsigned i2 = 0; i2 != 2; ++i2) + strncpy (sa[i0].a2_3_4[i1][i2], s[i2], n); +} + + +/* Verify that a note after the warning points to the accessed object + and mentions the starting offset of the access. Another alternative + might be for the offset to be the starting offset of the overflow. + As it is, it's not clear to which of the two the offset refers. */ + +void test_note (const char *s) +{ + extern void sink (void*); + + { + char a[1][1][2]; // { dg-message "destination object" "note" } + strncpy (a[0][0], s, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + sink (a); + } + + { + char a[1][1][2]; // { dg-message "at offset 2 into " "note" } + strncpy (a[0][1], s, 3); // { dg-warning "writing 3 bytes into a region of size 0 " } + sink (a); + } + + { + char a[1][2][2]; // { dg-message "destination object" "note" } + strncpy (a[0][0], s, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + sink (a); + } + + { + char a[1][2][2]; // { dg-message "at offset 2 into " "note" } + strncpy (a[0][1], s, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + sink (a); + } + + { + char a[1][2][2]; // { dg-message "at offset 4 into " "note" } + strncpy (a[1][0], s, 3); // { dg-warning "writing 3 bytes into a region of size 0 " } + sink (a); + } + + { + char a[2][1][2]; // { dg-message "at offset 2 into " "note" } + strncpy (a[0][1], s, 3); // { dg-warning "writing 3 bytes into a region of size 0 " } + sink (a); + } + + { + char a[2][1][2]; // { dg-message "at offset 2 into " "note" } + strncpy (a[1][0], s, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + sink (a); + } + + { + char a[2][2][3]; // { dg-message "at offset 9 into " "note" } + strncpy (a[1][1], s, 4); // { dg-warning "writing 4 bytes into a region of size 3 " } + sink (a); + } + + { + char a[2][3][3]; // { dg-message "at offset 12 into " "note" } + strncpy (a[1][1], s, 5); // { dg-warning "writing 5 bytes into a region of size 3 " } + sink (a); + } + + { + char a[2][3][3]; // { dg-message "at offset 12 into " "note" } + strncpy (a[1][1], s, 6); // { dg-warning "writing 6 bytes into a region of size 3 " } + sink (a); + } + + { + char a[2][3][3]; // { dg-message "at offset 15 into " "note" } + strncpy (a[1][2], s, 7); // { dg-warning "writing 7 bytes into a region of size 3 " } + sink (a); + } + +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-38.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-38.c new file mode 100644 index 0000000000..12bda2b31a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-38.c @@ -0,0 +1,94 @@ +/* Verify that non-constant offsets don't suppress warnings in cases + when the size of the access alone makes it invalid, regardless of + the offset value. + Also verify that writing into unknown objects through pointers + (or pointer members) doesn't trigger warnings. + { dg-do compile } + { dg-options "-O1 -Wall -Wno-array-bounds" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); +extern void* memset (void*, int, size_t); + + +struct Xp { char *p; } xp; +struct Xa { char *a[2]; } xa; + +void nowarn_copy_read_pointed_obj_plus_cst (void *d) +{ + int i = 0; + memcpy (d, xp.p + i, 9); + memcpy (d, xa.a[i], 9); +} + +void nowarn_copy_read_pointed_obj_plus_var (void *d, int i) +{ + memcpy (d, xp.p + i, 9); + memcpy (d, xa.a[i], 9); +} + + +void warn_copy_read_pointer_plus_cst (void *d) +{ + int i = 0; + memcpy (d, &xp.p + i, 9); // { dg-warning "reading 9 bytes from a region of size . " } +} + +void warn_copy_read_pointer_plus_var (void *d, int i) +{ + memcpy (d, &xp.p + i, 9); // { dg-warning "reading 9 bytes from a region of size . " } +} + + +void nowarn_copy_write_pointed_obj_plus_cst (const void *s) +{ + int i = 0; + memcpy (xp.p + i, s, 9); + memcpy (xa.a[i], s, 9); +} + +void nowarn_copy_write_pointed_obj_plus_var (const void *s, int i) +{ + memcpy (xp.p + i, s, 9); + memcpy (xa.a[i], s, 9); +} + + +void warn_copy_write_pointer_plus_cst (const void *s) +{ + int i = 0; + memcpy (&xp.p + i, s, 9); // { dg-warning "writing 9 bytes into a region of size . " } +} + +void warn_copy_write_pointer_plus_var (const void *s, int i) +{ + memcpy (&xp.p + i, s, 9); // { dg-warning "writing 9 bytes into a region of size . " } +} + + +void nowarn_set_pointed_obj_plus_cst (void) +{ + int i = 0; + memset (xp.p + i, 0, 9); + memset (xa.a[i], 0, 9); +} + +void nowarn_set_pointed_obj_plus_var (int i) +{ + memset (xp.p + i, 0, 9); + memset (xa.a[i], 0, 9); +} + + +void warn_set_pointer_plus_cst (void) +{ + int i = 0; + memset (&xp.p + i, 0, 9); // { dg-warning "writing 9 bytes into a region of size . " } +} + +void warn_set_pointer_plus_var (int i) +{ + memset (&xp.p + i, 0, 9); // { dg-warning "writing 9 bytes into a region of size . " } + memset (&xa.a[i], 0, 17); // { dg-warning "writing 17 bytes into a region of size \[0-9\]+ " } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-39.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-39.c new file mode 100644 index 0000000000..295a38de92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-39.c @@ -0,0 +1,119 @@ +/* PR middle-end/95667 - unintended warning for memset writing across multiple + members + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +extern void sink (void*); + +struct S1 { char a[3], b[5]; }; + +void warn_strcpy_s1 (void) +{ + struct S1 *p = __builtin_malloc (sizeof *p); + char s[] = "1234567"; + __builtin_strcpy (p->a, s); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); +} + +void nowarn_memset_s1 (void) +{ + struct S1 *p = __builtin_malloc (sizeof *p); + __builtin_memset (p->a, 0, 8); // { dg-bogus "\\\[-Wstringop-overflow" } + sink (p); +} + +struct S2 { char a[2], b[2][2], c[3]; }; + +void nowarn_memset_s2 (void) +{ + struct S2 *p = __builtin_malloc (sizeof *p); + + __builtin_memset (p->a, 0, sizeof *p); + sink (p); + + __builtin_memset (p->b, 0, 7); + sink (p); + + __builtin_memset (&p->b[0], 0, 7); + sink (p); + + __builtin_memset (&p->b[1], 0, 5); + sink (p); + + __builtin_memset (&p->b[0][0], 0, 7); + sink (p); + + __builtin_memset (&p->b[0][1], 0, 6); + sink (p); + + __builtin_memset (&p->b[1][0], 0, 5); + sink (p); + + __builtin_memset (&p->b[1][1], 0, 4); + sink (p); +} + +void warn_memset_s2 (void) +{ + const unsigned n = sizeof (struct S2); + struct S2 *p = __builtin_malloc (n); + + /* These should trigger -Wstringop-overflow rather than -Warray-bounds + but the main purpose of the test is to verify the absence of warnings + above so the exact warning for these overflwing calls isn't important + here. */ + + __builtin_memset (p->a, 0, n + 1); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + sink (p); + + __builtin_memset (p->b, 0, 8); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + sink (p); + + __builtin_memset (&p->b[0], 0, 8); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + sink (p); + + __builtin_memset (&p->b[0][0], 0, 8); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + sink (p); + + __builtin_memset (&p->b[1], 0, 6); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + sink (p); + + __builtin_memset (&p->b[0][1], 0, 7); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + sink (p); +} + +void nowarn_vl_struct (unsigned n) +{ + if (n < 3 || 5 < n) + n = 3; + + struct V { char a[3], b[n], c[7]; } v; + + __builtin_memset (v.a, 0, 15); + sink (&v); + + __builtin_memset (v.b, 0, 12); + sink (&v); + + __builtin_memset (v.c, 0, 7); + sink (&v); + + __builtin_memset (v.a, 0, 16); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + sink (&v); + + __builtin_memset (v.b, 0, 13); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } + sink (&v); + + /* The &V.C argument is represented as a variable offset from + the beginning of the allocated object and there's no good + way to figure out from its variable offset that it's base + is the C member: + s.1_12 = __builtin_alloca_with_align (prephitmp_24, 8); + _9 = s.1_12 + prephitmp_27; + __builtin_memset (_9, 0, 2); + */ + + __builtin_memset (v.c, 0, 8); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "pr?????" { xfail *-*-* } } + sink (&v); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-4.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-4.c new file mode 100644 index 0000000000..74596c4c99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-4.c @@ -0,0 +1,28 @@ +/* { dg-do compile } + { dg-options "-O2 -Wstringop-overflow" } */ + +extern char* strchr (const char*, int); +extern char* strcpy (char*, const char*); +extern void* malloc (__SIZE_TYPE__); +extern __SIZE_TYPE__ strlen (const char *); +struct define_item { + int len; + char value[1]; +}; + +struct define_item * foo(char *name) +{ + char * p; + char * value; + struct define_item * ptr; + + p = strchr (name, '='); + if (1 && p) { + value = p+1; + } else + value = "1"; + + ptr = malloc(sizeof(struct define_item) + strlen(value)); + strcpy(ptr->value, value); /* { dg-bogus "bytes into a region" } */ + return ptr; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-40.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-40.c new file mode 100644 index 0000000000..386c92dc7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-40.c @@ -0,0 +1,120 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + { dg-do compile } + { dg-options "-Wall" } */ + +typedef __INT16_TYPE__ int16_t; + +void fa2 (int16_t[2]); +void fxa2 (int16_t[2]) __attribute__ ((nonnull)); + +void fas2 (int16_t[static 2]); + +void fvla (unsigned n, int16_t[n]); + +void test_array_1_dim (void) +{ + int16_t a1[1]; + int16_t a2[2]; + int16_t i; + + fa2 (0); + fa2 (a2); + fa2 (a1); // { dg-warning "'fa2' accessing 4 bytes in a region of size 2 " } + fa2 (&i); // { dg-warning "'fa2' accessing 4 bytes in a region of size 2 " } + + fxa2 (0); // { dg-warning "\\\[-Wnonnull" } + fxa2 (a2); + fxa2 (a1); // { dg-warning "'fxa2' accessing 4 bytes in a region of size 2 " } + fxa2 (&i); // { dg-warning "'fxa2' accessing 4 bytes in a region of size 2 " } + + fas2 (0); // { dg-warning "\\\[-Wnonnull" } + fas2 (a2); + fas2 (a1); // { dg-warning "'fas2' accessing 4 bytes in a region of size 2 " } + fas2 (&i); // { dg-warning "'fas2' accessing 4 bytes in a region of size 2 " } + + fvla (1, 0); // { dg-warning "\\\[-Wnonnull" } + fvla (1, &i); + fvla (2, a2); + fvla (2, a1); // { dg-warning "'fvla' accessing 4 bytes in a region of size 2 " } + fvla (2, &i); // { dg-warning "'fvla' accessing 4 bytes in a region of size 2 " } +} + + +void fac2 (const int16_t[2]); +void fxac2 (const int16_t[2]) __attribute__ ((nonnull)); + +void facs2 (const int16_t[static 2]); + +void fvlac (unsigned n, const int16_t[n]); + +void test_const_array_1_dim (void) +{ + int16_t a1[1]; + int16_t a2[2]; + int16_t i; + + fac2 (0); + fac2 (a2); + fac2 (a1); // { dg-warning "'fac2' reading 4 bytes from a region of size 2 " } + fac2 (&i); // { dg-warning "'fac2' reading 4 bytes from a region of size 2 " } + + fxac2 (0); // { dg-warning "\\\[-Wnonnull" } + fxac2 (a2); + fxac2 (a1); // { dg-warning "'fxac2' reading 4 bytes from a region of size 2 " } + fxac2 (&i); // { dg-warning "'fxac2' reading 4 bytes from a region of size 2 " } + + facs2 (0); // { dg-warning "\\\[-Wnonnull" } + facs2 (a2); + facs2 (a1); // { dg-warning "'facs2' reading 4 bytes from a region of size 2 " } + facs2 (&i); // { dg-warning "'facs2' reading 4 bytes from a region of size 2 " } + + fvlac (1, 0); // { dg-warning "\\\[-Wnonnull" } + fvlac (1, &i); + fvlac (2, a2); + fvlac (2, a1); // { dg-warning "'fvlac' reading 4 bytes from a region of size 2 " } + fvlac (2, &i); // { dg-warning "'fvlac' reading 4 bytes from a region of size 2 " } +} + + +void fca3x5 (int16_t[3][5]); +void fcas5x7 (int16_t[static 5][7]); + +struct Snx5 { int16_t a3x5[3][5], a2x5[2][5], a1x5[1][5]; }; +struct Snx7 { int16_t a5x7[5][7], a4x7[4][7], a1x7[1][7]; }; +struct S0x7 { int x; int16_t a0x7[0][7]; }; + +void test_array_2_dim (struct Snx5 *px5, struct Snx7 *px7, struct S0x7 *p0x7) +{ + int16_t a0x5[0][5], a1x5[1][5], a2x5[2][5], a3x5[3][5], a4x5[4][5]; + + fca3x5 (a3x5); + fca3x5 (a4x5); + fca3x5 (a2x5); // { dg-warning "'fca3x5' accessing 30 bytes in a region of size 20" } + fca3x5 (a1x5); // { dg-warning "'fca3x5' accessing 30 bytes in a region of size 10" } + fca3x5 (a0x5); // { dg-warning "'fca3x5' accessing 30 bytes in a region of size 0" } + + fca3x5 (px5->a3x5); + fca3x5 (px5->a2x5); // { dg-warning "'fca3x5' accessing 30 bytes in a region of size 20" } + fca3x5 (px5->a1x5); // { dg-warning "'fca3x5' accessing 30 bytes in a region of size 10" "pr96346" { xfail *-*-* } } + + { + int16_t (*pa2x5)[5] = &a2x5[0]; + fca3x5 (pa2x5); // { dg-warning "'fca3x5' accessing 30 bytes in a region of size 10" } + ++pa2x5; + fca3x5 (pa2x5); // { dg-warning "'fca3x5' accessing 30 bytes " } + } + + int16_t a0x7[0][7], a1x7[1][7], a4x7[4][7], a5x7[5][7], a99x7[99][7]; + fcas5x7 (a99x7); + fcas5x7 (a5x7); + fcas5x7 (a4x7); // { dg-warning "'fcas5x7' accessing 70 bytes in a region of size 56" } + fcas5x7 (a1x7); // { dg-warning "'fcas5x7' accessing 70 bytes in a region of size 14" } + fcas5x7 (a0x7); // { dg-warning "'fcas5x7' accessing 70 bytes in a region of size 0" } + + fcas5x7 (px7->a5x7); + fcas5x7 (px7->a4x7); // { dg-warning "'fcas5x7' accessing 70 bytes in a region of size 56" } + fcas5x7 (px7->a1x7); // { dg-warning "'fcas5x7' accessing 70 bytes in a region of size 14" "pr96346" { xfail *-*-* } } + + fcas5x7 (p0x7->a0x7); // { dg-warning "'fcas5x7' accessing 70 bytes in a region of size 0" "pr96346" { xfail *-*-* } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-41.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-41.c new file mode 100644 index 0000000000..e255e67029 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-41.c @@ -0,0 +1,121 @@ +/* Verify that writes at excessive offsets into declared or allocated + objects of unknown size are diagnosed. + { dg-do compile } + { dg-options "-O2" } */ + +#define DIFF_MAX __PTRDIFF_MAX__ + +typedef __SIZE_TYPE__ size_t; + +void* malloc (size_t); +void* memcpy (void*, const void*, size_t); +void* memset (void*, int, size_t); + +void sink (void*); + + +void char_array_cst_off_cst_size (void) +{ + extern char caxcc[]; // { dg-message "at offset \\d+ into destination object 'caxcc'" } + + char *p = caxcc; + size_t idx = DIFF_MAX - 3; + + memset (p + idx, 0, 3); + sink (p); + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 2" } + sink (p); + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 1" } + sink (p); + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 0" } + sink (p); +} + + +void char_array_var_off_cst_size (size_t idx) +{ + /* The offset is a range with a very large lower bound and an upper + bound of DIFF_MAX. There's not point in also mentioning the latter + (it wouldn't make the note any more meaningful) so verify it only + mentions the lower bound. */ + extern char caxvc[]; // { dg-message "at offset \\d+ into destination object 'caxvc'" "note" } + + char *p = caxvc; + + if (idx < DIFF_MAX - 3) + idx = DIFF_MAX - 3; + + memset (p + idx, 0, 3); + sink (p); + + memset (p + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" } + sink (p); +} + + +void char_array_var_off_var_size (size_t idx, size_t n) +{ + extern char caxvv[]; // { dg-message "at offset \\d+ into destination object 'caxvv'" "note" } + + char *p = caxvv; + + if (idx < DIFF_MAX - 3) + idx = DIFF_MAX - 3; + + if (n < 3 || 7 < n) + n = 3; + + memset (p + idx, 0, n); + sink (p); + + ++n; + memset (p + idx, 0, n); // { dg-warning "writing between 4 and 8 bytes into a region of size 3" } + sink (p); +} + + +void alloc_array_var_off_cst_size (size_t n, size_t idx) +{ + char *p = malloc (n); // { dg-message "at offset \\d+ into destination object" "note" } + + if (idx < DIFF_MAX - 3) + idx = DIFF_MAX - 3; + + memset (p + idx, 0, 3); + sink (p); + + memset (p + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" } + sink (p); +} + + +void int_array_cst_off_cst_size (void) +{ + extern int iaxc[]; // { dg-message "at offset \[1-9\]\[0-9\]+ into destination object 'iaxc'" } + + int *p = iaxc; + size_t idx = DIFF_MAX / sizeof *iaxc; + + memset (p + idx, 0, 3); + sink (p); + + memset (p + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" } + sink (p); +} + + +void* nowarn_anti_range_1 (char *p, char *q) +{ + size_t n = q - p; + if (!n) return 0; + + char *d = __builtin_malloc (n + 1); + memcpy (d, p, n + 1); // { dg-bogus "-Wstringop-overflow" } + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-42.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-42.c new file mode 100644 index 0000000000..8527eea8e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-42.c @@ -0,0 +1,62 @@ +/* Verify -Wstringop-overflow a with destination pointer pointing either + before the beginning or past the end of an object. + { dg-do compile } + { dg-options "-O -Wall -Wno-array-bounds -Wno-restrict" } */ + +typedef __SIZE_TYPE__ size_t; + +char* strcpy (char *, const char *); + + +extern char a[1]; + +volatile char *d; + +void cpy_si_1_max (int i, const char *s) +{ + if (i < 1) i = 1; + d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" } + d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" } +} + +void cpy_ui_1_max (unsigned i, const char *s) +{ + if (i < 1) i = 1; + d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" } + d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { xfail { ! lp64 } } } +} + +void cpy_sl_1_max (long i, const char *s) +{ + if (i < 1) i = 1; + d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } } + d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } } +} + +void cpy_ul_1_max (unsigned long i, const char *s) +{ + if (i < 1) i = 1; + + d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } } + + /* Because of integer wraparound the offset's range is [1, 0] so + the overflow isn't diagnosed (yet). */ + d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { xfail *-*-* } } +} + + +void cpy_si_min_m1 (int i, const char *s) +{ + if (i > -1) i = -1; + d = strcpy (a + i - 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" } + d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" } + d = strcpy (a + i + 2, s); +} + +void cpy_sl_min_m1 (long i, const char *s) +{ + if (i > -1) i = -1; + d = strcpy (a + i - 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } } + d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } } + d = strcpy (a + i + 2, s); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-43.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-43.c new file mode 100644 index 0000000000..91006618fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-43.c @@ -0,0 +1,180 @@ +/* PR 96903 - bogus warning on memcpy at negative offset from array end + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ +#define INT_MIN -(INT_MAX - 1) +#define UINT_MAX (2U * INT_MAX + 1) + +typedef __SIZE_TYPE__ size_t; + +void* memset (void *, int, size_t); + +void sink (void*, ...); + +extern char a11[11]; +struct S { char a11[11], b; }; +extern struct S sa11; + +#define T2(dst, off1, off2, n) do { \ + char *_p0 = dst; \ + char *_p1 = _p0 + (off1); \ + char *_p2 = _p1 + (off2); \ + memset (_p2, 0, n); \ + sink (dst, _p0, _p1, _p2); \ + } while (0); + +#define T1(dst, off, n) T2 (dst, off, 0, n) + + +void nowarn_memset_array_cst (void) +{ + char *p = &a11[11]; + + T1 (p, -11, 11); + T1 (p, -10, 10); + T1 (p, -9, 9); + T1 (p, -8, 8); + T1 (p, -3, 3); + T1 (p, -2, 2); + T1 (p, -1, 1); + T1 (p, 0, 0); + + T2 (p, -6, -5, 11); + T2 (p, -6, -4, 10); + T2 (p, -6, -3, 9); + T2 (p, -6, -2, 8); + T2 (p, -6, -1, 7); + T2 (p, -5, -6, 11); + T2 (p, -5, -5, 10); +} + +void nowarn_memset_array_rng_int (void) +{ + char *p = &a11[11]; + + int i11 = SR (11, INT_MAX); + int i10 = SR (10, INT_MAX); + int i9 = SR ( 9, INT_MAX); + int i3 = SR ( 3, INT_MAX); + int i2 = SR ( 2, INT_MAX); + int i1 = SR ( 1, INT_MAX); + int i0 = SR ( 0, INT_MAX); + + int m11 = SR (INT_MIN, -11); + int m10 = SR (INT_MIN, -10); + int m9 = SR (INT_MIN, -9); + int m3 = SR (INT_MIN, -3); + int m2 = SR (INT_MIN, -2); + int m1 = SR (INT_MIN, -1); + int m0 = SR (INT_MIN, -0); + + T1 (p, m11, i11); + T1 (p, m10, i10); + T1 (p, m9, i9); + T1 (p, m3, i3); + T1 (p, m2, i2); + T1 (p, m1, i1); + T1 (p, m0, i0); + + T1 (p, m11, i11); + T1 (p, m10, i10); + T1 (p, m9, i9); + T1 (p, m3, i3); + T1 (p, m2, i2); + T1 (p, m1, i1); + T1 (p, m0, i0); +} + + +void nowarn_memset_array_rng (void) +{ + char *p = &a11[11]; + + T2 (p, SR (-11, -10), SR ( -2, -1), UR (11, 12)); + T2 (p, SR (-10, -9), SR ( -1, 0), UR (11, 13)); + T2 (p, SR ( -9, -8), SR ( -2, -1), UR (11, 14)); + T2 (p, SR ( -8, -7), SR ( -3, -2), UR (11, 15)); + T2 (p, SR ( -7, -6), SR ( -4, -3), UR (11, 16)); + T2 (p, SR ( -6, -5), SR ( -5, -4), UR (11, 17)); + T2 (p, SR ( -5, -4), SR ( -6, -5), UR (11, 18)); + T2 (p, SR ( -4, -3), SR ( -7, -6), UR (11, 19)); + T2 (p, SR ( -3, -2), SR ( -8, -7), UR (11, INT_MAX)); + T2 (p, SR ( -2, -1), SR ( -9, -8), UR (11, UINT_MAX)); + T2 (p, SR ( -1, 0), SR (-10, -9), UR (11, DIFF_MAX)); + T2 (p, SR ( 0, 1), SR (-11, -10), UR (11, SIZE_MAX)); + + T2 (p, SR (DIFF_MIN, -10), SR (DIFF_MIN, -1), UR (10, 12)); + + T2 (p, SR (-11, -10), SR ( -3, -1), UR (10, 12)) + T2 (p, SR (-11, -10), SR ( -3, -1), UR (10, 12)) +} + + +void warn_memset_array_rng (void) +{ + char *p = &a11[11]; + size_t n11_12 = UR (11, 12); + size_t n10_12 = UR (10, 12); + + T2 (p, SR (-11, -10), SR ( -3, -2), n11_12); // { dg-warning "writing between 11 and 12 bytes into a region of size 0" } + T2 (p, SR (-11, -10), SR ( -3, -2), n10_12); // { dg-warning "writing between 10 and 12 bytes into a region of size 0" } +} + + +void nowarn_memset_anti_range (void) +{ + size_t n11 = UR (11, SIZE_MAX); + + char *p = &a11[11]; + + T1 (p, (int)SAR (INT_MIN, -12), n11); + T1 (p, (int)SAR ( -13, -13), n11); + T1 (p, (int)SAR ( -13, -12), n11); + T1 (p, (int)SAR ( -10, 1), n11); + T1 (p, (int)SAR ( -10, 11), n11); + T1 (p, (int)SAR ( -10, INT_MAX), n11); + T1 (p, (int)SAR ( -1, -1), n11); + T1 (p, (int)SAR ( -1, 0), n11); + T1 (p, (int)SAR ( -1, 11), n11); + T1 (p, (int)SAR ( -1, INT_MAX), n11); + + T1 (p, SAR (DIFF_MIN, -12), n11); + T1 (p, SAR ( -13, -13), n11); + T1 (p, SAR ( -13, -12), n11); + T1 (p, SAR ( -10, 1), n11); // { dg-bogus "-Wstringop-overflow" } + T1 (p, SAR ( -10, 11), n11); // { dg-bogus "-Wstringop-overflow" } + T1 (p, SAR ( -10, DIFF_MAX), n11); + T1 (p, SAR ( -1, -1), n11); // { dg-bogus "-Wstringop-overflow" } + T1 (p, SAR ( -1, 0), n11); // { dg-bogus "-Wstringop-overflow" } + T1 (p, SAR ( -1, 11), n11); // { dg-bogus "-Wstringop-overflow" } + T1 (p, SAR ( -1, DIFF_MAX), n11); +} + +void warn_memset_reversed_range (void) +{ + size_t n11 = UR (11, SIZE_MAX); + + char *p = &a11[11]; + + /* Since the offset is excessive, either starting before &a11[0] + ot just past &a[11], the region size in the warning should + probably be zero, but accept other sizes too. + + The problem isn't detected anymore because the offset is in + the anti-range ~[INT_MIN, -11] which isn't handled. */ + T1 (p, SAR (INT_MIN, -11), n11); // { dg-warning "writing 11 or more bytes into a region of size \\d+" "" { xfail *-*-* } } + + /* The following are represented as ordinary ranges with reversed bounds + and those are handled. */ + T1 (p, SAR (INT_MIN, 11), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" } + T1 (p, SAR (INT_MIN, 1), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" } + T1 (p, SAR (INT_MIN, 0), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" } + /* Also represented as a true anti-range. */ + T1 (p, SAR ( -12, -11), n11); // { dg-warning "writing 11 or more bytes into a region of size \\d+" "" { xfail *-*-* } } + T1 (p, SAR ( -12, -1), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" } + T1 (p, SAR ( -11, 0), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" } + T1 (p, SAR ( -11, 11), n11); // { dg-warning "writing 11 or more bytes into a region of size 0" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-44.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-44.c new file mode 100644 index 0000000000..9e292a9b7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-44.c @@ -0,0 +1,129 @@ +/* PR middle-end/97175 - ICE on an excessive strncpy bound + { dg-do compile } + { dg-options "-O -Wall" } */ + +int n; + +char *d; + +void sink (void*); + +/* Exercise calls with a destination of unknown size. */ + +void f0 (const void *s) +{ + if (n > 0) return; + __builtin_memcpy (d, s, n); // eliminated +} + +void f1 (const void *s) +{ + if (n > 0) return; + __builtin_memmove (d, s, n); // eliminated +} + +void f2 (void) +{ + if (n > 0) return; + __builtin_memset (d, 0, n); // eliminated +} + +void f3 (const char *s) +{ + if (n > 0) return; + __builtin_strncpy (d, s, n); // can be eliminated but isn't +} + +void f4 (const char *s) +{ + if (n > 0) return; + *d = 0; + __builtin_strncat (d, s, n); // can be eliminated but isn't +} + + +/* Exercise the same calls but with a declared destination object. */ + +void g0 (const void *s) +{ + if (n > 0) return; + char a[1]; + __builtin_memcpy (a, s, n); // eliminated + sink (a); +} + +void g1 (const void *s) +{ + if (n > 0) return; + char a[1]; + __builtin_memmove (a, s, n); // eliminated + sink (a); +} + +void g2 (void) +{ + if (n > 0) return; + char a[1]; + __builtin_memset (a, 0, n); // eliminated + sink (a); +} + +void g3 (const char *s) +{ + if (n > 0) return; + char a[1]; + __builtin_strncpy (a, s, n); // can be eliminated but isn't + sink (a); +} + +void g4 (const char *s) +{ + if (n > 0) return; + char a[1]; + *a = 0; + __builtin_strncat (a, s, n); // can be eliminated but isn't + sink (a); +} + + +void h0 (const void *s) +{ + if (n > 0) return; + d = __builtin_malloc (1); + __builtin_memcpy (d, s, n); // eliminated +} + +void h1 (const void *s) +{ + if (n > 0) return; + d = __builtin_malloc (1); + __builtin_memmove (d, s, n); // eliminated +} + +void h2 (void) +{ + if (n > 0) return; + d = __builtin_malloc (1); + __builtin_memset (d, 0, n); // eliminated +} + +void h3 (const char *s) +{ + if (n > 0) return; + d = __builtin_malloc (1); + __builtin_strncpy (d, s, n); // can be eliminated but isn't +} + +void h4 (const char *s) +{ + if (n > 0) return; + d = __builtin_malloc (1); + *d = 0; + __builtin_strncat (d, s, n); // can be eliminated but isn't +} + +/* The calls above that aren't eliminated trigger + warning: specified size between INT_MAX and SIZE_MAX exceed maximum + object size PTRDIFF_MAX + { dg-prune-output "-Wstringop-overflow" } + { dg-prune-output "-Wstringop-overread" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-45.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-45.c new file mode 100644 index 0000000000..112d79a5ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-45.c @@ -0,0 +1,255 @@ +/* PR middle-end/97023 - missing warning on buffer overflow in chained mempcpy + Verify that out of bounds writes by built-ins to objects through pointers + returned by other built-ins are diagnosed. + { dg-do compile } + { dg-options "-O2" } */ + +#include "range.h" + +void* malloc (size_t); +void* memcpy (void*, const void*, size_t); +void* memmove (void*, const void*, size_t); +void* mempcpy (void*, const void*, size_t); + +void sink (void*, ...); + + +void nowarn_memcpy (const void *s) +{ + extern char cpy_a4[4]; + unsigned n = sizeof cpy_a4; + + void *p = cpy_a4; + p = memcpy (p, s, n); + sink (p); + memcpy (p, s, n); + sink (p); + + p = cpy_a4 + 1; + p = memcpy (p, s, n - 1); + sink (p); + memcpy (p, s, n - 1); + sink (p); + + p = cpy_a4 + 2; + p = memcpy (p, s, n - 2); + sink (p); + memcpy (p, s, n - 2); + sink (p); + + p = cpy_a4 + 3; + p = memcpy (p, s, n - 3); + sink (p); + memcpy (p, s, n - 3); + sink (p); + + p = cpy_a4 + 4; + p = memcpy (p, s, n - 4); + sink (p); + memcpy (p, s, n - 4); + sink (p); +} + + +void nowarn_memcpy_chain (const void *s) +{ + extern char cpy_a8[8]; + + char *p = cpy_a8; + + p = memcpy (p + 1, s, 7); + sink (p); + + p = memcpy (p + 2 , s, 5); + sink (p); + + p = memcpy (p + 3 , s, 2); + sink (p); + + p = memcpy (p + 1 , s, 1); + sink (p); + + p = memcpy (p - 7 , s, 8); + sink (p); + + memcpy (p + 1, s, 7); +} + + +void warn_memcpy (const void *s) +{ + extern char cpy_a5[5]; // { dg-message "destination object 'cpy_a5'" "note" } + + unsigned n = sizeof cpy_a5; + void *p = cpy_a5; + + p = memcpy (p, s, n); + sink (p); + memcpy (p, s, n + 1); // { dg-warning "writing 6 bytes into a region of size 5" } + sink (p); + + p = cpy_a5; + p = memcpy (p, s, n); + sink (p); + memcpy (p, s, n + 1); // { dg-warning "writing 6 bytes into a region of size 5" } + sink (p); + + p = cpy_a5 + 1; + p = memcpy (p, s, n - 1); + sink (p); + memcpy (p, s, n); // { dg-warning "writing 5 bytes into a region of size 4" } + sink (p); +} + + +void warn_memcpy_chain (const void *s) +{ + extern char cpy_a8[8]; // { dg-message "destination object 'cpy_a8'" "note" } + + char *p = cpy_a8; + + p = memcpy (p, s, 9); // { dg-warning "writing 9 bytes into a region of size 8" } + sink (p); + + p = memcpy (p + 2, s, 7); // { dg-warning "writing 7 bytes into a region of size 6" } + sink (p); + + p = memcpy (p + 3, s, 5); // { dg-warning "writing 5 bytes into a region of size 3" } + sink (p); + + p = memcpy (p + 3, s, 3); // { dg-warning "writing 3 bytes into a region of size 0" } + sink (p); +} + + +void nowarn_mempcpy (const void *s) +{ + extern char a4[4]; + unsigned n = sizeof a4; + + char *p = mempcpy (a4, s, n); + sink (p); + mempcpy (p - 4, s, n); + sink (p); + + p = mempcpy (a4 + 1, s, n - 1); + sink (p); + mempcpy (p - 4, s, n); + sink (p); + + p = mempcpy (a4 + 2, s, n - 2); + sink (p); + mempcpy (p - 4, s, n); + sink (p); + + p = mempcpy (a4 + 3, s, n - 3); + sink (p); + mempcpy (p - 4, s, n); + sink (p); + + p = mempcpy (a4 + 4, s, n - 4); + sink (p); + mempcpy (p - 4, s, n); + sink (p); +} + + +void nowarn_mempcpy_chain (const void *s) +{ + extern char pcpy_a8[8]; + + char *p = pcpy_a8; + + p = mempcpy (p + 1, s, 7); + sink (p); + + p = mempcpy (p - 7 , s, 7); + sink (p); + + p = mempcpy (p - 5 , s, 5); + sink (p); + + p = mempcpy (p - 3 , s, 3); + sink (p); + + p = mempcpy (p - 2 , s, 2); + sink (p); + + mempcpy (p - 1, s, 1); + sink (p); + + mempcpy (p - 8, s, 8); +} + + +void warn_mempcpy (const void *s) +{ + extern char pcpy_a5[5]; // { dg-message "destination object 'pcpy_a5'" "note" } + + char *p = pcpy_a5; + + p = mempcpy (p, s, 5); + sink (p); + mempcpy (p - 5, s, 6); // { dg-warning "writing 6 bytes into a region of size 5 " } + sink (p); + + p = pcpy_a5; + p = mempcpy (p, s, 3); + sink (p); + mempcpy (p, s, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + sink (p); + + p = pcpy_a5 + 1; + p = mempcpy (p, s, 3); + sink (p); + mempcpy (p - 1, s, 5); // { dg-warning "writing 5 bytes into a region of size 2 " } + sink (p); +} + + +void warn_mempcpy_chain_3 (const void *s) +{ + char *p = malloc (5); // { dg-message "at offset \\\[3, 5] into destination object of size 5" "note" } + p = mempcpy (p, s, UR (1, 2)); + p = mempcpy (p, s, UR (2, 3)); + p = mempcpy (p, s, UR (3, 4)); // { dg-warning "writing between 3 and 4 bytes into a region of size 2 " } + + sink (p); +} + +void warn_mempcpy_offrng_chain_3 (const void *s) +{ + char *p = malloc (11); // { dg-message "at offset \\\[9, 11] into destination object of size 11 " "note" } + size_t r1_2 = UR (1, 2); + size_t r2_3 = r1_2 + 1; + size_t r3_4 = r2_3 + 1; + + p = mempcpy (p + r1_2, s, r1_2); + p = mempcpy (p + r2_3, s, r2_3); + p = mempcpy (p + r3_4, s, r3_4); // { dg-warning "writing between 3 and 4 bytes into a region of size 2 " } + + sink (p); +} + +void warn_mempcpy_chain_4 (const void *s) +{ + char *p = malloc (9); // { dg-message "at offset \\\[6, 9] into destination object of size 9 " "note" } + p = mempcpy (p, s, UR (1, 2)); + p = mempcpy (p, s, UR (2, 3)); + p = mempcpy (p, s, UR (3, 4)); + p = mempcpy (p, s, UR (4, 5)); // { dg-warning "writing between 4 and 5 bytes into a region of size 3 " } + + sink (p); +} + +void warn_mempcpy_chain_5 (const void *s) +{ + char *p = malloc (14); // { dg-message "at offset \\\[10, 14] into destination object of size 14 " "note" } + p = mempcpy (p, s, UR (1, 2)); + p = mempcpy (p, s, UR (2, 3)); + p = mempcpy (p, s, UR (3, 4)); + p = mempcpy (p, s, UR (4, 5)); + p = mempcpy (p, s, UR (5, 6)); // { dg-warning "writing between 5 and 6 bytes into a region of size 4 " } + + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-46.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-46.c new file mode 100644 index 0000000000..042c9676c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-46.c @@ -0,0 +1,96 @@ +/* PR middle-end/97023 - missing warning on buffer overflow in chained mempcpy + Verify that out of bounds writes by built-ins to objects through pointers + returned by memchr() are diagnosed. + { dg-do compile } + { dg-options "-O2" } */ + +#include "range.h" + +void* malloc (size_t); +void* memchr (void*, int, size_t); +void* memset (void*, int, size_t); + +void sink (void*, ...); + +void nowarn_memchr_cst_memset_cst (const void *s) +{ + char *p = malloc (4); + sink (p); + + p = memchr (p, '1', 4); + memset (p, 0, 4); +} + +void nowarn_memchr_uint_memset_cst (const void *s, unsigned n) +{ + char *p = malloc (4); + sink (p); + + p = memchr (p, '1', n); + memset (p, 0, 4); +} + +void nowarn_memchr_sz_memset_cst (const void *s, size_t n) +{ + char *p = malloc (4); + sink (p); + + p = memchr (p, '1', n); + memset (p, 0, 4); +} + +void nowarn_memchr_anti_range_memset_cst (const void *s, size_t n) +{ + char *p = malloc (4); + sink (p); + + if (n == 0) + n = 1; + + p = memchr (p, '1', n); + memset (p, 0, 4); +} + +void warn_memchr_cst_memset_cst (const void *s) +{ + char *p = malloc (4); // { dg-message "destination object of size 4 " "note" } + sink (p); + + p = memchr (p, '1', 4); + memset (p, 0, 5); // { dg-warning "writing 5 bytes into a region of size 4 " } +} + +void warn_memchr_var_memset_cst (const void *s, unsigned n) +{ + char *p = malloc (4); // { dg-message "destination object of size 4 " "note" } + sink (p); + + p = memchr (p, '1', n); + memset (p, 0, 5); // { dg-warning "writing 5 bytes into a region of size 4 " } +} + +void warn_memchr_var_memset_range (const void *s, unsigned n) +{ + /* The offsets in the first two notes are bounded by the size of + the allocated object. The real upper bound of the offset in + the last note includes the upper bound f the offset of the pointer + returned from the previous memchr() call, but it ends up getting + constrained to the bounds of the allocated object so it's the same + as in the first two notes. The exact value probably isn't too + important. */ + char *p0 = malloc (UR (5, 7)); + // { dg-message "at offset \\\[\[01\], 6] into destination object of size \\\[5, 7]" "note 2" { target *-*-* } .-1 } + // { dg-message "at offset \\\[2, 7] into destination object of size \\\[5, 7]" "note 3" { target *-*-* } .-2 } + + sink (p0); + char *p1 = memchr (p0, '1', n); + memset (p1, 0, UR (8, 9)); // { dg-warning "writing between 8 and 9 bytes into a region of size 7 " } + + sink (p0); + p1 = memchr (p0 + 1, '2', n); + memset (p1, 0, UR (7, 9)); // { dg-warning "writing between 7 and 9 bytes into a region of size 6 " } + + sink (p0); + char *p2 = memchr (p1 + 1, '3', n); + memset (p2, 0, UR (6, 9)); // { dg-warning "writing between 6 and 9 bytes into a region of size 5 " } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-47.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-47.c new file mode 100644 index 0000000000..968f6ee4ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-47.c @@ -0,0 +1,79 @@ +/* Verify that storing a bigger vector into smaller space is diagnosed. + { dg-do compile } + { dg-options "-O2" } */ + +typedef __INT16_TYPE__ int16_t; +typedef __attribute__ ((__vector_size__ (32))) char C32; + +typedef __attribute__ ((__vector_size__ (64))) int16_t I16_64; + +void sink (void*); + + +void nowarn_c32 (char c) +{ + extern char nowarn_a32[32]; + + void *p = nowarn_a32; + *(C32*)p = (C32){ c }; + sink (p); + + char a32[32]; + p = a32; + *(C32*)p = (C32){ c }; + sink (p); +} + +/* The tests below failed as a result of the hack for PR 96963. However, + with -Wall, the invalid stores were diagnosed by -Warray-bounds which + runs before vectorization and so doesn't need the hack. Now that + -Warray-bounds has changed to use compute_objsize() the tests pass. */ + +void warn_c32 (char c) +{ + extern char warn_a32[32]; // { dg-message "at offset (32|1) into destination object 'warn_a32' of size 32" "pr97027" } + + void *p = warn_a32 + 1; + *(C32*)p = (C32){ c }; // { dg-warning "writing (1 byte|32 bytes) into a region of size (0|31)" "pr97027" } + + /* Verify a local variable too. */ + char a32[32]; + p = a32 + 1; + *(C32*)p = (C32){ c }; // { dg-warning "writing (1 byte|32 bytes) into a region of size (0|31)" "pr97027" } + sink (p); +} + + +void nowarn_i16_64 (int16_t i) +{ + extern char nowarn_a64[64]; + + void *p = nowarn_a64; + I16_64 *q = (I16_64*)p; + *q = (I16_64){ i }; + + char a64[64]; + q = (I16_64*)a64; + *q = (I16_64){ i }; + sink (q); +} + +void warn_i16_64 (int16_t i) +{ +/* The IL below that's visible to the warning changes from one target to + another. On some like aarch64 it's a single vector store, on others + like x86_64 it's a series of BIT_FIELD_REFs. The overflow by + the former is detected but the latter is not yet. */ + + extern char warn_a64[64]; // { dg-message "at offset (1|128) into destination object 'warn_a64' of size (63|64)" "pr97027 note" { xfail { ! aarch64-*-* } } } + + void *p = warn_a64 + 1; + I16_64 *q = (I16_64*)p; + *q = (I16_64){ i }; // { dg-warning "writing (1 byte|64 bytes) into a region of size (0|63)" "pr97027" { xfail { ! aarch64-*-* } } } + + char a64[64]; + p = a64 + 1; + q = (I16_64*)p; + *q = (I16_64){ i }; // { dg-warning "writing (1 byte|64 bytes) into a region of size (0|63)" "pr97027" { xfail { ! aarch64-*-* } } } + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-49.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-49.c new file mode 100644 index 0000000000..84b6c94fa7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-49.c @@ -0,0 +1,146 @@ +/* Verify the handling of anti-ranges/multi-ranges by allocation functions + and subsequent accesses. + { dg-do compile } + { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; + +void* malloc (size_t); +void bzero (void*, size_t); +void* memset (void*, int, size_t); + + +/* Exercise size_t (via malloc and memset) and unsigned/signed int. */ + +__attribute__ ((alloc_size (1))) void* +alloc_int (int); + +__attribute__ ((access (write_only, 1, 2))) void +access_int (void*, int); + +__attribute__ ((alloc_size (1))) void* +alloc_uint (unsigned); + +__attribute__ ((access (write_only, 1, 2))) void +access_uint (void*, unsigned); + + +void* nowarn_malloc_memset_same_anti_range (size_t n) +{ + /* Set N to the anti-range ~[3, 3]. */ + if (n == 3) + n = 4; + void *p = malloc (n); + + /* Verify there is no warning for an access to N bytes at P. + This means the warning has to assume the value of N in the call + to alloc() is in the larger subrange [4, UINT_MAX], while in + the call to access() in [0, 3]. */ + return memset (p, 0, n); +} + +/* Same as above but with two valid ranges. */ + +void* nowarn_malloc_memset_anti_range (size_t n1, size_t n2) +{ + /* Set N1 to the anti-range ~[3, 3]. */ + if (n1 == 3) + n1 = 4; + void *p = malloc (n1); + + /* Set N2 to the anti-range ~[7, 7]. */ + if (n2 == 7) + n2 = 8; + + return memset (p, 0, n2); +} + + +void nowarn_alloc_access_same_anti_range_int (int n) +{ + /* Set N to the anti-range ~[3, 3]. */ + if (n == 3) + n = 4; + void *p = alloc_int (n); + + /* Verify there is no warning for an access to N bytes at P. + This means the warning has to assume the value of N in the call + to alloc() is in the larger subrange [4, UINT_MAX], while in + the call to access() in [0, 3]. */ + access_int (p, n); +} + +/* Same as above but with two valid ranges. */ + +void nowarn_alloc_access_anti_range_int (int n1, int n2) +{ + /* Set N1 to the anti-range ~[3, 3]. */ + if (n1 == 3) + n1 = 4; + void *p = alloc_int (n1); + + /* Set N2 to the anti-range ~[7, 7]. */ + if (n2 == 7) + n2 = 8; + + access_int (p, n2); +} + + +void nowarn_alloc_access_same_anti_range_uint (unsigned n) +{ + /* Set N to the anti-range ~[3, 3]. */ + if (n == 3) + n = 4; + void *p = alloc_uint (n); + + /* Verify there is no warning for an access to N bytes at P. + This means the warning has to assume the value of N in the call + to alloc() is in the larger subrange [4, UINT_MAX], while in + the call to access() in [0, 3]. */ + access_uint (p, n); +} + +/* Same as above but with two valid ranges. */ + +void nowarn_alloc_access_anti_range_uint (unsigned n1, unsigned n2) +{ + /* Set N1 to the anti-range ~[3, 3]. */ + if (n1 == 3) + n1 = 4; + void *p = alloc_uint (n1); + + /* Set N2 to the anti-range ~[7, 7]. */ + if (n2 == 7) + n2 = 8; + + access_uint (p, n2); +} + + +void* nowarn_malloc_anti_range_memset_range (size_t n1, size_t n2) +{ + /* Set N1 to the anti-range ~[3, 3]. */ + if (n1 == 3) + n1 = 4; + void *p = malloc (n1); + + /* Set N2 to the range [5, MAX]. */ + if (n2 < 5) + n2 = 5; + return memset (p, 0, n2); +} + +void* nowarn_malloc_range_bzero_anti_range (size_t n1, size_t n2) +{ + /* Set N1 to the anti-range ~[3, 3]. */ + if (n1 > 4) + n1 = 4; + void *p = malloc (n1); + + /* Set N2 to the range [5, MAX]. */ + if (n2 <= 3 || 5 <= n2) + n2 = 4; + bzero (p, n2); + return p; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-5.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-5.c new file mode 100644 index 0000000000..4abce01b5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-5.c @@ -0,0 +1,58 @@ +/* PR tree-optimization/85259 - Missing -Wstringop-overflow= since r256683 + { dg-do compile } + { dg-options "-O2 -Wstringop-overflow" } */ + +extern char* strcpy (char*, const char*); +extern char* strcat (char*, const char*); + +char a1[1]; +char a2[2]; +char a3[3]; +char a4[4]; +char a5[5]; +char a6[6]; +char a7[7]; +char a8[8]; + +/* Verify that at least one instance of -Wstringop-overflow is issued + for each pair of strcpy/strcat calls. */ + +void test_strcpy_strcat_1 (void) +{ + strcpy (a1, "1"), strcat (a1, "2"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_2 (void) +{ + strcpy (a2, "12"), strcat (a2, "3"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_3 (void) +{ + strcpy (a3, "123"), strcat (a3, "4"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_4 (void) +{ + strcpy (a4, "1234"), strcat (a4, "5"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_5 (void) +{ + strcpy (a5, "12345"), strcat (a5, "6"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_6 (void) +{ + strcpy (a6, "123456"), strcat (a6, "7"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_7 (void) +{ + strcpy (a7, "1234567"), strcat (a7, "8"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_8 (void) +{ + strcpy (a8, "12345678"), strcat (a8, "9"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-50.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-50.c new file mode 100644 index 0000000000..7df58e5209 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-50.c @@ -0,0 +1,125 @@ +/* Verify that writes at excessive offsets into objects of unknown size + pointed to by function arguments are diagnosed. + { dg-do compile } + { dg-options "-O2" } */ + +#define DIFF_MAX __PTRDIFF_MAX__ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +void* memset (void*, int, size_t); + +void sink (void*); + +char* fcall (void); + +void char_ptr_cst_off_cst_size (char *p) + // { dg-message "at offset \[1-9\]\[0-9\]+ into destination object 'p'" "note" { target *-*-* } .-1 } +{ + size_t idx = DIFF_MAX - 3; + + memset (p + idx, 0, 3); + sink (p); + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 2" } + sink (p); + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 1" } + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 0" } +} + + +void char_ptr_var_difoff_cst_size (ptrdiff_t idx) +{ + char *p = fcall (); + /* The offset is a range with a very large lower bound and an upper + bound of DIFF_MAX. There's not point in also mentioning the latter + (it wouldn't make the note any more meaningful) so verify it only + mentions the lower bound. + { dg-message "at offset \\d+ into destination object of size \\\[0, \\d+] (allocated|returned) by 'fcall'" "note" { target *-*-* } .-5 } */ + + if (idx < DIFF_MAX - 3) + idx = DIFF_MAX - 3; + + memset (p + idx, 0, 3); + sink (p); + + memset (p + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" } +} + + +void char_ptr_var_szoff_cst_size (size_t idx) +{ + extern char* gptr; + // { dg-message "at offset \\d+ into destination object 'gptr'" "note" { target *-*-* } .-1 } + + char *p = gptr; + + if (idx < DIFF_MAX - 3) + idx = DIFF_MAX - 3; + + memset (p + idx, 0, 3); + sink (p); + + memset (p + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" "" { xfail *-*-* } } + + if (idx > DIFF_MAX) + idx = DIFF_MAX; + + memset (p + idx, 0, 7); // { dg-warning "writing 7 bytes into a region of size 3" } +} + + +void char_ptr_var_difoff_var_size (char *p, ptrdiff_t idx, size_t n) + // { dg-message "at offset \\d+ into destination object 'p'" "note" { target *-*-* } .-1 } +{ + if (idx < DIFF_MAX - 3) + idx = DIFF_MAX - 3; + + if (n < 3 || 7 < n) + n = 3; + + memset (p + idx, 0, n); + sink (p); + + ++n; + memset (p + idx, 0, n); // { dg-warning "writing between 4 and 8 bytes into a region of size 3" } +} + + +void char_ptr_var_szoff_var_size (char *p, size_t idx, size_t n) + // { dg-message "at offset \\\[\[1-9\]\[0-9\]+, \[1-9\]\[0-9\]+] into destination object 'p'" "note" { xfail *-*-* } .-1 } +{ + if (idx < DIFF_MAX - 3) + idx = DIFF_MAX - 3; + + if (n < 3 || 7 < n) + n = 3; + + memset (p + idx, 0, n); + sink (p); + + ++n; + /* With an unsigned offset large values are interpreted as negative + so the addition (p + idx) is effectively treated as subtraction, + making an overflow indistinguishable from a valid (if unlikely) + store. */ + memset (p + idx, 0, n); // { dg-warning "writing between 4 and 8 bytes into a region of size 3" "pr?????" { xfail *-*-* } } +} + + +void int_ptr_cst_off_cst_size (int *p) + // { dg-message "at offset \[1-9\]\[0-9\]+ into destination object 'p'" "note" { target *-*-* } .-1 } +{ + size_t idx = DIFF_MAX / sizeof *p; + + memset (p + idx, 0, 3); + sink (p); + + memset (p + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-51.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-51.c new file mode 100644 index 0000000000..6f36643c8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-51.c @@ -0,0 +1,34 @@ +/* Test case derived from Binutils/GDB's readline/readline/histexpand.c. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +char * +get_subst_pattern (char *str, int *iptr, int delimiter, int is_rhs, int *lenptr) +{ + int si, i, j, k; + char *s; + + s = 0; + i = *iptr; + + for (si = i; str[si] && str[si] != delimiter; si++) + if (str[si] == '\\' && str[si + 1] == delimiter) + si++; + + if (si > i || is_rhs) + { + s = (char *)__builtin_malloc (si - i + 1); + for (j = 0, k = i; k < si; j++, k++) + { + /* Remove a backslash quoting the search string delimiter. */ + if (str[k] == '\\' && str[k + 1] == delimiter) + k++; + s[j] = str[k]; // { dg-bogus "-Wstringop-overflow" } + } + s[j] = '\0'; + if (lenptr) + *lenptr = j; + } + + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-52.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-52.c new file mode 100644 index 0000000000..a28965557c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-52.c @@ -0,0 +1,62 @@ + +/* PR middle-end/97023 - missing warning on buffer overflow in chained mempcpy + Verify that writes by built-in functions to objects through pointers + returned by ordinary (non-built-int) function are assumed to point to + the beginning of objects. + { dg-do compile } + { dg-options "-O2" } */ + +#include "range.h" + +void* memcpy (void*, const void*, size_t); +void* memset (void*, int, size_t); + +void sink (void*, ...); + +extern char* arrptr[]; +extern char* ptr; +extern char* retptr (void); +struct S { char *p; }; +extern struct S retstruct (void); + +void nowarn_ptr (void) +{ + { + void *p = arrptr; + memset (p - 1, 0, 12345); // { dg-warning "\\\[-Wstringop-overflow" } + memset (p,0, 12345); + memset (p,0, DIFF_MAX - 1); + } + + { + char *p = arrptr[0]; + memset (p - 1, 0, 12345); + memset (p - 12345, 0, 12345); + memset (p - 1234, 0, DIFF_MAX - 1); + memset (p - DIFF_MAX + 1, 0, 12345); + } + + { + char *p = ptr; + memset (p - 1, 0, 12345); + memset (p - 12345, 0, 12345); + memset (p - 1234, 0, DIFF_MAX - 1); + memset (p - DIFF_MAX + 1, 0, 12345); + } + + { + char *p = retptr (); + memset (p - 1, 0, 12345); + memset (p - 12345, 0, 12345); + memset (p - 1234, 0, DIFF_MAX - 1); + memset (p - DIFF_MAX + 1, 0, 12345); + } + + { + char *p = retstruct ().p; + memset (p - 1, 0, 12345); + memset (p - 12345, 0, 12345); + memset (p - 1234, 0, DIFF_MAX - 1); + memset (p - DIFF_MAX + 1, 0, 12345); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-53.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-53.c new file mode 100644 index 0000000000..cd8fa3202e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-53.c @@ -0,0 +1,116 @@ +/* PR middle-end/96384 - bogus -Wstringop-overflow= storing into + multidimensional array with index in range + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define SHRT_MAX __SHRT_MAX__ +#define SHRT_MIN (-SHRT_MAX - 1) +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define LONG_MAX __LONG_MAX__ +#define LONG_MIN (-LONG_MAX - 1) + +#define USHRT_MAX (SHRT_MAX * 2 + 1) +#define UINT_MAX ~0U +#define ULONG_MAX ~0LU + +char ca3_5_7[3][5][7]; + +void nowarn_ca_3_5_ssi (short i) +{ + if (i > SHRT_MAX - 1) + i = SHRT_MAX - 1; + + ca3_5_7[i][0][0] = __LINE__; + ca3_5_7[i][0][1] = __LINE__; + ca3_5_7[i][0][2] = __LINE__; + ca3_5_7[i][0][3] = __LINE__; + ca3_5_7[i][0][4] = __LINE__; + ca3_5_7[i][0][5] = __LINE__; + ca3_5_7[i][0][6] = __LINE__; + + ca3_5_7[i][1][0] = __LINE__; + ca3_5_7[i][1][1] = __LINE__; + ca3_5_7[i][1][2] = __LINE__; + ca3_5_7[i][1][3] = __LINE__; + ca3_5_7[i][1][4] = __LINE__; + ca3_5_7[i][1][5] = __LINE__; + ca3_5_7[i][1][6] = __LINE__; + + ca3_5_7[i][2][0] = __LINE__; + ca3_5_7[i][2][1] = __LINE__; + ca3_5_7[i][2][2] = __LINE__; + ca3_5_7[i][2][3] = __LINE__; + ca3_5_7[i][2][4] = __LINE__; + ca3_5_7[i][2][5] = __LINE__; + ca3_5_7[i][2][6] = __LINE__; + + ca3_5_7[i][3][0] = __LINE__; + ca3_5_7[i][3][1] = __LINE__; + ca3_5_7[i][3][2] = __LINE__; + ca3_5_7[i][3][3] = __LINE__; + ca3_5_7[i][3][4] = __LINE__; + ca3_5_7[i][3][5] = __LINE__; + ca3_5_7[i][3][6] = __LINE__; + + ca3_5_7[i][4][0] = __LINE__; + ca3_5_7[i][4][1] = __LINE__; + ca3_5_7[i][4][2] = __LINE__; + ca3_5_7[i][4][3] = __LINE__; + ca3_5_7[i][4][4] = __LINE__; + ca3_5_7[i][4][5] = __LINE__; + ca3_5_7[i][4][6] = __LINE__; + + ca3_5_7[1][i][5] = __LINE__; + ca3_5_7[2][3][i] = __LINE__; +} + +void nowarn_ca_3_5_usi (unsigned short i) +{ + if (i > USHRT_MAX - 1) + i = USHRT_MAX - 1; + + ca3_5_7[i][3][5] = __LINE__; + ca3_5_7[1][i][5] = __LINE__; + ca3_5_7[2][3][i] = __LINE__; +} + +void nowarn_ca_3_5_si (int i) +{ + if (i > INT_MAX - 1) + i = INT_MAX - 1; + + ca3_5_7[i][3][5] = __LINE__; + ca3_5_7[1][i][5] = __LINE__; + ca3_5_7[2][3][i] = __LINE__; +} + +void nowarn_ca_3_5_ui (unsigned i) +{ + if (i > UINT_MAX - 1) + i = UINT_MAX - 1; + + ca3_5_7[i][3][5] = __LINE__; + ca3_5_7[1][i][5] = __LINE__; + ca3_5_7[2][3][i] = __LINE__; +} + +void nowarn_ca_3_5_li (long i) +{ + if (i > LONG_MAX - 1) + i = LONG_MAX - 1; + + ca3_5_7[i][3][5] = __LINE__; + ca3_5_7[1][i][5] = __LINE__; + ca3_5_7[2][3][i] = __LINE__; +} + +void nowarn_ca_3_5_uli (unsigned long i) +{ + if (i > ULONG_MAX - 1) + i = ULONG_MAX - 1; + + ca3_5_7[i][3][5] = __LINE__; + ca3_5_7[1][i][5] = __LINE__; + ca3_5_7[2][3][i] = __LINE__; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-54.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-54.c new file mode 100644 index 0000000000..f5929c9e7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-54.c @@ -0,0 +1,103 @@ +/* Verify that writes at excessive offsets into flexible array members + of extern or allocated objects of unknow size are diagnosed. + { dg-do compile } + { dg-options "-O2" } */ + +#define DIFF_MAX __PTRDIFF_MAX__ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +void* memset (void*, int, size_t); + +void sink (void*); + +void char_flexarray_cst_off_cst_size (void) +{ + extern struct { char n, a[]; } + caxcc; // { dg-message "at offset \[1-9\]\[0-9\]+ into destination object 'caxcc'" "note" } + + char *p = caxcc.a; + size_t idx = DIFF_MAX - 4; + + memset (p + idx, 0, 3); + sink (p); + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 2" } + sink (p); + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 1" } + + ++idx; + memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 0" } +} + + +void char_flexarray_var_off_cst_size (ptrdiff_t idx) +{ + extern struct { char n, a[]; } + caxvc; // { dg-message "destination object 'caxvc'" "note" } + + char *p = caxvc.a; + + if (idx < DIFF_MAX - 4) + idx = DIFF_MAX - 4; + + memset (p + idx, 0, 3); + sink (p); + + memset (p + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" } +} + + +void char_flexarray_var_off_var_size (size_t n, ptrdiff_t idx) +{ + extern struct { char n, a[]; } + caxvv; // { dg-message "destination object 'caxvv'" "note" } + + char *p = caxvv.a; + + if (idx < DIFF_MAX - 4) + idx = DIFF_MAX - 4; + + if (n < 3 || 7 < n) + n = 3; + + memset (p + idx, 0, n); + sink (p); + + ++n; + memset (p + idx, 0, n); // { dg-warning "writing between 4 and 8 bytes into a region of size 3" } +} + + +void alloc_array_var_off_cst_size (size_t n, ptrdiff_t idx) +{ + struct { char n, a[]; } + *p = __builtin_malloc (n); // { dg-message "at offset \\d+ into destination object" "note" } + + if (idx < DIFF_MAX - 4) + idx = DIFF_MAX - 4; + + memset (p->a + idx, 0, 3); + sink (p); + + memset (p->a + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" } +} + + +void int_array_cst_off_cst_size (void) +{ + extern struct { int n, a[]; } + iaxc; // { dg-message "at offset \[1-9\]\[0-9\]+ into destination object 'iaxc'" "note" } + + int *p = iaxc.a; + size_t idx = DIFF_MAX / sizeof *p - 1; + + memset (p + idx, 0, 3); + sink (p); + + memset (p + idx, 0, 5); // { dg-warning "writing 5 bytes into a region of size 3" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-55.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-55.c new file mode 100644 index 0000000000..c3c2dbe06d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-55.c @@ -0,0 +1,97 @@ +/* Verify that offsets in "anti-ranges" are handled correctly. + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0 -fno-ipa-icf" } */ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +void* memset (void*, int, size_t); + +void sink (void*, ...); +#define T(x) sink (x) + + +void int_range_add_sub_ (int i, int j) +{ + if (i < 1) i = 1; + if (j > -1) j = -1; + + char ca5[5]; // { dg-message "at offset \\\[1, 5]" "note" } + char *p0 = ca5; // offset + char *p1 = p0 + i; // 1-5 + char *p2 = p1 + i; // 2-5 + char *p3 = p2 + j; // 0-4 + char *p4 = p3 + j; // 0-3 + char *p5 = p4 + j; // 0-2 + char *p6 = p5 + j; // 0-1 + char *p7 = p6 + i; // 1-2 + + memset (p7, 0, 5); // { dg-warning "writing 5 bytes into a region of size 4" } + + sink (p0, p1, p2, p3, p4, p5, p6, p7); +} + + +void ruint_arint_add (unsigned i, int j) +{ + i |= 1; // [1, UINT_MAX] + j |= 1; // [INT_MIN + 1, -1] U [1, INT_MAX] + + char a[5]; // { dg-message "at offset \\\[1, 5]" "note" } + char *p0 = a; // offset + char *p1 = p0 + i; // 1-5 + T (memset (p1, 0, 4)); + + char *p2 = p1 + j; // 0-5 + T (memset (p2, 0, 5)); + + char *p3 = p2 + i; // 1-5 + T (memset (p3, 0, 4)); + + char *p4 = p3 + j; // 0-5 + T (memset (p4, 0, 5)); + + char *p5 = p4 + i; // 1-5 + T (memset (p5, 0, 4)); + + char *p6 = p5 + j; // 0-5 + T (memset (p6, 0, 5)); + + char *p7 = p6 + i; // 1-5 + T (memset (p7, 0, 5)); // { dg-warning "writing 5 bytes into a region of size 4" "" } +} + + +void warn_ptrdiff_anti_range_add (ptrdiff_t i) +{ + i |= 1; + + char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" } + char *p0 = ca5; // offset + char *p1 = p0 + i; // 1-5 + char *p2 = p1 + i; // 2-5 + char *p3 = p2 + i; // 3-5 + char *p4 = p3 + i; // 4-5 + char *p5 = p4 + i; // 5 + + memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size" "pr?????" } + + sink (p0, p1, p2, p3, p4, p5); +} + +void warn_int_anti_range (int i) +{ + i |= 1; + + char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" } + char *p0 = ca5; // offset + char *p1 = p0 + i; // 1-5 + char *p2 = p1 + i; // 2-5 + char *p3 = p2 + i; // 3-5 + char *p4 = p3 + i; // 4-5 + char *p5 = p4 + i; // 5 + + memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size" "pr?????" } + + sink (p0, p1, p2, p3, p4, p5); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-56.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-56.c new file mode 100644 index 0000000000..5ba4de48f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-56.c @@ -0,0 +1,164 @@ +/* PR middle-end/92942 - missing -Wstringop-overflow for allocations with + a negative lower bound size + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +#define SIZE_MAX __SIZE_MAX__ +#define UINT8_MAX __UINT8_MAX__ +#define UINT16_MAX __UINT16_MAX__ + +typedef __SIZE_TYPE__ size_t; +typedef __UINT8_TYPE__ uint8_t; +typedef __UINT16_TYPE__ uint16_t; + +void* usr_alloc1 (size_t) __attribute__ ((alloc_size (1))); +void* usr_alloc2 (size_t, size_t) __attribute__ ((alloc_size (1, 2))); + +void* malloc (size_t); +void* memcpy (void*, const void*, size_t); +void* memset (void*, int, size_t); +char* strcpy (char*, const char*); + +void sink (void*); + +void malloc_uint_range_strcpy (unsigned n) +{ + void *p = malloc (5 < n ? 5 : n); + + strcpy (p, "01234"); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); + + strcpy (p, "0123"); + sink (p); +} + +void malloc_uint16_anti_range_memset (uint16_t n) +{ + if (5 <= n && n <= 9) return; + void *p = malloc (n); + + if (UINT16_MAX < SIZE_MAX) + { + size_t sz = (uint16_t)-1 + (size_t)1; + memset (p, 0, sz); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); + } + + memset (p, 0, 1); + sink (p); + memset (p, 0, 5); + sink (p); + memset (p, 0, 6); + sink (p); + memset (p, 0, UINT16_MAX - 1); + sink (p); + memset (p, 0, UINT16_MAX); + sink (p); +} + +void malloc_int_strcpy (int n) +{ + void *p = malloc (7 < n ? 7 : n); + + strcpy (p, "0123456"); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); + + strcpy (p, "012345"); + sink (p); +} + +void vla_int_strcpy (int n) +{ + char a[9 < n ? 9 : n]; + + strcpy (a, "012345678"); // { dg-warning "\\\[-Wstringop-overflow" } + sink (a); + + strcpy (a, "01234567"); + sink (a); +} + +void usr_alloc1_int_strcpy (int n) +{ + void *p = usr_alloc1 (7 < n ? 7 : n); + + strcpy (p, "0123456"); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); + + strcpy (p, "012345"); + sink (p); +} + +void usr_alloc2_cst_ir_strcpy (int n) +{ + void *p = usr_alloc2 (1, 5 < n ? 5 : n); + + strcpy (p, "01234"); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); + + strcpy (p, "0123"); + sink (p); +} + +void usr_alloc2_ir_ir_strcpy (int m, int n) +{ + void *p = usr_alloc2 (3 < n ? 3 : n, 5 < n ? 5 : n); + + strcpy (p, "0123456789abcde"); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); + + strcpy (p, "0123456789abcd"); + sink (p); +} + +void usr_alloc2_uint8_memset (uint8_t m, uint8_t n) +{ + if (3 <= m && m <= 7) return; + if (5 <= n && n <= 9) return; + void *p = usr_alloc2 (m, n); + + size_t sz = UINT8_MAX * UINT8_MAX + 1; + memset (p, 0, sz); // { dg-warning "\\\[-Wstringop-overflow" "" { xfail *-*-* } } + // { dg-warning "\\\[-Warray-bounds" "pr?????" { target *-*-* } .-1 } + sink (p); + + memset (p, 0, sz - 1); + sink (p); + memset (p, 0, 64); + sink (p); + memset (p, 0, 63); + sink (p); + memset (p, 0, 16); + sink (p); + memset (p, 0, 15); + sink (p); + memset (p, 0, 14); + sink (p); + memset (p, 0, 3); + sink (p); +} + + + +void malloc_int_memset (int n) +{ + void *p = malloc (11 < n ? 11 : n); + + memset (p, 0, 12); // { dg-warning "\\\[-Wstringop-overflow" } + sink (p); + + memset (p, 0, 11); + sink (p); +} + +void vla_int_memset (int n) +{ + char a[13 < n ? 13 : n]; + + memset (a, 0, 14); // { dg-warning "\\\[-Wstringop-overflow" } + sink (a); + + memset (a, 0, 13); + sink (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-57.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-57.c new file mode 100644 index 0000000000..6ae8589070 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-57.c @@ -0,0 +1,92 @@ +/* Verify that an anti-range ~[A, B] with small positive A and B + is handled correctly and doesn't trigger warnings. + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +typedef __typeof__ (sizeof 0) size_t; + +int f (void*, size_t); +int g (void*); + +// Test case distilled from gcc/cp/semantics.c + +int omp_reduction_id (int i, int j, const char *mm) +{ + const char *p = 0; + const char *m = 0; + + switch (i) + { + case 1: + p = "min"; + break; + case 2: + p = "max"; + break; + default: + break; + } + + if (j) + m = mm; + + const char prefix[] = "omp declare reduction "; + size_t lenp = sizeof (prefix); + + if (__builtin_strncmp (p, prefix, lenp - 1) == 0) + lenp = 1; + + size_t len = __builtin_strlen (p); + size_t lenm = m ? __builtin_strlen (m) + 1 : 0; + char *name = ((char *) __builtin_alloca(lenp + len + lenm)); + + if (lenp > 1) + __builtin_memcpy (name, prefix, lenp - 1); + + __builtin_memcpy (name + lenp - 1, p, len + 1); + if (m) + { + name[lenp + len - 1] = '~'; + __builtin_memcpy (name + lenp + len, m, lenm); + } + return (__builtin_constant_p (name) + ? f (name, __builtin_strlen (name)) : g (name)); +} + +// Test case derived from gcc/d/dmd/root/filename.c. + +const char *ext (const char *str) +{ + size_t len = __builtin_strlen(str); + + const char *e = str + len; + for (;;) + { + switch (*e) + { + case '.': return e + 1; + case '/': break; + default: + if (e == str) + break; + e--; + continue; + } + return 0; + } +} + +const char *removeExt (const char *str) +{ + const char *e = ext (str); + if (e) + { + size_t len = (e - str) - 1; + char *n = (char *)__builtin_malloc (len + 1); + __builtin_memcpy(n, str, len); + n[len] = 0; + return n; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-58.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-58.c new file mode 100644 index 0000000000..e0a40788f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-58.c @@ -0,0 +1,268 @@ +/* PR middle-end/92936 - missing warning on a past-the-end store to a PHI + Exercise warnings for writing into one of two or more declared objects. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ + +extern void* memset (void*, int, size_t); +#define memset(d, c, n) sink (memset (d, c, n)) + +void sink (int, ...); +#define sink(...) sink (0, __VA_ARGS__) + +volatile int cond1, cond2; + +extern char ca0[0], ca1[1], ca2[2], ca3[3], ca4[4], + ca5[5], ca6[6], ca7[7], ca8[8], ca9[9], cax[]; + +#define CHOOSE_DECL_2(n1, n2) \ + (cond1 ? ca ## n1 : ca ## n2) +#define CHOOSE_DECL_3(n1, n2, n3) \ + (cond1 < 0 ? ca ## n1 : 0 < cond1 ? ca ## n2 : ca ## n3) + + +void memset_decl_2 (void) +{ + { + char *p0_1 = CHOOSE_DECL_2 (0, 1); + + memset (p0_1, 0, 0); + /* Writing more than the smallest destination should trigger a "may + write" warning if the access is unconditionally reachable from + the block where the pointer to either object is assigned. */ + memset (p0_1, 0, 1); + memset (p0_1, 0, 2); // { dg-warning "memset' writing 2 bytes into a region of size 1 " } + memset (p0_1, 0, 9); // { dg-warning "memset' writing 9 bytes into a region of size 1 " } + } + + { + char *p0_x = CHOOSE_DECL_2 (0, x); + + memset (p0_x, 0, 0); + memset (p0_x, 0, 1); + memset (p0_x, 0, 2); + memset (p0_x, 0, 9); + } + + { + char *p3_5 = CHOOSE_DECL_2 (3, 5); + + memset (p3_5, 0, 1); + memset (p3_5, 0, 3); + memset (p3_5, 0, 4); + memset (p3_5, 0, 5); + memset (p3_5, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " } + } + + { + char *p5_3 = CHOOSE_DECL_2 (5, 3); + + memset (p5_3, 0, 3); + memset (p5_3, 0, 4); + memset (p5_3, 0, 5); + memset (p5_3, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " } + } + + { + char *px_3 = CHOOSE_DECL_2 (x, 3); + + memset (px_3, 0, 1); + memset (px_3, 0, 3); + memset (px_3, 0, 4); + memset (px_3, 0, 1234); + } + + { + char *p5_x = CHOOSE_DECL_2 (5, x); + + memset (p5_x, 0, 1); + memset (p5_x, 0, 5); + memset (p5_x, 0, 6); + memset (p5_x, 0, 1234); + } + +} + + +void memset_decl_3 (void) +{ + { + char *p0_1_2 = CHOOSE_DECL_3 (0, 1, 2); + memset (p0_1_2, 0, 0); + memset (p0_1_2, 0, 1); + memset (p0_1_2, 0, 2); + memset (p0_1_2, 0, 3); // { dg-warning "memset' writing 3 bytes into a region of size 2 " } + memset (p0_1_2, 0, 9); // { dg-warning "memset' writing 9 bytes into a region of size 2 " } + } + + { + char *p0_2_x = CHOOSE_DECL_3 (0, 2, x); + + memset (p0_2_x, 0, 0); + memset (p0_2_x, 0, 1); + memset (p0_2_x, 0, 3); + memset (p0_2_x, 0, 9); + } + + { + char *p3_4_5 = CHOOSE_DECL_3 (3, 4, 5); + + memset (p3_4_5, 0, 3); + memset (p3_4_5, 0, 4); + memset (p3_4_5, 0, 5); + memset (p3_4_5, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " } + } + + { + char *p5_3_4 = CHOOSE_DECL_3 (5, 3, 4); + + memset (p5_3_4, 0, 3); + memset (p5_3_4, 0, 4); + memset (p5_3_4, 0, 5); + memset (p5_3_4, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " } + } + + { + char *p9_8_7 = CHOOSE_DECL_3 (9, 8, 7); + + memset (p9_8_7, 0, 7); + memset (p9_8_7, 0, 8); + memset (p9_8_7, 0, 9); + memset (p9_8_7, 0, 10); // { dg-warning "memset' writing 10 bytes into a region of size 9 " } + } +} + + +/* Verify conditionally writing into one of two objects with the same + size. */ + +void memset_decl_2_same_size (int i) +{ + { + char a4_1[4], a4_2[4]; + char *p4 = cond1 ? a4_1 : a4_2; + + memset (p4, 0, 1); + memset (p4, 0, 2); + memset (p4, 0, 3); + memset (p4, 0, 4); + memset (p4, 0, 5); // { dg-warning "memset' writing 5 bytes into a region of size 4" } + } + + { + char a4_1[4]; // { dg-message "destination object 'a4_1" "note" } + char a4_2[4]; // { dg-message "destination object 'a4_2" "note" } + char *p4 = cond1 ? a4_1 : a4_2; + char *p4_i = p4 + i; + + memset (p4_i, 0, 5); // { dg-warning "memset' writing 5 bytes into a region of size 4" } + } + + { + if (i < 1) + i = 1; + + char a4_1[4]; // { dg-message "at offset \\\[1, 4] into destination object 'a4_1" "note" } + char a4_2[4]; // { dg-message "at offset \\\[1, 4] into destination object 'a4_2" "note" } + char *p4 = cond1 ? a4_1 : a4_2; + char *p4_i = p4 + i; + + memset (p4_i, 0, 3); + memset (p4_i, 0, 4); // { dg-warning "memset' writing 4 bytes into a region of size 3 " } + } +} + + +void memset_decl_2_off (void) +{ + int i1 = SR (1, INT_MAX); + int i2 = SR (2, INT_MAX); + + { + char a5[5]; // { dg-message "at offset \\\[1, 5] into destination object 'a5'" "note" } + char a7[7]; // { dg-message "at offset \\\[2, 7] into destination object 'a7'" "note" } + char *p5_p1 = a5 + i1; + char *p7_p2 = a7 + i2; + char *p5_7 = cond1 ? p5_p1 : p7_p2; + + memset (p5_7, 0, 1); + memset (p5_7, 0, 2); + memset (p5_7, 0, 3); + memset (p5_7, 0, 4); + memset (p5_7, 0, 5); + /* The warning code conservatively "merges" both the sizes and the offsets + into A5 and A7 and so only the second store below is diagnosed but not + the first. See PR 103215. The logic needs to be tightened up. */ + memset (p5_7, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " "pr??????" { xfail *-*-* } } + memset (p5_7, 0, 7); // { dg-warning "memset' writing 7 bytes into a region of size 6 " } + } + + int i3 = SR (3, INT_MAX); + + { + char a5[5]; + // { dg-message "at offset \\\[3, 5] into destination object 'a5'" "note" { target *-*-* } .-1 } + // { dg-message "at offset \\\[2, 5] into destination object 'a5'" "note" { target *-*-* } .-2 } + // { dg-message "at offset \\\[1, 5] into destination object 'a5'" "note" { target *-*-* } .-3 } + // { dg-message ": destination object 'a5'" "note" { target *-*-* } .-4 } + char a9[9]; + // { dg-message "at offset \\\[4, 9] into destination object 'a9'" "note" { target *-*-* } .-1 } + // { dg-message "at offset \\\[3, 9] into destination object 'a9'" "note" { target *-*-* } .-2 } + // { dg-message "at offset \\\[2, 9] into destination object 'a9'" "note" { target *-*-* } .-3 } + // { dg-message "at offset \\\[1, 9] into destination object 'a9'" "note" { target *-*-* } .-4 } + // { dg-message ": destination object 'a9'" "pr??????" { xfail *-*-* } .-5 } + char *p5_p2 = a5 + i2; // 3 bytes left + char *p9_p3 = a9 + i3; // 6 bytes left + char *p = + cond1 ? p5_p2 : p9_p3; // [3 - 6] bytes left + char *q = p + i1; // [2 - 5] bytes left + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); + memset (q, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5" "pr??????" { xfail *-*-* } } + memset (q, 0, 7); // { dg-warning "memset' writing 7 bytes into a region of size 6" } + + --q; // [3 - 6] bytes left + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); + memset (q, 0, 6); + memset (q, 0, 7); // { dg-warning "memset' writing 7 bytes into a region of size 6" "pr??????" { xfail *-*-* } } + memset (q, 0, 8); // { dg-warning "memset' writing 8 bytes into a region of size 7" } + + --q; // [4 - 7] bytes left + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); + memset (q, 0, 6); + memset (q, 0, 7); + memset (q, 0, 8); // { dg-warning "memset' writing 8 bytes into a region of size 7" "pr??????" { xfail *-*-* } } + memset (q, 0, 9); // { dg-warning "memset' writing 9 bytes into a region of size 8" } + + int m1_x = SR (-1, INT_MAX); + int m2_x = SR (-2, INT_MAX); + + q += cond2 ? m1_x : m2_x; // [5 - 9] bytes left + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); + memset (q, 0, 6); + memset (q, 0, 7); + memset (q, 0, 8); + memset (q, 0, 9); + memset (q, 0, 10); // { dg-warning "memset' writing 10 bytes into a region of size 9" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-59.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-59.c new file mode 100644 index 0000000000..b6265e37c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-59.c @@ -0,0 +1,275 @@ +/* PR middle-end/92936 - missing warning on a past-the-end store to a PHI + Exercise warnings for writing into one of two or more allocated objects. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ + +extern void* malloc (size_t); +extern void* memset (void*, int, size_t); +#define memset(d, c, n) sink (memset (d, c, n)) + +void sink (int, ...); +#define sink(...) sink (0, __VA_ARGS__) + +volatile int cond1, cond2, x; + +#define CHOOSE_MALLOC_2(n1, n2) \ + (cond1 ? malloc (n1) : malloc (n2)) +#define CHOOSE_MALLOC_3(n1, n2, n3) \ + (cond1 < 0 ? malloc (n1) : 0 < cond1 ? malloc (n2) : malloc (n3)) + + +void memset_malloc_2 (void) +{ + { + char *p0_1 = CHOOSE_MALLOC_2 (0, 1); + + memset (p0_1, 0, 0); + /* Writing more than the smallest destination should trigger a "may + write" warning if the access is unconditionally reachable from + the block where the pointer to either object is assigned. */ + memset (p0_1, 0, 1); + memset (p0_1, 0, 2); // { dg-warning "memset' writing 2 bytes into a region of size 1 " } + memset (p0_1, 0, 9); // { dg-warning "memset' writing 9 bytes into a region of size 1 " } + } + + { + char *p0_x = CHOOSE_MALLOC_2 (0, x); + + memset (p0_x, 0, 0); + memset (p0_x, 0, 1); + memset (p0_x, 0, 2); + memset (p0_x, 0, 12345); + } + + { + char *px_x = CHOOSE_MALLOC_2 (x, x); + + memset (px_x, 0, 0); + memset (px_x, 0, 1); + memset (px_x, 0, 2); + memset (px_x, 0, 12345); + } + + { + char *p3_5 = CHOOSE_MALLOC_2 (3, 5); + + memset (p3_5, 0, 1); + memset (p3_5, 0, 3); + memset (p3_5, 0, 4); + memset (p3_5, 0, 5); + memset (p3_5, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " } + } + + { + char *p5_3 = CHOOSE_MALLOC_2 (5, 3); + + memset (p5_3, 0, 3); + memset (p5_3, 0, 4); + memset (p5_3, 0, 5); + memset (p5_3, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " } + } + + { + char *px_3 = CHOOSE_MALLOC_2 (x, 3); + + memset (px_3, 0, 1); + memset (px_3, 0, 3); + memset (px_3, 0, 4); + memset (px_3, 0, 1234); + } + + { + char *p5_x = CHOOSE_MALLOC_2 (5, x); + + memset (p5_x, 0, 1); + memset (p5_x, 0, 5); + memset (p5_x, 0, 6); + memset (p5_x, 0, 1234); + } + +} + + +void memset_malloc_3 (void) +{ + { + char *p0_1_2 = CHOOSE_MALLOC_3 (0, 1, 2); + memset (p0_1_2, 0, 0); + memset (p0_1_2, 0, 1); + memset (p0_1_2, 0, 2); + memset (p0_1_2, 0, 3); // { dg-warning "memset' writing 3 bytes into a region of size 2 " } + memset (p0_1_2, 0, 9); // { dg-warning "memset' writing 9 bytes into a region of size 2 " } + } + + { + char *p0_2_x = CHOOSE_MALLOC_3 (0, 2, x); + + memset (p0_2_x, 0, 0); + memset (p0_2_x, 0, 1); + memset (p0_2_x, 0, 3); + memset (p0_2_x, 0, 9); + } + + { + char *p3_4_5 = CHOOSE_MALLOC_3 (3, 4, 5); + + memset (p3_4_5, 0, 3); + memset (p3_4_5, 0, 4); + memset (p3_4_5, 0, 5); + memset (p3_4_5, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " } + } + + { + char *p5_3_4 = CHOOSE_MALLOC_3 (5, 3, 4); + + memset (p5_3_4, 0, 3); + memset (p5_3_4, 0, 4); + memset (p5_3_4, 0, 5); + memset (p5_3_4, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " } + } + + { + char *p9_8_7 = CHOOSE_MALLOC_3 (9, 8, 7); + + memset (p9_8_7, 0, 7); + memset (p9_8_7, 0, 8); + memset (p9_8_7, 0, 9); + memset (p9_8_7, 0, 10); // { dg-warning "memset' writing 10 bytes into a region of size 9 " } + } +} + + +/* Verify conditionally writing into one of two objects with the same + size. */ + +void memset_malloc_2_same_size (int i) +{ + { + char a4_1[4], a4_2[4]; + char *p4 = cond1 ? a4_1 : a4_2; + + memset (p4, 0, 1); + memset (p4, 0, 2); + memset (p4, 0, 3); + memset (p4, 0, 4); + memset (p4, 0, 5); // { dg-warning "memset' writing 5 bytes into a region of size 4" } + } + + { + char a4_1[4]; // { dg-message "destination object 'a4_1" "note" } + char a4_2[4]; // { dg-message "destination object 'a4_2" "note" } + char *p4 = cond1 ? a4_1 : a4_2; + char *p4_i = p4 + i; + + memset (p4_i, 0, 5); // { dg-warning "memset' writing 5 bytes into a region of size 4" } + } + + { + if (i < 1) + i = 1; + + char a4_1[4]; // { dg-message "at offset \\\[1, 4] into destination object 'a4_1" "note" } + char a4_2[4]; // { dg-message "at offset \\\[1, 4] into destination object 'a4_2" "note" } + char *p4 = cond1 ? a4_1 : a4_2; + char *p4_i = p4 + i; + + memset (p4_i, 0, 3); + memset (p4_i, 0, 4); // { dg-warning "memset' writing 4 bytes into a region of size 3 " } + } +} + + +void memset_malloc_2_off (void) +{ + int i1 = SR (1, INT_MAX); + int i2 = SR (2, INT_MAX); + + { + char a5[5]; // { dg-warning "at offset [1, 5] into destination object 'a5' + char a7[7]; // { dg-warning "at offset [2, 7] into destination object 'a7' + char *p5_p1 = a5 + i1; + char *p7_p2 = a7 + i2; + char *p5_7 = cond1 ? p5_p1 : p7_p2; + + memset (p5_7, 0, 1); + memset (p5_7, 0, 2); + memset (p5_7, 0, 3); + memset (p5_7, 0, 4); + memset (p5_7, 0, 5); + /* The warning code conservatively "merges" both the sizes and the offsets + into A5 and A7 and so only the second store below is diagnosed but not + the first. See PR 103215. The logic needs to be tightened up. */ + memset (p5_7, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5 " "pr??????" { xfail *-*-* } } + memset (p5_7, 0, 7); // { dg-warning "memset' writing 7 bytes into a region of size 6 " } + } + + int i3 = SR (3, INT_MAX); + + { + char a5[5]; + // { dg-message "at offset \\\[3, 5] into destination object 'a5'" "note" { target *-*-* } .-1 } + // { dg-message "at offset \\\[2, 5] into destination object 'a5'" "note" { target *-*-* } .-2 } + // { dg-message "at offset \\\[1, 5] into destination object 'a5'" "note" { target *-*-* } .-3 } + // { dg-message ": destination object 'a5'" "note" { target *-*-* } .-4 } + char a9[9]; + // { dg-message "at offset \\\[4, 9] into destination object 'a9'" "note" { target *-*-* } .-1 } + // { dg-message "at offset \\\[3, 9] into destination object 'a9'" "note" { target *-*-* } .-2 } + // { dg-message "at offset \\\[2, 9] into destination object 'a9'" "note" { target *-*-* } .-3 } + // { dg-message "at offset \\\[1, 9] into destination object 'a9'" "note" { target *-*-* } .-4 } + // { dg-message ": destination object 'a9'" "pr??????" { xfail *-*-* } .-5 } + char *p5_p2 = a5 + i2; // 3 bytes left + char *p9_p3 = a9 + i3; // 6 bytes left + char *p = + cond1 ? p5_p2 : p9_p3; // [3 - 6] bytes left + char *q = p + i1; // [2 - 5] bytes left + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); + memset (q, 0, 6); // { dg-warning "memset' writing 6 bytes into a region of size 5" "pr??????" { xfail *-*-* } } + memset (q, 0, 7); // { dg-warning "memset' writing 7 bytes into a region of size 6" } + + --q; // [3 - 6] bytes left + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); + memset (q, 0, 6); + memset (q, 0, 7); // { dg-warning "memset' writing 7 bytes into a region of size 6" "pr??????" { xfail *-*-* } } + memset (q, 0, 8); // { dg-warning "memset' writing 8 bytes into a region of size 7" } + + --q; // [4 - 7] bytes left + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); + memset (q, 0, 6); + memset (q, 0, 7); + memset (q, 0, 8); // { dg-warning "memset' writing 8 bytes into a region of size 7" "pr??????" { xfail *-*-* } } + memset (q, 0, 9); // { dg-warning "memset' writing 9 bytes into a region of size 8" } + + int m1_x = SR (-1, INT_MAX); + int m2_x = SR (-2, INT_MAX); + + q += cond2 ? m1_x : m2_x; // [5 - 9] bytes left + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); + memset (q, 0, 6); + memset (q, 0, 7); + memset (q, 0, 8); + memset (q, 0, 9); + memset (q, 0, 10); // { dg-warning "memset' writing 10 bytes into a region of size 9" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-6.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-6.c new file mode 100644 index 0000000000..acb0fcb6dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-6.c @@ -0,0 +1,59 @@ +/* PR tree-optimization/85259 - Missing -Wstringop-overflow= since r256683 + { dg-do compile } + { dg-options "-O2 -Wstringop-overflow -ftrack-macro-expansion=0" } */ + +#define bos1(p) __builtin_object_size (p, 1) +#define strcat(d, s) __builtin___strcat_chk (d, s, bos1 (d)) +#define strcpy(d, s) __builtin___strcpy_chk (d, s, bos1 (d)) + +char a1[1]; +char a2[2]; +char a3[3]; +char a4[4]; +char a5[5]; +char a6[6]; +char a7[7]; +char a8[8]; + +/* Verify that at least one instance of -Wstringop-overflow is issued + for each pair of strcpy/strcat calls. */ + +void test_strcpy_strcat_1 (void) +{ + strcpy (a1, "1"), strcat (a1, "2"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_2 (void) +{ + strcpy (a2, "12"), strcat (a2, "3"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_3 (void) +{ + strcpy (a3, "123"), strcat (a3, "4"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_4 (void) +{ + strcpy (a4, "1234"), strcat (a4, "5"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_5 (void) +{ + strcpy (a5, "12345"), strcat (a5, "6"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_6 (void) +{ + strcpy (a6, "123456"), strcat (a6, "7"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_7 (void) +{ + strcpy (a7, "1234567"), strcat (a7, "8"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +void test_strcpy_strcat_8 (void) +{ + strcpy (a8, "12345678"), strcat (a8, "9"); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-60.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-60.c new file mode 100644 index 0000000000..8c9de20e9b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-60.c @@ -0,0 +1,72 @@ +/* Test derived from Glibc's getifaddrs_internal. The code could be + rewritten to avoid the warning for the memcpy call but since unions + are designed to have their members treated as interchangeable there + isn't a whole lot to be gained from issuing one. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); + +struct sockaddr +{ + short sa_family; + char sa_data[14]; +}; + +struct in_addr +{ + int s_addr; +}; + +struct in6_addr +{ + union + { + char __u6_addr8[16]; + short __u6_addr16[8]; + int __u6_addr32[4]; + } __in6_u; +}; + +struct sockaddr_in +{ + short sin_family; + short sin_port; + struct in_addr sin_addr; + unsigned char sin_zero[sizeof (struct sockaddr) - + (sizeof (short)) - + sizeof (short) - + sizeof (struct in_addr)]; +}; + +struct sockaddr_in6 +{ + short sin6_family; + short sin6_port; + int sin6_flowinfo; + struct in6_addr sin6_addr; + int sin6_scope_id; +}; + +union +{ + struct sockaddr sa; + struct sockaddr_in s4; + struct sockaddr_in6 s6; +} u1, u2; + +struct sockaddr *sa; + +void test_unconditional (void *p) +{ + sa = &u1.sa; + memcpy (&((struct sockaddr_in6 *) sa)->sin6_addr, p, 16); +} + +void test_conditional (void *p, int i) +{ + sa = i ? &u1.sa : &u2.sa; + memcpy (&((struct sockaddr_in6 *) sa)->sin6_addr, p, 16); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-61.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-61.c new file mode 100644 index 0000000000..93c54c646c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-61.c @@ -0,0 +1,88 @@ +/* { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +void* malloc (size_t); +void* memcpy (void*, const void*, size_t); +size_t strlen (const char *); + +// Test case reduced from gcc/attribs.c. + +char* sorted_attr_string (char *argv[]) +{ + size_t n = 0; + unsigned int i; + + for (i = 0; argv[i]; ++i) + n += strlen (argv[i]); + + char *s = (char*)malloc (n); + n = 0; + for (i = 0; argv[i]; ++i) + { + const char *str = argv[i]; + size_t len = strlen (str); + memcpy (s + n, str, len); + n += len + 1; + } + + /* Replace "=,-" with "_". */ + for (i = 0; i < strlen (s); i++) + if (s[i] == '=') + s[i] = '_'; // { dg-bogus "\\\[-Wstringop-overflow" } + + return s; +} + + +void f (void*); + +void nowarn_cond_escape (int c, int *x) +{ + extern char a3[3], a5[5]; + + char *p; + if (c) + { + p = a3; + *x = 2; + } + else + { + p = a5; + *x = 4; + } + + f (p); // may modify *x + + if (*x == 2) + p[2] = 0; + else if (*x == 4) + p[4] = 0; // { dg-bogus "\\\[-Wstringop-overflow" } +} + +void warn_cond_escape (int c, int *x) +{ + extern char a3_2[3]; + extern char a5_2[5]; // { dg-message "at offset 5 into object 'a5_2'" } + + char *p; + if (c) + { + p = a3_2; + *x = 2; + } + else + { + p = a5_2; + *x = 5; + } + + f (p); // may modify *x + + if (*x == 2) + p[2] = 0; + else if (*x == 5) + p[5] = 0; // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-62.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-62.c new file mode 100644 index 0000000000..d589f07788 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-62.c @@ -0,0 +1,363 @@ +/* Test for MIN and MAX expressions involving pointers. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +#include "range.h" + +#define INT_MAX __INT_MAX__ + +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#define MAX(x, y) ((x) < (y) ? (y) : (x)) + +typedef __SIZE_TYPE__ size_t; + +void* memset (void*, int, size_t); +#define memset(...) sink (memset (__VA_ARGS__)) + +void sink (void*, ...); + +volatile int cond, vi; +char* volatile ptr; + +void test_min (void) +{ + const int i1 = SR (1, INT_MAX); + const int i2 = SR (2, INT_MAX); + + { + /* Exercise both pointers pointing to a different unknown object plus + positive constant offset. Since PTR is volatile P1 and P2 cannot + normally be considered to point to the same object. It can only + be inferred from the MIN expression. */ + char *p1 = ptr + 1; + char *p2 = ptr + 2; + + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, INT_MAX); + // { dg-warning "writing 2147483647 bytes into a region of size 2147483646" "ilp32" { target ilp32 } .-1 } + memset (q, 0, DIFF_MAX - 2); + memset (q, 0, DIFF_MAX); + // { dg-warning "writing 2147483647 bytes into a region of size 2147483646" "ilp32" { target ilp32 } .-1 } + // { dg-warning "writing 9223372036854775807 bytes into a region of size 9223372036854775806" "not-ilp32" { target { ! ilp32 } } .-2 } + } + + { + /* Exercise both pointers pointing to a different unknown object plus + variable offset. */ + char *p1 = ptr + vi; + char *p2 = ptr + vi; + + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, INT_MAX); + } + + { + /* Exercise both pointers pointing to the same object plus constant + offset. */ + char a2[2]; // { dg-message "at offset 1 into destination object 'a2' of size 2" "note" } + char *p1 = a2 + 1; + char *p2 = a2 + 2; + + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); // { dg-warning "writing 2 bytes into a region of size 1 " } + } + + { + /* Exercise both pointers pointing to the same object plus offset + in a known range. */ + char a3[3]; // { dg-message "at offset \\\[1, 3] into destination object 'a3'" "note" } + char *pi = a3 + i1; + char *pj = a3 + i2; + + char *q = MIN (pi, pj); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + } + + { + /* Exercise both pointers pointing to the same object plus variable + offset. Verify that no offset is mentioned in the note (since + its unknown, printing its full range is unnecessary). */ + char a4[4]; // { dg-message ": destination object 'a4'" "note" } + char *pi = a4 + vi; + char *pj = a4 + vi; + + char *q = MIN (pi, pj); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); // { dg-warning "writing 5 bytes into a region of size 4 " } + } + + { + /* Exercise a pointer pointing to a known object with one pointing + to an unknown object. */ + char a5[5]; // { dg-message ": destination object 'a5'" "note" } + char *p = ptr; + char *q = MIN (p, a5); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 5); + memset (q, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5 " } + } + + { + /* Exercise a pointer pointing to a known object plus constant offset + with one pointing to an unknown object. */ + char a6[6]; // { dg-message "(at offset 1 into )?destination object 'a6'" "note" } + char *p1 = ptr; + char *p2 = a6 + 1; + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 6); + memset (q, 0, 7); // { dg-warning "writing 7 bytes into a region of size 6 " } + } + + { + /* Exercise a pointer pointing to a known object with one pointing + to an unknown object plus constant offset. */ + char a7[7]; // { dg-message ": destination object 'a7'" "note" } + char *p1 = a7; + char *p2 = ptr + 1; + /* Since p1 points to a7[0] it must be less than any pointer to a7 + plus positive offset, and so Q == P1. */ + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 7); + memset (q, 0, 8); // { dg-warning "writing 8 bytes into a region of size 7 " } + } + + { + /* Exercise a pointer pointing to a known object plus constant offset + with one pointing to an unknown object plus a different constant + offset. */ + char a8[8]; // { dg-message "at offset 1 into destination object 'a8'" "note" } + char *p1 = a8 + 1; + char *p2 = ptr + 2; + /* Since P1 points to A8[1] it must be less than or equal to any + pointer to A8 plus positive offset. Either way, Q must point + to A8[1]. */ + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 7); + memset (q, 0, 8); // { dg-warning "writing 8 bytes into a region of size 7 " } + } + + { + /* Same as above but with larger offsets. */ + char a9[9]; // { dg-message "at offset 3 into destination object 'a9'" "note" } + char *p1 = a9 + 3; + char *p2 = ptr + 4; + /* Since P1 points to A9[3] it must be less than or equal to any + pointer anywhere into A9 plus 4, so Q must point to A9[3]. */ + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 6); + memset (q, 0, 7); // { dg-warning "writing 7 bytes into a region of size 6 " } + } + + { + /* Same as above but with the offsets reversed. */ + char a10[10]; // { dg-message "at offset 5 into destination object 'a10'" "note" } + char *p1 = a10 + 10; + char *p2 = ptr + 5; + /* Since P1 points just past the end of A10 it could be either less + or equal to another pointer anywhere into A10 plus 3 because + the other pointer itself could start at a non-zero offset that's + not reflected in the determined offset). */ + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 5); + memset (q, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5 " } + } + + { + char a3[3]; // { dg-message ": destination object 'a3'" "note" } + char *p1 = ptr; + char *p2 = a3 + i1; + char *q = MIN (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); // { dg-warning "writing 4 bytes into a region of size 3 " } + } +} + + +void test_max (void) +{ + const int i1 = SR (1, INT_MAX); + const int i2 = SR (2, INT_MAX); + + { + /* Exercise both pointers pointing to the same object plus constant + offset. */ + char a2[2]; + char *pi = a2 + 1; + char *pj = a2 + 2; + + char *q = MAX (pi, pj); + + memset (q, 0, 1); // { dg-warning "writing 1 byte into a region of size 0 " } + memset (q, 0, 2); // { dg-warning "writing 2 bytes into a region of size 0 " } + } + + { + /* Exercise both pointers pointing to the same object plus offset + in a known range. */ + char a3[3]; // { dg-message "at offset \\\[1, 3] into destination object 'a3'" "note" } + char *pi = a3 + i1; + char *pj = a3 + i2; + + char *q = MAX (pi, pj); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + } + + { + /* Exercise both pointers pointing to the same object plus variable + offset. Verify that no offset is mentioned in the note (since + its unknown, printing its full range is unnecessary). */ + char a4[4]; // { dg-message ": destination object 'a4'" "note" } + char *pi = a4 + vi; + char *pj = a4 + vi; + + char *q = MAX (pi, pj); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 3); + memset (q, 0, 4); + memset (q, 0, 5); // { dg-warning "writing 5 bytes into a region of size 4 " } + } + + { + /* Exercise a pointer pointing to a known object with one pointing + to an unknown object. */ + char a5[5]; // { dg-message ": destination object 'a5'" "note" } + char *p = ptr; + char *q = MAX (p, a5); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 5); + memset (q, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5 " } + } + + { + /* Exercise a pointer pointing to a known object plus constant offset + with one pointing to an unknown object. */ + char a6[6]; // { dg-message "at offset 1 into destination object 'a6'" "note" } + char *p1 = ptr; + char *p2 = a6 + 1; + char *q = MAX (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 5); + memset (q, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5 " } + memset (q, 0, 7); // { dg-warning "writing 7 bytes into a region of size 5 " } + } + + { + /* Exercise a pointer pointing to a known object with one pointing + to an unknown object plus constant offset. */ + char a7[7]; // { dg-message "at offset 1 into destination object 'a7'" "note" } + char *p1 = a7; + char *p2 = ptr + 1; + /* Since p1 points to a7[0] it must be less than any pointer to a7 + plus positive offset, and so Q == P2. */ + char *q = MAX (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 6); + memset (q, 0, 7); // { dg-warning "writing 7 bytes into a region of size 6 " } + memset (q, 0, 8); // { dg-warning "writing 8 bytes into a region of size 6 " } + } + + { + /* Exercise a pointer pointing to a known object plus constant offset + with one pointing to an unknown object plus a different constant + offset. */ + char a8[8]; // { dg-message "at offset 2 into destination object 'a8'" "note" } + char *p1 = a8 + 1; + char *p2 = ptr + 2; + /* Since P1 points to A8[1] it must be less than or equal to any + pointer to A8 plus positive offset. Either way, Q must point + to A8[2]. */ + char *q = MAX (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 6); + memset (q, 0, 7); // { dg-warning "writing 7 bytes into a region of size 6 " } + memset (q, 0, 8); // { dg-warning "writing 8 bytes into a region of size 6 " } + } + + { + /* Same as above but with larger offsets. */ + char a9[9]; // { dg-message "at offset 4 into destination object 'a9'" "note" } + char *p1 = a9 + 3; + char *p2 = ptr + 4; + /* Since P1 points to A9[3] it must be less than or equal to any + pointer anywhere into A9 plus 4, so Q must point to A9[4]. */ + char *q = MAX (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 5); + memset (q, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5 " } + } + + { + /* Same as above but with the offsets reversed. */ + char a10[10]; // { dg-message "at offset 10 into destination object 'a10'" "note" } + char *p1 = a10 + 10; + char *p2 = ptr + 5; + /* Since P1 points just past the end of A10 it could be either less + or equal to another pointer anywhere into A10 plus 3 because + the other pointer itself could start at a non-zero offset that's + not reflected in the determaxed offset). */ + char *q = MAX (p1, p2); + + memset (q, 0, 1); // { dg-warning "writing 1 byte into a region of size 0 " } + } + + { + char a11[11]; // { dg-message "at offset \\\[1, 11] into destination object 'a11'" "note" } + char *p1 = ptr; + char *p2 = a11 + i1; + char *q = MAX (p1, p2); + + memset (q, 0, 1); + memset (q, 0, 2); + memset (q, 0, 10); + memset (q, 0, 11); // { dg-warning "writing 11 bytes into a region of size 10 " } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-63.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-63.c new file mode 100644 index 0000000000..c98721dd8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-63.c @@ -0,0 +1,33 @@ +/* PR middle-end/92936 - missing warning on a past-the-end store to a PHI + Test case derived from gcc/opts-common.c. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +char* f (const void*, ...); + +const char * +candidates_list_and_hint (const char *arg, char **str, const char *a[]) +{ + size_t len = 0; + int i; + + for (i = 0; a[i]; ++i) + len += __builtin_strlen (a[i]) + 1; + + char *p = (char*)__builtin_malloc (len); + *str = p; + + for (i = 0; a[i]; ++i) + { + len = __builtin_strlen (a[i]); + __builtin_memcpy (p, a[i], len); + p[len] = ' '; + p += len + 1; + } + + p[-1] = '\0'; // { dg-bogus "\\\[-Wstringop-overflow" } + + return f (arg, &a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-64.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-64.c new file mode 100644 index 0000000000..88b9d29752 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-64.c @@ -0,0 +1,74 @@ +/* PR middle-end/92936 - missing warning on a past-the-end store to a PHI + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds" } */ + +typedef __SIZE_TYPE__ size_t; + +void* malloc (size_t); +void* memset (void*, int, size_t); + +extern char a3[3], a5[5], a9[9]; + +extern int cnd[]; + +void* f2 (void) +{ + char *p0 = cnd[0] ? a3 : 0; + char *p1 = cnd[1] ? a5 : p0; + + return memset (p1, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5" } +} + +void* f3 (void) +{ + char *p0 = cnd[0] ? a3 : 0; + char *p1 = cnd[1] ? a5 : 0; + char *p2 = cnd[2] ? p0 : p1; + + return memset (p2, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5" } +} + +void* f3_2 (void) +{ + char *p0 = cnd[0] ? a3 : 0; + char *p1 = cnd[1] ? a5 : 0; + char *p2 = cnd[2] ? p1 : p0; + + return memset (p2, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5" } +} + +void* f3_3 (void) +{ + char *p0 = cnd[0] ? a5 : 0; + char *p1 = cnd[1] ? p0 : a5; + char *p2 = cnd[2] ? p1 : p0; + + return memset (p2, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5" } +} + +void* f4 (void) +{ + char *p0 = cnd[0] ? a3 : 0; + char *p1 = cnd[1] ? a5 : 0; + char *p2 = cnd[2] ? p0 : 0; + char *p3 = cnd[3] ? p1 : p2; + + return memset (p3, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5" } +} + +void* f9 (void) +{ + char *p0 = cnd[0] ? a5 : 0; + char *p1 = cnd[1] ? a5 + 1 : 0; + char *p2 = cnd[2] ? a5 + 2 : 0; + char *p3 = cnd[3] ? a5 + 3 : 0; + char *p4 = cnd[4] ? a5 + 4 : 0; + + char *p5 = cnd[5] ? p0 : p1; + char *p6 = cnd[6] ? p5 : p2; + char *p7 = cnd[7] ? p6 : p3; + char *p8 = cnd[8] ? p7 : p4; + char *p9 = cnd[9] ? p8 : p5; + + return memset (p9, 0, 6); // { dg-warning "writing 6 bytes into a region of size 5" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-65.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-65.c new file mode 100644 index 0000000000..9f82d73e31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-65.c @@ -0,0 +1,98 @@ +/* PR middle-end/96963 - -Wstringop-overflow false positive with + -ftree-vectorize when assigning consecutive char struct members + { dg-do compile } + { dg-options "-O2 -Wall -ftree-vectorize" } */ + +void sink (void*); + +struct Char +{ + int i; + char c, d, e, f; + char a[2], b[2]; +}; + +void nowarn_char_assign (struct Char *p) +{ + sink (&p->c); + + /* Verify the bogus warning triggered by the tree-ssa-strlen.c pass + is not issued. */ + p->c = 1; // { dg-bogus "\\\[-Wstringop-overflow" } + p->d = 2; + p->e = 3; + p->f = 4; +} + +void nowarn_char_array_assign (struct Char *p) +{ + sink (p->a); + + p->a[0] = 1; // { dg-bogus "\\\[-Wstringop-overflow" } + p->a[1] = 2; + p->b[0] = 3; + p->b[1] = 4; +} + +void warn_char_array_assign_interior (struct Char *p) +{ + sink (p->a); + + p->a[0] = 1; + p->a[1] = 2; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" + /* Warnings are only suppressed for trailing arrays. Verify + one is issued for an interior array. */ + p->a[2] = 5; // { dg-warning "\\\[-Wstringop-overflow" } +#pragma GCC diagnostic pop +} + +void warn_char_array_assign_trailing (struct Char *p) +{ + /* This is separated from warn_char_array_assign_interior because + otherwise GCC removes the store to p->a[2] as dead since it's + overwritten by p->b[0]. */ + sink (p->b); + + p->b[0] = 3; + p->b[1] = 4; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" + /* Warnings are only suppressed for trailing arrays with at most + one element. Verify one is issued for a two-element array. */ + p->b[2] = 5; // { dg-warning "\\\[-Wstringop-overflow" } +#pragma GCC diagnostic pop +} + + +/* Also verify there's no warning for other types than char (even though + the problem was limited to chars and -Wstringop-overflow should only + trigger for character accesses). */ + +struct Short +{ + int i; + short c, d, e, f; + short a[2], b[2]; +}; + +void nowarn_short_assign (struct Short *p) +{ + sink (&p->c); + + p->c = 1; + p->d = 2; + p->e = 3; + p->f = 4; +} + +void nowarn_short_array_assign (struct Short *p) +{ + sink (p->a); + + p->a[0] = 1; + p->a[1] = 2; + p->b[0] = 3; + p->b[1] = 4; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-66.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-66.c new file mode 100644 index 0000000000..0ecf51149e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-66.c @@ -0,0 +1,180 @@ +/* PR middle-end/97631 - bogus "writing one too many bytes" warning for + memcpy with strlen argument + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define NOIPA __attribute__ ((noipa)) + +typedef __SIZE_TYPE__ size_t; + +extern void* malloc (size_t); +extern void* memcpy (void*, const void*, size_t); +extern void* memmove (void*, const void*, size_t); +extern void* memset (void*, int, size_t); +extern char* strcpy (char*, const char*); +extern char* strncpy (char*, const char*, size_t); +extern size_t strlen (const char*); + + +NOIPA char* nowarn_strcpy (char *s) +{ + size_t n = strlen (s); + char *d = malloc (n + 1); + strcpy (d, s); + return d; +} + + +NOIPA char* warn_strcpy (char *s) +{ + size_t n = strlen (s); + char *d = malloc (n); + strcpy (d, s); // { dg-warning "\\\[-Wstringop-overflow" } + return d; +} + +NOIPA char* warn_strcpy_nz (char *s) +{ + size_t n = strlen (s); + if (n == 0) + return 0; + + char *d = malloc (n); + strcpy (d, s); // { dg-warning "\\\[-Wstringop-overflow" } + return d; +} + +NOIPA char* warn_strcpy_nn (char *s) +{ + size_t n = strlen (s); + char *d = malloc (n); + if (!d) + return 0; + + strcpy (d, s); // { dg-warning "\\\[-Wstringop-overflow" } + return d; +} + +NOIPA char* warn_strcpy_nz_nn (char *s) +{ + size_t n = strlen (s); + if (n == 0) + return 0; + + char *d = malloc (n); + if (!d) + return 0; + + strcpy (d, s); // { dg-warning "\\\[-Wstringop-overflow" } + return d; +} + + +NOIPA char* nowarn_strncpy_1 (char *s) +{ + /* There's no overflow or truncation below so verify there is no + warning either. */ + size_t n = strlen (s) + 1; + char *d = malloc (n); + strncpy (d, s, n); + return d; +} + + +NOIPA char* warn_strncpy (char *s) +{ + size_t n = strlen (s); + char *d = malloc (n); + strncpy (d, s, n); // { dg-warning "\\\[-Wstringop-truncation" } + return d; +} + +NOIPA char* warn_strncpy_p1 (char *s) +{ + size_t n = strlen (s); + char *d = malloc (n + 1); + strncpy (d, s, n); // { dg-warning "\\\[-Wstringop-truncation" } + return d; +} + +NOIPA char* warn_strncpy_nz (char *s) +{ + size_t n = strlen (s); + if (n == 0) + return 0; + + char *d = malloc (n); + strncpy (d, s, n); // { dg-warning "\\\[-Wstringop-truncation" } + return d; + +} + + +NOIPA char* nowarn_memcpy (char *s) +{ + size_t n = strlen (s); + char *d = malloc (n); + memcpy (d, s, n); // { dg-bogus "\\\[-Wstringop-overflow" } + return d; +} + +NOIPA char* nowarn_memcpy_nz (char *s) +{ + size_t n = strlen (s); + if (n == 0) + return 0; + + char *d = malloc (n); + memcpy (d, s, n); // { dg-bogus "\\\[-Wstringop-overflow" } + return d; +} + +NOIPA char* nowarn_memcpy_nn (char *s) +{ + size_t n = strlen (s); + char *d = malloc (n); + if (!d) + return 0; + + memcpy (d, s, n); // { dg-bogus "\\\[-Wstringop-overflow" } + return d; +} + +NOIPA char* nowarn_memcpy_nn_nz (char *s) +{ + size_t n = strlen (s); + if (n == 0) + return 0; + + char *d = malloc (n); + if (!d) + return 0; + + memcpy (d, s, n); // { dg-bogus "\\\[-Wstringop-overflow" } + return d; + +} + + +NOIPA char* nowarn_memmove (char *s) +{ + size_t n = strlen (s); + if (n == 0) + return 0; + + char *d = malloc (n); + memmove (d, s, n); // { dg-bogus "\\\[-Wstringop-overflow" } + return d; +} + + +NOIPA char* nowarn_memset (char *s, int c) +{ + size_t n = strlen (s); + if (n == 0) + return 0; + + char *d = malloc (n); + memset (d, c, n); // { dg-bogus "\\\[-Wstringop-overflow" } + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-67.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-67.c new file mode 100644 index 0000000000..0f01082ede --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-67.c @@ -0,0 +1,93 @@ +/* PR middle-end/100571 - bogus -Wstringop-overflow with VLA of elements + larger than byte + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +__attribute__ ((access (read_only, 1, 2))) void fro (int *, int); +__attribute__ ((access (write_only, 1, 2))) void fwo (int *, int); +__attribute__ ((access (read_write, 1, 2))) void frw (int *, int); + +extern __SIZE_TYPE__ n; + +void alloca_ro (void) +{ + int *a = __builtin_alloca (n * sizeof *a); + a[0] = 0; + fro (a, n); +} + +void alloca_wo (void) +{ + int *a = __builtin_alloca (n * sizeof *a); + fwo (a, n); +} + +void alloca_rw (void) +{ + int *a = __builtin_alloca (n * sizeof *a); + a[0] = 0; + frw (a, n); +} + + +void calloc_ro (void) +{ + int *a = __builtin_calloc (n, sizeof *a); + fro (a, n); +} + +void calloc_wo (void) +{ + int *a = __builtin_calloc (n, sizeof *a); + fwo (a, n); +} + +void calloc_rw (void) +{ + int *a = __builtin_calloc (n, sizeof *a); + a[0] = 0; + frw (a, n); +} + + +void malloc_ro (void) +{ + int *a = __builtin_malloc (n * sizeof *a); + a[0] = 0; + fro (a, n); +} + +void malloc_wo (void) +{ + int *a = __builtin_malloc (n * sizeof *a); + fwo (a, n); +} + +void malloc_rw (void) +{ + int *a = __builtin_malloc (n * sizeof *a); + a[0] = 0; + frw (a, n); +} + + +void vla_ro (void) +{ + int a[n]; + a[0] = 0; + fro (a, n); +} + +void vla_wo (void) +{ + int a[n]; + fwo (a, n); +} + +void vla_rw (void) +{ + int a[n]; + a[0] = 0; + frw (a, n); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-68.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-68.c new file mode 100644 index 0000000000..4d132394f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-68.c @@ -0,0 +1,112 @@ +/* PR tree-optimization/97027 - missing warning on buffer overflow storing + a larger scalar into a smaller array + Verify overflow by aggregate stores. + { dg-do compile } + { dg-options "-O2 -fno-tree-vectorize" } */ + +#define A(N) (A ## N) +#define Ac1 (AC1){ 0 } +#define Ac2 (AC2){ 0, 1 } +#define Ac4 (AC4){ 0, 1, 2, 3 } +#define Ac8 (AC8){ 0, 1, 2, 3, 4, 5, 6, 7 } +#define Ac16 (AC16){ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } + +typedef struct AC1 { char a[1]; } AC1; +typedef struct AC2 { char a[2]; } AC2; +typedef struct AC3 { char a[3]; } AC3; +typedef struct AC4 { char a[4]; } AC4; +typedef struct AC5 { char a[5]; } AC5; +typedef struct AC8 { char a[8]; } AC8; +typedef struct AC16 { char a[16]; } AC16; + +extern char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8], a15[15]; + +extern AC1 ac1; +extern AC2 ac2; +extern AC4 ac4; +extern AC8 ac8; +extern AC16 ac16; + +extern AC1 fac1 (void); +extern AC2 fac2 (void); +extern AC4 fac4 (void); +extern AC8 fac8 (void); +extern AC16 fac16 (void); + +void nowarn (void) +{ + *(AC1*)a1 = Ac1; + *(AC2*)a2 = Ac2; + *(AC4*)a4 = Ac4; + *(AC4*)a5 = Ac4; + *(AC4*)a6 = Ac4; + *(AC4*)a7 = Ac4; + *(AC8*)a8 = Ac8; + *(AC8*)a15 = Ac8; +} + +void warn_comp_lit_zero (void) +{ + *(AC2*)a1 = (AC2){ }; // { dg-warning "writing 2 bytes into a region of size 1" } + *(AC4*)a2 = (AC4){ }; // { dg-warning "writing 4 bytes into a region of size 2" } + *(AC4*)a3 = (AC4){ }; // { dg-warning "writing 4 bytes into a region of size 3" } + *(AC8*)a4 = (AC8){ }; // { dg-warning "writing 8 bytes into a region of size 4" } + *(AC8*)a7 = (AC8){ }; // { dg-warning "writing 8 bytes into a region of size 7" } + *(AC16*)a15 = (AC16){ };// { dg-warning "writing 16 bytes into a region of size 15" } +} + +void warn_comp_lit (void) +{ + /* Ideally only one warning would be issued for each of the stores + mentioning the size of the rest of the source being assigned to + the destination that doesn't fit. But without vectorization + the assignment is a series of one-character stores, except in + the first instance multiple warnings end up being issued for + each assignment, each saying "writing 1 byte into a region of + size 0". That's suboptimal and should be improved. See also + PR 92110. */ + *(AC2*)a1 = Ac2; // { dg-warning "writing (2 bytes|1 byte) into a region of size (1|0)" "pr101475" } + *(AC4*)a2 = Ac4; // { dg-warning "writing (4 bytes|1 byte) into a region of size (2|0)" "pr101475" } + *(AC4*)a3 = Ac4; // { dg-warning "writing (4 bytes|1 byte) into a region of size (3|0)" "pr101475" } + *(AC8*)a4 = Ac8; // { dg-warning "writing (8 bytes|1 byte) into a region of size (4|0)" "pr101475" } + *(AC8*)a7 = Ac8; // { dg-warning "writing (8 bytes|1 byte) into a region of size (7|0)" "pr101475" } + *(AC16*)a15 = Ac16; // { dg-warning "writing (16 bytes|1 byte) into a region of size (15|0)" "pr101475" } +} + +void warn_aggr_decl (void) +{ + *(AC2*)a1 = ac2; // { dg-warning "writing 2 bytes into a region of size 1" } + *(AC4*)a2 = ac4; // { dg-warning "writing 4 bytes into a region of size 2" } + *(AC4*)a3 = ac4; // { dg-warning "writing 4 bytes into a region of size 3" } + *(AC8*)a4 = ac8; // { dg-warning "writing 8 bytes into a region of size 4" } + *(AC8*)a7 = ac8; // { dg-warning "writing 8 bytes into a region of size 7" } + *(AC16*)a15 = ac16; // { dg-warning "writing 16 bytes into a region of size 15" } +} + +void warn_aggr_parm (AC2 pc2, AC4 pc4, AC8 pc8, AC16 pc16) +{ + *(AC2*)a1 = pc2; // { dg-warning "writing 2 bytes into a region of size 1" } + *(AC4*)a2 = pc4; // { dg-warning "writing 4 bytes into a region of size 2" } + *(AC4*)a3 = pc4; // { dg-warning "writing 4 bytes into a region of size 3" } + *(AC8*)a4 = pc8; // { dg-warning "writing 8 bytes into a region of size 4" } + *(AC8*)a7 = pc8; // { dg-warning "writing 8 bytes into a region of size 7" } + *(AC16*)a15 = pc16; // { dg-warning "writing 16 bytes into a region of size 15" } +} + +void warn_aggr_func (void) +{ + *(AC2*)a1 = fac2 (); // { dg-warning "writing 2 bytes into a region of size 1" } + *(AC4*)a2 = fac4 (); // { dg-warning "writing 4 bytes into a region of size 2" } + *(AC4*)a3 = fac4 (); // { dg-warning "writing 4 bytes into a region of size 3" } + *(AC8*)a4 = fac8 (); // { dg-warning "writing 8 bytes into a region of size 4" } + *(AC8*)a7 = fac8 (); // { dg-warning "writing 8 bytes into a region of size 7" } + *(AC16*)a15 = fac16 ();// { dg-warning "writing 16 bytes into a region of size 15" } + + extern AC2 fac2_x (); + + *(AC2*)a1 = fac2_x (); // { dg-warning "writing 2 bytes into a region of size 1" } + + extern AC2 fac2_p (char*); + + *(AC2*)a1 = fac2_p (0); // { dg-warning "writing 2 bytes into a region of size 1" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-69.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-69.c new file mode 100644 index 0000000000..be361fe620 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-69.c @@ -0,0 +1,84 @@ +/* PR tree-optimization/97027 - missing warning on buffer overflow storing + a larger scalar into a smaller array + Verify overflow by vector stores. + { dg-do compile } + { dg-options "-O2 -Wno-psabi" } */ + +#define V(N) __attribute__ ((vector_size (N))) +#define C1 (VC1){ 0 } +#define C2 (VC2){ 0, 1 } +#define C4 (VC4){ 0, 1, 2, 3 } +#define C8 (VC8){ 0, 1, 2, 3, 4, 5, 6, 7 } +#define C16 (VC16){ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } + +typedef V (1) char VC1; +typedef V (2) char VC2; +typedef V (4) char VC4; +typedef V (8) char VC8; +typedef V (16) char VC16; + +extern char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8], a15[15]; + +extern VC1 c1; +extern VC2 c2; +extern VC4 c4; +extern VC8 c8; +extern VC16 c16; + +extern VC1 fc1 (void); +extern VC2 fc2 (void); +extern VC4 fc4 (void); +extern VC8 fc8 (void); +extern VC16 fc16 (void); + +void nowarn (void) +{ + *(VC1*)a1 = C1; + *(VC2*)a2 = C2; + *(VC4*)a4 = C4; + *(VC4*)a5 = C4; + *(VC4*)a6 = C4; + *(VC4*)a7 = C4; + *(VC8*)a8 = C8; + *(VC8*)a15 = C8; +} + +void warn_vec_lit (void) +{ + *(VC2*)a1 = C2; // { dg-warning "writing 2 bytes into a region of size 1" } + *(VC4*)a2 = C4; // { dg-warning "writing 4 bytes into a region of size 2" } + *(VC4*)a3 = C4; // { dg-warning "writing 4 bytes into a region of size 3" } + *(VC8*)a4 = C8; // { dg-warning "writing 8 bytes into a region of size 4" } + *(VC8*)a7 = C8; // { dg-warning "writing 8 bytes into a region of size 7" } + *(VC16*)a15 = C16; // { dg-warning "writing 16 bytes into a region of size 15" } +} + +void warn_vec_decl (void) +{ + *(VC2*)a1 = c2; // { dg-warning "writing 2 bytes into a region of size 1" } + *(VC4*)a2 = c4; // { dg-warning "writing 4 bytes into a region of size 2" } + *(VC4*)a3 = c4; // { dg-warning "writing 4 bytes into a region of size 3" } + *(VC8*)a4 = c8; // { dg-warning "writing 8 bytes into a region of size 4" } + *(VC8*)a7 = c8; // { dg-warning "writing 8 bytes into a region of size 7" } + *(VC16*)a15 = c16; // { dg-warning "writing 16 bytes into a region of size 15" } +} + +void warn_vec_parm (VC2 pc2, VC4 pc4, VC8 pc8, VC16 pc16) +{ + *(VC2*)a1 = pc2; // { dg-warning "writing 2 bytes into a region of size 1" } + *(VC4*)a2 = pc4; // { dg-warning "writing 4 bytes into a region of size 2" } + *(VC4*)a3 = pc4; // { dg-warning "writing 4 bytes into a region of size 3" } + *(VC8*)a4 = pc8; // { dg-warning "writing 8 bytes into a region of size 4" } + *(VC8*)a7 = pc8; // { dg-warning "writing 8 bytes into a region of size 7" } + *(VC16*)a15 = pc16; // { dg-warning "writing 16 bytes into a region of size 15" } +} + +void warn_vec_func (void) +{ + *(VC2*)a1 = fc2 (); // { dg-warning "writing 2 bytes into a region of size 1" } + *(VC4*)a2 = fc4 (); // { dg-warning "writing 4 bytes into a region of size 2" } + *(VC4*)a3 = fc4 (); // { dg-warning "writing 4 bytes into a region of size 3" } + *(VC8*)a4 = fc8 (); // { dg-warning "writing 8 bytes into a region of size 4" } + *(VC8*)a7 = fc8 (); // { dg-warning "writing 8 bytes into a region of size 7" } + *(VC16*)a15 = fc16 ();// { dg-warning "writing 16 bytes into a region of size 15" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-7.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-7.c new file mode 100644 index 0000000000..cb2addf3af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-7.c @@ -0,0 +1,124 @@ +/* Test to verify that --param ssa_name_def_chain_limit can be used to + limit the maximum number of SSA_NAME assignments the warning follows. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds --param ssa-name-def-chain-limit=5" } */ + +#define NOIPA __attribute__ ((noipa)) + +void* memset (void*, int, __SIZE_TYPE__); + +char a9[9]; + +void sink (const char*, ...); + +NOIPA void g2 (int i) +{ + if (i < 1) i = 1; + + char *p0 = a9; + char *p1 = p0 + i; + char *p2 = p1 + i; + + sink (p0, p1, p2); + + memset (p2, 0, 8); // { dg-warning "\\\[-Wstringop-overflow" } +} + +NOIPA void g3 (int i) +{ + if (i < 1) i = 1; + + char *p0 = a9; + char *p1 = p0 + i; + char *p2 = p1 + i; + char *p3 = p2 + i; + + sink (p0, p1, p2, p3); + + memset (p3, 0, 7); // { dg-warning "\\\[-Wstringop-overflow" } +} + +NOIPA void g4 (int i) +{ + if (i < 1) i = 1; + + char *p0 = a9; + char *p1 = p0 + i; + char *p2 = p1 + i; + char *p3 = p2 + i; + char *p4 = p3 + i; + + sink (p0, p1, p2, p3, p4); + + memset (p4, 0, 6); // { dg-warning "\\\[-Wstringop-overflow" } +} + +NOIPA void g5 (int i) +{ + if (i < 1) i = 1; + + char *p0 = a9; + char *p1 = p0 + i; + char *p2 = p1 + i; + char *p3 = p2 + i; + char *p4 = p3 + i; + char *p5 = p4 + i; + + sink (p0, p1, p2, p3, p4, p5); + + memset (p5, 0, 5); // { dg-warning "\\\[-Wstringop-overflow" } +} + +NOIPA void g6 (int i) +{ + if (i < 1) i = 1; + + char *p0 = a9; + char *p1 = p0 + i; + char *p2 = p1 + i; + char *p3 = p2 + i; + char *p4 = p3 + i; + char *p5 = p4 + i; + char *p6 = p5 + i; + + sink (p0, p1, p2, p3, p4, p5, p6); + + memset (p6, 0, 4); +} + +NOIPA void g7 (int i) +{ + if (i < 1) i = 1; + + char *p0 = a9; + char *p1 = p0 + i; + char *p2 = p1 + i; + char *p3 = p2 + i; + char *p4 = p3 + i; + char *p5 = p4 + i; + char *p6 = p5 + i; + char *p7 = p6 + i; + + sink (p0, p1, p2, p3, p4, p5, p6, p7); + + memset (p7, 0, 4); +} + +NOIPA void g8 (int i) +{ + if (i < 1) i = 1; + + char *p0 = a9; + char *p1 = p0 + i; + char *p2 = p1 + i; + char *p3 = p2 + i; + char *p4 = p3 + i; + char *p5 = p4 + i; + char *p6 = p5 + i; + char *p7 = p6 + i; + char *p8 = p7 + i; + + sink (p0, p1, p2, p3, p4, p5, p6, p7, p8); + + memset (p8, 0, 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-70.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-70.c new file mode 100644 index 0000000000..ccfe2cefd1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-70.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/97027 - missing warning on buffer overflow storing + a larger scalar into a smaller array + Verify overflow by vector stores. + { dg-do compile } + { dg-options "-O3" } */ + +void* nowarn_loop (void) +{ + char *p = __builtin_malloc (16); + for (int i = 0; i != 16; ++i) + p[i] = i; + return p; +} + +void* warn_loop (void) +{ + char *p = __builtin_malloc (15); + for (int i = 0; i != 16; ++i) + /* The size of the write below depends on the target. When vectorized + the vector size may be 4, 8 or 16, otherwise it may be a series of byte + assignments. */ + p[i] = i; // { dg-warning "writing (1|2|4|8|16) bytes? into a region of size (0|1|3|7|15)" } + return p; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-71.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-71.c new file mode 100644 index 0000000000..74311ecf7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-71.c @@ -0,0 +1,114 @@ +/* PR tree-optimization/97027 - missing warning on buffer overflow storing + a larger scalar into a smaller array + Verify warnings for overflow by stores of results of built-in functions. + { dg-do compile } + { dg-options "-O2" } + { dg-require-effective-target alloca } */ + +typedef __INT16_TYPE__ int16_t; +typedef __SIZE_TYPE__ size_t; + +extern int abs (int); + +extern void* alloca (size_t); + +extern double nan (const char *); + +#ifdef __DEC32_MAX__ + _Decimal32 nand32 (const char *); +#else +/* _Decimal32 is supported only conditionally and not available on all + targets. */ +# define _Decimal32 double +# define nand32(s) nan (s) +#endif + +extern size_t strlen (const char *); +extern char* strcpy (char *, const char *); + + +extern unsigned char ax[], a1[1], a2[2], a8[8]; + + +void nowarn_abs (int i) +{ + *(int *)ax = abs (i); + *(char *)a1 = abs (i); +} + +void warn_abs (int i) +{ + *(int *)a1 = abs (i); // { dg-warning "\\\[-Wstringop-overflow" } +} + + +void nowarn_alloca (size_t n) +{ + *(void **)ax = alloca (n); +} + +void warn_alloca (size_t n) +{ + *(void **)a1 = alloca (n); // { dg-warning "\\\[-Wstringop-overflow" } +} + + +void nowarn_complex (double x, double i) +{ + *(_Complex double *)ax = __builtin_complex (x, i); +} + +void warn_complex (double x, double i) +{ + _Complex double *p = (_Complex double *)a1; + *p = __builtin_complex (x, i); // { dg-warning "\\\[-Wstringop-overflow" "pr101455" { xfail *-*-* } } +} + + +__attribute__ ((noipa)) void nowarn_nan (const char *s) +{ + *(double *)ax = nan (s); +} + +__attribute__ ((noipa)) void warn_nan (const char *s) +{ + *(double *)a1 = nan (s); // { dg-warning "\\\[-Wstringop-overflow" } +} + + +__attribute__ ((noipa)) void nowarn_nand32 (const char *s) +{ + *(_Decimal32 *)ax = nand32 (s); +} + +__attribute__ ((noipa)) void warn_nand32 (const char *s) +{ + *(_Decimal32 *)a1 = nand32 (s); // { dg-warning "\\\[-Wstringop-overflow" } +} + + +void nowarn_strlen (const char *s1, const char *s2, const char *s3) +{ + *(char *)ax = strlen (s1); + *(char *)a1 = strlen (s2); + *(size_t *)a8 = strlen (s3); +} + +void warn_strlen (const char *s1, const char *s2) +{ + *(int16_t *)a1 = strlen (s1); // { dg-warning "\\\[-Wstringop-overflow" } + *(size_t *)a2 = strlen (s2); // { dg-warning "\\\[-Wstringop-overflow" "!ptr_eq_short" { target { ! ptr_eq_short } } } +} + + +void nowarn_strcpy (char *s1, char *s2, const char *s3) +{ + *(char **)ax = strcpy (s1, s2); + *(char **)a8 = strcpy (s2, s3); +} + +void warn_strcpy (char *s1, char *s2, const char *s3) +{ + *(char **)a1 = strcpy (s1, s2); // { dg-warning "\\\[-Wstringop-overflow" } + *(char **)a2 = strcpy (s2, s3); // { dg-warning "\\\[-Wstringop-overflow" "!ptr_eq_short" { target { ! ptr_eq_short } } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-72.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-72.c new file mode 100644 index 0000000000..c10773e90a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-72.c @@ -0,0 +1,13 @@ +/* PR middle-end/101854 - Invalid warning -Wstringop-overflow wrong argument + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct A { int a[5]; }; + +struct A g (int*, int[6][8]); + +struct A f (void) +{ + int a[2]; + return g (a, 0); // { dg-bogus "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-73.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-73.c new file mode 100644 index 0000000000..0bb4afecc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-73.c @@ -0,0 +1,35 @@ +/* + { dg-do compile } + { dg-options "-Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +int memcmp (const void*, const void*, size_t); +int strncmp (const char*, const char*, size_t); +char* stpncpy (char*, const char*, size_t); +char* strncpy (char*, const char*, size_t); + +extern char a4[4], b5[5]; + +struct A { char a4[4]; }; + +extern volatile int i; +extern void* volatile ptr; + +void test_stpncpy (struct A *p) +{ + ptr = stpncpy (a4, b5, 4); + ptr = stpncpy (a4, b5, 5); // { dg-warning "writing 5 bytes" } + + ptr = stpncpy (p->a4, b5, 4); + ptr = stpncpy (p->a4, b5, 5); // { dg-warning "writing 5 bytes" } +} + +void test_strncpy (struct A *p) +{ + ptr = strncpy (a4, b5, 4); + ptr = strncpy (a4, b5, 5); // { dg-warning "writing 5 bytes" } + + ptr = strncpy (p->a4, b5, 4); + ptr = strncpy (p->a4, b5, 5); // { dg-warning "writing 5 bytes" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-74.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-74.c new file mode 100644 index 0000000000..bacec964d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-74.c @@ -0,0 +1,22 @@ +/* PR middle-end/102200 - ICE on a min of a decl and pointer in a loop + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern char a[], n; + +void f (void) +{ + char *p = a; + size_t end = 1; + + while (n) + { + if (p < (char*)end) + *p = ';'; + + if (p > (char*)&end) + p = (char*)&end; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-75.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-75.c new file mode 100644 index 0000000000..9f9c3a9c2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-75.c @@ -0,0 +1,133 @@ +/* Verify warnings and notes for MIN_EXPRs involving either pointers + to distinct objects or one to a known object and the other to + an unknown one. The relational expressions are strictly invalid + but that should be diagnosed by a separate warning. + { dg-do compile } + { dg-options "-O2 -Wno-array-bounds" } */ + +/* Verify the note points to the larger of the two objects and mentions + the offset into it (although the offset might be better included in + the warning). */ +extern char a3[3]; +extern char a5[5]; // { dg-message "at offset \[^a-zA-Z\n\r\]*5\[^a-zA-Z0-9\]* into destination object 'a5' of size 5" "note" } + +void min_a3_a5 (int i) +{ + char *p = a3 + i; + char *q = a5 + i; + + /* The relational expression below is invalid and should be diagnosed + by its own warning independently of -Wstringop-overflow. */ + char *d = p < q ? p : q; + + d[4] = 0; // { dg-warning "writing 2 bytes into a region of size 1" "" { target { vect_slp_v2qi_store_unalign } } } + d[5] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +// Same as above but with the larger array as the first MIN_EXPR operand. +extern char b4[4]; +extern char b6[6]; // { dg-message "at offset \[^a-zA-Z\n\r\]*6\[^a-zA-Z0-9\]* into destination object 'b6' of size 6" "note" } + +void min_b6_b4 (int i) +{ + char *p = b6 + i; + char *q = b4 + i; + char *d = p < q ? p : q; + + d[5] = 0; // { dg-warning "writing 2 bytes into a region of size 1" "" { target { vect_slp_v2qi_store_unalign } } } + d[6] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +/* Same as above but with the first MIN_EXPR operand pointing to an unknown + object. */ +extern char c7[7]; // { dg-message "at offset 7 into destination object 'c7' of size 7" "note" { xfail { vect_slp_v2qi_store_unalign } } } + +void min_p_c7 (char *p, int i) +{ + char *q = c7 + i; + char *d = p < q ? p : q; + + d[6] = 0; // { dg-warning "writing 2 bytes into a region of size 1" "" { target { vect_slp_v2qi_store_unalign } } } + d[7] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +/* Same as above but with the second MIN_EXPR operand pointing to an unknown + object. */ +extern char d8[8]; // { dg-message "at offset 8 into destination object 'd8' of size 8" "note" { xfail { vect_slp_v2qi_store_unalign } } } + +void min_d8_p (char *q, int i) +{ + char *p = d8 + i; + char *d = p < q ? p : q; + + d[7] = 0; // { dg-warning "writing 2 bytes into a region of size 1" "" { target { vect_slp_v2qi_store_unalign } } } + d[8] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +struct A3_5 +{ + char a3[3]; + char a5[5]; // { dg-message "at offset 5 into destination object 'a5' of size 5" "note" } +}; + +void min_A3_A5 (int i, struct A3_5 *pa3_5) +{ + char *p = pa3_5->a3 + i; + char *q = pa3_5->a5 + i; + + char *d = p < q ? p : q; + + // d[4] = 0; + d[5] = 0; // { dg-warning "writing 1 byte into a region of size 0" } +} + + +struct B4_B6 +{ + char b4[4]; + char b6[6]; // { dg-message "at offset 6 into destination object 'b6' of size 6" "note" { xfail { vect_slp_v2qi_store_unalign } } } +}; + +void min_B6_B4 (int i, struct B4_B6 *pb4_b6) +{ + char *p = pb4_b6->b6 + i; + char *q = pb4_b6->b4 + i; + char *d = p < q ? p : q; + + d[5] = 0; + d[6] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +struct C7 +{ + char c7[7]; // { dg-message "at offset 7 into destination object 'c7' of size 7" "note" { xfail { vect_slp_v2qi_store_unalign } } } +}; + +void min_p_C7 (char *p, int i, struct C7 *pc7) +{ + char *q = pc7->c7 + i; + char *d = p < q ? p : q; + + d[6] = 0; + d[7] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +struct D8 +{ + char d8[8]; // { dg-message "at offset 8 into destination object 'd8' of size 8" "note" { xfail { vect_slp_v2qi_store_unalign } } } +}; + +void min_D8_p (char *q, int i, struct D8 *pd8) +{ + char *p = pd8->d8 + i; + char *d = p < q ? p : q; + + d[7] = 0; + d[8] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-76-novec.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-76-novec.c new file mode 100644 index 0000000000..71c643b62f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-76-novec.c @@ -0,0 +1,88 @@ +/* Verify warnings and notes for MAX_EXPRs involving either pointers + to distinct objects or one to a known object and the other to + an unknown one. Unlike for the same object, for unrelated objects + the expected warnings and notes are the same as for MIN_EXPR: when + the order of the objects in the address space cannot be determined + the larger of them is assumed to be used. (This is different for + distinct struct members where the order is given.) + The relational expressions are strictly invalid but that should be + diagnosed by a separate warning. + { dg-do compile } + { dg-options "-O2 -Wno-array-bounds -fno-tree-vectorize" } */ + +#define MAX(p, q) ((p) > (q) ? (p) : (q)) + +/* Verify that even for MAX_EXPR and like for MIN_EXPR, the note points + to the larger of the two objects and mentions the offset into it + (although the offset might be better included in the warning). */ +extern char a3[3]; +extern char a5[5]; // { dg-message "at offset 5 into destination object 'a5' of size 5" "note" } + +void max_a3_a5 (int i) +{ + char *p = a3 + i; + char *q = a5 + i; + + /* The relational expression below is invalid and should be diagnosed + by its own warning independently of -Wstringop-overflow. */ + char *d = MAX (p, q); + + d[2] = 0; + d[3] = 0; + d[4] = 0; + d[5] = 0; // { dg-warning "writing 1 byte into a region of size 0" } +} + + +// Same as above but with the larger array as the first MAX_EXPR operand. +extern char b4[4]; +extern char b6[6]; // { dg-message "at offset 6 into destination object 'b6' of size 6" "note" } + +void max_b6_b4 (int i) +{ + char *p = b6 + i; + char *q = b4 + i; + char *d = MAX (p, q); + + d[3] = 0; + d[4] = 0; + d[5] = 0; + d[6] = 0; // { dg-warning "writing 1 byte into a region of size 0" } +} + +struct A3_5 +{ + char a3[3]; // { dg-message "at offset 3 into destination object 'a3' of size 3" "pr??????" { xfail *-*-* } } + char a5[5]; // { dg-message "at offset 5 into destination object 'a5' of size 5" "note" } +}; + +void max_A3_A5 (int i, struct A3_5 *pa3_5) +{ + char *p = pa3_5->a3 + i; + char *q = pa3_5->a5 + i; + + char *d = MAX (p, q); + d[2] = 0; + d[3] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr??????" { xfail *-*-* } } + d[4] = 0; + d[5] = 0; // { dg-warning "writing 1 byte into a region of size 0" } +} + + +struct B4_B6 +{ + char b4[4]; + char b6[6]; // { dg-message "at offset 6 into destination object 'b6' of size 6" "note" } +}; + +void max_B6_B4 (int i, struct B4_B6 *pb4_b6) +{ + char *p = pb4_b6->b6 + i; + char *q = pb4_b6->b4 + i; + char *d = MAX (p, q); + + d[3] = 0; + d[4] = 0; + d[5] = 0; + d[6] = 0; // { dg-warning "writing 1 byte into a region of size 0" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-76.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-76.c new file mode 100644 index 0000000000..d5cf8662c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-76.c @@ -0,0 +1,150 @@ +/* Verify warnings and notes for MAX_EXPRs involving either pointers + to distinct objects or one to a known object and the other to + an unknown one. Unlike for the same object, for unrelated objects + the expected warnings and notes are the same as for MIN_EXPR: when + the order of the objects in the address space cannot be determined + the larger of them is assumed to be used. (This is different for + distinct struct members where the order is given.) + The relational expressions are strictly invalid but that should be + diagnosed by a separate warning. + { dg-do compile } + { dg-options "-O2 -Wno-array-bounds" } */ + +#define MAX(p, q) ((p) > (q) ? (p) : (q)) + +/* Verify that even for MAX_EXPR and like for MIN_EXPR, the note points + to the larger of the two objects and mentions the offset into it + (although the offset might be better included in the warning). */ +extern char a3[3]; +extern char a5[5]; // { dg-message "at offset \[^a-zA-Z\n\r\]*5\[^a-zA-Z0-9\]* into destination object 'a5' of size 5" "note" } + +void max_a3_a5 (int i) +{ + char *p = a3 + i; + char *q = a5 + i; + + /* The relational expression below is invalid and should be diagnosed + by its own warning independently of -Wstringop-overflow. */ + char *d = MAX (p, q); + + d[2] = 0; // { dg-warning "writing 4 bytes into a region of size 3" "pr102706" { target { vect_slp_v4qi_store_unalign } } } + d[3] = 0; + d[4] = 0; + d[5] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr102706" { xfail { vect_slp_v4qi_store_unalign } } } +} + + +// Same as above but with the larger array as the first MAX_EXPR operand. +extern char b4[4]; +extern char b6[6]; // { dg-message "at offset \[^a-zA-Z\n\r\]*6\[^a-zA-Z0-9\]* into destination object 'b6' of size 6" "note" } + +void max_b6_b4 (int i) +{ + char *p = b6 + i; + char *q = b4 + i; + char *d = MAX (p, q); + + d[3] = 0; // { dg-warning "writing 4 bytes into a region of size 3" "pr102706" { target { vect_slp_v4qi_store_unalign } } } + d[4] = 0; + d[5] = 0; + d[6] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr102706" { xfail { vect_slp_v4qi_store_unalign } } } +} + + +/* Same as above but with the first MAX_EXPR operand pointing to an unknown + object. */ +extern char c7[7]; // { dg-message "at offset 7 into destination object 'c7' of size 7" "note" { xfail { vect_slp_v2qi_store_unalign } } } + +void max_p_c7 (char *p, int i) +{ + char *q = c7 + i; + char *d = MAX (p, q); + + d[6] = 0; // { dg-warning "writing 2 bytes into a region of size 1" "" { target { vect_slp_v2qi_store_unalign } } } + d[7] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +/* Same as above but with the second MIN_EXPR operand pointing to an unknown + object. */ +extern char d8[8]; // { dg-message "at offset 8 into destination object 'd8' of size 8" "note" { xfail { vect_slp_v2qi_store_unalign } } } + +void max_d8_p (char *q, int i) +{ + char *p = d8 + i; + char *d = MAX (p, q); + + d[7] = 0; // { dg-warning "writing 2 bytes into a region of size 1" "" { target { vect_slp_v2qi_store_unalign } } } + d[8] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +struct A3_5 +{ + char a3[3]; // { dg-message "at offset 3 into destination object 'a3' of size 3" "pr??????" { xfail *-*-* } } + // refer to pr102697 for xfail + char a5[5]; // { dg-message "at offset 5 into destination object 'a5' of size 5" "note" { xfail { vect_slp_v4qi_store_unalign } } } +}; + +void max_A3_A5 (int i, struct A3_5 *pa3_5) +{ + char *p = pa3_5->a3 + i; + char *q = pa3_5->a5 + i; + + char *d = MAX (p, q); + + d[2] = 0; + d[3] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr??????" { xfail *-*-* } } + d[4] = 0; + d[5] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr102697" { xfail { vect_slp_v4qi_store_unalign } } } +} + + +struct B4_B6 +{ + char b4[4]; + // refer to pr102697 for xfail + char b6[6]; // { dg-message "at offset \[^a-zA-Z\n\r\]*6\[^a-zA-Z0-9\]* into destination object 'b6' of size 6" "note" { xfail { vect_slp_v4qi_store_unalign } } } +}; + +void max_B6_B4 (int i, struct B4_B6 *pb4_b6) +{ + char *p = pb4_b6->b6 + i; + char *q = pb4_b6->b4 + i; + char *d = MAX (p, q); + + d[3] = 0; + d[4] = 0; + d[5] = 0; + d[6] = 0; // { dg-warning "writing 1 byte into a region of size 0" "pr102697" { xfail { vect_slp_v4qi_store_unalign } } } +} + + +struct C7 +{ + char c7[7]; // { dg-message "at offset 7 into destination object 'c7' of size 7" "note" { xfail { vect_slp_v2qi_store_unalign } } } +}; + +void max_p_C7 (char *p, int i, struct C7 *pc7) +{ + char *q = pc7->c7 + i; + char *d = MAX (p, q); + + d[6] = 0; + d[7] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} + + +struct D8 +{ + char d8[8]; // { dg-message "at offset 8 into destination object 'd8' of size 8" "note" { xfail { vect_slp_v2qi_store_unalign } } } +}; + +void max_D8_p (char *q, int i, struct D8 *pd8) +{ + char *p = pd8->d8 + i; + char *d = MAX (p, q); + + d[7] = 0; + d[8] = 0; // { dg-warning "writing 1 byte into a region of size 0" "" { xfail { vect_slp_v2qi_store_unalign } } } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-77.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-77.c new file mode 100644 index 0000000000..732f56849a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-77.c @@ -0,0 +1,516 @@ +/* PR middle-end/102453 - buffer overflow by atomic built-ins not diagnosed + Verify that out-of-bounds accesses by atomic functions are diagnosed with + optimization disabled. + { dg-do compile } + { dg-options "-O0 -Wall -ftrack-macro-expansion=0" } */ + +#ifndef __cplusplus +# define bool _Bool +#endif + +#define add_fetch(p, q) __atomic_add_fetch (p, q, 0) +#define sub_fetch(p, q) __atomic_sub_fetch (p, q, 0) +#define and_fetch(p, q) __atomic_and_fetch (p, q, 0) +#define or_fetch(p, q) __atomic_or_fetch (p, q, 0) +#define xor_fetch(p, q) __atomic_xor_fetch (p, q, 0) +#define nand_fetch(p, q) __atomic_nand_fetch (p, q, 0) +#define exchange(p, q, r) __atomic_exchange (p, q, r, 0) +#define exchange_n(p, n) __atomic_exchange_n (p, n, 0) +#define cmpxchg(p, q, r) __atomic_compare_exchange (p, q, r, 0, 0, 0) + +typedef __SIZE_TYPE__ size_t; + +void sink (void*, ...); +#define sink(...) sink (0, __VA_ARGS__) + +extern _Bool eb; +extern char ec; +extern short int esi; +extern int ei; +extern long int eli; +extern long long int elli; + +extern const _Bool ecb; +extern const char ecc; +extern const short int ecsi; +extern const int eci; +extern const long int ecli; +extern const long long int eclli; + +extern _Atomic _Bool eab; +extern _Atomic char eac; +extern _Atomic short int easi; +extern _Atomic int eai; +extern _Atomic long int eali; +extern _Atomic long long int ealli; + +extern _Atomic const _Bool eacb; +extern _Atomic const char eacc; +extern _Atomic const short int eacsi; +extern _Atomic const int eaci; +extern _Atomic const long int eacli; +extern _Atomic const long long int eaclli; + + +void nowarn_atomic_add_fetch (void) +{ + add_fetch (&eac, ecc); + add_fetch (&easi, esi); + add_fetch (&eai, ei); + add_fetch (&eali, eli); + add_fetch (&ealli, elli); +} + + +void warn_atomic_add_fetch (void) +{ + _Atomic char *pc = &eac + 1; + add_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + add_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + add_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + add_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + add_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + add_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + add_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + add_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + add_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + add_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + add_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + add_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +void nowarn_atomic_sub_fetch (void) +{ + _Atomic char *pc = &eac; + sub_fetch (pc, ecc); + + _Atomic short *psi = &easi; + sub_fetch (psi, esi); + + _Atomic int *pi = &eai; + sub_fetch (pi, ei); + + _Atomic long *pli = &eali; + sub_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + sub_fetch (plli, elli); +} + + +void warn_atomic_sub_fetch (void) +{ + _Atomic char *pc = &eac + 1; + sub_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + sub_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + sub_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + sub_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + sub_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + sub_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + sub_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + sub_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + sub_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + sub_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + sub_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + sub_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +void nowarn_atomic_and_fetch (void) +{ + _Atomic char *pc = &eac; + and_fetch (pc, ecc); + + _Atomic short *psi = &easi; + and_fetch (psi, esi); + + _Atomic int *pi = &eai; + and_fetch (pi, ei); + + _Atomic long *pli = &eali; + and_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + and_fetch (plli, elli); +} + + +void warn_atomic_and_fetch (void) +{ + _Atomic char *pc = &eac + 1; + and_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + and_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + and_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + and_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + and_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + and_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + and_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + and_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + and_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + and_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + and_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + and_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +void nowarn_atomic_or_fetch (void) +{ + _Atomic char *pc = &eac; + or_fetch (pc, ecc); + + _Atomic short *psi = &easi; + or_fetch (psi, esi); + + _Atomic int *pi = &eai; + or_fetch (pi, ei); + + _Atomic long *pli = &eali; + or_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + or_fetch (plli, elli); +} + + +void warn_atomic_or_fetch (void) +{ + _Atomic char *pc = &eac + 1; + or_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + or_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + or_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + or_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + or_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + or_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + or_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + or_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + or_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + or_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + or_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + or_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +void nowarn_atomic_xor_fetch (void) +{ + _Atomic char *pc = &eac; + xor_fetch (pc, ecc); + + _Atomic short *psi = &easi; + xor_fetch (psi, esi); + + _Atomic int *pi = &eai; + xor_fetch (pi, ei); + + _Atomic long *pli = &eali; + xor_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + xor_fetch (plli, elli); +} + + +void warn_atomic_xor_fetch (void) +{ + _Atomic char *pc = &eac + 1; + xor_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + xor_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 1); + xor_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + xor_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + xor_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + xor_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + xor_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + xor_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + xor_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + xor_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&eali + 1); + xor_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + xor_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +void nowarn_atomic_nand_fetch (void) +{ + _Atomic char *pc = &eac; + nand_fetch (pc, ecc); + + _Atomic short *psi = &easi; + nand_fetch (psi, esi); + + _Atomic int *pi = &eai; + nand_fetch (pi, ei); + + _Atomic long *pli = &eali; + nand_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + nand_fetch (plli, elli); +} + + +void warn_atomic_nand_fetch (void) +{ + _Atomic char *pc = &eac + 1; + nand_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + nand_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 1); + nand_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + nand_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + nand_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + nand_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + nand_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + nand_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + nand_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + nand_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&eai + 1); + nand_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + nand_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +void nowarn_atomic_exchange (void) +{ + char rc; + _Atomic char *pc = &eac; + exchange (pc, &ecc, &rc); + + short rsi; + _Atomic short *psi = &easi; + exchange (psi, &esi, &rsi); + + int ri; + _Atomic int *pi = &eai; + exchange (pi, &ei, &ri); + + long rli; + _Atomic long *pli = &eali; + exchange (pli, &eli, &rli); + + long long rlli; + _Atomic long long *plli = &ealli; + exchange (plli, &elli, &rlli); + + sink (&rc, &rsi, &ri, &rli, &rlli); +} + +void warn_atomic_exchange (void) +{ + char rc; + _Atomic char *pc = &eac + 1; + exchange (pc, &ecc, &rc); // { dg-warning "-Wstringop-overflow" } + + short rsi[2]; + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + exchange (psi, &ecsi, rsi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + exchange (psi, &ecsi, rsi + 1); // { dg-warning "-Wstringop-overflow" } + + int ri[3]; + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + exchange (pi, &eci, ri); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + exchange (pi, &eci, ri + 1); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + exchange (pi, &eci, ri + 2); // { dg-warning "-Wstringop-overflow" } + + long rli[3]; + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + exchange (pli, &ecli, rli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + exchange (pli, &ecli, rli + 1); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + exchange (pli, &ecli, rli + 2); // { dg-warning "-Wstringop-overflow" } + + long long rlli[3]; + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + exchange (plli, &eclli, rlli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + exchange (plli, &eclli, rlli + 1); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + exchange (plli, &eclli, rlli + 2); // { dg-warning "-Wstringop-overflow" } + + sink (&rc, rsi, ri, rli, rlli); +} + + +void nowarn_atomic_exchange_n (_Atomic unsigned char *pauc, + _Atomic unsigned short *pausi, + _Atomic unsigned int *paui, + _Atomic unsigned long *pauli, + _Atomic unsigned long long *paulli) +{ + char rc = exchange_n (&eac, ecc); + short rsi = exchange_n (&easi, esi); + int ri = exchange_n (&eai, ei); + long rli = exchange_n (&eali, eli); + long long rlli = exchange_n (&ealli, elli); + + sink (rc, rsi, ri, rli, rlli); + + char ruc = exchange_n (pauc, ecc); + short rusi = exchange_n (pausi, esi); + int rui = exchange_n (paui, ei); + long ruli = exchange_n (pauli, eli); + long long rulli = exchange_n (paulli, elli); + + sink (ruc, rusi, rui, ruli, rulli); +} + + +void warn_atomic_exchange_n (void) +{ + _Atomic char *pc = &eac + 1; + char rc = exchange_n (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + short rsi[2]; + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + rsi[0] = exchange_n (psi, ecsi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + rsi[1] = exchange_n (psi, ecsi); // { dg-warning "-Wstringop-overflow" } + + int ri[3]; + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + ri[0] = exchange_n (pi, eci); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + ri[1] = exchange_n (pi, eci); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + ri[2] = exchange_n (pi, eci); // { dg-warning "-Wstringop-overflow" } + + long rli[3]; + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + rli[0] = exchange_n (pli, ecli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + rli[1] = exchange_n (pli, ecli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + rli[2] = exchange_n (pli, ecli); // { dg-warning "-Wstringop-overflow" } + + long long rlli[3]; + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + rlli[0] = exchange_n (plli, eclli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + rlli[1] = exchange_n (plli, eclli); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + rlli[2] = exchange_n (plli, eclli); // { dg-warning "-Wstringop-overflow" } + + sink (&rc, rsi, ri, rli, rlli); +} + + +void warn_atomic_compare_exchange (void) +{ + _Atomic char *pc = &eac + 1; + cmpxchg (pc, &ec, &ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + cmpxchg (psi, &esi, &ecsi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + cmpxchg (psi, &esi, &ecsi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + cmpxchg (pi, &ei, &eci); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + cmpxchg (pi, &ei, &eci); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + cmpxchg (pi, &ei, &eci); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + cmpxchg (pli, &eli, &ecli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + cmpxchg (pli, &eli, &ecli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + cmpxchg (pli, &eli, &ecli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + cmpxchg (plli, &elli, &eclli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + cmpxchg (plli, &elli, &eclli); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + cmpxchg (plli, &elli, &eclli); // { dg-warning "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-78.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-78.c new file mode 100644 index 0000000000..a25a418ed7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-78.c @@ -0,0 +1,518 @@ +/* PR middle-end/102453 - buffer overflow by atomic built-ins not diagnosed + Verify that out-of-bounds accesses by atomic functions are diagnosed with + optimization enabled. + { dg-do compile } + { dg-options "-O3 -Wall -ftrack-macro-expansion=0" } */ + +#ifndef __cplusplus +# define bool _Bool +#endif + +#define NOIPA __attribute__ ((noipa)) + +#define add_fetch(p, q) __atomic_add_fetch (p, q, 0) +#define sub_fetch(p, q) __atomic_sub_fetch (p, q, 0) +#define and_fetch(p, q) __atomic_and_fetch (p, q, 0) +#define or_fetch(p, q) __atomic_or_fetch (p, q, 0) +#define xor_fetch(p, q) __atomic_xor_fetch (p, q, 0) +#define nand_fetch(p, q) __atomic_nand_fetch (p, q, 0) +#define exchange(p, q, r) __atomic_exchange (p, q, r, 0) +#define exchange_n(p, n) __atomic_exchange_n (p, n, 0) +#define cmpxchg(p, q, r) __atomic_compare_exchange (p, q, r, __COUNTER__, 0, 0) + +typedef __SIZE_TYPE__ size_t; + +void sink (void*, ...); +#define sink(...) sink (0, __VA_ARGS__) + +extern _Bool eb; +extern char ec; +extern short int esi; +extern int ei; +extern long int eli; +extern long long int elli; + +extern const _Bool ecb; +extern const char ecc; +extern const short int ecsi; +extern const int eci; +extern const long int ecli; +extern const long long int eclli; + +extern _Atomic _Bool eab; +extern _Atomic char eac; +extern _Atomic short int easi; +extern _Atomic int eai; +extern _Atomic long int eali; +extern _Atomic long long int ealli; + +extern _Atomic const _Bool eacb; +extern _Atomic const char eacc; +extern _Atomic const short int eacsi; +extern _Atomic const int eaci; +extern _Atomic const long int eacli; +extern _Atomic const long long int eaclli; + + +NOIPA void nowarn_atomic_add_fetch (void) +{ + add_fetch (&eac, ecc); + add_fetch (&easi, esi); + add_fetch (&eai, ei); + add_fetch (&eali, eli); + add_fetch (&ealli, elli); +} + + +NOIPA void warn_atomic_add_fetch (void) +{ + _Atomic char *pc = &eac + 1; + add_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + add_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + add_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + add_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + add_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + add_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + add_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + add_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + add_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + add_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + add_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + add_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void nowarn_atomic_sub_fetch (void) +{ + _Atomic char *pc = &eac; + sub_fetch (pc, ecc); + + _Atomic short *psi = &easi; + sub_fetch (psi, esi); + + _Atomic int *pi = &eai; + sub_fetch (pi, ei); + + _Atomic long *pli = &eali; + sub_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + sub_fetch (plli, elli); +} + + +NOIPA void warn_atomic_sub_fetch (void) +{ + _Atomic char *pc = &eac + 1; + sub_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + sub_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + sub_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + sub_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + sub_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + sub_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + sub_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + sub_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + sub_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + sub_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + sub_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + sub_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void nowarn_atomic_and_fetch (void) +{ + _Atomic char *pc = &eac; + and_fetch (pc, ecc); + + _Atomic short *psi = &easi; + and_fetch (psi, esi); + + _Atomic int *pi = &eai; + and_fetch (pi, ei); + + _Atomic long *pli = &eali; + and_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + and_fetch (plli, elli); +} + + +NOIPA void warn_atomic_and_fetch (void) +{ + _Atomic char *pc = &eac + 1; + and_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + and_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + and_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + and_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + and_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + and_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + and_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + and_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + and_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + and_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + and_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + and_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void nowarn_atomic_or_fetch (void) +{ + _Atomic char *pc = &eac; + or_fetch (pc, ecc); + + _Atomic short *psi = &easi; + or_fetch (psi, esi); + + _Atomic int *pi = &eai; + or_fetch (pi, ei); + + _Atomic long *pli = &eali; + or_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + or_fetch (plli, elli); +} + + +NOIPA void warn_atomic_or_fetch (void) +{ + _Atomic char *pc = &eac + 1; + or_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + or_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + or_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + or_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + or_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + or_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + or_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + or_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + or_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + or_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + or_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + or_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void nowarn_atomic_xor_fetch (void) +{ + _Atomic char *pc = &eac; + xor_fetch (pc, ecc); + + _Atomic short *psi = &easi; + xor_fetch (psi, esi); + + _Atomic int *pi = &eai; + xor_fetch (pi, ei); + + _Atomic long *pli = &eali; + xor_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + xor_fetch (plli, elli); +} + + +NOIPA void warn_atomic_xor_fetch (void) +{ + _Atomic char *pc = &eac + 1; + xor_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + xor_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 1); + xor_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + xor_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + xor_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + xor_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + xor_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + xor_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + xor_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + xor_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&eali + 1); + xor_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + xor_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void nowarn_atomic_nand_fetch (void) +{ + _Atomic char *pc = &eac; + nand_fetch (pc, ecc); + + _Atomic short *psi = &easi; + nand_fetch (psi, esi); + + _Atomic int *pi = &eai; + nand_fetch (pi, ei); + + _Atomic long *pli = &eali; + nand_fetch (pli, eli); + + _Atomic long long *plli = &ealli; + nand_fetch (plli, elli); +} + + +NOIPA void warn_atomic_nand_fetch (void) +{ + _Atomic char *pc = &eac + 1; + nand_fetch (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + nand_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 1); + nand_fetch (psi, esi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + nand_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + nand_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + nand_fetch (pi, ei); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + nand_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + nand_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + nand_fetch (pli, eli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + nand_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&eai + 1); + nand_fetch (plli, eali); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + nand_fetch (plli, elli); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void nowarn_atomic_exchange (void) +{ + char rc; + _Atomic char *pc = &eac; + exchange (pc, &ecc, &rc); + + short rsi; + _Atomic short *psi = &easi; + exchange (psi, &esi, &rsi); + + int ri; + _Atomic int *pi = &eai; + exchange (pi, &ei, &ri); + + long rli; + _Atomic long *pli = &eali; + exchange (pli, &eli, &rli); + + long long rlli; + _Atomic long long *plli = &ealli; + exchange (plli, &elli, &rlli); + + sink (&rc, &rsi, &ri, &rli, &rlli); +} + +NOIPA void warn_atomic_exchange (void) +{ + char rc; + _Atomic char *pc = &eac + 1; + exchange (pc, &ecc, &rc); // { dg-warning "-Wstringop-overflow" } + + short rsi[2]; + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + exchange (psi, &ecsi, rsi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + exchange (psi, &ecsi, rsi + 1); // { dg-warning "-Wstringop-overflow" } + + int ri[3]; + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + exchange (pi, &eci, ri); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + exchange (pi, &eci, ri + 1); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + exchange (pi, &eci, ri + 2); // { dg-warning "-Wstringop-overflow" } + + long rli[3]; + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + exchange (pli, &ecli, rli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + exchange (pli, &ecli, rli + 1); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + exchange (pli, &ecli, rli + 2); // { dg-warning "-Wstringop-overflow" } + + long long rlli[3]; + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + exchange (plli, &eclli, rlli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + exchange (plli, &eclli, rlli + 1); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + exchange (plli, &eclli, rlli + 2); // { dg-warning "-Wstringop-overflow" } + + sink (&rc, rsi, ri, rli, rlli); +} + + +NOIPA void nowarn_atomic_exchange_n (_Atomic unsigned char *pauc, + _Atomic unsigned short *pausi, + _Atomic unsigned int *paui, + _Atomic unsigned long *pauli, + _Atomic unsigned long long *paulli) +{ + char rc = exchange_n (&eac, ecc); + short rsi = exchange_n (&easi, esi); + int ri = exchange_n (&eai, ei); + long rli = exchange_n (&eali, eli); + long long rlli = exchange_n (&ealli, elli); + + sink (rc, rsi, ri, rli, rlli); + + char ruc = exchange_n (pauc, ecc); + short rusi = exchange_n (pausi, esi); + int rui = exchange_n (paui, ei); + long ruli = exchange_n (pauli, eli); + long long rulli = exchange_n (paulli, elli); + + sink (ruc, rusi, rui, ruli, rulli); +} + + +NOIPA void warn_atomic_exchange_n (void) +{ + _Atomic char *pc = &eac + 1; + char rc = exchange_n (pc, ecc); // { dg-warning "-Wstringop-overflow" } + + short rsi[2]; + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + rsi[0] = exchange_n (psi, ecsi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + rsi[1] = exchange_n (psi, ecsi); // { dg-warning "-Wstringop-overflow" } + + int ri[3]; + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + ri[0] = exchange_n (pi, eci); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + ri[1] = exchange_n (pi, eci); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + ri[2] = exchange_n (pi, eci); // { dg-warning "-Wstringop-overflow" } + + long rli[3]; + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + rli[0] = exchange_n (pli, ecli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + rli[1] = exchange_n (pli, ecli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + rli[2] = exchange_n (pli, ecli); // { dg-warning "-Wstringop-overflow" } + + long long rlli[3]; + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + rlli[0] = exchange_n (plli, eclli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + rlli[1] = exchange_n (plli, eclli); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + rlli[2] = exchange_n (plli, eclli); // { dg-warning "-Wstringop-overflow" } + + sink (&rc, rsi, ri, rli, rlli); +} + + +NOIPA void warn_atomic_compare_exchange (void) +{ + _Atomic char *pc = &eac + 1; + cmpxchg (pc, &ec, &ecc); // { dg-warning "-Wstringop-overflow" } + + _Atomic short *psi = (_Atomic short*)((char*)&easi + 1); + cmpxchg (psi, &esi, &ecsi); // { dg-warning "-Wstringop-overflow" } + psi = (_Atomic short*)((char*)&easi + 2); + cmpxchg (psi, &esi, &ecsi); // { dg-warning "-Wstringop-overflow" } + + _Atomic int *pi = (_Atomic int*)((char*)&eai + 1); + cmpxchg (pi, &ei, &eci); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + 2); + cmpxchg (pi, &ei, &eci); // { dg-warning "-Wstringop-overflow" } + pi = (_Atomic int*)((char*)&eai + sizeof eai); + cmpxchg (pi, &ei, &eci); // { dg-warning "-Wstringop-overflow" } + + _Atomic long *pli = (_Atomic long*)((char*)&eali + 1); + cmpxchg (pli, &eli, &ecli); // { dg-warning "-Wstringop-overflow" } + pli = (_Atomic long*)((char*)&eali + 1); + cmpxchg (pli, &eli, &ecli); // { dg-warning "-Wstringop-overflow" } + pli = &eali + 1; + cmpxchg (pli, &eli, &ecli); // { dg-warning "-Wstringop-overflow" } + + _Atomic long long *plli = (_Atomic long long*)((char*)&ealli + 1); + cmpxchg (plli, &elli, &eclli); // { dg-warning "-Wstringop-overflow" } + plli = (_Atomic long long*)((char*)&ealli + 1); + cmpxchg (plli, &elli, &eclli); // { dg-warning "-Wstringop-overflow" } + plli = &ealli + 1; + cmpxchg (plli, &elli, &eclli); // { dg-warning "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-79.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-79.c new file mode 100644 index 0000000000..15eb26fbdb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-79.c @@ -0,0 +1,70 @@ +/* Verify that a separate note is issued for each offset into the same + object after a -Wstringop-overflow. Since all arguments are known + the test doesn't need optimization. Wstringop-overflow-79.c verifies + they're also issued at -O2. + { dg-do compile } + { dg-options "-O0 -Wno-array-bounds" } */ + +extern char a[8]; // dg-message at offset \\\[3, 6] into destination object 'a'" "note 1" } + // dg-message at offset \\\[5, 8] into destination object 'a'" "note 2" { target *-*-* } .-1 } + +void test_2_notes (int i) +{ + char *p = i ? a + 3 : a + 5; + __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" } +} + + +extern char b[8]; // dg-message at offset \\\[3, 6] into destination object 'b'" "note 1" } + // dg-message at offset \\\[4, 7] into destination object 'b'" "note 2" { target *-*-* } .-1 } + // dg-message at offset \\\[5, 8] into destination object 'b'" "note 3" { target *-*-* } .-2 } + +void test_3_notes (int i) +{ + char *p = i < 0 ? b + 3 : 0 < i ? b + 5 : b + 4; + __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" } +} + + +extern char c[8]; // dg-message at offset \\\[3, 6] into destination object 'c'" "note 1" } + // dg-message at offset \\\[4, 7] into destination object 'c'" "note 2" { target *-*-* } .-1 } + // dg-message at offset \\\[5, 8] into destination object 'c'" "note 3" { target *-*-* } .-2 } + // dg-message at offset \\\[6, 8] into destination object 'c'" "note 3" { target *-*-* } .-2 } + +void test_4_notes (int i) +{ + char *p; + if (i < -1) + p = c + 3; + else if (i < 0) + p = c + 4; + else if (0 < i) + p = c + 6; + else + p = c + 5; + + __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" } +} + + +extern char d[8]; // dg-message at offset \\\[3, 6] into destination object 'd'" "note 1" } + // dg-message at offset \\\[4, 7] into destination object 'd'" "note 2" { target *-*-* } .-1 } + // dg-message at offset \\\[5, 8] into destination object 'd'" "note 3" { target *-*-* } .-2 } + // dg-message at offset \\\[6, 8] into destination object 'd'" "note 3" { target *-*-* } .-3 } + // dg-message at offset \\\[7, 8] into destination object 'd'" "note 3" { target *-*-* } .-4 } + +void test_5_notes (int i) +{ + char *p; + switch (i) + { + case -9: p = d + 3; break; + case -5: p = d + 4; break; + case 0: p = d + 5; break; + case 3: p = d + 6; break; + case 4: p = d + 7; break; + default: return; + } + + __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-8.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-8.c new file mode 100644 index 0000000000..513d6b1d33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-8.c @@ -0,0 +1,62 @@ +/* PR tree-optimization/79220 - missing -Wstringop-overflow= on a memcpy + overflow with a small power-of-2 size + { dg-do compile } + { dg-options "-O2 -Wno-array-bounds -Wstringop-overflow" } */ + +extern void* memcpy (void*, const void*, __SIZE_TYPE__); +extern void* memmove (void*, const void*, __SIZE_TYPE__); +extern void* memset (void*, int, __SIZE_TYPE__); + +char d[1]; + +void test_memcpy_lit_2 (void) +{ + memcpy (d, "01", 2); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + +void test_memcpy_lit_4 (void) +{ + memcpy (d, "0123", 4); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + +void test_memmove_lit_8 (void) +{ + memmove (d, "01234567", 8); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + + +void test_memcpy_ptr_2 (const void *s) +{ + memcpy (d, s, 2); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + +void test_memcpy_ptr_4 (const void *s) +{ + memcpy (d, s, 4); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + +void test_memcpy_ptr_8 (const void *s) +{ + memcpy (d, s, 8); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + + +void test_memmove_ptr (const void *s) +{ + memmove (d, s, 8); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + +void test_memset_2 (void) +{ + memset (d, 0, 2); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + +void test_memset_4 (void) +{ + memset (d, 0, 4); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} + +void test_memset_8 (void) +{ + memset (d, 0, 8); /* { dg-warning "\\\[-Wstringop-overflow" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-80.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-80.c new file mode 100644 index 0000000000..1628c2f015 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-80.c @@ -0,0 +1,70 @@ +/* Verify that a separate note is issued for each offset into the same + object after a -Wstringop-overflow. Even though the warnings don't + need optimization the test enables it to verify they're still issued + with it. Wstringop-overflow-78.c verifies they're issued at -O0. + { dg-do compile } + { dg-options "-O2 -Wno-array-bounds" } */ + +extern char a[8]; // dg-message at offset \\\[3, 6] into destination object 'a'" "note 1" } + // dg-message at offset \\\[5, 8] into destination object 'a'" "note 2" { target *-*-* } .-1 } + +void test_2_notes (int i) +{ + char *p = i ? a + 3 : a + 5; + __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" } +} + + +extern char b[8]; // dg-message at offset \\\[3, 6] into destination object 'b'" "note 1" } + // dg-message at offset \\\[4, 7] into destination object 'b'" "note 2" { target *-*-* } .-1 } + // dg-message at offset \\\[5, 8] into destination object 'b'" "note 3" { target *-*-* } .-2 } + +void test_3_notes (int i) +{ + char *p = i < 0 ? b + 3 : 0 < i ? b + 5 : b + 4; + __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" } +} + + +extern char c[8]; // dg-message at offset \\\[3, 6] into destination object 'c'" "note 1" } + // dg-message at offset \\\[4, 7] into destination object 'c'" "note 2" { target *-*-* } .-1 } + // dg-message at offset \\\[5, 8] into destination object 'c'" "note 3" { target *-*-* } .-2 } + // dg-message at offset \\\[6, 8] into destination object 'c'" "note 3" { target *-*-* } .-2 } + +void test_4_notes (int i) +{ + char *p; + if (i < -1) + p = c + 3; + else if (i < 0) + p = c + 4; + else if (0 < i) + p = c + 6; + else + p = c + 5; + + __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" } +} + + +extern char d[8]; // dg-message at offset \\\[3, 6] into destination object 'd'" "note 1" } + // dg-message at offset \\\[4, 7] into destination object 'd'" "note 2" { target *-*-* } .-1 } + // dg-message at offset \\\[5, 8] into destination object 'd'" "note 3" { target *-*-* } .-2 } + // dg-message at offset \\\[6, 8] into destination object 'd'" "note 3" { target *-*-* } .-3 } + // dg-message at offset \\\[7, 8] into destination object 'd'" "note 3" { target *-*-* } .-4 } + +void test_5_notes (int i) +{ + char *p; + switch (i) + { + case -9: p = d + 3; break; + case -5: p = d + 4; break; + case 0: p = d + 5; break; + case 3: p = d + 6; break; + case 4: p = d + 7; break; + default: return; + } + + __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-81.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-81.c new file mode 100644 index 0000000000..e8bc327722 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-81.c @@ -0,0 +1,38 @@ +/* Verify that -Wstringop-overflow uses context-sensitive range info + even at -O0. + { dg-do compile } + { dg-options "-O0 -Wall" } */ + +extern void* memset (void*, int, __SIZE_TYPE__); + +char a[8]; + +void warn_offset_range (int i) +{ + if (i < 4) + i = 4; + memset (a + i, 0, 5); // { dg-warning "writing 5 bytes into a region of size 4 " } +} + +void warn_size_range (int i, int n) +{ + if (n < 5) + n = 5; + + memset (a + 4, 1, n); // { dg-warning "writing between 5 and \\d+ bytes into a region of size 4 " } +} + +void warn_offset_and_size_range (int i, int n) +{ + if (n < 5) + n = 5; + + if (i < 4) + { + if (n < 9) + n = 9; + memset (a + i, 1, n); // { dg-warning "writing between 9 and \\d+ bytes into a region of size 8 " } + } + else + memset (a + i, 0, n); // { dg-warning "writing between 5 and \\d+ bytes into a region of size 4 " } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-82.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-82.c new file mode 100644 index 0000000000..ee2693dcea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-82.c @@ -0,0 +1,29 @@ +/* Verify that notes after warnings for array and VLA parameters show + the array form. + { dg-do compile } + { dg-options "-Wall" } */ + +void fia5 (int[5]); + +void gia3_fia5 (void) +{ + int a[3]; + fia5 (a); // { dg-warning "-Wstringop-overflow" } + // { dg-message "argument 1 of type 'int\\\[5]'" "note" { target *-*-* } .-1 } +} + + +/* The type of the argument would ideall be 'int[n]' but the variable + bound is lost/cleared by free-lang-data and never makes it into + the middle end. An (inferior) alternative would be 'int[*]' but + the pretty printer doesn't know how to format the star. A better + solution might be to introduce a new notation, like 'int[$1]', + where the $1 refers to the VLA argument bound. */ +void fvla (int n, int[n]); + +void gia3_fvla (void) +{ + int a[3]; + fvla (sizeof a, a); // { dg-warning "-Wstringop-overflow" } + // { dg-message "argument 2 of type 'int\\\[]'" "note" { target *-*-* } .-1 } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-83.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-83.c new file mode 100644 index 0000000000..6928ee4d55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-83.c @@ -0,0 +1,19 @@ +/* PR middle-end/103143 - ICE due to infinite recursion in pointer-query.cc + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +void foo (size_t x) +{ + struct T { char buf[64]; char buf2[64]; } t; + char *p = &t.buf[8]; + char *r = t.buf2; + size_t i; + + for (i = 0; i < x; i++) + { + r = __builtin_mempcpy (r, p, i); + p = r + 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-84.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-84.c new file mode 100644 index 0000000000..2c0f507a0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-84.c @@ -0,0 +1,15 @@ +/* PR middle-end/102960 - ICE: in sign_mask, at wide-int.h:855 in GCC 10.3.0 + { dg-do compile } + { dg-options "-Og -Wall" } */ + +void f (int i) +{ + const char *s; + if (i) + s = &"abcd"[i]; + + __builtin_printf ("%s", s); +} + +/* The use of s in the call to sprintf should result in: + { dg-prune-output "-Wmaybe-uninitialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-85.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-85.c new file mode 100644 index 0000000000..ac61e0a0a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-85.c @@ -0,0 +1,153 @@ +/* PR middle-end/103215 - bogus -Wstringop-overflow with two pointers with + different offsets each + Test for accesses into distinct arrays through pointers with different + offsets each. + + If/when -Wstringop-overflow is enhanced to issue "maybe" kinds of + warnings some of the accesses here will trigger those and will need + updating. + + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#define NOIPA __attribute__ ((noipa)) + +void sink (int[1]); +#define A(p, off) sink (p + off) + +extern int a4[4], a8[8]; + + + + +NOIPA void a4_p1_a8_p3 (int i) +{ + int *a4_p1 = a4 + 1; + int *a8_p3 = a8 + 3; + int *q = i ? a4_p1 : a8_p3; + A (q, -4); // { dg-warning "-Wstringop-overflow" } + /* Because -3 is a valid offset into a8 but not a4, q must point + to the former and so subscripts between -3 and +4 refer to its + elements. */ + A (q, -3); A (q, -2); A (q, -1); A (q, 0); + A (q, 1); A (q, 2); A (q, 3); A (q, 4); + A (q, 5); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + /* Both of the following are definitely out of bounds but the first isn't + diagnosed because the code conservatively merges the offsets into A4 + and A8. */ + A (q, 7); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void a4_p1_a8_p5 (int i) +{ + int *a4_p1 = a4 + 1; + int *a8_p5 = a8 + 5; + int *q = i ? a4_p1 : a8_p5; + A (q, -6); // { dg-warning "-Wstringop-overflow" } + /* Similarly to the above, because -5 is a valid offset into a8 but + not a4, q must point to the former and so subscripts between -5 + and +2 refer to its elements. */ + A (q, -5); A (q, -4); A (q, -3); A (q, -2); + A (q, -1); A (q, 0); A (q, 1); A (q, 2); + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 7); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void a4_p1_a8_p7 (int i) +{ + int *a4_p1 = a4 + 1; + int *a8_p7 = a8 + 7; + int *q = i ? a4_p1 : a8_p7; + A (q, -8); // { dg-warning "-Wstringop-overflow" } + A (q, -7); A (q, -6); A (q, -5); A (q, -4); + A (q, -3); A (q, -2); A (q, -1); A (q, 0); + /* Since -7 is valid, q must point to a8 and the last valid subscript + must be 0. */ + A (q, 1); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 7); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void mp_1_a4_p1_a8_p7 (int i, int j) +{ + int *a4_p1 = a4 + 1; + int *a8_p7 = a8 + 7; + int *p = i ? a4_p1 : a8_p7; + int *q = j ? p + 1 : p - 1; + + A (q, -9); // { dg-warning "-Wstringop-overflow" } + + /* q points either to a8 + [6, 8] or a4 + [0, 2]. */ + A (q, -8); A (q, -7); A (q, -6); A (q, -5); + A (q, -4); A (q, -3); A (q, -2); A (q, -1); + + /* Since all the above are valid, q must point to a8 + 8. But as + mentioned above, the warning for each subscript is independent + of prior subscripts into the same object so the access below + aren't diagnosed. */ + A (q, 0); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 1); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 4); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 8); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void mp1_a4_p1_a8_p5 (int i, int j) +{ + int *a4_p1 = a4 + 1; + int *a8_p5 = a8 + 5; + int *p = i ? a4_p1 : a8_p5; + + int *q = j ? p + 1 : p - 1; + + // q is assumed to point to a8 + 6 + A (q, -7); // { dg-warning "-Wstringop-overflow" } + A (q, -6); A (q, -5); A (q, -4); A (q, -3); + A (q, -2); A (q, -1); A (q, 0); A (q, 1); + /* Even though the above accesses rule it out, q is now assumed + to point to either a4 + [0, 2] or a8 + [4, 5]. */ + A (q, 2); + /* q is now assumed to point tp a4. Given that, only the first store + is valid. */ + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 4); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 5); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 6); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 7); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 8); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void mp1_a4_p1_a8_p4 (int i, int j) +{ + int *a4_p1 = a4 + 1; + int *a8_p4 = a8 + 4; + int *p = i ? a4_p1 : a8_p4; + + int *q = j ? p + 1 : p - 1; + + // q is assumed to point to a8 + 5 + A (q, -6); // { dg-warning "-Wstringop-overflow" } + A (q, -5); + A (q, -4); + A (q, -3); + A (q, -2); + A (q, -1); + A (q, 0); + A (q, 1); + A (q, 2); + /* Even though the above accesses rule it out, q is now assumed + to point tp a4. Given that, only the first store is valid. */ + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 4); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 5); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 6); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 7); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 8); // { dg-warning "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-86.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-86.c new file mode 100644 index 0000000000..345abe4a27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-86.c @@ -0,0 +1,63 @@ +/* PR middle-end/101751 - attribute access none with void pointer expects + nonzero size + { dg-do compile } + { dg-options "-Wall" } */ + +__attribute__ ((access (none, 1))) void +fvp_m1 (const void*); + +void nowarn_m1 (void) +{ + /* Verify these don't trigger a warning for calls to a function + declared with attribute access none. */ + fvp_m1 ((void*)-1); // { dg-bogus "-Wstringop-" } + fvp_m1 ((void*)1); // { dg-bogus "-Wstringop-" } +} + + +__attribute__ ((access (none, 1))) void +fvp_none (void*); + +void nowarn_c_cp1 (void) +{ + char c; + fvp_none (&c); + fvp_none (&c + 1); // { dg-bogus "-Wstringop-" } +} + +void nowarn_f_fp1 (void) +{ + fvp_none ((char*)&nowarn_f_fp1); + fvp_none ((char*)&nowarn_f_fp1 + 1); +} + +void nowarn_sp1_sp_4 (void) +{ + fvp_none ("" + 1); // { dg-bogus "-Wstringop-" } + fvp_none ("123" + 4); // { dg-bogus "-Wstringop-" } +} + + +__attribute__ ((access (none, 1))) void +wfvp_none (void*); // { dg-message "in a call to function 'wfvp_none' declared with attribute 'access \\\(none, 1\\\)'" } + +void warn_cm1_p1 (void) +{ + char c; + /* With optimization both of the following are diagnosed by -Warray-bounds. + The second also without optimization by -Wstringop-overread. They + should both be diagnosed by the same warning even without optimization. */ + wfvp_none (&c - 1); // { dg-warning "" "pr??????" { xfail *-*-* } } + wfvp_none (&c + 2); // { dg-warning "" } +} + +void warn_fp2 (void) +{ + void *p = (char*)&warn_fp2 + sizeof warn_fp2; + fvp_none (p); // { dg-warning "" "pr??????" { xfail *-*-* } } +} + +void warn_sp2 (void) +{ + wfvp_none ("" + 2); // { dg-warning "" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-87.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-87.c new file mode 100644 index 0000000000..bc121928f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-87.c @@ -0,0 +1,147 @@ +/* PR middle-end/103215 - bogus -Warray-bounds with two pointers with + different offsets each + Test for accesses by a user-defined function into the same array + through pointers with different offsets each. See Warray-bounds-91.c + for the corresponding test exercising -Warray-bounds for direct accesses. + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#define NOIPA __attribute__ ((noipa)) + +void sink (int[1]); +#define A(p, off) sink (p + off) + +extern int a4[4]; + + +NOIPA void p0_p1 (int i) +{ + int *p0 = a4 + 0; + int *p1 = a4 + 1; + int *q = i ? p0 : p1; + A (q, -2); // { dg-warning "-Wstringop-overflow" } + A (q, -1); A (q, 0); A (q, 1); A (q, 2); + /* Since q points to a4 and -1 is a valid subscript, +3 must be invalid. + But the warning for each subscript is independent of prior subscripts + into the same object. That should be improved. */ + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 4); // { dg-warning "-Wstringop-overflow" } +} + +NOIPA void p1_p0 (int i) +{ + int *p1 = a4 + 1; + int *p0 = a4 + 0; + int *q = i ? p0 : p1; + A (q, -2); // { dg-warning "-Wstringop-overflow" } + A (q, -1); A (q, 0); A (q, 1); A (q, 2); + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 4); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void p1_p2 (int i) +{ + int *p1 = a4 + 1; + int *p2 = a4 + 2; + int *q = i ? p1 : p2; + A (q, -3); // { dg-warning "-Wstringop-overflow" } + A (q, -2); A (q, -1); A (q, 0); A (q, 1); + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" } +} + +NOIPA void p2_p1 (int i) +{ + int *p2 = a4 + 2; + int *p1 = a4 + 1; + int *q = i ? p1 : p2; + A (q, -3); // { dg-warning "-Wstringop-overflow" } + A (q, -2); A (q, -1); A (q, 0); A (q, 1); + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void p1_p3 (int i) +{ + int *p1 = a4 + 1; + int *p3 = a4 + 3; + int *q = i ? p1 : p3; + A (q, -4); // { dg-warning "-Wstringop-overflow" } + A (q, -3); A (q, -2); A (q, -1); A (q, 0); + A (q, 1); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" } +} + +NOIPA void p3_p1 (int i) +{ + int *p3 = a4 + 3; + int *p1 = a4 + 1; + int *q = i ? p1 : p3; + A (q, -4); // { dg-warning "-Wstringop-overflow" } + A (q, -3); A (q, -2); A (q, -1); A (q, 0); + A (q, 1); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void p1_p4 (int i) +{ + int *p1 = a4 + 1; + int *p4 = a4 + 4; + int *q = i ? p1 : p4; + A (q, -5); // { dg-warning "-Wstringop-overflow" } + A (q, -4); A (q, -3); A (q, -2); A (q, -1); + A (q, 0); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 1); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" } +} + +NOIPA void p4_p1 (int i) +{ + int *p4 = a4 + 4; + int *p1 = a4 + 1; + int *q = i ? p1 : p4; + A (q, -5); // { dg-warning "-Wstringop-overflow" } + A (q, -4); A (q, -3); A (q, -2); A (q, -1); + A (q, 0); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 1); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void p0_p1_p2 (int i) +{ + int *p0 = a4 + 0; + int *p1 = a4 + 1; + int *p2 = a4 + 2; + int *q = i < 0 ? p1 : 0 < i ? p2 : p0; + A (q, -3); // { dg-warning "-Wstringop-overflow" } + A (q, -2); A (q, -1); A (q, 0); A (q, 1); + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 4); // { dg-warning "-Wstringop-overflow" } +} + + +NOIPA void p0_p1_p2_p3_p4 (int i) +{ + int *p0 = a4 + 0; + int *p1 = a4 + 1; + int *p2 = a4 + 2; + int *p3 = a4 + 3; + int *p4 = a4 + 4; + int *q = i < -1 ? p1 : i < 0 ? p2 : 1 < i ? p4 : 0 < i ? p3 : p0; + A (q, -5); // { dg-warning "-Wstringop-overflow" } + A (q, -4); A (q, -3); A (q, -2); A (q, -1); + A (q, 0); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 1); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 2); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 3); // { dg-warning "-Wstringop-overflow" "pr??????" { xfail *-*-* } } + A (q, 4); // { dg-warning "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-88.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-88.c new file mode 100644 index 0000000000..c6b443e4d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-88.c @@ -0,0 +1,327 @@ +/* PR middle-end/101475 - missing -Wstringop-overflow storing a compound + literal + { dg-do compile } + { dg-options "-O2 -fno-tree-vectorize" } */ + +extern char ea1[1], ea2[2], ea3[3], ea4[4]; + +/* The trailing A member of all of Sx, S0, and S1 is treated the same: + as a flexible array member. */ +struct Sx { char n, a[]; }; +struct S0 { char n, a[0]; }; +struct S1 { char n, a[1]; }; +/* The trailing A member in both S2 and S3 is treated as an ordinary + array with exactly two elements and accesses to elements beyond + the last are diagnosed regardless of whether they are within + the bounds the enclosing object. */ +struct S2 { char n, a[2]; }; +struct S3 { char n, a[3]; }; + + +void fx_ea1 (void) +{ + struct Sx *p = (struct Sx*)ea1; + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f0_ea1 (void) +{ + struct S0 *p = (struct S0*)ea1; + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f1_ea1 (void) +{ + struct S1 *p = (struct S1*)ea1; + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f2_ea1 (void) +{ + struct S2 *p = (struct S2*)ea1; + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f3_ea1 (void) +{ + struct S3 *p = (struct S3*)ea1; + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + + +void fx_ea1_p1 (void) +{ + struct Sx *p = (struct Sx*)(ea1 + 1); + p->n = 0; // { dg-warning "-Wstringop-overflow" } + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f0_ea1_p1 (void) +{ + struct S0 *p = (struct S0*)(ea1 + 1); + p->n = 0; // { dg-warning "-Wstringop-overflow" } + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f1_ea1_p1 (void) +{ + struct S1 *p = (struct S1*)(ea1 + 1); + p->n = 0; // { dg-warning "-Wstringop-overflow" } + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f2_ea1_p1 (void) +{ + struct S2 *p = (struct S2*)(ea1 + 1); + p->n = 0; // { dg-warning "-Wstringop-overflow" } + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f3_ea1_p1 (void) +{ + struct S3 *p = (struct S3*)(ea1 + 1); + p->n = 0; // { dg-warning "-Wstringop-overflow" } + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + + +void fx_ea2 (void) +{ + struct Sx *p = (struct Sx*)ea2; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f0_ea2 (void) +{ + struct S0 *p = (struct S0*)ea2; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f1_ea2 (void) +{ + struct S1 *p = (struct S1*)ea2; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f2_ea2 (void) +{ + struct S2 *p = (struct S2*)ea2; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f3_ea2 (void) +{ + struct S3 *p = (struct S3*)ea2; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + + +void fx_ea2_p1 (void) +{ + struct Sx *p = (struct Sx*)(ea2 + 1); + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f0_ea2_p1 (void) +{ + struct S0 *p = (struct S0*)(ea2 + 1); + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f1_ea2_p1 (void) +{ + struct S1 *p = (struct S1*)(ea2 + 1); + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f2_ea2_p1 (void) +{ + struct S2 *p = (struct S2*)(ea2 + 1); + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f3_ea2_p1 (void) +{ + struct S3 *p = (struct S3*)(ea2 + 1); + p->n = 0; + p->a[0] = 0; // { dg-warning "-Wstringop-overflow" } + p->a[1] = 1; // { dg-warning "-Wstringop-overflow" } + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + + +void fx_ea3 (void) +{ + struct Sx *p = (struct Sx*)ea3; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f0_ea3 (void) +{ + struct S0 *p = (struct S0*)ea3; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f1_ea3 (void) +{ + struct S1 *p = (struct S1*)ea3; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f2_ea3 (void) +{ + struct S2 *p = (struct S2*)ea3; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f3_ea3 (void) +{ + struct S3 *p = (struct S3*)ea3; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + + +void fx_ea4 (void) +{ + struct Sx *p = (struct Sx*)ea4; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f0_ea4 (void) +{ + struct S0 *p = (struct S0*)ea4; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f1_ea4 (void) +{ + struct S1 *p = (struct S1*)ea4; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f2_ea4 (void) +{ + struct S2 *p = (struct S2*)ea4; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + /* Even though the offset of p->a[2] is within the bounds of EA4 + the warning triggers because it only considers trailing arrays + of at mnost one element as "poor man's flexible arrays." */ + p->a[2] = 2; // { dg-warning "-Wstringop-overflow" } + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} + +void f3_ea4 (void) +{ + struct S3 *p = (struct S3*)ea4; + p->n = 0; + p->a[0] = 0; + p->a[1] = 1; + p->a[2] = 2; + p->a[3] = 3; // { dg-warning "-Wstringop-overflow" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-89.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-89.c new file mode 100644 index 0000000000..ba25a9386a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-89.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-inline -Wall" } */ + +extern void process (char); + +void process_array4 (char a[4], int n) +{ + for (int i = 0; i < n; i++) + process (a[i]); +} + +void process_array3 (char a[3], int n) +{ + for (int i = 0; i < n; i++) + process (a[i]); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-9.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-9.c new file mode 100644 index 0000000000..2df84b2bbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-9.c @@ -0,0 +1,72 @@ +/* PR middle-end/88771 - Misleading -Werror=array-bounds error + Verify that the warning issued for calls to "bounded" string + functions is -Wstringop-overflow with the right wording. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); +extern void* memmove (void*, const void*, size_t); +extern void* memset (void*, int, size_t); + +extern char* stpncpy (char*, const char*, size_t); + +extern char* strncat (char*, const char*, size_t); +extern char* strncpy (char*, const char*, size_t); + +extern char* strndup (const char*, size_t); + +extern int strncmp (const char*, const char*, size_t); +extern int strncasecmp (const char*, const char*, size_t); + +extern size_t strnlen (const char*, size_t); + +extern char *d; +extern const char *s; + + +void test_memcpy (void) +{ + memcpy (d, s, SIZE_MAX); /* { dg-warning ".memcpy. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */ +} + +void test_memmove (void) +{ + memmove (d, s, SIZE_MAX - 1); /* { dg-warning ".memmove. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */ +} + +void test_memset (void) +{ + memset (d, 0, SIZE_MAX - 2); /* { dg-warning ".memset. specified \(bound|size\) \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */ +} + + +char* test_stpncpy (void) +{ + return stpncpy (d, s, SIZE_MAX - 4); /* { dg-warning ".stpncpy. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */ +} + + +void test_strncat (void) +{ + strncat (d, s, SIZE_MAX - 3); /* { dg-warning ".strncat. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */ +} + +void test_strncpy (void) +{ + strncpy (d, s, SIZE_MAX - 4); /* { dg-warning ".strncpy. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */ +} + +char* test_strndup (void) +{ + return strndup (s, SIZE_MAX - 5); /* { dg-warning ".strndup. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overread" } */ +} + +size_t test_strnlen (void) +{ + return strnlen (s, SIZE_MAX - 6); /* { dg-warning ".strnlen. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overread" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-pr106904.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-pr106904.c new file mode 100644 index 0000000000..15e67c28c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow-pr106904.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstringop-overflow -fno-vect-cost-model" } */ + +struct windowpos +{ + int hwnd; + int hwnd2; +}; + +struct packed_windowpos +{ + int hwnd; + int pad1; + int hwnd2; + int pad2; +}; + +struct packed_structs +{ + struct packed_windowpos wp; +}; + +void func(struct packed_structs *ps) +{ + struct windowpos wp; + + wp.hwnd = ps->wp.hwnd; + wp.hwnd2 = ps->wp.hwnd2; + __builtin_memcpy(&ps->wp, &wp, sizeof(wp)); /* { dg-bogus "into a region" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overflow.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow.c new file mode 100644 index 0000000000..c615dae03f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overflow.c @@ -0,0 +1,132 @@ +/* PR middle-end/77608 - missing protection on trivially detectable runtime + buffer overflow + { dg-do compile } + { dg-options "-O2 -Wstringop-overflow -ftrack-macro-expansion=0" } */ + +#define SIZE_MAX __SIZE_MAX__ +#define DIFF_MAX __PTRDIFF_MAX__ +#define DIFF_MIN (-DIFF_MAX - 1) + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); +extern char* strcpy (char*, const char*); +extern char* strncpy (char*, const char*, size_t); + +void sink (void*); + +static size_t unsigned_value (void) +{ + extern volatile size_t unsigned_value_source; + return unsigned_value_source; +} + +static size_t unsigned_range (size_t min, size_t max) +{ + size_t val = unsigned_value (); + return val < min || max < val ? min : val; +} + +#define UR(min, max) unsigned_range (min, max) + + +char a7[7]; + +struct MemArray { char a9[9]; char a1[1]; }; + +void test_memcpy_array (const void *s) +{ +#define T(d, s, n) (memcpy ((d), (s), (n)), sink (d)) + + T (a7 + UR (0, 1), s, 7); + T (a7 + UR (0, 7), s, 7); + T (a7 + UR (0, 8), s, 7); + T (a7 + UR (0, DIFF_MAX), s, 7); + T (a7 + UR (0, SIZE_MAX), s, 7); + + T (a7 + UR (1, 2), s, 7); /* { dg-warning "writing 7 bytes into a region of size 6" } */ + T (a7 + UR (2, 3), s, 7); /* { dg-warning "writing 7 bytes into a region of size 5" } */ + T (a7 + UR (6, 9), s, 7); /* { dg-warning "writing 7 bytes into a region of size 1" } */ + T (a7 + UR (7, 9), s, 7); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + T (a7 + UR (8, 9), s, 7); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + + T (a7 + UR (9, 10), s, 7); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + T (a7 + UR (DIFF_MAX, DIFF_MAX + (size_t)1), s, 7); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + T (a7 + UR (DIFF_MAX, SIZE_MAX), s, 7); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + + /* This is valid. */ + char *d = a7 + 7; + T (d + UR (-8, -7), s, 7); +} + +/* Verify the absence of warnings for memcpy writing beyond object + boundaries. */ + +void test_memcpy_memarray (struct MemArray *p, const void *s) +{ +#undef T +#define T(d, s, n) (memcpy ((d), (s), (n)), sink (d)) + + /* The following are valid. */ + T (p->a9 + UR (0, 1), s, 9); + T (p->a9 + UR (0, 7), s, 9); + T (p->a9 + UR (0, 8), s, 9); + T (p->a9 + UR (0, DIFF_MAX), s, 9); + T (p->a9 + UR (0, SIZE_MAX), s, 9); + + /* The following are invalid. Unfortunately, there is apparently enough + code out there that abuses memcpy to write past the end of one member + and into the members that follow so the following are not diagnosed + by design. It sure would be nice not to have to cater to hacks like + these... */ + T (p->a9 + UR (1, 2), s, 9); + T (p->a9 + UR (1, 2), s, 123); +} + + +void test_strcpy_array (void) +{ +#undef T +#define T(d, s) (strcpy ((d), (s)), sink (d)) + + T (a7 + UR (0, 1), "012345"); + T (a7 + UR (0, 7), "012345"); + T (a7 + UR (0, 8), "012345"); + T (a7 + UR (0, DIFF_MAX), "012345"); + T (a7 + UR (0, SIZE_MAX), "012345"); + + T (a7 + UR (1, 2), "012345"); /* { dg-warning "writing 7 bytes into a region of size 6" } */ + T (a7 + UR (2, 3), "012345"); /* { dg-warning "writing 7 bytes into a region of size 5" } */ + T (a7 + UR (6, 9), "012345"); /* { dg-warning "writing 7 bytes into a region of size 1" } */ + T (a7 + UR (7, 9), "012345"); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + T (a7 + UR (8, 9), "012345"); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + + T (a7 + UR (9, 10), "012345"); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + T (a7 + UR (DIFF_MAX, DIFF_MAX + (size_t)1), "012345"); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + T (a7 + UR (DIFF_MAX, SIZE_MAX), "012345"); /* { dg-warning "writing 7 bytes into a region of size 0" } */ + + char *d = a7 + 7; + + T (d + UR (-8, -7), "012345"); +} + +void test_strncpy_memarray (struct MemArray *p, const void *s) +{ +#undef T +#define T(d, s, n) (strncpy ((d), (s), (n)), sink (d)) + + T (p->a9 + UR (0, 1), s, 9); + T (p->a9 + UR (0, 7), s, 9); + T (p->a9 + UR (0, 8), s, 9); + T (p->a9 + UR (0, DIFF_MAX), s, 9); + T (p->a9 + UR (0, SIZE_MAX), s, 9); + + T (p->a9 + UR (1, 2), s, 9); /* { dg-warning "writing 9 bytes into a region of size 8" } */ + T (p->a9 + UR (2, 3), s, 9); /* { dg-warning "writing 9 bytes into a region of size 7" } */ + T (p->a9 + UR (6, 9), s, 9); /* { dg-warning "writing 9 bytes into a region of size 3" } */ + T (p->a9 + UR (9, 10), s, 9); /* { dg-warning "writing 9 bytes into a region of size 0" } */ + T (p->a9 + UR (10, 11), s, 9); /* { dg-warning "writing 9 bytes into a region of size 0" } */ + + T (p->a9 + UR (DIFF_MAX, DIFF_MAX + (size_t)1), s, 1); /* { dg-warning "writing 1 byte into a region of size 0" } */ + T (p->a9 + UR (DIFF_MAX, SIZE_MAX), s, 3); /* { dg-warning "writing 3 bytes into a region of size 0" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overread-2.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-2.c new file mode 100644 index 0000000000..16dc06d968 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-2.c @@ -0,0 +1,117 @@ +/* Verify -Wstringop-overread is issued for reading more than the maximum + object size but not for writing. + { dg-do compile } + { dg-options "-O2 -Wno-stringop-overflow -ftrack-macro-expansion=0" } */ + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +#define NOIPA __attribute__ ((noipa)) + +typedef __SIZE_TYPE__ size_t; + +void* memchr (const void*, int, size_t); +int memcmp (const void*, const void*, size_t); +void* memcpy (const void*, const void*, size_t); + +int strncmp (const char*, const char*, size_t); +char* strncat (char*, const char*, size_t); +char* strncpy (char*, const char*, size_t); +size_t strnlen (const char*, size_t); + +void sink (int, ...); +#define sink(...) sink (0, __VA_ARGS__) +#define T(exp) sink (exp) + +NOIPA void test_memchr (const void *p, int x) +{ + size_t dmax = PTRDIFF_MAX; + size_t smax = SIZE_MAX; + + T (memchr (p, x, dmax)); + + T (memchr (p, x, dmax + 1)); // { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" } + T (memchr (p, x, dmax * 2)); // { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" } + T (memchr (p, x, smax)); // { dg-warning "\\\[-Wstringop-overread" } +} + + +NOIPA void test_memcmp (const void *p, const void *q) +{ + size_t dmax = PTRDIFF_MAX; + size_t smax = SIZE_MAX; + + T (memcmp (p, q, dmax)); + + T (memcmp (p, q, dmax + 1)); // { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" } + T (memcmp (p, q, dmax * 2)); // { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" } + T (memcmp (p, q, smax)); // { dg-warning "\\\[-Wstringop-overread" } +} + + +NOIPA void test_memcpy (void *p, const void *q) +{ + size_t dmax = PTRDIFF_MAX; + size_t smax = SIZE_MAX; + + T (memcpy (p, q, dmax)); + + T (memcpy (p, q, dmax + 1)); // -Wstringop-overflow disabled + T (memcpy (p, q, dmax * 2)); // ditto + T (memcpy (p, q, smax)); // ditto +} + + +NOIPA void test_strncmp (const char *p, const char *q) +{ + size_t dmax = PTRDIFF_MAX; + size_t smax = SIZE_MAX; + + T (strncmp (p, q, dmax)); + + T (strncmp (p, q, dmax + 1)); // { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "strncmp" } + T (strncmp (p, q, dmax * 2)); // { dg-warning "\\\[-Wstringop-overread" "strncmp" } + T (strncmp (p, q, smax)); // { dg-warning "\\\[-Wstringop-overread" "strncmp" } +} + +NOIPA void test_strncat (char *p, const char *q) +{ + size_t dmax = PTRDIFF_MAX; + size_t smax = SIZE_MAX; + + T (strncat (p, q, dmax)); + + T (strncat (p, q, dmax + 1)); // { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" } + T (strncat (p, q, dmax * 2)); // { dg-warning "\\\[-Wstringop-overread" } + T (strncat (p, q, smax)); // { dg-warning "\\\[-Wstringop-overread" } +} + +NOIPA void test_strncpy (char *p, const char *q) +{ +#if 0 + /* Disabled: strncpy calls with an excissve bound trigger both + -Wstringop-overflow and, when the former option is disabled, + -Wstringop-overread. The latter should probably not trigger. */ + + size_t dmax = PTRDIFF_MAX; + size_t smax = SIZE_MAX; + + T (strncpy (p, q, dmax)); + + T (strncpy (p, q, dmax + 1)); // -Wstringop-overflow disabled + T (strncpy (p, q, dmax * 2)); // ditto + T (strncpy (p, q, smax)); // ditto +#endif +} + +NOIPA void test_strnlen (const char *p) +{ + size_t dmax = PTRDIFF_MAX; + size_t smax = SIZE_MAX; + + T (strnlen (p, dmax)); + + T (strnlen (p, dmax + 1)); // { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" } + T (strnlen (p, dmax * 2)); // { dg-warning "\\\[-Wstringop-overread" } + T (strnlen (p, smax)); // { dg-warning "\\\[-Wstringop-overread" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overread-3.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-3.c new file mode 100644 index 0000000000..6c2c6b6a29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-3.c @@ -0,0 +1,188 @@ +/* Verify that calling strndup and strnlen with an unknown bound isn't + diagnosed regardless of the size of the array and the type of the bound. + { dg-do compile } + { dg-options "-O -Wall" } */ + +#define NOIPA __attribute__ ((noipa)) + +typedef __SIZE_TYPE__ size_t; + +extern char* strndup (const char*, size_t); +extern size_t strnlen (const char*, size_t); + +/* TO DO: Passing a zero-length array to any function is almost certainly + a bug and should be diagnosed except perpaphs when the function also + takes a bound and its value is known to be zero. When this is + implemented this test will need to be adjusted. */ +extern char a0[0]; + +extern char a1[1]; + +NOIPA char* strndup_a0_si (short n) +{ + return strndup (a0, n); +} + +NOIPA char* strndup_a0_i (int n) +{ + return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA char* strndup_a0_li (long n) +{ + return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA char* strndup_a0_lli (long long n) +{ + return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + + +NOIPA char* strndup_a0_usi (unsigned short n) +{ + return strndup (a0, n); +} + +NOIPA char* strndup_a0_ui (unsigned n) +{ + return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA char* strndup_a0_uli (unsigned long n) +{ + return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA char* strndup_a0_ulli (unsigned long long n) +{ + return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + + + +NOIPA char* strndup_a1_si (short n) +{ + return strndup (a1, n); +} + +NOIPA char* strndup_a1_i (int n) +{ + return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA char* strndup_a1_li (long n) +{ + return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA char* strndup_a1_lli (long long n) +{ + return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + + +NOIPA char* strndup_a1_usi (unsigned short n) +{ + return strndup (a1, n); +} + +NOIPA char* strndup_a1_ui (unsigned n) +{ + return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA char* strndup_a1_uli (unsigned long n) +{ + return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA char* strndup_a1_ulli (unsigned long long n) +{ + return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + + +NOIPA size_t strnlen_a0_si (short n) +{ + return strnlen (a0, n); +} + +NOIPA size_t strnlen_a0_i (int n) +{ + return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA size_t strnlen_a0_li (long n) +{ + return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA size_t strnlen_a0_lli (long long n) +{ + return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + + +NOIPA size_t strnlen_a0_usi (unsigned short n) +{ + return strnlen (a0, n); +} + +NOIPA size_t strnlen_a0_ui (unsigned n) +{ + return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA size_t strnlen_a0_uli (unsigned long n) +{ + return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA size_t strnlen_a0_ulli (unsigned long long n) +{ + return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + + + +NOIPA size_t strnlen_a1_si (short n) +{ + return strnlen (a1, n); +} + +NOIPA size_t strnlen_a1_i (int n) +{ + return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA size_t strnlen_a1_li (long n) +{ + return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA size_t strnlen_a1_lli (long long n) +{ + return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + + +NOIPA size_t strnlen_a1_usi (unsigned short n) +{ + return strnlen (a1, n); +} + +NOIPA size_t strnlen_a1_ui (unsigned n) +{ + return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA size_t strnlen_a1_uli (unsigned long n) +{ + return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} + +NOIPA size_t strnlen_a1_ulli (unsigned long long n) +{ + return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overread-4.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-4.c new file mode 100644 index 0000000000..8248dad213 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-4.c @@ -0,0 +1,58 @@ +/* Verify -Wstringop-overread with a source pointer pointing either + before the beginning or past the end of an object. + { dg-do compile } + { dg-options "-O -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +size_t strlen (const char *); + + +extern char a[1]; + +volatile size_t n; + +void len_si_1_max (int i) +{ + if (i < 1) i = 1; + n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n = strlen (a + i + 1); // { dg-warning "reading 1 or more bytes from a region of size 0" } +} + +void len_ui_1_max (unsigned i) +{ + if (i < 1) i = 1; + n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n = strlen (a + i + 1); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail ilp32 } } +} + +void len_sl_1_max (long i) +{ + if (i < 1) i = 1; + n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n = strlen (a + i + 1); // { dg-warning "reading 1 or more bytes from a region of size 0" } +} + +void len_ul_1_max (unsigned long i) +{ + if (i < 1) i = 1; + n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n = strlen (a + i + 1); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail *-*-* } } +} + + +void len_si_min_m1 (int i) +{ + if (i > -1) i = -1; + n = strlen (a + i - 1); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail lp64 } } + n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail *-*-* } } + n = strlen (a + i + 2); +} + +void len_sl_min_m1 (long i) +{ + if (i > -1) i = -1; + n = strlen (a + i - 1); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n = strlen (a + i); // { dg-warning "reading 1 or more bytes from a region of size 0" "" { xfail *-*-* } } + n = strlen (a + i + 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overread-5.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-5.c new file mode 100644 index 0000000000..b75002b429 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-5.c @@ -0,0 +1,76 @@ +/* Verify -Wstringop-overread with a source pointer pointing either + before the beginning or past the end of an object. + { dg-do compile } + { dg-options "-O -Wall -Wno-array-bounds" } */ + +typedef __SIZE_TYPE__ size_t; + +size_t strlen (const char *); + +void sink (void*, ...); + +void off_sz_or_1 (size_t i) +{ + i |= 1; + + /* Verify the offset in the notes only mentions the meaningful lower + bound and not a range with the excessive (and meaningless) upper + bound like [2, 9223372036854775807]. */ + extern char a[1]; + // { dg-message "at offset 1 into source object 'a'" "note" { target *-*-* } .-1 } + // { dg-message "at offset 2 " "note" { target *-*-* } .-2 } + + char *p1 = a + i; + char *p2 = p1 + 1; + char *p3 = p1 - 1; + + size_t n = 0; + n += strlen (p1); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n += strlen (p2); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n += strlen (p3); + + sink (p1, p2, p3, n); +} + + +void off_sz_or_2 (size_t i) +{ + i |= 2; + + extern char b[2]; + // { dg-message "at offset 2 " "note" { target *-*-* } .-1 } + // { dg-message "at offset 3 " "note" { target *-*-* } .-2 } + + char *p1 = b + i; + char *p2 = p1 + 1; + char *p3 = p1 - 1; + + size_t n = 0; + n += strlen (p1); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n += strlen (p2); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n += strlen (p3); + + sink (p1, p2, p3, n); +} + + +void off_sz_or_4 (size_t i) +{ + i |= 4; + + extern char c[3]; + // { dg-message "at offset 4 " "note" { target *-*-* } .-1 } + // { dg-message "at offset 5 " "note" { target *-*-* } .-2 } + // { dg-message "at offset 3 " "note" { target *-*-* } .-3 } + + char *p1 = c + i; + char *p2 = p1 + 1; + char *p3 = p1 - 1; + + size_t n = 0; + n += strlen (p1); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n += strlen (p2); // { dg-warning "reading 1 or more bytes from a region of size 0" } + n += strlen (p3); // { dg-warning "reading 1 or more bytes from a region of size 0" } + + sink (p1, p2, p3, n); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overread-6.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-6.c new file mode 100644 index 0000000000..a8177a316c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overread-6.c @@ -0,0 +1,574 @@ +/* Verify -Wstringop-overread is issued appropriately for calls to string + functions at -O0 and without -Wall. + { dg-do compile } + { dg-options "-O0 -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +#define S2 "12" +#define S9 "123456789" + +// functions. + +char* gettext (const char *); + +// functions. + +typedef struct FILE FILE; + +int fputs (const char*, FILE*); +int fputs_unlocked (const char*, FILE*); + +int puts (const char*); +int puts_unlocked (const char*); + +// functions. + +void* memchr (const void*, int, size_t); +int memcmp (const void*, const void*, size_t); +void* memcpy (void*, const void*, size_t); +void* mempcpy (void*, const void*, size_t); +void* memmove (void*, const void*, size_t); + +char* strchr (const char*, int); +char* strrchr (const char*, int); + +int strcmp (const char*, const char*); +int strncmp (const char*, const char*, size_t); + +char* strcat (char*, const char*); +char* stpcpy (char*, const char*); +char* strcpy (char*, const char*); +char* stpncpy (char*, const char*, size_t); +char* strncpy (char*, const char*, size_t); +char* strdup (const char*); +char* strndup (const char*, size_t); + +char* strpbrk (const char*, const char*); +size_t strcspn (const char*, const char*); +size_t strspn (const char*, const char*); +char* strstr (const char*, const char*); + +size_t strlen (const char*); +size_t strnlen (const char*, size_t); + + +extern void* malloc (size_t); + +void sink (void*); + + +extern char *d; +extern char a0[0]; + +const char arr[7] = "abc\0def"; + +/* Unterminated array at the end of ARR above. */ +#define unterm (arr + __builtin_strlen (arr) + 1) + +/* Size of the unterminated array - 1. */ +#define unterm_size (sizeof arr - __builtin_strlen (arr) - 1) + +const void* nowarn_memchr (int x) +{ + const char *p1 = unterm; + return memchr (p1, x, unterm_size); +} + +const void* warn_memchr (int x) +{ + const char *p1 = unterm; + return memchr (p1, x, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + + +void* nowarn_memcpy (void) +{ + const char *s = unterm; + return memcpy (d, s, unterm_size); +} + +void* warn_memcpy (void) +{ + const char *s = unterm; + /* Use + 2 for an odd size to prevent the memmove --> MEM_REF transform + from defeating the warning (for now). */ + return memcpy (d, s, unterm_size + 2 | 1); // { dg-warning "-Wstringop-overread" } +} + + +void* nowarn_mempcpy (void) +{ + const char *s = unterm; + return mempcpy (d, s, unterm_size); +} + +void* warn_mempcpy (void) +{ + const char *s = unterm; + /* Use + 2 for an odd size to prevent the memmove --> MEM_REF transform + from defeating the warning (for now). */ + return mempcpy (d, s, unterm_size + 2 | 1); // { dg-warning "-Wstringop-overread" } +} + + +void* nowarn_memmove (void) +{ + const char *s = unterm; + return memmove (d, s, unterm_size); +} + +void* warn_memmove (void) +{ + const char *s = unterm; + /* Use + 2 for an odd size to prevent the memmove --> MEM_REF transform + from defeating the warning (for now). */ + return memmove (d, s, unterm_size + 2); // { dg-warning "-Wstringop-overread" } +} + + +int nowarn_memcmp_1 (const char *p2) +{ + const char *p1 = unterm; + return memcmp (p1, p2, unterm_size); +} + +int warn_memcmp_1 (const char *p2) +{ + const char *p1 = unterm; + return memcmp (p1, p2, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + +int nowarn_memcmp_2 (const char *p1) +{ + const char *p2 = unterm; + return memcmp (p1, p2, unterm_size); +} + +int warn_memcmp_2 (const char *p1) +{ + const char *p2 = unterm; + return memcmp (p1, p2, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + + +void warn_strcat (void) +{ + strcat (d, unterm); // { dg-warning "-Wstringop-overread" } +} + +void warn_strcat_a0 (void) +{ + strcat (d, a0); // { dg-warning "-Wstringop-overread" } +} + +void warn_strcat_end (void) +{ + const char *s = arr + sizeof arr; + strcat (d, s); // { dg-warning "-Wstringop-overread" } +} + +char* warn_stpcpy (void) +{ + return stpcpy (d, unterm); // { dg-warning "-Wstringop-overread" } +} + +char* warn_stpcpy_a0 (void) +{ + return stpcpy (d, a0); // { dg-warning "-Wstringop-overread" } +} + +char* warn_stpcpy_end (void) +{ + const char *s = arr + sizeof arr; + return stpcpy (d, s); // { dg-warning "-Wstringop-overread" } +} + +char* warn_stpcpy_malloc0 (void) +{ + char *s = malloc (0); + sink (s); + return stpcpy (d, s); // { dg-warning "-Wstringop-overread" } +} + + +void warn_strcpy (void) +{ + strcpy (d, unterm); // { dg-warning "-Wstringop-overread" } +} + +void warn_strcpy_a0 (void) +{ + strcpy (d, a0); // { dg-warning "-Wstringop-overread" } +} + +void warn_strcpy_end (void) +{ + const char *s = arr + sizeof arr; + strcpy (d, s); // { dg-warning "-Wstringop-overread" } +} + +void warn_strcpy_malloc0 (void) +{ + char *s = malloc (0); + sink (s); + strcpy (d, s); // { dg-warning "-Wstringop-overread" } +} + + +char* nowarn_stpncpy (void) +{ + const char *s = unterm; + return stpncpy (d, s, unterm_size); +} + +char* warn_stpncpy (void) +{ + const char *s = unterm; + return stpncpy (d, s, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + +char* warn_stpncpy_a0 (void) +{ + return stpncpy (d, a0, 3); // { dg-warning "-Wstringop-overread" } +} + +char* warn_stpncpy_end (void) +{ + const char *s = arr + sizeof arr; + return stpncpy (d, s, sizeof arr); // { dg-warning "-Wstringop-overread" } +} + + +void nowarn_strncpy (void) +{ + const char *s = unterm; + strncpy (d, s, unterm_size); +} + +void warn_strncpy (void) +{ + const char *s = unterm; + strncpy (d, s, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + +void warn_strncpy_a0 (void) +{ + const char *s = a0; + strncpy (d, s, sizeof arr); // { dg-warning "-Wstringop-overread" } +} + +void warn_strncpy_end (void) +{ + const char *s = arr + sizeof arr; + strncpy (d, s, sizeof arr); // { dg-warning "-Wstringop-overread" } +} + + +int warn_strlen (void) +{ + return strlen (unterm); // { dg-warning "-Wstringop-overread" } +} + +int warn_strlen_a0 (void) +{ + return strlen (a0); // { dg-warning "-Wstringop-overread" } +} + +int warn_strlen_end (void) +{ + const char *s = arr + sizeof arr; + return strlen (s); // { dg-warning "-Wstringop-overread" } +} + +int warn_strlen_malloc0 (void) +{ + char *s = malloc (0); + sink (s); + return strlen (s); // { dg-warning "-Wstringop-overread" } +} + + +int nowarn_strnlen (void) +{ + return strnlen (unterm, unterm_size); +} + +int warn_strnlen (void) +{ + return strnlen (unterm, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + +int warn_strnlen_end (void) +{ + const char *s = arr + sizeof arr; + return strnlen (s, 2); // { dg-warning "-Wstringop-overread" } +} + + +int warn_strcmp_1 (const char *s) +{ + return strcmp (unterm, s); // { dg-warning "-Wstringop-overread" } +} + +int warn_strcmp_2 (const char *s) +{ + return strcmp (s, unterm); // { dg-warning "-Wstringop-overread" } +} + +int warn_strcmp_2_end (const char *s) +{ + const char *t = arr + sizeof arr; + return strcmp (s, t); // { dg-warning "-Wstringop-overread" } +} + + +int nowarn_strncmp_1 (const char *s2) +{ + const char *s1 = unterm; + return strncmp (s1, s2, unterm_size); +} + +int warn_strncmp_1 (const char *s2) +{ + const char *s1 = unterm; + return strncmp (s1, s2, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + +int nowarn_strncmp_2 (const char *s1) +{ + const char *s2 = unterm; + return strncmp (s1, s2, unterm_size); +} + +int warn_strncmp_2 (const char *s1) +{ + const char *s2 = unterm; + return strncmp (s1, s2, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + +int warn_strncmp_2_end (const char *s1) +{ + const char *s2 = arr + sizeof arr;; + return strncmp (s1, s2, sizeof arr); // { dg-warning "-Wstringop-overread" } +} + + +int nowarn_strncmp_1_s2 (void) +{ + /* Since the read is also bounded by the length of the S2 literal + and so safe, expect no warning. */ + const char *s = unterm; + return strncmp (s, S2, unterm_size + 1); // { dg-bogus "-Wstringop-overread" "pr101778" { xfail *-*-* } } +} + +int warn_strncmp_2_s2 (void) +{ + /* Same as above. */ + const char *t = unterm; + return strncmp (S2, t, unterm_size + 1); // { dg-bogus "-Wstringop-overread" "pr101778" { xfail *-*-* } } +} + + +int warn_strncmp_1_s9 (void) +{ + /* Since both the bound and the length of the S9 literal are greater + than the size of UNNTERM the call reads past the end of the array. + Expect a warning. */ + const char *s1 = unterm; + return strncmp (s1, S9, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + +int warn_strncmp_2_s9 (void) +{ + /* Same as above. */ + const char *s2 = unterm; + return strncmp (S9, s2, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + + +const char* warn_strchr (int x) +{ + return strchr (unterm, x); // { dg-warning "-Wstringop-overread" } +} + +const char* warn_strchr_end (int x) +{ + const char *s = arr + sizeof arr; + return strchr (s, x); // { dg-warning "-Wstringop-overread" } +} + + +const char* warn_strrchr (int x) +{ + return strrchr (unterm, x); // { dg-warning "-Wstringop-overread" } +} + +const char* warn_strrchr_end (int x) +{ + const char *s = arr + sizeof arr; + return strrchr (s, x); // { dg-warning "-Wstringop-overread" } +} + + +char* warn_strdup (void) +{ + return strdup (unterm); // { dg-warning "-Wstringop-overread" } +} + +char* warn_strdup_end (void) +{ + const char *s = arr + sizeof arr; + return strdup (s); // { dg-warning "-Wstringop-overread" } +} + + +char* nowarn_strndup (void) +{ + return strndup (unterm, unterm_size); +} + +char* warn_strndup (void) +{ + return strndup (unterm, unterm_size + 1); // { dg-warning "-Wstringop-overread" } +} + +char* warn_strndup_end (void) +{ + const char *s = arr + sizeof arr; + return strndup (s, sizeof arr); // { dg-warning "-Wstringop-overread" } +} + + +const char* warn_strpbrk_1 (const char *s2) +{ + return strpbrk (unterm, s2); // { dg-warning "-Wstringop-overread" } +} + +const char* warn_strpbrk_2 (const char *s1) +{ + return strpbrk (s1, unterm); // { dg-warning "-Wstringop-overread" } +} + + +size_t warn_strspn_1 (const char *s2) +{ + return strspn (unterm, s2); // { dg-warning "-Wstringop-overread" } +} + +size_t warn_strspn_1_end (const char *s2) +{ + const char *s1 = arr + sizeof arr; + return strspn (s1, s2); // { dg-warning "-Wstringop-overread" } +} + +size_t warn_strspn_2 (const char *s1) +{ + return strspn (s1, unterm); // { dg-warning "-Wstringop-overread" } +} + +size_t warn_strspn_2_end (const char *s1) +{ + const char *s2 = arr + sizeof arr; + return strspn (s1, s2); // { dg-warning "-Wstringop-overread" } +} + + +size_t warn_strcspn_1 (const char *s2) +{ + return strcspn (unterm, s2); // { dg-warning "-Wstringop-overread" } +} + +size_t warn_strcspn_1_end (const char *s2) +{ + const char *s1 = arr + sizeof arr; + return strcspn (s1, s2); // { dg-warning "-Wstringop-overread" } +} + +size_t warn_strcspn_2 (const char *s1) +{ + return strcspn (s1, unterm); // { dg-warning "-Wstringop-overread" } +} + +size_t warn_strcspn_2_end (const char *s1) +{ + const char *s2 = arr + sizeof arr; + return strcspn (s1, s2); // { dg-warning "-Wstringop-overread" } +} + + +const char* warn_strstr_1 (const char *s2) +{ + return strstr (unterm, s2); // { dg-warning "-Wstringop-overread" } +} + +const char* warn_strstr_1_end (const char *s2) +{ + const char *s1 = arr + sizeof arr; + return strstr (s1, s2); // { dg-warning "-Wstringop-overread" } +} + + +const char* warn_strstr_2 (const char *s1) +{ + return strstr (s1, unterm); // { dg-warning "-Wstringop-overread" } +} + +const char* warn_strstr_2_end (const char *s1) +{ + const char *s2 = arr + sizeof arr; + return strstr (s1, s2); // { dg-warning "-Wstringop-overread" } +} + + +void warn_puts (void) +{ + puts (unterm); // { dg-warning "-Wstringop-overread" } +} + +void warn_puts_end (void) +{ + const char *s = arr + sizeof arr; + puts (s); // { dg-warning "-Wstringop-overread" } +} + + +void warn_fputs (FILE *f) +{ + fputs (unterm, f); // { dg-warning "-Wstringop-overread" } +} + +void warn_fputs_end (FILE *f) +{ + const char *s = arr + sizeof arr; + fputs (s, f); // { dg-warning "-Wstringop-overread" } +} + + +void warn_puts_unlocked (void) +{ + puts_unlocked (unterm); // { dg-warning "-Wstringop-overread" } +} + +void warn_puts_unlocked_end (void) +{ + const char *s = arr + sizeof arr; + puts_unlocked (s); // { dg-warning "-Wstringop-overread" } +} + +void warn_fputs_unlocked (FILE *f) +{ + fputs_unlocked (unterm, f); // { dg-warning "-Wstringop-overread" } +} + + +const char* warn_gettext (void) +{ + return gettext (unterm); // { dg-warning "-Wstringop-overread" } +} + +const char* warn_gettext_end (void) +{ + const char *s = arr + sizeof arr; + return gettext (s); // { dg-warning "-Wstringop-overread" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-overread.c b/SingleSource/Regression/C/gcc-dg/Wstringop-overread.c new file mode 100644 index 0000000000..7db7402981 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-overread.c @@ -0,0 +1,716 @@ +/* Verify -Wstringop-overread is issued appropriately. + { dg-do compile } + { dg-options "-O2 -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +// functions. + +char* gettext (const char *); + +// functions. + +int puts (const char*); +int puts_unlocked (const char*); + +// functions. + +char* strchr (const char*, int); + +int strcmp (const char*, const char*); +int strncmp (const char*, const char*, size_t); + +char* strcat (char*, const char*); +char* strcpy (char*, const char*); +char* strncpy (char*, const char*, size_t); +char* strdup (const char*); +char* strndup (const char*, size_t); + +char* strpbrk (char*, const char*); +size_t strcspn (const char*, const char*); +size_t strspn (const char*, const char*); +char* strstr (char*, const char*); + +size_t strlen (const char*); +size_t strnlen (const char*, size_t); + + +void sink (int, ...); +#define sink(...) sink (0, __VA_ARGS__) + +extern char *d; +extern char a0[0]; // { dg-message "source object 'a0'" } +extern char a1[1]; // { dg-message "source object 'a1'" } +extern char a2[2]; // { dg-message "source object 'a2'" } + +extern char b1[1]; +extern char b2[2]; +extern char bx[]; + +const char s0[0] = { }; // { dg-message "source object 's0'" } +const char s1[1] = ""; // { dg-message "source object 's1'" } +const char s2[2] = "1"; // { dg-message "source object 's2'" } + +#define T(x) sink (0, (x)) + + +void test_strcat_array (const char *s, int i, int i0) +{ + if (i0 < 0) + i0 = 0; + + T (strcat (d, a0)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, a0 + i)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, a0 + i + 1)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + + T (strcat (d, a0 + i0)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + + T (strcat (d, a1)); + T (strcat (d, a1 + 1)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, a1 + i)); + T (strcat (d, a1 + i + 1)); + + T (strcat (d, a1 + i0)); + T (strcat (d, a1 + i0 + 1)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + + T (strcat (d, a2)); + T (strcat (d, a2 + 1)); + T (strcat (d, a2 + 2)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, a2 + i)); + T (strcat (d, a2 + i + 2)); + + T (strcat (d, a2 + i0)); + T (strcat (d, a2 + i0 + 1)); + T (strcat (d, a2 + i0 + 2)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + + // Repeat the above with the arguments reversed. + + T (strcat (a0, s)); // { dg-warning "'strcat' writing 1 or more bytes into a region of size 0" } + T (strcat (a0 + i, s)); // { dg-warning "'strcat' writing 1 or more bytes into a region of size 0" } + T (strcat (a0 + i + 1, s)); // { dg-warning "'strcat' writing 1 or more bytes into a region of size 0" } + + T (strcat (a0 + i0, s)); // { dg-warning "'strcat' writing 1 or more bytes into a region of size 0" } + + T (strcat (a1, s)); + T (strcat (a1 + 1, s)); // { dg-warning "'strcat' writing 1 or more bytes into a region of size 0" } + T (strcat (a1 + i, s)); + T (strcat (a1 + i + 1, s)); + + T (strcat (a1 + i0, s)); + T (strcat (a1 + i0 + 1, s)); // { dg-warning "'strcat' writing 1 or more bytes into a region of size 0" } + + T (strcat (a2, s)); + T (strcat (a2 + 1, s)); + T (strcat (a2 + 2, s)); // { dg-warning "'strcat' writing 1 or more bytes into a region of size 0" } + T (strcat (a2 + i, s)); + T (strcat (a2 + i + 2, s)); + + T (strcat (a2 + i0, s)); + T (strcat (a2 + i0 + 1, s)); + T (strcat (a2 + i0 + 2, s)); // { dg-warning "'strcat' writing 1 or more bytes into a region of size 0" } +} + +void test_strcat_literal (int i) +{ + T (strcat (d, "")); + T (strcat (d, "" + 0)); + T (strcat (d, "" + i)); + + T (strcat (d, "1")); + T (strcat (d, "1" + 1)); + T (strcat (d, "1" + 2)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, "1" + i)); + + T (strcat (d, "12")); + T (strcat (d, "12" + 1)); + T (strcat (d, "12" + 2)); + T (strcat (d, "12" + 3)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, "12" + i)); +} + +void test_strcat_string (int i) +{ + T (strcat (d, s0)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, s0 + 1)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, s0 + i)); // { dg-warning "'strcat' (reading 1 or more bytes from a region of size 0|argument missing terminating nul)" } + + T (strcat (d, s1)); + T (strcat (d, s1 + 1)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, s1 + 2)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, s1 + i)); + + T (strcat (d, s2)); + T (strcat (d, s2 + 1)); + T (strcat (d, s2 + 2)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, s2 + 3)); // { dg-warning "'strcat' reading 1 or more bytes from a region of size 0" } + T (strcat (d, s2 + i)); +} + + +void test_strcpy_array (int i, int i0) +{ + if (i0 < 0) + i0 = 0; + + T (strcpy (d, a0)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, a0 + i)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, a0 + i + 1)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + + T (strcpy (d, a0 + i0)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + + T (strcpy (d, a1)); + T (strcpy (d, a1 + 1)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, a1 + i)); + T (strcpy (d, a1 + i + 1)); + + T (strcpy (d, a1 + i0)); + T (strcpy (d, a1 + i0 + 1)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + + T (strcpy (d, a2)); + T (strcpy (d, a2 + 1)); + T (strcpy (d, a2 + 2)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, a2 + i)); + T (strcpy (d, a2 + i + 2)); + + T (strcpy (d, a2 + i0)); + T (strcpy (d, a2 + i0 + 1)); + T (strcpy (d, a2 + i0 + 2)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } +} + +void test_strcpy_literal (int i) +{ + T (strcpy (d, "")); + T (strcpy (d, "" + 0)); + T (strcpy (d, "" + i)); + + T (strcpy (d, "1")); + T (strcpy (d, "1" + 1)); + T (strcpy (d, "1" + 2)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, "1" + i)); + + T (strcpy (d, "12")); + T (strcpy (d, "12" + 1)); + T (strcpy (d, "12" + 2)); + T (strcpy (d, "12" + 3)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, "12" + i)); +} + +void test_strcpy_string (int i) +{ + T (strcpy (d, s0)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, s0 + 1)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, s0 + i)); // { dg-warning "'strcpy' (reading 1 or more bytes from a region of size 0|argument missing terminating nul)" } + + T (strcpy (d, s1)); + T (strcpy (d, s1 + 1)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, s1 + 2)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, s1 + i)); + + T (strcpy (d, s2)); + T (strcpy (d, s2 + 1)); + T (strcpy (d, s2 + 2)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, s2 + 3)); // { dg-warning "'strcpy' reading 1 or more bytes from a region of size 0" } + T (strcpy (d, s2 + i)); +} + + +void test_strncpy_array (int i) +{ + T (strncpy (d, a0, 0)); + T (strncpy (d, a0, 1)); // { dg-warning "'strncpy' reading 1 byte from a region of size 0" } + T (strncpy (d, a0 + i, 0)); + T (strncpy (d, a0 + i, 1)); // { dg-warning "'strncpy' reading 1 byte from a region of size 0" } + + T (strncpy (d, a1, 0)); + T (strncpy (d, a1, 1)); + T (strncpy (d, a1 + 1, 0)); + T (strncpy (d, a1 + 1, 1)); // { dg-warning "'strncpy' reading 1 byte from a region of size 0" } + T (strncpy (d, a1 + i, 0)); + T (strncpy (d, a1 + i, 1)); + T (strncpy (d, a1 + i, 2)); +} + + +void test_strncpy_literal (int i, int i0) +{ + if (i0 < 0) + i0 = 0; + + T (strncpy (d, "", 0)); + T (strncpy (d, "", 1)); + T (strncpy (d, "", 2)); + + T (strncpy (d, "" + i, 0)); + T (strncpy (d, "" + i, 1)); + T (strncpy (d, "" + i0, 1)); + T (strncpy (d, "" + i0, 1)); + + T (strncpy (d, "" + 1, 0)); + T (strncpy (d, "" + 1, 1)); // { dg-warning "'strncpy' reading 1 byte from a region of size 0" } + + T (strncpy (d, "1", 0)); + T (strncpy (d, "1" + 1, 0)); + T (strncpy (d, "1" + 1, 1)); + T (strncpy (d, "1" + 1, 2)); + T (strncpy (d, "1" + i, 2)); + + T (strncpy (d, "1" + 2, 0)); + T (strncpy (d, "1" + 2, 1)); // { dg-warning "'strncpy' reading 1 byte from a region of size 0" } +} + + +void test_strlen_array (int i, int i0) +{ + if (i0 < 0) + i0 = 0; + + T (strlen (a0)); // { dg-warning "'strlen' reading 1 or more bytes from a region of size 0" } + T (strlen (a0 + i)); // { dg-warning "'strlen' reading 1 or more bytes from a region of size 0" } + T (strlen (a0 + i + 1)); // { dg-warning "'strlen' reading 1 or more bytes from a region of size 0" } + + T (strlen (a0 + i0)); // { dg-warning "'strlen' reading 1 or more bytes from a region of size 0" } + + T (strlen (a1)); + T (strlen (a1 + 1)); // { dg-warning "'strlen' reading 1 or more bytes from a region of size 0" } + T (strlen (a1 + i)); + T (strlen (a1 + i + 1)); + + T (strlen (a1 + i0)); + T (strlen (a1 + i0 + 1)); // { dg-warning "'strlen' reading 1 or more bytes from a region of size 0" } + + T (strlen (a2)); + T (strlen (a2 + 1)); + T (strlen (a2 + 2)); // { dg-warning "'strlen' reading 1 or more bytes from a region of size 0" } + T (strlen (a2 + i)); + T (strlen (a2 + i + 2)); + + T (strlen (a2 + i0)); + T (strlen (a2 + i0 + 1)); + T (strlen (a2 + i0 + 2)); // { dg-warning "'strlen' reading 1 or more bytes from a region of size 0" } +} + + +void test_strnlen_array (int i, int i0, unsigned n) +{ + if (i0 < 0) + i0 = 0; + + T (strnlen (a0, 0)); + T (strnlen (a0, 1)); // { dg-warning "'strnlen' (reading 1 byte from a region of size 0|specified bound 1 exceeds source size 0)" } + T (strnlen (a0, i0)); + T (strnlen (a0, i0 + 1)); // { dg-warning "'strnlen' (reading between 1 and \[0-9\]+ bytes from a region of size 0|specified bound \\\[1, \[0-9\]+\\\] exceeds source size 0)" } + T (strnlen (a0, n)); + T (strnlen (a0 + i, 0)); + T (strnlen (a0 + i, 1)); // { dg-warning "'strnlen' (reading 1 byte from a region of size 0|specified bound 1 exceeds source size 0)" } + T (strnlen (a0 + i, i0)); + T (strnlen (a0 + i, n)); + T (strnlen (a0 + i + 1, 0)); + T (strnlen (a0 + i + 1, 1)); // { dg-warning "'strnlen' (reading 1 byte from a region of size 0|specified bound 1 exceeds source size 0)" } + + T (strnlen (a0 + i0, 0)); + T (strnlen (a0 + i0, 1)); // { dg-warning "'strnlen' (reading 1 byte from a region of size 0|specified bound 1 exceeds source size 0)" } + T (strnlen (a0 + i0, n)); + + T (strnlen (a1, 0)); + T (strnlen (a1, 1)); + T (strnlen (a1, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" "pr87492" { xfail *-*-* } } + T (strnlen (a1, n)); + + T (strnlen (a1 + 1, 0)); + T (strnlen (a1 + 1, 1)); // { dg-warning "'strnlen' specified bound 1 exceeds source size 0" } + T (strnlen (a1 + 1, i0)); + T (strnlen (a1 + 1, i0 + 1)); // { dg-warning "'strnlen' specified bound \\\[1, \\d+] exceeds source size 0" } + T (strnlen (a1 + 1, n)); + T (strnlen (a1 + i, 0)); + T (strnlen (a1 + i, 1)); + T (strnlen (a1 + i, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" } + T (strnlen (a1 + i, n)); + T (strnlen (a1 + i + 1, 0)); + T (strnlen (a1 + i + 1, 1)); + T (strnlen (a1 + i + 1, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" } + T (strnlen (a1 + i + 1, n)); + + T (strnlen (a1 + i0, 0)); + T (strnlen (a1 + i0, 1)); + T (strnlen (a1 + i0, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" } + T (strnlen (a1 + i0, n)); + T (strnlen (a1 + i0 + 1, 0)); + T (strnlen (a1 + i0 + 1, 1)); // { dg-warning "'strnlen' specified bound 1 exceeds source size 0" } + T (strnlen (a1 + i0 + 1, n)); + + T (strnlen (a2, 0)); + T (strnlen (a2, 1)); + T (strnlen (a2, 2)); + T (strnlen (a2, n)); + T (strnlen (a2 + 1, 0)); + T (strnlen (a2 + 1, 1)); + T (strnlen (a2 + 1, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" "pr87492" } + T (strnlen (a2 + 1, n)); + T (strnlen (a2 + 2, 0)); + T (strnlen (a2 + 2, 1)); // { dg-warning "'strnlen' specified bound 1 exceeds source size 0" } + T (strnlen (a2 + 2, n)); + T (strnlen (a2 + i, 0)); + T (strnlen (a2 + i, 1)); + T (strnlen (a2 + i, 2)); + T (strnlen (a2 + i + 2, 0)); + T (strnlen (a2 + i + 2, 1)); + T (strnlen (a2 + i + 2, 2)); + T (strnlen (a2 + i + 2, n)); + + T (strnlen (a2 + i0, 0)); + T (strnlen (a2 + i0, 1)); + T (strnlen (a2 + i0, 2)); + T (strnlen (a2 + i0, 3)); // { dg-warning "'strnlen' specified bound 3 exceeds source size 2" } + T (strnlen (a2 + i0, n)); + + T (strnlen (a2 + i0 + 1, 0)); + T (strnlen (a2 + i0 + 1, 1)); + T (strnlen (a2 + i0 + 1, 2)); // { dg-warning "'strnlen' specified bound 2 exceeds source size 1" } + T (strnlen (a2 + i0 + 1, n)); + + T (strnlen (a2 + i0 + 2, 0)); + T (strnlen (a2 + i0 + 2, 1)); // { dg-warning "'strnlen' specified bound 1 exceeds source size 0" } + T (strnlen (a2 + i0 + 2, i0)); + T (strnlen (a2 + i0 + 2, i0 + 1)); // { dg-warning "'strnlen' specified bound \\\[1, \\d+] exceeds source size 0" } + T (strnlen (a2 + i0 + 2, n)); +} + + +void test_strcmp_array (const char *s, int i) +{ + T (strcmp (a0, "")); // { dg-warning "'strcmp' reading 1 or more bytes from a region of size 0" "pr?????" { xfail *-*-* } } + + T (strcmp (a0, s)); // { dg-warning "'strcmp' reading 1 or more bytes from a region of size 0" } + T (strcmp (a0 + i, s)); // { dg-warning "'strcmp' reading 1 or more bytes from a region of size 0" } + + T (strcmp (a1, s)); + T (strcmp (a1 + 1, s)); // { dg-warning "'strcmp' reading 1 or more bytes from a region of size 0" } + T (strcmp (a1 + i, s)); + T (strcmp (a1 + i + 1, s)); + + + // Repeat the above with the arguments reversed. + + T (strcmp ("", a0)); // { dg-warning "'strcmp' reading 1 or more bytes from a region of size 0" "pr?????" { xfail *-*-*} } + + T (strcmp (s, a0)); // { dg-warning "'strcmp' reading 1 or more bytes from a region of size 0" } + T (strcmp (s, a0 + i)); // { dg-warning "'strcmp' reading 1 or more bytes from a region of size 0" } + + T (strcmp (s, a1)); + T (strcmp (s, a1 + 1)); // { dg-warning "'strcmp' reading 1 or more bytes from a region of size 0" } + T (strcmp (s, a1 + i)); + T (strcmp (s, a1 + i + 1)); +} + +/* The number of characters read is considered to be bounded not just + by the third argument to strncmp but also by the length of the shorter + of the two strings. When the string length is unknowm, verify that + a warning is only issued for certain reading past the end but not + otherwise. */ + +void test_strncmp_array (const char *s, int i) +{ + T (strncmp (a0, a0, 0)); + + T (strncmp (a0, s, 0)); + T (strncmp (a0, s, 1)); // { dg-warning "'strncmp' reading 1 or more bytes from a region of size 0" "pr?????" { xfail *-*-* } } + + T (strncmp (a0, s, 2)); // { dg-warning "'strncmp' (reading between 1 and 2 bytes from a region of size 0|specified bound 2 exceeds source size 0)" } + T (strncmp (a1, s, 0)); + T (strncmp (a1, s, 1)); + T (strncmp (a1 + 1, s, 1)); // { dg-warning "'strncmp' reading 1 byte from a region of size 0" "pr?????" { xfail *-*-*} } + T (strncmp (a1, s, 1)); + T (strncmp (a1 + 1, s, 2)); // { dg-warning "'strncmp' (reading between 1 and 2 bytes from a region of size 0|specified bound 2 exceeds source size 0)" } + + T (strncmp (a2, s, 1)); + T (strncmp (a2, s, 2)); + T (strncmp (a2, s, 3)); + + T (strncmp (a2 + 1, s, 1)); + T (strncmp (a2 + 2, s, 2)); // { dg-warning "'strncmp' (reading between 1 and 2 bytes from a region of size 0|specified bound 2 exceeds source size 0)" } + + T (strncmp (a1, b1, 0)); + T (strncmp (a1, b1, 1)); + T (strncmp (a1, b1, 2)); // { dg-warning "'strncmp' specified bound 2 exceeds source size 1" } +} + + +void test_strncmp_literal (const char *s, int i) +{ + T (strncmp (a0, "", 0)); + T (strncmp (a0, "1", 0)); + T (strncmp (a0, "12", 0)); + + /* The calls with a bound in excess of the length of the literal are + folded early (most into strcmp) so the warning doesn't trigger. */ + T (strncmp (s, "", 0)); + + T (strncmp (s, "1", 0)); + T (strncmp (s, "1", 1)); + T (strncmp (s, "1", 2)); // { dg-warning "\\\[-Wstringop-overread" "pr93665" { xfail *-*-* } } + + T (strncmp (s, "12", 0)); + T (strncmp (s, "12", 1)); + T (strncmp (s, "12", 2)); + T (strncmp (s, "12", 3)); // { dg-warning "\\\[-Wstringop-overread" "pr93665" { xfail *-*-* } } + + T (strncmp (s, "123", 0)); + T (strncmp (s, "123", 1)); + T (strncmp (s, "123", 2)); + T (strncmp (s, "123", 3)); + T (strncmp (s, "123", 4)); // { dg-warning "\\\[-Wstringop-overread" "pr93665" { xfail *-*-* } } +} + + +void test_strchr_array (int x, int i) +{ + T (strchr (a0, x)); // { dg-warning "'strchr' reading 1 or more bytes from a region of size 0" } + T (strchr (a0 + i, x)); // { dg-warning "'strchr' reading 1 or more bytes from a region of size 0" } + + T (strchr (a1, x)); + T (strchr (a1 + 1, x)); // { dg-warning "'strchr' reading 1 or more bytes from a region of size 0" } + T (strchr (a1 + i, x)); + T (strchr (a1 + i + 1, x)); +} + + +void test_strdup_array (int i) +{ + T (strdup (a0)); // { dg-warning "'strdup' reading 1 or more bytes from a region of size 0" } + T (strdup (a0 + i)); // { dg-warning "'strdup' reading 1 or more bytes from a region of size 0" } + + T (strdup (a1)); + T (strdup (a1 + 1)); // { dg-warning "'strdup' reading 1 or more bytes from a region of size 0" } + T (strdup (a1 + i)); + T (strdup (a1 + i + 1)); +} + + +void test_strndup_array (int i, int i0, unsigned n) +{ + if (i0 < 0) + i0 = 0; + + T (strndup (a0, 0)); + T (strndup (a0, 1)); // { dg-warning "'strndup' (reading 1 byte from a region of size 0|specified bound 1 exceeds source size 0)" } + T (strndup (a0, i0)); + T (strndup (a0, i0 + 1)); // { dg-warning "'strndup' (reading between 1 and \[0-9\]+ bytes from a region of size 0|specified bound \\\[1, \[0-9\]+\\\] exceeds source size 0)" } + T (strndup (a0, n)); + T (strndup (a0 + i, 0)); + T (strndup (a0 + i, 1)); // { dg-warning "'strndup' (reading 1 byte from a region of size 0|specified bound 1 exceeds source size 0)" } + T (strndup (a0 + i, i0)); + T (strndup (a0 + i, n)); + T (strndup (a0 + i + 1, 0)); + T (strndup (a0 + i + 1, 1)); // { dg-warning "'strndup' (reading 1 byte from a region of size 0|specified bound 1 exceeds source size 0)" } + + T (strndup (a0 + i0, 0)); + T (strndup (a0 + i0, 1)); // { dg-warning "'strndup' (reading 1 byte from a region of size 0|specified bound 1 exceeds source size 0)" } + T (strndup (a0 + i0, n)); + + T (strndup (a1, 0)); + T (strndup (a1, 1)); + T (strndup (a1, 2)); // { dg-warning "'strndup' specified bound 2 exceeds source size 1" } + T (strndup (a1, n)); + T (strndup (a1 + 1, 0)); + T (strndup (a1 + 1, 1)); // { dg-warning "'strndup' specified bound 1 exceeds source size 0" } + T (strndup (a1 + 1, i0)); + T (strndup (a1 + 1, i0 + 1)); // { dg-warning "'strndup' specified bound \\\[1, \\d+] exceeds source size 0" } + T (strndup (a1 + 1, n)); + T (strndup (a1 + i, 0)); + T (strndup (a1 + i, 1)); + T (strndup (a1 + i, 2)); // { dg-warning "'strndup' specified bound 2 exceeds source size 1" } + T (strndup (a1 + i, n)); + T (strndup (a1 + i + 1, 0)); + T (strndup (a1 + i + 1, 1)); + T (strndup (a1 + i + 1, 2)); // { dg-warning "'strndup' specified bound 2 exceeds source size 1" } + T (strndup (a1 + i + 1, n)); + + T (strndup (a1 + i0, 0)); + T (strndup (a1 + i0, 1)); + T (strndup (a1 + i0, n)); + T (strndup (a1 + i0 + 1, 0)); + T (strndup (a1 + i0 + 1, 1)); // { dg-warning "'strndup' specified bound 1 exceeds source size 0" } + T (strndup (a1 + i0 + 1, n)); + + T (strndup (a2, 0)); + T (strndup (a2, 1)); + T (strndup (a2, 2)); + T (strndup (a2, n)); + T (strndup (a2 + 1, 0)); + T (strndup (a2 + 1, 1)); + T (strndup (a2 + 1, 2)); // { dg-warning "'strndup' specified bound 2 exceeds source size 1" } + T (strndup (a2 + 1, n)); + T (strndup (a2 + 2, 0)); + T (strndup (a2 + 2, 1)); // { dg-warning "'strndup' specified bound 1 exceeds source size 0" } + T (strndup (a2 + 2, n)); + T (strndup (a2 + i, 0)); + T (strndup (a2 + i, 1)); + T (strndup (a2 + i, 2)); + T (strndup (a2 + i + 2, 0)); + T (strndup (a2 + i + 2, 1)); + T (strndup (a2 + i + 2, 2)); + T (strndup (a2 + i + 2, n)); + + T (strndup (a2 + i0, 0)); + T (strndup (a2 + i0, 1)); + T (strndup (a2 + i0, 2)); + T (strndup (a2 + i0, 3)); // { dg-warning "'strndup' specified bound 3 exceeds source size 2" } + T (strndup (a2 + i0, n)); + + T (strndup (a2 + i0 + 1, 0)); + T (strndup (a2 + i0 + 1, 1)); + T (strndup (a2 + i0 + 1, 2)); // { dg-warning "'strndup' specified bound 2 exceeds source size 1" } + T (strndup (a2 + i0 + 1, n)); + + T (strndup (a2 + i0 + 2, 0)); + T (strndup (a2 + i0 + 2, 1)); // { dg-warning "'strndup' specified bound 1 exceeds source size 0" } + T (strndup (a2 + i0 + 2, i0)); + T (strndup (a2 + i0 + 2, i0 + 1)); // { dg-warning "'strndup' specified bound \\\[1, \\d+] exceeds source size 0" } + T (strndup (a2 + i0 + 2, n)); +} + + +void test_strpbrk_array (char *s, int i) +{ + T (strpbrk (a0, "")); // { dg-warning "'strpbrk' reading 1 or more bytes from a region of size 0" "pr?????" { xfail *-*-* } } + + T (strpbrk (a0, s)); // { dg-warning "'strpbrk' reading 1 or more bytes from a region of size 0" } + T (strpbrk (a0 + i, s)); // { dg-warning "'strpbrk' reading 1 or more bytes from a region of size 0" } + + T (strpbrk (a1, s)); + T (strpbrk (a1 + 1, s)); // { dg-warning "'strpbrk' reading 1 or more bytes from a region of size 0" } + T (strpbrk (a1 + i, s)); + T (strpbrk (a1 + i + 1, s)); + + + // Repeat the above with the arguments reversed. + + T (strpbrk ("", a0)); // { dg-warning "'strpbrk' reading 1 or more bytes from a region of size 0" } + + T (strpbrk (s, a0)); // { dg-warning "'strpbrk' reading 1 or more bytes from a region of size 0" } + T (strpbrk (s, a0 + i)); // { dg-warning "'strpbrk' reading 1 or more bytes from a region of size 0" } + + T (strpbrk (s, a1)); + T (strpbrk (s, a1 + 1)); // { dg-warning "'strpbrk' reading 1 or more bytes from a region of size 0" } + T (strpbrk (s, a1 + i)); + T (strpbrk (s, a1 + i + 1)); +} + + +void test_strspn_array (const char *s, int i) +{ + T (strspn (a0, "")); // { dg-warning "'strspn' reading 1 or more bytes from a region of size 0" "pr?????" { xfail *-*-* } } + + T (strspn (a0, s)); // { dg-warning "'strspn' reading 1 or more bytes from a region of size 0" } + T (strspn (a0 + i, s)); // { dg-warning "'strspn' reading 1 or more bytes from a region of size 0" } + + T (strspn (a1, s)); + T (strspn (a1 + 1, s)); // { dg-warning "'strspn' reading 1 or more bytes from a region of size 0" } + T (strspn (a1 + i, s)); + T (strspn (a1 + i + 1, s)); + + + // Repeat the above with the arguments reversed. + + T (strspn ("", a0)); // { dg-warning "'strspn' reading 1 or more bytes from a region of size 0" "pr?????" { xfail *-*-*} } + + T (strspn (s, a0)); // { dg-warning "'strspn' reading 1 or more bytes from a region of size 0" } + T (strspn (s, a0 + i)); // { dg-warning "'strspn' reading 1 or more bytes from a region of size 0" } + + T (strspn (s, a1)); + T (strspn (s, a1 + 1)); // { dg-warning "'strspn' reading 1 or more bytes from a region of size 0" } + T (strspn (s, a1 + i)); + T (strspn (s, a1 + i + 1)); +} + + +void test_strcspn_array (const char *s, int i) +{ + /* The call below is tranformed to strlen() so the warning references + the latter function instead of strcspn. Avoid testing that aspect. */ + T (strcspn (a0, "")); // { dg-warning "reading 1 or more bytes from a region of size 0" } + + T (strcspn (a0, s)); // { dg-warning "'strcspn' reading 1 or more bytes from a region of size 0" } + T (strcspn (a0 + i, s)); // { dg-warning "'strcspn' reading 1 or more bytes from a region of size 0" } + + T (strcspn (a1, s)); + T (strcspn (a1 + 1, s)); // { dg-warning "'strcspn' reading 1 or more bytes from a region of size 0" } + T (strcspn (a1 + i, s)); + T (strcspn (a1 + i + 1, s)); + + + // Repeat the above with the arguments reversed. + + T (strcspn ("", a0)); // { dg-warning "'strcspn' reading 1 or more bytes from a region of size 0" "pr?????" { xfail *-*-*} } + + T (strcspn (s, a0)); // { dg-warning "'strcspn' reading 1 or more bytes from a region of size 0" } + T (strcspn (s, a0 + i)); // { dg-warning "'strcspn' reading 1 or more bytes from a region of size 0" } + + T (strcspn (s, a1)); + T (strcspn (s, a1 + 1)); // { dg-warning "'strcspn' reading 1 or more bytes from a region of size 0" } + T (strcspn (s, a1 + i)); + T (strcspn (s, a1 + i + 1)); +} + + +void test_strstr_array (char *s, int i) +{ + T (strstr (a0, "")); // { dg-warning "'strstr' reading 1 or more bytes from a region of size 0" "pr?????" { xfail *-*-* } } + + T (strstr (a0, s)); // { dg-warning "'strstr' reading 1 or more bytes from a region of size 0" } + T (strstr (a0 + i, s)); // { dg-warning "'strstr' reading 1 or more bytes from a region of size 0" } + + T (strstr (a1, s)); + T (strstr (a1 + 1, s)); // { dg-warning "'strstr' reading 1 or more bytes from a region of size 0" } + T (strstr (a1 + i, s)); + T (strstr (a1 + i + 1, s)); + + + // Repeat the above with the arguments reversed. + + T (strstr ("", a0)); // { dg-warning "'strstr' reading 1 or more bytes from a region of size 0" } + + T (strstr (s, a0)); // { dg-warning "'strstr' reading 1 or more bytes from a region of size 0" } + T (strstr (s, a0 + i)); // { dg-warning "'strstr' reading 1 or more bytes from a region of size 0" } + + T (strstr (s, a1)); + T (strstr (s, a1 + 1)); // { dg-warning "'strstr' reading 1 or more bytes from a region of size 0" } + T (strstr (s, a1 + i)); + T (strstr (s, a1 + i + 1)); +} + + +void test_puts_array (int i) +{ + T (puts (a0)); // { dg-warning "'puts' reading 1 or more bytes from a region of size 0" } + T (puts (a0 + i)); // { dg-warning "'puts' reading 1 or more bytes from a region of size 0" } + + T (puts (a1)); + T (puts (a1 + 1)); // { dg-warning "'puts' reading 1 or more bytes from a region of size 0" } + T (puts (a1 + i)); + T (puts (a1 + i + 1)); +} + + +void test_puts_unlocked_array (int i) +{ + T (puts_unlocked (a0)); // { dg-warning "'puts_unlocked' reading 1 or more bytes from a region of size 0" } + T (puts_unlocked (a0 + i)); // { dg-warning "'puts_unlocked' reading 1 or more bytes from a region of size 0" } + + T (puts_unlocked (a1)); + T (puts_unlocked (a1 + 1)); // { dg-warning "'puts_unlocked' reading 1 or more bytes from a region of size 0" } + T (puts_unlocked (a1 + i)); + T (puts_unlocked (a1 + i + 1)); +} + + +void test_gettext_array (int i) +{ + T (gettext (a0)); // { dg-warning "'gettext' reading 1 or more bytes from a region of size 0" } + T (gettext (a0 + i)); // { dg-warning "'gettext' reading 1 or more bytes from a region of size 0" } + + T (gettext (a1)); + T (gettext (a1 + 1)); // { dg-warning "'gettext' reading 1 or more bytes from a region of size 0" } + T (gettext (a1 + i)); + T (gettext (a1 + i + 1)); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-2.c b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-2.c new file mode 100644 index 0000000000..707a511d92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-2.c @@ -0,0 +1,126 @@ +/* PR tree-optimization/84468 - bogus -Wstringop-truncation despite + assignment after conditional strncpy + { dg-do compile } + { dg-options "-O2 -Wstringop-truncation -g" } */ + +extern char* strncpy (char*, const char*, __SIZE_TYPE__); + +char a[4]; + +void f1 (char *s) +{ + int i = 0; + + if (s[0] == '0') + { + i += 1; + strncpy (a, s, sizeof a); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + } + else + i += 2; + + a[sizeof a - 1] = 0; +} + +void f2 (char *s) +{ + int i = 0; + + if (s[0] == '0') + { + i += 1; + if (s[1] == '1') + { + i += 2; + strncpy (a, s, sizeof a); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + } + else + i += 3; + } + else + i += 4; + + a[sizeof a - 1] = 0; +} + +void f3 (char *s) +{ + int i = 0; + + if (s[0] == '0') + { + i += 1; + if (s[1] == '1') + { + i += 2; + if (s[2] == '2') + strncpy (a, s, sizeof a); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + else + i += 3; + } + else + i += 4; + } + else + i += 5; + + a[sizeof a - 1] = 0; +} + +void f4 (char *s) +{ + int i = 0; + + if (s[0] == '0') + { + i += 1; + if (s[1] == '1') + { + i += 2; + if (s[2] == '2') + { + i += 3; + if (s[3] == '3') + strncpy (a, s, sizeof a); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + else + i += 4; + } + else + i += 5; + } + else + i += 6; + } + else + i += 7; + + a[sizeof a - 1] = 0; +} + +void f4_warn (char *s) +{ + int i = 0; + + if (s[0] == '0') + { + i += 1; + if (s[1] == '1') + { + i += 2; + if (s[2] == '2') + { + i += 3; + if (s[3] == '3') + strncpy (a, s, sizeof a); /* { dg-warning "\\\[-Wstringop-truncation]" } */ + else + i += 4; + } + else + i += 5; + } + else + i += 6; + } + else + i += 7; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-3.c b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-3.c new file mode 100644 index 0000000000..6c679747e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-3.c @@ -0,0 +1,60 @@ +/* PR c/85931 - -Wsizeof-pointer-memaccess for strncpy with size of source + { dg-do compile } + { dg-require-effective-target alloca } + { dg-options "-O2 -Wall -Wstringop-truncation -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; + +extern char* strncpy (char*, const char*, size_t); + +extern char a3[3], b3[3]; +extern char a5[5], b5[5]; +extern char ax[], bx[]; + +struct SA +{ + char a3[3], b3[3]; + char a5[5], b5[5]; + char ax[]; +}; + +void sink (void*, ...); + +#define T(d, s, n) sink (strncpy (d, s, n)) + +void test_array (unsigned n) +{ + T (a3, b3, 3); + /* For the following statemenmt, GCC 8.1 issues warning: + + argument to ‘sizeof’ in ‘strncpy’ call is the same expression + as the source; did you mean to use the size of the destination? + + Since the size of both the source and destination the warning + isn't helpful. Verify that it isn't issued. */ + T (a3, b3, sizeof b3); /* { dg-bogus "\\\[-Wsizeof-pointer-memaccess" } */ + + T (a3, ax, sizeof a3); /* { dg-warning "\\\[-Wstringop-truncation" } */ + T (ax, a3, sizeof a3); /* { dg-warning "argument to .sizeof. in .strncpy. call is the same expression as the source" } */ + + char an[n], bn[n]; + sink (an, bn); + + T (an, bn, sizeof bn); /* { dg-bogus "\\\[-Wsizeof-pointer-memaccess" } */ +} + +void test_member_array (struct SA *sa, unsigned n) +{ + T (sa->a3, sa->b3, 3); + T (sa->a3, sa->b3, sizeof sa->b3); /* { dg-bogus "\\\[-Wsizeof-pointer-memaccess" } */ + + T (sa->a3, sa->ax, sizeof sa->a3); /* { dg-warning "\\\[-Wstringop-truncation" } */ + T (sa->ax, sa->a3, sizeof sa->a3); /* { dg-warning "argument to .sizeof. in .strncpy. call is the same expression as the source" } */ + + struct VarLenStruct { + char an[n], bn[n]; + } x; + + sink (&x); + T (x.an, x.bn, sizeof x.bn); /* { dg-bogus "\\\[-Wsizeof-pointer-memaccess" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-4.c b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-4.c new file mode 100644 index 0000000000..f3948637d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-4.c @@ -0,0 +1,63 @@ +/* PR tree-optimization/85700 - Spurious -Wstringop-truncation warning + with strncat + { dg-do compile } + { dg-options "-O2 -Wno-stringop-overflow -Wstringop-truncation -ftrack-macro-expansion=0" } */ + +#define NOIPA __attribute__ ((noipa)) +#define strncat __builtin_strncat +#define strlen __builtin_strlen + +extern char a4[4], b4[4], ax[]; + +NOIPA void cat_a4_s1_1 (void) +{ + /* There is no truncation here but since the bound of 1 equals + the length of the source string it's likely a mistake that + could cause overflow so it's diagnosed by -Wstringop-overflow */ + strncat (a4, "1", 1); +} + +NOIPA void cat_a4_s1_2 (void) +{ + strncat (a4, "1", 2); +} + +NOIPA void cat_a4_s1_3 (void) +{ + strncat (a4, "1", 3); +} + +NOIPA void cat_a4_s1_4 (void) +{ + /* There is no truncation here but since the bound of 1 equals + the length of the source string it's likely a mistake that + could cause overflow so it's diagnosed by -Wstringop-overflow */ + strncat (a4, "1", 4); +} + +NOIPA void cat_a4_s1_5 (void) +{ + /* A bound in excess of the destination size is diagnosed by + -Wstringop-overflow. */ + strncat (a4, "1", 5); +} + +NOIPA void cat_a4_s1_dlen (void) +{ + strncat (a4, "1", sizeof a4 - strlen (a4) - 1); +} + +NOIPA void cat_a4_s2_dlen (void) +{ + strncat (a4, "12", sizeof a4 - strlen (a4) - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ +} + +NOIPA void cat_a4_b4_dlen (void) +{ + strncat (a4, b4, sizeof a4 - strlen (a4) - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ +} + +NOIPA void cat_ax_b4_dlen (void) +{ + strncat (ax, b4, 32 - strlen (ax) - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-5.c b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-5.c new file mode 100644 index 0000000000..f66c0ce1e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-5.c @@ -0,0 +1,64 @@ +/* PR tree-optimization/87028 - false positive -Wstringop-truncation + strncpy with global variable source string + { dg-do compile } + { dg-options "-O2 -Wstringop-truncation" } */ + +char *strncpy (char *, const char *, __SIZE_TYPE__); + +#define STR "1234567890" + +struct S +{ + char a[5], b[5]; +}; + +const char arr[] = STR; +const char* const ptr = STR; + +const char arr2[][10] = { "123", STR }; + +void test_literal (struct S *s) +{ + strncpy (s->a, STR, sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + s->a[sizeof s->a - 1] = '\0'; +} + +void test_global_arr (struct S *s) +{ + strncpy (s->a, arr, sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + s->a [sizeof s->a - 1] = '\0'; +} + +void test_global_arr2 (struct S *s) +{ + strncpy (s->a, arr2[1], sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + s->a [sizeof s->a - 1] = '\0'; + + strncpy (s->b, arr2[0], sizeof s->a - 1); +} + +void test_global_ptr (struct S *s) +{ + strncpy (s->a, ptr, sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + s->a [sizeof s->a - 1] = '\0'; +} + +void test_local_arr (struct S *s) +{ + const char arr[] = STR; + strncpy (s->a, arr, sizeof s->a - 1); + s->a [sizeof s->a - 1] = '\0'; +} + +void test_local_ptr (struct S *s) +{ + const char* const ptr = STR; + strncpy (s->a, ptr, sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ + s->a [sizeof s->a - 1] = '\0'; +} + +void test_compound_literal (struct S *s) +{ + strncpy (s->a, (char[]){ STR }, sizeof s->a - 1); + s->a [sizeof s->a - 1] = '\0'; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-6.c b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-6.c new file mode 100644 index 0000000000..b58f291afa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-6.c @@ -0,0 +1,42 @@ +/* PR tree-optimization/88659 - ICE in maybe_warn_nonstring_arg + { dg-do compile } + { dg-options "-O0 -Wall" } */ + +const char a[5] = "1234"; + +int cst_idx_cst_bnd (void) +{ + return __builtin_strnlen (&a[1], 0); +} + +int var_idx_cst_bnd (void) +{ + int i = 1; + return __builtin_strnlen (&a[i], 0); +} + +int phi_idx_cst_bnd (int i) +{ + return __builtin_strnlen (&a[i ? 1 : 2], 0); +} + +int unk_idx_cst_bnd (int i) +{ + return __builtin_strnlen (&a[i], 0); +} + +int cst_idx_var_bnd (void) +{ + int n = 0; + return __builtin_strnlen (&a[1], n); +} + +int cst_idx_phi_bnd (int n) +{ + return __builtin_strnlen (&a[1], n ? 1 : 2); +} + +int cst_idx_unk_bnd (int n) +{ + return __builtin_strnlen (&a[1], n); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-8.c b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-8.c new file mode 100644 index 0000000000..1745da50a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-8.c @@ -0,0 +1,94 @@ +/* PR tree-optimization/89644 - False-positive -Warray-bounds diagnostic + on strncpy + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#define NONSTR __attribute__ ((nonstring)) + +typedef __SIZE_TYPE__ size_t; + +size_t strlen (const char*); +extern char* stpncpy (char*, const char*, size_t); +extern char* strncpy (char*, const char*, size_t); + +void sink (char*, ...); + +char f0 (char *s) +{ + char a[6] NONSTR = { 1, 2, 3, 4, 5, 6 }; + if (*s) + strncpy (a, s, sizeof a); /* { dg-bogus "\\\[-Warray-bounds" } */ + return a[0]; +} + +void f1 (char *s) +{ + char a[6] NONSTR = { 1, 2, 3, 4, 5, 6 }; + if (*s) + strncpy (a, s, sizeof a); /* { dg-bogus "\\\[-Warray-bounds" } */ + sink (a); +} + +char f2 (void) +{ + char a[6] NONSTR = { 1, 2, 3, 4, 5, 6 }; + char b[6] NONSTR = { 6, 5, 4, 3, 2, 1 }; + strncpy (a, b + 1, 5); /* { dg-bogus "\\\[-Warray-bounds" } */ + return a[0]; +} + +void f3 (void) +{ + char a[6] NONSTR = { 1, 2, 3, 4, 5, 6 }; + char b[6] NONSTR = { 6, 5, 4, 3, 2, 1 }; + strncpy (a, b + 2, 4); /* { dg-bogus "\\\[-Warray-bounds" } */ + sink (a); +} + +void f4 (NONSTR char *d) +{ + char b[6] NONSTR = { 6, 5, 4, 3, 2, 1 }; + strncpy (d, b + 3, 3); /* { dg-bogus "\\\[-Warray-bounds" } */ + sink (d); +} + + +char g0 (char *s) +{ + char a[6] NONSTR = { 1, 2, 3, 4, 5, 6 }; + if (*s) + stpncpy (a, s, sizeof a); /* { dg-bogus "\\\[-Warray-bounds" } */ + return a[0]; +} + +void g1 (char *s) +{ + char a[6] NONSTR = { 1, 2, 3, 4, 5, 6 }; + char *p = 0; + if (*s) + p = stpncpy (a, s, sizeof a); /* { dg-bogus "\\\[-Warray-bounds" } */ + sink (a, p); +} + +char g2 (void) +{ + char a[6] NONSTR = { 1, 2, 3, 4, 5, 6 }; + char b[6] NONSTR = { 6, 5, 4, 3, 2, 1 }; + stpncpy (a, b + 1, 5); /* { dg-bogus "\\\[-Warray-bounds" } */ + return a[0]; +} + +void g3 (void) +{ + char a[6] NONSTR = { 1, 2, 3, 4, 5, 6 }; + char b[6] NONSTR = { 6, 5, 4, 3, 2, 1 }; + char *p = stpncpy (a, b + 2, 4); /* { dg-bogus "\\\[-Warray-bounds" } */ + sink (a, p); +} + +void g4 (NONSTR char *d) +{ + char b[6] NONSTR = { 6, 5, 4, 3, 2, 1 }; + char *p = stpncpy (d, b + 3, 3); /* { dg-bogus "\\\[-Warray-bounds" } */ + sink (d, p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-9.c b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-9.c new file mode 100644 index 0000000000..63614809da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation-9.c @@ -0,0 +1,41 @@ +/* PR tree-optimization/99489 - ICE calling strncat after strncat + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +// Important -- see pr82429. +char *stpcpy (char *, const char *); + +void fchar (char *d, char c, char *s) +{ + __builtin_strcat (d, s); + __builtin_strncat (d, &c, 1); +} + +void fcstchar (char *d, char *s) +{ + __builtin_strcat (d, s); + + const char c = 'x'; + __builtin_strncat (d, &c, 1); // { dg-warning "-Wstringop-truncation" } +} + +void fstr (char *d, char *s) +{ + __builtin_strcat (d, s); + __builtin_strncat (d, s, 1); +} + +void farr (char *d, char *s) +{ + __builtin_strcat (d, s); + + char a[] = "x"; + __builtin_strncat (d, a, 1); // { dg-warning "-Wstringop-truncation" } +} + +void flit (char *d, char *s) +{ + __builtin_strcat (d, s); + __builtin_strncat (d, "x", 1); // { dg-warning "-Wstringop-truncation" "pr?????" { xfail *-*-*} } + // { dg-warning "-Wstringop-overflow" "actual" { target *-*-*} .-1 } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wstringop-truncation.c b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation.c new file mode 100644 index 0000000000..b537296779 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wstringop-truncation.c @@ -0,0 +1,131 @@ +/* PR tree-optimization/84468 - Inconsistent -Wstringop-truncation warnings + with -O2 + { dg-do compile } + { dg-options "-O2 -Wstringop-truncation -ftrack-macro-expansion=0 -g" } */ + +#define strncpy __builtin_strncpy + +struct A +{ + char a[4]; +}; + +void no_pred_succ_lit (struct A *p) +{ + /* The following is folded early on, before the strncpy statement + has a basic block. Verify that the case is handled gracefully + (i.e., there's no assumption that the statement does have + a basic block). */ + strncpy (p->a, "1234", sizeof p->a - 1); /* { dg-warning "\\\[-Wstringop-truncation" } */ +} + +/* Verify a strncpy call in a basic block with no predecessor or + successor. */ +void no_pred_succ (struct A *p, const struct A *q) +{ + strncpy (p->a, q->a, sizeof p->a - 1); /* { dg-warning "\\\[-Wstringop-truncation" } */ +} + + +/* Verify a strncpy call in a basic block with no successor. */ +void no_succ (struct A *p, const struct A *q) +{ + if (q->a) + strncpy (p->a, q->a, sizeof p->a - 1); /* { dg-warning "\\\[-Wstringop-truncation" } */ +} + +/* Verify a strncpy call in a basic block with nul assignment in + a successor block. */ +void succ (struct A *p, const struct A *q) +{ + /* Verify that the assignment suppresses the warning for the conditional + strcnpy call. The conditional should be folded to true since the + address of an array can never be null (see bug 84470). */ + if (q->a) + strncpy (p->a, q->a, sizeof p->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation" } */ + + p->a[sizeof p->a - 1] = 0; +} + + +void succ_2 (struct A *p, const struct A *q, int i) +{ + /* Same as above but with a conditional that cannot be eliminated. */ + if (i < 0) + strncpy (p->a, q->a, sizeof p->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation" } */ + + p->a[sizeof p->a - 1] = 0; +} + + +/* Verify a strncpy call in a basic block with nul assignment in + the next successor block. */ +int next_succ (struct A *p, const struct A *q, int i, int j) +{ + /* Same as above but with a nested conditionals with else clauses. */ + if (i < 0) + { + if (j < 0) + strncpy (p->a, q->a, sizeof p->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation" } */ + } + else + __builtin_strcpy (p->a, q->a); + + p->a[sizeof p->a - 1] = 0; + return 0; +} + + +int next_succ_1 (struct A *p, const struct A *q, int i, int j) +{ + /* Same as above but with a nested conditionals with else clauses. */ + if (i < 0) + { + if (j < 0) + strncpy (p->a, q->a, sizeof p->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation" } */ + else + strncpy (p->a, q->a, sizeof p->a - 2); /* { dg-bogus "\\\[-Wstringop-truncation" } */ + } + + p->a[sizeof p->a - 2] = 0; + return 1; +} + + +int next_succ_2 (struct A *p, const struct A *q, int i, int j) +{ + /* Same as above but with a nested conditionals with else clauses. */ + if (i < 0) + { + if (j < 0) + strncpy (p->a, q->a, sizeof p->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation" } */ + else + strncpy (p->a, q->a, sizeof p->a - 2); /* { dg-bogus "\\\[-Wstringop-truncation" } */ + } + else + __builtin_strcpy (p->a, q->a); + + p->a[sizeof p->a - 2] = 0; + return 2; +} + + +void cond_succ_warn (struct A *p, const struct A *q, int i) +{ + /* Verify that a conditional assignment doesn't suppress the warning. */ + strncpy (p->a, q->a, sizeof p->a - 1); /* { dg-warning "\\\[-Wstringop-truncation" } */ + + if (i < 0) + p->a[sizeof p->a - 1] = 0; +} + +void cond_succ_nowarn (struct A *p, const struct A *q) +{ + /* Verify that distinct but provably equivalent conditionals are + recognized and don't trigger the warning. */ + if (p != q) + strncpy (p->a, q->a, sizeof p->a - 1); + + if (p->a != q->a) + p->a[sizeof p->a - 1] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-2.c b/SingleSource/Regression/C/gcc-dg/Wswitch-2.c new file mode 100644 index 0000000000..79ba4bdcb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-2.c @@ -0,0 +1,31 @@ +/* Further -Wswitch tests. */ +/* { dg-do compile } */ +/* { dg-options "-Wswitch" } */ + +enum e { e1 = 0, e2 = 1, e3 = 1, e4 = 2 }; + +int +foo (enum e ei, int j) +{ + switch (ei) + { + case e1: return 1; + case e3: return 2; + case e4: return 3; + } /* No warning here since e2 has the same value as e3. */ + switch (ei) /* { dg-warning "enumeration value 'e4' not handled in switch" "enum e4" } */ + { + case e1: return 1; + case e2: return 2; + } + switch ((int) ei) + { + case e1: return 1; + } /* No warning here since switch condition was cast to int. */ + switch ((enum e) j) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */ + { + case e2: return 1; + case e4: return 2; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-default.c b/SingleSource/Regression/C/gcc-dg/Wswitch-default.c new file mode 100644 index 0000000000..2d4e7994c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-default.c @@ -0,0 +1,62 @@ +/* { dg-do compile } */ +/* { dg-options "-Wswitch-default" } */ + +enum e { e1, e2 }; + +int +foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el, + enum e em, enum e en, enum e eo, enum e ep) +{ + switch (i) /* { dg-warning "switch missing default case" } */ + { + case 1: return 1; + case 2: return 2; + } + switch (j) + { + case 3: return 4; + case 4: return 3; + default: break; + } + switch (ei) /* { dg-warning "switch missing default case" } */ + { + } + switch (ej) + { + default: break; + } + switch (ek) /* { dg-warning "switch missing default case" } */ + { + case e1: return 1; + } + switch (el) + { + case e1: return 1; + default: break; + } + switch (em) /* { dg-warning "switch missing default case" } */ + { + case e1: return 1; + case e2: return 2; + } + switch (en) + { + case e1: return 1; + case e2: return 2; + default: break; + } + switch (eo) /* { dg-warning "switch missing default case" } */ + { + case e1: return 1; + case e2: return 2; + case 3: return 3; + } + switch (ep) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; + default: break; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-enum-2.c b/SingleSource/Regression/C/gcc-dg/Wswitch-enum-2.c new file mode 100644 index 0000000000..6b5ca1d307 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-enum-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wswitch-enum" } */ + +typedef enum { a = 2 } T; + +int main() +{ + T x = a; + switch(x) + { + case a ... 3: /* { dg-warning "case value '3' not in enumerated" "3" } */ + break; + } + switch(x) + { + case 1 ... a: /* { dg-warning "case value '1' not in enumerated" "1" } */ + break; + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-enum-3.c b/SingleSource/Regression/C/gcc-dg/Wswitch-enum-3.c new file mode 100644 index 0000000000..98db4d578f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-enum-3.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wswitch-enum" } */ + +typedef enum { a = 2 } T; + +int main() +{ + switch((T)a) /* { dg-warning "enumeration value 'a' not handled" "a" } */ + { + case 1: /* { dg-warning "case value '1' not in enumerated" "1" } */ + break; + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-enum-error.c b/SingleSource/Regression/C/gcc-dg/Wswitch-enum-error.c new file mode 100644 index 0000000000..e9e18262aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-enum-error.c @@ -0,0 +1,63 @@ + +/* { dg-do compile } */ +/* { dg-options "-Werror=switch-enum -Wswitch" } */ +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ +enum e { e1, e2 }; + +int +foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el, + enum e em, enum e en, enum e eo, enum e ep) +{ + switch (i) + { + case 1: return 1; + case 2: return 2; + } + switch (j) + { + case 3: return 4; + case 4: return 3; + default: break; + } + switch (ei) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */ + { /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */ + } + switch (ej) /* { dg-error "enumeration value 'e1' not handled in switch" "enum e1" } */ + { /* { dg-error "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */ + default: break; + } + switch (ek) /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" } */ + { + case e1: return 1; + } + switch (el) /* { dg-error "enumeration value 'e2' not handled in switch" "enum e2" } */ + { + case e1: return 1; + default: break; + } + switch (em) + { + case e1: return 1; + case e2: return 2; + } + switch (en) + { + case e1: return 1; + case e2: return 2; + default: break; + } + switch (eo) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */ + } + switch (ep) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */ + default: break; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-enum.c b/SingleSource/Regression/C/gcc-dg/Wswitch-enum.c new file mode 100644 index 0000000000..010712e59c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-enum.c @@ -0,0 +1,63 @@ +/* PR c/5044 */ +/* { dg-do compile } */ +/* { dg-options "-Wswitch-enum" } */ + +enum e { e1, e2 }; + +int +foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el, + enum e em, enum e en, enum e eo, enum e ep) +{ + switch (i) + { + case 1: return 1; + case 2: return 2; + } + switch (j) + { + case 3: return 4; + case 4: return 3; + default: break; + } + switch (ei) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */ + { /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */ + } + switch (ej) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */ + { /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */ + default: break; + } + switch (ek) /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" } */ + { + case e1: return 1; + } + switch (el) /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" } */ + { + case e1: return 1; + default: break; + } + switch (em) + { + case e1: return 1; + case e2: return 2; + } + switch (en) + { + case e1: return 1; + case e2: return 2; + default: break; + } + switch (eo) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */ + } + switch (ep) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */ + default: break; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-error.c b/SingleSource/Regression/C/gcc-dg/Wswitch-error.c new file mode 100644 index 0000000000..0d2f0b37ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-error.c @@ -0,0 +1,64 @@ + +/* { dg-do compile } */ +/* { dg-options "-Werror=switch -Wswitch-enum" } */ + +enum e { e1, e2 }; + +int +foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el, + enum e em, enum e en, enum e eo, enum e ep) +{ + switch (i) + { + case 1: return 1; + case 2: return 2; + } + switch (j) + { + case 3: return 4; + case 4: return 3; + default: break; + } + switch (ei) /* { dg-error "enumeration value 'e1' not handled in switch" "enum e1" } */ + { /* { dg-error "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */ + } + switch (ej) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */ + { /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */ + default: break; + } + switch (ek) /* { dg-error "enumeration value 'e2' not handled in switch" "enum e2" } */ + { + case e1: return 1; + } + switch (el) /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" } */ + { + case e1: return 1; + default: break; + } + switch (em) + { + case e1: return 1; + case e2: return 2; + } + switch (en) + { + case e1: return 1; + case e2: return 2; + default: break; + } + switch (eo) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; /* { dg-error "case value '3' not in enumerated type 'enum e'" "excess 3" } */ + } + switch (ep) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; /* { dg-error "case value '3' not in enumerated type 'enum e'" "excess 3" } */ + default: break; + } + return 0; +} +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-unreachable-1.c b/SingleSource/Regression/C/gcc-dg/Wswitch-unreachable-1.c new file mode 100644 index 0000000000..2e5c99bce3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-unreachable-1.c @@ -0,0 +1,35 @@ +/* PR c/49859 */ +/* { dg-do compile } */ +/* { dg-options "-Wswitch-unreachable" } */ + +extern void foo (int); +extern int j; + +void +fn0 (int i) +{ + switch (i) + { + int t = 10; /* { dg-warning "statement will never be executed" } */ + default: + foo (t); + } + + switch (i) + { /* { dg-warning "statement will never be executed" } */ + int A[i]; + default: /* { dg-error "switch jumps into scope" } */ + break; + } + + switch (i) + default: + j = sizeof (struct { int i; }); + + switch (i) + { + int A[3]; + default: + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch-unreachable-2.c b/SingleSource/Regression/C/gcc-dg/Wswitch-unreachable-2.c new file mode 100644 index 0000000000..343baea124 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch-unreachable-2.c @@ -0,0 +1,12 @@ +/* PR middle-end/71476 */ +/* { dg-do compile } */ +/* { dg-options "-Wswitch-unreachable" } */ + +void +foo (int a) +{ + switch (a) + { + void f (void) { } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wswitch.c b/SingleSource/Regression/C/gcc-dg/Wswitch.c new file mode 100644 index 0000000000..7bf5eb1937 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wswitch.c @@ -0,0 +1,63 @@ +/* PR c/4475, PR c++/3780 */ +/* { dg-do compile } */ +/* { dg-options "-Wswitch" } */ + +enum e { e1, e2 }; + +int +foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el, + enum e em, enum e en, enum e eo, enum e ep) +{ + switch (i) + { + case 1: return 1; + case 2: return 2; + } + switch (j) + { + case 3: return 4; + case 4: return 3; + default: break; + } + switch (ei) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */ + { /*{ dg-warning "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */ + } + switch (ej) + { + default: break; + } + switch (ek) /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" } */ + { + case e1: return 1; + } + switch (el) + { + case e1: return 1; + default: break; + } + switch (em) + { + case e1: return 1; + case e2: return 2; + } + switch (en) + { + case e1: return 1; + case e2: return 2; + default: break; + } + switch (eo) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */ + } + switch (ep) + { + case e1: return 1; + case e2: return 2; + case 3: return 3; /* { dg-warning "case value '3' not in enumerated type 'enum e'" "excess 3" } */ + default: break; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion-2.c b/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion-2.c new file mode 100644 index 0000000000..b3c7e3c6c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion-2.c @@ -0,0 +1,64 @@ +/* Test messages for -Wtraditional-conversion, including that they are not + pedwarns. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors -Wtraditional-conversion" } */ + +void fsc(signed char); +void fsi(signed int); +void fsll(signed long long); +void fuc(unsigned char); +void fui(unsigned int); +void full(unsigned long long); +void ff(float); +void fld(long double); +void fcf(_Complex float); + +struct s { + void (*fsc)(signed char); + void (*fsi)(signed int); + void (*fsll)(signed long long); + void (*fuc)(unsigned char); + void (*fui)(unsigned int); + void (*full)(unsigned long long); + void (*ff)(float); + void (*fld)(long double); + void (*fcf)(_Complex float); +} x; + +signed char sc; +signed int si; +signed long long sll; +unsigned char uc; +unsigned int ui; +unsigned long long ull; +float f; +long double ld; +_Complex float cf; + +void +g (void) +{ + fsi(f); /* { dg-warning "passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ + x.fsi(f); /* { dg-warning "passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ + fsi(cf); /* { dg-warning "passing argument 1 of 'fsi' as integer rather than complex due to prototype" } */ + x.fsi(cf); /* { dg-warning "passing argument 1 of 'x.fsi' as integer rather than complex due to prototype" } */ + fcf(f); /* { dg-warning "passing argument 1 of 'fcf' as complex rather than floating due to prototype" } */ + x.fcf(f); /* { dg-warning "passing argument 1 of 'x.fcf' as complex rather than floating due to prototype" } */ + fcf(si); /* { dg-warning "passing argument 1 of 'fcf' as complex rather than integer due to prototype" } */ + x.fcf(si); /* { dg-warning "passing argument 1 of 'x.fcf' as complex rather than integer due to prototype" } */ + ff(sc); /* { dg-warning "passing argument 1 of 'ff' as floating rather than integer due to prototype" } */ + x.ff(sc); /* { dg-warning "passing argument 1 of 'x.ff' as floating rather than integer due to prototype" } */ + ff(cf); /* { dg-warning "passing argument 1 of 'ff' as floating rather than complex due to prototype" } */ + x.ff(cf); /* { dg-warning "passing argument 1 of 'x.ff' as floating rather than complex due to prototype" } */ + ff(1.0); /* { dg-warning "passing argument 1 of 'ff' as 'float' rather than 'double' due to prototype" } */ + x.ff(1.0); /* { dg-warning "passing argument 1 of 'x.ff' as 'float' rather than 'double' due to prototype" } */ + fsll(sc); /* { dg-warning "passing argument 1 of 'fsll' with different width due to prototype" } */ + x.fsll(sc); /* { dg-warning "passing argument 1 of 'x.fsll' with different width due to prototype" } */ + fsc(sll); /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" } */ + x.fsc(sll); /* { dg-warning "passing argument 1 of 'x.fsc' with different width due to prototype" } */ + fsi(ui); /* { dg-warning "passing argument 1 of 'fsi' as signed due to prototype" } */ + x.fsi(ui); /* { dg-warning "passing argument 1 of 'x.fsi' as signed due to prototype" } */ + full(sll); /* { dg-warning "passing argument 1 of 'full' as unsigned due to prototype" } */ + x.full(sll); /* { dg-warning "passing argument 1 of 'x.full' as unsigned due to prototype" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion-3.c b/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion-3.c new file mode 100644 index 0000000000..796f2eb884 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion-3.c @@ -0,0 +1,9 @@ +/* { dg-options "-Wtraditional-conversion -Wno-psabi" } */ + +typedef int __attribute__((__vector_size__ (4))) V; + +void +foo (V v) +{ + foo (v); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion.c b/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion.c new file mode 100644 index 0000000000..a3f04acb5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wtraditional-conversion.c @@ -0,0 +1,20 @@ +/* Source: PR 137. + + We would not warn about passing an enum, but would warn about + passing a enum that was part of an array. TYPE_MAIN_VARIANT was + not used in the appropriate place in the warning code. */ + +/* { dg-do compile } */ +/* { dg-options -Wtraditional-conversion } */ + +typedef enum { a } __attribute__((packed)) t; +void f(t x) {} + +int main(void) +{ + t x[2], y; + f(x[0]); /* { dg-bogus "different width" } */ + f(y); /* { dg-bogus "different width" } */ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wtrampolines.c b/SingleSource/Regression/C/gcc-dg/Wtrampolines.c new file mode 100644 index 0000000000..8ff09ebc9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wtrampolines.c @@ -0,0 +1,53 @@ +/* Origin: trampoline-1.c Waldek Hebisch */ +/* Ported to test -Wtrampolines Magnus Granberg */ + +/* { dg-do compile } */ +/* { dg-require-effective-target trampolines } */ +/* { dg-options "-O2 -Wtrampolines" } */ + +/* This used to fail on various versions of Solaris 2 because the + trampoline couldn't be made executable. */ + +extern void abort(void); +extern double fabs(double); + +void foo (void) +{ + const int correct[1100] = {1, 0, -2, 0, 1, 0, 1, -1, -10, -30, -67}; + int i; + + double x1 (void) {return 1; } + double x2 (void) {return -1;} + double x3 (void) {return -1;} + double x4 (void) {return 1; } + double x5 (void) {return 0; } + + typedef double pfun(void); + + double a (int k, pfun x1, pfun x2, pfun x3, pfun x4, pfun x5) + { + double b (void) /* { dg-warning "trampoline generated for nested function 'b'" "standard descriptors" { xfail { { ia64-*-* *-*-aix* } || { powerpc*-*-* && lp64 } } } } */ + { + k = k - 1; + return a (k, b, x1, x2, x3, x4 ); + } + + if (k <= 0) + return x4 () + x5 (); + else + return b (); + } + + for (i=0; i<=10; i++) + { + if (fabs(a( i, x1, x2, x3, x4, x5 ) - correct [i]) > 0.1) + abort(); + } +} + +int main (void) +{ + foo (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wtype-limits-Wextra.c b/SingleSource/Regression/C/gcc-dg/Wtype-limits-Wextra.c new file mode 100644 index 0000000000..72a395164f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wtype-limits-Wextra.c @@ -0,0 +1,70 @@ +/* Test that -Wtype-limits is enabled by -Wextra */ +/* { dg-do compile } */ +/* { dg-excess-errors "short=int" { target { avr-*-* } } } */ +/* { dg-options "-Wextra" } */ + +void a (unsigned char x) +{ + if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */ + if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */ + if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */ + if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */ + if (x <= 255) /* { dg-warning "comparison is always true due to limited range of data type" } */ + return; + if (255 >= x) /* { dg-warning "comparison is always true due to limited range of data type" } */ + return; + if ((int)x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } } */ + return; + if (255 >= (unsigned char) 1) + return; + +} + +void b (unsigned short x) +{ /* { dg-warning "comparison of unsigned expression in '< 0' is always false" "" { target { ! int32plus } } .+1 } */ + if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" "" { target { int32plus } } } */ + /* { dg-warning "comparison of unsigned expression in '>= 0' is always true" "" { target { ! int32plus } } .+1 } */ + if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" "" { target { int32plus } } } */ + /* { dg-warning "comparison of unsigned expression in '< 0' is always false" "" { target { ! int32plus } } .+1 } */ + if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" "" { target { int32plus } } } */ + /* { dg-warning "comparison of unsigned expression in '>= 0' is always true" "" { target { ! int32plus } } .+1 } */ + if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" "" { target { int32plus } } } */ +} + +void c (unsigned int x) +{ + if (x < 0) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (x >= 0) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ + if (0 > x) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (0 <= x) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ + if (1U >= 0) return; + if (1U < 0) return; + if (0 <= 1U) return; + if (0 > 1U) return; +} + +void d (unsigned long x) +{ + if (x < 0) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (x >= 0) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ + if (0 > x) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (0 <= x) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ +} + +void e (unsigned long long x) +{ + if (x < 0) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (x >= 0) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ + if (0 > x) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (0 <= x) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ +} + +int test (int x) +{ + if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } } */ + return 1; + else + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/Wtype-limits-no.c b/SingleSource/Regression/C/gcc-dg/Wtype-limits-no.c new file mode 100644 index 0000000000..2af909abfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wtype-limits-no.c @@ -0,0 +1,66 @@ +/* Test disabling -Wtype-limits */ +/* { dg-do compile } */ +/* { dg-options "-Wextra -Wno-type-limits" } */ + + +void a (unsigned char x) +{ + if (x < 0) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */ + if (x >= 0) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */ + if (0 > x) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */ + if (0 <= x) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */ + if (x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" } */ + return; + if (255 >= x) /* { dg-bogus "comparison is always true due to limited range of data type" } */ + return; + if ((int)x <= 255) + return; + if (255 >= (unsigned char) 1) + return; + +} + +void b (unsigned short x) +{ + if (x < 0) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */ + if (x >= 0) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */ + if (0 > x) return;/* { dg-bogus "comparison is always false due to limited range of data type" } */ + if (0 <= x) return;/* { dg-bogus "comparison is always true due to limited range of data type" } */ +} + +void c (unsigned int x) +{ + if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ + if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ + if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ + if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ + if (1U >= 0) return; + if (1U < 0) return; + if (0 <= 1U) return; + if (0 > 1U) return; +} + +void d (unsigned long x) +{ + if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ + if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ + if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ + if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ +} + +void e (unsigned long long x) +{ + if (x < 0) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ + if (x >= 0) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ + if (0 > x) return;/* { dg-bogus "comparison of unsigned expression < 0 is always false" } */ + if (0 <= x) return;/* { dg-bogus "comparison of unsigned expression >= 0 is always true" } */ +} + +int test (int x) +{ + if ((long long)x <= 0x123456789ABCLL) + return 1; + else + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wtype-limits.c b/SingleSource/Regression/C/gcc-dg/Wtype-limits.c new file mode 100644 index 0000000000..6a596fc3a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wtype-limits.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-options "-Wtype-limits" } */ + + + +void a (unsigned char x) +{ + if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */ + if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */ + if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */ + if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */ + if (x <= 255) /* { dg-warning "comparison is always true due to limited range of data type" } */ + return; + if (255 >= x) /* { dg-warning "comparison is always true due to limited range of data type" } */ + return; + if ((int)x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } } */ + return; + if (255 >= (unsigned char) 1) + return; + +} + +void b (unsigned short x) +{ /* { dg-warning "comparison of unsigned expression in '< 0' is always false" "" { target { ! int32plus } } .+1 } */ + if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" "" { target { int32plus } } } */ + /* { dg-warning "comparison of unsigned expression in '>= 0' is always true" "" { target { ! int32plus } } .+1 } */ + if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" "" { target { int32plus } } } */ + /* { dg-warning "comparison of unsigned expression in '< 0' is always false" "" { target { ! int32plus } } .+1 } */ + if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" "" { target { int32plus } } } */ + /* { dg-warning "comparison of unsigned expression in '>= 0' is always true" "" { target { ! int32plus } } .+1 } */ + if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" "" { target { int32plus } } } */ +} + +void c (unsigned int x) +{ + if (x < 0) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (x >= 0) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ + if (0 > x) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (0 <= x) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ + if (1U >= 0) return; + if (1U < 0) return; + if (0 <= 1U) return; + if (0 > 1U) return; +} + +void d (unsigned long x) +{ + if (x < 0) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (x >= 0) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ + if (0 > x) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (0 <= x) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ +} + +void e (unsigned long long x) +{ + if (x < 0) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (x >= 0) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ + if (0 > x) return;/* { dg-warning "comparison of unsigned expression in '< 0' is always false" } */ + if (0 <= x) return;/* { dg-warning "comparison of unsigned expression in '>= 0' is always true" } */ +} + +int test (int x) +{ + if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } } */ + return 1; + else + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/Wtype-limits2.c b/SingleSource/Regression/C/gcc-dg/Wtype-limits2.c new file mode 100644 index 0000000000..92151aa68c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wtype-limits2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Wtype-limits" } */ +/* { dg-require-effective-target sync_char_short } */ + +#include + +unsigned foo (unsigned char *x) +{ + if (atomic_load (x) > 1000) /* { dg-warning "comparison is always false due to limited range of data type" } */ + return 0; + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunknownprag.c b/SingleSource/Regression/C/gcc-dg/Wunknownprag.c new file mode 100644 index 0000000000..158cab7151 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunknownprag.c @@ -0,0 +1,11 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ +/* { dg-options "-Wunknown-pragmas" } */ + +/* We used to get "unspellable token: CPP_EOF" warnings. */ + +#pragma /* { dg-warning "-:ignoring '#pragma" } */ +#pragma ~ /* { dg-warning "-:ignoring '#pragma" } */ +#pragma baz /* { dg-warning "-:ignoring '#pragma" } */ +#pragma baz baz /* { dg-warning "-:ignoring '#pragma baz baz'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wunsuffixed-float-constants-1.c b/SingleSource/Regression/C/gcc-dg/Wunsuffixed-float-constants-1.c new file mode 100644 index 0000000000..ba992c45c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunsuffixed-float-constants-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wunsuffixed-float-constants" } */ + +#define VAL 0.5; + +double a = 1.1d; + +/* With FLOAT_CONST_DECIMAL64 switched to ON these would have type + _Decimal64. */ + +double b = VAL; /* { dg-warning "unsuffixed floating constant" } */ +double c = 1.2; /* { dg-warning "unsuffixed floating constant" } */ + +/* With FLOAT_CONST_DECIMAL64 switched to ON these are still binary. */ + +double d = 0x5.0p1; /* No warning for hex constant. */ +double e = 3.1i; /* No warning for imaginary constant. */ diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-function.c b/SingleSource/Regression/C/gcc-dg/Wunused-function.c new file mode 100644 index 0000000000..1c59c50038 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-function.c @@ -0,0 +1,6 @@ +/* PR c/4076 -Wunused doesn't warn about static function only called by itself. */ +/* { dg-do compile } */ +/* { dg-options "-Wunused-function" } */ + +static void foo (void) {} /* { dg-warning "'foo' defined but not used" } */ +static void bar (void) { bar (); } /* { dg-warning "'bar' defined but not used" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-label-1.c b/SingleSource/Regression/C/gcc-dg/Wunused-label-1.c new file mode 100644 index 0000000000..1840a8008f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-label-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused-label" } */ + +extern void f2 (); + +void +f1 () +{ + l1: f2 (); /* { dg-warning "not used" } */ + l2: __attribute__ ((unused)) f2 (); + l3: ; f2 (); /* { dg-warning "not used" } */ + l4: __attribute__ ((unused)) ; f2 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-local-typedefs.c b/SingleSource/Regression/C/gcc-dg/Wunused-local-typedefs.c new file mode 100644 index 0000000000..4c8c15ed20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-local-typedefs.c @@ -0,0 +1,36 @@ +/* Origin PR c/53702 + { dg-options "-Wunused-local-typedefs" } + { dg-do compile } +*/ + +/* Only test nested functions for C. More tests that work for C and C++ + can be found in c-c++-common. +*/ + +void +test0 () +{ + typedef int foo; /* { dg-warning "locally defined but not used" } */ + void f () + { + } +} + +void +test1 () +{ + void f () + { + typedef int foo; /* { dg-warning "locally defined but not used" } */ + } +} + + +void +test2 () +{ + void f () + { + } + typedef int foo; /* { dg-warning "locally defined but not used" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-parm-1.c b/SingleSource/Regression/C/gcc-dg/Wunused-parm-1.c new file mode 100644 index 0000000000..bddbd83a63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-parm-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused -W" } */ + +long +f1 (unsigned long long x) +{ + unsigned long long a = 1; + const union { unsigned long long l; unsigned int p[2]; } b = { .l = x }; + const union { unsigned long long l; unsigned int p[2]; } c = { .l = a }; + return b.p[0] + c.p[0]; +} + +int +f2 (int x, int y) +{ + int a = 1; + int b[] = { 1, 2, x, a, 3, 4 }; + return b[y]; +} + +int +f3 (int a, /* { dg-warning "unused parameter" } */ + int b, /* { dg-warning "set but not used" } */ + int c) +{ + b = 1; + c = 1; + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-result.c b/SingleSource/Regression/C/gcc-dg/Wunused-result.c new file mode 100644 index 0000000000..c0bb9ae35e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-result.c @@ -0,0 +1,50 @@ +/* PR c/99972 - missing -Wunused-result on a call to a locally redeclared + warn_unused_result function + { dg-do compile } + { dg-options "-Wall" } */ + +void gwur_local_local (void) +{ + __attribute__ ((warn_unused_result)) int fwur1 (void); + + fwur1 (); // { dg-warning "\\\[-Wunused-result" } +} + +void hwur_local_local (void) +{ + /* Verify the attribute from the declaration above is copied/merged + into the declaration below. */ + int fwur1 (void); + + fwur1 (); // { dg-warning "\\\[-Wunused-result" } +} + + +void gwur_local_global (void) +{ + __attribute__ ((warn_unused_result)) int fwur2 (void); + + fwur2 (); // { dg-warning "\\\[-Wunused-result" } +} + +int fwur2 (void); + +void hwur_local_global (void) +{ + fwur2 (); // { dg-warning "\\\[-Wunused-result" } +} + + +__attribute__ ((warn_unused_result)) int fwur3 (void); + +void gwur_global_local (void) +{ + fwur3 (); // { dg-warning "\\\[-Wunused-result" } +} + +void hwur_global_local (void) +{ + int fwur3 (void); + + fwur3 (); // { dg-warning "\\\[-Wunused-result" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-value-1.c b/SingleSource/Regression/C/gcc-dg/Wunused-value-1.c new file mode 100644 index 0000000000..0fc7c364ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-value-1.c @@ -0,0 +1,31 @@ +/* Test -Wunused-value. Bug 23113. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wunused-value" } */ + +int f (void); +void g (void); +int *p; + +void +h (void) +{ + 1 + f (); /* { dg-warning "value computed is not used" } */ + f () + f (); /* { dg-warning "value computed is not used" } */ + f () + f (), f (); /* { dg-warning "value computed is not used" } */ + (char) f (); /* { dg-warning "value computed is not used" } */ + g (); + f (); + (void) f (); + *p++; /* { dg-warning "value computed is not used" } */ + ++*p; + (*p ? f() : 0); + ({ f(); }); + /* Statement expressions may be used in macro expansions which like + functions return values which may or may not be of use, so don't + warn for them but do warn inside them. */ + ({ f() + 1; }); + ({ f(); 0; }); + ({ f() + 1; 0; }); /* { dg-warning "value computed is not used" } */ + 1 + ({ f(); }); /* { dg-warning "value computed is not used" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-value-2.c b/SingleSource/Regression/C/gcc-dg/Wunused-value-2.c new file mode 100644 index 0000000000..4858bfade7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-value-2.c @@ -0,0 +1,18 @@ +/* Test -Wunused-value. Bug 30729. */ +/* { dg-do compile } */ +/* { dg-options "-Wunused-value" } */ +/* Make sure va_arg does not cause a value computed is not used warning + because it has side effects. */ +#include + +int f(int t, ...) +{ + va_list a; + va_start (a, t); + va_arg(a, int);/* { dg-bogus "value computed is not used" } */ + int t1 = va_arg(a, int); + va_end(a); + return t1; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-value-3.c b/SingleSource/Regression/C/gcc-dg/Wunused-value-3.c new file mode 100644 index 0000000000..333ddea4ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-value-3.c @@ -0,0 +1,9 @@ +/* PR c/39889 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused-value" } */ + +int x; +int foo (void) +{ + return (1 ? x = 0 : (void) 0), 0; /* { dg-bogus "value computed is not used" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-var-1.c b/SingleSource/Regression/C/gcc-dg/Wunused-var-1.c new file mode 100644 index 0000000000..d60dd70e57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-var-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +int +f1 (void) +{ + int a; + int foo (void) + { + return a; + } + a = 1; + return foo (); +} + +void +f2 (void) +{ + int a; /* { dg-warning "set but not used" } */ + void foo (void) + { + a = 2; + } + a = 1; + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-var-2.c b/SingleSource/Regression/C/gcc-dg/Wunused-var-2.c new file mode 100644 index 0000000000..b5a22f8654 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-var-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +int +f1 (void) +{ + int a; + int b; + int c; + int d; + int e; + a = 1; + b = 2; + c = 3; + d = 4; + e = 5; + return sizeof (a) + ((__typeof (b)) 1) + __alignof__ (c) + + __builtin_choose_expr (1, d, e); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-var-3.c b/SingleSource/Regression/C/gcc-dg/Wunused-var-3.c new file mode 100644 index 0000000000..5954c3b1be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-var-3.c @@ -0,0 +1,34 @@ +/* PR c/52577 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +typedef int V __attribute__((vector_size (sizeof (int) * 4))); + +void +f1 (V *p) +{ + V mask = { 1, 2, 3, 0 }; + *p = __builtin_shuffle (*p, mask); +} + +void +f2 (V *p, V *q) +{ + V mask = { 1, 2, 3, 0 }; + *p = __builtin_shuffle (*p, *q, mask); +} + +void +f3 (V *p, V *mask) +{ + V a = { 1, 2, 3, 0 }; + *p = __builtin_shuffle (a, *mask); +} + +void +f4 (V *p, V *mask) +{ + V a = { 1, 2, 3, 0 }; + V b = { 2, 3, 4, 1 }; + *p = __builtin_shuffle (a, b, *mask); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-var-4.c b/SingleSource/Regression/C/gcc-dg/Wunused-var-4.c new file mode 100644 index 0000000000..08ddcf4407 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-var-4.c @@ -0,0 +1,33 @@ +/* PR c/96571 */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -O2 -Wunused-but-set-variable" } */ + +enum E { V }; + +int +foo (void) +{ + enum E v; /* { dg-bogus "set but not used" } */ + return _Generic (v, enum E : 0); +} + +int +bar (void) +{ + int a = 0; /* { dg-bogus "set but not used" } */ + return _Generic (0, int : a); +} + +int +baz (void) +{ + int a; /* { dg-bogus "set but not used" } */ + return _Generic (0, long long : a, int : 0); +} + +int +qux (void) +{ + int a; /* { dg-bogus "set but not used" } */ + return _Generic (0, long long : a, default: 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-var-5.c b/SingleSource/Regression/C/gcc-dg/Wunused-var-5.c new file mode 100644 index 0000000000..cc5bbf51ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-var-5.c @@ -0,0 +1,23 @@ +/* PR c/99588 */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wunused-but-set-variable" } */ + +void bar (int, ...); +void f1 (void) { static _Atomic int x = 0; bar (0, x); } +void f2 (void) { static _Atomic int x = 0; bar (0, x += 1); } +void f3 (void) { static _Atomic int x = 0; bar (x); } +void f4 (void) { static _Atomic int x = 0; bar (x += 1); } +void f5 (void) { static _Atomic int x = 0; bar (x = 1); } +void f6 (void) { static _Atomic int x = 0; x = 1; } /* { dg-warning "variable 'x' set but not used" } */ +void f7 (void) { static _Atomic int x = 0; x += 3; } +void f8 (void) { _Atomic int x = 0; bar (0, x); } +void f9 (void) { _Atomic int x = 0; bar (0, x += 1); } +void f10 (void) { _Atomic int x = 0; bar (x); } +void f11 (void) { _Atomic int x = 0; bar (x += 1); } +void f12 (void) { _Atomic int x = 0; bar (x = 1); } +void f13 (void) { _Atomic int x = 0; x = 1; } /* { dg-warning "variable 'x' set but not used" } */ +void f14 (void) { _Atomic int x = 0; x += 3; } +void f15 (void) { _Atomic int x = 0; int y = 3; x += y; } +void f16 (void) { _Atomic int x = 0; int y = 3; bar (x += y); } +void f17 (void) { _Atomic int x = 0; int y = 3; x = y; } /* { dg-warning "variable 'x' set but not used" } */ +void f18 (void) { _Atomic int x = 0; int y = 3; bar (x = y); } diff --git a/SingleSource/Regression/C/gcc-dg/Wunused-var-6.c b/SingleSource/Regression/C/gcc-dg/Wunused-var-6.c new file mode 100644 index 0000000000..f48a4554d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wunused-var-6.c @@ -0,0 +1,14 @@ +/* PR c/99588 */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wunused-but-set-variable" } */ + +void bar (int, ...); +struct S { int a, b, c; }; +typedef _Atomic struct S T; + +void +foo (void) +{ + static T x = (struct S) { 0, 0, 0 }; /* { dg-bogus "set but not used" } */ + bar (0, x = (struct S) { 1, 1, 1 }); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wuse-after-free-2.c b/SingleSource/Regression/C/gcc-dg/Wuse-after-free-2.c new file mode 100644 index 0000000000..ac174fdd10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wuse-after-free-2.c @@ -0,0 +1,118 @@ +/* PR middle-end/104232 - spurious -Wuse-after-free after conditional free + { dg-do compile } + { dg-options "-O2 -Wall -fno-tree-loop-distribute-patterns -fno-ivopts" } */ + +void free (void*); + +void sink (void*); + +void nowarn_cond_2 (char *p0, char *q0, int i) +{ + char *r = i ? p0 : q0; + + free (p0); + + /* The use of a PHI operand could be diagnosed using the "maybe" form + of the warning at level 2 but it's not done. If it ever changes + this test and those below will need to be updated. */ + sink (r); +} + +void nowarn_cond_2_null (char *p0, int i) +{ + char *r = i ? p0 : 0; + + free (p0); + sink (r); +} + +void nowarn_cond_3 (char *p0, char *q0, int i) +{ + char *r = i < 0 ? p0 - 1 : 0 < i ? p0 + 1 : q0; + + free (p0); + sink (r); +} + +void nowarn_cond_3_null (char *p0, int i) +{ + char *r = i < 0 ? p0 - 1 : 0 < i ? p0 + 1 : 0; + + free (p0); + sink (r); +} + +void nowarn_cond_4 (char *p0, char *q0, int i) +{ + char *r = i < -1 ? p0 - 2 : i < 0 ? p0 - 1 : 1 < i ? p0 + 1 : q0; + + free (p0); + sink (r); +} + +int nowarn_cond_loop (char *p) +{ + char *q = p; + while (*q) + { + if (*q == 'x') + { + q = ""; + break; + } + ++q; + } + + free (p); + return *q; +} + + +void warn_cond_2_cst (char *p, int i) +{ + /* Same as nowarn_cond_2() above but with R being derived only from + P, which means that any R's use after P has been freed should be + diagnosed. */ + char *r = i ? p + 1 : p + 2; + + free (p); // { dg-message "call to 'free'" } + sink (r); // { dg-warning "pointer 'r' used after 'free'" } +} + +void warn_cond_2_var (char *p, int i, int j) +{ + char *r = i ? p + i : p + j; + + free (p); // { dg-message "call to 'free'" } + sink (r); // { dg-warning "pointer 'r' used after 'free'" } +} + +void warn_cond_3_var (char *p0, int i, int j) +{ + char *r = i < 0 ? p0 - i : 0 < i ? p0 + j : p0 + i + j; + + free (p0); // { dg-message "call to 'free'" } + sink (r + 1); // { dg-warning "pointer 'r' used after 'free'" } +} + +int warn_cond_4 (char *p0, char *q0, int i) +{ + char *r = i < -1 ? p0 - 2 : i < 0 ? p0 - 1 : 1 < i ? p0 + 2 : p0 + 1; + + free (p0); // { dg-message "call to 'free'" } + return *r; // { dg-warning "pointer 'r' used after 'free'" } +} + +int warn_cond_loop (char *p) +{ + char *q = p; + + /* -fno-tree-loop-distribute-patterns ensures this does not get converted + into rawmemchr (making q and p unrelated). Also, -fno-ivopts is required + for some targets, to not lose track of the pointer. */ + while (*q) + ++q; + + free (p); // { dg-message "call to 'free'" } + return *q; // { dg-warning "pointer 'q' used after 'free'" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wuse-after-free-3.c b/SingleSource/Regression/C/gcc-dg/Wuse-after-free-3.c new file mode 100644 index 0000000000..d1bcfcb3dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wuse-after-free-3.c @@ -0,0 +1,22 @@ +/* PR middle-end/104232 - spurious -Wuse-after-free after conditional free + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +char* f (void); + +static inline void freep (void *p) +{ + __builtin_free (*(void**)p); // { dg-bogus "-Wuse-after-free" } +} + +int test_no_warn (void) +{ + __attribute__ ((__cleanup__ (freep))) char *s = 0, *t = 0; + + t = f (); + if (!t) + return 0; + + s = f (); + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wuse-after-free-pr109123.c b/SingleSource/Regression/C/gcc-dg/Wuse-after-free-pr109123.c new file mode 100644 index 0000000000..ece066dd28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wuse-after-free-pr109123.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +typedef long unsigned int size_t; +extern void *realloc (void *__ptr, size_t __size) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__)) __attribute__ ((__alloc_size__ (2))); +struct vector_objective; +typedef struct vector_objective vector_objective; +struct vector_objective { double *_begin; double *_end; double *_capacity; }; +static inline size_t vector_objective_size(const vector_objective * v) { + return v->_end - v->_begin; /* { dg-bogus "used after" } */ +} +static inline size_t vector_objective_capacity(const vector_objective * v) { + return v->_capacity - v->_begin; +} +static inline void vector_objective_reserve(vector_objective * v, size_t n) { + size_t old_capacity = vector_objective_capacity(v); + size_t old_size = vector_objective_size(v); + if (n > old_capacity) { + v->_begin = realloc(v->_begin, sizeof(double) * n); + v->_end = v->_begin + old_size; + v->_capacity = v->_begin + n; + } +} +static inline void vector_objective_push_back(vector_objective * v, double x) { + if (v->_end == v->_capacity) + vector_objective_reserve (v, (vector_objective_capacity (v) == 0) ? 8 : 2 * vector_objective_capacity (v)); + *(v->_end) = x; + v->_end++; +} + +typedef struct { + vector_objective xy; +} eaf_polygon_t; + +int +rectangle_add(eaf_polygon_t * regions, double lx) +{ + vector_objective_push_back(®ions->xy, lx); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/Wuse-after-free-pr109170.c b/SingleSource/Regression/C/gcc-dg/Wuse-after-free-pr109170.c new file mode 100644 index 0000000000..14f1350aa2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wuse-after-free-pr109170.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuse-after-free=2" } */ + +unsigned long bufmax = 0; +unsigned long __open_catalog_bufmax; +void *realloc(void *, __SIZE_TYPE__); +void free(void *); + +void __open_catalog(char *buf) +{ + char *old_buf = buf; + buf = realloc (buf, bufmax); + if (__builtin_expect ((buf == ((void *)0)), 0)) + free (old_buf); /* { dg-bogus "used after" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wuse-after-free.c b/SingleSource/Regression/C/gcc-dg/Wuse-after-free.c new file mode 100644 index 0000000000..9862de5c0a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wuse-after-free.c @@ -0,0 +1,41 @@ +/* PR middle-end/104069 - -Werror=use-after-free false positive on + elfutils-0.186 + { dg-do compile } + { dg-options "-Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* realloc (void *, size_t); + +void* __libdw_unzstd (size_t todo) +{ + void *sb = 0; + + for ( ; ; ) + { + // Ran only once. + if (!sb) + { + char *b = realloc (sb, todo); + if (!b) + break; + + sb = b; + } + + todo -= 1; + if (todo == 0) + break; + } + + // Shrink buffer: leave only one byte for simplicity. + char *b = realloc (sb, 1); + if (b) + sb = b; + else + { + // Realloc failed mysteriously, leave 'sb' untouched. + } + + return sb; // { dg-bogus "-Wuse-after-free" } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wuseless-cast.c b/SingleSource/Regression/C/gcc-dg/Wuseless-cast.c new file mode 100644 index 0000000000..86e87584b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wuseless-cast.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuseless-cast" } */ + +void foo(void) +{ + // casts to the same type + int i = 0; + const int ic = 0; + struct foo { int x; } x = { 0 }; + int q[3]; + (int)ic; /* { dg-warning "useless cast" } */ + (int)i; /* { dg-warning "useless cast" } */ + (const int)ic; /* { dg-warning "useless cast" } */ + (const int)i; /* { dg-warning "useless cast" } */ + (struct foo)x; /* { dg-warning "useless cast" } */ + (int(*)[3])&q; /* { dg-warning "useless cast" } */ + (_Atomic(int))i; /* { dg-warning "useless cast" } */ + + // not the same + int n = 3; + (int(*)[n])&q; // no warning + int j = (int)0UL; + enum X { A = 1 } xx = { A }; + enum Y { B = 1 } yy = (enum Y)xx; +} + diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-1.c b/SingleSource/Regression/C/gcc-dg/Wvla-1.c new file mode 100644 index 0000000000..d2e3cb57d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-1.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -Wvla" } */ + +extern void +func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-2.c b/SingleSource/Regression/C/gcc-dg/Wvla-2.c new file mode 100644 index 0000000000..92c67ed639 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-2.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Wvla" } */ + +extern void +func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-3.c b/SingleSource/Regression/C/gcc-dg/Wvla-3.c new file mode 100644 index 0000000000..45132fa6b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-3.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c89 -Wvla" } */ + +extern void +func (int i, int array[i]); /* { dg-error "ISO C90 forbids variable.* array 'array'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-4.c b/SingleSource/Regression/C/gcc-dg/Wvla-4.c new file mode 100644 index 0000000000..ae2e0b064a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-4.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c99 -Wvla" } */ + +extern void +func (int i, int array[i]); /* { dg-warning "ISO C90 forbids variable length array 'array'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-5.c b/SingleSource/Regression/C/gcc-dg/Wvla-5.c new file mode 100644 index 0000000000..919b8dc201 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-5.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c89 -Wno-vla" } */ + +extern void +func (int i, int array[i]); diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-6.c b/SingleSource/Regression/C/gcc-dg/Wvla-6.c new file mode 100644 index 0000000000..694a4cc16c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-6.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -Wvla" } */ + +extern void +func (int i, int [i]); /* { dg-warning "ISO C90 forbids variable length array" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-7.c b/SingleSource/Regression/C/gcc-dg/Wvla-7.c new file mode 100644 index 0000000000..4c264f0d8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-7.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c89 -Wvla" } */ + +extern void +func (int i, int [i]); /* { dg-error "ISO C90 forbids variable" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-1.c b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-1.c new file mode 100644 index 0000000000..f0617f9530 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Wvla-larger-than=100 -O2" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void useit (char *); + +int num; + +void test_vlas (size_t num) +{ + char str2[num]; /* { dg-warning "unbounded use" } */ + useit(str2); + + num = 98; + for (int i=0; i < 1234; ++i) { + char str[num]; // OK, VLA in a loop, but it is a + // known size *AND* the compiler takes + // care of cleaning up between + // iterations with + // __builtin_stack_restore. + useit(str); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-2.c b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-2.c new file mode 100644 index 0000000000..a3a053402f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-2.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O2 -Wvla-larger-than=40" } */ + +#include + +void f0 (void *); +void +f1 (__SIZE_TYPE__ a) +{ + if (a <= 10) + { + // 10 * 4 bytes = 40: OK! + uint32_t x[a]; + f0 (x); + } +} + +void +f2 (__SIZE_TYPE__ a) +{ + if (a <= 11) + { + // 11 * 4 bytes = 44: Not OK. + uint32_t x[a]; // { dg-warning "array may be too large" } + f0 (x); + } +} + +void +f3 (__SIZE_TYPE__ a, __SIZE_TYPE__ b) +{ + if (a <= 5 && b <= 3) + { + // 5 * 3 * 4 bytes = 60: Not OK. + uint32_t x[a][b]; // { dg-warning "array may be too large" } + f0 (x); + } +} + +void +f4 (__SIZE_TYPE__ a, __SIZE_TYPE__ b) +{ + if (a <= 5 && b <= 2) + { + // 5 * 2 * 4 bytes = 40 bytes: OK! + uint32_t x[a][b]; + f0 (x); + } +} + +void +f5 (__SIZE_TYPE__ len) +{ + // Test that a direct call to __builtin_alloca_with_align is not + // confused with a VLA. + void *p = __builtin_alloca_with_align (len, 8); + f0 (p); +} + +void +f6 (unsigned stuff) +{ + int n = 7000; + do { + char a[n]; // { dg-warning "variable-length array is too large" } + f0 (a); + } while (stuff--); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-3.c b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-3.c new file mode 100644 index 0000000000..70011f1d38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-3.c @@ -0,0 +1,68 @@ +/* Verify that VLA definitions with an unknown upper bound don't trigger + -Wvla-larger-than= warnings by default. + { dg-do compile } + { dg-require-effective-target alloca } + { dg-options "-O2 -Wall" } */ + +void f (void *, ...); + +void nowarn_vla_int (int n) +{ + char a[n]; + + if (n < 1234) + n = 1234; + + char b[n]; + f (a, b); +} + +void nowarn_vla_uint (unsigned n) +{ + char a[n]; + f (a); + + if (n < 2345) + n = 2345; + + char b[n]; + f (a, b); +} + +void nowarn_vla_long (long n) +{ + char a[n]; + + if (n < 1234) + n = 1234; + + char b[n]; + f (a, b); +} + +void nowarn_vla_ulong (unsigned long n) +{ + char a[n]; + f (a); + + if (n < 2345) + n = 2345; + + char b[n]; + f (a, b); +} + +/* Verify that a VLA whose size is definitely in excess of PTRDIFF_MAX + is diagnosed by default. */ + +void warn_vla (__PTRDIFF_TYPE__ n) +{ + int a[n]; + f (a); + + if (n <= __PTRDIFF_MAX__) + n = __PTRDIFF_MAX__; + + int b[n]; /* { dg-warning "argument to variable-length array is too large" } */ + f (a, b); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-4.c b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-4.c new file mode 100644 index 0000000000..7d27829736 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-4.c @@ -0,0 +1,30 @@ +/* PR middle-end/94004 - missing -Walloca on calls to alloca due + to -Wno-system-headers + { dg-do compile } + { dg-options "-O2 -Wall -Wvla-larger-than=31 -ftrack-macro-expansion=0" } + { dg-require-effective-target alloca } */ + +void sink (void*, ...); + +static inline void inline_use_vla (unsigned n) +{ + if (n > 32) + n = 32; + char a[n]; // { dg-warning "\\\[-Wvla-larger-than" } + sink (a, 2); +} + +static inline void use_inlined_vla (unsigned n) +{ + inline_use_vla (n); // this call is okay + inline_use_vla (n + 1); // this one is not (line 20) +} + +void call_inline (void) +{ + use_inlined_vla (31); // line 25 +} + +/* Verify that the inlining context is included and that it points + to the correct line number in the inlined function: + { dg-message "function 'inline_use_vla'.*inlined from 'use_inlined_vla'.*:20:.*inlined from 'call_inline' .*:25:" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-5.c b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-5.c new file mode 100644 index 0000000000..ebd7fb3e01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-larger-than-5.c @@ -0,0 +1,39 @@ +/* PR middle-end/100510 - bogus -Wvla-large-than with -Walloca + { dg-do compile } + { dg-options "-O0 -Walloca -Wvla-larger-than=1000" } + { dg-require-effective-target alloca } */ + +void f (void*); + +#pragma GCC optimize ("0") + +void nowarn_O0 (__SIZE_TYPE__ n) +{ + if (n > 32) + return; + + char a[n]; // { dg-bogus "\\\[-Wvla-larger-than=" } + f (a); +} + +#pragma GCC optimize ("1") + +void nowarn_O1 (__SIZE_TYPE__ n) +{ + if (n > 33) + return; + + char a[n]; // { dg-bogus "\\\[-Wvla-larger-than=" } + f (a); +} + +#pragma GCC optimize ("2") + +void nowarn_O2 (__SIZE_TYPE__ n) +{ + if (n > 34) + return; + + char a[n]; // { dg-bogus "\\\[-Wvla-larger-than=" } + f (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-10.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-10.c new file mode 100644 index 0000000000..68db3edfbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-10.c @@ -0,0 +1,68 @@ +/* PR c/100719 - missing -Wvla-parameter on a mismatch in second parameter + { dg-do compile } + { dg-options "-Wall" } */ + +typedef struct A1 { int i; } A1; +typedef struct A2 { int i; } A2; +typedef struct A3 { int i; } A3; + +void f2 (int n, A1[n], A2[n]); +void f2 (int n, A1[n], A2[n]); + +void f2_x1 (int n, A1[n], A2[n]); // { dg-note "previously declared as 'A1\\\[n]' with bound argument 1" } +void f2_x1 (int n, A1[n + 1], A2[n]); // { dg-warning "argument 2 of type 'A1\\\[n \\+ 1]' declared with mismatched bound 'n \\+ 1'" } + +void f2_x2 (int n, A1[n], A2[n]); // { dg-note "previously declared as 'A2\\\[n]' with bound argument 1" } +void f2_x2 (int n, A1[n], A2[n + 2]); // { dg-warning "argument 3 of type 'A2\\\[n \\+ 2]' declared with mismatched bound 'n \\+ 2'" } + + +void f3 (int n, A1[n], A2[n], A3[n]); +void f3 (int n, A1[n], A2[n], A3[n]); + +void f3_x1 (int n, A1[n], A2[n], A3[n]); +// { dg-note "previously declared as 'A1\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void f3_x1 (int n, A1[n + 1], A2[n], A3[n]); +// { dg-warning "argument 2 of type 'A1\\\[n \\+ 1]' declared with mismatched bound 'n \\+ 1'" "" { target *-*-* } .-1 } + +void f3_x2 (int n, A1[n], A2[n], A3[n]); +// { dg-note "previously declared as 'A2\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void f3_x2 (int n, A1[n], A2[n + 2], A3[n]); +// { dg-warning "argument 3 of type 'A2\\\[n \\+ 2]' declared with mismatched bound 'n \\+ 2'" "" { target *-*-* } .-1 } + +void f3_x3 (int n, A1[n], A2[n], A3[n]); +// { dg-note "previously declared as 'A3\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void f3_x3 (int n, A1[n], A2[n], A3[n + 3]); +// { dg-warning "argument 4 of type 'A3\\\[n \\+ 3]' declared with mismatched bound 'n \\+ 3'" "" { target *-*-* } .-1 } + + +void g3_x1 (int n, A1[n], A2[*], A3[n]); +// { dg-note "previously declared as 'A1\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void g3_x1 (int n, A1[n + 1], A2[*], A3[n]); +// { dg-warning "argument 2 of type 'A1\\\[n \\+ 1]' declared with mismatched bound 'n \\+ 1'" "" { target *-*-* } .-1 } + +void g3_x2 (int n, A1[*], A2[n], A3[n]); +// { dg-note "previously declared as 'A2\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void g3_x2 (int n, A1[*], A2[n + 2], A3[n]); +// { dg-warning "argument 3 of type 'A2\\\[n \\+ 2]' declared with mismatched bound 'n \\+ 2'" "" { target *-*-* } .-1 } + +void g3_x3 (int n, A1[*], A2[*], A3[n]); +// { dg-note "previously declared as 'A3\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void g3_x3 (int n, A1[*], A2[*], A3[n + 3]); +// { dg-warning "argument 4 of type 'A3\\\[n \\+ 3]' declared with mismatched bound 'n \\+ 3'" "" { target *-*-* } .-1 } + + +void h3_x1 (int n, A1[n], A2[ ], A3[n]); +// { dg-note "previously declared as 'A1\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void h3_x1 (int n, A1[n + 1], A2[ ], A3[n]); +// { dg-warning "argument 2 of type 'A1\\\[n \\+ 1]' declared with mismatched bound 'n \\+ 1'" "" { target *-*-* } .-1 } + +void h3_x2 (int n, A1[ ], A2[n], A3[n]); +// { dg-note "previously declared as 'A2\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void h3_x2 (int n, A1[ ], A2[n + 2], A3[n]); +// { dg-warning "argument 3 of type 'A2\\\[n \\+ 2]' declared with mismatched bound 'n \\+ 2'" "" { target *-*-* } .-1 } + +void h3_x3 (int n, A1[ ], A2[ ], A3[n]); +// { dg-note "previously declared as 'A3\\\[n]' with bound argument 1" "note" { target *-*-* } .-1 } +void h3_x3 (int n, A1[ ], A2[ ], A3[n + 3]); +// { dg-warning "argument 4 of type 'A3\\\[n \\+ 3]' declared with mismatched bound 'n \\+ 3'" "" { target *-*-* } .-1 } + diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-11.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-11.c new file mode 100644 index 0000000000..39886a22d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-11.c @@ -0,0 +1,70 @@ +/* PR c/100719 - missing -Wvla-parameter on a mismatch in second parameter + { dg-do compile } + { dg-options "-Wall" } */ + +typedef struct A1 { int i; } A1; +typedef struct A2 { int i; } A2; +typedef struct A3 { int i; } A3; + +extern int n, n1, n2, n3; + +void f2 (int, A1[n], A2[n]); +void f2 (int, A1[n], A2[n]); + +void f2_x1 (int, A1[n], A2[n]); // { dg-note "previously declared as 'A1\\\[n]'" } +void f2_x1 (int, A1[n1], A2[n]); // { dg-warning "argument 2 of type 'A1\\\[n1]' declared with mismatched bound 'n1'" } + +void f2_x2 (int, A1[n], A2[n]); // { dg-note "previously declared as 'A2\\\[n]'" } +void f2_x2 (int, A1[n], A2[n2]); // { dg-warning "argument 3 of type 'A2\\\[n2]' declared with mismatched bound 'n2'" } + + +void f3 (int, A1[n], A2[n], A3[n]); +void f3 (int, A1[n], A2[n], A3[n]); + +void f3_x1 (int, A1[n], A2[n], A3[n]); +// { dg-note "previously declared as 'A1\\\[n]'" "note" { target *-*-* } .-1 } +void f3_x1 (int, A1[n1], A2[n], A3[n]); +// { dg-warning "argument 2 of type 'A1\\\[n1]' declared with mismatched bound 'n1'" "" { target *-*-* } .-1 } + +void f3_x2 (int, A1[n], A2[n], A3[n]); +// { dg-note "previously declared as 'A2\\\[n]'" "note" { target *-*-* } .-1 } +void f3_x2 (int, A1[n], A2[n2], A3[n]); +// { dg-warning "argument 3 of type 'A2\\\[n2]' declared with mismatched bound 'n2'" "" { target *-*-* } .-1 } + +void f3_x3 (int, A1[n], A2[n], A3[n]); +// { dg-note "previously declared as 'A3\\\[n]'" "note" { target *-*-* } .-1 } +void f3_x3 (int, A1[n], A2[n], A3[n3]); +// { dg-warning "argument 4 of type 'A3\\\[n3]' declared with mismatched bound 'n3'" "" { target *-*-* } .-1 } + + +void g3_x1 (int, A1[n], A2[*], A3[n]); +// { dg-note "previously declared as 'A1\\\[n]'" "note" { target *-*-* } .-1 } +void g3_x1 (int, A1[n1], A2[*], A3[n]); +// { dg-warning "argument 2 of type 'A1\\\[n1]' declared with mismatched bound 'n1'" "" { target *-*-* } .-1 } + +void g3_x2 (int, A1[*], A2[n], A3[n]); +// { dg-note "previously declared as 'A2\\\[n]'" "note" { target *-*-* } .-1 } +void g3_x2 (int, A1[*], A2[n2], A3[n]); +// { dg-warning "argument 3 of type 'A2\\\[n2]' declared with mismatched bound 'n2'" "" { target *-*-* } .-1 } + +void g3_x3 (int, A1[*], A2[*], A3[n]); +// { dg-note "previously declared as 'A3\\\[n]'" "note" { target *-*-* } .-1 } +void g3_x3 (int, A1[*], A2[*], A3[n3]); +// { dg-warning "argument 4 of type 'A3\\\[n3]' declared with mismatched bound 'n3'" "" { target *-*-* } .-1 } + + +void h3_x1 (int, A1[n], A2[ ], A3[n]); +// { dg-note "previously declared as 'A1\\\[n]'" "note" { target *-*-* } .-1 } +void h3_x1 (int, A1[n1], A2[ ], A3[n]); +// { dg-warning "argument 2 of type 'A1\\\[n1]' declared with mismatched bound 'n1'" "" { target *-*-* } .-1 } + +void h3_x2 (int, A1[ ], A2[n], A3[n]); +// { dg-note "previously declared as 'A2\\\[n]'" "note" { target *-*-* } .-1 } +void h3_x2 (int, A1[ ], A2[n2], A3[n]); +// { dg-warning "argument 3 of type 'A2\\\[n2]' declared with mismatched bound 'n2'" "" { target *-*-* } .-1 } + +void h3_x3 (int, A1[ ], A2[ ], A3[n]); +// { dg-note "previously declared as 'A3\\\[n]'" "note" { target *-*-* } .-1 } +void h3_x3 (int, A1[ ], A2[ ], A3[n3]); +// { dg-warning "argument 4 of type 'A3\\\[n3]' declared with mismatched bound 'n3'" "" { target *-*-* } .-1 } + diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-12.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-12.c new file mode 100644 index 0000000000..1be5e48203 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-12.c @@ -0,0 +1,36 @@ +/* PR c/101289 - bogus -Wvla-parameter warning when using const bound + { dg-do compile } + { dg-options "-Wall" } */ + +void f1ci_can (const int n, char a[n]); +void f1ci_can (const int n, char a[n]); // { dg-bogus "-Wvla-parameter" } + +void f2ci_can (const int m, char a[m]); +void f2ci_can (int n, char a[n]); // { dg-bogus "-Wvla-parameter" } + +void f3i_can (int n, char a[n]); +void f3i_can (const int n, char a[n]); // { dg-bogus "-Wvla-parameter" } + +void f4i_can (int n, char a[n]); +void f4i_can (const int n, char a[(int)n]); // { dg-bogus "-Wvla-parameter" } + +void f5i_can (int n, char a[(char)n]); +void f5i_can (const int n, char a[(char)n]); // { dg-bogus "-Wvla-parameter" } + +void f6i_can (int m, char a[(char)m]); +void f6i_can (const int n, char a[(char)n]); // { dg-bogus "-Wvla-parameter" "" { xfail *-*-* } } + + +/* PR c/97548 - bogus -Wvla-parameter on a bound expression involving + a parameter */ + +int n; + +void f7ianp1 (int, int[n + 1]); +void f7ianp1 (int, int[n + 1]); +void f7ianp1 (int, int[n + 2]); // { dg-warning "-Wvla-parameter" } + +void f8iakp1 (int k, int [k + 1]); +void f8iakp1 (int k, int [k + 1]); // { dg-bogus "-Wvla-parameter" } +void f8iakp1 (int k, int [1 + k]); // { dg-bogus "-Wvla-parameter" } +void f8iakp1 (int k, int [k + 2]); // { dg-warning "-Wvla-parameter" } diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-13.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-13.c new file mode 100644 index 0000000000..f64d29c665 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-13.c @@ -0,0 +1,18 @@ +/* PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters + { dg-do compile } + { dg-options "-Wall -fsanitize=undefined" } */ + +void f1 (int n, int (*)[n]); +void f1 (int n, int (*)[n]); // { dg-bogus "\\\[-Wvla-parameter" } + +void g1 (int m, int (*)[m]); +void g1 (int n, int (*)[n]); // { dg-bogus "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } } + +void h1 (int n, int (*)[n]); +void h1 (int n, int (*)[n + 1]); // { dg-warning "\\\[-Wvla-parameter" } + +void f2 (int m, int n, int (*)[m][n]); +void f2 (int n, int m, int (*)[n][m]); // { dg-bogus "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } } + +void g2 (int m, int n, int (*)[m][n]); +void g2 (int n, int m, int (*)[m][n]); // { dg-warning "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } } diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-2.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-2.c new file mode 100644 index 0000000000..daa71d897c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-2.c @@ -0,0 +1,75 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + Verify the -Wvla-parameter warnings correctly diagnose mismatches + between multimensional array arguments with one or more variable + bounds in redeclarations of the same function. + { dg-do compile } + { dg-options "-Wall -Wvla-parameter" } */ + +void fmn_a1n_axn (int n, int[1][n]); // { dg-message "previously declared as 'int\\\[1]\\\[n]' with 1 variable bound" "note" } +void fmn_a1n_axn (int n, int[*][n]); // { dg-warning "argument 2 of type 'int\\\[\\\*]\\\[n]' declared with 2 variable bounds" } + + +void fmn_axn_a2n (int n, int[*][n]); // { dg-message "previously declared as 'int\\\[\\\*]\\\[n]' with 2 variable bounds" "note" } +void fmn_axn_a2n (int n, int[2][n]); // { dg-warning "argument 2 of type 'int\\\[2]\\\[n]' declared with 1 variable bound" } + + +void fmn_amn_axn (int m, int n, int[m][n]); // { dg-message "previously declared as 'int\\\[m]\\\[n]' with 0 unspecified variable bounds" "note" } +void fmn_amn_axn (int m, int n, int[*][n]); // { dg-warning "argument 3 of type 'int\\\[\\\*]\\\[n]' declared with 1 unspecified variable bound" } + +// Same as above but a different function name. +void gmn_amn_axn (int m, int n, int[m][n]); // { dg-message "previously declared as 'int\\\[m]\\\[n]' with 0 unspecified variable bounds" "note" } +void gmn_amn_axn (int m, int n, int[*][n]); // { dg-warning "argument 3 of type 'int\\\[\\\*]\\\[n]' declared with 1 unspecified variable bound" } + +typedef int A7[7]; + +void fm_A7_m_5 (int m, A7[m][5]); // { dg-message "previously declared as 'int\\\[m]\\\[5]\\\[7]' with bound argument 1" "note" } +void fm_A7_m_5 (int n, A7[n][5]); + +void fm_A7_m_5 (int n, A7[n + 1][5]); // { dg-warning "argument 2 of type 'int\\\[n \\\+ 1]\\\[5]\\\[7]' declared with mismatched bound 'n \\\+ 1'" } + + +int n1, n2, n3, n4, n5, n6, n7, n8, n9; +void f (int[n1][2][n3][4][n5][6][n7][8][n9]); // { dg-message "previously declared as 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' with 0 unspecified variable bounds" "note" } + // { dg-message "with 5 variable bounds" "note" { target *-*-* } .-1 } +void f (int[n1][2][n3][4][n5][6][n7][8][n9]); + +/* Due to a limitation and because [*] is represented the same as [0] + only the most significant array bound is rendered as [*]; the others + are rendered as [0]. */ +void f (int[n1][2][n3][4][n5][6][n7][8][*]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[\\\*]' declared with 1 unspecified variable bound" "pr100420 (expected)" { xfail *-*-* } } +// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[0]' declared with 1 unspecified variable bound" "pr100420" { target *-*-* } .-1 } +void f (int[n1][2][n3][4][n5][6][*][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[\\\*]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420 (expected)" { xfail *-*-* } } +// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[0]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420" { target *-*-* } .-1 } +void f (int[n1][2][n3][4][*][6][n7][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[\\\*]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420 (expected)" { xfail *-*-*} } +// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[n3]\\\[4]\\\[0]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420" { target *-*-* } .-1 } +void f (int[n1][2][*][4][n5][6][n7][8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[\\\*]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420 (expected)" { xfail *-*-* } } +// { dg-warning "argument 1 of type 'int\\\[n1]\\\[2]\\\[0]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" "pr100420" { target *-*-* } .-1 } +void f (int[*][2][n3][4][n5][6][n7][8][n9]); // { dg-warning "argument 1 of type 'int\\\[\\\*]\\\[2]\\\[n3]\\\[4]\\\[n5]\\\[6]\\\[n7]\\\[8]\\\[n9]' declared with 1 unspecified variable bound" } + +void f (int[n1][n2][n3][n4][n5][n6][n7][n8][n9]); // { dg-warning "argument 1 of type 'int\\\[n1]\\\[n2]\\\[n3]\\\[n4]\\\[n5]\\\[n6]\\\[n7]\\\[n8]\\\[n9]' declared with 9 variable bounds" } + +// Verify that arrays of pointers to arrays...etc are handled correctly. +void a2pampan (int (*(*(*[2])[n1])[n2])); +// { dg-message "previously declared as 'int \\\* \\\(\\\* \\\(\\\*\\\[2]\\\)\\\[n1]\\\)\\\[n2]'" "note" { target *-*-* } .-1 } +void a2pampan (int (*(*(*[2])[n1])[1])); +// { dg-warning "argument 1 of type 'int \\\* \\\(\\\* \\\(\\\*\\\[2]\\\)\\\[n1]\\\)\\\[1]' declared with 1 variable bound" "" { target *-*-* } .-1 } +void a2pampan (int (*(*(*[2])[1])[n2])); +// { dg-warning "argument 1 of type 'int \\\* \\\(\\\* \\\(\\\*\\\[2]\\\)\\\[1]\\\)\\\[n2]' declared with 1 variable bound" "" { target *-*-* } .-1 } +void a2pampan (int (*(*(*[2])[n1])[n1])); +// { dg-warning "argument 1 of type 'int \\\* \\\(\\\* \\\(\\\*\\\[2]\\\)\\\[n1]\\\)\\\[n1]' declared with mismatched bound 'n1'" "" { target *-*-* } .-1 } +void a2pampan (int (*(*(*[2])[n1])[n2])); + + +/* Verify that the presence or absence of static with VLA dooesn't cause + unwanted warnings. */ + +int f2ia1_1 (int n, int [n][n]); // { sg-message "previously declared as 'int\\\[n]\\\[n]' with bound argument 1" } +int f2ia1_1 (int n, int[static n][n]); +int f2ia1_1 (int n, int a[static n][n]) { return sizeof *a; } +int f2ia1_1 (int n, int[static n + 1][n]); // { dg-warning "argument 2 of type 'int\\\[static *n \\\+ 1]\\\[n]' declared with mismatched bound 'n \\\+ 1'" } + +int f2ias1_1 (int n, int [static n][n]); // { dg-message "previously declared as 'int\\\[static +n]\\\[n]' with bound argument 1" } +int f2ias1_1 (int n, int[n][n]); +int f2ias1_1 (int n, int a[++n][n]) // { dg-warning "argument 2 of type 'int\\\[\\\+\\\+n]\\\[n]' declared with mismatched bound ' ?\\+\\+n'" } +{ return sizeof *a; } diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-3.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-3.c new file mode 100644 index 0000000000..f1cf139192 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-3.c @@ -0,0 +1,68 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + Verify that redeclarations of functions with pointer parameters to + arrays with variable bounds are diagnosed if the bounds don't match + either in kind or in the variable expression. + { dg-do compile } + { dg-options "-Wall -Wvla-parameter" } */ + +extern int m, n; + +void pa_ (int (*)[]); // { dg-message "previously declared as 'int \\\(\\\*\\\)\\\[]'" "note" } +void pa_ (int (*)[n]); // { dg-warning "\\\[-Wvla-parameter" } +void pa_ (int (*)[n + 1]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int *\\\(\\\*\\\)\\\[n \\\+ 1\\\]'" } + +void ppa_ (int (**)[]); // { dg-message "previously declared as 'int \\\(\\\*\\\*\\\)\\\[]'" "note" } +void ppa_ (int (**)[n]); // { dg-warning "\\\[-Wvla-parameter" } +void ppa_ (int (**)[n + 1]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\*\\\)\\\[n \\\+ 1\\\]'" } + +void pa1 (int (*)[1]); // { dg-message "previously declared as 'int \\\(\\\*\\\)\\\[1]'" "note" } +void pa1 (int (*)[n]); // { dg-warning "\\\[-Wvla-parameter" } +void pa1 (int (*)[1]); +void pa1 (int (*)[n + 1]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int *\\\(\\\*\\\)\\\[n \\\+ 1\\\]'" } + +void ppax (int (**)[*]); // { dg-message "previously declared as 'int \\\(\\\*\\\*\\\)\\\[.]'" "note" } +void ppax (int (**)[n]); // { dg-warning "\\\[-Wvla-parameter" } +/* A VLA with an unspecified bound is represented the same as [0] so + so the pretty printer can't differentiate between the two forms. */ +void ppax (int (**)[1]); // { dg-bogus "\\\[-Warray-parameter" "pr100420 (expected)" { xfail *-*-* } } + // { dg-warning "\\\[-Wvla-parameter" "pr100420 (expected)" { xfail *-*-* } .-1 } +void ppax (int (**)[n + 1]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int *\\\(\\\*\\\*\\\)\\\[n \\\+ 1\\\]'" } + + +void pa1_n (int (*)[1][n]); +void pa1_n (int (*)[1][n]); +void pa1_n (int (*)[*][n]); // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[\\\*]\\\[n]'" "pr100420 (expected)" { xfail *-*-*} } + // { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[0]\\\[n]'" "pr100420" { target *-*-* } .-1 } + +void pa1_n_2 (int (*)[1][n][2]); +void pa1_n_2 (int (*)[1][n][*]); // { dg-warning "mismatch in bound 3 of argument 1 declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[\\\*]'" "pr100420 (expected)" { xfail *-*-* } } + // { dg-warning "mismatch in bound 3 of argument 1 declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[0]'" "pr100420" { target *-*-* } .-1 } + + +void pa1_n_2_a1_n_2 (int (*)[1][n][2], int (*)[1][n][2]); +// { dg-message "previously declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[2]'" "note" { target *-*-* } .-1 } +void pa1_n_2_a1_n_2 (int (*)[1][n][2], int (*)[1][n][n]); +// { dg-warning "mismatch in bound 3 of argument 2 declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[n]'" "" { target *-*-* } .-1 } +void pa1_n_2_a1_n_2 (int (*)[1][n][2], int (*)[1][3][2]); +// { dg-warning "mismatch in bound 2 of argument 2 declared as 'int \\\(\\\*\\\)\\\[1]\\\[3]\\\[2]'" "" { target *-*-* } .-1 } +void pa1_n_2_a1_n_2 (int (*)[1][n][2], int (*)[n][n][2]); +// { dg-warning "mismatch in bound 1 of argument 2 declared as 'int \\\(\\\*\\\)\\\[n]\\\[n]\\\[2]'" "" { target *-*-* } .-1 } +void pa1_n_2_a1_n_2 (int (*)[1][n][n], int (*)[1][n][2]); +// { dg-warning "mismatch in bound 3 of argument 1 declared as 'int \\\(\\\*\\\)\\\[1]\\\[n]\\\[n]'" "" { target *-*-* } .-1 } +void pa1_n_2_a1_n_2 (int (*)[n][n][2], int (*)[1][n][2]); +// { dg-warning "mismatch in bound 1 of argument 1 declared as 'int \\\(\\\*\\\)\\\[n]\\\[n]\\\[2]'" "" { target *-*-* } .-1 } +void pa1_n_2_a1_n_2 (int (*)[*][*][*], int (*)[*][*][2]); +// { dg-warning "mismatch in bounds 1, 2, 3 of argument 1 declared as 'int \\\(\\\*\\\)\\\[.]\\\[.]\\\[.]'" "" { target *-*-* } .-1 } +// { dg-warning "mismatch in bounds 1, 2 of argument 2 declared as 'int \\\(\\\*\\\)\\\[.]\\\[.]\\\[2]'" "" { target *-*-* } .-2 } +void pa1_n_2_a1_n_2 (int (*)[1][n][2], int (*)[1][n][2]); + +/* Verify that pointers to arrays of pointers to arrays...etc are handled + correctly. */ +void pa2pampan (int (*(*(*(*)[2])[m])[n])); +// { dg-message "previously declared as 'int \\\* \\\(\\\* \\\(\\\* \\\(\\\*\\\)\\\[2]\\\)\\\[m]\\\)\\\[n]'" "note" { target *-*-* } .-1 } +void pa2pampan (int (*(*(*(*)[2])[m])[1])); +// { dg-warning "mismatch in bound 3 of argument 1 declared as 'int \\\* \\\(\\\* \\\(\\\* \\\(\\\*\\\)\\\[2]\\\)\\\[m]\\\)\\\[1]'" "" { target *-*-* } .-1 } +void pa2pampan (int (*(*(*(*)[2])[1])[n])); +// { dg-warning "mismatch in bound 2 of argument 1 declared as 'int \\\* \\\(\\\* \\\(\\\* \\\(\\\*\\\)\\\[2]\\\)\\\[1]\\\)\\\[n]'" "" { target *-*-* } .-1 } +void pa2pampan (int (*(*(*(*)[2])[m])[n])); diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-4.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-4.c new file mode 100644 index 0000000000..f35faea361 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-4.c @@ -0,0 +1,94 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + Verify warnings for redeclarations of functions with pointer parameters + to arrays with variable bounds involving typedefs. + { dg-do compile } + { dg-options "-Wall -Wvla-parameter" } */ + +extern int m, n; + +typedef int IA3[3]; + +/* Verify the warning points to the declaration with more unspecified + bounds, guiding the user to specify them rather than making them all + unspecified. */ + +void* f_pIA3an (IA3 *x[n]); // { dg-message "previously declared as 'int \\\(\\\*\\\[n]\\\)\\\[3]' with 0 unspecified variable bounds" "note" } +void* f_pIA3an (IA3 *x[n]); +void* f_pIA3an (IA3 *x[*]); // { dg-warning "argument 1 of type 'int \\\(\\\*\\\[\\\*]\\\)\\\[3]' .aka '\[^\n\r\}\]+'. declared with 1 unspecified variable bound" } +void* f_pIA3an (IA3 *x[n]) { return x; } + + +void nowarn_local_fndecl (void) +{ + typedef int IAm[m]; + + void* f_IAm (IAm); + void* f_IAm (int[m]); + void* f_IAm (IAm); + + void* f_iam (int[m]); + void* f_iam (IAm); + void* f_iam (int[m]); + + typedef int IA3[3]; + typedef IA3 IAn_3[n]; + typedef IAn_3 IA2_n_3[2]; + typedef IA2_n_3 IAm_2_n_3[m]; + + void f_IAm_2_n_3 (IAm_2_n_3); + void f_IAm_2_n_3 (IA2_n_3[m]); + void f_IAm_2_n_3 (IAn_3[m][2]); + void f_IAm_2_n_3 (IA3[m][2][n]); + void f_IAm_2_n_3 (int[m][2][n][3]); + + void f_iam_2_n_3 (int[m][2][n][3]); + void f_iam_2_n_3 (IA3[m][2][n]); + void f_iam_2_n_3 (IAn_3[m][2]); + void f_iam_2_n_3 (IAm_2_n_3); + + void f_IAx_m_2_n_3 (IAm_2_n_3[*]); + void f_IAx_m_2_n_3 (IA2_n_3[*][m]); + void f_IAx_m_2_n_3 (IAn_3[*][m][2]); + void f_IAx_m_2_n_3 (IA3[*][m][2][n]); + void f_IAx_m_2_n_3 (int[*][m][2][n][3]); + + void f_IA__m_2_n_3 (IAm_2_n_3[]); + void f_IA__m_2_n_3 (IA2_n_3[][m]); + void f_IA__m_2_n_3 (IAn_3[][m][2]); + void f_IA__m_2_n_3 (IA3[][m][2][n]); + void f_IA__m_2_n_3 (int[][m][2][n][3]); +} + + +void warn_local_fndecl (void) +{ + typedef int IAm[m]; + typedef int IAn[n]; + + void* g_IAm (IAm); // { dg-message "previously declared as 'int\\\[m]' with bound 'm'" } + void* g_IAm (int[n]); // { dg-warning "argument 1 of type 'int\\\[n]' declared with mismatched bound 'n'" } + void* g_IAm (IAm); + + void* g_iam (int[m]); // { dg-message "previously declared as 'int\\\[m]' with bound 'm'" } + void* g_iam (IAn); // { dg-warning "argument 1 of type 'int\\\[n]' declared with mismatched bound 'n'" } + void* g_iam (int[m]); + + + typedef int IA3[3]; + typedef IA3 IAn_3[n]; + typedef IAn_3 IA2_n_3[2]; + typedef IA2_n_3 IAm_2_n_3[m]; + + typedef IA3 IAm_3[m]; + typedef IAm_3 IA2_m_3[2]; + typedef IA2_m_3 IAm_2_m_3[m]; + + void* g_IAm_2_n_3 (IAm_2_n_3); + void* g_IAm_2_n_3 (int[m][2][m][3]); // { dg-warning "argument 1 of type 'int\\\[m]\\\[2]\\\[m]\\\[3]' declared with mismatched bound 'm'" } + void* g_IAm_2_n_3 (IAm_2_n_3); + + void* g_iam_2_n_2 (int[m][2][n][3]); + void* g_iam_2_n_2 (IAm_2_m_3); // { dg-warning "argument 1 of type 'int\\\[m]\\\[2]\\\[m]\\\[3]' declared with mismatched bound 'm'" } + void* g_iam_2_n_2 (int[m][2][n][3]); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-5.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-5.c new file mode 100644 index 0000000000..16b40d9539 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-5.c @@ -0,0 +1,22 @@ +/* Verify that combinations of array type qualifiers render correctly. + { dg-do compile } + { dg-options "-Wvla-parameter" } */ + +extern int n1, n2; + +void fcx_n1 (int [const][n1]); // { dg-message "previously declared as 'int\\\[const]\\\[n1]' with bound 'n1'" "note" } +void fcx_n1 (int [const][n2]); // { dg-warning "argument 1 of type 'int\\\[const]\\\[n2]' declared with mismatched bound 'n2'" } + +/* The mismatch in the array bound should not be diagnosed without + -Warray-parameter but the mismatch in the VLA should still be + diagnosed. */ +void fc3_n1 (int [const 3][n1]); // { dg-message "previously declared as 'int\\\[const 3]\\\[n1]' with bound 'n1'" "note" } +void fc3_n1 (int [const 5][n2]); // { dg-warning "argument 1 of type 'int\\\[const 5]\\\[n2]' declared with mismatched bound 'n2'" } + + +void frx_n1 (int [restrict][n1]); // { dg-message "previously declared as 'int\\\[restrict]\\\[n1]' with bound 'n1'" "note" } +void frx_n1 (int [restrict][n2]); // { dg-warning "argument 1 of type 'int\\\[restrict]\\\[n2]' declared with mismatched bound 'n2'" } + + +void fvx_n2 (int [volatile][n2]); // { dg-message "previously declared as 'int\\\[volatile]\\\[n2]' with bound 'n2'" "note" } +void fvx_n2 (int [volatile][n1]); // { dg-warning "argument 1 of type 'int\\\[volatile]\\\[n1]' declared with mismatched bound 'n1'" } diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-6.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-6.c new file mode 100644 index 0000000000..268aeec925 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-6.c @@ -0,0 +1,34 @@ +/* PR middle-end/97189 - ICE on redeclaration of a function with VLA argument + and attribute access + Also verify the right arguments are underlined in the notes. + { dg-do compile } + { dg-options "-Wall -fdiagnostics-show-caret" } */ + +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) + +RW (2, 3) void f1 (int n, int[n], int); +/* { dg-warning "attribute 'access \\(read_write, 2, 3\\)' positional argument 2 conflicts with previous designation by argument 3" "warning" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + RW (2, 3) void f1 (int n, int[n], int); + ^~ + { dg-end-multiline-output "" } + { dg-message "designating the bound of variable length array argument 2" "note" { target *-*-* } .-6 } + { dg-begin-multiline-output "" } + RW (2, 3) void f1 (int n, int[n], int); + ~~~~^ ~~~~~~ + { dg-end-multiline-output "" } */ + + +RW (2) void f2 (int, int[*], int); +/* { dg-message "previously declared as a variable length array 'int\\\[\\\*]'" "note" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + RW (2, 3) void f2 (int, int[], int); + ^~~~~ + { dg-end-multiline-output "" } */ + +RW (2, 3) void f2 (int, int[], int); +/* { dg-warning "argument 2 of type 'int\\\[]' declared as an ordinary array" "warning" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + RW (2) void f2 (int, int[*], int); + ^~~~~~ + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-7.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-7.c new file mode 100644 index 0000000000..14ce75f3e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-7.c @@ -0,0 +1,36 @@ +/* PR middle-end/97189 - ICE on redeclaration of a function with VLA argument + and attribute access + { dg-do compile } + { dg-options "-Wall" } */ + +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) + +RW (2, 3) void f1 (int n, int[n], int); +/* { dg-warning "attribute 'access \\(read_write, 2, 3\\)' positional argument 2 conflicts with previous designation by argument 3" "warning" { target *-*-* } .-1 } + { dg-message "designating the bound of variable length array argument 2" "note" { target *-*-* } .-2 } */ + +void call_f1 (int *p) +{ + /* Verify that a warning is issued. Ideally, it seems the VLA bound + should take precedence over the attribute and the warning would + reference argument 1 but since the conflict in the redeclarations + of the function is already diagnosed don't test that (and let it + be acceptable for this warning to reference argument 3). */ + f1 (-1, p, -1); + // { dg-warning "argument \\d value -1 is negative" "warning" { target *-*-* } .-1 } +} + +RW (2) void f2 (int, int[*], int); +// { dg-message "previously declared as a variable length array 'int\\\[\\\*]'" "note" { target *-*-* } .-1 } +RW (2, 3) void f2 (int, int[], int); +// { dg-warning "argument 2 of type 'int\\\[]' declared as an ordinary array" "warning" { target *-*-* } .-1 } + +void call_f2 (int *p) +{ + f2 (-1, p, 0); + + /* Verify that the attribute access on the redeclaration of f2() takes + precedence over the one on the first declaration. */ + f2 (0, p, -1); + // { dg-warning "argument 3 value -1 is negative" "warning" { target *-*-* } .-1 } +} diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-8.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-8.c new file mode 100644 index 0000000000..69e10f7006 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-8.c @@ -0,0 +1,86 @@ +/* PR c/97413 - bogus error on function declaration with many VLA arguments: + wrong number of arguments specified for 'access' attribute + { dg-do compile } + { dg-options "-Wall" } */ + +extern int n; + +void f1 (int[n]); +void f2 (int[n], int[n]); +void f3 (int[n], int[n], int[n]); +void f4 (int[n], int[n], int[n], int[n]); +void f5 (int[n], int[n], int[n], int[n], int[n]); +void f6 (int[n], int[n], int[n], int[n], int[n], int[n]); +void f7 (int[n], int[n], int[n], int[n], int[n], int[n], int[n]); +void f8 (int[n], int[n], int[n], int[n], int[n], int[n], int[n], int[n]); +void f9 (int[n], int[n], int[n], int[n], int[n], int[n], int[n], int[n], + int[n]); +void f10 (int[n], int[n], int[n], int[n], int[n], int[n], int[n], int[n], + int[n], int[n]); + + +void f1 (int[n]); +void f2 (int[n], int[n]); +void f3 (int[n], int[n], int[n]); +void f4 (int[n], int[n], int[n], int[n]); +void f5 (int[n], int[n], int[n], int[n], int[n]); +void f6 (int[n], int[n], int[n], int[n], int[n], int[n]); +void f7 (int[n], int[n], int[n], int[n], int[n], int[n], int[n]); +void f8 (int[n], int[n], int[n], int[n], int[n], int[n], int[n], int[n]); +void f9 (int[n], int[n], int[n], int[n], int[n], int[n], int[n], int[n], + int[n]); +void f10 (int[n], int[n], int[n], int[n], int[n], int[n], int[n], int[n], + int[n], int[n]); + + +void g (int n) +{ + typedef int A[n]; + + void g1 (A); + void g2 (A, A); + void g3 (A, A, A); + void g4 (A, A, A, A); + void g5 (A, A, A, A, A); + void g6 (A, A, A, A, A, A); + void g7 (A, A, A, A, A, A, A); + void g8 (A, A, A, A, A, A, A, A); + void g9 (A, A, A, A, A, A, A, A, A); + void g10 (A, A, A, A, A, A, A, A, A, A); + + void g1 (A); + void g2 (A, A); + void g3 (A, A, A); + void g4 (A, A, A, A); + void g5 (A, A, A, A, A); + void g6 (A, A, A, A, A, A); + void g7 (A, A, A, A, A, A, A); + void g8 (A, A, A, A, A, A, A, A); + void g9 (A, A, A, A, A, A, A, A, A); + void g10 (A, A, A, A, A, A, A, A, A, A); + + + typedef int B[n][n + 1][n + 2][n + 3][n + 4][n + 5][n + 7]; + + void h1 (B); + void h2 (B, B); + void h3 (B, B, B); + void h4 (B, B, B, B); + void h5 (B, B, B, B, B); + void h6 (B, B, B, B, B, B); + void h7 (B, B, B, B, B, B, B); + void h8 (B, B, B, B, B, B, B, B); + void h9 (B, B, B, B, B, B, B, B, B); + void h10 (B, B, B, B, B, B, B, B, B, B); + + void h1 (B); + void h2 (B, B); + void h3 (B, B, B); + void h4 (B, B, B, B); + void h5 (B, B, B, B, B); + void h6 (B, B, B, B, B, B); + void h7 (B, B, B, B, B, B, B); + void h8 (B, B, B, B, B, B, B, B); + void h9 (B, B, B, B, B, B, B, B, B); + void h10 (B, B, B, B, B, B, B, B, B, B); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter-9.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-9.c new file mode 100644 index 0000000000..6c8987a34e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter-9.c @@ -0,0 +1,30 @@ +/* PR c/100550 - ICE: in fold_convert_loc with function call VLA argument + { dg-do compile } + { dg-options "-Wall" } */ + +struct S { int i; }; + +extern void v; +extern void *pv; +extern struct S s; +void vf (void); + +/* Verify that a function redeclaration with an invalid VLA doesn't ICE. */ + +void f0 (int[]); +void f0 (int[undeclared]); // { dg-error "undeclared" } + +void f1 (int[]); +void f1 (int[-1]); // { dg-error "size" } + +void f2 (int[]); +void f2 (int[v]); // { dg-error "size" } + +void f3 (int[]); +void f3 (int b[s]); // { dg-error "size" } + +void f4 (int[]); +void f4 (int c[pv]); // { dg-error "size" } + +void f5 (int[]); +void f5 (int d[vf ()]); // { dg-error "size" } diff --git a/SingleSource/Regression/C/gcc-dg/Wvla-parameter.c b/SingleSource/Regression/C/gcc-dg/Wvla-parameter.c new file mode 100644 index 0000000000..6e4df02969 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wvla-parameter.c @@ -0,0 +1,136 @@ +/* PR c/50584 - No warning for passing small array to C99 static array + declarator + Verify the -Wvla-parameter warnings correctly diagnose mismatches + between one-dimensional VLA and non-VLA arguments in redeclarations + of the same function. + Also verify that the array/pointer argument form in a mismatched + redeclaration doesn't override the form in the initial declaration. + { dg-do compile } + { dg-options "-Wall -Wvla-parameter" } */ + +/* Verify that redeclaring an argument as a VLA with an unspecified + bound that was first declared as an ordinary array with an unspecified + bound triggers a warning. */ +void f1ia_x (int[]); // { dg-message "previously declared as an ordinary array 'int\\\[]'" "note" } +void f1ia_x (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } +void f1ia_x (int[]); +void f1ia_x (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } +/* Also verify that a definition of the same form as the first declaration + doesn't trigger a warning and doesn't prevent warnings for subsequent + mismatches. */ +void f1ia_x (int a[]) { (void)&a;} +void f1ia_x (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } + +/* Repeat the above but starting with an ordinary array with a constant + bound. */ +void f1ia1x (int[1]); // { dg-message "previously declared as an ordinary array 'int\\\[1]'" "note" } +void f1ia1x (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } +void f1ia1x (int a[1]) { (void)&a; } +void f1ia1x (int[1]); +void f1ia1x (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } + +void f1ipx (int*); // { dg-message "previously declared as a pointer 'int ?\\\*'" "note" } +void f1ipx (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } +void f1ipx (int*); +void f1ipx (int *p) { (void)&p; } +void f1ipx (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } +void f1ipx (int*); + +void f2ipx (int*, int*); // { dg-message "previously declared as a pointer 'int ?\\\*'" "note" } +void f2ipx (int*, int[*]); // { dg-warning "argument 2 of type 'int\\\[\\\*]' declared as a variable length array" } +void f2ipx (int*, int*); +void f2ipx (int*, int[*]); // { dg-warning "argument 2 of type 'int\\\[\\\*]' declared as a variable length array" } +void f2ipx (int *p, int *q) { (void)&p; (void)&q; } +void f2ipx (int*, int[*]); // { dg-warning "argument 2 of type 'int\\\[\\\*]' declared as a variable length array" } + +void f1ias2x (int[static 2]); // { dg-message "previously declared as an ordinary array 'int\\\[static 2]'" } +void f1ias2x (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } +void f1ias2x (int[static 2]); +void f1ias2x (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } +void f1ias2x (int a[static 2]) { (void)&a; } +void f1ias2x (int[*]); // { dg-warning "argument 1 of type 'int\\\[\\\*]' declared as a variable length array" } +void f1ias2x (int[static 2]); + +extern int nelts; + +void f1sa_var (short[]); // { dg-message "previously declared as an ordinary array 'short int\\\[]'" } +void f1sa_var (short[nelts]); // { dg-warning "argument 1 of type 'short int\\\[nelts]' declared as a variable length array" } +void f1sa_var (short[]); +void f1sa_var (short[nelts]); // { dg-warning "argument 1 of type 'short int\\\[nelts]' declared as a variable length array" } +void f1sa_var (short a[]) { (void)&a; } +void f1sa_var (short[nelts]); // { dg-warning "argument 1 of type 'short int\\\[nelts]' declared as a variable length array" } +void f1sa_var (short[]); + +void f1sa_expr (int[]); // { dg-message "previously declared as an ordinary array 'int\\\[]'" } +void f1sa_expr (int[nelts + 1]); // { dg-warning "argument 1 of type 'int\\\[nelts \\\+ 1]' declared as a variable length array" } +void f1sa_expr (int[]); +void f1sa_expr (int[nelts * 2]); // { dg-warning "argument 1 of type 'int\\\[nelts \\\* 2]' declared as a variable length array" } +void f1sa_expr (int a[]) { (void)&a; } +void f1sa_expr (int[nelts / 3]); // { dg-warning "argument 1 of type 'int\\\[nelts / 3]' declared as a variable length array" } +void f1sa_expr (int[]); + +extern int f (int); + +void f1ia_f (int[]); // { dg-message "previously declared as an ordinary array 'int\\\[]'" } +void f1ia_f (int[f (1)]); // { dg-warning "argument 1 of type 'int\\\[f *\\\(1\\\)]' declared as a variable length array" } +void f1ia_f (int[]); +void f1ia_f (int[f (2)]); // { dg-warning "argument 1 of type 'int\\\[f *\\\(2\\\)]' declared as a variable length array" } +void f1ia_f (int a[]) { (void)&a; } +void f1ia_f (int[f (3)]); // { dg-warning "argument 1 of type 'int\\\[f *\\\(3\\\)]' declared as a variable length array" } +void f1ia_f (int[f (4)]); // { dg-warning "argument 1 of type 'int\\\[f *\\\(4\\\)]' declared as a variable length array" } +void f1ia_f (int[]); + +void f1iaf0_f1 (int[f (0)]); // { dg-message "previously declared as 'int\\\[f *\\\(0\\\)]'" } +void f1iaf0_f1 (int[f (1)]); // { dg-warning "argument 1 of type 'int\\\[f *\\\(1\\\)]' declared with mismatched bound" } +void f1iaf0_f1 (int[f (0)]); +void f1iaf0_f1 (int[f (1)]); // { dg-warning "argument 1 of type 'int\\\[f *\\\(1\\\)]' declared with mismatched bound" } +void f1iaf0_f1 (int a[f (0)]) { (void)&a; } +void f1iaf0_f1 (int[f (1)]); // { dg-warning "argument 1 of type 'int\\\[f *\\\(1\\\)]' declared with mismatched bound" } +void f1iaf0_f1 (int[f (0)]); + +void f1la_ (long[]); // { dg-message "previously declared as an ordinary array 'long int\\\[]'" } +void f1la_ (long[nelts]); // { dg-warning "argument 1 of type 'long int\\\[nelts]' declared as a variable length array" } +void f1la_ (long[]); +void f1la_ (long a[nelts]) // { dg-warning "argument 1 of type 'long int\\\[nelts]' declared as a variable length array" } +{ (void)&a; } +void f1la_ (long[]); + +void f2ca_ (int, char[]); // { dg-message "previously declared as an ordinary array 'char\\\[]'" } +void f2ca_ (int n, char[n]); // { dg-warning "argument 2 of type 'char\\\[n]' declared as a variable length array" } +void f2ca_ (int, char[]); +void f2ca_ (int n, char a[n]) // { dg-warning "argument 2 of type 'char\\\[n]' declared as a variable length array" } +{ (void)&n; (void)&a; } + +void f2ia1_f (int n, int[n]); // { dg-message "previously declared as 'int\\\[n]' with bound argument 1" } +void f2ia1_f (int, int[f (0)]); // { dg-warning "argument 2 of type 'int\\\[f *\\\(0\\\)]' declared with mismatched bound 'f *\\\(0\\\)'" } +void f2ia1_f (int m, int[m]); +void f2ia1_f (int, int[f (1)]); // { dg-warning "argument 2 of type 'int\\\[f *\\\(1\\\)]' declared with mismatched bound 'f *\\\(1\\\)'" } +void f2ia1_f (int x, int a[x]) { (void)&x; (void)&a; } +void f2ia1_f (int, int[f (2)]); // { dg-warning "argument 2 of type 'int\\\[f *\\\(2\\\)]' declared with mismatched bound 'f *\\\(2\\\)'" } +void f2ia1_f (int y, int[y]); + +void f2iaf_1 (int, int[f (0)]); // { dg-message "previously declared as 'int\\\[f *\\\(0\\\)]'" } +void f2iaf_1 (int n, int[n]); // { dg-warning "argument 2 of type 'int\\\[n]' declared with mismatched bound argument 1" } +void f2iaf_1 (int, int[f (0)]); +void f2iaf_1 (int m, int[m]); // { dg-warning "argument 2 of type 'int\\\[m]' declared with mismatched bound argument 1" } +void f2iaf_1 (int x, int a[f (0)]) { (void)&x; (void)&a; } +void f2iaf_1 (int y, int[y]); // { dg-warning "argument 2 of type 'int\\\[y]' declared with mismatched bound argument 1" } + + +void f3ia1 (int n, int, int[n]); // { dg-message "previously declared as 'int\\\[n]' with bound argument 1" } +void f3ia1 (int, int n, int[n]); // { dg-warning "argument 3 of type 'int\\\[n]' declared with mismatched bound argument 2" } +void f3ia1 (int n, int, int[n]); + + +extern int g (int); + +void f1iaf_g (int[f (1)]); // { dg-message "previously declared as 'int\\\[f *\\\(1\\\)]'" } +void f1iaf_g (int[g (1)]); // { dg-warning "argument 1 of type 'int\\\[g *\\\(1\\\)]' declared with mismatched bound" } +void f1iaf_g (int[f (1)]); + + +void nrf1iaf_g (int[f (1)]); // { dg-message "previously declared as 'int\\\[f *\\\(1\\\)]'" } +__attribute__ ((nonnull)) +void nrf1iaf_g (int[g (1)]); // { dg-warning "argument 1 of type 'int\\\[g *\\\(1\\\)]' declared with mismatched bound" } +__attribute__ ((noreturn)) +void nrf1iaf_g (int[f (1)]); diff --git a/SingleSource/Regression/C/gcc-dg/Wwrite-strings-1.c b/SingleSource/Regression/C/gcc-dg/Wwrite-strings-1.c new file mode 100644 index 0000000000..24547d02bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wwrite-strings-1.c @@ -0,0 +1,8 @@ +/* Test pointer initialization and dereference don't lose qualifiers + on array types. This test wrongly failed to diagnose the loss of + const. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wwrite-strings" } */ +typedef char T[1]; +T *p = &""; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/Wxor-used-as-pow-pr106830.c b/SingleSource/Regression/C/gcc-dg/Wxor-used-as-pow-pr106830.c new file mode 100644 index 0000000000..104897a5f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wxor-used-as-pow-pr106830.c @@ -0,0 +1,6 @@ +/* { dg-require-effective-target int128 } + { dg-options "-Wno-pedantic" } */ + +void foo0_u16_0() { + (__int128)(18302628885633695743 << 4) ^ 0; /* { dg-warning "integer constant is so large that it is unsigned" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-2-novec.c b/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-2-novec.c new file mode 100644 index 0000000000..8e023b7cfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-2-novec.c @@ -0,0 +1,45 @@ +/* Test to verify that -Wzero-length-bounds and not -Warray-bounds is + issued for accesses to interior zero-length array members that are + within the bounds of the enclosing struct. + { dg-do compile } + { dg-options "-O2 -Wall -fno-tree-vectorize" } */ + +void sink (void*); + +struct A { int i; }; +struct B { int j; struct A a[0]; }; + +struct C +{ + struct B b1; + struct B b2; +}; + +char cbuf1[1 * sizeof (struct C)]; +char cbuf2[2 * sizeof (struct C)] = { }; + +void test_C_global_buf (void) +{ + struct C *p = (struct C*)&cbuf1; + + p->b1.a[-1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b1.a[ 0].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + p->b1.a[ 1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + sink (p); + + p->b2.a[ 0].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b2.a[ 1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + sink (p); + + p = (struct C*)&cbuf2; + p->b1.a[-1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b1.a[ 0].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + p->b1.a[ 1].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + sink (p); + + p->b2.a[ 0].i = 0; + p->b2.a[ 1].i = 0; + p->b2.a[ 2].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b2.a[ 3].i = 0; // { dg-warning "\\\[-Warray-bounds" } + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-2.c b/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-2.c new file mode 100644 index 0000000000..19932d05a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-2.c @@ -0,0 +1,132 @@ +/* Test to verify that -Wzero-length-bounds and not -Warray-bounds is + issued for accesses to interior zero-length array members that are + within the bounds of the enclosing struct. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +/* pr102706: disabled warnings because the now-disabled conditions for the + bogus warnings to come up do not take cost analysis into account, and often + come up wrong. */ +/* { dg-additional-options "-Wno-stringop-overflow" } */ + +void sink (void*); + +struct A { int i; }; +struct B { int j; struct A a[0]; }; + +struct C +{ + struct B b1; + struct B b2; +}; + + +void test_B_ref (struct B *p) +{ + // References with negative indices are always diagnosed by -Warray-bounds + // even though they could be considered the same as past the end accesses + // to trailing zero-length arrays. + p->a[-1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->a[ 0].i = 0; + p->a[ 1].i = 0; + sink (p); + + p[1].a[-1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p[1].a[ 0].i = 0; + p[1].a[ 1].i = 0; +} + + +void test_C_ref (struct C *p) +{ + p->b1.a[-1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b1.a[ 0].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + p->b1.a[ 1].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + + // Accesses to trailing zero-length arrays are not diagnosed (should + // they be?) + p->b2.a[ 0].i = 0; + p->b2.a[ 9].i = 0; +} + + +void test_C_decl (void) +{ + struct C c, *p = &c; + + p->b1.a[-1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + + // c.b1.a[0].i overlaps c.b2.j. + p->b1.a[ 0].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + + // c.b1.a[1].i is past the end of c... + p->b1.a[ 1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + sink (p); + + // ...and so are references to all elements of c.b2.a + p->b2.a[ 0].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b2.a[ 1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + sink (p); +} + + +char cbuf1[1 * sizeof (struct C)]; +char cbuf2[2 * sizeof (struct C)] = { }; + +void test_C_global_buf (void) +{ + struct C *p = (struct C*)&cbuf1; + + p->b1.a[-1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b1.a[ 0].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + p->b1.a[ 1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + sink (p); + + p->b2.a[ 0].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b2.a[ 1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + sink (p); + + p = (struct C*)&cbuf2; + p->b1.a[-1].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b1.a[ 0].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + p->b1.a[ 1].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + sink (p); + + p->b2.a[ 0].i = 0; // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" } + // { xfail { vect_slp_v2si_store_align && { ! vect_slp_v4si_store_unalign } } } + p->b2.a[ 1].i = 0; + p->b2.a[ 2].i = 0; // { dg-warning "\\\[-Warray-bounds" } + p->b2.a[ 3].i = 0; // { dg-warning "\\\[-Warray-bounds" } + sink (p); +} + + +void test_C_local_buf (void) +{ + char cbuf1[1 * sizeof (struct C)] = ""; + char cbuf2[2 * sizeof (struct C)] = { }; + + struct C *p = (struct C*)&cbuf1; + + p->b1.a[-1].i = 1; // { dg-warning "\\\[-Warray-bounds" } + p->b1.a[ 0].i = 2; // { dg-warning "\\\[-Wzero-length-bounds" } + p->b1.a[ 1].i = 3; // { dg-warning "\\\[-Warray-bounds" } + sink (p); + + p->b2.a[ 0].i = 4; // { dg-warning "\\\[-Warray-bounds" } + p->b2.a[ 1].i = 5; // { dg-warning "\\\[-Warray-bounds" } + sink (p); + + p = (struct C*)&cbuf2; + p->b1.a[-1].i = 6; // { dg-warning "\\\[-Warray-bounds" } + p->b1.a[ 0].i = 7; // { dg-warning "\\\[-Wzero-length-bounds" } + p->b1.a[ 1].i = 8; // { dg-warning "\\\[-Wzero-length-bounds" } + sink (p); + + p->b2.a[ 0].i = 9; // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" } + // { xfail { vect_slp_v2si_store_align && { ! vect_slp_v4si_store_unalign } } } + p->b2.a[ 1].i = 10; + p->b2.a[ 2].i = 11; // { dg-warning "\\\[-Warray-bounds" } + p->b2.a[ 3].i = 12; // { dg-warning "\\\[-Warray-bounds" } + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-3.c b/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-3.c new file mode 100644 index 0000000000..9292d182e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds-3.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/109215 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct S {}; +struct T { struct S s[3]; struct S t; }; +void foo (struct S *); + +void +bar (struct T *t) +{ + foo (&t->s[2]); /* { dg-bogus "array subscript 2 is outside the bounds of an interior zero-length array" } */ +} + +void +baz (struct T *t) +{ + foo (&t->s[3]); /* { dg-error "" "" { xfail *-*-* } } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds.c b/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds.c new file mode 100644 index 0000000000..8e880d92de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/Wzero-length-array-bounds.c @@ -0,0 +1,88 @@ +/* PR middle-end/91647 - missing -Warray-bounds accessing a zero-length array + of a declared object + Test to exercise -Wzero-length-bounds. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void sink (void*); + +struct X { int a[0]; int b, c; }; + +extern struct X x; + +void bad (int i, int j) +{ + x.a[0] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + x.a[1] = 1; // { dg-warning "\\\[-Wzero-length-bounds" } + x.a[2] = 2; // { dg-warning "\\\[-Warray-bounds" } + + x.a[i] = 3; // { dg-warning "\\\[-Wzero-length-bounds" } + x.a[j] = 4; // { dg-warning "array subscript 'j' is outside the bounds of an interior zero-length array" } +} + +void access_by_reference (struct X *p, int i) +{ + p->a[0] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + p->a[1] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + p->a[2] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + p->a[i] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } +} + + +extern struct X a[2]; + +void access_to_array (int i) +{ + a[0].a[0] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + a[0].a[1] = 1; // { dg-warning "\\\[-Wzero-length-bounds" } + /* Accesses to a subsequent element of the enclosing array seem like + a more sever problem than those to the next member of the same + struct and so might perhaps be better diagnosed by -Warray-bounds. + Then again, code that does this sort of crap might as well get what + it deserves if it disables -Wzero-length-bounds. */ + a[0].a[2] = 2; // { dg-warning "\\\[-Wzero-length-bounds" } + + a[0].a[i] = 3; // { dg-warning "\\\[-Wzero-length-bounds" } + sink (a); + + a[1].a[0] = 4; // { dg-warning "\\\[-Wzero-length-bounds" } + a[1].a[1] = 5; // { dg-warning "\\\[-Wzero-length-bounds" } + a[1].a[2] = 6; // { dg-warning "\\\[-Warray-bounds" } + + a[1].a[i] = 7; // { dg-warning "\\\[-Wzero-length-bounds" } + sink (a); + + a[i].a[0] = 8; // { dg-warning "\\\[-Wzero-length-bounds" } + a[i].a[1] = 9; // { dg-warning "\\\[-Wzero-length-bounds" } + a[i].a[2] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } +} + + +struct Y +{ + struct X a[2], b; + int c; +}; + +extern struct Y y; + +void access_to_member (int i) +{ + y.a[0].a[0] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + y.a[0].a[1] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + y.a[0].a[2] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + sink (a); + + y.a[1].a[0] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + y.a[1].a[1] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + /* Similar to the array case above, accesses to a subsequent member + of the "parent" struct seem like a more severe problem than those + to the next member of the same struct. */ + y.a[1].a[2] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + sink (a); + + y.b.a[0] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + y.b.a[1] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + y.b.a[2] = 0; // { dg-warning "\\\[-Wzero-length-bounds" } + y.b.a[3] = 0; // { dg-warning "\\\[-Warray-bounds" } +} diff --git a/SingleSource/Regression/C/gcc-dg/absu.c b/SingleSource/Regression/C/gcc-dg/absu.c new file mode 100644 index 0000000000..e2428cdbc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/absu.c @@ -0,0 +1,45 @@ + +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +#include +#define ABS(x) (((x) >= 0) ? (x) : -(x)) + +#define DEF_TEST(TYPE) \ +void foo_##TYPE (signed TYPE x, unsigned TYPE y){ \ + TYPE t = ABS (x); \ + if (t != y) \ + __builtin_abort (); \ +} \ + +DEF_TEST (char); +DEF_TEST (short); +DEF_TEST (int); +DEF_TEST (long); + +int main () +{ + foo_char (SCHAR_MIN + 1, SCHAR_MAX); + foo_char (0, 0); + foo_char (-1, 1); + foo_char (1, 1); + foo_char (SCHAR_MAX, SCHAR_MAX); + + foo_int (-1, 1); + foo_int (0, 0); + foo_int (INT_MAX, INT_MAX); + foo_int (INT_MIN + 1, INT_MAX); + + foo_short (-1, 1); + foo_short (0, 0); + foo_short (SHRT_MAX, SHRT_MAX); + foo_short (SHRT_MIN + 1, SHRT_MAX); + + foo_long (-1, 1); + foo_long (0, 0); + foo_long (LONG_MAX, LONG_MAX); + foo_long (LONG_MIN + 1, LONG_MAX); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/add-mul-overflow-1.c b/SingleSource/Regression/C/gcc-dg/add-mul-overflow-1.c new file mode 100644 index 0000000000..b23cdddbb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/add-mul-overflow-1.c @@ -0,0 +1,28 @@ +/* { dg-options "-O -fdump-tree-optimized" } */ + +int res[4]; + +void +f1 (int x, int y) +{ + res[2] = __builtin_add_overflow (x, y, res + 0); + res[3] = __builtin_add_overflow (y, x, res + 1); +} + +void +f2 (int x, int y) +{ + res[2] = __builtin_sub_overflow (x, y, res + 0); + res[3] = __builtin_sub_overflow (y, x, res + 1); +} + +void +f3 (int x, int y) +{ + res[2] = __builtin_mul_overflow (x, y, res + 0); + res[3] = __builtin_mul_overflow (y, x, res + 1); +} + +/* { dg-final { scan-tree-dump-times {\.ADD_OVERFLOW} 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times {\.SUB_OVERFLOW} 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times {\.MUL_OVERFLOW} 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/addr_builtin-1.c b/SingleSource/Regression/C/gcc-dg/addr_builtin-1.c new file mode 100644 index 0000000000..4a0888a55d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/addr_builtin-1.c @@ -0,0 +1,198 @@ +/* PR66516 - missing diagnostic on taking the address of a builtin function + { dg-do compile } */ + +typedef void (F)(void); +typedef __UINTPTR_TYPE__ uintptr_t; + +/* Utility function to test passing built-in functions as an ordinary + argument and via the ellipsis. */ +static void func_arg (F *p, ...) { (void)p; } + +static F* test_taking_address_of_gcc_builtin (void) +{ + F *p; + void *q; + uintptr_t a; + + /* Call, cast to void, and id are allowed. */ + __builtin_trap (); + (void)__builtin_trap; + __builtin_trap; + + { + typedef __typeof__ (__builtin_trap) F; /* Okay. */ + } + + /* Address and indirection operators. */ + p = &__builtin_trap; /* { dg-error "built-in function" } */ + p = *__builtin_trap; /* { dg-error "built-in function" } */ + + /* Unary NOT. */ + a = !__builtin_trap; /* { dg-error "built-in function" } */ + + /* Sizeof and _Alignof are disallowed by C but allowed by GCC + and there's no reason to reject built-ins as operands since + doing so doesn't yield their address. */ +#pragma GCC diagnostic push + /* Disable: invalid application of 'sizeof' to a function type. */ +#pragma GCC diagnostic ignored "-Wpointer-arith" + a = sizeof __builtin_trap; +#pragma GCC diagnostic pop + +#ifndef __STDC_VERSION__ +# pragma GCC diagnostic push + /* Disable: ISO C90 does not support '_Alignof'. */ +# pragma GCC diagnostic ignored "-Wpedantic" +#endif + + a = _Alignof __builtin_trap; + +#ifndef __STDC_VERSION__ +# pragma GCC diagnostic pop +#endif + + /* Casts. */ + p = (F*)__builtin_trap; /* { dg-error "built-in function" } */ + a = (uintptr_t)__builtin_trap; /* { dg-error "built-in function" } */ + + /* Additive operator. */ + p = __builtin_trap + 0; /* { dg-error "built-in function" } */ + p = __builtin_trap - 0; /* { dg-error "built-in function" } */ + a = __builtin_trap - p; /* { dg-error "built-in function" } */ + a = p - __builtin_trap; /* { dg-error "built-in function" } */ + + /* Relational operators. */ + a = __builtin_trap < p; /* { dg-error "built-in function" } */ + a = p < __builtin_trap; /* { dg-error "built-in function" } */ + + a = __builtin_trap <= p; /* { dg-error "built-in function" } */ + a = p <= __builtin_trap; /* { dg-error "built-in function" } */ + + a = __builtin_trap > p; /* { dg-error "built-in function" } */ + a = p > __builtin_trap; /* { dg-error "built-in function" } */ + + a = __builtin_trap > p; /* { dg-error "built-in function" } */ + a = p > __builtin_trap; /* { dg-error "built-in function" } */ + + a = __builtin_trap <= p; /* { dg-error "built-in function" } */ + a = p <= __builtin_trap; /* { dg-error "built-in function" } */ + + a = __builtin_trap <= p; /* { dg-error "built-in function" } */ + a = p <= __builtin_trap; /* { dg-error "built-in function" } */ + + /* Equality operators. */ + a = __builtin_trap == p; /* { dg-error "built-in function" } */ + a = p == __builtin_trap; /* { dg-error "built-in function" } */ + a = __builtin_trap != p; /* { dg-error "built-in function" } */ + a = p != __builtin_trap; /* { dg-error "built-in function" } */ + + /* Logical AND and OR. */ + a = __builtin_trap && p; /* { dg-error "built-in function" } */ + a = p && __builtin_trap; /* { dg-error "built-in function" } */ + + a = __builtin_trap || p; /* { dg-error "built-in function" } */ + a = p || __builtin_trap; /* { dg-error "built-in function" } */ + + /* Conditional operator. */ + a = __builtin_trap ? 1 : 0; /* { dg-error "built-in function" } */ + p = a ? __builtin_trap : 0; /* { dg-error "built-in function" } */ + p = a ? 0 : __builtin_trap; /* { dg-error "built-in function" } */ + + /* Assignment operator. */ + p = __builtin_trap; /* { dg-error "built-in function" } */ + + q = __builtin_trap; /* { dg-error "built-in function" } */ + a = __builtin_trap; /* { dg-error "built-in function" } */ + + /* Passing as an argument. */ + func_arg (__builtin_trap); /* { dg-error "built-in function" } */ + + /* Passing through the ellipsis. */ + func_arg (0, __builtin_trap); /* { dg-error "built-in function" } */ + + /* Return statement. */ + return __builtin_trap; /* { dg-error "built-in function" } */ + + (void)a; + (void)p; + (void)q; +} + +/* Helper declarations to verify that it's possible to take the address + of a user-declared function that's also a GCC built-in. */ +extern int abs (int); + +extern __SIZE_TYPE__ strlen (const char*); + +/* Taking the address of a builtin with a library "fallback" must be + allowed, either using the __builtin_xxx form or the xxx form, when + the library fallback is declared either explicitly or implicitly + by virtue of first calling the function. */ +void test_taking_address_of_library_builtin (int i) +{ + { + typedef int F (int); + + /* Compute the address of libc's abs using the implicitly declared + __builtin_abs form (all expressions are valid). */ + F *p = __builtin_abs; + p = &__builtin_abs; + p = *__builtin_abs; + + /* Compute the address of libc's abs declared above. */ + p = abs; + p = &abs; + p = *abs; + (void)p; + } + + { + typedef __SIZE_TYPE__ size_t; + typedef size_t F (const char*); + + /* Compute the address of libc's strlen using the implicitly + declared __builtin_strlen form. */ + F *p = __builtin_strlen; + p = &__builtin_strlen; + p = *__builtin_strlen; + + /* Compute the address of libc's strlen declared above. */ + p = strlen; + p = &strlen; + p = *strlen; + (void)p; + } + + { + typedef int F (int); + + /* Compute the address of libc's isxxx functions using the implicitly + declared __builtin_xxx form. */ + F *p = __builtin_isalnum; + p = &__builtin_isalpha; + p = *__builtin_iscntrl; + + /* According to C90 (see also the discussion in c/67386): + If the expression that precedes the parenthesized argument list + in a function call consists solely of an identifier, and if no + declaration is visible for this identifier, the identifier is + implicitly declared exactly as if, in the innermost block + containing the function call, the declaration + extern int identifier(); + appeared. */ + + /* Call the functions first to have their declarations "injected" + into the enclosing block. Suppress warnings. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wimplicit-function-declaration" + i = isalnum (i) || isalpha (i) || iscntrl (i); +#pragma GCC diagnostic pop + + /* Take the address of the functions relying on their declarations + having been implicitly provided by the calls above. */ + p = isalnum; + p = &isalpha; + p = *iscntrl; + (void)p; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/addr_equal-1.c b/SingleSource/Regression/C/gcc-dg/addr_equal-1.c new file mode 100644 index 0000000000..db65dea4a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/addr_equal-1.c @@ -0,0 +1,102 @@ +/* { dg-do run { target { { nonpic || pie_enabled } && weak_undefined } } } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2 -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "function pointers can be NULL" { keeps_null_pointer_checks } } */ +/* { dg-add-options weak_undefined } */ +void abort (void); +extern int undef_var0, undef_var1; +extern __attribute__ ((weak)) int weak_undef_var0; +extern __attribute__ ((weak)) int weak_undef_var1; +__attribute__ ((weak)) int weak_def_var0; +int def_var0=0, def_var1=0; +static int alias_var0 __attribute__ ((alias("def_var0"))); +extern int weak_alias_var0 __attribute__ ((alias("def_var0"))) __attribute__ ((weak)); +void undef_fn0(void); +void undef_fn1(void); +void def_fn0(void) +{ +} +void def_fn1(void) +{ +} +__attribute__ ((weak)) +void weak_def_fn0(void) +{ +} +__attribute__ ((weak)) +void weak_def_fn1(void) +{ +} +__attribute__ ((weak)) void weak_undef_fn0(void); + +inline +void inline_fn0(void) +{ +} +inline +void inline_fn1(void) +{ +} + +int +main(int argc, char **argv) +{ + /* Two definitions are always different unless they can be interposed. */ + if (!__builtin_constant_p (def_fn0 == def_fn1)) + abort(); + if (def_fn0 == def_fn1) + abort(); + + if (!__builtin_constant_p (&def_var0 == &def_var1)) + abort(); + if (&def_var0 == &def_var1) + abort(); + + /* Same symbol is the same no matter on interposition. */ + if (!__builtin_constant_p (undef_fn0 != undef_fn0)) + abort (); + if (undef_fn0 != undef_fn0) + abort (); + + /* Do not get confused by same offset. */ + if (!__builtin_constant_p (&undef_var0 + argc != &undef_var0 + argc)) + abort (); + if (&undef_var0 + argc != &undef_var0 + argc) + abort (); + + /* Alias and its target is equivalent unless one of them can be interposed. */ + if (!__builtin_constant_p (&def_var0 != &alias_var0)) + abort (); + if (&def_var0 != &alias_var0 ) + abort (); + + if (__builtin_constant_p (&def_var0 != &weak_alias_var0)) + abort (); + if (&def_var0 != &weak_alias_var0) + abort (); + + /* Weak definitions may be both NULL. */ + if (__builtin_constant_p ((void *)weak_undef_fn0 == (void *)&weak_undef_var0)) + abort (); + if ((void *)weak_undef_fn0 != (void *)&weak_undef_var0) + abort (); + + /* Variables and functions do not share same memory locations otherwise. */ + if (!__builtin_constant_p ((void *)undef_fn0 == (void *)&undef_var0)) + abort (); + if ((void *)undef_fn0 == (void *)&undef_var0) + abort (); + + /* This works for cases where one object is just weakly defined, too. */ + if (!__builtin_constant_p ((void *)weak_undef_fn0 == (void *)&weak_def_var0)) + abort (); + if ((void *)weak_undef_fn0 == (void *)&weak_def_var0) + abort (); + + /* Inline functions are known to be different. */ + if (!__builtin_constant_p (inline_fn0 != inline_fn1)) + abort (); + if (inline_fn0 == inline_fn1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-1.c b/SingleSource/Regression/C/gcc-dg/alias-1.c new file mode 100644 index 0000000000..17fb1f7ded --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-1.c @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-Wstrict-aliasing=2 -fstrict-aliasing" } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Sep 2002 + +// 8083. warn about odd casts + +typedef int YYSTYPE; +typedef struct tDefEntry +{ + unsigned t; + +} tDefEntry; +struct incomplete; + + +YYSTYPE + addSibMacro( + YYSTYPE list ) + { + tDefEntry** ppT = (tDefEntry**)&list; // { dg-warning "type-punned pointer will" } + + struct incomplete *p = (struct incomplete *)&list; // { dg-warning "type-punning to incomplete" } + + return list; + } + diff --git a/SingleSource/Regression/C/gcc-dg/alias-10.c b/SingleSource/Regression/C/gcc-dg/alias-10.c new file mode 100644 index 0000000000..8472d30a6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-10.c @@ -0,0 +1,31 @@ +/* For PR tree-optimization/14784 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */ + +typedef struct bitmap_element_def +{ + unsigned int indx; +} bitmap_element; + +typedef struct bitmap_head_def { + bitmap_element *first; + int using_obstack; +} bitmap_head; +typedef struct bitmap_head_def *bitmap; + +bitmap_element *bitmap_free; + +void foo (bitmap head, bitmap_element *elt) +{ + while (1) + { + /* Alias analysis problems used to prevent us from recognizing + that this condition is invariant. */ + if (head->using_obstack) + bitmap_free = elt; + } +} + + +/* { dg-final { scan-tree-dump-times "unswitching" 1 "unswitch"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/alias-11.c b/SingleSource/Regression/C/gcc-dg/alias-11.c new file mode 100644 index 0000000000..7629c6c7d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-11.c @@ -0,0 +1,111 @@ +/* { dg-do run } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2" } */ + +#include +#include +#include + +typedef struct dw_cfi_struct +{ + struct dw_cfi_struct *dw_cfi_next; + const char *dw_cfi_addr; +} +dw_cfi_node; + +typedef struct dw_fde_struct +{ + const char *dw_fde_current_label; + dw_cfi_node *dw_fde_cfi; +} +dw_fde_node; + +dw_cfi_node *cie_cfi_head; +unsigned fde_table_in_use; +dw_fde_node *fde_table; + +static __inline__ void +add_cfi (dw_cfi_node **list_head, dw_cfi_node *cfi) +{ + dw_cfi_node **p; + + for (p = list_head; (*p) != ((void *)0); p = &(*p)->dw_cfi_next) + ; + + *p = cfi; +} + +static __inline__ struct dw_cfi_struct * +new_cfi (void) +{ + dw_cfi_node *cfi = (dw_cfi_node *) malloc (sizeof (dw_cfi_node)); + + memset (cfi, 0, sizeof (dw_cfi_node)); + return cfi; +} + +char * +dwarf2out_cfi_label (void) +{ + static char label[20]; + static unsigned long label_num = 0; + + sprintf (label, "*.%s%u", "LCFI", (unsigned) (label_num++)); + return label; +} + +void +add_fde_cfi (const char *label, dw_cfi_node *cfi) +{ + if (label) + { + dw_fde_node *fde = fde_table + fde_table_in_use - 1; + + if (*label == 0) + label = dwarf2out_cfi_label (); + + if (fde->dw_fde_current_label == ((void *)0) + || strcmp (label, fde->dw_fde_current_label)) + { + dw_cfi_node *xcfi; + + fde->dw_fde_current_label = label = strdup (label); + + xcfi = new_cfi (); + xcfi->dw_cfi_addr = label; + add_cfi (&fde->dw_fde_cfi, xcfi); + } + + add_cfi (&fde->dw_fde_cfi, cfi); + } + else + add_cfi (&cie_cfi_head, cfi); +} + +int +main () +{ + dw_cfi_node *cfi; + dw_fde_node *fde; + + fde_table_in_use = 1; + fde_table = (dw_fde_node *) realloc (fde_table, + sizeof (dw_fde_node)); + memset (fde_table, 0, sizeof (dw_fde_node)); + cfi = new_cfi (); + add_fde_cfi ("", cfi); + + fde = &fde_table[0]; + cfi = fde->dw_fde_cfi; + + if (cfi == NULL) + abort (); + + if (cfi->dw_cfi_addr == NULL) + abort (); + + if (strcmp ("*.LCFI0", cfi->dw_cfi_addr)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-12.c b/SingleSource/Regression/C/gcc-dg/alias-12.c new file mode 100644 index 0000000000..4d69453f48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-12.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2" } */ +static void f (void) __attribute__((alias("f"))); // { dg-error "part of alias cycle" } + +void g () +{ + f (); +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-13.c b/SingleSource/Regression/C/gcc-dg/alias-13.c new file mode 100644 index 0000000000..85e1f8744b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-13.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2" } */ +static void f (void) __attribute__((alias("g"))); static void g (void) __attribute__((alias("f"))); // { dg-error "part of alias cycle" } + +void h () +{ + f (); +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-14.c b/SingleSource/Regression/C/gcc-dg/alias-14.c new file mode 100644 index 0000000000..24f0d1c116 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-14.c @@ -0,0 +1,70 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +#include +void *a; +int *b; +struct c {void * a;} c; +struct d {short * a;} d; + +int *ip= (int *)(size_t)2; +int **ipp = &ip; + +int +main() +{ + float **ptr; + void **uptr; + int* const* cipp = (int* const*)ipp; + /* as an extension we consider void * universal. Writes to it should alias. */ + asm ("":"=r"(ptr):"0"(&a)); + a=NULL; + *ptr=(float*)(size_t)1; + if (!a) + __builtin_abort (); + a=NULL; + if (*ptr) + __builtin_abort (); + + asm ("":"=r"(uptr):"0"(&b)); + b=NULL; + *uptr=(void*)(size_t)1; + if (!b) + __builtin_abort (); + b=NULL; + if (*uptr) + __builtin_abort (); + + /* Check that we disambiguate int * and char *. */ + asm ("":"=r"(ptr):"0"(&b)); + b=NULL; + *ptr=(float*)(size_t)1; + if (b) + __builtin_abort (); + + /* Again we should make void * in the structure conflict with any pointer. */ + asm ("":"=r"(ptr):"0"(&c)); + c.a=NULL; + *ptr=(float*)(size_t)1; + if (!c.a) + __builtin_abort (); + c.a=NULL; + if (*ptr) + __builtin_abort (); + + asm ("":"=r"(uptr):"0"(&d)); + d.a=NULL; + *uptr=(void*)(size_t)1; + if (!d.a) + __builtin_abort (); + d.a=NULL; + if (*uptr) + __builtin_abort (); + + if ((void *)*cipp != (void*)(size_t)2) + __builtin_abort (); + *ipp = NULL; + if (*cipp) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-15.c b/SingleSource/Regression/C/gcc-dg/alias-15.c new file mode 100644 index 0000000000..304ad1fbae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-15.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -fcommon -fdump-ipa-cgraph" } */ + +/* RTL-level CSE shouldn't introduce LCO (for the string) into varpool */ +char *p; + +void foo () +{ + p = "abc\n"; + + while (*p != '\n') + p++; +} + +/* { dg-final { scan-ipa-dump-not "LC0" "cgraph" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/alias-16.c b/SingleSource/Regression/C/gcc-dg/alias-16.c new file mode 100644 index 0000000000..8f5aa35281 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-16.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-Wstrict-aliasing=1 -fstrict-aliasing" } */ + +struct incomplete; +struct s1 { int i; }; +struct s2 { double d; }; + +void +f (int *i, double *d, struct s1 *s1, struct s2 *s2, char *c) +{ + (char *) i; + (char *) d; + (char *) s1; + (char *) s2; + (char *) c; + + (int *) i; + (int *) d; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (int *) s1; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (int *) s2; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (int *) c; + + (double *) i; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (double *) d; + (double *) s1; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (double *) s2; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (double *) c; + + (struct incomplete *) i; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct incomplete *) d; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct incomplete *) s1; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct incomplete *) s2; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct incomplete *) c; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + + (struct s1 *) i; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct s1 *) d; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct s1 *) s1; + (struct s1 *) s2; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct s1 *) c; + + (struct s2 *) i; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct s2 *) d; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct s2 *) s1; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ + (struct s2 *) s2; + (struct s2 *) c; +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-2.c b/SingleSource/Regression/C/gcc-dg/alias-2.c new file mode 100644 index 0000000000..ee384066d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-2.c @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-Wstrict-aliasing=2 -fstrict-aliasing" } + +struct foo { + char c; + char d; + short s; + int i; +} bar; + +int +sub1 (long long int foobar) +{ + struct foo *tmp = (struct foo *) &foobar; // { dg-warning "type-punned pointer will" } + return tmp->i; +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-3.c b/SingleSource/Regression/C/gcc-dg/alias-3.c new file mode 100644 index 0000000000..3dc25a91c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-options "" } */ + +extern int foo(); + +int baz () { return foo(); } + +static inline int bar () __attribute__ ((alias ("foo"))); /* { dg-error "aliased to" } */ + +int main () { return bar (); } diff --git a/SingleSource/Regression/C/gcc-dg/alias-4.c b/SingleSource/Regression/C/gcc-dg/alias-4.c new file mode 100644 index 0000000000..0a2633932e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-4.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2 -funit-at-a-time" } */ + +extern int foo(); + +int baz () { return foo(); } + +static inline int bar () __attribute__ ((alias ("foo"))); /* { dg-error "aliased to" } */ + +int main () { return bar (); } diff --git a/SingleSource/Regression/C/gcc-dg/alias-5.c b/SingleSource/Regression/C/gcc-dg/alias-5.c new file mode 100644 index 0000000000..56848c9a41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-5.c @@ -0,0 +1,7 @@ +/* { dg-do link } */ +/* { dg-require-alias "" } */ +/* { dg-options "" } */ + +static inline int foo () { return 0; } +static int bar () __attribute__ ((alias ("foo"))); +int main () { return bar (); } diff --git a/SingleSource/Regression/C/gcc-dg/alias-6.c b/SingleSource/Regression/C/gcc-dg/alias-6.c new file mode 100644 index 0000000000..3ba101aa1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-6.c @@ -0,0 +1,7 @@ +/* { dg-do link } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2 -funit-at-a-time" } */ + +static inline int foo () { return 0; } +static int bar () __attribute__ ((alias ("foo"))); +int main () { return bar (); } diff --git a/SingleSource/Regression/C/gcc-dg/alias-7.c b/SingleSource/Regression/C/gcc-dg/alias-7.c new file mode 100644 index 0000000000..e0c24bd63a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-7.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "weak alias" { powerpc-ibm-aix* } } */ + +extern void abort (void); + +#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) +#define ASMNAME2(prefix, cname) STRING (prefix) cname +#define STRING(x) #x + +int foo __asm__ (ASMNAME ("foo")) __attribute__((nocommon)); +extern __typeof (foo) bar __attribute__ ((weak, alias ("foo"))); + +int +main (void) +{ + if (&foo != &bar || foo || bar) + abort (); + return bar; +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-8.c b/SingleSource/Regression/C/gcc-dg/alias-8.c new file mode 100644 index 0000000000..690f1b62da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-8.c @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-options "-Wstrict-aliasing=2 -fstrict-aliasing" } + +struct s { + char *p; +}; + +void +func(struct s *ptr) +{ + *(void **)&ptr->p = 0; /* { dg-warning "type-punned pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/alias-9.c b/SingleSource/Regression/C/gcc-dg/alias-9.c new file mode 100644 index 0000000000..f8c1003162 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alias-9.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Wstrict-aliasing=2 -O2" } */ + +int a[2]; + +double *foo1(void) +{ + return (double *)a; /* { dg-warning "strict-aliasing" } */ +} + +double *foo2(void) +{ + return (double *)&a[0]; /* { dg-warning "strict-aliasing" } */ +} + +_Complex x; +int *bar(void) +{ + return (int *)&__imag x; /* { dg-warning "strict-aliasing" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/align-1.c b/SingleSource/Regression/C/gcc-dg/align-1.c new file mode 100644 index 0000000000..187eb5271d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/align-1.c @@ -0,0 +1,28 @@ +/* PR java/10145 + Test that requesting an alignment of 1 does not increase the alignment + of a long long field. + + { dg-do run } + { dg-options "" } +*/ + +extern void abort (void); + +struct A +{ + char c; + long long i; +}; + +struct B +{ + char c; + long long i __attribute ((__aligned__ (1))); +}; + +int main () +{ + if (sizeof (struct A) != sizeof (struct B)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/align-2.c b/SingleSource/Regression/C/gcc-dg/align-2.c new file mode 100644 index 0000000000..2001a153ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/align-2.c @@ -0,0 +1,6 @@ +/* PR 17962 */ +/* { dg-do compile { target vect_natural_alignment } } */ +/* { dg-options "" } */ + +typedef float v4 __attribute__((vector_size(sizeof(float)*4))); +extern char compile_time_assert[__alignof__(v4) == sizeof(float)*4 ? 1 : -1]; diff --git a/SingleSource/Regression/C/gcc-dg/align-3.c b/SingleSource/Regression/C/gcc-dg/align-3.c new file mode 100644 index 0000000000..5c97d5ac3c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/align-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-expand" } */ + +typedef struct { char a[2]; } __attribute__((__packed__)) TU2; +unsigned short get16_unaligned(const void *p) { + unsigned short v; + *(TU2 *)(void *)(&v) = *(const TU2 *)p; + return v; +} + +/* { dg-final { scan-rtl-dump "MEM\[^\n\r\]*A8\\\]" "expand" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/alignof.c b/SingleSource/Regression/C/gcc-dg/alignof.c new file mode 100644 index 0000000000..d018b44025 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/alignof.c @@ -0,0 +1,11 @@ +/* PR c/69507 - bogus warning: ISO C does not allow '__alignof__ (expression)' + */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wno-error -Wpedantic" } */ + +extern int e; + +int a[] = { + __alignof__ (e), + _Alignof (e) /* { dg-warning "ISO C does not allow ._Alignof \\(expression\\)." } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/always_inline.c b/SingleSource/Regression/C/gcc-dg/always_inline.c new file mode 100644 index 0000000000..8603bc6e38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/always_inline.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgnu89-inline" } */ +#include +inline __attribute__ ((always_inline)) void +e(int t, ...) /* { dg-error "variable argument lists" } */ +{ + va_list q; + va_start (q, t); +} diff --git a/SingleSource/Regression/C/gcc-dg/always_inline2.c b/SingleSource/Regression/C/gcc-dg/always_inline2.c new file mode 100644 index 0000000000..89b439f4eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/always_inline2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgnu89-inline" } */ +inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not available" } */ +void +q(void) +{ + t(); /* { dg-message "called from here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/always_inline3.c b/SingleSource/Regression/C/gcc-dg/always_inline3.c new file mode 100644 index 0000000000..1bd2b6d57f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/always_inline3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgnu89-inline" } */ +int do_something_evil (void); +inline __attribute__ ((always_inline)) void +q2(void) /* { dg-error "recursive inlining" } */ +{ + if (do_something_evil ()) + return; + q2(); /* { dg-message "called from here" } */ + q2(); /* With -O2 we don't warn here, it is eliminated by tail recursion. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/and-1.c b/SingleSource/Regression/C/gcc-dg/and-1.c new file mode 100644 index 0000000000..bec56fd849 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/and-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "and" { target powerpc*-*-* } } } */ +/* There should be no nand for this testcase (for PPC). */ +/* { dg-final { scan-assembler-not "nand" { target powerpc*-*-* } } } */ + +int f(int y) +{ + return y & ~(y & -y); +} diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-1.c b/SingleSource/Regression/C/gcc-dg/anon-struct-1.c new file mode 100644 index 0000000000..c599fa5669 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-1.c @@ -0,0 +1,56 @@ +/* { dg-options "-std=iso9899:1990 -pedantic" } */ +/* In strict ISO C mode, we don't recognize the anonymous struct/union + extension or any Microsoft extensions. */ + +struct A { char a; }; + +/* MS extension. */ +struct B { + struct A; /* { dg-warning "does not declare anything" } */ + char b; +}; +char testB[sizeof(struct B) == sizeof(struct A) ? 1 : -1]; + +/* MS extension. */ +struct C { + struct D { char d; }; /* { dg-warning "does not declare anything" } */ + char c; +}; +char testC[sizeof(struct C) == sizeof(struct A) ? 1 : -1]; +char testD[sizeof(struct D) == sizeof(struct A) ? 1 : -1]; + +/* GNU extension. */ +struct E { + struct { char z; }; /* { dg-warning "unnamed structs" } */ + char e; +}; + + +/* MS extension. */ +typedef struct A typedef_A; +struct F { + typedef_A; /* { dg-warning "does not declare anything" } */ + char f; +}; +char testF[sizeof(struct F) == sizeof(struct A) ? 1 : -1]; + +/* __extension__ enables GNU C mode for the duration of the declaration. */ +__extension__ struct G { + struct { char z; }; + char g; +}; +char testG[sizeof(struct G) == 2 * sizeof(struct A) ? 1 : -1]; + +struct H { + __extension__ struct { char z; }; + char h; +}; +char testH[sizeof(struct H) == 2 * sizeof(struct A) ? 1 : -1]; + +/* Make sure __extension__ gets turned back off. */ +struct I { + struct { char z; }; /* { dg-warning "unnamed structs" } */ + char i; +}; +char testI[sizeof(struct I) == sizeof(struct E) ? 1 : -1]; + diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-10.c b/SingleSource/Regression/C/gcc-dg/anon-struct-10.c new file mode 100644 index 0000000000..e212317ea3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-10.c @@ -0,0 +1,57 @@ +/* Test for designated initializers for anonymous structures and + unions. PR 10676. */ +/* { dg-do run } */ +/* { dg-options "" } */ + +extern void abort (void); +extern void exit (int); + +struct s +{ + int a; + struct + { + int b; + int c; + }; + union + { + int d; + struct + { + int e; + }; + }; + struct + { + struct + { + struct + { + int f; + }; + }; + }; +}; + +struct s x = + { + .e = 5, + .b = 4, + .a = 3, + .f = 7, + .c = 9 + }; + +int +main (void) +{ + if (x.a != 3 + || x.b != 4 + || x.c != 9 + || x.d != 5 + || x.e != 5 + || x.f != 7) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-11.c b/SingleSource/Regression/C/gcc-dg/anon-struct-11.c new file mode 100644 index 0000000000..c2f85fc24e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-11.c @@ -0,0 +1,111 @@ +/* { dg-do compile } */ + +/* No special options--in particular, turn off the default + -pedantic-errors option. */ +/* { dg-options "" } */ + +/* When not using -fplan9-extensions, we don't support automatic + conversion of pointer types, and we don't support referring to a + typedef name directly. */ + +extern void exit (int); +extern void abort (void); + +struct A { char a; }; + +struct B { + char b; + struct A; /* { dg-warning "does not declare anything" } */ + char c; +}; + +void +f1 (struct A *p) /* { dg-message "expected" } */ +{ + p->a = 1; +} + +void +test1 (void) +{ + struct B b; + struct A *p; + + b.b = 2; + b.c = 3; + f1 (&b); /* { dg-warning "incompatible pointer type" } */ + if (b.a != 1) /* { dg-error "no member" } */ + abort (); + if (b.b != 2 || b.c != 3) + abort (); + p = &b; /* { dg-warning "incompatible pointer type" } */ + if (p->a != 1) + abort (); +} + +typedef struct { char d; } D; + +struct E { + char b; + struct F { char f; }; /* { dg-warning "does not declare anything" } */ + char c; + union { + D; /* { dg-warning "does not declare anything" } */ + }; + char e; +}; + +void +f2 (struct F *p) /* { dg-message "expected" } */ +{ + p->f = 6; +} + +void +f3 (D *p) /* { dg-message "expected" } */ +{ + p->d = 4; +} + +void +f4 (D d) +{ +} + +void +test2 (void) +{ + struct E e; + struct F *pf; + D *pd; + D d; + + e.b = 2; + e.c = 3; + e.e = 5; + f2 (&e); /* { dg-warning "incompatible pointer type" } */ + f3 (&e); /* { dg-warning "incompatible pointer type" } */ + if (e.d != 4) /* { dg-error "no member" } */ + abort (); + if (e.f != 6) /* { dg-error "no member" } */ + abort (); + if (e.b != 2 || e.c != 3 || e.e != 5) + abort (); + pf = &e; /* { dg-warning "incompatible pointer type" } */ + if (pf->f != 6) + abort (); + pd = &e; /* { dg-warning "incompatible pointer type" } */ + if (pd->d != 4) + abort (); + d = e.D; /* { dg-error "no member" } */ + f3 (&e.D); /* { dg-error "no member" } */ + f4 (e.D); /* { dg-error "no member" } */ +} + +int +main () +{ + test1 (); + test2 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-12.c b/SingleSource/Regression/C/gcc-dg/anon-struct-12.c new file mode 100644 index 0000000000..60cd178224 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-12.c @@ -0,0 +1,108 @@ +/* { dg-do run } */ +/* { dg-options "-fplan9-extensions" } */ + +/* When using -fplan9-extensions, we support automatic conversion of + pointer types, and we support referring to a typedef name + directly. */ + +extern void exit (int); +extern void abort (void); + +struct A { char a; }; + +struct B { + char b; + struct A; + char c; +}; + +void +f1 (struct A *p) +{ + p->a = 1; +} + +void +test1 (void) +{ + struct B b; + struct A *p; + + b.b = 2; + b.c = 3; + f1 (&b); + if (b.a != 1) + abort (); + if (b.b != 2 || b.c != 3) + abort (); + p = &b; + if (p->a != 1) + abort (); +} + +typedef struct { char d; } D; + +struct E { + char b; + struct F { char f; }; + char c; + union { + D; + }; + char e; +}; + +void +f2 (struct F *p) +{ + p->f = 6; +} + +void +f3 (D *p) +{ + p->d = 4; +} + +void +f4 (D d) +{ +} + +void +test2 (void) +{ + struct E e; + struct F *pf; + D *pd; + D d; + + e.b = 2; + e.c = 3; + e.e = 5; + f2 (&e); + f3 (&e); + if (e.d != 4) + abort (); + if (e.f != 6) + abort (); + if (e.b != 2 || e.c != 3 || e.e != 5) + abort (); + pf = &e; + if (pf->f != 6) + abort (); + pd = &e; + if (pd->d != 4) + abort (); + d = e.D; + f3 (&e.D); + f4 (e.D); +} + +int +main () +{ + test1 (); + test2 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-13.c b/SingleSource/Regression/C/gcc-dg/anon-struct-13.c new file mode 100644 index 0000000000..6a508141ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-13.c @@ -0,0 +1,76 @@ +/* { dg-do compile } */ +/* { dg-options "-fplan9-extensions" } */ + +/* Test for ambiguity when using the Plan 9 extensions. */ + +struct A { + char a; /* { dg-error "duplicate member" } */ +}; + +struct B +{ + struct A; + struct A; +}; + +char +f1 (struct B *p) +{ + return p->a; /* { dg-error "no member" } */ +} + +void +f2 (struct A *p) /* { dg-message "expected" } */ +{ +} + +void +f3 (struct B *p) +{ + f2 (p); /* { dg-warning "incompatible pointer type" } */ +} + +struct C +{ + char c; /* { dg-error "duplicate member" } */ +}; + +struct D +{ + struct C; +}; + +struct E +{ + struct C; + struct D; +}; + +char +f4 (struct E *p) +{ + return p->c; /* { dg-error "no member" } */ +} + +void +f6 (struct C *p) /* { dg-message "expected" } */ +{ +} + +void +f7 (struct E *p) +{ + f6 (p); /* { dg-warning "incompatible pointer type" } */ +} + +struct A +f8 (struct B *p) +{ + return p->A; /* { dg-error "no member" } */ +} + +struct C +f9 (struct E *p) +{ + return p->C; /* { dg-error "no member" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-14.c b/SingleSource/Regression/C/gcc-dg/anon-struct-14.c new file mode 100644 index 0000000000..293ccc75a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-14.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fplan9-extensions" } */ + +/* When using Plan 9 extensions, a typedef can conflict with an + anonymous field. */ + +typedef struct { int a; } s1; +struct s2 { s1; int s1; }; /* { dg-error "duplicate" } */ +int f(struct s2 *p) { return p->s1; } /* { dg-error "incompatible" } */ diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-15.c b/SingleSource/Regression/C/gcc-dg/anon-struct-15.c new file mode 100644 index 0000000000..d9e786a8d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-15.c @@ -0,0 +1,16 @@ +/* Test diagnostics for duplicate field names involving anonymous + struct or union as first field. PR 46889. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct foo { + union { + struct { + unsigned long time_stamp; + }; + struct { + int *page; + }; + }; + int *page; /* { dg-error "duplicate member" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-2.c b/SingleSource/Regression/C/gcc-dg/anon-struct-2.c new file mode 100644 index 0000000000..4bd2d0f337 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-2.c @@ -0,0 +1,48 @@ +/* { dg-options "-std=gnu89" } */ +/* In GNU C mode, we recognize the anonymous struct/union extension, + but not Microsoft extensions. */ + +struct A { char a; }; + +/* MS extension. */ +struct B { + struct A; /* { dg-warning "does not declare anything" } */ + char b; +}; +char testB[sizeof(struct B) == sizeof(struct A) ? 1 : -1]; + +/* MS extension. */ +struct C { + struct D { char d; }; /* { dg-warning "does not declare anything" } */ + char c; +}; +char testC[sizeof(struct C) == sizeof(struct A) ? 1 : -1]; +char testD[sizeof(struct D) == sizeof(struct A) ? 1 : -1]; + +/* GNU extension. */ +struct E { + struct { char z; }; + char e; +}; +char testE[sizeof(struct E) == 2 * sizeof(struct A) ? 1 : -1]; + +/* MS extension. */ +typedef struct A typedef_A; +struct F { + typedef_A; /* { dg-warning "does not declare anything" } */ + char f; +}; +char testF[sizeof(struct F) == sizeof(struct A) ? 1 : -1]; + +/* Test that __extension__ does the right thing coming _from_ GNU C mode. */ +__extension__ struct G { + struct { char z; }; + char g; +}; +char testG[sizeof(struct G) == 2 * sizeof(struct A) ? 1 : -1]; + +struct H { + struct { char z; }; + char h; +}; +char testH[sizeof(struct H) == 2 * sizeof(struct A) ? 1 : -1]; diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-3.c b/SingleSource/Regression/C/gcc-dg/anon-struct-3.c new file mode 100644 index 0000000000..3ed6e672bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-3.c @@ -0,0 +1,32 @@ +/* { dg-options "-std=gnu89 -fms-extensions" } */ +/* Enabling Microsoft mode makes all of the tests equivalent. Checked vs + Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86 + */ + +struct A { char a; }; + +struct B { + struct A; + char b; +}; +char testB[sizeof(struct B) == 2 * sizeof(struct A) ? 1 : -1]; + +struct C { + struct D { char d; }; + char c; +}; +char testC[sizeof(struct C) == 2 * sizeof(struct A) ? 1 : -1]; +char testD[sizeof(struct D) == sizeof(struct A) ? 1 : -1]; + +struct E { + struct { char z; }; + char e; +}; +char testE[sizeof(struct E) == 2 * sizeof(struct A) ? 1 : -1]; + +typedef struct A typedef_A; +struct F { + typedef_A; + char f; +}; +char testF[sizeof(struct F) == 2 * sizeof(struct A) ? 1 : -1]; diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-4.c b/SingleSource/Regression/C/gcc-dg/anon-struct-4.c new file mode 100644 index 0000000000..dc30b0cc0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-4.c @@ -0,0 +1,10 @@ +/* Test anonymous structures with type qualifiers. Bug 8420. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +struct s { + struct { int a; }; + const struct { int b; }; + struct { int c; } volatile; +}; diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-5.c b/SingleSource/Regression/C/gcc-dg/anon-struct-5.c new file mode 100644 index 0000000000..e283e0d169 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-5.c @@ -0,0 +1,7 @@ +/* Test bad warning for anonymous int in structure. Bug 17189. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +struct Foo { int; }; /* { dg-bogus "unnamed" } */ +/* { dg-error "declaration does not declare anything" "int;" { target *-*-* } .-1 } */ +/* { dg-error "struct has no members" "no members" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-6.c b/SingleSource/Regression/C/gcc-dg/anon-struct-6.c new file mode 100644 index 0000000000..792769b886 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-6.c @@ -0,0 +1,12 @@ +/* Test diagnostics for structure member with no type specifier or + declarator. Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s { + int a; + const; + /* { dg-warning "useless type qualifier in empty declaration" "empty" { target *-*-* } .-1 } */ + /* { dg-warning "empty declaration" "empty 2" { target *-*-* } .-2 } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-7.c b/SingleSource/Regression/C/gcc-dg/anon-struct-7.c new file mode 100644 index 0000000000..0f05583c18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-7.c @@ -0,0 +1,10 @@ +/* Test diagnostics for structure member with no type specifier or + declarator. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +struct s { + int a; + const; /* { dg-warning "ISO C forbids member declarations with no members" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-8.c b/SingleSource/Regression/C/gcc-dg/anon-struct-8.c new file mode 100644 index 0000000000..66db0834ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-8.c @@ -0,0 +1,10 @@ +/* Test diagnostics for structure member with no type specifier or + declarator. Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +struct s { + int a; + const; /* { dg-error "ISO C forbids member declarations with no members" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/anon-struct-9.c b/SingleSource/Regression/C/gcc-dg/anon-struct-9.c new file mode 100644 index 0000000000..d223490457 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/anon-struct-9.c @@ -0,0 +1,129 @@ +/* Test for diagnostics for duplicate member names in anonymous + structures and unions. PR 4784. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s1 +{ + int x; + struct + { + int x; /* { dg-error "duplicate member" } */ + }; +}; + +struct s2 +{ + struct + { + int a; + struct + { + int b; + }; + }; + struct + { + int b; /* { dg-error "duplicate member" } */ + }; +}; + +struct s3 +{ + struct + { + int a; + struct + { + int b; + }; + }; + struct + { + int b; /* { dg-error "duplicate member" } */ + int c; + }; +}; + +struct s4 +{ + int x; + struct + { + int x; + } y; +}; + +union u1 +{ + int x; + union + { + int x; /* { dg-error "duplicate member" } */ + }; +}; + +union u2 +{ + union + { + int a; + union + { + int b; + }; + }; + union + { + int b; /* { dg-error "duplicate member" } */ + }; +}; + +union u3 +{ + union + { + int a; + union + { + int b; + }; + }; + union + { + int b; /* { dg-error "duplicate member" } */ + int c; + }; +}; + +union u4 +{ + int x; + union + { + int x; + } y; +}; + +#define D10(x) int x##0; int x##1; int x##2; int x##3; int x##4; int x##5; int x##6; int x##7; int x##8; int x##9; +#define D100(x) D10(x##0) D10(x##1) D10(x##2) D10(x##3) D10(x##4) D10(x##5) D10(x##6) D10(x##7) D10(x##8) D10(x##9) + +#define S10(x) struct { D100(x##0) }; struct { D100(x##1) }; struct { D100(x##2) }; struct { D100(x##3) }; struct { D100(x##4) }; struct { D100(x##5) }; struct { D100(x##6) }; struct { D100(x##7) }; struct { D100(x##8) }; struct { D100(x##9) }; + +struct sbig +{ + S10(a) + S10(b) + S10(c) + S10(d) + S10(e) + S10(f) + S10(g) + S10(h) + S10(j) + S10(k) + struct + { + int a123; /* { dg-error "duplicate member" } */ + }; +}; diff --git a/SingleSource/Regression/C/gcc-dg/array-1.c b/SingleSource/Regression/C/gcc-dg/array-1.c new file mode 100644 index 0000000000..6d1e69a17e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-1.c @@ -0,0 +1,15 @@ +/* Simplified from ncurses 5.0's pad.c + by Alexandre Oliva + + Copyright (C) 1999 Free Software Foundation */ + +/* { dg-do compile } */ + +extern char foo[1]; +char foo[] = ""; + +int +bar() +{ + return foo[0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/array-10.c b/SingleSource/Regression/C/gcc-dg/array-10.c new file mode 100644 index 0000000000..c1c73ff62b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-10.c @@ -0,0 +1,33 @@ +/* Test invalid array sizes at file scope: should not cause ICEs. + Bugs 25161 and 27020. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int a; + +int b0[a]; /* { dg-error "5:at file scope" } */ +int (*b1)[a]; /* { dg-error "7:at file scope" } */ +int (*b2())[a]; /* { dg-error "at file scope" } */ +struct b3 { int x[a]; }; /* { dg-error "17:at file scope" } */ +struct b4 { int (*x)[a]; }; /* { dg-error "19:at file scope" } */ +typeof (int [a]) b5; /* { dg-error "at file scope|outside of any function" } */ + +int c0[(__UINTPTR_TYPE__)&a]; /* { dg-error "5:at file scope" } */ +int (*c1)[(__UINTPTR_TYPE__)&a]; /* { dg-error "7:at file scope" } */ +int (*c2())[(__UINTPTR_TYPE__)&a]; /* { dg-error "7:at file scope" } */ +struct c3 { int x[(__UINTPTR_TYPE__)&a]; }; /* { dg-error "17:at file scope" } */ +struct c4 { int (*x)[(__UINTPTR_TYPE__)&a]; }; /* { dg-error "19:at file scope" } */ +typeof (int [(__UINTPTR_TYPE__)&a]) c5; /* { dg-error "37:at file scope" } */ + +int d0[1/0]; /* { dg-error "5:at file scope" } */ +/* { dg-warning "9:division by zero" "" { target *-*-* } .-1 } */ +int (*d1)[1/0]; /* { dg-error "7:at file scope" } */ +/* { dg-warning "12:division by zero" "" { target *-*-* } .-1 } */ +int (*d2())[1/0]; /* { dg-error "7:at file scope" } */ +/* { dg-warning "14:division by zero" "" { target *-*-* } .-1 } */ +struct d3 { int x[1/0]; }; /* { dg-error "17:at file scope" } */ +/* { dg-warning "20:division by zero" "" { target *-*-* } .-1 } */ +struct d4 { int (*x)[1/0]; }; /* { dg-error "19:at file scope" } */ +/* { dg-warning "23:division by zero" "" { target *-*-* } .-1 } */ +typeof (int [1/0]) d5; /* { dg-error "20:at file scope" } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-11.c b/SingleSource/Regression/C/gcc-dg/array-11.c new file mode 100644 index 0000000000..3b216a38e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-11.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Verify that we can't do things to get ourselves in trouble + with GCC's initialized flexible array member extension. */ + +typedef int T[]; +struct f { int w; T x; }; +struct g { struct f f; }; +struct g g1 = { { 0, { } } }; +struct g g2 = { { 0, { 1 } } }; /* { dg-error "nested context" "nested" } */ + /* { dg-message "near init" "near" { target *-*-* } .-1 } */ +struct h { int x[0]; int y; }; +struct h h1 = { { 0 }, 1 }; /* { dg-warning "excess elements" "excess" } */ + /* { dg-message "near init" "before end" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-12.c b/SingleSource/Regression/C/gcc-dg/array-12.c new file mode 100644 index 0000000000..b3beed57d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-12.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* ISO C99 flexible array members don't have a size. GCC's zero-length + array extension does. */ + +typedef int T0[0]; +typedef int T[]; +struct f { int w; T0 x; } f; +struct g { int w; T x; } g; + +char test_gcc[sizeof (f.x) ? -1 : 1]; +char test_iso[sizeof (g.x) ? -1 : 1]; /* { dg-error "incomplete type" "iso" } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-13.c b/SingleSource/Regression/C/gcc-dg/array-13.c new file mode 100644 index 0000000000..70fd87de8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-13.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "" } */ + +/* Verify that GCC's initialized flexible array member extension + works properly. */ + +extern void abort(void); +extern void exit(int); + +typedef int T[]; +typedef int T0[0]; + +struct f { int w; T x; }; +struct g { int w; T0 x; }; + +static struct f f = { 4, { 0, 1, 2, 3 } }; +static int junk1[] = { -1, -1, -1, -1 }; +static struct g g = { 4, { 0, 1, 2, 3 } }; /* { dg-warning "(excess elements)|(near initialization)" } */ +static int junk2[] = { -1, -1, -1, -1 }; + +int main() +{ + int i; + for (i = 0; i < f.w; ++i) + if (f.x[i] != i) + abort (); + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/array-14.c b/SingleSource/Regression/C/gcc-dg/array-14.c new file mode 100644 index 0000000000..cb2a347fbb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-14.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Verify that GCC forbids non-static initialization of + flexible array members. */ + +typedef char T[]; +struct str { int len; T s; }; + +struct str a = { 2, "a" }; + +void foo() +{ + static struct str b = { 2, "b" }; + struct str c = { 2, "c" }; /* { dg-error "(non-static)|(near initialization)" } */ + struct str d = (struct str) { 2, "d" }; /* { dg-error "(non-static)|(near initialization)" } */ + struct str e = (struct str) { d.len, "e" }; /* { dg-error "(non-static)|(initialization)" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/array-15.c b/SingleSource/Regression/C/gcc-dg/array-15.c new file mode 100644 index 0000000000..8e7c0adad2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-15.c @@ -0,0 +1,52 @@ +/* PR c/69262 */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +struct S +{ + int a[1][][2]; /* { dg-error "array type has incomplete element type" } */ + /* { dg-message "declaration of .a. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ +}; + +struct R +{ + int i; + int a[][]; /* { dg-error "array type has incomplete element type" } */ + /* { dg-message "declaration of .a. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ +}; + +typedef int T[]; +typedef int U[][]; /* { dg-error "array type has incomplete element type" } */ +/* { dg-message "declaration of .U. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ + +int x[][]; /* { dg-error "array type has incomplete element type" } */ +/* { dg-message "declaration of .x. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ + +struct N; + +void +fn1 (int z[][]) /* { dg-error "array type has incomplete element type" } */ +/* { dg-message "declaration of .z. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ +{ + int a[1][][2]; /* { dg-error "array type has incomplete element type" } */ + /* { dg-message "declaration of .a. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ + /* OK */ + int b[3][2][1]; + int c[1][2][3][]; /* { dg-error "array type has incomplete element type" } */ + /* { dg-message "declaration of .c. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ + T d[1]; /* { dg-error "array type has incomplete element type" } */ + /* { dg-message "declaration of .d. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ + T e[]; /* { dg-error "array type has incomplete element type" } */ + /* { dg-message "declaration of .e. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ + + /* This array has incomplete element type, but is not multidimensional. */ + struct N f[1]; /* { dg-error "array type has incomplete element type" } */ + /* { dg-bogus "declaration of .f. as multidimensional array must have bounds" "" { target *-*-* } .-1 } */ +} + +void fn2 (int [][]); /* { dg-error "array type has incomplete element type" } */ +/* { dg-message "declaration of multidimensional array must have bounds" "" { target *-*-* } .-1 } */ +/* OK */ +void fn3 (int [][*]); +void fn4 (T []); /* { dg-error "array type has incomplete element type" } */ +/* { dg-message "declaration of multidimensional array must have bounds" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-2.c b/SingleSource/Regression/C/gcc-dg/array-2.c new file mode 100644 index 0000000000..f207af58d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Verify that we can't do things to get ourselves in trouble + with GCC's initialized flexible array member extension. */ + +struct f { int w; int x[]; }; +struct g { struct f f; }; +struct g g1 = { { 0, { } } }; +struct g g2 = { { 0, { 1 } } }; /* { dg-error "nested context" "nested" } */ + /* { dg-message "near init" "near" { target *-*-* } .-1 } */ +struct h { int x[0]; int y; }; +struct h h1 = { { 0 }, 1 }; /* { dg-warning "excess elements" "excess" } */ + /* { dg-message "near init" "before end" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-3.c b/SingleSource/Regression/C/gcc-dg/array-3.c new file mode 100644 index 0000000000..f0709d2206 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* ISO C99 flexible array members don't have a size. GCC's zero-length + array extension does. */ + +struct f { int w; int x[0]; } f; +struct g { int w; int x[]; } g; + +char test_gcc[sizeof (f.x) ? -1 : 1]; +char test_iso[sizeof (g.x) ? -1 : 1]; /* { dg-error "incomplete type" "iso" } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-4.c b/SingleSource/Regression/C/gcc-dg/array-4.c new file mode 100644 index 0000000000..c045e7999e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-4.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "" } */ + +/* Verify that GCC's initialized flexible array member extension + works properly. */ + +extern void abort(void); +extern void exit(int); + +struct f { int w; int x[]; }; +struct g { int w; int x[0]; }; + +static struct f f = { 4, { 0, 1, 2, 3 } }; +static int junk1[] = { -1, -1, -1, -1 }; +static struct g g = { 4, { 0, 1, 2, 3 } }; /* { dg-warning "(excess elements)|(near initialization)" } */ +static int junk2[] = { -1, -1, -1, -1 }; + +int main() +{ + int i; + for (i = 0; i < f.w; ++i) + if (f.x[i] != i) + abort (); + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/array-5.c b/SingleSource/Regression/C/gcc-dg/array-5.c new file mode 100644 index 0000000000..4083c92ffc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-5.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Check compatibility of array declarations. */ + +/* Incomplete decl matches. */ +extern char arr0[]; +char arr0[1]; + +/* Two integral expressions must be the same. Note that 0 is + a gcc extension, but it should work like any other constant. */ +extern char arr1[1]; +char arr1[1]; +extern char arr2[0]; +char arr2[0]; +extern char arr3[0]; /* { dg-message "note: previous declaration" } */ +char arr3[1]; /* { dg-error "conflicting types" } */ + +/* Variable size matches. */ +void func(int n, int m) +{ + /* The next two are from the example in c99 6.7.5.2/9. */ + { + /* Invalid: not compatible because 4 != 6. */ + int a[n][6][m]; + int (*p)[4][n+1]; + p = a; /* { dg-warning "incompatible" } */ + } + { + /* Compatible, but defined behavior only if n == 6 and m == n+1. */ + int c[n][n][6][m]; + int (*r)[n][n][n+1]; + r = c; + } + { + /* Compatible, but undefined behavior; (2, 2) is not a constant + expression, and thus A is a VLA. */ + int a[6][(2, 2)]; + int (*p)[3]; + p = a; /* { dg-bogus "incompatible" "bad vla handling" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/array-7.c b/SingleSource/Regression/C/gcc-dg/array-7.c new file mode 100644 index 0000000000..9e70b26821 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-7.c @@ -0,0 +1,14 @@ +/* Test for array of incomplete structure type - Zack Weinberg in + . */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct foo; + +void +f (void) +{ + struct foo { int a; int b; }; +} + +struct foo array[5]; /* { dg-error "array type has incomplete element type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-8.c b/SingleSource/Regression/C/gcc-dg/array-8.c new file mode 100644 index 0000000000..71c98038b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-8.c @@ -0,0 +1,47 @@ +/* Test diagnostics for array references. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +struct s { char c[1]; }; +struct s f (void); +_Bool b; +char c; +enum e { E } e; +extern int a[]; +int *p; +void *pv; +void (*fp)(void); +struct si *sip; + +void +g (void) +{ + a[b]; + a[c]; + a[e]; + p[b]; + p[c]; + p[e]; + b[a]; + c[a]; + e[a]; + b[p]; + c[p]; + e[p]; + /* These two should be treated the same. In particular, a "neither + array nor pointer" bogus warning used to be given for the + second. */ + f().c[0]; + 0[f().c]; + /* Various invalid cases. */ + c[c]; /* { dg-error "subscripted value is neither array nor pointer nor vector" } */ + p[1.0]; /* { dg-error "array subscript is not an integer" } */ + 1.0[a]; /* { dg-error "array subscript is not an integer" } */ + fp[0]; /* { dg-error "subscripted value is pointer to function" } */ + 0[fp]; /* { dg-error "subscripted value is pointer to function" } */ + pv[0]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + 0[pv]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + sip[0]; /* { dg-error "invalid use of undefined type 'struct si'" } */ + 0[sip]; /* { dg-error "invalid use of undefined type 'struct si'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/array-9.c b/SingleSource/Regression/C/gcc-dg/array-9.c new file mode 100644 index 0000000000..f173f65693 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-9.c @@ -0,0 +1,10 @@ +/* PR target/27421 */ +/* { dg-do compile } */ + +struct A +{ + int i; + void x[1]; /* { dg-error "array of voids" } */ +}; + +void foo(struct A a) {} diff --git a/SingleSource/Regression/C/gcc-dg/array-const-1.c b/SingleSource/Regression/C/gcc-dg/array-const-1.c new file mode 100644 index 0000000000..0e0c46224c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-const-1.c @@ -0,0 +1,8 @@ +/* Test for array designators not integer constant expressions but + folding to integer constants (used in Linux kernel, + ). */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +extern int i; +int a[] = { [1 ? 1 : i] = 0 }; diff --git a/SingleSource/Regression/C/gcc-dg/array-const-2.c b/SingleSource/Regression/C/gcc-dg/array-const-2.c new file mode 100644 index 0000000000..d962a3729b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-const-2.c @@ -0,0 +1,9 @@ +/* Test for array designators not integer constant expressions but + folding to integer constants (used in Linux kernel, + ). */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic" } */ + +extern int i; +int a[] = { [1 ? 1 : i] = 0 }; /* { dg-warning "array index in initializer is not an integer constant expression" } */ +/* { dg-message "near initialization" "near init" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-const-3.c b/SingleSource/Regression/C/gcc-dg/array-const-3.c new file mode 100644 index 0000000000..b7089284f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-const-3.c @@ -0,0 +1,9 @@ +/* Test for array designators not integer constant expressions but + folding to integer constants (used in Linux kernel, + ). */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +extern int i; +int a[] = { [1 ? 1 : i] = 0 }; /* { dg-error "array index in initializer is not an integer constant expression" } */ +/* { dg-message "near initialization" "near init" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-init-1.c b/SingleSource/Regression/C/gcc-dg/array-init-1.c new file mode 100644 index 0000000000..14ec9552e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-init-1.c @@ -0,0 +1,25 @@ +/* Test that both arrays are initialized by store_by_pieces. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +struct A { char c[10]; }; +extern void baz (struct A *); + +void +foo (void) +{ + struct A a = { "abcdefghi" }; + baz (&a); +} + +void +bar (void) +{ + struct A a; + __builtin_strcpy (&a.c[0], "abcdefghi"); + baz (&a); +} + +/* { dg-final { scan-assembler-not "abcdefghi" { target i?86-*-* x86_64-*-* ia64-*-* } } } */ +/* { dg-final { scan-assembler-times "7017280452245743464\|7523094288207667809\|6867666564636261\|1684234849\|64636261" 2 { target i?86-*-* x86_64-*-* ia64-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/array-init-2.c b/SingleSource/Regression/C/gcc-dg/array-init-2.c new file mode 100644 index 0000000000..9c425818fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-init-2.c @@ -0,0 +1,51 @@ +/* Test array initializion by store_by_pieces. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +struct A { char c[10]; }; +extern void abort (void); + +void +__attribute__((noinline)) +check (struct A * a, int b) +{ + const char *p; + switch (b) + { + case 0: + p = "abcdefghi"; + break; + case 1: + p = "j\0\0\0\0\0\0\0\0"; + break; + case 2: + p = "kl\0\0\0\0\0\0\0"; + break; + case 3: + p = "mnop\0\0\0\0\0"; + break; + case 4: + p = "qrstuvwx\0"; + break; + default: + abort (); + } + if (__builtin_memcmp (a->c, p, 10) != 0) + abort (); +} + +int +main (void) +{ + struct A a = { "abcdefghi" }; + check (&a, 0); + struct A b = { "j" }; + check (&b, 1); + struct A c = { "kl" }; + check (&c, 2); + struct A d = { "mnop" }; + check (&d, 3); + struct A e = { "qrstuvwx" }; + check (&e, 4); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/array-quals-1.c b/SingleSource/Regression/C/gcc-dg/array-quals-1.c new file mode 100644 index 0000000000..b9b55f774b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-quals-1.c @@ -0,0 +1,52 @@ +/* Test for various combinations of const, arrays and typedefs: + should never actually get const on the final array type, but + all should end up in a read-only section. PR c/12165. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wno-discarded-array-qualifiers" } */ +/* { dg-additional-options "-fno-pie" { target pie } } */ +/* The MMIX port always switches to the .data section at the end of a file. */ +/* { dg-final { scan-assembler-not "\\.data(?!\\.rel\\.ro)" { xfail powerpc*-*-aix* mmix-*-* x86_64-*-mingw* } } } */ +/* { dg-final { scan-assembler-symbol-section {^_?a$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +static const int a[2] = { 1, 2 }; +/* { dg-final { scan-assembler-symbol-section {^_?a1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +const int a1[2] = { 1, 2 }; +typedef const int ci; +/* { dg-final { scan-assembler-symbol-section {^_?b$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +static ci b[2] = { 3, 4 }; +/* { dg-final { scan-assembler-symbol-section {^_?b1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +ci b1[2] = { 3, 4 }; +typedef int ia[2]; +/* { dg-final { scan-assembler-symbol-section {^_?c$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +static const ia c = { 5, 6 }; +/* { dg-final { scan-assembler-symbol-section {^_?c1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +const ia c1 = { 5, 6 }; +typedef const int cia[2]; +/* { dg-final { scan-assembler-symbol-section {^_?d$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +static cia d = { 7, 8 }; +/* { dg-final { scan-assembler-symbol-section {^_?d1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +cia d1 = { 7, 8 }; +/* { dg-final { scan-assembler-symbol-section {^_?e$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +static cia e[2] = { { 1, 2 }, { 3, 4 } }; +/* { dg-final { scan-assembler-symbol-section {^_?e1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ +cia e1[2] = { { 1, 2 }, { 3, 4 } }; +/* { dg-final { scan-assembler-symbol-section {^_?p$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const p = &a; +/* { dg-final { scan-assembler-symbol-section {^_?q$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const q = &b; +/* { dg-final { scan-assembler-symbol-section {^_?r$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const r = &c; +/* { dg-final { scan-assembler-symbol-section {^_?s$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const s = &d; +/* { dg-final { scan-assembler-symbol-section {^_?t$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const t = &e; +/* { dg-final { scan-assembler-symbol-section {^_?p1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const p1 = &a1; +/* { dg-final { scan-assembler-symbol-section {^_?q1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const q1 = &b1; +/* { dg-final { scan-assembler-symbol-section {^_?r1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const r1 = &c1; +/* { dg-final { scan-assembler-symbol-section {^_?s1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const s1 = &d1; +/* { dg-final { scan-assembler-symbol-section {^_?t1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ +void *const t1 = &e1; diff --git a/SingleSource/Regression/C/gcc-dg/array-quals-2.c b/SingleSource/Regression/C/gcc-dg/array-quals-2.c new file mode 100644 index 0000000000..7f33e3fb2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/array-quals-2.c @@ -0,0 +1,14 @@ +/* Test that pointers to arrays of differently qualified types aren't + permitted in conditional expressions, and that qualifiers aren't + lost in forming composite types. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic -Wno-discarded-array-qualifiers" } */ +typedef const char T[1]; +typedef const char T2[1]; +typedef volatile char U[1]; +T *p; +T2 *p2; +U *q; +void *f(void) { return 1 ? p : q; } /* { dg-warning "pointers to arrays with different qualifiers" } */ +T *g(void) { return 1 ? p : p2; } diff --git a/SingleSource/Regression/C/gcc-dg/aru-2.c b/SingleSource/Regression/C/gcc-dg/aru-2.c new file mode 100644 index 0000000000..054223c151 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/aru-2.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-require-profiling "-pg" } */ +/* { dg-options "-O2 -pg" } */ + +static int __attribute__((noinline)) +bar (int x) +{ + return x + 3; +} + +int __attribute__((noinline)) +foo (int y0, int y1, int y2, int y3, int y4) { + int r = 0; + r += bar (r + y4); + r += bar (r + y3); + r += bar (r + y2); + r += bar (r + y1); + r += bar (r + y0); + return r; +} + +int +main (void) +{ + int z = foo (0, 1, 2, 3, 4); + return !(z == 191); +} + +/* { dg-final { cleanup-profile-file } } */ diff --git a/SingleSource/Regression/C/gcc-dg/asm-1.c b/SingleSource/Regression/C/gcc-dg/asm-1.c new file mode 100644 index 0000000000..fecac780f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ + +struct x { + int selector; +}; + +void f() +{ + struct x* addr; + __asm__("mov %%gs,%0":"=r" ((unsigned short)addr->selector)); /* { dg-error "lvalue" "casts make rvalues" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-10.c b/SingleSource/Regression/C/gcc-dg/asm-10.c new file mode 100644 index 0000000000..e6c03c62ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-10.c @@ -0,0 +1,12 @@ +/* PR inline-asm/67448 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (int i) +{ + asm ("" : : "m"(i += 1)); /* { dg-error "not directly addressable" } */ + asm ("" : : "m"(i++)); /* { dg-error "not directly addressable" } */ + asm ("" : : "m"(++i)); /* { dg-error "not directly addressable" } */ + asm ("" : : "m"(i = 0)); /* { dg-error "not directly addressable" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-2.c b/SingleSource/Regression/C/gcc-dg/asm-2.c new file mode 100644 index 0000000000..9c464ce894 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void f() +{ + asm volatile ("foo%%bar" : : ); +} + +/* { dg-final { scan-assembler "foo%bar" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/asm-3.c b/SingleSource/Regression/C/gcc-dg/asm-3.c new file mode 100644 index 0000000000..917942d7b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void f() +{ + asm ("foo%%bar"); +} + +/* { dg-final { scan-assembler "foo%%bar" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/asm-4.c b/SingleSource/Regression/C/gcc-dg/asm-4.c new file mode 100644 index 0000000000..180578e64e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-4.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* "p" modifier can't be used to generate a valid memory address with ILP32. */ +/* { dg-skip-if "" { aarch64*-*-* && ilp32 } } */ +/* { dg-skip-if "'p' is not supported for GCN" { amdgcn-*-* } } */ + +int main() +{ + int x, y, z; + + asm volatile ("test0 X%0Y%[arg]Z" : [arg] "=g" (x)); + asm volatile ("test1 X%[out]Y%[in]Z" : [out] "=g" (y) : [in] "0"(y)); + asm volatile ("test2 X%a0Y%a[arg]Z" : : [arg] "p" (&z)); + asm volatile ("test3 %[in]" : [inout] "=g"(x) : "[inout]" (x), [in] "g" (y)); +} + +/* { dg-final { scan-assembler {test0 X(.*)Y\1Z} } } */ +/* { dg-final { scan-assembler {test1 X(.*)Y\1Z} } } */ +/* { dg-final { scan-assembler {test2 X(.*)Y\1Z} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/asm-6.c b/SingleSource/Regression/C/gcc-dg/asm-6.c new file mode 100644 index 0000000000..10983c77c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-6.c @@ -0,0 +1,7 @@ +/* Check error messages for named asm operands. */ +void foo () +{ + int i; + __asm__ ("" : [data] "=r" (i) : [data] "i" (100)); /* { dg-error "duplicate 'asm' operand" } */ + __asm__ ("%[foo]" :: [bar] "i" (1)); /* { dg-error "undefined named operand" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-7.c b/SingleSource/Regression/C/gcc-dg/asm-7.c new file mode 100644 index 0000000000..65b0353fe4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-7.c @@ -0,0 +1,28 @@ +/* Gcc 3.3.1 deprecates memory inputs of non-lvalues. */ +/* { dg-do compile } */ + +void test(void) +{ + register int r; + register int r2; + int i; + static int m; + int *p; + + __asm__ ("" : : "m"(r)); /* { dg-error "" } */ + __asm__ ("" : : "m"(i)); + __asm__ ("" : : "m"(m)); + __asm__ ("" : : "m"(0)); /* { dg-error "" } */ + __asm__ ("" : : "m"(i+1)); /* { dg-error "" } */ + __asm__ ("" : : "m"(*p++)); + + __asm__ ("" : : "g"(r)); + __asm__ ("" : : "g"(i)); + __asm__ ("" : : "g"(m)); + __asm__ ("" : : "g"(0)); + __asm__ ("" : : "g"(i+1)); + + __asm__ ("" : "=m"(r2)); /* { dg-error "" } */ + __asm__ ("" : "=m"(i)); + __asm__ ("" : "=m"(m)); +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-8.c b/SingleSource/Regression/C/gcc-dg/asm-8.c new file mode 100644 index 0000000000..a3f3962eb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-8.c @@ -0,0 +1,9 @@ +/* PR inline-asm/11676 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wall" } */ + +void foo(void) +{ + long x = 0; + asm volatile ("" : "=r"(x) : "r"(x)); /* { dg-bogus "uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-9.c b/SingleSource/Regression/C/gcc-dg/asm-9.c new file mode 100644 index 0000000000..4e3244169c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-9.c @@ -0,0 +1,11 @@ +/* PR inline-asm/15740 */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +void foo(void) +{ + int a, b; + a = 1; + b = a + 1; + asm ("" : : "m" (a)); +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-a.c b/SingleSource/Regression/C/gcc-dg/asm-a.c new file mode 100644 index 0000000000..a676c9ebc0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-a.c @@ -0,0 +1,15 @@ +/* { dg-options "-O2" } */ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ + +/* The problem was we were not striping the long cast here. + Note this really should be invalid code but not for the + current release (4.0) as we have people using it. */ + +void blockCopy_MMX2(int*); +void postProcess_MMX2() +{ + int c, x,y, width; + asm( "" :: "m" ((long)x)); + blockCopy_MMX2(&c); +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-b.c b/SingleSource/Regression/C/gcc-dg/asm-b.c new file mode 100644 index 0000000000..f888839abf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-b.c @@ -0,0 +1,39 @@ +/* { dg-do run { target powerpc*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O1" } */ +/* Test to make sure that inline-asm causes the tree optimizers to get the + V_MAY_DEFs and clobber memory. */ +/* Test from Jakub Jelinek, modified by Andrew Pinski to work on all powerpc targets. */ +extern void abort (void); + +unsigned short v = 0x0300; + +void +foo (unsigned short *p) +{ + *p = v; +} + +int +bar (void) +{ + unsigned short x; + volatile unsigned short *z; + foo (&x); + const unsigned int y = x; + z = &x; +#if defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (_POWER) || defined (__ppc64__) || defined (__ppc) + __asm __volatile ("sthbrx %1,0,%2" : "=m" (*z) : "r" (y), "r" (z)); +#elif defined __i386__ || defined __x86_64__ + __asm __volatile ("movb %b1,1(%2)\n\tmovb %h1,(%2)" + : "=m" (*z) : "Q" (y), "R" (z)); +#endif + return (x & 1) == 0; +} + +int +main (void) +{ + if (bar ()) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-fs-1.c b/SingleSource/Regression/C/gcc-dg/asm-fs-1.c new file mode 100644 index 0000000000..f215ee8ac8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-fs-1.c @@ -0,0 +1,14 @@ +/* Origin: + Make sure we do not get spurious '*' characters in section names or + elsewhere, with asm-specified names. */ +/* { dg-do compile } */ +/* { dg-options "-w -ffunction-sections -fdata-sections" } */ + +void foo (void) asm ("_bar"); +void foo (void) {} + +extern int foobar asm ("_baz"); +int foobar = 3; + +/* { dg-final { scan-assembler-not "\\*_bar" } } */ +/* { dg-final { scan-assembler-not "\\*_baz" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/asm-names.c b/SingleSource/Regression/C/gcc-dg/asm-names.c new file mode 100644 index 0000000000..f5e44e65f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-names.c @@ -0,0 +1,16 @@ +/* The name specified by an asm("...") suffix on a declaration is not + to have an underscore prefixed, even if normal symbols are. + Problem reported by Krister Walfridsson . */ + +/* { dg-do compile } */ +/* { dg-options "-fleading-underscore" } */ +/* { dg-final { scan-assembler-not "____frob14" } } */ + +extern void frobnicate (void) asm ("___frob14"); /* three underscores */ + +int +main (void) +{ + frobnicate (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-pr24146.c b/SingleSource/Regression/C/gcc-dg/asm-pr24146.c new file mode 100644 index 0000000000..0b1be7da7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-pr24146.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +/* Test that asm with no outputs are treated as volatile. */ + +void f(int x) +{ + __asm__ ("extended asm not discarded" : : "r" (x)); +} + +void g (void) +{ + __asm__ ("simple asm not discarded"); +} +/* { dg-final { scan-assembler "extended asm not discarded" } } */ +/* { dg-final { scan-assembler "simple asm not discarded" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/asm-qual-1.c b/SingleSource/Regression/C/gcc-dg/asm-qual-1.c new file mode 100644 index 0000000000..7e21687763 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-qual-1.c @@ -0,0 +1,14 @@ +/* Test that qualifiers other than volatile are disallowed on asm. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void +f (void) +{ + asm volatile (""); + + asm const (""); /* { dg-error {'const' is not a valid 'asm' qualifier} } */ + + asm restrict (""); /* { dg-error {'restrict' is not a valid 'asm' qualifier} } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-qual-2.c b/SingleSource/Regression/C/gcc-dg/asm-qual-2.c new file mode 100644 index 0000000000..79135c3d2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-qual-2.c @@ -0,0 +1,46 @@ +/* Test that qualifiers on asm are allowed in any order. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void +f (void) +{ + asm volatile goto ("" :::: lab); + asm volatile inline ("" :::); + asm inline volatile ("" :::); + asm inline goto ("" :::: lab); + asm goto volatile ("" :::: lab); + asm goto inline ("" :::: lab); + + asm volatile inline goto ("" :::: lab); + asm volatile goto inline ("" :::: lab); + asm inline volatile goto ("" :::: lab); + asm inline goto volatile ("" :::: lab); + asm goto volatile inline ("" :::: lab); + asm goto inline volatile ("" :::: lab); + + /* Duplicates are not allowed. */ + asm goto volatile volatile ("" :::: lab); /* { dg-error "" } */ + asm volatile goto volatile ("" :::: lab); /* { dg-error "" } */ + asm volatile volatile goto ("" :::: lab); /* { dg-error "" } */ + asm goto goto volatile ("" :::: lab); /* { dg-error "" } */ + asm goto volatile goto ("" :::: lab); /* { dg-error "" } */ + asm volatile goto goto ("" :::: lab); /* { dg-error "" } */ + + asm inline volatile volatile ("" :::); /* { dg-error "" } */ + asm volatile inline volatile ("" :::); /* { dg-error "" } */ + asm volatile volatile inline ("" :::); /* { dg-error "" } */ + asm inline inline volatile ("" :::); /* { dg-error "" } */ + asm inline volatile inline ("" :::); /* { dg-error "" } */ + asm volatile inline inline ("" :::); /* { dg-error "" } */ + + asm goto inline inline ("" :::: lab); /* { dg-error "" } */ + asm inline goto inline ("" :::: lab); /* { dg-error "" } */ + asm inline inline goto ("" :::: lab); /* { dg-error "" } */ + asm goto goto inline ("" :::: lab); /* { dg-error "" } */ + asm goto inline goto ("" :::: lab); /* { dg-error "" } */ + asm inline goto goto ("" :::: lab); /* { dg-error "" } */ + +lab: + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-qual-3.c b/SingleSource/Regression/C/gcc-dg/asm-qual-3.c new file mode 100644 index 0000000000..f85d8bff89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-qual-3.c @@ -0,0 +1,9 @@ +/* Test that asm-qualifiers are not allowed on toplevel asm. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +asm const (""); /* { dg-error {expected '\(' before 'const'} } */ +asm volatile (""); /* { dg-error {expected '\(' before 'volatile'} } */ +asm restrict (""); /* { dg-error {expected '\(' before 'restrict'} } */ +asm inline (""); /* { dg-error {expected '\(' before 'inline'} } */ +asm goto (""); /* { dg-error {expected '\(' before 'goto'} } */ diff --git a/SingleSource/Regression/C/gcc-dg/asm-scope-1.c b/SingleSource/Regression/C/gcc-dg/asm-scope-1.c new file mode 100644 index 0000000000..6439104e57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-scope-1.c @@ -0,0 +1,27 @@ +/* Test :: token handling in asm. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +void +f (void) +{ + asm (""); + asm ("" : ); + asm ("" : :); + asm ("" ::); + asm ("" : : :); + asm ("" :: :); + asm ("" : ::); + asm goto ("" : : : : lab); + asm goto ("" :: : : lab); + asm goto ("" : :: : lab); + asm goto ("" : : :: lab); + asm goto ("" :: :: lab); + lab: ; + /* Test errors when :: is at the end of asm and only one : allowed. */ + asm ("" : : ::); /* { dg-error "expected" } */ + asm ("" :: ::); /* { dg-error "expected" } */ + asm goto ("" : : : :: lab); /* { dg-error "expected" } */ + asm goto ("" :: : :: lab); /* { dg-error "expected" } */ + asm goto ("" : :: :: lab); /* { dg-error "expected" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/asm-wide-1.c b/SingleSource/Regression/C/gcc-dg/asm-wide-1.c new file mode 100644 index 0000000000..5ddc4c7d9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asm-wide-1.c @@ -0,0 +1,31 @@ +/* Wide string literals should not be allowed in asm. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int foo asm (L"bar"); /* { dg-error "14:a wide string is invalid in this context" } */ + +asm (L"foo"); /* { dg-error "6:a wide string is invalid in this context" } */ + +void +f (void) +{ + int x = 1; + asm (L"foo"); /* { dg-error "8:a wide string is invalid in this context" } */ + asm ("foo" : + L"=g" (x)); /* { dg-error "8:a wide string is invalid in this context" } */ + /* Extra errors from the substitution of "" for wide strings: */ + /* { dg-error "output" "output" { target *-*-* } .-2 } */ + asm ("foo" : [x] + L"=g" (x)); /* { dg-error "8:a wide string is invalid in this context" } */ + /* { dg-error "output" "output" { target *-*-* } .-1 } */ + asm ("foo" : [x] "=g" (x), + L"=g" (x)); /* { dg-error "8:a wide string is invalid in this context" } */ + /* { dg-error "output" "output" { target *-*-* } .-1 } */ + asm ("foo" : : + L"g" (x)); /* { dg-error "8:a wide string is invalid in this context" } */ + asm ("foo" : : : + L"memory"); /* { dg-error "8:a wide string is invalid in this context" } */ + asm ("foo" : : : "memory", + L"memory"); /* { dg-error "8:a wide string is invalid in this context" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/asr_div1.c b/SingleSource/Regression/C/gcc-dg/asr_div1.c new file mode 100644 index 0000000000..f808db3296 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/asr_div1.c @@ -0,0 +1,57 @@ +/* Test division by const int generates only one shift. */ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-rtl-combine-all" } */ +/* { dg-options "-O2 -fdump-rtl-combine-all -mtune=cortex-a53" { target aarch64*-*-* } } */ +/* { dg-require-effective-target int32plus } */ + +extern void abort (void); + +#define NOINLINE __attribute__((noinline)) + +static NOINLINE int +f1 (int n) +{ + return n / 33; +} + +static NOINLINE int +f2 (int n) +{ + return n / 77; +} + +int +main () +{ + int a = 0xaaaaaaaa; + int b = 0x55555555; + int c; + c = f1 (a); + if (c != 0xfd6a052c) + abort (); + c = f1 (b); + if (c != 0x295FAD4) + abort (); + c = f2 (a); + if (c != 0xfee44b5c) + abort (); + c = f2 (b); + if (c != 0x11bb4a4) + abort (); + return 0; +} + +/* Following replacement pattern of intger division by constant, GCC is expected + to generate MULT and (x)SHIFTRT. This test checks that considering division + by const 33, gcc generates a single ASHIFTRT by 35, instead of two - LSHIFTRT + by 32 and ASHIFTRT by 3. */ + +/* { dg-final { scan-rtl-dump "\\(set \\(subreg:DI \\(reg:SI" "combine" { target aarch64*-*-* } } } */ +/* { dg-final { scan-rtl-dump "\\(ashiftrt:DI \\(reg:DI" "combine" { target aarch64*-*-* } } } */ +/* { dg-final { scan-rtl-dump "\\(const_int 35 " "combine" { target aarch64*-*-* } } } */ + +/* Similarly, considering division by const 77, gcc generates a single ASHIFTRT + by 36, instead of two - LSHIFTRT by 32 and ASHIFTRT by 4. */ + +/* { dg-final { scan-rtl-dump "\\(const_int 36 " "combine" { target aarch64*-*-* } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/assign-warn-1.c b/SingleSource/Regression/C/gcc-dg/assign-warn-1.c new file mode 100644 index 0000000000..365025724c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/assign-warn-1.c @@ -0,0 +1,128 @@ +/* Test diagnostics for bad implicit type conversions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic -ftrack-macro-expansion=0" } */ + +#define TESTARG(ID, TL, TR) void ID##F(TL); void ID##F2(TR x) { ID##F(x); } extern int dummy +#define TESTARP(ID, TL, TR) struct { void (*x)(TL); } ID##Fp; void ID##F2(TR x) { ID##Fp.x(x); } extern int dummy +#define TESTASS(ID, TL, TR) void ID##F(TR x) { TL y; y = x; } extern int dummy +#define TESTINI(ID, TL, TR) void ID##F(TR x) { TL y = x; } extern int dummy +#define TESTRET(ID, TL, TR) TR ID##V; TL ID##F(void) { return ID##V; } extern int dummy + +typedef void (*fp)(void); +typedef void (*nrfp)(void) __attribute__((noreturn)); + +TESTARG(fqa, nrfp, fp); /* { dg-warning "passing argument 1 of 'fqaF' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ +TESTARP(fqb, nrfp, fp); /* { dg-warning "passing argument 1 of 'fqbFp.x' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ +TESTASS(fqc, nrfp, fp); /* { dg-warning "assignment makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ +TESTINI(fqd, nrfp, fp); /* { dg-warning "initialization makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ +TESTRET(fqe, nrfp, fp); /* { dg-warning "return makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ + +TESTARG(ofqa, fp, nrfp); +TESTARP(ofqb, fp, nrfp); +TESTASS(ofqc, fp, nrfp); +TESTINI(ofqd, fp, nrfp); +TESTRET(ofqe, fp, nrfp); + +TESTARG(qa, char *, const char *); /* { dg-warning "passing argument 1 of 'qaF' discards 'const' qualifier from pointer target type" } */ +TESTARP(qb, char *, const char *); /* { dg-warning "passing argument 1 of 'qbFp.x' discards 'const' qualifier from pointer target type" } */ +TESTASS(qc, char *, const char *); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ +TESTINI(qd, char *, const char *); /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */ +TESTRET(qe, char *, const char *); /* { dg-warning "return discards 'const' qualifier from pointer target type" } */ + +TESTARG(oqa, const char *, char *); +TESTARP(oqb, const char *, char *); +TESTASS(oqc, const char *, char *); +TESTINI(oqd, const char *, char *); +TESTRET(oqe, const char *, char *); + +TESTARG(fda, fp, void *); /* { dg-warning "ISO C forbids passing argument 1 of 'fdaF' between function pointer and 'void \\*'" } */ +TESTARP(fdb, fp, void *); /* { dg-warning "ISO C forbids passing argument 1 of 'fdbFp.x' between function pointer and 'void \\*'" } */ +TESTASS(fdc, fp, void *); /* { dg-warning "ISO C forbids assignment between function pointer and 'void \\*'" } */ +TESTINI(fdd, fp, void *); /* { dg-warning "ISO C forbids initialization between function pointer and 'void \\*'" } */ +TESTRET(fde, fp, void *); /* { dg-warning "ISO C forbids return between function pointer and 'void \\*'" } */ + +TESTARG(dfa, void *, fp); /* { dg-warning "ISO C forbids passing argument 1 of 'dfaF' between function pointer and 'void \\*'" } */ +TESTARP(dfb, void *, fp); /* { dg-warning "ISO C forbids passing argument 1 of 'dfbFp.x' between function pointer and 'void \\*'" } */ +TESTASS(dfc, void *, fp); /* { dg-warning "ISO C forbids assignment between function pointer and 'void \\*'" } */ +TESTINI(dfd, void *, fp); /* { dg-warning "ISO C forbids initialization between function pointer and 'void \\*'" } */ +TESTRET(dfe, void *, fp); /* { dg-warning "ISO C forbids return between function pointer and 'void \\*'" } */ + +TESTARG(sua, int *, unsigned int *); /* { dg-warning "pointer targets in passing argument 1 of 'suaF' differ in signedness" } */ +TESTARP(sub, int *, unsigned int *); /* { dg-warning "pointer targets in passing argument 1 of 'subFp.x' differ in signedness" } */ +TESTASS(suc, int *, unsigned int *); /* { dg-warning "pointer targets in assignment from 'unsigned int \\*' to 'int \\*' differ in signedness" } */ +TESTINI(sud, int *, unsigned int *); /* { dg-warning "pointer targets in initialization of 'int \\*' from 'unsigned int \\*' differ in signedness" } */ +TESTRET(sue, int *, unsigned int *); /* { dg-warning "pointer targets in returning 'unsigned int \\*' from a function with return type 'int \\*' differ in signedness" } */ + +TESTARG(usa, unsigned int *, int *); /* { dg-warning "pointer targets in passing argument 1 of 'usaF' differ in signedness" } */ +TESTARP(usb, unsigned int *, int *); /* { dg-warning "pointer targets in passing argument 1 of 'usbFp.x' differ in signedness" } */ +TESTASS(usc, unsigned int *, int *); /* { dg-warning "pointer targets in assignment from 'int \\*' to 'unsigned int \\*' differ in signedness" } */ +TESTINI(usd, unsigned int *, int *); /* { dg-warning "pointer targets in initialization of 'unsigned int \\*' from 'int \\*' differ in signedness" } */ +TESTRET(use, unsigned int *, int *); /* { dg-warning "pointer targets in returning 'int \\*' from a function with return type 'unsigned int \\*' differ in signedness" } */ + +TESTARG(cua, char *, unsigned char *); /* { dg-warning "pointer targets in passing argument 1 of 'cuaF' differ in signedness" } */ +TESTARP(cub, char *, unsigned char *); /* { dg-warning "pointer targets in passing argument 1 of 'cubFp.x' differ in signedness" } */ +TESTASS(cuc, char *, unsigned char *); /* { dg-warning "pointer targets in assignment from 'unsigned char \\*' to 'char \\*' differ in signedness" } */ +TESTINI(cud, char *, unsigned char *); /* { dg-warning "pointer targets in initialization of 'char \\*' from 'unsigned char \\*' differ in signedness" } */ +TESTRET(cue, char *, unsigned char *); /* { dg-warning "pointer targets in returning 'unsigned char \\*' from a function with return type 'char \\*' differ in signedness" } */ + +TESTARG(uca, unsigned char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'ucaF' differ in signedness" } */ +TESTARP(ucb, unsigned char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'ucbFp.x' differ in signedness" } */ +TESTASS(ucc, unsigned char *, char *); /* { dg-warning "pointer targets in assignment from 'char \\*' to 'unsigned char \\*' differ in signedness" } */ +TESTINI(ucd, unsigned char *, char *); /* { dg-warning "pointer targets in initialization of 'unsigned char \\*' from 'char \\*' differ in signedness" } */ +TESTRET(uce, unsigned char *, char *); /* { dg-warning "pointer targets in returning 'char \\*' from a function with return type 'unsigned char \\*' differ in signedness" } */ + +TESTARG(csa, char *, signed char *); /* { dg-warning "pointer targets in passing argument 1 of 'csaF' differ in signedness" } */ +TESTARP(csb, char *, signed char *); /* { dg-warning "pointer targets in passing argument 1 of 'csbFp.x' differ in signedness" } */ +TESTASS(csc, char *, signed char *); /* { dg-warning "pointer targets in assignment from 'signed char \\*' to 'char \\*' differ in signedness" } */ +TESTINI(csd, char *, signed char *); /* { dg-warning "pointer targets in initialization of 'char \\*' from 'signed char \\*' differ in signedness" } */ +TESTRET(cse, char *, signed char *); /* { dg-warning "pointer targets in returning 'signed char \\*' from a function with return type 'char \\*' differ in signedness" } */ + +TESTARG(sca, signed char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'scaF' differ in signedness" } */ +TESTARP(scb, signed char *, char *); /* { dg-warning "pointer targets in passing argument 1 of 'scbFp.x' differ in signedness" } */ +TESTASS(scc, signed char *, char *); /* { dg-warning "pointer targets in assignment from 'char \\*' to 'signed char \\*' differ in signedness" } */ +TESTINI(scd, signed char *, char *); /* { dg-warning "pointer targets in initialization of 'signed char \\*' from 'char \\*' differ in signedness" } */ +TESTRET(sce, signed char *, char *); /* { dg-warning "pointer targets in returning 'char \\*' from a function with return type 'signed char \\*' differ in signedness" } */ + +TESTARG(cia, char *, int *); /* { dg-warning "passing argument 1 of 'ciaF' from incompatible pointer type" } */ +TESTARP(cib, char *, int *); /* { dg-warning "passing argument 1 of 'cibFp.x' from incompatible pointer type" } */ +TESTASS(cic, char *, int *); /* { dg-warning "assignment to 'char \\*' from incompatible pointer type 'int \\*'" } */ +TESTINI(cid, char *, int *); /* { dg-warning "initialization of 'char \\*' from incompatible pointer type 'int \\*'" } */ +TESTRET(cie, char *, int *); /* { dg-warning "returning 'int \\*' from a function with incompatible return type 'char \\*'" } */ + +TESTARG(ica, int *, char *); /* { dg-warning "passing argument 1 of 'icaF' from incompatible pointer type" } */ +TESTARP(icb, int *, char *); /* { dg-warning "passing argument 1 of 'icbFp.x' from incompatible pointer type" } */ +TESTASS(icc, int *, char *); /* { dg-warning "assignment to 'int \\*' from incompatible pointer type 'char \\*'" } */ +TESTINI(icd, int *, char *); /* { dg-warning "initialization of 'int \\*' from incompatible pointer type 'char \\*'" } */ +TESTRET(ice, int *, char *); /* { dg-warning "returning 'char \\*' from a function with incompatible return type 'int \\*'" } */ + +TESTARG(ciia, char *, int); /* { dg-warning "passing argument 1 of 'ciiaF' makes pointer from integer without a cast" } */ +TESTARP(ciib, char *, int); /* { dg-warning "passing argument 1 of 'ciibFp.x' makes pointer from integer without a cast" } */ +TESTASS(ciic, char *, int); /* { dg-warning "assignment to 'char \\*' from 'int' makes pointer from integer without a cast" } */ +TESTINI(ciid, char *, int); /* { dg-warning "initialization of 'char \\*' from 'int' makes pointer from integer without a cast" } */ +TESTRET(ciie, char *, int); /* { dg-warning "returning 'int' from a function with return type 'char \\*' makes pointer from integer without a cast" } */ + +TESTARG(iica, int, char *); /* { dg-warning "passing argument 1 of 'iicaF' makes integer from pointer without a cast" } */ +TESTARP(iicb, int, char *); /* { dg-warning "passing argument 1 of 'iicbFp.x' makes integer from pointer without a cast" } */ +TESTASS(iicc, int, char *); /* { dg-warning "assignment to 'int' from 'char \\*' makes integer from pointer without a cast" } */ +TESTINI(iicd, int, char *); /* { dg-warning "initialization of 'int' from 'char \\*' makes integer from pointer without a cast" } */ +TESTRET(iice, int, char *); /* { dg-warning "returning 'char \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ + +struct s { int a; }; + +TESTARG(stria, struct s, int); /* { dg-error "incompatible type for argument 1 of 'striaF'" } */ +TESTARP(strib, struct s, int); /* { dg-error "incompatible type for argument 1 of 'stribFp.x'" } */ +TESTASS(stric, struct s, int); /* { dg-error "incompatible types when assigning to type 'struct s' from type 'int'" } */ +TESTINI(strid, struct s, int); /* { dg-error "invalid initializer" } */ +TESTRET(strie, struct s, int); /* { dg-error "incompatible types when returning type 'int' but 'struct s' was expected" } */ + +TESTARG(istra, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istraF'" } */ + +TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istrbFp.x'" } */ + +TESTASS(istrc, int, struct s); /* { dg-error "incompatible types when assigning to type 'int' from type 'struct s'" } */ +TESTINI(istrd, int, struct s); /* { dg-error "incompatible types when initializing type 'int' using type 'struct s'" } */ +TESTRET(istre, int, struct s); /* { dg-error "incompatible types when returning type 'struct s' but 'int' was expected" } */ + +/* Match all extra informative notes. */ +/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/assign-warn-2.c b/SingleSource/Regression/C/gcc-dg/assign-warn-2.c new file mode 100644 index 0000000000..0c8a8ee783 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/assign-warn-2.c @@ -0,0 +1,125 @@ +/* Test diagnostics for bad implicit type conversions. + -pedantic-errors test. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -ftrack-macro-expansion=0" } */ + +#define TESTARG(ID, TL, TR) void ID##F(TL); void ID##F2(TR x) { ID##F(x); } extern int dummy +#define TESTARP(ID, TL, TR) struct { void (*x)(TL); } ID##Fp; void ID##F2(TR x) { ID##Fp.x(x); } extern int dummy +#define TESTASS(ID, TL, TR) void ID##F(TR x) { TL y; y = x; } extern int dummy +#define TESTINI(ID, TL, TR) void ID##F(TR x) { TL y = x; } extern int dummy +#define TESTRET(ID, TL, TR) TR ID##V; TL ID##F(void) { return ID##V; } extern int dummy + +typedef void (*fp)(void); +typedef void (*nrfp)(void) __attribute__((noreturn)); + +TESTARG(fqa, nrfp, fp); /* { dg-error "passing argument 1 of 'fqaF' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ +TESTARP(fqb, nrfp, fp); /* { dg-error "passing argument 1 of 'fqbFp.x' makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ +TESTASS(fqc, nrfp, fp); /* { dg-error "assignment makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ +TESTINI(fqd, nrfp, fp); /* { dg-error "initialization makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ +TESTRET(fqe, nrfp, fp); /* { dg-error "return makes '__attribute__..noreturn..' qualified function pointer from unqualified" } */ + +TESTARG(ofqa, fp, nrfp); +TESTARP(ofqb, fp, nrfp); +TESTASS(ofqc, fp, nrfp); +TESTINI(ofqd, fp, nrfp); +TESTRET(ofqe, fp, nrfp); + +TESTARG(qa, char *, const char *); /* { dg-error "passing argument 1 of 'qaF' discards 'const' qualifier from pointer target type" } */ +TESTARP(qb, char *, const char *); /* { dg-error "passing argument 1 of 'qbFp.x' discards 'const' qualifier from pointer target type" } */ +TESTASS(qc, char *, const char *); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ +TESTINI(qd, char *, const char *); /* { dg-error "initialization discards 'const' qualifier from pointer target type" } */ +TESTRET(qe, char *, const char *); /* { dg-error "return discards 'const' qualifier from pointer target type" } */ + +TESTARG(oqa, const char *, char *); +TESTARP(oqb, const char *, char *); +TESTASS(oqc, const char *, char *); +TESTINI(oqd, const char *, char *); +TESTRET(oqe, const char *, char *); + +TESTARG(fda, fp, void *); /* { dg-error "ISO C forbids passing argument 1 of 'fdaF' between function pointer and 'void \\*'" } */ +TESTARP(fdb, fp, void *); /* { dg-error "ISO C forbids passing argument 1 of 'fdbFp.x' between function pointer and 'void \\*'" } */ +TESTASS(fdc, fp, void *); /* { dg-error "ISO C forbids assignment between function pointer and 'void \\*'" } */ +TESTINI(fdd, fp, void *); /* { dg-error "ISO C forbids initialization between function pointer and 'void \\*'" } */ +TESTRET(fde, fp, void *); /* { dg-error "ISO C forbids return between function pointer and 'void \\*'" } */ + +TESTARG(dfa, void *, fp); /* { dg-error "ISO C forbids passing argument 1 of 'dfaF' between function pointer and 'void \\*'" } */ +TESTARP(dfb, void *, fp); /* { dg-error "ISO C forbids passing argument 1 of 'dfbFp.x' between function pointer and 'void \\*'" } */ +TESTASS(dfc, void *, fp); /* { dg-error "ISO C forbids assignment between function pointer and 'void \\*'" } */ +TESTINI(dfd, void *, fp); /* { dg-error "ISO C forbids initialization between function pointer and 'void \\*'" } */ +TESTRET(dfe, void *, fp); /* { dg-error "ISO C forbids return between function pointer and 'void \\*'" } */ + +TESTARG(sua, int *, unsigned int *); /* { dg-error "pointer targets in passing argument 1 of 'suaF' differ in signedness" } */ +TESTARP(sub, int *, unsigned int *); /* { dg-error "pointer targets in passing argument 1 of 'subFp.x' differ in signedness" } */ +TESTASS(suc, int *, unsigned int *); /* { dg-error "pointer targets in assignment from 'unsigned int \\*' to 'int \\*' differ in signedness" } */ +TESTINI(sud, int *, unsigned int *); /* { dg-error "pointer targets in initialization of 'int \\*' from 'unsigned int \\*' differ in signedness" } */ +TESTRET(sue, int *, unsigned int *); /* { dg-error "pointer targets in returning 'unsigned int \\*' from a function with return type 'int \\*' differ in signedness" } */ + +TESTARG(usa, unsigned int *, int *); /* { dg-error "pointer targets in passing argument 1 of 'usaF' differ in signedness" } */ +TESTARP(usb, unsigned int *, int *); /* { dg-error "pointer targets in passing argument 1 of 'usbFp.x' differ in signedness" } */ +TESTASS(usc, unsigned int *, int *); /* { dg-error "pointer targets in assignment from 'int \\*' to 'unsigned int \\*' differ in signedness" } */ +TESTINI(usd, unsigned int *, int *); /* { dg-error "pointer targets in initialization of 'unsigned int \\*' from 'int \\*' differ in signedness" } */ +TESTRET(use, unsigned int *, int *); /* { dg-error "pointer targets in returning 'int \\*' from a function with return type 'unsigned int \\*' differ in signedness" } */ + +TESTARG(cua, char *, unsigned char *); /* { dg-error "pointer targets in passing argument 1 of 'cuaF' differ in signedness" } */ +TESTARP(cub, char *, unsigned char *); /* { dg-error "pointer targets in passing argument 1 of 'cubFp.x' differ in signedness" } */ +TESTASS(cuc, char *, unsigned char *); /* { dg-error "pointer targets in assignment from 'unsigned char \\*' to 'char \\*' differ in signedness" } */ +TESTINI(cud, char *, unsigned char *); /* { dg-error "pointer targets in initialization of 'char \\*' from 'unsigned char \\*' differ in signedness" } */ +TESTRET(cue, char *, unsigned char *); /* { dg-error "pointer targets in returning 'unsigned char \\*' from a function with return type 'char \\*' differ in signedness" } */ + +TESTARG(uca, unsigned char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'ucaF' differ in signedness" } */ +TESTARP(ucb, unsigned char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'ucbFp.x' differ in signedness" } */ +TESTASS(ucc, unsigned char *, char *); /* { dg-error "pointer targets in assignment from 'char \\*' to 'unsigned char \\*' differ in signedness" } */ +TESTINI(ucd, unsigned char *, char *); /* { dg-error "pointer targets in initialization of 'unsigned char \\*' from 'char \\*' differ in signedness" } */ +TESTRET(uce, unsigned char *, char *); /* { dg-error "pointer targets in returning 'char \\*' from a function with return type 'unsigned char \\*' differ in signedness" } */ + +TESTARG(csa, char *, signed char *); /* { dg-error "pointer targets in passing argument 1 of 'csaF' differ in signedness" } */ +TESTARP(csb, char *, signed char *); /* { dg-error "pointer targets in passing argument 1 of 'csbFp.x' differ in signedness" } */ +TESTASS(csc, char *, signed char *); /* { dg-error "pointer targets in assignment from 'signed char \\*' to 'char \\*' differ in signedness" } */ +TESTINI(csd, char *, signed char *); /* { dg-error "pointer targets in initialization of 'char \\*' from 'signed char \\*' differ in signedness" } */ +TESTRET(cse, char *, signed char *); /* { dg-error "pointer targets in returning 'signed char \\*' from a function with return type 'char \\*' differ in signedness" } */ + +TESTARG(sca, signed char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'scaF' differ in signedness" } */ +TESTARP(scb, signed char *, char *); /* { dg-error "pointer targets in passing argument 1 of 'scbFp.x' differ in signedness" } */ +TESTASS(scc, signed char *, char *); /* { dg-error "pointer targets in assignment from 'char \\*' to 'signed char \\*' differ in signedness" } */ +TESTINI(scd, signed char *, char *); /* { dg-error "pointer targets in initialization of 'signed char \\*' from 'char \\*' differ in signedness" } */ +TESTRET(sce, signed char *, char *); /* { dg-error "pointer targets in returning 'char \\*' from a function with return type 'signed char \\*' differ in signedness" } */ + +TESTARG(cia, char *, int *); /* { dg-error "passing argument 1 of 'ciaF' from incompatible pointer type" } */ +TESTARP(cib, char *, int *); /* { dg-error "passing argument 1 of 'cibFp.x' from incompatible pointer type" } */ +TESTASS(cic, char *, int *); /* { dg-error "assignment to 'char \\*' from incompatible pointer type 'int \\*'" } */ +TESTINI(cid, char *, int *); /* { dg-error "initialization of 'char \\*' from incompatible pointer type 'int \\*'" } */ +TESTRET(cie, char *, int *); /* { dg-error "returning 'int \\*' from a function with incompatible return type 'char \\*'" } */ + +TESTARG(ica, int *, char *); /* { dg-error "passing argument 1 of 'icaF' from incompatible pointer type" } */ +TESTARP(icb, int *, char *); /* { dg-error "passing argument 1 of 'icbFp.x' from incompatible pointer type" } */ +TESTASS(icc, int *, char *); /* { dg-error "assignment to 'int \\*' from incompatible pointer type 'char \\*'" } */ +TESTINI(icd, int *, char *); /* { dg-error "initialization of 'int \\*' from incompatible pointer type 'char \\*'" } */ +TESTRET(ice, int *, char *); /* { dg-error "returning 'char \\*' from a function with incompatible return type 'int \\*'" } */ + +TESTARG(ciia, char *, int); /* { dg-error "passing argument 1 of 'ciiaF' makes pointer from integer without a cast" } */ +TESTARP(ciib, char *, int); /* { dg-error "passing argument 1 of 'ciibFp.x' makes pointer from integer without a cast" } */ +TESTASS(ciic, char *, int); /* { dg-error "assignment to 'char \\*' from 'int' makes pointer from integer without a cast" } */ +TESTINI(ciid, char *, int); /* { dg-error "initialization of 'char \\*' from 'int' makes pointer from integer without a cast" } */ +TESTRET(ciie, char *, int); /* { dg-error "returning 'int' from a function with return type 'char \\*' makes pointer from integer without a cast" } */ + +TESTARG(iica, int, char *); /* { dg-error "passing argument 1 of 'iicaF' makes integer from pointer without a cast" } */ +TESTARP(iicb, int, char *); /* { dg-error "passing argument 1 of 'iicbFp.x' makes integer from pointer without a cast" } */ +TESTASS(iicc, int, char *); /* { dg-error "assignment to 'int' from 'char \\*' makes integer from pointer without a cast" } */ +TESTINI(iicd, int, char *); /* { dg-error "initialization of 'int' from 'char \\*' makes integer from pointer without a cast" } */ +TESTRET(iice, int, char *); /* { dg-error "returning 'char \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ + +struct s { int a; }; + +TESTARG(stria, struct s, int); /* { dg-error "incompatible type for argument 1 of 'striaF'" } */ +TESTARP(strib, struct s, int); /* { dg-error "incompatible type for argument 1 of 'stribFp.x'" } */ +TESTASS(stric, struct s, int); /* { dg-error "incompatible types when assigning to type 'struct s' from type 'int'" } */ +TESTINI(strid, struct s, int); /* { dg-error "invalid initializer" } */ +TESTRET(strie, struct s, int); /* { dg-error "incompatible types when returning type 'int' but 'struct s' was expected" } */ + +TESTARG(istra, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istraF'" } */ +TESTARP(istrb, int, struct s); /* { dg-error "incompatible type for argument 1 of 'istrbFp.x'" } */ +TESTASS(istrc, int, struct s); /* { dg-error "incompatible types when assigning to type 'int' from type 'struct s'" } */ +TESTINI(istrd, int, struct s); /* { dg-error "incompatible types when initializing type 'int' using type 'struct s'" } */ +TESTRET(istre, int, struct s); /* { dg-error "incompatible types when returning type 'struct s' but 'int' was expected" } */ +/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/assign-warn-3.c b/SingleSource/Regression/C/gcc-dg/assign-warn-3.c new file mode 100644 index 0000000000..f415cc6a81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/assign-warn-3.c @@ -0,0 +1,13 @@ +/* Test diagnostics for bad type conversion when inlining unprototyped + functions: should not be errors with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-O3 -std=c99 -pedantic-errors" } */ + +/* This is valid to execute, so maybe shouldn't warn at all. */ +inline void f0(x) signed char *x; { } +void g0(unsigned char *x) { f0(x); } /* { dg-bogus "warning: pointer targets in passing argument 1 of 'f0' differ in signedness" } */ + +/* This is undefined on execution but still must compile. */ +inline void f1(x) int *x; { } +void g1(unsigned int *x) { f1(x); } /* { dg-bogus "warning: pointer targets in passing argument 1 of 'f1' differ in signedness" } */ diff --git a/SingleSource/Regression/C/gcc-dg/associative-math-1.c b/SingleSource/Regression/C/gcc-dg/associative-math-1.c new file mode 100644 index 0000000000..3f9ce5b4bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/associative-math-1.c @@ -0,0 +1,17 @@ +/* Test __ASSOCIATIVE_MATH__ is defined with -fassociative-math. */ +/* { dg-do compile } */ +/* { dg-options "-fassociative-math -fno-signed-zeros -fno-trapping-math" } */ + +#ifndef __ASSOCIATIVE_MATH__ +#error "__ASSOCIATIVE_MATH__ not defined" +#endif + +#pragma GCC optimize "-fno-associative-math" +#ifdef __ASSOCIATIVE_MATH__ +#error "__ASSOCIATIVE_MATH__ defined" +#endif + +#pragma GCC optimize "-fassociative-math" +#ifndef __ASSOCIATIVE_MATH__ +#error "__ASSOCIATIVE_MATH__ not defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/associative-math-2.c b/SingleSource/Regression/C/gcc-dg/associative-math-2.c new file mode 100644 index 0000000000..764d6f01bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/associative-math-2.c @@ -0,0 +1,17 @@ +/* Test __ASSOCIATIVE_MATH__ is not defined with -fno-associative-math. */ +/* { dg-do compile } */ +/* { dg-options "-fno-associative-math" } */ + +#ifdef __ASSOCIATIVE_MATH__ +#error "__ASSOCIATIVE_MATH__ defined" +#endif + +#pragma GCC optimize "-fassociative-math" +#ifndef __ASSOCIATIVE_MATH__ +#error "__ASSOCIATIVE_MATH__ not defined" +#endif + +#pragma GCC optimize "-fno-associative-math" +#ifdef __ASSOCIATIVE_MATH__ +#error "__ASSOCIATIVE_MATH__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-1.c b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-1.c new file mode 100644 index 0000000000..4b999c682f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-1.c @@ -0,0 +1,86 @@ +/* Test __atomic routines for existence and proper execution on 1 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + +/* Test the execution of the __atomic_compare_exchange_n builtin for a char. */ + +extern void abort(void); + +char v = 0; +char expected = 0; +char max = ~0; +char desired = ~0; +char zero = 0; + +#define STRONG 0 +#define WEAK 1 + +int +main () +{ + + if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + /* Now test the generic version. */ + + v = 0; + + if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-2.c b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-2.c new file mode 100644 index 0000000000..736e358a6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-2.c @@ -0,0 +1,86 @@ +/* Test __atomic routines for existence and proper execution on 2 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + +/* Test the execution of the __atomic_compare_exchange_n builtin for a short. */ + +extern void abort(void); + +short v = 0; +short expected = 0; +short max = ~0; +short desired = ~0; +short zero = 0; + +#define STRONG 0 +#define WEAK 1 + +int +main () +{ + + if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + /* Now test the generic version. */ + + v = 0; + + if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-3.c b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-3.c new file mode 100644 index 0000000000..91a67cd742 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-3.c @@ -0,0 +1,86 @@ +/* Test __atomic routines for existence and proper execution on 4 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ + +/* Test the execution of the __atomic_compare_exchange_n builtin for an int. */ + +extern void abort(void); + +int v = 0; +int expected = 0; +int max = ~0; +int desired = ~0; +int zero = 0; + +#define STRONG 0 +#define WEAK 1 + +int +main () +{ + + if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + /* Now test the generic version. */ + + v = 0; + + if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-4.c b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-4.c new file mode 100644 index 0000000000..ac9531b782 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-4.c @@ -0,0 +1,88 @@ +/* Test __atomic routines for existence and proper execution on 8 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_long_long_runtime } */ +/* { dg-options "" } */ +/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* Test the execution of __atomic_compare_exchange_n builtin for a long_long. */ + +extern void abort(void); + +long long v = 0; +long long expected = 0; +long long max = ~0; +long long desired = ~0; +long long zero = 0; + +#define STRONG 0 +#define WEAK 1 + +int +main () +{ + + if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + /* Now test the generic version. */ + + v = 0; + + if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-5.c b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-5.c new file mode 100644 index 0000000000..f5d071affe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-compare-exchange-5.c @@ -0,0 +1,87 @@ +/* Test __atomic routines for existence and proper execution on 16 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_128_runtime } */ +/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ + +/* Test the execution of __atomic_compare_exchange_n builtin for an int_128. */ + +extern void abort(void); + +__int128_t v = 0; +__int128_t expected = 0; +__int128_t max = ~0; +__int128_t desired = ~0; +__int128_t zero = 0; + +#define STRONG 0 +#define WEAK 1 + +int +main () +{ + + if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + /* Now test the generic version. */ + + v = 0; + + if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + abort (); + if (expected != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) + abort (); + if (expected != max) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) + abort (); + if (expected != max) + abort (); + if (v != 0) + abort (); + + if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) + abort (); + if (expected != 0) + abort (); + + if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) + abort (); + if (expected != 0) + abort (); + if (v != max) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-exchange-1.c b/SingleSource/Regression/C/gcc-dg/atomic-exchange-1.c new file mode 100644 index 0000000000..ec8a09c8cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-exchange-1.c @@ -0,0 +1,68 @@ +/* Test __atomic routines for existence and proper execution on 1 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + +/* Test the execution of the __atomic_exchange_n builtin for a char. */ + +extern void abort(void); + +char v, count, ret; + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count) + abort (); + count++; + + /* Now test the generic version. */ + + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST); + if (ret != count - 1 || v != count) + abort (); + count++; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-exchange-2.c b/SingleSource/Regression/C/gcc-dg/atomic-exchange-2.c new file mode 100644 index 0000000000..0de2e68208 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-exchange-2.c @@ -0,0 +1,68 @@ +/* Test __atomic routines for existence and proper execution on 2 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + +/* Test the execution of the __atomic_X builtin for a short. */ + +extern void abort(void); + +short v, count, ret; + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count) + abort (); + count++; + + /* Now test the generic version. */ + + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST); + if (ret != count - 1 || v != count) + abort (); + count++; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-exchange-3.c b/SingleSource/Regression/C/gcc-dg/atomic-exchange-3.c new file mode 100644 index 0000000000..63a68cf473 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-exchange-3.c @@ -0,0 +1,68 @@ +/* Test __atomic routines for existence and proper execution on 4 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ + +/* Test the execution of the __atomic_X builtin for an int. */ + +extern void abort(void); + +int v, count, ret; + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count) + abort (); + count++; + + /* Now test the generic version. */ + + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST); + if (ret != count - 1 || v != count) + abort (); + count++; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-exchange-4.c b/SingleSource/Regression/C/gcc-dg/atomic-exchange-4.c new file mode 100644 index 0000000000..fc1e5081a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-exchange-4.c @@ -0,0 +1,70 @@ +/* Test __atomic routines for existence and proper execution on 8 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_long_long_runtime } */ +/* { dg-options "" } */ +/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* Test the execution of the __atomic_X builtin for a long_long. */ + +extern void abort(void); + +long long v, count, ret; + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count) + abort (); + count++; + + /* Now test the generic version. */ + + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST); + if (ret != count - 1 || v != count) + abort (); + count++; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-exchange-5.c b/SingleSource/Regression/C/gcc-dg/atomic-exchange-5.c new file mode 100644 index 0000000000..190377f0cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-exchange-5.c @@ -0,0 +1,69 @@ +/* Test __atomic routines for existence and proper execution on 16 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_128_runtime } */ +/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ + +/* Test the execution of the __atomic_X builtin for a 16 byte value. */ + +extern void abort(void); + +__int128_t v, count, ret; + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count) + abort (); + count++; + + if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count) + abort (); + count++; + + /* Now test the generic version. */ + + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL); + if (ret != count - 1 || v != count) + abort (); + count++; + + __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST); + if (ret != count - 1 || v != count) + abort (); + count++; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-fence.c b/SingleSource/Regression/C/gcc-dg/atomic-fence.c new file mode 100644 index 0000000000..ab5c7d62c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-fence.c @@ -0,0 +1,28 @@ +/* Test __atomic routines for existence and execution with each valid + memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + + +/* Test that __atomic_{thread,signal}_fence builtins execute. */ + +int +main () +{ + __atomic_thread_fence (__ATOMIC_RELAXED); + __atomic_thread_fence (__ATOMIC_CONSUME); + __atomic_thread_fence (__ATOMIC_ACQUIRE); + __atomic_thread_fence (__ATOMIC_RELEASE); + __atomic_thread_fence (__ATOMIC_ACQ_REL); + __atomic_thread_fence (__ATOMIC_SEQ_CST); + + __atomic_signal_fence (__ATOMIC_RELAXED); + __atomic_signal_fence (__ATOMIC_CONSUME); + __atomic_signal_fence (__ATOMIC_ACQUIRE); + __atomic_signal_fence (__ATOMIC_RELEASE); + __atomic_signal_fence (__ATOMIC_ACQ_REL); + __atomic_signal_fence (__ATOMIC_SEQ_CST); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-fetch-bool.c b/SingleSource/Regression/C/gcc-dg/atomic-fetch-bool.c new file mode 100644 index 0000000000..f7af11f5c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-fetch-bool.c @@ -0,0 +1,64 @@ +/* PR c/68966 - atomic_fetch_* on atomic_bool not diagnosed + Test to verify that calls to __atomic_fetch_op funcions with a _Bool + argument are rejected. This is necessary because GCC expects that + all initialized _Bool objects have a specific representation and + allowing atomic operations to change it would break the invariant. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c11" } */ + + +void test_atomic_bool (_Atomic _Bool *a) +{ + enum { SEQ_CST = __ATOMIC_SEQ_CST }; + + __atomic_fetch_add (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_add." } */ + __atomic_fetch_sub (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_sub." } */ + __atomic_fetch_and (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_and." } */ + __atomic_fetch_xor (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_xor." } */ + __atomic_fetch_or (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_or." } */ + __atomic_fetch_nand (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_nand." } */ + + __atomic_add_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_add_fetch." } */ + __atomic_sub_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_sub_fetch." } */ + __atomic_and_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_and_fetch." } */ + __atomic_xor_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_xor_fetch." } */ + __atomic_or_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_or_fetch." } */ + __atomic_nand_fetch (a, 1, SEQ_CST); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_nand_fetch." } */ + + /* The following are valid and must be accepted. */ + _Bool val = 0, ret = 0; + __atomic_exchange (a, &val, &ret, SEQ_CST); + __atomic_exchange_n (a, val, SEQ_CST); + __atomic_compare_exchange (a, &val, &ret, !1, SEQ_CST, SEQ_CST); + __atomic_compare_exchange_n (a, &val, ret, !1, SEQ_CST, SEQ_CST); + __atomic_test_and_set (a, SEQ_CST); + __atomic_clear (a, SEQ_CST); +} + +void test_bool (_Bool *b) +{ + enum { SEQ_CST = __ATOMIC_SEQ_CST }; + + __atomic_fetch_add (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_fetch_add." } */ + __atomic_fetch_sub (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_fetch_sub." } */ + __atomic_fetch_and (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_fetch_and." } */ + __atomic_fetch_xor (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_fetch_xor." } */ + __atomic_fetch_or (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_fetch_or." } */ + __atomic_fetch_nand (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_fetch_nand." } */ + + __atomic_add_fetch (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_add_fetch." } */ + __atomic_sub_fetch (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_sub_fetch." } */ + __atomic_and_fetch (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_and_fetch." } */ + __atomic_xor_fetch (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_xor_fetch." } */ + __atomic_or_fetch (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_or_fetch." } */ + __atomic_nand_fetch (b, 1, SEQ_CST); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__atomic_nand_fetch." } */ + + /* The following are valid and must be accepted. */ + _Bool val = 0, ret = 0; + __atomic_exchange (b, &val, &ret, SEQ_CST); + __atomic_exchange_n (b, val, SEQ_CST); + __atomic_compare_exchange (b, &val, &ret, !1, SEQ_CST, SEQ_CST); + __atomic_compare_exchange_n (b, &val, ret, !1, SEQ_CST, SEQ_CST); + __atomic_test_and_set (b, SEQ_CST); + __atomic_clear (b, SEQ_CST); +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-flag.c b/SingleSource/Regression/C/gcc-dg/atomic-flag.c new file mode 100644 index 0000000000..6e79b90272 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-flag.c @@ -0,0 +1,32 @@ +/* Test __atomic routines for existence and execution. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + +/* Test that __atomic_test_and_set and __atomic_clear builtins execute. */ + +extern void abort(void); +unsigned char a; + +int +main () +{ + int b; + + __atomic_clear (&a, __ATOMIC_RELAXED); + if (a != 0) + abort (); + + b = __atomic_test_and_set (&a, __ATOMIC_SEQ_CST); + if (a != __GCC_ATOMIC_TEST_AND_SET_TRUEVAL || b != 0) + abort (); + + b = __atomic_test_and_set (&a, __ATOMIC_ACQ_REL); + if (a != __GCC_ATOMIC_TEST_AND_SET_TRUEVAL || b != 1) + abort (); + + __atomic_clear (&a, __ATOMIC_SEQ_CST); + if (a != 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-generic-aux.c b/SingleSource/Regression/C/gcc-dg/atomic-generic-aux.c new file mode 100644 index 0000000000..73e1ed8539 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-generic-aux.c @@ -0,0 +1,58 @@ +/* Supply a set of generic atomic functions to test the compiler make the + calls properly. */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +/* Test that the generic builtins make calls as expected. */ + +#include +#include +#include + +void +__atomic_exchange (size_t size, void *obj, void *val, void *ret, int model) +{ + /* Copy old value into *ret. */ + memcpy (ret, obj, size); + /* Copy val into object. */ + memcpy (obj, val, size); +} + + +/* Note that the external version of this routine has the boolean weak/strong + parameter removed. This is required by the external library. */ +bool +__atomic_compare_exchange (size_t size, void *obj, void *expected, + void *desired, int model1, int model2) +{ + bool ret; + if (!memcmp (obj, expected, size)) + { + memcpy (obj, desired, size); + ret = true; + } + else + { + memcpy (expected, obj, size); + ret = false; + } + + /* Make sure the parameters have been properly adjusted for the external + function call (no weak/strong parameter. */ + if (model1 != __ATOMIC_SEQ_CST || model2 != __ATOMIC_ACQUIRE) + ret = !ret; + + return ret; +} + + +void __atomic_load (size_t size, void *obj, void *ret, int model) +{ + memcpy (ret, obj, size); +} + + +void __atomic_store (size_t size, void *obj, void *val, int model) +{ + memcpy (obj, val, size); +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-generic.c b/SingleSource/Regression/C/gcc-dg/atomic-generic.c new file mode 100644 index 0000000000..0e40630240 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-generic.c @@ -0,0 +1,58 @@ +/* Test generic __atomic routines for proper function calling. + memory model. */ +/* { dg-options "-w" } */ +/* { dg-do run } */ +/* { dg-additional-sources "atomic-generic-aux.c" } */ + +/* Test that the generioc atomic builtins execute as expected.. + sync-mem-generic-aux.c supplies a functional external entry point for + the 4 generic functions. */ + +#include +#include +#include + +extern void abort(); + +typedef struct test { + int array[10]; +} test_struct; + +test_struct zero = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +test_struct ones = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; +test_struct a,b; + +int size = sizeof (test_struct); +/* Test for consistency on sizes 1, 2, 4, 8, 16 and 32. */ +int +main () +{ + test_struct c; + + __atomic_store (&a, &zero, __ATOMIC_RELAXED); + if (memcmp (&a, &zero, size)) + abort (); + + __atomic_exchange (&a, &ones, &c, __ATOMIC_SEQ_CST); + if (memcmp (&c, &zero, size)) + abort (); + if (memcmp (&a, &ones, size)) + abort (); + + __atomic_load (&a, &b, __ATOMIC_RELAXED); + if (memcmp (&b, &ones, size)) + abort (); + + if (!__atomic_compare_exchange (&a, &b, &zero, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE)) + abort(); + if (memcmp (&a, &zero, size)) + abort (); + + if (__atomic_compare_exchange (&a, &b, &ones, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE)) + abort(); + if (memcmp (&b, &zero, size)) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-invalid-2.c b/SingleSource/Regression/C/gcc-dg/atomic-invalid-2.c new file mode 100644 index 0000000000..220432c34d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-invalid-2.c @@ -0,0 +1,59 @@ +/* PR c/69104. Test atomic routines for invalid memory model errors. This + only needs to be tested on a single size. */ +/* { dg-do compile } */ +/* { dg-require-effective-target sync_int_long } */ + +#include + +/* atomic_store_explicit(): + The order argument shall not be memory_order_acquire, + memory_order_consume, nor memory_order_acq_rel. */ + +void +store (atomic_int *i) +{ + atomic_store_explicit (i, 0, memory_order_consume); /* { dg-warning "invalid memory model" } */ + atomic_store_explicit (i, 0, memory_order_acquire); /* { dg-warning "invalid memory model" } */ + atomic_store_explicit (i, 0, memory_order_acq_rel); /* { dg-warning "invalid memory model" } */ +} + +/* atomic_load_explicit(): + The order argument shall not be memory_order_release nor + memory_order_acq_rel. */ + +void +load (atomic_int *i) +{ + atomic_int j = atomic_load_explicit (i, memory_order_release); /* { dg-warning "invalid memory model" } */ + atomic_int k = atomic_load_explicit (i, memory_order_acq_rel); /* { dg-warning "invalid memory model" } */ +} + +/* atomic_compare_exchange(): + The failure argument shall not be memory_order_release nor + memory_order_acq_rel. The failure argument shall be no stronger than the + success argument. */ + +void +exchange (atomic_int *i) +{ + int r; + + atomic_compare_exchange_strong_explicit (i, &r, 0, memory_order_seq_cst, memory_order_release); /* { dg-warning "invalid failure memory model 'memory_order_release'" } */ + atomic_compare_exchange_strong_explicit (i, &r, 0, memory_order_seq_cst, memory_order_acq_rel); /* { dg-warning "invalid failure memory model 'memory_order_acq_rel'" } */ + atomic_compare_exchange_strong_explicit (i, &r, 0, memory_order_relaxed, memory_order_consume); /* { dg-warning "failure memory model 'memory_order_consume' cannot be stronger than success memory model 'memory_order_relaxed'" } */ + + atomic_compare_exchange_weak_explicit (i, &r, 0, memory_order_seq_cst, memory_order_release); /* { dg-warning "invalid failure memory model 'memory_order_release'" } */ + atomic_compare_exchange_weak_explicit (i, &r, 0, memory_order_seq_cst, memory_order_acq_rel); /* { dg-warning "invalid failure memory model 'memory_order_acq_rel'" } */ + atomic_compare_exchange_weak_explicit (i, &r, 0, memory_order_relaxed, memory_order_consume); /* { dg-warning "failure memory model 'memory_order_consume' cannot be stronger than success memory model 'memory_order_relaxed'" } */ +} + +/* atomic_flag_clear(): + The order argument shall not be memory_order_acquire nor + memory_order_acq_rel. */ + +void +clear (atomic_int *i) +{ + atomic_flag_clear_explicit (i, memory_order_acquire); /* { dg-warning "invalid memory model" } */ + atomic_flag_clear_explicit (i, memory_order_acq_rel); /* { dg-warning "invalid memory model" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-invalid.c b/SingleSource/Regression/C/gcc-dg/atomic-invalid.c new file mode 100644 index 0000000000..26da5b725e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-invalid.c @@ -0,0 +1,36 @@ +/* Test __atomic routines for invalid memory model errors. This only needs + to be tested on a single size. */ +/* { dg-do compile } */ +/* { dg-require-effective-target sync_int_long } */ + +#include +#include + +int i, e, b; +size_t s; +bool x; + +int +main () +{ + __atomic_compare_exchange_n (&i, &e, 1, 0, __ATOMIC_RELAXED, __ATOMIC_SEQ_CST); /* { dg-warning "failure memory model 'memory_order_seq_cst' cannot be stronger" } */ + __atomic_compare_exchange_n (&i, &e, 1, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELEASE); /* { dg-warning "invalid failure memory" } */ + __atomic_compare_exchange_n (&i, &e, 1, 1, __ATOMIC_SEQ_CST, __ATOMIC_ACQ_REL); /* { dg-warning "invalid failure memory" } */ + + __atomic_load_n (&i, __ATOMIC_RELEASE); /* { dg-warning "invalid memory model" } */ + __atomic_load_n (&i, __ATOMIC_ACQ_REL); /* { dg-warning "invalid memory model" } */ + + __atomic_store_n (&i, 1, __ATOMIC_ACQUIRE); /* { dg-warning "invalid memory model" } */ + __atomic_store_n (&i, 1, __ATOMIC_CONSUME); /* { dg-warning "invalid memory model" } */ + __atomic_store_n (&i, 1, __ATOMIC_ACQ_REL); /* { dg-warning "invalid memory model" } */ + + i = __atomic_always_lock_free (s, NULL); /* { dg-error "non-constant argument" } */ + + __atomic_load_n (&i, 44); /* { dg-warning "invalid memory model" } */ + + __atomic_clear (&x, __ATOMIC_CONSUME); /* { dg-warning "invalid memory model" } */ + __atomic_clear (&x, __ATOMIC_ACQUIRE); /* { dg-warning "invalid memory model" } */ + + __atomic_clear (&x, __ATOMIC_ACQ_REL); /* { dg-warning "invalid memory model" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-load-1.c b/SingleSource/Regression/C/gcc-dg/atomic-load-1.c new file mode 100644 index 0000000000..72ca317f20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-load-1.c @@ -0,0 +1,67 @@ +/* Test __atomic routines for existence and proper execution on 1 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + + +/* Test the execution of the __atomic_load_n builtin for a char. */ + +extern void abort(void); + +char v, count; + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++) + abort(); + else + v++; + + /* Now test the generic variants. */ + + __atomic_load (&v, &count, __ATOMIC_RELAXED); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_ACQUIRE); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_CONSUME); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_SEQ_CST); + if (count != v) + abort(); + else + v++; + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-load-2.c b/SingleSource/Regression/C/gcc-dg/atomic-load-2.c new file mode 100644 index 0000000000..e937a2dab8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-load-2.c @@ -0,0 +1,69 @@ +/* Test __atomic routines for existence and proper execution on 2 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + + +/* Test the execution of the __atomic_load_n builtin for a short. */ + +extern void abort(void); + +short v, count; + + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++) + abort(); + else + v++; + + /* Now test the generic variants. */ + + __atomic_load (&v, &count, __ATOMIC_RELAXED); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_ACQUIRE); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_CONSUME); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_SEQ_CST); + if (count != v) + abort(); + else + v++; + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-load-3.c b/SingleSource/Regression/C/gcc-dg/atomic-load-3.c new file mode 100644 index 0000000000..3e70ef429f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-load-3.c @@ -0,0 +1,66 @@ +/* Test __atomic routines for existence and proper execution on 4 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ + +extern void abort(void); + +int v, count; + + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++) + abort(); + else + v++; + + /* Now test the generic variants. */ + + __atomic_load (&v, &count, __ATOMIC_RELAXED); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_ACQUIRE); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_CONSUME); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_SEQ_CST); + if (count != v) + abort(); + else + v++; + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-load-4.c b/SingleSource/Regression/C/gcc-dg/atomic-load-4.c new file mode 100644 index 0000000000..750623dcb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-load-4.c @@ -0,0 +1,67 @@ +/* Test __atomic routines for existence and proper execution on 8 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_long_long_runtime } */ +/* { dg-options "" } */ +/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern void abort(void); + +long long v, count; + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++) + abort(); + else + v++; + + /* Now test the generic variants. */ + + __atomic_load (&v, &count, __ATOMIC_RELAXED); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_ACQUIRE); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_CONSUME); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_SEQ_CST); + if (count != v) + abort(); + else + v++; + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-load-5.c b/SingleSource/Regression/C/gcc-dg/atomic-load-5.c new file mode 100644 index 0000000000..d37d642489 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-load-5.c @@ -0,0 +1,66 @@ +/* Test __atomic routines for existence and proper execution on 16 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_128_runtime } */ +/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ + +extern void abort(void); + +__int128_t v, count; + +int +main () +{ + v = 0; + count = 0; + + if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++) + abort(); + else + v++; + + if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++) + abort(); + else + v++; + + /* Now test the generic variants. */ + + __atomic_load (&v, &count, __ATOMIC_RELAXED); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_ACQUIRE); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_CONSUME); + if (count != v) + abort(); + else + v++; + + __atomic_load (&v, &count, __ATOMIC_SEQ_CST); + if (count != v) + abort(); + else + v++; + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-lockfree-aux.c b/SingleSource/Regression/C/gcc-dg/atomic-lockfree-aux.c new file mode 100644 index 0000000000..0ea872c302 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-lockfree-aux.c @@ -0,0 +1,17 @@ +/* Test supply a __atomic_is_lock_free routine for lock-free tests. */ +/* Just compile it on its own. */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +/* Test that __atomic_{is,always}_lock_free builtins execute. */ + +#include + +/* Supply a builtin external function which returns a non-standard value so + it can be detected that it was called. */ +int +__atomic_is_lock_free (size_t s, void *p) +{ + return 2; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-lockfree.c b/SingleSource/Regression/C/gcc-dg/atomic-lockfree.c new file mode 100644 index 0000000000..093aee9199 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-lockfree.c @@ -0,0 +1,121 @@ +/* Test __atomic routines for existence and execution with each valid + memory model. */ +/* { dg-options "-w" } */ +/* { dg-do run } */ +/* { dg-additional-sources "atomic-lockfree-aux.c" } */ + +/* Test that __atomic_{is,always}_lock_free builtins execute. + sync-mem-lockfree-aux.c supplies and external entry point for + __atomic_is_lock_free which always returns a 2. We can detect the + external routine was called if 2 is returned since that is not a valid + result normally. */ + +#include + +extern void abort(); + +int r1, r2; + +/* Test for consistency on sizes 1, 2, 4, 8, 16 and 32. */ +int +main () +{ + + r1 = __atomic_always_lock_free (sizeof(char), 0); + r2 = __atomic_is_lock_free (sizeof(char), 0); + /* If always lock free, then is_lock_free must also be true. */ + if (r1) + { + if (r2 != 1) + abort (); + } + else + { + /* If it is not lock free, then the external routine must be called. */ + if (r2 != 2) + abort (); + } + + r1 = __atomic_always_lock_free (2, 0); + r2 = __atomic_is_lock_free (2, 0); + /* If always lock free, then is_lock_free must also be true. */ + if (r1) + { + if (r2 != 1) + abort (); + } + else + { + /* If it is not lock free, then the external routine must be called. */ + if (r2 != 2) + abort (); + } + + + r1 = __atomic_always_lock_free (4, 0); + r2 = __atomic_is_lock_free (4, 0); /* Try passing in a variable. */ + /* If always lock free, then is_lock_free must also be true. */ + if (r1) + { + if (r2 != 1) + abort (); + } + else + { + /* If it is not lock free, then the external routine must be called. */ + if (r2 != 2) + abort (); + } + + + r1 = __atomic_always_lock_free (8, 0); + r2 = __atomic_is_lock_free (8, 0); + /* If always lock free, then is_lock_free must also be true. */ + if (r1) + { + if (r2 != 1) + abort (); + } + else + { + /* If it is not lock free, then the external routine must be called. */ + if (r2 != 2) + abort (); + } + + + r1 = __atomic_always_lock_free (16, 0); + r2 = __atomic_is_lock_free (16, 0); + /* If always lock free, then is_lock_free must also be true. */ + if (r1) + { + if (r2 != 1) + abort (); + } + else + { + /* If it is not lock free, then the external routine must be called. */ + if (r2 != 2) + abort (); + } + + + r1 = __atomic_always_lock_free (32, 0); + r2 = __atomic_is_lock_free (32, 0); + /* If always lock free, then is_lock_free must also be true. */ + if (r1) + { + if (r2 != 1) + abort (); + } + else + { + /* If it is not lock free, then the external routine must be called. */ + if (r2 != 2) + abort (); + } + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-noinline-aux.c b/SingleSource/Regression/C/gcc-dg/atomic-noinline-aux.c new file mode 100644 index 0000000000..f0e3387b98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-noinline-aux.c @@ -0,0 +1,72 @@ +/* Supply a set of generic atomic functions to test the compiler make the + calls properly. */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +/* Test that the generic builtins make calls as expected. This file provides + the exact entry points the test file will require. All these routines + simply set the first parameter to 1, and the caller will test for that. */ + +#include +#include +#include +#include + + +char +__atomic_exchange_1 (char *p, char t, int i) +{ + *p = 1; +} + +short +__atomic_load_2 (short *p, int i) +{ + *p = 1; +} + +void +__atomic_store_1 (char *p, char v, int i) +{ + *p = 1; +} + +int __atomic_compare_exchange_2 (short *p, short *a, short b, int y, int z) +{ + /* Fail if the memory models aren't correct as that will indicate the external + call has failed to remove the weak/strong parameter as required by the + library. */ + if (y != __ATOMIC_SEQ_CST || z != __ATOMIC_ACQUIRE) + *p = 0; + else + *p = 1; +} + +char __atomic_fetch_add_1 (char *p, char v, int i) +{ + *p = 1; +} + +short __atomic_fetch_add_2 (short *p, short v, int i) +{ + *p = 1; +} + +/* Really perform a NAND. PR51040 showed incorrect calculation of a + non-inlined fetch_nand. */ +unsigned char +__atomic_fetch_nand_1 (unsigned char *p, unsigned char v, int i) +{ + unsigned char ret; + + ret = *p; + *p = ~(*p & v); + + return ret; +} + +bool __atomic_is_lock_free (size_t i, void *p) +{ + *(short *)p = 1; + return true; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-noinline.c b/SingleSource/Regression/C/gcc-dg/atomic-noinline.c new file mode 100644 index 0000000000..99912cc87e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-noinline.c @@ -0,0 +1,61 @@ +/* Test generic __atomic routines for proper function calling. + memory model. */ +/* { dg-options "-w -fno-inline-atomics" } */ +/* { dg-do run } */ +/* { dg-additional-sources "atomic-noinline-aux.c" } */ + +/* Test that -fno-inline-atomics works as expected. + atomic-generic-aux provide the expected routines which simply set the + value of the first parameter to */ + +#include +#include + +extern void abort (void); + +short as,bs,cs,ds; +char ac,bc,cc; + +int +main (void) +{ + + ac = __atomic_exchange_n (&bc, cc, __ATOMIC_RELAXED); + if (bc != 1) + abort (); + + as = __atomic_load_n (&bs, __ATOMIC_SEQ_CST); + if (bs != 1) + abort (); + + __atomic_store_n (&ac, bc, __ATOMIC_RELAXED); + if (ac != 1) + abort (); + + __atomic_compare_exchange_n (&as, &bs, cs, 0, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); + if (as != 1) + abort (); + + ac = __atomic_fetch_add (&cc, 15, __ATOMIC_SEQ_CST); + if (cc != 1) + abort (); + + /* This should be translated to __atomic_fetch_add for the library */ + as = __atomic_add_fetch (&cs, 10, __ATOMIC_RELAXED); + if (cs != 1) + abort (); + + /* PR 51040 was caused by arithmetic code not patching up nand_fetch properly + when used an an external function. Look for proper return value here. */ + ac = 0x3C; + bc = __atomic_nand_fetch (&ac, 0x0f, __ATOMIC_RELAXED); + if (bc != ac) + abort (); + + if (!__atomic_is_lock_free (2, &ds)) + abort (); + if (ds != 1) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-op-1.c b/SingleSource/Regression/C/gcc-dg/atomic-op-1.c new file mode 100644 index 0000000000..a8a97c401b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-op-1.c @@ -0,0 +1,555 @@ +/* Test __atomic routines for existence and proper execution on 1 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + +/* Test the execution of the __atomic_*OP builtin routines for a char. */ + +extern void abort(void); + +char v, count, res; +const char init = ~0; + +/* The fetch_op routines return the original value before the operation. */ + +void +test_fetch_add () +{ + v = 0; + count = 1; + + if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5) + abort (); +} + + +void +test_fetch_sub() +{ + v = res = 20; + count = 0; + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--) + abort (); +} + +void +test_fetch_and () +{ + v = init; + + if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_fetch_nand () +{ + v = init; + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 ) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_xor () +{ + v = init; + count = 0; + + if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_or () +{ + v = 0; + count = 1; + + if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31) + abort (); +} + +/* The OP_fetch routines return the new value after the operation. */ + +void +test_add_fetch () +{ + v = 0; + count = 1; + + if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6) + abort (); +} + + +void +test_sub_fetch () +{ + v = res = 20; + count = 0; + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res) + abort (); +} + +void +test_and_fetch () +{ + v = init; + + if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0) + abort (); + + v = init; + if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_nand_fetch () +{ + v = init; + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + + + +void +test_xor_fetch () +{ + v = init; + count = 0; + + if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_or_fetch () +{ + v = 0; + count = 1; + + if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63) + abort (); +} + + +/* Test the OP routines with a result which isn't used. Use both variations + within each function. */ + +void +test_add () +{ + v = 0; + count = 1; + + __atomic_add_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_CONSUME); + if (v != 2) + abort (); + + __atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE); + if (v != 3) + abort (); + + __atomic_fetch_add (&v, 1, __ATOMIC_RELEASE); + if (v != 4) + abort (); + + __atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 5) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST); + if (v != 6) + abort (); +} + + +void +test_sub() +{ + v = res = 20; + count = 0; + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != --res) + abort (); +} + +void +test_and () +{ + v = init; + + __atomic_and_fetch (&v, 0, __ATOMIC_RELAXED); + if (v != 0) + abort (); + + v = init; + __atomic_fetch_and (&v, init, __ATOMIC_CONSUME); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, init, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_nand () +{ + v = init; + + __atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, init, __ATOMIC_RELEASE); + if (v != 0) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST); + if (v != init) + abort (); +} + + + +void +test_xor () +{ + v = init; + count = 0; + + __atomic_xor_fetch (&v, count, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_or () +{ + v = 0; + count = 1; + + __atomic_or_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_CONSUME); + if (v != 3) + abort (); + + count *= 2; + __atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE); + if (v != 7) + abort (); + + count *= 2; + __atomic_fetch_or (&v, 8, __ATOMIC_RELEASE); + if (v != 15) + abort (); + + count *= 2; + __atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 31) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST); + if (v != 63) + abort (); +} + +int +main () +{ + test_fetch_add (); + test_fetch_sub (); + test_fetch_and (); + test_fetch_nand (); + test_fetch_xor (); + test_fetch_or (); + + test_add_fetch (); + test_sub_fetch (); + test_and_fetch (); + test_nand_fetch (); + test_xor_fetch (); + test_or_fetch (); + + test_add (); + test_sub (); + test_and (); + test_nand (); + test_xor (); + test_or (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-op-2.c b/SingleSource/Regression/C/gcc-dg/atomic-op-2.c new file mode 100644 index 0000000000..949850345b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-op-2.c @@ -0,0 +1,556 @@ +/* Test __atomic routines for existence and proper execution on 2 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + + +/* Test the execution of the __atomic_*OP builtin routines for a short. */ + +extern void abort(void); + +short v, count, res; +const short init = ~0; + +/* The fetch_op routines return the original value before the operation. */ + +void +test_fetch_add () +{ + v = 0; + count = 1; + + if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5) + abort (); +} + + +void +test_fetch_sub() +{ + v = res = 20; + count = 0; + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--) + abort (); +} + +void +test_fetch_and () +{ + v = init; + + if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_fetch_nand () +{ + v = init; + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 ) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_xor () +{ + v = init; + count = 0; + + if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_or () +{ + v = 0; + count = 1; + + if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31) + abort (); +} + +/* The OP_fetch routines return the new value after the operation. */ + +void +test_add_fetch () +{ + v = 0; + count = 1; + + if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6) + abort (); +} + + +void +test_sub_fetch () +{ + v = res = 20; + count = 0; + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res) + abort (); +} + +void +test_and_fetch () +{ + v = init; + + if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0) + abort (); + + v = init; + if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_nand_fetch () +{ + v = init; + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + + + +void +test_xor_fetch () +{ + v = init; + count = 0; + + if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_or_fetch () +{ + v = 0; + count = 1; + + if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63) + abort (); +} + + +/* Test the OP routines with a result which isn't used. Use both variations + within each function. */ + +void +test_add () +{ + v = 0; + count = 1; + + __atomic_add_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_CONSUME); + if (v != 2) + abort (); + + __atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE); + if (v != 3) + abort (); + + __atomic_fetch_add (&v, 1, __ATOMIC_RELEASE); + if (v != 4) + abort (); + + __atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 5) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST); + if (v != 6) + abort (); +} + + +void +test_sub() +{ + v = res = 20; + count = 0; + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != --res) + abort (); +} + +void +test_and () +{ + v = init; + + __atomic_and_fetch (&v, 0, __ATOMIC_RELAXED); + if (v != 0) + abort (); + + v = init; + __atomic_fetch_and (&v, init, __ATOMIC_CONSUME); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, init, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_nand () +{ + v = init; + + __atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, init, __ATOMIC_RELEASE); + if (v != 0) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST); + if (v != init) + abort (); +} + + + +void +test_xor () +{ + v = init; + count = 0; + + __atomic_xor_fetch (&v, count, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_or () +{ + v = 0; + count = 1; + + __atomic_or_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_CONSUME); + if (v != 3) + abort (); + + count *= 2; + __atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE); + if (v != 7) + abort (); + + count *= 2; + __atomic_fetch_or (&v, 8, __ATOMIC_RELEASE); + if (v != 15) + abort (); + + count *= 2; + __atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 31) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST); + if (v != 63) + abort (); +} + +int +main () +{ + test_fetch_add (); + test_fetch_sub (); + test_fetch_and (); + test_fetch_nand (); + test_fetch_xor (); + test_fetch_or (); + + test_add_fetch (); + test_sub_fetch (); + test_and_fetch (); + test_nand_fetch (); + test_xor_fetch (); + test_or_fetch (); + + test_add (); + test_sub (); + test_and (); + test_nand (); + test_xor (); + test_or (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-op-3.c b/SingleSource/Regression/C/gcc-dg/atomic-op-3.c new file mode 100644 index 0000000000..9a54a2a417 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-op-3.c @@ -0,0 +1,555 @@ +/* Test __atomic routines for existence and proper execution on 4 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ + +/* Test the execution of the __atomic_*OP builtin routines for an int. */ + +extern void abort(void); + +int v, count, res; +const int init = ~0; + +/* The fetch_op routines return the original value before the operation. */ + +void +test_fetch_add () +{ + v = 0; + count = 1; + + if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5) + abort (); +} + + +void +test_fetch_sub() +{ + v = res = 20; + count = 0; + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--) + abort (); +} + +void +test_fetch_and () +{ + v = init; + + if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_fetch_nand () +{ + v = init; + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 ) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_xor () +{ + v = init; + count = 0; + + if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_or () +{ + v = 0; + count = 1; + + if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31) + abort (); +} + +/* The OP_fetch routines return the new value after the operation. */ + +void +test_add_fetch () +{ + v = 0; + count = 1; + + if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6) + abort (); +} + + +void +test_sub_fetch () +{ + v = res = 20; + count = 0; + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res) + abort (); +} + +void +test_and_fetch () +{ + v = init; + + if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0) + abort (); + + v = init; + if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_nand_fetch () +{ + v = init; + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + + + +void +test_xor_fetch () +{ + v = init; + count = 0; + + if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_or_fetch () +{ + v = 0; + count = 1; + + if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63) + abort (); +} + + +/* Test the OP routines with a result which isn't used. Use both variations + within each function. */ + +void +test_add () +{ + v = 0; + count = 1; + + __atomic_add_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_CONSUME); + if (v != 2) + abort (); + + __atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE); + if (v != 3) + abort (); + + __atomic_fetch_add (&v, 1, __ATOMIC_RELEASE); + if (v != 4) + abort (); + + __atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 5) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST); + if (v != 6) + abort (); +} + + +void +test_sub() +{ + v = res = 20; + count = 0; + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != --res) + abort (); +} + +void +test_and () +{ + v = init; + + __atomic_and_fetch (&v, 0, __ATOMIC_RELAXED); + if (v != 0) + abort (); + + v = init; + __atomic_fetch_and (&v, init, __ATOMIC_CONSUME); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, init, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_nand () +{ + v = init; + + __atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, init, __ATOMIC_RELEASE); + if (v != 0) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST); + if (v != init) + abort (); +} + + + +void +test_xor () +{ + v = init; + count = 0; + + __atomic_xor_fetch (&v, count, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_or () +{ + v = 0; + count = 1; + + __atomic_or_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_CONSUME); + if (v != 3) + abort (); + + count *= 2; + __atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE); + if (v != 7) + abort (); + + count *= 2; + __atomic_fetch_or (&v, 8, __ATOMIC_RELEASE); + if (v != 15) + abort (); + + count *= 2; + __atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 31) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST); + if (v != 63) + abort (); +} + +int +main () +{ + test_fetch_add (); + test_fetch_sub (); + test_fetch_and (); + test_fetch_nand (); + test_fetch_xor (); + test_fetch_or (); + + test_add_fetch (); + test_sub_fetch (); + test_and_fetch (); + test_nand_fetch (); + test_xor_fetch (); + test_or_fetch (); + + test_add (); + test_sub (); + test_and (); + test_nand (); + test_xor (); + test_or (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-op-4.c b/SingleSource/Regression/C/gcc-dg/atomic-op-4.c new file mode 100644 index 0000000000..6990b0e2d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-op-4.c @@ -0,0 +1,557 @@ +/* Test __atomic routines for existence and proper execution on 8 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_long_long_runtime } */ +/* { dg-options "" } */ +/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* Test the execution of the __atomic_*OP builtin routines for long long. */ + +extern void abort(void); + +long long v, count, res; +const long long init = ~0; + +/* The fetch_op routines return the original value before the operation. */ + +void +test_fetch_add () +{ + v = 0; + count = 1; + + if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5) + abort (); +} + + +void +test_fetch_sub() +{ + v = res = 20; + count = 0; + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--) + abort (); +} + +void +test_fetch_and () +{ + v = init; + + if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_fetch_nand () +{ + v = init; + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 ) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_xor () +{ + v = init; + count = 0; + + if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_or () +{ + v = 0; + count = 1; + + if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31) + abort (); +} + +/* The OP_fetch routines return the new value after the operation. */ + +void +test_add_fetch () +{ + v = 0; + count = 1; + + if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6) + abort (); +} + + +void +test_sub_fetch () +{ + v = res = 20; + count = 0; + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res) + abort (); +} + +void +test_and_fetch () +{ + v = init; + + if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0) + abort (); + + v = init; + if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_nand_fetch () +{ + v = init; + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + + + +void +test_xor_fetch () +{ + v = init; + count = 0; + + if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_or_fetch () +{ + v = 0; + count = 1; + + if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63) + abort (); +} + + +/* Test the OP routines with a result which isn't used. Use both variations + within each function. */ + +void +test_add () +{ + v = 0; + count = 1; + + __atomic_add_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_CONSUME); + if (v != 2) + abort (); + + __atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE); + if (v != 3) + abort (); + + __atomic_fetch_add (&v, 1, __ATOMIC_RELEASE); + if (v != 4) + abort (); + + __atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 5) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST); + if (v != 6) + abort (); +} + + +void +test_sub() +{ + v = res = 20; + count = 0; + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != --res) + abort (); +} + +void +test_and () +{ + v = init; + + __atomic_and_fetch (&v, 0, __ATOMIC_RELAXED); + if (v != 0) + abort (); + + v = init; + __atomic_fetch_and (&v, init, __ATOMIC_CONSUME); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, init, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_nand () +{ + v = init; + + __atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, init, __ATOMIC_RELEASE); + if (v != 0) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST); + if (v != init) + abort (); +} + + + +void +test_xor () +{ + v = init; + count = 0; + + __atomic_xor_fetch (&v, count, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_or () +{ + v = 0; + count = 1; + + __atomic_or_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_CONSUME); + if (v != 3) + abort (); + + count *= 2; + __atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE); + if (v != 7) + abort (); + + count *= 2; + __atomic_fetch_or (&v, 8, __ATOMIC_RELEASE); + if (v != 15) + abort (); + + count *= 2; + __atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 31) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST); + if (v != 63) + abort (); +} + +int +main () +{ + test_fetch_add (); + test_fetch_sub (); + test_fetch_and (); + test_fetch_nand (); + test_fetch_xor (); + test_fetch_or (); + + test_add_fetch (); + test_sub_fetch (); + test_and_fetch (); + test_nand_fetch (); + test_xor_fetch (); + test_or_fetch (); + + test_add (); + test_sub (); + test_and (); + test_nand (); + test_xor (); + test_or (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-op-5.c b/SingleSource/Regression/C/gcc-dg/atomic-op-5.c new file mode 100644 index 0000000000..1407f3fe3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-op-5.c @@ -0,0 +1,556 @@ +/* Test __atomic routines for existence and proper execution on 16 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_128_runtime } */ +/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ + +/* Test the execution of the __atomic_*OP builtin routines for an int_128. */ + +extern void abort(void); + +__int128_t v, count, res; +const __int128_t init = ~0; + +/* The fetch_op routines return the original value before the operation. */ + +void +test_fetch_add () +{ + v = 0; + count = 1; + + if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3) + abort (); + + if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4) + abort (); + + if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5) + abort (); +} + + +void +test_fetch_sub() +{ + v = res = 20; + count = 0; + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--) + abort (); + + if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--) + abort (); + + if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--) + abort (); +} + +void +test_fetch_and () +{ + v = init; + + if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_fetch_nand () +{ + v = init; + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 ) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0) + abort (); + + if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_xor () +{ + v = init; + count = 0; + + if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init) + abort (); +} + +void +test_fetch_or () +{ + v = 0; + count = 1; + + if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15) + abort (); + + count *= 2; + if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31) + abort (); +} + +/* The OP_fetch routines return the new value after the operation. */ + +void +test_add_fetch () +{ + v = 0; + count = 1; + + if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3) + abort (); + + if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5) + abort (); + + if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6) + abort (); +} + + +void +test_sub_fetch () +{ + v = res = 20; + count = 0; + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res) + abort (); + + if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res) + abort (); +} + +void +test_and_fetch () +{ + v = init; + + if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0) + abort (); + + v = init; + if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0) + abort (); + + v = ~v; + if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_nand_fetch () +{ + v = init; + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0) + abort (); + + if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init) + abort (); +} + + + +void +test_xor_fetch () +{ + v = init; + count = 0; + + if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init) + abort (); + + if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init) + abort (); + + if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0) + abort (); +} + +void +test_or_fetch () +{ + v = 0; + count = 1; + + if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31) + abort (); + + count *= 2; + if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63) + abort (); +} + + +/* Test the OP routines with a result which isn't used. Use both variations + within each function. */ + +void +test_add () +{ + v = 0; + count = 1; + + __atomic_add_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_CONSUME); + if (v != 2) + abort (); + + __atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE); + if (v != 3) + abort (); + + __atomic_fetch_add (&v, 1, __ATOMIC_RELEASE); + if (v != 4) + abort (); + + __atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 5) + abort (); + + __atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST); + if (v != 6) + abort (); +} + + +void +test_sub() +{ + v = res = 20; + count = 0; + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE); + if (v != --res) + abort (); + + __atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL); + if (v != --res) + abort (); + + __atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != --res) + abort (); +} + +void +test_and () +{ + v = init; + + __atomic_and_fetch (&v, 0, __ATOMIC_RELAXED); + if (v != 0) + abort (); + + v = init; + __atomic_fetch_and (&v, init, __ATOMIC_CONSUME); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, init, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL); + if (v != 0) + abort (); + + v = ~v; + __atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_nand () +{ + v = init; + + __atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, init, __ATOMIC_RELEASE); + if (v != 0) + abort (); + + __atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST); + if (v != init) + abort (); +} + + + +void +test_xor () +{ + v = init; + count = 0; + + __atomic_xor_fetch (&v, count, __ATOMIC_RELAXED); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME); + if (v != 0) + abort (); + + __atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE); + if (v != 0) + abort (); + + __atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE); + if (v != init) + abort (); + + __atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL); + if (v != init) + abort (); + + __atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST); + if (v != 0) + abort (); +} + +void +test_or () +{ + v = 0; + count = 1; + + __atomic_or_fetch (&v, count, __ATOMIC_RELAXED); + if (v != 1) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_CONSUME); + if (v != 3) + abort (); + + count *= 2; + __atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE); + if (v != 7) + abort (); + + count *= 2; + __atomic_fetch_or (&v, 8, __ATOMIC_RELEASE); + if (v != 15) + abort (); + + count *= 2; + __atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL); + if (v != 31) + abort (); + + count *= 2; + __atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST); + if (v != 63) + abort (); +} + +int +main () +{ + test_fetch_add (); + test_fetch_sub (); + test_fetch_and (); + test_fetch_nand (); + test_fetch_xor (); + test_fetch_or (); + + test_add_fetch (); + test_sub_fetch (); + test_and_fetch (); + test_nand_fetch (); + test_xor_fetch (); + test_or_fetch (); + + test_add (); + test_sub (); + test_and (); + test_nand (); + test_xor (); + test_or (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-op-6.c b/SingleSource/Regression/C/gcc-dg/atomic-op-6.c new file mode 100644 index 0000000000..f88c29389c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-op-6.c @@ -0,0 +1,11 @@ +/* Test we don't generate bogus warnings. */ +/* PR c/69407 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra" } */ + +void +foo (int *p, int a) +{ + __atomic_fetch_add (&p, a, 0); /* { dg-bogus "value computed is not used" } */ + __atomic_add_fetch (&p, a, 0); /* { dg-bogus "value computed is not used" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-op-optimize.c b/SingleSource/Regression/C/gcc-dg/atomic-op-optimize.c new file mode 100644 index 0000000000..66efee4bb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-op-optimize.c @@ -0,0 +1,20 @@ +/* Both these atomic operations should be optimized to an exchange operation. + Test that it at happens on x86 by making sure there are 2 xchg's and no + compare_exchange loop. */ + +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sync_int_long } */ +/* { dg-final { scan-assembler-times "cmpxchg" 0 } } */ +/* { dg-final { scan-assembler-times "xchg" 2 } } */ + +int x; + +int f() +{ + return __atomic_fetch_and (&x, 0, __ATOMIC_RELAXED); +} + +int g() +{ + return __atomic_fetch_or (&x, -1, __ATOMIC_RELAXED); +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-param.c b/SingleSource/Regression/C/gcc-dg/atomic-param.c new file mode 100644 index 0000000000..1f2b12690f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-param.c @@ -0,0 +1,14 @@ +/* Test __atomic routines for invalid memory model errors. This only needs + to be tested on a single size. */ +/* { dg-do compile } */ +/* { dg-require-effective-target sync_int_long } */ + +int i; + +int +main () +{ + + __atomic_exchange_n (&i, 1); /* { dg-error "too few arguments" } */ + __atomic_exchange_n (&i, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); /* { dg-error "too many arguments" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-pr51256.c b/SingleSource/Regression/C/gcc-dg/atomic-pr51256.c new file mode 100644 index 0000000000..2d39549c89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-pr51256.c @@ -0,0 +1,47 @@ +/* Test generic __atomic routines for various errors. */ +/* { dg-do compile } */ +/* { dg-require-effective-target sync_int_long } */ +/* { dg-options "-ansi" } */ + +void f1 (void* p) +{ + __atomic_compare_exchange(p, p, p, 0, 0, 0); /* { dg-error "must be a non-void pointer type" } */ +} + +void f2 (int n) +{ + int a[n], b[n]; + __atomic_load (&a, &b, __ATOMIC_SEQ_CST); /* { dg-error "must be a pointer to a constant size" } */ +} + +struct s { }; +void f3 (void) +{ + struct s a,b; + __atomic_load (&a, &b, __ATOMIC_SEQ_CST); /* { dg-error "must be a pointer to a nonzero size" } */ +} + +void f4 (int a, int b, int c) +{ + __atomic_load (&a, &b, &c, __ATOMIC_SEQ_CST); /* { dg-error "incorrect number of arguments" } */ +} + +void f5 (int a, int b) +{ + __atomic_load (&a, b, __ATOMIC_SEQ_CST); /* { dg-error "must be a pointer type" } */ +} + +void f6 (int a, char b) +{ + __atomic_load (&a, &b, __ATOMIC_SEQ_CST); /* { dg-error "size mismatch in argument" } */ +} + +void f7 (int a, int b) +{ + __atomic_load (&a, &b, 45); /* { dg-warning "invalid memory model argument" } */ +} + +void f8 (int a, int b, float c) +{ + __atomic_load (&a, &b, c); /* { dg-error "non-integer memory model argument" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-pr81231.c b/SingleSource/Regression/C/gcc-dg/atomic-pr81231.c new file mode 100644 index 0000000000..304e4281f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-pr81231.c @@ -0,0 +1,12 @@ +/* PR c/81231 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum E; + +void +foo (void) +{ + __atomic_load_n ((enum E *) 0, 0); /* { dg-error "incompatible" } */ + __atomic_load_n ((enum X *) 0, 0); /* { dg-error "incompatible" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/atomic-store-1.c b/SingleSource/Regression/C/gcc-dg/atomic-store-1.c new file mode 100644 index 0000000000..1ca5febcf8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-store-1.c @@ -0,0 +1,48 @@ +/* Test __atomic routines for existence and proper execution on 1 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + +/* Test the execution of the __atomic_store_n builtin for a char. */ + +extern void abort(void); + +char v, count; + +int +main () +{ + v = 0; + count = 0; + + __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != ++count) + abort (); + + /* Now test the generic variant. */ + count++; + + __atomic_store (&v, &count, __ATOMIC_RELAXED); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_RELEASE); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_SEQ_CST); + if (v != count) + abort (); + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-store-2.c b/SingleSource/Regression/C/gcc-dg/atomic-store-2.c new file mode 100644 index 0000000000..c7b1e211a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-store-2.c @@ -0,0 +1,47 @@ +/* Test __atomic routines for existence and proper execution on 2 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ + +/* Test the execution of the __atomic_store_n builtin for a short. */ + +extern void abort(void); + +short v, count; + +int +main () +{ + v = 0; + count = 0; + + __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != ++count) + abort (); + + /* Now test the generic variant. */ + count++; + + __atomic_store (&v, &count, __ATOMIC_RELAXED); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_RELEASE); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_SEQ_CST); + if (v != count) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-store-3.c b/SingleSource/Regression/C/gcc-dg/atomic-store-3.c new file mode 100644 index 0000000000..52b30faacd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-store-3.c @@ -0,0 +1,48 @@ +/* Test __atomic routines for existence and proper execution on 4 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ + +/* Test the execution of the __atomic_store_n builtin for an int. */ + +extern void abort(void); + +int v, count; + +int +main () +{ + v = 0; + count = 0; + + __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != ++count) + abort (); + + /* Now test the generic variant. */ + count++; + + __atomic_store (&v, &count, __ATOMIC_RELAXED); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_RELEASE); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_SEQ_CST); + if (v != count) + abort (); + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-store-4.c b/SingleSource/Regression/C/gcc-dg/atomic-store-4.c new file mode 100644 index 0000000000..ca37fdc462 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-store-4.c @@ -0,0 +1,50 @@ +/* Test __atomic routines for existence and proper execution on 8 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_long_long_runtime } */ +/* { dg-options "" } */ +/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* Test the execution of the __atomic_store_n builtin for a long long. */ + +extern void abort(void); + +long long v, count; + +int +main () +{ + v = 0; + count = 0; + + __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != ++count) + abort (); + + /* Now test the generic variant. */ + count++; + + __atomic_store (&v, &count, __ATOMIC_RELAXED); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_RELEASE); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_SEQ_CST); + if (v != count) + abort (); + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-store-5.c b/SingleSource/Regression/C/gcc-dg/atomic-store-5.c new file mode 100644 index 0000000000..a855182bf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-store-5.c @@ -0,0 +1,49 @@ +/* Test __atomic routines for existence and proper execution on 16 byte + values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_128_runtime } */ +/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ + +/* Test the execution of the __atomic_store_n builtin for a 16 byte value. */ + +extern void abort(void); + +__int128_t v, count; + +int +main () +{ + v = 0; + count = 0; + + __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE); + if (v != ++count) + abort (); + + __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST); + if (v != ++count) + abort (); + + /* Now test the generic variant. */ + count++; + + __atomic_store (&v, &count, __ATOMIC_RELAXED); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_RELEASE); + if (v != count++) + abort (); + + __atomic_store (&v, &count, __ATOMIC_SEQ_CST); + if (v != count) + abort (); + + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/atomic-store-6.c b/SingleSource/Regression/C/gcc-dg/atomic-store-6.c new file mode 100644 index 0000000000..81499cd716 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/atomic-store-6.c @@ -0,0 +1,13 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_128_runtime } */ +/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ + +__int128_t i; + +int main() +{ + __atomic_store_16(&i, -1, 0); + if (i != -1) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-2.c b/SingleSource/Regression/C/gcc-dg/attr-access-2.c new file mode 100644 index 0000000000..616b7a9527 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-2.c @@ -0,0 +1,112 @@ +/* PR 50584 - No warning for passing small array to C99 static array declarator + Exercise interaction between explicit attribute access and VLA parameters. + { dg-do compile } + { dg-options "-Wall" } */ + +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) + + +void f1 (int n, int[n], int); // { dg-message "designating the bound of variable length array argument 2" "note" } + +// Verify that a redundant attribute access doesn't trigger a warning. +RW (2, 1) void f1 (int n, int[n], int); + +RW (2, 3) void f1 (int n, int[n], int); // { dg-warning "attribute 'access\\\(read_write, 2, 3\\\)' positional argument 2 conflicts with previous designation by argument 1" } + + +/* Verify that applying the attribute to a VLA with an unspecified bound + doesn't trigger any warnings, both with and without a size operand. */ + void f2 (int, int[*], int); +RW (2) void f2 (int, int[*], int); +RW (2, 3) void f2 (int, int[*], int); + +/* Designating a parameter that comes before the VLA is the same as + using the standard VLA int[n] syntax. It might be worth issuing + a portability warning suggesting to prefer the standard syntax. */ + void f3 (int, int[*], int); +RW (2, 1) void f3 (int, int[*], int); + +/* Designating a parameter that comes after the VLA cannot be expressed + using the standard VLA int[n] syntax. Verify it doesn't trigger + a warning. */ + void f4 (int, int[*], int); +RW (2, 3) void f4 (int, int[*], int); + +/* Also verify the same on the same declaration. */ + void f5 (int[*], int) RW (1, 2); +RW (1, 2) void f5 (int[*], int); +RW (1, 2) void f5 (int[*], int) RW (1, 2); + + +/* Verify that designating a VLA parameter with an explicit bound without + also designating the same bound parameter triggers a warning (it has + a different meaning). */ + void f7 (int n, int[n]); // { dg-message "21:note: designating the bound of variable length array argument 2" "note" } +RW (2) void f7 (int n, int[n]); // { dg-warning "attribute 'access\\\(read_write, 2\\\)' missing positional argument 2 provided in previous designation by argument 1" } + + void f8 (int n, int[n]); +RW (2, 1) void f8 (int n, int[n]); + + + void f9 (int, char[]); // { dg-message "25:note: previously declared as an ordinary array 'char\\\[]'" note" } +RW (2) void f9 (int n, char a[n]) // { dg-warning "argument 2 of type 'char\\\[n]' declared as a variable length array" } + // { dg-warning "attribute 'access *\\\(read_write, 2\\\)' positional argument 2 missing in previous designation" "" { target *-*-* } .-1 } + // { dg-message "24:note: designating the bound of variable length array argument 2" "note" { target *-*-* } .-2 } +{ (void)&n; (void)&a; } + + + void f10 (int, char[]); // { dg-message "26:note: previously declared as an ordinary array 'char\\\[]'" "note" } +RW (2, 1) void f10 (int n, char a[n]) // { dg-warning "attribute 'access *\\\(read_write, 2, 1\\\)' positional argument 2 missing in previous designation" "pr????" { xfail *-*-* } } + // { dg-warning "argument 2 of type 'char\\\[n]' declared as a variable length array" "" { target *-*-* } .-1 } +{ (void)&n; (void)&a; } + +/* Verify that redeclaring a function with attribute access applying + to an array parameter of any form is not diagnosed. */ + void f12__ (int, int[]) RW (2, 1); +RW (2, 1) void f12__ (int, int[]); + + void f12_3 (int, int[3]) RW (2, 1); +RW (2, 1) void f12_3 (int, int[3]); + + void f12_n (int n, int[n]) RW (2, 1); +RW (2, 1) void f12_n (int n, int[n]); + + void f12_x (int, int[*]) RW (2, 1); +RW (2, 1) void f12_x (int, int[*]); + + void f13__ (int, int[]); +RW (2, 1) void f13__ (int, int[]); + + void f13_5 (int, int[5]); +RW (2, 1) void f13_5 (int, int[5]); + + void f13_n (int n, int[n]); +RW (2, 1) void f13_n (int n, int[n]); + + void f13_x (int, int[*]); +RW (2, 1) void f13_x (int, int[*]); + +RW (2, 1) void f14__ (int, int[]); + void f14__ (int, int[]); + +RW (2, 1) void f14_7 (int, int[7]); + void f14_7 (int, int[7]); + +RW (2, 1) void f14_n (int n, int[n]); + void f14_n (int n, int[n]); + +RW (2, 1) void f14_x (int, int[*]); + void f14_x (int, int[*]); + +typedef void G1 (int n, int[n], int); + +G1 g1; + +/* The warning is about the attribute positional argument 2 which refers + to the last function argument. Ideally, the caret would be under + the corresponding function argument, i.e., the last one here) but + that location isn't available yet. Verify that the caret doesn't + point to function argument 1 which is the VLA bound (that's what + the caret in the note points to). */ +RW (2, 3) void g1 (int n, int[n], int); // { dg-warning "16: attribute 'access *\\\(read_write, 2, 3\\\)' positional argument 2 conflicts with previous designation by argument 3" } +// { dg-message "24:designating the bound of variable length array argument 2" "note" { target *-*-* } .-1 } diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-3.c b/SingleSource/Regression/C/gcc-dg/attr-access-3.c new file mode 100644 index 0000000000..45dd1aaad1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-3.c @@ -0,0 +1,21 @@ +/* PR middle-end/97879 - ICE on invalid mode in attribute access + { dg-do compile } + { dg-options "-Wall" } */ + +#define A(...) __attribute__ ((access (__VA_ARGS__))) + +A (" ", 1) void f1 (int *); // { dg-error "attribute 'access' mode '\" \"' is not an identifier; expected one of 'read_only', 'read_write', 'write_only', or 'none'" } + void f1 (int *); + + +A ("none", 1) void f2 (char *); // { dg-error "not an identifier" } + void f2 (char *); + +A (1) void f3 (); // { dg-error "not an identifier" } + +A (1, 2) void f4 (); // { dg-error "not an identifier" } +A (2., 3.) void f5 (); // { dg-error "not an identifier" } + +// Verify that copying a valid access attribute doesn't cause errors. +A (read_only, 1, 2) void f6 (void*, int); +__attribute__ ((copy (f6))) void f7 (void*, int); diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-4.c b/SingleSource/Regression/C/gcc-dg/attr-access-4.c new file mode 100644 index 0000000000..7a2870a0ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-4.c @@ -0,0 +1,8 @@ +/* PR middle-end/97861 - ICE on an invalid redeclaration of a function + with attribute access + { dg-do compile } + { dg-options "-Wall" } */ + +__attribute__ ((access (read_only, 2))) +void f (int, int*); +void f (int a) { } // { dg-error "conflicting types for 'f'" } diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-5.c b/SingleSource/Regression/C/gcc-dg/attr-access-5.c new file mode 100644 index 0000000000..e78b3602ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-5.c @@ -0,0 +1,16 @@ +/* { dg-do compile } + { dg-options "-fdump-tree-gimple" } */ + +__attribute__ ((aligned (32))) +__attribute__ ((access (write_only, 2, 1))) +void f (int n, void *p) +{ + __builtin_memset (p, 0, n); +} + +/* Verify the DECL_ATTRIBUTE "aligned" is mentioned: + { dg-final { scan-tree-dump "__attribute__\\(\\(aligned" "gimple" } } + and the TYPE_ATTRIBUTE "access" is also mentioned: + { dg-final { scan-tree-dump "__attribute__\\(\\(access" "gimple" } } + and the function signature including its return type is mentioned: + { dg-final { scan-tree-dump "void f *\\(int n, void *\\* *p\\)" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-none.c b/SingleSource/Regression/C/gcc-dg/attr-access-none.c new file mode 100644 index 0000000000..dc06d05747 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-none.c @@ -0,0 +1,38 @@ +/* Test to verify the handling of attribute access (none). + { dg-do compile } + { dg-options "-O -Wall -ftrack-macro-expansion=0" } */ + +int __attribute__ ((access (none, 1))) +fnone_pv1 (void*); + +void nowarn_fnone_pv1 (void) +{ + int x; + fnone_pv1 (&x); +} + + +int __attribute__ ((access (none, 1))) +fnone_pcv1 (const void*); + +void nowarn_fnone_pcv1 (void) +{ + char a[2]; + fnone_pcv1 (a); +} + + +int __attribute__ ((access (none, 1, 2))) +fnone_pcv1_2 (const void*, int); // { dg-message "in a call to function 'fnone_pcv1_2' declared with attribute 'access \\\(none, 1, 2\\\)'" "note" } + +void nowarn_fnone_pcv1_2 (void) +{ + char a[2]; + fnone_pcv1_2 (a, 2); +} + +void warn_fnone_pcv1_2 (void) +{ + char a[3]; + fnone_pcv1_2 (a, 4); // { dg-warning "expecting 4 bytes in a region of size 3" } +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-read-only-2.c b/SingleSource/Regression/C/gcc-dg/attr-access-read-only-2.c new file mode 100644 index 0000000000..d3069b04ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-read-only-2.c @@ -0,0 +1,16 @@ +/* PR c/93132 - bogus 'attribute((access))' warning when size-index + is specified + { dg-do compile } + { dg-options "-Wall" } */ + +void __attribute__ ((access (read_only, 1, 5))) +f (void*, int, int, int, int); // { dg-message "previous declaration" } + +void __attribute__ ((access (read_only, 1, 3))) +f (void*, int, int, int, int); // { dg-warning "attribute 'access\\\(read_only, 1, 3\\\)' mismatched positional argument values 3 and 5" } + +void __attribute__ ((access (read_only, 1, 4))) +f (void*, int, int, int, int); // { dg-warning "attribute 'access\\\(read_only, 1, 4\\\)' mismatched positional argument values 4 and 5" } + +void __attribute__ ((access (read_only, 1, 5))) +f (void*, int, int, int, int); diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-read-only.c b/SingleSource/Regression/C/gcc-dg/attr-access-read-only.c new file mode 100644 index 0000000000..71175d05ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-read-only.c @@ -0,0 +1,96 @@ +/* PR middle-end/83859 - attribute to establish relation between parameters + for buffer and its size + Test to verify the handling of attribute access (read_only) syntax. + { dg-do compile } + { dg-options "-Wall -ftrack-macro-expansion=0" } */ + +int __attribute__ ((access)) +access_v (void); // { dg-error "wrong number of arguments specified for 'access' attribute" } + +int __attribute__ ((access ())) +access___v (void); // { dg-error "wrong number of arguments specified for 'access' attribute" } + +int __attribute__ ((access (rdonly))) +rdonly_spelling (void); // { dg-error "attribute .access. invalid mode 'rdonly'; expected one of 'read_only', 'read_write', 'write_only', or 'none'" } + +int __attribute__ ((access (read_only))) +rdonly_v_all (void); // { dg-error "attribute .access\\(read_only\\). missing an argument" } + +int __attribute__ ((access (read_only ()))) +rdonly___v_all (void); // { dg-error "attribute 'access' unexpected '\\(' after mode 'read_only'; expected a positional argument or '\\)'" } +// { dg-warning "implicit declaration of function 'read_only'" "" { target *-*-* } .-2 } + + +int rdonly (void); + +int __attribute__ ((access (rdonly ()))) +rdonly___v_all (void); // { dg-error "attribute 'access' invalid mode 'rdonly'" } + + +int __attribute__ ((access (read_only))) +rdonly_i_all (int); // { dg-error "attribute .access\\(read_only\\). missing an argument" } + +#define rdonly __attribute__ ((access (read_only))) +#define RDONLY(...) __attribute__ ((access (read_only, __VA_ARGS__))) + +int RDONLY (1) +rdonly_pcv_1 (const void*); +int RDONLY (2) +rdonly_i_pcv_2 (int, const void*); +int RDONLY (3) +rdonly_i_i_pcv_3 (int, int, const void*); + +int RDONLY (0 + 1) +rdonly_pcv_0p1 (const void*); + +int RDONLY (2 - 1) +rdonly_pcv_2m1 (const void*); + +int RDONLY (1, 1) +rdonly_pv_pi_1_1 (const void*, const int*); // { dg-error "attribute 'access\\(read_only, 1, 1\\)' positional argument 2 references non-integer argument type 'const void \\*'" } + +int RDONLY (1, 2) +rdonly_pcv_pc_1_2 (const void*, char*); // { dg-error "attribute .access\\(read_only, 1, 2\\)' positional argument 2 references non-integer argument type 'char \\*'" } + +int RDONLY (2, 1) +rdonly_pcd_pcv_2_1 (const double*, const void*); // { dg-error "attribute .access\\(read_only, 2, 1\\)' positional argument 2 references non-integer argument type 'const double \\*'" } + +int RDONLY (2, 2) +rdonly_pi_pcv_2_2 (int*, const void*); // { dg-error "positional argument 2 references non-integer argument type 'const void \\*'" } + +int RDONLY (4) +rdonly_i_i_i_4 (int, int, int); // { dg-error "attribute 'access\\(read_only, 4\\)' positional argument 1 value 4 exceeds number of function arguments 3" } + +int RDONLY (1) +rdonly_i_1 (int); // { dg-error "attribute 'access\\(read_only, 1\\)' positional argument 1 references non-pointer argument type 'int'" } + +// It's okay if the pointer argument is non-const, although a separate +// warning encouraging one might be worthwhile. Maybe something like +// -Wsuggest-const. +int RDONLY (2) +rdonly_i_pc (int, char*); + +int RDONLY (-1) +rdonly_pcv_m1 (const void*); // { dg-error "attribute 'access\\(read_only, -1\\)' positional argument 1 invalid value -1" } + +int RDONLY (1, -12345) +rdonly_pcv_i_1_m12345 (const void*, int*); // { dg-error "attribute 'access\\(read_only, 1, -12345\\)' positional argument 2 invalid value -12345" } + +int RDONLY ("blah") +rdonly_pcv_str (const void*); // { dg-error "attribute 'access\\(read_only, \"blah\"\\)' invalid positional argument 1" } + +int RDONLY (1, "foobar") +rdonly_pcv_i_1_str (const void*, int); // { dg-error "attribute 'access\\(read_only, 1, \"foobar\"\\)' invalid positional argument 2" } + +// Verify that attributes whose operands reference function pointers +// are rejected. +typedef int F (int, int); +RDONLY (1) void rdwr_pf_1 (F*); // { dg-error "attribute 'access\\(read_only, 1\\)' positional argument 1 references argument of function type 'F' \\{aka 'int\\(int, *int\\)'\\}" } + +// Verify pointers to functions. +void RDONLY(2) (*prdonly_pcv2)(int, const void*); +void RDONLY(3, 1) (*prdonly_pcv2_1)(int, void*, const void*); + +// Verify types. +typedef RDONLY (2) void rdonly_p2_t (const int*, const char*, const void*); +typedef RDONLY (2) void rdonly_p2_1 (int, const int*); diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-read-write-2.c b/SingleSource/Regression/C/gcc-dg/attr-access-read-write-2.c new file mode 100644 index 0000000000..deeee736eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-read-write-2.c @@ -0,0 +1,61 @@ +/* PR middle-end/83859 - attribute to establish relation between parameters + for buffer and its size + Test to verify the handling of attribute read_only combining multiple + declarations of the same function. + { dg-do compile } + { dg-options "-Wall -ftrack-macro-expansion=0" } */ + +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) +#define WO(...) __attribute__ ((access (write_only, __VA_ARGS__))) + +int rdwr1_rdwr1 (void*, void*); +int RW (1) RW (1) rdwr1_rdwr1 (void*, void*); +int RW (2) RW (2) rdwr1_rdwr1 (void*, void*); +int RW (1) RW (2) rdwr1_rdwr1 (void*, void*); +int RW (2) RW (1) rdwr1_rdwr1 (void*, void*); + +int frdwr1_wr1 (void*, void*); +int RW (1) WO (1) frdwr1_wr1 (void*, void*); // { dg-warning "attribute 'access\\(write_only, 1\\)' mismatch with mode 'read_write'" } + +int RW (1) grdwr1_wr1 (void*, void*); // { dg-message "previous declaration here" } + +int WO (1) grdwr1_wr1 (void*, void*); // { dg-warning "attribute 'access\\(write_only, 1\\)' mismatch with mode 'read_write'" } + + +int RW (1) RW (1, 2) frdwr1_rdwr1_1 (void*, int); // { dg-warning "attribute 'access\\(read_write, 1, 2\\)' positional argument 2 missing in previous designation" } + +int RW (1, 2) RW (1) frdwr1_1_rdwr1 (void*, int); // { dg-warning "attribute 'access\\(read_write, 1\\)' missing positional argument 2 provided in previous designation" } + +int RW (1) grdwr1_rdwr1_1 (void*, int); // { dg-message "previous declaration here" } +int RW (1, 2) grdwr1_rdwr1_1 (void*, int); // { dg-warning "attribute 'access\\(read_write, 1, 2\\)' positional argument 2 missing in previous designation" } + + +typedef int *P; + +int RW(1) WO(3) RW(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); + +int RW(1) WO(3) RW(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); + +int WO(1) WO(3) RW(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); +// { dg-warning "attribute 'access\\(write_only, 1\\)' mismatch with mode 'read_write'" "1" { target *-*-* } .-1 } + +int RW(1) RW(3) RW(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); +// { dg-warning "attribute 'access\\(read_write, 3\\)' mismatch with mode 'write_only'" "3" { target *-*-* } .-1 } + +int RW(1) WO(3) WO(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); +// { dg-warning "attribute 'access\\(write_only, 5\\)' mismatch with mode 'read_write'" "5" { target *-*-* } .-1 } + +int RW(1) WO(3) RW(5) RW(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); +// { dg-warning "attribute 'access\\(read_write, 7\\)' mismatch with mode 'write_only'" "7" { target *-*-* } .-1 } + +int RW(1) WO(3) RW(5) WO(7) WO(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); +// { dg-warning "attribute 'access\\(write_only, 9\\)' mismatch with mode 'read_write'" "9" { target *-*-* } .-1 } + +int RW(1) WO(3) RW(5) WO(7) RW(9) RW(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); +// { dg-warning "attribute 'access\\(read_write, 11\\)' mismatch with mode 'write_only'" "11" { target *-*-* } .-1 } + +int RW(1) WO(3) RW(5) WO(7) RW(9) WO(11) WO(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); +// { dg-warning "attribute 'access\\(write_only, 13\\)' mismatch with mode 'read_write'" "13" { target *-*-* } .-1 } + +int RW(1) WO(3) RW(5) WO(7) RW(9) WO(11) RW(13) RW(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); +// { dg-warning "attribute 'access\\(read_write, 15\\)' mismatch with mode 'write_only'" "15" { target *-*-* } .-1 } diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-read-write.c b/SingleSource/Regression/C/gcc-dg/attr-access-read-write.c new file mode 100644 index 0000000000..849d9f1cf6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-read-write.c @@ -0,0 +1,92 @@ +/* PR middle-end/83859 - attribute to establish relation between parameters + for buffer and its size + { dg-do compile } + { dg-options "-Wall -ftrack-macro-expansion=0" } */ + +int __attribute__ ((access)) +access_v (void); /* { dg-error "wrong number of arguments specified for 'access' attribute" } */ + +int __attribute__ ((access ())) +access___v (void); /* { dg-error "wrong number of arguments specified for 'access' attribute" } */ + +int __attribute__ ((access (rdwr))) +rdwr_spelling (void); /* { dg-error "attribute .access. invalid mode 'rdwr'; expected one of 'read_only', 'read_write', 'write_only', or 'none'" } */ + +int __attribute__ ((access (read_write))) +rdwr_v_all (void); /* { dg-error "attribute .access\\(read_write\\). missing an argument" } */ + +int __attribute__ ((access (read_write ()))) +rdwr___v_all (void); /* { dg-error "attribute 'access' unexpected '\\(' after mode 'read_write'; expected a positional argument or '\\)'" } */ +/* { dg-warning "implicit declaration of function 'read_write'" "" { target *-*-* } .-2 } */ + + +int rdwr (void); + +int __attribute__ ((access (rdwr ()))) +rdwr___v_all (void); /* { dg-error "attribute 'access' invalid mode 'rdwr'" } */ + + +#define RDWR(...) __attribute__ ((access (read_write, __VA_ARGS__))) + +int RDWR (1) +rdwr_pcv_1 (void*); + +int RDWR (2) +rdwr_i_pcv_2 (int, void*); +int RDWR (3) +rdwr_i_i_pcv_3 (int, int, void*); + +int RDWR (0 + 1) +rdwr_pcv_0p1 (void*); + +int RDWR (2 - 1) +rdwr_pcv_2m1 (void*); + +int RDWR (1) +rdwr_pcv_pi_1_1 (const void*, int*); /* { dg-error "attribute 'access\\(read_write, 1\\)' positional argument 1 references 'const'-qualified argument type 'const void \\*'" } */ + +int RDWR (1, 1) +rdwr_pv_pi_1_1 (void*, int*); /* { dg-error "attribute 'access\\(read_write, 1, 1\\)' positional argument 2 references non-integer argument type 'void \\*'" } */ + +int RDWR (1, 2) +rdwr_pcv_pc_1_2 (void*, char*); /* { dg-error "attribute .access\\(read_write, 1, 2\\)' positional argument 2 references non-integer argument type 'char \\*'" } */ + +int RDWR (2, 1) +rdwr_pcd_pcv_2_1 (double*, void*); /* { dg-error "attribute .access\\(read_write, 2, 1\\)' positional argument 2 references non-integer argument type 'double \\*'" } */ + +int RDWR (2, 2) +rdwr_pi_pcv_2_2 (int*, void*); /* { dg-error "positional argument 2 references non-integer argument type 'void \\*'" } */ + +int RDWR (4) +rdwr_i_i_i_4 (int, int, int); /* { dg-error "attribute 'access\\(read_write, 4\\)' positional argument 1 value 4 exceeds number of function arguments 3" } */ + +int RDWR (1) +rdwr_i_1 (int); /* { dg-error "attribute 'access\\(read_write, 1\\)' positional argument 1 references non-pointer argument type 'int'" } */ + +int RDWR (2) +rdwr_i_pc (int, const char*); /* { dg-error "attribute 'access\\(read_write, 2\\)' positional argument 1 references 'const'-qualified argument type 'const char \\*'" } */ + +int RDWR (-1) +rdwr_pcv_m1 (void*); /* { dg-error "attribute 'access\\(read_write, -1\\)' positional argument 1 invalid value -1" } */ + +int RDWR (1, -12345) +rdwr_pcv_i_1_m12345 (void*, int*); /* { dg-error "attribute 'access\\(read_write, 1, -12345\\)' positional argument 2 invalid value -12345" } */ + +int RDWR ("blah") +rdwr_pcv_str (void*); /* { dg-error "attribute 'access\\(read_write, \"blah\"\\)' invalid positional argument 1" } */ + +int RDWR (1, "foobar") +rdwr_pcv_i_1_str (void*, int); /* { dg-error "attribute 'access\\(read_write, 1, \"foobar\"\\)' invalid positional argument 2" } */ + +/* Verify that attributes whose operands reference function pointers + are rejected. */ +typedef int F (int, int); +RDWR (1) void rdwr_pf_1 (F*); /* { dg-error "attribute 'access\\(read_write, 1\\)' positional argument 1 references argument of function type 'F' \\{aka 'int\\(int, *int\\)'\\}" } */ + +/* Verify pointers to functions. */ +void RDWR(2) (*prdwr_pv2)(int, void*); +void RDWR(3, 1) (*prdwr_pv2_1)(int, void*, void*); + +/* Verify types. */ +typedef RDWR (2) void rdwr_p2_t (int*, char*, void*); +typedef RDWR (2) void rdwr_p2_1 (int, int*); diff --git a/SingleSource/Regression/C/gcc-dg/attr-access-write-only.c b/SingleSource/Regression/C/gcc-dg/attr-access-write-only.c new file mode 100644 index 0000000000..2718b0db45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access-write-only.c @@ -0,0 +1,89 @@ +/* PR middle-end/83859 - attribute to establish relation between parameters + for buffer and its size + Test to verify the handling of attribute access (write_only) syntax. + { dg-do compile } + { dg-options "-Wall -ftrack-macro-expansion=0" } */ + +int __attribute__ ((access)) +access_v (void); // { dg-error "wrong number of arguments specified for 'access' attribute" } + +int __attribute__ ((access ())) +access___v (void); // { dg-error "wrong number of arguments specified for 'access' attribute" } + +int __attribute__ ((access (wronly))) +wronly_spelling (void); // { dg-error "attribute .access. invalid mode 'wronly'; expected one of 'read_only', 'read_write', 'write_only', or 'none'" } + +int __attribute__ ((access (read_only))) +wronly_v_all (void); // { dg-error "attribute .access\\(read_only\\). missing an argument" } + +int __attribute__ ((access (read_only ()))) +wronly___v_all (void); // { dg-error "attribute 'access' unexpected '\\(' after mode 'read_only'; expected a positional argument or '\\)'" } +// { dg-warning "implicit declaration of function 'read_only'" "" { target *-*-* } .-2 } + + +int wronly (void); + +int __attribute__ ((access (wronly ()))) +wronly___v_all (void); // { dg-error "attribute 'access' invalid mode 'wronly'" } + +#define WRONLY(...) __attribute__ ((access (write_only, __VA_ARGS__))) + +int WRONLY (1) +wronly_pcv_1 (void*); +int WRONLY (2) +wronly_i_pcv_2 (int, void*); +int WRONLY (3) +wronly_i_i_pcv_3 (int, int, void*); + +int WRONLY (0 + 1) +wronly_pcv_0p1 (void*); + +int WRONLY (2 - 1) +wronly_pcv_2m1 (void*); + +int WRONLY (1, 1) +wronly_pv_pi_1_1 (void*, const int*); // { dg-error "attribute 'access\\(write_only, 1, 1\\)' positional argument 2 references non-integer argument type 'void \\*'" } + +int WRONLY (1, 2) +wronly_pcv_pc_1_2 (void*, char*); // { dg-error "attribute .access\\(write_only, 1, 2\\)' positional argument 2 references non-integer argument type 'char \\*'" } + +int WRONLY (2, 1) +wronly_pcd_pcv_2_1 (const double*, void*); // { dg-error "attribute .access\\(write_only, 2, 1\\)' positional argument 2 references non-integer argument type 'const double \\*'" } + +int WRONLY (2, 2) +wronly_pi_pcv_2_2 (int*, void*); // { dg-error "positional argument 2 references non-integer argument type 'void \\*'" } + +int WRONLY (4) +wronly_i_i_i_4 (int, int, int); // { dg-error "attribute 'access\\(write_only, 4\\)' positional argument 1 value 4 exceeds number of function arguments 3" } + +int WRONLY (1) +wronly_i_1 (int); // { dg-error "attribute 'access\\(write_only, 1\\)' positional argument 1 references non-pointer argument type 'int'" } + +int WRONLY (2) +wronly_i_pc (int, const char*); // { dg-error "attribute 'access\\(write_only, 2\\)' positional argument 1 references 'const'-qualified argument type 'const char \\*'" } + +int WRONLY (-1) +wronly_pcv_m1 (void*); // { dg-error "attribute 'access\\(write_only, -1\\)' positional argument 1 invalid value -1" } + +int WRONLY (1, -12345) +wronly_pcv_i_1_m12345 (void*, int*); // { dg-error "attribute 'access\\(write_only, 1, -12345\\)' positional argument 2 invalid value -12345" } + +int WRONLY ("blah") +wronly_pcv_str (void*); // { dg-error "attribute 'access\\(write_only, \"blah\"\\)' invalid positional argument 1" } + +int WRONLY (1, "foobar") +wronly_pcv_i_1_str (void*, int); // { dg-error "attribute 'access\\(write_only, 1, \"foobar\"\\)' invalid positional argument 2" } + +// Verify that attributes whose operands reference function pointers +// are rejected. +typedef int F (int, int); +WRONLY (1) void wronly_pf_1 (F*); // { dg-error "attribute 'access\\(write_only, 1\\)' positional argument 1 references argument of function type 'F' \\{aka 'int\\(int, *int\\)'\\}" } + +// Verify pointers to functions. +void WRONLY(2) (*pwronly_pcv2)(int, void*); +void WRONLY(3, 1) (*pwronly_pcv2_1)(int, void*, void*); +void WRONLY(1, 2) (*pwronly_i_pcv_1_2)(int, void*); // { dg-error "attribute 'access\\(write_only, 1, 2\\)' positional argument 1 references non-pointer argument type 'int'" } + +// Verify types. +typedef WRONLY (2) void wronly_p2_t (const int*, char*, const void*); +typedef WRONLY (2) void wronly_p2_1 (int, int*); diff --git a/SingleSource/Regression/C/gcc-dg/attr-access.c b/SingleSource/Regression/C/gcc-dg/attr-access.c new file mode 100644 index 0000000000..f859c461b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-access.c @@ -0,0 +1,21 @@ +/* PR c/93640 - The write_only and read_write attributes can be mistyped + due to invalid strncmp size argument + { dg-do compile } + { dg-options "-Wall" } */ + +__attribute__ ((access (read_onl))) int f0 (char*); // { dg-error "attribute 'access' invalid mode 'read_onl'" } +__attribute__ ((access (write_onl))) int f1 (char*); // { dg-error "attribute 'access' invalid mode 'write_onl'" } +__attribute__ ((access (read_writ))) int f2 (char*); // { dg-error "attribute 'access' invalid mode 'read_writ'" } + +__attribute__ ((access (read_onlX))) int f3 (char*); // { dg-error "attribute 'access' invalid mode 'read_onlX'" } +__attribute__ ((access (write_onlX))) int f4 (char*); // { dg-error "attribute 'access' invalid mode 'write_onlX'" } +__attribute__ ((access (read_writX))) int f5 (char*); // { dg-error "attribute 'access' invalid mode 'read_writX'" } + + +__attribute__ ((access (read_onl, 1))) int f7 (char*); // { dg-error "attribute 'access' invalid mode 'read_onl'" } +__attribute__ ((access (write_onl, 1))) int f8 (char*); // { dg-error "attribute 'access' invalid mode 'write_onl'" } +__attribute__ ((access (read_writ, 1))) int f9 (char*); // { dg-error "attribute 'access' invalid mode 'read_writ'" } + +__attribute__ ((access (read_onlX, 1))) int f10 (char*); // { dg-error "attribute 'access' invalid mode 'read_onlX'" } +__attribute__ ((access (write_onlX, 1))) int f11 (char*); // { dg-error "attribute 'access' invalid mode 'write_onlX'" } +__attribute__ ((access (read_writX, 1))) int f12 (char*); // { dg-error "attribute 'access' invalid mode 'read_writX'" } diff --git a/SingleSource/Regression/C/gcc-dg/attr-alias-1.c b/SingleSource/Regression/C/gcc-dg/attr-alias-1.c new file mode 100644 index 0000000000..8f530a84ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alias-1.c @@ -0,0 +1,8 @@ +/* PR c++/12795 */ +/* { dg-require-alias "" } */ + +void foo() +{ + extern void bar () __attribute__ ((__alias__ ("BAR"))); /* { dg-warning "ignored" } */ + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alias-2.c b/SingleSource/Regression/C/gcc-dg/attr-alias-2.c new file mode 100644 index 0000000000..c4179a47ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alias-2.c @@ -0,0 +1,20 @@ +/* PR 19031 */ +/* { dg-do link } */ +/* { dg-require-alias "" } */ +/* { dg-options "-funit-at-a-time" } */ + +static int f1 (void) { return 0; } +extern int g1 (void) __attribute__((__alias__("f1"))); + +#define STR(x) STR1(__USER_LABEL_PREFIX__, x) +#define STR1(x,y) STR2(x, y) +#define STR2(x,y) #x #y + +static int f2 (void) __asm__(STR(a2)); +static int f2 (void) { return 0; } +extern int g2 (void) __attribute__((__alias__("a2"))); + +int main () +{ + return g1() + g2(); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alias-3.c b/SingleSource/Regression/C/gcc-dg/attr-alias-3.c new file mode 100644 index 0000000000..03c4da9652 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alias-3.c @@ -0,0 +1,63 @@ +// { dg-do link } +// { dg-skip-if "" { "powerpc-ibm-aix*" } } +// { dg-require-alias "" } +// { dg-options "-O2 -fno-common" } + +// Copyright 2005 Free Software Foundation, Inc. +// Contributed by Alexandre Oliva + +// PR middle-end/24295 + +// The unit-at-a-time call graph code used to fail to emit variables +// without external linkage that were only used indirectly, through +// aliases. Although the PR above is about #pragma weak-introduced +// aliases, the underlying machinery is the same. + +#ifndef ATTRIBUTE_USED +# define ATTRIBUTE_USED __attribute__((used)) +#endif + +static int lv1; +extern int Av1a __attribute__((alias ("lv1"))); +int *pv1a = &Av1a; + +static int lv2; +extern int Av2a __attribute__((alias ("lv2"))); +int *pv2a = &lv2; + +static int lv3; +extern int Av3a __attribute__((alias ("lv3"))); +static int *pv3a ATTRIBUTE_USED = &Av3a; + +static int lv4; +extern int Av4a __attribute__((alias ("lv4"))); +static int *pv4a = &Av4a; + +typedef void ftype(void); + +static void lf1(void) {} +extern ftype Af1a __attribute__((alias ("lf1"))); +ftype *pf1a = &Af1a; + +static void lf2(void) {} +extern ftype Af2a __attribute__((alias ("lf2"))); +ftype *pf2a = &Af2a; + +static void lf3(void) {} +extern ftype Af3a __attribute__((alias ("lf3"))); +static ftype *pf3a ATTRIBUTE_USED = &Af3a; + +static void lf4(void) {} +extern ftype Af4a __attribute__((alias ("lf4"))); +static ftype *pf4a = &Af4a; + +int +main() { +#ifdef __mips + /* Use real asm for MIPS, to stop the assembler warning about + orphaned high-part relocations. */ + asm volatile ("lw $2,%0\n\tlw $2,%1" : : "m" (pv4a), "m" (pf4a) : "$2"); +#else + asm volatile ("" : : "m" (pv4a), "m" (pf4a)); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alias-4.c b/SingleSource/Regression/C/gcc-dg/attr-alias-4.c new file mode 100644 index 0000000000..fb15a20bf8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alias-4.c @@ -0,0 +1,4 @@ +/* ICE on invalid alias attribute: PR 35434. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +typedef int i __attribute__((alias("j"))); /* { dg-warning "ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-alias-5.c b/SingleSource/Regression/C/gcc-dg/attr-alias-5.c new file mode 100644 index 0000000000..a65fe0b9cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alias-5.c @@ -0,0 +1,14 @@ +/* Verify diagnostics for aliases to strings containing extended + identifiers or bad characters. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -w" } */ +/* { dg-require-alias "" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { powerpc*-*-aix* } } */ + +void f0 (void) __attribute__((alias("\xa1"))); /* { dg-error "undefined symbol '\\\\241'" } */ +void f1 (void) __attribute__((alias("\u00e9"))); /* { dg-error "undefined symbol '\\\\U000000e9'" } */ +void f2 (void) __attribute__((alias("\uffff"))); /* { dg-error "undefined symbol '\\\\U0000ffff'" } */ +void f3 (void) __attribute__((alias("\U000fffff"))); /* { dg-error "undefined symbol '\\\\U000fffff'" } */ +void f4 (void) __attribute__((alias("\U00ffffff"))); /* { dg-error "undefined symbol '\\\\U00ffffff'" } */ +void f5 (void) __attribute__((alias("\U0fffffff"))); /* { dg-error "undefined symbol '\\\\U0fffffff'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-aligned-2.c b/SingleSource/Regression/C/gcc-dg/attr-aligned-2.c new file mode 100644 index 0000000000..ff6516c41e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-aligned-2.c @@ -0,0 +1,21 @@ +/* PR c/88172 - attribute aligned of zero silently accepted but ignored + Verify that valid alignment on functions is accepted for all targets + and that alignment of zero is ignored with a warning. + { dg-do compile } + { dg-options "-Wno-pedantic" } */ + +#define ASSERT(expr) _Static_assert (expr, #expr) +#define ALIGN(n) __attribute__ ((aligned (n))) +#define alignof(expr) __alignof__ (expr) + +ALIGN (0) void f0 (void) { } /* { dg-warning "requested alignment .0. is not a positive power of 2" } */ +ALIGN (1) void f1 (void) { } +ALIGN (2) void f2 (void) { } +ALIGN (3) void f3 (void) { } /* { dg-error "requested alignment '3' is not a positive power of 2" } */ +ALIGN (4) void f4 (void) { } + +ASSERT (alignof (f0) > 0); +ASSERT (alignof (f1) >= 1); +ASSERT (alignof (f2) >= 2); +ASSERT (alignof (f3) >= 1); +ASSERT (alignof (f4) >= 4); diff --git a/SingleSource/Regression/C/gcc-dg/attr-aligned-3.c b/SingleSource/Regression/C/gcc-dg/attr-aligned-3.c new file mode 100644 index 0000000000..7415e5252f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-aligned-3.c @@ -0,0 +1,31 @@ +/* PR c/89812 - incorrect maximum in error: requested alignment '536870912' + exceeds maximum 2147483648 + Limit to ELF targets that are known to use MAX_OFILE_ALIGNMENT + (1 << 28) * BITS_PER_UNIT. + { dg-do compile { target { { *-*-elf* *-*-gnu* *-*-solaris2.* } && { ! avr*-*-* } } } } + { dg-require-effective-target size32plus } + { dg-options "" } */ + +#define POWALIGN(N) __attribute__ ((aligned ((__UINT64_TYPE__)1 << (N)))) + +typedef POWALIGN (28) char T28; + +/* The maximum alignment is constrained by the number of bits in int + on host minus 3: HOST_BITS_PER_INT - LOG2_BITS_PER_UNIT. The test + assumes host int is 32-bits wide. */ +typedef POWALIGN (29) char X29; /* { dg-error "requested alignment .536870912. exceeds maximum 268435456" } */ +typedef POWALIGN (30) char X30; /* { dg-error "requested alignment .1073741824. exceeds maximum 268435456" } */ +typedef POWALIGN (31) char X31; /* { dg-error "requested alignment .2147483648. exceeds maximum 268435456" } */ +typedef POWALIGN (32) char X32; /* { dg-error "requested alignment .4294967296. exceeds maximum 268435456" } */ +typedef POWALIGN (60) char X60; /* { dg-error "requested alignment .1152921504606846976. exceeds maximum 268435456" } */ +typedef POWALIGN (63) char X63; /* { dg-error "requested alignment .9223372036854775808. exceeds maximum 268435456" } */ + + +POWALIGN (28) char c28; + +POWALIGN (29) char c29; /* { dg-error "requested alignment .536870912. exceeds object file maximum 268435456" } */ +POWALIGN (30) char x30; /* { dg-error "requested alignment .1073741824. exceeds object file maximum 268435456" } */ +POWALIGN (31) char x31; /* { dg-error "requested alignment .2147483648. exceeds object file maximum 268435456" } */ +POWALIGN (32) char x32; /* { dg-error "requested alignment .4294967296. exceeds object file maximum 268435456" } */ +POWALIGN (60) char x60; /* { dg-error "requested alignment .1152921504606846976. exceeds object file maximum 268435456" } */ +POWALIGN (63) char x63; /* { dg-error "requested alignment .9223372036854775808. exceeds object file maximum 268435456" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-aligned.c b/SingleSource/Regression/C/gcc-dg/attr-aligned.c new file mode 100644 index 0000000000..4f0c885dc8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-aligned.c @@ -0,0 +1,160 @@ +/* PR c/87795 - Excessive alignment permitted for functions and labels + { dg-do compile } + { dg-options "-Wno-pedantic" } */ + +/* The maximum alignment GCC can handle. */ +#define ALIGN_MAX_HARD 0x10000000 + +/* Hardcode a few known values for testing the tight bounds. */ +#if __hpux__ && __hppa__ && __LP64__ + /* Maximum alignment for functions and objects with static storage + duration that's expected to be accepted. */ +# define ALIGN_MAX_STATIC 0x1000 + /* Excessive alignment for functions and objects with static storage + duration that's expected to trigger an error. */ +#elif __APPLE__ +# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 +# define ALIGN_MAX_STATIC 0x8000 +# else +# define ALIGN_MAX_STATIC ALIGN_MAX_HARD +# endif +#elif __CRIS__ +/* __BIGGEST_ALIGNMENT__ doesn't cover functions (16 bits for CRIS). */ +# define ALIGN_MAX_STATIC 512 +# define ALIGN_TOO_BIG_OFILE (ALIGN_MAX_HARD << 1) +#elif pdp11 +# define ALIGN_MAX_STATIC 2 +/* Work around a pdp11 ICE (see PR target/87821). */ +# define ALIGN_MAX_AUTO (ALIGN_MAX_HARD >> 14) +#elif __WIN32__ || __CYGWIN__ +# define ALIGN_MAX_STATIC 8192 +# define ALIGN_MAX_AUTO 8192 +#elif __powerpc64__ || __x86_64__ +/* Is this processor- or operating-system specific? */ +# define ALIGN_MAX_STATIC ALIGN_MAX_HARD +#else + /* Guaranteed to be accepted regardless of the target for objects. + This might not be true for alignment of functions though, so + may need to be set to a target-specific value above. */ +# define ALIGN_MAX_STATIC __BIGGEST_ALIGNMENT__ + /* Guaranteed to be rejected regardless of the target. */ +# define ALIGN_TOO_BIG_OFILE (ALIGN_MAX_HARD << 1) +#endif + +/* Maximum alignment for auto objects that's expected to be accepted. */ +#ifndef ALIGN_MAX_AUTO +# define ALIGN_MAX_AUTO ALIGN_MAX_HARD +#endif + +#ifndef ALIGN_TOO_BIG_OFILE +# define ALIGN_TOO_BIG_OFILE (ALIGN_MAX_STATIC << 1) +#endif + + +#define ALIGN(N) __attribute__ ((aligned (N))) + + +/* Verify that types can be defined maximally overaligned using + attribute aligned. */ +typedef ALIGN (ALIGN_MAX_HARD) char CharAlignedMaxHard; +typedef ALIGN (ALIGN_MAX_AUTO) char CharAlignedMaxAuto; +typedef ALIGN (ALIGN_MAX_STATIC) char CharAlignedMaxStatic; + +#if ALIGN_TOO_BIG_OFILE < ALIGN_MAX_HARD +/* Also verify that an alignment greater than MAX_OFILE_ALIGNMENT + is accepted unless the constant is as large as GCC's maximum + supported alignment in any context. */ +typedef ALIGN (ALIGN_TOO_BIG_OFILE) char CharAlignedTooBig; +#endif + +CharAlignedMaxStatic t_max; + +/* Verify that globals can be defined maximally overaligned using + attribute aligned. */ +ALIGN (ALIGN_MAX_STATIC) static const char aligned_sc_max = 0; +ALIGN (ALIGN_MAX_STATIC) const char aligned_c_max = aligned_sc_max; +ALIGN (ALIGN_MAX_STATIC) char aligned_v_max; +ALIGN (ALIGN_MAX_STATIC) void aligned_f_max (void); + +_Static_assert (__alignof__ (aligned_sc_max) == ALIGN_MAX_STATIC); +_Static_assert (__alignof__ (aligned_c_max) == ALIGN_MAX_STATIC); +_Static_assert (__alignof__ (aligned_v_max) == ALIGN_MAX_STATIC); +_Static_assert (__alignof__ (aligned_f_max) == ALIGN_MAX_STATIC); + + +/* Verify that globals can be defined maximally overaligned using + _Alignas. */ +_Alignas (ALIGN_MAX_STATIC) static const char alignas_sc_max = 0; +_Alignas (ALIGN_MAX_STATIC) const char alignas_c_max = alignas_sc_max; +_Alignas (ALIGN_MAX_STATIC) char alignas_v_max; + +_Static_assert (__alignof__ (alignas_sc_max) == ALIGN_MAX_STATIC); +_Static_assert (__alignof__ (alignas_c_max) == ALIGN_MAX_STATIC); +_Static_assert (__alignof__ (alignas_v_max) == ALIGN_MAX_STATIC); + + +/* Verify that auto and static local variables can be defined maximally + overaligned. */ + +int accept_local_attribute_aligned (void) +{ +#if ALIGN_TOO_BIG_OFILE < ALIGN_MAX_HARD + /* Same as above. */ + typedef ALIGN (ALIGN_TOO_BIG_OFILE) char LocalCharAlignedTooBig; + LocalCharAlignedTooBig aligned_lt_too_big = 0; + (void)&aligned_lt_too_big; +#endif + + static CharAlignedMaxStatic aligned_st_max; + _Static_assert (_Alignof (aligned_st_max) == ALIGN_MAX_STATIC); + + CharAlignedMaxAuto aligned_t_max; + _Static_assert (_Alignof (aligned_t_max) == ALIGN_MAX_AUTO); + + ALIGN (ALIGN_MAX_STATIC) char aligned_s_max; + _Static_assert (_Alignof (aligned_s_max) == ALIGN_MAX_STATIC); + + ALIGN (ALIGN_MAX_AUTO) char aligned_l_max; + _Static_assert (_Alignof (aligned_l_max) == ALIGN_MAX_AUTO); + + return aligned_st_max++ + aligned_t_max++ + aligned_s_max++ + aligned_l_max++; +} + + +int accept_local_alignas (void) +{ + _Alignas (ALIGN_MAX_STATIC) char alignas_s_max; + _Static_assert (_Alignof (alignas_s_max) == ALIGN_MAX_STATIC); + + _Alignas (ALIGN_MAX_AUTO) char alignas_l_max; + _Static_assert (_Alignof (alignas_l_max) == ALIGN_MAX_AUTO); + + return alignas_s_max++ + alignas_l_max++; +} + + +/* Verify that auto and static local variables are subject to the object + file alignment limit. The "object file" part may not be mentioned if + the object file maximum is the same as GCC's internal maximum. */ + +int reject_local_align (void) +{ + /* Ironically, the errors below are on different lines for each + of the two declarations if the aligned attribute is on a line + of its own. */ + ALIGN (ALIGN_TOO_BIG_OFILE) static char aligned_sl_max; /* { dg-error "requested alignment .\[0-9\]+. exceeds\( object file\)* maximum \[0-9\]+" } */ + + _Alignas (ALIGN_TOO_BIG_OFILE) static char alignas_sl_max; /* { dg-error "alignment" } */ + + return aligned_sl_max++ + alignas_sl_max++; +} + + +/* Verify that global variables are subject to the object file + alignment limit. */ + +ALIGN (ALIGN_TOO_BIG_OFILE) char a_max_x_2; /* { dg-error "requested alignment .\[0-9\]+. exceeds\( object file\)* maximum \[0-9\]+" } */ + +_Alignas (ALIGN_TOO_BIG_OFILE) char a_max_x_2; /* { dg-error "alignment" } */ + +ALIGN (ALIGN_TOO_BIG_OFILE) void f_max_x_2 (void); /* { dg-error "requested alignment .\[0-9\]+. exceeds\( object file\)* maximum \[0-9\]+" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_align-1.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-1.c new file mode 100644 index 0000000000..45f5ec065e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-1.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +double *my_alloc1 (int len, int align) __attribute__((__alloc_align__ (2))); +double *my_alloc2 (int align, int len) __attribute__((alloc_align (1))); + +void +test1 (int len, int align) +{ + int i; + double *__restrict o1 = my_alloc1 (len, 32); + double *__restrict o2 = my_alloc1 (len, 32); + double *__restrict o3 = my_alloc1 (len, 32); + double *__restrict i1 = my_alloc1 (len, 32); + double *__restrict i2 = my_alloc1 (len, align); + for (i = 0; i < len; ++i) + { + o1[i] = i1[i] * i2[i]; + o2[i] = i1[i] + i2[i]; + o3[i] = i1[i] - i2[i]; + } +} + +void +test2 (int len, int align) +{ + int i; + double *__restrict o1 = my_alloc2 (32, len); + double *__restrict o2 = my_alloc2 (32, len); + double *__restrict o3 = my_alloc2 (32, len); + double *__restrict i1 = my_alloc2 (32, len); + double *__restrict i2 = my_alloc2 (align, len); + for (i = 0; i < len; ++i) + { + o1[i] = i1[i] * i2[i]; + o2[i] = i1[i] + i2[i]; + o3[i] = i1[i] - i2[i]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_align-2.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-2.c new file mode 100644 index 0000000000..01321e7785 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +int i; +void *f1 (int) __attribute__((alloc_align (1))); +void *f2 (int, int, int) __attribute__((alloc_align (3))); +void *f3 (void) __attribute__((alloc_align)); /* { dg-error "wrong number of arguments specified" } */ +void *f4 (int, int) __attribute__((alloc_align (1, 2))); /* { dg-error "wrong number of arguments specified" } */ +void *f5 (void) __attribute__((alloc_align (i))); /* { dg-warning ".alloc_align. attribute argument value .i. is not an integer constant" } */ +void *f6 (int) __attribute__((alloc_align (0))); /* { dg-warning ".alloc_align. attribute argument value .0. does not refer to a function parameter" } */ +void *f7 (int) __attribute__((alloc_align (2))); /* { dg-warning ".alloc_align. attribute argument value .2. exceeds the number of function parameters 1" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_align-3.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-3.c new file mode 100644 index 0000000000..34d1b4a0a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-3.c @@ -0,0 +1,55 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +char *my_alloc1 (int len, int align) __attribute__((__alloc_align__ (2))); +char *my_alloc2 (int align, int len) __attribute__((alloc_align (1))); + +int +test1 (int len) +{ + int i; + char *p = my_alloc1 (len, 32); + return ((__INTPTR_TYPE__) p) & 31; +} + +int +test2 (int len) +{ + int i; + char *p = my_alloc2 (32, len); + return ((__INTPTR_TYPE__) p) & 31; +} + +int +test3 (int len) +{ + int i; + char *p = my_alloc1 (len, 16); + return ((__INTPTR_TYPE__) p) & 15; +} + +int +test4 (int len) +{ + int i; + char *p = my_alloc2 (16, len); + return ((__INTPTR_TYPE__) p) & 15; +} + +int +test5 (int len, int align) +{ + int i; + char *p = my_alloc1 (len, align); + return ((__INTPTR_TYPE__) p) & 15; +} + +int +test6 (int len, int align) +{ + int i; + char *p = my_alloc2 (align, len); + return ((__INTPTR_TYPE__) p) & 15; +} + +/* { dg-final { scan-tree-dump-times "return 0" 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_align-4.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-4.c new file mode 100644 index 0000000000..7cdfc7d840 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-4.c @@ -0,0 +1,43 @@ +/* PR middle-end/81871 - bogus attribute alloc_align accepted + { dg-do compile } + { dg-options "-Wall" } */ + +#define ALIGN(N) __attribute__ ((alloc_align (N))) +#define SIZE_MAX __SIZE_MAX__ + +ALIGN (1) void fvv_m1 (void); /* { dg-warning ".alloc_align. attribute ignored on a function returning .void." } */ + +ALIGN (1) int fiv_1 (void); /* { dg-warning ".alloc_align. attribute ignored on a function returning .int." } */ + +ALIGN (0) void* fpvv_0 (void); /* { dg-warning ".alloc_align. attribute argument value .0. does not refer to a function parameter" } */ + +ALIGN (1) void* fpvv_1 (void); /* { dg-warning ".alloc_align. attribute argument value .1. exceeds the number of function parameters 0" } */ + +ALIGN (2) void* fii_2 (int); /* { dg-warning ".alloc_align. attribute argument value .2. exceeds the number of function parameters 1" } */ + +ALIGN (1) void fvi_1 (int); /* { dg-warning ".alloc_align. attribute ignored on a function returning .void." } */ + +/* Using alloc_align with a function returning a pointer to a function + should perhaps trigger a warning. */ +typedef void (F)(void); +ALIGN (1) F* fpF_i_1 (int); + +ALIGN (SIZE_MAX) void* +fpvi_szmax (int); /* { dg-warning ".alloc_align. attribute argument value .\[0-9\]+. exceeds the number of function parameters 1" } */ + +ALIGN ("1") void* +fpvi_str_1 (int); /* { dg-warning ".alloc_align. attribute argument has type .char\\\[2]" } */ + +ALIGN ((void*)0) void* +fpvi_pv0 (int); /* { dg-warning ".alloc_align. attribute argument has type .void \\\*." } */ + +ALIGN ((double*)1) void* +fpvi_pd1 (int); /* { dg-warning ".alloc_align. attribute argument has type .double \\\*." } */ + +ALIGN (1) void* +fpvi_pv_1 (void*); /* { dg-warning ".alloc_align. attribute argument value .1. refers to parameter type .void \\\*." } */ + +struct S { int i; }; +ALIGN (2) void* +fpvi_S_2 (int, struct S); /* { dg-warning ".alloc_align. attribute argument value .2. refers to parameter type .struct S." } */ + diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_align-5.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-5.c new file mode 100644 index 0000000000..d6f2bc19da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_align-5.c @@ -0,0 +1,23 @@ +/* PR c/78666 - conflicting attribute alloc_size accepted + { dg-do compile } + { dg-options "-Wall" } */ + +#define A(pos) __attribute__ ((alloc_align (pos))) + +A (1) char* f2_1 (int, int); +A (1) char* f2_1 (int, int); // { dg-message "previous declaration here" } + +A (2) char* f2_1 (int, int); // { dg-warning "ignoring attribute 'alloc_align \\\(2\\\)' because it conflicts with previous 'alloc_align \\\(1\\\)'" } + + +A (2) char* f2_2 (int, int); +A (2) char* f2_2 (int, int); // { dg-message "previous declaration here" } + +A (1) char* f2_2 (int, int); // { dg-warning "ignoring attribute 'alloc_align \\\(1\\\)' because it conflicts with previous 'alloc_align \\\(2\\\)'" } + + +A (1) char* f3_1 (int, int, int); +A (1) char* f3_1 (int, int, int); // { dg-message "previous declaration here" } + +A (2) char* f3_1 (int, int, int); // { dg-warning "ignoring attribute 'alloc_align \\\(2\\\)' because it conflicts with previous 'alloc_align \\\(1\\\)'" } +A (3) char* f3_1 (int, int, int); // { dg-warning "ignoring attribute 'alloc_align \\\(3\\\)' because it conflicts with previous 'alloc_align \\\(1\\\)'" } diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-10.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-10.c new file mode 100644 index 0000000000..071c6aa1e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-10.c @@ -0,0 +1,143 @@ +/* Verify that -Walloc-size-greater-than doesn't cause false positives + for anti-ranges. Note that not all of the statements used to create + anti-ranges below result in the argument being represented as an anti + range. + + { dg-do compile } + { dg-options "-O2 -Walloc-size-larger-than=12" } + { dg-options "-Wno-overflow" { target { ! int32plus } } } */ + +#define SCHAR_MAX __SCHAR_MAX__ +#define SCHAR_MIN (-SCHAR_MAX - 1) +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +#define SHRT_MAX __SHRT_MAX__ +#define SHRT_MIN (-SHRT_MAX - 1) +#define USHRT_MAX (SHRT_MAX * 2U + 1) + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (INT_MAX * 2U + 1) + +#define LONG_MAX __LONG_MAX__ +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX (LONG_MAX * 2LU + 1) + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define PTRDIFF_MIN (-PTRDIFF_MAX - 1) +#define SIZE_MAX __SIZE_MAX__ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT (a, b) + +/* Macro to generate a unique function to test the anti-range + ~[MIN, MAX] for type T. */ +#define TEST(T, min, max) \ + void* CAT (test_anti_range_, __LINE__)(T n) \ + { \ + extern void* CAT (alloc_anti_range_, __LINE__)(T) \ + __attribute__ ((alloc_size (1))); \ + if (min <= n && n <= max) \ + n = min - 1; \ + return CAT (alloc_anti_range_, __LINE__)(n); \ + } typedef void dummy /* Require a semicolon. */ + + +/* Verify the anti-range ~[TYPE_MAX - 1, TYPE_MAX - 1]. */ +TEST (signed char, SCHAR_MAX - 1, SCHAR_MAX - 1); +TEST (unsigned char, UCHAR_MAX - 1, UCHAR_MAX - 1); +TEST (short, SHRT_MAX - 1, SHRT_MAX - 1); +TEST (unsigned short, USHRT_MAX - 1, USHRT_MAX - 1); +TEST (int, INT_MAX - 1, INT_MAX - 1); +TEST (unsigned, UINT_MAX - 1, UINT_MAX - 1); +TEST (long, LONG_MAX - 1, LONG_MAX - 1); +TEST (unsigned long, ULONG_MAX - 1, ULONG_MAX - 1); +TEST (ptrdiff_t, PTRDIFF_MAX - 1, PTRDIFF_MAX - 1); +TEST (size_t, SIZE_MAX - 1, SIZE_MAX - 1); + +/* Verify ~[0, 0]. */ +TEST (signed char, 0, 0); +TEST (unsigned char, 0, 0); +TEST (short, 0, 0); +TEST (unsigned short, 0, 0); +TEST (int, 0, 0); +TEST (unsigned, 0, 0); +TEST (long, 0, 0); +TEST (unsigned long, 0, 0); +TEST (ptrdiff_t, 0, 0); +TEST (size_t, 0, 0); + +/* Verify ~[1, 1]. */ +TEST (signed char, 1, 1); +TEST (unsigned char, 1, 1); +TEST (short, 1, 1); +TEST (unsigned short, 1, 1); +TEST (int, 1, 1); +TEST (unsigned, 1, 1); +TEST (long, 1, 1); +TEST (unsigned long, 1, 1); +TEST (ptrdiff_t, 1, 1); +TEST (size_t, 1, 1); + + +/* Verify ~[TYPE_MAX - 2, TYPE_MAX - 1]. */ +TEST (signed char, SCHAR_MAX - 2, SCHAR_MAX - 1); +TEST (unsigned char, UCHAR_MAX - 2, UCHAR_MAX - 1); +TEST (short, SHRT_MAX - 2, SHRT_MAX - 1); +TEST (unsigned short, USHRT_MAX - 2, USHRT_MAX - 1); +TEST (int, INT_MAX - 2, INT_MAX - 1); +TEST (unsigned, UINT_MAX - 2, UINT_MAX - 1); +TEST (long, LONG_MAX - 2, LONG_MAX - 1); +TEST (unsigned long, ULONG_MAX - 2, ULONG_MAX - 1); +TEST (ptrdiff_t, PTRDIFF_MAX - 2, PTRDIFF_MAX - 1); +TEST (size_t, SIZE_MAX - 2, SIZE_MAX - 1); + +/* Verify ~[0, 2]. */ +TEST (signed char, 0, 2); +TEST (unsigned char, 0, 2); +TEST (short, 0, 2); +TEST (unsigned short, 0, 2); +TEST (int, 0, 2); +TEST (unsigned int, 0, 2); +TEST (long, 0, 2); +TEST (unsigned long, 0, 2); +TEST (ptrdiff_t, 0, 2); +TEST (size_t, 0, 2); + +/* Verify the signed anti-range ~[TYPE_MIN - 2, -1]. */ +TEST (signed char, SCHAR_MIN + 2, -1); +TEST (short, SHRT_MIN + 2, -1); +TEST (int, INT_MIN + 2, -1); +TEST (long, LONG_MIN + 2, -1); +TEST (ptrdiff_t, PTRDIFF_MIN + 2, -1); + +/* Verify the signed anti-range ~[TYPE_MIN - 2, 0]. */ +TEST (signed char, SCHAR_MIN + 2, 0); +TEST (short, SHRT_MIN + 2, 0); +TEST (int, INT_MIN + 2, 0); +TEST (long, LONG_MIN + 2, 0); +TEST (ptrdiff_t, PTRDIFF_MIN + 2, 0); + +/* Verify the signed anti-range ~[TYPE_MIN - 2, 1]. */ +TEST (signed char, SCHAR_MIN + 2, 1); +TEST (short, SHRT_MIN + 2, 1); +TEST (int, INT_MIN + 2, 1); +TEST (long, LONG_MIN + 2, 1); +TEST (ptrdiff_t, PTRDIFF_MIN + 2, 1); + +/* Verify the signed anti-range ~[TYPE_MIN - 2, 2]. */ +TEST (signed char, SCHAR_MIN + 2, 2); +TEST (short, SHRT_MIN + 2, 2); +TEST (int, INT_MIN + 2, 2); +TEST (long, LONG_MIN + 2, 2); +TEST (ptrdiff_t, PTRDIFF_MIN + 2, 2); + +/* Verify the signed anti-range ~[-1, 2]. */ +TEST (signed char, -1, 2); +TEST (short, -1, 2); +TEST (int, -1, 2); +TEST (long, -1, 2); +TEST (ptrdiff_t, 01, 2); diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-11.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-11.c new file mode 100644 index 0000000000..a2efe12891 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-11.c @@ -0,0 +1,69 @@ +/* Verify that -Walloc-size-greater-than doesn't cause false positives + for anti-ranges. Note that not all of the statements below result + in the argument being represented as an anti-range. + + { dg-do compile } + { dg-options "-O2 -Walloc-size-larger-than=12 -ftrack-macro-expansion=0" } */ + +#define SCHAR_MAX __SCHAR_MAX__ +#define SCHAR_MIN (-SCHAR_MAX - 1) +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +#define SHRT_MAX __SHRT_MAX__ +#define SHRT_MIN (-SHRT_MAX - 1) +#define USHRT_MAX (SHRT_MAX * 2U + 1) + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (INT_MAX * 2U + 1) + +#define LONG_MAX __LONG_MAX__ +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX (LONG_MAX * 2LU + 1) + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define PTRDIFF_MIN (-PTRDIFF_MAX - 1) +#define SIZE_MAX __SIZE_MAX__ + +#define ALLOC_MAX 12 + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT (a, b) + +/* Macro to generate a unique function to test the anti-range + ~[MIN, MAX] for type T. */ +#define TEST(T, min, max) \ + void* CAT (test_anti_range_, __LINE__)(T n) \ + { \ + extern void* CAT (alloc_anti_range_, __LINE__)(T) \ + __attribute__ ((alloc_size (1))); \ + if (min <= n && n <= max) \ + n = min - 1; \ + return CAT (alloc_anti_range_, __LINE__)(n); \ + } typedef void dummy /* Require a semicolon. */ + +/* The following tests fail because of missing range information. The xfail + exclusions are PR79356. */ +TEST (signed char, SCHAR_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for signed char" { xfail { ! { aarch64*-*-* arm*-*-* avr-*-* alpha*-*-* cris-*-* ia64-*-* mips*-*-* or1k*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390*-*-* visium-*-* msp430-*-* nvptx*-*-*} } } } */ +TEST (short, SHRT_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" "missing range info for short" { xfail { ! { aarch64*-*-* arm*-*-* alpha*-*-* avr-*-* cris-*-* ia64-*-* mips*-*-* or1k*-*-* pdp11*-*-* powerpc*-*-* sparc*-*-* s390x-*-* visium-*-* msp430-*-* nvptx*-*-* } } } } */ +TEST (int, INT_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (int, -3, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (int, -2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (int, -1, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (int, 0, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (int, 1, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (int, 1, INT_MAX - 1); /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size 12" } */ + +/* The following two aren't necessarily anti-ranges. */ +TEST (int, 1, INT_MAX); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, 0\\\] is negative" } */ +TEST (int, 0, INT_MAX); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, -1\\\] is negative" } */ + +TEST (long, LONG_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (ptrdiff_t, PTRDIFF_MIN + 2, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ + +TEST (unsigned, 0, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (unsigned long, 0, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ +TEST (size_t, 0, ALLOC_MAX); /* { dg-warning "argument 1 range \\\[13, \[0-9\]+\\\] exceeds maximum object size 12" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-12.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-12.c new file mode 100644 index 0000000000..2e9be1e786 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-12.c @@ -0,0 +1,60 @@ +/* PR middle-end/81871 - bogus attribute alloc_align accepted + Test exercising the problem with attribute alloc_size. + { dg-do compile } + { dg-options "-Wall" } */ + +#define ASIZE(...) __attribute__ ((alloc_size (__VA_ARGS__))) +#define SIZE_MAX __SIZE_MAX__ + +ASIZE (-1) void fvv_m1 (void); /* { dg-warning ".alloc_size. attribute ignored on a function returning .void." } */ + +ASIZE (1) int fiv_1 (void); /* { dg-warning ".alloc_size. attribute ignored on a function returning .int." } */ + +ASIZE (1, 2) int fiv_1_2 (void); /* { dg-warning ".alloc_size. attribute ignored on a function returning .int." } */ + +ASIZE (0) void* fpvv_0 (void); /* { dg-warning ".alloc_size. attribute argument value .0. does not refer to a function parameter" } */ + +ASIZE (1, 0) void* +fpvv_1_0 (int); /* { dg-warning ".alloc_size. attribute argument 2 value .0. does not refer to a function parameter" } */ + +ASIZE (1) void* fpvv_1 (void); /* { dg-warning ".alloc_size. attribute argument value .1. exceeds the number of function parameters 0" } */ + +ASIZE (1, 9) void* +fpvv_1_9 (int); /* { dg-warning ".alloc_size. attribute argument 2 value .9. exceeds the number of function parameters 1" } */ + +ASIZE (2) void* fii_2 (int); /* { dg-warning ".alloc_size. attribute argument value .2. exceeds the number of function parameters 1" } */ + +ASIZE (1) void fvi_1 (int); /* { dg-warning ".alloc_size. attribute ignored on a function returning .void." } */ + +/* Using alloc_size with a function returning a pointer to a function + should perhaps trigger a warning. */ +typedef void (F)(void); +ASIZE (1) F* fpF_i_1 (int); + +ASIZE (SIZE_MAX) void* +fpvi_szmax (int); /* { dg-warning ".alloc_size. attribute argument value .\[0-9\]+. exceeds the number of function parameters 1" } */ + +ASIZE ("12") void* +fpvi_str_1 (int); /* { dg-warning ".alloc_size. attribute argument has type .char\\\[3]." } */ + +ASIZE (1, "123") void* +fpvi_str_2 (int, int); /* { dg-warning ".alloc_size. attribute argument 2 has type .char\\\[4]." } */ + +ASIZE ((void*)0) void* +fpvi_pv0 (int); /* { dg-warning ".alloc_size. attribute argument has type .void \\\*." } */ + +ASIZE ((double*)sizeof (double)) void* +fpvi_pd1 (int); /* { dg-warning ".alloc_size. attribute argument has type .double \\\*." } */ + +ASIZE (1) void* +fpvi_pv_1 (void*); /* { dg-warning ".alloc_size. attribute argument value .1. refers to parameter type .void \\\*." } */ + +struct S { int i; }; +ASIZE (2) void* +fpvi_S_2 (int, struct S); /* { dg-warning ".alloc_size. attribute argument value .2. refers to parameter type .struct S." } */ + +ASIZE ((struct S){ 1 }) void* +fpvi_S (int); /* { dg-warning ".alloc_size. attribute argument has type .struct S." } */ + +ASIZE (1, (struct S){ 1 }) void* +fpvi_1_S (int); /* { dg-warning ".alloc_size. attribute argument 2 has type .struct S." } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-13.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-13.c new file mode 100644 index 0000000000..df44f479e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-13.c @@ -0,0 +1,34 @@ +/* PR c/78666 - conflicting attribute alloc_size accepted + { dg-do compile } + { dg-options "-Wall" } */ + +#define A(...) __attribute__ ((alloc_size (__VA_ARGS__))) + +A (1) char* f2_1 (int, int); +A (1) A (1) char* f2_1 (int, int); + +A (1) char* f2_1 (int, int); // { dg-message "previous declaration here" } + +A (2) char* f2_1 (int, int); // { dg-warning "ignoring attribute 'alloc_size \\\(2\\\)' because it conflicts with previous 'alloc_size \\\(1\\\)'" } + + +A (2) char* f2_2 (int, int); +A (2) char* f2_2 (int, int); // { dg-message "previous declaration here" } + +A (1) char* f2_2 (int, int); // { dg-warning "ignoring attribute 'alloc_size \\\(1\\\)' because it conflicts with previous 'alloc_size \\\(2\\\)'" } + + +A (1) char* f3_1 (int, int, int); +A (1) char* f3_1 (int, int, int); // { dg-message "previous declaration here" } + +A (2) char* f3_1 (int, int, int); // { dg-warning "ignoring attribute 'alloc_size \\\(2\\\)' because it conflicts with previous 'alloc_size \\\(1\\\)'" } +A (3) char* f3_1 (int, int, int); // { dg-warning "ignoring attribute 'alloc_size \\\(3\\\)' because it conflicts with previous 'alloc_size \\\(1\\\)'" } +A (1, 2) char* f3_1 (int, int, int); // { dg-warning "ignoring attribute 'alloc_size \\\(1, 2\\\)' because it conflicts with previous 'alloc_size \\\(1\\\)'" } +A (1, 3) char* f3_1 (int, int, int); // { dg-warning "ignoring attribute 'alloc_size \\\(1, 3\\\)' because it conflicts with previous 'alloc_size \\\(1\\\)'" } + + +typedef A (2, 3) char* F3_2_3 (int, int, int); +typedef A (2, 3) char* F3_2_3 (int, int, int); +typedef A (2, 3) A (2, 3) char* F3_2_3 (int, int, int); + +typedef A (1) char* F3_2_3 (int, int, int); // { dg-warning "ignoring attribute 'alloc_size \\\(1\\\)' because it conflicts with previous 'alloc_size \\\(2, 3\\\)'" } diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-2.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-2.c new file mode 100644 index 0000000000..3bbd3e2b98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-2.c @@ -0,0 +1,5 @@ +/* PR c/36021 - __attribute__((alloc_size(n))) with function of no + arguments causes gcc to segfault + { dg-do compile } */ + +char *foo() __attribute__((alloc_size(1))); diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-3.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-3.c new file mode 100644 index 0000000000..7e8c22fc66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-3.c @@ -0,0 +1,466 @@ +/* PR c/77531 - __attribute__((alloc_size(1,2))) could also warn on + multiplication overflow + PR c/78284 - warn on malloc with very large arguments + Test exercising the ability to detect and diagnose calls to allocation + functions decorated with attribute alloc_size that either overflow or + exceed the default maximum object size (with -Walloc-size-larger-than + not explicitly specified). */ +/* { dg-do compile { target size32plus } } */ +/* { dg-options "-O2 -Wall" } */ + +#define SCHAR_MAX __SCHAR_MAX__ +#define SCHAR_MIN (-SCHAR_MAX - 1) +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +#define SHRT_MAX __SHRT_MAX__ +#define SHRT_MIN (-SHRT_MAX - 1) +#define USHRT_MAX (SHRT_MAX * 2U + 1) + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (INT_MAX * 2U + 1) + +#define LONG_MAX __LONG_MAX__ +#define LONG_MIN (-LONG_MAX - 1L) +#define ULONG_MAX (LONG_MAX * 2LU + 1) + +#define LLONG_MAX __LLONG_MAX__ +#define LLONG_MIN (-LLONG_MAX - 1LL) +#define ULLONG_MAX (ULLONG_MAX * 2LLU + 1) + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define PTRDIFF_MIN (-PTRDIFF_MAX - 1) +#define SIZE_MAX __SIZE_MAX__ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +#define ALLOC_SIZE(...) __attribute__ ((alloc_size (__VA_ARGS__))) + +void* f_uchar_1 (unsigned char) ALLOC_SIZE (1); +void* f_uchar_2 (unsigned char, unsigned char) ALLOC_SIZE (1, 2); +void* f_schar_1 (signed char) ALLOC_SIZE (1); +void* f_schar_2 (signed char, signed char) ALLOC_SIZE (1, 2); + +void* f_ushrt_1 (unsigned short) ALLOC_SIZE (1); +void* f_ushrt_2 (unsigned short, unsigned short) ALLOC_SIZE (1, 2); +void* f_shrt_1 (signed short) ALLOC_SIZE (1); +void* f_shrt_2 (signed short, signed short) ALLOC_SIZE (1, 2); + +void* f_uint_1 (unsigned) ALLOC_SIZE (1); +void* f_uint_2 (unsigned, unsigned) ALLOC_SIZE (1, 2); +void* f_int_1 (int) ALLOC_SIZE (1); +void* f_int_2 (int, int) ALLOC_SIZE (1, 2); + +void* f_ulong_1 (unsigned long) ALLOC_SIZE (1); +void* f_ulong_2 (unsigned long, unsigned long) ALLOC_SIZE (1, 2); +void* f_long_1 (long) ALLOC_SIZE (1); +void* f_long_2 (long, long) ALLOC_SIZE (1, 2); + +void* f_ullong_1 (unsigned long long) ALLOC_SIZE (1); +void* f_ullong_2 (unsigned long long, unsigned long long) ALLOC_SIZE (1, 2); +void* f_llong_1 (long long) ALLOC_SIZE (1); +void* f_llong_2 (long long, long long) ALLOC_SIZE (1, 2); + +void* f_size_1 (size_t) ALLOC_SIZE (1); +void* f_size_2 (size_t, size_t) ALLOC_SIZE (1, 2); + +static size_t +unsigned_range (size_t min, size_t max) +{ + extern size_t random_unsigned_value (void); + size_t val = random_unsigned_value (); + if (val < min || max < val) val = min; + return val; +} + +static long long +signed_range (long long min, long long max) +{ + extern long long random_signed_value (void); + long long val = random_signed_value (); + if (val < min || max < val) val = min; + return val; +} + +static size_t +unsigned_anti_range (size_t min, size_t max) +{ + extern size_t random_unsigned_value (void); + size_t val = random_unsigned_value (); + if (min <= val && val <= max) + val = min - 1; + return val; +} + +#define UR(min, max) unsigned_range (min, max) +#define SR(min, max) signed_range (min, max) + +#define UAR(min, max) unsigned_anti_range (min, max) +#define SAR(min, max) signed_anti_range (min, max) + + +void sink (void*); + +void +test_uchar_cst (void) +{ + const unsigned char max = UCHAR_MAX; + + sink (f_uchar_1 (0)); + sink (f_uchar_1 (1)); + sink (f_uchar_1 (max)); + + sink (f_uchar_2 (0, 0)); + sink (f_uchar_2 (0, 1)); + sink (f_uchar_2 (1, 0)); + sink (f_uchar_2 (1, 1)); + sink (f_uchar_2 (0, max)); + sink (f_uchar_2 (max, 0)); + sink (f_uchar_2 (max, max)); +} + +void +test_uchar_range (unsigned char n, int i) +{ + const unsigned char max = UCHAR_MAX; + + sink (f_uchar_1 (n)); + + sink (f_uchar_1 (UR (0, 1))); + sink (f_uchar_1 (UR (1, max))); + sink (f_uchar_1 (UR (0, max - 1))); + + sink (f_uchar_1 (UAR (1, 1))); + sink (f_uchar_1 (UAR (1, max - 1))); + sink (f_uchar_1 (UAR (max - 2, max - 1))); + + sink (f_uchar_2 (0, n)); + sink (f_uchar_2 (0, i)); + sink (f_uchar_2 (n, 0)); + sink (f_uchar_2 (i, 0)); + sink (f_uchar_2 (1, n)); + sink (f_uchar_2 (1, i)); + sink (f_uchar_2 (n, 1)); + sink (f_uchar_2 (i, 1)); + sink (f_uchar_2 (max, n)); + sink (f_uchar_2 (max, i)); + sink (f_uchar_2 (n, max)); + sink (f_uchar_2 (i, max)); + sink (f_uchar_2 (n, n)); + sink (f_uchar_2 (i, i)); + + sink (f_uchar_2 (UR (0, 1), UR (0, 1))); + sink (f_uchar_2 (UR (1, 2), UR (1, 2))); + sink (f_uchar_2 (UR (1, max), UR (0, 1))); + sink (f_uchar_2 (UR (0, 1), UR (1, max))); +} + +void +test_schar_cst (void) +{ + const signed char min = SCHAR_MIN; + const signed char max = SCHAR_MAX; + + sink (f_schar_1 (min)); /* { dg-warning "argument 1 value .-\[0-9\]+. is negative" } */ + sink (f_schar_1 (-1)); /* { dg-warning "argument 1 value .-1. is negative" } */ + sink (f_schar_1 (0)); + sink (f_schar_1 (1)); + sink (f_schar_1 (max)); + + sink (f_schar_2 (0, min)); /* { dg-warning "argument 2 value .-\[0-9\]+. is negative" } */ + sink (f_schar_2 (min, 0)); /* { dg-warning "argument 1 value .-\[0-9\]+. is negative" } */ + sink (f_schar_2 (0, -1)); /* { dg-warning "argument 2 value .-1. is negative" } */ + sink (f_schar_2 (-1, 0)); /* { dg-warning "argument 1 value .-1. is negative" } */ + +} + +void +test_schar_range (signed char n) +{ + const signed char min = SCHAR_MIN; + const signed char max = SCHAR_MAX; + + sink (f_schar_1 (n)); + + sink (f_schar_1 (SR (min, min + 1))); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + sink (f_schar_1 (SR (min, 0))); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + sink (f_schar_1 (SR (-1, 0))); /* { dg-warning "argument 1 range \\\[-1, 0\\\] is negative" } */ + sink (f_schar_1 (SR (-1, 1))); + sink (f_schar_1 (SR (0, 1))); + sink (f_schar_1 (SR (0, max - 1))); + sink (f_schar_1 (SR (1, max))); + sink (f_schar_1 (SR (max - 1, max))); + + sink (f_schar_2 (n, n)); + + sink (f_schar_2 (SR (min, min + 1), n)); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + sink (f_schar_2 (n, SR (min, min + 1))); /* { dg-warning "argument 2 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + sink (f_schar_2 (SR (min, min + 1), 0)); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + sink (f_schar_2 (0, SR (min, min + 1))); /* { dg-warning "argument 2 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + sink (f_schar_2 (SR (min, min + 1), min)); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + /* { dg-warning "argument 2 value .-\[0-9\]+. is negative" "argument 2" { target *-*-* } .-1 } */ + sink (f_schar_2 (min, SR (min, min + 1))); /* { dg-warning "argument 2 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + /* { dg-warning "argument 1 value .-\[0-9\]+. is negative" "argument 1" { target *-*-* } .-1 } */ + + sink (f_schar_2 (SR (-1, 0), 0)); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + sink (f_schar_2 (0, SR (-1, 0))); /* { dg-warning "argument 2 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + sink (f_schar_2 (SR (-1, 0), 1)); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + sink (f_schar_2 (1, SR (-1, 0))); /* { dg-warning "argument 2 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + sink (f_schar_2 (SR (-1, 0), n)); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + sink (f_schar_2 (n, SR (-1, 0))); /* { dg-warning "argument 2 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + + sink (f_schar_2 (max, SR (1, max))); + sink (f_schar_2 (SR (1, max), max)); +} + +void +test_ushrt_cst (void) +{ + const unsigned short max = USHRT_MAX; + + sink (f_ushrt_1 (0)); + sink (f_ushrt_1 (1)); + sink (f_ushrt_1 (max)); + + sink (f_ushrt_2 (0, 0)); + sink (f_ushrt_2 (0, 1)); + sink (f_ushrt_2 (1, 0)); + sink (f_ushrt_2 (1, 1)); + sink (f_ushrt_2 (0, max)); + sink (f_ushrt_2 (max, 0)); + + if (max < SIZE_MAX && (size_t)max * max < SIZE_MAX / 2) + sink (f_ushrt_2 (max, max)); +} + +void +test_ushrt_range (unsigned short n) +{ + const unsigned short max = USHRT_MAX; + + sink (f_ushrt_1 (n)); + sink (f_ushrt_1 (UR (0, 1))); + sink (f_ushrt_1 (UR (1, max - 1))); + sink (f_ushrt_1 (UR (1, max))); + sink (f_ushrt_1 (UR (0, max - 1))); +} + +void +test_shrt_cst (void) +{ + const short min = SHRT_MIN; + const short max = SHRT_MAX; + + sink (f_shrt_1 (min)); /* { dg-warning "argument 1 value .-\[0-9\]+. is negative" } */ + sink (f_shrt_1 (-1)); /* { dg-warning "argument 1 value .-1. is negative" } */ + sink (f_shrt_1 (0)); + sink (f_shrt_1 (1)); + sink (f_shrt_1 (max)); +} + +void +test_shrt_range (short n) +{ + const short min = SHRT_MIN; + const short max = SHRT_MAX; + + sink (f_shrt_1 (n)); + + sink (f_shrt_1 (SR (min, min + 1))); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + sink (f_shrt_1 (SR (min, 0))); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + sink (f_shrt_1 (SR (-1, 0))); /* { dg-warning "argument 1 range \\\[-1, 0\\\] is negative" } */ + sink (f_shrt_1 (SR (-1, 1))); + sink (f_shrt_1 (SR (0, 1))); + sink (f_shrt_1 (SR (0, max - 1))); + sink (f_shrt_1 (SR (1, max))); + sink (f_shrt_1 (SR (max - 1, max))); +} + +void +test_uint_cst (void) +{ + const unsigned max = UINT_MAX; + + sink (f_uint_1 (0)); + sink (f_uint_1 (1)); + + if (max < SIZE_MAX) + { + sink (f_uint_1 (max - 1)); + sink (f_uint_1 (max)); + } +} + +void +test_uint_range (unsigned n) +{ + const unsigned max = UINT_MAX; + + sink (f_uint_1 (n)); + sink (f_uint_1 (UR (0, 1))); + sink (f_uint_1 (UR (0, max - 1))); + sink (f_uint_1 (UR (1, max - 1))); + sink (f_uint_1 (UR (1, max))); +} + +void +test_int_cst (void) +{ + const int min = INT_MIN; + const int max = INT_MAX; + + sink (f_int_1 (min)); /* { dg-warning "argument 1 value .-\[0-9\]+. is negative" } */ + sink (f_int_1 (-1)); /* { dg-warning "argument 1 value .-1. is negative" } */ + sink (f_int_1 (0)); + sink (f_int_1 (1)); + sink (f_int_1 (max)); +} + +void +test_int_range (int n) +{ + const int min = INT_MIN; + const int max = INT_MAX; + + sink (f_int_1 (n)); + + sink (f_int_1 (SR (min, min + 1))); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, -\[0-9\]+\\\] is negative" } */ + sink (f_int_1 (SR (min, 0))); /* { dg-warning "argument 1 range \\\[-\[0-9\]+, 0\\\] is negative" } */ + sink (f_int_1 (SR (-1, 0))); /* { dg-warning "argument 1 range \\\[-1, 0\\\] is negative" } */ + sink (f_int_1 (SR (-1, 1))); + sink (f_int_1 (SR (0, 1))); + sink (f_int_1 (SR (0, max - 1))); + sink (f_int_1 (SR (1, max))); + sink (f_int_1 (SR (max - 1, max))); +} + +void +test_ulong_cst (void) +{ + const unsigned long max = ULONG_MAX; + + sink (f_ulong_1 (0)); + sink (f_ulong_1 (1)); +#if ULONG_MAX < SIZE_MAX + sink (f_ulong_1 (max - 1)); + sink (f_ulong_1 (max)); +#else + (void)&max; +#endif +} + +void +test_ulong_range (unsigned long n) +{ + const unsigned long max = ULONG_MAX; + + sink (f_ulong_1 (n)); + sink (f_ulong_1 (UR (0, 1))); + sink (f_ulong_1 (UR (0, max - 1))); + sink (f_ulong_1 (UR (1, max - 1))); + sink (f_ulong_1 (UR (1, max))); +} + +void +test_long_cst (void) +{ + const long min = LONG_MIN; + const long max = LONG_MAX; + + sink (f_long_1 (min)); /* { dg-warning "argument 1 value .-\[0-9\]+l*. is negative" } */ + sink (f_long_1 (-1)); /* { dg-warning "argument 1 value .-1l*. is negative" } */ + sink (f_long_1 (0)); + sink (f_long_1 (1)); + sink (f_long_1 (max)); +} + +void +test_long_range (long n) +{ + const long min = LONG_MIN; + const long max = LONG_MAX; + + sink (f_long_1 (n)); + + sink (f_long_1 (SR (min, min + 1))); /* { dg-warning "argument 1 range \\\[-\[0-9\]+l*, -\[0-9\]+l*\\\] is negative" } */ + sink (f_long_1 (SR (min, 0))); /* { dg-warning "argument 1 range \\\[-\[0-9\]+l*, 0l*\\\] is negative" } */ + sink (f_long_1 (SR (-1, 0))); /* { dg-warning "argument 1 range \\\[-1l*, 0l*\\\] is negative" } */ + sink (f_long_1 (SR (-1, 1))); + sink (f_long_1 (SR (0, 1))); + sink (f_long_1 (SR (0, max - 1))); + sink (f_long_1 (SR (1, max))); + sink (f_long_1 (SR (max - 1, max))); +} + +void +test_size_cst (void) +{ + const size_t max = __SIZE_MAX__; + + sink (f_size_1 (0)); + sink (f_size_1 (1)); + sink (f_size_1 (max - 1)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + sink (f_size_1 (max)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + + sink (f_size_2 (0, max - 1)); /* { dg-warning "argument 2 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + sink (f_size_2 (max - 1, 0)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + sink (f_size_2 (1, max - 1)); /* { dg-warning "argument 2 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + sink (f_size_2 (max - 1, 1)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + sink (f_size_2 (max - 1, max - 1)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + /* { dg-warning "argument 2 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" "argument 2" { target *-*-* } .-1 } */ + + sink (f_size_2 (0, max)); /* { dg-warning "argument 2 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + sink (f_size_2 (max, 0)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds maximum object size \[0-9\]+" } */ + + sink (f_size_2 (max / 2, 2)); /* { dg-warning "product .\[0-9\]+ \\* \[0-9\]+. of arguments 1 and 2 exceeds maximum object size \[0-9\]+" } */ + sink (f_size_2 (max / 2, 3)); /* { dg-warning "product .\[0-9\]+ \\* \[0-9\]+. of arguments 1 and 2 exceeds .SIZE_MAX." } */ +} + +void +test_size_range (size_t ui, ptrdiff_t si) +{ + const ptrdiff_t smin = PTRDIFF_MIN; + const ptrdiff_t smax = PTRDIFF_MAX; + const size_t umax = SIZE_MAX; + + sink (f_size_1 (ui)); + sink (f_size_1 (si)); + + sink (f_size_1 (UR (0, 1))); + sink (f_size_1 (UR (0, umax - 1))); + sink (f_size_1 (UR (1, umax - 1))); + sink (f_size_1 (UR (1, umax))); + + sink (f_size_1 (UAR (1, 1))); + /* Since the only valid argument in the anti-range below is zero + a warning is expected even though -Walloc-zero is not specified. */ + sink (f_size_1 (UAR (1, umax / 2))); /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " } */ + /* The only valid argument in this range is 1. */ + sink (f_size_1 (UAR (2, umax / 2))); + + sink (f_size_2 (ui, ui)); + sink (f_size_2 (si, si)); + sink (f_size_2 (ui, umax / 2)); + sink (f_size_2 (si, umax / 2)); + sink (f_size_2 (umax / 2, ui)); + sink (f_size_2 (umax / 2, si)); + + sink (f_size_2 (UR (0, 1), umax)); /* { dg-warning "argument 2 value .\[0-9\]+. exceeds maximum object size " } */ + sink (f_size_2 (UR (0, 1), umax / 2)); + sink (f_size_2 (UR (0, umax / 2), umax / 2)); + + sink (f_size_2 (UR (umax / 2 + 1, umax / 2 + 2), ui)); /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " } */ + sink (f_size_2 (ui, UR (umax / 2 + 1, umax / 2 + 2))); /* { dg-warning "argument 2 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " } */ + sink (f_size_2 (UR (umax / 2 + 1, umax), UR (umax / 2 + 1, umax))); /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " } */ +/* { dg-warning "argument 2 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " "argument 2" { target *-*-* } .-1 } */ + + sink (f_size_2 (SR (smin, 1), 1)); + sink (f_size_2 (SR (smin, 1), umax / 2)); + sink (f_size_2 (SR (-1, smax), 1)); + sink (f_size_2 (SR (-1, smax), umax / 2)); + sink (f_size_2 (SR (-1, 1), 1)); + sink (f_size_2 (SR (-1, 1), umax / 2)); + sink (f_size_2 (SR (-9, 9), 1)); + sink (f_size_2 (SR (-9, 9), umax / 2)); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-4.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-4.c new file mode 100644 index 0000000000..6ee064bb9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-4.c @@ -0,0 +1,203 @@ +/* PR c/77531 - __attribute__((alloc_size(1,2))) could also warn on + multiplication overflow + PR c/78284 - warn on malloc with very large arguments + Test exercising the ability to detect and diagnose calls to allocation + functions decorated with attribute alloc_size that either overflow or + exceed the maximum object size specified by -Walloc-size-larger-than. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Walloc-size-larger-than=1234" } */ + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (INT_MAX * 2U + 1) + +#define SIZE_MAX __SIZE_MAX__ + +typedef __SIZE_TYPE__ size_t; + +#define ALLOC_SIZE(...) __attribute__ ((alloc_size (__VA_ARGS__))) + +void* f_uint_1 (unsigned) ALLOC_SIZE (1); +void* f_uint_2 (unsigned, unsigned) ALLOC_SIZE (1, 2); +void* f_int_1 (int) ALLOC_SIZE (1); +void* f_int_2 (int, int) ALLOC_SIZE (1, 2); + +void* f_size_1 (size_t) ALLOC_SIZE (1); +void* f_size_2 (size_t, size_t) ALLOC_SIZE (1, 2); + +static size_t +unsigned_range (size_t min, size_t max) +{ + extern size_t random_unsigned_value (void); + size_t val = random_unsigned_value (); + if (val < min || max < val) val = min; + return val; +} + +static int +signed_range (int min, int max) +{ + extern int random_signed_value (void); + int val = random_signed_value (); + if (val < min || max < val) val = min; + return val; +} + +static size_t +unsigned_anti_range (size_t min, size_t max) +{ + extern size_t random_unsigned_value (void); + size_t val = random_unsigned_value (); + if (min <= val && val <= max) + val = min - 1; + return val; +} + +static int +signed_anti_range (int min, int max) +{ + extern int random_signed_value (void); + int val = random_signed_value (); + if (min <= val && val <= max) + val = min - 1; + return val; +} + +#define UR(min, max) unsigned_range (min, max) +#define SR(min, max) signed_range (min, max) + +#define UAR(min, max) unsigned_anti_range (min, max) +#define SAR(min, max) signed_anti_range (min, max) + + +void sink (void*); + +void +test_uint_cst (void) +{ + const unsigned max = UINT_MAX; + + sink (f_uint_1 (0)); + sink (f_uint_1 (1)); + sink (f_uint_1 (1233)); + sink (f_uint_1 (1234)); + sink (f_uint_1 (1235)); /* { dg-warning "argument 1 value .1235u?. exceeds maximum object size 1234" } */ + sink (f_uint_1 (max - 1)); /* { dg-warning "argument 1 value .\[0-9\]+u?. exceeds maximum object size 1234" } */ + sink (f_uint_1 (max)); /* { dg-warning "argument 1 value .\[0-9\]+u?. exceeds maximum object size 1234" } */ +} + +void +test_uint_range (unsigned n) +{ + const unsigned max = UINT_MAX; + + sink (f_uint_1 (n)); + sink (f_uint_1 (UR (0, 1))); + sink (f_uint_1 (UR (0, 1233))); + sink (f_uint_1 (UR (0, 1234))); + sink (f_uint_1 (UR (0, 1235))); + sink (f_uint_1 (UR (1, 1235))); + sink (f_uint_1 (UR (1234, 1235))); + sink (f_uint_1 (UR (1235, 1236))); /* { dg-warning "argument 1 range \\\[\[0-9\]+u?, \[0-9\]+u?\\\] exceeds maximum object size 1234" } */ + sink (f_uint_1 (UR (1, max - 1))); + sink (f_uint_1 (UR (1, max))); +} + +void +test_int_cst (void) +{ + const int min = INT_MIN; + const int max = INT_MAX; + + sink (f_int_1 (min)); /* { dg-warning "argument 1 value .-\[0-9\]+. is negative" } */ + sink (f_int_1 (-1)); /* { dg-warning "argument 1 value .-1. is negative" } */ + sink (f_int_1 (0)); + sink (f_int_1 (1)); + sink (f_int_1 (1233)); + sink (f_int_1 (1234)); + sink (f_int_1 (max)); /* { dg-warning "argument 1 value .\[0-9\]+u?. exceeds maximum object size 1234" } */ +} + +void +test_int_range (int n) +{ + const int min = INT_MIN; + const int max = INT_MAX; + + sink (f_int_1 (n)); + + sink (f_int_1 (SR (min, 1234))); + sink (f_int_1 (SR (-2, -1))); /* { dg-warning "argument 1 range \\\[-2, -1\\\] is negative" } */ + + sink (f_int_1 (SR (1235, 2345))); /* { dg-warning "argument 1 range \\\[1235, 2345\\\] exceeds maximum object size 1234" } */ + sink (f_int_1 (SR (max - 1, max))); /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size 1234" } */ + + sink (f_int_1 (SAR (-1, 1))); + sink (f_int_1 (SAR (-2, 12))); + sink (f_int_1 (SAR (-3, 123))); + sink (f_int_1 (SAR (-4, 1234))); /* { dg-warning "argument 1 range \\\[1235, \[0-9\]+\\\] exceeds maximum object size 1234" } */ + sink (f_int_1 (SAR (min + 1, 1233))); + +#if __i386__ || __x86_64__ + /* Avoid failures described in bug 79051. */ + sink (f_int_1 (SAR (min + 2, 1235))); /* { dg-warning "argument 1 range \\\[1236, \[0-9\]+\\\] exceeds maximum object size 1234" "" { target { i?86-*-* x86_64-*-* } } } */ +#endif + + sink (f_int_1 (SAR (0, max))); /* { dg-warning "argument 1 range \\\[-\[0-9\]*, -1\\\] is negative" } */ + /* The range below includes zero which would be diagnosed by + -Walloc-size-zero but since all other values are negative it + is diagnosed by -Walloc-size-larger-than. */ + sink (f_int_1 (SAR (1, max))); /* { dg-warning "argument 1 range \\\[-\[0-9\]*, 0\\\] is negative" } */ + sink (f_int_1 (SAR (2, max))); +} + +void +test_size_cst (void) +{ + const size_t max = __SIZE_MAX__; + + sink (f_size_1 (0)); + sink (f_size_1 (1)); + + sink (f_size_2 ( 0, 1234)); + sink (f_size_2 ( 1, 1234)); + sink (f_size_2 ( 2, 1234)); /* { dg-warning "product .2 \\* 1234. of arguments 1 and 2 exceeds maximum object size \[0-9\]+" } */ + sink (f_size_2 (1234, 1234)); /* { dg-warning "product .1234 \\* 1234. of arguments 1 and 2 exceeds (.SIZE_MAX.|maximum object size 1234)" } */ + sink (f_size_2 (1235, 1234)); /* { dg-warning "argument 1 value .1235. exceeds maximum object size 1234" } */ + sink (f_size_2 (1234, 1235)); /* { dg-warning "argument 2 value .1235. exceeds maximum object size 1234" } */ + sink (f_size_2 (1234, max)); /* { dg-warning "argument 2 value .\[0-9\]+. exceeds maximum object size 1234" } */ + sink (f_size_2 (max, 1234)); /* { dg-warning "argument 1 value .\[0-9\]+. exceeds maximum object size 1234" } */ +} + +void +test_size_range (size_t n) +{ + const size_t max = __SIZE_MAX__; + + sink (f_size_1 (n)); + + sink (f_size_1 (UR (0, 1))); + sink (f_size_1 (UR (0, max - 1))); + sink (f_size_1 (UR (1, max - 1))); + sink (f_size_1 (UR (1, max))); + + sink (f_size_1 (UAR (1, 1))); + /* Since the only valid argument in the anti-range below is zero + a warning is expected even though -Walloc-zero is not specified. */ + sink (f_size_1 (UAR (1, 1234))); /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " } */ + /* The only valid argument in this range is 1. */ + sink (f_size_1 (UAR (2, max / 2))); + + sink (f_size_2 (n, n)); + sink (f_size_2 (n, 1234)); + sink (f_size_2 (1234, n)); + + sink (f_size_2 (UR (0, 1), 1234)); + sink (f_size_2 (UR (0, 1), 1235)); /* { dg-warning "argument 2 value .1235. exceeds maximum object size 1234" } */ + + sink (f_size_2 (UR (1235, 1236), n)); /* { dg-warning "argument 1 range \\\[1235, 1236\\\] exceeds maximum object size 1234" } */ + + sink (f_size_2 (UR (1235, 1236), UR (max / 2, max))); /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " } */ +/* { dg-warning "argument 2 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size " "argument 2" { target *-*-* } .-1 } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-5.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-5.c new file mode 100644 index 0000000000..4eea625a96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-5.c @@ -0,0 +1,234 @@ +/* PR c/78284 - warn on malloc with very large arguments + Test exercising the ability to detect and diagnose calls to allocation + functions decorated with attribute alloc_size that attempt to allocate + zero bytes. For standard allocation functions the return value is + implementation-defined and so relying on it may be a source of bugs. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -Wall -Walloc-zero" } */ + +#define SCHAR_MAX __SCHAR_MAX__ +#define SCHAR_MIN (-SCHAR_MAX - 1) +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +#define SHRT_MAX __SHRT_MAX__ +#define SHRT_MIN (-SHRT_MAX - 1) +#define USHRT_MAX (SHRT_MAX * 2U + 1) + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (INT_MAX * 2U + 1) + +#define LONG_MAX __LONG_MAX__ +#define LONG_MIN (-LONG_MAX - 1L) +#define ULONG_MAX (LONG_MAX * 2LU + 1) + +#define LLONG_MAX __LLONG_MAX__ +#define LLONG_MIN (-LLONG_MAX - 1LL) +#define ULLONG_MAX (ULLONG_MAX * 2LLU + 1) + +#define SIZE_MAX __SIZE_MAX__ + +typedef __SIZE_TYPE__ size_t; + + +#define ALLOC_SIZE(...) __attribute__ ((alloc_size (__VA_ARGS__))) + +void* f_uchar_1 (unsigned char) ALLOC_SIZE (1); +void* f_uchar_2 (unsigned char, unsigned char) ALLOC_SIZE (1, 2); +void* f_schar_1 (signed char) ALLOC_SIZE (1); +void* f_schar_2 (signed char, signed char) ALLOC_SIZE (1, 2); + +void* f_ushrt_1 (unsigned short) ALLOC_SIZE (1); +void* f_ushrt_2 (unsigned short, unsigned short) ALLOC_SIZE (1, 2); +void* f_shrt_1 (signed short) ALLOC_SIZE (1); +void* f_shrt_2 (signed short, signed short) ALLOC_SIZE (1, 2); + +void* f_uint_1 (unsigned) ALLOC_SIZE (1); +void* f_uint_2 (unsigned, unsigned) ALLOC_SIZE (1, 2); +void* f_int_1 (int) ALLOC_SIZE (1); +void* f_int_2 (int, int) ALLOC_SIZE (1, 2); + +void* f_ulong_1 (unsigned long) ALLOC_SIZE (1); +void* f_ulong_2 (unsigned long, unsigned long) ALLOC_SIZE (1, 2); +void* f_long_1 (long) ALLOC_SIZE (1); +void* f_long_2 (long, long) ALLOC_SIZE (1, 2); + +void* f_ullong_1 (unsigned long long) ALLOC_SIZE (1); +void* f_ullong_2 (unsigned long long, unsigned long long) ALLOC_SIZE (1, 2); +void* f_llong_1 (long long) ALLOC_SIZE (1); +void* f_llong_2 (long long, long long) ALLOC_SIZE (1, 2); + +void* f_size_1 (size_t) ALLOC_SIZE (1); +void* f_size_2 (size_t, size_t) ALLOC_SIZE (1, 2); + +void* f_size_1_nonnull (size_t) + ALLOC_SIZE (1) __attribute__ ((returns_nonnull)); +void* f_size_2_nonnull (size_t, size_t) + ALLOC_SIZE (1, 2) __attribute__ ((returns_nonnull)); + +void sink (void*); + +void +test_uchar (unsigned char n) +{ + sink (f_uchar_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_uchar_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_uchar_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_uchar_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_uchar_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_uchar_1 (n)); + n = 0; + sink (f_uchar_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_uchar_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +void +test_schar (signed char n) +{ + sink (f_schar_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_schar_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_schar_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_schar_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_schar_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_schar_1 (n)); + n = 0; + sink (f_schar_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_schar_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +void +test_ushrt (unsigned short n) +{ + sink (f_ushrt_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_ushrt_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_ushrt_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_ushrt_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_ushrt_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_ushrt_1 (n)); + n = 0; + sink (f_ushrt_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_ushrt_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +void +test_shrt (short n) +{ + sink (f_shrt_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_shrt_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_shrt_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_shrt_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_shrt_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_shrt_1 (n)); + n = 0; + sink (f_shrt_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_shrt_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +void +test_uint (unsigned n) +{ + sink (f_uint_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_uint_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_uint_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_uint_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_uint_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_uint_1 (n)); + n = 0; + sink (f_uint_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_uint_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +void +test_int (int n) +{ + sink (f_int_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_int_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_int_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_int_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_int_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_int_1 (n)); + n = 0; + sink (f_int_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_int_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +void +test_ulong (unsigned long n) +{ + sink (f_ulong_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_ulong_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_ulong_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_ulong_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_ulong_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_ulong_1 (n)); + n = 0; + sink (f_ulong_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_ulong_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +void +test_long (long n) +{ + sink (f_long_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_long_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_long_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_long_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_long_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_long_1 (n)); + n = 0; + sink (f_long_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_long_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +void +test_size (size_t n) +{ + sink (f_size_1 (0)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_size_2 (0, 1)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_size_2 (1, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_size_2 (n, 0)); /* { dg-warning "argument 2 value is zero" } */ + sink (f_size_2 (0, n)); /* { dg-warning "argument 1 value is zero" } */ + + sink (f_size_1 (n)); + n = 0; + sink (f_size_1 (n)); /* { dg-warning "argument 1 value is zero" } */ + sink (f_size_2 (1, n)); /* { dg-warning "argument 2 value is zero" } */ +} + +/* Verify that calls to allocation function decorated with attribute + returns_nonnull don't cause warnings (unlike functions like malloc + that can return null in this case there's nothing to warn about + because a returns_nonnull function guarantees success). */ + +void +test_size_nonnull (size_t n) +{ + sink (f_size_1_nonnull (0)); + sink (f_size_2_nonnull (0, 1)); + sink (f_size_2_nonnull (1, 0)); + sink (f_size_2_nonnull (n, 0)); + sink (f_size_2_nonnull (0, n)); + + sink (f_size_1_nonnull (n)); + n = 0; + sink (f_size_1_nonnull (n)); + sink (f_size_2_nonnull (1, n)); +} + +/* Verify that call to plain alloca(0) is not diagnosed. */ + +void +test_alloca (size_t n) +{ + extern void* alloca (size_t); + + alloca (0); /* { dg-warning "ignoring return value of '.*' declared with attribute 'warn_unused_result'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-6.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-6.c new file mode 100644 index 0000000000..e28057f900 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-6.c @@ -0,0 +1,74 @@ +/* PR c/78284 - warn on malloc with very large arguments + Test exercising the ability of the built-in allocation functions + to detect and diagnose, without optimization, calls that attemnpt + to allocate objects in excess of the number of bytes specified by + -Walloc-larger-than=maximum. */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O0 -Wall -Walloc-size-larger-than=12345 -Wno-use-after-free" } */ + +#define MAXOBJSZ 12345 + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + + +void test_lit (char *p, char *q) +{ + sink (__builtin_aligned_alloc (1, MAXOBJSZ)); + sink (__builtin_aligned_alloc (1, MAXOBJSZ + 1)); /* { dg-warning "argument 2 value .12346\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_alloca (MAXOBJSZ)); + sink (__builtin_alloca (MAXOBJSZ + 2)); /* { dg-warning "argument 1 value .12347\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_calloc (MAXOBJSZ, 1)); + sink (__builtin_calloc (1, MAXOBJSZ)); + + /* Verify that the signed to unsigned conversion below doesn't cause + a warning. */ + sink (__builtin_calloc (p - q, 1)); + sink (__builtin_calloc (1, q - p)); + sink (__builtin_calloc (p - q, MAXOBJSZ)); + sink (__builtin_calloc (MAXOBJSZ, q - p)); + + sink (__builtin_calloc (MAXOBJSZ / 2, 3)); /* { dg-warning "product .6172\[lu\]* \\* 3\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + sink (__builtin_calloc (4, MAXOBJSZ / 3)); /* { dg-warning "product .4\[lu\]* \\* 4115\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + + sink (__builtin_malloc (MAXOBJSZ)); + sink (__builtin_malloc (MAXOBJSZ + 3)); /* { dg-warning "argument 1 value .12348\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_realloc (p, MAXOBJSZ)); + sink (__builtin_realloc (p, MAXOBJSZ + 4)); /* { dg-warning "argument 2 value .12349\[lu\]*. exceeds maximum object size 12345" } */ +} + + +enum { max = MAXOBJSZ }; + +void test_cst (char *p, char *q) +{ + sink (__builtin_aligned_alloc (1, max)); + sink (__builtin_aligned_alloc (1, max + 1)); /* { dg-warning "argument 2 value .12346\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_alloca (max)); + sink (__builtin_alloca (max + 2)); /* { dg-warning "argument 1 value .12347\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_calloc (max, 1)); + sink (__builtin_calloc (1, max)); + + /* Verify that the signed to unsigned conversion below doesn't cause + a warning. */ + sink (__builtin_calloc (p - q, 1)); + sink (__builtin_calloc (1, q - p)); + sink (__builtin_calloc (p - q, max)); + sink (__builtin_calloc (max, q - p)); + + sink (__builtin_calloc (max / 2, 3)); /* { dg-warning "product .6172\[lu\]* \\* 3\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + sink (__builtin_calloc (4, max / 3)); /* { dg-warning "product .4\[lu\]* \\* 4115\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + + sink (__builtin_malloc (max)); + sink (__builtin_malloc (max + 3)); /* { dg-warning "argument 1 value .12348\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_realloc (p, max)); + sink (__builtin_realloc (p, max + 4)); /* { dg-warning "argument 2 value .12349\[lu\]*. exceeds maximum object size 12345" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-7.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-7.c new file mode 100644 index 0000000000..6c26935211 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-7.c @@ -0,0 +1,106 @@ +/* PR c/78284 - warn on malloc with very large arguments + Test exercising the ability of the built-in allocation functions to + detect and diagnose calls that attemnpt to allocate objects in excess + of the maximum specified by -Walloc-size-larger-than=maximum. */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O1 -Wall -Walloc-size-larger-than=12345 -Wno-use-after-free" } */ + +#define SIZE_MAX __SIZE_MAX__ +#define MAXOBJSZ 12345 + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +#pragma GCC push_options +/* Verify that constant evaluation takes place even at -O0. */ +#pragma GCC optimize ("0") + +void test_cst (void *p) +{ + enum { max = MAXOBJSZ }; + + sink (__builtin_aligned_alloc (1, max)); + sink (__builtin_aligned_alloc (1, max + 1)); /* { dg-warning "argument 2 value .12346\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_alloca (max)); + sink (__builtin_alloca (max + 2)); /* { dg-warning "argument 1 value .12347\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_calloc (1, max)); + sink (__builtin_calloc (max, 1)); + + sink (__builtin_calloc (max / 2, 3)); /* { dg-warning "product .6172\[lu\]* \\* 3\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + sink (__builtin_calloc (4, max / 3)); /* { dg-warning "product .4\[lu\]* \\* 4115\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + + sink (__builtin_malloc (max)); + sink (__builtin_malloc (max + 3)); /* { dg-warning "argument 1 value .12348\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_realloc (p, max)); + sink (__builtin_realloc (p, max + 4)); /* { dg-warning "argument 2 value .12349\[lu\]*. exceeds maximum object size 12345" } */ +} + + +/* Variable evaluation needs -O1. */ +#pragma GCC pop_options + +__attribute__ ((noipa)) void test_var (void *p) +{ + size_t max = MAXOBJSZ; + + sink (__builtin_aligned_alloc (1, max)); + sink (__builtin_aligned_alloc (1, max + 1)); /* { dg-warning "argument 2 value .12346\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_alloca (max)); + sink (__builtin_alloca (max + 2)); /* { dg-warning "argument 1 value .12347\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_calloc (1, max)); + sink (__builtin_calloc (max, 1)); + + sink (__builtin_calloc (max / 2, 3)); /* { dg-warning "product .6172\[lu\]* \\* 3\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + sink (__builtin_calloc (4, max / 3)); /* { dg-warning "product .4\[lu\]* \\* 4115\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + + sink (__builtin_malloc (max)); + sink (__builtin_malloc (max + 3)); /* { dg-warning "argument 1 value .12348\[lu\]*. exceeds maximum object size 12345" } */ + + sink (__builtin_realloc (p, max)); + sink (__builtin_realloc (p, max + 4)); /* { dg-warning "argument 2 value .12349\[lu\]*. exceeds maximum object size 12345" } */ +} + + +/* Value range evaluation (apparently) needs -O2 here. */ +#pragma GCC optimize ("2") + +static size_t maxobjsize (void) +{ + return MAXOBJSZ; +} + +__attribute__ ((noipa)) void test_range (void *p, size_t range) +{ + /* Make sure the variable is at least as large as the maximum object + size but also make sure that it's guaranteed not to be too big to + increment (and wrap around). */ + size_t max = maxobjsize (); + + if (range < max || 2 * max <= range) + range = maxobjsize (); + + sink (__builtin_aligned_alloc (1, range)); + sink (__builtin_aligned_alloc (1, range + 1)); /* { dg-warning "argument 2 range \\\[12346\[lu\]*, \[0-9\]+\[lu\]*\\\] exceeds maximum object size 12345" } */ + + sink (__builtin_alloca (range)); + sink (__builtin_alloca (range + 2)); /* { dg-warning "argument 1 range \\\[12347\[lu\]*, \[0-9\]+\[lu\]*\\\] exceeds maximum object size 12345" } */ + + sink (__builtin_calloc (range, 1)); + sink (__builtin_calloc (1, range)); + + sink (__builtin_calloc (range / 2, 3)); /* { dg-warning "product .6172\[lu\]* \\* 3\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + sink (__builtin_calloc (4, range / 3)); /* { dg-warning "product .4\[lu\]* \\* 4115\[lu\]*. of arguments 1 and 2 exceeds maximum object size 12345" } */ + + sink (__builtin_malloc (range)); + sink (__builtin_malloc (range + 3)); /* { dg-warning "argument 1 range \\\[12348\[lu\]*, 24692\[lu\]*\\\] exceeds maximum object size 12345" } */ + + sink (__builtin_realloc (p, range)); + sink (__builtin_realloc (p, range + 4)); /* { dg-warning "argument 2 range \\\[12349\[lu\]*, 24693\[lu\]*\\\] exceeds maximum object size 12345" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-8.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-8.c new file mode 100644 index 0000000000..7b47b045b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-8.c @@ -0,0 +1,60 @@ +/* PR c/78284 - warn on malloc with very large arguments + Test to exercise the interaction of the -Walloca-larger-than, + -Wvla-larger-than, and -Walloc-size-larger-than options. The former + two more specific options override the more general latter option. */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O -Walloc-size-larger-than=123 -Walloca-larger-than=234 -Wvla-larger-than=345" } */ + +typedef __SIZE_TYPE__ size_t; + +void sink (void*); + +static size_t alloc_size_limit (void) +{ + return 123; +} + +static size_t alloca_limit (void) +{ + return 234; +} + +static size_t vla_limit (void) +{ + return 345; +} + +void test_alloca (void) +{ + void *p; + + /* No warning should be issued for the following call because the more + permissive alloca limit overrides the stricter alloc_size limit. */ + p = __builtin_alloca (alloca_limit ()); + sink (p); + + p = __builtin_alloca (alloca_limit () + 1); /* { dg-warning "argument to .alloca. is too large" } */ + sink (p); +} + +void test_vla (void) +{ + /* Same as above, no warning should be issued here because the more + permissive VLA limit overrides the stricter alloc_size limit. */ + char vla1 [vla_limit ()]; + sink (vla1); + + char vla2 [vla_limit () + 1]; /* { dg-warning "argument to variable-length array is too large" } */ + sink (vla2); +} + +void test_malloc (void) +{ + void *p; + p = __builtin_malloc (alloc_size_limit ()); + sink (p); + + p = __builtin_malloc (alloc_size_limit () + 1); /* { dg-warning "argument 1 value .124\[lu\]*. exceeds maximum object size 123" } */ + sink (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size-9.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-9.c new file mode 100644 index 0000000000..0c50b0ab63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size-9.c @@ -0,0 +1,31 @@ +/* PR c/78284 - warn on malloc with very large arguments + Test verifying that the built-in allocation functions are declared + with attribute malloc. This means that the pointer they return + can be assumed not to alias any other valid pointer. */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void sink (void*); + +extern int x; + +#define TEST(call) \ + do { \ + p = call; \ + x = 123; \ + *(int*)p = 456; \ + (x == 123) ? (void)0 : __builtin_abort (); \ + sink (p); \ + } while (0) + +void test (void *p, unsigned n) +{ + TEST (__builtin_aligned_alloc (8, n)); + TEST (__builtin_alloca (n)); + TEST (__builtin_calloc (4, n)); + TEST (__builtin_malloc (n)); + TEST (__builtin_realloc (p, n + 1)); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-alloc_size.c b/SingleSource/Regression/C/gcc-dg/attr-alloc_size.c new file mode 100644 index 0000000000..6f1d0195d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alloc_size.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +extern void abort (void); + +#include "../gcc-c-torture/execute/builtins/chk.h" + +extern char *mallocminus1(int size) __attribute__((alloc_size(-1))); /* { dg-warning ".alloc_size. attribute argument value .-1. exceeds the number of function parameters 1" } */ +extern char *malloc0(int size) __attribute__((alloc_size(0))); /* { dg-warning ".alloc_size. attribute argument value .0. does not refer to a function parameter" } */ +extern char *malloc1(int size) __attribute__((alloc_size(1))); +extern char *malloc2(int empty, int size) __attribute__((alloc_size(2))); +extern char *calloc1(int size, int elements) __attribute__((alloc_size(1,2))); +extern char *calloc2(int size, int empty, int elements) __attribute__((alloc_size(1,3))); +extern char *balloc1(void *size) __attribute__((alloc_size(1))); /* { dg-warning ".alloc_size. attribute argument value .1. refers to parameter type .void *." } */ + +void +test (void) +{ + char *p; + + p = malloc0 (6); + strcpy (p, "Hello"); + p = malloc1 (6); + strcpy (p, "Hello"); + strcpy (p, "Hello World"); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "strcpy" } */ + p = malloc2 (__INT_MAX__ >= 1700000 ? 424242 : __INT_MAX__ / 4, 6); + strcpy (p, "World"); + strcpy (p, "Hello World"); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "strcpy" } */ + p = calloc1 (2, 5); + strcpy (p, "World"); + strcpy (p, "Hello World"); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "strcpy" } */ + p = calloc2 (2, __INT_MAX__ >= 1700000 ? 424242 : __INT_MAX__ / 4, 5); + strcpy (p, "World"); + strcpy (p, "Hello World"); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "strcpy" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/attr-alwaysinline.c b/SingleSource/Regression/C/gcc-dg/attr-alwaysinline.c new file mode 100644 index 0000000000..8ff92b23a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-alwaysinline.c @@ -0,0 +1,19 @@ +/* Test always_inline attribute, which forces inlining of functions + even at no optimization. */ +/* Origin: Aldy Hernandez . */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +static inline int sabrina (void) __attribute__((always_inline)); + +static inline int sabrina (void) +{ + return 13; +} + +int bar (void) +{ + return sabrina () + 68; +} + +/* { dg-final { scan-assembler-not "sabrina" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume-1.c b/SingleSource/Regression/C/gcc-dg/attr-assume-1.c new file mode 100644 index 0000000000..16e919ef7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume-1.c @@ -0,0 +1,69 @@ +/* Portable assumptions */ +/* { dg-do run } */ +/* { dg-options "-std=c2x" } */ + +int +f1 (int i) +{ + [[gnu::assume (i == 42)]]; + return i; +} + +int +f2 (int i) +{ + __attribute__ ((assume (++i == 44))); + return i; +} + +int a; +int *volatile c; + +int +f3 () +{ + ++a; + return 1; +} + +int +f4 (double x) +{ + [[gnu::assume (__builtin_isfinite (x) && x >= 0.0)]]; + return __builtin_isfinite (__builtin_sqrt (x)); +} + +double +f5 (double x) +{ + __attribute__((assume (__builtin_isfinite (__builtin_sqrt (x))))); + return __builtin_sqrt (x); +} + +int +f6 (int x) +{ + [[gnu::assume (x == 93 ? 1 : 0)]]; + return x; +} + +int +main () +{ + int b = 42; + double d = 42.0, e = 43.0; + c = &b; + [[__gnu__::__assume__ (f3 ())]]; + if (a) + __builtin_abort (); + [[gnu::assume (++b == 43)]]; + if (b != 42 || *c != 42) + __builtin_abort (); + __attribute__((assume (d < e))); + int i = 90, j = 91, k = 92; + [[gnu::__assume__ (i == 90), gnu::assume (j <= 91)]] [[gnu::assume (k >= 92)]] + ; + __attribute__((__assume__ (i == 90), assume (j <= 91))) __attribute__((assume (k >= 92))); + if (f6 (93) != 93) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume-2.c b/SingleSource/Regression/C/gcc-dg/attr-assume-2.c new file mode 100644 index 0000000000..aa782e737e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume-2.c @@ -0,0 +1,66 @@ +/* Portable assumptions */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +[[gnu::__assume__ (1)]] void f1 (void); /* { dg-warning "'assume' attribute not followed by ';'" } */ + /* { dg-warning "'assume' attribute ignored" "" { target *-*-* } .-1 } */ +typedef int intx [[gnu::assume (1)]]; /* { dg-warning "'assume' attribute ignored" } */ +[[__gnu__::assume (1)]]; /* { dg-warning "'assume' attribute at top level" } */ +__attribute__((assume (1))) void f1b ();/* { dg-warning "'assume' attribute not followed by ';'" } */ + /* { dg-warning "'assume' attribute ignored" "" { target *-*-* } .-1 } */ +typedef int inty __attribute__((assume (1))); /* { dg-warning "'assume' attribute ignored" } */ + +void +foo () +{ + int i; + [[gnu::assume]]; /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */ + /* { dg-message "expected 1, found 0" "" { target *-*-* } .-1 } */ + [[gnu::__assume__ ()]]; /* { dg-error "parentheses must be omitted if attribute argument list is empty" } */ + /* { dg-error "wrong number of arguments specified for 'assume' attribute" "" { target *-*-* } .-1 } */ + /* { dg-message "expected 1, found 0" "" { target *-*-* } .-2 } */ + [[gnu::assume (1, 1)]]; /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */ + /* { dg-message "expected 1, found 2" "" { target *-*-* } .-1 } */ + [[gnu::assume (1)]] i = 1; /* { dg-warning "'assume' attribute ignored" } */ + [[gnu::assume (i = 1)]]; /* { dg-error "expected" } */ + /* { dg-warning "'assume' attribute ignored" "" { target *-*-* } .-1 } */ + __attribute__((assume)); /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */ + /* { dg-message "expected 1, found 0" "" { target *-*-* } .-1 } */ + __attribute__((assume ())); /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */ + /* { dg-message "expected 1, found 0" "" { target *-*-* } .-1 } */ + __attribute__((assume (1, 1))); /* { dg-error "wrong number of arguments specified for 'assume' attribute" } */ + /* { dg-message "expected 1, found 2" "" { target *-*-* } .-1 } */ + __attribute__((assume (i = 1))); /* { dg-error "expected" } */ +} + +int +f2 (int x) +{ + __asm ("" : "+r" (x)); + return x; +} + +int +f3 (int x) +{ + [[gnu::assume (f2 (42) == 42)]]; + return x; +} + +int +f3a (int x) +{ + __attribute__((assume (f2 (42) == 42))); + return x; +} + +struct S {}; + +int +f4 () +{ + struct S s; + [[gnu::assume (s)]]; /* { dg-error "used struct type value where scalar is required" } */ + __attribute__((assume (s))); /* { dg-error "used struct type value where scalar is required" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume-3.c b/SingleSource/Regression/C/gcc-dg/attr-assume-3.c new file mode 100644 index 0000000000..c611a8f8e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume-3.c @@ -0,0 +1,35 @@ +/* Portable assumptions */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +void +foo (int x) +{ + if (x == 1) + goto l1; /* { dg-error "jump into statement expression" } */ + else if (x == 2) + goto l2; /* { dg-error "jump into statement expression" } */ + else if (x == 3) + goto l3; /* { dg-error "jump into statement expression" } */ + [[gnu::assume (({ l0:; if (x == 0) goto l0; 1; }))]]; + [[gnu::assume (({ if (x == 0) __builtin_abort (); 1; }))]]; + [[gnu::assume (({ l1:; 1; }))]]; /* { dg-message "label 'l1' defined here" } */ + [[gnu::assume (({ l2:; 1; }))]]; /* { dg-message "label 'l2' defined here" } */ + __attribute__((assume (({ l3:; 1; })))); /* { dg-message "label 'l3' defined here" } */ + [[gnu::assume (({ l4:; 1; }))]]; /* { dg-message "label 'l4' defined here" } */ + [[gnu::assume (({ l5:; 1; }))]]; /* { dg-message "label 'l5' defined here" } */ + __attribute__((assume (({ l6:; 1; })))); /* { dg-message "label 'l6' defined here" } */ + switch (x) /* { dg-message "switch starts here" } */ + { + case 7: + [[gnu::assume (({ case 8:; 1; }))]]; /* { dg-error "switch jumps into statement expression" } */ + __attribute__((assume (({ default:; 1; })))); /* { dg-error "switch jumps into statement expression" } */ + break; + } + if (x == 4) + goto l4; /* { dg-error "jump into statement expression" } */ + else if (x == 5) + goto l5; /* { dg-error "jump into statement expression" } */ + else if (x == 6) + goto l6; /* { dg-error "jump into statement expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume-4.c b/SingleSource/Regression/C/gcc-dg/attr-assume-4.c new file mode 100644 index 0000000000..e8a2b8d316 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume-4.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/107369 */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -O1" } */ + +void +foo (int x) +{ + if (x == 1) + goto l1; /* { dg-error "jump into statement expression" } */ + + [[gnu::assume (({ l1:; 1; }))]]; /* { dg-message "label 'l1' defined here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume-5.c b/SingleSource/Regression/C/gcc-dg/attr-assume-5.c new file mode 100644 index 0000000000..8aa0f361da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume-5.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/107368 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +double +f4 (double x) +{ + [[gnu::assume (x && x > 0.0)]]; + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-1.c b/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-1.c new file mode 100644 index 0000000000..9a7d5a1ffe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-1.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +double *my_alloc1 (int len) __attribute__((__assume_aligned__ (16))); +double *my_alloc2 (int len) __attribute__((__assume_aligned__ (32, 16))); + +void +test1 (int len) +{ + int i; + double *__restrict o1 = my_alloc1 (len); + double *__restrict o2 = my_alloc1 (len); + double *__restrict o3 = my_alloc1 (len); + double *__restrict i1 = my_alloc1 (len); + double *__restrict i2 = my_alloc1 (len); + for (i = 0; i < len; ++i) + { + o1[i] = i1[i] * i2[i]; + o2[i] = i1[i] + i2[i]; + o3[i] = i1[i] - i2[i]; + } +} + +void +test2 (int len) +{ + int i; + double *__restrict o1 = my_alloc2 (len); + double *__restrict o2 = my_alloc2 (len); + double *__restrict o3 = my_alloc2 (len); + double *__restrict i1 = my_alloc2 (len); + double *__restrict i2 = my_alloc2 (len); + for (i = 0; i < len; ++i) + { + o1[i] = i1[i] * i2[i]; + o2[i] = i1[i] + i2[i]; + o3[i] = i1[i] - i2[i]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-2.c b/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-2.c new file mode 100644 index 0000000000..9ab558945b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +int i; +void *f1 (void) __attribute__((assume_aligned (32))); +void *f2 (void) __attribute__((assume_aligned (16, 4))); +void *f3 (void) __attribute__((assume_aligned)); /* { dg-error "wrong number of arguments specified" } */ +void *f4 (void) __attribute__((assume_aligned (32, 16, 8))); /* { dg-error "wrong number of arguments specified" } */ +void *f5 (void) __attribute__((assume_aligned (i))); /* { dg-warning "integer constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-3.c b/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-3.c new file mode 100644 index 0000000000..0e4c70b610 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-3.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +char *my_alloc1 (int len) __attribute__((__assume_aligned__ (32))); +char *my_alloc2 (int len) __attribute__((assume_aligned (32, 4))); + +int +test1 (int len) +{ + int i; + char *p = my_alloc1 (len); + return ((__INTPTR_TYPE__) p) & 31; +} + +int +test2 (int len) +{ + int i; + char *p = my_alloc2 (len); + return (((__INTPTR_TYPE__) p) & 31) != 4; +} + +/* { dg-final { scan-tree-dump-times "return 0" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-4.c b/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-4.c new file mode 100644 index 0000000000..f6eb6dc4e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-assume_aligned-4.c @@ -0,0 +1,36 @@ +/* PR middle-end/87533 - bogus assume_aligned attribute silently accepted + { dg-do compile } + { dg-options "-Wall" } */ + +#define A(...) __attribute__ ((assume_aligned (__VA_ARGS__))) + +A (1) void fv_1 (void); /* { dg-warning ".assume_aligned. attribute ignored on a function returning .void." } */ + +A (1) int fi_1 (void); /* { dg-warning ".assume_aligned. attribute ignored on a function returning .int." } */ + +A (-1) void* fpv_m1 (void); /* { dg-warning ".assume_aligned. attribute argument -1 is not positive" } */ + +A (0) void* fpv_0 (void); /* { dg-warning ".assume_aligned. attribute argument 0 is not a power of 2" } */ + +/* Alignment of 1 is fine, it just doesn't offer any benefits. */ +A (1) void* fpv_1 (void); + +A (3) void* fpv_3 (void); /* { dg-warning ".assume_aligned. attribute argument 3 is not a power of 2" } */ + +A (16383) void* fpv_16km1 (void); /* { dg-warning ".assume_aligned. attribute argument 16383 is not a power of 2" } */ +A (16384) void* fpv_16k (void); +A (16385) void* fpv_16kp1 (void); /* { dg-warning ".assume_aligned. attribute argument 16385 is not a power of 2" } */ + +A (32767) void* fpv_32km1 (void); /* { dg-warning ".assume_aligned. attribute argument 32767 is not a power of 2" } */ + +A (4, -1) void* fpv_4_m1 (void); /* { dg-warning ".assume_aligned. attribute argument -1 is not positive" } */ + +A (4, 0) void* fpv_4_0 (void); +A (4, 1) void* fpv_4_1 (void); +A (4, 2) void* fpv_4_2 (void); +A (4, 3) void* fpv_4_3 (void); + +A (4, 4) void* fpv_4_3 (void); /* { dg-warning ".assume_aligned. attribute argument 4 is not in the range \\\[0, 3]" } */ + +A (4) void* gpv_4_3 (void); +A (2) void* gpv_4_3 (void); diff --git a/SingleSource/Regression/C/gcc-dg/attr-copy-2.c b/SingleSource/Regression/C/gcc-dg/attr-copy-2.c new file mode 100644 index 0000000000..ffc7208f4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-copy-2.c @@ -0,0 +1,210 @@ +/* PR middle-end/81824 - Warn for missing attributes with function aliases + Exercise attribute copy for functions. + { dg-do compile } + { dg-require-alias "" } + { dg-options "-O2 -Wall -Wno-array-bounds" } */ + +#define Assert(expr) typedef char AssertExpr[2 * !!(expr) - 1] + +#define ATTR(list) __attribute__ (list) + +/* Verify that referencing a symbol with no attributes is accepted + with no diagnostics. */ + +void ref0 (void); + +ATTR ((copy (ref0))) void +f0 (void); + +/* Verify that referencing a symbol using the address-of and dereferencing + operators is also accepted with no diagnostics. */ + +ATTR ((copy (&ref0))) void f1 (void); +ATTR ((copy (*ref0))) void f2 (void); + +/* Verify that referencing a symbol of a different kind than that + of the one the attribute is applied to is diagnosed. */ + +int v0; /* { dg-message "symbol .v0. referenced by .f3. declared here" } */ + +ATTR ((copy (v0))) void +f3 (void); /* { dg-warning ".copy. attribute ignored on a declaration of a different kind than referenced symbol" } */ + +void f4 (void); /* { dg-message "symbol .f4. referenced by .v1. declared here" } */ + +ATTR ((copy (f4))) int +v1; /* { dg-warning ".copy. attribute ignored on a declaration of a different kind than referenced symbol" } */ + + +ATTR ((copy (v0 + 1))) +void f5 (void); /* { dg-warning ".copy. attribute ignored on a declaration of a different kind than referenced symbol" } */ + +void f6 (void); + +ATTR ((copy (f6 - 1))) +int v1; /* { dg-warning ".copy. attribute ignored on a declaration of a different kind than referenced symbol" } */ + + + +/* Verify that circular references of the copy function attribute + are handled gracefully (i.e., not by getting into an infinite + recursion) by issuing a diagnostic. */ + +void xref1 (void); /* { dg-message "previous declaration here" } */ +ATTR ((copy (xref1))) void +xref1 (void); /* { dg-warning ".copy. attribute ignored on a redeclaration of the referenced symbol" } */ +ATTR ((copy (xref1))) void +xref1 (void); /* { dg-warning ".copy. attribute ignored on a redeclaration of the referenced symbol" } */ +ATTR ((copy (xref1), copy (xref1))) void +xref1 (void); /* { dg-warning ".copy. attribute ignored on a redeclaration of the referenced symbol" } */ + + +/* Use attribute noreturn to verify that circular references propagate + atttibutes as expected, and unlike in the self-referential instances + above, without a warning. Also use the address-of operator to make + sure it doesn't change anything. */ + +ATTR ((noreturn)) void xref2 (void); +ATTR ((copy (xref2))) void xref3 (void); +ATTR ((copy (&xref3))) void xref4 (void); +ATTR ((copy (xref4))) void xref5 (void); +ATTR ((copy (&xref5))) void xref6 (void); +ATTR ((copy (xref6))) void xref7 (void); +ATTR ((copy (&xref7))) void xref8 (void); +ATTR ((copy (xref8))) void xref9 (void); +ATTR ((copy (&xref9))) void xref2 (void); + +int call_ref2 (void) { xref2 (); } +int call_ref3 (void) { xref3 (); } +int call_ref4 (void) { xref4 (); } +int call_ref5 (void) { xref5 (); } +int call_ref6 (void) { xref6 (); } +int call_ref7 (void) { xref7 (); } +int call_ref8 (void) { xref8 (); } +int call_ref9 (void) { xref9 (); } + + +/* Verify that copying attributes from multiple symbols into one works + as expected. */ + +ATTR ((malloc)) void* +xref10 (void); + +ATTR ((alloc_size (1))) +void* xref11 (int); + +ATTR ((copy (xref10), copy (xref11))) +void* xref12 (int); + +void* call_xref12 (void) +{ + void *p = xref12 (3); + __builtin___strcpy_chk (p, "123", __builtin_object_size (p, 0)); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + return p; +} + + +/* Verify that attribute exclusions apply. */ + +ATTR ((const)) int +fconst (void); + +ATTR ((pure)) int +fpure (void); /* { dg-message "previous declaration here" } */ + +ATTR ((copy (fconst), copy (fpure))) int +fconst_pure (void); /* { dg-warning "ignoring attribute .pure. because it conflicts with attribute .const." } */ + + +/* Also verify that the note in the exclusion warning points to + the declaration from which the conflicting attribute is copied. + The wording in the note could be improved but it's the same as + in ordinary exclusions so making it different between the two + would take some API changes. */ + +ATTR ((const)) int +gconst (void); /* { dg-message "previous declaration here" } */ + +ATTR ((pure, copy (gconst))) int +gpure_const (void); /* { dg-warning "ignoring attribute .const. because it conflicts with attribute .pure." } */ + + +/* Verify that attribute deprecated isn't copied (but referencing + the deprecated declaration still triggers a warning). */ + +ATTR ((deprecated)) void +fdeprecated (void); /* { dg-message "declared here" } */ + +/* Unlike in most other instance the warning below is on the line + with the copy attribute that references the deprecated function. */ +ATTR ((copy (fdeprecated))) /* { dg-warning "\\\[-Wdeprecated-declarations]" } */ +int fcurrent (void); + +ATTR ((copy (fcurrent))) int +fcurrent2 (void); + +int call_fcurrent (void) { return fcurrent () + fcurrent2 (); } + + +/* Verify that attributes are copied on a declaration using __typeof__ + and that -Wmissing-attributes is not issued. */ + +ATTR ((cold)) int +target_cold (void) +{ return 0; } + +__typeof__ (target_cold) ATTR ((copy (target_cold), alias ("target_cold"))) +alias_cold; /* { dg-bogus "\\\[-Wmissing-attributes]." } */ + + +/* Verify that attribute alias is not copied. This also indirectly + verifies that attribute copy itself isn't copied. */ + +ATTR ((noreturn)) void fnoret (void) { __builtin_abort (); } +ATTR ((alias ("fnoret"), copy (fnoret))) void fnoret_alias (void); +ATTR ((copy (fnoret_alias))) void fnoret2 (void) { __builtin_exit (1); } + +/* Expect no warning below. */ +int call_noret (void) { fnoret2 (); } + + +/* Verify that attribute nonnull (which is part of a function type, + even when it's specified on a function declaration) is copied to + the alias from its target. Expect no warning about the alias + specifying less restrictive attributes than its target, but do + verify that passing a null to the alias triggers -Wnonnull. */ + +ATTR ((nonnull)) +void* ftarget_nonnull (void *p) { return p; } + +ATTR ((alias ("ftarget_nonnull"), copy (ftarget_nonnull))) +void* falias_nonnull (void*); + +void call_falias_nonnull (void) +{ + falias_nonnull (0); /* { dg-warning "-Wnonnull" } */ +} + +/* Same as above but for malloc. Also verify that the attribute + on the alias is used by -Wstringop-overflow. */ + +ATTR ((malloc)) +void* ftarget_malloc (void) { return __builtin_malloc (1); } + +ATTR ((alias ("ftarget_malloc"), copy (ftarget_malloc))) +void* falias_malloc (void); + +void* call_falias_malloc (void) +{ + char *p = falias_malloc (); + __builtin___strcpy_chk (p, "123", __builtin_object_size (p, 0)); /* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" } */ + return p; +} + +/* Same as above but for nothrow. */ + +ATTR ((nothrow)) +void ftarget_nothrow (void) { } + +ATTR ((alias ("ftarget_nothrow"), copy (ftarget_nothrow))) +void falias_nothrow (void); diff --git a/SingleSource/Regression/C/gcc-dg/attr-copy-3.c b/SingleSource/Regression/C/gcc-dg/attr-copy-3.c new file mode 100644 index 0000000000..88e5e5ed21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-copy-3.c @@ -0,0 +1,75 @@ +/* PR middle-end/81824 - Warn for missing attributes with function aliases + Exercise attribute copy for variables. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define ATTR(list) __attribute__ (list) + +/* Verify that referencing a symbol with no attributes is accepted + with no diagnostics. */ + +int ref0; + +ATTR ((copy (ref0))) long +var0; + +/* Verify that referencing a symbol using the address-of and dereferencing + operators is also accepted with no diagnostics. */ + +ATTR ((copy (&ref0))) void* ptr0; +ATTR ((copy (*&ref0))) int arr[1]; + +/* Verify that referencing a symbol of a different kind than that + of the one the attribute is applied to is diagnosed. */ + +int ref1; /* { dg-message "previous declaration here" } */ + +ATTR ((copy (ref1))) int +ref1; /* { dg-warning ".copy. attribute ignored on a redeclaration of the referenced symbol " } */ + + +/* Verify that circular references of the copy variable attribute + are handled gracefully (i.e., not by getting into an infinite + recursion) by issuing a diagnostic. */ + +char xref1; +ATTR ((copy (xref1))) char +xref1; /* { dg-warning ".copy. attribute ignored on a redeclaration of the referenced symbol" } */ +ATTR ((copy (xref1))) char +xref1; /* { dg-warning ".copy. attribute ignored on a redeclaration of the referenced symbol" } */ +ATTR ((copy (xref1), copy (xref1))) char +xref1; /* { dg-warning ".copy. attribute ignored on a redeclaration of the referenced symbol" } */ + + +/* Use attribute unused to verify that circular references propagate + atttibutes as expected (expect no warnings the circular reference + or for any of the unused symbols). Also use the address-of operator + to make sure it doesn't change anything. */ + +static ATTR ((unused)) int xref2; +static ATTR ((copy (xref2))) int xref3; +static ATTR ((copy (&xref3))) int xref4; +static ATTR ((copy (xref4))) int xref5; +static ATTR ((copy (&xref5))) int xref6; +static ATTR ((copy (xref6))) int xref7; +static ATTR ((copy (&xref7))) int xref8; +static ATTR ((copy (xref8))) int xref9; +static ATTR ((copy (&xref9))) int xref2; + +/* Verify that attribute exclusions apply. */ + +ATTR ((common)) int common_var; +ATTR ((nocommon)) double nocommon_var; + +ATTR ((copy (common_var), copy (nocommon_var))) long +common_copy; /* { dg-warning "ignoring attribute .nocommon. because it conflicts with attribute .common." } */ + + +/* Verify that attribute deprecated isn't copied. */ + +ATTR ((deprecated)) char deprecated_var; + +ATTR ((copy (deprecated_var))) int current_var; /* { dg-warning "\\\[-Wdeprecated-declarations]" } */ +ATTR ((copy (current_var))) int current_var_2; + +int return_current_vars (void) { return current_var + current_var_2; } diff --git a/SingleSource/Regression/C/gcc-dg/attr-copy-4.c b/SingleSource/Regression/C/gcc-dg/attr-copy-4.c new file mode 100644 index 0000000000..01fae3f78d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-copy-4.c @@ -0,0 +1,63 @@ +/* PR middle-end/81824 - Warn for missing attributes with function aliases + Exercise attribute copy for types. + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#define Assert(expr) typedef char AssertExpr[2 * !!(expr) - 1] + +#define ATTR(list) __attribute__ (list) + +/* Use attribute packed to verify that type attributes are copied + from one type to another. */ + +struct ATTR ((packed)) PackedA { int i; char c; }; + +Assert (__alignof (struct PackedA) == 1); + +struct ATTR ((copy ((struct PackedA*)0))) PackedB { long i; char c; }; + +Assert (__alignof (struct PackedA) == __alignof (struct PackedB)); + +struct PackedMember +{ + char c; + ATTR ((copy ((struct PackedB*)0))) double packed_mem; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ +}; + +Assert (__alignof (struct PackedMember) == 1); + + +extern const struct PackedA packed; + +struct Unpacked { int i; char c; }; +Assert (__alignof (struct Unpacked) > 1); +/* { dg-error "size of array .* is negative" "" { target default_packed } .-1 } */ + +/* Verify that copying the packed attribute to the declaration + of an object is ignored with a warning. (There should be + a way to copy just the subset of attributes from a type that + aren't ignored and won't cause a warning, maybe via attribute + copy_except or something like that.) */ +extern ATTR ((copy ((struct PackedA*)0))) const struct Unpacked + unpacked; /* { dg-warning ".packed. attribute ignored" } */ + +Assert (__alignof (packed) == 1); +Assert (__alignof (unpacked) == __alignof (struct Unpacked)); + + + +/* Verify that attribute deprecated isn't copied (but referencing + the deprecated type in the copy attribute still triggers a warning). */ + +struct ATTR ((aligned (8), deprecated)) +AlignedDeprecated { char c; }; + +struct ATTR ((copy ((struct AlignedDeprecated *)0))) /* { dg-warning "\\\[-Wdeprecated-declarations]" } */ +AlignedCopy { short s; }; + +Assert (__alignof (struct AlignedCopy) == 8); + +struct AlignedCopy aligned_copy; + +Assert (__alignof (aligned_copy) == 8); diff --git a/SingleSource/Regression/C/gcc-dg/attr-copy-5.c b/SingleSource/Regression/C/gcc-dg/attr-copy-5.c new file mode 100644 index 0000000000..24cd6e7aa7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-copy-5.c @@ -0,0 +1,58 @@ +/* PR middle-end/81824 - Warn for missing attributes with function aliases + Verify that attributes always_inline, gnu_inline, and noinline aren't + copied. Also verify that copying attribute tls_model to a non-thread + variable triggers a warning. + { dg-do compile } + { dg-require-alias "" } + { dg-options "-Wall" } + { dg-require-effective-target tls } */ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) + +ATTR (always_inline, gnu_inline, noreturn) inline int +finline_noret (void) +{ + __builtin_abort (); + /* Expect no -Wreturn-type. */ +} + +int call_finline_noret (void) +{ + finline_noret (); + /* Expect no -Wreturn-type. */ +} + + +ATTR (copy (finline_noret)) int +fnoret (void); + +int call_fnoret (void) +{ + fnoret (); + /* Expect no -Wreturn-type. */ +} + + +/* Verify that attribute always_inline on an alias target doesn't + get copied and interfere with attribute noinline on the alias + (trigger a warning due to a conflict). */ + +ATTR (always_inline) static inline int +finline (void) { return 0; } + +ATTR (alias ("finline"), noinline) int +fnoinline (void); + +ATTR (copy (finline)) int +fnoinline (void); + + +ATTR (tls_model ("global-dynamic")) __thread int + tls_target; + +ATTR (alias ("tls_target"), copy (tls_target)) extern __thread int + thread_alias; + + +ATTR (alias ("tls_target"), copy (tls_target)) extern int + alias; /* { dg-warning ".tls_model. attribute ignored because .alias. does not have thread storage duration" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-copy-6.c b/SingleSource/Regression/C/gcc-dg/attr-copy-6.c new file mode 100644 index 0000000000..30a1317bf9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-copy-6.c @@ -0,0 +1,100 @@ +/* PR middle-end/88546 - Copy attribute unusable for weakrefs + { dg-do compile } + { dg-skip-if "Attributes not supported" { { hppa*-*-hpux* } && { ! lp64 } } } + { dg-options "-O2 -Wall" } + { dg-require-visibility "hidden" } + { dg-require-alias "" } + { dg-require-weak "" } */ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) +#define ASRT(expr) _Static_assert (expr, #expr) + +#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) +#define ASMNAME2(prefix, cname) STRING (prefix) cname +#define STRING(x) #x + +/* Variable that is local to this translation unit but that can + be modified from other units by calling reset_unit_local(). */ +static int unit_local; + +void reset_unit_local (void) +{ + unit_local = 0; +} + +/* Attribute leaf implies that fleaf() doesn't modify unit_local(). */ +ATTR (leaf, returns_nonnull) +void* fleaf_retnz (void); + +/* Verify both attributes have been applied. */ +ASRT (__builtin_has_attribute (fleaf_retnz, leaf)); +ASRT (__builtin_has_attribute (fleaf_retnz, returns_nonnull)); + +/* Verify that attribute leaf has the expected effect. */ +void call_fleaf_retnz (void) +{ + int i = unit_local; + void *p = fleaf_retnz (); + + /* Expect both tests to be folded to false and the calls eliminated. */ + extern void call_fleaf_retnz_test_leaf_eliminated (void); + if (i != unit_local) + call_fleaf_retnz_test_leaf_eliminated (); + + extern void call_fleaf_retnz_test_nonnull_eliminated (void); + if (p == 0) + call_fleaf_retnz_test_nonnull_eliminated (); +} + + +/* Verify that attribute copy copies the returns_nonnull attribute + but doesn't try to copy attribute leaf which only applies to extern + function. */ +static ATTR (copy (fleaf_retnz), weakref ("fleaf_retnz")) +void* fweakref_fleaf_retnz_copy (void); + +ASRT (!__builtin_has_attribute (fweakref_fleaf_retnz_copy, leaf)); +ASRT (__builtin_has_attribute (fweakref_fleaf_retnz_copy, returns_nonnull)); + +void call_fweakref_fleaf_retnz_copy (void) +{ + int i = unit_local; + void *p = fweakref_fleaf_retnz_copy (); + + /* Since leaf is not copied, expect the following test not to be + folded and the call to be emitted. */ + extern void call_fweakref_test_leaf_emitted (void); + if (i != unit_local) + call_fweakref_test_leaf_emitted (); + + /* Expect the following test to be folded to false and the call + eliminated. */ + extern void call_fweakref_fleaf_nonnull_eliminated (void); + if (p == 0) + call_fweakref_fleaf_nonnull_eliminated (); +} + +/* This is reduced from libgfortran/runtime/error.c. Verify it + doesn't trigger warnings and that the noreturn bit is copied + to the alias by verifying that calling the alias in a non-void + function with no return statement isn't diagnosed. */ + +extern _Noreturn void fnoreturn (void); + +extern __typeof (fnoreturn) + ATTR (visibility ("hidden")) + fnoreturn __asm__ (ASMNAME ("fnoreturn_name")); + +void fnoreturn (void) +{ + __builtin_abort (); +} + +extern __typeof (fnoreturn) + ATTR (alias ("fnoreturn_name"), copy (fnoreturn)) + fnoreturn_alias; + +int call_fnoreturn_alias (void) +{ + fnoreturn_alias (); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-copy-7.c b/SingleSource/Regression/C/gcc-dg/attr-copy-7.c new file mode 100644 index 0000000000..a9c49bd704 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-copy-7.c @@ -0,0 +1,76 @@ +/* PR middle-end/88546 - Copy attribute unusable for weakrefs + Verify that attribute noreturn (represented as volatile on function + decls) is interpreted correctly and doesn't affect variables. + { dg-do compile } + { dg-options "-O1 -Wall -fdump-tree-optimized" }*/ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) +#define ASRT(expr) _Static_assert (expr, #expr) + +ATTR (noreturn) void fnoreturn (void); +ATTR (copy (fnoreturn)) void fnoreturn_copy (void); +ASRT (__builtin_has_attribute (fnoreturn_copy, noreturn)); + +int call_fnoreturn_copy (void) +{ + fnoreturn_copy (); + fnoreturn_copy (); // should be eliminated +} + +// { dg-final { scan-tree-dump-times "fnoreturn_copy \\(\\);" 1 "optimized" } } + + +_Noreturn void f_Noreturn (void); +ATTR (copy (f_Noreturn)) void f_Noreturn_copy (void); +ASRT (__builtin_has_attribute (f_Noreturn_copy, noreturn)); + +int call_f_Noreturn_copy (void) +{ + f_Noreturn_copy (); + f_Noreturn_copy (); // should be eliminated +} + +// { dg-final { scan-tree-dump-times "f_Noreturn_copy \\(\\);" 1 "optimized" } } + + +// Verify the combination of both is accepted and works too, +// just for fun. +ATTR (noreturn) _Noreturn void fnoreturn_Noreturn (void); +ATTR (copy (fnoreturn_Noreturn)) void fnoreturn_Noreturn_copy (void); +ASRT (__builtin_has_attribute (fnoreturn_Noreturn_copy, noreturn)); + +int call_fnoreturn_Noreturn_copy (void) +{ + fnoreturn_Noreturn_copy (); + fnoreturn_Noreturn_copy (); // should be eliminated +} + +// { dg-final { scan-tree-dump-times "fnoreturn_Noreturn_copy \\(\\);" 1 "optimized" } } + + +typedef void func_t (void); + +ATTR (noreturn) func_t func_noreturn; +ATTR (copy (func_noreturn)) func_t func_noreturn_copy; +ASRT (__builtin_has_attribute (func_noreturn_copy, noreturn)); + +int call_func_noreturn_copy (void) +{ + func_noreturn_copy (); + func_noreturn_copy (); // should be eliminated +} + +// { dg-final { scan-tree-dump-times "func_noreturn_copy \\(\\);" 1 "optimized" } } + + +// Finally, verify that the volatile bit isn't copied for variables. +extern volatile int vi; + +int read_nonvolatile (void) +{ + ATTR (copy (vi)) int i = 0; + + return i + i; // should be folded to return 0; +} + +// { dg-final { scan-tree-dump-times "return 0;" 1 "optimized" } } diff --git a/SingleSource/Regression/C/gcc-dg/attr-copy-8.c b/SingleSource/Regression/C/gcc-dg/attr-copy-8.c new file mode 100644 index 0000000000..7195f6b19f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-copy-8.c @@ -0,0 +1,123 @@ +/* PR c/89685 - ICE on attribute copy with a compound expression + { dg-do compile } + { dg-options "-Wall -Wno-unused-value -Wno-int-to-pointer-cast" } */ + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) + +typedef struct ATTR (packed) A { ATTR (packed) unsigned bf: 1; } A; + +typedef struct B +{ + struct A a; + struct A *pa; +} B; + +extern struct A a; +extern struct A *pa; +extern B b; +extern B ab[1]; +extern B *pb; + +typedef struct C +{ + ATTR (copy ((struct A *)0)) short m_pa_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy ((struct A *)(1, 0))) int m_pa_1_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy ((struct A *)(0, 1))) long m_pa_0_1; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + + ATTR (copy (*(struct A *)0)) short m_xpa_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (*(struct A *)(1, 0))) int m_xpa_1_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (*(struct A *)(0, 1))) long m_xpa_0_1; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + + ATTR (copy (((struct A *)0)[0])) short m_arpa_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (((struct A *)(1, 0))[0])) int m_arpa_1_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (((struct A *)(0, 1))[0])) long m_arpa_0_1; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + + /* Also exercise COMPONENT_REF, ARRAY_REF, and INDIRECT_REF. */ + ATTR (copy (a)) short m_ra; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (b.a)) int m_rb_a; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (b.pa)) long m_rb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + + ATTR (copy (&a)) short m_ara; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (&b.a)) int m_arb_a; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (*b.pa)) long m_xb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (b.pa[0])) long m_arb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + + ATTR (copy (*pa)) short m_xpa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (pa[0])) short m_arpa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + + ATTR (copy (ab[0].a)) int m_arab_a; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (ab[1].pa)) long m_arab_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (*ab[2].pa)) int m_xarab_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (ab[3].pa->bf)) unsigned int m_arab_pa_bf: 1; + + ATTR (copy (pb->a)) int m_pb_a; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (pb->pa)) long m_pb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (*pb->pa)) int m_xpb_pa; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ + ATTR (copy (pb->pa->bf)) unsigned int m_pb_pa_bf: 1; + + ATTR (aligned (4), copy ((struct A *)(0))) short m_a4_pa_0; + /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ +} C; + + +_Static_assert (__builtin_has_attribute (((C*)0)->m_pa_0, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_pa_1_0, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_pa_0_1, packed)); + +_Static_assert (__builtin_has_attribute (((C*)0)->m_xpa_0, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_xpa_1_0, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_xpa_0_1, packed)); + +_Static_assert (__builtin_has_attribute (((C*)0)->m_arpa_0, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_arpa_1_0, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_arpa_0_1, packed)); + +_Static_assert (__builtin_has_attribute (((C*)0)->m_ra, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_rb_a, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_rb_pa, packed)); + +_Static_assert (__builtin_has_attribute (((C*)0)->m_ara, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_arb_a, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_xb_pa, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_arb_pa, packed)); + +_Static_assert (__builtin_has_attribute (((C*)0)->m_xpa, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_arpa, packed)); + +_Static_assert (__builtin_has_attribute (((C*)0)->m_arab_a, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_arab_pa, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_xarab_pa, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_arab_pa_bf, packed)); + +_Static_assert (__builtin_has_attribute (((C*)0)->m_pb_a, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_pb_pa, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_xpb_pa, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_pb_pa_bf, packed)); + +_Static_assert (__builtin_has_attribute (((C*)0)->m_a4_pa_0, packed)); +_Static_assert (__builtin_has_attribute (((C*)0)->m_a4_pa_0, aligned)); +_Static_assert (__alignof__ (((C*)0)->m_a4_pa_0) == 4); diff --git a/SingleSource/Regression/C/gcc-dg/attr-copy.c b/SingleSource/Regression/C/gcc-dg/attr-copy.c new file mode 100644 index 0000000000..8bd537acf7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-copy.c @@ -0,0 +1,34 @@ +/* PR middle-end/81824 - Warn for missing attributes with function aliases + Exercise error handling for attribute copy. + { dg-do compile } + { dg-require-alias "" } + { dg-options "-O2 -Wall" } */ + +#define ATTR(list) __attribute__ (list) + +/* Verify incorrect numbers of arguments. */ +ATTR ((copy)) void +fno_args (void); /* { dg-error "wrong number of arguments specified for .copy. attribute" } */ + +ATTR ((copy ())) void +fno_args2 (void); /* { dg-error "wrong number of arguments specified for .copy. attribute" } */ + +ATTR ((copy (fno_args, fno_args))) void +fmlti_args (void); /* { dg-error "wrong number of arguments specified for .copy. attribute" } */ + +/* Verify that referencing an undeclared symbol is rejected with an error. */ + +ATTR ((copy (foobar))) /* { dg-error ".foobar. undeclared" } */ +void fundeclared (void); + +/* Verify that using a string argument triggers a descriptive error + (given attributes like alias and weakref using a string is a likely + mistake). */ + +ATTR ((copy ("foobar"))) +void fstring (void); /* { dg-error ".copy. attribute argument cannot be a string" } */ + +/* Ditto for an integer. */ + +ATTR ((copy (123))) +void fnumber (void); /* { dg-error ".copy. attribute argument cannot be a constant arithmetic expression" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-error-1.c b/SingleSource/Regression/C/gcc-dg/attr-error-1.c new file mode 100644 index 0000000000..c136484a15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-error-1.c @@ -0,0 +1,12 @@ +/* PR c/35744 */ + +typedef char a[N] __attribute__((aligned(4))); /* { dg-error "undeclared" } */ + +void c[1] __attribute__((vector_size(8))); /* { dg-error "array of voids" } */ + +void b[1] __attribute__((may_alias)); /* { dg-error "array of voids" } */ + +struct A +{ + void d[1] __attribute__((packed)); /* { dg-error "array of voids" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/attr-externally-visible-1.c b/SingleSource/Regression/C/gcc-dg/attr-externally-visible-1.c new file mode 100644 index 0000000000..e1db6923a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-externally-visible-1.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fwhole-program" } */ +/* { dg-final { scan-assembler "foo1" } } */ +/* { dg-final { scan-assembler "foo2" } } */ +/* { dg-final { scan-assembler "foo3" } } */ +/* { dg-final { scan-assembler "foo4" } } */ +/* { dg-final { scan-assembler "foo5" } } */ +/* { dg-final { scan-assembler-not "foo6" } } */ +/* { dg-final { scan-assembler "bar1" } } */ +/* { dg-final { scan-assembler "bar2" } } */ +/* { dg-final { scan-assembler "bar3" } } */ +/* { dg-final { scan-assembler "bar4" } } */ +/* { dg-final { scan-assembler "bar5" } } */ +/* { dg-final { scan-assembler-not "bar6" } } */ + +extern void foo1 (void) __attribute__((externally_visible)); +void foo1 (void) { } + +extern void foo2 (void) __attribute__((externally_visible)); +__attribute__((externally_visible)) void foo2 (void) { } + +extern void foo3 (void); +__attribute__((externally_visible)) void foo3 (void) { } + +__attribute__((externally_visible)) void foo4 (void) { } + +void foo5 (void) { } +extern void foo5 (void) __attribute__((externally_visible)); + +void foo6 (void) { } + +extern char *bar1 __attribute__((externally_visible)); +char *bar1; + +extern char *bar2 __attribute__((externally_visible)); +char *bar2 __attribute__((externally_visible)); + +extern char *bar3; +char *bar3 __attribute__((externally_visible)); + +char *bar4 __attribute__((externally_visible)); + +char *bar5; +extern char *bar5 __attribute__((externally_visible)); + +char *bar6; + +int main (void) { } diff --git a/SingleSource/Regression/C/gcc-dg/attr-externally-visible-2.c b/SingleSource/Regression/C/gcc-dg/attr-externally-visible-2.c new file mode 100644 index 0000000000..0a925bab3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-externally-visible-2.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fwhole-program" } */ + +static void foo1 (void) { } /* { dg-warning "have effect only on public" } */ +extern void foo1 (void) __attribute__((externally_visible)); + +void foo2 (void) +{ + __attribute__((externally_visible)) void foo3 (void) { } /* { dg-warning "have effect only on public" } */ +} + +__attribute__((externally_visible)) static void foo3 (void) { } /* { dg-warning "have effect only on public" } */ + +static int bar1; +extern int bar1 __attribute__((externally_visible)); /* { dg-warning "have effect only on public" } */ + +static int bar2 __attribute__((externally_visible)); /* { dg-warning "have effect only on public" } */ + +void fn1 (void) +{ + static int bar3 __attribute__((externally_visible)); /* { dg-warning "have effect only on public" } */ +} + +void fn2 (void) +{ + int bar4 __attribute__((externally_visible)); /* { dg-warning "have effect only on public" } */ +} + +struct A +{ +} __attribute__((externally_visible)); /* { dg-warning "does not apply to types" } */ + +typedef int B __attribute__((externally_visible)); /* { dg-warning "attribute ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-flatten-1.c b/SingleSource/Regression/C/gcc-dg/attr-flatten-1.c new file mode 100644 index 0000000000..68a194cc52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-flatten-1.c @@ -0,0 +1,29 @@ +/* { dg-require-alias "" } */ +int fn2(int); +int fn3(int); + +__attribute__((flatten)) +int fn1(int p1) +{ + int a = fn2(p1); + return fn3(a); +} +__attribute__((flatten)) +__attribute__((alias("fn1"))) +int fn4(int p1); + +/* Again, but this time the target doesn't have the attribute. */ +int fn1a(int p1) +{ + int a = fn2(p1); + return fn3(a); +} +__attribute__((flatten)) +__attribute__((alias("fn1a"))) +int fn4a(int p1); /* { dg-warning "ignored" } */ + +int +test () +{ + return fn4(1)+fn4a(1); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-hotcold-1.c b/SingleSource/Regression/C/gcc-dg/attr-hotcold-1.c new file mode 100644 index 0000000000..f63a95c71c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-hotcold-1.c @@ -0,0 +1,8 @@ +void f(void) +{ + goto A; + A: __attribute__((cold)) + goto B; + B: __attribute__((hot)) + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-ifunc-1.c b/SingleSource/Regression/C/gcc-dg/attr-ifunc-1.c new file mode 100644 index 0000000000..f1a1986656 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-ifunc-1.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "" } */ + +static int implementation (void) +{ + __builtin_printf ("'ere I am JH\n"); + return 0; +} + +static __typeof__ (implementation)* resolver (void) +{ + return implementation; +} + +extern int magic (void) __attribute__ ((ifunc ("resolver"))); + +int main () +{ + return magic () != 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-ifunc-2.c b/SingleSource/Regression/C/gcc-dg/attr-ifunc-2.c new file mode 100644 index 0000000000..8221cd4313 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-ifunc-2.c @@ -0,0 +1,30 @@ +/* { dg-require-ifunc "" } */ + +typedef int F (void); + +static F *resolver () +{ + return 0; +} + +extern int magic (void) /* { dg-message "previous definition" } */ + __attribute__ ((ifunc ("resolver"))); +extern int magic (void) /* { dg-error "redefinition" } */ + __attribute__ ((alias ("resolver"))); + +extern int spell (void) /* { dg-message "previous definition" } */ +{ + return 0; +} +extern int spell (void) /* { dg-error "redefinition" } */ + __attribute__ ((ifunc ("resolver"))); + +extern int mantra (void) /* { dg-message "previous definition" } */ + __attribute__ ((alias ("resolver"))); +extern int mantra (void) /* { dg-error "redefinition" } */ + __attribute__ ((ifunc ("resolver"))); + +extern int saying (void) /* { dg-error "weak .* cannot be defined" } */ + __attribute__ ((weak,ifunc ("resolver"))); +extern int maxim (void) /* { dg-error "indirect function .* cannot be declared weak" } */ + __attribute__ ((ifunc ("resolver"),weak)); diff --git a/SingleSource/Regression/C/gcc-dg/attr-ifunc-3.c b/SingleSource/Regression/C/gcc-dg/attr-ifunc-3.c new file mode 100644 index 0000000000..653af856d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-ifunc-3.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "" } */ + +#include + +static int __attribute__((noinline)) + implementation (void *ptr) +{ + if (ptr) + return ((int (*) (void *))ptr) (0); + + printf ("'ere I am JH\n"); + return 0; +} + +static __typeof__ (implementation) *resolver (void) +{ + return (void *)implementation; +} + +extern int magic (void *) __attribute__ ((ifunc ("resolver"))); + +int main () +{ + return magic ((void *)magic); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-ifunc-4.c b/SingleSource/Regression/C/gcc-dg/attr-ifunc-4.c new file mode 100644 index 0000000000..5c87445b39 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-ifunc-4.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "" } */ + +#include + +static int implementation (void) +{ + printf ("'ere I am JH\n"); + return 0; +} + +static __typeof__ (implementation)* resolver (void) +{ + return implementation; +} + +static int magic (void) __attribute__ ((ifunc ("resolver"))); + +int main () +{ + return magic () != 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-ifunc-5.c b/SingleSource/Regression/C/gcc-dg/attr-ifunc-5.c new file mode 100644 index 0000000000..1ecc391f73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-ifunc-5.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "" } */ + +#include + +static int implementation (void) +{ + printf ("'ere I am JH\n"); + return 0; +} + +static __typeof__ (implementation)* resolver (void) +{ + return (void *)implementation; +} + +extern int magic (void) __attribute__ ((ifunc ("resolver"),visibility ("hidden"))); + +int main () +{ + return magic () != 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-invalid.c b/SingleSource/Regression/C/gcc-dg/attr-invalid.c new file mode 100644 index 0000000000..a3315fa131 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-invalid.c @@ -0,0 +1,102 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#define CONCAT_(A,B) A ## B +#define CONCAT(A,B) CONCAT_(A,B) + +#define ATTR __attribute__((AT)) +#define ATSYM(suf) CONCAT (AT, CONCAT_ (_, suf)) + +#define AT noinline + +typedef int ATSYM(type) ATTR; /* { dg-warning "attribute ignored" } */ + +typedef int (*ATSYM(fntype))(void) ATTR; /* { dg-warning "attribute ignored" } */ + +struct ATSYM(struct) { + char dummy ATTR; /* { dg-warning "attribute ignored" } */ +} ATTR; /* { dg-warning "does not apply to types" } */ + +int ATSYM(var) ATTR; /* { dg-warning "attribute ignored" } */ + +int ATSYM(fn_knrarg) (arg) + int arg ATTR; /* { dg-warning "attribute ignored" } */ +{ return 0; } + +int ATSYM(fn_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute ignored" } */ + +int ATSYM(fn_vars) (void) { + static int svar ATTR; /* { dg-warning "attribute ignored" } */ + auto int lvar ATTR; /* { dg-warning "attribute ignored" } */ + return 0; +} + + +#undef AT +#define AT used + +typedef int ATSYM(type) ATTR; /* used attribute is no longer + ignored. */ + +typedef int (*ATSYM(fntype))(void) ATTR; /* used attribute is no + longer ignored. */ + +struct ATSYM(struct) { + char dummy ATTR; /* { dg-warning "attribute ignored" } */ +} ATTR; /* { dg-warning "does not apply to types" } */ + +int ATSYM(var) ATTR; + +int ATSYM(fn_knrarg) (arg) + int arg ATTR; /* { dg-warning "attribute ignored" } */ +{ return 0; } + +int ATSYM(fn_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute ignored" } */ + +int ATSYM(fn_vars) (void) { + static int svar ATTR; + auto int lvar ATTR; /* { dg-warning "attribute ignored" } */ + return 0; +} + + +/* PR 28287 */ +/* These are invalid on all targets. Applying to PARM_ or FIELD_DECL + also caused a tree checking ice on targets that support weak, */ +#undef AT +#define AT weak + +typedef int ATSYM(type) ATTR; /* { dg-warning "attribute ignored" } */ + +typedef int (*ATSYM(fntype))(void) ATTR; /* { dg-warning "attribute ignored" } */ + +struct ATSYM(struct) { + char dummy ATTR; /* { dg-warning "attribute ignored" } */ +}; + +int ATSYM(fn_knrarg) (arg) + int arg ATTR; /* { dg-warning "attribute ignored" } */ +{ return 0; } + +int ATSYM(fn_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute ignored" } */ + + +/* PR target/28648 */ +/* These are invalid on all targets. Applying to PARM_ or FIELD_DECL + also caused a tree checking ice on targets that support dllimport. */ +#undef AT +#define AT dllimport + +typedef int ATSYM(type) ATTR; /* { dg-warning "attribute |directive ignored" } */ + +typedef int (*ATSYM(fntype))(void) ATTR; /* { dg-warning "attribute |directive ignored" } */ + +struct ATSYM(struct) { + char dummy ATTR; /* { dg-warning "attribute |directive ignored" } */ +}; + +int ATSYM(fn_knrarg) (arg) + int arg ATTR; /* { dg-warning "attribute |directive ignored" } */ +{ return 0; } + +int ATSYM(fn_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute |directive ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-malloc.c b/SingleSource/Regression/C/gcc-dg/attr-malloc.c new file mode 100644 index 0000000000..14f1980ed7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-malloc.c @@ -0,0 +1,75 @@ +/* PR middle-end/94527 - Add an attribute that marks a function as freeing + an object + Verify that attribute malloc with one or two arguments is accepted where + intended and rejected where it's invalid. + { dg-options "-Wall -ftrack-macro-expansion=0" } */ + +#define A(...) __attribute__ ((malloc (__VA_ARGS__))) + +A (0) void* alloc_zero (int); // { dg-error "'malloc' attribute argument 1 does not name a function" } + +A ("") void* alloc_string (int); // { dg-error "'malloc' attribute argument 1 does not name a function" } + +int var; +A (var) void* alloc_var (int); // { dg-error "'malloc' attribute argument 1 does not name a function" } + +typedef struct Type { int i; } Type; +A (Type) void* alloc_type (int); // { dg-error "expected expression|identifier" } + +A (unknown) void* alloc_unknown (int); // { dg-error "'unknown' undeclared" } + +void fv_ (); // { dg-message "declared here" } +A (fv_) void* alloc_fv_ (int); // { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument" } + +void fvi (int); // { dg-message "declared here" } +A (fvi) void* alloc_fvi (int); // { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument; have 'int'" } + +void fvv (void); // { dg-message "declared here" } +A (fvv) void* alloc_fvv (int); // { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument; have 'void'" } + +void fvi_ (int, ...); // { dg-message "declared here" } +A (fvi_) void* alloc_fvi_ (int); // { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument; have 'int'" } + +void fvi_vp (Type, void*); // { dg-message "declared here" } +A (fvi_vp) void* alloc_fvi_vp (int); // { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument; have 'Type'" } + + +void fpv (void*); +A (fpv) void* alloc_fpv (int); + +void fpv_i (void*, int); +A (fpv_i) void* alloc_fpv_i (int); + +void fpv_pv (void*, void*); +A (fpv_i) void* alloc_fpv_pv (int); + + +void gpc (char*); +void hpi (int*); +A (fpv) A (gpc) A (hpi) Type* alloc_fpv_gpv (int); + + +/* Verify that the attribute can be applied to functions. */ +typedef struct FILE FILE; +typedef __SIZE_TYPE__ size_t; + +int fclose (FILE*); +FILE* fdopen (int); +FILE* fopen (const char*, const char*); +FILE* freopen (const char*, const char*, FILE*); +int pclose (FILE*); +FILE* popen (const char*, const char*); +FILE* tmpfile (void); + +A (fclose) A (freopen, 3) A (pclose) + FILE* fdopen (int); +A (fclose) A (freopen, 3) A (pclose) + FILE* fopen (const char*, const char*); +A (fclose) A (freopen, 3) A (pclose) + FILE* fmemopen(void *, size_t, const char *); +A (fclose) A (freopen, 3) A (pclose) + FILE* freopen (const char*, const char*, FILE*); +A (fclose) A (freopen, 3) A (pclose) + FILE* popen (const char*, const char*); +A (fclose) A (freopen, 3) A (pclose) + FILE* tmpfile (void); diff --git a/SingleSource/Regression/C/gcc-dg/attr-may-alias-1.c b/SingleSource/Regression/C/gcc-dg/attr-may-alias-1.c new file mode 100644 index 0000000000..30e2bca6f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-may-alias-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "dont_delete" } } */ + +typedef struct { int x; } __attribute__((may_alias)) S; + +extern void dont_delete (void); + +void f(S *s, float *f) +{ + s->x = 1; + *f = 0; + if (s->x != 1) + dont_delete (); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-mode-1.c b/SingleSource/Regression/C/gcc-dg/attr-mode-1.c new file mode 100644 index 0000000000..e60d01b338 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-mode-1.c @@ -0,0 +1,13 @@ +/* PR c/17384 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef struct __attribute__((mode(SI))) { + unsigned INT0 :1, + RES0 :1, + :6, + INT1 :1, + RES1 :1, + :6, + :16; +} MCR; /* { dg-error "inappropriate type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-mode-2.c b/SingleSource/Regression/C/gcc-dg/attr-mode-2.c new file mode 100644 index 0000000000..1a025212e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-mode-2.c @@ -0,0 +1,22 @@ +/* PR c/18282 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int tword __attribute__((mode(word))); + +typedef enum { B1 = 1 } B; +typedef enum { C1 = 1 } C __attribute__ ((mode(QI))); +typedef enum { D1 = 1 } __attribute__ ((mode(word))) D; + +B __attribute__ ((mode (QI))) bqi; +B __attribute__ ((mode (word))) bword; + +int sqi[sizeof (bqi) == 1 ? 1 : -1]; +int sword[sizeof (bword) == sizeof(tword) ? 1 : -1]; +int sc[sizeof (C) == 1 ? 1 : -1]; +int sd[sizeof (D) == sizeof(tword) ? 1 : -1]; + +int aqi[__alignof (bqi) == 1 ? 1 : -1]; +int aword[__alignof (bword) == __alignof(tword) ? 1 : -1]; +int ac[__alignof (C) == 1 ? 1 : -1]; +int ad[__alignof (D) == __alignof(tword) ? 1 : -1]; diff --git a/SingleSource/Regression/C/gcc-dg/attr-ms_struct-1.c b/SingleSource/Regression/C/gcc-dg/attr-ms_struct-1.c new file mode 100644 index 0000000000..1e6cca5994 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-ms_struct-1.c @@ -0,0 +1,165 @@ +/* Test for MS structure sizes. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-std=gnu99" } */ + +extern void abort (); + +#define ATTR __attribute__((__ms_struct__)) + +#define size_struct_0 1 +#define size_struct_1 4 +#define size_struct_2 24 +#define size_struct_3 8 +#define size_struct_4 32 +#define size_struct_5 12 +#define size_struct_6 40 +#define size_struct_7 8 +#define size_struct_8 20 +#define size_struct_9 32 + +struct _struct_0 +{ + char member_0; +} ATTR; +typedef struct _struct_0 struct_0; + +struct _struct_1 +{ + char member_0; + short member_1:13; +} ATTR; +typedef struct _struct_1 struct_1; + +struct _struct_2 +{ + double member_0; + unsigned char member_1:8; + long member_2:32; + unsigned char member_3:5; + short member_4:14; + short member_5:13; + unsigned char:0; +} ATTR; +typedef struct _struct_2 struct_2; + +struct _struct_3 +{ + unsigned long member_0:26; + unsigned char member_1:2; + +} ATTR; +typedef struct _struct_3 struct_3; + +struct _struct_4 +{ + unsigned char member_0:7; + double member_1; + double member_2; + short member_3:5; + char member_4:2; + +} ATTR; +typedef struct _struct_4 struct_4; + +struct _struct_5 +{ + unsigned short member_0:12; + long member_1:1; + unsigned short member_2:6; + +} ATTR; +typedef struct _struct_5 struct_5; + +struct _struct_6 +{ + unsigned char member_0:7; + unsigned long member_1:25; + char member_2:1; + double member_3; + short member_4:9; + double member_5; + +} ATTR; +typedef struct _struct_6 struct_6; + +struct _struct_7 +{ + double member_0; + +} ATTR; +typedef struct _struct_7 struct_7; + +struct _struct_8 +{ + unsigned char member_0:7; + long member_1:11; + long member_2:5; + long:0; + char member_4:8; + unsigned short member_5:4; + unsigned char member_6:3; + long member_7:23; + +} ATTR; +typedef struct _struct_8 struct_8; + +struct _struct_9 +{ + double member_0; + unsigned long member_1:6; + long member_2:17; + double member_3; + unsigned long member_4:22; + +} ATTR; +typedef struct _struct_9 struct_9; + +struct_0 test_struct_0 = { 123 }; +struct_1 test_struct_1 = { 82, 1081 }; +struct_2 test_struct_2 = { 20.0, 31, 407760, 1, 14916, 6712 }; +struct_3 test_struct_3 = { 64616999, 1 }; +struct_4 test_struct_4 = { 61, 20.0, 20.0, 12, 0 }; +struct_5 test_struct_5 = { 909, 1, 57 }; +struct_6 test_struct_6 = { 12, 21355796, 0, 20.0, 467, 20.0 }; +struct_7 test_struct_7 = { 20.0 }; +struct_8 test_struct_8 = { 126, 1821, 22, 125, 6, 0, 2432638 }; +struct_9 test_struct_9 = { 20.0, 3, 23957, 20.0, 1001631 }; + + +int +main (void) +{ + + if (size_struct_0 != sizeof (struct_0)) + abort (); + + if (size_struct_1 != sizeof (struct_1)) + abort (); + + if (size_struct_2 != sizeof (struct_2)) + abort (); + + if (size_struct_3 != sizeof (struct_3)) + abort (); + + if (size_struct_4 != sizeof (struct_4)) + abort (); + + if (size_struct_5 != sizeof (struct_5)) + abort (); + + if (size_struct_6 != sizeof (struct_6)) + abort (); + + if (size_struct_7 != sizeof (struct_7)) + abort (); + + if (size_struct_8 != sizeof (struct_8)) + abort (); + + if (size_struct_9 != sizeof (struct_9)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-ms_struct-2.c b/SingleSource/Regression/C/gcc-dg/attr-ms_struct-2.c new file mode 100644 index 0000000000..4ebf06b7d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-ms_struct-2.c @@ -0,0 +1,36 @@ +/* Test for MS structure sizes. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-std=gnu99" } */ + +extern void abort (); + +#define ATTR __attribute__((__ms_struct__)) + +struct _struct_0 +{ + long member_0 : 25 ; + short member_1 : 6 ; + char member_2 : 2 ; + unsigned short member_3 : 1 ; + unsigned char member_4 : 7 ; + short member_5 : 16 ; + long : 0 ; + char member_7 ; + +} ATTR; +typedef struct _struct_0 struct_0; + +#define size_struct_0 20 + +struct_0 test_struct_0 = { 18557917, 17, 3, 0, 80, 6487, 93 }; + +int +main (void) +{ + + if (size_struct_0 != sizeof (struct_0)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-ms_struct-packed1.c b/SingleSource/Regression/C/gcc-dg/attr-ms_struct-packed1.c new file mode 100644 index 0000000000..cc26e6ee83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-ms_struct-packed1.c @@ -0,0 +1,25 @@ +/* Test for MS structure with packed attribute. */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } +/* { dg-options "-std=gnu99" } */ + +extern void abort (); + +union u +{ + int a; +} __attribute__((__ms_struct__, __packed__)); + +struct s +{ + char c; + union u u; +}; + +int +main (void) +{ + if (sizeof (struct s) != (sizeof (char) + sizeof (union u))) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-nest.c b/SingleSource/Regression/C/gcc-dg/attr-nest.c new file mode 100644 index 0000000000..16a79c6e74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-nest.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +#define ATTR_PRINTF __attribute__ ((format (printf, 1, 2))) +#define ATTR_USED __attribute__ ((used)) + +void bar (int, ...); + +/* gcc would segfault on the nested attribute. */ +void foo (void) +{ + bar (0, (void (*ATTR_PRINTF) (const char *, ...)) 0); +} + +/* For consistency, unnamed decls should give the same warnings as + named ones. */ +void proto1 (int (*ATTR_USED) (void)); /* { dg-warning "attribute ignored" } */ +void proto2 (int (*ATTR_USED bar) (void)); /* { dg-warning "attribute ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-noinline.c b/SingleSource/Regression/C/gcc-dg/attr-noinline.c new file mode 100644 index 0000000000..b77a346603 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-noinline.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -finline-functions -fno-ipa-icf" } */ + +extern int t(); + +static inline void __attribute__((__noinline__)) function_definition(void) {t();} /* { dg-warning "inline function \[^\n\]* given attribute 'noinline'" } */ + +static inline void __attribute__((__noinline__)) function_declaration_both_before(void); /* { dg-warning "inline function \[^\n\]* given attribute 'noinline'" } */ + +static void function_declaration_both_before(void) {t();} + +static void function_declaration_both_after(void); + +static inline void __attribute__((__noinline__)) function_declaration_both_after(void); /* { dg-warning "(inline function \[^\n\]* given attribute .noinline.|declared inline after its definition)" } */ + +static void function_declaration_both_after(void) {t();} + +static void function_declaration_noinline_before(void) __attribute__((__noinline__)); /* { dg-message "note: previous declaration" } */ + +static inline void function_declaration_noinline_before(void) {t();} /* { dg-warning "follows declaration with attribute .noinline." } */ + +static inline void function_declaration_noinline_after(void) {t();} /* { dg-message "note: previous definition" } */ + +static void function_declaration_noinline_after(void) __attribute__((__noinline__)); /* { dg-warning "follows inline declaration" } */ + +static inline void function_declaration_inline_before(void); /* { dg-message "note: previous declaration" } */ + +static void __attribute__((__noinline__)) function_declaration_inline_before(void) {t();} /* { dg-warning "follows inline declaration" } */ + +static inline void function_declaration_inline_noinline_before(void); /* { dg-message "note: previous declaration" } */ + +static void function_declaration_inline_noinline_before(void) __attribute__((__noinline__)); /* { dg-warning "follows inline declaration" } */ + +static void function_declaration_inline_noinline_before(void) {t();} + +static inline void function_declaration_inline_noinline_after(void); + +static void function_declaration_inline_noinline_after(void) {t();} /* { dg-message "note: previous definition" } */ + +static void function_declaration_inline_noinline_after(void) __attribute__((__noinline__)); /* { dg-warning "follows inline declaration" } */ + +static void function_declaration_noinline_inline_before(void) __attribute__((__noinline__)); /* { dg-message "note: previous declaration" } */ + +static inline void function_declaration_noinline_inline_before(void); /* { dg-warning "follows declaration with attribute .noinline." } */ + +static void function_declaration_noinline_inline_before(void) {t();} + +void f () { + function_definition (); + function_declaration_both_before (); + function_declaration_both_after (); + function_declaration_noinline_before (); + function_declaration_noinline_after (); + function_declaration_inline_before (); + function_declaration_inline_noinline_before (); + function_declaration_inline_noinline_after (); + function_declaration_noinline_inline_before (); +} + +/* { dg-final { scan-assembler "function_definition" } } */ +/* { dg-final { scan-assembler "function_declaration_both_before" } } */ +/* { dg-final { scan-assembler "function_declaration_both_after" } } */ +/* { dg-final { scan-assembler "function_declaration_noinline_before" } } */ +/* { dg-final { scan-assembler "function_declaration_noinline_after" } } */ +/* { dg-final { scan-assembler "function_declaration_inline_before" } } */ +/* { dg-final { scan-assembler "function_declaration_inline_noinline_before" } } */ +/* { dg-final { scan-assembler "function_declaration_inline_noinline_after" } } */ +/* { dg-final { scan-assembler "function_declaration_noinline_inline_before" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-noipa.c b/SingleSource/Regression/C/gcc-dg/attr-noipa.c new file mode 100644 index 0000000000..b2485bb7f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-noipa.c @@ -0,0 +1,189 @@ +/* Test the noipa attribute. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-require-effective-target alloca } */ + +static inline int __attribute__((noipa)) +fn1 (void) /* { dg-warning "inline function \[^\n\]* given attribute 'noinline'" "" } */ +{ + return 1; +} + +/* Verify the function is not inlined into its caller. */ + +static __attribute__((noipa)) int +fn2 (int x, int y) +{ + return x + y; +} + +int +fn3 (int x) +{ + return fn2 (x, 0); +} + +/* { dg-final { scan-tree-dump "= fn2 \\(" "optimized" } } */ + +void fn4 (char *); + +/* Verify the function is not cloned. */ + +__attribute__((__noipa__)) static int +fn5 (int x, int y) +{ + char *p = __builtin_alloca (x + y); + fn4 (p); + return x + y; +} + +int +fn6 (int x) +{ + return fn5 (x, 2); +} + +/* { dg-final { scan-tree-dump "= fn5 \\(" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "fn5\\.constprop" "optimized" } } */ + +/* Verify we still remove unused function calls, even if they have + noipa attribute. */ + +static void fn7 (void) __attribute__((noipa)); +static void +fn7 (void) +{ +} + +/* { dg-final { scan-tree-dump-not "fn7 \\(" "optimized" } } */ + +/* Verify noipa functions are not ICF optimized. */ + +static __attribute__((noipa)) int +fn8 (int x) +{ + return x + 12; +} + +static __attribute__((noipa)) int +fn9 (int x) +{ + return x + 12; +} + +int +fn10 (int x) +{ + return fn8 (x) + fn9 (x); +} + +/* { dg-final { scan-tree-dump "fn8 \\(int" "optimized" } } */ +/* { dg-final { scan-tree-dump "fn9 \\(int" "optimized" } } */ + +/* Verify IPA-VRP is not performed. */ + +void fn11 (void); + +static int __attribute__((noipa)) +fn12 (int x) +{ + if (x < 6 || x >= 29) + fn11 (); +} + +void +fn13 (int x) +{ + fn12 (6 + (x & 15)); +} + +/* { dg-final { scan-tree-dump "fn11 \\(\\)" "optimized" } } */ + +void fn14 (void); + +__attribute__((noipa)) static int +fn15 (int x) +{ + return x & 7; +} + +int +fn16 (int x) +{ + x = fn15 (x); + if (x < 0 || x >= 7) + fn14 (); +} + +/* { dg-final { scan-tree-dump "fn14 \\(\\)" "optimized" } } */ + +/* Verify IPA BIT CP is not performed. */ + +void fn17 (void); + +__attribute__((noipa)) static int +fn18 (int x) +{ + if (x & 8) + fn17 (); +} + +void +fn19 (void) +{ + fn18 (1); + fn18 (2); + fn18 (4); + fn18 (16); + fn18 (32); + fn18 (64); +} + +/* { dg-final { scan-tree-dump "fn17 \\(\\)" "optimized" } } */ + +/* Ensure pure/const discovery is not performed. */ + +int var1; +void fn20 (void); + +__attribute__((noipa)) static int +fn21 (int x, int y) +{ + return x * y; +} + +int +fn22 (void) +{ + var1 = 7; + asm volatile ("" : "+g" (var1) : : "memory"); + int a = var1; + int b = fn21 (a, a); + if (a != var1) + fn20 (); + return b; +} + +/* { dg-final { scan-tree-dump "fn20 \\(\\)" "optimized" } } */ + +/* Verify IPA alignment propagation is not performed. */ + +static __attribute__ ((aligned(16))) char var2[32]; +void fn23 (void); + +__attribute__((noipa)) static void +fn24 (char *p) +{ + if ((((__UINTPTR_TYPE__) p) & 15) != 0) + fn23 (); + asm (""); +} + +void +fn25 (void) +{ + fn24 (var2); + fn24 (var2 + 16); +} + +/* { dg-final { scan-tree-dump "fn20 \\(\\)" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-nonstring-2.c b/SingleSource/Regression/C/gcc-dg/attr-nonstring-2.c new file mode 100644 index 0000000000..44a102c5a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-nonstring-2.c @@ -0,0 +1,115 @@ +/* PR middle-end/81384 - built-in form of strnlen missing + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#include "range.h" + +extern void* memcpy (void*, const void*, size_t); +extern size_t strnlen (const char*, size_t); + +#define NONSTRING __attribute__ ((nonstring)) + +#define _CAT(s, n) s ## n +#define CAT(s, n) _CAT (s, n) +#define UNIQ(n) CAT (n, __LINE__) + +void sink (size_t, ...); + +#define T(expr) sink (expr) + +void test_strnlen_array_cst (void) +{ + NONSTRING char ns3[3]; + sink (0, ns3); // "initialize" ns3 + + T (strnlen (ns3, 0)); + T (strnlen (ns3, 1)); + T (strnlen (ns3, 2)); + T (strnlen (ns3, 3)); + T (strnlen (ns3, 4)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 4|specified bound 4 exceeds source size 3" } */ + T (strnlen (ns3, DIFF_MAX)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound|specified bound \[0-9\]+ exceeds source size" } */ + T (strnlen (ns3, SIZE_MAX)); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + NONSTRING char ns5[5]; + sink (0, ns5); + + T (strnlen (ns5, 0)); + T (strnlen (ns5, 1)); + T (strnlen (ns5, 2)); + T (strnlen (ns5, 3)); + T (strnlen (ns5, 6)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 6|specified bound 6 exceeds source size 5" } */ + T (strnlen (ns5, DIFF_MAX)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound|specified bound \[0-9\]+ exceeds source size 5" } */ + T (strnlen (ns5, SIZE_MAX)); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ +} + + +void test_strnlen_array_range (void) +{ + NONSTRING char ns3[3]; + sink (0, ns3); // "initialize" ns3 + + T (strnlen (ns3, UR (0, 3))); + T (strnlen (ns3, UR (0, 9))); + T (strnlen (ns3, UR (3, 4))); + T (strnlen (ns3, UR (3, DIFF_MAX))); + T (strnlen (ns3, UR (4, 5))); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[4, 5]|specified bound \\\[4, 5] exceeds source size 3" } */ + T (strnlen (ns3, UR (DIFF_MAX, SIZE_MAX))); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[\[0-9\]+, \[0-9\]+] |specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds source size 3 " } */ +} + + +#undef T +#define T(N, init, nelts, bound) \ + do { \ + extern NONSTRING char UNIQ (arr)[N]; \ + memcpy (UNIQ (arr), init, nelts); \ + sink (strnlen (UNIQ (arr), bound), UNIQ (arr)); \ + } while (0) + +void test_strnlen_string_cst (void) +{ + T (3, "1", 2, 1); + T (3, "1", 2, 2); + T (3, "1", 2, 3); + T (3, "12", 3, 1); + T (3, "12", 3, 9); + T (3, "123", 3, 1); + T (3, "123", 3, 4); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 4|specified bound 4 exceeds source size 3" } */ + T (3, "123", 3, 9); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 9|specified bound 9 exceeds source size 3" } */ + + T (5, "1", 2, 1); + T (5, "1", 2, 2); + T (5, "1", 2, 9); + + T (5, "12", 3, 1); + T (5, "12", 3, 9); + T (5, "123", 3, 1); + T (5, "123", 3, 5); + T (5, "123", 3, 6); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound 6|specified bound 6 exceeds source size 5" } */ + + /* Strnlen shouldn't trigger a warning for arrays of unknown size + (except for accesses to uninitialized elements when those are + detected). */ + T (/* [] */, "1", 1, 1); + T (/* [] */, "1", 1, 2); + T (/* [] */, "1", 2, 1); + T (/* [] */, "1", 2, 2); + T (/* [] */, "1", 2, 3); + T (/* [] */, "1", 2, 9); + T (/* [] */, "1", 2, DIFF_MAX); + T (/* [] */, "1", 2, SIZE_MAX); + + size_t n = DIFF_MAX; + T (/* [] */, "123", 3, n); + T (/* [] */, "123", 3, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size " } */ + n = SIZE_MAX; + T (/* [] */, "123", 3, n); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size " } */ +} + + +void test_strnlen_string_range (void) +{ + T (3, "1", 2, UR (0, 1)); + T (3, "1", 2, UR (3, 9)); + T (3, "123", 3, UR (4, 5)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[4, 5]|specified bound \\\[4, 5] exceeds source size 3" } */ + T (3, "123", 3, UR (5, 9)); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[5, 9]|specified bound \\\[5, 9] exceeds source size 3" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-nonstring-3.c b/SingleSource/Regression/C/gcc-dg/attr-nonstring-3.c new file mode 100644 index 0000000000..34f31fb6aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-nonstring-3.c @@ -0,0 +1,127 @@ +/* PR middle-end/81384 - built-in form of strnlen missing + + Since the strnlen patch affects the handling for strncmp and other + bounded functions, verify that a bound in excess of the maximum + object size specified for strncmp is diagnosed regardless of + attribute nonstring. Also verify that a bound that's greater than + the size of a non-string array is diagnosed, even if it's not in + excess of the maximum object size. + + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#include "range.h" + +extern int strncmp (const char*, const char*, size_t); + +#define STR /* not non-string */ +#define NS __attribute__ ((nonstring)) + +#define _CAT(s, n) s ## n +#define CAT(s, n) _CAT (s, n) +#define UNIQ(n) CAT (n, __LINE__) + +void sink (int); + +#define T(at1, N1, at2, N2, bound) \ + do { \ + extern at1 char UNIQ (a)[N1]; \ + extern at2 char UNIQ (b)[N2]; \ + sink (strncmp (UNIQ (a), UNIQ (b), bound)); \ + } while (0) + +void strncmp_cst (void) +{ + size_t n = DIFF_MAX; + + T (STR, /* [] */, STR, /* [] */, n); + T (STR, /* [] */, STR, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (STR, 1, STR, /* [] */, 1); + T (STR, 1, STR, /* [] */, n); + T (STR, 2, STR, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (STR, /* [] */, STR, 3, 3); + T (STR, /* [] */, STR, 3, n); + T (STR, /* [] */, STR, 4, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (STR, /* [] */, NS, /* [] */, 3); + T (STR, /* [] */, NS, /* [] */, n); + T (STR, /* [] */, NS, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (STR, 5, NS, /* [] */, 4); + T (STR, 5, NS, /* [] */, 5); + T (STR, 5, NS, /* [] */, 6); + T (STR, 5, NS, /* [] */, n); + T (STR, 6, NS, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (STR, /* [] */, NS, 7, n); /* { dg-warning "argument 2 declared attribute .nonstring. is smaller than the specified bound" } */ + + T (STR, /* [] */, NS, 8, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, STR, /* [] */, n); + T (NS, /* [] */, STR, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (NS, 9, STR, /* [] */, n); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \[0-9\]+" } */ + T (NS, 10, STR, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, STR, 11, 11); + T (NS, /* [] */, STR, 11, n); + T (NS, /* [] */, STR, 12, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, NS, /* [] */, n); + T (NS, /* [] */, NS, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (NS, 13, NS, /* [] */, 13); + T (NS, 13, NS, /* [] */, n); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \[0-9\]+" } */ + T (NS, 14, NS, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, NS, 15, 15); + T (NS, /* [] */, NS, 15, 16); /* { dg-warning "argument 2 declared attribute 'nonstring' is smaller than the specified bound 16" } */ + T (NS, /* [] */, NS, 16, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ +} + + +void strncmp_range (void) +{ + size_t n = DIFF_MAX; + n = UR (n, n + 1); + + T (STR, /* [] */, STR, /* [] */, n); + T (STR, /* [] */, STR, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (STR, 1, STR, /* [] */, 1); + T (STR, 1, STR, /* [] */, n); + T (STR, 2, STR, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (STR, /* [] */, STR, 3, n); + T (STR, /* [] */, STR, 4, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (STR, /* [] */, NS, /* [] */, n); + T (STR, /* [] */, NS, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (STR, 5, NS, /* [] */, n); + T (STR, 6, NS, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (STR, /* [] */, NS, 7, n); /* { dg-warning "argument 2 declared attribute 'nonstring' is smaller than the specified bound \\\[\[0-9\]+, \[0-9\]+]" } */ + + T (STR, /* [] */, NS, 8, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, STR, /* [] */, n); + T (NS, /* [] */, STR, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (NS, 9, STR, /* [] */, n); /* { dg-warning "argument 1 declared attribute .nonstring. is smaller than the specified bound" } */ + T (NS, 10, STR, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, STR, 11, n); + T (NS, /* [] */, STR, 12, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, NS, /* [] */, n); + T (NS, /* [] */, NS, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (NS, 13, NS, /* [] */, n); /* { dg-warning "argument 1 declared attribute .nonstring. is smaller than the specified bound" } */ + T (NS, 14, NS, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, NS, 15, n); /* { dg-warning "argument 2 declared attribute .nonstring. is smaller than the specified bound" } */ + T (NS, /* [] */, NS, 16, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-nonstring-4.c b/SingleSource/Regression/C/gcc-dg/attr-nonstring-4.c new file mode 100644 index 0000000000..6f03a56202 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-nonstring-4.c @@ -0,0 +1,64 @@ +/* PR middle-end/81384 - built-in form of strnlen missing + + Verify that a strnlen bound in excess of the maximum object size + is diagnosed regardless of attribute nonstring. Also verify that + a bound that's greater than the size of a non-string array is + diagnosed, even if it's not in excess of the maximum object size. + + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#include "range.h" + +extern size_t strnlen (const char*, size_t); + +#define STR /* not non-string */ +#define NS __attribute__ ((nonstring)) + +#define _CAT(s, n) s ## n +#define CAT(s, n) _CAT (s, n) +#define UNIQ(n) CAT (n, __LINE__) + +void sink (size_t); + +#define T(attr, N, bound) \ + do { \ + extern attr char UNIQ (a)[N]; \ + sink (strnlen (UNIQ (a), bound)); \ + } while (0) + +void strnlen_cst (void) +{ + size_t n = DIFF_MAX; + + T (STR, /* [] */, n); + T (STR, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (STR, 1, n); + T (STR, 2, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, n); + T (NS, /* [] */, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ + + T (NS, 9, n); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\d+|specified bound \\d+ exceeds source size 9" } */ + T (NS, 10, n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ +} + + +void strnlen_range (void) +{ + size_t n = DIFF_MAX; + n = UR (n, n + 1); + + T (STR, /* [] */, n); + T (STR, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (STR, 1, n); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds source size 1" } */ + T (STR, 2, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (NS, /* [] */, n); + T (NS, /* [] */, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ + + T (NS, 9, n); /* { dg-warning "argument 1 declared attribute 'nonstring' is smaller than the specified bound \\\[\\d+, \\d+]|specified bound \\\[\\d+, \\d+] exceeds source size 9" } */ + T (NS, 10, n + 1); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size \[0-9\]+" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-nonstring.c b/SingleSource/Regression/C/gcc-dg/attr-nonstring.c new file mode 100644 index 0000000000..d93e93ca67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-nonstring.c @@ -0,0 +1,123 @@ +/* PR middle-end/85359 - duplicate -Wstringop-overflow for a strcmp call + with a nonstring pointer + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __builtin_va_list va_list; + +int printf (const char*, ...); +int puts (const char*); +int puts_unlocked (const char*); +int sprintf (char*, const char*, ...); +int snprintf (char*, size_t, const char*, ...); +int vsprintf (char*, const char*, va_list); +int vsnprintf (char*, size_t, const char*, va_list); + +int strcmp (const char*, const char*); +int strncmp (const char*, const char*, size_t); + +char* stpcpy (char*, const char*); +char* stpncpy (char*, const char*, size_t); + +char* strcat (char*, const char*); +char* strncat (char*, const char*, size_t); + +char* strcpy (char*, const char*); +char* strncpy (char*, const char*, size_t); + +char* strchr (const char*, int); +char* strrchr (const char*, int); +char* strstr (const char*, const char*); +char* strdup (const char*); +size_t strlen (const char*); +size_t strnlen (const char*, size_t); +char* strndup (const char*, size_t); + +#define NONSTRING __attribute__ ((nonstring)) + +extern char ns5[5] NONSTRING; + +int strcmp_nonstring_1 (NONSTRING const char *a, const char *b) +{ + /* dg-warning matches one or more instances of the warning so it's + no good on its own. Use dg-regexp instead to verify that just + one instance of the warning is issued. See gcc.dg/pr64223-1 + for a different approach. */ + return strcmp (a, b); /* { dg-regexp "\[^\n\r\]+: warning: .strcmp. argument 1 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strcmp" } */ +} + +int strcmp_nonstring_2 (const char *a, NONSTRING const char *b) +{ + return strcmp (a, b); /* { dg-regexp "\[^\n\r\]+: warning: .strcmp. argument 2 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strcmp" } */ +} + +int strncmp_nonstring_1 (const char *s) +{ + return strncmp (s, ns5, sizeof ns5 + 1); /* { dg-regexp "\[^\n\r\]+: warning: .strncmp. argument 2 declared attribute .nonstring. \[^\n\r\]+ \\\[-Wstringop-overread\[^\n\r\]*" "strncmp" } */ +} + +int strncmp_nonstring_2 (const char *s) +{ + return strncmp (ns5, s, sizeof ns5 + 1); /* { dg-regexp "\[^\n\r\]+: warning: .strncmp. argument 1 declared attribute .nonstring. \[^\n\r\]+ \\\[-Wstringop-overread\[^\n\r\]*" "strncmp" } */ +} + +char* stpcpy_nonstring (char *d, NONSTRING const char *s) +{ + return stpcpy (d, s); /* { dg-regexp "\[^\n\r\]+: warning: .stpcpy. argument 2 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "stpcpy" } */ +} + +char* stpncpy_nonstring (char *d) +{ + return stpncpy (d, ns5, sizeof ns5 + 1); /* { dg-regexp "\[^\n\r\]+: warning: .stpncpy. argument 2 declared attribute .nonstring. \[^\n\r\]+ \\\[-Wstringop-overread\[^\n\r\]*" "stpncpy" } */ +} + +char* strchr_nonstring (NONSTRING const char *s, int c) +{ + return strchr (s, c); /* { dg-regexp "\[^\n\r\]+: warning: .strchr. argument 1 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strchr" } */ +} + +char* strrchr_nonstring (NONSTRING const char *s, int c) +{ + return strrchr (s, c); /* { dg-regexp "\[^\n\r\]+: warning: .strrchr. argument 1 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strrchr" } */ +} + +char* strcpy_nonstring (char *d, NONSTRING const char *s) +{ + return strcpy (d, s); /* { dg-regexp "\[^\n\r\]+: warning: .strcpy. argument 2 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strcpy" } */ +} + +char* strncpy_nonstring (char *d) +{ + return strncpy (d, ns5, sizeof ns5 + 1); /* { dg-regexp "\[^\n\r\]+: warning: .strncpy. argument 2 declared attribute .nonstring. \[^\n\r\]+ \\\[-Wstringop-overread\[^\n\r\]*" "strncpy" } */ +} + +char* strstr_nonstring_1 (NONSTRING const char *a, const char *b) +{ + return strstr (a, b); /* { dg-regexp "\[^\n\r\]+: warning: .strstr. argument 1 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strstr" } */ +} + +char* strstr_nonstring_2 (const char *a, NONSTRING const char *b) +{ + return strstr (a, b); /* { dg-regexp "\[^\n\r\]+: warning: .strstr. argument 2 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strstr" } */ +} + +char* stdup_nonstring (NONSTRING const char *s) +{ + return strdup (s); /* { dg-regexp "\[^\n\r\]+: warning: .strdup. argument 1 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strdup" } */ +} + +size_t strlen_nonstring (NONSTRING const char *s) +{ + return strlen (s); /* { dg-regexp "\[^\n\r\]+: warning: .strlen. argument 1 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "strlen" } */ +} + +int printf_nonstring (NONSTRING const char *s) +{ + return printf (s); /* { dg-regexp "\[^\n\r\]+: warning: .printf. argument 1 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "printf" } */ +} + +int sprintf_nonstring_2 (char *d, NONSTRING const char *s) +{ + return sprintf (d, s); /* { dg-regexp "\[^\n\r\]+: warning: .sprintf. argument 2 declared attribute .nonstring. \\\[-Wstringop-overread\[^\n\r\]*" "sprintf" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-noreturn.c b/SingleSource/Regression/C/gcc-dg/attr-noreturn.c new file mode 100644 index 0000000000..8d58f6ece9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-noreturn.c @@ -0,0 +1,64 @@ +/* Verify that attribute noreturn on global and local function declarations + is merged. + { dg-do compile } + { dg-options "-Wall -fdump-tree-optimized" } */ + +void foo (void); + +int fnr_local_local (void) +{ + __attribute__ ((noreturn)) void fnr1 (void); + + fnr1 (); + + foo (); +} + +int gnr_local_local (void) +{ + void fnr1 (void); + + fnr1 (); + + foo (); +} + + +int fnr_local_global (void) +{ + __attribute__ ((noreturn)) void fnr2 (void); + + fnr2 (); + + foo (); +} + +void fnr2 (void); + +int gnr_local_global (void) +{ + fnr2 (); + + foo (); +} + + +__attribute__ ((noreturn)) void fnr3 (void); + +int fnr_global_local (void) +{ + fnr3 (); + + foo (); +} + +int gnr_global_local (void) +{ + void fnr3 (void); + + fnr3 (); + + foo (); +} + +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-returns-nonnull.c b/SingleSource/Regression/C/gcc-dg/attr-returns-nonnull.c new file mode 100644 index 0000000000..d7f39be221 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-returns-nonnull.c @@ -0,0 +1,59 @@ +/* Verify that attribute returns_nonnull on global and local function + declarations is merged. + { dg-do compile } + { dg-options "-Wall -fdump-tree-optimized -fdelete-null-pointer-checks" } + { dg-skip-if "" keeps_null_pointer_checks } */ + +void foo (void); + + +void frnn_local_local (void) +{ + __attribute__ ((returns_nonnull)) void* frnn1 (void); + + if (!frnn1 ()) + foo (); +} + +void gnr_local_local (void) +{ + void* frnn1 (void); + + if (!frnn1 ()) + foo (); +} + +void frnn_local_global (void) +{ + __attribute__ ((returns_nonnull)) void* frnn2 (void); + + if (!frnn2 ()) + foo (); +} + +void* frnn2 (void); + +void gnr_local_global (void) +{ + if (!frnn2 ()) + foo (); +} + +__attribute__ ((returns_nonnull)) void* frnn3 (void); + +void frnn_global_local (void) +{ + if (!frnn3 ()) + foo (); +} + +void gnr_global_local (void) +{ + void* frnn3 (void); + + if (!frnn3 ()) + foo (); +} + + +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-section.c b/SingleSource/Regression/C/gcc-dg/attr-section.c new file mode 100644 index 0000000000..0062b544c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-section.c @@ -0,0 +1,13 @@ +/* PR c/96126 - conflicting attribute section accepted on redeclaration + { dg-do compile } + { dg-options "-Wall" } + { dg-require-named-sections "" } */ + +__attribute__ ((section ("s1"))) void f1 (void); +__attribute__ ((section ("s2"))) void f1 (void); // { dg-warning "ignoring attribute 'section \\\(\"s2\"\\\)' because it conflicts with previous 'section \\\(\"s1\"\\\)'" } + +__attribute__ ((section ("s3"), section ("s4"))) +void f2 (void); // { dg-error "conflicts" } + +__attribute__ ((section ("s5"))) __attribute ((section ("s6"))) +void f3 (void); // { dg-error "conflicts" } diff --git a/SingleSource/Regression/C/gcc-dg/attr-unavailable-1.c b/SingleSource/Regression/C/gcc-dg/attr-unavailable-1.c new file mode 100644 index 0000000000..768214fcd3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-unavailable-1.c @@ -0,0 +1,88 @@ +/* Test __attribute__ ((unavailable)) */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int INT1 __attribute__((unavailable)); +typedef INT1 INT2 __attribute__ ((__unavailable__)); + +typedef INT1 INT1a; /* { dg-error "'INT1' is unavailable" "" } */ +typedef INT1 INT1b __attribute__ ((unavailable)); + +INT1 should_be_unavailable; /* { dg-error "'INT1' is unavailable" "" } */ +INT1a should_not_be_unavailable; + +INT1 f1(void) __attribute__ ((unavailable)); +INT1 f2(void) { return 0; } /* { dg-error "'INT1' is unavailable" "" } */ + +INT2 f3(void) __attribute__ ((__unavailable__)); +INT2 f4(void) { return 0; } /* { dg-error "'INT2' is unavailable" "" } */ +int f5(INT2 x); /* { dg-error "'INT2' is unavailable" "" } */ +int f6(INT2 x) __attribute__ ((__unavailable__)); /* { dg-error "'INT2' is unavailable" "" } */ + +typedef enum {red, green, blue} Color __attribute__((unavailable)); + +int g1; +int g2 __attribute__ ((unavailable)); +int g3 __attribute__ ((__unavailable__)); +Color k; /* { dg-error "'Color' is unavailable" "" } */ + +typedef struct { + int field1; + int field2 __attribute__ ((unavailable)); + int field3; + int field4 __attribute__ ((__unavailable__)); + union { + int field5; + int field6 __attribute__ ((unavailable)); + } u1; + int field7:1; + int field8:1 __attribute__ ((unavailable)); + union { + int field9; + int field10; + } u2 __attribute__ ((unavailable)); +} S1; + +int func1() +{ + INT1 w; /* { dg-error "'INT1' is unavailable" "" } */ + int x __attribute__ ((unavailable)); + int y __attribute__ ((__unavailable__)); + int z; + int (*pf)() = f1; /* { dg-error "'f1' is unavailable" "" } */ + + z = w + x + y + g1 + g2 + g3; /* { dg-error "'x' is unavailable" "" } */ + /* { dg-error "'y' is unavailable" "y" { target *-*-* } .-1 } */ + /* { dg-error "'g2' is unavailable" "g2" { target *-*-* } .-2 } */ + /* { dg-error "'g3' is unavailable" "g3" { target *-*-* } .-3 } */ + return f1(); /* { dg-error "'f1' is unavailable" "f1" } */ +} + +int func2(S1 *p) +{ + S1 lp; + + if (p->field1) + return p->field2; /* { dg-error "'field2' is unavailable" "" } */ + else if (lp.field4) /* { dg-error "'field4' is unavailable" "" } */ + return p->field3; + + p->u1.field5 = g1 + p->field7; + p->u2.field9; /* { dg-error "'u2' is unavailable" "" } */ + return p->u1.field6 + p->field8; /* { dg-error "'field6' is unavailable" "" } */ + /* { dg-error "'field8' is unavailable" "field8" { target *-*-* } .-1 } */ +} + +struct SS1 { + int x; + INT1 y; /* { dg-error "'INT1' is unavailable" "" } */ +} __attribute__ ((unavailable)); + +struct SS1 *p1; /* { dg-error "'SS1' is unavailable" "" } */ + +struct __attribute__ ((__unavailable__)) SS2 { + int x; + INT1 y; /* { dg-error "'INT1' is unavailable" "" } */ +}; + +struct SS2 *p2; /* { dg-error "'SS2' is unavailable" "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-unavailable-2.c b/SingleSource/Regression/C/gcc-dg/attr-unavailable-2.c new file mode 100644 index 0000000000..303f973d5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-unavailable-2.c @@ -0,0 +1,6 @@ +/* Test __attribute__((unavailable)). Test types without names. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a; } __attribute__((unavailable)) x; /* { dg-error "type is unavailable" } */ +typeof(x) y; /* { dg-error "type is unavailable" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-unavailable-3.c b/SingleSource/Regression/C/gcc-dg/attr-unavailable-3.c new file mode 100644 index 0000000000..7274c193f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-unavailable-3.c @@ -0,0 +1,10 @@ +/* Test __attribute__((unavailable)). */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void func(void); +void func(void) __attribute__((unavailable)); + +void f(void) { + func(); /* { dg-error "'func' is unavailable" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-unavailable-4.c b/SingleSource/Regression/C/gcc-dg/attr-unavailable-4.c new file mode 100644 index 0000000000..9e39c50fec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-unavailable-4.c @@ -0,0 +1,88 @@ +/* Test __attribute__ ((unavailable("message"))) */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int INT1 __attribute__((unavailable("You can't use INT1"))); +typedef INT1 INT2 __attribute__ ((__unavailable__("You can't use INT2"))); + +typedef INT1 INT1a; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */ +typedef INT1 INT1b __attribute__ ((unavailable("You can't use INT1b"))); + +INT1 should_be_unavailable; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */ +INT1a should_not_be_unavailable; + +INT1 f1(void) __attribute__ ((unavailable("You can't use f1"))); +INT1 f2(void) { return 0; } /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */ + +INT2 f3(void) __attribute__ ((__unavailable__("You can't use f3"))); +INT2 f4(void) { return 0; } /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */ +int f5(INT2 x); /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */ +int f6(INT2 x) __attribute__ ((__unavailable__("You can't use f6"))); /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */ + +typedef enum {red, green, blue} Color __attribute__((unavailable("You can't use Color"))); + +int g1; +int g2 __attribute__ ((unavailable("You can't use g2"))); +int g3 __attribute__ ((__unavailable__("You can't use g3"))); +Color k; /* { dg-error "'Color' is unavailable: You can't use Color" "" } */ + +typedef struct { + int field1; + int field2 __attribute__ ((unavailable("You can't use field2"))); + int field3; + int field4 __attribute__ ((__unavailable__("You can't use field4"))); + union { + int field5; + int field6 __attribute__ ((unavailable("You can't use field6"))); + } u1; + int field7:1; + int field8:1 __attribute__ ((unavailable("You can't use field8"))); + union { + int field9; + int field10; + } u2 __attribute__ ((unavailable("You can't use u2"))); +} S1; + +int func1() +{ + INT1 w; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */ + int x __attribute__ ((unavailable("Avoid x"))); + int y __attribute__ ((__unavailable__("Bad y"))); + int z; + int (*pf)() = f1; /* { dg-error "'f1' is unavailable: You can't use f1" "" } */ + + z = w + x + y + g1 + g2 + g3; /* { dg-error "'x' is unavailable: Avoid x" "" } */ + /* { dg-error "'y' is unavailable: Bad y" "y" { target *-*-* } .-1 } */ + /* { dg-error "'g2' is unavailable: You can't use g2" "g2" { target *-*-* } .-2 } */ + /* { dg-error "'g3' is unavailable: You can't use g3" "g3" { target *-*-* } .-3 } */ + return f1(); /* { dg-error "'f1' is unavailable: You can't use f1" "" } */ +} + +int func2(S1 *p) +{ + S1 lp; + + if (p->field1) + return p->field2; /* { dg-error "'field2' is unavailable: You can't use field2" "" } */ + else if (lp.field4) /* { dg-error "'field4' is unavailable: You can't use field4" "" } */ + return p->field3; + + p->u1.field5 = g1 + p->field7; + p->u2.field9; /* { dg-error "'u2' is unavailable: You can't use u2" "" } */ + return p->u1.field6 + p->field8; /* { dg-error "'field6' is unavailable: You can't use field6" "" } */ + /* { dg-error "'field8' is unavailable: You can't use field8" "field8" { target *-*-* } .-1 } */ +} + +struct SS1 { + int x; + INT1 y; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */ +} __attribute__ ((unavailable("You can't use SS1"))); + +struct SS1 *p1; /* { dg-error "'SS1' is unavailable: You can't use SS1" "" } */ + +struct __attribute__ ((__unavailable__("You can't use SS2"))) SS2 { + int x; + INT1 y; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */ +}; + +struct SS2 *p2; /* { dg-error "'SS2' is unavailable: You can't use SS2" "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-unavailable-5.c b/SingleSource/Regression/C/gcc-dg/attr-unavailable-5.c new file mode 100644 index 0000000000..051f960c5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-unavailable-5.c @@ -0,0 +1,6 @@ +/* Test __attribute__((unavailable)). Test types without names. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a; } __attribute__((unavailable ("Do not use"))) x; /* { dg-error "type is unavailable" } */ +typeof(x) y; /* { dg-error "type is unavailable: Do not use" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-unavailable-6.c b/SingleSource/Regression/C/gcc-dg/attr-unavailable-6.c new file mode 100644 index 0000000000..f5f4560c73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-unavailable-6.c @@ -0,0 +1,11 @@ +/* Test __attribute__((unavailable)). Test merging with multiple + declarations. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void func(void); +void func(void) __attribute__((unavailable ("Do not use"))); + +void f(void) { + func(); /* { dg-error "'func' is unavailable: Do not use" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-vector_size.c b/SingleSource/Regression/C/gcc-dg/attr-vector_size.c new file mode 100644 index 0000000000..9177e25250 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-vector_size.c @@ -0,0 +1,53 @@ +/* PR middle-end/89797 - ICE on a vector_size (1LU << 33) int variable + PR c/89798 - excessive vector_size silently accepted and truncated + { dg-do compile { target int32plus } } + { dg-options "-Wall -Wno-unused" } */ + +#define ASSERT(e) _Static_assert (e, #e) +#define VEC(N) __attribute__ ((vector_size (N))) +#define POW2(N) (1LLU << N) +#define CAT(a, b) a ## b +#define CONCAT(a, b) CAT (a, b) + +#define DEFVEC(storage, N) \ + typedef VEC (POW2 (N)) char CONCAT (Vec, N); \ + storage CONCAT (Vec, N) CONCAT (v, N); \ + ASSERT (sizeof (CONCAT (Vec, N)) == POW2 (N)); \ + ASSERT (sizeof (CONCAT (v, N)) == POW2 (N)) + +DEFVEC (extern, 27); +DEFVEC (extern, 28); +DEFVEC (extern, 29); +DEFVEC (extern, 30); + +#if __SIZEOF_SIZE_T__ > 4 + +VEC (POW2 (63)) char v63; /* { dg-error "'vector_size' attribute argument value '9223372036854775808' exceeds 9223372036854775807" "not-ILP32" { target { ! ilp32 } } } */ + +#else + +VEC (POW2 (31)) char v31; /* { dg-error "'vector_size' attribute argument value '2147483648' exceeds 2147483647" "ILP32" { target ilp32 } } */ + +VEC (POW2 (32)) char v32; /* { dg-error "'vector_size' attribute argument value '4294967296' exceeds 2147483647" "ILP32" { target ilp32 } } */ + +#endif + +void test_local_scope (void) +{ + DEFVEC (auto, 27); + DEFVEC (auto, 28); + DEFVEC (auto, 29); + DEFVEC (auto, 30); + +#if __SIZEOF_SIZE_T__ > 4 + + VEC (POW2 (63)) char v63; /* { dg-error "'vector_size' attribute argument value '9223372036854775808' exceeds 9223372036854775807" "not-ILP32" { target { ! ilp32 } } } */ + +#else + + VEC (POW2 (31)) char v31; /* { dg-error "'vector_size' attribute argument value '2147483648' exceeds 2147483647" "ILP32" { target ilp32 } } */ + + VEC (POW2 (32)) char v32; /* { dg-error "'vector_size' attribute argument value '4294967296' exceeds 2147483647" "ILP32" { target ilp32 } } */ + +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-weak-1.c b/SingleSource/Regression/C/gcc-dg/attr-weak-1.c new file mode 100644 index 0000000000..65041291b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weak-1.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ + +__inline void foo(void) __attribute__((weak)); /* { dg-warning "inline.*weak" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/attr-weak-hidden-1.c b/SingleSource/Regression/C/gcc-dg/attr-weak-hidden-1.c new file mode 100644 index 0000000000..b8d75d9c7c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weak-hidden-1.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-require-weak "" } */ +/* { dg-require-visibility "" } */ +/* { dg-options "-O2" } */ +/* { dg-additional-sources "attr-weak-hidden-1a.c" } */ +int __attribute__((visibility("hidden"))) foo (void) { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/attr-weak-hidden-1a.c b/SingleSource/Regression/C/gcc-dg/attr-weak-hidden-1a.c new file mode 100644 index 0000000000..f6d3e9eae4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weak-hidden-1a.c @@ -0,0 +1,11 @@ +/* { dg-require-weak "" } */ +/* { dg-require-visibility "" } */ +void abort (void); +int __attribute__((weak, visibility("hidden"))) foo (void) { return 1; } +int +main (void) +{ + if (foo ()) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-weakref-1-darwin.c b/SingleSource/Regression/C/gcc-dg/attr-weakref-1-darwin.c new file mode 100644 index 0000000000..c6835ed7ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weakref-1-darwin.c @@ -0,0 +1,223 @@ +// { dg-do run { target { *-*-darwin* } } } +// { dg-require-weak "" } +// { dg-options "-O2" } +// { dg-options "-O2 -mmacosx-version-min=10.2" { target { powerpc-*-darwin* } } } +// { dg-additional-sources "attr-weakref-1a.c attr-weakref-1b.c" } + +// Copyright 2005 Free Software Foundation, Inc. +// Contributed by Alexandre Oliva + +// Torture test for weakrefs. The first letter of an identifier +// indicates whether/how it is defined; the second letter indicates +// whether it is part of a variable or function test; the number that +// follows is a test counter, and a letter that may follow enables +// multiple identifiers within the same test (e.g., multiple weakrefs +// or pointers to the same identifier). + +// Identifiers starting with W are weakrefs; those with p are +// pointers; those with g are global definitions; those with l are +// local definitions; those with w are expected to be weak undefined +// in the symbol table; those with u are expected to be marked as +// non-weak undefined in the symbol table. + +#include + +#define USED __attribute__((used)) + +typedef int vtype; + +extern vtype wv1; +static vtype Wv1a __attribute__((weakref ("wv1"))); +static vtype *pv1a USED = &Wv1a; + +vtype gv2; +static vtype Wv2a __attribute__((weakref ("gv2"))); +static vtype *pv2a USED = &Wv2a; + +static vtype lv3; +static vtype Wv3a __attribute__((weakref ("lv3"))); +static vtype *pv3a USED = &Wv3a; + +extern vtype uv4; +static vtype Wv4a __attribute__((weakref ("uv4"))); +static vtype *pv4a USED = &Wv4a; +static vtype *pv4 USED = &uv4; + +static vtype Wv5a __attribute__((weakref ("uv5"))); +static vtype *pv5a USED = &Wv5a; +extern vtype uv5; +static vtype *pv5 USED = &uv5; + +static vtype Wv6a __attribute__((weakref ("wv6"))); +static vtype *pv6a USED = &Wv6a; +extern vtype wv6; + +static vtype Wv7a __attribute__((weakref ("uv7"))); +static vtype* USED fv7 (void) { + return &Wv7a; +} +extern vtype uv7; +static vtype* USED fv7a (void) { + return &uv7; +} + +extern vtype uv8; +static vtype* USED fv8a (void) { + return &uv8; +} +static vtype Wv8a __attribute__((weakref ("uv8"))); +static vtype* USED fv8 (void) { + return &Wv8a; +} + +extern vtype wv9 __attribute__((weak)); +static vtype Wv9a __attribute__((weakref ("wv9"))); +static vtype *pv9a USED = &Wv9a; + +static vtype Wv10a __attribute__((weakref ("Wv10b"))); +static vtype Wv10b __attribute__((weakref ("Wv10c"))); +static vtype Wv10c __attribute__((weakref ("Wv10d"))); +static vtype Wv10d __attribute__((weakref ("wv10"))); +extern vtype wv10; + +extern vtype wv11; +static vtype Wv11d __attribute__((weakref ("wv11"))); +static vtype Wv11c __attribute__((weakref ("Wv11d"))); +static vtype Wv11b __attribute__((weakref ("Wv11c"))); +static vtype Wv11a __attribute__((weakref ("Wv11b"))); + +static vtype Wv12 __attribute__((weakref ("wv12"))); +extern vtype wv12 __attribute__((weak)); + +static vtype Wv13 __attribute__((weakref ("wv13"))); +extern vtype wv13 __attribute__((weak)); + +static vtype Wv14a __attribute__((weakref ("wv14"))); +static vtype Wv14b __attribute__((weakref ("wv14"))); +extern vtype wv14 __attribute__((weak)); + +typedef void ftype(void); + +extern ftype wf1; +static ftype Wf1a __attribute__((weakref ("wf1"))); +static ftype *pf1a USED = &Wf1a; +static ftype Wf1c __attribute__((weakref)); +extern ftype Wf1c __attribute__((alias ("wf1"))); +static ftype *pf1c USED = &Wf1c; + +void gf2(void) {} +static ftype Wf2a __attribute__((weakref ("gf2"))); +static ftype *pf2a USED = &Wf2a; + +static void lf3(void) {} +static ftype Wf3a __attribute__((weakref ("lf3"))); +static ftype *pf3a USED = &Wf3a; + +extern ftype uf4; +static ftype Wf4a __attribute__((weakref ("uf4"))); +static ftype *pf4a USED = &Wf4a; +static ftype *pf4 USED = &uf4; + +static ftype Wf5a __attribute__((weakref ("uf5"))); +static ftype *pf5a USED = &Wf5a; +extern ftype uf5; +static ftype *pf5 USED = &uf5; + +static ftype Wf6a __attribute__((weakref ("wf6"))); +static ftype *pf6a USED = &Wf6a; +extern ftype wf6; + +static ftype Wf7a __attribute__((weakref ("uf7"))); +static ftype* USED ff7 (void) { + return &Wf7a; +} +extern ftype uf7; +static ftype* USED ff7a (void) { + return &uf7; +} + +extern ftype uf8; +static ftype* USED ff8a (void) { + return &uf8; +} +static ftype Wf8a __attribute__((weakref ("uf8"))); +static ftype* USED ff8 (void) { + return &Wf8a; +} + +extern ftype wf9 __attribute__((weak)); +static ftype Wf9a __attribute__((weakref ("wf9"))); +static ftype *pf9a USED = &Wf9a; + +static ftype Wf10a __attribute__((weakref ("Wf10b"))); +static ftype Wf10b __attribute__((weakref ("Wf10c"))); +static ftype Wf10c __attribute__((weakref ("Wf10d"))); +static ftype Wf10d __attribute__((weakref ("wf10"))); +extern ftype wf10; + +extern ftype wf11; +static ftype Wf11d __attribute__((weakref ("wf11"))); +static ftype Wf11c __attribute__((weakref ("Wf11d"))); +static ftype Wf11b __attribute__((weakref ("Wf11c"))); +static ftype Wf11a __attribute__((weakref ("Wf11b"))); + +static ftype Wf12 __attribute__((weakref ("wf12"))); +extern ftype wf12 __attribute__((weak)); + +static ftype Wf13 __attribute__((weakref ("wf13"))); +extern ftype wf13 __attribute__((weak)); + +static ftype Wf14a __attribute__((weakref ("wf14"))); +static ftype Wf14b __attribute__((weakref ("wf14"))); +extern ftype wf14 __attribute__((weak)); + +#ifndef __APPLE__ +#define chk(p) do { if (!p) abort (); } while (0) +#else +#define chk(p) /* */ +#endif + +int main () { + chk (!pv1a); + chk (pv2a); + chk (pv3a); + chk (pv4a); + chk (pv4); + chk (pv5a); + chk (pv5); + chk (!pv6a); + chk (fv7 ()); + chk (fv7a ()); + chk (fv8 ()); + chk (fv8a ()); + chk (!pv9a); + chk (!&Wv10a); + chk (!&Wv11a); + chk (!&Wv12); + chk (!&wv12); + chk (!&wv13); + chk (!&Wv14a); + + chk (!pf1a); + chk (!pf1c); + chk (pf2a); + chk (pf3a); + chk (pf4a); + chk (pf4); + chk (pf5a); + chk (pf5); + chk (!pf6a); + chk (ff7 ()); + chk (ff7a ()); + chk (ff8 ()); + chk (ff8a ()); + chk (!pf9a); + chk (!&Wf10a); + chk (!&Wf11a); + chk (!&Wf12); + chk (!&wf12); + chk (!&wf13); + chk (!&Wf14a); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-weakref-1.c b/SingleSource/Regression/C/gcc-dg/attr-weakref-1.c new file mode 100644 index 0000000000..9e14b605be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weakref-1.c @@ -0,0 +1,235 @@ +// { dg-do run } +// { dg-require-weak "" } +// On darwin, we use attr-weakref-1-darwin.c. + +// This test requires support for undefined weak symbols. This support +// is not available on the following targets. The test is skipped rather than +// xfailed to suppress the warning that would otherwise arise. +// { dg-skip-if "" { "hppa*-*-hpux*" "*-*-aix*" "nvptx-*-*" } } + +// For kernel modules and static RTPs, the loader treats undefined weak +// symbols in the same way as undefined strong symbols. The test +// therefore fails to load, so skip it. +// { dg-skip-if "" { "*-*-vxworks*" && nonpic } "*" { "-non-static" } } +// { dg-options "-O2" } +// { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } +// { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } +// { dg-additional-sources "attr-weakref-1a.c" } + +// Copyright 2005 Free Software Foundation, Inc. +// Contributed by Alexandre Oliva + +// Torture test for weakrefs. The first letter of an identifier +// indicates whether/how it is defined; the second letter indicates +// whether it is part of a variable or function test; the number that +// follows is a test counter, and a letter that may follow enables +// multiple identifiers within the same test (e.g., multiple weakrefs +// or pointers to the same identifier). + +// Identifiers starting with W are weakrefs; those with p are +// pointers; those with g are global definitions; those with l are +// local definitions; those with w are expected to be weak undefined +// in the symbol table; those with u are expected to be marked as +// non-weak undefined in the symbol table. + +#include + +#define USED __attribute__((used)) + +typedef int vtype; + +extern vtype wv1; +static vtype Wv1a __attribute__((weakref ("wv1"))); +static vtype *pv1a USED = &Wv1a; + +vtype gv2; +static vtype Wv2a __attribute__((weakref ("gv2"))); +static vtype *pv2a USED = &Wv2a; + +static vtype lv3; +static vtype Wv3a __attribute__((weakref ("lv3"))); +static vtype *pv3a USED = &Wv3a; + +extern vtype uv4; +static vtype Wv4a __attribute__((weakref ("uv4"))); +static vtype *pv4a USED = &Wv4a; +static vtype *pv4 USED = &uv4; + +static vtype Wv5a __attribute__((weakref ("uv5"))); +static vtype *pv5a USED = &Wv5a; +extern vtype uv5; +static vtype *pv5 USED = &uv5; + +static vtype Wv6a __attribute__((weakref ("wv6"))); +static vtype *pv6a USED = &Wv6a; +extern vtype wv6; + +static vtype Wv7a __attribute__((weakref ("uv7"))); +static vtype* USED fv7 (void) { + return &Wv7a; +} +extern vtype uv7; +static vtype* USED fv7a (void) { + return &uv7; +} + +extern vtype uv8; +static vtype* USED fv8a (void) { + return &uv8; +} +static vtype Wv8a __attribute__((weakref ("uv8"))); +static vtype* USED fv8 (void) { + return &Wv8a; +} + +extern vtype wv9 __attribute__((weak)); +static vtype Wv9a __attribute__((weakref ("wv9"))); +static vtype *pv9a USED = &Wv9a; + +static vtype Wv10a __attribute__((weakref ("Wv10b"))); +static vtype Wv10b __attribute__((weakref ("Wv10c"))); +static vtype Wv10c __attribute__((weakref ("Wv10d"))); +static vtype Wv10d __attribute__((weakref ("wv10"))); +extern vtype wv10; + +extern vtype wv11; +static vtype Wv11d __attribute__((weakref ("wv11"))); +static vtype Wv11c __attribute__((weakref ("Wv11d"))); +static vtype Wv11b __attribute__((weakref ("Wv11c"))); +static vtype Wv11a __attribute__((weakref ("Wv11b"))); + +static vtype Wv12 __attribute__((weakref ("wv12"))); +extern vtype wv12 __attribute__((weak)); + +static vtype Wv13 __attribute__((weakref ("wv13"))); +extern vtype wv13 __attribute__((weak)); + +static vtype Wv14a __attribute__((weakref ("wv14"))); +static vtype Wv14b __attribute__((weakref ("wv14"))); +extern vtype wv14 __attribute__((weak)); + +typedef void ftype(void); + +extern ftype wf1; +static ftype Wf1a __attribute__((weakref ("wf1"))); +static ftype *pf1a USED = &Wf1a; +static ftype Wf1c __attribute__((weakref)); +extern ftype Wf1c __attribute__((alias ("wf1"))); +static ftype *pf1c USED = &Wf1c; + +void gf2(void) {} +static ftype Wf2a __attribute__((weakref ("gf2"))); +static ftype *pf2a USED = &Wf2a; + +static void lf3(void) {} +static ftype Wf3a __attribute__((weakref ("lf3"))); +static ftype *pf3a USED = &Wf3a; + +extern ftype uf4; +static ftype Wf4a __attribute__((weakref ("uf4"))); +static ftype *pf4a USED = &Wf4a; +static ftype *pf4 USED = &uf4; + +static ftype Wf5a __attribute__((weakref ("uf5"))); +static ftype *pf5a USED = &Wf5a; +extern ftype uf5; +static ftype *pf5 USED = &uf5; + +static ftype Wf6a __attribute__((weakref ("wf6"))); +static ftype *pf6a USED = &Wf6a; +extern ftype wf6; + +static ftype Wf7a __attribute__((weakref ("uf7"))); +static ftype* USED ff7 (void) { + return &Wf7a; +} +extern ftype uf7; +static ftype* USED ff7a (void) { + return &uf7; +} + +extern ftype uf8; +static ftype* USED ff8a (void) { + return &uf8; +} +static ftype Wf8a __attribute__((weakref ("uf8"))); +static ftype* USED ff8 (void) { + return &Wf8a; +} + +extern ftype wf9 __attribute__((weak)); +static ftype Wf9a __attribute__((weakref ("wf9"))); +static ftype *pf9a USED = &Wf9a; + +static ftype Wf10a __attribute__((weakref ("Wf10b"))); +static ftype Wf10b __attribute__((weakref ("Wf10c"))); +static ftype Wf10c __attribute__((weakref ("Wf10d"))); +static ftype Wf10d __attribute__((weakref ("wf10"))); +extern ftype wf10; + +extern ftype wf11; +static ftype Wf11d __attribute__((weakref ("wf11"))); +static ftype Wf11c __attribute__((weakref ("Wf11d"))); +static ftype Wf11b __attribute__((weakref ("Wf11c"))); +static ftype Wf11a __attribute__((weakref ("Wf11b"))); + +static ftype Wf12 __attribute__((weakref ("wf12"))); +extern ftype wf12 __attribute__((weak)); + +static ftype Wf13 __attribute__((weakref ("wf13"))); +extern ftype wf13 __attribute__((weak)); + +static ftype Wf14a __attribute__((weakref ("wf14"))); +static ftype Wf14b __attribute__((weakref ("wf14"))); +extern ftype wf14 __attribute__((weak)); + +#ifndef __APPLE__ +#define chk(p) do { if (!p) abort (); } while (0) +#else +#define chk(p) /* */ +#endif + +int main () { + chk (!pv1a); + chk (pv2a); + chk (pv3a); + chk (pv4a); + chk (pv4); + chk (pv5a); + chk (pv5); + chk (!pv6a); + chk (fv7 ()); + chk (fv7a ()); + chk (fv8 ()); + chk (fv8a ()); + chk (!pv9a); + chk (!&Wv10a); + chk (!&Wv11a); + chk (!&Wv12); + chk (!&wv12); + chk (!&wv13); + chk (!&Wv14a); + + chk (!pf1a); + chk (!pf1c); + chk (pf2a); + chk (pf3a); + chk (pf4a); + chk (pf4); + chk (pf5a); + chk (pf5); + chk (!pf6a); + chk (ff7 ()); + chk (ff7a ()); + chk (ff8 ()); + chk (ff8a ()); + chk (!pf9a); + chk (!&Wf10a); + chk (!&Wf11a); + chk (!&Wf12); + chk (!&wf12); + chk (!&wf13); + chk (!&Wf14a); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/attr-weakref-1a.c b/SingleSource/Regression/C/gcc-dg/attr-weakref-1a.c new file mode 100644 index 0000000000..5ce1e4e72d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weakref-1a.c @@ -0,0 +1,8 @@ +int uv4; +int uv5; +int uv7; +int uv8; +void uf4 (void) {} +void uf5 (void) {} +void uf7 (void) {} +void uf8 (void) {} diff --git a/SingleSource/Regression/C/gcc-dg/attr-weakref-1b.c b/SingleSource/Regression/C/gcc-dg/attr-weakref-1b.c new file mode 100644 index 0000000000..c2c43898c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weakref-1b.c @@ -0,0 +1,20 @@ +/* On Darwin, you have to have a definition of the function to link, + even if later on it won't be present in some dylib. (That is, + you have to link with the latest version of the dylib.) */ +void wf1(void) { } +void wf6(void) { } +void wf9(void) { } +void wf10(void) { } +void wf11(void) { } +void wf12(void) { } +void wf13(void) { } +void wf14(void) { } + +int wv1; +int wv6; +int wv9; +int wv10; +int wv11; +int wv12; +int wv13; +int wv14; diff --git a/SingleSource/Regression/C/gcc-dg/attr-weakref-2.c b/SingleSource/Regression/C/gcc-dg/attr-weakref-2.c new file mode 100644 index 0000000000..172a4a63e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weakref-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ + +typedef int vtype; + +extern vtype wv1; +extern vtype Wv1a __attribute__((weakref ("wv1"))); /* { dg-error "'weakref' symbol 'Wv1a' must have static linkage" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-weakref-3.c b/SingleSource/Regression/C/gcc-dg/attr-weakref-3.c new file mode 100644 index 0000000000..fe4462a8a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weakref-3.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ +static int i __attribute__ ((weakref)); /* { dg-warning "attribute should be accompanied" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-weakref-4.c b/SingleSource/Regression/C/gcc-dg/attr-weakref-4.c new file mode 100644 index 0000000000..df5fdebdc4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weakref-4.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ +static void __attribute__((weakref("bar"))) foo(void) { } /* { dg-warning "attribute ignored because function is defined" } */ +static int __attribute__((weakref)) a=0; /* { dg-warning "attribute ignored because variable is initialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/attr-weakref-5.c b/SingleSource/Regression/C/gcc-dg/attr-weakref-5.c new file mode 100644 index 0000000000..e2f0406823 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/attr-weakref-5.c @@ -0,0 +1,31 @@ +/* PR middle-end/92799 - ICE on a weakref function definition followed + by a declaration + { dg-do compile } + { dg-options "-Wall" } */ + +static __attribute__ ((weakref ("bar"))) void f0 (void) { } // { dg-warning "'weakref' attribute ignored because function is defined" } + +extern void f0 (void); + +void* use_f0 (void) { return f0; } + + +static __attribute__ ((weakref ("bar"))) void f1 (void) { } // { dg-warning "'weakref' attribute ignored because function is defined" } + +static void f1 (void); + +void* use_f1 (void) { return f1; } + + +static __attribute__ ((weakref ("bar"))) void f2 (void); + +static void f2 (void) { } // { dg-error "redefinition" } + +void* use_f2 (void) { return f2; } + + +static __attribute__ ((weakref ("bar"))) void f3 (void); + +void f3 (void) { } // { dg-error "redefinition" } + +void* use_f3 (void) { return f3; } diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-hardreg-1.c b/SingleSource/Regression/C/gcc-dg/auto-init-hardreg-1.c new file mode 100644 index 0000000000..7c9de99bf0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-hardreg-1.c @@ -0,0 +1,9 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-ftrivial-auto-var-init=zero" } */ + +int +main () +{ + register long *sp __asm__("sp"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-1.c b/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-1.c new file mode 100644 index 0000000000..d574926e0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-1.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -ftrivial-auto-var-init=zero" } */ + +int g(int *); +int f() +{ + switch (0) { + int x; /* { dg-bogus "statement will never be executed" } */ + default: + return g(&x); + } +} + +int g1(int); +int f1() +{ + switch (0) { + int x; /* { dg-bogus "statement will never be executed" } */ + default: + return g1(x); /* { dg-warning "is used uninitialized" } */ + } +} + +struct S +{ + char a; + int b; +}; +int g2(int); +int f2(int input) +{ + switch (0) { + struct S x; /* { dg-bogus "statement will never be executed" } */ + default: + return g2(input) + x.b; /* { dg-warning "is used uninitialized" } */ + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-2.c b/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-2.c new file mode 100644 index 0000000000..779d3ec388 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-2.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -ftrivial-auto-var-init=pattern" } */ + +int g(int *); +int f() +{ + switch (0) { + int x; /* { dg-bogus "statement will never be executed" } */ + default: + return g(&x); + } +} + +int g1(int); +int f1() +{ + switch (0) { + int x; /* { dg-bogus "statement will never be executed" } */ + default: + return g1(x); /* { dg-warning "is used uninitialized" } */ + } +} + +struct S +{ + char a; + int b; +}; +int g2(int); +int f2(int input) +{ + switch (0) { + struct S x; /* { dg-bogus "statement will never be executed" } */ + default: + return g2(input) + x.b; /* { dg-warning "is used uninitialized" } */ + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-3.c b/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-3.c new file mode 100644 index 0000000000..f113f46e29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-3.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wtrivial-auto-var-init -ftrivial-auto-var-init=zero" } */ + +int g(int *, int *); +int f() +{ + switch (0) { + int x; /* { dg-warning "cannot be initialized with" } */ + int y; /* { dg-warning "cannot be initialized with" } */ + default: + return g(&x, &y); + } +} + +int g1(int, int); +int f1() +{ + switch (0) { + int x; /* { dg-warning "cannot be initialized with" } */ + int y; /* { dg-warning "cannot be initialized with" } */ + default: + return g1(x, y); + } +} + +struct S +{ + char a; + int b; +}; +int g2(int); +int f2(int input) +{ + switch (0) { + struct S x; /* { dg-warning "cannot be initialized with" } */ + struct S y; /* { dg-warning "cannot be initialized with" } */ + default: + return g2(input) + x.b + y.b; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-4.c b/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-4.c new file mode 100644 index 0000000000..662e0d1182 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-pr102276-4.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wtrivial-auto-var-init -ftrivial-auto-var-init=pattern" } */ + +int g(int *, int *); +int f() +{ + switch (0) { + int x; /* { dg-warning "cannot be initialized with" } */ + int y; /* { dg-warning "cannot be initialized with" } */ + default: + return g(&x, &y); + } +} + +int g1(int, int); +int f1() +{ + switch (0) { + int x; /* { dg-warning "cannot be initialized with" } */ + int y; /* { dg-warning "cannot be initialized with" } */ + default: + return g1(x, y); + } +} + +struct S +{ + char a; + int b; +}; +int g2(int); +int f2(int input) +{ + switch (0) { + struct S x; /* { dg-warning "cannot be initialized with" } */ + struct S y; /* { dg-warning "cannot be initialized with" } */ + default: + return g2(input) + x.b + y.b; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-1.c b/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-1.c new file mode 100644 index 0000000000..a08110c3a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-1.c @@ -0,0 +1,10 @@ +/* PR 104550*/ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=pattern" } */ +struct vx_audio_level { + int has_monitor_level : 1; +}; + +void vx_set_monitor_level() { + struct vx_audio_level info; /* { dg-bogus "info" "is used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-2.c b/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-2.c new file mode 100644 index 0000000000..2c395b32d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-2.c @@ -0,0 +1,11 @@ +/* PR 104550 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +struct vx_audio_level { + int has_monitor_level : 1; +}; + +void vx_set_monitor_level() { + struct vx_audio_level info; + __builtin_clear_padding (&info); /* { dg-bogus "info" "is used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-3.c b/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-3.c new file mode 100644 index 0000000000..9893e37f12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-pr104550-3.c @@ -0,0 +1,11 @@ +/* PR 104550 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=pattern" } */ +struct vx_audio_level { + int has_monitor_level : 1; +}; + +void vx_set_monitor_level() { + struct vx_audio_level info; /* { dg-bogus "info" "is used uninitialized" } */ + __builtin_clear_padding (&info); /* { dg-bogus "info" "is used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-sra-1.c b/SingleSource/Regression/C/gcc-dg/auto-init-sra-1.c new file mode 100644 index 0000000000..88fd66678f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-sra-1.c @@ -0,0 +1,24 @@ +/* Verify that SRA total scalarization will not be confused by padding + and also not confused by auto initialization. */ +/* { dg-do compile } */ +/* { dg-options "-O1 --param sra-max-scalarization-size-Ospeed=16 -fdump-tree-release_ssa -ftrivial-auto-var-init=zero" } */ + +struct S +{ + int i; + unsigned short f1; + char f2; + unsigned short f3, f4; +}; + + +int foo (struct S *p) +{ + struct S l; + + l = *p; + l.i++; + *p = l; +} + +/* { dg-final { scan-tree-dump-times "l;" 0 "release_ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-sra-2.c b/SingleSource/Regression/C/gcc-dg/auto-init-sra-2.c new file mode 100644 index 0000000000..d260f5ae93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-sra-2.c @@ -0,0 +1,24 @@ +/* Verify that SRA total scalarization will not be confused by padding + and also not confused by auto initialization. */ +/* { dg-do compile } */ +/* { dg-options "-O1 --param sra-max-scalarization-size-Ospeed=16 -fdump-tree-release_ssa -ftrivial-auto-var-init=pattern" } */ + +struct S +{ + int i; + unsigned short f1; + char f2; + unsigned short f3, f4; +}; + + +int foo (struct S *p) +{ + struct S l; + + l = *p; + l.i++; + *p = l; +} + +/* { dg-final { scan-tree-dump-times "l;" 0 "release_ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-1.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-1.c new file mode 100644 index 0000000000..502db59122 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-1.c @@ -0,0 +1,5 @@ +/* Spurious uninitialized variable warnings, case 1. + Taken from cppfiles.c (merge_include_chains) */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-12.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-12.c new file mode 100644 index 0000000000..65da110f55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-12.c @@ -0,0 +1,4 @@ +/* PR 23497 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-12.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-13.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-13.c new file mode 100644 index 0000000000..87dd8b587e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-13.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ + +typedef _Complex float C; +C foo() +{ + C f; + __imag__ f = 0; + return f; /* { dg-warning "is used" "unconditional" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-14.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-14.c new file mode 100644 index 0000000000..9ffe00a67e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-14.c @@ -0,0 +1,4 @@ +/* PR 24931 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-14.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-15.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-15.c new file mode 100644 index 0000000000..121f0cff27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-15.c @@ -0,0 +1,26 @@ +/* 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. (not xfailed alternative) + But it is of course ok if we warn in bar about uninitialized use + of j. (not xfailed alternative) */ +/* { dg-do compile } */ +/* { dg-options "-O1 -Wuninitialized -ftrivial-auto-var-init=zero" } */ + +inline int +foo (int i) +{ + if (i) /* { dg-warning "used uninitialized" } */ + return 1; + return 0; +} + +void baz (void); + +void +bar (void) +{ + int j; /* { dg-message "note: 'j' was declared here" "" } */ + for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" "" { xfail *-*-* } } */ + baz (); +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-16.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-16.c new file mode 100644 index 0000000000..f14864be90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-16.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */ + +int foo, bar; + +static +void decode_reloc(int reloc, int *is_alt) +{ + if (reloc >= 20) + *is_alt = 1; + else if (reloc >= 10) + *is_alt = 0; +} + +void testfunc() +{ + int alt_reloc; + + decode_reloc(foo, &alt_reloc); + + if (alt_reloc) /* { dg-warning "may be used uninitialized" "" } */ + bar = 42; +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-17.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-17.c new file mode 100644 index 0000000000..9eec9440c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-17.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ + +typedef _Complex float C; +C foo(int cond) +{ + C f; + __imag__ f = 0; + if (cond) + { + __real__ f = 1; + return f; + } + return f; /* { dg-warning "may be used" "unconditional" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-18.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-18.c new file mode 100644 index 0000000000..1c9afa928c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-18.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-18.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-19.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-19.c new file mode 100644 index 0000000000..38d27e4f95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-19.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +/* { dg-additional-options "-finline-small-functions" { target avr-*-* } } */ + +int a, l, m; +float *b; +float c, d, e, g, h; +unsigned char i, k; +void +fn1 (int p1, float *f1, float *f2, float *f3, unsigned char *c1, float *f4, + unsigned char *c2, float *p10) +{ + if (p1 & 8) + b[3] = p10[a]; + /* { dg-warning "may be used uninitialized" "" { target { { nonpic || pie_enabled } || { hppa*64*-*-* *-*-darwin* } } } .-1 } */ +} + +void +fn2 () +{ + float *n; + if (l & 6) + n = &c + m; + fn1 (l, &d, &e, &g, &i, &h, &k, n); + /* { dg-warning "may be used uninitialized" "" { target { ! { { nonpic || pie_enabled } || { hppa*64*-*-* *-*-darwin* } } } } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-2.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-2.c new file mode 100644 index 0000000000..4c32dc8639 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-2.c @@ -0,0 +1,5 @@ +/* Spurious uninitialized variable warnings, case 2. + Taken from cpphash.c (macroexpand) */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-2.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-20.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-20.c new file mode 100644 index 0000000000..d81957e5bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-20.c @@ -0,0 +1,4 @@ +/* Spurious uninitialized variable warnings, from gdb */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-20.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-21.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-21.c new file mode 100644 index 0000000000..cc61746073 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-21.c @@ -0,0 +1,4 @@ +/* PR69537, spurious warning because of a missed optimization. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-short-enums -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-21.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-22.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-22.c new file mode 100644 index 0000000000..1e522ce542 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-22.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wuninitialized --param vect-max-version-for-alias-checks=20 -ftrivial-auto-var-init=zero" } */ +#include "uninit-22.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-23.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-23.c new file mode 100644 index 0000000000..f1f783973a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-23.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/78455 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */ + +int ij; + +void +ql (void) +{ + int m5 = 0; + + for (;;) + { + if (0) + for (;;) + { + int *go; + int *t4 = go; /* { dg-warning "is used uninitialized" } */ + + l1: + *t4 = (*t4 != 0) ? 0 : 2; /* { dg-warning "is used uninitialized" } */ + } + + if (ij != 0) + goto l1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-24.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-24.c new file mode 100644 index 0000000000..0f839ba9ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-24.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-24.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-25.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-25.c new file mode 100644 index 0000000000..f36d95f9d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-25.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized -ftrivial-auto-var-init=zero" } */ + +extern unsigned bar (void); +extern void quux (void); + +unsigned foo (unsigned v) +{ + unsigned u; + if (v != 1) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 1) is false then (v != 2) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + if (v != 2) + return u; /* { dg-warning "may be used uninitialized" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-26.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-26.c new file mode 100644 index 0000000000..ae97ecfa71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-26.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized -ftrivial-auto-var-init=zero" } */ + +extern unsigned bar (void); +extern void quux (void); + +unsigned foo (unsigned v) +{ + unsigned u; + if (v != 100) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 100) is false then (v < 105) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + if (v < 105) /* v == 100 falls into this range. */ + return u; /* { dg-warning "may be used uninitialized" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-3.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-3.c new file mode 100644 index 0000000000..5c109202a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-3.c @@ -0,0 +1,5 @@ +/* Spurious uninit variable warnings, case 3. + Inspired by cppexp.c (parse_charconst) */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-34.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-34.c new file mode 100644 index 0000000000..d6e7ed3e86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-34.c @@ -0,0 +1,58 @@ +/* PR middle-end/10138 - warn for uninitialized arrays passed as const* + arguments + Verify that passing pointers to uninitialized objects to arguments + to functions declared with attribute access is diagnosed where expected. + { dg-do compile } + { dg-options "-O -Wall -ftrivial-auto-var-init=zero" } */ + +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) + +RW (1) RW (3) void +f4pi (int*, int*, int*, int*); // { dg-message "in a call to 'f4pi' declared with attribute 'access \\\(read_write, \[13\]\\\)'" } + + +void nowarn_scalar (void) +{ + int i1 = 0, i2, i3 = 1, i4; + f4pi (&i1, &i2, &i3, &i4); +} + +void warn_scalar_1 (void) +{ + int i1; // { dg-message "declared here" "" } + int i2, i3 = 1, i4; + + f4pi (&i1, &i2, &i3, &i4); // { dg-warning "'i1' may be used uninitialized" "" } +} + +void warn_scalar_2 (void) +{ + int j1 = 0, j2, j4; + int j3; + + f4pi (&j1, &j2, &j3, &j4); // { dg-warning "'j3' may be used uninitialized" "" } +} + + +void nowarn_array_init (void) +{ + int a1[4] = { 0 }, a2[5], a3[6] = { 0 }, a4[7]; + + f4pi (a1, a2, a3, a4); +} + +void warn_array_1 (void) +{ + int a1[4]; // { dg-message "'a1' declared here" } + int a2[5], a3[6] = { 0 }, a4[7]; + + f4pi (a1, a2, a3, a4); // { dg-warning "'a1' may be used uninitialized" } +} + +void warn_array_2 (void) +{ + int a1[4] = { 0 }, a2[5], a4[7]; + int a3[6]; // { dg-message "'a3' declared here" } + + f4pi (a1, a2, a3, a4); // { dg-warning "'a3' may be used uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-36.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-36.c new file mode 100644 index 0000000000..64377d380e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-36.c @@ -0,0 +1,238 @@ +/* PR middle-end/10138 - warn for uninitialized arrays passed as const* + arguments + Verify that passing pointers to uninitialized objects to const + arguments to built-ins is diagnosed where expected. + { dg-do compile } + { dg-options "-O -Wall -ftrivial-auto-var-init=zero" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +void* alloca (size_t); +void* malloc (size_t); +void* realloc (void*, size_t); + +void* memcpy (void*, const void*, size_t); +char* strcpy (char*, const char*); +size_t strlen (const char*); + +void sink (void*); + +void nowarn_array_memcpy (void *d, unsigned n) +{ + int a[2]; + /* Diagnose this? */ + memcpy (d, a, n /* Non-constant to avoid folding into MEM_REF. */); +} + +void nowarn_array_plus_cst_memcpy (void *d, unsigned n) +{ + int a[3]; + /* Diagnose this? */ + memcpy (d, a + 1, n); +} + +void nowarn_array_plus_var_memcpy (void *d, unsigned n, int i) +{ + int a[4]; + /* Diagnose this? */ + memcpy (d, a + i, n); +} + +void nowarn_array_assign_memcpy (char *d, unsigned n) +{ + int a[3]; + a[1] = 3; + memcpy (d, a, n); +} + +void nowarn_array_init_memcpy (char *d, unsigned n) +{ + int a[4] = { 0 }; + memcpy (d, a, n); +} + +void nowarn_array_compound_memcpy (void *d, unsigned n) +{ + memcpy (d, (int[2]){ 0 }, n); +} + +void nowarn_struct_assign_memcpy (void *d, unsigned n) +{ + struct S { int a, b, c, d; } s; + s.b = 1; + s.d = 2; + memcpy (d, &s, n); +} + + +void nowarn_array_init_strcpy (char *d[], unsigned n) +{ + char a[8] = "012"; + + strcpy (d[0], a); + strcpy (d[1], a + 1); + strcpy (d[1], a + 2); + strcpy (d[1], a + 3); + strcpy (d[1], a + 4); + strcpy (d[1], a + 5); + strcpy (d[1], a + 6); + strcpy (d[1], a + 7); +} + + +void nowarn_array_assign_strcpy (char *d[], unsigned n) +{ + char a[8]; + a[0] = '0'; + a[1] = '1'; + a[2] = '2'; + a[3] = '\0'; + + strcpy (d[0], a); + strcpy (d[1], a + 1); + strcpy (d[1], a + 2); + strcpy (d[1], a + 3); +} + +void warn_array_plus_cst_strcpy (char *d, unsigned n) +{ + char a[8]; + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + a[3] = '\0'; + + strcpy (d, a + 4); // { dg-warning "\\\[-Wuninitialized" } + strcpy (d, a + 5); // { dg-warning "\\\[-Wuninitialized" } + strcpy (d, a + 6); // { dg-warning "\\\[-Wuninitialized" } + strcpy (d, a + 7); // { dg-warning "\\\[-Wuninitialized" } +} + +void nowarn_array_plus_var_strcpy (char *d, int i) +{ + char a[8]; + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + a[3] = '\0'; + + strcpy (d, a + i); +} + + +size_t nowarn_array_assign_strlen (const char *s) +{ + char a[8]; + a[0] = s[0]; + a[1] = s[1]; + a[2] = s[2]; + a[3] = s[3]; + + size_t n = 0; + + n += strlen (a); + n += strlen (a + 1); + n += strlen (a + 2); + n += strlen (a + 3); + return n; +} + +size_t warn_array_plus_cst_strlen (const char *s) +{ + char a[8]; + a[0] = s[0]; + a[1] = s[1]; + a[2] = s[2]; + a[3] = s[3]; + + return strlen (a + 4); // { dg-warning "\\\[-Wuninitialized" } +} + +size_t nowarn_array_plus_var_strlen (const char *s, int i) +{ + char a[8]; + a[0] = s[0]; + a[1] = s[1]; + a[2] = s[2]; + a[3] = s[3]; + + return strlen (a + i); +} + + +size_t nowarn_alloca_assign_strlen (int i) +{ + char *p = (char*)alloca (8); + p[i] = '\0'; + return strlen (p); +} + +size_t nowarn_alloca_escape_strlen (int i) +{ + char *p = (char*)alloca (8); + sink (p); + return strlen (p); +} + +size_t warn_alloca_strlen (void) +{ + char *p = (char*)alloca (8); + return strlen (p); // { dg-warning "\\\[-Wuninitialized" } +} + + +size_t nowarn_malloc_assign_strlen (int i) +{ + char *p = (char*)malloc (8); + p[i] = '\0'; + return strlen (p); +} + +size_t nowarn_malloc_escape_strlen (int i) +{ + char *p = (char*)malloc (8); + sink (p); + return strlen (p); +} + +size_t warn_malloc_strlen (void) +{ + char *p = (char*)malloc (8); + return strlen (p); // { dg-warning "\\\[-Wuninitialized" } +} + + +size_t nowarn_realloc_strlen (void *p) +{ + char *q = (char*)realloc (p, 8); + return strlen (q); +} + + +size_t nowarn_vla_assign_strlen (int n, int i) +{ + char vla[n]; + vla[i] = '\0'; + return strlen (vla); +} + +size_t nowarn_vla_strcpy_strlen (int n, const char *s, int i) +{ + char vla[n]; + strcpy (vla, s); + return strlen (vla + i); +} + +size_t nowarn_vla_escape_strlen (int n, int i) +{ + char vla[n]; + sink (vla); + return strlen (vla); +} + +size_t warn_vla_strlen (unsigned n) +{ + char vla[n]; + return strlen (vla); // { dg-warning "\\\[-Wuninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-37.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-37.c new file mode 100644 index 0000000000..aea554262f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-37.c @@ -0,0 +1,154 @@ +/* PR middle-end/10138 - warn for uninitialized arrays passed as const arguments + Verify that -Wuninitialized and -Wmaybe-uninitialized trigger (or don't) + when passing uninitialized variables by reference to functions declared + with or without attribute access and with (or without) const qualified + arguments of array, VLA, or pointer types. + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0 -ftrivial-auto-var-init=zero" } */ + +#define NONE /* none */ +#define RO(...) __attribute__ ((access (read_only, __VA_ARGS__))) +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) +#define WO(...) __attribute__ ((access (write_only, __VA_ARGS__))) +#define X(...) __attribute__ ((access (none, __VA_ARGS__))) + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define UNIQ(pfx) CAT (pfx, __LINE__) + +extern void sink (void*); + + +#define T1(attr, name, type) \ + void UNIQ (CAT (test_, name))(void) { \ + extern attr void UNIQ (name)(type); \ + int x; \ + UNIQ (name)(&x); \ + sink (&x); \ + } + +#define T2(attr, name, types) \ + void UNIQ (CAT (test_, name))(void) { \ + extern attr void UNIQ (name)(types); \ + int x; \ + UNIQ (name)(1, &x); \ + sink (&x); \ + } + + +typedef int IA_[]; +typedef const int CIA_[]; + +T1 (NONE, fia_, IA_); +T1 (NONE, fcia_, CIA_); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (RO (1), froia_, IA_); // { dg-warning "\\\[-Wuninitialized" "" } +T1 (RW (1), frwia_, IA_); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (WO (1), fwoia_, IA_); +T1 (X (1), fxia_, IA_); + + +typedef int IA1[1]; +typedef const int CIA1[1]; + +T1 (NONE, fia1, IA1); +T1 (NONE, fcia1, CIA1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (RO (1), froia1, IA1); // { dg-warning "\\\[-Wuninitialized" "" } +T1 (RW (1), frwia1, IA1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (WO (1), fwoia1, IA1); +T1 (X (1), fxia1, IA1); + + +#define IARS1 int[restrict static 1] +#define CIARS1 const int[restrict static 1] + +T1 (NONE, fiars1, IARS1); +T1 (NONE, fciars1, CIARS1);// { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (RO (1), froiars1, IARS1); // { dg-warning "\\\[-Wuninitialized" "" } +T1 (RW (1), frwiars1, IARS1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (WO (1), fwoiars1, IARS1); +T1 (X (1), fxiars1, IARS1); + + +#define IAS1 int[static 1] +#define CIAS1 const int[static 1] + +T1 (NONE, fias1, IAS1); +T1 (NONE, fcias1, CIAS1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (RO (1), froias1, IAS1); // { dg-warning "\\\[-Wuninitialized" "" } +T1 (RW (1), frwias1, IAS1); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (WO (1), fwoias1, IAS1); +T1 (X (1), fxias1, IAS1); + + +#define IAX int[*] +#define CIAX const int[*] + +T1 (NONE, fiax, IAX); +T1 (NONE, fciax, CIAX); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (RO (1), froiax, IAX); // { dg-warning "\\\[-Wuninitialized" "" } +T1 (RW (1), frwiax, IAX); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (WO (1), fwoiax, IAX); +T1 (X (1), fxiax, IAX); + + +#define IAN int n, int[n] +#define CIAN int n, const int[n] + +T2 (NONE, fian, IAN); +T2 (NONE, fcian, CIAN); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T2 (RO (2, 1), froian, IAN); // { dg-warning "\\\[-Wuninitialized" "" } +T2 (RW (2, 1), frwian, IAN); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T2 (WO (2, 1), fwoian, IAN); +T2 (X (2, 1), fxian, IAN); + + +typedef int* IP; +typedef const int* CIP; + +T1 (NONE, fip, IP); +T1 (NONE, fcip, CIP); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (RO (1), froip, IP); // { dg-warning "\\\[-Wuninitialized" "" } +T1 (RW (1), frwip, IP); // { dg-warning "\\\[-Wmaybe-uninitialized" "" } +T1 (WO (1), fwoip, IP); +T1 (X (1), fxip, IP); + + +/* Verify that the notes printed after the warning mention attribute + access only when the attribute is explicitly used in the declaration + and not otherwise. */ + +void test_note_cst_restrict (void) +{ + extern void + fccar (const char[restrict]); // { dg-message "by argument 1 of type 'const char\\\[restrict]' to 'fccar'" "note" } + + char a[1]; // { dg-message "'a' declared here" "note" } + fccar (a); // { dg-warning "'a' may be used uninitialized" } +} + +void test_note_vla (int n) +{ + extern void + fccvla (const char[n]); // { dg-message "by argument 1 of type 'const char\\\[n]' to 'fccvla'" "note" } + + char a[2]; // { dg-message "'a' declared here" "note" } + fccvla (a); // { dg-warning "'a' may be used uninitialized" } +} + +void test_note_ro (void) +{ + extern RO (1) void + frocar (char[restrict]); // { dg-message "in a call to 'frocar' declared with attribute 'access \\\(read_only, 1\\\)'" "note" } + + char a[3]; // { dg-message "'a' declared here" "note" } + frocar (a); // { dg-warning "'a' is used uninitialized" } +} + +void test_note_rw (void) +{ + extern RW (1) void + frwcar (char[restrict]); // { dg-message "in a call to 'frwcar' declared with attribute 'access \\\(read_write, 1\\\)'" "note" } + + char a[4]; // { dg-message "'a' declared here" "note" } + frwcar (a); // { dg-warning "'a' may be used uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-4.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-4.c new file mode 100644 index 0000000000..29ec860f0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-4.c @@ -0,0 +1,10 @@ +/* Spurious uninit variable warnings, case 4. + Simplified version of cppexp.c (cpp_parse_expr). + + This one is really fragile, it gets it right if you take out case + 1, or if the structure is replaced by an int, or if the structure + has fewer members (!) */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-4.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-5.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-5.c new file mode 100644 index 0000000000..65b251a218 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-5.c @@ -0,0 +1,6 @@ +/* Spurious uninitialized-variable warnings. */ +/* Disable jump threading, etc to test compiler analysis. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -fno-tree-dce -fno-tree-vrp -fno-tree-dominator-opts -ftrivial-auto-var-init=zero" } */ + +#include "uninit-5.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-6.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-6.c new file mode 100644 index 0000000000..7c10dfc589 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-6.c @@ -0,0 +1,7 @@ +/* Spurious uninitialized variable warnings. + This one inspired by java/class.c:build_utf8_ref. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ + +#include "uninit-6.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-8.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-8.c new file mode 100644 index 0000000000..eaa9c0c909 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-8.c @@ -0,0 +1,8 @@ +/* Uninitialized variable warning tests... + Inspired by part of optabs.c:expand_binop. + May be the same as uninit-1.c. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ + +#include "uninit-8.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-9.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-9.c new file mode 100644 index 0000000000..6dccf014fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-9.c @@ -0,0 +1,8 @@ +/* Spurious uninitialized variable warnings. Slight variant on the + documented case, inspired by reg-stack.c:record_asm_reg_life. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +/* { dg-require-effective-target alloca } */ + +#include "uninit-9.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-A.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-A.c new file mode 100644 index 0000000000..0ef1d92a74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-A.c @@ -0,0 +1,7 @@ +/* Inspired by part of java/parse.y. + May be a real bug in CSE. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -ftrivial-auto-var-init=zero" } */ + +#include "uninit-A.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-B.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-B.c new file mode 100644 index 0000000000..40d3196ea4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-B.c @@ -0,0 +1,15 @@ +/* Origin: PR c/179 from Gray Watson , adapted as a testcase + by Joseph Myers . */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */ +extern void foo (int *); +extern void bar (int); + +void +baz (void) +{ + int i; + if (i) /* { dg-warning "is used uninitialized" "uninit i warning" } */ + bar (i); + foo (&i); +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-C.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-C.c new file mode 100644 index 0000000000..be19796264 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-C.c @@ -0,0 +1,5 @@ +/* Spurious uninitialized variable warning, inspired by libgcc2.c. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ + +#include "uninit-C.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-H.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-H.c new file mode 100644 index 0000000000..e442fab00b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-H.c @@ -0,0 +1,5 @@ +/* PR 14204 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wall -Werror -ftrivial-auto-var-init=zero" } */ + +#include "uninit-H.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-uninit-I.c b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-I.c new file mode 100644 index 0000000000..4f9ae6cd98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-uninit-I.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */ +#include "uninit-H.c" diff --git a/SingleSource/Regression/C/gcc-dg/auto-init-unused-1.c b/SingleSource/Regression/C/gcc-dg/auto-init-unused-1.c new file mode 100644 index 0000000000..b7d44e6b4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-init-unused-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftrivial-auto-var-init=zero -fdump-tree-ssa" } */ + +int a; +int foo (void); +int bar (void); + +void +baz (void) +{ + int *b[6]; + if (foo ()) + a |= bar (); +} + +/* { dg-final { scan-tree-dump-not "DEFERRED_INIT" "ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/auto-type-1.c b/SingleSource/Regression/C/gcc-dg/auto-type-1.c new file mode 100644 index 0000000000..882bf2c13f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-type-1.c @@ -0,0 +1,38 @@ +/* Test __auto_type. Test correct uses. */ +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-require-effective-target alloca } */ + +extern void abort (void); +extern void exit (int); + +__auto_type i = 1; +extern int i; +__auto_type c = (char) 1; +extern char c; +static __auto_type u = 10U; +extern unsigned int u; +const __auto_type ll = 1LL; +extern const long long ll; + +int +main (void) +{ + if (i != 1 || c != 1 || u != 10U) + abort (); + __auto_type ai = i; + int *aip = &ai; + if (ai != 1) + abort (); + __auto_type p = (int (*) [++i]) 0; + if (i != 2) + abort (); + if (sizeof (*p) != 2 * sizeof (int)) + abort (); + int vla[u][u]; + int (*vp)[u] = &vla[0]; + __auto_type vpp = ++vp; + if (vp != &vla[1]) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/auto-type-2.c b/SingleSource/Regression/C/gcc-dg/auto-type-2.c new file mode 100644 index 0000000000..761671b3c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/auto-type-2.c @@ -0,0 +1,23 @@ +/* Test __auto_type. Test invalid uses. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +__auto_type; /* { dg-error "empty declaration" } */ +__auto_type *p = (int *) 0; /* { dg-error "plain identifier" } */ +struct s0 { int i : 1; } x; +void f (void) { __auto_type v = x.i; } /* { dg-error "bit-field initializer" } */ +__auto_type i; /* { dg-error "initialized data declaration" } */ +__auto_type g { } /* { dg-error "initialized data declaration" } */ +__auto_type a = 1, b = 2; /* { dg-error "single declarator" } */ +__auto_type long e0 = 0; /* { dg-error "__auto_type" } */ +__auto_type short e1 = 0; /* { dg-error "__auto_type" } */ +__auto_type signed e2 = 0; /* { dg-error "__auto_type" } */ +__auto_type unsigned e3 = 0; /* { dg-error "__auto_type" } */ +__auto_type _Complex e4 = 0; /* { dg-error "__auto_type" } */ +long __auto_type e5 = 0; /* { dg-error "__auto_type" } */ +short __auto_type e6 = 0; /* { dg-error "__auto_type" } */ +signed __auto_type e7 = 0; /* { dg-error "__auto_type" } */ +unsigned __auto_type e8 = 0; /* { dg-error "__auto_type" } */ +_Complex __auto_type e9 = 0; /* { dg-error "__auto_type" } */ +int __auto_type e10 = 0; /* { dg-error "two or more data types" } */ +__auto_type _Bool e11 = 0; /* { dg-error "two or more data types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bad-binary-ops.c b/SingleSource/Regression/C/gcc-dg/bad-binary-ops.c new file mode 100644 index 0000000000..45668be0a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bad-binary-ops.c @@ -0,0 +1,74 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +/* Adapted from https://gcc.gnu.org/wiki/ClangDiagnosticsComparison */ + +typedef float __m128; +void test_1 () +{ + __m128 myvec[2]; + int const *ptr; + myvec[1]/ptr; /* { dg-error "invalid operands to binary /" } */ + +/* TODO: ideally we'd underline "ptr" as well. +{ dg-begin-multiline-output "" } + myvec[1]/ptr; + ~~~~~~~~^ + | + __m128 +{ dg-end-multiline-output "" } */ + + +} + +struct s {}; +struct t {}; +extern struct s some_function (void); +extern struct t some_other_function (void); + +int test_2 (void) +{ + return (some_function () + + some_other_function ()); /* { dg-error "invalid operands to binary \+" } */ + +/* { dg-begin-multiline-output "" } + return (some_function () + ~~~~~~~~~~~~~~~~ + | + struct s + + some_other_function ()); + ^ ~~~~~~~~~~~~~~~~~~~~~~ + | + struct t + { dg-end-multiline-output "" } */ +} + +int test_3 (struct s param_s, struct t param_t) +{ + return param_s + param_t; // { dg-error "invalid operands to binary \+" } + +/* { dg-begin-multiline-output "" } + return param_s + param_t; + ^ + { dg-end-multiline-output "" } */ +/* TODO: ideally we'd underline both params here. */ +} + +typedef struct s S; +typedef struct t T; + +extern S callee_4a (void); +extern T callee_4b (void); + +int test_4 (void) +{ + return callee_4a () + callee_4b (); /* { dg-error "invalid operands to binary \+" } */ + +/* { dg-begin-multiline-output "" } + return callee_4a () + callee_4b (); + ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ + | | + | T {aka struct t} + S {aka struct s} + { dg-end-multiline-output "" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/bad-dereference.c b/SingleSource/Regression/C/gcc-dg/bad-dereference.c new file mode 100644 index 0000000000..5f8188dbcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bad-dereference.c @@ -0,0 +1,24 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +struct foo +{ + int x; +}; + +int test_1 (struct foo some_f) +{ + return *some_f.x; /* { dg-error "invalid type argument of unary ... .have .int.." } */ +/* { dg-begin-multiline-output "" } + return *some_f.x; + ^~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +int test_2 (struct foo some_f) +{ + return *some_f; /* { dg-error "invalid type argument of unary ... .have .struct foo.." } */ +/* { dg-begin-multiline-output "" } + return *some_f; + ^~~~~~~ + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/bad-pragma-locations.c b/SingleSource/Regression/C/gcc-dg/bad-pragma-locations.c new file mode 100644 index 0000000000..8068839881 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bad-pragma-locations.c @@ -0,0 +1,86 @@ +/* Verify that we use precise locations when emitting diagnostics + about pragmas. */ + +/* { dg-do assemble } */ +/* { dg-options "-fdiagnostics-show-caret" } */ + +/* pack ****************************************************************************/ + +#pragma pack +/* { dg-warning "missing '\\(' after '#pragma pack' - ignored" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma pack + ^~~~ + { dg-end-multiline-output "" } */ + +#pragma pack ( +/* { dg-warning "malformed '#pragma pack' - ignored" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma pack ( + ^~~~ + { dg-end-multiline-output "" } */ + +#pragma pack (32 +/* { dg-warning "malformed '#pragma pack' - ignored" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma pack (32 + ^~~~ + { dg-end-multiline-output "" } */ + +#pragma pack (3.14159 +/* { dg-warning "invalid constant in '#pragma pack' - ignored" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma pack (3.14159 + ^~~~~~~ + { dg-end-multiline-output "" } */ + +#pragma pack (push, 3.14159 +/* { dg-warning "invalid constant in '#pragma pack' - ignored" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma pack (push, 3.14159 + ^~~~~~~ + { dg-end-multiline-output "" } */ + +#pragma pack (toothbrush +/* { dg-warning "unknown action 'toothbrush' for '#pragma pack' - ignored" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma pack (toothbrush + ^~~~~~~~~~ + { dg-end-multiline-output "" } */ + +#pragma pack() pyjamas +/* { dg-warning "junk at end of '#pragma pack'" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma pack() pyjamas + ^~~~~~~ + { dg-end-multiline-output "" } */ + +/* target ****************************************************************************/ + +#pragma GCC target 42 +/* { dg-warning "#pragma GCC option' is not a string" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma GCC target 42 + ^~ + { dg-end-multiline-output "" } */ + +#pragma GCC target ( 1776 +/* { dg-warning "#pragma GCC option' is not a string" "" { target *-*-* } .-1 } + { dg-begin-multiline-output "" } + #pragma GCC target ( 1776 + ^~~~ + { dg-end-multiline-output "" } */ + +/* message ****************************************************************************/ + +#pragma message "foo" int +/* { dg-warning "junk at end of '#pragma message'" "" { target *-*-* } .-1 } + { dg-message "'#pragma message: foo'" "" { target *-*-* } .-2 } + { dg-begin-multiline-output "" } + #pragma message "foo" int + ^~~ + { dg-end-multiline-output "" } + { dg-begin-multiline-output "" } + #pragma message "foo" int + ^~~~~~~ + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bconstp-1.c b/SingleSource/Regression/C/gcc-dg/bconstp-1.c new file mode 100644 index 0000000000..36831a5d6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bconstp-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +/* This test checks that builtin_constant_p can be used safely in + initializers for static data. The macro X() defined below should + be an acceptable initializer expression no matter how complex its + argument is. */ + +extern int a; +extern int b; + +extern int foo(void); +extern int bar(void); + +#define X(exp) (__builtin_constant_p(exp) ? (exp) : -1) + +const short tests[] = { + X(0), + X(a), + X(0 && a), + X(a && b), + X(foo()), + X(0 && foo()), + X(a && foo()), + X(foo() && bar()) +}; diff --git a/SingleSource/Regression/C/gcc-dg/bconstp-2.c b/SingleSource/Regression/C/gcc-dg/bconstp-2.c new file mode 100644 index 0000000000..5b5ff8b1cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bconstp-2.c @@ -0,0 +1,27 @@ +/* As bconstp-1.c, but with the __builtin_constant_p calls + parenthesized. */ +/* { dg-do compile } */ + +/* This test checks that builtin_constant_p can be used safely in + initializers for static data. The macro X() defined below should + be an acceptable initializer expression no matter how complex its + argument is. */ + +extern int a; +extern int b; + +extern int foo(void); +extern int bar(void); + +#define X(exp) ((__builtin_constant_p(exp)) ? (exp) : -1) + +const short tests[] = { + X(0), + X(a), + X(0 && a), + X(a && b), + X(foo()), + X(0 && foo()), + X(a && foo()), + X(foo() && bar()) +}; diff --git a/SingleSource/Regression/C/gcc-dg/bconstp-3.c b/SingleSource/Regression/C/gcc-dg/bconstp-3.c new file mode 100644 index 0000000000..9e3d10f399 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bconstp-3.c @@ -0,0 +1,27 @@ +/* As bconstp-1.c, but with the __builtin_constant_p calls inside + __builtin_choose_expr. */ +/* { dg-do compile } */ + +/* This test checks that builtin_constant_p can be used safely in + initializers for static data. The macro X() defined below should + be an acceptable initializer expression no matter how complex its + argument is. */ + +extern int a; +extern int b; + +extern int foo(void); +extern int bar(void); + +#define X(exp) (__builtin_choose_expr(1, __builtin_constant_p(exp), 1) ? (exp) : -1) + +const short tests[] = { + X(0), + X(a), + X(0 && a), + X(a && b), + X(foo()), + X(0 && foo()), + X(a && foo()), + X(foo() && bar()) +}; diff --git a/SingleSource/Regression/C/gcc-dg/bconstp-4.c b/SingleSource/Regression/C/gcc-dg/bconstp-4.c new file mode 100644 index 0000000000..bb8aef19fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bconstp-4.c @@ -0,0 +1,10 @@ +/* Test that a condition is not counted as a call to + __builtin_constant_p if that call is itself inside a conditional + expression with __builtin_constant_p condition. */ +/* { dg-do compile } */ + +extern int foo(void); + +#define X(exp) (__builtin_choose_expr(1, __builtin_constant_p(exp), 1) ? (exp) : -1) + +const int x = ((__builtin_constant_p(1) ? __builtin_constant_p (0 && foo()) : 0) ? (0 && foo()) : -1); /* { dg-error "initializer element is not a constant expression" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bf-ms-attrib.c b/SingleSource/Regression/C/gcc-dg/bf-ms-attrib.c new file mode 100644 index 0000000000..2da4f0320d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bf-ms-attrib.c @@ -0,0 +1,40 @@ +/* bf-ms-attrib.c */ +/* Adapted from Donn Terry testcase + posted to GCC-patches + http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00577.html */ + +/* { dg-do run { target *-*-mingw* *-*-cygwin* } } */ + +/* We don't want the default "pedantic-errors" in this case, since we're + testing nonstandard stuff to begin with. */ +/* { dg-options "-ansi" } */ + +extern void abort(void); + +struct one_gcc { + int d; + unsigned char a; + unsigned short b:7; + char c; +} __attribute__((__gcc_struct__)) ; + + +struct one_ms { + int d; + unsigned char a; + unsigned short b:7; + char c; +} __attribute__((__ms_struct__)); + + +main() + { + /* As long as the sizes are as expected, we know attributes are working. + bf-ms-layout.c makes sure the right thing happens when the attribute + is on. */ + if (sizeof(struct one_ms) != 8) + abort(); + if (sizeof(struct one_gcc) != 8) + abort(); + return 0; + } diff --git a/SingleSource/Regression/C/gcc-dg/bf-ms-layout-2.c b/SingleSource/Regression/C/gcc-dg/bf-ms-layout-2.c new file mode 100644 index 0000000000..519785a823 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bf-ms-layout-2.c @@ -0,0 +1,236 @@ +/* bf-ms-layout.c */ + +/* Test for MS bitfield layout */ +/* Adapted from Donn Terry testcase + posted to GCC-patches + http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00577.html */ + +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-D_TEST_MS_LAYOUT" } */ +/* This test uses the attribute instead of the command line option. */ + +#include +#include + +extern void abort(); + +#pragma pack(8) + +#ifdef __GNUC__ +#define ATTR __attribute__ ((ms_struct)) +#endif + +struct one { + int d; + unsigned char a; + unsigned short b:7; + char c; +} ATTR; + +struct two { + int d; + unsigned char a; + unsigned int b:7; + char c; +} ATTR; + +struct three { + short d; + unsigned short a:3; + unsigned short b:9; + unsigned char c:7; +} ATTR; + + +/* Bitfields of size 0 have some truly odd behaviors. */ + +struct four { + unsigned short a:3; + unsigned short b:9; + unsigned int :0; /* forces struct alignment to int */ + unsigned char c:7; +} ATTR; + +struct five { + char a; + int :0; /* ignored; prior field is not a bitfield. */ + char b; + char c; +} ATTR; + +struct six { + char a :8; + int :0; /* not ignored; prior field IS a bitfield, causes + struct alignment as well. */ + char b; + char c; +} ATTR; + +struct seven { + char a:8; + char :0; + int :0; /* Ignored; prior field is zero size bitfield. */ + char b; + char c; +} ATTR; + +struct eight { /* ms size 4 */ + short b:3; + char c; +} ATTR; + +#ifdef _MSC_VER +#define LONGLONG __int64 +#else +#define LONGLONG long long +#endif + +union nine { /* ms size 8 */ + LONGLONG a:3; + char c; +} ATTR; + +struct ten { /* ms size 16 */ + LONGLONG a:3; + LONGLONG b:3; + char c; +} ATTR; + + +#define val(s,f) (s.f) + +#define check_struct(_X) \ +{ \ + if (sizeof (struct _X) != exp_sizeof_##_X ) \ + abort(); \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_union(_X) \ +{ \ + if (sizeof (union _X) != exp_sizeof_##_X ) \ + abort(); \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_struct_size(_X) \ +{ \ + if (sizeof (struct _X) != exp_sizeof_##_X ) \ + abort(); \ +} + +#define check_struct_off(_X) \ +{ \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_union_size(_X) \ +{ \ + if (sizeof (union _X) != exp_sizeof_##_X ) \ + abort(); \ +} + +#define check_union_off(_X) \ +{ \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +int main(){ + + unsigned char filler[16]; + struct one test_one; + struct two test_two; + struct three test_three; + struct four test_four; + struct five test_five; + struct six test_six; + struct seven test_seven; + struct eight test_eight; + union nine test_nine; + struct ten test_ten; + +#if defined (_TEST_MS_LAYOUT) || defined (_MSC_VER) + size_t exp_sizeof_one = 12; + size_t exp_sizeof_two = 16; + size_t exp_sizeof_three =6; + size_t exp_sizeof_four = 8; + size_t exp_sizeof_five = 3; + size_t exp_sizeof_six = 8; + size_t exp_sizeof_seven = 3; + size_t exp_sizeof_eight = 4; + size_t exp_sizeof_nine = 8; + size_t exp_sizeof_ten = 16; + + unsigned char exp_one_c = 8; + unsigned char exp_two_c = 12; + unsigned char exp_three_c = 4; + unsigned char exp_four_c = 4; + char exp_five_c = 2; + char exp_six_c = 5; + char exp_seven_c = 2; + char exp_eight_c = 2; + char exp_nine_c = 0; + char exp_ten_c = 8; + +#else /* testing -mno-ms-bitfields */ + + size_t exp_sizeof_one = 8; + size_t exp_sizeof_two = 8; + size_t exp_sizeof_three = 6; + size_t exp_sizeof_four = 6; + size_t exp_sizeof_five = 6; + size_t exp_sizeof_six = 6; + size_t exp_sizeof_seven = 6; + size_t exp_sizeof_eight = 2; + size_t exp_sizeof_nine = 8; + size_t exp_sizeof_ten = 8; + + unsigned short exp_one_c = 6; + unsigned int exp_two_c = 6; + unsigned char exp_three_c = 64; + unsigned char exp_four_c = 4; + char exp_five_c = 5; + char exp_six_c = 5; + char exp_seven_c = 5; + char exp_eight_c = 1; + char exp_nine_c = 0; + char exp_ten_c = 1; + +#endif + + unsigned char i; + for ( i = 0; i < 16; i++ ) + filler[i] = i; + + check_struct_off (one); + check_struct_off (two); + check_struct_off (three); + check_struct_off (four); + check_struct_off (five); + check_struct_off (six); + check_struct_off (seven); + check_struct_off (eight); + check_union_off (nine); + check_struct_off (ten); + + check_struct_size (one); + check_struct_size (two); + check_struct_size (three); + check_struct_size (four); + check_struct_size (five); + check_struct_size (six); + check_struct_size (seven); + check_struct_size (eight); + check_union_size (nine); + check_struct_size (ten); + + return 0; +}; diff --git a/SingleSource/Regression/C/gcc-dg/bf-ms-layout-3.c b/SingleSource/Regression/C/gcc-dg/bf-ms-layout-3.c new file mode 100644 index 0000000000..668a036677 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bf-ms-layout-3.c @@ -0,0 +1,52 @@ +/* Test for MS bitfield layout */ +/* { dg-do run { target *-*-mingw* *-*-cygwin* i?86-*-* x86_64-*-* } } */ + +extern void abort(); + +struct s1_t { + char a; + char b __attribute__ ((aligned (16))); +} __attribute__ ((ms_struct)); +struct s1_t s1; + +struct s2_t { + char a; + char b; +} __attribute__ ((ms_struct)); +struct s2_t s2; + +struct s3_t { + __extension__ char a : 6; + char b __attribute__ ((aligned (16))); +} __attribute__ ((ms_struct)); +struct s3_t s3; + +struct s4_t { + __extension__ char a : 6; + char b __attribute__ ((aligned (2))); +} __attribute__ ((ms_struct)); +struct s4_t s4; + +struct s5_t { + __extension__ char a : 6; + char b __attribute__ ((aligned (1))); +} __attribute__ ((ms_struct)); +struct s5_t s5; + +__extension__ +static __PTRDIFF_TYPE__ offs (const void *a, const void *b) +{ + return (__PTRDIFF_TYPE__) ((const char*)a - (const char*)b); +} + +int main() +{ + if (offs (&s1.b, &s1) != 16 + || offs (&s2.b, &s2) != 1 + || offs (&s3.b, &s3) != 16 + || offs (&s4.b, &s4) != 2 + || offs (&s5.b, &s5) != 1) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/bf-ms-layout-4.c b/SingleSource/Regression/C/gcc-dg/bf-ms-layout-4.c new file mode 100644 index 0000000000..821db075a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bf-ms-layout-4.c @@ -0,0 +1,43 @@ +/* PR target/52991 */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ + +#define CHECK(expr) extern char c[(expr) ? 1 : -1] +#define offsetof(x, y) __builtin_offsetof (x, y) + +struct test_sp1 { + int a; + short b; + int c; + char d; +} __attribute__((packed,ms_struct)); + +CHECK (sizeof (struct test_sp1) == 11); +CHECK (offsetof (struct test_sp1, a) == 0); +CHECK (offsetof (struct test_sp1, b) == 4); +CHECK (offsetof (struct test_sp1, c) == 6); +CHECK (offsetof (struct test_sp1, d) == 10); + +struct test_sp3 { + int a; + short b __attribute__((aligned(8))); + int c; + char d; +} __attribute__((packed,ms_struct)); + +CHECK (sizeof (struct test_sp3) == 16); +CHECK (offsetof (struct test_sp3, a) == 0); +CHECK (offsetof (struct test_sp3, b) == 8); +CHECK (offsetof (struct test_sp3, c) == 10); +CHECK (offsetof (struct test_sp3, d) == 14); + +struct test_s4 { + int a; + short b; + int c:15; + char d; +} __attribute__((ms_struct)); + +CHECK (sizeof (struct test_s4) == 16); +CHECK (offsetof (struct test_s4, a) == 0); +CHECK (offsetof (struct test_s4, b) == 4); +CHECK (offsetof (struct test_s4, d) == 12); diff --git a/SingleSource/Regression/C/gcc-dg/bf-ms-layout-5.c b/SingleSource/Regression/C/gcc-dg/bf-ms-layout-5.c new file mode 100644 index 0000000000..361b91464d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bf-ms-layout-5.c @@ -0,0 +1,45 @@ +/* PR target/52991 */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ + +struct S { + int a : 2; + __attribute__((aligned (8))) int b : 2; + int c : 28; + __attribute__((aligned (16))) int d : 2; + int e : 30; +} __attribute__((ms_struct)); + +struct S s; + +int +main () +{ + int i; + if (sizeof (s) != 32) + __builtin_abort (); + s.a = -1; + for (i = 0; i < 32; ++i) + if (((char *) &s)[i] != (i ? 0 : 3)) + __builtin_abort (); + s.a = 0; + s.b = -1; + for (i = 0; i < 32; ++i) + if (((char *) &s)[i] != (i ? 0 : 12)) + __builtin_abort (); + s.b = 0; + s.c = -1; + for (i = 0; i < 32; ++i) + if (((signed char *) &s)[i] != (i > 3 ? 0 : (i ? -1 : -16))) + __builtin_abort (); + s.c = 0; + s.d = -1; + for (i = 0; i < 32; ++i) + if (((signed char *) &s)[i] != (i == 16 ? 3 : 0)) + __builtin_abort (); + s.d = 0; + s.e = -1; + for (i = 0; i < 32; ++i) + if (((signed char *) &s)[i] != ((i < 16 || i > 19) ? 0 : (i == 16 ? -4 : -1))) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/bf-ms-layout.c b/SingleSource/Regression/C/gcc-dg/bf-ms-layout.c new file mode 100644 index 0000000000..94827516f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bf-ms-layout.c @@ -0,0 +1,231 @@ +/* bf-ms-layout.c */ + +/* Test for MS bitfield layout */ +/* Adapted from Donn Terry testcase + posted to GCC-patches + http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00577.html */ + +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-mms-bitfields -D_TEST_MS_LAYOUT" } */ + +#include +#include + +extern void abort(); + +#pragma pack(8) + +struct one { + int d; + unsigned char a; + unsigned short b:7; + char c; +} ; + +struct two { + int d; + unsigned char a; + unsigned int b:7; + char c; +} ; + +struct three { + short d; + unsigned short a:3; + unsigned short b:9; + unsigned char c:7; +} ; + + +/* Bitfields of size 0 have some truly odd behaviors. */ + +struct four { + unsigned short a:3; + unsigned short b:9; + unsigned int :0; /* forces struct alignment to int */ + unsigned char c:7; +} ; + +struct five { + char a; + int :0; /* ignored; prior field is not a bitfield. */ + char b; + char c; +} ; + +struct six { + char a :8; + int :0; /* not ignored; prior field IS a bitfield, causes + struct alignment as well. */ + char b; + char c; +} ; + +struct seven { + char a:8; + char :0; + int :0; /* Ignored; prior field is zero size bitfield. */ + char b; + char c; +} ; + +struct eight { /* ms size 4 */ + short b:3; + char c; +} ; + +#ifdef _MSC_VER +#define LONGLONG __int64 +#else +#define LONGLONG long long +#endif + +union nine { /* ms size 8 */ + LONGLONG a:3; + char c; +} ; + +struct ten { /* ms size 16 */ + LONGLONG a:3; + LONGLONG b:3; + char c; +} ; + + +#define val(s,f) (s.f) + +#define check_struct(_X) \ +{ \ + if (sizeof (struct _X) != exp_sizeof_##_X ) \ + abort(); \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_union(_X) \ +{ \ + if (sizeof (union _X) != exp_sizeof_##_X ) \ + abort(); \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_struct_size(_X) \ +{ \ + if (sizeof (struct _X) != exp_sizeof_##_X ) \ + abort(); \ +} + +#define check_struct_off(_X) \ +{ \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_union_size(_X) \ +{ \ + if (sizeof (union _X) != exp_sizeof_##_X ) \ + abort(); \ +} + +#define check_union_off(_X) \ +{ \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +int main(){ + + unsigned char filler[16]; + struct one test_one; + struct two test_two; + struct three test_three; + struct four test_four; + struct five test_five; + struct six test_six; + struct seven test_seven; + struct eight test_eight; + union nine test_nine; + struct ten test_ten; + +#if defined (_TEST_MS_LAYOUT) || defined (_MSC_VER) + size_t exp_sizeof_one = 12; + size_t exp_sizeof_two = 16; + size_t exp_sizeof_three =6; + size_t exp_sizeof_four = 8; + size_t exp_sizeof_five = 3; + size_t exp_sizeof_six = 8; + size_t exp_sizeof_seven = 3; + size_t exp_sizeof_eight = 4; + size_t exp_sizeof_nine = 8; + size_t exp_sizeof_ten = 16; + + unsigned char exp_one_c = 8; + unsigned char exp_two_c = 12; + unsigned char exp_three_c = 4; + unsigned char exp_four_c = 4; + char exp_five_c = 2; + char exp_six_c = 5; + char exp_seven_c = 2; + char exp_eight_c = 2; + char exp_nine_c = 0; + char exp_ten_c = 8; + +#else /* testing -mno-ms-bitfields */ + + size_t exp_sizeof_one = 8; + size_t exp_sizeof_two = 8; + size_t exp_sizeof_three = 6; + size_t exp_sizeof_four = 6; + size_t exp_sizeof_five = 6; + size_t exp_sizeof_six = 6; + size_t exp_sizeof_seven = 6; + size_t exp_sizeof_eight = 2; + size_t exp_sizeof_nine = 8; + size_t exp_sizeof_ten = 8; + + unsigned short exp_one_c = 6; + unsigned int exp_two_c = 6; + unsigned char exp_three_c = 64; + unsigned char exp_four_c = 4; + char exp_five_c = 5; + char exp_six_c = 5; + char exp_seven_c = 5; + char exp_eight_c = 1; + char exp_nine_c = 0; + char exp_ten_c = 1; + +#endif + + unsigned char i; + for ( i = 0; i < 16; i++ ) + filler[i] = i; + + check_struct_off (one); + check_struct_off (two); + check_struct_off (three); + check_struct_off (four); + check_struct_off (five); + check_struct_off (six); + check_struct_off (seven); + check_struct_off (eight); + check_union_off (nine); + check_struct_off (ten); + + check_struct_size (one); + check_struct_size (two); + check_struct_size (three); + check_struct_size (four); + check_struct_size (five); + check_struct_size (six); + check_struct_size (seven); + check_struct_size (eight); + check_union_size (nine); + check_struct_size (ten); + + return 0; +}; diff --git a/SingleSource/Regression/C/gcc-dg/bf-no-ms-layout.c b/SingleSource/Regression/C/gcc-dg/bf-no-ms-layout.c new file mode 100644 index 0000000000..80f7f98c4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bf-no-ms-layout.c @@ -0,0 +1,231 @@ +/* bf-no-ms-layout.c */ + +/* Test for gcc bitfield layout, with -mno-ms-bitfields */ +/* Adapted from Donn Terry testcase + posted to GCC-patches + http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00577.html */ + +/* { dg-do run { target *-*-mingw* *-*-cygwin* i?86-*-darwin } } */ +/* { dg-options "-mno-ms-bitfields" } */ + +#include +#include + +extern void abort(); + +#pragma pack(8) + +struct one { + int d; + unsigned char a; + unsigned short b:7; + char c; +}; + +struct two { + int d; + unsigned char a; + unsigned int b:7; + char c; +}; + +struct three { + short d; + unsigned short a:3; + unsigned short b:9; + unsigned char c:7; +}; + + +/* Bitfields of size 0 have some truly odd behaviors. */ + +struct four { + unsigned short a:3; + unsigned short b:9; + unsigned int :0; /* forces struct alignment to int */ + unsigned char c:7; +}; + +struct five { + char a; + int :0; /* ignored; prior field is not a bitfield. */ + char b; + char c; +}; + +struct six { + char a :8; + int :0; /* not ignored; prior field IS a bitfield, causes + struct alignment as well. */ + char b; + char c; +} ; + +struct seven { + char a:8; + char :0; + int :0; /* Ignored; prior field is zero size bitfield. */ + char b; + char c; +}; + +struct eight { /* ms size 4 */ + short b:3; + char c; +}; + +#ifdef _MSC_VER +#define LONGLONG __int64 +#else +#define LONGLONG long long +#endif + +union nine { /* ms size 8 */ + LONGLONG a:3; + char c; +}; + +struct ten { /* ms size 16 */ + LONGLONG a:3; + LONGLONG b:3; + char c; +}; + + +#define val(s,f) (s.f) + +#define check_struct(_X) \ +{ \ + if (sizeof (struct _X) != exp_sizeof_##_X ) \ + abort(); \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_union(_X) \ +{ \ + if (sizeof (union _X) != exp_sizeof_##_X ) \ + abort(); \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_struct_size(_X) \ +{ \ + if (sizeof (struct _X) != exp_sizeof_##_X ) \ + abort(); \ +} + +#define check_struct_off(_X) \ +{ \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_union_size(_X) \ +{ \ + if (sizeof (union _X) != exp_sizeof_##_X ) \ + abort(); \ +} + +#define check_union_off(_X) \ +{ \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +int main(){ + + unsigned char filler[16]; + struct one test_one; + struct two test_two; + struct three test_three; + struct four test_four; + struct five test_five; + struct six test_six; + struct seven test_seven; + struct eight test_eight; + union nine test_nine; + struct ten test_ten; + +#if defined (_TEST_MS_LAYOUT) || defined (_MSC_VER) + size_t exp_sizeof_one = 12; + size_t exp_sizeof_two = 16; + size_t exp_sizeof_three =6; + size_t exp_sizeof_four = 8; + size_t exp_sizeof_five = 3; + size_t exp_sizeof_six = 8; + size_t exp_sizeof_seven = 3; + size_t exp_sizeof_eight = 4; + size_t exp_sizeof_nine = 8; + size_t exp_sizeof_ten = 16; + + unsigned char exp_one_c = 8; + unsigned char exp_two_c = 12; + unsigned char exp_three_c = 4; + unsigned char exp_four_c = 4; + char exp_five_c = 2; + char exp_six_c = 5; + char exp_seven_c = 2; + char exp_eight_c = 2; + char exp_nine_c = 0; + char exp_ten_c = 8; + +#else /* testing -mno-ms-bitfields */ + + size_t exp_sizeof_one = 8; + size_t exp_sizeof_two = 8; + size_t exp_sizeof_three = 6; + size_t exp_sizeof_four = 6; + size_t exp_sizeof_five = 6; + size_t exp_sizeof_six = 6; + size_t exp_sizeof_seven = 6; + size_t exp_sizeof_eight = 2; + size_t exp_sizeof_nine = 8; + size_t exp_sizeof_ten = 8; + + unsigned short exp_one_c = 6; + unsigned int exp_two_c = 6; + unsigned char exp_three_c = 64; + unsigned char exp_four_c = 4; + char exp_five_c = 5; + char exp_six_c = 5; + char exp_seven_c = 5; + char exp_eight_c = 1; + char exp_nine_c = 0; + char exp_ten_c = 1; + +#endif + + unsigned char i; + for ( i = 0; i < 16; i++ ) + filler[i] = i; + + check_struct_off (one); + check_struct_off (two); + check_struct_off (three); + check_struct_off (four); + check_struct_off (five); + check_struct_off (six); + check_struct_off (seven); + check_struct_off (eight); + check_union_off (nine); + check_struct_off (ten); + + check_struct_size (one); + check_struct_size (two); + check_struct_size (three); + check_struct_size (four); + check_struct_size (five); + check_struct_size (six); + check_struct_size (seven); + check_struct_size (eight); + check_union_size (nine); + check_struct_size (ten); + + return 0; +}; diff --git a/SingleSource/Regression/C/gcc-dg/bf-spl1.c b/SingleSource/Regression/C/gcc-dg/bf-spl1.c new file mode 100644 index 0000000000..1cba005239 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bf-spl1.c @@ -0,0 +1,60 @@ +/* { dg-do run { target m68k-*-* fido-*-* sparc-*-* } } */ +/* { dg-options { -O2 } } */ + +extern void abort (void); + +typedef float SFtype __attribute__ ((mode (SF))); +typedef float DFtype __attribute__ ((mode (DF))); + +typedef int HItype __attribute__ ((mode (HI))); +typedef int SItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); + +typedef unsigned int UHItype __attribute__ ((mode (HI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef unsigned int UDItype __attribute__ ((mode (DI))); + +typedef UDItype fractype; +typedef USItype halffractype; +typedef DFtype FLO_type; +typedef DItype intfrac; + + +typedef union +{ + long long foo; + FLO_type value; + struct + { + fractype fraction:52 __attribute__ ((packed)); + unsigned int exp:11 __attribute__ ((packed)); + unsigned int sign:1 __attribute__ ((packed)); + } + bits; +} FLO_union_type; + +void foo (long long a); +long long x; + +void +pack_d () +{ + FLO_union_type dst = { 0x0123456789abcdefLL }; + + x = dst.bits.fraction; +} + +int +main () +{ + pack_d (); + foo (x); + return 0; +} + +void +foo (long long a) +{ + if (a != 0x0123456789abcLL) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-13.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-13.c new file mode 100644 index 0000000000..bac86c2cfc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-13.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O0 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {<=\s* 255} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s* 4294967040} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-14.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-14.c new file mode 100644 index 0000000000..ec3bd6a7e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-14.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {<=\s* 255} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s* 4294967040} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-15.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-15.c new file mode 100644 index 0000000000..8bdf1ea4eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-15.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) >= 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) >= 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {=\s* 1} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s* 4294967040} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-16.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-16.c new file mode 100644 index 0000000000..cfea925b59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-16.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) > 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) > 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {>\s* 255} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s* 4294967040} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-17.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-17.c new file mode 100644 index 0000000000..86873b97f2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-17.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) <= 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) <= 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {<=\s* 255} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s* 4294967040} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-18.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-18.c new file mode 100644 index 0000000000..70bab0c520 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-18.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~1)) < 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~1)) < 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times { = 0;} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-19.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-19.c new file mode 100644 index 0000000000..c4620dfaad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-19.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~1)) != 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~1)) != 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {>\s* 1} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s* 4294967294} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-20.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-20.c new file mode 100644 index 0000000000..a114122e07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-20.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~5)) == 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~5)) == 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-not {<=\s* 4294967289} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump {&\s* 4294967290} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-21.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-21.c new file mode 100644 index 0000000000..bd12a58da1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-21.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(int32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(int32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +#define TYPE int32_t +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump {<=\s* 255} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s* 4294967290} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-22.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-22.c new file mode 100644 index 0000000000..a9f0867b5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-22.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) != 0; +} + +__attribute__((noinline, noipa, optimize("O0"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) != 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump {>\s* 255} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s* 4294967290} dce7 { target vect_int } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask-7.c b/SingleSource/Regression/C/gcc-dg/bic-bitmask-7.c new file mode 100644 index 0000000000..bc49f299aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask-7.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -save-temps -fdump-tree-dce" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~1)) < 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~1)) < 0; +} + +#include "bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {__builtin_memset} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/bic-bitmask.h b/SingleSource/Regression/C/gcc-dg/bic-bitmask.h new file mode 100644 index 0000000000..faf80b974d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bic-bitmask.h @@ -0,0 +1,43 @@ +#include + +#ifndef N +#define N 65 +#endif + +#ifndef TYPE +#define TYPE uint32_t +#endif + +#ifndef DEBUG +#define DEBUG 0 +#endif + +#define BASE ((TYPE) -1 < 0 ? -126 : 4) + +int main () +{ + TYPE a[N]; + TYPE b[N]; + + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 13; + b[i] = BASE + i * 13; + if (DEBUG) + printf ("%d: 0x%x\n", i, a[i]); + } + + fun1 (a, N); + fun2 (b, N); + + for (int i = 0; i < N; ++i) + { + if (DEBUG) + printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]); + + if (a[i] != b[i]) + __builtin_abort (); + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/binary-constants-1.c b/SingleSource/Regression/C/gcc-dg/binary-constants-1.c new file mode 100644 index 0000000000..b7cc5fd0db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binary-constants-1.c @@ -0,0 +1,312 @@ +/* Test for binary integer constants. */ + +/* Derived from: c99-intconst-1.c, bye Joseph Myers . */ +/* Origin: Joerg Wunsch . */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +#include + +/* Assertion that constant C is of type T. */ +#define ASSERT_CONST_TYPE(C, T) \ + do { \ + typedef T type; \ + typedef type **typepp; \ + typedef __typeof__((C)) ctype; \ + typedef ctype **ctypepp; \ + typepp x = 0; \ + ctypepp y = 0; \ + x = y; \ + y = x; \ + } while (0) + +/* (T *) if E is zero, (void *) otherwise. */ +#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E)) + +/* (T *) if E is nonzero, (void *) otherwise. */ +#define type_if(T, E) type_if_not(T, !(E)) + +/* Combine pointer types, all but one (void *). */ +#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0) +#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3)) +#define type_comb4(T1, T2, T3, T4) \ + type_comb2(T1, type_comb2(T2, type_comb2(T3, T4))) +#define type_comb6(T1, T2, T3, T4, T5, T6) \ + type_comb2(T1, \ + type_comb2(T2, \ + type_comb2(T3, \ + type_comb2(T4, \ + type_comb2(T5, T6))))) + +/* (T1 *) if E1, otherwise (T2 *) if E2. */ +#define first_of2p(T1, E1, T2, E2) type_comb2(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2)))) +/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3. */ +#define first_of3p(T1, E1, T2, E2, T3, E3) \ + type_comb3(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2))), \ + type_if(T3, (!(E1) && !(E2) && (E3)))) +/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3, otherwise + (T4 *) if E4. */ +#define first_of4p(T1, E1, T2, E2, T3, E3, T4, E4) \ + type_comb4(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2))), \ + type_if(T3, (!(E1) && !(E2) && (E3))), \ + type_if(T4, (!(E1) && !(E2) && !(E3) && (E4)))) +/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3, otherwise + (T4 *) if E4, otherwise (T5 *) if E5, otherwise (T6 *) if E6. */ +#define first_of6p(T1, E1, T2, E2, T3, E3, T4, E4, T5, E5, T6, E6) \ + type_comb6(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2))), \ + type_if(T3, (!(E1) && !(E2) && (E3))), \ + type_if(T4, (!(E1) && !(E2) && !(E3) && (E4))), \ + type_if(T5, (!(E1) && !(E2) && !(E3) && !(E4) && (E5))), \ + type_if(T6, (!(E1) && !(E2) && !(E3) \ + && !(E4) && !(E5) && (E6)))) + +/* Likewise, but return the original type rather than a pointer type. */ +#define first_of2(T1, E1, T2, E2) \ + __typeof__(*((first_of2p(T1, (E1), T2, (E2)))0)) +#define first_of3(T1, E1, T2, E2, T3, E3) \ + __typeof__(*((first_of3p(T1, (E1), T2, (E2), T3, (E3)))0)) +#define first_of4(T1, E1, T2, E2, T3, E3, T4, E4) \ + __typeof__(*((first_of4p(T1, (E1), T2, (E2), T3, (E3), T4, (E4)))0)) +#define first_of6(T1, E1, T2, E2, T3, E3, T4, E4, T5, E5, T6, E6) \ + __typeof__(*((first_of6p(T1, (E1), T2, (E2), T3, (E3), \ + T4, (E4), T5, (E5), T6, (E6)))0)) + +/* Types of constants according to the C99 rules. */ +#define C99_UNSUF_TYPE(C) \ + first_of6(int, (C) <= INT_MAX, \ + unsigned int, (C) <= UINT_MAX, \ + long int, (C) <= LONG_MAX, \ + unsigned long int, (C) <= ULONG_MAX, \ + long long int, (C) <= LLONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) +#define C99_SUFu_TYPE(C) \ + first_of3(unsigned int, (C) <= UINT_MAX, \ + unsigned long int, (C) <= ULONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) +#define C99_SUFl_TYPE(C) \ + first_of4(long int, (C) <= LONG_MAX, \ + unsigned long int, (C) <= ULONG_MAX, \ + long long int, (C) <= LLONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) +#define C99_SUFul_TYPE(C) \ + first_of2(unsigned long int, (C) <= ULONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) +#define C99_SUFll_TYPE(C) \ + first_of2(long long int, (C) <= LLONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) + +/* Checks that constants have correct type. */ +#define CHECK_UNSUF_TYPE(C) \ + ASSERT_CONST_TYPE((C), C99_UNSUF_TYPE((C))) +#define CHECK_SUFu_TYPE(C) ASSERT_CONST_TYPE((C), C99_SUFu_TYPE((C))) +#define CHECK_SUFl_TYPE(C) \ + ASSERT_CONST_TYPE((C), C99_SUFl_TYPE((C))) +#define CHECK_SUFul_TYPE(C) ASSERT_CONST_TYPE((C), C99_SUFul_TYPE((C))) +#define CHECK_SUFll_TYPE(C) \ + ASSERT_CONST_TYPE((C), C99_SUFll_TYPE((C))) +#define CHECK_SUFull_TYPE(C) ASSERT_CONST_TYPE((C), unsigned long long int) + +/* Check an octal or hexadecimal value, with all suffixes. */ +#define CHECK_CONST(C) \ + CHECK_UNSUF_TYPE(C); \ + CHECK_SUFu_TYPE(C##u); \ + CHECK_SUFu_TYPE(C##U); \ + CHECK_SUFl_TYPE(C##l); \ + CHECK_SUFl_TYPE(C##L); \ + CHECK_SUFul_TYPE(C##ul); \ + CHECK_SUFul_TYPE(C##uL); \ + CHECK_SUFul_TYPE(C##Ul); \ + CHECK_SUFul_TYPE(C##UL); \ + CHECK_SUFll_TYPE(C##ll); \ + CHECK_SUFll_TYPE(C##LL); \ + CHECK_SUFull_TYPE(C##ull); \ + CHECK_SUFull_TYPE(C##uLL); \ + CHECK_SUFull_TYPE(C##Ull); \ + CHECK_SUFull_TYPE(C##ULL); + +#define CHECK_BIN_CONST(C) \ + CHECK_CONST(0b##C); \ + CHECK_CONST(0B##C); + +/* True iff "long long" is at least B bits. This presumes that (B-2)/3 is at + most 63. */ +#define LLONG_AT_LEAST(B) \ + (LLONG_MAX >> ((B)-2)/3 >> ((B)-2)/3 \ + >> ((B)-2 - ((B)-2)/3 - ((B)-2)/3)) + +#define LLONG_HAS_BITS(B) (LLONG_AT_LEAST((B)) && !LLONG_AT_LEAST((B) + 1)) + +#define FOO 0b1101 +#if !FOO +# error "preprocessor does not accept binary constants" +#endif + +void +foo (void) +{ + /* Check all 2^n and 2^n - 1 up to 2^72 - 1. */ + CHECK_BIN_CONST(1); + CHECK_BIN_CONST(10); + CHECK_BIN_CONST(11); + CHECK_BIN_CONST(100); + CHECK_BIN_CONST(111); + CHECK_BIN_CONST(1000); + CHECK_BIN_CONST(1111); + CHECK_BIN_CONST(10000); + CHECK_BIN_CONST(11111); + CHECK_BIN_CONST(100000); + CHECK_BIN_CONST(111111); + CHECK_BIN_CONST(1000000); + CHECK_BIN_CONST(1111111); + CHECK_BIN_CONST(10000000); + CHECK_BIN_CONST(11111111); + CHECK_BIN_CONST(100000000); + CHECK_BIN_CONST(111111111); + CHECK_BIN_CONST(1000000000); + CHECK_BIN_CONST(1111111111); + CHECK_BIN_CONST(10000000000); + CHECK_BIN_CONST(11111111111); + CHECK_BIN_CONST(100000000000); + CHECK_BIN_CONST(111111111111); + CHECK_BIN_CONST(1000000000000); + CHECK_BIN_CONST(1111111111111); + CHECK_BIN_CONST(10000000000000); + CHECK_BIN_CONST(11111111111111); + CHECK_BIN_CONST(100000000000000); + CHECK_BIN_CONST(111111111111111); + CHECK_BIN_CONST(1000000000000000); + CHECK_BIN_CONST(1111111111111111); + CHECK_BIN_CONST(10000000000000000); + CHECK_BIN_CONST(11111111111111111); + CHECK_BIN_CONST(100000000000000000); + CHECK_BIN_CONST(111111111111111111); + CHECK_BIN_CONST(1000000000000000000); + CHECK_BIN_CONST(1111111111111111111); + CHECK_BIN_CONST(10000000000000000000); + CHECK_BIN_CONST(11111111111111111111); + CHECK_BIN_CONST(100000000000000000000); + CHECK_BIN_CONST(111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111111111111111111); + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111111111111111111111); +#if LLONG_AT_LEAST(65) + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111111111111111111111); +#endif +#if LLONG_AT_LEAST(66) + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111111111111111111111); +#endif +#if LLONG_AT_LEAST(67) + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111111111111111111111111); +#endif +#if LLONG_AT_LEAST(68) + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111111111111111111111111); +#endif +#if LLONG_AT_LEAST(69) + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111111111111111111111111); +#endif +#if LLONG_AT_LEAST(70) + CHECK_BIN_CONST(1000000000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(1111111111111111111111111111111111111111111111111111111111111111111111); +#endif +#if LLONG_AT_LEAST(71) + CHECK_BIN_CONST(10000000000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(11111111111111111111111111111111111111111111111111111111111111111111111); +#endif +#if LLONG_AT_LEAST(72) + CHECK_BIN_CONST(100000000000000000000000000000000000000000000000000000000000000000000000); + CHECK_BIN_CONST(111111111111111111111111111111111111111111111111111111111111111111111111); +#endif +} + diff --git a/SingleSource/Regression/C/gcc-dg/binary-constants-2.c b/SingleSource/Regression/C/gcc-dg/binary-constants-2.c new file mode 100644 index 0000000000..5339d57b99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binary-constants-2.c @@ -0,0 +1,16 @@ +/* Test for binary integer constants: -pedantic warnings. */ + +/* Origin: Joerg Wunsch . */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic -ftrack-macro-expansion=0" } */ + +#define FOO 0b1101 + +int +foo (void) +{ +#if FOO /* { dg-warning "binary constants are a C2X feature or GCC extension" } */ + return 23; +#endif + return 0b1101; /* { dg-warning "binary constants are a C2X feature or GCC extension" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/binary-constants-3.c b/SingleSource/Regression/C/gcc-dg/binary-constants-3.c new file mode 100644 index 0000000000..5b49cb4efb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binary-constants-3.c @@ -0,0 +1,16 @@ +/* Test for binary integer constants: -pedantic-errors. */ + +/* Origin: Joerg Wunsch . */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -ftrack-macro-expansion=0" } */ + +#define FOO 0b1101 + +int +foo (void) +{ +#if FOO /* { dg-error "binary constants are a C2X feature or GCC extension" } */ + return 23; +#endif + return 0b1101; /* { dg-error "binary constants are a C2X feature or GCC extension" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/binary-constants-4.c b/SingleSource/Regression/C/gcc-dg/binary-constants-4.c new file mode 100644 index 0000000000..32c9d65a5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binary-constants-4.c @@ -0,0 +1,18 @@ +/* Test for binary integer constants: random errors. */ + +/* Origin: Joerg Wunsch . */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void +foo(void) +{ + double d; + int i; + + d = 0b1101; + d = 0b1101p1; /* { dg-error "invalid suffix \"p1\" on integer constant" } */ + d = 0x1101p1; + i = 0b3011; /* { dg-error "invalid suffix \"b3011\" on integer constant" } */ + i = 0b113; /* { dg-error "invalid digit \"3\" in binary constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand1.c b/SingleSource/Regression/C/gcc-dg/binop-notand1.c new file mode 100644 index 0000000000..7a56aa6128 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b) +{ + return (a & !a) | (b & !b); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand1a.c b/SingleSource/Regression/C/gcc-dg/binop-notand1a.c new file mode 100644 index 0000000000..c7e932b263 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand1a.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (char a, unsigned short b) +{ + return (a & !a) | (b & !b); +} + +/* As long as comparisons aren't boolified and casts from boolean-types + aren't preserved, the folding of X & !X to zero fails. */ +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand2.c b/SingleSource/Regression/C/gcc-dg/binop-notand2.c new file mode 100644 index 0000000000..40613548ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a) +{ + return (!a & 1) != (a == 0); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand2a.c b/SingleSource/Regression/C/gcc-dg/binop-notand2a.c new file mode 100644 index 0000000000..40613548ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand2a.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a) +{ + return (!a & 1) != (a == 0); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand3.c b/SingleSource/Regression/C/gcc-dg/binop-notand3.c new file mode 100644 index 0000000000..2fc1652ff1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand3.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a) +{ + return (!a & 1) != ((a == 0) & 1); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand3a.c b/SingleSource/Regression/C/gcc-dg/binop-notand3a.c new file mode 100644 index 0000000000..26f351b70b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand3a.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (short a) +{ + return (!a & 1) != ((a == 0) & 1); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand4.c b/SingleSource/Regression/C/gcc-dg/binop-notand4.c new file mode 100644 index 0000000000..d6ed6b54eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand4.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b) +{ + return (!a & a) | (b & !b); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand4a.c b/SingleSource/Regression/C/gcc-dg/binop-notand4a.c new file mode 100644 index 0000000000..dce6a5c7eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand4a.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (unsigned char a, _Bool b) +{ + return (!a & a) | (b & !b); +} + +/* As long as comparisons aren't boolified and casts from boolean-types + aren't preserved, the folding of X & !X to zero fails. */ +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand5.c b/SingleSource/Regression/C/gcc-dg/binop-notand5.c new file mode 100644 index 0000000000..3b74990942 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand5.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b) +{ + return (a & (a == 0)) | (b & !b); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand5a.c b/SingleSource/Regression/C/gcc-dg/binop-notand5a.c new file mode 100644 index 0000000000..378752b06d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand5a.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (long a, unsigned long b) +{ + return (a & (a == 0)) | (b & !b); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand6.c b/SingleSource/Regression/C/gcc-dg/binop-notand6.c new file mode 100644 index 0000000000..040efc92d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand6.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b) +{ + return (a & !a) | (b & (b == 0)); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notand6a.c b/SingleSource/Regression/C/gcc-dg/binop-notand6a.c new file mode 100644 index 0000000000..9f3d33b526 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notand6a.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (unsigned long a, long b) +{ + return (a & !a) | (b & (b == 0)); +} + +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notor1.c b/SingleSource/Regression/C/gcc-dg/binop-notor1.c new file mode 100644 index 0000000000..0f2dc38d27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notor1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (_Bool a, _Bool b) +{ + return (a | !a) | (!b | b); +} + +/* { dg-final { scan-tree-dump-times "return 1" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notor2.c b/SingleSource/Regression/C/gcc-dg/binop-notor2.c new file mode 100644 index 0000000000..7dacfa07f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notor2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (_Bool a, _Bool b) +{ + return (a | (a == 0)) | ((b ^ 1) | b); +} + +/* { dg-final { scan-tree-dump-times "return 1" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notxor1.c b/SingleSource/Regression/C/gcc-dg/binop-notxor1.c new file mode 100644 index 0000000000..f0ff203ad4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notxor1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (_Bool a, _Bool b) +{ + return (a ^ !a) | (!b ^ b); +} + +/* { dg-final { scan-tree-dump-times "return 1" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-notxor2.c b/SingleSource/Regression/C/gcc-dg/binop-notxor2.c new file mode 100644 index 0000000000..4a8d586922 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-notxor2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (_Bool a, _Bool b) +{ + return (a ^ (a == 0)) | ((b == 0) ^ b); +} + +/* { dg-final { scan-tree-dump-times "return 1" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-xor1.c b/SingleSource/Regression/C/gcc-dg/binop-xor1.c new file mode 100644 index 0000000000..dea11e50d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-xor1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */ + +int +foo (int a, int b, int c) +{ + return ((a && !b && c) || (!a && b && c)); +} + +/* { dg-final { scan-tree-dump-times "\\\^" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-xor2.c b/SingleSource/Regression/C/gcc-dg/binop-xor2.c new file mode 100644 index 0000000000..1da1a26aa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-xor2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b) +{ + return ((a & ~b) | (~a & b)); +} + +/* We expect to see ""; confirm that, so that we know to count + it in the real test. */ +/* { dg-final { scan-tree-dump-times "\]*>" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\\^" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-xor3.c b/SingleSource/Regression/C/gcc-dg/binop-xor3.c new file mode 100644 index 0000000000..82a17b89fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-xor3.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b) +{ + return ((a && !b) || (!a && b)); +} + +/* { dg-final { scan-tree-dump-times "\\\^" 1 "optimized" { target i?86-*-* x86_64-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-xor4.c b/SingleSource/Regression/C/gcc-dg/binop-xor4.c new file mode 100644 index 0000000000..bafa4bb32a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-xor4.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b, int c) +{ + return ((a & ~b) | (~a & b)) & c; +} + +/* We expect to see ""; confirm that, so that we know to count + it in the real test. */ +/* { dg-final { scan-tree-dump-times "\]*>" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\\^" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/binop-xor5.c b/SingleSource/Regression/C/gcc-dg/binop-xor5.c new file mode 100644 index 0000000000..55d59450a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/binop-xor5.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b, int c) +{ + return ((a & ~b & c) | (~a & b & c)); +} + +/* We expect to see ""; confirm that, so that we know to count + it in the real test. */ +/* { dg-final { scan-tree-dump-times "\]*>" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\\^" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\&" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-1.c b/SingleSource/Regression/C/gcc-dg/bitfld-1.c new file mode 100644 index 0000000000..246e07c589 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-1.c @@ -0,0 +1,31 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + + Tests various diagnostics about a bit-field's type and width. + + Source: Neil Booth, 26 Jan 2002. +*/ + +/* { dg-options "-pedantic -std=gnu89" } */ + +enum foo {e1 = 0, e2, e3, e4, e5}; + +int x; +typedef unsigned int ui; + +struct bf1 +{ + unsigned int a: 3.5; /* { dg-error "integer constant" } */ + unsigned int b: x; /* { dg-error "integer constant" } */ + unsigned int c: -1; /* { dg-error "negative width" } */ + unsigned int d: 0; /* { dg-error "zero width" } */ + unsigned int : 0; /* { dg-bogus "zero width" } */ + unsigned int : 5; + double e: 1; /* { dg-error "invalid type" } */ + float f: 1; /* { dg-error "invalid type" } */ + unsigned long g: 5; /* { dg-warning "GCC extension|ISO C" } */ + ui h: 5; + enum foo i: 2; /* { dg-warning "narrower" } */ + /* { dg-warning "GCC extension|ISO C" "extension" { target *-*-* } .-1 } */ + enum foo j: 3; /* { dg-warning "GCC extension|ISO C" } */ + unsigned int k: 256; /* { dg-error "exceeds its type" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-10.c b/SingleSource/Regression/C/gcc-dg/bitfld-10.c new file mode 100644 index 0000000000..ce72231491 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-10.c @@ -0,0 +1,8 @@ +/* Test for rejection of sizeof on bit-fields. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a : 1; } x; + +int r = sizeof (x.a); /* { dg-error "'sizeof' applied to a bit-field" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-11.c b/SingleSource/Regression/C/gcc-dg/bitfld-11.c new file mode 100644 index 0000000000..c7fe6a510a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-11.c @@ -0,0 +1,8 @@ +/* Test for rejection of __alignof on bit-fields. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a : 1; } x; + +int r = __alignof (x.a); /* { dg-error "'__alignof' applied to a bit-field" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-12.c b/SingleSource/Regression/C/gcc-dg/bitfld-12.c new file mode 100644 index 0000000000..1270d9b340 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-12.c @@ -0,0 +1,12 @@ +/* Test for rejection of taking address of bit-fields. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include + +struct s { int a : 1; } x, *y; + +int a = offsetof (struct s, a); /* { dg-error "attempt to take address of bit-field structure member 'a'" } */ +void *b = &x.a; /* { dg-error "cannot take address of bit-field 'a'" } */ +void *c = &y->a; /* { dg-error "cannot take address of bit-field 'a'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-13.c b/SingleSource/Regression/C/gcc-dg/bitfld-13.c new file mode 100644 index 0000000000..fcb381c86b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-13.c @@ -0,0 +1,14 @@ +/* Test invalid bit-field types: bug 18498. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int +main(void) +{ + struct X { + int s[20] : 1; /* { dg-error "bit-field 's' has invalid type" } */ + int *p : 2; /* { dg-error "bit-field 'p' has invalid type" } */ + int (*f)(float) : 3; /* { dg-error "bit-field 'f' has invalid type" } */ + } x; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-14.c b/SingleSource/Regression/C/gcc-dg/bitfld-14.c new file mode 100644 index 0000000000..de1971cd20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-14.c @@ -0,0 +1,11 @@ +/* Test for non-integer bit-field widths. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum e { E, F }; +struct s { + int a : (void *)4; /* { dg-error "bit-field 'a' width not an integer constant" } */ + int b : (enum e)F; + int c : (_Bool)1; +}; diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-15.c b/SingleSource/Regression/C/gcc-dg/bitfld-15.c new file mode 100644 index 0000000000..32878d74db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-15.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* Remove pedantic. Allow the GCC extension to use char for bitfields. */ +/* { dg-options "" } */ +/* { dg-options "-mno-ms-bitfields -Wno-packed-bitfield-compat" { target { i?86-*-mingw* x86_64-*-mingw* } } } */ + +struct t +{ + char a:4; + char b:8; + char c:4; +} __attribute__ ((packed)); /* { dg-message "note: offset of packed bit-field 'b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */ + +int assrt[sizeof (struct t) == 2 ? 1 : -1]; diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-16.c b/SingleSource/Regression/C/gcc-dg/bitfld-16.c new file mode 100644 index 0000000000..75d290f00e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-16.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-packed-bitfield-compat" } */ +/* { dg-options "-Wno-packed-bitfield-compat -mno-ms-bitfields" { target { i?86-*-mingw* x86_64-*-mingw* } } } */ + +struct t +{ + char a:4; + char b:8; + char c:4; +} __attribute__ ((packed)); + +int assrt[sizeof (struct t) == 2 ? 1 : -1]; diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-17.c b/SingleSource/Regression/C/gcc-dg/bitfld-17.c new file mode 100644 index 0000000000..6dc6989df7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-17.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-options "-mno-ms-bitfields -Wno-packed-bitfield-compat" { target { i?86-*-mingw* x86_64-*-mingw* } } } */ + +struct t +{ + char a:4; + char b:8 __attribute__ ((packed)); + char c:4; +}; /* { dg-message "note: offset of packed bit-field 'b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */ + +int assrt[sizeof (struct t) == 2 ? 1 : -1]; diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-18.c b/SingleSource/Regression/C/gcc-dg/bitfld-18.c new file mode 100644 index 0000000000..748669543c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-18.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-packed-bitfield-compat" } */ +/* { dg-options "-Wno-packed-bitfield-compat -mno-ms-bitfields" { target { i?86-*-mingw* x86_64-*-mingw* } } } */ + +struct t +{ + char a:4; + char b:8 __attribute__ ((packed)); + char c:4; +}; + +int assrt[sizeof (struct t) == 2 ? 1 : -1]; diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-19.c b/SingleSource/Regression/C/gcc-dg/bitfld-19.c new file mode 100644 index 0000000000..072e93c2ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-19.c @@ -0,0 +1,11 @@ +/* Test for bit-field widths not integer constant expressions but + folding to integer constants: PR 42439. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +f (void) +{ + const int m = 1; + ((void)(sizeof(struct { int i:!!m; }))); +} diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-2.c b/SingleSource/Regression/C/gcc-dg/bitfld-2.c new file mode 100644 index 0000000000..92cf2f6cc2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-2.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + + Tests we warn about overly-large assignments to bitfields. + + Source: Neil Booth, 28 Jan 2002. +*/ + +struct bf +{ + unsigned int a: 2; + int b: 2; +}; + +struct bf p = {4, 0}; /* { dg-warning "unsigned conversion from .int. to 'unsigned char:2' changes value from .4. to .0." } */ +struct bf q = {0, 2}; /* { dg-warning "overflow in conversion from .int. to .signed char:2. changes value from .2. to .-2." } */ +struct bf r = {3, -2}; /* { dg-bogus "(trunc|overflow)" } */ + +void foo () +{ + p.a = 4, p.b = 0; /* { dg-warning "unsigned conversion from .int. to .unsigned char:2. changes value from .4. to .0." } */ + q.a = 0, q.b = 2; /* { dg-warning "overflow in conversion from .int. to .signed char:2. changes value from .2. to .-2." } */ + r.a = 3, r.b = -2; /* { dg-bogus "(trunc|overflow)" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-20.c b/SingleSource/Regression/C/gcc-dg/bitfld-20.c new file mode 100644 index 0000000000..63aaa5c8dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-20.c @@ -0,0 +1,11 @@ +/* Test for bit-field widths not integer constant expressions but + folding to integer constants: PR 42439. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -pedantic" } */ + +void +f (void) +{ + const int m = 1; + ((void)(sizeof(struct { int i:!!m; }))); /* { dg-warning "not an integer constant expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-21.c b/SingleSource/Regression/C/gcc-dg/bitfld-21.c new file mode 100644 index 0000000000..66f9330f19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-21.c @@ -0,0 +1,11 @@ +/* Test for bit-field widths not integer constant expressions but + folding to integer constants: PR 42439. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -pedantic-errors" } */ + +void +f (void) +{ + const int m = 1; + ((void)(sizeof(struct { int i:!!m; }))); /* { dg-error "not an integer constant expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-22.c b/SingleSource/Regression/C/gcc-dg/bitfld-22.c new file mode 100644 index 0000000000..2fb904bce2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-22.c @@ -0,0 +1,18 @@ +/* PR c/70671 */ +/* { dg-do compile } */ + +extern void bar (int *); + +struct S +{ + int x:2; +} s, *r; + +void +foo (void) +{ + int *p1 = &s.x; /* { dg-error "13:cannot take address of bit-field 'x'" } */ + int *p2; + p2 = &s.x; /* { dg-error "8:cannot take address of bit-field 'x'" } */ + bar (&s.x); /* { dg-error "8:cannot take address of bit-field 'x'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-3.c b/SingleSource/Regression/C/gcc-dg/bitfld-3.c new file mode 100644 index 0000000000..5207bedb88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-3.c @@ -0,0 +1,67 @@ +/* Test for bitfield alignment in structs and unions. */ +/* { dg-do run { target pcc_bitfield_type_matters } } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); + +typedef long la __attribute__((aligned (8))); + +struct A +{ + char a; + union UA + { + char x; + la y : 6; + } b; + char c; +} a; + +struct B +{ + char a; + union UB + { + char x; + long y : 6 __attribute__((aligned (8))); + } b; + char c; +} b; + +struct C +{ + char a; + struct UC + { + la y : 6; + } b; + char c; +} c; + +struct D +{ + char a; + struct UD + { + long y : 6 __attribute__((aligned (8))); + } b; + char c; +} d; + +int main (void) +{ + if (sizeof (a) != sizeof (b)) + abort (); + if (sizeof (a) != sizeof (c)) + abort (); + if (sizeof (a) != sizeof (d)) + abort (); + if ((&a.c - &a.a) != (&b.c - &b.a)) + abort (); + if ((&a.c - &a.a) != (&c.c - &c.a)) + abort (); + if ((&a.c - &a.a) != (&d.c - &d.a)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-4.c b/SingleSource/Regression/C/gcc-dg/bitfld-4.c new file mode 100644 index 0000000000..e642bec5ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-4.c @@ -0,0 +1,42 @@ +/* { dg-do run { target { pcc_bitfield_type_matters || default_packed } } } */ +/* { dg-options "" } */ + +/* Check bitfields and non-bitfields are aligned & sized similarly. + + Copyright (C) 2002 Free Software Foundation Inc + Contributed by Nathan Sidwell +*/ + +#include +#include + +static int fail; + +#define CHECK1(N, T) do { \ + typedef struct Field_##N { char c; T f; } Field_##N; \ + typedef struct BitField_##N { char c; T f : sizeof (T) * CHAR_BIT; } BitField_##N; \ + if (sizeof (Field_##N) != sizeof (BitField_##N)) { \ + fail = 1; printf ("sizeof %s failed\n", #T); \ + } \ + if (__alignof__ (Field_##N) != __alignof__ (BitField_##N)) { \ + fail = 1; printf ("__alignof__ %s failed\n", #T); \ + } \ +} while (0) + +#define CHECK(N, T) do { \ + CHECK1(N, T); \ + CHECK1 (s##N, signed T); \ + CHECK1 (u##N, unsigned T); \ +} while (0) + +int main () +{ + + CHECK (c, char); + CHECK (s, short); + CHECK (i, int); + CHECK (l, long); + CHECK (ll, long long); + + return fail; +} diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-5.c b/SingleSource/Regression/C/gcc-dg/bitfld-5.c new file mode 100644 index 0000000000..835bbce323 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-5.c @@ -0,0 +1,12 @@ +/* { dg-options "" } */ +#include + +struct s +{ + int i1 : sizeof (int) * CHAR_BIT; + int i2 : sizeof (int) * CHAR_BIT; + int i3 : sizeof (int) * CHAR_BIT; + int i4 : sizeof (int) * CHAR_BIT; +}; + +int f[sizeof (struct s) != sizeof (int) * 4 ? -1 : 1]; diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-6.c b/SingleSource/Regression/C/gcc-dg/bitfld-6.c new file mode 100644 index 0000000000..a9a7f40999 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-6.c @@ -0,0 +1,16 @@ +/* { dg-options "" } */ +#include + +struct s +{ + int i1 : sizeof (int) * CHAR_BIT; + int i2 : sizeof (int) * CHAR_BIT; + int i3 : sizeof (int) * CHAR_BIT; + int i4 : sizeof (int) * CHAR_BIT; + int i5 : sizeof (int) * CHAR_BIT; + int i6 : sizeof (int) * CHAR_BIT; + int i7 : sizeof (int) * CHAR_BIT; + int i8 : sizeof (int) * CHAR_BIT; +}; + +int f[sizeof (struct s) != sizeof (int) * 8 ? -1 : 1]; diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-7.c b/SingleSource/Regression/C/gcc-dg/bitfld-7.c new file mode 100644 index 0000000000..fdaa93f261 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-7.c @@ -0,0 +1,8 @@ +/* Test for rejection of typeof on bit-fields. PR c/10333. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-fshow-column" } */ + +struct { int a:1; } x; + +typeof (x.a) z; /* { dg-error "9:applied to a bit-field" "typeof" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-8.c b/SingleSource/Regression/C/gcc-dg/bitfld-8.c new file mode 100644 index 0000000000..c73642c79d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-8.c @@ -0,0 +1,7 @@ +/* Test that too wide bit-fields are hard errors. PR c/3347. */ +/* Origin: Joseph Myers , from PR c/3347 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int i : 1999; } x; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "width" "bit-field too wide" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitfld-9.c b/SingleSource/Regression/C/gcc-dg/bitfld-9.c new file mode 100644 index 0000000000..c580e15ac5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitfld-9.c @@ -0,0 +1,119 @@ +/* Test -funsigned-bitfields works. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-funsigned-bitfields -fsigned-char -std=gnu89" } */ + +typedef char c; +typedef signed char sc; +typedef unsigned char uc; +typedef short s; +typedef signed short ss; +typedef unsigned short us; +typedef n; +typedef int i; +typedef signed int si; +typedef unsigned int ui; +typedef long l; +typedef signed long sl; +typedef unsigned long ul; +typedef long long ll; +typedef signed long long sll; +typedef unsigned long long ull; + +typedef c ct; +typedef sc sct; +typedef uc uct; +typedef s st; +typedef ss sst; +typedef us ust; +typedef n nt; +typedef i it; +typedef si sit; +typedef ui uit; +typedef l lt; +typedef sl slt; +typedef ul ult; +typedef ll llt; +typedef sll sllt; +typedef ull ullt; + +struct foo { + char char0 : 1; + c char1 : 1; + ct char2 : 1; + signed char schar0 : 1; + sc schar1 : 1; + sct schar2 : 1; + unsigned char uchar0 : 1; + uc uchar1 : 1; + uct uchar2 : 1; + short short0 : 1; + s short1 : 1; + st short2 : 1; + signed short sshort0 : 1; + ss sshort1 : 1; + sst sshort2 : 1; + unsigned short ushort0 : 1; + us ushort1 : 1; + ust ushort2 : 1; + __attribute__((dummy)) int0 : 1; /* { dg-warning "attribute directive ignored" } */ + n int1 : 1; + nt int2 : 1; + int int3 : 1; + i int4 : 1; + it int5 : 1; + signed int sint0 : 1; + si sint1 : 1; + sit sint2 : 1; + unsigned int uint0 : 1; + ui uint1 : 1; + uit uint2 : 1; + long long0 : 1; + l long1 : 1; + lt long2 : 1; + signed long slong0 : 1; + sl slong1 : 1; + slt slong2 : 1; + unsigned long ulong0 : 1; + ul ulong1 : 1; + ult ulong2 : 1; + long long llong0 : 1; + ll llong1 : 1; + llt llong2 : 1; + signed long long sllong0 : 1; + sll sllong1 : 1; + sllt sllong2 : 1; + unsigned long long ullong0 : 1; + ull ullong1 : 1; + ullt ullong2 : 1; +}; + +struct foo x; + +extern void abort (void); +extern void exit (int); +extern void *memset (void *, int, __SIZE_TYPE__); + +int +main (void) +{ + memset (&x, (unsigned char)-1, sizeof(x)); + if (x.char0 != 1 || x.char1 != 1 || x.char2 != 1 + || x.schar0 != -1 || x.schar1 != -1 || x.schar2 != -1 + || x.uchar0 != 1 || x.uchar1 != 1 || x.uchar2 != 1 + || x.short0 != 1 || x.short1 != 1 || x.short2 != 1 + || x.sshort0 != -1 || x.sshort1 != -1 || x.sshort2 != -1 + || x.ushort0 != 1 || x.ushort1 != 1 || x.ushort2 != 1 + || x.int0 != 1 || x.int1 != 1 || x.int2 != 1 + || x.int3 != 1 || x.int4 != 1 || x.int5 != 1 + || x.sint0 != -1 || x.sint1 != -1 || x.sint2 != -1 + || x.uint0 != 1 || x.uint1 != 1 || x.uint2 != 1 + || x.long0 != 1 || x.long1 != 1 || x.long2 != 1 + || x.slong0 != -1 || x.slong1 != -1 || x.slong2 != -1 + || x.ulong0 != 1 || x.ulong1 != 1 || x.ulong2 != 1 + || x.llong0 != 1 || x.llong1 != 1 || x.llong2 != 1 + || x.sllong0 != -1 || x.sllong1 != -1 || x.sllong2 != -1 + || x.ullong0 != 1 || x.ullong1 != 1 || x.ullong2 != 1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-1.c b/SingleSource/Regression/C/gcc-dg/bitint-1.c new file mode 100644 index 0000000000..0daa2b9bbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-1.c @@ -0,0 +1,26 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x" } */ + +void +foo (int x) +{ + _BitInt (1) a; /* { dg-error "'signed _BitInt' argument must be at least 2" } */ + signed _BitInt (1) b; /* { dg-error "'signed _BitInt' argument must be at least 2" } */ + _BitInt (0) c; /* { dg-error "'_BitInt' argument '0' is not a positive integer constant expression" } */ + unsigned _BitInt (0) d; /* { dg-error "'_BitInt' argument '0' is not a positive integer constant expression" } */ + _BitInt (-42) e; /* { dg-error "'_BitInt' argument '-42' is not a positive integer constant expression" } */ + _BitInt (-5) unsigned f; /* { dg-error "'_BitInt' argument '-5' is not a positive integer constant expression" } */ + _BitInt (4294967295ULL) g; /* { dg-error "'_BitInt' argument '4294967295' is larger than 'BITINT_MAXWIDTH' '\[0-9]+'" } */ + long _BitInt (42) h; /* { dg-error "both 'long' and '_BitInt' in declaration specifiers" } */ + long long _BitInt (42) i; /* { dg-error "both 'long' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) long j; /* { dg-error "both 'long' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) long long k; /* { dg-error "both 'long' and '_BitInt' in declaration specifiers" } */ + short _BitInt (42) l; /* { dg-error "both 'short' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) short m; /* { dg-error "both 'short' and '_BitInt' in declaration specifiers" } */ + _Complex _BitInt (42) n; /* { dg-error "both 'complex' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) _Complex o; /* { dg-error "both 'complex' and '_BitInt' in declaration specifiers" } */ + int _BitInt (42) p; /* { dg-error "two or more data types in declaration specifiers" } */ + _BitInt (42) int q; /* { dg-error "two or more data types in declaration specifiers" } */ + _BitInt (x) r; /* { dg-error "'_BitInt' argument is not an integer constant expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-10.c b/SingleSource/Regression/C/gcc-dg/bitint-10.c new file mode 100644 index 0000000000..ac59014ac1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-10.c @@ -0,0 +1,15 @@ +/* PR c/102989 */ +/* { dg-do compile { target { bitint && dfp } } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 129 +void +foo (_BitInt(129) *x, _Decimal64 *y) +{ + x[0] = y[0]; + y[1] = x[1]; +} +#endif + +/* _Decimal* <-> _BitInt conversions are unsupported for now. */ +/* { dg-prune-output "unsupported conversion between" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitint-11.c b/SingleSource/Regression/C/gcc-dg/bitint-11.c new file mode 100644 index 0000000000..1b257ec331 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-11.c @@ -0,0 +1,9 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +int +foo (_BitInt(127) x, _BitInt(127) y) +{ + return x < y; +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-12.c b/SingleSource/Regression/C/gcc-dg/bitint-12.c new file mode 100644 index 0000000000..ed75fd12c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-12.c @@ -0,0 +1,31 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=gnu2x -w" } */ + +_BitInt(37) +foo (_BitInt(37) x, _BitInt(37) y) +{ + _BitInt(37) w; + __asm ("# %0 %1 %2 %3" : "=r" (w) : "r" (x), "r" (x + y), "g" (68719476735wb)); + return w; +} + +#if __BITINT_MAXWIDTH__ >= 125 +_BitInt(125) +bar (_BitInt(125) x, _BitInt(125) y) +{ + _BitInt(125) w; + __asm ("# %0 %1 %2 %3" : "=g" (w) : "g" (x), "g" (x + y), "g" (21267647932558653966460912964485513215wb)); + return w; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +_BitInt(575) +baz (_BitInt(575) x, _BitInt(575) y) +{ + _BitInt(575) w; + __asm ("# %0 %1 %2 %3" : "=g" (w) : "g" (x), "g" (x + y), "g" (61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb)); + return w; +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-13.c b/SingleSource/Regression/C/gcc-dg/bitint-13.c new file mode 100644 index 0000000000..2810767112 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-13.c @@ -0,0 +1,17 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 315 +_Bool +foo (_BitInt (315) a, _BitInt (315) b, unsigned *c) +{ + if (a < -8 || a > 7) + __builtin_unreachable (); + if (b < 0 || b > 63) + __builtin_unreachable (); + return __builtin_add_overflow (a, b, c); +} +#else +int i; +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-14.c b/SingleSource/Regression/C/gcc-dg/bitint-14.c new file mode 100644 index 0000000000..4c3c86417c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-14.c @@ -0,0 +1,11 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint575 } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +enum A : _BitInt(15) { A0 = 0, A1 = 1 }; /* { dg-error "invalid 'enum' underlying type" } */ +enum B : unsigned _BitInt(575) { B0 = 0, B1 = 1 }; /* { dg-error "invalid 'enum' underlying type" } */ +enum C { C0 = 459875743wb, C1 = 3298437354uwb }; +enum D { D0 = 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, D1 }; +/* { dg-error "enumerator value outside the range of 'intmax_t'" "" { target *-*-* } .-1 } */ +/* { dg-error "overflow in enumeration values" "" { target *-*-* } .-2 } */ +/* { dg-error "enumeration values exceed range of largest integer" "" { target *-*-* } .-3 } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitint-15.c b/SingleSource/Regression/C/gcc-dg/bitint-15.c new file mode 100644 index 0000000000..78129700d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-15.c @@ -0,0 +1,10 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint575 } } */ +/* { dg-options "-std=gnu2x" } */ + +enum A : _BitInt(15) { A0 = 0, A1 = 1 }; /* { dg-error "invalid 'enum' underlying type" } */ +enum B : unsigned _BitInt(575) { B0 = 0, B1 = 1 }; /* { dg-error "invalid 'enum' underlying type" } */ +enum C { C0 = 459875743wb, C1 = 3298437354uwb }; +enum D { D0 = 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, D1 }; +/* { dg-error "overflow in enumeration values" "" { target *-*-* } .-1 } */ +/* { dg-warning "enumeration values exceed range of largest integer" "" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitint-16.c b/SingleSource/Regression/C/gcc-dg/bitint-16.c new file mode 100644 index 0000000000..ccb5d15dbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-16.c @@ -0,0 +1,31 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +_BitInt(15) a; +_BitInt(42) b; +#if __BITINT_MAXWIDTH__ >= 115 +_BitInt(115) c; +#endif +#if __BITINT_MAXWIDTH__ >= 192 +_BitInt(192) d; +#endif +#if __BITINT_MAXWIDTH__ >= 575 +_BitInt(575) e; +#endif + +int +main () +{ + __builtin_clear_padding (&a); + __builtin_clear_padding (&b); +#if __BITINT_MAXWIDTH__ >= 115 + __builtin_clear_padding (&c); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + __builtin_clear_padding (&d); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + __builtin_clear_padding (&e); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-17.c b/SingleSource/Regression/C/gcc-dg/bitint-17.c new file mode 100644 index 0000000000..a0e23268a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-17.c @@ -0,0 +1,47 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#define expr_has_type(e, t) _Generic (e, default : 0, t : 1) + +struct S1 { char x; char : 0; char y; }; +struct S2 { char x; int : 0; char y; }; +#if __BITINT_MAXWIDTH__ >= 575 +struct S3 { char x; _BitInt(575) : 0; char y; }; +#endif +#if __BITINT_MAXWIDTH__ >= 389 +struct S4 { char x; _BitInt(195) a : 63; _BitInt(282) b : 280; _BitInt(389) c : 23; _BitInt(2) d : 1; char y; }; +#endif +#if __BITINT_MAXWIDTH__ >= 192 +struct S5 { char x; _BitInt(192) a : 191; unsigned _BitInt(192) b : 190; _BitInt(192) c : 189; char y; }; +#endif +struct S6 { _BitInt(2) a : 1; }; +#if __BITINT_MAXWIDTH__ >= 389 +struct S4 s4; +static_assert (expr_has_type (s4.a + 1uwb, _BitInt(195))); +static_assert (expr_has_type (s4.b + 1uwb, _BitInt(282))); +static_assert (expr_has_type (s4.c + 1uwb, _BitInt(389))); +static_assert (expr_has_type (s4.d * 0wb, _BitInt(2))); +#endif +#if __BITINT_MAXWIDTH__ >= 192 +struct S5 s5; +static_assert (expr_has_type (s5.a + 1uwb, _BitInt(192))); +static_assert (expr_has_type (s5.b + 1wb, unsigned _BitInt(192))); +static_assert (expr_has_type (s5.c + 1uwb, _BitInt(192))); +#endif +struct S6 s6; +static_assert (expr_has_type (s6.a + 0wb, _BitInt(2))); +#if defined(__x86_64__) && __LP64__ && __BITINT_MAXWIDTH__ >= 575 +static_assert (sizeof (struct S1) == 2); +static_assert (sizeof (struct S2) == 5); +static_assert (sizeof (struct S3) == 9); +static_assert (sizeof (struct S4) == 48); +static_assert (sizeof (struct S5) == 88); +static_assert (sizeof (struct S6) == 1); +static_assert (alignof (struct S1) == 1); +static_assert (alignof (struct S2) == 1); +static_assert (alignof (struct S3) == 1); +static_assert (alignof (struct S4) == 8); +static_assert (alignof (struct S5) == 8); +static_assert (alignof (struct S6) == 1); +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-18.c b/SingleSource/Regression/C/gcc-dg/bitint-18.c new file mode 100644 index 0000000000..9293fa4699 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-18.c @@ -0,0 +1,44 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +_Atomic _BitInt(15) a; +_Atomic(_BitInt(15)) b; +_Atomic _BitInt(115) c; +_Atomic _BitInt(192) d; +_Atomic _BitInt(575) e; +unsigned _BitInt(575) f; + +__attribute__((noipa)) _BitInt(575) +foo (_BitInt(575) x) +{ + return x; +} + +__attribute__((noipa)) int +bar (int x) +{ + return x; +} + +__attribute__((noipa)) _Atomic _BitInt(575) * +baz (_Atomic _BitInt(575) *x) +{ + return x; +} + +int +main () +{ + a += 1wb; + b -= 2wb; + c *= 3wb; + d /= 4wb; + e -= 5wb; + f = __atomic_fetch_add (&e, 54342985743985743985743895743834298574985734895743895734895wb, __ATOMIC_SEQ_CST); + f += __atomic_sub_fetch (&e, 13110356772307144130089534440127211568864891923061809853784155727841516341877716905506658630804426134644404380556711020290072702485839594283061059349912463486203837251238365wb, __ATOMIC_SEQ_CST); + f += __atomic_fetch_and (&e, -33740418462630594385361724744395454079240140931656245750192534103967695265126850678980088699287669565365078793986191778469857714756111026776864987769580622009237241167211461wb, __ATOMIC_RELAXED); + f += __atomic_xor_fetch (&e, 30799001892772360282132495459823194445423296347702377756575214695893559890977912003055702776548378201752339680602420936304294728688029412276600086349055079523071860836114234wb, __ATOMIC_SEQ_CST); + f += __atomic_fetch_or (baz (&e), foo (-6581969867283727911005990155704642154324773504588160884865628865547696324844988049982401783508268917375066790729408659617189350524019843499435572226770089390885472550659255wb), bar (__ATOMIC_RELAXED)); + f += __atomic_nand_fetch (&e, 55047840194947228224723671648125013926111290688378416557548660662319034233151051252215595447712248992759177463741832904590457754423713378627482465906620631734790561114905369wb, __ATOMIC_ACQ_REL); +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-19.c b/SingleSource/Regression/C/gcc-dg/bitint-19.c new file mode 100644 index 0000000000..f33a82c3b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-19.c @@ -0,0 +1,16 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ + +#define expr_has_type(e, t) _Generic (e, default : 0, t : 1) + +void +foo (_Complex int ci, _Complex long long cl) +{ + _BitInt(__SIZEOF_INT__ * __CHAR_BIT__ - 1) bi = 0wb; + _BitInt(__SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 1) bl = 0wb; + static_assert (expr_has_type (ci + bi, _Complex int)); + static_assert (expr_has_type (cl + bl, _Complex long long)); + static_assert (expr_has_type (bi + ci, _Complex int)); + static_assert (expr_has_type (bl + cl, _Complex long long)); +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-2.c b/SingleSource/Regression/C/gcc-dg/bitint-2.c new file mode 100644 index 0000000000..6fa9c06d4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-2.c @@ -0,0 +1,122 @@ +/* PR c/102989 */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#define expr_has_type(e, t) _Generic (e, default : 0, t : 1) + +#ifdef __BITINT_MAXWIDTH__ +void +foo (void) +{ + _BitInt(42) a = (_BitInt(42)) 1; + _BitInt(42) unsigned b = (unsigned _BitInt(42)) 2; + _BitInt(5) c = (_BitInt(5)) 3; + _BitInt(5) unsigned d = (unsigned _BitInt(5)) 4; + _BitInt(32) e = (_BitInt(32)) 5; + _BitInt(32) unsigned f = (unsigned _BitInt(32)) 6; + constexpr int g = 43; + enum E { F = 44 }; + _BitInt(g) h; + unsigned _BitInt(F) i; + static_assert (expr_has_type (a, signed _BitInt(42)), ""); + static_assert (expr_has_type (a, _BitInt(42)), ""); + static_assert (!expr_has_type (a, unsigned _BitInt(42)), ""); + static_assert (!expr_has_type (b, signed _BitInt(42)), ""); + static_assert (!expr_has_type (b, _BitInt(42)), ""); + static_assert (expr_has_type (b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a + b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a * b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a - b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a * a, _BitInt(42)), ""); + static_assert (expr_has_type (a / b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (c, signed _BitInt(5)), ""); + static_assert (expr_has_type (c, _BitInt(5)), ""); + static_assert (!expr_has_type (c, unsigned _BitInt(5)), ""); + static_assert (!expr_has_type (d, signed _BitInt(5)), ""); + static_assert (!expr_has_type (d, _BitInt(5)), ""); + static_assert (expr_has_type (d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c + d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c * d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c - d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c * c, _BitInt(5)), ""); + static_assert (expr_has_type (c / d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (e, signed _BitInt(32)), ""); + static_assert (expr_has_type (e, _BitInt(32)), ""); + static_assert (!expr_has_type (e, unsigned _BitInt(32)), ""); + static_assert (!expr_has_type (f, signed _BitInt(32)), ""); + static_assert (!expr_has_type (f, _BitInt(32)), ""); + static_assert (expr_has_type (f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e + f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e * f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e - f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e * e, _BitInt(32)), ""); + static_assert (expr_has_type (e / f, unsigned _BitInt(32)), ""); +#if __CHAR_BIT__ * __SIZEOF_INT__ == 32 + static_assert (expr_has_type (e + 1, int), ""); + static_assert (expr_has_type (f + 1, unsigned int), ""); + static_assert (expr_has_type (e + 1U, unsigned int), ""); + static_assert (expr_has_type (f + 1U, unsigned int), ""); + static_assert (expr_has_type (1 - e, int), ""); + static_assert (expr_has_type (1 - f, unsigned int), ""); + static_assert (expr_has_type (1U * e, unsigned int), ""); + static_assert (expr_has_type (1U / f, unsigned int), ""); +#endif + static_assert (expr_has_type (0wb, _BitInt(2)), ""); + static_assert (expr_has_type (-1WB, _BitInt(2)), ""); + static_assert (expr_has_type (-1wb - 1wb, _BitInt(2)), ""); + static_assert (expr_has_type (1wb, _BitInt(2)), ""); + static_assert (expr_has_type (2wb, _BitInt(3)), ""); + static_assert (expr_has_type (0wbu, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (-1UWB, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (1uWB, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (2Uwb, unsigned _BitInt(2)), ""); + static_assert (expr_has_type (h, signed _BitInt(43)), ""); + static_assert (expr_has_type (i, unsigned _BitInt(44)), ""); + static_assert (0wb == 0, ""); + static_assert (-1wb == -1, ""); + static_assert (0xffffffffwb == 4294967295wb, ""); + static_assert (0xffffffffwb == 000000000000000000000000000037777777777wb, ""); + static_assert (0x0000000000000000000000000ffffffffwb == 0b00011111111111111111111111111111111wb, ""); +#if __BITINT_MAXWIDTH__ >= 128 + static_assert (expr_has_type (0xffffffffffffffffffffffffffffffffuwb, unsigned _BitInt(128)), ""); + static_assert (0xffffffffffffffffffffffffffffffffuwb == 340282366920938463463374607431768211455uwb, ""); + static_assert (200000000000000000000000000000000000000wb == 0x96769950b50d88f41314448000000000WB, ""); + static_assert (02263551452055206610750114242110000000000000wb == 200000000000000000000000000000000000000wb, ""); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static_assert (expr_has_type (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567UWB, unsigned _BitInt(575)), ""); + static_assert (expr_has_type (0x00000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwbu, unsigned _BitInt(575)), ""); + static_assert (expr_has_type (0377777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777uwb, unsigned _BitInt(575)), ""); + static_assert (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb == 0x00000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwbu, ""); + static_assert (0377777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777WBU == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffuWB, ""); + static_assert (100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb == 0X67815961'0903F797'4A7CB3F2'2F01FA5D'9A2CD603'9DE4A7A6'0F713676'CE7D7113'FF1A499D'9BFD0FDC'D2999652'EB4C7F39'8DE2A000'00000000'00000000'00000000'00000000'00000000UWB, ""); + static_assert (expr_has_type (-61'832600368'276133515'125630254'911797508'782837275'302959978'515764023'224306276'632966792'579100265'310761247'399417856'504034834'837841258'576687802'491886538'775473291'979151693'037174783wb, _BitInt(575)), ""); + static_assert (expr_has_type (0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, signed _BitInt(575)), ""); + static_assert (expr_has_type (0177777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777wb, _BitInt(575)), ""); + static_assert (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783WB == -0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, ""); + static_assert (0177777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777wb / 2wb * 2wb + 1wb == 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, ""); +#endif +#if (0wb != 0) || (0wbU != 0U) || (1wb != 1) || (1uWB != 1u) \ + || (-1wb >= 0) || (-1UWB < 0) || (4294967295uwb != 4294967295U) \ + || 18446744073709551615wbu != 18446744073709551615ULL +#error "" +#endif +} + +void +bar (void) +{ + _BitInt(2) a = (_BitInt(2)) 1; + unsigned _BitInt(1) b = 1uwb; + _BitInt(4) c; + c = 7; + _BitInt(2) d = 1; + _BitInt(5) e = 2wb; + unsigned _BitInt(6) f = 3uwb; +} +#endif + +int +main () +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-20.c b/SingleSource/Regression/C/gcc-dg/bitint-20.c new file mode 100644 index 0000000000..6b92b5b7dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-20.c @@ -0,0 +1,16 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ + +void +foo (_Complex int ci, _Complex long long cl) +{ + _BitInt(__SIZEOF_INT__ * __CHAR_BIT__ + 1) bi = 0wb; + ci + bi; /* { dg-message "unsupported" } */ + bi + ci; /* { dg-message "unsupported" } */ +#if __BITINT_MAXWIDTH__ >= 575 + _BitInt(575) bw = 0wb; + cl + bw; /* { dg-message "unsupported" "" { target bitint575 } } */ + bw + cl; /* { dg-message "unsupported" "" { target bitint575 } } */ +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-21.c b/SingleSource/Regression/C/gcc-dg/bitint-21.c new file mode 100644 index 0000000000..72f68c95a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-21.c @@ -0,0 +1,11 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ + +#define IB __SIZEOF_INT__ * __CHAR_BIT__ +typedef _BitInt(IB) V1 __attribute__((vector_size (sizeof (_BitInt(IB))))); /* { dg-error "invalid vector type for attribute 'vector_size'" } */ +typedef _BitInt(IB) V2 __attribute__((vector_size (8 * sizeof (_BitInt(IB))))); /* { dg-error "invalid vector type for attribute 'vector_size'" } */ +#if __BITINT_MAXWIDTH__ >= 575 +typedef _BitInt(575) V3 __attribute__((vector_size (sizeof (_BitInt(575))))); /* { dg-error "invalid vector type for attribute 'vector_size'" "" { target bitint575 } } */ +typedef _BitInt(575) V3 __attribute__((vector_size (16 * sizeof (_BitInt(575))))); /* { dg-error "invalid vector type for attribute 'vector_size'" "" { target bitint575 } } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-22.c b/SingleSource/Regression/C/gcc-dg/bitint-22.c new file mode 100644 index 0000000000..329d8a885d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-22.c @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c2x -pedantic-errors" } + +_BitInt(63) a; +signed _BitInt(15) b; +unsigned _BitInt(31) c; +int d = 21wb; +long long e = 60594869054uwb; +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 +#endif +#if 0uwb == 0 +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-23.c b/SingleSource/Regression/C/gcc-dg/bitint-23.c new file mode 100644 index 0000000000..89041c0f7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-23.c @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } + +_BitInt(63) a; /* { dg-warning "ISO C does not support '_BitInt\\\(63\\\)' before C2X" } */ +signed _BitInt(15) b; /* { dg-warning "ISO C does not support 'signed _BitInt\\\(15\\\)' before C2X" } */ +unsigned _BitInt(31) c; /* { dg-warning "ISO C does not support 'unsigned _BitInt\\\(31\\\)' before C2X" } */ +int d = 21wb; /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +long long e = 60594869054uwb; /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif +#if 0uwb == 0 /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-24.c b/SingleSource/Regression/C/gcc-dg/bitint-24.c new file mode 100644 index 0000000000..321b5522e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-24.c @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c11" } + +_BitInt(63) a; +signed _BitInt(15) b; +unsigned _BitInt(31) c; +int d = 21wb; +long long e = 60594869054uwb; +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 +#endif +#if 0uwb == 0 +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-25.c b/SingleSource/Regression/C/gcc-dg/bitint-25.c new file mode 100644 index 0000000000..b18244f345 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-25.c @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c11 -Wno-c11-c2x-compat -pedantic-errors" } + +_BitInt(63) a; +signed _BitInt(15) b; +unsigned _BitInt(31) c; +int d = 21wb; +long long e = 60594869054uwb; +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 +#endif +#if 0uwb == 0 +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-26.c b/SingleSource/Regression/C/gcc-dg/bitint-26.c new file mode 100644 index 0000000000..c5ce1acdaa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-26.c @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c11 -pedantic" } + +_BitInt(63) a; /* { dg-warning "ISO C does not support '_BitInt\\\(63\\\)' before C2X" } */ +signed _BitInt(15) b; /* { dg-warning "ISO C does not support 'signed _BitInt\\\(15\\\)' before C2X" } */ +unsigned _BitInt(31) c; /* { dg-warning "ISO C does not support 'unsigned _BitInt\\\(31\\\)' before C2X" } */ +int d = 21wb; /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +long long e = 60594869054uwb; /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif +#if 0uwb == 0 /* { dg-warning "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-27.c b/SingleSource/Regression/C/gcc-dg/bitint-27.c new file mode 100644 index 0000000000..e85f28830e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-27.c @@ -0,0 +1,18 @@ +// PR c/102989 +// { dg-do compile { target bitint } } +// { dg-options "-std=c11 -pedantic-errors" } + +_BitInt(63) a; /* { dg-error "ISO C does not support '_BitInt\\\(63\\\)' before C2X" } */ +signed _BitInt(15) b; /* { dg-error "ISO C does not support 'signed _BitInt\\\(15\\\)' before C2X" } */ +unsigned _BitInt(31) c; /* { dg-error "ISO C does not support 'unsigned _BitInt\\\(31\\\)' before C2X" } */ +int d = 21wb; /* { dg-error "ISO C does not support literal 'wb' suffixes before C2X" } */ +long long e = 60594869054uwb; /* { dg-error "ISO C does not support literal 'wb' suffixes before C2X" } */ +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; +long long j = __extension__ 60594869054uwb; +#if 0wb == 0 /* { dg-error "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif +#if 0uwb == 0 /* { dg-error "ISO C does not support literal 'wb' suffixes before C2X" } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-28.c b/SingleSource/Regression/C/gcc-dg/bitint-28.c new file mode 100644 index 0000000000..607c7d43fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-28.c @@ -0,0 +1,401 @@ +/* PR c/102989 */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-options "-std=c2x" } */ +/* { dg-add-options ieee } */ + +#include + +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testflt_135 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testfltu_135 (float d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testflt_192 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testfltu_192 (float d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testflt_575 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testfltu_575 (float d) +{ + return d; +} +#endif +#endif + +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testdbl_135 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testdblu_135 (double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testdbl_192 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testdblu_192 (double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testdbl_575 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testdblu_575 (double d) +{ + return d; +} +#endif +#endif + +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testldbl_135 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testldblu_135 (long double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testldbl_192 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testldblu_192 (long double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testldbl_575 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testldblu_575 (long double d) +{ + return d; +} +#endif +#endif + +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testflt128_135 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testflt128u_135 (_Float128 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testflt128_192 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testflt128u_192 (_Float128 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testflt128_575 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testflt128u_575 (_Float128 d) +{ + return d; +} +#endif +#endif + +__attribute__((noipa)) void +check_invalid (int test, int inv) +{ + if (!test) + __builtin_abort (); + if ((!fetestexcept (FE_INVALID)) != (!inv)) + __builtin_abort (); + feclearexcept (FE_INVALID); +} + +int +main () +{ +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 + check_invalid (testflt_135 (-85070591730234615865843651857942052864.0f) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testflt_135 (__builtin_inff ()) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testflt_135 (-__builtin_inff ()) == -21778071482940061661655974875633165533183wb - 1wb, 1); + check_invalid (testflt_135 (__builtin_nanf ("")) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testflt_135 (0xffffffp+104f) == 340282346638528859811704183484516925440wb, 0); + check_invalid (testflt_135 (-0xffffffp+104f) == -340282346638528859811704183484516925440wb, 0); + check_invalid (testfltu_135 (-0.9990234375f) == 0uwb, 0); + check_invalid (testfltu_135 (-1.f) == 0uwb, 1); + check_invalid (testfltu_135 (__builtin_inff ()) == 43556142965880123323311949751266331066367uwb, 1); + check_invalid (testfltu_135 (-__builtin_inff ()) == 0uwb, 1); + check_invalid (testfltu_135 (__builtin_nanf ("")) == 43556142965880123323311949751266331066367uwb, 1); + check_invalid (testfltu_135 (0xffffffp+104f) == 340282346638528859811704183484516925440uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_invalid (testflt_192 (-85070591730234615865843651857942052864.0f) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testflt_192 (__builtin_inff ()) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testflt_192 (-__builtin_inff ()) == -3138550867693340381917894711603833208051177722232017256447wb - 1wb, 1); + check_invalid (testflt_192 (__builtin_nanf ("")) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testflt_192 (0xffffffp+104f) == 340282346638528859811704183484516925440wb, 0); + check_invalid (testflt_192 (-0xffffffp+104f) == -340282346638528859811704183484516925440wb, 0); + check_invalid (testfltu_192 (-0.9990234375f) == 0uwb, 0); + check_invalid (testfltu_192 (-1.f) == 0uwb, 1); + check_invalid (testfltu_192 (__builtin_inff ()) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); + check_invalid (testfltu_192 (-__builtin_inff ()) == 0uwb, 1); + check_invalid (testfltu_192 (__builtin_nanf ("")) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); + check_invalid (testfltu_192 (0xffffffp+104f) == 340282346638528859811704183484516925440uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_invalid (testflt_575 (-85070591730234615865843651857942052864.0f) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testflt_575 (__builtin_inff ()) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testflt_575 (-__builtin_inff ()) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb, 1); + check_invalid (testflt_575 (__builtin_nanf ("")) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testflt_575 (0xffffffp+104f) == 340282346638528859811704183484516925440wb, 0); + check_invalid (testflt_575 (-0xffffffp+104f) == -340282346638528859811704183484516925440wb, 0); + check_invalid (testfltu_575 (-0.9990234375f) == 0uwb, 0); + check_invalid (testfltu_575 (-1.f) == 0uwb, 1); + check_invalid (testfltu_575 (__builtin_inff ()) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); + check_invalid (testfltu_575 (-__builtin_inff ()) == 0uwb, 1); + check_invalid (testfltu_575 (__builtin_nanf ("")) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); + check_invalid (testfltu_575 (0xffffffp+104f) == 340282346638528859811704183484516925440uwb, 0); +#endif +#endif +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 + check_invalid (testdbl_135 (-85070591730234615865843651857942052864.0) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testdbl_135 (__builtin_inf ()) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testdbl_135 (-__builtin_inf ()) == -21778071482940061661655974875633165533183wb - 1wb, 1); + check_invalid (testdbl_135 (__builtin_nan ("")) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testdbl_135 (0x1fffffffffffffp+81) == 21778071482940059243804335646374816120832wb, 0); + check_invalid (testdbl_135 (0x20000000000000p+81) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testdbl_135 (-0x20000000000000p+81) == -21778071482940061661655974875633165533183wb - 1, 0); + check_invalid (testdbl_135 (-0x20000000000002p+81) == -21778071482940061661655974875633165533183wb - 1, 1); + check_invalid (testdblu_135 (-0.9990234375) == 0uwb, 0); + check_invalid (testdblu_135 (-1.) == 0uwb, 1); + check_invalid (testdblu_135 (__builtin_inf ()) == 43556142965880123323311949751266331066367uwb, 1); + check_invalid (testdblu_135 (-__builtin_inf ()) == 0uwb, 1); + check_invalid (testdblu_135 (__builtin_nan ("")) == 43556142965880123323311949751266331066367uwb, 1); + check_invalid (testdblu_135 (0x1fffffffffffffp+82) == 43556142965880118487608671292749632241664uwb, 0); + check_invalid (testdblu_135 (0x20000000000000p+82) == 43556142965880123323311949751266331066367uwb, 1); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_invalid (testdbl_192 (-85070591730234615865843651857942052864.0) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testdbl_192 (__builtin_inf ()) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testdbl_192 (-__builtin_inf ()) == -3138550867693340381917894711603833208051177722232017256447wb - 1wb, 1); + check_invalid (testdbl_192 (__builtin_nan ("")) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testdbl_192 (0x1fffffffffffffp+138) == 3138550867693340033468750984562846621555579712101368725504wb, 0); + check_invalid (testdbl_192 (0x20000000000000p+138) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testdbl_192 (-0x20000000000000p+138) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 0); + check_invalid (testdbl_192 (-0x20000000000002p+138) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 1); + check_invalid (testdblu_192 (-0.9990234375) == 0uwb, 0); + check_invalid (testdblu_192 (-1.) == 0uwb, 1); + check_invalid (testdblu_192 (__builtin_inf ()) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); + check_invalid (testdblu_192 (-__builtin_inf ()) == 0uwb, 1); + check_invalid (testdblu_192 (__builtin_nan ("")) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); + check_invalid (testdblu_192 (0x1fffffffffffffp+139) == 6277101735386680066937501969125693243111159424202737451008uwb, 0); + check_invalid (testdblu_192 (0x20000000000000p+139) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_invalid (testdbl_575 (-85070591730234615865843651857942052864.0) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testdbl_575 (__builtin_inf ()) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testdbl_575 (-__builtin_inf ()) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb, 1); + check_invalid (testdbl_575 (__builtin_nan ("")) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testdbl_575 (0x1fffffffffffffp+521) == 61832600368276126650327970124302082526882038193909742709080463879918896882169507607035916867654709124839777195049479857541529867095829765369898539058829479405123401922117632wb, 0); + check_invalid (testdbl_575 (0x20000000000000p+521) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testdbl_575 (-0x20000000000000p+521) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 0); + check_invalid (testdbl_575 (-0x20000000000002p+521) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1); + check_invalid (testdblu_575 (-0.9990234375) == 0uwb, 0); + check_invalid (testdblu_575 (-1.) == 0uwb, 1); + check_invalid (testdblu_575 (__builtin_inf ()) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); + check_invalid (testdblu_575 (-__builtin_inf ()) == 0uwb, 1); + check_invalid (testdblu_575 (__builtin_nan ("")) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); + check_invalid (testdblu_575 (0x1fffffffffffffp+522) == 123665200736552253300655940248604165053764076387819485418160927759837793764339015214071833735309418249679554390098959715083059734191659530739797078117658958810246803844235264uwb, 0); + check_invalid (testdblu_575 (0x20000000000000p+522) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); +#endif +#endif +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 + check_invalid (testldbl_135 (-85070591730234615865843651857942052864.0L) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testldbl_135 (__builtin_infl ()) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testldbl_135 (-__builtin_infl ()) == -21778071482940061661655974875633165533183wb - 1wb, 1); + check_invalid (testldbl_135 (__builtin_nanl ("")) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testldbl_135 (0xffffffffffffffffp+70L) == 21778071482940061660475383254915754229760wb, 0); + check_invalid (testldbl_135 (0x10000000000000000p+70L) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testldbl_135 (-0x10000000000000000p+70L) == -21778071482940061661655974875633165533183wb - 1, 0); + check_invalid (testldbl_135 (-0x10000000000000002p+70L) == -21778071482940061661655974875633165533183wb - 1, 1); + check_invalid (testldblu_135 (-0.9990234375L) == 0uwb, 0); + check_invalid (testldblu_135 (-1.L) == 0uwb, 1); + check_invalid (testldblu_135 (__builtin_infl ()) == 43556142965880123323311949751266331066367uwb, 1); + check_invalid (testldblu_135 (-__builtin_infl ()) == 0uwb, 1); + check_invalid (testldblu_135 (__builtin_nanl ("")) == 43556142965880123323311949751266331066367uwb, 1); + check_invalid (testldblu_135 (0xffffffffffffffffp+71L) == 43556142965880123320950766509831508459520uwb, 0); + check_invalid (testldblu_135 (0x10000000000000000p+71L) == 43556142965880123323311949751266331066367uwb, 1); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_invalid (testldbl_192 (-85070591730234615865843651857942052864.0L) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testldbl_192 (__builtin_infl ()) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testldbl_192 (-__builtin_infl ()) == -3138550867693340381917894711603833208051177722232017256447wb - 1wb, 1); + check_invalid (testldbl_192 (__builtin_nanl ("")) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testldbl_192 (0xffffffffffffffffp+127L) == 3138550867693340381747753528143363976319490418516133150720wb, 0); + check_invalid (testldbl_192 (0x10000000000000000p+127L) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testldbl_192 (-0x10000000000000000p+127L) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 0); + check_invalid (testldbl_192 (-0x10000000000000002p+127L) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 1); + check_invalid (testldblu_192 (-0.9990234375L) == 0uwb, 0); + check_invalid (testldblu_192 (-1.L) == 0uwb, 1); + check_invalid (testldblu_192 (__builtin_infl ()) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); + check_invalid (testldblu_192 (-__builtin_infl ()) == 0uwb, 1); + check_invalid (testldblu_192 (__builtin_nanl ("")) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); + check_invalid (testldblu_192 (0xffffffffffffffffp+128L) == 6277101735386680763495507056286727952638980837032266301440uwb, 0); + check_invalid (testldblu_192 (0x10000000000000000p+128L) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_invalid (testldbl_575 (-85070591730234615865843651857942052864.0L) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testldbl_575 (__builtin_infl ()) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testldbl_575 (-__builtin_infl ()) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb, 1); + check_invalid (testldbl_575 (__builtin_nanl ("")) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testldbl_575 (0xffffffffffffffffp+510L) == 61832600368276133511773678272426148233889331025751498446645922568076207932202076431648659257792374503198949281962308977915333294030066289778448068072486649492543280785653760wb, 0); + check_invalid (testldbl_575 (0x10000000000000000p+510L) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testldbl_575 (-0x10000000000000000p+510L) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 0); + check_invalid (testldbl_575 (-0x10000000000000002p+510L) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1); + check_invalid (testldblu_575 (-0.9990234375L) == 0uwb, 0); + check_invalid (testldblu_575 (-1.L) == 0uwb, 1); + check_invalid (testldblu_575 (__builtin_infl ()) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); + check_invalid (testldblu_575 (-__builtin_infl ()) == 0uwb, 1); + check_invalid (testldblu_575 (__builtin_nanl ("")) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); + check_invalid (testldblu_575 (0xffffffffffffffffp+511L) == 123665200736552267023547356544852296467778662051502996893291845136152415864404152863297318515584749006397898563924617955830666588060132579556896136144973298985086561571307520uwb, 0); + check_invalid (testldblu_575 (0x10000000000000000p+511L) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); +#endif +#endif +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 + check_invalid (testflt128_135 (-85070591730234615865843651857942052864.0F128) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testflt128_135 (__builtin_inff128 ()) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testflt128_135 (-__builtin_inff128 ()) == -21778071482940061661655974875633165533183wb - 1wb, 1); + check_invalid (testflt128_135 (__builtin_nanf128 ("")) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testflt128_135 (0x1ffffffffffffffffffffffffffffp+21F128) == 21778071482940061661655974875633163436032wb, 0); + check_invalid (testflt128_135 (0x20000000000000000000000000000p+21F128) == 21778071482940061661655974875633165533183wb, 1); + check_invalid (testflt128_135 (-0x20000000000000000000000000000p+21F128) == -21778071482940061661655974875633165533183wb - 1, 0); + check_invalid (testflt128_135 (-0x20000000000000000000000000002p+21F128) == -21778071482940061661655974875633165533183wb - 1, 1); + check_invalid (testflt128u_135 (-0.9990234375F128) == 0uwb, 0); + check_invalid (testflt128u_135 (-1.F128) == 0uwb, 1); + check_invalid (testflt128u_135 (__builtin_inff128 ()) == 43556142965880123323311949751266331066367uwb, 1); + check_invalid (testflt128u_135 (-__builtin_inff128 ()) == 0uwb, 1); + check_invalid (testflt128u_135 (__builtin_nanf128 ("")) == 43556142965880123323311949751266331066367uwb, 1); + check_invalid (testflt128u_135 (0x1ffffffffffffffffffffffffffffp+22F128) == 43556142965880123323311949751266326872064uwb, 0); + check_invalid (testflt128u_135 (0x20000000000000000000000000000p+22F128) == 43556142965880123323311949751266331066367uwb, 1); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_invalid (testflt128_192 (-85070591730234615865843651857942052864.0F128) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testflt128_192 (__builtin_inff128 ()) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testflt128_192 (-__builtin_inff128 ()) == -3138550867693340381917894711603833208051177722232017256447wb - 1wb, 1); + check_invalid (testflt128_192 (__builtin_nanf128 ("")) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testflt128_192 (0x1ffffffffffffffffffffffffffffp+78F128) == 3138550867693340381917894711603832905819722818574723579904wb, 0); + check_invalid (testflt128_192 (0x20000000000000000000000000000p+78F128) == 3138550867693340381917894711603833208051177722232017256447wb, 1); + check_invalid (testflt128_192 (-0x20000000000000000000000000000p+78F128) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 0); + check_invalid (testflt128_192 (-0x20000000000000000000000000002p+78F128) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 1); + check_invalid (testflt128u_192 (-0.9990234375F128) == 0uwb, 0); + check_invalid (testflt128u_192 (-1.F128) == 0uwb, 1); + check_invalid (testflt128u_192 (__builtin_inff128 ()) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); + check_invalid (testflt128u_192 (-__builtin_inff128 ()) == 0uwb, 1); + check_invalid (testflt128u_192 (__builtin_nanf128 ("")) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); + check_invalid (testflt128u_192 (0x1ffffffffffffffffffffffffffffp+79F128) == 6277101735386680763835789423207665811639445637149447159808uwb, 0); + check_invalid (testflt128u_192 (0x20000000000000000000000000000p+79F128) == 6277101735386680763835789423207666416102355444464034512895uwb, 1); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_invalid (testflt128_575 (-85070591730234615865843651857942052864.0F128) == -85070591730234615865843651857942052864wb, 0); + check_invalid (testflt128_575 (__builtin_inff128 ()) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testflt128_575 (-__builtin_inff128 ()) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb, 1); + check_invalid (testflt128_575 (__builtin_nanf128 ("")) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testflt128_575 (0x1ffffffffffffffffffffffffffffp+461F128) == 61832600368276133515125630254911791554520007845691312598455129804691160851602940042069550439343049559602369631548246946680753811425558728725309540242943660463695151425912832wb, 0); + check_invalid (testflt128_575 (0x20000000000000000000000000000p+461F128) == 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1); + check_invalid (testflt128_575 (-0x20000000000000000000000000000p+461F128) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 0); + check_invalid (testflt128_575 (-0x20000000000000000000000000002p+461F128) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1); + check_invalid (testflt128u_575 (-0.9990234375F128) == 0uwb, 0); + check_invalid (testflt128u_575 (-1.F128) == 0uwb, 1); + check_invalid (testflt128u_575 (__builtin_inff128 ()) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); + check_invalid (testflt128u_575 (-__builtin_inff128 ()) == 0uwb, 1); + check_invalid (testflt128u_575 (__builtin_nanf128 ("")) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); + check_invalid (testflt128u_575 (0x1ffffffffffffffffffffffffffffp+462F128) == 123665200736552267030251260509823583109040015691382625196910259609382321703205880084139100878686099119204739263096493893361507622851117457450619080485887320927390302851825664uwb, 0); + check_invalid (testflt128u_575 (0x20000000000000000000000000000p+462F128) == 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb, 1); +#endif +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-29.c b/SingleSource/Regression/C/gcc-dg/bitint-29.c new file mode 100644 index 0000000000..b6a88567c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-29.c @@ -0,0 +1,351 @@ +/* PR c/102989 */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-options "-std=c2x" } */ +/* { dg-add-options ieee } */ + +#include + +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testflt_135 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testfltu_135 (float d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testflt_192 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testfltu_192 (float d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testflt_575 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testfltu_575 (float d) +{ + return d; +} +#endif +#endif + +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testdbl_135 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testdblu_135 (double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testdbl_192 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testdblu_192 (double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testdbl_575 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testdblu_575 (double d) +{ + return d; +} +#endif +#endif + +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testldbl_135 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testldblu_135 (long double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testldbl_192 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testldblu_192 (long double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testldbl_575 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testldblu_575 (long double d) +{ + return d; +} +#endif +#endif + +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testflt128_135 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testflt128u_135 (_Float128 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testflt128_192 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testflt128u_192 (_Float128 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testflt128_575 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testflt128u_575 (_Float128 d) +{ + return d; +} +#endif +#endif + +__attribute__((noipa)) void +check_inexact (int test, int inex) +{ + if (!test) + __builtin_abort (); + if ((!fetestexcept (FE_INEXACT)) != (!inex)) + __builtin_abort (); + feclearexcept (FE_INEXACT); +} + +int +main () +{ +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 + check_inexact (testflt_135 (-85070591730234615865843651857942052864.0f) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testflt_135 (0xffffffp+104f) == 340282346638528859811704183484516925440wb, 0); + check_inexact (testflt_135 (-0xffffffp+104f) == -340282346638528859811704183484516925440wb, 0); + check_inexact (testflt_135 (-0xffffffp-1f) == -8388607wb, 1); + check_inexact (testflt_135 (-0.f) == 0wb, 0); + check_inexact (testflt_135 (-0.f) == 0wb, 0); + check_inexact (testflt_135 (-0.9990234375f) == 0wb, 1); + check_inexact (testfltu_135 (0.f) == 0uwb, 0); + check_inexact (testfltu_135 (-0.9990234375f) == 0uwb, 1); + check_inexact (testfltu_135 (0xffffffp-1f) == 8388607uwb, 1); + check_inexact (testfltu_135 (0xffffffp+104f) == 340282346638528859811704183484516925440uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_inexact (testflt_192 (-85070591730234615865843651857942052864.0f) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testflt_192 (0xffffffp+104f) == 340282346638528859811704183484516925440wb, 0); + check_inexact (testflt_192 (-0xffffffp+104f) == -340282346638528859811704183484516925440wb, 0); + check_inexact (testflt_192 (-0xffffffp-3f) == -2097151wb, 1); + check_inexact (testflt_192 (-0.f) == 0wb, 0); + check_inexact (testflt_192 (-0.9990234375f) == 0wb, 1); + check_inexact (testfltu_192 (0.f) == 0uwb, 0); + check_inexact (testfltu_192 (-0.9990234375f) == 0uwb, 1); + check_inexact (testfltu_192 (0xffffffp-3f) == 2097151uwb, 1); + check_inexact (testfltu_192 (0xffffffp+104f) == 340282346638528859811704183484516925440uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_inexact (testflt_575 (-85070591730234615865843651857942052864.0f) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testflt_575 (0xffffffp+104f) == 340282346638528859811704183484516925440wb, 0); + check_inexact (testflt_575 (-0xffffffp+104f) == -340282346638528859811704183484516925440wb, 0); + check_inexact (testflt_575 (-0xffffffp-5f) == -524287wb, 1); + check_inexact (testflt_575 (0.f) == 0wb, 0); + check_inexact (testflt_575 (-0.9990234375f) == 0wb, 1); + check_inexact (testfltu_575 (-0.f) == 0uwb, 0); + check_inexact (testfltu_575 (-0.9990234375f) == 0uwb, 1); + check_inexact (testfltu_575 (0xffffffp-5f) == 524287uwb, 1); + check_inexact (testfltu_575 (0xffffffp+104f) == 340282346638528859811704183484516925440uwb, 0); +#endif +#endif +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 + check_inexact (testdbl_135 (-85070591730234615865843651857942052864.0) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testdbl_135 (0x1fffffffffffffp+81) == 21778071482940059243804335646374816120832wb, 0); + check_inexact (testdbl_135 (-0x20000000000000p+81) == -21778071482940061661655974875633165533183wb - 1, 0); + check_inexact (testdbl_135 (-0x1fffffffffffffp-1) == -4503599627370495wb, 1); + check_inexact (testdbl_135 (-0.) == 0wb, 0); + check_inexact (testdbl_135 (-0.9990234375) == 0wb, 1); + check_inexact (testdblu_135 (0.) == 0uwb, 0); + check_inexact (testdblu_135 (-0.9990234375) == 0uwb, 1); + check_inexact (testdblu_135 (0x1fffffffffffffp-1) == 4503599627370495uwb, 1); + check_inexact (testdblu_135 (0x1fffffffffffffp+82) == 43556142965880118487608671292749632241664uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_inexact (testdbl_192 (-85070591730234615865843651857942052864.0) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testdbl_192 (0x1fffffffffffffp+138) == 3138550867693340033468750984562846621555579712101368725504wb, 0); + check_inexact (testdbl_192 (-0x20000000000000p+138) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 0); + check_inexact (testdbl_192 (-0x1fffffffffffffp-3) == -1125899906842623wb, 1); + check_inexact (testdbl_192 (0.) == 0wb, 0); + check_inexact (testdbl_192 (-0.9990234375) == 0wb, 1); + check_inexact (testdblu_192 (-0.) == 0uwb, 0); + check_inexact (testdblu_192 (-0.9990234375) == 0uwb, 1); + check_inexact (testdblu_192 (0x1fffffffffffffp-3) == 1125899906842623uwb, 1); + check_inexact (testdblu_192 (0x1fffffffffffffp+139) == 6277101735386680066937501969125693243111159424202737451008uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_inexact (testdbl_575 (-85070591730234615865843651857942052864.0) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testdbl_575 (0x1fffffffffffffp+521) == 61832600368276126650327970124302082526882038193909742709080463879918896882169507607035916867654709124839777195049479857541529867095829765369898539058829479405123401922117632wb, 0); + check_inexact (testdbl_575 (-0x20000000000000p+521) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 0); + check_inexact (testdbl_575 (-0x1fffffffffffffp-5) == -281474976710655wb, 1); + check_inexact (testdbl_575 (-0.) == 0wb, 0); + check_inexact (testdbl_575 (-0.9990234375) == 0wb, 1); + check_inexact (testdblu_575 (0.) == 0uwb, 0); + check_inexact (testdblu_575 (-0.9990234375) == 0uwb, 1); + check_inexact (testdblu_575 (0x1fffffffffffffp-5) == 281474976710655uwb, 1); + check_inexact (testdblu_575 (0x1fffffffffffffp+522) == 123665200736552253300655940248604165053764076387819485418160927759837793764339015214071833735309418249679554390098959715083059734191659530739797078117658958810246803844235264uwb, 0); +#endif +#endif +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 + check_inexact (testldbl_135 (-85070591730234615865843651857942052864.0L) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testldbl_135 (0xffffffffffffffffp+70L) == 21778071482940061660475383254915754229760wb, 0); + check_inexact (testldbl_135 (-0x10000000000000000p+70L) == -21778071482940061661655974875633165533183wb - 1, 0); + check_inexact (testldbl_135 (-0xffffffffffffffffp-1L) == -9223372036854775807wb, 1); + check_inexact (testldbl_135 (-0.L) == 0wb, 0); + check_inexact (testldbl_135 (-0.9990234375L) == 0wb, 1); + check_inexact (testldblu_135 (0.L) == 0uwb, 0); + check_inexact (testldblu_135 (-0.9990234375L) == 0uwb, 1); + check_inexact (testldblu_135 (0xffffffffffffffffp-1L) == 9223372036854775807uwb, 1); + check_inexact (testldblu_135 (0xffffffffffffffffp+71L) == 43556142965880123320950766509831508459520uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_inexact (testldbl_192 (-85070591730234615865843651857942052864.0L) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testldbl_192 (0xffffffffffffffffp+127L) == 3138550867693340381747753528143363976319490418516133150720wb, 0); + check_inexact (testldbl_192 (-0x10000000000000000p+127L) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 0); + check_inexact (testldbl_192 (-0xffffffffffffffffp-2L) == -4611686018427387903wb, 1); + check_inexact (testldbl_192 (0.L) == 0wb, 0); + check_inexact (testldbl_192 (-0.9990234375L) == 0wb, 1); + check_inexact (testldblu_192 (-0.L) == 0uwb, 0); + check_inexact (testldblu_192 (-0.9990234375L) == 0uwb, 1); + check_inexact (testldblu_192 (0xffffffffffffffffp-2L) == 4611686018427387903uwb, 1); + check_inexact (testldblu_192 (0xffffffffffffffffp+128L) == 6277101735386680763495507056286727952638980837032266301440uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_inexact (testldbl_575 (-85070591730234615865843651857942052864.0L) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testldbl_575 (0xffffffffffffffffp+510L) == 61832600368276133511773678272426148233889331025751498446645922568076207932202076431648659257792374503198949281962308977915333294030066289778448068072486649492543280785653760wb, 0); + check_inexact (testldbl_575 (-0x10000000000000000p+510L) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 0); + check_inexact (testldbl_575 (-0xffffffffffffffffp-4L) == -1152921504606846975wb, 1); + check_inexact (testldbl_575 (0.L) == 0wb, 0); + check_inexact (testldbl_575 (-0.9990234375L) == 0wb, 1); + check_inexact (testldblu_575 (-0.L) == 0uwb, 0); + check_inexact (testldblu_575 (-0.9990234375L) == 0uwb, 1); + check_inexact (testldblu_575 (0xffffffffffffffffp-4L) == 1152921504606846975uwb, 1); + check_inexact (testldblu_575 (0xffffffffffffffffp+511L) == 123665200736552267023547356544852296467778662051502996893291845136152415864404152863297318515584749006397898563924617955830666588060132579556896136144973298985086561571307520uwb, 0); +#endif +#endif +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 + check_inexact (testflt128_135 (-85070591730234615865843651857942052864.0F128) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testflt128_135 (0x1ffffffffffffffffffffffffffffp+21F128) == 21778071482940061661655974875633163436032wb, 0); + check_inexact (testflt128_135 (-0x20000000000000000000000000000p+21F128) == -21778071482940061661655974875633165533183wb - 1, 0); + check_inexact (testflt128_135 (-0x1ffffffffffffffffffffffffffffp-1F128) == -5192296858534827628530496329220095wb, 1); + check_inexact (testflt128_135 (-0.F128) == 0wb, 0); + check_inexact (testflt128_135 (-0.9990234375F128) == 0wb, 1); + check_inexact (testflt128u_135 (0.F128) == 0uwb, 0); + check_inexact (testflt128u_135 (-0.9990234375F128) == 0uwb, 1); + check_inexact (testflt128u_135 (0x1ffffffffffffffffffffffffffffp-1F128) == 5192296858534827628530496329220095uwb, 1); + check_inexact (testflt128u_135 (0x1ffffffffffffffffffffffffffffp+22F128) == 43556142965880123323311949751266326872064uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_inexact (testflt128_192 (-85070591730234615865843651857942052864.0F128) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testflt128_192 (0x1ffffffffffffffffffffffffffffp+78F128) == 3138550867693340381917894711603832905819722818574723579904wb, 0); + check_inexact (testflt128_192 (-0x20000000000000000000000000000p+78F128) == -3138550867693340381917894711603833208051177722232017256447wb - 1, 0); + check_inexact (testflt128_192 (-0x1ffffffffffffffffffffffffffffp-4F128) == -649037107316853453566312041152511wb, 1); + check_inexact (testflt128_192 (-0.F128) == 0wb, 0); + check_inexact (testflt128_192 (-0.9990234375F128) == 0wb, 1); + check_inexact (testflt128u_192 (0.F128) == 0uwb, 0); + check_inexact (testflt128u_192 (-0.9990234375F128) == 0uwb, 1); + check_inexact (testflt128u_192 (0x1ffffffffffffffffffffffffffffp-4F128) == 649037107316853453566312041152511uwb, 1); + check_inexact (testflt128u_192 (0x1ffffffffffffffffffffffffffffp+79F128) == 6277101735386680763835789423207665811639445637149447159808uwb, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_inexact (testflt128_575 (-85070591730234615865843651857942052864.0F128) == -85070591730234615865843651857942052864wb, 0); + check_inexact (testflt128_575 (0x1ffffffffffffffffffffffffffffp+461F128) == 61832600368276133515125630254911791554520007845691312598455129804691160851602940042069550439343049559602369631548246946680753811425558728725309540242943660463695151425912832wb, 0); + check_inexact (testflt128_575 (-0x20000000000000000000000000000p+461F128) == -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 0); + check_inexact (testflt128_575 (-0x1ffffffffffffffffffffffffffffp-8F128) == -40564819207303340847894502572031wb, 1); + check_inexact (testflt128_575 (0.F128) == 0wb, 0); + check_inexact (testflt128_575 (-0.9990234375F128) == 0wb, 1); + check_inexact (testflt128u_575 (-0.F128) == 0uwb, 0); + check_inexact (testflt128u_575 (-0.9990234375F128) == 0uwb, 1); + check_inexact (testflt128u_575 (0x1ffffffffffffffffffffffffffffp-8F128) == 40564819207303340847894502572031uwb, 1); + check_inexact (testflt128u_575 (0x1ffffffffffffffffffffffffffffp+462F128) == 123665200736552267030251260509823583109040015691382625196910259609382321703205880084139100878686099119204739263096493893361507622851117457450619080485887320927390302851825664uwb, 0); +#endif +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-3.c b/SingleSource/Regression/C/gcc-dg/bitint-3.c new file mode 100644 index 0000000000..c32cb35210 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-3.c @@ -0,0 +1,40 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +_BitInt(32) a, b = 2147483647wb; +_BitInt(64) c, d = 9223372036854775807wb; +struct S { + _BitInt(2) a; + _BitInt(6) b; +} s, t = { -1wb - 1wb, 31wb }; + +void +foo (void) +{ + a = b; + c = d; + s.a = t.a; + s.b = t.b; +} + +void +bar (void) +{ + a += b; + c += d; + s.a += t.a; + s.b += t.b; +} + +#if __BITINT_MAXWIDTH__ >= 128 +unsigned _BitInt(128) e = 340282366920938463463374607431768211455uwb; +_BitInt(128) f = 20000000000000000000000000000000000000wb; +_BitInt(128) g = -20000000000000000000000000000000000000wb; +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +unsigned _BitInt(575) h = 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb; +_BitInt(575) i = 2000000000000000000000000000000000000000000wb; +_BitInt(575) j = -2000000000000000000000000000000000000000000wb; +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-30.c b/SingleSource/Regression/C/gcc-dg/bitint-30.c new file mode 100644 index 0000000000..48328f8eba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-30.c @@ -0,0 +1,470 @@ +/* PR c/102989 */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-options "-std=c2x" } */ +/* { dg-add-options ieee } */ + +#include + +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) float +testflt_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) float +testflt_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) float +testflt_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) double +testdbl_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) double +testdbl_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) double +testdbl_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) long double +testldbl_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) long double +testldbl_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) long double +testldbl_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _Float128 +testflt128_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _Float128 +testflt128_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _Float128 +testflt128_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +__attribute__((noipa)) void +check_except (int test, int inex, int ovf) +{ + if (!test) + __builtin_abort (); + if ((!fetestexcept (FE_INEXACT)) != (!inex)) + __builtin_abort (); + if ((!fetestexcept (FE_OVERFLOW)) != (!ovf)) + __builtin_abort (); + feclearexcept (FE_INEXACT | FE_OVERFLOW); +} + +int +main () +{ +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 + check_except (testflt_135 (151115713941029764726783wb) == 0xfffffep+53f, 1, 0); + check_except (testflt_135 (151115713941029764726784wb) == 0xfffffep+53f, 1, 0); + check_except (testflt_135 (151115713941029764726785wb) == 0xffffffp+53f, 1, 0); + check_except (testflt_135 (151115718444629392097280wb) == 0xffffffp+53f, 0, 0); + check_except (testflt_135 (151115722948229019467775wb) == 0xffffffp+53f, 1, 0); + check_except (testflt_135 (151115722948229019467776wb) == 0x1000000p+53f, 1, 0); + check_except (testflt_135 (151115722948229019467777wb) == 0x1000000p+53f, 1, 0); + check_except (testflt_135 (-340282346638528859811704183484516925440wb) == -0xffffffp+104f, 0, 0); + check_except (testflt_135 (-340282356779733661637539395458142568447wb) == -0xffffffp+104f, 1, 0); + check_except (testflt_135 (-340282356779733661637539395458142568448wb) == -__builtin_inff (), 1, 1); + check_except (testflt_135 (-21778071482940061661655974875633165533183wb - 1) == -__builtin_inff (), 1, 1); + check_except (testfltu_135 (151115713941029764726783uwb) == 0xfffffep+53f, 1, 0); + check_except (testfltu_135 (151115713941029764726784uwb) == 0xfffffep+53f, 1, 0); + check_except (testfltu_135 (151115713941029764726785uwb) == 0xffffffp+53f, 1, 0); + check_except (testfltu_135 (151115718444629392097280uwb) == 0xffffffp+53f, 0, 0); + check_except (testfltu_135 (151115722948229019467775uwb) == 0xffffffp+53f, 1, 0); + check_except (testfltu_135 (151115722948229019467776uwb) == 0x1000000p+53f, 1, 0); + check_except (testfltu_135 (151115722948229019467777uwb) == 0x1000000p+53f, 1, 0); + check_except (testfltu_135 (340282346638528859811704183484516925440uwb) == 0xffffffp+104f, 0, 0); + check_except (testfltu_135 (340282356779733661637539395458142568447uwb) == 0xffffffp+104f, 1, 0); + check_except (testfltu_135 (340282356779733661637539395458142568448uwb) == __builtin_inff (), 1, 1); + check_except (testfltu_135 (43556142965880123323311949751266331066367uwb) == __builtin_inff (), 1, 1); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_except (testflt_192 (-10141203895131470501001744613375wb) == -0xfffffep+79f, 1, 0); + check_except (testflt_192 (-10141203895131470501001744613376wb) == -0xfffffep+79f, 1, 0); + check_except (testflt_192 (-10141203895131470501001744613377wb) == -0xffffffp+79f, 1, 0); + check_except (testflt_192 (-10141204197362925404659038289920wb) == -0xffffffp+79f, 0, 0); + check_except (testflt_192 (-10141204499594380308316331966463wb) == -0xffffffp+79f, 1, 0); + check_except (testflt_192 (-10141204499594380308316331966464wb) == -0x1000000p+79f, 1, 0); + check_except (testflt_192 (-10141204499594380308316331966465wb) == -0x1000000p+79f, 1, 0); + check_except (testflt_192 (340282346638528859811704183484516925440wb) == 0xffffffp+104f, 0, 0); + check_except (testflt_192 (340282356779733661637539395458142568447wb) == 0xffffffp+104f, 1, 0); + check_except (testflt_192 (340282356779733661637539395458142568448wb) == __builtin_inff (), 1, 1); + check_except (testflt_192 (3138550867693340381917894711603833208051177722232017256447wb) == __builtin_inff (), 1, 1); + check_except (testfltu_192 (10141203895131470501001744613375uwb) == 0xfffffep+79f, 1, 0); + check_except (testfltu_192 (10141203895131470501001744613376uwb) == 0xfffffep+79f, 1, 0); + check_except (testfltu_192 (10141203895131470501001744613377uwb) == 0xffffffp+79f, 1, 0); + check_except (testfltu_192 (10141204197362925404659038289920uwb) == 0xffffffp+79f, 0, 0); + check_except (testfltu_192 (10141204499594380308316331966463uwb) == 0xffffffp+79f, 1, 0); + check_except (testfltu_192 (10141204499594380308316331966464uwb) == 0x1000000p+79f, 1, 0); + check_except (testfltu_192 (10141204499594380308316331966465uwb) == 0x1000000p+79f, 1, 0); + check_except (testfltu_192 (340282346638528859811704183484516925440uwb) == 0xffffffp+104f, 0, 0); + check_except (testfltu_192 (340282356779733661637539395458142568447uwb) == 0xffffffp+104f, 1, 0); + check_except (testfltu_192 (340282356779733661637539395458142568448uwb) == __builtin_inff (), 1, 1); + check_except (testfltu_192 (6277101735386680763835789423207666416102355444464034512895uwb) == __builtin_inff (), 1, 1); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_except (testflt_575 (10633823015541376812058405359715352575wb) == 0xfffffep+99f, 1, 0); + check_except (testflt_575 (10633823015541376812058405359715352576wb) == 0xfffffep+99f, 1, 0); + check_except (testflt_575 (10633823015541376812058405359715352577wb) == 0xffffffp+99f, 1, 0); + check_except (testflt_575 (10633823332454026869115755733891153920wb) == 0xffffffp+99f, 0, 0); + check_except (testflt_575 (10633823649366676926173106108066955263wb) == 0xffffffp+99f, 1, 0); + check_except (testflt_575 (10633823649366676926173106108066955264wb) == 0x1000000p+99f, 1, 0); + check_except (testflt_575 (10633823649366676926173106108066955265wb) == 0x1000000p+99f, 1, 0); + check_except (testflt_575 (-340282346638528859811704183484516925440wb) == -0xffffffp+104f, 0, 0); + check_except (testflt_575 (-340282356779733661637539395458142568447wb) == -0xffffffp+104f, 1, 0); + check_except (testflt_575 (-340282356779733661637539395458142568448wb) == -__builtin_inff (), 1, 1); + check_except (testflt_575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1) == -__builtin_inff (), 1, 1); + check_except (testfltu_575 (10633823015541376812058405359715352575uwb) == 0xfffffep+99f, 1, 0); + check_except (testfltu_575 (10633823015541376812058405359715352576uwb) == 0xfffffep+99f, 1, 0); + check_except (testfltu_575 (10633823015541376812058405359715352577uwb) == 0xffffffp+99f, 1, 0); + check_except (testfltu_575 (10633823332454026869115755733891153920uwb) == 0xffffffp+99f, 0, 0); + check_except (testfltu_575 (10633823649366676926173106108066955263uwb) == 0xffffffp+99f, 1, 0); + check_except (testfltu_575 (10633823649366676926173106108066955264uwb) == 0x1000000p+99f, 1, 0); + check_except (testfltu_575 (10633823649366676926173106108066955265uwb) == 0x1000000p+99f, 1, 0); + check_except (testfltu_575 (340282346638528859811704183484516925440uwb) == 0xffffffp+104f, 0, 0); + check_except (testfltu_575 (340282356779733661637539395458142568447uwb) == 0xffffffp+104f, 1, 0); + check_except (testfltu_575 (340282356779733661637539395458142568448uwb) == __builtin_inff (), 1, 1); + check_except (testfltu_575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb) == __builtin_inff (), 1, 1); +#endif +#endif +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 + check_except (testdbl_135 (-21267647932558650424686050812251602943wb) == -0x1ffffffffffffep+71, 1, 0); + check_except (testdbl_135 (-21267647932558650424686050812251602944wb) == -0x1ffffffffffffep+71, 1, 0); + check_except (testdbl_135 (-21267647932558650424686050812251602945wb) == -0x1fffffffffffffp+71, 1, 0); + check_except (testdbl_135 (-21267647932558651605277671529662906368wb) == -0x1fffffffffffffp+71, 0, 0); + check_except (testdbl_135 (-21267647932558652785869292247074209791wb) == -0x1fffffffffffffp+71, 1, 0); + check_except (testdbl_135 (-21267647932558652785869292247074209792wb) == -0x20000000000000p+71, 1, 0); + check_except (testdbl_135 (-21267647932558652785869292247074209793wb) == -0x20000000000000p+71, 1, 0); + check_except (testdbl_135 (21778071482940059243804335646374816120832wb) == 0x1fffffffffffffp+81, 0, 0); + check_except (testdbl_135 (21778071482940060452730155261003990827007wb) == 0x1fffffffffffffp+81, 1, 0); + check_except (testdbl_135 (21778071482940060452730155261003990827008wb) == 0x20000000000000p+81, 1, 0); + check_except (testdbl_135 (21778071482940060452730155261003990827009wb) == 0x20000000000000p+81, 1, 0); + check_except (testdbl_135 (21778071482940061661655974875633165533183wb) == 0x20000000000000p+81, 1, 0); + check_except (testdblu_135 (21267647932558650424686050812251602943uwb) == 0x1ffffffffffffep+71, 1, 0); + check_except (testdblu_135 (21267647932558650424686050812251602944uwb) == 0x1ffffffffffffep+71, 1, 0); + check_except (testdblu_135 (21267647932558650424686050812251602945uwb) == 0x1fffffffffffffp+71, 1, 0); + check_except (testdblu_135 (21267647932558651605277671529662906368uwb) == 0x1fffffffffffffp+71, 0, 0); + check_except (testdblu_135 (21267647932558652785869292247074209791uwb) == 0x1fffffffffffffp+71, 1, 0); + check_except (testdblu_135 (21267647932558652785869292247074209792uwb) == 0x20000000000000p+71, 1, 0); + check_except (testdblu_135 (21267647932558652785869292247074209793uwb) == 0x20000000000000p+71, 1, 0); + check_except (testdblu_135 (43556142965880118487608671292749632241664uwb) == 0x1fffffffffffffp+82, 0, 0); + check_except (testdblu_135 (43556142965880120905460310522007981654015uwb) == 0x1fffffffffffffp+82, 1, 0); + check_except (testdblu_135 (43556142965880120905460310522007981654016uwb) == 0x20000000000000p+82, 1, 0); + check_except (testdblu_135 (43556142965880120905460310522007981654017uwb) == 0x20000000000000p+82, 1, 0); + check_except (testdblu_135 (43556142965880123323311949751266331066367uwb) == 0x20000000000000p+82, 1, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_except (testdbl_192 (89202980794122477710862401666030147234430975wb) == 0x1ffffffffffffep+93, 1, 0); + check_except (testdbl_192 (89202980794122477710862401666030147234430976wb) == 0x1ffffffffffffep+93, 1, 0); + check_except (testdbl_192 (89202980794122477710862401666030147234430977wb) == 0x1fffffffffffffp+93, 1, 0); + check_except (testdbl_192 (89202980794122482662622558807551246830927872wb) == 0x1fffffffffffffp+93, 0, 0); + check_except (testdbl_192 (89202980794122487614382715949072346427424767wb) == 0x1fffffffffffffp+93, 1, 0); + check_except (testdbl_192 (89202980794122487614382715949072346427424768wb) == 0x20000000000000p+93, 1, 0); + check_except (testdbl_192 (89202980794122487614382715949072346427424769wb) == 0x20000000000000p+93, 1, 0); + check_except (testdbl_192 (-3138550867693340033468750984562846621555579712101368725504wb) == -0x1fffffffffffffp+138, 0, 0); + check_except (testdbl_192 (-3138550867693340207693322848083339914803378717166692990975wb) == -0x1fffffffffffffp+138, 1, 0); + check_except (testdbl_192 (-3138550867693340207693322848083339914803378717166692990976wb) == -0x20000000000000p+138, 1, 0); + check_except (testdbl_192 (-3138550867693340207693322848083339914803378717166692990977wb) == -0x20000000000000p+138, 1, 0); + check_except (testdbl_192 (-3138550867693340381917894711603833208051177722232017256447wb - 1) == -0x20000000000000p+138, 0, 0); + check_except (testdblu_192 (89202980794122477710862401666030147234430975uwb) == 0x1ffffffffffffep+93, 1, 0); + check_except (testdblu_192 (89202980794122477710862401666030147234430976uwb) == 0x1ffffffffffffep+93, 1, 0); + check_except (testdblu_192 (89202980794122477710862401666030147234430977uwb) == 0x1fffffffffffffp+93, 1, 0); + check_except (testdblu_192 (89202980794122482662622558807551246830927872uwb) == 0x1fffffffffffffp+93, 0, 0); + check_except (testdblu_192 (89202980794122487614382715949072346427424767uwb) == 0x1fffffffffffffp+93, 1, 0); + check_except (testdblu_192 (89202980794122487614382715949072346427424768uwb) == 0x20000000000000p+93, 1, 0); + check_except (testdblu_192 (89202980794122487614382715949072346427424769uwb) == 0x20000000000000p+93, 1, 0); + check_except (testdblu_192 (6277101735386680066937501969125693243111159424202737451008uwb) == 0x1fffffffffffffp+139, 0, 0); + check_except (testdblu_192 (6277101735386680415386645696166679829606757434333385981951uwb) == 0x1fffffffffffffp+139, 1, 0); + check_except (testdblu_192 (6277101735386680415386645696166679829606757434333385981952uwb) == 0x20000000000000p+139, 1, 0); + check_except (testdblu_192 (6277101735386680415386645696166679829606757434333385981953uwb) == 0x20000000000000p+139, 1, 0); + check_except (testdblu_192 (6277101735386680763835789423207666416102355444464034512895uwb) == 0x20000000000000p+139, 1, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_except (testdbl_575 (-615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392895wb) == -0x1ffffffffffffep+325, 1, 0); + check_except (testdbl_575 (-615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392896wb) == -0x1ffffffffffffep+325, 1, 0); + check_except (testdbl_575 (-615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392897wb) == -0x1fffffffffffffp+325, 1, 0); + check_except (testdbl_575 (-615656346818663669340274852095621329063676328675354936900147369028450764374312465492316685252079206152816780378112wb) == -0x1fffffffffffffp+325, 0, 0); + check_except (testdbl_575 (-615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363327wb) == -0x1fffffffffffffp+325, 1, 0); + check_except (testdbl_575 (-615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363328wb) == -0x20000000000000p+325, 1, 0); + check_except (testdbl_575 (-615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363329wb) == -0x20000000000000p+325, 1, 0); + check_except (testdbl_575 (61832600368276126650327970124302082526882038193909742709080463879918896882169507607035916867654709124839777195049479857541529867095829765369898539058829479405123401922117632wb) == 0x1fffffffffffffp+521, 0, 0); + check_except (testdbl_575 (61832600368276130082726800189606940017832437734606351343798113951571601579401237199807508566482735186119597525776757346189685562836258783930892538917151385692137547479646207wb) == 0x1fffffffffffffp+521, 1, 0); + check_except (testdbl_575 (61832600368276130082726800189606940017832437734606351343798113951571601579401237199807508566482735186119597525776757346189685562836258783930892538917151385692137547479646208wb) == 0x20000000000000p+521, 1, 0); + check_except (testdbl_575 (61832600368276130082726800189606940017832437734606351343798113951571601579401237199807508566482735186119597525776757346189685562836258783930892538917151385692137547479646209wb) == 0x20000000000000p+521, 1, 0); + check_except (testdbl_575 (61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb) == 0x20000000000000p+521, 1, 0); + check_except (testdblu_575 (615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392895uwb) == 0x1ffffffffffffep+325, 1, 0); + check_except (testdblu_575 (615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392896uwb) == 0x1ffffffffffffep+325, 1, 0); + check_except (testdblu_575 (615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392897uwb) == 0x1fffffffffffffp+325, 1, 0); + check_except (testdblu_575 (615656346818663669340274852095621329063676328675354936900147369028450764374312465492316685252079206152816780378112uwb) == 0x1fffffffffffffp+325, 0, 0); + check_except (testdblu_575 (615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363327uwb) == 0x1fffffffffffffp+325, 1, 0); + check_except (testdblu_575 (615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363328uwb) == 0x20000000000000p+325, 1, 0); + check_except (testdblu_575 (615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363329uwb) == 0x20000000000000p+325, 1, 0); + check_except (testdblu_575 (123665200736552253300655940248604165053764076387819485418160927759837793764339015214071833735309418249679554390098959715083059734191659530739797078117658958810246803844235264uwb) == 0x1fffffffffffffp+522, 0, 0); + check_except (testdblu_575 (123665200736552260165453600379213880035664875469212702687596227903143203158802474399615017132965470372239195051553514692379371125672517567861785077834302771384275094959292415uwb) == 0x1fffffffffffffp+522, 1, 0); + check_except (testdblu_575 (123665200736552260165453600379213880035664875469212702687596227903143203158802474399615017132965470372239195051553514692379371125672517567861785077834302771384275094959292416uwb) == 0x20000000000000p+522, 1, 0); + check_except (testdblu_575 (123665200736552260165453600379213880035664875469212702687596227903143203158802474399615017132965470372239195051553514692379371125672517567861785077834302771384275094959292417uwb) == 0x20000000000000p+522, 1, 0); + check_except (testdblu_575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb) == 0x20000000000000p+522, 1, 0); +#endif +#endif +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 + check_except (testldbl_135 (-27577662721237071616947187835994111wb) == -0xa9f5e144d113e1c4p+51L, 1, 0); + check_except (testldbl_135 (-27577662721237071616947187835994112wb) == -0xa9f5e144d113e1c4p+51L, 1, 0); + check_except (testldbl_135 (-27577662721237071616947187835994113wb) == -0xa9f5e144d113e1c5p+51L, 1, 0); + check_except (testldbl_135 (-27577662721237071618073087742836736wb) == -0xa9f5e144d113e1c5p+51L, 0, 0); + check_except (testldbl_135 (-27577662721237071619198987649679359wb) == -0xa9f5e144d113e1c5p+51L, 1, 0); + check_except (testldbl_135 (-27577662721237071619198987649679360wb) == -0xa9f5e144d113e1c6p+51L, 1, 0); + check_except (testldbl_135 (-27577662721237071619198987649679361wb) == -0xa9f5e144d113e1c6p+51L, 1, 0); + check_except (testldbl_135 (-21778071482940061660475383254915754229760wb) == -0xffffffffffffffffp+70L, 0, 0); + check_except (testldbl_135 (-21778071482940061661065679065274459881471wb) == -0xffffffffffffffffp+70L, 1, 0); + check_except (testldbl_135 (-21778071482940061661065679065274459881472wb) == -0x10000000000000000p+70L, 1, 0); + check_except (testldbl_135 (-21778071482940061661065679065274459881473wb) == -0x10000000000000000p+70L, 1, 0); + check_except (testldbl_135 (-21778071482940061661655974875633165533183wb - 1) == -0x10000000000000000p+70L, 0, 0); + check_except (testldblu_135 (27577662721237071616947187835994111uwb) == 0xa9f5e144d113e1c4p+51L, 1, 0); + check_except (testldblu_135 (27577662721237071616947187835994112uwb) == 0xa9f5e144d113e1c4p+51L, 1, 0); + check_except (testldblu_135 (27577662721237071616947187835994113uwb) == 0xa9f5e144d113e1c5p+51L, 1, 0); + check_except (testldblu_135 (27577662721237071618073087742836736uwb) == 0xa9f5e144d113e1c5p+51L, 0, 0); + check_except (testldblu_135 (27577662721237071619198987649679359uwb) == 0xa9f5e144d113e1c5p+51L, 1, 0); + check_except (testldblu_135 (27577662721237071619198987649679360uwb) == 0xa9f5e144d113e1c6p+51L, 1, 0); + check_except (testldblu_135 (27577662721237071619198987649679361uwb) == 0xa9f5e144d113e1c6p+51L, 1, 0); + check_except (testldblu_135 (43556142965880123320950766509831508459520uwb) == 0xffffffffffffffffp+71L, 0, 0); + check_except (testldblu_135 (43556142965880123322131358130548919762943uwb) == 0xffffffffffffffffp+71L, 1, 0); + check_except (testldblu_135 (43556142965880123322131358130548919762944uwb) == 0x10000000000000000p+71L, 1, 0); + check_except (testldblu_135 (43556142965880123322131358130548919762945uwb) == 0x10000000000000000p+71L, 1, 0); + check_except (testldblu_135 (43556142965880123323311949751266331066367uwb) == 0x10000000000000000p+71L, 1, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_except (testldbl_192 (96388802158769743653878219701497927252918090596351wb) == 0x83e75ebf94ce024ep+103L, 1, 0); + check_except (testldbl_192 (96388802158769743653878219701497927252918090596352wb) == 0x83e75ebf94ce024ep+103L, 1, 0); + check_except (testldbl_192 (96388802158769743653878219701497927252918090596353wb) == 0x83e75ebf94ce024fp+103L, 1, 0); + check_except (testldbl_192 (96388802158769743658948822102410844858904903417856wb) == 0x83e75ebf94ce024fp+103L, 0, 0); + check_except (testldbl_192 (96388802158769743664019424503323762464891716239359wb) == 0x83e75ebf94ce024fp+103L, 1, 0); + check_except (testldbl_192 (96388802158769743664019424503323762464891716239360wb) == 0x83e75ebf94ce0250p+103L, 1, 0); + check_except (testldbl_192 (96388802158769743664019424503323762464891716239361wb) == 0x83e75ebf94ce0250p+103L, 1, 0); + check_except (testldbl_192 (-3138550867693340381747753528143363976319490418516133150720wb) == -0xffffffffffffffffp+127L, 0, 0); + check_except (testldbl_192 (-3138550867693340381832824119873598592185334070374075203583wb) == -0xffffffffffffffffp+127L, 1, 0); + check_except (testldbl_192 (-3138550867693340381832824119873598592185334070374075203584wb) == -0x10000000000000000p+127L, 1, 0); + check_except (testldbl_192 (-3138550867693340381832824119873598592185334070374075203585wb) == -0x10000000000000000p+127L, 1, 0); + check_except (testldbl_192 (-3138550867693340381917894711603833208051177722232017256447wb - 1wb) == -0x10000000000000000p+127L, 0, 0); + check_except (testldblu_192 (96388802158769743653878219701497927252918090596351uwb) == 0x83e75ebf94ce024ep+103L, 1, 0); + check_except (testldblu_192 (96388802158769743653878219701497927252918090596352uwb) == 0x83e75ebf94ce024ep+103L, 1, 0); + check_except (testldblu_192 (96388802158769743653878219701497927252918090596353uwb) == 0x83e75ebf94ce024fp+103L, 1, 0); + check_except (testldblu_192 (96388802158769743658948822102410844858904903417856uwb) == 0x83e75ebf94ce024fp+103L, 0, 0); + check_except (testldblu_192 (96388802158769743664019424503323762464891716239359uwb) == 0x83e75ebf94ce024fp+103L, 1, 0); + check_except (testldblu_192 (96388802158769743664019424503323762464891716239360uwb) == 0x83e75ebf94ce0250p+103L, 1, 0); + check_except (testldblu_192 (96388802158769743664019424503323762464891716239361uwb) == 0x83e75ebf94ce0250p+103L, 1, 0); + check_except (testldblu_192 (6277101735386680763495507056286727952638980837032266301440uwb) == 0xffffffffffffffffp+128L, 0, 0); + check_except (testldblu_192 (6277101735386680763665648239747197184370668140748150407167uwb) == 0xffffffffffffffffp+128L, 1, 0); + check_except (testldblu_192 (6277101735386680763665648239747197184370668140748150407168uwb) == 0x10000000000000000p+128L, 1, 0); + check_except (testldblu_192 (6277101735386680763665648239747197184370668140748150407169uwb) == 0x10000000000000000p+128L, 1, 0); + check_except (testldblu_192 (6277101735386680763835789423207666416102355444464034512895uwb) == 0x10000000000000000p+128L, 1, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_except (testldbl_575 (-61832600368276133511773678272426148233889331025751498446645922568076207932202076431648659257792374503198949281962308977915333294030066289778448068072486649492543280785653760wb) == -0xffffffffffffffffp+510L, 0, 0); + check_except (testldbl_575 (-61832600368276133513449654263668972871336084150527229212580843295650257104417521612113879761551567875299183569233171906376587276303377046135167303423979970735847486911414271wb) == -0xffffffffffffffffp+510L, 1, 0); + check_except (testldbl_575 (-61832600368276133513449654263668972871336084150527229212580843295650257104417521612113879761551567875299183569233171906376587276303377046135167303423979970735847486911414272wb) == -0x10000000000000000p+510L, 1, 0); + check_except (testldbl_575 (-61832600368276133513449654263668972871336084150527229212580843295650257104417521612113879761551567875299183569233171906376587276303377046135167303423979970735847486911414273wb) == -0x10000000000000000p+510L, 1, 0); + check_except (testldbl_575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1) == -0x10000000000000000p+510L, 0, 0); + check_except (testldblu_575 (123665200736552267023547356544852296467778662051502996893291845136152415864404152863297318515584749006397898563924617955830666588060132579556896136144973298985086561571307520uwb) == 0xffffffffffffffffp+511L, 0, 0); + check_except (testldblu_575 (123665200736552267026899308527337945742672168301054458425161686591300514208835043224227759523103135750598367138466343812753174552606754092270334606847959941471694973822828543uwb) == 0xffffffffffffffffp+511L, 1, 0); + check_except (testldblu_575 (123665200736552267026899308527337945742672168301054458425161686591300514208835043224227759523103135750598367138466343812753174552606754092270334606847959941471694973822828544uwb) == 0x10000000000000000p+511L, 1, 0); + check_except (testldblu_575 (123665200736552267026899308527337945742672168301054458425161686591300514208835043224227759523103135750598367138466343812753174552606754092270334606847959941471694973822828545uwb) == 0x10000000000000000p+511L, 1, 0); + check_except (testldblu_575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb) == 0x10000000000000000p+511L, 1, 0); +#endif +#endif +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 + check_except (testflt128_135 (-21646332438261169091754659013488783917055wb) == -0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 1, 0); + check_except (testflt128_135 (-21646332438261169091754659013488783917056wb) == -0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 1, 0); + check_except (testflt128_135 (-21646332438261169091754659013488783917057wb) == -0x1fce71fdcfb1797b42dede66ac9edp+21F128, 1, 0); + check_except (testflt128_135 (-21646332438261169091754659013488784965632wb) == -0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0, 0); + check_except (testflt128_135 (-21646332438261169091754659013488786014207wb) == -0x1fce71fdcfb1797b42dede66ac9edp+21F128, 1, 0); + check_except (testflt128_135 (-21646332438261169091754659013488786014208wb) == -0x1fce71fdcfb1797b42dede66ac9eep+21F128, 1, 0); + check_except (testflt128_135 (-21646332438261169091754659013488786014209wb) == -0x1fce71fdcfb1797b42dede66ac9eep+21F128, 1, 0); + check_except (testflt128u_135 (21646332438261169091754659013488783917055uwb) == 0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 1, 0); + check_except (testflt128u_135 (21646332438261169091754659013488783917056uwb) == 0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 1, 0); + check_except (testflt128u_135 (21646332438261169091754659013488783917057uwb) == 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 1, 0); + check_except (testflt128u_135 (21646332438261169091754659013488784965632uwb) == 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0, 0); + check_except (testflt128u_135 (21646332438261169091754659013488786014207uwb) == 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 1, 0); + check_except (testflt128u_135 (21646332438261169091754659013488786014208uwb) == 0x1fce71fdcfb1797b42dede66ac9eep+21F128, 1, 0); + check_except (testflt128u_135 (21646332438261169091754659013488786014209uwb) == 0x1fce71fdcfb1797b42dede66ac9eep+21F128, 1, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_except (testflt128_192 (3138550867693340381917894711603832905819722818574723579904wb) == 0x1ffffffffffffffffffffffffffffp+78F128, 0, 0); + check_except (testflt128_192 (3138550867693340381917894711603833056935450270403370418175wb) == 0x1ffffffffffffffffffffffffffffp+78F128, 1, 0); + check_except (testflt128_192 (3138550867693340381917894711603833056935450270403370418176wb) == 0x20000000000000000000000000000p+78F128, 1, 0); + check_except (testflt128_192 (3138550867693340381917894711603833056935450270403370418177wb) == 0x20000000000000000000000000000p+78F128, 1, 0); + check_except (testflt128_192 (3138550867693340381917894711603833208051177722232017256447wb) == 0x20000000000000000000000000000p+78F128, 1, 0); + check_except (testflt128u_192 (6277101735386680763835789423207665811639445637149447159808uwb) == 0x1ffffffffffffffffffffffffffffp+79F128, 0, 0); + check_except (testflt128u_192 (6277101735386680763835789423207666113870900540806740836351uwb) == 0x1ffffffffffffffffffffffffffffp+79F128, 1, 0); + check_except (testflt128u_192 (6277101735386680763835789423207666113870900540806740836352uwb) == 0x20000000000000000000000000000p+79F128, 1, 0); + check_except (testflt128u_192 (6277101735386680763835789423207666113870900540806740836353uwb) == 0x20000000000000000000000000000p+79F128, 1, 0); + check_except (testflt128u_192 (6277101735386680763835789423207666416102355444464034512895uwb) == 0x20000000000000000000000000000p+79F128, 1, 0); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_except (testflt128_575 (-39695651458311907436978914487787846289740055435765388813682045155135192382154626611682813571487190641804615256990296246545713518740501887218789991403746059512699763279527936wb) == -0x148b25ce53790ddc343a80e5af6bap+461F128, 0, 0); + check_except (testflt128_575 (-39695651458311907436978914487787849266871470150571212503712362264401765094669639986937588484471046485703139369468190190624257242316066424102078490670010875270428034085158911wb) == -0x148b25ce53790ddc343a80e5af6bap+461F128, 1, 0); + check_except (testflt128_575 (-39695651458311907436978914487787849266871470150571212503712362264401765094669639986937588484471046485703139369468190190624257242316066424102078490670010875270428034085158912wb) == -0x148b25ce53790ddc343a80e5af6bap+461F128, 1, 0); + check_except (testflt128_575 (-39695651458311907436978914487787849266871470150571212503712362264401765094669639986937588484471046485703139369468190190624257242316066424102078490670010875270428034085158913wb) == -0x148b25ce53790ddc343a80e5af6bbp+461F128, 1, 0); + check_except (testflt128_575 (-39695651458311907436978914487787852244002884865377036193742679373668337807184653362192363397454902329601663481946084134702800965891630960985366989936275691028156304890789888wb) == -0x148b25ce53790ddc343a80e5af6bbp+461F128, 0, 0); + check_except (testflt128_575 (-39695651458311907436978914487787855221134299580182859883772996482934910519699666737447138310438758173500187594423978078781344689467195497868655489202540506785884575696420863wb) == -0x148b25ce53790ddc343a80e5af6bbp+461F128, 1, 0); + check_except (testflt128_575 (-39695651458311907436978914487787855221134299580182859883772996482934910519699666737447138310438758173500187594423978078781344689467195497868655489202540506785884575696420864wb) == -0x148b25ce53790ddc343a80e5af6bcp+461F128, 1, 0); + check_except (testflt128_575 (-39695651458311907436978914487787855221134299580182859883772996482934910519699666737447138310438758173500187594423978078781344689467195497868655489202540506785884575696420865wb) == -0x148b25ce53790ddc343a80e5af6bcp+461F128, 1, 0); + check_except (testflt128_575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1) == -0x20000000000000000000000000000p+461F128, 0, 0); + check_except (testflt128u_575 (79391302916623814873957828975575692579480110871530777627364090310270384764309253223365627142974381283609230513980592493091427037481003774437579982807492119025399526559055872uwb) == 0x148b25ce53790ddc343a80e5af6bap+462F128, 0, 0); + check_except (testflt128u_575 (79391302916623814873957828975575698533742940301142425007424724528803530189339279973875176968942092971406278738936380381248514484632132848204156981340021750540856068170317823uwb) == 0x148b25ce53790ddc343a80e5af6bap+462F128, 1, 0); + check_except (testflt128u_575 (79391302916623814873957828975575698533742940301142425007424724528803530189339279973875176968942092971406278738936380381248514484632132848204156981340021750540856068170317824uwb) == 0x148b25ce53790ddc343a80e5af6bap+462F128, 1, 0); + check_except (testflt128u_575 (79391302916623814873957828975575698533742940301142425007424724528803530189339279973875176968942092971406278738936380381248514484632132848204156981340021750540856068170317825uwb) == 0x148b25ce53790ddc343a80e5af6bbp+462F128, 1, 0); + check_except (testflt128u_575 (79391302916623814873957828975575704488005769730754072387485358747336675614369306724384726794909804659203326963892168269405601931783261921970733979872551382056312609781579776uwb) == 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0, 0); + check_except (testflt128u_575 (79391302916623814873957828975575710442268599160365719767545992965869821039399333474894276620877516347000375188847956157562689378934390995737310978405081013571769151392841727uwb) == 0x148b25ce53790ddc343a80e5af6bbp+462F128, 1, 0); + check_except (testflt128u_575 (79391302916623814873957828975575710442268599160365719767545992965869821039399333474894276620877516347000375188847956157562689378934390995737310978405081013571769151392841728uwb) == 0x148b25ce53790ddc343a80e5af6bcp+462F128, 1, 0); + check_except (testflt128u_575 (79391302916623814873957828975575710442268599160365719767545992965869821039399333474894276620877516347000375188847956157562689378934390995737310978405081013571769151392841729uwb) == 0x148b25ce53790ddc343a80e5af6bcp+462F128, 1, 0); + check_except (testflt128u_575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb) == 0x20000000000000000000000000000p+462F128, 1, 0); +#endif +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-31.c b/SingleSource/Regression/C/gcc-dg/bitint-31.c new file mode 100644 index 0000000000..65ac271ebb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-31.c @@ -0,0 +1,480 @@ +/* PR c/102989 */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv } */ +/* { dg-options "-std=c2x" } */ +/* { dg-add-options ieee } */ + +#include + +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) float +testflt_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) float +testflt_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) float +testflt_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) double +testdbl_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) double +testdbl_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) double +testdbl_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) long double +testldbl_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) long double +testldbl_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) long double +testldbl_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _Float128 +testflt128_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _Float128 +testflt128_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _Float128 +testflt128_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#define check_round(expr, vn, vd, vu, vz) \ + do \ + { \ + fesetround (FE_TONEAREST); \ + if (expr != vn) \ + __builtin_abort (); \ + fesetround (FE_DOWNWARD); \ + if (expr != vd) \ + __builtin_abort (); \ + fesetround (FE_UPWARD); \ + if (expr != vu) \ + __builtin_abort (); \ + fesetround (FE_TOWARDZERO); \ + if (expr != vz) \ + __builtin_abort (); \ + } \ + while (0) + +#define check_round_same(expr, vn) check_round (expr, vn, vn, vn, vn) + +int +main () +{ +#if defined(FE_TONEAREST) && defined(FE_DOWNWARD) && defined(FE_UPWARD) && defined (FE_TOWARDZERO) +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 + check_round (testflt_135 (151115713941029764726783wb), 0xfffffep+53f, 0xfffffep+53f, 0xffffffp+53f, 0xfffffep+53f); + check_round (testflt_135 (151115713941029764726784wb), 0xfffffep+53f, 0xfffffep+53f, 0xffffffp+53f, 0xfffffep+53f); + check_round (testflt_135 (151115713941029764726785wb), 0xffffffp+53f, 0xfffffep+53f, 0xffffffp+53f, 0xfffffep+53f); + check_round_same (testflt_135 (151115718444629392097280wb), 0xffffffp+53f); + check_round (testflt_135 (151115722948229019467775wb), 0xffffffp+53f, 0xffffffp+53f, 0x1000000p+53f, 0xffffffp+53f); + check_round (testflt_135 (151115722948229019467776wb), 0x1000000p+53f, 0xffffffp+53f, 0x1000000p+53f, 0xffffffp+53f); + check_round (testflt_135 (151115722948229019467777wb), 0x1000000p+53f, 0xffffffp+53f, 0x1000000p+53f, 0xffffffp+53f); + check_round_same (testflt_135 (-340282346638528859811704183484516925440wb), -0xffffffp+104f); + check_round (testflt_135 (-340282356779733661637539395458142568447wb), -0xffffffp+104f, -__builtin_inff (), -0xffffffp+104f, -0xffffffp+104f); + check_round (testflt_135 (-340282356779733661637539395458142568448wb), -__builtin_inff (), -__builtin_inff (), -0xffffffp+104f, -0xffffffp+104f); + check_round (testflt_135 (-21778071482940061661655974875633165533183wb - 1), -__builtin_inff (), -__builtin_inff (), -0xffffffp+104f, -0xffffffp+104f); + check_round (testfltu_135 (151115713941029764726783uwb), 0xfffffep+53f, 0xfffffep+53f, 0xffffffp+53f, 0xfffffep+53f); + check_round (testfltu_135 (151115713941029764726784uwb), 0xfffffep+53f, 0xfffffep+53f, 0xffffffp+53f, 0xfffffep+53f); + check_round (testfltu_135 (151115713941029764726785uwb), 0xffffffp+53f, 0xfffffep+53f, 0xffffffp+53f, 0xfffffep+53f); + check_round_same (testfltu_135 (151115718444629392097280uwb), 0xffffffp+53f); + check_round (testfltu_135 (151115722948229019467775uwb), 0xffffffp+53f, 0xffffffp+53f, 0x1000000p+53f, 0xffffffp+53f); + check_round (testfltu_135 (151115722948229019467776uwb), 0x1000000p+53f, 0xffffffp+53f, 0x1000000p+53f, 0xffffffp+53f); + check_round (testfltu_135 (151115722948229019467777uwb), 0x1000000p+53f, 0xffffffp+53f, 0x1000000p+53f, 0xffffffp+53f); + check_round_same (testfltu_135 (340282346638528859811704183484516925440uwb), 0xffffffp+104f); + check_round (testfltu_135 (340282356779733661637539395458142568447uwb), 0xffffffp+104f, 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testfltu_135 (340282356779733661637539395458142568448uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testfltu_135 (43556142965880123323311949751266331066367uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_round (testflt_192 (-10141203895131470501001744613375wb), -0xfffffep+79f, -0xffffffp+79f, -0xfffffep+79f, -0xfffffep+79f); + check_round (testflt_192 (-10141203895131470501001744613376wb), -0xfffffep+79f, -0xffffffp+79f, -0xfffffep+79f, -0xfffffep+79f); + check_round (testflt_192 (-10141203895131470501001744613377wb), -0xffffffp+79f, -0xffffffp+79f, -0xfffffep+79f, -0xfffffep+79f); + check_round_same (testflt_192 (-10141204197362925404659038289920wb), -0xffffffp+79f); + check_round (testflt_192 (-10141204499594380308316331966463wb), -0xffffffp+79f, -0x1000000p+79f, -0xffffffp+79f, -0xffffffp+79f); + check_round (testflt_192 (-10141204499594380308316331966464wb), -0x1000000p+79f, -0x1000000p+79f, -0xffffffp+79f, -0xffffffp+79f); + check_round (testflt_192 (-10141204499594380308316331966465wb), -0x1000000p+79f, -0x1000000p+79f, -0xffffffp+79f, -0xffffffp+79f); + check_round_same (testflt_192 (340282346638528859811704183484516925440wb), 0xffffffp+104f); + check_round (testflt_192 (340282356779733661637539395458142568447wb), 0xffffffp+104f, 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testflt_192 (340282356779733661637539395458142568448wb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testflt_192 (3138550867693340381917894711603833208051177722232017256447wb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testfltu_192 (10141203895131470501001744613375uwb), 0xfffffep+79f, 0xfffffep+79f, 0xffffffp+79f, 0xfffffep+79f); + check_round (testfltu_192 (10141203895131470501001744613376uwb), 0xfffffep+79f, 0xfffffep+79f, 0xffffffp+79f, 0xfffffep+79f); + check_round (testfltu_192 (10141203895131470501001744613377uwb), 0xffffffp+79f, 0xfffffep+79f, 0xffffffp+79f, 0xfffffep+79f); + check_round_same (testfltu_192 (10141204197362925404659038289920uwb), 0xffffffp+79f); + check_round (testfltu_192 (10141204499594380308316331966463uwb), 0xffffffp+79f, 0xffffffp+79f, 0x1000000p+79f, 0xffffffp+79f); + check_round (testfltu_192 (10141204499594380308316331966464uwb), 0x1000000p+79f, 0xffffffp+79f, 0x1000000p+79f, 0xffffffp+79f); + check_round (testfltu_192 (10141204499594380308316331966465uwb), 0x1000000p+79f, 0xffffffp+79f, 0x1000000p+79f, 0xffffffp+79f); + check_round_same (testfltu_192 (340282346638528859811704183484516925440uwb), 0xffffffp+104f); + check_round (testfltu_192 (340282356779733661637539395458142568447uwb), 0xffffffp+104f, 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testfltu_192 (340282356779733661637539395458142568448uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testfltu_192 (6277101735386680763835789423207666416102355444464034512895uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_round (testflt_575 (10633823015541376812058405359715352575wb), 0xfffffep+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); + check_round (testflt_575 (10633823015541376812058405359715352576wb), 0xfffffep+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); + check_round (testflt_575 (10633823015541376812058405359715352577wb), 0xffffffp+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); + check_round_same (testflt_575 (10633823332454026869115755733891153920wb), 0xffffffp+99f); + check_round (testflt_575 (10633823649366676926173106108066955263wb), 0xffffffp+99f, 0xffffffp+99f, 0x1000000p+99f, 0xffffffp+99f); + check_round (testflt_575 (10633823649366676926173106108066955264wb), 0x1000000p+99f, 0xffffffp+99f, 0x1000000p+99f, 0xffffffp+99f); + check_round (testflt_575 (10633823649366676926173106108066955265wb), 0x1000000p+99f, 0xffffffp+99f, 0x1000000p+99f, 0xffffffp+99f); + check_round_same (testflt_575 (-340282346638528859811704183484516925440wb), -0xffffffp+104f); + check_round (testflt_575 (-340282356779733661637539395458142568447wb), -0xffffffp+104f, -__builtin_inff (), -0xffffffp+104f, -0xffffffp+104f); + check_round (testflt_575 (-340282356779733661637539395458142568448wb), -__builtin_inff (), -__builtin_inff (), -0xffffffp+104f, -0xffffffp+104f); + check_round (testflt_575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), -__builtin_inff (), -__builtin_inff (), -0xffffffp+104f, -0xffffffp+104f); + check_round (testfltu_575 (10633823015541376812058405359715352575uwb), 0xfffffep+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); + check_round (testfltu_575 (10633823015541376812058405359715352576uwb), 0xfffffep+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); + check_round (testfltu_575 (10633823015541376812058405359715352577uwb), 0xffffffp+99f, 0xfffffep+99f, 0xffffffp+99f, 0xfffffep+99f); + check_round_same (testfltu_575 (10633823332454026869115755733891153920uwb), 0xffffffp+99f); + check_round (testfltu_575 (10633823649366676926173106108066955263uwb), 0xffffffp+99f, 0xffffffp+99f, 0x1000000p+99f, 0xffffffp+99f); + check_round (testfltu_575 (10633823649366676926173106108066955264uwb), 0x1000000p+99f, 0xffffffp+99f, 0x1000000p+99f, 0xffffffp+99f); + check_round (testfltu_575 (10633823649366676926173106108066955265uwb), 0x1000000p+99f, 0xffffffp+99f, 0x1000000p+99f, 0xffffffp+99f); + check_round_same (testfltu_575 (340282346638528859811704183484516925440uwb), 0xffffffp+104f); + check_round (testfltu_575 (340282356779733661637539395458142568447uwb), 0xffffffp+104f, 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testfltu_575 (340282356779733661637539395458142568448uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); + check_round (testfltu_575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb), __builtin_inff (), 0xffffffp+104f, __builtin_inff (), 0xffffffp+104f); +#endif +#endif +#if __DBL_MANT_DIG__, 53 +#if __BITINT_MAXWIDTH__ >= 135 + check_round (testdbl_135 (-21267647932558650424686050812251602943wb), -0x1ffffffffffffep+71, -0x1fffffffffffffp+71, -0x1ffffffffffffep+71, -0x1ffffffffffffep+71); + check_round (testdbl_135 (-21267647932558650424686050812251602944wb), -0x1ffffffffffffep+71, -0x1fffffffffffffp+71, -0x1ffffffffffffep+71, -0x1ffffffffffffep+71); + check_round (testdbl_135 (-21267647932558650424686050812251602945wb), -0x1fffffffffffffp+71, -0x1fffffffffffffp+71, -0x1ffffffffffffep+71, -0x1ffffffffffffep+71); + check_round_same (testdbl_135 (-21267647932558651605277671529662906368wb), -0x1fffffffffffffp+71); + check_round (testdbl_135 (-21267647932558652785869292247074209791wb), -0x1fffffffffffffp+71, -0x20000000000000p+71, -0x1fffffffffffffp+71, -0x1fffffffffffffp+71); + check_round (testdbl_135 (-21267647932558652785869292247074209792wb), -0x20000000000000p+71, -0x20000000000000p+71, -0x1fffffffffffffp+71, -0x1fffffffffffffp+71); + check_round (testdbl_135 (-21267647932558652785869292247074209793wb), -0x20000000000000p+71, -0x20000000000000p+71, -0x1fffffffffffffp+71, -0x1fffffffffffffp+71); + check_round_same (testdbl_135 (21778071482940059243804335646374816120832wb), 0x1fffffffffffffp+81); + check_round (testdbl_135 (21778071482940060452730155261003990827007wb), 0x1fffffffffffffp+81, 0x1fffffffffffffp+81, 0x20000000000000p+81, 0x1fffffffffffffp+81); + check_round (testdbl_135 (21778071482940060452730155261003990827008wb), 0x20000000000000p+81, 0x1fffffffffffffp+81, 0x20000000000000p+81, 0x1fffffffffffffp+81); + check_round (testdbl_135 (21778071482940060452730155261003990827009wb), 0x20000000000000p+81, 0x1fffffffffffffp+81, 0x20000000000000p+81, 0x1fffffffffffffp+81); + check_round (testdbl_135 (21778071482940061661655974875633165533183wb), 0x20000000000000p+81, 0x1fffffffffffffp+81, 0x20000000000000p+81, 0x1fffffffffffffp+81); + check_round (testdblu_135 (21267647932558650424686050812251602943uwb), 0x1ffffffffffffep+71, 0x1ffffffffffffep+71, 0x1fffffffffffffp+71, 0x1ffffffffffffep+71); + check_round (testdblu_135 (21267647932558650424686050812251602944uwb), 0x1ffffffffffffep+71, 0x1ffffffffffffep+71, 0x1fffffffffffffp+71, 0x1ffffffffffffep+71); + check_round (testdblu_135 (21267647932558650424686050812251602945uwb), 0x1fffffffffffffp+71, 0x1ffffffffffffep+71, 0x1fffffffffffffp+71, 0x1ffffffffffffep+71); + check_round_same (testdblu_135 (21267647932558651605277671529662906368uwb), 0x1fffffffffffffp+71); + check_round (testdblu_135 (21267647932558652785869292247074209791uwb), 0x1fffffffffffffp+71, 0x1fffffffffffffp+71, 0x20000000000000p+71, 0x1fffffffffffffp+71); + check_round (testdblu_135 (21267647932558652785869292247074209792uwb), 0x20000000000000p+71, 0x1fffffffffffffp+71, 0x20000000000000p+71, 0x1fffffffffffffp+71); + check_round (testdblu_135 (21267647932558652785869292247074209793uwb), 0x20000000000000p+71, 0x1fffffffffffffp+71, 0x20000000000000p+71, 0x1fffffffffffffp+71); + check_round_same (testdblu_135 (43556142965880118487608671292749632241664uwb), 0x1fffffffffffffp+82); + check_round (testdblu_135 (43556142965880120905460310522007981654015uwb), 0x1fffffffffffffp+82, 0x1fffffffffffffp+82, 0x20000000000000p+82, 0x1fffffffffffffp+82); + check_round (testdblu_135 (43556142965880120905460310522007981654016uwb), 0x20000000000000p+82, 0x1fffffffffffffp+82, 0x20000000000000p+82, 0x1fffffffffffffp+82); + check_round (testdblu_135 (43556142965880120905460310522007981654017uwb), 0x20000000000000p+82, 0x1fffffffffffffp+82, 0x20000000000000p+82, 0x1fffffffffffffp+82); + check_round (testdblu_135 (43556142965880123323311949751266331066367uwb), 0x20000000000000p+82, 0x1fffffffffffffp+82, 0x20000000000000p+82, 0x1fffffffffffffp+82); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_round (testdbl_192 (89202980794122477710862401666030147234430975wb), 0x1ffffffffffffep+93, 0x1ffffffffffffep+93, 0x1fffffffffffffp+93, 0x1ffffffffffffep+93); + check_round (testdbl_192 (89202980794122477710862401666030147234430976wb), 0x1ffffffffffffep+93, 0x1ffffffffffffep+93, 0x1fffffffffffffp+93, 0x1ffffffffffffep+93); + check_round (testdbl_192 (89202980794122477710862401666030147234430977wb), 0x1fffffffffffffp+93, 0x1ffffffffffffep+93, 0x1fffffffffffffp+93, 0x1ffffffffffffep+93); + check_round_same (testdbl_192 (89202980794122482662622558807551246830927872wb), 0x1fffffffffffffp+93); + check_round (testdbl_192 (89202980794122487614382715949072346427424767wb), 0x1fffffffffffffp+93, 0x1fffffffffffffp+93, 0x20000000000000p+93, 0x1fffffffffffffp+93); + check_round (testdbl_192 (89202980794122487614382715949072346427424768wb), 0x20000000000000p+93, 0x1fffffffffffffp+93, 0x20000000000000p+93, 0x1fffffffffffffp+93); + check_round (testdbl_192 (89202980794122487614382715949072346427424769wb), 0x20000000000000p+93, 0x1fffffffffffffp+93, 0x20000000000000p+93, 0x1fffffffffffffp+93); + check_round_same (testdbl_192 (-3138550867693340033468750984562846621555579712101368725504wb), -0x1fffffffffffffp+138); + check_round (testdbl_192 (-3138550867693340207693322848083339914803378717166692990975wb), -0x1fffffffffffffp+138, -0x20000000000000p+138, -0x1fffffffffffffp+138, -0x1fffffffffffffp+138); + check_round (testdbl_192 (-3138550867693340207693322848083339914803378717166692990976wb), -0x20000000000000p+138, -0x20000000000000p+138, -0x1fffffffffffffp+138, -0x1fffffffffffffp+138); + check_round (testdbl_192 (-3138550867693340207693322848083339914803378717166692990977wb), -0x20000000000000p+138, -0x20000000000000p+138, -0x1fffffffffffffp+138, -0x1fffffffffffffp+138); + check_round_same (testdbl_192 (-3138550867693340381917894711603833208051177722232017256447wb - 1), -0x20000000000000p+138); + check_round (testdblu_192 (89202980794122477710862401666030147234430975uwb), 0x1ffffffffffffep+93, 0x1ffffffffffffep+93, 0x1fffffffffffffp+93, 0x1ffffffffffffep+93); + check_round (testdblu_192 (89202980794122477710862401666030147234430976uwb), 0x1ffffffffffffep+93, 0x1ffffffffffffep+93, 0x1fffffffffffffp+93, 0x1ffffffffffffep+93); + check_round (testdblu_192 (89202980794122477710862401666030147234430977uwb), 0x1fffffffffffffp+93, 0x1ffffffffffffep+93, 0x1fffffffffffffp+93, 0x1ffffffffffffep+93); + check_round_same (testdblu_192 (89202980794122482662622558807551246830927872uwb), 0x1fffffffffffffp+93); + check_round (testdblu_192 (89202980794122487614382715949072346427424767uwb), 0x1fffffffffffffp+93, 0x1fffffffffffffp+93, 0x20000000000000p+93, 0x1fffffffffffffp+93); + check_round (testdblu_192 (89202980794122487614382715949072346427424768uwb), 0x20000000000000p+93, 0x1fffffffffffffp+93, 0x20000000000000p+93, 0x1fffffffffffffp+93); + check_round (testdblu_192 (89202980794122487614382715949072346427424769uwb), 0x20000000000000p+93, 0x1fffffffffffffp+93, 0x20000000000000p+93, 0x1fffffffffffffp+93); + check_round_same (testdblu_192 (6277101735386680066937501969125693243111159424202737451008uwb), 0x1fffffffffffffp+139); + check_round (testdblu_192 (6277101735386680415386645696166679829606757434333385981951uwb), 0x1fffffffffffffp+139, 0x1fffffffffffffp+139, 0x20000000000000p+139, 0x1fffffffffffffp+139); + check_round (testdblu_192 (6277101735386680415386645696166679829606757434333385981952uwb), 0x20000000000000p+139, 0x1fffffffffffffp+139, 0x20000000000000p+139, 0x1fffffffffffffp+139); + check_round (testdblu_192 (6277101735386680415386645696166679829606757434333385981953uwb), 0x20000000000000p+139, 0x1fffffffffffffp+139, 0x20000000000000p+139, 0x1fffffffffffffp+139); + check_round (testdblu_192 (6277101735386680763835789423207666416102355444464034512895uwb), 0x20000000000000p+139, 0x1fffffffffffffp+139, 0x20000000000000p+139, 0x1fffffffffffffp+139); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_round (testdbl_575 (-615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392895wb), -0x1ffffffffffffep+325, -0x1fffffffffffffp+325, -0x1ffffffffffffep+325, -0x1ffffffffffffep+325); + check_round (testdbl_575 (-615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392896wb), -0x1ffffffffffffep+325, -0x1fffffffffffffp+325, -0x1ffffffffffffep+325, -0x1ffffffffffffep+325); + check_round (testdbl_575 (-615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392897wb), -0x1fffffffffffffp+325, -0x1fffffffffffffp+325, -0x1ffffffffffffep+325, -0x1ffffffffffffep+325); + check_round_same (testdbl_575 (-615656346818663669340274852095621329063676328675354936900147369028450764374312465492316685252079206152816780378112wb), -0x1fffffffffffffp+325); + check_round (testdbl_575 (-615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363327wb), -0x1fffffffffffffp+325, -0x20000000000000p+325, -0x1fffffffffffffp+325, -0x1fffffffffffffp+325); + check_round (testdbl_575 (-615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363328wb), -0x20000000000000p+325, -0x20000000000000p+325, -0x1fffffffffffffp+325, -0x1fffffffffffffp+325); + check_round (testdbl_575 (-615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363329wb), -0x20000000000000p+325, -0x20000000000000p+325, -0x1fffffffffffffp+325, -0x1fffffffffffffp+325); + check_round_same (testdbl_575 (61832600368276126650327970124302082526882038193909742709080463879918896882169507607035916867654709124839777195049479857541529867095829765369898539058829479405123401922117632wb), 0x1fffffffffffffp+521); + check_round (testdbl_575 (61832600368276130082726800189606940017832437734606351343798113951571601579401237199807508566482735186119597525776757346189685562836258783930892538917151385692137547479646207wb), 0x1fffffffffffffp+521, 0x1fffffffffffffp+521, 0x20000000000000p+521, 0x1fffffffffffffp+521); + check_round (testdbl_575 (61832600368276130082726800189606940017832437734606351343798113951571601579401237199807508566482735186119597525776757346189685562836258783930892538917151385692137547479646208wb), 0x20000000000000p+521, 0x1fffffffffffffp+521, 0x20000000000000p+521, 0x1fffffffffffffp+521); + check_round (testdbl_575 (61832600368276130082726800189606940017832437734606351343798113951571601579401237199807508566482735186119597525776757346189685562836258783930892538917151385692137547479646209wb), 0x20000000000000p+521, 0x1fffffffffffffp+521, 0x20000000000000p+521, 0x1fffffffffffffp+521); + check_round (testdbl_575 (61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb), 0x20000000000000p+521, 0x1fffffffffffffp+521, 0x20000000000000p+521, 0x1fffffffffffffp+521); + check_round (testdblu_575 (615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392895uwb), 0x1ffffffffffffep+325, 0x1ffffffffffffep+325, 0x1fffffffffffffp+325, 0x1ffffffffffffep+325); + check_round (testdblu_575 (615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392896uwb), 0x1ffffffffffffep+325, 0x1ffffffffffffep+325, 0x1fffffffffffffp+325, 0x1ffffffffffffep+325); + check_round (testdblu_575 (615656346818663635164482277361060010743329029962521103256875011322006445221646740336801072761830405785423389392897uwb), 0x1fffffffffffffp+325, 0x1ffffffffffffep+325, 0x1fffffffffffffp+325, 0x1ffffffffffffep+325); + check_round_same (testdblu_575 (615656346818663669340274852095621329063676328675354936900147369028450764374312465492316685252079206152816780378112uwb), 0x1fffffffffffffp+325); + check_round (testdblu_575 (615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363327uwb), 0x1fffffffffffffp+325, 0x1fffffffffffffp+325, 0x20000000000000p+325, 0x1fffffffffffffp+325); + check_round (testdblu_575 (615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363328uwb), 0x20000000000000p+325, 0x1fffffffffffffp+325, 0x20000000000000p+325, 0x1fffffffffffffp+325); + check_round (testdblu_575 (615656346818663703516067426830182647384023627388188770543419726734895083526978190647832297742328006520210171363329uwb), 0x20000000000000p+325, 0x1fffffffffffffp+325, 0x20000000000000p+325, 0x1fffffffffffffp+325); + check_round_same (testdblu_575 (123665200736552253300655940248604165053764076387819485418160927759837793764339015214071833735309418249679554390098959715083059734191659530739797078117658958810246803844235264uwb), 0x1fffffffffffffp+522); + check_round (testdblu_575 (123665200736552260165453600379213880035664875469212702687596227903143203158802474399615017132965470372239195051553514692379371125672517567861785077834302771384275094959292415uwb), 0x1fffffffffffffp+522, 0x1fffffffffffffp+522, 0x20000000000000p+522, 0x1fffffffffffffp+522); + check_round (testdblu_575 (123665200736552260165453600379213880035664875469212702687596227903143203158802474399615017132965470372239195051553514692379371125672517567861785077834302771384275094959292416uwb), 0x20000000000000p+522, 0x1fffffffffffffp+522, 0x20000000000000p+522, 0x1fffffffffffffp+522); + check_round (testdblu_575 (123665200736552260165453600379213880035664875469212702687596227903143203158802474399615017132965470372239195051553514692379371125672517567861785077834302771384275094959292417uwb), 0x20000000000000p+522, 0x1fffffffffffffp+522, 0x20000000000000p+522, 0x1fffffffffffffp+522); + check_round (testdblu_575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb), 0x20000000000000p+522, 0x1fffffffffffffp+522, 0x20000000000000p+522, 0x1fffffffffffffp+522); +#endif +#endif +#if __LDBL_MANT_DIG__, 64 +#if __BITINT_MAXWIDTH__ >= 135 + check_round (testldbl_135 (-27577662721237071616947187835994111wb), -0xa9f5e144d113e1c4p+51L, -0xa9f5e144d113e1c5p+51L, -0xa9f5e144d113e1c4p+51L, -0xa9f5e144d113e1c4p+51L); + check_round (testldbl_135 (-27577662721237071616947187835994112wb), -0xa9f5e144d113e1c4p+51L, -0xa9f5e144d113e1c5p+51L, -0xa9f5e144d113e1c4p+51L, -0xa9f5e144d113e1c4p+51L); + check_round (testldbl_135 (-27577662721237071616947187835994113wb), -0xa9f5e144d113e1c5p+51L, -0xa9f5e144d113e1c5p+51L, -0xa9f5e144d113e1c4p+51L, -0xa9f5e144d113e1c4p+51L); + check_round_same (testldbl_135 (-27577662721237071618073087742836736wb), -0xa9f5e144d113e1c5p+51L); + check_round (testldbl_135 (-27577662721237071619198987649679359wb), -0xa9f5e144d113e1c5p+51L, -0xa9f5e144d113e1c6p+51L, -0xa9f5e144d113e1c5p+51L, -0xa9f5e144d113e1c5p+51L); + check_round (testldbl_135 (-27577662721237071619198987649679360wb), -0xa9f5e144d113e1c6p+51L, -0xa9f5e144d113e1c6p+51L, -0xa9f5e144d113e1c5p+51L, -0xa9f5e144d113e1c5p+51L); + check_round (testldbl_135 (-27577662721237071619198987649679361wb), -0xa9f5e144d113e1c6p+51L, -0xa9f5e144d113e1c6p+51L, -0xa9f5e144d113e1c5p+51L, -0xa9f5e144d113e1c5p+51L); + check_round_same (testldbl_135 (-21778071482940061660475383254915754229760wb), -0xffffffffffffffffp+70L); + check_round (testldbl_135 (-21778071482940061661065679065274459881471wb), -0xffffffffffffffffp+70L, -0x10000000000000000p+70L, -0xffffffffffffffffp+70L, -0xffffffffffffffffp+70L); + check_round (testldbl_135 (-21778071482940061661065679065274459881472wb), -0x10000000000000000p+70L, -0x10000000000000000p+70L, -0xffffffffffffffffp+70L, -0xffffffffffffffffp+70L); + check_round (testldbl_135 (-21778071482940061661065679065274459881473wb), -0x10000000000000000p+70L, -0x10000000000000000p+70L, -0xffffffffffffffffp+70L, -0xffffffffffffffffp+70L); + check_round_same (testldbl_135 (-21778071482940061661655974875633165533183wb - 1), -0x10000000000000000p+70L); + check_round (testldblu_135 (27577662721237071616947187835994111uwb), 0xa9f5e144d113e1c4p+51L, 0xa9f5e144d113e1c4p+51L, 0xa9f5e144d113e1c5p+51L, 0xa9f5e144d113e1c4p+51L); + check_round (testldblu_135 (27577662721237071616947187835994112uwb), 0xa9f5e144d113e1c4p+51L, 0xa9f5e144d113e1c4p+51L, 0xa9f5e144d113e1c5p+51L, 0xa9f5e144d113e1c4p+51L); + check_round (testldblu_135 (27577662721237071616947187835994113uwb), 0xa9f5e144d113e1c5p+51L, 0xa9f5e144d113e1c4p+51L, 0xa9f5e144d113e1c5p+51L, 0xa9f5e144d113e1c4p+51L); + check_round_same (testldblu_135 (27577662721237071618073087742836736uwb), 0xa9f5e144d113e1c5p+51L); + check_round (testldblu_135 (27577662721237071619198987649679359uwb), 0xa9f5e144d113e1c5p+51L, 0xa9f5e144d113e1c5p+51L, 0xa9f5e144d113e1c6p+51L, 0xa9f5e144d113e1c5p+51L); + check_round (testldblu_135 (27577662721237071619198987649679360uwb), 0xa9f5e144d113e1c6p+51L, 0xa9f5e144d113e1c5p+51L, 0xa9f5e144d113e1c6p+51L, 0xa9f5e144d113e1c5p+51L); + check_round (testldblu_135 (27577662721237071619198987649679361uwb), 0xa9f5e144d113e1c6p+51L, 0xa9f5e144d113e1c5p+51L, 0xa9f5e144d113e1c6p+51L, 0xa9f5e144d113e1c5p+51L); + check_round_same (testldblu_135 (43556142965880123320950766509831508459520uwb), 0xffffffffffffffffp+71L); + check_round (testldblu_135 (43556142965880123322131358130548919762943uwb), 0xffffffffffffffffp+71L, 0xffffffffffffffffp+71L, 0x10000000000000000p+71L, 0xffffffffffffffffp+71L); + check_round (testldblu_135 (43556142965880123322131358130548919762944uwb), 0x10000000000000000p+71L, 0xffffffffffffffffp+71L, 0x10000000000000000p+71L, 0xffffffffffffffffp+71L); + check_round (testldblu_135 (43556142965880123322131358130548919762945uwb), 0x10000000000000000p+71L, 0xffffffffffffffffp+71L, 0x10000000000000000p+71L, 0xffffffffffffffffp+71L); + check_round (testldblu_135 (43556142965880123323311949751266331066367uwb), 0x10000000000000000p+71L, 0xffffffffffffffffp+71L, 0x10000000000000000p+71L, 0xffffffffffffffffp+71L); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_round (testldbl_192 (96388802158769743653878219701497927252918090596351wb), 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024ep+103L); + check_round (testldbl_192 (96388802158769743653878219701497927252918090596352wb), 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024ep+103L); + check_round (testldbl_192 (96388802158769743653878219701497927252918090596353wb), 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024ep+103L); + check_round_same (testldbl_192 (96388802158769743658948822102410844858904903417856wb), 0x83e75ebf94ce024fp+103L); + check_round (testldbl_192 (96388802158769743664019424503323762464891716239359wb), 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L); + check_round (testldbl_192 (96388802158769743664019424503323762464891716239360wb), 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L); + check_round (testldbl_192 (96388802158769743664019424503323762464891716239361wb), 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L); + check_round_same (testldbl_192 (-3138550867693340381747753528143363976319490418516133150720wb), -0xffffffffffffffffp+127L); + check_round (testldbl_192 (-3138550867693340381832824119873598592185334070374075203583wb), -0xffffffffffffffffp+127L, -0x10000000000000000p+127L, -0xffffffffffffffffp+127L, -0xffffffffffffffffp+127L); + check_round (testldbl_192 (-3138550867693340381832824119873598592185334070374075203584wb), -0x10000000000000000p+127L, -0x10000000000000000p+127L, -0xffffffffffffffffp+127L, -0xffffffffffffffffp+127L); + check_round (testldbl_192 (-3138550867693340381832824119873598592185334070374075203585wb), -0x10000000000000000p+127L, -0x10000000000000000p+127L, -0xffffffffffffffffp+127L, -0xffffffffffffffffp+127L); + check_round_same (testldbl_192 (-3138550867693340381917894711603833208051177722232017256447wb - 1wb), -0x10000000000000000p+127L); + check_round (testldblu_192 (96388802158769743653878219701497927252918090596351uwb), 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024ep+103L); + check_round (testldblu_192 (96388802158769743653878219701497927252918090596352uwb), 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024ep+103L); + check_round (testldblu_192 (96388802158769743653878219701497927252918090596353uwb), 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024ep+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024ep+103L); + check_round_same (testldblu_192 (96388802158769743658948822102410844858904903417856uwb), 0x83e75ebf94ce024fp+103L); + check_round (testldblu_192 (96388802158769743664019424503323762464891716239359uwb), 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L); + check_round (testldblu_192 (96388802158769743664019424503323762464891716239360uwb), 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L); + check_round (testldblu_192 (96388802158769743664019424503323762464891716239361uwb), 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L, 0x83e75ebf94ce0250p+103L, 0x83e75ebf94ce024fp+103L); + check_round_same (testldblu_192 (6277101735386680763495507056286727952638980837032266301440uwb), 0xffffffffffffffffp+128L); + check_round (testldblu_192 (6277101735386680763665648239747197184370668140748150407167uwb), 0xffffffffffffffffp+128L, 0xffffffffffffffffp+128L, 0x10000000000000000p+128L, 0xffffffffffffffffp+128L); + check_round (testldblu_192 (6277101735386680763665648239747197184370668140748150407168uwb), 0x10000000000000000p+128L, 0xffffffffffffffffp+128L, 0x10000000000000000p+128L, 0xffffffffffffffffp+128L); + check_round (testldblu_192 (6277101735386680763665648239747197184370668140748150407169uwb), 0x10000000000000000p+128L, 0xffffffffffffffffp+128L, 0x10000000000000000p+128L, 0xffffffffffffffffp+128L); + check_round (testldblu_192 (6277101735386680763835789423207666416102355444464034512895uwb), 0x10000000000000000p+128L, 0xffffffffffffffffp+128L, 0x10000000000000000p+128L, 0xffffffffffffffffp+128L); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_round_same (testldbl_575 (-61832600368276133511773678272426148233889331025751498446645922568076207932202076431648659257792374503198949281962308977915333294030066289778448068072486649492543280785653760wb), -0xffffffffffffffffp+510L); + check_round (testldbl_575 (-61832600368276133513449654263668972871336084150527229212580843295650257104417521612113879761551567875299183569233171906376587276303377046135167303423979970735847486911414271wb), -0xffffffffffffffffp+510L, -0x10000000000000000p+510L, -0xffffffffffffffffp+510L, -0xffffffffffffffffp+510L); + check_round (testldbl_575 (-61832600368276133513449654263668972871336084150527229212580843295650257104417521612113879761551567875299183569233171906376587276303377046135167303423979970735847486911414272wb), -0x10000000000000000p+510L, -0x10000000000000000p+510L, -0xffffffffffffffffp+510L, -0xffffffffffffffffp+510L); + check_round (testldbl_575 (-61832600368276133513449654263668972871336084150527229212580843295650257104417521612113879761551567875299183569233171906376587276303377046135167303423979970735847486911414273wb), -0x10000000000000000p+510L, -0x10000000000000000p+510L, -0xffffffffffffffffp+510L, -0xffffffffffffffffp+510L); + check_round_same (testldbl_575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), -0x10000000000000000p+510L); + check_round_same (testldblu_575 (123665200736552267023547356544852296467778662051502996893291845136152415864404152863297318515584749006397898563924617955830666588060132579556896136144973298985086561571307520uwb), 0xffffffffffffffffp+511L); + check_round (testldblu_575 (123665200736552267026899308527337945742672168301054458425161686591300514208835043224227759523103135750598367138466343812753174552606754092270334606847959941471694973822828543uwb), 0xffffffffffffffffp+511L, 0xffffffffffffffffp+511L, 0x10000000000000000p+511L, 0xffffffffffffffffp+511L); + check_round (testldblu_575 (123665200736552267026899308527337945742672168301054458425161686591300514208835043224227759523103135750598367138466343812753174552606754092270334606847959941471694973822828544uwb), 0x10000000000000000p+511L, 0xffffffffffffffffp+511L, 0x10000000000000000p+511L, 0xffffffffffffffffp+511L); + check_round (testldblu_575 (123665200736552267026899308527337945742672168301054458425161686591300514208835043224227759523103135750598367138466343812753174552606754092270334606847959941471694973822828545uwb), 0x10000000000000000p+511L, 0xffffffffffffffffp+511L, 0x10000000000000000p+511L, 0xffffffffffffffffp+511L); + check_round (testldblu_575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb), 0x10000000000000000p+511L, 0xffffffffffffffffp+511L, 0x10000000000000000p+511L, 0xffffffffffffffffp+511L); +#endif +#endif +#if __FLT128_MANT_DIG__, 113 +#if __BITINT_MAXWIDTH__ >= 135 + check_round (testflt128_135 (-21646332438261169091754659013488783917055wb), -0x1fce71fdcfb1797b42dede66ac9ecp+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128, -0x1fce71fdcfb1797b42dede66ac9ecp+21F128, -0x1fce71fdcfb1797b42dede66ac9ecp+21F128); + check_round (testflt128_135 (-21646332438261169091754659013488783917056wb), -0x1fce71fdcfb1797b42dede66ac9ecp+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128, -0x1fce71fdcfb1797b42dede66ac9ecp+21F128, -0x1fce71fdcfb1797b42dede66ac9ecp+21F128); + check_round (testflt128_135 (-21646332438261169091754659013488783917057wb), -0x1fce71fdcfb1797b42dede66ac9edp+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128, -0x1fce71fdcfb1797b42dede66ac9ecp+21F128, -0x1fce71fdcfb1797b42dede66ac9ecp+21F128); + check_round_same (testflt128_135 (-21646332438261169091754659013488784965632wb), -0x1fce71fdcfb1797b42dede66ac9edp+21F128); + check_round (testflt128_135 (-21646332438261169091754659013488786014207wb), -0x1fce71fdcfb1797b42dede66ac9edp+21F128, -0x1fce71fdcfb1797b42dede66ac9eep+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128); + check_round (testflt128_135 (-21646332438261169091754659013488786014208wb), -0x1fce71fdcfb1797b42dede66ac9eep+21F128, -0x1fce71fdcfb1797b42dede66ac9eep+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128); + check_round (testflt128_135 (-21646332438261169091754659013488786014209wb), -0x1fce71fdcfb1797b42dede66ac9eep+21F128, -0x1fce71fdcfb1797b42dede66ac9eep+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128, -0x1fce71fdcfb1797b42dede66ac9edp+21F128); + check_round (testflt128u_135 (21646332438261169091754659013488783917055uwb), 0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0x1fce71fdcfb1797b42dede66ac9ecp+21F128); + check_round (testflt128u_135 (21646332438261169091754659013488783917056uwb), 0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0x1fce71fdcfb1797b42dede66ac9ecp+21F128); + check_round (testflt128u_135 (21646332438261169091754659013488783917057uwb), 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0x1fce71fdcfb1797b42dede66ac9ecp+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0x1fce71fdcfb1797b42dede66ac9ecp+21F128); + check_round_same (testflt128u_135 (21646332438261169091754659013488784965632uwb), 0x1fce71fdcfb1797b42dede66ac9edp+21F128); + check_round (testflt128u_135 (21646332438261169091754659013488786014207uwb), 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0x1fce71fdcfb1797b42dede66ac9eep+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128); + check_round (testflt128u_135 (21646332438261169091754659013488786014208uwb), 0x1fce71fdcfb1797b42dede66ac9eep+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0x1fce71fdcfb1797b42dede66ac9eep+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128); + check_round (testflt128u_135 (21646332438261169091754659013488786014209uwb), 0x1fce71fdcfb1797b42dede66ac9eep+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128, 0x1fce71fdcfb1797b42dede66ac9eep+21F128, 0x1fce71fdcfb1797b42dede66ac9edp+21F128); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check_round_same (testflt128_192 (3138550867693340381917894711603832905819722818574723579904wb), 0x1ffffffffffffffffffffffffffffp+78F128); + check_round (testflt128_192 (3138550867693340381917894711603833056935450270403370418175wb), 0x1ffffffffffffffffffffffffffffp+78F128, 0x1ffffffffffffffffffffffffffffp+78F128, 0x20000000000000000000000000000p+78F128, 0x1ffffffffffffffffffffffffffffp+78F128); + check_round (testflt128_192 (3138550867693340381917894711603833056935450270403370418176wb), 0x20000000000000000000000000000p+78F128, 0x1ffffffffffffffffffffffffffffp+78F128, 0x20000000000000000000000000000p+78F128, 0x1ffffffffffffffffffffffffffffp+78F128); + check_round (testflt128_192 (3138550867693340381917894711603833056935450270403370418177wb), 0x20000000000000000000000000000p+78F128, 0x1ffffffffffffffffffffffffffffp+78F128, 0x20000000000000000000000000000p+78F128, 0x1ffffffffffffffffffffffffffffp+78F128); + check_round (testflt128_192 (3138550867693340381917894711603833208051177722232017256447wb), 0x20000000000000000000000000000p+78F128, 0x1ffffffffffffffffffffffffffffp+78F128, 0x20000000000000000000000000000p+78F128, 0x1ffffffffffffffffffffffffffffp+78F128); + check_round_same (testflt128u_192 (6277101735386680763835789423207665811639445637149447159808uwb), 0x1ffffffffffffffffffffffffffffp+79F128); + check_round (testflt128u_192 (6277101735386680763835789423207666113870900540806740836351uwb), 0x1ffffffffffffffffffffffffffffp+79F128, 0x1ffffffffffffffffffffffffffffp+79F128, 0x20000000000000000000000000000p+79F128, 0x1ffffffffffffffffffffffffffffp+79F128); + check_round (testflt128u_192 (6277101735386680763835789423207666113870900540806740836352uwb), 0x20000000000000000000000000000p+79F128, 0x1ffffffffffffffffffffffffffffp+79F128, 0x20000000000000000000000000000p+79F128, 0x1ffffffffffffffffffffffffffffp+79F128); + check_round (testflt128u_192 (6277101735386680763835789423207666113870900540806740836353uwb), 0x20000000000000000000000000000p+79F128, 0x1ffffffffffffffffffffffffffffp+79F128, 0x20000000000000000000000000000p+79F128, 0x1ffffffffffffffffffffffffffffp+79F128); + check_round (testflt128u_192 (6277101735386680763835789423207666416102355444464034512895uwb), 0x20000000000000000000000000000p+79F128, 0x1ffffffffffffffffffffffffffffp+79F128, 0x20000000000000000000000000000p+79F128, 0x1ffffffffffffffffffffffffffffp+79F128); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check_round_same (testflt128_575 (-39695651458311907436978914487787846289740055435765388813682045155135192382154626611682813571487190641804615256990296246545713518740501887218789991403746059512699763279527936wb), -0x148b25ce53790ddc343a80e5af6bap+461F128); + check_round (testflt128_575 (-39695651458311907436978914487787849266871470150571212503712362264401765094669639986937588484471046485703139369468190190624257242316066424102078490670010875270428034085158911wb), -0x148b25ce53790ddc343a80e5af6bap+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128, -0x148b25ce53790ddc343a80e5af6bap+461F128, -0x148b25ce53790ddc343a80e5af6bap+461F128); + check_round (testflt128_575 (-39695651458311907436978914487787849266871470150571212503712362264401765094669639986937588484471046485703139369468190190624257242316066424102078490670010875270428034085158912wb), -0x148b25ce53790ddc343a80e5af6bap+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128, -0x148b25ce53790ddc343a80e5af6bap+461F128, -0x148b25ce53790ddc343a80e5af6bap+461F128); + check_round (testflt128_575 (-39695651458311907436978914487787849266871470150571212503712362264401765094669639986937588484471046485703139369468190190624257242316066424102078490670010875270428034085158913wb), -0x148b25ce53790ddc343a80e5af6bbp+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128, -0x148b25ce53790ddc343a80e5af6bap+461F128, -0x148b25ce53790ddc343a80e5af6bap+461F128); + check_round_same (testflt128_575 (-39695651458311907436978914487787852244002884865377036193742679373668337807184653362192363397454902329601663481946084134702800965891630960985366989936275691028156304890789888wb), -0x148b25ce53790ddc343a80e5af6bbp+461F128); + check_round (testflt128_575 (-39695651458311907436978914487787855221134299580182859883772996482934910519699666737447138310438758173500187594423978078781344689467195497868655489202540506785884575696420863wb), -0x148b25ce53790ddc343a80e5af6bbp+461F128, -0x148b25ce53790ddc343a80e5af6bcp+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128); + check_round (testflt128_575 (-39695651458311907436978914487787855221134299580182859883772996482934910519699666737447138310438758173500187594423978078781344689467195497868655489202540506785884575696420864wb), -0x148b25ce53790ddc343a80e5af6bcp+461F128, -0x148b25ce53790ddc343a80e5af6bcp+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128); + check_round (testflt128_575 (-39695651458311907436978914487787855221134299580182859883772996482934910519699666737447138310438758173500187594423978078781344689467195497868655489202540506785884575696420865wb), -0x148b25ce53790ddc343a80e5af6bcp+461F128, -0x148b25ce53790ddc343a80e5af6bcp+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128, -0x148b25ce53790ddc343a80e5af6bbp+461F128); + check_round_same (testflt128_575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), -0x20000000000000000000000000000p+461F128); + check_round_same (testflt128u_575 (79391302916623814873957828975575692579480110871530777627364090310270384764309253223365627142974381283609230513980592493091427037481003774437579982807492119025399526559055872uwb), 0x148b25ce53790ddc343a80e5af6bap+462F128); + check_round (testflt128u_575 (79391302916623814873957828975575698533742940301142425007424724528803530189339279973875176968942092971406278738936380381248514484632132848204156981340021750540856068170317823uwb), 0x148b25ce53790ddc343a80e5af6bap+462F128, 0x148b25ce53790ddc343a80e5af6bap+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0x148b25ce53790ddc343a80e5af6bap+462F128); + check_round (testflt128u_575 (79391302916623814873957828975575698533742940301142425007424724528803530189339279973875176968942092971406278738936380381248514484632132848204156981340021750540856068170317824uwb), 0x148b25ce53790ddc343a80e5af6bap+462F128, 0x148b25ce53790ddc343a80e5af6bap+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0x148b25ce53790ddc343a80e5af6bap+462F128); + check_round (testflt128u_575 (79391302916623814873957828975575698533742940301142425007424724528803530189339279973875176968942092971406278738936380381248514484632132848204156981340021750540856068170317825uwb), 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0x148b25ce53790ddc343a80e5af6bap+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0x148b25ce53790ddc343a80e5af6bap+462F128); + check_round_same (testflt128u_575 (79391302916623814873957828975575704488005769730754072387485358747336675614369306724384726794909804659203326963892168269405601931783261921970733979872551382056312609781579776uwb), 0x148b25ce53790ddc343a80e5af6bbp+462F128); + check_round (testflt128u_575 (79391302916623814873957828975575710442268599160365719767545992965869821039399333474894276620877516347000375188847956157562689378934390995737310978405081013571769151392841727uwb), 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0x148b25ce53790ddc343a80e5af6bcp+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128); + check_round (testflt128u_575 (79391302916623814873957828975575710442268599160365719767545992965869821039399333474894276620877516347000375188847956157562689378934390995737310978405081013571769151392841728uwb), 0x148b25ce53790ddc343a80e5af6bcp+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0x148b25ce53790ddc343a80e5af6bcp+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128); + check_round (testflt128u_575 (79391302916623814873957828975575710442268599160365719767545992965869821039399333474894276620877516347000375188847956157562689378934390995737310978405081013571769151392841729uwb), 0x148b25ce53790ddc343a80e5af6bcp+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128, 0x148b25ce53790ddc343a80e5af6bcp+462F128, 0x148b25ce53790ddc343a80e5af6bbp+462F128); + check_round (testflt128u_575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb), 0x20000000000000000000000000000p+462F128, 0x1ffffffffffffffffffffffffffffp+462F128, 0x20000000000000000000000000000p+462F128, 0x1ffffffffffffffffffffffffffffp+462F128); +#endif +#endif +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-32.c b/SingleSource/Regression/C/gcc-dg/bitint-32.c new file mode 100644 index 0000000000..e6c277ec1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-32.c @@ -0,0 +1,14 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x" } */ + +#include + +#ifndef BITINT_MAXWIDTH +#error BITINT_MAXWIDTH not defined +#elif BITINT_MAXWIDTH < ULLONG_WIDTH +#error BITINT_MAXWIDTH smaller than ULLONG_WIDTH +#endif + +_BitInt(BITINT_MAXWIDTH) a; +_BitInt(BITINT_MAXWIDTH + 1) b; /* { dg-error "'_BitInt' argument '\[0-9]+' is larger than 'BITINT_MAXWIDTH' '\[0-9]+'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bitint-33.c b/SingleSource/Regression/C/gcc-dg/bitint-33.c new file mode 100644 index 0000000000..a46d53eeb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-33.c @@ -0,0 +1,9 @@ +/* PR c/102989 */ +/* { dg-do compile } */ +/* { dg-options "-std=c17" } */ + +#include + +#ifdef BITINT_MAXWIDTH +#error BITINT_MAXWIDTH defined in C11 +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-34.c b/SingleSource/Regression/C/gcc-dg/bitint-34.c new file mode 100644 index 0000000000..7eaadb2fc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-34.c @@ -0,0 +1,16 @@ +/* PR c/102989 */ +/* Test that -funsigned-bitfields doesn't affect _BitInt bit-fields which are always signed. */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -funsigned-bitfields" } */ + +struct S { _BitInt(22) a : 7; signed _BitInt(22) b : 7; unsigned _BitInt(22) c : 7; } s; + +int +main () +{ + s.a = -64; + s.b = -64; + s.c = -64; + if (s.a != -64 || s.b != -64 || s.c != 64) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-35.c b/SingleSource/Regression/C/gcc-dg/bitint-35.c new file mode 100644 index 0000000000..352633d3cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-35.c @@ -0,0 +1,37 @@ +/* PR c/102989 */ +/* { dg-do compile { target { bitint && { float32 && int32 } } } } */ +/* { dg-options "-std=c2x -Wconversion -Wfloat-conversion" } */ +/* { dg-add-options float32 } */ + +void +foo (_Float32 x) +{ + _BitInt(57) a = 1.5F32; /* { dg-warning "conversion from '_Float32' to '_BitInt\\\(57\\\)' changes value from '1.5e\\\+0f32' to '1'" } */ + _BitInt(27) b = 76117358uwb; /* { dg-warning "signed conversion from 'unsigned _BitInt\\\(27\\\)' to '_BitInt\\\(27\\\)' changes value from '76117358' to '-58100370'" } */ + unsigned _BitInt(27) c = -15wb; /* { dg-warning "unsigned conversion from '_BitInt\\\(5\\\)' to 'unsigned _BitInt\\\(27\\\)' changes value from '-15' to '134217713'" } */ + _BitInt(27) d = -390288573wb; /* { dg-warning "overflow in conversion from '_BitInt\\\(30\\\)' to '_BitInt\\\(27\\\)' changes value from '-390288573' to '12364611'" } */ + unsigned _BitInt(27) e = 309641337uwb; /* { dg-warning "conversion from 'unsigned _BitInt\\\(29\\\)' to 'unsigned _BitInt\\\(27\\\)' changes value from '309641337' to '41205881'" } */ + _BitInt(27) f = 76117358U; /* { dg-warning "signed conversion from 'unsigned int' to '_BitInt\\\(27\\\)' changes value from '76117358' to '-58100370'" } */ + unsigned _BitInt(27) g = -15; /* { dg-warning "unsigned conversion from 'int' to 'unsigned _BitInt\\\(27\\\)' changes value from '-15' to '134217713'" } */ + _BitInt(27) h = -390288573; /* { dg-warning "overflow in conversion from 'int' to '_BitInt\\\(27\\\)' changes value from '-390288573' to '12364611'" } */ + unsigned _BitInt(27) i = 309641337U; /* { dg-warning "conversion from 'unsigned int' to 'unsigned _BitInt\\\(27\\\)' changes value from '309641337' to '41205881'" } */ + int j = 2936216298uwb; /* { dg-warning "signed conversion from 'unsigned _BitInt\\\(32\\\)' to 'int' changes value from '2936216298' to '-1358750998'" } */ + unsigned int k = -15wb; /* { dg-warning "unsigned conversion from '_BitInt\\\(5\\\)' to 'unsigned int' changes value from '-15' to '4294967281'" } */ + int l = -8087431137529383656wb; /* { dg-warning "overflow in conversion from '_BitInt\\\(64\\\)' to 'int' changes value from '-8087431137529383656' to '-1105152744'" } */ + unsigned int m = 1664073919553255778uwb; /* { dg-warning "conversion from 'unsigned _BitInt\\\(61\\\)' to 'unsigned int' changes value from '1664073919553255778' to '3338058082'" } */ +#if __BITINT_MAXWIDTH__ >= 575 + _Float32 n = 51441631083309184313435496923626431699697406185384986811300218556561965470218425783308778801748592322915101142266821623326688106425864884688172114173397118407357447763009120wb; /* { dg-warning "conversion from '_BitInt\\\(575\\\)' to '_Float32' changes value from '0x353eab28b46b03ea99b84f9736cd8dbe5e986915a0383c3cb381c0da41e31b3621c75fd53262bfcb1b0e6251dbf00f3988784e29b08b65640c263e4d0959832a20e2ff5245be1e60' to '\\\+Inff32'" "" { target bitint575 } } */ +#endif + _BitInt(57) o = x; /* { dg-warning "conversion from '_Float32' to '_BitInt\\\(57\\\)' may change value" } */ + unsigned _BitInt(15) p = 32767uwb; + unsigned _BitInt(15) q = (_BitInt(42)) p; + _BitInt(17) r = 0; + _BitInt(17) s = ((_BitInt(42)) r) & 32767wb; +#if __BITINT_MAXWIDTH__ >= 575 + _BitInt(575) t = 0; + _Float32 u = t; /* { dg-warning "conversion from '_BitInt\\\(575\\\)' to '_Float32' may change value" "" { target bitint575 } } */ +#endif + _BitInt(42) v = 0; + unsigned _BitInt(17) w = v; /* { dg-warning "conversion from '_BitInt\\\(42\\\)' to 'unsigned _BitInt\\\(17\\\)' may change value" } */ + _BitInt(17) y = v; /* { dg-warning "conversion from '_BitInt\\\(42\\\)' to '_BitInt\\\(17\\\)' may change value" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-36.c b/SingleSource/Regression/C/gcc-dg/bitint-36.c new file mode 100644 index 0000000000..1912869225 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-36.c @@ -0,0 +1,39 @@ +/* PR c/102989 */ +/* { dg-do compile { target { bitint } } } */ +/* { dg-options "-std=c2x -Wint-in-bool-context -Waddress -Wpointer-to-int-cast -Wint-to-pointer-cast -Wint-conversion -Wshift-negative-value -Wshift-count-overflow -Wdiv-by-zero" } */ + +extern char *ax[]; + +void bar (int); + +void +foo (_BitInt(61) x, long long *y) +{ + if (x << 15) /* { dg-warning "'<<' in boolean context, did you mean '<'" } */ + ; + bar ((_BitInt(sizeof (void *) * __CHAR_BIT__)) (ax + 0) == 0); + bar ((unsigned _BitInt(sizeof (void *) * __CHAR_BIT__)) (ax + 1) == 0); + char *z = __builtin_assume_aligned (y, 32wb, 8wb); + *z = 42; + _BitInt(sizeof (void *) * __CHAR_BIT__ + 1) a = (_BitInt(sizeof (void *) * __CHAR_BIT__ + 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */ + unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ + 1) b = (unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ + 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */ + _BitInt(sizeof (void *) * __CHAR_BIT__ - 1) c = (_BitInt(sizeof (void *) * __CHAR_BIT__ - 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */ + unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ - 1) d = (unsigned _BitInt(sizeof (void *) * __CHAR_BIT__ - 1)) y; /* { dg-warning "cast from pointer to integer of different size" } */ + void *e = (void *) a; /* { dg-warning "cast to pointer from integer of different size" } */ + void *f = (void *) b; /* { dg-warning "cast to pointer from integer of different size" } */ + void *g = (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */ + void *h = (void *) d; /* { dg-warning "cast to pointer from integer of different size" } */ + a = y; /* { dg-warning "assignment to '_BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */ + b = y; /* { dg-warning "assignment to 'unsigned _BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */ + c = y; /* { dg-warning "assignment to '_BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */ + d = y; /* { dg-warning "assignment to 'unsigned _BitInt\\\(\[0-9]+\\\)' from 'long long int \\\*' makes integer from pointer without a cast" } */ + e = a; /* { dg-warning "assignment to 'void \\\*' from '_BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */ + f = b; /* { dg-warning "assignment to 'void \\\*' from 'unsigned _BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */ + g = c; /* { dg-warning "assignment to 'void \\\*' from '_BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */ + h = d; /* { dg-warning "assignment to 'void \\\*' from 'unsigned _BitInt\\\(\[0-9]+\\\)' makes pointer from integer without a cast" } */ + _BitInt(61) i = (1wb - 1152921504606846975wb) << 1; /* { dg-warning "left shift of negative value" } */ + /* { dg-warning "result of '-1152921504606846974 << 1' requires 62 bits to represent, but '_BitInt\\\(61\\\)' only has 61 bits" "" { target *-*-* } .-1 } */ + _BitInt(61) j = i << (60 + 1); /* { dg-warning "left shift count >= width of type" } */ + _BitInt(61) k = i >> (60 + 1); /* { dg-warning "right shift count >= width of type" } */ + _BitInt(61) l = i / (51wb - 51wb); /* { dg-warning "division by zero" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-4.c b/SingleSource/Regression/C/gcc-dg/bitint-4.c new file mode 100644 index 0000000000..4c2446ba2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-4.c @@ -0,0 +1,39 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +_BitInt(2) +foo (_BitInt(2) x, _BitInt(15) y) +{ + return x + y; +} + +_BitInt(64) +bar (_BitInt(64) x, _BitInt(64) y) +{ + return x + y; +} + +#if __BITINT_MAXWIDTH__ >= 128 +_BitInt(128) a, b, c; + +_BitInt(128) +baz (_BitInt(128) x, _BitInt(128) y) +{ + a = x; + b = y; + return c; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +_BitInt(575) d, e, f; + +_BitInt(575) +qux (_BitInt(575) x, _BitInt(575) y) +{ + d = x; + e = y; + return f; +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-5.c b/SingleSource/Regression/C/gcc-dg/bitint-5.c new file mode 100644 index 0000000000..ebd6c18e0f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-5.c @@ -0,0 +1,63 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include +#include + +#if __BITINT_MAXWIDTH__ >= 128 +unsigned _BitInt(128) b, c; +#endif +#if __BITINT_MAXWIDTH__ >= 575 +signed _BitInt(575) d, e; +#endif + +void +foo (int a, ...) +{ + va_list ap; + va_start (ap, a); + if (a == 1) + { + if (va_arg (ap, _BitInt(2)) != 1wb) + abort (); + if (va_arg (ap, _BitInt(3)) != 3wb) + abort (); + if (va_arg (ap, _BitInt(15)) != 16383wb) + abort (); + if (va_arg (ap, unsigned _BitInt(32)) != 4294967295uwb) + abort (); + if (va_arg (ap, _BitInt(64)) != 0x7fffffffffffffffwb) + abort (); + } +#if __BITINT_MAXWIDTH__ >= 128 + b = va_arg (ap, unsigned _BitInt(128)); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + d = va_arg (ap, _BitInt(575)); +#endif + if (va_arg (ap, int) != 42) + abort (); + va_end (ap); +} + +void +bar (void) +{ + foo (1, 1wb, 3wb, 16383wb, 4294967295uwb, 9223372036854775807wb, +#if __BITINT_MAXWIDTH__ >= 128 + c, +#endif +#if __BITINT_MAXWIDTH__ >= 575 + e, +#endif + 42); + foo (2, +#if __BITINT_MAXWIDTH__ >= 128 + c, +#endif +#if __BITINT_MAXWIDTH__ >= 575 + e, +#endif + 42); +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-6.c b/SingleSource/Regression/C/gcc-dg/bitint-6.c new file mode 100644 index 0000000000..f4d7366348 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-6.c @@ -0,0 +1,15 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int *q, *r, *s; + +void +foo (int *p) +{ + p[4wb] = 0; + 6wb[p] = 0; + q = p + 8wb; + r = 10uwb + q; + s = r - 2wb; +} diff --git a/SingleSource/Regression/C/gcc-dg/bitint-7.c b/SingleSource/Regression/C/gcc-dg/bitint-7.c new file mode 100644 index 0000000000..ed6d577a16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-7.c @@ -0,0 +1,16 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 257 +void +foo (_BitInt(135) *p, _BitInt(193) *q, _BitInt(257) *r) +{ + r[0] = (((p[0] + p[1] + p[2]) + q[0] + (p[3] + p[4] + p[5])) + q[1]) + r[1] + (((p[6] + p[7] + p[8]) + q[2] + (p[9] + p[10] + p[11])) + q[3]) + r[2]; +} +#else +void +foo (void) +{ +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/bitint-8.c b/SingleSource/Regression/C/gcc-dg/bitint-8.c new file mode 100644 index 0000000000..83ef0f8633 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-8.c @@ -0,0 +1,34 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c2x -Wno-uninitialized" } */ + +#if __BITINT_MAXWIDTH__ >= 135 +_BitInt(135) +foo (void) +{ + _BitInt(135) d; + _BitInt(135) e = d + 2wb; + return e; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +_BitInt(575) +bar (void) +{ + _BitInt(575) d; + _BitInt(575) e = d * 42wb; + return e; +} + +_BitInt(575) +baz (int x) +{ + _BitInt(575) d; + if (x) + return 59843758943759843574wb; + return d; +} +#endif + +int x; diff --git a/SingleSource/Regression/C/gcc-dg/bitint-9.c b/SingleSource/Regression/C/gcc-dg/bitint-9.c new file mode 100644 index 0000000000..c3777b1662 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bitint-9.c @@ -0,0 +1,52 @@ +/* PR c/102989 */ +/* { dg-do compile { target { bitint && exceptions } } } */ +/* { dg-options "-O2 -std=gnu2x -fnon-call-exceptions -fexceptions" } */ + +__attribute__((noipa)) void +baz (int *p) +{ +} + +#if __BITINT_MAXWIDTH__ >= 575 +void +foo (volatile _BitInt(575) *p, _BitInt(575) q) +{ + int a __attribute__((cleanup (baz))) = 1; + *p = q; +} + +_BitInt(575) +bar (volatile _BitInt(575) *p) +{ + int a __attribute__((cleanup (baz))) = 1; + return *p; +} + +_BitInt(575) +qux (long double l) +{ + int a __attribute__((cleanup (baz))) = 1; + return l; +} + +long double +corge (_BitInt(575) b) +{ + int a __attribute__((cleanup (baz))) = 1; + return b; +} + +_BitInt(575) +garply (_BitInt(575) x, _BitInt(575) y) +{ + int a __attribute__((cleanup (baz))) = 1; + return x / y; +} + +_BitInt(575) +waldo (_BitInt(575) x, _BitInt(575) y) +{ + int a __attribute__((cleanup (baz))) = 1; + return x % y; +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/boolcomplex-1.c b/SingleSource/Regression/C/gcc-dg/boolcomplex-1.c new file mode 100644 index 0000000000..c34da04d6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/boolcomplex-1.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ +_Bool b = --0i == 0; /* { dg-error "lvalue required as decrement operand" } */ diff --git a/SingleSource/Regression/C/gcc-dg/bss.c b/SingleSource/Regression/C/gcc-dg/bss.c new file mode 100644 index 0000000000..af8d0c634f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/bss.c @@ -0,0 +1,8 @@ +/* Test non-zero initializers in .bss-like sections get properly refused. */ +/* { dg-do compile } */ +/* { dg-require-named-sections "" } */ + +int __attribute__((section(".bss.local"))) x = 1; /* { dg-error "" "zero init" } */ +int *__attribute__((section(".bss.local"))) px = &x; /* { dg-error "" "zero init" } */ +int __attribute__((section(".bss.local"))) y = 0; +int *__attribute__((section(".bss.local"))) py = (void*)0; diff --git a/SingleSource/Regression/C/gcc-dg/builtin-addc-1.c b/SingleSource/Regression/C/gcc-dg/builtin-addc-1.c new file mode 100644 index 0000000000..c875d8f66e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-addc-1.c @@ -0,0 +1,101 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -g" } */ + +int +main () +{ + unsigned int c; + unsigned long cl; + unsigned long long cll; + if (__builtin_addc (1, 42, 0, &c) != 43 || c != 0) + __builtin_abort (); + if (__builtin_addc (1, 42, 15, &c) != 58 || c != 0) + __builtin_abort (); + if (__builtin_addc (-2U, -3U, -4U, &c) != -9U || c != 1) + __builtin_abort (); + if (__builtin_addc (-2U, 1, 0, &c) != -1U || c != 0) + __builtin_abort (); + if (__builtin_addc (-2U, 1, 1, &c) != 0 || c != 1) + __builtin_abort (); + if (__builtin_addc (-2U, 2, 0, &c) != 0 || c != 1) + __builtin_abort (); + if (__builtin_addc (-2U, 0, 2, &c) != 0 || c != 1) + __builtin_abort (); + if (__builtin_addcl (1L, 42L, 0L, &cl) != 43 || cl != 0L) + __builtin_abort (); + if (__builtin_addcl (1L, 42L, 15L, &cl) != 58 || cl != 0L) + __builtin_abort (); + if (__builtin_addcl (-2UL, -3UL, -4UL, &cl) != -9UL || cl != 1L) + __builtin_abort (); + if (__builtin_addcl (-2UL, 1L, 0L, &cl) != -1UL || cl != 0L) + __builtin_abort (); + if (__builtin_addcl (-2UL, 1L, 1L, &cl) != 0 || cl != 1L) + __builtin_abort (); + if (__builtin_addcl (-2UL, 2L, 0L, &cl) != 0 || cl != 1L) + __builtin_abort (); + if (__builtin_addcl (-2UL, 0L, 2L, &cl) != 0 || cl != 1L) + __builtin_abort (); + if (__builtin_addcll (1LL, 42LL, 0LL, &cll) != 43 || cll != 0LL) + __builtin_abort (); + if (__builtin_addcll (1LL, 42LL, 15LL, &cll) != 58 || cll != 0LL) + __builtin_abort (); + if (__builtin_addcll (-2ULL, -3ULL, -4ULL, &cll) != -9ULL || cll != 1LL) + __builtin_abort (); + if (__builtin_addcll (-2ULL, 1LL, 0LL, &cll) != -1ULL || cll != 0LL) + __builtin_abort (); + if (__builtin_addcll (-2ULL, 1LL, 1LL, &cll) != 0 || cll != 1LL) + __builtin_abort (); + if (__builtin_addcll (-2ULL, 2LL, 0LL, &cll) != 0 || cll != 1LL) + __builtin_abort (); + if (__builtin_addcll (-2ULL, 0LL, 2LL, &cll) != 0 || cll != 1LL) + __builtin_abort (); + if (__builtin_subc (42, 42, 0, &c) != 0 || c != 0) + __builtin_abort (); + if (__builtin_subc (42, 42, 1, &c) != -1U || c != 1) + __builtin_abort (); + if (__builtin_subc (1, -3U, -4U, &c) != 8 || c != 1) + __builtin_abort (); + if (__builtin_subc (-2U, 1, 0, &c) != -3U || c != 0) + __builtin_abort (); + if (__builtin_subc (-2U, -1U, 0, &c) != -1U || c != 1) + __builtin_abort (); + if (__builtin_subc (-2U, -2U, 0, &c) != 0 || c != 0) + __builtin_abort (); + if (__builtin_subc (-2U, -2U, 1, &c) != -1U || c != 1) + __builtin_abort (); + if (__builtin_subc (-2U, 1, -2U, &c) != -1U || c != 1) + __builtin_abort (); + if (__builtin_subcl (42L, 42L, 0L, &cl) != 0L || cl != 0L) + __builtin_abort (); + if (__builtin_subcl (42L, 42L, 1L, &cl) != -1UL || cl != 1L) + __builtin_abort (); + if (__builtin_subcl (1L, -3UL, -4UL, &cl) != 8L || cl != 1L) + __builtin_abort (); + if (__builtin_subcl (-2UL, 1L, 0L, &cl) != -3UL || cl != 0L) + __builtin_abort (); + if (__builtin_subcl (-2UL, -1UL, 0L, &cl) != -1UL || cl != 1L) + __builtin_abort (); + if (__builtin_subcl (-2UL, -2UL, 0L, &cl) != 0L || cl != 0L) + __builtin_abort (); + if (__builtin_subcl (-2UL, -2UL, 1L, &cl) != -1UL || cl != 1L) + __builtin_abort (); + if (__builtin_subcl (-2UL, 1L, -2UL, &cl) != -1UL || cl != 1L) + __builtin_abort (); + if (__builtin_subcll (42LL, 42LL, 0LL, &cll) != 0LL || cll != 0LL) + __builtin_abort (); + if (__builtin_subcll (42LL, 42LL, 1LL, &cll) != -1ULL || cll != 1LL) + __builtin_abort (); + if (__builtin_subcll (1LL, -3ULL, -4ULL, &cll) != 8LL || cll != 1LL) + __builtin_abort (); + if (__builtin_subcll (-2ULL, 1LL, 0LL, &cll) != -3ULL || cll != 0LL) + __builtin_abort (); + if (__builtin_subcll (-2ULL, -1ULL, 0LL, &cll) != -1ULL || cll != 1LL) + __builtin_abort (); + if (__builtin_subcll (-2ULL, -2ULL, 0LL, &cll) != 0LL || cll != 0LL) + __builtin_abort (); + if (__builtin_subcll (-2ULL, -2ULL, 1LL, &cll) != -1ULL || cll != 1LL) + __builtin_abort (); + if (__builtin_subcll (-2ULL, 1LL, -2ULL, &cll) != -1ULL || cll != 1LL) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-alloc-size.c b/SingleSource/Regression/C/gcc-dg/builtin-alloc-size.c new file mode 100644 index 0000000000..400fd9bc8f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-alloc-size.c @@ -0,0 +1,73 @@ +/* PR c/78668 - aligned_alloc, realloc, et al. missing attribute alloc_size + Test to verify that memory allocation built-ins are decorated with + attribute alloc_size that __builtin_object_size can make use of (or + are treated as if they were for that purpose).. + { dg-do compile } + { dg-require-effective-target alloca } + { dg-additional-options "-O2 -fdump-tree-optimized" } */ + +void sink (void*); + +static unsigned size (unsigned n) +{ + return n; +} + +void test_aligned_alloc (unsigned a) +{ + unsigned n = size (7); + + void *p = __builtin_aligned_alloc (a, n); + if (__builtin_object_size (p, 0) != n) + __builtin_abort (); + sink (p); +} + +void test_alloca (void) +{ + unsigned n = size (13); + + void *p = __builtin_alloca (n); + + /* Also verify that alloca is declared with attribute returns_nonnull + (or treated as it were as the case may be). */ + if (!p) + __builtin_abort (); + + if (__builtin_object_size (p, 0) != n) + __builtin_abort (); + sink (p); +} + +void test_calloc (void) +{ + unsigned m = size (19); + unsigned n = size (23); + + void *p = __builtin_calloc (m, n); + if (__builtin_object_size (p, 0) != m * n) + __builtin_abort (); + sink (p); +} + +void test_malloc (void) +{ + unsigned n = size (17); + + void *p = __builtin_malloc (n); + if (__builtin_object_size (p, 0) != n) + __builtin_abort (); + sink (p); +} + +void test_realloc (void *p) +{ + unsigned n = size (31); + + p = __builtin_realloc (p, n); + if (__builtin_object_size (p, 0) != n) + __builtin_abort (); + sink (p); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-apply1.c b/SingleSource/Regression/C/gcc-dg/builtin-apply1.c new file mode 100644 index 0000000000..7079ce3a68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-apply1.c @@ -0,0 +1,10 @@ +/* PR 11184 */ +/* Origin: Dara Hazeghi */ +/* { dg-require-effective-target untyped_assembly } */ + +void * +objc_msg_sendv (char * arg_frame, void (*foo)()) +{ + return __builtin_apply ( foo, arg_frame, 4); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtin-apply2.c b/SingleSource/Regression/C/gcc-dg/builtin-apply2.c new file mode 100644 index 0000000000..0f350f4ac1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-apply2.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-require-effective-target untyped_assembly } */ +/* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args in registers." { "avr-*-* nds32*-*-* amdgcn-*-*" } } */ +/* { dg-skip-if "Variadic funcs use different argument passing from normal funcs." { "csky*-*-* riscv*-*-* or1k*-*-* msp430-*-* pru-*-* loongarch*-*-*" } } */ +/* { dg-skip-if "Variadic funcs use Base AAPCS. Normal funcs use VFP variant." { arm*-*-* && arm_hf_eabi } } */ + +/* PR target/12503 */ +/* Origin: */ + +/* Verify that __builtin_apply behaves correctly on targets + with pre-pushed arguments (e.g. SPARC). */ + + + +#define INTEGER_ARG 5 + +#if defined(__ARM_PCS) || defined(__epiphany__) +/* For Base AAPCS, NAME is passed in r0. D is passed in r2 and r3. + E, F and G are passed on stack. So the size of the stack argument + data is 20. */ +#define STACK_ARGUMENTS_SIZE 20 +#elif defined __MMIX__ || defined __arc__ +/* No parameters on stack for bar. */ +#define STACK_ARGUMENTS_SIZE 0 +#else +#define STACK_ARGUMENTS_SIZE 64 +#endif + +extern void abort(void); + +void foo(char *name, double d, double e, double f, int g) +{ + if (g != INTEGER_ARG) + abort(); +} + +void bar(char *name, ...) +{ + __builtin_apply(foo, __builtin_apply_args(), STACK_ARGUMENTS_SIZE); +} + +int main(void) +{ + bar("eeee", 5.444567, 8.90765, 4.567789, INTEGER_ARG); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-apply3.c b/SingleSource/Regression/C/gcc-dg/builtin-apply3.c new file mode 100644 index 0000000000..8fc20030ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-apply3.c @@ -0,0 +1,33 @@ +/* PR middle-end/12210 */ +/* Origin: Ossadchy Yury A. */ + +/* This used to fail on i686 because the argument was not copied + to the right location by __builtin_apply after the direct call. */ + +/* { dg-do run } */ +/* { dg-require-effective-target untyped_assembly } */ +/* { dg-xfail-run-if "can cause stack underflow" { amdgcn-*-* } } */ + + +#define INTEGER_ARG 5 + +extern void abort(void); + +void foo(int arg) +{ + if (arg != INTEGER_ARG) + abort(); +} + +void bar(int arg) +{ + foo(arg); + __builtin_apply(foo, __builtin_apply_args(), 16); +} + +int main(void) +{ + bar(INTEGER_ARG); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-apply4.c b/SingleSource/Regression/C/gcc-dg/builtin-apply4.c new file mode 100644 index 0000000000..aa491c18de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-apply4.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/20076 */ +/* { dg-options "-O2 -Wmissing-noreturn -fgnu89-inline" } */ +/* { dg-additional-options "-mno-mmx" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-do run } */ +/* { dg-require-effective-target untyped_assembly } */ +/* { dg-xfail-run-if "can cause stack underflow" { amdgcn-*-* } } */ + +extern void abort (void); + +double +foo (int arg) +{ + if (arg != 116) + abort(); + return arg + 1; +} + +inline double +bar (int arg) +{ + foo (arg); + __builtin_return (__builtin_apply ((void (*) ()) foo, + __builtin_apply_args (), 16)); +} + +int +main (int argc, char **argv) +{ + if (bar (116) != 117.0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-1.c b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-1.c new file mode 100644 index 0000000000..5db9368927 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-1.c @@ -0,0 +1,131 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-optimized -g" } */ + +/* SUB_OVERFLOW should be folded into unsigned subtraction, + because ovf is never used. */ +__attribute__((noinline, noclone)) int +fn1 (int x, unsigned int y) +{ + int res; + int ovf = __builtin_sub_overflow (x, y, &res); + int res2 = res; + int res3 = res2 - 2; + (void) ovf; + return res; +} + +/* MUL_OVERFLOW should be folded into unsigned multiplication, + because ovf is never used. */ +__attribute__((noinline, noclone)) int +fn2 (signed char x, long int y) +{ + short int res; + int ovf = __builtin_mul_overflow (x, y, &res); + int res2 = res; + int res3 = res2 - 2; + (void) ovf; + return res; +} + +#if __SIZEOF_INT__ > __SIZEOF_SHORT__ && __SIZEOF_INT__ > 1 +/* ADD_OVERFLOW should be folded into unsigned addition, + because it never overflows. */ +__attribute__((noinline, noclone)) int +fn3 (signed char x, unsigned short y, int *ovf) +{ + int res; + *ovf = __builtin_add_overflow (x, y, &res); + return res; +} +#endif + +/* MUL_OVERFLOW should be folded into unsigned multiplication, + because it never overflows. */ +__attribute__((noinline, noclone)) long int +fn4 (long int x, long int y, int *ovf) +{ + long int res; + x &= 65535; + y = (y & 65535) - 32768; + *ovf = __builtin_mul_overflow (x, y, &res); + return res; +} + +#if __SIZEOF_INT__ > 1 +/* MUL_OVERFLOW should be folded into unsigned multiplication, + because it always overflows. */ +__attribute__((noinline, noclone)) signed char +fn5 (long int x, long int y, int *ovf) +{ + signed char res; + x = (x & 63) + (__SCHAR_MAX__ / 4); + y = (y & 3) + 5; + *ovf = __builtin_mul_overflow (x, y, &res); + return res; +} +#endif + +/* ADD_OVERFLOW should be folded into unsigned additrion, + because it never overflows. */ +__attribute__((noinline, noclone)) unsigned char +fn6 (unsigned char x, unsigned char y, int *ovf) +{ + unsigned char res; + x = (x & 63) + ((unsigned char) ~0 - 66); + y = (y & 3); + *ovf = __builtin_add_overflow (x, y, &res); + return res; +} + +/* ADD_OVERFLOW should be folded into unsigned additrion, + because it always overflows. */ +__attribute__((noinline, noclone)) unsigned char +fn7 (unsigned char x, unsigned char y, int *ovf) +{ + unsigned char res; + x = (x & 15) + ((unsigned char) ~0 - 15); + y = (y & 3) + 16; + *ovf = __builtin_add_overflow (x, y, &res); + return res; +} + +int +main () +{ + int ovf; + if (fn1 (-10, __INT_MAX__) != (int) (-10U - __INT_MAX__) + || fn2 (0, 0) != 0 + || fn2 (32, 16383) != (short int) 524256ULL) + __builtin_abort (); +#if __SIZEOF_INT__ > __SIZEOF_SHORT__ && __SIZEOF_INT__ > 1 + if (fn3 (__SCHAR_MAX__, (unsigned short) ~0, &ovf) != (int) (__SCHAR_MAX__ + (unsigned short) ~0) + || ovf + || fn3 (-__SCHAR_MAX__ - 1, 0, &ovf) != (int) (-__SCHAR_MAX__ - 1) + || ovf) + __builtin_abort (); +#endif + if (fn4 (65535, 0, &ovf) != 65535L * -32768 || ovf) + __builtin_abort (); +#if __SIZEOF_INT__ > 1 + if (fn5 (0, 0, &ovf) != (signed char) (__SCHAR_MAX__ / 4 * 5) + || !ovf + || fn5 (63, 3, &ovf) != (signed char) ((__SCHAR_MAX__ / 4 + 63) * 8) + || !ovf) + __builtin_abort (); +#endif + if (fn6 (0, 0, &ovf) != (unsigned char) ~0 - 66 + || ovf + || fn6 (63, 3, &ovf) != (unsigned char) ~0 + || ovf) + __builtin_abort (); + if (fn7 (0, 0, &ovf) != 0 + || !ovf + || fn7 (63, 3, &ovf) != 18 + || !ovf) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "ADD_OVERFLOW" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "SUB_OVERFLOW" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "MUL_OVERFLOW" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-2.c b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-2.c new file mode 100644 index 0000000000..1a9e66637a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-2.c @@ -0,0 +1,109 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* MUL_OVERFLOW should not be folded into unsigned multiplication, + because it sometimes overflows and sometimes does not. */ +__attribute__((noinline, noclone)) long int +fn1 (long int x, long int y, int *ovf) +{ + long int res; + x &= 65535; + y = (y & 65535) - (__LONG_MAX__ / 65535 + 32768); + *ovf = __builtin_mul_overflow (x, y, &res); + return res; +} + +/* MUL_OVERFLOW should not be folded into unsigned multiplication, + because it sometimes overflows and sometimes does not. */ +__attribute__((noinline, noclone)) signed char +fn2 (long int x, long int y, int *ovf) +{ + signed char res; + x = (x & 63) + (__SCHAR_MAX__ / 4); + y = (y & 3) + 4; + *ovf = __builtin_mul_overflow (x, y, &res); + return res; +} + +/* ADD_OVERFLOW should be folded into unsigned additrion, + because it sometimes overflows and sometimes does not. */ +__attribute__((noinline, noclone)) unsigned char +fn3 (unsigned char x, unsigned char y, int *ovf) +{ + unsigned char res; + x = (x & 63) + ((unsigned char) ~0 - 65); + y = (y & 3); + *ovf = __builtin_add_overflow (x, y, &res); + return res; +} + +/* ADD_OVERFLOW should be folded into unsigned additrion, + because it sometimes overflows and sometimes does not. */ +__attribute__((noinline, noclone)) unsigned char +fn4 (unsigned char x, unsigned char y, int *ovf) +{ + unsigned char res; + x = (x & 15) + ((unsigned char) ~0 - 16); + y = (y & 3) + 16; + *ovf = __builtin_add_overflow (x, y, &res); + return res; +} + +/* MUL_OVERFLOW should not be folded into unsigned multiplication, + because it sometimes overflows and sometimes does not. */ +__attribute__((noinline, noclone)) long int +fn5 (long int x, unsigned long int y, int *ovf) +{ + long int res; + y = -65536UL + (y & 65535); + *ovf = __builtin_mul_overflow (x, y, &res); + return res; +} + +int +main () +{ + int ovf; + if (fn1 (0, 0, &ovf) != 0 + || ovf + || fn1 (65535, 0, &ovf) != (long int) ((__LONG_MAX__ / 65535 + 32768UL) * -65535UL) + || !ovf) + __builtin_abort (); + if (fn2 (0, 0, &ovf) != (signed char) (__SCHAR_MAX__ / 4 * 4U) + || ovf + || fn2 (0, 1, &ovf) != (signed char) (__SCHAR_MAX__ / 4 * 5U) + || !ovf) + __builtin_abort (); + if (fn3 (0, 0, &ovf) != (unsigned char) ~0 - 65 + || ovf + || fn3 (63, 2, &ovf) != (unsigned char) ~0 + || ovf + || fn3 (62, 3, &ovf) != (unsigned char) ~0 + || ovf + || fn3 (63, 3, &ovf) != 0 + || !ovf) + __builtin_abort (); + if (fn4 (0, 0, &ovf) != (unsigned char) ~0 + || ovf + || fn4 (1, 0, &ovf) != 0 + || !ovf + || fn4 (0, 1, &ovf) != 0 + || !ovf + || fn4 (63, 3, &ovf) != 17 + || !ovf) + __builtin_abort (); + if (fn5 (0, 0, &ovf) != 0 + || ovf + || fn5 (1, 0, &ovf) != -65536L + || !ovf + || fn5 (2, 32768, &ovf) != -65536L + || !ovf + || fn5 (4, 32768 + 16384 + 8192, &ovf) != -32768L + || !ovf) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "ADD_OVERFLOW" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "SUB_OVERFLOW" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "MUL_OVERFLOW" 3 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-3.c b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-3.c new file mode 100644 index 0000000000..6feae1eb42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-3.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +static int cnt = 0; + +#define LL_MIN ((long long)(-__LONG_LONG_MAX__ - 1)) + +#define SC1 (LL_MIN + 5) +#define UC1 ((1ULL << (__LONG_LONG_WIDTH__ - 1)) | 5ULL) +#define UC2 (~UC1) + +long long __attribute__ ((noinline, noclone)) +f1 (long long a) +{ + long long x; + if (__builtin_add_overflow (a, SC1, &x)) cnt++; + return x; +} + +unsigned long long __attribute__ ((noinline, noclone)) +f2 (unsigned long long a) +{ + unsigned long long x; + if (__builtin_add_overflow (a, UC1, &x)) + cnt++; + return x; +} + +int main () +{ + if (f1 (-5) != LL_MIN) __builtin_abort (); + if (cnt != 0) __builtin_abort (); + f1 (-6); + if (cnt != 1) __builtin_abort (); + cnt = 0; + if (f2 (UC2) != ~0ULL) __builtin_abort (); + if (cnt != 0) __builtin_abort (); + if (f2 (UC2 + 1) != 0) __builtin_abort (); + if (cnt != 1) __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-4.c b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-4.c new file mode 100644 index 0000000000..ab7d82a8d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-4.c @@ -0,0 +1,43 @@ +/* PR c/90628 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +_Atomic int a = 1, b = 2, c = 3; +_Atomic long d = 4, e = 5, f = 6; +_Atomic long long g = 7, h = 8, i = 9; + +void +f1 () +{ + __builtin_add_overflow (a, b, &c); /* { dg-error "argument 3 in call to function '__builtin_add_overflow' has pointer to '_Atomic' type" } */ +} + +void +f2 () +{ + __builtin_sub_overflow (d, e, &f); /* { dg-error "argument 3 in call to function '__builtin_sub_overflow' has pointer to '_Atomic' type" } */ +} + +void +f3 () +{ + __builtin_mul_overflow (g, h, &i); /* { dg-error "argument 3 in call to function '__builtin_mul_overflow' has pointer to '_Atomic' type" } */ +} + +void +f4 () +{ + __builtin_sadd_overflow (a, b, &c); /* { dg-warning "passing argument 3 of '__builtin_sadd_overflow' from incompatible pointer type" } */ +} + +void +f5 () +{ + __builtin_ssubl_overflow (d, e, &f); /* { dg-warning "passing argument 3 of '__builtin_ssubl_overflow' from incompatible pointer type" } */ +} + +void +f6 () +{ + __builtin_smulll_overflow (g, h, &i); /* { dg-warning "passing argument 3 of '__builtin_smulll_overflow' from incompatible pointer type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-5.c b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-5.c new file mode 100644 index 0000000000..b43fd1859d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-arith-overflow-5.c @@ -0,0 +1,87 @@ +/* PR rtl-optimization/95862 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +f1 (int a, int b) +{ + unsigned long long c; + return __builtin_mul_overflow (a, b, &c); +} + +int +f2 (int a, unsigned b) +{ + unsigned long long c; + return __builtin_mul_overflow (a, b, &c); +} + +int +f3 (unsigned a, unsigned b) +{ + long long c; + return __builtin_mul_overflow (a, b, &c); +} + +int +f4 (int a, unsigned b) +{ + long long c; + return __builtin_mul_overflow (a, b, &c); +} + +short +f5 (short a, short b) +{ + unsigned c; + return __builtin_mul_overflow (a, b, &c); +} + +short +f6 (short a, unsigned short b) +{ + unsigned c; + return __builtin_mul_overflow (a, b, &c); +} + +short +f7 (unsigned short a, unsigned short b) +{ + int c; + return __builtin_mul_overflow (a, b, &c); +} + +short +f8 (short a, unsigned short b) +{ + int c; + return __builtin_mul_overflow (a, b, &c); +} + +signed char +f9 (signed char a, signed char b) +{ + unsigned short c; + return __builtin_mul_overflow (a, b, &c); +} + +signed char +f10 (signed char a, unsigned char b) +{ + unsigned short c; + return __builtin_mul_overflow (a, b, &c); +} + +signed char +f11 (unsigned char a, unsigned char b) +{ + short c; + return __builtin_mul_overflow (a, b, &c); +} + +signed char +f12 (signed char a, unsigned char b) +{ + short c; + return __builtin_mul_overflow (a, b, &c); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-assume-aligned-1.c b/SingleSource/Regression/C/gcc-dg/builtin-assume-aligned-1.c new file mode 100644 index 0000000000..a74eccee4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-assume-aligned-1.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ + +void +test1 (double *out1, double *out2, double *out3, double *in1, + double *in2, int len) +{ + int i; + double *__restrict o1 = __builtin_assume_aligned (out1, 16); + double *__restrict o2 = __builtin_assume_aligned (out2, 16); + double *__restrict o3 = __builtin_assume_aligned (out3, 16); + double *__restrict i1 = __builtin_assume_aligned (in1, 16); + double *__restrict i2 = __builtin_assume_aligned (in2, 16); + for (i = 0; i < len; ++i) + { + o1[i] = i1[i] * i2[i]; + o2[i] = i1[i] + i2[i]; + o3[i] = i1[i] - i2[i]; + } +} + +void +test2 (double *out1, double *out2, double *out3, double *in1, + double *in2, int len) +{ + int i, align = 32, misalign = 16; + out1 = __builtin_assume_aligned (out1, align, misalign); + out2 = __builtin_assume_aligned (out2, align, 16); + out3 = __builtin_assume_aligned (out3, 32, misalign); + in1 = __builtin_assume_aligned (in1, 32, 16); + in2 = __builtin_assume_aligned (in2, 32, 0); + for (i = 0; i < len; ++i) + { + out1[i] = in1[i] * in2[i]; + out2[i] = in1[i] + in2[i]; + out3[i] = in1[i] - in2[i]; + } +} + +/* { dg-final { scan-tree-dump-not "__builtin_assume_aligned" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-assume-aligned-2.c b/SingleSource/Regression/C/gcc-dg/builtin-assume-aligned-2.c new file mode 100644 index 0000000000..5b0de5720c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-assume-aligned-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +double *bar (void); + +void +foo (double *ptr, int i) +{ + double *a = __builtin_assume_aligned (ptr, 16, 8, 7); /* { dg-error "too many arguments to function" } */ + double *b = __builtin_assume_aligned (bar (), 16); + double *c = __builtin_assume_aligned (bar (), 16, 8); + double *d = __builtin_assume_aligned (ptr, i, ptr); /* { dg-error "non-integer argument 3 in call to function" } */ + double *e = __builtin_assume_aligned (ptr, i, *ptr); /* { dg-error "non-integer argument 3 in call to function" } */ + *a = 0.0; + *b = 0.0; + *c = 0.0; + *d = 0.0; + *e = 0.0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-1.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-1.c new file mode 100644 index 0000000000..724ba1e984 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "" } */ +/* { dg-final { scan-assembler-not "__builtin_" } } */ + +#include + +uint16_t foo16 (uint16_t a) +{ + uint16_t b; + + b = __builtin_bswap16 (a); + + return b; +} + +uint32_t foo32 (uint32_t a) +{ + uint32_t b; + + b = __builtin_bswap32 (a); + + return b; +} + +uint64_t foo64 (uint64_t a) +{ + uint64_t b; + + b = __builtin_bswap64 (a); + + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-10.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-10.c new file mode 100644 index 0000000000..6c69bcd70d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-10.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target { ! int128 } } } */ +/* { dg-options "" } */ +/* { dg-final { scan-assembler "__builtin_" } } */ + +int foo (int x) +{ + return __builtin_bswap128 (x); /* { dg-warning "implicit declaration" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-11.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-11.c new file mode 100644 index 0000000000..3fedcf1bd3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-11.c @@ -0,0 +1,51 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-Wall" } */ + +#include + +#define MAKE_FUN(suffix, type) \ + type my_bswap##suffix(type x) { \ + type result = 0; \ + int shift; \ + for (shift = 0; shift < 8 * sizeof (type); shift += 8) \ + { \ + result <<= 8; \ + result |= (x >> shift) & 0xff; \ + } \ + return result; \ + } \ + +MAKE_FUN(128, __uint128_t); + +extern void abort (void); + +typedef union +{ + struct { uint64_t lo; uint64_t hi; } s; + __uint128_t n; +} u; + +#define NUMS128 \ + { \ + { .s = { 0x0000000000000000ULL, 0x1122334455667788ULL } }, \ + { .s = { 0x1122334455667788ULL, 0xffffffffffffffffULL } }, \ + { .s = { 0xffffffffffffffffULL, 0x0000000000000000ULL } } \ + } + +u uint128_ts[] = NUMS128; + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + for (i = 0; i < N(uint128_ts); i++) + if (__builtin_bswap128 (uint128_ts[i].n) != my_bswap128 (uint128_ts[i].n)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-12.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-12.c new file mode 100644 index 0000000000..8ff65d8530 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-12.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O" } */ + +#include + +typedef union +{ + struct { uint64_t lo; uint64_t hi; } s; + __uint128_t n; +} u; + +int +main (void) +{ + /* Test constant folding. */ + extern void link_error (void); + + const u U1 = { .s = { 0x1122334455667788ULL, 0xffffffffffffffffULL } }; + const u U2 = { .s = { 0xffffffffffffffffULL, 0x8877665544332211ULL } }; + + if (__builtin_bswap128 (U1.n) != U2.n) + link_error (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-13.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-13.c new file mode 100644 index 0000000000..6dc4c15b45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-13.c @@ -0,0 +1,329 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int test_s32_0_1(int x) { return __builtin_bswap32(x) & 1; } +int test_s32_0_2(int x) { return __builtin_bswap32(x) & 2; } +int test_s32_0_240(int x) { return __builtin_bswap32(x) & 240; } +int test_s32_0_255(int x) { return __builtin_bswap32(x) & 255; } +int test_s32_1_1(int x) { return (__builtin_bswap32(x) >> 1) & 1; } +int test_s32_7_1(int x) { return (__builtin_bswap32(x) >> 7) & 1; } +int test_s32_8_1(int x) { return (__builtin_bswap32(x) >> 8) & 1; } +int test_s32_8_240(int x) { return (__builtin_bswap32(x) >> 8) & 240; } +int test_s32_8_255(int x) { return (__builtin_bswap32(x) >> 8) & 255; } +int test_s32_15_1(int x) { return (__builtin_bswap32(x) >> 15) & 1; } +int test_s32_16_1(int x) { return (__builtin_bswap32(x) >> 16) & 1; } +int test_s32_16_240(int x) { return (__builtin_bswap32(x) >> 16) & 240; } +int test_s32_16_255(int x) { return (__builtin_bswap32(x) >> 16) & 255; } +int test_s32_24_1(int x) { return (__builtin_bswap32(x) >> 24) & 1; } +int test_s32_24_240(int x) { return (__builtin_bswap32(x) >> 24) & 240; } +int test_s32_24_255(int x) { return (__builtin_bswap32(x) >> 24) & 255; } +int test_s32_31_1(int x) { return (__builtin_bswap32(x) >> 31) & 1; } + +int test_S32_0_1(int x) { return (int)__builtin_bswap32(x) & 1; } +int test_S32_0_2(int x) { return (int)__builtin_bswap32(x) & 2; } +int test_S32_0_240(int x) { return (int)__builtin_bswap32(x) & 240; } +int test_S32_0_255(int x) { return (int)__builtin_bswap32(x) & 255; } +int test_S32_1_1(int x) { return ((int)__builtin_bswap32(x) >> 1) & 1; } +int test_S32_7_1(int x) { return ((int)__builtin_bswap32(x) >> 7) & 1; } +int test_S32_8_1(int x) { return ((int)__builtin_bswap32(x) >> 8) & 1; } +int test_S32_8_240(int x) { return ((int)__builtin_bswap32(x) >> 8) & 240; } +int test_S32_8_255(int x) { return ((int)__builtin_bswap32(x) >> 8) & 255; } +int test_S32_15_1(int x) { return ((int)__builtin_bswap32(x) >> 15) & 1; } +int test_S32_16_1(int x) { return ((int)__builtin_bswap32(x) >> 16) & 1; } +int test_S32_16_240(int x) { return ((int)__builtin_bswap32(x) >> 16) & 240; } +int test_S32_16_255(int x) { return ((int)__builtin_bswap32(x) >> 16) & 255; } +int test_S32_24_1(int x) { return ((int)__builtin_bswap32(x) >> 24) & 1; } +int test_S32_24_240(int x) { return ((int)__builtin_bswap32(x) >> 24) & 240; } +int test_S32_24_255(int x) { return ((int)__builtin_bswap32(x) >> 24) & 255; } +int test_S32_31_1(int x) { return ((int)__builtin_bswap32(x) >> 31) & 1; } + +unsigned int test_u32_24_255(unsigned int x) { + return (__builtin_bswap32(x) >> 24) & 255; +} + +long long test_s64_0_1(long long x) { + return __builtin_bswap64(x) & 1; +} +long long test_s64_0_2(long long x) { + return __builtin_bswap64(x) & 2; +} +long long test_s64_0_240(long long x) { + return __builtin_bswap64(x) & 240; +} +long long test_s64_0_255(long long x) { + return __builtin_bswap64(x) & 255; +} +long long test_s64_7_1(long long x) { + return (__builtin_bswap64(x) >> 7) & 1; +} +long long test_s64_8_1(long long x) { + return (__builtin_bswap64(x) >> 8) & 1; +} +long long test_s64_8_240(long long x) { + return (__builtin_bswap64(x) >> 56) & 240; +} +long long test_s64_8_255(long long x) { + return (__builtin_bswap64(x) >> 8) & 255; +} +long long test_s64_9_1(long long x) { + return (__builtin_bswap64(x) >> 9) & 1; +} +long long test_s64_31_1(long long x) { + return (__builtin_bswap64(x) >> 31) & 1; +} +long long test_s64_32_1(long long x) { + return (__builtin_bswap64(x) >> 32) & 1; +} +long long test_s64_32_240(long long x) { + return (__builtin_bswap64(x) >> 32) & 240; +} +long long test_s64_32_255(long long x) { + return (__builtin_bswap64(x) >> 32) & 255; +} +long long test_s64_33_1(long long x) { + return (__builtin_bswap64(x) >> 33) & 1; +} +long long test_s64_48_1(long long x) { + return (__builtin_bswap64(x) >> 48) & 1; +} +long long test_s64_48_240(long long x) { + return (__builtin_bswap64(x) >> 48) & 240; +} +long long test_s64_48_255(long long x) { + return (__builtin_bswap64(x) >> 48) & 255; +} +long long test_s64_56_1(long long x) { + return (__builtin_bswap64(x) >> 56) & 1; +} +long long test_s64_56_240(long long x) { + return (__builtin_bswap64(x) >> 56) & 240; +} +long long test_s64_56_255(long long x) { + return (__builtin_bswap64(x) >> 56) & 255; +} +long long test_s64_57_1(long long x) { + return (__builtin_bswap64(x) >> 57) & 1; +} +long long test_s64_63_1(long long x) { + return (__builtin_bswap64(x) >> 63) & 1; +} + +long long test_S64_0_1(long long x) { + return (long long)__builtin_bswap64(x) & 1; +} +long long test_S64_0_2(long long x) { + return (long long)__builtin_bswap64(x) & 2; +} +long long test_S64_0_240(long long x) { + return (long long)__builtin_bswap64(x) & 240; +} +long long test_S64_0_255(long long x) { + return (long long)__builtin_bswap64(x) & 255; +} +long long test_S64_7_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 7) & 1; +} +long long test_S64_8_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 8) & 1; +} +long long test_S64_8_240(long long x) { + return ((long long)__builtin_bswap64(x) >> 56) & 240; +} +long long test_S64_8_255(long long x) { + return ((long long)__builtin_bswap64(x) >> 8) & 255; +} +long long test_S64_9_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 9) & 1; +} +long long test_S64_31_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 31) & 1; +} +long long test_S64_32_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 32) & 1; +} +long long test_S64_32_240(long long x) { + return ((long long)__builtin_bswap64(x) >> 32) & 240; +} +long long test_S64_32_255(long long x) { + return ((long long)__builtin_bswap64(x) >> 32) & 255; +} +long long test_S64_33_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 33) & 1; +} +long long test_S64_48_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 48) & 1; +} +long long test_S64_48_240(long long x) { + return ((long long)__builtin_bswap64(x) >> 48) & 240; +} +long long test_S64_48_255(long long x) { + return ((long long)__builtin_bswap64(x) >> 48) & 255; +} +long long test_S64_56_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 56) & 1; +} +long long test_S64_56_240(long long x) { + return ((long long)__builtin_bswap64(x) >> 56) & 240; +} +long long test_S64_56_255(long long x) { + return ((long long)__builtin_bswap64(x) >> 56) & 255; +} +long long test_S64_57_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 57) & 1; +} +long long test_S64_63_1(long long x) { + return ((long long)__builtin_bswap64(x) >> 63) & 1; +} + +unsigned long long test_u64_56_255(unsigned long long x) { + return (__builtin_bswap64(x) >> 56) & 255; +} + +short test_s16_0_1(short x) { + return __builtin_bswap16(x) & 1; +} +short test_s16_0_240(short x) { + return __builtin_bswap16(x) & 240; +} +short test_s16_0_255(short x) { + return __builtin_bswap16(x) & 255; +} +short test_s16_1_1(short x) { + return (__builtin_bswap16(x) >> 1) & 1; +} +short test_s16_7_1(short x) { + return (__builtin_bswap16(x) >> 7) & 1; +} +short test_s16_8_1(short x) { + return (__builtin_bswap16(x) >> 8) & 1; +} +short test_s16_8_240(short x) { + return (__builtin_bswap16(x) >> 8) & 240; +} +short test_s16_8_255(short x) { + return (__builtin_bswap16(x) >> 8) & 255; +} +short test_s16_9_1(short x) { + return (__builtin_bswap16(x) >> 9) & 1; +} +short test_s16_15_1(short x) { + return (__builtin_bswap16(x) >> 15) & 1; +} + +short test_S16_0_1(short x) { + return (short)__builtin_bswap16(x) & 1; +} +short test_S16_0_240(short x) { + return (short)__builtin_bswap16(x) & 240; +} +short test_S16_0_255(short x) { + return (short)__builtin_bswap16(x) & 255; +} +short test_S16_1_1(short x) { + return ((short)__builtin_bswap16(x) >> 1) & 1; +} +short test_S16_7_1(short x) { + return ((short)__builtin_bswap16(x) >> 7) & 1; +} +short test_S16_8_1(short x) { + return ((short)__builtin_bswap16(x) >> 8) & 1; +} +short test_S16_8_240(short x) { + return ((short)__builtin_bswap16(x) >> 8) & 240; +} +short test_S16_8_255(short x) { + return ((short)__builtin_bswap16(x) >> 8) & 255; +} +short test_S16_9_1(short x) { + return ((short)__builtin_bswap16(x) >> 9) & 1; +} +short test_S16_15_1(short x) { + return ((short)__builtin_bswap16(x) >> 15) & 1; +} + +unsigned short test_u16_8_255(unsigned short x) { + return (__builtin_bswap16(x) >> 8) & 255; +} + + +/* Shifts only */ +int test_s32_24(int x) { + return __builtin_bswap32(x) >> 24; +} +int test_s32_25(int x) { + return __builtin_bswap32(x) >> 25; +} +int test_s32_30(int x) { + return __builtin_bswap32(x) >> 30; +} +int test_s32_31(int x) { + return __builtin_bswap32(x) >> 31; +} + +unsigned int test_u32_24(unsigned int x) { + return __builtin_bswap32(x) >> 24; +} +unsigned int test_u32_25(unsigned int x) { + return __builtin_bswap32(x) >> 25; +} +unsigned int test_u32_30(unsigned int x) { + return __builtin_bswap32(x) >> 30; +} +unsigned int test_u32_31(unsigned int x) { + return __builtin_bswap32(x) >> 31; +} + +long long test_s64_56(long long x) { + return __builtin_bswap64(x) >> 56; +} +long long test_s64_57(long long x) { + return __builtin_bswap64(x) >> 57; +} +long long test_s64_62(long long x) { + return __builtin_bswap64(x) >> 62; +} +long long test_s64_63(long long x) { + return __builtin_bswap64(x) >> 63; +} + +unsigned long long test_u64_56(unsigned long long x) { + return __builtin_bswap64(x) >> 56; +} +unsigned long long test_u64_57(unsigned long long x) { + return __builtin_bswap64(x) >> 57; +} +unsigned long long test_u64_62(unsigned long long x) { + return __builtin_bswap64(x) >> 62; +} +unsigned long long test_u64_63(unsigned long long x) { + return __builtin_bswap64(x) >> 63; +} + +short test_s16_8(short x) { + return __builtin_bswap16(x) >> 8; +} +short test_s16_9(short x) { + return __builtin_bswap16(x) >> 9; +} +short test_s16_14(short x) { + return __builtin_bswap16(x) >> 14; +} +short test_s16_15(short x) { + return __builtin_bswap16(x) >> 15; +} + +unsigned short test_u16_8(unsigned short x) { + return __builtin_bswap16(x) >> 8; +} +unsigned short test_u16_9(unsigned short x) { + return __builtin_bswap16(x) >> 9; +} +unsigned short test_u16_14(unsigned short x) { + return __builtin_bswap16(x) >> 14; +} +unsigned short test_u16_15(unsigned short x) { + return __builtin_bswap16(x) >> 15; +} + +/* { dg-final { scan-tree-dump-not "__builtin_bswap" "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-14.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-14.c new file mode 100644 index 0000000000..62711d8ef6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-14.c @@ -0,0 +1,302 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + + +__attribute__ ((noinline, noclone)) +static int rt32 (int x, int y, int z) { + return (__builtin_bswap32(x) >> y) & z; +} +#define TEST32(X,Y,Z) if(((__builtin_bswap32(X)>>Y)&Z)!=rt32(X,Y,Z)) abort() +void test32(int x) +{ + TEST32(x,0,1); + TEST32(x,0,255); + TEST32(x,1,1); + TEST32(x,2,1); + TEST32(x,3,1); + TEST32(x,4,1); + TEST32(x,5,1); + TEST32(x,6,1); + TEST32(x,7,1); + TEST32(x,8,1); + TEST32(x,8,255); + TEST32(x,9,1); + TEST32(x,10,1); + TEST32(x,11,1); + TEST32(x,12,1); + TEST32(x,13,1); + TEST32(x,14,1); + TEST32(x,15,1); + TEST32(x,16,1); + TEST32(x,16,255); + TEST32(x,17,1); + TEST32(x,18,1); + TEST32(x,19,1); + TEST32(x,20,1); + TEST32(x,21,1); + TEST32(x,22,1); + TEST32(x,23,1); + TEST32(x,24,1); + TEST32(x,24,255); + TEST32(x,25,1); + TEST32(x,26,1); + TEST32(x,27,1); + TEST32(x,28,1); + TEST32(x,29,1); + TEST32(x,30,1); + TEST32(x,31,1); +} + +#if __SIZEOF_LONG_LONG__ == 8 +__attribute__ ((noinline, noclone)) +static long long rt64 (long long x, int y, long long z) { + return (__builtin_bswap64(x) >> y) & z; +} +#define TEST64(X,Y,Z) if(((__builtin_bswap64(X)>>Y)&Z)!=rt64(X,Y,Z)) abort() +void test64(long long x) +{ + TEST64(x,0,1); + TEST64(x,0,255); + TEST64(x,1,1); + TEST64(x,2,1); + TEST64(x,3,1); + TEST64(x,4,1); + TEST64(x,5,1); + TEST64(x,6,1); + TEST64(x,7,1); + TEST64(x,8,1); + TEST64(x,8,255); + TEST64(x,9,1); + TEST64(x,10,1); + TEST64(x,11,1); + TEST64(x,12,1); + TEST64(x,13,1); + TEST64(x,14,1); + TEST64(x,15,1); + TEST64(x,16,1); + TEST64(x,16,255); + TEST64(x,17,1); + TEST64(x,18,1); + TEST64(x,19,1); + TEST64(x,20,1); + TEST64(x,21,1); + TEST64(x,22,1); + TEST64(x,23,1); + TEST64(x,24,1); + TEST64(x,24,255); + TEST64(x,25,1); + TEST64(x,26,1); + TEST64(x,27,1); + TEST64(x,28,1); + TEST64(x,29,1); + TEST64(x,30,1); + TEST64(x,31,1); + TEST64(x,32,1); + TEST64(x,32,255); + TEST64(x,33,1); + TEST64(x,34,1); + TEST64(x,35,1); + TEST64(x,36,1); + TEST64(x,37,1); + TEST64(x,38,1); + TEST64(x,39,1); + TEST64(x,40,1); + TEST64(x,40,255); + TEST64(x,41,1); + TEST64(x,42,1); + TEST64(x,43,1); + TEST64(x,44,1); + TEST64(x,45,1); + TEST64(x,46,1); + TEST64(x,47,1); + TEST64(x,48,1); + TEST64(x,48,255); + TEST64(x,49,1); + TEST64(x,50,1); + TEST64(x,51,1); + TEST64(x,52,1); + TEST64(x,53,1); + TEST64(x,54,1); + TEST64(x,55,1); + TEST64(x,56,1); + TEST64(x,56,255); + TEST64(x,57,1); + TEST64(x,58,1); + TEST64(x,59,1); + TEST64(x,60,1); + TEST64(x,61,1); + TEST64(x,62,1); + TEST64(x,63,1); +} +#endif + +__attribute__ ((noinline, noclone)) +static int rt16 (int x, int y, int z) { + return (__builtin_bswap16(x) >> y) & z; +} +#define TEST16(X,Y,Z) if(((__builtin_bswap16(X)>>Y)&Z)!=rt16(X,Y,Z)) abort() +void test16(int x) +{ + TEST16(x,0,1); + TEST16(x,0,255); + TEST16(x,1,1); + TEST16(x,2,1); + TEST16(x,3,1); + TEST16(x,4,1); + TEST16(x,5,1); + TEST16(x,6,1); + TEST16(x,7,1); + TEST16(x,8,1); + TEST16(x,8,255); + TEST16(x,9,1); + TEST16(x,10,1); + TEST16(x,11,1); + TEST16(x,12,1); + TEST16(x,13,1); + TEST16(x,14,1); + TEST16(x,15,1); +} + +int main() +{ + test32(0x00000000); + test32(0xffffffff); + test32(0x00000001); + test32(0x00000002); + test32(0x00000004); + test32(0x00000008); + test32(0x00000010); + test32(0x00000020); + test32(0x00000040); + test32(0x00000080); + test32(0x00000100); + test32(0x00000200); + test32(0x00000400); + test32(0x00000800); + test32(0x00001000); + test32(0x00002000); + test32(0x00004000); + test32(0x00008000); + test32(0x00010000); + test32(0x00020000); + test32(0x00040000); + test32(0x00080000); + test32(0x00100000); + test32(0x00200000); + test32(0x00400000); + test32(0x00800000); + test32(0x01000000); + test32(0x02000000); + test32(0x04000000); + test32(0x08000000); + test32(0x10000000); + test32(0x20000000); + test32(0x40000000); + test32(0x80000000); + test32(0x12345678); + test32(0x87654321); + test32(0xdeadbeef); + test32(0xcafebabe); + +#if __SIZEOF_LONG_LONG__ == 8 + test64(0x0000000000000000ll); + test64(0xffffffffffffffffll); + test64(0x0000000000000001ll); + test64(0x0000000000000002ll); + test64(0x0000000000000004ll); + test64(0x0000000000000008ll); + test64(0x0000000000000010ll); + test64(0x0000000000000020ll); + test64(0x0000000000000040ll); + test64(0x0000000000000080ll); + test64(0x0000000000000100ll); + test64(0x0000000000000200ll); + test64(0x0000000000000400ll); + test64(0x0000000000000800ll); + test64(0x0000000000001000ll); + test64(0x0000000000002000ll); + test64(0x0000000000004000ll); + test64(0x0000000000008000ll); + test64(0x0000000000010000ll); + test64(0x0000000000020000ll); + test64(0x0000000000040000ll); + test64(0x0000000000080000ll); + test64(0x0000000000100000ll); + test64(0x0000000000200000ll); + test64(0x0000000000400000ll); + test64(0x0000000000800000ll); + test64(0x0000000001000000ll); + test64(0x0000000002000000ll); + test64(0x0000000004000000ll); + test64(0x0000000008000000ll); + test64(0x0000000010000000ll); + test64(0x0000000020000000ll); + test64(0x0000000040000000ll); + test64(0x0000000080000000ll); + test64(0x0000000100000000ll); + test64(0x0000000200000000ll); + test64(0x0000000400000000ll); + test64(0x0000000800000000ll); + test64(0x0000001000000000ll); + test64(0x0000002000000000ll); + test64(0x0000004000000000ll); + test64(0x0000008000000000ll); + test64(0x0000010000000000ll); + test64(0x0000020000000000ll); + test64(0x0000040000000000ll); + test64(0x0000080000000000ll); + test64(0x0000100000000000ll); + test64(0x0000200000000000ll); + test64(0x0000400000000000ll); + test64(0x0000800000000000ll); + test64(0x0001000000000000ll); + test64(0x0002000000000000ll); + test64(0x0004000000000000ll); + test64(0x0008000000000000ll); + test64(0x0010000000000000ll); + test64(0x0020000000000000ll); + test64(0x0040000000000000ll); + test64(0x0080000000000000ll); + test64(0x0100000000000000ll); + test64(0x0200000000000000ll); + test64(0x0400000000000000ll); + test64(0x0800000000000000ll); + test64(0x1000000000000000ll); + test64(0x2000000000000000ll); + test64(0x4000000000000000ll); + test64(0x8000000000000000ll); + test64(0x0123456789abcdefll); + test64(0xfedcba9876543210ll); + test64(0xdeadbeefdeadbeefll); + test64(0xcafebabecafebabell); +#endif + + test16(0x0000); + test16(0xffff); + test16(0x0001); + test16(0x0002); + test16(0x0004); + test16(0x0008); + test16(0x0010); + test16(0x0020); + test16(0x0040); + test16(0x0080); + test16(0x0100); + test16(0x0200); + test16(0x0400); + test16(0x0800); + test16(0x1000); + test16(0x2000); + test16(0x4000); + test16(0x8000); + test16(0x1234); + test16(0x4321); + test16(0xdead); + test16(0xbeef); + test16(0xcafe); + test16(0xbabe); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-2.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-2.c new file mode 100644 index 0000000000..745fed9d16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "" } */ +#include + +extern void abort (void); + +int main (void) +{ + uint32_t a = 4; + uint32_t b; + + b = __builtin_bswap32 (a); + a = __builtin_bswap32 (b); + + if (b == 4 || a != 4) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-3.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-3.c new file mode 100644 index 0000000000..031817e780 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-3.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "" } */ +#include + +extern void abort (void); + +int main (void) +{ + uint32_t a = 0x80000000; + uint32_t b; + + b = __builtin_bswap32 (a); + a = __builtin_bswap32 (b); + + if (b != 0x80 || a != 0x80000000) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-4.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-4.c new file mode 100644 index 0000000000..da8ee68cd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-4.c @@ -0,0 +1,75 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-Wall" } */ + +#include + +#define MAKE_FUN(suffix, type) \ + type my_bswap##suffix(type x) { \ + type result = 0; \ + int shift; \ + for (shift = 0; shift < 8 * sizeof (type); shift += 8) \ + { \ + result <<= 8; \ + result |= (x >> shift) & 0xff; \ + } \ + return result; \ + } \ + +MAKE_FUN(16, uint16_t); +MAKE_FUN(32, uint32_t); +MAKE_FUN(64, uint64_t); + +extern void abort (void); + +#define NUMS16 \ + { \ + 0x0000, \ + 0x1122, \ + 0xffff, \ + } + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x11223344UL, \ + 0xffffffffUL, \ + } + +#define NUMS64 \ + { \ + 0x0000000000000000ULL, \ + 0x1122334455667788ULL, \ + 0xffffffffffffffffULL, \ + } + +uint16_t uint16_ts[] = + NUMS16; + +uint32_t uint32_ts[] = + NUMS32; + +uint64_t uint64_ts[] = + NUMS64; + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + for (i = 0; i < N(uint16_ts); i++) + if (__builtin_bswap16 (uint16_ts[i]) != my_bswap16 (uint16_ts[i])) + abort (); + + for (i = 0; i < N(uint32_ts); i++) + if (__builtin_bswap32 (uint32_ts[i]) != my_bswap32 (uint32_ts[i])) + abort (); + + for (i = 0; i < N(uint64_ts); i++) + if (__builtin_bswap64 (uint64_ts[i]) != my_bswap64 (uint64_ts[i])) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-5.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-5.c new file mode 100644 index 0000000000..b29931e4e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-5.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ +int +main (void) +{ + /* Test constant folding. */ + extern void link_error (void); + + if (__builtin_bswap16(0xaabb) != 0xbbaa) + link_error (); + + if (__builtin_bswap32(0xaabbccdd) != 0xddccbbaa) + link_error (); + + if (__builtin_bswap64(0x1122334455667788ULL) != 0x8877665544332211ULL) + link_error (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-6.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-6.c new file mode 100644 index 0000000000..152b7a6b9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-6.c @@ -0,0 +1,41 @@ +/* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* rs6000-*-* x86_64-*-* s390*-*-* } } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O -fdump-rtl-combine" } */ + +/* The branch cost setting prevents the return value from being + calculated with arithmetic instead of doing a compare. */ +/* { dg-additional-options "-march=z900 -mbranch-cost=0" { target s390*-*-* } } */ + +#include + +#define BS(X) __builtin_bswap32(X) + +int foo1 (uint32_t a) +{ + if (BS (a) == 0xA0000) + return 1; + return 0; +} + +int foo2 (uint32_t a) +{ + if (BS (a) != 0xA0000) + return 1; + return 0; +} + +int foo3 (uint32_t a, uint32_t b) +{ + if (BS (a) == BS (b)) + return 1; + return 0; +} + +int foo4 (uint32_t a, uint32_t b) +{ + if (BS (a) != BS (b)) + return 1; + return 0; +} + +/* { dg-final { scan-rtl-dump-not "bswapsi" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-6a.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-6a.c new file mode 100644 index 0000000000..90dfd7d624 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-6a.c @@ -0,0 +1,43 @@ +/* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* rs6000-*-* x86_64-*-* s390*-*-* } } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-rtl-combine" } */ +/* { dg-additional-options "-march=z900" { target s390*-*-* } } */ + +/* The test is similiar to builtin-bswap-6.c but returns 1/2 instead + of 0/1 to prevent GCC from calculating the return value with + arithmetic instead of a comparison. This requires the optimization + level to be bumped up to -O2 at least for x86_64. */ + +#include + +#define BS(X) __builtin_bswap32(X) + +int foo1 (uint32_t a) +{ + if (BS (a) == 0xA0000) + return 1; + return 2; +} + +int foo2 (uint32_t a) +{ + if (BS (a) != 0xA0000) + return 1; + return 2; +} + +int foo3 (uint32_t a, uint32_t b) +{ + if (BS (a) == BS (b)) + return 1; + return 2; +} + +int foo4 (uint32_t a, uint32_t b) +{ + if (BS (a) != BS (b)) + return 1; + return 2; +} + +/* { dg-final { scan-rtl-dump-not "bswapsi" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-7.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-7.c new file mode 100644 index 0000000000..35bcee3784 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-7.c @@ -0,0 +1,42 @@ +/* { dg-do compile { target arm*-*-* alpha*-*-* ia64*-*-* i?86-*-* x86_64-*-* s390x-*-* powerpc*-*-* rs6000-*-* } } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O -fdump-rtl-combine" } */ + +/* The param setting prevents the return value from being + calculated with arithmetic instead of doing a compare. */ +/* { dg-additional-options "--param logical-op-non-short-circuit=0" } */ + +#include + +#define BS(X) __builtin_bswap64(X) + +int foo1 (uint64_t a) +{ + if (BS (a) == 0xA00000000) + return 1; + return 0; +} + +int foo2 (uint64_t a) +{ + if (BS (a) != 0xA00000000) + return 1; + return 0; +} + +int foo3 (uint64_t a, uint64_t b) +{ + if (BS (a) == BS (b)) + return 1; + return 0; +} + +int foo4 (uint64_t a, uint64_t b) +{ + if (BS (a) != BS (b)) + return 1; + return 0; +} + +/* { dg-final { scan-rtl-dump-not "bswapdi" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-7a.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-7a.c new file mode 100644 index 0000000000..92b48cc416 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-7a.c @@ -0,0 +1,43 @@ +/* { dg-do compile { target arm*-*-* alpha*-*-* ia64*-*-* i?86-*-* x86_64-*-* s390x-*-* powerpc*-*-* rs6000-*-* } } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fdump-rtl-combine" } */ + +/* The test is similiar to builtin-bswap-7.c but returns 1/2 instead + of 0/1 to prevent GCC from calculating the return value with + arithmetic instead of a comparison. This requires the optimization + level to be bumped up to -O2 at least for x86_64. */ + +#include + +#define BS(X) __builtin_bswap64(X) + +int foo1 (uint64_t a) +{ + if (BS (a) == 0xA00000000) + return 1; + return 2; +} + +int foo2 (uint64_t a) +{ + if (BS (a) != 0xA00000000) + return 1; + return 2; +} + +int foo3 (uint64_t a, uint64_t b) +{ + if (BS (a) == BS (b)) + return 1; + return 2; +} + +int foo4 (uint64_t a, uint64_t b) +{ + if (BS (a) != BS (b)) + return 1; + return 2; +} + +/* { dg-final { scan-rtl-dump-not "bswapdi" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-8.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-8.c new file mode 100644 index 0000000000..3dbde6ba0a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-8.c @@ -0,0 +1,45 @@ +/* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* rs6000-*-* x86_64-*-* s390*-*-* } } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-rtl-combine" } */ +/* { dg-options "-O2 -fdump-rtl-combine -march=z900" { target s390-*-* } } */ + +#include + +#define BS(X) __builtin_bswap32(X) + +uint32_t foo1 (uint32_t a) +{ + return BS (~ BS (a)); +} + +uint32_t foo2 (uint32_t a) +{ + return BS (BS (a) & 0xA0000); +} + +uint32_t foo3 (uint32_t a) +{ + return BS (BS (a) | 0xA0000); +} + +uint32_t foo4 (uint32_t a) +{ + return BS (BS (a) ^ 0xA0000); +} + +uint32_t foo5 (uint32_t a, uint32_t b) +{ + return BS (BS (a) & BS (b)); +} + +uint32_t foo6 (uint32_t a, uint32_t b) +{ + return BS (BS (a) | BS (b)); +} + +uint32_t foo7 (uint32_t a, uint32_t b) +{ + return BS (BS (a) ^ BS (b)); +} + +/* { dg-final { scan-rtl-dump-not "bswapsi" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-bswap-9.c b/SingleSource/Regression/C/gcc-dg/builtin-bswap-9.c new file mode 100644 index 0000000000..4cf28e94fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-bswap-9.c @@ -0,0 +1,45 @@ +/* { dg-do compile { target arm*-*-* alpha*-*-* ia64*-*-* i?86-*-* x86_64-*-* s390x-*-* powerpc*-*-* rs6000-*-* } } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fdump-rtl-combine" } */ + +#include + +#define BS(X) __builtin_bswap64(X) + +uint64_t foo1 (uint64_t a) +{ + return BS (~ BS (a)); +} + +uint64_t foo2 (uint64_t a) +{ + return BS (BS (a) & 0xA00000000); +} + +uint64_t foo3 (uint64_t a) +{ + return BS (BS (a) | 0xA00000000); +} + +uint64_t foo4 (uint64_t a) +{ + return BS (BS (a) ^ 0xA00000000); +} + +uint64_t foo5 (uint64_t a, uint64_t b) +{ + return BS (BS (a) & BS (b)); +} + +uint64_t foo6 (uint64_t a, uint64_t b) +{ + return BS (BS (a) | BS (b)); +} + +uint64_t foo7 (uint64_t a, uint64_t b) +{ + return BS (BS (a) ^ BS (b)); +} + +/* { dg-final { scan-rtl-dump-not "bswapdi" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-choose-expr-2.c b/SingleSource/Regression/C/gcc-dg/builtin-choose-expr-2.c new file mode 100644 index 0000000000..d986b405ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-choose-expr-2.c @@ -0,0 +1,12 @@ +/* Test diagnostic for invalid use of __builtin_choose_expr. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int a, b, c, d; + +void +f (void) +{ + a = __builtin_choose_expr (b, c, d); /* { dg-error "first argument to '__builtin_choose_expr' not a constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-choose-expr.c b/SingleSource/Regression/C/gcc-dg/builtin-choose-expr.c new file mode 100644 index 0000000000..ceac6051f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-choose-expr.c @@ -0,0 +1,90 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -Wall" } */ + +#define choose __builtin_choose_expr + +/* Check the type of __builtin_choose_expr between E1 and E2, both + ways round and with both 0 and 1 as the condition. */ +#define ASSERT_COND_TYPE(E1, E2) \ + do { \ + typedef __typeof(E1) T1; \ + typedef __typeof(E2) T2; \ + typedef T1 **T1pp; \ + typedef T2 **T2pp; \ + typedef __typeof(choose (1, (E1), (E2))) T1a; \ + typedef __typeof(choose (0, (E2), (E1))) T1b; \ + typedef __typeof(choose (1, (E2), (E1))) T2a; \ + typedef __typeof(choose (0, (E1), (E2))) T2b; \ + typedef T1a **T1app; \ + typedef T1b **T1bpp; \ + typedef T2a **T2app; \ + typedef T2b **T2bpp; \ + T1pp t1 = 0; \ + T2pp t2 = 0; \ + T1app t1a = 0; \ + T1bpp t1b = 0; \ + T2app t2a = 0; \ + T2bpp t2b = 0; \ + t1 = t1a; \ + t1 = t1b; \ + t2 = t2a; \ + t2 = t2b; \ + (void) t1; \ + (void) t2; \ + } while (0) + + +extern void abort (); +extern void exit (); + +void bad () +{ + abort (); +} + +void good () +{ + exit (0); +} + +int main (void) +{ + signed char sc1, sc2; + void *v1; + int i, j; + double dd; + float f; + typedef void (*fpt)(void); + fpt triple; + struct S { int x, y; } pour, some, sugar; + union u { int p; } united, nations; + + if (__builtin_choose_expr (0, 12, 0) + || !__builtin_choose_expr (45, 5, 0) + || !__builtin_choose_expr (45, 3, 0)) + abort (); + + ASSERT_COND_TYPE (sc1, sc2); + ASSERT_COND_TYPE (v1, sc1); + ASSERT_COND_TYPE (i, j); + ASSERT_COND_TYPE (dd, main); + ASSERT_COND_TYPE ((float)dd, i); + ASSERT_COND_TYPE (4, f); + ASSERT_COND_TYPE (triple, some); + ASSERT_COND_TYPE (united, nations); + ASSERT_COND_TYPE (nations, main); + + pour.y = 69; + __builtin_choose_expr (0, bad (), sugar) = pour; + if (sugar.y != 69) + abort (); + + __builtin_choose_expr (sizeof (int), f, bad ()) = 3.5F; + + if (f != 3.5F) + abort (); + + __builtin_choose_expr (1, good, bad)(); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-clear-padding-1.c b/SingleSource/Regression/C/gcc-dg/builtin-clear-padding-1.c new file mode 100644 index 0000000000..27ffc0a57c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-clear-padding-1.c @@ -0,0 +1,10 @@ +/* PR libstdc++/88101 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo (int n) +{ + struct S { char a; int b[n]; long long c; } s; + __builtin_clear_padding (&s); /* { dg-message "unimplemented: __builtin_clear_padding not supported for variable length aggregates" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-clear-padding-2.c b/SingleSource/Regression/C/gcc-dg/builtin-clear-padding-2.c new file mode 100644 index 0000000000..641d47d70f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-clear-padding-2.c @@ -0,0 +1,15 @@ +/* PR middle-end/97943 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S { int a; char b[] __attribute__((aligned (2 * sizeof (int)))); }; +struct T { int a; struct S b; int c; }; +union U { int a; struct S b; }; +struct V { int a; union U b; int : 15; int c; }; + +void +foo (struct T *t, struct V *v) +{ + __builtin_clear_padding (t); /* { dg-error "flexible array member 'b' does not have well defined padding bits for '__builtin_clear_padding'" } */ + __builtin_clear_padding (v); /* { dg-error "flexible array member 'b' does not have well defined padding bits for '__builtin_clear_padding'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-complex-err-1.c b/SingleSource/Regression/C/gcc-dg/builtin-complex-err-1.c new file mode 100644 index 0000000000..ddc72b583c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-complex-err-1.c @@ -0,0 +1,26 @@ +/* Test __builtin_complex errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +typedef double D; + +double d; + +_Complex double dc = __builtin_complex (1.0, (D) 0.0); + +_Complex double dc2 = __builtin_complex (d, 0.0); /* { dg-error "not constant" } */ + +_Complex float fc = __builtin_complex (1.0f, 1); /* { dg-error "not of real binary floating-point type" } */ + +_Complex float fc2 = __builtin_complex (1, 1.0f); /* { dg-error "not of real binary floating-point type" } */ + +_Complex float fc3 = __builtin_complex (1.0f, 1.0); /* { dg-error "different types" } */ + +void +f (void) +{ + __builtin_complex (0.0); /* { dg-error "wrong number of arguments" } */ + __builtin_complex (0.0, 0.0, 0.0); /* { dg-error "wrong number of arguments" } */ +} + +void (*p) (void) = __builtin_complex; /* { dg-error "cannot take address" } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-complex-err-2.c b/SingleSource/Regression/C/gcc-dg/builtin-complex-err-2.c new file mode 100644 index 0000000000..be5ff65fda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-complex-err-2.c @@ -0,0 +1,10 @@ +/* Test __builtin_complex errors. Verify it does not allow quiet + creation of complex types in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=c90 -pedantic-errors" } */ + +void +f (void) +{ + __builtin_complex (0.0, 0.0); /* { dg-error "ISO C90 does not support complex types" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-constant_p-1.c b/SingleSource/Regression/C/gcc-dg/builtin-constant_p-1.c new file mode 100644 index 0000000000..f177fe34b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-constant_p-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +int main() +{ + if (__builtin_constant_p ()) /* { dg-error "too few arguments" } */ + return 0; + if (__builtin_constant_p (5, 6)) /* { dg-error "too many arguments" } */ + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-alloc-size.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-alloc-size.c new file mode 100644 index 0000000000..9d0eadd6be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-alloc-size.c @@ -0,0 +1,7 @@ +/* { dg-do compile } + { dg-require-effective-target alloca } + { dg-additional-options "-O2 -fdump-tree-optimized" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-alloc-size.c" +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-0.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-0.c new file mode 100644 index 0000000000..6da04202ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-0.c @@ -0,0 +1,789 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +typedef __SIZE_TYPE__ size_t; +#define abort __builtin_abort + +void * +__attribute__ ((alloc_size (1))) +__attribute__ ((__nothrow__ , __leaf__)) +__attribute__ ((noinline)) +alloc_func_long (long sz) +{ + return __builtin_malloc (sz); +} + +void * +__attribute__ ((alloc_size (1))) +__attribute__ ((__nothrow__ , __leaf__)) +__attribute__ ((noinline)) +alloc_func (size_t sz) +{ + return __builtin_malloc (sz); +} + +void * +__attribute__ ((alloc_size (1, 2))) +__attribute__ ((__nothrow__ , __leaf__)) +__attribute__ ((noinline)) +calloc_func (size_t cnt, size_t sz) +{ + return __builtin_calloc (cnt, sz); +} + +void * +__attribute__ ((noinline)) +unknown_allocator (size_t cnt, size_t sz) +{ + return __builtin_calloc (cnt, sz); +} + +size_t +__attribute__ ((noinline)) +test_unknown (size_t cnt, size_t sz) +{ + void *ch = unknown_allocator (cnt, sz); + size_t ret = __builtin_dynamic_object_size (ch, 0); + __builtin_free (ch); + return ret; +} + +/* Malloc-like allocator. */ + +size_t +__attribute__ ((noinline)) +test_malloc (size_t sz) +{ + void *ch = alloc_func (sz); + size_t ret = __builtin_dynamic_object_size (ch, 0); + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_malloc (size_t sz) +{ + void *ch = __builtin_malloc (sz); + size_t ret = __builtin_dynamic_object_size (ch, 0); + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_malloc_cond (int cond) +{ + void *ch = __builtin_malloc (cond ? 32 : 64); + size_t ret = __builtin_dynamic_object_size (ch, 0); + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_malloc_condphi (int cond) +{ + void *ch; + + if (cond) + ch = __builtin_malloc (32); + else + ch = __builtin_malloc (64); + + size_t ret = __builtin_dynamic_object_size (ch, 0); + + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_malloc_condphi2 (int cond, size_t in) +{ + void *ch; + + if (cond) + ch = __builtin_malloc (in); + else + ch = __builtin_malloc (64); + + size_t ret = __builtin_dynamic_object_size (ch, 0); + + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_malloc_condphi3 (int cond, size_t in, size_t in2) +{ + void *ch; + + if (cond) + ch = __builtin_malloc (in); + else + ch = __builtin_malloc (in2); + + size_t ret = __builtin_dynamic_object_size (ch, 0); + + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_malloc_condphi4 (size_t sz, int cond) +{ + char *a = __builtin_malloc (sz); + char b[sz / 2]; + + size_t ret = __builtin_dynamic_object_size (cond ? b : (void *) &a, 0); + __builtin_free (a); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_malloc_condphi5 (size_t sz, int cond, char *c) +{ + char *a = __builtin_malloc (sz); + + size_t ret = __builtin_dynamic_object_size (cond ? c : (void *) &a, 0); + __builtin_free (a); + return ret; +} + +long +__attribute__ ((noinline)) +test_builtin_malloc_long (long sz, long off) +{ + char *a = alloc_func_long (sz); + char *dest = a + off; + long ret = __builtin_dynamic_object_size (dest, 0); + return ret; +} + +/* Calloc-like allocator. */ + +size_t +__attribute__ ((noinline)) +test_calloc (size_t cnt, size_t sz) +{ + void *ch = calloc_func (cnt, sz); + size_t ret = __builtin_dynamic_object_size (ch, 0); + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_calloc (size_t cnt, size_t sz) +{ + void *ch = __builtin_calloc (cnt, sz); + size_t ret = __builtin_dynamic_object_size (ch, 0); + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_calloc_cond (int cond1, int cond2) +{ + void *ch = __builtin_calloc (cond1 ? 32 : 64, cond2 ? 1024 : 16); + size_t ret = __builtin_dynamic_object_size (ch, 0); + __builtin_free (ch); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_builtin_calloc_condphi (size_t cnt, size_t sz, int cond) +{ + struct + { + int a; + char b; + } bin[cnt]; + + char *ch = __builtin_calloc (cnt, sz); + size_t ret = __builtin_dynamic_object_size (cond ? ch : (void *) &bin, 0); + + __builtin_free (ch); + return ret; +} + +/* Passthrough functions. */ + +size_t +__attribute__ ((noinline)) +test_passthrough (size_t sz, char *in) +{ + char *bin = __builtin_malloc (sz); + char *dest = __builtin_memcpy (bin, in, sz); + + size_t ret = __builtin_dynamic_object_size (dest, 0); + __builtin_free (bin); + return ret; +} + +size_t +__attribute__ ((noinline)) +test_passthrough_nonssa (char *in) +{ + char bin[__builtin_strlen (in) + 1]; + char *dest = __builtin_memcpy (bin, in, __builtin_strlen (in) + 1); + + return __builtin_dynamic_object_size (dest, 0); +} + +/* Variable length arrays. */ +size_t +__attribute__ ((noinline)) +test_dynarray (size_t sz) +{ + char bin[sz]; + + return __builtin_dynamic_object_size (bin, 0); +} + +size_t +__attribute__ ((noinline)) +test_dynarray_cond (int cond) +{ + char bin[cond ? 8 : 16]; + + return __builtin_dynamic_object_size (bin, 0); +} + +size_t +__attribute__ ((noinline)) +test_deploop (size_t sz, size_t cond) +{ + char *bin = __builtin_alloca (32); + + for (size_t i = 0; i < sz; i++) + if (i == cond) + bin = __builtin_alloca (sz); + + return __builtin_dynamic_object_size (bin, 0); +} + +/* Address expressions. */ + +struct dynarray_struct +{ + long a; + char c[16]; + int b; +}; + +size_t +__attribute__ ((noinline)) +test_dynarray_struct (size_t sz, size_t off) +{ + struct dynarray_struct bin[sz]; + + return __builtin_dynamic_object_size (&bin[off].c, 0); +} + +size_t +__attribute__ ((noinline)) +test_dynarray_struct_subobj (size_t sz, size_t off) +{ + struct dynarray_struct bin[sz]; + + return __builtin_dynamic_object_size (&bin[off].c[4], 1); +} + +size_t +__attribute__ ((noinline)) +test_dynarray_struct_subobj2 (size_t sz, size_t off, size_t *objsz) +{ + struct dynarray_struct2 + { + long a; + int b; + char c[sz]; + }; + + struct dynarray_struct2 bin; + + *objsz = sizeof (bin); + + return __builtin_dynamic_object_size (&bin.c[off], 1); +} + +/* See pr #108522. */ + +#define DEFSTRUCT(_s, _n) \ + struct DS \ + { \ + char a[_n]; \ + unsigned long long b; \ + int c; \ + char d[2 * _n]; \ + } _s + +size_t +__attribute__ ((noinline)) +test_dynarray_struct_member_b (size_t sz) +{ + DEFSTRUCT (s, sz); + + return __builtin_dynamic_object_size (&s.b, 0); +} + +size_t +__attribute__ ((noinline)) +test_dynarray_struct_member_c (size_t sz) +{ + DEFSTRUCT (s, sz); + + return __builtin_dynamic_object_size (&s.c, 0); +} + +size_t +__attribute__ ((noinline)) +test_dynarray_struct_member_d (size_t sz, size_t offset) +{ + DEFSTRUCT (s, sz); + + return __builtin_dynamic_object_size (&s.d[offset], 0); +} + +size_t +__attribute__ ((noinline)) +test_dynarray_struct_member_subobj_b (size_t sz) +{ + DEFSTRUCT (s, sz); + + return __builtin_dynamic_object_size (&s.b, 1); +} + +size_t +__attribute__ ((noinline)) +test_dynarray_struct_member_subobj_c (size_t sz) +{ + DEFSTRUCT (s, sz); + + return __builtin_dynamic_object_size (&s.c, 1); +} + +size_t +__attribute__ ((noinline)) +test_dynarray_struct_member_subobj_d (size_t sz, size_t offset) +{ + DEFSTRUCT (s, sz); + + return __builtin_dynamic_object_size (&s.d[offset], 1); +} + +size_t +__attribute__ ((noinline)) +test_substring (size_t sz, size_t off) +{ + char str[sz]; + + return __builtin_dynamic_object_size (&str[off], 0); +} + +struct S2 +{ + char arr[7]; +}; + +struct S1 +{ + int pad; + struct S2 s2; +}; + +static long +g (struct S1 *s1) +{ + struct S2 *s2 = &s1->s2; + return __builtin_dynamic_object_size (s2->arr, 0); +} + +long +__attribute__ ((noinline)) +test_alloc_nested_structs (int x) +{ + struct S1 *s1 = __builtin_malloc (x); + return g (s1); +} + +/* POINTER_PLUS expressions. */ + +size_t +__attribute__ ((noinline)) +test_substring_ptrplus (size_t sz, size_t off) +{ + int str[sz]; + + return __builtin_dynamic_object_size (str + off, 0); +} + +size_t +__attribute__ ((noinline)) +test_substring_ptrplus2 (size_t sz, size_t off, size_t off2) +{ + int str[sz]; + int *ptr = &str[off]; + + return __builtin_dynamic_object_size (ptr + off2, 0); +} + +/* Function parameters. */ + +size_t +__attribute__ ((access (__read_write__, 1, 2))) +__attribute__ ((noinline)) +test_parmsz_simple (void *obj, size_t sz) +{ + return __builtin_dynamic_object_size (obj, 0); +} + +size_t +__attribute__ ((access (__read_write__, 2, 1))) +__attribute__ ((noinline)) +test_parmsz_simple2 (size_t sz, char obj[]) +{ + return __builtin_dynamic_object_size (obj, 0); +} + +/* Implicitly constructed access attributes not supported yet. */ +size_t +__attribute__ ((noinline)) +test_parmsz_simple3 (size_t sz, char obj[sz]) +{ + return __builtin_dynamic_object_size (obj, 0); +} + +size_t +__attribute__ ((noinline)) +__attribute__ ((access (__read_write__, 1, 2))) +test_parmsz (void *obj, size_t sz, size_t off) +{ + return __builtin_dynamic_object_size (obj + off, 0); +} + +size_t +__attribute__ ((access (__read_write__, 1, 2))) +__attribute__ ((noinline)) +test_parmsz_scaled (int *obj, size_t sz) +{ + return __builtin_dynamic_object_size (obj, 0); +} + +size_t +__attribute__ ((noinline)) +__attribute__ ((access (__read_write__, 1, 2))) +test_parmsz_scaled_off (int *obj, size_t sz, size_t off) +{ + return __builtin_dynamic_object_size (obj + off, 0); +} + +size_t +__attribute__ ((access (__read_write__, 1, 3))) +__attribute__ ((noinline)) +test_parmsz_unknown (void *obj, void *unknown, size_t sz, int cond) +{ + return __builtin_dynamic_object_size (cond ? obj : unknown, 0); +} + +struct S; +size_t +__attribute__ ((access (__read_write__, 1, 2))) +__attribute__ ((noinline)) +test_parmsz_extern (struct S *obj, size_t sz) +{ + return __builtin_dynamic_object_size (obj, 0); +} + +/* Implicitly constructed access attributes not supported yet. */ +size_t +__attribute__ ((noinline)) +test_parmsz_internal (size_t sz, double obj[][sz]) +{ + return __builtin_dynamic_object_size (obj, 0); +} + +size_t +__attribute__ ((access (__read_write__, 2, 1))) +__attribute__ ((noinline)) +test_parmsz_internal2 (size_t sz, double obj[][sz]) +{ + return __builtin_dynamic_object_size (obj, 0); +} + +size_t +__attribute__ ((noinline)) +test_parmsz_internal3 (size_t sz1, size_t sz2, double obj[sz1][sz2]) +{ + return __builtin_dynamic_object_size (obj, 0); +} + +/* Loops. */ + +size_t +__attribute__ ((noinline)) +__attribute__ ((access (__read_write__, 1, 2))) +test_loop (int *obj, size_t sz, size_t start, size_t end, int incr) +{ + int *ptr = obj + start; + + for (int i = start; i != end; i = i + incr) + { + ptr = ptr + incr; + if (__builtin_dynamic_object_size (ptr, 0) == 0) + return 0; + } + + return __builtin_dynamic_object_size (ptr, 0); +} + +/* strdup/strndup. */ + +size_t +__attribute__ ((noinline)) +test_strdup (const char *in) +{ + char *res = __builtin_strdup (in); + size_t sz = __builtin_dynamic_object_size (res, 0); + + __builtin_free (res); + return sz; +} + +size_t +__attribute__ ((noinline)) +test_strndup (const char *in, size_t bound) +{ + char *res = __builtin_strndup (in, bound); + size_t sz = __builtin_dynamic_object_size (res, 0); + + __builtin_free (res); + return sz; +} + +size_t +__attribute__ ((noinline)) +test_strdup_min (const char *in) +{ + char *res = __builtin_strdup (in); + size_t sz = __builtin_dynamic_object_size (res, 2); + + __builtin_free (res); + return sz; +} + +size_t +__attribute__ ((noinline)) +test_strndup_min (const char *in, size_t bound) +{ + char *res = __builtin_strndup (in, bound); + size_t sz = __builtin_dynamic_object_size (res, 2); + + __builtin_free (res); + return sz; +} + +/* Other tests. */ + +struct TV4 +{ + __attribute__((vector_size (sizeof (int) * 4))) int v; +}; + +struct TV4 val3; +int * +test_pr105736 (struct TV4 *a) +{ + return &a->v[0]; +} + +int +main (int argc, char **argv) +{ + size_t outsz = test_unknown (32, 42); + if (outsz != -1 && outsz != 32) + FAIL (); + if (test_malloc (2048) != 2048) + FAIL (); + if (test_builtin_malloc (2048) != 2048) + FAIL (); + if (test_builtin_malloc_cond (1) != 32) + FAIL (); + if (test_builtin_malloc_cond (0) != 64) + FAIL (); + if (test_builtin_malloc_condphi (1) != 32) + FAIL (); + if (test_builtin_malloc_condphi (0) != 64) + FAIL (); + if (test_builtin_malloc_condphi2 (1, 128) != 128) + FAIL (); + if (test_builtin_malloc_condphi2 (0, 128) != 64) + FAIL (); + if (test_builtin_malloc_condphi3 (1, 128, 256) != 128) + FAIL (); + if (test_builtin_malloc_condphi3 (0, 128, 256) != 256) + FAIL (); + if (test_builtin_malloc_condphi4 (128, 1) != 64) + FAIL (); + if (test_builtin_malloc_condphi4 (128, 0) != sizeof (void *)) + FAIL (); + if (test_builtin_malloc_condphi5 (128, 0, argv[0]) != -1) + FAIL (); + long x = 42; + if (test_builtin_malloc_long (x, 0) != x) + FAIL (); + if (test_calloc (2048, 4) != 2048 * 4) + FAIL (); + if (test_builtin_calloc (2048, 8) != 2048 * 8) + FAIL (); + if (test_builtin_calloc_cond (0, 0) != 64 * 16) + FAIL (); + if (test_builtin_calloc_cond (1, 1) != 32 * 1024) + FAIL (); + if (test_builtin_calloc_condphi (128, 1, 0) + != 128 * sizeof (struct { int a; char b; })) + FAIL (); + if (test_builtin_calloc_condphi (128, 1, 1) != 128) + FAIL (); + if (test_passthrough (__builtin_strlen (argv[0]) + 1, argv[0]) + != __builtin_strlen (argv[0]) + 1) + FAIL (); + if (test_passthrough_nonssa (argv[0]) != __builtin_strlen (argv[0]) + 1) + FAIL (); + if (test_dynarray (__builtin_strlen (argv[0])) != __builtin_strlen (argv[0])) + FAIL (); + if (test_dynarray_struct (42, 4) != + ((42 - 4) * sizeof (struct dynarray_struct) + - __builtin_offsetof (struct dynarray_struct, c))) + FAIL (); + if (test_dynarray_struct (42, 48) != 0) + FAIL (); + if (test_substring (128, 4) != 128 - 4) + FAIL (); + if (test_substring (128, 142) != 0) + FAIL (); + if (test_dynarray_struct_subobj (42, 4) != 16 - 4) + FAIL (); + if (test_dynarray_struct_subobj (42, 48) != 0) + FAIL (); + size_t objsz = 0; + if (test_dynarray_struct_subobj2 (42, 4, &objsz) + != objsz - 4 - sizeof (long) - sizeof (int)) + FAIL (); + DEFSTRUCT(ds, 64); + const size_t n = sizeof (ds.a); + if (test_dynarray_struct_member_b (n) + != sizeof (ds) - __builtin_offsetof (struct DS, b)) + FAIL (); + if (test_dynarray_struct_member_c (n) + != sizeof (ds) - __builtin_offsetof (struct DS, c)) + FAIL (); + if (test_dynarray_struct_member_d (n, 0) + != sizeof (ds) - __builtin_offsetof (struct DS, d)) + FAIL (); + if (test_dynarray_struct_member_subobj_b (n) != sizeof (ds.b)) + FAIL (); + if (test_dynarray_struct_member_subobj_c (n) != sizeof (ds.c)) + FAIL (); + if (test_dynarray_struct_member_subobj_d (n, n - 2) + != sizeof (ds) - __builtin_offsetof (struct DS, d) - n + 2) + FAIL (); + if (test_substring_ptrplus (128, 4) != (128 - 4) * sizeof (int)) + FAIL (); + if (test_substring_ptrplus (128, 142) != 0) + FAIL (); + if (test_substring_ptrplus2 (128, 4, 4) != (128 - 8) * sizeof (int)) + FAIL (); + if (test_substring_ptrplus2 (128, 4, -3) != (128 - 1) * sizeof (int)) + FAIL (); + if (test_dynarray_cond (0) != 16) + FAIL (); + if (test_dynarray_cond (1) != 8) + FAIL (); + if (test_alloc_nested_structs (42) != 42 - sizeof (int)) + FAIL (); + if (test_deploop (128, 4) != 128) + FAIL (); + if (test_deploop (128, 129) != 32) + FAIL (); + if (test_parmsz_simple (argv[0], __builtin_strlen (argv[0]) + 1) + != __builtin_strlen (argv[0]) + 1) + FAIL (); + if (test_parmsz_simple2 (__builtin_strlen (argv[0]) + 1, argv[0]) + != __builtin_strlen (argv[0]) + 1) + FAIL (); + /* Only explicitly added access attributes are supported for now. */ + if (test_parmsz_simple3 (__builtin_strlen (argv[0]) + 1, argv[0]) != -1) + FAIL (); + int arr[42]; + if (test_parmsz_scaled (arr, 42) != sizeof (arr)) + FAIL (); + if (test_parmsz_scaled (arr, 40) != 40 * sizeof (int)) + FAIL (); + /* __bdos cannot see the actual size of ARR, so it will return what it was + passed. Fortunately though the overflow warnings see this caller side and + warns of the problematic size. */ + if (test_parmsz_scaled (arr, 44) != 44 * sizeof (int)) /* { dg-warning "-Wstringop-overflow=" } */ + FAIL (); + if (test_parmsz_unknown (argv[0], argv[0], __builtin_strlen (argv[0]) + 1, 0) + != -1) + if (test_parmsz (argv[0], __builtin_strlen (argv[0]) + 1, -1) != 0) + FAIL (); + if (test_parmsz (argv[0], __builtin_strlen (argv[0]) + 1, 0) + != __builtin_strlen (argv[0]) + 1) + FAIL (); + if (test_parmsz (argv[0], __builtin_strlen (argv[0]) + 1, + __builtin_strlen (argv[0])) != 1) + FAIL (); + if (test_parmsz (argv[0], __builtin_strlen (argv[0]) + 1, + __builtin_strlen (argv[0]) + 2) != 0) + FAIL (); + if (test_parmsz_scaled_off (arr, 42, 2) != 40 * sizeof (int)) + FAIL (); + struct S *s; + if (test_parmsz_extern (s, 42) != -1) + FAIL (); + double obj[4][4]; + if (test_parmsz_internal (4, obj) != -1) + FAIL (); + if (test_parmsz_internal2 (4, obj) != -1) + FAIL (); + if (test_parmsz_internal3 (4, 4, obj) != -1) + FAIL (); + if (test_loop (arr, 42, 0, 32, 1) != 10 * sizeof (int)) + FAIL (); + if (test_loop (arr, 42, 32, -1, -1) != 0) + FAIL (); + if (test_loop (arr, 42, 32, 10, -1) != 32 * sizeof (int)) + FAIL (); + if (test_loop (arr, 42, 42, 0, -1) != 42 * sizeof (int)) + FAIL (); + if (test_loop (arr, 42, 44, 0, -1) != 0) + FAIL (); + if (test_loop (arr, 42, 20, 52, 1) != 0) + FAIL (); + /* pr105736. */ + int *t = test_pr105736 (&val3); + if (__builtin_dynamic_object_size (t, 0) != -1) + FAIL (); + const char *str = "hello world"; + if (test_strdup (str) != __builtin_strlen (str) + 1) + FAIL (); + if (test_strndup (str, 4) != 5) + FAIL (); + if (test_strdup_min (str) != __builtin_strlen (str) + 1) + FAIL (); + if (test_strndup_min (str, 4) != 1) + FAIL (); + + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-1.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-1.c new file mode 100644 index 0000000000..8f17c8edca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-1.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-10.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-10.c new file mode 100644 index 0000000000..3a2d9821a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-10.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-early_objsz-details" } */ +// { dg-skip-if "packed attribute missing for drone_source_packet" { "epiphany-*-*" } } + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-10.c" + +/* early_objsz should resolve __builtin_dynamic_object_size like + __builtin_object_size. */ +/* { dg-final { scan-tree-dump "maximum object size 21" "early_objsz" } } */ +/* { dg-final { scan-tree-dump "maximum subobject size 16" "early_objsz" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-11.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-11.c new file mode 100644 index 0000000000..65dcec9fca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-11.c @@ -0,0 +1,7 @@ +/* PR48985 */ +/* { dg-do run } */ +/* { dg-options "-std=gnu89" } */ +/* { dg-skip-if "packed attribute missing for struct s" { "epiphany-*-*" } } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-11.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-12.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-12.c new file mode 100644 index 0000000000..f0ce050a94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-12.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-12.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-13.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-13.c new file mode 100644 index 0000000000..555e23522d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-13.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-13.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-14.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-14.c new file mode 100644 index 0000000000..2620720019 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-14.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-14.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-15.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-15.c new file mode 100644 index 0000000000..cd8a941438 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-15.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-15.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-16.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-16.c new file mode 100644 index 0000000000..cc77508941 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-16.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +char ax2[]; /* { dg-warning "assumed to have one element" } */ +#include "builtin-object-size-16.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-17.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-17.c new file mode 100644 index 0000000000..f5c57a8788 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-17.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -fdump-tree-ssa" } */ + +char ax2[]; /* { dg-warning "assumed to have one element" } */ +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-17.c" +/* { dg-final { scan-tree-dump-not "failure_on_line" "ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-18.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-18.c new file mode 100644 index 0000000000..70c1ebcff2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-18.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* __stpncpy_chk could return buf up to buf + 64, so + the minimum object size might be far smaller than 64. */ +/* { dg-final { scan-tree-dump-not "return 64;" "optimized" } } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-18.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-19.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-19.c new file mode 100644 index 0000000000..44141a3860 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-19.c @@ -0,0 +1,104 @@ +/* PR tree-optimization/88372 - alloc_size attribute is ignored + on function pointers { dg-do compile } + { dg-options "-O2 -fdump-tree-optimized" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-18.c" + +typedef __SIZE_TYPE__ size_t; + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name) CAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to function named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +void sink (void*); + +#define T(alloc, n) do { \ + void *p = alloc; \ + sink (p); \ + ELIM (n == __builtin_object_size (p, 0)); \ + ELIM (n == __builtin_object_size (p, 1)); \ + ELIM (n == __builtin_object_size (p, 2)); \ + ELIM (n == __builtin_object_size (p, 3)); \ + } while (0) + + +ATTR (alloc_size (1)) void* (*alloc_1_x)(size_t, size_t); +ATTR (alloc_size (2)) void* (*alloc_x_2)(size_t, size_t); + +/* Verify that things work when attribute alloc_size is applied + to a typedef that is then used to declared a pointer. */ +typedef ATTR (alloc_size (1, 2)) void* (alloc_1_2_t)(size_t, size_t); + +void test_alloc_ptr (alloc_1_2_t *alloc_1_2) +{ + T (alloc_1_x (0, 0), 0); + T (alloc_1_x (1, 0), 1); + T (alloc_1_x (3, 0), 3); + T (alloc_1_x (9, 5), 9); + + T (alloc_x_2 (0, 0), 0); + T (alloc_x_2 (1, 0), 0); + T (alloc_x_2 (0, 1), 1); + T (alloc_x_2 (9, 5), 5); + + T (alloc_1_2 (0, 0), 0); + T (alloc_1_2 (1, 0), 0); + T (alloc_1_2 (0, 1), 0); + T (alloc_1_2 (9, 5), 45); +} + +/* Verify that object size is detected even in indirect calls via + function pointers to built-in allocation functions, even without + explicit use of attribute alloc_size on the pointers. */ + +typedef void *(allocfn_1) (size_t); +typedef void *(allocfn_1_2) (size_t, size_t); + +static inline void * +call_alloc (allocfn_1 *fn1, allocfn_1_2 *fn2, size_t n1, size_t n2) +{ + return fn1 ? fn1 (n1) : fn2 (n1, n2); +} + +static inline void * +call_malloc (size_t n) +{ + return call_alloc (__builtin_malloc, 0, n, 0); +} + +static inline void * +call_calloc (size_t n1, size_t n2) +{ + return call_alloc (0, __builtin_calloc, n1, n2); +} + +void test_builtin_ptr (void) +{ + T (call_malloc (0), 0); + T (call_malloc (1), 1); + T (call_malloc (9), 9); + + T (call_calloc (0, 0), 0); + T (call_calloc (0, 1), 0); + T (call_calloc (1, 0), 0); + T (call_calloc (1, 1), 1); + T (call_calloc (1, 3), 3); + T (call_calloc (2, 3), 6); +} + +/* { dg-final { scan-tree-dump-not "not_eliminated" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-2.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-2.c new file mode 100644 index 0000000000..3677782ff1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-2.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-2.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-3.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-3.c new file mode 100644 index 0000000000..5b6987b777 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-3.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-4.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-4.c new file mode 100644 index 0000000000..9d796224e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-4.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-4.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-5-main.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-5-main.c new file mode 100644 index 0000000000..49f459b8cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-5-main.c @@ -0,0 +1,32 @@ +#ifdef N +typedef __SIZE_TYPE__ size_t; + +char buf[N]; + +void test1 (size_t); +void test2 (size_t); +void test3 (size_t); +void test4 (size_t); +void test5 (size_t); +void test6 (size_t); +void test7 (size_t); + +int +main (void) +{ + test1 (42); + test2 (42); + test3 (42); + test4 (42); + test5 (42); + test6 (42); + test7 (42); + return 0; +} +#else +int +main (void) +{ + return 0; +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-5.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-5.c new file mode 100644 index 0000000000..80b77dd524 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-5.c @@ -0,0 +1,6 @@ +/* { dg-do run { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } */ +/* { dg-options "-O2 -DN=0x4000000" } */ +/* { dg-additional-sources "builtin-dynamic-object-size-5-main.c" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-5.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-6.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-6.c new file mode 100644 index 0000000000..6a275ce5b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-6.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-6.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-7.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-7.c new file mode 100644 index 0000000000..e2a6599468 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-7.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-7.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-8.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-8.c new file mode 100644 index 0000000000..e7af383d9b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-8.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-8.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-9.c b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-9.c new file mode 100644 index 0000000000..19021bc2ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-dynamic-object-size-9.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#define __builtin_object_size __builtin_dynamic_object_size +#include "builtin-object-size-9.c" diff --git a/SingleSource/Regression/C/gcc-dg/builtin-ffs-1.c b/SingleSource/Regression/C/gcc-dg/builtin-ffs-1.c new file mode 100644 index 0000000000..2bf0e9873d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-ffs-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int ffs (int) __asm ("__GI_ffs") __attribute__ ((nothrow, const)); + +int +ffsll (long long int i) +{ + unsigned long long int x = i & -i; + + if (x <= 0xffffffff) + return ffs (i); + else + return 32 + ffs (i >> 32); +} + +/* { dg-final { scan-assembler-not "\nffs\n|\nffs\[^a-zA-Z0-9_\]|\[^a-zA-Z0-9_\]ffs\n" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-has-attribute.c b/SingleSource/Regression/C/gcc-dg/builtin-has-attribute.c new file mode 100644 index 0000000000..9668acec0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-has-attribute.c @@ -0,0 +1,48 @@ +/* Verify that defining a type in __builtin_has_attribute triggers + the expected -Wc++-compat warning and evaluates as expected. + Also verify that the expression in __builtin_has_attribute is + not evaluated. + + { dg-do compile } + { dg-options "-O2 -Wall -Wc++-compat -fdump-tree-optimized -ftrack-macro-expansion=0" } */ + +#define ATTR(list) __attribute__ (list) + +#define A(expect, sym, attr) \ + typedef int Assert [1 - 2 * !(__builtin_has_attribute (sym, attr) == expect)] + +#define assert(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("Assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + ++nfails)) + +A (0, struct A { int i; }, aligned); /* { dg-warning "expression is invalid in C\\\+\\\+" } */ +A (1, struct ATTR ((aligned)) B { int i; }, aligned); /* { dg-warning "expression is invalid in C\\\+\\\+" } */ + + +static int f (void) +{ + __builtin_abort (); +} + +int main (void) +{ + int n = 0, nfails = 0; + + assert (0 == __builtin_has_attribute (int[n++], aligned)); + assert (1 == __builtin_has_attribute (ATTR ((aligned)) int[n++], aligned)); + assert (1 == __builtin_has_attribute (ATTR ((aligned)) int[f ()], aligned)); + assert (1 == 1); + + if (n) + __builtin_abort (); + + if (nfails) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "abort" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-inf-1.c b/SingleSource/Regression/C/gcc-dg/builtin-inf-1.c new file mode 100644 index 0000000000..b075fcd85f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-inf-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +float fi = __builtin_inff(); +/* { dg-error "does not support infinity" "INF unsupported" { target pdp11*-*-* vax-*-* } .-1 } */ +double di = __builtin_inf(); +/* { dg-error "does not support infinity" "INF unsupported" { target pdp11*-*-* vax-*-* } .-1 } */ +long double li = __builtin_infl(); +/* { dg-error "does not support infinity" "INF unsupported" { target pdp11*-*-* vax-*-* } .-1 } */ + +float fh = __builtin_huge_valf(); +double dh = __builtin_huge_val(); +long double lh = __builtin_huge_vall(); + diff --git a/SingleSource/Regression/C/gcc-dg/builtin-memchr-2.c b/SingleSource/Regression/C/gcc-dg/builtin-memchr-2.c new file mode 100644 index 0000000000..9797960900 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-memchr-2.c @@ -0,0 +1,55 @@ +/* Verify that memchr calls with the address of a constant character + are folded as expected even at -O0. + { dg-do compile } + { dg-options "-O0 -Wall -fdump-tree-gimple" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __WCHAR_TYPE__ wchar_t; + +extern void* memchr (const void*, int, size_t); +extern int printf (const char*, ...); +extern void abort (void); + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + abort ())) + +const char nul = 0; +const char cha = 'a'; + +const struct +{ + char c; +} snul = { 0 }, + schb = { 'b' }, + sarr[] = { + { 0 }, + { 'c' } + }; + + +void test_memchr_cst_char (void) +{ + A (&nul == memchr (&nul, 0, 1)); + A (!memchr (&nul, 'a', 1)); + + A (&cha == memchr (&cha, 'a', 1)); + A (!memchr (&cha, 0, 1)); + + A (&snul.c == memchr (&snul.c, 0, 1)); + A (!memchr (&snul.c, 'a', 1)); + + A (&schb.c == memchr (&schb.c, 'b', 1)); + A (!memchr (&schb.c, 0, 1)); + + A (&sarr[0].c == memchr (&sarr[0].c, 0, 1)); + A (!memchr (&sarr[0].c, 'a', 1)); + + A (&sarr[1].c == memchr (&sarr[1].c, 'c', 1)); + A (!memchr (&sarr[1].c, 0, 1)); +} + +/* { dg-final { scan-tree-dump-not "abort" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-memchr-3.c b/SingleSource/Regression/C/gcc-dg/builtin-memchr-3.c new file mode 100644 index 0000000000..c405e8d173 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-memchr-3.c @@ -0,0 +1,72 @@ +/* Verify that memchr calls with a pointer to a constant character + are folded as expected. + { dg-do compile } + { dg-options "-O1 -Wall -fdump-tree-gimple" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __WCHAR_TYPE__ wchar_t; + +extern void* memchr (const void*, int, size_t); +extern int printf (const char*, ...); +extern void abort (void); + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + abort ())) + +const char nul = 0; +const char cha = 'a'; + +const char* const pnul = &nul; +const char* const pcha = &cha; + +const struct +{ + char c; +} snul = { 0 }, + schb = { 'b' }, + sarr[] = { + { 0 }, + { 'c' } + }; + +const char* const psarr0c = &sarr[0].c; +const char* const psarr1c = &sarr[1].c; + +void test_memchr_cst_char (void) +{ + A (&nul == memchr (&nul, 0, 1)); + A (!memchr (&nul, 'a', 1)); + + A (&cha == memchr (&cha, 'a', 1)); + A (!memchr (&cha, 0, 1)); + + A (&nul == memchr (pnul, 0, 1)); + A (!memchr (pnul, 'a', 1)); + + A (&cha == memchr (pcha, 'a', 1)); + A (!memchr (pcha, 0, 1)); + + A (&snul.c == memchr (&snul.c, 0, 1)); + A (!memchr (&snul.c, 'a', 1)); + + A (&schb.c == memchr (&schb.c, 'b', 1)); + A (!memchr (&schb.c, 0, 1)); + + A (&sarr[0].c == memchr (&sarr[0].c, 0, 1)); + A (!memchr (&sarr[0].c, 'a', 1)); + + A (&sarr[1].c == memchr (&sarr[1].c, 'c', 1)); + A (!memchr (&sarr[1].c, 0, 1)); + + A (&sarr[0].c == memchr (psarr0c, 0, 1)); + A (!memchr (psarr0c, 'a', 1)); + + A (&sarr[1].c == memchr (psarr1c, 'c', 1)); + A (!memchr (psarr1c, 0, 1)); +} + +/* { dg-final { scan-tree-dump-not "abort" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-memchr-4.c b/SingleSource/Regression/C/gcc-dg/builtin-memchr-4.c new file mode 100644 index 0000000000..58a3b444b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-memchr-4.c @@ -0,0 +1,40 @@ +/* PR tree-optimization/89772 + Verify that memchr calls with a pointer to a constant character + are folded as expected. + { dg-do compile } + { dg-options "-O1 -Wall -fdump-tree-release_ssa" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __WCHAR_TYPE__ wchar_t; + +extern void* memchr (const void*, int, size_t); +extern int printf (const char*, ...); +extern void abort (void); + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + abort ())) + +const char a[8] = {'a',0,'b'}; +const char b[3] = {'a','b'}; +const char c[8] = {'a','b','c'}; + +void test_memchr_cst_char (void) +{ + A (!memchr (a, 'c', 2)); + A (!memchr (a, 'c', 5)); + A (!memchr (a, 'c', sizeof a)); + A (&a[1] == memchr (a, 0, sizeof a)); + + A (!memchr (b, 0, 2)); + A (&b[2] == memchr (b, 0, sizeof b)); + + A (!memchr (c, 0, 2)); + A (&c[3] == memchr (c, 0, 4)); + A (&c[3] == memchr (c, 0, sizeof a)); +} + +/* { dg-final { scan-tree-dump-not "abort" "release_ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-memchr.c b/SingleSource/Regression/C/gcc-dg/builtin-memchr.c new file mode 100644 index 0000000000..845362ee31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-memchr.c @@ -0,0 +1,68 @@ +/* PR tree-optimization/86711 - wrong folding of memchr + + Verify that memchr() of arrays initialized with 16-bit wide string + literals finds the nul only when it is present in the wide string. + + { dg-do compile } + { dg-options "-O1 -Wall -fshort-wchar -fdump-tree-optimized" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __WCHAR_TYPE__ wchar_t; + +extern void* memchr (const void*, int, size_t); +extern int printf (const char*, ...); +extern void abort (void); + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + abort ())) + +static const wchar_t wc = L'1'; +static const wchar_t ws1[] = L"1"; +static const wchar_t ws2[2] = L"\x1234\x5678"; /* no terminating nul */ +static const wchar_t ws4[] = L"\x0012\x1200\x1234"; + +void test_wide (void) +{ + int i0 = 0; + int i1 = i0 + 1; + int i2 = i1 + 1; + + A (sizeof (wchar_t) == 2); + + A (memchr (L"" + 1, 0, 0) == 0); + A (memchr (&wc + 1, 0, 0) == 0); + A (memchr (L"\x1234", 0, sizeof (wchar_t)) == 0); + + A (memchr (L"" + i1, i0, i0) == 0); + A (memchr (&wc + i1, i0, i0) == 0); + A (memchr (L"\x1234", i0, sizeof (wchar_t)) == 0); + + A (memchr (ws2, 0, sizeof ws2) == 0); + A (memchr (ws2, i0, sizeof ws2) == 0); + + const size_t nb = sizeof ws4; + const size_t nwb = sizeof (wchar_t); + + const char *pws1 = (const char*)ws1; + const char *pws4 = (const char*)ws4; + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + A (memchr (ws1, i0, sizeof ws1) == pws1 + 1); + + A (memchr (&ws4[0], i0, nb) == pws4 + i1); + A (memchr (&ws4[1], i0, nb - i1 * nwb) == pws4 + i1 * nwb); + A (memchr (&ws4[2], i0, nb - i2 * nwb) == pws4 + i2 * nwb + i2); +#else + A (memchr (ws1, i0, sizeof ws1) == pws1 + 0); + + A (memchr (&ws4[0], i0, nb) == pws4 + 0); + A (memchr (&ws4[1], i0, nb - i1 * nwb) == pws4 + i1 * nwb + i1); + A (memchr (&ws4[2], i0, nb - i2 * nwb) == pws4 + i2 * nwb + i2); +#endif +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-memcpy-2.c b/SingleSource/Regression/C/gcc-dg/builtin-memcpy-2.c new file mode 100644 index 0000000000..bddff935fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-memcpy-2.c @@ -0,0 +1,42 @@ +/* PR tree-optimization/88800 - Spurious -Werror=array-bounds for non-taken + branch + Verify that out-of-bounds memcpy calls are not folded even when + warnings are disabled. + { dg-do compile } + { dg-options "-O2 -w -fdump-tree-optimized" } */ + +extern void* memcpy (void*, const void*, __SIZE_TYPE__); + +char a1[1], a2[2], a4[4], a8[8], a16[16], a32[32]; + +void f1 (const void *p) +{ + memcpy (a1, p, sizeof a1 * 2); +} + +void f2 (const void *p) +{ + memcpy (a2, p, sizeof a2 * 2); +} + +void f4 (const void *p) +{ + memcpy (a4, p, sizeof a4 * 2); +} + +void f8 (const void *p) +{ + memcpy (a8, p, sizeof a8 * 2); +} + +void f16 (const void *p) +{ + memcpy (a16, p, sizeof a16 * 2); +} + +void f32 (const void *p) +{ + memcpy (a32, p, sizeof a32 * 2); +} + +/* { dg-final { scan-tree-dump-times "memcpy" 6 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-memcpy.c b/SingleSource/Regression/C/gcc-dg/builtin-memcpy.c new file mode 100644 index 0000000000..85e25396f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-memcpy.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/88800 - Spurious -Werror=array-bounds for non-taken + branch + Verify that out-of-bounds memcpy calls are not folded when warnings are + enabled (builtin-memcpy-2.c verifies they're not folded with warnings + disabled). + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +extern void* memcpy (void*, const void*, __SIZE_TYPE__); + +char a1[1], a2[2], a4[4], a8[8], a16[16], a32[32]; + +void f1 (const void *p) +{ + memcpy (a1, p, sizeof a1 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ +} + +void f2 (const void *p) +{ + memcpy (a2, p, sizeof a2 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ +} + +void f4 (const void *p) +{ + memcpy (a4, p, sizeof a4 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ +} + +void f8 (const void *p) +{ + memcpy (a8, p, sizeof a8 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ +} + +void f16 (const void *p) +{ + memcpy (a16, p, sizeof a16 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ +} + +void f32 (const void *p) +{ + memcpy (a32, p, sizeof a32 * 2); /* { dg-warning "\\\[-Warray-bounds" } */ +} + +/* { dg-final { scan-tree-dump-times "memcpy" 6 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-1.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-1.c new file mode 100644 index 0000000000..db325801f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-1.c @@ -0,0 +1,729 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +#include "builtin-object-size-common.h" + +struct A +{ + char a[10]; + int b; + char c[10]; +} y, w[4]; + +extern char exta[]; +extern char extb[30]; +extern struct A zerol[0]; + +void +__attribute__ ((noinline)) +test1 (void *q, int x) +{ + struct A a; + void *p = &a.a[3], *r; + char var[x + 10]; + if (x < 0) + r = &a.a[9]; + else + r = &a.c[1]; + if (__builtin_object_size (p, 0) + != sizeof (a) - __builtin_offsetof (struct A, a) - 3) + FAIL (); + if (__builtin_object_size (&a.c[9], 0) + != sizeof (a) - __builtin_offsetof (struct A, c) - 9) + FAIL (); + if (__builtin_object_size (q, 0) != (size_t) -1) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 0) + != (x < 0 + ? sizeof (a) - __builtin_offsetof (struct A, a) - 9 + : sizeof (a) - __builtin_offsetof (struct A, c) - 1)) + FAIL (); +#else + if (__builtin_object_size (r, 0) + != sizeof (a) - __builtin_offsetof (struct A, a) - 9) + FAIL (); +#endif + if (x < 6) + r = &w[2].a[1]; + else + r = &a.a[6]; + if (__builtin_object_size (&y, 0) + != sizeof (y)) + FAIL (); + if (__builtin_object_size (w, 0) + != sizeof (w)) + FAIL (); + if (__builtin_object_size (&y.b, 0) + != sizeof (a) - __builtin_offsetof (struct A, b)) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 0) + != (x < 6 + ? 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1 + : sizeof (a) - __builtin_offsetof (struct A, a) - 6)) + FAIL (); +#else + if (__builtin_object_size (r, 0) + != 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1) + FAIL (); +#endif + if (x < 20) + r = malloc (30); + else + r = calloc (2, 16); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 0) != (x < 20 ? 30 : 2 * 16)) + FAIL (); +#else + /* We may duplicate this test onto the two exit paths. On one path + the size will be 32, the other it will be 30. If we don't duplicate + this test, then the size will be 32. */ + if (__builtin_object_size (r, 0) != 2 * 16 + && __builtin_object_size (r, 0) != 30) + FAIL (); +#endif + if (x < 20) + r = malloc (30); + else + r = calloc (2, 14); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 0) != (x < 20 ? 30 : 2 * 14)) + FAIL (); +#else + if (__builtin_object_size (r, 0) != 30) + FAIL (); +#endif + if (x < 30) + r = malloc (sizeof (a)); + else + r = &a.a[3]; +#ifdef __builtin_object_size + if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) : sizeof (a) - 3)) + FAIL (); +#else + if (__builtin_object_size (r, 0) != sizeof (a)) + FAIL (); +#endif + r = memcpy (r, "a", 2); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) : sizeof (a) - 3)) + FAIL (); +#else + if (__builtin_object_size (r, 0) != sizeof (a)) + FAIL (); +#endif + r = memcpy (r + 2, "b", 2) + 2; +#ifdef __builtin_object_size + if (__builtin_object_size (r, 0) + != (x < 30 ? sizeof (a) - 4 : sizeof (a) - 7)) + FAIL (); +#else + if (__builtin_object_size (r, 0) != sizeof (a) - 4) + FAIL (); +#endif + r = &a.a[4]; + r = memset (r, 'a', 2); + if (__builtin_object_size (r, 0) + != sizeof (a) - __builtin_offsetof (struct A, a) - 4) + FAIL (); + r = memset (r + 2, 'b', 2) + 2; + if (__builtin_object_size (r, 0) + != sizeof (a) - __builtin_offsetof (struct A, a) - 8) + FAIL (); + r = &a.a[1]; + r = strcpy (r, "ab"); + if (__builtin_object_size (r, 0) + != sizeof (a) - __builtin_offsetof (struct A, a) - 1) + FAIL (); + r = strcpy (r + 2, "cd") + 2; + if (__builtin_object_size (r, 0) + != sizeof (a) - __builtin_offsetof (struct A, a) - 5) + FAIL (); + if (__builtin_object_size (exta, 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (exta + 10, 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&exta[5], 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (extb, 0) != sizeof (extb)) + FAIL (); + if (__builtin_object_size (extb + 10, 0) != sizeof (extb) - 10) + FAIL (); + if (__builtin_object_size (&extb[5], 0) != sizeof (extb) - 5) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (var, 0) != x + 10) + FAIL (); + if (__builtin_object_size (var + 10, 0) != x) + FAIL (); + if (__builtin_object_size (&var[5], 0) != x + 5) + FAIL (); +#else + if (__builtin_object_size (var, 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (var + 10, 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&var[5], 0) != (size_t) -1) + FAIL (); +#endif + if (__builtin_object_size (zerol, 0) != 0) + FAIL (); + if (__builtin_object_size (&zerol, 0) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0], 0) != 0) + FAIL (); + if (__builtin_object_size (zerol[0].a, 0) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0].a[0], 0) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0].b, 0) != 0) + FAIL (); + if (__builtin_object_size ("abcdefg", 0) != sizeof ("abcdefg")) + FAIL (); + if (__builtin_object_size ("abcd\0efg", 0) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg", 0) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg"[0], 0) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg"[4], 0) != sizeof ("abcd\0efg") - 4) + FAIL (); + if (__builtin_object_size ("abcd\0efg" + 5, 0) != sizeof ("abcd\0efg") - 5) + FAIL (); + if (__builtin_object_size (L"abcdefg", 0) != sizeof (L"abcdefg")) + FAIL (); + r = (char *) L"abcd\0efg"; + if (__builtin_object_size (r + 2, 0) != sizeof (L"abcd\0efg") - 2) + FAIL (); +} + +size_t l1 = 1; + +void +__attribute__ ((noinline)) +test2 (void) +{ + struct B { char buf1[10]; char buf2[10]; } a; + char *r, buf3[20]; + int i; + size_t res; + + if (sizeof (a) != 20) + return; + + r = buf3; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[1]; + else if (i == l1) + r = &a.buf2[7]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[9]; + } +#ifdef __builtin_object_size + res = sizeof (buf3); + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 1; + else if (i == l1) + res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7; + else if (i == l1 + 1) + res = sizeof (buf3) - 5; + else if (i == l1 + 2) + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; + } +#else + res = 20; +#endif + if (__builtin_object_size (r, 0) != res) + FAIL (); + r = &buf3[20]; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[7]; + else if (i == l1) + r = &a.buf2[7]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[9]; + } +#ifdef __builtin_object_size + res = sizeof (buf3) - 20; + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 7; + else if (i == l1) + res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7; + else if (i == l1 + 1) + res = sizeof (buf3) - 5; + else if (i == l1 + 2) + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; + } + if (__builtin_object_size (r, 0) != res) + FAIL (); +#else + res = 15; +#endif + if (__builtin_object_size (r, 0) != res) + FAIL (); + r += 8; +#ifdef __builtin_object_size + res -= 8; + if (__builtin_object_size (r, 0) != res) + FAIL (); + if (res >= 6) + { + if (__builtin_object_size (r + 6, 0) != res - 6) + FAIL (); + } + else if (__builtin_object_size (r + 6, 0) != 0) + FAIL (); +#else + if (__builtin_object_size (r, 0) != 7) + FAIL (); + if (__builtin_object_size (r + 6, 0) != 1) + FAIL (); +#endif + r = &buf3[18]; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[9]; + else if (i == l1) + r = &a.buf2[9]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[4]; + } +#ifdef __builtin_object_size + res = sizeof (buf3) - 18; + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; + else if (i == l1) + res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 9; + else if (i == l1 + 1) + res = sizeof (buf3) - 5; + else if (i == l1 + 2) + res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 4; + } + if (res >= 12) + { + if (__builtin_object_size (r + 12, 0) != res - 12) + FAIL (); + } + else if (__builtin_object_size (r + 12, 0) != 0) + FAIL (); +#else + if (__builtin_object_size (r + 12, 0) != 4) + FAIL (); +#endif +} + +void +__attribute__ ((noinline)) +test3 (void) +{ + char buf4[10]; + struct B { struct A a[2]; struct A b; char c[4]; char d; double e; + _Complex double f; } x; + double y; + _Complex double z; + double *dp; + + if (__builtin_object_size (buf4, 0) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4, 0) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4[0], 0) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4[1], 0) != sizeof (buf4) - 1) + FAIL (); + if (__builtin_object_size (&x, 0) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a, 0) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a[0], 0) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a[0].a, 0) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a[0].a[0], 0) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a[0].a[3], 0) != sizeof (x) - 3) + FAIL (); + if (__builtin_object_size (&x.a[0].b, 0) + != sizeof (x) - __builtin_offsetof (struct A, b)) + FAIL (); + if (__builtin_object_size (&x.a[1].c, 0) + != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&x.a[1].c[0], 0) + != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&x.a[1].c[3], 0) + != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c) - 3) + FAIL (); + if (__builtin_object_size (&x.b, 0) + != sizeof (x) - __builtin_offsetof (struct B, b)) + FAIL (); + if (__builtin_object_size (&x.b.a, 0) + != sizeof (x) - __builtin_offsetof (struct B, b)) + FAIL (); + if (__builtin_object_size (&x.b.a[0], 0) + != sizeof (x) - __builtin_offsetof (struct B, b)) + FAIL (); + if (__builtin_object_size (&x.b.a[3], 0) + != sizeof (x) - __builtin_offsetof (struct B, b) - 3) + FAIL (); + if (__builtin_object_size (&x.b.b, 0) + != sizeof (x) - __builtin_offsetof (struct B, b) + - __builtin_offsetof (struct A, b)) + FAIL (); + if (__builtin_object_size (&x.b.c, 0) + != sizeof (x) - __builtin_offsetof (struct B, b) + - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&x.b.c[0], 0) + != sizeof (x) - __builtin_offsetof (struct B, b) + - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&x.b.c[3], 0) + != sizeof (x) - __builtin_offsetof (struct B, b) + - __builtin_offsetof (struct A, c) - 3) + FAIL (); + if (__builtin_object_size (&x.c, 0) + != sizeof (x) - __builtin_offsetof (struct B, c)) + FAIL (); + if (__builtin_object_size (&x.c[0], 0) + != sizeof (x) - __builtin_offsetof (struct B, c)) + FAIL (); + if (__builtin_object_size (&x.c[1], 0) + != sizeof (x) - __builtin_offsetof (struct B, c) - 1) + FAIL (); + if (__builtin_object_size (&x.d, 0) + != sizeof (x) - __builtin_offsetof (struct B, d)) + FAIL (); + if (__builtin_object_size (&x.e, 0) + != sizeof (x) - __builtin_offsetof (struct B, e)) + FAIL (); + if (__builtin_object_size (&x.f, 0) + != sizeof (x) - __builtin_offsetof (struct B, f)) + FAIL (); + dp = &__real__ x.f; + if (__builtin_object_size (dp, 0) + != sizeof (x) - __builtin_offsetof (struct B, f)) + FAIL (); + dp = &__imag__ x.f; + if (__builtin_object_size (dp, 0) + != sizeof (x) - __builtin_offsetof (struct B, f) + - sizeof (x.f) / 2) + FAIL (); + dp = &y; + if (__builtin_object_size (dp, 0) != sizeof (y)) + FAIL (); + if (__builtin_object_size (&z, 0) != sizeof (z)) + FAIL (); + dp = &__real__ z; + if (__builtin_object_size (dp, 0) != sizeof (z)) + FAIL (); + dp = &__imag__ z; + if (__builtin_object_size (dp, 0) != sizeof (z) / 2) + FAIL (); +} + +struct S { unsigned int a; }; + +char * +__attribute__ ((noinline)) +test4 (char *x, int y) +{ + register int i; + struct A *p; + + for (i = 0; i < y; i++) + { + p = (struct A *) x; + x = (char *) &p[1]; + if (__builtin_object_size (p, 0) != (size_t) -1) + FAIL (); + } + return x; +} + +void +__attribute__ ((noinline)) +test5 (size_t x) +{ + char buf[64]; + char *p = &buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 0) != sizeof (buf) - 8 - 4 * x) + FAIL (); +#else + /* My understanding of ISO C99 6.5.6 is that a conforming + program will not end up with p equal to &buf[0] + through &buf[7], i.e. calling this function with say + UINTPTR_MAX / 4 results in undefined behavior. + If that's true, then the maximum number of remaining + bytes from p until end of the object is 56, otherwise + it would be 64 (or conservative (size_t) -1 == unknown). */ + if (__builtin_object_size (p, 0) != sizeof (buf) - 8) + FAIL (); +#endif + memset (p, ' ', sizeof (buf) - 8 - 4 * 4); +} + +void +__attribute__ ((noinline)) +test6 (size_t x) +{ + struct T { char buf[64]; char buf2[64]; } t; + char *p = &t.buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 0) != sizeof (t) - 8 - 4 * x) + FAIL (); +#else + if (__builtin_object_size (p, 0) != sizeof (t) - 8) + FAIL (); +#endif + memset (p, ' ', sizeof (t) - 8 - 4 * 4); +} + +void +__attribute__ ((noinline)) +test7 (void) +{ + char buf[64]; + struct T { char buf[64]; char buf2[64]; } t; + char *p = &buf[64], *q = &t.buf[64]; + + if (__builtin_object_size (p + 64, 0) != 0) + FAIL (); + if (__builtin_object_size (q + 63, 0) != sizeof (t) - 64 - 63) + FAIL (); + if (__builtin_object_size (q + 64, 0) != sizeof (t) - 64 - 64) + FAIL (); + if (__builtin_object_size (q + 256, 0) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test8 (void) +{ + struct T { char buf[10]; char buf2[10]; } t; + char *p = &t.buf2[-4]; + char *q = &t.buf2[0]; + if (__builtin_object_size (p, 0) != sizeof (t) - 10 + 4) + FAIL (); + if (__builtin_object_size (q, 0) != sizeof (t) - 10) + FAIL (); + /* GCC only handles additions, not subtractions. */ + q = q - 8; + if (__builtin_object_size (q, 0) != (size_t) -1 + && __builtin_object_size (q, 0) != sizeof (t) - 10 + 8) + FAIL (); + p = &t.buf[-4]; + if (__builtin_object_size (p, 0) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test9 (unsigned cond) +{ + char *buf2 = malloc (10); + char *p; + + if (cond) + p = &buf2[8]; + else + p = &buf2[4]; + +#ifdef __builtin_object_size + if (__builtin_object_size (&p[-4], 0) != (cond ? 6 : 10)) + FAIL (); +#else + if (__builtin_object_size (&p[-4], 0) != 10) + FAIL (); +#endif + + for (unsigned i = cond; i > 0; i--) + p--; + +#ifdef __builtin_object_size + if (__builtin_object_size (p, 0) != ((cond ? 2 : 6) + cond)) + FAIL (); +#else + if (__builtin_object_size (p, 0) != 10) + FAIL (); +#endif + + p = &y.c[8]; + for (unsigned i = cond; i > 0; i--) + p--; + +#ifdef __builtin_object_size + if (__builtin_object_size (p, 0) + != sizeof (y) - __builtin_offsetof (struct A, c) - 8 + cond) + FAIL (); +#else + if (__builtin_object_size (p, 0) != sizeof (y)) + FAIL (); +#endif +} + +void +__attribute__ ((noinline)) +test10 (void) +{ + static char buf[255]; + unsigned int i, len = sizeof (buf); + char *p = buf; + + for (i = 0 ; i < sizeof (buf) ; i++) + { + if (len < 2) + { +#ifdef __builtin_object_size + if (__builtin_object_size (p - 3, 0) != sizeof (buf) - i + 3) + FAIL (); +#else + if (__builtin_object_size (p - 3, 0) != sizeof (buf)) + FAIL (); +#endif + break; + } + p++; + len--; + } +} + +/* Tests for strdup/strndup. */ +size_t +__attribute__ ((noinline)) +test11 (void) +{ + int i = 0; + const char *ptr = "abcdefghijklmnopqrstuvwxyz"; + char *res = strndup (ptr, 21); + if (__builtin_object_size (res, 0) != 22) + FAIL (); + + free (res); + + res = strndup (ptr, 32); + if (__builtin_object_size (res, 0) != 27) + FAIL (); + + free (res); + + res = strdup (ptr); + if (__builtin_object_size (res, 0) != 27) + FAIL (); + + free (res); + + char *ptr2 = malloc (64); + strcpy (ptr2, ptr); + + res = strndup (ptr2, 21); + if (__builtin_object_size (res, 0) != 22) + FAIL (); + + free (res); + + res = strndup (ptr2, 32); + if (__builtin_object_size (res, 0) != 33) + FAIL (); + + free (res); + + res = strndup (ptr2, 128); + if (__builtin_object_size (res, 0) != 64) + FAIL (); + + free (res); + + res = strdup (ptr2); +#ifdef __builtin_object_size + if (__builtin_object_size (res, 0) != 27) +#else + if (__builtin_object_size (res, 0) != (size_t) -1) +#endif + FAIL (); + free (res); + free (ptr2); + + ptr = "abcd\0efghijklmnopqrstuvwxyz"; + res = strdup (ptr); + if (__builtin_object_size (res, 0) != 5) + FAIL (); + free (res); + + res = strndup (ptr, 24); + if (__builtin_object_size (res, 0) != 5) + FAIL (); + free (res); + + res = strndup (ptr, 2); + if (__builtin_object_size (res, 0) != 3) + FAIL (); + free (res); + + res = strdup (&ptr[4]); + if (__builtin_object_size (res, 0) != 1) + FAIL (); + free (res); + + res = strndup (&ptr[4], 4); + if (__builtin_object_size (res, 0) != 1) + FAIL (); + free (res); + + res = strndup (&ptr[4], 1); + if (__builtin_object_size (res, 0) != 1) + FAIL (); + free (res); +} + +int +main (void) +{ + struct S s[10]; + __asm ("" : "=r" (l1) : "0" (l1)); + test1 (main, 6); + test2 (); + test3 (); + test4 ((char *) s, 10); + test5 (4); + test6 (4); + test7 (); + test8 (); + test9 (1); + test10 (); + test11 (); + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-10.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-10.c new file mode 100644 index 0000000000..bfcdf5cc94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-10.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-early_objsz-details" } */ +// { dg-skip-if "packed attribute missing for drone_source_packet" { "epiphany-*-*" } } + +typedef struct { + char sentinel[4]; + char data[0]; +} drone_packet; +typedef struct { + char type_str[16]; + char channel_hop; +} drone_source_packet; +drone_packet * +foo(char *x) +{ + drone_packet *dpkt = __builtin_malloc(sizeof(drone_packet) + + sizeof(drone_source_packet)); + drone_source_packet *spkt = (drone_source_packet *) dpkt->data; + __builtin___snprintf_chk (spkt->type_str, 16, + 1, __builtin_object_size (spkt->type_str, 1), + "%s", x); + return dpkt; +} + +/* { dg-final { scan-tree-dump "maximum object size 21" "early_objsz" } } */ +/* { dg-final { scan-tree-dump "maximum subobject size 16" "early_objsz" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-11.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-11.c new file mode 100644 index 0000000000..7c4a921cbb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-11.c @@ -0,0 +1,22 @@ +/* PR48985 */ +/* { dg-do run } */ +/* { dg-options "-std=gnu89" } */ +/* { dg-skip-if "packed attribute missing for struct s" { "epiphany-*-*" } } */ + +extern void abort (void); + +struct s { + int i; + char c[]; +} s = { 1, "01234" }; + +__SIZE_TYPE__ f (void) { return __builtin_object_size (&s.c, 0); } + +int +main() +{ + if (f() != sizeof ("01234")) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-12.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-12.c new file mode 100644 index 0000000000..e29dd17d61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-12.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +struct S { + int len; + char s[0]; +}; +int main() +{ + char buf[sizeof (struct S) + 32]; + if (__builtin_object_size (((struct S *)&buf[0])->s, 1) != 32) + FAIL (); + if (__builtin_object_size (((struct S *)&buf[1])->s, 1) != 31) + FAIL (); + if (__builtin_object_size (((struct S *)&buf[64])->s, 0) != 0) + FAIL (); + + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-13.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-13.c new file mode 100644 index 0000000000..7b6264d748 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-13.c @@ -0,0 +1,348 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +union A +{ + int a1; + char a2[3]; +}; + +union B +{ + long long b1; + union A b2; +}; + +struct C +{ + int c1; + union A c2; +}; + +struct D +{ + int d1; + union B d2; +}; + +union E +{ + struct C e1; + char e2[3]; +}; + +union F +{ + int f1; + struct D f2; +}; + +struct G +{ + union A g1; + char g2; +}; + +struct H +{ + int h1; + union E h2; +}; + +#define T(X, S0, S1) \ + if (__builtin_object_size (X, 0) != (S0)) \ + FAIL (); \ + if (__builtin_object_size (X, 1) != (S1)) \ + FAIL (); \ + if (__builtin_object_size (X, 2) != (S0)) \ + FAIL (); \ + if (__builtin_object_size (X, 3) != (S1)) \ + FAIL () +#define TS(X, S0) T(&X, S0, sizeof (X)) +#define TA(X, S0, S1) \ + T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1) +#define TF(X, S0) TA(X, S0, S0) + +int +main (void) +{ + size_t s, o, o2; + + s = sizeof (union A); + o = 0; + union A *a1 = malloc (s); + union A *a2 = malloc (o + 212); + TS (a1->a1, s); + s = o + 212; + TS (a2->a1, s); + free (a2); + free (a1); + s = sizeof (union A); + o = 0; + a1 = malloc (s); + a2 = malloc (o + 212); + TF (a1->a2, s); + s = o + 212; + TF (a2->a2, s); + free (a2); + free (a1); + + s = sizeof (union B); + o = 0; + union B *b1 = malloc (s); + union B *b2 = malloc (o + 212); + TS (b1->b1, s); + s = o + 212; + TS (b2->b1, s); + free (b2); + free (b1); + s = sizeof (union B); + o = 0; + b1 = malloc (s); + b2 = malloc (o + 212); + TS (b1->b2.a1, s); + s = o + 212; + TS (b2->b2.a1, s); + free (b2); + free (b1); + s = sizeof (union B); + o = 0; + b1 = malloc (s); + b2 = malloc (o + 212); + TF (b1->b2.a2, s); + s = o + 212; + TF (b2->b2.a2, s); + free (b2); + free (b1); + + s = sizeof (struct C); + o = __builtin_offsetof (struct C, c2); + struct C *c1 = malloc (s); + struct C *c2 = malloc (o + 212); + TS (c1->c1, s); + s = o + 212; + TS (c2->c1, s); + free (c2); + free (c1); + s = sizeof (struct C); + o = __builtin_offsetof (struct C, c2); + c1 = malloc (s); + c2 = malloc (o + 212); + TS (c1->c2.a1, s - o); + s = o + 212; + TS (c2->c2.a1, s - o); + free (c2); + free (c1); + s = sizeof (struct C); + o = __builtin_offsetof (struct C, c2); + c1 = malloc (s); + c2 = malloc (o + 212); + TF (c1->c2.a2, s - o); + s = o + 212; + TF (c2->c2.a2, s - o); + free (c2); + free (c1); + + s = sizeof (struct D); + o = __builtin_offsetof (struct D, d2); + struct D *d1 = malloc (s); + struct D *d2 = malloc (o + 212); + TS (d1->d1, s); + s = o + 212; + TS (d2->d1, s); + free (d2); + free (d1); + s = sizeof (struct D); + o = __builtin_offsetof (struct D, d2); + d1 = malloc (s); + d2 = malloc (o + 212); + TS (d1->d2.b1, s - o); + s = o + 212; + TS (d2->d2.b1, s - o); + free (d2); + free (d1); + s = sizeof (struct D); + o = __builtin_offsetof (struct D, d2); + d1 = malloc (s); + d2 = malloc (o + 212); + TS (d1->d2.b2.a1, s - o); + s = o + 212; + TS (d2->d2.b2.a1, s - o); + free (d2); + free (d1); + s = sizeof (struct D); + o = __builtin_offsetof (struct D, d2); + d1 = malloc (s); + d2 = malloc (o + 212); + TF (d1->d2.b2.a2, s - o); + s = o + 212; + TF (d2->d2.b2.a2, s - o); + free (d2); + free (d1); + + s = sizeof (union E); + o = __builtin_offsetof (union E, e1.c2); + union E *e1 = malloc (s); + union E *e2 = malloc (o + 212); + TS (e1->e1.c1, s); + s = o + 212; + TS (e2->e1.c1, s); + free (e2); + free (e1); + s = sizeof (union E); + o = __builtin_offsetof (union E, e1.c2); + e1 = malloc (s); + e2 = malloc (o + 212); + TS (e1->e1.c2.a1, s - o); + s = o + 212; + TS (e2->e1.c2.a1, s - o); + free (e2); + free (e1); + s = sizeof (union E); + o = __builtin_offsetof (union E, e1.c2); + e1 = malloc (s); + e2 = malloc (o + 212); + TF (e1->e1.c2.a2, s - o); + s = o + 212; + TF (e2->e1.c2.a2, s - o); + free (e2); + free (e1); + s = sizeof (union E); + o = __builtin_offsetof (union E, e1.c2); + e1 = malloc (s); + e2 = malloc (o + 212); + TF (e1->e2, s); + s = o + 212; + TF (e2->e2, s); + free (e2); + free (e1); + + s = sizeof (union F); + o = __builtin_offsetof (union F, f2.d2); + union F *f1 = malloc (s); + union F *f2 = malloc (o + 212); + TS (f1->f1, s); + s = o + 212; + TS (f2->f1, s); + free (f2); + free (f1); + s = sizeof (union F); + o = __builtin_offsetof (union F, f2.d2); + f1 = malloc (s); + f2 = malloc (o + 212); + TS (f1->f2.d1, s); + s = o + 212; + TS (f2->f2.d1, s); + free (f2); + free (f1); + s = sizeof (union F); + o = __builtin_offsetof (union F, f2.d2); + f1 = malloc (s); + f2 = malloc (o + 212); + TS (f1->f2.d2.b1, s - o); + s = o + 212; + TS (f2->f2.d2.b1, s - o); + free (f2); + free (f1); + s = sizeof (union F); + o = __builtin_offsetof (union F, f2.d2); + f1 = malloc (s); + f2 = malloc (o + 212); + TS (f1->f2.d2.b2.a1, s - o); + s = o + 212; + TS (f2->f2.d2.b2.a1, s - o); + free (f2); + free (f1); + s = sizeof (union F); + o = __builtin_offsetof (union F, f2.d2); + f1 = malloc (s); + f2 = malloc (o + 212); + TF (f1->f2.d2.b2.a2, s - o); + s = o + 212; + TF (f2->f2.d2.b2.a2, s - o); + free (f2); + free (f1); + + s = sizeof (struct G); + o = __builtin_offsetof (struct G, g2); + struct G *g1 = malloc (s); + struct G *g2 = malloc (o + 212); + TS (g1->g1.a1, s); + s = o + 212; + TS (g2->g1.a1, s); + free (g2); + free (g1); + s = sizeof (struct G); + o = __builtin_offsetof (struct G, g2); + g1 = malloc (s); + g2 = malloc (o + 212); + TA (g1->g1.a2, s, sizeof (g1->g1.a2)); + s = o + 212; + TA (g2->g1.a2, s, sizeof (g1->g1.a2)); + free (g2); + free (g1); + s = sizeof (struct G); + o = __builtin_offsetof (struct G, g2); + g1 = malloc (s); + g2 = malloc (o + 212); + TS (g1->g2, s - o); + s = o + 212; + TS (g2->g2, s - o); + free (g2); + free (g1); + + s = sizeof (struct H); + o = __builtin_offsetof (struct H, h2); + o2 = __builtin_offsetof (struct H, h2.e1.c2); + struct H *h1 = malloc (s); + struct H *h2 = malloc (o2 + 212); + TS (h1->h1, s); + s = o2 + 212; + TS (h2->h1, s); + free (h2); + free (h1); + s = sizeof (struct H); + o = __builtin_offsetof (struct H, h2); + o2 = __builtin_offsetof (struct H, h2.e1.c2); + h1 = malloc (s); + h2 = malloc (o2 + 212); + TS (h1->h2.e1.c1, s - o); + s = o2 + 212; + TS (h2->h2.e1.c1, s - o); + free (h2); + free (h1); + s = sizeof (struct H); + o = __builtin_offsetof (struct H, h2); + o2 = __builtin_offsetof (struct H, h2.e1.c2); + h1 = malloc (s); + h2 = malloc (o2 + 212); + TS (h1->h2.e1.c2.a1, s - o2); + s = o2 + 212; + TS (h2->h2.e1.c2.a1, s - o2); + free (h2); + free (h1); + s = sizeof (struct H); + o = __builtin_offsetof (struct H, h2); + o2 = __builtin_offsetof (struct H, h2.e1.c2); + h1 = malloc (s); + h2 = malloc (o2 + 212); + TA (h1->h2.e1.c2.a2, s - o2, sizeof (h1->h2.e1.c2.a2)); + s = o2 + 212; + TA (h2->h2.e1.c2.a2, s - o2, sizeof (h2->h2.e1.c2.a2)); + free (h2); + free (h1); + s = sizeof (struct H); + o = __builtin_offsetof (struct H, h2); + o2 = __builtin_offsetof (struct H, h2.e1.c2); + h1 = malloc (s); + h2 = malloc (o2 + 212); + TF (h1->h2.e2, s - o); + s = o2 + 212; + TF (h2->h2.e2, s - o); + free (h2); + free (h1); + + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-14.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-14.c new file mode 100644 index 0000000000..085011eda5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-14.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern char *strncpy(char *, const char *, __SIZE_TYPE__); + +union u { + struct { + char vi[8]; + char pi[16]; + }; + char all[8+16+4]; +}; + +void __attribute__((noinline,noclone)) +f(union u *u) +{ + char vi[8+1]; + __builtin_strncpy(vi, u->vi, sizeof(u->vi)); + if (__builtin_object_size (u->all, 1) != -1) + abort (); +} +int main() +{ + union u u; + f (&u); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-15.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-15.c new file mode 100644 index 0000000000..7ee8ac095e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-15.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +int +main () +{ + struct A { char buf1[9]; char buf2[1]; } a; + + if (__builtin_object_size (a.buf1 + (0 + 4), 1) != 5) + FAIL (); + char *p = a.buf1; + p += 1; + p += 3; + if (__builtin_object_size (p, 1) != 5) + FAIL (); + p = (char *) &a; + char *q = p + 1; + char *r = q + 3; + char *t = r; + if (r != (char *) &a + 4) + t = (char *) &a + 1; + if (__builtin_object_size (t, 1) != 6) + FAIL (); + + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-16.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-16.c new file mode 100644 index 0000000000..f26d5d97a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-16.c @@ -0,0 +1,207 @@ +/* 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[]; +#ifndef __builtin_object_size +char ax2[]; /* { dg-warning "assumed to have one element" } */ +#endif + +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]; +#elif __SIZEOF_LONG__ == 4 +extern long ia0[0]; +static long ia1[1]; +static long 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/SingleSource/Regression/C/gcc-dg/builtin-object-size-17.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-17.c new file mode 100644 index 0000000000..28f8414636 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-17.c @@ -0,0 +1,164 @@ +/* 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[]; +#ifndef __builtin_object_size +char ax2[]; /* { dg-warning "assumed to have one element" } */ +#endif + +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]; +#elif __SIZEOF_LONG__ == 4 +extern long ia0[0]; +static long ia1[1]; +static long 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/SingleSource/Regression/C/gcc-dg/builtin-object-size-18.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-18.c new file mode 100644 index 0000000000..e065393282 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-18.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* __stpncpy_chk could return buf up to buf + 64, so + the minimum object size might be far smaller than 64. */ +/* { dg-final { scan-tree-dump-not "return 64;" "optimized" } } */ + +typedef __SIZE_TYPE__ size_t; + +size_t +foo (const char *p, size_t s, size_t t) +{ + char buf[64]; + char *q = __builtin___stpncpy_chk (buf, p, s, t); + return __builtin_object_size (q, 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-19.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-19.c new file mode 100644 index 0000000000..1aab1efb77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-19.c @@ -0,0 +1,101 @@ +/* PR tree-optimization/88372 - alloc_size attribute is ignored + on function pointers { dg-do compile } + { dg-options "-O2 -fdump-tree-optimized" } */ + +typedef __SIZE_TYPE__ size_t; + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name) CAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to function named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +void sink (void*); + +#define T(alloc, n) do { \ + void *p = alloc; \ + sink (p); \ + ELIM (n == __builtin_object_size (p, 0)); \ + ELIM (n == __builtin_object_size (p, 1)); \ + ELIM (n == __builtin_object_size (p, 2)); \ + ELIM (n == __builtin_object_size (p, 3)); \ + } while (0) + + +ATTR (alloc_size (1)) void* (*alloc_1_x)(size_t, size_t); +ATTR (alloc_size (2)) void* (*alloc_x_2)(size_t, size_t); + +/* Verify that things work when attribute alloc_size is applied + to a typedef that is then used to declared a pointer. */ +typedef ATTR (alloc_size (1, 2)) void* (alloc_1_2_t)(size_t, size_t); + +void test_alloc_ptr (alloc_1_2_t *alloc_1_2) +{ + T (alloc_1_x (0, 0), 0); + T (alloc_1_x (1, 0), 1); + T (alloc_1_x (3, 0), 3); + T (alloc_1_x (9, 5), 9); + + T (alloc_x_2 (0, 0), 0); + T (alloc_x_2 (1, 0), 0); + T (alloc_x_2 (0, 1), 1); + T (alloc_x_2 (9, 5), 5); + + T (alloc_1_2 (0, 0), 0); + T (alloc_1_2 (1, 0), 0); + T (alloc_1_2 (0, 1), 0); + T (alloc_1_2 (9, 5), 45); +} + +/* Verify that object size is detected even in indirect calls via + function pointers to built-in allocation functions, even without + explicit use of attribute alloc_size on the pointers. */ + +typedef void *(allocfn_1) (size_t); +typedef void *(allocfn_1_2) (size_t, size_t); + +static inline void * +call_alloc (allocfn_1 *fn1, allocfn_1_2 *fn2, size_t n1, size_t n2) +{ + return fn1 ? fn1 (n1) : fn2 (n1, n2); +} + +static inline void * +call_malloc (size_t n) +{ + return call_alloc (__builtin_malloc, 0, n, 0); +} + +static inline void * +call_calloc (size_t n1, size_t n2) +{ + return call_alloc (0, __builtin_calloc, n1, n2); +} + +void test_builtin_ptr (void) +{ + T (call_malloc (0), 0); + T (call_malloc (1), 1); + T (call_malloc (9), 9); + + T (call_calloc (0, 0), 0); + T (call_calloc (0, 1), 0); + T (call_calloc (1, 0), 0); + T (call_calloc (1, 1), 1); + T (call_calloc (1, 3), 3); + T (call_calloc (2, 3), 6); +} + +/* { dg-final { scan-tree-dump-not "not_eliminated" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-2.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-2.c new file mode 100644 index 0000000000..4c71b1f6a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-2.c @@ -0,0 +1,642 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +#include "builtin-object-size-common.h" + +struct A +{ + char a[10]; + int b; + char c[10]; +} y, w[4]; + +extern char exta[]; +extern char extb[30]; +extern struct A extc[]; +struct A zerol[0]; + +void +__attribute__ ((noinline)) +test1 (void *q, int x) +{ + struct A a; + void *p = &a.a[3], *r; + char var[x + 10]; + struct A vara[x + 10]; + if (x < 0) + r = &a.a[9]; + else + r = &a.c[1]; + if (__builtin_object_size (p, 1) != sizeof (a.a) - 3) + FAIL (); + if (__builtin_object_size (&a.c[9], 1) + != sizeof (a.c) - 9) + FAIL (); + if (__builtin_object_size (q, 1) != (size_t) -1) + FAIL (); +#ifdef __builtin_object_size + if (x < 0 + ? __builtin_object_size (r, 1) != sizeof (a.a) - 9 + : __builtin_object_size (r, 1) != sizeof (a.c) - 1) + FAIL (); +#else + if (__builtin_object_size (r, 1) != sizeof (a.c) - 1) + FAIL (); +#endif + if (x < 6) + r = &w[2].a[1]; + else + r = &a.a[6]; + if (__builtin_object_size (&y, 1) != sizeof (y)) + FAIL (); + if (__builtin_object_size (w, 1) != sizeof (w)) + FAIL (); + if (__builtin_object_size (&y.b, 1) != sizeof (a.b)) + FAIL (); +#ifdef __builtin_object_size + if (x < 6 + ? __builtin_object_size (r, 1) != sizeof (a.a) - 1 + : __builtin_object_size (r, 1) != sizeof (a.a) - 6) + FAIL (); +#else + if (__builtin_object_size (r, 1) != sizeof (a.a) - 1) + FAIL (); +#endif + if (x < 20) + r = malloc (30); + else + r = calloc (2, 16); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 1) != (x < 20 ? 30 : 2 * 16)) + FAIL (); +#else + /* We may duplicate this test onto the two exit paths. On one path + the size will be 32, the other it will be 30. If we don't duplicate + this test, then the size will be 32. */ + if (__builtin_object_size (r, 1) != 2 * 16 + && __builtin_object_size (r, 1) != 30) + FAIL (); +#endif + if (x < 20) + r = malloc (30); + else + r = calloc (2, 14); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 1) != (x < 20 ? 30 : 2 * 14)) + FAIL (); +#else + if (__builtin_object_size (r, 1) != 30) + FAIL (); +#endif + if (x < 30) + r = malloc (sizeof (a)); + else + r = &a.a[3]; +#ifdef __builtin_object_size + if (__builtin_object_size (r, 1) != (x < 30 ? sizeof (a) : sizeof (a) - 3)) + FAIL (); +#else + if (__builtin_object_size (r, 1) != sizeof (a)) + FAIL (); +#endif + r = memcpy (r, "a", 2); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 1) != (x < 30 ? sizeof (a) : sizeof (a) - 3)) + FAIL (); +#else + if (__builtin_object_size (r, 1) != sizeof (a)) + FAIL (); +#endif + r = memcpy (r + 2, "b", 2) + 2; +#ifdef __builtin_object_size + if (__builtin_object_size (r, 0) + != (x < 30 ? sizeof (a) - 4 : sizeof (a) - 7)) + FAIL (); +#else + if (__builtin_object_size (r, 1) != sizeof (a) - 4) + FAIL (); +#endif + r = &a.a[4]; + r = memset (r, 'a', 2); + if (__builtin_object_size (r, 1) != sizeof (a.a) - 4) + FAIL (); + r = memset (r + 2, 'b', 2) + 2; + if (__builtin_object_size (r, 1) != sizeof (a.a) - 8) + FAIL (); + r = &a.a[1]; + r = strcpy (r, "ab"); + if (__builtin_object_size (r, 1) != sizeof (a.a) - 1) + FAIL (); + r = strcpy (r + 2, "cd") + 2; + if (__builtin_object_size (r, 1) != sizeof (a.a) - 5) + FAIL (); + if (__builtin_object_size (exta, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (exta + 10, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&exta[5], 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (extb, 1) != sizeof (extb)) + FAIL (); + if (__builtin_object_size (extb + 10, 1) != sizeof (extb) - 10) + FAIL (); + if (__builtin_object_size (&extb[5], 1) != sizeof (extb) - 5) + FAIL (); + if (__builtin_object_size (extc, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (extc + 10, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&extc[5], 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&extc->a, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&(extc + 10)->b, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&extc[5].c[3], 1) != (size_t) -1) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (var, 1) != x + 10) + FAIL (); + if (__builtin_object_size (var + 10, 1) != x) + FAIL (); + if (__builtin_object_size (&var[5], 1) != x + 5) + FAIL (); + if (__builtin_object_size (vara, 1) != (x + 10) * sizeof (struct A)) + FAIL (); + if (__builtin_object_size (vara + 10, 1) != x * sizeof (struct A)) + FAIL (); + if (__builtin_object_size (&vara[5], 1) != (x + 5) * sizeof (struct A)) + FAIL (); +#else + if (__builtin_object_size (var, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (var + 10, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&var[5], 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (vara, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (vara + 10, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&vara[5], 1) != (size_t) -1) + FAIL (); +#endif + if (__builtin_object_size (&vara[0].a, 1) != sizeof (vara[0].a)) + FAIL (); + if (__builtin_object_size (&vara[10].a[0], 1) != sizeof (vara[0].a)) + FAIL (); + if (__builtin_object_size (&vara[5].a[4], 1) != sizeof (vara[0].a) - 4) + FAIL (); + if (__builtin_object_size (&vara[5].b, 1) != sizeof (vara[0].b)) + FAIL (); + if (__builtin_object_size (&vara[7].c[7], 1) != sizeof (vara[0].c) - 7) + FAIL (); + if (__builtin_object_size (zerol, 1) != 0) + FAIL (); + if (__builtin_object_size (&zerol, 1) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0], 1) != 0) + FAIL (); + if (__builtin_object_size (zerol[0].a, 1) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0].a[0], 1) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0].b, 1) != 0) + FAIL (); + if (__builtin_object_size ("abcdefg", 1) != sizeof ("abcdefg")) + FAIL (); + if (__builtin_object_size ("abcd\0efg", 1) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg", 1) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg"[0], 1) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg"[4], 1) != sizeof ("abcd\0efg") - 4) + FAIL (); + if (__builtin_object_size ("abcd\0efg" + 5, 1) != sizeof ("abcd\0efg") - 5) + FAIL (); + if (__builtin_object_size (L"abcdefg", 1) != sizeof (L"abcdefg")) + FAIL (); + r = (char *) L"abcd\0efg"; + if (__builtin_object_size (r + 2, 1) != sizeof (L"abcd\0efg") - 2) + FAIL (); +} + +size_t l1 = 1; + +void +__attribute__ ((noinline)) +test2 (void) +{ + struct B { char buf1[10]; char buf2[10]; } a; + char *r, buf3[20]; + int i; +#ifdef __builtin_object_size + size_t dyn_res; +#endif + + if (sizeof (a) != 20) + return; + + r = buf3; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[1]; + else if (i == l1) + r = &a.buf2[7]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[9]; + } +#ifdef __builtin_object_size + dyn_res = sizeof (buf3); + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + dyn_res = sizeof (a.buf1) - 1; + else if (i == l1) + dyn_res = sizeof (a.buf2) - 7; + else if (i == l1 + 1) + dyn_res = sizeof (buf3) - 5; + else if (i == l1 + 2) + dyn_res = sizeof (a.buf1) - 9; + } + if (__builtin_object_size (r, 1) != dyn_res) + FAIL (); +#else + if (__builtin_object_size (r, 1) != sizeof (buf3)) + FAIL (); +#endif + r = &buf3[20]; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[7]; + else if (i == l1) + r = &a.buf2[7]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[9]; + } +#ifdef __builtin_object_size + dyn_res = sizeof (buf3) - 20; + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + dyn_res = sizeof (a.buf1) - 7; + else if (i == l1) + dyn_res = sizeof (a.buf2) - 7; + else if (i == l1 + 1) + dyn_res = sizeof (buf3) - 5; + else if (i == l1 + 2) + dyn_res = sizeof (a.buf1) - 9; + } + if (__builtin_object_size (r, 1) != dyn_res) + FAIL (); +#else + if (__builtin_object_size (r, 1) != sizeof (buf3) - 5) + FAIL (); +#endif + r += 8; +#ifdef __builtin_object_size + if (dyn_res >= 8) + { + dyn_res -= 8; + if (__builtin_object_size (r, 1) != dyn_res) + FAIL (); + + if (dyn_res >= 6) + { + if (__builtin_object_size (r + 6, 1) != dyn_res - 6) + FAIL (); + } + else if (__builtin_object_size (r + 6, 1) != 0) + FAIL (); + } + else if (__builtin_object_size (r, 1) != 0) + FAIL (); +#else + if (__builtin_object_size (r, 1) != sizeof (buf3) - 13) + FAIL (); + if (__builtin_object_size (r + 6, 1) != sizeof (buf3) - 19) + FAIL (); +#endif +} + +void +__attribute__ ((noinline)) +test3 (void) +{ + char buf4[10]; + struct B { struct A a[2]; struct A b; char c[4]; char d; double e; + _Complex double f; } x; + double y; + _Complex double z; + double *dp; + + if (__builtin_object_size (buf4, 1) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4, 1) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4[0], 1) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4[1], 1) != sizeof (buf4) - 1) + FAIL (); + if (__builtin_object_size (&x, 1) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a, 1) != sizeof (x.a)) + FAIL (); + if (__builtin_object_size (&x.a[0], 1) != sizeof (x.a)) + FAIL (); + if (__builtin_object_size (&x.a[0].a, 1) != sizeof (x.a[0].a)) + FAIL (); + if (__builtin_object_size (&x.a[0].a[0], 1) != sizeof (x.a[0].a)) + FAIL (); + if (__builtin_object_size (&x.a[0].a[3], 1) != sizeof (x.a[0].a) - 3) + FAIL (); + if (__builtin_object_size (&x.a[0].b, 1) != sizeof (x.a[0].b)) + FAIL (); + if (__builtin_object_size (&x.a[1].c, 1) != sizeof (x.a[1].c)) + FAIL (); + if (__builtin_object_size (&x.a[1].c[0], 1) != sizeof (x.a[1].c)) + FAIL (); + if (__builtin_object_size (&x.a[1].c[3], 1) != sizeof (x.a[1].c) - 3) + FAIL (); + if (__builtin_object_size (&x.b, 1) != sizeof (x.b)) + FAIL (); + if (__builtin_object_size (&x.b.a, 1) != sizeof (x.b.a)) + FAIL (); + if (__builtin_object_size (&x.b.a[0], 1) != sizeof (x.b.a)) + FAIL (); + if (__builtin_object_size (&x.b.a[3], 1) != sizeof (x.b.a) - 3) + FAIL (); + if (__builtin_object_size (&x.b.b, 1) != sizeof (x.b.b)) + FAIL (); + if (__builtin_object_size (&x.b.c, 1) != sizeof (x.b.c)) + FAIL (); + if (__builtin_object_size (&x.b.c[0], 1) != sizeof (x.b.c)) + FAIL (); + if (__builtin_object_size (&x.b.c[3], 1) != sizeof (x.b.c) - 3) + FAIL (); + if (__builtin_object_size (&x.c, 1) != sizeof (x.c)) + FAIL (); + if (__builtin_object_size (&x.c[0], 1) != sizeof (x.c)) + FAIL (); + if (__builtin_object_size (&x.c[1], 1) != sizeof (x.c) - 1) + FAIL (); + if (__builtin_object_size (&x.d, 1) != sizeof (x.d)) + FAIL (); + if (__builtin_object_size (&x.e, 1) != sizeof (x.e)) + FAIL (); + if (__builtin_object_size (&x.f, 1) != sizeof (x.f)) + FAIL (); + dp = &__real__ x.f; + if (__builtin_object_size (dp, 1) != sizeof (x.f) / 2) + FAIL (); + dp = &__imag__ x.f; + if (__builtin_object_size (dp, 1) != sizeof (x.f) / 2) + FAIL (); + dp = &y; + if (__builtin_object_size (dp, 1) != sizeof (y)) + FAIL (); + if (__builtin_object_size (&z, 1) != sizeof (z)) + FAIL (); + dp = &__real__ z; + if (__builtin_object_size (dp, 1) != sizeof (z) / 2) + FAIL (); + dp = &__imag__ z; + if (__builtin_object_size (dp, 1) != sizeof (z) / 2) + FAIL (); +} + +struct S { unsigned int a; }; + +char * +__attribute__ ((noinline)) +test4 (char *x, int y) +{ + register int i; + struct A *p; + + for (i = 0; i < y; i++) + { + p = (struct A *) x; + x = (char *) &p[1]; + if (__builtin_object_size (p, 1) != (size_t) -1) + FAIL (); + } + return x; +} + +void +__attribute__ ((noinline)) +test5 (size_t x) +{ + struct T { char buf[64]; char buf2[64]; } t; + char *p = &t.buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 1) != sizeof (t.buf) - 8 - 4 * x) + FAIL (); +#else + if (__builtin_object_size (p, 1) != sizeof (t.buf) - 8) + FAIL (); +#endif + memset (p, ' ', sizeof (t.buf) - 8 - 4 * 4); +} + +void +__attribute__ ((noinline)) +test6 (void) +{ + char buf[64]; + struct T { char buf[64]; char buf2[64]; } t; + char *p = &buf[64], *q = &t.buf[64]; + + if (__builtin_object_size (p + 64, 1) != 0) + FAIL (); + if (__builtin_object_size (q + 0, 1) != 0) + FAIL (); + if (__builtin_object_size (q + 64, 1) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test7 (void) +{ + struct T { char buf[10]; char buf2[10]; } t; + char *p = &t.buf2[-4]; + char *q = &t.buf2[0]; + if (__builtin_object_size (p, 1) != 0) + FAIL (); + if (__builtin_object_size (q, 1) != sizeof (t.buf2)) + FAIL (); + q = &t.buf[10]; + if (__builtin_object_size (q, 1) != 0) + FAIL (); + q = &t.buf[11]; + if (__builtin_object_size (q, 1) != 0) + FAIL (); + p = &t.buf[-4]; + if (__builtin_object_size (p, 1) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test8 (unsigned cond) +{ + char *buf2 = malloc (10); + char *p; + + if (cond) + p = &buf2[8]; + else + p = &buf2[4]; + +#ifdef __builtin_object_size + if (__builtin_object_size (&p[-4], 1) != (cond ? 6 : 10)) + FAIL (); +#else + if (__builtin_object_size (&p[-4], 1) != 10) + FAIL (); +#endif + + for (unsigned i = cond; i > 0; i--) + p--; + +#ifdef __builtin_object_size + if (__builtin_object_size (p, 1) != ((cond ? 2 : 6) + cond)) + FAIL (); +#else + if (__builtin_object_size (p, 1) != 10) + FAIL (); +#endif + + p = &y.c[8]; + for (unsigned i = cond; i > 0; i--) + p--; + +#ifdef __builtin_object_size + if (__builtin_object_size (p, 1) != sizeof (y.c) - 8 + cond) + FAIL (); +#else + if (__builtin_object_size (p, 1) != sizeof (y.c)) + FAIL (); +#endif +} + +/* Tests for strdup/strndup. */ +size_t +__attribute__ ((noinline)) +test9 (void) +{ + const char *ptr = "abcdefghijklmnopqrstuvwxyz"; + char *res = strndup (ptr, 21); + if (__builtin_object_size (res, 1) != 22) + FAIL (); + + free (res); + + res = strndup (ptr, 32); + if (__builtin_object_size (res, 1) != 27) + FAIL (); + + free (res); + + res = strdup (ptr); + if (__builtin_object_size (res, 1) != 27) + FAIL (); + + free (res); + + char *ptr2 = malloc (64); + strcpy (ptr2, ptr); + + res = strndup (ptr2, 21); + if (__builtin_object_size (res, 1) != 22) + FAIL (); + + free (res); + + res = strndup (ptr2, 32); + if (__builtin_object_size (res, 1) != 33) + FAIL (); + + free (res); + + res = strndup (ptr2, 128); + if (__builtin_object_size (res, 1) != 64) + FAIL (); + + free (res); + + res = strdup (ptr2); +#ifdef __builtin_object_size + if (__builtin_object_size (res, 1) != 27) +#else + if (__builtin_object_size (res, 1) != (size_t) -1) +#endif + FAIL (); + + free (res); + free (ptr2); + + ptr = "abcd\0efghijklmnopqrstuvwxyz"; + res = strdup (ptr); + if (__builtin_object_size (res, 1) != 5) + FAIL (); + free (res); + + res = strndup (ptr, 24); + if (__builtin_object_size (res, 1) != 5) + FAIL (); + free (res); + + res = strndup (ptr, 2); + if (__builtin_object_size (res, 1) != 3) + FAIL (); + free (res); + + res = strdup (&ptr[4]); + if (__builtin_object_size (res, 1) != 1) + FAIL (); + free (res); + + res = strndup (&ptr[4], 4); + if (__builtin_object_size (res, 1) != 1) + FAIL (); + free (res); + + res = strndup (&ptr[4], 1); + if (__builtin_object_size (res, 1) != 1) + FAIL (); + free (res); +} + +int +main (void) +{ + struct S s[10]; + __asm ("" : "=r" (l1) : "0" (l1)); + test1 (main, 6); + test2 (); + test3 (); + test4 ((char *) s, 10); + test5 (4); + test6 (); + test7 (); + test8 (1); + test9 (); + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-20.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-20.c new file mode 100644 index 0000000000..f40e3dcc1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-20.c @@ -0,0 +1,255 @@ +/* PR middle-end/92815 - spurious -Wstringop-overflow writing into + a flexible array of an extern struct + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } + { dg-skip-if "test assumes that structs have padding" { default_packed } } */ + +#define ASSERT(expr) ((expr) ? (void)0 : fail (__LINE__)) +#define bos0(expr) __builtin_object_size (expr, 1) +#define bos1(expr) __builtin_object_size (expr, 1) +#define bos2(expr) __builtin_object_size (expr, 2) +#define bos3(expr) __builtin_object_size (expr, 3) + +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; +typedef __INT64_TYPE__ int64_t; +typedef __SIZE_TYPE__ size_t; + + +extern void fail (int); + + + + +/* Verify sizes of a struct with a flexible array member and 1 byte + of tail padding. */ + +struct AI16CX { int16_t i; char n, a[]; }; + +struct AI16CX ai16c0 = { 0 }; +struct AI16CX ai16c1 = { 0, 1, { 1 } }; +struct AI16CX ai16c2 = { 0, 2, { 1, 2 } }; +struct AI16CX ai16c3 = { 0, 3, { 1, 2, 3 } }; +struct AI16CX ai16c4 = { 0, 4, { 1, 2, 3, 4 } }; +struct AI16CX ai16c5 = { 0, 5, { 1, 2, 3, 4, 5 } }; +struct AI16CX ai16c6 = { 0, 6, { 1, 2, 3, 4, 5, 6 } }; +struct AI16CX ai16c7 = { 0, 7, { 1, 2, 3, 4, 5, 6, 7 } }; +struct AI16CX ai16c8 = { 0, 8, { 1, 2, 3, 4, 5, 6, 7, 8 } }; + +extern struct AI16CX eai16cx; + +void fai16cx (void) +{ + ASSERT (bos0 (&ai16c0) == sizeof ai16c0); + ASSERT (bos0 (&ai16c1) == sizeof ai16c1); + ASSERT (bos0 (&ai16c2) == sizeof ai16c2 + 1); + ASSERT (bos0 (&ai16c3) == sizeof ai16c3 + 2); + + ASSERT (bos0 (&ai16c4) == sizeof ai16c4 + 3); + ASSERT (bos0 (&ai16c5) == sizeof ai16c5 + 4); + ASSERT (bos0 (&ai16c6) == sizeof ai16c6 + 5); + ASSERT (bos0 (&ai16c7) == sizeof ai16c6 + 6); + ASSERT (bos0 (&ai16c8) == sizeof ai16c6 + 7); + + ASSERT (bos0 (&eai16cx) == (size_t)-1); + + + ASSERT (bos1 (&ai16c0) == sizeof ai16c0); + ASSERT (bos1 (&ai16c1) == sizeof ai16c1); + ASSERT (bos1 (&ai16c2) == sizeof ai16c2 + 1); + ASSERT (bos1 (&ai16c3) == sizeof ai16c3 + 2); + + ASSERT (bos1 (&ai16c4) == sizeof ai16c4 + 3); + ASSERT (bos1 (&ai16c5) == sizeof ai16c5 + 4); + ASSERT (bos1 (&ai16c6) == sizeof ai16c6 + 5); + ASSERT (bos1 (&ai16c7) == sizeof ai16c6 + 6); + ASSERT (bos1 (&ai16c8) == sizeof ai16c6 + 7); + + ASSERT (bos1 (&eai16cx) == (size_t)-1); + + + ASSERT (bos2 (&ai16c0) == sizeof ai16c0); + ASSERT (bos2 (&ai16c1) == sizeof ai16c1); + ASSERT (bos2 (&ai16c2) == sizeof ai16c2 + 1); + ASSERT (bos2 (&ai16c3) == sizeof ai16c3 + 2); + + ASSERT (bos2 (&ai16c4) == sizeof ai16c4 + 3); + ASSERT (bos2 (&ai16c5) == sizeof ai16c5 + 4); + ASSERT (bos2 (&ai16c6) == sizeof ai16c6 + 5); + ASSERT (bos2 (&ai16c7) == sizeof ai16c6 + 6); + ASSERT (bos2 (&ai16c8) == sizeof ai16c6 + 7); + + ASSERT (bos2 (&eai16cx) == sizeof eai16cx); + + + ASSERT (bos3 (&ai16c0) == sizeof ai16c0); + ASSERT (bos3 (&ai16c1) == sizeof ai16c1); + ASSERT (bos3 (&ai16c2) == sizeof ai16c2 + 1); + ASSERT (bos3 (&ai16c3) == sizeof ai16c3 + 2); + + ASSERT (bos3 (&ai16c4) == sizeof ai16c4 + 3); + ASSERT (bos3 (&ai16c5) == sizeof ai16c5 + 4); + ASSERT (bos3 (&ai16c6) == sizeof ai16c6 + 5); + ASSERT (bos3 (&ai16c7) == sizeof ai16c6 + 6); + ASSERT (bos3 (&ai16c8) == sizeof ai16c6 + 7); + + ASSERT (bos3 (&eai16cx) == sizeof eai16cx); +} + + +/* Verify sizes of a struct with a flexible array member and 3 bytes + of tail padding. */ + +struct AI32CX { int32_t i; char n, a[]; }; + +struct AI32CX ai32c0 = { 0 }; +struct AI32CX ai32c1 = { 0, 1, { 1 } }; +struct AI32CX ai32c2 = { 0, 2, { 1, 2 } }; +struct AI32CX ai32c3 = { 0, 3, { 1, 2, 3 } }; +struct AI32CX ai32c4 = { 0, 4, { 1, 2, 3, 4 } }; +struct AI32CX ai32c5 = { 0, 5, { 1, 2, 3, 4, 5 } }; +struct AI32CX ai32c6 = { 0, 6, { 1, 2, 3, 4, 5, 6 } }; +struct AI32CX ai32c7 = { 0, 7, { 1, 2, 3, 4, 5, 6, 7 } }; +struct AI32CX ai32c8 = { 0, 8, { 1, 2, 3, 4, 5, 6, 7, 8 } }; + +extern struct AI32CX eai32cx; + +void fai32cx (void) +{ + ASSERT (bos0 (&ai32c0) == sizeof ai32c0); + ASSERT (bos0 (&ai32c1) == sizeof ai32c1); + ASSERT (bos0 (&ai32c2) == sizeof ai32c2); + ASSERT (bos0 (&ai32c3) == sizeof ai32c3); + + ASSERT (bos0 (&ai32c4) == sizeof ai32c4 + 1); + ASSERT (bos0 (&ai32c5) == sizeof ai32c5 + 2); + ASSERT (bos0 (&ai32c6) == sizeof ai32c6 + 3); + ASSERT (bos0 (&ai32c7) == sizeof ai32c6 + 4); + ASSERT (bos0 (&ai32c8) == sizeof ai32c6 + 5); + + ASSERT (bos0 (&eai32cx) == (size_t)-1); + + + ASSERT (bos1 (&ai32c0) == sizeof ai32c0); + ASSERT (bos1 (&ai32c1) == sizeof ai32c1); + ASSERT (bos1 (&ai32c2) == sizeof ai32c2); + ASSERT (bos1 (&ai32c3) == sizeof ai32c3); + + ASSERT (bos1 (&ai32c4) == sizeof ai32c4 + 1); + ASSERT (bos1 (&ai32c5) == sizeof ai32c5 + 2); + ASSERT (bos1 (&ai32c6) == sizeof ai32c6 + 3); + ASSERT (bos1 (&ai32c7) == sizeof ai32c6 + 4); + ASSERT (bos1 (&ai32c8) == sizeof ai32c6 + 5); + + ASSERT (bos1 (&eai32cx) == (size_t)-1); + + + ASSERT (bos2 (&ai32c0) == sizeof ai32c0); + ASSERT (bos2 (&ai32c1) == sizeof ai32c1); + ASSERT (bos2 (&ai32c2) == sizeof ai32c2); + ASSERT (bos2 (&ai32c3) == sizeof ai32c3); + + ASSERT (bos2 (&ai32c4) == sizeof ai32c4 + 1); + ASSERT (bos2 (&ai32c5) == sizeof ai32c5 + 2); + ASSERT (bos2 (&ai32c6) == sizeof ai32c6 + 3); + ASSERT (bos2 (&ai32c7) == sizeof ai32c6 + 4); + ASSERT (bos2 (&ai32c8) == sizeof ai32c6 + 5); + + ASSERT (bos2 (&eai32cx) == sizeof eai32cx); + + + ASSERT (bos3 (&ai32c0) == sizeof ai32c0); + ASSERT (bos3 (&ai32c1) == sizeof ai32c1); + ASSERT (bos3 (&ai32c2) == sizeof ai32c2); + ASSERT (bos3 (&ai32c3) == sizeof ai32c3); + + ASSERT (bos3 (&ai32c4) == sizeof ai32c4 + 1); + ASSERT (bos3 (&ai32c5) == sizeof ai32c5 + 2); + ASSERT (bos3 (&ai32c6) == sizeof ai32c6 + 3); + ASSERT (bos3 (&ai32c7) == sizeof ai32c6 + 4); + ASSERT (bos3 (&ai32c8) == sizeof ai32c6 + 5); + + ASSERT (bos3 (&eai32cx) == sizeof eai32cx); +} + + +/* Verify sizes of a struct with a flexible array member and 7 bytes + of tail padding. */ + +struct AI64CX { int64_t i __attribute__ ((aligned (8))); char n, a[]; }; + +struct AI64CX ai64c0 = { 0 }; +struct AI64CX ai64c1 = { 0, 1, { 1 } }; +struct AI64CX ai64c2 = { 0, 2, { 1, 2 } }; +struct AI64CX ai64c3 = { 0, 3, { 1, 2, 3 } }; +struct AI64CX ai64c4 = { 0, 4, { 1, 2, 3, 4 } }; +struct AI64CX ai64c5 = { 0, 5, { 1, 2, 3, 4, 5 } }; +struct AI64CX ai64c6 = { 0, 6, { 1, 2, 3, 4, 5, 6 } }; +struct AI64CX ai64c7 = { 0, 7, { 1, 2, 3, 4, 5, 6, 7 } }; +struct AI64CX ai64c8 = { 0, 8, { 1, 2, 3, 4, 5, 6, 7, 8 } }; +struct AI64CX ai64c9 = { 0, 8, { 1, 2, 3, 4, 5, 6, 7, 8, 9 } }; + +extern struct AI64CX eai64cx; + +void fai64cx (void) +{ + ASSERT (bos0 (&ai64c0) == sizeof ai64c0); + ASSERT (bos0 (&ai64c1) == sizeof ai64c1); + ASSERT (bos0 (&ai64c2) == sizeof ai64c2); + ASSERT (bos0 (&ai64c3) == sizeof ai64c3); + ASSERT (bos0 (&ai64c4) == sizeof ai64c4); + ASSERT (bos0 (&ai64c5) == sizeof ai64c5); + ASSERT (bos0 (&ai64c6) == sizeof ai64c6); + ASSERT (bos0 (&ai64c7) == sizeof ai64c7); + + ASSERT (bos0 (&ai64c8) == sizeof ai64c8 + 1); + ASSERT (bos0 (&ai64c9) == sizeof ai64c9 + 2); + + ASSERT (bos0 (&eai64cx) == (size_t)-1); + + + ASSERT (bos1 (&ai64c0) == sizeof ai64c0); + ASSERT (bos1 (&ai64c1) == sizeof ai64c1); + ASSERT (bos1 (&ai64c2) == sizeof ai64c2); + ASSERT (bos1 (&ai64c3) == sizeof ai64c3); + ASSERT (bos1 (&ai64c4) == sizeof ai64c4); + ASSERT (bos1 (&ai64c5) == sizeof ai64c5); + ASSERT (bos1 (&ai64c6) == sizeof ai64c6); + ASSERT (bos1 (&ai64c7) == sizeof ai64c7); + + ASSERT (bos1 (&ai64c8) == sizeof ai64c8 + 1); + ASSERT (bos1 (&ai64c9) == sizeof ai64c9 + 2); + + ASSERT (bos1 (&eai64cx) == (size_t)-1); + + + ASSERT (bos2 (&ai64c0) == sizeof ai64c0); + ASSERT (bos2 (&ai64c1) == sizeof ai64c1); + ASSERT (bos2 (&ai64c2) == sizeof ai64c2); + ASSERT (bos2 (&ai64c3) == sizeof ai64c3); + ASSERT (bos2 (&ai64c4) == sizeof ai64c4); + ASSERT (bos2 (&ai64c5) == sizeof ai64c5); + ASSERT (bos2 (&ai64c6) == sizeof ai64c6); + ASSERT (bos2 (&ai64c7) == sizeof ai64c7); + + ASSERT (bos2 (&ai64c8) == sizeof ai64c8 + 1); + ASSERT (bos2 (&ai64c9) == sizeof ai64c9 + 2); + + ASSERT (bos2 (&eai64cx) == sizeof eai64cx); + + ASSERT (bos3 (&ai64c0) == sizeof ai64c0); + ASSERT (bos3 (&ai64c1) == sizeof ai64c1); + ASSERT (bos3 (&ai64c2) == sizeof ai64c2); + ASSERT (bos3 (&ai64c3) == sizeof ai64c3); + ASSERT (bos3 (&ai64c4) == sizeof ai64c4); + ASSERT (bos3 (&ai64c5) == sizeof ai64c5); + ASSERT (bos3 (&ai64c6) == sizeof ai64c6); + ASSERT (bos3 (&ai64c7) == sizeof ai64c7); + + ASSERT (bos3 (&ai64c8) == sizeof ai64c8 + 1); + ASSERT (bos3 (&ai64c9) == sizeof ai64c9 + 2); + + ASSERT (bos3 (&eai64cx) == sizeof eai64cx); +} + +/* { dg-final { scan-tree-dump-not "fail" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-21.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-21.c new file mode 100644 index 0000000000..7e0f85ffdf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-21.c @@ -0,0 +1,52 @@ +/* PR middle-end/92815 - spurious -Wstringop-overflow writing into + a flexible array of an extern struct + { dg-do compile } + { dg-options "-Wall -fdump-tree-optimized" } + { dg-require-effective-target large_initializer } */ + +#define PTRDIFF_MAX __PTRDIFF_MAX__ + +typedef __SIZE_TYPE__ size_t; + +#define bos0(expr) __builtin_object_size (expr, 0) +#define bos1(expr) __builtin_object_size (expr, 1) +#define bos2(expr) __builtin_object_size (expr, 2) +#define bos3(expr) __builtin_object_size (expr, 3) + +void fail (const char*, ...); + +#define A(x, n01, n23) \ + ((bos0 (&x) == n01 ? (void)0 : fail (#x, __LINE__, bos0 (&x), n01)), \ + (bos1 (&x) == n01 ? (void)0 : fail (#x, __LINE__, bos1 (&x), n01)), \ + (bos2 (&x) == n23 ? (void)0 : fail (#x, __LINE__, bos2 (&x), n23)), \ + (bos3 (&x) == n23 ? (void)0 : fail (#x, __LINE__, bos3 (&x), n23))) + +struct Ax_m3 { char a[PTRDIFF_MAX - 3], ax[]; }; + +struct Ax_m3 xm3_0 = { { 0 } }; +struct Ax_m3 xm3_1 = { { 0 }, { 1 } }; +struct Ax_m3 xm3_2 = { { 0 }, { 1, 2 } }; +struct Ax_m3 xm3_3 = { { 0 }, { 1, 2, 3 } }; +struct Ax_m3 xm3_4 = { { 0 }, { 1, 2, 3, 3 } }; // { dg-error "too large" } + +void test_axm3 (void) +{ + A (xm3_0, sizeof xm3_0, sizeof xm3_0); + A (xm3_1, sizeof xm3_1 + 1, sizeof xm3_1 + 1); + A (xm3_2, sizeof xm3_2 + 2, sizeof xm3_2 + 2); + A (xm3_3, (size_t)-1, 0); // expect failure + A (xm3_4, (size_t)-1, 0); // expect failure +} + + +struct Ax_mx { char a[PTRDIFF_MAX], ax[]; }; +struct Ax_mx xmx_0 = { { 0 } }; +struct Ax_mx xmx_1 = { { 0 }, { 1 } }; // { dg-error "too large" } +extern struct Ax_mx xmx_x; + +void test_axmx (void) +{ + A (xmx_0, (size_t)-1, 0); // expect failure + A (xmx_1, (size_t)-1, 0); // expect failure + A (xmx_x, (size_t)-1, 0); // expect failure +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-22.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-22.c new file mode 100644 index 0000000000..1e55229c94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-22.c @@ -0,0 +1,79 @@ +/* PR middle-end/92815 - a variant of gcc.dg/builtin-object-size-20.c + prepared for all targets, irregardless if they pack or not + the structs by default. + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } */ + +#define ASSERT(expr) ((expr) ? (void)0 : fail (__LINE__)) +#define bos0(expr) __builtin_object_size (expr, 1) +#define bos1(expr) __builtin_object_size (expr, 1) +#define bos2(expr) __builtin_object_size (expr, 2) +#define bos3(expr) __builtin_object_size (expr, 3) + +typedef __SIZE_TYPE__ size_t; + + +extern void fail (int); + + +/* Verify sizes of a struct with a flexible array member and no padding. */ + +struct ACX { char n, a[]; }; + +struct ACX ac0 = { }; +struct ACX ac1 = { 1, { 1 } }; +struct ACX ac2 = { 2, { 1, 2 } }; +struct ACX ac3 = { 3, { 1, 2, 3 } }; + +extern struct ACX eacx; + +void facx (void) +{ + ASSERT (bos0 (&ac0) == sizeof ac0); + ASSERT (bos0 (&ac1) == 2); + ASSERT (bos0 (&ac2) == 3); + ASSERT (bos0 (&ac3) == 4); + ASSERT (bos0 (&eacx) == (size_t)-1); + + ASSERT (bos1 (&ac0) == sizeof ac0); + ASSERT (bos1 (&ac1) == 2); + ASSERT (bos1 (&ac2) == 3); + ASSERT (bos1 (&ac3) == 4); + ASSERT (bos1 (&eacx) == (size_t)-1); + + ASSERT (bos2 (&ac0) == sizeof ac0); + ASSERT (bos2 (&ac1) == 2); + ASSERT (bos2 (&ac2) == 3); + ASSERT (bos2 (&ac3) == 4); + ASSERT (bos2 (&eacx) == sizeof eacx); + + ASSERT (bos3 (&ac0) == sizeof ac0); + ASSERT (bos3 (&ac1) == 2); + ASSERT (bos3 (&ac2) == 3); + ASSERT (bos3 (&ac3) == 4); + ASSERT (bos3 (&eacx) == sizeof eacx); +} + +/* Also verify sizes of a struct with a zero length array member. */ + +struct A0C0 { char n, a[0]; }; + +struct A0C0 a0c0 = { }; +extern struct A0C0 ea0c0; + +void fa0c0 (void) +{ + ASSERT (bos0 (&a0c0) == sizeof a0c0); + ASSERT (bos0 (&ea0c0) == sizeof ea0c0); + + ASSERT (bos1 (&a0c0) == sizeof a0c0); + ASSERT (bos1 (&a0c0) == sizeof ea0c0); + + ASSERT (bos2 (&a0c0) == sizeof a0c0); + ASSERT (bos2 (&a0c0) == sizeof ea0c0); + + ASSERT (bos3 (&a0c0) == sizeof a0c0); + ASSERT (bos3 (&a0c0) == sizeof ea0c0); +} + +/* { dg-final { scan-tree-dump-not "fail" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-3.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-3.c new file mode 100644 index 0000000000..3d907ef481 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-3.c @@ -0,0 +1,737 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +#include "builtin-object-size-common.h" + +struct A +{ + char a[10]; + int b; + char c[10]; +} y, w[4]; + +extern char exta[]; +extern char extb[30]; +extern struct A zerol[0]; + +void +__attribute__ ((noinline)) +test1 (void *q, int x) +{ + struct A a; + void *p = &a.a[3], *r; + char var[x + 10]; + if (x < 0) + r = &a.a[9]; + else + r = &a.c[1]; + if (__builtin_object_size (p, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 3) + FAIL (); + if (__builtin_object_size (&a.c[9], 2) + != sizeof (a) - __builtin_offsetof (struct A, c) - 9) + FAIL (); + if (__builtin_object_size (q, 2) != 0) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 2) + != (x < 0 + ? sizeof (a) - __builtin_offsetof (struct A, a) - 9 + : sizeof (a) - __builtin_offsetof (struct A, c) - 1)) + FAIL (); +#else + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, c) - 1) + FAIL (); +#endif + if (x < 6) + r = &w[2].a[1]; + else + r = &a.a[6]; + if (__builtin_object_size (&y, 2) + != sizeof (y)) + FAIL (); + if (__builtin_object_size (w, 2) + != sizeof (w)) + FAIL (); + if (__builtin_object_size (&y.b, 2) + != sizeof (a) - __builtin_offsetof (struct A, b)) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 2) + != (x < 6 + ? 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1 + : sizeof (a) - __builtin_offsetof (struct A, a) - 6)) + FAIL (); +#else + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 6) + FAIL (); +#endif + if (x < 20) + r = malloc (30); + else + r = calloc (2, 16); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 2) != (x < 20 ? 30 : 2 * 16)) + FAIL (); +#else + if (__builtin_object_size (r, 2) != 30) + FAIL (); +#endif + if (x < 20) + r = malloc (30); + else + r = calloc (2, 14); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 2) != (x < 20 ? 30 : 2 * 14)) + FAIL (); +#else + if (__builtin_object_size (r, 2) != 2 * 14) + FAIL (); +#endif + if (x < 30) + r = malloc (sizeof (a)); + else + r = &a.a[3]; +#ifdef __builtin_object_size + size_t objsz = (x < 30 ? sizeof (a) + : sizeof (a) - __builtin_offsetof (struct A, a) - 3); + if (__builtin_object_size (r, 2) != objsz) + FAIL (); +#else + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 3) + FAIL (); +#endif + r = memcpy (r, "a", 2); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 2) != objsz) + FAIL (); +#else + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 3) + FAIL (); +#endif + r = memcpy (r + 2, "b", 2) + 2; +#ifdef __builtin_object_size + if (__builtin_object_size (r, 2) != objsz - 4) + FAIL (); +#else + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 3 - 4) + FAIL (); +#endif + r = &a.a[4]; + r = memset (r, 'a', 2); + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 4) + FAIL (); + r = memset (r + 2, 'b', 2) + 2; + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 8) + FAIL (); + r = &a.a[1]; + r = strcpy (r, "ab"); + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 1) + FAIL (); + r = strcpy (r + 2, "cd") + 2; + if (__builtin_object_size (r, 2) + != sizeof (a) - __builtin_offsetof (struct A, a) - 5) + FAIL (); + if (__builtin_object_size (exta, 2) != 0) + FAIL (); + if (__builtin_object_size (exta + 10, 2) != 0) + FAIL (); + if (__builtin_object_size (&exta[5], 2) != 0) + FAIL (); + if (__builtin_object_size (extb, 2) != sizeof (extb)) + FAIL (); + if (__builtin_object_size (extb + 10, 2) != sizeof (extb) - 10) + FAIL (); + if (__builtin_object_size (&extb[5], 2) != sizeof (extb) - 5) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (var, 2) != x + 10) + FAIL (); + if (__builtin_object_size (var + 10, 2) != x) + FAIL (); + if (__builtin_object_size (&var[5], 2) != x + 5) + FAIL (); +#else + if (__builtin_object_size (var, 2) != 0) + FAIL (); + if (__builtin_object_size (var + 10, 2) != 0) + FAIL (); + if (__builtin_object_size (&var[5], 2) != 0) + FAIL (); +#endif + if (__builtin_object_size (zerol, 2) != 0) + FAIL (); + if (__builtin_object_size (&zerol, 2) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0], 2) != 0) + FAIL (); + if (__builtin_object_size (zerol[0].a, 2) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0].a[0], 2) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0].b, 2) != 0) + FAIL (); + if (__builtin_object_size ("abcdefg", 2) != sizeof ("abcdefg")) + FAIL (); + if (__builtin_object_size ("abcd\0efg", 2) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg", 2) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg"[0], 2) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg"[4], 2) != sizeof ("abcd\0efg") - 4) + FAIL (); + if (__builtin_object_size ("abcd\0efg" + 5, 2) != sizeof ("abcd\0efg") - 5) + FAIL (); + if (__builtin_object_size (L"abcdefg", 2) != sizeof (L"abcdefg")) + FAIL (); + r = (char *) L"abcd\0efg"; + if (__builtin_object_size (r + 2, 2) != sizeof (L"abcd\0efg") - 2) + FAIL (); +} + +size_t l1 = 1; + +void +__attribute__ ((noinline)) +test2 (void) +{ + struct B { char buf1[10]; char buf2[10]; } a; + char *r, buf3[20]; + int i; +#ifdef __builtin_object_size + size_t dyn_res; +#endif + + if (sizeof (a) != 20) + return; + + r = buf3; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[1]; + else if (i == l1) + r = &a.buf2[7]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[9]; + } +#ifdef __builtin_object_size + dyn_res = sizeof (buf3); + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 1; + else if (i == l1) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7; + else if (i == l1 + 1) + dyn_res = sizeof (buf3) - 5; + else if (i == l1 + 2) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; + } + if (__builtin_object_size (r, 2) != dyn_res) + FAIL (); +#else + if (__builtin_object_size (r, 2) != 3) + FAIL (); +#endif + r = &buf3[20]; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[7]; + else if (i == l1) + r = &a.buf2[7]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[9]; + } + if (__builtin_object_size (r, 2) != 0) + FAIL (); + r = &buf3[2]; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[1]; + else if (i == l1) + r = &a.buf1[2]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[4]; + } +#ifdef __builtin_object_size + dyn_res = sizeof (buf3) - 2; + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 1; + else if (i == l1) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 2; + else if (i == l1 + 1) + dyn_res = sizeof (buf3) - 5; + else if (i == l1 + 2) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 4; + } + if (__builtin_object_size (r, 2) != dyn_res) + FAIL (); +#else + if (__builtin_object_size (r, 2) != 15) + FAIL (); +#endif + r += 8; +#ifdef __builtin_object_size + dyn_res -= 8; + if (__builtin_object_size (r, 2) != dyn_res) + FAIL (); + if (dyn_res >= 6) + { + if (__builtin_object_size (r + 6, 2) != dyn_res - 6) + FAIL (); + } + else if (__builtin_object_size (r + 6, 2) != 0) + FAIL (); +#else + if (__builtin_object_size (r, 2) != 7) + FAIL (); + if (__builtin_object_size (r + 6, 2) != 1) + FAIL (); +#endif + r = &buf3[18]; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[9]; + else if (i == l1) + r = &a.buf2[9]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[4]; + } +#ifdef __builtin_object_size + dyn_res = sizeof (buf3) - 18; + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9; + else if (i == l1) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 9; + else if (i == l1 + 1) + dyn_res = sizeof (buf3) - 5; + else if (i == l1 + 2) + dyn_res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 4; + } + if (dyn_res >= 12) + { + if (__builtin_object_size (r + 12, 2) != dyn_res - 12) + FAIL (); + } + else if (__builtin_object_size (r + 12, 2) != 0) + FAIL (); +#else + if (__builtin_object_size (r + 12, 2) != 0) + FAIL (); +#endif +} + +void +__attribute__ ((noinline)) +test3 (void) +{ + char buf4[10]; + struct B { struct A a[2]; struct A b; char c[4]; char d; double e; + _Complex double f; } x; + double y; + _Complex double z; + double *dp; + + if (__builtin_object_size (buf4, 2) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4, 2) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4[0], 2) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4[1], 2) != sizeof (buf4) - 1) + FAIL (); + if (__builtin_object_size (&x, 2) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a, 2) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a[0], 2) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a[0].a, 2) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a[0].a[0], 2) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a[0].a[3], 2) != sizeof (x) - 3) + FAIL (); + if (__builtin_object_size (&x.a[0].b, 2) + != sizeof (x) - __builtin_offsetof (struct A, b)) + FAIL (); + if (__builtin_object_size (&x.a[1].c, 2) + != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&x.a[1].c[0], 2) + != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&x.a[1].c[3], 2) + != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c) - 3) + FAIL (); + if (__builtin_object_size (&x.b, 2) + != sizeof (x) - __builtin_offsetof (struct B, b)) + FAIL (); + if (__builtin_object_size (&x.b.a, 2) + != sizeof (x) - __builtin_offsetof (struct B, b)) + FAIL (); + if (__builtin_object_size (&x.b.a[0], 2) + != sizeof (x) - __builtin_offsetof (struct B, b)) + FAIL (); + if (__builtin_object_size (&x.b.a[3], 2) + != sizeof (x) - __builtin_offsetof (struct B, b) - 3) + FAIL (); + if (__builtin_object_size (&x.b.b, 2) + != sizeof (x) - __builtin_offsetof (struct B, b) + - __builtin_offsetof (struct A, b)) + FAIL (); + if (__builtin_object_size (&x.b.c, 2) + != sizeof (x) - __builtin_offsetof (struct B, b) + - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&x.b.c[0], 2) + != sizeof (x) - __builtin_offsetof (struct B, b) + - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&x.b.c[3], 2) + != sizeof (x) - __builtin_offsetof (struct B, b) + - __builtin_offsetof (struct A, c) - 3) + FAIL (); + if (__builtin_object_size (&x.c, 2) + != sizeof (x) - __builtin_offsetof (struct B, c)) + FAIL (); + if (__builtin_object_size (&x.c[0], 2) + != sizeof (x) - __builtin_offsetof (struct B, c)) + FAIL (); + if (__builtin_object_size (&x.c[1], 2) + != sizeof (x) - __builtin_offsetof (struct B, c) - 1) + FAIL (); + if (__builtin_object_size (&x.d, 2) + != sizeof (x) - __builtin_offsetof (struct B, d)) + FAIL (); + if (__builtin_object_size (&x.e, 2) + != sizeof (x) - __builtin_offsetof (struct B, e)) + FAIL (); + if (__builtin_object_size (&x.f, 2) + != sizeof (x) - __builtin_offsetof (struct B, f)) + FAIL (); + dp = &__real__ x.f; + if (__builtin_object_size (dp, 2) + != sizeof (x) - __builtin_offsetof (struct B, f)) + FAIL (); + dp = &__imag__ x.f; + if (__builtin_object_size (dp, 2) + != sizeof (x) - __builtin_offsetof (struct B, f) + - sizeof (x.f) / 2) + FAIL (); + dp = &y; + if (__builtin_object_size (dp, 2) != sizeof (y)) + FAIL (); + if (__builtin_object_size (&z, 2) != sizeof (z)) + FAIL (); + dp = &__real__ z; + if (__builtin_object_size (dp, 2) != sizeof (z)) + FAIL (); + dp = &__imag__ z; + if (__builtin_object_size (dp, 2) != sizeof (z) / 2) + FAIL (); +} + +struct S { unsigned int a; }; + +char * +__attribute__ ((noinline)) +test4 (char *x, int y) +{ + register int i; + struct A *p; + + for (i = 0; i < y; i++) + { + p = (struct A *) x; + x = (char *) &p[1]; + if (__builtin_object_size (p, 2) != 0) + FAIL (); + } + return x; +} + +void +__attribute__ ((noinline)) +test5 (size_t x) +{ + char buf[64]; + char *p = &buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 2) != sizeof (buf) - 8 - 4 * x) +#else + if (__builtin_object_size (p, 2) != 0) +#endif + FAIL (); + memset (p, ' ', sizeof (buf) - 8 - 4 * 4); +} + +void +__attribute__ ((noinline)) +test6 (size_t x) +{ + struct T { char buf[64]; char buf2[64]; } t; + char *p = &t.buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 2) != sizeof (t) - 8 - 4 * x) +#else + if (__builtin_object_size (p, 2) != 0) +#endif + FAIL (); + memset (p, ' ', sizeof (t) - 8 - 4 * 4); +} + +void +__attribute__ ((noinline)) +test7 (void) +{ + char buf[64]; + struct T { char buf[64]; char buf2[64]; } t; + char *p = &buf[64], *q = &t.buf[64]; + + if (__builtin_object_size (p + 64, 2) != 0) + FAIL (); + if (__builtin_object_size (q + 63, 2) != sizeof (t) - 64 - 63) + FAIL (); + if (__builtin_object_size (q + 64, 2) != sizeof (t) - 64 - 64) + FAIL (); + if (__builtin_object_size (q + 256, 2) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test8 (void) +{ + struct T { char buf[10]; char buf2[10]; } t; + char *p = &t.buf2[-4]; + char *q = &t.buf2[0]; + if (__builtin_object_size (p, 2) != sizeof (t) - 10 + 4) + FAIL (); + if (__builtin_object_size (q, 2) != sizeof (t) - 10) + FAIL (); + /* GCC only handles additions, not subtractions. */ + q = q - 8; + if (__builtin_object_size (q, 2) != 0 + && __builtin_object_size (q, 2) != sizeof (t) - 10 + 8) + FAIL (); + p = &t.buf[-4]; + if (__builtin_object_size (p, 2) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test9 (unsigned cond) +{ + char *buf2 = malloc (10); + char *p; + + if (cond) + p = &buf2[8]; + else + p = &buf2[4]; + +#ifdef __builtin_object_size + if (__builtin_object_size (&p[-4], 2) != (cond ? 6 : 10)) + FAIL (); +#else + if (__builtin_object_size (&p[-4], 2) != 0) + FAIL (); +#endif + + for (unsigned i = cond; i > 0; i--) + p--; + +#ifdef __builtin_object_size + if (__builtin_object_size (p, 2) != ((cond ? 2 : 6) + cond)) + FAIL (); +#else + if (__builtin_object_size (p, 2) != 0) + FAIL (); +#endif + + p = &y.c[8]; + for (unsigned i = cond; i > 0; i--) + p--; + +#ifdef __builtin_object_size + if (__builtin_object_size (p, 2) + != sizeof (y) - __builtin_offsetof (struct A, c) - 8 + cond) + FAIL (); +#else + if (__builtin_object_size (p, 2) != 0) + FAIL (); +#endif +} + +void +__attribute__ ((noinline)) +test10 (void) +{ + static char buf[255]; + unsigned int i, len = sizeof (buf); + char *p = buf; + + for (i = 0 ; i < sizeof (buf) ; i++) + { + if (len < 2) + { +#ifdef __builtin_object_size + if (__builtin_object_size (p - 3, 2) != sizeof (buf) - i + 3) + FAIL (); +#else + if (__builtin_object_size (p - 3, 2) != 0) + FAIL (); +#endif + break; + } + p++; + len--; + } +} + +/* Tests for strdup/strndup. */ +size_t +__attribute__ ((noinline)) +test11 (void) +{ + const char *ptr = "abcdefghijklmnopqrstuvwxyz"; + char *res = strndup (ptr, 21); + if (__builtin_object_size (res, 2) != 22) + FAIL (); + + free (res); + + res = strndup (ptr, 32); + if (__builtin_object_size (res, 2) != 27) + FAIL (); + + free (res); + + res = strdup (ptr); + if (__builtin_object_size (res, 2) != 27) + FAIL (); + + free (res); + + char *ptr2 = malloc (64); + strcpy (ptr2, ptr); + + res = strndup (ptr2, 21); + if (__builtin_object_size (res, 2) != 1) + FAIL (); + + free (res); + + res = strndup (ptr2, 32); + if (__builtin_object_size (res, 2) != 1) + FAIL (); + + free (res); + + res = strndup (ptr2, 128); + if (__builtin_object_size (res, 2) != 1) + FAIL (); + + free (res); + + res = strdup (ptr2); + +#ifdef __builtin_object_size + if (__builtin_object_size (res, 2) != 27) +#else + if (__builtin_object_size (res, 2) != 1) +#endif + FAIL (); + + free (res); + free (ptr2); + + ptr = "abcd\0efghijklmnopqrstuvwxyz"; + res = strdup (ptr); + if (__builtin_object_size (res, 2) != 5) + FAIL (); + free (res); + + res = strndup (ptr, 24); + if (__builtin_object_size (res, 2) != 5) + FAIL (); + free (res); + + res = strndup (ptr, 2); + if (__builtin_object_size (res, 2) != 3) + FAIL (); + free (res); + + res = strdup (&ptr[4]); + if (__builtin_object_size (res, 2) != 1) + FAIL (); + free (res); + + res = strndup (&ptr[4], 4); + if (__builtin_object_size (res, 2) != 1) + FAIL (); + free (res); + + res = strndup (&ptr[4], 1); + if (__builtin_object_size (res, 2) != 1) + FAIL (); + free (res); +} + +int +main (void) +{ + struct S s[10]; + __asm ("" : "=r" (l1) : "0" (l1)); + test1 (main, 6); + test2 (); + test3 (); + test4 ((char *) s, 10); + test5 (4); + test6 (4); + test7 (); + test8 (); + test9 (1); + test10 (); + test11 (); + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-4.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-4.c new file mode 100644 index 0000000000..c9af07499a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-4.c @@ -0,0 +1,615 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-stringop-overread" } */ +/* { dg-require-effective-target alloca } */ + +#include "builtin-object-size-common.h" + +struct A +{ + char a[10]; + int b; + char c[10]; +} y, w[4]; + +extern char exta[]; +extern char extb[30]; +extern struct A extc[]; +struct A zerol[0]; + +void +__attribute__ ((noinline)) +test1 (void *q, int x) +{ + struct A a; + void *p = &a.a[3], *r; + char var[x + 10]; + struct A vara[x + 10]; + if (x < 0) + r = &a.a[9]; + else + r = &a.c[1]; + if (__builtin_object_size (p, 3) != sizeof (a.a) - 3) + FAIL (); + if (__builtin_object_size (&a.c[9], 3) + != sizeof (a.c) - 9) + FAIL (); + if (__builtin_object_size (q, 3) != 0) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 3) + != (x < 0 ? sizeof (a.a) - 9 : sizeof (a.c) - 1)) +#else + if (__builtin_object_size (r, 3) != sizeof (a.a) - 9) +#endif + FAIL (); + if (x < 6) + r = &w[2].a[1]; + else + r = &a.a[6]; + if (__builtin_object_size (&y, 3) != sizeof (y)) + FAIL (); + if (__builtin_object_size (w, 3) != sizeof (w)) + FAIL (); + if (__builtin_object_size (&y.b, 3) != sizeof (a.b)) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 3) + != (x < 6 ? sizeof (w[2].a) - 1 : sizeof (a.a) - 6)) +#else + if (__builtin_object_size (r, 3) != sizeof (a.a) - 6) +#endif + FAIL (); + if (x < 20) + r = malloc (30); + else + r = calloc (2, 16); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 3) != (x < 20 ? 30 : 2 * 16)) +#else + if (__builtin_object_size (r, 3) != 30) +#endif + FAIL (); + if (x < 20) + r = malloc (30); + else + r = calloc (2, 14); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 3) != (x < 20 ? 30 : 2 * 14)) +#else + if (__builtin_object_size (r, 3) != 2 * 14) +#endif + FAIL (); + if (x < 30) + r = malloc (sizeof (a)); + else + r = &a.a[3]; +#ifdef __builtin_object_size + size_t objsz = x < 30 ? sizeof (a) : sizeof (a.a) - 3; + if (__builtin_object_size (r, 3) != objsz) +#else + if (__builtin_object_size (r, 3) != sizeof (a.a) - 3) +#endif + FAIL (); + r = memcpy (r, "a", 2); +#ifdef __builtin_object_size + if (__builtin_object_size (r, 3) != objsz) +#else + if (__builtin_object_size (r, 3) != sizeof (a.a) - 3) +#endif + FAIL (); + r = memcpy (r + 2, "b", 2) + 2; +#ifdef __builtin_object_size + if (__builtin_object_size (r, 3) != objsz - 4) +#else + if (__builtin_object_size (r, 3) != sizeof (a.a) - 3 - 4) +#endif + FAIL (); + r = &a.a[4]; + r = memset (r, 'a', 2); + if (__builtin_object_size (r, 3) != sizeof (a.a) - 4) + FAIL (); + r = memset (r + 2, 'b', 2) + 2; + if (__builtin_object_size (r, 3) != sizeof (a.a) - 8) + FAIL (); + r = &a.a[1]; + r = strcpy (r, "ab"); + if (__builtin_object_size (r, 3) != sizeof (a.a) - 1) + FAIL (); + r = strcpy (r + 2, "cd") + 2; + if (__builtin_object_size (r, 3) != sizeof (a.a) - 5) + FAIL (); + if (__builtin_object_size (exta, 3) != 0) + FAIL (); + if (__builtin_object_size (exta + 10, 3) != 0) + FAIL (); + if (__builtin_object_size (&exta[5], 3) != 0) + FAIL (); + if (__builtin_object_size (extb, 3) != sizeof (extb)) + FAIL (); + if (__builtin_object_size (extb + 10, 3) != sizeof (extb) - 10) + FAIL (); + if (__builtin_object_size (&extb[5], 3) != sizeof (extb) - 5) + FAIL (); + if (__builtin_object_size (extc, 3) != 0) + FAIL (); + if (__builtin_object_size (extc + 10, 3) != 0) + FAIL (); + if (__builtin_object_size (&extc[5], 3) != 0) + FAIL (); + if (__builtin_object_size (&extc->a, 3) != 0) + FAIL (); + if (__builtin_object_size (&(extc + 10)->b, 3) != 0) + FAIL (); + if (__builtin_object_size (&extc[5].c[3], 3) != 0) + FAIL (); +#ifdef __builtin_object_size + if (__builtin_object_size (var, 3) != x + 10) + FAIL (); + if (__builtin_object_size (var + 10, 3) != x) + FAIL (); + if (__builtin_object_size (&var[5], 3) != x + 5) + FAIL (); + if (__builtin_object_size (vara, 3) != (x + 10) * sizeof (struct A)) + FAIL (); + if (__builtin_object_size (vara + 10, 3) != x * sizeof (struct A)) + FAIL (); + if (__builtin_object_size (&vara[5], 3) != (x + 5) * sizeof (struct A)) + FAIL (); +#else + if (__builtin_object_size (var, 3) != 0) + FAIL (); + if (__builtin_object_size (var + 10, 3) != 0) + FAIL (); + if (__builtin_object_size (&var[5], 3) != 0) + FAIL (); + if (__builtin_object_size (vara, 3) != 0) + FAIL (); + if (__builtin_object_size (vara + 10, 3) != 0) + FAIL (); + if (__builtin_object_size (&vara[5], 3) != 0) + FAIL (); +#endif + if (__builtin_object_size (&vara[0].a, 3) != sizeof (vara[0].a)) + FAIL (); + if (__builtin_object_size (&vara[10].a[0], 3) != sizeof (vara[0].a)) + FAIL (); + if (__builtin_object_size (&vara[5].a[4], 3) != sizeof (vara[0].a) - 4) + FAIL (); + if (__builtin_object_size (&vara[5].b, 3) != sizeof (vara[0].b)) + FAIL (); + if (__builtin_object_size (&vara[7].c[7], 3) != sizeof (vara[0].c) - 7) + FAIL (); + if (__builtin_object_size (zerol, 3) != 0) + FAIL (); + if (__builtin_object_size (&zerol, 3) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0], 3) != 0) + FAIL (); + if (__builtin_object_size (zerol[0].a, 3) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0].a[0], 3) != 0) + FAIL (); + if (__builtin_object_size (&zerol[0].b, 3) != 0) + FAIL (); + if (__builtin_object_size ("abcdefg", 3) != sizeof ("abcdefg")) + FAIL (); + if (__builtin_object_size ("abcd\0efg", 3) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg", 3) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg"[0], 3) != sizeof ("abcd\0efg")) + FAIL (); + if (__builtin_object_size (&"abcd\0efg"[4], 3) != sizeof ("abcd\0efg") - 4) + FAIL (); + if (__builtin_object_size ("abcd\0efg" + 5, 3) != sizeof ("abcd\0efg") - 5) + FAIL (); + if (__builtin_object_size (L"abcdefg", 3) != sizeof (L"abcdefg")) + FAIL (); + r = (char *) L"abcd\0efg"; + if (__builtin_object_size (r + 2, 3) != sizeof (L"abcd\0efg") - 2) + FAIL (); + /* Prevent DSE from removing calls that prevent bad combining of + addresses and offsets. */ + asm volatile ("" : : "g" (&a)); +} + +size_t l1 = 1; + +void +__attribute__ ((noinline)) +test2 (void) +{ + struct B { char buf1[10]; char buf2[10]; } a; + char *r, buf3[20]; + int i; +#ifdef __builtin_object_size + size_t dyn_res = 0; +#endif + + if (sizeof (a) != 20) + return; + + r = buf3; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[1]; + else if (i == l1) + r = &a.buf2[7]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[9]; + } + if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 9) + FAIL (); + r = &buf3[20]; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[7]; + else if (i == l1) + r = &a.buf2[7]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[9]; + } + if (__builtin_object_size (r, 3) != 0) + FAIL (); + r = &buf3[1]; + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + r = &a.buf1[6]; + else if (i == l1) + r = &a.buf2[4]; + else if (i == l1 + 1) + r = &buf3[5]; + else if (i == l1 + 2) + r = &a.buf1[2]; + } +#ifdef __builtin_object_size + dyn_res = sizeof (buf3) - 1; + + for (i = 0; i < 4; ++i) + { + if (i == l1 - 1) + dyn_res = sizeof (a.buf1) - 6; + else if (i == l1) + dyn_res = sizeof (a.buf2) - 4; + else if (i == l1 + 1) + dyn_res = sizeof (buf3) - 5; + else if (i == l1 + 2) + dyn_res = sizeof (a.buf1) - 2; + } + if (__builtin_object_size (r, 3) != dyn_res) + FAIL (); +#else + if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 6) + FAIL (); +#endif + r += 2; +#ifdef __builtin_object_size + if (__builtin_object_size (r, 3) != dyn_res - 2) + FAIL (); + if (__builtin_object_size (r + 1, 3) != dyn_res - 3) + FAIL (); +#else + if (__builtin_object_size (r, 3) != sizeof (a.buf1) - 6 - 2) + FAIL (); + if (__builtin_object_size (r + 1, 3) != sizeof (a.buf1) - 6 - 3) + FAIL (); +#endif +} + +void +__attribute__ ((noinline)) +test3 (void) +{ + char buf4[10]; + struct B { struct A a[2]; struct A b; char c[4]; char d; double e; + _Complex double f; } x; + double y; + _Complex double z; + double *dp; + + if (__builtin_object_size (buf4, 3) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4, 3) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4[0], 3) != sizeof (buf4)) + FAIL (); + if (__builtin_object_size (&buf4[1], 3) != sizeof (buf4) - 1) + FAIL (); + if (__builtin_object_size (&x, 3) != sizeof (x)) + FAIL (); + if (__builtin_object_size (&x.a, 3) != sizeof (x.a)) + FAIL (); + if (__builtin_object_size (&x.a[0], 3) != sizeof (x.a)) + FAIL (); + if (__builtin_object_size (&x.a[0].a, 3) != sizeof (x.a[0].a)) + FAIL (); + if (__builtin_object_size (&x.a[0].a[0], 3) != sizeof (x.a[0].a)) + FAIL (); + if (__builtin_object_size (&x.a[0].a[3], 3) != sizeof (x.a[0].a) - 3) + FAIL (); + if (__builtin_object_size (&x.a[0].b, 3) != sizeof (x.a[0].b)) + FAIL (); + if (__builtin_object_size (&x.a[1].c, 3) != sizeof (x.a[1].c)) + FAIL (); + if (__builtin_object_size (&x.a[1].c[0], 3) != sizeof (x.a[1].c)) + FAIL (); + if (__builtin_object_size (&x.a[1].c[3], 3) != sizeof (x.a[1].c) - 3) + FAIL (); + if (__builtin_object_size (&x.b, 3) != sizeof (x.b)) + FAIL (); + if (__builtin_object_size (&x.b.a, 3) != sizeof (x.b.a)) + FAIL (); + if (__builtin_object_size (&x.b.a[0], 3) != sizeof (x.b.a)) + FAIL (); + if (__builtin_object_size (&x.b.a[3], 3) != sizeof (x.b.a) - 3) + FAIL (); + if (__builtin_object_size (&x.b.b, 3) != sizeof (x.b.b)) + FAIL (); + if (__builtin_object_size (&x.b.c, 3) != sizeof (x.b.c)) + FAIL (); + if (__builtin_object_size (&x.b.c[0], 3) != sizeof (x.b.c)) + FAIL (); + if (__builtin_object_size (&x.b.c[3], 3) != sizeof (x.b.c) - 3) + FAIL (); + if (__builtin_object_size (&x.c, 3) != sizeof (x.c)) + FAIL (); + if (__builtin_object_size (&x.c[0], 3) != sizeof (x.c)) + FAIL (); + if (__builtin_object_size (&x.c[1], 3) != sizeof (x.c) - 1) + FAIL (); + if (__builtin_object_size (&x.d, 3) != sizeof (x.d)) + FAIL (); + if (__builtin_object_size (&x.e, 3) != sizeof (x.e)) + FAIL (); + if (__builtin_object_size (&x.f, 3) != sizeof (x.f)) + FAIL (); + dp = &__real__ x.f; + if (__builtin_object_size (dp, 3) != sizeof (x.f) / 2) + FAIL (); + dp = &__imag__ x.f; + if (__builtin_object_size (dp, 3) != sizeof (x.f) / 2) + FAIL (); + dp = &y; + if (__builtin_object_size (dp, 3) != sizeof (y)) + FAIL (); + if (__builtin_object_size (&z, 3) != sizeof (z)) + FAIL (); + dp = &__real__ z; + if (__builtin_object_size (dp, 3) != sizeof (z) / 2) + FAIL (); + dp = &__imag__ z; + if (__builtin_object_size (dp, 3) != sizeof (z) / 2) + FAIL (); +} + +struct S { unsigned int a; }; + +char * +__attribute__ ((noinline)) +test4 (char *x, int y) +{ + register int i; + struct A *p; + + for (i = 0; i < y; i++) + { + p = (struct A *) x; + x = (char *) &p[1]; + if (__builtin_object_size (p, 3) != 0) + FAIL (); + } + return x; +} + +void +__attribute__ ((noinline)) +test5 (size_t x) +{ + struct T { char buf[64]; char buf2[64]; } t; + char *p = &t.buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 3) != sizeof (t.buf) - 8 - 4 * x) +#else + if (__builtin_object_size (p, 3) != 0) +#endif + FAIL (); + memset (p, ' ', sizeof (t.buf) - 8 - 4 * 4); +} + +void +__attribute__ ((noinline)) +test6 (void) +{ + char buf[64]; + struct T { char buf[64]; char buf2[64]; } t; + char *p = &buf[64], *q = &t.buf[64]; + + if (__builtin_object_size (p + 64, 3) != 0) + FAIL (); + if (__builtin_object_size (q + 0, 3) != 0) + FAIL (); + if (__builtin_object_size (q + 64, 3) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test7 (void) +{ + struct T { char buf[10]; char buf2[10]; } t; + char *p = &t.buf2[-4]; + char *q = &t.buf2[0]; + if (__builtin_object_size (p, 3) != 0) + FAIL (); + if (__builtin_object_size (q, 3) != sizeof (t.buf2)) + FAIL (); + q = &t.buf[10]; + if (__builtin_object_size (q, 3) != 0) + FAIL (); + q = &t.buf[11]; + if (__builtin_object_size (q, 3) != 0) + FAIL (); + p = &t.buf[-4]; + if (__builtin_object_size (p, 3) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test8 (unsigned cond) +{ + char *buf2 = malloc (10); + char *p; + + if (cond) + p = &buf2[8]; + else + p = &buf2[4]; + +#ifdef __builtin_object_size + if (__builtin_object_size (&p[-4], 3) != (cond ? 6 : 10)) + FAIL (); +#else + if (__builtin_object_size (&p[-4], 3) != 0) + FAIL (); +#endif + + for (unsigned i = cond; i > 0; i--) + p--; + +#ifdef __builtin_object_size + if (__builtin_object_size (p, 3) != ((cond ? 2 : 6) + cond)) + FAIL (); +#else + if (__builtin_object_size (p, 3) != 0) + FAIL (); +#endif + + p = &y.c[8]; + for (unsigned i = cond; i > 0; i--) + p--; + +#ifdef __builtin_object_size + if (__builtin_object_size (p, 3) != sizeof (y.c) - 8 + cond) + FAIL (); +#else + if (__builtin_object_size (p, 3) != 0) + FAIL (); +#endif +} + +/* Tests for strdup/strndup. */ +size_t +__attribute__ ((noinline)) +test9 (void) +{ + const char *ptr = "abcdefghijklmnopqrstuvwxyz"; + char *res = strndup (ptr, 21); + if (__builtin_object_size (res, 3) != 22) + FAIL (); + + free (res); + + res = strndup (ptr, 32); + if (__builtin_object_size (res, 3) != 27) + FAIL (); + + free (res); + + res = strdup (ptr); + if (__builtin_object_size (res, 3) != 27) + FAIL (); + + free (res); + + char *ptr2 = malloc (64); + strcpy (ptr2, ptr); + + res = strndup (ptr2, 21); + if (__builtin_object_size (res, 3) != 1) + FAIL (); + + free (res); + + res = strndup (ptr2, 32); + if (__builtin_object_size (res, 3) != 1) + FAIL (); + + free (res); + + res = strndup (ptr2, 128); + if (__builtin_object_size (res, 3) != 1) + FAIL (); + + free (res); + + res = strdup (ptr2); +#ifdef __builtin_object_size + if (__builtin_object_size (res, 3) != 27) +#else + if (__builtin_object_size (res, 3) != 1) +#endif + FAIL (); + + free (res); + free (ptr2); + + ptr = "abcd\0efghijklmnopqrstuvwxyz"; + res = strdup (ptr); + if (__builtin_object_size (res, 3) != 5) + FAIL (); + free (res); + + res = strndup (ptr, 24); + if (__builtin_object_size (res, 3) != 5) + FAIL (); + free (res); + + res = strndup (ptr, 2); + if (__builtin_object_size (res, 3) != 3) + FAIL (); + free (res); + + res = strdup (&ptr[4]); + if (__builtin_object_size (res, 3) != 1) + FAIL (); + free (res); + + res = strndup (&ptr[4], 4); + if (__builtin_object_size (res, 3) != 1) + FAIL (); + free (res); + + res = strndup (&ptr[4], 1); + if (__builtin_object_size (res, 3) != 1) + FAIL (); + free (res); +} + +int +main (void) +{ + struct S s[10]; + __asm ("" : "=r" (l1) : "0" (l1)); + test1 (main, 6); + test2 (); + test3 (); + test4 ((char *) s, 10); + test5 (4); + test6 (); + test7 (); + test8 (1); + test9 (); + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-5.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-5.c new file mode 100644 index 0000000000..d1ad761cb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-5.c @@ -0,0 +1,103 @@ +/* { dg-do compile { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } */ +/* { dg-options "-O2" } */ + +#ifndef N +# define N 0x40000000 +#endif + +typedef __SIZE_TYPE__ size_t; +extern void abort (void); +extern char buf[N]; + +void +test1 (size_t x) +{ + char *p = &buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 0) != sizeof (buf) - 8 - 4 * x) +#else + if (__builtin_object_size (p, 0) != sizeof (buf) - 8) +#endif + abort (); +} + +void +test2 (size_t x) +{ + char *p = &buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 1) != sizeof (buf) - 8 - 4 * x) +#else + if (__builtin_object_size (p, 1) != sizeof (buf) - 8) +#endif + abort (); +} + +void +test3 (size_t x) +{ + char *p = &buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 2) != sizeof (buf) - 8 - 4 * x) +#else + if (__builtin_object_size (p, 2) != 0) +#endif + abort (); +} + +void +test4 (size_t x) +{ + char *p = &buf[8]; + size_t i; + + for (i = 0; i < x; ++i) + p = p + 4; +#ifdef __builtin_object_size + if (__builtin_object_size (p, 3) != sizeof (buf) - 8 - 4 * x) +#else + if (__builtin_object_size (p, 3) != 0) +#endif + abort (); +} + +void +test5 (void) +{ + char *p = &buf[0x90000004]; + if (__builtin_object_size (p + 2, 0) != 0) + abort (); +} + +void +test6 (void) +{ + char *p = &buf[-4]; + if (__builtin_object_size (p + 2, 0) != 0) + abort (); +} + +#ifdef __builtin_object_size +void +test7 (void) +{ + char *buf2 = __builtin_malloc (8); + char *p = &buf2[0x90000004]; + if (__builtin_object_size (p + 2, 0) != 0) + abort (); +} +#endif + +/* { dg-final { scan-assembler-not "abort" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-6.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-6.c new file mode 100644 index 0000000000..b456b321db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-6.c @@ -0,0 +1,431 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +struct A +{ + char a[10]; + int b; + char c[10]; +}; + +void +__attribute__ ((noinline)) +test1 (struct A *p) +{ + char *c; + if (__builtin_object_size (&p->a, 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&p->a[0], 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&p->a[3], 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&p->b, 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&p->c, 0) != (size_t) -1) + FAIL (); + c = p->a; + if (__builtin_object_size (c, 0) != (size_t) -1) + FAIL (); + c = &p->a[0]; + if (__builtin_object_size (c, 0) != (size_t) -1) + FAIL (); + c = &p->a[3]; + if (__builtin_object_size (c, 0) != (size_t) -1) + FAIL (); + c = (char *) &p->b; + if (__builtin_object_size (c, 0) != (size_t) -1) + FAIL (); + c = (char *) &p->c; + if (__builtin_object_size (c, 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) + FAIL (); + if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) + FAIL (); + if (__builtin_object_size (&p->c, 1) != (size_t) -1) + FAIL (); + c = p->a; + if (__builtin_object_size (c, 1) != sizeof (p->a)) + FAIL (); + c = &p->a[0]; + if (__builtin_object_size (c, 1) != sizeof (p->a)) + FAIL (); + c = &p->a[3]; + if (__builtin_object_size (c, 1) != sizeof (p->a) - 3) + FAIL (); + c = (char *) &p->b; + if (__builtin_object_size (c, 1) != sizeof (p->b)) + FAIL (); + c = (char *) &p->c; + if (__builtin_object_size (c, 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&p->a, 2) != 0) + FAIL (); + if (__builtin_object_size (&p->a[0], 2) != 0) + FAIL (); + if (__builtin_object_size (&p->a[3], 2) != 0) + FAIL (); + if (__builtin_object_size (&p->b, 2) != 0) + FAIL (); + if (__builtin_object_size (&p->c, 2) != 0) + FAIL (); + c = p->a; + if (__builtin_object_size (c, 2) != 0) + FAIL (); + c = &p->a[0]; + if (__builtin_object_size (c, 2) != 0) + FAIL (); + c = &p->a[3]; + if (__builtin_object_size (c, 2) != 0) + FAIL (); + c = (char *) &p->b; + if (__builtin_object_size (c, 2) != 0) + FAIL (); + c = (char *) &p->c; + if (__builtin_object_size (c, 2) != 0) + FAIL (); + if (__builtin_object_size (&p->a, 3) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3) + FAIL (); + if (__builtin_object_size (&p->b, 3) != sizeof (p->b)) + FAIL (); + if (__builtin_object_size (&p->c, 3) != 0) + FAIL (); + c = p->a; + if (__builtin_object_size (c, 3) != sizeof (p->a)) + FAIL (); + c = &p->a[0]; + if (__builtin_object_size (c, 3) != sizeof (p->a)) + FAIL (); + c = &p->a[3]; + if (__builtin_object_size (c, 3) != sizeof (p->a) - 3) + FAIL (); + c = (char *) &p->b; + if (__builtin_object_size (c, 3) != sizeof (p->b)) + FAIL (); + c = (char *) &p->c; + if (__builtin_object_size (c, 3) != 0) + FAIL (); +} + +void +__attribute__ ((noinline)) +test2 (void) +{ + char *c; + size_t s = 2 * sizeof (struct A); + struct A *p = malloc (2 * sizeof (struct A)); + if (__builtin_object_size (&p->a, 0) != s) + FAIL (); + if (__builtin_object_size (&p->a[0], 0) != s) + FAIL (); + if (__builtin_object_size (&p->a[3], 0) != s - 3) + FAIL (); + if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (struct A, b)) + FAIL (); + if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (struct A, c)) + FAIL (); + c = p->a; + if (__builtin_object_size (c, 0) != s) + FAIL (); + c = &p->a[0]; + if (__builtin_object_size (c, 0) != s) + FAIL (); + c = &p->a[3]; + if (__builtin_object_size (c, 0) != s - 3) + FAIL (); + c = (char *) &p->b; + if (__builtin_object_size (c, 0) != s - __builtin_offsetof (struct A, b)) + FAIL (); + c = (char *) &p->c; + if (__builtin_object_size (c, 0) != s - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) + FAIL (); + if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) + FAIL (); + if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (struct A, c)) + FAIL (); + c = p->a; + if (__builtin_object_size (c, 1) != sizeof (p->a)) + FAIL (); + c = &p->a[0]; + if (__builtin_object_size (c, 1) != sizeof (p->a)) + FAIL (); + c = &p->a[3]; + if (__builtin_object_size (c, 1) != sizeof (p->a) - 3) + FAIL (); + c = (char *) &p->b; + if (__builtin_object_size (c, 1) != sizeof (p->b)) + FAIL (); + c = (char *) &p->c; + if (__builtin_object_size (c, 1) != s - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&p->a, 2) != s) + FAIL (); + if (__builtin_object_size (&p->a[0], 2) != s) + FAIL (); + if (__builtin_object_size (&p->a[3], 2) != s - 3) + FAIL (); + if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (struct A, b)) + FAIL (); + if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (struct A, c)) + FAIL (); + c = p->a; + if (__builtin_object_size (c, 2) != s) + FAIL (); + c = &p->a[0]; + if (__builtin_object_size (c, 2) != s) + FAIL (); + c = &p->a[3]; + if (__builtin_object_size (c, 2) != s - 3) + FAIL (); + c = (char *) &p->b; + if (__builtin_object_size (c, 2) != s - __builtin_offsetof (struct A, b)) + FAIL (); + c = (char *) &p->c; + if (__builtin_object_size (c, 2) != s - __builtin_offsetof (struct A, c)) + FAIL (); + if (__builtin_object_size (&p->a, 3) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3) + FAIL (); + if (__builtin_object_size (&p->b, 3) != sizeof (p->b)) + FAIL (); + if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (struct A, c)) + FAIL (); + c = p->a; + if (__builtin_object_size (c, 3) != sizeof (p->a)) + FAIL (); + c = &p->a[0]; + if (__builtin_object_size (c, 3) != sizeof (p->a)) + FAIL (); + c = &p->a[3]; + if (__builtin_object_size (c, 3) != sizeof (p->a) - 3) + FAIL (); + c = (char *) &p->b; + if (__builtin_object_size (c, 3) != sizeof (p->b)) + FAIL (); + c = (char *) &p->c; + if (__builtin_object_size (c, 3) != s - __builtin_offsetof (struct A, c)) + FAIL (); + free (p); +} + +void +__attribute__ ((noinline)) +test3 (void) +{ + char *c; + size_t s; + struct A *p = malloc (4); + if (__builtin_object_size (&p->a, 0) != 4) + FAIL (); + if (__builtin_object_size (&p->a[0], 0) != 4) + FAIL (); + if (__builtin_object_size (&p->a[3], 0) != 1) + FAIL (); + if (__builtin_object_size (&p->b, 0) != 0) + FAIL (); + if (__builtin_object_size (&p->c, 0) != 0) + FAIL (); + if (__builtin_object_size (&p->a, 1) != 4) + FAIL (); + if (__builtin_object_size (&p->a[0], 1) != 4) + FAIL (); + if (__builtin_object_size (&p->a[3], 1) != 1) + FAIL (); + if (__builtin_object_size (&p->b, 1) != 0) + FAIL (); + if (__builtin_object_size (&p->c, 1) != 0) + FAIL (); + free (p); + s = __builtin_offsetof (struct A, c) + 4; + p = malloc (s); + if (__builtin_object_size (&p->a, 0) != s) + FAIL (); + if (__builtin_object_size (&p->a[0], 0) != s) + FAIL (); + if (__builtin_object_size (&p->a[3], 0) != s - 3) + FAIL (); + if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (struct A, b)) + FAIL (); + if (__builtin_object_size (&p->c, 0) != 4) + FAIL (); + if (__builtin_object_size (&p->a, 1) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a)) + FAIL (); + if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3) + FAIL (); + if (__builtin_object_size (&p->b, 1) != sizeof (p->b)) + FAIL (); + if (__builtin_object_size (&p->c, 1) != 4) + FAIL (); + free (p); +} + +struct B +{ + struct A a[4]; +}; + +void +__attribute__ ((noinline)) +test4 (struct B *q, int i) +{ + if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2) + FAIL (); + if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2) + FAIL (); + if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2) + FAIL (); + if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2) + FAIL (); + if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2) + FAIL (); + if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2) + FAIL (); +} + +struct C +{ + char a[10]; + char b; +}; + +void +__attribute__ ((noinline)) +test5 (struct C *c) +{ + if (__builtin_object_size (&c->b, 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&c->b, 1) != 1) + FAIL (); + if (__builtin_object_size (&c->b, 2) != 0) + FAIL (); + if (__builtin_object_size (&c->b, 3) != 1) + FAIL (); +} + +struct D +{ + int i; + struct D1 + { + char b; + char a[10]; + } j; +}; + +void +__attribute__ ((noinline)) +test6 (struct D *d) +{ + if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3) + FAIL (); + if (__builtin_object_size (&d->j.a[3], 2) != 0) + FAIL (); + if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3) + FAIL (); +} + +struct E +{ + int i; + struct E1 + { + char b; + char a[10]; + } j[1]; +}; + +void +__attribute__ ((noinline)) +test7 (struct E *e) +{ + if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3) + FAIL (); + if (__builtin_object_size (&e->j[0].a[3], 2) != 0) + FAIL (); + if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3) + FAIL (); + if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size ((char *) &e->j[0], 2) != 0) + FAIL (); + if (__builtin_object_size ((char *) &e->j[0], 3) != 0) + FAIL (); +} + +union F +{ + char a[1]; + struct F1 + { + char b; + char c[10]; + } d; +}; + +void +__attribute__ ((noinline)) +test8 (union F *f) +{ + if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&f->d.c[3], 1) != (size_t) -1) + FAIL (); + if (__builtin_object_size (&f->d.c[3], 2) != 0) + FAIL (); + if (__builtin_object_size (&f->d.c[3], 3) != 0) + FAIL (); +} + +int +main (void) +{ + struct A a, *p = &a; + int i = 1; + __asm ("" : "+r" (p)); + test1 (p); + test2 (); + test3 (); + struct B b, *q = &b; + __asm ("" : "+r" (q), "+r" (i)); + test4 (q, i); + struct C c, *cp = &c; + __asm ("" : "+r" (cp)); + test5 (cp); + struct D d, *dp = &d; + __asm ("" : "+r" (dp)); + test6 (dp); + struct E e, *ep = &e; + __asm ("" : "+r" (ep)); + test7 (ep); + union F f, *fp = &f; + __asm ("" : "+r" (fp)); + test8 (fp); + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-7.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-7.c new file mode 100644 index 0000000000..0d11c42987 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-7.c @@ -0,0 +1,69 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +struct A +{ + int i, j, k; + char buf[255]; + int l, m, n, o; +}; + +int +main (void) +{ + const size_t s = sizeof (struct A); + const size_t o = __builtin_offsetof (struct A, buf); + struct A *a = malloc (s); + struct A *b = malloc (o + 212); + if (__builtin_object_size (a->buf, 0) != s - o) + FAIL (); + if (__builtin_object_size (a->buf, 1) != sizeof (a->buf)) + FAIL (); + if (__builtin_object_size (a->buf, 2) != s - o) + FAIL (); + if (__builtin_object_size (a->buf, 3) != sizeof (a->buf)) + FAIL (); + if (__builtin_object_size (&a->buf[0], 0) != s - o) + FAIL (); + if (__builtin_object_size (&a->buf[0], 1) != sizeof (a->buf)) + FAIL (); + if (__builtin_object_size (&a->buf[0], 2) != s - o) + FAIL (); + if (__builtin_object_size (&a->buf[0], 3) != sizeof (a->buf)) + FAIL (); + if (__builtin_object_size (&a->buf[6], 0) != s - o - 6) + FAIL (); + if (__builtin_object_size (&a->buf[6], 1) != sizeof (a->buf) - 6) + FAIL (); + if (__builtin_object_size (&a->buf[6], 2) != s - o - 6) + FAIL (); + if (__builtin_object_size (&a->buf[6], 3) != sizeof (a->buf) - 6) + FAIL (); + if (__builtin_object_size (b->buf, 0) != 212) + FAIL (); + if (__builtin_object_size (b->buf, 1) != 212) + FAIL (); + if (__builtin_object_size (b->buf, 2) != 212) + FAIL (); + if (__builtin_object_size (b->buf, 3) != 212) + FAIL (); + if (__builtin_object_size (&b->buf[0], 0) != 212) + FAIL (); + if (__builtin_object_size (&b->buf[0], 1) != 212) + FAIL (); + if (__builtin_object_size (&b->buf[0], 2) != 212) + FAIL (); + if (__builtin_object_size (&b->buf[0], 3) != 212) + FAIL (); + if (__builtin_object_size (&b->buf[28], 0) != 212 - 28) + FAIL (); + if (__builtin_object_size (&b->buf[28], 1) != 212 - 28) + FAIL (); + if (__builtin_object_size (&b->buf[28], 2) != 212 - 28) + FAIL (); + if (__builtin_object_size (&b->buf[28], 3) != 212 - 28) + FAIL (); + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-8.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-8.c new file mode 100644 index 0000000000..294e524263 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-8.c @@ -0,0 +1,197 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +union A +{ + int a1; + char a2[3]; +}; + +union B +{ + long long b1; + union A b2; +}; + +struct C +{ + int c1; + union A c2; +}; + +struct D +{ + int d1; + union B d2; +}; + +union E +{ + struct C e1; + char e2[3]; +}; + +union F +{ + int f1; + struct D f2; +}; + +struct G +{ + union A g1; + char g2; +}; + +struct H +{ + int h1; + union E h2; +}; + +#define T(X, S0, S1) \ + if (__builtin_object_size (X, 0) != (S0)) \ + FAIL (); \ + if (__builtin_object_size (X, 1) != (S1)) \ + FAIL (); \ + if (__builtin_object_size (X, 2) != (S0)) \ + FAIL (); \ + if (__builtin_object_size (X, 3) != (S1)) \ + FAIL () +#define TS(X, S0) T(&X, S0, sizeof (X)) +#define TA(X, S0, S1) \ + T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1) +#define TF(X, S0) TA(X, S0, S0) + +int +main (void) +{ + size_t s, o, o2; + + s = sizeof (union A); + o = 0; + union A *a1 = malloc (s); + union A *a2 = malloc (o + 212); + TS (a1->a1, s); + TF (a1->a2, s); + s = o + 212; + TS (a2->a1, s); + TF (a2->a2, s); + free (a2); + free (a1); + + s = sizeof (union B); + o = 0; + union B *b1 = malloc (s); + union B *b2 = malloc (o + 212); + TS (b1->b1, s); + TS (b1->b2.a1, s); + TF (b1->b2.a2, s); + s = o + 212; + TS (b2->b1, s); + TS (b2->b2.a1, s); + TF (b2->b2.a2, s); + free (b2); + free (b1); + + s = sizeof (struct C); + o = __builtin_offsetof (struct C, c2); + struct C *c1 = malloc (s); + struct C *c2 = malloc (o + 212); + TS (c1->c1, s); + TS (c1->c2.a1, s - o); + TF (c1->c2.a2, s - o); + s = o + 212; + TS (c2->c1, s); + TS (c2->c2.a1, s - o); + TF (c2->c2.a2, s - o); + free (c2); + free (c1); + + s = sizeof (struct D); + o = __builtin_offsetof (struct D, d2); + struct D *d1 = malloc (s); + struct D *d2 = malloc (o + 212); + TS (d1->d1, s); + TS (d1->d2.b1, s - o); + TS (d1->d2.b2.a1, s - o); + TF (d1->d2.b2.a2, s - o); + s = o + 212; + TS (d2->d1, s); + TS (d2->d2.b1, s - o); + TS (d2->d2.b2.a1, s - o); + TF (d2->d2.b2.a2, s - o); + free (d2); + free (d1); + + s = sizeof (union E); + o = __builtin_offsetof (union E, e1.c2); + union E *e1 = malloc (s); + union E *e2 = malloc (o + 212); + TS (e1->e1.c1, s); + TS (e1->e1.c2.a1, s - o); + TF (e1->e1.c2.a2, s - o); + TF (e1->e2, s); + s = o + 212; + TS (e2->e1.c1, s); + TS (e2->e1.c2.a1, s - o); + TF (e2->e1.c2.a2, s - o); + TF (e2->e2, s); + free (e2); + free (e1); + + s = sizeof (union F); + o = __builtin_offsetof (union F, f2.d2); + union F *f1 = malloc (s); + union F *f2 = malloc (o + 212); + TS (f1->f1, s); + TS (f1->f2.d1, s); + TS (f1->f2.d2.b1, s - o); + TS (f1->f2.d2.b2.a1, s - o); + TF (f1->f2.d2.b2.a2, s - o); + s = o + 212; + TS (f2->f1, s); + TS (f2->f2.d1, s); + TS (f2->f2.d2.b1, s - o); + TS (f2->f2.d2.b2.a1, s - o); + TF (f2->f2.d2.b2.a2, s - o); + free (f2); + free (f1); + + s = sizeof (struct G); + o = __builtin_offsetof (struct G, g2); + struct G *g1 = malloc (s); + struct G *g2 = malloc (o + 212); + TS (g1->g1.a1, s); + TA (g1->g1.a2, s, sizeof (g1->g1.a2)); + TS (g1->g2, s - o); + s = o + 212; + TS (g2->g1.a1, s); + TA (g2->g1.a2, s, sizeof (g1->g1.a2)); + TS (g2->g2, s - o); + free (g2); + free (g1); + + s = sizeof (struct H); + o = __builtin_offsetof (struct H, h2); + o2 = __builtin_offsetof (struct H, h2.e1.c2); + struct H *h1 = malloc (s); + struct H *h2 = malloc (o2 + 212); + TS (h1->h1, s); + TS (h1->h2.e1.c1, s - o); + TS (h1->h2.e1.c2.a1, s - o2); + TA (h1->h2.e1.c2.a2, s - o2, sizeof (h1->h2.e1.c2.a2)); + TF (h1->h2.e2, s - o); + s = o2 + 212; + TS (h2->h1, s); + TS (h2->h2.e1.c1, s - o); + TS (h2->h2.e1.c2.a1, s - o2); + TA (h2->h2.e1.c2.a2, s - o2, sizeof (h2->h2.e1.c2.a2)); + TF (h2->h2.e2, s - o); + free (h2); + free (h1); + + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-9.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-9.c new file mode 100644 index 0000000000..f134aaca0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-9.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; +extern void *malloc (size_t); +extern void free (void *); +extern void abort (void); + +union U +{ + struct S { int a; int b; } s; + int t; +}; + +struct T +{ + int c; + char d[1]; +}; + +int +main (void) +{ + union U *u = malloc (sizeof (struct S) + sizeof (struct T) + 6); + struct T *t = (struct T *) (&u->s + 1); + if (__builtin_object_size (t->d, 1) + != sizeof (struct T) + 6 - __builtin_offsetof (struct T, d)) + abort (); + free (u); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-common.h b/SingleSource/Regression/C/gcc-dg/builtin-object-size-common.h new file mode 100644 index 0000000000..66ff7cdd95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-common.h @@ -0,0 +1,32 @@ +typedef __SIZE_TYPE__ size_t; +#ifdef __cplusplus +extern "C" { +#endif + extern void exit (int); + extern void *malloc (size_t); + extern void free (void *); + extern void *calloc (size_t, size_t); + extern void *alloca (size_t); + extern void *memcpy (void *, const void *, size_t); + extern void *memset (void *, int, size_t); + extern char *strcpy (char *, const char *); + extern char *strdup (const char *); + extern char *strndup (const char *, size_t); +#ifdef __cplusplus +} +#endif + +unsigned nfails = 0; + +#define FAIL() \ + do { \ + __builtin_printf ("Failure at line: %d\n", __LINE__); \ + nfails++; \ + } while (0) + +#define DONE() \ + do { \ + if (nfails > 0) \ + __builtin_abort (); \ + return 0; \ + } while (0) diff --git a/SingleSource/Regression/C/gcc-dg/builtin-object-size-pr101832.c b/SingleSource/Regression/C/gcc-dg/builtin-object-size-pr101832.c new file mode 100644 index 0000000000..60078e1163 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-object-size-pr101832.c @@ -0,0 +1,134 @@ +/* PR 101832: + GCC extension accepts the case when a struct with a C99 flexible array + member is embedded into another struct (possibly recursively). + __builtin_object_size will treat such struct as flexible size. + However, when a structure with non-C99 flexible array member, i.e, trailing + [0], [1], or [4], is embedded into anther struct, the stucture will not + be treated as flexible size. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "builtin-object-size-common.h" + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + __builtin_printf ("ok: %s == %zd\n", #p, p); \ + else {\ + __builtin_printf ("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + FAIL (); \ + } \ +} while (0); + + +struct A { + int n; + char data[]; +}; + +struct B { + int m; + struct A a; +}; + +struct C { + int q; + struct B b; +}; + +struct A0 { + int n; + char data[0]; +}; + +struct B0 { + int m; + struct A0 a; +}; + +struct C0 { + int q; + struct B0 b; +}; + +struct A1 { + int n; + char data[1]; +}; + +struct B1 { + int m; + struct A1 a; +}; + +struct C1 { + int q; + struct B1 b; +}; + +struct An { + int n; + char data[8]; +}; + +struct Bn { + int m; + struct An a; +}; + +struct Cn { + int q; + struct Bn b; +}; + +volatile void *magic1, *magic2; + +int main (int argc, char *argv[]) +{ + struct B *outer; + struct C *outest; + + /* Make sure optimization can't find some other object size. */ + outer = (void *)magic1; + outest = (void *)magic2; + + expect (__builtin_object_size (&outer->a, 1), -1); + expect (__builtin_object_size (&outest->b, 1), -1); + expect (__builtin_object_size (&outest->b.a, 1), -1); + + struct B0 *outer0; + struct C0 *outest0; + + /* Make sure optimization can't find some other object size. */ + outer0 = (void *)magic1; + outest0 = (void *)magic2; + + expect (__builtin_object_size (&outer0->a, 1), sizeof (outer0->a)); + expect (__builtin_object_size (&outest0->b, 1), sizeof (outest0->b)); + expect (__builtin_object_size (&outest0->b.a, 1), sizeof (outest0->b.a)); + + struct B1 *outer1; + struct C1 *outest1; + + /* Make sure optimization can't find some other object size. */ + outer1 = (void *)magic1; + outest1 = (void *)magic2; + + expect (__builtin_object_size (&outer1->a, 1), sizeof (outer1->a)); + expect (__builtin_object_size (&outest1->b, 1), sizeof (outest1->b)); + expect (__builtin_object_size (&outest1->b.a, 1), sizeof (outest1->b.a)); + + struct Bn *outern; + struct Cn *outestn; + + /* Make sure optimization can't find some other object size. */ + outern = (void *)magic1; + outestn = (void *)magic2; + + expect (__builtin_object_size (&outern->a, 1), sizeof (outern->a)); + expect (__builtin_object_size (&outestn->b, 1), sizeof (outestn->b)); + expect (__builtin_object_size (&outestn->b.a, 1), sizeof (outestn->b.a)); + + DONE (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-prefetch-1.c b/SingleSource/Regression/C/gcc-dg/builtin-prefetch-1.c new file mode 100644 index 0000000000..11beb4e1bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-prefetch-1.c @@ -0,0 +1,45 @@ +/* Test that __builtin_prefetch does no harm. + + Prefetch using some invalid rw and locality values. These must be + compile-time constants. */ + +/* { dg-do run } */ + +extern void exit (int); + +enum locality { none, low, moderate, high, bogus }; +enum rw { read, write }; + +int arr[10]; + +void +good (int *p) +{ + __builtin_prefetch (p, 0, 0); + __builtin_prefetch (p, 0, 1); + __builtin_prefetch (p, 0, 2); + __builtin_prefetch (p, 0, 3); + __builtin_prefetch (p, 1, 0); + __builtin_prefetch (p, 1, 1); + __builtin_prefetch (p, 1, 2); + __builtin_prefetch (p, 1, 3); +} + +void +bad (int *p) +{ + __builtin_prefetch (p, -1, 0); /* { dg-warning "invalid second argument to '__builtin_prefetch'; using zero" } */ + __builtin_prefetch (p, 2, 0); /* { dg-warning "invalid second argument to '__builtin_prefetch'; using zero" } */ + __builtin_prefetch (p, bogus, 0); /* { dg-warning "invalid second argument to '__builtin_prefetch'; using zero" } */ + __builtin_prefetch (p, 0, -1); /* { dg-warning "invalid third argument to '__builtin_prefetch'; using zero" } */ + __builtin_prefetch (p, 0, 4); /* { dg-warning "invalid third argument to '__builtin_prefetch'; using zero" } */ + __builtin_prefetch (p, 0, bogus); /* { dg-warning "invalid third argument to '__builtin_prefetch'; using zero" } */ +} + +int +main () +{ + good (arr); + bad (arr); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-protos-1.c b/SingleSource/Regression/C/gcc-dg/builtin-protos-1.c new file mode 100644 index 0000000000..b9e939699f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-protos-1.c @@ -0,0 +1,74 @@ +/* { dg-do compile } */ +/* { dg-options -Wtraditional-conversion } */ + +int +test_s (signed int x) +{ + return __builtin_abs (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_clz (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ctz (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_clrsb (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_ffs (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_parity (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_popcount (x); /* { dg-warning "as unsigned due to prototype" } */ +} + +int +test_u (unsigned int x) +{ + return __builtin_abs (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_clz (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ctz (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_clrsb (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_ffs (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_parity (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_popcount (x); /* { dg-bogus "as signed due to prototype" } */ +} + +int +test_sl (signed long x) +{ + return __builtin_labs (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_clzl (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ctzl (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_clrsbl (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_ffsl (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_parityl (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_popcountl (x); /* { dg-warning "as unsigned due to prototype" } */ +} + +int +test_ul (unsigned long x) +{ + return __builtin_labs (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_clzl (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ctzl (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_clrsbl (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_ffsl (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_parityl (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_popcountl (x); /* { dg-bogus "as signed due to prototype" } */ +} + +int +test_sll (signed long long x) +{ + return __builtin_llabs (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_clzll (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ctzll (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_clrsbll (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_ffsll (x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_parityll (x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_popcountll (x); /* { dg-warning "as unsigned due to prototype" } */ +} + +int +test_ull (unsigned long long x) +{ + return __builtin_llabs (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_clzll (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ctzll (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_clrsbll (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_ffsll (x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_parityll (x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_popcountll (x); /* { dg-bogus "as signed due to prototype" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-redefine.c b/SingleSource/Regression/C/gcc-dg/builtin-redefine.c new file mode 100644 index 0000000000..8090015f69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-redefine.c @@ -0,0 +1,79 @@ +/* Test -Wno-builtin-macro-redefined warnings. */ + +/* { dg-do compile } */ +/* { dg-options "-Wno-builtin-macro-redefined -U__DATE__ -D__TIME__=X" } */ + +/* Check date, time, and datestamp built-ins warnings may be suppressed. */ + +#if defined(__DATE__) +#error "__DATE__ is defined, but should not be (-U command line error)" +/* { dg-bogus "__DATE__ is defined" "" { target *-*-* } .-1 } */ +#endif + +#if __TIME__ != X +#error "__TIME__ is not defined as expected (-D command line error)" +/* { dg-bogus "__TIME__ is not defined" "" { target *-*-* } .-1 } */ +#endif + +#if !defined(__TIMESTAMP__) +#error "__TIMESTAMP__ is not defined (built-in macro expectation error)" +/* { dg-bogus "__TIMESTAMP__ is not defined" "" { target *-*-* } .-1 } */ +#endif + + +#undef __TIME__ /* Undefine while defined. */ +#undef __TIME__ /* Undefine while already undefined. */ + +#define __TIME__ "X" /* Define while undefined. */ +#define __TIME__ "X" /* Re-define while defined. */ /* { dg-line time_prev } */ + +#define __TIME__ "Y" /* { dg-warning "\"__TIME__\" redefined" } */ +/* { dg-message "previous definition" "" { target *-*-* } time_prev } */ + +#undef __TIME__ /* Undefine while defined. */ + + +#undef __DATE__ /* Undefine while already undefined. */ + +#define __DATE__ "X" /* Define while undefined. */ +#define __DATE__ "X" /* Re-define while defined. */ /* { dg-line date_prev } */ + +#define __DATE__ "Y" /* { dg-warning "\"__DATE__\" redefined" } */ +/* { dg-message "previous definition" "" { target *-*-* } date_prev } */ + +#undef __DATE__ /* Undefine while defined. */ + + +#define __TIMESTAMP__ "X" /* Define while already defined. */ +#define __TIMESTAMP__ "X" /* Re-define while defined. */ /* { dg-line timestamp_prev } */ + +#define __TIMESTAMP__ "Y" /* { dg-warning "\"__TIMESTAMP__\" redefined" } */ +/* { dg-message "previous definition" "" { target *-*-* } timestamp_prev } */ + +#undef __TIMESTAMP__ /* Undefine while defined. */ + + +/* Check other built-ins with warnings that may be suppressed. */ + +#if !defined(__FILE__) || !defined(__BASE_FILE__) +#error "Expected built-in is not defined (built-in macro expectation error)" +/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */ +#endif + +#define __FILE__ "X" /* Define while already defined. */ +#define __BASE_FILE__ "X" /* Define while already defined. */ + + +/* Check selected built-ins not affected by warning suppression. */ + +#if !defined(__LINE__) || !defined(__INCLUDE_LEVEL__) || !defined(__COUNTER__) +#error "Expected built-in is not defined (built-in macro expectation error)" +/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */ +#endif + +#define __LINE__ 0 /* { dg-warning "\"__LINE__\" redef" } */ +#define __INCLUDE_LEVEL__ 0 /* { dg-warning "\"__INCLUDE_LEVEL__\" redef" } */ +#define __COUNTER__ 0 /* { dg-warning "\"__COUNTER__\" redef" } */ + + +int unused; /* Silence `ISO C forbids an empty translation unit' warning. */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-return-1.c b/SingleSource/Regression/C/gcc-dg/builtin-return-1.c new file mode 100644 index 0000000000..edcec9767a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-return-1.c @@ -0,0 +1,35 @@ +/* PR middle-end/11151 */ +/* Originator: Andrew Church */ +/* { dg-do run } */ +/* { dg-xfail-run-if "PR36571 untyped return is char register" { "avr-*-*" } } */ +/* { dg-require-effective-target untyped_assembly } */ +/* This used to fail on SPARC because the (undefined) return + value of 'bar' was overwriting that of 'foo'. */ + +extern void abort(void); + +int foo(int n) +{ + return n+1; +} + +int bar(int n) +{ + __builtin_return(__builtin_apply((void (*)(void))foo, __builtin_apply_args(), 64)); +} + +char *g; + +int main(void) +{ + /* Allocate 64 bytes on the stack to make sure that __builtin_apply + can read at least 64 bytes above the return address. */ + char dummy[64]; + + g = dummy; + + if (bar(1) != 2) + abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stpncpy.c b/SingleSource/Regression/C/gcc-dg/builtin-stpncpy.c new file mode 100644 index 0000000000..4b7b0f2c14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stpncpy.c @@ -0,0 +1,77 @@ +/* PR tree-optimization/80669 - Bad -Wstringop-overflow warnings for stpncpy + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -Wno-restrict -Wno-stringop-truncation" } */ + +#define SIZE_MAX __SIZE_MAX__ + +typedef __SIZE_TYPE__ size_t; + +void sink (char*); + +#define stpncpy (d, s, n) sink (__builtin_stpncpy (d, s, n)) + +size_t value (void); + +static size_t range (size_t min, size_t max) +{ + size_t val = value (); + return val < min || max < val ? min : val; +} + +/* Verify that no -Wstringop-overflow warning is issued for stpncpy + with constant size. (Some tests cause -Wstringop-truncation and + that's expected). */ +void test_cst (char *d) +{ + __builtin_stpncpy (d, "123", 0); + __builtin_stpncpy (d, "123", 1); + __builtin_stpncpy (d, "123", 2); + __builtin_stpncpy (d, "123", 3); + __builtin_stpncpy (d, "123", 4); + __builtin_stpncpy (d, "123", 5); + __builtin_stpncpy (d, "123", 999); + + size_t n = SIZE_MAX / 2; + + __builtin_stpncpy (d, "123", n); + + __builtin_stpncpy (d, "123", n + 1); /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ +} + + +/* Verify that no -Wstringop-overflow warning is issued for stpncpy + with size in some range. */ +void test_rng (char *d) +{ +#define R(min, max) range (min, max) + + __builtin_stpncpy (d, "123", R (0, 1)); + __builtin_stpncpy (d, "123", R (0, 2)); + __builtin_stpncpy (d, "123", R (0, 3)); + __builtin_stpncpy (d, "123", R (0, 4)); + __builtin_stpncpy (d, "123", R (0, 5)); + + __builtin_stpncpy (d, "123", R (1, 2)); + __builtin_stpncpy (d, "123", R (1, 3)); + __builtin_stpncpy (d, "123", R (1, 4)); + __builtin_stpncpy (d, "123", R (1, 5)); + + __builtin_stpncpy (d, "123", R (2, 3)); + __builtin_stpncpy (d, "123", R (2, 4)); + __builtin_stpncpy (d, "123", R (2, 5)); + + __builtin_stpncpy (d, "123", R (3, 4)); + __builtin_stpncpy (d, "123", R (3, 5)); + + __builtin_stpncpy (d, "123", R (4, 5)); + + __builtin_stpncpy (d, "123", R (5, 6)); + + __builtin_stpncpy (d, "123", R (12345, 23456)); + + size_t n = SIZE_MAX / 2; + + __builtin_stpncpy (d, "123", R (n - 1, n + 1)); + + __builtin_stpncpy (d, "123", R (n + 1, n + 2)); /* { dg-warning "specified bound between \[0-9\]+ and \[0-9\]+ exceeds maximum object size \[0-9\]+" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-1.c b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-1.c new file mode 100644 index 0000000000..2eec010ea9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-1.c @@ -0,0 +1,121 @@ +/* Test whether buffer overflow warnings for __*_chk builtins + are emitted properly. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-format -std=gnu99 -ftrack-macro-expansion=0 -fno-tree-dse" } */ +// { dg-skip-if "packed attribute missing for t" { "epiphany-*-*" } } + +extern void abort (void); + +#include "../gcc-c-torture/execute/builtins/chk.h" + +#define va_list __builtin_va_list +#define va_start __builtin_va_start +#define va_end __builtin_va_end + +volatile void *vx; +char buf1[20]; +int x; + +void +test (int arg, ...) +{ + char buf2[20]; + va_list ap; + char *p = &buf1[10], *q; + + memcpy (&buf2[19], "ab", 1); + memcpy (&buf2[19], "ab", 2); /* { dg-warning "writing 2 bytes into a region of size 1" "memcpy" } */ + vx = mempcpy (&buf2[19], "ab", 1); + vx = mempcpy (&buf2[19], "ab", 2); /* { dg-warning "writing 2 " "mempcpy" } */ + memmove (&buf2[18], &buf1[10], 2); + memmove (&buf2[18], &buf1[10], 3); /* { dg-warning "writing 3 " "memmove" } */ + memset (&buf2[16], 'a', 4); + memset (&buf2[15], 'b', 6); /* { dg-warning "writing 6 " "memset" } */ + strcpy (&buf2[18], "a"); + strcpy (&buf2[18], "ab"); /* { dg-warning "writing 3 " "strcpy" } */ + vx = stpcpy (&buf2[18], "a"); + vx = stpcpy (&buf2[18], "ab"); /* { dg-warning "writing 3" "stpcpy" } */ + strncpy (&buf2[18], "a", 2); + + /* Both warnings below are equally meaningful. */ + strncpy (&buf2[18], "a", 3); /* { dg-warning "(writing 3 bytes into a region of size 2|specified bound 3 exceeds destination size 2)" "strncpy" } */ + + strncpy (&buf2[18], "abc", 2); + strncpy (&buf2[18], "abc", 3); /* { dg-warning "writing 3 " "strncpy" } */ + memset (buf2, '\0', sizeof (buf2)); + strcat (&buf2[18], "a"); + memset (buf2, '\0', sizeof (buf2)); + strcat (&buf2[18], "ab"); /* { dg-warning "writing 3 " "strcat" } */ + sprintf (&buf2[18], "%s", buf1); + sprintf (&buf2[18], "%s", "a"); + sprintf (&buf2[18], "%s", "ab"); /* { dg-warning "writing 3 " "sprintf" } */ + sprintf (&buf2[18], "a"); + sprintf (&buf2[18], "ab"); /* { dg-warning "writing 3 " "sprintf" } */ + snprintf (&buf2[18], 2, "%d", x); + /* N argument to snprintf is the size of the buffer. + Although this particular call wouldn't overflow buf2, + incorrect buffer size was passed to it and therefore + we want a warning and runtime failure. */ + snprintf (&buf2[18], 3, "%d", x); /* { dg-warning "specified bound 3 exceeds destination size 2" "snprintf" } */ + va_start (ap, arg); + vsprintf (&buf2[18], "a", ap); + va_end (ap); + + va_start (ap, arg); + vsprintf (&buf2[18], "ab", ap); /* { dg-warning "writing 3" "vsprintf" } */ + va_end (ap); + va_start (ap, arg); + vsnprintf (&buf2[18], 2, "%s", ap); + va_end (ap); + va_start (ap, arg); + /* See snprintf above. */ + vsnprintf (&buf2[18], 3, "%s", ap); /* { dg-warning "specified bound 3 exceeds destination size 2" "vsnprintf" } */ + va_end (ap); + + p = p + 10; + memset (p, 'd', 0); + q = strcpy (p, ""); /* { dg-warning "writing 1 " "strcpy" } */ + + /* This invokes undefined behavior, since we are past the end of buf1. */ + p = p + 10; + memset (p, 'd', 1); /* { dg-warning "writing 1 " "memset" } */ + + memset (q, 'd', 0); + memset (q, 'd', 1); /* { dg-warning "writing 1 " "memset" } */ + q = q - 10; + memset (q, 'd', 10); +} + +char *str = "ABCDEFG"; +typedef struct { char b[16]; } H; + +/* Some brown paper bag bugs found in real applications. + This test is here merely for amusement. */ + +void +test2 (const H h) +{ + char c; + strncpy (&c, str, 3); /* { dg-warning "(writing 3 bytes into a region of size 1|specified bound 3 exceeds destination size 1)" "strncpy" } */ + + struct { char b[4]; } x; + sprintf (x.b, "%s", "ABCD"); /* { dg-warning "writing 5" "sprintf" } */ + + unsigned int i; + memcpy (&i, &h, sizeof (h)); /* { dg-warning "writing 16 " "memcpy" } */ + + unsigned char buf[21]; + memset (buf + 16, 0, 8); /* { dg-warning "writing 8 " "memset" } */ + + typedef struct { __INT32_TYPE__ i, j, k, l; } S; + S *s[3]; + memset (s, 0, sizeof (S) * 3); /* { dg-warning "writing 48 " "memset" } */ + + struct T { char a[8]; char b[4]; char c[10]; } t; + stpcpy (t.c,"Testing..."); /* { dg-warning "writing" "stpcpy" } */ + + char b1[7]; + char b2[4]; + memset (b1, 0, sizeof (b1)); + memset (b2, 0, sizeof (b1)); /* { dg-warning "writing 7" "memset" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-2.c b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-2.c new file mode 100644 index 0000000000..1e401ea3bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-2.c @@ -0,0 +1,137 @@ +/* This file was miscompiled by an earlier version of the object size + checking patch. Object size in one of the memcpy calls was + incorrectly determined to be 0 while it should be (size_t) -1 + (== unknown). */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftrack-macro-expansion=0" } */ + +#include "../gcc-c-torture/execute/builtins/chk.h" + +void *bar (int); +extern void *malloc (__SIZE_TYPE__); + +struct A +{ + int i, j, k; +}; + +/* Here all object sizes are not known at compile time. There + should be no warning, nor any checker functions called. */ + +void +foo (const struct A *x, int y, const unsigned char *z) +{ + unsigned int b; + unsigned char *c = 0; + + b = (x->i & 0xff) == 1 ? 3 : 4; + if (y) + c = bar (x->j * x->k); + + const unsigned char *d = z; + unsigned char *e = c; + unsigned char *f = c + x->j * x->k; + int g = 0; + + while (e < f) + { + unsigned int h = *d++; + + if (h & 128) + { + h = h - 128; + g = e + h * b > f; + if (g) + h = (f - e) / b; + if (b < 4) + do + { + memcpy (e, d, 3); + e += 3; + } + while (--h); + else + do + { + memcpy (e, d, 4); + e += 4; + } + while (--h); + d += b; + } + else + { + h *= b; + g = e + h > f; + if (g) + h = f - e; + memcpy (e, d, h); + e += h; + d += h; + } + } +} + +/* The same routine, slightly modified: + 1) c has known size at compile time + 2) e += h was changed into e += 16. + GCC could actually through VRP determine that + in e += h is (h >= 0 && h <= 127), thus know + it is pointer addition and not subtraction and + know e's __builtin_object_size (e, 0) is at 512, + but we are not there yet. */ + +unsigned char * +baz (const struct A *x, const unsigned char *z) +{ + unsigned int b; + unsigned char *c = 0; + + b = (x->i & 0xff) == 1 ? 3 : 4; + c = malloc (512); + + const unsigned char *d = z; + unsigned char *e = c; + unsigned char *f = c + x->j * x->k; + int g = 0; + + while (e < f) + { + unsigned int h = *d++; + + if (h & 128) + { + h = h - 128; + g = e + h * b > f; + if (g) + h = (f - e) / b; + if (b < 4) + do + { + memcpy (e, d, 3); + e += 3; + } + while (--h); + else + do + { + memcpy (e, d, 513); /* { dg-warning "writing" "memcpy" } */ + e += 4; + } + while (--h); + d += b; + } + else + { + h *= b; + g = e + h > f; + if (g) + h = f - e; + memcpy (e, d, h); + /* e += h; */ + e += 16; + d += h; + } + } + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-4.c b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-4.c new file mode 100644 index 0000000000..2409e597aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-4.c @@ -0,0 +1,504 @@ +/* Test exercising buffer overflow warnings emitted for raw memory and + string manipulation builtins involving ranges of sizes and strings + of varying lengths. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftrack-macro-expansion=0" } */ + +#define INT_MAX __INT_MAX__ +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +static const size_t ssize_max = SIZE_MAX / 2; +static const size_t size_max = SIZE_MAX; + +extern signed char schar_val; +extern signed short sshrt_val; +extern signed int sint_val; +extern signed long slong_val; +extern unsigned char uchar_val; +extern unsigned short ushrt_val; +extern unsigned int uint_val; +extern unsigned long ulong_val; + +#define memcpy(d, s, n) (memcpy ((d), (s), (n)), sink ((d))) +extern void* (memcpy)(void*, const void*, size_t); + +#define mempcpy(d, s, n) (mempcpy ((d), (s), (n)), sink ((d))) +extern void* (mempcpy)(void*, const void*, size_t); + +#define memset(d, c, n) (memset ((d), (c), (n)), sink ((d))) +extern void* (memset)(void*, int, size_t); + +#define bzero(d, n) (bzero ((d), (n)), sink ((d))) +extern void (bzero)(void*, size_t); + +#define strcat(d, s) (strcat ((d), (s)), sink ((d))) +extern char* (strcat)(char*, const char*); + +#define strncat(d, s, n) (strncat ((d), (s), (n)), sink ((d))) +extern char* (strncat)(char*, const char*, size_t); + +#define strcpy(d, s) (strcpy ((d), (s)), sink ((d))) +extern char* (strcpy)(char*, const char*); + +#define strncpy(d, s, n) (strncpy ((d), (s), (n)), sink ((d))) +extern char* (strncpy)(char*, const char*, size_t); + +void sink (void*); + +/* Function to "generate" a random number each time it's called. Declared + (but not defined) and used to prevent GCC from making assumptions about + their values based on the variables uses in the tested expressions. */ +size_t random_unsigned_value (void); +ptrdiff_t random_signed_value (void); + +/* Return a random unsigned value between MIN and MAX. */ + +static inline size_t +unsigned_range (size_t min, size_t max) +{ + const size_t val = random_unsigned_value (); + return val < min || max < val ? min : val; +} + +/* Return a random signed value between MIN and MAX. */ + +static inline ptrdiff_t +signed_range (ptrdiff_t min, ptrdiff_t max) +{ + const ptrdiff_t val = random_signed_value (); + return val < min || max < val ? min : val; +} + +/* For brevity. */ +#define UR(min, max) unsigned_range (min, max) +#define SR(min, max) signed_range (min, max) + +/* Return a pointer to constant string whose length is at least MINLEN + and at most 10. */ +#define S(minlen) \ + (minlen == random_unsigned_value () \ + ? "0123456789" + 10 - minlen : "0123456789") + +/* Test memcpy with a number of bytes bounded by a known range. */ + +void test_memcpy_range (void *d, const void *s) +{ + char buf[5]; + + memcpy (buf, s, UR (0, 5)); + memcpy (buf, s, UR (1, 5)); + memcpy (buf, s, UR (2, 5)); + memcpy (buf, s, UR (3, 5)); + memcpy (buf, s, UR (4, 5)); + + memcpy (buf, s, UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 overflows the destination" } */ + + memcpy (buf + 5, s, UR (1, 2)); /* { dg-warning "writing between 1 and 2 bytes into a region of size 0 overflows the destination" } */ + + memcpy (buf + size_max, s, UR (1, 2)); /* { dg-warning "writing between 1 and 2 bytes into a region of size 0 overflows the destination" "excessive pointer offset" } */ + + memcpy (buf, s, UR (ssize_max, size_max)); /* { dg-warning "writing \[0-9\]+ or more bytes into a region of size 5 overflows the destination" } */ + memcpy (buf, s, UR (ssize_max + 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + memcpy (buf, s, UR (size_max - 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + + /* Exercise memcpy into a destination of unknown size with excessive + number of bytes. */ + memcpy (d, s, UR (ssize_max, size_max)); + memcpy (d, s, UR (ssize_max + 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + + memcpy (buf, s, SR (-1, 1)); + memcpy (buf, s, SR (-3, 2)); + memcpy (buf, s, SR (-5, 3)); + memcpy (buf, s, SR (-7, 4)); + memcpy (buf, s, SR (-9, 5)); + memcpy (buf, s, SR (-11, 6)); + + memcpy (d, s, SR (-1, 1)); + memcpy (d, s, SR (-3, 2)); + memcpy (d, s, SR (-5, 3)); + memcpy (d, s, SR (-7, 4)); + memcpy (d, s, SR (-9, 5)); + memcpy (d, s, SR (-11, 6)); + + memcpy (buf, s, SR (-2, -1)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + memcpy (d, s, SR (-2, -1)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + + /* Even though the following calls are bounded by the range of N's + type they must not cause a warning for obvious reasons. */ + memcpy (buf, s, schar_val); + memcpy (buf, s, sshrt_val); + memcpy (buf, s, sint_val); + memcpy (buf, s, slong_val); + + memcpy (buf, s, uchar_val); + memcpy (buf, s, ushrt_val); + memcpy (buf, s, uint_val); + memcpy (buf, s, ulong_val); + + memcpy (buf, s, schar_val + 1); + memcpy (buf, s, sshrt_val + 2); + memcpy (buf, s, sint_val + 3); + memcpy (buf, s, slong_val + 4); + + memcpy (d, s, uchar_val + 5); + memcpy (d, s, ushrt_val + 6); + memcpy (d, s, uint_val + 7); + memcpy (d, s, ulong_val + 8); + + memcpy (d, s, schar_val); + memcpy (d, s, sshrt_val); + memcpy (d, s, sint_val); + memcpy (d, s, slong_val); + + memcpy (d, s, uchar_val); + memcpy (d, s, ushrt_val); + memcpy (d, s, uint_val); + memcpy (d, s, ulong_val); + + memcpy (d, s, schar_val + 1); + memcpy (d, s, sshrt_val + 2); + memcpy (d, s, sint_val + 3); + memcpy (d, s, slong_val + 4); + + memcpy (d, s, uchar_val + 5); + memcpy (d, s, ushrt_val + 6); + memcpy (d, s, uint_val + 7); + memcpy (d, s, ulong_val + 8); +} + +/* Test mempcpy with a number of bytes bounded by a known range. */ + +void test_mempcpy_range (void *d, const void *s) +{ + char buf[5]; + + mempcpy (buf, s, UR (0, 5)); + mempcpy (buf, s, UR (1, 5)); + mempcpy (buf, s, UR (2, 5)); + mempcpy (buf, s, UR (3, 5)); + mempcpy (buf, s, UR (4, 5)); + + mempcpy (buf, s, UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 overflows the destination" } */ + + mempcpy (buf, s, UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 overflows the destination" } */ + + mempcpy (buf, s, UR (ssize_max, size_max)); /* { dg-warning "writing \[0-9\]+ or more bytes into a region of size 5 overflows the destination" } */ + mempcpy (buf, s, UR (ssize_max + 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + mempcpy (buf, s, UR (size_max - 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + + /* Exercise mempcpy into a destination of unknown size with excessive + number of bytes. */ + mempcpy (d, s, UR (ssize_max, size_max)); + mempcpy (d, s, UR (ssize_max + 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ +} + +/* Test memset with a number of bytes bounded by a known range. */ + +void test_memset_range (void *d) +{ + char buf[5]; + + memset (buf, 0, UR (0, 5)); + memset (buf, 0, UR (1, 5)); + memset (buf, 0, UR (2, 5)); + memset (buf, 0, UR (3, 5)); + memset (buf, 0, UR (4, 5)); + + memset (buf, 0, UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 overflows the destination" } */ + + memset (buf, 0, UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 overflows the destination" } */ + + memset (buf, 0, UR (ssize_max, size_max)); /* { dg-warning "writing \[0-9\]+ or more bytes into a region of size 5 overflows the destination" } */ + memset (buf, 0, UR (ssize_max + 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + memset (buf, 0, UR (size_max - 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + + /* Exercise memset into a destination of unknown size with excessive + number of bytes. */ + memset (d, 0, UR (ssize_max, size_max)); + memset (d, 0, UR (ssize_max + 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ +} + +/* Test bzero with a number of bytes bounded by a known range. */ + +void test_bzero_range (void *d) +{ + char buf[5]; + + bzero (buf, UR (0, 5)); + bzero (buf, UR (1, 5)); + bzero (buf, UR (2, 5)); + bzero (buf, UR (3, 5)); + bzero (buf, UR (4, 5)); + + bzero (buf, UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 overflows the destination" } */ + + bzero (buf, UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 overflows the destination" } */ + + bzero (buf, UR (ssize_max, size_max)); /* { dg-warning "writing \[0-9\]+ or more bytes into a region of size 5 overflows the destination" } */ + bzero (buf, UR (ssize_max + 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + bzero (buf, UR (size_max - 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + + /* Exercise bzero into a destination of unknown size with excessive + number of bytes. */ + bzero (d, UR (ssize_max, size_max)); + bzero (d, UR (ssize_max + 1, size_max)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ +} + +/* Test strcat with an argument referencing a non-constant string of + lengths in a known range. */ + +void test_strcat_range (void) +{ + char buf[5] = ""; + + strcat (buf, S (0)); + strcat (buf, S (1)); + strcat (buf, S (2)); + strcat (buf, S (3)); + strcat (buf, S (4)); + strcat (buf, S (5)); /* { dg-warning "writing between 6 and 11 bytes into a region of size 5 " } */ + + { + /* The implementation of the warning isn't smart enough to determine + the length of the string in the buffer so it assumes it's empty + and issues the warning basically for the same cases as strcat. */ + char buf2[5] = "12"; + strcat (buf2, S (4)); /* { dg-warning "writing 5 bytes into a region of size 3" "strcat to a non-empty string" { xfail *-*-* } } */ + } +} + +/* Verify that strcpy with an unknown source string doesn't cause + warnings unless the destination has zero size. */ + +void test_strcpy (const char *src) +{ + struct A { char a[2]; char b[3]; } a; + + strcpy (a.a, src); + strcpy (a.a + 1, src); + + /* There must be enough room in the destination for the terminating + nul, otherwise verify that a warning is issued. + The following works as expected with __builtin___strcpy_chk and + __builtin_object_size because they see that the offset is from + the a.a array. When optimization is enabled, it isn't detected + by __bultin_strcpy (when __builtin_object_size isn't called + explicitly) because by the time it's seen the offset has been + transformed to one from the beginning of the whole object, i.e., + as if it had been written as (char*)&a + 2 . Then the destination + size is taken to be the rest of the whole object. It is detected + by __builtin_strcpy when optimization is not enabled because then + the &a.a + 2 expression is preserved. But without optimization + an ordinary call to strcpy isn't transformed to __builtin_strcpy + and so it can't be detected here (since the rest of the test + relies on optimization). */ + strcpy (a.a + 2, src); /* { dg-warning "writing at least 1 byte into a region of size 0 " "strcpy into empty substring" { xfail *-*-* } } */ + + /* This does work. */ + strcpy (a.a + 5, src); /* { dg-warning "writing 1 or more bytes into a region of size 0 " } */ + + /* As does this. */ + strcpy (a.a + 17, src); /* { dg-warning "writing 1 or more bytes into a region of size 0 " } */ +} + +/* Test strcpy with a non-constant source string of length in a known + range. */ + +void test_strcpy_range (void) +{ + char buf[5]; + + strcpy (buf, S (0)); + strcpy (buf, S (1)); + strcpy (buf, S (2)); + strcpy (buf, S (4)); + strcpy (buf, S (5)); /* { dg-warning "writing between 6 and 11 bytes into a region of size 5 " } */ + strcpy (buf, S (6)); /* { dg-warning "writing between 7 and 11 bytes" } */ + strcpy (buf, S (7)); /* { dg-warning "writing between 8 and 11 bytes" } */ + strcpy (buf, S (8)); /* { dg-warning "writing between 9 and 11 bytes" } */ + strcpy (buf, S (9)); /* { dg-warning "writing between 10 and 11 bytes" } */ + strcpy (buf, S (10)); /* { dg-warning "writing 11 bytes" } */ + + strcpy (buf + 5, S (0)); /* { dg-warning "writing between 1 and 11 bytes" } */ + + strcpy (buf + 17, S (0)); /* { dg-warning "writing between 1 and 11 bytes " } */ +} + +/* Test strncat with an argument referencing a non-constant string of + lengths in a known range. */ + +void test_strncat_range (void) +{ + char buf[5] = ""; + + strncat (buf, S (0), 0); + strncat (buf, S (0), 1); + strncat (buf, S (0), 2); + strncat (buf, S (0), 3); + strncat (buf, S (0), 4); + + strncat (buf + 5, S (0), 0); + + strncat (buf + 5, S (0), 1); /* { dg-warning "specified \(bound|size\) 1 exceeds destination size 0" } */ + strncat (buf + 5, S (1), 1); /* { dg-warning "specified \(bound|size\) 1 exceeds destination size 0" } */ + + /* Strncat always appends a terminating null after copying the N + characters so the following triggers a warning pointing out + that specifying sizeof(buf) as the upper bound may cause + the nul to overflow the destination. */ + strncat (buf, S (0), 5); /* { dg-warning "specified \(bound|size\) 5 equals destination size" } */ + strncat (buf, S (0), 6); /* { dg-warning "specified \(bound|size\) 6 exceeds destination size 5" } */ + + strncat (buf, S (1), 0); + strncat (buf, S (1), 1); + strncat (buf, S (1), 2); + strncat (buf, S (1), 3); + strncat (buf, S (1), 4); + strncat (buf, S (1), 5); /* { dg-warning "specified \(bound|size\) 5 equals destination size" } */ + strncat (buf, S (1), 6); /* { dg-warning "specified \(bound|size\) 6 exceeds destination size 5" } */ + strncat (buf, S (2), 6); /* { dg-warning "specified \(bound|size\) 6 exceeds destination size 5" } */ + + /* The following could just as well say "writing 6 bytes into a region + of size 5. Either would be correct and probably equally as clear + in this case. But when the length of the source string is not known + at all then the bound warning seems clearer. */ + strncat (buf, S (5), 6); /* { dg-warning "specified \(bound|size\) 6 exceeds destination size 5" } */ + strncat (buf, S (7), 6); /* { dg-warning "specified \(bound|size\) 6 exceeds destination size 5" } */ + + { + /* The implementation of the warning isn't smart enough to determine + the length of the string in the buffer so it assumes it's empty + and issues the warning basically for the same cases as strncpy. */ + char buf2[5] = "12"; + strncat (buf2, S (4), 4); /* { dg-warning "writing 5 bytes into a region of size 3" "strncat to a non-empty string" { xfail *-*-* } } */ + } +} + +/* Test strncat_chk with an argument referencing a non-constant string + of lengths in a known range. */ + +void test_strncat_chk_range (char *d) +{ + char buf[5] = ""; + +#define strncat_chk(d, s, n) \ + __builtin___strncat_chk ((d), (s), (n), __builtin_object_size (d, 1)); + + strncat_chk (buf, S (0), 1); + strncat_chk (buf, S (0), 2); + strncat_chk (buf, S (0), 3); + strncat_chk (buf, S (0), 4); + strncat_chk (buf, S (0), 5); /* { dg-warning "specified \(bound|size\) 5 equals destination size" } */ + + strncat_chk (buf, S (5), 1); + strncat_chk (buf, S (5), 2); + strncat_chk (buf, S (5), 3); + strncat_chk (buf, S (5), 4); + strncat_chk (buf, S (5), 5); /* { dg-warning "specified \(bound|size\) 5 equals destination size" } */ + + strncat_chk (buf, S (5), 10); /* { dg-warning "specified \(bound|size\) \[0-9\]+ exceeds destination size 5" } */ + + strncat_chk (d, S (5), size_max); /* { dg-warning "specified \(bound|size\) \[0-9\]+ exceeds maximum object size " } */ +} + +/* Test strncpy with a non-constant source string of length in a known + range and a constant number of bytes. */ + +void test_strncpy_string_range (char *d) +{ + char buf[5]; + + strncpy (buf, S (0), 0); + strncpy (buf, S (0), 1); + strncpy (buf, S (0), 2); + strncpy (buf, S (0), 3); + strncpy (buf, S (0), 4); + strncpy (buf, S (0), 5); + strncpy (buf, S (0), 6); /* { dg-warning "writing 6 bytes into a region of size 5 " } */ + + strncpy (buf, S (6), 4); + strncpy (buf, S (7), 5); + strncpy (buf, S (8), 6); /* { dg-warning "writing 6 bytes into a region of size 5 " } */ + + strncpy (buf, S (1), ssize_max - 1); /* { dg-warning "writing \[0-9\]+ bytes into a region of size 5" } */ + strncpy (buf, S (2), ssize_max); /* { dg-warning "writing \[0-9\]+ bytes into a region of size 5" } */ + strncpy (buf, S (3), ssize_max + 1); /* { dg-warning "specified \(bound|size\) \[0-9\]+ exceeds maximum object size" } */ + strncpy (buf, S (4), size_max); /* { dg-warning "specified \(bound|size\) \[0-9\]+ exceeds maximum object size" } */ + + /* Exercise strncpy into a destination of unknown size with a valid + and invalid constant number of bytes. */ + strncpy (d, S (1), ssize_max - 1); + strncpy (d, S (2), ssize_max); + strncpy (d, S (3), ssize_max + 1); /* { dg-warning "specified \(bound|size\) \[0-9\]+ exceeds maximum object size" } */ + strncpy (d, S (4), size_max); /* { dg-warning "specified \(bound|size\) \[0-9\]+ exceeds maximum object size" } */ +} + +/* Test strncpy with a non-constant source string of length in a known + range and a non-constant number of bytes also in a known range. */ + +void test_strncpy_string_count_range (char *dst, const char *src) +{ + char buf[5]; + + strncpy (buf, S (0), UR (0, 1)); + strncpy (buf, S (0), UR (0, 2)); + strncpy (buf, S (0), UR (0, 3)); + strncpy (buf, S (0), UR (0, 4)); + strncpy (buf, S (0), UR (0, 5)); + strncpy (buf, S (0), UR (0, 6)); + strncpy (buf, S (0), UR (1, 6)); + strncpy (buf, S (0), UR (2, 6)); + strncpy (buf, S (0), UR (3, 6)); + strncpy (buf, S (0), UR (4, 6)); + strncpy (buf, S (0), UR (5, 6)); + + strncpy (buf, S (9), UR (0, 1)); + strncpy (buf, S (8), UR (0, 2)); + strncpy (buf, S (7), UR (0, 3)); + strncpy (buf, S (6), UR (0, 4)); + strncpy (buf, S (8), UR (0, 5)); + strncpy (buf, S (7), UR (0, 6)); + strncpy (buf, S (6), UR (1, 6)); + strncpy (buf, S (5), UR (2, 6)); + strncpy (buf, S (9), UR (3, 6)); + strncpy (buf, S (8), UR (4, 6)); + strncpy (buf, S (7), UR (5, 6)); + + strncpy (buf, S (0), UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 " } */ + strncpy (buf, S (1), UR (7, 8)); /* { dg-warning "writing between 7 and 8 bytes into a region of size 5 " } */ + strncpy (buf, S (2), UR (ssize_max, ssize_max + 1)); /* { dg-warning "writing \[0-9\]+ or more bytes into a region of size 5 " } */ + + strncpy (buf, S (2), UR (ssize_max + 1, ssize_max + 2)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ + + strncpy (buf + 5, S (0), UR (0, 1)); + strncpy (buf + 5, S (1), UR (0, 1)); + strncpy (buf + 5, S (0), UR (1, 2)); /* { dg-warning "writing between 1 and 2 bytes into a region of size 0 " } */ + strncpy (buf + 5, S (1), UR (1, 2)); /* { dg-warning "writing between 1 and 2 bytes into a region of size 0 " } */ + + strncpy (buf, src, UR (0, 1)); + strncpy (buf, src, UR (0, 2)); + strncpy (buf, src, UR (0, 3)); + strncpy (buf, src, UR (0, 4)); + strncpy (buf, src, UR (0, 5)); + strncpy (buf, src, UR (0, 6)); + strncpy (buf, src, UR (1, 6)); + strncpy (buf, src, UR (2, 6)); + strncpy (buf, src, UR (3, 6)); + strncpy (buf, src, UR (4, 6)); + strncpy (buf, src, UR (5, 6)); + strncpy (buf, src, UR (6, 7)); /* { dg-warning "writing between 6 and 7 bytes into a region of size 5 " } */ + + /* Exercise strncpy into a destination of unknown size with a valid + and invalid constant number of bytes. */ + strncpy (dst, S (0), UR (5, 6)); + strncpy (dst, S (1), UR (6, 7)); + strncpy (dst, S (2), UR (7, 8)); + + strncpy (dst, S (3), UR (ssize_max, ssize_max + 1)); + + strncpy (dst, S (4), UR (ssize_max + 1, ssize_max + 2)); /* { dg-warning "specified \(bound|size\) between \[0-9\]+ and \[0-9\]+ exceeds maximum object size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-5.c b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-5.c new file mode 100644 index 0000000000..7d5b03b9c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-5.c @@ -0,0 +1,260 @@ +/* Test exercising -Wstringop-overflow warnings. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstringop-overflow=1 -Wno-array-bounds" } */ + +#define offsetof(type, mem) __builtin_offsetof (type, mem) + +/* Return the number of bytes from member MEM of TYPE to the end + of object OBJ. */ +#define offsetfrom(type, obj, mem) (sizeof (obj) - offsetof (type, mem)) + + +typedef __SIZE_TYPE__ size_t; +extern void* memcpy (void*, const void*, size_t); +extern void* memset (void*, int, __SIZE_TYPE__); + + +struct A { char a, b; }; +struct B { struct A a; char c, d; }; + +/* Function to call to "escape" pointers from tests below to prevent + GCC from assuming the values of the objects they point to stay + the unchanged. */ +void escape (void*, ...); + +/* Function to "generate" a random number each time it's called. Declared + (but not defined) and used to prevent GCC from making assumptions about + their values based on the variables uses in the tested expressions. */ +size_t random_unsigned_value (void); + +/* Return a random unsigned value between MIN and MAX. */ + +static inline size_t +range (size_t min, size_t max) +{ + const size_t val = random_unsigned_value (); + return val < min || max < val ? min : val; +} + +/* Verify that writing past the end of a local array is diagnosed. */ + +void test_memop_warn_local (const void *src) +{ + size_t n; + + n = range (8, 32); + + struct A a[2]; + + memcpy (a, src, n); /* { dg-warning "writing between 8 and 32 bytes into a region of size 4 overflows the destination" } */ + escape (a, src); + + /* At -Wstringop-overflow=1 the destination is considered to be + the whole array and its size is therefore sizeof a. */ + memcpy (&a[0], src, n); /* { dg-warning "writing between 8 and 32 bytes into a region of size 4 overflows the destination" } */ + escape (a, src); + + /* Verify the same as above but by writing into the first mmeber + of the first element of the array. */ + memcpy (&a[0].a, src, n); /* { dg-warning "writing between 8 and 32 bytes into a region of size 4 overflows the destination" } */ + escape (a, src); + + n = range (12, 32); + + struct B b[2]; + + memcpy (&b[0], src, n); /* { dg-warning "writing between 12 and 32 bytes into a region of size 8 overflows the destination" } */ + escape (b); + + /* The following idiom of clearing multiple members of a struct is + used in a few places in the Linux kernel. Verify that a warning + is issued for it when it writes past the end of the array object. */ + memset (&b[0].a.b, 0, offsetfrom (struct B, b, a.b) + 1); /* { dg-warning "writing 8 bytes into a region of size 7" } */ + escape (b); + + memset (&b->a.b, 0, offsetfrom (struct B, b, a.b) + 1); /* { dg-warning "writing 8 bytes into a region of size 7" } */ + escape (b); + + memset (&b[0].c, 0, offsetfrom (struct B, b, c) + 1); /* { dg-warning "writing 7 bytes into a region of size 6" } */ + escape (b); + + memset (&b->c, 0, offsetfrom (struct B, b, c) + 1); /* { dg-warning "writing 7 bytes into a region of size 6" } */ + escape (b); + + memset (&b[0].d, 0, offsetfrom (struct B, b, d) + 1); /* { dg-warning "writing 6 bytes into a region of size 5" } */ + escape (b); + + memset (&b->d, 0, offsetfrom (struct B, b, d) + 1); /* { dg-warning "writing 6 bytes into a region of size 5" } */ + escape (b); + + /* Same as above but clearing just members of the second element + of the array. */ + memset (&b[1].a.b, 0, offsetfrom (struct B, b[1], a.b) + 1); /* { dg-warning "writing 4 bytes into a region of size 3" } */ + escape (b); + + memset (&b[1].c, 0, offsetfrom (struct B, b[1], c) + 1); /* { dg-warning "writing 3 bytes into a region of size 2" } */ + escape (b); + + memset (&b[1].d, 0, offsetfrom (struct B, b[1], d) + 1); /* { dg-warning "writing 2 bytes into a region of size 1" } */ + escape (b); +} + +/* Verify that writing past the end of a dynamically allocated array + of known size is diagnosed. */ + +void test_memop_warn_alloc (const void *src) +{ + size_t n; + + n = range (8, 32); + + struct A *a = __builtin_malloc (sizeof *a * 2); + + memcpy (a, src, n); /* { dg-warning "writing between 8 and 32 bytes into a region of size 4 " "memcpy into allocated" } */ + escape (a, src); + + /* At -Wstringop-overflow=1 the destination is considered to be + the whole array and its size is therefore sizeof a. */ + memcpy (&a[0], src, n); /* { dg-warning "writing between 8 and 32 bytes into a region of size 4 overflows the destination" "memcpy into allocated" } */ + escape (a, src); + + /* Verify the same as above but by writing into the first mmeber + of the first element of the array. */ + memcpy (&a[0].a, src, n); /* { dg-warning "writing between 8 and 32 bytes into a region of size " "memcpy into allocated" } */ + escape (a, src); + + n = range (12, 32); + + struct B *b = __builtin_malloc (sizeof (struct B[2])); + + memcpy (&b[0], src, n); /* { dg-warning "writing between 12 and 32 bytes into a region of size 8 " "memcpy into allocated" } */ + escape (b); + + /* The following idiom of clearing multiple members of a struct is + used in a few places in the Linux kernel. Verify that a warning + is issued for it when it writes past the end of the array object. */ + memset (&b[0].a.b, 0, offsetfrom (struct B, struct B[2], a.b) + 1); /* { dg-warning "writing 8 bytes into a region of size " "memcpy into allocated" } */ + escape (b); + + memset (&b->a.b, 0, offsetfrom (struct B, struct B[2], a.b) + 1); /* { dg-warning "writing 8 bytes into a region of size " "memcpy into allocated" } */ + escape (b); + + memset (&b[0].c, 0, offsetfrom (struct B, struct B[2], c) + 1); /* { dg-warning "writing 7 bytes into a region of size " "memcpy into allocated" } */ + escape (b); + + memset (&b->c, 0, offsetfrom (struct B, struct B[2], c) + 1); /* { dg-warning "writing 7 bytes into a region of size " "memcpy into allocated" } */ + escape (b); + + memset (&b[0].d, 0, offsetfrom (struct B, struct B[2], d) + 1); /* { dg-warning "writing 6 bytes into a region of size " "memcpy into allocated" } */ + escape (b); + + memset (&b->d, 0, offsetfrom (struct B, struct B[2], d) + 1); /* { dg-warning "writing 6 bytes into a region of size " "memcpy into allocated" } */ + escape (b); + + /* Same as above but clearing just elements of the second element + of the array. */ + memset (&b[1].a.b, 0, offsetfrom (struct B, b[1], a.b) + 1); /* { dg-warning "writing 4 bytes into a region of size " "memcpy into allocated" } */ + escape (b); + + memset (&b[1].c, 0, offsetfrom (struct B, b[1], c) + 1); /* { dg-warning "writing 3 bytes into a region of size " "memcpy into allocated" } */ + escape (b); + + memset (&b[1].d, 0, offsetfrom (struct B, b[1], d) + 1); /* { dg-warning "writing 2 bytes into a region of size 1" "memcpy into allocated" } */ + escape (b); +} + + +void test_memop_nowarn (const void *src) +{ + struct B b[2]; + + size_t n = range (sizeof b, 32); + + /* Verify that clearing the whole array is not diagnosed regardless + of whether the expression pointing to its beginning is obtained + from the array itself or its first member(s). */ + memcpy (b, src, n); + escape (b); + + memcpy (&b[0], src, n); + escape (b); + + memcpy (&b[0].a, src, n); + escape (b, src); + + memcpy (&b[0].a.a, src, n); + escape (b, src); + + /* Clearing multiple elements of an array of structs. */ + memset (&b[0].a.b, 0, sizeof b - offsetof (struct B, a.b)); + escape (b); + + memset (&b->a.b, 0, sizeof b - offsetof (struct B, a.b)); + escape (b); + + memset (&b[0].c, 0, sizeof b - offsetof (struct B, c)); + escape (b); + + memset (&b->c, 0, sizeof b - offsetof (struct B, c)); + escape (b); + + memset (&b[0].d, 0, sizeof b - offsetof (struct B, d)); + escape (b); + + memset (&b->d, 0, sizeof b - offsetof (struct B, d)); + escape (b); + + /* Same as above but clearing just elements of the second element + of the array. */ + memset (&b[1].a.b, 0, sizeof b[1] - offsetof (struct B, a.b)); + escape (b); + + memset (&b[1].c, 0, sizeof b[1] - offsetof (struct B, c)); + escape (b); + + memset (&b[1].d, 0, sizeof b[1] - offsetof (struct B, d)); + escape (b); +} + + +/* The foollowing function could specify in its API that it takes + an array of exactly two elements, as shown below. Verify that + writing into both elements is not diagnosed. */ +void test_memop_nowarn_arg (struct A[2], const void*); + +void test_memop_nowarn_arg (struct A *a, const void *src) +{ + memcpy (a, src, 2 * sizeof *a); + escape (a, src); + + memcpy (a, src, range (2 * sizeof *a, 123)); + escape (a, src); +} + + +struct C { char a[3], b; }; +struct D { struct C c; char d, e; }; + +extern char* strncpy (char*, const char*, __SIZE_TYPE__); + +void test_stringop_warn (void) +{ + size_t n = range (2 * sizeof (struct D) + 1, 33); + + struct C c[2]; + + /* Similarly, at -Wstringop-overflow=1 the destination is considered + to be the whole array and its size is therefore sizeof c. */ + strncpy (c[0].a, "123", n); /* { dg-warning "writing between 13 and 33 bytes into a region of size 8 overflows the destination" } */ + + escape (c); +} + + +void test_stringop_nowarn (void) +{ + struct D d[2]; + + strncpy (d[0].c.a, "123", range (sizeof d, 32)); + escape (d); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-6.c b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-6.c new file mode 100644 index 0000000000..9572ce15cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-6.c @@ -0,0 +1,112 @@ +/* Test exercising -Wrawmem-overflow and -Wstringop-overflow warnings. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstringop-overflow=2" } */ + +#define offsetof(type, mem) __builtin_offsetof (type, mem) + +/* Return the number of bytes from member MEM of TYPE to the end + of object OBJ. */ +#define offsetfrom(type, obj, mem) (sizeof (obj) - offsetof (type, mem)) + + +typedef __SIZE_TYPE__ size_t; +extern void* memcpy (void*, const void*, size_t); +extern void* memset (void*, int, __SIZE_TYPE__); + + +struct A { char a, b; }; +struct B { struct A a; char c, d; }; + +/* Function to call to "escape" pointers from tests below to prevent + GCC from assuming the values of the objects they point to stay + the unchanged. */ +void escape (void*, ...); + +/* Function to "generate" a random number each time it's called. Declared + (but not defined) and used to prevent GCC from making assumptions about + their values based on the variables uses in the tested expressions. */ +size_t random_unsigned_value (void); + +/* Return a random unsigned value between MIN and MAX. */ + +static inline size_t +range (size_t min, size_t max) +{ + const size_t val = random_unsigned_value (); + return val < min || max < val ? min : val; +} + + +void test_memop_warn_object (const void *src) +{ + unsigned n = range (17, 29); + + struct A a[2]; + + /* At both -Wstringop-overflow=2, like at 1, the destination of functions + that operate on raw memory is considered to be the whole array and its + size is therefore sizeof a. */ + memcpy (&a[0], src, n); /* { dg-warning "writing between 17 and 29 bytes into a region of size 4 overflows the destination" } */ + escape (a); +} + +void test_memop_warn_subobject (const void *src) +{ + unsigned n = range (17, 31); + + struct B b[2]; + + /* At -Wrawmem-overflow=2 the destination is considered to be + the member sobobject of the first array element and its size + is therefore sizeof b[0].a. */ + memcpy (&b[0].a, src, n); /* { dg-warning "writing between 17 and 31 bytes into a region of size 8 overflows the destination" } */ + + escape (b); +} + +void test_memop_nowarn_subobject (void) +{ + struct B b[2]; + + /* The following idiom of clearing multiple members of a struct + has been seen in a few places in the Linux kernel. Verify + that a warning is not issued for it. */ + memset (&b[0].c, 0, sizeof b[0] - offsetof (struct B, c)); + + escape (b); +} + +struct C { char a[3], b; }; +struct D { struct C c; char d, e; }; + +extern char* strncpy (char*, const char*, __SIZE_TYPE__); + +void test_stringop_warn_object (const char *str) +{ + unsigned n = range (2 * sizeof (struct D), 32); + + struct C c[2]; + + /* Similarly, at -Wstringop-overflow=2 the destination is considered + to be the array member of the first element of the array c and its + size is therefore sizeof c[0].a. */ + strncpy (c[0].a, "123", n); /* { dg-warning "writing between 12 and 32 bytes into a region of size 3 overflows the destination" } */ + escape (c); + + strncpy (c[0].a, str, n); /* { dg-warning "writing between 12 and 32 bytes into a region of size 3 overflows the destination" } */ + escape (c); +} + +void test_stringop_warn_subobject (const char *src) +{ + unsigned n = range (2 * sizeof (struct D), 32); + + struct D d[2]; + + /* Same as above. */ + strncpy (d[0].c.a, "123", n); /* { dg-warning "writing between 12 and 32 bytes into a region of size 3 overflows the destination" } */ + escape (d); + + strncpy (d[0].c.a, src, n); /* { dg-warning "writing between 12 and 32 bytes into a region of size 3 overflows the destination" } */ + escape (d); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-7.c b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-7.c new file mode 100644 index 0000000000..d3908a2cd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-7.c @@ -0,0 +1,72 @@ +/* Verify that -Wstringop-overflow doesn't cause false positives for + anti-ranges. Note that not all of the statements below result in + the memset argument being represented as an anti-range. + + { dg-do compile } + { dg-options "-O2 -Wstringop-overflow" } */ + +#define SCHAR_MAX __SCHAR_MAX__ +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +#define SHRT_MAX __SHRT_MAX__ +#define USHRT_MAX (SHRT_MAX * 2U + 1) + +#define INT_MAX __INT_MAX__ +#define UINT_MAX (INT_MAX * 2U + 1) + +#define LONG_MAX __LONG_MAX__ +#define ULONG_MAX (LONG_MAX * 2LU + 1) + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +#define TEST_AR_1(T, prefix) \ + void test_ar_1_ ## prefix (void *d, T n) \ + { \ + if (n == prefix ## _MAX - 1) \ + n = prefix ## _MAX - 2; \ + __builtin_memset (d, 0, n); \ + } typedef void dummy + +#define TEST_AR_2(T, prefix) \ + void test_ar_2_ ## prefix (void *d, T n) \ + { \ + if (prefix ## _MAX - 2 <= n && n <= prefix ## _MAX - 1) \ + n = prefix ## _MAX - 3; \ + __builtin_memset (d, 0, n); \ + } typedef void dummy + +/* Verify antirange where MIN == MAX. */ +TEST_AR_1 (signed char, SCHAR); +TEST_AR_1 (unsigned char, UCHAR); + +TEST_AR_1 (short, SHRT); +TEST_AR_1 (unsigned short, USHRT); + +TEST_AR_1 (int, INT); +TEST_AR_1 (unsigned, UINT); + +TEST_AR_1 (long, LONG); +TEST_AR_1 (unsigned long, ULONG); + +TEST_AR_1 (ptrdiff_t, PTRDIFF); +TEST_AR_1 (size_t, SIZE); + +/* Verify antirange where MIN < MAX. */ +TEST_AR_2 (signed char, SCHAR); +TEST_AR_2 (unsigned char, UCHAR); + +TEST_AR_2 (short, SHRT); +TEST_AR_2 (unsigned short, USHRT); + +TEST_AR_2 (int, INT); +TEST_AR_2 (unsigned, UINT); + +TEST_AR_2 (long, LONG); +TEST_AR_2 (unsigned long, ULONG); + +TEST_AR_2 (ptrdiff_t, PTRDIFF); +TEST_AR_2 (size_t, SIZE); diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-8.c b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-8.c new file mode 100644 index 0000000000..f2e9c48117 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-8.c @@ -0,0 +1,173 @@ +/* Test exercising -Wstringop-overread warnings for reading past the end. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstringop-overread -ftrack-macro-expansion=0" } */ + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +#define offsetof(type, mem) __builtin_offsetof (type, mem) + +/* Return the number of bytes from member MEM of TYPE to the end + of object OBJ. */ +#define offsetfrom(type, obj, mem) (sizeof (obj) - offsetof (type, mem)) + + +typedef __SIZE_TYPE__ size_t; +extern void* memchr (const void*, int, size_t); +extern int memcmp (const void*, const void*, size_t); +extern void* memcpy (void*, const void*, size_t); +extern void* memmove (void*, const void*, size_t); +extern void* mempcpy (void*, const void*, size_t); + +#define memchr(d, s, n) sink (memchr (d, s, n)) +#define memcmp(d, s, n) sink (d, memcmp (d, s, n)) +#define memcpy(d, s, n) sink (memcpy (d, s, n)) +#define memmove(d, s, n) sink (memmove (d, s, n)) +#define mempcpy(d, s, n) sink (mempcpy (d, s, n)) + +struct A { char a, b; }; +struct B { struct A a; char c, d; }; + +/* Function to call to "escape" pointers from tests below to prevent + GCC from assuming the values of the objects they point to stay + the unchanged. */ +void sink (void*, ...); + +/* Function to "generate" a random number each time it's called. Declared + (but not defined) and used to prevent GCC from making assumptions about + their values based on the variables uses in the tested expressions. */ +size_t random_unsigned_value (void); + +/* Return a random unsigned value between MIN and MAX. */ + +static inline size_t +range (size_t min, size_t max) +{ + const size_t val = random_unsigned_value (); + return val < min || max < val ? min : val; +} + +#define R(min, max) range (min, max) + +/* Verify that reading beyond the end of a local array is diagnosed. */ + +void test_memop_warn_local (void *p, const void *q) +{ + memcpy (p, "1234", R (6, 7)); /* { dg-warning "reading between 6 and 7 bytes from a region of size 5" } */ + + struct A a[2]; + + memcpy (p, a, R (7, 8)); /* { dg-warning "reading between 7 and 8 bytes from a region of size 4" } */ + + /* At -Wstringop-overflow=1 the destination is considered to be + the whole array and its size is therefore sizeof a. */ + memcpy (p, &a[0], R (8, 9)); /* { dg-warning "reading between 8 and 9 bytes from a region of size 4" } */ + + /* Verify the same as above but by reading from the first mmeber + of the first element of the array. */ + memcpy (p, &a[0].a, R (8, 9)); /* { dg-warning "reading between 8 and 9 bytes from a region of size 4" } */ + + struct B b[2]; + + memcpy (p, &b[0], R (12, 32)); /* { dg-warning "reading between 12 and 32 bytes from a region of size 8" } */ + + /* Verify memchr/memcmp. */ + int i = R (0, 255); + memchr ("", i, 2); /* { dg-warning "specified bound 2 exceeds source size 1" "memchr" } */ + memchr ("", i, 2); /* { dg-warning "specified bound 2 exceeds source size 1" "memchr" } */ + memchr ("123", i, 5); /* { dg-warning "specified bound 5 exceeds source size 4" "memchr" } */ + memchr (a, i, sizeof a + 1); /* { dg-warning "specified bound 5 exceeds source size 4" "memchr" } */ + + memcmp (p, "", 2); /* { dg-warning "specified bound 2 exceeds source size 1" "memcmp" } */ + memcmp (p, "123", 5); /* { dg-warning "specified bound 5 exceeds source size 4" "memcmp" } */ + memcmp (p, a, sizeof a + 1); /* { dg-warning "specified bound 5 exceeds source size 4" "memcmp" } */ + + size_t n = PTRDIFF_MAX + (size_t)1; + memchr (p, 1, n); /* { dg-warning "exceeds maximum object size" "memchr" } */ + memcmp (p, q, n); /* { dg-warning "exceeds maximum object size" "memcmp" } */ + + n = SIZE_MAX; + memchr (p, 1, n); /* { dg-warning "exceeds maximum object size" "memchr" } */ + memcmp (p, q, n); /* { dg-warning "exceeds maximum object size" "memcmp" } */ +} + +/* Verify that reading beyond the end of a dynamically allocated array + of known size is diagnosed. */ + +void test_memop_warn_alloc (void *p) +{ + size_t n; + + n = range (8, 32); + + struct A *a = __builtin_malloc (sizeof *a * 2); + + memcpy (p, a, n); /* { dg-warning "reading between 8 and 32 bytes from a region of size 4" "memcpy from allocated" } */ + + memcpy (p, &a[0], n); /* { dg-warning "reading between 8 and 32 bytes from a region of size 4" "memcpy from allocated" } */ + + memcpy (p, &a[0].a, n); /* { dg-warning "reading between 8 and 32 bytes from a region of size " "memcpy from allocated" } */ + + n = range (12, 32); + + struct B *b = __builtin_malloc (sizeof *b * 2); + + memcpy (p, &b[0], n); /* { dg-warning "reading between 12 and 32 bytes from a region of size 8" "memcpy from allocated" } */ + + /* Verify memchr/memcmp. */ + n = sizeof *b * 2 + 1; + + memchr (b, 1, n); /* { dg-warning "specified bound 9 exceeds source size 8" "memchr from allocated" } */ + memcmp (p, b, n); /* { dg-warning "specified bound 9 exceeds source size 8" "memcmp from allocated" } */ +} + + +void test_memop_nowarn (void *p) +{ + struct B b[2]; + + size_t n = range (sizeof b, 32); + + /* Verify that copying the whole array is not diagnosed regardless + of whether the expression pointing to its beginning is obtained + from the array itself or its first member(s). */ + memcpy (p, b, n); + + memcpy (p, &b[0], n); + + memcpy (p, &b[0].a, n); + + memcpy (p, &b[0].a.a, n); + + /* Verify that memchr/memcmp doesn't cause a warning. */ + memchr (p, 1, n); + memchr (b, 2, n); + memchr (&b[0], 3, n); + memchr (&b[0].a, 4, n); + memchr (&b[0].a.a, 5, n); + memchr ("01234567", R (0, 255), n); + + memcmp (p, p, n); + memcmp (p, b, n); + memcmp (p, &b[0], n); + memcmp (p, &b[0].a, n); + memcmp (p, &b[0].a.a, n); + memcmp (p, "01234567", n); +} + + +/* The following function could specify in its API that it takes + an array of exactly two elements, as shown below (or simply be + called with such an array). Verify that reading from both + elements is not diagnosed. */ +void test_memop_nowarn_arg (void*, const struct A[2]); + +void test_memop_nowarn_arg (void *p, const struct A *a) +{ + memcpy (p, a, 2 * sizeof *a); + + memcpy (p, a, range (2 * sizeof *a, 123)); + + memchr (p, 1, 1234); + memcmp (p, a, 1234); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-9.c b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-9.c new file mode 100644 index 0000000000..b5464c2f06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-stringop-chk-9.c @@ -0,0 +1,150 @@ +/* PR middle-end/82646 - bogus -Wstringop-overflow with -D_FORTIFY_SOURCE=2 + on strncpy with range to a member array + { dg-do compile } + { dg-options "-O2 -Wstringop-overflow -ftrack-macro-expansion=0" } */ + +#define bos(p) __builtin_object_size (p, 1) + +struct S { + char a[5]; + void (*pf)(void); +}; + +/* Verify that none of the string function calls below triggers a warning. */ + +char* test_stpncpy_const_nowarn (struct S *p) +{ + int n = sizeof p->a; + + return __builtin_stpncpy (p->a, "123456", n); +} + +char* test_strncpy_const_nowarn (struct S *p) +{ + int n = sizeof p->a; + + return __builtin_strncpy (p->a, "1234567", n); +} + +char* test_stpncpy_chk_const_nowarn (struct S *p) +{ + int n = sizeof p->a; + + return __builtin___stpncpy_chk (p->a, "12345678", n, bos (p->a)); +} + +char* test_strncpy_chk_const_nowarn (struct S *p) +{ + int n = sizeof p->a; + + return __builtin___strncpy_chk (p->a, "123456789", n, bos (p->a)); +} + + +char* test_stpncpy_range_nowarn (struct S *p, int n) +{ + if (n < sizeof p->a) + n = sizeof p->a; + + return __builtin_stpncpy (p->a, "123456", n); +} + +char* test_strncpy_range_nowarn (struct S *p, int n) +{ + if (n < sizeof p->a) + n = sizeof p->a; + + return __builtin_strncpy (p->a, "1234567", n); +} + +char* test_stpncpy_chk_range_nowarn (struct S *p, int n) +{ + if (n < sizeof p->a) + n = sizeof p->a; + + return __builtin___stpncpy_chk (p->a, "12345678", n, bos (p->a)); /* { dg-bogus "\\\[-Wstringop-overflow=]" } */ +} + +char* test_strncpy_chk_range_nowarn (struct S *p, int n) +{ + if (n < sizeof p->a) + n = sizeof p->a; + + return __builtin___strncpy_chk (p->a, "123456789", n, bos (p->a)); /* { dg-bogus "\\\[-Wstringop-overflow=]" } */ +} + + +/* Verify that all of the string function calls below trigger a warning. */ + +char* test_stpncpy_const_warn (struct S *p) +{ + int n = sizeof p->a; + + ++n; + + return __builtin_stpncpy (p->a, "123456", n); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +char* test_strncpy_const_warn (struct S *p) +{ + int n = sizeof p->a; + + /* A call to strncpy() with a known string and small bound is folded + into memcpy() which defeats the warning in this case since memcpy + uses Object Size Type 0, i.e., the largest object that p->a may + be a part of. Use a larger bound to get around this here. */ + n += 11; + + return __builtin_strncpy (p->a, "1234567", n); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +char* test_stpncpy_chk_const_warn (struct S *p) +{ + int n = sizeof p->a; + + ++n; + + return __builtin___stpncpy_chk (p->a, "12345678", n, bos (p->a)); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +char* test_strncpy_chk_const_warn (struct S *p) +{ + int n = sizeof p->a; + + ++n; + + return __builtin___strncpy_chk (p->a, "123456789", n, bos (p->a)); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + + +char* test_stpncpy_range_warn (struct S *p, int n) +{ + if (n < sizeof p->a + 1) + n = sizeof p->a + 1; + + return __builtin_stpncpy (p->a, "123456", n); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +char* test_strncpy_range_warn (struct S *p, int n) +{ + if (n < sizeof p->a + 1) + n = sizeof p->a + 1; + + return __builtin_strncpy (p->a, "1234567", n); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +char* test_stpncpy_chk_range_warn (struct S *p, int n) +{ + if (n < sizeof p->a + 1) + n = sizeof p->a + 1; + + return __builtin___stpncpy_chk (p->a, "12345678", n, bos (p->a)); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +char* test_strncpy_chk_range_warn (struct S *p, int n) +{ + if (n < sizeof p->a + 1) + n = sizeof p->a + 1; + + return __builtin___strncpy_chk (p->a, "123456789", n, bos (p->a)); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-strncat-chk-1.c b/SingleSource/Regression/C/gcc-dg/builtin-strncat-chk-1.c new file mode 100644 index 0000000000..0389b2406a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-strncat-chk-1.c @@ -0,0 +1,38 @@ +/* Test whether buffer overflow warnings for __strncat_chk builtin + are emitted properly. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu99 -ftrack-macro-expansion=0" } */ + +extern void abort (void); + +#include "../gcc-c-torture/execute/builtins/chk.h" + +char buf1[20]; +char *q; + +void +test (int arg, ...) +{ + char *p = &buf1[10]; + + *p = 0; + strncat (p, "abcdefg", 9); + *p = 0; + strncat (p, "abcdefghi", 9); + *p = 0; + strncat (p, "abcdefghij", 9); + *p = 0; + strncat (p, "abcdefghi", 10); + *p = 0; + strncat (p, "abcdefghij", 10); /* { dg-warning "writing 11 bytes into a region of size 10 overflows the destination" } */ + *p = 0; + strncat (p, "abcdefgh", 11); + *p = 0; + strncat (p, "abcdefghijkl", 11); /* { dg-warning "specified bound 11 exceeds destination size 10" } */ + *p = 0; + strncat (p, q, 9); + *p = 0; + strncat (p, q, 10); /* { dg-warning "specified bound 10 equals destination size" } */ + *p = 0; + strncat (p, q, 11); /* { dg-warning "specified bound 11 exceeds destination size 10" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-strstr-1.c b/SingleSource/Regression/C/gcc-dg/builtin-strstr-1.c new file mode 100644 index 0000000000..9d584b67c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-strstr-1.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-not "link_error" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "__builtin_strstr" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return p_\[0-9]*.D.;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_strchr" 1 "optimized" } } */ + +extern void link_error (void); + +void +foo (void) +{ + const char *p = "abcdef"; + const char *q = "def"; + p++; + q++; + if (__builtin_strstr (p, q) != p + 3) + link_error (); +} + +char * +bar (const char *p) +{ + return __builtin_strstr (p, ""); +} + +char * +baz (const char *p) +{ + return __builtin_strstr (p, "d"); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-strstr.c b/SingleSource/Regression/C/gcc-dg/builtin-strstr.c new file mode 100644 index 0000000000..b8201f4164 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-strstr.c @@ -0,0 +1,8 @@ +/* The strstr call is expanded to just "s", which should not result in a + warning about discarding qualifiers in an assignment. */ +/* { dg-do compile } */ +extern char * strstr (const char *s1, const char * s2); +void foo(const char *s){ + char * cp; + cp = strstr(s, ""); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-tgmath-1.c b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-1.c new file mode 100644 index 0000000000..ff87ace42f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-1.c @@ -0,0 +1,322 @@ +/* Test __builtin_tgmath: valid uses, standard floating-point types. */ +/* { dg-do run } */ +/* { dg-options "" } */ + +extern void abort (void); +extern void exit (int); + +#define CHECK_CALL(C, E, V) \ + do \ + { \ + if ((C) != (E)) \ + abort (); \ + extern __typeof (C) V; \ + } \ + while (0) + +extern float var_f; +extern double var_d; +extern long double var_ld; +extern _Complex float var_cf; +extern _Complex double var_cd; +extern _Complex long double var_cld; +extern int var_i; + +typedef float float_type; +typedef double double_type; + +/* Test simple case, real arguments and return type. */ + +float_type t1f (float x) { return x + 1; } +double t1d (double_type x) { return x + 2; } +long double t1l (volatile long double x) { return x + 3; } + +#define t1v(x) __builtin_tgmath (t1f, t1d, t1l, x) +#define t1vr(x) __builtin_tgmath (t1l, t1d, t1f, x) + +static void +test_1 (void) +{ + float_type f = 1; + volatile float vf = 2; + double d = 3; + long double ld = 4; + int i = 5; + long long ll = 6; + CHECK_CALL (t1v (f), 2, var_f); + CHECK_CALL (t1v (vf), 3, var_f); + CHECK_CALL (t1v (d), 5, var_d); + CHECK_CALL (t1v (ld), 7, var_ld); + CHECK_CALL (t1v (i), 7, var_d); + CHECK_CALL (t1v (ll), 8, var_d); + CHECK_CALL (t1vr (f), 2, var_f); + CHECK_CALL (t1vr (vf), 3, var_f); + CHECK_CALL (t1vr (d), 5, var_d); + CHECK_CALL (t1vr (ld), 7, var_ld); + CHECK_CALL (t1vr (i), 7, var_d); + CHECK_CALL (t1vr (ll), 8, var_d); +} + +/* Test first argument not type-generic. */ + +float t2f (int a, float x) { return a * x + 1; } +double t2d (int a, double x) { return a * x + 2; } +long double t2l (int a, long double x) { return a * x + 3; } + +#define t2v(a, x) __builtin_tgmath (t2f, t2d, t2l, a, x) + +static void +test_2 (void) +{ + float f = 1; + double d = 2; + long double ld = 3; + int i = 4; + unsigned long long ll = 5; + CHECK_CALL (t2v (1, f), 2, var_f); + CHECK_CALL (t2v (2, d), 6, var_d); + CHECK_CALL (t2v (3, ld), 12, var_ld); + CHECK_CALL (t2v (4, i), 18, var_d); + CHECK_CALL (t2v (5, ll), 27, var_d); +} + +/* Test return type not type-generic. */ + +int t3f (float x) { return x + 1; } +int t3d (double x) { return x + 2; } +int t3l (long double x) { return x + 3; } + +#define t3v(x) __builtin_tgmath (t3f, t3d, t3l, x) + +static void +test_3 (void) +{ + float f = 1; + double d = 2; + long double ld = 3; + short s = 4; + CHECK_CALL (t3v (f), 2, var_i); + CHECK_CALL (t3v (d), 4, var_i); + CHECK_CALL (t3v (ld), 6, var_i); + CHECK_CALL (t3v (s), 6, var_i); +} + +/* Test multiple type-generic arguments. */ + +float t4f (float x, float y) { return 10 * x + y; } +double t4d (double x, double y) { return 100 * x + y; } +long double t4l (long double x, long double y) { return 1000 * x + y; } + +#define t4v(x, y) __builtin_tgmath (t4f, t4d, t4l, x, y) + +static void +test_4 (void) +{ + float f1 = 1; + float f2 = 2; + double d1 = 3; + double d2 = 4; + long double ld = 5; + long int l = 6; + CHECK_CALL (t4v (f1, f2), 12, var_f); + CHECK_CALL (t4v (f2, f1), 21, var_f); + CHECK_CALL (t4v (f1, d1), 103, var_d); + CHECK_CALL (t4v (d2, f2), 402, var_d); + CHECK_CALL (t4v (f1, l), 106, var_d); + CHECK_CALL (t4v (ld, f1), 5001, var_ld); + CHECK_CALL (t4v (l, l), 606, var_d); + CHECK_CALL (t4v (l, ld), 6005, var_ld); +} + +/* Test complex argument, real return type. */ + +float t5f (_Complex float x) { return 1 + __real__ x + 3 * __imag__ x; } +double t5d (_Complex double x) { return 2 + __real__ x + 4 * __imag__ x; } +long double t5l (_Complex long double x) { return 3 + __real__ x + 5 * __imag__ x; } + +#define t5v(x) __builtin_tgmath (t5f, t5d, t5l, x) + +static void +test_5 (void) +{ + float f = 1; + _Complex float cf = 2 + 3i; + double d = 4; + _Complex double cd = 5 + 6i; + long double ld = 7; + _Complex long double cld = 8 + 9i; + int i = 10; + _Complex int ci = 11 + 12i; + CHECK_CALL (t5v (f), 2, var_f); + CHECK_CALL (t5v (cf), 12, var_f); + CHECK_CALL (t5v (d), 6, var_d); + CHECK_CALL (t5v (cd), 31, var_d); + CHECK_CALL (t5v (ld), 10, var_ld); + CHECK_CALL (t5v (cld), 56, var_ld); + CHECK_CALL (t5v (i), 12, var_d); + CHECK_CALL (t5v (ci), 61, var_d); +} + +/* Test complex argument, complex return type. */ + +_Complex float t6f (_Complex float x) { return 1 + x; } +_Complex double t6d (_Complex double x) { return 2 + x; } +_Complex long double t6l (_Complex long double x) { return 3 + x; } + +#define t6v(x) __builtin_tgmath (t6f, t6d, t6l, x) + +static void +test_6 (void) +{ + float f = 1; + _Complex float cf = 2 + 3i; + double d = 4; + _Complex double cd = 5 + 6i; + long double ld = 7; + _Complex long double cld = 8 + 9i; + int i = 10; + _Complex int ci = 11 + 12i; + CHECK_CALL (t6v (f), 2, var_cf); + CHECK_CALL (t6v (cf), 3 + 3i, var_cf); + CHECK_CALL (t6v (d), 6, var_cd); + CHECK_CALL (t6v (cd), 7 + 6i, var_cd); + CHECK_CALL (t6v (ld), 10, var_cld); + CHECK_CALL (t6v (cld), 11 + 9i, var_cld); + CHECK_CALL (t6v (i), 12, var_cd); + CHECK_CALL (t6v (ci), 13 + 12i, var_cd); +} + +/* Test real and complex argument, real return type. */ + +float t7f (float x) { return 1 + x; } +float t7cf (_Complex float x) { return 2 + __real__ x; } +double t7d (double x) { return 3 + x; } +double t7cd (_Complex double x) { return 4 + __real__ x; } +long double t7l (long double x) { return 5 + x; } +long double t7cl (_Complex long double x) { return 6 + __real__ x; } + +#define t7v(x) __builtin_tgmath (t7f, t7d, t7l, t7cf, t7cd, t7cl, x) + +static void +test_7 (void) +{ + float f = 1; + _Complex float cf = 2 + 3i; + double d = 4; + _Complex double cd = 5 + 6i; + long double ld = 7; + _Complex long double cld = 8 + 9i; + int i = 10; + _Complex int ci = 11 + 12i; + CHECK_CALL (t7v (f), 2, var_f); + CHECK_CALL (t7v (cf), 4, var_f); + CHECK_CALL (t7v (d), 7, var_d); + CHECK_CALL (t7v (cd), 9, var_d); + CHECK_CALL (t7v (ld), 12, var_ld); + CHECK_CALL (t7v (cld), 14, var_ld); + CHECK_CALL (t7v (i), 13, var_d); + CHECK_CALL (t7v (ci), 15, var_d); +} + +/* Test real and complex argument, real and complex return type. */ + +float t8f (float x) { return 1 + x; } +_Complex float t8cf (_Complex float x) { return 2 + x; } +double t8d (double x) { return 3 + x; } +_Complex double t8cd (_Complex double x) { return 4 + x; } +long double t8l (long double x) { return 5 + x; } +_Complex long double t8cl (_Complex long double x) { return 6 + x; } + +#define t8v(x) __builtin_tgmath (t8f, t8d, t8l, t8cf, t8cd, t8cl, x) + +static void +test_8 (void) +{ + float f = 1; + _Complex float cf = 2 + 3i; + double d = 4; + _Complex double cd = 5 + 6i; + long double ld = 7; + _Complex long double cld = 8 + 9i; + int i = 10; + _Complex int ci = 11 + 12i; + CHECK_CALL (t8v (f), 2, var_f); + CHECK_CALL (t8v (cf), 4 + 3i, var_cf); + CHECK_CALL (t8v (d), 7, var_d); + CHECK_CALL (t8v (cd), 9 + 6i, var_cd); + CHECK_CALL (t8v (ld), 12, var_ld); + CHECK_CALL (t8v (cld), 14 + 9i, var_cld); + CHECK_CALL (t8v (i), 13, var_d); + CHECK_CALL (t8v (ci), 15 + 12i, var_cd); +} + +/* Test multiple type-generic arguments, real and complex. */ + +float t9f (float x, float y) { return x + 10 * y; } +_Complex float t9cf (_Complex float x, _Complex float y) { return x + 100 * y; } +double t9d (double x, double y) { return x + 1000 * y; } +_Complex double t9cd (_Complex double x, _Complex double y) { return x + 10000 * y; } +long double t9l (long double x, long double y) { return x + 100000 * y; } +_Complex long double t9cl (_Complex long double x, _Complex long double y) { return x + 1000000 * y; } + +#define t9v(x, y) __builtin_tgmath (t9f, t9d, t9l, t9cf, t9cd, t9cl, x, y) + +static void +test_9 (void) +{ + float f = 1; + _Complex float cf = 2 + 3i; + double d = 4; + _Complex double cd = 5 + 6i; + long double ld = 7; + _Complex long double cld = 8 + 9i; + int i = 10; + _Complex int ci = 11 + 12i; + CHECK_CALL (t9v (f, f), 11, var_f); + CHECK_CALL (t9v (f, cf), 201 + 300i, var_cf); + CHECK_CALL (t9v (cf, f), 102 + 3i, var_cf); + CHECK_CALL (t9v (f, i), 10001, var_d); + CHECK_CALL (t9v (i, f), 1010, var_d); + CHECK_CALL (t9v (d, d), 4004, var_d); + CHECK_CALL (t9v (d, cd), 50004 + 60000i, var_cd); + CHECK_CALL (t9v (ld, i), 1000007, var_ld); + CHECK_CALL (t9v (cf, cld), 8000002 + 9000003i, var_cld); + CHECK_CALL (t9v (i, i), 10010, var_d); + CHECK_CALL (t9v (ci, i), 100011 + 12i, var_cd); +} + +/* Test functions rounding result to narrower type. */ + +float t10d (double x) { return 1 + x; } +float t10l (long double x) { return 2 + x; } + +#define t10v(x) __builtin_tgmath (t10d, t10l, x) + +static void +test_10 (void) +{ + float f = 1; + double d = 2; + long double ld = 3; + short s = 4; + CHECK_CALL (t10v (f), 2, var_f); + CHECK_CALL (t10v (d), 3, var_f); + CHECK_CALL (t10v (ld), 5, var_f); + CHECK_CALL (t10v (s), 5, var_f); +} + +int +main (void) +{ + test_1 (); + test_2 (); + test_3 (); + test_4 (); + test_5 (); + test_6 (); + test_7 (); + test_8 (); + test_9 (); + test_10 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-tgmath-2.c b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-2.c new file mode 100644 index 0000000000..c4140cc2bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-2.c @@ -0,0 +1,51 @@ +/* Test __builtin_tgmath: valid uses, _FloatN types. */ +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-add-options float32 } */ +/* { dg-require-effective-target float32_runtime } */ + +extern void abort (void); +extern void exit (int); + +#define CHECK_CALL(C, E, V) \ + do \ + { \ + if ((C) != (E)) \ + abort (); \ + extern __typeof (C) V; \ + } \ + while (0) + +extern float var_f; +extern double var_d; +extern long double var_ld; +extern _Float32 var_f32; + +float t1f (float x) { return x + 1; } +double t1d (double x) { return x + 2; } +long double t1l (long double x) { return x + 3; } +_Float32 t1f32 (_Float32 x) { return x + 4; } + +#define t1v(x) __builtin_tgmath (t1f, t1d, t1l, t1f32, x) + +static void +test_1 (void) +{ + float f = 1; + double d = 2; + long double ld = 3; + _Float32 f32 = 4; + int i = 5; + CHECK_CALL (t1v (f), 2, var_f); + CHECK_CALL (t1v (d), 4, var_d); + CHECK_CALL (t1v (ld), 6, var_ld); + CHECK_CALL (t1v (f32), 8, var_f32); + CHECK_CALL (t1v (i), 7, var_d); +} + +int +main (void) +{ + test_1 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-tgmath-3.c b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-3.c new file mode 100644 index 0000000000..652113088a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-3.c @@ -0,0 +1,89 @@ +/* Test __builtin_tgmath: integer arguments with _FloatN / _FloatNx. */ +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32_runtime } */ +/* { dg-require-effective-target float64_runtime } */ +/* { dg-require-effective-target float32x_runtime } */ + +extern void abort (void); +extern void exit (int); + +#define CHECK_CALL(C, E, V) \ + do \ + { \ + if ((C) != (E)) \ + abort (); \ + extern __typeof (C) V; \ + } \ + while (0) + +extern double var_d; +extern _Float32 var_f32; +extern _Float64 var_f64; +extern _Float32x var_f32x; +extern _Complex _Float32x var_cf32x; + +_Float32 t1f (float x) { return x + 1; } +_Float32 t1d (double x) { return x + 2; } +_Float32 t1l (long double x) { return x + 3; } +_Float32 t1f64 (_Float64 x) { return x + 4; } + +#define t1v(x) __builtin_tgmath (t1f, t1d, t1l, t1f64, x) + +static void +test_1 (void) +{ + float f = 1; + double d = 2; + long double ld = 3; + _Float64 f64 = 4; + int i = 5; + CHECK_CALL (t1v (f), 2, var_f32); + CHECK_CALL (t1v (d), 4, var_f32); + CHECK_CALL (t1v (ld), 6, var_f32); + CHECK_CALL (t1v (f64), 8, var_f32); + CHECK_CALL (t1v (i), 7, var_f32); +} + +float t2f (float x, float y) { return 10 * x + y; } +double t2d (double x, double y) { return 100 * x + y; } +long double t2l (long double x, long double y) { return 1000 * x + y; } +_Float32x t2f32x (_Float32x x, _Float32x y) { return 10000 * x + y; } +_Float64 t2f64 (_Float64 x, _Float64 y) { return 100000 * x + y; } + +_Complex _Float32x +ct2f32x (_Complex _Float32x x, _Complex _Float32x y) +{ + return 1000000 * x + y; +} + +#define t2v(x, y) __builtin_tgmath (t2f, t2d, t2l, t2f32x, t2f64, ct2f32x, x, y) + +static void +test_2 (void) +{ + double d = 3; + _Float64 f64 = 6; + _Float32x f32x = 7; + int i = 5; + _Complex _Float32x cf32x = 8; + CHECK_CALL (t2v (f32x, i), 70005, var_f32x); + CHECK_CALL (t2v (i, f32x), 50007, var_f32x); + CHECK_CALL (t2v (f64, i), 600005, var_f64); + CHECK_CALL (t2v (i, f64), 500006, var_f64); + CHECK_CALL (t2v (d, i), 305, var_d); + CHECK_CALL (t2v (i, d), 503, var_d); + CHECK_CALL (t2v (cf32x, i), 8000005, var_cf32x); + CHECK_CALL (t2v (i, cf32x), 5000008, var_cf32x); +} + +int +main (void) +{ + test_1 (); + test_2 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-tgmath-err-1.c b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-err-1.c new file mode 100644 index 0000000000..9016ec742b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-err-1.c @@ -0,0 +1,76 @@ +/* Test __builtin_tgmath: errors that indicate a bad definition of a + type-generic macro rather than bad arguments in a call to it. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void *p; +double d; +double unprototyped_d (); +long double unprototyped_ld (); +double variadic_d (double, ...); +long double variadic_ld (long double, ...); +double no_arguments_d (void); +long double no_arguments_ld (void); +double f_d (double); +long double f_ld (long double); +double many_args (double, double, double, double); +int f_i_d (double); +_Complex int f_ci_d (double); +void * f_p_d (double); +double f_d_i (int); +double f_d_ci (_Complex int); +double f_d_p (void *); +long double f_ld_d (double); +_Complex double f_cd_d (double); +double f_d_f (float); +double f_d_dd (double, double); +long double f_ld_ldld (long double, long double); +float f_f_fd (float, double); + +void +test (void) +{ + /* Arguments individually invalid or no consistent number of + arguments followed by those arguments. */ + __builtin_tgmath (); /* { dg-error "too few arguments" } */ + __builtin_tgmath (f_d); /* { dg-error "too few arguments" } */ + __builtin_tgmath (f_d, f_ld); /* { dg-error "too few arguments" } */ + __builtin_tgmath (many_args, many_args, many_args); /* { dg-error "too few arguments" } */ + __builtin_tgmath (many_args, d, d, d, d); /* { dg-error "too few arguments" } */ + __builtin_tgmath (f_ld, many_args, d); /* { dg-error "has wrong number of arguments" } */ + __builtin_tgmath (unprototyped_d, unprototyped_ld, d); /* { dg-error "is unprototyped" } */ + __builtin_tgmath (f_d, unprototyped_ld, d); /* { dg-error "is unprototyped" } */ + __builtin_tgmath (variadic_d, variadic_ld, d); /* { dg-error "variable arguments" } */ + __builtin_tgmath (f_d, variadic_ld, d); /* { dg-error "variable arguments" } */ + __builtin_tgmath (p, p, p); /* { dg-error "is not a function pointer" } */ + __builtin_tgmath (f_d, p, p); /* { dg-error "is not a function pointer" } */ + __builtin_tgmath (no_arguments_d, no_arguments_d, no_arguments_ld); /* { dg-error "has no arguments" } */ + __builtin_tgmath (f_d, no_arguments_d, no_arguments_ld); /* { dg-error "has no arguments" } */ + + /* Invalid varying types of arguments. */ + __builtin_tgmath (f_i_d, f_ld, 0); /* { dg-error "invalid type-generic return type" } */ + __builtin_tgmath (f_ci_d, f_ld, 0); /* { dg-error "invalid type-generic return type" } */ + __builtin_tgmath (f_p_d, f_ld, 0); /* { dg-error "invalid type-generic return type" } */ + __builtin_tgmath (f_ld, f_i_d, 0); /* { dg-error "invalid type-generic return type" } */ + __builtin_tgmath (f_ld, f_ci_d, 0); /* { dg-error "invalid type-generic return type" } */ + __builtin_tgmath (f_ld, f_p_d, 0); /* { dg-error "invalid type-generic return type" } */ + __builtin_tgmath (f_d_i, f_ld, 0); /* { dg-error "invalid type-generic type for argument" } */ + __builtin_tgmath (f_d_ci, f_ld, 0); /* { dg-error "invalid type-generic type for argument" } */ + __builtin_tgmath (f_d_p, f_ld, 0); /* { dg-error "invalid type-generic type for argument" } */ + __builtin_tgmath (f_ld, f_d_i, 0); /* { dg-error "invalid type-generic type for argument" } */ + __builtin_tgmath (f_ld, f_d_ci, 0); /* { dg-error "invalid type-generic type for argument" } */ + __builtin_tgmath (f_ld, f_d_p, 0); /* { dg-error "invalid type-generic type for argument" } */ + + /* Arguments same type. */ + __builtin_tgmath (f_d, f_d, 0); /* { dg-error "all have the same type" } */ + + /* Missing or invalid type-generic parameter. */ + __builtin_tgmath (f_d, f_ld_d, 0); /* { dg-error "lack type-generic parameter" } */ + __builtin_tgmath (f_d, f_ld, f_cd_d, 0); /* { dg-error "lack type-generic parameter" } */ + __builtin_tgmath (f_d, f_ld, f_d, 0); /* { dg-error "duplicate type-generic parameter type" } */ + + /* Variation not consistent with the identified type-generic + parameter. */ + __builtin_tgmath (f_d, f_ld, f_d_f, 0); /* { dg-error "bad return type for function argument" } */ + __builtin_tgmath (f_d_dd, f_ld_ldld, f_f_fd, 0, 0); /* { dg-error "bad type for argument" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-tgmath-err-2.c b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-err-2.c new file mode 100644 index 0000000000..df5655ef40 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-tgmath-err-2.c @@ -0,0 +1,19 @@ +/* Test __builtin_tgmath: errors that indicate bad arguments in a call + to a type-generic macro, non-DFP. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +float f_f (float); +double f_d (double); +long double f_ld (long double); +void *p; +long double ld; +_Complex float cf; + +void +test (void) +{ + __builtin_tgmath (f_f, f_d, f_ld, p); /* { dg-error "invalid type of argument" } */ + __builtin_tgmath (f_f, f_d, ld); /* { dg-error "no matching function for type-generic call" } */ + __builtin_tgmath (f_f, f_d, cf); /* { dg-error "no matching function for type-generic call" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-unreachable-1.c b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-1.c new file mode 100644 index 0000000000..165da3f944 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-1.c @@ -0,0 +1,17 @@ +/* Check that __builtin_unreachable() prevents the 'control reaches + end of non-void function' diagnostic. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wreturn-type" } */ +int +f(int a, int b) +{ + if (a) + { + return b; + } + else + { + asm ("bug"); + __builtin_unreachable(); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-unreachable-2.c b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-2.c new file mode 100644 index 0000000000..f6c5ab709d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-2.c @@ -0,0 +1,18 @@ +/* Check that __builtin_unreachable() is a no-return function thus + causing the dead call to foo() to be removed. The comparison is + dead too, and should be removed. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-rtl-cse1" } */ +void foo (void); + +int +f (int i) +{ + if (i > 1) + __builtin_unreachable(); + if (i > 1) + foo (); + return 1; +} +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ +/* { dg-final { scan-rtl-dump-not "\\(if_then_else" "cse1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-unreachable-3.c b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-3.c new file mode 100644 index 0000000000..6ad69261e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-3.c @@ -0,0 +1,9 @@ +/* Check that a function containing only __builtin_unreachable() + doesn't ICE. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +const char * +f (void) +{ + __builtin_unreachable (); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-unreachable-4.c b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-4.c new file mode 100644 index 0000000000..90bc99cbe2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-4.c @@ -0,0 +1,14 @@ +/* Check that this valid code doesn't ICE. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +void +g (int a, int b, int c, int d) +{ + if (d) + { + ((void) + (!(a && b && c) ? __builtin_unreachable (), 0 : 0)); + } + ((void) + (!(a && b && c) ? __builtin_unreachable (), 0 : 0)); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtin-unreachable-5.c b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-5.c new file mode 100644 index 0000000000..ba87bdd735 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-5.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-fab1" } */ + +int +foo (int a) +{ + if (a <= 0) + { + L1: + __builtin_unreachable (); + } + + if (a > 2) + goto L1; + + return a > 0; +} + +/* { dg-final { scan-tree-dump-times "if \\(" 0 "fab1" } } */ +/* { dg-final { scan-tree-dump-times "goto" 0 "fab1" } } */ +/* { dg-final { scan-tree-dump-times "L1:" 0 "fab1" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_unreachable" 0 "fab1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-unreachable-6.c b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-6.c new file mode 100644 index 0000000000..4c3b9bbaef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-6.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-fab1 -fno-tree-dominator-opts -fno-tree-vrp" } */ +/* { dg-require-effective-target label_values } */ + +void +foo (int b, int c) +{ + void *x = &&lab; + if (b) + { +lab: + __builtin_unreachable (); + } +lab2: + if (c) + x = &&lab2; + goto *x; +} + +/* { dg-final { scan-tree-dump-times "lab:" 1 "fab1" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_unreachable" 1 "fab1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtin-unreachable-6a.c b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-6a.c new file mode 100644 index 0000000000..f527f2edc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtin-unreachable-6a.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-fab1" } */ + +#include "builtin-unreachable-6.c" + +/* { dg-final { scan-tree-dump-times "lab:" 1 "fab1" } } */ +/* { dg-final { scan-tree-dump-not "__builtin_unreachable" "fab1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-1.c b/SingleSource/Regression/C/gcc-dg/builtins-1.c new file mode 100644 index 0000000000..6128642b5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-1.c @@ -0,0 +1,212 @@ +/* Copyright (C) 2002, 2003 Free Software Foundation. + + Verify that all the __builtin_ math functions are recognized + by the compiler. + + Written by Roger Sayle, 11th July 2002. */ + +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-final { scan-assembler-not "__builtin_" } } */ + +/* These helper macros ensure we also check the float and long double + cases. */ + +/* Test FP functions taking void. */ +#define FPTEST0(FN) \ +double test_##FN(void) { return __builtin_##FN(); } \ +float test_##FN##f(void) { return __builtin_##FN##f(); } \ +long double test_##FN##l(void) { return __builtin_##FN##l(); } + +/* Test FP functions taking one FP argument. */ +#define FPTEST1(FN) \ +double test_##FN(double x) { return __builtin_##FN(x); } \ +float test_##FN##f(float x) { return __builtin_##FN##f(x); } \ +long double test_##FN##l(long double x) { return __builtin_##FN##l(x); } + +/* Test FP functions taking one argument of a supplied type. */ +#define FPTEST1ARG(FN, TYPE) \ +double test_##FN(TYPE x) { return __builtin_##FN(x); } \ +float test_##FN##f(TYPE x) { return __builtin_##FN##f(x); } \ +long double test_##FN##l(TYPE x) { return __builtin_##FN##l(x); } + +/* Test FP functions taking two arguments, the first argument is of a + supplied type. */ +#define FPTEST2ARG1(FN, TYPE) \ +double test_##FN(TYPE x, double y) { return __builtin_##FN(x, y); } \ +float test_##FN##f(TYPE x, float y) { return __builtin_##FN##f(x, y); } \ +long double test_##FN##l(TYPE x, long double y) { return __builtin_##FN##l(x, y); } + +/* Test FP functions taking two arguments, the second argument is of a + supplied type. */ +#define FPTEST2ARG2(FN, TYPE) \ +double test_##FN(double x, TYPE y) { return __builtin_##FN(x, y); } \ +float test_##FN##f(float x, TYPE y) { return __builtin_##FN##f(x, y); } \ +long double test_##FN##l(long double x, TYPE y) { return __builtin_##FN##l(x, y); } + +/* Test FP functions taking two arguments, the second argument is of a + supplied type. The function is named reentrant style, meaning "_r" + appears after the possible f/l suffix. */ +#define FPTEST2ARG2_REENT(FN, TYPE) \ +double test_##FN##_r(double x, TYPE y) { return __builtin_##FN##_r(x, y); } \ +float test_##FN##f_r(float x, TYPE y) { return __builtin_##FN##f_r(x, y); } \ +long double test_##FN##l_r(long double x, TYPE y) { return __builtin_##FN##l_r(x, y); } + +/* Test FP functions taking two arguments, the second argument is a + FP pointer. */ +#define FPTEST2FPP2(FN) \ +double test_##FN(double x, double *y) { return __builtin_##FN(x, y); } \ +float test_##FN##f(float x, float *y) { return __builtin_##FN##f(x, y); } \ +long double test_##FN##l(long double x, long double *y) { return __builtin_##FN##l(x, y); } + +/* Test FP functions taking one FP argument and a supplied return + type. */ +#define FPTEST1RET(FN, TYPE) \ +TYPE test_##FN(double x) { return __builtin_##FN(x); } \ +TYPE test_##FN##f(float x) { return __builtin_##FN##f(x); } \ +TYPE test_##FN##l(long double x) { return __builtin_##FN##l(x); } + +/* Test FP functions taking two FP arguments. */ +#define FPTEST2(FN) \ +double test_##FN(double x, double y) { return __builtin_##FN(x, y); } \ +float test_##FN##f(float x, float y) { return __builtin_##FN##f(x, y); } \ +long double test_##FN##l(long double x, long double y) { return __builtin_##FN##l(x, y); } + +/* Test FP functions taking three FP arguments. */ +#define FPTEST3(FN) \ +double test_##FN(double x, double y, double z) { return __builtin_##FN(x, y, z); } \ +float test_##FN##f(float x, float y, float z) { return __builtin_##FN##f(x, y, z); } \ +long double test_##FN##l(long double x, long double y, long double z) { return __builtin_##FN##l(x, y, z); } + +/* Test FP functions taking three arguments, two FP and the third is + of a supplied type. */ +#define FPTEST3ARG3(FN, TYPE) \ +double test_##FN(double x, double y, TYPE z) { return __builtin_##FN(x, y, z); } \ +float test_##FN##f(float x, float y, TYPE z) { return __builtin_##FN##f(x, y, z); } \ +long double test_##FN##l(long double x, long double y, TYPE z) { return __builtin_##FN##l(x, y, z); } + +/* Test FP functions taking three FP arguments. The second and third + are FP pointers. The return type is void. */ +#define FPTEST3FPP23VOID(FN) \ +double test_##FN(double x, double *y, double *z) { __builtin_##FN(x, y, z); return *y * *z; } \ +float test_##FN##f(float x, float *y, float *z) { __builtin_##FN##f(x, y, z); return *y * *z; } \ +long double test_##FN##l(long double x, long double *y, long double *z) { __builtin_##FN##l(x, y, z); return *y * *z; } + +/* Test Complex functions taking one Complex argument. */ +#define CPTEST1(FN) \ +_Complex double test_##FN(_Complex double x) { return __builtin_##FN(x); } \ +_Complex float test_##FN##f(_Complex float x) { return __builtin_##FN##f(x); } \ +_Complex long double test_##FN##l(_Complex long double x) { return __builtin_##FN##l(x); } + +/* Test Complex functions taking one Complex argument and returning an FP type. */ +#define CPTEST1RETFP(FN) \ +double test_##FN(_Complex double x) { return __builtin_##FN(x); } \ +float test_##FN##f(_Complex float x) { return __builtin_##FN##f(x); } \ +long double test_##FN##l(_Complex long double x) { return __builtin_##FN##l(x); } + +/* Test Complex functions taking two Complex arguments. */ +#define CPTEST2(FN) \ +_Complex double test_##FN(_Complex double x, _Complex double y) { return __builtin_##FN(x,y); } \ +_Complex float test_##FN##f(_Complex float x, _Complex float y) { return __builtin_##FN##f(x,y); } \ +_Complex long double test_##FN##l(_Complex long double x, _Complex long double y) { return __builtin_##FN##l(x,y); } + + +/* Keep this list sorted alphabetically by function name. */ +FPTEST1 (acos) +FPTEST1 (acosh) +FPTEST1 (asin) +FPTEST1 (asinh) +FPTEST1 (atan) +FPTEST2 (atan2) +FPTEST1 (atanh) +FPTEST1 (cbrt) +FPTEST1 (ceil) +FPTEST2 (copysign) +FPTEST1 (cos) +FPTEST1 (cosh) +FPTEST2 (drem) +FPTEST1 (erf) +FPTEST1 (erfc) +FPTEST1 (exp) +FPTEST1 (exp10) +FPTEST1 (exp2) +FPTEST1 (expm1) +FPTEST1 (fabs) +FPTEST2 (fdim) +FPTEST1 (floor) +FPTEST3 (fma) +FPTEST2 (fmax) +FPTEST2 (fmin) +FPTEST2 (fmod) +FPTEST2ARG2 (frexp, int *) +FPTEST1 (gamma) +FPTEST2ARG2_REENT (gamma, int *) /* gamma_r */ +FPTEST0 (huge_val) +FPTEST2 (hypot) +FPTEST1 (ilogb) +FPTEST0 (inf) /* { dg-warning "target format does not support infinity" "inf" {target pdp11*-*-* } } */ +FPTEST1 (j0) +FPTEST1 (j1) +FPTEST2ARG1 (jn, int) +FPTEST2ARG2 (ldexp, int) +FPTEST1 (lgamma) +FPTEST2ARG2_REENT (lgamma, int *) /* lgamma_r */ +FPTEST1RET (llrint, long long) +FPTEST1RET (llround, long long) +FPTEST1 (log) +FPTEST1 (log10) +FPTEST1 (log1p) +FPTEST1 (log2) +FPTEST1 (logb) +FPTEST1RET (lrint, long) +FPTEST1RET (lround, long) +FPTEST2FPP2 (modf) +FPTEST1 (nearbyint) +FPTEST2 (nextafter) +FPTEST2 (nexttoward) +FPTEST2 (pow) +FPTEST1 (pow10) +FPTEST2 (remainder) +FPTEST3ARG3 (remquo, int *) +FPTEST1 (rint) +FPTEST1 (round) +FPTEST2 (scalb) +FPTEST2ARG2 (scalbln, int) +FPTEST2ARG2 (scalbn, int) +FPTEST1RET (signbit, int) +FPTEST1 (significand) +FPTEST1 (sin) +FPTEST3FPP23VOID (sincos) +FPTEST1 (sinh) +FPTEST1 (sqrt) +FPTEST1 (tan) +FPTEST1 (tanh) +FPTEST1 (tgamma) +FPTEST1 (trunc) +FPTEST1 (y0) +FPTEST1 (y1) +FPTEST2ARG1 (yn, int) + +/* Keep this list sorted alphabetically by function name. */ +CPTEST1RETFP (cabs) +CPTEST1 (cacos) +CPTEST1 (cacosh) +CPTEST1RETFP (carg) +CPTEST1 (casin) +CPTEST1 (casinh) +CPTEST1 (catan) +CPTEST1 (catanh) +CPTEST1 (ccos) +CPTEST1 (ccosh) +CPTEST1 (cexp) +CPTEST1RETFP (cimag) +CPTEST1 (clog) +CPTEST1 (conj) +CPTEST2 (cpow) +CPTEST1 (cproj) +CPTEST1RETFP (creal) +CPTEST1 (csin) +CPTEST1 (csinh) +CPTEST1 (csqrt) +CPTEST1 (ctan) +CPTEST1 (ctanh) diff --git a/SingleSource/Regression/C/gcc-dg/builtins-10.c b/SingleSource/Regression/C/gcc-dg/builtins-10.c new file mode 100644 index 0000000000..1b141fda25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-10.c @@ -0,0 +1,55 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding of built-in math functions doesn't + break anything and produces the expected results. + + Written by Roger Sayle, 2nd April 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void link_error(void); + +extern double exp(double); +extern double log(double); +extern double sqrt(double); +extern double pow(double,double); +extern double fabs(double); + +void test(double x) +{ + if (sqrt(pow(x,4.0)) != x*x) + link_error (); + + if (pow(sqrt(x),4.0) != x*x) + link_error (); + + if (pow(pow(x,4.0),0.25) != x) + /* XFAIL. PR41098. */; +} + +void test2(double x, double y, double z) +{ + if (sqrt(pow(x,y)) != pow(fabs(x),y*0.5)) + link_error (); + + if (log(pow(x,y)) != y*log(x)) + link_error (); + + if (pow(exp(x),y) != exp(x*y)) + link_error (); + + if (pow(sqrt(x),y) != pow(x,y*0.5)) + link_error (); + + if (pow(pow(fabs(x),y),z) != pow(fabs(x),y*z)) + link_error (); +} + +int main() +{ + test (2.0); + test2 (2.0, 3.0, 4.0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-11.c b/SingleSource/Regression/C/gcc-dg/builtins-11.c new file mode 100644 index 0000000000..ba0d2dbf0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-11.c @@ -0,0 +1,53 @@ +/* Copyright (C) 2003,2007 Free Software Foundation. + + Check that constant folding of built-in math functions doesn't + break anything and produces the expected results. + + Written by Roger Sayle, 5th April 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void link_error(void); + +extern double exp(double); +extern double sqrt(double); +extern double cbrt(double); +extern double pow(double,double); + +void test(double x, double y, double z) +{ + if (sqrt(x)*sqrt(x) != x) + link_error (); + + if (sqrt(x)*sqrt(y) != sqrt(x*y)) + link_error (); + + if (exp(x)*exp(y) != exp(x+y)) + link_error (); + + if (pow(x,y)*pow(z,y) != pow(z*x,y)) + link_error (); + + if (pow(x,y)*pow(x,z) != pow(x,y+z)) + link_error (); + + if (x/exp(y) != x*exp(-y)) + link_error (); + + if (x/pow(y,z) != x*pow(y,-z)) + link_error (); + + if (x/sqrt(y/z) != x*sqrt(z/y)) + link_error (); + + if (x/cbrt(y/z) != x*cbrt(z/y)) + link_error (); +} + +int main() +{ + test (2.0, 3.0, 4.0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-12.c b/SingleSource/Regression/C/gcc-dg/builtins-12.c new file mode 100644 index 0000000000..61a80edf78 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-12.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Verify that all the malloc-like __builtin_ allocation functions are + recognized by the compiler. + + Written by Roger Sayle, 12th April 2003. */ + +/* { dg-do compile } */ +/* { dg-options "-ansi" } */ +/* { dg-final { scan-assembler-not "__builtin_" } } */ + +typedef __SIZE_TYPE__ size_t; + +void *test1(size_t n) +{ + return __builtin_malloc(n); +} + +void *test2(size_t n, size_t s) +{ + return __builtin_calloc(n,s); +} + +char *test3(const char *ptr) +{ + return __builtin_strdup(ptr); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-13.c b/SingleSource/Regression/C/gcc-dg/builtins-13.c new file mode 100644 index 0000000000..149407b540 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-13.c @@ -0,0 +1,62 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Verify that the malloc-like __builtin_ allocation functions are + correctly aliased by the compiler. + + Written by Roger Sayle, 12th April 2003. */ + +/* { dg-do link } */ +/* { dg-options "-ansi" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void *malloc (size_t); +extern void *calloc (size_t,size_t); + +extern void link_error (void); + +static int x; + +void test1(void) +{ + int *ptr1, *ptr2; + + ptr1 = &x; + ptr2 = (int*) malloc (sizeof (int)); + + *ptr1 = 12; + *ptr2 = 8; + + if (*ptr1 != 12) + link_error(); +} + +void test2(void) +{ + int *ptr1, *ptr2; + + ptr1 = &x; + ptr2 = (int*) calloc (1, sizeof (int)); + + *ptr1 = 12; + *ptr2 = 8; + + if (*ptr1 != 12) + link_error (); +} + +int main() +{ + test1 (); + test2 (); + return 0; +} + +#ifndef __OPTIMIZE__ +void link_error (void) +{ + abort (); +} +#endif + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-14.c b/SingleSource/Regression/C/gcc-dg/builtins-14.c new file mode 100644 index 0000000000..e025391a9b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-14.c @@ -0,0 +1,26 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding of built-in math functions doesn't + break anything and produces the expected results. + + Written by Roger Sayle, 9th April 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern void link_error(void); + +extern double pow(double,double); + + +int main() +{ + if (pow (2.0, 3.0) != 8.0) + link_error (); + + if (pow (2.0, -3.0) != 0.125) + link_error (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-15.c b/SingleSource/Regression/C/gcc-dg/builtins-15.c new file mode 100644 index 0000000000..6d94c7edc5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-15.c @@ -0,0 +1,17 @@ +/* Derived from PR optimization/10764 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double log(double x); + +double ndtri(double y0) +{ + double x; + + x = log(y0); + x = log(x); + + return x; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-16.c b/SingleSource/Regression/C/gcc-dg/builtins-16.c new file mode 100644 index 0000000000..e7ffe93506 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-16.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Verify that all the __builtin_cabs? functions are recognized + by the compiler. Complex numbers are not supported with the + gcc.dg default "-pedantic-errors" option, so the dg-options + overrides this. + + Written by Roger Sayle, 1st June 2003. */ + +/* { dg-do compile } */ +/* { dg-options "-O -ansi" } */ +/* { dg-final { scan-assembler-not "__builtin_" } } */ + +double test(__complex__ double x) +{ + return __builtin_cabs (x); +} + +float testf(__complex__ float x) +{ + return __builtin_cabsf (x); +} + +long double testl(__complex__ long double x) +{ + return __builtin_cabsl (x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-17.c b/SingleSource/Regression/C/gcc-dg/builtins-17.c new file mode 100644 index 0000000000..a9e21fba8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-17.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding of built-in math functions doesn't + break anything and produces the expected results. + + Written by Roger Sayle, 25th May 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void link_error(void); + +extern double exp(double); +extern double atan(double); + +int main() +{ + if (exp (1.0) < 2.71 || exp (1.0) > 2.72) + link_error (); + if (exp (2.0) < 7.38 || exp (2.0) > 7.39) + link_error (); + if (exp (-2.0) < 0.13 || exp (-2.0) > 0.14) + link_error (); + if (atan (1.0) < 0.78 || atan (1.0) > 0.79) + link_error (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-18.c b/SingleSource/Regression/C/gcc-dg/builtins-18.c new file mode 100644 index 0000000000..4501cc14bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-18.c @@ -0,0 +1,64 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that built-in cabs, cabsf and cabsl functions don't + break anything and produces the expected results. + + Written by Roger Sayle, 1st June 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +#include "builtins-config.h" + +extern void link_error(void); + +extern float cabsf (float _Complex); +extern double cabs (double _Complex); +extern long double cabsl (long double _Complex); + +int +main (void) +{ + /* For each type, test both runtime and compile time (constant folding) + optimization. */ + float _Complex fc = 3.0F + 4.0iF; + double _Complex dc = 3.0 + 4.0i; + long double _Complex ldc = 3.0L + 4.0iL; + +#ifdef HAVE_C99_RUNTIME + /* Test floats. */ + if (cabsf (fc) != 5.0F) + link_error (); + if (__builtin_cabsf (fc) != 5.0F) + link_error (); + if (cabsf (3.0F + 4.0iF) != 5.0F) + link_error (); + if (__builtin_cabsf (3.0F + 4.0iF) != 5.0F) + link_error (); +#endif + + /* Test doubles. */ + if (cabs (dc) != 5.0) + link_error (); + if (__builtin_cabs (dc) != 5.0) + link_error (); + if (cabs (3.0 + 4.0i) != 5.0) + link_error (); + if (__builtin_cabs (3.0 + 4.0i) != 5.0) + link_error (); + +#ifdef HAVE_C99_RUNTIME + /* Test long doubles. */ + if (cabsl (ldc) != 5.0L) + link_error (); + if (__builtin_cabsl (ldc) != 5.0L) + link_error (); + if (cabsl (3.0L + 4.0iL) != 5.0L) + link_error (); + if (__builtin_cabsl (3.0L + 4.0iL) != 5.0L) + link_error (); +#endif + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-19.c b/SingleSource/Regression/C/gcc-dg/builtins-19.c new file mode 100644 index 0000000000..f0583a9783 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-19.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that cabs of a non-complex argument is converted into fabs. + + Written by Roger Sayle, 1st June 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +double cabs (__complex__ double); +float cabsf (__complex__ float); +long double cabsl (__complex__ long double); +double fabs (double); +float fabsf (float); +long double fabsl (long double); + +void link_error (void); + +void test (double x) +{ + if (cabs (x) != fabs (x)) + link_error (); +} + +void testf (float x) +{ + if (cabsf (x) != fabsf (x)) + link_error (); +} + +void testl (long double x) +{ + if (cabsl (x) != fabsl (x)) + link_error (); +} + +int main () +{ + test (1.0); + testf (1.0f); + testl (1.0l); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-2.c b/SingleSource/Regression/C/gcc-dg/builtins-2.c new file mode 100644 index 0000000000..b1f31c84aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-2.c @@ -0,0 +1,227 @@ +/* Copyright (C) 2002 Free Software Foundation. + + Verify that built-in math function constant folding doesn't + cause any problems for the compiler. + + Written by Roger Sayle, 16th August 2002. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double atan (double); +extern float atanf (float); +extern long double atanl (long double); +extern double exp (double); +extern float expf (float); +extern long double expl (long double); +extern double fabs (double); +extern float fabsf (float); +extern long double fabsl (long double); +extern double log (double); +extern float logf (float); +extern long double logl (long double); +extern double pow (double, double); +extern float powf (float, float); +extern long double powl (long double, long double); +extern double sqrt (double); +extern float sqrtf (float); +extern long double sqrtl (long double); +extern double tan (double); +extern float tanf (float); +extern long double tanl (long double); + +double test1(double x) +{ + return log(exp(x)); +} + +double test2(double x) +{ + return exp(log(x)); +} + +double test3(double x) +{ + return sqrt(exp(x)); +} + +double test4(double x) +{ + return log(sqrt(x)); +} + +double test5(double x, double y) +{ + return sqrt(x)*sqrt(y); +} + +double test6(double x, double y) +{ + return exp(x)*exp(y); +} + +double test7(double x, double y) +{ + return x/exp(y); +} + +double test8(double x) +{ + return fabs(sqrt(x)); +} + +double test9(double x) +{ + return fabs(exp(x)); +} + +double test10(double x) +{ + return tan(atan(x)); +} + +double test11(double x) +{ + return fabs(fabs(x)); +} + +double test12(double x) +{ + return fabs(atan(x)); +} + +double test13(double x) +{ + return fabs(pow(2.0,x)); +} + +float test1f(float x) +{ + return logf(expf(x)); +} + +float test2f(float x) +{ + return expf(logf(x)); +} + +float test3f(float x) +{ + return sqrtf(expf(x)); +} + +float test4f(float x) +{ + return logf(sqrtf(x)); +} + +float test5f(float x, float y) +{ + return sqrtf(x)*sqrtf(y); +} + +float test6f(float x, float y) +{ + return expf(x)*expf(y); +} + +float test7f(float x, float y) +{ + return x/expf(y); +} + +float test8f(float x) +{ + return fabsf(sqrtf(x)); +} + +float test9f(float x) +{ + return fabsf(expf(x)); +} + +float test10f(float x) +{ + return tanf(atanf(x)); +} + +float test11f(float x) +{ + return fabsf(fabsf(x)); +} + +float test12f(float x) +{ + return fabsf(atanf(x)); +} + +float test13f(float x) +{ + return fabsf(powf(2.0f,x)); +} + +long double test1l(long double x) +{ + return logl(expl(x)); +} + +long double test2l(long double x) +{ + return expl(logl(x)); +} + +long double test3l(long double x) +{ + return sqrtl(expl(x)); +} + +long double test4l(long double x) +{ + return logl(sqrtl(x)); +} + +long double test5l(long double x, long double y) +{ + return sqrtl(x)*sqrtl(y); +} + +long double test6l(long double x, long double y) +{ + return expl(x)*expl(y); +} + +long double test7l(long double x, long double y) +{ + return x/expl(y); +} + +long double test8l(long double x) +{ + return fabsl(sqrtl(x)); +} + +long double test9l(long double x) +{ + return fabsl(expl(x)); +} + +long double test10l(long double x) +{ + return tanl(atanl(x)); +} + +long double test11l(long double x) +{ + return fabsl(fabsl(x)); +} + +long double test12l(long double x) +{ + return fabsl(atanl(x)); +} + +long double test13l(long double x) +{ + return fabsl(powl(2.0l,x)); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-20.c b/SingleSource/Regression/C/gcc-dg/builtins-20.c new file mode 100644 index 0000000000..8f864f6249 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-20.c @@ -0,0 +1,748 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Verify that built-in math function constant folding doesn't break + anything and produces the expected results. + + Written by Roger Sayle, 8th June 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +#include "builtins-config.h" + +extern double cos (double); +extern double sin (double); +extern double tan (double); +extern double fabs (double); +extern double atan2 (double, double); +extern double copysign (double, double); +extern double fmin (double, double); +extern double fmax (double, double); +extern double hypot (double, double); +extern double pure (double) __attribute__ ((__pure__)); +extern double carg (__complex__ double); +extern __complex__ double ccos (__complex__ double); +extern __complex__ double ctan (__complex__ double); +extern float cosf (float); +extern float sinf (float); +extern float tanf (float); +extern float fabsf (float); +extern float atan2f (float, float); +extern float copysignf (float, float); +extern float fminf (float, float); +extern float fmaxf (float, float); +extern float hypotf (float, float); +extern float puref (float) __attribute__ ((__pure__)); +extern float cargf (__complex__ float); +extern __complex__ float ccosf (__complex__ float); +extern __complex__ float ctanf (__complex__ float); +extern long double cosl (long double); +extern long double sinl (long double); +extern long double tanl (long double); +extern long double fabsl (long double); +extern long double atan2l (long double, long double); +extern long double copysignl (long double, long double); +extern long double fminl (long double, long double); +extern long double fmaxl (long double, long double); +extern long double hypotl (long double, long double); +extern long double purel (long double) __attribute__ ((__pure__)); +extern long double cargl (__complex__ long double); +extern __complex__ long double ccosl (__complex__ long double); +extern __complex__ long double ctanl (__complex__ long double); + +extern void link_error(void); + +void test1(double x) +{ + if (cos(x) != cos(-x)) + link_error (); + + if (cos(x) != cos(fabs(x))) + link_error (); + + if (cos(x) != cos(-fabs(x))) + link_error (); + + if (cos(tan(x)) != cos(tan(-fabs(x)))) + link_error (); + + if (sin(x)/cos(x) != tan(x)) + link_error (); + + if (cos(x)/sin(x) != 1.0/tan(x)) + link_error (); + + if (tan(x)*cos(x) != sin(x)) + link_error (); + + if (cos(x)*tan(x) != sin(x)) + link_error (); + + if (sin(x)/tan(x) != cos(x)) + link_error (); + + if (tan(x)/sin(x) != 1.0/cos(x)) + link_error (); +} + +void test2(double x, double y) +{ + if (-tan(x-y) != tan(y-x)) + link_error (); + + if (-sin(x-y) != sin(y-x)) + link_error (); + + if (cos(-x*y) != cos(x*y)) + link_error (); + + if (cos(x*-y) != cos(x*y)) + link_error (); + + if (cos(-x/y) != cos(x/y)) + link_error (); + + if (cos(x/-y) != cos(x/y)) + link_error (); + + if (cos(-fabs(tan(x/-y))) != cos(tan(x/y))) + link_error (); + + if (cos(y<10 ? -x : y) != cos(y<10 ? x : y)) + link_error (); + + if (cos(y<10 ? x : -y) != cos(y<10 ? x : y)) + link_error (); + + if (cos(y<10 ? -fabs(x) : tan(x<20 ? -x : -fabs(y))) + != cos(y<10 ? x : tan(x<20 ? x : y))) + link_error (); + + if (cos((y*=3, -x)) != cos((y*=3,x))) + link_error (); + + if (cos(-fabs(tan(x/-y))) != cos(tan(x/y))) + link_error (); + + if (cos(copysign(x,y)) != cos(x)) + link_error (); + + if (cos(copysign(-fabs(x),y*=2)) != cos((y*=2,x))) + link_error (); + + if (hypot (x, 0) != fabs(x)) + link_error (); + + if (hypot (0, x) != fabs(x)) + link_error (); + + if (hypot (x, x) != fabs(x) * __builtin_sqrt(2)) + link_error (); + + if (hypot (-x, y) != hypot (x, y)) + link_error (); + + if (hypot (x, -y) != hypot (x, y)) + link_error (); + + if (hypot (-x, -y) != hypot (x, y)) + link_error (); + + if (hypot (fabs(x), y) != hypot (x, y)) + link_error (); + + if (hypot (x, fabs(y)) != hypot (x, y)) + link_error (); + + if (hypot (fabs(x), fabs(y)) != hypot (x, y)) + link_error (); + + if (hypot (-fabs(-x), -fabs(fabs(fabs(-y)))) != hypot (x, y)) + link_error (); + + if (hypot (-x, 0) != fabs(x)) + link_error (); + + if (hypot (-x, x) != fabs(x) * __builtin_sqrt(2)) + link_error (); + + if (hypot (pure(x), -pure(x)) != fabs(pure(x)) * __builtin_sqrt(2)) + link_error (); + + if (hypot (tan(-x), tan(-fabs(y))) != hypot (tan(x), tan(y))) + link_error (); + + if (fmin (fmax(x,y),y) != y) + link_error (); + + if (fmin (fmax(y,x),y) != y) + link_error (); + + if (fmin (x,fmax(x,y)) != x) + link_error (); + + if (fmin (x,fmax(y,x)) != x) + link_error (); + + if (fmax (fmin(x,y),y) != y) + link_error (); + + if (fmax (fmin(y,x),y) != y) + link_error (); + + if (fmax (x,fmin(x,y)) != x) + link_error (); + + if (fmax (x,fmin(y,x)) != x) + link_error (); + + if ((__complex__ double) x != -(__complex__ double) (-x)) + link_error (); + + if (x*1i != -(-x*1i)) + link_error (); + + if (x+(x-y)*1i != -(-x+(y-x)*1i)) + link_error (); + + if (x+(x-y)*1i != -(-x-(x-y)*1i)) + link_error (); + + if (ccos(tan(x)+sin(y)*1i) != ccos(-tan(-x)+-sin(-y)*1i)) + link_error (); + + if (ccos(tan(x)+sin(x-y)*1i) != ccos(-tan(-x)-sin(y-x)*1i)) + link_error (); + + if (-5+x*1i != -~(5+x*1i)) + link_error (); + + if (tan(x)+tan(y)*1i != -~(tan(-x)+tan(y)*1i)) + link_error (); +} + +void test3(__complex__ double x, __complex__ double y, int i) +{ + if (carg(x) != atan2(__imag__ x, __real__ x)) + link_error (); + + if (ccos(x) != ccos(-x)) + link_error(); + + if (ccos(ctan(x)) != ccos(ctan(-x))) + link_error(); + + if (ctan(x-y) != -ctan(y-x)) + link_error(); + + if (ccos(x/y) != ccos(-x/y)) + link_error(); + + if (ccos(x/y) != ccos(x/-y)) + link_error(); + + if (ccos(x/ctan(y)) != ccos(-x/ctan(-y))) + link_error(); + + if (ccos(x*y) != ccos(-x*y)) + link_error(); + + if (ccos(x*y) != ccos(x*-y)) + link_error(); + + if (ccos(ctan(x)*y) != ccos(ctan(-x)*-y)) + link_error(); + + if (ccos(ctan(x/y)) != ccos(-ctan(x/-y))) + link_error(); + + if (ccos(i ? x : y) != ccos(i ? -x : y)) + link_error(); + + if (ccos(i ? x : y) != ccos(i ? x : -y)) + link_error(); + + if (ccos(i ? x : ctan(y/x)) != ccos(i ? -x : -ctan(-y/x))) + link_error(); + + if (~x != -~-x) + link_error(); + + if (ccos(~x) != ccos(-~-x)) + link_error(); + + if (ctan(~(x-y)) != -ctan(~(y-x))) + link_error(); + + if (ctan(~(x/y)) != -ctan(~(x/-y))) + link_error(); +} + +void test1f(float x) +{ + if (cosf(x) != cosf(-x)) + link_error (); + + if (cosf(x) != cosf(fabsf(x))) + link_error (); + + if (cosf(x) != cosf(-fabsf(x))) + link_error (); + + if (cosf(tanf(x)) != cosf(tanf(-fabsf(x)))) + link_error (); + +#ifdef HAVE_C99_RUNTIME + if (sinf(x)/cosf(x) != tanf(x)) + link_error (); + + if (cosf(x)/sinf(x) != 1.0f/tanf(x)) + link_error (); + + if (tanf(x)*cosf(x) != sinf(x)) + link_error (); + + if (cosf(x)*tanf(x) != sinf(x)) + link_error (); + + if (sinf(x)/tanf(x) != cosf(x)) + link_error (); + + if (tanf(x)/sinf(x) != 1.0f/cosf(x)) + link_error (); +#endif +} + +void test2f(float x, float y) +{ + if (-tanf(x-y) != tanf(y-x)) + link_error (); + + if (-sinf(x-y) != sinf(y-x)) + link_error (); + + if (cosf(-x*y) != cosf(x*y)) + link_error (); + + if (cosf(x*-y) != cosf(x*y)) + link_error (); + + if (cosf(-x/y) != cosf(x/y)) + link_error (); + + if (cosf(x/-y) != cosf(x/y)) + link_error (); + + if (cosf(-fabsf(tanf(x/-y))) != cosf(tanf(x/y))) + link_error (); + + if (cosf(y<10 ? -x : y) != cosf(y<10 ? x : y)) + link_error (); + + if (cosf(y<10 ? x : -y) != cosf(y<10 ? x : y)) + link_error (); + + if (cosf(y<10 ? -fabsf(x) : tanf(x<20 ? -x : -fabsf(y))) + != cosf(y<10 ? x : tanf(x<20 ? x : y))) + link_error (); + + if (cosf((y*=3, -x)) != cosf((y*=3,x))) + link_error (); + + if (cosf(-fabsf(tanf(x/-y))) != cosf(tanf(x/y))) + link_error (); + + if (cosf(copysignf(x,y)) != cosf(x)) + link_error (); + + if (cosf(copysignf(-fabsf(x),y*=2)) != cosf((y*=2,x))) + link_error (); + + if (hypotf (x, 0) != fabsf(x)) + link_error (); + + if (hypotf (0, x) != fabsf(x)) + link_error (); + + if (hypotf (x, x) != fabsf(x) * __builtin_sqrtf(2)) + link_error (); + + if (hypotf (-x, y) != hypotf (x, y)) + link_error (); + + if (hypotf (x, -y) != hypotf (x, y)) + link_error (); + + if (hypotf (-x, -y) != hypotf (x, y)) + link_error (); + + if (hypotf (fabsf(x), y) != hypotf (x, y)) + link_error (); + + if (hypotf (x, fabsf(y)) != hypotf (x, y)) + link_error (); + + if (hypotf (fabsf(x), fabsf(y)) != hypotf (x, y)) + link_error (); + + if (hypotf (-fabsf(-x), -fabsf(fabsf(fabsf(-y)))) != hypotf (x, y)) + link_error (); + + if (hypotf (-x, 0) != fabsf(x)) + link_error (); + + if (hypotf (-x, x) != fabsf(x) * __builtin_sqrtf(2)) + link_error (); + + if (hypotf (puref(x), -puref(x)) != fabsf(puref(x)) * __builtin_sqrtf(2)) + link_error (); + + if (hypotf (tanf(-x), tanf(-fabsf(y))) != hypotf (tanf(x), tanf(y))) + link_error (); + + if (fminf (fmaxf(x,y),y) != y) + link_error (); + + if (fminf (fmaxf(y,x),y) != y) + link_error (); + + if (fminf (x,fmaxf(x,y)) != x) + link_error (); + + if (fminf (x,fmaxf(y,x)) != x) + link_error (); + + if (fmaxf (fminf(x,y),y) != y) + link_error (); + + if (fmaxf (fminf(y,x),y) != y) + link_error (); + + if (fmaxf (x,fminf(x,y)) != x) + link_error (); + + if (fmaxf (x,fminf(y,x)) != x) + link_error (); + + if ((__complex__ float) x != -(__complex__ float) (-x)) + link_error (); + + if (x+(x-y)*1i != -(-x+(y-x)*1i)) + link_error (); + + if (x+(x-y)*1i != -(-x-(x-y)*1i)) + link_error (); + + if (ccosf(tanf(x)+sinf(y)*1i) != ccosf(-tanf(-x)+-sinf(-y)*1i)) + link_error (); + + if (ccosf(tanf(x)+sinf(x-y)*1i) != ccosf(-tanf(-x)-sinf(y-x)*1i)) + link_error (); + + if (-5+x*1i != -~(5+x*1i)) + link_error (); + + if (tanf(x)+tanf(y)*1i != -~(tanf(-x)+tanf(y)*1i)) + link_error (); +} + +void test3f(__complex__ float x, __complex__ float y, int i) +{ + if (ccosf(x) != ccosf(-x)) + link_error(); + + if (ccosf(ctanf(x)) != ccosf(ctanf(-x))) + link_error(); + + if (ctanf(x-y) != -ctanf(y-x)) + link_error(); + + if (ccosf(x/y) != ccosf(-x/y)) + link_error(); + + if (ccosf(x/y) != ccosf(x/-y)) + link_error(); + + if (ccosf(x/ctanf(y)) != ccosf(-x/ctanf(-y))) + link_error(); + + if (ccosf(x*y) != ccosf(-x*y)) + link_error(); + + if (ccosf(x*y) != ccosf(x*-y)) + link_error(); + + if (ccosf(ctanf(x)*y) != ccosf(ctanf(-x)*-y)) + link_error(); + + if (ccosf(ctanf(x/y)) != ccosf(-ctanf(x/-y))) + link_error(); + + if (ccosf(i ? x : y) != ccosf(i ? -x : y)) + link_error(); + + if (ccosf(i ? x : y) != ccosf(i ? x : -y)) + link_error(); + + if (ccosf(i ? x : ctanf(y/x)) != ccosf(i ? -x : -ctanf(-y/x))) + link_error(); + + if (~x != -~-x) + link_error(); + + if (ccosf(~x) != ccosf(-~-x)) + link_error(); + + if (ctanf(~(x-y)) != -ctanf(~(y-x))) + link_error(); + + if (ctanf(~(x/y)) != -ctanf(~(x/-y))) + link_error(); + +#ifdef HAVE_C99_RUNTIME + if (cargf(x) != atan2f(__imag__ x, __real__ x)) + link_error (); +#endif +} + +void test1l(long double x) +{ + if (cosl(x) != cosl(-x)) + link_error (); + + if (cosl(x) != cosl(fabsl(x))) + link_error (); + + if (cosl(x) != cosl(-fabsl(x))) + link_error (); + + if (cosl(tanl(x)) != cosl(tanl(-fabsl(x)))) + link_error (); + +#ifdef HAVE_C99_RUNTIME + if (sinl(x)/cosl(x) != tanl(x)) + link_error (); + + if (cosl(x)/sinl(x) != 1.0l/tanl(x)) + link_error (); + + if (tanl(x)*cosl(x) != sinl(x)) + link_error (); + + if (cosl(x)*tanl(x) != sinl(x)) + link_error (); + + if (sinl(x)/tanl(x) != cosl(x)) + link_error (); + + if (tanl(x)/sinl(x) != 1.0l/cosl(x)) + link_error (); +#endif +} + +void test2l(long double x, long double y) +{ + if (-tanl(x-y) != tanl(y-x)) + link_error (); + + if (-sinl(x-y) != sinl(y-x)) + link_error (); + + if (cosl(-x*y) != cosl(x*y)) + link_error (); + + if (cosl(x*-y) != cosl(x*y)) + link_error (); + + if (cosl(-x/y) != cosl(x/y)) + link_error (); + + if (cosl(x/-y) != cosl(x/y)) + link_error (); + + if (cosl(-fabsl(tanl(x/-y))) != cosl(tanl(x/y))) + link_error (); + + if (cosl(y<10 ? -x : y) != cosl(y<10 ? x : y)) + link_error (); + + if (cosl(y<10 ? x : -y) != cosl(y<10 ? x : y)) + link_error (); + + if (cosl(y<10 ? -fabsl(x) : tanl(x<20 ? -x : -fabsl(y))) + != cosl(y<10 ? x : tanl(x<20 ? x : y))) + link_error (); + + if (cosl((y*=3, -x)) != cosl((y*=3,x))) + link_error (); + + if (cosl(-fabsl(tanl(x/-y))) != cosl(tanl(x/y))) + link_error (); + + if (cosl(copysignl(x,y)) != cosl(x)) + link_error (); + + if (cosl(copysignl(-fabsl(x),y*=2)) != cosl((y*=2,x))) + link_error (); + + if (hypotl (x, 0) != fabsl(x)) + link_error (); + + if (hypotl (0, x) != fabsl(x)) + link_error (); + + if (hypotl (x, x) != fabsl(x) * __builtin_sqrtl(2)) + link_error (); + + if (hypotl (-x, y) != hypotl (x, y)) + link_error (); + + if (hypotl (x, -y) != hypotl (x, y)) + link_error (); + + if (hypotl (-x, -y) != hypotl (x, y)) + link_error (); + + if (hypotl (fabsl(x), y) != hypotl (x, y)) + link_error (); + + if (hypotl (x, fabsl(y)) != hypotl (x, y)) + link_error (); + + if (hypotl (fabsl(x), fabsl(y)) != hypotl (x, y)) + link_error (); + + if (hypotl (-fabsl(-x), -fabsl(fabsl(fabsl(-y)))) != hypotl (x, y)) + link_error (); + + if (hypotl (-x, 0) != fabsl(x)) + link_error (); + + if (hypotl (-x, x) != fabsl(x) * __builtin_sqrtl(2)) + link_error (); + + if (hypotl (purel(x), -purel(x)) != fabsl(purel(x)) * __builtin_sqrtl(2)) + link_error (); + + if (hypotl (tanl(-x), tanl(-fabsl(y))) != hypotl (tanl(x), tanl(y))) + link_error (); + + if (fminl (fmaxl(x,y),y) != y) + link_error (); + + if (fminl (fmaxl(y,x),y) != y) + link_error (); + + if (fminl (x,fmaxl(x,y)) != x) + link_error (); + + if (fminl (x,fmaxl(y,x)) != x) + link_error (); + + if (fmaxl (fminl(x,y),y) != y) + link_error (); + + if (fmaxl (fminl(y,x),y) != y) + link_error (); + + if (fmaxl (x,fminl(x,y)) != x) + link_error (); + + if (fmaxl (x,fminl(y,x)) != x) + link_error (); + + if ((__complex__ long double) x != -(__complex__ long double) (-x)) + link_error (); + + if (x+(x-y)*1i != -(-x+(y-x)*1i)) + link_error (); + + if (x+(x-y)*1i != -(-x-(x-y)*1i)) + link_error (); + + if (ccosl(tanl(x)+sinl(y)*1i) != ccosl(-tanl(-x)+-sinl(-y)*1i)) + link_error (); + + if (ccosl(tanl(x)+sinl(x-y)*1i) != ccosl(-tanl(-x)-sinl(y-x)*1i)) + link_error (); + + if (-5+x*1i != -~(5+x*1i)) + link_error (); + + if (tanl(x)+tanl(y)*1i != -~(tanl(-x)+tanl(y)*1i)) + link_error (); +} + +void test3l(__complex__ long double x, __complex__ long double y, int i) +{ + if (ccosl(x) != ccosl(-x)) + link_error(); + + if (ccosl(ctanl(x)) != ccosl(ctanl(-x))) + link_error(); + + if (ctanl(x-y) != -ctanl(y-x)) + link_error(); + + if (ccosl(x/y) != ccosl(-x/y)) + link_error(); + + if (ccosl(x/y) != ccosl(x/-y)) + link_error(); + + if (ccosl(x/ctanl(y)) != ccosl(-x/ctanl(-y))) + link_error(); + + if (ccosl(x*y) != ccosl(-x*y)) + link_error(); + + if (ccosl(x*y) != ccosl(x*-y)) + link_error(); + + if (ccosl(ctanl(x)*y) != ccosl(ctanl(-x)*-y)) + link_error(); + + if (ccosl(ctanl(x/y)) != ccosl(-ctanl(x/-y))) + link_error(); + + if (ccosl(i ? x : y) != ccosl(i ? -x : y)) + link_error(); + + if (ccosl(i ? x : y) != ccosl(i ? x : -y)) + link_error(); + + if (ccosl(i ? x : ctanl(y/x)) != ccosl(i ? -x : -ctanl(-y/x))) + link_error(); + + if (~x != -~-x) + link_error(); + + if (ccosl(~x) != ccosl(-~-x)) + link_error(); + + if (ctanl(~(x-y)) != -ctanl(~(y-x))) + link_error(); + + if (ctanl(~(x/y)) != -ctanl(~(x/-y))) + link_error(); + +#ifdef HAVE_C99_RUNTIME + if (cargl(x) != atan2l(__imag__ x, __real__ x)) + link_error (); +#endif +} + +int main() +{ + test1 (1.0); + test2 (1.0, 2.0); + + test1f (1.0f); + test2f (1.0f, 2.0f); + + test1l (1.0l); + test2l (1.0l, 2.0l); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-21.c b/SingleSource/Regression/C/gcc-dg/builtins-21.c new file mode 100644 index 0000000000..60b127fe61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-21.c @@ -0,0 +1,65 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Verify that built-in math function constant folding doesn't + cause any problems for the compiler. + + Written by Roger Sayle, 7th June 2003. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double fabs (double); +extern float fabsf (float); +extern long double fabsl (long double); +extern double sqrt (double); +extern float sqrtf (float); +extern long double sqrtl (long double); +extern double exp (double); +extern float expf (float); +extern long double expl (long double); + +double test1(double x) +{ + return fabs(x*x); +} + +double test2(double x) +{ + return fabs(sqrt(x)+2.0); +} + +double test3(double x) +{ + return fabs(3.0*exp(x)); +} + +float test1f(float x) +{ + return fabsf(x*x); +} + +float test2f(float x) +{ + return fabsf(sqrtf(x)+2.0f); +} + +float test3f(float x) +{ + return fabsf(3.0f*expf(x)); +} + +long double test1l(long double x) +{ + return fabsl(x*x); +} + +long double test2l(long double x) +{ + return fabsl(sqrtl(x)+2.0l); +} + +long double test3l(long double x) +{ + return fabsl(3.0l*expl(x)); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-22.c b/SingleSource/Regression/C/gcc-dg/builtins-22.c new file mode 100644 index 0000000000..916890b409 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-22.c @@ -0,0 +1,12 @@ +/* Related to PR optimization/10764 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double exp(double x); + +double foo(double x) +{ + return exp(exp(x)); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-23.c b/SingleSource/Regression/C/gcc-dg/builtins-23.c new file mode 100644 index 0000000000..f463e17e1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-23.c @@ -0,0 +1,12 @@ +/* Related to PR optimization/10764 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double atan(double x); + +double foo(double x) +{ + return atan(atan(x)); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-24.c b/SingleSource/Regression/C/gcc-dg/builtins-24.c new file mode 100644 index 0000000000..41ec1889f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-24.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that the RTL expansion of floating point exponentiation by + a constant integer doesn't break anything and produces the expected + results. + + Written by Roger Sayle, 20th June 2003. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double pow(double,double); +extern void abort(void); + +double foo (double x) +{ + return pow (x, 6); +} + +double bar (double x) +{ + return pow (x, -4); +} + +int main() +{ + if (foo (2.0) != 64.0) + abort (); + + if (bar (2.0) != 0.0625) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-26.c b/SingleSource/Regression/C/gcc-dg/builtins-26.c new file mode 100644 index 0000000000..c4d03cd7da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-26.c @@ -0,0 +1,105 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding of built-in math functions doesn't + break anything and produces the expected results. + + Written by Roger Sayle, 28th June 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void link_error(void); + +extern double trunc(double); +extern double floor(double); +extern double ceil(double); + +extern float truncf(float); +extern float floorf(float); +extern float ceilf(float); + +extern long double truncl(long double); +extern long double floorl(long double); +extern long double ceill(long double); + +void test(double x) +{ + if (trunc (trunc (x)) != trunc (x)) + link_error (); + if (trunc (floor (x)) != floor (x)) + link_error (); + if (trunc (ceil (x)) != ceil (x)) + link_error (); + + if (floor (trunc (x)) != trunc (x)) + link_error (); + if (floor (floor (x)) != floor (x)) + link_error (); + if (floor (ceil (x)) != ceil (x)) + link_error (); + + if (ceil (trunc (x)) != trunc (x)) + link_error (); + if (ceil (floor (x)) != floor (x)) + link_error (); + if (ceil (ceil (x)) != ceil (x)) + link_error (); +} + +void testf(float x) +{ + if (truncf (truncf (x)) != truncf (x)) + link_error (); + if (truncf (floorf (x)) != floorf (x)) + link_error (); + if (truncf (ceilf (x)) != ceilf (x)) + link_error (); + + if (floorf (truncf (x)) != truncf (x)) + link_error (); + if (floorf (floorf (x)) != floorf (x)) + link_error (); + if (floorf (ceilf (x)) != ceilf (x)) + link_error (); + + if (ceilf (truncf (x)) != truncf (x)) + link_error (); + if (ceilf (floorf (x)) != floorf (x)) + link_error (); + if (ceilf (ceilf (x)) != ceilf (x)) + link_error (); +} + +void testl(long double x) +{ + if (truncl (truncl (x)) != truncl (x)) + link_error (); + if (truncl (floorl (x)) != floorl (x)) + link_error (); + if (truncl (ceill (x)) != ceill (x)) + link_error (); + + if (floorl (truncl (x)) != truncl (x)) + link_error (); + if (floorl (floorl (x)) != floorl (x)) + link_error (); + if (floorl (ceill (x)) != ceill (x)) + link_error (); + + if (ceill (truncl (x)) != truncl (x)) + link_error (); + if (ceill (floorl (x)) != floorl (x)) + link_error (); + if (ceill (ceill (x)) != ceill (x)) + link_error (); +} + + +int main() +{ + test (3.2); + testf (3.2f); + testl (3.2l); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-27.c b/SingleSource/Regression/C/gcc-dg/builtins-27.c new file mode 100644 index 0000000000..69d8f99448 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-27.c @@ -0,0 +1,47 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding of built-in math functions doesn't + break anything and produces the expected results. + + Written by Roger Sayle, 29th July 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void link_error(void); + +extern double pow(double,double); + +void test(double x) +{ + if (pow(x,2.0) != x*x) + link_error (); + + if (x*pow(x,2.0) != pow(x,3.0)) + link_error (); + + if (pow(x,2.0)*x != pow(x,3.0)) + link_error (); + + if (pow(x,3.0) != x*x*x) + link_error (); + + if (pow(x,2.0)*x != x*x*x) + link_error (); + + if (x*pow(x,2.0) != x*x*x) + link_error (); + + if (pow(x,3.0)/x != pow(x,2.0)) + link_error (); + + if (pow(x,3.0)/x != x*x) + link_error (); +} + +int main() +{ + test (2.0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-28.c b/SingleSource/Regression/C/gcc-dg/builtins-28.c new file mode 100644 index 0000000000..bd76d6b97b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-28.c @@ -0,0 +1,27 @@ +/* Test that creal and cimag built-in functions do not return lvalues. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern float crealf (float _Complex); +extern double creal (double _Complex); +extern long double creall (long double _Complex); + +extern float cimagf (float _Complex); +extern double cimag (double _Complex); +extern long double cimagl (long double _Complex); + +float _Complex fc; +double _Complex dc; +long double _Complex ldc; + +void +foo (void) +{ + crealf (fc) = 0; /* { dg-error "lvalue" "crealf not lvalue" } */ + cimagf (fc) = 0; /* { dg-error "lvalue" "cimagf not lvalue" } */ + creal (dc) = 0; /* { dg-error "lvalue" "creal not lvalue" } */ + cimag (dc) = 0; /* { dg-error "lvalue" "cimag not lvalue" } */ + creall (ldc) = 0; /* { dg-error "lvalue" "creall not lvalue" } */ + cimagl (ldc) = 0; /* { dg-error "lvalue" "cimagl not lvalue" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-30.c b/SingleSource/Regression/C/gcc-dg/builtins-30.c new file mode 100644 index 0000000000..37e5dba2db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-30.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wshadow -fshow-column" } */ + +extern double strtod (const char *, char **); +#define UNUSED __attribute__ ((unused)) + +/* A built-in function may be overridden by an old-style definition + specifying too few arguments... */ +double cos () /* { dg-warning "shadows a built-in|number of arguments" } */ +{ + return strtod ("nan", 0); +} + +/* the right number, but the wrong type, arguments... */ +double sin (foo) /* { dg-warning "8:shadows a built-in" } */ + int foo UNUSED; /* { dg-warning "10:argument 'foo' doesn't match built-in prototype" } */ +{ + return strtod ("nan", 0); +} + +/* or too many arguments. */ +long double cosl (foo, bar) /* { dg-warning "shadows a built-in|number of arguments" } */ + const char *foo UNUSED; /* { dg-warning "18:argument 'foo' doesn't match" } */ + int bar UNUSED; +{ + return strtod ("nan", 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-31.c b/SingleSource/Regression/C/gcc-dg/builtins-31.c new file mode 100644 index 0000000000..6e1bda0b7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-31.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that constant folding of signbit, signbitf and signbitl math + functions doesn't break anything and produces the expected results. + + Written by Roger Sayle, 28th January 2004. */ + +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern void link_error(void); + +extern int signbit(double); +extern int signbitf(float); +extern int signbitl(long double); + +int main() +{ + if (signbit (1.0) != 0) + link_error (); + if (signbit (-2.0) == 0) + link_error (); + + if (signbitf (1.0f) != 0) + link_error (); + if (signbitf (-2.0f) == 0) + link_error (); + + if (signbitl (1.0l) != 0) + link_error (); + if (signbitl (-2.0f) == 0) + link_error (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-32.c b/SingleSource/Regression/C/gcc-dg/builtins-32.c new file mode 100644 index 0000000000..3d2a36190a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-32.c @@ -0,0 +1,58 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that constant folding of signbit, signbitf and signbitl math + functions doesn't break anything and produces the expected results. + + Written by Roger Sayle, 28th January 2004. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort(void); + +extern int signbit(double); +extern int signbitf(float); +extern int signbitl(long double); + +int test (double x) +{ + return signbit(x); +} + +int testf (float x) +{ + return signbitf(x); +} + +int testl (long double x) +{ + return signbitl(x); +} + + +int main() +{ + if (test (0.0) != 0) + abort (); + if (test (1.0) != 0) + abort (); + if (test (-2.0) == 0) + abort (); + + if (testf (0.0f) != 0) + abort (); + if (testf (1.0f) != 0) + abort (); + if (testf (-2.0f) == 0) + abort (); + + if (testl (0.0l) != 0) + abort (); + if (testl (1.0l) != 0) + abort (); + if (testl (-2.0l) == 0) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-33.c b/SingleSource/Regression/C/gcc-dg/builtins-33.c new file mode 100644 index 0000000000..11393e3008 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-33.c @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that log10, log10f, log10l, log2, log2f and log2l + built-in functions compile. + + Written by Uros Bizjak, 11th February 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double log10(double); +extern double log2(double); +extern double log1p(double); +extern float log10f(float); +extern float log2f(float); +extern float log1pf(float); +extern long double log10l(long double); +extern long double log2l(long double); +extern long double log1pl(long double); + + +double test1(double x) +{ + return log10(x); +} + +double test2(double x) +{ + return log2(x); +} + +double test3(double x) +{ + return log1p(x); +} + +float test1f(float x) +{ + return log10f(x); +} + +float test2f(float x) +{ + return log2f(x); +} + +float test3f(float x) +{ + return log1pf(x); +} + +long double test1l(long double x) +{ + return log10l(x); +} + +long double test2l(long double x) +{ + return log2l(x); +} + +long double test3l(long double x) +{ + return log1pl(x); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-34.c b/SingleSource/Regression/C/gcc-dg/builtins-34.c new file mode 100644 index 0000000000..e348a1ca94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-34.c @@ -0,0 +1,172 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that various built-in functions compile. + + Written by Uros Bizjak, 13th February 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double exp10(double); +extern double exp2(double); +extern double pow10(double); +extern double expm1(double); +extern double ldexp(double, int); +extern double scalb(double, double); +extern double scalbn(double, int); +extern double scalbln(double, long); +extern double significand(double); +extern float exp10f(float); +extern float exp2f(float); +extern float pow10f(float); +extern float expm1f(float); +extern float ldexpf(float, int); +extern float scalbf(float, float); +extern float scalbnf(float, int); +extern float scalblnf(float, long); +extern float significandf(float); +extern long double exp10l(long double); +extern long double exp2l(long double); +extern long double pow10l(long double); +extern long double expm1l(long double); +extern long double ldexpl(long double, int); +extern long double scalbl(long double, long double); +extern long double scalbnl(long double, int); +extern long double scalblnl(long double, long); +extern long double significandl(long double); + + +double test1(double x) +{ + return exp10(x); +} + +double test2(double x) +{ + return exp2(x); +} + +double test3(double x) +{ + return pow10(x); +} + +double test4(double x) +{ + return expm1(x); +} + +double test5(double x, int exp) +{ + return ldexp(x, exp); +} + +double test6(double x, double exp) +{ + return scalb(x, exp); +} + +double test7(double x, int exp) +{ + return scalbn(x, exp); +} + +double test8(double x, long exp) +{ + return scalbln(x, exp); +} + +double test9(double x) +{ + return significand(x); +} + +float test1f(float x) +{ + return exp10f(x); +} + +float test2f(float x) +{ + return exp2f(x); +} + +float test3f(float x) +{ + return pow10f(x); +} + +float test4f(float x) +{ + return expm1f(x); +} + +float test5f(float x, int exp) +{ + return ldexpf(x, exp); +} + +float test6f(float x, float exp) +{ + return scalbf(x, exp); +} + +float test7f(float x, int exp) +{ + return scalbnf(x, exp); +} + +float test8f(float x, long exp) +{ + return scalblnf(x, exp); +} + +float test9f(float x) +{ + return significandf(x); +} + +long double test1l(long double x) +{ + return exp10l(x); +} + +long double test2l(long double x) +{ + return exp2l(x); +} + +long double test3l(long double x) +{ + return pow10l(x); +} + +long double test4l(long double x) +{ + return expm1l(x); +} + +long double test5l(long double x, int exp) +{ + return ldexpl(x, exp); +} + +long double test6l(long double x, long double exp) +{ + return scalbl(x, exp); +} + +long double test7l(long double x, int exp) +{ + return scalbnl(x, exp); +} + +long double test8l(long double x, long exp) +{ + return scalblnl(x, exp); +} + +long double test9l(long double x) +{ + return significandl(x); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-35.c b/SingleSource/Regression/C/gcc-dg/builtins-35.c new file mode 100644 index 0000000000..f898707e24 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-35.c @@ -0,0 +1,6 @@ +/* Test that nan functions are not built-in in C90 mode. Bug 14635. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c89" } */ + +int nan, nanf, nanl, nans, nansf, nansl; diff --git a/SingleSource/Regression/C/gcc-dg/builtins-36.c b/SingleSource/Regression/C/gcc-dg/builtins-36.c new file mode 100644 index 0000000000..dc71198844 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-36.c @@ -0,0 +1,79 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check sin, sinf, sinl, cos, cosf and cosl built-in functions + eventually compile to sincos, sincosf and sincosl. + + Written by Uros Bizjak, 5th April 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double sin(double); +extern float sinf(float); +extern long double sinl(long double); + +extern double cos(double); +extern float cosf(float); +extern long double cosl(long double); + + +double test1(double x) +{ + double y1, y2; + + y1 = sin(x); + y2 = cos(x); + + return y1 - y2; +} + +float test1f(float x) +{ + float y1, y2; + + y1 = sinf(x); + y2 = cosf(x); + + return y1 - y2; +} + +long double test1l(long double x) +{ + long double y1, y2; + + y1 = sinl(x); + y2 = cosl(x); + + return y1 - y2; +} + +double test2(double x) +{ + return sin(x); +} + +float test2f(float x) +{ + return sinf(x); +} + +long double test2l(long double x) +{ + return sinl(x); +} + +double test3(double x) +{ + return cos(x); +} + +float test3f(float x) +{ + return cosf(x); +} + +long double test3l(long double x) +{ + return cosl(x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-37.c b/SingleSource/Regression/C/gcc-dg/builtins-37.c new file mode 100644 index 0000000000..e366a6ac55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-37.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check tan, tanf and tanl built-in functions. + + Written by Uros Bizjak, 7th April 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double tan(double); +extern float tanf(float); +extern long double tanl(long double); + + +double test1(double x) +{ + return tan(x); +} + +float test1f(float x) +{ + return tanf(x); +} + +long double test1l(long double x) +{ + return tanl(x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-38.c b/SingleSource/Regression/C/gcc-dg/builtins-38.c new file mode 100644 index 0000000000..210516bb7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-38.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that logb, logbf, logbl, ilogb, ilogbf and ilogbl + built-in functions compile. + + Written by Uros Bizjak, 14th April 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double logb(double); +extern float logbf(float); +extern long double logbl(long double); +extern int ilogb(double); +extern int ilogbf(float); +extern int ilogbl(long double); + + +double test1(double x) +{ + return logb(x); +} + +float test1f(float x) +{ + return logbf(x); +} + +long double test1l(long double x) +{ + return logbl(x); +} + +int test2(double x) +{ + return ilogb(x); +} + +int test2f(float x) +{ + return ilogbf(x); +} + +int test2l(long double x) +{ + return ilogbl(x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-39.c b/SingleSource/Regression/C/gcc-dg/builtins-39.c new file mode 100644 index 0000000000..6359be2b30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-39.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that asin, asinf, asinl, acos, acosf + and acosl built-in functions compile. + + Written by Uros Bizjak, 20th April 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double asin(double); +extern double acos(double); +extern float asinf(float); +extern float acosf(float); +extern long double asinl(long double); +extern long double acosl(long double); + + +double test1(double x) +{ + return asin(x); +} + +double test2(double x) +{ + return acos(x); +} + +float test1f(float x) +{ + return asinf(x); +} + +float test2f(float x) +{ + return acosf(x); +} + +long double test1l(long double x) +{ + return asinl(x); +} + +long double test2l(long double x) +{ + return acosl(x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-40.c b/SingleSource/Regression/C/gcc-dg/builtins-40.c new file mode 100644 index 0000000000..982175a3a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-40.c @@ -0,0 +1,68 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that fmod, fmodf, fmodl, drem, dremf, dreml, + remainder, remainderf and remainderl + built-in functions compile. + + Written by Uros Bizjak, 5th May 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern double fmod(double, double); +extern float fmodf(float, float); +extern long double fmodl(long double, long double); + +extern double remainder(double, double); +extern float remainderf(float, float); +extern long double remainderl(long double, long double); + +extern double drem(double, double); +extern float dremf(float, float); +extern long double dreml(long double, long double); + + +double test1(double x, double y) +{ + return fmod(x, y); +} + +float test1f(float x, float y) +{ + return fmodf(x, y); +} + +long double test1l(long double x, long double y) +{ + return fmodl(x, y); +} + +double test2(double x, double y) +{ + return remainder(x, y); +} + +float test2f(float x, float y) +{ + return remainderf(x, y); +} + +long double test2l(long double x, long double y) +{ + return remainderl(x, y); +} + +double test3(double x, double y) +{ + return drem(x, y); +} + +float test3f(float x, float y) +{ + return dremf(x, y); +} + +long double test3l(long double x, long double y) +{ + return dreml(x, y); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-41.c b/SingleSource/Regression/C/gcc-dg/builtins-41.c new file mode 100644 index 0000000000..5b96551fb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-41.c @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that constant folding of copysign, copysignf and copysignl math + functions doesn't break anything and produces the expected results. + + Written by Roger Sayle, 6th June 2004. */ + +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern void link_error(void); + +extern double copysign(double, double); +extern float copysignf(float, float); +extern long double copysignl(long double, long double); + +int main() +{ + if (copysign (2.0, 1.0) != 2.0) + link_error (); + if (copysign (2.0, -1.0) != -2.0) + link_error (); + if (copysign (-2.0, 1.0) != 2.0) + link_error (); + if (copysign (-2.0, -1.0) != -2.0) + link_error (); + + if (copysign (2.0, 1.0) != 2.0) + link_error (); + if (copysign (2.0, -1.0) != -2.0) + link_error (); + if (copysign (-2.0, 1.0) != 2.0) + link_error (); + if (copysign (-2.0, -1.0) != -2.0) + link_error (); + + if (copysignf (2.0f, 1.0f) != 2.0f) + link_error (); + if (copysignf (2.0f, -1.0f) != -2.0f) + link_error (); + if (copysignf (-2.0f, 1.0f) != 2.0f) + link_error (); + if (copysignf (-2.0f, -1.0f) != -2.0f) + link_error (); + + if (copysignl (2.0l, 1.0l) != 2.0l) + link_error (); + if (copysignl (2.0l, -1.0l) != -2.0l) + link_error (); + if (copysignl (-2.0l, 1.0l) != 2.0l) + link_error (); + if (copysignl (-2.0l, -1.0l) != -2.0l) + link_error (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-43.c b/SingleSource/Regression/C/gcc-dg/builtins-43.c new file mode 100644 index 0000000000..24a34ed35b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-43.c @@ -0,0 +1,52 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-trapping-math -fno-finite-math-only -fdump-tree-gimple -fdump-tree-optimized" } */ + +extern void f(int); +extern void link_error (); + +extern float x; +extern double y; +extern long double z; + +int +main () +{ + double nan = __builtin_nan (""); + float nanf = __builtin_nanf (""); + long double nanl = __builtin_nanl (""); + + if (!__builtin_isnan (nan)) + link_error (); + if (!__builtin_isnan (nanf)) + link_error (); + if (!__builtin_isnanf (nanf)) + link_error (); + if (!__builtin_isnan (nanl)) + link_error (); + if (!__builtin_isnanl (nanl)) + link_error (); + + if (__builtin_isnan (4.0)) + link_error (); + if (__builtin_isnan (4.0)) + link_error (); + if (__builtin_isnanf (4.0)) + link_error (); + if (__builtin_isnan (4.0)) + link_error (); + if (__builtin_isnanl (4.0)) + link_error (); + + f (__builtin_isnan (x)); + f (__builtin_isnan (y)); + f (__builtin_isnanf (y)); + f (__builtin_isnan (z)); + f (__builtin_isnanl (z)); +} + + +/* Check that all instances of __builtin_isnan were folded. */ +/* { dg-final { scan-tree-dump-times "isnan" 0 "gimple" } } */ + +/* Check that all instances of link_error were subject to DCE. */ +/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-44.c b/SingleSource/Regression/C/gcc-dg/builtins-44.c new file mode 100644 index 0000000000..4a123502dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-44.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target inf } */ +/* { dg-options "-O1 -fno-trapping-math -fno-finite-math-only -fdump-tree-optimized" } */ + +extern void f(int); +extern void link_error (); + +extern float x; +extern double y; +extern long double z; + +int +main () +{ + double pinf = __builtin_inf (); + float pinff = __builtin_inff (); + long double pinfl = __builtin_infl (); + + if (__builtin_isinf (pinf) != 1) + link_error (); + if (__builtin_isinf (pinff) != 1) + link_error (); + if (__builtin_isinff (pinff) != 1) + link_error (); + if (__builtin_isinf (pinfl) != 1) + link_error (); + if (__builtin_isinfl (pinfl) != 1) + link_error (); + + if (__builtin_isinf_sign (-pinf) != -1) + link_error (); + if (__builtin_isinf_sign (-pinff) != -1) + link_error (); + if (__builtin_isinf_sign (-pinfl) != -1) + link_error (); + + if (__builtin_isinf (4.0)) + link_error (); + if (__builtin_isinf (4.0)) + link_error (); + if (__builtin_isinff (4.0)) + link_error (); + if (__builtin_isinf (4.0)) + link_error (); + if (__builtin_isinfl (4.0)) + link_error (); +} + + +/* Check that all instances of link_error were subject to DCE. */ +/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-45.c b/SingleSource/Regression/C/gcc-dg/builtins-45.c new file mode 100644 index 0000000000..871e802e19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-45.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target inf } */ +/* { dg-options "-O1 -fno-trapping-math -fno-finite-math-only -fdump-tree-optimized" } */ + +extern void f(int); +extern void link_error (); + +extern float x; +extern double y; +extern long double z; + +int +main () +{ + double nan = __builtin_nan (""); + float nanf = __builtin_nanf (""); + long double nanl = __builtin_nanl (""); + + double pinf = __builtin_inf (); + float pinff = __builtin_inff (); + long double pinfl = __builtin_infl (); + + if (__builtin_finite (pinf)) + link_error (); + if (__builtin_finitef (pinff)) + link_error (); + if (__builtin_finitel (pinfl)) + link_error (); + + if (__builtin_finite (nan)) + link_error (); + if (__builtin_finitef (nanf)) + link_error (); + if (__builtin_finitel (nanl)) + link_error (); + + if (!__builtin_finite (4.0)) + link_error (); + if (!__builtin_finitef (4.0)) + link_error (); + if (!__builtin_finitel (4.0)) + link_error (); +} + + +/* Check that all instances of link_error were subject to DCE. */ +/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-46.c b/SingleSource/Regression/C/gcc-dg/builtins-46.c new file mode 100644 index 0000000000..3a955a5692 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-46.c @@ -0,0 +1,142 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check that rint, rintf, rintl, lrint, lrintf, lrintl, + llrint, llrintf, llrintl, floor, floorf, floorl, + ceil, ceilf, ceill, trunc, truncf, truncl, + nearbyint, nearbyintf and nearbyintl + built-in functions compile. + + Written by Uros Bizjak, 25th Aug 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double rint(double); +extern long int lrint(double); +extern long long int llrint(double); +extern double floor(double); +extern double ceil(double); +extern double trunc(double); +extern double nearbyint(double); + +extern float rintf(float); +extern long int lrintf(float); +extern long long int llrintf(float); +extern float floorf(float); +extern float ceilf(float); +extern float truncf(float); +extern float nearbyintf(float); + +extern long double rintl(long double); +extern long int lrintl(long double); +extern long long int llrintl(long double); +extern long double floorl(long double); +extern long double ceill(long double); +extern long double truncl(long double); +extern long double nearbyintl(long double); + + +double test1(double x) +{ + return rint(x); +} + +long int test11(double x) +{ + return lrint(x); +} + +long long int test12(double x) +{ + return llrint(x); +} + +double test2(double x) +{ + return floor(x); +} + +double test3(double x) +{ + return ceil(x); +} + +double test4(double x) +{ + return trunc(x); +} + +double test5(double x) +{ + return nearbyint(x); +} + +float test1f(float x) +{ + return rintf(x); +} + +long int test11f(float x) +{ + return lrintf(x); +} + +long long int test12f(float x) +{ + return llrintf(x); +} + +float test2f(float x) +{ + return floorf(x); +} + +float test3f(float x) +{ + return ceilf(x); +} + +float test4f(float x) +{ + return truncf(x); +} + +float test5f(float x) +{ + return nearbyintf(x); +} + +long double test1l(long double x) +{ + return rintl(x); +} + +long int test11l(long double x) +{ + return lrintl(x); +} + +long long int test12l(long double x) +{ + return llrintl(x); +} + +long double test2l(long double x) +{ + return floorl(x); +} + +long double test3l(long double x) +{ + return ceill(x); +} + +long double test4l(long double x) +{ + return truncl(x); +} + +long double test5l(long double x) +{ + return nearbyintl(x); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-47.c b/SingleSource/Regression/C/gcc-dg/builtins-47.c new file mode 100644 index 0000000000..fbe9d21a26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-47.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O -ffast-math -fdump-tree-optimized" } */ + +extern double sqrt (double); +extern double pow (double, double); +extern void abort (void); + +int main () +{ + double x = -1.0; + if (sqrt (pow (x, 2)) != 1.0) + abort(); + if (sqrt (x*x) != 1.0) + abort(); + return 0; +} + +/* { dg-final { scan-tree-dump-times "sqrt" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "pow" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-48.c b/SingleSource/Regression/C/gcc-dg/builtins-48.c new file mode 100644 index 0000000000..43710b868b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-48.c @@ -0,0 +1,181 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern double fabs(double); +extern float fabsf(float); +extern void abort(void); + + +double test1(double x) +{ + return (-x)*(-x); +} + +float test1f(float x) +{ + return (-x)*(-x); +} + +double test2(double x) +{ + return fabs(x)*fabs(x); +} + +float test2f(float x) +{ + return fabsf(x)*fabsf(x); +} + +double test3(double x, double y) +{ + return (x*-y)*(x*-y); +} + +float test3f(float x, float y) +{ + return (x*-y)*(x*-y); +} + +double test4(double x, double y) +{ + return (x/-y)*(x/-y); +} + +float test4f(float x, float y) +{ + return (x/-y)*(x/-y); +} + +int main() +{ + if (test1(1.0) != 1.0) + abort(); + if (test1(2.0) != 4.0) + abort(); + if (test1(0.0) != 0.0) + abort(); + if (test1(-1.0) != 1.0) + abort(); + if (test1(-2.0) != 4.0) + abort(); + + if (test1f(1.0f) != 1.0f) + abort(); + if (test1f(2.0f) != 4.0f) + abort(); + if (test1f(0.0f) != 0.0f) + abort(); + if (test1f(-1.0f) != 1.0f) + abort(); + if (test1f(-2.0f) != 4.0f) + abort(); + + if (test2(1.0) != 1.0) + abort(); + if (test2(2.0) != 4.0) + abort(); + if (test2(0.0) != 0.0) + abort(); + if (test2(-1.0) != 1.0) + abort(); + if (test2(-2.0) != 4.0) + abort(); + + if (test2f(1.0f) != 1.0f) + abort(); + if (test2f(2.0f) != 4.0f) + abort(); + if (test2f(0.0f) != 0.0f) + abort(); + if (test2f(-1.0f) != 1.0f) + abort(); + if (test2f(-2.0f) != 4.0f) + abort(); + + if (test3(1.0,1.0) != 1.0) + abort(); + if (test3(1.0,-1.0) != 1.0) + abort(); + if (test3(1.0,2.0) != 4.0) + abort(); + if (test3(1.0,-2.0) != 4.0) + abort(); + if (test3(2.0,1.0) != 4.0) + abort(); + if (test3(2.0,-1.0) != 4.0) + abort(); + if (test3(2.0,2.0) != 16.0) + abort(); + if (test3(2.0,-2.0) != 16.0) + abort(); + if (test3(-2.0,1.0) != 4.0) + abort(); + if (test3(-2.0,-1.0) != 4.0) + abort(); + if (test3(-2.0,2.0) != 16.0) + abort(); + if (test3(-2.0,-2.0) != 16.0) + abort(); + + if (test3f(1.0f,1.0f) != 1.0f) + abort(); + if (test3f(1.0f,-1.0f) != 1.0f) + abort(); + if (test3f(1.0f,2.0f) != 4.0f) + abort(); + if (test3f(1.0f,-2.0f) != 4.0f) + abort(); + if (test3f(2.0f,1.0f) != 4.0f) + abort(); + if (test3f(2.0f,-1.0f) != 4.0f) + abort(); + if (test3f(2.0f,2.0f) != 16.0f) + abort(); + if (test3f(2.0f,-2.0f) != 16.0f) + abort(); + if (test3f(-2.0f,1.0f) != 4.0f) + abort(); + if (test3f(-2.0f,-1.0f) != 4.0f) + abort(); + if (test3f(-2.0f,2.0f) != 16.0f) + abort(); + if (test3f(-2.0f,-2.0f) != 16.0f) + abort(); + + if (test4(1.0,1.0) != 1.0) + abort(); + if (test4(1.0,-1.0) != 1.0) + abort(); + if (test4(-1.0,1.0) != 1.0) + abort(); + if (test4(-1.0,-1.0) != 1.0) + abort(); + if (test4(6.0,3.0) != 4.0) + abort(); + if (test4(6.0,-3.0) != 4.0) + abort(); + if (test4(-6.0,3.0) != 4.0) + abort(); + if (test4(-6.0,-3.0) != 4.0) + abort(); + + if (test4f(1.0f,1.0f) != 1.0f) + abort(); + if (test4f(1.0f,-1.0f) != 1.0f) + abort(); + if (test4f(-1.0f,1.0f) != 1.0f) + abort(); + if (test4f(-1.0f,-1.0f) != 1.0f) + abort(); + if (test4f(6.0f,3.0f) != 4.0f) + abort(); + if (test4f(6.0f,-3.0f) != 4.0f) + abort(); + if (test4f(-6.0f,3.0f) != 4.0f) + abort(); + if (test4f(-6.0f,-3.0f) != 4.0f) + abort(); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-49.c b/SingleSource/Regression/C/gcc-dg/builtins-49.c new file mode 100644 index 0000000000..fdeaad467f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-49.c @@ -0,0 +1,181 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern double fabs(double); +extern float fabsf(float); +extern void abort(void); + + +double test1(double x) +{ + return fabs(-x); +} + +float test1f(float x) +{ + return fabsf(-x); +} + +double test2(double x) +{ + return fabs(fabs(x)); +} + +float test2f(float x) +{ + return fabsf(fabsf(x)); +} + +double test3(double x, double y) +{ + return fabs(x*-y); +} + +float test3f(float x, float y) +{ + return fabsf(x*-y); +} + +double test4(double x, double y) +{ + return fabs(x/-y); +} + +float test4f(float x, float y) +{ + return fabsf(x/-y); +} + +int main() +{ + if (test1(1.0) != 1.0) + abort(); + if (test1(2.0) != 2.0) + abort(); + if (test1(0.0) != 0.0) + abort(); + if (test1(-1.0) != 1.0) + abort(); + if (test1(-2.0) != 2.0) + abort(); + + if (test1f(1.0f) != 1.0f) + abort(); + if (test1f(2.0f) != 2.0f) + abort(); + if (test1f(0.0f) != 0.0f) + abort(); + if (test1f(-1.0f) != 1.0f) + abort(); + if (test1f(-2.0f) != 2.0f) + abort(); + + if (test2(1.0) != 1.0) + abort(); + if (test2(2.0) != 2.0) + abort(); + if (test2(0.0) != 0.0) + abort(); + if (test2(-1.0) != 1.0) + abort(); + if (test2(-2.0) != 2.0) + abort(); + + if (test2f(1.0f) != 1.0f) + abort(); + if (test2f(2.0f) != 2.0f) + abort(); + if (test2f(0.0f) != 0.0f) + abort(); + if (test2f(-1.0f) != 1.0f) + abort(); + if (test2f(-2.0f) != 2.0f) + abort(); + + if (test3(1.0,1.0) != 1.0) + abort(); + if (test3(1.0,-1.0) != 1.0) + abort(); + if (test3(1.0,2.0) != 2.0) + abort(); + if (test3(1.0,-2.0) != 2.0) + abort(); + if (test3(2.0,1.0) != 2.0) + abort(); + if (test3(2.0,-1.0) != 2.0) + abort(); + if (test3(2.0,2.0) != 4.0) + abort(); + if (test3(2.0,-2.0) != 4.0) + abort(); + if (test3(-2.0,1.0) != 2.0) + abort(); + if (test3(-2.0,-1.0) != 2.0) + abort(); + if (test3(-2.0,2.0) != 4.0) + abort(); + if (test3(-2.0,-2.0) != 4.0) + abort(); + + if (test3f(1.0f,1.0f) != 1.0f) + abort(); + if (test3f(1.0f,-1.0f) != 1.0f) + abort(); + if (test3f(1.0f,2.0f) != 2.0f) + abort(); + if (test3f(1.0f,-2.0f) != 2.0f) + abort(); + if (test3f(2.0f,1.0f) != 2.0f) + abort(); + if (test3f(2.0f,-1.0f) != 2.0f) + abort(); + if (test3f(2.0f,2.0f) != 4.0f) + abort(); + if (test3f(2.0f,-2.0f) != 4.0f) + abort(); + if (test3f(-2.0f,1.0f) != 2.0f) + abort(); + if (test3f(-2.0f,-1.0f) != 2.0f) + abort(); + if (test3f(-2.0f,2.0f) != 4.0f) + abort(); + if (test3f(-2.0f,-2.0f) != 4.0f) + abort(); + + if (test4(1.0,1.0) != 1.0) + abort(); + if (test4(1.0,-1.0) != 1.0) + abort(); + if (test4(-1.0,1.0) != 1.0) + abort(); + if (test4(-1.0,-1.0) != 1.0) + abort(); + if (test4(6.0,3.0) != 2.0) + abort(); + if (test4(6.0,-3.0) != 2.0) + abort(); + if (test4(-6.0,3.0) != 2.0) + abort(); + if (test4(-6.0,-3.0) != 2.0) + abort(); + + if (test4f(1.0f,1.0f) != 1.0f) + abort(); + if (test4f(1.0f,-1.0f) != 1.0f) + abort(); + if (test4f(-1.0f,1.0f) != 1.0f) + abort(); + if (test4f(-1.0f,-1.0f) != 1.0f) + abort(); + if (test4f(6.0f,3.0f) != 2.0f) + abort(); + if (test4f(6.0f,-3.0f) != 2.0f) + abort(); + if (test4f(-6.0f,3.0f) != 2.0f) + abort(); + if (test4f(-6.0f,-3.0f) != 2.0f) + abort(); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-50.c b/SingleSource/Regression/C/gcc-dg/builtins-50.c new file mode 100644 index 0000000000..2d32d1ed96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-50.c @@ -0,0 +1,159 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern double copysign(double,double); +extern float copysignf(float,float); +extern double fabs(double); +extern float fabsf(float); +extern void abort(void); + + +double test1(double x, double y) +{ + return copysign(-x,y); +} + +float test1f(float x, float y) +{ + return copysignf(-x,y); +} + +double test2(double x, double y) +{ + return copysign(fabs(x),y); +} + +float test2f(float x, float y) +{ + return copysignf(fabsf(x),y); +} + +double test3(double x, double y, double z) +{ + return copysign(x*-y,z); +} + +float test3f(float x, float y, float z) +{ + return copysignf(x*-y,z); +} + +double test4(double x, double y, double z) +{ + return copysign(x/-y,z); +} + +float test4f(float x, float y, float z) +{ + return copysignf(x/-y,z); +} + +int main() +{ + if (test1(3.0,2.0) != 3.0) + abort(); + if (test1(3.0,-2.0) != -3.0) + abort(); + if (test1(-3.0,2.0) != 3.0) + abort(); + if (test1(-3.0,-2.0) != -3.0) + abort(); + + if (test1f(3.0f,2.0f) != 3.0f) + abort(); + if (test1f(3.0f,-2.0f) != -3.0f) + abort(); + if (test1f(-3.0f,2.0f) != 3.0f) + abort(); + if (test1f(-3.0f,-2.0f) != -3.0f) + abort(); + + if (test2(3.0,2.0) != 3.0) + abort(); + if (test2(3.0,-2.0) != -3.0) + abort(); + if (test2(-3.0,2.0) != 3.0) + abort(); + if (test2(-3.0,-2.0) != -3.0) + abort(); + + if (test2f(3.0f,2.0f) != 3.0f) + abort(); + if (test2f(3.0f,-2.0f) != -3.0f) + abort(); + if (test2f(-3.0f,2.0f) != 3.0f) + abort(); + if (test2f(-3.0f,-2.0f) != -3.0f) + abort(); + + if (test3(2.0,3.0,4.0) != 6.0) + abort(); + if (test3(2.0,3.0,-4.0) != -6.0) + abort(); + if (test3(2.0,-3.0,4.0) != 6.0) + abort(); + if (test3(2.0,-3.0,-4.0) != -6.0) + abort(); + if (test3(-2.0,3.0,4.0) != 6.0) + abort(); + if (test3(-2.0,3.0,-4.0) != -6.0) + abort(); + if (test3(-2.0,-3.0,4.0) != 6.0) + abort(); + if (test3(-2.0,-3.0,-4.0) != -6.0) + abort(); + + if (test3f(2.0f,3.0f,4.0f) != 6.0f) + abort(); + if (test3f(2.0f,3.0f,-4.0f) != -6.0f) + abort(); + if (test3f(2.0f,-3.0f,4.0f) != 6.0f) + abort(); + if (test3f(2.0f,-3.0f,-4.0f) != -6.0f) + abort(); + if (test3f(-2.0f,3.0f,4.0f) != 6.0f) + abort(); + if (test3f(-2.0f,3.0f,-4.0f) != -6.0f) + abort(); + if (test3f(-2.0f,-3.0f,4.0f) != 6.0f) + abort(); + if (test3f(-2.0f,-3.0f,-4.0f) != -6.0f) + abort(); + + if (test4(8.0,2.0,3.0) != 4.0) + abort(); + if (test4(8.0,2.0,-3.0) != -4.0) + abort(); + if (test4(8.0,-2.0,3.0) != 4.0) + abort(); + if (test4(8.0,-2.0,-3.0) != -4.0) + abort(); + if (test4(-8.0,2.0,3.0) != 4.0) + abort(); + if (test4(-8.0,2.0,-3.0) != -4.0) + abort(); + if (test4(-8.0,-2.0,3.0) != 4.0) + abort(); + if (test4(-8.0,-2.0,-3.0) != -4.0) + abort(); + + if (test4f(8.0f,2.0f,3.0f) != 4.0f) + abort(); + if (test4f(8.0f,2.0f,-3.0f) != -4.0f) + abort(); + if (test4f(8.0f,-2.0f,3.0f) != 4.0f) + abort(); + if (test4f(8.0f,-2.0f,-3.0f) != -4.0f) + abort(); + if (test4f(-8.0f,2.0f,3.0f) != 4.0f) + abort(); + if (test4f(-8.0f,2.0f,-3.0f) != -4.0f) + abort(); + if (test4f(-8.0f,-2.0f,3.0f) != 4.0f) + abort(); + if (test4f(-8.0f,-2.0f,-3.0f) != -4.0f) + abort(); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-51.c b/SingleSource/Regression/C/gcc-dg/builtins-51.c new file mode 100644 index 0000000000..fdfc9bec7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-51.c @@ -0,0 +1,157 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double pow(double, double); +extern double fabs(double); +extern void abort(void); + +double test2_1(double x) +{ + return pow(x,2.0); +} + +double test2_2(double x) +{ + return pow(-x,2.0); +} + +double test2_3(double x) +{ + return pow(fabs(x),2.0); +} + +double test3_1(double x) +{ + return pow(x,3.0); +} + +double test3_2(double x) +{ + return pow(-x,3.0); +} + +double test3_3(double x) +{ + return pow(fabs(x),3.0); +} + +double test6_1(double x) +{ + return pow(x,6.0); +} + +double test6_2(double x) +{ + return pow(-x,6.0); +} + +double test6_3(double x) +{ + return pow(fabs(x),6.0); +} + + +int main() +{ + if (test2_1(1.0) != 1.0) + abort(); + if (test2_1(2.0) != 4.0) + abort(); + if (test2_1(0.0) != 0.0) + abort(); + if (test2_1(-1.0) != 1.0) + abort(); + if (test2_1(-2.0) != 4.0) + abort(); + + if (test2_2(1.0) != 1.0) + abort(); + if (test2_2(2.0) != 4.0) + abort(); + if (test2_2(0.0) != 0.0) + abort(); + if (test2_2(-1.0) != 1.0) + abort(); + if (test2_2(-2.0) != 4.0) + abort(); + + if (test2_3(1.0) != 1.0) + abort(); + if (test2_3(2.0) != 4.0) + abort(); + if (test2_3(0.0) != 0.0) + abort(); + if (test2_3(-1.0) != 1.0) + abort(); + if (test2_3(2.0) != 4.0) + abort(); + + if (test3_1(1.0) != 1.0) + abort(); + if (test3_1(2.0) != 8.0) + abort(); + if (test3_1(0.0) != 0.0) + abort(); + if (test3_1(-1.0) != -1.0) + abort(); + if (test3_1(-2.0) != -8.0) + abort(); + + if (test3_2(1.0) != -1.0) + abort(); + if (test3_2(2.0) != -8.0) + abort(); + if (test3_2(0.0) != -0.0) + abort(); + if (test3_2(-1.0) != 1.0) + abort(); + if (test3_2(-2.0) != 8.0) + abort(); + + if (test3_3(1.0) != 1.0) + abort(); + if (test3_3(2.0) != 8.0) + abort(); + if (test3_3(0.0) != 0.0) + abort(); + if (test3_3(-1.0) != 1.0) + abort(); + if (test3_3(-2.0) != 8.0) + abort(); + + if (test6_1(1.0) != 1.0) + abort(); + if (test6_1(2.0) != 64.0) + abort(); + if (test6_1(0.0) != 0.0) + abort(); + if (test6_1(-1.0) != 1.0) + abort(); + if (test6_1(-2.0) != 64.0) + abort(); + + if (test6_2(1.0) != 1.0) + abort(); + if (test6_2(2.0) != 64.0) + abort(); + if (test6_2(0.0) != 0.0) + abort(); + if (test6_2(-1.0) != 1.0) + abort(); + if (test6_2(-2.0) != 64.0) + abort(); + + if (test6_3(1.0) != 1.0) + abort(); + if (test6_3(2.0) != 64.0) + abort(); + if (test6_3(0.0) != 0.0) + abort(); + if (test6_3(-1.0) != 1.0) + abort(); + if (test6_3(-2.0) != 64.0) + abort(); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-52.c b/SingleSource/Regression/C/gcc-dg/builtins-52.c new file mode 100644 index 0000000000..1cff017ad9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-52.c @@ -0,0 +1,23 @@ +/* { dg-do link } */ +/* { dg-options "-O -ffast-math" } */ + +extern void link_error(void); + +void test(double x, int n) +{ + if (__builtin_powi(x,-1.0) != 1.0/x) + link_error (); + if (__builtin_powi(x,0.0) != 1.0) + link_error (); + if (__builtin_powi(x,1.0) != x) + link_error (); + if (__builtin_powi(1.0,n) != 1.0) + link_error (); +} + +int main() +{ + test(7.3, 2); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-53.c b/SingleSource/Regression/C/gcc-dg/builtins-53.c new file mode 100644 index 0000000000..e01908c26a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-53.c @@ -0,0 +1,121 @@ +/* Copyright (C) 2005 Free Software Foundation. + + Check that (long)floor, (long)floorf, (long)floorl, + (long long)floor, (long long)floorf, (long long)floorl, + (long)ceil, (long)ceilf, (long)ceill, + (long long)ceil, (long long)ceilf, (long long)ceill + built-in functions compile. + + Written by Uros Bizjak, 5th April 2005. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +#include "builtins-config.h" + +extern double floor(double); +extern double ceil(double); +extern double trunc(double); + +extern float floorf(float); +extern float ceilf(float); +extern float truncf(float); + +extern long double floorl(long double); +extern long double ceill(long double); +extern long double truncl(long double); + + +long int test1(double x) +{ + return floor(x); +} + +long long int test2(double x) +{ + return floor(x); +} + +long int test3(double x) +{ + return ceil(x); +} + +long long int test4(double x) +{ + return ceil(x); +} + +long int test5(double x) +{ + return trunc(x); +} + +long long int test6(double x) +{ + return trunc(x); +} + +#ifdef HAVE_C99_RUNTIME +long int test1f(float x) +{ + return floorf(x); +} + +long long int test2f(float x) +{ + return floorf(x); +} + +long int test3f(float x) +{ + return ceilf(x); +} + +long long int test4f(float x) +{ + return ceilf(x); +} +#endif + +long int test5f(float x) +{ + return truncf(x); +} + +long long int test6f(float x) +{ + return truncf(x); +} + +#ifdef HAVE_C99_RUNTIME +long int test1l(long double x) +{ + return floorl(x); +} + +long long int test2l(long double x) +{ + return floorl(x); +} + +long int test3l(long double x) +{ + return ceill(x); +} + +long long int test4l(long double x) +{ + return ceill(x); +} +#endif + +long int test5l(long double x) +{ + return truncl(x); +} + +long long int test6l(long double x) +{ + return truncl(x); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-54.c b/SingleSource/Regression/C/gcc-dg/builtins-54.c new file mode 100644 index 0000000000..2713a3b1d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-54.c @@ -0,0 +1,146 @@ +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +double fabs(double); +float fabsf(float); +long double fabsl(long double); +double cabs(__complex__ double); +float cabsf(__complex__ float); +long double cabsl(__complex__ long double); + +void link_error (void); + +void test(__complex__ double x, double a, double b) +{ + if (cabs(x) != cabs(-x)) + link_error(); + + if (cabs(x) != cabs(~x)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (a+a*1i)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (a*1i+a)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (-a+a*-1i)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (-a+-a*1i)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (-a-a*1i)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (a*-1i-a)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (-a*1i-a)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (a*-1i+-a)) + link_error(); + + if (fabs(a) * __builtin_sqrt(2) != cabs (-a*1i+-a)) + link_error(); + + if (fabs(a*b) * __builtin_sqrt(2) != cabs (a*b-(-b*a*1i))) + link_error(); + + if (fabs(a*b) * __builtin_sqrt(2) != cabs (a*b*1i-a*-b)) + link_error(); +} + +void testf(__complex__ float x, float a, float b) +{ + if (cabsf(x) != cabsf(-x)) + link_error(); + + if (cabsf(x) != cabsf(~x)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (a+a*1i)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (a*1i+a)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (-a+a*-1i)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (-a+-a*1i)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (-a-a*1i)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (a*-1i-a)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (-a*1i-a)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (a*-1i+-a)) + link_error(); + + if (fabsf(a) * __builtin_sqrtf(2) != cabsf (-a*1i+-a)) + link_error(); + + if (fabsf(a*b) * __builtin_sqrtf(2) != cabsf (a*b-(-b*a*1i))) + link_error(); + + if (fabsf(a*b) * __builtin_sqrtf(2) != cabsf (a*b*1i-a*-b)) + link_error(); +} + +void testl(__complex__ long double x, long double a, long double b) +{ + if (cabsl(x) != cabsl(-x)) + link_error(); + + if (cabsl(x) != cabsl(~x)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (a+a*1i)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (a*1i+a)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (-a+a*-1i)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (-a+-a*1i)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (-a-a*1i)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (a*-1i-a)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (-a*1i-a)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (a*-1i+-a)) + link_error(); + + if (fabsl(a) * __builtin_sqrtl(2) != cabsl (-a*1i+-a)) + link_error(); + + if (fabsl(a*b) * __builtin_sqrtl(2) != cabsl (a*b-(-b*a*1i))) + link_error(); + + if (fabsl(a*b) * __builtin_sqrtl(2) != cabsl (a*b*1i-a*-b)) + link_error(); +} + +int main() +{ + test(0, 0, 0); + testf(0, 0, 0); + testl(0, 0, 0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-55.c b/SingleSource/Regression/C/gcc-dg/builtins-55.c new file mode 100644 index 0000000000..76786fb6b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-55.c @@ -0,0 +1,85 @@ +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +#include "builtins-config.h" + +void link_error (void); + +extern long lround(double); +extern long lrint(double); + +extern long long llround(double); +extern long long llrint(double); + +extern long lroundf(float); +extern long lrintf(float); + +extern long long llroundf(float); +extern long long llrintf(float); + +extern long lroundl(long double); +extern long lrintl(long double); + +extern long long llroundl(long double); +extern long long llrintl(long double); + + +void test(double x) +{ +#ifdef HAVE_C99_RUNTIME + if (sizeof(long) != sizeof(long long)) + return; + + if (__builtin_lceil(x) != __builtin_llceil(x)) + link_error(); + if (__builtin_lfloor(x) != __builtin_llfloor(x)) + link_error(); + if (lround(x) != llround(x)) + link_error(); + if (lrint(x) != llrint(x)) + link_error(); +#endif +} + +void testf(float x) +{ +#ifdef HAVE_C99_RUNTIME + if (sizeof(long) != sizeof(long long)) + return; + + if (__builtin_lceilf(x) != __builtin_llceilf(x)) + link_error(); + if (__builtin_lfloorf(x) != __builtin_llfloorf(x)) + link_error(); + if (lroundf(x) != llroundf(x)) + link_error(); + if (lrintf(x) != llrintf(x)) + link_error(); +#endif +} + +void testl(long double x) +{ +#ifdef HAVE_C99_RUNTIME + if (sizeof(long) != sizeof(long long)) + return; + + if (__builtin_lceill(x) != __builtin_llceill(x)) + link_error(); + if (__builtin_lfloorl(x) != __builtin_llfloorl(x)) + link_error(); + if (lroundl(x) != llroundl(x)) + link_error(); + if (lrintl(x) != llrintl(x)) + link_error(); +#endif +} + +int main() +{ + test(0.0); + testf(0.0); + testl(0.0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-57.c b/SingleSource/Regression/C/gcc-dg/builtins-57.c new file mode 100644 index 0000000000..18d40e8f7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-57.c @@ -0,0 +1,25 @@ +/* { dg-do link } */ +/* { dg-options "-std=c99 -ffinite-math-only -O" } */ + +#include "builtins-config.h" + +extern void link_error (void); + +extern double floor (double); +extern double trunc (double); +extern double fabs (double); + +void test (double x) +{ +#ifdef HAVE_C99_RUNTIME + if (floor (fabs (x)) != trunc (fabs (x))) + link_error (); +#endif + if (__builtin_lfloor (fabs (x)) != (long)fabs (x)) + link_error (); +} + +int main (void) +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-58.c b/SingleSource/Regression/C/gcc-dg/builtins-58.c new file mode 100644 index 0000000000..262f162cf5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-58.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -std=c99 -fno-ident" } */ + +#include "builtins-config.h" + +#ifdef HAVE_C99_RUNTIME +double test1 (double x) +{ + return __builtin_pow (x, 1./3.); +} + +double test2 (double x) +{ + return __builtin_pow (x, 4./3.); +} + +double test3a (double x) +{ + return __builtin_pow (x, 5./3.); +} + +double test3b (double x) +{ + return __builtin_pow (x, -5./3.); +} + +double test4 (double x) +{ + return __builtin_pow (x, 7./3.); +} +#endif + +/* { dg-final { scan-assembler-not {pow\M} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-59.c b/SingleSource/Regression/C/gcc-dg/builtins-59.c new file mode 100644 index 0000000000..c9b685c83e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-59.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ +/* { dg-require-effective-target c99_runtime } */ +/* { dg-require-effective-target libc_has_complex_functions } */ + +double test (double x) +{ + double s, c; + __builtin_sincos (x, &s, &c); + return s + c; +} + +/* { dg-final { scan-tree-dump "__builtin_cexpi" "gimple" } } */ +/* { dg-final { scan-tree-dump-not "sincos" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-6.c b/SingleSource/Regression/C/gcc-dg/builtins-6.c new file mode 100644 index 0000000000..2ebb0b2d86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-6.c @@ -0,0 +1,80 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Verify that constant folding comparisons against built-in math functions + don't cause any problems for the compiler, and produce expected results. + + Written by Roger Sayle, 15th March 2003. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +#include + +extern void abort (void); +extern double sqrt (double); + +int test1(double x) +{ + return sqrt(x) < -9.0; +} + +int test2(double x) +{ + return sqrt(x) > -9.0; +} + +int test3(double x) +{ + return sqrt(x) < 9.0; +} + +int test4(double x) +{ + return sqrt(x) > 9.0; +} + +int test5(double x) +{ + return sqrt(x) < DBL_MAX; +} + +int test6(double x) +{ + return sqrt(x) > DBL_MAX; +} + +int main() +{ + double x; + + x = 80.0; + if (test1 (x)) + abort (); + if (! test2 (x)) + abort (); + if (! test3 (x)) + abort (); + if (test4 (x)) + abort (); + if (! test5 (x)) + abort (); + if (test6 (x)) + abort (); + + x = 100.0; + if (test1 (x)) + abort (); + if (! test2 (x)) + abort (); + if (test3 (x)) + abort (); + if (! test4 (x)) + abort (); + if (! test5 (x)) + abort (); + if (test6 (x)) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-60.c b/SingleSource/Regression/C/gcc-dg/builtins-60.c new file mode 100644 index 0000000000..72684197bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-60.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +double test1 (double x) +{ + return __real __builtin_cexpi (x); +} + +double test2 (double x) +{ + return __imag __builtin_cexpi (x); +} + +/* { dg-final { scan-tree-dump "cos" "gimple" } } */ +/* { dg-final { scan-tree-dump "sin" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-61.c b/SingleSource/Regression/C/gcc-dg/builtins-61.c new file mode 100644 index 0000000000..d7813409a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-61.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -fdump-tree-optimized" } */ +/* { dg-require-effective-target c99_runtime } */ +/* { dg-require-effective-target libc_has_complex_functions } */ + +double test1 (double x) +{ + return __real __builtin_cexp(x * (__extension__ 1.0iF)); +} + +double test2(double x) +{ + return __imag __builtin_cexp((__extension__ 1.0iF) * x); +} + +double test3(double x) +{ + _Complex c = __builtin_cexp(x * (__extension__ 1.0iF)); + return __imag c + __real c; +} + +double test4(double x, double y) +{ + _Complex c = __builtin_cexp(x); + x = __builtin_exp (x); + return x - __real c; +} + +/* { dg-final { scan-tree-dump "cexpi" "optimized" } } */ +/* { dg-final { scan-tree-dump "sin" "optimized" } } */ +/* { dg-final { scan-tree-dump "cos" "optimized" } } */ +/* { dg-final { scan-tree-dump "return 0.0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-62.c b/SingleSource/Regression/C/gcc-dg/builtins-62.c new file mode 100644 index 0000000000..e0420cea68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-62.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffinite-math-only -fdump-tree-optimized" } */ +/* { dg-require-effective-target c99_runtime } */ + +double test1 (double x) +{ + double s, c; + s = __builtin_sin (x); + c = __builtin_cos (x); + return s + c; +} + +double test2 (double x) +{ + double s, c; + x = x * 2; + s = __builtin_sin (x); + c = __builtin_cos (x); + return s + c; +} + +double test3 (double x, int b) +{ + double s, c; + if (b) + x = x * 2; + s = __builtin_sin (x); + c = __builtin_cos (x); + return s + c; +} + +double test4 (double x) +{ + double s; + x = x * 2; + s = __builtin_sin (x); + return s; +} + +/* { dg-final { scan-tree-dump-times "cexpi" 3 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-63.c b/SingleSource/Regression/C/gcc-dg/builtins-63.c new file mode 100644 index 0000000000..8fcbc68e6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-63.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2007 Free Software Foundation. + + Check that isinf, isinff and isinfl built-in functions compile. + + Written by Uros Bizjak, 31st January 2007. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int isinf(double); +extern int isinff(float); +extern int isinfl(long double); + +int test1(double x) +{ + return isinf(x); +} + +int test1f(float x) +{ + return isinff(x); +} + +int test1l(long double x) +{ + return isinfl(x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-64.c b/SingleSource/Regression/C/gcc-dg/builtins-64.c new file mode 100644 index 0000000000..3c04c44a67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-64.c @@ -0,0 +1,9 @@ +/* { dg-do run } */ +/* { dg-require-effective-target alloca } */ + +int main () +{ + char *mem = __builtin_alloca (40); + __builtin___clear_cache (mem, mem + 40); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-65.c b/SingleSource/Regression/C/gcc-dg/builtins-65.c new file mode 100644 index 0000000000..91930c9588 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-65.c @@ -0,0 +1,40 @@ +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ +/* { dg-require-effective-target c99_runtime } */ + +extern int ilogbf (float); +extern float logbf (float); +extern int ilogb (double); +extern double logb (double); +extern int ilogbl (long double); +extern long double logbl (long double); + +extern void link_error(void); + +void testf(float x) +{ + if ((int) logbf (x) != ilogbf (x)) + link_error (); +} + +void test(double x) +{ + if ((int) logb (x) != ilogb (x)) + link_error (); +} + +void testl(long double x) +{ + if ((int) logbl (x) != ilogbl (x)) + link_error (); +} + +int main() +{ + testf (2.0f); + test (2.0); + testl (2.0l); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-66.c b/SingleSource/Regression/C/gcc-dg/builtins-66.c new file mode 100644 index 0000000000..87bea3f420 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-66.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +enum { E0 = 0, E1 = 1, E2 = 2 } e; + +int +foo (void) +{ + return __builtin_popcount ((int) e); +} + +/* { dg-final { scan-assembler-not "__builtin_popcount" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-67.c b/SingleSource/Regression/C/gcc-dg/builtins-67.c new file mode 100644 index 0000000000..36b7886b16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-67.c @@ -0,0 +1,74 @@ +/* Check that conversion functions link correctly with -ffast-math. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math -lm" } */ +/* Bionic doesn't have rintl */ +/* { dg-require-effective-target non_bionic } */ + +#include "builtins-config.h" + +double floor (double); +float floorf (float); +long double floorl (long double); + +double ceil (double); +float ceilf (float); +long double ceill (long double); + +double round (double); +float roundf (float); +long double roundl (long double); + +double rint (double); +float rintf (float); +long double rintl (long double); + +int ifloor (double a) { return (int) floor (a); } +#ifdef HAVE_C99_RUNTIME +int ifloorf (float a) { return (int) floorf (a); } +int ifloorl (long double a) { return (int) floorl (a); } +#endif + +long lfloor (double a) { return (long) floor (a); } +#ifdef HAVE_C99_RUNTIME +long lfloorf (float a) { return (long) floorf (a); } +long lfloorl (long double a) { return (long) floorl (a); } +#endif + +long long llfloor (double a) { return (long long) floor (a); } +#ifdef HAVE_C99_RUNTIME +long long llfloorf (float a) { return (long long) floorf (a); } +long long llfloorl (long double a) { return (long long) floorl (a); } +#endif + +int iceil (double a) { return (int) ceil (a); } +#ifdef HAVE_C99_RUNTIME +int iceilf (float a) { return (int) ceilf (a); } +int iceill (long double a) { return (int) ceill (a); } +#endif + +long lceil (double a) { return (long) ceil (a); } +#ifdef HAVE_C99_RUNTIME +long lceilf (float a) { return (long) ceilf (a); } +long lceill (long double a) { return (long) ceill (a); } +#endif + +long long llceil (double a) { return (long long) ceil (a); } +#ifdef HAVE_C99_RUNTIME +long long llceilf (float a) { return (long long) ceilf (a); } +long long llceill (long double a) { return (long long) ceill (a); } +#endif + +#ifdef HAVE_C99_RUNTIME +int iround (double a) { return (int) round (a); } +int iroundf (float a) { return (int) roundf (a); } +int iroundl (long double a) { return (int) roundl (a); } +#endif + +#ifdef HAVE_C99_RUNTIME +int irint (double a) { return (int) rint (a); } +int irintf (float a) { return (int) rintf (a); } +int irintl (long double a) { return (int) rintl (a); } +#endif + +int main () { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/builtins-68.c b/SingleSource/Regression/C/gcc-dg/builtins-68.c new file mode 100644 index 0000000000..1247394e4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-68.c @@ -0,0 +1,114 @@ +/* PR middle-end/69780 - [4.9/5/6 Regression] ICE on + __builtin_alloca_with_align with small alignment */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Wno-long-long" } */ + +#define CHAR_BIT __CHAR_BIT__ +#define SIZE_MAX __SIZE_MAX__ +#define UINT_MAX (__INT_MAX__ + 1U) + +/* The largest valid alignment is undocumented and subject to change + but for the purposes of white box testing we rely on knowing that + it happens to be defined to (UINT_MAX >> 1) + 1. */ +#define ALIGN_MAX ((UINT_MAX >> 1) + 1) + +#if UINT_MAX < SIZE_MAX +/* Define a constant to exercise an alignment that is valid a power + of 2 in excess of the maximum. */ +# define MAX_X_2 (ALIGN_MAX << 1) +#else +/* For targets where UINT_MAX is the same as SIZE_MAX, use an invalid + alignment that's less than the maximum to elicit the same errors. */ +# define MAX_X_2 (ALIGN_MAX + 1) +#endif + +static void* p; + +/* Verify that valid __builtin_alloca_with_align expressions are accepted. */ +void test_valid (int n) +{ + enum { + A1 = CHAR_BIT * 1, + A2 = CHAR_BIT * 2, + A4 = CHAR_BIT * 4, + A8 = CHAR_BIT * 8, + A16 = CHAR_BIT * 16, + A32 = CHAR_BIT * 32 + }; + + /* Valid alignments are power of 2 positive multiples of CHAR_BIT. */ + p = __builtin_alloca_with_align (n, CHAR_BIT * 1); + p = __builtin_alloca_with_align (n, CHAR_BIT * 2); + p = __builtin_alloca_with_align (n, CHAR_BIT * 4); + p = __builtin_alloca_with_align (n, CHAR_BIT * 8); + p = __builtin_alloca_with_align (n, CHAR_BIT * 16); + p = __builtin_alloca_with_align (n, CHAR_BIT * 32); + + p = __builtin_alloca_with_align (n, A1); + p = __builtin_alloca_with_align (n, A2); + p = __builtin_alloca_with_align (n, A4); + p = __builtin_alloca_with_align (n, A8); + p = __builtin_alloca_with_align (n, A16); + p = __builtin_alloca_with_align (n, A32); +} + +/* Non-integer alignments must be rejected. */ +void test_arg2_non_int (int n) +{ + /* Verify the full text of the diagnostic just once. */ + p = __builtin_alloca_with_align (n, 0.0); /* { dg-error "second argument to function .__builtin_alloca_with_align. must be a constant integer power of 2 between .8. and " } */ + + /* Disable diagnostic complaining about converting void* to int that + preempts the "constant integer expression" error. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wint-conversion" + + p = __builtin_alloca_with_align (n, (void*)0); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, ""); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, L""); /* { dg-error "must be a constant integer" } */ + +#pragma GCC diagnostic pop + +} + +/* Integer alignment that's not a constant expression must be rejected. */ +void test_arg2_non_const (int n, int a1) +{ + extern const int a2; + static const int a3 = CHAR_BIT; + static volatile const int a4 = CHAR_BIT; + + p = __builtin_alloca_with_align (n, a1); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, a2); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, a3); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, a4); /* { dg-error "must be a constant integer" } */ +} + +/* Constant integer alignment that's not a power of 2 positive multiple + of CHAR_BIT less than (1LLU << 32) must be rejected. */ +void test_arg2_non_pow2 (int n) +{ + p = __builtin_alloca_with_align (n, 0); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 1); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 2); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 3); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 4); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 5); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 6); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 7); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 9); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 10); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 11); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 12); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 13); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 14); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 15); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 17); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 31); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 33); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 63); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, 65); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, SIZE_MAX); /* { dg-error "must be a constant integer" } */ + p = __builtin_alloca_with_align (n, MAX_X_2); /* { dg-error "must be a constant integer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-69.c b/SingleSource/Regression/C/gcc-dg/builtins-69.c new file mode 100644 index 0000000000..b754b5d26e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-69.c @@ -0,0 +1,22 @@ +/* PR middle-end/86308 - ICE in verify_gimple calling index() with + an invalid declaration + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +int index (int, int); /* { dg-warning "conflicting types for built-in function .index.; expected .char \\\*\\\(const char \\\*, int\\\)." } */ + +int test_index (void) +{ + return index (0, 0); +} + + +/* PR middle-end/86202 - ICE in get_range_info calling an invalid memcpy() + declaration */ + +void *memcpy (void *, void *, __SIZE_TYPE__ *); /* { dg-warning "conflicting types for built-in function .memcpy.; expected .void \\\*\\\(void \\\*, const void \\\*, \(long \)*unsigned int\\\)." } */ + +void test_memcpy (void *p, void *q, __SIZE_TYPE__ *r) +{ + memcpy (p, q, r); +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-7.c b/SingleSource/Regression/C/gcc-dg/builtins-7.c new file mode 100644 index 0000000000..13e708e299 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-7.c @@ -0,0 +1,55 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Verify that built-in math function constant folding of constant + arguments is correctly performed by the by the compiler. + + Written by Roger Sayle, 30th March 2003. */ + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double pow (double, double); +extern float powf (float, float); +extern long double powl (long double, long double); +extern double tan (double); +extern float tanf (float); +extern long double tanl (long double); +extern double atan (double); +extern float atanf (float); +extern long double atanl (long double); + +extern void link_error(void); + +void test(double x) +{ + if (pow (x, 1.0) != x) + link_error (); + if (tan (atan (x)) != x) + link_error (); +} + +void testf(float x) +{ + if (powf (x, 1.0f) != x) + link_error (); + if (tanf (atanf (x)) != x) + link_error (); +} + +void testl(long double x) +{ + if (powl (x, 1.0l) != x) + link_error (); + if (tanl (atanl (x)) != x) + link_error (); +} + +int main() +{ + test (2.0); + testf (2.0f); + testl (2.0l); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-70.c b/SingleSource/Regression/C/gcc-dg/builtins-70.c new file mode 100644 index 0000000000..a0c2dc9e9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-70.c @@ -0,0 +1,46 @@ +/* Copyright (C) 2021 Free Software Foundation. + + Check that constant folding of built-in fmod functions doesn't + break anything and produces the expected results. + +/* { dg-do link } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void link_error(void); + +extern double fmod(double,double); +extern float fmodf(float,float); +extern long double fmodl(long double,long double); + +int main() +{ + if (fmod (6.5, 2.3) < 1.8999 || fmod (6.5, 2.3) > 1.9001) + link_error (); + if (fmod (-6.5, 2.3) < -1.9001 || fmod (-6.5, 2.3) > -1.8999) + link_error (); + if (fmod (6.5, -2.3) < 1.8999 || fmod (6.5, -2.3) > 1.9001) + link_error (); + if (fmod (-6.5, -2.3) < -1.9001 || fmod (-6.5, -2.3) > -1.8999) + link_error (); + + if (fmodf (6.5f, 2.3f) < 1.8999f || fmodf (6.5f, 2.3f) > 1.9001f) + link_error (); + if (fmodf (-6.5f, 2.3f) < -1.9001f || fmodf (-6.5f, 2.3f) > -1.8999f) + link_error (); + if (fmodf (6.5f, -2.3f) < 1.8999f || fmodf (6.5f, -2.3f) > 1.9001f) + link_error (); + if (fmodf (-6.5f, -2.3f) < -1.9001f || fmodf (-6.5f, -2.3f) > -1.8999f) + link_error (); + + if (fmodl (6.5l, 2.3l) < 1.8999l || fmod (6.5l, 2.3l) > 1.9001l) + link_error (); + if (fmodl (-6.5l, 2.3l) < -1.9001l || fmod (-6.5l, 2.3l) > -1.8999l) + link_error (); + if (fmodl (6.5l, -2.3l) < 1.8999l || fmod (6.5l, -2.3l) > 1.9001l) + link_error (); + if (fmodl (-6.5l, -2.3l) < -1.9001l || fmod (-6.5l, -2.3l) > -1.8999l) + link_error (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-8.c b/SingleSource/Regression/C/gcc-dg/builtins-8.c new file mode 100644 index 0000000000..95c17e72f2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-8.c @@ -0,0 +1,42 @@ +/* Copyright (C) 2003, 2006 Free Software Foundation. + + Verify that built-in math function constant folding of functions + with one constant argument is correctly performed by the compiler. + + Written by Roger Sayle, 30th March 2003. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void abort(void); +extern double pow(double, double); +extern double sqrt(double); +extern double cbrt(double); + +void test(double x) +{ + if (pow(x,-1.0) != 1.0/x) + abort (); + + if (pow(x,2.0) != x*x) + abort (); + + if (pow(x,-2.0) != 1.0/(x*x)) + abort (); + + if (pow(x,0.5) != sqrt(x)) + abort (); + +#ifdef HAVE_C99_RUNTIME + if (pow(x,1.0/3.0) != cbrt(x)) + abort (); +#endif +} + +int main() +{ + test (1.0); + test (2.0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-85.c b/SingleSource/Regression/C/gcc-dg/builtins-85.c new file mode 100644 index 0000000000..0993fbc19f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-85.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; +extern void __chk_fail (void); +extern int snprintf (char *, size_t, const char *, ...); +extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...) +{ + if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b) + __chk_fail (); + return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ()); +} +extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf"); + +char buf[10]; + +int +main (void) +{ + snprintf (buf, 10, "%d%d\n", 10, 10); + return 0; +} + +/* { dg-final { scan-assembler "mysnprintf" } } */ +/* { dg-final { scan-assembler-not "__chk_fail" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/builtins-9.c b/SingleSource/Regression/C/gcc-dg/builtins-9.c new file mode 100644 index 0000000000..108e0d2f11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-9.c @@ -0,0 +1,103 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Check that constant folding of built-in math functions doesn't + break anything. + + Written by Roger Sayle, 2nd April 2003. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double log(double); +extern double exp(double); +extern double sqrt(double); +extern double pow(double,double); + +extern float logf(float); +extern float expf(float); +extern float sqrtf(float); +extern float powf(float,float); + +extern long double logl(long double); +extern long double expl(long double); +extern long double sqrtl(long double); +extern long double powl(long double,long double); + + +double test1(double x, double y) +{ + return log(pow(x,y)); +} + +double test2(double x, double y) +{ + return sqrt(pow(x,y)); +} + +double test3(double x, double y) +{ + return pow(exp(x),y); +} + +double test4(double x, double y) +{ + return pow(sqrt(x),y); +} + +double test5(double x, double y, double z) +{ + return pow(pow(x,y),z); +} + + +float test1f(float x, float y) +{ + return logf(powf(x,y)); +} + +float test2f(float x, float y) +{ + return sqrtf(powf(x,y)); +} + +float test3f(float x, float y) +{ + return powf(expf(x),y); +} + +float test4f(float x, float y) +{ + return powf(sqrtf(x),y); +} + +float test5f(float x, float y, float z) +{ + return powf(powf(x,y),z); +} + + +long double test1l(long double x, long double y) +{ + return logl(powl(x,y)); +} + +long double test2l(long double x, long double y) +{ + return sqrtl(powl(x,y)); +} + +long double test3l(long double x, long double y) +{ + return powl(expl(x),y); +} + +long double test4l(long double x, long double y) +{ + return powl(sqrtl(x),y); +} + +long double test5l(long double x, long double y, long double z) +{ + return powl(powl(x,y),z); +} + diff --git a/SingleSource/Regression/C/gcc-dg/builtins-config.h b/SingleSource/Regression/C/gcc-dg/builtins-config.h new file mode 100644 index 0000000000..5e27c1deb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-config.h @@ -0,0 +1,62 @@ +/* Copyright (C) 2003, 2004, 2005, 2006, 2009, 2011, 2012, 2019 + Free Software Foundation. + + Define macros useful in tests for bulitin functions. */ + +/* Define HAVE_C99_RUNTIME if the entire C99 runtime is available on + the target system. The value of HAVE_C99_RUNTIME should be the + same as the value of TARGET_C99_FUNCTIONS in the GCC machine + description. (Perhaps GCC should predefine a special macro + indicating whether or not TARGET_C99_FUNCTIONS is set, but it does + not presently do that.) */ + +#if defined(__hppa) && defined(__hpux) +/* PA HP-UX doesn't have the entire C99 runtime. */ +#elif defined(__INTERIX) +/* Interix6 doesn't have the entire C99 runtime. */ +#elif defined(__AVR__) +/* AVR doesn't have the entire C99 runtime. */ +#elif defined(__FreeBSD__) && (__FreeBSD__ < 9) +/* FreeBSD up to version 8 lacks support for cexp and friends. */ +#elif defined(__vxworks) +/* VxWorks doesn't have a full C99 time. (cabs is missing, for example.) */ +#elif defined (__BPF__) +/* No chance for eBPF to support C99 functions. */ +#elif defined(_WIN32) && !defined(__CYGWIN__) +/* Windows doesn't have the entire C99 runtime. */ +#elif (defined(__APPLE__) && defined(__ppc__) \ + && ! defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)) +/* MacOS versions before 10.3 don't have many C99 functions. + But, if you're including this file, you probably want to test the + newer behavior, so: */ +#error forgot to set -mmacosx-version-min. +#elif (defined(__APPLE__) && defined(__ppc__) \ + && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1030) +/* MacOS versions before 10.3 don't have many C99 functions. */ +#else +/* Newlib has the "f" variants of the math functions, but not the "l" + variants. TARGET_C99_FUNCTIONS is only defined if all C99 + functions are present. Therefore, on systems using newlib, tests + of builtins will fail the "l" variants, and we should therefore not + define HAVE_C99_RUNTIME. Including gives us a way of + seeing if _NEWLIB_VERSION is defined. Including would work + too, but the GLIBC math inlines cause us to generate inferior code, + which causes the test to fail, so it is not safe. Including + also fails because the include search paths are ordered such that GCC's + version will be found before the newlib version. Similarly, uClibc + lacks the C99 functions. */ +#include +#if defined(_NEWLIB_VERSION) || defined(__UCLIBC__) +#elif defined(__sun) && __STDC_VERSION__ - 0 < 199901L +/* If you're including this file, you probably want to test the newer + behavior, so ensure the right flags were used for each test: */ +#error forgot to set -std=c99. +#elif defined(__sun) && ! defined (_STDC_C99) +/* Solaris up to 9 doesn't have the entire C99 runtime. + Solaris 10 defines _STDC_C99 if __STDC_VERSION__ is >= 199901L. + This macro is defined in which is included by + various system headers, in this case above. */ +#else +#define HAVE_C99_RUNTIME +#endif +#endif diff --git a/SingleSource/Regression/C/gcc-dg/builtins-error.c b/SingleSource/Regression/C/gcc-dg/builtins-error.c new file mode 100644 index 0000000000..945d239d60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-error.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ + +struct X { int x; }; + +int test1(struct X x) +{ + if (x.x == 1) return __builtin_fpclassify(1,2,3,4,5,x); /* { dg-error "non-floating-point argument" } */ + if (x.x == 2) return __builtin_isfinite(x); /* { dg-error "non-floating-point argument" } */ + if (x.x == 3) return __builtin_isinf_sign(x); /* { dg-error "non-floating-point argument" } */ + if (x.x == 4) return __builtin_isinf(x); /* { dg-error "non-floating-point argument" } */ + if (x.x == 5) return __builtin_isnan(x); /* { dg-error "non-floating-point argument" } */ + if (x.x == 6) return __builtin_isnormal(x); /* { dg-error "non-floating-point argument" } */ + if (x.x == 7) return __builtin_isgreater(x, x); /* { dg-error "non-floating-point arguments" } */ + if (x.x == 8) return __builtin_isgreaterequal(x, x); /* { dg-error "non-floating-point arguments" } */ + if (x.x == 9) return __builtin_isless(x, x); /* { dg-error "non-floating-point arguments" } */ + if (x.x == 10) return __builtin_islessequal(x, x); /* { dg-error "non-floating-point arguments" } */ + if (x.x == 11) return __builtin_islessgreater(x, x); /* { dg-error "non-floating-point arguments" } */ + if (x.x == 12) return __builtin_isunordered(x, x); /* { dg-error "non-floating-point arguments" } */ + if (x.x == 13) return __builtin_signbit(x); /* { dg-error "non-floating-point argument" } */ + + return 0; +} + +int test2(double x) +{ + if (x == 1) return __builtin_fpclassify(1,2,3,4,5); /* { dg-error "too few arguments" } */ + if (x == 2) return __builtin_isfinite(); /* { dg-error "too few arguments" } */ + if (x == 3) return __builtin_isinf_sign(); /* { dg-error "too few arguments" } */ + if (x == 4) return __builtin_isinf(); /* { dg-error "too few arguments" } */ + if (x == 5) return __builtin_isnan(); /* { dg-error "too few arguments" } */ + if (x == 6) return __builtin_isnormal(); /* { dg-error "too few arguments" } */ + if (x == 7) return __builtin_isgreater(x); /* { dg-error "too few arguments" } */ + if (x == 8) return __builtin_isgreaterequal(x); /* { dg-error "too few arguments" } */ + if (x == 9) return __builtin_isless(x); /* { dg-error "too few arguments" } */ + if (x == 10) return __builtin_islessequal(x); /* { dg-error "too few arguments" } */ + if (x == 11) return __builtin_islessgreater(x); /* { dg-error "too few arguments" } */ + if (x == 12) return __builtin_isunordered(x); /* { dg-error "too few arguments" } */ + if (x == 13) return __builtin_signbit(); /* { dg-error "too few arguments" } */ + return 0; +} + +int test3(double x) +{ + if (x == 1) return __builtin_fpclassify(1,2,3,4,5,x,x); /* { dg-error "too many arguments" } */ + if (x == 2) return __builtin_isfinite(x, x); /* { dg-error "too many arguments" } */ + if (x == 3) return __builtin_isinf_sign(x, x); /* { dg-error "too many arguments" } */ + if (x == 4) return __builtin_isinf(x, x); /* { dg-error "too many arguments" } */ + if (x == 5) return __builtin_isnan(x, x); /* { dg-error "too many arguments" } */ + if (x == 6) return __builtin_isnormal(x, x); /* { dg-error "too many arguments" } */ + if (x == 7) return __builtin_isgreater(x, x, x); /* { dg-error "too many arguments" } */ + if (x == 8) return __builtin_isgreaterequal(x, x, x); /* { dg-error "too many arguments" } */ + if (x == 9) return __builtin_isless(x, x, x); /* { dg-error "too many arguments" } */ + if (x == 10) return __builtin_islessequal(x, x, x); /* { dg-error "too many arguments" } */ + if (x == 11) return __builtin_islessgreater(x, x, x); /* { dg-error "too many arguments" } */ + if (x == 12) return __builtin_isunordered(x, x, x); /* { dg-error "too many arguments" } */ + if (x == 13) return __builtin_signbit(x, x); /* { dg-error "too many arguments" } */ + return 0; +} + +int test4(int i, double x) +{ + if (x == 1) return __builtin_fpclassify(i,2,3,4,5,x); /* { dg-error "non-const integer argument" } */ + if (x == 2) return __builtin_fpclassify(1,i,3,4,5,x); /* { dg-error "non-const integer argument" } */ + if (x == 3) return __builtin_fpclassify(1,2,i,4,5,x); /* { dg-error "non-const integer argument" } */ + if (x == 4) return __builtin_fpclassify(1,2,3,i,5,x); /* { dg-error "non-const integer argument" } */ + if (x == 5) return __builtin_fpclassify(1,2,3,4,i,x); /* { dg-error "non-const integer argument" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/builtins-nonnull.c b/SingleSource/Regression/C/gcc-dg/builtins-nonnull.c new file mode 100644 index 0000000000..f8c482e982 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/builtins-nonnull.c @@ -0,0 +1,240 @@ +/* PR c/17308 - nonnull attribute not as useful as it could be + PR c/78673 - sprintf missing attribute nonnull on destination argument + { dg-do "compile" } + { dg-additional-options "-O2 -Wnonnull -ftrack-macro-expansion=0 -std=c99" } */ + +#define va_list __builtin_va_list + +typedef struct FILE FILE; + +static char* null (void) +{ + return 0; +} + +void sink (int, ...); +#define T(arg) sink (0, arg) + + +#define bzero __builtin_bzero +#define memcpy __builtin_memcpy +#define memmove __builtin_memmove +#define mempcpy __builtin_mempcpy +#define memset __builtin_memset + +void test_memfuncs (void *s, unsigned n) +{ + /* Bzero is not declared attribute nonnull (maybe it should be?) + but it's transformed into a call to memset() which is. */ + bzero (null (), n); /* { dg-warning "argument 1 null where non-null expected" } */ + + T (memcpy (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (memcpy (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (memmove (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (memmove (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (mempcpy (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (mempcpy (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (memset (null (), 0, n)); /* { dg-warning "argument 1 null where non-null expected" } */ +} + +#undef memcpy +#undef memmove +#undef mempcpy +#undef memset +#define memcpy(d, s, n) __builtin___memcpy_chk (d, s, n, n) +#define memmove(d, s, n) __builtin___memmove_chk (d, s, n, n) +#define mempcpy(d, s, n) __builtin___mempcpy_chk (d, s, n, n) +#define memset(d, x, n) __builtin___memset_chk (d, x, n, n) + +void test_memfuncs_chk (void *s, unsigned n) +{ + T (memcpy (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (memcpy (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (memmove (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (memmove (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (mempcpy (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (mempcpy (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (memset (null (), 0, n)); /* { dg-warning "argument 1 null where non-null expected" } */ +} + + +#define strcat __builtin_strcat +#define strchr __builtin_strchr +#define stpcpy __builtin_stpcpy +#define stpncpy __builtin_stpncpy +#define strcpy __builtin_strcpy +#define strncpy __builtin_strncpy +#define strlen __builtin_strlen +#define strncat __builtin_strncat +#define strstr __builtin_strstr + +void test_strfuncs (char *s, unsigned n) +{ + T (strcat (null (), s)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (strcat (s, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (strchr (null (), 'x')); /* { dg-warning "argument 1 null where non-null expected" } */ + + T (stpcpy (null (), s)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (stpcpy (s, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (stpncpy (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (stpncpy (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (strcpy (null (), s)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (strcpy (s, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (strncpy (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (strncpy (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (strlen (null ())); /* { dg-warning "argument 1 null where non-null expected" } */ + + T (strncat (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + T (strncat (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + + T (strstr (null (), s)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (strstr (s, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ +} + + +#undef strcat +#undef stpcpy +#undef stpncpy +#undef strcpy +#undef strncpy +#undef strncat + +#define strcat(d, s) __builtin___strcat_chk (d, s, n) +#define stpcpy(d, s) __builtin___stpcpy_chk (d, s, n) +#define stpncpy(d, s, n) __builtin___stpncpy_chk (d, s, n, n) +#define strcpy(d, s) __builtin___strcpy_chk (d, s, n) +#define strncpy(d, s, n) __builtin___strncpy_chk (d, s, n, n) +#define strncat(d, s, n) __builtin___strncat_chk (d, s, n, n) + +void test_strfuncs_chk (char *s, unsigned n) +{ + T (strcat (null (), s)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (strcat (s, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (strchr (null (), 'x')); /* { dg-warning "argument 1 null where non-null expected" } */ + + T (stpcpy (null (), s)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (stpcpy (s, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (stpncpy (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (stpncpy (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (strcpy (null (), s)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (strcpy (s, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (strncpy (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (strncpy (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (strncat (s, null (), n)); /* { dg-warning "argument 2 null where non-null expected" } */ + T (strncat (null (), s, n)); /* { dg-warning "argument 1 null where non-null expected" } */ +} + + +#define fprintf __builtin_fprintf +#define fprintf_unlocked __builtin_fprintf_unlocked +#define vfprintf __builtin_vfprintf +#define printf __builtin_printf +#define printf_unlocked __builtin_printf_unlocked +#define vprintf __builtin_vprintf +#define sprintf __builtin_sprintf +#define snprintf __builtin_snprintf +#define vsprintf __builtin_vsprintf +#define vsnprintf __builtin_vsnprintf + +void test_stdio_funcs (FILE *f, char *d, unsigned n, va_list va) +{ + T (fprintf (null (), "%i", 0)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (fprintf (f, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (fprintf_unlocked (null (), "%i", 0)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (fprintf_unlocked (f, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (vfprintf (null (), "%i", va));/* { dg-warning "argument 1 null where non-null expected" } */ + T (vfprintf (f, null (), va)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (vprintf (null (), va)); /* { dg-warning "argument 1 null where non-null expected" } */ + + T (printf (null ())); /* { dg-warning "argument 1 null where non-null expected" } */ + T (printf_unlocked (null ())); /* { dg-warning "argument 1 null where non-null expected" } */ + + T (vprintf (null (), va)); /* { dg-warning "argument 1 null where non-null expected" } */ + + T (sprintf (null (), "%i", 0)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (sprintf (d, null ())); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (snprintf (null (), n, "%i", 0)); + T (snprintf (d, n, null ())); /* { dg-warning "argument 3 null where non-null expected" } */ + + T (vsprintf (null (), "%i", va)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (vsprintf (d, null (), va)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (vsnprintf (null (), n, "%i", va)); + T (vsnprintf (d, n, null (), va)); /* { dg-warning "argument 3 null where non-null expected" } */ +} + +#undef fprintf +#undef fprintf_unlocked +#undef vfprintf +#undef printf +#undef printf_unlocked +#undef vprintf +#undef sprintf +#undef snprintf +#undef vsprintf +#undef vsnprintf + +#define fprintf(f, fmt, ...) \ + __builtin___fprintf_chk (f, 0, fmt, __VA_ARGS__) +#define vfprintf(f, fmt, va) \ + __builtin___vfprintf_chk (f, 0, fmt, va) +#define printf(fmt, ...) \ + __builtin___printf_chk (0, fmt, __VA_ARGS__) +#define vprintf(fmt, va) \ + __builtin___vprintf_chk (0, fmt, va) +#define sprintf(d, fmt, ... ) \ + __builtin___sprintf_chk (d, 0, n, fmt, __VA_ARGS__) +#define snprintf(d, n, fmt, ...) \ + __builtin___snprintf_chk (d, n, 0, n, fmt, __VA_ARGS__) +#define vsprintf(d, fmt, va) \ + __builtin___vsprintf_chk (d, 0, n, fmt, va) +#define vsnprintf(d, n, fmt, va) \ + __builtin___vsnprintf_chk (d, n, 0, n, fmt, va) + +void test_stdio_funcs_chk (FILE *f, char *d, const char *fmt, + unsigned n, va_list va) +{ + T (fprintf (null (), "%i", 0)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (fprintf (f, null (), 0)); /* { dg-warning "argument 3 null where non-null expected" } */ + + T (vfprintf (null (), "%i", va));/* { dg-warning "argument 1 null where non-null expected" } */ + T (vfprintf (f, null (), va)); /* { dg-warning "argument 3 null where non-null expected" } */ + + T (vprintf (null (), va)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (printf (null (), 0)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (vprintf (null (), va)); /* { dg-warning "argument 2 null where non-null expected" } */ + + T (sprintf (null (), "%i", 0)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (sprintf (d, null (), 0)); /* { dg-warning "argument 4 null where non-null expected" } */ + + T (snprintf (null (), n, "%i", 0)); + T (snprintf (d, n, null (), 0)); /* { dg-warning "argument 5 null where non-null expected" } */ + + T (vsprintf (null (), "%i", va)); /* { dg-warning "argument 1 null where non-null expected" } */ + T (vsprintf (d, null (), va)); /* { dg-warning "argument 4 null where non-null expected" } */ + + T (vsnprintf (null (), n, "%i", va)); + T (vsnprintf (d, n, null (), va)); /* { dg-warning "argument 5 null where non-null expected" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-1.c b/SingleSource/Regression/C/gcc-dg/c11-align-1.c new file mode 100644 index 0000000000..e0058c3800 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-1.c @@ -0,0 +1,41 @@ +/* Test C11 alignment support. Test valid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +_Alignas (_Alignof (max_align_t)) char c; +extern _Alignas (max_align_t) char c; +extern char c; + +extern _Alignas (max_align_t) short s; +_Alignas (max_align_t) short s; + +_Alignas (int) int i; +extern int i; + +_Alignas (max_align_t) long l; + +_Alignas (max_align_t) long long ll; + +_Alignas (max_align_t) float f; + +_Alignas (max_align_t) double d; + +_Alignas (max_align_t) _Complex long double cld; + +_Alignas (0) _Alignas (int) _Alignas (char) char ca[10]; + +_Alignas ((int) _Alignof (max_align_t) + 0) int x; + +enum e { E = _Alignof (max_align_t) }; +_Alignas (E) int y; + +void +func (void) +{ + _Alignas (max_align_t) long long auto_ll; +} + +/* Valid, but useless. */ +_Alignas (0) struct s; /* { dg-warning "useless" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-2.c b/SingleSource/Regression/C/gcc-dg/c11-align-2.c new file mode 100644 index 0000000000..a1750ac547 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-2.c @@ -0,0 +1,92 @@ +/* Test C11 alignment support. Test valid code using stdalign.h. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include +#include + +extern int strcmp (const char *, const char *); + +extern void exit (int); +extern void abort (void); + +alignas (alignof (max_align_t)) char c; +extern alignas (max_align_t) char c; +extern char c; + +extern alignas (max_align_t) short s; +alignas (max_align_t) short s; + +alignas (int) int i; +extern int i; + +alignas (max_align_t) long l; + +alignas (max_align_t) long long ll; + +alignas (max_align_t) float f; + +alignas (max_align_t) double d; + +alignas (max_align_t) _Complex long double cld; + +alignas (0) alignas (int) alignas (char) char ca[10]; + +alignas ((int) alignof (max_align_t) + 0) int x; + +enum e { E = alignof (max_align_t) }; +alignas (E) int y; + +void +func (void) +{ + alignas (max_align_t) long long auto_ll; +} + +/* Valid, but useless. */ +alignas (0) struct s; /* { dg-warning "useless" } */ + +#ifndef alignas +#error "alignas not defined" +#endif + +#ifndef alignof +#error "alignof not defined" +#endif + +#ifndef __alignas_is_defined +#error "__alignas_is_defined not defined" +#endif + +#if __alignas_is_defined != 1 +#error "__alignas_is_defined not 1" +#endif + +#ifndef __alignof_is_defined +#error "__alignof_is_defined not defined" +#endif + +#if __alignof_is_defined != 1 +#error "__alignof_is_defined not 1" +#endif + +#define str(x) #x +#define xstr(x) str(x) + +const char *s1 = xstr(alignas); +const char *s2 = xstr(alignof); +const char *s3 = xstr(__alignas_is_defined); +const char *s4 = xstr(__alignof_is_defined); + +int +main (void) +{ + if (strcmp (s1, "_Alignas") != 0) + abort (); + if (strcmp (s2, "_Alignof") != 0) + abort (); + if (strcmp (s3, "1") != 0) + abort (); + if (strcmp (s4, "1") != 0) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-3.c b/SingleSource/Regression/C/gcc-dg/c11-align-3.c new file mode 100644 index 0000000000..39b81ef6f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-3.c @@ -0,0 +1,43 @@ +/* Test C11 alignment support. Test invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int a = _Alignof (void (void)); /* { dg-error "function" } */ +struct s; +int b = _Alignof (struct s); /* { dg-error "incomplete" } */ +int c = _Alignof (void); /* { dg-error "void" } */ +int d = _Alignof (a); /* { dg-error "expression" } */ + +_Alignas (void (void)) char e; /* { dg-error "function" } */ +_Alignas (struct s) char f; /* { dg-error "incomplete" } */ +_Alignas (void) char g; /* { dg-error "void" } */ + +_Alignas (-__INT_MAX__-1) char h; /* { dg-error "too large|power of 2" } */ +_Alignas (-__INT_MAX__) char h2; /* { dg-error "too large|power of 2" } */ +_Alignas ((-__INT_MAX__-1)/2) char h3; /* { dg-error "too large|power of 2" } */ +_Alignas ((-__INT_MAX__-1)/4) char h4; /* { dg-error "too large|power of 2" } */ +_Alignas ((-__INT_MAX__-1)/8) char h5; /* { dg-error "too large|power of 2" } */ +_Alignas (-__LONG_LONG_MAX__-1) char i; /* { dg-error "too large|power of 2" } */ +_Alignas (-(__LONG_LONG_MAX__-1)/2) char i2; /* { dg-error "too large|power of 2" } */ +_Alignas (-(__LONG_LONG_MAX__-1)/4) char i3; /* { dg-error "too large|power of 2" } */ +_Alignas (-(__LONG_LONG_MAX__-1)/8) char i4; /* { dg-error "too large|power of 2" } */ +_Alignas (-(__LONG_LONG_MAX__-1)/16) char i5; /* { dg-error "too large|power of 2" } */ +_Alignas (-1) char j; /* { dg-error "power of 2" } */ +_Alignas (-2) char j; /* { dg-error "positive power of 2" } */ +_Alignas (3) char k; /* { dg-error "power of 2" } */ + +_Alignas ((void *) 1) char k; /* { dg-error "integer constant" } */ +int x; +_Alignas (x) char l; /* { dg-error "integer constant" } */ + +_Alignas (0) struct s; /* { dg-error "does not redeclare tag" } */ + +_Alignas (0) typedef int T; /* { dg-error "alignment specified for typedef" } */ +void func (_Alignas (0) int); /* { dg-error "alignment specified for unnamed parameter" } */ +void f2 (_Alignas (0) int parm2) {} /* { dg-error "alignment specified for parameter" } */ +void +f3 (void) +{ + register _Alignas (0) int reg; /* { dg-error "register" } */ +} +_Alignas (0) void f4 (void); /* { dg-error "alignment specified for function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-4.c b/SingleSource/Regression/C/gcc-dg/c11-align-4.c new file mode 100644 index 0000000000..eb9071b914 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-4.c @@ -0,0 +1,9 @@ +/* Test C11 alignment support. Test reducing alignment (assumes there + are at least some alignment constraints). */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ +/* { dg-skip-if "no alignment constraints" { no_alignment_constraints } } */ + +#include + +_Alignas (_Alignof (char)) max_align_t x; /* { dg-error "reduce alignment" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-5.c b/SingleSource/Regression/C/gcc-dg/c11-align-5.c new file mode 100644 index 0000000000..08ec65a8b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-5.c @@ -0,0 +1,28 @@ +/* Test C11 alignment support. Test invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void foo (int []); +void bar1 (int [_Alignas (double) 10]); /* { dg-error "expected expression before" } */ +void bar2 (int [static _Alignas (double) 10]); /* { dg-error "expected expression before" } */ +void bar3 (int [static const _Alignas (double) 10]); /* { dg-error "expected expression before" } */ +void bar4 (int [const _Alignas (double) 10]); /* { dg-error "expected expression before" } */ +void bar5 (int [_Alignas (0) *]); /* { dg-error "expected expression before" } */ + +void foo (int a[_Alignas (0) 10]) { } /* { dg-error "expected expression before" } */ + +void +test (void) +{ + int *_Alignas (long) p; /* { dg-error "expected" } */ + int *const _Alignas (long) *q; /* { dg-error "expected" } */ + struct s { int n; }; + __builtin_offsetof (struct s _Alignas (int), n); /* { dg-error "expected" } */ + __typeof (long double _Alignas (0)) e; /* { dg-error "expected" } */ + sizeof (int _Alignas (int)); /* { dg-error "specified for type name" } */ + _Alignas (int _Alignas (float)) int t; /* { dg-error "expected" } */ + __builtin_types_compatible_p (signed _Alignas (0), unsigned); /* { dg-error "expected" } */ + int a[_Alignas (int) 10]; /* { dg-error "expected expression before" } */ + int b[10]; + foo (b); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-6.c b/SingleSource/Regression/C/gcc-dg/c11-align-6.c new file mode 100644 index 0000000000..7ea994da40 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-6.c @@ -0,0 +1,40 @@ +/* Test C11 _Alignof returning minimum alignment for a type. PR + 52023. */ +/* { dg-do run } */ +/* { dg-options "-std=c11" } */ + +extern void abort (void); +extern void exit (int); + +#define CHECK_ALIGN(TYPE) \ + do \ + { \ + struct { char c; TYPE v; } x; \ + if (_Alignof (TYPE) > __alignof__ (x.v)) \ + abort (); \ + } \ + while (0) + +int +main (void) +{ + CHECK_ALIGN (_Bool); + CHECK_ALIGN (char); + CHECK_ALIGN (signed char); + CHECK_ALIGN (unsigned char); + CHECK_ALIGN (signed short); + CHECK_ALIGN (unsigned short); + CHECK_ALIGN (signed int); + CHECK_ALIGN (unsigned int); + CHECK_ALIGN (signed long); + CHECK_ALIGN (unsigned long); + CHECK_ALIGN (signed long long); + CHECK_ALIGN (unsigned long long); + CHECK_ALIGN (float); + CHECK_ALIGN (double); + CHECK_ALIGN (long double); + CHECK_ALIGN (_Complex float); + CHECK_ALIGN (_Complex double); + CHECK_ALIGN (_Complex long double); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-7.c b/SingleSource/Regression/C/gcc-dg/c11-align-7.c new file mode 100644 index 0000000000..631986ac30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-7.c @@ -0,0 +1,20 @@ +/* Test C11 alignment support. Test code valid after the resolution + of DR#444: alignment specifiers for struct and union members and + compound literals. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +struct s +{ + _Alignas (_Alignof (max_align_t)) char c; +}; + +union u +{ + _Alignas (_Alignof (max_align_t)) char c; +}; + +char *p = &(_Alignas (_Alignof (max_align_t)) char) { 1 }; +size_t size = sizeof (_Alignas (_Alignof (max_align_t)) char) { 1 }; diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-8.c b/SingleSource/Regression/C/gcc-dg/c11-align-8.c new file mode 100644 index 0000000000..a201674cf9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-8.c @@ -0,0 +1,18 @@ +/* Test C11 alignment support. Test invalid use of alignment + specifiers in type names in cases not permitted by the resolution + of DR#444. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +void +f (void) +{ + _Generic (1, int: 1, _Alignas (8) long: 2); /* { dg-error "expected" } */ + sizeof (_Alignas (8) long); /* { dg-error "specified for type name" } */ + _Alignof (_Alignas (8) long); /* { dg-error "specified for type name" } */ + (_Alignas (8) long) 0; /* { dg-error "specified for type name" } */ + _Atomic (_Alignas (8) long) x; /* { dg-error "expected" } */ + _Alignas (_Alignas (8) long) long y; /* { dg-error "expected" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-align-9.c b/SingleSource/Regression/C/gcc-dg/c11-align-9.c new file mode 100644 index 0000000000..6a0d4248f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-align-9.c @@ -0,0 +1,9 @@ +/* Test C11 alignment support. Test reducing alignment (assumes there + are at least some alignment constraints), case of compound literals. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +max_align_t *p = &(_Alignas (_Alignof (char)) max_align_t) { 1 }; +/* { dg-error "reduce alignment" "" { target { ! default_packed } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-anon-struct-1.c b/SingleSource/Regression/C/gcc-dg/c11-anon-struct-1.c new file mode 100644 index 0000000000..779ae66b7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-anon-struct-1.c @@ -0,0 +1,72 @@ +/* Test for anonymous structures and unions in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +struct s1 +{ + int a; + union + { + int i; + }; + struct + { + int b; + }; +}; + +union u1 +{ + int b; + struct + { + int i; + }; + union + { + int c; + }; +}; + +struct s2 +{ + struct + { + int a; + }; +}; + +struct s3 +{ + union + { + int i; + }; +}; + +struct s4 +{ + struct + { + int i; + }; + int a[]; +}; + +struct s1 x = + { + .b = 1, + .i = 2, + .a = 3 + }; + +int o = offsetof (struct s1, i); + +void +f (void) +{ + x.i = 3; + (&x)->i = 4; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-anon-struct-2.c b/SingleSource/Regression/C/gcc-dg/c11-anon-struct-2.c new file mode 100644 index 0000000000..d954b4b127 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-anon-struct-2.c @@ -0,0 +1,57 @@ +/* Test for anonymous structures and unions in C11. Test for invalid + cases. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +typedef struct s0 +{ + int i; +} s0; + +struct s1 +{ + int a; + struct s0; /* { dg-error "declaration does not declare anything" } */ +}; + +struct s2 +{ + int a; + s0; /* { dg-error "declaration does not declare anything" } */ +}; + +struct s3 +{ + struct + { + int i; + }; + struct + { + int i; /* { dg-error "duplicate member" } */ + }; +}; + +struct s4 +{ + int a; + struct s + { + int i; + }; /* { dg-error "declaration does not declare anything" } */ +}; + +struct s5 +{ + struct + { + int i; + } a; + int b; +} x; + +void +f (void) +{ + x.i = 0; /* { dg-error "has no member" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-anon-struct-3.c b/SingleSource/Regression/C/gcc-dg/c11-anon-struct-3.c new file mode 100644 index 0000000000..05cc3660cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-anon-struct-3.c @@ -0,0 +1,34 @@ +/* Test for anonymous structures and unions in C11. Test for invalid + cases: typedefs disallowed by N1549. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +typedef struct +{ + int i; +} s0; + +typedef union +{ + int i; +} u0; + +struct s1 +{ + int a; + u0; /* { dg-error "declaration does not declare anything" } */ + struct + { + int b; + }; +}; + +union u1 +{ + int b; + s0; /* { dg-error "declaration does not declare anything" } */ + union + { + int c; + }; +}; diff --git a/SingleSource/Regression/C/gcc-dg/c11-atomic-1.c b/SingleSource/Regression/C/gcc-dg/c11-atomic-1.c new file mode 100644 index 0000000000..9702a10a62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-atomic-1.c @@ -0,0 +1,267 @@ +/* Test for _Atomic in C11. Test of valid code. See c11-atomic-2.c + for more exhaustive tests of assignment cases. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +/* The use of _Atomic as a qualifier, and of _Atomic (type-name), give + the same type. */ +extern _Atomic int a; +extern _Atomic (int) a; +extern int *_Atomic b; +extern _Atomic (int *) b; +extern void f (int [_Atomic]); +extern void f (int *_Atomic); + +/* _Atomic may be applied to arbitrary types, with or without other + qualifiers, and assignments may be made as with non-atomic + types. Structure and union elements may be atomic. */ +_Atomic int ai1, ai2; +int i1; +volatile _Atomic long double ald1; +const _Atomic long double ald2; +long double ld1; +_Atomic _Complex double acd1, acd2; +_Complex double d1; +_Atomic volatile _Bool ab1; +int *p; +int *_Atomic restrict ap; +struct s { char c[1000]; }; +_Atomic struct s as1; +struct s s1; +struct t { _Atomic int i; }; +_Atomic struct t at1; +_Atomic struct t *atp1; +struct t t1; +union u { char c[1000]; }; +_Atomic union u au1; +union u u1; +union v { _Atomic int i; }; +_Atomic union v av1; +union v v1; + +void +func (_Atomic volatile long al1) +{ + ai1 = ai2; + ai1 = i1; + i1 = ai2; + ai1 = ald2; + ald1 = d1; + ld1 = acd2; + acd1 += ab1; + acd2 /= ai1; + p = ap; + ap = p; + ab1 = p; + as1 = s1; + s1 = as1; + at1 = t1; + t1 = at1; + /* It's unclear whether the undefined behavior (6.5.2.3#5) for + accessing elements of atomic structures and unions is at + translation or execution time; presume here that it's at + execution time. */ + t1.i = at1.i; /* { dg-warning "accessing a member .i. of an atomic structure" } */ + at1.i = t1.i; /* { dg-warning "accessing a member .i. of an atomic structure" } */ + atp1->i = t1.i; /* { dg-warning "accessing a member .i. of an atomic structure" } */ + au1 = u1; + u1 = au1; + av1 = v1; + v1 = av1; + v1.i = av1.i; /* { dg-warning "accessing a member .i. of an atomic union" } */ + av1.i = v1.i; /* { dg-warning "accessing a member .i. of an atomic union" } */ + /* _Atomic is valid on register variables, even if not particularly + useful. */ + register _Atomic volatile int ra1 = 1, ra2 = 2; + ra1 = ra2; + ra2 = ra1; + /* And on parameters. */ + al1 = ra1; + ra2 = al1; +} + +/* A function may return an atomic type. */ +_Atomic int +func2 (int i) +{ + return i; +} + +/* Casts may specify atomic type. */ +int +func3 (int i) +{ + return func2 ((_Atomic long) i); +} + +/* The _Atomic void type is valid. */ +_Atomic void *avp; + +/* An array of atomic elements is valid (the elements being atomic, + not the array). */ +_Atomic int aa[10]; +int +func4 (void) +{ + return aa[2]; +} + +/* Increment and decrement are valid for atomic types when they are + valid for non-atomic types. */ +void +func5 (void) +{ + ald1++; + ald1--; + ++ald1; + --ald1; + ai1++; + ai1--; + ++ai1; + --ai1; + ab1++; + ab1--; + ++ab1; + --ab1; + ap++; + ap--; + ++ap; + --ap; +} + +/* Compound literals may have atomic type. */ +_Atomic int *aiclp = &(_Atomic int) { 1 }; + +/* Test unary & and *. */ +void +func6 (void) +{ + int i = *aiclp; + _Atomic int *p = &ai2; +} + +/* Casts to atomic type are valid (although the _Atomic has little + effect because the result is an rvalue). */ +int i2 = (_Atomic int) 1.0; + +/* For pointer subtraction and comparisons, _Atomic does not count as + a qualifier. Likewise for conditional expressions. */ +_Atomic int *xaip1; +volatile _Atomic int *xaip2; +void *xvp1; + +void +func7 (void) +{ + int r; + r = xaip1 - xaip2; + r = xaip1 < xaip2; + r = xaip1 > xaip2; + r = xaip1 <= xaip2; + r = xaip1 >= xaip2; + r = xaip1 == xaip2; + r = xaip1 != xaip2; + r = xaip1 == xvp1; + r = xaip1 != xvp1; + r = xvp1 == xaip1; + r = xvp1 != xaip1; + r = xaip1 == 0; + r = ((void *) 0) == xaip2; + (void) (r ? xaip1 : xaip2); + (void) (r ? xvp1 : xaip2); + (void) (r ? xaip2 : xvp1); + (void) (r ? xaip1 : 0); + (void) (r ? 0 : xaip1); + /* The result of a conditional expression between a pointer to + qualified or unqualified (but not atomic) void, and a pointer to + an atomic type, is a pointer to appropriately qualified, not + atomic, void. As such, it is valid to use further in conditional + expressions with other pointer types. */ + (void) (r ? xaip1 : (r ? xaip1 : xvp1)); +} + +/* Pointer += and -= integer is valid. */ +void +func8 (void) +{ + b += 1; + b -= 2ULL; + ap += 3; +} + +/* Various other cases of simple assignment are valid (some already + tested above). */ +void +func9 (void) +{ + ap = 0; + ap = (void *) 0; + xvp1 = atp1; + atp1 = xvp1; +} + +/* Test compatibility of function types in cases where _Atomic matches + (see c11-atomic-3.c for corresponding cases where it doesn't + match). */ +void fc0a (int const); +void fc0a (int); +void fc0b (int _Atomic); +void fc0b (int _Atomic); +void fc1a (int); +void +fc1a (x) + volatile int x; +{ +} +void fc1b (_Atomic int); +void +fc1b (x) + volatile _Atomic int x; +{ +} +void +fc2a (x) + const int x; +{ +} +void fc2a (int); /* { dg-warning "follows non-prototype" } */ +void +fc2b (x) + _Atomic int x; +{ +} +void fc2b (_Atomic int); /* { dg-warning "follows non-prototype" } */ +void fc3a (int); +void +fc3a (x) + volatile short x; +{ +} +void fc3b (_Atomic int); +void +fc3b (x) + _Atomic short x; +{ +} +void +fc4a (x) + const short x; +{ +} +void fc4a (int); /* { dg-warning "follows non-prototype" } */ +void +fc4b (x) + _Atomic short x; +{ +} +void fc4b (_Atomic int); /* { dg-warning "follows non-prototype" } */ + +/* Test cases involving C_MAYBE_CONST_EXPR work. */ +void +func10 (_Atomic int *p) +{ + p[0 / 0] = 1; /* { dg-warning "division by zero" } */ + p[0 / 0] += 1; /* { dg-warning "division by zero" } */ + *p = 0 / 0; /* { dg-warning "division by zero" } */ + *p += 0 / 0; /* { dg-warning "division by zero" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-atomic-2.c b/SingleSource/Regression/C/gcc-dg/c11-atomic-2.c new file mode 100644 index 0000000000..34ee081d42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-atomic-2.c @@ -0,0 +1,165 @@ +/* Test for _Atomic in C11. Test of valid assignment cases for + arithmetic types. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#define TEST_ASSIGN(TYPE1, OP, TYPE2) \ + do \ + { \ + _Atomic TYPE1 a = 0; \ + TYPE2 b = 0; \ + _Atomic TYPE2 c = 0; \ + a OP b; \ + a OP c; \ + } \ + while (0) + +#define TEST_ASSIGN_ARITHR(TYPE1, OP) \ + do \ + { \ + TEST_ASSIGN (TYPE1, OP, _Bool); \ + TEST_ASSIGN (TYPE1, OP, char); \ + TEST_ASSIGN (TYPE1, OP, signed char); \ + TEST_ASSIGN (TYPE1, OP, unsigned char); \ + TEST_ASSIGN (TYPE1, OP, signed short); \ + TEST_ASSIGN (TYPE1, OP, unsigned short); \ + TEST_ASSIGN (TYPE1, OP, signed int); \ + TEST_ASSIGN (TYPE1, OP, unsigned int); \ + TEST_ASSIGN (TYPE1, OP, signed long); \ + TEST_ASSIGN (TYPE1, OP, unsigned long); \ + TEST_ASSIGN (TYPE1, OP, signed long long); \ + TEST_ASSIGN (TYPE1, OP, unsigned long long); \ + TEST_ASSIGN (TYPE1, OP, float); \ + TEST_ASSIGN (TYPE1, OP, double); \ + TEST_ASSIGN (TYPE1, OP, long double); \ + TEST_ASSIGN (TYPE1, OP, _Complex float); \ + TEST_ASSIGN (TYPE1, OP, _Complex double); \ + TEST_ASSIGN (TYPE1, OP, _Complex long double); \ + } \ + while (0) + +#define TEST_ASSIGN_ARITHBOTH(OP) \ + do \ + { \ + TEST_ASSIGN_ARITHR (_Bool, OP); \ + TEST_ASSIGN_ARITHR (char, OP); \ + TEST_ASSIGN_ARITHR (signed char, OP); \ + TEST_ASSIGN_ARITHR (unsigned char, OP); \ + TEST_ASSIGN_ARITHR (signed short, OP); \ + TEST_ASSIGN_ARITHR (unsigned short, OP); \ + TEST_ASSIGN_ARITHR (signed int, OP); \ + TEST_ASSIGN_ARITHR (unsigned int, OP); \ + TEST_ASSIGN_ARITHR (signed long, OP); \ + TEST_ASSIGN_ARITHR (unsigned long, OP); \ + TEST_ASSIGN_ARITHR (signed long long, OP); \ + TEST_ASSIGN_ARITHR (unsigned long long, OP); \ + TEST_ASSIGN_ARITHR (float, OP); \ + TEST_ASSIGN_ARITHR (double, OP); \ + TEST_ASSIGN_ARITHR (long double, OP); \ + TEST_ASSIGN_ARITHR (_Complex float, OP); \ + TEST_ASSIGN_ARITHR (_Complex double, OP); \ + TEST_ASSIGN_ARITHR (_Complex long double, OP); \ + } \ + while (0) + +#define TEST_ASSIGN_INTR(TYPE1, OP) \ + do \ + { \ + TEST_ASSIGN (TYPE1, OP, _Bool); \ + TEST_ASSIGN (TYPE1, OP, char); \ + TEST_ASSIGN (TYPE1, OP, signed char); \ + TEST_ASSIGN (TYPE1, OP, unsigned char); \ + TEST_ASSIGN (TYPE1, OP, signed short); \ + TEST_ASSIGN (TYPE1, OP, unsigned short); \ + TEST_ASSIGN (TYPE1, OP, signed int); \ + TEST_ASSIGN (TYPE1, OP, unsigned int); \ + TEST_ASSIGN (TYPE1, OP, signed long); \ + TEST_ASSIGN (TYPE1, OP, unsigned long); \ + TEST_ASSIGN (TYPE1, OP, signed long long); \ + TEST_ASSIGN (TYPE1, OP, unsigned long long); \ + } \ + while (0) + +#define TEST_ASSIGN_INTBOTH(OP) \ + do \ + { \ + TEST_ASSIGN_INTR (_Bool, OP); \ + TEST_ASSIGN_INTR (char, OP); \ + TEST_ASSIGN_INTR (signed char, OP); \ + TEST_ASSIGN_INTR (unsigned char, OP); \ + TEST_ASSIGN_INTR (signed short, OP); \ + TEST_ASSIGN_INTR (unsigned short, OP); \ + TEST_ASSIGN_INTR (signed int, OP); \ + TEST_ASSIGN_INTR (unsigned int, OP); \ + TEST_ASSIGN_INTR (signed long, OP); \ + TEST_ASSIGN_INTR (unsigned long, OP); \ + TEST_ASSIGN_INTR (signed long long, OP); \ + TEST_ASSIGN_INTR (unsigned long long, OP); \ + } \ + while (0) + +void +test_simple (void) +{ + TEST_ASSIGN_ARITHBOTH (=); +} + +void +test_mult (void) +{ + TEST_ASSIGN_ARITHBOTH (*=); +} + +void +test_div (void) +{ + TEST_ASSIGN_ARITHBOTH (/=); +} + +void +test_mod (void) +{ + TEST_ASSIGN_INTBOTH (%=); +} + +void +test_plus (void) +{ + TEST_ASSIGN_ARITHBOTH (+=); +} + +void +test_minus (void) +{ + TEST_ASSIGN_ARITHBOTH (-=); +} + +void +test_lshift (void) +{ + TEST_ASSIGN_INTBOTH (<<=); +} + +void +test_rshift (void) +{ + TEST_ASSIGN_INTBOTH (>>=); +} + +void +test_and (void) +{ + TEST_ASSIGN_INTBOTH (&=); +} + +void +test_xor (void) +{ + TEST_ASSIGN_INTBOTH (^=); +} + +void +test_or (void) +{ + TEST_ASSIGN_INTBOTH (|=); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-atomic-3.c b/SingleSource/Regression/C/gcc-dg/c11-atomic-3.c new file mode 100644 index 0000000000..4b314e88ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-atomic-3.c @@ -0,0 +1,174 @@ +/* Test for _Atomic in C11. Test of invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +/* Increment and decrement are invalid for atomic complex types and + atomic pointers to incomplete types, just as for the corresponding + non-atomic types. Likewise for types on which arithmetic is + invalid. */ +_Atomic _Complex float acf; +void *_Atomic apv; +struct s *_Atomic aps; +_Atomic struct t { char c; } as; + +void +func (void) +{ + acf++; /* { dg-error "complex types" } */ + acf--; /* { dg-error "complex types" } */ + ++acf; /* { dg-error "complex types" } */ + --acf; /* { dg-error "complex types" } */ + apv++; /* { dg-error "wrong type|pointer of type" } */ + apv--; /* { dg-error "wrong type|pointer of type" } */ + ++apv; /* { dg-error "wrong type|pointer of type" } */ + --apv; /* { dg-error "wrong type|pointer of type" } */ + aps++; /* { dg-error "pointer to|invalid use of undefined type" } */ + aps--; /* { dg-error "pointer to|invalid use of undefined type" } */ + ++aps; /* { dg-error "pointer to|invalid use of undefined type" } */ + --aps; /* { dg-error "pointer to|invalid use of undefined type" } */ + as++; /* { dg-error "wrong type" } */ + as--; /* { dg-error "wrong type" } */ + ++as; /* { dg-error "wrong type" } */ + --as; /* { dg-error "wrong type" } */ +} + +/* Pointer subtraction and comparisons differing in _Atomic are + invalid where such subtraction and comparisons differing in + qualifiers are valid. There is no special allowance for equality + comparisons of pointers to atomic void to pointers to object + types. Likewise for conditional expressions. */ +int *pi; +_Atomic int *pai; +_Atomic void *pav; +int r; + +void +func2 (void) +{ + r = pai - pi; /* { dg-error "invalid operands" } */ + r = pi - pai; /* { dg-error "invalid operands" } */ + r = pi < pai; /* { dg-error "distinct pointer types" } */ + r = pi > pai; /* { dg-error "distinct pointer types" } */ + r = pi <= pai; /* { dg-error "distinct pointer types" } */ + r = pi >= pai; /* { dg-error "distinct pointer types" } */ + r = pai < pi; /* { dg-error "distinct pointer types" } */ + r = pai > pi; /* { dg-error "distinct pointer types" } */ + r = pai <= pi; /* { dg-error "distinct pointer types" } */ + r = pai >= pi; /* { dg-error "distinct pointer types" } */ + r = pav == pi; /* { dg-error "distinct pointer types" } */ + r = pav != pi; /* { dg-error "distinct pointer types" } */ + r = pi == pav; /* { dg-error "distinct pointer types" } */ + r = pi != pav; /* { dg-error "distinct pointer types" } */ + (void) (r ? pai : pi); /* { dg-error "pointer type mismatch" } */ + (void) (r ? pi : pai); /* { dg-error "pointer type mismatch" } */ + (void) (r ? pai : pav); /* { dg-error "pointer type mismatch" } */ + (void) (r ? pav : pai); /* { dg-error "pointer type mismatch" } */ +} + +/* Likewise for pointer assignment. */ +void +func3 (void) +{ + pai = pi; /* { dg-error "incompatible pointer type" } */ + pi = pai; /* { dg-error "incompatible pointer type" } */ + pav = pai; /* { dg-error "incompatible pointer type" } */ + pai = pav; /* { dg-error "incompatible pointer type" } */ +} + +/* Cases that are invalid for normal assignments are just as invalid + (and should not ICE) when the LHS is atomic. */ +void +func4 (void) +{ + as = acf; /* { dg-error "incompatible types" } */ + apv = as; /* { dg-error "incompatible types" } */ + as += 1; /* { dg-error "invalid operands" } */ + apv -= 1; /* { dg-error "pointer of type" } */ + apv *= 1; /* { dg-error "invalid operands" } */ + apv /= 1; /* { dg-error "invalid operands" } */ + apv %= 1; /* { dg-error "invalid operands" } */ + apv <<= 1; /* { dg-error "invalid operands" } */ + apv >>= 1; /* { dg-error "invalid operands" } */ + apv &= 1; /* { dg-error "invalid operands" } */ + apv ^= 1; /* { dg-error "invalid operands" } */ + apv |= 1; /* { dg-error "invalid operands" } */ +} + +/* We don't allow atomic bit-fields in GCC (implementation-defined + whether they are permitted). */ +struct abf +{ + _Atomic int i : 1; /* { dg-error "atomic type" } */ + _Atomic int : 0; /* { dg-error "atomic type" } */ +}; + +/* _Atomic (type-name) may not use a name for an array, function, + qualified or atomic type. */ +_Atomic (int [2]) v0; /* { dg-error "array type" } */ +_Atomic (void (void)) v1; /* { dg-error "function type" } */ +_Atomic (_Atomic int) v2; /* { dg-error "applied to a qualified type" } */ +_Atomic (const int) v3; /* { dg-error "applied to a qualified type" } */ +_Atomic (volatile int) v4; /* { dg-error "applied to a qualified type" } */ +_Atomic (int *restrict) v5; /* { dg-error "applied to a qualified type" } */ + +/* _Atomic, used as a qualifier, may not be applied to a function or + array type. */ +typedef int arraytype[2]; +typedef void functiontype (void); +_Atomic arraytype v6; /* { dg-error "array type" } */ +_Atomic arraytype *v7; /* { dg-error "array type" } */ +typedef _Atomic arraytype v8; /* { dg-error "array type" } */ +int v9 = sizeof (_Atomic arraytype); /* { dg-error "array type" } */ +void v10 (_Atomic arraytype parm); /* { dg-error "array type" } */ +struct v11 { _Atomic arraytype f; }; /* { dg-error "array type" } */ +_Atomic functiontype v12; /* { dg-error "function type" } */ +_Atomic functiontype *v13; /* { dg-error "function type" } */ +typedef _Atomic functiontype *v14; /* { dg-error "function type" } */ +void v15 (_Atomic functiontype parm); /* { dg-error "function type" } */ + +/* Function parameters, when function types are required to be + compatible, may not differ in the presence of _Atomic. See + c11-atomic-1.c for corresponding tests where _Atomic matches. */ +void fc0 (int _Atomic); /* { dg-message "previous declaration" } */ +void fc0 (int); /* { dg-error "conflicting types" } */ +void fc1 (int); /* { dg-message "prototype declaration" } */ +void +fc1 (x) + _Atomic int x; /* { dg-error "match prototype" } */ +{ +} +void +fc2 (x) /* { dg-message "previous definition" } */ + _Atomic int x; +{ +} +void fc2 (int); /* { dg-error "incompatible type" } */ +void fc3 (int); /* { dg-message "prototype declaration" } */ +void +fc3 (x) + _Atomic short x; /* { dg-error "match prototype" } */ +{ +} +void +fc4 (x) /* { dg-message "previous definition" } */ + _Atomic short x; +{ +} +void fc4 (int); /* { dg-error "incompatible type" } */ + +/* Arrays of atomic elements cannot be initialized with string + literals. */ +_Atomic char si0[] = ""; /* { dg-error "inappropriate type" } */ +_Atomic char si1[] = u8""; /* { dg-error "inappropriate type" } */ +_Atomic signed char si2[] = ""; /* { dg-error "inappropriate type" } */ +_Atomic signed char si3[] = u8""; /* { dg-error "inappropriate type" } */ +_Atomic unsigned char si4[] = ""; /* { dg-error "inappropriate type" } */ +_Atomic unsigned char si5[] = u8""; /* { dg-error "inappropriate type" } */ +_Atomic __WCHAR_TYPE__ si6[] = L""; /* { dg-error "inappropriate type" } */ +_Atomic __CHAR16_TYPE__ si7[] = u""; /* { dg-error "inappropriate type" } */ +_Atomic __CHAR32_TYPE__ si8[] = U""; /* { dg-error "inappropriate type" } */ + +/* Anything that is syntactically a qualifier applied to the (void) + parameter list results in undefined behavior, which we + diagnose. */ +void fv (_Atomic void); /* { dg-error "may not be qualified" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-atomic-4.c b/SingleSource/Regression/C/gcc-dg/c11-atomic-4.c new file mode 100644 index 0000000000..81003aa695 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-atomic-4.c @@ -0,0 +1,92 @@ +/* PR c/69002 */ +/* Test we diagnose accessing elements of atomic structures or unions, + which is undefined behavior (C11 6.5.2.3#5). */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +struct S { int x; }; +union U { int x; }; + +int +fn1 (_Atomic struct S p) +{ + int e = 0 && p.x; + return p.x + e; /* { dg-warning "accessing a member .x. of an atomic structure" } */ +} + +int +fn2 (_Atomic struct S *p) +{ + int e = 1 || p->x; + return p->x + e; /* { dg-warning "accessing a member .x. of an atomic structure" } */ +} + +void +fn3 (_Atomic struct S p, int x) +{ + p.x = x; /* { dg-warning "accessing a member .x. of an atomic structure" } */ +} + +void +fn4 (_Atomic struct S *p, int x) +{ + p->x = x; /* { dg-warning "accessing a member .x. of an atomic structure" } */ +} + +int +fn5 (_Atomic struct S p) +{ + /* This is OK: Members can be safely accessed using a non-atomic + object which is assigned to or from the atomic object. */ + struct S s = p; + return s.x; +} + +int +fn6 (_Atomic struct S *p) +{ + struct S s = *p; + return s.x; +} + +int +fn7 (_Atomic union U p) +{ + int e = 0 && p.x; + return p.x + e; /* { dg-warning "accessing a member .x. of an atomic union" } */ +} + +int +fn8 (_Atomic union U *p) +{ + int e = 1 || p->x; + return p->x + e; /* { dg-warning "accessing a member .x. of an atomic union" } */ +} + +void +fn9 (_Atomic union U p, int x) +{ + p.x = x; /* { dg-warning "accessing a member .x. of an atomic union" } */ +} + +void +fn10 (_Atomic union U *p, int x) +{ + p->x = x; /* { dg-warning "accessing a member .x. of an atomic union" } */ +} + +int +fn11 (_Atomic union U p) +{ + /* This is OK: Members can be safely accessed using a non-atomic + object which is assigned to or from the atomic object. */ + union U s = p; + return s.x; +} + +int +fn12 (_Atomic union U *p) +{ + union U s = *p; + return s.x; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-atomic-5.c b/SingleSource/Regression/C/gcc-dg/c11-atomic-5.c new file mode 100644 index 0000000000..090ffdfa69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-atomic-5.c @@ -0,0 +1,10 @@ +/* PR c/82679 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +typedef _Atomic int A[10]; +A a; + +typedef _Atomic int I; +typedef I T[10]; +T t; diff --git a/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-1.c b/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-1.c new file mode 100644 index 0000000000..5a3f70cd71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-1.c @@ -0,0 +1,7 @@ +/* Test C2x attribute syntax: rejected in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +[[]]; /* { dg-error "attributes before C2X" } */ + +void f [[]] (void); /* { dg-error "attributes before C2X" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-2.c b/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-2.c new file mode 100644 index 0000000000..d92a1891ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-2.c @@ -0,0 +1,7 @@ +/* Test C2x attribute syntax: rejected in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +[[]]; /* { dg-warning "attributes before C2X" } */ + +void f [[]] (void); /* { dg-warning "attributes before C2X" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-3.c b/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-3.c new file mode 100644 index 0000000000..4d7cb77d09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-attr-syntax-3.c @@ -0,0 +1,8 @@ +/* Test C2x attribute syntax: rejected in C11, but warning disabled + with -Wno-c11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic -Wno-c11-c2x-compat" } */ + +[[]]; + +void f [[]] (void); diff --git a/SingleSource/Regression/C/gcc-dg/c11-binary-constants-1.c b/SingleSource/Regression/C/gcc-dg/c11-binary-constants-1.c new file mode 100644 index 0000000000..fdc7df4bfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-binary-constants-1.c @@ -0,0 +1,11 @@ +/* Test that binary constants are diagnosed in C11 mode: -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +int a = 0b1; /* { dg-warning "binary constants" } */ +#if 0b101 /* { dg-warning "binary constants" } */ +#endif + +int b = 0B1; /* { dg-warning "binary constants" } */ +#if 0B101 /* { dg-warning "binary constants" } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-binary-constants-2.c b/SingleSource/Regression/C/gcc-dg/c11-binary-constants-2.c new file mode 100644 index 0000000000..6b48a5d005 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-binary-constants-2.c @@ -0,0 +1,11 @@ +/* Test that binary constants are diagnosed in C11 mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int a = 0b1; /* { dg-error "binary constants" } */ +#if 0b101 /* { dg-error "binary constants" } */ +#endif + +int b = 0B1; /* { dg-error "binary constants" } */ +#if 0B101 /* { dg-error "binary constants" } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-bool-1.c b/SingleSource/Regression/C/gcc-dg/c11-bool-1.c new file mode 100644 index 0000000000..0412624a70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-bool-1.c @@ -0,0 +1,50 @@ +/* Test macro expansions in in C11. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#define str(x) xstr(x) +#define xstr(x) #x + +extern void abort (void); +extern void exit (int); +extern int strcmp (const char *, const char *); + +#if false - 1 >= 0 +#error "false unsigned in #if" +#endif + +#if false != 0 +#error "false not 0 in #if" +#endif + +#if true - 2 >= 0 +#error "true unsigned in #if" +#endif + +#if true != 1 +#error "true not 1 in #if" +#endif + +int +main (void) +{ + if (strcmp (str (bool), "_Bool") != 0) + abort (); + if (_Generic (true, int : 1) != 1) + abort (); + if (true != 1) + abort (); + if (strcmp (str (true), "1") != 0) + abort (); + if (_Generic (false, int : 1) != 1) + abort (); + if (false != 0) + abort (); + if (strcmp (str (false), "0") != 0) + abort (); + if (strcmp (str (__bool_true_false_are_defined), "1") != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-bool-limits-1.c b/SingleSource/Regression/C/gcc-dg/c11-bool-limits-1.c new file mode 100644 index 0000000000..9ca29be4d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-bool-limits-1.c @@ -0,0 +1,13 @@ +/* Test limits for _Bool not in in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +#include + +#ifdef BOOL_MAX +# error "unexpected BOOL_MAX" +#endif + +#ifdef BOOL_WIDTH +# error "unexpected BOOL_WIDTH" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-builtins-1.c b/SingleSource/Regression/C/gcc-dg/c11-builtins-1.c new file mode 100644 index 0000000000..bfadf70471 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-builtins-1.c @@ -0,0 +1,19 @@ +/* Test C11 built-in functions: test functions new in C2x are not + declared as built-in for C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +int exp10 (void); +int exp10f (void); +int exp10l (void); +int fabsd32 (void); +int fabsd64 (void); +int fabsd128 (void); +int nand32 (void); +int nand64 (void); +int nand128 (void); +int roundeven (void); +int roundevenf (void); +int roundevenl (void); +int strdup (void); +int strndup (void); diff --git a/SingleSource/Regression/C/gcc-dg/c11-compare-incomplete-1.c b/SingleSource/Regression/C/gcc-dg/c11-compare-incomplete-1.c new file mode 100644 index 0000000000..b1c05cf221 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-compare-incomplete-1.c @@ -0,0 +1,52 @@ +/* Test comparisons of pointers to complete and incomplete types are + accepted in C11 mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int +f (int (*p)[], int (*q)[3]) +{ + return p < q; +} + +int +f2 (int (*p)[], int (*q)[3]) +{ + return p <= q; +} + +int +f3 (int (*p)[], int (*q)[3]) +{ + return p > q; +} + +int +f4 (int (*p)[], int (*q)[3]) +{ + return p >= q; +} + +int +g (int (*p)[], int (*q)[3]) +{ + return q < p; +} + +int +g2 (int (*p)[], int (*q)[3]) +{ + return q <= p; +} + +int +g3 (int (*p)[], int (*q)[3]) +{ + return q > p; +} + +int +g4 (int (*p)[], int (*q)[3]) +{ + return q >= p; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-compare-incomplete-2.c b/SingleSource/Regression/C/gcc-dg/c11-compare-incomplete-2.c new file mode 100644 index 0000000000..8e809e87e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-compare-incomplete-2.c @@ -0,0 +1,52 @@ +/* Test comparisons of pointers to complete and incomplete types are + diagnosed in C11 mode with -Wc99-c11-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors -Wc99-c11-compat" } */ + +int +f (int (*p)[], int (*q)[3]) +{ + return p < q; /* { dg-warning "complete and incomplete" } */ +} + +int +f2 (int (*p)[], int (*q)[3]) +{ + return p <= q; /* { dg-warning "complete and incomplete" } */ +} + +int +f3 (int (*p)[], int (*q)[3]) +{ + return p > q; /* { dg-warning "complete and incomplete" } */ +} + +int +f4 (int (*p)[], int (*q)[3]) +{ + return p >= q; /* { dg-warning "complete and incomplete" } */ +} + +int +g (int (*p)[], int (*q)[3]) +{ + return q < p; /* { dg-warning "complete and incomplete" } */ +} + +int +g2 (int (*p)[], int (*q)[3]) +{ + return q <= p; /* { dg-warning "complete and incomplete" } */ +} + +int +g3 (int (*p)[], int (*q)[3]) +{ + return q > p; /* { dg-warning "complete and incomplete" } */ +} + +int +g4 (int (*p)[], int (*q)[3]) +{ + return q >= p; /* { dg-warning "complete and incomplete" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-complex-1.c b/SingleSource/Regression/C/gcc-dg/c11-complex-1.c new file mode 100644 index 0000000000..4acb2bcc22 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-complex-1.c @@ -0,0 +1,43 @@ +/* Test complex divide does not have the bug identified in N1496. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ +/* { dg-add-options ieee } */ + +extern void abort (void); +extern void exit (int); + +#define CMPLX(x, y) __builtin_complex ((double) (x), (double) (y)) +#define CMPLXF(x, y) __builtin_complex ((float) (x), (float) (y)) +#define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double) (y)) +#define NAN __builtin_nanf ("") +#define isnan(x) __builtin_isnan (x) + +volatile _Complex float num_f = CMPLXF (1, 1); +volatile _Complex float den_f = CMPLXF (0, NAN); +volatile _Complex float res_f, cres_f = CMPLXF (1, 1) / CMPLXF (0, NAN); + +volatile _Complex double num_d = CMPLX (1, 1); +volatile _Complex double den_d = CMPLX (0, NAN); +volatile _Complex double res_d, cres_d = CMPLX (1, 1) / CMPLX (0, NAN); + +volatile _Complex long double num_ld = CMPLXL (1, 1); +volatile _Complex long double den_ld = CMPLXL (0, NAN); +volatile _Complex long double res_ld, cres_ld = CMPLXL (1, 1) / CMPLXL (0, NAN); + +int +main (void) +{ + res_f = num_f / den_f; + if (!isnan (__real__ res_f) || !isnan (__imag__ res_f) + || !isnan (__real__ cres_f) || !isnan (__imag__ cres_f)) + abort (); + res_d = num_d / den_d; + if (!isnan (__real__ res_d) || !isnan (__imag__ res_d) + || !isnan (__real__ cres_d) || !isnan (__imag__ cres_d)) + abort (); + res_ld = num_ld / den_ld; + if (!isnan (__real__ res_ld) || !isnan (__imag__ res_ld) + || !isnan (__real__ cres_ld) || !isnan (__imag__ cres_ld)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-complit-1.c b/SingleSource/Regression/C/gcc-dg/c11-complit-1.c new file mode 100644 index 0000000000..e191cebbb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-complit-1.c @@ -0,0 +1,7 @@ +/* Test C2x storage class specifiers in compound literals not permitted for + C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int *ps = &(static int) { 1 }; /* { dg-error "forbids storage class specifiers in compound literals" } */ +int ss = sizeof (static int) { 1 }; /* { dg-error "forbids storage class specifiers in compound literals" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-complit-2.c b/SingleSource/Regression/C/gcc-dg/c11-complit-2.c new file mode 100644 index 0000000000..d4d1f16f62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-complit-2.c @@ -0,0 +1,7 @@ +/* Test C2x storage class specifiers in compound literals not permitted for + C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +int *ps = &(static int) { 1 }; /* { dg-warning "forbids storage class specifiers in compound literals" } */ +int ss = sizeof (static int) { 1 }; /* { dg-warning "forbids storage class specifiers in compound literals" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-complit-3.c b/SingleSource/Regression/C/gcc-dg/c11-complit-3.c new file mode 100644 index 0000000000..a73a8ef8ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-complit-3.c @@ -0,0 +1,7 @@ +/* Test C2x storage class specifiers in compound literals not permitted for + C11, but -Wno-c11-c2x-compat disables the -pedantic diagnostic for that. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors -Wno-c11-c2x-compat" } */ + +int *ps = &(static int) { 1 }; +int ss = sizeof (static int) { 1 }; diff --git a/SingleSource/Regression/C/gcc-dg/c11-digit-separators-1.c b/SingleSource/Regression/C/gcc-dg/c11-digit-separators-1.c new file mode 100644 index 0000000000..fc832260ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-digit-separators-1.c @@ -0,0 +1,7 @@ +/* Test C2x digit separators not in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#define m(x) 0 + +_Static_assert (m(1'2)+(3'4) == 0, "digit separators"); diff --git a/SingleSource/Regression/C/gcc-dg/c11-empty-init-1.c b/SingleSource/Regression/C/gcc-dg/c11-empty-init-1.c new file mode 100644 index 0000000000..120c282258 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-empty-init-1.c @@ -0,0 +1,25 @@ +/* Test C11 does not support empty initializers. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +struct s { int a; }; +struct s s = {}; /* { dg-error "empty initializer" } */ +int x = {}; /* { dg-error "empty initializer" } */ +float y = {}; /* { dg-error "empty initializer" } */ +void *p = {}; /* { dg-error "empty initializer" } */ +union u { int a; long b; }; +union u z = {}; /* { dg-error "empty initializer" } */ +int aa[2] = {}; /* { dg-error "empty initializer" } */ + +void +f (int a) +{ + int vla[a] = {}; /* { dg-error "empty initializer" } */ + struct s as = {}; /* { dg-error "empty initializer" } */ + int ax = {}; /* { dg-error "empty initializer" } */ + float ay = {}; /* { dg-error "empty initializer" } */ + void *ap = {}; /* { dg-error "empty initializer" } */ + union u az = {}; /* { dg-error "empty initializer" } */ + int aaa[2] = {}; /* { dg-error "empty initializer" } */ + int t = (int) {}; /* { dg-error "empty initializer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-empty-init-2.c b/SingleSource/Regression/C/gcc-dg/c11-empty-init-2.c new file mode 100644 index 0000000000..3ec7c512a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-empty-init-2.c @@ -0,0 +1,25 @@ +/* Test C11 does not support empty initializers. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +struct s { int a; }; +struct s s = {}; /* { dg-warning "empty initializer" } */ +int x = {}; /* { dg-warning "empty initializer" } */ +float y = {}; /* { dg-warning "empty initializer" } */ +void *p = {}; /* { dg-warning "empty initializer" } */ +union u { int a; long b; }; +union u z = {}; /* { dg-warning "empty initializer" } */ +int aa[2] = {}; /* { dg-warning "empty initializer" } */ + +void +f (int a) +{ + int vla[a] = {}; /* { dg-warning "empty initializer" } */ + struct s as = {}; /* { dg-warning "empty initializer" } */ + int ax = {}; /* { dg-warning "empty initializer" } */ + float ay = {}; /* { dg-warning "empty initializer" } */ + void *ap = {}; /* { dg-warning "empty initializer" } */ + union u az = {}; /* { dg-warning "empty initializer" } */ + int aaa[2] = {}; /* { dg-warning "empty initializer" } */ + int t = (int) {}; /* { dg-warning "empty initializer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-empty-init-3.c b/SingleSource/Regression/C/gcc-dg/c11-empty-init-3.c new file mode 100644 index 0000000000..fd43fa7890 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-empty-init-3.c @@ -0,0 +1,25 @@ +/* Test C11 does not support empty initializers. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wc11-c2x-compat" } */ + +struct s { int a; }; +struct s s = {}; /* { dg-warning "empty initializer" } */ +int x = {}; /* { dg-warning "empty initializer" } */ +float y = {}; /* { dg-warning "empty initializer" } */ +void *p = {}; /* { dg-warning "empty initializer" } */ +union u { int a; long b; }; +union u z = {}; /* { dg-warning "empty initializer" } */ +int aa[2] = {}; /* { dg-warning "empty initializer" } */ + +void +f (int a) +{ + int vla[a] = {}; /* { dg-warning "empty initializer" } */ + struct s as = {}; /* { dg-warning "empty initializer" } */ + int ax = {}; /* { dg-warning "empty initializer" } */ + float ay = {}; /* { dg-warning "empty initializer" } */ + void *ap = {}; /* { dg-warning "empty initializer" } */ + union u az = {}; /* { dg-warning "empty initializer" } */ + int aaa[2] = {}; /* { dg-warning "empty initializer" } */ + int t = (int) {}; /* { dg-warning "empty initializer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-enum-1.c b/SingleSource/Regression/C/gcc-dg/c11-enum-1.c new file mode 100644 index 0000000000..571041d596 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-enum-1.c @@ -0,0 +1,14 @@ +/* Test C2x enumerations with values not representable in int are diagnosed for + C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +enum e1 { e1a = -__LONG_LONG_MAX__ - 1 }; /* { dg-error "ISO C restricts enumerator values" } */ + +enum e2 { e2a = __LONG_LONG_MAX__ }; /* { dg-error "ISO C restricts enumerator values" } */ + +enum e3 { e3a = (unsigned int) -1 }; /* { dg-error "ISO C restricts enumerator values" } */ + +enum e4 { e4a = (long long) -__INT_MAX__ - 1, e4b = (unsigned int) __INT_MAX__ }; + +enum e5 { e5a = __INT_MAX__, e5b }; /* { dg-error "ISO C restricts enumerator values" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-enum-2.c b/SingleSource/Regression/C/gcc-dg/c11-enum-2.c new file mode 100644 index 0000000000..5b07c8d4b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-enum-2.c @@ -0,0 +1,14 @@ +/* Test C2x enumerations with values not representable in int are diagnosed for + C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +enum e1 { e1a = -__LONG_LONG_MAX__ - 1 }; /* { dg-warning "ISO C restricts enumerator values" } */ + +enum e2 { e2a = __LONG_LONG_MAX__ }; /* { dg-warning "ISO C restricts enumerator values" } */ + +enum e3 { e3a = (unsigned int) -1 }; /* { dg-warning "ISO C restricts enumerator values" } */ + +enum e4 { e4a = (long long) -__INT_MAX__ - 1, e4b = (unsigned int) __INT_MAX__ }; + +enum e5 { e5a = __INT_MAX__, e5b }; /* { dg-warning "ISO C restricts enumerator values" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-enum-3.c b/SingleSource/Regression/C/gcc-dg/c11-enum-3.c new file mode 100644 index 0000000000..8266d4ea34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-enum-3.c @@ -0,0 +1,14 @@ +/* Test C2x enumerations with values not representable in int are not diagnosed + for C11 with -pedantic-errors -Wno-c11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors -Wno-c11-c2x-compat" } */ + +enum e1 { e1a = -__LONG_LONG_MAX__ - 1 }; + +enum e2 { e2a = __LONG_LONG_MAX__ }; + +enum e3 { e3a = (unsigned int) -1 }; + +enum e4 { e4a = (long long) -__INT_MAX__ - 1, e4b = (unsigned int) __INT_MAX__ }; + +enum e5 { e5a = __INT_MAX__, e5b }; diff --git a/SingleSource/Regression/C/gcc-dg/c11-enum-4.c b/SingleSource/Regression/C/gcc-dg/c11-enum-4.c new file mode 100644 index 0000000000..57dd92a687 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-enum-4.c @@ -0,0 +1,7 @@ +/* Test C2x enumerations with fixed underlying type are diagnosed for C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +enum e1 : int; /* { dg-error "ISO C does not support specifying 'enum' underlying types" } */ +enum e2 : short { A }; /* { dg-error "ISO C does not support specifying 'enum' underlying types" } */ +enum : short { B }; /* { dg-error "ISO C does not support specifying 'enum' underlying types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-enum-5.c b/SingleSource/Regression/C/gcc-dg/c11-enum-5.c new file mode 100644 index 0000000000..91d681f21f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-enum-5.c @@ -0,0 +1,7 @@ +/* Test C2x enumerations with fixed underlying type are diagnosed for C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +enum e1 : int; /* { dg-warning "ISO C does not support specifying 'enum' underlying types" } */ +enum e2 : short { A }; /* { dg-warning "ISO C does not support specifying 'enum' underlying types" } */ +enum : short { B }; /* { dg-warning "ISO C does not support specifying 'enum' underlying types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-enum-6.c b/SingleSource/Regression/C/gcc-dg/c11-enum-6.c new file mode 100644 index 0000000000..cd708bd7c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-enum-6.c @@ -0,0 +1,8 @@ +/* Test C2x enumerations with fixed underlying type are not diagnosed for C11 + with -pedantic-errors -Wno-c11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors -Wno-c11-c2x-compat" } */ + +enum e1 : int; +enum e2 : short { A }; +enum : short { B }; diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-1.c b/SingleSource/Regression/C/gcc-dg/c11-float-1.c new file mode 100644 index 0000000000..376c44d3e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-1.c @@ -0,0 +1,169 @@ +/* Test for C11 macros. */ +/* Origin: Joseph Myers */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +/* This test checks that the C11 macros are defined; + it does not check the correctness of their values. */ + +#include + +#ifndef FLT_ROUNDS +#error "FLT_ROUNDS undefined" +#endif + +#ifndef FLT_RADIX +#error "FLT_RADIX undefined" +#endif + +#ifndef FLT_MANT_DIG +#error "FLT_MANT_DIG undefined" +#endif + +#ifndef FLT_DIG +#error "FLT_DIG undefined" +#endif + +#ifndef FLT_MIN_EXP +#error "FLT_MIN_EXP undefined" +#endif + +#ifndef FLT_MIN_10_EXP +#error "FLT_MIN_10_EXP undefined" +#endif + +#ifndef FLT_MAX_EXP +#error "FLT_MAX_EXP undefined" +#endif + +#ifndef FLT_MAX_10_EXP +#error "FLT_MAX_10_EXP undefined" +#endif + +#ifndef FLT_MAX +#error "FLT_MAX undefined" +#endif + +#ifndef FLT_EPSILON +#error "FLT_EPSILON undefined" +#endif + +#ifndef FLT_MIN +#error "FLT_MIN undefined" +#endif + +#ifndef DBL_MANT_DIG +#error "DBL_MANT_DIG undefined" +#endif + +#ifndef DBL_DIG +#error "DBL_DIG undefined" +#endif + +#ifndef DBL_MIN_EXP +#error "DBL_MIN_EXP undefined" +#endif + +#ifndef DBL_MIN_10_EXP +#error "DBL_MIN_10_EXP undefined" +#endif + +#ifndef DBL_MAX_EXP +#error "DBL_MAX_EXP undefined" +#endif + +#ifndef DBL_MAX_10_EXP +#error "DBL_MAX_10_EXP undefined" +#endif + +#ifndef DBL_MAX +#error "DBL_MAX undefined" +#endif + +#ifndef DBL_EPSILON +#error "DBL_EPSILON undefined" +#endif + +#ifndef DBL_MIN +#error "DBL_MIN undefined" +#endif + +#ifndef LDBL_MANT_DIG +#error "LDBL_MANT_DIG undefined" +#endif + +#ifndef LDBL_DIG +#error "LDBL_DIG undefined" +#endif + +#ifndef LDBL_MIN_EXP +#error "LDBL_MIN_EXP undefined" +#endif + +#ifndef LDBL_MIN_10_EXP +#error "LDBL_MIN_10_EXP undefined" +#endif + +#ifndef LDBL_MAX_EXP +#error "LDBL_MAX_EXP undefined" +#endif + +#ifndef LDBL_MAX_10_EXP +#error "LDBL_MAX_10_EXP undefined" +#endif + +#ifndef LDBL_MAX +#error "LDBL_MAX undefined" +#endif + +#ifndef LDBL_EPSILON +#error "LDBL_EPSILON undefined" +#endif + +#ifndef LDBL_MIN +#error "LDBL_MIN undefined" +#endif + +#ifndef FLT_EVAL_METHOD +#error "FLT_EVAL_METHOD undefined" +#endif + +#ifndef DECIMAL_DIG +#error "DECIMAL_DIG undefined" +#endif + +#ifndef FLT_DECIMAL_DIG +#error "FLT_DECIMAL_DIG undefined" +#endif + +#ifndef DBL_DECIMAL_DIG +#error "DBL_DECIMAL_DIG undefined" +#endif + +#ifndef LDBL_DECIMAL_DIG +#error "LDBL_DECIMAL_DIG undefined" +#endif + +#ifndef FLT_HAS_SUBNORM +#error "FLT_HAS_SUBNORM undefined" +#endif + +#ifndef DBL_HAS_SUBNORM +#error "DBL_HAS_SUBNORM undefined" +#endif + +#ifndef LDBL_HAS_SUBNORM +#error "LDBL_HAS_SUBNORM undefined" +#endif + +#ifndef FLT_TRUE_MIN +#error "FLT_TRUE_MIN undefined" +#endif + +#ifndef DBL_TRUE_MIN +#error "DBL_TRUE_MIN undefined" +#endif + +#ifndef LDBL_TRUE_MIN +#error "LDBL_TRUE_MIN undefined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-2.c b/SingleSource/Regression/C/gcc-dg/c11-float-2.c new file mode 100644 index 0000000000..345c2d349b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-2.c @@ -0,0 +1,9 @@ +/* Test DECIMAL_DIG equals LDBL_DECIMAL_DIG; see DR#501 and N2108. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#if DECIMAL_DIG != LDBL_DECIMAL_DIG +# error "DECIMAL_DIG != LDBL_DECIMAL_DIG" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-3.c b/SingleSource/Regression/C/gcc-dg/c11-float-3.c new file mode 100644 index 0000000000..95d2074ea2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-3.c @@ -0,0 +1,17 @@ +/* Test *_NORM_MAX not defined for C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef FLT_NORM_MAX +#error "FLT_NORM_MAX defined" +#endif + +#ifdef DBL_NORM_MAX +#error "DBL_NORM_MAX defined" +#endif + +#ifdef LDBL_NORM_MAX +#error "LDBL_NORM_MAX defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-4.c b/SingleSource/Regression/C/gcc-dg/c11-float-4.c new file mode 100644 index 0000000000..ceac6ef506 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-4.c @@ -0,0 +1,25 @@ +/* Test infinity and NaN macros not defined for C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef INFINITY +#error "INFINITY defined" +#endif + +#ifdef NAN +#error "NAN defined" +#endif + +#ifdef FLT_SNAN +#error "FLT_SNAN defined" +#endif + +#ifdef DBL_SNAN +#error "DBL_SNAN defined" +#endif + +#ifdef LDBL_SNAN +#error "LDBL_SNAN defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-5.c b/SingleSource/Regression/C/gcc-dg/c11-float-5.c new file mode 100644 index 0000000000..bb48695599 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-5.c @@ -0,0 +1,35 @@ +/* Test sNaN macros for _FloatN and _FloatNx not defined for C11 with + __STDC_WANT_IEC_60559_TYPES_EXT__. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include + +#ifdef FLT16_SNAN +#error "FLT16_SNAN defined" +#endif + +#ifdef FLT32_SNAN +#error "FLT32_SNAN defined" +#endif + +#ifdef FLT64_SNAN +#error "FLT64_SNAN defined" +#endif + +#ifdef FLT128_SNAN +#error "FLT128_SNAN defined" +#endif + +#ifdef FLT32X_SNAN +#error "FLT32X_SNAN defined" +#endif + +#ifdef FLT64X_SNAN +#error "FLT64X_SNAN defined" +#endif + +#ifdef FLT128X_SNAN +#error "FLT128X_SNAN defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-6.c b/SingleSource/Regression/C/gcc-dg/c11-float-6.c new file mode 100644 index 0000000000..b0381e5788 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-6.c @@ -0,0 +1,17 @@ +/* Test *_IS_IEC_60559 not defined for C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef FLT_IS_IEC_60559 +#error "FLT_IS_IEC_60559 defined" +#endif + +#ifdef DBL_IS_IEC_60559 +#error "DBL_IS_IEC_60559 defined" +#endif + +#ifdef LDBL_IS_IEC_60559 +#error "LDBL_IS_IEC_60559 defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-7.c b/SingleSource/Regression/C/gcc-dg/c11-float-7.c new file mode 100644 index 0000000000..a8a7ef5bc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-7.c @@ -0,0 +1,24 @@ +/* Test C11 definition of LDBL_EPSILON. Based on + gcc.target/powerpc/rs6000-ldouble-2.c. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + volatile long double ee = 1.0; + long double eps = ee; + while (ee + 1.0 != 1.0) + { + eps = ee; + ee = eps / 2; + } + if (eps != LDBL_EPSILON) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-8.c b/SingleSource/Regression/C/gcc-dg/c11-float-8.c new file mode 100644 index 0000000000..7fb1e0a568 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-8.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_FLOAT_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_FLOAT_H__ +#error "__STDC_VERSION_FLOAT_H__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-dfp-1.c b/SingleSource/Regression/C/gcc-dg/c11-float-dfp-1.c new file mode 100644 index 0000000000..8d86b1bf23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-dfp-1.c @@ -0,0 +1,5 @@ +/* Test DFP macros not defined in for C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +#include "c2x-float-no-dfp-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/c11-float-dfp-2.c b/SingleSource/Regression/C/gcc-dg/c11-float-dfp-2.c new file mode 100644 index 0000000000..e63ebbcb0f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-float-dfp-2.c @@ -0,0 +1,6 @@ +/* Test DFP macros not defined in for C11. Infinity and NaN + macros. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +#include "c2x-float-no-dfp-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/c11-floatn-1.c b/SingleSource/Regression/C/gcc-dg/c11-floatn-1.c new file mode 100644 index 0000000000..82cae878b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-floatn-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +_Float32 a /* { dg-error "ISO C does not support the '_Float32' type before C2X" } */ + = 1.0F32; /* { dg-error "non-standard suffix on floating constant before C2X" } */ +_Float64 b /* { dg-error "ISO C does not support the '_Float64' type before C2X" } */ + = 1.0F64; /* { dg-error "non-standard suffix on floating constant before C2X" } */ +_Float32x c /* { dg-error "ISO C does not support the '_Float32x' type before C2X" } */ + = 1.0F32x; /* { dg-error "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float32 d + = 2.0F32; +__extension__ _Float64 e + = 2.0F64; +__extension__ _Float32x f + = 2.0F32x; diff --git a/SingleSource/Regression/C/gcc-dg/c11-floatn-2.c b/SingleSource/Regression/C/gcc-dg/c11-floatn-2.c new file mode 100644 index 0000000000..fafdb8e26f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-floatn-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +_Float128 a /* { dg-error "ISO C does not support the '_Float128' type before C2X" } */ + = 1.0F128; /* { dg-error "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float128 b + = 2.0F128; diff --git a/SingleSource/Regression/C/gcc-dg/c11-floatn-3.c b/SingleSource/Regression/C/gcc-dg/c11-floatn-3.c new file mode 100644 index 0000000000..2268a9d83d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-floatn-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Float16 a /* { dg-error "ISO C does not support the '_Float16' type before C2X" } */ + = 1.0F16; /* { dg-error "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float16 b + = 2.0F16; diff --git a/SingleSource/Regression/C/gcc-dg/c11-floatn-4.c b/SingleSource/Regression/C/gcc-dg/c11-floatn-4.c new file mode 100644 index 0000000000..8936ee2e49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-floatn-4.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +_Float64x a /* { dg-error "ISO C does not support the '_Float64x' type before C2X" } */ + = 1.0F64x; /* { dg-error "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float64x b + = 2.0F64x; diff --git a/SingleSource/Regression/C/gcc-dg/c11-floatn-5.c b/SingleSource/Regression/C/gcc-dg/c11-floatn-5.c new file mode 100644 index 0000000000..1b4511494b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-floatn-5.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wc11-c2x-compat" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +_Float32 a /* { dg-warning "ISO C does not support the '_Float32' type before C2X" } */ + = 1.0F32; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +_Float64 b /* { dg-warning "ISO C does not support the '_Float64' type before C2X" } */ + = 1.0F64; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +_Float32x c /* { dg-warning "ISO C does not support the '_Float32x' type before C2X" } */ + = 1.0F32x; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float32 d + = 2.0F32; +__extension__ _Float64 e + = 2.0F64; +__extension__ _Float32x f + = 2.0F32x; diff --git a/SingleSource/Regression/C/gcc-dg/c11-floatn-6.c b/SingleSource/Regression/C/gcc-dg/c11-floatn-6.c new file mode 100644 index 0000000000..ebdb5ddcde --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-floatn-6.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wc11-c2x-compat" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +_Float128 a /* { dg-warning "ISO C does not support the '_Float128' type before C2X" } */ + = 1.0F128; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float128 b + = 2.0F128; diff --git a/SingleSource/Regression/C/gcc-dg/c11-floatn-7.c b/SingleSource/Regression/C/gcc-dg/c11-floatn-7.c new file mode 100644 index 0000000000..005571d544 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-floatn-7.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wc11-c2x-compat" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Float16 a /* { dg-warning "ISO C does not support the '_Float16' type before C2X" } */ + = 1.0F16; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float16 b + = 2.0F16; diff --git a/SingleSource/Regression/C/gcc-dg/c11-floatn-8.c b/SingleSource/Regression/C/gcc-dg/c11-floatn-8.c new file mode 100644 index 0000000000..f6d7228684 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-floatn-8.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wc11-c2x-compat" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +_Float64x a /* { dg-warning "ISO C does not support the '_Float64x' type before C2X" } */ + = 1.0F64x; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float64x b + = 2.0F64x; diff --git a/SingleSource/Regression/C/gcc-dg/c11-fordecl-1.c b/SingleSource/Regression/C/gcc-dg/c11-fordecl-1.c new file mode 100644 index 0000000000..4aceb335e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-fordecl-1.c @@ -0,0 +1,27 @@ +/* Test for C99 declarations in for loops. Test constraints are diagnosed for + C11. Based on c99-fordecl-2.c. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void +foo (void) +{ + int j = 0; + for (int i = 1, bar (void); i <= 10; i++) /* { dg-error "bar" } */ + j += i; + + for (static int i = 1; i <= 10; i++) /* /* { dg-error "static" } */ + j += i; + + for (extern int i; j <= 500; j++) /* { dg-error "extern" } */ + j += 5; + + for (enum { FOO } i = FOO; i < 10; i++) /* { dg-error "FOO" } */ + j += i; + + for (enum BAR { FOO } i = FOO; i < 10; i++) /* { dg-error "FOO" } */ + /* { dg-error "BAR" "enum tag in for loop" { target *-*-* } .-1 } */ + j += i; + for (typedef int T;;) /* { dg-error "non-variable" } */ + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-fordecl-2.c b/SingleSource/Regression/C/gcc-dg/c11-fordecl-2.c new file mode 100644 index 0000000000..0be1a0d13f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-fordecl-2.c @@ -0,0 +1,14 @@ +/* Test for C99 declarations in for loops. Test constraints are diagnosed for + C11: struct and union tags can't be declared there (affirmed in response to + DR#277). Based on c99-fordecl-3.c. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void +foo (void) +{ + for (struct s { int p; } *p = 0; ;) /* { dg-error "'struct s' declared in 'for' loop initial declaration" } */ + ; + for (union u { int p; } *p = 0; ;) /* { dg-error "'union u' declared in 'for' loop initial declaration" } */ + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-fordecl-3.c b/SingleSource/Regression/C/gcc-dg/c11-fordecl-3.c new file mode 100644 index 0000000000..28ef6294c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-fordecl-3.c @@ -0,0 +1,6 @@ +/* Test restrictions on the kind of declarations permitted in for loops removed + in C2X, and thus with -std=c11 -pedantic -Wno-c11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic -Wno-c11-c2x-compat" } */ + +#include "c99-fordecl-2.c" diff --git a/SingleSource/Regression/C/gcc-dg/c11-fordecl-4.c b/SingleSource/Regression/C/gcc-dg/c11-fordecl-4.c new file mode 100644 index 0000000000..2a352d6496 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-fordecl-4.c @@ -0,0 +1,6 @@ +/* Test restrictions on the kind of declarations permitted in for loops removed + in C2X, and thus with -std=c11 -pedantic -Wno-c11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic -Wno-c11-c2x-compat" } */ + +#include "c99-fordecl-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/c11-generic-1.c b/SingleSource/Regression/C/gcc-dg/c11-generic-1.c new file mode 100644 index 0000000000..60ef1f0eb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-generic-1.c @@ -0,0 +1,57 @@ +/* Test C11 _Generic. Valid uses. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Noreturn extern void exit (int); +_Noreturn extern void abort (void); + +void +check (int n) +{ + if (n) + abort (); +} + +int +main (void) +{ + int n = 0; + + check (_Generic (n++, int: 0)); + /* _Generic should not evaluate its argument. */ + check (n); + + check (_Generic (n, double: n++, default: 0)); + check (n); + + /* Qualifiers are removed for the purpose of type matching. */ + const int cn = 0; + check (_Generic (cn, int: 0, default: n++)); + check (n); + check (_Generic ((const int) n, int: 0, default: n++)); + check (n); + + /* Arrays decay to pointers. */ + int a[1]; + const int ca[1]; + check (_Generic (a, int *: 0, const int *: n++)); + check (n); + check (_Generic (ca, const int *: 0, int *: n++)); + check (n); + + /* Functions decay to pointers. */ + extern void f (void); + check (_Generic (f, void (*) (void): 0, default: n++)); + check (n); + + /* _Noreturn is not part of the function type. */ + check (_Generic (&abort, void (*) (void): 0, default: n++)); + check (n); + + /* Integer promotions do not occur. */ + short s; + check (_Generic (s, short: 0, int: n++)); + check (n); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-generic-2.c b/SingleSource/Regression/C/gcc-dg/c11-generic-2.c new file mode 100644 index 0000000000..90be650af2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-generic-2.c @@ -0,0 +1,27 @@ +/* Test C11 _Generic. Error cases. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +struct incomplete; + +void +f (int n) +{ + /* Multiple 'default's. */ + _Generic (n, default: 1, default: 2); /* { dg-error "duplicate .*default.* case" } */ + + /* Variably-modified type not ok. */ + _Generic (n, int[n]: 0, default: 1); /* { dg-error "variable length type" } */ + /* Type must be complete. */ + _Generic (n, struct incomplete: 0, default: 1); /* { dg-error "incomplete type" } */ + _Generic (n, void: 0, default: 1); /* { dg-error "incomplete type" } */ + + /* Type must be object type. */ + _Generic (n, void (void): 0, default: 1); /* { dg-error "function type" } */ + + /* Two compatible types in association list. */ + _Generic (&n, int: 5, signed int: 7, default: 23); /* { dg-error "two compatible types" } */ + + /* No matching association. */ + _Generic (n, void *: 5); /* { dg-error "not compatible with any association" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-generic-3.c b/SingleSource/Regression/C/gcc-dg/c11-generic-3.c new file mode 100644 index 0000000000..8bac21ed31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-generic-3.c @@ -0,0 +1,10 @@ +/* Test C11 _Generic. Test we follow the resolution of DR#423. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +char const *a = _Generic ("bla", char *: ""); +char const *b = _Generic ("bla", char[4]: ""); /* { dg-error "not compatible with any association" } */ +char const *c = _Generic ((int const) { 0 }, int: ""); +char const *d = _Generic ((int const) { 0 }, int const: ""); /* { dg-error "not compatible with any association" } */ +char const *e = _Generic (+(int const) { 0 }, int: ""); +char const *f = _Generic (+(int const) { 0 }, int const: ""); /* { dg-error "not compatible with any association" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-keywords-1.c b/SingleSource/Regression/C/gcc-dg/c11-keywords-1.c new file mode 100644 index 0000000000..997c1b0aff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-keywords-1.c @@ -0,0 +1,12 @@ +/* Test new C2x keywords not keywords in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int alignas; +int alignof; +int bool; +int constexpr; +int false; +int true; +int static_assert; +int thread_local; diff --git a/SingleSource/Regression/C/gcc-dg/c11-labels-1.c b/SingleSource/Regression/C/gcc-dg/c11-labels-1.c new file mode 100644 index 0000000000..6350403bf3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-labels-1.c @@ -0,0 +1,15 @@ +/* Tests for labels before declarations and at ends of compound statements. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +int f(int x) +{ + goto b; + a: int i = 2 * x; + goto c; + b: goto a; + { i *= 3; c: } + return i; + d: +} + diff --git a/SingleSource/Regression/C/gcc-dg/c11-labels-2.c b/SingleSource/Regression/C/gcc-dg/c11-labels-2.c new file mode 100644 index 0000000000..e9b492446b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-labels-2.c @@ -0,0 +1,15 @@ +/* Tests for labels before declarations and at ends of compound statements. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +int f(int x) +{ + goto b; + a: int i = 2 * x; /* { dg-warning "a label can only be part of a statement and a declaration is not a statement" } */ + goto c; + b: goto a; + { i *= 3; c: } /* { dg-warning "label at end of compound statement" } */ + return i; + d: /* { dg-warning "label at end of compound statement" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/c11-labels-3.c b/SingleSource/Regression/C/gcc-dg/c11-labels-3.c new file mode 100644 index 0000000000..1e4be63af6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-labels-3.c @@ -0,0 +1,15 @@ +/* Tests for labels before declarations and at ends of compound statements. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int f(int x) +{ + goto b; + a: int i = 2 * x; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" } */ + goto c; + b: goto a; + { i *= 3; c: } /* { dg-error "label at end of compound statement" } */ + return i; + d: /* { dg-error "label at end of compound statement" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/c11-limits-1.c b/SingleSource/Regression/C/gcc-dg/c11-limits-1.c new file mode 100644 index 0000000000..6dc5737024 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-limits-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_LIMITS_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_LIMITS_H__ +#error "__STDC_VERSION_LIMITS_H__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-noreturn-1.c b/SingleSource/Regression/C/gcc-dg/c11-noreturn-1.c new file mode 100644 index 0000000000..1b0c218b08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-noreturn-1.c @@ -0,0 +1,59 @@ +/* Test C11 _Noreturn. Test valid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Noreturn void exit (int); + +_Noreturn int f1 (void); + +_Noreturn void f2 (void); + +static void _Noreturn f3 (void) { exit (0); } + +/* Returning from a noreturn function is undefined at runtime, not a + constraint violation, but recommended practice is to diagnose if + such a return appears possible. */ + +_Noreturn int +f4 (void) +{ + return 1; /* { dg-warning "has a 'return' statement" } */ + /* { dg-warning "does return" "second warning" { target *-*-* } .-1 } */ +} + +_Noreturn void +f5 (void) +{ + return; /* { dg-warning "has a 'return' statement" } */ + /* { dg-warning "does return" "second warning" { target *-*-* } .-1 } */ +} + +_Noreturn void +f6 (void) +{ +} /* { dg-warning "does return" } */ + +_Noreturn void +f7 (int a) +{ + if (a) + exit (0); +} /* { dg-warning "does return" } */ + +/* Declarations need not all have _Noreturn. */ + +void f2 (void); + +void f8 (void); +_Noreturn void f8 (void); + +/* Duplicate _Noreturn is OK. */ +_Noreturn _Noreturn void _Noreturn f9 (void); + +/* _Noreturn does not affect type compatibility. */ + +void (*fp) (void) = f5; + +/* noreturn is an ordinary identifier. */ + +int noreturn; diff --git a/SingleSource/Regression/C/gcc-dg/c11-noreturn-2.c b/SingleSource/Regression/C/gcc-dg/c11-noreturn-2.c new file mode 100644 index 0000000000..58fafdb2e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-noreturn-2.c @@ -0,0 +1,77 @@ +/* Test C11 _Noreturn. Test valid code using stdnoreturn.h. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +extern int strcmp (const char *, const char *); + +noreturn void exit (int); +noreturn void abort (void); + +noreturn int f1 (void); + +noreturn void f2 (void); + +static void noreturn f3 (void) { exit (0); } + +/* Returning from a noreturn function is undefined at runtime, not a + constraint violation, but recommended practice is to diagnose if + such a return appears possible. */ + +noreturn int +f4 (void) +{ + return 1; /* { dg-warning "has a 'return' statement" } */ + /* { dg-warning "does return" "second warning" { target *-*-* } .-1 } */ +} + +noreturn void +f5 (void) +{ + return; /* { dg-warning "has a 'return' statement" } */ + /* { dg-warning "does return" "second warning" { target *-*-* } .-1 } */ +} + +noreturn void +f6 (void) +{ +} /* { dg-warning "does return" } */ + +noreturn void +f7 (int a) +{ + if (a) + exit (0); +} /* { dg-warning "does return" } */ + +/* Declarations need not all have noreturn. */ + +void f2 (void); + +void f8 (void); +noreturn void f8 (void); + +/* Duplicate noreturn is OK. */ +noreturn noreturn void noreturn f9 (void); + +/* noreturn does not affect type compatibility. */ + +void (*fp) (void) = f5; + +#ifndef noreturn +#error "noreturn not defined" +#endif + +#define str(x) #x +#define xstr(x) str(x) + +const char *s = xstr(noreturn); + +int +main (void) +{ + if (strcmp (s, "_Noreturn") != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-noreturn-3.c b/SingleSource/Regression/C/gcc-dg/c11-noreturn-3.c new file mode 100644 index 0000000000..168d012a3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-noreturn-3.c @@ -0,0 +1,11 @@ +/* Test C11 _Noreturn. Test _Noreturn on main, hosted. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors -fhosted" } */ + +_Noreturn void exit (int); + +_Noreturn int +main (void) /* { dg-error "'main' declared '_Noreturn'" } */ +{ + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-noreturn-4.c b/SingleSource/Regression/C/gcc-dg/c11-noreturn-4.c new file mode 100644 index 0000000000..a92a1140f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-noreturn-4.c @@ -0,0 +1,11 @@ +/* Test C11 _Noreturn. Test _Noreturn on main, freestanding. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors -ffreestanding" } */ + +_Noreturn void exit (int); + +_Noreturn int +main (void) +{ + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-noreturn-5.c b/SingleSource/Regression/C/gcc-dg/c11-noreturn-5.c new file mode 100644 index 0000000000..d1c0949f32 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-noreturn-5.c @@ -0,0 +1,17 @@ +/* Test C11 _Noreturn. Test invalid uses. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Noreturn struct s; /* { dg-error "empty declaration" } */ + +typedef _Noreturn void f (void); /* { dg-error "typedef" } */ + +void g (_Noreturn void fp (void)); /* { dg-error "parameter" } */ + +_Noreturn void (*p) (void); /* { dg-error "variable" } */ + +struct t { int a; _Noreturn void (*f) (void); }; /* { dg-error "expected" } */ + +int *_Noreturn *q; /* { dg-error "expected" } */ + +int i = sizeof (_Noreturn int (*) (void)); /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-nullptr-1.c b/SingleSource/Regression/C/gcc-dg/c11-nullptr-1.c new file mode 100644 index 0000000000..c4faedc2c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-nullptr-1.c @@ -0,0 +1,10 @@ +/* Test that in pre-C23 modes, nullptr is a normal identifier, + not a keyword. */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int nullptr; + +void +f (int nullptr) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-old-style-definition-1.c b/SingleSource/Regression/C/gcc-dg/c11-old-style-definition-1.c new file mode 100644 index 0000000000..74164b7690 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-old-style-definition-1.c @@ -0,0 +1,9 @@ +/* Test old-style function definitions not in C2x: allowed in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void +f (x) + int x; +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-old-style-definition-2.c b/SingleSource/Regression/C/gcc-dg/c11-old-style-definition-2.c new file mode 100644 index 0000000000..a22f555416 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-old-style-definition-2.c @@ -0,0 +1,15 @@ +/* Test old-style function definitions not in C2x: () does not give + type with a prototype for older standards. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +void +f () +{ +} + +void +g (void) +{ + f (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-parm-omit-1.c b/SingleSource/Regression/C/gcc-dg/c11-parm-omit-1.c new file mode 100644 index 0000000000..83d1b50828 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-parm-omit-1.c @@ -0,0 +1,5 @@ +/* Test omitted parameter names not in C11: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void f (int) { } /* { dg-error "omitting parameter names" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-parm-omit-2.c b/SingleSource/Regression/C/gcc-dg/c11-parm-omit-2.c new file mode 100644 index 0000000000..2efd4505db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-parm-omit-2.c @@ -0,0 +1,5 @@ +/* Test omitted parameter names not in C11: -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +void f (int) { } /* { dg-warning "omitting parameter names" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-parm-omit-3.c b/SingleSource/Regression/C/gcc-dg/c11-parm-omit-3.c new file mode 100644 index 0000000000..5bf27a03af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-parm-omit-3.c @@ -0,0 +1,5 @@ +/* Test omitted parameter names not in C11: -pedantic -Wno-c11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic -Wno-c11-c2x-compat" } */ + +void f (int) { } diff --git a/SingleSource/Regression/C/gcc-dg/c11-parm-omit-4.c b/SingleSource/Regression/C/gcc-dg/c11-parm-omit-4.c new file mode 100644 index 0000000000..ea4cbfa992 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-parm-omit-4.c @@ -0,0 +1,6 @@ +/* Test omitted parameter names not in C11: accepted by default in the + absence of -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +void f (int) { } diff --git a/SingleSource/Regression/C/gcc-dg/c11-pointer-float-1.c b/SingleSource/Regression/C/gcc-dg/c11-pointer-float-1.c new file mode 100644 index 0000000000..8c24165877 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-pointer-float-1.c @@ -0,0 +1,28 @@ +/* Test C11 constraint against pointer / floating-point casts. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void *p; +float f; +double d; +long double ld; +_Complex float cf; +_Complex double cd; +_Complex long double cld; + +void +func (void) +{ + f = (float) p; /* { dg-error "pointer" } */ + d = (double) p; /* { dg-error "pointer" } */ + ld = (long double) p; /* { dg-error "pointer" } */ + cf = (_Complex float) p; /* { dg-error "pointer" } */ + cd = (_Complex double) p; /* { dg-error "pointer" } */ + cld = (_Complex long double) p; /* { dg-error "pointer" } */ + p = (void *) f; /* { dg-error "pointer" } */ + p = (void *) d; /* { dg-error "pointer" } */ + p = (void *) ld; /* { dg-error "pointer" } */ + p = (void *) cf; /* { dg-error "pointer" } */ + p = (void *) cd; /* { dg-error "pointer" } */ + p = (void *) cld; /* { dg-error "pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-qual-1.c b/SingleSource/Regression/C/gcc-dg/c11-qual-1.c new file mode 100644 index 0000000000..f731e06883 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-qual-1.c @@ -0,0 +1,11 @@ +/* Test that qualifiers are lost in tertiary operator for pointers to arrays before C2X, PR98397 */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors -Wno-discarded-array-qualifiers" } */ + +void foo(void) +{ + const int (*u)[1]; + void *v; + _Static_assert(_Generic(1 ? u : v, const void*: 0, void*: 1), "qualifier not lost"); + _Static_assert(_Generic(1 ? v : u, const void*: 0, void*: 1), "qualifier not lost"); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-1.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-1.c new file mode 100644 index 0000000000..9209a7a407 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-1.c @@ -0,0 +1,41 @@ +/* Test C11 static assertions. Valid assertions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Static_assert (1, "foo"); + +enum e { E0, E1 }; + +_Static_assert (E1, L"bar"); + +_Static_assert (-1, "foo" L"bar"); + +struct s +{ + int a; + _Static_assert (3, "s"); + int b; +}; + +union u +{ + int i; + _Static_assert ((int)1.0, L""); +}; + +void +f (void) +{ + int i; + i = 1; + _Static_assert (0 + 1, "f"); + i = 2; +} + +void +g (void) +{ + int i = 0; + for (_Static_assert (1, ""); i < 10; i++) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-10.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-10.c new file mode 100644 index 0000000000..2fe210b6cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-10.c @@ -0,0 +1,9 @@ +/* Test for constant expressions: casts with integer overflow. PR + c/93241. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +_Static_assert (0 ? (_Bool) (INT_MAX + 1) : 1, ""); +_Static_assert (0 ? (short) ((INT_MAX + 1) != 0) : 1, ""); diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-2.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-2.c new file mode 100644 index 0000000000..de2f573cb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-2.c @@ -0,0 +1,41 @@ +/* Test C11 static assertions. Failed assertions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Static_assert (0, "assert1"); /* { dg-error "static assertion failed: \"assert1\"" } */ + +enum e { E0, E1 }; + +_Static_assert (E0, L"assert2"); /* { dg-error "static assertion failed: \"assert2\"" } */ + +_Static_assert (-0, "ass" L"ert3"); /* { dg-error "static assertion failed: \"assert3\"" } */ + +struct s +{ + int a; + _Static_assert (0, "assert4"); /* { dg-error "static assertion failed: \"assert4\"" } */ + int b; +}; + +union u +{ + int i; + _Static_assert ((int)0.0, L"assert5"); /* { dg-error "static assertion failed: \"assert5\"" } */ +}; + +void +f (void) +{ + int i; + i = 1; + _Static_assert (0 + 0, "assert6"); /* { dg-error "static assertion failed: \"assert6\"" } */ + i = 2; +} + +void +g (void) +{ + int i = 0; + for (_Static_assert (0, "assert7"); i < 10; i++) /* { dg-error "static assertion failed: \"assert7\"" } */ + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-3.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-3.c new file mode 100644 index 0000000000..9799b972e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-3.c @@ -0,0 +1,28 @@ +/* Test C11 static assertions. Invalid assertions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Static_assert (__INT_MAX__ * 2, "overflow"); /* { dg-warning "integer overflow in expression" } */ +/* { dg-error "overflow in constant expression" "error" { target *-*-* } .-1 } */ + +_Static_assert ((void *)(__SIZE_TYPE__)16, "non-integer"); /* { dg-error "not an integer" } */ + +_Static_assert (1.0, "non-integer"); /* { dg-error "not an integer" } */ + +_Static_assert ((int)(1.0 + 1.0), "non-constant-expression"); /* { dg-error "not an integer constant expression" } */ + +int i; + +_Static_assert (i, "non-constant"); /* { dg-error "not constant" } */ + +void +f (void) +{ + int j = 0; + for (_Static_assert (sizeof (struct s { int k; }), ""); j < 10; j++) /* { dg-error "loop initial declaration" } */ + ; +} + +_Static_assert (1, 1); /* { dg-error "expected" } */ + +_Static_assert (1, ("")); /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-4.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-4.c new file mode 100644 index 0000000000..ddab440ff4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-4.c @@ -0,0 +1,13 @@ +/* Test C11 static assertions. More invalid assertions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +/* Static assertions not valid in old-style parameter declarations + because declarations there must have declarators. */ + +void +f (i) + int i; + _Static_assert (1, ""); /* { dg-error "expected" } */ +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-5.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-5.c new file mode 100644 index 0000000000..e88b8167a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-5.c @@ -0,0 +1,5 @@ +/* Test C11 static assertions. Non-constant-expression without -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +_Static_assert ((int)(1.0 + 1.0), "non-constant-expression"); diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-6.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-6.c new file mode 100644 index 0000000000..ac7e14114d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-6.c @@ -0,0 +1,5 @@ +/* Test C11 static assertions. Non-constant-expression with -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +_Static_assert ((int)(1.0 + 1.0), "non-constant-expression"); /* { dg-warning "not an integer constant expression" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-7.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-7.c new file mode 100644 index 0000000000..8cea923b67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-7.c @@ -0,0 +1,5 @@ +/* Test C11 static assertions. Omitting the string not supported. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +_Static_assert (1); /* { dg-warning "does not support omitting the string" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-8.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-8.c new file mode 100644 index 0000000000..20e5a6d107 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-8.c @@ -0,0 +1,5 @@ +/* Test C11 static assertions. Omitting the string not supported. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Static_assert (1); /* { dg-error "does not support omitting the string" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-static-assert-9.c b/SingleSource/Regression/C/gcc-dg/c11-static-assert-9.c new file mode 100644 index 0000000000..93696ab1b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-static-assert-9.c @@ -0,0 +1,6 @@ +/* Test C11 static assertions. Omitting the string not supported, but + -Wno-c11-c2x-compat disables the -pedantic diagnostic for that. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic -Wno-c11-c2x-compat" } */ + +_Static_assert (1); diff --git a/SingleSource/Regression/C/gcc-dg/c11-stdarg-1.c b/SingleSource/Regression/C/gcc-dg/c11-stdarg-1.c new file mode 100644 index 0000000000..984577fe65 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stdarg-1.c @@ -0,0 +1,7 @@ +/* Test variadic functions with no named parameters not supported in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int f (...); /* { dg-error "ISO C requires a named argument before" } */ +int g (int (...)); /* { dg-error "ISO C requires a named argument before" } */ +int h (...) { return 0; } /* { dg-error "ISO C requires a named argument before" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-stdarg-2.c b/SingleSource/Regression/C/gcc-dg/c11-stdarg-2.c new file mode 100644 index 0000000000..bd115e8850 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stdarg-2.c @@ -0,0 +1,7 @@ +/* Test variadic functions with no named parameters not supported in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +int f (...); /* { dg-warning "ISO C requires a named argument before" } */ +int g (int (...)); /* { dg-warning "ISO C requires a named argument before" } */ +int h (...) { return 0; } /* { dg-warning "ISO C requires a named argument before" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-stdarg-3.c b/SingleSource/Regression/C/gcc-dg/c11-stdarg-3.c new file mode 100644 index 0000000000..009292461b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stdarg-3.c @@ -0,0 +1,8 @@ +/* Test variadic functions with no named parameters not supported in C11, but + diagnostic disabled with -Wno-c11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors -Wno-c11-c2x-compat" } */ + +int f (...); +int g (int (...)); +int h (...) { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/c11-stdarg-4.c b/SingleSource/Regression/C/gcc-dg/c11-stdarg-4.c new file mode 100644 index 0000000000..06bff1f044 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stdarg-4.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_STDARG_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_STDARG_H__ +#error "__STDC_VERSION_STDARG_H__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-stdatomic-1.c b/SingleSource/Regression/C/gcc-dg/c11-stdatomic-1.c new file mode 100644 index 0000000000..79909c055a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stdatomic-1.c @@ -0,0 +1,119 @@ +/* Test stdatomic.h header contents. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifndef ATOMIC_BOOL_LOCK_FREE +# error ATOMIC_BOOL_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_CHAR_LOCK_FREE +# error ATOMIC_CHAR_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_CHAR16_T_LOCK_FREE +# error ATOMIC_CHAR16_T_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_CHAR32_T_LOCK_FREE +# error ATOMIC_CHAR32_T_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_WCHAR_T_LOCK_FREE +# error ATOMIC_WCHAR_T_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_SHORT_LOCK_FREE +# error ATOMIC_SHORT_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_INT_LOCK_FREE +# error ATOMIC_INT_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_LONG_LOCK_FREE +# error ATOMIC_LONG_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_LLONG_LOCK_FREE +# error ATOMIC_LLONG_LOCK_FREE not defined +#endif + +#ifndef ATOMIC_POINTER_LOCK_FREE +# error ATOMIC_POINTER_LOCK_FREE not defined +#endif + +memory_order m0 = memory_order_relaxed; +memory_order m1 = memory_order_consume; +memory_order m2 = memory_order_acquire; +memory_order m3 = memory_order_release; +memory_order m4 = memory_order_acq_rel; +memory_order m5 = memory_order_seq_cst; + +atomic_flag af = ATOMIC_FLAG_INIT; + +struct s { int i[100]; } sv; +void +f (void) +{ + _Atomic struct s sva = ATOMIC_VAR_INIT (sv); +} + +#ifndef kill_dependency +# error kill_dependency not defined +#endif + +#define CHECK_ATOMIC_TYPEDEF(A, B) \ + do \ + { \ + A v; \ + char array1[sizeof (A) == sizeof (B) ? 1 : -1]; \ + char array2[_Alignof (A) == _Alignof (B) ? 1 : -1]; \ + } \ + while (0) + +#include +#include + +void +check_typedefs (void) +{ + CHECK_ATOMIC_TYPEDEF (atomic_bool, _Atomic _Bool); + CHECK_ATOMIC_TYPEDEF (atomic_char, _Atomic char); + CHECK_ATOMIC_TYPEDEF (atomic_schar, _Atomic signed char); + CHECK_ATOMIC_TYPEDEF (atomic_uchar, _Atomic unsigned char); + CHECK_ATOMIC_TYPEDEF (atomic_short, _Atomic short); + CHECK_ATOMIC_TYPEDEF (atomic_ushort, _Atomic unsigned short); + CHECK_ATOMIC_TYPEDEF (atomic_int, _Atomic int); + CHECK_ATOMIC_TYPEDEF (atomic_uint, _Atomic unsigned int); + CHECK_ATOMIC_TYPEDEF (atomic_long, _Atomic long); + CHECK_ATOMIC_TYPEDEF (atomic_ulong, _Atomic unsigned long); + CHECK_ATOMIC_TYPEDEF (atomic_llong, _Atomic long long); + CHECK_ATOMIC_TYPEDEF (atomic_ullong, _Atomic unsigned long long); + CHECK_ATOMIC_TYPEDEF (atomic_char16_t, _Atomic __CHAR16_TYPE__); + CHECK_ATOMIC_TYPEDEF (atomic_char32_t, _Atomic __CHAR32_TYPE__); + CHECK_ATOMIC_TYPEDEF (atomic_wchar_t, _Atomic wchar_t); + CHECK_ATOMIC_TYPEDEF (atomic_int_least8_t, _Atomic int_least8_t); + CHECK_ATOMIC_TYPEDEF (atomic_uint_least8_t, _Atomic uint_least8_t); + CHECK_ATOMIC_TYPEDEF (atomic_int_least16_t, _Atomic int_least16_t); + CHECK_ATOMIC_TYPEDEF (atomic_uint_least16_t, _Atomic uint_least16_t); + CHECK_ATOMIC_TYPEDEF (atomic_int_least32_t, _Atomic int_least32_t); + CHECK_ATOMIC_TYPEDEF (atomic_uint_least32_t, _Atomic uint_least32_t); + CHECK_ATOMIC_TYPEDEF (atomic_int_least64_t, _Atomic int_least64_t); + CHECK_ATOMIC_TYPEDEF (atomic_uint_least64_t, _Atomic uint_least64_t); + CHECK_ATOMIC_TYPEDEF (atomic_int_fast8_t, _Atomic int_fast8_t); + CHECK_ATOMIC_TYPEDEF (atomic_uint_fast8_t, _Atomic uint_fast8_t); + CHECK_ATOMIC_TYPEDEF (atomic_int_fast16_t, _Atomic int_fast16_t); + CHECK_ATOMIC_TYPEDEF (atomic_uint_fast16_t, _Atomic uint_fast16_t); + CHECK_ATOMIC_TYPEDEF (atomic_int_fast32_t, _Atomic int_fast32_t); + CHECK_ATOMIC_TYPEDEF (atomic_uint_fast32_t, _Atomic uint_fast32_t); + CHECK_ATOMIC_TYPEDEF (atomic_int_fast64_t, _Atomic int_fast64_t); + CHECK_ATOMIC_TYPEDEF (atomic_uint_fast64_t, _Atomic uint_fast64_t); + CHECK_ATOMIC_TYPEDEF (atomic_intptr_t, _Atomic intptr_t); + CHECK_ATOMIC_TYPEDEF (atomic_uintptr_t, _Atomic uintptr_t); + CHECK_ATOMIC_TYPEDEF (atomic_size_t, _Atomic size_t); + CHECK_ATOMIC_TYPEDEF (atomic_ptrdiff_t, _Atomic ptrdiff_t); + CHECK_ATOMIC_TYPEDEF (atomic_intmax_t, _Atomic intmax_t); + CHECK_ATOMIC_TYPEDEF (atomic_uintmax_t, _Atomic uintmax_t); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-stdatomic-2.c b/SingleSource/Regression/C/gcc-dg/c11-stdatomic-2.c new file mode 100644 index 0000000000..d746b5ce48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stdatomic-2.c @@ -0,0 +1,27 @@ +/* Test stdatomic.h header contents. Test that ATOMIC_*_LOCK_FREE + macros can be used in an #if directive (DR#458). */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#if ATOMIC_BOOL_LOCK_FREE +#endif +#if ATOMIC_CHAR_LOCK_FREE +#endif +#if ATOMIC_CHAR16_T_LOCK_FREE +#endif +#if ATOMIC_CHAR32_T_LOCK_FREE +#endif +#if ATOMIC_WCHAR_T_LOCK_FREE +#endif +#if ATOMIC_SHORT_LOCK_FREE +#endif +#if ATOMIC_INT_LOCK_FREE +#endif +#if ATOMIC_LONG_LOCK_FREE +#endif +#if ATOMIC_LLONG_LOCK_FREE +#endif +#if ATOMIC_POINTER_LOCK_FREE +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-stdatomic-3.c b/SingleSource/Regression/C/gcc-dg/c11-stdatomic-3.c new file mode 100644 index 0000000000..1f5a71b621 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stdatomic-3.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_STDATOMIC_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_STDATOMIC_H__ +#error "__STDC_VERSION_STDATOMIC_H__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-stddef-1.c b/SingleSource/Regression/C/gcc-dg/c11-stddef-1.c new file mode 100644 index 0000000000..9918d9478c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stddef-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_STDDEF_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_STDDEF_H__ +#error "__STDC_VERSION_STDDEF_H__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-stdint-1.c b/SingleSource/Regression/C/gcc-dg/c11-stdint-1.c new file mode 100644 index 0000000000..43fe681c7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-stdint-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_STDINT_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors -ffreestanding" } */ + +#include + +#ifdef __STDC_VERSION_STDINT_H__ +#error "__STDC_VERSION_STDINT_H__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-thread-local-1.c b/SingleSource/Regression/C/gcc-dg/c11-thread-local-1.c new file mode 100644 index 0000000000..b21209aecd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-thread-local-1.c @@ -0,0 +1,28 @@ +/* Test for _Thread_local in C11. Test of valid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Thread_local int a; +static _Thread_local long b; +extern _Thread_local int c, a; +_Thread_local static int d; +long _Thread_local extern b; +_Thread_local int extern a; +_Thread_local struct s; /* { dg-warning "useless" } */ +_Thread_local int a = 1; +extern _Thread_local int c = 2; /* { dg-warning "initialized and" } */ +void +f (void) +{ + static _Thread_local int x; + extern _Thread_local long b; + _Thread_local extern int a; +} + +inline void +fi (void) +{ + static _Thread_local const int v; + (void) a; + static _Thread_local int (*const p)[a]; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-thread-local-2.c b/SingleSource/Regression/C/gcc-dg/c11-thread-local-2.c new file mode 100644 index 0000000000..3387226168 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-thread-local-2.c @@ -0,0 +1,46 @@ +/* Test for _Thread_local in C11. Test of invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Thread_local void f (void); /* { dg-error "storage class" } */ +_Thread_local void g (void) {} /* { dg-error "_Thread_local" } */ +typedef _Thread_local int t1; /* { dg-error "_Thread_local" } */ +_Thread_local typedef int t2; /* { dg-error "_Thread_local" } */ + +void +h (void) +{ + _Thread_local auto int a; /* { dg-error "_Thread_local" } */ + _Thread_local register int b; /* { dg-error "_Thread_local" } */ + auto _Thread_local int c; /* { dg-error "_Thread_local" } */ + register _Thread_local int d; /* { dg-error "_Thread_local" } */ + _Thread_local int e; /* { dg-error "_Thread_local" } */ +} + +_Thread_local int v; /* { dg-message "previous" } */ +extern int v; /* { dg-error "thread" } */ +int w; /* { dg-message "previous" } */ +extern _Thread_local int w; /* { dg-error "thread" } */ + +_Thread_local int x; /* { dg-message "previous" } */ +int y; /* { dg-message "previous" } */ + +int vv; + +void +i (void) +{ + extern int x; /* { dg-error "thread" } */ + extern _Thread_local int y; /* { dg-error "thread" } */ + static _Thread_local int a[vv]; /* { dg-error "storage size" } */ + static _Thread_local int vi = vv; /* { dg-error "not constant" } */ +} + +static _Thread_local int sv; + +inline void +j (void) +{ + static _Thread_local int vj; /* { dg-error "static but declared" } */ + (void) sv; /* { dg-error "static but used in inline" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-true_min-1.c b/SingleSource/Regression/C/gcc-dg/c11-true_min-1.c new file mode 100644 index 0000000000..1fbf51485b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-true_min-1.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-std=c11" } */ +/* { dg-xfail-run-if "PR58757 -mieee is required to compare denormals" { alpha*-*-* } } */ +/* { dg-skip-if "No subnormal support" { csky-*-* } { "-mhard-float" } } */ + +/* Test that the smallest positive value is not 0. This needs to be true + even when denormals are not supported, so we do not pass any flag + like -mieee. */ + +#include + +int main(){ + volatile float f = FLT_TRUE_MIN; + volatile double d = DBL_TRUE_MIN; + volatile long double l = LDBL_TRUE_MIN; + if (f == 0 || d == 0 || l == 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-typedef-1.c b/SingleSource/Regression/C/gcc-dg/c11-typedef-1.c new file mode 100644 index 0000000000..3224ba5a41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-typedef-1.c @@ -0,0 +1,70 @@ +/* Test typedef redeclaration in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +/* C11 permits typedefs to be redeclared to the same type, but not to + different-but-compatible types, and not when the type is variably + modified. */ + +#include + +typedef int TI; +typedef int TI2; +typedef TI2 TI; +typedef TI TI2; + +enum e { E1 = 0, E2 = INT_MAX, E3 = -1 }; +typedef enum e TE; +typedef enum e TE; /* { dg-message "previous declaration" } */ +typedef int TE; /* { dg-error "with different type" } */ + +struct s; +typedef struct s TS; +struct s { int i; }; +typedef struct s TS; + +typedef int IA[]; +typedef TI2 IA[]; /* { dg-message "previous declaration" } */ +typedef int A2[2]; +typedef TI A2[2]; /* { dg-message "previous declaration" } */ +typedef IA A2; /* { dg-error "with different type" } */ +typedef int A3[3]; +typedef A3 IA; /* { dg-error "with different type" } */ + +typedef void F(int); +typedef void F(TI); /* { dg-message "previous declaration" } */ +typedef void F(enum e); /* { dg-error "with different type" } */ + +typedef int G(void); +typedef TI G(void); /* { dg-message "previous declaration" } */ +typedef enum e G(void); /* { dg-error "with different type" } */ + +typedef int *P; +typedef TI *P; /* { dg-message "previous declaration" } */ +typedef enum e *P; /* { dg-error "with different type" } */ + +typedef void F2(); +typedef void F2(); /* { dg-message "previous declaration" } */ +typedef void F2(int); /* { dg-error "with different type" } */ + +void +f (void) +{ + int a = 1; + int b = 2; + typedef void FN(int (*p)[a]); + typedef void FN(int (*p)[b]); + typedef void FN(int (*p)[*]); /* { dg-message "previous declaration" } */ + typedef void FN(int (*p)[1]); /* { dg-error "with different type" } */ + typedef void FN2(int (*p)[a]); + typedef void FN2(int (*p)[b]); + typedef void FN2(int (*p)[*]); /* { dg-message "previous declaration" } */ + typedef void FN2(int (*p)[]); /* { dg-error "with different type" } */ + typedef int AV[a]; /* { dg-message "previous declaration" } */ + typedef int AV[b-1]; /* { dg-error "redefinition" } */ + typedef int AAa[a]; /* { dg-message "previous declaration" } */ + typedef int AAb[b-1]; + typedef AAa *VF(void); /* { dg-message "previous declaration" } */ + typedef AAb *VF(void); /* { dg-error "redefinition" } */ + typedef AAa AAa; /* { dg-error "redefinition" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-typeof-1.c b/SingleSource/Regression/C/gcc-dg/c11-typeof-1.c new file mode 100644 index 0000000000..a2abe8e465 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-typeof-1.c @@ -0,0 +1,6 @@ +/* Test typeof and typeof_unqual not keywords in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int typeof = 1; +long typeof_unqual = 2; diff --git a/SingleSource/Regression/C/gcc-dg/c11-typeof-2.c b/SingleSource/Regression/C/gcc-dg/c11-typeof-2.c new file mode 100644 index 0000000000..3d49ada5fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-typeof-2.c @@ -0,0 +1,177 @@ +/* Test GNU extensions __typeof__ and __typeof_unqual__. Valid code. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int i; +extern __typeof__ (i) i; +extern __typeof (int) i; +extern __typeof_unqual__ (i) i; +extern __typeof_unqual (int) i; + +volatile int vi; +extern __typeof__ (volatile int) vi; +extern __typeof (vi) vi; + +extern __typeof_unqual__ (volatile int) i; +extern __typeof_unqual__ (vi) i; +extern __typeof__ ((const int) vi) i; +extern __typeof ((volatile int) vi) i; + +const int ci; +extern __typeof (const int) ci; +extern __typeof (ci) ci; + +extern __typeof_unqual (const int) i; +extern __typeof_unqual (ci) i; +extern __typeof__ ((const int) ci) i; +extern __typeof__ (+ci) i; +extern __typeof (0, ci) i; +extern __typeof__ (1 ? ci : ci) i; +extern __typeof (0) i; + +const int fci (void); +extern __typeof__ (fci ()) i; + +_Atomic int ai; +extern __typeof (_Atomic int) ai; +extern __typeof__ (_Atomic (int)) ai; +extern __typeof (ai) ai; + +extern __typeof_unqual__ (_Atomic int) i; +extern __typeof_unqual (_Atomic (int)) i; +extern __typeof_unqual__ (ai) i; +extern __typeof (+ai) i; +extern __typeof__ ((_Atomic int) ai) i; +extern __typeof__ (0, ai) i; +extern __typeof (1 ? ai : ai) i; + +_Atomic int fai (void); +extern __typeof__ (fai ()) i; + +_Atomic const volatile int acvi; +extern __typeof (int volatile const _Atomic) acvi; +extern __typeof (acvi) acvi; +extern const _Atomic volatile __typeof (acvi) acvi; +extern _Atomic volatile __typeof__ (ci) acvi; +extern _Atomic const __typeof (vi) acvi; +extern const __typeof__ (ai) volatile acvi; + +extern __typeof_unqual (acvi) i; +extern __typeof_unqual__ (__typeof (acvi)) i; +extern __typeof_unqual (_Atomic __typeof_unqual__ (acvi)) i; + +extern _Atomic __typeof_unqual (acvi) ai; + +char c; +volatile char vc; +volatile char *pvc; +volatile char *const cpvc; +const char *pcc; +const char *volatile vpcc; +__typeof (*vpcc) cc; + +extern __typeof__ (*cpvc) vc; +extern __typeof_unqual (*cpvc) c; +extern __typeof_unqual__ (cpvc) pvc; +extern __typeof_unqual__ (vpcc) pcc; +extern const char cc; + +extern __typeof (++vi) i; +extern __typeof (++ai) i; +extern __typeof__ (--vi) i; +extern __typeof (--ai) i; +extern __typeof__ (vi++) i; +extern __typeof__ (ai++) i; +extern __typeof (vi--) i; +extern __typeof__ (ai--) i; + +_Bool b; +volatile _Bool vb; +_Atomic _Bool ab; +extern __typeof__ (++vb) b; +extern __typeof__ (++ab) b; +extern __typeof (--vb) b; +extern __typeof__ (--ab) b; +extern __typeof (vb++) b; +extern __typeof (ab++) b; +extern __typeof__ (vb--) b; +extern __typeof (ab--) b; + +extern __typeof__ (vc = 1) c; +extern __typeof__ (vpcc = 0) pcc; +extern __typeof (ai *= 2) i; + +int s = sizeof (__typeof__ (int (*)[++i])); + +void *vp; + +extern void abort (void); +extern void exit (int); + +extern int only_used_in_typeof; + +static int not_defined (void); + +__typeof (i) +main (__typeof (*vp)) +{ + volatile __typeof__ (only_used_in_typeof) ii = 2; + if (ii != 2) + abort (); + const __typeof__ (not_defined ()) jj = 3; + if (jj != 3) + abort (); + unsigned int u = 1; + __typeof__ (u) u2 = 0; + __typeof (int (*)[++u2]) p = 0; + if (u2 != 1) + abort (); + if (sizeof (*p) != sizeof (int)) + abort (); + __typeof_unqual (int (*)[++u2]) q = 0; + if (u2 != 2) + abort (); + if (sizeof (*q) != 2 * sizeof (int)) + abort (); + if (sizeof (*p) != sizeof (int)) + abort (); + __typeof (++u2) u3 = 1; + if (u2 != u + u3) + abort (); + __typeof_unqual__ (++u2) u4 = 2; + if (u2 != u4) + abort (); + u = sizeof (__typeof__ (int (*)[++u2])); + if (u2 != 2) + abort (); + u = sizeof (__typeof_unqual (int (*)[++u2])); + if (u2 != 2) + abort (); + __typeof ((int (*)[++u2]) 0) q2; + if (u2 != 3) + abort (); + __typeof ((void) 0, (int (*)[++u2]) 0) q3; + if (u2 != 4) + abort (); + __typeof__ ((int (*)[++u2]) 0, 0) q4; + if (u2 != 4) + abort (); + __typeof_unqual ((int (*)[++u2]) 0) q5; + if (u2 != 5) + abort (); + __typeof_unqual__ ((void) 0, (int (*)[++u2]) 0) q6; + if (u2 != 6) + abort (); + __typeof_unqual__ ((int (*)[++u2]) 0, 0) q7; + if (u2 != 6) + abort (); + int a1[6], a2[6]; + int (*pa)[u2] = &a1; + __typeof (pa = &a2) pp; + if (pa != &a2) + abort (); + __typeof_unqual (pa = &a1) pp2; + if (pa != &a1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-typeof-3.c b/SingleSource/Regression/C/gcc-dg/c11-typeof-3.c new file mode 100644 index 0000000000..026a57f65b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-typeof-3.c @@ -0,0 +1,58 @@ +/* Test GNU extensions __typeof__ and __typeof_unqual__. Invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +struct s { int i : 2; } x; +union u { unsigned int j : 1; } y; + +__typeof__ (x.i) j; /* { dg-error "applied to a bit-field" } */ +__typeof_unqual__ (x.i) j2; /* { dg-error "applied to a bit-field" } */ +__typeof (y.j) j3; /* { dg-error "applied to a bit-field" } */ +__typeof_unqual (y.j) j4; /* { dg-error "applied to a bit-field" } */ + +static int ok (void); +static int also_ok (void); +static int not_defined (void); /* { dg-error "used but never defined" } */ +static int also_not_defined (void); /* { dg-error "used but never defined" } */ + +_Noreturn void nf1 (void); +__attribute__((noreturn)) void nf2 (void); +void fg (void) {} +__typeof__ (&nf1) pnf1 = fg; /* { dg-error "qualified function pointer from unqualified" } */ +__typeof (&nf2) pnf2 = fg; /* { dg-error "qualified function pointer from unqualified" } */ +extern void (*pnf1) (void); /* { dg-error "conflicting types for" } */ +extern void (*pnf2) (void); /* { dg-error "conflicting types for" } */ +extern __typeof (nf1) *pnf1; /* { dg-error "conflicting types for" } */ +extern __typeof (nf1) *pnf2; /* { dg-error "conflicting types for" } */ +extern __typeof__ (nf2) *pnf1; /* { dg-error "conflicting types for" } */ +extern __typeof__ (nf2) *pnf2; /* { dg-error "conflicting types for" } */ +__typeof (*&nf1) fg2, fg2a, fg2b; /* { dg-error "ISO C forbids qualified function types" } */ +__typeof__ (*&nf2) fg3, fg3a, fg3b; /* { dg-error "ISO C forbids qualified function types" } */ +__typeof (nf1) fg4, fg4a, fg4b; +__typeof__ (nf2) fg5, fg5a, fg5b; + +extern void abort (void); + +void fg2 (void) {} /* { dg-error "conflicting type qualifiers for" } */ +_Noreturn void fg2a (void) { abort (); } /* { dg-error "conflicting type qualifiers for" } */ +__attribute__((noreturn)) void fg2b (void) { abort (); } /* { dg-error "conflicting type qualifiers for" } */ +void fg3 (void) {} /* { dg-error "conflicting type qualifiers for" } */ +_Noreturn void fg3a (void) { abort (); } /* { dg-error "conflicting type qualifiers for" } */ +__attribute__((noreturn)) void fg3b (void) { abort (); } /* { dg-error "conflicting type qualifiers for" } */ +void fg4 (void) {} +_Noreturn void fg4a (void) { abort (); } +__attribute__((noreturn)) void fg4b (void) { abort (); } +void fg5 (void) {} +_Noreturn void fg5a (void) { abort (); } +__attribute__((noreturn)) void fg5b (void) { abort (); } + +void +f (void) +{ + __typeof__ (ok ()) x = 2; + __typeof_unqual (also_ok ()) y = 2; + int a[2]; + int (*p)[x] = &a; + __typeof (p + not_defined ()) q; + __typeof_unqual__ (p + also_not_defined ()) q2; +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-uni-string-1.c b/SingleSource/Regression/C/gcc-dg/c11-uni-string-1.c new file mode 100644 index 0000000000..9f86bea826 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-uni-string-1.c @@ -0,0 +1,112 @@ +/* Test Unicode strings in C11. Test valid code. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +/* More thorough tests are in c-c++-common/raw-string-*.c; this test + verifies the particular subset (Unicode but not raw strings) that + is in C11. */ + +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; +typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void exit (int); +extern int memcmp (const void *, const void *, size_t); + +#define R "(R)" +#define u8R "(u8R)" +#define uR "(uR)" +#define UR "(UR)" +#define LR "(LR)" +#define u8 randomu8 +#define u randomu +#define U randomU + +const char su8[] = u8"a\u010d"; +const char su8a[] = "a\xc4\x8d"; + +const char16_t su16[] = u"\u0567"; +const char16_t su16a[] = { 0x0567, 0 }; + +const char32_t su32[] = U"\u0123"; +const char32_t su32a[] = { 0x0123, 0 }; + +const char tu[] = R"a"; +const char tua[] = "(R)a"; + +const char tu8[] = u8R"b"; +const char tu8a[] = "(u8R)b"; + +const char tu16[] = uR"c"; +const char tu16a[] = "(uR)c"; + +const char tu32[] = UR"d"; +const char tu32a[] = "(UR)d"; + +const char tl[] = LR"e"; +const char tla[] = "(LR)e"; + +#define str(x) #x +const char ts[] = str(u"a" U"b" u8"c"); +const char tsa[] = "u\"a\" U\"b\" u8\"c\""; + +/* GCC always uses UTF-16 and UTF-32 for char16_t and char32_t. */ +#ifndef __STDC_UTF_16__ +#error "__STDC_UTF_16__ not defined" +#endif +#ifndef __STDC_UTF_32__ +#error "__STDC_UTF_32__ not defined" +#endif +#define xstr(x) str(x) +const char tm16[] = xstr(__STDC_UTF_16__); +const char tm16a[] = "1"; +const char tm32[] = xstr(__STDC_UTF_32__); +const char tm32a[] = "1"; + +int +main (void) +{ + if (sizeof (su8) != sizeof (su8a) + || memcmp (su8, su8a, sizeof (su8)) != 0) + abort (); + if (sizeof (su16) != sizeof (su16a) + || memcmp (su16, su16a, sizeof (su16)) != 0) + abort (); + if (sizeof (su32) != sizeof (su32a) + || memcmp (su32, su32a, sizeof (su32)) != 0) + abort (); + if (sizeof (tu) != sizeof (tua) + || memcmp (tu, tua, sizeof (tu)) != 0) + abort (); + if (sizeof (tu8) != sizeof (tu8a) + || memcmp (tu8, tu8a, sizeof (tu8)) != 0) + abort (); + if (sizeof (tu16) != sizeof (tu16a) + || memcmp (tu16, tu16a, sizeof (tu16)) != 0) + abort (); + if (sizeof (tu32) != sizeof (tu32a) + || memcmp (tu32, tu32a, sizeof (tu32)) != 0) + abort (); + if (sizeof (tl) != sizeof (tla) + || memcmp (tl, tla, sizeof (tl)) != 0) + abort (); + if (sizeof (ts) != sizeof (tsa) + || memcmp (ts, tsa, sizeof (ts)) != 0) + abort (); + if (sizeof (tm16) != sizeof (tm16a) + || memcmp (tm16, tm16a, sizeof (tm16)) != 0) + abort (); + if (sizeof (tm32) != sizeof (tm32a) + || memcmp (tm32, tm32a, sizeof (tm32)) != 0) + abort (); + if (u'\u0123' != 0x0123) + abort (); + if (U'\u0456' != 0x0456) + abort (); +#undef u8 +#define u8 + if (u8'a' != 'a') + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c11-uni-string-2.c b/SingleSource/Regression/C/gcc-dg/c11-uni-string-2.c new file mode 100644 index 0000000000..583c38a87e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-uni-string-2.c @@ -0,0 +1,8 @@ +/* Test Unicode strings in C11. Test constraint. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +const void *p1 = L"a" u8"b"; /* { dg-error "concatenation" } */ +const void *p2 = L"a" "b" u8"c"; /* { dg-error "concatenation" } */ +const void *p3 = u8"a" L"b"; /* { dg-error "concatenation" } */ +const void *p4 = u8"a" "b" L"c"; /* { dg-error "concatenation" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-unproto-1.c b/SingleSource/Regression/C/gcc-dg/c11-unproto-1.c new file mode 100644 index 0000000000..0949c7bc90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-unproto-1.c @@ -0,0 +1,25 @@ +/* Test compatibility of unprototyped and prototyped function types (C2x made + the case of types affected by default argument promotions compatible, before + removing unprototyped functions completely). Test affected usages are not + accepted for C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void f1 (); /* { dg-message "previous declaration" } */ +void f1 (float); /* { dg-error "conflicting types" } */ +/* { dg-message "default promotion" "" { target *-*-* } .-1 } */ + +void f2 (float); /* { dg-message "previous declaration" } */ +void f2 (); /* { dg-error "conflicting types" } */ +/* { dg-message "default promotion" "" { target *-*-* } .-1 } */ + +void f3 (); /* { dg-message "previous declaration" } */ +void f3 (char); /* { dg-error "conflicting types" } */ +/* { dg-message "default promotion" "" { target *-*-* } .-1 } */ + +void f4 (char); /* { dg-message "previous declaration" } */ +void f4 (); /* { dg-error "conflicting types" } */ +/* { dg-message "default promotion" "" { target *-*-* } .-1 } */ + +/* Built-in function case. */ +float sqrtf (); /* { dg-warning "conflicting types for built-in function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-unproto-2.c b/SingleSource/Regression/C/gcc-dg/c11-unproto-2.c new file mode 100644 index 0000000000..06da935336 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-unproto-2.c @@ -0,0 +1,22 @@ +/* Test compatibility of unprototyped and prototyped function types (C2x made + the case of types affected by default argument promotions compatible, before + removing unprototyped functions completely). Test always-invalid-in-C2x + usages, in C11 mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void f1 (); /* { dg-message "previous declaration" } */ +void f1 (int, ...); /* { dg-error "conflicting types" } */ +/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */ + +void f2 (int, ...); /* { dg-message "previous declaration" } */ +void f2 (); /* { dg-error "conflicting types" } */ +/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */ + +void f3 (); /* { dg-message "previous declaration" } */ +void f3 (char, ...); /* { dg-error "conflicting types" } */ +/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */ + +void f4 (char, ...); /* { dg-message "previous declaration" } */ +void f4 (); /* { dg-error "conflicting types" } */ +/* { dg-message "ellipsis" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c11-unproto-3.c b/SingleSource/Regression/C/gcc-dg/c11-unproto-3.c new file mode 100644 index 0000000000..b0e4bf3d5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-unproto-3.c @@ -0,0 +1,19 @@ +/* Test function declarations without prototypes for C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +void f1 (); +void +f1a (void) +{ + f1 (1, 2); +} + +void f2 (); +void f2 (int); + +void f3 (); + +_Static_assert (_Generic (f3, + void (*) (int) : 1, + default : 3) == 1, "unprototyped test"); diff --git a/SingleSource/Regression/C/gcc-dg/c11-unreachable-1.c b/SingleSource/Regression/C/gcc-dg/c11-unreachable-1.c new file mode 100644 index 0000000000..28e48392ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-unreachable-1.c @@ -0,0 +1,9 @@ +/* Test unreachable not defined in for C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef unreachable +#error "unreachable defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-utf8char-1.c b/SingleSource/Regression/C/gcc-dg/c11-utf8char-1.c new file mode 100644 index 0000000000..26dbd92b3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-utf8char-1.c @@ -0,0 +1,7 @@ +/* Test C2x UTF-8 characters. Test not accepted for C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#define z(x) 0 +#define u8 z( +unsigned char a = u8'a'); diff --git a/SingleSource/Regression/C/gcc-dg/c11-utf8str-type.c b/SingleSource/Regression/C/gcc-dg/c11-utf8str-type.c new file mode 100644 index 0000000000..8be9abb968 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-utf8str-type.c @@ -0,0 +1,6 @@ +/* Test C11 UTF-8 string literal type. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +_Static_assert (_Generic (u8"text", char*: 1, default: 2) == 1, "UTF-8 string literals have an unexpected type"); +_Static_assert (_Generic (u8"x"[0], char: 1, default: 2) == 1, "UTF-8 string literal elements have an unexpected type"); diff --git a/SingleSource/Regression/C/gcc-dg/c11-version-1.c b/SingleSource/Regression/C/gcc-dg/c11-version-1.c new file mode 100644 index 0000000000..9ab7936d1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C11. Test -std=c11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201112L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c11-version-2.c b/SingleSource/Regression/C/gcc-dg/c11-version-2.c new file mode 100644 index 0000000000..3ac2305f77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c11-version-2.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C11. Test -std=iso9899:2011. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:2011 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201112L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c17-nullptr-1.c b/SingleSource/Regression/C/gcc-dg/c17-nullptr-1.c new file mode 100644 index 0000000000..92e43b9df2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c17-nullptr-1.c @@ -0,0 +1,10 @@ +/* Test that in pre-C23 modes, nullptr is a normal identifier, + not a keyword. */ +/* { dg-options "-std=c17 -pedantic-errors" } */ + +int nullptr; + +void +f (int nullptr) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/c17-nullptr-2.c b/SingleSource/Regression/C/gcc-dg/c17-nullptr-2.c new file mode 100644 index 0000000000..a6ad7703ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c17-nullptr-2.c @@ -0,0 +1,10 @@ +/* Test that we don't predefine `nullptr' pre-C2X. */ +/* { dg-do compile } */ +/* { dg-options "-std=c17 -pedantic-errors" } */ + +int * +fn (int *p) +{ + p = nullptr; /* { dg-error "'nullptr' undeclared" } */ + return p; +} diff --git a/SingleSource/Regression/C/gcc-dg/c17-utf8str-type.c b/SingleSource/Regression/C/gcc-dg/c17-utf8str-type.c new file mode 100644 index 0000000000..515c6db397 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c17-utf8str-type.c @@ -0,0 +1,6 @@ +/* Test C17 UTF-8 string literal type. */ +/* { dg-do compile } */ +/* { dg-options "-std=c17" } */ + +_Static_assert (_Generic (u8"text", char*: 1, default: 2) == 1, "UTF-8 string literals have an unexpected type"); +_Static_assert (_Generic (u8"x"[0], char: 1, default: 2) == 1, "UTF-8 string literal elements have an unexpected type"); diff --git a/SingleSource/Regression/C/gcc-dg/c17-version-1.c b/SingleSource/Regression/C/gcc-dg/c17-version-1.c new file mode 100644 index 0000000000..4e69a6eec1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c17-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C17. Test -std=c17. */ +/* { dg-do compile } */ +/* { dg-options "-std=c17 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201710L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c17-version-2.c b/SingleSource/Regression/C/gcc-dg/c17-version-2.c new file mode 100644 index 0000000000..3f36720409 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c17-version-2.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C17. Test -std=iso9899:2017. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:2017 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201710L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c18-version-1.c b/SingleSource/Regression/C/gcc-dg/c18-version-1.c new file mode 100644 index 0000000000..9acd02461a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c18-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C17. Test -std=c18. */ +/* { dg-do compile } */ +/* { dg-options "-std=c18 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201710L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c18-version-2.c b/SingleSource/Regression/C/gcc-dg/c18-version-2.c new file mode 100644 index 0000000000..8786402bb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c18-version-2.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C17. Test -std=iso9899:2018. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:2018 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201710L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-align-1.c b/SingleSource/Regression/C/gcc-dg/c2x-align-1.c new file mode 100644 index 0000000000..25dbd62c55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-align-1.c @@ -0,0 +1,41 @@ +/* Test C2x alignment support. Test valid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +alignas (alignof (max_align_t)) char c; +extern alignas (max_align_t) char c; +extern char c; + +extern alignas (max_align_t) short s; +alignas (max_align_t) short s; + +alignas (int) int i; +extern int i; + +alignas (max_align_t) long l; + +alignas (max_align_t) long long ll; + +alignas (max_align_t) float f; + +alignas (max_align_t) double d; + +alignas (max_align_t) _Complex long double cld; + +alignas (0) alignas (int) alignas (char) char ca[10]; + +alignas ((int) alignof (max_align_t) + 0) int x; + +enum e { E = alignof (max_align_t) }; +alignas (E) int y; + +void +func (void) +{ + alignas (max_align_t) long long auto_ll; +} + +/* Valid, but useless. */ +alignas (0) struct s; /* { dg-warning "useless" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-align-6.c b/SingleSource/Regression/C/gcc-dg/c2x-align-6.c new file mode 100644 index 0000000000..8559a58d96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-align-6.c @@ -0,0 +1,8 @@ +/* Test C2x alignof returning minimum alignment for a type. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#define _Alignas alignas +#define _Alignof alignof + +#include "c11-align-6.c" diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-1.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-1.c new file mode 100644 index 0000000000..227c241bbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-1.c @@ -0,0 +1,99 @@ +/* Test C2x deprecated attribute: valid uses. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* Similar to tests from gnu2x-attrs-1.c, but using the standard + attribute instead of gnu::deprecated, and sometimes using + __deprecated__ or a string-literal argument. */ + +[[deprecated]] void f1 (void); + +[[deprecated]] typedef int dep_int; + +dep_int dv; /* { dg-warning "deprecated" } */ + +void +g (void) +{ + f1 (); /* { dg-warning "deprecated" } */ +} + +int +f2 (void) +{ + [[deprecated ("for this reason")]] int a = 1; + return a; /* { dg-warning "for this reason" } */ +} + +int +f3 (void) +{ + int a [[__deprecated__]] = 1; + return a; /* { dg-warning "deprecated" } */ +} + +struct s2 { [[__deprecated__("some other message")]] int a; int b [[deprecated]]; } x; + +int +f4 (void) +{ + return x.a; /* { dg-warning "some other message" } */ +} + +int +f5 (void) +{ + return x.b; /* { dg-warning "deprecated" } */ +} + +enum e { E1 [[deprecated("third message")]] }; + +enum e +f6 (void) +{ + return E1; /* { dg-warning "third message" } */ +} + +int +f7 ([[deprecated]] int y) +{ + return y; /* { dg-warning "deprecated" } */ +} + +union [[__deprecated__]] u { int x; }; + +void +f8 (void) +{ + union u var; /* { dg-warning "deprecated" } */ +} + +enum [[deprecated("edep reason")]] edep { E2 }; + +void +f9 (void) +{ + enum edep var; /* { dg-warning "edep reason" } */ +} + +union u2 { [[__deprecated__]] int a; int b [[deprecated]]; } y; + +int +f10 (void) +{ + return y.a; /* { dg-warning "deprecated" } */ +} + +int +f11 (void) +{ + return y.b; /* { dg-warning "deprecated" } */ +} + +struct [[deprecated]] s { int x; }; + +void +f12 (void) +{ + struct s var; /* { dg-warning "deprecated" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-2.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-2.c new file mode 100644 index 0000000000..7c01317d8f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-2.c @@ -0,0 +1,31 @@ +/* Test C2x deprecated attribute: invalid contexts. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* This attribute is not valid in most cases on types other than their + definitions, or on labels, or on statements, or as an + attribute-declaration. */ + +[[deprecated]]; /* { dg-error "ignored" } */ + +int [[deprecated]] var; /* { dg-error "ignored" } */ + +int array_with_dep_type[2] [[deprecated]]; /* { dg-error "ignored" } */ + +void fn_with_dep_type () [[deprecated]]; /* { dg-error "ignored" } */ + +int z = sizeof (int [[__deprecated__]]); /* { dg-error "ignored" } */ + +void +f (void) +{ + int a; + [[deprecated]]; /* { dg-error "ignored" } */ + [[deprecated]] a = 1; /* { dg-error "ignored" } */ + [[deprecated]] label: ; /* { dg-error "ignored" } */ + switch (var) + { + [[deprecated]] case 1: ; /* { dg-error "ignored" } */ + [[deprecated]] default: ; /* { dg-error "ignored" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-3.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-3.c new file mode 100644 index 0000000000..044725e512 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-3.c @@ -0,0 +1,11 @@ +/* Test C2x deprecated attribute: invalid syntax. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[deprecated()]] int a; /* { dg-error "parentheses must be omitted if attribute argument list is empty" } */ + +[[deprecated(0)]] int b; /* { dg-error "expected" } */ + +[[deprecated("", 123)]] int c; /* { dg-error "expected" } */ + +[[deprecated((""))]] int d; /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-4.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-4.c new file mode 100644 index 0000000000..7698434cc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-deprecated-4.c @@ -0,0 +1,11 @@ +/* Test C2x deprecated attribute: duplicates (allowed after N2557). */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[deprecated, __deprecated__]] int a; +[[__deprecated__, deprecated("message")]] int b; +int c [[deprecated("message"), deprecated]]; +[[deprecated, deprecated]]; +/* { dg-error "ignored" "ignored" { target *-*-* } .-1 } */ + +[[deprecated]] [[deprecated]] int d [[deprecated]] [[deprecated]]; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-1.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-1.c new file mode 100644 index 0000000000..60fe11da82 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-1.c @@ -0,0 +1,42 @@ +/* Test C2x attribute syntax. Valid use of fallthrough attribute. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wextra" } */ + +int +f (int a, int c) +{ + int b = 2; + switch (a) + { + case 1: + b = 1; /* { dg-warning "may fall through" } */ + case 2: + b = 2; + [[fallthrough]]; + case 3: + b += 7; + break; + case 4: + b = 5; + [[__fallthrough__]]; + case 5: + b += 1; + break; + case 6: + if (c == 2) + { + [[fallthrough]]; + } + else + { + [[fallthrough]]; + } + case 7: + b += 3; + [[fallthrough]]; + default: + b += 8; + break; + } + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-2.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-2.c new file mode 100644 index 0000000000..b65bcbef70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-2.c @@ -0,0 +1,42 @@ +/* Test C2x attribute syntax. Invalid use of fallthrough attribute. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wextra" } */ + +[[fallthrough]]; /* { dg-error "'fallthrough' attribute at top level" } */ + +int [[fallthrough]] x; /* { dg-error "ignored" } */ + +int g () [[fallthrough]]; /* { dg-error "ignored" } */ + +int array[2] [[fallthrough]]; /* { dg-error "ignored" } */ + +int z = sizeof (int [[fallthrough]]); /* { dg-error "ignored" } */ + +int +f (int a) +{ + [[fallthrough]] int b = 2; /* { dg-warning "not followed by" } */ + /* { dg-error "ignored" "ignored" { target *-*-* } .-1 } */ + switch (a) + { + case 1: + b = 1; /* { dg-warning "may fall through" } */ + case 2: + b = 2; /* { dg-warning "may fall through" } */ + [[fallthrough()]]; /* { dg-error "does not take any arguments" } */ + case 3: + b += 7; + break; + case 4: + b = 4; /* { dg-warning "may fall through" } */ + [[fallthrough(1)]]; /* { dg-error "does not take any arguments|expected" } */ + case 5: + b += 5; + break; + [[fallthrough]] case 6: break; /* { dg-error "ignored" } */ + [[fallthrough]] default: break; /* { dg-error "ignored" } */ + } + [[fallthrough]] return b; /* { dg-error "ignored" } */ + [[fallthrough]] label: ; /* { dg-error "ignored" } */ + goto label; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-3.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-3.c new file mode 100644 index 0000000000..714d0af947 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-3.c @@ -0,0 +1,11 @@ +/* Test C2x attribute syntax. Invalid use of fallthrough attribute + outside switch. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wextra" } */ + +int +f (int a) +{ + [[fallthrough]]; /* { dg-error "invalid use of attribute 'fallthrough'" } */ + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-4.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-4.c new file mode 100644 index 0000000000..a6cedcd004 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-4.c @@ -0,0 +1,20 @@ +/* Test C2x fallthrough attribute: duplicates (allowed after N2557). */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int +f (int a) +{ + switch (a) + { + case 1: + a++; + [[fallthrough, __fallthrough__]]; /* { dg-warning "specified multiple times" } */ + case 2: + a++; + [[fallthrough]] [[fallthrough]]; /* { dg-warning "specified multiple times" } */ + case 3: + a++; + } + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-5.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-5.c new file mode 100644 index 0000000000..c614ceba20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-5.c @@ -0,0 +1,30 @@ +/* Test C2x fallthrough attribute: mixtures with other attributes. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* Use of other standard attributes together with "fallthrough" goes + through a different path to diagnosing ignored attributes from that + used in attribute declarations without "fallthrough". Verify that + such ignored attributes result in a pedwarn (for use in a context + not permitted in the constraints for those attributes) in this case + as well. */ + +int +f (int a) +{ + switch (a) + { + case 1: + a++; + [[fallthrough, deprecated]]; /* { dg-error "attribute ignored" } */ + case 2: + a++; + [[maybe_unused]] [[fallthrough]]; /* { dg-error "attribute ignored" } */ + case 3: + a++; + [[__nodiscard__, fallthrough]]; /* { dg-error "attribute ignored" } */ + case 4: + a++; + } + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-6.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-6.c new file mode 100644 index 0000000000..aa7ff4cdd2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-fallthrough-6.c @@ -0,0 +1,18 @@ +/* Test C2x attribute syntax. Invalid use of fallthrough attribute in + bad context inside switch. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wextra" } */ + +int +f (int a) +{ + switch (a) + { + case 1: + a++; + [[fallthrough]]; /* { dg-error "attribute 'fallthrough' not preceding a case label or default label" } */ + a++; + [[fallthrough]]; /* { dg-error "attribute 'fallthrough' not preceding a case label or default label" } */ + } + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-1.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-1.c new file mode 100644 index 0000000000..7090a3f30e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-1.c @@ -0,0 +1,44 @@ +/* Test C2x maybe_unused attribute: valid uses. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wall -Wextra -Wunused" } */ + +[[maybe_unused]] static void f1 (void) {} + +[[__maybe_unused__]] const int c1 = 1; +static int c2 [[maybe_unused]] = 2; + +int +g ([[maybe_unused]] int x, int y) +{ + [[maybe_unused]] typedef float F; + [[maybe_unused]] int a; + int b [[__maybe_unused__]]; + int c [[maybe_unused]]; + [[__maybe_unused__]] label1: + c = y; + [[maybe_unused]] label2: + return y; +} + +struct [[maybe_unused]] s { double d; }; + +struct s2 { [[__maybe_unused__]] int a; int b [[maybe_unused]]; } x; + +enum e { E1 [[maybe_unused]] }; + +union [[maybe_unused]] u { int x; }; + +enum [[maybe_unused]] eu { E2 }; + +union u2 { [[maybe_unused]] int a; int b [[maybe_unused]]; } y; + +void +g2 (int x) +{ + switch (x) + { + [[maybe_unused]] case 1: ; + [[__maybe_unused__]] case 2: ; + [[maybe_unused]] default: ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-2.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-2.c new file mode 100644 index 0000000000..a749639192 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-2.c @@ -0,0 +1,24 @@ +/* Test C2x maybe_unused attribute: invalid contexts. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* This attribute is not valid in most cases on types other than their + definitions, or on statements, or as an attribute-declaration. */ + +[[maybe_unused]]; /* { dg-error "ignored" } */ + +int [[maybe_unused]] var; /* { dg-error "ignored" } */ + +int array_with_dep_type[2] [[maybe_unused]]; /* { dg-error "ignored" } */ + +void fn_with_dep_type () [[maybe_unused]]; /* { dg-error "ignored" } */ + +int z = sizeof (int [[__maybe_unused__]]); /* { dg-error "ignored" } */ + +void +f (void) +{ + int a; + [[maybe_unused]]; /* { dg-error "ignored" } */ + [[maybe_unused]] a = 1; /* { dg-error "ignored" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-3.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-3.c new file mode 100644 index 0000000000..4d4da0867c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-3.c @@ -0,0 +1,11 @@ +/* Test C2x maybe_unused attribute: invalid syntax. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[maybe_unused()]] int a; /* { dg-error "does not take any arguments" } */ + +[[maybe_unused(0)]] int b; /* { dg-error "does not take any arguments|expected" } */ + +[[maybe_unused("", 123)]] int c; /* { dg-error "does not take any arguments|expected" } */ + +[[maybe_unused("")]] int d; /* { dg-error "does not take any arguments|expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-4.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-4.c new file mode 100644 index 0000000000..6b997aa003 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-maybe_unused-4.c @@ -0,0 +1,11 @@ +/* Test C2x maybe_unused attribute: duplicates (allowed after N2557). */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[maybe_unused, __maybe_unused__]] int a; +[[__maybe_unused__, maybe_unused]] int b; +int c [[maybe_unused, maybe_unused]]; +[[maybe_unused, maybe_unused]]; +/* { dg-error "ignored" "ignored" { target *-*-* } .-1 } */ + +[[maybe_unused]] [[maybe_unused]] int d [[maybe_unused]] [[maybe_unused]]; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-1.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-1.c new file mode 100644 index 0000000000..f4893bd123 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-1.c @@ -0,0 +1,62 @@ +/* Test C2x deprecated attribute: valid uses. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[nodiscard]] int c1 (void); /* { dg-message "declared here" } */ +[[__nodiscard__ ("some reason")]] int c2 (void); /* { dg-message "declared here" } */ + +struct [[nodiscard ("struct reason")]] s1 { int a; }; +struct [[__nodiscard__]] s2 { long b; }; +struct s1 cs1 (void); /* { dg-message "declared here" } */ +struct s2 cs2 (void); /* { dg-message "declared here" } */ +typedef struct s2 s2t; +s2t cs3 (void); /* { dg-message "declared here" } */ + +union [[nodiscard]] u1 { int a; long b; }; +union [[nodiscard ("union reason")]] u2 { short c; float d; }; +union u1 cu1 (void); /* { dg-message "declared here" } */ +union u2 cu2 (void); /* { dg-message "declared here" } */ + +enum [[nodiscard]] e1 { E1 }; +enum [[nodiscard ("enum reason")]] e2 { E2 }; +enum e1 ce1 (void); /* { dg-message "declared here" } */ +enum e2 ce2 (void); /* { dg-message "declared here" } */ +enum e1 ce1a (void); +int i; + +[[nodiscard]] void v (void); /* { dg-warning "void return type" } */ + +int ok (void); + +void +f (void) +{ + c1 (); /* { dg-warning "ignoring return value" } */ + c2 (); /* { dg-warning "some reason" } */ + cs1 (); /* { dg-warning "struct reason" } */ + cs2 (); /* { dg-warning "ignoring return value of type" } */ + cs3 (); /* { dg-warning "ignoring return value of type" } */ + cu1 (); /* { dg-warning "ignoring return value of type" } */ + cu2 (); /* { dg-warning "union reason" } */ + ce1 (); /* { dg-warning "ignoring return value of type" } */ + ce2 (); /* { dg-warning "enum reason" } */ + ok (); + c1 (), ok (); /* { dg-warning "ignoring return value" } */ + cs1 (), ok (); /* { dg-warning "struct reason" } */ + ok (), cu1 (); /* { dg-warning "ignoring return value" } */ + ok (), (ok (), (ok (), ce2 ())); /* { dg-warning "enum reason" } */ + (ok (), cu1 ()), ok (); /* { dg-warning "ignoring return value" } */ + v (); + (i ? ce1 : ce1a) (); /* { dg-warning "ignoring return value of type" } */ + (void) c1 (); + (void) c2 (); + (void) cs1 (); + (void) cs2 (); + (void) cs3 (); + (void) cu1 (); + (void) cu2 (); + (void) ce1 (); + (void) ce2 (); + (void) (ok (), cu1 ()); + (void) (i ? ce1 : ce1a) (); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-2.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-2.c new file mode 100644 index 0000000000..0ed2ebe92f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-2.c @@ -0,0 +1,48 @@ +/* Test C2x nodiscard attribute: invalid contexts. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* This attribute is not valid on types other than their definitions, + or on declarations other than function declarations, or on + statements, or as an attribute-declaration. */ + +[[nodiscard]]; /* { dg-error "ignored" } */ + +int [[nodiscard]] var; /* { dg-error "ignored" } */ + +int [[nodiscard ("reason")]] var2; /* { dg-error "ignored" } */ + +int array_with_nod_type[2] [[nodiscard]]; /* { dg-error "ignored" } */ + +void fn_with_nod_type () [[nodiscard]]; /* { dg-error "ignored" } */ + +int z = sizeof (int [[__nodiscard__]]); /* { dg-error "ignored" } */ + +[[nodiscard]] typedef int nod_int; /* { dg-error "can only be applied" } */ + +[[nodiscard]] int nvar; /* { dg-error "can only be applied" } */ + +struct s { int a; }; + +[[nodiscard]] typedef struct s nod_s; /* { dg-error "can only be applied" } */ + +struct t { [[nodiscard]] int b; }; /* { dg-error "can only be applied" } */ + +enum e { E [[nodiscard]] }; /* { dg-error "can only be applied" } */ + +void fx ([[nodiscard]] int p); /* { dg-error "can only be applied" } */ + +void +f (void) +{ + int a; + [[nodiscard ("reason")]] int b = 1; /* { dg-error "can only be applied" } */ + [[nodiscard]]; /* { dg-error "ignored" } */ + [[nodiscard]] a = 1; /* { dg-error "ignored" } */ + [[nodiscard]] label: ; /* { dg-error "can only be applied" } */ + switch (var) + { + [[nodiscard]] case 1: ; /* { dg-error "can only be applied" } */ + [[nodiscard]] default: ; /* { dg-error "can only be applied" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-3.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-3.c new file mode 100644 index 0000000000..2e70d12bff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-3.c @@ -0,0 +1,11 @@ +/* Test C2x nodiscard attribute: invalid syntax. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[nodiscard()]] int a (void); /* { dg-error "parentheses must be omitted if attribute argument list is empty" } */ + +[[nodiscard(0)]] int b (void); /* { dg-error "expected" } */ + +[[nodiscard("", 123)]] int c (void); /* { dg-error "expected" } */ + +[[nodiscard((""))]] int d (void); /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-4.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-4.c new file mode 100644 index 0000000000..278f55d1e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-nodiscard-4.c @@ -0,0 +1,6 @@ +/* Test C2x nodiscard attribute: duplicates (allowed after N2557). */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[nodiscard, __nodiscard__]] int f (void); +[[__nodiscard__, nodiscard("message")]] int g (void); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-1.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-1.c new file mode 100644 index 0000000000..d903c09a9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-1.c @@ -0,0 +1,56 @@ +/* Test C2x noreturn attribute: valid uses. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[noreturn]] void exit (int); + +[[__noreturn__]] int f1 (void); + +[[_Noreturn]] void f2 (void); + +[[___Noreturn__]] static void f3 (void) { exit (0); } + +/* Returning from a noreturn function is undefined at runtime, not a + constraint violation, but recommended practice is to diagnose if + such a return appears possible. */ + +[[noreturn]] int +f4 (void) +{ + return 1; /* { dg-warning "has a 'return' statement" } */ + /* { dg-warning "does return" "second warning" { target *-*-* } .-1 } */ +} + +[[__noreturn__]] void +f5 (void) +{ + return; /* { dg-warning "has a 'return' statement" } */ + /* { dg-warning "does return" "second warning" { target *-*-* } .-1 } */ +} + +[[_Noreturn]] void +f6 (void) +{ +} /* { dg-warning "does return" } */ + +[[___Noreturn__]] void +f7 (int a) +{ + if (a) + exit (0); +} /* { dg-warning "does return" } */ + +/* Declarations need not all have the attribute (buf if the first does not, + there is undefined behavior). */ + +void f2 (void); + +/* Duplicate attribute, and use with _Noreturn, is OK. */ +[[noreturn]] [[noreturn]] [[noreturn, __noreturn__]] void _Noreturn f9 (void); + +/* The attribute does not affect type compatibility. */ + +void (*fp) (void) = f5; + +/* Unlike the function specifier, the attribute may be used on main. */ +[[noreturn]] int main (); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-2.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-2.c new file mode 100644 index 0000000000..331da4a6b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-2.c @@ -0,0 +1,72 @@ +/* Test C2x noreturn attribute: invalid contexts. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[noreturn]]; /* { dg-error "ignored" } */ + +int [[noreturn]] var; /* { dg-error "ignored" } */ + +int array_with_dep_type[2] [[noreturn]]; /* { dg-error "ignored" } */ + +void fn_with_dep_type () [[noreturn]]; /* { dg-error "ignored" } */ + +int z = sizeof (int [[__noreturn__]]); /* { dg-error "ignored" } */ + +[[noreturn]] int x1; /* { dg-error "can only be applied to functions" } */ +int x2 [[__noreturn__]]; /* { dg-error "can only be applied to functions" } */ + +[[_Noreturn]] void (*fp) (); /* { dg-error "can only be applied to functions" } */ + +void +f (void) +{ + int a; + [[_Noreturn]]; /* { dg-error "ignored" } */ + [[___Noreturn__]] a = 1; /* { dg-error "ignored" } */ +} + +int +g ([[noreturn]] int x, int y) /* { dg-error "can only be applied to functions" } */ +{ + [[noreturn]] typedef float F; /* { dg-error "can only be applied to functions" } */ + [[noreturn]] int a; /* { dg-error "can only be applied to functions" } */ + int b [[__noreturn__]]; /* { dg-error "can only be applied to functions" } */ + int c [[noreturn]]; /* { dg-error "can only be applied to functions" } */ + [[__noreturn__]] label1: ; /* { dg-error "can only be applied to functions" } */ + c = y; + [[noreturn]] label2: ; /* { dg-error "can only be applied to functions" } */ + return y; +} + +struct [[_Noreturn]] s { double d; }; /* { dg-error "can only be applied to functions" } */ + +struct s2 +{ + [[___Noreturn__]] int a; /* { dg-error "can only be applied to functions" } */ + int b [[noreturn]]; /* { dg-error "can only be applied to functions" } */ +} x; + +enum e { E1 [[noreturn]] }; /* { dg-error "can only be applied to functions" } */ + +union [[_Noreturn]] u { int x; }; /* { dg-error "can only be applied to functions" } */ + +enum [[noreturn]] eu { E2 }; /* { dg-error "can only be applied to functions" } */ + +void fx ([[noreturn]] int p); /* { dg-error "can only be applied" } */ + +union u2 +{ + [[noreturn]] int a; /* { dg-error "can only be applied to functions" } */ + int b [[noreturn]]; /* { dg-error "can only be applied to functions" } */ +} y; + +void +g2 (int x) +{ + switch (x) + { + [[noreturn]] case 1: ; /* { dg-error "can only be applied to functions" } */ + [[__noreturn__]] case 2: ; /* { dg-error "can only be applied to functions" } */ + [[noreturn]] default: ; /* { dg-error "can only be applied to functions" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-3.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-3.c new file mode 100644 index 0000000000..aaf21e22a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-noreturn-3.c @@ -0,0 +1,11 @@ +/* Test C2x noreturn attribute: invalid syntax. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[noreturn()]] void a(); /* { dg-error "does not take any arguments" } */ + +[[__noreturn__(0)]] void b(); /* { dg-error "does not take any arguments|expected" } */ + +[[_Noreturn("", 123)]] void c(); /* { dg-error "does not take any arguments|expected" } */ + +[[___Noreturn__("")]] void d(); /* { dg-error "does not take any arguments|expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-1.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-1.c new file mode 100644 index 0000000000..48e2591258 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-1.c @@ -0,0 +1,55 @@ +/* Test C2x attribute syntax. Basic tests of valid uses of empty + attributes. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[ [ ] ] [[]]; + +[[]] int [[]] a [[]] = 123; + +int f([[]] int x [[]], [[]] long [[]], short [[]] *[[]] [3] [[]], + int [[]] (int)[[]], int (*)(int)[[]]) [[]] [[]]; + +int g [[]] [2] [[]] [3] [[]]; + +int *[[]] const *[[]] volatile *[[]] *const p; + +int *[[]][[]] q = 0; + +struct [[]] s; +union [[]][[]] u; + +struct [[]] s2 { [[]] long [[]] *a[[]] [3] [[]] [4], b[[]]; }; + +union [[]] u2 { [[]] long [[]] *a[[]] [3] [[]] [4]; }; + +int z = sizeof (int [[]]); + +enum [[]] { E1 [[]][[]], E2[[]][[]] = 3 }; +enum [[]] e { E3 = 4, E4 [[]] }; + +void +func (void) [[]] +{ + [[]] int var; + [[]] { } + [[]] switch (a) { [[]] case 1: [[]] case 2: [[]] default: [[]] var = 3; } + [[]] x : [[]] y: [[]] var = 1; + [[]]; + int [[]] var2; + [[]] if (a) [[]] (void) 0; else [[]] (void) 1; + [[]] while (0) [[]] var = 2; + [[]] do [[]] var = 3; while (0); + for ([[]] int zz = 1; zz < 10; zz++) + { + [[]] var2 = 8; + [[]] continue; + [[]] break; + } + if (a) [[]] goto x; + [[]] return; +} + +void func2 () [[]]; + +void func3 () [[]] { } diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-2.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-2.c new file mode 100644 index 0000000000..ceca9501ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-2.c @@ -0,0 +1,60 @@ +/* Test C2x attribute syntax. Test ignored attributes diagnosed. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* A GNU attribute that is valid in some contexts, but should be + diagnosed in contexts where all attributes are ignored (attribute + declarations, except for fallthrough attributes, and + statements). */ +#define CTX [[gnu::const]] + +/* An attribute that is unknown, so ignored with a warning. */ +#define UNK [[gnu::no_such_attribute(![!(!)!]!,;;)]] + +CTX; /* { dg-warning "ignored" } */ +UNK; /* { dg-warning "ignored" } */ + +UNK extern int a; /* { dg-warning "ignored" } */ +extern int UNK a; /* { dg-warning "ignored" } */ +extern int a UNK; /* { dg-warning "ignored" } */ + +int f () UNK; /* { dg-warning "ignored" } */ +int f (void) UNK; /* { dg-warning "ignored" } */ +int g (UNK int a); /* { dg-warning "ignored" } */ +int g (int UNK a); /* { dg-warning "ignored" } */ +int g (int a UNK); /* { dg-warning "ignored" } */ +int g (UNK int); /* { dg-warning "ignored" } */ +int g (int UNK); /* { dg-warning "ignored" } */ +int g (int) UNK; /* { dg-warning "ignored" } */ + +int *UNK p; /* { dg-warning "ignored" } */ +int b[3] UNK; /* { dg-warning "ignored" } */ + +int h (int () UNK); /* { dg-warning "ignored" } */ + +struct UNK s; /* { dg-warning "ignored" } */ +union UNK u; /* { dg-warning "ignored" } */ + +struct UNK s2 { int a; }; /* { dg-warning "ignored" } */ +union UNK u2 { int a; }; /* { dg-warning "ignored" } */ + +struct s3 { UNK int a; }; /* { dg-warning "ignored" } */ +struct s4 { int UNK a; }; /* { dg-warning "ignored" } */ +union u3 { UNK int a; }; /* { dg-warning "ignored" } */ +union u4 { int UNK a; }; /* { dg-warning "ignored" } */ + +int z = sizeof (int UNK); /* { dg-warning "ignored" } */ + +enum UNK { E1 }; /* { dg-warning "ignored" } */ +enum { E2 UNK }; /* { dg-warning "ignored" } */ +enum { E3 UNK = 4 }; /* { dg-warning "ignored" } */ + +void +func (void) UNK { /* { dg-warning "ignored" } */ + UNK int var; /* { dg-warning "ignored" } */ + CTX { } /* { dg-warning "ignored" } */ + CTX; /* { dg-warning "ignored" } */ + CTX var = 1; /* { dg-warning "ignored" } */ + CTX x: var = 2; /* { dg-warning "ignored" } */ + for (UNK int zz = 1; zz < 10; zz++) ; /* { dg-warning "ignored" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-3.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-3.c new file mode 100644 index 0000000000..2f0d9f60cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-3.c @@ -0,0 +1,57 @@ +/* Test C2x attribute syntax. Invalid uses of attributes. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* Prefix attributes not allowed on declarations without declarators. */ + +[[]] struct s { int a; }; /* { dg-error "empty declaration" } */ + +[[]] union u { int a; }; /* { dg-error "empty declaration" } */ + +void +f1 (void) +{ + [[]] struct t { int a; }; /* { dg-error "empty declaration" } */ +} + +/* Prefix attributes not allowed on _Static_assert. */ + +[[]] _Static_assert (1); /* { dg-error "expected" } */ + +void +f2 (void) +{ + [[]] _Static_assert (1); /* { dg-error "expected" } */ +} + +/* Declarations, including attribute declarations, cannot appear after + labels when a statement is expected. */ + +void +f3 (void) +{ + if (1) + x: [[]]; /* { dg-error "expected" } */ +} + +/* Prefix attributes cannot appear on type names. */ + +int z = sizeof ([[]] int); /* { dg-error "expected" } */ + +/* Attributes are not allowed after struct, union or enum, except when + the type contents are being defined or the declaration is just + "struct-or-union atribute-specifier-sequence identifier;". */ + +const struct [[]] s2; /* { dg-warning "useless type qualifier" } */ +/* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */ + +const union [[]] u2; /* { dg-warning "useless type qualifier" } */ +/* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */ + +struct [[]] s3 *sv; /* { dg-error "expected" } */ + +union [[]] u3 *uv; /* { dg-error "expected" } */ + +enum e { E1 }; + +enum [[]] e *ev; /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-4.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-4.c new file mode 100644 index 0000000000..30c966817b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-4.c @@ -0,0 +1,7 @@ +/* Test C2x attribute syntax: diagnosed with -Wc11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +[[]]; /* { dg-warning "attributes before C2X" } */ + +void f [[]] (void); /* { dg-warning "attributes before C2X" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-5.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-5.c new file mode 100644 index 0000000000..b261be067c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-5.c @@ -0,0 +1,51 @@ +/* Test C2x attribute syntax. Test unknown standard attributes + diagnosed with a pedwarn. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +[[unknown_attribute]]; /* { dg-error "attribute ignored" } */ + +[[unknown_attribute]] extern int a; /* { dg-error "attribute ignored" } */ +extern int [[unknown_attribute(123)]] a; /* { dg-error "attribute ignored" } */ +extern int a [[unknown_attribute("")]]; /* { dg-error "attribute ignored" } */ + +int f () [[unknown_attribute]]; /* { dg-error "attribute ignored" } */ +int f (void) [[unknown_attribute(1)]]; /* { dg-error "attribute ignored" } */ +int g ([[unknown_attribute]] int a); /* { dg-error "attribute ignored" } */ +int g (int [[unknown_attribute]] a); /* { dg-error "attribute ignored" } */ +int g (int a [[unknown_attribute]]); /* { dg-error "attribute ignored" } */ +int g ([[unknown_attribute]] int); /* { dg-error "attribute ignored" } */ +int g (int [[unknown_attribute]]); /* { dg-error "attribute ignored" } */ +int g (int) [[unknown_attribute]]; /* { dg-error "attribute ignored" } */ + +int *[[unknown_attribute]] p; /* { dg-error "attribute ignored" } */ +int b[3] [[unknown_attribute]]; /* { dg-error "attribute ignored" } */ + +int h (int () [[unknown_attribute]]); /* { dg-error "attribute ignored" } */ + +struct [[unknown_attribute]] s; /* { dg-error "attribute ignored" } */ +union [[unknown_attribute]] u; /* { dg-error "attribute ignored" } */ + +struct [[unknown_attribute]] s2 { int a; }; /* { dg-error "attribute ignored" } */ +union [[unknown_attribute(x)]] u2 { int a; }; /* { dg-error "attribute ignored" } */ + +struct s3 { [[unknown_attribute]] int a; }; /* { dg-error "attribute ignored" } */ +struct s4 { int [[unknown_attribute]] a; }; /* { dg-error "attribute ignored" } */ +union u3 { [[unknown_attribute]] int a; }; /* { dg-error "attribute ignored" } */ +union u4 { int [[unknown_attribute]] a; }; /* { dg-error "attribute ignored" } */ + +int z = sizeof (int [[unknown_attribute]]); /* { dg-error "attribute ignored" } */ + +enum [[unknown_attribute]] { E1 }; /* { dg-error "attribute ignored" } */ +enum { E2 [[unknown_attribute]] }; /* { dg-error "attribute ignored" } */ +enum { E3 [[unknown_attribute]] = 4 }; /* { dg-error "attribute ignored" } */ + +void +func (void) [[unknown_attribute]] { /* { dg-error "attribute ignored" } */ + [[unknown_attribute]] int var; /* { dg-error "attribute ignored" } */ + [[unknown_attribute]] { } /* { dg-error "attribute ignored" } */ + [[unknown_attribute(!)]]; /* { dg-error "attribute ignored" } */ + [[unknown_attribute]] var = 1; /* { dg-error "attribute ignored" } */ + [[unknown_attribute]] x: var = 2; /* { dg-error "attribute ignored" } */ + for ([[unknown_attribute]] int zz = 1; zz < 10; zz++) ; /* { dg-error "attribute ignored" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-6.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-6.c new file mode 100644 index 0000000000..9e5f65ce46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-6.c @@ -0,0 +1,62 @@ +/* Test C2x attribute syntax: use of __extension__ in C11 mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#define FOO :: +#define BAR : +#define JOIN(A, B) A/**/B +#define JOIN2(A, B) A##B + +typedef int [[__extension__ gnu::vector_size (4)]] g1; +typedef int [[__extension__ gnu :: vector_size (4)]] g2; +typedef int [[__extension__ gnu : : vector_size (4)]] g3; +typedef int [[__extension__ gnu: :vector_size (4)]] g4; +typedef int [[__extension__ gnu FOO vector_size (4)]] g5; +typedef int [[__extension__ gnu BAR BAR vector_size (4)]] g6; +typedef int [[__extension__ gnu :/**/: vector_size (4)]] g7; +typedef int [[__extension__ gnu JOIN(:,:) vector_size (4)]] g8; +typedef int [[__extension__ gnu :: vector_size (sizeof (void (*)(...)))]] g10; +typedef int [[__extension__]] g11; +typedef int [[__extension__,]] g12; +typedef int [[__extension__, ,,,, ,, ,]] g13; +[[__extension__ deprecated]] int g14 (); +[[__extension__ nodiscard]] int g15 (); +[[__extension__ noreturn]] void g16 (); + +int +cases (int x) +{ + switch (x) + { + case 1: + case 2: + case 4: + x += 1; + [[__extension__ fallthrough]]; + case 19: + case 33: + x *= 2; + [[fallthrough]]; /* { dg-error {attributes before C2X} } */ + case 99: + return x; + + default: + return 0; + } +} + +typedef int [[__extension__ vector_size (4)]] b1; /* { dg-error {'vector_size' attribute ignored} } */ +typedef int [[__extension__ __extension__]] b2; /* { dg-error {'extension' attribute ignored} } */ +typedef int [[__extension__ unknown_attribute]] b3; /* { dg-error {'unknown_attribute' attribute ignored} } */ +typedef int [[__extension__ gnu:vector_size(4)]] b4; /* { dg-error {expected '\]' before ':'} } */ +/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-1 } */ +typedef int [[__extension__ gnu JOIN2(:,:) vector_size (4)]] b5; /* { dg-error {pasting ":" and ":" does not give a valid preprocessing token} } */ +typedef int [[gnu::vector_size(4)]] b6; /* { dg-error {expected '\]' before ':'} } */ +/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-1 } */ +/* { dg-error {attributes before C2X} "" { target *-*-* } .-2 } */ +typedef int [[gnu : : vector_size(4)]] b7; /* { dg-error {expected '\]' before ':'} } */ +/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-1 } */ +/* { dg-error {attributes before C2X} "" { target *-*-* } .-2 } */ +typedef int [[gnu : vector_size(4)]] b8; /* { dg-error {expected '\]' before ':'} } */ +/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-1 } */ +/* { dg-error {attributes before C2X} "" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-7.c b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-7.c new file mode 100644 index 0000000000..702f733b17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-attr-syntax-7.c @@ -0,0 +1,60 @@ +/* Test C2x attribute syntax: use of __extension__ in C11 mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +#define FOO :: +#define BAR : +#define JOIN(A, B) A/**/B +#define JOIN2(A, B) A##B + +typedef int [[__extension__ gnu::vector_size (4)]] g1; +typedef int [[__extension__ gnu :: vector_size (4)]] g2; +typedef int [[__extension__ gnu : : vector_size (4)]] g3; +typedef int [[__extension__ gnu: :vector_size (4)]] g4; +typedef int [[__extension__ gnu FOO vector_size (4)]] g5; +typedef int [[__extension__ gnu BAR BAR vector_size (4)]] g6; +typedef int [[__extension__ gnu :/**/: vector_size (4)]] g7; +typedef int [[__extension__ gnu JOIN(:,:) vector_size (4)]] g8; +typedef int [[__extension__ gnu :: vector_size (sizeof (void (*)(...)))]] g10; +typedef int [[__extension__]] g11; +typedef int [[__extension__,]] g12; +typedef int [[__extension__, ,,,, ,, ,]] g13; +[[__extension__ deprecated]] int g14 (); +[[__extension__ nodiscard]] int g15 (); +[[__extension__ noreturn]] void g16 (); + +int +cases (int x) +{ + switch (x) + { + case 1: + case 2: + case 4: + x += 1; + [[__extension__ fallthrough]]; + case 19: + case 33: + x *= 2; + [[fallthrough]]; /* { dg-warning {attributes before C2X} } */ + case 99: + return x; + + default: + return 0; + } +} + +typedef int [[__extension__ vector_size (4)]] b1; /* { dg-error {'vector_size' attribute ignored} } */ +typedef int [[__extension__ __extension__]] b2; /* { dg-error {'extension' attribute ignored} } */ +typedef int [[__extension__ unknown_attribute]] b3; /* { dg-error {'unknown_attribute' attribute ignored} } */ +typedef int [[__extension__ gnu:vector_size(4)]] b4; /* { dg-error {expected '\]' before ':'} } */ +/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-1 } */ +typedef int [[__extension__ gnu JOIN2(:,:) vector_size (4)]] b5; +typedef int [[gnu::vector_size(4)]] b6; /* { dg-warning {attributes before C2X} } */ +typedef int [[gnu : : vector_size(4)]] b7; /* { dg-error {expected '\]' before ':'} } */ +/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-1 } */ +/* { dg-warning {attributes before C2X} "" { target *-*-* } .-2 } */ +typedef int [[gnu : vector_size(4)]] b8; /* { dg-error {expected '\]' before ':'} } */ +/* { dg-error {'gnu' attribute ignored} "" { target *-*-* } .-1 } */ +/* { dg-warning {attributes before C2X} "" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-auto-1.c b/SingleSource/Regression/C/gcc-dg/c2x-auto-1.c new file mode 100644 index 0000000000..c50daccfe8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-auto-1.c @@ -0,0 +1,81 @@ +/* Test C2x auto. Valid code, compilation tests. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +auto i = 1; +extern int i; +static auto l = 0L; +extern long l; +extern auto const d = 0.0; /* { dg-warning "initialized and declared 'extern'" } */ +extern const double d; +double dx; +auto ((i2)) = 3; +extern int i2; +const auto i3 [[]] = 4; +extern int i4; +thread_local auto f = 1.0f; +float ff; +extern typeof (f) ff; +auto h = (short) 0; +extern short h; + +struct s { int a; }; +struct s sv; +struct s2; +enum e : int; + +extern const volatile long double cvld; +extern void (*tfp) (void); + +int a[10]; +int *ap; + +typedef int ti; + +void +tf () +{ + auto asv = (struct s) { 0 }; + extern typeof (asv) sv; + auto s2p = (struct s2 *) 0; + struct s3; + auto s3p = (struct s3 *) 0; + auto ev = (enum e) 0; + static const auto volatile acvld = 0.5L; + extern typeof (acvld) cvld; + /* lvalue conversion occurs on the initializer, so losing qualifiers. */ + auto ncd = d; + extern typeof (ncd) dx; + _Atomic double ad = 0.0; + auto nad = ad; + extern typeof (nad) dx; + /* Function-to-pointer conversion occurs on the initializer. */ + auto fp = tf; + extern typeof (fp) tfp; + /* Array-to-pointer conversion occurs on the initializer. */ + auto aap = a; + extern typeof (aap) ap; + /* Shadowing a declaration from a containing scope is OK. */ + auto i = 2L; + extern typeof (i) l; + /* auto can be used in for loops. */ + for (auto ix = 2; ix < 10; ix++) + { + extern typeof (ix) i2; + } + /* auto is valid with bit-field initializers; the choice of type those have + in expressions is unspecified but should match how _Generic handles such + expressions. */ + struct b { int a : 2; unsigned b : 3; } bv = { }; + auto bfa = bv.a; + auto bfb = bv.b; + static_assert (_Generic (bv.a, typeof (bfa) : 1, default : 2) == 1); + static_assert (_Generic (bv.b, typeof (bfb) : 1, default : 2) == 1); + /* The traditional meaning of auto with a type specifier is OK. */ + auto short s; + char auto c; + auto struct t { int x; } t; + /* That includes the case where the type comes from a typedef name. */ + auto ti int_from_typedef = 3.0; + extern typeof (int_from_typedef) i2; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-auto-2.c b/SingleSource/Regression/C/gcc-dg/c2x-auto-2.c new file mode 100644 index 0000000000..a41f813018 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-auto-2.c @@ -0,0 +1,38 @@ +/* Test C2x auto. Valid code, execution tests. Based on auto-type-1.c. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-require-effective-target alloca } */ + +extern void abort (void); +extern void exit (int); + +auto i = 1; +extern int i; +auto c = (char) 1; +extern char c; +static auto u = 10U; +extern unsigned int u; +const auto ll = 1LL; +extern const long long ll; + +int +main (void) +{ + if (i != 1 || c != 1 || u != 10U) + abort (); + auto ai = i; + int *aip = &ai; + if (ai != 1) + abort (); + auto p = (int (*) [++i]) 0; + if (i != 2) + abort (); + if (sizeof (*p) != 2 * sizeof (int)) + abort (); + int vla[u][u]; + int (*vp)[u] = &vla[0]; + auto vpp = ++vp; + if (vp != &vla[1]) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-auto-3.c b/SingleSource/Regression/C/gcc-dg/c2x-auto-3.c new file mode 100644 index 0000000000..1ab3cc74d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-auto-3.c @@ -0,0 +1,71 @@ +/* Test C2x auto. Invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +auto; /* { dg-error "empty declaration" } */ +auto *p = (int *) 0; /* { dg-error "plain identifier" } */ +auto i; /* { dg-error "initialized data declaration" } */ +auto g { } /* { dg-error "initialized data declaration" } */ +auto a = 1, b = 2; /* { dg-error "single declarator" } */ +auto long e0 = 0; /* { dg-error "file-scope declaration" } */ +long auto e1 = 0; /* { dg-error "file-scope declaration" } */ +int auto e2 = 0; /* { dg-error "file-scope declaration" } */ + +extern int e3; +auto e3 = 1; /* { dg-error "underspecified declaration of 'e3', which is already declared in this scope" } */ + +void +f () +{ + extern int fe1; + auto fe1 = 1; /* { dg-error "underspecified declaration of 'fe1', which is already declared in this scope" } */ + /* { dg-error "declaration of 'fe1' with no linkage follows extern declaration" "linkage error" { target *-*-* } .-1 } */ + auto fe2 = (struct s *) 0; /* { dg-error "declared in underspecified object initializer" } */ + auto fe3 = (union u *) 0; /* { dg-error "declared in underspecified object initializer" } */ + auto fe4 = (struct s2 { int a; }) { }; /* { dg-error "defined in underspecified object initializer" } */ + auto fe5 = (struct { int a; }) { }; /* { dg-error "defined in underspecified object initializer" } */ + auto fe6 = (union u2 { int a; }) { }; /* { dg-error "defined in underspecified object initializer" } */ + auto fe7 = (union { int a; }) { }; /* { dg-error "defined in underspecified object initializer" } */ + auto fe8 = sizeof (enum e { A }); /* { dg-error "defined in underspecified object initializer" } */ + /* The following case is undefined behavior (so doesn't actually require a + diagnostic). */ + auto fe9 = sizeof (enum { B }); /* { dg-error "defined in underspecified object initializer" } */ + /* Examples with a forward declaration, then definition inside auto. */ + struct s3; + auto fe10 = (struct s3 { int a; }) { }; /* { dg-error "defined in underspecified object initializer" } */ + union u3; + auto fe11 = (union u3 { int a; }) { }; /* { dg-error "defined in underspecified object initializer" } */ +} + +void f2 (auto x); /* { dg-error "storage class specified for parameter" } */ +void f3 (auto y) { } /* { dg-error "storage class specified for parameter" } */ + +auto e4 = sizeof (e4); /* { dg-error "underspecified 'e4' referenced in its initializer" } */ +__SIZE_TYPE__ e5; +void +f4 () +{ + auto e5 = sizeof (e5); /* { dg-error "underspecified 'e5' referenced in its initializer" } */ +} + +auto typedef int T; /* { dg-error "'typedef' used with 'auto'" } */ +auto auto e6 = 1; /* { dg-error "duplicate 'auto'" } */ +static auto int e7 = 1; /* { dg-error "multiple storage classes in declaration specifiers" } */ +_Thread_local auto int e8 = 2; /* { dg-error "'_Thread_local' used with 'auto'" } */ +_Thread_local int auto e9 = 3; /* { dg-error "'_Thread_local' used with 'auto'" } */ +/* { dg-error "file-scope declaration of 'e9' specifies 'auto'" "file-scope error" { target *-*-* } .-1 } */ + +typedef auto int T2; /* { dg-error "multiple storage classes in declaration specifiers" } */ + +void +f5 () +{ + static int auto e10 = 3; /* { dg-error "multiple storage classes in declaration specifiers" } */ +} + +void +f6 () +{ + static auto l = { 0L }; /* { dg-error "expected expression" } */ + const auto i3 [[]] = { 4, }; /* { dg-error "expected expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-auto-4.c b/SingleSource/Regression/C/gcc-dg/c2x-auto-4.c new file mode 100644 index 0000000000..3c6cb34710 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-auto-4.c @@ -0,0 +1,5 @@ +/* Test C2x auto. -Wc11-c2x-compat warning. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +auto x = 2; /* { dg-warning "ISO C does not support 'auto' type deduction before" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-1.c b/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-1.c new file mode 100644 index 0000000000..bbb2bc842c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-1.c @@ -0,0 +1,5 @@ +/* Test C2x binary constants. Valid syntax and types. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include "binary-constants-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-2.c b/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-2.c new file mode 100644 index 0000000000..4379427d6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-2.c @@ -0,0 +1,11 @@ +/* Test that binary constants are accepted in C2X mode: compat warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ + +int a = 0b1; /* { dg-warning "C2X feature" } */ +#if 0b101 /* { dg-warning "C2X feature" } */ +#endif + +int b = 0B1; /* { dg-warning "C2X feature" } */ +#if 0B101 /* { dg-warning "C2X feature" } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-3.c b/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-3.c new file mode 100644 index 0000000000..7604791fa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-binary-constants-3.c @@ -0,0 +1,9 @@ +/* Test C2x binary constants. Invalid constants. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int a = 0b; /* { dg-error "invalid suffix" } */ +int b = 0B2; /* { dg-error "invalid suffix" } */ +int c = 0B02; /* { dg-error "invalid digit" } */ +int d = 0b1.1; /* { dg-error "invalid prefix" } */ +int e = 0B0p0; /* { dg-error "invalid suffix" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-bool-1.c b/SingleSource/Regression/C/gcc-dg/c2x-bool-1.c new file mode 100644 index 0000000000..992fb31808 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-bool-1.c @@ -0,0 +1,44 @@ +/* Test macro expansions in in C2x. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#define str(x) xstr(x) +#define xstr(x) #x + +extern void abort (void); +extern void exit (int); +extern int strcmp (const char *, const char *); + +#if false - 1 >= 0 +#error "false unsigned in #if" +#endif + +#if false != 0 +#error "false not 0 in #if" +#endif + +#if true - 2 >= 0 +#error "true unsigned in #if" +#endif + +#if true != 1 +#error "true not 1 in #if" +#endif + +int +main (void) +{ + if (_Generic (true, _Bool : 1) != 1) + abort (); + if (true != 1) + abort (); + if (_Generic (false, _Bool : 1) != 1) + abort (); + if (false != 0) + abort (); + if (strcmp (str (__bool_true_false_are_defined), "1") != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-bool-2.c b/SingleSource/Regression/C/gcc-dg/c2x-bool-2.c new file mode 100644 index 0000000000..4edb34e4de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-bool-2.c @@ -0,0 +1,42 @@ +/* Test bool, true and false keywords in C2x. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +#if false - 1 >= 0 +#error "false unsigned in #if" +#endif + +#if false != 0 +#error "false not 0 in #if" +#endif + +#if true - 2 >= 0 +#error "true unsigned in #if" +#endif + +#if true != 1 +#error "true not 1 in #if" +#endif + +extern bool b; +extern _Bool b; + +_Static_assert (false == 0); +_Static_assert (true == 1); + +int +main (void) +{ + if (_Generic (true, bool : 1) != 1) + abort (); + if (true != 1) + abort (); + if (_Generic (false, bool : 1) != 1) + abort (); + if (false != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-bool-limits-1.c b/SingleSource/Regression/C/gcc-dg/c2x-bool-limits-1.c new file mode 100644 index 0000000000..d32b4ef59e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-bool-limits-1.c @@ -0,0 +1,19 @@ +/* Test limits for _Bool in in C2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#include + +#ifndef BOOL_MAX +# error "missing BOOL_MAX" +#endif + +#ifndef BOOL_WIDTH +# error "missing BOOL_WIDTH" +#endif + +/* In principle _Bool can support values wider than 1 bit, stored via + type punning, but this is not supported by GCC. */ + +_Static_assert (BOOL_MAX == 1, "bad BOOL_MAX"); +_Static_assert (BOOL_WIDTH == 1, "bad BOOL_WIDTH"); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-builtins-1.c b/SingleSource/Regression/C/gcc-dg/c2x-builtins-1.c new file mode 100644 index 0000000000..74760592cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-builtins-1.c @@ -0,0 +1,13 @@ +/* Test C2x built-in functions: test functions new in C2x are indeed + declared as built-in as expected. Non-DFP tests. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +int exp10 (void); /* { dg-warning "conflicting types for built-in function" } */ +int exp10f (void); /* { dg-warning "conflicting types for built-in function" } */ +int exp10l (void); /* { dg-warning "conflicting types for built-in function" } */ +int roundeven (void); /* { dg-warning "conflicting types for built-in function" } */ +int roundevenf (void); /* { dg-warning "conflicting types for built-in function" } */ +int roundevenl (void); /* { dg-warning "conflicting types for built-in function" } */ +int strdup (void); /* { dg-warning "conflicting types for built-in function" } */ +int strndup (void); /* { dg-warning "conflicting types for built-in function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-complit-1.c b/SingleSource/Regression/C/gcc-dg/c2x-complit-1.c new file mode 100644 index 0000000000..af92d4d0a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-complit-1.c @@ -0,0 +1,35 @@ +/* Test storage duration of compound literals in parameter lists for C2x. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +int x; + +void f (int a[(int) { x }]); + +int *q; + +int +fp (int *p) +{ + q = p; + return 1; +} + +void +g (int a, int b[fp ((int [2]) { a, a + 2 })]) +{ + if (q[0] != a || q[1] != a + 2) + abort (); +} + +int +main (void) +{ + int t[1] = { 0 }; + g (1, t); + g (2, t); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-complit-2.c b/SingleSource/Regression/C/gcc-dg/c2x-complit-2.c new file mode 100644 index 0000000000..dcca5e8d34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-complit-2.c @@ -0,0 +1,48 @@ +/* Test C2x storage class specifiers in compound literals. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +extern void abort (void); +extern void exit (int); + +/* static is OK (although redundant) at file scope. */ +int *ps = &(static int) { 1 }; +size_t ss = sizeof (static int) { 1 }; +int *psa = (static int [3]) { 1, 2, 3 }; + +int +main () +{ + if (ps[0] != 1) + abort (); + if (ss != sizeof (int)) + abort (); + if (psa[0] != 1 || psa[1] != 2 || psa[2] != 3) + abort (); + if ((register int) { 3 } != 3) + abort (); + /* A static compound literal, like a static variable, is initialized once, + but an automatic compound literal is initialized every time it is reached + in the order of execution. */ + int i = 0; + lab: + int *p = &(static int) { 0 }; + if (*p != i) + abort (); + i++; + *p = i; + if (i < 5) + goto lab; + i = 0; + lab2: + int *p2 = &(int) { 0 }; + if (*p2 != 0) + abort (); + i++; + *p2 = i; + if (i < 5) + goto lab2; + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-complit-3.c b/SingleSource/Regression/C/gcc-dg/c2x-complit-3.c new file mode 100644 index 0000000000..c672525ba6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-complit-3.c @@ -0,0 +1,24 @@ +/* Test C2x storage class specifiers in compound literals. Thread-local + cases, compilation tests. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-require-effective-target tls } */ + +#include + +/* thread_local is OK at file scope, although of limited use since the + thread-local object and its address are not constant expressions. */ +size_t st = sizeof (thread_local int) { 1 }; +size_t sst = sizeof (static thread_local int) { 1 }; + +int * +f () +{ + return &(static thread_local int) { 2 }; +} + +int * +g () +{ + return &(thread_local static int) { 3 }; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-complit-4.c b/SingleSource/Regression/C/gcc-dg/c2x-complit-4.c new file mode 100644 index 0000000000..31d741325d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-complit-4.c @@ -0,0 +1,60 @@ +/* Test C2x storage class specifiers in compound literals. Thread-local + cases, execution tests. */ +/* { dg-do run } */ +/* { dg-options "-pthread -std=gnu2x -pedantic-errors" } */ +/* { dg-require-effective-target pthread_h } */ +/* { dg-require-effective-target pthread } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +#include + +extern void abort (void); +extern void exit (int); + +int * +thread_addr () +{ + return (static thread_local int []) { 1, 2 }; +} + +int *volatile p, *volatile q, r; + +void * +thread_fn (void *) +{ + q = thread_addr (); + if (q[0] != 1 || q[1] != 2) + return NULL; + q[0] = 5; + q[1] = 6; + return &r; +} + +int +main () +{ + int i; + pthread_t tid; + void *ret; + p = thread_addr (); + if (p[0] != 1 || p[1] != 2) + abort (); + p[0] = 3; + p[1] = 4; + if (p != thread_addr ()) + abort (); + i = pthread_create (&tid, NULL, thread_fn, NULL); + if (p != thread_addr ()) + abort (); + i = pthread_join (tid, &ret); + if (i != 0) + abort (); + if (ret != &r) + abort (); + if (p != thread_addr ()) + abort (); + if (p[0] != 3 || p[1] != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-complit-5.c b/SingleSource/Regression/C/gcc-dg/c2x-complit-5.c new file mode 100644 index 0000000000..1eb0f8dd76 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-complit-5.c @@ -0,0 +1,52 @@ +/* Test C2x storage class specifiers in compound literals: invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int *p = &(register int) { 0 }; /* { dg-error "file-scope compound literal specifies" } */ + +int v; + +void +f () +{ + int *q = &(thread_local int) { 0 }; /* { dg-error "compound literal implicitly auto and declared" } */ + int *pc = &(static int) { v }; /* { dg-error "not constant" } */ + int *pt = &(static thread_local int) { v }; /* { dg-error "not constant" } */ + &(register int) { 0 }; /* { dg-error "address of register compound literal requested" } */ + struct s { int a, b; }; + &((register struct s) { 1, 2 }.b); /* { dg-error "address of register compound literal requested" } */ +} + +int *s = &(static static int) { 0 }; /* { dg-error "duplicate" } */ + +void +g () +{ + (void) (register register int) { 0 }; /* { dg-error "duplicate" } */ + (void) (static static int) { 0 }; /* { dg-error "duplicate" } */ + (void) (static thread_local thread_local int) { 0 }; /* { dg-error "duplicate" } */ + (void) (static register int) { 0 }; /* { dg-error "multiple storage classes in declaration specifiers" } */ + (void) (register static int) { 0 }; /* { dg-error "multiple storage classes in declaration specifiers" } */ + (void) (register thread_local int) { 0 }; /* { dg-error "used with" } */ + (void) (thread_local register int) { 0 }; /* { dg-error "used with" } */ +} + +void +h () +{ + /* The following cases are not part of the C2x syntax, but are detected + specially by the parser. */ + (static int) 0; /* { dg-error "storage class specifier in cast" } */ + sizeof (static int); /* { dg-error "storage class specifier in" } */ + alignof (static int); /* { dg-error "storage class specifier in" } */ +} + +void +bad_scspec () +{ + /* Storage class specifiers not permitted in compound literals result in a + syntax error. */ + (typedef int) { 0 }; /* { dg-error "expected" } */ + (auto int) { 0 }; /* { dg-error "expected" } */ + (extern int) { 0 }; /* { dg-error "expected" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-complit-6.c b/SingleSource/Regression/C/gcc-dg/c2x-complit-6.c new file mode 100644 index 0000000000..23a0bb6420 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-complit-6.c @@ -0,0 +1,7 @@ +/* Test C2x storage class specifiers in compound literals diagnosed with + -Wc11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ + +int *ps = &(static int) { 1 }; /* { dg-warning "forbids storage class specifiers in compound literals" } */ +int ss = sizeof (static int) { 1 }; /* { dg-warning "forbids storage class specifiers in compound literals" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-complit-7.c b/SingleSource/Regression/C/gcc-dg/c2x-complit-7.c new file mode 100644 index 0000000000..0cd0b86c54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-complit-7.c @@ -0,0 +1,7 @@ +/* Test C2x storage class specifiers in compound literals diagnosed with + -Wc11-c2x-compat, but not errors with -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat -pedantic-errors" } */ + +int *ps = &(static int) { 1 }; /* { dg-warning "forbids storage class specifiers in compound literals" } */ +int ss = sizeof (static int) { 1 }; /* { dg-warning "forbids storage class specifiers in compound literals" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-complit-8.c b/SingleSource/Regression/C/gcc-dg/c2x-complit-8.c new file mode 100644 index 0000000000..fb614ab780 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-complit-8.c @@ -0,0 +1,70 @@ +/* Test C2x storage class specifiers in compound literals: inline function + constraints. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +inline void +f1 () +{ + (static int) { 123 }; /* { dg-error "static but declared in inline function 'f1' which is not static" } */ + (static thread_local int) { 456 } ; /* { dg-error "static but declared in inline function 'f1' which is not static" } */ + (int) { 789 }; + (register int) { 1234 }; +} + +inline void +f1e () +{ + (static int) { 123 }; + (static thread_local int) { 456 } ; +} + +static inline void +f1s () +{ + (static int) { 123 }; + (static thread_local int) { 456 } ; +} + +inline void +f2 () +{ + (static const int) { 123 }; + (static thread_local const int) { 456 }; +} + +inline void +f2e () +{ + (static const int) { 123 }; + (static thread_local const int) { 456 }; +} + +static inline void +f2s () +{ + (static const int) { 123 }; + (static thread_local const int) { 456 }; +} + +inline void +f3 () +{ + (static constexpr int) { 123 }; +} + +inline void +f3e () +{ + (static constexpr int) { 123 }; +} + +static inline void +f3s () +{ + (static constexpr int) { 123 }; +} + +extern void f1e (); +extern void f2e (); +extern void f3e (); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-concat-1.c b/SingleSource/Regression/C/gcc-dg/c2x-concat-1.c new file mode 100644 index 0000000000..e92eaaf639 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-concat-1.c @@ -0,0 +1,31 @@ +/* Test errors for bad string literal concatenation. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +void *pLU = L"" U""; /* { dg-error "non-standard concatenation" } */ +void *pL_U = L"" "" U""; /* { dg-error "non-standard concatenation" } */ +void *pLu = L"" u""; /* { dg-error "non-standard concatenation" } */ +void *pL_u = L"" "" u""; /* { dg-error "non-standard concatenation" } */ +void *pLu8 = L"" u8""; /* { dg-error "non-standard concatenation" } */ +void *pL_u8 = L"" "" u8""; /* { dg-error "non-standard concatenation" } */ + +void *pUL = U"" L""; /* { dg-error "non-standard concatenation" } */ +void *pU_L = U"" "" L""; /* { dg-error "non-standard concatenation" } */ +void *pUu = U"" u""; /* { dg-error "non-standard concatenation" } */ +void *pU_u = U"" "" u""; /* { dg-error "non-standard concatenation" } */ +void *pUu8 = U"" u8""; /* { dg-error "non-standard concatenation" } */ +void *pU_u8 = U"" "" u8""; /* { dg-error "non-standard concatenation" } */ + +void *puL = u"" L""; /* { dg-error "non-standard concatenation" } */ +void *pu_L = u"" "" L""; /* { dg-error "non-standard concatenation" } */ +void *puU = u"" U""; /* { dg-error "non-standard concatenation" } */ +void *pu_U = u"" "" U""; /* { dg-error "non-standard concatenation" } */ +void *puu8 = u"" u8""; /* { dg-error "non-standard concatenation" } */ +void *pu_u8 = u"" "" u8""; /* { dg-error "non-standard concatenation" } */ + +void *pu8L = u8"" L""; /* { dg-error "non-standard concatenation" } */ +void *pu8_L = u8"" "" L""; /* { dg-error "non-standard concatenation" } */ +void *pu8U = u8"" U""; /* { dg-error "non-standard concatenation" } */ +void *pu8_U = u8"" "" U""; /* { dg-error "non-standard concatenation" } */ +void *pu8u = u8"" u""; /* { dg-error "non-standard concatenation" } */ +void *pu8_u = u8"" "" u""; /* { dg-error "non-standard concatenation" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-1.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-1.c new file mode 100644 index 0000000000..898953020e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-1.c @@ -0,0 +1,327 @@ +/* Test C2x constexpr. Valid code, compilation tests. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +constexpr int v1 = 1; +static_assert (v1 == 1); +extern typeof (v1) *pci; +extern const int *pci; +extern typeof (&(constexpr int) {}) pci; +/* Redeclaring a constexpr object is OK (although it can't be declared before + the definition without undefined behavior). */ +extern const int v1; +static_assert (v1 == 1); +unsigned int constexpr v2 = 2; +static_assert (v2 == 2); +extern typeof (v2) *pcui; +extern const unsigned int *pcui; +static constexpr char v3 = 3; +static_assert (v3 == 3); +extern typeof (v3) *pcc; +extern const char *pcc; +constexpr void *v4 = 0; +extern typeof (v4) *pcpv; +extern void *const *pcpv; +constexpr int *v5 = nullptr; +extern typeof (v5) *pcpi; +extern int *const *pcpi; +constexpr double v6 = 3.5; +extern typeof (v6) *pcd; +extern const double *pcd; +auto constexpr v7 = 1.0; +extern typeof (v7) *pcd; +constexpr auto v8 = 1.5f; +extern typeof (v8) *pcf; +extern const float *pcf; +constexpr static long v9 = 2ULL; +static_assert (v9 == 2); +extern typeof (v9) *pcl; +extern const long *pcl; +const short *v10 = &(constexpr short) { 10 }; +/* Qualifiers that aren't permitted on a constexpr object itself are OK in a + pointer target. */ +constexpr volatile int *v11 = nullptr; +extern typeof (v11) *pcpvi; +extern volatile int *const *pcpvi; +constexpr _Atomic int *v12 = nullptr; +extern typeof (v12) *pcpai; +extern _Atomic int *const *pcpai; +constexpr int *restrict *v13 = nullptr; +extern typeof (v13) cprpi; +extern int *restrict *const cprpi; +typedef int *P; +constexpr restrict P *v14 = nullptr; +extern typeof (v14) cprpi; +struct s15 { volatile int a; _Atomic int b; int *restrict p; }; +constexpr struct s15 *v16 = nullptr; +constexpr char v17[3] = { 1, 2, 3 }; +struct s18 { int a; int *b; double c; }; +constexpr struct s18 v19 = { 12345ULL, 0, 19.0L }; +static_assert (v19.a == 12345); +union u20 { int a; float b; }; +constexpr union u20 v21 = { 1 }; +static_assert (v21.a == 1); +constexpr union u20 v22 = { .b = 23.0 }; +constexpr float v23 = (float) (1.0f / 3.0f); +constexpr double v24 = (double) (1.0 / 3.0); +constexpr struct s18 v25 = { 0, 0, (double) (1.0 / 3.0) }; +static_assert (v25.a == 0); +constexpr char v26[] = "abc\xfe"; +constexpr unsigned char v27[] = u8"xyz\xff"; +constexpr unsigned char v28[] = "\x12\x7f"; +constexpr signed char v29[] = "\x34\x66"; +constexpr double v30 = (int) (double) 3.0 - (long) (double) 2.0; +constexpr int v31 = 1 + 2 + (int) 3.0; +static_assert (v31 == 6); +constexpr typeof (nullptr) v32 = nullptr; +constexpr _Complex double v33 = __builtin_complex (1.0f, 3.0f / 2.0f); +constexpr float v34 = 1234.0L; +constexpr char v35 = 127ULL; +#if FLT_MIN_EXP == -125 && FLT_MANT_DIG == 24 +constexpr float v36 = 0x1p-149; +constexpr float _Complex v37 = __builtin_complex (0x1p-149, 0x1p127); +constexpr float v38 = 0xffffffUL; +constexpr float v39 = -0xffffffL; +constexpr float v40 = 0xffffff0L; +constexpr float v41 = 1ULL << 63; +#endif +#if DBL_MIN_EXP == -1021 && DBL_MANT_DIG == 53 +constexpr double v42 = 0x1p-1074L; +constexpr _Complex double v43 = __builtin_complex (0x1p1023L, 0x1p-1074L); +constexpr double v44 = 0x1fffffffffffffULL; +constexpr double v45 = -0x1fffffffffffffLL; +constexpr double v46 = 0x3ffffffffffffeULL; +constexpr double v47 = 1ULL << 63; +#endif +constexpr void *v48 = (void *) 0; +constexpr int *v49 = (void *) 0L; +constexpr long *v50 = 0LL; +constexpr int v51 = {}; +static_assert (v51 == 0); +constexpr float v52 = {}; +constexpr long double v53 = {}; +constexpr int *v54 = {}; +constexpr void *v55 = {}; +constexpr typeof (nullptr) v56 = {}; +struct s57 { int *p; }; +union u58 { int *p; }; +constexpr int *v59 = 0; +constexpr int *v60 = { 0 }; +constexpr struct s57 v61 = { 0 }; +constexpr struct s57 v62 = { { } }; /* { dg-warning "braces around scalar initializer" } */ +constexpr struct s57 v63 = { { 0 } }; /* { dg-warning "braces around scalar initializer" } */ +constexpr union u58 v64 = { 0 }; +constexpr union u58 v65 = { { } }; /* { dg-warning "braces around scalar initializer" } */ +constexpr union u58 v66 = { { 0 } }; /* { dg-warning "braces around scalar initializer" } */ +struct s67 { int a; float b; void *c; int *d; typeof (nullptr) e; int f; int g[2]; }; +struct s68 { struct s67 x; }; +union u69 { int a; float b; void *c; int *d; struct s68 e; }; +struct s70 { union u69 x; }; +constexpr struct s67 v71 = { 1, 2.0, 0, 0, nullptr, 7, { 3, 4 } }; +static_assert (v71.a == 1); +static_assert (v71.f == 7); +constexpr struct s67 v72 = v71; +static_assert (v72.a == 1); +static_assert (v72.f == 7); +extern const struct s67 v71; +constexpr auto v73 = v71; +static_assert (v73.a == 1); +static_assert (v73.f == 7); +auto v74 = v71; +constexpr struct s68 v75 = { v72 }; +static_assert (v75.x.a == 1); +static_assert (v75.x.f == 7); +constexpr union u69 v76 = { }; +static_assert (v76.a == 0); +constexpr union u69 v77 = { .e = v75 }; +static_assert (v77.e.x.a == 1); +static_assert (v77.e.x.f == 7); +constexpr union u69 v78 = { .a = 1 }; +static_assert (v78.a == 1); +constexpr union u69 v79 = { .e = { v72 } }; +static_assert (v79.e.x.a == 1); +static_assert (v79.e.x.f == 7); +enum e80 { E80 = v79.e.x.f }; +static_assert (E80 == 7); +constexpr struct s70 v81 = { v79 }; +static_assert (v81.x.e.x.f == 7); +constexpr struct s68 v82 = { (constexpr struct s67) { 5, 6, 0, 0, nullptr, 9, { 1, 2 } } }; +static_assert (v82.x.a == 5); +static_assert (v82.x.f == 9); +constexpr auto v83 = (constexpr int) { (constexpr int) { 0 } }; +/* These are null pointers but not null pointer constants. */ +constexpr typeof (nullptr) v84 = nullptr; +constexpr void *v85 = 0; +int *v86 = v85; +int *v87 = v84; +typeof (1 ? v85 : (int *) 0) v88; +extern void *v88; +typeof (1 ? (void *) 0 : (int *) 0) v89; +extern int *v89; +constexpr struct s68 v90 = { }; +static_assert (v90.x.a == 0); +static_assert (v90.x.f == 0); +constexpr int v91 = { 123 }; +static_assert (v91 == 123); +constexpr int v92 = { v91 }; +static_assert (v92 == 123); +/* Verify that constexpr values can be used in various contexts requiring + (integer) constant expressions. */ +struct s93 { int x : v79.e.x.f; }; +constexpr int v94 = alignof (int); +alignas (v94) int v95; +constexpr int v97[100] = { [v82.x.f] = 7 }; +static int v98[v94]; +constexpr _Complex double v99 = 1.0; +constexpr _Complex float v100 = 12345; +constexpr int *v101 = (int *) 0; +constexpr void *v102 = (void *) (void *) 0; +constexpr void *v103 = v101; +constexpr void *v104 = v84; +struct s105 { void *p; }; +constexpr struct s105 v106 = { (int *) 0 }; + +void +f0 () +{ + constexpr int fv0 = 3; + static_assert (fv0 == 3); + auto constexpr fv1 = 4; + static_assert (fv1 == 4); + register constexpr float fv2 = 1.0; + constexpr auto fv3 = 123; + static_assert (fv3 == 123); + constexpr register void *fv4 = (void *) 0; + const int *fv5 = &(constexpr int) { 234 }; + const int *fv6 = &(constexpr static int) { 234 }; + const int *fv7 = &(static constexpr int) { 234 }; + typeof ((constexpr register int) { 234 }) *fv8; + typeof ((register constexpr int) { 234 }) *fv9; + int fv10 = (constexpr int) { 1 } + sizeof (struct fs *); + constexpr auto fv11 = (constexpr int) { (constexpr int) { 0 } }; + static_assert (fv11 == 0); + constexpr char fv12[3] = { 1, 2, 3 }; + (constexpr short [4]) { 9, 8, 7, -6 }; + constexpr struct s18 fv13 = { 1234ULL, 0, 13.0f }; + (constexpr struct s18) { 123, (void *) 0, 11 }; + constexpr union u20 fv14 = { 2 }; + (constexpr union u20) { 5 }; + constexpr union u20 fv15 = { .b = 15.0 }; + (constexpr union u20) { .b = 20 }; + (constexpr float) { (float) (1.0f / 3.0f) }; + (constexpr double) { (double) (1.0 / 3.0) }; + (constexpr struct s18) { 0, 0, (double) (1.0 / 3.0) }; + (constexpr char []) { "abc\xfe" }; + (constexpr unsigned char []) { u8"xyz\xff" }; + (constexpr unsigned char []) { "\x12\x7f" }; + (constexpr signed char []) { "\x34\x66" }; + (constexpr double) { (int) (double) 3.0 - (long) (double) 2.0 }; + (constexpr int) { 1 + 2 + (int) 3.0 }; + (constexpr typeof (nullptr)) { nullptr }; + (constexpr _Complex double) { __builtin_complex (1.0f, 3.0f / 2.0f) }; + (constexpr float) { 1234.0L }; + (constexpr char) { 127ULL }; +#if FLT_MIN_EXP == -125 && FLT_MANT_DIG == 24 + (constexpr float) { 0x1p-149 }; + (constexpr float _Complex) { __builtin_complex (0x1p-149, 0x1p127) }; + (constexpr float) { 0xffffffUL }; + (constexpr float) { -0xffffffL }; + (constexpr float) { 0xffffff0L }; + (constexpr float) { 1ULL << 63 }; +#endif +#if DBL_MIN_EXP == -1021 && DBL_MANT_DIG == 53 + (constexpr double) { 0x1p-1074L }; + (constexpr _Complex double) { __builtin_complex (0x1p1023L, 0x1p-1074L) }; + (constexpr double) { 0x1fffffffffffffULL }; + (constexpr double) { -0x1fffffffffffffLL }; + (constexpr double) { 0x3ffffffffffffeULL }; + (constexpr double) { 1ULL << 63 }; +#endif + (constexpr void *) { (void *) 0 }; + (constexpr int *) { (void *) 0L }; + (constexpr long *) { 0LL }; + (constexpr int) {}; + (constexpr float) {}; + (constexpr long double) {}; + (constexpr int *) {}; + (constexpr void *) {}; + (constexpr typeof (nullptr)) {}; + (constexpr int *) { 0 }; + (constexpr struct s57) { 0 }; + (constexpr struct s57) { { } }; /* { dg-warning "braces around scalar initializer" } */ + (constexpr struct s57) { { 0 } }; /* { dg-warning "braces around scalar initializer" } */ + (constexpr union u58) { 0 }; + (constexpr union u58) { { } }; /* { dg-warning "braces around scalar initializer" } */ + (constexpr union u58) { { 0 } }; /* { dg-warning "braces around scalar initializer" } */ + (constexpr _Complex double) { 1.0 }; + (constexpr _Complex float) { 12345 }; + (constexpr int *) { (int *) 0 }; + (constexpr void *) { (void *) (void *) 0 }; + (constexpr void *) { v101 }; + (constexpr void *) { v84 }; + (constexpr struct s105) { (int *) 0 }; + /* It's not entirely clear if constexpr declarations are allowed in this + position in a for loop; presume they are, as implicitly auto just as if no + storage class specifiers were used. */ + for (constexpr int fv16 = 1;;) + break; + constexpr struct s67 fv17 = { 1, 2.0, 0, 0, nullptr, 7, { 3, 4 } }; + static_assert (fv17.a == 1); + static_assert (fv17.f == 7); + constexpr struct s67 fv18 = fv17; + static_assert (fv18.a == 1); + static_assert (fv18.f == 7); + constexpr auto fv19 = fv17; + static_assert (fv19.a == 1); + static_assert (fv19.f == 7); + auto fv20 = fv17; + constexpr struct s68 fv21 = { fv18 }; + static_assert (fv21.x.a == 1); + static_assert (fv21.x.f == 7); + constexpr union u69 fv22 = { }; + static_assert (fv22.a == 0); + constexpr union u69 fv23 = { .e = fv21 }; + static_assert (fv23.e.x.a == 1); + static_assert (fv23.e.x.f == 7); + constexpr union u69 fv24 = { .a = 1 }; + static_assert (fv24.a == 1); + constexpr union u69 fv25 = { .e = { fv18 } }; + static_assert (fv25.e.x.a == 1); + static_assert (fv25.e.x.f == 7); + enum fe80 { FE80 = fv25.e.x.f }; + static_assert (FE80 == 7); + constexpr struct s70 fv26 = { fv25 }; + static_assert (fv26.x.e.x.f == 7); + constexpr struct s68 fv27 = { (constexpr struct s67) { 5, 6, 0, 0, nullptr, 9, { 1, 2 } } }; + static_assert (fv27.x.a == 5); + static_assert (fv27.x.f == 9); + constexpr struct s68 fv28 = { }; + static_assert (fv28.x.a == 0); + static_assert (fv28.x.f == 0); + constexpr int fv29 = { 123 }; + static_assert (fv29 == 123); + constexpr int fv30 = { fv29 }; + static_assert (fv30 == 123); + static_assert ((constexpr struct s67) { 1, 2.0, 0, 0, nullptr, 7, { 3, 4 } }.f == 7); + static_assert ((constexpr struct s68) { fv18 }.x.a == 1); + static_assert ((constexpr union u69) { }.a == 0); + static_assert ((constexpr union u69) { .e = fv21 }.e.x.f == 7); + static_assert ((constexpr union u69) { .a = 1 }.a == 1); + static_assert ((constexpr union u69) { .e = { fv18 } }.e.x.a == 1); + static_assert ((constexpr struct s70) { fv25 }.x.e.x.f == 7); + static_assert ((constexpr struct s68) { (constexpr struct s67) { 5, 6, 0, 0, nullptr, 9, { 1, 2 } } }.x.f == 9); + static_assert ((constexpr struct s68) { }.x.f == 0); + /* Verify that constexpr values can be used in various contexts requiring + (integer) constant expressions. */ + struct fs93 { int x : fv25.e.x.f; }; + constexpr int fv31 = alignof (int); + alignas (fv31) int fv32; + constexpr int fv33[100] = { [fv27.x.f] = 7 }; + static int fv34[fv31]; + switch (fv0) + { + case fv27.x.f: ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-2a.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-2a.c new file mode 100644 index 0000000000..f74e2ec53b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-2a.c @@ -0,0 +1,37 @@ +/* Test C2x constexpr. Valid code, execution test. */ +/* { dg-do link } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-additional-sources "c2x-constexpr-2b.c" } */ + +extern void abort (void); +extern void exit (int); + +/* constexpr objects at file scope have internal linkage. */ +constexpr int a = 2; + +struct s { int a; float b; int c[3]; }; +constexpr struct s s1 = { 2, 3, { 4, 5, 6 } }; +constexpr struct s s2 = s1; +struct s s3 = s2; + +void +check (const struct s *p) +{ + if (p->a != 2 || p->b != 3 || p->c[0] != 4 || p->c[1] != 5 || p->c[2] != 6) + abort (); +} + +int +main () +{ + constexpr struct s s4 = s1; + struct s s5 = s4; + constexpr struct s s6 = { s1.a, s2.b, { 4, 5, 6 } }; + check (&s1); + check (&s2); + check (&s3); + check (&s4); + check (&s5); + check (&s6); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-2b.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-2b.c new file mode 100644 index 0000000000..04058b3f55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-2b.c @@ -0,0 +1,6 @@ +/* Test C2x constexpr. Second file for link test. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* constexpr objects at file scope have internal linkage. */ +constexpr int a = 3; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-3.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-3.c new file mode 100644 index 0000000000..b9b780e5ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-3.c @@ -0,0 +1,230 @@ +/* Test C2x constexpr. Invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +extern constexpr int v0 = 0; /* { dg-error "'constexpr' used with 'extern'" } */ +/* { dg-warning "initialized and declared 'extern'" "initialized extern" { target *-*-* } .-1 } */ +constexpr extern int v1 = 0; /* { dg-error "'constexpr' used with 'extern'" } */ +/* { dg-warning "initialized and declared 'extern'" "initialized extern" { target *-*-* } .-1 } */ +typedef constexpr int v2; /* { dg-error "'constexpr' used with 'typedef'" } */ +constexpr typedef int v3; /* { dg-error "'constexpr' used with 'typedef'" } */ +thread_local constexpr int v4 = 0; /* { dg-error "'constexpr' used with '_Thread_local'" } */ +constexpr thread_local int v5 = 0; /* { dg-error "'thread_local' used with 'constexpr'" } */ +constexpr constexpr int v6 = 1; /* { dg-error "duplicate 'constexpr'" } */ +constexpr struct v7; /* { dg-error "'constexpr' in empty declaration" } */ +/* { dg-error "'struct v7' declared in underspecified object declaration" "underspecified" { target *-*-* } .-1 } */ +constexpr union v8; /* { dg-error "'constexpr' in empty declaration" } */ +/* { dg-error "'union v8' declared in underspecified object declaration" "underspecified" { target *-*-* } .-1 } */ +constexpr struct v9 { int a; }; /* { dg-error "'constexpr' in empty declaration" } */ +/* { dg-error "'struct v9' defined in underspecified object declaration" "underspecified" { target *-*-* } .-1 } */ +constexpr union v10 { int a; }; /* { dg-error "'constexpr' in empty declaration" } */ +/* { dg-error "'union v10' defined in underspecified object declaration" "underspecified" { target *-*-* } .-1 } */ +constexpr; /* { dg-error "'constexpr' in empty declaration" } */ +constexpr int; /* { dg-error "empty declaration" } */ +constexpr const; /* { dg-error "empty declaration" } */ +constexpr int v11; /* { dg-error "initialized data declaration" } */ +constexpr int v12 { } /* { dg-error "initialized data declaration" } */ +constexpr int v13 = 1, v14 = 2; /* { dg-error "single declarator" } */ +constexpr int v15 = sizeof (struct v16 *); /* { dg-error "declared in underspecified object initializer" } */ +constexpr int v17 = sizeof (union v18 *); /* { dg-error "declared in underspecified object initializer" } */ +constexpr int v19 = sizeof (struct v20 { int a; }); /* { dg-error "defined in underspecified object initializer" } */ +constexpr int v21 = sizeof (struct { int a; }); /* { dg-error "defined in underspecified object initializer" } */ +constexpr int v22 = sizeof (union v23 { int a; }); /* { dg-error "defined in underspecified object initializer" } */ +constexpr int v24 = sizeof (union { int a; }); /* { dg-error "defined in underspecified object initializer" } */ +constexpr int v25 = sizeof (enum v26 { A }); /* { dg-error "defined in underspecified object initializer" } */ +/* The following case is undefined behavior (so doesn't actually require a + diagnostic). */ +constexpr int v27 = sizeof (enum { B }); /* { dg-error "defined in underspecified object initializer" } */ +/* Examples with a forward declaration, then definition inside constexpr. */ +struct v28; +constexpr int v29 = sizeof (struct v28 { int a; }); /* { dg-error "defined in underspecified object initializer" } */ +union v30; +constexpr int v31 = sizeof (union v30 { int a; }); /* { dg-error "defined in underspecified object initializer" } */ +constexpr int v32 = sizeof (v32); /* { dg-error "underspecified 'v32' referenced in its initializer" } */ +static const int v33; +constexpr const int v33 = 1; /* { dg-error "underspecified declaration of 'v33', which is already declared in this scope" } */ +constexpr void v34 () {} /* { dg-error "'constexpr' requires an initialized data declaration" } */ +void v35 (constexpr int v36); /* { dg-error "storage class specified for parameter 'v36'" } */ +void v37 (constexpr short); /* { dg-error "storage class specified for unnamed parameter" } */ +void v38 (constexpr register int v39); /* { dg-error "storage class specified for parameter 'v39'" } */ +void v40 (constexpr register short); /* { dg-error "storage class specified for unnamed parameter" } */ +/* The following case is undefined behavior (presumably to allow for possible + future support for constexpr functions), but should clearly be diagnosed + when such functions aren't actually supported. */ +constexpr int v41 (); /* { dg-error "'constexpr' requires an initialized data declaration" } */ +typedef volatile long t42; +typedef int *restrict t43; +typedef _Atomic int t44; +struct t45 { struct { struct { t42 a[2]; } a; } a; }; +struct t46 { struct { struct { int z; int *restrict a; } a[3]; } a; }; +struct t47 { short x; struct { struct { _Atomic long a; } a; } a[4][5]; }; +constexpr t42 v48 = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr t43 v49 = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr t44 v50 = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr volatile double v51 = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr int *restrict v52 = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr _Atomic (short) v53 = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr long *volatile v54 = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr struct t45 v55 = {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ +constexpr struct t46 v56 = {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ +constexpr struct t47 v57 = {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ +union t58 { struct { union { t42 a[1]; } a; } a; }; +union t59 { struct { union { int z; int *restrict a; } a; } a; }; +union t60 { short x; union { struct { _Atomic long a; } a[3]; } a; }; +constexpr union t58 v61 = {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ +constexpr union t59 v62 = {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ +constexpr union t60 v63 = {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ +constexpr t42 v64[1][2][3] = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr volatile int v65[1][2][3] = {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ +constexpr struct t45 v66[2][2][4] = {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ +constexpr union t60 v67[2][2][4] = {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ +int v68 = 0; +constexpr int v69 = v68; /* { dg-error "initializer element is not constant" } */ +double exp (double); +constexpr double v70 = exp (0); /* { dg-error "initializer element is not a constant expression" } */ +struct s71 { int a; double b; }; +constexpr struct s71 v72 = { 0, exp (0) }; /* { dg-error "initializer element is not a constant expression" } */ +/* { dg-error "'constexpr' initializer is not an arithmetic constant expression" "arithmetic" { target *-*-* } .-1 } */ +constexpr struct s71 v73 = { v68, 0 }; /* { dg-error "initializer element is not constant" } */ +union u74 { int a; double b; }; +constexpr union u74 v75 = { v68 }; /* { dg-error "initializer element is not constant" } */ +constexpr union u74 v76 = { .b = exp (0) }; /* { dg-error "initializer element is not a constant expression" } */ +/* { dg-error "'constexpr' initializer is not an arithmetic constant expression" "arithmetic" { target *-*-* } .-1 } */ +constexpr struct s77 *v77 = 0; /* { dg-error "'struct s77' declared in underspecified object declaration" } */ +constexpr union u78 *v78 = 0; /* { dg-error "'union u78' declared in underspecified object declaration" } */ +constexpr struct s79 { int a; } v79 = { 0 }; /* { dg-error "'struct s79' defined in underspecified object declaration" } */ +constexpr union u80 { int a; } v80 = { 0 }; /* { dg-error "'union u80' defined in underspecified object declaration" } */ +constexpr enum e81 { E81 } v81 = E81; /* { dg-error "'enum e81' defined in underspecified object declaration" } */ +constexpr enum { E82 } v82 = E82; /* { dg-error "defined in underspecified object declaration" } */ +struct s83 constexpr *v83 = 0; /* { dg-error "'struct s83' declared in underspecified object declaration" } */ +union u84 constexpr *v84 = 0; /* { dg-error "'union u84' declared in underspecified object declaration" } */ +struct s85 { int a; } constexpr v85 = { 0 }; /* { dg-error "'struct s85' defined in underspecified object declaration" } */ +union u86 { int a; } constexpr v86 = { 0 }; /* { dg-error "'union u86' defined in underspecified object declaration" } */ +enum e87 { E87 } constexpr v87 = E87; /* { dg-error "'enum e87' defined in underspecified object declaration" } */ +enum { E88 } constexpr v88 = E88; /* { dg-error "defined in underspecified object declaration" } */ +constexpr void *v89 = (void *) 64; /* { dg-error "'constexpr' pointer initializer is not null" } */ +constexpr int *v90 = (int *) 64; /* { dg-error "'constexpr' pointer initializer is not null" } */ +constexpr int v91 = (int) (double) 1.0; /* { dg-error "constexpr' integer initializer is not an integer constant expression" } */ +constexpr struct s71 v92 = { (int) (double) 1.0, 0 }; /* { dg-error "constexpr' integer initializer is not an integer constant expression" } */ +struct s93 { void *p; }; +constexpr struct s93 v94 = { (int *) 16 }; /* { dg-error "'constexpr' pointer initializer is not null" } */ +constexpr int v95 = (unsigned int) -1; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr unsigned char v96 = -1; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr signed char v97 = 1234567LL; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +/* { dg-warning "overflow in conversion" "overflow warning" { target *-*-* } .-1 } */ +constexpr double v98 = __builtin_complex (1.0, 0.0); /* { dg-error "'constexpr' initializer for a real type is of complex type" } */ +constexpr double v99 = __builtin_complex (1.0, 1.0); /* { dg-error "'constexpr' initializer for a real type is of complex type" } */ +constexpr double v100 = __builtin_complex (1.0, -0.0); /* { dg-error "'constexpr' initializer for a real type is of complex type" } */ +constexpr float v102 = (unsigned long long) -1; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr double v103 = (unsigned long long) -1; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr float v104 = __LONG_LONG_MAX__; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr double v105 = __LONG_LONG_MAX__; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr signed char v106[] = u8"\xff"; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +/* Only the initialized (possibly by default) element of a constexpr union is a + named constant. */ +union u107 { int a; int b; }; +constexpr union u107 v108 = { }; +constexpr union u107 v109 = { .a = 0 }; +constexpr union u107 v110 = { .b = 0 }; +constexpr int v111 = v108.b; /* { dg-error "initializer" } */ +constexpr int v112 = v109.b; /* { dg-error "initializer" } */ +constexpr int v113 = v110.a; /* { dg-error "initializer" } */ +/* A reference to an array in a constexpr object is converted to a pointer as + usual, so in particular is not equivalent to directly using a string literal + initializer extracted from the initializer of that object. */ +struct s114 { char c[10]; }; +constexpr struct s114 v115 = { "abc" }; +constexpr struct s114 v116 = { v115.c }; /* { dg-error "initializer" } */ +/* { dg-error "integer from pointer" "conversion" { target *-*-* } .-1 } */ + +void +f0 () +{ + (constexpr constexpr int) { 1 }; /* { dg-error "duplicate 'constexpr'" } */ + (constexpr thread_local int) { 1 }; /* { dg-error "'thread_local' used with 'constexpr'" } */ + (thread_local constexpr static int) { 1 }; /* { dg-error "'constexpr' used with '_Thread_local'" } */ + (constexpr int) { sizeof (struct fs1 *) }; /* { dg-error "declared in underspecified object initializer" } */ + (constexpr int) { sizeof (union fs2 *) }; /* { dg-error "declared in underspecified object initializer" } */ + (constexpr int) { sizeof (struct fs3 { int a; }) }; /* { dg-error "defined in underspecified object initializer" } */ + (constexpr int) { sizeof (struct { int a; }) }; /* { dg-error "defined in underspecified object initializer" } */ + (constexpr int) { sizeof (union fs4 { int a; }) }; /* { dg-error "defined in underspecified object initializer" } */ + (constexpr int) { sizeof (union { int a; }) }; /* { dg-error "defined in underspecified object initializer" } */ + (constexpr int) { sizeof (enum fs5 { A }) }; /* { dg-error "defined in underspecified object initializer" } */ + /* The following case is undefined behavior (so doesn't actually require a + diagnostic). */ + (constexpr int) { sizeof (enum { B }) }; /* { dg-error "defined in underspecified object initializer" } */ + /* Examples with a forward declaration, then definition inside constexpr. */ + struct fs6; + (constexpr int) { sizeof (struct fs6 { int a; }) }; /* { dg-error "defined in underspecified object initializer" } */ + union fs7; + (constexpr int) { sizeof (union fs7 { int a; }) }; /* { dg-error "defined in underspecified object initializer" } */ + constexpr int fv32 = sizeof (fv32); /* { dg-error "underspecified 'fv32' referenced in its initializer" } */ + /* Test entering then exiting nested underspecified initializers. */ + constexpr int x = (constexpr int) { 1 } + sizeof (struct fs8 *); /* { dg-error "declared in underspecified object initializer" } */ + auto y = (constexpr int) { 1 } + sizeof (struct fs9 *); /* { dg-error "declared in underspecified object initializer" } */ + extern const int z; /* { dg-message "previous declaration" } */ + constexpr const int z = 1; /* { dg-error "underspecified declaration of 'z', which is already declared in this scope" } */ + /* { dg-error "declaration of 'z' with no linkage follows extern declaration" "linkage error" { target *-*-* } .-1 } */ + int non_const = 1; + typedef int VLA[non_const]; + constexpr VLA *pnc = nullptr; /* { dg-error "'constexpr' object has variably modified type" } */ + (constexpr t42) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr t43) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr t44) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr volatile double) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr int *restrict) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr _Atomic (short)) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr long *volatile) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr struct t45) {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ + (constexpr struct t46) {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ + (constexpr struct t47) {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ + (constexpr union t58) {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ + (constexpr union t59) {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ + (constexpr union t60) {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ + (constexpr t42 [1][2][3]) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr volatile int [1][2][3]) {}; /* { dg-error "invalid qualifiers for 'constexpr' object" } */ + (constexpr struct t45 [2][2][4]) {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ + (constexpr union t60 [2][2][4]) {}; /* { dg-error "invalid qualifiers for field of 'constexpr' object" } */ + (constexpr int) { v68 }; /* { dg-error "initializer element is not constant" } */ + (constexpr double) { exp (0) }; /* { dg-error "initializer element is not a constant expression" } */ + /* { dg-error "'constexpr' initializer is not an arithmetic constant expression" "arithmetic" { target *-*-* } .-1 } */ + (constexpr struct s71) { 0, exp (0) }; /* { dg-error "initializer element is not a constant expression" } */ + /* { dg-error "'constexpr' initializer is not an arithmetic constant expression" "arithmetic" { target *-*-* } .-1 } */ + (constexpr struct s71) { v68, 0 }; /* { dg-error "initializer element is not constant" } */ + (constexpr union u74) { v68 }; /* { dg-error "initializer element is not constant" } */ + (constexpr union u74) { .b = exp (0) }; /* { dg-error "initializer element is not a constant expression" } */ + /* { dg-error "'constexpr' initializer is not an arithmetic constant expression" "arithmetic" { target *-*-* } .-1 } */ + (constexpr struct fs10 *) { 0 }; /* { dg-error "declared in 'constexpr' compound literal" } */ + (constexpr union fs11 *) { 0 }; /* { dg-error "declared in 'constexpr' compound literal" } */ + (constexpr struct fs12 { int a; }) { 0 }; /* { dg-error "defined in 'constexpr' compound literal" } */ + (constexpr union fs13 { int a; }) { 0 }; /* { dg-error "defined in 'constexpr' compound literal" } */ + (constexpr enum fs14 { FS14 }) { FS14 }; /* { dg-error "defined in 'constexpr' compound literal" } */ + (constexpr enum { FS15 }) { FS15 }; /* { dg-error "defined in 'constexpr' compound literal" } */ + (constexpr void *) { (void *) 64 }; /* { dg-error "'constexpr' pointer initializer is not null" } */ + (constexpr int *) { (int *) 64 }; /* { dg-error "'constexpr' pointer initializer is not null" } */ + (constexpr int) { (int) (double) 1.0 }; /* { dg-error "constexpr' integer initializer is not an integer constant expression" } */ + (constexpr struct s71) { (int) (double) 1.0, 0 }; /* { dg-error "constexpr' integer initializer is not an integer constant expression" } */ + (constexpr struct s93) { (int *) 16 }; /* { dg-error "'constexpr' pointer initializer is not null" } */ + (constexpr int) { (unsigned int) -1 }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr unsigned char) { -1 }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr signed char) { 1234567LL }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + /* { dg-warning "overflow in conversion" "overflow warning" { target *-*-* } .-1 } */ + (constexpr double) { __builtin_complex (1.0, 0.0) }; /* { dg-error "'constexpr' initializer for a real type is of complex type" } */ + (constexpr double) { __builtin_complex (1.0, 1.0) }; /* { dg-error "'constexpr' initializer for a real type is of complex type" } */ + (constexpr double) { __builtin_complex (1.0, -0.0) }; /* { dg-error "'constexpr' initializer for a real type is of complex type" } */ + (constexpr float) { (unsigned long long) -1 }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr double) { (unsigned long long) -1 }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr float) { __LONG_LONG_MAX__ }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr double) { __LONG_LONG_MAX__ }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr signed char []) { u8"\xff" }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + constexpr typeof (nullptr) not_npc = nullptr; + int *ptr = 0; + /* auto may only be used with another storage class specifier, such as + constexpr, if the type is inferred. */ + auto constexpr int a_c_t = 1; /* { dg-error "'auto' used with 'constexpr'" } */ + constexpr auto int c_a_t = 1; /* { dg-error "'auto' used with 'constexpr'" } */ + auto int constexpr a_t_c = 1; /* { dg-error "'constexpr' used with 'auto'" } */ + constexpr int auto c_t_a = 1; /* { dg-error "'auto' used with 'constexpr'" } */ + int auto constexpr t_a_c = 1; /* { dg-error "'constexpr' used with 'auto'" } */ + int constexpr auto t_c_a = 1; /* { dg-error "'auto' used with 'constexpr'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-4.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-4.c new file mode 100644 index 0000000000..2a42af890a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-4.c @@ -0,0 +1,21 @@ +/* Test C2x constexpr. Valid code, compilation tests, signed char. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -fsigned-char" } */ + +constexpr char v1[] = "\x00\xff"; +constexpr signed char v2[] = "\x7f\x80"; +constexpr unsigned char v3[] = "\x00\x7f"; +constexpr char v4[] = u8"\x00\x7f"; +constexpr signed char v5[] = u8"\x7f\x00"; +constexpr unsigned char v6[] = u8"\x00\xff"; + +void +f0 () +{ + (constexpr char []) { "\x00\xff" }; + (constexpr signed char []) { "\x7f\x80" }; + (constexpr unsigned char []) { "\x00\x7f" }; + (constexpr char []) { u8"\x00\x7f" }; + (constexpr signed char []) { u8"\x7f\x00" }; + (constexpr unsigned char []) { u8"\x00\xff" }; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-5.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-5.c new file mode 100644 index 0000000000..6febd2ee67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-5.c @@ -0,0 +1,21 @@ +/* Test C2x constexpr. Valid code, compilation tests, unsigned char. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -funsigned-char" } */ + +constexpr char v1[] = "\x00\xff"; +constexpr signed char v2[] = "\x7f\x00"; +constexpr unsigned char v3[] = "\x80\x7f"; +constexpr char v4[] = u8"\x00\xff"; +constexpr signed char v5[] = u8"\x7f\x00"; +constexpr unsigned char v6[] = u8"\x00\xff"; + +void +f0 () +{ + (constexpr char []) { "\x00\xff" }; + (constexpr signed char []) { "\x7f\x00" }; + (constexpr unsigned char []) { "\x80\x7f" }; + (constexpr char []) { u8"\x00\xff" }; + (constexpr signed char []) { u8"\x7f\x00" }; + (constexpr unsigned char []) { u8"\x00\xff" }; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-6.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-6.c new file mode 100644 index 0000000000..a86124a997 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-6.c @@ -0,0 +1,15 @@ +/* Test C2x constexpr. Invalid code, compilation tests, signed char. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -fsigned-char" } */ + +constexpr unsigned char v3[] = "\x00\xff"; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr char v4[] = u8"\x00\xff"; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr signed char v5[] = u8"\x00\xff"; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + +void +f0 () +{ + (constexpr unsigned char []) { "\x00\xff" }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr char []) { u8"\x00\xff" }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr signed char []) { u8"\x00\xff" }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-7.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-7.c new file mode 100644 index 0000000000..5282d92318 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-7.c @@ -0,0 +1,13 @@ +/* Test C2x constexpr. Invalid code, compilation tests, unsigned char. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -funsigned-char" } */ + +constexpr signed char v2[] = "\x00\xff"; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr signed char v5[] = u8"\x00\xff"; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + +void +f0 () +{ + (constexpr signed char []) { "\x00\xff" }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr signed char []) { u8"\x00\xff" }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-8.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-8.c new file mode 100644 index 0000000000..11372cf1d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-8.c @@ -0,0 +1,25 @@ +/* Test C2x constexpr. Valid code, compilation tests, IEEE arithmetic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target inff } */ + +constexpr float fi = __builtin_inf (); +constexpr double di = __builtin_inff (); +constexpr float fn = __builtin_nan (""); +constexpr double dn = __builtin_nanf (""); +constexpr float fns = __builtin_nansf (""); +constexpr double dns = __builtin_nans (""); +constexpr _Complex double cdns = __builtin_nans (""); + +void +f0 (void) +{ + (constexpr float) { __builtin_inf () }; + (constexpr double) { __builtin_inff () }; + (constexpr float) { __builtin_nan ("") }; + (constexpr double) { __builtin_nanf ("") }; + (constexpr float) { __builtin_nansf ("") }; + (constexpr double) { __builtin_nans ("") }; + (constexpr _Complex double) { __builtin_nans ("") }; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-constexpr-9.c b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-9.c new file mode 100644 index 0000000000..8a07ed5b38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-constexpr-9.c @@ -0,0 +1,45 @@ +/* Test C2x constexpr. Invalid code, compilation tests, IEEE arithmetic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target inff } */ + +/* A conversion from signaling NaN to quiet NaN in a different format or type + is not valid for constexpr. */ +constexpr float fns = __builtin_nans (""); /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr double dns = __builtin_nansf (""); /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr long double ldns = __builtin_nans (""); /* { dg-error "'constexpr' initializer not representable in type of object" } */ + +/* Test out-of-range values. */ +constexpr float fu = __DBL_MIN__; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr float fo = __DBL_MAX__; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr float fp = 0x1.ffffffp0; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + +constexpr _Complex float cfur = __builtin_complex (__DBL_MIN__, 0.0); /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr _Complex float cfor = __builtin_complex (__DBL_MAX__, 0.0); /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr _Complex float cfpr = __builtin_complex (0x1.ffffffp0, 0.0); /* { dg-error "'constexpr' initializer not representable in type of object" } */ + +constexpr _Complex float cfui = __builtin_complex (0.0, __DBL_MIN__); /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr _Complex float cfoi = __builtin_complex (0.0, __DBL_MAX__); /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr _Complex float cfpi = __builtin_complex (0.0, 0x1.ffffffp0); /* { dg-error "'constexpr' initializer not representable in type of object" } */ + +constexpr _Complex float cfd = __DBL_MAX__; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +constexpr _Complex float cfi = __LONG_LONG_MAX__; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + +void +f0 () +{ + (constexpr float) { __builtin_nans ("") }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr double) { __builtin_nansf ("") }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr float) { __DBL_MIN__ }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr float) { __DBL_MAX__ }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr float) { 0x1.ffffffp0 }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr _Complex float) { __builtin_complex (__DBL_MIN__, 0.0) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr _Complex float) { __builtin_complex (__DBL_MAX__, 0.0) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr _Complex float) { __builtin_complex (0x1.ffffffp0, 0.0) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr _Complex float) { __builtin_complex (0.0, __DBL_MIN__) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr _Complex float) { __builtin_complex (0.0, __DBL_MAX__) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr _Complex float) { __builtin_complex (0.0, 0x1.ffffffp0) }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr _Complex float) { __DBL_MAX__ }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ + (constexpr _Complex float) { __LONG_LONG_MAX__ }; /* { dg-error "'constexpr' initializer not representable in type of object" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-1.c b/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-1.c new file mode 100644 index 0000000000..6eadf2ea87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-1.c @@ -0,0 +1,39 @@ +/* Test C2x digit separators. Valid usages. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +_Static_assert (123'45'6 == 123456); +_Static_assert (0'123 == 0123); +_Static_assert (0x1'23 == 0x123); + +#define m(x) 0 + +_Static_assert (m(1'2)+(3'4) == 34); + +_Static_assert (0x0'e-0xe == 0); + +#define a0 '.' - +#define acat(x) a ## x +_Static_assert (acat (0'.') == 0); + +#define c0(x) 0 +#define b0 c0 ( +#define bcat(x) b ## x +_Static_assert (bcat (0'\u00c0')) == 0); + +extern void exit (int); +extern void abort (void); + +int +main (void) +{ + if (314'159e-0'5f != 3.14159f) + abort (); + exit (0); +} + +#line 0'123 +_Static_assert (__LINE__ == 123); + +#line 4'56'7'8'9 +_Static_assert (__LINE__ == 456789); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-2.c b/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-2.c new file mode 100644 index 0000000000..d72f8adc6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-2.c @@ -0,0 +1,25 @@ +/* Test C2x digit separators. Invalid usages. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +void +tf (void) +{ + int i; + i = 1''2; /* { dg-error "adjacent digit separators" } */ + i = 0x'0; /* { dg-error "digit separator after base indicator" } */ + i = 0X'1; /* { dg-error "digit separator after base indicator" } */ + i = 0b'0; /* { dg-error "digit separator after base indicator" } */ + i = 0B'1; /* { dg-error "digit separator after base indicator" } */ + i = 1'u; /* { dg-error "digit separator outside digit sequence" } */ + float f = 1.2e-3'f; /* { dg-error "digit separator outside digit sequence" } */ + i = 1'2'3'; /* { dg-error "12:missing terminating" } */ + ; + double d; + d = 1'.2'3e-4; /* { dg-warning "multi-character" } */ + /* { dg-error "expected" "parse error" { target *-*-* } .-1 } */ + d = 1.2''3; /* { dg-error "adjacent digit separators" } */ + d = 1.23e-4''5; /* { dg-error "adjacent digit separators" } */ + d = 1.2'3e-4'5'; /* { dg-error "17:missing terminating" } */ + /* { dg-error "expected" "parse error" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-3.c b/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-3.c new file mode 100644 index 0000000000..cddb88fa88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-digit-separators-3.c @@ -0,0 +1,12 @@ +/* Test C2x digit separators. Test token pasting avoided for preprocessed + output. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -save-temps" } */ + +#define ZERO 0 + +int +f (void) +{ + return ZERO'0'0; /* { dg-error "expected" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-empty-init-1.c b/SingleSource/Regression/C/gcc-dg/c2x-empty-init-1.c new file mode 100644 index 0000000000..1487a2b23a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-empty-init-1.c @@ -0,0 +1,80 @@ +/* Test C2X support for empty initializers: valid use cases. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +extern void exit (int); +extern void abort (void); + +struct s { int a; }; +struct s s = {}; +int x = {}; +float y = {}; +void *p = {}; +union u { int a; long b; }; +union u z = {}; +int aa[2] = {}; + +void +f (int a) +{ + volatile int vla[a] = {}; + struct s as = {}; + int ax = {}; + float ay = {}; + void *ap = {}; + union u az = {}; + int aaa[2] = {}; + for (int i = 0; i < a; i++) + if (vla[i] != 0) + abort (); + if (as.a != 0) + abort (); + if (ax != 0) + abort (); + if (ay != 0) + abort (); + if (ap != 0) + abort (); + if (az.a != 0) + abort (); + if (aaa[0] != 0) + abort (); + if (aaa[1] != 0) + abort (); + if ((int) {} != 0) + abort (); + if ((float) {} != 0) + abort (); + if ((struct s) {}.a != 0) + abort (); + if ((union u) {}.a != 0) + abort (); + if ((int [5]) {}[2] != 0) + abort (); + /* Overwrite contents of vla before second call to make it more likely stack + contents are nonzero if proper initialization did not occur. */ + for (int i = 0; i < a; i++) + vla[i] = -1; +} + +int +main (void) +{ + f (100); + f (100); + if (s.a != 0) + abort (); + if (x != 0) + abort (); + if (y != 0) + abort (); + if (p != 0) + abort (); + if (z.a != 0) + abort (); + if (aa[0] != 0) + abort (); + if (aa[1] != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-empty-init-2.c b/SingleSource/Regression/C/gcc-dg/c2x-empty-init-2.c new file mode 100644 index 0000000000..0dc81ce5b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-empty-init-2.c @@ -0,0 +1,18 @@ +/* Test C2X support for empty initializers: invalid use cases. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* Empty initialization is invalid for arrays of unknown size. This is + diagnosed via the diagnostic for zero-size arrays. */ +int x[] = {}; /* { dg-error "zero or negative size array" } */ + +void +f (int a) +{ + int x1[] = {}; /* { dg-error "zero or negative size array" } */ + int x2[][a] = {}; /* { dg-error "zero or negative size array" } */ + /* Nonempty VLA initializers are still invalid. */ + int x3[a] = { 0 }; /* { dg-error "variable-sized object may not be initialized except with an empty initializer" } */ + /* Variable-size compound literals are still invalid. */ + (void) (int [a]) {}; /* { dg-error "compound literal has variable size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-empty-init-3.c b/SingleSource/Regression/C/gcc-dg/c2x-empty-init-3.c new file mode 100644 index 0000000000..472f8169c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-empty-init-3.c @@ -0,0 +1,25 @@ +/* Test empty initializers diagnosed in C2X mode with -Wc11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ + +struct s { int a; }; +struct s s = {}; /* { dg-warning "empty initializer" } */ +int x = {}; /* { dg-warning "empty initializer" } */ +float y = {}; /* { dg-warning "empty initializer" } */ +void *p = {}; /* { dg-warning "empty initializer" } */ +union u { int a; long b; }; +union u z = {}; /* { dg-warning "empty initializer" } */ +int aa[2] = {}; /* { dg-warning "empty initializer" } */ + +void +f (int a) +{ + int vla[a] = {}; /* { dg-warning "empty initializer" } */ + struct s as = {}; /* { dg-warning "empty initializer" } */ + int ax = {}; /* { dg-warning "empty initializer" } */ + float ay = {}; /* { dg-warning "empty initializer" } */ + void *ap = {}; /* { dg-warning "empty initializer" } */ + union u az = {}; /* { dg-warning "empty initializer" } */ + int aaa[2] = {}; /* { dg-warning "empty initializer" } */ + int t = (int) {}; /* { dg-warning "empty initializer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-enum-1.c b/SingleSource/Regression/C/gcc-dg/c2x-enum-1.c new file mode 100644 index 0000000000..984a4e70d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-enum-1.c @@ -0,0 +1,109 @@ +/* Test C2x enumerations with values not representable in int. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* Check a type while defining an enum (via a diagnostic for incompatible + pointer types if the wrong type was chosen). */ +#define TYPE_CHECK(cst, type) \ + cst ## _type_check = sizeof (1 ? (type *) 0 : (typeof (cst) *) 0) + +/* Test various explicit values not representable in int. */ + +enum e1 { e1a = -__LONG_LONG_MAX__ - 1, TYPE_CHECK (e1a, long long), + e1b = 0, TYPE_CHECK (e1b, int), + e1c = __LONG_LONG_MAX__, TYPE_CHECK (e1c, long long), + e1d = 1, TYPE_CHECK (e1d, int) }; +extern enum e1 e1v; +extern typeof (e1a) e1v; +extern typeof (e1b) e1v; +extern typeof (e1c) e1v; +extern typeof (e1d) e1v; +static_assert (sizeof (enum e1) >= sizeof (long long)); +static_assert (e1a == -__LONG_LONG_MAX__ - 1); +static_assert (e1b == 0); +static_assert (e1c == __LONG_LONG_MAX__); +static_assert (e1d == 1); +static_assert (e1a < 0); +static_assert (e1c > 0); + +/* This is a test where values are representable in int. */ +enum e2 { e2a = (long long) -__INT_MAX__ - 1, TYPE_CHECK (e2a, int), + e2b = (unsigned int) __INT_MAX__, TYPE_CHECK (e2b, int), + e2c = 2, TYPE_CHECK (e2c, int) }; +extern int e2v; +extern typeof (e2a) e2v; +extern typeof (e2b) e2v; +extern typeof (e2c) e2v; +static_assert (e2a == -__INT_MAX__ - 1); +static_assert (e2b == __INT_MAX__); +static_assert (e2c == 2); +static_assert (e2a < 0); +static_assert (e2b > 0); + +enum e3 { e3a = 0, TYPE_CHECK (e3a, int), + e3b = (unsigned int) -1, TYPE_CHECK (e3b, unsigned int) }; +extern enum e3 e3v; +extern typeof (e3a) e3v; +extern typeof (e3b) e3v; +static_assert (e3a == 0u); +static_assert (e3b == (unsigned int) -1); +static_assert (e3b > 0); + +/* Test handling of overflow and wraparound (choosing a wider type). */ +#if __LONG_LONG_MAX__ > __INT_MAX__ +enum e4 { e4a = __INT_MAX__, + e4b, e4c, e4d = ((typeof (e4b)) -1) < 0, + e4e = (unsigned int) -1, + e4f, e4g = ((typeof (e4e)) -1) > 0, + TYPE_CHECK (e4a, int), TYPE_CHECK (e4e, unsigned int) }; +extern enum e4 e4v; +extern typeof (e4a) e4v; +extern typeof (e4b) e4v; +extern typeof (e4c) e4v; +extern typeof (e4d) e4v; +extern typeof (e4e) e4v; +extern typeof (e4f) e4v; +extern typeof (e4g) e4v; +static_assert (e4a == __INT_MAX__); +static_assert (e4b == (long long) __INT_MAX__ + 1); +static_assert (e4c == (long long) __INT_MAX__ + 2); +static_assert (e4f == (unsigned long long) (unsigned int) -1 + 1); +/* Verify the type chosen on overflow of a signed type while parsing was + signed. */ +static_assert (e4d == 1); +/* Verify the type chosen on wraparound of an unsigned type while parsing was + unsigned. */ +static_assert (e4g == 1); +#endif + +/* Likewise, for overflow from long to long long. */ +#if __LONG_LONG_MAX__ > __LONG_MAX__ +enum e5 { e5a = __LONG_MAX__, + e5b, e5c, e5d = ((typeof (e5b)) -1) < 0, + e5e = (unsigned long) -1, + e5f, e5g = ((typeof (e5e)) -1) > 0, +#if __LONG_MAX__ > __INT_MAX__ + TYPE_CHECK (e5a, long), +#else + TYPE_CHECK (e5a, int), +#endif + TYPE_CHECK (e5e, unsigned long) }; +extern enum e5 e5v; +extern typeof (e5a) e5v; +extern typeof (e5b) e5v; +extern typeof (e5c) e5v; +extern typeof (e5d) e5v; +extern typeof (e5e) e5v; +extern typeof (e5f) e5v; +extern typeof (e5g) e5v; +static_assert (e5a == __LONG_MAX__); +static_assert (e5b == (long long) __LONG_MAX__ + 1); +static_assert (e5c == (long long) __LONG_MAX__ + 2); +static_assert (e5f == (unsigned long long) (unsigned long) -1 + 1); +/* Verify the type chosen on overflow of a signed type while parsing was + signed. */ +static_assert (e5d == 1); +/* Verify the type chosen on wraparound of an unsigned type while parsing was + unsigned. */ +static_assert (e5g == 1); +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-enum-2.c b/SingleSource/Regression/C/gcc-dg/c2x-enum-2.c new file mode 100644 index 0000000000..15dcf9ac77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-enum-2.c @@ -0,0 +1,14 @@ +/* Test C2x enumerations with values not representable in int. Test values + outside the range of standard or extended integer types are diagnosed, even + when they can be represented in __int128. */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +enum e1 { e1a = __LONG_LONG_MAX__, e1b }; /* { dg-error "enumerator value outside the range" } */ + +enum e2 { e2a = __LONG_LONG_MAX__ * 2ULL + 1ULL, e2b }; /* { dg-error "enumerator value outside the range" } */ + +/* Likewise, when it's the enum as a whole that can't fit in any standard or + extended type, but the individual enumerators fit (some fitting a signed + type and some fitting an unsigned type). */ +enum e3 { e3a = -__LONG_LONG_MAX__ - 1, e3b = __LONG_LONG_MAX__ * 2ULL + 1ULL }; /* { dg-error "enumeration values exceed range of 'intmax_t'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-enum-3.c b/SingleSource/Regression/C/gcc-dg/c2x-enum-3.c new file mode 100644 index 0000000000..532d9776d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-enum-3.c @@ -0,0 +1,14 @@ +/* Test C2x enumerations with values not representable in int. Test values + outside the range of standard or extended integer types are diagnosed, + when __int128 is unsupported. */ +/* { dg-do compile { target { ! int128 } } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +enum e1 { e1a = __LONG_LONG_MAX__, e1b }; /* { dg-error "overflow in enumeration values" } */ + +enum e2 { e2a = __LONG_LONG_MAX__ * 2ULL + 1ULL, e2b }; /* { dg-error "overflow in enumeration values" } */ + +/* Likewise, when it's the enum as a whole that can't fit in any standard or + extended type, but the individual enumerators fit (some fitting a signed + type and some fitting an unsigned type). */ +enum e3 { e3a = -__LONG_LONG_MAX__ - 1, e3b = __LONG_LONG_MAX__ * 2ULL + 1ULL }; /* { dg-error "enumeration values exceed range of largest integer" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-enum-4.c b/SingleSource/Regression/C/gcc-dg/c2x-enum-4.c new file mode 100644 index 0000000000..c2e58bfe75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-enum-4.c @@ -0,0 +1,14 @@ +/* Test C2x enumerations with values not representable in int. Test overflow + of __int128 is diagnosed. */ +/* { dg-do compile { target { int128 } } } */ +/* { dg-options "-std=c2x" } */ + +enum e1 { e1a = (__int128) (((unsigned __int128) -1) >> 1), e1b }; /* { dg-error "overflow in enumeration values" } */ + +enum e2 { e2a = (unsigned __int128) -1, e2b }; /* { dg-error "overflow in enumeration values" } */ + +/* Likewise, when it's the enum as a whole that can't fit in __int128 or + unsigned __int128, but the individual enumerators fit (some fitting __int128 + and some fitting unsigned __int128). */ +enum e3 { e3a = -(__int128) (((unsigned __int128) -1) >> 1) - 1, + e3b = (unsigned __int128) -1 }; /* { dg-warning "enumeration values exceed range of largest integer" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-enum-5.c b/SingleSource/Regression/C/gcc-dg/c2x-enum-5.c new file mode 100644 index 0000000000..a4290f0452 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-enum-5.c @@ -0,0 +1,12 @@ +/* Test C2x enumerations with values not representable in int. Test + -Wc11-c2x-compat warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +enum e1 { e1a = -__LONG_LONG_MAX__ - 1 }; /* { dg-warning "ISO C restricts enumerator values" } */ + +enum e2 { e2a = __LONG_LONG_MAX__ }; /* { dg-warning "ISO C restricts enumerator values" } */ + +enum e3 { e3a = (unsigned int) -1 }; /* { dg-warning "ISO C restricts enumerator values" } */ + +enum e4 { e4a = (long long) -__INT_MAX__ - 1, e4b = (unsigned int) __INT_MAX__ }; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-enum-6.c b/SingleSource/Regression/C/gcc-dg/c2x-enum-6.c new file mode 100644 index 0000000000..5ab9694302 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-enum-6.c @@ -0,0 +1,167 @@ +/* Test C2x enumerations with fixed underlying type. Valid code. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* Check a type while defining an enum (via a diagnostic for incompatible + pointer types if the wrong type was chosen). */ +#define TYPE_CHECK(cst, type) \ + cst ## _type_check = sizeof (1 ? (type *) 0 : (typeof (cst) *) 0) + +extern int i; + +enum e1 : short { e1a = __SHRT_MAX__, + TYPE_CHECK (e1a, short), + e1z = (long long) 0, + TYPE_CHECK (e1z, enum e1), + e1b = -__SHRT_MAX__ - 1, + e1c, + TYPE_CHECK (e1c, enum e1) }; +extern enum e1 e1v; +extern typeof (e1a) e1v; +extern typeof (e1b) e1v; +extern typeof (e1c) e1v; +extern typeof (e1z) e1v; +extern short e1v; +static_assert (e1a == __SHRT_MAX__); +static_assert (e1b == -__SHRT_MAX__ - 1); +static_assert (e1c == -__SHRT_MAX__); +static_assert (e1a > 0); +static_assert (e1b < 0); +static_assert (e1c < 0); +static_assert (e1z == 0); +extern typeof (+e1v) i; +extern typeof (+e1a) i; +extern typeof (e1a + e1b) i; +enum e1 : short; +enum e1 : volatile short; +enum e1 : _Atomic short; +enum e1 : typeof (short); + +enum e2 : bool { b0, b1, b0a = 0, b1a = 1 }; +extern enum e2 e2v; +extern typeof (b0) e2v; +extern typeof (b0a) e2v; +extern typeof (b1) e2v; +extern typeof (b1a) e2v; +extern bool e2v; +extern typeof (+e2v) i; +extern typeof (+b0) i; +static_assert (b0 == 0); +static_assert (b1 == 1); +static_assert (b0a == 0); +static_assert (b1a == 1); + +enum e3 : volatile const _Atomic unsigned short; +enum e3 : unsigned short { e3a, e3b }; +extern enum e3 e3v; +extern typeof (e3a) e3v; +extern typeof (e3b) e3v; +extern unsigned short e3v; + +/* The enum type is complete from the end of the first enum type specifier + (which is nested inside another enum type specifier in this example). */ +enum e4 : typeof ((enum e4 : long { e4a = sizeof (enum e4) })0, 0L); +extern enum e4 e4v; +extern typeof (e4a) e4v; +extern long e4v; + +enum e5 : unsigned int; +extern enum e5 e5v; +extern typeof (e5v + e5v) e5v; +extern unsigned int e5v; + +enum : unsigned short { e6a, e6b, TYPE_CHECK (e6a, unsigned short) } e6v; +extern typeof (e6a) e6v; +extern typeof (e6b) e6v; +extern unsigned short e6v; + +struct s1; +struct s2 { int a; }; +union u1; +union u2 { int a; }; +enum xe1 { XE1 }; +enum xe2 : long long { XE2 }; +enum xe3 : unsigned long; + +void +f () +{ + /* Tags can be redeclared in an inner scope. */ + enum s1 : char; + enum s2 : int { S2 }; + enum u1 : long { U1 }; + enum u2 : unsigned char; + enum xe1 : long long; + enum xe2 : short; + enum xe3 : char { XE3 }; + static_assert (sizeof (enum xe3) == 1); + static_assert (sizeof (enum xe2) == sizeof (short)); + static_assert (sizeof (enum xe1) == sizeof (long long)); +} + +void *p; +typeof (nullptr) np; + +extern void abort (void); +extern void exit (int); + +int +main () +{ + /* Conversions to enums with fixed underlying type have the same semantics as + converting to the underlying type. */ + volatile enum e1 e1vm; + volatile enum e2 e2vm; + e1vm = __LONG_LONG_MAX__; /* { dg-warning "overflow" } */ + if (e1vm != (short) __LONG_LONG_MAX__) + abort (); + e2vm = 10; + if (e2vm != 1) + abort (); + e2vm = 0; + if (e2vm != 0) + abort (); + /* Arithmetic on enums with fixed underlying type has the same semantics as + arithmetic on the underlying type; in particular, the special semantics + for bool apply to enums with bool as fixed underlying type. */ + if (e2vm++ != 0) + abort (); + if (e2vm != 1) + abort (); + if (e2vm++ != 1) + abort (); + if (e2vm != 1) + abort (); + if (e2vm-- != 1) + abort (); + if (e2vm != 0) + abort (); + if (e2vm-- != 0) + abort (); + if (e2vm != 1) + abort (); + if (++e2vm != 1) + abort (); + if (e2vm != 1) + abort (); + e2vm = 0; + if (++e2vm != 1) + abort (); + if (e2vm != 1) + abort (); + if (--e2vm != 0) + abort (); + if (e2vm != 0) + abort (); + if (--e2vm != 1) + abort (); + if (e2vm != 1) + abort (); + e2vm = p; + e2vm = np; + e2vm = (bool) p; + e2vm = (bool) np; + if (e2vm != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-enum-7.c b/SingleSource/Regression/C/gcc-dg/c2x-enum-7.c new file mode 100644 index 0000000000..08bae31d82 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-enum-7.c @@ -0,0 +1,97 @@ +/* Test C2x enumerations with fixed underlying type. Invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* An enum type specifier may only be used when the enum is defined, or in a + declaration of the form "enum name enum-type-specifier;". */ +extern enum e1 : int; /* { dg-error "storage class specifier in empty declaration with 'enum' underlying type" } */ +_Thread_local enum e2 : short; /* { dg-error "'_Thread_local' in empty declaration with 'enum' underlying type" } */ +const enum e3 : long; /* { dg-error "type qualifier in empty declaration with 'enum' underlying type" } */ +alignas (8) enum e4 : long; /* { dg-error "'alignas' in empty declaration with 'enum' underlying type" } */ +inline enum e5 : unsigned; /* { dg-error "'inline' in empty declaration" } */ +_Noreturn enum e6 : unsigned; /* { dg-error "'_Noreturn' in empty declaration" } */ +auto enum e7 : unsigned; /* { dg-error "'auto' in file-scope empty declaration" } */ +register enum e8 : unsigned; /* { dg-error "'register' in file-scope empty declaration" } */ + +/* When the enum is defined, some extra declaration specifiers are permitted, + but diagnosed as useless. */ +extern enum e9 : int { E9 }; /* { dg-warning "useless storage class specifier in empty declaration" } */ +_Thread_local enum e10 : short { E10 }; /* { dg-warning "useless '_Thread_local' in empty declaration" } */ +const enum e11 : long { E11 }; /* { dg-warning "useless type qualifier in empty declaration" } */ +alignas (8) enum e12 : long { E12 }; /* { dg-warning "useless '_Alignas' in empty declaration" } */ + +/* Nothing else may be declared with an enum type specifier for an enum not + being defined in that declaration. */ +enum e13 : short x13; /* { dg-error "'enum' underlying type may not be specified here" } */ +enum e14 : short f14 (); /* { dg-error "'enum' underlying type may not be specified here" } */ +typeof (enum e15 : long) x15; /* { dg-error "'enum' underlying type may not be specified here" } */ +int f16 (enum e16 : char p); /* { dg-error "'enum' underlying type may not be specified here" } */ +/* { dg-warning "will not be visible outside of this definition or declaration" "warning" { target *-*-* } .-1 } */ +int f17 (enum e17 : char); /* { dg-error "'enum' underlying type may not be specified here" } */ +/* { dg-warning "will not be visible outside of this definition or declaration" "warning" { target *-*-* } .-1 } */ +struct s18 { enum e18 : int x; }; /* { dg-error "'enum' underlying type may not be specified here" } */ + +/* But those are OK if the enum content is defined. */ +enum e19 : short { E19 } x19; +enum e20 : long { E20 } f20 (); +typeof (enum e21 : long { E21 }) x21; +int f22 (enum e22 : long long { E22 } p); /* { dg-warning "will not be visible outside of this definition or declaration" } */ +int f23 (enum e23 : long long { E23 } p); /* { dg-warning "will not be visible outside of this definition or declaration" } */ +struct s24 { enum e24 : int { E24 } x; }; + +/* Incompatible kinds of tags in the same scope are errors. */ +struct s25; +enum s25 : int; /* { dg-error "wrong kind of tag" } */ +struct s26; +enum s26 : int { E26 }; /* { dg-error "wrong kind of tag" } */ +struct s27 { int x; }; +enum s27 : int; /* { dg-error "wrong kind of tag" } */ +struct s28 { int x; }; +enum s28 : int { E28 }; /* { dg-error "wrong kind of tag" } */ +union u29; +enum u29 : int; /* { dg-error "wrong kind of tag" } */ +union u30; +enum u30 : int { E30 }; /* { dg-error "wrong kind of tag" } */ +union u31 { int x; }; +enum u31 : int; /* { dg-error "wrong kind of tag" } */ +union u32 { int x; }; +enum u32 : int { E32 }; /* { dg-error "wrong kind of tag" } */ + +/* If an enum has a fixed underlying type, that must be given when defining the + enum. */ +enum e33 : short; +enum e33 { E33 }; /* { dg-error "'enum' declared with but defined without fixed underlying type" } */ + +/* An enum defined without a fixed underlying type cannot then be declared with + one. */ +enum e34 { E34A = -__INT_MAX__, E34B = __INT_MAX__ }; +enum e34 : int; /* { dg-error "'enum' declared both with and without fixed underlying type" } */ + +/* An enum with a fixed underlying type cannot be declared with an incompatible + fixed underlying type. */ +enum e35 : int; +enum e35 : unsigned int; /* { dg-error "'enum' underlying type incompatible with previous declaration" } */ +enum e36 : int; +enum e36 : unsigned int { E36 }; /* { dg-error "'enum' underlying type incompatible with previous declaration" } */ +enum e37 : unsigned int { E37 }; +enum e37 : int; /* { dg-error "'enum' underlying type incompatible with previous declaration" } */ + +/* Enumeration constants must fit in the fixed underlying type. */ +enum e38 : unsigned char { E38 = (unsigned long long)((unsigned char) -1) + 1 }; /* { dg-error "enumerator value outside the range of underlying type" } */ +enum e39 : unsigned int { E39 = -1 }; /* { dg-error "enumerator value outside the range of underlying type" } */ +enum e40 : int { E40 = __INT_MAX__, E40A }; /* { dg-error "overflow in enumeration values" } */ +enum e41 : unsigned int { E41 = (unsigned int) -1, E41A }; /* { dg-error "overflow in enumeration values" } */ +enum e42 : bool { E42 = 2 }; /* { dg-error "enumerator value outside the range of underlying type" } */ +enum e43 : bool { E43 = 1, E43A }; /* { dg-error "overflow in enumeration values" } */ + +/* The underlying type must be an integer type, not itself an enum (or + bit-precise) type. */ +enum e44 : double; /* { dg-error "invalid 'enum' underlying type" } */ +typedef int T; +enum e45 : T; +typedef int *TP; +enum e46 : TP; /* { dg-error "invalid 'enum' underlying type" } */ +enum e47 : enum e45; /* { dg-error "invalid 'enum' underlying type" } */ +enum e48 : const; /* { dg-error "no 'enum' underlying type specified" } */ +/* 'restrict' is not valid on integer types. */ +enum e49 : int restrict; /* { dg-error "invalid use of 'restrict'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-enum-8.c b/SingleSource/Regression/C/gcc-dg/c2x-enum-8.c new file mode 100644 index 0000000000..f7757fc332 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-enum-8.c @@ -0,0 +1,7 @@ +/* Test C2x enumerations with fixed underlying type. Test -Wc11-c2x-compat + warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +enum e1 : int; /* { dg-warning "ISO C does not support specifying 'enum' underlying types before" } */ +enum e2 : short { E2 }; /* { dg-warning "ISO C does not support specifying 'enum' underlying types before" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-1.c b/SingleSource/Regression/C/gcc-dg/c2x-float-1.c new file mode 100644 index 0000000000..8df85f935f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-1.c @@ -0,0 +1,37 @@ +/* Test *_NORM_MAX macros. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef FLT_NORM_MAX +#error "FLT_NORM_MAX undefined" +#endif + +#ifndef DBL_NORM_MAX +#error "DBL_NORM_MAX undefined" +#endif + +#ifndef LDBL_NORM_MAX +#error "LDBL_NORM_MAX undefined" +#endif + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + if (FLT_NORM_MAX != FLT_MAX) + abort (); + if (DBL_NORM_MAX != DBL_MAX) + abort (); +#if LDBL_MANT_DIG == 106 + if (LDBL_NORM_MAX != 0x0.ffffffffffffffffffffffffffcp1023L) + abort (); +#else + if (LDBL_NORM_MAX != LDBL_MAX) + abort (); +#endif + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-10.c b/SingleSource/Regression/C/gcc-dg/c2x-float-10.c new file mode 100644 index 0000000000..7206921db8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-10.c @@ -0,0 +1,33 @@ +/* Test *_IS_IEC_60559 macros. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef FLT_IS_IEC_60559 +#error "FLT_IS_IEC_60559 undefined" +#endif + +#ifndef DBL_IS_IEC_60559 +#error "DBL_IS_IEC_60559 undefined" +#endif + +#ifndef LDBL_IS_IEC_60559 +#error "LDBL_IS_IEC_60559 undefined" +#endif + +#if defined __pdp11__ || defined __vax__ +_Static_assert (FLT_IS_IEC_60559 == 0); +_Static_assert (DBL_IS_IEC_60559 == 0); +_Static_assert (LDBL_IS_IEC_60559 == 0); +#else +_Static_assert (FLT_IS_IEC_60559 == 1); +_Static_assert (DBL_IS_IEC_60559 == 1); +#if LDBL_MANT_DIG == 106 || LDBL_MIN_EXP == -16382 +/* IBM long double and m68k extended format do not meet the definition + of an IEC 60559 interchange or extended format. */ +_Static_assert (LDBL_IS_IEC_60559 == 0); +#else +_Static_assert (LDBL_IS_IEC_60559 == 1); +#endif +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-11.c b/SingleSource/Regression/C/gcc-dg/c2x-float-11.c new file mode 100644 index 0000000000..0e2f3c0c97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-11.c @@ -0,0 +1,9 @@ +/* Test INFINITY macro. Test when infinities not supported. */ +/* { dg-do compile { target { ! inff } } } */ +/* { dg-options "-std=c2x" } */ + +#include + +#ifdef INFINITY +#error "INFINITY defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-12.c b/SingleSource/Regression/C/gcc-dg/c2x-float-12.c new file mode 100644 index 0000000000..40900bd918 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-12.c @@ -0,0 +1,19 @@ +/* Test C2x definition of LDBL_EPSILON. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + volatile long double x = 1.0L; + for (int i = 0; i < LDBL_MANT_DIG - 1; i++) + x /= 2; + if (x != LDBL_EPSILON) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-13.c b/SingleSource/Regression/C/gcc-dg/c2x-float-13.c new file mode 100644 index 0000000000..dc54bc734b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-13.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_FLOAT_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_FLOAT_H__ +#error "__STDC_VERSION_FLOAT_H__ not defined" +#endif + +#if __STDC_VERSION_FLOAT_H__ != 202311L +#error "bad value of __STDC_VERSION_FLOAT_H__" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-2.c b/SingleSource/Regression/C/gcc-dg/c2x-float-2.c new file mode 100644 index 0000000000..61a77f6f2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-2.c @@ -0,0 +1,23 @@ +/* Test INFINITY macro. Generic test. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -w" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target inff } */ + +#include + +#ifndef INFINITY +#error "INFINITY undefined" +#endif + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + (void) _Generic (INFINITY, float : 0); + if (!(INFINITY >= FLT_MAX)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-3.c b/SingleSource/Regression/C/gcc-dg/c2x-float-3.c new file mode 100644 index 0000000000..7c6298b8ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-3.c @@ -0,0 +1,27 @@ +/* Test INFINITY macro. Test when infinities supported. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target inff } */ + +#include + +#ifndef INFINITY +#error "INFINITY undefined" +#endif + +volatile float f = INFINITY; + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + (void) _Generic (INFINITY, float : 0); + if (!(INFINITY > FLT_MAX)) + abort (); + if (!(f > FLT_MAX)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-4.c b/SingleSource/Regression/C/gcc-dg/c2x-float-4.c new file mode 100644 index 0000000000..bca843547c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-4.c @@ -0,0 +1,33 @@ +/* Test NAN macro. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options ieee } */ + +#include + +/* This should be defined if and only if quiet NaNs are supported for + type float. If the testsuite gains effective-target support for + targets not supporting NaNs, or not supporting them for all types, + this test should be split into versions for targets with and + without NaNs for float. */ +#ifndef NAN +#error "NAN undefined" +#endif + +volatile float f = NAN; + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + (void) _Generic (NAN, float : 0); + if (!__builtin_isnan (NAN)) + abort (); + if (!__builtin_isnan (f)) + abort (); + if (!__builtin_isnan (f + f)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-5.c b/SingleSource/Regression/C/gcc-dg/c2x-float-5.c new file mode 100644 index 0000000000..477f9cf09c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-5.c @@ -0,0 +1,32 @@ +/* Test NAN macro. Runtime exceptions test, to verify NaN is quiet + not signaling. */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options ieee } */ + +#include +#include + +/* This should be defined if and only if quiet NaNs are supported for + type float. If the testsuite gains effective-target support for + targets not supporting NaNs, or not supporting them for all types, + this test should only be run for targets supporting quiet NaNs for + float. */ +#ifndef NAN +#error "NAN undefined" +#endif + +volatile float f = NAN; + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + f += f; + if (fetestexcept (FE_INVALID)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-6.c b/SingleSource/Regression/C/gcc-dg/c2x-float-6.c new file mode 100644 index 0000000000..573540b038 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-6.c @@ -0,0 +1,49 @@ +/* Test SNAN macros. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors -fsignaling-nans" } */ +/* { dg-add-options ieee } */ + +#include + +/* These should be defined if and only if signaling NaNs are supported + for the given types. If the testsuite gains effective-target + support for targets not supporting signaling NaNs, or not + supporting them for all types, this test should be made + appropriately conditional. */ +#ifndef FLT_SNAN +#error "FLT_SNAN undefined" +#endif +#ifndef DBL_SNAN +#error "DBL_SNAN undefined" +#endif +#ifndef LDBL_SNAN +#error "LDBL_SNAN undefined" +#endif + +volatile float f = FLT_SNAN; +volatile double d = DBL_SNAN; +volatile long double ld = LDBL_SNAN; + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + (void) _Generic (FLT_SNAN, float : 0); + (void) _Generic (DBL_SNAN, double : 0); + (void) _Generic (LDBL_SNAN, long double : 0); + if (!__builtin_isnan (FLT_SNAN)) + abort (); + if (!__builtin_isnan (f)) + abort (); + if (!__builtin_isnan (DBL_SNAN)) + abort (); + if (!__builtin_isnan (d)) + abort (); + if (!__builtin_isnan (LDBL_SNAN)) + abort (); + if (!__builtin_isnan (ld)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-7a.c b/SingleSource/Regression/C/gcc-dg/c2x-float-7a.c new file mode 100644 index 0000000000..129e7906ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-7a.c @@ -0,0 +1,32 @@ +/* Test SNAN macros. Runtime exceptions test, to verify NaN is + signaling. */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-options "-std=c2x -pedantic-errors -fsignaling-nans" } */ +/* { dg-add-options ieee } */ + +#include +#include + +/* This should be defined if and only if signaling NaNs is supported + for the given type. If the testsuite gains effective-target + support for targets not supporting signaling NaNs, this test + should be made appropriately conditional. */ +#ifndef FLT_SNAN +#error "FLT_SNAN undefined" +#endif + +volatile float f = FLT_SNAN; + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + feclearexcept (FE_ALL_EXCEPT); + f += f; + if (!fetestexcept (FE_INVALID)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-7b.c b/SingleSource/Regression/C/gcc-dg/c2x-float-7b.c new file mode 100644 index 0000000000..0ae9038c1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-7b.c @@ -0,0 +1,32 @@ +/* Test SNAN macros. Runtime exceptions test, to verify NaN is + signaling. */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv_exceptions_double } */ +/* { dg-options "-std=c2x -pedantic-errors -fsignaling-nans" } */ +/* { dg-add-options ieee } */ + +#include +#include + +/* This should be defined if and only if signaling NaNs is supported + for the given type. If the testsuite gains effective-target + support for targets not supporting signaling NaNs, this test + should be made appropriately conditional. */ +#ifndef DBL_SNAN +#error "DBL_SNAN undefined" +#endif + +volatile double d = DBL_SNAN; + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + feclearexcept (FE_ALL_EXCEPT); + d += d; + if (!fetestexcept (FE_INVALID)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-7c.c b/SingleSource/Regression/C/gcc-dg/c2x-float-7c.c new file mode 100644 index 0000000000..038fd5501b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-7c.c @@ -0,0 +1,32 @@ +/* Test SNAN macros. Runtime exceptions test, to verify NaN is + signaling. */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv_exceptions_long_double } */ +/* { dg-options "-std=c2x -pedantic-errors -fsignaling-nans" } */ +/* { dg-add-options ieee } */ + +#include +#include + +/* This should be defined if and only if signaling NaNs is supported + for the given type. If the testsuite gains effective-target + support for targets not supporting signaling NaNs, this test + should be made appropriately conditional. */ +#ifndef LDBL_SNAN +#error "LDBL_SNAN undefined" +#endif + +volatile long double ld = LDBL_SNAN; + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + feclearexcept (FE_ALL_EXCEPT); + ld += ld; + if (!fetestexcept (FE_INVALID)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-8.c b/SingleSource/Regression/C/gcc-dg/c2x-float-8.c new file mode 100644 index 0000000000..b10cb85009 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-8.c @@ -0,0 +1,7 @@ +/* Test including then does not result in errors + from duplicate NAN and INFINITY macros. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include +#include diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-9.c b/SingleSource/Regression/C/gcc-dg/c2x-float-9.c new file mode 100644 index 0000000000..0a54bc2ad4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-9.c @@ -0,0 +1,7 @@ +/* Test including then does not result in errors + from duplicate NAN and INFINITY macros. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include +#include diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-1.c b/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-1.c new file mode 100644 index 0000000000..73610c8524 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-1.c @@ -0,0 +1,101 @@ +/* Test DFP macros not defined in if no DFP support. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=c2x" } */ + +#include + +#ifdef DEC32_MANT_DIG +# error "DEC32_MANT_DIG defined" +#endif + +#ifdef DEC64_MANT_DIG +# error "DEC64_MANT_DIG defined" +#endif + +#ifdef DEC128_MANT_DIG +# error "DEC128_MANT_DIG defined" +#endif + +#ifdef DEC32_MIN_EXP +# error "DEC32_MIN_EXP defined" +#endif + +#ifdef DEC64_MIN_EXP +# error "DEC64_MIN_EXP defined" +#endif + +#ifdef DEC128_MIN_EXP +# error "DEC128_MIN_EXP defined" +#endif + +#ifdef DEC32_MAX_EXP +# error "DEC32_MAX_EXP defined" +#endif + +#ifdef DEC64_MAX_EXP +# error "DEC64_MAX_EXP defined" +#endif + +#ifdef DEC128_MAX_EXP +# error "DEC128_MAX_EXP defined" +#endif + +#ifdef DEC32_MAX +# error "DEC32_MAX defined" +#endif + +#ifdef DEC64_MAX +# error "DEC64_MAX defined" +#endif + +#ifdef DEC128_MAX +# error "DEC128_MAX defined" +#endif + +#ifdef DEC32_EPSILON +# error "DEC32_EPSILON defined" +#endif + +#ifdef DEC64_EPSILON +# error "DEC64_EPSILON defined" +#endif + +#ifdef DEC128_EPSILON +# error "DEC128_EPSILON defined" +#endif + +#ifdef DEC32_MIN +# error "DEC32_MIN defined" +#endif + +#ifdef DEC64_MIN +# error "DEC64_MIN defined" +#endif + +#ifdef DEC128_MIN +# error "DEC128_MIN defined" +#endif + +#ifdef DEC32_TRUE_MIN +# error "DEC32_TRUE_MIN defined" +#endif + +#ifdef DEC64_TRUE_MIN +# error "DEC64_TRUE_MIN defined" +#endif + +#ifdef DEC128_TRUE_MIN +# error "DEC128_TRUE_MIN defined" +#endif + +#ifdef DEC32_SUBNORMAL_MIN +# error "DEC32_SUBNORMAL_MIN defined" +#endif + +#ifdef DEC64_SUBNORMAL_MIN +# error "DEC64_SUBNORMAL_MIN defined" +#endif + +#ifdef DEC128_SUBNORMAL_MIN +# error "DEC128_SUBNORMAL_MIN defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-2.c b/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-2.c new file mode 100644 index 0000000000..730ce89c4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-2.c @@ -0,0 +1,9 @@ +/* Test DFP macros not defined in if no DFP support. Test + with feature test macros defined. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=c2x" } */ + +#define __STDC_WANT_DEC_FP__ +#define __STDC_WANT_IEC_60559_DFP_EXT__ + +#include "c2x-float-no-dfp-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-3.c b/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-3.c new file mode 100644 index 0000000000..aa790c8e21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-3.c @@ -0,0 +1,26 @@ +/* Test DFP macros not defined in if no DFP support. + Infinity and NaN macros. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=c2x" } */ + +#include + +#ifdef DEC_INFINITY +# error "DEC_INFINITY defined" +#endif + +#ifdef DEC_NAN +# error "DEC_NAN defined" +#endif + +#ifdef DEC32_SNAN +# error "DEC32_SNAN defined" +#endif + +#ifdef DEC64_SNAN +# error "DEC64_SNAN defined" +#endif + +#ifdef DEC128_SNAN +# error "DEC128_SNAN defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-4.c b/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-4.c new file mode 100644 index 0000000000..855922a47b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-float-no-dfp-4.c @@ -0,0 +1,10 @@ +/* Test DFP macros not defined in if no DFP support. + Infinity and NaN macros. Test with feature test macros + defined. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=c2x" } */ + +#define __STDC_WANT_DEC_FP__ +#define __STDC_WANT_IEC_60559_DFP_EXT__ + +#include "c2x-float-no-dfp-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/c2x-floatn-1.c b/SingleSource/Regression/C/gcc-dg/c2x-floatn-1.c new file mode 100644 index 0000000000..d9998496ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-floatn-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +_Float32 a + = 1.0F32; +_Float64 b + = 1.0F64; +_Float32x c + = 1.0F32x; +__extension__ _Float32 d + = 2.0F32; +__extension__ _Float64 e + = 2.0F64; +__extension__ _Float32x f + = 2.0F32x; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-floatn-2.c b/SingleSource/Regression/C/gcc-dg/c2x-floatn-2.c new file mode 100644 index 0000000000..179364564d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-floatn-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +_Float128 a + = 1.0F128; +__extension__ _Float128 b + = 2.0F128; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-floatn-3.c b/SingleSource/Regression/C/gcc-dg/c2x-floatn-3.c new file mode 100644 index 0000000000..9ac133ccfd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-floatn-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Float16 a + = 1.0F16; +__extension__ _Float16 b + = 2.0F16; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-floatn-4.c b/SingleSource/Regression/C/gcc-dg/c2x-floatn-4.c new file mode 100644 index 0000000000..5d3ab24ac1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-floatn-4.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +_Float64x a + = 1.0F64x; +__extension__ _Float64x b + = 2.0F64x; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-floatn-5.c b/SingleSource/Regression/C/gcc-dg/c2x-floatn-5.c new file mode 100644 index 0000000000..ea4e4bed45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-floatn-5.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +_Float32 a /* { dg-warning "ISO C does not support the '_Float32' type before C2X" } */ + = 1.0F32; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +_Float64 b /* { dg-warning "ISO C does not support the '_Float64' type before C2X" } */ + = 1.0F64; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +_Float32x c /* { dg-warning "ISO C does not support the '_Float32x' type before C2X" } */ + = 1.0F32x; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float32 d + = 2.0F32; +__extension__ _Float64 e + = 2.0F64; +__extension__ _Float32x f + = 2.0F32x; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-floatn-6.c b/SingleSource/Regression/C/gcc-dg/c2x-floatn-6.c new file mode 100644 index 0000000000..c982a11d16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-floatn-6.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +_Float128 a /* { dg-warning "ISO C does not support the '_Float128' type before C2X" } */ + = 1.0F128; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float128 b + = 2.0F128; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-floatn-7.c b/SingleSource/Regression/C/gcc-dg/c2x-floatn-7.c new file mode 100644 index 0000000000..bf9b1ffba7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-floatn-7.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Float16 a /* { dg-warning "ISO C does not support the '_Float16' type before C2X" } */ + = 1.0F16; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float16 b + = 2.0F16; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-floatn-8.c b/SingleSource/Regression/C/gcc-dg/c2x-floatn-8.c new file mode 100644 index 0000000000..7174b66032 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-floatn-8.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +_Float64x a /* { dg-warning "ISO C does not support the '_Float64x' type before C2X" } */ + = 1.0F64x; /* { dg-warning "non-standard suffix on floating constant before C2X" } */ +__extension__ _Float64x b + = 2.0F64x; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-fordecl-1.c b/SingleSource/Regression/C/gcc-dg/c2x-fordecl-1.c new file mode 100644 index 0000000000..563186f060 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-fordecl-1.c @@ -0,0 +1,6 @@ +/* Test restrictions on the kind of declarations permitted in for loops removed + in C2X. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include "c99-fordecl-2.c" diff --git a/SingleSource/Regression/C/gcc-dg/c2x-fordecl-2.c b/SingleSource/Regression/C/gcc-dg/c2x-fordecl-2.c new file mode 100644 index 0000000000..42501901c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-fordecl-2.c @@ -0,0 +1,6 @@ +/* Test restrictions on the kind of declarations permitted in for loops removed + in C2X. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include "c99-fordecl-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/c2x-fordecl-3.c b/SingleSource/Regression/C/gcc-dg/c2x-fordecl-3.c new file mode 100644 index 0000000000..d39d4a6a4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-fordecl-3.c @@ -0,0 +1,27 @@ +/* Test for C99 declarations in for loops. Test constraints are diagnosed with + -Wc11-c2x-compat for C2X. Based on c99-fordecl-2.c. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +void +foo (void) +{ + int j = 0; + for (int i = 1, bar (void); i <= 10; i++) /* { dg-warning "bar" } */ + j += i; + + for (static int i = 1; i <= 10; i++) /* /* { dg-warning "static" } */ + j += i; + + for (extern int i; j <= 500; j++) /* { dg-warning "extern" } */ + j += 5; + + for (enum { FOO } i = FOO; i < 10; i++) /* { dg-warning "FOO" } */ + j += i; + + for (enum BAR { FOO } i = FOO; i < 10; i++) /* { dg-warning "FOO" } */ + /* { dg-warning "BAR" "enum tag in for loop" { target *-*-* } .-1 } */ + j += i; + for (typedef int T;;) /* { dg-warning "non-variable" } */ + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-fordecl-4.c b/SingleSource/Regression/C/gcc-dg/c2x-fordecl-4.c new file mode 100644 index 0000000000..e9dfc4b51f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-fordecl-4.c @@ -0,0 +1,14 @@ +/* Test for C99 declarations in for loops. Test constraints are diagnosed with + -Wc11-c2x-compat for C2X: struct and union tags can't be declared there + (affirmed in response to DR#277). Based on c99-fordecl-3.c. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +void +foo (void) +{ + for (struct s { int p; } *p = 0; ;) /* { dg-warning "'struct s' declared in 'for' loop initial declaration" } */ + ; + for (union u { int p; } *p = 0; ;) /* { dg-warning "'union u' declared in 'for' loop initial declaration" } */ + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-1.c b/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-1.c new file mode 100644 index 0000000000..fe06abf99b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-1.c @@ -0,0 +1,28 @@ +/* Test __has_c_attribute. Test basic properties. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#ifdef __has_c_attribute +/* OK. */ +#else +#error "__has_c_attribute not defined" +#endif + +#ifndef __has_c_attribute +#error "__has_c_attribute not defined" +#endif + +#if defined __has_c_attribute +/* OK. */ +#else +#error "__has_c_attribute not defined" +#endif + +#if __has_c_attribute(foo) +#error "foo attribute supported" +#endif + +#if 0 +#elif __has_c_attribute(foo) +#error "foo attribute supported" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-2.c b/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-2.c new file mode 100644 index 0000000000..dc92b95e90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-2.c @@ -0,0 +1,57 @@ +/* Test __has_c_attribute. Test supported attributes. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#if __has_c_attribute ( nodiscard ) != 202311L +#error "bad result for nodiscard" +#endif + +#if __has_c_attribute ( __nodiscard__ ) != 202311L +#error "bad result for __nodiscard__" +#endif + +#if __has_c_attribute(maybe_unused) != 202311L +#error "bad result for maybe_unused" +#endif + +#if __has_c_attribute(__maybe_unused__) != 202311L +#error "bad result for __maybe_unused__" +#endif + +#if __has_c_attribute (deprecated) != 202311L +#error "bad result for deprecated" +#endif + +#if __has_c_attribute (__deprecated__) != 202311L +#error "bad result for __deprecated__" +#endif + +#if __has_c_attribute (fallthrough) != 202311L +#error "bad result for fallthrough" +#endif + +#if __has_c_attribute (__fallthrough__) != 202311L +#error "bad result for __fallthrough__" +#endif + +#if __has_c_attribute (noreturn) != 202311L +#error "bad result for noreturn" +#endif + +#if __has_c_attribute (__noreturn__) != 202311L +#error "bad result for __noreturn__" +#endif + +#if __has_c_attribute (_Noreturn) != 202311L +#error "bad result for _Noreturn" +#endif + +#if __has_c_attribute (___Noreturn__) != 202311L +#error "bad result for ___Noreturn__" +#endif + +/* Macros in the attribute name are expanded. */ +#define foo deprecated +#if __has_c_attribute (foo) != 202311L +#error "bad result for foo" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-3.c b/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-3.c new file mode 100644 index 0000000000..36842ed41b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-3.c @@ -0,0 +1,25 @@ +/* Test __has_c_attribute. Test GNU attributes. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#if __has_c_attribute (gnu::packed) != 1 +#error "bad result for gnu::packed" +#endif + +#if __has_c_attribute (__gnu__::__packed__) != 1 +#error "bad result for __gnu__::__packed__" +#endif + +#if __has_c_attribute (gnu::__packed__) != 1 +#error "bad result for gnu::__packed__" +#endif + +#if __has_c_attribute (__gnu__::packed) != 1 +#error "bad result for __gnu__::packed" +#endif + +/* GNU attributes should not be reported as accepted without a scope + specified. */ +#if __has_c_attribute (packed) != 0 +#error "bad result for packed" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-4.c b/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-4.c new file mode 100644 index 0000000000..acd35d2d5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-has-c-attribute-4.c @@ -0,0 +1,18 @@ +/* Test __has_c_attribute. Test syntax errors. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#if __has_c_attribute /* { dg-error "missing '\\('" } */ +#endif + +#if __has_c_attribute 0 /* { dg-error "missing '\\('" } */ +#endif + +#if __has_c_attribute (0 /* { dg-error "requires an identifier" } */ +#endif + +#if __has_c_attribute (x /* { dg-error "missing '\\)'" } */ +#endif + +#if __has_c_attribute (x::0) /* { dg-error "required after scope" } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-labels-1.c b/SingleSource/Regression/C/gcc-dg/c2x-labels-1.c new file mode 100644 index 0000000000..439cf7834e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-labels-1.c @@ -0,0 +1,23 @@ +/* Tests for labels before declarations and at ends of compound statements. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int f(int x) +{ + goto b; + a: int i = 2 * x; + aa: int u = 0; int v = 0; + goto c; + b: goto a; + { i *= 3; c: } + return i + u + v; + d: +} + +int main(void) +{ + if (2 != f(1)) + __builtin_abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-labels-2.c b/SingleSource/Regression/C/gcc-dg/c2x-labels-2.c new file mode 100644 index 0000000000..bd010e9ecf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-labels-2.c @@ -0,0 +1,15 @@ +/* Tests for labels before declarations and at ends of compound statements. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ + +int f(int x) +{ + goto b; + a: int i = 2 * x; /* { dg-warning "a label can only be part of a statement and a declaration is not a statement" } */ + goto c; + b: goto a; + { i *= 3; c: } /* { dg-warning "label at end of compound statement" } */ + return i; + d: /* { dg-warning "label at end of compound statement" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/c2x-labels-3.c b/SingleSource/Regression/C/gcc-dg/c2x-labels-3.c new file mode 100644 index 0000000000..159116db18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-labels-3.c @@ -0,0 +1,38 @@ +/* Tests for labels before declarations and at ends of compound statements + * in combination with attributes. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wall" } */ + +int f(void) +{ + goto b; + a: int i = 0; + aa: __attribute__((unused)) int u = 0; int v = 0; /* { dg-warning "GNU-style attribute between label and declaration appertains to the label" } */ + goto c; + { c: } + b: goto a; + return i + u + v; + d: __attribute__((unused)) (void)0; + e: __attribute__((unused)) +} + +int g(void) +{ + goto b; + a: int i = 0; + [[maybe_unused]] aa: int u = 0; int v = 0; + goto c; + { c: } + b: goto a; + return i + u + v; + [[maybe_unused]] d: (void)0; + [[maybe_unused]] e: +} + +void h(void) +{ + [[maybe_unused]] a: [[maybe_unused]] b: [[maybe_unused]] int x; + + if (1) + [[maybe_unused]] c: [[maybe_unused]] d: (void)0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-limits-1.c b/SingleSource/Regression/C/gcc-dg/c2x-limits-1.c new file mode 100644 index 0000000000..4977faf47b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-limits-1.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_LIMITS_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_LIMITS_H__ +#error "__STDC_VERSION_LIMITS_H__ not defined" +#endif + +#if __STDC_VERSION_LIMITS_H__ != 202311L +#error "bad value of __STDC_VERSION_LIMITS_H__" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-no-dfp-1.c b/SingleSource/Regression/C/gcc-dg/c2x-no-dfp-1.c new file mode 100644 index 0000000000..2cfbb6cad2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-no-dfp-1.c @@ -0,0 +1,12 @@ +/* Test DFP types and constants rejected if no DFP support. Bug + 91985. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=c2x" } */ + +_Decimal32 d32a; /* { dg-error "not supported" } */ +_Decimal64 d64a; /* { dg-error "not supported" } */ +_Decimal128 d128a; /* { dg-error "not supported" } */ + +_Bool d32b = 1.0DF; /* { dg-error "not supported" } */ +_Bool d64b = 1.0DD; /* { dg-error "not supported" } */ +_Bool d128b = 1.0DL; /* { dg-error "not supported" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-nullptr-1.c b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-1.c new file mode 100644 index 0000000000..4e440234d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-1.c @@ -0,0 +1,328 @@ +/* Test valid usage of C23 nullptr. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors -Wall -Wextra -Wno-unused-variable" } */ + +#include + +typedef __typeof__(nullptr) nullptr_t; + +void f1 (nullptr_t) { } +void f2 (int *) { } +void f3 (_Bool) { } +nullptr_t cmp (void) { return nullptr; } + +/* The type nullptr_t shall not be converted to any type other than void, bool + or a pointer type. No type other than nullptr_t or a null pointer constant + shall be converted to nullptr_t. */ +void +test1 (void) +{ + const nullptr_t nptr = nullptr; + static nullptr_t static_nptr; + int *p1 = nullptr; + void *p2 = nullptr; + float *p3 = nullptr; + void (*p4)(int) = nullptr; + int (*p5)[10] = nullptr; + int *p6 = nptr; + void *p7 = nptr; + float *p8 = nptr; + void (*p9)(int) = nptr; + int (*p10)[10] = nptr; + int *p11 = (int *) nullptr; + int *p12 = (int *) nptr; + int *p13 = (nullptr); + int *p14 = _Generic(0, int : nullptr); + if (nullptr || p1 || p2 || p3 || p4 || p5 || p6 || p7 || p8 || p9 || p10 + || p11 || p12 || p13 || p14) + __builtin_abort (); + + _Bool b1 = nullptr; + _Bool b2 = (_Bool) nullptr; + _Bool b3 = nptr; + _Bool b4 = (_Bool) nptr; + _Bool b5 = _Generic(0, int : nullptr); + if (b1 || b2 || b3 || b4 || b5 || (_Bool) nullptr || (_Bool) nptr) + __builtin_abort (); + + __auto_type a1 = nullptr; + __auto_type a2 = nptr; + + /* We can convert nullptr_t to nullptr_t. */ + __typeof__(nullptr) x = nullptr; + f1 (x); + f1 (nullptr); + f1 (_Generic(0, int : nullptr)); + f2 (x); + f2 (nullptr); + f3 (nullptr); + + const nullptr_t np1 = nullptr; + const nullptr_t np2 = np1; + (void) nullptr; + (void) np1; + (void) np2; + (void) cmp (); + (void)(nullptr_t) nullptr; + + const nullptr_t n = 0; + (void) (nullptr_t) 0; + + f1 (0); + f1 ((void *) 0); + f1 (0L); + nullptr_t n2; + n2 = (void *) 0; + n2 = 123 - 123; + (void) n2; +} + +/* Test valid comparison. */ +void +test2 (int *p) +{ + /* If both operands have type nullptr_t or one operand has type nullptr_t + and the other is a null pointer constant, they compare equal. */ + const nullptr_t nptr = nullptr; + int r = 0; + + /* Both operands have type nullptr_t. */ + r |= nullptr != nullptr; + r |= cmp () != nullptr; + r |= nullptr != cmp (); + r |= !(nullptr == nullptr); + r |= !(cmp () == nullptr); + r |= !(nullptr == cmp ()); + r |= nptr != nptr; + r |= cmp () != nptr; + r |= nptr != cmp (); + r |= !(nptr == nptr); + r |= !(cmp () == nptr); + r |= !(nptr == cmp ()); + + /* One operand has type nullptr_t and the other is a null pointer constant. */ + r |= nullptr != (void *) 0; + r |= _Generic(0, int : nullptr) != (void *) 0; + r |= (nullptr) != (void *) 0; + r |= !(nullptr == (void *) 0); + r |= (void *) 0 != nullptr; + r |= (void *) 0 != (nullptr); + r |= !((void *) 0 == nullptr); + r |= nullptr != 0; + r |= _Generic(0, int : nullptr) != 0; + r |= (nullptr) != 0; + r |= 0 != nullptr; + r |= 0 != (nullptr); + r |= !(nullptr == 0); + r |= !(0 == nullptr); + r |= nullptr != 0u; + r |= 0u != nullptr; + r |= !(nullptr == 0u); + r |= !(0u == nullptr); + r |= nptr != (void *) 0; + r |= !(nptr == (void *) 0); + r |= (void *) 0 != nptr; + r |= !((void *) 0 == nptr); + r |= nptr != 0; + r |= 0 != nptr; + r |= !(nptr == 0); + r |= !(0 == nptr); + r |= nptr != 0u; + r |= 0u != nptr; + r |= !(nptr == 0u); + r |= !(0u == nptr); + r |= nptr != _Generic(0, int : nullptr); + r |= _Generic(0, int : nullptr) != nptr; + if (r) + __builtin_abort (); + + /* One operand is a pointer and the other is a null pointer constant. */ + (void) (p == nullptr); + (void) (p != nullptr); + (void) (nullptr == p); + (void) (nullptr != p); + (void) (p == (nullptr)); + (void) (p != (nullptr)); + (void) ((nullptr) == p); + (void) ((nullptr) != p); + (void) ((void *)nullptr == nullptr); + (void) ((void *)nullptr != nullptr); + (void) (nullptr == (void *)nullptr); + (void) (nullptr != (void *)nullptr); + (void) (p == _Generic(0, int : nullptr)); + (void) (p != _Generic(0, int : nullptr)); + (void) (_Generic(0, int : nullptr) == p); + (void) (_Generic(0, int : nullptr) != p); + + /* "(nullptr_t)nullptr" has type nullptr_t but isn't an NPC; these + comparisons are valid after C2X CD comments GB-071 and FR-073 were + resolved by the wording in N3077. */ + (void) ((nullptr_t)nullptr == p); + (void) ((nullptr_t)nullptr != p); + (void) (p == (nullptr_t)nullptr); + (void) (p != (nullptr_t)nullptr); + (void) (cmp () == p); + (void) (cmp () != p); + (void) (p == cmp ()); + (void) (p != cmp ()); + /* "(void *)nullptr" is not an NPC, either. */ + (void) ((void *)nullptr == cmp ()); + (void) ((void *)nullptr != cmp ()); + (void) (cmp () == (void *)nullptr); + (void) (cmp () != (void *)nullptr); +} + +/* Test ?:. */ +void +test3 (int *p, _Bool b) +{ + int x = nullptr ? 1 : 2; + (void) x; + const nullptr_t nptr = nullptr; + /* One of the following shall hold for the second and third operands: + -- both operands have nullptr_t type. */ + __auto_type r1 = b ? nullptr : nullptr; + __auto_type r2 = b ? nptr : nptr; + /* -- one operand is a pointer and the other is a null pointer constant + or has type nullptr_t; */ + __auto_type r3 = b ? p : nullptr; + __auto_type r4 = b ? nullptr : p; + __auto_type r5 = b ? nptr : p; + __auto_type r6 = b ? p : nptr; + __auto_type r7 = b ? 0 : p; + __auto_type r8 = b ? p : 0; + __auto_type r9 = b ? p : cmp (); + __auto_type r10 = b ? cmp () : p; + __auto_type r11 = b ? p : _Generic(0, int : nullptr); + __auto_type r12 = b ? _Generic(0, int : nullptr) : p; +} + +void test_arg1 (const nullptr_t, _Atomic nullptr_t, volatile nullptr_t) { } +void test_arg2 (_Atomic int *, const int *, volatile int *) { } +void test_arg3 (_Atomic _Bool, const _Bool, volatile _Bool) { } +nullptr_t retn (void) { return nullptr; } +_Atomic int *ai (void) { return nullptr; } +const int *ci (void) { return nullptr; } +volatile int *vi (void) { return nullptr; } +_Bool retb (void) { return nullptr; } + +/* Simple assignment. */ +void +test4 (void) +{ + /* -- the left operand has an atomic, qualified, or unqualified version of + the nullptr_t type and the type of the right is nullptr_t; */ + nullptr_t n1; + const nullptr_t n2 = nullptr; + _Atomic nullptr_t n3 = nullptr; + volatile nullptr_t n4 = nullptr; + _Atomic volatile nullptr_t n5 = nullptr; + n1 = nullptr; + n3 = nullptr; + n4 = nullptr; + n5 = nullptr; + n5 = _Generic(0, int : nullptr); + /* -- the left operand is an atomic, qualified, or unqualified pointer, + and the type of the right is nullptr_t; */ + int *p1 = cmp (); + _Atomic int *p2 = cmp (); + const int *volatile p3 = cmp (); + const int *const *const p4 = cmp (); + double (*const p5)(void) = n1; + p2 = _Generic(0, int : nullptr); + p3 = nullptr; + /* -- the left operand is an atomic, qualified, or unqualified bool, and + the type of the right is nullptr_t; */ + _Bool b1; + b1 = cmp (); + const _Bool b2 = nullptr; + _Atomic _Bool b3; + b3 = n1; + (void) b1; + (void) b3; + (void) n3; + (void) n4; + (void) n5; + (void) p2; + (void) p3; + + test_arg1 (nullptr, nullptr, nullptr); + test_arg2 (nullptr, nullptr, nullptr); + test_arg3 (nullptr, nullptr, nullptr); +} + +/* var_arg etc. */ +static void +test5 (int i, ...) +{ + (void) i; + va_list ap; + va_start (ap, i); + if (va_arg (ap, void *)) + __builtin_abort (); +} + +/* Operand of alignas, sizeof or typeof operators. */ +void +test6 (void) +{ + _Static_assert (sizeof (nullptr) == sizeof (void *), "sizeof (nullptr)"); + _Static_assert (sizeof (nullptr_t) == sizeof (void *), "sizeof (nullptr_t)"); + _Static_assert (sizeof (nullptr) == sizeof (char *), "sizeof (nullptr)"); + _Static_assert (sizeof (nullptr_t) == sizeof (char *), "sizeof (nullptr_t)"); + _Static_assert (_Alignof (nullptr_t) == _Alignof (char *), "_Alignof (nullptr_t)"); + __typeof__(nullptr) t = nullptr; + f1 (t); + _Alignas (nullptr_t) char i1 = 'q'; + + _Static_assert (_Generic (nullptr, nullptr_t: 1, default: 0) == 1, "_Generic"); + _Static_assert (_Generic (t, nullptr_t: 1, default: 0) == 1, "_Generic"); + _Static_assert (_Generic (cmp (), nullptr_t: 1, default: 0) == 1, "_Generic"); + _Static_assert (_Generic (0, nullptr_t: 1, int: 2, default: 0) == 2, "_Generic"); + _Static_assert (_Generic ((void *)0, nullptr_t: 1, void *: 2, default: 0) == 2, "_Generic"); + _Static_assert (_Generic (nullptr, nullptr_t: 1, void *: 2, default: 0) == 1, "_Generic"); +} + +/* Play with !, ||, &&. */ +void +test7 (void) +{ + if (nullptr) + __builtin_abort (); + if (1 && nullptr) + __builtin_abort (); + if (0 || nullptr) + __builtin_abort (); + if (nullptr && 1) + __builtin_abort (); + if (nullptr || 0) + __builtin_abort (); + if (!nullptr) + { + } + else + __builtin_abort (); + while (nullptr) + __builtin_abort (); + int i = 0; + do + ++i; + while (nullptr); + if (i != 1) + __builtin_abort (); + for (;nullptr;) + __builtin_abort (); +} + +int +main (void) +{ + int i = 42; + test1 (); + test2 (&i); + test3 (&i, 0); + test4 (); + test5 (42, nullptr); + test6 (); + test7 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-nullptr-2.c b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-2.c new file mode 100644 index 0000000000..b610565736 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-2.c @@ -0,0 +1,9 @@ +/* Test nullptr_t from . */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +void f(nullptr_t); +_Static_assert (sizeof (nullptr_t) == sizeof (char *), "sizeof (nullptr_t)"); +_Static_assert (_Alignof (nullptr_t) == _Alignof (char *), "_Alignof (nullptr_t)"); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-nullptr-3.c b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-3.c new file mode 100644 index 0000000000..09d9856ef9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-3.c @@ -0,0 +1,68 @@ +/* Test wrong usage of C23 nullptr. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wall -Wextra -Wno-unused-variable" } */ + +typedef __typeof__(nullptr) nullptr_t; + +void g (nullptr_t); /* { dg-message "expected .nullptr_t. but argument is of type .int." } */ +nullptr_t cmp (void); + +void +test1 (int *p) +{ + (void) (p > nullptr); /* { dg-error "ordered comparison" } */ + (void) (p >= nullptr); /* { dg-error "ordered comparison" } */ + (void) (p < nullptr); /* { dg-error "ordered comparison" } */ + (void) (p <= nullptr); /* { dg-error "ordered comparison" } */ + (void) (nullptr == 1); /* { dg-error "invalid operands" } */ + (void) (1 == nullptr); /* { dg-error "invalid operands" } */ + (void) (nullptr != 1); /* { dg-error "invalid operands" } */ + (void) (1 != nullptr); /* { dg-error "invalid operands" } */ + (void) (1 > nullptr); /* { dg-error "invalid operands" } */ +} + +void +test2 (void) +{ + const nullptr_t nptr = nullptr; + int p = nullptr; /* { dg-error "incompatible types" } */ + float d = nullptr; /* { dg-error "incompatible types" } */ + char arr[10] = { nullptr }; /* { dg-error "incompatible types" } */ + + /* Unary '+' is not valid for nullptr. */ + +nullptr; /* { dg-error "wrong type argument to unary plus" } */ + + g (0.0); /* { dg-error "incompatible type" } */ + g (1); /* { dg-error "incompatible type" } */ + g ((int) (float) 0.0); /* { dg-error "incompatible type" } */ + int i = 42 + nullptr; /* { dg-error "invalid operands" } */ + + /* The assignment of an object of type nullptr_t with a value of another + type, other than a null pointer constant, is a constraint + violation. */ + nullptr_t m; + m = 1; /* { dg-error "incompatible types" } */ + m = 0.0; /* { dg-error "incompatible types" } */ + (void) m; + nullptr_t o = 1; /* { dg-error "incompatible types" } */ + (nullptr_t) 0.0; /* { dg-error "conversion" } */ + (nullptr_t) (int) (float) 0.0; /* { dg-error "conversion" } */ + + switch (nullptr); /* { dg-error "switch quantity not an integer" } */ +} + +/* If a second or third operand of type nullptr_t is used that is not a null + pointer constant and the other operand is not a pointer or does not have + itself nullptr_t, a constraint is violated even if that other operand is + a null pointer constant such as 0. */ +void +test3 (_Bool b, int i) +{ + const nullptr_t nptr = nullptr; + __auto_type a1 = b ? nptr : i; /* { dg-error "type mismatch" } */ + __auto_type a2 = b ? i : nptr; /* { dg-error "type mismatch" } */ + __auto_type a3 = b ? nptr : 0; /* { dg-error "type mismatch" } */ + __auto_type a4 = b ? 0 : nptr; /* { dg-error "type mismatch" } */ + __auto_type a5 = b ? 0 : nullptr; /* { dg-error "type mismatch" } */ + __auto_type a6 = b ? nullptr : 0; /* { dg-error "type mismatch" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-nullptr-4.c b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-4.c new file mode 100644 index 0000000000..7479ab4ea1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-4.c @@ -0,0 +1,11 @@ +/* Test that -Wc11-c2x-compat issues a warning (not a pedwarn) about + `nullptr' in C2X. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +int * +fn (int *p) +{ + p = nullptr; /* { dg-warning "ISO C does not support .nullptr. before C2X" } */ + return p; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-nullptr-5.c b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-5.c new file mode 100644 index 0000000000..27803f7d03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-5.c @@ -0,0 +1,14 @@ +/* Test that we don't lose side-effects when converting from nullptr_t. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int i; +nullptr_t fn () { ++i; return nullptr; } + +int +main () +{ + int *p = fn (); + if (i != 1) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-nullptr-6.c b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-6.c new file mode 100644 index 0000000000..24e14fa692 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-nullptr-6.c @@ -0,0 +1,33 @@ +/* PR c/108424 */ +/* { dg-options "-std=c2x" } */ + +struct S { + int i; + int : nullptr; /* { dg-error "not an integer constant" } */ +}; + +enum E { X = nullptr }; /* { dg-error "not an integer constant" } */ + +alignas(nullptr) int g; /* { dg-error "not an integer constant" } */ + +int arr[10] = { [nullptr] = 1 }; /* { dg-error "not of integer type" } */ + +_Static_assert (nullptr, "nullptr"); /* { dg-error "not an integer" } */ + +void f (int n) +{ + switch (n) { + case nullptr: /* { dg-error "an integer constant" } */ + default: + } + + switch (n) { + case 1 ... nullptr: /* { dg-error "an integer constant" } */ + default: + } + + switch (n) { + case nullptr ... 2: /* { dg-error "an integer constant" } */ + default: + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-1.c b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-1.c new file mode 100644 index 0000000000..c775366d70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-1.c @@ -0,0 +1,9 @@ +/* Test old-style function definitions not in C2x: warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +void +f (x) /* { dg-warning "old-style function definition" } */ + int x; +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-2.c b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-2.c new file mode 100644 index 0000000000..7bd5a60f6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-2.c @@ -0,0 +1,9 @@ +/* Test old-style function definitions not in C2x: errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +void +f (x) /* { dg-error "old-style function definition" } */ + int x; +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-3.c b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-3.c new file mode 100644 index 0000000000..a2500769f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-3.c @@ -0,0 +1,10 @@ +/* Test old-style function definitions not in C2x: warnings disabled + by -Wno-old-style-definition. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wno-old-style-definition" } */ + +void +f (x) + int x; +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-4.c b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-4.c new file mode 100644 index 0000000000..b1862b101b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-4.c @@ -0,0 +1,15 @@ +/* Test old-style function definitions not in C2x: () gives type with + a prototype. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +void +f () +{ +} + +void +g (void) +{ + f (1); /* { dg-error "too many arguments to function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-5.c b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-5.c new file mode 100644 index 0000000000..0c37a067c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-5.c @@ -0,0 +1,9 @@ +/* Test old-style function definitions not in C2x: () does not warn + with -Wold-style-definition. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wold-style-definition" } */ + +void +f () +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-6.c b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-6.c new file mode 100644 index 0000000000..72bfd56f00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-old-style-definition-6.c @@ -0,0 +1,16 @@ +/* Test old-style function definitions not in C2x: () gives a type with + a prototype for all declarations. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +void f1 (); /* { dg-message "declared here" } */ + +/* Prototyped function returning a pointer to a function with no arguments. */ +void (*f2 (void))() { return f1; } + +void +g (void) +{ + f1 (1); /* { dg-error "too many arguments" } */ + f2 () (1); /* { dg-error "too many arguments" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-1.c b/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-1.c new file mode 100644 index 0000000000..0dc89bb027 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-1.c @@ -0,0 +1,5 @@ +/* Test omitted parameter names in C2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +void f (int) { } diff --git a/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-2.c b/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-2.c new file mode 100644 index 0000000000..7d68933281 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-2.c @@ -0,0 +1,10 @@ +/* Test omitted parameter names in C2x. Warning test: there should be + no warning for an unnamed parameter being unused. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wall -Wextra" } */ + +int +f (int a, int, int c, int d) /* { dg-warning "unused parameter 'd'" } */ +{ + return a + c; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-3.c b/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-3.c new file mode 100644 index 0000000000..dac258b0fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-3.c @@ -0,0 +1,23 @@ +/* Test omitted parameter names in C2x. Execution test. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +void +f (int a, int [++a], int b) +{ + /* Verify array size expression of unnamed parameter is processed as + expected. */ + if (a != 2 || b != 3) + abort (); +} + +int +main (void) +{ + int t[2]; + f (1, t, 3); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-4.c b/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-4.c new file mode 100644 index 0000000000..a4b0deb7ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-parm-omit-4.c @@ -0,0 +1,5 @@ +/* Test omitted parameter names in C2x: diagnosed with -Wc11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ + +void f (int) { } /* { dg-warning "omitting parameter names" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-qual-1.c b/SingleSource/Regression/C/gcc-dg/c2x-qual-1.c new file mode 100644 index 0000000000..4d33db1907 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-qual-1.c @@ -0,0 +1,30 @@ +/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C2X */ + +void f(void) +{ + const int (*u)[1]; + void *v; + _Static_assert(_Generic(1 ? u : v, const void*: 1, void*: 0), "lost qualifier"); + _Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier"); +} + +/* test that assignment of unqualified to qualified pointers works as expected */ + +void g(void) +{ + int (*x)[3]; + const int (*p)[3] = x; +} + +/* test that assignment of qualified void pointers works as expected */ + +void h(void) +{ + const void* x; + const int (*p)[3] = x; +} + diff --git a/SingleSource/Regression/C/gcc-dg/c2x-qual-2.c b/SingleSource/Regression/C/gcc-dg/c2x-qual-2.c new file mode 100644 index 0000000000..f60a5b18fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-qual-2.c @@ -0,0 +1,30 @@ +/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ + +/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C2X */ + +void f(void) +{ + const int (*u)[1]; + void *v; + _Static_assert(_Generic(1 ? u : v, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */ + _Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */ +} + +/* test that assignment of unqualified to qualified pointers works as expected */ + +void g(void) +{ + int (*x)[3]; + const int (*p)[3] = x; /* { dg-warning "arrays with different qualifiers" } */ +} + +/* test that assignment of qualified void pointers works as expected */ + +void h(void) +{ + const void* x; + const int (*p)[3] = x; /* { dg-warning "array with qualifier on the element is not qualified before C2X" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/c2x-qual-3.c b/SingleSource/Regression/C/gcc-dg/c2x-qual-3.c new file mode 100644 index 0000000000..31896fcb1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-qual-3.c @@ -0,0 +1,30 @@ +/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat -pedantic-errors" } */ + +/* test that qualifiers are preserved in tertiary operator for pointers to arrays in C2X */ + +void f(void) +{ + const int (*u)[1]; + void *v; + _Static_assert(_Generic(1 ? u : v, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */ + _Static_assert(_Generic(1 ? v : u, const void*: 1, void*: 0), "lost qualifier"); /* { dg-warning "pointer to array loses qualifier in conditional" } */ +} + +/* test that assignment of unqualified to qualified pointers works as expected */ + +void g(void) +{ + int (*x)[3]; + const int (*p)[3] = x; /* { dg-warning "arrays with different qualifiers" } */ +} + +/* test that assignment of qualified void pointers works as expected */ + +void h(void) +{ + const void* x; + const int (*p)[3] = x; /* { dg-warning "array with qualifier on the element is not qualified before C2X" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/c2x-qual-4.c b/SingleSource/Regression/C/gcc-dg/c2x-qual-4.c new file mode 100644 index 0000000000..93b4723dcd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-qual-4.c @@ -0,0 +1,105 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ +void tvoid(void* x); +void transpose0(double* out, const double* in) { } +void transpose1(double out[2][2], const double in[2][2]) { } +void transpose2(double out[2][2][2], const double in[2][2][2]) { } +// return +int (*y2(const int x[3][3]))[3] { return x; } /* { dg-warning "return discards 'const' qualifier from pointer target type" } */ +const int (*y3(int x[3][3]))[3] { return x; } +void test(void) +{ + double x0[2]; + double y0[2]; + const double z0[4]; + double x1[2][2]; + double y1[2][2]; + double o1[2][3]; + const double z1[2][2]; + double x2[2][2][2]; + double y2[2][2][2]; + double o2[2][2][3]; + const double z2[2][2][2]; + // void pointers + tvoid(x0); + tvoid(x1); + tvoid(x2); + tvoid(z0); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z1); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z2); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + void* p; + const void* pc; + p = x0; + p = x1; + p = x2; + p = z0; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + p = z1; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + p = z2; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + pc = x0; + pc = x1; + pc = x2; + pc = z0; + pc = z1; + pc = z2; + transpose0(pc, p); /* { dg-warning "passing argument 1 of 'transpose0' discards 'const' qualifier from pointer target type" } */ + transpose1(pc, p); /* { dg-warning "passing argument 1 of 'transpose1' discards 'const' qualifier from pointer target type" } */ + transpose2(pc, p); /* { dg-warning "passing argument 1 of 'transpose2' discards 'const' qualifier from pointer target type" } */ + transpose0(p, pc); + transpose1(p, pc); + transpose2(p, pc); + // passing as arguments + transpose0(y0, x0); + transpose1(y1, x1); + transpose2(y2, x2); + // initialization + const double (*u0p) = x0; + const double (*u1p)[2] = x1; + const double (*u2p)[2][2] = x2; + double (*v0p) = z0; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */ + double (*v1p)[2] = z1; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */ + double (*v2p)[2][2] = z2; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */ + // subtraction + &(x0[1]) - &(z0[0]); + &(x1[1]) - &(z1[0]); + &(x2[1]) - &(z2[0]); + // comparison + x0 == z0; + x1 == z1; + x2 == z2; + x0 < z0; + x1 < z1; + x2 < z2; + x0 > z0; + x1 > z1; + x2 > z2; + // assignment + u0p = x0; + u1p = x1; + u2p = x2; + v0p = z0; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = z1; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = z2; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + // conditional expressions + (void)(1 ? x0 : z0); + (void)(1 ? x1 : z1); + (void)(1 ? x2 : z2); + (void)(1 ? x0 : x1); /* { dg-warning "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : x2); /* { dg-warning "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : x0); /* { dg-warning "pointer type mismatch in conditional expression" } */ + v0p = (1 ? z0 : v0p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? z1 : v1p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? z2 : v2p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v0p = (1 ? x0 : u0p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? x1 : u1p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? x2 : u2p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + (1 ? x0 : z0)[0] = 1; /* { dg-error "assignment of read-only location" } */ + (1 ? x1 : z1)[0][0] = 1; /* { dg-error "assignment of read-only location" } */ + (1 ? x2 : z2)[0][0][0] = 1; /* { dg-error "assignment of read-only location" } */ + v0p = (1 ? p : z0); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? p : z1); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? p : z2); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v0p = (1 ? pc : x0); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? pc : x1); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? pc : x2); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/c2x-qual-5.c b/SingleSource/Regression/C/gcc-dg/c2x-qual-5.c new file mode 100644 index 0000000000..0801fa0eed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-qual-5.c @@ -0,0 +1,101 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +void tvoid(void* x); +void transpose0(double* out, const double* in) { } +void transpose1(double out[2][2], const double in[2][2]) { } +void transpose2(double out[2][2][2], const double in[2][2][2]) { } +// return +int (*x2(const int x[3][3]))[3] { return x; } /* { dg-error "return discards" } */ +const int (*x3(int x[3][3]))[3] { return x; } +void test(void) +{ + double x0[2]; + double y0[2]; + const double z0[4]; + double x1[2][2]; + double y1[2][2]; + double o1[2][3]; + const double z1[2][2]; + double x2[2][2][2]; + double y2[2][2][2]; + double o2[2][2][3]; + const double z2[2][2][2]; + // void pointers + tvoid(z0); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z1); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z2); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + void* p; + const void* pc; + p = x0; + p = x1; + p = x2; + p = z0; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + p = z1; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + p = z2; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + pc = x0; + pc = x1; + pc = x2; + pc = z0; + pc = z1; + pc = z2; + transpose0(pc, p); /* { dg-error "passing argument 1 of 'transpose0' discards 'const' qualifier from pointer target type" } */ + transpose1(pc, p); /* { dg-error "passing argument 1 of 'transpose1' discards 'const' qualifier from pointer target type" } */ + transpose2(pc, p); /* { dg-error "passing argument 1 of 'transpose2' discards 'const' qualifier from pointer target type" } */ + transpose0(p, pc); + transpose1(p, pc); + transpose2(p, pc); + // passing as arguments + transpose0(y0, x0); + transpose1(y1, o1); /* { dg-error "passing argument 2 of 'transpose1' from incompatible pointer type" } */ + transpose1(y1, x1); + transpose2(y2, o2); /* { dg-error "passing argument 2 of 'transpose2' from incompatible pointer type" } */ + transpose2(y2, x2); + // initialization + const double (*x0p) = x0; + const double (*x1p)[2] = x1; + const double (*x2p)[2][2] = x2; + double (*v0p) = z0; /* { dg-error "initialization discards 'const' qualifier from pointer target type" } */ + double (*v1p)[2] = z1; /* { dg-error "initialization discards" } */ + double (*v2p)[2][2] = z2; /* { dg-error "initialization discards" } */ + // assignment + x0p = x0; + x1p = x1; + x2p = x2; + // subtraction + &(x0[1]) - &(z0[0]); + &(x1[1]) - &(z1[0]); + &(x2[1]) - &(z2[0]); + // comparison + x0 == z0; + x1 == z1; + x2 == z2; + x0 < z0; + x1 < z1; + x2 < z2; + x0 > z0; + x1 > z1; + x2 > z2; + // conditional expressions + (void)(1 ? x0 : z0); + (void)(1 ? x1 : z1); + (void)(1 ? x2 : z2); + (void)(1 ? x0 : x1); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : x2); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : x0); /* { dg-error "pointer type mismatch in conditional expression" } */ + v0p = (1 ? z0 : v0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? z1 : v1p); /* { dg-error "assignment discards" } */ + v2p = (1 ? z2 : v2p); /* { dg-error "assignment discards" } */ + v0p = (1 ? x0 : x0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? x1 : x1p); /* { dg-error "assignment discards" } */ + v2p = (1 ? x2 : x2p); /* { dg-error "assignment discards" } */ + (1 ? x0 : z0)[0] = 1; /* { dg-error "assignment of read-only location" } */ + (1 ? x1 : z1)[0][0] = 1; /* { dg-error "assignment of read-only location" } */ + (1 ? x2 : z2)[0][0][0] = 1; /* { dg-error "assignment of read-only location" } */ + v0p = (1 ? p : z0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? p : z1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? p : z2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v0p = (1 ? pc : x0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? pc : x1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? pc : x2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/c2x-qual-6.c b/SingleSource/Regression/C/gcc-dg/c2x-qual-6.c new file mode 100644 index 0000000000..9c91e206e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-qual-6.c @@ -0,0 +1,114 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat -pedantic-errors" } */ +void tvoid(void* x); +void transpose0(double* out, const double* in) { } +void transpose1(double out[2][2], const double in[2][2]) { } +void transpose2(double out[2][2][2], const double in[2][2][2]) { } +// return +int (*x2(const int x[3][3]))[3] { return x; } /* { dg-warning "before C2X" } */ + /* { dg-error "return discards" "" { target *-*-* } .-1 } */ +const int (*x3(int x[3][3]))[3] { return x; } /* { dg-warning "before C2X" } */ +void test(void) +{ + double x0[2]; + double y0[2]; + const double z0[4]; + double x1[2][2]; + double y1[2][2]; + double o1[2][3]; + const double z1[2][2]; + double x2[2][2][2]; + double y2[2][2][2]; + double o2[2][2][3]; + const double z2[2][2][2]; + // void pointers + tvoid(z0); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z1); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z2); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + void* p; + const void* pc; + p = x0; + p = x1; + p = x2; + p = z0; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + p = z1; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + p = z2; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + pc = x0; + pc = x1; + pc = x2; + pc = z0; + pc = z1; + pc = z2; + transpose0(pc, p); /* { dg-error "passing argument 1 of 'transpose0' discards 'const' qualifier from pointer target type" } */ + transpose1(pc, p); /* { dg-error "passing argument 1 of 'transpose1' discards 'const' qualifier from pointer target type" } */ + transpose2(pc, p); /* { dg-error "passing argument 1 of 'transpose2' discards 'const' qualifier from pointer target type" } */ + transpose0(p, pc); + transpose1(p, pc); /* { dg-warning "before C2X" } */ + transpose2(p, pc); /* { dg-warning "before C2X" } */ + // passing as arguments + transpose0(y0, x0); + transpose1(y1, o1); /* { dg-error "passing argument 2 of 'transpose1' from incompatible pointer type" } */ + transpose1(y1, x1); /* { dg-warning "before C2X" } */ + transpose2(y2, o2); /* { dg-error "passing argument 2 of 'transpose2' from incompatible pointer type" } */ + transpose2(y2, x2); /* { dg-warning "before C2X" } */ + // initialization + const double (*x0p) = x0; + const double (*x1p)[2] = x1; /* { dg-warning "before C2X" } */ + const double (*x2p)[2][2] = x2; /* { dg-warning "before C2X" } */ + double (*v0p) = z0; /* { dg-error "initialization discards 'const' qualifier from pointer target type" } */ + double (*v1p)[2] = z1; /* { dg-warning "before C2X" } */ + /* { dg-error "initialization discards" "" { target *-*-* } .-1 } */ + double (*v2p)[2][2] = z2; /* { dg-warning "before C2X" } */ + /* { dg-error "initialization discards" "" { target *-*-* } .-1 } */ + + // assignment + x0p = x0; + x1p = x1; /* { dg-warning "before C2X" } */ + x2p = x2; /* { dg-warning "before C2X" } */ + + // subtraction + &(x0[1]) - &(z0[0]); + &(x1[1]) - &(z1[0]); /* { dg-warning "before C2X" } */ + &(x2[1]) - &(z2[0]); /* { dg-warning "before C2X" } */ + // comparison + x0 == z0; + x1 == z1; /* { dg-warning "before C2X" } */ + x2 == z2; /* { dg-warning "before C2X" } */ + x0 < z0; + x1 < z1; /* { dg-warning "before C2X" } */ + x2 < z2; /* { dg-warning "before C2X" } */ + x0 > z0; + x1 > z1; /* { dg-warning "before C2X" } */ + x2 > z2; /* { dg-warning "before C2X" } */ + // conditional expressions + (void)(1 ? x0 : z0); + (void)(1 ? x1 : z1); /* { dg-warning "before C2X" } */ + (void)(1 ? x2 : z2); /* { dg-warning "before C2X" } */ + (void)(1 ? x0 : x1); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : x2); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : x0); /* { dg-error "pointer type mismatch in conditional expression" } */ + v0p = (1 ? z0 : v0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? z1 : v1p); /* { dg-warning "before C2X" } */ + /* { dg-error "assignment discards" "" { target *-*-* } .-1 } */ + v2p = (1 ? z2 : v2p); /* { dg-warning "before C2X" } */ + /* { dg-error "assignment discards" "" { target *-*-* } .-1 } */ + v0p = (1 ? x0 : x0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? x1 : x1p); /* { dg-error "assignment discards" } */ + /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */ + v2p = (1 ? x2 : x2p); /* { dg-error "assignment discards" } */ + /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */ + (1 ? x0 : z0)[0] = 1; /* { dg-error "assignment of read-only location" } */ + (1 ? x1 : z1)[0][0] = 1; /* { dg-error "assignment of read-only location" } */ + /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */ + (1 ? x2 : z2)[0][0][0] = 1; /* { dg-error "assignment of read-only location" } */ + /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */ + v0p = (1 ? p : z0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? p : z1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */ + v2p = (1 ? p : z2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + /* { dg-warning "before C2X" "" { target *-*-* } .-1 } */ + v0p = (1 ? pc : x0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? pc : x1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? pc : x2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/c2x-qual-7.c b/SingleSource/Regression/C/gcc-dg/c2x-qual-7.c new file mode 100644 index 0000000000..5fe15e1d2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-qual-7.c @@ -0,0 +1,16 @@ +/* Tests related to qualifiers and pointers to arrays in C2X, PR98397 */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* test that _Atomic qualifier is not preserved in tertiary operator for pointers to arrays in C2X */ + +void f(void) +{ + _Atomic void *u; + void *v; + _Static_assert(_Generic(1 ? u : v, _Atomic void*: 0, void*: 1), "_Atomic should be removed"); + _Static_assert(_Generic(1 ? v : u, _Atomic void*: 0, void*: 1), "_Atomic should be removed"); +} + + + diff --git a/SingleSource/Regression/C/gcc-dg/c2x-static-assert-1.c b/SingleSource/Regression/C/gcc-dg/c2x-static-assert-1.c new file mode 100644 index 0000000000..1b771a1c0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-static-assert-1.c @@ -0,0 +1,5 @@ +/* Test C2x static assertions. Omitting the string supported. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic" } */ + +_Static_assert (1); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-static-assert-2.c b/SingleSource/Regression/C/gcc-dg/c2x-static-assert-2.c new file mode 100644 index 0000000000..c3474676e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-static-assert-2.c @@ -0,0 +1,6 @@ +/* Test C2x static assertions. Omitting the string supported. Failed + assertions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic" } */ + +_Static_assert (0); /* { dg-error "static assertion failed" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-static-assert-3.c b/SingleSource/Regression/C/gcc-dg/c2x-static-assert-3.c new file mode 100644 index 0000000000..5d84a6a239 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-static-assert-3.c @@ -0,0 +1,6 @@ +/* Test C2x static assertions. static_assert keyword. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic" } */ + +static_assert (1); +static_assert (1, "message"); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-static-assert-4.c b/SingleSource/Regression/C/gcc-dg/c2x-static-assert-4.c new file mode 100644 index 0000000000..b3bcfb4ae2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-static-assert-4.c @@ -0,0 +1,6 @@ +/* Test C2x static assertions. static_assert keyword. Failed assertions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic" } */ + +static_assert (0); /* { dg-error "static assertion failed" } */ +static_assert (0, "message"); /* { dg-error "message" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-stdarg-1.c b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-1.c new file mode 100644 index 0000000000..7def49d3ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-1.c @@ -0,0 +1,22 @@ +/* Test C2x variadic functions with no named parameters. Compilation tests, + valid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int f (...); +int g (int (...)); +int h (...) { return 0; } + +typedef int A[]; +typedef int A2[2]; + +A *f1 (...); +A2 *f1 (...); +A *f1 (...) { return 0; } + +A2 *f2 (...); +A *f2 (...); +A2 *f2 (...) { return 0; } +typeof (f1) f2; + +int t () { return f () + f (1) + f (1, 2) + h () + h (1.5, 2, f1) + g (f); } diff --git a/SingleSource/Regression/C/gcc-dg/c2x-stdarg-2.c b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-2.c new file mode 100644 index 0000000000..27782401c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-2.c @@ -0,0 +1,22 @@ +/* Test C2x variadic functions with no named parameters. Compilation tests, + valid code, verify not considered unprototyped functions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wstrict-prototypes -Wold-style-definition" } */ + +int f (...); +int g (int (...)); +int h (...) { return 0; } + +typedef int A[]; +typedef int A2[2]; + +A *f1 (...); +A2 *f1 (...); +A *f1 (...) { return 0; } + +A2 *f2 (...); +A *f2 (...); +A2 *f2 (...) { return 0; } +typeof (f1) f2; + +int t () { return f () + f (1) + f (1, 2) + h () + h (1.5, 2, f1) + g (f); } diff --git a/SingleSource/Regression/C/gcc-dg/c2x-stdarg-3.c b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-3.c new file mode 100644 index 0000000000..e2e14063e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-3.c @@ -0,0 +1,16 @@ +/* Test C2x variadic functions with no named parameters. Compilation tests, + invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int f (...); /* { dg-message "previous declaration" } */ +int f (); /* { dg-error "conflicting types" } */ + +int f2 (...); /* { dg-message "previous declaration" } */ +int f2 (int); /* { dg-error "conflicting types" } */ + +int g (); /* { dg-message "previous declaration" } */ +int g (...); /* { dg-error "conflicting types" } */ + +int g2 (int); /* { dg-message "previous declaration" } */ +int g2 (...); /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-stdarg-4.c b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-4.c new file mode 100644 index 0000000000..1f8718dec6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-4.c @@ -0,0 +1,164 @@ +/* Test C2x variadic functions with no named parameters, or last named + parameter with a declaration not allowed in C17. Execution tests. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +extern void abort (void); +extern void exit (int); + +double +f (...) +{ + va_list ap; + va_start (ap); + double ret = va_arg (ap, int); + ret += va_arg (ap, double); + ret += va_arg (ap, int); + ret += va_arg (ap, double); + va_end (ap); + return ret; +} + +void +g (...) +{ + va_list ap; + va_start (ap, random ! ignored, ignored ** text); + for (int i = 0; i < 10; i++) + if (va_arg (ap, double) != i) + abort (); + va_end (ap); +} + +void +h1 (register int x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); +} + +void +h2 (int x(), ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); +} + +void +h3 (int x[10], ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); +} + +void +h4 (char x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); +} + +void +h5 (float x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); +} + +void +h6 (volatile long x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); +} + +struct s { char c[1000]; }; + +void +h7 (volatile struct s x, ...) +{ + va_list ap; + va_start (ap); + for (int i = 0; i < 10; i++) + { + if (va_arg (ap, double) != i) + abort (); + i++; + if (va_arg (ap, int) != i) + abort (); + } + va_end (ap); +} + +int +main () +{ + if (f (1, 2.0, 3, 4.0) != 10.0) + abort (); + g (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); + g (0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f); + h1 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + h2 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + h3 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + h4 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + h5 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + h6 (0, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + h7 ((struct s) {}, 0.0, 1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-stdarg-5.c b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-5.c new file mode 100644 index 0000000000..134244357b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-stdarg-5.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_STDARG_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_STDARG_H__ +#error "__STDC_VERSION_STDARG_H__ not defined" +#endif + +#if __STDC_VERSION_STDARG_H__ != 202311L +#error "bad value of __STDC_VERSION_STDARG_H__" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-stdatomic-1.c b/SingleSource/Regression/C/gcc-dg/c2x-stdatomic-1.c new file mode 100644 index 0000000000..3a9ceb0ea3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-stdatomic-1.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_STDATOMIC_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_STDATOMIC_H__ +#error "__STDC_VERSION_STDATOMIC_H__ not defined" +#endif + +#if __STDC_VERSION_STDATOMIC_H__ != 202311L +#error "bad value of __STDC_VERSION_STDATOMIC_H__" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-stddef-1.c b/SingleSource/Regression/C/gcc-dg/c2x-stddef-1.c new file mode 100644 index 0000000000..1ebdf2037e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-stddef-1.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_STDDEF_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_STDDEF_H__ +#error "__STDC_VERSION_STDDEF_H__ not defined" +#endif + +#if __STDC_VERSION_STDDEF_H__ != 202311L +#error "bad value of __STDC_VERSION_STDDEF_H__" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-stdint-1.c b/SingleSource/Regression/C/gcc-dg/c2x-stdint-1.c new file mode 100644 index 0000000000..3ba6ce56a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-stdint-1.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_STDINT_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors -ffreestanding" } */ + +#include + +#ifndef __STDC_VERSION_STDINT_H__ +#error "__STDC_VERSION_STDINT_H__ not defined" +#endif + +#if __STDC_VERSION_STDINT_H__ != 202311L +#error "bad value of __STDC_VERSION_STDINT_H__" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-thread-local-1.c b/SingleSource/Regression/C/gcc-dg/c2x-thread-local-1.c new file mode 100644 index 0000000000..e1917bd99d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-thread-local-1.c @@ -0,0 +1,6 @@ +/* Test C2x thread_local keyword. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +thread_local int a; +thread_local void f (void); /* { dg-error "storage class" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-thread-local-2.c b/SingleSource/Regression/C/gcc-dg/c2x-thread-local-2.c new file mode 100644 index 0000000000..d199ff2384 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-thread-local-2.c @@ -0,0 +1,40 @@ +/* Test that thread-local declarations are not considered tentative definitions + in C2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +thread_local int a; /* { dg-message "previous" } */ +thread_local int a; /* { dg-error "redefinition" } */ + +static thread_local int b; /* { dg-message "previous" } */ +static thread_local int b; /* { dg-error "redefinition" } */ + +thread_local int c; /* { dg-message "previous" } */ +thread_local int c = 1; /* { dg-error "redefinition" } */ + +static thread_local int d; /* { dg-message "previous" } */ +static thread_local int d = 1; /* { dg-error "redefinition" } */ + +thread_local int e = 1; /* { dg-message "previous" } */ +thread_local int e; /* { dg-error "redefinition" } */ + +static thread_local int f = 1; /* { dg-message "previous" } */ +static thread_local int f; /* { dg-error "redefinition" } */ + +/* Not being a tentative definition means that incomplete arrays are an error + rather than defaulting to size 1. */ +thread_local int g[]; /* { dg-error "storage size" } */ +static thread_local int h[]; /* { dg-error "array size missing" } */ +extern thread_local int i[]; + +thread_local int j[] = { 0 }; +static thread_local int k[] = { 0 }; + +thread_local int l; +extern thread_local int l; + +extern thread_local int m; +thread_local int m; + +static thread_local int n; +extern thread_local int n; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-typeof-1.c b/SingleSource/Regression/C/gcc-dg/c2x-typeof-1.c new file mode 100644 index 0000000000..0b721fedd4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-typeof-1.c @@ -0,0 +1,208 @@ +/* Test C2x typeof and typeof_unqual. Valid code. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int i; +extern typeof (i) i; +extern typeof (int) i; +extern typeof_unqual (i) i; +extern typeof_unqual (int) i; + +volatile int vi; +extern typeof (volatile int) vi; +extern typeof (vi) vi; + +extern typeof_unqual (volatile int) i; +extern typeof_unqual (vi) i; +extern typeof ((const int) vi) i; +extern typeof ((volatile int) vi) i; + +const int ci; +extern typeof (const int) ci; +extern typeof (ci) ci; + +extern typeof_unqual (const int) i; +extern typeof_unqual (ci) i; +extern typeof ((const int) ci) i; +extern typeof (+ci) i; +extern typeof (0, ci) i; +extern typeof (1 ? ci : ci) i; +extern typeof (0) i; + +const int fci (void); +extern typeof (fci ()) i; + +_Atomic int ai; +extern typeof (_Atomic int) ai; +extern typeof (_Atomic (int)) ai; +extern typeof (ai) ai; + +extern typeof_unqual (_Atomic int) i; +extern typeof_unqual (_Atomic (int)) i; +extern typeof_unqual (ai) i; +extern typeof (+ai) i; +extern typeof ((_Atomic int) ai) i; +extern typeof (0, ai) i; +extern typeof (1 ? ai : ai) i; + +_Atomic int fai (void); +extern typeof (fai ()) i; + +_Atomic const volatile int acvi; +extern typeof (int volatile const _Atomic) acvi; +extern typeof (acvi) acvi; +extern const _Atomic volatile typeof (acvi) acvi; +extern _Atomic volatile typeof (ci) acvi; +extern _Atomic const typeof (vi) acvi; +extern const typeof (ai) volatile acvi; + +extern typeof_unqual (acvi) i; +extern typeof_unqual (typeof (acvi)) i; +extern typeof_unqual (_Atomic typeof_unqual (acvi)) i; + +extern _Atomic typeof_unqual (acvi) ai; + +char c; +volatile char vc; +volatile char *pvc; +volatile char *const cpvc; +const char *pcc; +const char *volatile vpcc; +typeof (*vpcc) cc; + +extern typeof (*cpvc) vc; +extern typeof_unqual (*cpvc) c; +extern typeof_unqual (cpvc) pvc; +extern typeof_unqual (vpcc) pcc; +extern const char cc; + +extern typeof (++vi) i; +extern typeof (++ai) i; +extern typeof (--vi) i; +extern typeof (--ai) i; +extern typeof (vi++) i; +extern typeof (ai++) i; +extern typeof (vi--) i; +extern typeof (ai--) i; + +bool b; +volatile bool vb; +_Atomic bool ab; +extern typeof (++vb) b; +extern typeof (++ab) b; +extern typeof (--vb) b; +extern typeof (--ab) b; +extern typeof (vb++) b; +extern typeof (ab++) b; +extern typeof (vb--) b; +extern typeof (ab--) b; + +extern typeof (vc = 1) c; +extern typeof (vpcc = 0) pcc; +extern typeof (ai *= 2) i; + +int s = sizeof (typeof (int (*)[++i])); + +void *vp; + +/* The non-returning property of a function is not part of the type given by + ISO C typeof. */ +_Noreturn void nf1 (void); +[[noreturn]] void nf2 (void); +void fg (void) {} +typeof (&nf1) pnf1 = fg; +typeof (&nf2) pnf2 = fg; +extern void (*pnf1) (void); +extern void (*pnf2) (void); +extern typeof (nf1) *pnf1; +extern typeof (nf1) *pnf2; +extern typeof (nf2) *pnf1; +extern typeof (nf2) *pnf2; +typeof (*&nf1) fg2, fg2a, fg2b; +typeof (*&nf2) fg3, fg3a, fg3b; +typeof (nf1) fg4, fg4a, fg4b; +typeof (nf2) fg5, fg5a, fg5b; + +extern void abort (void); +extern void exit (int); + +void fg2 (void) {} +_Noreturn void fg2a (void) { abort (); } +[[noreturn]] void fg2b (void) { abort (); } +void fg3 (void) {} +_Noreturn void fg3a (void) { abort (); } +[[noreturn]] void fg3b (void) { abort (); } +void fg4 (void) {} +_Noreturn void fg4a (void) { abort (); } +[[noreturn]] void fg4b (void) { abort (); } +void fg5 (void) {} +_Noreturn void fg5a (void) { abort (); } +[[noreturn]] void fg5b (void) { abort (); } + +extern int only_used_in_typeof; + +static int not_defined (void); + +typeof (i) +main (typeof (*vp)) +{ + volatile typeof (only_used_in_typeof) ii = 2; + if (ii != 2) + abort (); + const typeof (not_defined ()) jj = 3; + if (jj != 3) + abort (); + unsigned int u = 1; + typeof (u) u2 = 0; + typeof (int (*)[++u2]) p = 0; + if (u2 != 1) + abort (); + if (sizeof (*p) != sizeof (int)) + abort (); + typeof_unqual (int (*)[++u2]) q = 0; + if (u2 != 2) + abort (); + if (sizeof (*q) != 2 * sizeof (int)) + abort (); + if (sizeof (*p) != sizeof (int)) + abort (); + typeof (++u2) u3 = 1; + if (u2 != u + u3) + abort (); + typeof_unqual (++u2) u4 = 2; + if (u2 != u4) + abort (); + u = sizeof (typeof (int (*)[++u2])); + if (u2 != 2) + abort (); + u = sizeof (typeof_unqual (int (*)[++u2])); + if (u2 != 2) + abort (); + typeof ((int (*)[++u2]) 0) q2; + if (u2 != 3) + abort (); + typeof ((void) 0, (int (*)[++u2]) 0) q3; + if (u2 != 4) + abort (); + typeof ((int (*)[++u2]) 0, 0) q4; + if (u2 != 4) + abort (); + typeof_unqual ((int (*)[++u2]) 0) q5; + if (u2 != 5) + abort (); + typeof_unqual ((void) 0, (int (*)[++u2]) 0) q6; + if (u2 != 6) + abort (); + typeof_unqual ((int (*)[++u2]) 0, 0) q7; + if (u2 != 6) + abort (); + int a1[6], a2[6]; + int (*pa)[u2] = &a1; + typeof (pa = &a2) pp; + if (pa != &a2) + abort (); + typeof_unqual (pa = &a1) pp2; + if (pa != &a1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-typeof-2.c b/SingleSource/Regression/C/gcc-dg/c2x-typeof-2.c new file mode 100644 index 0000000000..f1c30a00a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-typeof-2.c @@ -0,0 +1,27 @@ +/* Test C2x typeof and typeof_unqual. Invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +struct s { int i : 2; } x; +union u { unsigned int j : 1; } y; + +typeof (x.i) j; /* { dg-error "applied to a bit-field" } */ +typeof_unqual (x.i) j2; /* { dg-error "applied to a bit-field" } */ +typeof (y.j) j3; /* { dg-error "applied to a bit-field" } */ +typeof_unqual (y.j) j4; /* { dg-error "applied to a bit-field" } */ + +static int ok (void); +static int also_ok (void); +static int not_defined (void); /* { dg-error "used but never defined" } */ +static int also_not_defined (void); /* { dg-error "used but never defined" } */ + +void +f (void) +{ + typeof (ok ()) x = 2; + typeof_unqual (also_ok ()) y = 2; + int a[2]; + int (*p)[x] = &a; + typeof (p + not_defined ()) q; + typeof_unqual (p + also_not_defined ()) q2; +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-typeof-3.c b/SingleSource/Regression/C/gcc-dg/c2x-typeof-3.c new file mode 100644 index 0000000000..c7a057700d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-typeof-3.c @@ -0,0 +1,7 @@ +/* Test C2x typeof and typeof_unqual. -fno-asm has no effect on keywords in + C2x mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -fno-asm" } */ + +int i; +extern typeof (i) i; diff --git a/SingleSource/Regression/C/gcc-dg/c2x-unproto-1.c b/SingleSource/Regression/C/gcc-dg/c2x-unproto-1.c new file mode 100644 index 0000000000..d21c6a712f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-unproto-1.c @@ -0,0 +1,21 @@ +/* Test compatibility of prototyped function types with and without arguments + (C2x made the case of types affected by default argument promotions + compatible, before removing unprototyped functions completely). Test + affected usages are not accepted for C2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +void f1 (); /* { dg-message "previous declaration" } */ +void f1 (float); /* { dg-error "conflicting types" } */ + +void f2 (float); /* { dg-message "previous declaration" } */ +void f2 (); /* { dg-error "conflicting types" } */ + +void f3 (); /* { dg-message "previous declaration" } */ +void f3 (char); /* { dg-error "conflicting types" } */ + +void f4 (char); /* { dg-message "previous declaration" } */ +void f4 (); /* { dg-error "conflicting types" } */ + +/* Built-in function case. */ +float sqrtf (); /* { dg-warning "conflicting types for built-in function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-unproto-2.c b/SingleSource/Regression/C/gcc-dg/c2x-unproto-2.c new file mode 100644 index 0000000000..533fb743b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-unproto-2.c @@ -0,0 +1,18 @@ +/* Test compatibility of prototyped function types without arguments and with + variable arguments (C2x made the case of types affected by default argument + promotions compatible, before removing unprototyped functions completely). + Test always-invalid-in-C2x usages, in C2X mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +void f1 (); /* { dg-message "previous declaration" } */ +void f1 (int, ...); /* { dg-error "conflicting types" } */ + +void f2 (int, ...); /* { dg-message "previous declaration" } */ +void f2 (); /* { dg-error "conflicting types" } */ + +void f3 (); /* { dg-message "previous declaration" } */ +void f3 (char, ...); /* { dg-error "conflicting types" } */ + +void f4 (char, ...); /* { dg-message "previous declaration" } */ +void f4 (); /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-unproto-3.c b/SingleSource/Regression/C/gcc-dg/c2x-unproto-3.c new file mode 100644 index 0000000000..762f8b2103 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-unproto-3.c @@ -0,0 +1,20 @@ +/* Test that declaring a function with () is the same as (void) in C2X. Valid + use cases. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors -Wstrict-prototypes" } */ + +void f1 (); +void f1 (void); + +void f2 (void); +void f2 (); + +typedef void T1 (); +typedef void T1 (void); + +void f3 (); + +_Static_assert (_Generic (f3, + void (*) (int) : 1, + void (*) (void) : 2, + default : 3) == 2); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-unproto-4.c b/SingleSource/Regression/C/gcc-dg/c2x-unproto-4.c new file mode 100644 index 0000000000..fceff22b1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-unproto-4.c @@ -0,0 +1,15 @@ +/* Test that declaring a function with () is the same as (void) in C2X. + Invalid use cases. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +void f1 (); /* { dg-message "previous declaration" } */ +void f1 (int); /* { dg-error "conflicting types" } */ + +void f2 (); /* { dg-message "declared here" } */ + +void +f3 (void) +{ + f2 (1); /* { dg-error "too many arguments" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-unreachable-1.c b/SingleSource/Regression/C/gcc-dg/c2x-unreachable-1.c new file mode 100644 index 0000000000..468f1f87eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-unreachable-1.c @@ -0,0 +1,29 @@ +/* Test unreachable in for C2x. */ +/* { dg-do run } */ +/* { dg-options "-std=c2x -pedantic-errors -O2" } */ + +#include + +#ifndef unreachable +#error "unreachable not defined" +#endif + +extern void *p; +extern __typeof__ (unreachable ()) *p; + +volatile int x = 1; + +extern void not_defined (void); + +extern void exit (int); + +int +main () +{ + if (x == 2) + { + unreachable (); + not_defined (); + } + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c2x-utf8char-1.c b/SingleSource/Regression/C/gcc-dg/c2x-utf8char-1.c new file mode 100644 index 0000000000..76543afca8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-utf8char-1.c @@ -0,0 +1,29 @@ +/* Test C2x UTF-8 characters. Test valid usages. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +unsigned char a = u8'a'; +_Static_assert (u8'a' == 97); + +unsigned char b = u8'\0'; +_Static_assert (u8'\0' == 0); + +unsigned char c = u8'\xff'; +_Static_assert (u8'\xff' == 255); + +unsigned char d = u8'\377'; +_Static_assert (u8'\377' == 255); + +_Static_assert (sizeof (u8'a') == 1); +_Static_assert (sizeof (u8'\0') == 1); +_Static_assert (sizeof (u8'\xff') == 1); +_Static_assert (sizeof (u8'\377') == 1); + +_Static_assert (_Generic (u8'a', unsigned char: 1, default: 2) == 1); +_Static_assert (_Generic (u8'\0', unsigned char: 1, default: 2) == 1); +_Static_assert (_Generic (u8'\xff', unsigned char: 1, default: 2) == 1); +_Static_assert (_Generic (u8'\377', unsigned char: 1, default: 2) == 1); + +#if u8'\0' - 1 < 0 +#error "UTF-8 constants not unsigned in preprocessor" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c2x-utf8char-2.c b/SingleSource/Regression/C/gcc-dg/c2x-utf8char-2.c new file mode 100644 index 0000000000..4e6a2f6955 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-utf8char-2.c @@ -0,0 +1,8 @@ +/* Test C2x UTF-8 characters. Character values not affected by + different execution character set. */ +/* { dg-do compile } */ +/* { dg-require-iconv "IBM1047" } */ +/* { dg-options "-std=c2x -pedantic-errors -fexec-charset=IBM1047" } */ + +_Static_assert (u8'a' == 97); +_Static_assert (u8'a' != (unsigned char) 'a'); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-utf8char-3.c b/SingleSource/Regression/C/gcc-dg/c2x-utf8char-3.c new file mode 100644 index 0000000000..7c48983199 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-utf8char-3.c @@ -0,0 +1,8 @@ +/* Test C2x UTF-8 characters. Test errors for invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +unsigned char a = u8''; /* { dg-error "empty character constant" } */ +unsigned char b = u8'ab'; /* { dg-error "character constant too long for its type" } */ +unsigned char c = u8'\u00ff'; /* { dg-error "character constant too long for its type" } */ +unsigned char d = u8'\x100'; /* { dg-error "hex escape sequence out of range" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c2x-utf8str-type.c b/SingleSource/Regression/C/gcc-dg/c2x-utf8str-type.c new file mode 100644 index 0000000000..ebdde97b57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-utf8str-type.c @@ -0,0 +1,6 @@ +/* Test C2X UTF-8 string literal type. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +_Static_assert (_Generic (u8"text", unsigned char*: 1, default: 2) == 1, "UTF-8 string literals have an unexpected type"); +_Static_assert (_Generic (u8"x"[0], unsigned char: 1, default: 2) == 1, "UTF-8 string literal elements have an unexpected type"); diff --git a/SingleSource/Regression/C/gcc-dg/c2x-utf8str.c b/SingleSource/Regression/C/gcc-dg/c2x-utf8str.c new file mode 100644 index 0000000000..2e4c392da9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c2x-utf8str.c @@ -0,0 +1,34 @@ +/* Test initialization by UTF-8 string literal in C2X. */ +/* { dg-do compile } */ +/* { dg-require-effective-target wchar } */ +/* { dg-options "-std=c2x" } */ + +typedef __CHAR8_TYPE__ char8_t; +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; +typedef __WCHAR_TYPE__ wchar_t; + +/* Test that char, signed char, unsigned char, and char8_t arrays can be + initialized by a UTF-8 string literal. */ +const char cbuf1[] = u8"text"; +const char cbuf2[] = { u8"text" }; +const signed char scbuf1[] = u8"text"; +const signed char scbuf2[] = { u8"text" }; +const unsigned char ucbuf1[] = u8"text"; +const unsigned char ucbuf2[] = { u8"text" }; +const char8_t c8buf1[] = u8"text"; +const char8_t c8buf2[] = { u8"text" }; + +/* Test that a diagnostic is issued for attempted initialization of + other character types by a UTF-8 string literal. */ +const char16_t c16buf1[] = u8"text"; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const char16_t c16buf2[] = { u8"text" }; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const char32_t c32buf1[] = u8"text"; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const char32_t c32buf2[] = { u8"text" }; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const wchar_t wbuf1[] = u8"text"; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const wchar_t wbuf2[] = { u8"text" }; /* { dg-error "from a string literal with type array of .unsigned char." } */ + +/* Test that char8_t arrays can be initialized by an ordinary string + literal. */ +const char8_t c8buf3[] = "text"; +const char8_t c8buf4[] = { "text" }; diff --git a/SingleSource/Regression/C/gcc-dg/c90-align-1.c b/SingleSource/Regression/C/gcc-dg/c90-align-1.c new file mode 100644 index 0000000000..77510f4e0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-align-1.c @@ -0,0 +1,6 @@ +/* Test _Alignof and _Alignas not in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +int a = _Alignof (int); /* { dg-error "ISO C90 does not support '_Alignof'" } */ +_Alignas (int) int b; /* { dg-error "ISO C90 does not support '_Alignas'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-anon-struct-1.c b/SingleSource/Regression/C/gcc-dg/c90-anon-struct-1.c new file mode 100644 index 0000000000..a3eb7f7e39 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-anon-struct-1.c @@ -0,0 +1,12 @@ +/* Test for anonymous structures and unions not permitted in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s +{ + int a; + struct + { + int b; + }; /* { dg-error "unnamed structs" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-lval-1.c b/SingleSource/Regression/C/gcc-dg/c90-array-lval-1.c new file mode 100644 index 0000000000..69655c8350 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-lval-1.c @@ -0,0 +1,21 @@ +/* Test for non-lvalue arrays decaying to pointers: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s { char c[1]; }; + +extern struct s foo (void); + +void +bar (void) +{ + char *t; + (foo ()).c[0]; /* { dg-bogus "warning" "warning in place of error" } */ + t = (foo ()).c; /* { dg-bogus "warning" "warning in place of error" } */ + (foo ()).c + 1; /* { dg-bogus "warning" "warning in place of error" } */ +} +/* { dg-error "non-lvalue" "array not decaying to lvalue" { target *-*-* } 14 } + { dg-error "non-lvalue|incompatible" "array not decaying to lvalue" { target *-*-* } 15 } + { dg-error "non-lvalue|invalid" "array not decaying to lvalue" { target *-*-* } 16 } +*/ diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-lval-2.c b/SingleSource/Regression/C/gcc-dg/c90-array-lval-2.c new file mode 100644 index 0000000000..9f261e05e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-lval-2.c @@ -0,0 +1,20 @@ +/* Test for non-lvalue arrays decaying to pointers: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s { char c[17]; }; + +struct s x; + +extern struct s foo (void); + +#define ASSERT(v, a) char v[((a) ? 1 : -1)] + +ASSERT (p, sizeof (x.c) == 17); +ASSERT (q, sizeof (0, x.c) == sizeof (char *)); +ASSERT (r, sizeof ((foo ()).c) == 17); +/* The non-lvalue array does not decay to a pointer, so the comma expression + has (non-lvalue) array type. +*/ +ASSERT (s, sizeof (0, (foo ()).c) == 17); /* { dg-bogus "array" "bad non-lvalue array handling" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-lval-3.c b/SingleSource/Regression/C/gcc-dg/c90-array-lval-3.c new file mode 100644 index 0000000000..192a05f62c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-lval-3.c @@ -0,0 +1,34 @@ +/* Test for non-lvalue arrays decaying to pointers: in C99 only. + Test various ways of producing non-lvalue arrays. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s { char c[1]; }; +struct s a, b, c; +int d; + +void +bar (void) +{ + char *t; + (d ? b : c).c[0]; /* { dg-bogus "warning" "warning in place of error" } */ + (d, b).c[0]; /* { dg-bogus "warning" "warning in place of error" } */ + (a = b).c[0]; /* { dg-bogus "warning" "warning in place of error" } */ + t = (d ? b : c).c; /* { dg-bogus "warning" "warning in place of error" } */ + t = (d, b).c; /* { dg-bogus "warning" "warning in place of error" } */ + t = (a = b).c; /* { dg-bogus "warning" "warning in place of error" } */ + (d ? b : c).c + 1; /* { dg-bogus "warning" "warning in place of error" } */ + (d, b).c + 1; /* { dg-bogus "warning" "warning in place of error" } */ + (a = b).c + 1; /* { dg-bogus "warning" "warning in place of error" } */ +} +/* { dg-error "non-lvalue" "array not decaying to lvalue" { target *-*-* } 15 } + { dg-error "non-lvalue" "array not decaying to lvalue" { target *-*-* } 16 } + { dg-error "non-lvalue" "array not decaying to lvalue" { target *-*-* } 17 } + { dg-error "non-lvalue|incompatible" "array not decaying to lvalue" { target *-*-* } 18 } + { dg-error "non-lvalue|incompatible" "array not decaying to lvalue" { target *-*-* } 19 } + { dg-error "non-lvalue|incompatible" "array not decaying to lvalue" { target *-*-* } 20 } + { dg-error "non-lvalue|invalid" "array not decaying to lvalue" { target *-*-* } 21 } + { dg-error "non-lvalue|invalid" "array not decaying to lvalue" { target *-*-* } 22 } + { dg-error "non-lvalue|invalid" "array not decaying to lvalue" { target *-*-* } 23 } +*/ diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-lval-4.c b/SingleSource/Regression/C/gcc-dg/c90-array-lval-4.c new file mode 100644 index 0000000000..1f9cb1455e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-lval-4.c @@ -0,0 +1,26 @@ +/* Test for non-lvalue arrays decaying to pointers: in C99 only. + Test various ways of producing non-lvalue arrays. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s { char c[17]; }; + +struct s x; + +struct s a, b, c; +int d; + +#define ASSERT(v, a) char v[((a) ? 1 : -1)] + +ASSERT (p, sizeof (x.c) == 17); +ASSERT (q, sizeof (0, x.c) == sizeof (char *)); +ASSERT (r0, sizeof ((d ? b : c).c) == 17); +ASSERT (r1, sizeof ((d, b).c) == 17); +ASSERT (r2, sizeof ((a = b).c) == 17); +/* The non-lvalue array does not decay to a pointer, so the comma expression + has (non-lvalue) array type. +*/ +ASSERT (s0, sizeof (0, (d ? b : c).c) == 17); /* { dg-bogus "array" "bad non-lvalue array handling" } */ +ASSERT (s0, sizeof (0, (d, b).c) == 17); /* { dg-bogus "array" "bad non-lvalue array handling" } */ +ASSERT (s0, sizeof (0, (a = b).c) == 17); /* { dg-bogus "array" "bad non-lvalue array handling" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-lval-5.c b/SingleSource/Regression/C/gcc-dg/c90-array-lval-5.c new file mode 100644 index 0000000000..c218a4dae6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-lval-5.c @@ -0,0 +1,26 @@ +/* Test for non-lvalue arrays: test that the unary '&' operator is not + allowed on them, for both C90 and C99. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s { char c[1]; }; + +extern struct s foo (void); +struct s a, b, c; +int d; + +void +bar (void) +{ + &((foo ()).c); /* { dg-bogus "warning" "warning in place of error" } */ + &((d ? b : c).c); /* { dg-bogus "warning" "warning in place of error" } */ + &((d, b).c); /* { dg-bogus "warning" "warning in place of error" } */ + &((a = b).c); /* { dg-bogus "warning" "warning in place of error" } */ +} +/* { dg-error "lvalue" "bad address-of" { target *-*-* } 17 } + { dg-error "lvalue" "bad address-of" { target *-*-* } 18 } + { dg-error "lvalue" "bad address-of" { target *-*-* } 19 } + { dg-error "lvalue" "bad address-of" { target *-*-* } 20 } +*/ diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-lval-6.c b/SingleSource/Regression/C/gcc-dg/c90-array-lval-6.c new file mode 100644 index 0000000000..dc57ed7077 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-lval-6.c @@ -0,0 +1,16 @@ +/* PR c/12446 */ +/* Origin: Keith Thompson */ + +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + + +struct s { char c[1]; }; + +extern struct s foo(void); + +void bar(void) +{ + char *ptr = foo().c; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "non-lvalue" "array not decaying to lvalue" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-lval-7.c b/SingleSource/Regression/C/gcc-dg/c90-array-lval-7.c new file mode 100644 index 0000000000..9b41777a15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-lval-7.c @@ -0,0 +1,22 @@ +/* Test for non-lvalue arrays: test that C90 does not allow them in + conditional expressions, while in C99 they decay and are + allowed. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s { char c[1]; }; +struct s a, b, c; +int d; +int e; + +void +bar (void) +{ + /* In C90, the non-lvalue arrays do not decay to pointers, and + 6.3.15 does not permit conditional expressions between arrays. + In C99, they decay to pointers. */ + (e ? (d ? b : c).c : (e ? b : c).c); /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "array" "bad conditional" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-lval-8.c b/SingleSource/Regression/C/gcc-dg/c90-array-lval-8.c new file mode 100644 index 0000000000..bc5b7b21b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-lval-8.c @@ -0,0 +1,20 @@ +/* Test for non-lvalue arrays: test that they cannot be assigned to + array variables. PR 58235. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s { char c[1]; } x; +struct s f (void) { return x; } + +void +g (void) +{ + char c[1]; + c = f ().c; /* { dg-error "array" } */ +} + +void +h (void) +{ + char c[1] = f ().c; /* { dg-error "array" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-quals-2.c b/SingleSource/Regression/C/gcc-dg/c90-array-quals-2.c new file mode 100644 index 0000000000..7cb68c8468 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-quals-2.c @@ -0,0 +1,3 @@ +extern const char *const a[]; +extern const char *const a[]; +extern const char *const a[]; diff --git a/SingleSource/Regression/C/gcc-dg/c90-array-quals.c b/SingleSource/Regression/C/gcc-dg/c90-array-quals.c new file mode 100644 index 0000000000..228e79f65c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-array-quals.c @@ -0,0 +1,3 @@ +extern int (*const a)[]; +extern int (*const a)[10]; +extern int (*const a)[]; diff --git a/SingleSource/Regression/C/gcc-dg/c90-arraydecl-1.c b/SingleSource/Regression/C/gcc-dg/c90-arraydecl-1.c new file mode 100644 index 0000000000..358abbfe25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-arraydecl-1.c @@ -0,0 +1,30 @@ +/* Test for C99 forms of array declarator: rejected in C90. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +/* Use of [*] (possibly with type qualifiers) in an array declarator with + function prototype scope is a C99 feature. GCC does not yet implement + it correctly, so gives a warning about this. so we can't yet test here + that we get just one error and no warnings. */ + +void foo0 (int a, int b[*]); /* { dg-error "ISO C90" "\[*\] not in C90" } */ +void foo1 (int, int [*]); /* { dg-error "ISO C90" "\[*\] not in C90" } */ + + +/* Use of static and type qualifiers (not allowed with abstract declarators) + is a C99 feature. */ + +void bar0 (int a[const]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C90" "\[quals\] not in C90" { target *-*-* } .-1 } */ +void bar1 (int a[const 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C90" "\[quals expr\] not in C90" { target *-*-* } .-1 } */ +void bar2 (int a[static 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C90" "\[static expr\] not in C90" { target *-*-* } .-1 } */ +void bar3 (int a[static const 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C90" "\[static quals expr\] not in C90" { target *-*-* } .-1 } */ +void bar4 (int a[const static 2]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C90" "\[quals static expr\] not in C90" { target *-*-* } .-1 } */ + +/* Because [*] isn't properly implemented and so warns, we don't test here + for [const *] yet. */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-atomic-1.c b/SingleSource/Regression/C/gcc-dg/c90-atomic-1.c new file mode 100644 index 0000000000..3506563940 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-atomic-1.c @@ -0,0 +1,7 @@ +/* Test for _Atomic: not in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=c90 -pedantic-errors" } */ + +_Atomic int i; /* { dg-error "_Atomic" } */ +_Atomic (int) j; /* { dg-error "_Atomic" } */ +int *_Atomic p; /* { dg-error "_Atomic" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-auto-1.c b/SingleSource/Regression/C/gcc-dg/c90-auto-1.c new file mode 100644 index 0000000000..f00f767c50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-auto-1.c @@ -0,0 +1,12 @@ +/* Test auto with implicit int for C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=c90 -pedantic-errors" } */ + +void +f (void) +{ + /* This should have type int following C90 rules, whereas in C2x it + would have type double. */ + auto x = 1.5; + int *p = &x; +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-complex-1.c b/SingleSource/Regression/C/gcc-dg/c90-complex-1.c new file mode 100644 index 0000000000..43648955d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-complex-1.c @@ -0,0 +1,7 @@ +/* Test for _Complex: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +_Complex double foo; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "C" "_Complex not in C90" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-complit-1.c b/SingleSource/Regression/C/gcc-dg/c90-complit-1.c new file mode 100644 index 0000000000..824288f34b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-complit-1.c @@ -0,0 +1,20 @@ +/* Test for compound literals: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct s { int a; int b; }; +union u { int c; int d; }; + +void +foo (void) +{ + (int) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "compound literal" "scalar" { target *-*-* } .-1 } */ + (struct s) { 1, 2 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "compound literal" "struct" { target *-*-* } .-1 } */ + (union u) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "compound literal" "union" { target *-*-* } .-1 } */ + (int [1]) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "compound literal" "array" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-complit-2.c b/SingleSource/Regression/C/gcc-dg/c90-complit-2.c new file mode 100644 index 0000000000..6fcf2a59c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-complit-2.c @@ -0,0 +1,8 @@ +/* Test C2x storage class specifiers in compound literals not permitted for + C90, but without a duplicate diagnostic, just the diagnostic for compound + literals not being permitted in C90 at all. */ +/* { dg-do compile } */ +/* { dg-options "-std=c90 -pedantic-errors" } */ + +int *ps = &(static int) { 1 }; /* { dg-error "ISO C90 forbids compound literals" } */ +int ss = sizeof (static int) { 1 }; /* { dg-error "ISO C90 forbids compound literals" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-1.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-1.c new file mode 100644 index 0000000000..e4c27ac456 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-1.c @@ -0,0 +1,23 @@ +/* Test for constraints on constant expressions. In C90 it is clear that + certain constructs are not permitted in unevaluated parts of an + expression (except in sizeof); in C99 it might fall within implementation + latitude. +*/ +/* Origin: Joseph Myers ; inspired by + http://deja.com/getdoc.xp?AN=524271595&fmt=text by Peter Seebach. +*/ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +extern int bar (void); + +void +foo (void) +{ + int i; + static int j = (1 ? 0 : (i = 2)); /* { dg-error "initial" "assignment" } */ + static int k = (1 ? 0 : ++i); /* { dg-error "initial" "increment" } */ + static int l = (1 ? 0 : --i); /* { dg-error "initial" "decrement" } */ + static int m = (1 ? 0 : bar ()); /* { dg-error "initial" "function call" } */ + static int n = (1 ? 0 : (2, 3)); /* { dg-error "initial" "comma" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-10.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-10.c new file mode 100644 index 0000000000..30c60e31f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-10.c @@ -0,0 +1,30 @@ +/* Test for constant expressions: invalid null pointer constants in + various contexts (make sure NOPs are not inappropriately + stripped). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +__extension__ typedef __SIZE_TYPE__ size_t; + +void *p = (size_t)(void *)0; /* { dg-error "without a cast" } */ +struct s { void *a; } q = { (size_t)(void *)0 }; /* { dg-error "without a cast|near initialization" } */ +void * +f (void) +{ + void *r; + r = (size_t)(void *)0; /* { dg-error "without a cast" } */ + return (size_t)(void *)0; /* { dg-error "without a cast" } */ +} +void g (void *); /* { dg-message "but argument is of type" } */ +void +h (void) +{ + g ((size_t)(void *)0); /* { dg-error "without a cast" } */ +} +void g2 (int, void *); /* { dg-message "but argument is of type" } */ +void +h2 (void) +{ + g2 (0, (size_t)(void *)0); /* { dg-error "without a cast" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-11.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-11.c new file mode 100644 index 0000000000..a2720c47bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-11.c @@ -0,0 +1,27 @@ +/* Test for constant expressions: C90 aggregate initializers requiring + constant expressions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors -O2" } */ + +#include +#include + +double atan(double); + +struct s { double d; }; +struct t { int i; }; + +void +f (void) +{ + /* As in PR 14649 for static initializers. */ + struct s a = { atan (1.0) }; /* { dg-error "is not a constant expression|near initialization" } */ + /* Overflow. */ + struct t b = { INT_MAX + 1 }; /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + struct t c = { DBL_MAX }; /* { dg-warning "overflow in conversion from .double. to .int. changes value " } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + /* Bad operator outside sizeof. */ + struct s d = { 1 ? 1.0 : atan (a.d) }; /* { dg-error "is not a constant expression|near initialization" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-2.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-2.c new file mode 100644 index 0000000000..ee57d55037 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-2.c @@ -0,0 +1,45 @@ +/* Test for constant expressions: details of what is a null pointer + constant. +*/ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990" } */ +/* Note: not using -pedantic since the -std option alone should be enough + to give the correct behavior to conforming programs. If -pedantic is + needed to make (say) (0, 0) not be a constant expression, this is a + bug. +*/ + +int *a; +int b; +long *c; + +#if defined(_LP64) +#define ZERO 0L +#elif defined(_WIN64) +#define ZERO 0LL +#else +#define ZERO 0 +#endif + +/* Assertion that n is a null pointer constant: so the conditional expression + has type 'int *' instead of 'void *'. +*/ +#define ASSERT_NPC(n) (b = *(1 ? a : (n))) +/* Assertion that n is not a null pointer constant: so the conditional + expressions has type 'void *' instead of 'int *'. +*/ +#define ASSERT_NOT_NPC(n) (c = (1 ? a : (n))) + +void +foo (void) +{ + ASSERT_NPC (0); + ASSERT_NPC ((void *)0); + ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((void *)(0, ZERO)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((void *)(&"Foobar"[0] - &"Foobar"[0])); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + /* This last one is a null pointer constant in C99 only. */ + ASSERT_NOT_NPC ((void *)(1 ? ZERO : (0, ZERO))); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-3.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-3.c new file mode 100644 index 0000000000..46a0227344 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-3.c @@ -0,0 +1,46 @@ +/* Test for constant expressions: broken optimization with const variables. */ +/* Reference: ISO 9989:1990 6.5.15 */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -O2" } */ +/* Note: not using -pedantic since the -std option alone should be enough + to give the correct behavior to conforming programs. */ + +static const int ZERO = 0; +static const double DZERO = 0; + +int *a; +int b; +long *c; + +/* Assertion that n is a constant zero: so the conditional expression + has type 'int *' instead of 'void *'. +*/ +#define ASSERT_NPC(n) (b = *(1 ? a : (n))) +/* Assertion that n is not a constant zero: so the conditional + expressions has type 'void *' instead of 'int *'. +*/ +#define ASSERT_NOT_NPC(n) (c = (1 ? a : (void *)(__SIZE_TYPE__)(n))) + +void +foo (void) +{ + ASSERT_NPC (0); + ASSERT_NOT_NPC (ZERO); + ASSERT_NPC (0 + 0); + ASSERT_NOT_NPC (ZERO + 0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC (ZERO + ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NPC (+0); + ASSERT_NOT_NPC (+ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NPC (-0); + ASSERT_NOT_NPC (-ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NPC ((char) 0); + ASSERT_NOT_NPC ((char) ZERO); + ASSERT_NPC ((int) 0); + ASSERT_NOT_NPC ((int) ZERO); + ASSERT_NPC ((int) 0.0); + ASSERT_NOT_NPC ((int) DZERO); + ASSERT_NOT_NPC ((int) +0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((int) (0.0+0.0)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((int) (double)0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-4.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-4.c new file mode 100644 index 0000000000..6a449870ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-4.c @@ -0,0 +1,11 @@ +/* Test for constant expressions: const variable with value 0 is not a + null pointer constant so the conditional expression should have + type void * and the assignment is OK. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -O2" } */ +int *p; +long *q; +static void *const n = 0; +int j; +void f(void) { q = j ? p : n; } diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-5.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-5.c new file mode 100644 index 0000000000..e7422eb602 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-5.c @@ -0,0 +1,39 @@ +/* Test null pointer constants: typedefs for void should be OK but not + qualified void. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +typedef void V; +int *p; +long *q; +int j; +void (*fp)(void); + +void +f (void) +{ + /* (V *)0 is a null pointer constant, so the assignment should be + diagnosed. */ + q = (j ? p : (V *)0); /* { dg-error "5:assignment to 'long int \\*' from incompatible pointer type 'int \\*'" } */ + q = (j ? p : (void *)0); /* { dg-error "5:assignment to 'long int \\*' from incompatible pointer type 'int \\*'" } */ + /* And this conversion should be valid. */ + (void (*)(void))(V *)0; + (void (*)(void))(void *)0; + /* Pointers to qualified void are not valid null pointer + constants. */ + fp = (const void *)0; /* { dg-error "6:ISO C forbids assignment between function pointer and 'void \\*'" } */ + fp = (void *)0; + fp = (V *)0; + fp = 0; + fp == 0; + 0 == fp; + fp == (void *)0; + (void *)0 == fp; + fp == (V *)0; + (V *)0 == fp; + fp == (V *)1; /* { dg-error "6:ISO C forbids comparison of 'void \\*' with function pointer" } */ + (V *)1 == fp; /* { dg-error "10:ISO C forbids comparison of 'void \\*' with function pointer" } */ + fp == (const void *)0; /* { dg-error "6:ISO C forbids comparison of 'void \\*' with function pointer" } */ + (const void *)0 == fp; /* { dg-error "19:ISO C forbids comparison of 'void \\*' with function pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-6.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-6.c new file mode 100644 index 0000000000..210659d724 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-6.c @@ -0,0 +1,55 @@ +/* Test for constant expressions: operands and casts not permitted in + integer constant expressions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +__extension__ typedef __INTPTR_TYPE__ intptr_t; + +/* PR 29116. */ +int n = 0, p[n * 0 + 1]; /* { dg-error "variabl|cannot be evaluated" } */ + +/* PR 31871. */ +extern int c[1 + ((intptr_t) (void *) 0)]; /* { dg-error "variab|cannot be evaluated" } */ + +/* Implicit conversions from floating-point constants are not OK, + although explicit ones are. */ +extern int c1[1.0 ? 1 : 0]; /* { dg-error "variab|cannot be evaluated" } */ + +extern int c2[(int)1.0 ? 1 : 0]; + +extern int c3[1.0 && 1]; /* { dg-error "variab|cannot be evaluated" } */ + +extern int c4[(int)1.0 && 1]; + +extern int c5[1.0 || 1]; /* { dg-error "variab|cannot be evaluated" } */ + +extern int c6[(int)1.0 || 1]; + +/* Similar with various other cases where integer constant expressions + are required. */ + +struct s { + int a : (n * 0 + 1); /* { dg-error "constant" } */ +}; + +enum e { + E = (1 + ((intptr_t) (void *) 0)), /* { dg-error "constant" } */ + E2 = 0 +}; + +enum f { + F = (1 ? 1 : n), /* { dg-error "constant" } */ + F2 = 0 +}; + +void +f (int a) +{ + int v[1 + ((intptr_t) (void *) 0)]; /* { dg-error "variab|cannot be evaluated" } */ + switch (a) + { + case (n * 0 + 1): /* { dg-error "constant" } */ + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-7.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-7.c new file mode 100644 index 0000000000..f423b005e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-7.c @@ -0,0 +1,35 @@ +/* Test for constant expressions: overflow and constant expressions; + see also overflow-warn-*.c for some other cases. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#include + +int a = DBL_MAX; /* { dg-warning "overflow in conversion" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ +int b = (int) DBL_MAX; /* { dg-error "overflow" } */ +unsigned int c = -1.0; /* { dg-warning "overflow in conversion" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ +unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */ + +int e = 0 << 1000; /* { dg-warning "shift count" } */ +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ +int f = 0 << -1; /* { dg-warning "shift count" } */ +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ +int g = 0 >> 1000; /* { dg-warning "shift count" } */ +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ +int h = 0 >> -1; /* { dg-warning "shift count" } */ +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ + +int b1 = (0 ? (int) DBL_MAX : 0); +unsigned int d1 = (0 ? (unsigned int)-1.0 : 0); +int e1 = (0 ? 0 << 1000 : 0); +int f1 = (0 ? 0 << -1 : 0); +int g1 = (0 ? 0 >> 1000 : 0); +int h1 = (0 ? 0 >> -1: 0); + +int i = -1 << 0; + +int j[1] = { DBL_MAX }; /* { dg-warning "overflow in conversion" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-8.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-8.c new file mode 100644 index 0000000000..c9e41541f2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-8.c @@ -0,0 +1,28 @@ +/* Test for constant expressions: overflow and constant expressions + with -fwrapv: overflows still count as such for the purposes of + constant expressions even when they have defined values at + runtime. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors -fwrapv" } */ + +#include + +enum e { + E0 = 0 * (INT_MAX + 1), /* { dg-warning "21:integer overflow in expression" } */ + /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E1 = 0 * (INT_MIN / -1), /* { dg-warning "21:integer overflow in expression" } */ + /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "21:integer overflow in expression" } */ + /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E3 = 0 * (INT_MIN - 1), /* { dg-warning "21:integer overflow in expression" } */ + /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "31:integer overflow in expression" } */ + /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E5 = 0 * -INT_MIN, /* { dg-warning "12:integer overflow in expression" } */ + /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E6 = 0 * !-INT_MIN, /* { dg-warning "13:integer overflow in expression" } */ + /* { dg-error "8:not an integer constant" "constant" { target *-*-* } .-1 } */ + E7 = INT_MIN % -1 /* { dg-warning "16:integer overflow in expression" } */ + /* { dg-error "1:overflow in constant expression" "constant" { target *-*-* } .+1 } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/c90-const-expr-9.c b/SingleSource/Regression/C/gcc-dg/c90-const-expr-9.c new file mode 100644 index 0000000000..4793a14b6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-const-expr-9.c @@ -0,0 +1,29 @@ +/* Test for constant expressions: __builtin_offsetof allowed in + integer constant expressions but not traditional offsetof + expansion. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors -ftrack-macro-expansion=0" } */ + +struct s { + int a; +}; + +struct t { + struct s a; + int b[2]; +}; + +__extension__ typedef __SIZE_TYPE__ size_t; +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; + +#define old_offsetof(TYPE, MEMBER) ((size_t) (uintptr_t) &((TYPE *)0)->MEMBER) + +enum e { + E1 = old_offsetof (struct s, a), /* { dg-error "constant" } */ + E2 = old_offsetof (struct t, a.a), /* { dg-error "constant" } */ + E3 = old_offsetof (struct t, b[1]), /* { dg-error "constant" } */ + E4 = __builtin_offsetof (struct s, a), + E5 = __builtin_offsetof (struct t, a.a), + E6 = __builtin_offsetof (struct t, b[1]) +}; diff --git a/SingleSource/Regression/C/gcc-dg/c90-digraph-1.c b/SingleSource/Regression/C/gcc-dg/c90-digraph-1.c new file mode 100644 index 0000000000..9396d13673 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-digraph-1.c @@ -0,0 +1,24 @@ +/* Test for recognition of digraphs: should be recognized in C94 and C99 + mode, but not in C90 mode. Also check correct stringizing. +*/ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#define str(x) xstr(x) +#define xstr(x) #x +#define foo(p, q) str(p %:%: q) + +extern void abort (void); +extern int strcmp (const char *, const char *); + +int +main (void) +{ + const char *t = foo (1, 2); + const char *u = str (<:); + if (strcmp (t, "1 %:%: 2") || strcmp (u, "<:")) + abort (); + else + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-dupqual-1.c b/SingleSource/Regression/C/gcc-dg/c90-dupqual-1.c new file mode 100644 index 0000000000..14838c7367 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-dupqual-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +typedef const int CI; +const const int c1; /* { dg-error "duplicate" } */ +const CI c2; /* { dg-error "duplicate" } */ +const CI *c3; /* { dg-error "duplicate" } */ + +typedef volatile int VI; +volatile volatile int v1; /* { dg-error "duplicate" } */ +volatile VI v2; /* { dg-error "duplicate" } */ +volatile VI *v3; /* { dg-error "duplicate" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-enum-comma-1.c b/SingleSource/Regression/C/gcc-dg/c90-enum-comma-1.c new file mode 100644 index 0000000000..d8143c0094 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-enum-comma-1.c @@ -0,0 +1,7 @@ +/* Test for commas at end of enums: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +enum foo { bar, }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "comma at end" "enum comma error" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-flex-array-1.c b/SingleSource/Regression/C/gcc-dg/c90-flex-array-1.c new file mode 100644 index 0000000000..871fdfcdf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-flex-array-1.c @@ -0,0 +1,7 @@ +/* Test for flexible array members. Test for rejection in C90 mode. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct flex { int a; int b[]; }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "ISO C90" "flexible array members not in C90" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-flex-array-2.c b/SingleSource/Regression/C/gcc-dg/c90-flex-array-2.c new file mode 100644 index 0000000000..425ce84649 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-flex-array-2.c @@ -0,0 +1,15 @@ +/* [] does not indicate a flexible array member unless it is the field + itself being declared as an incomplete array type rather than a + pointer or other type derived from such a type. PR 36432. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +void +f (void) +{ + int a[3]; + int (*p)[]; + struct { int (*p)[]; } s; + p = &a; + s.p = &a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-float-1.c b/SingleSource/Regression/C/gcc-dg/c90-float-1.c new file mode 100644 index 0000000000..649cddfa07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-float-1.c @@ -0,0 +1,169 @@ +/* Test for C90 macros. */ +/* Origin: Joseph Myers */ +/* { dg-do preprocess } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +/* This test checks that the C90 macros (but not the C99 or C11 ones) + are defined; it does not check the correctness of their values. */ + +#include + +#ifndef FLT_ROUNDS +#error "FLT_ROUNDS undefined" +#endif + +#ifndef FLT_RADIX +#error "FLT_RADIX undefined" +#endif + +#ifndef FLT_MANT_DIG +#error "FLT_MANT_DIG undefined" +#endif + +#ifndef FLT_DIG +#error "FLT_DIG undefined" +#endif + +#ifndef FLT_MIN_EXP +#error "FLT_MIN_EXP undefined" +#endif + +#ifndef FLT_MIN_10_EXP +#error "FLT_MIN_10_EXP undefined" +#endif + +#ifndef FLT_MAX_EXP +#error "FLT_MAX_EXP undefined" +#endif + +#ifndef FLT_MAX_10_EXP +#error "FLT_MAX_10_EXP undefined" +#endif + +#ifndef FLT_MAX +#error "FLT_MAX undefined" +#endif + +#ifndef FLT_EPSILON +#error "FLT_EPSILON undefined" +#endif + +#ifndef FLT_MIN +#error "FLT_MIN undefined" +#endif + +#ifndef DBL_MANT_DIG +#error "DBL_MANT_DIG undefined" +#endif + +#ifndef DBL_DIG +#error "DBL_DIG undefined" +#endif + +#ifndef DBL_MIN_EXP +#error "DBL_MIN_EXP undefined" +#endif + +#ifndef DBL_MIN_10_EXP +#error "DBL_MIN_10_EXP undefined" +#endif + +#ifndef DBL_MAX_EXP +#error "DBL_MAX_EXP undefined" +#endif + +#ifndef DBL_MAX_10_EXP +#error "DBL_MAX_10_EXP undefined" +#endif + +#ifndef DBL_MAX +#error "DBL_MAX undefined" +#endif + +#ifndef DBL_EPSILON +#error "DBL_EPSILON undefined" +#endif + +#ifndef DBL_MIN +#error "DBL_MIN undefined" +#endif + +#ifndef LDBL_MANT_DIG +#error "LDBL_MANT_DIG undefined" +#endif + +#ifndef LDBL_DIG +#error "LDBL_DIG undefined" +#endif + +#ifndef LDBL_MIN_EXP +#error "LDBL_MIN_EXP undefined" +#endif + +#ifndef LDBL_MIN_10_EXP +#error "LDBL_MIN_10_EXP undefined" +#endif + +#ifndef LDBL_MAX_EXP +#error "LDBL_MAX_EXP undefined" +#endif + +#ifndef LDBL_MAX_10_EXP +#error "LDBL_MAX_10_EXP undefined" +#endif + +#ifndef LDBL_MAX +#error "LDBL_MAX undefined" +#endif + +#ifndef LDBL_EPSILON +#error "LDBL_EPSILON undefined" +#endif + +#ifndef LDBL_MIN +#error "LDBL_MIN undefined" +#endif + +#ifdef FLT_EVAL_METHOD +#error "FLT_EVAL_METHOD defined" +#endif + +#ifdef DECIMAL_DIG +#error "DECIMAL_DIG defined" +#endif + +#ifdef FLT_DECIMAL_DIG +#error "FLT_DECIMAL_DIG defined" +#endif + +#ifdef DBL_DECIMAL_DIG +#error "DBL_DECIMAL_DIG defined" +#endif + +#ifdef LDBL_DECIMAL_DIG +#error "LDBL_DECIMAL_DIG defined" +#endif + +#ifdef FLT_HAS_SUBNORM +#error "FLT_HAS_SUBNORM defined" +#endif + +#ifdef DBL_HAS_SUBNORM +#error "DBL_HAS_SUBNORM defined" +#endif + +#ifdef LDBL_HAS_SUBNORM +#error "LDBL_HAS_SUBNORM defined" +#endif + +#ifdef FLT_TRUE_MIN +#error "FLT_TRUE_MIN defined" +#endif + +#ifdef DBL_TRUE_MIN +#error "DBL_TRUE_MIN defined" +#endif + +#ifdef LDBL_TRUE_MIN +#error "LDBL_TRUE_MIN defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c90-fordecl-1.c b/SingleSource/Regression/C/gcc-dg/c90-fordecl-1.c new file mode 100644 index 0000000000..6a8e061fb4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-fordecl-1.c @@ -0,0 +1,14 @@ +/* Test for C99 declarations in for loops - rejection in C90 mode. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +void +foo (void) +{ + int j = 0; + for (int i = 1; i <= 10; i++) /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "'for' loop initial declarations are only allowed in C99 or C11 mode" "declaration in for loop" { target *-*-* } .-1 } */ + /* { dg-message "note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code" "note" { target *-*-* } .-2 } */ + j += i; +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-func-1.c b/SingleSource/Regression/C/gcc-dg/c90-func-1.c new file mode 100644 index 0000000000..5f171d3618 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-func-1.c @@ -0,0 +1,10 @@ +/* Test that we diagnose the __func__ predefined identifier in + C90 pedantic mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +void +foo (void) +{ + const char *s = __func__; /* { dg-error " ISO C90 does not support .__func__. predefined identifier" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-func-2.c b/SingleSource/Regression/C/gcc-dg/c90-func-2.c new file mode 100644 index 0000000000..5185e35db5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-func-2.c @@ -0,0 +1,12 @@ +/* Test that we don't pedwarn about __func__ predefined identifier in + a system header in C90 pedantic mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#include "c90-func-2.h" + +void +foo (void) +{ + const char *s = FN; +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-func-2.h b/SingleSource/Regression/C/gcc-dg/c90-func-2.h new file mode 100644 index 0000000000..2bad1bde19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-func-2.h @@ -0,0 +1,2 @@ +#pragma GCC system_header +#define FN __func__ diff --git a/SingleSource/Regression/C/gcc-dg/c90-hexfloat-1.c b/SingleSource/Regression/C/gcc-dg/c90-hexfloat-1.c new file mode 100644 index 0000000000..b67b1b7dff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-hexfloat-1.c @@ -0,0 +1,11 @@ +/* Test for hex floating point constants: in C99 only. Compiler test. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +double d = 0x1.2p2; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "hexadecimal floating" "hex float error" { target *-*-* } .-1 } */ +double d1 = 0x1p2; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "hexadecimal floating" "hex float error" { target *-*-* } .-1 } */ +double d2 = 0x1...p2; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "too many decimal points" "bad hex float" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-hexfloat-2.c b/SingleSource/Regression/C/gcc-dg/c90-hexfloat-2.c new file mode 100644 index 0000000000..259471c8fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-hexfloat-2.c @@ -0,0 +1,24 @@ +/* Test for hex floating point constants: in C99 only. Preprocessor test. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#define f ( +#define l ) +#define str(x) #x +#define xstr(x) str(x) + +/* C90: "0x1p+( 0x1p+)"; C99: "0x1p+f 0x1p+l" */ +const char *s = xstr(0x1p+f 0x1p+l); + +extern void abort (void); +extern int strcmp (const char *, const char *); + +int +main (void) +{ + if (strcmp (s, "0x1p+( 0x1p+)")) + abort (); + else + return 0; /* Correct C90 behavior. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-idem-qual-1.c b/SingleSource/Regression/C/gcc-dg/c90-idem-qual-1.c new file mode 100644 index 0000000000..bc0068e8a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-idem-qual-1.c @@ -0,0 +1,8 @@ +/* Test for idempotent type qualifiers: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +typedef const int cint; +const cint foo; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "duplicate" "duplicate type qualifier error" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-idem-qual-2.c b/SingleSource/Regression/C/gcc-dg/c90-idem-qual-2.c new file mode 100644 index 0000000000..ab7324962e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-idem-qual-2.c @@ -0,0 +1,7 @@ +/* Test for idempotent type qualifiers: in C99 only. Test "const const". */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +const const int foo; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "duplicate" "duplicate type qualifier error" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-idem-qual-3.c b/SingleSource/Regression/C/gcc-dg/c90-idem-qual-3.c new file mode 100644 index 0000000000..db7e9a2d25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-idem-qual-3.c @@ -0,0 +1,11 @@ +/* Test for idempotent type qualifiers: in C99 only. Test duplicate + type qualifiers with array element types. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +typedef const int cia[2]; +const cia a; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "duplicate" "duplicate type qualifier error" { target *-*-* } .-1 } */ +const cia b[2]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "duplicate" "duplicate type qualifier error" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-impl-decl-1.c b/SingleSource/Regression/C/gcc-dg/c90-impl-decl-1.c new file mode 100644 index 0000000000..4e4431e6be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-impl-decl-1.c @@ -0,0 +1,22 @@ +/* Test for implicit function declaration: in C90 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +void +foo (void) +{ + bar (); +} + +/* C90 subclause 7.1.7 says we can implicitly declare strcmp; C99 removes + implict declarations. +*/ +int +bar (const char *a, const char *b) +{ + /* This fails for GCC CVS 20000709, but is not marked XFAIL since + GCC 2.95.2 passes. + */ + return strcmp (a, b); /* { dg-bogus "implicit" "implicit declaration warning for strcmp" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-impl-int-1.c b/SingleSource/Regression/C/gcc-dg/c90-impl-int-1.c new file mode 100644 index 0000000000..cd995c296c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-impl-int-1.c @@ -0,0 +1,8 @@ +/* Test for implicit int: in C90 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +extern foo; + +bar (void) { } diff --git a/SingleSource/Regression/C/gcc-dg/c90-impl-int-2.c b/SingleSource/Regression/C/gcc-dg/c90-impl-int-2.c new file mode 100644 index 0000000000..884c9d92e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-impl-int-2.c @@ -0,0 +1,8 @@ +/* Test for implicit int: in C90 only. Function parameters in old-style + function definition. +*/ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +void foo (a) { } diff --git a/SingleSource/Regression/C/gcc-dg/c90-init-1.c b/SingleSource/Regression/C/gcc-dg/c90-init-1.c new file mode 100644 index 0000000000..68308d3e26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-init-1.c @@ -0,0 +1,25 @@ +/* Test for C99 designated initializers */ +/* Origin: Jakub Jelinek */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct A { + int B; + short C[2]; +}; +int a[10] = { 10, [4] = 15 }; /* { dg-error "ISO (C89|C90) forbids specifying subobject to initialize" } */ +struct A b = { .B = 2 }; /* { dg-error "ISO (C89|C90) forbids specifying subobject to initialize" } */ +struct A c[] = { [3].C[1] = 1 }; /* { dg-error "ISO (C89|C90) forbids specifying subobject to initialize" } */ +struct A d[] = { [4 ... 6].C[0 ... 1] = 2 }; /* { dg-error "(forbids specifying range of elements to initialize)|(ISO (C89|C90) forbids specifying subobject to initialize)" } */ +int e[] = { [2] 2 }; /* { dg-error "use of designated initializer without" } */ +struct A f = { C: { 0, 1 } }; /* { dg-error "use of designated initializer with " } */ +int g; + +void foo (int *); + +void bar (void) +{ + int x[] = { g++, 2 }; /* { dg-error "is not computable at load time" } */ + + foo (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-intconst-1.c b/SingleSource/Regression/C/gcc-dg/c90-intconst-1.c new file mode 100644 index 0000000000..de7371c067 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-intconst-1.c @@ -0,0 +1,763 @@ +/* Test for integer constant types. */ + +/* Origin: Joseph Myers . */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#include + +/* Assertion that constant C is of type T. */ +#define ASSERT_CONST_TYPE(C, T) \ + do { \ + typedef T type; \ + typedef type **typepp; \ + typedef __typeof__((C)) ctype; \ + typedef ctype **ctypepp; \ + typepp x = 0; \ + ctypepp y = 0; \ + x = y; \ + y = x; \ + } while (0) + +/* (T *) if E is zero, (void *) otherwise. */ +#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E)) + +/* (T *) if E is nonzero, (void *) otherwise. */ +#define type_if(T, E) type_if_not(T, !(E)) + +/* Combine pointer types, all but one (void *). */ +#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0) +#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3)) +#define type_comb4(T1, T2, T3, T4) \ + type_comb2(T1, type_comb2(T2, type_comb2(T3, T4))) + +/* (T1 *) if E1, otherwise (T2 *) if E2. */ +#define first_of2p(T1, E1, T2, E2) type_comb2(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2)))) +/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3. */ +#define first_of3p(T1, E1, T2, E2, T3, E3) \ + type_comb3(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2))), \ + type_if(T3, (!(E1) && !(E2) && (E3)))) +/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3, otherwise + (T4 *) if E4. */ +#define first_of4p(T1, E1, T2, E2, T3, E3, T4, E4) \ + type_comb4(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2))), \ + type_if(T3, (!(E1) && !(E2) && (E3))), \ + type_if(T4, (!(E1) && !(E2) && !(E3) && (E4)))) + +/* Likewise, but return the original type rather than a pointer type. */ +#define first_of2(T1, E1, T2, E2) \ + __typeof__(*((first_of2p(T1, (E1), T2, (E2)))0)) +#define first_of3(T1, E1, T2, E2, T3, E3) \ + __typeof__(*((first_of3p(T1, (E1), T2, (E2), T3, (E3)))0)) +#define first_of4(T1, E1, T2, E2, T3, E3, T4, E4) \ + __typeof__(*((first_of4p(T1, (E1), T2, (E2), T3, (E3), T4, (E4)))0)) + +/* Types of constants according to the C90 rules. */ +#define C90_UNSUF_DEC_TYPE(C) \ + first_of3(int, (C) <= INT_MAX, \ + long int, (C) <= LONG_MAX, \ + unsigned long int, (C) <= ULONG_MAX) +#define C90_UNSUF_OCTHEX_TYPE(C) \ + first_of4(int, (C) <= INT_MAX, \ + unsigned int, (C) <= UINT_MAX, \ + long int, (C) <= LONG_MAX, \ + unsigned long int, (C) <= ULONG_MAX) +#define C90_SUFu_TYPE(C) \ + first_of2(unsigned int, (C) <= UINT_MAX, \ + unsigned long int, (C) <= ULONG_MAX) +#define C90_SUFl_TYPE(C) \ + first_of2(long int, (C) <= LONG_MAX, \ + unsigned long int, (C) <= ULONG_MAX) + +/* Checks that constants have correct type. */ +#define CHECK_UNSUF_DEC_TYPE(C) ASSERT_CONST_TYPE((C), C90_UNSUF_DEC_TYPE((C))) +#define CHECK_UNSUF_OCTHEX_TYPE(C) \ + ASSERT_CONST_TYPE((C), C90_UNSUF_OCTHEX_TYPE((C))) +#define CHECK_SUFu_TYPE(C) ASSERT_CONST_TYPE((C), C90_SUFu_TYPE((C))) +#define CHECK_SUFl_TYPE(C) ASSERT_CONST_TYPE((C), C90_SUFl_TYPE((C))) +#define CHECK_SUFul_TYPE(C) ASSERT_CONST_TYPE((C), unsigned long int) + +/* Check a decimal value, with all suffixes. */ +#define CHECK_DEC_CONST(C) \ + CHECK_UNSUF_DEC_TYPE(C); \ + CHECK_SUFu_TYPE(C##u); \ + CHECK_SUFu_TYPE(C##U); \ + CHECK_SUFl_TYPE(C##l); \ + CHECK_SUFl_TYPE(C##L); \ + CHECK_SUFul_TYPE(C##ul); \ + CHECK_SUFul_TYPE(C##uL); \ + CHECK_SUFul_TYPE(C##Ul); \ + CHECK_SUFul_TYPE(C##UL); + +/* Check an octal or hexadecimal value, with all suffixes. */ +#define CHECK_OCTHEX_CONST(C) \ + CHECK_UNSUF_OCTHEX_TYPE(C); \ + CHECK_SUFu_TYPE(C##u); \ + CHECK_SUFu_TYPE(C##U); \ + CHECK_SUFl_TYPE(C##l); \ + CHECK_SUFl_TYPE(C##L); \ + CHECK_SUFul_TYPE(C##ul); \ + CHECK_SUFul_TYPE(C##uL); \ + CHECK_SUFul_TYPE(C##Ul); \ + CHECK_SUFul_TYPE(C##UL); + +#define CHECK_OCT_CONST(C) CHECK_OCTHEX_CONST(C) +#define CHECK_HEX_CONST(C) \ + CHECK_OCTHEX_CONST(0x##C); \ + CHECK_OCTHEX_CONST(0X##C); + +/* True iff "long" is at least B bits. This presumes that (B-2)/3 is at + most 31. */ +#define LONG_AT_LEAST(B) \ + (LONG_MAX >> ((B)-2)/3 >> ((B)-2)/3 >> ((B)-2 - ((B)-2)/3 - ((B)-2)/3)) + +#define LONG_HAS_BITS(B) (LONG_AT_LEAST((B)) && !LONG_AT_LEAST((B) + 1)) + +/* Decimal values that are large enough to be unsigned. Allow for up to + 64 bits in long. */ +#if LONG_HAS_BITS(32) +#define LARGE_UNSIGNED_DECIMAL 2147483648 +#endif +#if LONG_HAS_BITS(33) +#define LARGE_UNSIGNED_DECIMAL 4294967296 +#endif +#if LONG_HAS_BITS(34) +#define LARGE_UNSIGNED_DECIMAL 8589934592 +#endif +#if LONG_HAS_BITS(35) +#define LARGE_UNSIGNED_DECIMAL 17179869184 +#endif +#if LONG_HAS_BITS(36) +#define LARGE_UNSIGNED_DECIMAL 34359738368 +#endif +#if LONG_HAS_BITS(37) +#define LARGE_UNSIGNED_DECIMAL 68719476736 +#endif +#if LONG_HAS_BITS(38) +#define LARGE_UNSIGNED_DECIMAL 137438953472 +#endif +#if LONG_HAS_BITS(39) +#define LARGE_UNSIGNED_DECIMAL 274877906944 +#endif +#if LONG_HAS_BITS(40) +#define LARGE_UNSIGNED_DECIMAL 549755813888 +#endif +#if LONG_HAS_BITS(41) +#define LARGE_UNSIGNED_DECIMAL 1099511627776 +#endif +#if LONG_HAS_BITS(42) +#define LARGE_UNSIGNED_DECIMAL 2199023255552 +#endif +#if LONG_HAS_BITS(43) +#define LARGE_UNSIGNED_DECIMAL 4398046511104 +#endif +#if LONG_HAS_BITS(44) +#define LARGE_UNSIGNED_DECIMAL 8796093022208 +#endif +#if LONG_HAS_BITS(45) +#define LARGE_UNSIGNED_DECIMAL 17592186044416 +#endif +#if LONG_HAS_BITS(46) +#define LARGE_UNSIGNED_DECIMAL 35184372088832 +#endif +#if LONG_HAS_BITS(47) +#define LARGE_UNSIGNED_DECIMAL 70368744177664 +#endif +#if LONG_HAS_BITS(48) +#define LARGE_UNSIGNED_DECIMAL 140737488355328 +#endif +#if LONG_HAS_BITS(49) +#define LARGE_UNSIGNED_DECIMAL 281474976710656 +#endif +#if LONG_HAS_BITS(50) +#define LARGE_UNSIGNED_DECIMAL 562949953421312 +#endif +#if LONG_HAS_BITS(51) +#define LARGE_UNSIGNED_DECIMAL 1125899906842624 +#endif +#if LONG_HAS_BITS(52) +#define LARGE_UNSIGNED_DECIMAL 2251799813685248 +#endif +#if LONG_HAS_BITS(53) +#define LARGE_UNSIGNED_DECIMAL 4503599627370496 +#endif +#if LONG_HAS_BITS(54) +#define LARGE_UNSIGNED_DECIMAL 9007199254740992 +#endif +#if LONG_HAS_BITS(55) +#define LARGE_UNSIGNED_DECIMAL 18014398509481984 +#endif +#if LONG_HAS_BITS(56) +#define LARGE_UNSIGNED_DECIMAL 36028797018963968 +#endif +#if LONG_HAS_BITS(57) +#define LARGE_UNSIGNED_DECIMAL 72057594037927936 +#endif +#if LONG_HAS_BITS(58) +#define LARGE_UNSIGNED_DECIMAL 144115188075855872 +#endif +#if LONG_HAS_BITS(59) +#define LARGE_UNSIGNED_DECIMAL 288230376151711744 +#endif +#if LONG_HAS_BITS(60) +#define LARGE_UNSIGNED_DECIMAL 576460752303423488 +#endif +#if LONG_HAS_BITS(61) +#define LARGE_UNSIGNED_DECIMAL 1152921504606846976 +#endif +#if LONG_HAS_BITS(62) +#define LARGE_UNSIGNED_DECIMAL 2305843009213693952 +#endif +#if LONG_HAS_BITS(63) +#define LARGE_UNSIGNED_DECIMAL 4611686018427387904 +#endif +#if LONG_HAS_BITS(64) +#define LARGE_UNSIGNED_DECIMAL 9223372036854775808 +#endif +#if LONG_AT_LEAST(65) +#error "extend this test to allow for long larger than 64 bits" +#endif + +#define cat(x, y) x ## y +#define xcat(x, y) cat(x, y) + +#define LARGE_UNSIGNED_DECIMALl xcat(LARGE_UNSIGNED_DECIMAL, l) +#define LARGE_UNSIGNED_DECIMALL xcat(LARGE_UNSIGNED_DECIMAL, L) +#define LARGE_UNSIGNED_DECIMALu xcat(LARGE_UNSIGNED_DECIMAL, u) +#define LARGE_UNSIGNED_DECIMALU xcat(LARGE_UNSIGNED_DECIMAL, U) +#define LARGE_UNSIGNED_DECIMALul xcat(LARGE_UNSIGNED_DECIMAL, ul) +#define LARGE_UNSIGNED_DECIMALuL xcat(LARGE_UNSIGNED_DECIMAL, uL) +#define LARGE_UNSIGNED_DECIMALUl xcat(LARGE_UNSIGNED_DECIMAL, Ul) +#define LARGE_UNSIGNED_DECIMALUL xcat(LARGE_UNSIGNED_DECIMAL, UL) + +void +foo (void) +{ + /* Decimal. */ + /* Check all 2^n and 2^n - 1 up to 2^63 - 1. Check values that would be + unsigned separately since they generate a warning. */ + CHECK_DEC_CONST(1); + CHECK_DEC_CONST(2); + CHECK_DEC_CONST(3); + CHECK_DEC_CONST(4); + CHECK_DEC_CONST(7); + CHECK_DEC_CONST(8); + CHECK_DEC_CONST(15); + CHECK_DEC_CONST(16); + CHECK_DEC_CONST(31); + CHECK_DEC_CONST(32); + CHECK_DEC_CONST(63); + CHECK_DEC_CONST(64); + CHECK_DEC_CONST(127); + CHECK_DEC_CONST(128); + CHECK_DEC_CONST(255); + CHECK_DEC_CONST(256); + CHECK_DEC_CONST(511); + CHECK_DEC_CONST(512); + CHECK_DEC_CONST(1023); + CHECK_DEC_CONST(1024); + CHECK_DEC_CONST(2047); + CHECK_DEC_CONST(2048); + CHECK_DEC_CONST(4095); + CHECK_DEC_CONST(4096); + CHECK_DEC_CONST(8191); + CHECK_DEC_CONST(8192); + CHECK_DEC_CONST(16383); + CHECK_DEC_CONST(16384); + CHECK_DEC_CONST(32767); + CHECK_DEC_CONST(32768); + CHECK_DEC_CONST(65535); + CHECK_DEC_CONST(65536); + CHECK_DEC_CONST(131071); + CHECK_DEC_CONST(131072); + CHECK_DEC_CONST(262143); + CHECK_DEC_CONST(262144); + CHECK_DEC_CONST(524287); + CHECK_DEC_CONST(524288); + CHECK_DEC_CONST(1048575); + CHECK_DEC_CONST(1048576); + CHECK_DEC_CONST(2097151); + CHECK_DEC_CONST(2097152); + CHECK_DEC_CONST(4194303); + CHECK_DEC_CONST(4194304); + CHECK_DEC_CONST(8388607); + CHECK_DEC_CONST(8388608); + CHECK_DEC_CONST(16777215); + CHECK_DEC_CONST(16777216); + CHECK_DEC_CONST(33554431); + CHECK_DEC_CONST(33554432); + CHECK_DEC_CONST(67108863); + CHECK_DEC_CONST(67108864); + CHECK_DEC_CONST(134217727); + CHECK_DEC_CONST(134217728); + CHECK_DEC_CONST(268435455); + CHECK_DEC_CONST(268435456); + CHECK_DEC_CONST(536870911); + CHECK_DEC_CONST(536870912); + CHECK_DEC_CONST(1073741823); + CHECK_DEC_CONST(1073741824); + CHECK_DEC_CONST(2147483647); +#if LONG_AT_LEAST(33) + CHECK_DEC_CONST(2147483648); + CHECK_DEC_CONST(4294967295); +#endif +#if LONG_AT_LEAST(34) + CHECK_DEC_CONST(4294967296); + CHECK_DEC_CONST(8589934591); +#endif +#if LONG_AT_LEAST(35) + CHECK_DEC_CONST(8589934592); + CHECK_DEC_CONST(17179869183); +#endif +#if LONG_AT_LEAST(36) + CHECK_DEC_CONST(17179869184); + CHECK_DEC_CONST(34359738367); +#endif +#if LONG_AT_LEAST(37) + CHECK_DEC_CONST(34359738368); + CHECK_DEC_CONST(68719476735); +#endif +#if LONG_AT_LEAST(38) + CHECK_DEC_CONST(68719476736); + CHECK_DEC_CONST(137438953471); +#endif +#if LONG_AT_LEAST(39) + CHECK_DEC_CONST(137438953472); + CHECK_DEC_CONST(274877906943); +#endif +#if LONG_AT_LEAST(40) + CHECK_DEC_CONST(274877906944); + CHECK_DEC_CONST(549755813887); +#endif +#if LONG_AT_LEAST(41) + CHECK_DEC_CONST(549755813888); + CHECK_DEC_CONST(1099511627775); +#endif +#if LONG_AT_LEAST(42) + CHECK_DEC_CONST(1099511627776); + CHECK_DEC_CONST(2199023255551); +#endif +#if LONG_AT_LEAST(43) + CHECK_DEC_CONST(2199023255552); + CHECK_DEC_CONST(4398046511103); +#endif +#if LONG_AT_LEAST(44) + CHECK_DEC_CONST(4398046511104); + CHECK_DEC_CONST(8796093022207); +#endif +#if LONG_AT_LEAST(45) + CHECK_DEC_CONST(8796093022208); + CHECK_DEC_CONST(17592186044415); +#endif +#if LONG_AT_LEAST(46) + CHECK_DEC_CONST(17592186044416); + CHECK_DEC_CONST(35184372088831); +#endif +#if LONG_AT_LEAST(47) + CHECK_DEC_CONST(35184372088832); + CHECK_DEC_CONST(70368744177663); +#endif +#if LONG_AT_LEAST(48) + CHECK_DEC_CONST(70368744177664); + CHECK_DEC_CONST(140737488355327); +#endif +#if LONG_AT_LEAST(49) + CHECK_DEC_CONST(140737488355328); + CHECK_DEC_CONST(281474976710655); +#endif +#if LONG_AT_LEAST(50) + CHECK_DEC_CONST(281474976710656); + CHECK_DEC_CONST(562949953421311); +#endif +#if LONG_AT_LEAST(51) + CHECK_DEC_CONST(562949953421312); + CHECK_DEC_CONST(1125899906842623); +#endif +#if LONG_AT_LEAST(52) + CHECK_DEC_CONST(1125899906842624); + CHECK_DEC_CONST(2251799813685247); +#endif +#if LONG_AT_LEAST(53) + CHECK_DEC_CONST(2251799813685248); + CHECK_DEC_CONST(4503599627370495); +#endif +#if LONG_AT_LEAST(54) + CHECK_DEC_CONST(4503599627370496); + CHECK_DEC_CONST(9007199254740991); +#endif +#if LONG_AT_LEAST(55) + CHECK_DEC_CONST(9007199254740992); + CHECK_DEC_CONST(18014398509481983); +#endif +#if LONG_AT_LEAST(56) + CHECK_DEC_CONST(18014398509481984); + CHECK_DEC_CONST(36028797018963967); +#endif +#if LONG_AT_LEAST(57) + CHECK_DEC_CONST(36028797018963968); + CHECK_DEC_CONST(72057594037927935); +#endif +#if LONG_AT_LEAST(58) + CHECK_DEC_CONST(72057594037927936); + CHECK_DEC_CONST(144115188075855871); +#endif +#if LONG_AT_LEAST(59) + CHECK_DEC_CONST(144115188075855872); + CHECK_DEC_CONST(288230376151711743); +#endif +#if LONG_AT_LEAST(60) + CHECK_DEC_CONST(288230376151711744); + CHECK_DEC_CONST(576460752303423487); +#endif +#if LONG_AT_LEAST(61) + CHECK_DEC_CONST(576460752303423488); + CHECK_DEC_CONST(1152921504606846975); +#endif +#if LONG_AT_LEAST(62) + CHECK_DEC_CONST(1152921504606846976); + CHECK_DEC_CONST(2305843009213693951); +#endif +#if LONG_AT_LEAST(63) + CHECK_DEC_CONST(2305843009213693952); + CHECK_DEC_CONST(4611686018427387903); +#endif +#if LONG_AT_LEAST(64) + CHECK_DEC_CONST(4611686018427387904); + CHECK_DEC_CONST(9223372036854775807); +#endif + /* Separate checks for values that are unsigned. */ + CHECK_UNSUF_DEC_TYPE(LARGE_UNSIGNED_DECIMAL); /* { dg-warning "unsigned" "unsigned decimal no suffix" } */ + CHECK_SUFl_TYPE(LARGE_UNSIGNED_DECIMALl); /* { dg-warning "unsigned" "unsigned decimal long suffix" } */ + CHECK_SUFl_TYPE(LARGE_UNSIGNED_DECIMALL); /* { dg-warning "unsigned" "unsigned decimal long suffix" } */ + CHECK_SUFu_TYPE(LARGE_UNSIGNED_DECIMALu); + CHECK_SUFu_TYPE(LARGE_UNSIGNED_DECIMALU); + CHECK_SUFul_TYPE(LARGE_UNSIGNED_DECIMALul); + CHECK_SUFul_TYPE(LARGE_UNSIGNED_DECIMALuL); + CHECK_SUFul_TYPE(LARGE_UNSIGNED_DECIMALUl); + CHECK_SUFul_TYPE(LARGE_UNSIGNED_DECIMALUL); + /* Octal and hexadecimal. */ + /* Check all 2^n and 2^n - 1 up to 2^64 - 1. */ + CHECK_OCT_CONST(0); + CHECK_HEX_CONST(0); + CHECK_OCT_CONST(01); + CHECK_HEX_CONST(1); + CHECK_OCT_CONST(02); + CHECK_HEX_CONST(2); + CHECK_OCT_CONST(03); + CHECK_HEX_CONST(3); + CHECK_OCT_CONST(04); + CHECK_HEX_CONST(4); + CHECK_OCT_CONST(07); + CHECK_HEX_CONST(7); + CHECK_OCT_CONST(010); + CHECK_HEX_CONST(8); + CHECK_OCT_CONST(017); + CHECK_HEX_CONST(f); + CHECK_OCT_CONST(020); + CHECK_HEX_CONST(10); + CHECK_OCT_CONST(037); + CHECK_HEX_CONST(1f); + CHECK_OCT_CONST(040); + CHECK_HEX_CONST(20); + CHECK_OCT_CONST(077); + CHECK_HEX_CONST(3f); + CHECK_OCT_CONST(0100); + CHECK_HEX_CONST(40); + CHECK_OCT_CONST(0177); + CHECK_HEX_CONST(7f); + CHECK_OCT_CONST(0200); + CHECK_HEX_CONST(80); + CHECK_OCT_CONST(0377); + CHECK_HEX_CONST(ff); + CHECK_OCT_CONST(0400); + CHECK_HEX_CONST(100); + CHECK_OCT_CONST(0777); + CHECK_HEX_CONST(1ff); + CHECK_OCT_CONST(01000); + CHECK_HEX_CONST(200); + CHECK_OCT_CONST(01777); + CHECK_HEX_CONST(3ff); + CHECK_OCT_CONST(02000); + CHECK_HEX_CONST(400); + CHECK_OCT_CONST(03777); + CHECK_HEX_CONST(7ff); + CHECK_OCT_CONST(04000); + CHECK_HEX_CONST(800); + CHECK_OCT_CONST(07777); + CHECK_HEX_CONST(fff); + CHECK_OCT_CONST(010000); + CHECK_HEX_CONST(1000); + CHECK_OCT_CONST(017777); + CHECK_HEX_CONST(1fff); + CHECK_OCT_CONST(020000); + CHECK_HEX_CONST(2000); + CHECK_OCT_CONST(037777); + CHECK_HEX_CONST(3fff); + CHECK_OCT_CONST(040000); + CHECK_HEX_CONST(4000); + CHECK_OCT_CONST(077777); + CHECK_HEX_CONST(7fff); + CHECK_OCT_CONST(0100000); + CHECK_HEX_CONST(8000); + CHECK_OCT_CONST(0177777); + CHECK_HEX_CONST(ffff); + CHECK_OCT_CONST(0200000); + CHECK_HEX_CONST(10000); + CHECK_OCT_CONST(0377777); + CHECK_HEX_CONST(1ffff); + CHECK_OCT_CONST(0400000); + CHECK_HEX_CONST(20000); + CHECK_OCT_CONST(0777777); + CHECK_HEX_CONST(3ffff); + CHECK_OCT_CONST(01000000); + CHECK_HEX_CONST(40000); + CHECK_OCT_CONST(01777777); + CHECK_HEX_CONST(7ffff); + CHECK_OCT_CONST(02000000); + CHECK_HEX_CONST(80000); + CHECK_OCT_CONST(03777777); + CHECK_HEX_CONST(fffff); + CHECK_OCT_CONST(04000000); + CHECK_HEX_CONST(100000); + CHECK_OCT_CONST(07777777); + CHECK_HEX_CONST(1fffff); + CHECK_OCT_CONST(010000000); + CHECK_HEX_CONST(200000); + CHECK_OCT_CONST(017777777); + CHECK_HEX_CONST(3fffff); + CHECK_OCT_CONST(020000000); + CHECK_HEX_CONST(400000); + CHECK_OCT_CONST(037777777); + CHECK_HEX_CONST(7fffff); + CHECK_OCT_CONST(040000000); + CHECK_HEX_CONST(800000); + CHECK_OCT_CONST(077777777); + CHECK_HEX_CONST(ffffff); + CHECK_OCT_CONST(0100000000); + CHECK_HEX_CONST(1000000); + CHECK_OCT_CONST(0177777777); + CHECK_HEX_CONST(1ffffff); + CHECK_OCT_CONST(0200000000); + CHECK_HEX_CONST(2000000); + CHECK_OCT_CONST(0377777777); + CHECK_HEX_CONST(3ffffff); + CHECK_OCT_CONST(0400000000); + CHECK_HEX_CONST(4000000); + CHECK_OCT_CONST(0777777777); + CHECK_HEX_CONST(7ffffff); + CHECK_OCT_CONST(01000000000); + CHECK_HEX_CONST(8000000); + CHECK_OCT_CONST(01777777777); + CHECK_HEX_CONST(fffffff); + CHECK_OCT_CONST(02000000000); + CHECK_HEX_CONST(10000000); + CHECK_OCT_CONST(03777777777); + CHECK_HEX_CONST(1fffffff); + CHECK_OCT_CONST(04000000000); + CHECK_HEX_CONST(20000000); + CHECK_OCT_CONST(07777777777); + CHECK_HEX_CONST(3fffffff); + CHECK_OCT_CONST(010000000000); + CHECK_HEX_CONST(40000000); + CHECK_OCT_CONST(017777777777); + CHECK_HEX_CONST(7fffffff); + CHECK_OCT_CONST(020000000000); + CHECK_HEX_CONST(80000000); + CHECK_OCT_CONST(037777777777); + CHECK_HEX_CONST(ffffffff); +#if LONG_AT_LEAST(33) + CHECK_OCT_CONST(040000000000); + CHECK_HEX_CONST(100000000); + CHECK_OCT_CONST(077777777777); + CHECK_HEX_CONST(1ffffffff); +#endif +#if LONG_AT_LEAST(34) + CHECK_OCT_CONST(0100000000000); + CHECK_HEX_CONST(200000000); + CHECK_OCT_CONST(0177777777777); + CHECK_HEX_CONST(3ffffffff); +#endif +#if LONG_AT_LEAST(35) + CHECK_OCT_CONST(0200000000000); + CHECK_HEX_CONST(400000000); + CHECK_OCT_CONST(0377777777777); + CHECK_HEX_CONST(7ffffffff); +#endif +#if LONG_AT_LEAST(36) + CHECK_OCT_CONST(0400000000000); + CHECK_HEX_CONST(800000000); + CHECK_OCT_CONST(0777777777777); + CHECK_HEX_CONST(fffffffff); +#endif +#if LONG_AT_LEAST(37) + CHECK_OCT_CONST(01000000000000); + CHECK_HEX_CONST(1000000000); + CHECK_OCT_CONST(01777777777777); + CHECK_HEX_CONST(1fffffffff); +#endif +#if LONG_AT_LEAST(38) + CHECK_OCT_CONST(02000000000000); + CHECK_HEX_CONST(2000000000); + CHECK_OCT_CONST(03777777777777); + CHECK_HEX_CONST(3fffffffff); +#endif +#if LONG_AT_LEAST(39) + CHECK_OCT_CONST(04000000000000); + CHECK_HEX_CONST(4000000000); + CHECK_OCT_CONST(07777777777777); + CHECK_HEX_CONST(7fffffffff); +#endif +#if LONG_AT_LEAST(40) + CHECK_OCT_CONST(010000000000000); + CHECK_HEX_CONST(8000000000); + CHECK_OCT_CONST(017777777777777); + CHECK_HEX_CONST(ffffffffff); +#endif +#if LONG_AT_LEAST(41) + CHECK_OCT_CONST(020000000000000); + CHECK_HEX_CONST(10000000000); + CHECK_OCT_CONST(037777777777777); + CHECK_HEX_CONST(1ffffffffff); +#endif +#if LONG_AT_LEAST(42) + CHECK_OCT_CONST(040000000000000); + CHECK_HEX_CONST(20000000000); + CHECK_OCT_CONST(077777777777777); + CHECK_HEX_CONST(3ffffffffff); +#endif +#if LONG_AT_LEAST(43) + CHECK_OCT_CONST(0100000000000000); + CHECK_HEX_CONST(40000000000); + CHECK_OCT_CONST(0177777777777777); + CHECK_HEX_CONST(7ffffffffff); +#endif +#if LONG_AT_LEAST(44) + CHECK_OCT_CONST(0200000000000000); + CHECK_HEX_CONST(80000000000); + CHECK_OCT_CONST(0377777777777777); + CHECK_HEX_CONST(fffffffffff); +#endif +#if LONG_AT_LEAST(45) + CHECK_OCT_CONST(0400000000000000); + CHECK_HEX_CONST(100000000000); + CHECK_OCT_CONST(0777777777777777); + CHECK_HEX_CONST(1fffffffffff); +#endif +#if LONG_AT_LEAST(46) + CHECK_OCT_CONST(01000000000000000); + CHECK_HEX_CONST(200000000000); + CHECK_OCT_CONST(01777777777777777); + CHECK_HEX_CONST(3fffffffffff); +#endif +#if LONG_AT_LEAST(47) + CHECK_OCT_CONST(02000000000000000); + CHECK_HEX_CONST(400000000000); + CHECK_OCT_CONST(03777777777777777); + CHECK_HEX_CONST(7fffffffffff); +#endif +#if LONG_AT_LEAST(48) + CHECK_OCT_CONST(04000000000000000); + CHECK_HEX_CONST(800000000000); + CHECK_OCT_CONST(07777777777777777); + CHECK_HEX_CONST(ffffffffffff); +#endif +#if LONG_AT_LEAST(49) + CHECK_OCT_CONST(010000000000000000); + CHECK_HEX_CONST(1000000000000); + CHECK_OCT_CONST(017777777777777777); + CHECK_HEX_CONST(1ffffffffffff); +#endif +#if LONG_AT_LEAST(50) + CHECK_OCT_CONST(020000000000000000); + CHECK_HEX_CONST(2000000000000); + CHECK_OCT_CONST(037777777777777777); + CHECK_HEX_CONST(3ffffffffffff); +#endif +#if LONG_AT_LEAST(51) + CHECK_OCT_CONST(040000000000000000); + CHECK_HEX_CONST(4000000000000); + CHECK_OCT_CONST(077777777777777777); + CHECK_HEX_CONST(7ffffffffffff); +#endif +#if LONG_AT_LEAST(52) + CHECK_OCT_CONST(0100000000000000000); + CHECK_HEX_CONST(8000000000000); + CHECK_OCT_CONST(0177777777777777777); + CHECK_HEX_CONST(fffffffffffff); +#endif +#if LONG_AT_LEAST(53) + CHECK_OCT_CONST(0200000000000000000); + CHECK_HEX_CONST(10000000000000); + CHECK_OCT_CONST(0377777777777777777); + CHECK_HEX_CONST(1fffffffffffff); +#endif +#if LONG_AT_LEAST(54) + CHECK_OCT_CONST(0400000000000000000); + CHECK_HEX_CONST(20000000000000); + CHECK_OCT_CONST(0777777777777777777); + CHECK_HEX_CONST(3fffffffffffff); +#endif +#if LONG_AT_LEAST(55) + CHECK_OCT_CONST(01000000000000000000); + CHECK_HEX_CONST(40000000000000); + CHECK_OCT_CONST(01777777777777777777); + CHECK_HEX_CONST(7fffffffffffff); +#endif +#if LONG_AT_LEAST(56) + CHECK_OCT_CONST(02000000000000000000); + CHECK_HEX_CONST(80000000000000); + CHECK_OCT_CONST(03777777777777777777); + CHECK_HEX_CONST(ffffffffffffff); +#endif +#if LONG_AT_LEAST(57) + CHECK_OCT_CONST(04000000000000000000); + CHECK_HEX_CONST(100000000000000); + CHECK_OCT_CONST(07777777777777777777); + CHECK_HEX_CONST(1ffffffffffffff); +#endif +#if LONG_AT_LEAST(58) + CHECK_OCT_CONST(010000000000000000000); + CHECK_HEX_CONST(200000000000000); + CHECK_OCT_CONST(017777777777777777777); + CHECK_HEX_CONST(3ffffffffffffff); +#endif +#if LONG_AT_LEAST(59) + CHECK_OCT_CONST(020000000000000000000); + CHECK_HEX_CONST(400000000000000); + CHECK_OCT_CONST(037777777777777777777); + CHECK_HEX_CONST(7ffffffffffffff); +#endif +#if LONG_AT_LEAST(60) + CHECK_OCT_CONST(040000000000000000000); + CHECK_HEX_CONST(800000000000000); + CHECK_OCT_CONST(077777777777777777777); + CHECK_HEX_CONST(fffffffffffffff); +#endif +#if LONG_AT_LEAST(61) + CHECK_OCT_CONST(0100000000000000000000); + CHECK_HEX_CONST(1000000000000000); + CHECK_OCT_CONST(0177777777777777777777); + CHECK_HEX_CONST(1fffffffffffffff); +#endif +#if LONG_AT_LEAST(62) + CHECK_OCT_CONST(0200000000000000000000); + CHECK_HEX_CONST(2000000000000000); + CHECK_OCT_CONST(0377777777777777777777); + CHECK_HEX_CONST(3fffffffffffffff); +#endif +#if LONG_AT_LEAST(63) + CHECK_OCT_CONST(0400000000000000000000); + CHECK_HEX_CONST(4000000000000000); + CHECK_OCT_CONST(0777777777777777777777); + CHECK_HEX_CONST(7fffffffffffffff); +#endif +#if LONG_AT_LEAST(64) + CHECK_OCT_CONST(01000000000000000000000); + CHECK_HEX_CONST(8000000000000000); + CHECK_OCT_CONST(01777777777777777777777); + CHECK_HEX_CONST(ffffffffffffffff); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-intprom-1.c b/SingleSource/Regression/C/gcc-dg/c90-intprom-1.c new file mode 100644 index 0000000000..78e4b39ef3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-intprom-1.c @@ -0,0 +1,47 @@ +/* Test for integer promotion rules: C90 subset of types. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#include + +#define CHECK(T1, T2, TC) \ + do { \ + T1 a = 0; \ + T2 b = 0; \ + TC *c = 0; \ + __typeof__(a+b) *d = 0; \ + c = d; \ + d = c; \ + } while (0) + +void +f (void) +{ + /* One type is unsigned long. */ + CHECK(unsigned long, unsigned long, unsigned long); + CHECK(unsigned int, unsigned long, unsigned long); + CHECK(unsigned long, unsigned int, unsigned long); + CHECK(int, unsigned long, unsigned long); + CHECK(long, unsigned long, unsigned long); + CHECK(unsigned long, int, unsigned long); + CHECK(unsigned long, long, unsigned long); + /* long and unsigned int. */ +#if LONG_MAX >= UINT_MAX + CHECK(unsigned int, long, long); + CHECK(long, unsigned int, long); +#else + CHECK(unsigned int, long, unsigned long); + CHECK(long, unsigned int, unsigned long); +#endif + /* One type is long. */ + CHECK(long, long, long); + CHECK(int, long, long); + CHECK(long, int, long); + /* One type is unsigned int. */ + CHECK(unsigned int, unsigned int, unsigned int); + CHECK(int, unsigned int, unsigned int); + CHECK(unsigned int, int, unsigned int); + /* Otherwise int. */ + CHECK(int, int, int); +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-left-shift-1.c b/SingleSource/Regression/C/gcc-dg/c90-left-shift-1.c new file mode 100644 index 0000000000..755595f5c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-left-shift-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +enum E { A = -2 << 1 }; +int i = -1 << 0; + +int +f (int i) +{ + switch (i) + case -1 << 0: break; +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-left-shift-2.c b/SingleSource/Regression/C/gcc-dg/c90-left-shift-2.c new file mode 100644 index 0000000000..f79ab8b71d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-left-shift-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#define INTM2 (sizeof (int) * __CHAR_BIT__ - 2) + +enum { A = 10 << INTM2 }; +int k = 10 << INTM2; + +void +fn (int i) +{ + switch (i) + case 10 << INTM2: break; +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-left-shift-3.c b/SingleSource/Regression/C/gcc-dg/c90-left-shift-3.c new file mode 100644 index 0000000000..43942dd29d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-left-shift-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#define INTM1 (sizeof (int) * __CHAR_BIT__ - 1) + +enum { A = 1 << INTM1 }; +int k = 1 << INTM1; + +void +fn (int i) +{ + switch (i) + case 1 << INTM1: break; +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-longlong-1.c b/SingleSource/Regression/C/gcc-dg/c90-longlong-1.c new file mode 100644 index 0000000000..3594d4be99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-longlong-1.c @@ -0,0 +1,6 @@ +/* Test for long long: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +long long foo; /* { dg-error "long long" "long long not in C90" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-mixdecl-1.c b/SingleSource/Regression/C/gcc-dg/c90-mixdecl-1.c new file mode 100644 index 0000000000..4e8b19264d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-mixdecl-1.c @@ -0,0 +1,13 @@ +/* Test for C99 mixed declarations and code: not in C90. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +void +foo (void) +{ + int i; + i = 0; + int j; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "mix|parse" "mixed declarations and code not in C90" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-noreturn-1.c b/SingleSource/Regression/C/gcc-dg/c90-noreturn-1.c new file mode 100644 index 0000000000..87b832e067 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-noreturn-1.c @@ -0,0 +1,5 @@ +/* Test _Noreturn not in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +_Noreturn void f (void); /* { dg-error "ISO C90 does not support '_Noreturn'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-restrict-1.c b/SingleSource/Regression/C/gcc-dg/c90-restrict-1.c new file mode 100644 index 0000000000..2afd786777 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-restrict-1.c @@ -0,0 +1,7 @@ +/* Test for restrict: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +char *restrict foo; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parse error|syntax error|expected|no type" "restrict not in C90" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-return-1.c b/SingleSource/Regression/C/gcc-dg/c90-return-1.c new file mode 100644 index 0000000000..96a3876a6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-return-1.c @@ -0,0 +1,17 @@ +/* Test for constraints on return statements. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +int +foo (void) +{ + return; +} + +void +bar (void) +{ + return 1; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "with a value" "return constraint violation" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-scope-1.c b/SingleSource/Regression/C/gcc-dg/c90-scope-1.c new file mode 100644 index 0000000000..ad36b7063f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-scope-1.c @@ -0,0 +1,34 @@ +/* Test for new block scopes in C99. Inspired by C99 Rationale (N897). */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +struct foo { + char a; +}; + +extern void abort (void); +extern void exit (int); + +int +sfoo (void) +{ + if (sizeof (struct foo { int a; double b; char *c; void *d; })) + (void) 0; + return sizeof (struct foo); +} + +int +main (void) +{ + int t, u; + t = sfoo (); + u = sizeof (struct foo); + /* With C90 scoping rules the new declaration of struct foo is in scope + above; with C99 it is local to the if. + */ + if (t == u) + abort (); /* C99 rules apply. */ + else + exit (0); /* C90 rules apply. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c90-static-1.c b/SingleSource/Regression/C/gcc-dg/c90-static-1.c new file mode 100644 index 0000000000..cc6f320c5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-static-1.c @@ -0,0 +1,22 @@ +/* It is a constraint violation for a static function to be declared + but not defined if it is used except in a sizeof expression. The + use of the function simply being unevaluated is not enough. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=iso9899:1990 -pedantic-errors" } */ + +/* Constraint violation (trivial case, where function is used). */ +static void f0(void); /* { dg-error "used but never defined" } */ +void g0(void) { f0(); } + +/* Constraint violation. */ +static void f1(void); /* { dg-error "used but never defined" } */ +void g1(void) { if (0) { f1(); } } + +/* Constraint violation. */ +static int f2(void); /* { dg-error "used but never defined" } */ +void g2(void) { 0 ? f2() : 0; } + +/* OK. */ +static int f3(void); +void g3(void) { sizeof(f3()); } diff --git a/SingleSource/Regression/C/gcc-dg/c90-static-assert-1.c b/SingleSource/Regression/C/gcc-dg/c90-static-assert-1.c new file mode 100644 index 0000000000..d174ec9b10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-static-assert-1.c @@ -0,0 +1,5 @@ +/* Test for static assertions not in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +_Static_assert (1, ""); /* { dg-error "ISO C90 does not support '_Static_assert'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-thread-local-1.c b/SingleSource/Regression/C/gcc-dg/c90-thread-local-1.c new file mode 100644 index 0000000000..92bf57a90b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-thread-local-1.c @@ -0,0 +1,5 @@ +/* Test for _Thread_local: not in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=c90 -pedantic-errors" } */ + +static _Thread_local int x; /* { dg-error "_Thread_local" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-typedef-1.c b/SingleSource/Regression/C/gcc-dg/c90-typedef-1.c new file mode 100644 index 0000000000..1920f3b519 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-typedef-1.c @@ -0,0 +1,6 @@ +/* Test typedef redeclaration not permitted in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +typedef int TI; /* { dg-message "previous declaration" } */ +typedef int TI; /* { dg-error "redefinition of typedef" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-typespec-1.c b/SingleSource/Regression/C/gcc-dg/c90-typespec-1.c new file mode 100644 index 0000000000..e32111b632 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-typespec-1.c @@ -0,0 +1,522 @@ +/* Test for valid and invalid combinations of type specifiers in C90. + Similar to typespec-1.c but with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +typedef char type; +extern *x0; +void *x1; +char *x2; +short *x3; +int *x4; +long *x5; +float *x6; +double *x7; +signed *x8; +unsigned *x9; +type *x10; +void void *x11; /* { dg-error "" "void void" } */ +void char *x12; /* { dg-error "" "void char" } */ +void short *x13; /* { dg-error "" "void short" } */ +void int *x14; /* { dg-error "" "void int" } */ +void long *x15; /* { dg-error "" "void long" } */ +void float *x16; /* { dg-error "" "void float" } */ +void double *x17; /* { dg-error "" "void double" } */ +void signed *x18; /* { dg-error "" "void signed" } */ +void unsigned *x19; /* { dg-error "" "void unsigned" } */ +char void *x20; /* { dg-error "" "char void" } */ +char char *x21; /* { dg-error "" "char char" } */ +char short *x22; /* { dg-error "" "char short" } */ +char int *x23; /* { dg-error "" "char int" } */ +char long *x24; /* { dg-error "" "char long" } */ +char float *x25; /* { dg-error "" "char float" } */ +char double *x26; /* { dg-error "" "char double" } */ +char signed *x27; +char unsigned *x28; +short void *x29; /* { dg-error "" "short void" } */ +short char *x30; /* { dg-error "" "short char" } */ +short short *x31; /* { dg-error "" "short short" } */ +short int *x32; +short long *x33; /* { dg-error "" "short long" } */ +short float *x34; /* { dg-error "" "short float" } */ +short double *x35; /* { dg-error "" "short double" } */ +short signed *x36; +short unsigned *x37; +int void *x38; /* { dg-error "" "int void" } */ +int char *x39; /* { dg-error "" "int char" } */ +int short *x40; +int int *x41; /* { dg-error "" "int int" } */ +int long *x42; +int float *x43; /* { dg-error "" "int float" } */ +int double *x44; /* { dg-error "" "int double" } */ +int signed *x45; +int unsigned *x46; +long void *x47; /* { dg-error "" "long void" } */ +long char *x48; /* { dg-error "" "long char" } */ +long short *x49; /* { dg-error "" "long short" } */ +long int *x50; +long long *x51; /* { dg-error "" "long long" } */ +long float *x52; /* { dg-error "" "long float" } */ +long double *x53; +long signed *x54; +long unsigned *x55; +float void *x56; /* { dg-error "" "float void" } */ +float char *x57; /* { dg-error "" "float char" } */ +float short *x58; /* { dg-error "" "float short" } */ +float int *x59; /* { dg-error "" "float int" } */ +float long *x60; /* { dg-error "" "float long" } */ +float float *x61; /* { dg-error "" "float float" } */ +float double *x62; /* { dg-error "" "float double" } */ +float signed *x63; /* { dg-error "" "float signed" } */ +float unsigned *x64; /* { dg-error "" "float unsigned" } */ +double void *x65; /* { dg-error "" "double void" } */ +double char *x66; /* { dg-error "" "double char" } */ +double short *x67; /* { dg-error "" "double short" } */ +double int *x68; /* { dg-error "" "double int" } */ +double long *x69; +double float *x70; /* { dg-error "" "double float" } */ +double double *x71; /* { dg-error "" "double double" } */ +double signed *x72; /* { dg-error "" "double signed" } */ +double unsigned *x73; /* { dg-error "" "double unsigned" } */ +signed void *x74; /* { dg-error "" "signed void" } */ +signed char *x75; +signed short *x76; +signed int *x77; +signed long *x78; +signed float *x79; /* { dg-error "" "signed float" } */ +signed double *x80; /* { dg-error "" "signed double" } */ +signed signed *x81; /* { dg-error "" "signed signed" } */ +signed unsigned *x82; /* { dg-error "" "signed unsigned" } */ +unsigned void *x83; /* { dg-error "" "unsigned void" } */ +unsigned char *x84; +unsigned short *x85; +unsigned int *x86; +unsigned long *x87; +unsigned float *x88; /* { dg-error "" "unsigned float" } */ +unsigned double *x89; /* { dg-error "" "unsigned double" } */ +unsigned signed *x90; /* { dg-error "" "unsigned signed" } */ +unsigned unsigned *x91; /* { dg-error "" "unsigned unsigned" } */ +type void *x92; /* { dg-error "" "type void" } */ +type char *x93; /* { dg-error "" "type char" } */ +type short *x94; /* { dg-error "" "type short" } */ +type int *x95; /* { dg-error "" "type int" } */ +type long *x96; /* { dg-error "" "type long" } */ +type float *x97; /* { dg-error "" "type float" } */ +type double *x98; /* { dg-error "" "type double" } */ +type signed *x99; /* { dg-error "" "type signed" } */ +type unsigned *x100; /* { dg-error "" "type unsigned" } */ +char signed void *x101; /* { dg-error "" "char signed void" } */ +char signed char *x102; /* { dg-error "" "char signed char" } */ +char signed short *x103; /* { dg-error "" "char signed short" } */ +char signed int *x104; /* { dg-error "" "char signed int" } */ +char signed long *x105; /* { dg-error "" "char signed long" } */ +char signed float *x106; /* { dg-error "" "char signed float" } */ +char signed double *x107; /* { dg-error "" "char signed double" } */ +char signed signed *x108; /* { dg-error "" "char signed signed" } */ +char signed unsigned *x109; /* { dg-error "" "char signed unsigned" } */ +char unsigned void *x110; /* { dg-error "" "char unsigned void" } */ +char unsigned char *x111; /* { dg-error "" "char unsigned char" } */ +char unsigned short *x112; /* { dg-error "" "char unsigned short" } */ +char unsigned int *x113; /* { dg-error "" "char unsigned int" } */ +char unsigned long *x114; /* { dg-error "" "char unsigned long" } */ +char unsigned float *x115; /* { dg-error "" "char unsigned float" } */ +char unsigned double *x116; /* { dg-error "" "char unsigned double" } */ +char unsigned signed *x117; /* { dg-error "" "char unsigned signed" } */ +char unsigned unsigned *x118; /* { dg-error "" "char unsigned unsigned" } */ +short int void *x119; /* { dg-error "" "short int void" } */ +short int char *x120; /* { dg-error "" "short int char" } */ +short int short *x121; /* { dg-error "" "short int short" } */ +short int int *x122; /* { dg-error "" "short int int" } */ +short int long *x123; /* { dg-error "" "short int long" } */ +short int float *x124; /* { dg-error "" "short int float" } */ +short int double *x125; /* { dg-error "" "short int double" } */ +short int signed *x126; +short int unsigned *x127; +short signed void *x128; /* { dg-error "" "short signed void" } */ +short signed char *x129; /* { dg-error "" "short signed char" } */ +short signed short *x130; /* { dg-error "" "short signed short" } */ +short signed int *x131; +short signed long *x132; /* { dg-error "" "short signed long" } */ +short signed float *x133; /* { dg-error "" "short signed float" } */ +short signed double *x134; /* { dg-error "" "short signed double" } */ +short signed signed *x135; /* { dg-error "" "short signed signed" } */ +short signed unsigned *x136; /* { dg-error "" "short signed unsigned" } */ +short unsigned void *x137; /* { dg-error "" "short unsigned void" } */ +short unsigned char *x138; /* { dg-error "" "short unsigned char" } */ +short unsigned short *x139; /* { dg-error "" "short unsigned short" } */ +short unsigned int *x140; +short unsigned long *x141; /* { dg-error "" "short unsigned long" } */ +short unsigned float *x142; /* { dg-error "" "short unsigned float" } */ +short unsigned double *x143; /* { dg-error "" "short unsigned double" } */ +short unsigned signed *x144; /* { dg-error "" "short unsigned signed" } */ +short unsigned unsigned *x145; /* { dg-error "" "short unsigned unsigned" } */ +int short void *x146; /* { dg-error "" "int short void" } */ +int short char *x147; /* { dg-error "" "int short char" } */ +int short short *x148; /* { dg-error "" "int short short" } */ +int short int *x149; /* { dg-error "" "int short int" } */ +int short long *x150; /* { dg-error "" "int short long" } */ +int short float *x151; /* { dg-error "" "int short float" } */ +int short double *x152; /* { dg-error "" "int short double" } */ +int short signed *x153; +int short unsigned *x154; +int long void *x155; /* { dg-error "" "int long void" } */ +int long char *x156; /* { dg-error "" "int long char" } */ +int long short *x157; /* { dg-error "" "int long short" } */ +int long int *x158; /* { dg-error "" "int long int" } */ +int long long *x159; /* { dg-error "" "int long long" } */ +int long float *x160; /* { dg-error "" "int long float" } */ +int long double *x161; /* { dg-error "" "int long double" } */ +int long signed *x162; +int long unsigned *x163; +int signed void *x164; /* { dg-error "" "int signed void" } */ +int signed char *x165; /* { dg-error "" "int signed char" } */ +int signed short *x166; +int signed int *x167; /* { dg-error "" "int signed int" } */ +int signed long *x168; +int signed float *x169; /* { dg-error "" "int signed float" } */ +int signed double *x170; /* { dg-error "" "int signed double" } */ +int signed signed *x171; /* { dg-error "" "int signed signed" } */ +int signed unsigned *x172; /* { dg-error "" "int signed unsigned" } */ +int unsigned void *x173; /* { dg-error "" "int unsigned void" } */ +int unsigned char *x174; /* { dg-error "" "int unsigned char" } */ +int unsigned short *x175; +int unsigned int *x176; /* { dg-error "" "int unsigned int" } */ +int unsigned long *x177; +int unsigned float *x178; /* { dg-error "" "int unsigned float" } */ +int unsigned double *x179; /* { dg-error "" "int unsigned double" } */ +int unsigned signed *x180; /* { dg-error "" "int unsigned signed" } */ +int unsigned unsigned *x181; /* { dg-error "" "int unsigned unsigned" } */ +long int void *x182; /* { dg-error "" "long int void" } */ +long int char *x183; /* { dg-error "" "long int char" } */ +long int short *x184; /* { dg-error "" "long int short" } */ +long int int *x185; /* { dg-error "" "long int int" } */ +long int long *x186; /* { dg-error "" "long int long" } */ +long int float *x187; /* { dg-error "" "long int float" } */ +long int double *x188; /* { dg-error "" "long int double" } */ +long int signed *x189; +long int unsigned *x190; +long double void *x191; /* { dg-error "" "long double void" } */ +long double char *x192; /* { dg-error "" "long double char" } */ +long double short *x193; /* { dg-error "" "long double short" } */ +long double int *x194; /* { dg-error "" "long double int" } */ +long double long *x195; /* { dg-error "" "long double long" } */ +long double float *x196; /* { dg-error "" "long double float" } */ +long double double *x197; /* { dg-error "" "long double double" } */ +long double signed *x198; /* { dg-error "" "long double signed" } */ +long double unsigned *x199; /* { dg-error "" "long double unsigned" } */ +long signed void *x200; /* { dg-error "" "long signed void" } */ +long signed char *x201; /* { dg-error "" "long signed char" } */ +long signed short *x202; /* { dg-error "" "long signed short" } */ +long signed int *x203; +long signed long *x204; /* { dg-error "" "long signed long" } */ +long signed float *x205; /* { dg-error "" "long signed float" } */ +long signed double *x206; /* { dg-error "" "long signed double" } */ +long signed signed *x207; /* { dg-error "" "long signed signed" } */ +long signed unsigned *x208; /* { dg-error "" "long signed unsigned" } */ +long unsigned void *x209; /* { dg-error "" "long unsigned void" } */ +long unsigned char *x210; /* { dg-error "" "long unsigned char" } */ +long unsigned short *x211; /* { dg-error "" "long unsigned short" } */ +long unsigned int *x212; +long unsigned long *x213; /* { dg-error "" "long unsigned long" } */ +long unsigned float *x214; /* { dg-error "" "long unsigned float" } */ +long unsigned double *x215; /* { dg-error "" "long unsigned double" } */ +long unsigned signed *x216; /* { dg-error "" "long unsigned signed" } */ +long unsigned unsigned *x217; /* { dg-error "" "long unsigned unsigned" } */ +double long void *x218; /* { dg-error "" "double long void" } */ +double long char *x219; /* { dg-error "" "double long char" } */ +double long short *x220; /* { dg-error "" "double long short" } */ +double long int *x221; /* { dg-error "" "double long int" } */ +double long long *x222; /* { dg-error "" "double long long" } */ +double long float *x223; /* { dg-error "" "double long float" } */ +double long double *x224; /* { dg-error "" "double long double" } */ +double long signed *x225; /* { dg-error "" "double long signed" } */ +double long unsigned *x226; /* { dg-error "" "double long unsigned" } */ +signed char void *x227; /* { dg-error "" "signed char void" } */ +signed char char *x228; /* { dg-error "" "signed char char" } */ +signed char short *x229; /* { dg-error "" "signed char short" } */ +signed char int *x230; /* { dg-error "" "signed char int" } */ +signed char long *x231; /* { dg-error "" "signed char long" } */ +signed char float *x232; /* { dg-error "" "signed char float" } */ +signed char double *x233; /* { dg-error "" "signed char double" } */ +signed char signed *x234; /* { dg-error "" "signed char signed" } */ +signed char unsigned *x235; /* { dg-error "" "signed char unsigned" } */ +signed short void *x236; /* { dg-error "" "signed short void" } */ +signed short char *x237; /* { dg-error "" "signed short char" } */ +signed short short *x238; /* { dg-error "" "signed short short" } */ +signed short int *x239; +signed short long *x240; /* { dg-error "" "signed short long" } */ +signed short float *x241; /* { dg-error "" "signed short float" } */ +signed short double *x242; /* { dg-error "" "signed short double" } */ +signed short signed *x243; /* { dg-error "" "signed short signed" } */ +signed short unsigned *x244; /* { dg-error "" "signed short unsigned" } */ +signed int void *x245; /* { dg-error "" "signed int void" } */ +signed int char *x246; /* { dg-error "" "signed int char" } */ +signed int short *x247; +signed int int *x248; /* { dg-error "" "signed int int" } */ +signed int long *x249; +signed int float *x250; /* { dg-error "" "signed int float" } */ +signed int double *x251; /* { dg-error "" "signed int double" } */ +signed int signed *x252; /* { dg-error "" "signed int signed" } */ +signed int unsigned *x253; /* { dg-error "" "signed int unsigned" } */ +signed long void *x254; /* { dg-error "" "signed long void" } */ +signed long char *x255; /* { dg-error "" "signed long char" } */ +signed long short *x256; /* { dg-error "" "signed long short" } */ +signed long int *x257; +signed long long *x258; /* { dg-error "" "signed long long" } */ +signed long float *x259; /* { dg-error "" "signed long float" } */ +signed long double *x260; /* { dg-error "" "signed long double" } */ +signed long signed *x261; /* { dg-error "" "signed long signed" } */ +signed long unsigned *x262; /* { dg-error "" "signed long unsigned" } */ +unsigned char void *x263; /* { dg-error "" "unsigned char void" } */ +unsigned char char *x264; /* { dg-error "" "unsigned char char" } */ +unsigned char short *x265; /* { dg-error "" "unsigned char short" } */ +unsigned char int *x266; /* { dg-error "" "unsigned char int" } */ +unsigned char long *x267; /* { dg-error "" "unsigned char long" } */ +unsigned char float *x268; /* { dg-error "" "unsigned char float" } */ +unsigned char double *x269; /* { dg-error "" "unsigned char double" } */ +unsigned char signed *x270; /* { dg-error "" "unsigned char signed" } */ +unsigned char unsigned *x271; /* { dg-error "" "unsigned char unsigned" } */ +unsigned short void *x272; /* { dg-error "" "unsigned short void" } */ +unsigned short char *x273; /* { dg-error "" "unsigned short char" } */ +unsigned short short *x274; /* { dg-error "" "unsigned short short" } */ +unsigned short int *x275; +unsigned short long *x276; /* { dg-error "" "unsigned short long" } */ +unsigned short float *x277; /* { dg-error "" "unsigned short float" } */ +unsigned short double *x278; /* { dg-error "" "unsigned short double" } */ +unsigned short signed *x279; /* { dg-error "" "unsigned short signed" } */ +unsigned short unsigned *x280; /* { dg-error "" "unsigned short unsigned" } */ +unsigned int void *x281; /* { dg-error "" "unsigned int void" } */ +unsigned int char *x282; /* { dg-error "" "unsigned int char" } */ +unsigned int short *x283; +unsigned int int *x284; /* { dg-error "" "unsigned int int" } */ +unsigned int long *x285; +unsigned int float *x286; /* { dg-error "" "unsigned int float" } */ +unsigned int double *x287; /* { dg-error "" "unsigned int double" } */ +unsigned int signed *x288; /* { dg-error "" "unsigned int signed" } */ +unsigned int unsigned *x289; /* { dg-error "" "unsigned int unsigned" } */ +unsigned long void *x290; /* { dg-error "" "unsigned long void" } */ +unsigned long char *x291; /* { dg-error "" "unsigned long char" } */ +unsigned long short *x292; /* { dg-error "" "unsigned long short" } */ +unsigned long int *x293; +unsigned long long *x294; /* { dg-error "" "unsigned long long" } */ +unsigned long float *x295; /* { dg-error "" "unsigned long float" } */ +unsigned long double *x296; /* { dg-error "" "unsigned long double" } */ +unsigned long signed *x297; /* { dg-error "" "unsigned long signed" } */ +unsigned long unsigned *x298; /* { dg-error "" "unsigned long unsigned" } */ +short int signed void *x299; /* { dg-error "" "short int signed void" } */ +short int signed char *x300; /* { dg-error "" "short int signed char" } */ +short int signed short *x301; /* { dg-error "" "short int signed short" } */ +short int signed int *x302; /* { dg-error "" "short int signed int" } */ +short int signed long *x303; /* { dg-error "" "short int signed long" } */ +short int signed float *x304; /* { dg-error "" "short int signed float" } */ +short int signed double *x305; /* { dg-error "" "short int signed double" } */ +short int signed signed *x306; /* { dg-error "" "short int signed signed" } */ +short int signed unsigned *x307; /* { dg-error "" "short int signed unsigned" } */ +short int unsigned void *x308; /* { dg-error "" "short int unsigned void" } */ +short int unsigned char *x309; /* { dg-error "" "short int unsigned char" } */ +short int unsigned short *x310; /* { dg-error "" "short int unsigned short" } */ +short int unsigned int *x311; /* { dg-error "" "short int unsigned int" } */ +short int unsigned long *x312; /* { dg-error "" "short int unsigned long" } */ +short int unsigned float *x313; /* { dg-error "" "short int unsigned float" } */ +short int unsigned double *x314; /* { dg-error "" "short int unsigned double" } */ +short int unsigned signed *x315; /* { dg-error "" "short int unsigned signed" } */ +short int unsigned unsigned *x316; /* { dg-error "" "short int unsigned unsigned" } */ +short signed int void *x317; /* { dg-error "" "short signed int void" } */ +short signed int char *x318; /* { dg-error "" "short signed int char" } */ +short signed int short *x319; /* { dg-error "" "short signed int short" } */ +short signed int int *x320; /* { dg-error "" "short signed int int" } */ +short signed int long *x321; /* { dg-error "" "short signed int long" } */ +short signed int float *x322; /* { dg-error "" "short signed int float" } */ +short signed int double *x323; /* { dg-error "" "short signed int double" } */ +short signed int signed *x324; /* { dg-error "" "short signed int signed" } */ +short signed int unsigned *x325; /* { dg-error "" "short signed int unsigned" } */ +short unsigned int void *x326; /* { dg-error "" "short unsigned int void" } */ +short unsigned int char *x327; /* { dg-error "" "short unsigned int char" } */ +short unsigned int short *x328; /* { dg-error "" "short unsigned int short" } */ +short unsigned int int *x329; /* { dg-error "" "short unsigned int int" } */ +short unsigned int long *x330; /* { dg-error "" "short unsigned int long" } */ +short unsigned int float *x331; /* { dg-error "" "short unsigned int float" } */ +short unsigned int double *x332; /* { dg-error "" "short unsigned int double" } */ +short unsigned int signed *x333; /* { dg-error "" "short unsigned int signed" } */ +short unsigned int unsigned *x334; /* { dg-error "" "short unsigned int unsigned" } */ +int short signed void *x335; /* { dg-error "" "int short signed void" } */ +int short signed char *x336; /* { dg-error "" "int short signed char" } */ +int short signed short *x337; /* { dg-error "" "int short signed short" } */ +int short signed int *x338; /* { dg-error "" "int short signed int" } */ +int short signed long *x339; /* { dg-error "" "int short signed long" } */ +int short signed float *x340; /* { dg-error "" "int short signed float" } */ +int short signed double *x341; /* { dg-error "" "int short signed double" } */ +int short signed signed *x342; /* { dg-error "" "int short signed signed" } */ +int short signed unsigned *x343; /* { dg-error "" "int short signed unsigned" } */ +int short unsigned void *x344; /* { dg-error "" "int short unsigned void" } */ +int short unsigned char *x345; /* { dg-error "" "int short unsigned char" } */ +int short unsigned short *x346; /* { dg-error "" "int short unsigned short" } */ +int short unsigned int *x347; /* { dg-error "" "int short unsigned int" } */ +int short unsigned long *x348; /* { dg-error "" "int short unsigned long" } */ +int short unsigned float *x349; /* { dg-error "" "int short unsigned float" } */ +int short unsigned double *x350; /* { dg-error "" "int short unsigned double" } */ +int short unsigned signed *x351; /* { dg-error "" "int short unsigned signed" } */ +int short unsigned unsigned *x352; /* { dg-error "" "int short unsigned unsigned" } */ +int long signed void *x353; /* { dg-error "" "int long signed void" } */ +int long signed char *x354; /* { dg-error "" "int long signed char" } */ +int long signed short *x355; /* { dg-error "" "int long signed short" } */ +int long signed int *x356; /* { dg-error "" "int long signed int" } */ +int long signed long *x357; /* { dg-error "" "int long signed long" } */ +int long signed float *x358; /* { dg-error "" "int long signed float" } */ +int long signed double *x359; /* { dg-error "" "int long signed double" } */ +int long signed signed *x360; /* { dg-error "" "int long signed signed" } */ +int long signed unsigned *x361; /* { dg-error "" "int long signed unsigned" } */ +int long unsigned void *x362; /* { dg-error "" "int long unsigned void" } */ +int long unsigned char *x363; /* { dg-error "" "int long unsigned char" } */ +int long unsigned short *x364; /* { dg-error "" "int long unsigned short" } */ +int long unsigned int *x365; /* { dg-error "" "int long unsigned int" } */ +int long unsigned long *x366; /* { dg-error "" "int long unsigned long" } */ +int long unsigned float *x367; /* { dg-error "" "int long unsigned float" } */ +int long unsigned double *x368; /* { dg-error "" "int long unsigned double" } */ +int long unsigned signed *x369; /* { dg-error "" "int long unsigned signed" } */ +int long unsigned unsigned *x370; /* { dg-error "" "int long unsigned unsigned" } */ +int signed short void *x371; /* { dg-error "" "int signed short void" } */ +int signed short char *x372; /* { dg-error "" "int signed short char" } */ +int signed short short *x373; /* { dg-error "" "int signed short short" } */ +int signed short int *x374; /* { dg-error "" "int signed short int" } */ +int signed short long *x375; /* { dg-error "" "int signed short long" } */ +int signed short float *x376; /* { dg-error "" "int signed short float" } */ +int signed short double *x377; /* { dg-error "" "int signed short double" } */ +int signed short signed *x378; /* { dg-error "" "int signed short signed" } */ +int signed short unsigned *x379; /* { dg-error "" "int signed short unsigned" } */ +int signed long void *x380; /* { dg-error "" "int signed long void" } */ +int signed long char *x381; /* { dg-error "" "int signed long char" } */ +int signed long short *x382; /* { dg-error "" "int signed long short" } */ +int signed long int *x383; /* { dg-error "" "int signed long int" } */ +int signed long long *x384; /* { dg-error "" "int signed long long" } */ +int signed long float *x385; /* { dg-error "" "int signed long float" } */ +int signed long double *x386; /* { dg-error "" "int signed long double" } */ +int signed long signed *x387; /* { dg-error "" "int signed long signed" } */ +int signed long unsigned *x388; /* { dg-error "" "int signed long unsigned" } */ +int unsigned short void *x389; /* { dg-error "" "int unsigned short void" } */ +int unsigned short char *x390; /* { dg-error "" "int unsigned short char" } */ +int unsigned short short *x391; /* { dg-error "" "int unsigned short short" } */ +int unsigned short int *x392; /* { dg-error "" "int unsigned short int" } */ +int unsigned short long *x393; /* { dg-error "" "int unsigned short long" } */ +int unsigned short float *x394; /* { dg-error "" "int unsigned short float" } */ +int unsigned short double *x395; /* { dg-error "" "int unsigned short double" } */ +int unsigned short signed *x396; /* { dg-error "" "int unsigned short signed" } */ +int unsigned short unsigned *x397; /* { dg-error "" "int unsigned short unsigned" } */ +int unsigned long void *x398; /* { dg-error "" "int unsigned long void" } */ +int unsigned long char *x399; /* { dg-error "" "int unsigned long char" } */ +int unsigned long short *x400; /* { dg-error "" "int unsigned long short" } */ +int unsigned long int *x401; /* { dg-error "" "int unsigned long int" } */ +int unsigned long long *x402; /* { dg-error "" "int unsigned long long" } */ +int unsigned long float *x403; /* { dg-error "" "int unsigned long float" } */ +int unsigned long double *x404; /* { dg-error "" "int unsigned long double" } */ +int unsigned long signed *x405; /* { dg-error "" "int unsigned long signed" } */ +int unsigned long unsigned *x406; /* { dg-error "" "int unsigned long unsigned" } */ +long int signed void *x407; /* { dg-error "" "long int signed void" } */ +long int signed char *x408; /* { dg-error "" "long int signed char" } */ +long int signed short *x409; /* { dg-error "" "long int signed short" } */ +long int signed int *x410; /* { dg-error "" "long int signed int" } */ +long int signed long *x411; /* { dg-error "" "long int signed long" } */ +long int signed float *x412; /* { dg-error "" "long int signed float" } */ +long int signed double *x413; /* { dg-error "" "long int signed double" } */ +long int signed signed *x414; /* { dg-error "" "long int signed signed" } */ +long int signed unsigned *x415; /* { dg-error "" "long int signed unsigned" } */ +long int unsigned void *x416; /* { dg-error "" "long int unsigned void" } */ +long int unsigned char *x417; /* { dg-error "" "long int unsigned char" } */ +long int unsigned short *x418; /* { dg-error "" "long int unsigned short" } */ +long int unsigned int *x419; /* { dg-error "" "long int unsigned int" } */ +long int unsigned long *x420; /* { dg-error "" "long int unsigned long" } */ +long int unsigned float *x421; /* { dg-error "" "long int unsigned float" } */ +long int unsigned double *x422; /* { dg-error "" "long int unsigned double" } */ +long int unsigned signed *x423; /* { dg-error "" "long int unsigned signed" } */ +long int unsigned unsigned *x424; /* { dg-error "" "long int unsigned unsigned" } */ +long signed int void *x425; /* { dg-error "" "long signed int void" } */ +long signed int char *x426; /* { dg-error "" "long signed int char" } */ +long signed int short *x427; /* { dg-error "" "long signed int short" } */ +long signed int int *x428; /* { dg-error "" "long signed int int" } */ +long signed int long *x429; /* { dg-error "" "long signed int long" } */ +long signed int float *x430; /* { dg-error "" "long signed int float" } */ +long signed int double *x431; /* { dg-error "" "long signed int double" } */ +long signed int signed *x432; /* { dg-error "" "long signed int signed" } */ +long signed int unsigned *x433; /* { dg-error "" "long signed int unsigned" } */ +long unsigned int void *x434; /* { dg-error "" "long unsigned int void" } */ +long unsigned int char *x435; /* { dg-error "" "long unsigned int char" } */ +long unsigned int short *x436; /* { dg-error "" "long unsigned int short" } */ +long unsigned int int *x437; /* { dg-error "" "long unsigned int int" } */ +long unsigned int long *x438; /* { dg-error "" "long unsigned int long" } */ +long unsigned int float *x439; /* { dg-error "" "long unsigned int float" } */ +long unsigned int double *x440; /* { dg-error "" "long unsigned int double" } */ +long unsigned int signed *x441; /* { dg-error "" "long unsigned int signed" } */ +long unsigned int unsigned *x442; /* { dg-error "" "long unsigned int unsigned" } */ +signed short int void *x443; /* { dg-error "" "signed short int void" } */ +signed short int char *x444; /* { dg-error "" "signed short int char" } */ +signed short int short *x445; /* { dg-error "" "signed short int short" } */ +signed short int int *x446; /* { dg-error "" "signed short int int" } */ +signed short int long *x447; /* { dg-error "" "signed short int long" } */ +signed short int float *x448; /* { dg-error "" "signed short int float" } */ +signed short int double *x449; /* { dg-error "" "signed short int double" } */ +signed short int signed *x450; /* { dg-error "" "signed short int signed" } */ +signed short int unsigned *x451; /* { dg-error "" "signed short int unsigned" } */ +signed int short void *x452; /* { dg-error "" "signed int short void" } */ +signed int short char *x453; /* { dg-error "" "signed int short char" } */ +signed int short short *x454; /* { dg-error "" "signed int short short" } */ +signed int short int *x455; /* { dg-error "" "signed int short int" } */ +signed int short long *x456; /* { dg-error "" "signed int short long" } */ +signed int short float *x457; /* { dg-error "" "signed int short float" } */ +signed int short double *x458; /* { dg-error "" "signed int short double" } */ +signed int short signed *x459; /* { dg-error "" "signed int short signed" } */ +signed int short unsigned *x460; /* { dg-error "" "signed int short unsigned" } */ +signed int long void *x461; /* { dg-error "" "signed int long void" } */ +signed int long char *x462; /* { dg-error "" "signed int long char" } */ +signed int long short *x463; /* { dg-error "" "signed int long short" } */ +signed int long int *x464; /* { dg-error "" "signed int long int" } */ +signed int long long *x465; /* { dg-error "" "signed int long long" } */ +signed int long float *x466; /* { dg-error "" "signed int long float" } */ +signed int long double *x467; /* { dg-error "" "signed int long double" } */ +signed int long signed *x468; /* { dg-error "" "signed int long signed" } */ +signed int long unsigned *x469; /* { dg-error "" "signed int long unsigned" } */ +signed long int void *x470; /* { dg-error "" "signed long int void" } */ +signed long int char *x471; /* { dg-error "" "signed long int char" } */ +signed long int short *x472; /* { dg-error "" "signed long int short" } */ +signed long int int *x473; /* { dg-error "" "signed long int int" } */ +signed long int long *x474; /* { dg-error "" "signed long int long" } */ +signed long int float *x475; /* { dg-error "" "signed long int float" } */ +signed long int double *x476; /* { dg-error "" "signed long int double" } */ +signed long int signed *x477; /* { dg-error "" "signed long int signed" } */ +signed long int unsigned *x478; /* { dg-error "" "signed long int unsigned" } */ +unsigned short int void *x479; /* { dg-error "" "unsigned short int void" } */ +unsigned short int char *x480; /* { dg-error "" "unsigned short int char" } */ +unsigned short int short *x481; /* { dg-error "" "unsigned short int short" } */ +unsigned short int int *x482; /* { dg-error "" "unsigned short int int" } */ +unsigned short int long *x483; /* { dg-error "" "unsigned short int long" } */ +unsigned short int float *x484; /* { dg-error "" "unsigned short int float" } */ +unsigned short int double *x485; /* { dg-error "" "unsigned short int double" } */ +unsigned short int signed *x486; /* { dg-error "" "unsigned short int signed" } */ +unsigned short int unsigned *x487; /* { dg-error "" "unsigned short int unsigned" } */ +unsigned int short void *x488; /* { dg-error "" "unsigned int short void" } */ +unsigned int short char *x489; /* { dg-error "" "unsigned int short char" } */ +unsigned int short short *x490; /* { dg-error "" "unsigned int short short" } */ +unsigned int short int *x491; /* { dg-error "" "unsigned int short int" } */ +unsigned int short long *x492; /* { dg-error "" "unsigned int short long" } */ +unsigned int short float *x493; /* { dg-error "" "unsigned int short float" } */ +unsigned int short double *x494; /* { dg-error "" "unsigned int short double" } */ +unsigned int short signed *x495; /* { dg-error "" "unsigned int short signed" } */ +unsigned int short unsigned *x496; /* { dg-error "" "unsigned int short unsigned" } */ +unsigned int long void *x497; /* { dg-error "" "unsigned int long void" } */ +unsigned int long char *x498; /* { dg-error "" "unsigned int long char" } */ +unsigned int long short *x499; /* { dg-error "" "unsigned int long short" } */ +unsigned int long int *x500; /* { dg-error "" "unsigned int long int" } */ +unsigned int long long *x501; /* { dg-error "" "unsigned int long long" } */ +unsigned int long float *x502; /* { dg-error "" "unsigned int long float" } */ +unsigned int long double *x503; /* { dg-error "" "unsigned int long double" } */ +unsigned int long signed *x504; /* { dg-error "" "unsigned int long signed" } */ +unsigned int long unsigned *x505; /* { dg-error "" "unsigned int long unsigned" } */ +unsigned long int void *x506; /* { dg-error "" "unsigned long int void" } */ +unsigned long int char *x507; /* { dg-error "" "unsigned long int char" } */ +unsigned long int short *x508; /* { dg-error "" "unsigned long int short" } */ +unsigned long int int *x509; /* { dg-error "" "unsigned long int int" } */ +unsigned long int long *x510; /* { dg-error "" "unsigned long int long" } */ +unsigned long int float *x511; /* { dg-error "" "unsigned long int float" } */ +unsigned long int double *x512; /* { dg-error "" "unsigned long int double" } */ +unsigned long int signed *x513; /* { dg-error "" "unsigned long int signed" } */ +unsigned long int unsigned *x514; /* { dg-error "" "unsigned long int unsigned" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c90-vla-1.c b/SingleSource/Regression/C/gcc-dg/c90-vla-1.c new file mode 100644 index 0000000000..2d9b5f10bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c90-vla-1.c @@ -0,0 +1,12 @@ +/* Origin: PR 3467 */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +void +tdef (int n) +{ + typedef int A[n]; /* { dg-error "forbids variable length array" } */ + A a; + A *p; + p = &a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c94-digraph-1.c b/SingleSource/Regression/C/gcc-dg/c94-digraph-1.c new file mode 100644 index 0000000000..55d77146be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c94-digraph-1.c @@ -0,0 +1,24 @@ +/* Test for recognition of digraphs: should be recognized in C94 and C99 + mode, but not in C90 mode. Also check correct stringizing. +*/ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:199409 -pedantic-errors" } */ + +#define str(x) xstr(x) +#define xstr(x) #x +#define foo(p, q) str(p %:%: q) + +extern void abort (void); +extern int strcmp (const char *, const char *); + +int +main (void) +{ + const char *t = foo (1, 2); + const char *u = str (<:); + if (strcmp (t, "12") || strcmp (u, "<:")) + abort (); + else + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c94-version-1.c b/SingleSource/Regression/C/gcc-dg/c94-version-1.c new file mode 100644 index 0000000000..7437dda905 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c94-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C94. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:199409 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 199409L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c99-align-1.c b/SingleSource/Regression/C/gcc-dg/c99-align-1.c new file mode 100644 index 0000000000..1fb2cb0711 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-align-1.c @@ -0,0 +1,6 @@ +/* Test _Alignof and _Alignas not in C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +int a = _Alignof (int); /* { dg-error "ISO C99 does not support '_Alignof'" } */ +_Alignas (int) int b; /* { dg-error "ISO C99 does not support '_Alignas'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-anon-struct-1.c b/SingleSource/Regression/C/gcc-dg/c99-anon-struct-1.c new file mode 100644 index 0000000000..87d4c3438e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-anon-struct-1.c @@ -0,0 +1,12 @@ +/* Test for anonymous structures and unions not permitted in C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s +{ + int a; + struct + { + int b; + }; /* { dg-error "unnamed structs" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-lval-1.c b/SingleSource/Regression/C/gcc-dg/c99-array-lval-1.c new file mode 100644 index 0000000000..c0fccc813a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-lval-1.c @@ -0,0 +1,17 @@ +/* Test for non-lvalue arrays decaying to pointers: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { char c[1]; }; + +extern struct s foo (void); + +void +bar (void) +{ + char *t; + (foo ()).c[0]; /* { dg-bogus "non-lvalue" "array not decaying to lvalue" } */ + t = (foo ()).c; /* { dg-bogus "non-lvalue" "array not decaying to lvalue" } */ + (foo ()).c + 1; /* { dg-bogus "non-lvalue" "array not decaying to lvalue" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-lval-2.c b/SingleSource/Regression/C/gcc-dg/c99-array-lval-2.c new file mode 100644 index 0000000000..894ff957a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-lval-2.c @@ -0,0 +1,18 @@ +/* Test for non-lvalue arrays decaying to pointers: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { char c[17]; }; + +struct s x; + +extern struct s foo (void); + +#define ASSERT(v, a) char v[((a) ? 1 : -1)] + +ASSERT (p, sizeof (x.c) == 17); +ASSERT (q, sizeof (0, x.c) == sizeof (char *)); +ASSERT (r, sizeof ((foo ()).c) == 17); +/* The non-lvalue array decays to a pointer in C99. */ +ASSERT (s, sizeof (0, (foo ()).c) == sizeof (char *)); /* { dg-bogus "array" "bad non-lvalue array handling" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-lval-3.c b/SingleSource/Regression/C/gcc-dg/c99-array-lval-3.c new file mode 100644 index 0000000000..a12a9600bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-lval-3.c @@ -0,0 +1,24 @@ +/* Test for non-lvalue arrays decaying to pointers: in C99 only. + Test various ways of producing non-lvalue arrays. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { char c[1]; }; +struct s a, b, c; +int d; + +void +bar (void) +{ + char *t; + (d ? b : c).c[0]; + (d, b).c[0]; + (a = b).c[0]; + t = (d ? b : c).c; + t = (d, b).c; + t = (a = b).c; + (d ? b : c).c + 1; + (d, b).c + 1; + (a = b).c + 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-lval-4.c b/SingleSource/Regression/C/gcc-dg/c99-array-lval-4.c new file mode 100644 index 0000000000..259ce92145 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-lval-4.c @@ -0,0 +1,24 @@ +/* Test for non-lvalue arrays decaying to pointers: in C99 only. + Test various ways of producing non-lvalue arrays. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { char c[17]; }; + +struct s x; + +struct s a, b, c; +int d; + +#define ASSERT(v, a) char v[((a) ? 1 : -1)] + +ASSERT (p, sizeof (x.c) == 17); +ASSERT (q, sizeof (0, x.c) == sizeof (char *)); +ASSERT (r0, sizeof ((d ? b : c).c) == 17); +ASSERT (r1, sizeof ((d, b).c) == 17); +ASSERT (r2, sizeof ((a = b).c) == 17); +/* The non-lvalue array decays to a pointer in C99. */ +ASSERT (s0, sizeof (0, (d ? b : c).c) == sizeof (char *)); /* { dg-bogus "array" "bad non-lvalue array handling" } */ +ASSERT (s0, sizeof (0, (d, b).c) == sizeof (char *)); /* { dg-bogus "array" "bad non-lvalue array handling" } */ +ASSERT (s0, sizeof (0, (a = b).c) == sizeof (char *)); /* { dg-bogus "array" "bad non-lvalue array handling" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-lval-5.c b/SingleSource/Regression/C/gcc-dg/c99-array-lval-5.c new file mode 100644 index 0000000000..57e806d97d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-lval-5.c @@ -0,0 +1,26 @@ +/* Test for non-lvalue arrays: test that the unary '&' operator is not + allowed on them, for both C90 and C99. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { char c[1]; }; + +extern struct s foo (void); +struct s a, b, c; +int d; + +void +bar (void) +{ + &((foo ()).c); /* { dg-bogus "warning" "warning in place of error" } */ + &((d ? b : c).c); /* { dg-bogus "warning" "warning in place of error" } */ + &((d, b).c); /* { dg-bogus "warning" "warning in place of error" } */ + &((a = b).c); /* { dg-bogus "warning" "warning in place of error" } */ +} +/* { dg-error "lvalue" "bad address-of" { target *-*-* } 17 } + { dg-error "lvalue" "bad address-of" { target *-*-* } 18 } + { dg-error "lvalue" "bad address-of" { target *-*-* } 19 } + { dg-error "lvalue" "bad address-of" { target *-*-* } 20 } +*/ diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-lval-6.c b/SingleSource/Regression/C/gcc-dg/c99-array-lval-6.c new file mode 100644 index 0000000000..426b3c75c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-lval-6.c @@ -0,0 +1,15 @@ +/* PR c/12446 */ +/* Origin: Keith Thompson */ + +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + + +struct s { char c[1]; }; + +extern struct s foo(void); + +void bar(void) +{ + char *ptr = foo().c; /* { dg-bogus "non-lvalue" "array not decaying to lvalue" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-lval-7.c b/SingleSource/Regression/C/gcc-dg/c99-array-lval-7.c new file mode 100644 index 0000000000..3d70ed07b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-lval-7.c @@ -0,0 +1,21 @@ +/* Test for non-lvalue arrays: test that C90 does not allow them in + conditional expressions, while in C99 they decay and are + allowed. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { char c[1]; }; +struct s a, b, c; +int d; +int e; + +void +bar (void) +{ + /* In C90, the non-lvalue arrays do not decay to pointers, and + 6.3.15 does not permit conditional expressions between arrays. + In C99, they decay to pointers. */ + (e ? (d ? b : c).c : (e ? b : c).c); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-lval-8.c b/SingleSource/Regression/C/gcc-dg/c99-array-lval-8.c new file mode 100644 index 0000000000..c4e202ef30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-lval-8.c @@ -0,0 +1,30 @@ +/* Test for non-lvalue arrays: test that qualifiers on non-lvalues + containing arrays do not remain when those arrays decay to + pointers. PR 35235. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +int a; + +void +f (void) +{ + const struct { + int a[1]; + } s; + int *p1 = s.a; /* { dg-error "qualifier" } */ + int *p2 = (a ? s : s).a; + /* In this case, the qualifier is properly on the array element type + not on the rvalue structure and so is not discarded. */ + struct { + const int a[1]; + } t; + int *p3 = t.a; /* { dg-error "qualifier" } */ + int *p4 = (a ? t : t).a; /* { dg-error "qualifier" } */ + /* The issue could also lead to code being wrongly accepted. */ + const struct { + int a[1][1]; + } u; + const int (*p5)[1] = u.a; + const int (*p6)[1] = (a ? u : u).a; /* { dg-error "pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-array-nonobj-1.c b/SingleSource/Regression/C/gcc-dg/c99-array-nonobj-1.c new file mode 100644 index 0000000000..d4566b7010 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-array-nonobj-1.c @@ -0,0 +1,27 @@ +/* Test for arrays of incomplete and function types: a constraint violation + in C99 only, though undefined (DR#047) before. +*/ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef void func (void); +struct s; + +extern int a[][]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "array" "\[\]\[\] var" { target *-*-* } .-1 } */ + +void f (int [][]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "array" "\[\]\[\] arg" { target *-*-* } .-1 } */ + +extern struct s b[]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "array" "struct \[\] var" { target *-*-* } .-1 } */ + +void g (struct s []); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "array" "struct \[\] arg" { target *-*-* } .-1 } */ + +extern func c[]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "array" "func \[\] var" { target *-*-* } .-1 } */ + +void h (func []); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "array" "func \[\] arg" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-arraydecl-1.c b/SingleSource/Regression/C/gcc-dg/c99-arraydecl-1.c new file mode 100644 index 0000000000..05bda39885 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-arraydecl-1.c @@ -0,0 +1,111 @@ +/* Test for C99 forms of array declarator. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* Because GCC doesn't yet implement it, we don't yet test for [*] here. */ + +/* Test each of: [quals], [quals expr], [static expr], [static quals expr], + [quals static expr]. Not yet: [quals *]. */ + +void f00 (int a[const]); +void f01 (int [const]); + +void +f02 (int a[const]) +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } .-1 } */ + int *const *c = &a; +} +void +f03 (a) + int a[const]; +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } .-1 } */ + int *const *c = &a; +} + +void f10 (int a[const 2]); +void f11 (int [const 2]); + +void +f12 (int a[const 2]) +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } .-1 } */ + int *const *c = &a; +} +void +f13 (a) + int a[const 2]; +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } .-1 } */ + int *const *c = &a; +} + +void f20 (int a[static 2]); +void f21 (int [static 2]); + +void +f22 (int a[static 2]) +{ + int **b = &a; + int *const *c = &a; +} +void +f23 (a) + int a[static 2]; +{ + int **b = &a; + int *const *c = &a; +} + +void f30 (int a[static const 2]); +void f31 (int [static const 2]); + +void +f32 (int a[static const 2]) +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } .-1 } */ + int *const *c = &a; +} +void +f33 (a) + int a[static const 2]; +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } .-1 } */ + int *const *c = &a; +} + +void f40 (int a[const static 2]); +void f41 (int [const static 2]); + +void +f42 (int a[const static 2]) +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } .-1 } */ + int *const *c = &a; +} +void +f43 (a) + int a[const static 2]; +{ + int **b = &a; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "discards" "discards quals" { target *-*-* } .-1 } */ + int *const *c = &a; +} + +/* Test rejection of static and type qualifiers in non-parameter contexts. */ +int x[const 2]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "non-parameter" "quals in non-parm array" { target *-*-* } .-1 } */ +int y[static 2]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "non-parameter" "static in non-parm array" { target *-*-* } .-1 } */ +void g (int a[static 2][3]); +void h (int a[2][static 3]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "non-parameter" "static in non-final parm array" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-arraydecl-2.c b/SingleSource/Regression/C/gcc-dg/c99-arraydecl-2.c new file mode 100644 index 0000000000..22d6e97be4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-arraydecl-2.c @@ -0,0 +1,16 @@ +/* Test for C99 array declarators: expression must be an + assignment-expression. PR 11943. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +foo (void) +{ + int a[2, 3]; /* { dg-error "parse|syntax|expected" "bad array declarator" } */ + void b(int x[2, 3]); /* { dg-error "parse|syntax|expected" "bad array declarator" } */ + void c(int [2, 3]); /* { dg-error "parse|syntax|expected" "bad array declarator" } */ + void d(int *x[restrict 2, 3]); /* { dg-error "parse|syntax|expected" "bad array declarator" } */ + void e(int *x[static restrict 2, 3]); /* { dg-error "parse|syntax|expected" "bad array declarator" } */ + void f(int *x[restrict static 2, 3]); /* { dg-error "parse|syntax|expected" "bad array declarator" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-arraydecl-3.c b/SingleSource/Regression/C/gcc-dg/c99-arraydecl-3.c new file mode 100644 index 0000000000..9f383b9c3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-arraydecl-3.c @@ -0,0 +1,20 @@ +/* Test for C99 forms of array declarator. Test restrict qualifiers + properly applied to type of parameter. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +f0 (int a[restrict]) +{ + int **b = &a; /* { dg-error "discards 'restrict' qualifier" } */ + int *restrict *c = &a; +} + +void +f1 (a) + int a[restrict]; +{ + int **b = &a; /* { dg-error "discards 'restrict' qualifier" } */ + int *restrict *c = &a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-atomic-1.c b/SingleSource/Regression/C/gcc-dg/c99-atomic-1.c new file mode 100644 index 0000000000..3a13f77712 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-atomic-1.c @@ -0,0 +1,8 @@ +/* Test for _Atomic: not in C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +_Atomic int i; /* { dg-error "_Atomic" } */ +_Atomic (int) j; /* { dg-error "_Atomic" } */ +int *_Atomic p; /* { dg-error "_Atomic" } */ +void f (int a[_Atomic]); /* { dg-error "_Atomic" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-bool-1.c b/SingleSource/Regression/C/gcc-dg/c99-bool-1.c new file mode 100644 index 0000000000..7ec99a76bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-bool-1.c @@ -0,0 +1,248 @@ +/* Test for _Bool and in C99. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* _Bool must be a builtin type. */ + +_Bool foo; + +#include + +/* Three macros must be integer constant expressions suitable for use + in #if. +*/ + +#if !defined(true) || (true != 1) +#error "bad stdbool true" /* { dg-bogus "#error" "bad stdbool.h" } */ +#endif + +#if !defined(false) || (false != 0) +#error "bad stdbool false" /* { dg-bogus "#error" "bad stdbool.h" } */ +#endif + +#if !defined(__bool_true_false_are_defined) || (__bool_true_false_are_defined != 1) +#error "bad stdbool __bool_true_false_are_defined" /* { dg-bogus "#error" "bad stdbool.h" } */ +#endif + +int a = true; +int b = false; +int c = __bool_true_false_are_defined; + +struct foo +{ + _Bool a : 1; +} sf; + +#define str(x) xstr(x) +#define xstr(x) #x + + +extern void abort (void); +extern void exit (int); +extern int strcmp (const char *, const char *); + +int +main (void) +{ + /* The macro `bool' must expand to _Bool. */ + const char *t = str (bool); + _Bool u, v; + if (strcmp (t, "_Bool")) + abort (); + if (a != 1 || b != 0 || c != 1) + abort (); + /* Casts to _Bool have a specified behavior. */ + if ((int)(_Bool)2 != 1) + abort (); + if ((int)(_Bool)0.2 != 1) + abort (); + /* Pointers may be assigned to _Bool. */ + if ((u = t) != 1) + abort (); + /* _Bool may be used to subscript arrays. */ + u = 0; + if (t[u] != '_') + abort (); + if (u[t] != '_') + abort (); + u = 1; + if (t[u] != 'B') + abort (); + if (u[t] != 'B') + abort (); + /* Test increment and decrement operators. */ + u = 0; + if (u++ != 0) + abort (); + if (u != 1) + abort (); + if (u++ != 1) + abort (); + if (u != 1) + abort (); + u = 0; + if (++u != 1) + abort (); + if (u != 1) + abort (); + if (++u != 1) + abort (); + if (u != 1) + abort (); + u = 0; + if (u-- != 0) + abort (); + if (u != 1) + abort (); + if (u-- != 1) + abort (); + if (u != 0) + abort (); + u = 0; + if (--u != 1) + abort (); + if (u != 1) + abort (); + if (--u != 0) + abort (); + if (u != 0) + abort (); + /* Test unary + - ~ !. */ + u = 0; + if (+u != 0) + abort (); + if (-u != 0) + abort (); + u = 1; + if (+u != 1) + abort (); + if (-u != -1) + abort (); + u = 2; + if (+u != 1) + abort (); + if (-u != -1) + abort (); + u = 0; + if (~u != ~(int)0) + abort (); + u = 1; + if (~u != ~(int)1) + abort (); + u = 0; + if (!u != 1) + abort (); + u = 1; + if (!u != 0) + abort (); + /* Test arithmetic * / % + - (which all apply promotions). */ + u = 0; + if (u + 2 != 2) + abort (); + u = 1; + if (u * 4 != 4) + abort (); + if (u % 3 != 1) + abort (); + if (u / 1 != 1) + abort (); + if (4 / u != 4) + abort (); + if (u - 7 != -6) + abort (); + /* Test bitwise shift << >>. */ + u = 1; + if (u << 1 != 2) + abort (); + if (u >> 1 != 0) + abort (); + /* Test relational and equality operators < > <= >= == !=. */ + u = 0; + v = 0; + if (u < v || u > v || !(u <= v) || !(u >= v) || !(u == v) || u != v) + abort (); + u = 0; + v = 1; + if (!(u < v) || u > v || !(u <= v) || u >= v || u == v || !(u != v)) + abort (); + /* Test bitwise operators & ^ |. */ + u = 1; + if ((u | 2) != 3) + abort (); + if ((u ^ 3) != 2) + abort (); + if ((u & 1) != 1) + abort (); + if ((u & 0) != 0) + abort (); + /* Test logical && ||. */ + u = 0; + v = 1; + if (!(u || v)) + abort (); + if (!(v || u)) + abort (); + if (u && v) + abort (); + if (v && u) + abort (); + u = 1; + v = 1; + if (!(u && v)) + abort (); + /* Test conditional ? :. */ + u = 0; + if ((u ? 4 : 7) != 7) + abort (); + u = 1; + v = 0; + if ((1 ? u : v) != 1) + abort (); + if ((1 ? 4 : u) != 4) + abort (); + /* Test assignment operators = *= /= %= += -= <<= >>= &= ^= |=. */ + if ((u = 2) != 1) + abort (); + if (u != 1) + abort (); + if ((u *= -1) != 1) + abort (); + if (u != 1) + abort (); + if ((u /= 2) != 0) + abort (); + if ((u += 3) != 1) + abort (); + if ((u -= 1) != 0) + abort (); + u = 1; + if ((u <<= 4) != 1) + abort (); + if ((u >>= 1) != 0) + abort (); + u = 1; + if ((u &= 0) != 0) + abort (); + if ((u |= 2) != 1) + abort (); + if ((u ^= 3) != 1) + abort (); + /* Test comma expressions. */ + u = 1; + if ((4, u) != 1) + abort (); + /* Test bitfields. */ + { + int i; + for (i = 0; i < sizeof (struct foo); i++) + *((unsigned char *)&sf + i) = (unsigned char) -1; + sf.a = 1; + if (sf.a != 1) + abort (); + sf.a = 0; + if (sf.a != 0) + abort (); + } + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-bool-2.c b/SingleSource/Regression/C/gcc-dg/c99-bool-2.c new file mode 100644 index 0000000000..5a577a428d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-bool-2.c @@ -0,0 +1,14 @@ +/* Test for _Bool bit-fields. After TC2, the width of a _Bool + bit-field must not extend the width (number of sign and value bits) + of _Bool, which is implementation-defined but is 1 unless the + implementation defines representations for values greater than 1 in + type _Bool and allows for _Bool objects to have such types, which + GCC does not. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct foo +{ + _Bool b : 2; /* { dg-error "width" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/c99-bool-3.c b/SingleSource/Regression/C/gcc-dg/c99-bool-3.c new file mode 100644 index 0000000000..f93547ac01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-bool-3.c @@ -0,0 +1,33 @@ +/* Test for _Bool bit-fields. They have the semantics of _Bool, at + least for now (DR#335 Spring 2007 discussion). */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ +struct foo +{ + _Bool a : 1; +} sf; + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int i; + for (i = 0; i < sizeof (struct foo); i++) + *((unsigned char *)&sf + i) = (unsigned char) -1; + sf.a = 2; + if (sf.a != 1) + abort (); + sf.a = 0; + if (sf.a != 0) + abort (); + sf.a = 0.2; + if (sf.a != 1) + abort (); + sf.a = &sf; + if (sf.a != 1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-bool-4.c b/SingleSource/Regression/C/gcc-dg/c99-bool-4.c new file mode 100644 index 0000000000..5cae18ad0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-bool-4.c @@ -0,0 +1,46 @@ +/* Test macro expansions in in C99. */ +/* { dg-do run } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +#include + +#define str(x) xstr(x) +#define xstr(x) #x + +extern void abort (void); +extern void exit (int); +extern int strcmp (const char *, const char *); + +#if false - 1 >= 0 +#error "false unsigned in #if" +#endif + +#if false != 0 +#error "false not 0 in #if" +#endif + +#if true - 2 >= 0 +#error "true unsigned in #if" +#endif + +#if true != 1 +#error "true not 1 in #if" +#endif + +int +main (void) +{ + if (strcmp (str (bool), "_Bool") != 0) + abort (); + if (true != 1) + abort (); + if (strcmp (str (true), "1") != 0) + abort (); + if (false != 0) + abort (); + if (strcmp (str (false), "0") != 0) + abort (); + if (strcmp (str (__bool_true_false_are_defined), "1") != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-compare-incomplete-1.c b/SingleSource/Regression/C/gcc-dg/c99-compare-incomplete-1.c new file mode 100644 index 0000000000..dfafc39145 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-compare-incomplete-1.c @@ -0,0 +1,52 @@ +/* Test comparisons of pointers to complete and incomplete types are + diagnosed in C99 mode: -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic" } */ + +int +f (int (*p)[], int (*q)[3]) +{ + return p < q; /* { dg-warning "complete and incomplete" } */ +} + +int +f2 (int (*p)[], int (*q)[3]) +{ + return p <= q; /* { dg-warning "complete and incomplete" } */ +} + +int +f3 (int (*p)[], int (*q)[3]) +{ + return p > q; /* { dg-warning "complete and incomplete" } */ +} + +int +f4 (int (*p)[], int (*q)[3]) +{ + return p >= q; /* { dg-warning "complete and incomplete" } */ +} + +int +g (int (*p)[], int (*q)[3]) +{ + return q < p; /* { dg-warning "complete and incomplete" } */ +} + +int +g2 (int (*p)[], int (*q)[3]) +{ + return q <= p; /* { dg-warning "complete and incomplete" } */ +} + +int +g3 (int (*p)[], int (*q)[3]) +{ + return q > p; /* { dg-warning "complete and incomplete" } */ +} + +int +g4 (int (*p)[], int (*q)[3]) +{ + return q >= p; /* { dg-warning "complete and incomplete" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-compare-incomplete-2.c b/SingleSource/Regression/C/gcc-dg/c99-compare-incomplete-2.c new file mode 100644 index 0000000000..5ae7f303e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-compare-incomplete-2.c @@ -0,0 +1,52 @@ +/* Test comparisons of pointers to complete and incomplete types are + diagnosed in C99 mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +int +f (int (*p)[], int (*q)[3]) +{ + return p < q; /* { dg-error "complete and incomplete" } */ +} + +int +f2 (int (*p)[], int (*q)[3]) +{ + return p <= q; /* { dg-error "complete and incomplete" } */ +} + +int +f3 (int (*p)[], int (*q)[3]) +{ + return p > q; /* { dg-error "complete and incomplete" } */ +} + +int +f4 (int (*p)[], int (*q)[3]) +{ + return p >= q; /* { dg-error "complete and incomplete" } */ +} + +int +g (int (*p)[], int (*q)[3]) +{ + return q < p; /* { dg-error "complete and incomplete" } */ +} + +int +g2 (int (*p)[], int (*q)[3]) +{ + return q <= p; /* { dg-error "complete and incomplete" } */ +} + +int +g3 (int (*p)[], int (*q)[3]) +{ + return q > p; /* { dg-error "complete and incomplete" } */ +} + +int +g4 (int (*p)[], int (*q)[3]) +{ + return q >= p; /* { dg-error "complete and incomplete" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-complex-1.c b/SingleSource/Regression/C/gcc-dg/c99-complex-1.c new file mode 100644 index 0000000000..f41eba5beb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-complex-1.c @@ -0,0 +1,33 @@ +/* Test for _Complex: in C99 only. A few basic tests. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* Test _Complex allowed on floating types. */ + +float _Complex a; +_Complex float b; +double _Complex c; +_Complex double d; +long double _Complex e; +_Complex long double f; + +/* Plain `_Complex' for complex double is a GNU extension. */ +_Complex g; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "plain" "plain _Complex" { target *-*-* } .-1 } */ + +/* Complex integer types are GNU extensions. */ +_Complex int h; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "complex integer" "_Complex int" { target *-*-* } .-1 } */ +_Complex long i; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "complex integer" "_Complex long" { target *-*-* } .-1 } */ + +/* Use of ~ for complex conjugation is a GNU extension, but a constraint + violation (6.5.3.3p1) in C99. +*/ +_Complex double +foo (_Complex double z) +{ + return ~z; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "complex conj" "~ for conjugation" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-complex-2.c b/SingleSource/Regression/C/gcc-dg/c99-complex-2.c new file mode 100644 index 0000000000..fa68a96840 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-complex-2.c @@ -0,0 +1,22 @@ +/* Test for _Complex: in C99 only. Test for increment and decrement. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* Use of ++ and -- on complex types (both prefix and postfix) is a + C99 constraint violation (6.5.2.4p1, 6.5.3.1p1). +*/ + +_Complex double +foo (_Complex double z) +{ + z++; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "complex" "postinc" { target *-*-* } .-1 } */ + ++z; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "complex" "preinc" { target *-*-* } .-1 } */ + z--; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "complex" "postdec" { target *-*-* } .-1 } */ + --z; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "complex" "predec" { target *-*-* } .-1 } */ + return z; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-complex-3.c b/SingleSource/Regression/C/gcc-dg/c99-complex-3.c new file mode 100644 index 0000000000..f1f7a1f874 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-complex-3.c @@ -0,0 +1,7 @@ +/* Test for _Imaginary: when imaginary types are not implemented, this + is still a keyword and must give a syntax error if used rather than + being treated as an identifier. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +float _Imaginary; /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-complit-1.c b/SingleSource/Regression/C/gcc-dg/c99-complit-1.c new file mode 100644 index 0000000000..94e15db6d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-complit-1.c @@ -0,0 +1,112 @@ +/* Test for compound literals: in C99 only. Test for valid uses. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +struct s { int a; int b; }; +union u { int c; int d; }; + +int *i0a = &(int) { 0 }; +int *i0b = &(int) { 0 }; +int *i1a = &(int) { 1 }; +int *i1b = &(int) { 1 }; +const int *i0c = &(const int) { 0 }; + +struct s *s0 = &(struct s) { 1, 2 }; +struct s *s1 = &(struct s) { 1, 2 }; +const struct s *s2 = &(const struct s) { 1, 2 }; + +union u *u0 = &(union u) { 3 }; +union u *u1 = &(union u) { 3 }; +const union u *u2 = &(const union u) { 3 }; + +int *a0 = (int []) { 1, 2, 3 }; +const int *a1 = (const int []) { 1, 2, 3 }; + +char *p = (char []){ "foo" }; + +int +main (void) +{ + if (i0a == i0b || i0a == i0c || i0b == i0c) + abort (); + if (i1a == i1b) + abort (); + if (*i0a != 0 || *i0b != 0 || *i1a != 1 || *i1b != 1 || *i0c != 0) + abort (); + *i0a = 1; + *i1a = 0; + if (*i0a != 1 || *i0b != 0 || *i1a != 0 || *i1b != 1 || *i0c != 0) + abort (); + if (s0 == s1 || s1 == s2 || s2 == s0) + abort (); + if (s0->a != 1 || s0->b != 2 || s1->a != 1 || s1->b != 2 + || s2->a != 1 || s2->b != 2) + abort (); + s0->a = 2; + s1->b = 1; + if (s0->a != 2 || s0->b != 2 || s1->a != 1 || s1->b != 1 + || s2->a != 1 || s2->b != 2) + abort (); + if (u0 == u1 || u1 == u2 || u2 == u0) + abort (); + if (u0->c != 3 || u1->c != 3 || u2->c != 3) + abort (); + u0->d = 2; + if (u0->d != 2 || u1->c != 3 || u2->c != 3) + abort (); + if (a0 == a1) + abort (); + if (a0[0] != 1 || a0[1] != 2 || a0[2] != 3 + || a1[0] != 1 || a1[1] != 2 || a1[2] != 3) + abort (); + a0[0] = 3; + if (a0[0] != 3 || a0[1] != 2 || a0[2] != 3 + || a1[0] != 1 || a1[1] != 2 || a1[2] != 3) + abort (); + if (p[0] != 'f' || p[1] != 'o' || p[2] != 'o' || p[3] != 0) + abort (); + p[0] = 'g'; + if (p[0] != 'g' || p[1] != 'o' || p[2] != 'o' || p[3] != 0) + abort (); + if (sizeof((int []) { 1, 2 ,3 }) != 3 * sizeof(int)) + abort (); + if (sizeof((int []) { [3] = 4 }) != 4 * sizeof(int)) + abort (); + struct s *y; + for (int i = 0; i < 3; i++) { + struct s *x = &(struct s) { 1, i }; + if (x->a != 1 || x->b != i) + abort (); + x->a++; + x->b--; + if (x->a != 2 || x->b != i - 1) + abort (); + if (i && y != x) + abort (); + y = x; + } + int *z; + for (int i = 0; i < 4; i++) { + int *x = (int []){ 0, i, i + 2, i - 3 }; + if (x[0] != 0 || x[1] != i || x[2] != i + 2 || x[3] != i - 3) + abort (); + x[0] = x[1]; + x[1] *= x[2]; + x[2] -= x[3]; + x[3] += 7; + if (x[0] != i || x[1] != i * (i + 2) || x[2] != 5 || x[3] != i + 4) + abort (); + if (i && z != x) + abort (); + z = x; + } + (int) { 0 } = 1; + (struct s) { 0, 1 }.a = 3; + (union u) { 3 }.c = 4; + (int []){ 1, 2 }[0] = 0; + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-complit-2.c b/SingleSource/Regression/C/gcc-dg/c99-complit-2.c new file mode 100644 index 0000000000..5e1b5be8e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-complit-2.c @@ -0,0 +1,70 @@ +/* Test for compound literals: in C99 only. Test for invalid uses. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { int a; int b; }; +union u { int c; int d; }; + +struct si; +union ui; + +void +foo (int a) +{ + /* The type name must not be incomplete (apart from arrays of unknown + size), or a function type, or a VLA type. */ + (void) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "init" "void type" { target *-*-* } .-1 } */ + &(struct si) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "init" "incomplete struct type" { target *-*-* } .-1 } */ + /* { dg-error "invalid use of undefined type" "" { target *-*-* } .-2 } */ + &(union ui) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "init" "incomplete union type" { target *-*-* } .-1 } */ + /* { dg-error "invalid use of undefined type" "" { target *-*-* } .-2 } */ + (void (void)) { 0 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "compound literal has function type" "function type" { target *-*-* } .-1 } */ + (int [a]) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "init|variable" "VLA type" { target *-*-* } .-1 } */ + /* Initializers must not attempt to initialize outside the object + declared. */ + (int [1]) { [1] = 2 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "init" "value outside array" { target *-*-* } .-1 } */ + (int [1]) { [-1] = 2 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "init" "value outside array" { target *-*-* } .-1 } */ + (int [1]) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "init" "value outside array" { target *-*-* } .-1 } */ +} + +int z; + +/* Outside a function, initializers must be constant. */ +struct s *s0 = &(struct s) { 0, z }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "init" "non-const" { target *-*-* } .-1 } */ +int sz = sizeof((struct s) { 0, z }); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "init" "non-const" { target *-*-* } .-1 } */ + +/* Compound literals aren't themselves constant expressions. */ +int x = (int) { 0 }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "init" "non-const" { target *-*-* } .-1 } */ + +/* Nor are they suitable structure or union initializers + outside a function. */ +struct s s1 = (struct s) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "init" "struct bad init" { target *-*-* } .-1 } */ +union u u1 = (union u) { 0 }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "init" "union bad init" { target *-*-* } .-1 } */ + +/* They aren't suitable for array initializers, either inside or outside + a function. */ +int y[2] = (int [2]) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "init" "array bad init" { target *-*-* } .-1 } */ + +void +bar (void) +{ + struct s s2 = (struct s) { 0, 1 }; + union u u2 = (union u) { 0 }; + int z[2] = (int [2]) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "init" "array bad init" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-condexpr-1.c b/SingleSource/Regression/C/gcc-dg/c99-condexpr-1.c new file mode 100644 index 0000000000..69d4250801 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-condexpr-1.c @@ -0,0 +1,70 @@ +/* Test for types of conditional expressions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* Notes: + + (a) The rules are the same in both C standard versions, but C99 also + gives us the "restrict" qualifier to play with. + + (b) Within the C standard, the value of a conditional expression can't + have qualified type - but nor can this be detected. Because of GCC's + extended lvalues, the value may in GCC have qualified type if the + arguments do. So don't use the following macro with arguments of + qualified type. + +*/ + +/* Assertion that the type of a conditional expression between E1 and E2 + is T. Checks the expression both ways round. */ +#define ASSERT_COND_TYPE(E1, E2, T) \ + do { \ + typedef T type; \ + typedef type **typepp; \ + typedef __typeof(0 ? (E1) : (E2)) ctype; \ + typedef __typeof(0 ? (E2) : (E1)) ctype2; \ + typedef ctype **ctypepp; \ + typedef ctype2 **ctype2pp; \ + typepp x = 0; \ + ctypepp y = 0; \ + ctype2pp z = 0; \ + x = y; \ + x = z; \ + } while (0) + +void +foo (void) +{ + const void *c_vp; + void *vp; + const int *c_ip; + volatile int *v_ip; + int *ip; + const char *c_cp; + int *restrict *r_ipp; + typedef void (*fpt)(void); + fpt fp; + signed char sc; + struct s { int p; } st; + union u { int p; } un; + /* Arithmetic type. */ + ASSERT_COND_TYPE (sc, sc, int); + /* Structure and union. */ + ASSERT_COND_TYPE (st, st, struct s); + ASSERT_COND_TYPE (un, un, union u); + /* Void. */ + ASSERT_COND_TYPE ((void)0, (void)1, void); + /* Pointers: examples from 6.5.15 paragraph 8. */ + ASSERT_COND_TYPE (c_vp, c_ip, const void *); + ASSERT_COND_TYPE (v_ip, 0, volatile int *); + ASSERT_COND_TYPE (c_ip, v_ip, const volatile int *); + ASSERT_COND_TYPE (vp, c_cp, const void *); + ASSERT_COND_TYPE (ip, c_ip, const int *); + ASSERT_COND_TYPE (vp, ip, void *); + /* Null pointer constants. */ + ASSERT_COND_TYPE (v_ip, (void *)0, volatile int *); + ASSERT_COND_TYPE (r_ipp, (void *)0, int *restrict *); + ASSERT_COND_TYPE (fp, 0, fpt); + ASSERT_COND_TYPE (fp, (void *)0, fpt); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-1.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-1.c new file mode 100644 index 0000000000..c3082ee38f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-1.c @@ -0,0 +1,16 @@ +/* Test for constraints on constant expressions. In C90 it is clear that + certain constructs are not permitted in unevaluated parts of an + expression (except in sizeof); in C99 it might fall within implementation + latitude; and if the operands are suitable, diagnostics should not be + issued. +*/ +/* Origin: Joseph Myers ; inspired by + http://deja.com/getdoc.xp?AN=524271595&fmt=text by Peter Seebach. +*/ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* The comma operator is in a subexpression that is not evaluated, so OK + by C99. In C90 a diagnostic is required since it is not in a sizeof. +*/ +int i = (1 ? 0 : (2, 3)); diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-10.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-10.c new file mode 100644 index 0000000000..2aca6106a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-10.c @@ -0,0 +1,28 @@ +/* Test for constant expressions: invalid null pointer constants in + various contexts (make sure NOPs are not inappropriately + stripped). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void *p = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ +struct s { void *a; } q = { (__SIZE_TYPE__)(void *)0 }; /* { dg-error "without a cast|near initialization" } */ +void * +f (void) +{ + void *r; + r = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ + return (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ +} +void g (void *); /* { dg-message "but argument is of type" } */ +void +h (void) +{ + g ((__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */ +} +void g2 (int, void *); /* { dg-message "but argument is of type" } */ +void +h2 (void) +{ + g2 (0, (__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-11.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-11.c new file mode 100644 index 0000000000..21d9c5f46a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-11.c @@ -0,0 +1,46 @@ +/* Test for constant expressions: cases involving VLAs. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* It appears address constants may contain casts to variably modified + types. Whether they should be permitted was discussed in + + ; since static pointers to VLAs + are definitely permitted within functions and may be initialized + and such initialization involves implicit conversion to a variably + modified type, allowing explicit casts seems appropriate. Thus, + GCC allows them as long as the "evaluated" size expressions do not + contain the various operators not permitted to be evaluated in a + constant expression, and as long as the result is genuinely + constant (meaning that pointer arithmetic using the size of the VLA + is generally not permitted). */ + +static int sa[100]; + +volatile int nv; + +int +f (int m, int n) +{ + static int (*a1)[n] = &sa; + static int (*a2)[n] = (int (*)[n])sa; + static int (*a3)[n] = (int (*)[(int){n}])sa; + static int (*a4)[n] = (int (*)[(int){m++}])sa; /* { dg-error "constant" } */ + static int (*a5)[n] = (int (*)[(int){++m}])sa; /* { dg-error "constant" } */ + static int (*a6)[n] = (int (*)[(int){m--}])sa; /* { dg-error "constant" } */ + static int (*a7)[n] = (int (*)[(int){--m}])sa; /* { dg-error "constant" } */ + static int (*a8)[n] = (int (*)[(m=n)])sa; /* { dg-error "constant" } */ + static int (*a9)[n] = (int (*)[(m+=n)])sa; /* { dg-error "constant" } */ + static int (*a10)[n] = (int (*)[f(m,n)])sa; /* { dg-error "constant" } */ + static int (*a11)[n] = (int (*)[(m,n)])sa; /* { dg-error "constant" } */ + static int (*a12)[n] = (int (*)[sizeof(int[n])])sa; + static int (*a13)[n] = (int (*)[sizeof(int[m++])])sa; /* { dg-error "constant" } */ + static int (*a14)[n] = (int (*)[sizeof(*a1)])sa; + static int (*a15)[n] = (int (*)[sizeof(*(int (*)[n])sa)])sa; + static int (*a16)[n] = (int (*)[sizeof(*(int (*)[m++])sa)])sa; /* { dg-error "constant" } */ + static int (*a17)[n] = (int (*)[nv])sa; + typedef int (*vmt)[m++]; + static int (*a18)[n] = (vmt)sa; + return n; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-12.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-12.c new file mode 100644 index 0000000000..396cea51ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-12.c @@ -0,0 +1,23 @@ +/* Test for constant expressions: VLA size constraints. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +f (int m) +{ + /* An array size that is a constant expression, not just an integer + constant expression, must be checked for being positive, but only + an integer constant expression makes it not a VLA (which affects + certain compatibility checks, in particular). */ + int a1[0]; /* { dg-error "zero" } */ + int a2[-1]; /* { dg-error "negative" } */ + int a3[(int)(double)0.0]; /* { dg-error "zero" } */ + int a4[(int)-1.0]; /* { dg-error "negative" } */ + int a5[(int)+1.0]; + int a6[(int)+2.0]; + void *p = (m ? &a5 : &a6); + int a7[(int)1.0]; + int a8[(int)2.0]; + void *q = (m ? &a7 : &a8); /* { dg-error "pointer type mismatch in conditional expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-13.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-13.c new file mode 100644 index 0000000000..e477e5d162 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-13.c @@ -0,0 +1,16 @@ +/* Test for constant expressions: VLA size constraints with + -frounding-math. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -frounding-math" } */ +/* { dg-require-effective-target alloca } */ + +void +f (void) +{ + /* With -frounding-math, presume that floating-point expressions + that may depend on the rounding mode do not count as arithmetic + constant expressions, and so arrays involving such expressions in + their sizes do not have the size checked for being negative. */ + int a1[(int)(-5.0/3.0)]; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-14.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-14.c new file mode 100644 index 0000000000..0c4f1b69bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-14.c @@ -0,0 +1,35 @@ +/* Test for constant expressions: cases involving VLAs, at file scope. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* It appears address constants may contain casts to variably modified + types. Whether they should be permitted was discussed in + + ; since static pointers to VLAs + are definitely permitted within functions and may be initialized + and such initialization involves implicit conversion to a variably + modified type, allowing explicit casts seems appropriate. Thus, + GCC allows them as long as the "evaluated" size expressions do not + contain the various operators not permitted to be evaluated in a + constant expression, and as long as the result is genuinely + constant (meaning that pointer arithmetic using the size of the VLA + is generally not permitted). */ + +static int sa[100]; + +volatile int nv; +int m; +int n; +int f (int, int); + +static int (*a2)[] = (int (*)[n])sa; +static int (*a8)[] = (int (*)[(m=n)])sa; /* { dg-error "constant" } */ +static int (*a9)[] = (int (*)[(m+=n)])sa; /* { dg-error "constant" } */ +static int (*a10)[] = (int (*)[f(m,n)])sa; /* { dg-error "constant" } */ +static int (*a11)[] = (int (*)[(m,n)])sa; /* { dg-error "constant" } */ +static int (*a12)[] = (int (*)[sizeof(int[n])])sa; +static int (*a13)[] = (int (*)[sizeof(int[m++])])sa; /* { dg-error "constant" } */ +static int (*a15)[] = (int (*)[sizeof(*(int (*)[n])sa)])sa; +static int (*a16)[] = (int (*)[sizeof(*(int (*)[m++])sa)])sa; /* { dg-error "constant" } */ +static int (*a17)[] = (int (*)[nv])sa; diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-15.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-15.c new file mode 100644 index 0000000000..b1744b6718 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-15.c @@ -0,0 +1,9 @@ +/* Test for constant expressions: casts with integer overflow. PR + c/93241. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +#include + +struct s { int a : (0 ? (_Bool) (INT_MAX + 1) : 1); }; +struct t { int a : (0 ? (short) ((INT_MAX + 1) != 0) : 1); }; diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-2.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-2.c new file mode 100644 index 0000000000..a78e412d35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-2.c @@ -0,0 +1,45 @@ +/* Test for constant expressions: details of what is a null pointer + constant. +*/ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999" } */ +/* Note: not using -pedantic since the -std option alone should be enough + to give the correct behavior to conforming programs. If -pedantic is + needed to make (say) (0, 0) not be a constant expression, this is a + bug. +*/ + +int *a; +int b; +long *c; + +#if defined(_LP64) +#define ZERO 0L +#elif defined(_WIN64) +#define ZERO 0LL +#else +#define ZERO 0 +#endif + +/* Assertion that n is a null pointer constant: so the conditional expression + has type 'int *' instead of 'void *'. +*/ +#define ASSERT_NPC(n) (b = *(1 ? a : (n))) +/* Assertion that n is not a null pointer constant: so the conditional + expressions has type 'void *' instead of 'int *'. +*/ +#define ASSERT_NOT_NPC(n) (c = (1 ? a : (n))) + +void +foo (void) +{ + ASSERT_NPC (0); + ASSERT_NPC ((void *)0); + ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((void *)(0, ZERO)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((void *)(&"Foobar"[0] - &"Foobar"[0])); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + /* This last one is a null pointer constant in C99 only. */ + ASSERT_NPC ((void *)(1 ? 0 : (0, 0))); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-3.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-3.c new file mode 100644 index 0000000000..9b036a32d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-3.c @@ -0,0 +1,45 @@ +/* Test for constant expressions: broken optimization with const variables. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -O2" } */ +/* Note: not using -pedantic since the -std option alone should be enough + to give the correct behavior to conforming programs. */ + +static const int ZERO = 0; +static const double DZERO = 0; + +int *a; +int b; +long *c; + +/* Assertion that n is a constant zero: so the conditional expression + has type 'int *' instead of 'void *'. +*/ +#define ASSERT_NPC(n) (b = *(1 ? a : (n))) +/* Assertion that n is not a constant zero: so the conditional + expressions has type 'void *' instead of 'int *'. +*/ +#define ASSERT_NOT_NPC(n) (c = (1 ? a : (void *)(__SIZE_TYPE__)(n))) + +void +foo (void) +{ + ASSERT_NPC (0); + ASSERT_NOT_NPC (ZERO); + ASSERT_NPC (0 + 0); + ASSERT_NOT_NPC (ZERO + 0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC (ZERO + ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NPC (+0); + ASSERT_NOT_NPC (+ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NPC (-0); + ASSERT_NOT_NPC (-ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NPC ((char) 0); + ASSERT_NOT_NPC ((char) ZERO); + ASSERT_NPC ((int) 0); + ASSERT_NOT_NPC ((int) ZERO); + ASSERT_NPC ((int) 0.0); + ASSERT_NOT_NPC ((int) DZERO); + ASSERT_NOT_NPC ((int) +0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((int) (0.0+0.0)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ + ASSERT_NOT_NPC ((int) (double)0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-4.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-4.c new file mode 100644 index 0000000000..f6beaf77a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-4.c @@ -0,0 +1,11 @@ +/* Test for constant expressions: const variable with value 0 is not a + null pointer constant so the conditional expression should have + type void * and the assignment is OK. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -O2" } */ +int *p; +long *q; +static void *const n = 0; +int j; +void f(void) { q = j ? p : n; } diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-5.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-5.c new file mode 100644 index 0000000000..693b97d018 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-5.c @@ -0,0 +1,39 @@ +/* Test null pointer constants: typedefs for void should be OK but not + qualified void. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef void V; +int *p; +long *q; +int j; +void (*fp)(void); + +void +f (void) +{ + /* (V *)0 is a null pointer constant, so the assignment should be + diagnosed. */ + q = (j ? p : (V *)0); /* { dg-error "assignment to 'long int \\*' from incompatible pointer type 'int \\*'" } */ + q = (j ? p : (void *)0); /* { dg-error "assignment to 'long int \\*' from incompatible pointer type 'int \\*'" } */ + /* And this conversion should be valid. */ + (void (*)(void))(V *)0; + (void (*)(void))(void *)0; + /* Pointers to qualified void are not valid null pointer + constants. */ + fp = (const void *)0; /* { dg-error "ISO C forbids assignment between function pointer and 'void \\*'" } */ + fp = (void *)0; + fp = (V *)0; + fp = 0; + fp == 0; + 0 == fp; + fp == (void *)0; + (void *)0 == fp; + fp == (V *)0; + (V *)0 == fp; + fp == (V *)1; /* { dg-error "ISO C forbids comparison of 'void \\*' with function pointer" } */ + (V *)1 == fp; /* { dg-error "ISO C forbids comparison of 'void \\*' with function pointer" } */ + fp == (const void *)0; /* { dg-error "ISO C forbids comparison of 'void \\*' with function pointer" } */ + (const void *)0 == fp; /* { dg-error "ISO C forbids comparison of 'void \\*' with function pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-6.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-6.c new file mode 100644 index 0000000000..ca602438d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-6.c @@ -0,0 +1,62 @@ +/* Test for constant expressions: operands and casts not permitted in + integer constant expressions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* PR 29116. */ +int n = 0, p[n * 0 + 1]; /* { dg-error "variabl" } */ + +/* PR 31871. */ +extern int c[1 + ((__INTPTR_TYPE__) (void *) 0)]; /* { dg-error "variab" } */ + +/* Implicit conversions from floating-point constants are not OK, + although explicit ones are. */ +extern int c1[1.0 ? 1 : 0]; /* { dg-error "variab" } */ + +extern int c2[(int)1.0 ? 1 : 0]; + +extern int c3[1.0 && 1]; /* { dg-error "variab" } */ + +extern int c4[(int)1.0 && 1]; + +extern int c5[1.0 || 1]; /* { dg-error "variab" } */ + +extern int c6[(int)1.0 || 1]; + +/* Similar with various other cases where integer constant expressions + are required. */ + +struct s { + int a : (n * 0 + 1); /* { dg-error "constant" } */ +}; + +enum e { + E = (1 + ((__INTPTR_TYPE__) (void *) 0)), /* { dg-error "constant" } */ + E2 = 0 +}; + +enum f { + F = (1 ? 1 : n), /* { dg-error "constant" } */ + F2 = 0 +}; + +/* Presume that a compound literal, being a reference to an anonymous + variable, is not allowed in an integer constant expression + regardless of what initializers it contains. */ +enum g { + G = (1 ? 1 : (int){0}), /* { dg-error "constant" } */ + G2 = 0 +}; + +int v[2] = { [(n * 0 + 1)] = 1 }; /* { dg-error "constant|near initialization" } */ + +void +f (int a) +{ + switch (a) + { + case (n * 0 + 1): /* { dg-error "constant" } */ + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-7.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-7.c new file mode 100644 index 0000000000..bf23a4a417 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-7.c @@ -0,0 +1,43 @@ +/* Test for constant expressions: overflow and constant expressions; + see also overflow-warn-*.c for some other cases. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#include +#include + +int a = DBL_MAX; /* { dg-warning "overflow in conversion" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ +int b = (int) DBL_MAX; /* { dg-error "overflow" } */ +unsigned int c = -1.0; /* { dg-warning "overflow in conversion" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ +unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */ + +int e = 0 << 1000; /* { dg-warning "shift count" } */ +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ +int f = 0 << -1; /* { dg-warning "shift count" } */ +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ +int g = 0 >> 1000; /* { dg-warning "shift count" } */ +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ +int h = 0 >> -1; /* { dg-warning "shift count" } */ +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ + +int b1 = (0 ? (int) DBL_MAX : 0); +unsigned int d1 = (0 ? (unsigned int)-1.0 : 0); +int e1 = (0 ? 0 << 1000 : 0); +int f1 = (0 ? 0 << -1 : 0); +int g1 = (0 ? 0 >> 1000 : 0); +int h1 = (0 ? 0 >> -1: 0); + +int i = -1 << 0; +/* { dg-error "constant" "constant" { target *-*-* } .-1 } */ + +int j[1] = { DBL_MAX }; /* { dg-warning "overflow in conversion" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + +int array[2] = { [0 * (INT_MAX + 1)] = 0 }; /* { dg-warning "integer overflow in expression" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + +_Bool k = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-8.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-8.c new file mode 100644 index 0000000000..bce78f6ce6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-8.c @@ -0,0 +1,28 @@ +/* Test for constant expressions: overflow and constant expressions + with -fwrapv: overflows still count as such for the purposes of + constant expressions even when they have defined values at + runtime. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -fwrapv" } */ + +#include + +enum e { + E0 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E1 = 0 * (INT_MIN / -1), /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E3 = 0 * (INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E5 = 0 * -INT_MIN, /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + E6 = 0 * !-INT_MIN, /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "not an integer constant" "constant" { target *-*-* } .-1 } */ + E7 = INT_MIN % -1 /* { dg-warning "16:integer overflow in expression" } */ + /* { dg-error "1:overflow in constant expression" "constant" { target *-*-* } .+1 } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/c99-const-expr-9.c b/SingleSource/Regression/C/gcc-dg/c99-const-expr-9.c new file mode 100644 index 0000000000..11e0b2c08b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-const-expr-9.c @@ -0,0 +1,26 @@ +/* Test for constant expressions: __builtin_offsetof allowed in + integer constant expressions but not traditional offsetof + expansion. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -ftrack-macro-expansion=0" } */ + +struct s { + int a; +}; + +struct t { + struct s a; + int b[2]; +}; + +#define old_offsetof(TYPE, MEMBER) ((__SIZE_TYPE__)(__UINTPTR_TYPE__) &((TYPE *)0)->MEMBER) + +enum e { + E1 = old_offsetof (struct s, a), /* { dg-error "constant" } */ + E2 = old_offsetof (struct t, a.a), /* { dg-error "constant" } */ + E3 = old_offsetof (struct t, b[1]), /* { dg-error "constant" } */ + E4 = __builtin_offsetof (struct s, a), + E5 = __builtin_offsetof (struct t, a.a), + E6 = __builtin_offsetof (struct t, b[1]) +}; diff --git a/SingleSource/Regression/C/gcc-dg/c99-digraph-1.c b/SingleSource/Regression/C/gcc-dg/c99-digraph-1.c new file mode 100644 index 0000000000..318aa70bdc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-digraph-1.c @@ -0,0 +1,24 @@ +/* Test for recognition of digraphs: should be recognized in C94 and C99 + mode, but not in C90 mode. Also check correct stringizing. +*/ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#define str(x) xstr(x) +#define xstr(x) #x +#define foo(p, q) str(p %:%: q) + +extern void abort (void); +extern int strcmp (const char *, const char *); + +int +main (void) +{ + const char *t = foo (1, 2); + const char *u = str (<:); + if (strcmp (t, "12") || strcmp (u, "<:")) + abort (); + else + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-dupqual-1.c b/SingleSource/Regression/C/gcc-dg/c99-dupqual-1.c new file mode 100644 index 0000000000..2e6d7e1bc5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-dupqual-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef const int CI; +const const int c1; /* { dg-bogus "duplicate" } */ +const CI c2; /* { dg-bogus "duplicate" } */ +const CI *c3; /* { dg-bogus "duplicate" } */ + +typedef volatile int VI; +volatile volatile int v1; /* { dg-bogus "duplicate" } */ +volatile VI v2; /* { dg-bogus "duplicate" } */ +volatile VI *v3; /* { dg-bogus "duplicate" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-enum-comma-1.c b/SingleSource/Regression/C/gcc-dg/c99-enum-comma-1.c new file mode 100644 index 0000000000..1b676a2291 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-enum-comma-1.c @@ -0,0 +1,6 @@ +/* Test for commas at end of enums: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +enum foo { bar, }; diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-1.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-1.c new file mode 100644 index 0000000000..f315709517 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-1.c @@ -0,0 +1,8 @@ +/* Test for invalid uses of flexible array members. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s1 { int x[]; }; /* { dg-error "no named members" "members" } */ +struct s2 { int :1; int x[]; }; /* { dg-error "no named members" "members" } */ +struct s3 { int x[]; int y; }; /* { dg-error "not at end" "not at end" } */ +struct s4 { int x; int y[]; }; diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-2.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-2.c new file mode 100644 index 0000000000..496f4f985c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-2.c @@ -0,0 +1,14 @@ +/* PR c/5623 */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct blah { + int number; + char array[]; +}; + +void foo(void) +{ + struct blah b; + b.array = "hi"; /* { dg-error "invalid use of flexible array member" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-3.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-3.c new file mode 100644 index 0000000000..784dabdeac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-3.c @@ -0,0 +1,47 @@ +/* Test for flexible array members. Test for where structures with + such members may not occur. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct flex { int a; int b[]; }; +union rf1 { struct flex a; int b; }; +union rf2 { int a; struct flex b; }; +union rf3 { int a; union rf1 b; }; +union rf4 { union rf2 a; int b; }; + +/* The above structure and unions may not be members of structures or + elements of arrays (6.7.2.1#2). */ + +struct t0 { struct flex a; }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "struct in struct" { target *-*-* } .-1 } */ +struct t1 { union rf1 a; }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "union in struct" { target *-*-* } .-1 } */ +struct t2 { union rf2 a; }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "union in struct" { target *-*-* } .-1 } */ +struct t3 { union rf3 a; }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "recursive union in struct" { target *-*-* } .-1 } */ +struct t4 { union rf4 a; }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "recursive union in struct" { target *-*-* } .-1 } */ + +void f0 (struct flex[]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "struct in array" { target *-*-* } .-1 } */ +void f1 (union rf1[]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "union in array" { target *-*-* } .-1 } */ +void f2 (union rf2[]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "union in array" { target *-*-* } .-1 } */ +void f3 (union rf3[]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "recursive union in array" { target *-*-* } .-1 } */ +void f4 (union rf4[]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "recursive union in array" { target *-*-* } .-1 } */ + +struct flex a0[1]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "struct in array" { target *-*-* } .-1 } */ +union rf1 a1[1]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "union in array" { target *-*-* } .-1 } */ +union rf2 a2[1]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "union in array" { target *-*-* } .-1 } */ +union rf3 a3[1]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "recursive union in array" { target *-*-* } .-1 } */ +union rf4 a4[1]; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "invalid use of structure" "recursive union in array" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-5.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-5.c new file mode 100644 index 0000000000..385b0cb959 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-5.c @@ -0,0 +1,6 @@ +/* Test for flexible array members: not permitted in unions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +union u { int a; char b[]; }; /* { dg-error "flexible array member in union" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-6.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-6.c new file mode 100644 index 0000000000..468c4b3cda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-6.c @@ -0,0 +1,15 @@ +/* [] does not indicate a flexible array member unless it is the field + itself being declared as an incomplete array type rather than a + pointer or other type derived from such a type. PR 36432. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +f (void) +{ + int a[3]; + int (*p)[]; + struct { int (*p)[]; } s; + p = &a; + s.p = &a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-7.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-7.c new file mode 100644 index 0000000000..49bb3e42bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-7.c @@ -0,0 +1,17 @@ +/* Initialization of a flexible array member with a string constant + must be diagnosed. PR 37481. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { int a; char b[]; }; + +struct s a = { 0, "" }; /* { dg-error "initialization of a flexible array member" } */ +/* { dg-message "near init" "near init" { target *-*-* } .-1 } */ +struct s b = { 0, { 0 } }; /* { dg-error "initialization of a flexible array member" } */ +/* { dg-message "near init" "near init" { target *-*-* } .-1 } */ +struct s c = { 0, { } }; /* { dg-error "ISO C forbids empty initializer braces" } */ +struct s d = { .b = "" }; /* { dg-error "initialization of a flexible array member" } */ +/* { dg-message "near init" "near init" { target *-*-* } .-1 } */ +struct s e = { .b = { 0 } }; /* { dg-error "initialization of a flexible array member" } */ +/* { dg-message "near init" "near init" { target *-*-* } .-1 } */ +struct s f = { .b = { } }; /* { dg-error "ISO C forbids empty initializer braces" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-1.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-1.c new file mode 100644 index 0000000000..8c3b712474 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-1.c @@ -0,0 +1,9 @@ +/* Test for invalid uses of flexible array members. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef int A[]; +struct s1 { A x; }; /* { dg-error "no named members" "members" } */ +struct s2 { int :1; A x; }; /* { dg-error "no named members" "members" } */ +struct s3 { A x; int y; }; /* { dg-error "not at end" "not at end" } */ +struct s4 { int x; A y; }; diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-2.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-2.c new file mode 100644 index 0000000000..f869f75c2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-2.c @@ -0,0 +1,17 @@ +/* Test for invalid uses of flexible array members. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef char A[]; + +struct S { + int n; + A a; +}; + +void +foo (void) +{ + struct S s; + s.a = "abc"; /* { dg-error "invalid use of flexible array member" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-3.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-3.c new file mode 100644 index 0000000000..11db886118 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-3.c @@ -0,0 +1,32 @@ +/* Test for flexible array members. Test for where structures with + such members may not occur. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef int T[]; +struct flex { int a; T b; }; +union rf1 { struct flex a; int b; }; +union rf2 { int a; struct flex b; }; +union rf3 { int a; union rf1 b; }; +union rf4 { union rf2 a; int b; }; + +/* The above structure and unions may not be members of structures or + elements of arrays (6.7.2.1#2). */ + +struct t0 { struct flex a; }; /* { dg-error "invalid use of structure" } */ +struct t1 { union rf1 a; }; /* { dg-error "invalid use of structure" } */ +struct t2 { union rf2 a; }; /* { dg-error "invalid use of structure" } */ +struct t3 { union rf3 a; }; /* { dg-error "invalid use of structure" } */ +struct t4 { union rf4 a; }; /* { dg-error "invalid use of structure" } */ + +void f0 (struct flex[]); /* { dg-error "invalid use of structure" } */ +void f1 (union rf1[]); /* { dg-error "invalid use of structure" } */ +void f2 (union rf2[]); /* { dg-error "invalid use of structure" } */ +void f3 (union rf3[]); /* { dg-error "invalid use of structure" } */ +void f4 (union rf4[]); /* { dg-error "invalid use of structure" } */ + +struct flex a0[1]; /* { dg-error "invalid use of structure" } */ +union rf1 a1[1]; /* { dg-error "invalid use of structure" } */ +union rf2 a2[1]; /* { dg-error "invalid use of structure" } */ +union rf3 a3[1]; /* { dg-error "invalid use of structure" } */ +union rf4 a4[1]; /* { dg-error "invalid use of structure" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-5.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-5.c new file mode 100644 index 0000000000..2d1fbe1c13 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-5.c @@ -0,0 +1,6 @@ +/* Test for flexible array members: not permitted in unions. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef char T[]; +union u { int a; T b; }; /* { dg-error "flexible array member in union" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-7.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-7.c new file mode 100644 index 0000000000..f1505d4dcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-7.c @@ -0,0 +1,18 @@ +/* Initialization of a flexible array member with a string constant + must be diagnosed. PR 37481. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef char T[]; +struct s { int a; T b; }; + +struct s a = { 0, "" }; /* { dg-error "initialization of a flexible array member" } */ +/* { dg-message "near init" "near init" { target *-*-* } .-1 } */ +struct s b = { 0, { 0 } }; /* { dg-error "initialization of a flexible array member" } */ +/* { dg-message "near init" "near init" { target *-*-* } .-1 } */ +struct s c = { 0, { } }; /* { dg-error "ISO C forbids empty initializer braces" } */ +struct s d = { .b = "" }; /* { dg-error "initialization of a flexible array member" } */ +/* { dg-message "near init" "near init" { target *-*-* } .-1 } */ +struct s e = { .b = { 0 } }; /* { dg-error "initialization of a flexible array member" } */ +/* { dg-message "near init" "near init" { target *-*-* } .-1 } */ +struct s f = { .b = { } }; /* { dg-error "ISO C forbids empty initializer braces" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-8.c b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-8.c new file mode 100644 index 0000000000..26c4a23428 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-flex-array-typedef-8.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef char T[]; +struct foo { int x; T y; }; +struct bar { struct foo f; }; +struct baz { struct bar b; }; + +struct foo a1 = { 1, "abc" }; +struct foo a2 = { 1, { "abc" } }; +struct foo b1[] = { { 1, "abc" } }; /* { dg-error "initialization of flexible array member" } */ +struct foo b2[] = { { 1, { "abc" } } }; /* { dg-error "initialization of flexible array member" } */ +struct bar c1[] = { { { 1, "abc" } } }; /* { dg-error "initialization of flexible array member" } */ +struct bar c2[] = { { { 1, { "abc" } } } }; /* { dg-error "initialization of flexible array member" } */ +struct baz d1[] = { { { { 1, "abc" } } } }; /* { dg-error "initialization of flexible array member" } */ +struct baz d2[] = { { { { 1, { "abc" } } } } }; /* { dg-error "initialization of flexible array member" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-float-1.c b/SingleSource/Regression/C/gcc-dg/c99-float-1.c new file mode 100644 index 0000000000..7ee87a564a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-float-1.c @@ -0,0 +1,169 @@ +/* Test for C99 macros. */ +/* Origin: Joseph Myers */ +/* { dg-do preprocess } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* This test checks that the C99 macros (but not the C11 ones) are defined; + it does not check the correctness of their values. */ + +#include + +#ifndef FLT_ROUNDS +#error "FLT_ROUNDS undefined" +#endif + +#ifndef FLT_RADIX +#error "FLT_RADIX undefined" +#endif + +#ifndef FLT_MANT_DIG +#error "FLT_MANT_DIG undefined" +#endif + +#ifndef FLT_DIG +#error "FLT_DIG undefined" +#endif + +#ifndef FLT_MIN_EXP +#error "FLT_MIN_EXP undefined" +#endif + +#ifndef FLT_MIN_10_EXP +#error "FLT_MIN_10_EXP undefined" +#endif + +#ifndef FLT_MAX_EXP +#error "FLT_MAX_EXP undefined" +#endif + +#ifndef FLT_MAX_10_EXP +#error "FLT_MAX_10_EXP undefined" +#endif + +#ifndef FLT_MAX +#error "FLT_MAX undefined" +#endif + +#ifndef FLT_EPSILON +#error "FLT_EPSILON undefined" +#endif + +#ifndef FLT_MIN +#error "FLT_MIN undefined" +#endif + +#ifndef DBL_MANT_DIG +#error "DBL_MANT_DIG undefined" +#endif + +#ifndef DBL_DIG +#error "DBL_DIG undefined" +#endif + +#ifndef DBL_MIN_EXP +#error "DBL_MIN_EXP undefined" +#endif + +#ifndef DBL_MIN_10_EXP +#error "DBL_MIN_10_EXP undefined" +#endif + +#ifndef DBL_MAX_EXP +#error "DBL_MAX_EXP undefined" +#endif + +#ifndef DBL_MAX_10_EXP +#error "DBL_MAX_10_EXP undefined" +#endif + +#ifndef DBL_MAX +#error "DBL_MAX undefined" +#endif + +#ifndef DBL_EPSILON +#error "DBL_EPSILON undefined" +#endif + +#ifndef DBL_MIN +#error "DBL_MIN undefined" +#endif + +#ifndef LDBL_MANT_DIG +#error "LDBL_MANT_DIG undefined" +#endif + +#ifndef LDBL_DIG +#error "LDBL_DIG undefined" +#endif + +#ifndef LDBL_MIN_EXP +#error "LDBL_MIN_EXP undefined" +#endif + +#ifndef LDBL_MIN_10_EXP +#error "LDBL_MIN_10_EXP undefined" +#endif + +#ifndef LDBL_MAX_EXP +#error "LDBL_MAX_EXP undefined" +#endif + +#ifndef LDBL_MAX_10_EXP +#error "LDBL_MAX_10_EXP undefined" +#endif + +#ifndef LDBL_MAX +#error "LDBL_MAX undefined" +#endif + +#ifndef LDBL_EPSILON +#error "LDBL_EPSILON undefined" +#endif + +#ifndef LDBL_MIN +#error "LDBL_MIN undefined" +#endif + +#ifndef FLT_EVAL_METHOD +#error "FLT_EVAL_METHOD undefined" +#endif + +#ifndef DECIMAL_DIG +#error "DECIMAL_DIG undefined" +#endif + +#ifdef FLT_DECIMAL_DIG +#error "FLT_DECIMAL_DIG defined" +#endif + +#ifdef DBL_DECIMAL_DIG +#error "DBL_DECIMAL_DIG defined" +#endif + +#ifdef LDBL_DECIMAL_DIG +#error "LDBL_DECIMAL_DIG defined" +#endif + +#ifdef FLT_HAS_SUBNORM +#error "FLT_HAS_SUBNORM defined" +#endif + +#ifdef DBL_HAS_SUBNORM +#error "DBL_HAS_SUBNORM defined" +#endif + +#ifdef LDBL_HAS_SUBNORM +#error "LDBL_HAS_SUBNORM defined" +#endif + +#ifdef FLT_TRUE_MIN +#error "FLT_TRUE_MIN defined" +#endif + +#ifdef DBL_TRUE_MIN +#error "DBL_TRUE_MIN defined" +#endif + +#ifdef LDBL_TRUE_MIN +#error "LDBL_TRUE_MIN defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c99-fordecl-1.c b/SingleSource/Regression/C/gcc-dg/c99-fordecl-1.c new file mode 100644 index 0000000000..faaab1e953 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-fordecl-1.c @@ -0,0 +1,35 @@ +/* Test for C99 declarations in for loops. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int j = 0; + int i = -1; + for (int i = 1; i <= 10; i++) + j += i; + if (j != 55) + abort (); + if (i != -1) + abort (); + j = 0; + for (auto int i = 1; i <= 10; i++) + j += i; + if (j != 55) + abort (); + if (i != -1) + abort (); + j = 0; + for (register int i = 1; i <= 10; i++) + j += i; + if (j != 55) + abort (); + if (i != -1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-fordecl-2.c b/SingleSource/Regression/C/gcc-dg/c99-fordecl-2.c new file mode 100644 index 0000000000..a8d5b124fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-fordecl-2.c @@ -0,0 +1,34 @@ +/* Test for C99 declarations in for loops. Test constraints. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +foo (void) +{ + /* See comments in check_for_loop_decls (c-decl.c) for the presumptions + behind these tests. */ + int j = 0; + for (int i = 1, bar (void); i <= 10; i++) /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "bar" "function in for loop" { target *-*-* } .-1 } */ + j += i; + + for (static int i = 1; i <= 10; i++) /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "static" "static in for loop" { target *-*-* } .-1 } */ + j += i; + + for (extern int i; j <= 500; j++) /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "extern" "extern in for loop" { target *-*-* } .-1 } */ + j += 5; + + for (enum { FOO } i = FOO; i < 10; i++) /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "FOO" "enum value in for loop" { target *-*-* } .-1 } */ + j += i; + + for (enum BAR { FOO } i = FOO; i < 10; i++) /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "FOO" "enum value in for loop" { target *-*-* } .-1 } */ + /* { dg-error "BAR" "enum tag in for loop" { target *-*-* } .-2 } */ + j += i; + for (typedef int T;;) /* { dg-error "non-variable" } */ + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-fordecl-3.c b/SingleSource/Regression/C/gcc-dg/c99-fordecl-3.c new file mode 100644 index 0000000000..ff814ad573 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-fordecl-3.c @@ -0,0 +1,15 @@ +/* Test for C99 declarations in for loops. Test constraints: struct + and union tags can't be declared there (affirmed in response to + DR#277). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +foo (void) +{ + for (struct s { int p; } *p = 0; ;) /* { dg-error "'struct s' declared in 'for' loop initial declaration" } */ + ; + for (union u { int p; } *p = 0; ;) /* { dg-error "'union u' declared in 'for' loop initial declaration" } */ + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-func-1.c b/SingleSource/Regression/C/gcc-dg/c99-func-1.c new file mode 100644 index 0000000000..43fb032177 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-func-1.c @@ -0,0 +1,17 @@ +/* Test for C99 __func__. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +extern void abort (void); +extern int strcmp (const char *, const char *); +extern void exit (int); + +int +main (void) +{ + if (strcmp (__func__, "main") || sizeof (__func__) != 5) + abort (); + else + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-func-2.c b/SingleSource/Regression/C/gcc-dg/c99-func-2.c new file mode 100644 index 0000000000..f3eaaa1fe9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-func-2.c @@ -0,0 +1,10 @@ +/* Test for C99 __func__: not a string constant. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +foo (void) +{ + __func__ "foo"; /* { dg-error "parse error|syntax error|expected" "before string constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-func-3.c b/SingleSource/Regression/C/gcc-dg/c99-func-3.c new file mode 100644 index 0000000000..f8a06a0e75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-func-3.c @@ -0,0 +1,16 @@ +/* Test for C99 __func__: not merging with string literals. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + if ("main" == __func__) + abort (); + else + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-func-4.c b/SingleSource/Regression/C/gcc-dg/c99-func-4.c new file mode 100644 index 0000000000..10ec19566f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-func-4.c @@ -0,0 +1,10 @@ +/* Test for C99 __func__: of type const char []. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +foo (void) +{ + char *p = __func__; /* { dg-error "discards" "__func__ pointer to const" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-hexfloat-1.c b/SingleSource/Regression/C/gcc-dg/c99-hexfloat-1.c new file mode 100644 index 0000000000..f4c147bcca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-hexfloat-1.c @@ -0,0 +1,6 @@ +/* Test for hex floating point constants: in C99 only. Compiler test. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +double d = 0x1.2p2; /* { dg-bogus "radix 16" "bogus C99 hex float error" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-hexfloat-2.c b/SingleSource/Regression/C/gcc-dg/c99-hexfloat-2.c new file mode 100644 index 0000000000..3ca15c3c53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-hexfloat-2.c @@ -0,0 +1,24 @@ +/* Test for hex floating point constants: in C99 only. Preprocessor test. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#define f ( +#define l ) +#define str(x) #x +#define xstr(x) str(x) + +/* C90: "0x1p+( 0x1p+)"; C99: "0x1p+f 0x1p+l" */ +const char *s = xstr(0x1p+f 0x1p+l); + +extern void abort (void); +extern int strcmp (const char *, const char *); + +int +main (void) +{ + if (strcmp (s, "0x1p+f 0x1p+l")) + abort (); + else + return 0; /* Correct C99 behavior. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-hexfloat-3.c b/SingleSource/Regression/C/gcc-dg/c99-hexfloat-3.c new file mode 100644 index 0000000000..62dc4956ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-hexfloat-3.c @@ -0,0 +1,25 @@ +/* Test syntax of hexadecimal floating point constants: at least one + digit needed before or after point. PR 41947. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +double d0 = 0x0.0p0; +double d1 = 0x.0p0; +double d2 = 0x0.p0; +double d3 = 0x0.0p+0; +double d4 = 0x.0p+0; +double d5 = 0x0.p+0; +double d6 = 0x0.0p-0; +double d7 = 0x.0p-0; +double d8 = 0x0.p-0; + +double e0 = 0x.p0; /* { dg-error "no digits" } */ +double e1 = 0x0.; /* { dg-error "require an exponent" } */ +double e2 = 0x.0; /* { dg-error "require an exponent" } */ +double e3 = 0x0.0; /* { dg-error "require an exponent" } */ +double e4 = 0x0.0p; /* { dg-error "exponent has no digits" } */ +double e5 = 0x0.0pf; /* { dg-error "exponent has no digits" } */ +double e6 = 0x0.0p+; /* { dg-error "exponent has no digits" } */ +double e7 = 0x0.0p+f; /* { dg-error "exponent has no digits" } */ +double e8 = 0x0.0p-; /* { dg-error "exponent has no digits" } */ +double e9 = 0x0.0p-f; /* { dg-error "exponent has no digits" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-idem-qual-1.c b/SingleSource/Regression/C/gcc-dg/c99-idem-qual-1.c new file mode 100644 index 0000000000..c541d075cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-idem-qual-1.c @@ -0,0 +1,7 @@ +/* Test for idempotent type qualifiers: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef const int cint; +const cint foo; /* { dg-bogus "duplicate" "duplicate type qualifier error" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-idem-qual-2.c b/SingleSource/Regression/C/gcc-dg/c99-idem-qual-2.c new file mode 100644 index 0000000000..dd9f932b97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-idem-qual-2.c @@ -0,0 +1,6 @@ +/* Test for idempotent type qualifiers: in C99 only. Test "const const". */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +const const int foo; /* { dg-bogus "duplicate" "duplicate type qualifier error" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-idem-qual-3.c b/SingleSource/Regression/C/gcc-dg/c99-idem-qual-3.c new file mode 100644 index 0000000000..0f34f83218 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-idem-qual-3.c @@ -0,0 +1,9 @@ +/* Test for idempotent type qualifiers: in C99 only. Test duplicate + type qualifiers with array element types. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef const int cia[2]; +const cia a; /* { dg-bogus "duplicate" "duplicate type qualifier warning" } */ +const cia b[2]; /* { dg-bogus "duplicate" "duplicate type qualifier warning" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-impl-decl-1.c b/SingleSource/Regression/C/gcc-dg/c99-impl-decl-1.c new file mode 100644 index 0000000000..bc4f5fe58f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-impl-decl-1.c @@ -0,0 +1,21 @@ +/* Test for implicit function declaration: in C90 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +foo (void) +{ + bar (); /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "implicit" "C99 implicit declaration error" { target *-*-* } .-1 } */ +} + +/* C90 subclause 7.1.7 says we can implicitly declare strcmp; C99 removes + implict declarations. +*/ +int +bar (const char *a, const char *b) +{ + return strcmp (a, b); /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "implicit" "C99 implicit declaration error" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-impl-int-1.c b/SingleSource/Regression/C/gcc-dg/c99-impl-int-1.c new file mode 100644 index 0000000000..0423735c11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-impl-int-1.c @@ -0,0 +1,9 @@ +/* Test for implicit int: in C90 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +extern foo; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "type defaults" "C99 implicit int error" { target *-*-* } .-1 } */ +bar (void) { } /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "return type defaults" "C99 implicit int error" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-impl-int-2.c b/SingleSource/Regression/C/gcc-dg/c99-impl-int-2.c new file mode 100644 index 0000000000..ed3eb4bf36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-impl-int-2.c @@ -0,0 +1,9 @@ +/* Test for implicit int: in C90 only. Function parameters in old-style + function definition. +*/ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void foo (a) { } /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "defaults" "C99 implicit int parameter error" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-init-1.c b/SingleSource/Regression/C/gcc-dg/c99-init-1.c new file mode 100644 index 0000000000..95803c241f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-init-1.c @@ -0,0 +1,78 @@ +/* Test for C99 designated initializers */ +/* Origin: Jakub Jelinek */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __WCHAR_TYPE__ wchar_t; +extern int memcmp (const void *, const void *, size_t); +extern void abort (void); +extern void exit (int); + +int a[10] = { 10, 0, 12, 13, 14, 0, 0, 17, 0, 0 }; +int b[10] = { 10, [4] = 15, [2] = 12, [4] = 14, [7] = 17 }; +int c[10] = { 10, [4] = 15, [2] = 12, [3] = 13, 14, [7] = 17 }; +struct A { + int B; + short C[2]; +}; +struct A d[] = { { 0, { 1, 2 } }, { 0, { 0, 0 } }, { 10, { 11, 12 } } }; +struct A e[] = { 0, 1, 2, [2] = 10, 11, 12 }; +struct A f[] = { 0, 1, 2, [2].C = 11, 12, 13 }; +struct A g[] = { 0, 1, 2, [2].C[1] = 12, 13, 14 }; +struct A h[] = { 0, 1, 2, [2] = { .C[1] = 12 }, 13, 14 }; +struct A i[] = { 0, 1, 2, [2] = { .C = { [1] = 12 } }, 13, 14 }; +union D { + int E; + double F; + struct A G; +}; +union D j[] = { [4] = 1, [4].F = 1.0, [1].G.C[1] = 4 }; +struct H { + char I[6]; + int J; +} k[] = { { { "foo" }, 1 }, [0].I[0] = 'b' }; +struct K { + wchar_t L[6]; + int M; +} l[] = { { { L"foo" }, 1 }, [0].L[2] = L'x', [0].L[4] = L'y' }; +struct H m[] = { { { "foo" }, 1 }, [0] = { .I[0] = 'b' } }; +struct H n[] = { { { "foo" }, 1 }, [0].I = { "a" }, [0].J = 2 }; +int o = { 22 }; + +int main (void) +{ + if (b[3]) + abort (); + b[3] = 13; + if (memcmp (a, b, sizeof (a)) || memcmp (a, c, sizeof (a))) + abort (); + if (memcmp (d, e, sizeof (d)) || sizeof (d) != sizeof (e)) + abort (); + if (f[2].B != 0 || g[2].B != 0 || g[2].C[0] != 0) + abort (); + if (memcmp (g, h, sizeof (g)) || memcmp (g, i, sizeof (g))) + abort (); + f[2].B = 10; + g[2].B = 10; + g[2].C[0] = 11; + if (memcmp (d, f, sizeof (d)) || memcmp (d, g, sizeof (d))) + abort (); + if (f[3].B != 13 || g[3].B != 13 || g[3].C[0] != 14) + abort (); + if (j[0].E || j[1].G.B || j[1].G.C[0] || j[1].G.C[1] != 4) + abort (); + if (j[2].E || j[3].E || j[4].F != 1.0) + abort (); + if (memcmp (k[0].I, "boo\0\0", 6) || k[0].J != 1) + abort (); + if (memcmp (l[0].L, L"fox\0y", 6 * sizeof(wchar_t)) || l[0].M != 1) + abort (); + if (memcmp (m[0].I, "b\0\0\0\0", 6) || m[0].J) + abort (); + if (memcmp (n[0].I, "a\0\0\0\0", 6) || n[0].J != 2) + abort (); + if (o != 22) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-init-2.c b/SingleSource/Regression/C/gcc-dg/c99-init-2.c new file mode 100644 index 0000000000..c07005be24 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-init-2.c @@ -0,0 +1,30 @@ +/* Test for C99 designated initializer warnings and errors */ +/* Origin: Jakub Jelinek */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -Wall -pedantic-errors" } */ + +typedef struct { + int B; + short C[2]; +} A; +A a = { [2] = 1 }; /* { dg-error "(array index in non-array)|(near initialization)" } */ +int b[] = { .B = 1 }; /* { dg-error "(field name not in record)|(near initialization)" } */ +A c[] = { [0].D = 1 }; /* { dg-error "15: has no member named .D." } */ +int d; +int e = { d++ }; /* { dg-error "(is not constant)|(near initialization)" } */ +A f[2] = { [0].C[0] = 1, [2] = { 2, { 1, 2 } } };/* { dg-error "(array index in initializer exceeds array bounds)|(near initialization)" } */ +int g[4] = { [1] = 1, 2, [6] = 5 }; /* { dg-error "(array index in initializer exceeds array bounds)|(near initialization)" } */ +int h[] = { [0 ... 3] = 5 }; /* { dg-error "forbids specifying range of elements" } */ +int i[] = { [2] 4 }; /* { dg-error "use of designated initializer without" } */ +A j = { B: 2 }; /* { dg-error "use of designated initializer with " } */ + +void foo (int *, A *); + +void bar (void) +{ + int a[] = { d++, [0] = 1 }; /* { dg-warning "(initialized field with side-effects overwritten)|(near initialization)" } */ + A b = { 1, { d++, 2 }, .C[0] = 3 };/* { dg-warning "(initialized field with side-effects overwritten)|(near initialization)" } */ + A c = { d++, { 2, 3 }, .B = 4 }; /* { dg-warning "(initialized field with side-effects overwritten)|(near initialization)" } */ + + foo (a, d ? &b : &c); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-init-3.c b/SingleSource/Regression/C/gcc-dg/c99-init-3.c new file mode 100644 index 0000000000..8bc6d2c10e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-init-3.c @@ -0,0 +1,8 @@ +/* Test for designated initializers: array designators must be of + integer type. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +int a[] = { [(void *)0] = 1 }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "integer type|near init" "pointer designator" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-init-4.c b/SingleSource/Regression/C/gcc-dg/c99-init-4.c new file mode 100644 index 0000000000..7073557858 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-init-4.c @@ -0,0 +1,8 @@ +/* Test for nested initialization of a compound literal: must not be + checked against outer array bounds. Bug 19435. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { char *p; }; +struct s a[1] = { { .p = ((char []){ 1, 2 }) } }; diff --git a/SingleSource/Regression/C/gcc-dg/c99-init-5.c b/SingleSource/Regression/C/gcc-dg/c99-init-5.c new file mode 100644 index 0000000000..17bacd90c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-init-5.c @@ -0,0 +1,9 @@ +/* Test for designated initializers: string constants used with + designator in character array should not initialize the array as a + whole. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +char g[] = { [7] = "abcd" }; /* { dg-error "initial" } */ +char h[10][10] = { [1][1] = "abcd" }; /* { dg-error "initial" } */ +char i[10][10] = { [1] = "abcd" }; diff --git a/SingleSource/Regression/C/gcc-dg/c99-init-6.c b/SingleSource/Regression/C/gcc-dg/c99-init-6.c new file mode 100644 index 0000000000..6328f82676 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-init-6.c @@ -0,0 +1,6 @@ +/* Test for designated initializers: invalid uses of string constants + should not ICE. PR 42262. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +int a[] = { [0 ... 1] = "", [0] = "" }; /* { dg-error "initial" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-intconst-1.c b/SingleSource/Regression/C/gcc-dg/c99-intconst-1.c new file mode 100644 index 0000000000..629b0bcac2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-intconst-1.c @@ -0,0 +1,639 @@ +/* Test for integer constant types. */ + +/* Origin: Joseph Myers . */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#include + +/* Assertion that constant C is of type T. */ +#define ASSERT_CONST_TYPE(C, T) \ + do { \ + typedef T type; \ + typedef type **typepp; \ + typedef __typeof__((C)) ctype; \ + typedef ctype **ctypepp; \ + typepp x = 0; \ + ctypepp y = 0; \ + x = y; \ + y = x; \ + } while (0) + +/* (T *) if E is zero, (void *) otherwise. */ +#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E)) + +/* (T *) if E is nonzero, (void *) otherwise. */ +#define type_if(T, E) type_if_not(T, !(E)) + +/* Combine pointer types, all but one (void *). */ +#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0) +#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3)) +#define type_comb4(T1, T2, T3, T4) \ + type_comb2(T1, type_comb2(T2, type_comb2(T3, T4))) +#define type_comb6(T1, T2, T3, T4, T5, T6) \ + type_comb2(T1, \ + type_comb2(T2, \ + type_comb2(T3, \ + type_comb2(T4, \ + type_comb2(T5, T6))))) + +/* (T1 *) if E1, otherwise (T2 *) if E2. */ +#define first_of2p(T1, E1, T2, E2) type_comb2(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2)))) +/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3. */ +#define first_of3p(T1, E1, T2, E2, T3, E3) \ + type_comb3(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2))), \ + type_if(T3, (!(E1) && !(E2) && (E3)))) +/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3, otherwise + (T4 *) if E4. */ +#define first_of4p(T1, E1, T2, E2, T3, E3, T4, E4) \ + type_comb4(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2))), \ + type_if(T3, (!(E1) && !(E2) && (E3))), \ + type_if(T4, (!(E1) && !(E2) && !(E3) && (E4)))) +/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3, otherwise + (T4 *) if E4, otherwise (T5 *) if E5, otherwise (T6 *) if E6. */ +#define first_of6p(T1, E1, T2, E2, T3, E3, T4, E4, T5, E5, T6, E6) \ + type_comb6(type_if(T1, (E1)), \ + type_if(T2, (!(E1) && (E2))), \ + type_if(T3, (!(E1) && !(E2) && (E3))), \ + type_if(T4, (!(E1) && !(E2) && !(E3) && (E4))), \ + type_if(T5, (!(E1) && !(E2) && !(E3) && !(E4) && (E5))), \ + type_if(T6, (!(E1) && !(E2) && !(E3) \ + && !(E4) && !(E5) && (E6)))) + +/* Likewise, but return the original type rather than a pointer type. */ +#define first_of2(T1, E1, T2, E2) \ + __typeof__(*((first_of2p(T1, (E1), T2, (E2)))0)) +#define first_of3(T1, E1, T2, E2, T3, E3) \ + __typeof__(*((first_of3p(T1, (E1), T2, (E2), T3, (E3)))0)) +#define first_of4(T1, E1, T2, E2, T3, E3, T4, E4) \ + __typeof__(*((first_of4p(T1, (E1), T2, (E2), T3, (E3), T4, (E4)))0)) +#define first_of6(T1, E1, T2, E2, T3, E3, T4, E4, T5, E5, T6, E6) \ + __typeof__(*((first_of6p(T1, (E1), T2, (E2), T3, (E3), \ + T4, (E4), T5, (E5), T6, (E6)))0)) + +/* Types of constants according to the C99 rules. */ +#define C99_UNSUF_DEC_TYPE(C) \ + first_of3(int, (C) <= INT_MAX, \ + long int, (C) <= LONG_MAX, \ + long long int, (C) <= LLONG_MAX) +#define C99_UNSUF_OCTHEX_TYPE(C) \ + first_of6(int, (C) <= INT_MAX, \ + unsigned int, (C) <= UINT_MAX, \ + long int, (C) <= LONG_MAX, \ + unsigned long int, (C) <= ULONG_MAX, \ + long long int, (C) <= LLONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) +#define C99_SUFu_TYPE(C) \ + first_of3(unsigned int, (C) <= UINT_MAX, \ + unsigned long int, (C) <= ULONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) +#define C99_SUFl_DEC_TYPE(C) \ + first_of2(long int, (C) <= LONG_MAX, \ + long long int, (C) <= LLONG_MAX) +#define C99_SUFl_OCTHEX_TYPE(C) \ + first_of4(long int, (C) <= LONG_MAX, \ + unsigned long int, (C) <= ULONG_MAX, \ + long long int, (C) <= LLONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) +#define C99_SUFul_TYPE(C) \ + first_of2(unsigned long int, (C) <= ULONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) +#define C99_SUFll_OCTHEX_TYPE(C) \ + first_of2(long long int, (C) <= LLONG_MAX, \ + unsigned long long int, (C) <= ULLONG_MAX) + +/* Checks that constants have correct type. */ +#define CHECK_UNSUF_DEC_TYPE(C) ASSERT_CONST_TYPE((C), C99_UNSUF_DEC_TYPE((C))) +#define CHECK_UNSUF_OCTHEX_TYPE(C) \ + ASSERT_CONST_TYPE((C), C99_UNSUF_OCTHEX_TYPE((C))) +#define CHECK_SUFu_TYPE(C) ASSERT_CONST_TYPE((C), C99_SUFu_TYPE((C))) +#define CHECK_SUFl_DEC_TYPE(C) ASSERT_CONST_TYPE((C), C99_SUFl_DEC_TYPE((C))) +#define CHECK_SUFl_OCTHEX_TYPE(C) \ + ASSERT_CONST_TYPE((C), C99_SUFl_OCTHEX_TYPE((C))) +#define CHECK_SUFul_TYPE(C) ASSERT_CONST_TYPE((C), C99_SUFul_TYPE((C))) +#define CHECK_SUFll_DEC_TYPE(C) ASSERT_CONST_TYPE((C), long long int) +#define CHECK_SUFll_OCTHEX_TYPE(C) \ + ASSERT_CONST_TYPE((C), C99_SUFll_OCTHEX_TYPE((C))) +#define CHECK_SUFull_TYPE(C) ASSERT_CONST_TYPE((C), unsigned long long int) + +/* Check a decimal value, with all suffixes. */ +#define CHECK_DEC_CONST(C) \ + CHECK_UNSUF_DEC_TYPE(C); \ + CHECK_SUFu_TYPE(C##u); \ + CHECK_SUFu_TYPE(C##U); \ + CHECK_SUFl_DEC_TYPE(C##l); \ + CHECK_SUFl_DEC_TYPE(C##L); \ + CHECK_SUFul_TYPE(C##ul); \ + CHECK_SUFul_TYPE(C##uL); \ + CHECK_SUFul_TYPE(C##Ul); \ + CHECK_SUFul_TYPE(C##UL); \ + CHECK_SUFll_DEC_TYPE(C##ll); \ + CHECK_SUFll_DEC_TYPE(C##LL); \ + CHECK_SUFull_TYPE(C##ull); \ + CHECK_SUFull_TYPE(C##uLL); \ + CHECK_SUFull_TYPE(C##Ull); \ + CHECK_SUFull_TYPE(C##ULL); + +/* Check an octal or hexadecimal value, with all suffixes. */ +#define CHECK_OCTHEX_CONST(C) \ + CHECK_UNSUF_OCTHEX_TYPE(C); \ + CHECK_SUFu_TYPE(C##u); \ + CHECK_SUFu_TYPE(C##U); \ + CHECK_SUFl_OCTHEX_TYPE(C##l); \ + CHECK_SUFl_OCTHEX_TYPE(C##L); \ + CHECK_SUFul_TYPE(C##ul); \ + CHECK_SUFul_TYPE(C##uL); \ + CHECK_SUFul_TYPE(C##Ul); \ + CHECK_SUFul_TYPE(C##UL); \ + CHECK_SUFll_OCTHEX_TYPE(C##ll); \ + CHECK_SUFll_OCTHEX_TYPE(C##LL); \ + CHECK_SUFull_TYPE(C##ull); \ + CHECK_SUFull_TYPE(C##uLL); \ + CHECK_SUFull_TYPE(C##Ull); \ + CHECK_SUFull_TYPE(C##ULL); + +#define CHECK_OCT_CONST(C) CHECK_OCTHEX_CONST(C) +#define CHECK_HEX_CONST(C) \ + CHECK_OCTHEX_CONST(0x##C); \ + CHECK_OCTHEX_CONST(0X##C); + +/* True iff "long long" is at least B bits. This presumes that (B-2)/3 is at + most 63. */ +#define LLONG_AT_LEAST(B) \ + (LLONG_MAX >> ((B)-2)/3 >> ((B)-2)/3 \ + >> ((B)-2 - ((B)-2)/3 - ((B)-2)/3)) + +#define LLONG_HAS_BITS(B) (LLONG_AT_LEAST((B)) && !LLONG_AT_LEAST((B) + 1)) + +void +foo (void) +{ + /* Decimal. */ + /* Check all 2^n and 2^n - 1 up to 2^71 - 1. */ + CHECK_DEC_CONST(1); + CHECK_DEC_CONST(2); + CHECK_DEC_CONST(3); + CHECK_DEC_CONST(4); + CHECK_DEC_CONST(7); + CHECK_DEC_CONST(8); + CHECK_DEC_CONST(15); + CHECK_DEC_CONST(16); + CHECK_DEC_CONST(31); + CHECK_DEC_CONST(32); + CHECK_DEC_CONST(63); + CHECK_DEC_CONST(64); + CHECK_DEC_CONST(127); + CHECK_DEC_CONST(128); + CHECK_DEC_CONST(255); + CHECK_DEC_CONST(256); + CHECK_DEC_CONST(511); + CHECK_DEC_CONST(512); + CHECK_DEC_CONST(1023); + CHECK_DEC_CONST(1024); + CHECK_DEC_CONST(2047); + CHECK_DEC_CONST(2048); + CHECK_DEC_CONST(4095); + CHECK_DEC_CONST(4096); + CHECK_DEC_CONST(8191); + CHECK_DEC_CONST(8192); + CHECK_DEC_CONST(16383); + CHECK_DEC_CONST(16384); + CHECK_DEC_CONST(32767); + CHECK_DEC_CONST(32768); + CHECK_DEC_CONST(65535); + CHECK_DEC_CONST(65536); + CHECK_DEC_CONST(131071); + CHECK_DEC_CONST(131072); + CHECK_DEC_CONST(262143); + CHECK_DEC_CONST(262144); + CHECK_DEC_CONST(524287); + CHECK_DEC_CONST(524288); + CHECK_DEC_CONST(1048575); + CHECK_DEC_CONST(1048576); + CHECK_DEC_CONST(2097151); + CHECK_DEC_CONST(2097152); + CHECK_DEC_CONST(4194303); + CHECK_DEC_CONST(4194304); + CHECK_DEC_CONST(8388607); + CHECK_DEC_CONST(8388608); + CHECK_DEC_CONST(16777215); + CHECK_DEC_CONST(16777216); + CHECK_DEC_CONST(33554431); + CHECK_DEC_CONST(33554432); + CHECK_DEC_CONST(67108863); + CHECK_DEC_CONST(67108864); + CHECK_DEC_CONST(134217727); + CHECK_DEC_CONST(134217728); + CHECK_DEC_CONST(268435455); + CHECK_DEC_CONST(268435456); + CHECK_DEC_CONST(536870911); + CHECK_DEC_CONST(536870912); + CHECK_DEC_CONST(1073741823); + CHECK_DEC_CONST(1073741824); + CHECK_DEC_CONST(2147483647); + CHECK_DEC_CONST(2147483648); + CHECK_DEC_CONST(4294967295); + CHECK_DEC_CONST(4294967296); + CHECK_DEC_CONST(8589934591); + CHECK_DEC_CONST(8589934592); + CHECK_DEC_CONST(17179869183); + CHECK_DEC_CONST(17179869184); + CHECK_DEC_CONST(34359738367); + CHECK_DEC_CONST(34359738368); + CHECK_DEC_CONST(68719476735); + CHECK_DEC_CONST(68719476736); + CHECK_DEC_CONST(137438953471); + CHECK_DEC_CONST(137438953472); + CHECK_DEC_CONST(274877906943); + CHECK_DEC_CONST(274877906944); + CHECK_DEC_CONST(549755813887); + CHECK_DEC_CONST(549755813888); + CHECK_DEC_CONST(1099511627775); + CHECK_DEC_CONST(1099511627776); + CHECK_DEC_CONST(2199023255551); + CHECK_DEC_CONST(2199023255552); + CHECK_DEC_CONST(4398046511103); + CHECK_DEC_CONST(4398046511104); + CHECK_DEC_CONST(8796093022207); + CHECK_DEC_CONST(8796093022208); + CHECK_DEC_CONST(17592186044415); + CHECK_DEC_CONST(17592186044416); + CHECK_DEC_CONST(35184372088831); + CHECK_DEC_CONST(35184372088832); + CHECK_DEC_CONST(70368744177663); + CHECK_DEC_CONST(70368744177664); + CHECK_DEC_CONST(140737488355327); + CHECK_DEC_CONST(140737488355328); + CHECK_DEC_CONST(281474976710655); + CHECK_DEC_CONST(281474976710656); + CHECK_DEC_CONST(562949953421311); + CHECK_DEC_CONST(562949953421312); + CHECK_DEC_CONST(1125899906842623); + CHECK_DEC_CONST(1125899906842624); + CHECK_DEC_CONST(2251799813685247); + CHECK_DEC_CONST(2251799813685248); + CHECK_DEC_CONST(4503599627370495); + CHECK_DEC_CONST(4503599627370496); + CHECK_DEC_CONST(9007199254740991); + CHECK_DEC_CONST(9007199254740992); + CHECK_DEC_CONST(18014398509481983); + CHECK_DEC_CONST(18014398509481984); + CHECK_DEC_CONST(36028797018963967); + CHECK_DEC_CONST(36028797018963968); + CHECK_DEC_CONST(72057594037927935); + CHECK_DEC_CONST(72057594037927936); + CHECK_DEC_CONST(144115188075855871); + CHECK_DEC_CONST(144115188075855872); + CHECK_DEC_CONST(288230376151711743); + CHECK_DEC_CONST(288230376151711744); + CHECK_DEC_CONST(576460752303423487); + CHECK_DEC_CONST(576460752303423488); + CHECK_DEC_CONST(1152921504606846975); + CHECK_DEC_CONST(1152921504606846976); + CHECK_DEC_CONST(2305843009213693951); + CHECK_DEC_CONST(2305843009213693952); + CHECK_DEC_CONST(4611686018427387903); + CHECK_DEC_CONST(4611686018427387904); + CHECK_DEC_CONST(9223372036854775807); +#if LLONG_AT_LEAST(65) + CHECK_DEC_CONST(9223372036854775808); + CHECK_DEC_CONST(18446744073709551615); +#endif +#if LLONG_AT_LEAST(66) + CHECK_DEC_CONST(18446744073709551616); + CHECK_DEC_CONST(36893488147419103231); +#endif +#if LLONG_AT_LEAST(67) + CHECK_DEC_CONST(36893488147419103232); + CHECK_DEC_CONST(73786976294838206463); +#endif +#if LLONG_AT_LEAST(68) + CHECK_DEC_CONST(73786976294838206464); + CHECK_DEC_CONST(147573952589676412927); +#endif +#if LLONG_AT_LEAST(69) + CHECK_DEC_CONST(147573952589676412928); + CHECK_DEC_CONST(295147905179352825855); +#endif +#if LLONG_AT_LEAST(70) + CHECK_DEC_CONST(295147905179352825856); + CHECK_DEC_CONST(590295810358705651711); +#endif +#if LLONG_AT_LEAST(71) + CHECK_DEC_CONST(590295810358705651712); + CHECK_DEC_CONST(1180591620717411303423); +#endif +#if LLONG_AT_LEAST(72) + CHECK_DEC_CONST(1180591620717411303424); + CHECK_DEC_CONST(2361183241434822606847); +#endif + /* Octal and hexadecimal. */ + /* Check all 2^n and 2^n - 1 up to 2^72 - 1. */ + CHECK_OCT_CONST(0); + CHECK_HEX_CONST(0); + CHECK_OCT_CONST(01); + CHECK_HEX_CONST(1); + CHECK_OCT_CONST(02); + CHECK_HEX_CONST(2); + CHECK_OCT_CONST(03); + CHECK_HEX_CONST(3); + CHECK_OCT_CONST(04); + CHECK_HEX_CONST(4); + CHECK_OCT_CONST(07); + CHECK_HEX_CONST(7); + CHECK_OCT_CONST(010); + CHECK_HEX_CONST(8); + CHECK_OCT_CONST(017); + CHECK_HEX_CONST(f); + CHECK_OCT_CONST(020); + CHECK_HEX_CONST(10); + CHECK_OCT_CONST(037); + CHECK_HEX_CONST(1f); + CHECK_OCT_CONST(040); + CHECK_HEX_CONST(20); + CHECK_OCT_CONST(077); + CHECK_HEX_CONST(3f); + CHECK_OCT_CONST(0100); + CHECK_HEX_CONST(40); + CHECK_OCT_CONST(0177); + CHECK_HEX_CONST(7f); + CHECK_OCT_CONST(0200); + CHECK_HEX_CONST(80); + CHECK_OCT_CONST(0377); + CHECK_HEX_CONST(ff); + CHECK_OCT_CONST(0400); + CHECK_HEX_CONST(100); + CHECK_OCT_CONST(0777); + CHECK_HEX_CONST(1ff); + CHECK_OCT_CONST(01000); + CHECK_HEX_CONST(200); + CHECK_OCT_CONST(01777); + CHECK_HEX_CONST(3ff); + CHECK_OCT_CONST(02000); + CHECK_HEX_CONST(400); + CHECK_OCT_CONST(03777); + CHECK_HEX_CONST(7ff); + CHECK_OCT_CONST(04000); + CHECK_HEX_CONST(800); + CHECK_OCT_CONST(07777); + CHECK_HEX_CONST(fff); + CHECK_OCT_CONST(010000); + CHECK_HEX_CONST(1000); + CHECK_OCT_CONST(017777); + CHECK_HEX_CONST(1fff); + CHECK_OCT_CONST(020000); + CHECK_HEX_CONST(2000); + CHECK_OCT_CONST(037777); + CHECK_HEX_CONST(3fff); + CHECK_OCT_CONST(040000); + CHECK_HEX_CONST(4000); + CHECK_OCT_CONST(077777); + CHECK_HEX_CONST(7fff); + CHECK_OCT_CONST(0100000); + CHECK_HEX_CONST(8000); + CHECK_OCT_CONST(0177777); + CHECK_HEX_CONST(ffff); + CHECK_OCT_CONST(0200000); + CHECK_HEX_CONST(10000); + CHECK_OCT_CONST(0377777); + CHECK_HEX_CONST(1ffff); + CHECK_OCT_CONST(0400000); + CHECK_HEX_CONST(20000); + CHECK_OCT_CONST(0777777); + CHECK_HEX_CONST(3ffff); + CHECK_OCT_CONST(01000000); + CHECK_HEX_CONST(40000); + CHECK_OCT_CONST(01777777); + CHECK_HEX_CONST(7ffff); + CHECK_OCT_CONST(02000000); + CHECK_HEX_CONST(80000); + CHECK_OCT_CONST(03777777); + CHECK_HEX_CONST(fffff); + CHECK_OCT_CONST(04000000); + CHECK_HEX_CONST(100000); + CHECK_OCT_CONST(07777777); + CHECK_HEX_CONST(1fffff); + CHECK_OCT_CONST(010000000); + CHECK_HEX_CONST(200000); + CHECK_OCT_CONST(017777777); + CHECK_HEX_CONST(3fffff); + CHECK_OCT_CONST(020000000); + CHECK_HEX_CONST(400000); + CHECK_OCT_CONST(037777777); + CHECK_HEX_CONST(7fffff); + CHECK_OCT_CONST(040000000); + CHECK_HEX_CONST(800000); + CHECK_OCT_CONST(077777777); + CHECK_HEX_CONST(ffffff); + CHECK_OCT_CONST(0100000000); + CHECK_HEX_CONST(1000000); + CHECK_OCT_CONST(0177777777); + CHECK_HEX_CONST(1ffffff); + CHECK_OCT_CONST(0200000000); + CHECK_HEX_CONST(2000000); + CHECK_OCT_CONST(0377777777); + CHECK_HEX_CONST(3ffffff); + CHECK_OCT_CONST(0400000000); + CHECK_HEX_CONST(4000000); + CHECK_OCT_CONST(0777777777); + CHECK_HEX_CONST(7ffffff); + CHECK_OCT_CONST(01000000000); + CHECK_HEX_CONST(8000000); + CHECK_OCT_CONST(01777777777); + CHECK_HEX_CONST(fffffff); + CHECK_OCT_CONST(02000000000); + CHECK_HEX_CONST(10000000); + CHECK_OCT_CONST(03777777777); + CHECK_HEX_CONST(1fffffff); + CHECK_OCT_CONST(04000000000); + CHECK_HEX_CONST(20000000); + CHECK_OCT_CONST(07777777777); + CHECK_HEX_CONST(3fffffff); + CHECK_OCT_CONST(010000000000); + CHECK_HEX_CONST(40000000); + CHECK_OCT_CONST(017777777777); + CHECK_HEX_CONST(7fffffff); + CHECK_OCT_CONST(020000000000); + CHECK_HEX_CONST(80000000); + CHECK_OCT_CONST(037777777777); + CHECK_HEX_CONST(ffffffff); + CHECK_OCT_CONST(040000000000); + CHECK_HEX_CONST(100000000); + CHECK_OCT_CONST(077777777777); + CHECK_HEX_CONST(1ffffffff); + CHECK_OCT_CONST(0100000000000); + CHECK_HEX_CONST(200000000); + CHECK_OCT_CONST(0177777777777); + CHECK_HEX_CONST(3ffffffff); + CHECK_OCT_CONST(0200000000000); + CHECK_HEX_CONST(400000000); + CHECK_OCT_CONST(0377777777777); + CHECK_HEX_CONST(7ffffffff); + CHECK_OCT_CONST(0400000000000); + CHECK_HEX_CONST(800000000); + CHECK_OCT_CONST(0777777777777); + CHECK_HEX_CONST(fffffffff); + CHECK_OCT_CONST(01000000000000); + CHECK_HEX_CONST(1000000000); + CHECK_OCT_CONST(01777777777777); + CHECK_HEX_CONST(1fffffffff); + CHECK_OCT_CONST(02000000000000); + CHECK_HEX_CONST(2000000000); + CHECK_OCT_CONST(03777777777777); + CHECK_HEX_CONST(3fffffffff); + CHECK_OCT_CONST(04000000000000); + CHECK_HEX_CONST(4000000000); + CHECK_OCT_CONST(07777777777777); + CHECK_HEX_CONST(7fffffffff); + CHECK_OCT_CONST(010000000000000); + CHECK_HEX_CONST(8000000000); + CHECK_OCT_CONST(017777777777777); + CHECK_HEX_CONST(ffffffffff); + CHECK_OCT_CONST(020000000000000); + CHECK_HEX_CONST(10000000000); + CHECK_OCT_CONST(037777777777777); + CHECK_HEX_CONST(1ffffffffff); + CHECK_OCT_CONST(040000000000000); + CHECK_HEX_CONST(20000000000); + CHECK_OCT_CONST(077777777777777); + CHECK_HEX_CONST(3ffffffffff); + CHECK_OCT_CONST(0100000000000000); + CHECK_HEX_CONST(40000000000); + CHECK_OCT_CONST(0177777777777777); + CHECK_HEX_CONST(7ffffffffff); + CHECK_OCT_CONST(0200000000000000); + CHECK_HEX_CONST(80000000000); + CHECK_OCT_CONST(0377777777777777); + CHECK_HEX_CONST(fffffffffff); + CHECK_OCT_CONST(0400000000000000); + CHECK_HEX_CONST(100000000000); + CHECK_OCT_CONST(0777777777777777); + CHECK_HEX_CONST(1fffffffffff); + CHECK_OCT_CONST(01000000000000000); + CHECK_HEX_CONST(200000000000); + CHECK_OCT_CONST(01777777777777777); + CHECK_HEX_CONST(3fffffffffff); + CHECK_OCT_CONST(02000000000000000); + CHECK_HEX_CONST(400000000000); + CHECK_OCT_CONST(03777777777777777); + CHECK_HEX_CONST(7fffffffffff); + CHECK_OCT_CONST(04000000000000000); + CHECK_HEX_CONST(800000000000); + CHECK_OCT_CONST(07777777777777777); + CHECK_HEX_CONST(ffffffffffff); + CHECK_OCT_CONST(010000000000000000); + CHECK_HEX_CONST(1000000000000); + CHECK_OCT_CONST(017777777777777777); + CHECK_HEX_CONST(1ffffffffffff); + CHECK_OCT_CONST(020000000000000000); + CHECK_HEX_CONST(2000000000000); + CHECK_OCT_CONST(037777777777777777); + CHECK_HEX_CONST(3ffffffffffff); + CHECK_OCT_CONST(040000000000000000); + CHECK_HEX_CONST(4000000000000); + CHECK_OCT_CONST(077777777777777777); + CHECK_HEX_CONST(7ffffffffffff); + CHECK_OCT_CONST(0100000000000000000); + CHECK_HEX_CONST(8000000000000); + CHECK_OCT_CONST(0177777777777777777); + CHECK_HEX_CONST(fffffffffffff); + CHECK_OCT_CONST(0200000000000000000); + CHECK_HEX_CONST(10000000000000); + CHECK_OCT_CONST(0377777777777777777); + CHECK_HEX_CONST(1fffffffffffff); + CHECK_OCT_CONST(0400000000000000000); + CHECK_HEX_CONST(20000000000000); + CHECK_OCT_CONST(0777777777777777777); + CHECK_HEX_CONST(3fffffffffffff); + CHECK_OCT_CONST(01000000000000000000); + CHECK_HEX_CONST(40000000000000); + CHECK_OCT_CONST(01777777777777777777); + CHECK_HEX_CONST(7fffffffffffff); + CHECK_OCT_CONST(02000000000000000000); + CHECK_HEX_CONST(80000000000000); + CHECK_OCT_CONST(03777777777777777777); + CHECK_HEX_CONST(ffffffffffffff); + CHECK_OCT_CONST(04000000000000000000); + CHECK_HEX_CONST(100000000000000); + CHECK_OCT_CONST(07777777777777777777); + CHECK_HEX_CONST(1ffffffffffffff); + CHECK_OCT_CONST(010000000000000000000); + CHECK_HEX_CONST(200000000000000); + CHECK_OCT_CONST(017777777777777777777); + CHECK_HEX_CONST(3ffffffffffffff); + CHECK_OCT_CONST(020000000000000000000); + CHECK_HEX_CONST(400000000000000); + CHECK_OCT_CONST(037777777777777777777); + CHECK_HEX_CONST(7ffffffffffffff); + CHECK_OCT_CONST(040000000000000000000); + CHECK_HEX_CONST(800000000000000); + CHECK_OCT_CONST(077777777777777777777); + CHECK_HEX_CONST(fffffffffffffff); + CHECK_OCT_CONST(0100000000000000000000); + CHECK_HEX_CONST(1000000000000000); + CHECK_OCT_CONST(0177777777777777777777); + CHECK_HEX_CONST(1fffffffffffffff); + CHECK_OCT_CONST(0200000000000000000000); + CHECK_HEX_CONST(2000000000000000); + CHECK_OCT_CONST(0377777777777777777777); + CHECK_HEX_CONST(3fffffffffffffff); + CHECK_OCT_CONST(0400000000000000000000); + CHECK_HEX_CONST(4000000000000000); + CHECK_OCT_CONST(0777777777777777777777); + CHECK_HEX_CONST(7fffffffffffffff); + CHECK_OCT_CONST(01000000000000000000000); + CHECK_HEX_CONST(8000000000000000); + CHECK_OCT_CONST(01777777777777777777777); + CHECK_HEX_CONST(ffffffffffffffff); +#if LLONG_AT_LEAST(65) + CHECK_OCT_CONST(02000000000000000000000); + CHECK_HEX_CONST(10000000000000000); + CHECK_OCT_CONST(03777777777777777777777); + CHECK_HEX_CONST(1ffffffffffffffff); +#endif +#if LLONG_AT_LEAST(66) + CHECK_OCT_CONST(04000000000000000000000); + CHECK_HEX_CONST(20000000000000000); + CHECK_OCT_CONST(07777777777777777777777); + CHECK_HEX_CONST(3ffffffffffffffff); +#endif +#if LLONG_AT_LEAST(67) + CHECK_OCT_CONST(010000000000000000000000); + CHECK_HEX_CONST(40000000000000000); + CHECK_OCT_CONST(017777777777777777777777); + CHECK_HEX_CONST(7ffffffffffffffff); +#endif +#if LLONG_AT_LEAST(68) + CHECK_OCT_CONST(020000000000000000000000); + CHECK_HEX_CONST(80000000000000000); + CHECK_OCT_CONST(037777777777777777777777); + CHECK_HEX_CONST(fffffffffffffffff); +#endif +#if LLONG_AT_LEAST(69) + CHECK_OCT_CONST(040000000000000000000000); + CHECK_HEX_CONST(100000000000000000); + CHECK_OCT_CONST(077777777777777777777777); + CHECK_HEX_CONST(1fffffffffffffffff); +#endif +#if LLONG_AT_LEAST(70) + CHECK_OCT_CONST(0100000000000000000000000); + CHECK_HEX_CONST(200000000000000000); + CHECK_OCT_CONST(0177777777777777777777777); + CHECK_HEX_CONST(3fffffffffffffffff); +#endif +#if LLONG_AT_LEAST(71) + CHECK_OCT_CONST(0200000000000000000000000); + CHECK_HEX_CONST(400000000000000000); + CHECK_OCT_CONST(0377777777777777777777777); + CHECK_HEX_CONST(7fffffffffffffffff); +#endif +#if LLONG_AT_LEAST(72) + CHECK_OCT_CONST(0400000000000000000000000); + CHECK_HEX_CONST(800000000000000000); + CHECK_OCT_CONST(0777777777777777777777777); + CHECK_HEX_CONST(ffffffffffffffffff); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-intconst-2.c b/SingleSource/Regression/C/gcc-dg/c99-intconst-2.c new file mode 100644 index 0000000000..3492367576 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-intconst-2.c @@ -0,0 +1,8 @@ +/* Test for integer constant types: diagnostics for constants outside + range of intmax_t must be pedwarns. PR 39559. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#if 9223372036854775808LL /* { dg-error "integer constant is so large that it is unsigned" } */ +unsigned long long l = 9223372036854775808LL; /* { dg-error "integer constant is so large that it is unsigned" } */ +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c99-intprom-1.c b/SingleSource/Regression/C/gcc-dg/c99-intprom-1.c new file mode 100644 index 0000000000..0d7a33ee8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-intprom-1.c @@ -0,0 +1,77 @@ +/* Test for integer promotion rules: extended to long long by C99. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#include + +#define CHECK(T1, T2, TC) \ + do { \ + T1 a = 0; \ + T2 b = 0; \ + TC *c = 0; \ + __typeof__(a+b) *d = 0; \ + c = d; \ + d = c; \ + } while (0) + +void +f (void) +{ + /* Same type. */ + CHECK(int, int, int); + CHECK(unsigned int, unsigned int, unsigned int); + CHECK(long, long, long); + CHECK(unsigned long, unsigned long, unsigned long); + CHECK(long long, long long, long long); + CHECK(unsigned long long, unsigned long long, unsigned long long); + /* Both signed. */ + CHECK(int, long, long); + CHECK(int, long long, long long); + CHECK(long, int, long); + CHECK(long, long long, long long); + CHECK(long long, int, long long); + CHECK(long long, long, long long); + /* Both unsigned. */ + CHECK(unsigned int, unsigned long, unsigned long); + CHECK(unsigned int, unsigned long long, unsigned long long); + CHECK(unsigned long, unsigned int, unsigned long); + CHECK(unsigned long, unsigned long long, unsigned long long); + CHECK(unsigned long long, unsigned int, unsigned long long); + CHECK(unsigned long long, unsigned long, unsigned long long); + /* Unsigned of greater or equal rank. */ + CHECK(int, unsigned int, unsigned int); + CHECK(int, unsigned long, unsigned long); + CHECK(int, unsigned long long, unsigned long long); + CHECK(unsigned int, int, unsigned int); + CHECK(long, unsigned long, unsigned long); + CHECK(long, unsigned long long, unsigned long long); + CHECK(unsigned long, int, unsigned long); + CHECK(unsigned long, long, unsigned long); + CHECK(long long, unsigned long long, unsigned long long); + CHECK(unsigned long long, int, unsigned long long); + CHECK(unsigned long long, long, unsigned long long); + CHECK(unsigned long long, long long, unsigned long long); + /* Signed of greater rank. */ +#if LONG_MAX >= UINT_MAX + CHECK(unsigned int, long, long); + CHECK(long, unsigned int, long); +#else + CHECK(unsigned int, long, unsigned long); + CHECK(long, unsigned int, unsigned long); +#endif +#if LLONG_MAX >= UINT_MAX + CHECK(unsigned int, long long, long long); + CHECK(long long, unsigned int, long long); +#else + CHECK(unsigned int, long long, unsigned long long); + CHECK(long long, unsigned int, unsigned long long); +#endif +#if LLONG_MAX >= ULONG_MAX + CHECK(unsigned long, long long, long long); + CHECK(long long, unsigned long, long long); +#else + CHECK(unsigned long, long long, unsigned long long); + CHECK(long long, unsigned long, unsigned long long); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-left-shift-1.c b/SingleSource/Regression/C/gcc-dg/c99-left-shift-1.c new file mode 100644 index 0000000000..9a73049fa2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-left-shift-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +enum E { A = -2 << 1 }; /* { dg-error "constant expression" } */ +int i = -1 << 0; /* { dg-error "constant expression" } */ + +int +f (int i) +{ + switch (i) + case -1 << 0: break; /* { dg-error "constant expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-left-shift-2.c b/SingleSource/Regression/C/gcc-dg/c99-left-shift-2.c new file mode 100644 index 0000000000..e35786e50d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-left-shift-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -Wno-shift-overflow" } */ + +#define INTM2 (sizeof (int) * __CHAR_BIT__ - 2) + +enum { A = 10 << INTM2 }; /* { dg-error "constant expression" } */ +int k = 10 << INTM2; /* { dg-error "constant expression" } */ + +void +fn (int i) +{ + switch (i) + case 10 << INTM2: break; /* { dg-error "constant expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-left-shift-3.c b/SingleSource/Regression/C/gcc-dg/c99-left-shift-3.c new file mode 100644 index 0000000000..59d0f24e39 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-left-shift-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -Wno-shift-overflow" } */ + +#define INTM1 (sizeof (int) * __CHAR_BIT__ - 1) + +enum { A = 1 << INTM1 }; /* { dg-error "constant expression" } */ +int k = 1 << INTM1; /* { dg-error "constant expression" } */ + +void +fn (int i) +{ + switch (i) + case 1 << INTM1: break; /* { dg-error "constant expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-longlong-1.c b/SingleSource/Regression/C/gcc-dg/c99-longlong-1.c new file mode 100644 index 0000000000..92d5e0e806 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-longlong-1.c @@ -0,0 +1,6 @@ +/* Test for long long: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +long long foo; /* { dg-bogus "long long" "bogus long long error" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-longlong-2.c b/SingleSource/Regression/C/gcc-dg/c99-longlong-2.c new file mode 100644 index 0000000000..fc6c8a5efd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-longlong-2.c @@ -0,0 +1,6 @@ +/* Test for long long: if explicit Wlong-long, in C99 only warn, not + pedwarn. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -Wlong-long" } */ + +long long foo; /* { dg-warning "long long" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-main-1.c b/SingleSource/Regression/C/gcc-dg/c99-main-1.c new file mode 100644 index 0000000000..fdef9fd36a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-main-1.c @@ -0,0 +1,9 @@ +/* Test for implicit return 0 from main in C99. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -Wreturn-type -O -fhosted" } */ + +int +main (void) +{ +} /* { dg-bogus "control reaches end" "missing implicit return" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-math-double-1.c b/SingleSource/Regression/C/gcc-dg/c99-math-double-1.c new file mode 100644 index 0000000000..0db4297845 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-math-double-1.c @@ -0,0 +1,22 @@ +/* { dg-do run { target *-*-solaris2* } } */ +/* { dg-options "-std=c99 -O" } */ + +#include +#include "c99-math.h" + +int main(void) +{ + volatile double nan = NAN; + volatile double inf = INFINITY; + volatile double huge = HUGE_VAL; + volatile double norm1 = __DBL_MIN__; + volatile double norm2 = 1; + volatile double norm3 = __DBL_MAX__; + volatile double sub = __DBL_MIN__ / 2; + volatile double zero = 0.0; + + C99_MATH_TESTS (nan, inf, huge, norm1, norm2, norm3, sub, zero, /*neg=*/0) + C99_MATH_TESTS (-nan, -inf, -huge, -norm1, -norm2, -norm3, -sub, -zero, /*neg=*/1) + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-math-float-1.c b/SingleSource/Regression/C/gcc-dg/c99-math-float-1.c new file mode 100644 index 0000000000..8654e76721 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-math-float-1.c @@ -0,0 +1,22 @@ +/* { dg-do run { target *-*-solaris2* } } */ +/* { dg-options "-std=c99 -O" } */ + +#include +#include "c99-math.h" + +int main(void) +{ + volatile float nan = NAN; + volatile float inf = INFINITY; + volatile float huge = HUGE_VALF; + volatile float norm1 = __FLT_MIN__; + volatile float norm2 = 1; + volatile float norm3 = __FLT_MAX__; + volatile float sub = __FLT_MIN__ / 2; + volatile float zero = 0.0f; + + C99_MATH_TESTS (nan, inf, huge, norm1, norm2, norm3, sub, zero, /*neg=*/0) + C99_MATH_TESTS (-nan, -inf, -huge, -norm1, -norm2, -norm3, -sub, -zero, /*neg=*/1) + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-math-long-double-1.c b/SingleSource/Regression/C/gcc-dg/c99-math-long-double-1.c new file mode 100644 index 0000000000..97948f4cc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-math-long-double-1.c @@ -0,0 +1,22 @@ +/* { dg-do run { target *-*-solaris2* } } */ +/* { dg-options "-std=c99 -O" } */ + +#include +#include "c99-math.h" + +int main(void) +{ + volatile long double nan = NAN; + volatile long double inf = INFINITY; + volatile long double huge = HUGE_VALL; + volatile long double norm1 = __LDBL_MIN__; + volatile long double norm2 = 1; + volatile long double norm3 = __LDBL_MAX__; + volatile long double sub = __LDBL_MIN__ / 2; + volatile long double zero = 0.0l; + + C99_MATH_TESTS (nan, inf, huge, norm1, norm2, norm3, sub, zero, /*neg=*/0) + C99_MATH_TESTS (-nan, -inf, -huge, -norm1, -norm2, -norm3, -sub, -zero, /*neg=*/1) + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-math.h b/SingleSource/Regression/C/gcc-dg/c99-math.h new file mode 100644 index 0000000000..81f2e6ddb4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-math.h @@ -0,0 +1,236 @@ +#include +#include + +extern void abort(void); + +#define C99_MATH_TESTS(nan, inf, huge, norm1, norm2, norm3, sub, zero, neg) \ +{ \ + if (feclearexcept (FE_ALL_EXCEPT) != 0) \ + abort(); \ + \ + \ + if (fpclassify (nan) != FP_NAN) \ + abort (); \ + \ + if (fpclassify (inf) != FP_INFINITE) \ + abort (); \ + \ + if (fpclassify (huge) != FP_INFINITE) \ + abort (); \ + \ + if (fpclassify (norm1) != FP_NORMAL) \ + abort (); \ + \ + if (fpclassify (norm2) != FP_NORMAL) \ + abort (); \ + \ + if (fpclassify (norm3) != FP_NORMAL) \ + abort (); \ + \ + if (fpclassify (sub) != FP_SUBNORMAL) \ + abort (); \ + \ + if (fpclassify (zero) != FP_ZERO) \ + abort (); \ + \ + \ + if (!isnan (nan)) \ + abort (); \ + \ + if (isnan (inf)) \ + abort (); \ + \ + if (isnan (huge)) \ + abort (); \ + \ + if (isnan (norm1)) \ + abort (); \ + \ + if (isnan (norm2)) \ + abort (); \ + \ + if (isnan (norm3)) \ + abort (); \ + \ + if (isnan (sub)) \ + abort (); \ + \ + if (isnan (zero)) \ + abort (); \ + \ + \ + if (isinf (nan)) \ + abort (); \ + \ + if (!isinf (inf)) \ + abort (); \ + \ + if (!isinf (huge)) \ + abort (); \ + \ + if (isinf (norm1)) \ + abort (); \ + \ + if (isinf (norm2)) \ + abort (); \ + \ + if (isinf (norm3)) \ + abort (); \ + \ + if (isinf (sub)) \ + abort (); \ + \ + if (isinf (zero)) \ + abort (); \ + \ + \ + if (isfinite (nan)) \ + abort (); \ + \ + if (isfinite (inf)) \ + abort (); \ + \ + if (isfinite (huge)) \ + abort (); \ + \ + if (!isfinite (norm1)) \ + abort (); \ + \ + if (!isfinite (norm2)) \ + abort (); \ + \ + if (!isfinite (norm3)) \ + abort (); \ + \ + if (!isfinite (sub)) \ + abort (); \ + \ + if (!isfinite (zero)) \ + abort (); \ + \ + \ + if (isnormal (nan)) \ + abort (); \ + \ + if (isnormal (inf)) \ + abort (); \ + \ + if (isnormal (huge)) \ + abort (); \ + \ + if (!isnormal (norm1)) \ + abort (); \ + \ + if (!isnormal (norm2)) \ + abort (); \ + \ + if (!isnormal (norm3)) \ + abort (); \ + \ + if (isnormal (sub)) \ + abort (); \ + \ + if (isnormal (zero)) \ + abort (); \ + \ + \ + if (!!signbit (nan) != neg) \ + abort (); \ + \ + if (!!signbit (inf) != neg) \ + abort (); \ + \ + if (!!signbit (huge) != neg) \ + abort (); \ + \ + if (!!signbit (norm1) != neg) \ + abort (); \ + \ + if (!!signbit (norm2) != neg) \ + abort (); \ + \ + if (!!signbit (norm3) != neg) \ + abort (); \ + \ + if (!!signbit (sub) != neg) \ + abort (); \ + \ + if (!!signbit (zero) != neg) \ + abort (); \ + \ + \ + if (neg) \ + { \ + if (!isless ((inf), (norm1))) \ + abort (); \ + \ + if (!isless ((inf), (norm2))) \ + abort (); \ + \ + if (!isless ((inf), (norm3))) \ + abort (); \ + \ + if (!islessequal ((inf), (huge))) \ + abort (); \ + \ + if (!isgreater ((norm1), (inf))) \ + abort (); \ + \ + if (!isgreater ((norm2), (inf))) \ + abort (); \ + \ + if (!isgreater ((norm3), (inf))) \ + abort (); \ + \ + if (!isgreaterequal ((huge), (inf))) \ + abort (); \ + } \ + else \ + { \ + if (!isgreater ((inf), (norm1))) \ + abort (); \ + \ + if (!isgreater ((inf), (norm2))) \ + abort (); \ + \ + if (!isgreater ((inf), (norm3))) \ + abort (); \ + \ + if (!isgreaterequal ((inf), (huge))) \ + abort (); \ + \ + if (!isless ((norm1), (inf))) \ + abort (); \ + \ + if (!isless ((norm2), (inf))) \ + abort (); \ + \ + if (!isless ((norm3), (inf))) \ + abort (); \ + \ + if (!islessequal ((huge), (inf))) \ + abort (); \ + } \ + \ + if (!islessgreater ((inf), (norm1))) \ + abort (); \ + \ + if (!islessgreater ((inf), (norm2))) \ + abort (); \ + \ + if (!islessgreater ((inf), (norm3))) \ + abort (); \ + \ + if (!isunordered ((nan), (norm1))) \ + abort (); \ + \ + if (!isunordered ((nan), (norm2))) \ + abort (); \ + \ + if (!isunordered ((nan), (norm3))) \ + abort (); \ + \ + \ + if (fetestexcept (FE_ALL_EXCEPT) != 0) \ + abort(); \ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-mixdecl-1.c b/SingleSource/Regression/C/gcc-dg/c99-mixdecl-1.c new file mode 100644 index 0000000000..cfedad44c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-mixdecl-1.c @@ -0,0 +1,25 @@ +/* Test for C99 mixed declarations and code. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int i = 0; + if (i != 0) + abort (); + i++; + if (i != 1) + abort (); + int j = i; + if (j != 1) + abort (); + struct foo { int i0; } k = { 4 }; + if (k.i0 != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-noreturn-1.c b/SingleSource/Regression/C/gcc-dg/c99-noreturn-1.c new file mode 100644 index 0000000000..4cbc513595 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-noreturn-1.c @@ -0,0 +1,5 @@ +/* Test _Noreturn not in C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +_Noreturn void f (void); /* { dg-error "ISO C99 does not support '_Noreturn'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-predef-1.c b/SingleSource/Regression/C/gcc-dg/c99-predef-1.c new file mode 100644 index 0000000000..b907764579 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-predef-1.c @@ -0,0 +1,63 @@ +/* Verify that predefined macros for properties of the compiler and + library together are the same before and after system headers are + included. This is broken with older glibc versions. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#ifdef __STDC_IEC_559__ +#define IEC_559_DEFINED_BEFORE 1 +#else +#define IEC_559_DEFINED_BEFORE 0 +#endif + +#ifdef __STDC_IEC_559_COMPLEX__ +#define IEC_559_COMPLEX_DEFINED_BEFORE 1 +#else +#define IEC_559_COMPLEX_DEFINED_BEFORE 0 +#endif + +#ifdef __STDC_ISO_10646__ +#define ISO_10646_DEFINED_BEFORE 1 +#else +#define ISO_10646_DEFINED_BEFORE 0 +#endif + +#include + +#ifdef __STDC_IEC_559__ +#define IEC_559_DEFINED_AFTER 1 +#else +#define IEC_559_DEFINED_AFTER 0 +#endif + +#ifdef __STDC_IEC_559_COMPLEX__ +#define IEC_559_COMPLEX_DEFINED_AFTER 1 +#else +#define IEC_559_COMPLEX_DEFINED_AFTER 0 +#endif + +#ifdef __STDC_ISO_10646__ +#define ISO_10646_DEFINED_AFTER 1 +#else +#define ISO_10646_DEFINED_AFTER 0 +#endif + +#if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 16)) +#define BROKEN +#endif + +#ifndef BROKEN + +#if IEC_559_DEFINED_BEFORE != IEC_559_DEFINED_AFTER +#error "__STDC_IEC_559__ definition inconsistency" +#endif + +#if IEC_559_COMPLEX_DEFINED_BEFORE != IEC_559_COMPLEX_DEFINED_AFTER +#error "__STDC_IEC_559_COMPLEX__ definition inconsistency" +#endif + +#if ISO_10646_DEFINED_BEFORE != ISO_10646_DEFINED_AFTER +#error "__STDC_ISO_10646__ definition inconsistency" +#endif + +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c99-restrict-1.c b/SingleSource/Regression/C/gcc-dg/c99-restrict-1.c new file mode 100644 index 0000000000..a93b3e1de6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-restrict-1.c @@ -0,0 +1,19 @@ +/* Test for restrict: in C99 only. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +char *restrict foo; + +/* The following are constraint violations and should be rejected. */ + +int restrict bar; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "restrict" "restrict constraint violation" { target *-*-* } .-1 } */ + +typedef void (*fp) (void); + +fp restrict baz; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "restrict" "restrict constraint violation" { target *-*-* } .-1 } */ + +void quux (int restrict a[3]); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "restrict" "restrict constraint violation" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-restrict-2.c b/SingleSource/Regression/C/gcc-dg/c99-restrict-2.c new file mode 100644 index 0000000000..2adc5f2b36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-restrict-2.c @@ -0,0 +1,12 @@ +/* Test for restrict: in C99 only. Test handling of arrays of restricted + pointers. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef int *ipa[2]; + +int *restrict x[2]; +restrict ipa y; + +void f(int *restrict a[2], restrict ipa b, int *restrict c[restrict]); diff --git a/SingleSource/Regression/C/gcc-dg/c99-restrict-3.c b/SingleSource/Regression/C/gcc-dg/c99-restrict-3.c new file mode 100644 index 0000000000..e5200a57be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-restrict-3.c @@ -0,0 +1,7 @@ +/* restrict qualifiers on non-pointers must be diagnosed even when + only a tag is being declared. PR 38243. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +restrict struct s; /* { dg-error "restrict" } */ +restrict union u; /* { dg-error "restrict" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-restrict-4.c b/SingleSource/Regression/C/gcc-dg/c99-restrict-4.c new file mode 100644 index 0000000000..5852d0a112 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-restrict-4.c @@ -0,0 +1,17 @@ +/* Qualifiers lost when taking the address of a const restrict object. + PR 44322. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ +void * restrict const a[2]; +void * restrict const (*p2)[2]; + +void foo(void) { + p2 = &a; +} + +void * restrict volatile b[2]; +void * restrict volatile (*q2)[2]; + +void bar(void) { + q2 = &b; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-return-1.c b/SingleSource/Regression/C/gcc-dg/c99-return-1.c new file mode 100644 index 0000000000..97ce3ad884 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-return-1.c @@ -0,0 +1,18 @@ +/* Test for constraints on return statements. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +int +foo (void) +{ + return; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "with no value" "return constraint violation" { target *-*-* } .-1 } */ +} + +void +bar (void) +{ + return 1; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "with a value" "return constraint violation" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-scope-1.c b/SingleSource/Regression/C/gcc-dg/c99-scope-1.c new file mode 100644 index 0000000000..48ea3b088f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-scope-1.c @@ -0,0 +1,34 @@ +/* Test for new block scopes in C99. Inspired by C99 Rationale (N897). */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct foo { + char a; +}; + +extern void abort (void); +extern void exit (int); + +int +sfoo (void) +{ + if (sizeof (struct foo { int a; double b; char *c; void *d; })) + (void) 0; + return sizeof (struct foo); +} + +int +main (void) +{ + int t, u; + t = sfoo (); + u = sizeof (struct foo); + /* With C90 scoping rules the new declaration of struct foo is in scope + above; with C99 it is local to the if. + */ + if (t == u) + exit (0); /* C99 rules apply. */ + else + abort (); /* C90 rules apply. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-scope-2.c b/SingleSource/Regression/C/gcc-dg/c99-scope-2.c new file mode 100644 index 0000000000..86ac272a74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-scope-2.c @@ -0,0 +1,71 @@ +/* Test for new block scopes in C99. Test for each new scope. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + struct foo { int i0; }; + int a, b, c, d; + a = sizeof (struct foo); + if (b = sizeof (struct foo { int i0; int i1; })) + c = sizeof (struct foo { int i0; int i1; int i2; }); + if (!(a <= b && b <= c)) + abort (); + if ((b = sizeof (struct foo { int i0; int i1; })), 0) + c = sizeof (struct foo { int i0; int i1; int i2; }); + else + d = sizeof (struct foo { int i0; int i1; int i2; int i3; }); + if (!(a <= b && b <= d)) + abort (); + switch (b = sizeof (struct foo { int i0; int i1; })) + default: + c = sizeof (struct foo { int i0; int i1; int i2; }); + if (!(a <= b && b <= c)) + abort (); + do + c = sizeof (struct foo { int i0; int i1; int i2; }); + while ((b = sizeof (struct foo { int i0; int i1; })), 0); + if (!(a <= b && b <= c)) + abort (); + d = 1; + while ((b = sizeof (struct foo { int i0; int i1; })), d) + (c = sizeof (struct foo { int i0; int i1; int i2; })), d--; + if (!(a <= b && b <= c)) + abort (); + d = 1; + for ((b = sizeof (struct foo { int i0; int i1; })); d; d--) + c = sizeof (struct foo { int i0; int i1; int i2; }); + if (!(a <= b && b <= c)) + abort (); + d = 1; + for ((b = sizeof (struct foo { int i0; int i1; })); d; d--) + c = sizeof (struct foo); + if (!(a <= b && b == c)) + abort (); + d = 1; + for (; (b = sizeof (struct foo { int i0; int i1; })), d; d--) + c = sizeof (struct foo { int i0; int i1; int i2; }); + if (!(a <= b && b <= c)) + abort (); + d = 1; + for (; (b = sizeof (struct foo { int i0; int i1; })), d; d--) + c = sizeof (struct foo); + if (!(a <= b && b == c)) + abort (); + d = 1; + for (; d; (b = sizeof (struct foo { int i0; int i1; })), d--) + c = sizeof (struct foo { int i0; int i1; int i2; }); + if (!(a <= b && b <= c)) + abort (); + d = 1; + for (; d; (b = sizeof (struct foo { int i0; int i1; })), d--) + c = sizeof (struct foo); + if (!(a <= b && b == c)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-static-1.c b/SingleSource/Regression/C/gcc-dg/c99-static-1.c new file mode 100644 index 0000000000..a138f878d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-static-1.c @@ -0,0 +1,35 @@ +/* It is a constraint violation for a static function to be declared + but not defined if it is used except in a sizeof expression whose + result is an integer constant. The use of the function simply + being unevaluated is not enough. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=iso9899:1999 -pedantic-errors" } */ + +/* Constraint violation (trivial case, where function is used). */ +static void f0(void); /* { dg-error "used but never defined" } */ +void g0(void) { f0(); } + +/* Constraint violation. */ +static void f1(void); /* { dg-error "used but never defined" } */ +void g1(void) { if (0) { f1(); } } + +/* Constraint violation. */ +static int f2(void); /* { dg-error "used but never defined" } */ +void g2(void) { 0 ? f2() : 0; } + +/* OK. */ +static int f3(void); +void g3(void) { sizeof(f3()); } + +/* OK (VM type, not VLA). */ +static int f4(void); +void g4(void) { sizeof(int (*)[f4()]); } + +/* Constraint violation (VLA). */ +static int f5(void); /* { dg-error "used but never defined" "VLA" } */ +void g5(void) { sizeof(int [0 ? f5() : 1]); } + +/* OK (non-constant sizeof inside constant sizeof). */ +static int f6(void); +void g6(void) { sizeof(sizeof(int [f6()])); } diff --git a/SingleSource/Regression/C/gcc-dg/c99-static-assert-1.c b/SingleSource/Regression/C/gcc-dg/c99-static-assert-1.c new file mode 100644 index 0000000000..23477360e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-static-assert-1.c @@ -0,0 +1,5 @@ +/* Test for static assertions not in C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +_Static_assert (1, ""); /* { dg-error "ISO C99 does not support '_Static_assert'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-static-assert-2.c b/SingleSource/Regression/C/gcc-dg/c99-static-assert-2.c new file mode 100644 index 0000000000..dffa77c64f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-static-assert-2.c @@ -0,0 +1,6 @@ +/* Test static assertions. Omitting the string should not result in a + duplicate diagnostic in pre-C11 modes. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic" } */ + +_Static_assert (1); /* { dg-warning "ISO C99 does not support '_Static_assert'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-stdint-1.c b/SingleSource/Regression/C/gcc-dg/c99-stdint-1.c new file mode 100644 index 0000000000..f5c2cda77c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-stdint-1.c @@ -0,0 +1,271 @@ +/* Verify that is present and follows the C99 requirements. + If this test fails because of the header being missing on a + particular target, this indicates GCC has not been correctly + configured regarding what version of to install or what + the types are on that target. If GCC is wrapping a + system copy of the header and some tests fail because of bugs in + that copy, they should be fixed with fixincludes (and the bugs + reported to maintainer of that copy if still present in the latest + version). */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -fhosted" } */ +/* { dg-require-effective-target ptr32plus } */ +/* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */ + +#include +#include +/* This and the later SIG_ATOMIC_* tests should be appropriately + conditioned for any freestanding targets with no . */ +#ifndef SIGNAL_SUPPRESS +#include +#endif + +/* Note that some of these conditions assume two's complement and no + padding bits; GCC only supports two's complement, and no supported + target has padding bits in any integer type of the standard + widths. */ +#define CHECK_SIGNED(TYPE) \ + do { TYPE a; int b[(TYPE)-1 < 0 ? 1 : -1]; } while (0) +#define CHECK_UNSIGNED(TYPE) \ + do { TYPE a; int b[(TYPE)-1 < 0 ? -1 : 1]; } while (0) +#define CHECK_WIDTH_EQUALS(TYPE, WIDTH) \ + do { int a[sizeof(TYPE) * CHAR_BIT == (WIDTH) ? 1 : -1]; } while (0) +#define CHECK_WIDTH_AT_LEAST(TYPE, WIDTH) \ + do { int a[sizeof(TYPE) * CHAR_BIT >= (WIDTH) ? 1 : -1]; } while (0) +#define CHECK_WIDTH_ORDER(TYPE1, TYPE2) \ + do { int a[sizeof(TYPE2) >= sizeof(TYPE1) ? 1 : -1]; } while (0) +#define CHECK_EXPR_TYPE(TYPE, EXPR) \ + do { __typeof__(EXPR) a; __typeof__((TYPE)0 + 0) *b = &a; } while (0) +#define UNSIGNED_MAX_COND(TYPE, EXPR) \ + ((EXPR) == (TYPE)-1) +#define SIGNED_MIN_MAX_COND(TYPE, MIN, MAX) \ + ((MIN) == -(MAX)-1 \ + && ((MAX) & 1) \ + && ((((MAX) >> 1) + 1) >> (sizeof(TYPE) * CHAR_BIT - 2)) == 1) +#define MIN_MAX_COND(TYPE, MIN, MAX) \ + ((TYPE)-1 < 0 \ + ? SIGNED_MIN_MAX_COND(TYPE, (MIN), (MAX)) \ + : ((MIN) == 0 && UNSIGNED_MAX_COND(TYPE, (MAX)))) +#define CHECK_SIGNED_LIMITS(TYPE, MIN, MAX) \ + CHECK_SIGNED(TYPE); \ + CHECK_EXPR_TYPE(TYPE, (MIN)); \ + CHECK_EXPR_TYPE(TYPE, (MAX)); \ + do { int a[SIGNED_MIN_MAX_COND(TYPE, (MIN), (MAX)) ? 1 : -1]; } while (0) +#define CHECK_SIGNED_LIMITS_2(TYPE, MIN, MAX, MINBD, MAXBD) \ + CHECK_SIGNED(TYPE); \ + CHECK_EXPR_TYPE(TYPE, (MIN)); \ + CHECK_EXPR_TYPE(TYPE, (MAX)); \ + do { int a[(SIGNED_MIN_MAX_COND(TYPE, (MIN), (MAX)) \ + && (MIN) <= (MINBD) \ + && (MAX) >= (MAXBD)) ? 1 : -1]; } while (0) +#define CHECK_UNSIGNED_LIMITS(TYPE, MAX) \ + CHECK_UNSIGNED(TYPE); \ + CHECK_EXPR_TYPE(TYPE, (MAX)); \ + do { int a[UNSIGNED_MAX_COND(TYPE, (MAX)) ? 1 : -1]; } while (0) +#define CHECK_UNSIGNED_LIMITS_2(TYPE, MAX, MAXBD) \ + CHECK_UNSIGNED(TYPE); \ + CHECK_EXPR_TYPE(TYPE, (MAX)); \ + do { int a[(UNSIGNED_MAX_COND(TYPE, (MAX)) \ + && (MAX) >= (MAXBD)) ? 1 : -1]; } while (0) +#define CHECK_LIMITS_2(TYPE, MIN, MAX, SMINBD, SMAXBD, UMAXBD) \ + do { int a[(MIN_MAX_COND(TYPE, (MIN), (MAX)) \ + && ((TYPE)-1 < 0 \ + ? ((MIN) <= (SMINBD) && (MAX) >= (SMAXBD)) \ + : (MAX) >= (UMAXBD))) ? 1 : -1]; } while (0) +#define CHECK_CONSTS(TYPE, MACRO) \ + CHECK_EXPR_TYPE(TYPE, MACRO(01)); \ + CHECK_EXPR_TYPE(TYPE, MACRO(2)); \ + CHECK_EXPR_TYPE(TYPE, MACRO(0x3)); \ + do { int a[(MACRO(12) == 12 \ + && MACRO(012) == 012 \ + && MACRO(0x12) == 0x12) ? 1 : -1]; } while (0); + +void +test_exact (void) +{ +#ifdef INT8_MIN + CHECK_WIDTH_EQUALS(int8_t, 8); + CHECK_SIGNED_LIMITS(int8_t, INT8_MIN, INT8_MAX); +#else + CHECK_WIDTH_AT_LEAST(int_least8_t, 9); +#endif +#ifdef INT16_MIN + CHECK_WIDTH_EQUALS(int16_t, 16); + CHECK_SIGNED_LIMITS(int16_t, INT16_MIN, INT16_MAX); +#else + CHECK_WIDTH_AT_LEAST(int_least16_t, 17); +#endif +#ifdef INT32_MIN + CHECK_WIDTH_EQUALS(int32_t, 32); + CHECK_SIGNED_LIMITS(int32_t, INT32_MIN, INT32_MAX); +#else + CHECK_WIDTH_AT_LEAST(int_least32_t, 33); +#endif +#ifdef INT64_MIN + CHECK_WIDTH_EQUALS(int64_t, 64); + CHECK_SIGNED_LIMITS(int64_t, INT64_MIN, INT64_MAX); +#else + CHECK_WIDTH_AT_LEAST(int_least64_t, 65); +#endif +#ifdef UINT8_MAX + CHECK_WIDTH_EQUALS(uint8_t, 8); + CHECK_UNSIGNED_LIMITS(uint8_t, UINT8_MAX); +#else + CHECK_WIDTH_AT_LEAST(uint_least8_t, 9); +#endif +#ifdef UINT16_MAX + CHECK_WIDTH_EQUALS(uint16_t, 16); + CHECK_UNSIGNED_LIMITS(uint16_t, UINT16_MAX); +#else + CHECK_WIDTH_AT_LEAST(uint_least16_t, 17); +#endif +#ifdef UINT32_MAX + CHECK_WIDTH_EQUALS(uint32_t, 32); + CHECK_UNSIGNED_LIMITS(uint32_t, UINT32_MAX); +#else + CHECK_WIDTH_AT_LEAST(uint_least32_t, 33); +#endif +#ifdef UINT64_MAX + CHECK_WIDTH_EQUALS(uint64_t, 64); + CHECK_UNSIGNED_LIMITS(uint64_t, UINT64_MAX); +#else + CHECK_WIDTH_AT_LEAST(uint_least64_t, 65); +#endif +} + +void +test_least (void) +{ + CHECK_WIDTH_AT_LEAST(int_least8_t, 8); + CHECK_WIDTH_ORDER(int_least8_t, int_fast8_t); + CHECK_SIGNED_LIMITS(int_least8_t, INT_LEAST8_MIN, INT_LEAST8_MAX); + CHECK_WIDTH_AT_LEAST(int_least16_t, 16); + CHECK_WIDTH_ORDER(int_least16_t, int_fast16_t); + CHECK_SIGNED_LIMITS(int_least16_t, INT_LEAST16_MIN, INT_LEAST16_MAX); + CHECK_WIDTH_AT_LEAST(int_least32_t, 32); + CHECK_WIDTH_ORDER(int_least32_t, int_fast32_t); + CHECK_SIGNED_LIMITS(int_least32_t, INT_LEAST32_MIN, INT_LEAST32_MAX); + CHECK_WIDTH_AT_LEAST(int_least64_t, 64); + CHECK_WIDTH_ORDER(int_least64_t, int_fast64_t); + CHECK_SIGNED_LIMITS(int_least64_t, INT_LEAST64_MIN, INT_LEAST64_MAX); + CHECK_WIDTH_AT_LEAST(uint_least8_t, 8); + CHECK_WIDTH_ORDER(uint_least8_t, uint_fast8_t); + CHECK_UNSIGNED_LIMITS(uint_least8_t, UINT_LEAST8_MAX); + CHECK_WIDTH_AT_LEAST(uint_least16_t, 16); + CHECK_WIDTH_ORDER(uint_least16_t, uint_fast16_t); + CHECK_UNSIGNED_LIMITS(uint_least16_t, UINT_LEAST16_MAX); + CHECK_WIDTH_AT_LEAST(uint_least32_t, 32); + CHECK_WIDTH_ORDER(uint_least32_t, uint_fast32_t); + CHECK_UNSIGNED_LIMITS(uint_least32_t, UINT_LEAST32_MAX); + CHECK_WIDTH_AT_LEAST(uint_least64_t, 64); + CHECK_WIDTH_ORDER(uint_least64_t, uint_fast64_t); + CHECK_UNSIGNED_LIMITS(uint_least64_t, UINT_LEAST64_MAX); +} + +void +test_fast (void) +{ + CHECK_WIDTH_AT_LEAST(int_fast8_t, 8); + CHECK_SIGNED_LIMITS(int_fast8_t, INT_FAST8_MIN, INT_FAST8_MAX); + CHECK_WIDTH_AT_LEAST(int_fast16_t, 16); + CHECK_SIGNED_LIMITS(int_fast16_t, INT_FAST16_MIN, INT_FAST16_MAX); + CHECK_WIDTH_AT_LEAST(int_fast32_t, 32); + CHECK_SIGNED_LIMITS(int_fast32_t, INT_FAST32_MIN, INT_FAST32_MAX); + CHECK_WIDTH_AT_LEAST(int_fast64_t, 64); + CHECK_SIGNED_LIMITS(int_fast64_t, INT_FAST64_MIN, INT_FAST64_MAX); + CHECK_WIDTH_AT_LEAST(uint_fast8_t, 8); + CHECK_UNSIGNED_LIMITS(uint_fast8_t, UINT_FAST8_MAX); + CHECK_WIDTH_AT_LEAST(uint_fast16_t, 16); + CHECK_UNSIGNED_LIMITS(uint_fast16_t, UINT_FAST16_MAX); + CHECK_WIDTH_AT_LEAST(uint_fast32_t, 32); + CHECK_UNSIGNED_LIMITS(uint_fast32_t, UINT_FAST32_MAX); + CHECK_WIDTH_AT_LEAST(uint_fast64_t, 64); + CHECK_UNSIGNED_LIMITS(uint_fast64_t, UINT_FAST64_MAX); +} + +void +test_ptr (void) +{ +#ifdef INTPTR_MIN + CHECK_SIGNED_LIMITS_2(intptr_t, INTPTR_MIN, INTPTR_MAX, -0x7fff, 0x7fff); +#endif +#ifdef UINTPTR_MAX + CHECK_UNSIGNED_LIMITS_2(uintptr_t, UINTPTR_MAX, 0xffffU); +#endif +} + +void +test_max (void) +{ + CHECK_WIDTH_AT_LEAST(intmax_t, 64); + CHECK_WIDTH_ORDER(long long, intmax_t); + CHECK_WIDTH_ORDER(int_fast8_t, intmax_t); + CHECK_WIDTH_ORDER(int_fast16_t, intmax_t); + CHECK_WIDTH_ORDER(int_fast32_t, intmax_t); + CHECK_WIDTH_ORDER(int_fast64_t, intmax_t); + CHECK_SIGNED_LIMITS(intmax_t, INTMAX_MIN, INTMAX_MAX); + CHECK_WIDTH_AT_LEAST(uintmax_t, 64); + CHECK_WIDTH_ORDER(unsigned long long, uintmax_t); + CHECK_WIDTH_ORDER(uint_fast8_t, uintmax_t); + CHECK_WIDTH_ORDER(uint_fast16_t, uintmax_t); + CHECK_WIDTH_ORDER(uint_fast32_t, uintmax_t); + CHECK_WIDTH_ORDER(uint_fast64_t, uintmax_t); + CHECK_UNSIGNED_LIMITS(uintmax_t, UINTMAX_MAX); +} + +void +test_misc_limits (void) +{ + CHECK_SIGNED_LIMITS_2(__PTRDIFF_TYPE__, PTRDIFF_MIN, PTRDIFF_MAX, -65535L, 65535L); +#ifndef SIGNAL_SUPPRESS + CHECK_LIMITS_2(sig_atomic_t, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX, -127, 127, 255); +#endif + CHECK_UNSIGNED_LIMITS_2(__SIZE_TYPE__, SIZE_MAX, 65535U); + CHECK_LIMITS_2(__WCHAR_TYPE__, WCHAR_MIN, WCHAR_MAX, -127, 127, 255); + CHECK_LIMITS_2(__WINT_TYPE__, WINT_MIN, WINT_MAX, -32767, 32767, 65535); +} + +void +test_constants (void) +{ + CHECK_CONSTS(int_least8_t, INT8_C); + CHECK_CONSTS(int_least16_t, INT16_C); + CHECK_CONSTS(int_least32_t, INT32_C); + CHECK_CONSTS(int_least64_t, INT64_C); + CHECK_CONSTS(intmax_t, INTMAX_C); + CHECK_CONSTS(uint_least8_t, UINT8_C); + CHECK_CONSTS(uint_least16_t, UINT16_C); + CHECK_CONSTS(uint_least32_t, UINT32_C); + CHECK_CONSTS(uint_least64_t, UINT64_C); + CHECK_CONSTS(uintmax_t, UINTMAX_C); +#if INT8_C(12) != 12 +#error "INT8_C not usable in #if" +#endif +#if INT16_C(12) != 12 +#error "INT16_C not usable in #if" +#endif +#if INT32_C(12) != 12 +#error "INT32_C not usable in #if" +#endif +#if INT64_C(12) != 12 +#error "INT64_C not usable in #if" +#endif +#if INTMAX_C(12) != 12 +#error "INTMAX_C not usable in #if" +#endif +#if UINT8_C(12) != 12 +#error "UINT8_C not usable in #if" +#endif +#if UINT16_C(12) != 12 +#error "UINT16_C not usable in #if" +#endif +#if UINT32_C(12) != 12 +#error "UINT32_C not usable in #if" +#endif +#if UINT64_C(12) != 12 +#error "UINT64_C not usable in #if" +#endif +#if UINTMAX_C(12) != 12 +#error "UINTMAX_C not usable in #if" +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-stdint-2.c b/SingleSource/Regression/C/gcc-dg/c99-stdint-2.c new file mode 100644 index 0000000000..08d9f6023d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-stdint-2.c @@ -0,0 +1,10 @@ +/* Verify that is present and follows the C99 requirements. + Freestanding version. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -ffreestanding" } */ +/* { dg-require-effective-target ptr32plus } */ +/* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */ + +/* The test is that there are no diagnostics, so just include the + hosted version. */ +#include "c99-stdint-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/c99-stdint-3.c b/SingleSource/Regression/C/gcc-dg/c99-stdint-3.c new file mode 100644 index 0000000000..c42ac8b9c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-stdint-3.c @@ -0,0 +1,39 @@ +/* Verify that pairs of types in are corresponding types + (requires no pointer sign warnings, so separate from + c99-stdint-1.c). */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -fhosted" } */ + +#include + +#define CHECK_CORRESPONDING(TYPE1, TYPE2) \ + do { TYPE1 a; TYPE2 *b = &a; TYPE2 c; TYPE1 *d = &c; } while (0) + +void +check_corresponding (void) +{ +#if defined(INT8_MAX) && defined(UINT8_MAX) + CHECK_CORRESPONDING(int8_t, uint8_t); +#endif +#if defined(INT16_MAX) && defined(UINT16_MAX) + CHECK_CORRESPONDING(int16_t, uint16_t); +#endif +#if defined(INT32_MAX) && defined(UINT32_MAX) + CHECK_CORRESPONDING(int32_t, uint32_t); +#endif +#if defined(INT64_MAX) && defined(UINT64_MAX) + CHECK_CORRESPONDING(int64_t, uint64_t); +#endif + CHECK_CORRESPONDING(int_least8_t, uint_least8_t); + CHECK_CORRESPONDING(int_least16_t, uint_least16_t); + CHECK_CORRESPONDING(int_least32_t, uint_least32_t); + CHECK_CORRESPONDING(int_least64_t, uint_least64_t); + CHECK_CORRESPONDING(int_fast8_t, uint_fast8_t); + CHECK_CORRESPONDING(int_fast16_t, uint_fast16_t); + CHECK_CORRESPONDING(int_fast32_t, uint_fast32_t); + CHECK_CORRESPONDING(int_fast64_t, uint_fast64_t); +#if defined(INTPTR_MAX) && defined(UINTPTR_MAX) + CHECK_CORRESPONDING(intptr_t, uintptr_t); +#endif + CHECK_CORRESPONDING(intmax_t, uintmax_t); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-stdint-4.c b/SingleSource/Regression/C/gcc-dg/c99-stdint-4.c new file mode 100644 index 0000000000..469df8cd8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-stdint-4.c @@ -0,0 +1,8 @@ +/* Verify that pairs of types in are corresponding types. + Freestanding version. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -ffreestanding" } */ + +/* The test is that there are no diagnostics, so just include the + hosted version. */ +#include "c99-stdint-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/c99-stdint-5.c b/SingleSource/Regression/C/gcc-dg/c99-stdint-5.c new file mode 100644 index 0000000000..60513233a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-stdint-5.c @@ -0,0 +1,70 @@ +/* Verify that GCC's internal notions of types in agree + with any system header (which GCC will use by default for hosted + compilations). */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ +/* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */ + +#include +#ifndef SIGNAL_SUPPRESS +#include +#endif + +#define CHECK_TYPES(TYPE1, TYPE2) \ + do { TYPE1 a; TYPE2 *b = &a; TYPE2 c; TYPE1 *d = &c; } while (0) + +void +check_types (void) +{ +#ifdef __INT8_TYPE__ + CHECK_TYPES(__INT8_TYPE__, int8_t); +#endif +#ifdef __INT16_TYPE__ + CHECK_TYPES(__INT16_TYPE__, int16_t); +#endif +#ifdef __INT32_TYPE__ + CHECK_TYPES(__INT32_TYPE__, int32_t); +#endif +#ifdef __INT64_TYPE__ + CHECK_TYPES(__INT64_TYPE__, int64_t); +#endif +#ifdef __UINT8_TYPE__ + CHECK_TYPES(__UINT8_TYPE__, uint8_t); +#endif +#ifdef __UINT16_TYPE__ + CHECK_TYPES(__UINT16_TYPE__, uint16_t); +#endif +#ifdef __UINT32_TYPE__ + CHECK_TYPES(__UINT32_TYPE__, uint32_t); +#endif +#ifdef __UINT64_TYPE__ + CHECK_TYPES(__UINT64_TYPE__, uint64_t); +#endif + CHECK_TYPES(__INT_LEAST8_TYPE__, int_least8_t); + CHECK_TYPES(__INT_LEAST16_TYPE__, int_least16_t); + CHECK_TYPES(__INT_LEAST32_TYPE__, int_least32_t); + CHECK_TYPES(__INT_LEAST64_TYPE__, int_least64_t); + CHECK_TYPES(__UINT_LEAST8_TYPE__, uint_least8_t); + CHECK_TYPES(__UINT_LEAST16_TYPE__, uint_least16_t); + CHECK_TYPES(__UINT_LEAST32_TYPE__, uint_least32_t); + CHECK_TYPES(__UINT_LEAST64_TYPE__, uint_least64_t); + CHECK_TYPES(__INT_FAST8_TYPE__, int_fast8_t); + CHECK_TYPES(__INT_FAST16_TYPE__, int_fast16_t); + CHECK_TYPES(__INT_FAST32_TYPE__, int_fast32_t); + CHECK_TYPES(__INT_FAST64_TYPE__, int_fast64_t); + CHECK_TYPES(__UINT_FAST8_TYPE__, uint_fast8_t); + CHECK_TYPES(__UINT_FAST16_TYPE__, uint_fast16_t); + CHECK_TYPES(__UINT_FAST32_TYPE__, uint_fast32_t); + CHECK_TYPES(__UINT_FAST64_TYPE__, uint_fast64_t); +#ifdef __INTPTR_TYPE__ + CHECK_TYPES(__INTPTR_TYPE__, intptr_t); +#endif +#ifdef __UINTPTR_TYPE__ + CHECK_TYPES(__UINTPTR_TYPE__, uintptr_t); +#endif + CHECK_TYPES(__INTMAX_TYPE__, intmax_t); + CHECK_TYPES(__UINTMAX_TYPE__, uintmax_t); +#ifndef SIGNAL_SUPPRESS + CHECK_TYPES(__SIG_ATOMIC_TYPE__, sig_atomic_t); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-stdint-6.c b/SingleSource/Regression/C/gcc-dg/c99-stdint-6.c new file mode 100644 index 0000000000..60ac31ff7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-stdint-6.c @@ -0,0 +1,75 @@ +/* Verify that GCC's internal notions of types in agree + with any system header. */ +/* { dg-do compile { target inttypes_types } } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ +/* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */ + +#include +#ifndef SIGNAL_SUPPRESS +#include +#endif + +#define CHECK_TYPES(TYPE1, TYPE2) \ + do { TYPE1 a; TYPE2 *b = &a; TYPE2 c; TYPE1 *d = &c; } while (0) + +void +check_types (void) +{ +#ifdef __INT8_TYPE__ + CHECK_TYPES(__INT8_TYPE__, int8_t); +#endif +#ifdef __INT16_TYPE__ + CHECK_TYPES(__INT16_TYPE__, int16_t); +#endif +#ifdef __INT32_TYPE__ + CHECK_TYPES(__INT32_TYPE__, int32_t); +#endif +#ifdef __INT64_TYPE__ + CHECK_TYPES(__INT64_TYPE__, int64_t); +#endif +#ifdef __UINT8_TYPE__ + CHECK_TYPES(__UINT8_TYPE__, uint8_t); +#endif +#ifdef __UINT16_TYPE__ + CHECK_TYPES(__UINT16_TYPE__, uint16_t); +#endif +#ifdef __UINT32_TYPE__ + CHECK_TYPES(__UINT32_TYPE__, uint32_t); +#endif +#ifdef __UINT64_TYPE__ + CHECK_TYPES(__UINT64_TYPE__, uint64_t); +#endif +#ifndef NO_LEAST_TYPES + CHECK_TYPES(__INT_LEAST8_TYPE__, int_least8_t); + CHECK_TYPES(__INT_LEAST16_TYPE__, int_least16_t); + CHECK_TYPES(__INT_LEAST32_TYPE__, int_least32_t); + CHECK_TYPES(__INT_LEAST64_TYPE__, int_least64_t); + CHECK_TYPES(__UINT_LEAST8_TYPE__, uint_least8_t); + CHECK_TYPES(__UINT_LEAST16_TYPE__, uint_least16_t); + CHECK_TYPES(__UINT_LEAST32_TYPE__, uint_least32_t); + CHECK_TYPES(__UINT_LEAST64_TYPE__, uint_least64_t); +#endif +#ifndef NO_FAST_TYPES + CHECK_TYPES(__INT_FAST8_TYPE__, int_fast8_t); + CHECK_TYPES(__INT_FAST16_TYPE__, int_fast16_t); + CHECK_TYPES(__INT_FAST32_TYPE__, int_fast32_t); + CHECK_TYPES(__INT_FAST64_TYPE__, int_fast64_t); + CHECK_TYPES(__UINT_FAST8_TYPE__, uint_fast8_t); + CHECK_TYPES(__UINT_FAST16_TYPE__, uint_fast16_t); + CHECK_TYPES(__UINT_FAST32_TYPE__, uint_fast32_t); + CHECK_TYPES(__UINT_FAST64_TYPE__, uint_fast64_t); +#endif +#ifdef __INTPTR_TYPE__ + CHECK_TYPES(__INTPTR_TYPE__, intptr_t); +#endif +#ifdef __UINTPTR_TYPE__ + CHECK_TYPES(__UINTPTR_TYPE__, uintptr_t); +#endif +#ifndef NO_MAX_TYPES + CHECK_TYPES(__INTMAX_TYPE__, intmax_t); + CHECK_TYPES(__UINTMAX_TYPE__, uintmax_t); +#endif +#ifndef SIGNAL_SUPPRESS + CHECK_TYPES(__SIG_ATOMIC_TYPE__, sig_atomic_t); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-stdint-7.c b/SingleSource/Regression/C/gcc-dg/c99-stdint-7.c new file mode 100644 index 0000000000..777e895b50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-stdint-7.c @@ -0,0 +1,217 @@ +/* Verify that the limits defined in are those GCC expects + internally to be defined and that they are usable in #if + conditions. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -fhosted" } */ + +#include + +/* Exact-width and pointer-holding types are optional. */ +#if defined(INT8_MIN) != defined(__INT8_TYPE__) +#error "Unexpected INT8_MIN definedness" +#endif +#if defined(INT8_MAX) != defined(__INT8_TYPE__) +#error "Unexpected INT8_MAX definedness" +#endif +#if defined(UINT8_MAX) != defined(__UINT8_TYPE__) +#error "Unexpected UINT8_MAX definedness" +#endif +#if defined(INT16_MIN) != defined(__INT16_TYPE__) +#error "Unexpected INT16_MIN definedness" +#endif +#if defined(INT16_MAX) != defined(__INT16_TYPE__) +#error "Unexpected INT16_MAX definedness" +#endif +#if defined(UINT16_MAX) != defined(__UINT16_TYPE__) +#error "Unexpected UINT16_MAX definedness" +#endif +#if defined(INT32_MIN) != defined(__INT32_TYPE__) +#error "Unexpected INT32_MIN definedness" +#endif +#if defined(INT32_MAX) != defined(__INT32_TYPE__) +#error "Unexpected INT32_MAX definedness" +#endif +#if defined(UINT32_MAX) != defined(__UINT32_TYPE__) +#error "Unexpected UINT32_MAX definedness" +#endif +#if defined(INT64_MIN) != defined(__INT64_TYPE__) +#error "Unexpected INT64_MIN definedness" +#endif +#if defined(INT64_MAX) != defined(__INT64_TYPE__) +#error "Unexpected INT64_MAX definedness" +#endif +#if defined(UINT64_MAX) != defined(__UINT64_TYPE__) +#error "Unexpected UINT64_MAX definedness" +#endif +#if defined(INTPTR_MIN) != defined(__INTPTR_TYPE__) +#error "Unexpected INTPTR_MIN definedness" +#endif +#if defined(INTPTR_MAX) != defined(__INTPTR_TYPE__) +#error "Unexpected INTPTR_MAX definedness" +#endif +#if defined(UINTPTR_MAX) != defined(__UINTPTR_TYPE__) +#error "Unexpected UINTPTR_MAX definedness" +#endif + +#if defined(INT8_MIN) && INT8_MIN != -__INT8_MAX__-1 +#error "INT8_MIN not usable in #if or wrong value" +#endif +#if defined(INT8_MAX) && INT8_MAX != __INT8_MAX__ +#error "INT8_MAX not usable in #if or wrong value" +#endif +#if defined(UINT8_MAX) && UINT8_MAX != __UINT8_MAX__ +#error "UINT8_MAX not usable in #if or wrong value" +#endif +#if defined(INT16_MIN) && INT16_MIN != -__INT16_MAX__-1 +#error "INT16_MIN not usable in #if or wrong value" +#endif +#if defined(INT16_MAX) && INT16_MAX != __INT16_MAX__ +#error "INT16_MAX not usable in #if or wrong value" +#endif +#if defined(UINT16_MAX) && UINT16_MAX != __UINT16_MAX__ +#error "UINT16_MAX not usable in #if or wrong value" +#endif +#if defined(INT32_MIN) && INT32_MIN != -__INT32_MAX__-1 +#error "INT32_MIN not usable in #if or wrong value" +#endif +#if defined(INT32_MAX) && INT32_MAX != __INT32_MAX__ +#error "INT32_MAX not usable in #if or wrong value" +#endif +#if defined(UINT32_MAX) && UINT32_MAX != __UINT32_MAX__ +#error "UINT32_MAX not usable in #if or wrong value" +#endif +#if defined(INT64_MIN) && INT64_MIN != -__INT64_MAX__-1 +#error "INT64_MIN not usable in #if or wrong value" +#endif +#if defined(INT64_MAX) && INT64_MAX != __INT64_MAX__ +#error "INT64_MAX not usable in #if or wrong value" +#endif +#if defined(UINT64_MAX) && UINT64_MAX != __UINT64_MAX__ +#error "UINT64_MAX not usable in #if or wrong value" +#endif + +#if INT_LEAST8_MIN != -__INT_LEAST8_MAX__-1 +#error "INT_LEAST8_MIN not usable in #if or wrong value" +#endif +#if INT_LEAST8_MAX != __INT_LEAST8_MAX__ +#error "INT_LEAST8_MAX not usable in #if or wrong value" +#endif +#if UINT_LEAST8_MAX != __UINT_LEAST8_MAX__ +#error "UINT_LEAST8_MAX not usable in #if or wrong value" +#endif +#if INT_LEAST16_MIN != -__INT_LEAST16_MAX__-1 +#error "INT_LEAST16_MIN not usable in #if or wrong value" +#endif +#if INT_LEAST16_MAX != __INT_LEAST16_MAX__ +#error "INT_LEAST16_MAX not usable in #if or wrong value" +#endif +#if UINT_LEAST16_MAX != __UINT_LEAST16_MAX__ +#error "UINT_LEAST16_MAX not usable in #if or wrong value" +#endif +#if INT_LEAST32_MIN != -__INT_LEAST32_MAX__-1 +#error "INT_LEAST32_MIN not usable in #if or wrong value" +#endif +#if INT_LEAST32_MAX != __INT_LEAST32_MAX__ +#error "INT_LEAST32_MAX not usable in #if or wrong value" +#endif +#if UINT_LEAST32_MAX != __UINT_LEAST32_MAX__ +#error "UINT_LEAST32_MAX not usable in #if or wrong value" +#endif +#if INT_LEAST64_MIN != -__INT_LEAST64_MAX__-1 +#error "INT_LEAST64_MIN not usable in #if or wrong value" +#endif +#if INT_LEAST64_MAX != __INT_LEAST64_MAX__ +#error "INT_LEAST64_MAX not usable in #if or wrong value" +#endif +#if UINT_LEAST64_MAX != __UINT_LEAST64_MAX__ +#error "UINT_LEAST64_MAX not usable in #if or wrong value" +#endif + +#if INT_FAST8_MIN != -__INT_FAST8_MAX__-1 +#error "INT_FAST8_MIN not usable in #if or wrong value" +#endif +#if INT_FAST8_MAX != __INT_FAST8_MAX__ +#error "INT_FAST8_MAX not usable in #if or wrong value" +#endif +#if UINT_FAST8_MAX != __UINT_FAST8_MAX__ +#error "UINT_FAST8_MAX not usable in #if or wrong value" +#endif +#if INT_FAST16_MIN != -__INT_FAST16_MAX__-1 +#error "INT_FAST16_MIN not usable in #if or wrong value" +#endif +#if INT_FAST16_MAX != __INT_FAST16_MAX__ +#error "INT_FAST16_MAX not usable in #if or wrong value" +#endif +#if UINT_FAST16_MAX != __UINT_FAST16_MAX__ +#error "UINT_FAST16_MAX not usable in #if or wrong value" +#endif +#if INT_FAST32_MIN != -__INT_FAST32_MAX__-1 +#error "INT_FAST32_MIN not usable in #if or wrong value" +#endif +#if INT_FAST32_MAX != __INT_FAST32_MAX__ +#error "INT_FAST32_MAX not usable in #if or wrong value" +#endif +#if UINT_FAST32_MAX != __UINT_FAST32_MAX__ +#error "UINT_FAST32_MAX not usable in #if or wrong value" +#endif +#if INT_FAST64_MIN != -__INT_FAST64_MAX__-1 +#error "INT_FAST64_MIN not usable in #if or wrong value" +#endif +#if INT_FAST64_MAX != __INT_FAST64_MAX__ +#error "INT_FAST64_MAX not usable in #if or wrong value" +#endif +#if UINT_FAST64_MAX != __UINT_FAST64_MAX__ +#error "UINT_FAST64_MAX not usable in #if or wrong value" +#endif + +#if defined(INTPTR_MIN) && INTPTR_MIN != -__INTPTR_MAX__-1 +#error "INTPTR_MIN not usable in #if or wrong value" +#endif +#if defined(INTPTR_MAX) && INTPTR_MAX != __INTPTR_MAX__ +#error "INTPTR_MAX not usable in #if or wrong value" +#endif +#if defined(UINTPTR_MAX) && UINTPTR_MAX != __UINTPTR_MAX__ +#error "UINTPTR_MAX not usable in #if or wrong value" +#endif + +#if INTMAX_MIN != -__INTMAX_MAX__-1 +#error "INTMAX_MIN not usable in #if or wrong value" +#endif +#if INTMAX_MAX != __INTMAX_MAX__ +#error "INTMAX_MAX not usable in #if or wrong value" +#endif +#if UINTMAX_MAX != __UINTMAX_MAX__ +#error "UINTMAX_MAX not usable in #if or wrong value" +#endif + +#if PTRDIFF_MIN != -__PTRDIFF_MAX__-1 +#error "PTRDIFF_MIN not usable in #if or wrong value" +#endif +#if PTRDIFF_MAX != __PTRDIFF_MAX__ +#error "PTRDIFF_MAX not usable in #if or wrong value" +#endif + +#if SIG_ATOMIC_MIN != __SIG_ATOMIC_MIN__ +#error "SIG_ATOMIC_MIN not usable in #if or wrong value" +#endif +#if SIG_ATOMIC_MAX != __SIG_ATOMIC_MAX__ +#error "SIG_ATOMIC_MAX not usable in #if or wrong value" +#endif + +#if SIZE_MAX != __SIZE_MAX__ +#error "SIZE_MAX not usable in #if or wrong value" +#endif + +#if WCHAR_MIN != __WCHAR_MIN__ +#error "WCHAR_MIN not usable in #if or wrong value" +#endif +#if WCHAR_MAX != __WCHAR_MAX__ +#error "WCHAR_MAX not usable in #if or wrong value" +#endif + +#if WINT_MIN != __WINT_MIN__ +#error "WINT_MIN not usable in #if or wrong value" +#endif +#if WINT_MAX != __WINT_MAX__ +#error "WINT_MAX not usable in #if or wrong value" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c99-stdint-8.c b/SingleSource/Regression/C/gcc-dg/c99-stdint-8.c new file mode 100644 index 0000000000..c64b3feb4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-stdint-8.c @@ -0,0 +1,9 @@ +/* Verify that the limits defined in are those GCC expects + internally to be defined and that they are usable in #if + conditions. Freestanding version. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -ffreestanding" } */ + +/* The test is that there are no diagnostics, so just include the + hosted version. */ +#include "c99-stdint-7.c" diff --git a/SingleSource/Regression/C/gcc-dg/c99-tag-1.c b/SingleSource/Regression/C/gcc-dg/c99-tag-1.c new file mode 100644 index 0000000000..d7011d2cbe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tag-1.c @@ -0,0 +1,151 @@ +/* Test for handling of tags (6.7.2.3). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +foo (void) +{ + /* Forward declarations of structs and unions are OK; those of enums are + not. */ + { + struct s0; + struct s1 *x0; + union u0; + union u1 *x1; + enum e0; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "forward" "enum forward 1" { target *-*-* } .-1 } */ + enum e1 *x2; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "forward" "enum forward 2" { target *-*-* } .-1 } */ + /* GCC used to fail to diagnose a use of an enum inside its definition. */ + enum e2 { E2A = sizeof (enum e2 *) }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "forward" "enum forward 3" { target *-*-* } .-1 } */ + } + /* A specific type shall have its content defined at most once. But we + may redeclare the tag in different scopes. */ + { + struct s0 { int i; }; /* { dg-message "note: originally defined here" } */ + { + struct s0 { long l; }; + } + { + union s0 { long l; }; + } + struct s0 { int i; }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "rede" "struct redef" { target *-*-* } .-1 } */ + union u0 { int i; }; /* { dg-message "note: originally defined here" } */ + { + union u0 { long l; }; + } + { + struct u0 { long l; }; + } + union u0 { int i; }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "rede" "union redef" { target *-*-* } .-1 } */ + enum e0 { E0A }; /* { dg-message "note: originally defined here" } */ + { + enum e0 { E0B }; + } + { + struct e0 { long l; }; + } + enum e0 { E0B }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "rede" "enum redef" { target *-*-* } .-1 } */ + } + /* Structure, union and enumerated types have a single namespace of tags. */ + { + struct s0; + struct s1; + struct s2 { int i; }; + struct s2; + struct s3 { int i; }; + struct s2 sv; + union u0; + union u2 { int i; }; + union u2; + union u2 uv; + enum e0 { E0A }; + enum e1 { E1A }; + /* None of the following are allowed; some were not detected by GCC. */ + union s0; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + union s1 { int i; }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + union s2; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + union s3 { int i; }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + enum u0 { U0A }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + enum u2 { U2A }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + struct e0; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + struct e1 { int i; }; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + } + /* Explicit shadowing in inner scopes is OK, but references to the tag + that don't explicitly shadow it must (whether in declarations or + expressions) use the correct one of struct/union/enum. */ + { + struct s0; + struct s1; + struct s2 { int i; }; + struct s2; + struct s3 { int i; }; + struct s2 sv; + union u0; + union u2 { int i; }; + union u2; + union u2 uv; + enum e0 { E0A }; + enum e1 { E1A }; + { + union s0; + union s1; + union s2; + union s3; + struct u0; + struct u2; + struct e0; + union e1; + } + { + union s0 *x0; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + int x1[sizeof (union s1 *)]; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + struct t; + union s2 *x2; + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + int x3[sizeof (union s3 *)]; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + struct u; + enum u0 *y0; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong|forward" "wrong tag type" { target *-*-* } .-1 } */ + int y1[sizeof (enum u2 *)]; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong|forward" "wrong tag type" { target *-*-* } .-1 } */ + struct v; + struct e0 *z0; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + int z1[sizeof (struct e1 *)]; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + struct w; + } + /* When explicitly shadowed to be a tag of a different type, references + to the new type of tag must be accepted and those to the old type + rejected. */ + { + union s0; + union s0 *x0; + union s1; + struct s1 *x1; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + union s2; + union s2 *x2; + union s3; + struct s3 *x3; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "wrong" "wrong tag type" { target *-*-* } .-1 } */ + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-tag-2.c b/SingleSource/Regression/C/gcc-dg/c99-tag-2.c new file mode 100644 index 0000000000..22cf90e27d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tag-2.c @@ -0,0 +1,16 @@ +/* Test for handling of tags. A struct defined in an inner scope does + not match one declared in an outer scope. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s; +struct t { struct s *p; } x; + +void +f (void) +{ + /* This is a different struct s from the outer one. */ + struct s { int a; } y; + x.p = &y; /* { dg-error "incompatible" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-tag-3.c b/SingleSource/Regression/C/gcc-dg/c99-tag-3.c new file mode 100644 index 0000000000..11a1096fd7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tag-3.c @@ -0,0 +1,59 @@ +/* Test for handling of tags. "const struct foo;" and similar does + not redeclare an existing tag. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* Plain "struct s;" always declares a tag: the same as one declared + in that scope, or shadowing one from an outer scope. */ +struct s0; +struct s0 { int a; }; +struct s0; +void f (void) { struct s0; } + +/* A declaration with a qualifier or storage class specifier declares + the tag if no other declaration of it is visible. */ +const union u0; /* { dg-warning "13:useless type qualifier in empty declaration" } */ +union u0 { long b; }; + +extern struct s1; /* { dg-warning "15:useless storage class specifier in empty declaration" } */ + +/* But if a declaration of the tag is visible, whether at the same + scope or an outer scope, the declaration specifies the same type as + the previous declaration and does not redeclare the tag (C99 + 6.7.2.3#8). Thus, as it does not declare a declarator, a tag or + the members of an enumeration, it is a constraint violation. */ + +struct s2 { char x; }; +const struct s2; /* { dg-error "14:empty declaration with type qualifier does not redeclare tag" } */ + +union u1; +extern union u1; /* { dg-error "14:empty declaration with storage class specifier does not redeclare tag" } */ + +union u2 { long b; }; +void g(void) { const union u2; } /* { dg-error "28:empty declaration with type qualifier does not redeclare tag" } */ + +/* And it does not redeclare the tag either if the outer tag is the + wrong kind of tag. This also yields an error for the reference to + the wrong kind of tag in addition to the pedwarn for the empty + declaration. */ + +union u3 { float v; }; +void h(void) { const struct u3; } /* { dg-error "29:'u3' defined as wrong kind of tag" } */ +/* { dg-error "29:empty declaration with type qualifier does not redeclare tag" "wrong tag empty" { target *-*-* } .-1 } */ + +/* However, such useless specifiers are OK if the contents of the tag + are being defined, or shadowed in an inner scope with the contents + included in the shadowing. */ + +struct s3; +const struct s3 { int a; }; /* { dg-warning "14:useless type qualifier in empty declaration" } */ + +union u4; +extern union u4 { int z; }; /* { dg-warning "14:useless storage class specifier in empty declaration" } */ + +enum e0 { E0 }; +void i(void) { const enum e0 { E1 }; } /* { dg-warning "32:useless type qualifier in empty declaration" } */ + +union u5 { int p; }; +void j(void) { extern struct u5 { int q; }; } /* { dg-warning "30:useless storage class specifier in empty declaration" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-tag-4.c b/SingleSource/Regression/C/gcc-dg/c99-tag-4.c new file mode 100644 index 0000000000..9ff3ccb8d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tag-4.c @@ -0,0 +1,8 @@ +/* Test for handling of tags. "enum foo;" is invalid after an existing + declaration (does not redeclare the tag) as well as before: bug 107164. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +enum e1; /* { dg-error "ISO C forbids forward references to 'enum' types" } */ +enum e2 { E }; +enum e2; /* { dg-error "empty declaration of 'enum' type does not redeclare tag" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-tag-5.c b/SingleSource/Regression/C/gcc-dg/c99-tag-5.c new file mode 100644 index 0000000000..97fcc75bc2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tag-5.c @@ -0,0 +1,8 @@ +/* Test for handling of tags. "enum foo;" is invalid after an existing + declaration (does not redeclare the tag) as well as before: bug 107164. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic" } */ + +enum e1; /* { dg-warning "ISO C forbids forward references to 'enum' types" } */ +enum e2 { E }; +enum e2; /* { dg-warning "empty declaration of 'enum' type does not redeclare tag" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-tag-6.c b/SingleSource/Regression/C/gcc-dg/c99-tag-6.c new file mode 100644 index 0000000000..8307217523 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tag-6.c @@ -0,0 +1,9 @@ +/* Test for handling of tags. "enum foo;" is invalid after an existing + declaration (does not redeclare the tag) as well as before: bug 107164. + Test this is not diagnosed without -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +enum e1; +enum e2 { E }; +enum e2; diff --git a/SingleSource/Regression/C/gcc-dg/c99-tgmath-1.c b/SingleSource/Regression/C/gcc-dg/c99-tgmath-1.c new file mode 100644 index 0000000000..cfcba8369d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tgmath-1.c @@ -0,0 +1,248 @@ +/* Test for in C99. */ +/* Origin: Matt Austern +/* { dg-do preprocess { target c99_runtime } } */ +/* { dg-options "-std=iso9899:1999" } */ +/* { dg-require-effective-target tgmath_h } */ + +/* Test that tgmath defines the macros it's supposed to. */ +#include + +#ifndef acos +#error acos undefined +#endif + +#ifndef asin +#error asin undefined +#endif + +#ifndef atan +#error atan undefined +#endif + +#ifndef acosh +#error acosh undefined +#endif + +#ifndef asinh +#error asinh undefined +#endif + +#ifndef atanh +#error atanh undefined +#endif + +#ifndef cos +#error cos undefined +#endif + +#ifndef sin +#error sin undefined +#endif + +#ifndef tan +#error tan undefined +#endif + +#ifndef cosh +#error cosh undefined +#endif + +#ifndef sinh +#error sinh undefined +#endif + +#ifndef tanh +#error tanh undefined +#endif + +#ifndef exp +#error exp undefined +#endif + +#ifndef log +#error log undefined +#endif + +#ifndef pow +#error pow undefined +#endif + +#ifndef sqrt +#error sqrt undefined +#endif + +#ifndef fabs +#error fabs undefined +#endif + +#ifndef atan2 +#error atan2 undefined +#endif + +#ifndef cbrt +#error cbrt undefined +#endif + +#ifndef ceil +#error ceil undefined +#endif + +#ifndef copysign +#error copysign undefined +#endif + +#ifndef erf +#error erf undefined +#endif + +#ifndef erfc +#error erfc undefined +#endif + +#ifndef exp2 +#error exp2 undefined +#endif + +#ifndef expm1 +#error expm1 undefined +#endif + +#ifndef fdim +#error fdim undefined +#endif + +#ifndef floor +#error floor undefined +#endif + +#ifndef fma +#error fma undefined +#endif + +#ifndef fmax +#error fmax undefined +#endif + +#ifndef fmin +#error fmin undefined +#endif + +#ifndef fmod +#error fmod undefined +#endif + +#ifndef frexp +#error frexp undefined +#endif + +#ifndef hypot +#error hypot undefined +#endif + +#ifndef ilogb +#error ilogb undefined +#endif + +#ifndef ldexp +#error ldexp undefined +#endif + +#ifndef lgamma +#error lgamma undefined +#endif + +#ifndef llrint +#error llrint undefined +#endif + +#ifndef llround +#error llround undefined +#endif + +#ifndef log10 +#error log10 undefined +#endif + +#ifndef log1p +#error log1p undefined +#endif + +#ifndef log2 +#error log2 undefined +#endif + +#ifndef logb +#error logb undefined +#endif + +#ifndef lrint +#error lrint undefined +#endif + +#ifndef lround +#error lround undefined +#endif + +#ifndef nearbyint +#error nearbyint undefined +#endif + +#ifndef nextafter +#error nextafter undefined +#endif + +#ifndef nexttoward +#error nexttoward undefined +#endif + +#ifndef remainder +#error remainder undefined +#endif + +#ifndef remquo +#error remquo undefined +#endif + +#ifndef rint +#error rint undefined +#endif + +#ifndef round +#error round undefined +#endif + +#ifndef scalbn +#error scalbn undefined +#endif + +#ifndef scalbln +#error scalbln undefined +#endif + +#ifndef tgamma +#error tgamma undefined +#endif + +#ifndef trunc +#error trunc undefined +#endif + +#ifndef carg +#error carg undefined +#endif + +#ifndef cimag +#error cimag undefined +#endif + +#ifndef conj +#error conj undefined +#endif + +#ifndef cproj +#error cproj undefined +#endif + +#ifndef creal +#error creal undefined +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c99-tgmath-2.c b/SingleSource/Regression/C/gcc-dg/c99-tgmath-2.c new file mode 100644 index 0000000000..7b0cfa4c6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tgmath-2.c @@ -0,0 +1,15 @@ +/* Test for in C99. */ +/* Origin: Matt Austern +/* { dg-do compile { target c99_runtime } } */ +/* { dg-options "-std=iso9899:1999" } */ +/* { dg-require-effective-target tgmath_h } */ + +/* Test that invoking type-generic sin on a float invokes sinf. */ +#include + +float foo(float x) +{ + return sin(x); +} + +/* { dg-final { scan-assembler "sinf" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-tgmath-3.c b/SingleSource/Regression/C/gcc-dg/c99-tgmath-3.c new file mode 100644 index 0000000000..8ed8b30f8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tgmath-3.c @@ -0,0 +1,15 @@ +/* Test for in C99. */ +/* Origin: Matt Austern +/* { dg-do compile { target c99_runtime } } */ +/* { dg-options "-std=iso9899:1999" } */ +/* { dg-require-effective-target tgmath_h } */ + +/* Test that invoking type-generic exp on a complex invokes cexp. */ +#include + +complex double foo(complex double x) +{ + return exp(x); +} + +/* { dg-final { scan-assembler "cexp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-tgmath-4.c b/SingleSource/Regression/C/gcc-dg/c99-tgmath-4.c new file mode 100644 index 0000000000..f66bcdffae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-tgmath-4.c @@ -0,0 +1,15 @@ +/* Test for in C99. */ +/* Origin: Matt Austern +/* { dg-do compile { target c99_runtime } } */ +/* { dg-options "-std=iso9899:1999" } */ +/* { dg-require-effective-target tgmath_h } */ + +/* Test that invoking type-generic pow on complex float invokes cpowf. */ +#include + +complex double foo(complex float x, float y) +{ + return pow(x, y); +} + +/* { dg-final { scan-assembler "cpowf" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-thread-local-1.c b/SingleSource/Regression/C/gcc-dg/c99-thread-local-1.c new file mode 100644 index 0000000000..ff531252c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-thread-local-1.c @@ -0,0 +1,5 @@ +/* Test for _Thread_local: not in C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +static _Thread_local int x; /* { dg-error "_Thread_local" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-typedef-1.c b/SingleSource/Regression/C/gcc-dg/c99-typedef-1.c new file mode 100644 index 0000000000..8aacb3bc2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-typedef-1.c @@ -0,0 +1,6 @@ +/* Test typedef redeclaration not permitted in C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef int TI; /* { dg-message "previous declaration" } */ +typedef int TI; /* { dg-error "redefinition of typedef" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-typespec-1.c b/SingleSource/Regression/C/gcc-dg/c99-typespec-1.c new file mode 100644 index 0000000000..a72335e4be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-typespec-1.c @@ -0,0 +1,1164 @@ +/* Test for valid and invalid combinations of type specifiers in C99. + Similar to typespec-1.c but with -pedantic-errors. + Includes _Complex, but not _Imaginary (expected to be removed in TC2). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +typedef char type; +void *x0; +char *x1; +short *x2; +int *x3; +long *x4; +float *x5; +double *x6; +signed *x7; +unsigned *x8; +_Bool *x9; +_Complex *x10; /* { dg-error "" "_Complex" } */ +type *x11; +void void *x12; /* { dg-error "" "void void" } */ +void char *x13; /* { dg-error "" "void char" } */ +void short *x14; /* { dg-error "" "void short" } */ +void int *x15; /* { dg-error "" "void int" } */ +void long *x16; /* { dg-error "" "void long" } */ +void float *x17; /* { dg-error "" "void float" } */ +void double *x18; /* { dg-error "" "void double" } */ +void signed *x19; /* { dg-error "" "void signed" } */ +void unsigned *x20; /* { dg-error "" "void unsigned" } */ +void _Bool *x21; /* { dg-error "" "void _Bool" } */ +void _Complex *x22; /* { dg-error "" "void _Complex" } */ +char void *x23; /* { dg-error "" "char void" } */ +char char *x24; /* { dg-error "" "char char" } */ +char short *x25; /* { dg-error "" "char short" } */ +char int *x26; /* { dg-error "" "char int" } */ +char long *x27; /* { dg-error "" "char long" } */ +char float *x28; /* { dg-error "" "char float" } */ +char double *x29; /* { dg-error "" "char double" } */ +char signed *x30; +char unsigned *x31; +char _Bool *x32; /* { dg-error "" "char _Bool" } */ +char _Complex *x33; /* { dg-error "" "char _Complex" } */ +short void *x34; /* { dg-error "" "short void" } */ +short char *x35; /* { dg-error "" "short char" } */ +short short *x36; /* { dg-error "" "short short" } */ +short int *x37; +short long *x38; /* { dg-error "" "short long" } */ +short float *x39; /* { dg-error "" "short float" } */ +short double *x40; /* { dg-error "" "short double" } */ +short signed *x41; +short unsigned *x42; +short _Bool *x43; /* { dg-error "" "short _Bool" } */ +short _Complex *x44; /* { dg-error "" "short _Complex" } */ +int void *x45; /* { dg-error "" "int void" } */ +int char *x46; /* { dg-error "" "int char" } */ +int short *x47; +int int *x48; /* { dg-error "" "int int" } */ +int long *x49; +int float *x50; /* { dg-error "" "int float" } */ +int double *x51; /* { dg-error "" "int double" } */ +int signed *x52; +int unsigned *x53; +int _Bool *x54; /* { dg-error "" "int _Bool" } */ +int _Complex *x55; /* { dg-error "" "int _Complex" } */ +long void *x56; /* { dg-error "" "long void" } */ +long char *x57; /* { dg-error "" "long char" } */ +long short *x58; /* { dg-error "" "long short" } */ +long int *x59; +long long *x60; +long float *x61; /* { dg-error "" "long float" } */ +long double *x62; +long signed *x63; +long unsigned *x64; +long _Bool *x65; /* { dg-error "" "long _Bool" } */ +long _Complex *x66; /* { dg-error "" "long _Complex" } */ +float void *x67; /* { dg-error "" "float void" } */ +float char *x68; /* { dg-error "" "float char" } */ +float short *x69; /* { dg-error "" "float short" } */ +float int *x70; /* { dg-error "" "float int" } */ +float long *x71; /* { dg-error "" "float long" } */ +float float *x72; /* { dg-error "" "float float" } */ +float double *x73; /* { dg-error "" "float double" } */ +float signed *x74; /* { dg-error "" "float signed" } */ +float unsigned *x75; /* { dg-error "" "float unsigned" } */ +float _Bool *x76; /* { dg-error "" "float _Bool" } */ +float _Complex *x77; +double void *x78; /* { dg-error "" "double void" } */ +double char *x79; /* { dg-error "" "double char" } */ +double short *x80; /* { dg-error "" "double short" } */ +double int *x81; /* { dg-error "" "double int" } */ +double long *x82; +double float *x83; /* { dg-error "" "double float" } */ +double double *x84; /* { dg-error "" "double double" } */ +double signed *x85; /* { dg-error "" "double signed" } */ +double unsigned *x86; /* { dg-error "" "double unsigned" } */ +double _Bool *x87; /* { dg-error "" "double _Bool" } */ +double _Complex *x88; +signed void *x89; /* { dg-error "" "signed void" } */ +signed char *x90; +signed short *x91; +signed int *x92; +signed long *x93; +signed float *x94; /* { dg-error "" "signed float" } */ +signed double *x95; /* { dg-error "" "signed double" } */ +signed signed *x96; /* { dg-error "" "signed signed" } */ +signed unsigned *x97; /* { dg-error "" "signed unsigned" } */ +signed _Bool *x98; /* { dg-error "" "signed _Bool" } */ +signed _Complex *x99; /* { dg-error "" "signed _Complex" } */ +unsigned void *x100; /* { dg-error "" "unsigned void" } */ +unsigned char *x101; +unsigned short *x102; +unsigned int *x103; +unsigned long *x104; +unsigned float *x105; /* { dg-error "" "unsigned float" } */ +unsigned double *x106; /* { dg-error "" "unsigned double" } */ +unsigned signed *x107; /* { dg-error "" "unsigned signed" } */ +unsigned unsigned *x108; /* { dg-error "" "unsigned unsigned" } */ +unsigned _Bool *x109; /* { dg-error "" "unsigned _Bool" } */ +unsigned _Complex *x110; /* { dg-error "" "unsigned _Complex" } */ +_Bool void *x111; /* { dg-error "" "_Bool void" } */ +_Bool char *x112; /* { dg-error "" "_Bool char" } */ +_Bool short *x113; /* { dg-error "" "_Bool short" } */ +_Bool int *x114; /* { dg-error "" "_Bool int" } */ +_Bool long *x115; /* { dg-error "" "_Bool long" } */ +_Bool float *x116; /* { dg-error "" "_Bool float" } */ +_Bool double *x117; /* { dg-error "" "_Bool double" } */ +_Bool signed *x118; /* { dg-error "" "_Bool signed" } */ +_Bool unsigned *x119; /* { dg-error "" "_Bool unsigned" } */ +_Bool _Bool *x120; /* { dg-error "" "_Bool _Bool" } */ +_Bool _Complex *x121; /* { dg-error "" "_Bool _Complex" } */ +_Complex void *x122; /* { dg-error "" "_Complex void" } */ +_Complex char *x123; /* { dg-error "" "_Complex char" } */ +_Complex short *x124; /* { dg-error "" "_Complex short" } */ +_Complex int *x125; /* { dg-error "" "_Complex int" } */ +_Complex long *x126; /* { dg-error "" "_Complex long" } */ +_Complex float *x127; +_Complex double *x128; +_Complex signed *x129; /* { dg-error "" "_Complex signed" } */ +_Complex unsigned *x130; /* { dg-error "" "_Complex unsigned" } */ +_Complex _Bool *x131; /* { dg-error "" "_Complex _Bool" } */ +_Complex _Complex *x132; /* { dg-error "" "_Complex _Complex" } */ +type void *x133; /* { dg-error "" "type void" } */ +type char *x134; /* { dg-error "" "type char" } */ +type short *x135; /* { dg-error "" "type short" } */ +type int *x136; /* { dg-error "" "type int" } */ +type long *x137; /* { dg-error "" "type long" } */ +type float *x138; /* { dg-error "" "type float" } */ +type double *x139; /* { dg-error "" "type double" } */ +type signed *x140; /* { dg-error "" "type signed" } */ +type unsigned *x141; /* { dg-error "" "type unsigned" } */ +type _Bool *x142; /* { dg-error "" "type _Bool" } */ +type _Complex *x143; /* { dg-error "" "type _Complex" } */ +char signed void *x144; /* { dg-error "" "char signed void" } */ +char signed char *x145; /* { dg-error "" "char signed char" } */ +char signed short *x146; /* { dg-error "" "char signed short" } */ +char signed int *x147; /* { dg-error "" "char signed int" } */ +char signed long *x148; /* { dg-error "" "char signed long" } */ +char signed float *x149; /* { dg-error "" "char signed float" } */ +char signed double *x150; /* { dg-error "" "char signed double" } */ +char signed signed *x151; /* { dg-error "" "char signed signed" } */ +char signed unsigned *x152; /* { dg-error "" "char signed unsigned" } */ +char signed _Bool *x153; /* { dg-error "" "char signed _Bool" } */ +char signed _Complex *x154; /* { dg-error "" "char signed _Complex" } */ +char unsigned void *x155; /* { dg-error "" "char unsigned void" } */ +char unsigned char *x156; /* { dg-error "" "char unsigned char" } */ +char unsigned short *x157; /* { dg-error "" "char unsigned short" } */ +char unsigned int *x158; /* { dg-error "" "char unsigned int" } */ +char unsigned long *x159; /* { dg-error "" "char unsigned long" } */ +char unsigned float *x160; /* { dg-error "" "char unsigned float" } */ +char unsigned double *x161; /* { dg-error "" "char unsigned double" } */ +char unsigned signed *x162; /* { dg-error "" "char unsigned signed" } */ +char unsigned unsigned *x163; /* { dg-error "" "char unsigned unsigned" } */ +char unsigned _Bool *x164; /* { dg-error "" "char unsigned _Bool" } */ +char unsigned _Complex *x165; /* { dg-error "" "char unsigned _Complex" } */ +short int void *x166; /* { dg-error "" "short int void" } */ +short int char *x167; /* { dg-error "" "short int char" } */ +short int short *x168; /* { dg-error "" "short int short" } */ +short int int *x169; /* { dg-error "" "short int int" } */ +short int long *x170; /* { dg-error "" "short int long" } */ +short int float *x171; /* { dg-error "" "short int float" } */ +short int double *x172; /* { dg-error "" "short int double" } */ +short int signed *x173; +short int unsigned *x174; +short int _Bool *x175; /* { dg-error "" "short int _Bool" } */ +short int _Complex *x176; /* { dg-error "" "short int _Complex" } */ +short signed void *x177; /* { dg-error "" "short signed void" } */ +short signed char *x178; /* { dg-error "" "short signed char" } */ +short signed short *x179; /* { dg-error "" "short signed short" } */ +short signed int *x180; +short signed long *x181; /* { dg-error "" "short signed long" } */ +short signed float *x182; /* { dg-error "" "short signed float" } */ +short signed double *x183; /* { dg-error "" "short signed double" } */ +short signed signed *x184; /* { dg-error "" "short signed signed" } */ +short signed unsigned *x185; /* { dg-error "" "short signed unsigned" } */ +short signed _Bool *x186; /* { dg-error "" "short signed _Bool" } */ +short signed _Complex *x187; /* { dg-error "" "short signed _Complex" } */ +short unsigned void *x188; /* { dg-error "" "short unsigned void" } */ +short unsigned char *x189; /* { dg-error "" "short unsigned char" } */ +short unsigned short *x190; /* { dg-error "" "short unsigned short" } */ +short unsigned int *x191; +short unsigned long *x192; /* { dg-error "" "short unsigned long" } */ +short unsigned float *x193; /* { dg-error "" "short unsigned float" } */ +short unsigned double *x194; /* { dg-error "" "short unsigned double" } */ +short unsigned signed *x195; /* { dg-error "" "short unsigned signed" } */ +short unsigned unsigned *x196; /* { dg-error "" "short unsigned unsigned" } */ +short unsigned _Bool *x197; /* { dg-error "" "short unsigned _Bool" } */ +short unsigned _Complex *x198; /* { dg-error "" "short unsigned _Complex" } */ +int short void *x199; /* { dg-error "" "int short void" } */ +int short char *x200; /* { dg-error "" "int short char" } */ +int short short *x201; /* { dg-error "" "int short short" } */ +int short int *x202; /* { dg-error "" "int short int" } */ +int short long *x203; /* { dg-error "" "int short long" } */ +int short float *x204; /* { dg-error "" "int short float" } */ +int short double *x205; /* { dg-error "" "int short double" } */ +int short signed *x206; +int short unsigned *x207; +int short _Bool *x208; /* { dg-error "" "int short _Bool" } */ +int short _Complex *x209; /* { dg-error "" "int short _Complex" } */ +int long void *x210; /* { dg-error "" "int long void" } */ +int long char *x211; /* { dg-error "" "int long char" } */ +int long short *x212; /* { dg-error "" "int long short" } */ +int long int *x213; /* { dg-error "" "int long int" } */ +int long long *x214; +int long float *x215; /* { dg-error "" "int long float" } */ +int long double *x216; /* { dg-error "" "int long double" } */ +int long signed *x217; +int long unsigned *x218; +int long _Bool *x219; /* { dg-error "" "int long _Bool" } */ +int long _Complex *x220; /* { dg-error "" "int long _Complex" } */ +int signed void *x221; /* { dg-error "" "int signed void" } */ +int signed char *x222; /* { dg-error "" "int signed char" } */ +int signed short *x223; +int signed int *x224; /* { dg-error "" "int signed int" } */ +int signed long *x225; +int signed float *x226; /* { dg-error "" "int signed float" } */ +int signed double *x227; /* { dg-error "" "int signed double" } */ +int signed signed *x228; /* { dg-error "" "int signed signed" } */ +int signed unsigned *x229; /* { dg-error "" "int signed unsigned" } */ +int signed _Bool *x230; /* { dg-error "" "int signed _Bool" } */ +int signed _Complex *x231; /* { dg-error "" "int signed _Complex" } */ +int unsigned void *x232; /* { dg-error "" "int unsigned void" } */ +int unsigned char *x233; /* { dg-error "" "int unsigned char" } */ +int unsigned short *x234; +int unsigned int *x235; /* { dg-error "" "int unsigned int" } */ +int unsigned long *x236; +int unsigned float *x237; /* { dg-error "" "int unsigned float" } */ +int unsigned double *x238; /* { dg-error "" "int unsigned double" } */ +int unsigned signed *x239; /* { dg-error "" "int unsigned signed" } */ +int unsigned unsigned *x240; /* { dg-error "" "int unsigned unsigned" } */ +int unsigned _Bool *x241; /* { dg-error "" "int unsigned _Bool" } */ +int unsigned _Complex *x242; /* { dg-error "" "int unsigned _Complex" } */ +long int void *x243; /* { dg-error "" "long int void" } */ +long int char *x244; /* { dg-error "" "long int char" } */ +long int short *x245; /* { dg-error "" "long int short" } */ +long int int *x246; /* { dg-error "" "long int int" } */ +long int long *x247; +long int float *x248; /* { dg-error "" "long int float" } */ +long int double *x249; /* { dg-error "" "long int double" } */ +long int signed *x250; +long int unsigned *x251; +long int _Bool *x252; /* { dg-error "" "long int _Bool" } */ +long int _Complex *x253; /* { dg-error "" "long int _Complex" } */ +long long void *x254; /* { dg-error "" "long long void" } */ +long long char *x255; /* { dg-error "" "long long char" } */ +long long short *x256; /* { dg-error "" "long long short" } */ +long long int *x257; +long long long *x258; /* { dg-error "" "long long long" } */ +long long float *x259; /* { dg-error "" "long long float" } */ +long long double *x260; /* { dg-error "" "long long double" } */ +long long signed *x261; +long long unsigned *x262; +long long _Bool *x263; /* { dg-error "" "long long _Bool" } */ +long long _Complex *x264; /* { dg-error "" "long long _Complex" } */ +long double void *x265; /* { dg-error "" "long double void" } */ +long double char *x266; /* { dg-error "" "long double char" } */ +long double short *x267; /* { dg-error "" "long double short" } */ +long double int *x268; /* { dg-error "" "long double int" } */ +long double long *x269; /* { dg-error "" "long double long" } */ +long double float *x270; /* { dg-error "" "long double float" } */ +long double double *x271; /* { dg-error "" "long double double" } */ +long double signed *x272; /* { dg-error "" "long double signed" } */ +long double unsigned *x273; /* { dg-error "" "long double unsigned" } */ +long double _Bool *x274; /* { dg-error "" "long double _Bool" } */ +long double _Complex *x275; +long signed void *x276; /* { dg-error "" "long signed void" } */ +long signed char *x277; /* { dg-error "" "long signed char" } */ +long signed short *x278; /* { dg-error "" "long signed short" } */ +long signed int *x279; +long signed long *x280; +long signed float *x281; /* { dg-error "" "long signed float" } */ +long signed double *x282; /* { dg-error "" "long signed double" } */ +long signed signed *x283; /* { dg-error "" "long signed signed" } */ +long signed unsigned *x284; /* { dg-error "" "long signed unsigned" } */ +long signed _Bool *x285; /* { dg-error "" "long signed _Bool" } */ +long signed _Complex *x286; /* { dg-error "" "long signed _Complex" } */ +long unsigned void *x287; /* { dg-error "" "long unsigned void" } */ +long unsigned char *x288; /* { dg-error "" "long unsigned char" } */ +long unsigned short *x289; /* { dg-error "" "long unsigned short" } */ +long unsigned int *x290; +long unsigned long *x291; +long unsigned float *x292; /* { dg-error "" "long unsigned float" } */ +long unsigned double *x293; /* { dg-error "" "long unsigned double" } */ +long unsigned signed *x294; /* { dg-error "" "long unsigned signed" } */ +long unsigned unsigned *x295; /* { dg-error "" "long unsigned unsigned" } */ +long unsigned _Bool *x296; /* { dg-error "" "long unsigned _Bool" } */ +long unsigned _Complex *x297; /* { dg-error "" "long unsigned _Complex" } */ +long _Complex void *x298; /* { dg-error "" "long _Complex void" } */ +long _Complex char *x299; /* { dg-error "" "long _Complex char" } */ +long _Complex short *x300; /* { dg-error "" "long _Complex short" } */ +long _Complex int *x301; /* { dg-error "" "long _Complex int" } */ +long _Complex long *x302; /* { dg-error "" "long _Complex long" } */ +long _Complex float *x303; /* { dg-error "" "long _Complex float" } */ +long _Complex double *x304; +long _Complex signed *x305; /* { dg-error "" "long _Complex signed" } */ +long _Complex unsigned *x306; /* { dg-error "" "long _Complex unsigned" } */ +long _Complex _Bool *x307; /* { dg-error "" "long _Complex _Bool" } */ +long _Complex _Complex *x308; /* { dg-error "" "long _Complex _Complex" } */ +float _Complex void *x309; /* { dg-error "" "float _Complex void" } */ +float _Complex char *x310; /* { dg-error "" "float _Complex char" } */ +float _Complex short *x311; /* { dg-error "" "float _Complex short" } */ +float _Complex int *x312; /* { dg-error "" "float _Complex int" } */ +float _Complex long *x313; /* { dg-error "" "float _Complex long" } */ +float _Complex float *x314; /* { dg-error "" "float _Complex float" } */ +float _Complex double *x315; /* { dg-error "" "float _Complex double" } */ +float _Complex signed *x316; /* { dg-error "" "float _Complex signed" } */ +float _Complex unsigned *x317; /* { dg-error "" "float _Complex unsigned" } */ +float _Complex _Bool *x318; /* { dg-error "" "float _Complex _Bool" } */ +float _Complex _Complex *x319; /* { dg-error "" "float _Complex _Complex" } */ +double long void *x320; /* { dg-error "" "double long void" } */ +double long char *x321; /* { dg-error "" "double long char" } */ +double long short *x322; /* { dg-error "" "double long short" } */ +double long int *x323; /* { dg-error "" "double long int" } */ +double long long *x324; /* { dg-error "" "double long long" } */ +double long float *x325; /* { dg-error "" "double long float" } */ +double long double *x326; /* { dg-error "" "double long double" } */ +double long signed *x327; /* { dg-error "" "double long signed" } */ +double long unsigned *x328; /* { dg-error "" "double long unsigned" } */ +double long _Bool *x329; /* { dg-error "" "double long _Bool" } */ +double long _Complex *x330; +double _Complex void *x331; /* { dg-error "" "double _Complex void" } */ +double _Complex char *x332; /* { dg-error "" "double _Complex char" } */ +double _Complex short *x333; /* { dg-error "" "double _Complex short" } */ +double _Complex int *x334; /* { dg-error "" "double _Complex int" } */ +double _Complex long *x335; +double _Complex float *x336; /* { dg-error "" "double _Complex float" } */ +double _Complex double *x337; /* { dg-error "" "double _Complex double" } */ +double _Complex signed *x338; /* { dg-error "" "double _Complex signed" } */ +double _Complex unsigned *x339; /* { dg-error "" "double _Complex unsigned" } */ +double _Complex _Bool *x340; /* { dg-error "" "double _Complex _Bool" } */ +double _Complex _Complex *x341; /* { dg-error "" "double _Complex _Complex" } */ +signed char void *x342; /* { dg-error "" "signed char void" } */ +signed char char *x343; /* { dg-error "" "signed char char" } */ +signed char short *x344; /* { dg-error "" "signed char short" } */ +signed char int *x345; /* { dg-error "" "signed char int" } */ +signed char long *x346; /* { dg-error "" "signed char long" } */ +signed char float *x347; /* { dg-error "" "signed char float" } */ +signed char double *x348; /* { dg-error "" "signed char double" } */ +signed char signed *x349; /* { dg-error "" "signed char signed" } */ +signed char unsigned *x350; /* { dg-error "" "signed char unsigned" } */ +signed char _Bool *x351; /* { dg-error "" "signed char _Bool" } */ +signed char _Complex *x352; /* { dg-error "" "signed char _Complex" } */ +signed short void *x353; /* { dg-error "" "signed short void" } */ +signed short char *x354; /* { dg-error "" "signed short char" } */ +signed short short *x355; /* { dg-error "" "signed short short" } */ +signed short int *x356; +signed short long *x357; /* { dg-error "" "signed short long" } */ +signed short float *x358; /* { dg-error "" "signed short float" } */ +signed short double *x359; /* { dg-error "" "signed short double" } */ +signed short signed *x360; /* { dg-error "" "signed short signed" } */ +signed short unsigned *x361; /* { dg-error "" "signed short unsigned" } */ +signed short _Bool *x362; /* { dg-error "" "signed short _Bool" } */ +signed short _Complex *x363; /* { dg-error "" "signed short _Complex" } */ +signed int void *x364; /* { dg-error "" "signed int void" } */ +signed int char *x365; /* { dg-error "" "signed int char" } */ +signed int short *x366; +signed int int *x367; /* { dg-error "" "signed int int" } */ +signed int long *x368; +signed int float *x369; /* { dg-error "" "signed int float" } */ +signed int double *x370; /* { dg-error "" "signed int double" } */ +signed int signed *x371; /* { dg-error "" "signed int signed" } */ +signed int unsigned *x372; /* { dg-error "" "signed int unsigned" } */ +signed int _Bool *x373; /* { dg-error "" "signed int _Bool" } */ +signed int _Complex *x374; /* { dg-error "" "signed int _Complex" } */ +signed long void *x375; /* { dg-error "" "signed long void" } */ +signed long char *x376; /* { dg-error "" "signed long char" } */ +signed long short *x377; /* { dg-error "" "signed long short" } */ +signed long int *x378; +signed long long *x379; +signed long float *x380; /* { dg-error "" "signed long float" } */ +signed long double *x381; /* { dg-error "" "signed long double" } */ +signed long signed *x382; /* { dg-error "" "signed long signed" } */ +signed long unsigned *x383; /* { dg-error "" "signed long unsigned" } */ +signed long _Bool *x384; /* { dg-error "" "signed long _Bool" } */ +signed long _Complex *x385; /* { dg-error "" "signed long _Complex" } */ +unsigned char void *x386; /* { dg-error "" "unsigned char void" } */ +unsigned char char *x387; /* { dg-error "" "unsigned char char" } */ +unsigned char short *x388; /* { dg-error "" "unsigned char short" } */ +unsigned char int *x389; /* { dg-error "" "unsigned char int" } */ +unsigned char long *x390; /* { dg-error "" "unsigned char long" } */ +unsigned char float *x391; /* { dg-error "" "unsigned char float" } */ +unsigned char double *x392; /* { dg-error "" "unsigned char double" } */ +unsigned char signed *x393; /* { dg-error "" "unsigned char signed" } */ +unsigned char unsigned *x394; /* { dg-error "" "unsigned char unsigned" } */ +unsigned char _Bool *x395; /* { dg-error "" "unsigned char _Bool" } */ +unsigned char _Complex *x396; /* { dg-error "" "unsigned char _Complex" } */ +unsigned short void *x397; /* { dg-error "" "unsigned short void" } */ +unsigned short char *x398; /* { dg-error "" "unsigned short char" } */ +unsigned short short *x399; /* { dg-error "" "unsigned short short" } */ +unsigned short int *x400; +unsigned short long *x401; /* { dg-error "" "unsigned short long" } */ +unsigned short float *x402; /* { dg-error "" "unsigned short float" } */ +unsigned short double *x403; /* { dg-error "" "unsigned short double" } */ +unsigned short signed *x404; /* { dg-error "" "unsigned short signed" } */ +unsigned short unsigned *x405; /* { dg-error "" "unsigned short unsigned" } */ +unsigned short _Bool *x406; /* { dg-error "" "unsigned short _Bool" } */ +unsigned short _Complex *x407; /* { dg-error "" "unsigned short _Complex" } */ +unsigned int void *x408; /* { dg-error "" "unsigned int void" } */ +unsigned int char *x409; /* { dg-error "" "unsigned int char" } */ +unsigned int short *x410; +unsigned int int *x411; /* { dg-error "" "unsigned int int" } */ +unsigned int long *x412; +unsigned int float *x413; /* { dg-error "" "unsigned int float" } */ +unsigned int double *x414; /* { dg-error "" "unsigned int double" } */ +unsigned int signed *x415; /* { dg-error "" "unsigned int signed" } */ +unsigned int unsigned *x416; /* { dg-error "" "unsigned int unsigned" } */ +unsigned int _Bool *x417; /* { dg-error "" "unsigned int _Bool" } */ +unsigned int _Complex *x418; /* { dg-error "" "unsigned int _Complex" } */ +unsigned long void *x419; /* { dg-error "" "unsigned long void" } */ +unsigned long char *x420; /* { dg-error "" "unsigned long char" } */ +unsigned long short *x421; /* { dg-error "" "unsigned long short" } */ +unsigned long int *x422; +unsigned long long *x423; +unsigned long float *x424; /* { dg-error "" "unsigned long float" } */ +unsigned long double *x425; /* { dg-error "" "unsigned long double" } */ +unsigned long signed *x426; /* { dg-error "" "unsigned long signed" } */ +unsigned long unsigned *x427; /* { dg-error "" "unsigned long unsigned" } */ +unsigned long _Bool *x428; /* { dg-error "" "unsigned long _Bool" } */ +unsigned long _Complex *x429; /* { dg-error "" "unsigned long _Complex" } */ +_Complex long void *x430; /* { dg-error "" "_Complex long void" } */ +_Complex long char *x431; /* { dg-error "" "_Complex long char" } */ +_Complex long short *x432; /* { dg-error "" "_Complex long short" } */ +_Complex long int *x433; /* { dg-error "" "_Complex long int" } */ +_Complex long long *x434; /* { dg-error "" "_Complex long long" } */ +_Complex long float *x435; /* { dg-error "" "_Complex long float" } */ +_Complex long double *x436; +_Complex long signed *x437; /* { dg-error "" "_Complex long signed" } */ +_Complex long unsigned *x438; /* { dg-error "" "_Complex long unsigned" } */ +_Complex long _Bool *x439; /* { dg-error "" "_Complex long _Bool" } */ +_Complex long _Complex *x440; /* { dg-error "" "_Complex long _Complex" } */ +_Complex float void *x441; /* { dg-error "" "_Complex float void" } */ +_Complex float char *x442; /* { dg-error "" "_Complex float char" } */ +_Complex float short *x443; /* { dg-error "" "_Complex float short" } */ +_Complex float int *x444; /* { dg-error "" "_Complex float int" } */ +_Complex float long *x445; /* { dg-error "" "_Complex float long" } */ +_Complex float float *x446; /* { dg-error "" "_Complex float float" } */ +_Complex float double *x447; /* { dg-error "" "_Complex float double" } */ +_Complex float signed *x448; /* { dg-error "" "_Complex float signed" } */ +_Complex float unsigned *x449; /* { dg-error "" "_Complex float unsigned" } */ +_Complex float _Bool *x450; /* { dg-error "" "_Complex float _Bool" } */ +_Complex float _Complex *x451; /* { dg-error "" "_Complex float _Complex" } */ +_Complex double void *x452; /* { dg-error "" "_Complex double void" } */ +_Complex double char *x453; /* { dg-error "" "_Complex double char" } */ +_Complex double short *x454; /* { dg-error "" "_Complex double short" } */ +_Complex double int *x455; /* { dg-error "" "_Complex double int" } */ +_Complex double long *x456; +_Complex double float *x457; /* { dg-error "" "_Complex double float" } */ +_Complex double double *x458; /* { dg-error "" "_Complex double double" } */ +_Complex double signed *x459; /* { dg-error "" "_Complex double signed" } */ +_Complex double unsigned *x460; /* { dg-error "" "_Complex double unsigned" } */ +_Complex double _Bool *x461; /* { dg-error "" "_Complex double _Bool" } */ +_Complex double _Complex *x462; /* { dg-error "" "_Complex double _Complex" } */ +short int signed void *x463; /* { dg-error "" "short int signed void" } */ +short int signed char *x464; /* { dg-error "" "short int signed char" } */ +short int signed short *x465; /* { dg-error "" "short int signed short" } */ +short int signed int *x466; /* { dg-error "" "short int signed int" } */ +short int signed long *x467; /* { dg-error "" "short int signed long" } */ +short int signed float *x468; /* { dg-error "" "short int signed float" } */ +short int signed double *x469; /* { dg-error "" "short int signed double" } */ +short int signed signed *x470; /* { dg-error "" "short int signed signed" } */ +short int signed unsigned *x471; /* { dg-error "" "short int signed unsigned" } */ +short int signed _Bool *x472; /* { dg-error "" "short int signed _Bool" } */ +short int signed _Complex *x473; /* { dg-error "" "short int signed _Complex" } */ +short int unsigned void *x474; /* { dg-error "" "short int unsigned void" } */ +short int unsigned char *x475; /* { dg-error "" "short int unsigned char" } */ +short int unsigned short *x476; /* { dg-error "" "short int unsigned short" } */ +short int unsigned int *x477; /* { dg-error "" "short int unsigned int" } */ +short int unsigned long *x478; /* { dg-error "" "short int unsigned long" } */ +short int unsigned float *x479; /* { dg-error "" "short int unsigned float" } */ +short int unsigned double *x480; /* { dg-error "" "short int unsigned double" } */ +short int unsigned signed *x481; /* { dg-error "" "short int unsigned signed" } */ +short int unsigned unsigned *x482; /* { dg-error "" "short int unsigned unsigned" } */ +short int unsigned _Bool *x483; /* { dg-error "" "short int unsigned _Bool" } */ +short int unsigned _Complex *x484; /* { dg-error "" "short int unsigned _Complex" } */ +short signed int void *x485; /* { dg-error "" "short signed int void" } */ +short signed int char *x486; /* { dg-error "" "short signed int char" } */ +short signed int short *x487; /* { dg-error "" "short signed int short" } */ +short signed int int *x488; /* { dg-error "" "short signed int int" } */ +short signed int long *x489; /* { dg-error "" "short signed int long" } */ +short signed int float *x490; /* { dg-error "" "short signed int float" } */ +short signed int double *x491; /* { dg-error "" "short signed int double" } */ +short signed int signed *x492; /* { dg-error "" "short signed int signed" } */ +short signed int unsigned *x493; /* { dg-error "" "short signed int unsigned" } */ +short signed int _Bool *x494; /* { dg-error "" "short signed int _Bool" } */ +short signed int _Complex *x495; /* { dg-error "" "short signed int _Complex" } */ +short unsigned int void *x496; /* { dg-error "" "short unsigned int void" } */ +short unsigned int char *x497; /* { dg-error "" "short unsigned int char" } */ +short unsigned int short *x498; /* { dg-error "" "short unsigned int short" } */ +short unsigned int int *x499; /* { dg-error "" "short unsigned int int" } */ +short unsigned int long *x500; /* { dg-error "" "short unsigned int long" } */ +short unsigned int float *x501; /* { dg-error "" "short unsigned int float" } */ +short unsigned int double *x502; /* { dg-error "" "short unsigned int double" } */ +short unsigned int signed *x503; /* { dg-error "" "short unsigned int signed" } */ +short unsigned int unsigned *x504; /* { dg-error "" "short unsigned int unsigned" } */ +short unsigned int _Bool *x505; /* { dg-error "" "short unsigned int _Bool" } */ +short unsigned int _Complex *x506; /* { dg-error "" "short unsigned int _Complex" } */ +int short signed void *x507; /* { dg-error "" "int short signed void" } */ +int short signed char *x508; /* { dg-error "" "int short signed char" } */ +int short signed short *x509; /* { dg-error "" "int short signed short" } */ +int short signed int *x510; /* { dg-error "" "int short signed int" } */ +int short signed long *x511; /* { dg-error "" "int short signed long" } */ +int short signed float *x512; /* { dg-error "" "int short signed float" } */ +int short signed double *x513; /* { dg-error "" "int short signed double" } */ +int short signed signed *x514; /* { dg-error "" "int short signed signed" } */ +int short signed unsigned *x515; /* { dg-error "" "int short signed unsigned" } */ +int short signed _Bool *x516; /* { dg-error "" "int short signed _Bool" } */ +int short signed _Complex *x517; /* { dg-error "" "int short signed _Complex" } */ +int short unsigned void *x518; /* { dg-error "" "int short unsigned void" } */ +int short unsigned char *x519; /* { dg-error "" "int short unsigned char" } */ +int short unsigned short *x520; /* { dg-error "" "int short unsigned short" } */ +int short unsigned int *x521; /* { dg-error "" "int short unsigned int" } */ +int short unsigned long *x522; /* { dg-error "" "int short unsigned long" } */ +int short unsigned float *x523; /* { dg-error "" "int short unsigned float" } */ +int short unsigned double *x524; /* { dg-error "" "int short unsigned double" } */ +int short unsigned signed *x525; /* { dg-error "" "int short unsigned signed" } */ +int short unsigned unsigned *x526; /* { dg-error "" "int short unsigned unsigned" } */ +int short unsigned _Bool *x527; /* { dg-error "" "int short unsigned _Bool" } */ +int short unsigned _Complex *x528; /* { dg-error "" "int short unsigned _Complex" } */ +int long long void *x529; /* { dg-error "" "int long long void" } */ +int long long char *x530; /* { dg-error "" "int long long char" } */ +int long long short *x531; /* { dg-error "" "int long long short" } */ +int long long int *x532; /* { dg-error "" "int long long int" } */ +int long long long *x533; /* { dg-error "" "int long long long" } */ +int long long float *x534; /* { dg-error "" "int long long float" } */ +int long long double *x535; /* { dg-error "" "int long long double" } */ +int long long signed *x536; +int long long unsigned *x537; +int long long _Bool *x538; /* { dg-error "" "int long long _Bool" } */ +int long long _Complex *x539; /* { dg-error "" "int long long _Complex" } */ +int long signed void *x540; /* { dg-error "" "int long signed void" } */ +int long signed char *x541; /* { dg-error "" "int long signed char" } */ +int long signed short *x542; /* { dg-error "" "int long signed short" } */ +int long signed int *x543; /* { dg-error "" "int long signed int" } */ +int long signed long *x544; +int long signed float *x545; /* { dg-error "" "int long signed float" } */ +int long signed double *x546; /* { dg-error "" "int long signed double" } */ +int long signed signed *x547; /* { dg-error "" "int long signed signed" } */ +int long signed unsigned *x548; /* { dg-error "" "int long signed unsigned" } */ +int long signed _Bool *x549; /* { dg-error "" "int long signed _Bool" } */ +int long signed _Complex *x550; /* { dg-error "" "int long signed _Complex" } */ +int long unsigned void *x551; /* { dg-error "" "int long unsigned void" } */ +int long unsigned char *x552; /* { dg-error "" "int long unsigned char" } */ +int long unsigned short *x553; /* { dg-error "" "int long unsigned short" } */ +int long unsigned int *x554; /* { dg-error "" "int long unsigned int" } */ +int long unsigned long *x555; +int long unsigned float *x556; /* { dg-error "" "int long unsigned float" } */ +int long unsigned double *x557; /* { dg-error "" "int long unsigned double" } */ +int long unsigned signed *x558; /* { dg-error "" "int long unsigned signed" } */ +int long unsigned unsigned *x559; /* { dg-error "" "int long unsigned unsigned" } */ +int long unsigned _Bool *x560; /* { dg-error "" "int long unsigned _Bool" } */ +int long unsigned _Complex *x561; /* { dg-error "" "int long unsigned _Complex" } */ +int signed short void *x562; /* { dg-error "" "int signed short void" } */ +int signed short char *x563; /* { dg-error "" "int signed short char" } */ +int signed short short *x564; /* { dg-error "" "int signed short short" } */ +int signed short int *x565; /* { dg-error "" "int signed short int" } */ +int signed short long *x566; /* { dg-error "" "int signed short long" } */ +int signed short float *x567; /* { dg-error "" "int signed short float" } */ +int signed short double *x568; /* { dg-error "" "int signed short double" } */ +int signed short signed *x569; /* { dg-error "" "int signed short signed" } */ +int signed short unsigned *x570; /* { dg-error "" "int signed short unsigned" } */ +int signed short _Bool *x571; /* { dg-error "" "int signed short _Bool" } */ +int signed short _Complex *x572; /* { dg-error "" "int signed short _Complex" } */ +int signed long void *x573; /* { dg-error "" "int signed long void" } */ +int signed long char *x574; /* { dg-error "" "int signed long char" } */ +int signed long short *x575; /* { dg-error "" "int signed long short" } */ +int signed long int *x576; /* { dg-error "" "int signed long int" } */ +int signed long long *x577; +int signed long float *x578; /* { dg-error "" "int signed long float" } */ +int signed long double *x579; /* { dg-error "" "int signed long double" } */ +int signed long signed *x580; /* { dg-error "" "int signed long signed" } */ +int signed long unsigned *x581; /* { dg-error "" "int signed long unsigned" } */ +int signed long _Bool *x582; /* { dg-error "" "int signed long _Bool" } */ +int signed long _Complex *x583; /* { dg-error "" "int signed long _Complex" } */ +int unsigned short void *x584; /* { dg-error "" "int unsigned short void" } */ +int unsigned short char *x585; /* { dg-error "" "int unsigned short char" } */ +int unsigned short short *x586; /* { dg-error "" "int unsigned short short" } */ +int unsigned short int *x587; /* { dg-error "" "int unsigned short int" } */ +int unsigned short long *x588; /* { dg-error "" "int unsigned short long" } */ +int unsigned short float *x589; /* { dg-error "" "int unsigned short float" } */ +int unsigned short double *x590; /* { dg-error "" "int unsigned short double" } */ +int unsigned short signed *x591; /* { dg-error "" "int unsigned short signed" } */ +int unsigned short unsigned *x592; /* { dg-error "" "int unsigned short unsigned" } */ +int unsigned short _Bool *x593; /* { dg-error "" "int unsigned short _Bool" } */ +int unsigned short _Complex *x594; /* { dg-error "" "int unsigned short _Complex" } */ +int unsigned long void *x595; /* { dg-error "" "int unsigned long void" } */ +int unsigned long char *x596; /* { dg-error "" "int unsigned long char" } */ +int unsigned long short *x597; /* { dg-error "" "int unsigned long short" } */ +int unsigned long int *x598; /* { dg-error "" "int unsigned long int" } */ +int unsigned long long *x599; +int unsigned long float *x600; /* { dg-error "" "int unsigned long float" } */ +int unsigned long double *x601; /* { dg-error "" "int unsigned long double" } */ +int unsigned long signed *x602; /* { dg-error "" "int unsigned long signed" } */ +int unsigned long unsigned *x603; /* { dg-error "" "int unsigned long unsigned" } */ +int unsigned long _Bool *x604; /* { dg-error "" "int unsigned long _Bool" } */ +int unsigned long _Complex *x605; /* { dg-error "" "int unsigned long _Complex" } */ +long int long void *x606; /* { dg-error "" "long int long void" } */ +long int long char *x607; /* { dg-error "" "long int long char" } */ +long int long short *x608; /* { dg-error "" "long int long short" } */ +long int long int *x609; /* { dg-error "" "long int long int" } */ +long int long long *x610; /* { dg-error "" "long int long long" } */ +long int long float *x611; /* { dg-error "" "long int long float" } */ +long int long double *x612; /* { dg-error "" "long int long double" } */ +long int long signed *x613; +long int long unsigned *x614; +long int long _Bool *x615; /* { dg-error "" "long int long _Bool" } */ +long int long _Complex *x616; /* { dg-error "" "long int long _Complex" } */ +long int signed void *x617; /* { dg-error "" "long int signed void" } */ +long int signed char *x618; /* { dg-error "" "long int signed char" } */ +long int signed short *x619; /* { dg-error "" "long int signed short" } */ +long int signed int *x620; /* { dg-error "" "long int signed int" } */ +long int signed long *x621; +long int signed float *x622; /* { dg-error "" "long int signed float" } */ +long int signed double *x623; /* { dg-error "" "long int signed double" } */ +long int signed signed *x624; /* { dg-error "" "long int signed signed" } */ +long int signed unsigned *x625; /* { dg-error "" "long int signed unsigned" } */ +long int signed _Bool *x626; /* { dg-error "" "long int signed _Bool" } */ +long int signed _Complex *x627; /* { dg-error "" "long int signed _Complex" } */ +long int unsigned void *x628; /* { dg-error "" "long int unsigned void" } */ +long int unsigned char *x629; /* { dg-error "" "long int unsigned char" } */ +long int unsigned short *x630; /* { dg-error "" "long int unsigned short" } */ +long int unsigned int *x631; /* { dg-error "" "long int unsigned int" } */ +long int unsigned long *x632; +long int unsigned float *x633; /* { dg-error "" "long int unsigned float" } */ +long int unsigned double *x634; /* { dg-error "" "long int unsigned double" } */ +long int unsigned signed *x635; /* { dg-error "" "long int unsigned signed" } */ +long int unsigned unsigned *x636; /* { dg-error "" "long int unsigned unsigned" } */ +long int unsigned _Bool *x637; /* { dg-error "" "long int unsigned _Bool" } */ +long int unsigned _Complex *x638; /* { dg-error "" "long int unsigned _Complex" } */ +long long int void *x639; /* { dg-error "" "long long int void" } */ +long long int char *x640; /* { dg-error "" "long long int char" } */ +long long int short *x641; /* { dg-error "" "long long int short" } */ +long long int int *x642; /* { dg-error "" "long long int int" } */ +long long int long *x643; /* { dg-error "" "long long int long" } */ +long long int float *x644; /* { dg-error "" "long long int float" } */ +long long int double *x645; /* { dg-error "" "long long int double" } */ +long long int signed *x646; +long long int unsigned *x647; +long long int _Bool *x648; /* { dg-error "" "long long int _Bool" } */ +long long int _Complex *x649; /* { dg-error "" "long long int _Complex" } */ +long long signed void *x650; /* { dg-error "" "long long signed void" } */ +long long signed char *x651; /* { dg-error "" "long long signed char" } */ +long long signed short *x652; /* { dg-error "" "long long signed short" } */ +long long signed int *x653; +long long signed long *x654; /* { dg-error "" "long long signed long" } */ +long long signed float *x655; /* { dg-error "" "long long signed float" } */ +long long signed double *x656; /* { dg-error "" "long long signed double" } */ +long long signed signed *x657; /* { dg-error "" "long long signed signed" } */ +long long signed unsigned *x658; /* { dg-error "" "long long signed unsigned" } */ +long long signed _Bool *x659; /* { dg-error "" "long long signed _Bool" } */ +long long signed _Complex *x660; /* { dg-error "" "long long signed _Complex" } */ +long long unsigned void *x661; /* { dg-error "" "long long unsigned void" } */ +long long unsigned char *x662; /* { dg-error "" "long long unsigned char" } */ +long long unsigned short *x663; /* { dg-error "" "long long unsigned short" } */ +long long unsigned int *x664; +long long unsigned long *x665; /* { dg-error "" "long long unsigned long" } */ +long long unsigned float *x666; /* { dg-error "" "long long unsigned float" } */ +long long unsigned double *x667; /* { dg-error "" "long long unsigned double" } */ +long long unsigned signed *x668; /* { dg-error "" "long long unsigned signed" } */ +long long unsigned unsigned *x669; /* { dg-error "" "long long unsigned unsigned" } */ +long long unsigned _Bool *x670; /* { dg-error "" "long long unsigned _Bool" } */ +long long unsigned _Complex *x671; /* { dg-error "" "long long unsigned _Complex" } */ +long double _Complex void *x672; /* { dg-error "" "long double _Complex void" } */ +long double _Complex char *x673; /* { dg-error "" "long double _Complex char" } */ +long double _Complex short *x674; /* { dg-error "" "long double _Complex short" } */ +long double _Complex int *x675; /* { dg-error "" "long double _Complex int" } */ +long double _Complex long *x676; /* { dg-error "" "long double _Complex long" } */ +long double _Complex float *x677; /* { dg-error "" "long double _Complex float" } */ +long double _Complex double *x678; /* { dg-error "" "long double _Complex double" } */ +long double _Complex signed *x679; /* { dg-error "" "long double _Complex signed" } */ +long double _Complex unsigned *x680; /* { dg-error "" "long double _Complex unsigned" } */ +long double _Complex _Bool *x681; /* { dg-error "" "long double _Complex _Bool" } */ +long double _Complex _Complex *x682; /* { dg-error "" "long double _Complex _Complex" } */ +long signed int void *x683; /* { dg-error "" "long signed int void" } */ +long signed int char *x684; /* { dg-error "" "long signed int char" } */ +long signed int short *x685; /* { dg-error "" "long signed int short" } */ +long signed int int *x686; /* { dg-error "" "long signed int int" } */ +long signed int long *x687; +long signed int float *x688; /* { dg-error "" "long signed int float" } */ +long signed int double *x689; /* { dg-error "" "long signed int double" } */ +long signed int signed *x690; /* { dg-error "" "long signed int signed" } */ +long signed int unsigned *x691; /* { dg-error "" "long signed int unsigned" } */ +long signed int _Bool *x692; /* { dg-error "" "long signed int _Bool" } */ +long signed int _Complex *x693; /* { dg-error "" "long signed int _Complex" } */ +long signed long void *x694; /* { dg-error "" "long signed long void" } */ +long signed long char *x695; /* { dg-error "" "long signed long char" } */ +long signed long short *x696; /* { dg-error "" "long signed long short" } */ +long signed long int *x697; +long signed long long *x698; /* { dg-error "" "long signed long long" } */ +long signed long float *x699; /* { dg-error "" "long signed long float" } */ +long signed long double *x700; /* { dg-error "" "long signed long double" } */ +long signed long signed *x701; /* { dg-error "" "long signed long signed" } */ +long signed long unsigned *x702; /* { dg-error "" "long signed long unsigned" } */ +long signed long _Bool *x703; /* { dg-error "" "long signed long _Bool" } */ +long signed long _Complex *x704; /* { dg-error "" "long signed long _Complex" } */ +long unsigned int void *x705; /* { dg-error "" "long unsigned int void" } */ +long unsigned int char *x706; /* { dg-error "" "long unsigned int char" } */ +long unsigned int short *x707; /* { dg-error "" "long unsigned int short" } */ +long unsigned int int *x708; /* { dg-error "" "long unsigned int int" } */ +long unsigned int long *x709; +long unsigned int float *x710; /* { dg-error "" "long unsigned int float" } */ +long unsigned int double *x711; /* { dg-error "" "long unsigned int double" } */ +long unsigned int signed *x712; /* { dg-error "" "long unsigned int signed" } */ +long unsigned int unsigned *x713; /* { dg-error "" "long unsigned int unsigned" } */ +long unsigned int _Bool *x714; /* { dg-error "" "long unsigned int _Bool" } */ +long unsigned int _Complex *x715; /* { dg-error "" "long unsigned int _Complex" } */ +long unsigned long void *x716; /* { dg-error "" "long unsigned long void" } */ +long unsigned long char *x717; /* { dg-error "" "long unsigned long char" } */ +long unsigned long short *x718; /* { dg-error "" "long unsigned long short" } */ +long unsigned long int *x719; +long unsigned long long *x720; /* { dg-error "" "long unsigned long long" } */ +long unsigned long float *x721; /* { dg-error "" "long unsigned long float" } */ +long unsigned long double *x722; /* { dg-error "" "long unsigned long double" } */ +long unsigned long signed *x723; /* { dg-error "" "long unsigned long signed" } */ +long unsigned long unsigned *x724; /* { dg-error "" "long unsigned long unsigned" } */ +long unsigned long _Bool *x725; /* { dg-error "" "long unsigned long _Bool" } */ +long unsigned long _Complex *x726; /* { dg-error "" "long unsigned long _Complex" } */ +long _Complex double void *x727; /* { dg-error "" "long _Complex double void" } */ +long _Complex double char *x728; /* { dg-error "" "long _Complex double char" } */ +long _Complex double short *x729; /* { dg-error "" "long _Complex double short" } */ +long _Complex double int *x730; /* { dg-error "" "long _Complex double int" } */ +long _Complex double long *x731; /* { dg-error "" "long _Complex double long" } */ +long _Complex double float *x732; /* { dg-error "" "long _Complex double float" } */ +long _Complex double double *x733; /* { dg-error "" "long _Complex double double" } */ +long _Complex double signed *x734; /* { dg-error "" "long _Complex double signed" } */ +long _Complex double unsigned *x735; /* { dg-error "" "long _Complex double unsigned" } */ +long _Complex double _Bool *x736; /* { dg-error "" "long _Complex double _Bool" } */ +long _Complex double _Complex *x737; /* { dg-error "" "long _Complex double _Complex" } */ +double long _Complex void *x738; /* { dg-error "" "double long _Complex void" } */ +double long _Complex char *x739; /* { dg-error "" "double long _Complex char" } */ +double long _Complex short *x740; /* { dg-error "" "double long _Complex short" } */ +double long _Complex int *x741; /* { dg-error "" "double long _Complex int" } */ +double long _Complex long *x742; /* { dg-error "" "double long _Complex long" } */ +double long _Complex float *x743; /* { dg-error "" "double long _Complex float" } */ +double long _Complex double *x744; /* { dg-error "" "double long _Complex double" } */ +double long _Complex signed *x745; /* { dg-error "" "double long _Complex signed" } */ +double long _Complex unsigned *x746; /* { dg-error "" "double long _Complex unsigned" } */ +double long _Complex _Bool *x747; /* { dg-error "" "double long _Complex _Bool" } */ +double long _Complex _Complex *x748; /* { dg-error "" "double long _Complex _Complex" } */ +double _Complex long void *x749; /* { dg-error "" "double _Complex long void" } */ +double _Complex long char *x750; /* { dg-error "" "double _Complex long char" } */ +double _Complex long short *x751; /* { dg-error "" "double _Complex long short" } */ +double _Complex long int *x752; /* { dg-error "" "double _Complex long int" } */ +double _Complex long long *x753; /* { dg-error "" "double _Complex long long" } */ +double _Complex long float *x754; /* { dg-error "" "double _Complex long float" } */ +double _Complex long double *x755; /* { dg-error "" "double _Complex long double" } */ +double _Complex long signed *x756; /* { dg-error "" "double _Complex long signed" } */ +double _Complex long unsigned *x757; /* { dg-error "" "double _Complex long unsigned" } */ +double _Complex long _Bool *x758; /* { dg-error "" "double _Complex long _Bool" } */ +double _Complex long _Complex *x759; /* { dg-error "" "double _Complex long _Complex" } */ +signed short int void *x760; /* { dg-error "" "signed short int void" } */ +signed short int char *x761; /* { dg-error "" "signed short int char" } */ +signed short int short *x762; /* { dg-error "" "signed short int short" } */ +signed short int int *x763; /* { dg-error "" "signed short int int" } */ +signed short int long *x764; /* { dg-error "" "signed short int long" } */ +signed short int float *x765; /* { dg-error "" "signed short int float" } */ +signed short int double *x766; /* { dg-error "" "signed short int double" } */ +signed short int signed *x767; /* { dg-error "" "signed short int signed" } */ +signed short int unsigned *x768; /* { dg-error "" "signed short int unsigned" } */ +signed short int _Bool *x769; /* { dg-error "" "signed short int _Bool" } */ +signed short int _Complex *x770; /* { dg-error "" "signed short int _Complex" } */ +signed int short void *x771; /* { dg-error "" "signed int short void" } */ +signed int short char *x772; /* { dg-error "" "signed int short char" } */ +signed int short short *x773; /* { dg-error "" "signed int short short" } */ +signed int short int *x774; /* { dg-error "" "signed int short int" } */ +signed int short long *x775; /* { dg-error "" "signed int short long" } */ +signed int short float *x776; /* { dg-error "" "signed int short float" } */ +signed int short double *x777; /* { dg-error "" "signed int short double" } */ +signed int short signed *x778; /* { dg-error "" "signed int short signed" } */ +signed int short unsigned *x779; /* { dg-error "" "signed int short unsigned" } */ +signed int short _Bool *x780; /* { dg-error "" "signed int short _Bool" } */ +signed int short _Complex *x781; /* { dg-error "" "signed int short _Complex" } */ +signed int long void *x782; /* { dg-error "" "signed int long void" } */ +signed int long char *x783; /* { dg-error "" "signed int long char" } */ +signed int long short *x784; /* { dg-error "" "signed int long short" } */ +signed int long int *x785; /* { dg-error "" "signed int long int" } */ +signed int long long *x786; +signed int long float *x787; /* { dg-error "" "signed int long float" } */ +signed int long double *x788; /* { dg-error "" "signed int long double" } */ +signed int long signed *x789; /* { dg-error "" "signed int long signed" } */ +signed int long unsigned *x790; /* { dg-error "" "signed int long unsigned" } */ +signed int long _Bool *x791; /* { dg-error "" "signed int long _Bool" } */ +signed int long _Complex *x792; /* { dg-error "" "signed int long _Complex" } */ +signed long int void *x793; /* { dg-error "" "signed long int void" } */ +signed long int char *x794; /* { dg-error "" "signed long int char" } */ +signed long int short *x795; /* { dg-error "" "signed long int short" } */ +signed long int int *x796; /* { dg-error "" "signed long int int" } */ +signed long int long *x797; +signed long int float *x798; /* { dg-error "" "signed long int float" } */ +signed long int double *x799; /* { dg-error "" "signed long int double" } */ +signed long int signed *x800; /* { dg-error "" "signed long int signed" } */ +signed long int unsigned *x801; /* { dg-error "" "signed long int unsigned" } */ +signed long int _Bool *x802; /* { dg-error "" "signed long int _Bool" } */ +signed long int _Complex *x803; /* { dg-error "" "signed long int _Complex" } */ +signed long long void *x804; /* { dg-error "" "signed long long void" } */ +signed long long char *x805; /* { dg-error "" "signed long long char" } */ +signed long long short *x806; /* { dg-error "" "signed long long short" } */ +signed long long int *x807; +signed long long long *x808; /* { dg-error "" "signed long long long" } */ +signed long long float *x809; /* { dg-error "" "signed long long float" } */ +signed long long double *x810; /* { dg-error "" "signed long long double" } */ +signed long long signed *x811; /* { dg-error "" "signed long long signed" } */ +signed long long unsigned *x812; /* { dg-error "" "signed long long unsigned" } */ +signed long long _Bool *x813; /* { dg-error "" "signed long long _Bool" } */ +signed long long _Complex *x814; /* { dg-error "" "signed long long _Complex" } */ +unsigned short int void *x815; /* { dg-error "" "unsigned short int void" } */ +unsigned short int char *x816; /* { dg-error "" "unsigned short int char" } */ +unsigned short int short *x817; /* { dg-error "" "unsigned short int short" } */ +unsigned short int int *x818; /* { dg-error "" "unsigned short int int" } */ +unsigned short int long *x819; /* { dg-error "" "unsigned short int long" } */ +unsigned short int float *x820; /* { dg-error "" "unsigned short int float" } */ +unsigned short int double *x821; /* { dg-error "" "unsigned short int double" } */ +unsigned short int signed *x822; /* { dg-error "" "unsigned short int signed" } */ +unsigned short int unsigned *x823; /* { dg-error "" "unsigned short int unsigned" } */ +unsigned short int _Bool *x824; /* { dg-error "" "unsigned short int _Bool" } */ +unsigned short int _Complex *x825; /* { dg-error "" "unsigned short int _Complex" } */ +unsigned int short void *x826; /* { dg-error "" "unsigned int short void" } */ +unsigned int short char *x827; /* { dg-error "" "unsigned int short char" } */ +unsigned int short short *x828; /* { dg-error "" "unsigned int short short" } */ +unsigned int short int *x829; /* { dg-error "" "unsigned int short int" } */ +unsigned int short long *x830; /* { dg-error "" "unsigned int short long" } */ +unsigned int short float *x831; /* { dg-error "" "unsigned int short float" } */ +unsigned int short double *x832; /* { dg-error "" "unsigned int short double" } */ +unsigned int short signed *x833; /* { dg-error "" "unsigned int short signed" } */ +unsigned int short unsigned *x834; /* { dg-error "" "unsigned int short unsigned" } */ +unsigned int short _Bool *x835; /* { dg-error "" "unsigned int short _Bool" } */ +unsigned int short _Complex *x836; /* { dg-error "" "unsigned int short _Complex" } */ +unsigned int long void *x837; /* { dg-error "" "unsigned int long void" } */ +unsigned int long char *x838; /* { dg-error "" "unsigned int long char" } */ +unsigned int long short *x839; /* { dg-error "" "unsigned int long short" } */ +unsigned int long int *x840; /* { dg-error "" "unsigned int long int" } */ +unsigned int long long *x841; +unsigned int long float *x842; /* { dg-error "" "unsigned int long float" } */ +unsigned int long double *x843; /* { dg-error "" "unsigned int long double" } */ +unsigned int long signed *x844; /* { dg-error "" "unsigned int long signed" } */ +unsigned int long unsigned *x845; /* { dg-error "" "unsigned int long unsigned" } */ +unsigned int long _Bool *x846; /* { dg-error "" "unsigned int long _Bool" } */ +unsigned int long _Complex *x847; /* { dg-error "" "unsigned int long _Complex" } */ +unsigned long int void *x848; /* { dg-error "" "unsigned long int void" } */ +unsigned long int char *x849; /* { dg-error "" "unsigned long int char" } */ +unsigned long int short *x850; /* { dg-error "" "unsigned long int short" } */ +unsigned long int int *x851; /* { dg-error "" "unsigned long int int" } */ +unsigned long int long *x852; +unsigned long int float *x853; /* { dg-error "" "unsigned long int float" } */ +unsigned long int double *x854; /* { dg-error "" "unsigned long int double" } */ +unsigned long int signed *x855; /* { dg-error "" "unsigned long int signed" } */ +unsigned long int unsigned *x856; /* { dg-error "" "unsigned long int unsigned" } */ +unsigned long int _Bool *x857; /* { dg-error "" "unsigned long int _Bool" } */ +unsigned long int _Complex *x858; /* { dg-error "" "unsigned long int _Complex" } */ +unsigned long long void *x859; /* { dg-error "" "unsigned long long void" } */ +unsigned long long char *x860; /* { dg-error "" "unsigned long long char" } */ +unsigned long long short *x861; /* { dg-error "" "unsigned long long short" } */ +unsigned long long int *x862; +unsigned long long long *x863; /* { dg-error "" "unsigned long long long" } */ +unsigned long long float *x864; /* { dg-error "" "unsigned long long float" } */ +unsigned long long double *x865; /* { dg-error "" "unsigned long long double" } */ +unsigned long long signed *x866; /* { dg-error "" "unsigned long long signed" } */ +unsigned long long unsigned *x867; /* { dg-error "" "unsigned long long unsigned" } */ +unsigned long long _Bool *x868; /* { dg-error "" "unsigned long long _Bool" } */ +unsigned long long _Complex *x869; /* { dg-error "" "unsigned long long _Complex" } */ +_Complex long double void *x870; /* { dg-error "" "_Complex long double void" } */ +_Complex long double char *x871; /* { dg-error "" "_Complex long double char" } */ +_Complex long double short *x872; /* { dg-error "" "_Complex long double short" } */ +_Complex long double int *x873; /* { dg-error "" "_Complex long double int" } */ +_Complex long double long *x874; /* { dg-error "" "_Complex long double long" } */ +_Complex long double float *x875; /* { dg-error "" "_Complex long double float" } */ +_Complex long double double *x876; /* { dg-error "" "_Complex long double double" } */ +_Complex long double signed *x877; /* { dg-error "" "_Complex long double signed" } */ +_Complex long double unsigned *x878; /* { dg-error "" "_Complex long double unsigned" } */ +_Complex long double _Bool *x879; /* { dg-error "" "_Complex long double _Bool" } */ +_Complex long double _Complex *x880; /* { dg-error "" "_Complex long double _Complex" } */ +_Complex double long void *x881; /* { dg-error "" "_Complex double long void" } */ +_Complex double long char *x882; /* { dg-error "" "_Complex double long char" } */ +_Complex double long short *x883; /* { dg-error "" "_Complex double long short" } */ +_Complex double long int *x884; /* { dg-error "" "_Complex double long int" } */ +_Complex double long long *x885; /* { dg-error "" "_Complex double long long" } */ +_Complex double long float *x886; /* { dg-error "" "_Complex double long float" } */ +_Complex double long double *x887; /* { dg-error "" "_Complex double long double" } */ +_Complex double long signed *x888; /* { dg-error "" "_Complex double long signed" } */ +_Complex double long unsigned *x889; /* { dg-error "" "_Complex double long unsigned" } */ +_Complex double long _Bool *x890; /* { dg-error "" "_Complex double long _Bool" } */ +_Complex double long _Complex *x891; /* { dg-error "" "_Complex double long _Complex" } */ +int long long signed void *x892; /* { dg-error "" "int long long signed void" } */ +int long long signed char *x893; /* { dg-error "" "int long long signed char" } */ +int long long signed short *x894; /* { dg-error "" "int long long signed short" } */ +int long long signed int *x895; /* { dg-error "" "int long long signed int" } */ +int long long signed long *x896; /* { dg-error "" "int long long signed long" } */ +int long long signed float *x897; /* { dg-error "" "int long long signed float" } */ +int long long signed double *x898; /* { dg-error "" "int long long signed double" } */ +int long long signed signed *x899; /* { dg-error "" "int long long signed signed" } */ +int long long signed unsigned *x900; /* { dg-error "" "int long long signed unsigned" } */ +int long long signed _Bool *x901; /* { dg-error "" "int long long signed _Bool" } */ +int long long signed _Complex *x902; /* { dg-error "" "int long long signed _Complex" } */ +int long long unsigned void *x903; /* { dg-error "" "int long long unsigned void" } */ +int long long unsigned char *x904; /* { dg-error "" "int long long unsigned char" } */ +int long long unsigned short *x905; /* { dg-error "" "int long long unsigned short" } */ +int long long unsigned int *x906; /* { dg-error "" "int long long unsigned int" } */ +int long long unsigned long *x907; /* { dg-error "" "int long long unsigned long" } */ +int long long unsigned float *x908; /* { dg-error "" "int long long unsigned float" } */ +int long long unsigned double *x909; /* { dg-error "" "int long long unsigned double" } */ +int long long unsigned signed *x910; /* { dg-error "" "int long long unsigned signed" } */ +int long long unsigned unsigned *x911; /* { dg-error "" "int long long unsigned unsigned" } */ +int long long unsigned _Bool *x912; /* { dg-error "" "int long long unsigned _Bool" } */ +int long long unsigned _Complex *x913; /* { dg-error "" "int long long unsigned _Complex" } */ +int long signed long void *x914; /* { dg-error "" "int long signed long void" } */ +int long signed long char *x915; /* { dg-error "" "int long signed long char" } */ +int long signed long short *x916; /* { dg-error "" "int long signed long short" } */ +int long signed long int *x917; /* { dg-error "" "int long signed long int" } */ +int long signed long long *x918; /* { dg-error "" "int long signed long long" } */ +int long signed long float *x919; /* { dg-error "" "int long signed long float" } */ +int long signed long double *x920; /* { dg-error "" "int long signed long double" } */ +int long signed long signed *x921; /* { dg-error "" "int long signed long signed" } */ +int long signed long unsigned *x922; /* { dg-error "" "int long signed long unsigned" } */ +int long signed long _Bool *x923; /* { dg-error "" "int long signed long _Bool" } */ +int long signed long _Complex *x924; /* { dg-error "" "int long signed long _Complex" } */ +int long unsigned long void *x925; /* { dg-error "" "int long unsigned long void" } */ +int long unsigned long char *x926; /* { dg-error "" "int long unsigned long char" } */ +int long unsigned long short *x927; /* { dg-error "" "int long unsigned long short" } */ +int long unsigned long int *x928; /* { dg-error "" "int long unsigned long int" } */ +int long unsigned long long *x929; /* { dg-error "" "int long unsigned long long" } */ +int long unsigned long float *x930; /* { dg-error "" "int long unsigned long float" } */ +int long unsigned long double *x931; /* { dg-error "" "int long unsigned long double" } */ +int long unsigned long signed *x932; /* { dg-error "" "int long unsigned long signed" } */ +int long unsigned long unsigned *x933; /* { dg-error "" "int long unsigned long unsigned" } */ +int long unsigned long _Bool *x934; /* { dg-error "" "int long unsigned long _Bool" } */ +int long unsigned long _Complex *x935; /* { dg-error "" "int long unsigned long _Complex" } */ +int signed long long void *x936; /* { dg-error "" "int signed long long void" } */ +int signed long long char *x937; /* { dg-error "" "int signed long long char" } */ +int signed long long short *x938; /* { dg-error "" "int signed long long short" } */ +int signed long long int *x939; /* { dg-error "" "int signed long long int" } */ +int signed long long long *x940; /* { dg-error "" "int signed long long long" } */ +int signed long long float *x941; /* { dg-error "" "int signed long long float" } */ +int signed long long double *x942; /* { dg-error "" "int signed long long double" } */ +int signed long long signed *x943; /* { dg-error "" "int signed long long signed" } */ +int signed long long unsigned *x944; /* { dg-error "" "int signed long long unsigned" } */ +int signed long long _Bool *x945; /* { dg-error "" "int signed long long _Bool" } */ +int signed long long _Complex *x946; /* { dg-error "" "int signed long long _Complex" } */ +int unsigned long long void *x947; /* { dg-error "" "int unsigned long long void" } */ +int unsigned long long char *x948; /* { dg-error "" "int unsigned long long char" } */ +int unsigned long long short *x949; /* { dg-error "" "int unsigned long long short" } */ +int unsigned long long int *x950; /* { dg-error "" "int unsigned long long int" } */ +int unsigned long long long *x951; /* { dg-error "" "int unsigned long long long" } */ +int unsigned long long float *x952; /* { dg-error "" "int unsigned long long float" } */ +int unsigned long long double *x953; /* { dg-error "" "int unsigned long long double" } */ +int unsigned long long signed *x954; /* { dg-error "" "int unsigned long long signed" } */ +int unsigned long long unsigned *x955; /* { dg-error "" "int unsigned long long unsigned" } */ +int unsigned long long _Bool *x956; /* { dg-error "" "int unsigned long long _Bool" } */ +int unsigned long long _Complex *x957; /* { dg-error "" "int unsigned long long _Complex" } */ +long int long signed void *x958; /* { dg-error "" "long int long signed void" } */ +long int long signed char *x959; /* { dg-error "" "long int long signed char" } */ +long int long signed short *x960; /* { dg-error "" "long int long signed short" } */ +long int long signed int *x961; /* { dg-error "" "long int long signed int" } */ +long int long signed long *x962; /* { dg-error "" "long int long signed long" } */ +long int long signed float *x963; /* { dg-error "" "long int long signed float" } */ +long int long signed double *x964; /* { dg-error "" "long int long signed double" } */ +long int long signed signed *x965; /* { dg-error "" "long int long signed signed" } */ +long int long signed unsigned *x966; /* { dg-error "" "long int long signed unsigned" } */ +long int long signed _Bool *x967; /* { dg-error "" "long int long signed _Bool" } */ +long int long signed _Complex *x968; /* { dg-error "" "long int long signed _Complex" } */ +long int long unsigned void *x969; /* { dg-error "" "long int long unsigned void" } */ +long int long unsigned char *x970; /* { dg-error "" "long int long unsigned char" } */ +long int long unsigned short *x971; /* { dg-error "" "long int long unsigned short" } */ +long int long unsigned int *x972; /* { dg-error "" "long int long unsigned int" } */ +long int long unsigned long *x973; /* { dg-error "" "long int long unsigned long" } */ +long int long unsigned float *x974; /* { dg-error "" "long int long unsigned float" } */ +long int long unsigned double *x975; /* { dg-error "" "long int long unsigned double" } */ +long int long unsigned signed *x976; /* { dg-error "" "long int long unsigned signed" } */ +long int long unsigned unsigned *x977; /* { dg-error "" "long int long unsigned unsigned" } */ +long int long unsigned _Bool *x978; /* { dg-error "" "long int long unsigned _Bool" } */ +long int long unsigned _Complex *x979; /* { dg-error "" "long int long unsigned _Complex" } */ +long int signed long void *x980; /* { dg-error "" "long int signed long void" } */ +long int signed long char *x981; /* { dg-error "" "long int signed long char" } */ +long int signed long short *x982; /* { dg-error "" "long int signed long short" } */ +long int signed long int *x983; /* { dg-error "" "long int signed long int" } */ +long int signed long long *x984; /* { dg-error "" "long int signed long long" } */ +long int signed long float *x985; /* { dg-error "" "long int signed long float" } */ +long int signed long double *x986; /* { dg-error "" "long int signed long double" } */ +long int signed long signed *x987; /* { dg-error "" "long int signed long signed" } */ +long int signed long unsigned *x988; /* { dg-error "" "long int signed long unsigned" } */ +long int signed long _Bool *x989; /* { dg-error "" "long int signed long _Bool" } */ +long int signed long _Complex *x990; /* { dg-error "" "long int signed long _Complex" } */ +long int unsigned long void *x991; /* { dg-error "" "long int unsigned long void" } */ +long int unsigned long char *x992; /* { dg-error "" "long int unsigned long char" } */ +long int unsigned long short *x993; /* { dg-error "" "long int unsigned long short" } */ +long int unsigned long int *x994; /* { dg-error "" "long int unsigned long int" } */ +long int unsigned long long *x995; /* { dg-error "" "long int unsigned long long" } */ +long int unsigned long float *x996; /* { dg-error "" "long int unsigned long float" } */ +long int unsigned long double *x997; /* { dg-error "" "long int unsigned long double" } */ +long int unsigned long signed *x998; /* { dg-error "" "long int unsigned long signed" } */ +long int unsigned long unsigned *x999; /* { dg-error "" "long int unsigned long unsigned" } */ +long int unsigned long _Bool *x1000; /* { dg-error "" "long int unsigned long _Bool" } */ +long int unsigned long _Complex *x1001; /* { dg-error "" "long int unsigned long _Complex" } */ +long long int signed void *x1002; /* { dg-error "" "long long int signed void" } */ +long long int signed char *x1003; /* { dg-error "" "long long int signed char" } */ +long long int signed short *x1004; /* { dg-error "" "long long int signed short" } */ +long long int signed int *x1005; /* { dg-error "" "long long int signed int" } */ +long long int signed long *x1006; /* { dg-error "" "long long int signed long" } */ +long long int signed float *x1007; /* { dg-error "" "long long int signed float" } */ +long long int signed double *x1008; /* { dg-error "" "long long int signed double" } */ +long long int signed signed *x1009; /* { dg-error "" "long long int signed signed" } */ +long long int signed unsigned *x1010; /* { dg-error "" "long long int signed unsigned" } */ +long long int signed _Bool *x1011; /* { dg-error "" "long long int signed _Bool" } */ +long long int signed _Complex *x1012; /* { dg-error "" "long long int signed _Complex" } */ +long long int unsigned void *x1013; /* { dg-error "" "long long int unsigned void" } */ +long long int unsigned char *x1014; /* { dg-error "" "long long int unsigned char" } */ +long long int unsigned short *x1015; /* { dg-error "" "long long int unsigned short" } */ +long long int unsigned int *x1016; /* { dg-error "" "long long int unsigned int" } */ +long long int unsigned long *x1017; /* { dg-error "" "long long int unsigned long" } */ +long long int unsigned float *x1018; /* { dg-error "" "long long int unsigned float" } */ +long long int unsigned double *x1019; /* { dg-error "" "long long int unsigned double" } */ +long long int unsigned signed *x1020; /* { dg-error "" "long long int unsigned signed" } */ +long long int unsigned unsigned *x1021; /* { dg-error "" "long long int unsigned unsigned" } */ +long long int unsigned _Bool *x1022; /* { dg-error "" "long long int unsigned _Bool" } */ +long long int unsigned _Complex *x1023; /* { dg-error "" "long long int unsigned _Complex" } */ +long long signed int void *x1024; /* { dg-error "" "long long signed int void" } */ +long long signed int char *x1025; /* { dg-error "" "long long signed int char" } */ +long long signed int short *x1026; /* { dg-error "" "long long signed int short" } */ +long long signed int int *x1027; /* { dg-error "" "long long signed int int" } */ +long long signed int long *x1028; /* { dg-error "" "long long signed int long" } */ +long long signed int float *x1029; /* { dg-error "" "long long signed int float" } */ +long long signed int double *x1030; /* { dg-error "" "long long signed int double" } */ +long long signed int signed *x1031; /* { dg-error "" "long long signed int signed" } */ +long long signed int unsigned *x1032; /* { dg-error "" "long long signed int unsigned" } */ +long long signed int _Bool *x1033; /* { dg-error "" "long long signed int _Bool" } */ +long long signed int _Complex *x1034; /* { dg-error "" "long long signed int _Complex" } */ +long long unsigned int void *x1035; /* { dg-error "" "long long unsigned int void" } */ +long long unsigned int char *x1036; /* { dg-error "" "long long unsigned int char" } */ +long long unsigned int short *x1037; /* { dg-error "" "long long unsigned int short" } */ +long long unsigned int int *x1038; /* { dg-error "" "long long unsigned int int" } */ +long long unsigned int long *x1039; /* { dg-error "" "long long unsigned int long" } */ +long long unsigned int float *x1040; /* { dg-error "" "long long unsigned int float" } */ +long long unsigned int double *x1041; /* { dg-error "" "long long unsigned int double" } */ +long long unsigned int signed *x1042; /* { dg-error "" "long long unsigned int signed" } */ +long long unsigned int unsigned *x1043; /* { dg-error "" "long long unsigned int unsigned" } */ +long long unsigned int _Bool *x1044; /* { dg-error "" "long long unsigned int _Bool" } */ +long long unsigned int _Complex *x1045; /* { dg-error "" "long long unsigned int _Complex" } */ +long signed int long void *x1046; /* { dg-error "" "long signed int long void" } */ +long signed int long char *x1047; /* { dg-error "" "long signed int long char" } */ +long signed int long short *x1048; /* { dg-error "" "long signed int long short" } */ +long signed int long int *x1049; /* { dg-error "" "long signed int long int" } */ +long signed int long long *x1050; /* { dg-error "" "long signed int long long" } */ +long signed int long float *x1051; /* { dg-error "" "long signed int long float" } */ +long signed int long double *x1052; /* { dg-error "" "long signed int long double" } */ +long signed int long signed *x1053; /* { dg-error "" "long signed int long signed" } */ +long signed int long unsigned *x1054; /* { dg-error "" "long signed int long unsigned" } */ +long signed int long _Bool *x1055; /* { dg-error "" "long signed int long _Bool" } */ +long signed int long _Complex *x1056; /* { dg-error "" "long signed int long _Complex" } */ +long signed long int void *x1057; /* { dg-error "" "long signed long int void" } */ +long signed long int char *x1058; /* { dg-error "" "long signed long int char" } */ +long signed long int short *x1059; /* { dg-error "" "long signed long int short" } */ +long signed long int int *x1060; /* { dg-error "" "long signed long int int" } */ +long signed long int long *x1061; /* { dg-error "" "long signed long int long" } */ +long signed long int float *x1062; /* { dg-error "" "long signed long int float" } */ +long signed long int double *x1063; /* { dg-error "" "long signed long int double" } */ +long signed long int signed *x1064; /* { dg-error "" "long signed long int signed" } */ +long signed long int unsigned *x1065; /* { dg-error "" "long signed long int unsigned" } */ +long signed long int _Bool *x1066; /* { dg-error "" "long signed long int _Bool" } */ +long signed long int _Complex *x1067; /* { dg-error "" "long signed long int _Complex" } */ +long unsigned int long void *x1068; /* { dg-error "" "long unsigned int long void" } */ +long unsigned int long char *x1069; /* { dg-error "" "long unsigned int long char" } */ +long unsigned int long short *x1070; /* { dg-error "" "long unsigned int long short" } */ +long unsigned int long int *x1071; /* { dg-error "" "long unsigned int long int" } */ +long unsigned int long long *x1072; /* { dg-error "" "long unsigned int long long" } */ +long unsigned int long float *x1073; /* { dg-error "" "long unsigned int long float" } */ +long unsigned int long double *x1074; /* { dg-error "" "long unsigned int long double" } */ +long unsigned int long signed *x1075; /* { dg-error "" "long unsigned int long signed" } */ +long unsigned int long unsigned *x1076; /* { dg-error "" "long unsigned int long unsigned" } */ +long unsigned int long _Bool *x1077; /* { dg-error "" "long unsigned int long _Bool" } */ +long unsigned int long _Complex *x1078; /* { dg-error "" "long unsigned int long _Complex" } */ +long unsigned long int void *x1079; /* { dg-error "" "long unsigned long int void" } */ +long unsigned long int char *x1080; /* { dg-error "" "long unsigned long int char" } */ +long unsigned long int short *x1081; /* { dg-error "" "long unsigned long int short" } */ +long unsigned long int int *x1082; /* { dg-error "" "long unsigned long int int" } */ +long unsigned long int long *x1083; /* { dg-error "" "long unsigned long int long" } */ +long unsigned long int float *x1084; /* { dg-error "" "long unsigned long int float" } */ +long unsigned long int double *x1085; /* { dg-error "" "long unsigned long int double" } */ +long unsigned long int signed *x1086; /* { dg-error "" "long unsigned long int signed" } */ +long unsigned long int unsigned *x1087; /* { dg-error "" "long unsigned long int unsigned" } */ +long unsigned long int _Bool *x1088; /* { dg-error "" "long unsigned long int _Bool" } */ +long unsigned long int _Complex *x1089; /* { dg-error "" "long unsigned long int _Complex" } */ +signed int long long void *x1090; /* { dg-error "" "signed int long long void" } */ +signed int long long char *x1091; /* { dg-error "" "signed int long long char" } */ +signed int long long short *x1092; /* { dg-error "" "signed int long long short" } */ +signed int long long int *x1093; /* { dg-error "" "signed int long long int" } */ +signed int long long long *x1094; /* { dg-error "" "signed int long long long" } */ +signed int long long float *x1095; /* { dg-error "" "signed int long long float" } */ +signed int long long double *x1096; /* { dg-error "" "signed int long long double" } */ +signed int long long signed *x1097; /* { dg-error "" "signed int long long signed" } */ +signed int long long unsigned *x1098; /* { dg-error "" "signed int long long unsigned" } */ +signed int long long _Bool *x1099; /* { dg-error "" "signed int long long _Bool" } */ +signed int long long _Complex *x1100; /* { dg-error "" "signed int long long _Complex" } */ +signed long int long void *x1101; /* { dg-error "" "signed long int long void" } */ +signed long int long char *x1102; /* { dg-error "" "signed long int long char" } */ +signed long int long short *x1103; /* { dg-error "" "signed long int long short" } */ +signed long int long int *x1104; /* { dg-error "" "signed long int long int" } */ +signed long int long long *x1105; /* { dg-error "" "signed long int long long" } */ +signed long int long float *x1106; /* { dg-error "" "signed long int long float" } */ +signed long int long double *x1107; /* { dg-error "" "signed long int long double" } */ +signed long int long signed *x1108; /* { dg-error "" "signed long int long signed" } */ +signed long int long unsigned *x1109; /* { dg-error "" "signed long int long unsigned" } */ +signed long int long _Bool *x1110; /* { dg-error "" "signed long int long _Bool" } */ +signed long int long _Complex *x1111; /* { dg-error "" "signed long int long _Complex" } */ +signed long long int void *x1112; /* { dg-error "" "signed long long int void" } */ +signed long long int char *x1113; /* { dg-error "" "signed long long int char" } */ +signed long long int short *x1114; /* { dg-error "" "signed long long int short" } */ +signed long long int int *x1115; /* { dg-error "" "signed long long int int" } */ +signed long long int long *x1116; /* { dg-error "" "signed long long int long" } */ +signed long long int float *x1117; /* { dg-error "" "signed long long int float" } */ +signed long long int double *x1118; /* { dg-error "" "signed long long int double" } */ +signed long long int signed *x1119; /* { dg-error "" "signed long long int signed" } */ +signed long long int unsigned *x1120; /* { dg-error "" "signed long long int unsigned" } */ +signed long long int _Bool *x1121; /* { dg-error "" "signed long long int _Bool" } */ +signed long long int _Complex *x1122; /* { dg-error "" "signed long long int _Complex" } */ +unsigned int long long void *x1123; /* { dg-error "" "unsigned int long long void" } */ +unsigned int long long char *x1124; /* { dg-error "" "unsigned int long long char" } */ +unsigned int long long short *x1125; /* { dg-error "" "unsigned int long long short" } */ +unsigned int long long int *x1126; /* { dg-error "" "unsigned int long long int" } */ +unsigned int long long long *x1127; /* { dg-error "" "unsigned int long long long" } */ +unsigned int long long float *x1128; /* { dg-error "" "unsigned int long long float" } */ +unsigned int long long double *x1129; /* { dg-error "" "unsigned int long long double" } */ +unsigned int long long signed *x1130; /* { dg-error "" "unsigned int long long signed" } */ +unsigned int long long unsigned *x1131; /* { dg-error "" "unsigned int long long unsigned" } */ +unsigned int long long _Bool *x1132; /* { dg-error "" "unsigned int long long _Bool" } */ +unsigned int long long _Complex *x1133; /* { dg-error "" "unsigned int long long _Complex" } */ +unsigned long int long void *x1134; /* { dg-error "" "unsigned long int long void" } */ +unsigned long int long char *x1135; /* { dg-error "" "unsigned long int long char" } */ +unsigned long int long short *x1136; /* { dg-error "" "unsigned long int long short" } */ +unsigned long int long int *x1137; /* { dg-error "" "unsigned long int long int" } */ +unsigned long int long long *x1138; /* { dg-error "" "unsigned long int long long" } */ +unsigned long int long float *x1139; /* { dg-error "" "unsigned long int long float" } */ +unsigned long int long double *x1140; /* { dg-error "" "unsigned long int long double" } */ +unsigned long int long signed *x1141; /* { dg-error "" "unsigned long int long signed" } */ +unsigned long int long unsigned *x1142; /* { dg-error "" "unsigned long int long unsigned" } */ +unsigned long int long _Bool *x1143; /* { dg-error "" "unsigned long int long _Bool" } */ +unsigned long int long _Complex *x1144; /* { dg-error "" "unsigned long int long _Complex" } */ +unsigned long long int void *x1145; /* { dg-error "" "unsigned long long int void" } */ +unsigned long long int char *x1146; /* { dg-error "" "unsigned long long int char" } */ +unsigned long long int short *x1147; /* { dg-error "" "unsigned long long int short" } */ +unsigned long long int int *x1148; /* { dg-error "" "unsigned long long int int" } */ +unsigned long long int long *x1149; /* { dg-error "" "unsigned long long int long" } */ +unsigned long long int float *x1150; /* { dg-error "" "unsigned long long int float" } */ +unsigned long long int double *x1151; /* { dg-error "" "unsigned long long int double" } */ +unsigned long long int signed *x1152; /* { dg-error "" "unsigned long long int signed" } */ +unsigned long long int unsigned *x1153; /* { dg-error "" "unsigned long long int unsigned" } */ +unsigned long long int _Bool *x1154; /* { dg-error "" "unsigned long long int _Bool" } */ +unsigned long long int _Complex *x1155; /* { dg-error "" "unsigned long long int _Complex" } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-version-1.c b/SingleSource/Regression/C/gcc-dg/c99-version-1.c new file mode 100644 index 0000000000..b99d54c7e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 199901L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/c99-vla-1.c b/SingleSource/Regression/C/gcc-dg/c99-vla-1.c new file mode 100644 index 0000000000..4501852066 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-vla-1.c @@ -0,0 +1,13 @@ +/* Origin: PR 3467 */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ +/* { dg-require-effective-target alloca } */ + +void +tdef (int n) +{ + typedef int A[n]; /* { dg-bogus "forbids variable length array" } */ + A a; + A *p; + p = &a; +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-vla-2.c b/SingleSource/Regression/C/gcc-dg/c99-vla-2.c new file mode 100644 index 0000000000..de15c73c8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-vla-2.c @@ -0,0 +1,107 @@ +/* Test composite type of VLA and fixed-size array: should be the + fixed-size type. Bug 22192. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +/* Test that the given expression (of pointer-to-array type) points to + the right sort of array. */ +#define TEST_FIXED_SIZE(a) do { static int x[sizeof(*(a))]; (void)x; } while (0) +#define TEST_VLA(a) do { (void)sizeof(*(a)); (void)(1 ? (a) : (__typeof__(**(a)) (*)[1])0); (void)(1 ? (a) : (__typeof__(**(a)) (*)[2])0); } while (0) +#define TEST_INCOMPLETE(a) do { __typeof__(*(a)) x = { 0 }; (void)x; (void)(1 ? a : (__typeof__(**(a)) (*)[1])0); (void)(1 ? a : (__typeof__(**(a)) (*)[2])0); } while (0) + +#define TEST_COMP_FIX(a, b) TEST_FIXED_SIZE(i ? a : b) +#define TEST_COMP_VLA(a, b) TEST_VLA(i ? a : b) +#define TEST_COMP_INC(a, b) TEST_INCOMPLETE(i ? a : b) + +void +foo (int i, int j) +{ + typedef int I; + int (*pf)[2]; + int (*pv)[i]; + int (*pi)[]; + I (*pfI)[2]; + I (*pvI)[i]; + I (*piI)[]; + TEST_COMP_FIX(pf, pf); + TEST_COMP_FIX(pf, pv); + TEST_COMP_FIX(pf, pi); + TEST_COMP_FIX(pf, pfI); + TEST_COMP_FIX(pf, pvI); + TEST_COMP_FIX(pf, piI); + TEST_COMP_FIX(pv, pf); + TEST_COMP_VLA(pv, pv); + TEST_COMP_VLA(pv, pi); + TEST_COMP_FIX(pv, pfI); + TEST_COMP_VLA(pv, pvI); + TEST_COMP_VLA(pv, piI); + TEST_COMP_FIX(pi, pf); + TEST_COMP_VLA(pi, pv); + TEST_COMP_INC(pi, pi); + TEST_COMP_FIX(pi, pfI); + TEST_COMP_VLA(pi, pvI); + TEST_COMP_INC(pi, piI); + TEST_COMP_FIX(pfI, pf); + TEST_COMP_FIX(pfI, pv); + TEST_COMP_FIX(pfI, pi); + TEST_COMP_FIX(pfI, pfI); + TEST_COMP_FIX(pfI, pvI); + TEST_COMP_FIX(pfI, piI); + TEST_COMP_FIX(pvI, pf); + TEST_COMP_VLA(pvI, pv); + TEST_COMP_VLA(pvI, pi); + TEST_COMP_FIX(pvI, pfI); + TEST_COMP_VLA(pvI, pvI); + TEST_COMP_VLA(pvI, piI); + TEST_COMP_FIX(piI, pf); + TEST_COMP_VLA(piI, pv); + TEST_COMP_INC(piI, pi); + TEST_COMP_FIX(piI, pfI); + TEST_COMP_VLA(piI, pvI); + TEST_COMP_INC(piI, piI); + typedef int (*Ti)[i]; + typedef int (*Tj)[j]; + Ti (*qf)[2]; + Ti (*qv)[i]; + Ti (*qi)[]; + Tj (*rf)[2]; + Tj (*rv)[j]; + Tj (*ri)[]; + TEST_COMP_FIX(qf, qf); + TEST_COMP_FIX(qf, qv); + TEST_COMP_FIX(qf, qi); + TEST_COMP_FIX(qf, rf); + TEST_COMP_FIX(qf, rv); + TEST_COMP_FIX(qf, ri); + TEST_COMP_FIX(qv, qf); + TEST_COMP_VLA(qv, qv); + TEST_COMP_VLA(qv, qi); + TEST_COMP_FIX(qv, rf); + TEST_COMP_VLA(qv, rv); + TEST_COMP_VLA(qv, ri); + TEST_COMP_FIX(qi, qf); + TEST_COMP_VLA(qi, qv); + TEST_COMP_INC(qi, qi); + TEST_COMP_FIX(qi, rf); + TEST_COMP_VLA(qi, rv); + TEST_COMP_INC(qi, ri); + TEST_COMP_FIX(rf, qf); + TEST_COMP_FIX(rf, qv); + TEST_COMP_FIX(rf, qi); + TEST_COMP_FIX(rf, rf); + TEST_COMP_FIX(rf, rv); + TEST_COMP_FIX(rf, ri); + TEST_COMP_FIX(rv, qf); + TEST_COMP_VLA(rv, qv); + TEST_COMP_VLA(rv, qi); + TEST_COMP_FIX(rv, rf); + TEST_COMP_VLA(rv, rv); + TEST_COMP_VLA(rv, ri); + TEST_COMP_FIX(ri, qf); + TEST_COMP_VLA(ri, qv); + TEST_COMP_INC(ri, qi); + TEST_COMP_FIX(ri, rf); + TEST_COMP_VLA(ri, rv); + TEST_COMP_INC(ri, ri); +} diff --git a/SingleSource/Regression/C/gcc-dg/c99-vla-jump-1.c b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-1.c new file mode 100644 index 0000000000..0747475e28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-1.c @@ -0,0 +1,309 @@ +/* Test for labels and VM declarations: bug 12913. + goto statements must not jump into the scope of VM declarations. + + This tests all combinations of label and goto locations in a given + function. + + c99-vla-jump-1.c tests with just that label and goto, VLAs. + c99-vla-jump-2.c tests with many other labels and gotos, VLAs. + c99-vla-jump-3.c tests with just that label and goto, VM. + c99-vla-jump-4.c tests with many other labels and gotos, VM. + c99-vla-jump-5.c tests with switch statements. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void fa0 (int n) { goto a; a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa1 (int n) { goto a; { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */ +void fa2 (int n) { goto a; { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */ +void fa3 (int n) { goto a; { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */ +void fa4 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */ +void fa5 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */ +void fa6 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa7 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa8 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa9 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa10 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa11 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa12 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa13 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa14 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa15 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa16 (int n) { a: goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa17 (int n) { a:{ int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa18 (int n) { { int b[n]; goto a; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa19 (int n) { { int b[n]; goto a; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa20 (int n) { { int b[n]; goto a; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa21 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa22 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa23 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa24 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa25 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa26 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa27 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa28 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa29 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa30 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa31 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa32 (int n) { { int b[n]; goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa33 (int n) { { int b[n]; a: goto a; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa34 (int n) { a:{ int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa35 (int n) { { int b[n]; a:{ int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa36 (int n) { { int b[n]; { int c[n]; goto a; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa37 (int n) { { int b[n]; { int c[n]; goto a; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa38 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa39 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa40 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa41 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa42 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa43 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa44 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa45 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa46 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa47 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa48 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa49 (int n) { { int b[n]; { int c[n]; goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa50 (int n) { { int b[n]; { int c[n]; a: goto a; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa51 (int n) { a:{ int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa52 (int n) { { int b[n]; a:{ int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa53 (int n) { { int b[n]; { int c[n]; a:0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa54 (int n) { { int b[n]; { int c[n]; 0;} goto a; a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa55 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa56 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa57 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa58 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa59 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa60 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa61 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa62 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa63 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa64 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa65 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa66 (int n) { { int b[n]; { int c[n]; 0;} goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa67 (int n) { { int b[n]; { int c[n]; 0;} a: goto a; { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa68 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa69 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa70 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa71 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa72 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa73 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa74 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa75 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa76 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa77 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa78 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa79 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa80 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa81 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa82 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa83 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa84 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a: goto a; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa85 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa86 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa87 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa88 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa89 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa90 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa91 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa92 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa93 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa94 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa95 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa96 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa97 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa98 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa99 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa100 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa101 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a: goto a; ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa102 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa103 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa104 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa105 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa106 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa107 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa108 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa109 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa110 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa111 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa112 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa113 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa114 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa115 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa116 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa117 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa118 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a: goto a; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa119 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa120 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa121 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa122 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa123 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa124 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa125 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa126 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa127 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa128 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa129 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa130 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa131 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa132 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa133 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa134 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa135 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a: goto a; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa136 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa137 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa138 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa139 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa140 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa141 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa142 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa143 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa144 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa145 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa146 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa147 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa148 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } +void fa149 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa150 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa151 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa152 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a: goto a; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa153 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa154 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa155 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa156 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa157 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa158 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa159 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa160 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa161 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa162 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa163 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa164 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa165 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } +void fa166 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa167 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa168 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa169 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a: goto a; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa170 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa171 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa172 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa173 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa174 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa175 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa176 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa177 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa178 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa179 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa180 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa181 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa182 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } +void fa183 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa184 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa185 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa186 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a: goto a; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa187 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa188 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa189 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa190 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa191 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa192 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa193 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa194 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa195 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa196 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa197 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa198 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa199 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; } +void fa200 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa201 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa202 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa203 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a: goto a; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa204 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa205 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa206 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa207 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa208 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa209 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa210 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa211 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa212 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa213 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa214 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa215 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; goto a; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa216 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; a:; int i[n]; 0;}; ; int j[n]; 0; } +void fa217 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; a:0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa218 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; a:; int j[n]; 0; } +void fa219 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; goto a; ; int i[n]; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa220 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a: goto a; ; int i[n]; 0;}; ; int j[n]; 0; } +void fa221 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } +void fa222 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa223 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa224 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa225 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa226 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa227 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa228 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } +void fa229 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } +void fa230 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa231 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } +void fa232 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; goto a; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa233 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; goto a; 0;}; ; int j[n]; 0; } +void fa234 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; a:0;}; ; int j[n]; 0; } +void fa235 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; a:; int j[n]; 0; } +void fa236 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; goto a; 0;}; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa237 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a: goto a; 0;}; ; int j[n]; 0; } +void fa238 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } +void fa239 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa240 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa241 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa242 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa243 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa244 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa245 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } +void fa246 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa247 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa248 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa249 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa250 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa251 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; goto a; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa252 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; a:; int j[n]; 0; } +void fa253 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; goto a; ; int j[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa254 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a: goto a; ; int j[n]; 0; } +void fa255 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } +void fa256 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa257 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa258 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa259 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa260 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa261 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa262 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } +void fa263 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa264 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa265 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa266 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa267 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa268 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa269 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; goto a; 0; } +void fa270 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; goto a; a:0; } +void fa271 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a: goto a; 0; } +void fa272 (int n) { a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } +void fa273 (int n) { { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa274 (int n) { { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa275 (int n) { { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa276 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa277 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa278 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa279 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } +void fa280 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa281 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; a:0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa282 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; a:{ int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa283 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; a:0;}; ; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa284 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; a:; int i[n]; 0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa285 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; a:0;}; ; int j[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fa286 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; goto a; } +void fa287 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; goto a; } +void fa288 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0;a: goto a; } + +/* Match extra informative notes. */ +/* { dg-message "note: label '\[^\n'\]*' defined here" "note: defined" { target *-*-* } 0 } */ +/* { dg-message "note: '\[^\n'\]*' declared here" "note: declared" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-vla-jump-2.c b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-2.c new file mode 100644 index 0000000000..afea116924 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-2.c @@ -0,0 +1,309 @@ +/* Test for labels and VM declarations: bug 12913. + goto statements must not jump into the scope of VM declarations. + + This tests all combinations of label and goto locations in a given + function. + + c99-vla-jump-1.c tests with just that label and goto, VLAs. + c99-vla-jump-2.c tests with many other labels and gotos, VLAs. + c99-vla-jump-3.c tests with just that label and goto, VM. + c99-vla-jump-4.c tests with many other labels and gotos, VM. + c99-vla-jump-5.c tests with switch statements. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void fb0 (int n) { p0A:goto p0A; goto a; a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb1 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb2 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb3 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb4 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb5 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb6 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb7 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb8 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb9 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb10 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb11 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb12 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb13 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb14 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb15 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb16 (int n) { a: goto a; P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb17 (int n) { a:{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb18 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb19 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb20 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb21 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb22 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb23 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb24 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb25 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb26 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb27 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb28 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb29 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb30 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb31 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb32 (int n) { P0A:goto P0A;{ int b[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb33 (int n) { P0A:goto P0A;{ int b[n]; a: goto a; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb34 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb35 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb36 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb37 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb38 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb39 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb40 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb41 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb42 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb43 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb44 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb45 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb46 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb47 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb48 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb49 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb50 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a: goto a; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb51 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb52 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb53 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb54 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb55 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb56 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb57 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb58 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb59 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb60 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb61 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb62 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb63 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb64 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb65 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb66 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb67 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a: goto a; P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb68 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb69 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb70 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb71 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb72 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb73 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb74 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb75 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb76 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb77 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb78 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb79 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb80 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb81 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb82 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb83 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb84 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a: goto a; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb85 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb86 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb87 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb88 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb89 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb90 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb91 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb92 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb93 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb94 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb95 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb96 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb97 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb98 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb99 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb100 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb101 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a: goto a; P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb102 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb103 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb104 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb105 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb106 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb107 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb108 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb109 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb110 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb111 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb112 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb113 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb114 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb115 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb116 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb117 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb118 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a: goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb119 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb120 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb121 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb122 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb123 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb124 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb125 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb126 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb127 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb128 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb129 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb130 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb131 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb132 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb133 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb134 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb135 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a: goto a; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb136 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb137 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb138 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb139 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb140 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb141 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb142 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb143 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb144 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb145 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb146 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb147 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb148 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb149 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb150 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb151 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb152 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a: goto a; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb153 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb154 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb155 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb156 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb157 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb158 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb159 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb160 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb161 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb162 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb163 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb164 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb165 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb166 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb167 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb168 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb169 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a: goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb170 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb171 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb172 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb173 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb174 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb175 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb176 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb177 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb178 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb179 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb180 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb181 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb182 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb183 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb184 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb185 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb186 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a: goto a; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb187 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb188 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb189 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb190 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb191 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb192 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb193 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb194 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb195 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb196 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb197 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb198 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb199 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb200 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb201 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb202 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb203 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a: goto a; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb204 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb205 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb206 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb207 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb208 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb209 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb210 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb211 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb212 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb213 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb214 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb215 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb216 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb217 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb218 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb219 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb220 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a: goto a; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb221 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb222 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb223 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb224 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb225 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb226 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb227 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb228 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb229 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb230 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb231 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb232 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb233 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb234 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb235 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb236 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb237 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a: goto a; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb238 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb239 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb240 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb241 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb242 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb243 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb244 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb245 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb246 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb247 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb248 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb249 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb250 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb251 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb252 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; a:; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb253 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; int j[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb254 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a: goto a; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fb255 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } +void fb256 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb257 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb258 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb259 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb260 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb261 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb262 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } +void fb263 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb264 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb265 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb266 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb267 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb268 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb269 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } +void fb270 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; p03A:goto p03A; goto a; a:0;P03B:goto P03B; } +void fb271 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a: goto a; P03A:goto P03A;0;P03B:goto P03B; } +void fb272 (int n) { a:{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } +void fb273 (int n) { P0A:goto P0A;{ int b[n]; a:{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb274 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; a:0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb275 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} a:{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb276 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; a:0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb277 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} a:; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb278 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; a:0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb279 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; a:{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } +void fb280 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; a:{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb281 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; a:0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb282 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; a:{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb283 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; a:0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb284 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; a:; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb285 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; a:0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fb286 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } +void fb287 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;p03B:goto p03B; goto a; P03B:goto P03B; } +void fb288 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;a: goto a; P03B:goto P03B; } + +/* Match extra informative notes. */ +/* { dg-message "note: label '\[^\n'\]*' defined here" "note: defined" { target *-*-* } 0 } */ +/* { dg-message "note: '\[^\n'\]*' declared here" "note: declared" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-vla-jump-3.c b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-3.c new file mode 100644 index 0000000000..f7cb6ac63f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-3.c @@ -0,0 +1,309 @@ +/* Test for labels and VM declarations: bug 12913. + goto statements must not jump into the scope of VM declarations. + + This tests all combinations of label and goto locations in a given + function. + + c99-vla-jump-1.c tests with just that label and goto, VLAs. + c99-vla-jump-2.c tests with many other labels and gotos, VLAs. + c99-vla-jump-3.c tests with just that label and goto, VM. + c99-vla-jump-4.c tests with many other labels and gotos, VM. + c99-vla-jump-5.c tests with switch statements. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void fc0 (int n) { goto a; a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc1 (int n) { goto a; { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc2 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc3 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc4 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc5 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc6 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc7 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc8 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc9 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc10 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc11 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc12 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc13 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc14 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc15 (int n) { goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc16 (int n) { a: goto a; { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc17 (int n) { a:{ typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc18 (int n) { { typedef int (*b)[n]; goto a; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc19 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc20 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc21 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc22 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc23 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc24 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc25 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc26 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc27 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc28 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc29 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc30 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc31 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc32 (int n) { { typedef int (*b)[n]; goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc33 (int n) { { typedef int (*b)[n]; a: goto a; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc34 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc35 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc36 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc37 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc38 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc39 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc40 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc41 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc42 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc43 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc44 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc45 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc46 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc47 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc48 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc49 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc50 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a: goto a; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc51 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc52 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc53 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc54 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc55 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc56 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc57 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc58 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc59 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc60 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc61 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc62 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc63 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc64 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc65 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc66 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc67 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a: goto a; { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc68 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc69 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc70 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc71 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc72 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc73 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc74 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc75 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc76 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc77 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc78 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc79 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc80 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc81 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc82 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc83 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc84 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a: goto a; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc85 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc86 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc87 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc88 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc89 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc90 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc91 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc92 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc93 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc94 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc95 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc96 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc97 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc98 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc99 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc100 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc101 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a: goto a; ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc102 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc103 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc104 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc105 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc106 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc107 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc108 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc109 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc110 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc111 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc112 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc113 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc114 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc115 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc116 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc117 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc118 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a: goto a; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc119 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc120 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc121 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc122 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc123 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc124 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc125 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc126 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc127 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc128 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc129 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc130 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc131 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc132 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc133 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc134 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc135 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a: goto a; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc136 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc137 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc138 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc139 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc140 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc141 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc142 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc143 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc144 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc145 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc146 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc147 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc148 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc149 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc150 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc151 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc152 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a: goto a; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc153 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc154 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc155 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc156 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc157 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc158 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc159 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc160 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc161 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc162 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc163 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc164 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc165 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc166 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc167 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc168 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc169 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a: goto a; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc170 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc171 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc172 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc173 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc174 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc175 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc176 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc177 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc178 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc179 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc180 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc181 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc182 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc183 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc184 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc185 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc186 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a: goto a; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc187 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc188 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc189 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc190 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc191 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc192 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc193 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc194 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc195 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc196 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc197 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc198 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc199 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc200 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc201 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc202 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc203 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a: goto a; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc204 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc205 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc206 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc207 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc208 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc209 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc210 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc211 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc212 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc213 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc214 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc215 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc216 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc217 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc218 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; } +void fc219 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc220 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a: goto a; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; } +void fc221 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } +void fc222 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc223 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc224 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc225 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc226 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc227 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc228 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } +void fc229 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } +void fc230 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc231 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } +void fc232 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc233 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; 0; } +void fc234 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; a:0;}; ; typedef int (*j)[n]; 0; } +void fc235 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; a:; typedef int (*j)[n]; 0; } +void fc236 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; goto a; 0;}; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc237 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a: goto a; 0;}; ; typedef int (*j)[n]; 0; } +void fc238 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } +void fc239 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc240 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc241 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc242 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc243 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc244 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc245 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } +void fc246 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc247 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc248 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc249 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc250 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc251 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; goto a; ; typedef int (*j)[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc252 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; a:; typedef int (*j)[n]; 0; } +void fc253 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; goto a; ; typedef int (*j)[n]; a:0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc254 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a: goto a; ; typedef int (*j)[n]; 0; } +void fc255 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } +void fc256 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc257 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc258 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc259 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc260 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc261 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc262 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } +void fc263 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc264 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc265 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc266 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc267 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc268 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; goto a; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc269 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; goto a; 0; } +void fc270 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; goto a; a:0; } +void fc271 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a: goto a; 0; } +void fc272 (int n) { a:{ typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } +void fc273 (int n) { { typedef int (*b)[n]; a:{ typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc274 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; a:0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc275 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} a:{ typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc276 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; a:0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc277 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} a:; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc278 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; a:0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc279 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; a:{ typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } +void fc280 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; a:{ typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc281 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; a:0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc282 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; a:{ typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc283 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; a:0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc284 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; a:; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc285 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; a:0;}; ; typedef int (*j)[n]; 0; goto a; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fc286 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; goto a; } +void fc287 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; goto a; } +void fc288 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0;a: goto a; } + +/* Match extra informative notes. */ +/* { dg-message "note: label '\[^\n'\]*' defined here" "note: defined" { target *-*-* } 0 } */ +/* { dg-message "note: '\[^\n'\]*' declared here" "note: declared" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-vla-jump-4.c b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-4.c new file mode 100644 index 0000000000..6f0060e664 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-4.c @@ -0,0 +1,309 @@ +/* Test for labels and VM declarations: bug 12913. + goto statements must not jump into the scope of VM declarations. + + This tests all combinations of label and goto locations in a given + function. + + c99-vla-jump-1.c tests with just that label and goto, VLAs. + c99-vla-jump-2.c tests with many other labels and gotos, VLAs. + c99-vla-jump-3.c tests with just that label and goto, VM. + c99-vla-jump-4.c tests with many other labels and gotos, VM. + c99-vla-jump-5.c tests with switch statements. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void fd0 (int n) { p0A:goto p0A; goto a; a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd1 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd2 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd3 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd4 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd5 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd6 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd7 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd8 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd9 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd10 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd11 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd12 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd13 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd14 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd15 (int n) { p0A:goto p0A; goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd16 (int n) { a: goto a; P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd17 (int n) { a:{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd18 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd19 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd20 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd21 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd22 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd23 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd24 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd25 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd26 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd27 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd28 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd29 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd30 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd31 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd32 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; p01A:goto p01A; goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd33 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a: goto a; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd34 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd35 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd36 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd37 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd38 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd39 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd40 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd41 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd42 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd43 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd44 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd45 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd46 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd47 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd48 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd49 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; p012A:goto p012A; goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd50 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a: goto a; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd51 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd52 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd53 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd54 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd55 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd56 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd57 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd58 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd59 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd60 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd61 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd62 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd63 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd64 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd65 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd66 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} p01B:goto p01B; goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd67 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a: goto a; P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd68 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd69 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd70 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd71 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd72 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd73 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd74 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd75 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd76 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd77 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd78 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd79 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd80 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd81 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd82 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd83 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; p013A:goto p013A; goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd84 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a: goto a; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd85 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd86 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd87 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd88 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd89 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd90 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd91 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd92 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd93 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd94 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd95 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd96 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd97 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd98 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd99 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd100 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} p01C:goto p01C; goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd101 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a: goto a; P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd102 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd103 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd104 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd105 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd106 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd107 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd108 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd109 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd110 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd111 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd112 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd113 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd114 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd115 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd116 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd117 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; p014A:goto p014A; goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd118 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a: goto a; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd119 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd120 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd121 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd122 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd123 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd124 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd125 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd126 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd127 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd128 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd129 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd130 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd131 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd132 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd133 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd134 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; p0B:goto p0B; goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd135 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a: goto a; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd136 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd137 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd138 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd139 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd140 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd141 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd142 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd143 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd144 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd145 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd146 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd147 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd148 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd149 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd150 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd151 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; p02A:goto p02A; goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd152 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a: goto a; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd153 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd154 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd155 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd156 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd157 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd158 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd159 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd160 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd161 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd162 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd163 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd164 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd165 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd166 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd167 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd168 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; p024A:goto p024A; goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd169 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a: goto a; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd170 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd171 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd172 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd173 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd174 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd175 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd176 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd177 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd178 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd179 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd180 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd181 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd182 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd183 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd184 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd185 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; p02B:goto p02B; goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd186 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a: goto a; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd187 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd188 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd189 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd190 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd191 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd192 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd193 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd194 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd195 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd196 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd197 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd198 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd199 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd200 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd201 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd202 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; p025A:goto p025A; goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd203 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a: goto a; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd204 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd205 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd206 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd207 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd208 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd209 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd210 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd211 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd212 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd213 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd214 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd215 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd216 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd217 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd218 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd219 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; p02C:goto p02C; goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd220 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a: goto a; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd221 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd222 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd223 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd224 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd225 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd226 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd227 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd228 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd229 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd230 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd231 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd232 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd233 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd234 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd235 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd236 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; p026A:goto p026A; goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd237 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a: goto a; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd238 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd239 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd240 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd241 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd242 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd243 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd244 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd245 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd246 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd247 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd248 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd249 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd250 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd251 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd252 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; a:; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd253 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; p0C:goto p0C; goto a; P0C:goto P0C;; typedef int (*j)[n]; a:0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd254 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a: goto a; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;P03B:goto P03B; } +void fd255 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } +void fd256 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd257 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd258 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd259 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd260 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd261 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd262 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } +void fd263 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd264 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd265 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd266 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd267 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd268 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd269 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; p03A:goto p03A; goto a; P03A:goto P03A;0;P03B:goto P03B; } +void fd270 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; p03A:goto p03A; goto a; a:0;P03B:goto P03B; } +void fd271 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a: goto a; P03A:goto P03A;0;P03B:goto P03B; } +void fd272 (int n) { a:{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } +void fd273 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; a:{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd274 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; a:0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd275 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} a:{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd276 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; a:0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd277 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} a:; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd278 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; a:0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd279 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; a:{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } +void fd280 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; a:{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd281 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; a:0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd282 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; a:{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd283 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; a:0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd284 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; a:; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd285 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; a:0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } /* { dg-error "jump into scope of identifier with variably modified type" } */ +void fd286 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; } +void fd287 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;p03B:goto p03B; goto a; P03B:goto P03B; } +void fd288 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;a: goto a; P03B:goto P03B; } + +/* Match extra informative notes. */ +/* { dg-message "note: label '\[^\n'\]*' defined here" "note: defined" { target *-*-* } 0 } */ +/* { dg-message "note: '\[^\n'\]*' declared here" "note: declared" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/c99-vla-jump-5.c b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-5.c new file mode 100644 index 0000000000..5b5fc74f2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/c99-vla-jump-5.c @@ -0,0 +1,34 @@ +/* Test for labels and VM declarations: bug 12913. + switch statements must not jump into the scope of VM declarations. + + c99-vla-jump-1.c tests with just that label and goto, VLAs. + c99-vla-jump-2.c tests with many other labels and gotos, VLAs. + c99-vla-jump-3.c tests with just that label and goto, VM. + c99-vla-jump-4.c tests with many other labels and gotos, VM. + c99-vla-jump-5.c tests with switch statements. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +void +f (int a, int b) +{ + switch (a) { /* { dg-warning "statement will never be executed" } */ + int v[b]; + case 2: /* { dg-error "switch jumps into scope of identifier with variably modified type" } */ + default: /* { dg-error "switch jumps into scope of identifier with variably modified type" } */ + switch (a) + { + case 4: + { int z[b]; } + default: + ; + int w[b]; + } + } +} + +/* Match extra informative notes. */ +/* { dg-message "note: switch starts here" "note: starts" { target *-*-* } 0 } */ +/* { dg-message "note: '\[^\n'\]*' declared here" "note: declared" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/call-diag-1.c b/SingleSource/Regression/C/gcc-dg/call-diag-1.c new file mode 100644 index 0000000000..884baa0d43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/call-diag-1.c @@ -0,0 +1,9 @@ +/* The warning for calling through a non-compatible type must not + disable the normal diagnostics from comparing the argument list + against the type of the called expression. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo (void); +void bar (void) { ((long (*)(int))foo) (); } /* { dg-error "too few arguments to function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/call-diag-2.c b/SingleSource/Regression/C/gcc-dg/call-diag-2.c new file mode 100644 index 0000000000..f7e66ebb36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/call-diag-2.c @@ -0,0 +1,15 @@ +/* Test diagnostics for calling function returning qualified void or + other incomplete type other than void. PR 35210. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +const void f_cv (void); +struct s f_s (void); +void f_v (void); + +void g1 (void) { f_cv (); } /* { dg-error "qualified void" } */ +void g2 (void) { f_s (); } /* { dg-error "invalid use of undefined type" } */ +void g3 (void) { ((const void (*) (void)) f_v) (); } /* { dg-error "qualified void" } */ +/* { dg-warning "function called through a non-compatible type" "cast" { target *-*-* } .-1 } */ +void g4 (void) { ((struct s (*) (void)) f_v) (), (void) 0; } /* { dg-error "invalid use of undefined type" } */ +/* { dg-warning "function called through a non-compatible type" "cast" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/case-bogus-1.c b/SingleSource/Regression/C/gcc-dg/case-bogus-1.c new file mode 100644 index 0000000000..548312edf9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/case-bogus-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +void +foo (int n) +{ + switch (n) + case 0: case 3: case 0.2: case 5:; /* { dg-error "21:case label does not reduce to an integer constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/case-const-1.c b/SingleSource/Regression/C/gcc-dg/case-const-1.c new file mode 100644 index 0000000000..ba39d09616 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/case-const-1.c @@ -0,0 +1,15 @@ +/* Test for case labels not integer constant expressions but folding + to integer constants (used in Linux kernel, PR 39613). */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern int i; +void +f (int c) +{ + switch (c) + { + case (1 ? 1 : i): + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/case-const-2.c b/SingleSource/Regression/C/gcc-dg/case-const-2.c new file mode 100644 index 0000000000..9c119b04df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/case-const-2.c @@ -0,0 +1,15 @@ +/* Test for case labels not integer constant expressions but folding + to integer constants (used in Linux kernel, PR 39613). */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +extern int i; +void +f (int c) +{ + switch (c) + { + case (1 ? 1 : i): /* { dg-warning "case label is not an integer constant expression" } */ + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/case-const-3.c b/SingleSource/Regression/C/gcc-dg/case-const-3.c new file mode 100644 index 0000000000..7224cca47d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/case-const-3.c @@ -0,0 +1,15 @@ +/* Test for case labels not integer constant expressions but folding + to integer constants (used in Linux kernel, PR 39613). */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +extern int i; +void +f (int c) +{ + switch (c) + { + case (1 ? 1 : i): /* { dg-error "case label is not an integer constant expression" } */ + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-1.c b/SingleSource/Regression/C/gcc-dg/cast-1.c new file mode 100644 index 0000000000..335a090d4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-1.c @@ -0,0 +1,41 @@ +/* Test diagnostics for bad or doubtful casts. Test with no special + options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +struct s { int a; } sv; +union u { int a; } uv; +int i; +long l; +char c; +void *p; +float fv; + +void +f (void) +{ + (int []) p; /* { dg-error "cast specifies array type" } */ + (int ()) p; /* { dg-error "cast specifies function type" } */ + (struct s) sv; + (union u) uv; + (struct s) i; /* { dg-error "conversion to non-scalar type requested" } */ + (union u) i; + (union u) l; /* { dg-error "cast to union type from type not present in union" } */ + (int) sv; /* { dg-error "aggregate value used where an integer was expected" } */ + (int) uv; /* { dg-error "aggregate value used where an integer was expected" } */ + (float) sv; /* { dg-error "aggregate value used where a floating-point was expected" } */ + (float) uv; /* { dg-error "aggregate value used where a floating-point was expected" } */ + (_Complex double) sv; /* { dg-error "aggregate value used where a complex was expected" } */ + (_Complex double) uv; /* { dg-error "aggregate value used where a complex was expected" } */ + (void *) sv; /* { dg-error "cannot convert to a pointer type" } */ + (void *) uv; /* { dg-error "cannot convert to a pointer type" } */ + (_Bool) sv; /* { dg-error "used struct type value where scalar is required" } */ + (_Bool) uv; /* { dg-error "used union type value where scalar is required" } */ + (void) sv; + (const void) uv; + (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */ + (void *) (char) 1; + (char) p; /* { dg-warning "cast from pointer to integer of different size" } */ + (char) (void *) 1; /* { dg-warning "cast from pointer to integer of different size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-2.c b/SingleSource/Regression/C/gcc-dg/cast-2.c new file mode 100644 index 0000000000..2523ac4cbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-2.c @@ -0,0 +1,41 @@ +/* Test diagnostics for bad or doubtful casts. Test with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic" } */ + +struct s { int a; } sv; +union u { int a; } uv; +int i; +long l; +char c; +void *p; +float fv; + +void +f (void) +{ + (int []) p; /* { dg-error "cast specifies array type" } */ + (int ()) p; /* { dg-error "cast specifies function type" } */ + (struct s) sv; /* { dg-warning "ISO C forbids casting nonscalar to the same type" } */ + (union u) uv; /* { dg-warning "ISO C forbids casting nonscalar to the same type" } */ + (struct s) i; /* { dg-error "conversion to non-scalar type requested" } */ + (union u) i; /* { dg-warning "ISO C forbids casts to union type" } */ + (union u) l; /* { dg-error "cast to union type from type not present in union" } */ + (int) sv; /* { dg-error "aggregate value used where an integer was expected" } */ + (int) uv; /* { dg-error "aggregate value used where an integer was expected" } */ + (float) sv; /* { dg-error "aggregate value used where a floating-point was expected" } */ + (float) uv; /* { dg-error "aggregate value used where a floating-point was expected" } */ + (_Complex double) sv; /* { dg-error "aggregate value used where a complex was expected" } */ + (_Complex double) uv; /* { dg-error "aggregate value used where a complex was expected" } */ + (void *) sv; /* { dg-error "cannot convert to a pointer type" } */ + (void *) uv; /* { dg-error "cannot convert to a pointer type" } */ + (_Bool) sv; /* { dg-error "used struct type value where scalar is required" } */ + (_Bool) uv; /* { dg-error "used union type value where scalar is required" } */ + (void) sv; + (const void) uv; + (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */ + (void *) (char) 1; + (char) p; /* { dg-warning "cast from pointer to integer of different size" } */ + (char) (void *) 1; /* { dg-warning "cast from pointer to integer of different size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-3.c b/SingleSource/Regression/C/gcc-dg/cast-3.c new file mode 100644 index 0000000000..1e3f5f43c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-3.c @@ -0,0 +1,41 @@ +/* Test diagnostics for bad or doubtful casts. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +struct s { int a; } sv; +union u { int a; } uv; +int i; +long l; +char c; +void *p; +float fv; + +void +f (void) +{ + (int []) p; /* { dg-error "cast specifies array type" } */ + (int ()) p; /* { dg-error "cast specifies function type" } */ + (struct s) sv; /* { dg-error "ISO C forbids casting nonscalar to the same type" } */ + (union u) uv; /* { dg-error "ISO C forbids casting nonscalar to the same type" } */ + (struct s) i; /* { dg-error "conversion to non-scalar type requested" } */ + (union u) i; /* { dg-error "ISO C forbids casts to union type" } */ + (union u) l; /* { dg-error "cast to union type from type not present in union" } */ + (int) sv; /* { dg-error "aggregate value used where an integer was expected" } */ + (int) uv; /* { dg-error "aggregate value used where an integer was expected" } */ + (float) sv; /* { dg-error "aggregate value used where a floating-point was expected" } */ + (float) uv; /* { dg-error "aggregate value used where a floating-point was expected" } */ + (_Complex double) sv; /* { dg-error "aggregate value used where a complex was expected" } */ + (_Complex double) uv; /* { dg-error "aggregate value used where a complex was expected" } */ + (void *) sv; /* { dg-error "cannot convert to a pointer type" } */ + (void *) uv; /* { dg-error "cannot convert to a pointer type" } */ + (_Bool) sv; /* { dg-error "used struct type value where scalar is required" } */ + (_Bool) uv; /* { dg-error "used union type value where scalar is required" } */ + (void) sv; + (const void) uv; + (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */ + (void *) (char) 1; + (char) p; /* { dg-warning "cast from pointer to integer of different size" } */ + (char) (void *) 1; /* { dg-warning "cast from pointer to integer of different size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-4.c b/SingleSource/Regression/C/gcc-dg/cast-4.c new file mode 100644 index 0000000000..ebc84c11ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-4.c @@ -0,0 +1,13 @@ +/* Test warnings when casting from a constant integer to pointer. + Test with -pedantic-errors. */ +/* Origin: Carlos O'Donell */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +extern int i; +char c; +void +f (void) +{ + c = (char)&i; /* { dg-warning "cast from pointer to integer of different size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-function-1.c b/SingleSource/Regression/C/gcc-dg/cast-function-1.c new file mode 100644 index 0000000000..5228b55916 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-function-1.c @@ -0,0 +1,49 @@ +/* PR c/12085 */ +/* Origin: David Hollenberg */ + +/* Verify that the compiler doesn't inline a function at + a calling point where it is viewed with a different + prototype than the actual one. */ + +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int foo1(int); +int foo2(); + +typedef struct { + double d; + int a; +} str_t; + +void bar(double d, int i, str_t s) +{ + d = ((double (*) (int)) foo1) (i); /* { dg-warning "8:non-compatible|abort" } */ + i = ((int (*) (double)) foo1) (d); /* { dg-warning "8:non-compatible|abort" } */ + s = ((str_t (*) (int)) foo1) (i); /* { dg-warning "8:non-compatible|abort" } */ + ((void (*) (int)) foo1) (d); /* { dg-warning "non-compatible|abort" } */ + i = ((int (*) (int)) foo1) (i); /* { dg-bogus "non-compatible|abort" } */ + (void) foo1 (i); /* { dg-bogus "non-compatible|abort" } */ + + d = ((double (*) (int)) foo2) (i); /* { dg-warning "8:non-compatible|abort" } */ + i = ((int (*) (double)) foo2) (d); /* { dg-bogus "non-compatible|abort" } */ + s = ((str_t (*) (int)) foo2) (i); /* { dg-warning "non-compatible|abort" } */ + ((void (*) (int)) foo2) (d); /* { dg-warning "non-compatible|abort" } */ + i = ((int (*) (int)) foo2) (i); /* { dg-bogus "non-compatible|abort" } */ + (void) foo2 (i); /* { dg-bogus "non-compatible|abort" } */ +} + +int foo1(int arg) +{ + /* Prevent the function from becoming const and thus DCEd. */ + __asm volatile ("" : "+r" (arg)); + return arg; +} + +int foo2(arg) + int arg; +{ + /* Prevent the function from becoming const and thus DCEd. */ + __asm volatile ("" : "+r" (arg)); + return arg; +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-lvalue-1.c b/SingleSource/Regression/C/gcc-dg/cast-lvalue-1.c new file mode 100644 index 0000000000..ef3ae0a4db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-lvalue-1.c @@ -0,0 +1,13 @@ +/* Test for deprecation of casts as lvalues. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int x; + +void +foo (void) +{ + (char) x = 1; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "lvalue" "cast as lvalue" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-lvalue-2.c b/SingleSource/Regression/C/gcc-dg/cast-lvalue-2.c new file mode 100644 index 0000000000..0dcbedc7c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-lvalue-2.c @@ -0,0 +1,13 @@ +/* Test for error on casts as lvalues. Casts to same type. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int x; + +void +foo (void) +{ + (int) x = 1; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "lvalue" "cast as lvalue" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-pretty-print-1.c b/SingleSource/Regression/C/gcc-dg/cast-pretty-print-1.c new file mode 100644 index 0000000000..b9da56674d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-pretty-print-1.c @@ -0,0 +1,12 @@ +/* Test pretty-printing of casts. Should not depend on whether + NOP_EXPR or CONVERT_EXPR is used. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ +int i; +void +f (void) +{ + ((unsigned int)i)(); /* { dg-error "called object '\\(unsigned int\\)i' is not a function" } */ + ((char)i)(); /* { dg-error "called object '\\(char\\)i' is not a function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-qual-1.c b/SingleSource/Regression/C/gcc-dg/cast-qual-1.c new file mode 100644 index 0000000000..407d138d1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-qual-1.c @@ -0,0 +1,30 @@ +/* Incorrect `cast discards `const'' warnings. There should be warnings + in bad_cast and bad_assign; bad_assign gets the correct warning, but + good_cast may get the warning instead of bad_cast. + gcc 2.7.2.3 passes, egcs-1.1.2 and egcs-ss-19990428 fail. + http://gcc.gnu.org/ml/gcc-bugs/1998-08/msg00645.html */ +/* { dg-do compile } */ +/* { dg-options "-Wcast-qual" } */ +void +good_cast(const void *bar) +{ + (char *const *)bar; /* { dg-bogus "cast discards" "discarding `const' warning" } */ +} + +void +bad_cast(const void *bar) +{ + (const char **)bar; /* { dg-warning "cast discards" "discarding `const' warning" } */ +} + +void +good_assign(const void *bar) +{ + char *const *foo = bar; /* { dg-bogus "initialization discards" "discarding `const' warning" } */ +} + +void +bad_assign(const void *bar) +{ + const char **foo = bar; /* { dg-warning "initialization discards" "discarding `const' warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cast-qual-2.c b/SingleSource/Regression/C/gcc-dg/cast-qual-2.c new file mode 100644 index 0000000000..5fd2b854d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-qual-2.c @@ -0,0 +1,34 @@ +/* Test whether the -Wcast-qual handles cv-qualified functions correctly. */ +/* { dg-do compile } */ +/* { dg-options "-Wcast-qual" } */ + +typedef int (intfn_t) (int); +typedef void (voidfn_t) (void); + +typedef const intfn_t *constfn_t; +typedef volatile voidfn_t *noreturnfn_t; + +intfn_t intfn; +const intfn_t constfn; +voidfn_t voidfn; +volatile voidfn_t noreturnfn; + +intfn_t *i1 = intfn; +intfn_t *i2 = (intfn_t *) intfn; +intfn_t *i3 = constfn; +intfn_t *i4 = (intfn_t *) constfn; /* { dg-bogus "discards qualifier" } */ + +constfn_t p1 = intfn; /* { dg-warning "makes '__attribute__..const..' qualified function" } */ +constfn_t p2 = (constfn_t) intfn; /* { dg-warning "adds '__attribute__..const..' qualifier" } */ +constfn_t p3 = constfn; +constfn_t p4 = (constfn_t) constfn; + +voidfn_t *v1 = voidfn; +voidfn_t *v2 = (voidfn_t *) voidfn; +voidfn_t *v3 = noreturnfn; +voidfn_t *v4 = (voidfn_t *) noreturnfn; /* { dg-bogus "discards qualifier" } */ + +noreturnfn_t n1 = voidfn; /* { dg-warning "makes '__attribute__..noreturn..' qualified function" } */ +noreturnfn_t n2 = (noreturnfn_t) voidfn; /* { dg-warning "adds '__attribute__..noreturn..' qualifier" } */ +noreturnfn_t n3 = noreturnfn; +noreturnfn_t n4 = (noreturnfn_t) noreturnfn; diff --git a/SingleSource/Regression/C/gcc-dg/cast-qual-3.c b/SingleSource/Regression/C/gcc-dg/cast-qual-3.c new file mode 100644 index 0000000000..50dabab474 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cast-qual-3.c @@ -0,0 +1,11 @@ +/* PR 55383 */ +/* { dg-do compile } */ +/* { dg-options "-Wcast-qual" } */ + +void set(void*); + +int foo(int argc) +{ + volatile double val; + set((void*)&val); /* { dg-warning "cast discards .volatile. qualifier" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cdce1.c b/SingleSource/Regression/C/gcc-dg/cdce1.c new file mode 100644 index 0000000000..e7d2ca7403 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cdce1.c @@ -0,0 +1,81 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details -fdump-tree-optimized -lm" } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-require-effective-target large_double } */ +/* { dg-final { scan-tree-dump "cdce1.c:17: \[^\n\r]* function call is shrink-wrapped into error conditions\." "cdce" } } */ +/* { dg-final { scan-tree-dump "pow \\(\[^\n\r]*\\); \\\[tail call\\\]" "optimized" } } */ + +#include +#include +#include +int total_err_count = 0; +double foo_opt (int x, double y) __attribute__((noinline)); +double foo_opt (int x, double y) +{ + double yy = 0; + errno = 0; + yy = pow (x, y * y); + return 0; +} + +double foo (int x, double y) __attribute__((noinline)); +double foo (int x, double y) +{ + double yy = 0; + errno = 0; + yy = pow (x, y * y); + return yy; +} + +int test (double (*fp)(int x, double y)) +{ + int i,x; + + x = 127; + for (i = 30; i < 300; i++) + { + fp (x, i); + if (errno) + total_err_count ++; + } + + x = -300; + for (i = 100; i < 300; i++) + { + fp (x, i); + if (errno) + total_err_count ++; + } + + x = 65577; + for (i = 60; i < 200; i++) + { + fp (x, i); + if (errno) + total_err_count ++; + } + + x = 65577 * 127; + for (i = 1; i < 100; i++) + { + fp (x, i); + if (errno) + total_err_count ++; + } + + return total_err_count; +} + +int main () +{ + int en1, en2; + total_err_count = 0; + en1 = test (foo_opt); + total_err_count = 0; + en2 = test (foo); + + if (en1 != en2) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/cdce2.c b/SingleSource/Regression/C/gcc-dg/cdce2.c new file mode 100644 index 0000000000..7924973c09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cdce2.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-skip-if "doubles are floats" { "avr-*-*" } } */ +/* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details -fdump-tree-optimized -lm" } */ +/* { dg-final { scan-tree-dump "cdce2.c:16: \[^\n\r]* function call is shrink-wrapped into error conditions\." "cdce" } } */ +/* { dg-final { scan-tree-dump "log \\(\[^\n\r]*\\); \\\[tail call\\\]" "optimized" } } */ + +#include +#include +#include +int total_err_count = 0; +double foo_opt (double y) __attribute__((noinline)); +double foo_opt (double y) +{ + double yy = 0; + errno = 0; + yy = log (y); + return 0; +} + +double foo (double y) __attribute__((noinline)); +double foo (double y) +{ + double yy = 0; + errno = 0; + yy = log (y); + return yy; +} + +int test (double (*fp) (double y)) +{ + int i,x; + for (i = -100; i < 100; i++) + { + fp (i); + if (errno) + total_err_count ++; + } + + return total_err_count; +} + +int main () +{ + int en1, en2; + double yy; + total_err_count = 0; + en1 = test (foo_opt); + total_err_count = 0; + en2 = test (foo); + + if (en1 != en2) + abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/cdce3.c b/SingleSource/Regression/C/gcc-dg/cdce3.c new file mode 100644 index 0000000000..601ddf055f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cdce3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump "cdce3.c:11: \[^\n\r]* function call is shrink-wrapped into error conditions\." "cdce" } } */ +/* { dg-final { scan-tree-dump "sqrtf \\(\[^\n\r]*\\); \\\[tail call\\\]" "optimized" } } */ +/* { dg-skip-if "doesn't have a sqrtf insn" { mmix-*-* } } */ + +float sqrtf (float); +float foo (float x) +{ + return sqrtf (x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/char-compare.c b/SingleSource/Regression/C/gcc-dg/char-compare.c new file mode 100644 index 0000000000..f8b2fb968b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/char-compare.c @@ -0,0 +1,23 @@ +/* PR rtl-optimization/23241 */ +/* Origin: Josh Conner */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort(void); + +struct fbs { + unsigned char uc; +} fbs1 = {255}; + +void fn(struct fbs *fbs_ptr) +{ + if ((fbs_ptr->uc != 255) && (fbs_ptr->uc != 0)) + abort(); +} + +int main(void) +{ + fn(&fbs1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-1.c b/SingleSource/Regression/C/gcc-dg/cleanup-1.c new file mode 100644 index 0000000000..48b82646e4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-1.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ +/* Validate expected warnings and errors. */ + +#define U __attribute__((unused)) +#define C(x) __attribute__((cleanup(x))) + +static int f1(void *x U) { return 0; } +static void f2() { } +static void f3(void) { } /* { dg-message "note: declared here" } */ +static void f4(void *x U) { } +static void f5(int *x U) { } +static void f6(double *x U) { } /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ +static void f7(const int *x U) { } +static void f8(const int *x U, int y U) { } /* { dg-message "note: declared here" } */ +static void f9(int x U) { } /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ + +void test(void) +{ + int o1 C(f1); + int o2 C(f2); + int o3 C(f3); /* { dg-error "too many arguments" } */ + int o4 C(f4); + int o5 C(f5); + int o6 C(f6); /* { dg-warning "incompatible pointer type" } */ + int o7 C(f7); + int o8 C(f8); /* { dg-error "too few arguments" } */ + int o9 C(f9); /* { dg-warning "from pointer without a cast" } */ + int o10 U C(undef); /* { dg-error "not a function" } */ + int o11 U C(o1); /* { dg-error "not a function" } */ + int o12 U C("f1"); /* { dg-error "not an identifier" } */ + static int o13 U C(f1); /* { dg-warning "attribute ignored" } */ +} + +int o14 C(f1); /* { dg-warning "attribute ignored" } */ +void t15(int o U C(f1)) {} /* { dg-warning "attribute ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-10.c b/SingleSource/Regression/C/gcc-dg/cleanup-10.c new file mode 100644 index 0000000000..9fc8658192 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-10.c @@ -0,0 +1,117 @@ +/* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* *-*-darwin[912]* *-*-uclinux* } } */ +/* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */ +/* { dg-require-effective-target exceptions } */ +/* Verify that cleanups work with exception handling through signal frames + on alternate stack. */ + +#include +#include +#include +#include +#include + +static _Unwind_Reason_Code +force_unwind_stop (int version, _Unwind_Action actions, + _Unwind_Exception_Class exc_class, + struct _Unwind_Exception *exc_obj, + struct _Unwind_Context *context, + void *stop_parameter) +{ + if (actions & _UA_END_OF_STACK) + abort (); + return _URC_NO_REASON; +} + +static void force_unwind () +{ + struct _Unwind_Exception *exc = malloc (sizeof (*exc)); + memset (&exc->exception_class, 0, sizeof (exc->exception_class)); + exc->exception_cleanup = 0; + +#ifndef __USING_SJLJ_EXCEPTIONS__ + _Unwind_ForcedUnwind (exc, force_unwind_stop, 0); +#else + _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0); +#endif + + abort (); +} + +int count; +char *null; + +static void counter (void *p __attribute__((unused))) +{ + ++count; +} + +static void handler (void *p __attribute__((unused))) +{ + if (count != 2) + abort (); + exit (0); +} + +static int __attribute__((noinline)) fn5 () +{ + char dummy __attribute__((cleanup (counter))); + force_unwind (); + return 0; +} + +static void fn4 (int sig, siginfo_t *info, void *ctx) +{ + char dummy __attribute__((cleanup (counter))); + fn5 (); + null = NULL; +} + +static void fn3 () +{ + abort (); +} + +static int __attribute__((noinline)) fn2 () +{ + *null = 0; + fn3 (); + return 0; +} + +static int __attribute__((noinline)) fn1 () +{ + stack_t ss; + struct sigaction s; + + ss.ss_size = 4 * sysconf (_SC_PAGESIZE); + if (ss.ss_size < SIGSTKSZ) + ss.ss_size = SIGSTKSZ; + ss.ss_sp = malloc (ss.ss_size); + if (ss.ss_sp == NULL) + exit (1); + ss.ss_flags = 0; + if (sigaltstack (&ss, NULL) < 0) + exit (1); + + sigemptyset (&s.sa_mask); + s.sa_sigaction = fn4; + s.sa_flags = SA_RESETHAND | SA_ONSTACK; + sigaction (SIGSEGV, &s, NULL); + sigaction (SIGBUS, &s, NULL); + fn2 (); + return 0; +} + +static int __attribute__((noinline)) fn0 () +{ + char dummy __attribute__((cleanup (handler))); + fn1 (); + null = 0; + return 0; +} + +int main() +{ + fn0 (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-11.c b/SingleSource/Regression/C/gcc-dg/cleanup-11.c new file mode 100644 index 0000000000..6b499d4583 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-11.c @@ -0,0 +1,117 @@ +/* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* *-*-darwin[912]* *-*-uclinux* } } */ +/* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */ +/* { dg-require-effective-target exceptions } */ +/* Verify that cleanups work with exception handling through realtime signal + frames on alternate stack. */ + +#include +#include +#include +#include +#include + +static _Unwind_Reason_Code +force_unwind_stop (int version, _Unwind_Action actions, + _Unwind_Exception_Class exc_class, + struct _Unwind_Exception *exc_obj, + struct _Unwind_Context *context, + void *stop_parameter) +{ + if (actions & _UA_END_OF_STACK) + abort (); + return _URC_NO_REASON; +} + +static void force_unwind () +{ + struct _Unwind_Exception *exc = malloc (sizeof (*exc)); + memset (&exc->exception_class, 0, sizeof (exc->exception_class)); + exc->exception_cleanup = 0; + +#ifndef __USING_SJLJ_EXCEPTIONS__ + _Unwind_ForcedUnwind (exc, force_unwind_stop, 0); +#else + _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0); +#endif + + abort (); +} + +int count; +char *null; + +static void counter (void *p __attribute__((unused))) +{ + ++count; +} + +static void handler (void *p __attribute__((unused))) +{ + if (count != 2) + abort (); + exit (0); +} + +static int __attribute__((noinline)) fn5 () +{ + char dummy __attribute__((cleanup (counter))); + force_unwind (); + return 0; +} + +static void fn4 (int sig, siginfo_t *info, void *ctx) +{ + char dummy __attribute__((cleanup (counter))); + fn5 (); + null = NULL; +} + +static void fn3 () +{ + abort (); +} + +static int __attribute__((noinline)) fn2 () +{ + *null = 0; + fn3 (); + return 0; +} + +static int __attribute__((noinline)) fn1 () +{ + stack_t ss; + struct sigaction s; + + ss.ss_size = 4 * sysconf (_SC_PAGESIZE); + if (ss.ss_size < SIGSTKSZ) + ss.ss_size = SIGSTKSZ; + ss.ss_sp = malloc (ss.ss_size); + if (ss.ss_sp == NULL) + exit (1); + ss.ss_flags = 0; + if (sigaltstack (&ss, NULL) < 0) + exit (1); + + sigemptyset (&s.sa_mask); + s.sa_sigaction = fn4; + s.sa_flags = SA_RESETHAND | SA_ONSTACK | SA_SIGINFO; + sigaction (SIGSEGV, &s, NULL); + sigaction (SIGBUS, &s, NULL); + fn2 (); + return 0; +} + +static int __attribute__((noinline)) fn0 () +{ + char dummy __attribute__((cleanup (handler))); + fn1 (); + null = 0; + return 0; +} + +int main() +{ + fn0 (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-12.c b/SingleSource/Regression/C/gcc-dg/cleanup-12.c new file mode 100644 index 0000000000..2171e35de9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-12.c @@ -0,0 +1,71 @@ +/* PR middle-end/32758 */ +/* HP-UX libunwind.so doesn't provide _UA_END_OF_STACK */ +/* { dg-do run } */ +/* { dg-options "-O2 -fexceptions" } */ +/* { dg-skip-if "" { "ia64-*-hpux11.*" } } */ +/* { dg-skip-if "" { ! nonlocal_goto } } */ +/* { dg-require-effective-target exceptions } */ +/* Verify unwind info in presence of alloca. */ + +#include +#include +#include + +static _Unwind_Reason_Code +force_unwind_stop (int version, _Unwind_Action actions, + _Unwind_Exception_Class exc_class, + struct _Unwind_Exception *exc_obj, + struct _Unwind_Context *context, + void *stop_parameter) +{ + if (actions & _UA_END_OF_STACK) + abort (); + return _URC_NO_REASON; +} + +static void force_unwind (void) +{ + struct _Unwind_Exception *exc = malloc (sizeof (*exc)); + memset (&exc->exception_class, 0, sizeof (exc->exception_class)); + exc->exception_cleanup = 0; + +#ifndef __USING_SJLJ_EXCEPTIONS__ + _Unwind_ForcedUnwind (exc, force_unwind_stop, 0); +#else + _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0); +#endif + + abort (); +} + +__attribute__((noinline)) +void foo (void *x __attribute__((unused))) +{ + force_unwind (); +} + +__attribute__((noinline)) +int bar (unsigned int x) +{ + void *y = __builtin_alloca (x); + foo (y); + return 1; +} + +static void handler (void *p __attribute__((unused))) +{ + exit (0); +} + +__attribute__((noinline)) +static void doit () +{ + char dummy __attribute__((cleanup (handler))); + bar (1024); +} + +int main () +{ + doit (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-13.c b/SingleSource/Regression/C/gcc-dg/cleanup-13.c new file mode 100644 index 0000000000..86cfae09e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-13.c @@ -0,0 +1,338 @@ +/* This test is expected to FAIL to compile with + -fcompare-debug -fno-asynchronous-unwind-tables -fno-exceptions + because in that case, the __GCC_HAVE_DWARF2_CFI_ASM macro is only + defined during -g compilation and not defined with -g0. */ +/* HP-UX libunwind.so doesn't provide _UA_END_OF_STACK */ +/* { dg-do run } */ +/* { dg-options "-fexceptions" } */ +/* { dg-skip-if "" { "ia64-*-hpux11.*" } } */ +/* { dg-skip-if "" { ! nonlocal_goto } } */ +/* { dg-require-effective-target exceptions } */ +/* Verify DW_OP_* handling in the unwinder. */ + +#include +#include +#include + +/* #define OP_addr(x) 0x06, ... */ +#define OP_deref 0x06, +#define SLEB128(x) (x)&0x7f /* Assume here the value is -0x40 ... 0x3f. */ +#define ULEB128(x) (x)&0x7f /* Assume here the value is 0 ... 0x7f. */ +#define VAL1(x) (x)&0xff +#if defined (__BIG_ENDIAN__) +#define VAL2(x) ((x)>>8)&0xff,(x)&0xff +#define VAL4(x) ((x)>>24)&0xff,((x)>>16)&0xff,((x)>>8)&0xff,(x)&0xff +#define VAL8(x) ((x)>>56)&0xff,((x)>>48)&0xff,((x)>>40)&0xff,((x)>>32)&0xff,((x)>>24)&0xff,((x)>>16)&0xff,((x)>>8)&0xff,(x)&0xff +#elif defined(__LITTLE_ENDIAN__) || defined(__x86_64__) || defined(__i386__) +#define VAL2(x) (x)&0xff,((x)>>8)&0xff +#define VAL4(x) (x)&0xff,((x)>>8)&0xff,((x)>>16)&0xff,((x)>>24)&0xff +#define VAL8(x) (x)&0xff,((x)>>8)&0xff,((x)>>16)&0xff,((x)>>24)&0xff,((x)>>32)&0xff,((x)>>40)&0xff,((x)>>48)&0xff,((x)>>56)&0xff +#endif +#define OP_const1u(x) 0x08,VAL1(x), +#define OP_const1s(x) 0x09,VAL1(x), +#define OP_const2u(x) 0x0a,VAL2(x), +#define OP_const2s(x) 0x0b,VAL2(x), +#define OP_const4u(x) 0x0c,VAL4(x), +#define OP_const4s(x) 0x0d,VAL4(x), +#define OP_const8u(x) 0x0e,VAL8(x), +#define OP_const8s(x) 0x0f,VAL8(x), +#define OP_constu(x) 0x10,ULEB128(x), +#define OP_consts(x) 0x11,SLEB128(x), +#define OP_dup 0x12, +#define OP_drop 0x13, +#define OP_over 0x14, +#define OP_pick(x) 0x15,VAL1(x), +#define OP_swap 0x16, +#define OP_rot 0x17, +#define OP_xderef 0x18, +#define OP_abs 0x19, +#define OP_and 0x1a, +#define OP_div 0x1b, +#define OP_minus 0x1c, +#define OP_mod 0x1d, +#define OP_mul 0x1e, +#define OP_neg 0x1f, +#define OP_not 0x20, +#define OP_or 0x21, +#define OP_plus 0x22, +#define OP_plus_uconst(x) 0x23,ULEB128(x), +#define OP_shl 0x24, +#define OP_shr 0x25, +#define OP_shra 0x26, +#define OP_xor 0x27, +#define OP_bra(x) 0x28,VAL2(x), +#define OP_eq 0x29, +#define OP_ge 0x2a, +#define OP_gt 0x2b, +#define OP_le 0x2c, +#define OP_lt 0x2d, +#define OP_ne 0x2e, +#define OP_skip(x) 0x2f,VAL2(x), +#define OP_lit0 0x30, +#define OP_lit1 0x31, +#define OP_lit2 0x32, +#define OP_lit3 0x33, +#define OP_lit4 0x34, +#define OP_lit5 0x35, +#define OP_lit6 0x36, +#define OP_lit7 0x37, +#define OP_lit8 0x38, +#define OP_lit9 0x39, +#define OP_lit10 0x3a, +#define OP_lit11 0x3b, +#define OP_lit12 0x3c, +#define OP_lit13 0x3d, +#define OP_lit14 0x3e, +#define OP_lit15 0x3f, +#define OP_lit16 0x40, +#define OP_lit17 0x41, +#define OP_lit18 0x42, +#define OP_lit19 0x43, +#define OP_lit20 0x44, +#define OP_lit21 0x45, +#define OP_lit22 0x46, +#define OP_lit23 0x47, +#define OP_lit24 0x48, +#define OP_lit25 0x49, +#define OP_lit26 0x4a, +#define OP_lit27 0x4b, +#define OP_lit28 0x4c, +#define OP_lit29 0x4d, +#define OP_lit30 0x4e, +#define OP_lit31 0x4f, +#define OP_reg0 0x50, +#define OP_reg1 0x51, +#define OP_reg2 0x52, +#define OP_reg3 0x53, +#define OP_reg4 0x54, +#define OP_reg5 0x55, +#define OP_reg6 0x56, +#define OP_reg7 0x57, +#define OP_reg8 0x58, +#define OP_reg9 0x59, +#define OP_reg10 0x5a, +#define OP_reg11 0x5b, +#define OP_reg12 0x5c, +#define OP_reg13 0x5d, +#define OP_reg14 0x5e, +#define OP_reg15 0x5f, +#define OP_reg16 0x60, +#define OP_reg17 0x61, +#define OP_reg18 0x62, +#define OP_reg19 0x63, +#define OP_reg20 0x64, +#define OP_reg21 0x65, +#define OP_reg22 0x66, +#define OP_reg23 0x67, +#define OP_reg24 0x68, +#define OP_reg25 0x69, +#define OP_reg26 0x6a, +#define OP_reg27 0x6b, +#define OP_reg28 0x6c, +#define OP_reg29 0x6d, +#define OP_reg30 0x6e, +#define OP_reg31 0x6f, +#define OP_breg0(x) 0x70,SLEB128(x), +#define OP_breg1(x) 0x71,SLEB128(x), +#define OP_breg2(x) 0x72,SLEB128(x), +#define OP_breg3(x) 0x73,SLEB128(x), +#define OP_breg4(x) 0x74,SLEB128(x), +#define OP_breg5(x) 0x75,SLEB128(x), +#define OP_breg6(x) 0x76,SLEB128(x), +#define OP_breg7(x) 0x77,SLEB128(x), +#define OP_breg8(x) 0x78,SLEB128(x), +#define OP_breg9(x) 0x79,SLEB128(x), +#define OP_breg10(x) 0x7a,SLEB128(x), +#define OP_breg11(x) 0x7b,SLEB128(x), +#define OP_breg12(x) 0x7c,SLEB128(x), +#define OP_breg13(x) 0x7d,SLEB128(x), +#define OP_breg14(x) 0x7e,SLEB128(x), +#define OP_breg15(x) 0x7f,SLEB128(x), +#define OP_breg16(x) 0x80,SLEB128(x), +#define OP_breg17(x) 0x81,SLEB128(x), +#define OP_breg18(x) 0x82,SLEB128(x), +#define OP_breg19(x) 0x83,SLEB128(x), +#define OP_breg20(x) 0x84,SLEB128(x), +#define OP_breg21(x) 0x85,SLEB128(x), +#define OP_breg22(x) 0x86,SLEB128(x), +#define OP_breg23(x) 0x87,SLEB128(x), +#define OP_breg24(x) 0x88,SLEB128(x), +#define OP_breg25(x) 0x89,SLEB128(x), +#define OP_breg26(x) 0x8a,SLEB128(x), +#define OP_breg27(x) 0x8b,SLEB128(x), +#define OP_breg28(x) 0x8c,SLEB128(x), +#define OP_breg29(x) 0x8d,SLEB128(x), +#define OP_breg30(x) 0x8e,SLEB128(x), +#define OP_breg31(x) 0x8f,SLEB128(x), +#define OP_regx(x) 0x90,SLEB128(x), +#define OP_fbreg(x) 0x91,SLEB128(x), +#define OP_bregx(x,y) 0x92,ULEB128(x),SLEB128(y), +#define OP_piece(x) 0x93,ULEB128(x), +#define OP_deref_size(x) 0x94,VAL1(x), +#define OP_xderef_size(x) 0x95,VAL1(x), +#define OP_nop 0x96, +#define OP_nop_termination 0x96 +#define OP_push_object_address 0x97, +#define OP_call2(x) 0x98,VAL2(x), +#define OP_call4(x) 0x99,VAL4(x), +/* #define OP_call_ref(x) 0x9a,... */ +#define OP_form_tls_address(x) 0x9b, +#define OP_call_frame_cfa 0x9c, +#define OP_bit_piece(x) 0x9d,ULEB128(x), +/* #define OP_implicit_value(x...) 0x9e,... */ +#define OP_stack_value 0x9f, +#define OP_GNU_push_tls_address 0xe0, +/* #define OP_GNU_encoded_addr(x...) 0xf1, */ + +#define ASSERT_TOS_NON0 OP_bra(3) OP_skip(-3) +#define ASSERT_TOS_0 OP_lit0 OP_eq ASSERT_TOS_NON0 + +/* Initially there is CFA value on the stack, we want to + keep it there at the end. */ +#define CFI_PROGRAM \ +OP_lit0 OP_nop ASSERT_TOS_0 \ +OP_lit1 ASSERT_TOS_NON0 \ +OP_lit1 OP_const1u(1) OP_eq ASSERT_TOS_NON0 \ +OP_lit16 OP_const2u(16) OP_eq ASSERT_TOS_NON0 \ +OP_lit31 OP_const4u(31) OP_ne ASSERT_TOS_0 \ +OP_lit1 OP_neg OP_const1s(-1) OP_eq ASSERT_TOS_NON0 \ +OP_lit16 OP_neg OP_const2s(-16) OP_ne ASSERT_TOS_0 \ +OP_lit31 OP_const4s(-31) OP_neg OP_ne ASSERT_TOS_0 \ +OP_lit7 OP_dup OP_plus_uconst(2) OP_lit9 OP_eq ASSERT_TOS_NON0 \ + OP_lit7 OP_eq ASSERT_TOS_NON0 \ +OP_lit20 OP_lit1 OP_drop OP_lit20 OP_eq ASSERT_TOS_NON0 \ +OP_lit17 OP_lit19 OP_over OP_lit17 OP_eq ASSERT_TOS_NON0 \ + OP_lit19 OP_eq ASSERT_TOS_NON0 OP_lit17 OP_eq ASSERT_TOS_NON0 \ +OP_lit1 OP_lit2 OP_lit3 OP_lit4 OP_pick(2) OP_lit2 OP_eq ASSERT_TOS_NON0\ + OP_lit4 OP_eq ASSERT_TOS_NON0 OP_lit3 OP_eq ASSERT_TOS_NON0 \ + OP_pick(0) OP_lit2 OP_eq ASSERT_TOS_NON0 \ + OP_lit2 OP_eq ASSERT_TOS_NON0 OP_lit1 OP_eq ASSERT_TOS_NON0 \ +OP_lit6 OP_lit12 OP_swap OP_lit6 OP_eq ASSERT_TOS_NON0 \ + OP_lit12 OP_eq ASSERT_TOS_NON0 \ +OP_lit7 OP_lit8 OP_lit9 OP_rot OP_lit8 OP_eq ASSERT_TOS_NON0 \ + OP_lit7 OP_eq ASSERT_TOS_NON0 OP_lit9 OP_eq ASSERT_TOS_NON0 \ +OP_lit7 OP_abs OP_lit7 OP_eq ASSERT_TOS_NON0 \ +OP_const1s(-123) OP_abs OP_const1u(123) OP_eq ASSERT_TOS_NON0 \ +OP_lit3 OP_lit6 OP_and OP_lit2 OP_eq ASSERT_TOS_NON0 \ +OP_lit3 OP_lit6 OP_or OP_lit7 OP_eq ASSERT_TOS_NON0 \ +OP_lit17 OP_lit2 OP_minus OP_lit15 OP_eq ASSERT_TOS_NON0 \ +/* Divide is signed truncating toward zero. */ \ +OP_const1s(-6) OP_const1s(-2) OP_div OP_lit3 OP_eq ASSERT_TOS_NON0 \ +OP_const1s(-7) OP_const1s(3) OP_div OP_const1s(-2) \ + OP_eq ASSERT_TOS_NON0 \ +/* Modulo is unsigned. */ \ +OP_const1s(-6) OP_const1s(-4) OP_mod OP_const1s(-6) \ + OP_eq ASSERT_TOS_NON0 \ +OP_const1s(-6) OP_lit4 OP_mod OP_lit2 OP_eq ASSERT_TOS_NON0 \ +OP_lit6 OP_const1s(-4) OP_mod OP_lit6 OP_eq ASSERT_TOS_NON0 \ +/* Signed modulo can be implemented using "over over div mul minus". */\ +OP_const1s(-6) OP_const1s(-4) OP_over OP_over OP_div OP_mul OP_minus \ + OP_const1s(-2) OP_eq ASSERT_TOS_NON0 \ +OP_const1s(-7) OP_lit3 OP_over OP_over OP_div OP_mul OP_minus \ + OP_const1s(-1) OP_eq ASSERT_TOS_NON0 \ +OP_lit7 OP_const1s(-3) OP_over OP_over OP_div OP_mul OP_minus \ + OP_lit1 OP_eq ASSERT_TOS_NON0 \ +OP_lit16 OP_lit31 OP_plus_uconst(1) OP_mul OP_const2u(512) \ + OP_eq ASSERT_TOS_NON0 \ +OP_lit5 OP_not OP_lit31 OP_and OP_lit26 OP_eq ASSERT_TOS_NON0 \ +OP_lit12 OP_lit31 OP_plus OP_const1u(43) OP_eq ASSERT_TOS_NON0 \ +OP_const1s(-6) OP_lit2 OP_plus OP_const1s(-4) OP_eq ASSERT_TOS_NON0 \ +OP_const1s(-6) OP_plus_uconst(3) OP_const1s(-3) OP_eq ASSERT_TOS_NON0 \ +OP_lit16 OP_lit4 OP_shl OP_const2u(256) OP_eq ASSERT_TOS_NON0 \ +OP_lit16 OP_lit3 OP_shr OP_lit2 OP_eq ASSERT_TOS_NON0 \ +OP_const1s(-16) OP_lit3 OP_shra OP_const1s(-2) OP_eq ASSERT_TOS_NON0 \ +OP_lit3 OP_lit6 OP_xor OP_lit5 OP_eq ASSERT_TOS_NON0 \ +OP_lit3 OP_lit6 OP_le ASSERT_TOS_NON0 \ +OP_lit3 OP_lit3 OP_le ASSERT_TOS_NON0 \ +OP_lit6 OP_lit3 OP_le ASSERT_TOS_0 \ +OP_lit3 OP_lit6 OP_lt ASSERT_TOS_NON0 \ +OP_lit3 OP_lit3 OP_lt ASSERT_TOS_0 \ +OP_lit6 OP_lit3 OP_lt ASSERT_TOS_0 \ +OP_lit3 OP_lit6 OP_ge ASSERT_TOS_0 \ +OP_lit3 OP_lit3 OP_ge ASSERT_TOS_NON0 \ +OP_lit6 OP_lit3 OP_ge ASSERT_TOS_NON0 \ +OP_lit3 OP_lit6 OP_gt ASSERT_TOS_0 \ +OP_lit3 OP_lit3 OP_gt ASSERT_TOS_0 \ +OP_lit6 OP_lit3 OP_gt ASSERT_TOS_NON0 \ +OP_const1s(-6) OP_lit1 OP_shr OP_lit0 OP_gt ASSERT_TOS_NON0 \ +OP_const1s(-6) OP_lit1 OP_shra OP_lit0 OP_lt ASSERT_TOS_NON0 + +#define CFI_ESCAPE_VAL_2(VALUES...) #VALUES +#define CFI_ESCAPE_VAL_1(VALUES...) CFI_ESCAPE_VAL_2(VALUES) +#define CFI_ESCAPE_VAL(VALUES...) CFI_ESCAPE_VAL_1(VALUES) +#define CFI_ESCAPE do { } while (0) +#define CFI_ARCH_PROGRAM OP_nop_termination +#ifdef __GCC_HAVE_DWARF2_CFI_ASM +#if defined (__x86_64__) +#undef CFI_ESCAPE +#undef CFI_ARCH_PROGRAM +#define CFI_ARCH_PROGRAM CFI_PROGRAM OP_lit8 OP_minus OP_nop_termination +unsigned char cfi_arch_program[] = { CFI_ARCH_PROGRAM }; +extern char verify_it[sizeof (cfi_arch_program) - 0x80 < 0x3f80 ? 1 : -1]; +/* DW_CFA_expression %rip, uleb128(l2-l1), l1: program DW_OP_lit8 DW_OP_minus DW_OP_nop l2: */ +#define CFI_ESCAPE \ + asm volatile (".cfi_escape 0x10, 0x10, (%P0&0x7f)+0x80, %P0>>7, " \ + CFI_ESCAPE_VAL (CFI_ARCH_PROGRAM) \ + : : "i" (sizeof (cfi_arch_program))) +#elif defined (__i386__) +#undef CFI_ESCAPE +#undef CFI_ARCH_PROGRAM +#define CFI_ARCH_PROGRAM CFI_PROGRAM OP_lit4 OP_minus OP_nop_termination +unsigned char cfi_arch_program[] = { CFI_ARCH_PROGRAM }; +extern char verify_it[sizeof (cfi_arch_program) - 0x80 < 0x3f80 ? 1 : -1]; +/* DW_CFA_expression %eip, uleb128(l2-l1), l1: program DW_OP_lit4 DW_OP_minus DW_OP_nop l2: */ +#define CFI_ESCAPE \ + asm volatile (".cfi_escape 0x10, 8, (%P0&0x7f)+0x80, %P0>>7, " \ + CFI_ESCAPE_VAL (CFI_ARCH_PROGRAM) \ + : : "i" (sizeof (cfi_arch_program))) +#endif +#endif +static _Unwind_Reason_Code +force_unwind_stop (int version, _Unwind_Action actions, + _Unwind_Exception_Class exc_class, + struct _Unwind_Exception *exc_obj, + struct _Unwind_Context *context, + void *stop_parameter) +{ + if (actions & _UA_END_OF_STACK) + abort (); + return _URC_NO_REASON; +} + +static void force_unwind () +{ + struct _Unwind_Exception *exc = malloc (sizeof (*exc)); + memset (&exc->exception_class, 0, sizeof (exc->exception_class)); + exc->exception_cleanup = 0; + +#ifndef __USING_SJLJ_EXCEPTIONS__ + _Unwind_ForcedUnwind (exc, force_unwind_stop, 0); +#else + _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0); +#endif + + abort (); +} + +static void handler (void *p __attribute__((unused))) +{ + exit (0); +} + +__attribute__((noinline)) static void callme () +{ + CFI_ESCAPE; + force_unwind (); +} + +__attribute__((noinline)) static void doit () +{ + char dummy __attribute__((cleanup (handler))); + callme (); +} + +int main() +{ + doit (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-2.c b/SingleSource/Regression/C/gcc-dg/cleanup-2.c new file mode 100644 index 0000000000..2c798023cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-2.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "" } */ +/* Verify that cleanup works in the most basic of ways. */ + +extern void exit(int); +extern void abort(void); + +static void handler(void *p __attribute__((unused))) +{ + exit (0); +} + +static void doit(void) +{ + int x __attribute__((cleanup (handler))); +} + +int main() +{ + doit (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-3.c b/SingleSource/Regression/C/gcc-dg/cleanup-3.c new file mode 100644 index 0000000000..b5b01fd590 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-3.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ +/* { dg-options "" } */ +/* Verify that the cleanup handler receives the proper contents + of the variable. */ + +extern void exit(int); +extern void abort(void); + +static int expected; + +static void +handler(int *p) +{ + if (*p != expected) + abort (); +} + +static void __attribute__((noinline)) +bar(void) +{ +} + +static void doit(int x, int y) +{ + int r __attribute__((cleanup (handler))); + if (x < y) + { + r = 0; + return; + } + + bar(); + r = x + y; +} + +int main() +{ + expected = 0; + doit (1, 2); + + expected = 3; + doit (2, 1); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-4.c b/SingleSource/Regression/C/gcc-dg/cleanup-4.c new file mode 100644 index 0000000000..a5487553d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-4.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-options "" } */ +/* Verify cleanup execution on non-trivial exit from a block. */ + +extern void exit(int); +extern void abort(void); + +static int counter; + +static void +handler(int *p) +{ + counter += *p; +} + +static void __attribute__((noinline)) +bar(void) +{ +} + +static void doit(int n, int n2) +{ + int i; + for (i = 0; i < n; ++i) + { + int dummy __attribute__((cleanup (handler))) = i; + if (i == n2) + break; + bar(); + } +} + +int main() +{ + doit (10, 6); + if (counter != 0 + 1 + 2 + 3 + 4 + 5 + 6) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-5.c b/SingleSource/Regression/C/gcc-dg/cleanup-5.c new file mode 100644 index 0000000000..9ed2a7c95f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-5.c @@ -0,0 +1,55 @@ +/* HP-UX libunwind.so doesn't provide _UA_END_OF_STACK */ +/* { dg-do run } */ +/* { dg-options "-fexceptions" } */ +/* { dg-skip-if "" { "ia64-*-hpux11.*" } } */ +/* { dg-skip-if "" { ! nonlocal_goto } } */ +/* { dg-require-effective-target exceptions } */ +/* Verify that cleanups work with exception handling. */ + +#include +#include +#include + +static _Unwind_Reason_Code +force_unwind_stop (int version, _Unwind_Action actions, + _Unwind_Exception_Class exc_class, + struct _Unwind_Exception *exc_obj, + struct _Unwind_Context *context, + void *stop_parameter) +{ + if (actions & _UA_END_OF_STACK) + abort (); + return _URC_NO_REASON; +} + +static void force_unwind () +{ + struct _Unwind_Exception *exc = malloc (sizeof (*exc)); + memset (&exc->exception_class, 0, sizeof (exc->exception_class)); + exc->exception_cleanup = 0; + +#ifndef __USING_SJLJ_EXCEPTIONS__ + _Unwind_ForcedUnwind (exc, force_unwind_stop, 0); +#else + _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0); +#endif + + abort (); +} + +static void handler (void *p __attribute__((unused))) +{ + exit (0); +} + +static void doit () +{ + char dummy __attribute__((cleanup (handler))); + force_unwind (); +} + +int main() +{ + doit (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-6.c b/SingleSource/Regression/C/gcc-dg/cleanup-6.c new file mode 100644 index 0000000000..4e3d53893a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-6.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* Verify that a cleanup marked "inline" gets inlined. */ + +static inline void xyzzy(void *p __attribute__((unused))) +{ +} + +void doit(void) +{ + int x __attribute__((cleanup (xyzzy))); +} + +/* { dg-final { scan-assembler-not "xyzzy" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-7.c b/SingleSource/Regression/C/gcc-dg/cleanup-7.c new file mode 100644 index 0000000000..eae3d52980 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-7.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "" } */ +/* Verify that the search for function happens in the proper scope. */ + +extern void exit(int); +extern void abort(void); + +int main() +{ + auto void xyzzy(void *p __attribute__((unused))) + { + exit (0); + } + + auto void doit () + { + int x __attribute__((cleanup (xyzzy))); + } + + doit (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-8.c b/SingleSource/Regression/C/gcc-dg/cleanup-8.c new file mode 100644 index 0000000000..87f4186561 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-8.c @@ -0,0 +1,100 @@ +/* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* *-*-darwin[912]* *-*-uclinux* } } */ +/* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */ +/* { dg-require-effective-target exceptions } */ +/* Verify that cleanups work with exception handling through signal + frames. */ + +#include +#include +#include +#include + +static _Unwind_Reason_Code +force_unwind_stop (int version, _Unwind_Action actions, + _Unwind_Exception_Class exc_class, + struct _Unwind_Exception *exc_obj, + struct _Unwind_Context *context, + void *stop_parameter) +{ + if (actions & _UA_END_OF_STACK) + abort (); + return _URC_NO_REASON; +} + +static void force_unwind () +{ + struct _Unwind_Exception *exc = malloc (sizeof (*exc)); + memset (&exc->exception_class, 0, sizeof (exc->exception_class)); + exc->exception_cleanup = 0; + +#ifndef __USING_SJLJ_EXCEPTIONS__ + _Unwind_ForcedUnwind (exc, force_unwind_stop, 0); +#else + _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0); +#endif + + abort (); +} + +int count; +char *null; + +static void counter (void *p __attribute__((unused))) +{ + ++count; +} + +static void handler (void *p __attribute__((unused))) +{ + if (count != 2) + abort (); + exit (0); +} + +static int __attribute__((noinline)) fn5 () +{ + char dummy __attribute__((cleanup (counter))); + force_unwind (); + return 0; +} + +static void fn4 (int sig) +{ + char dummy __attribute__((cleanup (counter))); + fn5 (); + null = NULL; +} + +static void fn3 () +{ + abort (); +} + +static int __attribute__((noinline)) fn2 () +{ + *null = 0; + fn3 (); + return 0; +} + +static int __attribute__((noinline)) fn1 () +{ + signal (SIGSEGV, fn4); + signal (SIGBUS, fn4); + fn2 (); + return 0; +} + +static int __attribute__((noinline)) fn0 () +{ + char dummy __attribute__((cleanup (handler))); + fn1 (); + null = 0; + return 0; +} + +int main() +{ + fn0 (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cleanup-9.c b/SingleSource/Regression/C/gcc-dg/cleanup-9.c new file mode 100644 index 0000000000..d34ce12224 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cleanup-9.c @@ -0,0 +1,104 @@ +/* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* *-*-darwin[912]* *-*-uclinux* } } */ +/* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */ +/* { dg-require-effective-target exceptions } */ +/* Verify that cleanups work with exception handling through realtime + signal frames. */ + +#include +#include +#include +#include + +static _Unwind_Reason_Code +force_unwind_stop (int version, _Unwind_Action actions, + _Unwind_Exception_Class exc_class, + struct _Unwind_Exception *exc_obj, + struct _Unwind_Context *context, + void *stop_parameter) +{ + if (actions & _UA_END_OF_STACK) + abort (); + return _URC_NO_REASON; +} + +static void force_unwind () +{ + struct _Unwind_Exception *exc = malloc (sizeof (*exc)); + memset (&exc->exception_class, 0, sizeof (exc->exception_class)); + exc->exception_cleanup = 0; + +#ifndef __USING_SJLJ_EXCEPTIONS__ + _Unwind_ForcedUnwind (exc, force_unwind_stop, 0); +#else + _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0); +#endif + + abort (); +} + +int count; +char *null; + +static void counter (void *p __attribute__((unused))) +{ + ++count; +} + +static void handler (void *p __attribute__((unused))) +{ + if (count != 2) + abort (); + exit (0); +} + +static int __attribute__((noinline)) fn5 () +{ + char dummy __attribute__((cleanup (counter))); + force_unwind (); + return 0; +} + +static void fn4 (int sig, siginfo_t *info, void *ctx) +{ + char dummy __attribute__((cleanup (counter))); + fn5 (); + null = NULL; +} + +static void fn3 () +{ + abort (); +} + +static int __attribute__((noinline)) fn2 () +{ + *null = 0; + fn3 (); + return 0; +} + +static int __attribute__((noinline)) fn1 () +{ + struct sigaction s; + sigemptyset (&s.sa_mask); + s.sa_sigaction = fn4; + s.sa_flags = SA_RESETHAND | SA_SIGINFO; + sigaction (SIGSEGV, &s, NULL); + sigaction (SIGBUS, &s, NULL); + fn2 (); + return 0; +} + +static int __attribute__((noinline)) fn0 () +{ + char dummy __attribute__((cleanup (handler))); + fn1 (); + null = 0; + return 0; +} + +int main() +{ + fn0 (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/cmp-mem-const-1.c b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-1.c new file mode 100644 index 0000000000..0b0e733135 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target { lp64 } } } */ +/* { dg-options "-O2 -fdump-rtl-combine-details" } */ +/* { dg-final { scan-rtl-dump "narrow comparison from mode .I to QI" "combine" } } */ + +typedef __UINT64_TYPE__ uint64_t; + +int +le_1byte_a (uint64_t *x) +{ + return *x <= 0x3fffffffffffffff; +} + +int +le_1byte_b (uint64_t *x) +{ + return *x < 0x4000000000000000; +} diff --git a/SingleSource/Regression/C/gcc-dg/cmp-mem-const-2.c b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-2.c new file mode 100644 index 0000000000..8022137a8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target { lp64 } } } */ +/* { dg-options "-O2 -fdump-rtl-combine-details" } */ +/* { dg-final { scan-rtl-dump "narrow comparison from mode .I to QI" "combine" } } */ + +typedef __UINT64_TYPE__ uint64_t; + +int +ge_1byte_a (uint64_t *x) +{ + return *x > 0x3fffffffffffffff; +} + +int +ge_1byte_b (uint64_t *x) +{ + return *x >= 0x4000000000000000; +} diff --git a/SingleSource/Regression/C/gcc-dg/cmp-mem-const-3.c b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-3.c new file mode 100644 index 0000000000..c60ecdb402 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-3.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target { lp64 && { ! sparc*-*-* } } } } */ +/* Excluding sparc since there we do not end up with a comparison of memory and + a constant which means that the optimization is not applicable. */ +/* { dg-options "-O2 -fdump-rtl-combine-details" } */ +/* { dg-final { scan-rtl-dump "narrow comparison from mode .I to HI" "combine" } } */ + +typedef __UINT64_TYPE__ uint64_t; + +int +le_2bytes_a (uint64_t *x) +{ + return *x <= 0x3ffdffffffffffff; +} + +int +le_2bytes_b (uint64_t *x) +{ + return *x < 0x3ffe000000000000; +} diff --git a/SingleSource/Regression/C/gcc-dg/cmp-mem-const-4.c b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-4.c new file mode 100644 index 0000000000..7aa403d76d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-4.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target { lp64 && { ! sparc*-*-* } } } } */ +/* Excluding sparc since there we do not end up with a comparison of memory and + a constant which means that the optimization is not applicable. */ +/* { dg-options "-O2 -fdump-rtl-combine-details" } */ +/* { dg-final { scan-rtl-dump "narrow comparison from mode .I to HI" "combine" } } */ + +typedef __UINT64_TYPE__ uint64_t; + +int +ge_2bytes_a (uint64_t *x) +{ + return *x > 0x400cffffffffffff; +} + +int +ge_2bytes_b (uint64_t *x) +{ + return *x >= 0x400d000000000000; +} diff --git a/SingleSource/Regression/C/gcc-dg/cmp-mem-const-5.c b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-5.c new file mode 100644 index 0000000000..4316dcb560 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target { lp64 && { ! sparc*-*-* } } } } */ +/* Excluding sparc since there a prior optimization already reduced the + constant, i.e., nothing left for us. */ +/* { dg-options "-O2 -fdump-rtl-combine-details" } */ +/* { dg-final { scan-rtl-dump "narrow comparison from mode .I to SI" "combine" } } */ + +typedef __UINT64_TYPE__ uint64_t; + +int +le_4bytes_a (uint64_t *x) +{ + return *x <= 0x3ffffdffffffffff; +} + +int +le_4bytes_b (uint64_t *x) +{ + return *x < 0x3ffffe0000000000; +} diff --git a/SingleSource/Regression/C/gcc-dg/cmp-mem-const-6.c b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-6.c new file mode 100644 index 0000000000..d9046af79e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cmp-mem-const-6.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target { lp64 && { ! sparc*-*-* } } } } */ +/* Excluding sparc since there a prior optimization already reduced the + constant, i.e., nothing left for us. */ +/* { dg-options "-O2 -fdump-rtl-combine-details" } */ +/* { dg-final { scan-rtl-dump "narrow comparison from mode .I to SI" "combine" } } */ + +typedef __UINT64_TYPE__ uint64_t; + +int +ge_4bytes_a (uint64_t *x) +{ + return *x > 0x4000cfffffffffff; +} + +int +ge_4bytes_b (uint64_t *x) +{ + return *x >= 0x4000d00000000000; +} diff --git a/SingleSource/Regression/C/gcc-dg/cold-1.c b/SingleSource/Regression/C/gcc-dg/cold-1.c new file mode 100644 index 0000000000..ba1cd3a4e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cold-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile { target nonpic } } */ +/* { dg-options "-O2 -Wsuggest-attribute=cold" } */ + +extern void abort (void); +extern void do_something_interesting_and_never_return (); + +int +foo1(int a) +{ /* { dg-warning "cold" "detect cold candidate" { target *-*-* } ".-1" } */ + if (a) + abort (); + else + abort (); +} + +int +foo2(int a) +{ + if (a) + do_something_interesting_and_never_return (); + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/combine-clobber.c b/SingleSource/Regression/C/gcc-dg/combine-clobber.c new file mode 100644 index 0000000000..09e800067b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/combine-clobber.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fdump-rtl-combine-all" } */ + +/* This testcase checks if combine tries to combine sequences where the last + insn has a clobber of a reg, and a previous insn sets that reg. + + In this case, we have three insns + + (set flags (compare a b)) + (set tmp (eq flags 0)) + (parallel [(set dst (neg tmp)) + (clobber flags)]) + + Previously, combine would not try the three-insn combination because of + the set and clobber of flags. Now it does. Test that. */ + + +int f(int a, int b) { return -(a == b); } + +/* This regexp works for reg parameters as well as mem parameters. */ +/* { dg-final { scan-rtl-dump {neg:SI[^:]*eq:SI[^:]*:SI} "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/combine-subregs.c b/SingleSource/Regression/C/gcc-dg/combine-subregs.c new file mode 100644 index 0000000000..ccace233cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/combine-subregs.c @@ -0,0 +1,36 @@ +/* { dg-do run { target { stdint_types } } } */ +/* { dg-options "-O2" } */ + +#include +#include + +void __attribute__ ((noinline)) +foo (uint64_t state, uint32_t last) +{ + if (state == last) abort (); +} + +/* This function may do a bad comparision by trying to + use SUBREGS during the compare on machines where comparing + two registers always compares the entire register regardless + of mode. */ + +int __attribute__ ((noinline)) +compare (uint64_t state, uint32_t *last, uint8_t buf) +{ + if (*last == ((state | buf) & 0xFFFFFFFF)) { + foo (state, *last); + return 0; + } + return 1; +} + +int +main(int argc, char **argv) { + uint64_t state = 0xF00000100U; + uint32_t last = 0x101U; + int ret = compare(state, &last, 0x01); + if (ret != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/combine_ashiftrt_1.c b/SingleSource/Regression/C/gcc-dg/combine_ashiftrt_1.c new file mode 100644 index 0000000000..f4e53c83d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/combine_ashiftrt_1.c @@ -0,0 +1,20 @@ +/* Target architectures which have been found to produce the expected RTL + (neg:DI (ge:DI ...)) when compiling for LP64. */ +/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* ia64-*-* powerpc*-*-* sparc*-*-* x86_64-*-* } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fdump-rtl-combine-all" } */ + +typedef long long int int64_t; + +int64_t +foo (int64_t a) +{ + return (~a) >> 63; +} + +/* The combine phase will try to combine not & ashiftrt, and + combine_simplify_rtx should transform (ashiftrt (not x) 63) + to (not (ashiftrt x 63)) and then to (neg (ge x 0)). We look for + the *attempt* to match this RTL pattern, regardless of whether an + actual insn may be found on the platform. */ +/* { dg-final { scan-rtl-dump "\\(neg:DI \\(ge:DI" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/combine_ashiftrt_2.c b/SingleSource/Regression/C/gcc-dg/combine_ashiftrt_2.c new file mode 100644 index 0000000000..b499544658 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/combine_ashiftrt_2.c @@ -0,0 +1,20 @@ +/* Target architectures where RTL has been found to produce the expected + (neg:SI (ge:SI ...)) when compiling for ILP32. */ +/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* microblaze-*-* mips*-*-* powerpc*-*-* sparc*-*-* x86_64-*-* } } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O2 -fdump-rtl-combine-all" } */ + +typedef long int32_t; + +int32_t +foo (int32_t a) +{ + return (~a) >> 31; +} + +/* The combine phase will try to combine not & ashiftrt, and + combine_simplify_rtx should transform (ashiftrt (not x) 31) + to (not (ashiftrt x 63)) and then to (neg (ge x 0)). We look for + the *attempt* to match this RTL pattern, regardless of whether an + actual insn may be found on the platform. */ +/* { dg-final { scan-rtl-dump "\\(neg:SI \\(ge:SI" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/comp-goto-1.c b/SingleSource/Regression/C/gcc-dg/comp-goto-1.c new file mode 100644 index 0000000000..39baae534d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/comp-goto-1.c @@ -0,0 +1,15 @@ +/* Test diagnostics for addresses of labels and computed gotos. Test + with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-require-effective-target indirect_jumps } */ +/* { dg-require-effective-target label_values } */ + +void +f (void) +{ + void *p = &&a; + goto *p; + a: ; +} diff --git a/SingleSource/Regression/C/gcc-dg/comp-goto-2.c b/SingleSource/Regression/C/gcc-dg/comp-goto-2.c new file mode 100644 index 0000000000..54c2111927 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/comp-goto-2.c @@ -0,0 +1,15 @@ +/* Test diagnostics for addresses of labels and computed gotos. Test + with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ +/* { dg-require-effective-target indirect_jumps } */ +/* { dg-require-effective-target label_values } */ + +void +f (void) +{ + void *p = &&a; /* { dg-warning "taking the address of a label is non-standard" } */ + goto *p; /* { dg-warning "ISO C forbids 'goto \\*expr;'" } */ + a: ; +} diff --git a/SingleSource/Regression/C/gcc-dg/comp-goto-3.c b/SingleSource/Regression/C/gcc-dg/comp-goto-3.c new file mode 100644 index 0000000000..5a3b4d2cad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/comp-goto-3.c @@ -0,0 +1,13 @@ +/* Test diagnostics for addresses of labels and computed gotos. Test + with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +void +f (void) +{ + void *p = &&a; /* { dg-error "taking the address of a label is non-standard" } */ + goto *p; /* { dg-error "ISO C forbids 'goto \\*expr;'" } */ + a: ; +} diff --git a/SingleSource/Regression/C/gcc-dg/comp-goto-4.c b/SingleSource/Regression/C/gcc-dg/comp-goto-4.c new file mode 100644 index 0000000000..51a6a86770 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/comp-goto-4.c @@ -0,0 +1,21 @@ +/* PR middle-end/79537 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-require-effective-target indirect_jumps } */ +/* { dg-require-effective-target label_values } */ + +void +f (void) +{ +L: + *&&L; +} + +void +f2 (void) +{ + void *p; +L: + p = &&L; + *p; /* { dg-warning "dereferencing 'void \\*' pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/comp-goto-5.c b/SingleSource/Regression/C/gcc-dg/comp-goto-5.c new file mode 100644 index 0000000000..d487729a5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/comp-goto-5.c @@ -0,0 +1,11 @@ +/* PR c/32122 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum {a=1}; +void foo() +{ + goto * + a; /* { dg-error "computed goto must be pointer type" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/comp-goto-6.c b/SingleSource/Regression/C/gcc-dg/comp-goto-6.c new file mode 100644 index 0000000000..497f6cd76c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/comp-goto-6.c @@ -0,0 +1,6 @@ +/* PR c/32122 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +void foo(void *a) { goto *10000000; } /* { dg-error "computed goto must be pointer type" } */ +void foo1(void *a) { goto *a; } + diff --git a/SingleSource/Regression/C/gcc-dg/comp-return-1.c b/SingleSource/Regression/C/gcc-dg/comp-return-1.c new file mode 100644 index 0000000000..82c398355d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/comp-return-1.c @@ -0,0 +1,31 @@ +/* When merging a nonprototype definition of a function with a prior + prototype declaration, the composite type of the return types must + be formed rather than just copying the function type. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ + +typedef int a[]; +typedef int a5[5]; +typedef int a10[10]; + +a *f1 (); +a5 *f1 () { return 0; } + +a *f2 (void); +a5 *f2 () { return 0; } + +a *f3 (); +a5 *f3 (void) { return 0; } + +a *f4 (void); +a5 *f4 (void) { return 0; } + +void +g (void) +{ + a10 *x; + x = f1 (); /* { dg-error "incompatible" "f1" } */ + x = f2 (); /* { dg-error "incompatible" "f2" } */ + x = f3 (); /* { dg-error "incompatible" "f3" } */ + x = f4 (); /* { dg-error "incompatible" "f4" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/compare1.c b/SingleSource/Regression/C/gcc-dg/compare1.c new file mode 100644 index 0000000000..ebab8c2cbf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare1.c @@ -0,0 +1,41 @@ +/* Test for a bogus warning on comparison between signed and unsigned. + This was inspired by code in gcc. This testcase is identical to + compare9.c except that we use -fno-short-enums here and expect a + warning from case 4. */ + +/* { dg-do compile } */ +/* { dg-options "-fno-short-enums -Wsign-compare" } */ + +int tf = 1; + +/* This enumeration has an explicit negative value and is therefore signed. */ +enum mm1 +{ + VOID, SI, DI, MAX = -1 +}; + +/* This enumeration fits entirely in a signed int, but is unsigned anyway. */ +enum mm2 +{ + VOID2, SI2, DI2, MAX2 +}; + +int f(enum mm1 x) +{ + return x == (tf?DI:SI); /* { dg-bogus "changes signedness" "case 1" } */ +} + +int g(enum mm1 x) +{ + return x == (tf?DI:-1); /* { dg-bogus "changes signedness" "case 2" } */ +} + +int h(enum mm2 x) +{ + return x == (tf?DI2:SI2); /* { dg-bogus "changes signedness" "case 3" } */ +} + +int i(enum mm2 x) +{ + return x == (tf?DI2:-1); /* { dg-warning "different signedness" "case 4" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/compare10.c b/SingleSource/Regression/C/gcc-dg/compare10.c new file mode 100644 index 0000000000..3b8af28bf1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare10.c @@ -0,0 +1,16 @@ +/* Test for bogus -Wsign-compare warnings that appeared when not + folding operands before warning. */ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +int +test_compare (int a, unsigned b) +{ + return (b > 8 * (a ? 4 : 8)); +} + +unsigned int +test_conditional (int a, unsigned b, int c) +{ + return (c ? b : 8 * (a ? 4 : 8)); +} diff --git a/SingleSource/Regression/C/gcc-dg/compare2.c b/SingleSource/Regression/C/gcc-dg/compare2.c new file mode 100644 index 0000000000..f742e95f60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare2.c @@ -0,0 +1,58 @@ +/* Test for a bogus warning on comparison between signed and unsigned. + This was inspired by code in gcc. */ + +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +int tf = 1; + +void f(int x, unsigned int y) +{ + /* ?: branches are constants. */ + x > (tf?64:128); /* { dg-bogus "changes signedness" "case 1" } */ + y > (tf?64:128); /* { dg-bogus "changes signedness" "case 2" } */ + + /* ?: branches are (recursively) constants. */ + x > (tf?64:(tf?128:256)); /* { dg-bogus "changes signedness" "case 3" } */ + y > (tf?64:(tf?128:256)); /* { dg-bogus "changes signedness" "case 4" } */ + + /* ?: branches are signed constants. */ + x > (tf?64:-1); /* { dg-bogus "changes signedness" "case 5" } */ + y > (tf?64:-1); /* { dg-warning "different signedness" "case 6" } */ + + /* ?: branches are (recursively) signed constants. */ + x > (tf?64:(tf?128:-1)); /* { dg-bogus "changes signedness" "case 7" } */ + y > (tf?64:(tf?128:-1)); /* { dg-warning "different signedness" "case 8" } */ + + /* Statement expression. */ + x > ({tf; 64;}); /* { dg-bogus "changes signedness" "case 9" } */ + y > ({tf; 64;}); /* { dg-bogus "changes signedness" "case 10" } */ + + /* Statement expression with recursive ?: . */ + x > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "changes signedness" "case 11" } */ + y > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "changes signedness" "case 12" } */ + + /* Statement expression with signed ?:. */ + x > ({tf; tf?64:-1;}); /* { dg-bogus "changes signedness" "case 13" } */ + y > ({tf; tf?64:-1;}); /* { dg-warning "different signedness" "case 14" } */ + + /* Statement expression with recursive signed ?:. */ + x > ({tf; tf?64:(tf?128:-1);}); /* { dg-bogus "changes signedness" "case 15" } */ + y > ({tf; tf?64:(tf?128:-1);}); /* { dg-warning "different signedness" "case 16" } */ + + /* ?: branches are constants. */ + tf ? x : (tf?64:32); /* { dg-bogus "changes signedness" "case 17" } */ + tf ? y : (tf?64:32); /* { dg-bogus "changes signedness" "case 18" } */ + + /* ?: branches are signed constants. */ + tf ? x : (tf?64:-1); /* { dg-bogus "changes signedness" "case 19" } */ + tf ? y : (tf?64:-1); /* { dg-warning "changes signedness" "case 20" } */ + + /* ?: branches are (recursively) constants. */ + tf ? x : (tf?64:(tf?128:256)); /* { dg-bogus "changes signedness" "case 21" } */ + tf ? y : (tf?64:(tf?128:256)); /* { dg-bogus "changes signedness" "case 22" } */ + + /* ?: branches are (recursively) signed constants. */ + tf ? x : (tf?64:(tf?128:-1)); /* { dg-bogus "changes signedness" "case 23" } */ + tf ? y : (tf?64:(tf?128:-1)); /* { dg-warning "changes signedness" "case 24" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/compare3.c b/SingleSource/Regression/C/gcc-dg/compare3.c new file mode 100644 index 0000000000..836231fb87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare3.c @@ -0,0 +1,59 @@ +/* Test for a bogus warning on comparison between signed and unsigned. + This was inspired by code in gcc. */ + +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +int tf = 1; + +void f(int x, unsigned int y) +{ + /* Test comparing conditional expressions containing truth values. + This can occur explicitly, or e.g. when (foo?2:(bar?1:0)) is + optimized into (foo?2:(bar!=0)). */ + x > (tf?64:(tf!=x)); /* { dg-bogus "changes signedness" "case 1" } */ + y > (tf?64:(tf!=x)); /* { dg-bogus "changes signedness" "case 2" } */ + x > (tf?(tf!=x):64); /* { dg-bogus "changes signedness" "case 3" } */ + y > (tf?(tf!=x):64); /* { dg-bogus "changes signedness" "case 4" } */ + + x > (tf?64:(tf==x)); /* { dg-bogus "changes signedness" "case 5" } */ + y > (tf?64:(tf==x)); /* { dg-bogus "changes signedness" "case 6" } */ + x > (tf?(tf==x):64); /* { dg-bogus "changes signedness" "case 7" } */ + y > (tf?(tf==x):64); /* { dg-bogus "changes signedness" "case 8" } */ + + x > (tf?64:(tf>x)); /* { dg-bogus "changes signedness" "case 9" } */ + y > (tf?64:(tf>x)); /* { dg-bogus "changes signedness" "case 10" } */ + x > (tf?(tf>x):64); /* { dg-bogus "changes signedness" "case 11" } */ + y > (tf?(tf>x):64); /* { dg-bogus "changes signedness" "case 12" } */ + + x < (tf?64:(tf (tf?64:(tf>=x)); /* { dg-bogus "changes signedness" "case 17" } */ + y > (tf?64:(tf>=x)); /* { dg-bogus "changes signedness" "case 18" } */ + x > (tf?(tf>=x):64); /* { dg-bogus "changes signedness" "case 19" } */ + y > (tf?(tf>=x):64); /* { dg-bogus "changes signedness" "case 20" } */ + + x > (tf?64:(tf<=x)); /* { dg-bogus "changes signedness" "case 21" } */ + y > (tf?64:(tf<=x)); /* { dg-bogus "changes signedness" "case 22" } */ + x > (tf?(tf<=x):64); /* { dg-bogus "changes signedness" "case 23" } */ + y > (tf?(tf<=x):64); /* { dg-bogus "changes signedness" "case 24" } */ + + x > (tf?64:(tf&&x)); /* { dg-bogus "changes signedness" "case 25" } */ + y > (tf?64:(tf&&x)); /* { dg-bogus "changes signedness" "case 26" } */ + x > (tf?(tf&&x):64); /* { dg-bogus "changes signedness" "case 27" } */ + y > (tf?(tf&&x):64); /* { dg-bogus "changes signedness" "case 28" } */ + + x > (tf?64:(tf||x)); /* { dg-bogus "changes signedness" "case 29" } */ + y > (tf?64:(tf||x)); /* { dg-bogus "changes signedness" "case 30" } */ + x > (tf?(tf||x):64); /* { dg-bogus "changes signedness" "case 31" } */ + y > (tf?(tf||x):64); /* { dg-bogus "changes signedness" "case 32" } */ + + x > (tf?64:(!tf)); /* { dg-bogus "changes signedness" "case 33" } */ + y > (tf?64:(!tf)); /* { dg-bogus "changes signedness" "case 34" } */ + x > (tf?(!tf):64); /* { dg-bogus "changes signedness" "case 35" } */ + y > (tf?(!tf):64); /* { dg-bogus "changes signedness" "case 36" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/compare4.c b/SingleSource/Regression/C/gcc-dg/compare4.c new file mode 100644 index 0000000000..299d488edf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare4.c @@ -0,0 +1,49 @@ +/* Test for a bogus warning on comparison between signed and unsigned. + Origin: Kaveh R. Ghazi 5/13/2001. */ + +/* { dg-do compile } */ +/* { dg-options "-fshow-column -Wsign-compare -fstrict-overflow" } */ + +extern void bar(void); + +int foo(int x, int y, unsigned u) +{ + /* A COMPOUND_EXPR is non-negative if the last element is known to + be non-negative. */ + if (u < (bar(), -1)) /*{ dg-warning "9:different signedness" "COMPOUND_EXPR" }*/ + return x; + if (u < (bar(), 10)) + return x; + if ((bar(), 10) < u) + return x; + if (u < (x ? (bar(),bar(),bar(),bar(),x==y) : 10)) + return x; + if ((x ? 10 : (bar(),bar(),bar(),bar(),x==y)) < u) + return x; + + /* Test an ABS_EXPR, which is by definition non-negative when + -fstrict-overflow is used. */ + if (u < __builtin_abs(x)) + return x; + if (__builtin_abs(x) < u) + return x; + if (u < (x ? __builtin_abs(x) : 10)) + return x; + if ((x ? 10: __builtin_abs(x)) < u) + return x; + + /* A MODIFY_EXPR is non-negative if the new value is known to be + non-negative. */ + if (u < (x = -1)) /* { dg-warning "9:different signedness" "MODIFY_EXPR" } */ + return x; + if (u < (x = 10)) + return x; + if ((x = 10) < u) + return x; + if (u < (x = (y ? (x==y) : 10))) + return x; + if ((x = (y ? 10 : (x==y))) < u) + return x; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/compare5.c b/SingleSource/Regression/C/gcc-dg/compare5.c new file mode 100644 index 0000000000..3a502f12de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare5.c @@ -0,0 +1,41 @@ +/* Test for a bogus warning on comparison between signed and unsigned. + Origin: Kaveh R. Ghazi 8/21/2001. */ + +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +extern void bar(void); + +int foo(int x, int y, unsigned u) +{ + /* A *_DIV_EXPR is non-negative if both operands are. */ + + if (u < ((x=-22)/33)) /* { dg-warning "different signedness" "DIV_EXPR" } */ + return x; + + if (u < ((x=22)/33)) + return x; + + if (u < ((x=22)/(y=33))) + return x; + + if (u < (((x&0x10000)?128:64) / ((y&0x10000)?8:4))) + return x; + + + /* A *_MOD_EXPR is non-negative if the first operand is. */ + + if (u < ((x=-22)%33)) /* { dg-warning "different signedness" "MOD_EXPR" } */ + return x; + + if (u < ((x=22)%-33)) + return x; + + if (u < ((x==y)%-33)) + return x; + + if (u < (((x=22)/33)%-33)) + return x; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/compare6.c b/SingleSource/Regression/C/gcc-dg/compare6.c new file mode 100644 index 0000000000..945d282395 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare6.c @@ -0,0 +1,13 @@ +/* PR c/2098 */ +/* Test for a warning on comparison on out-of-range data. */ +/* { dg-do compile } */ +/* { dg-options "-Wtype-limits" } */ + +signed char sc; +unsigned char uc; + +void foo() +{ + if (sc == 10000) return; /* { dg-warning "always false" "signed" } */ + if (uc == 10000) return; /* { dg-warning "always false" "unsigned" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/compare7.c b/SingleSource/Regression/C/gcc-dg/compare7.c new file mode 100644 index 0000000000..b6fe6e7833 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare7.c @@ -0,0 +1,10 @@ +/* -Wall is not supposed to trigger -Wsign-compare for C. PR 10604. + See also g++.dg/warn/compare1.C. */ + +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int f(unsigned a, int b) +{ + return a < b; /* { dg-bogus "changes signedness" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/compare8.c b/SingleSource/Regression/C/gcc-dg/compare8.c new file mode 100644 index 0000000000..d09b69c53a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare8.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +int +f(unsigned short a1, unsigned short a2, unsigned int b) +{ + return ((a1+a2)|5) > b ? 2 : 3; /* { dg-bogus "changes signedness" } */ +} + +int +g(unsigned short a1, unsigned short a2, unsigned int b) +{ + return ((a1+a2)&5) > b ? 2 : 3; /* { dg-bogus "changes signedness" } */ +} + +int +h(unsigned short a1, unsigned short a2, unsigned int b) +{ + return ((a1+a2)^5) > b ? 2 : 3; /* { dg-bogus "changes signedness" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/compare9.c b/SingleSource/Regression/C/gcc-dg/compare9.c new file mode 100644 index 0000000000..fba61e42a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compare9.c @@ -0,0 +1,41 @@ +/* Test for a bogus warning on comparison between signed and unsigned. + This was inspired by code in gcc. This testcase is identical to + compare1.c except that we use -fshort-enums here and do not expect + a warning from case 4. */ + +/* { dg-do compile } */ +/* { dg-options "-fshort-enums -Wsign-compare" } */ + +int tf = 1; + +/* This enumeration has an explicit negative value and is therefore signed. */ +enum mm1 +{ + VOID, SI, DI, MAX = -1 +}; + +/* This enumeration fits entirely in a signed int, but is unsigned anyway. */ +enum mm2 +{ + VOID2, SI2, DI2, MAX2 +}; + +int f(enum mm1 x) +{ + return x == (tf?DI:SI); /* { dg-bogus "changes signedness" "case 1" } */ +} + +int g(enum mm1 x) +{ + return x == (tf?DI:-1); /* { dg-bogus "changes signedness" "case 2" } */ +} + +int h(enum mm2 x) +{ + return x == (tf?DI2:SI2); /* { dg-bogus "changes signedness" "case 3" } */ +} + +int i(enum mm2 x) +{ + return x == (tf?DI2:-1); /* { dg-bogus "changes signedness" "case 4" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/complete-port.c b/SingleSource/Regression/C/gcc-dg/complete-port.c new file mode 100644 index 0000000000..c8ebcc10e4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complete-port.c @@ -0,0 +1,96 @@ +/* This small program uses all the arithmetic operators that may + generate calls to library routines which must be implemented in + port-specific assembly language. */ +/* { dg-do link } */ + +#include + +int foo (); +double dfoo (); +void discard (int); +void ddiscard (double); + +int +main (void) +{ + int a = foo (), b = foo (); + unsigned int au = foo (), bu = foo (); + float af = dfoo (), bf = dfoo (); + double ad = dfoo (), bd = dfoo (); + + discard (a * b); + discard (a / b); + discard (a % b); + + discard (au / bu); + discard (au % bu); + + discard (a >> b); + discard (a << b); + + discard (au >> bu); + discard (au << bu); + + ddiscard (ad + bd); + ddiscard (ad - bd); + ddiscard (ad * bd); + ddiscard (ad / bd); + ddiscard (-ad); + + ddiscard (af + bf); + ddiscard (af - bf); + ddiscard (af * bf); + ddiscard (af / bf); + ddiscard (-af); + + discard ((int) ad); + discard ((int) af); + + ddiscard ((double) a); + ddiscard ((float) a); + ddiscard ((float) ad); + + discard (ad == bd); + discard (ad < bd); + discard (ad > bd); + discard (ad != bd); + discard (ad <= bd); + discard (ad >= bd); + + discard (af == bf); + discard (af < bf); + discard (af > bf); + discard (af != bf); + discard (af <= bf); + discard (af >= bf); + + return 0; +} + +void +discard (x) + int x __attribute__((__unused__)); +{} + +void +ddiscard (x) + double x __attribute__((__unused__)); +{} + +int +foo () +{ + static int table[] = {20, 69, 4, 12}; + static int idx; + + return table[idx++]; +} + +double +dfoo () +{ + static double table[] = {20.4, 69.96, 4.4, 202.202}; + static int idx; + + return table[idx++]; +} diff --git a/SingleSource/Regression/C/gcc-dg/completion-1.c b/SingleSource/Regression/C/gcc-dg/completion-1.c new file mode 100644 index 0000000000..64da64f1c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/completion-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "--completion=-fipa-ic" } */ + +/* { dg-begin-multiline-output "" } +-fipa-icf +-fipa-icf-functions +-fipa-icf-variables + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/completion-2.c b/SingleSource/Regression/C/gcc-dg/completion-2.c new file mode 100644 index 0000000000..166bfdc142 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/completion-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "--completion=-flto-parti" } */ + +/* { dg-begin-multiline-output "" } +-flto-partition=1to1 +-flto-partition=balanced +-flto-partition=max +-flto-partition=none +-flto-partition=one +-flto-partition= + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/completion-3.c b/SingleSource/Regression/C/gcc-dg/completion-3.c new file mode 100644 index 0000000000..462d356250 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/completion-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "--completion=--param=asan-" } */ + +/* { dg-begin-multiline-output "" } +--param=asan-globals= +--param=asan-instrument-allocas= +--param=asan-instrument-reads= +--param=asan-instrument-writes= +--param=asan-instrumentation-with-call-threshold= +--param=asan-kernel-mem-intrinsic-prefix= +--param=asan-memintrin= +--param=asan-stack= +--param=asan-use-after-return= + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/completion-4.c b/SingleSource/Regression/C/gcc-dg/completion-4.c new file mode 100644 index 0000000000..8116811998 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/completion-4.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "--completion=-march=geo" } */ + +/* { dg-begin-multiline-output "" } +-march=geode + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/completion-5.c b/SingleSource/Regression/C/gcc-dg/completion-5.c new file mode 100644 index 0000000000..6719cfb671 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/completion-5.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "--completion=-mfm" } */ + +/* { dg-begin-multiline-output "" } +-mfma +-mfma4 + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/complex-1.c b/SingleSource/Regression/C/gcc-dg/complex-1.c new file mode 100644 index 0000000000..7153433d0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complex-1.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +/* Verify that the 6th complex floating-point argument is + correctly passed as unnamed argument on SPARC64. */ + +extern void abort(void); + +void foo(long arg1, long arg2, long arg3, long arg4, long arg5, ...) +{ + __builtin_va_list ap; + _Complex float cf; + + __builtin_va_start(ap, arg5); + cf = __builtin_va_arg(ap, _Complex float); + __builtin_va_end(ap); + + if (__imag__ cf != 2.0f) + abort(); +} + +int bar(long arg1, long arg2, long arg3, long arg4, long arg5, _Complex float arg6) +{ + foo(arg1, arg2, arg3, arg4, arg5, arg6); + return 0; +} + +int main(void) +{ + return bar(0, 0, 0, 0, 0, 2.0fi); +} diff --git a/SingleSource/Regression/C/gcc-dg/complex-2.c b/SingleSource/Regression/C/gcc-dg/complex-2.c new file mode 100644 index 0000000000..85adcde2a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complex-2.c @@ -0,0 +1,7 @@ +/* Allow complex types in system headers even with -std=iso9899:1990 + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#include "complex-2.h" diff --git a/SingleSource/Regression/C/gcc-dg/complex-2.h b/SingleSource/Regression/C/gcc-dg/complex-2.h new file mode 100644 index 0000000000..752d7f26d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complex-2.h @@ -0,0 +1,6 @@ +/* Allow complex types in system headers even with -std=iso9899:1990 + -pedantic-errors. Header file. */ + +#pragma GCC system_header + +_Complex double x; diff --git a/SingleSource/Regression/C/gcc-dg/complex-3.c b/SingleSource/Regression/C/gcc-dg/complex-3.c new file mode 100644 index 0000000000..54ec82c0d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complex-3.c @@ -0,0 +1,25 @@ +/* Verify that rtl expansion cleanup doesn't get too aggressive about + code dealing with complex CONCATs. */ +/* { dg-do run } */ +/* { dg-options "-O -fno-tree-sra" } */ + +extern void abort (void); +extern void exit (int); + +__complex__ float foo (void) +{ + __complex__ float f[1]; + __real__ f[0] = 1; + __imag__ f[0] = 1; + f[0] = __builtin_conjf (f[0]); + return f[0]; +} + +int main (void) +{ + __complex__ double d[1]; + d[0] = foo (); + if (__real__ d[0] != 1 || __imag__ d[0] != -1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/complex-4.c b/SingleSource/Regression/C/gcc-dg/complex-4.c new file mode 100644 index 0000000000..6becd3b947 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complex-4.c @@ -0,0 +1,7 @@ +/* PR c/22393 */ +/* { dg-options "-O -std=gnu99" } */ + +__complex__ double foo (__complex__ double x) +{ + return 1.0 / x * -1.0i; +} diff --git a/SingleSource/Regression/C/gcc-dg/complex-5.c b/SingleSource/Regression/C/gcc-dg/complex-5.c new file mode 100644 index 0000000000..ffedefea36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complex-5.c @@ -0,0 +1,55 @@ +/* PR middle-end/33088 */ +/* Origin: Joseph S. Myers */ + +/* { dg-do run { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } */ +/* { dg-options "-std=c99 -O -ffloat-store -lm" } */ + +#include +#include + +volatile int x[1024]; + +void __attribute__((noinline)) +fill_stack (void) +{ + volatile int y[1024]; + int i; + for (i = 0; i < 1024; i++) + y[i] = 0x7ff00000; + for (i = 0; i < 1024; i++) + x[i] = y[i]; +} + +volatile _Complex double vc; + +void __attribute__((noinline)) +use_complex (_Complex double c) +{ + vc = c; +} + +double t0, t1, t2, t3; + +#define USE_COMPLEX(X, R, C) \ + do { __real__ X = R; __imag__ X = C; use_complex (X); } while (0) + +void __attribute__((noinline)) +use_stack (void) +{ + _Complex double a, b, c, d; + USE_COMPLEX (a, t0, t1); + USE_COMPLEX (b, t1, t2); + USE_COMPLEX (c, t2, t3); + USE_COMPLEX (d, t3, t0); +} + +int +main (void) +{ + fill_stack (); + feclearexcept (FE_INVALID); + use_stack (); + if (fetestexcept (FE_INVALID)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/complex-6.c b/SingleSource/Regression/C/gcc-dg/complex-6.c new file mode 100644 index 0000000000..cfbfc07d61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complex-6.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/70291. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cplxlower" } */ + +__complex float +foo (__complex float a, __complex float b) +{ + return a * b; +} + +/* { dg-final { scan-tree-dump-times "unord" 1 "cplxlower1" { target { ! rx*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "__(?:gnu_)?mulsc3" 1 "cplxlower1" { target { ! rx*-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/complex-7.c b/SingleSource/Regression/C/gcc-dg/complex-7.c new file mode 100644 index 0000000000..659ae40afa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/complex-7.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/70291. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cplxlower" } */ +/* { dg-require-effective-target double64 } */ + +__complex double +foo (__complex double a, __complex double b) +{ + return a * b; +} + +/* { dg-final { scan-tree-dump-times "unord" 1 "cplxlower1" } } */ +/* { dg-final { scan-tree-dump-times "__(?:gnu_)?muldc3" 1 "cplxlower1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/compound-literal-1.c b/SingleSource/Regression/C/gcc-dg/compound-literal-1.c new file mode 100644 index 0000000000..9b3b24e254 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compound-literal-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +/* PR c/43248 */ + +__extension__ int foo(__SIZE_TYPE__ i) +{ + i ? : (void *){}; /* { dg-error "" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/compound-literal-cast-lvalue-1.c b/SingleSource/Regression/C/gcc-dg/compound-literal-cast-lvalue-1.c new file mode 100644 index 0000000000..729bae2431 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compound-literal-cast-lvalue-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ +/* PR c/84900; casts from compound literals + were not considered a non-lvalue. */ + +int main() { + int *p = &(int) (int) {0}; /* { dg-error "lvalue" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/compound-lvalue-1.c b/SingleSource/Regression/C/gcc-dg/compound-lvalue-1.c new file mode 100644 index 0000000000..ffff76e47a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/compound-lvalue-1.c @@ -0,0 +1,13 @@ +/* Test for deprecation of compound expressions as lvalues. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int x, y; + +void +foo (void) +{ + (x, y) = 1; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "lvalue" "compound expression as lvalue" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/concat.c b/SingleSource/Regression/C/gcc-dg/concat.c new file mode 100644 index 0000000000..e3bfd46324 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/concat.c @@ -0,0 +1,17 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Test we output an error for concatenation of artificial strings. + + Neil Booth, 10 Dec 2001. */ + +void foo () +{ + char s1[] = __FUNCTION__"."; /* { dg-error "(parse|syntax|expected|invalid|array)" } */ + char s2[] = __PRETTY_FUNCTION__".";/* { dg-error "(parse|syntax|expected|invalid|array)" } */ + char s3[] = "."__FUNCTION__; /* { dg-error "(parse|syntax|expected|invalid)" } */ + char s4[] = "."__PRETTY_FUNCTION__;/* { dg-error "(parse|syntax|expected|invalid)" } */ + char s5[] = ".""."; /* No error. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/concat2.c b/SingleSource/Regression/C/gcc-dg/concat2.c new file mode 100644 index 0000000000..62f45d4880 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/concat2.c @@ -0,0 +1,14 @@ +/* PR c/3581 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Intended as a compile-time test for string literal concatenation. */ + +#define e0 "a" +#define e1 e0 e0 e0 e0 e0 e0 e0 e0 e0 e0 +#define e2 e1 e1 e1 e1 e1 e1 e1 e1 e1 e1 +#define e3 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2 +#define e4 e3 e3 e3 e3 e3 e3 e3 e3 e3 e3 +#define e5 e4 e4 e4 e4 e4 e4 e4 e4 e4 e4 + +void foo() { (void)(e5); } /* { dg-error "size of string literal is too large" "" { target { ! size20plus } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/cond-constqual-1.c b/SingleSource/Regression/C/gcc-dg/cond-constqual-1.c new file mode 100644 index 0000000000..b5a09cb003 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cond-constqual-1.c @@ -0,0 +1,15 @@ +/* Test for const qualification of type of conditional expression. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int foo (int) __attribute__ ((const)); +const int i; + +void +test (void) +{ + __typeof__ (1 ? foo (0) : 0) texpr; + __typeof__ (1 ? i : 0) texpr2; + texpr = 0; /* { dg-bogus "read-only variable" "conditional expression with call to const function" } */ + texpr2 = 0; /* { dg-bogus "read-only variable" "conditional expression with const variable" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/cond-lvalue-1.c b/SingleSource/Regression/C/gcc-dg/cond-lvalue-1.c new file mode 100644 index 0000000000..d7995c7eda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cond-lvalue-1.c @@ -0,0 +1,13 @@ +/* Test for deprecation of conditional expressions as lvalues. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int x, y, z; + +void +foo (void) +{ + (x ? y : z) = 1; /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "lvalue" "conditional expression as lvalue" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/const-1.c b/SingleSource/Regression/C/gcc-dg/const-1.c new file mode 100644 index 0000000000..5c2d49d870 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/const-1.c @@ -0,0 +1,57 @@ +/* { dg-do compile { target { nonpic || pie_enabled } } } */ +/* { dg-options "-O2 -Wsuggest-attribute=const -fno-finite-loops" } */ + +extern int extern_const(int a) __attribute__ ((const)); + +/* Trivial. */ +int +foo1(int a) /* { dg-bogus "normally" "detect const candidate" } */ +{ /* { dg-warning "const" "detect const candidate" { target *-*-* } "8" } */ + return extern_const (a); +} + +/* Loops known to be normally and extern const calls should be safe. */ + +int __attribute__ ((noinline)) +foo2(int n) /* { dg-bogus "normally" "detect const candidate" } */ +{ /* { dg-warning "const" "detect const candidate" { target *-*-* } "16" } */ + int ret = 0; + int i; + for (i=0; i + +int x, y; + +void __attribute__((noinline)) +bar(void) +{ + y++; +} + +void __attribute__((constructor)) +foo(void) +{ + if (!x) + { + bar(); + y++; + } +} + +int main() +{ + x = 1; + foo(); + foo(); + if (y != 2) + abort(); + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/conv-1.c b/SingleSource/Regression/C/gcc-dg/conv-1.c new file mode 100644 index 0000000000..07e41a6ac4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/conv-1.c @@ -0,0 +1,11 @@ +/* Copyright (C) 2000 Free Software Foundation. + + by Alexandre Oliva */ + +/* { dg-do compile } */ + +double +foo (unsigned long var) +{ + return var; +} diff --git a/SingleSource/Regression/C/gcc-dg/conv-2.c b/SingleSource/Regression/C/gcc-dg/conv-2.c new file mode 100644 index 0000000000..83468cdad1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/conv-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-Wpointer-sign" } */ + +void f1(long *); /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ +void f2(unsigned long *); /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */ + +int main() +{ + long *lp; + unsigned long *ulp; + char *cp; + unsigned char *ucp; + signed char *scp; + + ulp = lp; /* { dg-warning " pointer targets in assignment from 'long int \\*' to 'long unsigned int \\*' differ in signedness" } */ + lp = ulp; /* { dg-warning " pointer targets in assignment from 'long unsigned int \\*' to 'long int \\*' differ in signedness" } */ + f1(ulp); /* { dg-warning " differ in signedness" } */ + f2(lp); /* { dg-warning " differ in signedness" } */ + + cp = ucp; /* { dg-warning " pointer targets in assignment from 'unsigned char \\*' to 'char \\*' differ in signedness" } */ + cp = scp; /* { dg-warning " pointer targets in assignment from 'signed char \\*' to 'char \\*' differ in signedness" } */ + ucp = scp; /* { dg-warning " pointer targets in assignment from 'signed char \\*' to 'unsigned char \\*' differ in signedness" } */ + ucp = cp; /* { dg-warning " pointer targets in assignment from 'char \\*' to 'unsigned char \\*' differ in signedness" } */ + scp = ucp; /* { dg-warning " pointer targets in assignment from 'unsigned char \\*' to 'signed char \\*' differ in signedness" } */ + scp = cp; /* { dg-warning " pointer targets in assignment from 'char \\*' to 'signed char \\*' differ in signedness" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/conv-3.c b/SingleSource/Regression/C/gcc-dg/conv-3.c new file mode 100644 index 0000000000..3b4f4309d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/conv-3.c @@ -0,0 +1,18 @@ +/* PR middle-end/19100 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +void abort (void); + +int test (int v) +{ + return ((signed char) (v ? 0x100 : 0)) ? 17 : 18; +} + +int main() +{ + if (test (2) != 18) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-1.c b/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-1.c new file mode 100644 index 0000000000..2bbc40c1ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-1.c @@ -0,0 +1,14 @@ +/* Test TS 18661-1 CR_DECIMAL_DIG. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +#define __STDC_WANT_IEC_60559_BFP_EXT__ +#include + +#ifndef CR_DECIMAL_DIG +#error "CR_DECIMAL_DIG not defined" +#endif + +#if CR_DECIMAL_DIG < DECIMAL_DIG + 3 +#error "CR_DECIMAL_DIG too small" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-2.c b/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-2.c new file mode 100644 index 0000000000..42e79d545c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-2.c @@ -0,0 +1,10 @@ +/* Test TS 18661-1 CR_DECIMAL_DIG: not in C2X without + __STDC_WANT_IEC_60559_BFP_EXT__ defined. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#include + +#ifdef CR_DECIMAL_DIG +#error "CR_DECIMAL_DIG defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-3.c b/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-3.c new file mode 100644 index 0000000000..8e07b67dd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cr-decimal-dig-3.c @@ -0,0 +1,14 @@ +/* Test C2x CR_DECIMAL_DIG: defined for __STDC_WANT_IEC_60559_EXT__. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#define __STDC_WANT_IEC_60559_EXT__ +#include + +#ifndef CR_DECIMAL_DIG +#error "CR_DECIMAL_DIG not defined" +#endif + +#if CR_DECIMAL_DIG < DECIMAL_DIG + 3 +#error "CR_DECIMAL_DIG too small" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/cse_recip.c b/SingleSource/Regression/C/gcc-dg/cse_recip.c new file mode 100644 index 0000000000..49216620a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cse_recip.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized-raw -fno-tree-slp-vectorize" } */ + +void +cse_recip (float x, float y, float *a) +{ + a[0] = y / (5 * x); + a[1] = y / (3 * x); + a[2] = y / x; +} + +/* { dg-final { scan-tree-dump-times "rdiv_expr" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ctor1.c b/SingleSource/Regression/C/gcc-dg/ctor1.c new file mode 100644 index 0000000000..6c1cd72cc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ctor1.c @@ -0,0 +1,10 @@ +/* Related to PR c++/38410. + We shouldn't write out a static variable for an all-zero aggregate + initializer. The variable named C.0 was created by + gimplify_init_constructor. */ +/* { dg-final { scan-assembler-not "C\\.0" } } */ + +int main() +{ + int a[] = { 0,0 }; +} diff --git a/SingleSource/Regression/C/gcc-dg/cwsc0.c b/SingleSource/Regression/C/gcc-dg/cwsc0.c new file mode 100644 index 0000000000..3d92222bf9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cwsc0.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +#include + +void foo(void); +void test(int (*f)(void), char *p) +{ + __builtin_call_with_static_chain(f(), p); + __builtin_call_with_static_chain(p, f()); /* { dg-error "must be a call" } */ + __builtin_call_with_static_chain(f() + 1, p); /* { dg-error "must be a call" } */ + __builtin_call_with_static_chain(f(), 0); /* { dg-error "must be a pointer" } */ + __builtin_call_with_static_chain(f(), NULL); + __builtin_call_with_static_chain(foo, p); /* { dg-error "must be a call" } */ + __builtin_call_with_static_chain(foo(), p); + __builtin_call_with_static_chain(foo(), foo); +} diff --git a/SingleSource/Regression/C/gcc-dg/cwsc1.c b/SingleSource/Regression/C/gcc-dg/cwsc1.c new file mode 100644 index 0000000000..e793e26116 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/cwsc1.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +#if defined(__x86_64__) +# define CHAIN "%r10" +#elif defined(__i386__) +# define CHAIN "%ecx" +#elif defined(__aarch64__) +# define CHAIN "x18" +#elif defined(__alpha__) +# define CHAIN "$1" +#elif defined(__arm__) +# define CHAIN "ip" +#elif defined(__powerpc__) +# define CHAIN "11" +#elif defined(__s390__) +# define CHAIN "%r0" +#elif defined(__sparc__) +# ifdef __arch64__ +# define CHAIN "%g5" +# else +# define CHAIN "%g2" +# endif +#endif + +#ifdef CHAIN +void *__attribute__((noinline, noclone)) foo(void) +{ + register void *chain __asm__(CHAIN); + return chain; +} + +void * (*ptr)(void) = foo; +extern void abort(void); + +int main() +{ + char c; + void *x = __builtin_call_with_static_chain(ptr(), &c); + if (x != &c) + abort(); + return 0; +} +#else +int main() { return 0; } +#endif diff --git a/SingleSource/Regression/C/gcc-dg/darwin-20040812-1.c b/SingleSource/Regression/C/gcc-dg/darwin-20040812-1.c new file mode 100644 index 0000000000..4ae8657ba0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-20040812-1.c @@ -0,0 +1,24 @@ +/* Test dead code strip support. */ +/* Contributed by Devang Patel */ + +/* { dg-do compile { target *-*-darwin* } } */ + +const char my_version_string[] __attribute__((__used__)) + = "Do not remove this string\n"; + + static int + __attribute__((__used__)) + static_debug_routine() +{ + int i; + i = 42; +} + +int +main () +{ + return 0; +} + +/* { dg-final { scan-assembler ".no_dead_strip _my_version_string" } } */ +/* { dg-final { scan-assembler ".no_dead_strip _static_debug_routine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/darwin-aligned-globals.c b/SingleSource/Regression/C/gcc-dg/darwin-aligned-globals.c new file mode 100644 index 0000000000..18b71e7e32 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-aligned-globals.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-additional-options "-fcommon" } */ + +/* Test alignment rules which differ for earlier hosts (so we must + work on the principle that this test will be exercised by self- + hosted compilers. */ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070 +#define align_OK (1ul << 28) +#define align_BAD (1ul << 29) +#else +#define align_OK (1ul << 15) +#define align_BAD (1ul << 16) +#endif + +/* All non common vars are allowed larger alignment on modern systems. */ +static int xn __attribute__ ((aligned (align_OK))); +static int xi __attribute__ ((aligned (align_OK))) = 5 ; +int gxi __attribute__ ((aligned (align_OK))) = 6 ; + +/* test that we detect bad cases. */ +static int yn __attribute__ ((aligned (align_BAD))); /* { dg-error {requested alignment .[0-9]+. exceeds object file maximum} } */ +static int yi __attribute__ ((aligned (align_BAD))) = 5; /* { dg-error {requested alignment .[0-9]+. exceeds object file maximum} } */ +int yni __attribute__ ((aligned (align_BAD))) = 6; /* { dg-error {requested alignment .[0-9]+. exceeds object file maximum} } */ diff --git a/SingleSource/Regression/C/gcc-dg/darwin-cfstring-1.c b/SingleSource/Regression/C/gcc-dg/darwin-cfstring-1.c new file mode 100644 index 0000000000..b9565e721a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-cfstring-1.c @@ -0,0 +1,28 @@ +/* Test whether the __builtin__CFStringMakeConstantString + "function" fails gracefully when handed a non-constant + argument. This will only work on MacOS X 10.1.2 and later. */ +/* Developed by Ziemowit Laski . */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-mconstant-cfstrings" } */ + +typedef const struct __CFString *CFStringRef; + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR)) +#else +#error __CONSTANT_CFSTRINGS__ not defined +#endif + +extern int cond; +extern const char *func(void); + +const CFStringRef s0 = CFSTR("Hello" "there"); + +int main(void) { + CFStringRef s1 = CFSTR("Str1"); + CFStringRef s2 = CFSTR(cond? "Str2": "Str3"); /* { dg-error "CFString literal expression is not a string constant" } */ + CFStringRef s3 = CFSTR(func()); /* { dg-error "CFString literal expression is not a string constant" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-cfstring-2.c b/SingleSource/Regression/C/gcc-dg/darwin-cfstring-2.c new file mode 100644 index 0000000000..82b0551b87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-cfstring-2.c @@ -0,0 +1,12 @@ +/* Test whether the __builtin__CFStringMakeConstantString + "function" fails gracefully when used without the + -mconstant-cfstrings flag. */ +/* Developed by Ziemowit Laski . */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-mno-constant-cfstrings" } */ + +typedef const struct __CFString *CFStringRef; + +const CFStringRef S = ((CFStringRef)__builtin___CFStringMakeConstantString("Testing")); +/* { dg-error "built-in" "built-in function .* requires .* flag" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/darwin-cfstring-format-1.c b/SingleSource/Regression/C/gcc-dg/darwin-cfstring-format-1.c new file mode 100644 index 0000000000..a1513ee233 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-cfstring-format-1.c @@ -0,0 +1,36 @@ +/* Check CFString format extensions. */ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-Wall" } */ + +extern int printf (const char *fmt, ...); + +typedef const struct __CFString * CFStringRef; + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr "")) +#else +#error requires CFString +#endif + +int s1 (CFStringRef fmt, ...) __attribute__((format(CFString, 1, 2))) ; /* OK */ +int s2 (int a, CFStringRef fmt, ... ) __attribute__((format(__CFString__, 2, 3))) ; /* OK */ + +int s2a (int a, CFStringRef fmt, ... ) __attribute__((format(CFString, 2, 2))) ; /* { dg-error ".format. attribute argument 3 value .2. does not refer to a variable argument list" } */ + +int s3 (const char *fmt, ... ) __attribute__((format(__CFString__, 1, 2))) ; /* { dg-error "format argument should be a .CFString. reference but a string was found" } */ +int s4 (CFStringRef fmt, ... ) __attribute__((format(printf, 1, 2))) ; /* { dg-error "found a .CFStringRef.* but the format argument should be a string" } */ + +char *s5 (char dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ +CFStringRef s6 (CFStringRef dum, CFStringRef fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ + +char *s7 (int dum, void *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error ".format_arg. attribute argument value .2. refers to parameter type .void \\\*." } */ +int s8 (CFStringRef dum, CFStringRef fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "function does not return string type" } */ + +void foo (void) +{ + CFStringRef notchk = CFSTR ("here is an unchecked %d %s string"); + s1 (notchk, 5, 6, 7); + printf("this one is checked %d %s", 3, 4, 5); /* { dg-warning "format .%s. expects argument of type .char .., but argument 3 has type .int." } */ + /* { dg-warning "too many arguments for format" "" { target *-*-* } .-1 } */ + printf(s5 (1, "and so is this %d %d %s", 3, 4, "hey", 6), 5, 6, 12);/* { dg-warning "format .%s. expects argument of type .char .., but argument 4 has type .int." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-comm-1.c b/SingleSource/Regression/C/gcc-dg/darwin-comm-1.c new file mode 100644 index 0000000000..2ea11d63d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-comm-1.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-fcommon" } */ + +/* In all cases, common has a max alignment of 2^15. */ +int badcommon __attribute__ ((aligned (65536))); /* { dg-error "common variables must have an alignment" "" { target { *-*-darwin1[1-9]* *-*-darwin2* } } } */ +/* { dg-error "requested alignment .65536. exceeds object file maximum 32768" "" { target { *-*-darwin[4-9]* *-*-darwin10* } } .-1 } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/darwin-comm.c b/SingleSource/Regression/C/gcc-dg/darwin-comm.c new file mode 100644 index 0000000000..ac892b0032 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-comm.c @@ -0,0 +1,5 @@ +/* { dg-do compile { target *-*-darwin[912]* } } */ +/* { dg-options "-fcommon" } */ +/* { dg-final { scan-assembler ".comm\[ \t\]_foo,1,15" } } */ + +char foo __attribute__ ((aligned(32768))); diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-1.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-1.c new file mode 100644 index 0000000000..60761577e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-1.c @@ -0,0 +1,11 @@ +/* Test Darwin linker option -all_load. */ +/* Developed by Devang Patel . */ + +/* { dg-options "-all_load" } */ +/* { dg-do link { target *-*-darwin* } } */ + +int main() +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-2.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-2.c new file mode 100644 index 0000000000..5de19524f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-2.c @@ -0,0 +1,11 @@ +/* Test Darwin linker option -bind_at_load. */ +/* Developed by Devang Patel . */ + +/* { dg-options "-bind_at_load" } */ +/* { dg-do link { target *-*-darwin* } } */ + +int main() +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-20040809-1.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040809-1.c new file mode 100644 index 0000000000..c54a4aa0cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040809-1.c @@ -0,0 +1,13 @@ +/* Test -dead_strip support. */ +/* Contributed by Devang Patel */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-dead_strip" } */ + + +int +main () +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-20040809-2.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040809-2.c new file mode 100644 index 0000000000..73d788db06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040809-2.c @@ -0,0 +1,12 @@ +/* Test -no_dead_strip_inits_and_terms support. */ +/* Contributed by Devang Patel */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-no_dead_strip_inits_and_terms" } */ + +int +main () +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-1.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-1.c new file mode 100644 index 0000000000..b90328be9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-1.c @@ -0,0 +1,13 @@ +/* Test -segaddr. */ +/* Contributed by Devang Patel */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-segaddr __DATA 4000" } */ + + +int +main () +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-2.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-2.c new file mode 100644 index 0000000000..51f5ae8308 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-2.c @@ -0,0 +1,13 @@ +/* Test -segs_read_only_addr. */ +/* Contributed by Devang Patel */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-segs_read_only_addr 4000 -dynamiclib" } */ + + +int +main () +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-3.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-3.c new file mode 100644 index 0000000000..ca8928bd86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-20040828-3.c @@ -0,0 +1,13 @@ +/* Test -segs_read_write_addr. */ +/* Contributed by Devang Patel */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-segs_read_only_addr 4000 -segs_read_write_addr 8000 -dynamiclib" } */ + + +int +main () +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-3.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-3.c new file mode 100644 index 0000000000..e3efacaba2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-3.c @@ -0,0 +1,12 @@ + +/* Test Darwin linker option -arch_errors_fatal. */ +/* Developed by Devang Patel . */ + +/* { dg-options "-arch_errors_fatal" } */ +/* { dg-do link { target *-*-darwin* } } */ + +int main() +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-4.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-4.c new file mode 100644 index 0000000000..5cac36ccf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-4.c @@ -0,0 +1,11 @@ +/* Test Darwin linker option -bundle. */ +/* Developed by Devang Patel . */ + +/* { dg-options "-bundle" } */ +/* { dg-do link { target *-*-darwin* } } */ + +int main() +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-ld-5.c b/SingleSource/Regression/C/gcc-dg/darwin-ld-5.c new file mode 100644 index 0000000000..0540f92bcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-ld-5.c @@ -0,0 +1,11 @@ +/* Test Darwin linker option -dynamic. */ +/* Developed by Devang Patel . */ + +/* { dg-options "-dynamic" } */ +/* { dg-do link { target *-*-darwin* } } */ + +int main() +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-1.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-1.c new file mode 100644 index 0000000000..5f8524fbcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-1.c @@ -0,0 +1,12 @@ +/* Basic test for -mmacosx-version-min switch on Darwin. */ +/* { dg-options "-mmacosx-version-min=10.5" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1050 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-10.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-10.c new file mode 100644 index 0000000000..bf95d46960 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-10.c @@ -0,0 +1,16 @@ +/* PR target/63810: Test that an OS X minimum version with zero-padded + minor and tiny numbers less than 10 produces the correct + four-character macro. */ +/* Added by Lawrence Velázquez . */ + +/* { dg-options "-mmacosx-version-min=10.07.02" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1072 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-11.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-11.c new file mode 100644 index 0000000000..a03e707168 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-11.c @@ -0,0 +1,16 @@ +/* PR target/63810: Test that an OS X minimum version with outrageous + zero-padding and a minor number greater than 9 still produces + a six-character macro. */ +/* Added by Lawrence Velázquez . */ + +/* { dg-options "-mmacosx-version-min=00010.010.0000098" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101098 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-12.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-12.c new file mode 100644 index 0000000000..4c2ce38b55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-12.c @@ -0,0 +1,16 @@ +/* PR target/63810: Test that an OS X minimum version with outrageous + zero-padding and a minor number less than 10 still produces + a four-character macro. */ +/* Added by Lawrence Velázquez . */ + +/* { dg-options "-mmacosx-version-min=010.008.000031" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1089 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-2.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-2.c new file mode 100644 index 0000000000..3dbbca6f4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-2.c @@ -0,0 +1,12 @@ +/* Basic test for -mmacosx-version-min switch on Darwin. */ +/* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.5" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1050 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-3.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-3.c new file mode 100644 index 0000000000..a2be54f490 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-3.c @@ -0,0 +1,12 @@ +/* Test that most minor versions less than 10 work. */ +/* { dg-options "-mmacosx-version-min=10.5.8" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1058 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-4.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-4.c new file mode 100644 index 0000000000..1481aa53dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-4.c @@ -0,0 +1,12 @@ +/* Test that minor versions greater than 9 produce a six-character macro. */ +/* { dg-options "-mmacosx-version-min=10.10.1" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101001 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-5.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-5.c new file mode 100644 index 0000000000..09a9d7263b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-5.c @@ -0,0 +1,16 @@ +/* PR target/63810: Test that an OS X minimum version with minor number + less than 10 and tiny number greater than 9 produces a four-character + macro with the tiny number clamped to 9. */ +/* Added by Lawrence Velázquez . */ + +/* { dg-options "-mmacosx-version-min=10.9.10" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1099 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-6.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-6.c new file mode 100644 index 0000000000..e01fa72c59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-6.c @@ -0,0 +1,15 @@ +/* PR target/63810: Test that tiny numbers are preserved in + six-character macros. */ +/* Added by Lawrence Velázquez . */ + +/* { dg-options "-mmacosx-version-min=10.10.11" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101011 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-7.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-7.c new file mode 100644 index 0000000000..72f495b22a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-7.c @@ -0,0 +1,15 @@ +/* PR target/63810: Test that tiny numbers less than 10 are preserved in + four-character macros. */ +/* Added by Lawrence Velázquez . */ + +/* { dg-options "-mmacosx-version-min=10.9.1" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1091 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-8.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-8.c new file mode 100644 index 0000000000..5982df5e3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-8.c @@ -0,0 +1,16 @@ +/* PR target/63810: Test that an OS X minimum version with minor number + greater than 9 and no tiny number produces a six-character macro + ending in "00". */ +/* Added by Lawrence Velázquez . */ + +/* { dg-options "-mmacosx-version-min=10.11" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101100 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-9.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-9.c new file mode 100644 index 0000000000..d78178376d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-9.c @@ -0,0 +1,15 @@ +/* PR target/63810: Test that an OS X minimum version with a zero-padded + minor number less than 10 produces a four-character macro. */ +/* Added by Lawrence Velázquez . */ + +/* { dg-options "-mmacosx-version-min=10.08.4" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1084 + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-minversion-link.c b/SingleSource/Regression/C/gcc-dg/darwin-minversion-link.c new file mode 100644 index 0000000000..a835e9d464 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-minversion-link.c @@ -0,0 +1,30 @@ +/* Test that we can handle leading-zeros on mmacosx-version-min for invocations + including linking (so that spec processing works). To make sure that any + necessary target libs are present we make this specific to the target version + being built. */ +/* { dg-do link { target *-*-darwin* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.04.11 -DCHECK=1049" { target *-*-darwin8* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.05.08 -DCHECK=1058" { target *-*-darwin9* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.06.08 -DCHECK=1068" { target *-*-darwin10* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.07.05 -DCHECK=1075" { target *-*-darwin11* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.08.05 -DCHECK=1085" { target *-*-darwin12* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.09.05 -DCHECK=1095" { target *-*-darwin13* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.010.03 -DCHECK=101003" { target *-*-darwin14* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.011.06 -DCHECK=101106" { target *-*-darwin15* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.012.06 -DCHECK=101206" { target *-*-darwin16* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.013.06 -DCHECK=101306" { target *-*-darwin17* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.014.05 -DCHECK=101405" { target *-*-darwin18* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.015.06 -DCHECK=101506" { target *-*-darwin19* } } */ +/* { dg-additional-options "-mmacosx-version-min=011.000.00 -DCHECK=110000" { target *-*-darwin20* } } */ +/* { dg-additional-options "-mmacosx-version-min=012.000.00 -DCHECK=120000" { target *-*-darwin21* } } */ +/* { dg-additional-options "-mmacosx-version-min=013.000.00 -DCHECK=130000" { target *-*-darwin22* } } */ +/* { dg-additional-options "-mmacosx-version-min=014.000.00 -DCHECK=140000" { target *-*-darwin23* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != CHECK + fail me; +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-sections.c b/SingleSource/Regression/C/gcc-dg/darwin-sections.c new file mode 100644 index 0000000000..dbe37027f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-sections.c @@ -0,0 +1,69 @@ +/* { dg-do compile {target *-*-darwin* } } */ +/* { dg-options "-std=c99 -w -fcommon" } */ + +/* This has been designed to give the same section usage for + -m32 and -m64 - so don't put any ints or longs in it ... */ + +/* A zero-sized object. */ +typedef struct _empty {} e_s; + +/* These should go in .comm */ +char ub; +e_s ea; +/* { dg-final { scan-assembler ".comm\[\t \]_ub,1" } } */ +/* { dg-final { scan-assembler ".comm\[\t \]_ea,1" } } */ + +/* These should go into __DATA,__common */ +char a = 0; +short b = 0; +long long d = 0; +float e = 0; +double f = 0; +long double g = 0.L; +long long al_256 __attribute__((aligned (256))) = 0; +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_a,1,0} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_b,2,1} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_d,8,3} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_e,4,2} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_f,8,3} } } */ +/* long double can be 64 or 128 bits depending on the Darwin subtarget. */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_g,(16,4|8,3)} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_al_256,8,8} } } */ + +/* These should go into __DATA,__bss */ +static e_s sea; +static char sa ; +static short sb ; +static long long sd; +static float se ; +static double sf ; +static long double sg; +static long long sal_256 __attribute__((aligned (2048))); +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sea,1,0} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sa,1,0} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sb,2,1} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sd,8,3} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_se,4,2} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sf,8,3} } } */ +/* long double can be 64 or 128 bits depending on the Darwin subtarget. */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sg,(16,4|8,3)} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sal_256,8,11} } } */ + +long long foo (int x) +{ + e_s *s; + a += x + sa; + b += a + sb; + d += b + sd; + e += d + se; + f += e + sf; + g += f + sg; + + s = &ea; + s = &sea; + + b += al_256; + b += sal_256; + + return (long long) sd + b; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-segaddr.c b/SingleSource/Regression/C/gcc-dg/darwin-segaddr.c new file mode 100644 index 0000000000..526db77bd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-segaddr.c @@ -0,0 +1,19 @@ +/* Check that -segaddr gets through and works. */ +/* { dg-do run { target *-*-darwin* } } */ +/* { dg-options "-O0 -segaddr __TEST 0x200000 -fno-pie" { target { *-*-darwin* && { ! lp64 } } } } */ +/* { dg-options "-O0 -segaddr __TEST 0x110000000 -fno-pie" { target { *-*-darwin* && lp64 } } } */ + +extern void abort (); + +int t __attribute__((section("__TEST,__test"))); + +int main (void) +{ +#ifdef __LP64__ + if ((unsigned long long) &t != 0x110000000ULL) +#else + if ((unsigned long) &t != 0x200000UL) +#endif + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-version-1.c b/SingleSource/Regression/C/gcc-dg/darwin-version-1.c new file mode 100644 index 0000000000..2ca34c6c00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-version-1.c @@ -0,0 +1,16 @@ +/* Basic test of the -mmacosx-version-min option. */ + +/* Darwin4 corresponds to MacOS 10.0. */ +/* { dg-options "-mmacosx-version-min=10.1" { target *-*-darwin[456789]* } } */ +/* Later Darwin linkers decline to link for less than Darwin8/MacOS 10.4. + However, we need to make the link for 10.6 because the relevant libgcc_s + shim files for 10.4 and 10.5 are also not installed in later SDKs. */ +/* { dg-options "-mmacosx-version-min=10.6" { target *-*-darwin1[01234567]* } } */ +/* From XCode 11.4 on 10.14/15 10.6 and 10.7 are also deprecated. */ +/* { dg-options "-mmacosx-version-min=10.8" { target *-*-darwin1[89]* } } */ +/* { dg-do link { target *-*-darwin* } } */ + +int main() +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-weakimport-1.c b/SingleSource/Regression/C/gcc-dg/darwin-weakimport-1.c new file mode 100644 index 0000000000..16b7024fe2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-weakimport-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-require-weak "" } */ +/* { dg-options "-fno-common -fno-asynchronous-unwind-tables" } */ + +/* { dg-final { scan-assembler "weak_reference _a" } } */ +/* { dg-final { scan-assembler-not "weak_\[a-z \t\]*_b" } } */ + +extern void a (void) __attribute__((weak_import)); +extern void b (void) __attribute__((weak_import)); + +void b(void) +{ + a(); +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-weakimport-2.c b/SingleSource/Regression/C/gcc-dg/darwin-weakimport-2.c new file mode 100644 index 0000000000..1c98172228 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-weakimport-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-require-weak "" } */ + +/* { dg-final { scan-assembler "weak_reference _foo" } } */ + +extern int foo __attribute__((weak_import)); + +int main(void) +{ + if (&foo) + return foo; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-weakimport-3.c b/SingleSource/Regression/C/gcc-dg/darwin-weakimport-3.c new file mode 100644 index 0000000000..a15b5b0e7c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-weakimport-3.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target *-*-darwin* } } */ + +/* Here we want to test if "foo" gets placed into a coalesced + section (it should not). + + However, for i386, and PIC code we have a "get_pc thunk" that + is (correctly) placed in a coalesced section when using an older + linker - also unwind tables are emitted into coalesced. + + With modern linkers this is moot, since even weak symbols + are emitted into the regular sections. + + To avoid the unwind tables -fno-asynchronous-unwind-tables. + To ensure that we emit code for an older linker -mtarget-linker + To avoid the get_pc thunk optimise at least O1. */ + +/* { dg-options "-fno-asynchronous-unwind-tables -O1 -mtarget-linker 85.2" } */ +/* { dg-require-weak "" } */ + +/* { dg-final { scan-assembler-not "coalesced" } } */ + +extern void foo(void) __attribute__((weak_import)); + +void foo(void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/darwin-weakref-1.c b/SingleSource/Regression/C/gcc-dg/darwin-weakref-1.c new file mode 100644 index 0000000000..22a3cc079a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/darwin-weakref-1.c @@ -0,0 +1,28 @@ +/* { dg-do compile { target *-*-darwin* } } */ +// { dg-require-weak "" } +// { dg-options "-O2" } +// { dg-options "-O2 -mmacosx-version-min=10.2" { target { powerpc-*-darwin* } } } +/* { dg-final { scan-assembler "weak_reference _wv1" } } */ +/* { dg-final { scan-assembler "weak_reference _wf1" } } */ +/* { dg-final { scan-assembler-not "weak_reference _w.2" } } */ + + +typedef int vtype; + +extern vtype wv1; +static vtype Wv1a __attribute__((weakref ("wv1"))); +vtype *pv1a = &Wv1a; + +extern vtype wv2; +static vtype Wv2a __attribute__((weakref ("wv2"))); +vtype *pv2a = &wv2; + +typedef void ftype(void); + +extern ftype wf1; +static ftype Wf1a __attribute__((weakref ("wf1"))); +ftype *pf1a = &Wf1a; + +extern ftype wf2; +static ftype Wf2a __attribute__((weakref ("wf2"))); +ftype *pf2a = &wf2; diff --git a/SingleSource/Regression/C/gcc-dg/decl-1.c b/SingleSource/Regression/C/gcc-dg/decl-1.c new file mode 100644 index 0000000000..8bad2d368b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-1.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + + Source: Neil Booth, 12 Feb 2002. + + In the declaration of proc, x must be parsed as a typedef name (C99 + 6.7.5.3 p11. Also see C89 DR #009, which was erroneously omitted + from C99, and resubmitted as DR #249: if in a parameter + declaration, an identifier can be read as a typedef name or a + parameter name, it is read as a typedef name). */ + +/* { dg-do compile } */ + +typedef int x; +typedef int y; +int proc(int (x)); /* x is a typedef, param to proc is a function. */ +int proc2(int x); /* x is an identifier, param is an int. */ + +/* Parameter to proc3 is unnamed, with type a function that returns + int and takes a single argument of type function with one int + parameter returning int. In particular, proc3 is not a function + that takes a parameter y that is a function with one int parameter + returning int. 8-) */ +int proc3(int (y (x))); + +int main () +{ + proc (proc2); /* { dg-bogus "integer from pointer" } */ + return proc3 (proc); /* { dg-bogus "incompatible pointer type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/decl-10.c b/SingleSource/Regression/C/gcc-dg/decl-10.c new file mode 100644 index 0000000000..ec4259bfd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-10.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +void +f4(const foo x) /* { dg-error "10:unknown type name" } */ +{} + +void +f5(foo x, int i) /* { dg-error "4:unknown type name" } */ +{} + +void +f6(char c, foo x, ...) /* { dg-error "12:unknown type name" } */ +{} diff --git a/SingleSource/Regression/C/gcc-dg/decl-2.c b/SingleSource/Regression/C/gcc-dg/decl-2.c new file mode 100644 index 0000000000..40d744c926 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-2.c @@ -0,0 +1,16 @@ +/* PR c/7411 */ +/* Contributed by Christian Ehrhardt */ +/* Added extra line-breaks to check that diagnostics refer to correct token. + --Per Bothner. */ +/* { dg-do compile } */ + +void foo(void) +{ + char + c /* { dg-message "note: previous declaration" } */ + ; + int i; + int + c /* { dg-error "conflicting types" } */ + = i; +} diff --git a/SingleSource/Regression/C/gcc-dg/decl-3.c b/SingleSource/Regression/C/gcc-dg/decl-3.c new file mode 100644 index 0000000000..cba0b906db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-3.c @@ -0,0 +1,5 @@ +/* PR c/9928 */ +/* { dg-do compile } */ + +enum { CODES }; /* { dg-message "note: previous definition" } */ +enum { CODES }; /* { dg-error "conflicting types|redeclaration of enumerator" } */ diff --git a/SingleSource/Regression/C/gcc-dg/decl-4.c b/SingleSource/Regression/C/gcc-dg/decl-4.c new file mode 100644 index 0000000000..80566f74f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-4.c @@ -0,0 +1,10 @@ +/* Redeclaration of parameters is an error. PR 13728. */ +/* { dg-do compile } */ + +void f (int fred, /* { dg-message "note: previous definition" } */ + int fred); /* { dg-error "redefinition of parameter" } */ + +void f2 (int fred, /* { dg-message "note: previous definition" } */ + int fred) /* { dg-error "redefinition of parameter" } */ +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/decl-5.c b/SingleSource/Regression/C/gcc-dg/decl-5.c new file mode 100644 index 0000000000..9b77824645 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-5.c @@ -0,0 +1,20 @@ +/* PR c/14114 */ +/* Origin: */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +/* This used to fail because the compiler thought that the + declaration of 'c' from 'b' was shadowing that from 'a'. */ + +void a() +{ + void c(); + c(); +} + +void b() +{ + void c(); +} + +void c() {} diff --git a/SingleSource/Regression/C/gcc-dg/decl-6.c b/SingleSource/Regression/C/gcc-dg/decl-6.c new file mode 100644 index 0000000000..0fd45d3c68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-6.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +extern int var; + +int foo1(void) +{ + extern int var; + + var += 1; +} + +int foo2(void) +{ + var += 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/decl-7.c b/SingleSource/Regression/C/gcc-dg/decl-7.c new file mode 100644 index 0000000000..14b67baef8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-7.c @@ -0,0 +1,6 @@ +/* Test diagnostic for array defaulting to one element. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int a[]; /* { dg-warning "array 'a' assumed to have one element" } */ diff --git a/SingleSource/Regression/C/gcc-dg/decl-8.c b/SingleSource/Regression/C/gcc-dg/decl-8.c new file mode 100644 index 0000000000..608ff97d7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-8.c @@ -0,0 +1,10 @@ +/* Test diagnostics for duplicate typedefs. Basic diagnostics. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic-errors" } */ + +typedef int I; /* { dg-message "note: previous declaration of 'I'" "note" } */ +typedef int I; /* { dg-error "redefinition of typedef 'I'" } */ + +typedef int I1; /* { dg-message "note: previous declaration of 'I1'" "note" } */ +typedef long I1; /* { dg-error "conflicting types for 'I1'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/decl-9.c b/SingleSource/Regression/C/gcc-dg/decl-9.c new file mode 100644 index 0000000000..9bb15609d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-9.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic-errors" } */ + +w *x; /* { dg-error "unknown type name 'w'" } */ + +int z; /* { dg-message "previous declaration of 'z'" } */ +y /* { dg-error "unknown type name 'y'" } */ + * z; /* { dg-error "conflicting " } */ + +int f1() +{ + int d, e; + d * e; /* { dg-bogus "unknown type name 'd'" } */ + g * h; /* { dg-error "unknown type name 'g'" } */ + /* { dg-error "mixed declarations" "" { target *-*-* } .-1 } */ + g i; /* { dg-error "unknown type name 'g'" } */ +} + +typedef int a; + +int f2() +{ +b: a: ; /* { dg-bogus "a label can only be part of a statement" } */ +c: d e; /* { dg-error "a label can only be part of a statement" } */ +/* { dg-error "unknown type name 'd'" "unknown type name" { target *-*-* } .-1 } */ + ; +} + +void *f3() +{ + return x; /* { dg-bogus "'x' undeclared" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/decl-global-ext.c b/SingleSource/Regression/C/gcc-dg/decl-global-ext.c new file mode 100644 index 0000000000..97ffa7c2f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-global-ext.c @@ -0,0 +1,13 @@ +int merror = 0; +extern int merror; + +void mtherr (int code) +{ + merror = code + 1; +} + +int main() +{ + mtherr(7); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/decl-nospec-1.c b/SingleSource/Regression/C/gcc-dg/decl-nospec-1.c new file mode 100644 index 0000000000..b7061c49f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-nospec-1.c @@ -0,0 +1,8 @@ +/* Data definition with no type or storage class should receive a + pedwarn, rather than a warning which becomes an error with + -pedantic. Test with no options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +foo(); /* { dg-warning "data definition has no type or storage class" } */ diff --git a/SingleSource/Regression/C/gcc-dg/decl-nospec-2.c b/SingleSource/Regression/C/gcc-dg/decl-nospec-2.c new file mode 100644 index 0000000000..a4e9052207 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-nospec-2.c @@ -0,0 +1,8 @@ +/* Data definition with no type or storage class should receive a + pedwarn, rather than a warning which becomes an error with + -pedantic. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic" } */ + +foo(); /* { dg-warning "data definition has no type or storage class" } */ diff --git a/SingleSource/Regression/C/gcc-dg/decl-nospec-3.c b/SingleSource/Regression/C/gcc-dg/decl-nospec-3.c new file mode 100644 index 0000000000..f0347ca248 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/decl-nospec-3.c @@ -0,0 +1,8 @@ +/* Data definition with no type or storage class should receive a + pedwarn, rather than a warning which becomes an error with + -pedantic. Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic-errors" } */ + +foo(); /* { dg-error "data definition has no type or storage class" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declare-simd.c b/SingleSource/Regression/C/gcc-dg/declare-simd.c new file mode 100644 index 0000000000..2c8c1b7da4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declare-simd.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fopenmp-simd" } */ + +#pragma omp declare simd linear (p2, p3) +extern void fn2 (float p1, float *p2, float *p3); +/* { dg-warning "GCC does not currently support mixed size types for 'simd' functions" "" { target { { aarch64*-*-* } && lp64 } } .-1 } */ + +float *a, *b; +void fn1 (float *p1) +{ + int i; +#pragma omp simd + for (i = 0; i < 1000; i++) + fn2 (p1[i], a + i, b + i); +} diff --git a/SingleSource/Regression/C/gcc-dg/declspec-1.c b/SingleSource/Regression/C/gcc-dg/declspec-1.c new file mode 100644 index 0000000000..a75df90772 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-1.c @@ -0,0 +1,29 @@ +/* Test declaration specifiers. Test cases that used to be handled in + a loop in grokdeclarator. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +typedef int t; + +/* These should all be diagnosed, but only once, not for every + identifier declared. */ +struct s0 int x0, /* { dg-error "two or more data types" } */ +/* { dg-error "storage size of 'x0' isn't known" "" { target *-*-* } .-1 } */ +x1; /* { dg-error "storage size of 'x1' isn't known" } */ + +char union u0 x2, /* { dg-error "two or more data types" } */ +x3; + +enum e0 struct s1 x4, /* { dg-error "two or more data types" } */ + /* { dg-error "storage size of 'x4' isn't known" "" { target *-*-* } .-1 } */ +x5; /* { dg-error "storage size of 'x5' isn't known" } */ + +short short x6, /* { dg-error "duplicate" } */ +x7; + +t int x8, /* { dg-error "two or more data types" } */ +x9; + +long long long x10, /* { dg-error "long long long" } */ +x11; diff --git a/SingleSource/Regression/C/gcc-dg/declspec-10.c b/SingleSource/Regression/C/gcc-dg/declspec-10.c new file mode 100644 index 0000000000..241422bd5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-10.c @@ -0,0 +1,48 @@ +/* Test declaration specifiers. Test various checks on storage class + and function specifiers that depend on information about the + declaration, not just the specifiers. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } */ +register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ +typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ + +void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f5 (register int); +void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */ + +auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ + +register int y; +/* { dg-warning "file-scope declaration of 'y' specifies 'register'" "" { target *-*-* } .-1 } */ +/* { dg-message "error: register name not specified for 'y'" "not specified" { target *-*-* } .-2 } */ + +void h (void) { extern void x (void) {} } /* { dg-error "nested function 'x' declared 'extern'" } */ +/* { dg-warning "ISO C forbids nested functions" "nested" { target *-*-* } .-1 } */ + +void +g (void) +{ + void a; /* { dg-error "variable or field 'a' declared void" } */ + const void b; /* { dg-error "variable or field 'b' declared void" } */ + static void c; /* { dg-error "variable or field 'c' declared void" } */ +} + +void p; +const void p1; +extern void q; +extern const void q1; +static void r; /* { dg-error "variable or field 'r' declared void" } */ +static const void r1; /* { dg-error "variable or field 'r1' declared void" } */ + +register void f8 (void); /* { dg-error "invalid storage class for function 'f8'" } */ +/* { dg-warning "file-scope declaration of 'f8' specifies 'register'" "register function" { target *-*-* } .-1 } */ + +void i (void) { auto void y (void) {} } /* { dg-warning "ISO C forbids nested functions" } */ +/* { dg-warning "function definition declared 'auto'" "nested" { target *-*-* } .-1 } */ + +inline int main (void) { return 0; } /* { dg-warning "cannot inline function 'main'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-11.c b/SingleSource/Regression/C/gcc-dg/declspec-11.c new file mode 100644 index 0000000000..58f35ab7c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-11.c @@ -0,0 +1,48 @@ +/* Test declaration specifiers. Test various checks on storage class + and function specifiers that depend on information about the + declaration, not just the specifiers. Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +auto void f0 (void) {} /* { dg-error "function definition declared 'auto'" } */ +register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ +typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ + +void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f5 (register int); +void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */ + +auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ + +register int y; +/* { dg-error "file-scope declaration of 'y' specifies 'register'" "" { target *-*-* } .-1 } */ +/* { dg-message "error: register name not specified for 'y'" "" { target *-*-* } .-2 } */ + +void h (void) { extern void x (void) {} } /* { dg-error "nested function 'x' declared 'extern'" } */ +/* { dg-error "ISO C forbids nested functions" "nested" { target *-*-* } .-1 } */ + +void +g (void) +{ + void a; /* { dg-error "variable or field 'a' declared void" } */ + const void b; /* { dg-error "variable or field 'b' declared void" } */ + static void c; /* { dg-error "variable or field 'c' declared void" } */ +} + +void p; +const void p1; +extern void q; +extern const void q1; +static void r; /* { dg-error "variable or field 'r' declared void" } */ +static const void r1; /* { dg-error "variable or field 'r1' declared void" } */ + +register void f8 (void); /* { dg-error "invalid storage class for function 'f8'" } */ +/* { dg-error "file-scope declaration of 'f8' specifies 'register'" "register function" { target *-*-* } .-1 } */ + +void i (void) { auto void y (void) {} } /* { dg-error "ISO C forbids nested functions" } */ +/* { dg-error "function definition declared 'auto'" "nested" { target *-*-* } .-1 } */ + +inline int main (void) { return 0; } /* { dg-error "cannot inline function 'main'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-12.c b/SingleSource/Regression/C/gcc-dg/declspec-12.c new file mode 100644 index 0000000000..66c153740b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-12.c @@ -0,0 +1,6 @@ +/* Test type qualifier in empty declaration: OK but useless. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +const struct foo; /* { dg-warning "useless type qualifier in empty declaration" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-13.c b/SingleSource/Regression/C/gcc-dg/declspec-13.c new file mode 100644 index 0000000000..a69b94893b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-13.c @@ -0,0 +1,96 @@ +/* Test declaration specifiers. Test messages for bad type + specifiers. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic" } */ + +/* typeof should act much like typedef, so the following are + invalid. */ +typeof(double) long x0; /* { dg-error "two or more data types in declaration specifiers" } */ +typeof(double) _Complex x1; /* { dg-error "two or more data types in declaration specifiers" } */ + +/* The following is erroneous, and used to get a bogus message about + complex integer types. */ +typedef double D; +D _Complex x2; /* { dg-error "two or more data types in declaration specifiers" } */ + +/* The following empty declarations should have problems in their type + specifiers diagnosed, not just the general problem that they are + empty declarations. */ +long short; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +_Complex double; /* { dg-warning "ISO C90 does not support complex types" } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +_Complex; /* { dg-warning "ISO C90 does not support complex types" } */ +/* { dg-warning "ISO C does not support plain 'complex' meaning 'double complex'" "ISO C" { target *-*-* } .-1 } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-2 } */ +_Complex int; /* { dg-warning "ISO C90 does not support complex types" } */ +/* { dg-warning "ISO C does not support complex integer types" "ISO C" { target *-*-* } .-1 } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-2 } */ + +/* Specific messages for each invalid combination. (That some message + is given when appropriate for a larger collection of combinations + of type specifiers is tested in *typespec*.c.) */ + +long double long x3; /* { dg-error "both 'long long' and 'double' in declaration specifiers" } */ +short long x4; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */ +void long x5; /* { dg-error "both 'long' and 'void' in declaration specifiers" } */ +_Bool long x6; /* { dg-error "both 'long' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-1 } */ +char long x7; /* { dg-error "both 'long' and 'char' in declaration specifiers" } */ +float long x8; /* { dg-error "both 'long' and 'float' in declaration specifiers" } */ +long short x9; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */ +void short x10; /* { dg-error "both 'short' and 'void' in declaration specifiers" } */ +_Bool short x11; /* { dg-error "both 'short' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-1 } */ +char short x12; /* { dg-error "both 'short' and 'char' in declaration specifiers" } */ +float short x13; /* { dg-error "both 'short' and 'float' in declaration specifiers" } */ +double short x14; /* { dg-error "both 'short' and 'double' in declaration specifiers" } */ +unsigned signed x15; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */ +void signed x16; /* { dg-error "both 'signed' and 'void' in declaration specifiers" } */ +_Bool signed x17; /* { dg-error "both 'signed' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-1 } */ +float signed x18; /* { dg-error "both 'signed' and 'float' in declaration specifiers" } */ +double signed x19; /* { dg-error "both 'signed' and 'double' in declaration specifiers" } */ +signed unsigned x20; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */ +void unsigned x21; /* { dg-error "both 'unsigned' and 'void' in declaration specifiers" } */ +_Bool unsigned x22; /* { dg-error "both 'unsigned' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-1 } */ +float unsigned x23; /* { dg-error "both 'unsigned' and 'float' in declaration specifiers" } */ +double unsigned x24; /* { dg-error "both 'unsigned' and 'double' in declaration specifiers" } */ +void _Complex x25; /* { dg-error "both 'complex' and 'void' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } .-1 } */ +_Bool _Complex x26; /* { dg-error "both 'complex' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } .-1 } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-2 } */ + +long void x27; /* { dg-error "both 'long' and 'void' in declaration specifiers" } */ +short void x28; /* { dg-error "both 'short' and 'void' in declaration specifiers" } */ +signed void x29; /* { dg-error "both 'signed' and 'void' in declaration specifiers" } */ +unsigned void x30; /* { dg-error "both 'unsigned' and 'void' in declaration specifiers" } */ +_Complex void x31; /* { dg-error "both 'complex' and 'void' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } .-1 } */ +/* { dg-warning "ISO C does not support plain 'complex' meaning 'double complex'" "complex" { target *-*-* } .-2 } */ +long _Bool x32; /* { dg-error "both 'long' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-1 } */ +short _Bool x33; /* { dg-error "both 'short' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-1 } */ +signed _Bool x34; /* { dg-error "both 'signed' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-1 } */ +unsigned _Bool x35; /* { dg-error "both 'unsigned' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-1 } */ +_Complex _Bool x36; /* { dg-error "both 'complex' and '_Bool' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } .-1 } */ +/* { dg-warning "ISO C90 does not support boolean types" "C90" { target *-*-* } .-2 } */ +/* { dg-warning "ISO C does not support plain 'complex' meaning 'double complex'" "complex" { target *-*-* } .-3 } */ +long char x37; /* { dg-error "both 'long' and 'char' in declaration specifiers" } */ +short char x38; /* { dg-error "both 'short' and 'char' in declaration specifiers" } */ +long float x39; /* { dg-error "both 'long' and 'float' in declaration specifiers" } */ +short float x40; /* { dg-error "both 'short' and 'float' in declaration specifiers" } */ +signed float x41; /* { dg-error "both 'signed' and 'float' in declaration specifiers" } */ +unsigned float x42; /* { dg-error "both 'unsigned' and 'float' in declaration specifiers" } */ +long long double x43; /* { dg-error "both 'long long' and 'double' in declaration specifiers" } */ +/* { dg-warning "ISO C90 does not support 'long long'" "C90" { target *-*-* } .-1 } */ +short double x44; /* { dg-error "both 'short' and 'double' in declaration specifiers" } */ +signed double x45; /* { dg-error "both 'signed' and 'double' in declaration specifiers" } */ +unsigned double x46; /* { dg-error "both 'unsigned' and 'double' in declaration specifiers" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-14.c b/SingleSource/Regression/C/gcc-dg/declspec-14.c new file mode 100644 index 0000000000..d8ec78c9ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-14.c @@ -0,0 +1,11 @@ +/* Test that "typeof(struct foo)" and similar as declaration + specifiers act like typedef. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typeof(struct foo); /* { dg-warning "useless type name in empty declaration" } */ + +struct bar { int a; } x; + +typeof(x); /* { dg-warning "useless type name in empty declaration" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-15.c b/SingleSource/Regression/C/gcc-dg/declspec-15.c new file mode 100644 index 0000000000..dc3da61c26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-15.c @@ -0,0 +1,12 @@ +/* Test diagnostic for empty declarations in old-style parameter + declarations. Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +void +f (a, b) + int; /* { dg-warning "empty declaration" } */ + register; /* { dg-warning "empty declaration" } */ +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/declspec-16.c b/SingleSource/Regression/C/gcc-dg/declspec-16.c new file mode 100644 index 0000000000..598623930a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-16.c @@ -0,0 +1,12 @@ +/* Test diagnostic for empty declarations in old-style parameter + declarations. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic" } */ + +void +f (a, b) + int; /* { dg-warning "empty declaration" } */ + register; /* { dg-warning "empty declaration" } */ +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/declspec-17.c b/SingleSource/Regression/C/gcc-dg/declspec-17.c new file mode 100644 index 0000000000..d27faa1b31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-17.c @@ -0,0 +1,12 @@ +/* Test diagnostic for empty declarations in old-style parameter + declarations. Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic-errors" } */ + +void +f (a, b) + int; /* { dg-error "empty declaration" } */ + register; /* { dg-error "empty declaration" } */ +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/declspec-18.c b/SingleSource/Regression/C/gcc-dg/declspec-18.c new file mode 100644 index 0000000000..2885692e1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-18.c @@ -0,0 +1,112 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +static t1 *a; /* { dg-error "unknown type name 't1'" } */ + +int z; /* { dg-message "previous declaration of 'z'" } */ +typedef t2 *z; /* { dg-error "unknown type name 't2'" } */ +/* { dg-error "'z' redeclared " "redeclared" { target *-*-* } .-1 } */ + +extern t3 p1(void); /* { dg-error "unknown type name 't3'" } */ +int p2(const t4 x); /* { dg-error "unknown type name 't4'" } */ +int p3(const t1 x); /* { dg-error "unknown type name 't1'" } */ /* dup??? */ +int p4(t5 (*x)(void)); /* { dg-error "unknown type name 't5'" } */ +int p5(t6 *); /* { dg-error "unknown type name 't6'" } */ +int p6(t7 x); /* { dg-error "unknown type name 't7'" } */ +int p7(t8[]); /* { dg-error "unknown type name 't8'" } */ +int p8(int, t9); /* { dg-error "unknown type name 't9'" } */ + +struct s { + const t1 a; /* { dg-error "unknown type name 't1'" } */ /* dup??? */ + const t10 b; /* { dg-error "unknown type name 't10'" } */ + int b; /* { dg-error "duplicate member" } */ +}; + +typeof (z) c1; + +typeof (x1) c2; +/* { dg-error "undeclared" "undeclared" { target *-*-* } .-1 } */ +/* { dg-bogus "unknown type name 'x1'" "unknown" { target *-*-* } .-2 } */ + +typeof (const t11) c3; /* { dg-error "unknown type name 't11'" } */ + +typeof (t12 *) c3; +/* { dg-error "unknown type name 't12'" "t12" { xfail *-*-* } .-1 } */ +/* { dg-bogus "undeclared" "undeclared" { xfail *-*-* } .-2 } */ +/* { dg-bogus "expected expression before" "expected" { xfail *-*-* } .-3 } */ + +int recover1; + +int s0 = sizeof (z); + +int s1 = sizeof (x2); +/* { dg-error "undeclared" "undeclared" { target *-*-* } .-1 } */ +/* { dg-bogus "unknown type name 'x2'" "unknown" { target *-*-* } .-2 } */ + +int s2 = sizeof (const t13); /* { dg-error "unknown type name 't13'" } */ + +int s3 = sizeof (t14 *); +/* { dg-error "unknown type name 't14'" "t14" { xfail *-*-* } .-1 } */ +/* { dg-bogus "undeclared" "undeclared" { xfail *-*-* } .-2 } */ +/* { dg-bogus "expected expression before" "expected" { xfail *-*-* } .-3 } */ + +int recover2; + +int a0 = __alignof__ (z); + +int a1 = __alignof__ (x3); /* { dg-error "undeclared" } */ +/* { dg-bogus "unknown type name 'x3'" "" { target *-*-* } .-1 } */ + +int a2 = __alignof__ (const t15); /* { dg-error "unknown type name 't15'" } */ + +int a3 = __alignof__ (t16 *); +/* { dg-error "unknown type name 't16'" "t16" { xfail *-*-* } .-1 } */ +/* { dg-bogus "undeclared" "undeclared" { xfail *-*-* } .-2 } */ +/* { dg-bogus "expected expression before" "expected" { xfail *-*-* } .-3 } */ + +int recover3; + + +/* Cannot detect (undefd_type *) or (undefd_type (*) because it would + require 3 tokens of lookahead (same as above). */ + +const char *f1() +{ + return (const t17) "abc"; /* { dg-error "unknown type name 't17'" "t17" } */ +/* { dg-bogus "expected" "expected" { target *-*-* } .-1 } */ +} + +const char *f2() +{ + return (const t18 *) "abc"; /* { dg-error "unknown type name 't18'" "t18" } */ +/* { dg-bogus "expected" "expected" { target *-*-* } .-1 } */ +} + + +/* The parser has problems distinguishing semantic and syntactic errors, + so it emits a wrong "expected ')'" error here. */ + +void *f3(int x) +{ + return (void *) ((void *(*)(t19)) f3); /* { dg-error "unknown type name 't19'" "t19" } */ +/* { dg-bogus "expected" "expected" { xfail *-*-* } .-1 } */ +} + +const void *f4() +{ + return &((const t20){1}); /* { dg-error "unknown type name 't20'" } */ +/* { dg-bogus "return discards 'const'" "discards" { target *-*-* } .-1 } */ +/* { dg-bogus "expected" "expected" { target *-*-* } .-2 } */ +} + +int f5(__builtin_va_list ap) +{ + int x = __builtin_va_arg (ap, t21); /* { dg-error "unknown type name 't21'" } */ + int y = __builtin_va_arg (ap, const t22); /* { dg-error "unknown type name 't22'" } */ +} + +int f6(void) +{ + return __builtin_offsetof (t23, field); /* { dg-error "unknown type name 't23'" "t23" } */ +/* { dg-bogus "request for member" "request" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/declspec-2.c b/SingleSource/Regression/C/gcc-dg/declspec-2.c new file mode 100644 index 0000000000..f2c535ad83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-2.c @@ -0,0 +1,14 @@ +/* Test declaration specifiers. Test cases that used to be handled in + a loop in grokdeclarator. Pedantic cases. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic" } */ + +/* These should all be diagnosed, but only once, not for every + identifier declared. */ + +const const int x0, /* { dg-warning "duplicate" } */ +x1; + +long long x2, /* { dg-warning "long long" } */ +x3; diff --git a/SingleSource/Regression/C/gcc-dg/declspec-3-Wextra.c b/SingleSource/Regression/C/gcc-dg/declspec-3-Wextra.c new file mode 100644 index 0000000000..66378cc71d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-3-Wextra.c @@ -0,0 +1,32 @@ +/* See declspec-3.c . Test -Wold-style-declaration is enabled by -Wextra. */ +/* { dg-do compile } */ +/* { dg-options "-Wextra" } */ + +static int x0; +int static x1; /* { dg-warning "not at beginning" } */ + +extern int x2; +int extern x3; /* { dg-warning "not at beginning" } */ + +typedef int x4; +int typedef x5; /* { dg-warning "not at beginning" } */ + +void g (int); + +void +f (void) +{ + auto int x6 = 0; + int auto x7 = 0; /* { dg-warning "not at beginning" } */ + register int x8 = 0; + int register x9 = 0; /* { dg-warning "not at beginning" } */ + g (x6 + x7 + x8 + x9); +} + +const static int x10; /* { dg-warning "not at beginning" } */ + +/* Attributes are OK before storage class specifiers, since some + attributes are like such specifiers themselves. */ + +__attribute__((format(printf, 1, 2))) static void h (const char *, ...); +__attribute__((format(printf, 1, 2))) void static i (const char *, ...); /* { dg-warning "not at beginning" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-3-no.c b/SingleSource/Regression/C/gcc-dg/declspec-3-no.c new file mode 100644 index 0000000000..678b4f2d3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-3-no.c @@ -0,0 +1,32 @@ +/* See declspec-3.c . Test disabling -Wold-style-declaration. */ +/* { dg-do compile } */ +/* { dg-options "-Wextra -Wno-old-style-declaration" } */ + +static int x0; +int static x1; /* { dg-bogus "not at beginning" } */ + +extern int x2; +int extern x3; /* { dg-bogus "not at beginning" } */ + +typedef int x4; +int typedef x5; /* { dg-bogus "not at beginning" } */ + +void g (int); + +void +f (void) +{ + auto int x6 = 0; + int auto x7 = 0; /* { dg-bogus "not at beginning" } */ + register int x8 = 0; + int register x9 = 0; /* { dg-bogus "not at beginning" } */ + g (x6 + x7 + x8 + x9); +} + +const static int x10; /* { dg-bogus "not at beginning" } */ + +/* Attributes are OK before storage class specifiers, since some + attributes are like such specifiers themselves. */ + +__attribute__((format(printf, 1, 2))) static void h (const char *, ...); +__attribute__((format(printf, 1, 2))) void static i (const char *, ...); /* { dg-bogus "not at beginning" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-3.c b/SingleSource/Regression/C/gcc-dg/declspec-3.c new file mode 100644 index 0000000000..95052a9860 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-3.c @@ -0,0 +1,34 @@ +/* Test declaration specifiers. Test diagnosis of storage class + specifiers not at start. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wold-style-declaration" } */ + +static int x0; +int static x1; /* { dg-warning "not at beginning" } */ + +extern int x2; +int extern x3; /* { dg-warning "not at beginning" } */ + +typedef int x4; +int typedef x5; /* { dg-warning "not at beginning" } */ + +void g (int); + +void +f (void) +{ + auto int x6 = 0; + int auto x7 = 0; /* { dg-warning "not at beginning" } */ + register int x8 = 0; + int register x9 = 0; /* { dg-warning "not at beginning" } */ + g (x6 + x7 + x8 + x9); +} + +const static int x10; /* { dg-warning "not at beginning" } */ + +/* Attributes are OK before storage class specifiers, since some + attributes are like such specifiers themselves. */ + +__attribute__((format(printf, 1, 2))) static void h (const char *, ...); +__attribute__((format(printf, 1, 2))) void static i (const char *, ...); /* { dg-warning "not at beginning" } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-4.c b/SingleSource/Regression/C/gcc-dg/declspec-4.c new file mode 100644 index 0000000000..59dbae0bd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-4.c @@ -0,0 +1,43 @@ +/* Test declaration specifiers. Test empty declarations. Test with + no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* If a declaration does not declare a declarator, it must declare a + tag or the members of an enumeration, and must only contain one + type specifier. */ + +typedef int T; + +struct s0; +union u0; +enum e0; /* A GNU extension. */ +enum { E0 }; +enum e1 { E1 }; + +/* Not declaring anything (pedwarns). */ +struct { int a; }; /* { dg-warning "unnamed struct/union that defines no instances" } */ +int; /* { dg-warning "useless type name in empty declaration" } */ +long; /* { dg-warning "useless type name in empty declaration" } */ +T; /* { dg-warning "useless type name in empty declaration" } */ +static const; /* { dg-warning "useless storage class specifier in empty declaration" } */ +/* { dg-warning "empty declaration" "static const" { target *-*-* } .-1 } */ +union { long b; }; /* { dg-warning "unnamed struct/union that defines no instances" } */ + +/* Multiple type names (errors). */ +struct s1 int; /* { dg-error "two or more data types in declaration specifiers" } */ +char union u1; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "char union" { target *-*-* } .-1 } */ +double enum { E2 }; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "double enum" { target *-*-* } .-1 } */ +T struct s2; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "T struct" { target *-*-* } .-1 } */ +long union u2; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +struct s3 short; /* { dg-error "two or more data types in declaration specifiers" } */ +union u3 signed; /* { dg-error "two or more data types in declaration specifiers" } */ +unsigned struct s4; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +_Complex enum { E3 }; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-5.c b/SingleSource/Regression/C/gcc-dg/declspec-5.c new file mode 100644 index 0000000000..f7f80bf8b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-5.c @@ -0,0 +1,45 @@ +/* Test declaration specifiers. Test empty declarations. Test with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic" } */ + +/* If a declaration does not declare a declarator, it must declare a + tag or the members of an enumeration, and must only contain one + type specifier. */ + +typedef int T; + +struct s0; +union u0; +enum e0; /* { dg-warning "ISO C forbids forward references" } */ +enum { E0 }; +enum e1 { E1 }; + +/* Not declaring anything (pedwarns). */ +struct { int a; }; /* { dg-warning "unnamed struct/union that defines no instances" } */ +int; /* { dg-warning "useless type name in empty declaration" } */ +long; /* { dg-warning "useless type name in empty declaration" } */ +T; /* { dg-warning "useless type name in empty declaration" } */ +static const; /* { dg-warning "useless storage class specifier in empty declaration" } */ +/* { dg-warning "empty declaration" "static const" { target *-*-* } .-1 } */ +union { long b; }; /* { dg-warning "unnamed struct/union that defines no instances" } */ + +/* Multiple type names (errors). */ +struct s1 int; /* { dg-error "two or more data types in declaration specifiers" } */ +char union u1; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "char union" { target *-*-* } .-1 } */ +double enum { E2 }; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "double enum" { target *-*-* } .-1 } */ +T struct s2; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "T struct" { target *-*-* } .-1 } */ +long union u2; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +struct s3 short; /* { dg-error "two or more data types in declaration specifiers" } */ +union u3 signed; /* { dg-error "two or more data types in declaration specifiers" } */ +unsigned struct s4; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +_Complex enum { E3 }; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-warning "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +/* { dg-warning "ISO C90 does not support complex types" "C90" { target *-*-* } .-2 } */ +/* { dg-warning "ISO C does not support plain 'complex' meaning 'double complex'" "ISO C" { target *-*-* } .-3 } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-6.c b/SingleSource/Regression/C/gcc-dg/declspec-6.c new file mode 100644 index 0000000000..c235717214 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-6.c @@ -0,0 +1,45 @@ +/* Test declaration specifiers. Test empty declarations. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic-errors" } */ + +/* If a declaration does not declare a declarator, it must declare a + tag or the members of an enumeration, and must only contain one + type specifier. */ + +typedef int T; + +struct s0; +union u0; +enum e0; /* { dg-error "ISO C forbids forward references" } */ +enum { E0 }; +enum e1 { E1 }; + +/* Not declaring anything (pedwarns). */ +struct { int a; }; /* { dg-error "unnamed struct/union that defines no instances" } */ +int; /* { dg-error "useless type name in empty declaration" } */ +long; /* { dg-error "useless type name in empty declaration" } */ +T; /* { dg-error "useless type name in empty declaration" } */ +static const; /* { dg-warning "useless storage class specifier in empty declaration" } */ +/* { dg-error "empty declaration" "static const" { target *-*-* } .-1 } */ +union { long b; }; /* { dg-error "unnamed struct/union that defines no instances" } */ + +/* Multiple type names (errors). */ +struct s1 int; /* { dg-error "two or more data types in declaration specifiers" } */ +char union u1; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-error "useless type name in empty declaration" "char union" { target *-*-* } .-1 } */ +double enum { E2 }; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-error "useless type name in empty declaration" "double enum" { target *-*-* } .-1 } */ +T struct s2; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-error "useless type name in empty declaration" "T struct" { target *-*-* } .-1 } */ +long union u2; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-error "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +struct s3 short; /* { dg-error "two or more data types in declaration specifiers" } */ +union u3 signed; /* { dg-error "two or more data types in declaration specifiers" } */ +unsigned struct s4; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-error "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +_Complex enum { E3 }; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-error "useless type name in empty declaration" "empty" { target *-*-* } .-1 } */ +/* { dg-error "ISO C90 does not support complex types" "C90" { target *-*-* } .-2 } */ +/* { dg-error "ISO C does not support plain 'complex' meaning 'double complex'" "ISO C" { target *-*-* } .-3 } */ diff --git a/SingleSource/Regression/C/gcc-dg/declspec-7.c b/SingleSource/Regression/C/gcc-dg/declspec-7.c new file mode 100644 index 0000000000..10623e4ea7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-7.c @@ -0,0 +1,39 @@ +/* Test declaration specifiers. Test checks on storage class + specifiers that can be made at parse time rather than for each + declarator. Note that __thread is tested in + gcc.dg/tls/diag-*.c. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-fgnu89-inline" } */ + +/* Duplicate specifiers. */ + +inline inline void f0 (void), + f1 (void); + +static static int a, /* { dg-error "duplicate 'static'" } */ + b; + +extern extern int c, /* { dg-error "duplicate 'extern'" } */ + d; + +typedef typedef int e, /* { dg-error "duplicate 'typedef'" } */ + f; + +void +h (void) +{ + auto auto int p, /* { dg-error "duplicate 'auto'" } */ + q; + + register register int r, /* { dg-error "duplicate 'register'" } */ + s; +} + +/* Multiple specifiers. */ + +static extern int x, /* { dg-error "multiple storage classes in declaration specifiers" } */ + y; + +extern typedef long z, /* { dg-error "multiple storage classes in declaration specifiers" } */ + w; diff --git a/SingleSource/Regression/C/gcc-dg/declspec-8.c b/SingleSource/Regression/C/gcc-dg/declspec-8.c new file mode 100644 index 0000000000..a26cfa4d75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-8.c @@ -0,0 +1,32 @@ +/* Test declaration specifiers. Test checks on storage class + specifiers and function specifiers in empty declarations. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* The constraints on storage class specifiers and function specifiers + must be met for empty declarations where they are useless. Thus + there may be only one storage class specifier (C90 6.5.1, C99 + 6.7.1#2) and "inline" must not be used because the declaration is + not that of an identifier for a function (C99 6.7.4#1), and + "register" and "auto" must not be used at file scope (C90 6.7, C99 + 6.9#2). */ + +static static struct s; /* { dg-error "duplicate 'static'" } */ +/* { dg-warning "useless storage class specifier in empty declaration" "static static" { target *-*-* } .-1 } */ + +static extern struct t; /* { dg-error "multiple storage classes in declaration specifiers" } */ +/* { dg-warning "useless storage class specifier in empty declaration" "static extern" { target *-*-* } .-1 } */ + +inline union u; /* { dg-error "'inline' in empty declaration" } */ + +auto struct v; /* { dg-error "'auto' in file-scope empty declaration" } */ + +register struct w; /* { dg-error "'register' in file-scope empty declaration" } */ + +void +f (void) +{ + auto union p; /* { dg-warning "useless storage class specifier in empty declaration" } */ + register struct q; /* { dg-warning "useless storage class specifier in empty declaration" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/declspec-9.c b/SingleSource/Regression/C/gcc-dg/declspec-9.c new file mode 100644 index 0000000000..7766ed6a4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/declspec-9.c @@ -0,0 +1,43 @@ +/* Test declaration specifiers. Test various checks on storage class + and function specifiers that depend on information about the + declaration, not just the specifiers. Test with no special + options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } */ +register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */ +typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */ + +void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f5 (register int); +void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */ +void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */ + +auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ +register int y; /* { dg-error "register name not specified for 'y'" } */ + +void h (void) { extern void x (void) {} } /* { dg-error "nested function 'x' declared 'extern'" } */ + +void +g (void) +{ + void a; /* { dg-error "variable or field 'a' declared void" } */ + const void b; /* { dg-error "variable or field 'b' declared void" } */ + static void c; /* { dg-error "variable or field 'c' declared void" } */ +} + +void p; +const void p1; +extern void q; +extern const void q1; +static void r; /* { dg-error "variable or field 'r' declared void" } */ +static const void r1; /* { dg-error "variable or field 'r1' declared void" } */ + +register void f8 (void); /* { dg-error "invalid storage class for function 'f8'" } */ + +void i (void) { auto void y (void) {} } + +inline int main (void) { return 0; } /* { dg-warning "cannot inline function 'main'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/delay-slot-1.c b/SingleSource/Regression/C/gcc-dg/delay-slot-1.c new file mode 100644 index 0000000000..bfc0273e4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/delay-slot-1.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mabi=64" { target { mips*-*-linux* && mips64 } } } */ + +struct offset_v1 { + int k_uniqueness; +}; + +struct offset_v2 { + long v; +} __attribute__ ((__packed__)); + +struct reiserfs_key { + int k_objectid; + union { + struct offset_v1 k_offset_v1; + struct offset_v2 k_offset_v2; + } u; +}; + +struct item_head +{ + struct reiserfs_key ih_key; + int ih_version; +}; + +static void set_offset_v2_k_type(struct offset_v2 *v2) +{ + v2->v &= 1; +} + +static void set_le_key_k_type (int version, struct reiserfs_key * key) +{ + version ? (key->u.k_offset_v1.k_uniqueness = 1) + : set_offset_v2_k_type(&(key->u.k_offset_v2)); +} + +static void set_le_ih_k_type (struct item_head * ih) +{ + set_le_key_k_type((__builtin_constant_p((ih)->ih_version) ? (ih)->ih_version : (ih)->ih_version), &(ih->ih_key)); +} + +void boo(struct item_head *ih, const char *body); + +void direct2indirect(void) +{ + struct item_head *p_le_ih; + struct item_head ind_ih; + unsigned int unfm_ptr; + + if (__builtin_expect(32, 0)) __asm__ ("break"); + + set_le_ih_k_type (&ind_ih); + + if (__builtin_constant_p(p_le_ih) ? 1 : 2) { + (__builtin_constant_p(__builtin_constant_p(1) == 1)); + boo(&ind_ih, (char *)&unfm_ptr); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/delay-slot-2.c b/SingleSource/Regression/C/gcc-dg/delay-slot-2.c new file mode 100644 index 0000000000..d8619aac95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/delay-slot-2.c @@ -0,0 +1,117 @@ +/* PR rtl-optimization/51187 */ +/* Reported by Jurij Smakov */ + +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ + +extern int printf (__const char *__restrict __format, ...); +extern void print_c_condition (const char *); +extern void print_host_wide_int (long); + +enum decision_type +{ + DT_num_insns, + DT_mode, DT_code, DT_veclen, + DT_elt_zero_int, DT_elt_one_int, DT_elt_zero_wide, DT_elt_zero_wide_safe, + DT_const_int, + DT_veclen_ge, DT_dup, DT_pred, DT_c_test, + DT_accept_op, DT_accept_insn +}; + +struct decision_test +{ + struct decision_test *next; + enum decision_type type; + + union + { + int num_insns; + + struct + { + const char *name; + } pred; + + const char *c_test; + int veclen; + int dup; + long intval; + int opno; + + struct { + int code_number; + int lineno; + int num_clobbers_to_add; + } insn; + } u; +}; + +enum routine_type { + RECOG, SPLIT, PEEPHOLE2 +}; + +void +write_cond (struct decision_test *p, int depth, + enum routine_type subroutine_type) +{ + switch (p->type) + { + case DT_num_insns: + printf ("peep2_current_count >= %d", p->u.num_insns); + break; + + case DT_code: + printf ("GET_CODE (x%d) == ", depth); + break; + + case DT_veclen: + printf ("XVECLEN (x%d, 0) == %d", depth, p->u.veclen); + break; + + case DT_elt_zero_int: + printf ("XINT (x%d, 0) == %d", depth, (int) p->u.intval); + break; + + case DT_elt_one_int: + printf ("XINT (x%d, 1) == %d", depth, (int) p->u.intval); + break; + + case DT_elt_zero_wide: + case DT_elt_zero_wide_safe: + printf ("XWINT (x%d, 0) == ", depth); + print_host_wide_int (p->u.intval); + break; + + case DT_const_int: + printf ("x%d == const_int_rtx[MAX_SAVED_CONST_INT + (%d)]", + depth, (int) p->u.intval); + break; + + case DT_veclen_ge: + printf ("XVECLEN (x%d, 0) >= %d", depth, p->u.veclen); + break; + + case DT_dup: + printf ("rtx_equal_p (x%d, operands[%d])", depth, p->u.dup); + break; + + case DT_pred: + printf ("%s (x%d)", p->u.pred.name, depth); + break; + + case DT_c_test: + print_c_condition (p->u.c_test); + break; + + case DT_accept_insn: + ((void)(__builtin_expect(!(subroutine_type == RECOG), 0) ? __builtin_unreachable(), 0 : 0)); + ((void)(__builtin_expect(!(p->u.insn.num_clobbers_to_add), 0) ? __builtin_unreachable(), 0 : 0)); + printf ("pnum_clobbers != NULL"); + break; + + default: + __builtin_unreachable(); + } +} + +/* { dg-final { scan-assembler "printf" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/deprecated-2.c b/SingleSource/Regression/C/gcc-dg/deprecated-2.c new file mode 100644 index 0000000000..c4ca8a272d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/deprecated-2.c @@ -0,0 +1,7 @@ +/* Test __attribute__((deprecated)). Test types without names. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a; } __attribute__((deprecated)) x; /* { dg-warning "type is deprecated" } */ +typeof(x) y; /* { dg-warning "type is deprecated" } */ diff --git a/SingleSource/Regression/C/gcc-dg/deprecated-3.c b/SingleSource/Regression/C/gcc-dg/deprecated-3.c new file mode 100644 index 0000000000..2c35bb314e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/deprecated-3.c @@ -0,0 +1,11 @@ +/* Test __attribute__((deprecated)). Test merging with multiple + declarations. Bug 7425. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void func(void); +void func(void) __attribute__((deprecated)); + +void f(void) { + func(); /* { dg-warning "'func' is deprecated" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/deprecated-4.c b/SingleSource/Regression/C/gcc-dg/deprecated-4.c new file mode 100644 index 0000000000..e8f08176fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/deprecated-4.c @@ -0,0 +1,88 @@ +/* Test __attribute__ ((deprecated("message"))) */ +/* { dg-do compile } */ +/* { dg-options "-Wdeprecated-declarations" } */ + +typedef int INT1 __attribute__((deprecated("Please avoid INT1"))); +typedef INT1 INT2 __attribute__ ((__deprecated__("Please avoid INT2"))); + +typedef INT1 INT1a; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" } */ +typedef INT1 INT1b __attribute__ ((deprecated("Please avoid INT1b"))); + +INT1 should_be_unavailable; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" } */ +INT1a should_not_be_deprecated; + +INT1 f1(void) __attribute__ ((deprecated("Please avoid f1"))); +INT1 f2(void) { return 0; } /* { dg-warning "'INT1' is deprecated: Please avoid INT1" } */ + +INT2 f3(void) __attribute__ ((__deprecated__("Please avoid f3"))); +INT2 f4(void) { return 0; } /* { dg-warning "'INT2' is deprecated: Please avoid INT2" } */ +int f5(INT2 x); /* { dg-warning "'INT2' is deprecated: Please avoid INT2" } */ +int f6(INT2 x) __attribute__ ((__deprecated__("Please avoid f6"))); /* { dg-warning "'INT2' is deprecated: Please avoid INT2" } */ + +typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color"))); + +int g1; +int g2 __attribute__ ((deprecated("Please avoid g2"))); +int g3 __attribute__ ((__deprecated__("Please avoid g3"))); +Color k; /* { dg-warning "'Color' is deprecated: Please avoid Color" } */ + +typedef struct { + int field1; + int field2 __attribute__ ((deprecated("Please avoid field2"))); + int field3; + int field4 __attribute__ ((__deprecated__("Please avoid field4"))); + union { + int field5; + int field6 __attribute__ ((deprecated("Please avoid field6"))); + } u1; + int field7:1; + int field8:1 __attribute__ ((deprecated("Please avoid field8"))); + union { + int field9; + int field10; + } u2 __attribute__ ((deprecated("Please avoid u2"))); +} S1; + +int func1() +{ + INT1 w; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" } */ + int x __attribute__ ((deprecated("Avoid x"))); + int y __attribute__ ((__deprecated__("Bad y"))); + int z; + int (*pf)() = f1; /* { dg-warning "'f1' is deprecated: Please avoid f1" } */ + + z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated: Avoid x" } */ + /* { dg-warning "'y' is deprecated: Bad y" "y" { target *-*-* } .-1 } */ + /* { dg-warning "'g2' is deprecated: Please avoid g2" "g2" { target *-*-* } .-2 } */ + /* { dg-warning "'g3' is deprecated: Please avoid g3" "g3" { target *-*-* } .-3 } */ + return f1(); /* { dg-warning "'f1' is deprecated: Please avoid f1" } */ +} + +int func2(S1 *p) +{ + S1 lp; + + if (p->field1) + return p->field2; /* { dg-warning "'field2' is deprecated: Please avoid field2" } */ + else if (lp.field4) /* { dg-warning "'field4' is deprecated: Please avoid field4" } */ + return p->field3; + + p->u1.field5 = g1 + p->field7; + p->u2.field9; /* { dg-warning "'u2' is deprecated: Please avoid u2" } */ + return p->u1.field6 + p->field8; /* { dg-warning "'field6' is deprecated: Please avoid field6" } */ + /* { dg-warning "'field8' is deprecated: Please avoid field8" "field8" { target *-*-* } .-1 } */ +} + +struct SS1 { + int x; + INT1 y; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" } */ +} __attribute__ ((deprecated("Please avoid SS1"))); + +struct SS1 *p1; /* { dg-warning "'SS1' is deprecated: Please avoid SS1" } */ + +struct __attribute__ ((__deprecated__("Please avoid SS2"))) SS2 { + int x; + INT1 y; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" } */ +}; + +struct SS2 *p2; /* { dg-warning "'SS2' is deprecated: Please avoid SS2" } */ diff --git a/SingleSource/Regression/C/gcc-dg/deprecated-5.c b/SingleSource/Regression/C/gcc-dg/deprecated-5.c new file mode 100644 index 0000000000..a757c4a3dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/deprecated-5.c @@ -0,0 +1,7 @@ +/* Test __attribute__((deprecated)). Test types without names. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a; } __attribute__((deprecated ("Do not use"))) x; /* { dg-warning "type is deprecated" } */ +typeof(x) y; /* { dg-warning "type is deprecated: Do not use" } */ diff --git a/SingleSource/Regression/C/gcc-dg/deprecated-6.c b/SingleSource/Regression/C/gcc-dg/deprecated-6.c new file mode 100644 index 0000000000..a361050dbf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/deprecated-6.c @@ -0,0 +1,11 @@ +/* Test __attribute__((deprecated)). Test merging with multiple + declarations. Bug 7425. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void func(void); +void func(void) __attribute__((deprecated ("Do not use"))); + +void f(void) { + func(); /* { dg-warning "'func' is deprecated: Do not use" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/deprecated.c b/SingleSource/Regression/C/gcc-dg/deprecated.c new file mode 100644 index 0000000000..7579378714 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/deprecated.c @@ -0,0 +1,117 @@ +/* Test __attribute__ ((deprecated)) */ +/* { dg-do compile } */ +/* { dg-options "-Wdeprecated-declarations" } */ + +#if 1 +typedef int INT1 __attribute__((deprecated)); +typedef INT1 INT2 __attribute__ ((__deprecated__)); + +typedef INT1 INT1a; /* { dg-warning "'INT1' is deprecated" } */ +typedef INT1 INT1b __attribute__ ((deprecated)); + +INT1 should_be_unavailable; /* { dg-warning "'INT1' is deprecated" } */ +INT1a should_not_be_deprecated; + +INT1 f1(void) __attribute__ ((deprecated)); +INT1 f2(void) { return 0; } /* { dg-warning "'INT1' is deprecated" } */ + +INT2 f3(void) __attribute__ ((__deprecated__)); +INT2 f4(void) { return 0; } /* { dg-warning "'INT2' is deprecated" } */ +int f5(INT2 x); /* { dg-warning "'INT2' is deprecated" } */ +int f6(INT2 x) __attribute__ ((__deprecated__)); /* { dg-warning "'INT2' is deprecated" } */ + +typedef enum {red, green, blue} Color __attribute__((deprecated)); + +int g1; +int g2 __attribute__ ((deprecated)); +int g3 __attribute__ ((__deprecated__)); +Color k; /* { dg-warning "'Color' is deprecated" } */ + +typedef struct { + int field1; + int field2 __attribute__ ((deprecated)); + int field3; + int field4 __attribute__ ((__deprecated__)); + union { + int field5; + int field6 __attribute__ ((deprecated)); + } u1; + int field7:1; + int field8:1 __attribute__ ((deprecated)); + union { + int field9; + int field10; + } u2 __attribute__ ((deprecated)); +} S1; + +int func1() +{ + INT1 w; /* { dg-warning "'INT1' is deprecated" } */ + int x __attribute__ ((deprecated)); + int y __attribute__ ((__deprecated__)); + int z; + int (*pf)() = f1; /* { dg-warning "'f1' is deprecated" } */ + + z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated" } */ + /* { dg-warning "'y' is deprecated" "y" { target *-*-* } .-1 } */ + /* { dg-warning "'g2' is deprecated" "g2" { target *-*-* } .-2 } */ + /* { dg-warning "'g3' is deprecated" "g3" { target *-*-* } .-3 } */ + return f1(); /* { dg-warning "'f1' is deprecated" "f1" } */ +} + +int func2(S1 *p) +{ + S1 lp; + + if (p->field1) + return p->field2; /* { dg-warning "'field2' is deprecated" } */ + else if (lp.field4) /* { dg-warning "'field4' is deprecated" } */ + return p->field3; + + p->u1.field5 = g1 + p->field7; + p->u2.field9; /* { dg-warning "'u2' is deprecated" } */ + return p->u1.field6 + p->field8; /* { dg-warning "'field6' is deprecated" } */ + /* { dg-warning "'field8' is deprecated" "field8" { target *-*-* } .-1 } */ +} + +struct SS1 { + int x; + INT1 y; /* { dg-warning "'INT1' is deprecated" } */ +} __attribute__ ((deprecated)); + +struct SS1 *p1; /* { dg-warning "'SS1' is deprecated" } */ + +struct __attribute__ ((__deprecated__)) SS2 { + int x; + INT1 y; /* { dg-warning "'INT1' is deprecated" } */ +}; + +struct SS2 *p2; /* { dg-warning "'SS2' is deprecated" } */ +#endif + +#ifdef __cplusplus +class T { + public: + void member1(int) __attribute__ ((deprecated)); + void member2(INT1) __attribute__ ((__deprecated__)); + int member3(T *); + int x; +} __attribute__ ((deprecated)); + +T *p2; + +inline void T::member1(int) {} + +int T::member2(T *p) +{ + p->member1(1); /* { xxdg-warning "'member1' is deprecated" } */ + (*p).member1(2); /* { xxdg-warning "'member1' is deprecated" } */ + p->member2(1); /* { xxdg-warning "'member2' is deprecated" } */ + (*p).member2(2); /* { xxdg-warning "'member2' is deprecated" } */ + p->member3(p); + (*p).member3(p); + return f1(); /* { xxdg-warning "'f1' is deprecated" } */ +} +#endif + + diff --git a/SingleSource/Regression/C/gcc-dg/devnull-dump.c b/SingleSource/Regression/C/gcc-dg/devnull-dump.c new file mode 100644 index 0000000000..378e0901c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/devnull-dump.c @@ -0,0 +1,7 @@ +/* { dg-do assemble } */ +/* { dg-options "-fdump-ipa-clones -o /dev/null" } */ + +int main() +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/dg-test-1.c b/SingleSource/Regression/C/gcc-dg/dg-test-1.c new file mode 100644 index 0000000000..c0e672aaee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dg-test-1.c @@ -0,0 +1,42 @@ +/* Test relative line number specification extensions over what DejaGNU supports. */ +/* { dg-do compile } */ +/* { dg-options "-Wunused-parameter" } */ + +void +foo (void) +{ /* { dg-error "'a' undeclared" "err1" { target *-*-* } .+1 } */ + int z = a + b + c + d;/* { dg-error "'b' undeclared" "err2" } */ +} /* { dg-error "'c' undeclared" "err3" { target *-*-* } .-1 } */ + + +/* { dg-error "'d' undeclared" "err4" { target *-*-* } .-4 } */ +/* { dg-warning "unused parameter 'e'" "warn1" { target *-*-* } .+3 } */ + +void /* { dg-warning "unused parameter 'f'" "warn2" { target *-*-* } .+1 } */ +bar (int e, int f, int g, int h)/* { dg-warning "unused parameter 'g'" "warn3" } */ +{ /* { dg-warning "unused parameter 'h'" "warn4" { target *-*-* } .-1 } */ +} + + +/* Ensure that relative line numbers with more than one digit are supported. */ +/* { dg-warning "unused parameter 'i'" "warn5" { target *-*-* } .+10 } */ + + + + + + + + +void +baz (int i, int j) +{ +} + + + + + + + +/* { dg-warning "unused parameter 'j'" "warn6" { target *-*-* } .-10 } */ diff --git a/SingleSource/Regression/C/gcc-dg/di-longlong64-sync-1.c b/SingleSource/Regression/C/gcc-dg/di-longlong64-sync-1.c new file mode 100644 index 0000000000..b49acd27a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/di-longlong64-sync-1.c @@ -0,0 +1,166 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_long_long_runtime } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-additional-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "fetch_and_nand" { target *-*-* } 0 } */ +/* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "nand_and_fetch" { target *-*-* } 0 } */ + + +/* Test basic functionality of the intrinsics. The operations should + not be optimized away if no one checks the return values. */ + +/* Based on ia64-sync-[12].c, but 1) long on ARM is 32 bit so use long long + (an explicit 64bit type maybe a better bet) and 2) Use values that cross + the 32bit boundary and cause carries since the actual maths are done as + pairs of 32 bit instructions. */ + +/* Note: This file is #included by some of the ARM tests. */ + +__extension__ typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void *memcpy (void *, const void *, size_t); +extern int memcmp (const void *, const void *, size_t); + +/* Temporary space where the work actually gets done. */ +static long long AL[24]; +/* Values copied into AL before we start. */ +static long long init_di[24] = { 0x100000002ll, 0x200000003ll, 0, 1, + + 0x100000002ll, 0x100000002ll, + 0x100000002ll, 0x100000002ll, + + 0, 0x1000e0de0000ll, + 42 , 0xc001c0de0000ll, + + -1ll, 0, 0xff00ff0000ll, -1ll, + + 0, 0x1000e0de0000ll, + 42 , 0xc001c0de0000ll, + + -1ll, 0, 0xff00ff0000ll, -1ll}; +/* This is what should be in AL at the end. */ +static long long test_di[24] = { 0x1234567890ll, 0x1234567890ll, 1, 0, + + 0x100000002ll, 0x100000002ll, + 0x100000002ll, 0x100000002ll, + + 1, 0xc001c0de0000ll, + 20, 0x1000e0de0000ll, + + 0x300000007ll , 0x500000009ll, + 0xf100ff0001ll, ~0xa00000007ll, + + 1, 0xc001c0de0000ll, + 20, 0x1000e0de0000ll, + + 0x300000007ll , 0x500000009ll, + 0xf100ff0001ll, ~0xa00000007ll }; + +/* First check they work in terms of what they do to memory. */ +static void +do_noret_di (void) +{ + __sync_val_compare_and_swap (AL+0, 0x100000002ll, 0x1234567890ll); + __sync_bool_compare_and_swap (AL+1, 0x200000003ll, 0x1234567890ll); + __sync_lock_test_and_set (AL+2, 1); + __sync_lock_release (AL+3); + + /* The following tests should not change the value since the + original does NOT match. */ + __sync_val_compare_and_swap (AL+4, 0x000000002ll, 0x1234567890ll); + __sync_val_compare_and_swap (AL+5, 0x100000000ll, 0x1234567890ll); + __sync_bool_compare_and_swap (AL+6, 0x000000002ll, 0x1234567890ll); + __sync_bool_compare_and_swap (AL+7, 0x100000000ll, 0x1234567890ll); + + __sync_fetch_and_add (AL+8, 1); + __sync_fetch_and_add (AL+9, 0xb000e0000000ll); /* + to both halves & carry. */ + __sync_fetch_and_sub (AL+10, 22); + __sync_fetch_and_sub (AL+11, 0xb000e0000000ll); + + __sync_fetch_and_and (AL+12, 0x300000007ll); + __sync_fetch_and_or (AL+13, 0x500000009ll); + __sync_fetch_and_xor (AL+14, 0xe00000001ll); + __sync_fetch_and_nand (AL+15, 0xa00000007ll); + + /* These should be the same as the fetch_and_* cases except for + return value. */ + __sync_add_and_fetch (AL+16, 1); + /* add to both halves & carry. */ + __sync_add_and_fetch (AL+17, 0xb000e0000000ll); + __sync_sub_and_fetch (AL+18, 22); + __sync_sub_and_fetch (AL+19, 0xb000e0000000ll); + + __sync_and_and_fetch (AL+20, 0x300000007ll); + __sync_or_and_fetch (AL+21, 0x500000009ll); + __sync_xor_and_fetch (AL+22, 0xe00000001ll); + __sync_nand_and_fetch (AL+23, 0xa00000007ll); +} + +/* Now check return values. */ +static void +do_ret_di (void) +{ + if (__sync_val_compare_and_swap (AL+0, 0x100000002ll, 0x1234567890ll) != + 0x100000002ll) abort (); + if (__sync_bool_compare_and_swap (AL+1, 0x200000003ll, 0x1234567890ll) != + 1) abort (); + if (__sync_lock_test_and_set (AL+2, 1) != 0) abort (); + __sync_lock_release (AL+3); /* no return value, but keep to match results. */ + + /* The following tests should not change the value since the + original does NOT match. */ + if (__sync_val_compare_and_swap (AL+4, 0x000000002ll, 0x1234567890ll) != + 0x100000002ll) abort (); + if (__sync_val_compare_and_swap (AL+5, 0x100000000ll, 0x1234567890ll) != + 0x100000002ll) abort (); + if (__sync_bool_compare_and_swap (AL+6, 0x000000002ll, 0x1234567890ll) != + 0) abort (); + if (__sync_bool_compare_and_swap (AL+7, 0x100000000ll, 0x1234567890ll) != + 0) abort (); + + if (__sync_fetch_and_add (AL+8, 1) != 0) abort (); + if (__sync_fetch_and_add (AL+9, 0xb000e0000000ll) != 0x1000e0de0000ll) abort (); + if (__sync_fetch_and_sub (AL+10, 22) != 42) abort (); + if (__sync_fetch_and_sub (AL+11, 0xb000e0000000ll) != 0xc001c0de0000ll) + abort (); + + if (__sync_fetch_and_and (AL+12, 0x300000007ll) != -1ll) abort (); + if (__sync_fetch_and_or (AL+13, 0x500000009ll) != 0) abort (); + if (__sync_fetch_and_xor (AL+14, 0xe00000001ll) != 0xff00ff0000ll) abort (); + if (__sync_fetch_and_nand (AL+15, 0xa00000007ll) != -1ll) abort (); + + /* These should be the same as the fetch_and_* cases except for + return value. */ + if (__sync_add_and_fetch (AL+16, 1) != 1) abort (); + if (__sync_add_and_fetch (AL+17, 0xb000e0000000ll) != 0xc001c0de0000ll) + abort (); + if (__sync_sub_and_fetch (AL+18, 22) != 20) abort (); + if (__sync_sub_and_fetch (AL+19, 0xb000e0000000ll) != 0x1000e0de0000ll) + abort (); + + if (__sync_and_and_fetch (AL+20, 0x300000007ll) != 0x300000007ll) abort (); + if (__sync_or_and_fetch (AL+21, 0x500000009ll) != 0x500000009ll) abort (); + if (__sync_xor_and_fetch (AL+22, 0xe00000001ll) != 0xf100ff0001ll) abort (); + if (__sync_nand_and_fetch (AL+23, 0xa00000007ll) != ~0xa00000007ll) abort (); +} + +int main () +{ + memcpy (AL, init_di, sizeof (init_di)); + + do_noret_di (); + + if (memcmp (AL, test_di, sizeof (test_di))) + abort (); + + memcpy (AL, init_di, sizeof (init_di)); + + do_ret_di (); + + if (memcmp (AL, test_di, sizeof (test_di))) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/di-sync-multithread.c b/SingleSource/Regression/C/gcc-dg/di-sync-multithread.c new file mode 100644 index 0000000000..1a97df7a9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/di-sync-multithread.c @@ -0,0 +1,221 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_long_long_runtime } */ +/* { dg-require-effective-target pthread_h } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-pthread -std=gnu99" } */ +/* { dg-additional-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* test of long long atomic ops performed in parallel in 3 pthreads + david.gilbert@linaro.org */ + +#include +#include +#ifdef _WIN32 +#include +#endif + +/*#define DEBUGIT 1 */ + +#ifdef DEBUGIT +#include + +#define DOABORT(x,...) {\ + fprintf (stderr, x, __VA_ARGS__); fflush (stderr); abort ();\ + } + +#else + +#define DOABORT(x,...) abort (); + +#endif + +/* Passed to each thread to describe which bits it is going to work on. */ +struct threadwork { + unsigned long long count; /* incremented each time the worker loops. */ + unsigned int thread; /* ID */ + unsigned int addlsb; /* 8 bit */ + unsigned int logic1lsb; /* 5 bit */ + unsigned int logic2lsb; /* 8 bit */ +}; + +/* The shared word where all the atomic work is done. */ +static volatile long long workspace; + +/* A shared word to tell the workers to quit when non-0. */ +static long long doquit; + +extern void abort (void); + +/* Note this test doesn't test the return values much. */ +void* +worker (void* data) +{ + struct threadwork *tw = (struct threadwork*)data; + long long add1bit = 1ll << tw->addlsb; + long long logic1bit = 1ll << tw->logic1lsb; + long long logic2bit = 1ll << tw->logic2lsb; + + /* Clear the bits we use. */ + __sync_and_and_fetch (&workspace, ~(0xffll * add1bit)); + __sync_fetch_and_and (&workspace, ~(0x1fll * logic1bit)); + __sync_fetch_and_and (&workspace, ~(0xffll * logic2bit)); + + do + { + long long tmp1, tmp2, tmp3; + /* OK, lets try and do some stuff to the workspace - by the end + of the main loop our area should be the same as it is now - i.e. 0. */ + + /* Push the arithmetic section up to 128 - one of the threads will + case this to carry across the 32bit boundary. */ + for (tmp2 = 0; tmp2 < 64; tmp2++) + { + sched_yield (); + + /* Add 2 using the two different adds. */ + tmp1 = __sync_add_and_fetch (&workspace, add1bit); + tmp3 = __sync_fetch_and_add (&workspace, add1bit); + + /* The value should be the intermediate add value in both cases. */ + if ((tmp1 & (add1bit * 0xff)) != (tmp3 & (add1bit * 0xff))) + DOABORT ("Mismatch of add intermediates on thread %d " + "workspace=0x%llx tmp1=0x%llx " + "tmp2=0x%llx tmp3=0x%llx\n", + tw->thread, workspace, tmp1, tmp2, tmp3); + } + + /* Set the logic bits. */ + tmp2=__sync_or_and_fetch (&workspace, + 0x1fll * logic1bit | 0xffll * logic2bit); + + /* Check the logic bits are set and the arithmetic value is correct. */ + if ((tmp2 & (0x1fll * logic1bit | 0xffll * logic2bit + | 0xffll * add1bit)) + != (0x1fll * logic1bit | 0xffll * logic2bit | 0x80ll * add1bit)) + DOABORT ("Midloop check failed on thread %d " + "workspace=0x%llx tmp2=0x%llx " + "masktmp2=0x%llx expected=0x%llx\n", + tw->thread, workspace, tmp2, + tmp2 & (0x1fll * logic1bit | 0xffll * logic2bit | + 0xffll * add1bit), + (0x1fll * logic1bit | 0xffll * logic2bit | 0x80ll * add1bit)); + + /* Pull the arithmetic set back down to 0 - again this should cause a + carry across the 32bit boundary in one thread. */ + + for (tmp2 = 0; tmp2 < 64; tmp2++) + { + sched_yield (); + + /* Subtract 2 using the two different subs. */ + tmp1=__sync_sub_and_fetch (&workspace, add1bit); + tmp3=__sync_fetch_and_sub (&workspace, add1bit); + + /* The value should be the intermediate sub value in both cases. */ + if ((tmp1 & (add1bit * 0xff)) != (tmp3 & (add1bit * 0xff))) + DOABORT ("Mismatch of sub intermediates on thread %d " + "workspace=0x%llx tmp1=0x%llx " + "tmp2=0x%llx tmp3=0x%llx\n", + tw->thread, workspace, tmp1, tmp2, tmp3); + } + + + /* Clear the logic bits. */ + __sync_fetch_and_xor (&workspace, 0x1fll * logic1bit); + tmp3=__sync_and_and_fetch (&workspace, ~(0xffll * logic2bit)); + + /* The logic bits and the arithmetic bits should be zero again. */ + if (tmp3 & (0x1fll * logic1bit | 0xffll * logic2bit | 0xffll * add1bit)) + DOABORT ("End of worker loop; bits none 0 on thread %d " + "workspace=0x%llx tmp3=0x%llx " + "mask=0x%llx maskedtmp3=0x%llx\n", + tw->thread, workspace, tmp3, (0x1fll * logic1bit | + 0xffll * logic2bit | 0xffll * add1bit), + tmp3 & (0x1fll * logic1bit | 0xffll * logic2bit | 0xffll * add1bit)); + + __sync_add_and_fetch (&tw->count, 1); + } + while (!__sync_bool_compare_and_swap (&doquit, 1, 1)); + + pthread_exit (0); +} + +int +main () +{ + /* We have 3 threads doing three sets of operations, an 8 bit + arithmetic field, a 5 bit logic field and an 8 bit logic + field (just to pack them all in). + + 6 5 4 4 3 2 1 + 3 6 8 0 2 4 6 8 0 + |...,...|...,...|...,...|...,...|...,...|...,...|...,...|...,... + - T0 -- T1 -- T2 --T2 -- T0 -*- T2-- T1-- T1 -***- T0- + logic2 logic2 arith log2 arith log1 log1 arith log1 + + */ + unsigned int t; + long long tmp; + int err; + + struct threadwork tw[3]={ + { 0ll, 0, 27, 0, 56 }, + { 0ll, 1, 8,16, 48 }, + { 0ll, 2, 40,21, 35 } + }; + + pthread_t threads[3]; + + __sync_lock_release (&doquit); + + /* Get the work space into a known value - All 1's. */ + __sync_lock_release (&workspace); /* Now all 0. */ + tmp = __sync_val_compare_and_swap (&workspace, 0, -1ll); + if (tmp!=0) + DOABORT ("Initial __sync_val_compare_and_swap wasn't 0 workspace=0x%llx " + "tmp=0x%llx\n", workspace,tmp); + + for (t = 0; t < 3; t++) + { + err=pthread_create (&threads[t], NULL , worker, &tw[t]); + if (err) DOABORT ("pthread_create failed on thread %d with error %d\n", + t, err); + }; + + sched_yield (); + +#ifdef _WIN32 + Sleep (5000); +#else + sleep (5); +#endif + + /* Stop please. */ + __sync_lock_test_and_set (&doquit, 1ll); + + sched_yield (); + + for (t = 0; t < 3; t++) + { + err=pthread_join (threads[t], NULL); + if (err) + DOABORT ("pthread_join failed on thread %d with error %d\n", t, err); + }; + + __sync_synchronize (); + + /* OK, so all the workers have finished - + the workers should have zero'd their workspace, the unused areas + should still be 1. */ + if (!__sync_bool_compare_and_swap (&workspace, 0x040000e0ll, 0)) + DOABORT ("End of run workspace mismatch, got %llx\n", workspace); + + /* All the workers should have done some work. */ + for (t = 0; t < 3; t++) + { + if (tw[t].count == 0) DOABORT ("Worker %d gave 0 count\n", t); + }; + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/diag-aka-1.c b/SingleSource/Regression/C/gcc-dg/diag-aka-1.c new file mode 100644 index 0000000000..3383c1c263 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diag-aka-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +typedef struct A { int i; } B; +typedef struct T { int i; } *T; /* { dg-warning "using 'T' as both a typedef and a tag is invalid" } */ +typedef const float TFA; +typedef TFA TFB; +typedef TFB TFC; +typedef int IA[]; +typedef IA *IAP; +extern IAP arr[]; + +void fn1 (B *); /* { dg-message "expected 'B \\*' {aka 'struct A \\*'} but argument is of type 'struct B \\*'" } */ +void fn2 (TFC *); + +void +bar (B *b, int *i) +{ + fn1 ((struct B *) b); /* { dg-warning "passing argument" } */ + fn2 (i); /* { dg-warning "passing argument" } */ + sizeof (arr); /* { dg-error "invalid application of .sizeof. to incomplete type .int \\(\\*\\\[\\\]\\)\\\[\\\]." } */ +} + +int +foo (void *a) +{ + T t = a; /* { dg-warning "request for implicit conversion from 'void \\*' to 'T' {aka 'struct T \\*'} not" } */ + return t->i; +} diff --git a/SingleSource/Regression/C/gcc-dg/diag-aka-2.c b/SingleSource/Regression/C/gcc-dg/diag-aka-2.c new file mode 100644 index 0000000000..a4b22429c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diag-aka-2.c @@ -0,0 +1,12 @@ +/* Verify that the "aka" descriptions for typedefs are correctly + quoted (PR 62170). */ + +typedef struct s1 t1; + +int foo(t1 *); /* { dg-message "expected 't1 \\*' {aka 'struct s1 \\*'} but argument is of type 't2 \\*' {aka 'struct s2 \\*'}" } */ + +int bar() { + typedef struct s2 {int i;} t2; + t2 pos; + return foo(&pos); /* { dg-error "incompatible pointer type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diag-aka-3.c b/SingleSource/Regression/C/gcc-dg/diag-aka-3.c new file mode 100644 index 0000000000..a3778ed7d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diag-aka-3.c @@ -0,0 +1,9 @@ +typedef unsigned int myvec __attribute__((vector_size (16))); + +void f (float x) +{ + myvec y = x; /* { dg-error {incompatible types when initializing type 'myvec' {aka '__vector\([48]\) unsigned int'} using type 'float'} } */ + myvec *ptr = &x; /* { dg-error {initialization of 'myvec \*' {aka '__vector\([48]\) unsigned int \*'} from incompatible pointer type 'float \*'} } */ + const myvec *const_ptr = &x; /* { dg-error {initialization of 'const myvec \*' {aka 'const __vector\([48]\) unsigned int \*'} from incompatible pointer type 'float \*'} } */ + volatile myvec *volatile_ptr = &x; /* { dg-error {initialization of 'volatile myvec \*' {aka 'volatile __vector\([48]\) unsigned int \*'} from incompatible pointer type 'float \*'} } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diag-aka-4.c b/SingleSource/Regression/C/gcc-dg/diag-aka-4.c new file mode 100644 index 0000000000..cf98dd96a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diag-aka-4.c @@ -0,0 +1,72 @@ +typedef struct struct_wrapper { int i; } struct_wrapper; +typedef struct { int i; } anon_struct_wrapper; + +typedef union union_wrapper { int i; } union_wrapper; +typedef union { int i; } anon_union_wrapper; + +typedef enum enum_wrapper { A, B } enum_wrapper; +typedef enum { C, D } anon_enum_wrapper; + +void test_struct_wrapper (struct_wrapper y, int x) +{ + struct_wrapper *ptr = &x; /* { dg-error {initialization of 'struct_wrapper \*' from incompatible pointer type 'int \*'} } */ + const struct_wrapper *const_ptr = &x; /* { dg-error {initialization of 'const struct_wrapper \*' from incompatible pointer type 'int \*'} } */ + volatile struct_wrapper *volatile_ptr = &x; /* { dg-error {initialization of 'volatile struct_wrapper \*' from incompatible pointer type 'int \*'} } */ + struct_wrapper (*aptr)[10] = &x; /* { dg-error {initialization of 'struct_wrapper \(\*\)\[10\]' from incompatible pointer type 'int \*'} } */ + struct_wrapper (*f1)(int) = &x; /* { dg-error {initialization of 'struct_wrapper \(\*\)\(int\)' from incompatible pointer type 'int \*'} } */ + int (*f2)(struct_wrapper) = &x; /* { dg-error {initialization of 'int \(\*\)\(struct_wrapper\)' from incompatible pointer type 'int \*'} } */ + y = x; /* { dg-error {incompatible types when assigning to type 'struct_wrapper' from type 'int'} } */ +} + +void test_anon_struct_wrapper (anon_struct_wrapper y, int x) +{ + anon_struct_wrapper *ptr = &x; /* { dg-error {initialization of 'anon_struct_wrapper \*' from incompatible pointer type 'int \*'} } */ + const anon_struct_wrapper *const_ptr = &x; /* { dg-error {initialization of 'const anon_struct_wrapper \*' from incompatible pointer type 'int \*'} } */ + volatile anon_struct_wrapper *volatile_ptr = &x; /* { dg-error {initialization of 'volatile anon_struct_wrapper \*' from incompatible pointer type 'int \*'} } */ + anon_struct_wrapper (*aptr)[10] = &x; /* { dg-error {initialization of 'anon_struct_wrapper \(\*\)\[10\]' from incompatible pointer type 'int \*'} } */ + anon_struct_wrapper (*f1)(int) = &x; /* { dg-error {initialization of 'anon_struct_wrapper \(\*\)\(int\)' from incompatible pointer type 'int \*'} } */ + int (*f2)(anon_struct_wrapper) = &x; /* { dg-error {initialization of 'int \(\*\)\(anon_struct_wrapper\)' from incompatible pointer type 'int \*'} } */ + y = x; /* { dg-error {incompatible types when assigning to type 'anon_struct_wrapper' from type 'int'} } */ +} + +void test_union_wrapper (union_wrapper y, int x) +{ + union_wrapper *ptr = &x; /* { dg-error {initialization of 'union_wrapper \*' from incompatible pointer type 'int \*'} } */ + const union_wrapper *const_ptr = &x; /* { dg-error {initialization of 'const union_wrapper \*' from incompatible pointer type 'int \*'} } */ + volatile union_wrapper *volatile_ptr = &x; /* { dg-error {initialization of 'volatile union_wrapper \*' from incompatible pointer type 'int \*'} } */ + union_wrapper (*aptr)[10] = &x; /* { dg-error {initialization of 'union_wrapper \(\*\)\[10\]' from incompatible pointer type 'int \*'} } */ + union_wrapper (*f1)(int) = &x; /* { dg-error {initialization of 'union_wrapper \(\*\)\(int\)' from incompatible pointer type 'int \*'} } */ + int (*f2)(union_wrapper) = &x; /* { dg-error {initialization of 'int \(\*\)\(union_wrapper\)' from incompatible pointer type 'int \*'} } */ + y = x; /* { dg-error {incompatible types when assigning to type 'union_wrapper' from type 'int'} } */ +} + +void test_anon_union_wrapper (anon_union_wrapper y, int x) +{ + anon_union_wrapper *ptr = &x; /* { dg-error {initialization of 'anon_union_wrapper \*' from incompatible pointer type 'int \*'} } */ + const anon_union_wrapper *const_ptr = &x; /* { dg-error {initialization of 'const anon_union_wrapper \*' from incompatible pointer type 'int \*'} } */ + volatile anon_union_wrapper *volatile_ptr = &x; /* { dg-error {initialization of 'volatile anon_union_wrapper \*' from incompatible pointer type 'int \*'} } */ + anon_union_wrapper (*aptr)[10] = &x; /* { dg-error {initialization of 'anon_union_wrapper \(\*\)\[10\]' from incompatible pointer type 'int \*'} } */ + anon_union_wrapper (*f1)(int) = &x; /* { dg-error {initialization of 'anon_union_wrapper \(\*\)\(int\)' from incompatible pointer type 'int \*'} } */ + int (*f2)(anon_union_wrapper) = &x; /* { dg-error {initialization of 'int \(\*\)\(anon_union_wrapper\)' from incompatible pointer type 'int \*'} } */ + y = x; /* { dg-error {incompatible types when assigning to type 'anon_union_wrapper' from type 'int'} } */ +} + +void test_enum_wrapper (enum_wrapper y, int x) +{ + enum_wrapper *ptr = &x; /* { dg-error {initialization of 'enum_wrapper \*' from incompatible pointer type 'int \*'} } */ + const enum_wrapper *const_ptr = &x; /* { dg-error {initialization of 'const enum_wrapper \*' from incompatible pointer type 'int \*'} } */ + volatile enum_wrapper *volatile_ptr = &x; /* { dg-error {initialization of 'volatile enum_wrapper \*' from incompatible pointer type 'int \*'} } */ + enum_wrapper (*aptr)[10] = &x; /* { dg-error {initialization of 'enum_wrapper \(\*\)\[10\]' from incompatible pointer type 'int \*'} } */ + enum_wrapper (*f1)(int) = &x; /* { dg-error {initialization of 'enum_wrapper \(\*\)\(int\)' from incompatible pointer type 'int \*'} } */ + int (*f2)(enum_wrapper) = &x; /* { dg-error {initialization of 'int \(\*\)\(enum_wrapper\)' from incompatible pointer type 'int \*'} } */ +} + +void test_anon_enum_wrapper (anon_enum_wrapper y, int x) +{ + anon_enum_wrapper *ptr = &x; /* { dg-error {initialization of 'anon_enum_wrapper \*' from incompatible pointer type 'int \*'} } */ + const anon_enum_wrapper *const_ptr = &x; /* { dg-error {initialization of 'const anon_enum_wrapper \*' from incompatible pointer type 'int \*'} } */ + volatile anon_enum_wrapper *volatile_ptr = &x; /* { dg-error {initialization of 'volatile anon_enum_wrapper \*' from incompatible pointer type 'int \*'} } */ + anon_enum_wrapper (*aptr)[10] = &x; /* { dg-error {initialization of 'anon_enum_wrapper \(\*\)\[10\]' from incompatible pointer type 'int \*'} } */ + anon_enum_wrapper (*f1)(int) = &x; /* { dg-error {initialization of 'anon_enum_wrapper \(\*\)\(int\)' from incompatible pointer type 'int \*'} } */ + int (*f2)(anon_enum_wrapper) = &x; /* { dg-error {initialization of 'int \(\*\)\(anon_enum_wrapper\)' from incompatible pointer type 'int \*'} } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diag-aka-5.h b/SingleSource/Regression/C/gcc-dg/diag-aka-5.h new file mode 100644 index 0000000000..0c7404d766 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diag-aka-5.h @@ -0,0 +1,22 @@ +#ifdef IS_SYSTEM_HEADER +#pragma GCC system_header +#endif + +typedef enum __internal_enum { A, B } user_enum; +typedef user_enum *user_enum_ptr; + +typedef struct __internal_struct { int i; } user_struct; +typedef user_struct user_struct_copy; +typedef user_struct *user_struct_ptr; + +typedef union __internal_union { int i; } user_union; +typedef user_union user_union_copy; +typedef user_union *user_union_ptr; + +typedef unsigned int user_vector __attribute__((__vector_size__(16))); +typedef user_vector user_vector_copy; +typedef user_vector *user_vector_ptr; + +typedef int user_int; +typedef user_int user_int_copy; +typedef user_int *user_int_ptr; diff --git a/SingleSource/Regression/C/gcc-dg/diag-aka-5a.c b/SingleSource/Regression/C/gcc-dg/diag-aka-5a.c new file mode 100644 index 0000000000..8768a79204 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diag-aka-5a.c @@ -0,0 +1,135 @@ +#define IS_SYSTEM_HEADER +#include "diag-aka-5.h" + +typedef user_enum user_enum_copy; + +struct s { int i; }; + +user_enum ue1; +user_enum_copy ue2; +user_enum_ptr ue_ptr1; +user_enum *ue_ptr2; +const user_enum *const_ue_ptr1; +const user_enum_copy *const_ue_ptr2; +volatile user_enum *volatile_ue_ptr1; +volatile user_enum_copy *volatile_ue_ptr2; +__extension__ _Atomic user_enum *atomic_ue_ptr1; +__extension__ _Atomic user_enum_copy *atomic_ue_ptr2; +user_enum (*ue_array_ptr1)[10]; +user_enum_copy (*ue_array_ptr2)[10]; +user_enum (*ue_fn_ptr1) (void); +void (*ue_fn_ptr2) (user_enum); +void (*ue_fn_ptr3) (user_enum, ...); +user_enum_copy (*ue_fn_ptr4) (void); +void (*ue_fn_ptr5) (user_enum_copy); +void (*ue_fn_ptr6) (user_enum_copy, ...); +user_enum (*__attribute__((__transaction_unsafe__)) unsafe_ue_fn_ptr1) (void); +user_enum_copy (*__attribute__((__transaction_unsafe__)) unsafe_ue_fn_ptr2) (void); + +user_struct us1; +user_struct_copy us2; +user_struct_ptr us_ptr1; +user_struct *us_ptr2; +const user_struct *const_us_ptr1; +const user_struct_copy *const_us_ptr2; + +user_union uu1; +user_union_copy uu2; +user_union_ptr uu_ptr1; +user_union *uu_ptr2; +const user_union *const_uu_ptr1; +const user_union_copy *const_uu_ptr2; + +user_vector uv1; +user_vector_copy uv2; +user_vector_ptr uv_ptr1; +user_vector *uv_ptr2; +const user_vector *const_uv_ptr1; +const user_vector_copy *const_uv_ptr2; + +user_int ui1; +user_int_copy ui2; +user_int_ptr ui_ptr1; +user_int *ui_ptr2; +const user_int *const_ui_ptr1; +const user_int_copy *const_ui_ptr2; +volatile user_int *volatile_ui_ptr1; +volatile user_int_copy *volatile_ui_ptr2; +__extension__ _Atomic user_int *atomic_ui_ptr1; +__extension__ _Atomic user_int_copy *atomic_ui_ptr2; +user_int (*ui_array_ptr1)[10]; +user_int_copy (*ui_array_ptr2)[10]; +user_int (*ui_fn_ptr1) (void); +void (*ui_fn_ptr2) (user_int); +void (*ui_fn_ptr3) (user_int, ...); +user_int_copy (*ui_fn_ptr4) (void); +void (*ui_fn_ptr5) (user_int_copy); +void (*ui_fn_ptr6) (user_int_copy, ...); +user_int (*__attribute__((__transaction_unsafe__)) unsafe_ui_fn_ptr1) (void); +user_int_copy (*__attribute__((__transaction_unsafe__)) unsafe_ui_fn_ptr2) (void); + +void f (struct s s) +{ + ue1 = s; /* { dg-error {assigning to type 'user_enum' from type 'struct s'} } */ + ue2 = s; /* { dg-error {assigning to type 'user_enum_copy' {aka 'user_enum'} from type 'struct s'} } */ + ue_ptr1 = &s; /* { dg-error {assignment to 'user_enum_ptr' {aka 'user_enum \*'} from incompatible pointer type 'struct s \*'} } */ + ue_ptr2 = &s; /* { dg-error {assignment to 'user_enum \*' from incompatible pointer type 'struct s \*'} } */ + const_ue_ptr1 = &s; /* { dg-error {assignment to 'const user_enum \*' from incompatible pointer type 'struct s \*'} } */ + const_ue_ptr2 = &s; /* { dg-error {assignment to 'const user_enum_copy \*' {aka 'const user_enum \*'} from incompatible pointer type 'struct s \*'} } */ + volatile_ue_ptr1 = &s; /* { dg-error {assignment to 'volatile user_enum \*' from incompatible pointer type 'struct s \*'} } */ + volatile_ue_ptr2 = &s; /* { dg-error {assignment to 'volatile user_enum_copy \*' {aka 'volatile user_enum \*'} from incompatible pointer type 'struct s \*'} } */ + atomic_ue_ptr1 = &s; /* { dg-error {assignment to '_Atomic user_enum \*' from incompatible pointer type 'struct s \*'} } */ + atomic_ue_ptr2 = &s; /* { dg-error {assignment to '_Atomic user_enum_copy \*' {aka '_Atomic user_enum \*'} from incompatible pointer type 'struct s \*'} } */ + ue_array_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(\*\)\[10\]' from incompatible pointer type 'struct s \*'} } */ + ue_array_ptr2 = &s; /* { dg-error {assignment to 'user_enum_copy \(\*\)\[10\]' {aka 'user_enum \(\*\)\[10\]'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(\*\)\(void\)' from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr2 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum\)' from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr3 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum, \.\.\.\)' from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr4 = &s; /* { dg-error {assignment to 'user_enum_copy \(\*\)\(void\)' {aka 'user_enum \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr5 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum_copy\)' {aka 'void \(\*\)\(user_enum\)'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr6 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum_copy, \.\.\.\)' {aka 'void \(\*\)\(user_enum, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ue_fn_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' from incompatible pointer type 'struct s \*'} } */ + unsafe_ue_fn_ptr2 = &s; /* { dg-error {assignment to 'user_enum_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + + us1 = s; /* { dg-error {assigning to type 'user_struct' from type 'struct s'} } */ + us2 = s; /* { dg-error {assigning to type 'user_struct_copy' {aka 'user_struct'} from type 'struct s'} } */ + us_ptr1 = &s; /* { dg-error {assignment to 'user_struct_ptr' {aka 'user_struct \*'} from incompatible pointer type 'struct s \*'} } */ + us_ptr2 = &s; /* { dg-error {assignment to 'user_struct \*' from incompatible pointer type 'struct s \*'} } */ + const_us_ptr1 = &s; /* { dg-error {assignment to 'const user_struct \*' from incompatible pointer type 'struct s \*'} } */ + const_us_ptr2 = &s; /* { dg-error {assignment to 'const user_struct_copy \*' {aka 'const user_struct \*'} from incompatible pointer type 'struct s \*'} } */ + + uu1 = s; /* { dg-error {assigning to type 'user_union' from type 'struct s'} } */ + uu2 = s; /* { dg-error {assigning to type 'user_union_copy' {aka 'user_union'} from type 'struct s'} } */ + uu_ptr1 = &s; /* { dg-error {assignment to 'user_union_ptr' {aka 'user_union \*'} from incompatible pointer type 'struct s \*'} } */ + uu_ptr2 = &s; /* { dg-error {assignment to 'user_union \*' from incompatible pointer type 'struct s \*'} } */ + const_uu_ptr1 = &s; /* { dg-error {assignment to 'const user_union \*' from incompatible pointer type 'struct s \*'} } */ + const_uu_ptr2 = &s; /* { dg-error {assignment to 'const user_union_copy \*' {aka 'const user_union \*'} from incompatible pointer type 'struct s \*'} } */ + + uv1 = s; /* { dg-error {assigning to type 'user_vector' from type 'struct s'} } */ + uv2 = s; /* { dg-error {assigning to type 'user_vector_copy' {aka 'user_vector'} from type 'struct s'} } */ + uv_ptr1 = &s; /* { dg-error {assignment to 'user_vector_ptr' {aka 'user_vector \*'} from incompatible pointer type 'struct s \*'} } */ + uv_ptr2 = &s; /* { dg-error {assignment to 'user_vector \*' from incompatible pointer type 'struct s \*'} } */ + const_uv_ptr1 = &s; /* { dg-error {assignment to 'const user_vector \*' from incompatible pointer type 'struct s \*'} } */ + const_uv_ptr2 = &s; /* { dg-error {assignment to 'const user_vector_copy \*' {aka 'const user_vector \*'} from incompatible pointer type 'struct s \*'} } */ + + ui1 = s; /* { dg-error {assigning to type 'user_int' {aka 'int'} from type 'struct s'} } */ + ui2 = s; /* { dg-error {assigning to type 'user_int_copy' {aka 'int'} from type 'struct s'} } */ + ui_ptr1 = &s; /* { dg-error {assignment to 'user_int_ptr' {aka 'int \*'} from incompatible pointer type 'struct s \*'} } */ + ui_ptr2 = &s; /* { dg-error {assignment to 'user_int \*' {aka 'int \*'} from incompatible pointer type 'struct s \*'} } */ + const_ui_ptr1 = &s; /* { dg-error {assignment to 'const user_int \*' {aka 'const int \*'} from incompatible pointer type 'struct s \*'} } */ + const_ui_ptr2 = &s; /* { dg-error {assignment to 'const user_int_copy \*' {aka 'const int \*'} from incompatible pointer type 'struct s \*'} } */ + volatile_ui_ptr1 = &s; /* { dg-error {assignment to 'volatile user_int \*' {aka 'volatile int \*'} from incompatible pointer type 'struct s \*'} } */ + volatile_ui_ptr2 = &s; /* { dg-error {assignment to 'volatile user_int_copy \*' {aka 'volatile int \*'} from incompatible pointer type 'struct s \*'} } */ + atomic_ui_ptr1 = &s; /* { dg-error {assignment to '_Atomic user_int \*' {aka '_Atomic int \*'} from incompatible pointer type 'struct s \*'} } */ + atomic_ui_ptr2 = &s; /* { dg-error {assignment to '_Atomic user_int_copy \*' {aka '_Atomic int \*'} from incompatible pointer type 'struct s \*'} } */ + ui_array_ptr1 = &s; /* { dg-error {assignment to 'user_int \(\*\)\[10\]' {aka 'int \(\*\)\[10\]'} from incompatible pointer type 'struct s \*'} } */ + ui_array_ptr2 = &s; /* { dg-error {assignment to 'user_int_copy \(\*\)\[10\]' {aka 'int \(\*\)\[10\]'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr1 = &s; /* { dg-error {assignment to 'user_int \(\*\)\(void\)' {aka 'int \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr2 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int\)' {aka 'void \(\*\)\(int\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr3 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int, \.\.\.\)' {aka 'void \(\*\)\(int, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr4 = &s; /* { dg-error {assignment to 'user_int_copy \(\*\)\(void\)' {aka 'int \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr5 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int_copy\)' {aka 'void \(\*\)\(int\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr6 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int_copy, \.\.\.\)' {aka 'void \(\*\)\(int, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ui_fn_ptr1 = &s; /* { dg-error {assignment to 'user_int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ui_fn_ptr2 = &s; /* { dg-error {assignment to 'user_int_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diag-aka-5b.c b/SingleSource/Regression/C/gcc-dg/diag-aka-5b.c new file mode 100644 index 0000000000..e0ec7c816a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diag-aka-5b.c @@ -0,0 +1,134 @@ +#include "diag-aka-5.h" + +typedef user_enum user_enum_copy; + +struct s { int i; }; + +user_enum ue1; +user_enum_copy ue2; +user_enum_ptr ue_ptr1; +user_enum *ue_ptr2; +const user_enum *const_ue_ptr1; +const user_enum_copy *const_ue_ptr2; +volatile user_enum *volatile_ue_ptr1; +volatile user_enum_copy *volatile_ue_ptr2; +__extension__ _Atomic user_enum *atomic_ue_ptr1; +__extension__ _Atomic user_enum_copy *atomic_ue_ptr2; +user_enum (*ue_array_ptr1)[10]; +user_enum_copy (*ue_array_ptr2)[10]; +user_enum (*ue_fn_ptr1) (void); +void (*ue_fn_ptr2) (user_enum); +void (*ue_fn_ptr3) (user_enum, ...); +user_enum_copy (*ue_fn_ptr4) (void); +void (*ue_fn_ptr5) (user_enum_copy); +void (*ue_fn_ptr6) (user_enum_copy, ...); +user_enum (*__attribute__((__transaction_unsafe__)) unsafe_ue_fn_ptr1) (void); +user_enum_copy (*__attribute__((__transaction_unsafe__)) unsafe_ue_fn_ptr2) (void); + +user_struct us1; +user_struct_copy us2; +user_struct_ptr us_ptr1; +user_struct *us_ptr2; +const user_struct *const_us_ptr1; +const user_struct_copy *const_us_ptr2; + +user_union uu1; +user_union_copy uu2; +user_union_ptr uu_ptr1; +user_union *uu_ptr2; +const user_union *const_uu_ptr1; +const user_union_copy *const_uu_ptr2; + +user_vector uv1; +user_vector_copy uv2; +user_vector_ptr uv_ptr1; +user_vector *uv_ptr2; +const user_vector *const_uv_ptr1; +const user_vector_copy *const_uv_ptr2; + +user_int ui1; +user_int_copy ui2; +user_int_ptr ui_ptr1; +user_int *ui_ptr2; +const user_int *const_ui_ptr1; +const user_int_copy *const_ui_ptr2; +volatile user_int *volatile_ui_ptr1; +volatile user_int_copy *volatile_ui_ptr2; +__extension__ _Atomic user_int *atomic_ui_ptr1; +__extension__ _Atomic user_int_copy *atomic_ui_ptr2; +user_int (*ui_array_ptr1)[10]; +user_int_copy (*ui_array_ptr2)[10]; +user_int (*ui_fn_ptr1) (void); +void (*ui_fn_ptr2) (user_int); +void (*ui_fn_ptr3) (user_int, ...); +user_int_copy (*ui_fn_ptr4) (void); +void (*ui_fn_ptr5) (user_int_copy); +void (*ui_fn_ptr6) (user_int_copy, ...); +user_int (*__attribute__((__transaction_unsafe__)) unsafe_ui_fn_ptr1) (void); +user_int_copy (*__attribute__((__transaction_unsafe__)) unsafe_ui_fn_ptr2) (void); + +void f (struct s s) +{ + ue1 = s; /* { dg-error {assigning to type 'user_enum' {aka 'enum __internal_enum'} from type 'struct s'} } */ + ue2 = s; /* { dg-error {assigning to type 'user_enum_copy' {aka 'enum __internal_enum'} from type 'struct s'} } */ + ue_ptr1 = &s; /* { dg-error {assignment to 'user_enum_ptr' {aka 'enum __internal_enum \*'} from incompatible pointer type 'struct s \*'} } */ + ue_ptr2 = &s; /* { dg-error {assignment to 'user_enum \*' {aka 'enum __internal_enum \*'} from incompatible pointer type 'struct s \*'} } */ + const_ue_ptr1 = &s; /* { dg-error {assignment to 'const user_enum \*' {aka 'const enum __internal_enum \*'} from incompatible pointer type 'struct s \*'} } */ + const_ue_ptr2 = &s; /* { dg-error {assignment to 'const user_enum_copy \*' {aka 'const enum __internal_enum \*'} from incompatible pointer type 'struct s \*'} } */ + volatile_ue_ptr1 = &s; /* { dg-error {assignment to 'volatile user_enum \*' {aka 'volatile enum __internal_enum \*'} from incompatible pointer type 'struct s \*'} } */ + volatile_ue_ptr2 = &s; /* { dg-error {assignment to 'volatile user_enum_copy \*' {aka 'volatile enum __internal_enum \*'} from incompatible pointer type 'struct s \*'} } */ + atomic_ue_ptr1 = &s; /* { dg-error {assignment to '_Atomic user_enum \*' {aka '_Atomic enum __internal_enum \*'} from incompatible pointer type 'struct s \*'} } */ + atomic_ue_ptr2 = &s; /* { dg-error {assignment to '_Atomic user_enum_copy \*' {aka '_Atomic enum __internal_enum \*'} from incompatible pointer type 'struct s \*'} } */ + ue_array_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(\*\)\[10\]' {aka 'enum __internal_enum \(\*\)\[10\]'} from incompatible pointer type 'struct s \*'} } */ + ue_array_ptr2 = &s; /* { dg-error {assignment to 'user_enum_copy \(\*\)\[10\]' {aka 'enum __internal_enum \(\*\)\[10\]'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(\*\)\(void\)' {aka 'enum __internal_enum \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr2 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum\)' {aka 'void \(\*\)\(enum __internal_enum\)'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr3 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum, \.\.\.\)' {aka 'void \(\*\)\(enum __internal_enum, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr4 = &s; /* { dg-error {assignment to 'user_enum_copy \(\*\)\(void\)' {aka 'enum __internal_enum \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr5 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum_copy\)' {aka 'void \(\*\)\(enum __internal_enum\)'} from incompatible pointer type 'struct s \*'} } */ + ue_fn_ptr6 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum_copy, \.\.\.\)' {aka 'void \(\*\)\(enum __internal_enum, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ue_fn_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'enum __internal_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ue_fn_ptr2 = &s; /* { dg-error {assignment to 'user_enum_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'enum __internal_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + + us1 = s; /* { dg-error {assigning to type 'user_struct' {aka 'struct __internal_struct'} from type 'struct s'} } */ + us2 = s; /* { dg-error {assigning to type 'user_struct_copy' {aka 'struct __internal_struct'} from type 'struct s'} } */ + us_ptr1 = &s; /* { dg-error {assignment to 'user_struct_ptr' {aka 'struct __internal_struct \*'} from incompatible pointer type 'struct s \*'} } */ + us_ptr2 = &s; /* { dg-error {assignment to 'user_struct \*' {aka 'struct __internal_struct \*'} from incompatible pointer type 'struct s \*'} } */ + const_us_ptr1 = &s; /* { dg-error {assignment to 'const user_struct \*' {aka 'const struct __internal_struct \*'} from incompatible pointer type 'struct s \*'} } */ + const_us_ptr2 = &s; /* { dg-error {assignment to 'const user_struct_copy \*' {aka 'const struct __internal_struct \*'} from incompatible pointer type 'struct s \*'} } */ + + uu1 = s; /* { dg-error {assigning to type 'user_union' {aka 'union __internal_union'} from type 'struct s'} } */ + uu2 = s; /* { dg-error {assigning to type 'user_union_copy' {aka 'union __internal_union'} from type 'struct s'} } */ + uu_ptr1 = &s; /* { dg-error {assignment to 'user_union_ptr' {aka 'union __internal_union \*'} from incompatible pointer type 'struct s \*'} } */ + uu_ptr2 = &s; /* { dg-error {assignment to 'user_union \*' {aka 'union __internal_union \*'} from incompatible pointer type 'struct s \*'} } */ + const_uu_ptr1 = &s; /* { dg-error {assignment to 'const user_union \*' {aka 'const union __internal_union \*'} from incompatible pointer type 'struct s \*'} } */ + const_uu_ptr2 = &s; /* { dg-error {assignment to 'const user_union_copy \*' {aka 'const union __internal_union \*'} from incompatible pointer type 'struct s \*'} } */ + + uv1 = s; /* { dg-error {assigning to type 'user_vector' {aka '__vector\([48]\) unsigned int'} from type 'struct s'} } */ + uv2 = s; /* { dg-error {assigning to type 'user_vector_copy' {aka '__vector\([48]\) unsigned int'} from type 'struct s'} } */ + uv_ptr1 = &s; /* { dg-error {assignment to 'user_vector_ptr' {aka '__vector\([48]\) unsigned int \*'} from incompatible pointer type 'struct s \*'} } */ + uv_ptr2 = &s; /* { dg-error {assignment to 'user_vector \*' {aka '__vector\([48]\) unsigned int \*'} from incompatible pointer type 'struct s \*'} } */ + const_uv_ptr1 = &s; /* { dg-error {assignment to 'const user_vector \*' {aka 'const __vector\([48]\) unsigned int \*'} from incompatible pointer type 'struct s \*'} } */ + const_uv_ptr2 = &s; /* { dg-error {assignment to 'const user_vector_copy \*' {aka 'const __vector\([48]\) unsigned int \*'} from incompatible pointer type 'struct s \*'} } */ + + ui1 = s; /* { dg-error {assigning to type 'user_int' {aka 'int'} from type 'struct s'} } */ + ui2 = s; /* { dg-error {assigning to type 'user_int_copy' {aka 'int'} from type 'struct s'} } */ + ui_ptr1 = &s; /* { dg-error {assignment to 'user_int_ptr' {aka 'int \*'} from incompatible pointer type 'struct s \*'} } */ + ui_ptr2 = &s; /* { dg-error {assignment to 'user_int \*' {aka 'int \*'} from incompatible pointer type 'struct s \*'} } */ + const_ui_ptr1 = &s; /* { dg-error {assignment to 'const user_int \*' {aka 'const int \*'} from incompatible pointer type 'struct s \*'} } */ + const_ui_ptr2 = &s; /* { dg-error {assignment to 'const user_int_copy \*' {aka 'const int \*'} from incompatible pointer type 'struct s \*'} } */ + volatile_ui_ptr1 = &s; /* { dg-error {assignment to 'volatile user_int \*' {aka 'volatile int \*'} from incompatible pointer type 'struct s \*'} } */ + volatile_ui_ptr2 = &s; /* { dg-error {assignment to 'volatile user_int_copy \*' {aka 'volatile int \*'} from incompatible pointer type 'struct s \*'} } */ + atomic_ui_ptr1 = &s; /* { dg-error {assignment to '_Atomic user_int \*' {aka '_Atomic int \*'} from incompatible pointer type 'struct s \*'} } */ + atomic_ui_ptr2 = &s; /* { dg-error {assignment to '_Atomic user_int_copy \*' {aka '_Atomic int \*'} from incompatible pointer type 'struct s \*'} } */ + ui_array_ptr1 = &s; /* { dg-error {assignment to 'user_int \(\*\)\[10\]' {aka 'int \(\*\)\[10\]'} from incompatible pointer type 'struct s \*'} } */ + ui_array_ptr2 = &s; /* { dg-error {assignment to 'user_int_copy \(\*\)\[10\]' {aka 'int \(\*\)\[10\]'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr1 = &s; /* { dg-error {assignment to 'user_int \(\*\)\(void\)' {aka 'int \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr2 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int\)' {aka 'void \(\*\)\(int\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr3 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int, \.\.\.\)' {aka 'void \(\*\)\(int, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr4 = &s; /* { dg-error {assignment to 'user_int_copy \(\*\)\(void\)' {aka 'int \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr5 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int_copy\)' {aka 'void \(\*\)\(int\)'} from incompatible pointer type 'struct s \*'} } */ + ui_fn_ptr6 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int_copy, \.\.\.\)' {aka 'void \(\*\)\(int, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ui_fn_ptr1 = &s; /* { dg-error {assignment to 'user_int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ui_fn_ptr2 = &s; /* { dg-error {assignment to 'user_int_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diag-sanity.c b/SingleSource/Regression/C/gcc-dg/diag-sanity.c new file mode 100644 index 0000000000..5e58d96633 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diag-sanity.c @@ -0,0 +1,7 @@ +/* Verify that an invalid argument is diagnosed correcly. + { dg-do compile } + { dg-options "-fdiagnostics-minimum-margin-width=42xyz -flto-compression-level=2-O2" } */ + + +/* { dg-error "argument to '-fdiagnostics-minimum-margin-width=' should be a non-negative integer" "" { target *-*-* } 0 } + { dg-error "argument to '-flto-compression-level=' should be a non-negative integer" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-input-charset-1.c b/SingleSource/Regression/C/gcc-dg/diagnostic-input-charset-1.c new file mode 100644 index 0000000000..4e56833162 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-input-charset-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-iconv "CP850" } */ +/* { dg-options "-finput-charset=CP850 -fdiagnostics-show-caret" } */ + +/* Test that diagnostics are converted to UTF-8; this file is encoded in + CP850. Why CP850? -finput-charset only supports encodings that are a + superset of ASCII. But encodings that look like latin-1 are automatically + converted by expect to UTF-8, and hence by the time dg sees them, it can't + verify they were actually output in UTF-8. So codepage 850 was chosen as one + that is hopefully available and meets the requirements of matching ASCII and + not matching latin-1. */ +const char *section = "õ" +/* { dg-error "expected .* at end of input" "" { target *-*-*} .-1 } */ +/* { dg-begin-multiline-output "" } + const char *section = "§" + ^~~~~ + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-input-utf8-bom.c b/SingleSource/Regression/C/gcc-dg/diagnostic-input-utf8-bom.c new file mode 100644 index 0000000000..1a3f35287d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-input-utf8-bom.c @@ -0,0 +1,14 @@ +int 1; +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-show-caret" } */ + +/* This file begins with a UTF-8 byte order mark. Verify that diagnostics + still point to the right place, since the stripping of the BOM happens twice, + once when libcpp reads the file, and once when diagnostics infrastucture + reads it. */ + +/* { dg-error "expected .* before numeric constant" "" { target *-*-*} 1 } */ +/* { dg-begin-multiline-output "" } + int 1; + ^ + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-range-bad-called-object.c b/SingleSource/Regression/C/gcc-dg/diagnostic-range-bad-called-object.c new file mode 100644 index 0000000000..0f7fd2a285 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-range-bad-called-object.c @@ -0,0 +1,24 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +/* Adapted from https://gcc.gnu.org/wiki/ClangDiagnosticsComparison */ + +void call_of_non_function_ptr (char **argP, char **argQ) +{ + (argP - argQ)(); /* { dg-error "called object is not a function or function pointer" } */ + +/* { dg-begin-multiline-output "" } + (argP - argQ)(); + ~~~~~~^~~~~~~ + { dg-end-multiline-output "" } */ + + argP(); /* { dg-error "called object 'argP' is not a function or function pointer" } */ + +/* { dg-begin-multiline-output "" } + argP(); + ^~~~ + { dg-end-multiline-output "" } + { dg-begin-multiline-output "" } + void call_of_non_function_ptr (char **argP, char **argQ) + ~~~~~~~^~~~ + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-range-bad-return.c b/SingleSource/Regression/C/gcc-dg/diagnostic-range-bad-return.c new file mode 100644 index 0000000000..063fdf1f63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-range-bad-return.c @@ -0,0 +1,52 @@ +/* { dg-options "-fdiagnostics-show-caret -Wreturn-local-addr" } */ + +int *address_of_local (void) +{ + int some_local; + return &some_local; /* { dg-warning "function returns address of local variable" } */ +/* { dg-begin-multiline-output "" } + return &some_local; + ^~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +void surplus_return_when_void_1 (void) +{ + return 500; /* { dg-warning "'return' with a value, in function returning void" } */ +/* { dg-begin-multiline-output "" } + return 500; + ^~~ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + void surplus_return_when_void_1 (void) + ^~~~~~~~~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +void surplus_return_when_void_2 (int i, int j) +{ + return i * j; /* { dg-warning "'return' with a value, in function returning void" } */ +/* { dg-begin-multiline-output "" } + return i * j; + ~~^~~ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + void surplus_return_when_void_2 (int i, int j) + ^~~~~~~~~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +int missing_return_value (void) +{ + return; /* { dg-warning "'return' with no value, in function returning non-void" } */ +/* { dg-begin-multiline-output "" } + return; + ^~~~~~ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + int missing_return_value (void) + ^~~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +/* TODO: ideally we'd underline the return type i.e. "int", but that + location isn't captured. */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-range-static-assert.c b/SingleSource/Regression/C/gcc-dg/diagnostic-range-static-assert.c new file mode 100644 index 0000000000..6f75476deb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-range-static-assert.c @@ -0,0 +1,24 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +void test_nonconst_static_assert (int param) +{ + int local = 0; + + _Static_assert (param > 0, "message"); /* { dg-error "expression in static assertion is not constant" } */ +/* { dg-begin-multiline-output "" } + _Static_assert (param > 0, "message"); + ~~~~~~^~~ +{ dg-end-multiline-output "" } */ + + _Static_assert (param, "message"); /* { dg-error "expression in static assertion is not constant" } */ +/* { dg-begin-multiline-output "" } + _Static_assert (param, "message"); + ^~~~~ +{ dg-end-multiline-output "" } */ + + _Static_assert (local, "message"); /* { dg-error "expression in static assertion is not constant" } */ +/* { dg-begin-multiline-output "" } + _Static_assert (local, "message"); + ^~~~~ +{ dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-ranges-1.c b/SingleSource/Regression/C/gcc-dg/diagnostic-ranges-1.c new file mode 100644 index 0000000000..369c0b3990 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-ranges-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-show-caret -Wall" } */ + +void test_range_of_unused_variable (void) +{ + int redundant; /* { dg-warning "unused variable" } */ +/* { dg-begin-multiline-output "" } + int redundant; + ^~~~~~~~~ + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-token-ranges.c b/SingleSource/Regression/C/gcc-dg/diagnostic-token-ranges.c new file mode 100644 index 0000000000..31085be142 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-token-ranges.c @@ -0,0 +1,122 @@ +/* { dg-options "-fdiagnostics-show-caret -Wc++-compat -std=c11 -pedantic" } */ + +/* Verify that various diagnostics show source code ranges. */ + +long double nanl (const char *); + +/* These ones merely use token ranges; they don't use tree ranges. */ + +void undeclared_identifier (void) +{ + name; /* { dg-error "'name' undeclared" } */ +/* +{ dg-begin-multiline-output "" } + name; + ^~~~ +{ dg-end-multiline-output "" } +*/ +} + +void unknown_type_name (void) +{ + foo bar; /* { dg-error "unknown type name 'foo'" } */ +/* +{ dg-begin-multiline-output "" } + foo bar; + ^~~ +{ dg-end-multiline-output "" } +*/ + + qux *baz; /* { dg-error "unknown type name 'qux'" } */ +/* +{ dg-begin-multiline-output "" } + qux *baz; + ^~~ +{ dg-end-multiline-output "" } +*/ +} + +void test_identifier_conflicts_with_cplusplus (void) +{ + int new; /* { dg-warning "identifier 'new' conflicts with" } */ +/* +{ dg-begin-multiline-output "" } + int new; + ^~~ +{ dg-end-multiline-output "" } +*/ +} + +extern void +bogus_varargs (...); /* { dg-warning "ISO C requires a named argument before '...'" } */ +/* +{ dg-begin-multiline-output "" } + bogus_varargs (...); + ^~~ +{ dg-end-multiline-output "" } +*/ + +extern void +foo (unknown_type param); /* { dg-error "unknown type name 'unknown_type'" } */ +/* +{ dg-begin-multiline-output "" } + foo (unknown_type param); + ^~~~~~~~~~~~ +{ dg-end-multiline-output "" } +*/ + +void wide_string_literal_in_asm (void) +{ + __asm (L"nop"); /* { dg-error "a wide string is invalid in this context" } */ +/* +{ dg-begin-multiline-output "" } + __asm (L"nop"); + ^~~~~~ +{ dg-end-multiline-output "" } +*/ +} + +void break_and_continue_in_wrong_places (void) +{ + if (0) + break; /* { dg-error "break statement not within loop or switch" } */ +/* { dg-begin-multiline-output "" } + break; + ^~~~~ + { dg-end-multiline-output "" } */ + + if (1) + ; + else + continue; /* { dg-error "continue statement not within a loop" } */ +/* { dg-begin-multiline-output "" } + continue; + ^~~~~~~~ + { dg-end-multiline-output "" } */ +} + +/* Various examples of bad type decls. */ + +int float bogus; /* { dg-error "two or more data types in declaration specifiers" } */ +/* { dg-begin-multiline-output "" } + int float bogus; + ^~~~~ + { dg-end-multiline-output "" } */ + +long long long bogus2; /* { dg-error "'long long long' is too long for GCC" } */ +/* { dg-begin-multiline-output "" } + long long long bogus2; + ^~~~ + { dg-end-multiline-output "" } */ + +long short bogus3; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */ +/* { dg-begin-multiline-output "" } + long short bogus3; + ^~~~~ + { dg-end-multiline-output "" } */ + +signed unsigned bogus4; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */ +/* { dg-begin-multiline-output "" } + signed unsigned bogus4; + ^~~~~~~~ + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-tree-expr-ranges-2.c b/SingleSource/Regression/C/gcc-dg/diagnostic-tree-expr-ranges-2.c new file mode 100644 index 0000000000..1cbcad5ac7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-tree-expr-ranges-2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -fdiagnostics-show-caret" } */ + +int test_uninit_1 (void) +{ + int result_1; /* { dg-message "declared here" } */ + return result_1; /* { dg-warning "uninitialized" } */ + /* { dg-begin-multiline-output "" } + return result_1; + ^~~~~~~~ + int result_1; + ^~~~~~~~ + { dg-end-multiline-output "" } */ +} + +int test_uninit_2 (void) +{ + int result_2; /* { dg-message "declared here" } */ + result_2 += 3; /* { dg-warning "uninitialized" } */ + /* { dg-begin-multiline-output "" } + result_2 += 3; + ~~~~~~~~~^~~~ + int result_2; + ^~~~~~~~ + { dg-end-multiline-output "" } */ + return result_2; +} diff --git a/SingleSource/Regression/C/gcc-dg/diagnostic-types-1.c b/SingleSource/Regression/C/gcc-dg/diagnostic-types-1.c new file mode 100644 index 0000000000..fc4b104df0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/diagnostic-types-1.c @@ -0,0 +1,57 @@ +/* PR c/81233 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat -Wpedantic" } */ +/* Test we're printing the types, like the good compiler we are. */ + +enum E1 { A } e; +enum E2 { B }; +extern void foo_E (enum E1); /* { dg-message "expected 'enum E1' but argument is of type 'int'" } */ +extern void foo (char *); /* { dg-message "expected 'char \\*' but argument is of type 'int \\*'" } */ +extern void foo2 (int *); /* { dg-message "expected 'int \\*' but argument is of type 'int'" } */ +extern void foo3 (int); /* { dg-message "expected 'int' but argument is of type 'int \\*'" } */ +extern void foo4 (int *); /* { dg-message "expected 'int \\*' but argument is of type 'unsigned int \\*'" } */ + +char * +fn0 (int *p, char *q) +{ + p = q; /* { dg-warning "assignment to 'int \\*' from incompatible pointer type 'char \\*'" } */ + int *r = q; /* { dg-warning "initialization of 'int \\*' from incompatible pointer type 'char \\*'" } */ + foo (r); /* { dg-warning "passing argument 1 of 'foo' from incompatible pointer type" } */ + return p; /* { dg-warning "returning 'int \\*' from a function with incompatible return type 'char \\*'" } */ +} + +int * +fn1 (int *p) +{ + p = 1; /* { dg-warning "assignment to 'int \\*' from 'int' makes pointer from integer without a cast" } */ + int *q = 1; /* { dg-warning "initialization of 'int \\*' from 'int' makes pointer from integer without a cast" } */ + foo2 (1); /* { dg-warning "passing argument 1 of 'foo2' makes pointer from integer without a cast" } */ + return 1; /* { dg-warning "returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */ +} + +int +fn2 (int i, int *p) +{ + i = p; /* { dg-warning "assignment to 'int' from 'int \\*' makes integer from pointer without a cast" } */ + int j = p; /* { dg-warning "initialization of 'int' from 'int \\*' makes integer from pointer without a cast" } */ + foo3 (p); /* { dg-warning "passing argument 1 of 'foo3' makes integer from pointer without a cast" } */ + return p; /* { dg-warning "returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ +} + +int * +fn3 (int *p, unsigned int *u) +{ + p = u; /* { dg-warning "pointer targets in assignment from 'unsigned int \\*' to 'int \\*' differ in signedness" } */ + int *q = u; /* { dg-warning "pointer targets in initialization of 'int \\*' from 'unsigned int \\*' differ in signedness" } */ + foo4 (u); /* { dg-warning "pointer targets in passing argument 1 of 'foo4' differ in signedness" } */ + return u; /* { dg-warning "pointer targets in returning 'unsigned int \\*' from a function with return type 'int \\*' differ in signedness" } */ +} + +enum E1 +fn4 (void) +{ + foo_E (B); /* { dg-warning "enum conversion when passing argument" } */ + e = 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in assignment is invalid" } */ + enum E1 f = 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in initialization is invalid" } */ + return 0; /* { dg-warning "enum conversion from 'int' to 'enum E1' in return is invalid" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/div-cmp-1.c b/SingleSource/Regression/C/gcc-dg/div-cmp-1.c new file mode 100644 index 0000000000..cd1a5cd3d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/div-cmp-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funsafe-math-optimizations -fdump-tree-optimized-raw" } */ + +int +cmp_mul_1 (float x) +{ + return x * 3 <= 100; +} + +int +cmp_mul_2 (float x) +{ + return x * -5 > 100; +} + +int +div_cmp_1 (float x, float y) +{ + return x / 3 <= y; +} + +int +div_cmp_2 (float x, float y) +{ + return x / 3 <= 1; +} + +/* { dg-final { scan-tree-dump-times "mult_expr" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "rdiv_expr" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/div-cmp-2.c b/SingleSource/Regression/C/gcc-dg/div-cmp-2.c new file mode 100644 index 0000000000..95e5400d77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/div-cmp-2.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funsafe-math-optimizations -ffinite-math-only -fdump-tree-optimized-raw" } */ + +int +cmp_1 (float x) +{ + return 5 / x >= 0; +} + +int +cmp_2 (float x) +{ + return 1 / x <= 0; +} + +int +cmp_3 (float x) +{ + return -2 / x >= 0; +} + +int +cmp_4 (float x) +{ + return -5 / x <= 0; +} + +/* { dg-final { scan-tree-dump-not "rdiv_expr" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/div-compare-1.c b/SingleSource/Regression/C/gcc-dg/div-compare-1.c new file mode 100644 index 0000000000..61adafe140 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/div-compare-1.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +extern void abort(void); + +typedef unsigned long long uint64; + +int very_large_value (uint64 t) +{ + return (t / 1000000000ULL) > 9223372037ULL; +} + +int main(void) +{ + uint64 t = 0xC000000000000000ULL; + + if (!very_large_value (t)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/div-double-1.c b/SingleSource/Regression/C/gcc-dg/div-double-1.c new file mode 100644 index 0000000000..f290ab0678 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/div-double-1.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffinite-math-only" } */ +/* { dg-require-effective-target double64plus } */ + +extern void abort (void); + +volatile double a = 2.002083e-146; +volatile double b; + +int +main() +{ + b = 1. / a; + + if (b != (1. / 2.002083e-146)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/div_neg.c b/SingleSource/Regression/C/gcc-dg/div_neg.c new file mode 100644 index 0000000000..da499cda2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/div_neg.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +float +div_neg (float x, float y) +{ + return (-x / y) * (x / -y); +} + +/* { dg-final { scan-tree-dump-times " / " 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divbyzero.c b/SingleSource/Regression/C/gcc-dg/divbyzero.c new file mode 100644 index 0000000000..607aa12d56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divbyzero.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ + +/* Source: Neil Booth, Oct 22 2001. PR 150 - warn about division by + zero. */ + +#define ZERO (4 - 6 + 2) + +int main (int argc, char *argv[]) +{ + int w = argc % ZERO; /* { dg-warning "division by zero" } */ + int x = argc / 0; /* { dg-warning "division by zero" } */ + int y = argc / ZERO; /* { dg-warning "division by zero" } */ + + double z = 0.0 / 0.0 ; /* { dg-bogus "division by zero" } */ + w = (ZERO ? y / ZERO : x); /* { dg-bogus "division by zero" } */ + x = (ZERO ? argc % ZERO: x); /* { dg-bogus "division by zero" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/divmod-1-simode.c b/SingleSource/Regression/C/gcc-dg/divmod-1-simode.c new file mode 100644 index 0000000000..9e477997bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-1-simode.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div dominates mod. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + if (cond) \ + foo (); \ + bigtype r = x % y; \ + return q + r; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-1.c b/SingleSource/Regression/C/gcc-dg/divmod-1.c new file mode 100644 index 0000000000..edcc2a107d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-1.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div dominates mod. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + if (cond) \ + foo (); \ + bigtype r = x % y; \ + return q + r; \ +} + +FOO(SImode, DImode, 1) +FOO(SImode, UDImode, 2) +FOO(USImode, DImode, 3) +FOO(USImode, UDImode, 4) +FOO(DImode, DImode, 5) +FOO(DImode, UDImode, 6) +FOO(UDImode, UDImode, 7) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-2-simode.c b/SingleSource/Regression/C/gcc-dg/divmod-2-simode.c new file mode 100644 index 0000000000..fa28beb3ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-2-simode.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* mod dominates div. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype r = x % y; \ + if (cond) \ + foo (); \ + bigtype q = x / y; \ + return q + r; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-2.c b/SingleSource/Regression/C/gcc-dg/divmod-2.c new file mode 100644 index 0000000000..ded732e121 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-2.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* mod dominates div. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype r = x % y; \ + if (cond) \ + foo (); \ + bigtype q = x / y; \ + return q + r; \ +} + +FOO(SImode, DImode, 1) +FOO(SImode, UDImode, 2) +FOO(USImode, DImode, 3) +FOO(USImode, UDImode, 4) +FOO(DImode, DImode, 5) +FOO(DImode, UDImode, 6) +FOO(UDImode, UDImode, 7) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-3-simode.c b/SingleSource/Regression/C/gcc-dg/divmod-3-simode.c new file mode 100644 index 0000000000..9dee5bf603 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-3-simode.c @@ -0,0 +1,23 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div comes before mod in same bb. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + bigtype r = x % y; \ + return q + r; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-3.c b/SingleSource/Regression/C/gcc-dg/divmod-3.c new file mode 100644 index 0000000000..02aa367ac6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-3.c @@ -0,0 +1,30 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div comes before mod in same bb. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + bigtype r = x % y; \ + return q + r; \ +} + +FOO(SImode, DImode, 1) +FOO(SImode, UDImode, 2) +FOO(USImode, DImode, 3) +FOO(USImode, UDImode, 4) +FOO(DImode, DImode, 5) +FOO(DImode, UDImode, 6) +FOO(UDImode, UDImode, 7) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-4-simode.c b/SingleSource/Regression/C/gcc-dg/divmod-4-simode.c new file mode 100644 index 0000000000..dbe29cb761 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-4-simode.c @@ -0,0 +1,23 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* mod comes before div in same bb. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype r = x % y; \ + bigtype q = x / y; \ + return q + r; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-4.c b/SingleSource/Regression/C/gcc-dg/divmod-4.c new file mode 100644 index 0000000000..861ecbdec4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-4.c @@ -0,0 +1,30 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* mod comes before div in same bb. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype r = x % y; \ + bigtype q = x / y; \ + return q + r; \ +} + +FOO(SImode, DImode, 3) +FOO(SImode, UDImode, 4) +FOO(USImode, DImode, 6) +FOO(USImode, UDImode, 7) +FOO(DImode, DImode, 8) +FOO(DImode, UDImode, 9) +FOO(UDImode, UDImode, 10) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-5.c b/SingleSource/Regression/C/gcc-dg/divmod-5.c new file mode 100644 index 0000000000..8a8cee50ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-5.c @@ -0,0 +1,19 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div and mod are not in same bb and + bb's containing div and mod don't dominate each other. */ + +int f(int x, int y) +{ + int q = 0; + int r = 0; + extern int cond; + + if (cond) + q = x / y; + + r = x % y; + return q + r; +} + +/* { dg-final { scan-tree-dump-times "DIVMOD" 0 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-6-simode.c b/SingleSource/Regression/C/gcc-dg/divmod-6-simode.c new file mode 100644 index 0000000000..1107f760b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-6-simode.c @@ -0,0 +1,26 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + bigtype r1 = 0, r2 = 0; \ + if (cond) \ + r1 = x % y; \ + else \ + r2 = x % y; \ + return q + r1 + r2; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-6.c b/SingleSource/Regression/C/gcc-dg/divmod-6.c new file mode 100644 index 0000000000..495ebaff80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-6.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + bigtype r1 = 0, r2 = 0; \ + if (cond) \ + r1 = x % y; \ + else \ + r2 = x % y; \ + return q + r1 + r2; \ +} + +FOO(SImode, DImode, 3) +FOO(SImode, UDImode, 4) +FOO(USImode, DImode, 6) +FOO(USImode, UDImode, 7) +FOO(DImode, DImode, 8) +FOO(DImode, UDImode, 9) +FOO(UDImode, UDImode, 10) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/divmod-7.c b/SingleSource/Regression/C/gcc-dg/divmod-7.c new file mode 100644 index 0000000000..faa90b3ac8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/divmod-7.c @@ -0,0 +1,21 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ + +int f(int x, int y) +{ + int q = 0, r1 = 0, r2 = 0; + extern int cond; + + if (cond) + q = x / y; + else + { + r1 = x % y; + return q + r1; + } + + r2 = x % y; + return q + r2; +} + +/* { dg-final { scan-tree-dump-times "DIVMOD" 1 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/dll-1.c b/SingleSource/Regression/C/gcc-dg/dll-1.c new file mode 100644 index 0000000000..f823523b27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target arm*-*-pe* } } */ +/* { dg-options -mno-nop-fun-dllimport } */ + +__declspec (dllimport) void imp (); + +__declspec (dllexport) void _exp () { imp (); } + +/* { dg-final { scan-assembler "\.section\[ \t\]*.drectve\n\[^\n\]*-export:_exp.*__imp_imp" } } */ +/* { dg-final { scan-assembler-not "__imp__exp" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/dll-10.c b/SingleSource/Regression/C/gcc-dg/dll-10.c new file mode 100644 index 0000000000..2f0c6ce31a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-10.c @@ -0,0 +1,54 @@ +/* { dg-do link } */ +/* { dg-require-dll "" } */ +/* { dg-additional-sources "dll-10a.c" } */ +/* { dg-options "-w -O2 -std=gnu99 -fno-keep-inline-dllexport" } */ +/* { dg-prune-output .*undefined.* } */ +/* { dg-xfail-if "link failure expected" { *-*-* } } */ + +/* Test that inline functions declared "dllexport" appear in object files, + even if they are not called - except when -fno-keep-inline-dllexport. + + This behavior is required by the ARM C++ ABI: + + Exporting a function that can be inlined should force the + creation and export of an out-of-line copy of it. + + and should presumably also apply. + + Visual Studio 2005 also honors that rule. */ + +__declspec(dllexport) inline void i1() {} + +__declspec(dllexport) extern inline void e1() {} + +/* It is invalid to declare the function inline after its definition. */ +#if 0 +__declspec(dllexport) void i2() {} +inline void i2(); + +__declspec(dllexport) extern void e2() {} +inline void e2(); +#endif + +__declspec(dllexport) inline void i3() {} +void i3(); + +__declspec(dllexport) inline void e3() {} +extern void e3(); + +__declspec(dllexport) void i4(); +inline void i4() {}; + +__declspec(dllexport) extern void e4(); +inline void e4() {}; + +__declspec(dllexport) inline void i5(); +void i5() {}; + +__declspec(dllexport) inline void e5(); +extern void e5() {}; + +/* Make sure that just declaring the function -- without defining it + -- does not cause errors. */ +__declspec(dllexport) inline void i6(); +__declspec(dllexport) extern inline void e6(); diff --git a/SingleSource/Regression/C/gcc-dg/dll-10a.c b/SingleSource/Regression/C/gcc-dg/dll-10a.c new file mode 100644 index 0000000000..80caf32174 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-10a.c @@ -0,0 +1,21 @@ +extern void i1(); +extern void i3(); +extern void i4(); +extern void i5(); + +extern void e1(); +extern void e3(); +extern void e4(); +extern void e5(); + +int main () { + i1(); + i3(); + i4(); + i5(); + + e1(); + e3(); + e4(); + e5(); +} diff --git a/SingleSource/Regression/C/gcc-dg/dll-11.c b/SingleSource/Regression/C/gcc-dg/dll-11.c new file mode 100644 index 0000000000..5fa2e6f19f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-11.c @@ -0,0 +1,52 @@ +/* { dg-do link } */ +/* { dg-require-dll "" } */ +/* { dg-additional-sources "dll-11a.c" } */ +/* { dg-options "-w -O2 -std=gnu89 -fkeep-inline-dllexport" } */ + +/* Test that inline functions declared "dllexport" appear in object files, + even if they are not called, when -fkeep-inline-dllexport is supplied. + + This behavior is required by the ARM C++ ABI: + + Exporting a function that can be inlined should force the + creation and export of an out-of-line copy of it. + + and should presumably also apply. + + Visual Studio 2005 also honors that rule. */ + +__declspec(dllexport) inline void i1() {} + +__declspec(dllexport) extern inline void e1() {} + +/* It is invalid to declare the function inline after its definition. */ +#if 0 +__declspec(dllexport) void i2() {} +inline void i2(); + +__declspec(dllexport) extern void e2() {} +inline void e2(); +#endif + +__declspec(dllexport) inline void i3() {} +void i3(); + +__declspec(dllexport) inline void e3() {} +extern void e3(); + +__declspec(dllexport) void i4(); +inline void i4() {}; + +__declspec(dllexport) extern void e4(); +inline void e4() {}; + +__declspec(dllexport) inline void i5(); +void i5() {}; + +__declspec(dllexport) inline void e5(); +extern void e5() {}; + +/* Make sure that just declaring the function -- without defining it + -- does not cause errors. */ +__declspec(dllexport) inline void i6(); +__declspec(dllexport) extern inline void e6(); diff --git a/SingleSource/Regression/C/gcc-dg/dll-11a.c b/SingleSource/Regression/C/gcc-dg/dll-11a.c new file mode 100644 index 0000000000..80caf32174 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-11a.c @@ -0,0 +1,21 @@ +extern void i1(); +extern void i3(); +extern void i4(); +extern void i5(); + +extern void e1(); +extern void e3(); +extern void e4(); +extern void e5(); + +int main () { + i1(); + i3(); + i4(); + i5(); + + e1(); + e3(); + e4(); + e5(); +} diff --git a/SingleSource/Regression/C/gcc-dg/dll-12.c b/SingleSource/Regression/C/gcc-dg/dll-12.c new file mode 100644 index 0000000000..4f8829964a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-12.c @@ -0,0 +1,52 @@ +/* { dg-do link } */ +/* { dg-require-dll "" } */ +/* { dg-additional-sources "dll-12a.c" } */ +/* { dg-options "-w -O2 -std=gnu99 -fkeep-inline-dllexport" } */ + +/* Test that inline functions declared "dllexport" appear in object files, + even if they are not called, when -fkeep-inline-dllexport is supplied. + + This behavior is required by the ARM C++ ABI: + + Exporting a function that can be inlined should force the + creation and export of an out-of-line copy of it. + + and should presumably also apply. + + Visual Studio 2005 also honors that rule. */ + +__declspec(dllexport) inline void i1() {} + +__declspec(dllexport) extern inline void e1() {} + +/* It is invalid to declare the function inline after its definition. */ +#if 0 +__declspec(dllexport) void i2() {} +inline void i2(); + +__declspec(dllexport) extern void e2() {} +inline void e2(); +#endif + +__declspec(dllexport) inline void i3() {} +void i3(); + +__declspec(dllexport) inline void e3() {} +extern void e3(); + +__declspec(dllexport) void i4(); +inline void i4() {}; + +__declspec(dllexport) extern void e4(); +inline void e4() {}; + +__declspec(dllexport) inline void i5(); +void i5() {}; + +__declspec(dllexport) inline void e5(); +extern void e5() {}; + +/* Make sure that just declaring the function -- without defining it + -- does not cause errors. */ +__declspec(dllexport) inline void i6(); +__declspec(dllexport) extern inline void e6(); diff --git a/SingleSource/Regression/C/gcc-dg/dll-12a.c b/SingleSource/Regression/C/gcc-dg/dll-12a.c new file mode 100644 index 0000000000..80caf32174 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-12a.c @@ -0,0 +1,21 @@ +extern void i1(); +extern void i3(); +extern void i4(); +extern void i5(); + +extern void e1(); +extern void e3(); +extern void e4(); +extern void e5(); + +int main () { + i1(); + i3(); + i4(); + i5(); + + e1(); + e3(); + e4(); + e5(); +} diff --git a/SingleSource/Regression/C/gcc-dg/dll-2.c b/SingleSource/Regression/C/gcc-dg/dll-2.c new file mode 100644 index 0000000000..3b8b60eee4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-2.c @@ -0,0 +1,22 @@ +/* These dllimport and dllexport appearing for a symbol. + The desired behavior is that if both dllimport + and dllexport appear (in either order) the result is dllexport. + + Microsoft's MSVC 2.0 allows dllimport followed by dllexport for variables, + but does not allow dllexport followed by dllimport. + + In C, it's ok to redeclare a variable so this works for variables + and functions. In C++, it only works for functions. */ + +/* { dg-require-dll "" } */ + +__declspec (dllimport) int foo1 (); +__declspec (dllexport) int foo1 (); /* { dg-warning "previous dllimport ignored" } */ +__declspec (dllexport) int foo2 (); +__declspec (dllimport) int foo2 (); /* { dg-warning "dllimport ignored" } */ + +__declspec (dllimport) int bar1; +__declspec (dllexport) int bar1; /* { dg-warning "previous dllimport ignored" } */ + +__declspec (dllexport) int bar2; +__declspec (dllimport) int bar2; /* { dg-warning "dllimport ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/dll-3.c b/SingleSource/Regression/C/gcc-dg/dll-3.c new file mode 100644 index 0000000000..f68758ccaa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-3.c @@ -0,0 +1,18 @@ +/* Ensure dllexport overrides dllimport. */ + +/* { dg-do compile { target arm*-*-pe* } } */ +/* { dg-do compile { target i?86-pc-cygwin } } */ +/* { dg-do compile { target i?86-*-mingw* x86_64-*-mingw*} } */ + +__declspec (dllimport) int foo1 (); +__declspec (dllexport) int foo1 (); /* { dg-warning "previous dllimport ignored" } */ + +__declspec (dllexport) int foo2 (); +__declspec (dllimport) int foo2 (); /* { dg-warning "dllimport ignored" } */ + +__declspec (dllexport) int foo1 () { return foo2 (); } +__declspec (dllexport) int foo2 () { return foo1 (); } + +/* { dg-final { scan-assembler "\.section\[ \t\]*.drectve\n.*-export:\[\\\\\"\]*foo2" } } */ +/* { dg-final { scan-assembler "-export:\[\\\\\"\]*foo1" } } */ +/* { dg-final { scan-assembler-not "(__imp_foo1|_imp__foo1|__imp_foo2|_imp__foo2)" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/dll-4.c b/SingleSource/Regression/C/gcc-dg/dll-4.c new file mode 100644 index 0000000000..e2d701b47b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-4.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target arm*-*-pe* } } */ +/* { dg-do compile { target i?86-pc-cygwin } } */ +/* { dg-do compile { target i?86-*-mingw* x86_64-*-mingw* } } */ + +__declspec (dllimport) int foo1; +int foo1; /* { dg-warning "redeclared without dllimport" } */ + +__declspec (dllimport) int foo2; +int foo2 = 5; /* { dg-warning "redeclared without dllimport" } */ + +int f () { return foo1 + foo2; } + +/* FIXME: We should scan the output of nm for this case. */ +/* { dg-final { scan-assembler "(foo2:)" } } */ +/* { dg-final { scan-assembler "(\.comm\[ \t_\]*foo1)" } } */ +/* { dg-final { scan-assembler-not "(__imp_|_imp__)" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/dll-5.c b/SingleSource/Regression/C/gcc-dg/dll-5.c new file mode 100644 index 0000000000..d28603b56e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-5.c @@ -0,0 +1,22 @@ +/* { dg-do compile { target i?86-pc-cygwin } } */ +/* { dg-do compile { target i?86-*-mingw* x86_64-*-mingw* } } */ +/* { dg-do compile { target arm*-*-pe* } } */ + +/* { dg-options -mnop-fun-dllimport } */ + +/* The dllimport attribute should be ignored for functions. */ +__declspec (dllimport) void dllimpfn (); + +/* The dllimport attribute should not be ignored for variables. */ +__declspec (dllimport) int dllimpvar; + +/* The dllexport attribute should not be ignored. */ +__declspec (dllexport) void dllexp () +{ + dllimpfn (); + dllimpvar = 0; +} + +/* { dg-final { scan-assembler-not "(__imp_dllimpfn|_imp__dllimpfn)" } } */ +/* { dg-final { scan-assembler "(__imp_dllimpvar|_imp__dllimpvar)" } } */ +/* { dg-final { scan-assembler "\.section\[ \t\]*.drectve\n\.*-export:\[\\\\\"\]*dllexp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/dll-6.c b/SingleSource/Regression/C/gcc-dg/dll-6.c new file mode 100644 index 0000000000..7907f40d1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-6.c @@ -0,0 +1,52 @@ +/* { dg-do link } */ +/* { dg-require-dll "" } */ +/* { dg-additional-sources "dll-6a.c" } */ +/* { dg-options "-w -O2 -std=gnu89" } */ + +/* Test that inline functions declared "dllexport" appear in object + files, even if they are not called. + + This behavior is required by the ARM C++ ABI: + + Exporting a function that can be inlined should force the + creation and export of an out-of-line copy of it. + + and should presumably also apply. + + Visual Studio 2005 also honors that rule. */ + +__declspec(dllexport) inline void i1() {} + +__declspec(dllexport) extern inline void e1() {} + +/* It is invalid to declare the function inline after its definition. */ +#if 0 +__declspec(dllexport) void i2() {} +inline void i2(); + +__declspec(dllexport) extern void e2() {} +inline void e2(); +#endif + +__declspec(dllexport) inline void i3() {} +void i3(); + +__declspec(dllexport) inline void e3() {} +extern void e3(); + +__declspec(dllexport) void i4(); +inline void i4() {}; + +__declspec(dllexport) extern void e4(); +inline void e4() {}; + +__declspec(dllexport) inline void i5(); +void i5() {}; + +__declspec(dllexport) inline void e5(); +extern void e5() {}; + +/* Make sure that just declaring the function -- without defining it + -- does not cause errors. */ +__declspec(dllexport) inline void i6(); +__declspec(dllexport) extern inline void e6(); diff --git a/SingleSource/Regression/C/gcc-dg/dll-6a.c b/SingleSource/Regression/C/gcc-dg/dll-6a.c new file mode 100644 index 0000000000..80caf32174 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-6a.c @@ -0,0 +1,21 @@ +extern void i1(); +extern void i3(); +extern void i4(); +extern void i5(); + +extern void e1(); +extern void e3(); +extern void e4(); +extern void e5(); + +int main () { + i1(); + i3(); + i4(); + i5(); + + e1(); + e3(); + e4(); + e5(); +} diff --git a/SingleSource/Regression/C/gcc-dg/dll-7.c b/SingleSource/Regression/C/gcc-dg/dll-7.c new file mode 100644 index 0000000000..c3a5957ae6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-7.c @@ -0,0 +1,52 @@ +/* { dg-do link } */ +/* { dg-require-dll "" } */ +/* { dg-additional-sources "dll-7a.c" } */ +/* { dg-options "-w -O2 -std=gnu99" } */ + +/* Test that inline functions declared "dllexport" appear in object + files, even if they are not called. + + This behavior is required by the ARM C++ ABI: + + Exporting a function that can be inlined should force the + creation and export of an out-of-line copy of it. + + and should presumably also apply. + + Visual Studio 2005 also honors that rule. */ + +__declspec(dllexport) inline void i1() {} + +__declspec(dllexport) extern inline void e1() {} + +/* It is invalid to declare the function inline after its definition. */ +#if 0 +__declspec(dllexport) void i2() {} +inline void i2(); + +__declspec(dllexport) extern void e2() {} +inline void e2(); +#endif + +__declspec(dllexport) inline void i3() {} +void i3(); + +__declspec(dllexport) inline void e3() {} +extern void e3(); + +__declspec(dllexport) void i4(); +inline void i4() {}; + +__declspec(dllexport) extern void e4(); +inline void e4() {}; + +__declspec(dllexport) inline void i5(); +void i5() {}; + +__declspec(dllexport) inline void e5(); +extern void e5() {}; + +/* Make sure that just declaring the function -- without defining it + -- does not cause errors. */ +__declspec(dllexport) inline void i6(); +__declspec(dllexport) extern inline void e6(); diff --git a/SingleSource/Regression/C/gcc-dg/dll-7a.c b/SingleSource/Regression/C/gcc-dg/dll-7a.c new file mode 100644 index 0000000000..80caf32174 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-7a.c @@ -0,0 +1,21 @@ +extern void i1(); +extern void i3(); +extern void i4(); +extern void i5(); + +extern void e1(); +extern void e3(); +extern void e4(); +extern void e5(); + +int main () { + i1(); + i3(); + i4(); + i5(); + + e1(); + e3(); + e4(); + e5(); +} diff --git a/SingleSource/Regression/C/gcc-dg/dll-8.c b/SingleSource/Regression/C/gcc-dg/dll-8.c new file mode 100644 index 0000000000..98afba8d0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-8.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target i?86-pc-cygwin } } */ +/* { dg-do compile { target i?86-*-mingw* x86_64-*-mingw*} } */ +/* { dg-options "-O3 -fwhole-program" } */ +/* { dg-final { scan-assembler "foo1" } } */ +/* { dg-final { scan-assembler-not "foo2" } } */ +/* { dg-final { scan-assembler "doo1" } } */ +/* { dg-final { scan-assembler-not "doo2" } } */ + +__declspec(dllexport) int doo1 = 2; +int doo2 = 3; +__declspec(dllexport) int foo1 (void) { return 0; } +int foo2 (void) { return 1; } +int main() { return 0; } + diff --git a/SingleSource/Regression/C/gcc-dg/dll-9.c b/SingleSource/Regression/C/gcc-dg/dll-9.c new file mode 100644 index 0000000000..ae641d29d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-9.c @@ -0,0 +1,54 @@ +/* { dg-do link } */ +/* { dg-require-dll "" } */ +/* { dg-additional-sources "dll-9a.c" } */ +/* { dg-options "-w -O2 -std=gnu89 -fno-keep-inline-dllexport" } */ +/* { dg-prune-output .*undefined.* } */ +/* { dg-xfail-if "link failure expected" { *-*-* } } */ + +/* Test that inline functions declared "dllexport" appear in object files, + even if they are not called - except when -fno-keep-inline-dllexport. + + This behavior is required by the ARM C++ ABI: + + Exporting a function that can be inlined should force the + creation and export of an out-of-line copy of it. + + and should presumably also apply. + + Visual Studio 2005 also honors that rule. */ + +__declspec(dllexport) inline void i1() {} + +__declspec(dllexport) extern inline void e1() {} + +/* It is invalid to declare the function inline after its definition. */ +#if 0 +__declspec(dllexport) void i2() {} +inline void i2(); + +__declspec(dllexport) extern void e2() {} +inline void e2(); +#endif + +__declspec(dllexport) inline void i3() {} +void i3(); + +__declspec(dllexport) inline void e3() {} +extern void e3(); + +__declspec(dllexport) void i4(); +inline void i4() {}; + +__declspec(dllexport) extern void e4(); +inline void e4() {}; + +__declspec(dllexport) inline void i5(); +void i5() {}; + +__declspec(dllexport) inline void e5(); +extern void e5() {}; + +/* Make sure that just declaring the function -- without defining it + -- does not cause errors. */ +__declspec(dllexport) inline void i6(); +__declspec(dllexport) extern inline void e6(); diff --git a/SingleSource/Regression/C/gcc-dg/dll-9a.c b/SingleSource/Regression/C/gcc-dg/dll-9a.c new file mode 100644 index 0000000000..80caf32174 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dll-9a.c @@ -0,0 +1,21 @@ +extern void i1(); +extern void i3(); +extern void i4(); +extern void i5(); + +extern void e1(); +extern void e3(); +extern void e4(); +extern void e5(); + +int main () { + i1(); + i3(); + i4(); + i5(); + + e1(); + e3(); + e4(); + e5(); +} diff --git a/SingleSource/Regression/C/gcc-dg/do-empty.c b/SingleSource/Regression/C/gcc-dg/do-empty.c new file mode 100644 index 0000000000..350261d48e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/do-empty.c @@ -0,0 +1,15 @@ +/* Test diagnostics for empty bodies in do / while. */ +/* { dg-do compile } */ +/* { dg-options "-Wempty-body" } */ + +void +f (int x) +{ + do + ; /* { dg-warning "empty body in" } */ + while (x--); + + do + {} /* { dg-bogus "empty body in" } */ + while (++x < 10); +} diff --git a/SingleSource/Regression/C/gcc-dg/dollar.c b/SingleSource/Regression/C/gcc-dg/dollar.c new file mode 100644 index 0000000000..e69c4e2ec8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dollar.c @@ -0,0 +1,9 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. */ + +/* { dg-do compile } */ +/* { dg-options -fno-dollars-in-identifiers } */ + +/* Test that -fno-dollars-in-identifiers is honoured. + Neil Booth, 17 May 2003. */ + +int foobar$; /* { dg-error "11:stray '\\$'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/doloop-2.c b/SingleSource/Regression/C/gcc-dg/doloop-2.c new file mode 100644 index 0000000000..115ec742ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/doloop-2.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +extern void abort (void); +unsigned global_iters; + +void bi_reverse(int len) +{ + do { + global_iters++; + } while (--len > 0); +} + +int main() +{ + bi_reverse(5); + if (global_iters != 5) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/dremf-type-compat-1.c b/SingleSource/Regression/C/gcc-dg/dremf-type-compat-1.c new file mode 100644 index 0000000000..79c55ef840 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dremf-type-compat-1.c @@ -0,0 +1,16 @@ +/* Test for bogus diagnostics for dremf definition. Although this + definition is formally incorrect in ISO C, a GNU extension permits + a prototype followed by unpromoted types in a function definition, + so it should be permitted when the function is built in. Bug + 16666. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +float dremf (float, float); + +float +dremf (x, y) + float x, y; +{ + return x + y; +} diff --git a/SingleSource/Regression/C/gcc-dg/dremf-type-compat-2.c b/SingleSource/Regression/C/gcc-dg/dremf-type-compat-2.c new file mode 100644 index 0000000000..980ead187e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dremf-type-compat-2.c @@ -0,0 +1,18 @@ +/* Test for bogus diagnostics for dremf definition. Although this + definition is formally incorrect in ISO C, a GNU extension permits + a prototype followed by unpromoted types in a function definition, + so it should be permitted when the function is built in. Bug + 16666. Test with -pedantic, where the problem should still be + diagnosed. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +float dremf (float, float); /* { dg-warning "prototype declaration" } */ + +float +dremf (x, y) + float x; /* { dg-warning "promoted argument 'x' doesn't match prototype" } */ + float y; /* { dg-warning "promoted argument 'y' doesn't match prototype" } */ +{ + return x + y; +} diff --git a/SingleSource/Regression/C/gcc-dg/dremf-type-compat-3.c b/SingleSource/Regression/C/gcc-dg/dremf-type-compat-3.c new file mode 100644 index 0000000000..3934a64e19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dremf-type-compat-3.c @@ -0,0 +1,18 @@ +/* Test for bogus diagnostics for dremf definition. Although this + definition is formally incorrect in ISO C, a GNU extension permits + a prototype followed by unpromoted types in a function definition, + so it should be permitted when the function is built in. Bug + 16666. Test with -pedantic-errors, where the problem should still + be diagnosed. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +float dremf (float, float); /* { dg-error "prototype declaration" } */ + +float +dremf (x, y) + float x; /* { dg-error "promoted argument 'x' doesn't match prototype" } */ + float y; /* { dg-error "promoted argument 'y' doesn't match prototype" } */ +{ + return x + y; +} diff --git a/SingleSource/Regression/C/gcc-dg/dremf-type-compat-4.c b/SingleSource/Regression/C/gcc-dg/dremf-type-compat-4.c new file mode 100644 index 0000000000..b3a2c5ad5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dremf-type-compat-4.c @@ -0,0 +1,13 @@ +/* Test for bogus diagnostics for dremf definition, as in bug 16666. + The GNU extension permitting a prototype to override the promotion + of old-style parameter declarations should only apply when the + prototype is visible, not for a built-in prototype. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +float +dremf(x, y) /* { dg-warning "conflicting types for built-in function 'dremf'" } */ + float x, y; +{ + return x + y; +} diff --git a/SingleSource/Regression/C/gcc-dg/driver-specs.c b/SingleSource/Regression/C/gcc-dg/driver-specs.c new file mode 100644 index 0000000000..9cb66e14c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/driver-specs.c @@ -0,0 +1,4 @@ +// { dg-additional-options "-specs=not-a-file" } +// { dg-prune-output "compilation terminated" } +// { dg-error "cannot read spec file" "" { target *-*-* } 0 } + diff --git a/SingleSource/Regression/C/gcc-dg/dse.c b/SingleSource/Regression/C/gcc-dg/dse.c new file mode 100644 index 0000000000..4358d6c927 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dse.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-dse1-details" } */ + +#define N 256 + +struct +{ + int x; + int y; +} S[100]; + +int z[100]; + +int +foo (void) +{ + int i; + int x, y; + + S[5].x = 0; + S[5].y = 0; + + x = 5 + z[0]; + y = z[0]; + + S[5].x = x; + S[5].y = y; +} + +/* { dg-final { scan-tree-dump-times "Deleted dead store" 2 "dse1" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/duff-1.c b/SingleSource/Regression/C/gcc-dg/duff-1.c new file mode 100644 index 0000000000..b718f6c05e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/duff-1.c @@ -0,0 +1,50 @@ +/* Duff's device is legal C; test to make sure the compiler + doesn't complain about it. + + Jason Thorpe + Derived from PR 3846. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); + +typedef __SIZE_TYPE__ size_t; +extern int memcmp (const void *, const void *, size_t); + +void +duffcpy (char *dst, const char *src, unsigned long size) +{ + switch (size & 3) + { + for (;;) + { + *dst++ = *src++; + case 3: + *dst++ = *src++; + case 2: + *dst++ = *src++; + case 1: + *dst++ = *src++; + case 0: + if (size <= 3) + break; + size -= 4; + } + } +} + +const char testpat[] = "The quick brown fox jumped over the lazy dog."; + +int +main() +{ + char buf[64]; + + duffcpy (buf, testpat, sizeof (testpat)); + if (memcmp (buf, testpat, sizeof (testpat)) != 0) + abort (); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/duff-2.c b/SingleSource/Regression/C/gcc-dg/duff-2.c new file mode 100644 index 0000000000..8b8923eb94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/duff-2.c @@ -0,0 +1,60 @@ +/* Duff's device is legal C; test to make sure the compiler + doesn't complain about it. + + Jason Thorpe + Derived from the BSD Telnet Kerberos 4 checksum routine. + See also PR 5230. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); + +#if __INT_MAX__ >= 2147483647 +/* At least 32-bit integers. */ +typedef int type32; +#else +typedef long type32; +#endif + +type32 +cksum (const unsigned char *src, unsigned long size) +{ + type32 ck = 0; + + switch (size & 3) + { + while (size > 0) + { + case 0: + ck ^= (type32)*src++ << 24; + --size; + case 3: + ck ^= (type32)*src++ << 16; + --size; + case 2: + ck ^= (type32)*src++ << 8; + --size; + case 1: + ck ^= (type32)*src++; + --size; + } + } + + return ck; +} + +const char testpat[] = "The quick brown fox jumped over the lazy dog."; + +int +main() +{ + type32 ck; + + ck = cksum ((const unsigned char *) testpat, sizeof (testpat)); + if (ck != 925902908) + abort (); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/duff-3.c b/SingleSource/Regression/C/gcc-dg/duff-3.c new file mode 100644 index 0000000000..23cddeff9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/duff-3.c @@ -0,0 +1,47 @@ +/* Duff's device is legal C; test to make sure the compiler + doesn't complain about it. + + Jason Thorpe + Derived from Tom Duff's original usenet message about the device. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); + +typedef __SIZE_TYPE__ size_t; +extern int memcmp (const void *, const void *, size_t); + +void +duffcpy (char *dst, const char *src, unsigned long size) +{ + unsigned long n = (size + 7) / 8; + + switch (size % 8) + { + case 0: do { *dst++ = *src++; + case 7: *dst++ = *src++; + case 6: *dst++ = *src++; + case 5: *dst++ = *src++; + case 4: *dst++ = *src++; + case 3: *dst++ = *src++; + case 2: *dst++ = *src++; + case 1: *dst++ = *src++; + } while (--n > 0); + } +} + +const char testpat[] = "The quick brown fox jumped over the lazy dog."; + +int +main() +{ + char buf[64]; + + duffcpy (buf, testpat, sizeof (testpat)); + if (memcmp (buf, testpat, sizeof (testpat)) != 0) + abort (); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/duff-4.c b/SingleSource/Regression/C/gcc-dg/duff-4.c new file mode 100644 index 0000000000..7032285af5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/duff-4.c @@ -0,0 +1,60 @@ +/* Duff's device is legal C; test to make sure the compiler + doesn't complain about it. + + Roger Sayle + Derived from duff-2.c. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); + +#if __INT_MAX__ >= 2147483647 +/* At least 32-bit integers. */ +typedef int type32; +#else +typedef long type32; +#endif + +type32 +cksum (const unsigned char *src, unsigned long size) +{ + type32 ck = 0; + + switch (size & 3) + { + do + { + case 0: + ck ^= (type32)*src++ << 24; + --size; + case 3: + ck ^= (type32)*src++ << 16; + --size; + case 2: + ck ^= (type32)*src++ << 8; + --size; + case 1: + ck ^= (type32)*src++; + --size; + } + while (size > 0); + } + + return ck; +} + +const char testpat[] = "The quick brown fox jumped over the lazy dog."; + +int +main() +{ + type32 ck; + + ck = cksum ((const unsigned char *) testpat, sizeof (testpat)); + if (ck != 925902908) + abort (); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/dump-pass.c b/SingleSource/Regression/C/gcc-dg/dump-pass.c new file mode 100644 index 0000000000..bcdf99ae02 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dump-pass.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-passes" } */ + +unsigned res; + +void +foo (unsigned code, int len) +{ + int i; + for (i = 0; i < len; i++) + res |= code & 1; +} + +/* { dg-prune-output ".*" } */ diff --git a/SingleSource/Regression/C/gcc-dg/dx-test.c b/SingleSource/Regression/C/gcc-dg/dx-test.c new file mode 100644 index 0000000000..579ccfb979 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/dx-test.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-dx" } */ + +void f(void) +{} diff --git a/SingleSource/Regression/C/gcc-dg/empty-source-1.c b/SingleSource/Regression/C/gcc-dg/empty-source-1.c new file mode 100644 index 0000000000..239001c030 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/empty-source-1.c @@ -0,0 +1,5 @@ +/* Test diagnostic for an empty source file. Test with no special + options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/empty-source-2.c b/SingleSource/Regression/C/gcc-dg/empty-source-2.c new file mode 100644 index 0000000000..67906f9e8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/empty-source-2.c @@ -0,0 +1,6 @@ +/* Test diagnostic for an empty source file. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +/* { dg-warning "-:ISO C forbids an empty translation unit" "empty" { target *-*-* } .+1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/empty-source-3.c b/SingleSource/Regression/C/gcc-dg/empty-source-3.c new file mode 100644 index 0000000000..f2877159fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/empty-source-3.c @@ -0,0 +1,7 @@ +/* Test diagnostic for an empty source file. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +/* { dg-error "-:ISO C forbids an empty translation unit" "empty" { target *-*-* } .+1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/empty.h b/SingleSource/Regression/C/gcc-dg/empty.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/SingleSource/Regression/C/gcc-dg/empty1.c b/SingleSource/Regression/C/gcc-dg/empty1.c new file mode 100644 index 0000000000..89b2de1e90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/empty1.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-options "" } */ + +struct S { int : 0; }; +union U { int : 0; }; + +int main () { + if (__alignof__ (struct S) != __alignof__ (union U)) + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/empty2.c b/SingleSource/Regression/C/gcc-dg/empty2.c new file mode 100644 index 0000000000..acc1ac8ddc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/empty2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ +double d=0; + +struct A {} a; /* { dg-warning "struct has no members" } */ + +void foo(struct A x) +{ + d=0; +} + +void bar() +{ + if (d) foo(a); +} diff --git a/SingleSource/Regression/C/gcc-dg/encoding-issues-bytes.c b/SingleSource/Regression/C/gcc-dg/encoding-issues-bytes.c new file mode 100644 index 0000000000..d3dc59f353 Binary files /dev/null and b/SingleSource/Regression/C/gcc-dg/encoding-issues-bytes.c differ diff --git a/SingleSource/Regression/C/gcc-dg/encoding-issues-unicode.c b/SingleSource/Regression/C/gcc-dg/encoding-issues-unicode.c new file mode 100644 index 0000000000..39f371307d Binary files /dev/null and b/SingleSource/Regression/C/gcc-dg/encoding-issues-unicode.c differ diff --git a/SingleSource/Regression/C/gcc-dg/enum-compat-1.c b/SingleSource/Regression/C/gcc-dg/enum-compat-1.c new file mode 100644 index 0000000000..5fb150cee7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-compat-1.c @@ -0,0 +1,32 @@ +/* Test that enumerated types are only considered compatible when they + are the same type. PR c/6024. */ +/* Origin: Joseph Myers , based on + PR c/6024 from Richard Earnshaw */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Original test from PR c/6024. */ +enum e1 {a, b}; +enum e2 {c, d}; + +void f(enum e1); /* { dg-error "prototype" "error at decl" } */ + +void f(x) + enum e2 x; /* { dg-error "doesn't match prototype" } */ +{ + return; +} + +/* Other compatibility tests. */ +enum e3 { A }; +enum e4 { B }; + +enum e3 v3; +enum e4 *p = &v3; /* { dg-warning "incompatible" "incompatible pointer" } */ +enum e3 *q = &v3; + +void g(enum e3); /* { dg-message "note: previous declaration" "error at first decl" } */ +void g(enum e4); /* { dg-error "conflicting types" "error at second decl" } */ + +void h(enum e3); +void h(enum e3); diff --git a/SingleSource/Regression/C/gcc-dg/enum-const-1.c b/SingleSource/Regression/C/gcc-dg/enum-const-1.c new file mode 100644 index 0000000000..205bb23721 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-const-1.c @@ -0,0 +1,8 @@ +/* Test for enumeration constants not integer constant expressions but + folding to integer constants (used in Linux kernel, + ). */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern int i; +enum e { E = (1 ? 1 : i) }; diff --git a/SingleSource/Regression/C/gcc-dg/enum-const-2.c b/SingleSource/Regression/C/gcc-dg/enum-const-2.c new file mode 100644 index 0000000000..7e83a6ff45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-const-2.c @@ -0,0 +1,8 @@ +/* Test for enumeration constants not integer constant expressions but + folding to integer constants (used in Linux kernel, + ). */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +extern int i; +enum e { E = (1 ? 1 : i) }; /* { dg-warning "not an integer constant expression" } */ diff --git a/SingleSource/Regression/C/gcc-dg/enum-const-3.c b/SingleSource/Regression/C/gcc-dg/enum-const-3.c new file mode 100644 index 0000000000..ab355cafe1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-const-3.c @@ -0,0 +1,8 @@ +/* Test for enumeration constants not integer constant expressions but + folding to integer constants (used in Linux kernel, + ). */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +extern int i; +enum e { E = (1 ? 1 : i) }; /* { dg-error "not an integer constant expression" } */ diff --git a/SingleSource/Regression/C/gcc-dg/enum-incomplete-1.c b/SingleSource/Regression/C/gcc-dg/enum-incomplete-1.c new file mode 100644 index 0000000000..2da3b58f54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-incomplete-1.c @@ -0,0 +1,88 @@ +/* Test for uses of incomplete enum variables: should be allowed just + when incomplete structs are allowed. PR 32295. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern enum e ve; +extern struct s vs; +void *p; + +int +f0 (int i) +{ + ve; /* { dg-error "incomplete" } */ + vs; /* { dg-error "incomplete" } */ + (void) ve; /* { dg-error "incomplete" } */ + (void) vs; /* { dg-error "incomplete" } */ + (void) (i ? ve : ve); /* { dg-error "incomplete" } */ + (void) (i ? vs : vs); /* { dg-error "incomplete" } */ + (void) (ve = ve); /* { dg-error "incomplete" } */ + (void) (vs = vs); /* { dg-error "incomplete" } */ + (void) ve, /* { dg-error "incomplete" } */ + (void) ve; /* { dg-error "incomplete" } */ + (void) vs, /* { dg-error "incomplete" } */ + (void) vs; /* { dg-error "incomplete" } */ + p = &ve; + p = &vs; + (void) sizeof (ve); /* { dg-error "incomplete" } */ + (void) sizeof (vs); /* { dg-error "incomplete" } */ + typeof (ve) *pe; + typeof (vs) *ps; + /* ??? alignof should probably not be accepted here. */ + (void) __alignof (ve); + (void) __alignof (vs); + (void) (ve + i); /* { dg-error "incomplete" } */ + (void) (i * ve); /* { dg-error "incomplete" } */ + (void) (i / ve); /* { dg-error "incomplete" } */ + (void) (ve - i); /* { dg-error "incomplete" } */ + (void) (ve << i); /* { dg-error "incomplete" } */ + (void) (i >> ve); /* { dg-error "incomplete" } */ + (void) (ve < i); /* { dg-error "incomplete" } */ + (void) (ve <= i); /* { dg-error "incomplete" } */ + (void) (i > ve); /* { dg-error "incomplete" } */ + (void) (i >= ve); /* { dg-error "incomplete" } */ + (void) (ve == i); /* { dg-error "incomplete" } */ + (void) (i != ve); /* { dg-error "incomplete" } */ + (void) (ve & i); /* { dg-error "incomplete" } */ + (void) (ve ^ i); /* { dg-error "incomplete" } */ + (void) (i | ve); /* { dg-error "incomplete" } */ + (void) (i && ve); /* { dg-error "incomplete" } */ + (void) (ve || i); /* { dg-error "incomplete" } */ + (void) -ve; /* { dg-error "incomplete" } */ + (void) +ve; /* { dg-error "incomplete" } */ + (void) ~ve; /* { dg-error "incomplete" } */ + (void) !ve; /* { dg-error "incomplete" } */ + (void) --ve; /* { dg-error "incomplete" } */ + (void) ++ve; /* { dg-error "incomplete" } */ + (void) ve--; /* { dg-error "incomplete" } */ + (void) ve++; /* { dg-error "incomplete" } */ + i = ve; /* { dg-error "incomplete" } */ + i *= ve; /* { dg-error "incomplete" } */ + i /= ve; /* { dg-error "incomplete" } */ + i %= ve; /* { dg-error "incomplete" } */ + i += ve; /* { dg-error "incomplete" } */ + i -= ve; /* { dg-error "incomplete" } */ + i <<= ve; /* { dg-error "incomplete" } */ + i >>= ve; /* { dg-error "incomplete" } */ + i &= ve; /* { dg-error "incomplete" } */ + i ^= ve; /* { dg-error "incomplete" } */ + i |= ve; /* { dg-error "incomplete" } */ + (void) (ve ? 1 : 1); /* { dg-error "incomplete" } */ + (void) (int) ve; /* { dg-error "incomplete" } */ + f0 (ve); /* { dg-error "incomplete" } */ + if (ve) /* { dg-error "incomplete" } */ + ; + do + ; + while (ve); /* { dg-error "incomplete" } */ + while (ve) /* { dg-error "incomplete" } */ + ; + _Bool b = ve; /* { dg-error "incomplete" } */ + float f = ve; /* { dg-error "incomplete" } */ + switch (ve) /* { dg-error "incomplete" } */ + ; + for (; ve;) /* { dg-error "incomplete" } */ + ; + return ve; /* { dg-error "incomplete" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/enum-incomplete-2.c b/SingleSource/Regression/C/gcc-dg/enum-incomplete-2.c new file mode 100644 index 0000000000..59705514cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-incomplete-2.c @@ -0,0 +1,41 @@ +/* PR c/52085 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#define SA(X) _Static_assert((X),#X) + +enum e1; +enum e1 { A } __attribute__ ((__packed__)); +enum e2 { B } __attribute__ ((__packed__)); +SA (sizeof (enum e1) == sizeof (enum e2)); +SA (_Alignof (enum e1) == _Alignof (enum e2)); + +enum e3; +enum e3 { C = 256 } __attribute__ ((__packed__)); +enum e4 { D = 256 } __attribute__ ((__packed__)); +SA (sizeof (enum e3) == sizeof (enum e4)); +SA (_Alignof (enum e3) == _Alignof (enum e4)); + +enum e5; +enum e5 { E = __INT_MAX__ } __attribute__ ((__packed__)); +enum e6 { F = __INT_MAX__ } __attribute__ ((__packed__)); +SA (sizeof (enum e5) == sizeof (enum e6)); +SA (_Alignof (enum e5) == _Alignof (enum e6)); + +enum e7; +enum e7 { G } __attribute__ ((__mode__(__byte__))); +enum e8 { H } __attribute__ ((__mode__(__byte__))); +SA (sizeof (enum e7) == sizeof (enum e8)); +SA (_Alignof (enum e7) == _Alignof (enum e8)); + +enum e9; +enum e9 { I } __attribute__ ((__packed__, __mode__(__byte__))); +enum e10 { J } __attribute__ ((__packed__, __mode__(__byte__))); +SA (sizeof (enum e9) == sizeof (enum e10)); +SA (_Alignof (enum e9) == _Alignof (enum e10)); + +enum e11; +enum e11 { K } __attribute__ ((__mode__(__word__))); +enum e12 { L } __attribute__ ((__mode__(__word__))); +SA (sizeof (enum e11) == sizeof (enum e12)); +SA (_Alignof (enum e11) == _Alignof (enum e12)); diff --git a/SingleSource/Regression/C/gcc-dg/enum-incomplete-3.c b/SingleSource/Regression/C/gcc-dg/enum-incomplete-3.c new file mode 100644 index 0000000000..12280db61f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-incomplete-3.c @@ -0,0 +1,20 @@ +/* PR c/70851 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum E e; /* { dg-error "storage size" } */ + +void bar (int [e]); /* { dg-error "has an incomplete type" } */ +void bar2 (int [][e]); /* { dg-error "has an incomplete type" } */ + +void +foo (void) +{ + int a1[e]; /* { dg-error "has an incomplete type" } */ + int a2[e][3]; /* { dg-error "has an incomplete type" } */ + + struct S + { + int a3[e]; /* { dg-error "has an incomplete type" } */ + }; +} diff --git a/SingleSource/Regression/C/gcc-dg/enum-incomplete-4.c b/SingleSource/Regression/C/gcc-dg/enum-incomplete-4.c new file mode 100644 index 0000000000..03fb9f4923 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-incomplete-4.c @@ -0,0 +1,11 @@ +/* PR c/79662 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern enum e ve; + +int +f0 (int i) +{ + f0 (ve); /* { dg-error "incomplete" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/enum-mode-1.c b/SingleSource/Regression/C/gcc-dg/enum-mode-1.c new file mode 100644 index 0000000000..9d3ea26d6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-mode-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +enum e1 { A = 256 } __attribute__((__mode__(__byte__))); /* { dg-error "specified mode too small for enumerated values" } */ +enum e2 { B = 256 } __attribute__((__packed__, __mode__(__byte__))); /* { dg-error "specified mode too small for enumerated values" } */ + +enum e3 { C = __INT_MAX__ } __attribute__((__mode__(__QI__))); /* { dg-error "specified mode too small for enumerated values" } */ +enum e4 { D = __INT_MAX__ } __attribute__((__packed__, __mode__(__QI__))); /* { dg-error "specified mode too small for enumerated values" } */ + +enum e5 { E = __INT_MAX__ } __attribute__((__mode__(__HI__))); /* { dg-error "specified mode too small for enumerated values" "" { xfail int16 } } */ +enum e6 { F = __INT_MAX__ } __attribute__((__packed__, __mode__(__HI__))); /* { dg-error "specified mode too small for enumerated values" "" { xfail int16 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/enum-mode-2.c b/SingleSource/Regression/C/gcc-dg/enum-mode-2.c new file mode 100644 index 0000000000..8dba3c53c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-mode-2.c @@ -0,0 +1,22 @@ +/* PR c/51147 - attribute((mode(byte))) on an enum generates wrong code */ + +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -fdump-tree-optimized" } */ + +enum _eq_bool +{ + false, + true +} __attribute__((mode (byte))); + +typedef enum _eq_bool bool; + +bool foo (void); +bool bar (void); + +bool test (void) +{ + return foo () || bar (); +} + +/* { dg-final { scan-tree-dump-times "foo|bar" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/enum-redef-1.c b/SingleSource/Regression/C/gcc-dg/enum-redef-1.c new file mode 100644 index 0000000000..b3fa6cbf8f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum-redef-1.c @@ -0,0 +1,29 @@ +enum a { A }; +enum a { B }; /* { dg-bogus "nested redefinition" } */ +/* { dg-error "redeclaration of 'enum a'" "" { target *-*-* } .-1 } */ + +enum empty {}; /* { dg-error "empty enum is invalid" } */ +enum empty {}; /* { dg-bogus "nested redefinition" } */ +/* { dg-error "empty enum is invalid" "" { target *-*-* } .-1 } */ + +enum nested_first { + C1 = sizeof(enum nested_first { C1a }), /* { dg-error "nested redefinition of 'enum nested_first" } */ + C2 = sizeof(enum nested_first { C2a }) /* { dg-error "redeclaration of 'enum nested_first'" "" } */ +}; + +enum nested_second { + D1, + D2 = sizeof(enum nested_second { D2a }), /* { dg-error "nested redefinition of 'enum nested_second" } */ + D3 = sizeof(enum nested_second { D3a }) /* { dg-error "redeclaration of 'enum nested_second'" "" } */ +}; + +enum nested_repeat { E }; +enum nested_repeat { /* { dg-error "redeclaration of 'enum nested_repeat'" "" } */ + F = sizeof(enum nested_repeat { Fa }) /* { dg-error "nested redefinition of 'enum nested_repeat" } */ +}; + +enum nested_empty { + G1 = sizeof(enum nested_empty {}), /* { dg-error "nested redefinition of 'enum nested_empty" } */ + /* { dg-error "empty enum is invalid" "" { target *-*-* } .-1 } */ + G2 = sizeof(enum nested_empty { G2a }) +}; diff --git a/SingleSource/Regression/C/gcc-dg/enum1.c b/SingleSource/Regression/C/gcc-dg/enum1.c new file mode 100644 index 0000000000..0f4587ff65 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum1.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu89" } */ + +/* In standard C, enumeration constants always have type int. If they + are not representables are int, they're ill-formed. In GNU C, we + give such ill-formed constructs well-defined meaning. Make sure it + works. */ + +#include + +enum foo +{ + foo1 = 0, + foo2 = 0xffffffffffffffffULL, + foo3 = 0xf0fffffffffffffeULL +}; + +int main () +{ + if (sizeof (enum foo) != sizeof (unsigned long long)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/enum2.c b/SingleSource/Regression/C/gcc-dg/enum2.c new file mode 100644 index 0000000000..575cc5ce08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum2.c @@ -0,0 +1,8 @@ +/* { dg-options "-fshort-enums" } */ +/* Check that "-fshort-enums" packs enumeration tyes into a minimal + number of bytes.. */ + +enum e { e_1 }; + +extern int i[sizeof (enum e)]; +int i[1]; diff --git a/SingleSource/Regression/C/gcc-dg/enum3.c b/SingleSource/Regression/C/gcc-dg/enum3.c new file mode 100644 index 0000000000..eebd6ca64c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/enum3.c @@ -0,0 +1,11 @@ +/* Test for non-integer enum values. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum e { E, F }; +enum e2 { + E1 = (void *)4, /* { dg-error "enumerator value for 'E1' is not an integer constant" } */ + E2 = (enum e)F, + E3 = (_Bool)1 +}; diff --git a/SingleSource/Regression/C/gcc-dg/errno-1.c b/SingleSource/Regression/C/gcc-dg/errno-1.c new file mode 100644 index 0000000000..0dfb00087d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/errno-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include +#include + +void do_not_optimize_away (); + +int main() +{ + void * volatile p; + errno = 0; + /* The malloc call below may cause a -Walloc-size-larger-than warning. */ + p = malloc (-1); + if (errno != 0) + do_not_optimize_away (); + return 0; +} + +/* { dg-final { scan-assembler "do_not_optimize_away" } } */ +/* { dg-prune-output "exceeds maximum object size" } */ diff --git a/SingleSource/Regression/C/gcc-dg/ext-elim-1.c b/SingleSource/Regression/C/gcc-dg/ext-elim-1.c new file mode 100644 index 0000000000..5e899a235f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ext-elim-1.c @@ -0,0 +1,39 @@ +/* PR rtl-optimization/51924 */ +/* Testcase by Zdenek Sojka */ + +/* { dg-do run } */ +/* { dg-options "-O -free -fno-rename-registers -ftree-vectorize -funroll-loops" } */ + +typedef __UINT64_TYPE__ uint64_t; + +uint64_t __attribute__ ((noinline, noclone)) +bn_sub_words (uint64_t * r, const uint64_t * a, const uint64_t * b, int n) +{ + uint64_t t1, t2; + unsigned c = 0; + + while (n) + { + t1 = a[0]; + t2 = b[0]; + r[0] = (t1 - t2 - c); + if (t1 != t2) + c = (t1 < t2); + a++; + b++; + r++; + n--; + } + return (c); +} + +int +main (void) +{ + uint64_t r[2]; + uint64_t a[2] = { -1, -1 }; + uint64_t b[2] = { 0, 0 }; + if (bn_sub_words (r, a, b, 2) != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/extra-semi-1.c b/SingleSource/Regression/C/gcc-dg/extra-semi-1.c new file mode 100644 index 0000000000..74857cad12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/extra-semi-1.c @@ -0,0 +1,7 @@ +/* Test diagnostic for extra semicolon outside a function. Test with + no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +; diff --git a/SingleSource/Regression/C/gcc-dg/extra-semi-2.c b/SingleSource/Regression/C/gcc-dg/extra-semi-2.c new file mode 100644 index 0000000000..2964ed557e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/extra-semi-2.c @@ -0,0 +1,7 @@ +/* Test diagnostic for extra semicolon outside a function. Test with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +; /* { dg-warning "ISO C does not allow extra ';' outside of a function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/extra-semi-3.c b/SingleSource/Regression/C/gcc-dg/extra-semi-3.c new file mode 100644 index 0000000000..53a420a5e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/extra-semi-3.c @@ -0,0 +1,7 @@ +/* Test diagnostic for extra semicolon outside a function. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +; /* { dg-error "ISO C does not allow extra ';' outside of a function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/extract_recip_3.c b/SingleSource/Regression/C/gcc-dg/extract_recip_3.c new file mode 100644 index 0000000000..15bcc27f8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/extract_recip_3.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized-raw" } */ + +float +extract_square (float *a, float *b, float x, float y) +{ + *a = 3 / (y * y); + *b = 5 / (y * y); + + return x / (y * y); +} + +/* Don't expect the 'powmult' (calculation of y * y) + to be deleted until a later pass, so look for one + more multiplication than strictly necessary. */ +float +extract_recip (float *a, float *b, float x, float y, float z) +{ + *a = 7 / y; + *b = x / (y * y); + + return z / y; +} + +/* 4 multiplications in 'extract_square', and 4 in 'extract_recip'. */ +/* { dg-final { scan-tree-dump-times "mult_expr" 8 "optimized" } } */ + +/* 1 division in 'extract_square', 1 division in 'extract_recip'. */ +/* { dg-final { scan-tree-dump-times "rdiv_expr" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/extract_recip_4.c b/SingleSource/Regression/C/gcc-dg/extract_recip_4.c new file mode 100644 index 0000000000..816e3615e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/extract_recip_4.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized-raw" } */ + +/* Don't expect any of these divisions to be extracted. */ +double f (double x, int p) +{ + if (p > 0) + { + return 1.0/(x * x); + } + + if (p > -1) + { + return x * x * x; + } + return 1.0 /(x); +} + +/* Expect a reciprocal to be extracted here. */ +double g (double *a, double x, double y) +{ + *a = 3 / y; + double k = x / (y * y); + + if (y * y == 2.0) + return k + 1 / y; + else + return k - 1 / y; +} + +/* Expect 2 divisions in 'f' and 1 in 'g'. */ +/* { dg-final { scan-tree-dump-times "rdiv_expr" 3 "optimized" } } */ +/* Expect 3 multiplications in 'f' and 4 in 'g'. */ +/* { dg-final { scan-tree-dump-times "mult_expr" 7 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fail_always_inline.c b/SingleSource/Regression/C/gcc-dg/fail_always_inline.c new file mode 100644 index 0000000000..86645b850d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fail_always_inline.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-add-options bind_pic_locally } */ + +extern __attribute__ ((always_inline)) void + bar() { } /* { dg-warning "function might not be inlinable" } */ + +void +f() +{ + bar(); +} + diff --git a/SingleSource/Regression/C/gcc-dg/fail_always_inline2.c b/SingleSource/Regression/C/gcc-dg/fail_always_inline2.c new file mode 100644 index 0000000000..863597f705 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fail_always_inline2.c @@ -0,0 +1,19 @@ +extern char *__realpath_alias (__const char *__restrict __name, char +*__restrict __resolved) __asm__ ("" "realpath") __attribute__ +((__nothrow__)) __attribute__ ((__warn_unused_result__)); + +extern __inline __attribute__ ((__always_inline__)) __attribute__ +((__artificial__)) __attribute__ ((__warn_unused_result__)) char * +__attribute__ ((__nothrow__)) realpath (__const char *__restrict __name, +char *__restrict __resolved) +{ + return __realpath_alias (__name, __resolved); +} + +char * +realpath(path, resolved) + const char *path; + char *resolved; +{ + return (((void *)0)); +} diff --git a/SingleSource/Regression/C/gcc-dg/falign-labels-1.c b/SingleSource/Regression/C/gcc-dg/falign-labels-1.c new file mode 100644 index 0000000000..e4c61c8b19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/falign-labels-1.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-falign-labels=8" } */ +/* { dg-skip-if "no label alignment > 2" { "pdp11-*-*" } } */ + +/* On ARMv7-A CPUs, this test resulted in incorrect code generation. + The code generated for the switch statement expected the jump table + to immediately follow the jump instruction, but -falign-labels + caused the label preceding the table to be aligned. */ +/* M68K and fido only support -falign-labels argument <= 2. */ + +volatile int x; + +int main(void) +{ + int y; + + x = 0; + + switch(x) + { + case 0: + y = 2 * x; + break; + case 1: + y = -3 * x; + break; + case 2: + y = x + 5; + break; + case 3: + y = x - 7; + break; + default: + break; + } + + x = y; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/fastmath-1.c b/SingleSource/Regression/C/gcc-dg/fastmath-1.c new file mode 100644 index 0000000000..ed4f37f147 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fastmath-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void abort (void); + +int foo ( float* dists, int k) +{ +if ( ( dists [ 0 ] > 0 ) == ( dists [ 1 ] > 0 ) ) + return k; +return 0; +} +int +main() { + float dists[16] = { 0., 1., 1., 0., 0., -1., -1., 0., + 1., 1., 1., -1., -1., 1., -1., -1. }; + if ( foo(&dists[0], 1) + + foo(&dists[2], 2) + + foo(&dists[4], 4) + + foo(&dists[6], 8) + + foo(&dists[8], 16) + + foo(&dists[10], 32) + + foo(&dists[12], 64) + + foo(&dists[14], 128) + != 156) + abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/fdata-sections-1.c b/SingleSource/Regression/C/gcc-dg/fdata-sections-1.c new file mode 100644 index 0000000000..de5ddfc017 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fdata-sections-1.c @@ -0,0 +1,9 @@ +/* PR middle-end/15486 */ +/* Origin: Jonathan Larmour */ + +/* { dg-do compile { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-fcommon -fdata-sections" } */ + +int x; + +/* { dg-final { scan-assembler "comm" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fdata-sections-2.c b/SingleSource/Regression/C/gcc-dg/fdata-sections-2.c new file mode 100644 index 0000000000..48d44a2f18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fdata-sections-2.c @@ -0,0 +1,18 @@ +/* PR middle-end/192 */ +/* PR middle-end/54303 */ + +/* This checks that string constants are put in per-function rodata + sections, so that they can be garbage collected. */ + +/* { dg-do compile { target *-*-linux* *-*-uclinux* } } */ +/* { dg-options "-O -ffunction-sections -fdata-sections" } */ + +const char *f1(void) { return "falderalde"; } +const char *f2(void) { return "a"; } +const char *f3(void) { return "falderalde"; } +const char *f4(void) { return "eralde"; } + +/* { dg-final { scan-assembler {\.rodata\.f1\.str} } } */ +/* { dg-final { scan-assembler {\.rodata\.f2\.str} } } */ +/* { dg-final { scan-assembler-not {\.rodata\.f3\.str} } } */ +/* { dg-final { scan-assembler {\.rodata\.f4\.str} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fixits-pr84852-1.c b/SingleSource/Regression/C/gcc-dg/fixits-pr84852-1.c new file mode 100644 index 0000000000..0afd9e9fb4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fixits-pr84852-1.c @@ -0,0 +1,22 @@ +/* This is padding (to avoid the output containing DejaGnu directives). */ + +/* We need -fdiagnostics-show-caret to trigger the ICE. */ + +/* { dg-options "-fdiagnostics-show-caret -pedantic-errors -Wno-implicit-function-declaration" } */ + +#line 3482810481 /* { dg-error "line number out of range" } */ +/* { dg-begin-multiline-output "" } + #line 3482810481 + ^~~~~~~~~~ + { dg-end-multiline-output "" } */ + +int foo (void) { return strlen(""); } + +/* { dg-warning "incompatible implicit declaration of built-in function 'strlen'" "" { target *-*-* } { -812156810 } } */ +/* { dg-message "include '' or provide a declaration of 'strlen'" "" { target *-*-* } 1 } */ +#if 0 +{ dg-begin-multiline-output "" } ++#include + /* This is padding (to avoid the output containing DejaGnu directives). */ +{ dg-end-multiline-output "" } +#endif diff --git a/SingleSource/Regression/C/gcc-dg/fixits-pr84852-2.c b/SingleSource/Regression/C/gcc-dg/fixits-pr84852-2.c new file mode 100644 index 0000000000..ec52eb8c72 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fixits-pr84852-2.c @@ -0,0 +1,22 @@ +/* This is padding (to avoid the output containing DejaGnu directives). */ + +/* We need -fdiagnostics-show-caret to trigger the ICE. */ + +/* { dg-options "-fdiagnostics-show-caret -pedantic-errors -Wno-implicit-function-declaration" } */ + +#line 7777777777 /* { dg-error "line number out of range" } */ +/* { dg-begin-multiline-output "" } + #line 7777777777 + ^~~~~~~~~~ + { dg-end-multiline-output "" } */ + +int foo (void) { return strlen(""); } + +/* { dg-warning "incompatible implicit declaration of built-in function 'strlen'" "" { target *-*-* } { -812156810 } } */ +/* { dg-message "include '' or provide a declaration of 'strlen'" "" { target *-*-* } 1 } */ +#if 0 +{ dg-begin-multiline-output "" } ++#include + /* This is padding (to avoid the output containing DejaGnu directives). */ +{ dg-end-multiline-output "" } +#endif diff --git a/SingleSource/Regression/C/gcc-dg/fixits.c b/SingleSource/Regression/C/gcc-dg/fixits.c new file mode 100644 index 0000000000..06c9995d7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fixits.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-show-caret" } */ + +struct foo { int x; }; +union u { int x; }; + +/* Verify that we issue a hint for "." used with a ptr to a struct. */ + +int test_1 (struct foo *ptr) +{ + return ptr.x; /* { dg-error "'ptr' is a pointer; did you mean to use '->'?" } */ +/* { dg-begin-multiline-output "" } + return ptr.x; + ^ + -> + { dg-end-multiline-output "" } */ +} + +/* Likewise for a ptr to a union. */ + +int test_2 (union u *ptr) +{ + return ptr.x; /* { dg-error "'ptr' is a pointer; did you mean to use '->'?" } */ +/* { dg-begin-multiline-output "" } + return ptr.x; + ^ + -> + { dg-end-multiline-output "" } */ +} + +/* Verify that we don't issue a hint for a ptr to something that isn't a + struct or union. */ + +int test_3 (void **ptr) +{ + return ptr.x; /* { dg-error "request for member 'x' in something not a structure or union" } */ +/* { dg-begin-multiline-output "" } + return ptr.x; + ^ + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/fixuns-trunc-1.c b/SingleSource/Regression/C/gcc-dg/fixuns-trunc-1.c new file mode 100644 index 0000000000..0d09429524 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fixuns-trunc-1.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +unsigned long foo(double d) +{ + return (unsigned long) d; +} + +extern void abort(void); + +int main(void) +{ + double d; + unsigned long l; + +#ifdef __LP64__ + d = 9223372036854775808.7; + l = 1LL << 63; + + if (foo(d) != l) + abort(); +#endif + + d = 122485.2; + l = 122485; + + if (foo(d) != l) + abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/float-exact-1.c b/SingleSource/Regression/C/gcc-dg/float-exact-1.c new file mode 100644 index 0000000000..d22e70b354 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float-exact-1.c @@ -0,0 +1,3178 @@ +/* Test exact conversion to binary floating-point types of + floating-point contents expressed in decimal. PR 21718. */ +/* { dg-do run } */ +/* { dg-options "-w" } */ +/* { dg-add-options ieee } */ + +/* For float (if IEEE binary32), double (if IEEE binary64) and long + double (if IEEE binary64, x86 extended or IEEE binary128) we test + half-way values and numbers close to those half-way values. */ + +#include + +#if FLT_EVAL_METHOD == 0 \ + && FLT_MANT_DIG == 24 \ + && FLT_MIN_EXP == -125 \ + && FLT_MAX_EXP == 128 +# define FLT_OK +/* 0x0.8p-149 */ +static const float f1ae = 0, f1be = 0, f1ce = 0x1p-149f; +static const float f1a = +7.0064923216240853546186479164495806564013097093825788587853\ +4141944895541342930300743319094181060791015624999e-46f; +static const float f1b = +7.0064923216240853546186479164495806564013097093825788587853\ +4141944895541342930300743319094181060791015625e-46f; +static const float f1c = +7.0064923216240853546186479164495806564013097093825788587853\ +4141944895541342930300743319094181060791015625001e-46f; +/* 0x1.8p-149 */ +static const float f2ae = 0x1p-149f, f2be = 0x2p-149f, f2ce = 0x2p-149f; +static const float f2a = +2.1019476964872256063855943749348741969203929128147736576356\ +02425834686624028790902229957282543182373046874999e-45f; +static const float f2b = +2.1019476964872256063855943749348741969203929128147736576356\ +02425834686624028790902229957282543182373046875e-45f; +static const float f2c = +2.1019476964872256063855943749348741969203929128147736576356\ +02425834686624028790902229957282543182373046875001e-45f; +/* 0x1.000001p127 */ +static const float f3ae = 0x1p127f, f3be = 0x1p127f, f3ce = 0x1.000002p127f; +static const float f3a = +1.70141193601674033557522515689509748735999e+38f; +static const float f3b = +1.70141193601674033557522515689509748736e+38f; +static const float f3c = +1.70141193601674033557522515689509748736001e+38f; +#endif + +#if (FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1) \ + && DBL_MANT_DIG == 53 \ + && DBL_MIN_EXP == -1021 \ + && DBL_MAX_EXP == 1024 +# define DBL_OK +/* 0x0.8p-1074 */ +static const double d1ae = 0, d1be = 0, d1ce = 0x1p-1074; +static const double d1a = +2.4703282292062327208828439643411068618252990130716238221279\ +284125033775363510437593264991818081799618989828234772285886\ +546332835517796989819938739800539093906315035659515570226392\ +290858392449105184435931802849936536152500319370457678249219\ +365623669863658480757001585769269903706311928279558551332927\ +834338409351978015531246597263579574622766465272827220056374\ +006485499977096599470454020828166226237857393450736339007967\ +761930577506740176324673600968951340535537458516661134223766\ +678604162159680461914467291840300530057530849048765391711386\ +591646239524912623653881879636239373280423891018672348497668\ +235089863388587925628302755995657524455507255189313690836254\ +779186948667994968324049705821028513185451396213837722826145\ +437693412532098591327667236328124999e-324; +static const double d1b = +2.4703282292062327208828439643411068618252990130716238221279\ +284125033775363510437593264991818081799618989828234772285886\ +546332835517796989819938739800539093906315035659515570226392\ +290858392449105184435931802849936536152500319370457678249219\ +365623669863658480757001585769269903706311928279558551332927\ +834338409351978015531246597263579574622766465272827220056374\ +006485499977096599470454020828166226237857393450736339007967\ +761930577506740176324673600968951340535537458516661134223766\ +678604162159680461914467291840300530057530849048765391711386\ +591646239524912623653881879636239373280423891018672348497668\ +235089863388587925628302755995657524455507255189313690836254\ +779186948667994968324049705821028513185451396213837722826145\ +437693412532098591327667236328125e-324; +static const double d1c = +2.4703282292062327208828439643411068618252990130716238221279\ +284125033775363510437593264991818081799618989828234772285886\ +546332835517796989819938739800539093906315035659515570226392\ +290858392449105184435931802849936536152500319370457678249219\ +365623669863658480757001585769269903706311928279558551332927\ +834338409351978015531246597263579574622766465272827220056374\ +006485499977096599470454020828166226237857393450736339007967\ +761930577506740176324673600968951340535537458516661134223766\ +678604162159680461914467291840300530057530849048765391711386\ +591646239524912623653881879636239373280423891018672348497668\ +235089863388587925628302755995657524455507255189313690836254\ +779186948667994968324049705821028513185451396213837722826145\ +437693412532098591327667236328125001e-324; +/* 0x1.8p-1074 */ +static const double d2ae = 0x1p-1074, d2be = 0x2p-1074, d2ce = 0x2p-1074; +static const double d2a = +7.4109846876186981626485318930233205854758970392148714663837\ +852375101326090531312779794975454245398856969484704316857659\ +638998506553390969459816219401617281718945106978546710679176\ +872575177347315553307795408549809608457500958111373034747658\ +096871009590975442271004757307809711118935784838675653998783\ +503015228055934046593739791790738723868299395818481660169122\ +019456499931289798411362062484498678713572180352209017023903\ +285791732520220528974020802906854021606612375549983402671300\ +035812486479041385743401875520901590172592547146296175134159\ +774938718574737870961645638908718119841271673056017045493004\ +705269590165763776884908267986972573366521765567941072508764\ +337560846003984904972149117463085539556354188641513168478436\ +313080237596295773983001708984374999e-324; +static const double d2b = +7.4109846876186981626485318930233205854758970392148714663837\ +852375101326090531312779794975454245398856969484704316857659\ +638998506553390969459816219401617281718945106978546710679176\ +872575177347315553307795408549809608457500958111373034747658\ +096871009590975442271004757307809711118935784838675653998783\ +503015228055934046593739791790738723868299395818481660169122\ +019456499931289798411362062484498678713572180352209017023903\ +285791732520220528974020802906854021606612375549983402671300\ +035812486479041385743401875520901590172592547146296175134159\ +774938718574737870961645638908718119841271673056017045493004\ +705269590165763776884908267986972573366521765567941072508764\ +337560846003984904972149117463085539556354188641513168478436\ +313080237596295773983001708984375e-324; +static const double d2c = +7.4109846876186981626485318930233205854758970392148714663837\ +852375101326090531312779794975454245398856969484704316857659\ +638998506553390969459816219401617281718945106978546710679176\ +872575177347315553307795408549809608457500958111373034747658\ +096871009590975442271004757307809711118935784838675653998783\ +503015228055934046593739791790738723868299395818481660169122\ +019456499931289798411362062484498678713572180352209017023903\ +285791732520220528974020802906854021606612375549983402671300\ +035812486479041385743401875520901590172592547146296175134159\ +774938718574737870961645638908718119841271673056017045493004\ +705269590165763776884908267986972573366521765567941072508764\ +337560846003984904972149117463085539556354188641513168478436\ +313080237596295773983001708984375001e-324; +/* 0x1.00000000000008p1023 */ +static const double d3ae = 0x1p1023, d3be = 0x1p1023, d3ce = 0x1.0000000000001p1023; +static const double d3a = +8.9884656743115805365666807213050294962762414131308158973971\ +342756154045415486693752413698006024096935349884403114202125\ +541629105369684531108613657287705365884742938136589844238179\ +474556051429647415148697857438797685859063890851407391008830\ +874765563025951597582513936655578157348020066364210154316532\ +161708031999e+307; +static const double d3b = +8.9884656743115805365666807213050294962762414131308158973971\ +342756154045415486693752413698006024096935349884403114202125\ +541629105369684531108613657287705365884742938136589844238179\ +474556051429647415148697857438797685859063890851407391008830\ +874765563025951597582513936655578157348020066364210154316532\ +161708032e+307; +static const double d3c = +8.9884656743115805365666807213050294962762414131308158973971\ +342756154045415486693752413698006024096935349884403114202125\ +541629105369684531108613657287705365884742938136589844238179\ +474556051429647415148697857438797685859063890851407391008830\ +874765563025951597582513936655578157348020066364210154316532\ +161708032001e+307; +#endif + +#if LDBL_MANT_DIG == 53 \ + && LDBL_MIN_EXP == -1021 \ + && LDBL_MAX_EXP == 1024 +# define LDBL_OK +/* 0x0.8p-1074 */ +static const long double ld1ae = 0, ld1be = 0, ld1ce = 0x1p-1074L; +static const long double ld1a = +2.4703282292062327208828439643411068618252990130716238221279\ +284125033775363510437593264991818081799618989828234772285886\ +546332835517796989819938739800539093906315035659515570226392\ +290858392449105184435931802849936536152500319370457678249219\ +365623669863658480757001585769269903706311928279558551332927\ +834338409351978015531246597263579574622766465272827220056374\ +006485499977096599470454020828166226237857393450736339007967\ +761930577506740176324673600968951340535537458516661134223766\ +678604162159680461914467291840300530057530849048765391711386\ +591646239524912623653881879636239373280423891018672348497668\ +235089863388587925628302755995657524455507255189313690836254\ +779186948667994968324049705821028513185451396213837722826145\ +437693412532098591327667236328124999e-324L; +static const long double ld1b = +2.4703282292062327208828439643411068618252990130716238221279\ +284125033775363510437593264991818081799618989828234772285886\ +546332835517796989819938739800539093906315035659515570226392\ +290858392449105184435931802849936536152500319370457678249219\ +365623669863658480757001585769269903706311928279558551332927\ +834338409351978015531246597263579574622766465272827220056374\ +006485499977096599470454020828166226237857393450736339007967\ +761930577506740176324673600968951340535537458516661134223766\ +678604162159680461914467291840300530057530849048765391711386\ +591646239524912623653881879636239373280423891018672348497668\ +235089863388587925628302755995657524455507255189313690836254\ +779186948667994968324049705821028513185451396213837722826145\ +437693412532098591327667236328125e-324L; +static const long double ld1c = +2.4703282292062327208828439643411068618252990130716238221279\ +284125033775363510437593264991818081799618989828234772285886\ +546332835517796989819938739800539093906315035659515570226392\ +290858392449105184435931802849936536152500319370457678249219\ +365623669863658480757001585769269903706311928279558551332927\ +834338409351978015531246597263579574622766465272827220056374\ +006485499977096599470454020828166226237857393450736339007967\ +761930577506740176324673600968951340535537458516661134223766\ +678604162159680461914467291840300530057530849048765391711386\ +591646239524912623653881879636239373280423891018672348497668\ +235089863388587925628302755995657524455507255189313690836254\ +779186948667994968324049705821028513185451396213837722826145\ +437693412532098591327667236328125001e-324L; +/* 0x1.8p-1074 */ +static const long double ld2ae = 0x1p-1074L, ld2be = 0x2p-1074L, ld2ce = 0x2p-1074L; +static const long double ld2a = +7.4109846876186981626485318930233205854758970392148714663837\ +852375101326090531312779794975454245398856969484704316857659\ +638998506553390969459816219401617281718945106978546710679176\ +872575177347315553307795408549809608457500958111373034747658\ +096871009590975442271004757307809711118935784838675653998783\ +503015228055934046593739791790738723868299395818481660169122\ +019456499931289798411362062484498678713572180352209017023903\ +285791732520220528974020802906854021606612375549983402671300\ +035812486479041385743401875520901590172592547146296175134159\ +774938718574737870961645638908718119841271673056017045493004\ +705269590165763776884908267986972573366521765567941072508764\ +337560846003984904972149117463085539556354188641513168478436\ +313080237596295773983001708984374999e-324L; +static const long double ld2b = +7.4109846876186981626485318930233205854758970392148714663837\ +852375101326090531312779794975454245398856969484704316857659\ +638998506553390969459816219401617281718945106978546710679176\ +872575177347315553307795408549809608457500958111373034747658\ +096871009590975442271004757307809711118935784838675653998783\ +503015228055934046593739791790738723868299395818481660169122\ +019456499931289798411362062484498678713572180352209017023903\ +285791732520220528974020802906854021606612375549983402671300\ +035812486479041385743401875520901590172592547146296175134159\ +774938718574737870961645638908718119841271673056017045493004\ +705269590165763776884908267986972573366521765567941072508764\ +337560846003984904972149117463085539556354188641513168478436\ +313080237596295773983001708984375e-324L; +static const long double ld2c = +7.4109846876186981626485318930233205854758970392148714663837\ +852375101326090531312779794975454245398856969484704316857659\ +638998506553390969459816219401617281718945106978546710679176\ +872575177347315553307795408549809608457500958111373034747658\ +096871009590975442271004757307809711118935784838675653998783\ +503015228055934046593739791790738723868299395818481660169122\ +019456499931289798411362062484498678713572180352209017023903\ +285791732520220528974020802906854021606612375549983402671300\ +035812486479041385743401875520901590172592547146296175134159\ +774938718574737870961645638908718119841271673056017045493004\ +705269590165763776884908267986972573366521765567941072508764\ +337560846003984904972149117463085539556354188641513168478436\ +313080237596295773983001708984375001e-324L; +/* 0x1.00000000000008p1023 */ +static const long double ld3ae = 0x1p1023L, ld3be = 0x1p1023L, ld3ce = 0x1.0000000000001p1023L; +static const long double ld3a = +8.9884656743115805365666807213050294962762414131308158973971\ +342756154045415486693752413698006024096935349884403114202125\ +541629105369684531108613657287705365884742938136589844238179\ +474556051429647415148697857438797685859063890851407391008830\ +874765563025951597582513936655578157348020066364210154316532\ +161708031999e+307L; +static const long double ld3b = +8.9884656743115805365666807213050294962762414131308158973971\ +342756154045415486693752413698006024096935349884403114202125\ +541629105369684531108613657287705365884742938136589844238179\ +474556051429647415148697857438797685859063890851407391008830\ +874765563025951597582513936655578157348020066364210154316532\ +161708032e+307L; +static const long double ld3c = +8.9884656743115805365666807213050294962762414131308158973971\ +342756154045415486693752413698006024096935349884403114202125\ +541629105369684531108613657287705365884742938136589844238179\ +474556051429647415148697857438797685859063890851407391008830\ +874765563025951597582513936655578157348020066364210154316532\ +161708032001e+307L; +#endif + +#if LDBL_MANT_DIG == 64 \ + && LDBL_MIN_EXP == -16381 \ + && LDBL_MAX_EXP == 16384 +# define LDBL_OK +/* 0x0.8p-16445 */ +static const long double ld1ae = 0, ld1be = 0, ld1ce = 0x1p-16445L; +static const long double ld1a = +1.8225997659412373012642029668097099081995254078467816718604\ +902435141858443166988684047803543129136025986236736736017655\ +509834928163110160849867540377949045027419112905889658392846\ +126319028167798783107812829917053644701598967767636342956203\ +999770864055077592691915230273843577112246476529298591341071\ +313110337661777304220340396298768698441131694859514066773321\ +059786469060001083813361460161387168195154228027648977594276\ +496061276605855817438145692314650177569263750801566422892936\ +732834290416745265618525969943519916542939199731612507343012\ +297331882934352282118173551211985973294301787840335672389913\ +821098681464088756477802684228806339233239542587316254618680\ +197563613907079766830481997222017010585267442240109888818022\ +189543438116245170584546472752661417773021275082355242554950\ +776248474101880875363872607989624146320823364146896124171892\ +610744237622308266702265704492674694505399997330424978964704\ +335411125839490463131661420668167686151828553033363555080508\ +484934542727634080467233927879117726432283352324546435315312\ +937809651095964197873430398662003709663353962932921239516263\ +008572512558260093668527782388349282015308359304941505110445\ +043762021191469060607078792635897736408141163554429972292873\ +575169264387977130124003958599909776720759582995017519144111\ +001778329839793855454688442046155253818724410472281602421363\ +580613990749181808302947976045417884436271162664776148749463\ +202753814797191206392480969096910387729527305862739806702349\ +088455828380471306603628636563037414688265702108098430515297\ +645997107159687247830496686980315376091511219227376708389862\ +310190633134517040835432587726931910775044780329777051964574\ +763119639404235797665922677433332402402817037657141926646502\ +612388421085254756323737273178774331073924707711575555193153\ +421957126062196520952920611871114861423032687425262323243276\ +848595495133802591437804984986053892365334900647137137197585\ +161954823956838391108748154877098567190695813394392779995887\ +642254413740232692940887236351533691174492514884514265006822\ +752026136435469700291628942927286843274959781329315250417360\ +438115330104516894597449604875954147108010051910197388860417\ +003307595774863477182911525109554542883460240867674794470854\ +883815424039187014069246137704710366577005576311674384079810\ +437206511282792194562503036151028910065418370565117488062226\ +073975854919243439941741016447206284543777826080409075756028\ +194465562812076645422284670475730922346454505830553174377950\ +824178034708147037448871898963699023373821217419560423459358\ +846127232531421552826545954362386431279626917642725181802754\ +271134597856231805666129524101509582941585421888561296839474\ +232056474112935379177434928227554149402642893913492062781246\ +372611175305462271711931011635602039137701669573065960945871\ +579420683440097179831368317352157202215160682058878025153007\ +184185319863451652087375936651004559837502483808090613073982\ +264685620351993519454344577635257452328683726988824705474397\ +398247190812883071734743260426540123481791283782928972842466\ +595210269414219040901793935553872090377394005932597887081359\ +481915849178541128182923272843218513093012167744690818603663\ +862691727272565325057703378827553284852502067686026850339624\ +401046086817036618366842240024522042069888708534827471235203\ +998932259309110942367856287784097166420437430118381247339347\ +418156902369282431197735078016591613063918260343498992697002\ +033186558413655576703389208301203552157755701852051877927864\ +696515420369217703510602759815252574799728706795849558382877\ +392016396900560101736741462690753991602263974212137632508984\ +264559315540891383192361601189350414311358816980975697568561\ +515680971830107704152657284552920241862730125888825702301035\ +564615759615882010733764341109834449576907982406265803484111\ +303615971297609065271517286111839839646343815364461776394273\ +571391219315553915335300622295196577640884201524657614065743\ +729121754460652975075990012786021662416077757235487562550381\ +116824006014440438178253273174734436163638119532295383351135\ +543170811596051785036366846773285937845231974424475418970517\ +659179798069972876889488877627309887323737590814875050457317\ +809625163713227973229002908003491739085115971899606986738405\ +752463436186745107821032315480693516006251388789902053863235\ +071957895722121876262598833823352290042576488238120724072267\ +480348425637199003147760378463243043407534395221882144887315\ +875876025907739792297575795373506429192468470170038312050500\ +917665707583420927303790875332407805094505665159755210495266\ +485594187244922216154283213688032393939401426499517609275128\ +062067355172333120857796045387692492375534056470145301671359\ +016602832469675123108598588424022216759334733452626330303791\ +660952659036162827509451468771297954737165701921676834866994\ +084496268491510599580714458155026746676860790028899722645883\ +679435969902046442373108472951515492761911884847211825930115\ +654927539118088350255959445076757398298893380662248358210075\ +297702191186519614515280395341723177201383862827129721649638\ +274531314762377778754560119397123180107310216608157141828379\ +259328274508467371717057031104537750450228447941619684073375\ +630517322006118640290925241602376256334414376495602911265450\ +165889418372161719063670619610214632774542741157366426747861\ +054811449449004970132668146607323502760146957586465275981090\ +328336256381187450646030492071694516054712444513961269623339\ +705411366337817643269316717217432478812002049894979925260411\ +553651385384826214231392012841425936827944383266227115236029\ +717393064659821056467446870597828757433936024422511537561864\ +619865595955628070343780472634463916608440151554502790128417\ +277259492437005696576453717387309605129939526661181496994297\ +244693710437436581443653555343763817246961834486181294985455\ +884981266421533438177271809310897035958260776218253097858601\ +160643120653927024652834025146166356877731266566437231429061\ +099807825113272551869352908241073955695854354852545370793609\ +838167127357752579007490955536081388103461735071174567636929\ +060824172375010035497010614957197713919909924635906503348016\ +450952475530978921242656498701313530533991692867619886826204\ +706468476070943378163577235406861262755114909606255628375659\ +196050370661430148107216310635729360112021571291096278032076\ +401092225373270173950575377792566872113768085940991929655824\ +050914085013970861399015141010432835406337266746706727481946\ +196898882472095111505210339933002505227334750020285673634670\ +738458390159933494226851499935336922036551687169140582574153\ +726872453800858360764892975201757027862632615130256075468549\ +502839367841926212872731925042838691319757663382746471782087\ +828988857978192483595747889021081459460627705275735868618724\ +958783348362295106875556443770626864591972089881215465141073\ +516646930158996569747675806719463602045230325049794904894739\ +988312727573320971310488326486213061839843830003145873279435\ +454121817918269218294901387830156432148142381592864575229119\ +479029130050663564889172093067341444164942736885872753984012\ +865743421266470861425283889134636885790293235727017788606167\ +560012477186697069994213912998550931078617189790771376702549\ +055361745205232419031423044366971378594392952093464046441667\ +117613906203494872209149396518971207279263883566606774353236\ +255473603377861613942239543893894460581170658088042083661404\ +937465706659424639301296621963906278930754459296017486063079\ +582024995485338893699574289806529424673393810217577605952909\ +491283123179789154639057105774960699934999681018155749261864\ +012821574480758746632022143860041252142846691648490809250856\ +327057133540568617791625295314357533564192304930155735301757\ +457531580062662693966772497728335047637869054460240023262262\ +260698443946964564691259441706490611176164305693669515767804\ +836460521205954731752583848846525153811934541997962775215961\ +180346397456122329133421016560406277159258781706172834569862\ +946953007793254152187010227976038449980797987728559041018441\ +590564594738308310579014597893182017151615208050090318483536\ +106249131918576316944251537092347119867433735046169725181104\ +507590928834713669184230634083190791725243913641206256399101\ +550966117564795555149420011152858441084271411289366093158722\ +254752761637144762690747726313899449121995142565661043193165\ +353010677613760383307839362361625628371456344409245507081913\ +518237257141164239966660785903970075181826808229440731778746\ +830751045427285945936163931997929399708401851740705527023711\ +492262489476846435969872480702228386506357017948329114555484\ +164760105906717855684788039081591713778852802032849601308169\ +832017420608399347713424218434541771868442189843417628618330\ +607429739733739437863581804003482214082370567967330530446020\ +897773385726872912189813323094415093143437550397556262780011\ +208941731420098754319961419532567861629590267320403217607660\ +774125374101195389953895035347940170148097810952083736798564\ +420421622607993390894450932047257403433908665884124601384175\ +012387617430467934818665777122459487877479257747635172691688\ +471574765285820096075133353869554987216398800026453207557923\ +535966131756358352198875705382763163680830588056974671628368\ +719411827591592806044707764658145625683998557872894583705117\ +936257144994734815912058252772021032081682437093280526665192\ +728869800954748014250481042845426151143544474372887617562791\ +409866964806319608280819816846942058817381943129762034507591\ +367065185343216917751414811188645979508942996964383255432999\ +246119971295726296202396921903289017490293595312645036697141\ +581149988784499288560584613793415358537364677872496224892098\ +940856692342358755626519304557946447004033186014602147449599\ +351317079758304444877174136521487256811625263467410007624215\ +856145392339552689565690577293133060124853654497575571509576\ +408069646196646757505249296126372820539234090564691695806544\ +715766025588258581902342311480969412221466852421842650484494\ +063894865891424563992751226230317059592413191308470146226366\ +458233536657973376067140793776369412191789801225320255079444\ +592709005698858098716107025188986428347407279053266600044521\ +079987989879536957560131070100060050673537683871138182387904\ +590837539252425985326631955455857258818756188063697492342550\ +045277400125480079927908846850898283905756532829762950509886\ +991675925213188409911532242068610889478326451513981115020992\ +630395715520350039372702741107911736947893709538471200363740\ +669304116845653259038102180504837110789645359520309929381266\ +271463740502507456882882255788069710715770802338317704510793\ +279398576163709512326095306022330346997717688118726634628650\ +675984237916551201500684504118483305560295744746257951860545\ +390826531622290588364837980034428055971370065573420370270905\ +592141420051502465016793525150950140243606137664910359769114\ +512792293426708006440346732679574519594848136194781488696994\ +267355775509666977187349644291823026624985531726865131782364\ +428380093055155988532106121916567178604128111080322761213573\ +781334480667563871257352254033032675246444238637990062075058\ +819854494711379915549313390179300091783493496822950479766923\ +983305064901026858870340863556799948310622536592472509634484\ +910640735459644047154918467543140024764605449756679450446473\ +048922824617117723876384637412932380635306714345354710568410\ +140587435077620501285599837051978855056335305570615129711860\ +309387503970812843734718712815925040263182888714533431137355\ +255722368962836390856001176889513153529416105504464217522618\ +741534232432067776306691118141998014985541610448993152948945\ +865983354717289054861249734477980864059509622993770525110616\ +313865830823478927462500895844216364365499438449134659145333\ +799994034010282254566331595018205841080487728993632798168070\ +476921205941768965021887178681810499301253039335978279707627\ +295287697256489961179958946847840431902105306618594831078534\ +622089641993900896756734276531931450266972752637997248151974\ +2277811246822238899767398834228515624999e-4951L; +static const long double ld1b = +1.8225997659412373012642029668097099081995254078467816718604\ +902435141858443166988684047803543129136025986236736736017655\ +509834928163110160849867540377949045027419112905889658392846\ +126319028167798783107812829917053644701598967767636342956203\ +999770864055077592691915230273843577112246476529298591341071\ +313110337661777304220340396298768698441131694859514066773321\ +059786469060001083813361460161387168195154228027648977594276\ +496061276605855817438145692314650177569263750801566422892936\ +732834290416745265618525969943519916542939199731612507343012\ +297331882934352282118173551211985973294301787840335672389913\ +821098681464088756477802684228806339233239542587316254618680\ +197563613907079766830481997222017010585267442240109888818022\ +189543438116245170584546472752661417773021275082355242554950\ +776248474101880875363872607989624146320823364146896124171892\ +610744237622308266702265704492674694505399997330424978964704\ +335411125839490463131661420668167686151828553033363555080508\ +484934542727634080467233927879117726432283352324546435315312\ +937809651095964197873430398662003709663353962932921239516263\ +008572512558260093668527782388349282015308359304941505110445\ +043762021191469060607078792635897736408141163554429972292873\ +575169264387977130124003958599909776720759582995017519144111\ +001778329839793855454688442046155253818724410472281602421363\ +580613990749181808302947976045417884436271162664776148749463\ +202753814797191206392480969096910387729527305862739806702349\ +088455828380471306603628636563037414688265702108098430515297\ +645997107159687247830496686980315376091511219227376708389862\ +310190633134517040835432587726931910775044780329777051964574\ +763119639404235797665922677433332402402817037657141926646502\ +612388421085254756323737273178774331073924707711575555193153\ +421957126062196520952920611871114861423032687425262323243276\ +848595495133802591437804984986053892365334900647137137197585\ +161954823956838391108748154877098567190695813394392779995887\ +642254413740232692940887236351533691174492514884514265006822\ +752026136435469700291628942927286843274959781329315250417360\ +438115330104516894597449604875954147108010051910197388860417\ +003307595774863477182911525109554542883460240867674794470854\ +883815424039187014069246137704710366577005576311674384079810\ +437206511282792194562503036151028910065418370565117488062226\ +073975854919243439941741016447206284543777826080409075756028\ +194465562812076645422284670475730922346454505830553174377950\ +824178034708147037448871898963699023373821217419560423459358\ +846127232531421552826545954362386431279626917642725181802754\ +271134597856231805666129524101509582941585421888561296839474\ +232056474112935379177434928227554149402642893913492062781246\ +372611175305462271711931011635602039137701669573065960945871\ +579420683440097179831368317352157202215160682058878025153007\ +184185319863451652087375936651004559837502483808090613073982\ +264685620351993519454344577635257452328683726988824705474397\ +398247190812883071734743260426540123481791283782928972842466\ +595210269414219040901793935553872090377394005932597887081359\ +481915849178541128182923272843218513093012167744690818603663\ +862691727272565325057703378827553284852502067686026850339624\ +401046086817036618366842240024522042069888708534827471235203\ +998932259309110942367856287784097166420437430118381247339347\ +418156902369282431197735078016591613063918260343498992697002\ +033186558413655576703389208301203552157755701852051877927864\ +696515420369217703510602759815252574799728706795849558382877\ +392016396900560101736741462690753991602263974212137632508984\ +264559315540891383192361601189350414311358816980975697568561\ +515680971830107704152657284552920241862730125888825702301035\ +564615759615882010733764341109834449576907982406265803484111\ +303615971297609065271517286111839839646343815364461776394273\ +571391219315553915335300622295196577640884201524657614065743\ +729121754460652975075990012786021662416077757235487562550381\ +116824006014440438178253273174734436163638119532295383351135\ +543170811596051785036366846773285937845231974424475418970517\ +659179798069972876889488877627309887323737590814875050457317\ +809625163713227973229002908003491739085115971899606986738405\ +752463436186745107821032315480693516006251388789902053863235\ +071957895722121876262598833823352290042576488238120724072267\ +480348425637199003147760378463243043407534395221882144887315\ +875876025907739792297575795373506429192468470170038312050500\ +917665707583420927303790875332407805094505665159755210495266\ +485594187244922216154283213688032393939401426499517609275128\ +062067355172333120857796045387692492375534056470145301671359\ +016602832469675123108598588424022216759334733452626330303791\ +660952659036162827509451468771297954737165701921676834866994\ +084496268491510599580714458155026746676860790028899722645883\ +679435969902046442373108472951515492761911884847211825930115\ +654927539118088350255959445076757398298893380662248358210075\ +297702191186519614515280395341723177201383862827129721649638\ +274531314762377778754560119397123180107310216608157141828379\ +259328274508467371717057031104537750450228447941619684073375\ +630517322006118640290925241602376256334414376495602911265450\ +165889418372161719063670619610214632774542741157366426747861\ +054811449449004970132668146607323502760146957586465275981090\ +328336256381187450646030492071694516054712444513961269623339\ +705411366337817643269316717217432478812002049894979925260411\ +553651385384826214231392012841425936827944383266227115236029\ +717393064659821056467446870597828757433936024422511537561864\ +619865595955628070343780472634463916608440151554502790128417\ +277259492437005696576453717387309605129939526661181496994297\ +244693710437436581443653555343763817246961834486181294985455\ +884981266421533438177271809310897035958260776218253097858601\ +160643120653927024652834025146166356877731266566437231429061\ +099807825113272551869352908241073955695854354852545370793609\ +838167127357752579007490955536081388103461735071174567636929\ +060824172375010035497010614957197713919909924635906503348016\ +450952475530978921242656498701313530533991692867619886826204\ +706468476070943378163577235406861262755114909606255628375659\ +196050370661430148107216310635729360112021571291096278032076\ +401092225373270173950575377792566872113768085940991929655824\ +050914085013970861399015141010432835406337266746706727481946\ +196898882472095111505210339933002505227334750020285673634670\ +738458390159933494226851499935336922036551687169140582574153\ +726872453800858360764892975201757027862632615130256075468549\ +502839367841926212872731925042838691319757663382746471782087\ +828988857978192483595747889021081459460627705275735868618724\ +958783348362295106875556443770626864591972089881215465141073\ +516646930158996569747675806719463602045230325049794904894739\ +988312727573320971310488326486213061839843830003145873279435\ +454121817918269218294901387830156432148142381592864575229119\ +479029130050663564889172093067341444164942736885872753984012\ +865743421266470861425283889134636885790293235727017788606167\ +560012477186697069994213912998550931078617189790771376702549\ +055361745205232419031423044366971378594392952093464046441667\ +117613906203494872209149396518971207279263883566606774353236\ +255473603377861613942239543893894460581170658088042083661404\ +937465706659424639301296621963906278930754459296017486063079\ +582024995485338893699574289806529424673393810217577605952909\ +491283123179789154639057105774960699934999681018155749261864\ +012821574480758746632022143860041252142846691648490809250856\ +327057133540568617791625295314357533564192304930155735301757\ +457531580062662693966772497728335047637869054460240023262262\ +260698443946964564691259441706490611176164305693669515767804\ +836460521205954731752583848846525153811934541997962775215961\ +180346397456122329133421016560406277159258781706172834569862\ +946953007793254152187010227976038449980797987728559041018441\ +590564594738308310579014597893182017151615208050090318483536\ +106249131918576316944251537092347119867433735046169725181104\ +507590928834713669184230634083190791725243913641206256399101\ +550966117564795555149420011152858441084271411289366093158722\ +254752761637144762690747726313899449121995142565661043193165\ +353010677613760383307839362361625628371456344409245507081913\ +518237257141164239966660785903970075181826808229440731778746\ +830751045427285945936163931997929399708401851740705527023711\ +492262489476846435969872480702228386506357017948329114555484\ +164760105906717855684788039081591713778852802032849601308169\ +832017420608399347713424218434541771868442189843417628618330\ +607429739733739437863581804003482214082370567967330530446020\ +897773385726872912189813323094415093143437550397556262780011\ +208941731420098754319961419532567861629590267320403217607660\ +774125374101195389953895035347940170148097810952083736798564\ +420421622607993390894450932047257403433908665884124601384175\ +012387617430467934818665777122459487877479257747635172691688\ +471574765285820096075133353869554987216398800026453207557923\ +535966131756358352198875705382763163680830588056974671628368\ +719411827591592806044707764658145625683998557872894583705117\ +936257144994734815912058252772021032081682437093280526665192\ +728869800954748014250481042845426151143544474372887617562791\ +409866964806319608280819816846942058817381943129762034507591\ +367065185343216917751414811188645979508942996964383255432999\ +246119971295726296202396921903289017490293595312645036697141\ +581149988784499288560584613793415358537364677872496224892098\ +940856692342358755626519304557946447004033186014602147449599\ +351317079758304444877174136521487256811625263467410007624215\ +856145392339552689565690577293133060124853654497575571509576\ +408069646196646757505249296126372820539234090564691695806544\ +715766025588258581902342311480969412221466852421842650484494\ +063894865891424563992751226230317059592413191308470146226366\ +458233536657973376067140793776369412191789801225320255079444\ +592709005698858098716107025188986428347407279053266600044521\ +079987989879536957560131070100060050673537683871138182387904\ +590837539252425985326631955455857258818756188063697492342550\ +045277400125480079927908846850898283905756532829762950509886\ +991675925213188409911532242068610889478326451513981115020992\ +630395715520350039372702741107911736947893709538471200363740\ +669304116845653259038102180504837110789645359520309929381266\ +271463740502507456882882255788069710715770802338317704510793\ +279398576163709512326095306022330346997717688118726634628650\ +675984237916551201500684504118483305560295744746257951860545\ +390826531622290588364837980034428055971370065573420370270905\ +592141420051502465016793525150950140243606137664910359769114\ +512792293426708006440346732679574519594848136194781488696994\ +267355775509666977187349644291823026624985531726865131782364\ +428380093055155988532106121916567178604128111080322761213573\ +781334480667563871257352254033032675246444238637990062075058\ +819854494711379915549313390179300091783493496822950479766923\ +983305064901026858870340863556799948310622536592472509634484\ +910640735459644047154918467543140024764605449756679450446473\ +048922824617117723876384637412932380635306714345354710568410\ +140587435077620501285599837051978855056335305570615129711860\ +309387503970812843734718712815925040263182888714533431137355\ +255722368962836390856001176889513153529416105504464217522618\ +741534232432067776306691118141998014985541610448993152948945\ +865983354717289054861249734477980864059509622993770525110616\ +313865830823478927462500895844216364365499438449134659145333\ +799994034010282254566331595018205841080487728993632798168070\ +476921205941768965021887178681810499301253039335978279707627\ +295287697256489961179958946847840431902105306618594831078534\ +622089641993900896756734276531931450266972752637997248151974\ +2277811246822238899767398834228515625e-4951L; +static const long double ld1c = +1.8225997659412373012642029668097099081995254078467816718604\ +902435141858443166988684047803543129136025986236736736017655\ +509834928163110160849867540377949045027419112905889658392846\ +126319028167798783107812829917053644701598967767636342956203\ +999770864055077592691915230273843577112246476529298591341071\ +313110337661777304220340396298768698441131694859514066773321\ +059786469060001083813361460161387168195154228027648977594276\ +496061276605855817438145692314650177569263750801566422892936\ +732834290416745265618525969943519916542939199731612507343012\ +297331882934352282118173551211985973294301787840335672389913\ +821098681464088756477802684228806339233239542587316254618680\ +197563613907079766830481997222017010585267442240109888818022\ +189543438116245170584546472752661417773021275082355242554950\ +776248474101880875363872607989624146320823364146896124171892\ +610744237622308266702265704492674694505399997330424978964704\ +335411125839490463131661420668167686151828553033363555080508\ +484934542727634080467233927879117726432283352324546435315312\ +937809651095964197873430398662003709663353962932921239516263\ +008572512558260093668527782388349282015308359304941505110445\ +043762021191469060607078792635897736408141163554429972292873\ +575169264387977130124003958599909776720759582995017519144111\ +001778329839793855454688442046155253818724410472281602421363\ +580613990749181808302947976045417884436271162664776148749463\ +202753814797191206392480969096910387729527305862739806702349\ +088455828380471306603628636563037414688265702108098430515297\ +645997107159687247830496686980315376091511219227376708389862\ +310190633134517040835432587726931910775044780329777051964574\ +763119639404235797665922677433332402402817037657141926646502\ +612388421085254756323737273178774331073924707711575555193153\ +421957126062196520952920611871114861423032687425262323243276\ +848595495133802591437804984986053892365334900647137137197585\ +161954823956838391108748154877098567190695813394392779995887\ +642254413740232692940887236351533691174492514884514265006822\ +752026136435469700291628942927286843274959781329315250417360\ +438115330104516894597449604875954147108010051910197388860417\ +003307595774863477182911525109554542883460240867674794470854\ +883815424039187014069246137704710366577005576311674384079810\ +437206511282792194562503036151028910065418370565117488062226\ +073975854919243439941741016447206284543777826080409075756028\ +194465562812076645422284670475730922346454505830553174377950\ +824178034708147037448871898963699023373821217419560423459358\ +846127232531421552826545954362386431279626917642725181802754\ +271134597856231805666129524101509582941585421888561296839474\ +232056474112935379177434928227554149402642893913492062781246\ +372611175305462271711931011635602039137701669573065960945871\ +579420683440097179831368317352157202215160682058878025153007\ +184185319863451652087375936651004559837502483808090613073982\ +264685620351993519454344577635257452328683726988824705474397\ +398247190812883071734743260426540123481791283782928972842466\ +595210269414219040901793935553872090377394005932597887081359\ +481915849178541128182923272843218513093012167744690818603663\ +862691727272565325057703378827553284852502067686026850339624\ +401046086817036618366842240024522042069888708534827471235203\ +998932259309110942367856287784097166420437430118381247339347\ +418156902369282431197735078016591613063918260343498992697002\ +033186558413655576703389208301203552157755701852051877927864\ +696515420369217703510602759815252574799728706795849558382877\ +392016396900560101736741462690753991602263974212137632508984\ +264559315540891383192361601189350414311358816980975697568561\ +515680971830107704152657284552920241862730125888825702301035\ +564615759615882010733764341109834449576907982406265803484111\ +303615971297609065271517286111839839646343815364461776394273\ +571391219315553915335300622295196577640884201524657614065743\ +729121754460652975075990012786021662416077757235487562550381\ +116824006014440438178253273174734436163638119532295383351135\ +543170811596051785036366846773285937845231974424475418970517\ +659179798069972876889488877627309887323737590814875050457317\ +809625163713227973229002908003491739085115971899606986738405\ +752463436186745107821032315480693516006251388789902053863235\ +071957895722121876262598833823352290042576488238120724072267\ +480348425637199003147760378463243043407534395221882144887315\ +875876025907739792297575795373506429192468470170038312050500\ +917665707583420927303790875332407805094505665159755210495266\ +485594187244922216154283213688032393939401426499517609275128\ +062067355172333120857796045387692492375534056470145301671359\ +016602832469675123108598588424022216759334733452626330303791\ +660952659036162827509451468771297954737165701921676834866994\ +084496268491510599580714458155026746676860790028899722645883\ +679435969902046442373108472951515492761911884847211825930115\ +654927539118088350255959445076757398298893380662248358210075\ +297702191186519614515280395341723177201383862827129721649638\ +274531314762377778754560119397123180107310216608157141828379\ +259328274508467371717057031104537750450228447941619684073375\ +630517322006118640290925241602376256334414376495602911265450\ +165889418372161719063670619610214632774542741157366426747861\ +054811449449004970132668146607323502760146957586465275981090\ +328336256381187450646030492071694516054712444513961269623339\ +705411366337817643269316717217432478812002049894979925260411\ +553651385384826214231392012841425936827944383266227115236029\ +717393064659821056467446870597828757433936024422511537561864\ +619865595955628070343780472634463916608440151554502790128417\ +277259492437005696576453717387309605129939526661181496994297\ +244693710437436581443653555343763817246961834486181294985455\ +884981266421533438177271809310897035958260776218253097858601\ +160643120653927024652834025146166356877731266566437231429061\ +099807825113272551869352908241073955695854354852545370793609\ +838167127357752579007490955536081388103461735071174567636929\ +060824172375010035497010614957197713919909924635906503348016\ +450952475530978921242656498701313530533991692867619886826204\ +706468476070943378163577235406861262755114909606255628375659\ +196050370661430148107216310635729360112021571291096278032076\ +401092225373270173950575377792566872113768085940991929655824\ +050914085013970861399015141010432835406337266746706727481946\ +196898882472095111505210339933002505227334750020285673634670\ +738458390159933494226851499935336922036551687169140582574153\ +726872453800858360764892975201757027862632615130256075468549\ +502839367841926212872731925042838691319757663382746471782087\ +828988857978192483595747889021081459460627705275735868618724\ +958783348362295106875556443770626864591972089881215465141073\ +516646930158996569747675806719463602045230325049794904894739\ +988312727573320971310488326486213061839843830003145873279435\ +454121817918269218294901387830156432148142381592864575229119\ +479029130050663564889172093067341444164942736885872753984012\ +865743421266470861425283889134636885790293235727017788606167\ +560012477186697069994213912998550931078617189790771376702549\ +055361745205232419031423044366971378594392952093464046441667\ +117613906203494872209149396518971207279263883566606774353236\ +255473603377861613942239543893894460581170658088042083661404\ +937465706659424639301296621963906278930754459296017486063079\ +582024995485338893699574289806529424673393810217577605952909\ +491283123179789154639057105774960699934999681018155749261864\ +012821574480758746632022143860041252142846691648490809250856\ +327057133540568617791625295314357533564192304930155735301757\ +457531580062662693966772497728335047637869054460240023262262\ +260698443946964564691259441706490611176164305693669515767804\ +836460521205954731752583848846525153811934541997962775215961\ +180346397456122329133421016560406277159258781706172834569862\ +946953007793254152187010227976038449980797987728559041018441\ +590564594738308310579014597893182017151615208050090318483536\ +106249131918576316944251537092347119867433735046169725181104\ +507590928834713669184230634083190791725243913641206256399101\ +550966117564795555149420011152858441084271411289366093158722\ +254752761637144762690747726313899449121995142565661043193165\ +353010677613760383307839362361625628371456344409245507081913\ +518237257141164239966660785903970075181826808229440731778746\ +830751045427285945936163931997929399708401851740705527023711\ +492262489476846435969872480702228386506357017948329114555484\ +164760105906717855684788039081591713778852802032849601308169\ +832017420608399347713424218434541771868442189843417628618330\ +607429739733739437863581804003482214082370567967330530446020\ +897773385726872912189813323094415093143437550397556262780011\ +208941731420098754319961419532567861629590267320403217607660\ +774125374101195389953895035347940170148097810952083736798564\ +420421622607993390894450932047257403433908665884124601384175\ +012387617430467934818665777122459487877479257747635172691688\ +471574765285820096075133353869554987216398800026453207557923\ +535966131756358352198875705382763163680830588056974671628368\ +719411827591592806044707764658145625683998557872894583705117\ +936257144994734815912058252772021032081682437093280526665192\ +728869800954748014250481042845426151143544474372887617562791\ +409866964806319608280819816846942058817381943129762034507591\ +367065185343216917751414811188645979508942996964383255432999\ +246119971295726296202396921903289017490293595312645036697141\ +581149988784499288560584613793415358537364677872496224892098\ +940856692342358755626519304557946447004033186014602147449599\ +351317079758304444877174136521487256811625263467410007624215\ +856145392339552689565690577293133060124853654497575571509576\ +408069646196646757505249296126372820539234090564691695806544\ +715766025588258581902342311480969412221466852421842650484494\ +063894865891424563992751226230317059592413191308470146226366\ +458233536657973376067140793776369412191789801225320255079444\ +592709005698858098716107025188986428347407279053266600044521\ +079987989879536957560131070100060050673537683871138182387904\ +590837539252425985326631955455857258818756188063697492342550\ +045277400125480079927908846850898283905756532829762950509886\ +991675925213188409911532242068610889478326451513981115020992\ +630395715520350039372702741107911736947893709538471200363740\ +669304116845653259038102180504837110789645359520309929381266\ +271463740502507456882882255788069710715770802338317704510793\ +279398576163709512326095306022330346997717688118726634628650\ +675984237916551201500684504118483305560295744746257951860545\ +390826531622290588364837980034428055971370065573420370270905\ +592141420051502465016793525150950140243606137664910359769114\ +512792293426708006440346732679574519594848136194781488696994\ +267355775509666977187349644291823026624985531726865131782364\ +428380093055155988532106121916567178604128111080322761213573\ +781334480667563871257352254033032675246444238637990062075058\ +819854494711379915549313390179300091783493496822950479766923\ +983305064901026858870340863556799948310622536592472509634484\ +910640735459644047154918467543140024764605449756679450446473\ +048922824617117723876384637412932380635306714345354710568410\ +140587435077620501285599837051978855056335305570615129711860\ +309387503970812843734718712815925040263182888714533431137355\ +255722368962836390856001176889513153529416105504464217522618\ +741534232432067776306691118141998014985541610448993152948945\ +865983354717289054861249734477980864059509622993770525110616\ +313865830823478927462500895844216364365499438449134659145333\ +799994034010282254566331595018205841080487728993632798168070\ +476921205941768965021887178681810499301253039335978279707627\ +295287697256489961179958946847840431902105306618594831078534\ +622089641993900896756734276531931450266972752637997248151974\ +2277811246822238899767398834228515625001e-4951L; +/* 0x1.8p-16445 */ +static const long double ld2ae = 0x1p-16445L, ld2be = 0x2p-16445L, ld2ce = 0x2p-16445L; +static const long double ld2a = +5.4677992978237119037926089004291297245985762235403450155814\ +707305425575329500966052143410629387408077958710210208052966\ +529504784489330482549602621133847135082257338717668975178538\ +378957084503396349323438489751160934104796903302909028868611\ +999312592165232778075745690821530731336739429587895774023213\ +939331012985331912661021188896306095323395084578542200319963\ +179359407180003251440084380484161504585462684082946932782829\ +488183829817567452314437076943950532707791252404699268678810\ +198502871250235796855577909830559749628817599194837522029036\ +891995648803056846354520653635957919882905363521007017169741\ +463296044392266269433408052686419017699718627761948763856040\ +592690841721239300491445991666051031755802326720329666454066\ +568630314348735511753639418257984253319063825247065727664852\ +328745422305642626091617823968872438962470092440688372515677\ +832232712866924800106797113478024083516199991991274936894113\ +006233377518471389394984262004503058455485659100090665241525\ +454803628182902241401701783637353179296850056973639305945938\ +813428953287892593620291195986011128990061888798763718548789\ +025717537674780281005583347165047846045925077914824515331335\ +131286063574407181821236377907693209224423490663289916878620\ +725507793163931390372011875799729330162278748985052557432333\ +005334989519381566364065326138465761456173231416844807264090\ +741841972247545424908843928136253653308813487994328446248389\ +608261444391573619177442907290731163188581917588219420107047\ +265367485141413919810885909689112244064797106324295291545892\ +937991321479061743491490060940946128274533657682130125169586\ +930571899403551122506297763180795732325134340989331155893724\ +289358918212707392997768032299997207208451112971425779939507\ +837165263255764268971211819536322993221774123134726665579460\ +265871378186589562858761835613344584269098062275786969729830\ +545786485401407774313414954958161677096004701941411411592755\ +485864471870515173326244464631295701572087440183178339987662\ +926763241220698078822661709054601073523477544653542795020468\ +256078409306409100874886828781860529824879343987945751252081\ +314345990313550683792348814627862441324030155730592166581251\ +009922787324590431548734575328663628650380722603024383412564\ +651446272117561042207738413114131099731016728935023152239431\ +311619533848376583687509108453086730196255111695352464186678\ +221927564757730319825223049341618853631333478241227227268084\ +583396688436229936266854011427192767039363517491659523133852\ +472534104124441112346615696891097070121463652258681270378076\ +538381697594264658479637863087159293838880752928175545408262\ +813403793568695416998388572304528748824756265665683890518422\ +696169422338806137532304784682662448207928681740476188343739\ +117833525916386815135793034906806117413105008719197882837614\ +738262050320291539494104952056471606645482046176634075459021\ +552555959590354956262127809953013679512507451424271839221946\ +794056861055980558363033732905772356986051180966474116423192\ +194741572438649215204229781279620370445373851348786918527399\ +785630808242657122705381806661616271132182017797793661244078\ +445747547535623384548769818529655539279036503234072455810991\ +588075181817695975173110136482659854557506203058080551018873\ +203138260451109855100526720073566126209666125604482413705611\ +996796777927332827103568863352291499261312290355143742018042\ +254470707107847293593205234049774839191754781030496978091006\ +099559675240966730110167624903610656473267105556155633783594\ +089546261107653110531808279445757724399186120387548675148632\ +176049190701680305210224388072261974806791922636412897526952\ +793677946622674149577084803568051242934076450942927092705684\ +547042915490323112457971853658760725588190377666477106903106\ +693847278847646032201293023329503348730723947218797410452333\ +910847913892827195814551858335519518939031446093385329182820\ +714173657946661746005901866885589732922652604573972842197231\ +187365263381958925227970038358064987248233271706462687651143\ +350472018043321314534759819524203308490914358596886150053406\ +629512434788155355109100540319857813535695923273426256911552\ +977539394209918630668466632881929661971212772444625151371953\ +428875491139683919687008724010475217255347915698820960215217\ +257390308560235323463096946442080548018754166369706161589705\ +215873687166365628787796501470056870127729464714362172216802\ +441045276911597009443281135389729130222603185665646434661947\ +627628077723219376892727386120519287577405410510114936151502\ +752997122750262781911372625997223415283516995479265631485799\ +456782561734766648462849641064097181818204279498552827825384\ +186202065516999362573388136163077477126602169410435905014077\ +049808497409025369325795765272066650278004200357878990911374\ +982857977108488482528354406313893864211497105765030504600982\ +253488805474531798742143374465080240030582370086699167937651\ +038307909706139327119325418854546478285735654541635477790346\ +964782617354265050767878335230272194896680141986745074630225\ +893106573559558843545841186025169531604151588481389164948914\ +823593944287133336263680358191369540321930649824471425485137\ +777984823525402115151171093313613251350685343824859052220126\ +891551966018355920872775724807128769003243129486808733796350\ +497668255116485157191011858830643898323628223472099280243583\ +164434348347014910398004439821970508280440872759395827943270\ +985008769143562351938091476215083548164137333541883808870019\ +116234099013452929807950151652297436436006149684939775781234\ +660954156154478642694176038524277810483833149798681345708089\ +152179193979463169402340611793486272301808073267534612685593\ +859596787866884211031341417903391749825320454663508370385251\ +831778477311017089729361152161928815389818579983544490982891\ +734081131312309744330960666031291451740885503458543884956367\ +654943799264600314531815427932691107874782328654759293575803\ +481929361961781073958502075438499070633193799699311694287183\ +299423475339817655608058724723221867087563064557636112380829\ +514501382073257737022472866608244164310385205213523702910787\ +182472517125030106491031844871593141759729773907719510044049\ +352857426592936763727969496103940591601975078602859660478614\ +119405428212830134490731706220583788265344728818766885126977\ +588151111984290444321648931907188080336064713873288834096229\ +203276676119810521851726133377700616341304257822975788967472\ +152742255041912584197045423031298506219011800240120182445838\ +590696647416285334515631019799007515682004250060857020904012\ +215375170479800482680554499806010766109655061507421747722461\ +180617361402575082294678925605271083587897845390768226405648\ +508518103525778638618195775128516073959272990148239415346263\ +486966573934577450787243667063244378381883115827207605856174\ +876350045086885320626669331311880593775916269643646395423220\ +549940790476989709243027420158390806135690975149384714684219\ +964938182719962913931464979458639185519531490009437619838306\ +362365453754807654884704163490469296444427144778593725687358\ +437087390151990694667516279202024332494828210657618261952038\ +597230263799412584275851667403910657370879707181053365818502\ +680037431560091209982641738995652793235851569372314130107647\ +166085235615697257094269133100914135783178856280392139325001\ +352841718610484616627448189556913621837791650699820323059708\ +766420810133584841826718631681683381743511974264126250984214\ +812397119978273917903889865891718836792263377888052458189238\ +746074986456016681098722869419588274020181430652732817858728\ +473849369539367463917171317324882099804999043054467247785592\ +038464723442276239896066431580123756428540074945472427752568\ +981171400621705853374875885943072600692576914790467205905272\ +372594740187988081900317493185005142913607163380720069786786\ +782095331840893694073778325119471833528492917081008547303414\ +509381563617864195257751546539575461435803625993888325647883\ +541039192368366987400263049681218831477776345118518503709588\ +840859023379762456561030683928115349942393963185677123055324\ +771693784214924931737043793679546051454845624150270955450608\ +318747395755728950832754611277041359602301205138509175543313\ +522772786504141007552691902249572375175731740923618769197304\ +652898352694386665448260033458575323252814233868098279476166\ +764258284911434288072243178941698347365985427696983129579496\ +059032032841281149923518087084876885114369033227736521245740\ +554711771423492719899982357711910225545480424688322195336240\ +492253136281857837808491795993788199125205555222116581071134\ +476787468430539307909617442106685159519071053844987343666452\ +494280317720153567054364117244775141336558406098548803924509\ +496052261825198043140272655303625315605326569530252885854991\ +822289219201218313590745412010446642247111703901991591338062\ +693320157180618736569439969283245279430312651192668788340033\ +626825194260296262959884258597703584888770801961209652822982\ +322376122303586169861685106043820510444293432856251210395693\ +261264867823980172683352796141772210301725997652373804152525\ +037162852291403804455997331367378463632437773242905518075065\ +414724295857460288225400061608664961649196400079359622673770\ +607898395269075056596627116148289491042491764170924014885106\ +158235482774778418134123293974436877051995673618683751115353\ +808771434984204447736174758316063096245047311279841579995578\ +186609402864244042751443128536278453430633423118662852688374\ +229600894418958824842459450540826176452145829389286103522774\ +101195556029650753254244433565937938526828990893149766298997\ +738359913887178888607190765709867052470880785937935110091424\ +743449966353497865681753841380246075612094033617488674676296\ +822570077027076266879557913673839341012099558043806442348798\ +053951239274913334631522409564461770434875790402230022872647\ +568436177018658068697071731879399180374560963492726714528729\ +224208938589940272515747888379118461617702271694075087419634\ +147298076764775745707026934442908236664400557265527951453482\ +191684597674273691978253678690951178777239573925410438679099\ +374700609973920128201422381329108236575369403675960765238333\ +778127017096574296148321075566959285042221837159799800133563\ +239963969638610872680393210300180152020613051613414547163713\ +772512617757277955979895866367571776456268564191092477027650\ +135832200376440239783726540552694851717269598489288851529660\ +975027775639565229734596726205832668434979354541943345062977\ +891187146561050118118108223323735210843681128615413601091222\ +007912350536959777114306541514511332368936078560929788143798\ +814391221507522370648646767364209132147312407014953113532379\ +838195728491128536978285918066991040993153064356179903885952\ +027952713749653604502053512355449916680887234238773855581636\ +172479594866871765094513940103284167914110196720261110812716\ +776424260154507395050380575452850420730818412994731079307343\ +538376880280124019321040198038723558784544408584344466090982\ +802067326529000931562048932875469079874956595180595395347093\ +285140279165467965596318365749701535812384333240968283640721\ +344003442002691613772056762099098025739332715913970186225176\ +459563484134139746647940170537900275350480490468851439300771\ +949915194703080576611022590670399844931867609777417528903454\ +731922206378932141464755402629420074293816349270038351339419\ +146768473851353171629153912238797141905920143036064131705230\ +421762305232861503856799511155936565169005916711845389135580\ +928162511912438531204156138447775120789548666143600293412065\ +767167106888509172568003530668539460588248316513392652567856\ +224602697296203328920073354425994044956624831346979458846837\ +597950064151867164583749203433942592178528868981311575331848\ +941597492470436782387502687532649093096498315347403977436001\ +399982102030846763698994785054617523241463186980898394504211\ +430763617825306895065661536045431497903759118007934839122881\ +885863091769469883539876840543521295706315919855784493235603\ +866268925981702690270202829595794350800918257913991744455922\ +6833433740466716699302196502685546874999e-4951L; +static const long double ld2b = +5.4677992978237119037926089004291297245985762235403450155814\ +707305425575329500966052143410629387408077958710210208052966\ +529504784489330482549602621133847135082257338717668975178538\ +378957084503396349323438489751160934104796903302909028868611\ +999312592165232778075745690821530731336739429587895774023213\ +939331012985331912661021188896306095323395084578542200319963\ +179359407180003251440084380484161504585462684082946932782829\ +488183829817567452314437076943950532707791252404699268678810\ +198502871250235796855577909830559749628817599194837522029036\ +891995648803056846354520653635957919882905363521007017169741\ +463296044392266269433408052686419017699718627761948763856040\ +592690841721239300491445991666051031755802326720329666454066\ +568630314348735511753639418257984253319063825247065727664852\ +328745422305642626091617823968872438962470092440688372515677\ +832232712866924800106797113478024083516199991991274936894113\ +006233377518471389394984262004503058455485659100090665241525\ +454803628182902241401701783637353179296850056973639305945938\ +813428953287892593620291195986011128990061888798763718548789\ +025717537674780281005583347165047846045925077914824515331335\ +131286063574407181821236377907693209224423490663289916878620\ +725507793163931390372011875799729330162278748985052557432333\ +005334989519381566364065326138465761456173231416844807264090\ +741841972247545424908843928136253653308813487994328446248389\ +608261444391573619177442907290731163188581917588219420107047\ +265367485141413919810885909689112244064797106324295291545892\ +937991321479061743491490060940946128274533657682130125169586\ +930571899403551122506297763180795732325134340989331155893724\ +289358918212707392997768032299997207208451112971425779939507\ +837165263255764268971211819536322993221774123134726665579460\ +265871378186589562858761835613344584269098062275786969729830\ +545786485401407774313414954958161677096004701941411411592755\ +485864471870515173326244464631295701572087440183178339987662\ +926763241220698078822661709054601073523477544653542795020468\ +256078409306409100874886828781860529824879343987945751252081\ +314345990313550683792348814627862441324030155730592166581251\ +009922787324590431548734575328663628650380722603024383412564\ +651446272117561042207738413114131099731016728935023152239431\ +311619533848376583687509108453086730196255111695352464186678\ +221927564757730319825223049341618853631333478241227227268084\ +583396688436229936266854011427192767039363517491659523133852\ +472534104124441112346615696891097070121463652258681270378076\ +538381697594264658479637863087159293838880752928175545408262\ +813403793568695416998388572304528748824756265665683890518422\ +696169422338806137532304784682662448207928681740476188343739\ +117833525916386815135793034906806117413105008719197882837614\ +738262050320291539494104952056471606645482046176634075459021\ +552555959590354956262127809953013679512507451424271839221946\ +794056861055980558363033732905772356986051180966474116423192\ +194741572438649215204229781279620370445373851348786918527399\ +785630808242657122705381806661616271132182017797793661244078\ +445747547535623384548769818529655539279036503234072455810991\ +588075181817695975173110136482659854557506203058080551018873\ +203138260451109855100526720073566126209666125604482413705611\ +996796777927332827103568863352291499261312290355143742018042\ +254470707107847293593205234049774839191754781030496978091006\ +099559675240966730110167624903610656473267105556155633783594\ +089546261107653110531808279445757724399186120387548675148632\ +176049190701680305210224388072261974806791922636412897526952\ +793677946622674149577084803568051242934076450942927092705684\ +547042915490323112457971853658760725588190377666477106903106\ +693847278847646032201293023329503348730723947218797410452333\ +910847913892827195814551858335519518939031446093385329182820\ +714173657946661746005901866885589732922652604573972842197231\ +187365263381958925227970038358064987248233271706462687651143\ +350472018043321314534759819524203308490914358596886150053406\ +629512434788155355109100540319857813535695923273426256911552\ +977539394209918630668466632881929661971212772444625151371953\ +428875491139683919687008724010475217255347915698820960215217\ +257390308560235323463096946442080548018754166369706161589705\ +215873687166365628787796501470056870127729464714362172216802\ +441045276911597009443281135389729130222603185665646434661947\ +627628077723219376892727386120519287577405410510114936151502\ +752997122750262781911372625997223415283516995479265631485799\ +456782561734766648462849641064097181818204279498552827825384\ +186202065516999362573388136163077477126602169410435905014077\ +049808497409025369325795765272066650278004200357878990911374\ +982857977108488482528354406313893864211497105765030504600982\ +253488805474531798742143374465080240030582370086699167937651\ +038307909706139327119325418854546478285735654541635477790346\ +964782617354265050767878335230272194896680141986745074630225\ +893106573559558843545841186025169531604151588481389164948914\ +823593944287133336263680358191369540321930649824471425485137\ +777984823525402115151171093313613251350685343824859052220126\ +891551966018355920872775724807128769003243129486808733796350\ +497668255116485157191011858830643898323628223472099280243583\ +164434348347014910398004439821970508280440872759395827943270\ +985008769143562351938091476215083548164137333541883808870019\ +116234099013452929807950151652297436436006149684939775781234\ +660954156154478642694176038524277810483833149798681345708089\ +152179193979463169402340611793486272301808073267534612685593\ +859596787866884211031341417903391749825320454663508370385251\ +831778477311017089729361152161928815389818579983544490982891\ +734081131312309744330960666031291451740885503458543884956367\ +654943799264600314531815427932691107874782328654759293575803\ +481929361961781073958502075438499070633193799699311694287183\ +299423475339817655608058724723221867087563064557636112380829\ +514501382073257737022472866608244164310385205213523702910787\ +182472517125030106491031844871593141759729773907719510044049\ +352857426592936763727969496103940591601975078602859660478614\ +119405428212830134490731706220583788265344728818766885126977\ +588151111984290444321648931907188080336064713873288834096229\ +203276676119810521851726133377700616341304257822975788967472\ +152742255041912584197045423031298506219011800240120182445838\ +590696647416285334515631019799007515682004250060857020904012\ +215375170479800482680554499806010766109655061507421747722461\ +180617361402575082294678925605271083587897845390768226405648\ +508518103525778638618195775128516073959272990148239415346263\ +486966573934577450787243667063244378381883115827207605856174\ +876350045086885320626669331311880593775916269643646395423220\ +549940790476989709243027420158390806135690975149384714684219\ +964938182719962913931464979458639185519531490009437619838306\ +362365453754807654884704163490469296444427144778593725687358\ +437087390151990694667516279202024332494828210657618261952038\ +597230263799412584275851667403910657370879707181053365818502\ +680037431560091209982641738995652793235851569372314130107647\ +166085235615697257094269133100914135783178856280392139325001\ +352841718610484616627448189556913621837791650699820323059708\ +766420810133584841826718631681683381743511974264126250984214\ +812397119978273917903889865891718836792263377888052458189238\ +746074986456016681098722869419588274020181430652732817858728\ +473849369539367463917171317324882099804999043054467247785592\ +038464723442276239896066431580123756428540074945472427752568\ +981171400621705853374875885943072600692576914790467205905272\ +372594740187988081900317493185005142913607163380720069786786\ +782095331840893694073778325119471833528492917081008547303414\ +509381563617864195257751546539575461435803625993888325647883\ +541039192368366987400263049681218831477776345118518503709588\ +840859023379762456561030683928115349942393963185677123055324\ +771693784214924931737043793679546051454845624150270955450608\ +318747395755728950832754611277041359602301205138509175543313\ +522772786504141007552691902249572375175731740923618769197304\ +652898352694386665448260033458575323252814233868098279476166\ +764258284911434288072243178941698347365985427696983129579496\ +059032032841281149923518087084876885114369033227736521245740\ +554711771423492719899982357711910225545480424688322195336240\ +492253136281857837808491795993788199125205555222116581071134\ +476787468430539307909617442106685159519071053844987343666452\ +494280317720153567054364117244775141336558406098548803924509\ +496052261825198043140272655303625315605326569530252885854991\ +822289219201218313590745412010446642247111703901991591338062\ +693320157180618736569439969283245279430312651192668788340033\ +626825194260296262959884258597703584888770801961209652822982\ +322376122303586169861685106043820510444293432856251210395693\ +261264867823980172683352796141772210301725997652373804152525\ +037162852291403804455997331367378463632437773242905518075065\ +414724295857460288225400061608664961649196400079359622673770\ +607898395269075056596627116148289491042491764170924014885106\ +158235482774778418134123293974436877051995673618683751115353\ +808771434984204447736174758316063096245047311279841579995578\ +186609402864244042751443128536278453430633423118662852688374\ +229600894418958824842459450540826176452145829389286103522774\ +101195556029650753254244433565937938526828990893149766298997\ +738359913887178888607190765709867052470880785937935110091424\ +743449966353497865681753841380246075612094033617488674676296\ +822570077027076266879557913673839341012099558043806442348798\ +053951239274913334631522409564461770434875790402230022872647\ +568436177018658068697071731879399180374560963492726714528729\ +224208938589940272515747888379118461617702271694075087419634\ +147298076764775745707026934442908236664400557265527951453482\ +191684597674273691978253678690951178777239573925410438679099\ +374700609973920128201422381329108236575369403675960765238333\ +778127017096574296148321075566959285042221837159799800133563\ +239963969638610872680393210300180152020613051613414547163713\ +772512617757277955979895866367571776456268564191092477027650\ +135832200376440239783726540552694851717269598489288851529660\ +975027775639565229734596726205832668434979354541943345062977\ +891187146561050118118108223323735210843681128615413601091222\ +007912350536959777114306541514511332368936078560929788143798\ +814391221507522370648646767364209132147312407014953113532379\ +838195728491128536978285918066991040993153064356179903885952\ +027952713749653604502053512355449916680887234238773855581636\ +172479594866871765094513940103284167914110196720261110812716\ +776424260154507395050380575452850420730818412994731079307343\ +538376880280124019321040198038723558784544408584344466090982\ +802067326529000931562048932875469079874956595180595395347093\ +285140279165467965596318365749701535812384333240968283640721\ +344003442002691613772056762099098025739332715913970186225176\ +459563484134139746647940170537900275350480490468851439300771\ +949915194703080576611022590670399844931867609777417528903454\ +731922206378932141464755402629420074293816349270038351339419\ +146768473851353171629153912238797141905920143036064131705230\ +421762305232861503856799511155936565169005916711845389135580\ +928162511912438531204156138447775120789548666143600293412065\ +767167106888509172568003530668539460588248316513392652567856\ +224602697296203328920073354425994044956624831346979458846837\ +597950064151867164583749203433942592178528868981311575331848\ +941597492470436782387502687532649093096498315347403977436001\ +399982102030846763698994785054617523241463186980898394504211\ +430763617825306895065661536045431497903759118007934839122881\ +885863091769469883539876840543521295706315919855784493235603\ +866268925981702690270202829595794350800918257913991744455922\ +6833433740466716699302196502685546875e-4951L; +static const long double ld2c = +5.4677992978237119037926089004291297245985762235403450155814\ +707305425575329500966052143410629387408077958710210208052966\ +529504784489330482549602621133847135082257338717668975178538\ +378957084503396349323438489751160934104796903302909028868611\ +999312592165232778075745690821530731336739429587895774023213\ +939331012985331912661021188896306095323395084578542200319963\ +179359407180003251440084380484161504585462684082946932782829\ +488183829817567452314437076943950532707791252404699268678810\ +198502871250235796855577909830559749628817599194837522029036\ +891995648803056846354520653635957919882905363521007017169741\ +463296044392266269433408052686419017699718627761948763856040\ +592690841721239300491445991666051031755802326720329666454066\ +568630314348735511753639418257984253319063825247065727664852\ +328745422305642626091617823968872438962470092440688372515677\ +832232712866924800106797113478024083516199991991274936894113\ +006233377518471389394984262004503058455485659100090665241525\ +454803628182902241401701783637353179296850056973639305945938\ +813428953287892593620291195986011128990061888798763718548789\ +025717537674780281005583347165047846045925077914824515331335\ +131286063574407181821236377907693209224423490663289916878620\ +725507793163931390372011875799729330162278748985052557432333\ +005334989519381566364065326138465761456173231416844807264090\ +741841972247545424908843928136253653308813487994328446248389\ +608261444391573619177442907290731163188581917588219420107047\ +265367485141413919810885909689112244064797106324295291545892\ +937991321479061743491490060940946128274533657682130125169586\ +930571899403551122506297763180795732325134340989331155893724\ +289358918212707392997768032299997207208451112971425779939507\ +837165263255764268971211819536322993221774123134726665579460\ +265871378186589562858761835613344584269098062275786969729830\ +545786485401407774313414954958161677096004701941411411592755\ +485864471870515173326244464631295701572087440183178339987662\ +926763241220698078822661709054601073523477544653542795020468\ +256078409306409100874886828781860529824879343987945751252081\ +314345990313550683792348814627862441324030155730592166581251\ +009922787324590431548734575328663628650380722603024383412564\ +651446272117561042207738413114131099731016728935023152239431\ +311619533848376583687509108453086730196255111695352464186678\ +221927564757730319825223049341618853631333478241227227268084\ +583396688436229936266854011427192767039363517491659523133852\ +472534104124441112346615696891097070121463652258681270378076\ +538381697594264658479637863087159293838880752928175545408262\ +813403793568695416998388572304528748824756265665683890518422\ +696169422338806137532304784682662448207928681740476188343739\ +117833525916386815135793034906806117413105008719197882837614\ +738262050320291539494104952056471606645482046176634075459021\ +552555959590354956262127809953013679512507451424271839221946\ +794056861055980558363033732905772356986051180966474116423192\ +194741572438649215204229781279620370445373851348786918527399\ +785630808242657122705381806661616271132182017797793661244078\ +445747547535623384548769818529655539279036503234072455810991\ +588075181817695975173110136482659854557506203058080551018873\ +203138260451109855100526720073566126209666125604482413705611\ +996796777927332827103568863352291499261312290355143742018042\ +254470707107847293593205234049774839191754781030496978091006\ +099559675240966730110167624903610656473267105556155633783594\ +089546261107653110531808279445757724399186120387548675148632\ +176049190701680305210224388072261974806791922636412897526952\ +793677946622674149577084803568051242934076450942927092705684\ +547042915490323112457971853658760725588190377666477106903106\ +693847278847646032201293023329503348730723947218797410452333\ +910847913892827195814551858335519518939031446093385329182820\ +714173657946661746005901866885589732922652604573972842197231\ +187365263381958925227970038358064987248233271706462687651143\ +350472018043321314534759819524203308490914358596886150053406\ +629512434788155355109100540319857813535695923273426256911552\ +977539394209918630668466632881929661971212772444625151371953\ +428875491139683919687008724010475217255347915698820960215217\ +257390308560235323463096946442080548018754166369706161589705\ +215873687166365628787796501470056870127729464714362172216802\ +441045276911597009443281135389729130222603185665646434661947\ +627628077723219376892727386120519287577405410510114936151502\ +752997122750262781911372625997223415283516995479265631485799\ +456782561734766648462849641064097181818204279498552827825384\ +186202065516999362573388136163077477126602169410435905014077\ +049808497409025369325795765272066650278004200357878990911374\ +982857977108488482528354406313893864211497105765030504600982\ +253488805474531798742143374465080240030582370086699167937651\ +038307909706139327119325418854546478285735654541635477790346\ +964782617354265050767878335230272194896680141986745074630225\ +893106573559558843545841186025169531604151588481389164948914\ +823593944287133336263680358191369540321930649824471425485137\ +777984823525402115151171093313613251350685343824859052220126\ +891551966018355920872775724807128769003243129486808733796350\ +497668255116485157191011858830643898323628223472099280243583\ +164434348347014910398004439821970508280440872759395827943270\ +985008769143562351938091476215083548164137333541883808870019\ +116234099013452929807950151652297436436006149684939775781234\ +660954156154478642694176038524277810483833149798681345708089\ +152179193979463169402340611793486272301808073267534612685593\ +859596787866884211031341417903391749825320454663508370385251\ +831778477311017089729361152161928815389818579983544490982891\ +734081131312309744330960666031291451740885503458543884956367\ +654943799264600314531815427932691107874782328654759293575803\ +481929361961781073958502075438499070633193799699311694287183\ +299423475339817655608058724723221867087563064557636112380829\ +514501382073257737022472866608244164310385205213523702910787\ +182472517125030106491031844871593141759729773907719510044049\ +352857426592936763727969496103940591601975078602859660478614\ +119405428212830134490731706220583788265344728818766885126977\ +588151111984290444321648931907188080336064713873288834096229\ +203276676119810521851726133377700616341304257822975788967472\ +152742255041912584197045423031298506219011800240120182445838\ +590696647416285334515631019799007515682004250060857020904012\ +215375170479800482680554499806010766109655061507421747722461\ +180617361402575082294678925605271083587897845390768226405648\ +508518103525778638618195775128516073959272990148239415346263\ +486966573934577450787243667063244378381883115827207605856174\ +876350045086885320626669331311880593775916269643646395423220\ +549940790476989709243027420158390806135690975149384714684219\ +964938182719962913931464979458639185519531490009437619838306\ +362365453754807654884704163490469296444427144778593725687358\ +437087390151990694667516279202024332494828210657618261952038\ +597230263799412584275851667403910657370879707181053365818502\ +680037431560091209982641738995652793235851569372314130107647\ +166085235615697257094269133100914135783178856280392139325001\ +352841718610484616627448189556913621837791650699820323059708\ +766420810133584841826718631681683381743511974264126250984214\ +812397119978273917903889865891718836792263377888052458189238\ +746074986456016681098722869419588274020181430652732817858728\ +473849369539367463917171317324882099804999043054467247785592\ +038464723442276239896066431580123756428540074945472427752568\ +981171400621705853374875885943072600692576914790467205905272\ +372594740187988081900317493185005142913607163380720069786786\ +782095331840893694073778325119471833528492917081008547303414\ +509381563617864195257751546539575461435803625993888325647883\ +541039192368366987400263049681218831477776345118518503709588\ +840859023379762456561030683928115349942393963185677123055324\ +771693784214924931737043793679546051454845624150270955450608\ +318747395755728950832754611277041359602301205138509175543313\ +522772786504141007552691902249572375175731740923618769197304\ +652898352694386665448260033458575323252814233868098279476166\ +764258284911434288072243178941698347365985427696983129579496\ +059032032841281149923518087084876885114369033227736521245740\ +554711771423492719899982357711910225545480424688322195336240\ +492253136281857837808491795993788199125205555222116581071134\ +476787468430539307909617442106685159519071053844987343666452\ +494280317720153567054364117244775141336558406098548803924509\ +496052261825198043140272655303625315605326569530252885854991\ +822289219201218313590745412010446642247111703901991591338062\ +693320157180618736569439969283245279430312651192668788340033\ +626825194260296262959884258597703584888770801961209652822982\ +322376122303586169861685106043820510444293432856251210395693\ +261264867823980172683352796141772210301725997652373804152525\ +037162852291403804455997331367378463632437773242905518075065\ +414724295857460288225400061608664961649196400079359622673770\ +607898395269075056596627116148289491042491764170924014885106\ +158235482774778418134123293974436877051995673618683751115353\ +808771434984204447736174758316063096245047311279841579995578\ +186609402864244042751443128536278453430633423118662852688374\ +229600894418958824842459450540826176452145829389286103522774\ +101195556029650753254244433565937938526828990893149766298997\ +738359913887178888607190765709867052470880785937935110091424\ +743449966353497865681753841380246075612094033617488674676296\ +822570077027076266879557913673839341012099558043806442348798\ +053951239274913334631522409564461770434875790402230022872647\ +568436177018658068697071731879399180374560963492726714528729\ +224208938589940272515747888379118461617702271694075087419634\ +147298076764775745707026934442908236664400557265527951453482\ +191684597674273691978253678690951178777239573925410438679099\ +374700609973920128201422381329108236575369403675960765238333\ +778127017096574296148321075566959285042221837159799800133563\ +239963969638610872680393210300180152020613051613414547163713\ +772512617757277955979895866367571776456268564191092477027650\ +135832200376440239783726540552694851717269598489288851529660\ +975027775639565229734596726205832668434979354541943345062977\ +891187146561050118118108223323735210843681128615413601091222\ +007912350536959777114306541514511332368936078560929788143798\ +814391221507522370648646767364209132147312407014953113532379\ +838195728491128536978285918066991040993153064356179903885952\ +027952713749653604502053512355449916680887234238773855581636\ +172479594866871765094513940103284167914110196720261110812716\ +776424260154507395050380575452850420730818412994731079307343\ +538376880280124019321040198038723558784544408584344466090982\ +802067326529000931562048932875469079874956595180595395347093\ +285140279165467965596318365749701535812384333240968283640721\ +344003442002691613772056762099098025739332715913970186225176\ +459563484134139746647940170537900275350480490468851439300771\ +949915194703080576611022590670399844931867609777417528903454\ +731922206378932141464755402629420074293816349270038351339419\ +146768473851353171629153912238797141905920143036064131705230\ +421762305232861503856799511155936565169005916711845389135580\ +928162511912438531204156138447775120789548666143600293412065\ +767167106888509172568003530668539460588248316513392652567856\ +224602697296203328920073354425994044956624831346979458846837\ +597950064151867164583749203433942592178528868981311575331848\ +941597492470436782387502687532649093096498315347403977436001\ +399982102030846763698994785054617523241463186980898394504211\ +430763617825306895065661536045431497903759118007934839122881\ +885863091769469883539876840543521295706315919855784493235603\ +866268925981702690270202829595794350800918257913991744455922\ +6833433740466716699302196502685546875001e-4951L; +/* 0x1.0000000000000001p16383 */ +static const long double ld3ae = 0x1p16383L, ld3be = 0x1p16383L, ld3ce = 0x1.0000000000000002p16383L; +static const long double ld3a = +5.9486574767861588257512740011252202817891302594919813725251\ +295428739285541899832559628345030434759848834258858109152060\ +168394580447354320917546191141469316674407503401251826592118\ +529247805068466318759038608659253988075214874609536526621357\ +456531393890166762179915866732524251539065872543957371571521\ +983821811625262362379785274802094595537134203491628334800642\ +100552410980148340419844099304716014319891796892117978584065\ +642215994189779833796388294931075153217985342401232585488548\ +183499573356819649604353341808627018653300000165159821533158\ +398534762310007133107769480816106094590754928301890268526601\ +948012303315011492834812113743989351274355589970363438128551\ +573643438403526566620300559126131289478114044934210031633528\ +263569989916613277150372804081100885766846923338387335735275\ +815690693627425316500993091757924061275520326543377826484801\ +260850814410014200240706874882235908793464063722267631785502\ +588978890438298369667014685160756795261293064179236782450102\ +879817506411379585551974343148401888001113058696688771238532\ +123329163319380775763389985796856252232367435778523577763581\ +076318820356483011816956309162306010784749642144593052844981\ +144455778303480881727480293033710826466852650686573284449164\ +971550815761322623554550767170481569400661823142075309755585\ +825399262942161733431916879499819498306470556518202895225167\ +570891857833504708712937447726161123901897152190727519098753\ +173091256107155059564163182449945325514965354563242034921715\ +085079669416064946957897843700525314730377964740286745952320\ +848539618361767466769711132391357232984948881905511016501295\ +373458116601070538750219227472880922074079367616789330713051\ +392796054620611196686398104309732110578180612371988986941283\ +463409571752839755060102940634838880149410521082372514146698\ +949690555298417297141754693386954049385392552489950059242099\ +158790234260937921119976211248531759522503364724271154732450\ +580204158756703065275680503502538215181617861403909609765438\ +459404741896379126766756324776550060890489522385655907004761\ +103760380176704738464932582597767398552360992261748200224552\ +499221197984163362555822765637968034280918669504609870586242\ +062170049756721980421608552698712778507151233315121277695507\ +694932304894125095195395002291537339548463471343544834535084\ +385597125111888342671654244935921073610595930775193595237994\ +484405470453247603596164707279142831292696020597352513459682\ +982542490819269161229107183625537754125393689567083050306972\ +299472451409351528024124972676859164822379702549840869992122\ +109088558738008051503238314435613116752657081607929379237268\ +685258548361696557803717952234859306922044575896046034219495\ +078937310258307531674502149231702180717812559299741279722940\ +331553164095430990867607708187092707603492795672693661579813\ +722297206006600340954221573260854019342039503980256096723323\ +974619210941227998945120494044519820953637210732374225869479\ +681431453077746347270062554307578221973966755682727685671115\ +104598487346465589917255152859638133529840253249441154093766\ +468296435228729803156904942774237478111621919125582394448948\ +295406406844691902789160843785892192212760482854142616066966\ +061436483840059374641455624686877579416182709686546132337333\ +180030729666859995573465620394353524944034503194887839608451\ +069029644904642077575045157730600577875158390703330602738631\ +860629283284285902868412268522486164537842820453011183015531\ +669082023505889165928251243784395957824980999247118276540195\ +068956031183236585108415603897481193085040746824934727777986\ +761703484626902903260925660927239810711484175954901422619731\ +922057229492660554293614771979793133433085936212830723862399\ +334585740422370252249982159238980361966177481883090934546250\ +903836442278836769393445168381535656636696931116641217099763\ +249205106142470169654056239769609880390474141835446455366216\ +163044493526155530766380018725181852858797332884069215206429\ +253933800732703242020102754246055713369281324885855415528125\ +659581759080256206862639693790603663547070031814664699862085\ +124026740519096394950750536940374610036575208929959836461615\ +919280191863569472772191938255564055565023733812663112274784\ +824733213440763947293874467915896768018331324730250697015099\ +463062533087218087488410166157459583569488345783974179340987\ +151815108212218686575226398710276498737521494877861721916239\ +286780194943271811625644415312213945242110591353818534254974\ +082884162962499579444882831630967263044313008877192427542802\ +154833385005287431176015973444837288763406349559772586733139\ +508290944276618724455216038372331277739377332938820061159422\ +131545699737995079186343848189545551446309662717473667598998\ +332988069951307480469935653061211574846012803370905284012473\ +025318540210297839541696998136885534223864988557670674501375\ +244470147903967779423817060038384764935662497442963759653206\ +786432859777470896394181997456033131032688720696203667198626\ +404895099030068466008555612541561023366202324622483939422567\ +021914882845352467305687811236417567525816955182834161603932\ +993065869465459807593704095390354125514253872107415823725124\ +7263969181695999e+4931L; +static const long double ld3b = +5.9486574767861588257512740011252202817891302594919813725251\ +295428739285541899832559628345030434759848834258858109152060\ +168394580447354320917546191141469316674407503401251826592118\ +529247805068466318759038608659253988075214874609536526621357\ +456531393890166762179915866732524251539065872543957371571521\ +983821811625262362379785274802094595537134203491628334800642\ +100552410980148340419844099304716014319891796892117978584065\ +642215994189779833796388294931075153217985342401232585488548\ +183499573356819649604353341808627018653300000165159821533158\ +398534762310007133107769480816106094590754928301890268526601\ +948012303315011492834812113743989351274355589970363438128551\ +573643438403526566620300559126131289478114044934210031633528\ +263569989916613277150372804081100885766846923338387335735275\ +815690693627425316500993091757924061275520326543377826484801\ +260850814410014200240706874882235908793464063722267631785502\ +588978890438298369667014685160756795261293064179236782450102\ +879817506411379585551974343148401888001113058696688771238532\ +123329163319380775763389985796856252232367435778523577763581\ +076318820356483011816956309162306010784749642144593052844981\ +144455778303480881727480293033710826466852650686573284449164\ +971550815761322623554550767170481569400661823142075309755585\ +825399262942161733431916879499819498306470556518202895225167\ +570891857833504708712937447726161123901897152190727519098753\ +173091256107155059564163182449945325514965354563242034921715\ +085079669416064946957897843700525314730377964740286745952320\ +848539618361767466769711132391357232984948881905511016501295\ +373458116601070538750219227472880922074079367616789330713051\ +392796054620611196686398104309732110578180612371988986941283\ +463409571752839755060102940634838880149410521082372514146698\ +949690555298417297141754693386954049385392552489950059242099\ +158790234260937921119976211248531759522503364724271154732450\ +580204158756703065275680503502538215181617861403909609765438\ +459404741896379126766756324776550060890489522385655907004761\ +103760380176704738464932582597767398552360992261748200224552\ +499221197984163362555822765637968034280918669504609870586242\ +062170049756721980421608552698712778507151233315121277695507\ +694932304894125095195395002291537339548463471343544834535084\ +385597125111888342671654244935921073610595930775193595237994\ +484405470453247603596164707279142831292696020597352513459682\ +982542490819269161229107183625537754125393689567083050306972\ +299472451409351528024124972676859164822379702549840869992122\ +109088558738008051503238314435613116752657081607929379237268\ +685258548361696557803717952234859306922044575896046034219495\ +078937310258307531674502149231702180717812559299741279722940\ +331553164095430990867607708187092707603492795672693661579813\ +722297206006600340954221573260854019342039503980256096723323\ +974619210941227998945120494044519820953637210732374225869479\ +681431453077746347270062554307578221973966755682727685671115\ +104598487346465589917255152859638133529840253249441154093766\ +468296435228729803156904942774237478111621919125582394448948\ +295406406844691902789160843785892192212760482854142616066966\ +061436483840059374641455624686877579416182709686546132337333\ +180030729666859995573465620394353524944034503194887839608451\ +069029644904642077575045157730600577875158390703330602738631\ +860629283284285902868412268522486164537842820453011183015531\ +669082023505889165928251243784395957824980999247118276540195\ +068956031183236585108415603897481193085040746824934727777986\ +761703484626902903260925660927239810711484175954901422619731\ +922057229492660554293614771979793133433085936212830723862399\ +334585740422370252249982159238980361966177481883090934546250\ +903836442278836769393445168381535656636696931116641217099763\ +249205106142470169654056239769609880390474141835446455366216\ +163044493526155530766380018725181852858797332884069215206429\ +253933800732703242020102754246055713369281324885855415528125\ +659581759080256206862639693790603663547070031814664699862085\ +124026740519096394950750536940374610036575208929959836461615\ +919280191863569472772191938255564055565023733812663112274784\ +824733213440763947293874467915896768018331324730250697015099\ +463062533087218087488410166157459583569488345783974179340987\ +151815108212218686575226398710276498737521494877861721916239\ +286780194943271811625644415312213945242110591353818534254974\ +082884162962499579444882831630967263044313008877192427542802\ +154833385005287431176015973444837288763406349559772586733139\ +508290944276618724455216038372331277739377332938820061159422\ +131545699737995079186343848189545551446309662717473667598998\ +332988069951307480469935653061211574846012803370905284012473\ +025318540210297839541696998136885534223864988557670674501375\ +244470147903967779423817060038384764935662497442963759653206\ +786432859777470896394181997456033131032688720696203667198626\ +404895099030068466008555612541561023366202324622483939422567\ +021914882845352467305687811236417567525816955182834161603932\ +993065869465459807593704095390354125514253872107415823725124\ +7263969181696e+4931L; +static const long double ld3c = +5.9486574767861588257512740011252202817891302594919813725251\ +295428739285541899832559628345030434759848834258858109152060\ +168394580447354320917546191141469316674407503401251826592118\ +529247805068466318759038608659253988075214874609536526621357\ +456531393890166762179915866732524251539065872543957371571521\ +983821811625262362379785274802094595537134203491628334800642\ +100552410980148340419844099304716014319891796892117978584065\ +642215994189779833796388294931075153217985342401232585488548\ +183499573356819649604353341808627018653300000165159821533158\ +398534762310007133107769480816106094590754928301890268526601\ +948012303315011492834812113743989351274355589970363438128551\ +573643438403526566620300559126131289478114044934210031633528\ +263569989916613277150372804081100885766846923338387335735275\ +815690693627425316500993091757924061275520326543377826484801\ +260850814410014200240706874882235908793464063722267631785502\ +588978890438298369667014685160756795261293064179236782450102\ +879817506411379585551974343148401888001113058696688771238532\ +123329163319380775763389985796856252232367435778523577763581\ +076318820356483011816956309162306010784749642144593052844981\ +144455778303480881727480293033710826466852650686573284449164\ +971550815761322623554550767170481569400661823142075309755585\ +825399262942161733431916879499819498306470556518202895225167\ +570891857833504708712937447726161123901897152190727519098753\ +173091256107155059564163182449945325514965354563242034921715\ +085079669416064946957897843700525314730377964740286745952320\ +848539618361767466769711132391357232984948881905511016501295\ +373458116601070538750219227472880922074079367616789330713051\ +392796054620611196686398104309732110578180612371988986941283\ +463409571752839755060102940634838880149410521082372514146698\ +949690555298417297141754693386954049385392552489950059242099\ +158790234260937921119976211248531759522503364724271154732450\ +580204158756703065275680503502538215181617861403909609765438\ +459404741896379126766756324776550060890489522385655907004761\ +103760380176704738464932582597767398552360992261748200224552\ +499221197984163362555822765637968034280918669504609870586242\ +062170049756721980421608552698712778507151233315121277695507\ +694932304894125095195395002291537339548463471343544834535084\ +385597125111888342671654244935921073610595930775193595237994\ +484405470453247603596164707279142831292696020597352513459682\ +982542490819269161229107183625537754125393689567083050306972\ +299472451409351528024124972676859164822379702549840869992122\ +109088558738008051503238314435613116752657081607929379237268\ +685258548361696557803717952234859306922044575896046034219495\ +078937310258307531674502149231702180717812559299741279722940\ +331553164095430990867607708187092707603492795672693661579813\ +722297206006600340954221573260854019342039503980256096723323\ +974619210941227998945120494044519820953637210732374225869479\ +681431453077746347270062554307578221973966755682727685671115\ +104598487346465589917255152859638133529840253249441154093766\ +468296435228729803156904942774237478111621919125582394448948\ +295406406844691902789160843785892192212760482854142616066966\ +061436483840059374641455624686877579416182709686546132337333\ +180030729666859995573465620394353524944034503194887839608451\ +069029644904642077575045157730600577875158390703330602738631\ +860629283284285902868412268522486164537842820453011183015531\ +669082023505889165928251243784395957824980999247118276540195\ +068956031183236585108415603897481193085040746824934727777986\ +761703484626902903260925660927239810711484175954901422619731\ +922057229492660554293614771979793133433085936212830723862399\ +334585740422370252249982159238980361966177481883090934546250\ +903836442278836769393445168381535656636696931116641217099763\ +249205106142470169654056239769609880390474141835446455366216\ +163044493526155530766380018725181852858797332884069215206429\ +253933800732703242020102754246055713369281324885855415528125\ +659581759080256206862639693790603663547070031814664699862085\ +124026740519096394950750536940374610036575208929959836461615\ +919280191863569472772191938255564055565023733812663112274784\ +824733213440763947293874467915896768018331324730250697015099\ +463062533087218087488410166157459583569488345783974179340987\ +151815108212218686575226398710276498737521494877861721916239\ +286780194943271811625644415312213945242110591353818534254974\ +082884162962499579444882831630967263044313008877192427542802\ +154833385005287431176015973444837288763406349559772586733139\ +508290944276618724455216038372331277739377332938820061159422\ +131545699737995079186343848189545551446309662717473667598998\ +332988069951307480469935653061211574846012803370905284012473\ +025318540210297839541696998136885534223864988557670674501375\ +244470147903967779423817060038384764935662497442963759653206\ +786432859777470896394181997456033131032688720696203667198626\ +404895099030068466008555612541561023366202324622483939422567\ +021914882845352467305687811236417567525816955182834161603932\ +993065869465459807593704095390354125514253872107415823725124\ +7263969181696001e+4931L; +#endif + +#if LDBL_MANT_DIG == 113 \ + && LDBL_MIN_EXP == -16381 \ + && LDBL_MAX_EXP == 16384 +# define LDBL_OK +/* 0x0.8p-16494 */ +static const long double ld1ae = 0, ld1be = 0, ld1ce = 0x1p-16494L; +static const long double ld1a = +3.2375875597190125554622194791138232762497846690173405048449\ +421945985197700620596855088357456383249701279390707384240598\ +382936099431912710233425550359863089915213963553756674672083\ +673128192358701197242632527769951957277781260855740340354110\ +173441284912381364143945515141786687806740155311932822963199\ +131134959539539338316310328556057915323285980341541664226172\ +265348802632447238304822896568757017013159021750199744350376\ +278243566840330589397015778833566517337174685312047058426075\ +688036665697114219175258344917835835984013214761767520398571\ +735519302688914468501077605843338555214753050109407568139932\ +147308502166696009676987494125921676927574464221699654264839\ +192243410627511520570610765229732327315423820550872393685221\ +676561948307418196052769717057382723931306989375320957256133\ +838073129463951849807075348034900035402513943244599879584009\ +391110011261908615236154859382854977144106096407982738165117\ +693915685918231984764157652755343417097983676870433731452629\ +339981084526616826599425863049784138127555181662391766144738\ +159400253422795753041594932607700680306368857466952063923782\ +760519487592638820793893796669403574411398166619131986561877\ +034635197232626532239192571857518274939275861531537920777299\ +133535479548088762634002006634954143608168633852204577195463\ +389533233992867620995583241321034602255800668175356808869060\ +608582640890741203603916133682748118680676374951545690715916\ +241859799379894025137504643469040366684778763795442214328000\ +375999444991619403217748350277527106812175542863660436614910\ +135938862296156144947361864759321605496309393905421651264941\ +669606814994816518612155298709843817262034769175075602668866\ +926449523554218142013501373514352370369126244144449924971423\ +038024236058971106053649565799145071085840022305247663313482\ +714565918140785997808209749619683146844964283106915422726638\ +184861327711776708749278315100024436584176080783836115268999\ +055336294569042349971163039294272620322160728879610722678506\ +182344928526064885227397447578450046944618127903428943538029\ +386719288345854473283987116842451647036255801966780244103035\ +425445345127067921349083698736056197567752071915587544133815\ +717564310032485290205726480489464589999677885266171263493459\ +668963623768410922688414177814149693150024191921819721215688\ +114324591287371281400636455584825253000890602388603923710921\ +026880979879158388608823700222683123228822356907857261909150\ +626993825760416437415551396973489279578569909699853422995997\ +974315036153120383930698087773157253674975950409660938084071\ +173163693891122166282318691732176374528554627905530306369204\ +877964658806333996327938827344733821685425961846791581492287\ +250044047142934607523718654369478552373072400018635730811749\ +291666457582760812726851561001954207941547404866373158231367\ +986951247388733285659455982411993350593989550494594498447410\ +984783303191128659803467713819821511544998464785455306500918\ +241648925913966507036336000231915215026183799886938007038845\ +551916478649593272604688927931953165785101738164060543643192\ +949066412847647883846835866623820426428526541564774787007791\ +235843699657232847114093617412355486871810526396392792853731\ +390841657984518997639795008374280777823099107035223998600103\ +103211166230289241182380237703814248941627178152962100972452\ +217697144954497443279450919433943252592977710901289696002698\ +225209041938801190947812141758873162203113090284565687499100\ +109623665868340184032428667217835198069330185880779776269137\ +742366802202585247113480377505916462865316253065105837519292\ +805411191872195967066157363040364443666632564266439033866945\ +366496486863801221986778957510023272290593640187551645170603\ +215150911733580059874983597994671388176488814794186236946834\ +548816837468411497151813344980969677026131105901402313456769\ +561412278508799050185582199844418197980544632067644131002512\ +557755358307705356209461595354064971347590431926479961905129\ +785864961996560707071051177738535042777950247546470241655891\ +294428226271478689174637951663865529219133988782700199051475\ +108495188941141025360733690471601309904116260484264378352956\ +830972782977747351810451586166745640802378131466232692150196\ +132319386267589275314909450293562079332893638471814389025392\ +970579695249613486078445695214422379148991006996109216699215\ +721671648754881325271879493185438097033881789311707997697928\ +860866812849648616086569281093053695399558469641977866770538\ +476039621947215238679930485285585513808236992918733520331110\ +962448142457896209307561142289713638388281085340301520317159\ +297224995464365477734040179470355969363384621039467975256670\ +339354334892926205316491997244008324897517881293654265688813\ +283579663372924392043825371743576754041055802440187836850412\ +247984570221893156921757872572872036331343007592090605703195\ +088864753777199111760713027328198781654685927174063882187275\ +850263521274368447629947228263907797373221137688424821608129\ +731003236738630502344377228987961455961818623205503012858619\ +800521948637807438081069469400793496307826769301971342062597\ +391253779410607511754278887744936774785938056823221738917303\ +119592848951788560393540150358649310736020595310015728915288\ +289821678102453433273888879288862086153270028346900686360943\ +250522514297816412678213672667152836436597491522644579383191\ +851483036048273636234050603745735057899230038434384361744893\ +838050985090837220507663282503497932038372021626246900935334\ +781144388106031405650705176699646299475436084049881780196520\ +881623075256119318210664937469946410480660118598143375898298\ +965497205621170906772915413181530577151676241283182977713765\ +317889730886996471681592298058774155948285325398399674640645\ +566475947058303746531133735308766583802401453804232106737787\ +768035926272312574958173945816077962772826443125107145322971\ +087220172175473177449006473180221085709470643042801004189714\ +505520073568915195232936144169440163547568663500508335014169\ +425050712038101167190534305435310279534374364467455668392421\ +298604104431988622194699721632249712583483143417550152131186\ +288827131347662976240916448058011869761525369135147129192405\ +037216807405860168320999468074663117771890506566769628495813\ +837909047220874786467663205170561835819702362482274133227483\ +041342457179876653773960112367066273208176545656826800069574\ +547599816180234764485446735080683694920665668954370505715843\ +455110709594838989387382250502925336743830916124954071268053\ +817964873658921319164268375226716232666274830656557657055342\ +393552148933959057023293404027940528842591460490646295820755\ +765633076707491896621769767253619370462005760078938144396953\ +018925287611875441613896820035092167912718365454954166761481\ +511451950826683236776211829914518353242818636196417736206010\ +145109509967467266157037719712666871515644277723594273405669\ +093518586548079997818085130346801040781966074621669280188633\ +856299289656492439545033914935979634179552686396067914528336\ +924678729357419403624798426886422277256625046946795576781709\ +298737741510378578072199383561520569978396254537274419476511\ +983161908266152660163477408756159700314280122283281906103567\ +067156627222418787671312246698375736071215395722993294041012\ +744631560602983489316782773611740570974847045870362276861106\ +774130949410119612624380274679529647271294627526939490197641\ +645383447755544661714281218489998189691140343327976729279891\ +077101372792811842951182338559423852563331641533781432796742\ +873181364582071661749961126386895359760476172215209100274274\ +851619657020388051618654944574445941780637669570374280535432\ +399157923698778110534174856844986671232161320063786308144771\ +068130888985636449091787794632959555876880672773686838364706\ +122084832995722603440165161942472322987408003421165899848443\ +566885769845535074102932500939450142098799833145629484519298\ +622410092757836842296697186410137365818568152771850732591405\ +340248509247875448717161746544246407280913725135059228268131\ +453903691495906528862410006254958805237716723952273129715780\ +425223305517882562616830806755498203755676925741529569939445\ +043490046171854709456730491532189688306135861932534903184518\ +717706426178028900836080044604143054210332610482947502104703\ +032028463320549525316174330585387581543470878545616097381416\ +151451037487775797335749896735101048367502483255117772375025\ +269956476872153642623856062175536913321594213515989059505375\ +135183515207096576145781316398544325320022366962008554087665\ +201050763789833457082359181807492731245904330245198691471329\ +319324627030678762142685799400660305214140453863665517807185\ +105354694177602424937823924511789133225030926924236498557565\ +212794565582753399214908928688568628950225640472058381324292\ +866007645368390366981937596341868992912741319342960598330486\ +905946276235953206760977215407164729909506118583728562718724\ +235732515062300426080741679038098122641980345051854359908213\ +563779664847422505775922437272989231878912994048540484468227\ +199282393172540734295329890896755037903724644870572648941076\ +132423009124870700536763793881894969000042397318202298868940\ +530196108237639578098191879486398269734335286831689173606327\ +500405178476864790935386838169242131756729797688220656276969\ +434749140204830563840068728357383111109865861495106613619153\ +421725274090787422508800568671498311491210197298472420373359\ +044400631309819996507004167876832936101195902219429743174557\ +163362274547892397934880322990633165889175059124060202200452\ +648684577182821651588921716304707095995039972827781680978274\ +973838841958209215836456212939412000456040621743349981715350\ +305133662772937143899882197561295808685181679238411733642697\ +748892466944352640514849114619882270112386610376024527101889\ +119004382703622803911212700216792471528793241950356942780714\ +774957204475130171711488773121937363663487116301055073658645\ +980695862570269762957141239436916216723776945522480189876803\ +386123827956059851911061129713987960026363403936931196519733\ +447116468545744829997003979525368783485129837821983305137448\ +031689360764270759437872004895754351479890333865299565515706\ +690471030702230767978923298480584997256328135245813726407464\ +159230169328539541524724878662873185450510653764301207480799\ +488602832618557388369552461881286225098286358672257087829660\ +174231705350465091313887538950130611513878400895128618426154\ +417299623157313010877679890009181366178705821415173309356192\ +686429159835537275875876767919535369607142366878476025895389\ +279625854409611312402187942369446302119309705461187450803468\ +606366203101933821675974655441744883993796837164178911391575\ +751463591650231265941242686108002052587760190005508737394014\ +453031299745602214380618917954427803281262300931789525045703\ +809571995929933387196864877982754748535701000330924817431298\ +365273697561943437891318220691072831562717726798635382168915\ +187137325209768346284183473712613689334546294053718697897526\ +843398053681374508250012035211936425982389543291022583173280\ +985811169783438836113209408147936547458073361625570571955232\ +746103236016857123149307991441916732438322836596693687161268\ +151183603534413030099360835441935243365729307681545065674775\ +655582111435085683962037818795920337874290127531069511296530\ +746308404963763022896682861683252995925040540038039172626001\ +958340013361801588367655990575379797454237110701588716509764\ +759243657077584013289594787913434812509790293636440469725564\ +222946985585616708175959944099853232059130350099233608207347\ +955460820122006976717445739825352919058005528371183277021250\ +186916447745609162301667393077050176560656798672598371789181\ +232542195795945358691713761483976100058707499929103557275695\ +937295677892604799308353051124627278706035295473126217205599\ +530746756205492173148619619059839609108464715691924592576481\ +382126740168148453274964955074129767533813576349605298268179\ +068244338581354855186516322703199278802275718580352103754433\ +240982354636196477238624205575823556321375833700666021556412\ +182358152808745703724362178773168996492870519432472065091133\ +11767578124999e-4966L; +static const long double ld1b = +3.2375875597190125554622194791138232762497846690173405048449\ +421945985197700620596855088357456383249701279390707384240598\ +382936099431912710233425550359863089915213963553756674672083\ +673128192358701197242632527769951957277781260855740340354110\ +173441284912381364143945515141786687806740155311932822963199\ +131134959539539338316310328556057915323285980341541664226172\ +265348802632447238304822896568757017013159021750199744350376\ +278243566840330589397015778833566517337174685312047058426075\ +688036665697114219175258344917835835984013214761767520398571\ +735519302688914468501077605843338555214753050109407568139932\ +147308502166696009676987494125921676927574464221699654264839\ +192243410627511520570610765229732327315423820550872393685221\ +676561948307418196052769717057382723931306989375320957256133\ +838073129463951849807075348034900035402513943244599879584009\ +391110011261908615236154859382854977144106096407982738165117\ +693915685918231984764157652755343417097983676870433731452629\ +339981084526616826599425863049784138127555181662391766144738\ +159400253422795753041594932607700680306368857466952063923782\ +760519487592638820793893796669403574411398166619131986561877\ +034635197232626532239192571857518274939275861531537920777299\ +133535479548088762634002006634954143608168633852204577195463\ +389533233992867620995583241321034602255800668175356808869060\ +608582640890741203603916133682748118680676374951545690715916\ +241859799379894025137504643469040366684778763795442214328000\ +375999444991619403217748350277527106812175542863660436614910\ +135938862296156144947361864759321605496309393905421651264941\ +669606814994816518612155298709843817262034769175075602668866\ +926449523554218142013501373514352370369126244144449924971423\ +038024236058971106053649565799145071085840022305247663313482\ +714565918140785997808209749619683146844964283106915422726638\ +184861327711776708749278315100024436584176080783836115268999\ +055336294569042349971163039294272620322160728879610722678506\ +182344928526064885227397447578450046944618127903428943538029\ +386719288345854473283987116842451647036255801966780244103035\ +425445345127067921349083698736056197567752071915587544133815\ +717564310032485290205726480489464589999677885266171263493459\ +668963623768410922688414177814149693150024191921819721215688\ +114324591287371281400636455584825253000890602388603923710921\ +026880979879158388608823700222683123228822356907857261909150\ +626993825760416437415551396973489279578569909699853422995997\ +974315036153120383930698087773157253674975950409660938084071\ +173163693891122166282318691732176374528554627905530306369204\ +877964658806333996327938827344733821685425961846791581492287\ +250044047142934607523718654369478552373072400018635730811749\ +291666457582760812726851561001954207941547404866373158231367\ +986951247388733285659455982411993350593989550494594498447410\ +984783303191128659803467713819821511544998464785455306500918\ +241648925913966507036336000231915215026183799886938007038845\ +551916478649593272604688927931953165785101738164060543643192\ +949066412847647883846835866623820426428526541564774787007791\ +235843699657232847114093617412355486871810526396392792853731\ +390841657984518997639795008374280777823099107035223998600103\ +103211166230289241182380237703814248941627178152962100972452\ +217697144954497443279450919433943252592977710901289696002698\ +225209041938801190947812141758873162203113090284565687499100\ +109623665868340184032428667217835198069330185880779776269137\ +742366802202585247113480377505916462865316253065105837519292\ +805411191872195967066157363040364443666632564266439033866945\ +366496486863801221986778957510023272290593640187551645170603\ +215150911733580059874983597994671388176488814794186236946834\ +548816837468411497151813344980969677026131105901402313456769\ +561412278508799050185582199844418197980544632067644131002512\ +557755358307705356209461595354064971347590431926479961905129\ +785864961996560707071051177738535042777950247546470241655891\ +294428226271478689174637951663865529219133988782700199051475\ +108495188941141025360733690471601309904116260484264378352956\ +830972782977747351810451586166745640802378131466232692150196\ +132319386267589275314909450293562079332893638471814389025392\ +970579695249613486078445695214422379148991006996109216699215\ +721671648754881325271879493185438097033881789311707997697928\ +860866812849648616086569281093053695399558469641977866770538\ +476039621947215238679930485285585513808236992918733520331110\ +962448142457896209307561142289713638388281085340301520317159\ +297224995464365477734040179470355969363384621039467975256670\ +339354334892926205316491997244008324897517881293654265688813\ +283579663372924392043825371743576754041055802440187836850412\ +247984570221893156921757872572872036331343007592090605703195\ +088864753777199111760713027328198781654685927174063882187275\ +850263521274368447629947228263907797373221137688424821608129\ +731003236738630502344377228987961455961818623205503012858619\ +800521948637807438081069469400793496307826769301971342062597\ +391253779410607511754278887744936774785938056823221738917303\ +119592848951788560393540150358649310736020595310015728915288\ +289821678102453433273888879288862086153270028346900686360943\ +250522514297816412678213672667152836436597491522644579383191\ +851483036048273636234050603745735057899230038434384361744893\ +838050985090837220507663282503497932038372021626246900935334\ +781144388106031405650705176699646299475436084049881780196520\ +881623075256119318210664937469946410480660118598143375898298\ +965497205621170906772915413181530577151676241283182977713765\ +317889730886996471681592298058774155948285325398399674640645\ +566475947058303746531133735308766583802401453804232106737787\ +768035926272312574958173945816077962772826443125107145322971\ +087220172175473177449006473180221085709470643042801004189714\ +505520073568915195232936144169440163547568663500508335014169\ +425050712038101167190534305435310279534374364467455668392421\ +298604104431988622194699721632249712583483143417550152131186\ +288827131347662976240916448058011869761525369135147129192405\ +037216807405860168320999468074663117771890506566769628495813\ +837909047220874786467663205170561835819702362482274133227483\ +041342457179876653773960112367066273208176545656826800069574\ +547599816180234764485446735080683694920665668954370505715843\ +455110709594838989387382250502925336743830916124954071268053\ +817964873658921319164268375226716232666274830656557657055342\ +393552148933959057023293404027940528842591460490646295820755\ +765633076707491896621769767253619370462005760078938144396953\ +018925287611875441613896820035092167912718365454954166761481\ +511451950826683236776211829914518353242818636196417736206010\ +145109509967467266157037719712666871515644277723594273405669\ +093518586548079997818085130346801040781966074621669280188633\ +856299289656492439545033914935979634179552686396067914528336\ +924678729357419403624798426886422277256625046946795576781709\ +298737741510378578072199383561520569978396254537274419476511\ +983161908266152660163477408756159700314280122283281906103567\ +067156627222418787671312246698375736071215395722993294041012\ +744631560602983489316782773611740570974847045870362276861106\ +774130949410119612624380274679529647271294627526939490197641\ +645383447755544661714281218489998189691140343327976729279891\ +077101372792811842951182338559423852563331641533781432796742\ +873181364582071661749961126386895359760476172215209100274274\ +851619657020388051618654944574445941780637669570374280535432\ +399157923698778110534174856844986671232161320063786308144771\ +068130888985636449091787794632959555876880672773686838364706\ +122084832995722603440165161942472322987408003421165899848443\ +566885769845535074102932500939450142098799833145629484519298\ +622410092757836842296697186410137365818568152771850732591405\ +340248509247875448717161746544246407280913725135059228268131\ +453903691495906528862410006254958805237716723952273129715780\ +425223305517882562616830806755498203755676925741529569939445\ +043490046171854709456730491532189688306135861932534903184518\ +717706426178028900836080044604143054210332610482947502104703\ +032028463320549525316174330585387581543470878545616097381416\ +151451037487775797335749896735101048367502483255117772375025\ +269956476872153642623856062175536913321594213515989059505375\ +135183515207096576145781316398544325320022366962008554087665\ +201050763789833457082359181807492731245904330245198691471329\ +319324627030678762142685799400660305214140453863665517807185\ +105354694177602424937823924511789133225030926924236498557565\ +212794565582753399214908928688568628950225640472058381324292\ +866007645368390366981937596341868992912741319342960598330486\ +905946276235953206760977215407164729909506118583728562718724\ +235732515062300426080741679038098122641980345051854359908213\ +563779664847422505775922437272989231878912994048540484468227\ +199282393172540734295329890896755037903724644870572648941076\ +132423009124870700536763793881894969000042397318202298868940\ +530196108237639578098191879486398269734335286831689173606327\ +500405178476864790935386838169242131756729797688220656276969\ +434749140204830563840068728357383111109865861495106613619153\ +421725274090787422508800568671498311491210197298472420373359\ +044400631309819996507004167876832936101195902219429743174557\ +163362274547892397934880322990633165889175059124060202200452\ +648684577182821651588921716304707095995039972827781680978274\ +973838841958209215836456212939412000456040621743349981715350\ +305133662772937143899882197561295808685181679238411733642697\ +748892466944352640514849114619882270112386610376024527101889\ +119004382703622803911212700216792471528793241950356942780714\ +774957204475130171711488773121937363663487116301055073658645\ +980695862570269762957141239436916216723776945522480189876803\ +386123827956059851911061129713987960026363403936931196519733\ +447116468545744829997003979525368783485129837821983305137448\ +031689360764270759437872004895754351479890333865299565515706\ +690471030702230767978923298480584997256328135245813726407464\ +159230169328539541524724878662873185450510653764301207480799\ +488602832618557388369552461881286225098286358672257087829660\ +174231705350465091313887538950130611513878400895128618426154\ +417299623157313010877679890009181366178705821415173309356192\ +686429159835537275875876767919535369607142366878476025895389\ +279625854409611312402187942369446302119309705461187450803468\ +606366203101933821675974655441744883993796837164178911391575\ +751463591650231265941242686108002052587760190005508737394014\ +453031299745602214380618917954427803281262300931789525045703\ +809571995929933387196864877982754748535701000330924817431298\ +365273697561943437891318220691072831562717726798635382168915\ +187137325209768346284183473712613689334546294053718697897526\ +843398053681374508250012035211936425982389543291022583173280\ +985811169783438836113209408147936547458073361625570571955232\ +746103236016857123149307991441916732438322836596693687161268\ +151183603534413030099360835441935243365729307681545065674775\ +655582111435085683962037818795920337874290127531069511296530\ +746308404963763022896682861683252995925040540038039172626001\ +958340013361801588367655990575379797454237110701588716509764\ +759243657077584013289594787913434812509790293636440469725564\ +222946985585616708175959944099853232059130350099233608207347\ +955460820122006976717445739825352919058005528371183277021250\ +186916447745609162301667393077050176560656798672598371789181\ +232542195795945358691713761483976100058707499929103557275695\ +937295677892604799308353051124627278706035295473126217205599\ +530746756205492173148619619059839609108464715691924592576481\ +382126740168148453274964955074129767533813576349605298268179\ +068244338581354855186516322703199278802275718580352103754433\ +240982354636196477238624205575823556321375833700666021556412\ +182358152808745703724362178773168996492870519432472065091133\ +11767578125e-4966L; +static const long double ld1c = +3.2375875597190125554622194791138232762497846690173405048449\ +421945985197700620596855088357456383249701279390707384240598\ +382936099431912710233425550359863089915213963553756674672083\ +673128192358701197242632527769951957277781260855740340354110\ +173441284912381364143945515141786687806740155311932822963199\ +131134959539539338316310328556057915323285980341541664226172\ +265348802632447238304822896568757017013159021750199744350376\ +278243566840330589397015778833566517337174685312047058426075\ +688036665697114219175258344917835835984013214761767520398571\ +735519302688914468501077605843338555214753050109407568139932\ +147308502166696009676987494125921676927574464221699654264839\ +192243410627511520570610765229732327315423820550872393685221\ +676561948307418196052769717057382723931306989375320957256133\ +838073129463951849807075348034900035402513943244599879584009\ +391110011261908615236154859382854977144106096407982738165117\ +693915685918231984764157652755343417097983676870433731452629\ +339981084526616826599425863049784138127555181662391766144738\ +159400253422795753041594932607700680306368857466952063923782\ +760519487592638820793893796669403574411398166619131986561877\ +034635197232626532239192571857518274939275861531537920777299\ +133535479548088762634002006634954143608168633852204577195463\ +389533233992867620995583241321034602255800668175356808869060\ +608582640890741203603916133682748118680676374951545690715916\ +241859799379894025137504643469040366684778763795442214328000\ +375999444991619403217748350277527106812175542863660436614910\ +135938862296156144947361864759321605496309393905421651264941\ +669606814994816518612155298709843817262034769175075602668866\ +926449523554218142013501373514352370369126244144449924971423\ +038024236058971106053649565799145071085840022305247663313482\ +714565918140785997808209749619683146844964283106915422726638\ +184861327711776708749278315100024436584176080783836115268999\ +055336294569042349971163039294272620322160728879610722678506\ +182344928526064885227397447578450046944618127903428943538029\ +386719288345854473283987116842451647036255801966780244103035\ +425445345127067921349083698736056197567752071915587544133815\ +717564310032485290205726480489464589999677885266171263493459\ +668963623768410922688414177814149693150024191921819721215688\ +114324591287371281400636455584825253000890602388603923710921\ +026880979879158388608823700222683123228822356907857261909150\ +626993825760416437415551396973489279578569909699853422995997\ +974315036153120383930698087773157253674975950409660938084071\ +173163693891122166282318691732176374528554627905530306369204\ +877964658806333996327938827344733821685425961846791581492287\ +250044047142934607523718654369478552373072400018635730811749\ +291666457582760812726851561001954207941547404866373158231367\ +986951247388733285659455982411993350593989550494594498447410\ +984783303191128659803467713819821511544998464785455306500918\ +241648925913966507036336000231915215026183799886938007038845\ +551916478649593272604688927931953165785101738164060543643192\ +949066412847647883846835866623820426428526541564774787007791\ +235843699657232847114093617412355486871810526396392792853731\ +390841657984518997639795008374280777823099107035223998600103\ +103211166230289241182380237703814248941627178152962100972452\ +217697144954497443279450919433943252592977710901289696002698\ +225209041938801190947812141758873162203113090284565687499100\ +109623665868340184032428667217835198069330185880779776269137\ +742366802202585247113480377505916462865316253065105837519292\ +805411191872195967066157363040364443666632564266439033866945\ +366496486863801221986778957510023272290593640187551645170603\ +215150911733580059874983597994671388176488814794186236946834\ +548816837468411497151813344980969677026131105901402313456769\ +561412278508799050185582199844418197980544632067644131002512\ +557755358307705356209461595354064971347590431926479961905129\ +785864961996560707071051177738535042777950247546470241655891\ +294428226271478689174637951663865529219133988782700199051475\ +108495188941141025360733690471601309904116260484264378352956\ +830972782977747351810451586166745640802378131466232692150196\ +132319386267589275314909450293562079332893638471814389025392\ +970579695249613486078445695214422379148991006996109216699215\ +721671648754881325271879493185438097033881789311707997697928\ +860866812849648616086569281093053695399558469641977866770538\ +476039621947215238679930485285585513808236992918733520331110\ +962448142457896209307561142289713638388281085340301520317159\ +297224995464365477734040179470355969363384621039467975256670\ +339354334892926205316491997244008324897517881293654265688813\ +283579663372924392043825371743576754041055802440187836850412\ +247984570221893156921757872572872036331343007592090605703195\ +088864753777199111760713027328198781654685927174063882187275\ +850263521274368447629947228263907797373221137688424821608129\ +731003236738630502344377228987961455961818623205503012858619\ +800521948637807438081069469400793496307826769301971342062597\ +391253779410607511754278887744936774785938056823221738917303\ +119592848951788560393540150358649310736020595310015728915288\ +289821678102453433273888879288862086153270028346900686360943\ +250522514297816412678213672667152836436597491522644579383191\ +851483036048273636234050603745735057899230038434384361744893\ +838050985090837220507663282503497932038372021626246900935334\ +781144388106031405650705176699646299475436084049881780196520\ +881623075256119318210664937469946410480660118598143375898298\ +965497205621170906772915413181530577151676241283182977713765\ +317889730886996471681592298058774155948285325398399674640645\ +566475947058303746531133735308766583802401453804232106737787\ +768035926272312574958173945816077962772826443125107145322971\ +087220172175473177449006473180221085709470643042801004189714\ +505520073568915195232936144169440163547568663500508335014169\ +425050712038101167190534305435310279534374364467455668392421\ +298604104431988622194699721632249712583483143417550152131186\ +288827131347662976240916448058011869761525369135147129192405\ +037216807405860168320999468074663117771890506566769628495813\ +837909047220874786467663205170561835819702362482274133227483\ +041342457179876653773960112367066273208176545656826800069574\ +547599816180234764485446735080683694920665668954370505715843\ +455110709594838989387382250502925336743830916124954071268053\ +817964873658921319164268375226716232666274830656557657055342\ +393552148933959057023293404027940528842591460490646295820755\ +765633076707491896621769767253619370462005760078938144396953\ +018925287611875441613896820035092167912718365454954166761481\ +511451950826683236776211829914518353242818636196417736206010\ +145109509967467266157037719712666871515644277723594273405669\ +093518586548079997818085130346801040781966074621669280188633\ +856299289656492439545033914935979634179552686396067914528336\ +924678729357419403624798426886422277256625046946795576781709\ +298737741510378578072199383561520569978396254537274419476511\ +983161908266152660163477408756159700314280122283281906103567\ +067156627222418787671312246698375736071215395722993294041012\ +744631560602983489316782773611740570974847045870362276861106\ +774130949410119612624380274679529647271294627526939490197641\ +645383447755544661714281218489998189691140343327976729279891\ +077101372792811842951182338559423852563331641533781432796742\ +873181364582071661749961126386895359760476172215209100274274\ +851619657020388051618654944574445941780637669570374280535432\ +399157923698778110534174856844986671232161320063786308144771\ +068130888985636449091787794632959555876880672773686838364706\ +122084832995722603440165161942472322987408003421165899848443\ +566885769845535074102932500939450142098799833145629484519298\ +622410092757836842296697186410137365818568152771850732591405\ +340248509247875448717161746544246407280913725135059228268131\ +453903691495906528862410006254958805237716723952273129715780\ +425223305517882562616830806755498203755676925741529569939445\ +043490046171854709456730491532189688306135861932534903184518\ +717706426178028900836080044604143054210332610482947502104703\ +032028463320549525316174330585387581543470878545616097381416\ +151451037487775797335749896735101048367502483255117772375025\ +269956476872153642623856062175536913321594213515989059505375\ +135183515207096576145781316398544325320022366962008554087665\ +201050763789833457082359181807492731245904330245198691471329\ +319324627030678762142685799400660305214140453863665517807185\ +105354694177602424937823924511789133225030926924236498557565\ +212794565582753399214908928688568628950225640472058381324292\ +866007645368390366981937596341868992912741319342960598330486\ +905946276235953206760977215407164729909506118583728562718724\ +235732515062300426080741679038098122641980345051854359908213\ +563779664847422505775922437272989231878912994048540484468227\ +199282393172540734295329890896755037903724644870572648941076\ +132423009124870700536763793881894969000042397318202298868940\ +530196108237639578098191879486398269734335286831689173606327\ +500405178476864790935386838169242131756729797688220656276969\ +434749140204830563840068728357383111109865861495106613619153\ +421725274090787422508800568671498311491210197298472420373359\ +044400631309819996507004167876832936101195902219429743174557\ +163362274547892397934880322990633165889175059124060202200452\ +648684577182821651588921716304707095995039972827781680978274\ +973838841958209215836456212939412000456040621743349981715350\ +305133662772937143899882197561295808685181679238411733642697\ +748892466944352640514849114619882270112386610376024527101889\ +119004382703622803911212700216792471528793241950356942780714\ +774957204475130171711488773121937363663487116301055073658645\ +980695862570269762957141239436916216723776945522480189876803\ +386123827956059851911061129713987960026363403936931196519733\ +447116468545744829997003979525368783485129837821983305137448\ +031689360764270759437872004895754351479890333865299565515706\ +690471030702230767978923298480584997256328135245813726407464\ +159230169328539541524724878662873185450510653764301207480799\ +488602832618557388369552461881286225098286358672257087829660\ +174231705350465091313887538950130611513878400895128618426154\ +417299623157313010877679890009181366178705821415173309356192\ +686429159835537275875876767919535369607142366878476025895389\ +279625854409611312402187942369446302119309705461187450803468\ +606366203101933821675974655441744883993796837164178911391575\ +751463591650231265941242686108002052587760190005508737394014\ +453031299745602214380618917954427803281262300931789525045703\ +809571995929933387196864877982754748535701000330924817431298\ +365273697561943437891318220691072831562717726798635382168915\ +187137325209768346284183473712613689334546294053718697897526\ +843398053681374508250012035211936425982389543291022583173280\ +985811169783438836113209408147936547458073361625570571955232\ +746103236016857123149307991441916732438322836596693687161268\ +151183603534413030099360835441935243365729307681545065674775\ +655582111435085683962037818795920337874290127531069511296530\ +746308404963763022896682861683252995925040540038039172626001\ +958340013361801588367655990575379797454237110701588716509764\ +759243657077584013289594787913434812509790293636440469725564\ +222946985585616708175959944099853232059130350099233608207347\ +955460820122006976717445739825352919058005528371183277021250\ +186916447745609162301667393077050176560656798672598371789181\ +232542195795945358691713761483976100058707499929103557275695\ +937295677892604799308353051124627278706035295473126217205599\ +530746756205492173148619619059839609108464715691924592576481\ +382126740168148453274964955074129767533813576349605298268179\ +068244338581354855186516322703199278802275718580352103754433\ +240982354636196477238624205575823556321375833700666021556412\ +182358152808745703724362178773168996492870519432472065091133\ +11767578125001e-4966L; +/* 0x1.8p-16494 */ +static const long double ld2ae = 0x1p-16494L, ld2be = 0x2p-16494L, ld2ce = 0x2p-16494L; +static const long double ld2a = +9.7127626791570376663866584373414698287493540070520215145348\ +265837955593101861790565265072369149749103838172122152721795\ +148808298295738130700276651079589269745641890661270024016251\ +019384577076103591727897583309855871833343782567221021062330\ +520323854737144092431836545425360063420220465935798468889597\ +393404878618618014948930985668173745969857941024624992678516\ +796046407897341714914468689706271051039477065250599233051128\ +834730700520991768191047336500699552011524055936141175278227\ +064109997091342657525775034753507507952039644285302561195715\ +206557908066743405503232817530015665644259150328222704419796\ +441925506500088029030962482377765030782723392665098962794517\ +576730231882534561711832295689196981946271461652617181055665\ +029685844922254588158309151172148171793920968125962871768401\ +514219388391855549421226044104700106207541829733799638752028\ +173330033785725845708464578148564931432318289223948214495353\ +081747057754695954292472958266030251293951030611301194357888\ +019943253579850479798277589149352414382665544987175298434214\ +478200760268387259124784797823102040919106572400856191771348\ +281558462777916462381681390008210723234194499857395959685631\ +103905591697879596717577715572554824817827584594613762331897\ +400606438644266287902006019904862430824505901556613731586390\ +168599701978602862986749723963103806767402004526070426607181\ +825747922672223610811748401048244356042029124854637072147748\ +725579398139682075412513930407121100054336291386326642984001\ +127998334974858209653245050832581320436526628590981309844730\ +407816586888468434842085594277964816488928181716264953794825\ +008820444984449555836465896129531451786104307525226808006600\ +779348570662654426040504120543057111107378732433349774914269\ +114072708176913318160948697397435213257520066915742989940448\ +143697754422357993424629248859049440534892849320746268179914\ +554583983135330126247834945300073309752528242351508345806997\ +166008883707127049913489117882817860966482186638832168035518\ +547034785578194655682192342735350140833854383710286830614088\ +160157865037563419851961350527354941108767405900340732309106\ +276336035381203764047251096208168592703256215746762632401447\ +152692930097455870617179441468393769999033655798513790480379\ +006890871305232768065242533442449079450072575765459163647064\ +342973773862113844201909366754475759002671807165811771132763\ +080642939637475165826471100668049369686467070723571785727451\ +880981477281249312246654190920467838735709729099560268987993\ +922945108459361151792094263319471761024927851228982814252213\ +519491081673366498846956075196529123585663883716590919107614\ +633893976419001988983816482034201465056277885540374744476861\ +750132141428803822571155963108435657119217200055907192435247\ +874999372748282438180554683005862623824642214599119474694103\ +960853742166199856978367947235980051781968651483783495342232\ +954349909573385979410403141459464534634995394356365919502754\ +724946777741899521109008000695745645078551399660814021116536\ +655749435948779817814066783795859497355305214492181630929578\ +847199238542943651540507599871461279285579624694324361023373\ +707531098971698541342280852237066460615431579189178378561194\ +172524973953556992919385025122842333469297321105671995800309\ +309633498690867723547140713111442746824881534458886302917356\ +653091434863492329838352758301829757778933132703869088008094\ +675627125816403572843436425276619486609339270853697062497300\ +328870997605020552097286001653505594207990557642339328807413\ +227100406607755741340441132517749388595948759195317512557878\ +416233575616587901198472089121093330999897692799317101600836\ +099489460591403665960336872530069816871780920562654935511809\ +645452735200740179624950793984014164529466444382558710840503\ +646450512405234491455440034942909031078393317704206940370308\ +684236835526397150556746599533254593941633896202932393007537\ +673266074923116068628384786062194914042771295779439885715389\ +357594885989682121213153533215605128333850742639410724967673\ +883284678814436067523913854991596587657401966348100597154425\ +325485566823423076082201071414803929712348781452793135058870\ +492918348933242055431354758500236922407134394398698076450588\ +396958158802767825944728350880686237998680915415443167076178\ +911739085748840458235337085643267137446973020988327650097647\ +165014946264643975815638479556314291101645367935123993093786\ +582600438548945848259707843279161086198675408925933600311615\ +428118865841645716039791455856756541424710978756200560993332\ +887344427373688627922683426869140915164843256020904560951477\ +891674986393096433202120538411067908090153863118403925770011\ +018063004678778615949475991732024974692553643880962797066439\ +850738990118773176131476115230730262123167407320563510551236\ +743953710665679470765273617718616108994029022776271817109585\ +266594261331597335282139081984596344964057781522191646561827\ +550790563823105342889841684791723392119663413065274464824389\ +193009710215891507033131686963884367885455869616509038575859\ +401565845913422314243208408202380488923480307905914026187792\ +173761338231822535262836663234810324357814170469665216751909\ +358778546855365681180620451075947932208061785930047186745864\ +869465034307360299821666637866586258459810085040702059082829\ +751567542893449238034641018001458509309792474567933738149575\ +554449108144820908702151811237205173697690115303153085234681\ +514152955272511661522989847510493796115116064878740702806004\ +343433164318094216952115530098938898426308252149645340589562\ +644869225768357954631994812409839231441980355794430127694896\ +896491616863512720318746239544591731455028723849548933141295\ +953669192660989415044776894176322467844855976195199023921936\ +699427841174911239593401205926299751407204361412696320213363\ +304107778816937724874521837448233888318479329375321435968913\ +261660516526419532347019419540663257128411929128403012569143\ +516560220706745585698808432508320490642705990501525005042508\ +275152136114303501571602916305930838603123093402367005177263\ +895812313295965866584099164896749137750449430252650456393558\ +866481394042988928722749344174035609284576107405441387577215\ +111650422217580504962998404223989353315671519700308885487441\ +513727141662624359402989615511685507459107087446822399682449\ +124027371539629961321880337101198819624529636970480400208723\ +642799448540704293456340205242051084761997006863111517147530\ +365332128784516968162146751508776010231492748374862213804161\ +453894620976763957492805125680148697998824491969672971166027\ +180656446801877171069880212083821586527774381471938887462267\ +296899230122475689865309301760858111386017280236814433190859\ +056775862835626324841690460105276503738155096364862500284444\ +534355852480049710328635489743555059728455908589253208618030\ +435328529902401798471113159138000614546932833170782820217007\ +280555759644239993454255391040403122345898223865007840565901\ +568897868969477318635101744807938902538658059188203743585010\ +774036188072258210874395280659266831769875140840386730345127\ +896213224531135734216598150684561709935188763611823258429535\ +949485724798457980490432226268479100942840366849845718310701\ +201469881667256363013936740095127208213646187168979882123038\ +233894681808950467950348320835221712924541137611086830583320\ +322392848230358837873140824038588941813883882580818470592924\ +936150343266633985142843655469994569073421029983930187839673\ +231304118378435528853547015678271557689994924601344298390228\ +619544093746214985249883379160686079281428516645627300822824\ +554858971061164154855964833723337825341913008711122841606297\ +197473771096334331602524570534960013696483960191358924434313\ +204392666956909347275363383898878667630642018321060515094118\ +366254498987167810320495485827416968962224010263497699545330\ +700657309536605222308797502818350426296399499436888453557895\ +867230278273510526890091559230412097455704458315552197774216\ +020745527743626346151485239632739221842741175405177684804394\ +361711074487719586587230018764876415713150171856819389147341\ +275669916553647687850492420266494611267030777224588709818335\ +130470138515564128370191474596569064918407585797604709553556\ +153119278534086702508240133812429162630997831448842506314109\ +096085389961648575948522991756162744630412635636848292144248\ +454353112463327392007249690205303145102507449765353317125075\ +809869430616460927871568186526610739964782640547967178516125\ +405550545621289728437343949195632975960067100886025662262995\ +603152291369500371247077545422478193737712990735596074413987\ +957973881092036286428057398201980915642421361590996553421555\ +316064082532807274813471773535367399675092780772709495672695\ +638383696748260197644726786065705886850676921416175143972878\ +598022936105171100945812789025606978738223958028881794991460\ +717838828707859620282931646221494189728518355751185688156172\ +707197545186901278242225037114294367925941035155563079724640\ +691338994542267517327767311818967695636738982145621453404681\ +597847179517622202885989672690265113711173934611717946823228\ +397269027374612101610291381645684907000127191954606896606821\ +590588324712918734294575638459194809203005860495067520818982\ +501215535430594372806160514507726395270189393064661968830908\ +304247420614491691520206185072149333329597584485319840857460\ +265175822272362267526401706014494934473630591895417261120077\ +133201893929459989521012503630498808303587706658289229523671\ +490086823643677193804640968971899497667525177372180606601357\ +946053731548464954766765148914121287985119918483345042934824\ +921516525874627647509368638818236001368121865230049945146050\ +915400988318811431699646592683887426055545037715235200928093\ +246677400833057921544547343859646810337159831128073581305667\ +357013148110868411733638100650377414586379725851070828342144\ +324871613425390515134466319365812090990461348903165220975937\ +942087587710809288871423718310748650171330836567440569630410\ +158371483868179555733183389141963880079090211810793589559200\ +341349405637234489991011938576106350455389513465949915412344\ +095068082292812278313616014687263054439671001595898696547120\ +071413092106692303936769895441754991768984405737441179222392\ +477690507985618624574174635988619556351531961292903622442398\ +465808497855672165108657385643858675294859076016771263488980\ +522695116051395273941662616850391834541635202685385855278463\ +251898869471939032633039670027544098536117464245519928068578\ +059287479506611827627630303758606108821427100635428077686167\ +838877563228833937206563827108338906357929116383562352410405\ +819098609305801465027923966325234651981390511492536734174727\ +254390774950693797823728058324006157763280570016526212182043\ +359093899236806643141856753863283409843786902795368575137111\ +428715987789800161590594633948264245607103000992774452293895\ +095821092685830313673954662073218494688153180395906146506745\ +561411975629305038852550421137841068003638882161156093692580\ +530194161044123524750036105635809277947168629873067749519842\ +957433509350316508339628224443809642374220084876711715865698\ +238309708050571369447923974325750197314968509790081061483804\ +453550810603239090298082506325805730097187923044635197024326\ +966746334305257051886113456387761013622870382593208533889592\ +238925214891289068690048585049758987775121620114117517878005\ +875020040085404765102967971726139392362711332104766149529294\ +277730971232752039868784363740304437529370880909321409176692\ +668840956756850124527879832299559696177391050297700824622043\ +866382460366020930152337219476058757174016585113549831063750\ +560749343236827486905002179231150529681970396017795115367543\ +697626587387836076075141284451928300176122499787310671827087\ +811887033677814397925059153373881836118105886419378651616798\ +592240268616476519445858857179518827325394147075773777729444\ +146380220504445359824894865222389302601440729048815894804537\ +204733015744064565559548968109597836406827155741056311263299\ +722947063908589431715872616727470668964127501101998064669236\ +547074458426237111173086536319506989478611558297416195273399\ +35302734374999e-4966L; +static const long double ld2b = +9.7127626791570376663866584373414698287493540070520215145348\ +265837955593101861790565265072369149749103838172122152721795\ +148808298295738130700276651079589269745641890661270024016251\ +019384577076103591727897583309855871833343782567221021062330\ +520323854737144092431836545425360063420220465935798468889597\ +393404878618618014948930985668173745969857941024624992678516\ +796046407897341714914468689706271051039477065250599233051128\ +834730700520991768191047336500699552011524055936141175278227\ +064109997091342657525775034753507507952039644285302561195715\ +206557908066743405503232817530015665644259150328222704419796\ +441925506500088029030962482377765030782723392665098962794517\ +576730231882534561711832295689196981946271461652617181055665\ +029685844922254588158309151172148171793920968125962871768401\ +514219388391855549421226044104700106207541829733799638752028\ +173330033785725845708464578148564931432318289223948214495353\ +081747057754695954292472958266030251293951030611301194357888\ +019943253579850479798277589149352414382665544987175298434214\ +478200760268387259124784797823102040919106572400856191771348\ +281558462777916462381681390008210723234194499857395959685631\ +103905591697879596717577715572554824817827584594613762331897\ +400606438644266287902006019904862430824505901556613731586390\ +168599701978602862986749723963103806767402004526070426607181\ +825747922672223610811748401048244356042029124854637072147748\ +725579398139682075412513930407121100054336291386326642984001\ +127998334974858209653245050832581320436526628590981309844730\ +407816586888468434842085594277964816488928181716264953794825\ +008820444984449555836465896129531451786104307525226808006600\ +779348570662654426040504120543057111107378732433349774914269\ +114072708176913318160948697397435213257520066915742989940448\ +143697754422357993424629248859049440534892849320746268179914\ +554583983135330126247834945300073309752528242351508345806997\ +166008883707127049913489117882817860966482186638832168035518\ +547034785578194655682192342735350140833854383710286830614088\ +160157865037563419851961350527354941108767405900340732309106\ +276336035381203764047251096208168592703256215746762632401447\ +152692930097455870617179441468393769999033655798513790480379\ +006890871305232768065242533442449079450072575765459163647064\ +342973773862113844201909366754475759002671807165811771132763\ +080642939637475165826471100668049369686467070723571785727451\ +880981477281249312246654190920467838735709729099560268987993\ +922945108459361151792094263319471761024927851228982814252213\ +519491081673366498846956075196529123585663883716590919107614\ +633893976419001988983816482034201465056277885540374744476861\ +750132141428803822571155963108435657119217200055907192435247\ +874999372748282438180554683005862623824642214599119474694103\ +960853742166199856978367947235980051781968651483783495342232\ +954349909573385979410403141459464534634995394356365919502754\ +724946777741899521109008000695745645078551399660814021116536\ +655749435948779817814066783795859497355305214492181630929578\ +847199238542943651540507599871461279285579624694324361023373\ +707531098971698541342280852237066460615431579189178378561194\ +172524973953556992919385025122842333469297321105671995800309\ +309633498690867723547140713111442746824881534458886302917356\ +653091434863492329838352758301829757778933132703869088008094\ +675627125816403572843436425276619486609339270853697062497300\ +328870997605020552097286001653505594207990557642339328807413\ +227100406607755741340441132517749388595948759195317512557878\ +416233575616587901198472089121093330999897692799317101600836\ +099489460591403665960336872530069816871780920562654935511809\ +645452735200740179624950793984014164529466444382558710840503\ +646450512405234491455440034942909031078393317704206940370308\ +684236835526397150556746599533254593941633896202932393007537\ +673266074923116068628384786062194914042771295779439885715389\ +357594885989682121213153533215605128333850742639410724967673\ +883284678814436067523913854991596587657401966348100597154425\ +325485566823423076082201071414803929712348781452793135058870\ +492918348933242055431354758500236922407134394398698076450588\ +396958158802767825944728350880686237998680915415443167076178\ +911739085748840458235337085643267137446973020988327650097647\ +165014946264643975815638479556314291101645367935123993093786\ +582600438548945848259707843279161086198675408925933600311615\ +428118865841645716039791455856756541424710978756200560993332\ +887344427373688627922683426869140915164843256020904560951477\ +891674986393096433202120538411067908090153863118403925770011\ +018063004678778615949475991732024974692553643880962797066439\ +850738990118773176131476115230730262123167407320563510551236\ +743953710665679470765273617718616108994029022776271817109585\ +266594261331597335282139081984596344964057781522191646561827\ +550790563823105342889841684791723392119663413065274464824389\ +193009710215891507033131686963884367885455869616509038575859\ +401565845913422314243208408202380488923480307905914026187792\ +173761338231822535262836663234810324357814170469665216751909\ +358778546855365681180620451075947932208061785930047186745864\ +869465034307360299821666637866586258459810085040702059082829\ +751567542893449238034641018001458509309792474567933738149575\ +554449108144820908702151811237205173697690115303153085234681\ +514152955272511661522989847510493796115116064878740702806004\ +343433164318094216952115530098938898426308252149645340589562\ +644869225768357954631994812409839231441980355794430127694896\ +896491616863512720318746239544591731455028723849548933141295\ +953669192660989415044776894176322467844855976195199023921936\ +699427841174911239593401205926299751407204361412696320213363\ +304107778816937724874521837448233888318479329375321435968913\ +261660516526419532347019419540663257128411929128403012569143\ +516560220706745585698808432508320490642705990501525005042508\ +275152136114303501571602916305930838603123093402367005177263\ +895812313295965866584099164896749137750449430252650456393558\ +866481394042988928722749344174035609284576107405441387577215\ +111650422217580504962998404223989353315671519700308885487441\ +513727141662624359402989615511685507459107087446822399682449\ +124027371539629961321880337101198819624529636970480400208723\ +642799448540704293456340205242051084761997006863111517147530\ +365332128784516968162146751508776010231492748374862213804161\ +453894620976763957492805125680148697998824491969672971166027\ +180656446801877171069880212083821586527774381471938887462267\ +296899230122475689865309301760858111386017280236814433190859\ +056775862835626324841690460105276503738155096364862500284444\ +534355852480049710328635489743555059728455908589253208618030\ +435328529902401798471113159138000614546932833170782820217007\ +280555759644239993454255391040403122345898223865007840565901\ +568897868969477318635101744807938902538658059188203743585010\ +774036188072258210874395280659266831769875140840386730345127\ +896213224531135734216598150684561709935188763611823258429535\ +949485724798457980490432226268479100942840366849845718310701\ +201469881667256363013936740095127208213646187168979882123038\ +233894681808950467950348320835221712924541137611086830583320\ +322392848230358837873140824038588941813883882580818470592924\ +936150343266633985142843655469994569073421029983930187839673\ +231304118378435528853547015678271557689994924601344298390228\ +619544093746214985249883379160686079281428516645627300822824\ +554858971061164154855964833723337825341913008711122841606297\ +197473771096334331602524570534960013696483960191358924434313\ +204392666956909347275363383898878667630642018321060515094118\ +366254498987167810320495485827416968962224010263497699545330\ +700657309536605222308797502818350426296399499436888453557895\ +867230278273510526890091559230412097455704458315552197774216\ +020745527743626346151485239632739221842741175405177684804394\ +361711074487719586587230018764876415713150171856819389147341\ +275669916553647687850492420266494611267030777224588709818335\ +130470138515564128370191474596569064918407585797604709553556\ +153119278534086702508240133812429162630997831448842506314109\ +096085389961648575948522991756162744630412635636848292144248\ +454353112463327392007249690205303145102507449765353317125075\ +809869430616460927871568186526610739964782640547967178516125\ +405550545621289728437343949195632975960067100886025662262995\ +603152291369500371247077545422478193737712990735596074413987\ +957973881092036286428057398201980915642421361590996553421555\ +316064082532807274813471773535367399675092780772709495672695\ +638383696748260197644726786065705886850676921416175143972878\ +598022936105171100945812789025606978738223958028881794991460\ +717838828707859620282931646221494189728518355751185688156172\ +707197545186901278242225037114294367925941035155563079724640\ +691338994542267517327767311818967695636738982145621453404681\ +597847179517622202885989672690265113711173934611717946823228\ +397269027374612101610291381645684907000127191954606896606821\ +590588324712918734294575638459194809203005860495067520818982\ +501215535430594372806160514507726395270189393064661968830908\ +304247420614491691520206185072149333329597584485319840857460\ +265175822272362267526401706014494934473630591895417261120077\ +133201893929459989521012503630498808303587706658289229523671\ +490086823643677193804640968971899497667525177372180606601357\ +946053731548464954766765148914121287985119918483345042934824\ +921516525874627647509368638818236001368121865230049945146050\ +915400988318811431699646592683887426055545037715235200928093\ +246677400833057921544547343859646810337159831128073581305667\ +357013148110868411733638100650377414586379725851070828342144\ +324871613425390515134466319365812090990461348903165220975937\ +942087587710809288871423718310748650171330836567440569630410\ +158371483868179555733183389141963880079090211810793589559200\ +341349405637234489991011938576106350455389513465949915412344\ +095068082292812278313616014687263054439671001595898696547120\ +071413092106692303936769895441754991768984405737441179222392\ +477690507985618624574174635988619556351531961292903622442398\ +465808497855672165108657385643858675294859076016771263488980\ +522695116051395273941662616850391834541635202685385855278463\ +251898869471939032633039670027544098536117464245519928068578\ +059287479506611827627630303758606108821427100635428077686167\ +838877563228833937206563827108338906357929116383562352410405\ +819098609305801465027923966325234651981390511492536734174727\ +254390774950693797823728058324006157763280570016526212182043\ +359093899236806643141856753863283409843786902795368575137111\ +428715987789800161590594633948264245607103000992774452293895\ +095821092685830313673954662073218494688153180395906146506745\ +561411975629305038852550421137841068003638882161156093692580\ +530194161044123524750036105635809277947168629873067749519842\ +957433509350316508339628224443809642374220084876711715865698\ +238309708050571369447923974325750197314968509790081061483804\ +453550810603239090298082506325805730097187923044635197024326\ +966746334305257051886113456387761013622870382593208533889592\ +238925214891289068690048585049758987775121620114117517878005\ +875020040085404765102967971726139392362711332104766149529294\ +277730971232752039868784363740304437529370880909321409176692\ +668840956756850124527879832299559696177391050297700824622043\ +866382460366020930152337219476058757174016585113549831063750\ +560749343236827486905002179231150529681970396017795115367543\ +697626587387836076075141284451928300176122499787310671827087\ +811887033677814397925059153373881836118105886419378651616798\ +592240268616476519445858857179518827325394147075773777729444\ +146380220504445359824894865222389302601440729048815894804537\ +204733015744064565559548968109597836406827155741056311263299\ +722947063908589431715872616727470668964127501101998064669236\ +547074458426237111173086536319506989478611558297416195273399\ +35302734375e-4966L; +static const long double ld2c = +9.7127626791570376663866584373414698287493540070520215145348\ +265837955593101861790565265072369149749103838172122152721795\ +148808298295738130700276651079589269745641890661270024016251\ +019384577076103591727897583309855871833343782567221021062330\ +520323854737144092431836545425360063420220465935798468889597\ +393404878618618014948930985668173745969857941024624992678516\ +796046407897341714914468689706271051039477065250599233051128\ +834730700520991768191047336500699552011524055936141175278227\ +064109997091342657525775034753507507952039644285302561195715\ +206557908066743405503232817530015665644259150328222704419796\ +441925506500088029030962482377765030782723392665098962794517\ +576730231882534561711832295689196981946271461652617181055665\ +029685844922254588158309151172148171793920968125962871768401\ +514219388391855549421226044104700106207541829733799638752028\ +173330033785725845708464578148564931432318289223948214495353\ +081747057754695954292472958266030251293951030611301194357888\ +019943253579850479798277589149352414382665544987175298434214\ +478200760268387259124784797823102040919106572400856191771348\ +281558462777916462381681390008210723234194499857395959685631\ +103905591697879596717577715572554824817827584594613762331897\ +400606438644266287902006019904862430824505901556613731586390\ +168599701978602862986749723963103806767402004526070426607181\ +825747922672223610811748401048244356042029124854637072147748\ +725579398139682075412513930407121100054336291386326642984001\ +127998334974858209653245050832581320436526628590981309844730\ +407816586888468434842085594277964816488928181716264953794825\ +008820444984449555836465896129531451786104307525226808006600\ +779348570662654426040504120543057111107378732433349774914269\ +114072708176913318160948697397435213257520066915742989940448\ +143697754422357993424629248859049440534892849320746268179914\ +554583983135330126247834945300073309752528242351508345806997\ +166008883707127049913489117882817860966482186638832168035518\ +547034785578194655682192342735350140833854383710286830614088\ +160157865037563419851961350527354941108767405900340732309106\ +276336035381203764047251096208168592703256215746762632401447\ +152692930097455870617179441468393769999033655798513790480379\ +006890871305232768065242533442449079450072575765459163647064\ +342973773862113844201909366754475759002671807165811771132763\ +080642939637475165826471100668049369686467070723571785727451\ +880981477281249312246654190920467838735709729099560268987993\ +922945108459361151792094263319471761024927851228982814252213\ +519491081673366498846956075196529123585663883716590919107614\ +633893976419001988983816482034201465056277885540374744476861\ +750132141428803822571155963108435657119217200055907192435247\ +874999372748282438180554683005862623824642214599119474694103\ +960853742166199856978367947235980051781968651483783495342232\ +954349909573385979410403141459464534634995394356365919502754\ +724946777741899521109008000695745645078551399660814021116536\ +655749435948779817814066783795859497355305214492181630929578\ +847199238542943651540507599871461279285579624694324361023373\ +707531098971698541342280852237066460615431579189178378561194\ +172524973953556992919385025122842333469297321105671995800309\ +309633498690867723547140713111442746824881534458886302917356\ +653091434863492329838352758301829757778933132703869088008094\ +675627125816403572843436425276619486609339270853697062497300\ +328870997605020552097286001653505594207990557642339328807413\ +227100406607755741340441132517749388595948759195317512557878\ +416233575616587901198472089121093330999897692799317101600836\ +099489460591403665960336872530069816871780920562654935511809\ +645452735200740179624950793984014164529466444382558710840503\ +646450512405234491455440034942909031078393317704206940370308\ +684236835526397150556746599533254593941633896202932393007537\ +673266074923116068628384786062194914042771295779439885715389\ +357594885989682121213153533215605128333850742639410724967673\ +883284678814436067523913854991596587657401966348100597154425\ +325485566823423076082201071414803929712348781452793135058870\ +492918348933242055431354758500236922407134394398698076450588\ +396958158802767825944728350880686237998680915415443167076178\ +911739085748840458235337085643267137446973020988327650097647\ +165014946264643975815638479556314291101645367935123993093786\ +582600438548945848259707843279161086198675408925933600311615\ +428118865841645716039791455856756541424710978756200560993332\ +887344427373688627922683426869140915164843256020904560951477\ +891674986393096433202120538411067908090153863118403925770011\ +018063004678778615949475991732024974692553643880962797066439\ +850738990118773176131476115230730262123167407320563510551236\ +743953710665679470765273617718616108994029022776271817109585\ +266594261331597335282139081984596344964057781522191646561827\ +550790563823105342889841684791723392119663413065274464824389\ +193009710215891507033131686963884367885455869616509038575859\ +401565845913422314243208408202380488923480307905914026187792\ +173761338231822535262836663234810324357814170469665216751909\ +358778546855365681180620451075947932208061785930047186745864\ +869465034307360299821666637866586258459810085040702059082829\ +751567542893449238034641018001458509309792474567933738149575\ +554449108144820908702151811237205173697690115303153085234681\ +514152955272511661522989847510493796115116064878740702806004\ +343433164318094216952115530098938898426308252149645340589562\ +644869225768357954631994812409839231441980355794430127694896\ +896491616863512720318746239544591731455028723849548933141295\ +953669192660989415044776894176322467844855976195199023921936\ +699427841174911239593401205926299751407204361412696320213363\ +304107778816937724874521837448233888318479329375321435968913\ +261660516526419532347019419540663257128411929128403012569143\ +516560220706745585698808432508320490642705990501525005042508\ +275152136114303501571602916305930838603123093402367005177263\ +895812313295965866584099164896749137750449430252650456393558\ +866481394042988928722749344174035609284576107405441387577215\ +111650422217580504962998404223989353315671519700308885487441\ +513727141662624359402989615511685507459107087446822399682449\ +124027371539629961321880337101198819624529636970480400208723\ +642799448540704293456340205242051084761997006863111517147530\ +365332128784516968162146751508776010231492748374862213804161\ +453894620976763957492805125680148697998824491969672971166027\ +180656446801877171069880212083821586527774381471938887462267\ +296899230122475689865309301760858111386017280236814433190859\ +056775862835626324841690460105276503738155096364862500284444\ +534355852480049710328635489743555059728455908589253208618030\ +435328529902401798471113159138000614546932833170782820217007\ +280555759644239993454255391040403122345898223865007840565901\ +568897868969477318635101744807938902538658059188203743585010\ +774036188072258210874395280659266831769875140840386730345127\ +896213224531135734216598150684561709935188763611823258429535\ +949485724798457980490432226268479100942840366849845718310701\ +201469881667256363013936740095127208213646187168979882123038\ +233894681808950467950348320835221712924541137611086830583320\ +322392848230358837873140824038588941813883882580818470592924\ +936150343266633985142843655469994569073421029983930187839673\ +231304118378435528853547015678271557689994924601344298390228\ +619544093746214985249883379160686079281428516645627300822824\ +554858971061164154855964833723337825341913008711122841606297\ +197473771096334331602524570534960013696483960191358924434313\ +204392666956909347275363383898878667630642018321060515094118\ +366254498987167810320495485827416968962224010263497699545330\ +700657309536605222308797502818350426296399499436888453557895\ +867230278273510526890091559230412097455704458315552197774216\ +020745527743626346151485239632739221842741175405177684804394\ +361711074487719586587230018764876415713150171856819389147341\ +275669916553647687850492420266494611267030777224588709818335\ +130470138515564128370191474596569064918407585797604709553556\ +153119278534086702508240133812429162630997831448842506314109\ +096085389961648575948522991756162744630412635636848292144248\ +454353112463327392007249690205303145102507449765353317125075\ +809869430616460927871568186526610739964782640547967178516125\ +405550545621289728437343949195632975960067100886025662262995\ +603152291369500371247077545422478193737712990735596074413987\ +957973881092036286428057398201980915642421361590996553421555\ +316064082532807274813471773535367399675092780772709495672695\ +638383696748260197644726786065705886850676921416175143972878\ +598022936105171100945812789025606978738223958028881794991460\ +717838828707859620282931646221494189728518355751185688156172\ +707197545186901278242225037114294367925941035155563079724640\ +691338994542267517327767311818967695636738982145621453404681\ +597847179517622202885989672690265113711173934611717946823228\ +397269027374612101610291381645684907000127191954606896606821\ +590588324712918734294575638459194809203005860495067520818982\ +501215535430594372806160514507726395270189393064661968830908\ +304247420614491691520206185072149333329597584485319840857460\ +265175822272362267526401706014494934473630591895417261120077\ +133201893929459989521012503630498808303587706658289229523671\ +490086823643677193804640968971899497667525177372180606601357\ +946053731548464954766765148914121287985119918483345042934824\ +921516525874627647509368638818236001368121865230049945146050\ +915400988318811431699646592683887426055545037715235200928093\ +246677400833057921544547343859646810337159831128073581305667\ +357013148110868411733638100650377414586379725851070828342144\ +324871613425390515134466319365812090990461348903165220975937\ +942087587710809288871423718310748650171330836567440569630410\ +158371483868179555733183389141963880079090211810793589559200\ +341349405637234489991011938576106350455389513465949915412344\ +095068082292812278313616014687263054439671001595898696547120\ +071413092106692303936769895441754991768984405737441179222392\ +477690507985618624574174635988619556351531961292903622442398\ +465808497855672165108657385643858675294859076016771263488980\ +522695116051395273941662616850391834541635202685385855278463\ +251898869471939032633039670027544098536117464245519928068578\ +059287479506611827627630303758606108821427100635428077686167\ +838877563228833937206563827108338906357929116383562352410405\ +819098609305801465027923966325234651981390511492536734174727\ +254390774950693797823728058324006157763280570016526212182043\ +359093899236806643141856753863283409843786902795368575137111\ +428715987789800161590594633948264245607103000992774452293895\ +095821092685830313673954662073218494688153180395906146506745\ +561411975629305038852550421137841068003638882161156093692580\ +530194161044123524750036105635809277947168629873067749519842\ +957433509350316508339628224443809642374220084876711715865698\ +238309708050571369447923974325750197314968509790081061483804\ +453550810603239090298082506325805730097187923044635197024326\ +966746334305257051886113456387761013622870382593208533889592\ +238925214891289068690048585049758987775121620114117517878005\ +875020040085404765102967971726139392362711332104766149529294\ +277730971232752039868784363740304437529370880909321409176692\ +668840956756850124527879832299559696177391050297700824622043\ +866382460366020930152337219476058757174016585113549831063750\ +560749343236827486905002179231150529681970396017795115367543\ +697626587387836076075141284451928300176122499787310671827087\ +811887033677814397925059153373881836118105886419378651616798\ +592240268616476519445858857179518827325394147075773777729444\ +146380220504445359824894865222389302601440729048815894804537\ +204733015744064565559548968109597836406827155741056311263299\ +722947063908589431715872616727470668964127501101998064669236\ +547074458426237111173086536319506989478611558297416195273399\ +35302734375001e-4966L; +/* 0x1.00000000000000000000000000008p16383 */ +static const long double ld3ae = 0x1p16383L, ld3be = 0x1p16383L, ld3ce = 0x1.0000000000000000000000000001p16383L; +static const long double ld3a = +5.9486574767861588254287966331400362266521016077566321470782\ +537912717956830282749074200158904838100315216442070246474582\ +902003466452178519493817532236893426065414065500349426609921\ +035191682920005861156266113904955955975156868485667432573303\ +878926292023832306985858165533616318247459636179261303962505\ +904914506095247123433601806274279678546351097459236573913920\ +031119173565521719790447288258729779003490433862818295682642\ +966216118764004792730459319737327354906008978235133081179386\ +661103577408353480771246949457853166617701522167422003413661\ +284349262437896929014552545611813747697933241007066137144800\ +742052491919942298834913628182656296203230288447275444631994\ +418174246363265098248611943128819168942591708210157385631417\ +956400560296628065072016801065604053356267458749418972817500\ +860163920552394032596390414022010839803056885484295371329659\ +344624001094572196271168792142488910586863048428263135994222\ +918660801863635503541746352435642903327106245556596971697306\ +154375736529491499973297647239267168544491542059174479409314\ +453930981788080813637734358380528957486229480817553751111130\ +404254432007093360403147894746265072027252334199618554793914\ +408408563073872776198001518686536858983411123156743992398602\ +085226973929708268146742705557350571330511483380748376403472\ +416543579901056379914358020396036857647833383066531875675143\ +906511120597222727322243981995901699031025427175941279288823\ +868963521340475095965307606235778429805072284801680535137734\ +383642104178041358430293569208331406005130704155581295151191\ +023575851522079817808333970280354640050199344622016227349001\ +158400930280667186488774262251890453600109065837537684194570\ +764422774923245437306731669764159584659798151950637627762794\ +773771743234047950402370403351226180108444229650943701626484\ +199813157683590670152514287926030050893275989087988431157294\ +053225152320381185461962202878894704210605536874860744635921\ +856800920799848781308318732102232154544901177747472418520161\ +539850654183977571241391795912749098112352006092865789718049\ +308722403022684428414862730635213534446271587083620368851394\ +539053886621230946713996355227159995125430034494483477708852\ +290917108703653719242299789100268057863851224567265334616704\ +172517852701300018859009181286438758473871366303386211559752\ +189988549719766361306120241141163757479824826687017385967199\ +730649217746155593260923125994938678356692052428393066501806\ +030161358556419313420716683771612548240263459903320490075985\ +482955242306590857238462197972208846146747634114611463194143\ +127229709932188005016692926586196070737427116881065809283735\ +578248117685225847553587906225824731173075427424421056682930\ +008434666477496431516691881829440430197100204332606435934395\ +919650053069892524027974091575173698894803107552411683630872\ +565514028274910395383420510115859479233531504702656455261624\ +525121293886827716275308028935388238178963278225114817400178\ +138358373030159940110845417191798464503817960506134575572552\ +914585335913528444536373142082490326061583126796147603336390\ +503084982226891516248370317420733394038771780044922478150880\ +480334844447412365553656029955296322473008695074712792828366\ +405738282245039545396582938290818627301780773130202921675326\ +417583673495241569334204568141534153408474297319168484568799\ +451491133718839097374713416523361939237171154953070144389353\ +699828605993755613252573941610133829557167740458222617685028\ +690018342727148122013513056358815140027414679795450105000784\ +206522215604435223172005007036171570530334304897008809135848\ +675229547083561399988252552429769084290516103080260036003448\ +294799988351419108088251107290628711358276092795741489822211\ +879153727229891058795497426373608319405317602924241055836665\ +412584135657242160003706626205312971822953452930840783143003\ +733239017808969394445195220787737174218027747221253900890536\ +730326425051240764874006627032589076376990325467270006751475\ +463920721323985366812116303998245085483206258613663624851716\ +293180303624443281556295689730668616708901429287181381627670\ +203893651414675005136379365959571811951919653635887567699289\ +348324076406793991923217469674198904524716009847788439650157\ +995310043698774137542541699134940585662745702625097983274489\ +141416414789061652098131796728731652650516767112149192122453\ +562328802846445391417036742140146906572447511494124473885963\ +235217227016424204095604485308686968373890645296189932416571\ +281295736247619241329068636405743573306087991776733585972793\ +132869616481671565021096885870153734254648327143225051745267\ +530463119926261147612098111086806545372953526471421579845285\ +862975776235466663857936867536855924718593170503922894779577\ +706239977813334283740751103082483280516469722321753891088699\ +714361755511843803441649441302693703577359971743834932539197\ +595873998629500074441134301810890941848881837426270390549007\ +490141375766653241037340192392236932759127069111401216220596\ +540958515892047794438580629374176225297401789362125586732528\ +367695144980519774116001979888033796577336271850743828263427\ +598863925843301048044096576340652808516459551933515596083641\ +0468395384831999e+4931L; +static const long double ld3b = +5.9486574767861588254287966331400362266521016077566321470782\ +537912717956830282749074200158904838100315216442070246474582\ +902003466452178519493817532236893426065414065500349426609921\ +035191682920005861156266113904955955975156868485667432573303\ +878926292023832306985858165533616318247459636179261303962505\ +904914506095247123433601806274279678546351097459236573913920\ +031119173565521719790447288258729779003490433862818295682642\ +966216118764004792730459319737327354906008978235133081179386\ +661103577408353480771246949457853166617701522167422003413661\ +284349262437896929014552545611813747697933241007066137144800\ +742052491919942298834913628182656296203230288447275444631994\ +418174246363265098248611943128819168942591708210157385631417\ +956400560296628065072016801065604053356267458749418972817500\ +860163920552394032596390414022010839803056885484295371329659\ +344624001094572196271168792142488910586863048428263135994222\ +918660801863635503541746352435642903327106245556596971697306\ +154375736529491499973297647239267168544491542059174479409314\ +453930981788080813637734358380528957486229480817553751111130\ +404254432007093360403147894746265072027252334199618554793914\ +408408563073872776198001518686536858983411123156743992398602\ +085226973929708268146742705557350571330511483380748376403472\ +416543579901056379914358020396036857647833383066531875675143\ +906511120597222727322243981995901699031025427175941279288823\ +868963521340475095965307606235778429805072284801680535137734\ +383642104178041358430293569208331406005130704155581295151191\ +023575851522079817808333970280354640050199344622016227349001\ +158400930280667186488774262251890453600109065837537684194570\ +764422774923245437306731669764159584659798151950637627762794\ +773771743234047950402370403351226180108444229650943701626484\ +199813157683590670152514287926030050893275989087988431157294\ +053225152320381185461962202878894704210605536874860744635921\ +856800920799848781308318732102232154544901177747472418520161\ +539850654183977571241391795912749098112352006092865789718049\ +308722403022684428414862730635213534446271587083620368851394\ +539053886621230946713996355227159995125430034494483477708852\ +290917108703653719242299789100268057863851224567265334616704\ +172517852701300018859009181286438758473871366303386211559752\ +189988549719766361306120241141163757479824826687017385967199\ +730649217746155593260923125994938678356692052428393066501806\ +030161358556419313420716683771612548240263459903320490075985\ +482955242306590857238462197972208846146747634114611463194143\ +127229709932188005016692926586196070737427116881065809283735\ +578248117685225847553587906225824731173075427424421056682930\ +008434666477496431516691881829440430197100204332606435934395\ +919650053069892524027974091575173698894803107552411683630872\ +565514028274910395383420510115859479233531504702656455261624\ +525121293886827716275308028935388238178963278225114817400178\ +138358373030159940110845417191798464503817960506134575572552\ +914585335913528444536373142082490326061583126796147603336390\ +503084982226891516248370317420733394038771780044922478150880\ +480334844447412365553656029955296322473008695074712792828366\ +405738282245039545396582938290818627301780773130202921675326\ +417583673495241569334204568141534153408474297319168484568799\ +451491133718839097374713416523361939237171154953070144389353\ +699828605993755613252573941610133829557167740458222617685028\ +690018342727148122013513056358815140027414679795450105000784\ +206522215604435223172005007036171570530334304897008809135848\ +675229547083561399988252552429769084290516103080260036003448\ +294799988351419108088251107290628711358276092795741489822211\ +879153727229891058795497426373608319405317602924241055836665\ +412584135657242160003706626205312971822953452930840783143003\ +733239017808969394445195220787737174218027747221253900890536\ +730326425051240764874006627032589076376990325467270006751475\ +463920721323985366812116303998245085483206258613663624851716\ +293180303624443281556295689730668616708901429287181381627670\ +203893651414675005136379365959571811951919653635887567699289\ +348324076406793991923217469674198904524716009847788439650157\ +995310043698774137542541699134940585662745702625097983274489\ +141416414789061652098131796728731652650516767112149192122453\ +562328802846445391417036742140146906572447511494124473885963\ +235217227016424204095604485308686968373890645296189932416571\ +281295736247619241329068636405743573306087991776733585972793\ +132869616481671565021096885870153734254648327143225051745267\ +530463119926261147612098111086806545372953526471421579845285\ +862975776235466663857936867536855924718593170503922894779577\ +706239977813334283740751103082483280516469722321753891088699\ +714361755511843803441649441302693703577359971743834932539197\ +595873998629500074441134301810890941848881837426270390549007\ +490141375766653241037340192392236932759127069111401216220596\ +540958515892047794438580629374176225297401789362125586732528\ +367695144980519774116001979888033796577336271850743828263427\ +598863925843301048044096576340652808516459551933515596083641\ +0468395384832e+4931L; +static const long double ld3c = +5.9486574767861588254287966331400362266521016077566321470782\ +537912717956830282749074200158904838100315216442070246474582\ +902003466452178519493817532236893426065414065500349426609921\ +035191682920005861156266113904955955975156868485667432573303\ +878926292023832306985858165533616318247459636179261303962505\ +904914506095247123433601806274279678546351097459236573913920\ +031119173565521719790447288258729779003490433862818295682642\ +966216118764004792730459319737327354906008978235133081179386\ +661103577408353480771246949457853166617701522167422003413661\ +284349262437896929014552545611813747697933241007066137144800\ +742052491919942298834913628182656296203230288447275444631994\ +418174246363265098248611943128819168942591708210157385631417\ +956400560296628065072016801065604053356267458749418972817500\ +860163920552394032596390414022010839803056885484295371329659\ +344624001094572196271168792142488910586863048428263135994222\ +918660801863635503541746352435642903327106245556596971697306\ +154375736529491499973297647239267168544491542059174479409314\ +453930981788080813637734358380528957486229480817553751111130\ +404254432007093360403147894746265072027252334199618554793914\ +408408563073872776198001518686536858983411123156743992398602\ +085226973929708268146742705557350571330511483380748376403472\ +416543579901056379914358020396036857647833383066531875675143\ +906511120597222727322243981995901699031025427175941279288823\ +868963521340475095965307606235778429805072284801680535137734\ +383642104178041358430293569208331406005130704155581295151191\ +023575851522079817808333970280354640050199344622016227349001\ +158400930280667186488774262251890453600109065837537684194570\ +764422774923245437306731669764159584659798151950637627762794\ +773771743234047950402370403351226180108444229650943701626484\ +199813157683590670152514287926030050893275989087988431157294\ +053225152320381185461962202878894704210605536874860744635921\ +856800920799848781308318732102232154544901177747472418520161\ +539850654183977571241391795912749098112352006092865789718049\ +308722403022684428414862730635213534446271587083620368851394\ +539053886621230946713996355227159995125430034494483477708852\ +290917108703653719242299789100268057863851224567265334616704\ +172517852701300018859009181286438758473871366303386211559752\ +189988549719766361306120241141163757479824826687017385967199\ +730649217746155593260923125994938678356692052428393066501806\ +030161358556419313420716683771612548240263459903320490075985\ +482955242306590857238462197972208846146747634114611463194143\ +127229709932188005016692926586196070737427116881065809283735\ +578248117685225847553587906225824731173075427424421056682930\ +008434666477496431516691881829440430197100204332606435934395\ +919650053069892524027974091575173698894803107552411683630872\ +565514028274910395383420510115859479233531504702656455261624\ +525121293886827716275308028935388238178963278225114817400178\ +138358373030159940110845417191798464503817960506134575572552\ +914585335913528444536373142082490326061583126796147603336390\ +503084982226891516248370317420733394038771780044922478150880\ +480334844447412365553656029955296322473008695074712792828366\ +405738282245039545396582938290818627301780773130202921675326\ +417583673495241569334204568141534153408474297319168484568799\ +451491133718839097374713416523361939237171154953070144389353\ +699828605993755613252573941610133829557167740458222617685028\ +690018342727148122013513056358815140027414679795450105000784\ +206522215604435223172005007036171570530334304897008809135848\ +675229547083561399988252552429769084290516103080260036003448\ +294799988351419108088251107290628711358276092795741489822211\ +879153727229891058795497426373608319405317602924241055836665\ +412584135657242160003706626205312971822953452930840783143003\ +733239017808969394445195220787737174218027747221253900890536\ +730326425051240764874006627032589076376990325467270006751475\ +463920721323985366812116303998245085483206258613663624851716\ +293180303624443281556295689730668616708901429287181381627670\ +203893651414675005136379365959571811951919653635887567699289\ +348324076406793991923217469674198904524716009847788439650157\ +995310043698774137542541699134940585662745702625097983274489\ +141416414789061652098131796728731652650516767112149192122453\ +562328802846445391417036742140146906572447511494124473885963\ +235217227016424204095604485308686968373890645296189932416571\ +281295736247619241329068636405743573306087991776733585972793\ +132869616481671565021096885870153734254648327143225051745267\ +530463119926261147612098111086806545372953526471421579845285\ +862975776235466663857936867536855924718593170503922894779577\ +706239977813334283740751103082483280516469722321753891088699\ +714361755511843803441649441302693703577359971743834932539197\ +595873998629500074441134301810890941848881837426270390549007\ +490141375766653241037340192392236932759127069111401216220596\ +540958515892047794438580629374176225297401789362125586732528\ +367695144980519774116001979888033796577336271850743828263427\ +598863925843301048044096576340652808516459551933515596083641\ +0468395384832001e+4931L; +#endif + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ +#ifdef FLT_OK + if (f1a != f1ae + || f1b != f1be + || f1c != f1ce + || f2a != f2ae + || f2b != f2be + || f2c != f2ce + || f3a != f3ae + || f3b != f3be + || f3c != f3ce) + abort (); +#endif +#ifdef DBL_OK + if (d1a != d1ae + || d1b != d1be + || d1c != d1ce + || d2a != d2ae + || d2b != d2be + || d2c != d2ce + || d3a != d3ae + || d3b != d3be + || d3c != d3ce) + abort (); +#endif +#ifdef LDBL_OK + if (ld1a != ld1ae + || ld1b != ld1be + || ld1c != ld1ce + || ld2a != ld2ae + || ld2b != ld2be + || ld2c != ld2ce + || ld3a != ld3ae + || ld3b != ld3be + || ld3c != ld3ce) + abort (); +#endif + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/float-range-1.c b/SingleSource/Regression/C/gcc-dg/float-range-1.c new file mode 100644 index 0000000000..0142c3d8f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float-range-1.c @@ -0,0 +1,14 @@ +/* Floating constants outside the range of their type should receive a + just a warning if the target supports infinities. Otherwise, a + pedwarn should be produced. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-ansi -pedantic-errors -Woverflow" } */ + +void +f (void) +{ + float a = 1e+100000000f; /* { dg-warning "floating constant exceeds range of 'float'" } */ + double b = 1e+100000000; /* { dg-warning "floating constant exceeds range of 'double'" } */ + long double c = 1e+100000000l; /* { dg-warning "floating constant exceeds range of 'long double'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/float-range-2.c b/SingleSource/Regression/C/gcc-dg/float-range-2.c new file mode 100644 index 0000000000..d6c0b8a400 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float-range-2.c @@ -0,0 +1,14 @@ +/* Floating constants outside the range of their type should receive a + pedwarn, not a warning. This includes INFINITY if the target does + not support infinities. */ +/* Origin: Joseph Myers */ +/* { dg-do compile { target vax-*-* pdp11-*-* } } */ +/* { dg-options "-ansi -pedantic-errors" } */ + +void +f (void) +{ + float a = __builtin_inff (); /* { dg-error "target format does not support infinity" } */ + double b = __builtin_inf (); /* { dg-error "target format does not support infinity" } */ + long double c = __builtin_infl (); /* { dg-error "target format does not support infinity" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/float-range-3.c b/SingleSource/Regression/C/gcc-dg/float-range-3.c new file mode 100644 index 0000000000..e386bbab36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float-range-3.c @@ -0,0 +1,42 @@ +/* PR 23572 : warnings for out of range floating-point constants. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ +#include + +#ifndef INFINITY +#define INFINITY (__builtin_inff ()) +#endif + +void overflow(void) +{ + float f1 = 3.5E+38f; /* { dg-warning "floating constant exceeds range" } */ + float f2 = -3.5E+38f; /* { dg-warning "floating constant exceeds range" } */ + float f3 = INFINITY; + float f4 = -INFINITY; + + double d1 = 1.9E+308; /* { dg-warning "floating constant exceeds range" } */ + double d2 = -1.9E+308; /* { dg-warning "floating constant exceeds range" } */ + double d3 = INFINITY; + double d4 = -INFINITY; +} + +void underflow(void) +{ + float f11 = 3.3E-10000000000000000000f; /* { dg-warning "floating constant truncated to zero" } */ + float f22 = -3.3E-10000000000000000000f; /* { dg-warning "floating constant truncated to zero" } */ + float f1 = 3.3E-46f; /* { dg-warning "floating constant truncated to zero" } */ + float f2 = -3.3E-46f; /* { dg-warning "floating constant truncated to zero" } */ + float f3 = 0; + float f4 = -0; + float f5 = 0.0; + float f6 = -0.0; + + double d11 = 3.3E-10000000000000000000; /* { dg-warning "floating constant truncated to zero" } */ + double d22 = -3.3E-10000000000000000000; /* { dg-warning "floating constant truncated to zero" } */ + double d1 = 1.4E-325; /* { dg-warning "floating constant truncated to zero" } */ + double d2 = -1.4E-325; /* { dg-warning "floating constant truncated to zero" } */ + double d3 = 0; + double d4 = -0; + double d5 = 0.0; + double d6 = -0.0; +} diff --git a/SingleSource/Regression/C/gcc-dg/float-range-4.c b/SingleSource/Regression/C/gcc-dg/float-range-4.c new file mode 100644 index 0000000000..c4faaa067b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float-range-4.c @@ -0,0 +1,42 @@ +/* PR 23572 : warnings for out of range floating-point constants. */ +/* { dg-do compile } */ +/* { dg-options "-Wno-overflow -std=c99" } */ +#include + +#ifndef INFINITY +#define INFINITY (__builtin_inff ()) +#endif + +void overflow(void) +{ + float f1 = 3.5E+38f; + float f2 = -3.5E+38f; + float f3 = INFINITY; + float f4 = -INFINITY; + + double d1 = 1.9E+308; + double d2 = -1.9E+308; + double d3 = INFINITY; + double d4 = -INFINITY; +} + +void underflow(void) +{ + float f11 = 3.3E-10000000000000000000f; + float f22 = -3.3E-10000000000000000000f; + float f1 = 3.3E-46f; + float f2 = -3.3E-46f; + float f3 = 0; + float f4 = -0; + float f5 = 0.0; + float f6 = -0.0; + + double d11 = 3.3E-10000000000000000000; + double d22 = -3.3E-10000000000000000000; + double d1 = 1.4E-325; + double d2 = -1.4E-325; + double d3 = 0; + double d4 = -0; + double d5 = 0.0; + double d6 = -0.0; +} diff --git a/SingleSource/Regression/C/gcc-dg/float-range-5.c b/SingleSource/Regression/C/gcc-dg/float-range-5.c new file mode 100644 index 0000000000..f3e06ba636 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float-range-5.c @@ -0,0 +1,43 @@ +/* PR 23572 : warnings for out of range floating-point constants + Test that they are NOT pedantic warnings. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c99" } */ +#include + +#ifndef INFINITY +#define INFINITY (__builtin_inff ()) +#endif + +void overflow(void) +{ + float f1 = 3.5E+38f; /* { dg-warning "floating constant exceeds range" } */ + float f2 = -3.5E+38f; /* { dg-warning "floating constant exceeds range" } */ + float f3 = INFINITY; + float f4 = -INFINITY; + + double d1 = 1.9E+308; /* { dg-warning "floating constant exceeds range" } */ + double d2 = -1.9E+308; /* { dg-warning "floating constant exceeds range" } */ + double d3 = INFINITY; + double d4 = -INFINITY; +} + +void underflow(void) +{ + float f11 = 3.3E-10000000000000000000f; /* { dg-warning "floating constant truncated to zero" } */ + float f22 = -3.3E-10000000000000000000f; /* { dg-warning "floating constant truncated to zero" } */ + float f1 = 3.3E-46f; /* { dg-warning "floating constant truncated to zero" } */ + float f2 = -3.3E-46f; /* { dg-warning "floating constant truncated to zero" } */ + float f3 = 0; + float f4 = -0; + float f5 = 0.0; + float f6 = -0.0; + + double d11 = 3.3E-10000000000000000000; /* { dg-warning "floating constant truncated to zero" } */ + double d22 = -3.3E-10000000000000000000; /* { dg-warning "floating constant truncated to zero" } */ + double d1 = 1.4E-325; /* { dg-warning "floating constant truncated to zero" } */ + double d2 = -1.4E-325; /* { dg-warning "floating constant truncated to zero" } */ + double d3 = 0; + double d4 = -0; + double d5 = 0.0; + double d6 = -0.0; +} diff --git a/SingleSource/Regression/C/gcc-dg/float128-align.c b/SingleSource/Regression/C/gcc-dg/float128-align.c new file mode 100644 index 0000000000..511540b7bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float128-align.c @@ -0,0 +1,9 @@ +/* Test _Float128 alignment. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +#define WIDTH 128 +#define EXT 0 +#include "floatn-align.h" diff --git a/SingleSource/Regression/C/gcc-dg/float128-typeof.c b/SingleSource/Regression/C/gcc-dg/float128-typeof.c new file mode 100644 index 0000000000..b6f95b770a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float128-typeof.c @@ -0,0 +1,9 @@ +/* Test _Float128 constant types. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ + +#define WIDTH 128 +#define EXT 0 +#include "floatn-typeof.h" diff --git a/SingleSource/Regression/C/gcc-dg/float128x-align.c b/SingleSource/Regression/C/gcc-dg/float128x-align.c new file mode 100644 index 0000000000..45b3e5b265 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float128x-align.c @@ -0,0 +1,9 @@ +/* Test _Float128 alignment. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float128x } */ +/* { dg-require-effective-target float128x } */ + +#define WIDTH 128 +#define EXT 1 +#include "floatn-align.h" diff --git a/SingleSource/Regression/C/gcc-dg/float128x-typeof.c b/SingleSource/Regression/C/gcc-dg/float128x-typeof.c new file mode 100644 index 0000000000..3ab2ce2deb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float128x-typeof.c @@ -0,0 +1,9 @@ +/* Test _Float128x constant types. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float128x } */ +/* { dg-require-effective-target float128x } */ + +#define WIDTH 128 +#define EXT 1 +#include "floatn-typeof.h" diff --git a/SingleSource/Regression/C/gcc-dg/float16-align.c b/SingleSource/Regression/C/gcc-dg/float16-align.c new file mode 100644 index 0000000000..90e6f455c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float16-align.c @@ -0,0 +1,9 @@ +/* Test _Float16 alignment. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +#define WIDTH 16 +#define EXT 0 +#include "floatn-align.h" diff --git a/SingleSource/Regression/C/gcc-dg/float16-typeof.c b/SingleSource/Regression/C/gcc-dg/float16-typeof.c new file mode 100644 index 0000000000..a781239efa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float16-typeof.c @@ -0,0 +1,9 @@ +/* Test _Float16 constant types. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +#define WIDTH 16 +#define EXT 0 +#include "floatn-typeof.h" diff --git a/SingleSource/Regression/C/gcc-dg/float32-align.c b/SingleSource/Regression/C/gcc-dg/float32-align.c new file mode 100644 index 0000000000..c881700a20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float32-align.c @@ -0,0 +1,9 @@ +/* Test _Float32 alignment. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float32 } */ +/* { dg-require-effective-target float32 } */ + +#define WIDTH 32 +#define EXT 0 +#include "floatn-align.h" diff --git a/SingleSource/Regression/C/gcc-dg/float32-typeof.c b/SingleSource/Regression/C/gcc-dg/float32-typeof.c new file mode 100644 index 0000000000..4b9ccf82cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float32-typeof.c @@ -0,0 +1,9 @@ +/* Test _Float32 constant types. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float32 } */ +/* { dg-require-effective-target float32 } */ + +#define WIDTH 32 +#define EXT 0 +#include "floatn-typeof.h" diff --git a/SingleSource/Regression/C/gcc-dg/float32x-align.c b/SingleSource/Regression/C/gcc-dg/float32x-align.c new file mode 100644 index 0000000000..da396c67e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float32x-align.c @@ -0,0 +1,9 @@ +/* Test _Float32 alignment. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32x } */ + +#define WIDTH 32 +#define EXT 1 +#include "floatn-align.h" diff --git a/SingleSource/Regression/C/gcc-dg/float32x-typeof.c b/SingleSource/Regression/C/gcc-dg/float32x-typeof.c new file mode 100644 index 0000000000..9af60778d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float32x-typeof.c @@ -0,0 +1,9 @@ +/* Test _Float32x constant types. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32x } */ + +#define WIDTH 32 +#define EXT 1 +#include "floatn-typeof.h" diff --git a/SingleSource/Regression/C/gcc-dg/float64-align.c b/SingleSource/Regression/C/gcc-dg/float64-align.c new file mode 100644 index 0000000000..82266e33fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float64-align.c @@ -0,0 +1,9 @@ +/* Test _Float64 alignment. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float64 } */ +/* { dg-require-effective-target float64 } */ + +#define WIDTH 64 +#define EXT 0 +#include "floatn-align.h" diff --git a/SingleSource/Regression/C/gcc-dg/float64-typeof.c b/SingleSource/Regression/C/gcc-dg/float64-typeof.c new file mode 100644 index 0000000000..aa7d504efd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float64-typeof.c @@ -0,0 +1,9 @@ +/* Test _Float64 constant types. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float64 } */ +/* { dg-require-effective-target float64 } */ + +#define WIDTH 64 +#define EXT 0 +#include "floatn-typeof.h" diff --git a/SingleSource/Regression/C/gcc-dg/float64x-align.c b/SingleSource/Regression/C/gcc-dg/float64x-align.c new file mode 100644 index 0000000000..8916071ceb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float64x-align.c @@ -0,0 +1,9 @@ +/* Test _Float64 alignment. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +#define WIDTH 64 +#define EXT 1 +#include "floatn-align.h" diff --git a/SingleSource/Regression/C/gcc-dg/float64x-typeof.c b/SingleSource/Regression/C/gcc-dg/float64x-typeof.c new file mode 100644 index 0000000000..934d6cf5f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/float64x-typeof.c @@ -0,0 +1,9 @@ +/* Test _Float64x constant types. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float64x } */ +/* { dg-require-effective-target float64x } */ + +#define WIDTH 64 +#define EXT 1 +#include "floatn-typeof.h" diff --git a/SingleSource/Regression/C/gcc-dg/floatn-align.h b/SingleSource/Regression/C/gcc-dg/floatn-align.h new file mode 100644 index 0000000000..3196f33066 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/floatn-align.h @@ -0,0 +1,18 @@ +/* Tests for _FloatN / _FloatNx types: test max_align_t alignment. + Before including this file, define WIDTH as the value N; define EXT + to 1 for _FloatNx and 0 for _FloatN. */ + +#define CONCATX(X, Y) X ## Y +#define CONCAT(X, Y) CONCATX (X, Y) +#define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z) + +#if EXT +# define TYPE CONCAT3 (_Float, WIDTH, x) +#else +# define TYPE CONCAT (_Float, WIDTH) +#endif + +#include + +_Static_assert (_Alignof (max_align_t) >= _Alignof (TYPE), + "max_align_t must be at least as aligned as _Float* types"); diff --git a/SingleSource/Regression/C/gcc-dg/floatn-arithconv.c b/SingleSource/Regression/C/gcc-dg/floatn-arithconv.c new file mode 100644 index 0000000000..c3eb24e1fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/floatn-arithconv.c @@ -0,0 +1,50 @@ +/* Tests for _FloatN / _FloatNx types: test usual arithmetic + conversions. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float64 } */ +/* { dg-require-effective-target float32x } */ + +#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include + +int i; + +#define TEST(VAR, TYPE1, TYPE2, RESTYPE) \ + do \ + { \ + typedef __typeof__ ((TYPE1) 0 + (TYPE2) 1) restype; \ + typedef __typeof__ (i ? (TYPE1) 0 : (TYPE2) 1) restype2; \ + typedef RESTYPE exptype; \ + extern restype VAR; \ + extern restype2 VAR; \ + extern exptype VAR; \ + } \ + while (0) + +void +f (void) +{ + TEST (v1, float, double, double); +#if DBL_MANT_DIG > FLT32_MANT_DIG + TEST (v2, double, _Float32, double); +#endif +#if DBL_MANT_DIG <= FLT64_MANT_DIG + TEST (v3, double, _Float64, _Float64); +#endif +#if DBL_MANT_DIG >= FLT32X_MANT_DIG + TEST (v4, double, _Float32x, double); +#endif +#if FLT_MANT_DIG <= FLT32_MANT_DIG + TEST (v5, float, _Float32, _Float32); +#endif +#if FLT32X_MANT_DIG <= FLT64_MANT_DIG + TEST (v6, _Float32x, _Float64, _Float64); +#endif + TEST (v7, _Float32, _Float64, _Float64); + TEST (v8, _Float32, _Float32x, _Float32x); +} diff --git a/SingleSource/Regression/C/gcc-dg/floatn-errs.c b/SingleSource/Regression/C/gcc-dg/floatn-errs.c new file mode 100644 index 0000000000..0dcc2f1bb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/floatn-errs.c @@ -0,0 +1,44 @@ +/* Tests for _FloatN / _FloatNx types: test erroneous code. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float32x } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float32x } */ +/* { dg-require-effective-target float64 } */ + +/* _FloatN, _FloatNx and standard types are incompatible even if they + have the same ABI. */ + +extern float a; /* { dg-message "previous declaration" } */ +extern _Float32 a; /* { dg-error "conflicting" } */ + +extern double b; /* { dg-message "previous declaration" } */ +extern _Float32x b; /* { dg-error "conflicting" } */ + +extern _Float64 c; /* { dg-message "previous declaration" } */ +extern _Float32x c; /* { dg-error "conflicting" } */ + +/* These types are not promoted in old-style function definitions. */ + +void f (_Float32); +void +f (x) + _Float32 x; +{ +} + +void g (double); /* { dg-error "prototype declaration" } */ +void +g (x) + _Float32 x; /* { dg-error "match prototype" } */ +{ +} + +void h (_Float64); /* { dg-error "prototype declaration" } */ +void +h (x) + _Float32 x; /* { dg-error "match prototype" } */ +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/floatn-typeof.h b/SingleSource/Regression/C/gcc-dg/floatn-typeof.h new file mode 100644 index 0000000000..4a3e5865a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/floatn-typeof.h @@ -0,0 +1,22 @@ +/* Tests for _FloatN / _FloatNx types: test types of constants. + Before including this file, define WIDTH as the value N; define EXT + to 1 for _FloatNx and 0 for _FloatN. */ + +#define CONCATX(X, Y) X ## Y +#define CONCAT(X, Y) CONCATX (X, Y) +#define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z) +#define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z) + +#if EXT +# define TYPE CONCAT3 (_Float, WIDTH, x) +# define CST(C) CONCAT4 (C, f, WIDTH, x) +# define CSTU(C) CONCAT4 (C, F, WIDTH, x) +#else +# define TYPE CONCAT (_Float, WIDTH) +# define CST(C) CONCAT3 (C, f, WIDTH) +# define CSTU(C) CONCAT3 (C, F, WIDTH) +#endif + +extern TYPE test_type; +extern __typeof (CST (1.0)) test_type; +extern __typeof (CSTU (1.0)) test_type; diff --git a/SingleSource/Regression/C/gcc-dg/fltconst-1.c b/SingleSource/Regression/C/gcc-dg/fltconst-1.c new file mode 100644 index 0000000000..e8ecf6750a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fltconst-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fshow-column" } */ + +double a = 1.ld; /* { dg-error "12:invalid suffix" } */ +double b = 1.fd; /* { dg-error "12:invalid suffix" } */ +double c = 1.di; +double d = 1.dj; +double e = 1.id; +double f = 1.jd; +double g = 1.ddd; /* { dg-error "12:invalid suffix" } */ +double h = 1.ldd; /* { dg-error "12:invalid suffix" } */ +double i = 1.dld; /* { dg-error "12:invalid suffix" } */ +double j = 1.ddl; /* { dg-error "12:invalid suffix" } */ +double k = 1.fdd; /* { dg-error "12:invalid suffix" } */ +double l = 1.dfd; /* { dg-error "12:invalid suffix" } */ +double m = 1.ddf; /* { dg-error "12:invalid suffix" } */ diff --git a/SingleSource/Regression/C/gcc-dg/fltconst-2.c b/SingleSource/Regression/C/gcc-dg/fltconst-2.c new file mode 100644 index 0000000000..d4d06ac882 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fltconst-2.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +/* Check that d or D is recognized as a float constant suffix. */ + +double d = 0.5d; +double D = 0.5D; + +/* Check that d or D is recognized in a hexadecimal floating constant. */ + +double hd1 = 0x1.8p1d; +double hd2 = 0x1.p+1D; +double hd3 = 0x0.8p-1d; + +/* Check that imaginary constant suffixes are still recognized with + only i, I, j, or J. */ + +double i = 0.5i; +double I = 0.5I; +double j = 0.5j; +double J = 0.5J; + +/* Check that imaginary constant suffixes are allowed with d or D. */ + +double di = 0.5di; +double dI = 0.5dI; +double Di = 0.5Di; +double DI = 0.5DI; +double dj = 0.5dj; +double dJ = 0.5dJ; +double Dj = 0.5Dj; +double DJ = 0.5DJ; +double id = 0.5id; +double iD = 0.5iD; +double Id = 0.5Id; +double ID = 0.5ID; +double jd = 0.5jd; +double jD = 0.5jD; +double Jd = 0.5Jd; +double JD = 0.5JD; diff --git a/SingleSource/Regression/C/gcc-dg/fltconst-double-pedantic-1.c b/SingleSource/Regression/C/gcc-dg/fltconst-double-pedantic-1.c new file mode 100644 index 0000000000..07827296db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fltconst-double-pedantic-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic" } */ + +double a = 1.d; /* { dg-warning "double constant" } */ +double b = 1.D; /* { dg-warning "double constant" } */ +double c = 1.1e+2d; /* { dg-warning "double constant" } */ + +double d = 1.di; /* { dg-warning "imaginary constants" } */ +double e = 1.dj; /* { dg-warning "imaginary constants" } */ +double f = 1.id; /* { dg-warning "imaginary constants" } */ +double g = 1.jd; /* { dg-warning "imaginary constants" } */ + +double h = 0x1.5p1d; /* { dg-warning "double constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/fltconst-double-pedantic-2.c b/SingleSource/Regression/C/gcc-dg/fltconst-double-pedantic-2.c new file mode 100644 index 0000000000..316571f762 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fltconst-double-pedantic-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +double a = 1.d; /* { dg-error "double constant" } */ +double b = 1.D; /* { dg-error "double constant" } */ +double c = 1.1e+2d; /* { dg-error "double constant" } */ + +double d = 1.di; /* { dg-error "imaginary constants" } */ +double e = 1.dj; /* { dg-error "imaginary constants" } */ +double f = 1.id; /* { dg-error "imaginary constants" } */ +double g = 1.jd; /* { dg-error "imaginary constants" } */ + +double h = 0x1.5p1d; /* { dg-error "double constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/fltconst-pedantic-dfp.c b/SingleSource/Regression/C/gcc-dg/fltconst-pedantic-dfp.c new file mode 100644 index 0000000000..6ff3091ce6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fltconst-pedantic-dfp.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +double a = 1.dl; /* { dg-warning "decimal float" } */ +/* { dg-error "not supported for this target" "not supported" { target { ! dfp } } .-1 } */ +double b = 1.df; /* { dg-warning "decimal float" } */ +/* { dg-error "not supported for this target" "not supported" { target { ! dfp } } .-1 } */ +double c = 1.dd; /* { dg-warning "decimal float" } */ +/* { dg-error "not supported for this target" "not supported" { target { ! dfp } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/fma-1.c b/SingleSource/Regression/C/gcc-dg/fma-1.c new file mode 100644 index 0000000000..8c33cb2d64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fma-1.c @@ -0,0 +1,15 @@ +/* { dg-options "-O2 -fdump-tree-widening_mul" } */ + +float +f1 (float a, float b, float c) +{ + return a * b + c; +} + +double +f2 (double a, double b, double c) +{ + return a * b + c; +} + +/* { dg-final { scan-tree-dump-times { = \.FMA \(} 2 "widening_mul" { target scalar_all_fma } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fma-2.c b/SingleSource/Regression/C/gcc-dg/fma-2.c new file mode 100644 index 0000000000..41d20a4296 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fma-2.c @@ -0,0 +1,15 @@ +/* { dg-options "-O2 -fdump-tree-widening_mul" } */ + +float +f1 (float a, float b, float c) +{ + return a * b - c; +} + +double +f2 (double a, double b, double c) +{ + return a * b - c; +} + +/* { dg-final { scan-tree-dump-times { = \.FMS \(} 2 "widening_mul" { target scalar_all_fma } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fma-3.c b/SingleSource/Regression/C/gcc-dg/fma-3.c new file mode 100644 index 0000000000..699aa2c953 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fma-3.c @@ -0,0 +1,15 @@ +/* { dg-options "-O2 -fdump-tree-widening_mul" } */ + +float +f1 (float a, float b, float c) +{ + return c - a * b; +} + +double +f2 (double a, double b, double c) +{ + return c - a * b; +} + +/* { dg-final { scan-tree-dump-times { = \.FNMA \(} 2 "widening_mul" { target scalar_all_fma } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fma-4.c b/SingleSource/Regression/C/gcc-dg/fma-4.c new file mode 100644 index 0000000000..bff928f1fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fma-4.c @@ -0,0 +1,15 @@ +/* { dg-options "-O2 -fdump-tree-widening_mul" } */ + +float +f1 (float a, float b, float c) +{ + return -(a * b) - c; +} + +double +f2 (double a, double b, double c) +{ + return -(a * b) - c; +} + +/* { dg-final { scan-tree-dump-times { = \.FNMS \(} 2 "widening_mul" { target scalar_all_fma } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fma-5.c b/SingleSource/Regression/C/gcc-dg/fma-5.c new file mode 100644 index 0000000000..68d75979fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fma-5.c @@ -0,0 +1,53 @@ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +float +f1 (float a, float b, float c) +{ + return __builtin_fmaf (a, b, -c); +} + +double +f2 (double a, double b, double c) +{ + return __builtin_fma (a, b, -c); +} + +void +f3 (float a, float b, float c, float d, float e, float *res) +{ + res[0] = __builtin_fmaf (a, b, -e); + res[1] = __builtin_fmaf (c, d, -e); +} + +void +f4 (double a, double b, double c, double d, double e, double *res) +{ + res[0] = __builtin_fma (a, b, -e); + res[1] = __builtin_fma (c, d, -e); +} + +float +f5 (float a, float b, float c) +{ + return -__builtin_fmaf (-a, b, c); +} + +double +f6 (double a, double b, double c) +{ + return -__builtin_fma (-a, b, c); +} + +float +f7 (float a, float b, float c) +{ + return -__builtin_fmaf (a, -b, c); +} + +double +f8 (double a, double b, double c) +{ + return -__builtin_fma (a, -b, c); +} + +/* { dg-final { scan-tree-dump-times { = \.FMS \(} 10 "optimized" { target scalar_all_fma } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fma-6.c b/SingleSource/Regression/C/gcc-dg/fma-6.c new file mode 100644 index 0000000000..87258cec4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fma-6.c @@ -0,0 +1,67 @@ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +float +f1 (float a, float b, float c) +{ + return __builtin_fmaf (-a, b, c); +} + +double +f2 (double a, double b, double c) +{ + return __builtin_fma (-a, b, c); +} + +float +f3 (float a, float b, float c) +{ + return __builtin_fmaf (a, -b, c); +} + +double +f4 (double a, double b, double c) +{ + return __builtin_fma (a, -b, c); +} + +void +f5 (float a, float b, float c, float d, float e, float *res) +{ + res[0] = __builtin_fmaf (-a, b, c); + res[1] = __builtin_fmaf (-a, d, e); +} + +void +f6 (double a, double b, double c, double d, double e, double *res) +{ + res[0] = __builtin_fma (-a, b, c); + res[1] = __builtin_fma (-a, d, e); +} + +void +f7 (float a, float b, float c, float d, float e, float *res) +{ + res[0] = __builtin_fmaf (a, -b, c); + res[1] = __builtin_fmaf (d, -b, e); +} + +void +f8 (double a, double b, double c, double d, double e, double *res) +{ + res[0] = __builtin_fma (a, -b, c); + res[1] = __builtin_fma (d, -b, e); +} + +float +f9 (float a, float b, float c) +{ + return -__builtin_fmaf (a, b, -c); +} + +double +f10 (double a, double b, double c) +{ + return -__builtin_fma (a, b, -c); +} + +/* { dg-final { scan-tree-dump-times { = \.FNMA \(} 14 "optimized" { target scalar_all_fma } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fma-7.c b/SingleSource/Regression/C/gcc-dg/fma-7.c new file mode 100644 index 0000000000..f409cc8ee3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fma-7.c @@ -0,0 +1,67 @@ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +float +f1 (float a, float b, float c) +{ + return __builtin_fmaf (-a, b, -c); +} + +double +f2 (double a, double b, double c) +{ + return __builtin_fma (-a, b, -c); +} + +float +f3 (float a, float b, float c) +{ + return __builtin_fmaf (a, -b, -c); +} + +double +f4 (double a, double b, double c) +{ + return __builtin_fma (a, -b, -c); +} + +void +f5 (float a, float b, float c, float d, float *res) +{ + res[0] = __builtin_fmaf (-a, b, -c); + res[1] = __builtin_fmaf (-a, d, -c); +} + +void +f6 (double a, double b, double c, double d, double *res) +{ + res[0] = __builtin_fma (-a, b, -c); + res[1] = __builtin_fma (-a, d, -c); +} + +void +f7 (float a, float b, float c, float d, float *res) +{ + res[0] = __builtin_fmaf (a, -b, -c); + res[1] = __builtin_fmaf (d, -b, -c); +} + +void +f8 (double a, double b, double c, double d, double *res) +{ + res[0] = __builtin_fma (a, -b, -c); + res[1] = __builtin_fma (d, -b, -c); +} + +float +f9 (float a, float b, float c) +{ + return -__builtin_fmaf (a, b, c); +} + +double +f10 (double a, double b, double c) +{ + return -__builtin_fma (a, b, c); +} + +/* { dg-final { scan-tree-dump-times { = \.FNMS \(} 14 "optimized" { target scalar_all_fma } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fmax-fmin-1.c b/SingleSource/Regression/C/gcc-dg/fmax-fmin-1.c new file mode 100644 index 0000000000..e7e0518d8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fmax-fmin-1.c @@ -0,0 +1,18 @@ +/* { dg-options "-O -fdump-tree-optimized" } */ + +void +f1 (double *res, double x, double y) +{ + res[0] = __builtin_fmax (x, y); + res[1] = __builtin_fmax (y, x); +} + +void +f2 (double *res, double x, double y) +{ + res[0] = __builtin_fmin (x, y); + res[1] = __builtin_fmin (y, x); +} + +/* { dg-final { scan-tree-dump-times {__builtin_fmax} 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times {__builtin_fmin} 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fnegate-1.c b/SingleSource/Regression/C/gcc-dg/fnegate-1.c new file mode 100644 index 0000000000..ad0f4e09f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fnegate-1.c @@ -0,0 +1,113 @@ +/* Copyright (C) 2002 Free Software Foundation. + + Test floating point negation produces the expected results. + + Written by Roger Sayle, 21st May 2002. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void abort (); + + +double +dneg (double x) +{ + return -x; +} + +double +dmult (double x) +{ + return -1.0 * x; +} + +double +ddiv (double x) +{ + return x / -1.0; +} + + +float +fneg (float x) +{ + return -x; +} + +float +fmult (float x) +{ + return -1.0f * x; +} + +float +fdiv (float x) +{ + return x / -1.0f; +} + + +void +ftest(float src, float dst) +{ + if (fneg (src) != dst) + abort (); + + if (src != fneg (dst)) + abort (); + + if (fmult (src) != dst) + abort (); + + if (src != fmult (dst)) + abort (); + + if (fdiv (src) != dst) + abort (); + + if (src != fdiv(dst)) + abort (); +} + +void +dtest(double src, double dst) +{ + if (dneg (src) != dst) + abort (); + + if (src != dneg (dst)) + abort (); + + if (dmult (src) != dst) + abort (); + + if (src != dmult (dst)) + abort (); + + if (ddiv (src) != dst) + abort (); + + if (src != ddiv(dst)) + abort (); +} + + +int +main () +{ + ftest (1.0f, -1.0f); + ftest (2.0f, -2.0f); + ftest (-3.0f, 3.0f); + ftest (0.0f, -0.0f); + ftest (-0.0f, 0.0f); + + dtest (1.0, -1.0); + dtest (2.0, -2.0); + dtest (-3.0, 3.0); + dtest (0.0, -0.0); + dtest (-0.0, 0.0); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/fold-abs-1.c b/SingleSource/Regression/C/gcc-dg/fold-abs-1.c new file mode 100644 index 0000000000..2e69a20757 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-abs-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fwrapv" } */ +#define ABS(x) (x > 0 ? x : -x) +int f (int a, int b) { + if ((ABS(a) | b) != 0) return 1; + else return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/fold-abs-2.c b/SingleSource/Regression/C/gcc-dg/fold-abs-2.c new file mode 100644 index 0000000000..6291d7e538 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-abs-2.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -fwrapv" } */ +#include +void exit (int); +void abort (); +#define ABS(x) (x > 0 ? x : -x) +int f (int a) { + if (ABS(a) >= 0) return 1; + else return 0; +} + +int main (int argc, char *argv[]) { + if (f(INT_MIN)) + abort (); + else + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/fold-abs-3.c b/SingleSource/Regression/C/gcc-dg/fold-abs-3.c new file mode 100644 index 0000000000..fcbcb4bde0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-abs-3.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple -fwrapv" } */ +#define ABS(x) (x > 0 ? x : -x) +int f (int a) { + return ABS (ABS(a)); +} + +/* { dg-final { scan-tree-dump-times "ABS" 1 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-abs-4.c b/SingleSource/Regression/C/gcc-dg/fold-abs-4.c new file mode 100644 index 0000000000..38a7d9dabb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-abs-4.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple -fwrapv" } */ +extern float fabsf (float); +extern float cabsf (_Complex float); + +int f (float a) { + return fabsf(a) < 0.0; +} + +int g (_Complex float a) { + return cabsf (a) < 0.0; +} + +/* { dg-final { scan-tree-dump-times "ABS" 0 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-abs-5.c b/SingleSource/Regression/C/gcc-dg/fold-abs-5.c new file mode 100644 index 0000000000..4a892afe8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-abs-5.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test (int a, int b, int sum) +{ + sum += ((a - b) > 0 ? (a - b) : -(a - b)); + return sum; +} + +/* { dg-final { scan-tree-dump "ABS" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-addr-1.c b/SingleSource/Regression/C/gcc-dg/fold-addr-1.c new file mode 100644 index 0000000000..a0597813ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-addr-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int bar(char p1, char p2) +{ + return &p1 == &p2; +} + +/* { dg-final { scan-tree-dump "return 0;" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-alloca-1.c b/SingleSource/Regression/C/gcc-dg/fold-alloca-1.c new file mode 100644 index 0000000000..733aeecca3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-alloca-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-cfg" } */ +/* { dg-require-effective-target alloca } */ + +void *alloca (__SIZE_TYPE__); +void link_error (); + +int main (int argc, char *argv[]) { + char *foo; + if ((foo = alloca(argc)) == 0) + link_error (); + return 0; +} +/* { dg-final { scan-tree-dump-times "link_error" 0 "cfg" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-and-1.c b/SingleSource/Regression/C/gcc-dg/fold-and-1.c new file mode 100644 index 0000000000..d555bb4b2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-and-1.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int x, int y) +{ + int tem1 = x | y; + int tem2 = ~(x & y); + return tem1 & tem2; +} + +int +fn2 (int x, int y) +{ + int tem1 = y | x; + int tem2 = ~(x & y); + return tem1 & tem2; +} + +int +fn3 (int x, int y) +{ + int tem1 = x | y; + int tem2 = ~(y & x); + return tem1 & tem2; +} + +int +fn4 (int x, int y) +{ + int tem1 = y | x; + int tem2 = ~(y & x); + return tem1 & tem2; +} + +int +fn5 (int x, int y) +{ + int tem1 = ~(x & y); + int tem2 = x | y; + return tem1 & tem2; +} + +int +fn6 (int x, int y) +{ + int tem1 = ~(x & y); + int tem2 = y | x; + return tem1 & tem2; +} + +int +fn7 (int x, int y) +{ + int tem1 = ~(y & x); + int tem2 = x | y; + return tem1 & tem2; +} + +int +fn8 (int x, int y) +{ + int tem1 = ~(y & x); + int tem2 = y | x; + return tem1 & tem2; +} + +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\& " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-and-2.c b/SingleSource/Regression/C/gcc-dg/fold-and-2.c new file mode 100644 index 0000000000..3df2a0ba59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-and-2.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int x, int y) +{ + int tem1 = x | y; + int tem2 = ~x ^ y; + return tem1 & tem2; +} + +int +fn2 (int x, int y) +{ + int tem1 = y | x; + int tem2 = ~x ^ y; + return tem1 & tem2; +} + +int +fn3 (int x, int y) +{ + int tem1 = x | y; + int tem2 = y ^ ~x; + return tem1 & tem2; +} + +int +fn4 (int x, int y) +{ + int tem1 = y | x; + int tem2 = y ^ ~x; + return tem1 & tem2; +} + +int +fn5 (int x, int y) +{ + int tem1 = ~x ^ y; + int tem2 = x | y; + return tem1 & tem2; +} + +int +fn6 (int x, int y) +{ + int tem1 = ~x ^ y; + int tem2 = y | x; + return tem1 & tem2; +} + +int +fn7 (int x, int y) +{ + int tem1 = y ^ ~x; + int tem2 = x | y; + return tem1 & tem2; +} + +int +fn8 (int x, int y) +{ + int tem1 = y ^ ~x; + int tem2 = y | x; + return tem1 & tem2; +} + +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-and-lshift.c b/SingleSource/Regression/C/gcc-dg/fold-and-lshift.c new file mode 100644 index 0000000000..2905095ff7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-and-lshift.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +int f(int x) +{ + return (x << 2) & 128; +} + +int g(int x) +{ + return !!(x & 32) << 7; +} + +int h(int x) +{ + return ((x >> 5) & 1) << 7; +} + +int i(int x) +{ + return (x & 32) >> 5 << 7; +} + +int j(int x) +{ + return ((x >> 5) & 1) ? 128 : 0; +} + +int k(int x) +{ + return (x & 32) ? 128 : 0; +} + +/* { dg-final { scan-tree-dump-not " \\? " "original" } } */ +/* { dg-final { scan-assembler-not "sarl" { target i?86-*-* x86_64-*-* } } }" */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-and-rshift-1.c b/SingleSource/Regression/C/gcc-dg/fold-and-rshift-1.c new file mode 100644 index 0000000000..11c13d582e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-and-rshift-1.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +int f(int x) +{ + return (x >> 2) & 128; +} + +int g(int x) +{ + return !!(x & 512) << 7; +} + +int h(int x) +{ + return ((x >> 9) & 1) << 7; +} + +int i(int x) +{ + return (x & 512) >> 9 << 7; +} + +int j(int x) +{ + return ((x >> 9) & 1) ? 128 : 0; +} + +int k(int x) +{ + return (x & 512) ? 128 : 0; +} + +/* { dg-final { scan-tree-dump-not " \\? " "original" } } */ +/* { dg-final { scan-assembler-not "sall" { target i?86-*-* x86_64-*-* } } }" */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-and-rshift-2.c b/SingleSource/Regression/C/gcc-dg/fold-and-rshift-2.c new file mode 100644 index 0000000000..74edf42e48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-and-rshift-2.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +#if __SIZEOF_INT__ < 4 +#define unsigned __UINT32_TYPE__ +#endif + +unsigned f(unsigned x) +{ + return (x >> 29) & 32; +} + +unsigned g(unsigned x) +{ + return !!(x & 0x80000000) << 5; +} + +unsigned j(unsigned x) +{ + return ((x >> 31) & 1) ? 32 : 0; +} + +unsigned k(unsigned x) +{ + return (x & 0x80000000) ? 32 : 0; +} + +/* { dg-final { scan-tree-dump-not " \\? " "original" } } */ +/* { dg-final { scan-assembler-not "sall" { target i?86-*-* x86_64-*-* } } }" */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-andxor-1.c b/SingleSource/Regression/C/gcc-dg/fold-andxor-1.c new file mode 100644 index 0000000000..dcef3f8377 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-andxor-1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return (a ^ b) & a; +} + +int test2(int c, int d) +{ + return (c ^ d) & d; +} + +int test3(int e, int f) +{ + return e & (e ^ f); +} + +int test4(int g, int h) +{ + return g & (h ^ g); +} + +/* { dg-final { scan-tree-dump-times "~b \& a" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "~c \& d" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "~f \& e" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "~h \& g" 1 "original" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-bcopy.c b/SingleSource/Regression/C/gcc-dg/fold-bcopy.c new file mode 100644 index 0000000000..9a5448465e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-bcopy.c @@ -0,0 +1,54 @@ +/* PR tree-optimization/80933 - redundant bzero/bcopy calls not eliminated + { dg-do compile } + { dg-options "-O1 -Wall -fdump-tree-lower" } */ + +void f0 (void *dst, const void *src, unsigned n) +{ + /* Bcopy(src, dst, ...) corresponds to memmove(dst, src, ...), + with the first two arguments transposed, not memcpy. */ + __builtin_bcopy (src, dst, n); +} + +void f1 (void *p, const void *q, unsigned n) +{ + /* A call with zero size should be eliminated. */ + __builtin_bcopy (q, p, 0); +} + +int f2 (const void *p, const void *q, unsigned n) +{ + return __builtin_bcmp (p, q, n); +} + +int f3 (const void *p, const void *q) +{ + /* A call with zero size should be folded into 0. */ + return __builtin_bcmp (p, q, 0); +} + +int f4 (const void *p, unsigned n) +{ + /* A call with the same argument should also be folded into 0. */ + return __builtin_bcmp (p, p, n); +} + +void f5 (void *p, unsigned n) +{ + __builtin_bzero (p, n); +} + +void f6 (void *p) +{ + /* A call with zero size should be eliminated. */ + __builtin_bzero (p, 0); +} + +/* Verify that calls to bcmp, bcopy, and bzero have all been removed + and one of each replaced with memcmp, memmove, and memset, respectively. + The remaining three should be eliminated. + { dg-final { scan-tree-dump-not "bcmp|bcopy|bzero" "lower" } } + { dg-final { scan-tree-dump-times "memcmp|memmove|memset" 3 "lower" } } + + Verify that the bcopy to memmove transformation correctly transposed + the source and destination pointer arguments. + { dg-final { scan-tree-dump-times "memmove \\(dst, src" 1 "lower" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-bitand-1.c b/SingleSource/Regression/C/gcc-dg/fold-bitand-1.c new file mode 100644 index 0000000000..68a7c27a6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-bitand-1.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-w -fdump-tree-original" } */ + +char c1 __attribute__ ((aligned (1))); +char c2 __attribute__ ((aligned (2))); +char c4 __attribute__ ((aligned (4))); +char c8 __attribute__ ((aligned (8))); +unsigned f1(void) +{ + return 3 & (__SIZE_TYPE__)&c1; +} + +unsigned f2(void) +{ + return 3 & (__SIZE_TYPE__)&c2; +} + +unsigned f3(void) +{ + return 3 & (__SIZE_TYPE__)&c4; +} + +unsigned f4(void) +{ + return 3 & (__SIZE_TYPE__)&c8; +} + +/* { dg-final { scan-tree-dump-times "\&c1 \& 3" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\&c2 \& 3" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\&c4 \& 3" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "\&c8 \& 3" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 0" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-bitand-2.c b/SingleSource/Regression/C/gcc-dg/fold-bitand-2.c new file mode 100644 index 0000000000..5809965c59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-bitand-2.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +struct { + char c1; + char c2; + char c3; + char c4; +} s __attribute__ ((aligned (4))); + +unsigned f1 (void) +{ + return 3 & (__SIZE_TYPE__)&s.c1; +} + +unsigned f2 (void) +{ + return 3 & (__SIZE_TYPE__)&s.c2; +} + +unsigned f3 (void) +{ + return 3 & (__SIZE_TYPE__)&s.c3; +} + +unsigned f4 (void) +{ + return 3 & (__SIZE_TYPE__)&s.c4; +} + +unsigned f5 (void) +{ + return 4 & (__SIZE_TYPE__)&s.c1; +} + +/* { dg-final { scan-tree-dump-times "\& 3" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "\& 4" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 1" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 2" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 3" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-bitand-3.c b/SingleSource/Regression/C/gcc-dg/fold-bitand-3.c new file mode 100644 index 0000000000..c0fe87d364 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-bitand-3.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +char c[4] __attribute__ ((aligned (4))); + +struct S { + char c1; + char c2; + char c3; + char c4; +}; + +int f1 (void) +{ + return 3 & (__SIZE_TYPE__)&c[1]; +} + +int f2 (void) +{ + return 3 & (__SIZE_TYPE__)&((struct S *)&c)->c2; +} + +/* { dg-final { scan-tree-dump-times "\& 3" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 1" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-bitand-4.c b/SingleSource/Regression/C/gcc-dg/fold-bitand-4.c new file mode 100644 index 0000000000..9ca2842fc5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-bitand-4.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +int foo (int i) +{ + return (i * 8) & 5; +} + +unsigned bar (unsigned i) +{ + return (i * 6) & 5; +} + +/* { dg-final { scan-tree-dump-times "\\\&" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\\& 4;" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-bopcond-1.c b/SingleSource/Regression/C/gcc-dg/fold-bopcond-1.c new file mode 100644 index 0000000000..7324c166c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-bopcond-1.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-ifcvt" } */ + +int foo1 (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x <= 32768 ? x + 32768 : 0); + } + return x; +} + +int foo2 (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x < 32768 ? x + 32768 : 0); + } + return x; +} + +int foo3 (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x < 1000 ? x - 1000 : 0); + } + return x; +} + +int foo4 (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x <= 2 ? x + 999 : 1001); + } + return x; +} + +/* { dg-final { scan-tree-dump-times "MIN_EXPR " 4 "ifcvt" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-bopcond-2.c b/SingleSource/Regression/C/gcc-dg/fold-bopcond-2.c new file mode 100644 index 0000000000..7a47449f93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-bopcond-2.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-ifcvt" } */ + +int foo1 (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x >= 32768 ? x - 32768 : 0); + } + return x; +} + +int foo2 (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x > 32768 ? x - 32768 : 0); + } + return x; +} + +int foo3 (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x > 1000 ? x - 1000 : 0); + } + return x; +} + +int foo4 (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x >= 2 ? x - 32768 : 32770); + } + return x; +} + +/* { dg-final { scan-tree-dump-times "MAX_EXPR " 4 "ifcvt" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-compare-1.c b/SingleSource/Regression/C/gcc-dg/fold-compare-1.c new file mode 100644 index 0000000000..8ab21c05b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-compare-1.c @@ -0,0 +1,52 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return ~a == ~b; +} + +int test2(int c, int d) +{ + return -c == -d; +} + +int test3(int e) +{ + return -e == 5; +} + +int test4(int f) +{ + return ~f == 5; +} + +int test5(int g, int h) +{ + return ~g < ~h; +} + +int test6(int i, int j) +{ + return ~i >= ~j; +} + +int test7(int k) +{ + return ~k < 3; +} + +int test8(int l) +{ + return ~l >= 2; +} + +/* { dg-final { scan-tree-dump-times "b == a" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "c == d" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e == -5" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "f == -6" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "h < g" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "j >= i" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "k >= -3" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "l < -2" 1 "original" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-compare-2.c b/SingleSource/Regression/C/gcc-dg/fold-compare-2.c new file mode 100644 index 0000000000..16f0fd9cdc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-compare-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-fre1" } */ + +extern void abort (void); + +int a; + +int +main(void) +{ + if (a * 1000 < 0) + abort (); + if (a * -43 > 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Removing basic block" 2 "fre1" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-compare-3.c b/SingleSource/Regression/C/gcc-dg/fold-compare-3.c new file mode 100644 index 0000000000..f8a38b0994 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-compare-3.c @@ -0,0 +1,158 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cfg" } */ + +#include + +void this_comparison_is_false (void); +void this_comparison_is_true (void); +void this_comparison_is_not_decidable (void); + +void bla1eq (int var) +{ + if (var + 10 == INT_MIN + 9) + this_comparison_is_false (); +} + +void bla2eq (int var) +{ + if (var + 10 == INT_MIN + 10) + this_comparison_is_not_decidable (); +} + +void bla3eq (int var) +{ + if (var - 10 == INT_MAX - 9) + this_comparison_is_false (); +} + +void bla4eq (int var) +{ + if (var - 10 == INT_MAX - 10) + this_comparison_is_not_decidable (); +} + +void bla1ne (int var) +{ + if (var + 10 != INT_MIN + 9) + this_comparison_is_true (); +} + +void bla2ne (int var) +{ + if (var + 10 != INT_MIN + 10) + this_comparison_is_not_decidable (); +} + +void bla3ne (int var) +{ + if (var - 10 != INT_MAX - 9) + this_comparison_is_true (); +} + +void bla4ne (int var) +{ + if (var - 10 != INT_MAX - 10) + this_comparison_is_not_decidable (); +} + +void bla1lt (int var) +{ + if (var + 10 < INT_MIN + 10) + this_comparison_is_false (); +} + +void bla2lt (int var) +{ + if (var + 10 < INT_MIN + 11) + this_comparison_is_not_decidable (); +} + +void bla3lt (int var) +{ + if (var - 10 < INT_MAX - 9) + this_comparison_is_true (); +} + +void bla4lt (int var) +{ + if (var - 10 < INT_MAX - 10) + this_comparison_is_not_decidable (); +} + +void bla1le (int var) +{ + if (var + 10 <= INT_MIN + 9) + this_comparison_is_false (); +} + +void bla2le (int var) +{ + if (var + 10 <= INT_MIN + 10) + this_comparison_is_not_decidable (); +} + +void bla3le (int var) +{ + if (var - 10 <= INT_MAX - 10) + this_comparison_is_true (); +} + +void bla4le (int var) +{ + if (var - 10 <= INT_MAX - 11) + this_comparison_is_not_decidable (); +} + +void bla1gt (int var) +{ + if (var + 10 > INT_MIN + 9) + this_comparison_is_true (); +} + +void bla2gt (int var) +{ + if (var + 10 > INT_MIN + 10) + this_comparison_is_not_decidable (); +} + +void bla3gt (int var) +{ + if (var - 10 > INT_MAX - 10) + this_comparison_is_false (); +} + +void bla4gt (int var) +{ + if (var - 10 > INT_MAX - 11) + this_comparison_is_not_decidable (); +} + +void bla1ge (int var) +{ + if (var + 10 >= INT_MIN + 10) + this_comparison_is_true (); +} + +void bla2ge (int var) +{ + if (var + 10 >= INT_MIN + 11) + this_comparison_is_not_decidable (); +} + +void bla3ge (int var) +{ + if (var - 11 >= INT_MAX - 10) + this_comparison_is_false (); +} + +void bla4ge (int var) +{ + if (var - 10 >= INT_MAX - 10) + this_comparison_is_not_decidable (); +} + +/* { dg-final { scan-tree-dump-times "this_comparison_is_false" 0 "cfg" } } */ +/* { dg-final { scan-tree-dump-times "this_comparison_is_true" 6 "cfg" } } */ +/* { dg-final { scan-tree-dump-times "this_comparison_is_not_decidable" 12 "cfg" } } */ +/* { dg-final { scan-tree-dump-times "if " 12 "cfg" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-compare-4.c b/SingleSource/Regression/C/gcc-dg/fold-compare-4.c new file mode 100644 index 0000000000..b7ccc303f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-compare-4.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int test1 (int a, int b) +{ + return a - b == a; +} +int test2 (int a, int b) +{ + return a + b == a; +} +int test3 (int a) +{ + return a + 5 == a; +} +int test4 (int a) +{ + return a - 5 == a; +} + +/* { dg-final { scan-tree-dump-times "b == 0" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 0" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-compare-5.c b/SingleSource/Regression/C/gcc-dg/fold-compare-5.c new file mode 100644 index 0000000000..7d9343ef78 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-compare-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int test1 (int a) +{ + return 2 - a == a; +} +int test2 (int a) +{ + return 1 - a == a; +} +int test3 (int a) +{ + return 1 - a != a; +} + +/* { dg-final { scan-tree-dump-times "return 2 - a == a" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "return 1" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-compare-6.c b/SingleSource/Regression/C/gcc-dg/fold-compare-6.c new file mode 100644 index 0000000000..0c4c657d94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-compare-6.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +char digs[] = "0123456789"; +int foo (void) +{ + int xlcbug = 1 / (&(digs + 5)[-2 + (_Bool) 1] == &digs[4] ? 1 : -1); + return xlcbug; +} + +/* { dg-final { scan-tree-dump "xlcbug = 1;" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-compare-7.c b/SingleSource/Regression/C/gcc-dg/fold-compare-7.c new file mode 100644 index 0000000000..8296751aff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-compare-7.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef float vecf __attribute__((vector_size(8*sizeof(float)))); + +long f(vecf *f1, vecf *f2){ + return ((*f1 == *f2) < 0)[2]; +} diff --git a/SingleSource/Regression/C/gcc-dg/fold-compare-8.c b/SingleSource/Regression/C/gcc-dg/fold-compare-8.c new file mode 100644 index 0000000000..45456f4038 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-compare-8.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int +foo (int x, int y) +{ + return x - y < 0; +} + +/* { dg-final { scan-tree-dump "x < y" "original" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-complex-1.c b/SingleSource/Regression/C/gcc-dg/fold-complex-1.c new file mode 100644 index 0000000000..cf07cef07e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-complex-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -fdump-tree-original" } */ + +_Complex float +foo (_Complex float x) +{ + return __real x + 1.0iF * __imag x; +} + +/* { dg-final { scan-tree-dump-times "COMPLEX_EXPR" 0 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-cond-1.c b/SingleSource/Regression/C/gcc-dg/fold-cond-1.c new file mode 100644 index 0000000000..18ddc357a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-cond-1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +_Bool test1(int a, int b) +{ + return a ? b : 0; +} + +_Bool test2(int c, int d) +{ + return c ? d : 1; +} + +_Bool test3(int e, int f) +{ + return e ? 0 : f; +} + +_Bool test4(int g, int h) +{ + return g ? 1 : h; +} + +/* { dg-final { scan-tree-dump-times "a != 0 \&\& b != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "c == 0 \\|\\| d != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e == 0 \&\& f != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "g == 0 \\? h != 0 : 1" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "g != 0 \\? 1 : h != 0" 0 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-cond-2.c b/SingleSource/Regression/C/gcc-dg/fold-cond-2.c new file mode 100644 index 0000000000..68ec75480a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-cond-2.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +min1 (signed char op1, signed char op2) +{ + return (op1 < 25) ? (int)op1 : 24; +} +int +min2 (signed char op1, signed char op2) +{ + return (op1 <= 24) ? (int)op1 : 25; +} +int +min3 (unsigned char op1, unsigned char op2) +{ + return (op1 < 25) ? (unsigned int)op1 : 24; +} +int +min4 (unsigned char op1, unsigned char op2) +{ + return (op1 <= 24) ? (unsigned int)op1 : 25; +} +int +max1 (signed char op1, signed char op2) +{ + return (op1 > 24) ? (int)op1 : 25; +} +int +max2 (signed char op1, signed char op2) +{ + return (op1 >= 25) ? (int)op1 : 24; +} +int +max3 (unsigned char op1, unsigned char op2) +{ + return (op1 > 24) ? (unsigned int)op1 : 25; +} +int +max4 (unsigned char op1, unsigned char op2) +{ + return (op1 >= 25) ? (unsigned int)op1 : 24; +} + +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 4 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-cond-3.c b/SingleSource/Regression/C/gcc-dg/fold-cond-3.c new file mode 100644 index 0000000000..fe0ba65eba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-cond-3.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +unsigned long f1 (int x) +{ + return x > 0 ? (unsigned long) x : 0; +} + +unsigned long f2 (int x, int y) +{ + return x > y ? (unsigned long) x : (unsigned long) y; +} + +unsigned long f3 (int x) +{ + return x < 0 ? (unsigned long) x : 0; +} + +unsigned long f4 (int x, int y) +{ + return x < y ? (unsigned long) x : (unsigned long) y; +} + +unsigned long f5 (unsigned int x, unsigned int y) +{ + return x > y ? (unsigned long) x : (unsigned long) y; +} + +unsigned long f6 (unsigned int x, unsigned int y) +{ + return x < y ? (unsigned long) x : (unsigned long) y; +} + +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "original"} } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "original"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-condcmpconv-1.c b/SingleSource/Regression/C/gcc-dg/fold-condcmpconv-1.c new file mode 100644 index 0000000000..321294f4b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-condcmpconv-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-ifcvt" } */ + +int foo (unsigned short a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned short)(x >= 255 ? 255 : x); + } return x; +} + +/* { dg-final { scan-tree-dump " = MIN_EXPR <" "ifcvt" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-condcmpconv-2.c b/SingleSource/Regression/C/gcc-dg/fold-condcmpconv-2.c new file mode 100644 index 0000000000..5d3ef4a1e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-condcmpconv-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-ifcvt" } */ + +int foo (short a[], int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (short)(x <= 0 ? 0 : x); + } return x; +} + + +/* { dg-final { scan-tree-dump " = MAX_EXPR <" "ifcvt" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-condneg-1.c b/SingleSource/Regression/C/gcc-dg/fold-condneg-1.c new file mode 100644 index 0000000000..c4edd7487e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-condneg-1.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int test_i0(int x) +{ + return x != 0 ? -x : 0; +} + +int test_i1(int x) +{ + return x != 1 ? -x : -1; +} + +int test_im1(int x) +{ + return x != -1 ? -x : 1; +} + +unsigned int test_u0(unsigned int x) +{ + return x != 0 ? -x : 0; +} + +unsigned int test_u1(unsigned int x) +{ + return x != 1 ? -x : ~0u; +} + +unsigned int test_um1(unsigned int x) +{ + return x != ~0u ? -x : 1; +} + +unsigned char test_uc0(unsigned char x) +{ + return x != 0 ? -x : 0; +} + +unsigned char test_uc1(unsigned char x) +{ + return x != 1 ? -x : 255; +} + +unsigned char test_uc127(unsigned char x) +{ + return x != 127 ? -x : 129; +} + +unsigned char test_uc128(unsigned char x) +{ + return x != 128 ? -x : 128; +} + +unsigned char test_uc255(unsigned char x) +{ + return x != 255 ? -x : 1; +} + +/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-condneg-2.c b/SingleSource/Regression/C/gcc-dg/fold-condneg-2.c new file mode 100644 index 0000000000..1af24636ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-condneg-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftrapv -fdump-tree-optimized" } */ + +#define INT_MIN (-__INT_MAX__ - 1) + +int test(int x) +{ + return x != INT_MIN ? -x : INT_MIN; +} + +/* { dg-final { scan-tree-dump "goto" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-condnot-1.c b/SingleSource/Regression/C/gcc-dg/fold-condnot-1.c new file mode 100644 index 0000000000..75d558c268 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-condnot-1.c @@ -0,0 +1,84 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int test_i0(int x) +{ + return x != 0 ? ~x : ~0; +} + +int test_i1(int x) +{ + return x != 1 ? ~x : -2; +} + +int test_im1(int x) +{ + return x != ~0 ? ~x : 0; +} + +unsigned int test_u0(unsigned int x) +{ + return x != 0 ? ~x : ~0; +} + +unsigned int test_u1(unsigned int x) +{ + return x != 1 ? ~x : ~1u; +} + +unsigned int test_um1(unsigned int x) +{ + return x != ~0u ? ~x : 0; +} + +signed char test_c0(signed char x) +{ + return x != 0 ? ~x : -1; +} + +signed char test_c1(signed char x) +{ + return x != 1 ? ~x : -2; +} + +signed char test_cm1(signed char x) +{ + return x != -1 ? ~x : 0; +} + +signed char test_cm128(signed char x) +{ + return x != -128 ? ~x : 127; +} + +signed char test_c127(signed char x) +{ + return x != 127 ? ~x : -128; +} + +unsigned char test_uc0(unsigned char x) +{ + return x != 0 ? ~x : 255; +} + +unsigned char test_uc1(unsigned char x) +{ + return x != 1 ? ~x : 254; +} + +unsigned char test_uc127(unsigned char x) +{ + return x != 127 ? ~x : 128; +} + +unsigned char test_uc128(unsigned char x) +{ + return x != 128 ? ~x : 127; +} + +unsigned char test_ucm1(unsigned char x) +{ + return x != 255 ? ~x : 0; +} + +/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-convlshift-1.c b/SingleSource/Regression/C/gcc-dg/fold-convlshift-1.c new file mode 100644 index 0000000000..b6f57f81e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-convlshift-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned int foo(unsigned int i) +{ + int t1 = i; + int t2 = t1 << 8; + return t2; +} + +int bar(int i) +{ + unsigned int t1 = i; + unsigned int t2 = t1 << 8; + return t2; +} + +/* { dg-final { scan-tree-dump-not "\\(int\\)" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "\\(unsigned int\\)" "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-convlshift-2.c b/SingleSource/Regression/C/gcc-dg/fold-convlshift-2.c new file mode 100644 index 0000000000..f21358c458 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-convlshift-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned int foo(unsigned char c) +{ + int t1 = c; + int t2 = t1 << 8; + return t2; +} + +int bar(unsigned char c) +{ + unsigned int t1 = c; + unsigned int t2 = t1 << 8; + return t2; +} + +/* { dg-final { scan-tree-dump-times "\\(int\\)" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\(unsigned int\\)" 1 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-convlshift-3.c b/SingleSource/Regression/C/gcc-dg/fold-convlshift-3.c new file mode 100644 index 0000000000..8d01191f19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-convlshift-3.c @@ -0,0 +1,8 @@ +/* PR middle-end/102029 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +int * +foo (const __PTRDIFF_TYPE__ l) +{ + return (int *) (l << 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/fold-convlshift-4.c b/SingleSource/Regression/C/gcc-dg/fold-convlshift-4.c new file mode 100644 index 0000000000..001627fc18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-convlshift-4.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +short foo(short x) +{ + return x << 5; +} + +/* { dg-final { scan-tree-dump-not "\\(int\\)" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "\\(short int\\)" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-convmaxconv-1.c b/SingleSource/Regression/C/gcc-dg/fold-convmaxconv-1.c new file mode 100644 index 0000000000..f8157e9257 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-convmaxconv-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +typedef int int32_t __attribute__((mode (__SI__))); +typedef unsigned uint32_t __attribute__((mode (__SI__))); + +int32_t foo (short a[], int32_t x) +{ + uint32_t i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (x <= 0 ? 0 : x); + } + return x; +} + +/* { dg-final { scan-tree-dump-not " = MAX_EXPR = 255 ? 255 : x); + } + return x; +} + +/* { dg-final { scan-tree-dump-not " = MIN_EXPR > 1; +} + +/* { dg-final { scan-tree-dump "{ 4, 6, 8, 10 }" "ccp1"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-cvect.c b/SingleSource/Regression/C/gcc-dg/fold-cvect.c new file mode 100644 index 0000000000..8687f8db2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-cvect.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +extern void abort (void); + +/* We should fold all reads from xconstant and eliminate it, removing + the reference to blah which cannot be resolved at link time. */ +extern int blah; + +typedef int v4si __attribute__((vector_size(16))); + +static const struct { + int *y; + const v4si x[2] __attribute__((aligned(32))); +} xconstant = { &blah, { { 0, 1, 2, 3 }, { 2, 3, 4, 5 } } }; + +int main() +{ + if (sizeof (int) != 4) + return 0; + if (*(int *)&xconstant.x[0][0] != 0) + abort (); + if (*(int *)&xconstant.x[0][1] != 1) + abort (); + if (*(int *)&xconstant.x[0][2] != 2) + abort (); + if (*(int *)&xconstant.x[0][3] != 3) + abort (); + if (*(int *)&xconstant.x[1][0] != 2) + abort (); + if (*(int *)&xconstant.x[1][1] != 3) + abort (); + if (*(int *)&xconstant.x[1][2] != 4) + abort (); + if (*(int *)&xconstant.x[1][3] != 5) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/fold-div-1.c b/SingleSource/Regression/C/gcc-dg/fold-div-1.c new file mode 100644 index 0000000000..73b7586116 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-div-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -funsafe-math-optimizations -fdump-tree-gimple" } */ + +float f(float x) +{ + return x/2 + x/3; +} + +float g(float x) +{ + return 2/x + 3/x; +} + +float h(float x) +{ + return x/2 - x/3; +} + +float i(float x) +{ + return 2/x - 3/x; +} + +/* f and h should be turned into multiplications, + the divisions in g and i should be grouped together. */ + +/* { dg-final { scan-tree-dump-times " \\* " 2 "gimple" } } */ +/* { dg-final { scan-tree-dump-times " / " 2 "gimple" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-div-2.c b/SingleSource/Regression/C/gcc-dg/fold-div-2.c new file mode 100644 index 0000000000..5432c81354 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-div-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-ffinite-math-only -fdump-tree-gimple" } */ + +double f(double x) +{ + return x / x; +} + +/* Division should be turned into 1.0. */ + +/* { dg-final { scan-tree-dump-not " / " "gimple" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-div-3.c b/SingleSource/Regression/C/gcc-dg/fold-div-3.c new file mode 100644 index 0000000000..4a6420e724 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-div-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +unsigned int +apply_frontend_param (unsigned int spi_bias) +{ + static const int ppm = 8000; + spi_bias /= 1000ULL + ppm/1000; + return spi_bias; +} + +/* Make sure we perform the division in the narrower type. */ + +/* { dg-final { scan-tree-dump "spi_bias = spi_bias / 1008;" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqand-1.c b/SingleSource/Regression/C/gcc-dg/fold-eqand-1.c new file mode 100644 index 0000000000..ab9dae0167 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqand-1.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/13827 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +unsigned foo (unsigned a, unsigned b) +{ + return (a & 0xff00) != (b & 0xff00); +} + +unsigned bar (unsigned c, unsigned d) +{ + return (c & 0xff00) == (d & 0xff00); +} + +/* { dg-final { scan-tree-dump-times "a \\^ b" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "c \\^ d" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqandnot-1.c b/SingleSource/Regression/C/gcc-dg/fold-eqandnot-1.c new file mode 100644 index 0000000000..972c20329a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqandnot-1.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ +int test1(int a) +{ + return !(a & 4); +} + +int test2(int b) +{ + return (b & 4) == 0; +} + +int test3(int c) +{ + return ((c & 4) ^ 4) != 0; +} + +int test4(int d) +{ + return ((d ^ 4) & 4) != 0; +} + +int test5(int e) +{ + return (~e & 4) != 0; +} + +/* { dg-final { scan-tree-dump-times "\\(a \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(b \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(c \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(d \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(e \& 4\\) == 0" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqandshift-1.c b/SingleSource/Regression/C/gcc-dg/fold-eqandshift-1.c new file mode 100644 index 0000000000..d2154c88aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqandshift-1.c @@ -0,0 +1,55 @@ +/* PR middle-end/21137 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ +extern void foo(); + +void test1(int a) +{ + if ((a >> 3) & 1) + foo (); +} + +void test2(int b) +{ + if ((b >> 3) & 4) + foo (); +} + +int test3(int c) +{ + return (c >> 3) & 1; +} + +int test4(int d) +{ + return (d >> 3) & 4; +} + +#if __INT_MAX__ == 32767 +#define INT_BITS 16 +#elif __INT_MAX__ == 2147483647 +#define INT_BITS 32 +#elif __INT_MAX__ == 9223372036854775807 +#define INT_BITS 64 +#else +#error Please add support for your target here. +#endif + +void test5(int e) +{ + if ((e >> (INT_BITS - 1)) & 64) + foo(); +} + +void test6(unsigned int f) +{ + if ((f >> (INT_BITS - 1)) & 64) + foo(); +} + +/* { dg-final { scan-tree-dump-times "\\(a \& 8\\) != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(b \& 32\\) != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "c >> 3 \& 1" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "d >> 3 \& 4" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e < 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "if \\(0\\)" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqandshift-2.c b/SingleSource/Regression/C/gcc-dg/fold-eqandshift-2.c new file mode 100644 index 0000000000..936b89f291 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqandshift-2.c @@ -0,0 +1,21 @@ +/* PR middle-end/14752 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +void bar (void); + +void foo (unsigned int a) +{ + if ((a >> 2) & 1) + bar (); +} + +void baz (unsigned int b) +{ + if ((~b >> 2) & 1) + bar (); +} + +/* { dg-final { scan-tree-dump-times "\\(a \& 4\\) != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(b \& 4\\) == 0" 1 "original" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqandshift-3.c b/SingleSource/Regression/C/gcc-dg/fold-eqandshift-3.c new file mode 100644 index 0000000000..50978b5b6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqandshift-3.c @@ -0,0 +1,28 @@ +/* PR middle-end/29726 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +void foo (void); +#if(__SIZEOF_INT__ >= 4) +int test1 (int a) +#else +int test1 (long a) +#endif + +{ + if ((a >> 3) & 134217728) + foo (); +} + +#if(__SIZEOF_INT__ >= 4) +int test2 (unsigned int b) +#else +int test2 (unsigned long b) +#endif +{ + if ((b >> 3) & 134217728) + foo (); +} + +/* { dg-final { scan-tree-dump-times "\\(a \& 1073741824\\) != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(b \& 1073741824\\) != 0" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqandshift-4.c b/SingleSource/Regression/C/gcc-dg/fold-eqandshift-4.c new file mode 100644 index 0000000000..fbba438556 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqandshift-4.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int sr30eq00(signed char x) { return ((x >> 4) & 0x30) == 0; } +int sr30ne00(signed char x) { return ((x >> 4) & 0x30) != 0; } +int sr30eq20(signed char z) { return ((z >> 4) & 0x30) == 0x20; } +int sr30ne20(signed char z) { return ((z >> 4) & 0x30) != 0x20; } +int sr30eq30(signed char x) { return ((x >> 4) & 0x30) == 0x30; } +int sr30ne30(signed char x) { return ((x >> 4) & 0x30) != 0x30; } +int sr33eq33(signed char x) { return ((x >> 4) & 0x33) == 0x33; } +int sr33ne33(signed char x) { return ((x >> 4) & 0x33) != 0x33; } + +int ur30eq00(unsigned char z) { return ((z >> 4) & 0x30) == 0; } +int ur30ne00(unsigned char z) { return ((z >> 4) & 0x30) != 0; } +int ur30eq30(unsigned char z) { return ((z >> 4) & 0x30) == 0x30; } +int ur30ne30(unsigned char z) { return ((z >> 4) & 0x30) != 0x30; } +int ur33eq03(unsigned char x) { return ((x >> 4) & 0x33) == 0x03; } +int ur33ne03(unsigned char x) { return ((x >> 4) & 0x33) != 0x03; } +int ur33eq30(unsigned char z) { return ((z >> 4) & 0x33) == 0x30; } +int ur33ne30(unsigned char z) { return ((z >> 4) & 0x33) != 0x30; } +int ur33eq33(unsigned char z) { return ((z >> 4) & 0x33) == 0x33; } +int ur33ne33(unsigned char z) { return ((z >> 4) & 0x33) != 0x33; } + +int sl30eq00(char x) { return ((char)(x << 4) & 0x30) == 0; } +int sl30ne00(char x) { return ((char)(x << 4) & 0x30) != 0; } +int sl30eq20(char x) { return ((char)(x << 4) & 0x30) == 0x20; } +int sl30ne20(char x) { return ((char)(x << 4) & 0x30) != 0x20; } +int sl30eq30(char x) { return ((char)(x << 4) & 0x30) == 0x30; } +int sl30ne30(char x) { return ((char)(x << 4) & 0x30) != 0x30; } +int sl33eq00(char x) { return ((char)(x << 4) & 0x33) == 0; } +int sl33ne00(char x) { return ((char)(x << 4) & 0x33) != 0; } +int sl33eq03(char z) { return ((char)(z << 4) & 0x33) == 0x03; } +int sl33ne03(char z) { return ((char)(z << 4) & 0x33) != 0x03; } +int sl33eq30(char x) { return ((char)(x << 4) & 0x33) == 0x30; } +int sl33ne30(char x) { return ((char)(x << 4) & 0x33) != 0x30; } +int sl33eq33(char z) { return ((char)(z << 4) & 0x33) == 0x33; } +int sl33ne33(char z) { return ((char)(z << 4) & 0x33) != 0x33; } + +/* { dg-final { scan-tree-dump-not " >> " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " << " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "z_\[0-9\]\\(D\\)" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return \[01\]" 14 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "char z\\)" 14 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "x_\[0-9\]\\(D\\)" 18 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "char x\\)" 18 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqbswap-1.c b/SingleSource/Regression/C/gcc-dg/fold-eqbswap-1.c new file mode 100644 index 0000000000..ed9820b0f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqbswap-1.c @@ -0,0 +1,113 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int test1(int x, int y) +{ +#if __SIZEOF_INT__ == 4 + return __builtin_bswap32(x) == __builtin_bswap32(y); +#else + return x == y; +#endif +} + +int test2(int x, int y) +{ +#if __SIZEOF_INT__ == 4 + return __builtin_bswap32(x) != __builtin_bswap32(y); +#else + return x != y; +#endif +} + +int test3(int x) +{ +#if __SIZEOF_INT__ == 4 + return __builtin_bswap32(x) == 12345; +#else + return x; +#endif +} + +int test4(int x) +{ +#if __SIZEOF_INT__ == 4 + return __builtin_bswap32(x) != 12345; +#else + return x; +#endif +} + +int test1ll(long long x, long long y) +{ +#if __SIZEOF_LONG_LONG__ == 8 + return __builtin_bswap64(x) == __builtin_bswap64(y); +#else + return x == y; +#endif +} + +int test2ll(long long x, long long y) +{ +#if __SIZEOF_LONG_LONG__ == 8 + return __builtin_bswap64(x) != __builtin_bswap64(y); +#else + return x != y; +#endif +} + +int test3ll(long long x) +{ +#if __SIZEOF_LONG_LONG__ == 8 + return __builtin_bswap64(x) == 12345; +#else + return (int)x; +#endif +} + +int test4ll(long long x) +{ +#if __SIZEOF_LONG_LONG__ == 8 + return __builtin_bswap64(x) != 12345; +#else + return (int)x; +#endif +} + +int test1s(short x, short y) +{ +#if __SIZEOF_SHORT__ == 2 + return __builtin_bswap16(x) == __builtin_bswap16(y); +#else + return x == y; +#endif +} + +int test2s(short x, short y) +{ +#if __SIZEOF_SHORT__ == 2 + return __builtin_bswap16(x) != __builtin_bswap16(y); +#else + return x != y; +#endif +} + +int test3s(short x) +{ +#if __SIZEOF_SHORT__ == 2 + return __builtin_bswap16(x) == 12345; +#else + return (int)x; +#endif +} + +int test4s(short x) +{ +#if __SIZEOF_SHORT__ == 2 + return __builtin_bswap16(x) != 12345; +#else + return (int)x; +#endif +} + +/* { dg-final { scan-tree-dump-times "__builtin_bswap" 0 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqcmplx-1.c b/SingleSource/Regression/C/gcc-dg/fold-eqcmplx-1.c new file mode 100644 index 0000000000..6c8e05f258 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqcmplx-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int foo(float x, float y) +{ + return (_Complex float)x == (_Complex float)y; +} + +/* { dg-final { scan-tree-dump-times "x == y" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqrotate-1.c b/SingleSource/Regression/C/gcc-dg/fold-eqrotate-1.c new file mode 100644 index 0000000000..7d2b63718c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqrotate-1.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int test1(unsigned int x, unsigned int y) +{ +#if __SIZEOF_INT__ == 4 + unsigned int r1 = (x << 16) | (x >> 16); + unsigned int r2 = (y << 16) | (y >> 16); + return r1 == r2; +#else + return x == y; +#endif +} + +int test2(unsigned int x) +{ +#if __SIZEOF_INT__ == 4 + unsigned int r1 = (x << 16) | (x >> 16); + return r1 == 12345; +#else + return x == 12345; +#endif +} + +int test3(unsigned int x) +{ +#if __SIZEOF_INT__ == 4 + unsigned int r1 = (x << 16) | (x >> 16); + return r1 == 0; +#else + return x == 0; +#endif +} + +int test4(unsigned int x) +{ +#if __SIZEOF_INT__ == 4 + unsigned int r1 = (x << 16) | (x >> 16); + return r1 == ~0; +#else + return x == ~0; +#endif +} + +/* { dg-final { scan-tree-dump-times "r>>" 0 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqxor-1.c b/SingleSource/Regression/C/gcc-dg/fold-eqxor-1.c new file mode 100644 index 0000000000..5ded86a1d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqxor-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return (a ^ b) == 0; +} + +int test2(int c, int d) +{ + return (c ^ d) != 0; +} + +unsigned int test3(unsigned int e, unsigned int f) +{ + return (e ^ f) == 0; +} + +unsigned int test4(unsigned int g, unsigned int h) +{ + return (g ^ h) != 0; +} + +/* { dg-final { scan-tree-dump-times "a == b" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "c != d" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e == f" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "g != h" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqxor-2.c b/SingleSource/Regression/C/gcc-dg/fold-eqxor-2.c new file mode 100644 index 0000000000..02eef39487 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqxor-2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return (a ^ b) == a; +} + +int test2(int c, int d) +{ + return (c ^ d) != c; +} + +int test3(int e, int f) +{ + return (e ^ f) == f; +} + +int test4(int g, int h) +{ + return (g ^ h) != h; +} + +/* { dg-final { scan-tree-dump-times "b == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "d != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "g != 0" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqxor-3.c b/SingleSource/Regression/C/gcc-dg/fold-eqxor-3.c new file mode 100644 index 0000000000..d9cfb80077 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqxor-3.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return (a ^ 2) == 2; +} + +int test2(int c, int d) +{ + return (c ^ 4) != 4; +} + +int test3(int e, int f) +{ + return (e ^ 2) == 6; +} + +int test4(int g, int h) +{ + return (g ^ 6) != 4; +} + +/* { dg-final { scan-tree-dump-times "a == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "c != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e == 4" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "g != 2" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-eqxor-4.c b/SingleSource/Regression/C/gcc-dg/fold-eqxor-4.c new file mode 100644 index 0000000000..7144fea04b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-eqxor-4.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a) +{ + return (a ^ 6) == 2; +} + +int test2(int b, int c, int d) +{ + return (b ^ d) == (c ^ d); +} + +int test3(int e, int f) +{ + return (e ^ 6) == (f ^ 4); +} + +/* { dg-final { scan-tree-dump-times "a == 4" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "b == c" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e \\^ 2" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-even-1.c b/SingleSource/Regression/C/gcc-dg/fold-even-1.c new file mode 100644 index 0000000000..94711ab149 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-even-1.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ +int test1(int a) +{ + return !(a & 1); +} + +int test2(int b) +{ + return (b & 1) == 0; +} + +int test3(int c) +{ + return (c & 1) ^ 1; +} + +int test4(int d) +{ + return (d ^ 1) & 1; +} + +int test5(int e) +{ + return ~e & 1; +} + +/* { dg-final { scan-tree-dump-times "\\(a \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(b \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(c \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(d \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(e \& 1\\) == 0" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-ior-1.c b/SingleSource/Regression/C/gcc-dg/fold-ior-1.c new file mode 100644 index 0000000000..0358eb5cf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-ior-1.c @@ -0,0 +1,69 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a & b; + int tem2 = a ^ b; + return tem1 | tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b & a; + int tem2 = a ^ b; + return tem1 | tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a & b; + int tem2 = b ^ a; + return tem1 | tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b & a; + int tem2 = b ^ a; + return tem1 | tem2; +} + +int +fn5 (int a, int b) +{ + int tem1 = a ^ b; + int tem2 = a & b; + return tem1 | tem2; +} + +int +fn6 (int a, int b) +{ + int tem1 = b ^ a; + int tem2 = a & b; + return tem1 | tem2; +} + +int +fn7 (int a, int b) +{ + int tem1 = a ^ b; + int tem2 = b & a; + return tem1 | tem2; +} + +int +fn8 (int a, int b) +{ + int tem1 = b ^ a; + int tem2 = b & a; + return tem1 | tem2; +} + +/* { dg-final { scan-tree-dump-not " & " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-ior-2.c b/SingleSource/Regression/C/gcc-dg/fold-ior-2.c new file mode 100644 index 0000000000..41b372d06f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-ior-2.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int x) +{ + return ~x | x; +} + +int +fn2 (int x) +{ + return x | ~x; +} + +unsigned int +fn3 (unsigned int x) +{ + return ~x | x; +} + +unsigned int +fn4 (unsigned int x) +{ + return x | ~x; +} + +int +fn5 (int x) +{ + return ~x | (unsigned) x; +} + +int +fn6 (int x) +{ + return (unsigned) ~x | x; +} + +int +fn7 (int x) +{ + return ~(unsigned) x | x; +} + +/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-ior-3.c b/SingleSource/Regression/C/gcc-dg/fold-ior-3.c new file mode 100644 index 0000000000..ed89ff9188 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-ior-3.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (_Bool a) +{ + return ((int) a) | ((int) ~a); +} + +int +fn2 (unsigned char a) +{ + return ((int) a) | ((int) ~a); +} + +int +fn3 (unsigned short a) +{ + return ((int) a) | ((int) ~a); +} + +int +fn4 (signed char a) +{ + return ((int) a) | ((int) ~a); +} + +int +fn5 (signed short a) +{ + return ((int) a) | ((int) ~a); +} + +/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-ior-4.c b/SingleSource/Regression/C/gcc-dg/fold-ior-4.c new file mode 100644 index 0000000000..8f7213eb6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-ior-4.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned int test_ior(unsigned char i) +{ + return i | (i<<8) | (i<<16) | (i<<24); +} + +unsigned int test_xor(unsigned char i) +{ + return i ^ (i<<8) ^ (i<<16) ^ (i<<24); +} + +unsigned int test_ior_1s(unsigned char i) +{ + return i | (i<<8); +} + +unsigned int test_ior_1u(unsigned char i) +{ + unsigned int t = i; + return t | (t<<8); +} + +unsigned int test_xor_1s(unsigned char i) +{ + return i ^ (i<<8); +} + +unsigned int test_xor_1u(unsigned char i) +{ + unsigned int t = i; + return t ^ (t<<8); +} + +unsigned int test_ior_2s(unsigned char i) +{ + return (i<<8) | (i<<16); +} + +unsigned int test_ior_2u(unsigned char i) +{ + unsigned int t = i; + return (t<<8) | (t<<16); +} + +unsigned int test_xor_2s(unsigned char i) +{ + return (i<<8) ^ (i<<16); +} + +unsigned int test_xor_2u(unsigned char i) +{ + unsigned int t = i; + return (t<<8) ^ (t<<16); +} + +/* { dg-final { scan-tree-dump-not " \\^ " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\* 16843009" 2 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-ior-5.c b/SingleSource/Regression/C/gcc-dg/fold-ior-5.c new file mode 100644 index 0000000000..8de56976da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-ior-5.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned int test_ior(unsigned char i) +{ + return (i | (i<<16)) | ((i<<24) | (i<<8)); +} + +unsigned int test_xor(unsigned char i) +{ + return (i ^ (i<<16)) ^ ((i<<24) ^ (i<<8)); +} + +/* { dg-final { scan-tree-dump-not " \\^ " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\* 16843009" 2 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-isfinite-1.c b/SingleSource/Regression/C/gcc-dg/fold-isfinite-1.c new file mode 100644 index 0000000000..2ea0192e86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-isfinite-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target inf } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(int x) +{ + return __builtin_finite((double)x); +} + +int foof(int x) +{ + return __builtin_finitef((float)x); +} + +int fool(int x) +{ + return __builtin_finitel((long double)x); +} + +/* { dg-final { scan-tree-dump-times "_finite" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " u> " 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-isfinite-2.c b/SingleSource/Regression/C/gcc-dg/fold-isfinite-2.c new file mode 100644 index 0000000000..ff70d8d3dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-isfinite-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target inf } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(unsigned int x) +{ + return __builtin_finite((double)x); +} + +int foof(unsigned int x) +{ + return __builtin_finitef((float)x); +} + +int fool(unsigned int x) +{ + return __builtin_finitel((long double)x); +} + +/* { dg-final { scan-tree-dump-times "_finite" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " u> " 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-isinf-1.c b/SingleSource/Regression/C/gcc-dg/fold-isinf-1.c new file mode 100644 index 0000000000..485816ef7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-isinf-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target inf } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(int x) +{ + return __builtin_isinf((double)x); +} + +int foof(int x) +{ + return __builtin_isinff((float)x); +} + +int fool(int x) +{ + return __builtin_isinfl((long double)x); +} + +/* { dg-final { scan-tree-dump-times "_isinf" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " u<= " 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-isinf-2.c b/SingleSource/Regression/C/gcc-dg/fold-isinf-2.c new file mode 100644 index 0000000000..a236ca1031 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-isinf-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target inf } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(unsigned int x) +{ + return __builtin_isinf((double)x); +} + +int foof(unsigned int x) +{ + return __builtin_isinff((float)x); +} + +int fool(unsigned int x) +{ + return __builtin_isinfl((long double)x); +} + +/* { dg-final { scan-tree-dump-times "_isinf" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " u<= " 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-isnan-1.c b/SingleSource/Regression/C/gcc-dg/fold-isnan-1.c new file mode 100644 index 0000000000..05ee930f93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-isnan-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target inf } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(int x) +{ + return __builtin_isnan((double)x); +} + +int foof(int x) +{ + return __builtin_isnanf((float)x); +} + +int fool(int x) +{ + return __builtin_isnanl((long double)x); +} + +/* { dg-final { scan-tree-dump-times "_isnan" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " unord " 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-isnan-2.c b/SingleSource/Regression/C/gcc-dg/fold-isnan-2.c new file mode 100644 index 0000000000..32b8833711 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-isnan-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target inf } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(unsigned int x) +{ + return __builtin_isnan((double)x); +} + +int foof(unsigned int x) +{ + return __builtin_isnanf((float)x); +} + +int fool(unsigned int x) +{ + return __builtin_isnanl((long double)x); +} + +/* { dg-final { scan-tree-dump-times "_isnan" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " unord " 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-minus-1.c b/SingleSource/Regression/C/gcc-dg/fold-minus-1.c new file mode 100644 index 0000000000..b3f096afc0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-minus-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-gimple" } */ + +typedef int vec __attribute__((vector_size(2*sizeof(int)))); + +void f(vec*x,vec*y){ + *x -= *x / *y * *y; +} +void g(vec*x,vec*y,vec*z){ + *x = -1 - *x; + *y = -*y - 1; + *z = -*z - 13; +} + +/* { dg-final { scan-tree-dump-times "%" 1 "gimple"} } */ +/* { dg-final { scan-tree-dump-times "~" 2 "gimple"} } */ +/* { dg-final { scan-tree-dump-not "/" "gimple"} } */ +/* { dg-final { scan-tree-dump-not "\\\+" "gimple"} } */ +/* { dg-final { scan-tree-dump "{ -13, -13 }" "gimple"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-minus-2.c b/SingleSource/Regression/C/gcc-dg/fold-minus-2.c new file mode 100644 index 0000000000..6501f2f926 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-minus-2.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a | b; + int tem2 = a ^ b; + return tem1 - tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b | a; + int tem2 = a ^ b; + return tem1 - tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a | b; + int tem2 = b ^ a; + return tem1 - tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b | a; + int tem2 = b ^ a; + return tem1 - tem2; +} + +/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-minus-3.c b/SingleSource/Regression/C/gcc-dg/fold-minus-3.c new file mode 100644 index 0000000000..e7adce6b2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-minus-3.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a | b; + int tem2 = a & b; + return tem1 - tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b | a; + int tem2 = a & b; + return tem1 - tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a | b; + int tem2 = b & a; + return tem1 - tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b | a; + int tem2 = b & a; + return tem1 - tem2; +} + +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " & " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-minus-4.c b/SingleSource/Regression/C/gcc-dg/fold-minus-4.c new file mode 100644 index 0000000000..2d76b4f60e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-minus-4.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a + b; + int tem2 = a & b; + return tem1 - tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b + a; + int tem2 = a & b; + return tem1 - tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a + b; + int tem2 = b & a; + return tem1 - tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b + a; + int tem2 = b & a; + return tem1 - tem2; +} + +/* { dg-final { scan-tree-dump-not " & " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\+ " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-minus-5.c b/SingleSource/Regression/C/gcc-dg/fold-minus-5.c new file mode 100644 index 0000000000..a31e1cc1e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-minus-5.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a + b; + int tem2 = a | b; + return tem1 - tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b + a; + int tem2 = a | b; + return tem1 - tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a + b; + int tem2 = b | a; + return tem1 - tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b + a; + int tem2 = b | a; + return tem1 - tem2; +} + +/* { dg-final { scan-tree-dump-not " \\+ " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-minus-6.c b/SingleSource/Regression/C/gcc-dg/fold-minus-6.c new file mode 100644 index 0000000000..153545266d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-minus-6.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int x) +{ + return 42L - (42 / x) * x; +} + +long +fn2 (int x) +{ + return 42L - (42 / x) * x; +} + +int +fn3 (long int x) +{ + return 42L - (42 / x) * x; +} + +int +fn4 (unsigned int a, int b) +{ + return a - (unsigned) ((a / b) * b); +} + +int +fn5 (int a, unsigned int b) +{ + return a - ((a / b) * b); +} + +unsigned int +fn6 (int a, int b) +{ + return a - ((a / b) * b); +} + +/* { dg-final { scan-tree-dump-not " / " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " - " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\+ " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-minus-7.c b/SingleSource/Regression/C/gcc-dg/fold-minus-7.c new file mode 100644 index 0000000000..7a49faa9ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-minus-7.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +f1 (int a, int b) +{ + int tem = a & b; + return a - tem; +} + +int +f2 (int a, int b) +{ + int tem = b & a; + return a - tem; +} + +int +f3 (unsigned int a, int b) +{ + return a - (a & b); +} + +int +f4 (int a, unsigned int b) +{ + return a - (a & b); +} + +int +f5 (int a, int b) +{ + return a - (unsigned) (b & a); +} + +/* { dg-final { scan-tree-dump-not " - " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-mod-1.c b/SingleSource/Regression/C/gcc-dg/fold-mod-1.c new file mode 100644 index 0000000000..4ceb90d4ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-mod-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-fdump-tree-gimple -fstrict-overflow" } */ + +#define ABS(x) (x > 0 ? x : -x) + +unsigned int f (unsigned int a) { + /* (unsigned)-8 is not a power of 2. */ + return a % -8; +} + +int g (int b) { + return ABS (b) % -8; +} + +int h (int c) { + return ABS (c) % 8; +} + +unsigned int k (unsigned int d) { + return d % 8; +} + +/* { dg-final { scan-tree-dump "a % (4294967288|0x0fffffff8)" "gimple" } } */ +/* { dg-final { scan-tree-dump-times " & 7" 3 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-modpow2-2.c b/SingleSource/Regression/C/gcc-dg/fold-modpow2-2.c new file mode 100644 index 0000000000..803d527547 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-modpow2-2.c @@ -0,0 +1,47 @@ +/* PR tree-optimization/99079 */ +/* { dg-do compile { target { lp64 || ilp32 } } } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned int +foo1 (unsigned int a, unsigned int b) +{ + return a % (1 << b); +} + +int +foo2 (int b) +{ + return 371 % (1U << b); +} + +long long +foo3 (int b) +{ + return 371LL % (1U << b); +} + +unsigned long long +foo4 (unsigned long long a, int b) +{ + return a % (1U << b); +} + +unsigned +foo5 (unsigned a, int b) +{ + return a % (unsigned) (1ULL << b); +} + +int +foo6 (int b) +{ + return 371 % (int) (1ULL << b); +} + +long long +foo7 (int b) +{ + return 371LL % (1 << b); +} + +/* { dg-final { scan-tree-dump-not " % " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-modpow2.c b/SingleSource/Regression/C/gcc-dg/fold-modpow2.c new file mode 100644 index 0000000000..4541b1ccf0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-modpow2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +unsigned int +my_mod (unsigned int a, unsigned int b) +{ + return a % (1 << b); +} + +/* The above should be simplified to (unsigned int) ((1 << b) + -1) & a */ +/* { dg-final { scan-tree-dump "& a;" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-mulconj-1.c b/SingleSource/Regression/C/gcc-dg/fold-mulconj-1.c new file mode 100644 index 0000000000..27b526f911 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-mulconj-1.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/23452 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-gimple" } */ + +_Complex double foo(_Complex double z) +{ + return z * ~z; +} + +_Complex int bar(_Complex int z) +{ + return z * ~z; +} + +/* { dg-final { scan-tree-dump-times "CONJ_EXPR" 0 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-narrowbopcst-1.c b/SingleSource/Regression/C/gcc-dg/fold-narrowbopcst-1.c new file mode 100644 index 0000000000..8a33677c27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-narrowbopcst-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +int foo1 (unsigned char a[], unsigned int x) +{ + unsigned int i; + for (i = 0; i < 1000; i++) + { + x = a[i]; + a[i] = (unsigned char)(x >= 100 ? x - 100 : 0); + } + return x; +} +/* { dg-final { scan-tree-dump " = _.* \\+ 156" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-negate-1.c b/SingleSource/Regression/C/gcc-dg/fold-negate-1.c new file mode 100644 index 0000000000..00ec8b4c0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-negate-1.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#define SHIFT ((8*__SIZEOF_INT__)-1) + +int test_rshift_1(int x) +{ + int t = x >> SHIFT; + return -t; +} + +int test_rshift_2(int x) +{ + unsigned int t = (unsigned int)x >> SHIFT; + return -t; +} + +int test_rshift_3(int x) +{ + int t = (unsigned int)x >> SHIFT; + return -t; +} + +int test_rshift_4(int x) +{ + unsigned int t = x >> SHIFT; + return -t; +} + +double test_mul_1(double x) +{ + double t = -5.0 * x; + return -t; +} + +double test_mul_2(double x, double y) +{ + double t1 = -x; + double t2 = t1 * y; + return -t2; +} + +double test_rdiv_1(double x, double y) +{ + double t1 = -x; + double t2 = t1 / y; + return -t2; +} + +double test_rdiv_2(double x, double y) +{ + double t1 = -y; + double t2 = x / t1; + return -t2; +} + +/* { dg-final { scan-tree-dump-not " -" "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-nonneg-1.c b/SingleSource/Regression/C/gcc-dg/fold-nonneg-1.c new file mode 100644 index 0000000000..03dae358b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-nonneg-1.c @@ -0,0 +1,10 @@ +/* PR middle-end/27488 */ +/* { dg-do compile } */ + +extern double fabs(double x); +extern double sinh(double x); + +void foo() +{ + fabs(sinh(0..)); /* { dg-error "decimal points" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/fold-notrotate-1.c b/SingleSource/Regression/C/gcc-dg/fold-notrotate-1.c new file mode 100644 index 0000000000..a9b38040f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-notrotate-1.c @@ -0,0 +1,54 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +#define INT_BITS (sizeof (int) * __CHAR_BIT__) +#define ROL(x, y) ((x) << (y) | (x) >> (INT_BITS - (y))) +#define ROR(x, y) ((x) >> (y) | (x) << (INT_BITS - (y))) + +unsigned +rol (unsigned a, unsigned b) +{ + return ~ROL (~a, b); +} + +unsigned int +ror (unsigned a, unsigned b) +{ + return ~ROR (~a, b); +} + +int +rol_conv1 (int a, unsigned b) +{ + return ~(int)ROL((unsigned)~a, b); +} + +int +rol_conv2 (int a, unsigned b) +{ + return ~ROL((unsigned)~a, b); +} + +int +rol_conv3 (unsigned a, unsigned b) +{ + return ~(int)ROL(~a, b); +} + +#define LONG_BITS (sizeof (long) * __CHAR_BIT__) +#define ROLL(x, y) ((x) << (y) | (x) >> (LONG_BITS - (y))) +#define RORL(x, y) ((x) >> (y) | (x) << (LONG_BITS - (y))) + +unsigned long +roll (unsigned long a, unsigned long b) +{ + return ~ROLL (~a, b); +} + +unsigned long +rorl (unsigned long a, unsigned long b) +{ + return ~RORL (~a, b); +} + +/* { dg-final { scan-tree-dump-not "~" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-notshift-1.c b/SingleSource/Regression/C/gcc-dg/fold-notshift-1.c new file mode 100644 index 0000000000..2de236fc4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-notshift-1.c @@ -0,0 +1,77 @@ +/* PR tree-optimization/54579 + PR middle-end/55299 */ + +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +asr1 (int a, int b) +{ + return ~((~a) >> b); +} + +long +asr1l (long a, long b) +{ + return ~((~a) >> b); +} + +int +asr_conv (unsigned a, unsigned b) +{ + return ~((int)~a >> b); +} + +unsigned +asr_conv2 (unsigned a, unsigned b) +{ + return ~(unsigned)((int)~a >> b); +} + +unsigned +asr_conv3 (int a, int b) +{ + return ~(unsigned)(~a >> b); +} + +typedef __INT32_TYPE__ int32_t; +typedef __INT64_TYPE__ int64_t; + +int32_t +asr_conv4 (int64_t a, int b) +{ + return ~((int32_t)~a >> b); +} + +int32_t +asr_conv5 (int64_t a, int b) +{ + return ~(int32_t)(~a >> b); +} + +int +asr2 (int a, int b) +{ + return -((-a - 1) >> b) - 1; +} + +int +asr3 (int a, int b) +{ + return a < 0 ? ~((~a) >> b) : a >> b; +} + +int64_t +asr3l (int64_t a, int b) +{ + return a < 0 ? ~((~a) >> b) : a >> b; +} + +int +asr4 (int a, int b) +{ + return a < 0 ? -((-a - 1) >> b) - 1 : a >> b; +} + +/* { dg-final { scan-tree-dump-times ">>" 11 "cddce1" } } */ +/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-notshift-2.c b/SingleSource/Regression/C/gcc-dg/fold-notshift-2.c new file mode 100644 index 0000000000..f8aab2a005 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-notshift-2.c @@ -0,0 +1,33 @@ +/* PR middle-end/55299 */ + +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +unsigned int +lsr (unsigned int a, unsigned int b) +{ + return ~((~a) >> b); +} + +int +sl (int a, int b) +{ + return ~((~a) << b); +} + +typedef unsigned __INT32_TYPE__ uint32_t; +typedef __INT64_TYPE__ int64_t; + +int64_t +asr_widen1 (uint32_t a, int b) +{ + return ~((int64_t)(~a) >> b); +} + +int64_t +asr_widen2 (uint32_t a, int b) +{ + return ~(int64_t)(~a >> b); +} + +/* { dg-final { scan-tree-dump-times "~" 8 "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-notunord.c b/SingleSource/Regression/C/gcc-dg/fold-notunord.c new file mode 100644 index 0000000000..ca345154ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-notunord.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftrapping-math -fdump-tree-optimized" } */ + +int f (double d) +{ + return !__builtin_isnan (d); +} + +/* { dg-final { scan-tree-dump " ord " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-overflow-1.c b/SingleSource/Regression/C/gcc-dg/fold-overflow-1.c new file mode 100644 index 0000000000..108df4e315 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-overflow-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-O -ftrapping-math" } */ + +/* There should be exactly 2 +Inf in the assembly file. */ + +float f1 = __FLT_MAX__ + __FLT_MAX__; + +float foo1(void) +{ + return __FLT_MAX__ + __FLT_MAX__; +} + +float f2 = 1.0f/0.0f; + +float foo2(void) +{ + return 1.0f/0.0f; +} + +/* { dg-final { scan-assembler-times "2139095040" 2 { target { ! mmix-*-* } } } } */ +/* { dg-final { scan-assembler-times "#7f800000" 2 { target mmix-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-parity-1.c b/SingleSource/Regression/C/gcc-dg/fold-parity-1.c new file mode 100644 index 0000000000..3ba56c7fcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-parity-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int foo(unsigned int x) +{ + return __builtin_popcount(x) & 1; +} + +int fool(unsigned long x) +{ + return __builtin_popcountl(x) & 1; +} + +int fooll(unsigned long long x) +{ + return __builtin_popcountll(x) & 1; +} + +/* { dg-final { scan-tree-dump-times "__builtin_popcount" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_parity" 3 "original" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-parity-2.c b/SingleSource/Regression/C/gcc-dg/fold-parity-2.c new file mode 100644 index 0000000000..8c7acbfd15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-parity-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(unsigned int x) +{ + return __builtin_parity(~x); +} + +int fool(unsigned long x) +{ + return __builtin_parityl(~x); +} + +int fooll(unsigned long long x) +{ + return __builtin_parityll(~x); +} + +/* { dg-final { scan-tree-dump-times "~" 0 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-parity-3.c b/SingleSource/Regression/C/gcc-dg/fold-parity-3.c new file mode 100644 index 0000000000..e0355cca4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-parity-3.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(unsigned int x) +{ + return __builtin_parity(x&1); +} + +int fool(unsigned long x) +{ + return __builtin_parityl(x&1); +} + +int fooll(unsigned long long x) +{ + return __builtin_parityll(x&1); +} + +/* { dg-final { scan-tree-dump-times "__builtin_parity" 0 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-parity-4.c b/SingleSource/Regression/C/gcc-dg/fold-parity-4.c new file mode 100644 index 0000000000..5dfedab918 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-parity-4.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(unsigned int x, unsigned int y) +{ + return __builtin_parity(x) ^ __builtin_parity(y); +} + +int fool(unsigned long x, unsigned long y) +{ + return __builtin_parityl(x) ^ __builtin_parityl(y); +} + +int fooll(unsigned long long x, unsigned long long y) +{ + return __builtin_parityll(x) ^ __builtin_parityll(y); +} + +/* { dg-final { scan-tree-dump-times "__builtin_parity" 3 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-parity-5.c b/SingleSource/Regression/C/gcc-dg/fold-parity-5.c new file mode 100644 index 0000000000..69d3a6a54c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-parity-5.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int test_and4(unsigned int a) +{ + return __builtin_parity(a&4); +} + +int test_and4l(unsigned long b) +{ + return __builtin_parityl(b&4); +} + +int test_and4ll(unsigned long long c) +{ + return __builtin_parityll(c&4); +} + +int test_shift(unsigned int d) +{ + int bits = 8*sizeof(unsigned int)-1; + return __builtin_parity(d<<31); +} + +int test_shiftl(unsigned long e) +{ + int bits = 8*sizeof(unsigned long)-1; + return __builtin_parityl(e<>4) | (x<<28); + return __builtin_parity(y); +#elif __SIZEOF_INT__ == 2 + unsigned int y = (x>>4) | (x<<12); + return __builtin_parity(y); +#else + return x; +#endif +} + +int bar(unsigned long x) +{ +#if __SIZEOF_LONG__ == 8 + unsigned long y = (x>>4) | (x<<60); + return __builtin_parityl (y); +#elif __SIZEOF_LONG__ == 4 + unsigned long y = (x>>4) | (x<<28); + return __builtin_parityl (y); +#else + return x; +#endif +} + +int baz(unsigned long long x) +{ +#if __SIZEOF_LONG_LONG__ == 8 + unsigned long long y = (x>>4) | (x<<60); + return __builtin_parityll (y); +#elif __SIZEOF_LONG_LONG__ == 4 + unsigned long long y = (x>>4) | (x<<28); + return __builtin_parityll (y); +#else + return x; +#endif +} + +/* { dg-final { scan-tree-dump-not " r>> " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-parity-8.c b/SingleSource/Regression/C/gcc-dg/fold-parity-8.c new file mode 100644 index 0000000000..48e1f7f2b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-parity-8.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(unsigned short x) +{ + unsigned short t1 = __builtin_bswap16(x); + unsigned int t2 = t1; + return __builtin_parity (t2); +} + +int fool(unsigned short x) +{ + unsigned short t1 = __builtin_bswap16(x); + unsigned long t2 = t1; + return __builtin_parityl (t2); +} + +int fooll(unsigned short x) +{ + unsigned short t1 = __builtin_bswap16(x); + unsigned long long t2 = t1; + return __builtin_parityll (t2); +} + +/* { dg-final { scan-tree-dump-not "bswap" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-perm.c b/SingleSource/Regression/C/gcc-dg/fold-perm.c new file mode 100644 index 0000000000..0fa050eb29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-perm.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre1" } */ + +typedef int veci __attribute__ ((vector_size (4 * sizeof (int)))); + +void fun (veci *f, veci *g, veci *h, veci *i) +{ + veci m = { 7, 7, 4, 6 }; + veci n = { 0, 1, 2, 3 }; + veci p = { 1, 1, 7, 6 }; + *i = __builtin_shuffle (*i, p, m); + *h = __builtin_shuffle (*h, *h, p); + *g = __builtin_shuffle (*f, *g, m); + *f = __builtin_shuffle (*f, *g, n); +} + +/* { dg-final { scan-tree-dump "VEC_PERM_EXPR.*{ 3, 3, 0, 2 }" "fre1" } } */ +/* { dg-final { scan-tree-dump "VEC_PERM_EXPR.*{ 1, 1, 3, 2 }" "fre1" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 2 "fre1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-plus-1.c b/SingleSource/Regression/C/gcc-dg/fold-plus-1.c new file mode 100644 index 0000000000..40d6aa251d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-plus-1.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a & b; + int tem2 = a ^ b; + return tem1 + tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b & a; + int tem2 = a ^ b; + return tem1 + tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a & b; + int tem2 = b ^ a; + return tem1 + tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b & a; + int tem2 = b ^ a; + return tem1 + tem2; +} + +int +fn5 (int a, int b) +{ + int tem1 = a ^ b; + int tem2 = a & b; + return tem1 + tem2; +} + +int +fn6 (int a, int b) +{ + int tem1 = b ^ a; + int tem2 = a & b; + return tem1 + tem2; +} + +int +fn7 (int a, int b) +{ + int tem1 = a ^ b; + int tem2 = b & a; + return tem1 + tem2; +} + +int +fn8 (int a, int b) +{ + int tem1 = b ^ a; + int tem2 = b & a; + return tem1 + tem2; +} + +/* { dg-final { scan-tree-dump-not " & " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\+ " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-plus-2.c b/SingleSource/Regression/C/gcc-dg/fold-plus-2.c new file mode 100644 index 0000000000..713abf6246 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-plus-2.c @@ -0,0 +1,69 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a & b; + int tem2 = a | b; + return tem1 + tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b & a; + int tem2 = a | b; + return tem1 + tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a & b; + int tem2 = b | a; + return tem1 + tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b & a; + int tem2 = b | a; + return tem1 + tem2; +} + +int +fn5 (int a, int b) +{ + int tem1 = a | b; + int tem2 = a & b; + return tem1 + tem2; +} + +int +fn6 (int a, int b) +{ + int tem1 = b | a; + int tem2 = a & b; + return tem1 + tem2; +} + +int +fn7 (int a, int b) +{ + int tem1 = a | b; + int tem2 = b & a; + return tem1 + tem2; +} + +int +fn8 (int a, int b) +{ + int tem1 = b | a; + int tem2 = b & a; + return tem1 + tem2; +} + +/* { dg-final { scan-tree-dump-not " & " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-plusmult-2.c b/SingleSource/Regression/C/gcc-dg/fold-plusmult-2.c new file mode 100644 index 0000000000..82f9898ba8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-plusmult-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int foo (int i) +{ + return 2 + i * 4; +} + +/* We do _not_ want the above to be canonicalized to (i * 2 + 1) * 2. */ + +int bar (int i) +{ + return 4 + i * 2; +} + +/* But eventually this to be canonicalized to (i + 2) * 2. */ + +/* { dg-final { scan-tree-dump "i \\\* 4 \\\+ 2" "original" } } */ +/* { dg-final { scan-tree-dump "\\\(i \\\+ 2\\\) \\\* 2" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-plusmult.c b/SingleSource/Regression/C/gcc-dg/fold-plusmult.c new file mode 100644 index 0000000000..cd28fa6751 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-plusmult.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int test1 (int a) +{ + return 2*a + 2*a; +} + +int test2 (int a) +{ + return (a + a)*2; +} + +/* { dg-final { scan-tree-dump-times "a \\\* 4" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-plusnot-1.c b/SingleSource/Regression/C/gcc-dg/fold-plusnot-1.c new file mode 100644 index 0000000000..3fc22363b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-plusnot-1.c @@ -0,0 +1,29 @@ +/* PR middle-end/30322 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a) +{ + return a + ~a; +} + +int test2(int b) +{ + return ~b + b; +} + +unsigned int test3(unsigned int c) +{ + return c + ~c; +} + +unsigned int test4(unsigned int d) +{ + return ~d + d; +} + +/* { dg-final { scan-tree-dump-times "\\+ a" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\+ b" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\+ c" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\+ d" 0 "original" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-1.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-1.c new file mode 100644 index 0000000000..32bb7e2a32 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-1.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test_eqzero(unsigned int a) +{ + return __builtin_popcount(a) == 0; +} + +int test_eqzerol(unsigned long b) +{ + return __builtin_popcountl(b) == 0; +} + +int test_eqzeroll(unsigned long long c) +{ + return __builtin_popcountll(c) == 0; +} + +int test_nezero(unsigned int d) +{ + return __builtin_popcount(d) != 0; +} + +int test_nezerol(unsigned long e) +{ + return __builtin_popcountl(e) != 0; +} + +int test_nezeroll(unsigned long long f) +{ + return __builtin_popcountll(f) != 0; +} + +/* { dg-final { scan-tree-dump-times "popcount" 0 "original" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-10.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-10.c new file mode 100644 index 0000000000..fa8a52a54e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-10.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#define popc __builtin_popcount + +int foo1(unsigned int x, unsigned int y) +{ + return popc (x) + popc (y) - popc (x|y); +} + +int foo2(unsigned int x, unsigned int y) +{ + return popc (y) + popc (x) - popc (x|y); +} + +int foo3(unsigned int x, unsigned int y) +{ + return (popc (x) - popc (x|y)) + popc (y); +} + +int foo4(unsigned int x, unsigned int y) +{ + return (popc (y) - popc (x|y)) + popc (x); +} + +/* { dg-final { scan-tree-dump-not " \\| " "optimized" } } */ +/* { dg-final { scan-tree-dump-times " & " 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "popcount " 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-11.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-11.c new file mode 100644 index 0000000000..e59be003ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-11.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(unsigned short x) +{ + unsigned short t1 = __builtin_bswap16(x); + unsigned int t2 = t1; + return __builtin_popcount (t2); +} + +int fool(unsigned short x) +{ + unsigned short t1 = __builtin_bswap16(x); + unsigned long t2 = t1; + return __builtin_popcountl (t2); +} + +int fooll(unsigned short x) +{ + unsigned short t1 = __builtin_bswap16(x); + unsigned long long t2 = t1; + return __builtin_popcountll (t2); +} + +/* { dg-final { scan-tree-dump-not "bswap" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-2.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-2.c new file mode 100644 index 0000000000..27557da7cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-2.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cddce1" } */ + +int test_andone(unsigned int a) +{ + return __builtin_popcount(a&1); +} + +int test_andonel(unsigned long b) +{ + return __builtin_popcountl(b&1); +} + +int test_andonell(unsigned long long c) +{ + return __builtin_popcountll(c&1); +} + +int test_oneand(unsigned int d) +{ + return __builtin_popcount(1&d); +} + +int test_oneandl(unsigned long e) +{ + return __builtin_popcountl(1&e); +} + +int test_oneandll(unsigned long long f) +{ + return __builtin_popcountll(1&f); +} + +/* { dg-final { scan-tree-dump-times "popcount" 0 "cddce1" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-3.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-3.c new file mode 100644 index 0000000000..eda007796b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-3.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cddce1" } */ + +int test_combine(unsigned int a, unsigned int b) +{ + return __builtin_popcount(a&8) + __builtin_popcount(b&2); +} + +/* { dg-final { scan-tree-dump-times "popcount" 1 "cddce1" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-4.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-4.c new file mode 100644 index 0000000000..424c3d8669 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-4.c @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cddce1" } */ + +int test_shiftmax(unsigned int a) +{ + return __builtin_popcount(a>>(8*sizeof(a)-1)); +} + +int test_shiftmaxl(unsigned long b) +{ + return __builtin_popcountl(b>>(8*sizeof(b)-1)); +} + +int test_shiftmaxll(unsigned long long c) +{ + return __builtin_popcountll(c>>(8*sizeof(c)-1)); +} + +int test_shift7(unsigned char d) +{ + return __builtin_popcount(d>>7); +} + +int test_shift7l(unsigned char e) +{ + return __builtin_popcountl(e>>7); +} + +int test_shift7ll(unsigned char f) +{ + return __builtin_popcountll(f>>7); +} + +int test_shift15(unsigned short g) +{ + return __builtin_popcount(g>>15); +} + +int test_shift15l(unsigned short h) +{ + return __builtin_popcountl(h>>15); +} + +int test_shift15ll(unsigned short i) +{ + return __builtin_popcountll(i>>15); +} + +/* { dg-final { scan-tree-dump-times "popcount" 0 "cddce1" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-5.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-5.c new file mode 100644 index 0000000000..943726f090 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-5.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int test_and4(unsigned int a) +{ + return __builtin_popcount(a&4); +} + +int test_and4l(unsigned long b) +{ + return __builtin_popcountl(b&4); +} + +int test_and4ll(unsigned long long c) +{ + return __builtin_popcountll(c&4); +} + +int test_shift(unsigned int d) +{ + int bits = 8*sizeof(unsigned int)-1; + return __builtin_popcount(d<<31); +} + +int test_shiftl(unsigned long e) +{ + int bits = 8*sizeof(unsigned long)-1; + return __builtin_popcountl(e<>4) | (x<<28); + return __builtin_popcount(y); +#elif __SIZEOF_INT__ == 2 + unsigned int y = (x>>4) | (x<<12); + return __builtin_popcount(y); +#else + return x; +#endif +} + +int bar(unsigned long x) +{ +#if __SIZEOF_LONG__ == 8 + unsigned long y = (x>>4) | (x<<60); + return __builtin_popcountl (y); +#elif __SIZEOF_LONG__ == 4 + unsigned long y = (x>>4) | (x<<28); + return __builtin_popcountl (y); +#else + return x; +#endif +} + +int baz(unsigned long long x) +{ +#if __SIZEOF_LONG_LONG__ == 8 + unsigned long long y = (x>>4) | (x<<60); + return __builtin_popcountll (y); +#elif __SIZEOF_LONG_LONG__ == 4 + unsigned long long y = (x>>4) | (x<<28); + return __builtin_popcountll (y); +#else + return x; +#endif +} + +/* { dg-final { scan-tree-dump-not " r>> " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-8.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-8.c new file mode 100644 index 0000000000..9599a3c80b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-8.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo1(unsigned int x, unsigned int y) +{ + return __builtin_popcount (x&y) + __builtin_popcount (x|y); +} + +int foo2(unsigned int x, unsigned int y) +{ + return __builtin_popcount (x&y) + __builtin_popcount (y|x); +} + +int foo3(unsigned int x, unsigned int y) +{ + return __builtin_popcount (x|y) + __builtin_popcount (x&y); +} + +int foo4(unsigned int x, unsigned int y) +{ + return __builtin_popcount (x|y) + __builtin_popcount (y&x); +} + +/* { dg-final { scan-tree-dump-not " & " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-popcount-9.c b/SingleSource/Regression/C/gcc-dg/fold-popcount-9.c new file mode 100644 index 0000000000..a9ffa62a07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-popcount-9.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#define popc __builtin_popcount + +int foo1(unsigned int x, unsigned int y) +{ + return popc (x) + popc (y) - popc (x&y); +} + +int foo2(unsigned int x, unsigned int y) +{ + return popc (y) + popc (x) - popc (x&y); +} + +int foo3(unsigned int x, unsigned int y) +{ + return (popc (x) - popc (x&y)) + popc (y); +} + +int foo4(unsigned int x, unsigned int y) +{ + return (popc (y) - popc (x&y)) + popc (x); +} + +/* { dg-final { scan-tree-dump-not " & " "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\| " 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "popcount " 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-reassoc-1.c b/SingleSource/Regression/C/gcc-dg/fold-reassoc-1.c new file mode 100644 index 0000000000..46ef07118a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-reassoc-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -fdump-tree-original" } */ + +double foo (double x) +{ + return (x + 0.5 - x - 0.5); +} + +/* { dg-final { scan-tree-dump "return 0.0;" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-reassoc-2.c b/SingleSource/Regression/C/gcc-dg/fold-reassoc-2.c new file mode 100644 index 0000000000..a334ec6122 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-reassoc-2.c @@ -0,0 +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-times "return 1;" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-reassoc-3.c b/SingleSource/Regression/C/gcc-dg/fold-reassoc-3.c new file mode 100644 index 0000000000..174b35bab1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-reassoc-3.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int i; +int *p = &i; +static __PTRDIFF_TYPE__ d = p - (p + 1); + +void +foo (void) +{ + int *q = &i; + static __PTRDIFF_TYPE__ e = q - (q + 1); +} + +/* { dg-final { scan-tree-dump-not " - " "original" } } */ +/* { dg-final { scan-tree-dump-not " \\+ " "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-reduc-1.c b/SingleSource/Regression/C/gcc-dg/fold-reduc-1.c new file mode 100644 index 0000000000..c8360b0fc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-reduc-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-optimized" } */ +float foo (float x) +{ + int i; + float j; + float a = 0; + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 4; ++j) + { + a += 1; + x += a; + } + } + return x; +} + +/* { dg-final { scan-tree-dump-not "REDUC_PLUS" "optimized"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-rotate-1.c b/SingleSource/Regression/C/gcc-dg/fold-rotate-1.c new file mode 100644 index 0000000000..19384f64d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-rotate-1.c @@ -0,0 +1,73 @@ +/* PR middle-end/29749 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +#if __SCHAR_MAX__ == 127 + +unsigned char +e1 (unsigned char a) +{ + return a >> 5 | a << 3; +} + +unsigned char +e2 (unsigned char a) +{ + return (a & 0xe0) >> 5 | (a & 0x1f) << 3; +} + +unsigned char +e3 (unsigned char a) +{ + return ((a >> 5) & 0x07) | ((a << 3) & 0xf8); +} + +#endif + +#if __SHRT_MAX__ == 32767 + +unsigned short +f1 (unsigned short a) +{ + return a >> 8 | a << 8; +} + +unsigned short +f2 (unsigned short a) +{ + return (a & 0xff00) >> 8 | (a & 0x00ff) << 8; +} + +unsigned short +f3 (unsigned short a) +{ + return ((a >> 8) & 0x00ff) | ((a << 8) & 0xff00); +} + +#endif + +#if __INT_MAX__ == 2147483647 + +unsigned int +g1 (unsigned int a) +{ + return a >> 24 | a << 8; +} + +unsigned int +g2 (unsigned int a) +{ + return (a & 0xff000000) >> 24 | (a & 0x00ffffff) << 8; +} + +unsigned int +g3 (unsigned int a) +{ + return ((a >> 24) & 0x000000ff) | ((a << 8) & 0xffffff00U); +} + +#endif + +int i; + +/* { dg-final { scan-tree-dump-times "&" 0 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-stringops-1.c b/SingleSource/Regression/C/gcc-dg/fold-stringops-1.c new file mode 100644 index 0000000000..e26632afd4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-stringops-1.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-lower-details" } */ + +char dst[2048]; + +char * +copy1 (const char *src, int cond) +{ + __builtin___stpncpy_chk (dst, src, 42, __builtin_object_size (dst, 0)); + + return dst; +} + +char * +copy2 (void) +{ + __builtin___stpcpy_chk (dst, "Hello world", __builtin_object_size (dst, 0)); + + return dst; +} +/* { dg-final { scan-tree-dump "simplified __builtin___stpncpy_chk to __builtin_strncpy" "lower" } } */ +/* { dg-final { scan-tree-dump "simplified __builtin___stpcpy_chk to __builtin_strcpy" "lower" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-stringops-2.c b/SingleSource/Regression/C/gcc-dg/fold-stringops-2.c new file mode 100644 index 0000000000..ac7d29eac5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-stringops-2.c @@ -0,0 +1,63 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; + +#define bos(__d) __builtin_object_size ((__d), 0) + +char * +safe1 (const char *src, int cond, size_t len) +{ + char *dst; + + if (cond) + dst = __builtin_malloc (1024); + else + dst = __builtin_malloc (2048); + + len = len > 2048 ? 2048 : len; + + return __builtin___memcpy_chk (dst, src, len, bos (dst)); +} + +char * +safe2 (const char *src, int cond, unsigned char len) +{ + char *dst; + + if (cond) + dst = __builtin_malloc (1024); + else + dst = __builtin_malloc (2048); + + return __builtin___strncpy_chk (dst, src, len, bos (dst)); +} + +int +safe3 (const char *src, int cond, unsigned char len) +{ + char *dst; + + if (cond) + dst = __builtin_malloc (1024); + else + dst = __builtin_malloc (2048); + + return __builtin___snprintf_chk (dst, len, 0, bos (dst), "%s", src); +} + +char dst[1024]; + +void +safe4 (size_t len) +{ + len = len > sizeof (dst) - 1 ? sizeof (dst) - 1 : len; + len = len < sizeof (dst) / 2 ? sizeof (dst) / 2 : len; + + __builtin_strncat (dst, "hello", len); +} + +/* { dg-final { scan-assembler-not "__memcpy_chk" } } */ +/* { dg-final { scan-assembler-not "__strncpy_chk" } } */ +/* { dg-final { scan-assembler-not "__snprintf_chk" } } */ +/* { dg-final { scan-assembler-not "strncat" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-stringops-3.c b/SingleSource/Regression/C/gcc-dg/fold-stringops-3.c new file mode 100644 index 0000000000..ae2efbf996 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-stringops-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; + +char dst[1024]; + +void +safe1 (size_t len) +{ + len = len > sizeof (dst) ? sizeof (dst) : len; + len = len < sizeof (dst) / 2 ? sizeof (dst) / 2 : len; + + __builtin_snprintf (dst, len, "hello"); + __builtin_snprintf (dst + 5, len, "%s", " world"); +} + +/* { dg-final { scan-assembler-not "snprintf" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-sub.c b/SingleSource/Regression/C/gcc-dg/fold-sub.c new file mode 100644 index 0000000000..f47f124df6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-sub.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-ffinite-math-only -fdump-tree-gimple" } */ + +float f(float x) +{ + return x - x; +} + +/* Substraction should be turned into 0. */ + +/* { dg-final { scan-tree-dump-not " - " "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-xor-1.c b/SingleSource/Regression/C/gcc-dg/fold-xor-1.c new file mode 100644 index 0000000000..a7d05524cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-xor-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +int f (int a, int b) { + return ~a ^ ~b; +} + +unsigned int g (unsigned int a, unsigned int b) { + return ~a ^ ~b; +} +/* { dg-final { scan-tree-dump-times "a \\^ b" 2 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-xor-2.c b/SingleSource/Regression/C/gcc-dg/fold-xor-2.c new file mode 100644 index 0000000000..64a4e42e70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-xor-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ +int f (int a, int b) { + return ~(a ^ -(b + 1)); +} + +int g (int a, int b) { + return b ^ a; +} + +unsigned int h (unsigned int a, unsigned int b) { + return ~(-(b + 1) ^ a); +} + +/* { dg-final { scan-tree-dump-times "b \\^ a" 3 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-xor-3.c b/SingleSource/Regression/C/gcc-dg/fold-xor-3.c new file mode 100644 index 0000000000..c2c0af66ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-xor-3.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (signed int x, signed int y) +{ + signed int tem1 = x & y; + signed int tem2 = x | y; + return tem1 ^ tem2; +} + +unsigned int +fn2 (unsigned int x, unsigned int y) +{ + unsigned int tem1 = x & y; + unsigned int tem2 = x | y; + return tem1 ^ tem2; +} + +int +fn3 (signed int x, signed int y) +{ + signed int tem1 = x & y; + signed int tem2 = x | y; + return tem2 ^ tem1; +} + +unsigned int +fn4 (unsigned int x, unsigned int y) +{ + unsigned int tem1 = x & y; + unsigned int tem2 = x | y; + return tem2 ^ tem1; +} + +/* { dg-final { scan-tree-dump-not " & " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-xor-4.c b/SingleSource/Regression/C/gcc-dg/fold-xor-4.c new file mode 100644 index 0000000000..b5a2c48b66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-xor-4.c @@ -0,0 +1,69 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a & b; + int tem2 = a ^ b; + return tem1 ^ tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b & a; + int tem2 = a ^ b; + return tem1 ^ tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a & b; + int tem2 = b ^ a; + return tem1 ^ tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b & a; + int tem2 = b ^ a; + return tem1 ^ tem2; +} + +int +fn5 (int a, int b) +{ + int tem1 = a ^ b; + int tem2 = a & b; + return tem1 ^ tem2; +} + +int +fn6 (int a, int b) +{ + int tem1 = b ^ a; + int tem2 = a & b; + return tem1 ^ tem2; +} + +int +fn7 (int a, int b) +{ + int tem1 = a ^ b; + int tem2 = b & a; + return tem1 ^ tem2; +} + +int +fn8 (int a, int b) +{ + int tem1 = b ^ a; + int tem2 = b & a; + return tem1 ^ tem2; +} + +/* { dg-final { scan-tree-dump-not " & " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-xor-5.c b/SingleSource/Regression/C/gcc-dg/fold-xor-5.c new file mode 100644 index 0000000000..15ee76c791 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-xor-5.c @@ -0,0 +1,69 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b) +{ + int tem1 = a | b; + int tem2 = a ^ b; + return tem1 ^ tem2; +} + +int +fn2 (int a, int b) +{ + int tem1 = b | a; + int tem2 = a ^ b; + return tem1 ^ tem2; +} + +int +fn3 (int a, int b) +{ + int tem1 = a | b; + int tem2 = b ^ a; + return tem1 ^ tem2; +} + +int +fn4 (int a, int b) +{ + int tem1 = b | a; + int tem2 = b ^ a; + return tem1 ^ tem2; +} + +int +fn5 (int a, int b) +{ + int tem1 = a ^ b; + int tem2 = a | b; + return tem1 ^ tem2; +} + +int +fn6 (int a, int b) +{ + int tem1 = b ^ a; + int tem2 = a | b; + return tem1 ^ tem2; +} + +int +fn7 (int a, int b) +{ + int tem1 = a ^ b; + int tem2 = b | a; + return tem1 ^ tem2; +} + +int +fn8 (int a, int b) +{ + int tem1 = b ^ a; + int tem2 = b | a; + return tem1 ^ tem2; +} + +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ +/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fold-xorand-1.c b/SingleSource/Regression/C/gcc-dg/fold-xorand-1.c new file mode 100644 index 0000000000..3909de7a8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-xorand-1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return (a & b) ^ a; +} + +int test2(int c, int d) +{ + return (c & d) ^ d; +} + +int test3(int e, int f) +{ + return e ^ (e & f); +} + +int test4(int g, int h) +{ + return g ^ (h & g); +} + +/* { dg-final { scan-tree-dump-times "~b \& a" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "~c \& d" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "~f \& e" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "~h \& g" 1 "original" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/fold-xornot-1.c b/SingleSource/Regression/C/gcc-dg/fold-xornot-1.c new file mode 100644 index 0000000000..167cc1f34c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fold-xornot-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int foo(int x) +{ + return ~(x ^ 4); +} + +int bar(int y) +{ + return ~y ^ 4; +} + +/* { dg-final { scan-tree-dump-times "x \\^ -5" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "y \\^ -5" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/for-1.c b/SingleSource/Regression/C/gcc-dg/for-1.c new file mode 100644 index 0000000000..3df943976f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/for-1.c @@ -0,0 +1,7 @@ +/* PR c/23439 */ +/* Origin: Serge Belyshev */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +# 0 "for-1.c" +void foo() { for /* { dg-error "at end of input" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/fork-instrumentation.c b/SingleSource/Regression/C/gcc-dg/fork-instrumentation.c new file mode 100644 index 0000000000..aedb9ee797 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fork-instrumentation.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -fprofile-generate" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +int fork(void); +int +t() +{ + fork (); +} +/* { dg-final { scan-assembler "gcov_fork" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_1.c b/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_1.c new file mode 100644 index 0000000000..c022f86b25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_1.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-std=c11" } */ + +/* Test that we only see the C99/C11 values for __FLT_EVAL_METHOD__ if + we are compiling with -std=c11. */ + +int main (int argc, char** argv) +{ + switch (__FLT_EVAL_METHOD__) + { + case 0: + case 1: + case 2: + case -1: + return 0; + default: + return 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_2.c b/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_2.c new file mode 100644 index 0000000000..a76ea7e99a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_2.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-fpermitted-flt-eval-methods=c11" } */ + +/* Test that we only see the C99/C11 values for __FLT_EVAL_METHOD__ if + we are compiling with -fpermitted-flt-eval-methods=c11. */ + +int main (int argc, char** argv) +{ + switch (__FLT_EVAL_METHOD__) + { + case 0: + case 1: + case 2: + case -1: + return 0; + default: + return 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_3.c b/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_3.c new file mode 100644 index 0000000000..c7bd7567ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_3.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-std=c11" } */ + +/* Test that when compiling with -std=c11, we only see the C99/C11 values + for FLT_EVAL_METHOD. */ + +#include + +int main (int argc, char** argv) +{ + switch (FLT_EVAL_METHOD) + { + case 0: + case 1: + case 2: + case -1: + return 0; + default: + return 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_4.c b/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_4.c new file mode 100644 index 0000000000..a7bbb65b3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fpermitted-flt-eval-methods_4.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-std=c11" } */ + +/* Test that when compiling with -std=c11 and defining + __STDC_WANT_IEC_60559_TYPES_EXT__, we only see the ISO/IEC TS + 18661-3 values for FLT_EVAL_METHOD. */ + +#define __STDC_WANT_IEC_60559_TYPES_EXT__ + +#include + +int main (int argc, char** argv) +{ + switch (__FLT_EVAL_METHOD__) + { + case 0: + case 1: + case 2: + case 16: + case -1: + return 0; + default: + return 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/framework-1.c b/SingleSource/Regression/C/gcc-dg/framework-1.c new file mode 100644 index 0000000000..de4adc3986 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/framework-1.c @@ -0,0 +1,4 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-F." } */ + +#include diff --git a/SingleSource/Regression/C/gcc-dg/framework-2.c b/SingleSource/Regression/C/gcc-dg/framework-2.c new file mode 100644 index 0000000000..2d86699287 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/framework-2.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-F$srcdir/gcc.dg" } */ + +#include +/* { dg-message "terminated" "" { target *-*-* } 0 } */ +/* { dg-message "Foundation/Foundation.h" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/free-1.c b/SingleSource/Regression/C/gcc-dg/free-1.c new file mode 100644 index 0000000000..ad49d787fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/free-1.c @@ -0,0 +1,26 @@ +/* PR c/36970 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern void free (void *); + +char *p, buf3[10], d; +struct S { char a; int b; } *r; + +void foo (void) +{ + char buf[10], buf2[10], c; + static char buf4[10], e; + char *q = buf; + free (p); + free (q); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (buf2); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (&c); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (buf3); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (&d); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (buf4); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (&e); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (&r->a); + free ("abcd"); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (L"abcd"); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/free-2.c b/SingleSource/Regression/C/gcc-dg/free-2.c new file mode 100644 index 0000000000..edbcdc74a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/free-2.c @@ -0,0 +1,26 @@ +/* PR c/36970 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +extern void free (void *); + +char *p, buf3[10], d; +struct S { char a; int b; } *r; + +void foo (void) +{ + char buf[10], buf2[10], c; + static char buf4[10], e; + char *q = buf; + free (p); + free (q); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (buf2); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (&c); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (buf3); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (&d); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (buf4); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (&e); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (&r->a); + free ("abcd"); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ + free (L"abcd"); /* { dg-warning "\\\[-Wfree-nonheap-object" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/freestanding-main.c b/SingleSource/Regression/C/gcc-dg/freestanding-main.c new file mode 100644 index 0000000000..3718cc4508 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/freestanding-main.c @@ -0,0 +1,5 @@ +/* Make sure we don't get a missing return warning on freestanding. */ +/* { dg-do compile } */ +/* { dg-options "-ffreestanding -Wreturn-type" } */ + +int main() {} diff --git a/SingleSource/Regression/C/gcc-dg/freestanding-nonint-main.c b/SingleSource/Regression/C/gcc-dg/freestanding-nonint-main.c new file mode 100644 index 0000000000..d8393346b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/freestanding-nonint-main.c @@ -0,0 +1,5 @@ +/* Check that we get the right warning for nonint main in freestanding. */ +/* { dg-do compile } */ +/* { dg-options "-ffreestanding -Wreturn-type" } */ + +const char *main(void) {} /* { dg-warning "-Wreturn-type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/fshort-wchar.c b/SingleSource/Regression/C/gcc-dg/fshort-wchar.c new file mode 100644 index 0000000000..63f6d5d011 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fshort-wchar.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. */ + +/* { dg-do run } */ +/* { dg-options "-fshort-wchar" } */ +/* { dg-options "-fshort-wchar -Wl,--no-wchar-size-warning" { target arm_eabi } } */ + +/* Source: Neil Booth, 10 Dec 2002. + + Test that __WCHAR_MAX__ is correct with -fshort-wchar. */ + +extern void abort (void); + +int main () +{ + __WCHAR_TYPE__ w = ~(__WCHAR_TYPE__) 0; + + if (w != __WCHAR_MAX__) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/fstack-protector-strong.c b/SingleSource/Regression/C/gcc-dg/fstack-protector-strong.c new file mode 100644 index 0000000000..94dc3508f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fstack-protector-strong.c @@ -0,0 +1,157 @@ +/* Test that stack protection is done on chosen functions. */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */ +/* { dg-options "-O2 -fstack-protector-strong" } */ + +/* This test checks the presence of __stack_chk_fail function in assembler. + * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC. + */ +/* { dg-require-effective-target nonpic } */ + +#include + +extern int g0; +extern int* pg0; +int +goo (int *); +int +hoo (int); + +/* Function frame address escaped function call. */ +int +foo1 () +{ + int i; + return goo (&i); +} + +struct ArrayStruct +{ + int a; + int array[10]; +}; + +struct AA +{ + int b; + struct ArrayStruct as; +}; + +/* Function frame contains array. */ +int +foo2 () +{ + struct AA aa; + int i; + for (i = 0; i < 10; ++i) + { + aa.as.array[i] = i * (i-1) + i / 2; + } + return aa.as.array[5]; +} + +/* Address computation based on a function frame address. */ +int +foo3 () +{ + int a; + int *p; + p = &a + 5; + return goo (p); +} + +/* Address cast based on a function frame address. */ +int +foo4 () +{ + int a; + return goo (g0 << 2 ? (int *)(3 * (long)(void *)(&a)) : 0); +} + +/* Address cast based on a local array. */ +int +foo5 () +{ + short array[10]; + return goo ((int *)(array + 5)); +} + +struct BB +{ + int one; + int two; + int three; +}; + +/* Address computaton based on a function frame address.*/ +int +foo6 () +{ + struct BB bb; + return goo (&bb.one + sizeof(int)); +} + +/* Function frame address escaped via global variable. */ +int +foo7 () +{ + int a; + pg0 = &a; + goo (pg0); + return *pg0; +} + +/* Check that this covers -fstack-protector. */ +int +foo8 () +{ + char base[100]; + memcpy ((void *)base, (const void *)pg0, 105); /* { dg-warning "writing 105 bytes into a region of size 100" } */ + return (int)(base[32]); +} + +/* Check that this covers -fstack-protector. */ +int +foo9 () +{ + char* p = __builtin_alloca (100); + return goo ((int *)(p + 50)); +} + +int +global2 (struct BB* pbb); + +/* Address taken on struct. */ +int +foo10 () +{ + struct BB bb; + int i; + bb.one = global2 (&bb); + for (i = 0; i < 10; ++i) + { + bb.two = bb.one + bb.two; + bb.three = bb.one + bb.two + bb.three; + } + return bb.three; +} + +struct B +{ + /* Discourage passing this struct in registers. */ + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; +}; + +struct B global3 (void); + +int foo11 () +{ + return global3 ().a1; +} + +void foo12 () +{ + global3 (); +} + +/* { dg-final { scan-assembler-times "stack_chk_fail" 12 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ftrapv-1.c b/SingleSource/Regression/C/gcc-dg/ftrapv-1.c new file mode 100644 index 0000000000..86bd802cf1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ftrapv-1.c @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 Free Software Foundation. + + PR other/15526 + Verify correct overflow checking with -ftrapv. + + Written by Falk Hueffner, 20th May 2004. */ + +/* { dg-do run } */ +/* { dg-options "-ftrapv" } */ +/* { dg-require-effective-target trapping } */ + +__attribute__((noinline)) int +mulv(int a, int b) +{ + return a * b; +} + +int +main() +{ + mulv( 0, 0); + mulv( 0, -1); + mulv(-1, 0); + mulv(-1, -1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ftrapv-2.c b/SingleSource/Regression/C/gcc-dg/ftrapv-2.c new file mode 100644 index 0000000000..721bece436 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ftrapv-2.c @@ -0,0 +1,110 @@ +/* Copyright (C) 2004 Free Software Foundation. + + PR other/18665 + Verify that -ftrapv doesn't produce bogus results + on 64-bit platforms. + + Written by Eric Botcazou */ + +/* { dg-do run } */ +/* { dg-options "-ftrapv" } */ +/* { dg-require-effective-target trapping } */ + +extern void abort(void); +extern int abs(int); +extern long labs(long); + +int __attribute__((noinline)) +iabsv(int a) +{ + return abs(a); +} + +int __attribute__((noinline)) +iaddv(int a, int b) +{ + return a + b; +} + +int __attribute__((noinline)) +isubv(int a, int b) +{ + return a - b; +} + +int __attribute__((noinline)) +imulv(int a, int b) +{ + return a * b; +} + +int __attribute__((noinline)) +inegv(int a) +{ + return -a; +} + +long __attribute__((noinline)) +labsv(long a) +{ + return labs(a); +} + +long __attribute__((noinline)) +laddv(long a, long b) +{ + return a + b; +} + +long __attribute__((noinline)) +lsubv(long a, long b) +{ + return a - b; +} + +long __attribute__((noinline)) +lmulv(long a, long b) +{ + return a * b; +} + +long __attribute__((noinline)) +lnegv(long a) +{ + return -a; +} + +int main(void) +{ + if (iabsv (-1) != 1) + abort (); + + if (iaddv (2,-3) != -1) + abort (); + + if (isubv (2,3) != -1) + abort (); + + if (imulv (-2,3) != -6) + abort (); + + if (inegv (-1) != 1) + abort (); + + if (labsv (-1L) != 1L) + abort (); + + if (laddv (2L,-3L) != -1L) + abort (); + + if (lsubv (2L,3L) != -1L) + abort (); + + if (lmulv (-2L,3L) != -6L) + abort (); + + if (lnegv (-1L) != 1L) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ftrapv-3.c b/SingleSource/Regression/C/gcc-dg/ftrapv-3.c new file mode 100644 index 0000000000..e23059a078 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ftrapv-3.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ +/* { dg-options "-ftrapv" } */ + +extern void abort (void); +unsigned long +foo (long i, long j) +{ + /* We may not fold this to (unsigned long)(i * j). */ + return -(unsigned long)(i * -j); +} +int main() +{ + if (foo (-__LONG_MAX__ - 1, -1) != -(unsigned long)(-__LONG_MAX__ - 1)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/func-args-1.c b/SingleSource/Regression/C/gcc-dg/func-args-1.c new file mode 100644 index 0000000000..5f7b245355 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/func-args-1.c @@ -0,0 +1,53 @@ +/* Test messages for wrong number of arguments to function. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void f0(void); /* { dg-message "note: declared here" } */ +void f1(int); /* { dg-message "note: declared here" } */ +void f1v(int, ...); /* { dg-message "note: declared here" } */ +void f2(int, int); /* { dg-message "note: declared here" } */ +void f2v(int, int, ...); /* { dg-message "note: declared here" } */ + +struct s { + void (*f0)(void); + void (*f1)(int); + void (*f1v)(int, ...); + void (*f2)(int, int); + void (*f2v)(int, int, ...); +} x; + +void +g (int a) +{ + f0(); + x.f0(); + f0(a); /* { dg-error "too many arguments to function 'f0'" } */ + x.f0(a); /* { dg-error "too many arguments to function 'x.f0'" } */ + f0(a, a); /* { dg-error "too many arguments to function 'f0'" } */ + x.f0(a, a); /* { dg-error "too many arguments to function 'x.f0'" } */ + f1(); /* { dg-error "too few arguments to function 'f1'" } */ + x.f1(); /* { dg-error "too few arguments to function 'x.f1'" } */ + f1(a); + x.f1(a); + f1(a, a); /* { dg-error "too many arguments to function 'f1'" } */ + x.f1(a, a); /* { dg-error "too many arguments to function 'x.f1'" } */ + f1v(); /* { dg-error "too few arguments to function 'f1v'" } */ + x.f1v(); /* { dg-error "too few arguments to function 'x.f1v'" } */ + f1v(a); + x.f1v(a); + f1v(a, a); + x.f1v(a, a); + f2(a); /* { dg-error "too few arguments to function 'f2'" } */ + x.f2(a); /* { dg-error "too few arguments to function 'x.f2'" } */ + f2(a, a); + x.f2(a, a); + f2(a, a, a); /* { dg-error "too many arguments to function 'f2'" } */ + x.f2(a, a, a); /* { dg-error "too many arguments to function 'x.f2'" } */ + f2v(a); /* { dg-error "too few arguments to function 'f2v'" } */ + x.f2v(a); /* { dg-error "too few arguments to function 'x.f2v'" } */ + f2v(a, a); + x.f2v(a, a); + f2v(a, a, a); + x.f2v(a, a, a); +} diff --git a/SingleSource/Regression/C/gcc-dg/func-args-2.c b/SingleSource/Regression/C/gcc-dg/func-args-2.c new file mode 100644 index 0000000000..a537f8956a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/func-args-2.c @@ -0,0 +1,6 @@ +/* PR c/27420 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +void foo(); +void foo(struct A a) {} /* { dg-error "incomplete type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/func-attr-1.c b/SingleSource/Regression/C/gcc-dg/func-attr-1.c new file mode 100644 index 0000000000..8d1a3bd724 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/func-attr-1.c @@ -0,0 +1,23 @@ +/* Test that setting -Os in a function attribute works. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-bbro" } */ + +extern void f1 (); +extern int f2 (); + +__attribute__ ((__optimize__ ("O2"))) +void +f3() +{ +} + +__attribute__ ((__optimize__ ("-Os", "-falign-functions", "-falign-jumps", "-falign-labels", "-falign-loops", "-fno-inline-functions", "-foptimize-strlen"))) +int +f4 () { + if (f2 () == 0) { + f1 (); + } + return 0; +} + +/* { dg-final { scan-rtl-dump-not "Duplicated bb" "bbro" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/func-outside-1.c b/SingleSource/Regression/C/gcc-dg/func-outside-1.c new file mode 100644 index 0000000000..25c19c6f64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/func-outside-1.c @@ -0,0 +1,9 @@ +/* Test for rejection of __func__ outside a function (GNU extensions + are OK there). Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-fshow-column" } */ + +const char *a = __func__; /* { dg-warning "17:'__func__' is not defined outside of function scope" "undef" } */ +const char *b = __FUNCTION__; +const char *c = __PRETTY_FUNCTION__; diff --git a/SingleSource/Regression/C/gcc-dg/func-outside-2.c b/SingleSource/Regression/C/gcc-dg/func-outside-2.c new file mode 100644 index 0000000000..28ef6bced7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/func-outside-2.c @@ -0,0 +1,9 @@ +/* Test for rejection of __func__ outside a function (GNU extensions + are OK there). Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +__extension__ const char *a = __func__; /* { dg-error "'__func__' is not defined outside of function scope" "undef" } */ +__extension__ const char *b = __FUNCTION__; +__extension__ const char *c = __PRETTY_FUNCTION__; diff --git a/SingleSource/Regression/C/gcc-dg/func-ptr-conv-1.c b/SingleSource/Regression/C/gcc-dg/func-ptr-conv-1.c new file mode 100644 index 0000000000..5c8a101343 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/func-ptr-conv-1.c @@ -0,0 +1,56 @@ +/* Conversions between function and object pointers are not permitted + in any version of ISO C, even with casts, except for the special + case of converting a null pointer constant to function pointer + type. Likewise, comparisons between function and object pointers + are not permitted. PR c/11234. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +void f(void); + +void *v1 = f; /* { dg-warning "12:pointer" "bad conversion" } */ +void *v2 = &f; /* { dg-warning "12:pointer" "bad conversion" } */ +void *v3 = (void *)f; /* { dg-warning "12:pointer" "bad conversion" } */ +void *v4 = (void *)&f; /* { dg-warning "12:pointer" "bad conversion" } */ +void *v5; +char *c1 = f; /* { dg-warning "12:pointer" "bad conversion" } */ +char *c2 = &f; /* { dg-warning "12:pointer" "bad conversion" } */ +char *c3 = (char *)f; /* { dg-warning "12:pointer" "bad conversion" } */ +char *c4 = (char *)&f; /* { dg-warning "12:pointer" "bad conversion" } */ +char *c5; +void (*fp)(void); +int a; + +void +g(void) +{ + v5 = f; /* { dg-warning "6:pointer" "bad conversion" } */ + v5 = &f; /* { dg-warning "6:pointer" "bad conversion" } */ + v5 = (void *)f; /* { dg-warning "8:pointer" "bad conversion" } */ + v5 = (void *)&f; /* { dg-warning "8:pointer" "bad conversion" } */ + c5 = f; /* { dg-warning "6:pointer" "bad conversion" } */ + c5 = &f; /* { dg-warning "6:pointer" "bad conversion" } */ + c5 = (char *)f; /* { dg-warning "8:pointer" "bad conversion" } */ + c5 = (char *)&f; /* { dg-warning "8:pointer" "bad conversion" } */ + fp = v5; /* { dg-warning "6:pointer" "bad conversion" } */ + fp = c5; /* { dg-warning "6:pointer" "bad conversion" } */ + fp = (void (*)(void))v5; /* { dg-warning "8:pointer" "bad conversion" } */ + fp = (void (*)(void))c5; /* { dg-warning "8:pointer" "bad conversion" } */ + (a ? f : v3); /* { dg-warning "10:pointer" "bad conversion" } */ + (a ? v2 : fp); /* { dg-warning "11:pointer" "bad conversion" } */ + /* The following are OK. */ + fp = 0; + fp = (void *)0; + fp = 0L; + fp = (void (*)(void))0; + fp = (void (*)(void))(void *)0; + (a ? f : 0); + (a ? f : (void *)0); + (a ? (void *)0 : fp); + (a ? 0 : fp); +} + +/* The following are OK. */ +void (*fp2)(void) = 0; +void (*fp3)(void) = (void *)0; diff --git a/SingleSource/Regression/C/gcc-dg/funcdef-attr-1.c b/SingleSource/Regression/C/gcc-dg/funcdef-attr-1.c new file mode 100644 index 0000000000..17249a0cb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/funcdef-attr-1.c @@ -0,0 +1,14 @@ +/* The declarator in a function definition should be able to take the + form of an attributed function declarator, not just a plain + function declarator. This was formerly allowed by some of the code + but then the wrong constraint checks were made because other code + didn't recognise the declarator as being that of the function + definition. */ +/* Origin: Joseph Myers . */ + +int (__attribute__((const)) x) (a, b) + int a; + int b; +{ + return a + b; +} diff --git a/SingleSource/Regression/C/gcc-dg/funcdef-storage-1.c b/SingleSource/Regression/C/gcc-dg/funcdef-storage-1.c new file mode 100644 index 0000000000..9aa963a028 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/funcdef-storage-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void +flarm(void) +{ + static void foo(); /* { dg-error "invalid storage class" } */ + + foo(); +} diff --git a/SingleSource/Regression/C/gcc-dg/funcdef-var-1.c b/SingleSource/Regression/C/gcc-dg/funcdef-var-1.c new file mode 100644 index 0000000000..cef7026c3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/funcdef-var-1.c @@ -0,0 +1,10 @@ +/* Test ICE on defining function with a name previously declared as a + nonfunction. Bug 28299 from Bernhard Fischer + . */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-prototypes" } */ + +extern __typeof(foo) foo __asm__(""); /* { dg-error "undeclared" } */ +/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */ +void *foo (void) {} /* { dg-error "redeclared as different kind of symbol" } */ +/* { dg-warning "no previous prototype" "no previous prototype" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/funcdef-var-2.c b/SingleSource/Regression/C/gcc-dg/funcdef-var-2.c new file mode 100644 index 0000000000..e978050b47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/funcdef-var-2.c @@ -0,0 +1,11 @@ +/* Test ICE on defining function with a name previously declared as a + nonfunction. Bug 28299 from Bernhard Fischer . + Reduced testcase from Volker Reichelt . */ + +/* { dg-do compile } */ +/* { dg-options "-Wmissing-prototypes" } */ + +int foo; +/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */ +void foo () {} /* { dg-error "redeclared as different kind of symbol" } */ +/* { dg-warning "no previous prototype" "no previous prototype" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/funcorder.c b/SingleSource/Regression/C/gcc-dg/funcorder.c new file mode 100644 index 0000000000..9e4d8dedd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/funcorder.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funit-at-a-time" } */ +/* { dg-final { scan-assembler-not "link_error" } } */ +/* In unit-at-time the functions should be assembled in order + e q t main, so we realize that they are pure. */ + +void link_error (void); +static int mem; +static int e(void) __attribute__ ((noinline)); +static int q(void) __attribute__ ((noinline)); +static int t(void) __attribute__ ((noinline)); +int +main() +{ + return t(); +} +static int t() +{ + int r,e; + if (mem) + t(); + e=mem; + r=q(); + if (e!=mem) + link_error(); + return r; +} +static int e() +{ + return 0; +} +static int q() +{ + int t=mem,r; + r=e(); + if (t!=mem) + link_error(); + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/funroll-loops-all.c b/SingleSource/Regression/C/gcc-dg/funroll-loops-all.c new file mode 100644 index 0000000000..ab12df1c43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/funroll-loops-all.c @@ -0,0 +1,4 @@ +/* PR 17594 */ +/* { dg-do compile } */ +/* { dg-options "-funroll-loops-all" } */ +/* { dg-error "unrecognized command-line option '-funroll-loops-all'" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/fuse-caller-save.c b/SingleSource/Regression/C/gcc-dg/fuse-caller-save.c new file mode 100644 index 0000000000..2854b94654 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fuse-caller-save.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-fipa-ra" } */ +/* Testing -fipa-ra optimization option. */ + +static int __attribute__((noinline)) +bar (int x) +{ + return x + 3; +} + +int __attribute__((noinline)) +foo (int y) +{ + return y + bar (y); +} + +int +main (void) +{ + return !(foo (5) == 13); +} diff --git a/SingleSource/Regression/C/gcc-dg/fwrapv-1.c b/SingleSource/Regression/C/gcc-dg/fwrapv-1.c new file mode 100644 index 0000000000..a172b3b8fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fwrapv-1.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Test that the -fwrapv command line option is accepted and disables + "unsafe" optimizations that rely on undefined arithmetic overflow. + + Written by Roger Sayle, 24th March 2003. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +#include + +extern void abort (); + +int test(int x) +{ + return (2*x)/2; +} + +int +main() +{ + int x = INT_MAX; + + if (test(x) == x) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/fwrapv-2.c b/SingleSource/Regression/C/gcc-dg/fwrapv-2.c new file mode 100644 index 0000000000..e260e545b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/fwrapv-2.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2003 Free Software Foundation. + + Test that the -fno-wrapv command line option is accepted and enables + "unsafe" optimizations that rely on undefined arithmetic overflow. + + Written by Roger Sayle, 31st May 2003. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -fno-wrapv" } */ + +#include + +extern void abort (); + +int test(int x) +{ + return (2*x)/2; +} + +int +main() +{ + int x = INT_MAX; + + if (test(x) != x) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/gcc-have-sync-compare-and-swap.c b/SingleSource/Regression/C/gcc-dg/gcc-have-sync-compare-and-swap.c new file mode 100644 index 0000000000..5affeba19f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gcc-have-sync-compare-and-swap.c @@ -0,0 +1,62 @@ +/* { dg-do link } */ +/* MIPS only supports these built-in functions for non-MIPS16 mode, and + -mflip-mips16 will change the mode of some functions to be different + from the command-line setting. */ +/* { dg-skip-if "" { mips*-*-* } { "-mflip-mips16" } { "" } } */ + +void f1() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 + typedef int __attribute__ ((__mode__ (__QI__))) qi_int_type; + qi_int_type qi_int; + __sync_bool_compare_and_swap (&qi_int, (qi_int_type)0, (qi_int_type)1); +#endif +} + +void f2() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 + typedef int __attribute__ ((__mode__ (__HI__))) hi_int_type; + hi_int_type hi_int; + __sync_bool_compare_and_swap (&hi_int, (hi_int_type)0, (hi_int_type)1); +#endif +} + +void f4() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 + typedef int __attribute__ ((__mode__ (__SI__))) si_int_type; + si_int_type si_int; + __sync_bool_compare_and_swap (&si_int, (si_int_type)0, (si_int_type)1); +#endif +} + +void f8() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 + typedef int __attribute__ ((__mode__ (__DI__))) di_int_type; + di_int_type di_int; + __sync_bool_compare_and_swap (&di_int, (di_int_type)0, (di_int_type)1); +#endif +} + +/* aligned (16): On S/390 16 byte compare and swap operations are only + available if the memory operand resides on a 16 byte boundary. */ +void f16() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 + typedef int __attribute__ ((__mode__ (__TI__), aligned (16))) ti_int_type; + ti_int_type ti_int; + __sync_bool_compare_and_swap (&ti_int, (ti_int_type)0, (ti_int_type)1); +#endif +} + +int main() +{ + f1(); + f2(); + f4(); + f8(); + f16(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/gcov-info-to-gcda.c b/SingleSource/Regression/C/gcc-dg/gcov-info-to-gcda.c new file mode 100644 index 0000000000..ca9b3e831f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gcov-info-to-gcda.c @@ -0,0 +1,81 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* } } */ +/* { dg-options "-fprofile-arcs -fprofile-info-section" } */ + +#define assert(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("%s:%i: Assertion `%s' failed.\n", \ + __FILE__, __LINE__, #expr), \ + __builtin_abort ())) + +struct gcov_info; + +extern void +__gcov_info_to_gcda (const struct gcov_info *__info, + void (*__filename_fn) (const char *, void *), + void (*__dump_fn) (const void *, unsigned, void *), + void *(*__allocate_fn) (unsigned, void *), + void *__arg); + +extern void +__gcov_filename_to_gcfn (const char *__filename, + void (*__dump_fn) (const void *, unsigned, void *), + void *__arg); + +extern const struct gcov_info *my_info; + +static unsigned counter; + +static unsigned counter_after_filename; + +static int check_zero; + +static int check_after_filename; + +static void +dump (const void *d, unsigned n, void *arg) +{ + unsigned *m = (unsigned *)arg; + assert (arg == &counter); + + if (*m == 0) + { + const unsigned *u = d; + assert (*u == 0x6763666e); + check_zero = 1; + } + else if (*m == counter_after_filename) + { + const unsigned *u = d; + assert (*u == 0x67636461); + check_after_filename = 1; + } + + *m += n; +} + +static void +filename (const char *f, void *arg) +{ + assert (arg == &counter); + assert (__builtin_strstr (f, "gcov-info-to-gcda.c") == 0); + __gcov_filename_to_gcfn (f, dump, arg); + counter_after_filename = counter; +} + +static void * +allocate (unsigned length, void *arg) +{ + assert (arg == &counter); + return __builtin_malloc (length); +} + +int main() +{ + __asm__ volatile (".set my_info, .LPBX2"); + __gcov_info_to_gcda (my_info, filename, dump, allocate, &counter); + assert (counter > 8); + assert (check_zero); + assert (check_after_filename); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-1.c b/SingleSource/Regression/C/gcc-dg/gimplefe-1.c new file mode 100644 index 0000000000..a81ed1ff38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int i; +void __GIMPLE foo() +{ + i = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-10.c b/SingleSource/Regression/C/gcc-dg/gimplefe-10.c new file mode 100644 index 0000000000..7f63c587c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-10.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE() bar(int a, int b, int c) +{ + a = 1; + b = a + 1; + c = b * 4; + return b; +} + +void __GIMPLE() foo() +{ + int a; + int b; + int c; + b = bar(a, b, c); +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-11.c b/SingleSource/Regression/C/gcc-dg/gimplefe-11.c new file mode 100644 index 0000000000..e1483f4c36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-11.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE() bar(int a, int b, int c) +{ + a = 1; + b = a + 1; + c = b * 4; + return; +} + +void __GIMPLE() foo() +{ + int a; + int b; + int c; + bar(a, b, c); +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-12.c b/SingleSource/Regression/C/gcc-dg/gimplefe-12.c new file mode 100644 index 0000000000..2863228779 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-12.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple" } */ + +void __GIMPLE (startwith ("ccp1")) foo () +{ + int a; + int b; + a = b + 2; + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-13.c b/SingleSource/Regression/C/gcc-dg/gimplefe-13.c new file mode 100644 index 0000000000..dc326861c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-13.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple" } */ + +void __GIMPLE (ssa,startwith ("dse2")) foo () +{ + int a; + +__BB(2): + if (a_5(D) > 4) + goto __BB3; + else + goto __BB4; + +__BB(3): + a_2 = 10; + goto __BB5; + +__BB(4): + a_3 = 20; + goto __BB5; + +__BB(5): + a_1 = __PHI (__BB3: a_2, __BB4: a_3); + a_4 = a_1 + 4; + +return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-14.c b/SingleSource/Regression/C/gcc-dg/gimplefe-14.c new file mode 100644 index 0000000000..a9e9d8141f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-14.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-O -fgimple" } */ + +int __GIMPLE (ssa) +main (int argc, char * * argv) +{ + int a; + + __BB(2): + /* Because of PR82114 we need to handle also 0 as base metal can have + argc == 0. */ + switch (argc_2(D)) {default: L2; case 0: L0; case 1: L0; case 2: L1; } + + __BB(3): +L0: + a_4 = 0; + goto __BB6; + + __BB(4): +L1: + a_3 = 3; + goto __BB6; + + __BB(5): +L2: + a_5 = -1; + goto __BB6; + + __BB(6): + a_1 = __PHI (__BB3: a_4, __BB4: a_3, __BB5: a_5); + return a_1; + +} + + diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-15.c b/SingleSource/Regression/C/gcc-dg/gimplefe-15.c new file mode 100644 index 0000000000..ca990313c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-15.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple" } */ + +struct Y { int b[2]; }; +struct X { int a; struct Y y; }; +struct X x; + +int __GIMPLE () +foo (struct X *p, _Complex int q) +{ + int b; + b = __real q; + p->a = b; + x.y.b[b] = b; + b = p->y.b[1]; + b = x.a; + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-16.c b/SingleSource/Regression/C/gcc-dg/gimplefe-16.c new file mode 100644 index 0000000000..2949249151 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-16.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple" } */ + +struct Y { int b[2]; }; +struct X { int a; struct Y y; }; +struct X x; + +int __GIMPLE () +foo (struct X *p, _Complex int q) +{ + int b; + b_1 = __real q; + p_4(D)->a = b_1; + x.y.b[b_1] = b_1; + b_2 = p->y.b[1]; + b_3 = x.a; + return b_3; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-17.c b/SingleSource/Regression/C/gcc-dg/gimplefe-17.c new file mode 100644 index 0000000000..eceefd153e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-17.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -fdump-tree-fixup_cfg2" } */ + +int +__GIMPLE (ssa) * +foo () +{ + int _1; + int j; + int *b; + +__BB(5): + _1 = 1; + goto __BB2; + +__BB(2): + if (_1) + goto __BB4; + else + goto __BB3; + +__BB(3): + b_2 = (int *)0; + goto __BB4; + +__BB(4): + b_4 = __PHI (__BB2: b_3(D), __BB3: b_2); + return b_4; +} + +/* { dg-final { scan-tree-dump-not "_1_" "fixup_cfg2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-18.c b/SingleSource/Regression/C/gcc-dg/gimplefe-18.c new file mode 100644 index 0000000000..18fabbe1e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-18.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int +__GIMPLE (ssa) * +foo () +{ + int _1; + int j; + int *b; + +__BB(2): + _1 = 1; + goto __BB3; + +__BB(3): + if (_1) + goto __BB5; + else + goto __BB4; + +__BB(4): + b_2 = (int *)0; + goto __BB5; + +__BB(5): + b_4 = __PHI (__BB3: &j, __BB4: b_2); + return b_4; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-19.c b/SingleSource/Regression/C/gcc-dg/gimplefe-19.c new file mode 100644 index 0000000000..5ce1cec68d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-19.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE (startwith ("ccp1")) foo () +{ + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-2.c b/SingleSource/Regression/C/gcc-dg/gimplefe-2.c new file mode 100644 index 0000000000..e3a23cf4ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile }*/ +/* { dg-options "-fgimple" } */ + +int a; +void __GIMPLE () foo () +{ + int b; + b = a; + b = b + 1; + a = b; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-20.c b/SingleSource/Regression/C/gcc-dg/gimplefe-20.c new file mode 100644 index 0000000000..99b3180648 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-20.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-ssa-gimple" } */ + +_Complex a; + +double __GIMPLE() f() +{ + double t1; + double t2; + double _1; + +bb1: + t1_2 = __real a; + t2_3 = __imag a; + _1 = t1_2 + t2_3; + return _1; +} + +/* { dg-final { scan-tree-dump "__real a" "ssa" } } */ +/* { dg-final { scan-tree-dump "__imag a" "ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-21.c b/SingleSource/Regression/C/gcc-dg/gimplefe-21.c new file mode 100644 index 0000000000..55ea0b825c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-21.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +float __GIMPLE () +foo (int * p) +{ + float f; + float D1800; + unsigned int D1799; + + D1799 = __MEM ((char *)p + 1); + __MEM ((char *)&f + 0xfffffffffffffffe) = D1799; + __MEM (p) = 1; + __MEM (p) = 1; + __MEM (p + 2) = 1; + __MEM ((char *)p) = 1; + D1800 = f; + return D1800; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-22.c b/SingleSource/Regression/C/gcc-dg/gimplefe-22.c new file mode 100644 index 0000000000..8e213b94ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-22.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE () +foo (short * p) +{ + *p = _Literal (short int) 1; + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-23.c b/SingleSource/Regression/C/gcc-dg/gimplefe-23.c new file mode 100644 index 0000000000..05f87ed4df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-23.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +short int __GIMPLE () +foo (short int s) +{ + short int D_1803; + +bb_2: + D_1803 = s; + +L0: + return D_1803; + +} + +int __GIMPLE () +main (int argc, char * * argv) +{ + short int s; + int D_1805; + int _1; + short _2; + +bb_2: + s = (short int) argc; + _1 = (int) s; + _2 = foo (_1); + D_1805 = (int) _2; + +L0: + return D_1805; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-24.c b/SingleSource/Regression/C/gcc-dg/gimplefe-24.c new file mode 100644 index 0000000000..1f8dbb4725 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-24.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE foo(int a) +{ + int t1; + t1_1 = __builtin_abs (a); + return t1_1; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-25.c b/SingleSource/Regression/C/gcc-dg/gimplefe-25.c new file mode 100644 index 0000000000..d8c44a7401 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-25.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-ssa-gimple" } */ + +int __GIMPLE() f(int a) +{ + int t0; + t0_1 = __ABS a; + return t0_1; +} + +/* { dg-final { scan-tree-dump "__ABS a" "ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-26.c b/SingleSource/Regression/C/gcc-dg/gimplefe-26.c new file mode 100644 index 0000000000..f4dbdb18bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-26.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target scalar_all_fma } } */ +/* { dg-options "-O -fgimple -fdump-tree-ssa-gimple" } */ + +#define foo(type, num) \ +type __GIMPLE () foo_##num (type a, type b, type c) \ +{ \ + type t0; \ + t0_1 = .FMA (a, b, c); \ + return t0_1; \ +} + +foo(float, 1) +foo(double, 2) + +/* { dg-final { scan-tree-dump-times {\.FMA} 2 "ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-27.c b/SingleSource/Regression/C/gcc-dg/gimplefe-27.c new file mode 100644 index 0000000000..0053222c86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-27.c @@ -0,0 +1,11 @@ +/* { dg-options "-O -fgimple" } */ + +int __GIMPLE () +p (int n) +{ + int _2; + _Bool _3; + _3 = n_1(D) != 0; + _2 = _3 ? 2 : 0; + return _2; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-28.c b/SingleSource/Regression/C/gcc-dg/gimplefe-28.c new file mode 100644 index 0000000000..d2f6b4c5c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-28.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target sqrt_insn } } */ +/* { dg-options "-fgimple -O2" } */ +/* { dg-add-options sqrt_insn } */ + +double __GIMPLE +f1 (double x) +{ + double res; + res = .SQRT (x); + return res; +} + +void __GIMPLE +f2 (double x) +{ + .SQRT (x); // Dead code +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-29.c b/SingleSource/Regression/C/gcc-dg/gimplefe-29.c new file mode 100644 index 0000000000..54b86ef86f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-29.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-ssa-gimple" } */ + +unsigned int __GIMPLE() f(int a) +{ + unsigned int t0; + t0_1 = __ABSU a; + return t0_1; +} + +/* { dg-final { scan-tree-dump "__ABSU a" "ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-3.c b/SingleSource/Regression/C/gcc-dg/gimplefe-3.c new file mode 100644 index 0000000000..595365e0b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-3.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE () foo () +{ + int *b; + *b = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-30.c b/SingleSource/Regression/C/gcc-dg/gimplefe-30.c new file mode 100644 index 0000000000..6c25106160 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-30.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-optimized" } */ + +unsigned int __GIMPLE() f(int a) +{ + unsigned int t0; + unsigned int t1; + unsigned int t2; + t0 = __ABSU a; + t1 = __ABSU a; + t2 = t0 * t1; + return t2; +} + + +/* { dg-final { scan-tree-dump-times "ABSU" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-31.c b/SingleSource/Regression/C/gcc-dg/gimplefe-31.c new file mode 100644 index 0000000000..a97d0dd65e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-31.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-optimized" } */ + + +unsigned int __GIMPLE() f(int a) +{ + unsigned int t0; + int t1; + unsigned int t2; + t0 = __ABSU a; + t1 = (int) t0; + t2 = __ABSU t1; + return t2; +} + +/* { dg-final { scan-tree-dump-times "ABSU" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-32.c b/SingleSource/Regression/C/gcc-dg/gimplefe-32.c new file mode 100644 index 0000000000..9b3963cdde --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-32.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-optimized" } */ + +unsigned int __GIMPLE() f(int a) +{ + int t0; + unsigned int t1; + t0 = -a; + t1 = __ABSU a; + return t1; +} + + +/* { dg-final { scan-tree-dump-times "= -" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-33.c b/SingleSource/Regression/C/gcc-dg/gimplefe-33.c new file mode 100644 index 0000000000..4e4982247c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-33.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-optimized" } */ + +int __GIMPLE() f(int c) +{ + int D; + int _1; + unsigned int _2; + _1 = __ABS c; + _2 = __ABSU _1; + D = (int) _2; + return D; +} + + +/* { dg-final { scan-tree-dump-times "ABSU" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-34.c b/SingleSource/Regression/C/gcc-dg/gimplefe-34.c new file mode 100644 index 0000000000..5825edce34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-34.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +typedef unsigned char v16qi __attribute__((vector_size(16))); +typedef unsigned char v8qi __attribute__((vector_size(8))); + +v16qi x; + +void __GIMPLE foo (unsigned char *p) +{ + v8qi _2; + v16qi _3; + +bb_2: + _2 = __MEM (p_1(D)); + _3 = _Literal (v16qi) { _2, _Literal (v8qi) { _Literal (unsigned char) 0, _Literal (unsigned char) 0, _Literal (unsigned char) 0, _Literal (unsigned char) 0, _Literal (unsigned char) 0, _Literal (unsigned char) 0, _Literal (unsigned char) 0 } }; + x = _3; + return; +} + diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-35.c b/SingleSource/Regression/C/gcc-dg/gimplefe-35.c new file mode 100644 index 0000000000..80ee75cf2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-35.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +struct X { int i; } x; +void __GIMPLE foo (void) +{ +bb_2: + x = _Literal (struct X) {}; + return; +} + diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-36.c b/SingleSource/Regression/C/gcc-dg/gimplefe-36.c new file mode 100644 index 0000000000..1c59541fc0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-36.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple" } */ + +int foo (void); + +void __GIMPLE (startwith("fre1")) +d () +{ + int _1; + +bb_2: + _1 = foo (); + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-37.c b/SingleSource/Regression/C/gcc-dg/gimplefe-37.c new file mode 100644 index 0000000000..12f6f64fc2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-37.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgimple -fdump-tree-optimized --param=gimple-fe-computed-hot-bb-threshold=10 " } */ + +int __GIMPLE (ssa,startwith("slsr"),precise(3)) +main (int argc) +{ + int _1; + + __BB(2,precise(3)): + if (argc_2(D) == 2) + goto __BB3(precise(44739243)); + else + goto __BB4(precise(89478485)); + + __BB(3,precise(1)): + goto __BB4(precise(134217728)); + + __BB(4,precise(3)): + _1 = __PHI (__BB2: 0, __BB3: 12); + return _1; +} + + +/* { dg-final { scan-tree-dump-times " \\\[count: 3" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\\[count: \[12\]" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "goto ; \\\[33\\\.33%\\\]" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "goto ; \\\[66\\\.67%\\\]" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-38.c b/SingleSource/Regression/C/gcc-dg/gimplefe-38.c new file mode 100644 index 0000000000..64532d87da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-38.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgimple -fdump-tree-slsr" } */ + +int __GIMPLE (ssa,startwith("slsr"),guessed_local(1073741824)) +main (int argc) +{ + int _1; + + __BB(2,guessed_local(1073741824)): + if (argc_2(D) == 2) + goto __BB3(guessed(16777216)); + else + goto __BB4(guessed(117440512)); + + __BB(3,guessed_local(134217728)): + goto __BB4(precise(134217728)); + + __BB(4,guessed_local(1073741824)): + _1 = __PHI (__BB2: 0, __BB3: 12); + return _1; +} + + +/* { dg-final { scan-tree-dump-times " \\\[local count: 1073741824" 2 "slsr" } } */ +/* { dg-final { scan-tree-dump-times " \\\[local count: 134217728" 1 "slsr" } } */ +/* { dg-final { scan-tree-dump-times "goto ; \\\[12\\\.50%\\\]" 1 "slsr" } } */ +/* { dg-final { scan-tree-dump-times "goto ; \\\[87\\\.50%\\\]" 1 "slsr" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-39.c b/SingleSource/Regression/C/gcc-dg/gimplefe-39.c new file mode 100644 index 0000000000..30677356d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-39.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgimple -fdump-tree-optimized" } */ + +int a, b; + +int __GIMPLE (ssa,guessed_local(1073741824)) +main (int argc) +{ + int _1; + int _2; + int _4; + + __BB(2,guessed_local(1073741824)): + _1 = a; + _2 = b; + _4 = __MAX (_1, _2); + return _4; + +} + +/* { dg-final { scan-tree-dump "MAX_EXPR" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-4.c b/SingleSource/Regression/C/gcc-dg/gimplefe-4.c new file mode 100644 index 0000000000..3600c7ca1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-4.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE () foo () +{ + int a; + char b; + a = (int) b; + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-42.c b/SingleSource/Regression/C/gcc-dg/gimplefe-42.c new file mode 100644 index 0000000000..b79033934d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-42.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +typedef char ref_all_char __attribute__((may_alias)); +char a[7]; +__GIMPLE void f() +{ + int _1; + /* string literals inside __MEM need their address taken. */ + __MEM ((ref_all_char *)&a) + = __MEM (_Literal (char *) &"654321"); + /* but plain assignment also works. */ + __MEM ((ref_all_char *)&a) = "654321"; + /* also punning with int. */ + _1 = __MEM (_Literal (char *) &"654321"); + __MEM ((ref_all_char *)&a) = _1; + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-43.c b/SingleSource/Regression/C/gcc-dg/gimplefe-43.c new file mode 100644 index 0000000000..5fd66e6dfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-43.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE foo() +{ + try + { + try + { + ; + } + finally + { + ; + } + else + { + ; + } + } + finally + { + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-44.c b/SingleSource/Regression/C/gcc-dg/gimplefe-44.c new file mode 100644 index 0000000000..3c83d4946f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-44.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target exceptions } */ +/* { dg-options "-fexceptions -fgimple -fdump-tree-eh-eh" } */ +/* { dg-require-effective-target nonlocal_goto } */ + +void __GIMPLE foo() +{ + try + { + try + { + extern void might_throw1 (); + might_throw1 (); + } + finally + { + extern void might_throw2 (); + might_throw2 (); + } + else + { + extern void might_throw3 (); + might_throw3 (); + } + } + finally + { + extern void might_throw4 (); + might_throw4 (); + } +} + +/* { dg-final { scan-tree-dump ".LP 1. might_throw1" "eh" } } */ +/* { dg-final { scan-tree-dump ".LP 2. might_throw2" "eh" } } */ +/* { dg-final { scan-tree-dump ".LP 2. might_throw3" "eh" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-45.c b/SingleSource/Regression/C/gcc-dg/gimplefe-45.c new file mode 100644 index 0000000000..8e1447ff3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-45.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgimple" } */ + +/* This used to ICE when simplifying (A & C) != 0 ? D : 0 + for pointer types. */ + +int *__GIMPLE () +p (int n) +{ + int *_2; + int *_t; + int *_t1; + _Bool _3; + _t = (int*)8; + _t1 = 0; + n = n & 2; + _3 = n != 0; + _2 = _3 ? _t : _t1; + return _2; +} + diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-46.c b/SingleSource/Regression/C/gcc-dg/gimplefe-46.c new file mode 100644 index 0000000000..fb91f7d2a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-46.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +char global[10]; + +void bar (void); + +void __GIMPLE (ssa) +foo (char * p) +{ + __BB(2): + if (p_2(D) == _Literal (char *)&global[2]) + goto __BB3; + else + goto __BB4; + + __BB(3): + bar (); + goto __BB4; + + __BB(4): + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-47.c b/SingleSource/Regression/C/gcc-dg/gimplefe-47.c new file mode 100644 index 0000000000..3bbd34d669 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-47.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +char * begfield (int tab, char * ptr, char * lim, int sword, int schar); + +int __GIMPLE (ssa) +main () +{ + char * lim; + char * s; + char * _1; + + __BB(2): + _1 = begfield (58, ":ab", &__MEM ((void *)&":ab" + _Literal +(void *) 3), 1, 1); + if (_1 != _Literal (char *) &__MEM ((void *)&":ab" + _Literal (void *) 2)) + goto __BB3; + else + goto __BB4; + + __BB(3): + __builtin_abort (); + + __BB(4): + __builtin_exit (0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-48.c b/SingleSource/Regression/C/gcc-dg/gimplefe-48.c new file mode 100644 index 0000000000..1399cc9d79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-48.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -Wno-psabi -w" } */ +/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */ + +typedef int v8si __attribute__((vector_size(8*sizeof(int)))); +typedef v8si v8sib __attribute__((vector_mask)); + +v8si res; + +void __GIMPLE (ssa) foo (v8si v1, v8si v2, v8si v3, v8si v4) +{ + v8sib tem; + v8si resr; + +__BB(2): + tem_3 = v1_1(D) <= v2_2(D); + resr_4 = tem_3 ? v3_5(D) : v4_6(D); + res = resr_4; + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-49.c b/SingleSource/Regression/C/gcc-dg/gimplefe-49.c new file mode 100644 index 0000000000..d28dc70841 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-49.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +__GIMPLE (ssa) int * +bar (int i, int a, int b) +{ + int * _3; + int *p; + +__BB(2): + if (i_24(D) <= 0) + goto __BB3; + else + goto __BB4; + +__BB(3): + _3 = &a; + goto __BB5; + +__BB(4): + p_4 = &b; + goto __BB5; + +__BB(5): + p_5 = __PHI (__BB3: _3, __BB4: p_4); + return p_5; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-5.c b/SingleSource/Regression/C/gcc-dg/gimplefe-5.c new file mode 100644 index 0000000000..1dab4af4f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-5.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int a; +void __GIMPLE () foo () +{ + int b; + int c; + +bb_2: + b = a; + if (b > 3) + goto bb_3; + else + goto bb_4; + +bb_3: + b = c + 4; + goto bb_5; + +bb_4: + b = b + 1; + goto bb_5; + +bb_5: + a = b; + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-6.c b/SingleSource/Regression/C/gcc-dg/gimplefe-6.c new file mode 100644 index 0000000000..242e08fe1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-6.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE () foo () +{ + int a; + int b; + int c; + int d; + +bb_2: + a = ~b; + b = a << c; + c = a & b; + d = b | c; + +bb_3: + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-7.c b/SingleSource/Regression/C/gcc-dg/gimplefe-7.c new file mode 100644 index 0000000000..ad34e85b50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-7.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE (ssa) foo () +{ + int a; + +__BB(2): + if (a_5(D) > 4) + goto __BB3; + else + goto __BB4; + +__BB(3): + a_2 = 10; + goto __BB5; + +__BB(4): + a_3 = 20; + goto __BB5; + +__BB(5): + a_1 = __PHI (__BB3: a_2, __BB4: a_3); + a_4 = a_1 + 4; + +return; +} + diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-8.c b/SingleSource/Regression/C/gcc-dg/gimplefe-8.c new file mode 100644 index 0000000000..4936bec334 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-8.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE () foo () +{ + int a; + int b; + +bb_2: + b = a_1(D) + 1; +bb_3: + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-9.c b/SingleSource/Regression/C/gcc-dg/gimplefe-9.c new file mode 100644 index 0000000000..a24be273ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-9.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE() bar() +{ + int a; + a = a + 1; + return a; +} + +void __GIMPLE() foo() +{ + int b; + b = bar(); +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-1.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-1.c new file mode 100644 index 0000000000..5b870f14a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE () foo (int a) +{ +bb_2: + a = *b; /* { dg-error "undeclared" } */ + +bb_3: + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-10.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-10.c new file mode 100644 index 0000000000..13d86ac5d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-10.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +__GIMPLE +void foo() { + int t1; + t1_1 = t1_1(); /* { dg-error "invalid call" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-11.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-11.c new file mode 100644 index 0000000000..9c29717676 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-11.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int bar(); +__GIMPLE +int foo() +{ + if (bar()) /* { dg-error "comparison required" } */ + goto bb1; + else + goto bb2; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-12.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-12.c new file mode 100644 index 0000000000..981ff7ba49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-12.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int get_current (); + +__GIMPLE +void foo() +{ + get_current()->flags; /* { dg-error "non-pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-13.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-13.c new file mode 100644 index 0000000000..637ed322ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-13.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +__GIMPLE (ssa) void +bar (void) +{ + int _3; + +__BB(2): + return; +} /* { dg-error "version 3 has no definition" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-14.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-14.c new file mode 100644 index 0000000000..3e1a13219b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-14.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE () foo () +{ + int _1; + return a_1(D); /* { dg-error "cannot have default definition" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-15.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-15.c new file mode 100644 index 0000000000..066cd845d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-15.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +unsigned a; +static double *d; +static _Bool b; +__GIMPLE int +foo (int n) +{ + b = __builtin_add_overflow (n, *d, &a); +} /* { dg-error "invalid argument" } */ + +/* { dg-message "" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-2.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-2.c new file mode 100644 index 0000000000..216623e6d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE () +main (int argc, char * * argv) +{ + +bb_2: + switch (a) {default: L2; case 1: L0; case 2: L1; } /* { dg-error "undeclared" } */ + +L0: + a = 0; + goto bb_6; + +L1: + a = 3; + goto L2; + +L2: + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-3.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-3.c new file mode 100644 index 0000000000..9209bbaeb7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE foo() +{ + if (a != 2) /* { dg-error "undeclared" } */ + goto bb1; + else + goto bb2; + +bb1: + a_1 = 10; /* { dg-error "undeclared" } */ + return a_1; + +bb2: + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-4.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-4.c new file mode 100644 index 0000000000..b2ca796656 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-4.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +__GIMPLE() void a() +{ + *0 = 1; /* { dg-error "expected pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-5.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-5.c new file mode 100644 index 0000000000..2bdb398252 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-5.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +__GIMPLE() void a() +{ + __MEM() = 0; /* { dg-error "expected .<." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-6.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-6.c new file mode 100644 index 0000000000..c73b85c1e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-6.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void a(int); + +__GIMPLE() void b() +{ + a_2 = 0; /* { dg-error "invalid" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-7.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-7.c new file mode 100644 index 0000000000..7d5ff374a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-7.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +__GIMPLE() void fn1() +{ + if (1) + goto + else /* { dg-error "expected label" } */ + goto lbl; +} + +__GIMPLE() void fn2() +{ + if (1) + goto lbl; + else + goto ; /* { dg-error "expected label" } */ +} + +__GIMPLE() void fn3() +{ + if (1) + goto lbl; + else + goto +} /* { dg-error "expected label" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-8.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-8.c new file mode 100644 index 0000000000..59e81eb4b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-8.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE() f(int x, int y) +{ + int a; + a = (x < y) ? 1 : 2; /* { dg-error "expected" } */ + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/gimplefe-error-9.c b/SingleSource/Regression/C/gcc-dg/gimplefe-error-9.c new file mode 100644 index 0000000000..87014c1cbb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gimplefe-error-9.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void __GIMPLE +foo() +{ +bb1: +bb1:; /* { dg-error "duplicate" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/globalalias-2.c b/SingleSource/Regression/C/gcc-dg/globalalias-2.c new file mode 100644 index 0000000000..ab6db292e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/globalalias-2.c @@ -0,0 +1,21 @@ +/* { dg-require-alias "" } */ +int test2count; +extern void abort (void); +static +void test(void) +{ + test2count++; +} +__attribute__ ((weak,noinline)) +__attribute ((alias("test"))) +void test2(void); + +void tt() +{ + int prev = test2count; + /* This call must bind locally. */ + test(); + if (test2count == prev) + abort(); + test2(); + } diff --git a/SingleSource/Regression/C/gcc-dg/globalalias.c b/SingleSource/Regression/C/gcc-dg/globalalias.c new file mode 100644 index 0000000000..69cd4abf86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/globalalias.c @@ -0,0 +1,42 @@ +/* This test checks that local aliases behave sanely. This is necessary for code correctness + of aliases introduced by ipa-visibility pass. + + This test expose weird behavior of AIX's .set pseudo-op where the global symbol is created, + but all uses of the alias are syntactically replaced by uses of the target. This means that + both counters are increased to 2. */ + +/* { dg-do run } + { dg-options "-O2" } + { dg-require-alias "" } + { dg-additional-sources "globalalias-2.c" } */ +extern int test2count; +extern void abort (void); +extern void tt (); +int testcount; +static +void test(void) +{ + testcount++; +} +__attribute__ ((weak,noinline)) +__attribute ((alias("test"))) +void test2(void); + +int main() +{ + test(); + /* This call must bind locally. */ + if (!testcount) + abort (); + test2(); + /* Depending on linker choice, this one may bind locally + or to the other unit. */ + if (!testcount && !test2count) + abort(); + tt(); + + if ((testcount != 1 || test2count != 3) + && (testcount != 3 || test2count != 1)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-1.c b/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-1.c new file mode 100644 index 0000000000..0f0bb21422 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-1.c @@ -0,0 +1,13 @@ +/* Test diagnostic for GNU extension: omitting middle term of + conditional expression. Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +int a, b, c; + +void +f (void) +{ + c = (++a ? : b); +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-2.c b/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-2.c new file mode 100644 index 0000000000..fed5adf15b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-2.c @@ -0,0 +1,13 @@ +/* Test diagnostic for GNU extension: omitting middle term of + conditional expression. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic" } */ + +int a, b, c; + +void +f (void) +{ + c = (++a ? : b); /* { dg-warning "ISO C forbids omitting the middle term of a '\\?:' expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-3.c b/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-3.c new file mode 100644 index 0000000000..08657ff737 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu-cond-expr-3.c @@ -0,0 +1,13 @@ +/* Test diagnostic for GNU extension: omitting middle term of + conditional expression. Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +int a, b, c; + +void +f (void) +{ + c = (++a ? : b); /* { dg-error "ISO C forbids omitting the middle term of a '\\?:' expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu-predef-1.c b/SingleSource/Regression/C/gcc-dg/gnu-predef-1.c new file mode 100644 index 0000000000..9c7eebf75e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu-predef-1.c @@ -0,0 +1,14 @@ +/* Test that we diagnose the __FUNCTION__ and the __PRETTY_FUNCTION__ + predefined identifiers in pedantic mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -pedantic" } */ + +void +foo (void) +{ + const char *s; + s = __FUNCTION__; /* { dg-warning " ISO C does not support .__FUNCTION__. predefined identifier" } */ + s = __PRETTY_FUNCTION__; /* { dg-warning " ISO C does not support .__PRETTY_FUNCTION__. predefined identifier" } */ + s = __extension__ __FUNCTION__; + s = __extension__ __PRETTY_FUNCTION__; +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu11-align-1.c b/SingleSource/Regression/C/gcc-dg/gnu11-align-1.c new file mode 100644 index 0000000000..50522d7bed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu11-align-1.c @@ -0,0 +1,8 @@ +/* Test C11 alignment support. Test code valid after the resolution + of DR#444: alignment specifiers for compound literals in _Alignof. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +#include + +size_t align = _Alignof (_Alignas (_Alignof (max_align_t)) char) { 1 }; diff --git a/SingleSource/Regression/C/gcc-dg/gnu11-typeof-1.c b/SingleSource/Regression/C/gcc-dg/gnu11-typeof-1.c new file mode 100644 index 0000000000..6477c78bd3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu11-typeof-1.c @@ -0,0 +1,6 @@ +/* Test typeof and typeof_unqual not keywords with -std=gnu11 -fno-asm. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -fno-asm" } */ + +int typeof = 1; +long typeof_unqual = 2; diff --git a/SingleSource/Regression/C/gcc-dg/gnu11-typeof-2.c b/SingleSource/Regression/C/gcc-dg/gnu11-typeof-2.c new file mode 100644 index 0000000000..e60ad466c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu11-typeof-2.c @@ -0,0 +1,39 @@ +/* Test typeof propagation of noreturn function attributes with -std=gnu11: + these are part of the type of a function pointer with GNU typeof, but not + with C2x typeof. */ +/* { dg-do link } */ +/* { dg-options "-std=gnu11 -O2" } */ + +_Noreturn void f (void); + +typeof (&f) volatile p; +typeof (&p) volatile pp; + +void link_failure (void); + +void +g (void) +{ + (*p) (); + link_failure (); +} + +void +h (void) +{ + (**pp) (); + link_failure (); +} + +volatile int flag; +volatile int x; + +int +main (void) +{ + if (flag) + g (); + if (flag) + h (); + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu11-typeof-3.c b/SingleSource/Regression/C/gcc-dg/gnu11-typeof-3.c new file mode 100644 index 0000000000..0ae5e5bb8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu11-typeof-3.c @@ -0,0 +1,177 @@ +/* Test GNU extensions __typeof__ and __typeof_unqual__. Valid code. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu11" } */ + +int i; +extern __typeof__ (i) i; +extern __typeof (int) i; +extern __typeof_unqual__ (i) i; +extern __typeof_unqual (int) i; + +volatile int vi; +extern __typeof__ (volatile int) vi; +extern __typeof (vi) vi; + +extern __typeof_unqual__ (volatile int) i; +extern __typeof_unqual__ (vi) i; +extern __typeof__ ((const int) vi) i; +extern __typeof ((volatile int) vi) i; + +const int ci; +extern __typeof (const int) ci; +extern __typeof (ci) ci; + +extern __typeof_unqual (const int) i; +extern __typeof_unqual (ci) i; +extern __typeof__ ((const int) ci) i; +extern __typeof__ (+ci) i; +extern __typeof (0, ci) i; +extern __typeof__ (1 ? ci : ci) i; +extern __typeof (0) i; + +const int fci (void); +extern __typeof__ (fci ()) i; + +_Atomic int ai; +extern __typeof (_Atomic int) ai; +extern __typeof__ (_Atomic (int)) ai; +extern __typeof (ai) ai; + +extern __typeof_unqual__ (_Atomic int) i; +extern __typeof_unqual (_Atomic (int)) i; +extern __typeof_unqual__ (ai) i; +extern __typeof (+ai) i; +extern __typeof__ ((_Atomic int) ai) i; +extern __typeof__ (0, ai) i; +extern __typeof (1 ? ai : ai) i; + +_Atomic int fai (void); +extern __typeof__ (fai ()) i; + +_Atomic const volatile int acvi; +extern __typeof (int volatile const _Atomic) acvi; +extern __typeof (acvi) acvi; +extern const _Atomic volatile __typeof (acvi) acvi; +extern _Atomic volatile __typeof__ (ci) acvi; +extern _Atomic const __typeof (vi) acvi; +extern const __typeof__ (ai) volatile acvi; + +extern __typeof_unqual (acvi) i; +extern __typeof_unqual__ (__typeof (acvi)) i; +extern __typeof_unqual (_Atomic __typeof_unqual__ (acvi)) i; + +extern _Atomic __typeof_unqual (acvi) ai; + +char c; +volatile char vc; +volatile char *pvc; +volatile char *const cpvc; +const char *pcc; +const char *volatile vpcc; +__typeof (*vpcc) cc; + +extern __typeof__ (*cpvc) vc; +extern __typeof_unqual (*cpvc) c; +extern __typeof_unqual__ (cpvc) pvc; +extern __typeof_unqual__ (vpcc) pcc; +extern const char cc; + +extern __typeof (++vi) i; +extern __typeof (++ai) i; +extern __typeof__ (--vi) i; +extern __typeof (--ai) i; +extern __typeof__ (vi++) i; +extern __typeof__ (ai++) i; +extern __typeof (vi--) i; +extern __typeof__ (ai--) i; + +_Bool b; +volatile _Bool vb; +_Atomic _Bool ab; +extern __typeof__ (++vb) b; +extern __typeof__ (++ab) b; +extern __typeof (--vb) b; +extern __typeof__ (--ab) b; +extern __typeof (vb++) b; +extern __typeof (ab++) b; +extern __typeof__ (vb--) b; +extern __typeof (ab--) b; + +extern __typeof__ (vc = 1) c; +extern __typeof__ (vpcc = 0) pcc; +extern __typeof (ai *= 2) i; + +int s = sizeof (__typeof__ (int (*)[++i])); + +void *vp; + +extern void abort (void); +extern void exit (int); + +extern int only_used_in_typeof; + +static int not_defined (void); + +__typeof (i) +main (__typeof (*vp)) +{ + volatile __typeof__ (only_used_in_typeof) ii = 2; + if (ii != 2) + abort (); + const __typeof__ (not_defined ()) jj = 3; + if (jj != 3) + abort (); + unsigned int u = 1; + __typeof__ (u) u2 = 0; + __typeof (int (*)[++u2]) p = 0; + if (u2 != 1) + abort (); + if (sizeof (*p) != sizeof (int)) + abort (); + __typeof_unqual (int (*)[++u2]) q = 0; + if (u2 != 2) + abort (); + if (sizeof (*q) != 2 * sizeof (int)) + abort (); + if (sizeof (*p) != sizeof (int)) + abort (); + __typeof (++u2) u3 = 1; + if (u2 != u + u3) + abort (); + __typeof_unqual__ (++u2) u4 = 2; + if (u2 != u4) + abort (); + u = sizeof (__typeof__ (int (*)[++u2])); + if (u2 != 2) + abort (); + u = sizeof (__typeof_unqual (int (*)[++u2])); + if (u2 != 2) + abort (); + __typeof ((int (*)[++u2]) 0) q2; + if (u2 != 3) + abort (); + __typeof ((void) 0, (int (*)[++u2]) 0) q3; + if (u2 != 4) + abort (); + __typeof__ ((int (*)[++u2]) 0, 0) q4; + if (u2 != 4) + abort (); + __typeof_unqual ((int (*)[++u2]) 0) q5; + if (u2 != 5) + abort (); + __typeof_unqual__ ((void) 0, (int (*)[++u2]) 0) q6; + if (u2 != 6) + abort (); + __typeof_unqual__ ((int (*)[++u2]) 0, 0) q7; + if (u2 != 6) + abort (); + int a1[6], a2[6]; + int (*pa)[u2] = &a1; + __typeof (pa = &a2) pp; + if (pa != &a2) + abort (); + __typeof_unqual (pa = &a1) pp2; + if (pa != &a1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu11-typeof-4.c b/SingleSource/Regression/C/gcc-dg/gnu11-typeof-4.c new file mode 100644 index 0000000000..313ee97875 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu11-typeof-4.c @@ -0,0 +1,58 @@ +/* Test GNU extensions __typeof__ and __typeof_unqual__. Invalid code. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +struct s { int i : 2; } x; +union u { unsigned int j : 1; } y; + +__typeof__ (x.i) j; /* { dg-error "applied to a bit-field" } */ +__typeof_unqual__ (x.i) j2; /* { dg-error "applied to a bit-field" } */ +__typeof (y.j) j3; /* { dg-error "applied to a bit-field" } */ +__typeof_unqual (y.j) j4; /* { dg-error "applied to a bit-field" } */ + +static int ok (void); +static int also_ok (void); +static int not_defined (void); /* { dg-warning "used but never defined" } */ +static int also_not_defined (void); /* { dg-warning "used but never defined" } */ + +_Noreturn void nf1 (void); +__attribute__((noreturn)) void nf2 (void); +void fg (void) {} +__typeof__ (&nf1) pnf1 = fg; /* { dg-warning "qualified function pointer from unqualified" } */ +__typeof (&nf2) pnf2 = fg; /* { dg-warning "qualified function pointer from unqualified" } */ +extern void (*pnf1) (void); /* { dg-error "conflicting types for" } */ +extern void (*pnf2) (void); /* { dg-error "conflicting types for" } */ +extern __typeof (nf1) *pnf1; /* { dg-error "conflicting types for" } */ +extern __typeof (nf1) *pnf2; /* { dg-error "conflicting types for" } */ +extern __typeof__ (nf2) *pnf1; /* { dg-error "conflicting types for" } */ +extern __typeof__ (nf2) *pnf2; /* { dg-error "conflicting types for" } */ +__typeof (*&nf1) fg2, fg2a, fg2b; +__typeof__ (*&nf2) fg3, fg3a, fg3b; +__typeof (nf1) fg4, fg4a, fg4b; +__typeof__ (nf2) fg5, fg5a, fg5b; + +extern void abort (void); + +void fg2 (void) {} /* { dg-error "conflicting type qualifiers for" } */ +_Noreturn void fg2a (void) { abort (); } /* { dg-error "conflicting type qualifiers for" } */ +__attribute__((noreturn)) void fg2b (void) { abort (); } /* { dg-error "conflicting type qualifiers for" } */ +void fg3 (void) {} /* { dg-error "conflicting type qualifiers for" } */ +_Noreturn void fg3a (void) { abort (); } /* { dg-error "conflicting type qualifiers for" } */ +__attribute__((noreturn)) void fg3b (void) { abort (); } /* { dg-error "conflicting type qualifiers for" } */ +void fg4 (void) {} +_Noreturn void fg4a (void) { abort (); } +__attribute__((noreturn)) void fg4b (void) { abort (); } +void fg5 (void) {} +_Noreturn void fg5a (void) { abort (); } +__attribute__((noreturn)) void fg5b (void) { abort (); } + +void +f (void) +{ + __typeof__ (ok ()) x = 2; + __typeof_unqual (also_ok ()) y = 2; + int a[2]; + int (*p)[x] = &a; + __typeof (p + not_defined ()) q; + __typeof_unqual__ (p + also_not_defined ()) q2; +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu11-version-1.c b/SingleSource/Regression/C/gcc-dg/gnu11-version-1.c new file mode 100644 index 0000000000..56efbd43bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu11-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C11 with GNU extensions. Test -std=gnu11. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201112L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-attr-syntax-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-attr-syntax-1.c new file mode 100644 index 0000000000..bd21086475 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-attr-syntax-1.c @@ -0,0 +1,16 @@ +/* Test C2x attribute syntax. Basic tests of valid uses of empty + attributes with GNU C features. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +/* Attributes can be used in declarations after __extension__, and + before asm statements. */ + +__extension__ [[]] int a; + +void +f (void) +{ + __extension__ [[]] int b; + [[]] asm (""); +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-attr-syntax-2.c b/SingleSource/Regression/C/gcc-dg/gnu2x-attr-syntax-2.c new file mode 100644 index 0000000000..97d1654d9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-attr-syntax-2.c @@ -0,0 +1,16 @@ +/* Test C2x attribute syntax. Invalid uses of attributes with GNU C + features. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x -w" } */ + +/* Attributes cannot be used as prefix attributes on old-style + parameter declarations or on function declarators with identifier + lists (removed from C2x). */ + +void (*f(a, b) [[]])() int a, b; { } /* { dg-error "expected" } */ + +void f(x, y) int x; [[]] int y; { } /* { dg-error "expected" } */ + +/* Nonempty attributes cannot be used as postfix attributes with + __auto_type. */ +__auto_type [[gnu::no_such_attr]] x = 1; /* { dg-error "'__auto_type' followed by" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-attrs-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-attrs-1.c new file mode 100644 index 0000000000..2007911e72 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-attrs-1.c @@ -0,0 +1,72 @@ +/* Test C2x attribute syntax. Test GNU attributes appertain to + appropriate constructs. */ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-options "-std=gnu2x" } */ + +void f (void) {}; + +[[gnu::alias("f")]] void g (void); /* { dg-error "only weak" "" { target *-*-darwin* } } */ + +void [[gnu::alias("f")]] h (void); /* { dg-warning "does not apply to types" } */ + +struct [[gnu::packed]] s { int a; char b; }; +_Static_assert (sizeof (struct s) == (sizeof (int) + sizeof (char))); + +int +f2 (void) +{ + [[gnu::deprecated]] int a = 1; + return a; /* { dg-warning "deprecated" } */ +} + +int +f3 (void) +{ + int a [[gnu::deprecated]] = 1; + return a; /* { dg-warning "deprecated" } */ +} + +struct s2 { [[gnu::deprecated]] int a; int b [[gnu::deprecated]]; } x; + +int +f4 (void) +{ + return x.a; /* { dg-warning "deprecated" } */ +} + +int +f5 (void) +{ + return x.b; /* { dg-warning "deprecated" } */ +} + +enum e { E1 [[gnu::deprecated]] }; + +enum e +f6 (void) +{ + return E1; /* { dg-warning "deprecated" } */ +} + +int +f7 ([[gnu::deprecated]] int y) +{ + return y; /* { dg-warning "deprecated" } */ +} + +union [[gnu::deprecated]] u { int x; }; + +void +f8 (void) +{ + union u var; /* { dg-warning "deprecated" } */ +} + +enum [[gnu::deprecated]] edep { E2 }; + +void +f9 (void) +{ + enum edep var; /* { dg-warning "deprecated" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-attrs-2.c b/SingleSource/Regression/C/gcc-dg/gnu2x-attrs-2.c new file mode 100644 index 0000000000..d512b2a2ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-attrs-2.c @@ -0,0 +1,33 @@ +/* Test C2x attribute syntax. Test GNU attributes appertain to + appropriate constructs. Attributes on types not being defined at + the time. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x -Wformat" } */ + +typedef void va_type (const char *, ...); +typedef va_type [[gnu::format (printf, 1, 2)]] printf_like_1; +typedef void printf_like_2 (const char *, ...) [[gnu::format (printf, 1, 2)]]; +typedef __typeof__ (void (const char *, ...) [[gnu::format (printf, 1, 2)]]) + printf_like_3; + +va_type func1; +printf_like_1 func2; +printf_like_2 func3; +printf_like_3 func4; +va_type [[gnu::format (printf, 1, 2)]] *func5 (void); + +void +func_test (void) +{ + func1 ("%s", 1); + func2 ("%s", 1); /* { dg-warning "expects argument" } */ + func3 ("%s", 1); /* { dg-warning "expects argument" } */ + func4 ("%s", 1); /* { dg-warning "expects argument" } */ + func5 () ("%s", 1); /* { dg-warning "expects argument" } */ +} + +typedef int A[2]; + +__typeof__ (int [[gnu::deprecated]]) var1; /* { dg-warning "deprecated" } */ +__typeof__ (A [[gnu::deprecated]]) var2; /* { dg-warning "deprecated" } */ +__typeof__ (int [3] [[gnu::deprecated]]) var3; /* { dg-warning "deprecated" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-auto-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-auto-1.c new file mode 100644 index 0000000000..e0b9e867d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-auto-1.c @@ -0,0 +1,11 @@ +/* Test C2x auto. Invalid code with GNU extensions. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +void +f () +{ + /* Do not allow a non-definition declaration of a tag in the auto + initializer, to avoid it escaping an inner scope as shown here. */ + auto x = ({ struct s; struct s *x = 0; x; }); /* { dg-error "declared in underspecified object initializer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-builtins-no-dfp-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-builtins-no-dfp-1.c new file mode 100644 index 0000000000..853a56e9a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-builtins-no-dfp-1.c @@ -0,0 +1,18 @@ +/* Test C2x built-in functions: test DFP built-in functions are not + available when no DFP support. Bug 91985. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=gnu2x" } */ + +int fabsd32 (void); +int fabsd64 (void); +int fabsd128 (void); +int nand32 (void); +int nand64 (void); +int nand128 (void); + +__typeof__ (__builtin_fabsd32 (0)) d32; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_fabsd64 (0)) d64; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_fabsd128 (0)) d128; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_nand32 (0)) d32n; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_nand64 (0)) d64n; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_nand128 (0)) d128n; /* { dg-warning "implicit" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-complit-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-complit-1.c new file mode 100644 index 0000000000..e9da5ad795 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-complit-1.c @@ -0,0 +1,7 @@ +/* Test C2x storage class specifiers in compound literals: GNU use of alignof + on objects (tested separately since alignof parsing handles the type name of + compound literals). */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +int a = alignof (static int) { 0 }; diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-complit-2.c b/SingleSource/Regression/C/gcc-dg/gnu2x-complit-2.c new file mode 100644 index 0000000000..20cb38fd94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-complit-2.c @@ -0,0 +1,18 @@ +/* Test C2x storage class specifiers in compound literals. Thread-local + cases, compilation tests, GNU __thread used. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-require-effective-target tls } */ + +#include + +/* __thread is OK at file scope, although of limited use since the + thread-local object and its address are not constant expressions. */ +size_t st = sizeof (__thread int) { 1 }; +size_t sst = sizeof (static __thread int) { 1 }; + +int * +f () +{ + return &(static __thread int) { 2 }; +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-constexpr-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-constexpr-1.c new file mode 100644 index 0000000000..6078f0807e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-constexpr-1.c @@ -0,0 +1,17 @@ +/* Test C2x constexpr. Valid code using GNU extensions, compilation tests. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +struct s { struct { int x, y; } x; }; +constexpr struct s v = { { 123, 150 } }; +int k; +constexpr int a[200] = { [v.x.x ... v.x.y] = 7 }; + +void +f () +{ + switch (k) + { + case v.x.x ... v.x.y: ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-empty-init-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-empty-init-1.c new file mode 100644 index 0000000000..e7dc9dfde2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-empty-init-1.c @@ -0,0 +1,29 @@ +/* Test C2X support for empty initializers: valid use cases with GNU + extensions. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu2x" } */ + +extern void exit (int); +extern void abort (void); + +void +f (int a) +{ + struct s { volatile int x[a]; }; + struct s b = {}; + for (int i = 0; i < a; i++) + if (b.x[i] != 0) + abort (); + /* Overwrite contents of b.x before second call to make it more likely stack + contents are nonzero if proper initialization did not occur. */ + for (int i = 0; i < a; i++) + b.x[i] = -1; +} + +int +main (void) +{ + f (100); + f (100); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-empty-init-2.c b/SingleSource/Regression/C/gcc-dg/gnu2x-empty-init-2.c new file mode 100644 index 0000000000..69ee4e36b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-empty-init-2.c @@ -0,0 +1,16 @@ +/* Test C2X support for empty initializers: invalid use cases with GNU + extensions. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +void +f (int a) +{ + /* Make sure a non-braced initializer for a VLA-in-struct is still not + allowed. */ + struct s { int x[a]; }; + struct s b; + for (int i = 0; i < a; i++) + b.x[i] = 0; + struct s c = b; /* { dg-error "variable-sized object may not be initialized except with an empty initializer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-enum-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-enum-1.c new file mode 100644 index 0000000000..b72ed7380e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-enum-1.c @@ -0,0 +1,11 @@ +/* Test C2x enumerations with fixed underlying type together with GNU + extensions: an enum cannot be forward declared without a fixed underlying + type and then declared or defined with one. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +enum e1; +enum e1 : int; /* { dg-error "'enum' declared both with and without fixed underlying type" } */ + +enum e2; +enum e2 : long { A }; /* { dg-error "'enum' declared both with and without fixed underlying type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-static-assert-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-static-assert-1.c new file mode 100644 index 0000000000..4ed095cb3c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-static-assert-1.c @@ -0,0 +1,6 @@ +/* Test C11 static assertions. Omitting the string diagnosed with + -Wc11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x -Wc11-c2x-compat" } */ + +_Static_assert (1); /* { dg-warning "does not support omitting the string" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-stdarg-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-stdarg-1.c new file mode 100644 index 0000000000..bb64cdeb48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-stdarg-1.c @@ -0,0 +1,8 @@ +/* Test variadic functions with no named parameters do not accept GNU + attributes before '...'. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +int f (__attribute__(()) ...); /* { dg-error "expected" } */ +int g (int (__attribute__(()) ...)); /* { dg-error "expected" } */ +int h (__attribute__(()) ...) { return 0; } /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-typeof-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-typeof-1.c new file mode 100644 index 0000000000..f14b54f1f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-typeof-1.c @@ -0,0 +1,39 @@ +/* Test __typeof__ propagation of noreturn function attributes with -std=gnu2x: + these are part of the type of a function pointer with GNU __typeof__, but + not with C2x typeof. */ +/* { dg-do link } */ +/* { dg-options "-std=gnu2x -O2" } */ + +_Noreturn void f (void); + +__typeof__ (&f) volatile p; +__typeof__ (&p) volatile pp; + +void link_failure (void); + +void +g (void) +{ + (*p) (); + link_failure (); +} + +void +h (void) +{ + (**pp) (); + link_failure (); +} + +volatile int flag; +volatile int x; + +int +main (void) +{ + if (flag) + g (); + if (flag) + h (); + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-utf8char-1.c b/SingleSource/Regression/C/gcc-dg/gnu2x-utf8char-1.c new file mode 100644 index 0000000000..9c3add2ae8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-utf8char-1.c @@ -0,0 +1,5 @@ +/* Test C2x UTF-8 characters. Test accepted with -std=gnu2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +#include "c2x-utf8char-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-utf8str-type.c b/SingleSource/Regression/C/gcc-dg/gnu2x-utf8str-type.c new file mode 100644 index 0000000000..efe16ffc28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-utf8str-type.c @@ -0,0 +1,5 @@ +/* Test C2X UTF-8 string literal type with -std=gnu2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +#include "c2x-utf8str-type.c" diff --git a/SingleSource/Regression/C/gcc-dg/gnu2x-utf8str.c b/SingleSource/Regression/C/gcc-dg/gnu2x-utf8str.c new file mode 100644 index 0000000000..f3719ea8c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu2x-utf8str.c @@ -0,0 +1,34 @@ +/* Test initialization by UTF-8 string literal in C2X with -std=gnu2x. */ +/* { dg-do compile } */ +/* { dg-require-effective-target wchar } */ +/* { dg-options "-std=gnu2x" } */ + +typedef __CHAR8_TYPE__ char8_t; +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; +typedef __WCHAR_TYPE__ wchar_t; + +/* Test that char, signed char, unsigned char, and char8_t arrays can be + initialized by a UTF-8 string literal. */ +const char cbuf1[] = u8"text"; +const char cbuf2[] = { u8"text" }; +const signed char scbuf1[] = u8"text"; +const signed char scbuf2[] = { u8"text" }; +const unsigned char ucbuf1[] = u8"text"; +const unsigned char ucbuf2[] = { u8"text" }; +const char8_t c8buf1[] = u8"text"; +const char8_t c8buf2[] = { u8"text" }; + +/* Test that a diagnostic is issued for attempted initialization of + other character types by a UTF-8 string literal. */ +const char16_t c16buf1[] = u8"text"; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const char16_t c16buf2[] = { u8"text" }; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const char32_t c32buf1[] = u8"text"; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const char32_t c32buf2[] = { u8"text" }; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const wchar_t wbuf1[] = u8"text"; /* { dg-error "from a string literal with type array of .unsigned char." } */ +const wchar_t wbuf2[] = { u8"text" }; /* { dg-error "from a string literal with type array of .unsigned char." } */ + +/* Test that char8_t arrays can be initialized by an ordinary string + literal. */ +const char8_t c8buf3[] = "text"; +const char8_t c8buf4[] = { "text" }; diff --git a/SingleSource/Regression/C/gcc-dg/gnu89-const-expr-1.c b/SingleSource/Regression/C/gcc-dg/gnu89-const-expr-1.c new file mode 100644 index 0000000000..0af5787314 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu89-const-expr-1.c @@ -0,0 +1,56 @@ +/* Test for constant expressions: GNU extensions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic-errors" } */ + +int n; + +void +f (void) +{ + int i = 0; + int a[n]; /* { dg-error "ISO C90 forbids variable length array" } */ + enum e1 { + /* Integer constant expressions may not contain statement + expressions (not a permitted operand). */ + E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant expression" } */ + /* { dg-error "ISO C forbids braced-groups" "ISO" { target *-*-* } .-1 } */ + /* Real and imaginary parts act like other arithmetic + operators. */ + E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant expression" } */ + E3 = __real__ 0, + E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */ + E5 = __imag__ 0, + /* __alignof__ always constant. */ + E6 = __alignof__ (int[n]), /* { dg-error "ISO C90 forbids variable length array" } */ + E7 = __alignof__ (a), + /* __extension__ ignored for constant expression purposes. */ + E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant expression" } */ + E9 = __extension__ 0, + /* Conditional expressions with omitted arguments act like the + standard type. */ + E10 = (1 ? : i++), /* { dg-error "constant expression" } */ + /* { dg-error "ISO C forbids omitting" "ISO" { target *-*-* } .-1 } */ + E11 = (1 ? : 0) /* { dg-error "ISO C forbids omitting" } */ + }; + enum e2 { + /* Complex integer constants may be cast directly to integer + types, but not after further arithmetic on them. */ + F1 = (int) (_Complex int) 2i, /* { dg-error "constant expression" } */ + /* { dg-error "complex" "complex" { target *-*-* } .-1 } */ + /* { dg-error "imaginary" "imaginary" { target *-*-* } .-2 } */ + F2 = (int) +2i, /* { dg-error "constant expression" } */ + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + F3 = (int) (1 + 2i), /* { dg-error "constant expression" } */ + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + F4 = (int) 2i /* { dg-error "imaginary" } */ + }; + static double dr = __real__ (1.0 + 2.0i); + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + static double di = __imag__ (1.0 + 2.0i); + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + /* Statement expressions allowed in unevaluated subexpressions in + initializers in gnu99 but not gnu89. */ + static int j = (1 ? 0 : ({ 0; })); /* { dg-error "constant expression" } */ + /* { dg-error "braced" "ISO" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu89-const-expr-2.c b/SingleSource/Regression/C/gcc-dg/gnu89-const-expr-2.c new file mode 100644 index 0000000000..9d8678f577 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu89-const-expr-2.c @@ -0,0 +1,26 @@ +/* Test for constant expressions: __builtin_choose_expr. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -pedantic-errors" } */ + +#include + +int a, b, c; + +void +f (void) +{ + /* __builtin_choose_expr acts exactly like the chosen argument for + all constant expression purposes. */ + enum e { + E1 = __builtin_choose_expr (1, 1, ++b) + }; + /* The first argument to __builtin_choose_expr must be an integer + constant expression. */ + a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */ + a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + a = __builtin_choose_expr (1 / 0, 0, 0); /* { dg-warning "division by zero" } */ + /* { dg-error "not a constant" "error" { target *-*-* } .-1 } */ + a = __builtin_choose_expr ((1 ? 1 : a), b, c); /* { dg-error "constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu89-dupqual-1.c b/SingleSource/Regression/C/gcc-dg/gnu89-dupqual-1.c new file mode 100644 index 0000000000..9bd1db0156 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu89-dupqual-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -Werror" } */ + +typedef const int CI; +const const int c1; /* { dg-bogus "duplicate" } */ +const CI c2; /* { dg-bogus "duplicate" } */ +const CI *c3; /* { dg-bogus "duplicate" } */ + +typedef volatile int VI; +volatile volatile int v1; /* { dg-bogus "duplicate" } */ +volatile VI v2; /* { dg-bogus "duplicate" } */ +volatile VI *v3; /* { dg-bogus "duplicate" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu89-init-1.c b/SingleSource/Regression/C/gcc-dg/gnu89-init-1.c new file mode 100644 index 0000000000..07bf823535 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu89-init-1.c @@ -0,0 +1,69 @@ +/* Test for GNU extensions to compound literals */ +/* Origin: Jakub Jelinek */ +/* { dg-do run } */ +/* { dg-options "-std=gnu89" } */ + +extern void abort (void); +extern void exit (int); + +struct A { int i; int j; int k[4]; }; +struct B { }; +struct C { int i; }; +struct D { int i; struct C j; }; + +/* As a GNU extension, we allow initialization of objects with static storage + duration by compound literals. It is handled as if the object + was initialized only with the bracket enclosed list if compound literal's + and object types match. If the object being initialized has array type + of unknown size, the size is determined by compound literal's initializer + list, not by size of the compound literal. */ + +struct A a = (struct A) { .j = 6, .k[2] = 12 }; +struct B b = (struct B) { }; +int c[] = (int []) { [2] = 6, 7, 8 }; +int d[] = (int [3]) { 1 }; +int e[2] = (int []) { 1, 2 }; +int f[2] = (int [2]) { 1 }; +struct C g[3] = { [2] = (struct C) { 13 }, [1] = (const struct C) { 12 } }; +struct D h = { .j = (struct C) { 15 }, .i = 14 }; +struct D i[2] = { [1].j = (const struct C) { 17 }, + [0] = { 0, (struct C) { 16 } } }; +struct C j[2][3] = { [0 ... 1] = { [0 ... 2] = (struct C) { 26 } } }; +struct C k[3][2] = { [0 ... 2][0 ... 1] = (const struct C) { 27 } }; + +int main (void) +{ + if (a.i || a.j != 6 || a.k[0] || a.k[1] || a.k[2] != 12 || a.k[3]) + abort (); + if (c[0] || c[1] || c[2] != 6 || c[3] != 7 || c[4] != 8) + abort (); + if (sizeof (c) != 5 * sizeof (int)) + abort (); + if (d[0] != 1 || d[1] || d[2]) + abort (); + if (sizeof (d) != 3 * sizeof (int)) + abort (); + if (e[0] != 1 || e[1] != 2) + abort (); + if (sizeof (e) != 2 * sizeof (int)) + abort (); + if (f[0] != 1 || f[1]) + abort (); + if (sizeof (f) != 2 * sizeof (int)) + abort (); + if (g[0].i || g[1].i != 12 || g[2].i != 13) + abort (); + if (h.i != 14 || h.j.i != 15) + abort (); + if (i[0].i || i[0].j.i != 16 || i[1].i || i[1].j.i != 17) + abort (); + if (j[0][0].i != 26 || j[0][1].i != 26 || j[0][2].i != 26) + abort (); + if (j[1][0].i != 26 || j[1][1].i != 26 || j[1][2].i != 26) + abort (); + if (k[0][0].i != 27 || k[0][1].i != 27 || k[1][0].i != 27) + abort (); + if (k[1][1].i != 27 || k[2][0].i != 27 || k[2][1].i != 27) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu89-init-2.c b/SingleSource/Regression/C/gcc-dg/gnu89-init-2.c new file mode 100644 index 0000000000..ce966ec898 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu89-init-2.c @@ -0,0 +1,25 @@ +/* Test whether __compound_literal.* objects are not emitted unless + they are actually needed. */ +/* Origin: Jakub Jelinek */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -O2" } */ +/* { dg-final { scan-assembler-not "__compound_literal" } } */ + +struct A { int i; int j; int k[4]; }; +struct B { }; +struct C { int i; }; +struct D { int i; struct C j; }; + +struct A a = (struct A) { .j = 6, .k[2] = 12 }; +struct B b = (struct B) { }; +int c[] = (int []) { [2] = 6, 7, 8 }; +int d[] = (int [3]) { 1 }; +int e[2] = (int []) { 1, 2 }; +int f[2] = (int [2]) { 1 }; +struct C g[3] = { [2] = (struct C) { 13 }, [1] = (const struct C) { 12 } }; +struct D h = { .j = (struct C) { 15 }, .i = 14 }; +struct D i[2] = { [1].j = (const struct C) { 17 }, + [0] = { 0, (struct C) { 16 } } }; +static const int *j = 1 ? (const int *) 0 : & (const int) { 26 }; +int k = (int) sizeof ((int [6]) { 1, 2, 3, 4, 5, 6 }) + 4; +int l = (int) sizeof ((struct C) { 16 }); diff --git a/SingleSource/Regression/C/gcc-dg/gnu89-init-3.c b/SingleSource/Regression/C/gcc-dg/gnu89-init-3.c new file mode 100644 index 0000000000..bd4283ec87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu89-init-3.c @@ -0,0 +1,18 @@ +/* PR 11527 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +typedef struct smrdd_memory_blocks_s +{ + int blocks; + int block[]; +} smrdd_memory_blocks_t; + +const smrdd_memory_blocks_t smrdd_memory_blocks = +{ + 3, + { + [5] = 5, + [1] = 2, + } +}; diff --git a/SingleSource/Regression/C/gcc-dg/gnu89-init-4.c b/SingleSource/Regression/C/gcc-dg/gnu89-init-4.c new file mode 100644 index 0000000000..15e9cdb35e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu89-init-4.c @@ -0,0 +1,12 @@ +/* Test for GNU extensions to compound literals are giving the correct array bounds */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -W -Wall -O2" } */ + +int a[] = (int[4]){1, 1, 2}; +int f(void) +{ + int sum = 0; int i; + for(i = 0;i<4;i++) + sum = a[i]; + return sum; +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu90-const-expr-1.c b/SingleSource/Regression/C/gcc-dg/gnu90-const-expr-1.c new file mode 100644 index 0000000000..0a76ff6811 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu90-const-expr-1.c @@ -0,0 +1,56 @@ +/* Test for constant expressions: GNU extensions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90 -pedantic-errors" } */ + +int n; + +void +f (void) +{ + int i = 0; + int a[n]; /* { dg-error "ISO C90 forbids variable length array" } */ + enum e1 { + /* Integer constant expressions may not contain statement + expressions (not a permitted operand). */ + E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant expression" } */ + /* { dg-error "ISO C forbids braced-groups" "ISO" { target *-*-* } .-1 } */ + /* Real and imaginary parts act like other arithmetic + operators. */ + E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant expression" } */ + E3 = __real__ 0, + E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */ + E5 = __imag__ 0, + /* __alignof__ always constant. */ + E6 = __alignof__ (int[n]), /* { dg-error "ISO C90 forbids variable length array" } */ + E7 = __alignof__ (a), + /* __extension__ ignored for constant expression purposes. */ + E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant expression" } */ + E9 = __extension__ 0, + /* Conditional expressions with omitted arguments act like the + standard type. */ + E10 = (1 ? : i++), /* { dg-error "constant expression" } */ + /* { dg-error "ISO C forbids omitting" "ISO" { target *-*-* } .-1 } */ + E11 = (1 ? : 0) /* { dg-error "ISO C forbids omitting" } */ + }; + enum e2 { + /* Complex integer constants may be cast directly to integer + types, but not after further arithmetic on them. */ + F1 = (int) (_Complex int) 2i, /* { dg-error "constant expression" } */ + /* { dg-error "complex" "complex" { target *-*-* } .-1 } */ + /* { dg-error "imaginary" "imaginary" { target *-*-* } .-2 } */ + F2 = (int) +2i, /* { dg-error "constant expression" } */ + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + F3 = (int) (1 + 2i), /* { dg-error "constant expression" } */ + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + F4 = (int) 2i /* { dg-error "imaginary" } */ + }; + static double dr = __real__ (1.0 + 2.0i); + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + static double di = __imag__ (1.0 + 2.0i); + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + /* Statement expressions allowed in unevaluated subexpressions in + initializers in gnu99 but not gnu89. */ + static int j = (1 ? 0 : ({ 0; })); /* { dg-error "constant expression" } */ + /* { dg-error "braced" "ISO" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-1.c b/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-1.c new file mode 100644 index 0000000000..4148cd9f07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-1.c @@ -0,0 +1,56 @@ +/* Test for constant expressions: GNU extensions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +int n; + +void +f (void) +{ + int i = 0; + int a[n]; + enum e1 { + /* Integer constant expressions may not contain statement + expressions (not a permitted operand). */ + E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant expression" } */ + /* { dg-error "ISO C forbids braced-groups" "ISO" { target *-*-* } .-1 } */ + /* Real and imaginary parts act like other arithmetic + operators. */ + E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant expression" } */ + E3 = __real__ 0, + E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */ + E5 = __imag__ 0, + /* __alignof__ always constant. */ + E6 = __alignof__ (int[n]), + E7 = __alignof__ (a), + /* __extension__ ignored for constant expression purposes. */ + E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant expression" } */ + E9 = __extension__ 0, + /* Conditional expressions with omitted arguments act like the + standard type. */ + E10 = (1 ? : i++), /* { dg-error "constant expression" } */ + /* { dg-error "ISO C forbids omitting" "ISO" { target *-*-* } .-1 } */ + E11 = (1 ? : 0) /* { dg-error "ISO C forbids omitting" } */ + }; + enum e2 { + /* Complex integer constants may be cast directly to integer + types, but not after further arithmetic on them. */ + F1 = (int) (_Complex int) 2i, /* { dg-error "constant expression" } */ + /* { dg-error "complex" "complex" { target *-*-* } .-1 } */ + /* { dg-error "imaginary" "imaginary" { target *-*-* } .-2 } */ + F2 = (int) +2i, /* { dg-error "constant expression" } */ + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + F3 = (int) (1 + 2i), /* { dg-error "constant expression" } */ + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + F4 = (int) 2i /* { dg-error "imaginary" } */ + }; + static double dr = __real__ (1.0 + 2.0i); + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + static double di = __imag__ (1.0 + 2.0i); + /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */ + /* Statement expressions allowed in unevaluated subexpressions in + initializers in gnu99 but not gnu89. */ + static int j = (1 ? 0 : ({ 0; })); + /* { dg-error "braced" "ISO" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-2.c b/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-2.c new file mode 100644 index 0000000000..4ce5445c61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-2.c @@ -0,0 +1,26 @@ +/* Test for constant expressions: __builtin_choose_expr. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +#include + +int a, b, c; + +void +f (void) +{ + /* __builtin_choose_expr acts exactly like the chosen argument for + all constant expression purposes. */ + enum e { + E1 = __builtin_choose_expr (1, 1, ++b) + }; + /* The first argument to __builtin_choose_expr must be an integer + constant expression. */ + a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */ + a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + a = __builtin_choose_expr (1 / 0, 0, 0); /* { dg-warning "division by zero" } */ + /* { dg-error "not a constant" "error" { target *-*-* } .-1 } */ + a = __builtin_choose_expr ((1 ? 1 : a), b, c); /* { dg-error "constant" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-3.c b/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-3.c new file mode 100644 index 0000000000..aba7da542a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-3.c @@ -0,0 +1,32 @@ +/* Test for constant expressions: cases involving VLAs and typeof. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +/* It appears address constants may contain casts to variably modified + types. Whether they should be permitted was discussed in + + ; since static pointers to VLAs + are definitely permitted within functions and may be initialized + and such initialization involves implicit conversion to a variably + modified type, allowing explicit casts seems appropriate. Thus, + GCC allows them as long as the "evaluated" size expressions do not + contain the various operators not permitted to be evaluated in a + constant expression, and as long as the result is genuinely + constant (meaning that pointer arithmetic using the size of the VLA + is generally not permitted). */ + +static int sa[100]; + +int +f (int m, int n) +{ + static int (*a1)[n] = &sa; + static int (*a2)[n] = (__typeof__(int (*)[n]))sa; + static int (*a3)[n] = (__typeof__(int (*)[(int){m++}]))sa; /* { dg-error "constant" } */ + static int (*a4)[n] = (__typeof__((int (*)[n])sa))sa; + static int (*a5)[n] = (__typeof__((int (*)[m++])sa))sa; /* { dg-error "constant" } */ + static int (*a6)[n] = (__typeof__((int (*)[100])(int (*)[m++])sa))sa; + static int (*a7)[n] = (__typeof__((int (*)[n])sa + m++))sa; /* { dg-error "constant" } */ + return n; +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-4.c b/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-4.c new file mode 100644 index 0000000000..baaa63031a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu99-const-expr-4.c @@ -0,0 +1,29 @@ +/* Test for constant expressions: cases involving VLAs and typeof, at + file scope. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +/* It appears address constants may contain casts to variably modified + types. Whether they should be permitted was discussed in + + ; since static pointers to VLAs + are definitely permitted within functions and may be initialized + and such initialization involves implicit conversion to a variably + modified type, allowing explicit casts seems appropriate. Thus, + GCC allows them as long as the "evaluated" size expressions do not + contain the various operators not permitted to be evaluated in a + constant expression, and as long as the result is genuinely + constant (meaning that pointer arithmetic using the size of the VLA + is generally not permitted). */ + +static int sa[100]; +int m; +int n; + +static int (*a1)[] = &sa; +static int (*a2)[] = (__typeof__(int (*)[n]))sa; +static int (*a4)[] = (__typeof__((int (*)[n])sa))sa; +static int (*a5)[] = (__typeof__((int (*)[m++])sa))sa; /* { dg-error "constant" } */ +static int (*a6)[] = (__typeof__((int (*)[100])(int (*)[m++])sa))sa; +static int (*a7)[] = (__typeof__((int (*)[n])sa + m++))sa; /* { dg-error "constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu99-init-1.c b/SingleSource/Regression/C/gcc-dg/gnu99-init-1.c new file mode 100644 index 0000000000..009c8515f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu99-init-1.c @@ -0,0 +1,80 @@ +/* Test for GNU extensions to C99 designated initializers */ +/* Origin: Jakub Jelinek */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +typedef __SIZE_TYPE__ size_t; +extern int memcmp (const void *, const void *, size_t); +extern void abort (void); +extern void exit (int); + +int a[][2][4] = { [2 ... 4][0 ... 1][2 ... 3] = 1, [2] = 2, [2][0][2] = 3 }; +struct E {}; +struct F { struct E H; }; +struct G { int I; struct E J; int K; }; +struct H { int I; struct F J; int K; }; +struct G k = { .J = {}, 1 }; +struct H l = { .J.H = {}, 2 }; +struct H m = { .J = {}, 3 }; +struct I { int J; int K[3]; int L; }; +struct M { int N; struct I O[3]; int P; }; +struct M n[] = { [0 ... 5].O[1 ... 2].K[0 ... 1] = 4, 5, 6, 7 }; +struct M o[] = { [0 ... 5].O = { [1 ... 2].K[0 ... 1] = 4 }, + [5].O[2].K[2] = 5, 6, 7 }; +struct M p[] = { [0 ... 5].O[1 ... 2].K = { [0 ... 1] = 4 }, + [5].O[2].K[2] = 5, 6, 7 }; +int q[3][3] = { [0 ... 1] = { [1 ... 2] = 23 }, [1][2] = 24 }; +int r[1] = { [0 ... 1 - 1] = 27 }; + +int main (void) +{ + int x, y, z; + + if (a[2][0][0] != 2 || a[2][0][2] != 3) + abort (); + a[2][0][0] = 0; + a[2][0][2] = 1; + for (x = 0; x <= 4; x++) + for (y = 0; y <= 1; y++) + for (z = 0; z <= 3; z++) + if (a[x][y][z] != (x >= 2 && z >= 2)) + abort (); + if (k.I || l.I || m.I || k.K != 1 || l.K != 2 || m.K != 3) + abort (); + for (x = 0; x <= 5; x++) + { + if (n[x].N || n[x].O[0].J || n[x].O[0].L) + abort (); + for (y = 0; y <= 2; y++) + if (n[x].O[0].K[y]) + abort (); + for (y = 1; y <= 2; y++) + { + if (n[x].O[y].J) + abort (); + if (n[x].O[y].K[0] != 4) + abort (); + if (n[x].O[y].K[1] != 4) + abort (); + if ((x < 5 || y < 2) && (n[x].O[y].K[2] || n[x].O[y].L)) + abort (); + } + if (x < 5 && n[x].P) + abort (); + } + if (n[5].O[2].K[2] != 5 || n[5].O[2].L != 6 || n[5].P != 7) + abort (); + if (memcmp (n, o, sizeof (n)) || sizeof (n) != sizeof (o)) + abort (); + if (memcmp (n, p, sizeof (n)) || sizeof (n) != sizeof (p)) + abort (); + if (q[0][0] || q[0][1] != 23 || q[0][2] != 23) + abort (); + if (q[1][0] || q[1][1] != 23 || q[1][2] != 24) + abort (); + if (q[2][0] || q[2][1] || q[2][2]) + abort (); + if (r[0] != 27) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/gnu99-init-2.c b/SingleSource/Regression/C/gcc-dg/gnu99-init-2.c new file mode 100644 index 0000000000..5ccdc118b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu99-init-2.c @@ -0,0 +1,11 @@ +/* Test for designated initializers: array designators must be of + integer type. Test for index ranges (GNU extension). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +int a[] = { [(void *)0 ... 0] = 1 }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "integer type|near init" "pointer designator" { target *-*-* } .-1 } */ + +int b[] = { [0 ... (void *)0] = 1 }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "integer type|near init" "pointer designator" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/gnu99-static-1.c b/SingleSource/Regression/C/gcc-dg/gnu99-static-1.c new file mode 100644 index 0000000000..982113bc7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/gnu99-static-1.c @@ -0,0 +1,30 @@ +/* It is a constraint violation for a static function to be declared + but not defined if it is used except in a sizeof expression whose + result is an integer constant. In GNU C, we need to consider + __typeof__ and __alignof__ as well. __alignof__ always returns a + constant, so static functions can always be used therein. + __typeof__ evaluates its argument iff it has variably modified + type. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu99 -pedantic-errors" } */ + +/* __alignof__, OK. */ +static int f0(void); +void g0(void) { __alignof__(f0()); } + +/* __typeof__ not variably modified, OK. */ +static int f1(void); +void g1(void) { __typeof__(f1()) x; } + +/* __typeof__ variably modified, not OK. */ +static int f2(void); /* { dg-error "used but never defined" } */ +void g2(void) { __typeof__(int [f2()]) x; } + +/* __typeof__ variably modified, not OK. */ +static int f3(void); /* { dg-error "used but never defined" } */ +void g3(void) { __typeof__(int (*)[f3()]) x; } + +/* Integer sizeof of VM typeof, OK. */ +static int f4(void); +void g4(void) { sizeof(__typeof__(int (*)[f3()])); } diff --git a/SingleSource/Regression/C/gcc-dg/h8300-bit-insn-ice.c b/SingleSource/Regression/C/gcc-dg/h8300-bit-insn-ice.c new file mode 100644 index 0000000000..442dc4bb9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/h8300-bit-insn-ice.c @@ -0,0 +1,39 @@ +/* { dg-skip-if "" { "h8300*-*-*" } "*" "-msx*" } */ +/* ICE for bit instruction generation using 16-bit const */ + +__extension__ struct st_mstp +{ + union + { + unsigned short WORD; + struct + { + unsigned char ACSE:1; + unsigned char _EXDMAC:1; + unsigned char _DMAC:1; + unsigned char _DTC:1; + unsigned char:2; + unsigned char _TMR23:1; + unsigned char _TMR01:1; + unsigned char:2; + unsigned char _DA:1; + unsigned char:1; + unsigned char _AD:1; + unsigned char:1; + unsigned char _TPUU:1; + unsigned char _TPUL:1; + } BIT; + } CRA; +}; +#define MSTP (*(volatile struct st_mstp *)0xFFFDC8) +#define MSTPA_EXDMA 0x4000 +#define MSTPA_AND 0xFEFF + +int +main () +{ + MSTP.CRA.WORD |= MSTPA_EXDMA; + MSTP.CRA.WORD ^= MSTPA_EXDMA; + MSTP.CRA.WORD &= MSTPA_AND; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/h8300-bit-insn-ice2.c b/SingleSource/Regression/C/gcc-dg/h8300-bit-insn-ice2.c new file mode 100644 index 0000000000..8b5f628759 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/h8300-bit-insn-ice2.c @@ -0,0 +1,15 @@ +/* { dg-skip-if "" { "h8300*-*-*" } "*" "-msx*" } */ +/* { dg-options "-O2" } */ +/* ICE for bit instruction generation using 16-bit const */ + +#define MSTPCRA (*(volatile unsigned char*)0xFFFFC9) +#define MSTPCRA2 (*(volatile unsigned char*)0xFFFDC8) + +int +main (void) +{ + MSTPCRA = MSTPCRA2 & ~0x01; + MSTPCRA = MSTPCRA2 ^ ~0xFE; + MSTPCRA = MSTPCRA2 | ~0xFE; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/h8300-bss-align-1.c b/SingleSource/Regression/C/gcc-dg/h8300-bss-align-1.c new file mode 100644 index 0000000000..d6459e15f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/h8300-bss-align-1.c @@ -0,0 +1,12 @@ +/* Make sure that the H8 backend does align zero initialized variables. */ +/* { dg-do compile { target h8300-*-* } } */ +/* { dg-options "" } */ + +struct s { + char a, b; + long c; +}; + +struct s s = {0}; + +/* { dg-final { scan-assembler ".align" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/h8300-div-delay-slot.c b/SingleSource/Regression/C/gcc-dg/h8300-div-delay-slot.c new file mode 100644 index 0000000000..5fa60ec4d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/h8300-div-delay-slot.c @@ -0,0 +1,19 @@ +/* Make sure that the H8 backend does not generate a div + instruction in a delay slot. */ +/* { dg-options "-Os" } */ +/* { dg-skip-if "" { "h8300*-*-*" } "*" "-msx*" } */ +/* { dg-final { scan-assembler-not "\tbra/s\t.*\n\tdiv*" } } */ + +extern volatile unsigned long timer_ticks; +#define timer_ms_elapsed(ticks) (((unsigned long)(timer_ticks-ticks))/10) +unsigned long ticks; + +unsigned tst_read( unsigned char idx ) +{ + switch( idx ) + { + case 0x62: return timer_ms_elapsed(ticks); + case 0x61: return timer_ticks; + default: return 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/h8300-ice2.c b/SingleSource/Regression/C/gcc-dg/h8300-ice2.c new file mode 100644 index 0000000000..216ea34c94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/h8300-ice2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* ICE for signed/unsigned long and signed char comparison */ +int main() +{ + unsigned long ul = 4; + long sl = 2; + signed char sch = -1; + if (ul <= sch); + return 0; + if (sl <= sch) + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/h8300-stack-1.c b/SingleSource/Regression/C/gcc-dg/h8300-stack-1.c new file mode 100644 index 0000000000..b63bde29c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/h8300-stack-1.c @@ -0,0 +1,14 @@ +/* Make sure that the H8 backend does not generate a non-atomic stack + adjustment. */ +/* { dg-do compile { target h8300-*-* } } */ +/* { dg-options "" } */ + +void foo (short, short, short, short, short, short); + +void +bar () +{ + foo (0, 0, 0, 0, 0, 0); +} + +/* { dg-final { scan-assembler-not "addx" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/header.c b/SingleSource/Regression/C/gcc-dg/header.c new file mode 100644 index 0000000000..3241a96344 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/header.c @@ -0,0 +1,9 @@ +/* This really should use "dg-do compile" without the -S in dg-options, + but the extra options get put after the input file in that case, and + hence the test would fail. */ +/* { dg-do assemble } */ +/* { dg-options "-S -x c-header" } */ + +struct s { + unsigned field; +}; diff --git a/SingleSource/Regression/C/gcc-dg/hex-round-1.c b/SingleSource/Regression/C/gcc-dg/hex-round-1.c new file mode 100644 index 0000000000..3276ad4637 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/hex-round-1.c @@ -0,0 +1,113 @@ +/* Test for hexadecimal float rounding: bug 21720. */ +/* { dg-do link } */ +/* { dg-options "-O -std=gnu99" } */ + +#include + +extern void link_failure (void); + +int +main (void) +{ +#if FLT_RADIX == 2 && FLT_MANT_DIG == 24 + if (0x1.0000011p0f == 1) + link_failure (); + if (0x1.00000101p0f == 1) + link_failure (); + if (0x1.000001001p0f == 1) + link_failure (); + if (0x1.0000010001p0f == 1) + link_failure (); + if (0x1.00000100001p0f == 1) + link_failure (); + if (0x1.000001000001p0f == 1) + link_failure (); + if (0x1.0000010000001p0f == 1) + link_failure (); + if (0x1.00000100000001p0f == 1) + link_failure (); + if (0x1.000001000000001p0f == 1) + link_failure (); + if (0x1.0000010000000001p0f == 1) + link_failure (); + if (0x1.00000100000000001p0f == 1) + link_failure (); + if (0x1.000001000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.00000100000000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.000001000000000000000000000000000000000000000000000001p0f == 1) + link_failure (); + if (0x1.0000010000000000000000000000000000000000000000000000001p0f == 1) + link_failure (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/hex-round-2.c b/SingleSource/Regression/C/gcc-dg/hex-round-2.c new file mode 100644 index 0000000000..ba9b8bf3d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/hex-round-2.c @@ -0,0 +1,114 @@ +/* Test for hexadecimal float rounding: bug 21720. Test with no "." + in number. */ +/* { dg-do link } */ +/* { dg-options "-O -std=gnu99" } */ + +#include + +extern void link_failure (void); + +int +main (void) +{ +#if FLT_RADIX == 2 && FLT_MANT_DIG == 24 + if (0x10000011p-28f == 1) + link_failure (); + if (0x100000101p-32f == 1) + link_failure (); + if (0x1000001001p-36f == 1) + link_failure (); + if (0x10000010001p-40f == 1) + link_failure (); + if (0x100000100001p-44f == 1) + link_failure (); + if (0x1000001000001p-48f == 1) + link_failure (); + if (0x10000010000001p-52f == 1) + link_failure (); + if (0x100000100000001p-56f == 1) + link_failure (); + if (0x1000001000000001p-60f == 1) + link_failure (); + if (0x10000010000000001p-64f == 1) + link_failure (); + if (0x100000100000000001p-68f == 1) + link_failure (); + if (0x1000001000000000001p-72f == 1) + link_failure (); + if (0x10000010000000000001p-76f == 1) + link_failure (); + if (0x100000100000000000001p-80f == 1) + link_failure (); + if (0x1000001000000000000001p-84f == 1) + link_failure (); + if (0x10000010000000000000001p-88f == 1) + link_failure (); + if (0x100000100000000000000001p-92f == 1) + link_failure (); + if (0x1000001000000000000000001p-96f == 1) + link_failure (); + if (0x10000010000000000000000001p-100f == 1) + link_failure (); + if (0x100000100000000000000000001p-104f == 1) + link_failure (); + if (0x1000001000000000000000000001p-108f == 1) + link_failure (); + if (0x10000010000000000000000000001p-112f == 1) + link_failure (); + if (0x100000100000000000000000000001p-116f == 1) + link_failure (); + if (0x1000001000000000000000000000001p-120f == 1) + link_failure (); + if (0x10000010000000000000000000000001p-124f == 1) + link_failure (); + if (0x100000100000000000000000000000001p-128f == 1) + link_failure (); + if (0x1000001000000000000000000000000001p-132f == 1) + link_failure (); + if (0x10000010000000000000000000000000001p-136f == 1) + link_failure (); + if (0x100000100000000000000000000000000001p-140f == 1) + link_failure (); + if (0x1000001000000000000000000000000000001p-144f == 1) + link_failure (); + if (0x10000010000000000000000000000000000001p-148f == 1) + link_failure (); + if (0x100000100000000000000000000000000000001p-152f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000001p-156f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000001p-160f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000001p-164f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000001p-168f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000001p-172f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000000001p-176f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000000001p-180f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000000001p-184f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000000000001p-188f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000000000001p-192f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000000000001p-196f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000000000000001p-200f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000000000000001p-204f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000000000000001p-208f == 1) + link_failure (); + if (0x100000100000000000000000000000000000000000000000000001p-212f == 1) + link_failure (); + if (0x1000001000000000000000000000000000000000000000000000001p-216f == 1) + link_failure (); + if (0x10000010000000000000000000000000000000000000000000000001p-220f == 1) + link_failure (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-1.c b/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-1.c new file mode 100644 index 0000000000..6e566da4db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-1.c @@ -0,0 +1,35 @@ +/* { dg-options "-Os -fdump-rtl-hoist -fno-code-hoisting" } */ +/* The rtl hoist pass requires that the expression to be hoisted can + be assigned without clobbering cc. For a PLUS rtx on S/390 this + requires a load address instruction which is fine on 64 bit but + cannot be used on 31 bit since it does a 31 bit add only. */ +/* { dg-final { scan-rtl-dump "PRE/HOIST: end of bb .* copying expression" "hoist" { target { { !s390*-*-* || lp64 } && nonpic } } } } */ + +#define BUF 100 +long a[BUF]; + +void com (long); +void bar (long); + +long foo (long x, long y, long z) +{ + /* "x+y" won't be hoisted if "-fira-hoist-pressure" is disabled, + because its rtx_cost is too small. */ + if (z) + { + a[1] = a[0] + a[2]; + a[2] = a[1] + a[3]; + a[3] = a[2] + a[4]; + a[4] = a[3] + a[5]; + a[5] = a[4] + a[6]; + a[6] = a[5] + a[7]; + a[7] = a[6] + a[8]; + com (x+y); + } + else + { + bar (x+y); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-2.c b/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-2.c new file mode 100644 index 0000000000..05ffd8d93f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-2.c @@ -0,0 +1,36 @@ +/* { dg-options "-Os -fdump-rtl-hoist -fno-code-hoisting" } */ +/* The rtl hoist pass requires that the expression to be hoisted can + be assigned without clobbering cc. For a PLUS rtx on S/390 this + requires a load address instruction which is fine on 64 bit but + cannot be used on 31 bit since it does a 31 bit add only. */ +/* { dg-final { scan-rtl-dump "PRE/HOIST: end of bb .* copying expression" "hoist" { target { !s390*-*-* || lp64 } } } } */ + +#define BUF 100 +long a[BUF]; + +void com (long); +void bar (long); + +long foo (long x, long y, long z) +{ + /* "x+y" won't be hoisted if "-fira-hoist-pressure" is disabled, + because its rtx_cost is too small. */ + if (z) + { + a[1] = a[0]; + a[2] = a[1]; + a[3] = a[3]; + a[4] = a[5]; + a[5] = a[7]; + a[6] = a[11]; + a[7] = a[13]; + a[8] = a[17]; + com (x+y); + } + else + { + bar (x+y); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-3.c b/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-3.c new file mode 100644 index 0000000000..f274fa1334 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/hoist-register-pressure-3.c @@ -0,0 +1,36 @@ +/* { dg-options "-Os -fdump-rtl-hoist -fno-code-hoisting" } */ +/* The rtl hoist pass requires that the expression to be hoisted can + be assigned without clobbering cc. For a PLUS rtx on S/390 this + requires a load address instruction which is fine on 64 bit but + cannot be used on 31 bit since it does a 31 bit add only. */ +/* { dg-final { scan-rtl-dump "PRE/HOIST: end of bb .* copying expression" "hoist" { target { !s390*-*-* || lp64 } } } } */ + +#define BUF 100 +long a[BUF]; + +void com (long); +void bar (long); + +long foo (long x, long y, long z) +{ + /* "x+y" won't be hoisted if "-fira-hoist-pressure" is disabled, + because its rtx_cost is too small. */ + if (z) + { + a[1] = a[0] + a[2] + a[3] + a[4] + a[5] + a[6]; + a[2] = a[1] + a[3] + a[5] + a[5] + a[6] + a[7]; + a[3] = a[2] + a[5] + a[7] + a[6] + a[7] + a[8]; + a[4] = a[3] + a[7] + a[11] + a[7] + a[8] + a[9]; + a[5] = a[5] + a[11] + a[13] + a[8] + a[9] + a[10]; + a[6] = a[7] + a[13] + a[17] + a[9] + a[10] + a[11]; + a[7] = a[11] + a[17] + a[19] + a[10] + a[11] + a[12]; + com (x+y); + } + else + { + bar (x+y); + } + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/ia64-sync-1.c b/SingleSource/Regression/C/gcc-dg/ia64-sync-1.c new file mode 100644 index 0000000000..ce83a84073 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ia64-sync-1.c @@ -0,0 +1,76 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ +/* { dg-options } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ + +/* Test basic functionality of the intrinsics. The operations should + not be optimized away if no one checks the return values. */ + +__extension__ typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void *memcpy (void *, const void *, size_t); +extern int memcmp (const void *, const void *, size_t); + +static int AI[12]; +static int init_noret_si[12] = { 0, 0, 0, 1, 0, 0, 0 , 0 , -1, 0, 0, -1 }; +static int test_noret_si[12] = { 1, 1, 1, 0, 1, 4, 22, -12, 7 , 8, 9, ~7 }; + +static void +do_noret_si (void) +{ + __sync_val_compare_and_swap(AI+0, 0, 1); + __sync_bool_compare_and_swap(AI+1, 0, 1); + __sync_lock_test_and_set(AI+2, 1); + __sync_lock_release(AI+3); + + __sync_fetch_and_add(AI+4, 1); + __sync_fetch_and_add(AI+5, 4); + __sync_fetch_and_add(AI+6, 22); + __sync_fetch_and_sub(AI+7, 12); + __sync_fetch_and_and(AI+8, 7); + __sync_fetch_and_or(AI+9, 8); + __sync_fetch_and_xor(AI+10, 9); + __sync_fetch_and_nand(AI+11, 7); +} + +static long AL[12]; +static long init_noret_di[12] = { 0, 0, 0, 1, 0, 0, 0 , 0 , -1, 0, 0, -1 }; +static long test_noret_di[12] = { 1, 1, 1, 0, 1, 4, 22, -12, 7 , 8, 9, ~7 }; + +static void +do_noret_di (void) +{ + __sync_val_compare_and_swap(AL+0, 0, 1); + __sync_bool_compare_and_swap(AL+1, 0, 1); + __sync_lock_test_and_set(AL+2, 1); + __sync_lock_release(AL+3); + + __sync_fetch_and_add(AL+4, 1); + __sync_fetch_and_add(AL+5, 4); + __sync_fetch_and_add(AL+6, 22); + __sync_fetch_and_sub(AL+7, 12); + __sync_fetch_and_and(AL+8, 7); + __sync_fetch_and_or(AL+9, 8); + __sync_fetch_and_xor(AL+10, 9); + __sync_fetch_and_nand(AL+11, 7); +} + +int main() +{ + memcpy(AI, init_noret_si, sizeof(init_noret_si)); + memcpy(AL, init_noret_di, sizeof(init_noret_di)); + + do_noret_si (); + do_noret_di (); + + if (memcmp (AI, test_noret_si, sizeof(test_noret_si))) + abort (); + if (memcmp (AL, test_noret_di, sizeof(test_noret_di))) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ia64-sync-2.c b/SingleSource/Regression/C/gcc-dg/ia64-sync-2.c new file mode 100644 index 0000000000..3dc10359a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ia64-sync-2.c @@ -0,0 +1,132 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ +/* { dg-options } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "fetch_and_nand" { target *-*-* } 0 } */ +/* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "nand_and_fetch" { target *-*-* } 0 } */ + +/* Test basic functionality of the intrinsics. */ + +__extension__ typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void *memcpy (void *, const void *, size_t); +extern int memcmp (const void *, const void *, size_t); + +static int AI[18]; +static int init_si[18] = { 0,0,0,1,0,0, 0,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static int test_si[18] = { 1,1,1,1,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; + +static void +do_si (void) +{ + if (__sync_val_compare_and_swap(AI+0, 0, 1) != 0) + abort (); + if (__sync_val_compare_and_swap(AI+0, 0, 1) != 1) + abort (); + if (__sync_bool_compare_and_swap(AI+1, 0, 1) != 1) + abort (); + if (__sync_bool_compare_and_swap(AI+1, 0, 1) != 0) + abort (); + + if (__sync_lock_test_and_set(AI+2, 1) != 0) + abort (); + + if (__sync_fetch_and_add(AI+4, 1) != 0) + abort (); + if (__sync_fetch_and_add(AI+5, 4) != 0) + abort (); + if (__sync_fetch_and_add(AI+6, 22) != 0) + abort (); + if (__sync_fetch_and_sub(AI+7, 12) != 0) + abort (); + if (__sync_fetch_and_and(AI+8, 7) != -1) + abort (); + if (__sync_fetch_and_or(AI+9, 8) != 0) + abort (); + if (__sync_fetch_and_xor(AI+10, 9) != 0) + abort (); + if (__sync_fetch_and_nand(AI+11, 7) != -1) + abort (); + + if (__sync_add_and_fetch(AI+12, 1) != 1) + abort (); + if (__sync_sub_and_fetch(AI+13, 12) != -12) + abort (); + if (__sync_and_and_fetch(AI+14, 7) != 7) + abort (); + if (__sync_or_and_fetch(AI+15, 8) != 8) + abort (); + if (__sync_xor_and_fetch(AI+16, 9) != 9) + abort (); + if (__sync_nand_and_fetch(AI+17, 7) != ~7) + abort (); +} + +static long AL[18]; +static long init_di[18] = { 0,0,0,1,0,0, 0,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static long test_di[18] = { 1,1,1,1,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; + +static void +do_di (void) +{ + if (__sync_val_compare_and_swap(AL+0, 0, 1) != 0) + abort (); + if (__sync_val_compare_and_swap(AL+0, 0, 1) != 1) + abort (); + if (__sync_bool_compare_and_swap(AL+1, 0, 1) != 1) + abort (); + if (__sync_bool_compare_and_swap(AL+1, 0, 1) != 0) + abort (); + + if (__sync_lock_test_and_set(AL+2, 1) != 0) + abort (); + + if (__sync_fetch_and_add(AL+4, 1) != 0) + abort (); + if (__sync_fetch_and_add(AL+5, 4) != 0) + abort (); + if (__sync_fetch_and_add(AL+6, 22) != 0) + abort (); + if (__sync_fetch_and_sub(AL+7, 12) != 0) + abort (); + if (__sync_fetch_and_and(AL+8, 7) != -1) + abort (); + if (__sync_fetch_and_or(AL+9, 8) != 0) + abort (); + if (__sync_fetch_and_xor(AL+10, 9) != 0) + abort (); + if (__sync_fetch_and_nand(AL+11, 7) != -1) + abort (); + + if (__sync_add_and_fetch(AL+12, 1) != 1) + abort (); + if (__sync_sub_and_fetch(AL+13, 12) != -12) + abort (); + if (__sync_and_and_fetch(AL+14, 7) != 7) + abort (); + if (__sync_or_and_fetch(AL+15, 8) != 8) + abort (); + if (__sync_xor_and_fetch(AL+16, 9) != 9) + abort (); + if (__sync_nand_and_fetch(AL+17, 7) != ~7) + abort (); +} + +int main() +{ + memcpy(AI, init_si, sizeof(init_si)); + memcpy(AL, init_di, sizeof(init_di)); + + do_si (); + do_di (); + + if (memcmp (AI, test_si, sizeof(test_si))) + abort (); + if (memcmp (AL, test_di, sizeof(test_di))) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ia64-sync-3.c b/SingleSource/Regression/C/gcc-dg/ia64-sync-3.c new file mode 100644 index 0000000000..ad2716943a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ia64-sync-3.c @@ -0,0 +1,81 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ +/* { dg-options } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* Test basic functionality of the intrinsics. */ + +__extension__ typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void *memcpy (void *, const void *, size_t); +extern int memcmp (const void *, const void *, size_t); + +static int AI[4]; +static int init_si[4] = { -30,-30,-50,-50 }; +static int test_si[4] = { -115,-115,25,25 }; + +static void +do_si (void) +{ + if (__sync_val_compare_and_swap(AI+0, -30, -115) != -30) + abort (); + if (__sync_val_compare_and_swap(AI+0, -30, -115) != -115) + abort (); + if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 1) + abort (); + if (__sync_bool_compare_and_swap(AI+1, -30, -115) != 0) + abort (); + + if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != -50) + abort (); + if (__sync_val_compare_and_swap(AI+2, AI[2], 25) != 25) + abort (); + if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1) + abort (); + if (__sync_bool_compare_and_swap(AI+3, AI[3], 25) != 1) + abort (); +} + +static long AL[4]; +static long init_di[4] = { -30,-30,-50,-50 }; +static long test_di[4] = { -115,-115,25,25 }; + +static void +do_di (void) +{ + if (__sync_val_compare_and_swap(AL+0, -30, -115) != -30) + abort (); + if (__sync_val_compare_and_swap(AL+0, -30, -115) != -115) + abort (); + if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 1) + abort (); + if (__sync_bool_compare_and_swap(AL+1, -30, -115) != 0) + abort (); + + if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != -50) + abort (); + if (__sync_val_compare_and_swap(AL+2, AL[2], 25) != 25) + abort (); + if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1) + abort (); + if (__sync_bool_compare_and_swap(AL+3, AL[3], 25) != 1) + abort (); +} + +int main() +{ + memcpy(AI, init_si, sizeof(init_si)); + memcpy(AL, init_di, sizeof(init_di)); + + do_si (); + do_di (); + + if (memcmp (AI, test_si, sizeof(test_si))) + abort (); + if (memcmp (AL, test_di, sizeof(test_di))) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ia64-sync-4.c b/SingleSource/Regression/C/gcc-dg/ia64-sync-4.c new file mode 100644 index 0000000000..eec472f388 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ia64-sync-4.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target sync_int_long } */ +/* { dg-options "-O2 -finline-functions" } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* Test inlining __sync_bool_compare_and_swap. */ + +#include + +static bool +compare_and_swap(long *addr, long old, long new_val) +{ + return __sync_bool_compare_and_swap(addr, old, new_val); +} + +void +foo (long *address) +{ + long he_address = *address & ~1; + while (!compare_and_swap(address, he_address, he_address | 1)) + he_address = *address & ~1; +} diff --git a/SingleSource/Regression/C/gcc-dg/ia64-sync-5.c b/SingleSource/Regression/C/gcc-dg/ia64-sync-5.c new file mode 100644 index 0000000000..a3923b06b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ia64-sync-5.c @@ -0,0 +1,83 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ +/* { dg-options } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* Test basic functionality of the intrinsics. */ + +/* This is a copy of gcc.dg/ia64-sync-3.c, for 8-bit and 16-bit. */ + +__extension__ typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void *memcpy (void *, const void *, size_t); +extern int memcmp (const void *, const void *, size_t); + +static signed char AC[4]; +static signed char init_qi[4] = { -30,-30,-50,-50 }; +static signed char test_qi[4] = { -115,-115,25,25 }; + +static void +do_qi (void) +{ + if (__sync_val_compare_and_swap(AC+0, -30, -115) != -30) + abort (); + if (__sync_val_compare_and_swap(AC+0, -30, -115) != -115) + abort (); + if (__sync_bool_compare_and_swap(AC+1, -30, -115) != 1) + abort (); + if (__sync_bool_compare_and_swap(AC+1, -30, -115) != 0) + abort (); + + if (__sync_val_compare_and_swap(AC+2, AC[2], 25) != -50) + abort (); + if (__sync_val_compare_and_swap(AC+2, AC[2], 25) != 25) + abort (); + if (__sync_bool_compare_and_swap(AC+3, AC[3], 25) != 1) + abort (); + if (__sync_bool_compare_and_swap(AC+3, AC[3], 25) != 1) + abort (); +} + +static short AS[4]; +static short init_hi[4] = { -30,-30,-50,-50 }; +static short test_hi[4] = { -115,-115,25,25 }; + +static void +do_hi (void) +{ + if (__sync_val_compare_and_swap(AS+0, -30, -115) != -30) + abort (); + if (__sync_val_compare_and_swap(AS+0, -30, -115) != -115) + abort (); + if (__sync_bool_compare_and_swap(AS+1, -30, -115) != 1) + abort (); + if (__sync_bool_compare_and_swap(AS+1, -30, -115) != 0) + abort (); + + if (__sync_val_compare_and_swap(AS+2, AS[2], 25) != -50) + abort (); + if (__sync_val_compare_and_swap(AS+2, AS[2], 25) != 25) + abort (); + if (__sync_bool_compare_and_swap(AS+3, AS[3], 25) != 1) + abort (); + if (__sync_bool_compare_and_swap(AS+3, AS[3], 25) != 1) + abort (); +} + +int main() +{ + memcpy(AC, init_qi, sizeof(init_qi)); + memcpy(AS, init_hi, sizeof(init_hi)); + + do_qi (); + do_hi (); + + if (memcmp (AC, test_qi, sizeof(test_qi))) + abort (); + if (memcmp (AS, test_hi, sizeof(test_hi))) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-1.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-1.c new file mode 100644 index 0000000000..bd5d037afc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-1.c @@ -0,0 +1,16 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess } */ +/* { dg-options "" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-2.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-2.c new file mode 100644 index 0000000000..5a28574ac9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-2.c @@ -0,0 +1,23 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess } */ +/* { dg-options "-funsafe-math-optimizations" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif + +#if __GCC_IEC_559 != 0 +# error "__GCC_IEC_559 != 0 with -funsafe-math-optimizations" +#endif +#if __GCC_IEC_559_COMPLEX != 0 +# error "__GCC_IEC_559_COMPLEX != 0 with -funsafe-math-optimizations" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-3.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-3.c new file mode 100644 index 0000000000..5eeb34503f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-3.c @@ -0,0 +1,23 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess } */ +/* { dg-options "-freciprocal-math" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif + +#if __GCC_IEC_559 != 0 +# error "__GCC_IEC_559 != 0 with -freciprocal-math" +#endif +#if __GCC_IEC_559_COMPLEX != 0 +# error "__GCC_IEC_559_COMPLEX != 0 with -freciprocal-math" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-4.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-4.c new file mode 100644 index 0000000000..7bf6b9c30b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-4.c @@ -0,0 +1,23 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess } */ +/* { dg-options "-ffinite-math-only" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif + +#if __GCC_IEC_559 != 0 +# error "__GCC_IEC_559 != 0 with -ffinite-math-only" +#endif +#if __GCC_IEC_559_COMPLEX != 0 +# error "__GCC_IEC_559_COMPLEX != 0 with -ffinite-math-only" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-5.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-5.c new file mode 100644 index 0000000000..ea37474fd1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-5.c @@ -0,0 +1,23 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess } */ +/* { dg-options "-fno-signed-zeros" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif + +#if __GCC_IEC_559 != 0 +# error "__GCC_IEC_559 != 0 with -fno-signed-zeros" +#endif +#if __GCC_IEC_559_COMPLEX != 0 +# error "__GCC_IEC_559_COMPLEX != 0 with -fno-signed-zeros" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-6.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-6.c new file mode 100644 index 0000000000..e2be757f86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-6.c @@ -0,0 +1,23 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess } */ +/* { dg-options "-fsingle-precision-constant" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif + +#if __GCC_IEC_559 != 0 +# error "__GCC_IEC_559 != 0 with -fsingle-precision-constant" +#endif +#if __GCC_IEC_559_COMPLEX != 0 +# error "__GCC_IEC_559_COMPLEX != 0 with -fsingle-precision-constant" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-7.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-7.c new file mode 100644 index 0000000000..3b1f79172d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-7.c @@ -0,0 +1,20 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess } */ +/* { dg-options "-fcx-limited-range" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif + +#if __GCC_IEC_559_COMPLEX != 0 +# error "__GCC_IEC_559_COMPLEX != 0 with -fcx-limited-range" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-8.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-8.c new file mode 100644 index 0000000000..1990b944dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-8.c @@ -0,0 +1,20 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess } */ +/* { dg-options "-fcx-fortran-rules" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif + +#if __GCC_IEC_559_COMPLEX != 0 +# error "__GCC_IEC_559_COMPLEX != 0 with -fcx-fortran-rules" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/iec-559-macros-9.c b/SingleSource/Regression/C/gcc-dg/iec-559-macros-9.c new file mode 100644 index 0000000000..6179a3bfe4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iec-559-macros-9.c @@ -0,0 +1,23 @@ +/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */ +/* { dg-do preprocess { target i?86-*-linux* x86_64-*-linux* powerpc*-*-linux* } } */ +/* { dg-options "-std=c11" } */ + +#ifndef __GCC_IEC_559 +# error "__GCC_IEC_559 not defined" +#endif +#ifndef __GCC_IEC_559_COMPLEX +# error "__GCC_IEC_559_COMPLEX not defined" +#endif +#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559 +# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559" +#endif +#if __GCC_IEC_559_COMPLEX < 0 +# error "__GCC_IEC_559_COMPLEX < 0" +#endif + +#if __GCC_IEC_559 < 2 +# error "__GCC_IEC_559 < 2" +#endif +#if __GCC_IEC_559_COMPLEX < 2 +# error "__GCC_IEC_559_COMPLEX < 2" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/if-empty-1.c b/SingleSource/Regression/C/gcc-dg/if-empty-1.c new file mode 100644 index 0000000000..b29a6cb922 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/if-empty-1.c @@ -0,0 +1,23 @@ +/* Test diagnostics for empty bodies in if / else. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wempty-body" } */ + +void +f (int x) +{ + if (x) + ; /* { dg-warning "suggest braces around empty body in an" } */ + if (x) + ; /* By design we don't warn in this case. */ + else + (void)0; + if (x) + (void)0; + else + ; /* { dg-warning "suggest braces around empty body in an" } */ + if (x) + (void)0; + else + (void)0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ifcvt-1.c b/SingleSource/Regression/C/gcc-dg/ifcvt-1.c new file mode 100644 index 0000000000..02bd628d73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ifcvt-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { { { i?86-*-* x86_64-*-* } && { ! ia32 } } || aarch64*-*-* } } } */ +/* { dg-options "-fdump-rtl-ce1 -O2" } */ + +int +foo (int x) +{ + return x > 100 ? x - 2 : x - 1; +} + +/* { dg-final { scan-rtl-dump "3 true changes made" "ce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ifcvt-2.c b/SingleSource/Regression/C/gcc-dg/ifcvt-2.c new file mode 100644 index 0000000000..cdd525e9ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ifcvt-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target { { { i?86-*-* x86_64-*-* } && { ! ia32 } } || aarch64*-*-* } } } */ +/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-unpredictable-cost=100" } */ + +typedef unsigned char uint8_t; +typedef unsigned int uint16_t; + +uint8_t +_xtime (const uint8_t byte, const uint16_t generator) +{ + if (byte & 0x80) + return byte ^ generator; + else + return byte << 1; +} + +/* { dg-final { scan-rtl-dump "3 true changes made" "ce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ifcvt-3.c b/SingleSource/Regression/C/gcc-dg/ifcvt-3.c new file mode 100644 index 0000000000..56fdd753a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ifcvt-3.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target { { aarch64*-*-* i?86-*-* x86_64-*-* } && lp64 } } } */ +/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-unpredictable-cost=100" } */ + +typedef long long s64; + +int +foo (s64 a, s64 b, s64 c) +{ + s64 d = a - b; + + if (d == 0) + return a + c; + else + return b + c + d; +} + +/* This test can be reduced to just return a + c; */ +/* { dg-final { scan-rtl-dump "3 true changes made" "ce1" } } */ +/* { dg-final { scan-assembler-not "sub\.*\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+\.*" { target { aarch64*-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ifcvt-4.c b/SingleSource/Regression/C/gcc-dg/ifcvt-4.c new file mode 100644 index 0000000000..8b2583d00e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ifcvt-4.c @@ -0,0 +1,23 @@ +/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-insns=3 --param max-rtl-if-conversion-unpredictable-cost=100" } */ +/* { dg-additional-options "-misel" { target { powerpc*-*-* } } } */ +/* { dg-additional-options "-march=z196" { target { s390x-*-* } } } */ +/* { dg-additional-options "-mtune-ctrl=^one_if_conv_insn" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-skip-if "Multiple set if-conversion not guaranteed on all subtargets" { "arm*-*-* avr-*-* cris-*-* hppa*64*-*-* visium-*-*" riscv*-*-* msp430-*-* nios2-*-* pru-*-* } } */ +/* { dg-skip-if "" { "s390x-*-*" } { "-m31" } } */ + +typedef int word __attribute__((mode(word))); + +word +foo (word x, word y, word a) +{ + word i = x; + word j = y; + /* Try to make taking the branch likely. */ + if (__builtin_expect (x > y, 0)) + { + i = a; + j = i; + } + return i * j; +} +/* { dg-final { scan-rtl-dump "2 true changes made" "ce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ifcvt-5.c b/SingleSource/Regression/C/gcc-dg/ifcvt-5.c new file mode 100644 index 0000000000..d2a947646a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ifcvt-5.c @@ -0,0 +1,21 @@ +/* Check that multi-insn if-conversion is not done if the override + parameter would not allow it. Set the cost parameter very high + to ensure that the limiting factor is actually the count parameter. */ + +/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-insns=1 --param max-rtl-if-conversion-unpredictable-cost=200" } */ + +typedef int word __attribute__((mode(word))); + +word +foo (word x, word y, word a) +{ + word i = x; + word j = y; + if (x > y) + { + i = a; + j = i; + } + return i * j; +} +/* { dg-final { scan-rtl-dump "0 true changes made" "ce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ifcvt-fabs-1.c b/SingleSource/Regression/C/gcc-dg/ifcvt-fabs-1.c new file mode 100644 index 0000000000..409bbc4fea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ifcvt-fabs-1.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ +/* { dg-options "-O -march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern void abort(void); + +float foo(float f) +{ + if (f < 0.0f) + f = -f; + + return f; +} + +int main(void) +{ + if (foo (-1.0f) != 1.0f) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ifelse-1.c b/SingleSource/Regression/C/gcc-dg/ifelse-1.c new file mode 100644 index 0000000000..2dd2208b01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ifelse-1.c @@ -0,0 +1,21 @@ +/* +{ dg-do compile } +{ dg-options "-W -Wall" } +*/ + + +extern int bar (); +extern int com (); +extern int baz (); +void +foo (a,b) + int a, b; +{ + if (a) + if (b) + bar (); + else + com (); /* { dg-bogus ".*warning.*" "bogus warning" } */ + else + baz (); +} diff --git a/SingleSource/Regression/C/gcc-dg/ifelse-2.c b/SingleSource/Regression/C/gcc-dg/ifelse-2.c new file mode 100644 index 0000000000..0210fcfa4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ifelse-2.c @@ -0,0 +1,34 @@ +/* +{ dg-do run } +{ dg-options "-O2" } +*/ + +extern void abort (void); + +enum Status +{ + P_ON_LOWER = -4, + P_ON_UPPER = -2, + P_FREE = -1 +}; + +void +foo (enum Status *stat, double newUpper, double lower, double max) +{ + if (newUpper >= max) + *stat = P_FREE; + else if (newUpper == lower) + *stat = P_ON_LOWER; +} + +int +main () +{ + enum Status stat = P_ON_UPPER; + + foo (&stat, 5.0, -10.0, 10.0); + + if (stat != P_ON_UPPER) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/iftrap-1.c b/SingleSource/Regression/C/gcc-dg/iftrap-1.c new file mode 100644 index 0000000000..c6d55843bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iftrap-1.c @@ -0,0 +1,40 @@ +/* Verify that we optimize to conditional traps. */ +/* { dg-options "-O" } */ +/* { dg-do compile { target rs6000-*-* powerpc*-*-* sparc*-*-* ia64-*-* } } */ +/* { dg-final { scan-assembler-not "^\t(trap|ta|break)\[ \t\]" } } */ + +void bar (void); + +void f1(int p) +{ + if (p) + __builtin_trap(); +} + +void f2(int p) +{ + if (p) + __builtin_trap(); + else + bar(); +} + +void f3(int p) +{ + if (p) + bar(); + else + __builtin_trap(); +} + +void f4(int p, int q) +{ + if (p) + { + bar(); + if (q) + bar(); + } + else + __builtin_trap(); +} diff --git a/SingleSource/Regression/C/gcc-dg/iftrap-2.c b/SingleSource/Regression/C/gcc-dg/iftrap-2.c new file mode 100644 index 0000000000..8c9c0577ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/iftrap-2.c @@ -0,0 +1,22 @@ +/* Verify that we optimize to conditional traps. */ +/* { dg-options "-O" } */ +/* { dg-do compile { target rs6000-*-* powerpc*-*-* sparc*-*-* ia64-*-* } } */ +/* { dg-final { scan-assembler-not "^\t(trap|ta|break)\[ \t\]" } } */ + +extern void abort(void); + +void f1(int p) +{ + if (p) + __builtin_trap(); + else + abort(); +} + +void f2(int p) +{ + if (p) + abort(); + else + __builtin_trap(); +} diff --git a/SingleSource/Regression/C/gcc-dg/imag-1.c b/SingleSource/Regression/C/gcc-dg/imag-1.c new file mode 100644 index 0000000000..e07ef72e43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/imag-1.c @@ -0,0 +1,18 @@ +/* Test for __imag__ side effects; see PR 33192. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int i, j; + i = 1; + j = __imag__ ++i; + if (i != 2 || j != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/incomplete-typedef-1.c b/SingleSource/Regression/C/gcc-dg/incomplete-typedef-1.c new file mode 100644 index 0000000000..622bf65042 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/incomplete-typedef-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef struct S TS; +typedef union U TU; + +void +foo (void) +{ + (TS) { }; /* { dg-error "invalid use of incomplete typedef" } */ + (TU) { }; /* { dg-error "invalid use of incomplete typedef" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/independent-cloneids-1.c b/SingleSource/Regression/C/gcc-dg/independent-cloneids-1.c new file mode 100644 index 0000000000..efbc1c51da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/independent-cloneids-1.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fipa-cp -fipa-cp-clone -fdump-rtl-final" } */ +/* { dg-skip-if "Odd label definition syntax" { mmix-*-* } } */ + +extern int printf (const char *, ...); + +static int __attribute__ ((noinline)) +foo (int arg) +{ + return 7 * arg; +} + +static int __attribute__ ((noinline)) +bar (int arg) +{ + return arg * arg; +} + +int +baz (int arg) +{ + printf("%d\n", bar (3)); + printf("%d\n", bar (4)); + printf("%d\n", foo (5)); + printf("%d\n", foo (6)); + /* adding or removing the following call should not affect foo + function's clone numbering */ + printf("%d\n", bar (7)); + return foo (8); +} + +/* { dg-final { scan-rtl-dump-times {(?n)^;; Function bar.constprop \(bar[.$_]constprop[.$_]0,} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {(?n)^;; Function bar.constprop \(bar[.$_]constprop[.$_]1,} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {(?n)^;; Function bar.constprop \(bar[.$_]constprop[.$_]2,} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {(?n)^;; Function foo.constprop \(foo[.$_]constprop[.$_]0,} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {(?n)^;; Function foo.constprop \(foo[.$_]constprop[.$_]1,} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {(?n)^;; Function foo.constprop \(foo[.$_]constprop[.$_]2,} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {(?n)^;; Function foo.constprop \(foo[.$_]constprop[.$_]3,} 0 "final" } } */ +/* { dg-final { scan-rtl-dump-times {(?n)^;; Function foo.constprop \(foo[.$_]constprop[.$_]4,} 0 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/infinite-loop.c b/SingleSource/Regression/C/gcc-dg/infinite-loop.c new file mode 100644 index 0000000000..25037a2027 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/infinite-loop.c @@ -0,0 +1,26 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ +void link_error (void); + +void __attribute__ ((noinline,noipa)) +foo(int a) +{ + int b = 0; + + while (1) + { + if (!a) + break; + b = 1; + } + + if (b != 0) + link_error (); +} + +int +main() +{ + foo (0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-1.c b/SingleSource/Regression/C/gcc-dg/init-bad-1.c new file mode 100644 index 0000000000..7c80006670 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-1.c @@ -0,0 +1,44 @@ +/* Test diagnostics for various bad initializers. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void f(void); +void g(void) = f; /* { dg-error "function 'g' is initialized like a variable" } */ + +void h(a) + int a = 1; /* { dg-error "parameter 'a' is initialized" } */ +{ + struct s x = { 0 }; /* { dg-error "variable 'x' has initializer but incomplete type" } */ + /* { dg-warning "excess elements|near init" "excess" { target *-*-* } .-1 } */ + /* { dg-error "storage size" "size" { target *-*-* } .-2 } */ +} + +char s[1] = "x"; +char s1[1] = { "x" }; +char t[1] = "xy"; /* { dg-warning "initializer-string for array of 'char' is too long" } */ +char t1[1] = { "xy" }; /* { dg-warning "initializer-string for array of 'char' is too long" } */ +char u[1] = { "x", "x" }; /* { dg-error "excess elements in 'char.1.' initializer" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ + +int i = { }; + +int j = { 1 }; + +int k = { 1, 2 }; /* { dg-warning "excess elements in scalar initializer" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ + +int a1[1] = { [1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ +int a2[1] = { [-1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ +int a3[1] = { [0 ... 1] = 0 }; /* { dg-error "array index range in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ +int a4[2] = { [1 ... 0] = 0 }; /* { dg-error "empty index range in initializer" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ +int a5[2] = { [0 ... 2] = 0 }; /* { dg-error "array index range in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ +int a6[2] = { [-1 ... 1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ +int a7[] = { [-1 ... 1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-2.c b/SingleSource/Regression/C/gcc-dg/init-bad-2.c new file mode 100644 index 0000000000..57fd9f99f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-2.c @@ -0,0 +1,33 @@ +/* Test diagnostics for various bad initializers. Test cases with + standard syntax with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic" } */ + +void f(void); +void g(void) = f; /* { dg-error "function 'g' is initialized like a variable" } */ + +void h(a) + int a = 1; /* { dg-error "parameter 'a' is initialized" } */ +{ + struct s x = { 0 }; /* { dg-error "variable 'x' has initializer but incomplete type" } */ + /* { dg-message "excess elements|near init" "near" { target *-*-* } .-1 } */ + /* { dg-error "storage size" "size" { target *-*-* } .-2 } */ +} + +char s[1] = "x"; +char s1[1] = { "x" }; +char t[1] = "xy"; /* { dg-warning "initializer-string for array of 'char' is too long" } */ +char t1[1] = { "xy" }; /* { dg-warning "initializer-string for array of 'char' is too long" } */ +char u[1] = { "x", "x" }; /* { dg-error "excess elements in 'char.1.' initializer" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ + +int j = { 1 }; + +int k = { 1, 2 }; /* { dg-warning "excess elements in scalar initializer" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ + +int a1[1] = { [1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ +int a2[1] = { [-1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-3.c b/SingleSource/Regression/C/gcc-dg/init-bad-3.c new file mode 100644 index 0000000000..c22e8ec669 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-3.c @@ -0,0 +1,33 @@ +/* Test diagnostics for various bad initializers. Test cases with + standard syntax with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +void f(void); +void g(void) = f; /* { dg-error "function 'g' is initialized like a variable" } */ + +void h(a) + int a = 1; /* { dg-error "parameter 'a' is initialized" } */ +{ + struct s x = { 0 }; /* { dg-error "variable 'x' has initializer but incomplete type" } */ + /* { dg-message "excess elements|near init" "near" { target *-*-* } .-1 } */ + /* { dg-error "storage size" "size" { target *-*-* } .-2 } */ +} + +char s[1] = "x"; +char s1[1] = { "x" }; +char t[1] = "xy"; /* { dg-error "initializer-string for array of 'char' is too long" } */ +char t1[1] = { "xy" }; /* { dg-error "initializer-string for array of 'char' is too long" } */ +char u[1] = { "x", "x" }; /* { dg-error "excess elements in 'char.1.' initializer" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ + +int j = { 1 }; + +int k = { 1, 2 }; /* { dg-error "excess elements in scalar initializer" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ + +int a1[1] = { [1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ +int a2[1] = { [-1] = 0 }; /* { dg-error "array index in initializer exceeds array bounds" } */ +/* { dg-message "near init" "near" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-4.c b/SingleSource/Regression/C/gcc-dg/init-bad-4.c new file mode 100644 index 0000000000..c8c11845c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-4.c @@ -0,0 +1,5 @@ +/* PR c/25875 */ +/* Origin: Richard Guenther */ +/* { dg-do compile } */ + +struct A { } a = (struct A) {{ (X)0 }}; /* { dg-error "no members|extra brace|near|undeclared|constant|compound|excess" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-5.c b/SingleSource/Regression/C/gcc-dg/init-bad-5.c new file mode 100644 index 0000000000..18cee43b53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-5.c @@ -0,0 +1,5 @@ +/* PR c/28136 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int i = (struct A[]) {}; /* { dg-error "incomplete|empty|initialization" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-6.c b/SingleSource/Regression/C/gcc-dg/init-bad-6.c new file mode 100644 index 0000000000..8235f5d967 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-6.c @@ -0,0 +1,12 @@ +/* ICE arising from bug computing composite type of zero-length array + types: PR 35433. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int* X; +typedef int* Y; + +X (*p)[][0]; +Y (*q)[][0]; + +typeof(*(0 ? p : q)) x = { 0 }; /* { dg-warning "excess elements in array initializer|near initialization" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-7.c b/SingleSource/Regression/C/gcc-dg/init-bad-7.c new file mode 100644 index 0000000000..de5e570978 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-7.c @@ -0,0 +1,11 @@ +/* PR c/37724 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic" } */ + +struct f +{ + int *a; +}; + +char b[10]; +struct f g = {b}; /* { dg-warning "initialization of 'int \\*' from incompatible pointer type|near initialization for" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-8.c b/SingleSource/Regression/C/gcc-dg/init-bad-8.c new file mode 100644 index 0000000000..f7b0f7f688 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-8.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S { int i, j, k; }; + +void +foo (void) +{ + struct S s = { .i = 1, .j = 2, .l = 4}; /* { dg-error "35: .struct S. has no member named .l." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/init-bad-9.c b/SingleSource/Regression/C/gcc-dg/init-bad-9.c new file mode 100644 index 0000000000..035d34940d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-bad-9.c @@ -0,0 +1,12 @@ +/* PR c/71552 - Confusing error for incorrect struct initialization */ +/* { dg-do compile } */ + +struct A { void *p; }; +struct B { struct A *p; }; +struct A a; + +/* Verify that the initializer is diagnosed for its incompatibility + with the type of the object being initialized, not for its lack + of constness (which is a lesser problem). */ +struct B b = { a }; /* { dg-error "incompatible types when initializing" } */ +struct B *p = a; /* { dg-error "incompatible types when initializing" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-compare-1.c b/SingleSource/Regression/C/gcc-dg/init-compare-1.c new file mode 100644 index 0000000000..a473f598cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-compare-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ + +extern int a, b; +int c = &a == &a; +int d = &a != &b; diff --git a/SingleSource/Regression/C/gcc-dg/init-desig-obs-1.c b/SingleSource/Regression/C/gcc-dg/init-desig-obs-1.c new file mode 100644 index 0000000000..52639c86b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-desig-obs-1.c @@ -0,0 +1,19 @@ +/* Test obsolete forms of designated initializers. Test with default + warning options: valid forms are accepted, while ".member" without + "=" should not be (bug 16667). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ +struct s { int a; }; +struct s s0 = { .a = 1 }; +struct s s1 = { a: 1 }; + +int x0[] = { [0] = 1 }; +int x1[] = { [0] 1 }; + +/* Invalid syntax: multiple designators without "=". */ +int x2[2][2] = { [0][0] 1 }; /* { dg-error "syntax error|parse error|expected" } */ + + +/* Invalid syntax: C99-style structure designator without "=". */ +struct s s2 = { .a 1 }; /* { dg-error "syntax error|parse error|expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-desig-obs-2.c b/SingleSource/Regression/C/gcc-dg/init-desig-obs-2.c new file mode 100644 index 0000000000..4fbd456431 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-desig-obs-2.c @@ -0,0 +1,11 @@ +/* Test obsolete forms of designated initializers. Test with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic" } */ +struct s { int a; }; +struct s s0 = { .a = 1 }; +struct s s1 = { a: 1 }; /* { dg-warning "obsolete use of designated initializer with ':'" } */ + +int x0[] = { [0] = 1 }; +int x1[] = { [0] 1 }; /* { dg-warning "obsolete use of designated initializer without '='" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-desig-obs-3.c b/SingleSource/Regression/C/gcc-dg/init-desig-obs-3.c new file mode 100644 index 0000000000..e3fca6cdd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-desig-obs-3.c @@ -0,0 +1,11 @@ +/* Test obsolete forms of designated initializers. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ +struct s { int a; }; +struct s s0 = { .a = 1 }; +struct s s1 = { a: 1 }; /* { dg-error "obsolete use of designated initializer with ':'" } */ + +int x0[] = { [0] = 1 }; +int x1[] = { [0] 1 }; /* { dg-error "obsolete use of designated initializer without '='" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-empty-1.c b/SingleSource/Regression/C/gcc-dg/init-empty-1.c new file mode 100644 index 0000000000..39a5174ba8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-empty-1.c @@ -0,0 +1,9 @@ +/* Test diagnostic for empty initializer braces. Test with no special + options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +struct s { int a; } x = { }; + +struct s *p = &(struct s){ }; diff --git a/SingleSource/Regression/C/gcc-dg/init-empty-2.c b/SingleSource/Regression/C/gcc-dg/init-empty-2.c new file mode 100644 index 0000000000..597d72d374 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-empty-2.c @@ -0,0 +1,9 @@ +/* Test diagnostic for empty initializer braces. Test with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic" } */ + +struct s { int a; } x = { }; /* { dg-warning "ISO C forbids empty initializer braces" } */ + +struct s *p = &(struct s){ }; /* { dg-warning "ISO C forbids empty initializer braces" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-empty-3.c b/SingleSource/Regression/C/gcc-dg/init-empty-3.c new file mode 100644 index 0000000000..136931867c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-empty-3.c @@ -0,0 +1,9 @@ +/* Test diagnostic for empty initializer braces. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +struct s { int a; } x = { }; /* { dg-error "ISO C forbids empty initializer braces" } */ + +struct s *p = &(struct s){ }; /* { dg-error "ISO C forbids empty initializer braces" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-excess-1.c b/SingleSource/Regression/C/gcc-dg/init-excess-1.c new file mode 100644 index 0000000000..ade6fd0859 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-excess-1.c @@ -0,0 +1,48 @@ +/* Test for various cases of excess initializers for empty objects: + bug 21873. Various versions of GCC ICE, hang or loop repeating + diagnostics on various of these tests. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 { }; +struct s1 { int a; }; +struct s2 { int a; int b; }; + +int a0[0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +int a1[0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +int a2[0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +int a3[1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +int a4[][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +int a5[][0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +int a6[][0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +int a7[][1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ + +struct s0 b0[0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b1[0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b2[0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b3[1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b4[][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b5[][0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b6[][0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b7[][1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b8[1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s0 b9[] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ + +struct s1 c0[0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s1 c1[0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s1 c2[0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s1 c3[1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s1 c4[][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s1 c5[][0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s1 c6[][0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s1 c7[][1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ + +struct s2 d0[0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s2 d1[0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s2 d2[0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s2 d3[1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s2 d4[][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s2 d5[][0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s2 d6[][0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ +struct s2 d7[][1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-excess-2.c b/SingleSource/Regression/C/gcc-dg/init-excess-2.c new file mode 100644 index 0000000000..0e91b60950 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-excess-2.c @@ -0,0 +1,48 @@ +/* Test for diagnostics about excess initializers when using a macro + defined in a system header: + c/71115 - Missing warning: excess elements in struct initializer. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-require-effective-target int32plus } */ + +#include + +int* a[1] = { + 0, + NULL /* { dg-warning "excess elements|near init" } */ +}; + +const char str[1] = { + 0, + NULL /* { dg-warning "excess elements|near init" } */ +}; + +struct S { + int *a; +} s = { + 0, + NULL /* { dg-warning "excess elements|near init" } */ +}; + +struct __attribute__ ((designated_init)) S2 { + int *a; +} s2 = { + NULL /* { dg-warning "positional initialization|near init" } */ +}; + +union U { + int *a; +} u = { + 0, + NULL /* { dg-warning "excess elements|near init" } */ +}; + +int __attribute__ ((vector_size (16))) ivec = { + 0, 0, 0, 0, + NULL /* { dg-warning "excess elements|near init" } */ +}; + +int* scal = { + 0, + NULL /* { dg-warning "excess elements|near init" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/init-excess-3.c b/SingleSource/Regression/C/gcc-dg/init-excess-3.c new file mode 100644 index 0000000000..c03a98487b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-excess-3.c @@ -0,0 +1,15 @@ +/* Test for various cases of excess initializers for char arrays, + bug 107926. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + + +char s0[] = {"abc",1}; /* { dg-error "'char..' initializer|near init" } */ +char s1[] = {"abc","a"}; /* { dg-error "'char..' initializer|near init" } */ +char s2[] = {1,"abc"}; /* { dg-error "'char..' initializer|near init|computable at load time" } */ +/* { dg-warning "integer from pointer without a cast" "" { target *-*-* } .-1 } */ + +char s3[5] = {"abc",1}; /* { dg-error "'char.5.' initializer|near init" } */ +char s4[5] = {"abc","a"}; /* { dg-error "'char.5.' initializer|near init" } */ +char s5[5] = {1,"abc"}; /* { dg-error "'char.5.' initializer|near init|computable at load time" } */ +/* { dg-warning "integer from pointer without a cast" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-rounding-math-1.c b/SingleSource/Regression/C/gcc-dg/init-rounding-math-1.c new file mode 100644 index 0000000000..2bece1a09d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-rounding-math-1.c @@ -0,0 +1,11 @@ +/* Test static initializer folding of implicit conversions to floating point + types, even with -frounding-math and related options. Bug 103031. */ +/* { dg-do compile } */ +/* { dg-options "-frounding-math -ftrapping-math -fsignaling-nans" } */ + +float f1 = -1ULL; +float f2 = __DBL_MAX__; +float f3 = __DBL_MIN__; +float f4 = 0.1; +float f5 = __builtin_nans (""); +double d1 = -1ULL; diff --git a/SingleSource/Regression/C/gcc-dg/init-string-1.c b/SingleSource/Regression/C/gcc-dg/init-string-1.c new file mode 100644 index 0000000000..67bd7961b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-string-1.c @@ -0,0 +1,60 @@ +/* String initializers for arrays must not be parenthesized. Bug + 11250 from h.b.furuseth at usit.uio.no. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +#include + +char *a = "a"; +char *b = ("b"); +char *c = (("c")); + +char d[] = "d"; +char e[] = ("e"); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ +char f[] = (("f")); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ + +signed char g[] = { "d" }; +unsigned char h[] = { ("e") }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ +signed char i[] = { (("f")) }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ + + +struct s { char a[10]; int b; wchar_t c[10]; }; + +struct s j = { + "j", + 1, + (L"j") + /* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ +}; /* { dg-bogus "warning" "warning in place of error" } */ + +struct s k = { + (("k")), /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ + 1, + L"k" +}; + +struct s l = { + .c = (L"l"), /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ + .a = "l" +}; + +struct s m = { + .c = L"m", + .a = ("m") + /* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ +}; /* { dg-bogus "warning" "warning in place of error" } */ + +char *n = (char []){ "n" }; + +char *o = (char []){ ("o") }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ + +wchar_t *p = (wchar_t [5]){ (L"p") }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/init-string-2.c b/SingleSource/Regression/C/gcc-dg/init-string-2.c new file mode 100644 index 0000000000..ded9bf2770 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-string-2.c @@ -0,0 +1,57 @@ +/* Character arrays but not arrays of compatible enum type may be + initialized by narrow string literals. Arrays of type compatible + with wchar_t, including compatible enums, may be initialized by + wide string literals. Use -fshort-enums -fshort-wchar so the + relevant circumstances can be obtained portably; may still fail if + char, short and int do not all have distinct precisions. */ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-std=c99 -pedantic-errors -fshort-enums -fshort-wchar" } */ + +#include +#include + +typedef enum { schar_min = SCHAR_MIN, schar_max = SCHAR_MAX } schar; +typedef enum { uchar_max = UCHAR_MAX } uchar; +typedef enum { shrt_min = SHRT_MIN, shrt_max = SHRT_MAX } sshrt; +typedef enum { ushrt_max = USHRT_MAX } ushrt; + +char a0[] = "foo"; +const signed char a2[4] = "foo"; +volatile unsigned char a3[3] = "foo"; +wchar_t a4[] = L"foo"; +const wchar_t a5[3] = L"foo"; +volatile ushrt a6[] = L"foo"; + +schar a7[] = "foo"; /* { dg-error "string constant" "a7" } */ +uchar a8[] = "foo"; /* { dg-error "string constant" "a8" } */ +const schar a9[] = "foo"; /* { dg-error "string constant" "a9" } */ +short a10[] = L"foo"; /* { dg-error "string constant" "a10" } */ +const sshrt a11[] = L"foo"; /* { dg-error "string constant" "a11" } */ +char a12[] = L"foo"; /* { dg-error "from a string literal with type array of" "a12" } */ +wchar_t a13[] = "foo"; /* { dg-error "from a string literal with type array of .char." "a13" } */ + +char b0[] = { "foo" }; +const signed char b2[4] = { "foo" }; +volatile unsigned char b3[3] = { "foo" }; +wchar_t b4[] = { L"foo" }; +const wchar_t b5[3] = { L"foo" }; +volatile ushrt b6[] = { L"foo" }; + +schar b7[] = { "foo" }; /* { dg-error "string constant" "b7" } */ +uchar b8[] = { "foo" }; /* { dg-error "string constant" "b8" } */ +const schar b9[] = { "foo" }; /* { dg-error "string constant" "b9" } */ +short b10[] = { L"foo" }; /* { dg-error "string constant" "b10" } */ +const sshrt b11[] = { L"foo" }; /* { dg-error "string constant" "b11" } */ +char b12[] = { L"foo" }; /* { dg-error "from a string literal with type array of" "b12" } */ +wchar_t b13[] = { "foo" }; /* { dg-error "from a string literal with type array of .char." "b13" } */ + +struct s { signed char a[10]; int b; ushrt c[10]; }; + +struct s c = { "foo", 0, L"bar" }; +struct s d = { .c = L"bar", .a = "foo" }; + +ushrt *e = (ushrt [7]){ L"bar" }; + +wchar_t f[5][5] = { L"foo", L"bar" }; +ushrt g[5][5] = { L"foo", L"bar" }; diff --git a/SingleSource/Regression/C/gcc-dg/init-string-3.c b/SingleSource/Regression/C/gcc-dg/init-string-3.c new file mode 100644 index 0000000000..e955f2e6ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-string-3.c @@ -0,0 +1,58 @@ +/* PR tree-optimization/71625 - missing strlen optimization on different + array initialization style + + Verify that zero-length array initialization results in the expected + array sizes. + + { dg-do compile } + { dg-options "-Wall -Wno-unused-local-typedefs" } */ + +#define A(expr) typedef char A[-1 + 2 * !!(expr)]; + +const char a[] = { }; + +A (sizeof a == 0); + + +const char b[0] = { }; + +A (sizeof b == 0); + + +const char c[0] = { 1 }; /* { dg-warning "excess elements" } */ + +A (sizeof c == 0); + + +void test_auto_empty (void) +{ + const char a[] = { }; + + A (sizeof a == 0); +} + +void test_auto_zero_length (void) +{ + const char a[0] = { }; + + A (sizeof a == 0); + + const char b[0] = { 0 }; /* { dg-warning "excess elements" } */ + + A (sizeof b == 0); + + const char c[0] = ""; + + A (sizeof c == 0); +} + + +void test_compound_zero_length (void) +{ + A (sizeof (const char[]){ } == 0); + A (sizeof (const char[0]){ } == 0); + A (sizeof (const char[0]){ 0 } == 0); /* { dg-warning "excess elements" } */ + A (sizeof (const char[0]){ 1 } == 0); /* { dg-warning "excess elements" } */ + A (sizeof (const char[0]){ "" } == 0); + A (sizeof (const char[0]){ "1" } == 0); /* { dg-warning "too long" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/init-undef-1.c b/SingleSource/Regression/C/gcc-dg/init-undef-1.c new file mode 100644 index 0000000000..b775889cea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/init-undef-1.c @@ -0,0 +1,8 @@ +/* Invalid initializers should not receive an "is not constant" + error. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int p = c; /* { dg-error "undeclared" } */ +struct s { int a; } x = { b }; /* { dg-error "undeclared" } */ diff --git a/SingleSource/Regression/C/gcc-dg/initpri1.c b/SingleSource/Regression/C/gcc-dg/initpri1.c new file mode 100644 index 0000000000..b6afd7690d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/initpri1.c @@ -0,0 +1,62 @@ +/* { dg-do run { target init_priority } } */ + +extern void abort (void); + +int i; +int j; + +void c1() __attribute__((constructor (500))); +void c2() __attribute__((constructor (700))); +void c3() __attribute__((constructor (600))); + +void c1() { + if (i++ != 0) + abort (); +} + +void c2() { + if (i++ != 2) + abort (); +} + +void c3() { + if (i++ != 1) + abort (); +} + +void d1() __attribute__((destructor (500))); +void d2() __attribute__((destructor (700))); +void d3() __attribute__((destructor (600))); + +void d1() { + if (--i != 0) + abort (); +} + +void d2() { + if (--i != 2) + abort (); +} + +void d3() { + if (j != 2) + abort (); + if (--i != 1) + abort (); +} + +void cd4() __attribute__((constructor (800), destructor (800))); + +void cd4() { + if (i != 3) + abort (); + ++j; +} + +int main () { + if (i != 3) + return 1; + if (j != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/initpri2.c b/SingleSource/Regression/C/gcc-dg/initpri2.c new file mode 100644 index 0000000000..fa9fda0d7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/initpri2.c @@ -0,0 +1,39 @@ +/* { dg-do compile { target init_priority } } */ + +/* Priorities must be in the range [0, 65535]. */ +void c1() + __attribute__((constructor (-1))); /* { dg-error "priorities" } */ +void c2() + __attribute__((constructor (65536))); /* { dg-error "priorities" } */ +void d1() + __attribute__((destructor (-1))); /* { dg-error "priorities" } */ +void d2() + __attribute__((destructor (65536))); /* { dg-error "priorities" } */ + +/* Priorities 0-100 are reserved for system libraries. */ +void c3() + __attribute__((constructor (50))); /* { dg-warning "reserved" } */ +void d3() + __attribute__((constructor (50))); /* { dg-warning "reserved" } */ + +/* Priorities must be integral constants. */ + +/* Pointers, even with constant values, are not allowed. */ +void c4() + __attribute__((constructor ((void*) 500))); /* { dg-error "priorities" } */ +void d4() + __attribute__((destructor ((void*) 500))); /* { dg-error "priorities" } */ + +/* Integer variables are not allowed. */ +int i; +void c5() + __attribute__((constructor ((i)))); /* { dg-error "priorities" } */ +void d5() + __attribute__((destructor ((i)))); /* { dg-error "priorities" } */ + +/* Enumeration constants are allowed. */ +enum E { e = 500 }; +void c6() + __attribute__((constructor ((e)))); +void d6() + __attribute__((destructor ((e)))); diff --git a/SingleSource/Regression/C/gcc-dg/initpri3.c b/SingleSource/Regression/C/gcc-dg/initpri3.c new file mode 100644 index 0000000000..1633da0141 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/initpri3.c @@ -0,0 +1,64 @@ +/* { dg-do run { target init_priority } } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -O3" } */ + +extern void abort (); + +int i; +int j; + +void c1() __attribute__((constructor (500))); +void c2() __attribute__((constructor (700))); +void c3() __attribute__((constructor (600))); + +void c1() { + if (i++ != 0) + abort (); +} + +void c2() { + if (i++ != 2) + abort (); +} + +void c3() { + if (i++ != 1) + abort (); +} + +void d1() __attribute__((destructor (500))); +void d2() __attribute__((destructor (700))); +void d3() __attribute__((destructor (600))); + +void d1() { + if (--i != 0) + abort (); +} + +void d2() { + if (--i != 2) + abort (); +} + +void d3() { + if (j != 2) + abort (); + if (--i != 1) + abort (); +} + +void cd4() __attribute__((constructor (800), destructor (800))); + +void cd4() { + if (i != 3) + abort (); + ++j; +} + +int main () { + if (i != 3) + return 1; + if (j != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-1.c b/SingleSource/Regression/C/gcc-dg/inline-1.c new file mode 100644 index 0000000000..06059b9553 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-1.c @@ -0,0 +1,28 @@ +/* Verify that DECL_INLINE gets copied between DECLs properly. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fgnu89-inline" } */ +/* { dg-final { if [ istarget hppa*-*-* ] { scan-assembler-not "xyzzy?,%r" } else { scan-assembler-not "xyzzy" } } } */ + +/* Test that declaration followed by definition inlines. */ +static inline int xyzzy0 (int); +static int xyzzy0 (int x) { return x; } +int test0 (void) +{ + return xyzzy0 (5); +} + +/* Test that definition following declaration inlines. */ +static int xyzzy1 (int); +static inline int xyzzy1 (int x) { return x; } +int test1 (void) +{ + return xyzzy1 (5); +} + +/* Test that redeclaration inside a function body inlines. */ +extern inline int xyzzy2 (int x) { return x; } +int test2 (void) +{ + extern int xyzzy2 (int); + return xyzzy2 (5); +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-10.c b/SingleSource/Regression/C/gcc-dg/inline-10.c new file mode 100644 index 0000000000..f7a7592a6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-10.c @@ -0,0 +1,6 @@ +/* Test inline main, gnu99 mode, freestanding, -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -ffreestanding -pedantic-errors" } */ + +inline int main (void) { return 1; } diff --git a/SingleSource/Regression/C/gcc-dg/inline-11.c b/SingleSource/Regression/C/gcc-dg/inline-11.c new file mode 100644 index 0000000000..dd07fdd11d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-11.c @@ -0,0 +1,14 @@ +/* Test misuses of inline. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +/* These should perhaps be hard errors, but are pedwarns at + present. */ + +inline int a; /* { dg-warning "variable 'a' declared 'inline'" } */ +inline int (*b)(void); /* { dg-warning "variable 'b' declared 'inline'" } */ +typedef inline void c(void); /* { dg-warning "typedef 'c' declared 'inline'" } */ +typedef inline int d; /* { dg-warning "typedef 'd' declared 'inline'" } */ +void e(inline int f(void)); /* { dg-warning "parameter 'f' declared 'inline'" } */ +void g(inline int(void)); /* { dg-warning "parameter '\\({anonymous}\\)' declared 'inline'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-12.c b/SingleSource/Regression/C/gcc-dg/inline-12.c new file mode 100644 index 0000000000..c289517635 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-12.c @@ -0,0 +1,14 @@ +/* Test misuses of inline. -pedantic-errors test. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +/* These should perhaps be hard errors, but are pedwarns at + present. */ + +inline int a; /* { dg-error "variable 'a' declared 'inline'" } */ +inline int (*b)(void); /* { dg-error "variable 'b' declared 'inline'" } */ +typedef inline void c(void); /* { dg-error "typedef 'c' declared 'inline'" } */ +typedef inline int d; /* { dg-error "typedef 'd' declared 'inline'" } */ +void e(inline int f(void)); /* { dg-error "parameter 'f' declared 'inline'" } */ +void g(inline int(void)); /* { dg-error "parameter '\\({anonymous}\\)' declared 'inline'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-13.c b/SingleSource/Regression/C/gcc-dg/inline-13.c new file mode 100644 index 0000000000..62a898c3c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-13.c @@ -0,0 +1,56 @@ +/* Verify basic C99 inline functionality. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ +/* { dg-final { scan-assembler-not "dontgenerate" } } */ +/* { dg-final { scan-assembler "func1" } } */ +/* { dg-final { scan-assembler "func2" } } */ +/* { dg-final { scan-assembler "func3" } } */ +/* { dg-final { scan-assembler "func4" } } */ +/* { dg-final { scan-assembler "func5" } } */ +/* { dg-final { scan-assembler "func6" } } */ +/* { dg-final { scan-assembler "func7" } } */ +/* { dg-final { scan-assembler "func8" } } */ +/* { dg-final { scan-assembler "func9" } } */ + +inline int dontgenerate1 (void) +{ + return 1; +} + +inline int dontgenerate2 (void); +inline int dontgenerate2 (void) +{ + return 2; +} + +inline int dontgenerate3 (void) +{ + return 3; +} +inline int dontgenerate3 (void); + +extern inline int func1 (void) { return 1; } + +extern inline int func2 (void); +inline int func2 (void) { return 2; } + +inline int func3 (void) { return 3; } +extern inline int func3 (void); + +inline int func4 (void); +extern inline int func4 (void) { return 4; } + +extern inline int func5 (void) { return 5; } +inline int func5 (void); + +extern int func6 (void); +inline int func6 (void) { return 6; } + +inline int func7 (void) { return 7; } +extern int func7 (void); + +inline int func8 (void); +extern int func8 (void) { return 8; } + +extern int func9 (void) { return 9; } +inline int func9 (void); diff --git a/SingleSource/Regression/C/gcc-dg/inline-14.c b/SingleSource/Regression/C/gcc-dg/inline-14.c new file mode 100644 index 0000000000..b2bfb67c5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-14.c @@ -0,0 +1,23 @@ +/* Check that you can't redefine a C99 inline function. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +extern inline int func1 (void) /* { dg-message "note: previous definition" } */ +{ + return 1; +} + +inline int func1 (void) /* { dg-error "redefinition" } */ +{ + return 1; +} + +inline int func2 (void) /* { dg-message "note: previous definition" } */ +{ + return 2; +} + +inline int func2 (void) /* { dg-error "redefinition" } */ +{ + return 2; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-15.c b/SingleSource/Regression/C/gcc-dg/inline-15.c new file mode 100644 index 0000000000..e668191159 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-15.c @@ -0,0 +1,7 @@ +/* Check that an error message is produced when a C99 inline function + is never defined. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +extern inline int func1 (void); /* { dg-warning "never defined" } */ +inline int func2 (void); /* { dg-warning "never defined" } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-16.c b/SingleSource/Regression/C/gcc-dg/inline-16.c new file mode 100644 index 0000000000..4f9fe978ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-16.c @@ -0,0 +1,22 @@ +/* { dg-do link } */ +/* { dg-options "-std=c99" } */ + +static inline __SIZE_TYPE__ +func1(const volatile void * base, __SIZE_TYPE__ byteOffset) +{ + volatile __SIZE_TYPE__ *addr + = (volatile __SIZE_TYPE__ *)((__SIZE_TYPE__)base + byteOffset); + return *addr; +} + +static inline __SIZE_TYPE__ +func2(__SIZE_TYPE__ data) +{ + return func1(&data, 0); +} + +int main(int argc, char *argv[]) { + __SIZE_TYPE__ b = func2(argc); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-17.c b/SingleSource/Regression/C/gcc-dg/inline-17.c new file mode 100644 index 0000000000..235ad8b001 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-17.c @@ -0,0 +1,24 @@ +/* Test __attribute__((gnu_inline)). */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ +/* { dg-final { scan-assembler "func1" } } */ +/* { dg-final { scan-assembler-not "func2" } } */ +/* { dg-final { scan-assembler "func3" } } */ +/* { dg-final { scan-assembler "func4" } } */ + +#if __STDC_VERSION__ >= 199901L +# define inline __attribute__((gnu_inline)) inline +#endif + +extern inline int func1 (void) { return 0; } +inline int func1 (void) { return 1; } + +extern int func2 (void); +extern inline int func2 (void) { return 2; } + +inline int func3 (void); +inline int func3 (void) { return 3; } + +extern int func4 (void); +extern inline int func4 (void) { return 4; } +int func4 (void) { return 5; } diff --git a/SingleSource/Regression/C/gcc-dg/inline-18.c b/SingleSource/Regression/C/gcc-dg/inline-18.c new file mode 100644 index 0000000000..5a37195be9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-18.c @@ -0,0 +1,28 @@ +/* Test -fgnu89-extern-inline. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -fgnu89-inline" } */ +/* { dg-final { scan-assembler "func1" } } */ +/* { dg-final { scan-assembler-not "func2" } } */ +/* { dg-final { scan-assembler "func3" } } */ +/* { dg-final { scan-assembler "func4" } } */ + +#ifndef __GNUC_GNU_INLINE__ +#error __GNUC_GNU_INLINE__ is not defined +#endif + +#ifdef __GNUC_STDC_INLINE__ +#error __GNUC_STDC_INLINE__ is defined +#endif + +extern inline int func1 (void) { return 0; } +inline int func1 (void) { return 1; } + +extern int func2 (void); +extern inline int func2 (void) { return 2; } + +inline int func3 (void); +inline int func3 (void) { return 3; } + +extern int func4 (void); +extern inline int func4 (void) { return 4; } +int func4 (void) { return 5; } diff --git a/SingleSource/Regression/C/gcc-dg/inline-19.c b/SingleSource/Regression/C/gcc-dg/inline-19.c new file mode 100644 index 0000000000..96dceb4335 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-19.c @@ -0,0 +1,28 @@ +/* Test -fgnu89-extern-inline. */ +/* { dg-do compile } */ +/* { dg-options "-fgnu89-inline" } */ +/* { dg-final { scan-assembler "func1" } } */ +/* { dg-final { scan-assembler-not "func2" } } */ +/* { dg-final { scan-assembler "func3" } } */ +/* { dg-final { scan-assembler "func4" } } */ + +#ifndef __GNUC_GNU_INLINE__ +#error __GNUC_GNU_INLINE__ is not defined +#endif + +#ifdef __GNUC_STDC_INLINE__ +#error __GNUC_STDC_INLINE__ is defined +#endif + +extern inline int func1 (void) { return 0; } +inline int func1 (void) { return 1; } + +extern int func2 (void); +extern inline int func2 (void) { return 2; } + +inline int func3 (void); +inline int func3 (void) { return 3; } + +extern int func4 (void); +extern inline int func4 (void) { return 4; } +int func4 (void) { return 5; } diff --git a/SingleSource/Regression/C/gcc-dg/inline-2.c b/SingleSource/Regression/C/gcc-dg/inline-2.c new file mode 100644 index 0000000000..6aceb74545 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-2.c @@ -0,0 +1,18 @@ +/* Ensure that we continue to consider FOO local, even though + it has been deferred. */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O3 -finline-limit=0 -fpic" } */ + +static int foo(void) +{ + return 3; +} + +int bar(void) +{ + /* Call twice to avoid bypassing the limit for functions called once. */ + return foo() + foo() + 1; +} + +/* { dg-final { scan-assembler-not "PLT" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-assembler-not "plt" { target powerpc*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-20.c b/SingleSource/Regression/C/gcc-dg/inline-20.c new file mode 100644 index 0000000000..31354abca9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-20.c @@ -0,0 +1,64 @@ +/* Test -fno-gnu89-extern-inline. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -fno-gnu89-inline" } */ +/* { dg-final { scan-assembler-not "dontgenerate" } } */ +/* { dg-final { scan-assembler "func1" } } */ +/* { dg-final { scan-assembler "func2" } } */ +/* { dg-final { scan-assembler "func3" } } */ +/* { dg-final { scan-assembler "func4" } } */ +/* { dg-final { scan-assembler "func5" } } */ +/* { dg-final { scan-assembler "func6" } } */ +/* { dg-final { scan-assembler "func7" } } */ +/* { dg-final { scan-assembler "func8" } } */ +/* { dg-final { scan-assembler "func9" } } */ + +#ifdef __GNUC_GNU_INLINE__ +#error __GNUC_GNU_INLINE__ is defined +#endif + +#ifndef __GNUC_STDC_INLINE__ +#error __GNUC_STDC_INLINE__ is not defined +#endif + +inline int dontgenerate1 (void) +{ + return 1; +} + +inline int dontgenerate2 (void); +inline int dontgenerate2 (void) +{ + return 2; +} + +inline int dontgenerate3 (void) +{ + return 3; +} +inline int dontgenerate3 (void); + +extern inline int func1 (void) { return 1; } + +extern inline int func2 (void); +inline int func2 (void) { return 2; } + +inline int func3 (void) { return 3; } +extern inline int func3 (void); + +inline int func4 (void); +extern inline int func4 (void) { return 4; } + +extern inline int func5 (void) { return 5; } +inline int func5 (void); + +extern int func6 (void); +inline int func6 (void) { return 6; } + +inline int func7 (void) { return 7; } +extern int func7 (void); + +inline int func8 (void); +extern int func8 (void) { return 8; } + +extern int func9 (void) { return 9; } +inline int func9 (void); diff --git a/SingleSource/Regression/C/gcc-dg/inline-21.c b/SingleSource/Regression/C/gcc-dg/inline-21.c new file mode 100644 index 0000000000..c7f9a07b6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-21.c @@ -0,0 +1,4 @@ +/* Test -fno-gnu89-extern-inline. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -fno-gnu89-inline" } */ +/* { dg-error "only supported in GNU99 or C99 mode" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-22.c b/SingleSource/Regression/C/gcc-dg/inline-22.c new file mode 100644 index 0000000000..6795c5f4ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-22.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-funit-at-a-time -Wno-attributes" } */ +/* { dg-add-options bind_pic_locally } */ +/* Verify we can inline without a complete prototype and with promoted + arguments. See also PR32492. */ +__attribute__((always_inline)) void f1() {} +__attribute__((always_inline)) void f2(char x) {} +void f3() { f1(); f2(0); } diff --git a/SingleSource/Regression/C/gcc-dg/inline-23.c b/SingleSource/Regression/C/gcc-dg/inline-23.c new file mode 100644 index 0000000000..2829ecbf7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-23.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ +/* Make sure we can inline a varargs function whose variable arguments + are not used. See PR32493. */ +#include + +typedef __INTPTR_TYPE__ my_intptr_t; + +static inline __attribute__((always_inline)) void __check_printsym_format(const +char *fmt, ...) +{ +} +static inline __attribute__((always_inline)) void print_symbol(const char *fmt, +my_intptr_t addr) +{ + __check_printsym_format(fmt, ""); +} +void do_initcalls(void **call) +{ + print_symbol(": %s()", (my_intptr_t) *call); +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-24.c b/SingleSource/Regression/C/gcc-dg/inline-24.c new file mode 100644 index 0000000000..d9758176c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-24.c @@ -0,0 +1,28 @@ +/* Verify that gnu_inline inlines disregard inlining limits. */ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern int foo (int); +extern int baz (int); + +extern inline __attribute__((gnu_inline)) +int foo (int x) +{ + int i; + if (!__builtin_constant_p (x)) + { +#define B(n) baz (1##n) + baz (2##n) + baz (3##n) \ + + baz (4##n) + baz (5##n) + baz (6##n) +#define C(n) B(1##n) + B(2##n) + B(3##n) + B(4##n) + B(5##n) + B(6##n) +#define D(n) C(1##n) + C(2##n) + C(3##n) + C(4##n) + C(5##n) + C(6##n) + return D(0) + D(1) + D(2) + D(3) + D(4) + + D(5) + D(6) + D(7) + D(8) + D(9); + } + return 0; +} + +int +main (void) +{ + return foo (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-25.c b/SingleSource/Regression/C/gcc-dg/inline-25.c new file mode 100644 index 0000000000..8063d6cd58 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-25.c @@ -0,0 +1,145 @@ +/* PR c/35017 */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +static int a = 6; +static const int b = 6; +int c = 6; + +inline int +fn1 (void) +{ + return a; /* { dg-error "used in inline" } */ +} + +inline int +fn2 (void) +{ + return b; /* { dg-error "used in inline" } */ +} + +inline int +fn3 (void) +{ + return c; +} + +inline int +fn4 (void) +{ + static int d = 6; /* { dg-error "declared in inline" } */ + return d; +} + +inline int +fn5 (void) +{ + static const int e = 6; + return e; +} + +inline int +fn6 (void) +{ + int f = 6; + return f; +} + +inline int +fn7 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} + +extern inline int +fn8 (void) +{ + return a; +} + +extern inline int +fn9 (void) +{ + return b; +} + +extern inline int +fn10 (void) +{ + return c; +} + +extern inline int +fn11 (void) +{ + static int d = 6; + return d; +} + +extern inline int +fn12 (void) +{ + static const int e = 6; + return e; +} + +extern inline int +fn13 (void) +{ + int f = 6; + return f; +} + +extern inline int +fn14 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} + +static inline int +fn15 (void) +{ + return a; +} + +static inline int +fn16 (void) +{ + return b; +} + +static inline int +fn17 (void) +{ + return c; +} + +static inline int +fn18 (void) +{ + static int d = 6; + return d; +} + +static inline int +fn19 (void) +{ + static const int e = 6; + return e; +} + +static inline int +fn20 (void) +{ + int f = 6; + return f; +} + +static inline int +fn21 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-26.c b/SingleSource/Regression/C/gcc-dg/inline-26.c new file mode 100644 index 0000000000..02f78bb942 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-26.c @@ -0,0 +1,145 @@ +/* PR c/35017 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +static int a = 6; +static const int b = 6; +int c = 6; + +inline int +fn1 (void) +{ + return a; /* { dg-warning "used in inline" } */ +} + +inline int +fn2 (void) +{ + return b; /* { dg-warning "used in inline" } */ +} + +inline int +fn3 (void) +{ + return c; +} + +inline int +fn4 (void) +{ + static int d = 6; /* { dg-warning "declared in inline" } */ + return d; +} + +inline int +fn5 (void) +{ + static const int e = 6; + return e; +} + +inline int +fn6 (void) +{ + int f = 6; + return f; +} + +inline int +fn7 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} + +extern inline int +fn8 (void) +{ + return a; +} + +extern inline int +fn9 (void) +{ + return b; +} + +extern inline int +fn10 (void) +{ + return c; +} + +extern inline int +fn11 (void) +{ + static int d = 6; + return d; +} + +extern inline int +fn12 (void) +{ + static const int e = 6; + return e; +} + +extern inline int +fn13 (void) +{ + int f = 6; + return f; +} + +extern inline int +fn14 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} + +static inline int +fn15 (void) +{ + return a; +} + +static inline int +fn16 (void) +{ + return b; +} + +static inline int +fn17 (void) +{ + return c; +} + +static inline int +fn18 (void) +{ + static int d = 6; + return d; +} + +static inline int +fn19 (void) +{ + static const int e = 6; + return e; +} + +static inline int +fn20 (void) +{ + int f = 6; + return f; +} + +static inline int +fn21 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-27.c b/SingleSource/Regression/C/gcc-dg/inline-27.c new file mode 100644 index 0000000000..0ecfbcf5ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-27.c @@ -0,0 +1,145 @@ +/* PR c/35017 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +static int a = 6; +static const int b = 6; +int c = 6; + +inline int +fn1 (void) +{ + return a; +} + +inline int +fn2 (void) +{ + return b; +} + +inline int +fn3 (void) +{ + return c; +} + +inline int +fn4 (void) +{ + static int d = 6; + return d; +} + +inline int +fn5 (void) +{ + static const int e = 6; + return e; +} + +inline int +fn6 (void) +{ + int f = 6; + return f; +} + +inline int +fn7 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} + +extern inline int +fn8 (void) +{ + return a; /* { dg-warning "used in inline" } */ +} + +extern inline int +fn9 (void) +{ + return b; /* { dg-warning "used in inline" } */ +} + +extern inline int +fn10 (void) +{ + return c; +} + +extern inline int +fn11 (void) +{ + static int d = 6; /* { dg-warning "declared in inline" } */ + return d; +} + +extern inline int +fn12 (void) +{ + static const int e = 6; + return e; +} + +extern inline int +fn13 (void) +{ + int f = 6; + return f; +} + +extern inline int +fn14 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} + +static inline int +fn15 (void) +{ + return a; +} + +static inline int +fn16 (void) +{ + return b; +} + +static inline int +fn17 (void) +{ + return c; +} + +static inline int +fn18 (void) +{ + static int d = 6; + return d; +} + +static inline int +fn19 (void) +{ + static const int e = 6; + return e; +} + +static inline int +fn20 (void) +{ + int f = 6; + return f; +} + +static inline int +fn21 (int i) +{ + static const char g[10] = "abcdefghij"; + return g[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-28.c b/SingleSource/Regression/C/gcc-dg/inline-28.c new file mode 100644 index 0000000000..20916aef99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-28.c @@ -0,0 +1,28 @@ +/* PR c/36507 */ +/* { dg-do run } */ +/* { dg-options "-O0 -std=gnu89" } */ + +int +main (void) +{ + int i = 2; + auto inline int f1 (void) + { + return i; + } + inline int f2 (void) + { + return i; + } + auto inline int f3 (void); + auto inline int f3 (void) + { + return i; + } + auto inline int f4 (void); + inline int f4 (void) + { + return i; + } + return f1 () + f2 () + f3 () + f4 () - 8; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-29.c b/SingleSource/Regression/C/gcc-dg/inline-29.c new file mode 100644 index 0000000000..77672f3429 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-29.c @@ -0,0 +1,28 @@ +/* PR c/36507 */ +/* { dg-do run } */ +/* { dg-options "-O0 -std=gnu99" } */ + +int +main (void) +{ + int i = 2; + auto inline int f1 (void) + { + return i; + } + inline int f2 (void) + { + return i; + } + auto inline int f3 (void); + auto inline int f3 (void) + { + return i; + } + auto inline int f4 (void); + inline int f4 (void) + { + return i; + } + return f1 () + f2 () + f3 () + f4 () - 8; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-3.c b/SingleSource/Regression/C/gcc-dg/inline-3.c new file mode 100644 index 0000000000..8173ae9cfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-3.c @@ -0,0 +1,49 @@ +/* { dg-options "-O2 -funit-at-a-time" } */ +/* { dg-final { scan-assembler-not "big_function_2" } } */ + +int t(void); +static void +big_function_2(void); +void +big_function_1() +{ + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + big_function_2(); +} +static void +big_function_2() +{ + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); + while (t()); +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-30.c b/SingleSource/Regression/C/gcc-dg/inline-30.c new file mode 100644 index 0000000000..bb9b2b4776 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-30.c @@ -0,0 +1,28 @@ +/* PR c/36507 */ +/* { dg-do run } */ +/* { dg-options "-O0 -std=gnu99 -fgnu89-inline" } */ + +int +main (void) +{ + int i = 2; + auto inline int f1 (void) + { + return i; + } + inline int f2 (void) + { + return i; + } + auto inline int f3 (void); + auto inline int f3 (void) + { + return i; + } + auto inline int f4 (void); + inline int f4 (void) + { + return i; + } + return f1 () + f2 () + f3 () + f4 () - 8; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-31.c b/SingleSource/Regression/C/gcc-dg/inline-31.c new file mode 100644 index 0000000000..1d9a2212e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-31.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ +inline int f (void) { return 0; } + +void +g (void) +{ + extern int f(); +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-32.c b/SingleSource/Regression/C/gcc-dg/inline-32.c new file mode 100644 index 0000000000..bfcafd5dbb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-32.c @@ -0,0 +1,11 @@ +/* { dg-do link } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ +/* { dg-additional-sources inline-32a.c } */ +inline int f (void) { return 0; } + +int +main (void) +{ + extern int f(); + return f (); +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-32a.c b/SingleSource/Regression/C/gcc-dg/inline-32a.c new file mode 100644 index 0000000000..a2bde0aac4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-32a.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ +int f (void) { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/inline-33.c b/SingleSource/Regression/C/gcc-dg/inline-33.c new file mode 100644 index 0000000000..6ce3a5326b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-33.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-add-options bind_pic_locally } */ + +int i; + +int foo (); +int bar (); + +int +main () +{ + return foo (i); +} + +int foo (i) + int i; +{ + return bar(i); +} + +/* { dg-final { scan-tree-dump-times "bar" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-34.c b/SingleSource/Regression/C/gcc-dg/inline-34.c new file mode 100644 index 0000000000..f257792c73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-34.c @@ -0,0 +1,19 @@ +/* Diagnostics for bad references to static objects and functions from + inline definitions must take account of declarations after the + definition which make it not an inline definition. PR 39556. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +static int a1; +inline int f1 (void) { return a1; } +int f1 (void); + +static int a2; +inline int f2 (void) { return a2; } +extern inline int f2 (void); + +inline void f3 (void) { static int a3; } +void f3 (void); + +inline void f4 (void) { static int a4; } +extern inline void f4 (void); diff --git a/SingleSource/Regression/C/gcc-dg/inline-35.c b/SingleSource/Regression/C/gcc-dg/inline-35.c new file mode 100644 index 0000000000..ebbb8df2fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-35.c @@ -0,0 +1,19 @@ +/* A function definition of an inline function following a static + declaration does not make an inline definition in C99/C11 terms. + PR 57574. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +static int n; + +static inline int f1 (void); +inline int f1 (void) { return n; } + +static int f2 (void); +inline int f2 (void) { return n; } + +static inline int f3 (void); +int f3 (void) { return n; } + +static int f4 (void); +int f4 (void) { return n; } diff --git a/SingleSource/Regression/C/gcc-dg/inline-36.c b/SingleSource/Regression/C/gcc-dg/inline-36.c new file mode 100644 index 0000000000..4494f6fb30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-36.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdisable-tree-einline -fdisable-ipa-inline -Wno-attributes" } */ +int g; +__attribute__((always_inline)) void bar (void) +{ + g++; +} + +int foo (void) +{ + bar (); + return g; +} + +int foo2 (void) +{ + bar(); + return g + 1; +} + +/* { dg-final { scan-tree-dump-times "bar" 5 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-37.c b/SingleSource/Regression/C/gcc-dg/inline-37.c new file mode 100644 index 0000000000..f96ed7972b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-37.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdisable-tree-einline=0:100 -fdisable-ipa-inline -Wno-attributes" } */ +int g; +__attribute__((always_inline)) void bar (void) +{ + g++; +} + +int foo (void) +{ + bar (); + return g; +} + +int foo2 (void) +{ + bar(); + return g + 1; +} + +/* { dg-final { scan-tree-dump-times "bar" 5 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-38.c b/SingleSource/Regression/C/gcc-dg/inline-38.c new file mode 100644 index 0000000000..82306c6a87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-38.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdisable-tree-einline=foo,foo2 -fdisable-ipa-inline -Wno-attributes" } */ +int g; +__attribute__((always_inline)) void bar (void) +{ + g++; +} + +int foo (void) +{ + bar (); + return g; +} + +int foo2 (void) +{ + bar(); + return g + 1; +} + +/* { dg-final { scan-tree-dump-times "bar" 5 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-39.c b/SingleSource/Regression/C/gcc-dg/inline-39.c new file mode 100644 index 0000000000..52ab572929 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-39.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdisable-tree-einline=foo2 -fdisable-ipa-inline -Wno-attributes" } */ +/* { dg-add-options bind_pic_locally } */ +int g; +__attribute__((always_inline)) void bar (void) +{ + g++; +} + +int foo (void) +{ + bar (); + return g; +} + +int foo2 (void) +{ + bar(); + return g + 1; +} + +/* { dg-final { scan-tree-dump-times "bar" 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-4.c b/SingleSource/Regression/C/gcc-dg/inline-4.c new file mode 100644 index 0000000000..2442f2d392 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "big_static_inline" } } */ + +extern void f(void); +static inline void big_static_inline(void) +{ + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); + f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-40.c b/SingleSource/Regression/C/gcc-dg/inline-40.c new file mode 100644 index 0000000000..d0fdaeef34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-40.c @@ -0,0 +1,49 @@ +/* Test inline functions declared in inner scopes. Bugs 88720 and 88726. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +inline_1 (void) +{ +} + +void +inline_2 (void) +{ +} + +static void +inline_static_1 (void) +{ +} + +static void +inline_static_2 (void) +{ +} + +static void inline_static_3 (void); +static void inline_static_4 (void); + +static void +test (void) +{ + inline void inline_1 (void); + extern inline void inline_2 (void); + inline void inline_3 (void); + extern inline void inline_4 (void); + inline void inline_static_1 (void); + extern inline void inline_static_2 (void); + inline void inline_static_3 (void); + extern inline void inline_static_4 (void); +} + +void +inline_3 (void) +{ +} + +void +inline_4 (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-41.c b/SingleSource/Regression/C/gcc-dg/inline-41.c new file mode 100644 index 0000000000..1511aeebd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-41.c @@ -0,0 +1,49 @@ +/* Test inline functions declared in inner scopes. Bugs 88720 and 88726. */ +/* { dg-do compile } */ +/* { dg-options "-fgnu89-inline" } */ + +void +inline_1 (void) +{ +} + +void +inline_2 (void) +{ +} + +static void +inline_static_1 (void) +{ +} + +static void +inline_static_2 (void) +{ +} + +static void inline_static_3 (void); +static void inline_static_4 (void); + +static void +test (void) +{ + inline void inline_1 (void); + extern inline void inline_2 (void); + inline void inline_3 (void); + extern inline void inline_4 (void); + inline void inline_static_1 (void); + extern inline void inline_static_2 (void); + inline void inline_static_3 (void); + extern inline void inline_static_4 (void); +} + +void +inline_3 (void) +{ +} + +void +inline_4 (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-42.c b/SingleSource/Regression/C/gcc-dg/inline-42.c new file mode 100644 index 0000000000..f5ccea8f3c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-42.c @@ -0,0 +1,50 @@ +/* Test inline functions declared in inner scopes. Bug 93072. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +inline_1 (void) +{ +} + +void +inline_2 (void) +{ +} + +static void +inline_static_1 (void) +{ +} + +static void +inline_static_2 (void) +{ +} + +static void +test (void) +{ + inline void inline_1 (void); + if (inline_1 == 0) ; + extern inline void inline_2 (void); + if (inline_2 == 0) ; + inline void inline_3 (void); + if (inline_3 == 0) ; + extern inline void inline_4 (void); + if (inline_4 == 0) ; + inline void inline_static_1 (void); + if (inline_static_1 == 0) ; + extern inline void inline_static_2 (void); + if (inline_static_2 == 0) ; +} + +void +inline_3 (void) +{ +} + +void +inline_4 (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-43.c b/SingleSource/Regression/C/gcc-dg/inline-43.c new file mode 100644 index 0000000000..87b2445038 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-43.c @@ -0,0 +1,50 @@ +/* Test inline functions declared in inner scopes. Bug 93072. */ +/* { dg-do compile } */ +/* { dg-options "-fgnu89-inline" } */ + +void +inline_1 (void) +{ +} + +void +inline_2 (void) +{ +} + +static void +inline_static_1 (void) +{ +} + +static void +inline_static_2 (void) +{ +} + +static void +test (void) +{ + inline void inline_1 (void); + if (inline_1 == 0) ; + extern inline void inline_2 (void); + if (inline_2 == 0) ; + inline void inline_3 (void); + if (inline_3 == 0) ; + extern inline void inline_4 (void); + if (inline_4 == 0) ; + inline void inline_static_1 (void); + if (inline_static_1 == 0) ; + extern inline void inline_static_2 (void); + if (inline_static_2 == 0) ; +} + +void +inline_3 (void) +{ +} + +void +inline_4 (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-5.c b/SingleSource/Regression/C/gcc-dg/inline-5.c new file mode 100644 index 0000000000..d72fad6561 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-5.c @@ -0,0 +1,13 @@ +/* PR middle-end/13448 */ + +/* { dg-options "-O3" } */ + +void funct (const int n) +{ + n++; /* { dg-error "" } */ +} + +int main () { + funct (1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline-6.c b/SingleSource/Regression/C/gcc-dg/inline-6.c new file mode 100644 index 0000000000..81d6dc2208 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-6.c @@ -0,0 +1,6 @@ +/* Test duplicate inline, gnu89 mode. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +inline inline void f (void) {} diff --git a/SingleSource/Regression/C/gcc-dg/inline-7.c b/SingleSource/Regression/C/gcc-dg/inline-7.c new file mode 100644 index 0000000000..b239a20461 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-7.c @@ -0,0 +1,6 @@ +/* Test duplicate inline, gnu99 mode. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +inline inline void f (void) {} diff --git a/SingleSource/Regression/C/gcc-dg/inline-8.c b/SingleSource/Regression/C/gcc-dg/inline-8.c new file mode 100644 index 0000000000..b4c0eb8401 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-8.c @@ -0,0 +1,6 @@ +/* Test inline main, gnu99 mode, hosted. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fhosted" } */ + +inline int main (void); /* { dg-warning "cannot inline function 'main'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline-9.c b/SingleSource/Regression/C/gcc-dg/inline-9.c new file mode 100644 index 0000000000..c8dda53601 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline-9.c @@ -0,0 +1,6 @@ +/* Test inline main, gnu99 mode, hosted, -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fhosted -pedantic-errors" } */ + +inline int main (void); /* { dg-error "cannot inline function 'main'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline1.c b/SingleSource/Regression/C/gcc-dg/inline1.c new file mode 100644 index 0000000000..c660fe3146 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -std=gnu89" } */ +/* This test is expected to fail with an error for the redefinition of foo. + This violates the constraint of 6.9#3 (no more than one external definition + of an identifier with internal linkage in the same translation unit). */ +static inline int foo(void) { return 1; } /* { dg-message "note: previous definition of" } */ +static inline int foo(void) { return 0; } /* { dg-error "redefinition of" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/inline2.c b/SingleSource/Regression/C/gcc-dg/inline2.c new file mode 100644 index 0000000000..ede4104927 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline2.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -std=gnu89" } */ +/* This test should compile successfully. */ +extern inline int foo (void) { return 0; } +inline int foo (void) { return 1; } diff --git a/SingleSource/Regression/C/gcc-dg/inline3.c b/SingleSource/Regression/C/gcc-dg/inline3.c new file mode 100644 index 0000000000..d7fd8dba60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline3.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -std=gnu89" } */ +/* This testcase should fail since we're redefining foo in the same + translation unit. */ +extern inline int foo(void) { return 0; } +inline int foo (void) { return 1; } /* { dg-message "note: previous definition of" } */ +int foo (void) { return 2; } /* { dg-error "redefinition of" } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline4.c b/SingleSource/Regression/C/gcc-dg/inline4.c new file mode 100644 index 0000000000..64cea7515a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline4.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -std=gnu89" } */ +/* This testcase should fail since we're redefining foo in the same + translation unit. */ +int foo (void) { return 2; } /* { dg-message "note: previous definition of" } */ +extern inline int foo (void) { return 1; } /* { dg-error "redefinition of" } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline5.c b/SingleSource/Regression/C/gcc-dg/inline5.c new file mode 100644 index 0000000000..40fb7cd910 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline5.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -std=gnu89" } */ +/* This testcase should fail since we're redefining foo in the same + translation unit. */ +extern inline int foo (void) { return 2; } /* { dg-message "note: previous definition of" } */ +extern inline int foo (void) { return 1; } /* { dg-error "redefinition of" } */ diff --git a/SingleSource/Regression/C/gcc-dg/inline6.c b/SingleSource/Regression/C/gcc-dg/inline6.c new file mode 100644 index 0000000000..3b9e3e99e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline6.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ +static int i; +extern int j; +extern inline int func1 (void) { + return i++; /* { dg-warning "static" } */ +} +extern inline int func2 (void) { + return j++; +} +inline int func3 (void) +{ + return i++; +} diff --git a/SingleSource/Regression/C/gcc-dg/inline7.c b/SingleSource/Regression/C/gcc-dg/inline7.c new file mode 100644 index 0000000000..54f3360b8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/inline7.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ +extern inline void func1 (void) { + static int i; /* { dg-warning "static" } */ +} +inline void func3 (void) +{ + static int i; +} diff --git a/SingleSource/Regression/C/gcc-dg/instrument-1.c b/SingleSource/Regression/C/gcc-dg/instrument-1.c new file mode 100644 index 0000000000..1e2d8acc66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/instrument-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-finstrument-functions" } */ + +void fn () { } + +/* { dg-final { scan-assembler "__cyg_profile_func_enter" } } */ +/* { dg-final { scan-assembler "__cyg_profile_func_exit" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/instrument-2.c b/SingleSource/Regression/C/gcc-dg/instrument-2.c new file mode 100644 index 0000000000..297a02da69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/instrument-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-finstrument-functions -finstrument-functions-exclude-function-list=fn" } */ + +void fn () { } + +/* { dg-final { scan-assembler-not "__cyg_profile_func_enter" } } */ +/* { dg-final { scan-assembler-not "__cyg_profile_func_exit" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/instrument-3.c b/SingleSource/Regression/C/gcc-dg/instrument-3.c new file mode 100644 index 0000000000..c1a9c2a813 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/instrument-3.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-finstrument-functions -finstrument-functions-exclude-file-list=instrument-3" } */ + +void fn () { } + +/* { dg-final { scan-assembler-not "__cyg_profile_func_enter" } } */ +/* { dg-final { scan-assembler-not "__cyg_profile_func_exit" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/instrument-4.c b/SingleSource/Regression/C/gcc-dg/instrument-4.c new file mode 100644 index 0000000000..c19e8bf397 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/instrument-4.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-finstrument-functions-once" } */ + +void fn () { } + +/* { dg-final { scan-assembler "__cyg_profile_func_enter" } } */ +/* { dg-final { scan-assembler "__cyg_profile_func_exit" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/intermod-1.c b/SingleSource/Regression/C/gcc-dg/intermod-1.c new file mode 100644 index 0000000000..9f8d19deb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/intermod-1.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-final { scan-assembler-not {foo[1-9]\.[0-9]} } } */ + +/* Check that we don't get .0 suffixes on static variables when not using + intermodule analysis. */ + +static int foo1; +static int foo2 = 1; + +static void foo5(void) { } +static void foo6(void); +static void foo6(void) { } +static void foo7(void); +void foo7(void) { } + +void foo9(void) +{ + foo1 = 2; + foo2 = 3; + foo5(); + foo6(); + foo7(); +} diff --git a/SingleSource/Regression/C/gcc-dg/intmax_t-1.c b/SingleSource/Regression/C/gcc-dg/intmax_t-1.c new file mode 100644 index 0000000000..03d4266cc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/intmax_t-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ +/* { dg-error "" "" { target { { *arm*-*-*elf* xtensa*-*-elf* } || { vxworks_kernel && { ! *-*-vxworks7r* } } } } 0 } */ + +/* Compile with -Wall to get a warning if built-in and system intmax_t don't + match. */ + +#include + +__INTMAX_TYPE__ __im_t__; +__UINTMAX_TYPE__ __uim_t__; +intmax_t *im_t_p; +uintmax_t *uim_t_p; + +void +imt (void) +{ + im_t_p = &__im_t__; +} + +void +uimt (void) +{ + uim_t_p = &__uim_t__; +} diff --git a/SingleSource/Regression/C/gcc-dg/invalid-call-1.c b/SingleSource/Regression/C/gcc-dg/invalid-call-1.c new file mode 100644 index 0000000000..7a2f6a07bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/invalid-call-1.c @@ -0,0 +1,17 @@ +/* PR rtl-optimization/29841 */ +/* Testcase by Khem Raj */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -march=i586" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +typedef void (*fp)(void); +extern char* bar(void* a1, int a2); +extern char* mar(int n); +char* cptr; + +void foo() +{ + cptr = mar(6); + ((char *(*)(void *,int (*)(void *,unsigned char **),char**))((fp)bar))(0,0,(void*)(0)); /* { dg-warning "function called through a non-compatible type" "non-compatible type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/ira-loop-pressure.c b/SingleSource/Regression/C/gcc-dg/ira-loop-pressure.c new file mode 100644 index 0000000000..cf06c27031 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ira-loop-pressure.c @@ -0,0 +1,31 @@ +/* Loop2_invariants pass should distinguish register pressures of different + register classes. In this case, register pressue of INT is high. But + we can still move the FP invariant out of the loop. */ + +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */ +/* { dg-options "-O2 -fira-loop-pressure -fdump-rtl-loop2_invariant " } */ + +float tt; +extern void foo2 (int *, int *, int *, int *, int *, int *); +extern int foo3 (int, int, int, int, int, int); +int foo (int a, int b, int c, int d) +{ + int i = a; + int t1, t2, t3, t4, t5, t6; + t1 = t2 = t3 = t4 = t5 = t6 = 0; + + for (; i > 0; i += c) + { + tt += 123456.0; + if (d > t1 + t2) + tt = 3.0; + foo2 (&t1, &t2, &t3, &t4, &t5, &t6); + t1 += t3 + t4 + a + b; + t2 -= t5 - t6 - c - d; + } + + return foo3 (t1, t2, t3, t4, t5, t6); +} + +/* { dg-final { scan-rtl-dump "Decided to move invariant" "loop2_invariant" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/ira-shrinkwrap-prep-1.c b/SingleSource/Regression/C/gcc-dg/ira-shrinkwrap-prep-1.c new file mode 100644 index 0000000000..f290b9ccbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ira-shrinkwrap-prep-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile { target { { { i?86-*-* x86_64-*-* } && lp64 } || { { powerpc*-*-* && lp64 } || { arm_nothumb || { aarch64*-*-* && lp64 } } } } } } */ +/* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue -fno-ipa-ra" } */ + +long __attribute__((noinline, noclone)) +foo (long a) +{ + return a + 5; +} + +static long g __attribute__ ((used)); + +long __attribute__((noinline, noclone)) +bar (long a) +{ + long r; + + if (a) + { + r = foo (a); + g = r + a; + } + else + r = a+1; + return r; +} + +/* { dg-final { scan-rtl-dump "Will split live ranges of parameters" "ira" } } */ +/* { dg-final { scan-rtl-dump "Split live-range of register" "ira" { xfail *-*-* } } } */ +/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" { xfail powerpc*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ira-shrinkwrap-prep-2.c b/SingleSource/Regression/C/gcc-dg/ira-shrinkwrap-prep-2.c new file mode 100644 index 0000000000..6212c95585 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ira-shrinkwrap-prep-2.c @@ -0,0 +1,35 @@ +/* { dg-do compile { target { { { i?86-*-* x86_64-*-* } && lp64 } || { { powerpc*-*-* && lp64 } || { arm_nothumb || { aarch64*-*-* && lp64 } } } } } } */ +/* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue -fno-ipa-ra" } */ + +long __attribute__((noinline, noclone)) +foo (long a) +{ + return a + 5; +} + +static long g; + +long __attribute__((noinline, noclone)) +bar (long a) +{ + long r; + + if (a) + { + r = a; + while (r < 500) + if (r % 2) + r = foo (r); + else + r = foo (r+1); + g = r + a; + } + else + r = g+1; + return r; +} + +/* { dg-final { scan-rtl-dump "Will split live ranges of parameters" "ira" } } */ +/* { dg-final { scan-rtl-dump "Split live-range of register" "ira" { xfail *-*-* } } } */ +/* XFAIL due to PR70681. */ +/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" { xfail arm*-*-* powerpc*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/ivdep.c b/SingleSource/Regression/C/gcc-dg/ivdep.c new file mode 100644 index 0000000000..23d51de9fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ivdep.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +/* PR other/33426 */ + +void foo(int n, int *a, int *b, int *c, int *d, int *e) { + int i, j; +#pragma GCC ivdep + for (i = 0; ; ++i) { /* { dg-error "missing loop condition in loop with 'GCC ivdep' pragma before ';' token" } */ + a[i] = b[i] + c[i]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/kpice1.c b/SingleSource/Regression/C/gcc-dg/kpice1.c new file mode 100644 index 0000000000..be9179b037 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/kpice1.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target h8300-*-* } } */ +/* { dg-options "-ms -mn" } */ + +void f(void) __attribute__((interrupt_handler)); +void g(void) { } +void f(void) { g(); } diff --git a/SingleSource/Regression/C/gcc-dg/label-compound-stmt-1.c b/SingleSource/Regression/C/gcc-dg/label-compound-stmt-1.c new file mode 100644 index 0000000000..2ae2b82ef1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/label-compound-stmt-1.c @@ -0,0 +1,7 @@ +/* Test that labels at ends of compound statements are hard errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c17 -pedantic-errors" } */ + +void f(void) { g: } /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "label|parse|syntax" "label at end of compound statement" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/label-decl-1.c b/SingleSource/Regression/C/gcc-dg/label-decl-1.c new file mode 100644 index 0000000000..3b33888d89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/label-decl-1.c @@ -0,0 +1,17 @@ +/* Test diagnostics for label declarations. Test with no special + options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int b; + +void +f (void) +{ + __label__ a, b, c, d; + __extension__ (void)&&d; /* { dg-error "label 'd' used but not defined" } */ + goto c; /* { dg-error "label 'c' used but not defined" } */ + a: (void)0; + b: (void)0; +} diff --git a/SingleSource/Regression/C/gcc-dg/label-decl-2.c b/SingleSource/Regression/C/gcc-dg/label-decl-2.c new file mode 100644 index 0000000000..3ebe290a27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/label-decl-2.c @@ -0,0 +1,16 @@ +/* Test diagnostics for label declarations. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +typedef int b; + +void +f (void) +{ + __label__ a, b, c, d; /* { dg-warning "ISO C forbids label declarations" "label decls" } */ + __extension__ (void)&&d; /* { dg-error "label 'd' used but not defined" } */ + goto c; /* { dg-error "label 'c' used but not defined" } */ + a: (void)0; + b: (void)0; +} diff --git a/SingleSource/Regression/C/gcc-dg/label-decl-3.c b/SingleSource/Regression/C/gcc-dg/label-decl-3.c new file mode 100644 index 0000000000..2e9ea09e1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/label-decl-3.c @@ -0,0 +1,18 @@ +/* Test diagnostics for label declarations. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +typedef int b; + +void +f (void) +{ + __label__ a, b, c, d; + /* { dg-error "ISO C forbids label declarations" "label decls" { target *-*-* } .-1 } */ + __extension__ (void)&&d; /* { dg-error "label 'd' used but not defined" } */ + goto c; /* { dg-error "label 'c' used but not defined" } */ + a: (void)0; + b: (void)0; +} diff --git a/SingleSource/Regression/C/gcc-dg/label-decl-4.c b/SingleSource/Regression/C/gcc-dg/label-decl-4.c new file mode 100644 index 0000000000..82f1af050b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/label-decl-4.c @@ -0,0 +1,14 @@ +/* Test diagnostics for duplicate label declarations. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (void) +{ + __label__ a, b, a; /* { dg-error "duplicate label declaration 'a'" } */ + /* { dg-message "note: previous declaration of 'a'" "previous" { target *-*-* } .-1 } */ + __label__ c; /* { dg-message "note: previous declaration of 'c'" "note" } */ + __label__ c; /* { dg-error "duplicate label declaration 'c'" } */ + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/large-size-array-2.c b/SingleSource/Regression/C/gcc-dg/large-size-array-2.c new file mode 100644 index 0000000000..da13858672 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/large-size-array-2.c @@ -0,0 +1,7 @@ +/* PR c/25309 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +static char * name[] = { + [0x80000000] = "bar" + }; +/* { dg-error "too large" "" { target { { ! lp64 } && { ! llp64 } } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/large-size-array-3.c b/SingleSource/Regression/C/gcc-dg/large-size-array-3.c new file mode 100644 index 0000000000..0a83b9c417 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/large-size-array-3.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +#include + +#if defined(__LP64__) || defined(_WIN64) +#define DIM (UINT_MAX>>1)+1 +#else +#define DIM 65536 +#endif + +int +sub (int *a) +{ + return a[0]; +} + +int +main (void) +{ + int a[DIM][DIM]; /* { dg-error "exceeds maximum object size|size of array 'a' is too large" } */ + return sub (&a[0][0]); +} diff --git a/SingleSource/Regression/C/gcc-dg/large-size-array-4.c b/SingleSource/Regression/C/gcc-dg/large-size-array-4.c new file mode 100644 index 0000000000..f9f94b29bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/large-size-array-4.c @@ -0,0 +1,7 @@ +/* PR c/25309 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +static char * name[] = { + [0x80000000] = "bar" + }; +/* { dg-error "too large" "" { target { { ! lp64 } && { ! llp64 } } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/large-size-array-5.c b/SingleSource/Regression/C/gcc-dg/large-size-array-5.c new file mode 100644 index 0000000000..f9acdf4528 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/large-size-array-5.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-overflow" } */ + +typedef __SIZE_TYPE__ size_t; + +extern char a[((size_t)-1 >> 1) + 1]; /* { dg-error "is too large" } */ +extern char b[((size_t)-1 >> 1)]; +extern int c[(((size_t)-1 >> 1) + 1) / sizeof(int)]; /* { dg-error "exceeds maximum object size" } */ +extern int d[((size_t)-1 >> 1) / sizeof(int)]; diff --git a/SingleSource/Regression/C/gcc-dg/large-size-array-6.c b/SingleSource/Regression/C/gcc-dg/large-size-array-6.c new file mode 100644 index 0000000000..f7da47e937 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/large-size-array-6.c @@ -0,0 +1,6 @@ +/* PR c/57821 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +static char * name[] = { + [0x8000000000000000] = "bar" + }; /* { dg-error "too large" } */ diff --git a/SingleSource/Regression/C/gcc-dg/large-size-array.c b/SingleSource/Regression/C/gcc-dg/large-size-array.c new file mode 100644 index 0000000000..79e371f4a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/large-size-array.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +#include + +#if defined(__LP64__) || defined(_WIN64) +#define DIM UINT_MAX>>1 +#else +#define DIM USHRT_MAX>>1 +#endif + +int +sub (int *a) +{ + return a[0]; +} + +int +main (void) +{ + int a[DIM][DIM]; /* { dg-error "exceeds maximum object size" } */ + return sub (&a[0][0]); +} diff --git a/SingleSource/Regression/C/gcc-dg/lazy-ptr-test.c b/SingleSource/Regression/C/gcc-dg/lazy-ptr-test.c new file mode 100644 index 0000000000..da66b518ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lazy-ptr-test.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-apple-darwin* } } */ +/* { dg-options "-S" } */ + +void f () __attribute__((weak_import)); + +typedef void PF (void); + +void f(void){}; + +PF* g (void) { return f; } + +int main() +{ + (*g())(); + return 0; +} + +/* { dg-final { scan-assembler "non_lazy_ptr" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/limits-width-1.c b/SingleSource/Regression/C/gcc-dg/limits-width-1.c new file mode 100644 index 0000000000..7a87014526 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/limits-width-1.c @@ -0,0 +1,55 @@ +/* Test TS 18661-1 width macros in . */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +#define __STDC_WANT_IEC_60559_BFP_EXT__ +#include + +#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/SingleSource/Regression/C/gcc-dg/limits-width-2.c b/SingleSource/Regression/C/gcc-dg/limits-width-2.c new file mode 100644 index 0000000000..a3c38958ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/limits-width-2.c @@ -0,0 +1,54 @@ +/* Test C2X width macros in . */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#include + +#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/SingleSource/Regression/C/gcc-dg/live-patching-1.c b/SingleSource/Regression/C/gcc-dg/live-patching-1.c new file mode 100644 index 0000000000..6a1ea38c49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/live-patching-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -flive-patching=inline-only-static -fdump-ipa-inline" } */ + +extern int sum, n, m; + +int foo (int a) +{ + return a + n; +} + +static int bar (int b) +{ + return b * m; +} + +int main() +{ + sum = foo (m) + bar (n); + return 0; +} + +/* { dg-final { scan-ipa-dump "foo/0 function has external linkage when the user requests only inlining static for live patching" "inline" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/live-patching-2.c b/SingleSource/Regression/C/gcc-dg/live-patching-2.c new file mode 100644 index 0000000000..1c4f9229b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/live-patching-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-O2 -flive-patching=inline-only-static -flto" } */ + +int main() +{ + return 0; +} + +/* { dg-message "sorry, unimplemented: live patching \\(with 'inline-only-static'\\) is not supported with LTO" "-flive-patching and -flto together" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/live-patching-3.c b/SingleSource/Regression/C/gcc-dg/live-patching-3.c new file mode 100644 index 0000000000..b86f3c6e08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/live-patching-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -flive-patching -fwhole-program" } */ + +int main() +{ + return 0; +} + +/* { dg-message "'-fwhole-program' is incompatible with '-flive-patching=inline-only-static|inline-clone’" "" {target "*-*-*"} 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/live-patching-4.c b/SingleSource/Regression/C/gcc-dg/live-patching-4.c new file mode 100644 index 0000000000..ffea8f4cc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/live-patching-4.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -flive-patching=inline-only-static -fdump-tree-einline-optimized" } */ + +extern int sum, n, m; + +extern inline __attribute__((always_inline)) int foo (int a); +inline __attribute__((always_inline)) int foo (int a) +{ + return a + n; +} + +static int bar (int b) +{ + return b * m; +} + +int main() +{ + sum = foo (m) + bar (n); + return 0; +} + +/* { dg-final { scan-tree-dump "Inlining foo/0 into main/2" "einline" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/live-patching-5.c b/SingleSource/Regression/C/gcc-dg/live-patching-5.c new file mode 100644 index 0000000000..098047a36c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/live-patching-5.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-O2 -flive-patching -flto" } */ + +int main() +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/local1.c b/SingleSource/Regression/C/gcc-dg/local1.c new file mode 100644 index 0000000000..448c71b056 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/local1.c @@ -0,0 +1,23 @@ +/* This is allowed, with the effect that the 'extern' declaration at block + scope refers to the same object as the 'static' declaration at file scope. + + C90 6.1.2.2 [as corrected by TC1], C99 6.2.2: + + For an identifier declared with the storage-class specifier + extern in a scope in which a prior declaration of that + identifier is visible, if the prior declaration specifies + internal or external linkage, the linkage of the identifier at + the later daclaration is the same as the linkage specified at + the prior declaration. If no prior declaration is visible, + or if the prior declaration specifies no linkage, then the + identifier has external linkage. + + This is PR 14366. */ + +static int i; + +extern int i; + +static void f() { + extern int i; +} diff --git a/SingleSource/Regression/C/gcc-dg/localalias-2.c b/SingleSource/Regression/C/gcc-dg/localalias-2.c new file mode 100644 index 0000000000..aa67d58600 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/localalias-2.c @@ -0,0 +1,20 @@ +/* { dg-require-alias "" } */ +extern void abort (void); +int test2count; +__attribute__ ((weak,noinline)) +void test(void) +{ + test2count++; +} +__attribute ((alias("test"))) +static void test2(void); + +void tt() +{ + int prev = test2count; + /* This call must bind locally. */ + test2(); + if (test2count == prev) + abort(); + test(); + } diff --git a/SingleSource/Regression/C/gcc-dg/localalias.c b/SingleSource/Regression/C/gcc-dg/localalias.c new file mode 100644 index 0000000000..fb62066a2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/localalias.c @@ -0,0 +1,42 @@ +/* This test checks that local aliases behave sanely. This is necessary for code correctness + of aliases introduced by ipa-visibility pass. + + If this test fails either aliases needs to be disabled on given target on aliases with + proper semantic needs to be implemented. This is problem with e.g. AIX .set pseudo-op + that implementes alias syntactically (by substituting in assembler) rather as alternative + symbol defined on a target's location. */ + +/* { dg-do run } + { dg-options "-Wstrict-aliasing=2 -fstrict-aliasing" } + { dg-require-alias "" } + { dg-additional-sources "localalias-2.c" } */ +extern void abort (void); +extern void tt (void); +extern int test2count; +int testcount; +__attribute__ ((weak,noinline)) +void test(void) +{ + testcount++; +} +__attribute ((alias("test"))) +static void test2(void); + +int main() +{ + test2(); + /* This call must bind locally. */ + if (!testcount) + abort (); + test(); + /* Depending on linker choice, this one may bind locally + or to the other unit. */ + if (!testcount && !test2count) + abort(); + tt(); + + if ((testcount != 1 || test2count != 3) + && (testcount != 3 || test2count != 1)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/long-long-compare-1.c b/SingleSource/Regression/C/gcc-dg/long-long-compare-1.c new file mode 100644 index 0000000000..e05fcead21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/long-long-compare-1.c @@ -0,0 +1,124 @@ +/* Problem noticed on SH for DImode comparison with constants. +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +extern void abort(void); +extern void exit(int); + +int test2(long long n) +{ + if (n < 2) + return 1; + return 0; +} + +int test1(long long n) +{ + if (n < 1) + return 1; + return 0; +} + +int test0(long long n) +{ + if (n < 0) + return 1; + return 0; +} + +int test1n(long long n) +{ + if (n < -1LL) + return 1; + return 0; +} + +int test2n(long long n) +{ + if (n < -2LL) + return 1; + return 0; +} + +int main() +{ + if (test2n (-1LL)) + abort (); + + if (test2n (-2LL)) + abort (); + + if (test2n (0LL)) + abort (); + + if (test2n (1LL)) + abort (); + + if (test2n (2LL)) + abort (); + + if (test1n (-1LL)) + abort (); + + if (!test1n (-2LL)) + abort (); + + if (test1n (0LL)) + abort (); + + if (test1n (1LL)) + abort (); + + if (test1n (2LL)) + abort (); + + if (!test0 (-1LL)) + abort (); + + if (!test0 (-2LL)) + abort (); + + if (test0 (0LL)) + abort (); + + if (test0 (1LL)) + abort (); + + if (test0 (2LL)) + abort (); + + if (!test2 (-1LL)) + abort (); + + if (!test2 (-2LL)) + abort (); + + if (!test2 (0LL)) + abort (); + + if (!test2 (1LL)) + abort (); + + if (test2 (2LL)) + abort (); + + if (!test1 (-1LL)) + abort (); + + if (!test1 (-2LL)) + abort (); + + if (!test1 (0LL)) + abort (); + + if (test1 (1LL)) + abort (); + + if (test1 (2LL)) + abort (); + + exit (0); +} + + + diff --git a/SingleSource/Regression/C/gcc-dg/long-long-cst1.c b/SingleSource/Regression/C/gcc-dg/long-long-cst1.c new file mode 100644 index 0000000000..800d6d64b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/long-long-cst1.c @@ -0,0 +1,18 @@ +/* PR middle-end/27724 */ +/* { dg-do run } */ +/* { dg-options "" } */ + +extern void abort(); + +struct st{ + int _mark; +}; +unsigned long long t = ((int)(__UINTPTR_TYPE__)&(((struct st*)16)->_mark) - 32); + +int main() +{ + if (t != (unsigned long long)(int)-16) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/long-long-typespec-1.c b/SingleSource/Regression/C/gcc-dg/long-long-typespec-1.c new file mode 100644 index 0000000000..2ef2416f2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/long-long-typespec-1.c @@ -0,0 +1,828 @@ +/* Test for valid and invalid combinations of type specifiers in C90 + with -Wno-long-long. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors -Wno-long-long" } */ + +typedef char type; +extern *x0; +void *x1; +char *x2; +short *x3; +int *x4; +long *x5; +float *x6; +double *x7; +signed *x8; +unsigned *x9; +type *x10; +void void *x11; /* { dg-error "" "void void" } */ +void char *x12; /* { dg-error "" "void char" } */ +void short *x13; /* { dg-error "" "void short" } */ +void int *x14; /* { dg-error "" "void int" } */ +void long *x15; /* { dg-error "" "void long" } */ +void float *x16; /* { dg-error "" "void float" } */ +void double *x17; /* { dg-error "" "void double" } */ +void signed *x18; /* { dg-error "" "void signed" } */ +void unsigned *x19; /* { dg-error "" "void unsigned" } */ +char void *x20; /* { dg-error "" "char void" } */ +char char *x21; /* { dg-error "" "char char" } */ +char short *x22; /* { dg-error "" "char short" } */ +char int *x23; /* { dg-error "" "char int" } */ +char long *x24; /* { dg-error "" "char long" } */ +char float *x25; /* { dg-error "" "char float" } */ +char double *x26; /* { dg-error "" "char double" } */ +char signed *x27; +char unsigned *x28; +short void *x29; /* { dg-error "" "short void" } */ +short char *x30; /* { dg-error "" "short char" } */ +short short *x31; /* { dg-error "" "short short" } */ +short int *x32; +short long *x33; /* { dg-error "" "short long" } */ +short float *x34; /* { dg-error "" "short float" } */ +short double *x35; /* { dg-error "" "short double" } */ +short signed *x36; +short unsigned *x37; +int void *x38; /* { dg-error "" "int void" } */ +int char *x39; /* { dg-error "" "int char" } */ +int short *x40; +int int *x41; /* { dg-error "" "int int" } */ +int long *x42; +int float *x43; /* { dg-error "" "int float" } */ +int double *x44; /* { dg-error "" "int double" } */ +int signed *x45; +int unsigned *x46; +long void *x47; /* { dg-error "" "long void" } */ +long char *x48; /* { dg-error "" "long char" } */ +long short *x49; /* { dg-error "" "long short" } */ +long int *x50; +long long *x51; +long float *x52; /* { dg-error "" "long float" } */ +long double *x53; +long signed *x54; +long unsigned *x55; +float void *x56; /* { dg-error "" "float void" } */ +float char *x57; /* { dg-error "" "float char" } */ +float short *x58; /* { dg-error "" "float short" } */ +float int *x59; /* { dg-error "" "float int" } */ +float long *x60; /* { dg-error "" "float long" } */ +float float *x61; /* { dg-error "" "float float" } */ +float double *x62; /* { dg-error "" "float double" } */ +float signed *x63; /* { dg-error "" "float signed" } */ +float unsigned *x64; /* { dg-error "" "float unsigned" } */ +double void *x65; /* { dg-error "" "double void" } */ +double char *x66; /* { dg-error "" "double char" } */ +double short *x67; /* { dg-error "" "double short" } */ +double int *x68; /* { dg-error "" "double int" } */ +double long *x69; +double float *x70; /* { dg-error "" "double float" } */ +double double *x71; /* { dg-error "" "double double" } */ +double signed *x72; /* { dg-error "" "double signed" } */ +double unsigned *x73; /* { dg-error "" "double unsigned" } */ +signed void *x74; /* { dg-error "" "signed void" } */ +signed char *x75; +signed short *x76; +signed int *x77; +signed long *x78; +signed float *x79; /* { dg-error "" "signed float" } */ +signed double *x80; /* { dg-error "" "signed double" } */ +signed signed *x81; /* { dg-error "" "signed signed" } */ +signed unsigned *x82; /* { dg-error "" "signed unsigned" } */ +unsigned void *x83; /* { dg-error "" "unsigned void" } */ +unsigned char *x84; +unsigned short *x85; +unsigned int *x86; +unsigned long *x87; +unsigned float *x88; /* { dg-error "" "unsigned float" } */ +unsigned double *x89; /* { dg-error "" "unsigned double" } */ +unsigned signed *x90; /* { dg-error "" "unsigned signed" } */ +unsigned unsigned *x91; /* { dg-error "" "unsigned unsigned" } */ +type void *x92; /* { dg-error "" "type void" } */ +type char *x93; /* { dg-error "" "type char" } */ +type short *x94; /* { dg-error "" "type short" } */ +type int *x95; /* { dg-error "" "type int" } */ +type long *x96; /* { dg-error "" "type long" } */ +type float *x97; /* { dg-error "" "type float" } */ +type double *x98; /* { dg-error "" "type double" } */ +type signed *x99; /* { dg-error "" "type signed" } */ +type unsigned *x100; /* { dg-error "" "type unsigned" } */ +char signed void *x101; /* { dg-error "" "char signed void" } */ +char signed char *x102; /* { dg-error "" "char signed char" } */ +char signed short *x103; /* { dg-error "" "char signed short" } */ +char signed int *x104; /* { dg-error "" "char signed int" } */ +char signed long *x105; /* { dg-error "" "char signed long" } */ +char signed float *x106; /* { dg-error "" "char signed float" } */ +char signed double *x107; /* { dg-error "" "char signed double" } */ +char signed signed *x108; /* { dg-error "" "char signed signed" } */ +char signed unsigned *x109; /* { dg-error "" "char signed unsigned" } */ +char unsigned void *x110; /* { dg-error "" "char unsigned void" } */ +char unsigned char *x111; /* { dg-error "" "char unsigned char" } */ +char unsigned short *x112; /* { dg-error "" "char unsigned short" } */ +char unsigned int *x113; /* { dg-error "" "char unsigned int" } */ +char unsigned long *x114; /* { dg-error "" "char unsigned long" } */ +char unsigned float *x115; /* { dg-error "" "char unsigned float" } */ +char unsigned double *x116; /* { dg-error "" "char unsigned double" } */ +char unsigned signed *x117; /* { dg-error "" "char unsigned signed" } */ +char unsigned unsigned *x118; /* { dg-error "" "char unsigned unsigned" } */ +short int void *x119; /* { dg-error "" "short int void" } */ +short int char *x120; /* { dg-error "" "short int char" } */ +short int short *x121; /* { dg-error "" "short int short" } */ +short int int *x122; /* { dg-error "" "short int int" } */ +short int long *x123; /* { dg-error "" "short int long" } */ +short int float *x124; /* { dg-error "" "short int float" } */ +short int double *x125; /* { dg-error "" "short int double" } */ +short int signed *x126; +short int unsigned *x127; +short signed void *x128; /* { dg-error "" "short signed void" } */ +short signed char *x129; /* { dg-error "" "short signed char" } */ +short signed short *x130; /* { dg-error "" "short signed short" } */ +short signed int *x131; +short signed long *x132; /* { dg-error "" "short signed long" } */ +short signed float *x133; /* { dg-error "" "short signed float" } */ +short signed double *x134; /* { dg-error "" "short signed double" } */ +short signed signed *x135; /* { dg-error "" "short signed signed" } */ +short signed unsigned *x136; /* { dg-error "" "short signed unsigned" } */ +short unsigned void *x137; /* { dg-error "" "short unsigned void" } */ +short unsigned char *x138; /* { dg-error "" "short unsigned char" } */ +short unsigned short *x139; /* { dg-error "" "short unsigned short" } */ +short unsigned int *x140; +short unsigned long *x141; /* { dg-error "" "short unsigned long" } */ +short unsigned float *x142; /* { dg-error "" "short unsigned float" } */ +short unsigned double *x143; /* { dg-error "" "short unsigned double" } */ +short unsigned signed *x144; /* { dg-error "" "short unsigned signed" } */ +short unsigned unsigned *x145; /* { dg-error "" "short unsigned unsigned" } */ +int short void *x146; /* { dg-error "" "int short void" } */ +int short char *x147; /* { dg-error "" "int short char" } */ +int short short *x148; /* { dg-error "" "int short short" } */ +int short int *x149; /* { dg-error "" "int short int" } */ +int short long *x150; /* { dg-error "" "int short long" } */ +int short float *x151; /* { dg-error "" "int short float" } */ +int short double *x152; /* { dg-error "" "int short double" } */ +int short signed *x153; +int short unsigned *x154; +int long void *x155; /* { dg-error "" "int long void" } */ +int long char *x156; /* { dg-error "" "int long char" } */ +int long short *x157; /* { dg-error "" "int long short" } */ +int long int *x158; /* { dg-error "" "int long int" } */ +int long long *x159; +int long float *x160; /* { dg-error "" "int long float" } */ +int long double *x161; /* { dg-error "" "int long double" } */ +int long signed *x162; +int long unsigned *x163; +int signed void *x164; /* { dg-error "" "int signed void" } */ +int signed char *x165; /* { dg-error "" "int signed char" } */ +int signed short *x166; +int signed int *x167; /* { dg-error "" "int signed int" } */ +int signed long *x168; +int signed float *x169; /* { dg-error "" "int signed float" } */ +int signed double *x170; /* { dg-error "" "int signed double" } */ +int signed signed *x171; /* { dg-error "" "int signed signed" } */ +int signed unsigned *x172; /* { dg-error "" "int signed unsigned" } */ +int unsigned void *x173; /* { dg-error "" "int unsigned void" } */ +int unsigned char *x174; /* { dg-error "" "int unsigned char" } */ +int unsigned short *x175; +int unsigned int *x176; /* { dg-error "" "int unsigned int" } */ +int unsigned long *x177; +int unsigned float *x178; /* { dg-error "" "int unsigned float" } */ +int unsigned double *x179; /* { dg-error "" "int unsigned double" } */ +int unsigned signed *x180; /* { dg-error "" "int unsigned signed" } */ +int unsigned unsigned *x181; /* { dg-error "" "int unsigned unsigned" } */ +long int void *x182; /* { dg-error "" "long int void" } */ +long int char *x183; /* { dg-error "" "long int char" } */ +long int short *x184; /* { dg-error "" "long int short" } */ +long int int *x185; /* { dg-error "" "long int int" } */ +long int long *x186; +long int float *x187; /* { dg-error "" "long int float" } */ +long int double *x188; /* { dg-error "" "long int double" } */ +long int signed *x189; +long int unsigned *x190; +long long void *x191; /* { dg-error "" "long long void" } */ +long long char *x192; /* { dg-error "" "long long char" } */ +long long short *x193; /* { dg-error "" "long long short" } */ +long long int *x194; +long long long *x195; /* { dg-error "" "long long long" } */ +long long float *x196; /* { dg-error "" "long long float" } */ +long long double *x197; /* { dg-error "" "long long double" } */ +long long signed *x198; +long long unsigned *x199; +long double void *x200; /* { dg-error "" "long double void" } */ +long double char *x201; /* { dg-error "" "long double char" } */ +long double short *x202; /* { dg-error "" "long double short" } */ +long double int *x203; /* { dg-error "" "long double int" } */ +long double long *x204; /* { dg-error "" "long double long" } */ +long double float *x205; /* { dg-error "" "long double float" } */ +long double double *x206; /* { dg-error "" "long double double" } */ +long double signed *x207; /* { dg-error "" "long double signed" } */ +long double unsigned *x208; /* { dg-error "" "long double unsigned" } */ +long signed void *x209; /* { dg-error "" "long signed void" } */ +long signed char *x210; /* { dg-error "" "long signed char" } */ +long signed short *x211; /* { dg-error "" "long signed short" } */ +long signed int *x212; +long signed long *x213; +long signed float *x214; /* { dg-error "" "long signed float" } */ +long signed double *x215; /* { dg-error "" "long signed double" } */ +long signed signed *x216; /* { dg-error "" "long signed signed" } */ +long signed unsigned *x217; /* { dg-error "" "long signed unsigned" } */ +long unsigned void *x218; /* { dg-error "" "long unsigned void" } */ +long unsigned char *x219; /* { dg-error "" "long unsigned char" } */ +long unsigned short *x220; /* { dg-error "" "long unsigned short" } */ +long unsigned int *x221; +long unsigned long *x222; +long unsigned float *x223; /* { dg-error "" "long unsigned float" } */ +long unsigned double *x224; /* { dg-error "" "long unsigned double" } */ +long unsigned signed *x225; /* { dg-error "" "long unsigned signed" } */ +long unsigned unsigned *x226; /* { dg-error "" "long unsigned unsigned" } */ +double long void *x227; /* { dg-error "" "double long void" } */ +double long char *x228; /* { dg-error "" "double long char" } */ +double long short *x229; /* { dg-error "" "double long short" } */ +double long int *x230; /* { dg-error "" "double long int" } */ +double long long *x231; /* { dg-error "" "double long long" } */ +double long float *x232; /* { dg-error "" "double long float" } */ +double long double *x233; /* { dg-error "" "double long double" } */ +double long signed *x234; /* { dg-error "" "double long signed" } */ +double long unsigned *x235; /* { dg-error "" "double long unsigned" } */ +signed char void *x236; /* { dg-error "" "signed char void" } */ +signed char char *x237; /* { dg-error "" "signed char char" } */ +signed char short *x238; /* { dg-error "" "signed char short" } */ +signed char int *x239; /* { dg-error "" "signed char int" } */ +signed char long *x240; /* { dg-error "" "signed char long" } */ +signed char float *x241; /* { dg-error "" "signed char float" } */ +signed char double *x242; /* { dg-error "" "signed char double" } */ +signed char signed *x243; /* { dg-error "" "signed char signed" } */ +signed char unsigned *x244; /* { dg-error "" "signed char unsigned" } */ +signed short void *x245; /* { dg-error "" "signed short void" } */ +signed short char *x246; /* { dg-error "" "signed short char" } */ +signed short short *x247; /* { dg-error "" "signed short short" } */ +signed short int *x248; +signed short long *x249; /* { dg-error "" "signed short long" } */ +signed short float *x250; /* { dg-error "" "signed short float" } */ +signed short double *x251; /* { dg-error "" "signed short double" } */ +signed short signed *x252; /* { dg-error "" "signed short signed" } */ +signed short unsigned *x253; /* { dg-error "" "signed short unsigned" } */ +signed int void *x254; /* { dg-error "" "signed int void" } */ +signed int char *x255; /* { dg-error "" "signed int char" } */ +signed int short *x256; +signed int int *x257; /* { dg-error "" "signed int int" } */ +signed int long *x258; +signed int float *x259; /* { dg-error "" "signed int float" } */ +signed int double *x260; /* { dg-error "" "signed int double" } */ +signed int signed *x261; /* { dg-error "" "signed int signed" } */ +signed int unsigned *x262; /* { dg-error "" "signed int unsigned" } */ +signed long void *x263; /* { dg-error "" "signed long void" } */ +signed long char *x264; /* { dg-error "" "signed long char" } */ +signed long short *x265; /* { dg-error "" "signed long short" } */ +signed long int *x266; +signed long long *x267; +signed long float *x268; /* { dg-error "" "signed long float" } */ +signed long double *x269; /* { dg-error "" "signed long double" } */ +signed long signed *x270; /* { dg-error "" "signed long signed" } */ +signed long unsigned *x271; /* { dg-error "" "signed long unsigned" } */ +unsigned char void *x272; /* { dg-error "" "unsigned char void" } */ +unsigned char char *x273; /* { dg-error "" "unsigned char char" } */ +unsigned char short *x274; /* { dg-error "" "unsigned char short" } */ +unsigned char int *x275; /* { dg-error "" "unsigned char int" } */ +unsigned char long *x276; /* { dg-error "" "unsigned char long" } */ +unsigned char float *x277; /* { dg-error "" "unsigned char float" } */ +unsigned char double *x278; /* { dg-error "" "unsigned char double" } */ +unsigned char signed *x279; /* { dg-error "" "unsigned char signed" } */ +unsigned char unsigned *x280; /* { dg-error "" "unsigned char unsigned" } */ +unsigned short void *x281; /* { dg-error "" "unsigned short void" } */ +unsigned short char *x282; /* { dg-error "" "unsigned short char" } */ +unsigned short short *x283; /* { dg-error "" "unsigned short short" } */ +unsigned short int *x284; +unsigned short long *x285; /* { dg-error "" "unsigned short long" } */ +unsigned short float *x286; /* { dg-error "" "unsigned short float" } */ +unsigned short double *x287; /* { dg-error "" "unsigned short double" } */ +unsigned short signed *x288; /* { dg-error "" "unsigned short signed" } */ +unsigned short unsigned *x289; /* { dg-error "" "unsigned short unsigned" } */ +unsigned int void *x290; /* { dg-error "" "unsigned int void" } */ +unsigned int char *x291; /* { dg-error "" "unsigned int char" } */ +unsigned int short *x292; +unsigned int int *x293; /* { dg-error "" "unsigned int int" } */ +unsigned int long *x294; +unsigned int float *x295; /* { dg-error "" "unsigned int float" } */ +unsigned int double *x296; /* { dg-error "" "unsigned int double" } */ +unsigned int signed *x297; /* { dg-error "" "unsigned int signed" } */ +unsigned int unsigned *x298; /* { dg-error "" "unsigned int unsigned" } */ +unsigned long void *x299; /* { dg-error "" "unsigned long void" } */ +unsigned long char *x300; /* { dg-error "" "unsigned long char" } */ +unsigned long short *x301; /* { dg-error "" "unsigned long short" } */ +unsigned long int *x302; +unsigned long long *x303; +unsigned long float *x304; /* { dg-error "" "unsigned long float" } */ +unsigned long double *x305; /* { dg-error "" "unsigned long double" } */ +unsigned long signed *x306; /* { dg-error "" "unsigned long signed" } */ +unsigned long unsigned *x307; /* { dg-error "" "unsigned long unsigned" } */ +short int signed void *x308; /* { dg-error "" "short int signed void" } */ +short int signed char *x309; /* { dg-error "" "short int signed char" } */ +short int signed short *x310; /* { dg-error "" "short int signed short" } */ +short int signed int *x311; /* { dg-error "" "short int signed int" } */ +short int signed long *x312; /* { dg-error "" "short int signed long" } */ +short int signed float *x313; /* { dg-error "" "short int signed float" } */ +short int signed double *x314; /* { dg-error "" "short int signed double" } */ +short int signed signed *x315; /* { dg-error "" "short int signed signed" } */ +short int signed unsigned *x316; /* { dg-error "" "short int signed unsigned" } */ +short int unsigned void *x317; /* { dg-error "" "short int unsigned void" } */ +short int unsigned char *x318; /* { dg-error "" "short int unsigned char" } */ +short int unsigned short *x319; /* { dg-error "" "short int unsigned short" } */ +short int unsigned int *x320; /* { dg-error "" "short int unsigned int" } */ +short int unsigned long *x321; /* { dg-error "" "short int unsigned long" } */ +short int unsigned float *x322; /* { dg-error "" "short int unsigned float" } */ +short int unsigned double *x323; /* { dg-error "" "short int unsigned double" } */ +short int unsigned signed *x324; /* { dg-error "" "short int unsigned signed" } */ +short int unsigned unsigned *x325; /* { dg-error "" "short int unsigned unsigned" } */ +short signed int void *x326; /* { dg-error "" "short signed int void" } */ +short signed int char *x327; /* { dg-error "" "short signed int char" } */ +short signed int short *x328; /* { dg-error "" "short signed int short" } */ +short signed int int *x329; /* { dg-error "" "short signed int int" } */ +short signed int long *x330; /* { dg-error "" "short signed int long" } */ +short signed int float *x331; /* { dg-error "" "short signed int float" } */ +short signed int double *x332; /* { dg-error "" "short signed int double" } */ +short signed int signed *x333; /* { dg-error "" "short signed int signed" } */ +short signed int unsigned *x334; /* { dg-error "" "short signed int unsigned" } */ +short unsigned int void *x335; /* { dg-error "" "short unsigned int void" } */ +short unsigned int char *x336; /* { dg-error "" "short unsigned int char" } */ +short unsigned int short *x337; /* { dg-error "" "short unsigned int short" } */ +short unsigned int int *x338; /* { dg-error "" "short unsigned int int" } */ +short unsigned int long *x339; /* { dg-error "" "short unsigned int long" } */ +short unsigned int float *x340; /* { dg-error "" "short unsigned int float" } */ +short unsigned int double *x341; /* { dg-error "" "short unsigned int double" } */ +short unsigned int signed *x342; /* { dg-error "" "short unsigned int signed" } */ +short unsigned int unsigned *x343; /* { dg-error "" "short unsigned int unsigned" } */ +int short signed void *x344; /* { dg-error "" "int short signed void" } */ +int short signed char *x345; /* { dg-error "" "int short signed char" } */ +int short signed short *x346; /* { dg-error "" "int short signed short" } */ +int short signed int *x347; /* { dg-error "" "int short signed int" } */ +int short signed long *x348; /* { dg-error "" "int short signed long" } */ +int short signed float *x349; /* { dg-error "" "int short signed float" } */ +int short signed double *x350; /* { dg-error "" "int short signed double" } */ +int short signed signed *x351; /* { dg-error "" "int short signed signed" } */ +int short signed unsigned *x352; /* { dg-error "" "int short signed unsigned" } */ +int short unsigned void *x353; /* { dg-error "" "int short unsigned void" } */ +int short unsigned char *x354; /* { dg-error "" "int short unsigned char" } */ +int short unsigned short *x355; /* { dg-error "" "int short unsigned short" } */ +int short unsigned int *x356; /* { dg-error "" "int short unsigned int" } */ +int short unsigned long *x357; /* { dg-error "" "int short unsigned long" } */ +int short unsigned float *x358; /* { dg-error "" "int short unsigned float" } */ +int short unsigned double *x359; /* { dg-error "" "int short unsigned double" } */ +int short unsigned signed *x360; /* { dg-error "" "int short unsigned signed" } */ +int short unsigned unsigned *x361; /* { dg-error "" "int short unsigned unsigned" } */ +int long long void *x362; /* { dg-error "" "int long long void" } */ +int long long char *x363; /* { dg-error "" "int long long char" } */ +int long long short *x364; /* { dg-error "" "int long long short" } */ +int long long int *x365; /* { dg-error "" "int long long int" } */ +int long long long *x366; /* { dg-error "" "int long long long" } */ +int long long float *x367; /* { dg-error "" "int long long float" } */ +int long long double *x368; /* { dg-error "" "int long long double" } */ +int long long signed *x369; +int long long unsigned *x370; +int long signed void *x371; /* { dg-error "" "int long signed void" } */ +int long signed char *x372; /* { dg-error "" "int long signed char" } */ +int long signed short *x373; /* { dg-error "" "int long signed short" } */ +int long signed int *x374; /* { dg-error "" "int long signed int" } */ +int long signed long *x375; +int long signed float *x376; /* { dg-error "" "int long signed float" } */ +int long signed double *x377; /* { dg-error "" "int long signed double" } */ +int long signed signed *x378; /* { dg-error "" "int long signed signed" } */ +int long signed unsigned *x379; /* { dg-error "" "int long signed unsigned" } */ +int long unsigned void *x380; /* { dg-error "" "int long unsigned void" } */ +int long unsigned char *x381; /* { dg-error "" "int long unsigned char" } */ +int long unsigned short *x382; /* { dg-error "" "int long unsigned short" } */ +int long unsigned int *x383; /* { dg-error "" "int long unsigned int" } */ +int long unsigned long *x384; +int long unsigned float *x385; /* { dg-error "" "int long unsigned float" } */ +int long unsigned double *x386; /* { dg-error "" "int long unsigned double" } */ +int long unsigned signed *x387; /* { dg-error "" "int long unsigned signed" } */ +int long unsigned unsigned *x388; /* { dg-error "" "int long unsigned unsigned" } */ +int signed short void *x389; /* { dg-error "" "int signed short void" } */ +int signed short char *x390; /* { dg-error "" "int signed short char" } */ +int signed short short *x391; /* { dg-error "" "int signed short short" } */ +int signed short int *x392; /* { dg-error "" "int signed short int" } */ +int signed short long *x393; /* { dg-error "" "int signed short long" } */ +int signed short float *x394; /* { dg-error "" "int signed short float" } */ +int signed short double *x395; /* { dg-error "" "int signed short double" } */ +int signed short signed *x396; /* { dg-error "" "int signed short signed" } */ +int signed short unsigned *x397; /* { dg-error "" "int signed short unsigned" } */ +int signed long void *x398; /* { dg-error "" "int signed long void" } */ +int signed long char *x399; /* { dg-error "" "int signed long char" } */ +int signed long short *x400; /* { dg-error "" "int signed long short" } */ +int signed long int *x401; /* { dg-error "" "int signed long int" } */ +int signed long long *x402; +int signed long float *x403; /* { dg-error "" "int signed long float" } */ +int signed long double *x404; /* { dg-error "" "int signed long double" } */ +int signed long signed *x405; /* { dg-error "" "int signed long signed" } */ +int signed long unsigned *x406; /* { dg-error "" "int signed long unsigned" } */ +int unsigned short void *x407; /* { dg-error "" "int unsigned short void" } */ +int unsigned short char *x408; /* { dg-error "" "int unsigned short char" } */ +int unsigned short short *x409; /* { dg-error "" "int unsigned short short" } */ +int unsigned short int *x410; /* { dg-error "" "int unsigned short int" } */ +int unsigned short long *x411; /* { dg-error "" "int unsigned short long" } */ +int unsigned short float *x412; /* { dg-error "" "int unsigned short float" } */ +int unsigned short double *x413; /* { dg-error "" "int unsigned short double" } */ +int unsigned short signed *x414; /* { dg-error "" "int unsigned short signed" } */ +int unsigned short unsigned *x415; /* { dg-error "" "int unsigned short unsigned" } */ +int unsigned long void *x416; /* { dg-error "" "int unsigned long void" } */ +int unsigned long char *x417; /* { dg-error "" "int unsigned long char" } */ +int unsigned long short *x418; /* { dg-error "" "int unsigned long short" } */ +int unsigned long int *x419; /* { dg-error "" "int unsigned long int" } */ +int unsigned long long *x420; +int unsigned long float *x421; /* { dg-error "" "int unsigned long float" } */ +int unsigned long double *x422; /* { dg-error "" "int unsigned long double" } */ +int unsigned long signed *x423; /* { dg-error "" "int unsigned long signed" } */ +int unsigned long unsigned *x424; /* { dg-error "" "int unsigned long unsigned" } */ +long int long void *x425; /* { dg-error "" "long int long void" } */ +long int long char *x426; /* { dg-error "" "long int long char" } */ +long int long short *x427; /* { dg-error "" "long int long short" } */ +long int long int *x428; /* { dg-error "" "long int long int" } */ +long int long long *x429; /* { dg-error "" "long int long long" } */ +long int long float *x430; /* { dg-error "" "long int long float" } */ +long int long double *x431; /* { dg-error "" "long int long double" } */ +long int long signed *x432; +long int long unsigned *x433; +long int signed void *x434; /* { dg-error "" "long int signed void" } */ +long int signed char *x435; /* { dg-error "" "long int signed char" } */ +long int signed short *x436; /* { dg-error "" "long int signed short" } */ +long int signed int *x437; /* { dg-error "" "long int signed int" } */ +long int signed long *x438; +long int signed float *x439; /* { dg-error "" "long int signed float" } */ +long int signed double *x440; /* { dg-error "" "long int signed double" } */ +long int signed signed *x441; /* { dg-error "" "long int signed signed" } */ +long int signed unsigned *x442; /* { dg-error "" "long int signed unsigned" } */ +long int unsigned void *x443; /* { dg-error "" "long int unsigned void" } */ +long int unsigned char *x444; /* { dg-error "" "long int unsigned char" } */ +long int unsigned short *x445; /* { dg-error "" "long int unsigned short" } */ +long int unsigned int *x446; /* { dg-error "" "long int unsigned int" } */ +long int unsigned long *x447; +long int unsigned float *x448; /* { dg-error "" "long int unsigned float" } */ +long int unsigned double *x449; /* { dg-error "" "long int unsigned double" } */ +long int unsigned signed *x450; /* { dg-error "" "long int unsigned signed" } */ +long int unsigned unsigned *x451; /* { dg-error "" "long int unsigned unsigned" } */ +long long int void *x452; /* { dg-error "" "long long int void" } */ +long long int char *x453; /* { dg-error "" "long long int char" } */ +long long int short *x454; /* { dg-error "" "long long int short" } */ +long long int int *x455; /* { dg-error "" "long long int int" } */ +long long int long *x456; /* { dg-error "" "long long int long" } */ +long long int float *x457; /* { dg-error "" "long long int float" } */ +long long int double *x458; /* { dg-error "" "long long int double" } */ +long long int signed *x459; +long long int unsigned *x460; +long long signed void *x461; /* { dg-error "" "long long signed void" } */ +long long signed char *x462; /* { dg-error "" "long long signed char" } */ +long long signed short *x463; /* { dg-error "" "long long signed short" } */ +long long signed int *x464; +long long signed long *x465; /* { dg-error "" "long long signed long" } */ +long long signed float *x466; /* { dg-error "" "long long signed float" } */ +long long signed double *x467; /* { dg-error "" "long long signed double" } */ +long long signed signed *x468; /* { dg-error "" "long long signed signed" } */ +long long signed unsigned *x469; /* { dg-error "" "long long signed unsigned" } */ +long long unsigned void *x470; /* { dg-error "" "long long unsigned void" } */ +long long unsigned char *x471; /* { dg-error "" "long long unsigned char" } */ +long long unsigned short *x472; /* { dg-error "" "long long unsigned short" } */ +long long unsigned int *x473; +long long unsigned long *x474; /* { dg-error "" "long long unsigned long" } */ +long long unsigned float *x475; /* { dg-error "" "long long unsigned float" } */ +long long unsigned double *x476; /* { dg-error "" "long long unsigned double" } */ +long long unsigned signed *x477; /* { dg-error "" "long long unsigned signed" } */ +long long unsigned unsigned *x478; /* { dg-error "" "long long unsigned unsigned" } */ +long signed int void *x479; /* { dg-error "" "long signed int void" } */ +long signed int char *x480; /* { dg-error "" "long signed int char" } */ +long signed int short *x481; /* { dg-error "" "long signed int short" } */ +long signed int int *x482; /* { dg-error "" "long signed int int" } */ +long signed int long *x483; +long signed int float *x484; /* { dg-error "" "long signed int float" } */ +long signed int double *x485; /* { dg-error "" "long signed int double" } */ +long signed int signed *x486; /* { dg-error "" "long signed int signed" } */ +long signed int unsigned *x487; /* { dg-error "" "long signed int unsigned" } */ +long signed long void *x488; /* { dg-error "" "long signed long void" } */ +long signed long char *x489; /* { dg-error "" "long signed long char" } */ +long signed long short *x490; /* { dg-error "" "long signed long short" } */ +long signed long int *x491; +long signed long long *x492; /* { dg-error "" "long signed long long" } */ +long signed long float *x493; /* { dg-error "" "long signed long float" } */ +long signed long double *x494; /* { dg-error "" "long signed long double" } */ +long signed long signed *x495; /* { dg-error "" "long signed long signed" } */ +long signed long unsigned *x496; /* { dg-error "" "long signed long unsigned" } */ +long unsigned int void *x497; /* { dg-error "" "long unsigned int void" } */ +long unsigned int char *x498; /* { dg-error "" "long unsigned int char" } */ +long unsigned int short *x499; /* { dg-error "" "long unsigned int short" } */ +long unsigned int int *x500; /* { dg-error "" "long unsigned int int" } */ +long unsigned int long *x501; +long unsigned int float *x502; /* { dg-error "" "long unsigned int float" } */ +long unsigned int double *x503; /* { dg-error "" "long unsigned int double" } */ +long unsigned int signed *x504; /* { dg-error "" "long unsigned int signed" } */ +long unsigned int unsigned *x505; /* { dg-error "" "long unsigned int unsigned" } */ +long unsigned long void *x506; /* { dg-error "" "long unsigned long void" } */ +long unsigned long char *x507; /* { dg-error "" "long unsigned long char" } */ +long unsigned long short *x508; /* { dg-error "" "long unsigned long short" } */ +long unsigned long int *x509; +long unsigned long long *x510; /* { dg-error "" "long unsigned long long" } */ +long unsigned long float *x511; /* { dg-error "" "long unsigned long float" } */ +long unsigned long double *x512; /* { dg-error "" "long unsigned long double" } */ +long unsigned long signed *x513; /* { dg-error "" "long unsigned long signed" } */ +long unsigned long unsigned *x514; /* { dg-error "" "long unsigned long unsigned" } */ +signed short int void *x515; /* { dg-error "" "signed short int void" } */ +signed short int char *x516; /* { dg-error "" "signed short int char" } */ +signed short int short *x517; /* { dg-error "" "signed short int short" } */ +signed short int int *x518; /* { dg-error "" "signed short int int" } */ +signed short int long *x519; /* { dg-error "" "signed short int long" } */ +signed short int float *x520; /* { dg-error "" "signed short int float" } */ +signed short int double *x521; /* { dg-error "" "signed short int double" } */ +signed short int signed *x522; /* { dg-error "" "signed short int signed" } */ +signed short int unsigned *x523; /* { dg-error "" "signed short int unsigned" } */ +signed int short void *x524; /* { dg-error "" "signed int short void" } */ +signed int short char *x525; /* { dg-error "" "signed int short char" } */ +signed int short short *x526; /* { dg-error "" "signed int short short" } */ +signed int short int *x527; /* { dg-error "" "signed int short int" } */ +signed int short long *x528; /* { dg-error "" "signed int short long" } */ +signed int short float *x529; /* { dg-error "" "signed int short float" } */ +signed int short double *x530; /* { dg-error "" "signed int short double" } */ +signed int short signed *x531; /* { dg-error "" "signed int short signed" } */ +signed int short unsigned *x532; /* { dg-error "" "signed int short unsigned" } */ +signed int long void *x533; /* { dg-error "" "signed int long void" } */ +signed int long char *x534; /* { dg-error "" "signed int long char" } */ +signed int long short *x535; /* { dg-error "" "signed int long short" } */ +signed int long int *x536; /* { dg-error "" "signed int long int" } */ +signed int long long *x537; +signed int long float *x538; /* { dg-error "" "signed int long float" } */ +signed int long double *x539; /* { dg-error "" "signed int long double" } */ +signed int long signed *x540; /* { dg-error "" "signed int long signed" } */ +signed int long unsigned *x541; /* { dg-error "" "signed int long unsigned" } */ +signed long int void *x542; /* { dg-error "" "signed long int void" } */ +signed long int char *x543; /* { dg-error "" "signed long int char" } */ +signed long int short *x544; /* { dg-error "" "signed long int short" } */ +signed long int int *x545; /* { dg-error "" "signed long int int" } */ +signed long int long *x546; +signed long int float *x547; /* { dg-error "" "signed long int float" } */ +signed long int double *x548; /* { dg-error "" "signed long int double" } */ +signed long int signed *x549; /* { dg-error "" "signed long int signed" } */ +signed long int unsigned *x550; /* { dg-error "" "signed long int unsigned" } */ +signed long long void *x551; /* { dg-error "" "signed long long void" } */ +signed long long char *x552; /* { dg-error "" "signed long long char" } */ +signed long long short *x553; /* { dg-error "" "signed long long short" } */ +signed long long int *x554; +signed long long long *x555; /* { dg-error "" "signed long long long" } */ +signed long long float *x556; /* { dg-error "" "signed long long float" } */ +signed long long double *x557; /* { dg-error "" "signed long long double" } */ +signed long long signed *x558; /* { dg-error "" "signed long long signed" } */ +signed long long unsigned *x559; /* { dg-error "" "signed long long unsigned" } */ +unsigned short int void *x560; /* { dg-error "" "unsigned short int void" } */ +unsigned short int char *x561; /* { dg-error "" "unsigned short int char" } */ +unsigned short int short *x562; /* { dg-error "" "unsigned short int short" } */ +unsigned short int int *x563; /* { dg-error "" "unsigned short int int" } */ +unsigned short int long *x564; /* { dg-error "" "unsigned short int long" } */ +unsigned short int float *x565; /* { dg-error "" "unsigned short int float" } */ +unsigned short int double *x566; /* { dg-error "" "unsigned short int double" } */ +unsigned short int signed *x567; /* { dg-error "" "unsigned short int signed" } */ +unsigned short int unsigned *x568; /* { dg-error "" "unsigned short int unsigned" } */ +unsigned int short void *x569; /* { dg-error "" "unsigned int short void" } */ +unsigned int short char *x570; /* { dg-error "" "unsigned int short char" } */ +unsigned int short short *x571; /* { dg-error "" "unsigned int short short" } */ +unsigned int short int *x572; /* { dg-error "" "unsigned int short int" } */ +unsigned int short long *x573; /* { dg-error "" "unsigned int short long" } */ +unsigned int short float *x574; /* { dg-error "" "unsigned int short float" } */ +unsigned int short double *x575; /* { dg-error "" "unsigned int short double" } */ +unsigned int short signed *x576; /* { dg-error "" "unsigned int short signed" } */ +unsigned int short unsigned *x577; /* { dg-error "" "unsigned int short unsigned" } */ +unsigned int long void *x578; /* { dg-error "" "unsigned int long void" } */ +unsigned int long char *x579; /* { dg-error "" "unsigned int long char" } */ +unsigned int long short *x580; /* { dg-error "" "unsigned int long short" } */ +unsigned int long int *x581; /* { dg-error "" "unsigned int long int" } */ +unsigned int long long *x582; +unsigned int long float *x583; /* { dg-error "" "unsigned int long float" } */ +unsigned int long double *x584; /* { dg-error "" "unsigned int long double" } */ +unsigned int long signed *x585; /* { dg-error "" "unsigned int long signed" } */ +unsigned int long unsigned *x586; /* { dg-error "" "unsigned int long unsigned" } */ +unsigned long int void *x587; /* { dg-error "" "unsigned long int void" } */ +unsigned long int char *x588; /* { dg-error "" "unsigned long int char" } */ +unsigned long int short *x589; /* { dg-error "" "unsigned long int short" } */ +unsigned long int int *x590; /* { dg-error "" "unsigned long int int" } */ +unsigned long int long *x591; +unsigned long int float *x592; /* { dg-error "" "unsigned long int float" } */ +unsigned long int double *x593; /* { dg-error "" "unsigned long int double" } */ +unsigned long int signed *x594; /* { dg-error "" "unsigned long int signed" } */ +unsigned long int unsigned *x595; /* { dg-error "" "unsigned long int unsigned" } */ +unsigned long long void *x596; /* { dg-error "" "unsigned long long void" } */ +unsigned long long char *x597; /* { dg-error "" "unsigned long long char" } */ +unsigned long long short *x598; /* { dg-error "" "unsigned long long short" } */ +unsigned long long int *x599; +unsigned long long long *x600; /* { dg-error "" "unsigned long long long" } */ +unsigned long long float *x601; /* { dg-error "" "unsigned long long float" } */ +unsigned long long double *x602; /* { dg-error "" "unsigned long long double" } */ +unsigned long long signed *x603; /* { dg-error "" "unsigned long long signed" } */ +unsigned long long unsigned *x604; /* { dg-error "" "unsigned long long unsigned" } */ +int long long signed void *x605; /* { dg-error "" "int long long signed void" } */ +int long long signed char *x606; /* { dg-error "" "int long long signed char" } */ +int long long signed short *x607; /* { dg-error "" "int long long signed short" } */ +int long long signed int *x608; /* { dg-error "" "int long long signed int" } */ +int long long signed long *x609; /* { dg-error "" "int long long signed long" } */ +int long long signed float *x610; /* { dg-error "" "int long long signed float" } */ +int long long signed double *x611; /* { dg-error "" "int long long signed double" } */ +int long long signed signed *x612; /* { dg-error "" "int long long signed signed" } */ +int long long signed unsigned *x613; /* { dg-error "" "int long long signed unsigned" } */ +int long long unsigned void *x614; /* { dg-error "" "int long long unsigned void" } */ +int long long unsigned char *x615; /* { dg-error "" "int long long unsigned char" } */ +int long long unsigned short *x616; /* { dg-error "" "int long long unsigned short" } */ +int long long unsigned int *x617; /* { dg-error "" "int long long unsigned int" } */ +int long long unsigned long *x618; /* { dg-error "" "int long long unsigned long" } */ +int long long unsigned float *x619; /* { dg-error "" "int long long unsigned float" } */ +int long long unsigned double *x620; /* { dg-error "" "int long long unsigned double" } */ +int long long unsigned signed *x621; /* { dg-error "" "int long long unsigned signed" } */ +int long long unsigned unsigned *x622; /* { dg-error "" "int long long unsigned unsigned" } */ +int long signed long void *x623; /* { dg-error "" "int long signed long void" } */ +int long signed long char *x624; /* { dg-error "" "int long signed long char" } */ +int long signed long short *x625; /* { dg-error "" "int long signed long short" } */ +int long signed long int *x626; /* { dg-error "" "int long signed long int" } */ +int long signed long long *x627; /* { dg-error "" "int long signed long long" } */ +int long signed long float *x628; /* { dg-error "" "int long signed long float" } */ +int long signed long double *x629; /* { dg-error "" "int long signed long double" } */ +int long signed long signed *x630; /* { dg-error "" "int long signed long signed" } */ +int long signed long unsigned *x631; /* { dg-error "" "int long signed long unsigned" } */ +int long unsigned long void *x632; /* { dg-error "" "int long unsigned long void" } */ +int long unsigned long char *x633; /* { dg-error "" "int long unsigned long char" } */ +int long unsigned long short *x634; /* { dg-error "" "int long unsigned long short" } */ +int long unsigned long int *x635; /* { dg-error "" "int long unsigned long int" } */ +int long unsigned long long *x636; /* { dg-error "" "int long unsigned long long" } */ +int long unsigned long float *x637; /* { dg-error "" "int long unsigned long float" } */ +int long unsigned long double *x638; /* { dg-error "" "int long unsigned long double" } */ +int long unsigned long signed *x639; /* { dg-error "" "int long unsigned long signed" } */ +int long unsigned long unsigned *x640; /* { dg-error "" "int long unsigned long unsigned" } */ +int signed long long void *x641; /* { dg-error "" "int signed long long void" } */ +int signed long long char *x642; /* { dg-error "" "int signed long long char" } */ +int signed long long short *x643; /* { dg-error "" "int signed long long short" } */ +int signed long long int *x644; /* { dg-error "" "int signed long long int" } */ +int signed long long long *x645; /* { dg-error "" "int signed long long long" } */ +int signed long long float *x646; /* { dg-error "" "int signed long long float" } */ +int signed long long double *x647; /* { dg-error "" "int signed long long double" } */ +int signed long long signed *x648; /* { dg-error "" "int signed long long signed" } */ +int signed long long unsigned *x649; /* { dg-error "" "int signed long long unsigned" } */ +int unsigned long long void *x650; /* { dg-error "" "int unsigned long long void" } */ +int unsigned long long char *x651; /* { dg-error "" "int unsigned long long char" } */ +int unsigned long long short *x652; /* { dg-error "" "int unsigned long long short" } */ +int unsigned long long int *x653; /* { dg-error "" "int unsigned long long int" } */ +int unsigned long long long *x654; /* { dg-error "" "int unsigned long long long" } */ +int unsigned long long float *x655; /* { dg-error "" "int unsigned long long float" } */ +int unsigned long long double *x656; /* { dg-error "" "int unsigned long long double" } */ +int unsigned long long signed *x657; /* { dg-error "" "int unsigned long long signed" } */ +int unsigned long long unsigned *x658; /* { dg-error "" "int unsigned long long unsigned" } */ +long int long signed void *x659; /* { dg-error "" "long int long signed void" } */ +long int long signed char *x660; /* { dg-error "" "long int long signed char" } */ +long int long signed short *x661; /* { dg-error "" "long int long signed short" } */ +long int long signed int *x662; /* { dg-error "" "long int long signed int" } */ +long int long signed long *x663; /* { dg-error "" "long int long signed long" } */ +long int long signed float *x664; /* { dg-error "" "long int long signed float" } */ +long int long signed double *x665; /* { dg-error "" "long int long signed double" } */ +long int long signed signed *x666; /* { dg-error "" "long int long signed signed" } */ +long int long signed unsigned *x667; /* { dg-error "" "long int long signed unsigned" } */ +long int long unsigned void *x668; /* { dg-error "" "long int long unsigned void" } */ +long int long unsigned char *x669; /* { dg-error "" "long int long unsigned char" } */ +long int long unsigned short *x670; /* { dg-error "" "long int long unsigned short" } */ +long int long unsigned int *x671; /* { dg-error "" "long int long unsigned int" } */ +long int long unsigned long *x672; /* { dg-error "" "long int long unsigned long" } */ +long int long unsigned float *x673; /* { dg-error "" "long int long unsigned float" } */ +long int long unsigned double *x674; /* { dg-error "" "long int long unsigned double" } */ +long int long unsigned signed *x675; /* { dg-error "" "long int long unsigned signed" } */ +long int long unsigned unsigned *x676; /* { dg-error "" "long int long unsigned unsigned" } */ +long int signed long void *x677; /* { dg-error "" "long int signed long void" } */ +long int signed long char *x678; /* { dg-error "" "long int signed long char" } */ +long int signed long short *x679; /* { dg-error "" "long int signed long short" } */ +long int signed long int *x680; /* { dg-error "" "long int signed long int" } */ +long int signed long long *x681; /* { dg-error "" "long int signed long long" } */ +long int signed long float *x682; /* { dg-error "" "long int signed long float" } */ +long int signed long double *x683; /* { dg-error "" "long int signed long double" } */ +long int signed long signed *x684; /* { dg-error "" "long int signed long signed" } */ +long int signed long unsigned *x685; /* { dg-error "" "long int signed long unsigned" } */ +long int unsigned long void *x686; /* { dg-error "" "long int unsigned long void" } */ +long int unsigned long char *x687; /* { dg-error "" "long int unsigned long char" } */ +long int unsigned long short *x688; /* { dg-error "" "long int unsigned long short" } */ +long int unsigned long int *x689; /* { dg-error "" "long int unsigned long int" } */ +long int unsigned long long *x690; /* { dg-error "" "long int unsigned long long" } */ +long int unsigned long float *x691; /* { dg-error "" "long int unsigned long float" } */ +long int unsigned long double *x692; /* { dg-error "" "long int unsigned long double" } */ +long int unsigned long signed *x693; /* { dg-error "" "long int unsigned long signed" } */ +long int unsigned long unsigned *x694; /* { dg-error "" "long int unsigned long unsigned" } */ +long long int signed void *x695; /* { dg-error "" "long long int signed void" } */ +long long int signed char *x696; /* { dg-error "" "long long int signed char" } */ +long long int signed short *x697; /* { dg-error "" "long long int signed short" } */ +long long int signed int *x698; /* { dg-error "" "long long int signed int" } */ +long long int signed long *x699; /* { dg-error "" "long long int signed long" } */ +long long int signed float *x700; /* { dg-error "" "long long int signed float" } */ +long long int signed double *x701; /* { dg-error "" "long long int signed double" } */ +long long int signed signed *x702; /* { dg-error "" "long long int signed signed" } */ +long long int signed unsigned *x703; /* { dg-error "" "long long int signed unsigned" } */ +long long int unsigned void *x704; /* { dg-error "" "long long int unsigned void" } */ +long long int unsigned char *x705; /* { dg-error "" "long long int unsigned char" } */ +long long int unsigned short *x706; /* { dg-error "" "long long int unsigned short" } */ +long long int unsigned int *x707; /* { dg-error "" "long long int unsigned int" } */ +long long int unsigned long *x708; /* { dg-error "" "long long int unsigned long" } */ +long long int unsigned float *x709; /* { dg-error "" "long long int unsigned float" } */ +long long int unsigned double *x710; /* { dg-error "" "long long int unsigned double" } */ +long long int unsigned signed *x711; /* { dg-error "" "long long int unsigned signed" } */ +long long int unsigned unsigned *x712; /* { dg-error "" "long long int unsigned unsigned" } */ +long long signed int void *x713; /* { dg-error "" "long long signed int void" } */ +long long signed int char *x714; /* { dg-error "" "long long signed int char" } */ +long long signed int short *x715; /* { dg-error "" "long long signed int short" } */ +long long signed int int *x716; /* { dg-error "" "long long signed int int" } */ +long long signed int long *x717; /* { dg-error "" "long long signed int long" } */ +long long signed int float *x718; /* { dg-error "" "long long signed int float" } */ +long long signed int double *x719; /* { dg-error "" "long long signed int double" } */ +long long signed int signed *x720; /* { dg-error "" "long long signed int signed" } */ +long long signed int unsigned *x721; /* { dg-error "" "long long signed int unsigned" } */ +long long unsigned int void *x722; /* { dg-error "" "long long unsigned int void" } */ +long long unsigned int char *x723; /* { dg-error "" "long long unsigned int char" } */ +long long unsigned int short *x724; /* { dg-error "" "long long unsigned int short" } */ +long long unsigned int int *x725; /* { dg-error "" "long long unsigned int int" } */ +long long unsigned int long *x726; /* { dg-error "" "long long unsigned int long" } */ +long long unsigned int float *x727; /* { dg-error "" "long long unsigned int float" } */ +long long unsigned int double *x728; /* { dg-error "" "long long unsigned int double" } */ +long long unsigned int signed *x729; /* { dg-error "" "long long unsigned int signed" } */ +long long unsigned int unsigned *x730; /* { dg-error "" "long long unsigned int unsigned" } */ +long signed int long void *x731; /* { dg-error "" "long signed int long void" } */ +long signed int long char *x732; /* { dg-error "" "long signed int long char" } */ +long signed int long short *x733; /* { dg-error "" "long signed int long short" } */ +long signed int long int *x734; /* { dg-error "" "long signed int long int" } */ +long signed int long long *x735; /* { dg-error "" "long signed int long long" } */ +long signed int long float *x736; /* { dg-error "" "long signed int long float" } */ +long signed int long double *x737; /* { dg-error "" "long signed int long double" } */ +long signed int long signed *x738; /* { dg-error "" "long signed int long signed" } */ +long signed int long unsigned *x739; /* { dg-error "" "long signed int long unsigned" } */ +long signed long int void *x740; /* { dg-error "" "long signed long int void" } */ +long signed long int char *x741; /* { dg-error "" "long signed long int char" } */ +long signed long int short *x742; /* { dg-error "" "long signed long int short" } */ +long signed long int int *x743; /* { dg-error "" "long signed long int int" } */ +long signed long int long *x744; /* { dg-error "" "long signed long int long" } */ +long signed long int float *x745; /* { dg-error "" "long signed long int float" } */ +long signed long int double *x746; /* { dg-error "" "long signed long int double" } */ +long signed long int signed *x747; /* { dg-error "" "long signed long int signed" } */ +long signed long int unsigned *x748; /* { dg-error "" "long signed long int unsigned" } */ +long unsigned int long void *x749; /* { dg-error "" "long unsigned int long void" } */ +long unsigned int long char *x750; /* { dg-error "" "long unsigned int long char" } */ +long unsigned int long short *x751; /* { dg-error "" "long unsigned int long short" } */ +long unsigned int long int *x752; /* { dg-error "" "long unsigned int long int" } */ +long unsigned int long long *x753; /* { dg-error "" "long unsigned int long long" } */ +long unsigned int long float *x754; /* { dg-error "" "long unsigned int long float" } */ +long unsigned int long double *x755; /* { dg-error "" "long unsigned int long double" } */ +long unsigned int long signed *x756; /* { dg-error "" "long unsigned int long signed" } */ +long unsigned int long unsigned *x757; /* { dg-error "" "long unsigned int long unsigned" } */ +long unsigned long int void *x758; /* { dg-error "" "long unsigned long int void" } */ +long unsigned long int char *x759; /* { dg-error "" "long unsigned long int char" } */ +long unsigned long int short *x760; /* { dg-error "" "long unsigned long int short" } */ +long unsigned long int int *x761; /* { dg-error "" "long unsigned long int int" } */ +long unsigned long int long *x762; /* { dg-error "" "long unsigned long int long" } */ +long unsigned long int float *x763; /* { dg-error "" "long unsigned long int float" } */ +long unsigned long int double *x764; /* { dg-error "" "long unsigned long int double" } */ +long unsigned long int signed *x765; /* { dg-error "" "long unsigned long int signed" } */ +long unsigned long int unsigned *x766; /* { dg-error "" "long unsigned long int unsigned" } */ +signed int long long void *x767; /* { dg-error "" "signed int long long void" } */ +signed int long long char *x768; /* { dg-error "" "signed int long long char" } */ +signed int long long short *x769; /* { dg-error "" "signed int long long short" } */ +signed int long long int *x770; /* { dg-error "" "signed int long long int" } */ +signed int long long long *x771; /* { dg-error "" "signed int long long long" } */ +signed int long long float *x772; /* { dg-error "" "signed int long long float" } */ +signed int long long double *x773; /* { dg-error "" "signed int long long double" } */ +signed int long long signed *x774; /* { dg-error "" "signed int long long signed" } */ +signed int long long unsigned *x775; /* { dg-error "" "signed int long long unsigned" } */ +signed long int long void *x776; /* { dg-error "" "signed long int long void" } */ +signed long int long char *x777; /* { dg-error "" "signed long int long char" } */ +signed long int long short *x778; /* { dg-error "" "signed long int long short" } */ +signed long int long int *x779; /* { dg-error "" "signed long int long int" } */ +signed long int long long *x780; /* { dg-error "" "signed long int long long" } */ +signed long int long float *x781; /* { dg-error "" "signed long int long float" } */ +signed long int long double *x782; /* { dg-error "" "signed long int long double" } */ +signed long int long signed *x783; /* { dg-error "" "signed long int long signed" } */ +signed long int long unsigned *x784; /* { dg-error "" "signed long int long unsigned" } */ +signed long long int void *x785; /* { dg-error "" "signed long long int void" } */ +signed long long int char *x786; /* { dg-error "" "signed long long int char" } */ +signed long long int short *x787; /* { dg-error "" "signed long long int short" } */ +signed long long int int *x788; /* { dg-error "" "signed long long int int" } */ +signed long long int long *x789; /* { dg-error "" "signed long long int long" } */ +signed long long int float *x790; /* { dg-error "" "signed long long int float" } */ +signed long long int double *x791; /* { dg-error "" "signed long long int double" } */ +signed long long int signed *x792; /* { dg-error "" "signed long long int signed" } */ +signed long long int unsigned *x793; /* { dg-error "" "signed long long int unsigned" } */ +unsigned int long long void *x794; /* { dg-error "" "unsigned int long long void" } */ +unsigned int long long char *x795; /* { dg-error "" "unsigned int long long char" } */ +unsigned int long long short *x796; /* { dg-error "" "unsigned int long long short" } */ +unsigned int long long int *x797; /* { dg-error "" "unsigned int long long int" } */ +unsigned int long long long *x798; /* { dg-error "" "unsigned int long long long" } */ +unsigned int long long float *x799; /* { dg-error "" "unsigned int long long float" } */ +unsigned int long long double *x800; /* { dg-error "" "unsigned int long long double" } */ +unsigned int long long signed *x801; /* { dg-error "" "unsigned int long long signed" } */ +unsigned int long long unsigned *x802; /* { dg-error "" "unsigned int long long unsigned" } */ +unsigned long int long void *x803; /* { dg-error "" "unsigned long int long void" } */ +unsigned long int long char *x804; /* { dg-error "" "unsigned long int long char" } */ +unsigned long int long short *x805; /* { dg-error "" "unsigned long int long short" } */ +unsigned long int long int *x806; /* { dg-error "" "unsigned long int long int" } */ +unsigned long int long long *x807; /* { dg-error "" "unsigned long int long long" } */ +unsigned long int long float *x808; /* { dg-error "" "unsigned long int long float" } */ +unsigned long int long double *x809; /* { dg-error "" "unsigned long int long double" } */ +unsigned long int long signed *x810; /* { dg-error "" "unsigned long int long signed" } */ +unsigned long int long unsigned *x811; /* { dg-error "" "unsigned long int long unsigned" } */ +unsigned long long int void *x812; /* { dg-error "" "unsigned long long int void" } */ +unsigned long long int char *x813; /* { dg-error "" "unsigned long long int char" } */ +unsigned long long int short *x814; /* { dg-error "" "unsigned long long int short" } */ +unsigned long long int int *x815; /* { dg-error "" "unsigned long long int int" } */ +unsigned long long int long *x816; /* { dg-error "" "unsigned long long int long" } */ +unsigned long long int float *x817; /* { dg-error "" "unsigned long long int float" } */ +unsigned long long int double *x818; /* { dg-error "" "unsigned long long int double" } */ +unsigned long long int signed *x819; /* { dg-error "" "unsigned long long int signed" } */ +unsigned long long int unsigned *x820; /* { dg-error "" "unsigned long long int unsigned" } */ diff --git a/SingleSource/Regression/C/gcc-dg/long_branch.c b/SingleSource/Regression/C/gcc-dg/long_branch.c new file mode 100644 index 0000000000..c1ac24f511 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/long_branch.c @@ -0,0 +1,200 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-reorder-blocks" } */ +/* { dg-skip-if "limited code space" { pdp11-*-* } } */ +/* { dg-timeout-factor 2.0 { target hppa*-*-* } } */ + +void abort (); + +__attribute__((noinline, noclone)) int +restore (int a, int b) +{ + return a * b; +} + +__attribute__((noinline, noclone)) void +do_nothing (int *input) +{ + *input = restore (*input, 1); + return; +} + +#define CASE_ENTRY(n) \ + case n: \ + sum = sum / (n + 1); \ + sum = restore (sum, n + 1); \ + if (sum == (n + addend)) \ + break;\ + sum = sum / (n + 2); \ + sum = restore (sum, n + 2); \ + sum = sum / (n + 3); \ + sum = restore (sum, n + 3); \ + sum = sum / (n + 4); \ + sum = restore (sum, n + 4); \ + sum = sum / (n + 5); \ + sum = restore (sum, n + 5); \ + sum = sum / (n + 6); \ + sum = restore (sum, n + 6); \ + sum = sum / (n + 7); \ + sum = restore (sum, n + 7); \ + sum = sum / (n + 8); \ + sum = restore (sum, n + 8); \ + sum = sum / (n + 9); \ + sum = restore (sum, n + 9); \ + sum = sum / (n + 10); \ + sum = restore (sum, n + 10); \ + sum = sum / (n + 11); \ + sum = restore (sum, n + 11); \ + sum = sum / (n + 12); \ + sum = restore (sum, n + 12); \ + sum = sum / (n + 13); \ + sum = restore (sum, n + 13); \ + sum = sum / (n + 14); \ + sum = restore (sum, n + 14); \ + sum = sum / (n + 15); \ + sum = restore (sum, n + 15); \ + sum = sum / (n + 16); \ + sum = restore (sum, n + 16); \ + sum = sum / (n + 17); \ + sum = restore (sum, n + 17); \ + sum = sum / (n + 18); \ + sum = restore (sum, n + 18); \ + sum = sum / (n + 19); \ + sum = restore (sum, n + 19); \ + sum = sum / (n + 20); \ + sum = restore (sum, n + 20); \ + sum = sum / (n + 21); \ + sum = restore (sum, n + 21); \ + sum = sum / (n + 22); \ + sum = restore (sum, n + 22); \ + sum = sum / (n + 23); \ + sum = restore (sum, n + 23); \ + sum = sum / (n + 24); \ + sum = restore (sum, n + 24); \ + sum = sum / (n + 25); \ + sum = restore (sum, n + 25); \ + sum = sum / (n + 26); \ + sum = restore (sum, n + 26); \ + sum = sum / (n + 27); \ + sum = restore (sum, n + 27); \ + sum = sum / (n + 28); \ + sum = restore (sum, n + 28); \ + sum = sum / (n + 29); \ + sum = restore (sum, n + 29); \ + sum = sum / (n + 30); \ + sum = restore (sum, n + 30); \ + sum = sum / (n + 31); \ + sum = restore (sum, n + 31); \ + sum = sum / (n + 32); \ + sum = restore (sum, n + 32); \ + sum = sum / (n + 33); \ + sum = restore (sum, n + 33); \ + sum = sum / (n + 34); \ + sum = restore (sum, n + 34); \ + sum = sum / (n + 35); \ + sum = restore (sum, n + 35); \ + sum = sum / (n + 36); \ + sum = restore (sum, n + 36); \ + break; + +__attribute__((noinline, noclone)) long long +test_and_branch (int selector, int addend) +{ + long long sum = selector + 1; + + if (selector > 64) + { +start: + return sum - 1; + } + else + { + switch (selector) + { + CASE_ENTRY (1) + CASE_ENTRY (2) + CASE_ENTRY (3) + CASE_ENTRY (4) + CASE_ENTRY (5) + CASE_ENTRY (6) + CASE_ENTRY (7) + CASE_ENTRY (8) + CASE_ENTRY (9) + CASE_ENTRY (10) + CASE_ENTRY (11) + CASE_ENTRY (12) + CASE_ENTRY (13) + CASE_ENTRY (14) + CASE_ENTRY (15) + CASE_ENTRY (16) + CASE_ENTRY (17) + CASE_ENTRY (18) + CASE_ENTRY (19) + CASE_ENTRY (20) + CASE_ENTRY (21) + CASE_ENTRY (22) + CASE_ENTRY (23) + CASE_ENTRY (24) + CASE_ENTRY (25) + CASE_ENTRY (26) + CASE_ENTRY (27) + CASE_ENTRY (28) + CASE_ENTRY (29) + CASE_ENTRY (30) + CASE_ENTRY (31) + CASE_ENTRY (32) + CASE_ENTRY (33) + CASE_ENTRY (34) + CASE_ENTRY (35) + CASE_ENTRY (36) + CASE_ENTRY (37) + CASE_ENTRY (38) + CASE_ENTRY (39) + CASE_ENTRY (40) + CASE_ENTRY (41) + CASE_ENTRY (42) + CASE_ENTRY (43) + CASE_ENTRY (44) + CASE_ENTRY (45) + CASE_ENTRY (46) + CASE_ENTRY (47) + CASE_ENTRY (48) + CASE_ENTRY (49) + CASE_ENTRY (50) + CASE_ENTRY (51) + CASE_ENTRY (52) + CASE_ENTRY (53) + CASE_ENTRY (54) + CASE_ENTRY (55) + CASE_ENTRY (56) + CASE_ENTRY (57) + CASE_ENTRY (58) + CASE_ENTRY (59) + CASE_ENTRY (60) + CASE_ENTRY (61) + CASE_ENTRY (62) + CASE_ENTRY (63) + CASE_ENTRY (64) + } + + do_nothing ((int *)&sum); + + if (sum & 0x40) + goto start; + } + + return -1; +} + +int +main (int argc, char **argv) +{ + long long ret = test_and_branch (64, 1); + if (ret != 64) + abort (); + + ret = test_and_branch (7, 1); + if (ret != -1) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/loop-1.c b/SingleSource/Regression/C/gcc-dg/loop-1.c new file mode 100644 index 0000000000..a2c7fe6420 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-1.c @@ -0,0 +1,20 @@ +/* Copyright (C) 2000 Free Software Foundation. + + Simplified from gcc/fold-const.c + by Alexandre Oliva */ + +/* { dg-do compile } */ + +void +mul_double () +{ + int i, j, *prod; + + for (i = 0; i < 4; i++) + { + for (j = 0; j < 4; j++) + { + *prod = 0; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/loop-2.c b/SingleSource/Regression/C/gcc-dg/loop-2.c new file mode 100644 index 0000000000..fa96f89278 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-2.c @@ -0,0 +1,23 @@ +/* PR optimization/10171 */ +/* Bug: unroll_loop misoptimized the function so that we got + 0 iterations of the loop rather than the correct 1. */ +/* { dg-do run } */ + +extern void abort (void); +extern void exit (int); + +__inline__ int tag() { return 0; } + +void f (); + +int main() { + int i; + for (i = 0; i < (tag() ? 2 : 1); i++) + f(); + abort (); +} + +void f () +{ + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/loop-3.c b/SingleSource/Regression/C/gcc-dg/loop-3.c new file mode 100644 index 0000000000..7472ea1dfc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-3.c @@ -0,0 +1,46 @@ +/* PR optimization/13985 */ +/* Copied from gcc.c-torture/compile/930621-1.c */ + +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-options "-O3 -mtune=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-add-options stack_size } */ + +#if defined(STACK_SIZE) && (STACK_SIZE < 65536) +# define BYTEMEM_SIZE 10000L +#endif + +#ifndef BYTEMEM_SIZE +# define BYTEMEM_SIZE 45000L +#endif + +int bytestart[5000 + 1]; +unsigned char modtext[400 + 1]; +unsigned char bytemem[2][BYTEMEM_SIZE + 1]; + +long +modlookup (int l) +{ + signed char c; + long j; + long k; + signed char w; + long p; + while (p != 0) + { + while ((k < bytestart[p + 2]) && (j <= l) && (modtext[j] == bytemem[w][k])) + { + k = k + 1; + j = j + 1; + } + if (k == bytestart[p + 2]) + if (j > l) + c = 1; + else c = 4; + else if (j > l) + c = 3; + else if (modtext[j] < bytemem[w][k]) + c = 0; + else c = 2; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/loop-4.c b/SingleSource/Regression/C/gcc-dg/loop-4.c new file mode 100644 index 0000000000..c83fd1c0fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-4.c @@ -0,0 +1,25 @@ +/* PR optimization/11841 */ +/* Originator: Andrey Panov */ +/* Reduced testcase by Volker Reichelt */ + +/* Verify that the (old) loop unroller doesn't wrongly mark a pseudo + referenced in a note as local. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-loops" } */ + +int *a; + +int main() +{ + double d[6]; + int i, j; + + for (i=0; i<4; ++i) + for (j=0; j<3; ++j) + d[i+j] = 0; + + a = &i; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/loop-5.c b/SingleSource/Regression/C/gcc-dg/loop-5.c new file mode 100644 index 0000000000..198823b196 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-5.c @@ -0,0 +1,16 @@ +/* PR c/16180 */ +/* { dg-options "-O2" } */ + +extern int b; +int foo (int a) +{ + if (a) + { + b = 0; + for(;;) + goto L; + } + L: + for(;;) + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/loop-6.c b/SingleSource/Regression/C/gcc-dg/loop-6.c new file mode 100644 index 0000000000..653854eb8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-6.c @@ -0,0 +1,25 @@ +/* PR optimization/18577 */ +/* Origin: Falk Hueffner */ + +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-all-loops" } */ + +static float tfcos12[3]; +__attribute__((noinline)) double f(double x) { return x; } +int g; + +int main(void) +{ + int i, j; + for (i = 0; i < 1; i++) + tfcos12[i] = 0.5; + + for (i = 0; i < 1; i++) + { + tfcos12[i] = 0.5 * f(i); + for (j = 0; j < 12; j++) + g++; + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/loop-7.c b/SingleSource/Regression/C/gcc-dg/loop-7.c new file mode 100644 index 0000000000..9f7196f49a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-7.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/31360 */ + +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-options "-O1 -fdump-rtl-loop2_invariant" } */ + +void f(int *a) +{ + int i; + for (i = 0;i<100;i++) + a[i] = 0; +} + +/* Load of 0 is moved out of the loop. */ +/* { dg-final { scan-rtl-dump-times "Decided" 1 "loop2_invariant" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/loop-8.c b/SingleSource/Regression/C/gcc-dg/loop-8.c new file mode 100644 index 0000000000..8e5f208783 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-8.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-rtl-loop2_invariant" } */ +/* { dg-skip-if "unexpected IV" { "hppa*-*-* mips*-*-* visium-*-* powerpc*-*-* riscv*-*-* mmix-*-* vax-*-* loongarch*-*-*" } } */ +/* Load immediate on condition is available from z13 on and prevents moving + the load out of the loop, so always run this test with -march=zEC12 that + does not have load immediate on condition. */ +/* { dg-additional-options "-march=zEC12" { target { s390*-*-* } } } */ + +void +f (int *a, int *b) +{ + int i; + + i = 100; + if (i > 0) + { + do + { + int d = 42; + + a[i] = d; + if (i % 2) + d = i; + b[i] = d; + ++i; + } + while (i < 100); + } +} + +/* Load of 42 is moved out of the loop, introducing a new pseudo register. */ +/* { dg-final { scan-rtl-dump-not "without introducing a new temporary register" "loop2_invariant" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/loop-9.c b/SingleSource/Regression/C/gcc-dg/loop-9.c new file mode 100644 index 0000000000..44f720653f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-9.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-rtl-loop2_invariant" } */ +/* { dg-additional-options "-fno-pie" { target pie } } */ + +void +f (double *a) +{ + int i; + for (i = 0; i < 100; i++) + a[i] = 18.4242; +} + +/* Load of x is moved out of the loop. */ +/* { dg-final { scan-rtl-dump "Decided" "loop2_invariant" } } */ +/* { dg-final { scan-rtl-dump "without introducing a new temporary register" "loop2_invariant" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/loop-invariant-2.c b/SingleSource/Regression/C/gcc-dg/loop-invariant-2.c new file mode 100644 index 0000000000..df3d845856 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-invariant-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-loop2_invariant" } */ + +volatile int x; +void +bar (int, char *, char *); +void +foo (int *a, int n, int k) +{ + int i; + + for (i = 0; i < n; i++) + { + if (__builtin_expect (x, 0)) + bar (k / 5, "one", "two"); + a[i] = k; + } +} + +/* { dg-final { scan-rtl-dump "Don't move invariant from bb: .*out of loop" "loop2_invariant" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-invariant.c b/SingleSource/Regression/C/gcc-dg/loop-invariant.c new file mode 100644 index 0000000000..702050b5c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-invariant.c @@ -0,0 +1,42 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fdump-rtl-loop2_invariant" } */ +/* NOTE: The target list above could be extended to other targets that have + conditional moves, but don't have zero registers. */ + +enum test_type +{ + TYPE0, + TYPE1 +}; + +struct type_node +{ + enum test_type type; +}; + +struct test_ref +{ + struct type_node *referring; +}; + +struct test_node +{ + struct test_node *next; +}; + +int iterate (struct test_node *, unsigned, struct test_ref **); + +int +loop_invar (struct test_node *node) +{ + struct test_ref *ref; + + for (unsigned i = 0; iterate (node, i, &ref); i++) + if (loop_invar ((ref->referring && ref->referring->type == TYPE0) + ? ((struct test_node *) (ref->referring)) : 0)) + return 1; + + return 0; +} + +/* { dg-final { scan-rtl-dump "Decided to move invariant" "loop2_invariant" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-split.c b/SingleSource/Regression/C/gcc-dg/loop-split.c new file mode 100644 index 0000000000..81fdb700f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-split.c @@ -0,0 +1,148 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fsplit-loops -fdump-tree-lsplit-details" } */ +/* { dg-require-effective-target int32plus } */ + +#ifdef __cplusplus +extern "C" int printf (const char *, ...); +extern "C" void abort (void); +#else +extern int printf (const char *, ...); +extern void abort (void); +#endif + +/* Define TRACE to 1 or 2 to get detailed tracing. + Define SINGLE_TEST to 1 or 2 to get a simple routine with + just one loop, called only one time or with multiple parameters, + to make debugging easier. */ +#ifndef TRACE +#define TRACE 0 +#endif + +#define loop(beg,step,beg2,cond1,cond2) \ + do \ + { \ + sum = 0; \ + for (i = (beg), j = (beg2); (cond1); i+=(step),j+=(step)) \ + { \ + if (cond2) { \ + if (TRACE > 1) printf ("a: %d %d\n", i, j); \ + sum += a[i]; \ + } else { \ + if (TRACE > 1) printf ("b: %d %d\n", i, j); \ + sum += b[i]; \ + } \ + } \ + if (TRACE > 0) printf ("sum: %d\n", sum); \ + check = check * 47 + sum; \ + } while (0) + +#ifndef SINGLE_TEST +unsigned __attribute__((noinline, noclone)) dotest (int beg, int end, int step, + int c, int *a, int *b, int beg2) +{ + unsigned check = 0; + int sum; + int i, j; + loop (beg, 1, beg2, i < end, j < c); + loop (beg, 1, beg2, i <= end, j < c); + loop (beg, 1, beg2, i < end, j <= c); + loop (beg, 1, beg2, i <= end, j <= c); + loop (beg, 1, beg2, i < end, j > c); + loop (beg, 1, beg2, i <= end, j > c); + loop (beg, 1, beg2, i < end, j >= c); + loop (beg, 1, beg2, i <= end, j >= c); + beg2 += end-beg; + loop (end, -1, beg2, i >= beg, j >= c); + loop (end, -1, beg2, i >= beg, j > c); + loop (end, -1, beg2, i > beg, j >= c); + loop (end, -1, beg2, i > beg, j > c); + loop (end, -1, beg2, i >= beg, j <= c); + loop (end, -1, beg2, i >= beg, j < c); + loop (end, -1, beg2, i > beg, j <= c); + loop (end, -1, beg2, i > beg, j < c); + return check; +} + +#else + +int __attribute__((noinline, noclone)) f (int beg, int end, int step, + int c, int *a, int *b, int beg2) +{ + int sum = 0; + int i, j; + //for (i = beg, j = beg2; i < end; i += 1, j++ /*step*/) + for (i = end, j = beg2 + (end-beg); i > beg; i += -1, j-- /*step*/) + { + // i - j == X --> i = X + j + // --> i < end == X+j < end == j < end - X + // --> newend = end - (i_init - j_init) + // j < end-X && j < c --> j < min(end-X,c) + // j < end-X && j <= c --> j <= min(end-X-1,c) or j < min(end-X,c+1{OF!}) + //if (j < c) + if (j >= c) + printf ("a: %d %d\n", i, j); + /*else + printf ("b: %d %d\n", i, j);*/ + /*sum += a[i]; + else + sum += b[i];*/ + } + return sum; +} + +int __attribute__((noinline, noclone)) f2 (int *beg, int *end, int step, + int *c, int *a, int *b, int *beg2) +{ + int sum = 0; + int *i, *j; + for (i = beg, j = beg2; i < end; i += 1, j++ /*step*/) + { + if (j <= c) + printf ("%d %d\n", i - beg, j - beg); + /*sum += a[i]; + else + sum += b[i];*/ + } + return sum; +} +#endif + +extern int printf (const char *, ...); + +int main () +{ + int a[] = {0,0,0,0,0, 1,2,3,4,5,6,7,8,9, 0,0,0,0,0}; + int b[] = {0,0,0,0,0, -1,-2,-3,-4,-5,-6,-7,-8,-9, 0,0,0,0,0,}; + int c; + int diff = 0; + unsigned check = 0; +#if defined(SINGLE_TEST) && (SINGLE_TEST == 1) + //dotest (0, 9, 1, -1, a+5, b+5, -1); + //return 0; + f (0, 9, 1, 5, a+5, b+5, -1); + return 0; +#endif + for (diff = -5; diff <= 5; diff++) + { + for (c = -1; c <= 10; c++) + { +#ifdef SINGLE_TEST + int s = f (0, 9, 1, c, a+5, b+5, diff); + //int s = f2 (a+0, a+9, 1, a+c, a+5, b+5, a+diff); + printf ("%d ", s); +#else + if (TRACE > 0) + printf ("check %d %d\n", c, diff); + check = check * 51 + dotest (0, 9, 1, c, a+5, b+5, diff); +#endif + } + //printf ("\n"); + } + //printf ("%u\n", check); + if (check != 3213344948) + abort (); + return 0; +} + +/* All 16 loops in dotest should be split. */ +/* { dg-final { scan-tree-dump-times "Loop split" 16 "lsplit" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-1.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-1.c new file mode 100644 index 0000000000..196cb64735 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-1.c @@ -0,0 +1,36 @@ +/* For PR rtl-optimization/27735 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-all -fno-finite-loops" } */ + +void set_color(void); +void xml_colorize_line(unsigned int *p, int state) +{ + int c; + switch(state) + { + case 1: + goto parse_tag; + case 2: + goto parse_comment; + } + + for(;;) + { + c = *p; + if (c == '<' && state == 0) + { +parse_comment: ; + while (*p != '\n') + state = 3; +parse_tag: ; + while (*p != '\n') + state = 0; + set_color(); + } + else + p++; + } +} + +/* Test that we actually unswitched something. */ +/* { dg-final { scan-tree-dump "unswitching loop" "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-10.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-10.c new file mode 100644 index 0000000000..395167ee6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-10.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized" } */ + +int +__attribute__((noipa)) +foo(double *a, double *b, double *c, double *d, double *r, int size, int order) +{ + for (int i = 0; i < size; i++) + { + double tmp, tmp2; + + switch(order) + { + case 0: + tmp = -8 * a[i]; + tmp2 = 2 * b[i]; + break; + case 1: + tmp = 3 * a[i] - 2 * b[i]; + tmp2 = 5 * b[i] - 2 * c[i]; + break; + case 2: + tmp = 9 * a[i] + 2 * b[i] + c[i]; + tmp2 = 4 * b[i] + 2 * c[i] + 8 * d[i]; + break; + case 3: + tmp = 3 * a[i] + 2 * b[i] - c[i]; + tmp2 = b[i] - 2 * c[i] + 8 * d[i]; + break; + default: + __builtin_unreachable (); + } + + double x = 3 * tmp + d[i] + tmp; + double y = 3.4f * tmp + d[i] + tmp2; + r[i] = x + y; + } + + return 0; +} + +#define N 16 * 1024 +double aa[N], bb[N], cc[N], dd[N], rr[N]; + +int main() +{ + for (int i = 0; i < 100 * 1000; i++) + foo (aa, bb, cc, dd, rr, N, i % 4); +} + + +/* Test that we actually unswitched something. */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 0" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 1" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 2" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 3" 1 "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-11.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-11.c new file mode 100644 index 0000000000..422a94227b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-11.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized" } */ + +int +foo(double *a, double *b, double *c, double *d, double *r, int size, int order) +{ + for (int i = 0; i < size; i++) + { + double tmp, tmp2; + + switch(order) + { + case 5 ... 6: + case 9: + tmp = -8 * a[i]; + tmp2 = 2 * b[i]; + break; + case 11: + tmp = 3 * a[i] - 2 * b[i]; + tmp2 = 5 * b[i] - 2 * c[i]; + break; + case 22: + tmp = 9 * a[i] + 2 * b[i] + c[i]; + tmp2 = 4 * b[i] + 2 * c[i] + 8 * d[i]; + break; + case 33: + tmp = 3 * a[i] + 2 * b[i] - c[i]; + tmp2 = b[i] - 2 * c[i] + 8 * d[i]; + break; + default: + __builtin_unreachable (); + } + + double x = 3 * tmp + d[i] + tmp; + double y = 3.4f * tmp + d[i] + tmp2; + r[i] = x + y; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* \\+ 4294967291.*order.* == 9" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 1" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 2" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 3" 1 "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-12.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-12.c new file mode 100644 index 0000000000..052c456846 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-12.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized" } */ + +int +foo(double *a, double *b, double *c, double *d, double *r, int size, int order) +{ + for (int i = 0; i < size; i++) + { + double tmp; + + if (order == 1) + tmp = -8 * a[i]; + else + tmp = -4 * b[i]; + + double x = 3 * tmp + d[i] + tmp; + + if (order == 1) + x += 2; + + double y = 3.4f * tmp + d[i]; + r[i] = x + y; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "unswitching loop . on .if. with condition: order.* == 1" 1 "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-13.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-13.c new file mode 100644 index 0000000000..d09c4aabc4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-13.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fno-thread-jumps -fdump-tree-unswitch-optimized" } */ + +int +foo(double *a, double *b, double *c, double *d, double *r, int size, unsigned order) +{ + for (int i = 0; i < size; i++) + { + double tmp; + + switch (order) + { + case 0 ... 4: + tmp = -8 * a[i]; + break; + default: + tmp = -4 * b[i]; + break; + } + + double x = 3 * tmp + d[i] + tmp; + + /* This and the case 0 ... 4 condition should only be unswitched once + since they are mutually excluded. */ + if (order >= 5) + x += 2; + + double y = 3.4f * tmp + d[i]; + r[i] = x + y; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "unswitching loop . on .\[^\n\r\]*. with condition" 1 "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-14.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-14.c new file mode 100644 index 0000000000..d9d31680cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-14.c @@ -0,0 +1,60 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized --param=max-unswitch-insns=1000" } */ + +int +__attribute__((noipa)) +foo(double *a, double *b, double *c, double *d, double *r, int size, int order) +{ + for (int i = 0; i < size; i++) + { + double tmp, tmp2; + + if (order <= 0) + tmp = 123; + + switch(order) + { + case 0: + tmp += -8 * a[i]; + tmp2 = 2 * b[i]; + break; + case 1: + tmp = 3 * a[i] - 2 * b[i]; + tmp2 = 5 * b[i] - 2 * c[i]; + break; + case 2: + tmp = 9 * a[i] + 2 * b[i] + c[i]; + tmp2 = 4 * b[i] + 2 * c[i] + 8 * d[i]; + break; + case 3: + tmp = 3 * a[i] + 2 * b[i] - c[i]; + tmp2 = b[i] - 2 * c[i] + 8 * d[i]; + break; + default: + __builtin_unreachable (); + } + + double x = 3 * tmp + d[i] + tmp; + double y = 3.4f * tmp + d[i] + tmp2; + r[i] = x + y; + } + + return 0; +} + +#define N 16 * 1024 +double aa[N], bb[N], cc[N], dd[N], rr[N]; + +int main() +{ + for (int i = 0; i < 100 * 1000; i++) + foo (aa, bb, cc, dd, rr, N, i % 4); +} + + +/* Test that we actually unswitched something. */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* <= 0" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 0" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 1" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 2" 1 "unswitch" } } */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .switch. with condition: order.* == 3" 1 "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-15.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-15.c new file mode 100644 index 0000000000..87139bb333 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-15.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized" } */ + +void bar(); +void baz(); +void foo (int a, int b, int n) +{ + for (int i = 0; i < n; ++i) + if (a < b) + bar (); + else + baz (); +} + +/* { dg-final { scan-tree-dump "unswitching loop . on .if. with condition:" "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-16.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-16.c new file mode 100644 index 0000000000..4b0b40015a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-16.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized --param max-unswitch-insns=100" } */ + +void bar (int); +void foo (int a, int b, int c, int n) +{ + for (int i = 0; i < n; ++i) + { + if (a > 5) + bar (1); + if (b < 10) + bar (2); + if (c != 5) + bar (3); + } +} + +/* Verify we can unswitch all permutations of the predicates. */ +/* { dg-final { scan-tree-dump-times "unswitching loop . on .if. with condition" 7 "unswitch" } } */ +/* { dg-final { scan-tree-dump "unswitching loop . on .if. with condition: a" "unswitch" } } */ +/* { dg-final { scan-tree-dump "unswitching loop . on .if. with condition: b" "unswitch" } } */ +/* { dg-final { scan-tree-dump "unswitching loop . on .if. with condition: c" "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-17.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-17.c new file mode 100644 index 0000000000..4b806c475b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-17.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized -fno-tree-ch" } */ + +int foo (int a) +{ + do + { + if (a == 1) + return 0; + switch (a) + { + case 1: + return 5; + case 2: + return 7; + case 3: + return 11; + default:; + } + } + while (1); +} + +/* { dg-final { scan-tree-dump-times "unswitching loop" 3 "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-18.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-18.c new file mode 100644 index 0000000000..91dc201492 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-18.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-unswitch-optimized" } */ + +void bar(); +void foo (int x, int n, int m) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < m; ++j) + if (x) + bar (); +} + +/* { dg-final { scan-tree-dump "unswitching outer loop" "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-2.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-2.c new file mode 100644 index 0000000000..e92ae55351 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-all -fno-thread-jumps" } */ + +void foo (float **a, float **b, float *c, int n, int m, int l) +{ + int i,j,k; + float s; + for (i=0; i +#define N 32 +float *foo(int ustride, int size, float *src) +{ + float *buffer, *p; + int i, k; + + if (!src) + return NULL; + + buffer = (float *) malloc(N * size * sizeof(float)); + + if(buffer) + for(i=0, p=buffer; i +__attribute__ ((noinline)) +void foo (float **a, float **b, float *c, int n, int m, int l) +{ + int i,j,k; + float s; + for (i=0; i order) + x += 2; + + if (order == 12345) + x *= 5; + + double y = 3.4f * tmp + d[i]; + r[i] = x + y; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "unswitching loop . on .if. with condition: order" 3 "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-unswitch-9.c b/SingleSource/Regression/C/gcc-dg/loop-unswitch-9.c new file mode 100644 index 0000000000..5e50b078bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-unswitch-9.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-optimized" } */ + +int +foo(double *a, double *b, double *c, double *d, double *r, int size, int order) +{ + for (int i = 0; i < size; i++) + { + double tmp; + + if (order == 1) + tmp = -8 * a[i]; + else + { + if (order == 2) + tmp = -4 * b[i]; + else + tmp = a[i]; + } + + r[i] = 3.4f * tmp + d[i]; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "unswitching loop . on .if. with condition: order" 2 "unswitch" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-1.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-1.c new file mode 100644 index 0000000000..2f2c1eeee7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-1.c @@ -0,0 +1,97 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ +/* { dg-require-effective-target size32plus } */ + +/* The simplest IV case. */ + +void +f1 (double *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + x[stepx * i] = 100; +} + +void +f2 (double *x, int stepx, int limit) +{ + for (int i = 0; i < limit; i += stepx) + x[i] = 100; +} + +void +f3 (double *x, int stepx, int limit) +{ + for (double *y = x; y < x + limit; y += stepx) + *y = 100; +} + +void +f4 (double *x, int stepx, unsigned int n) +{ + for (unsigned int i = 0; i < n; ++i) + x[stepx * i] = 100; +} + +void +f5 (double *x, int stepx, unsigned int limit) +{ + for (unsigned int i = 0; i < limit; i += stepx) + x[i] = 100; +} + +void +f6 (double *x, int stepx, unsigned int limit) +{ + for (double *y = x; y < x + limit; y += stepx) + *y = 100; +} + +#if __SIZEOF_SIZE_T__ < 4 +double x[1000]; +#else +double x[10000]; +#endif + +void +g1 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + x[stepx * i] = 100; +} + +void +g2 (int stepx, int limit) +{ + for (int i = 0; i < limit; i += stepx) + x[i] = 100; +} + +void +g3 (int stepx, int limit) +{ + for (double *y = x; y < x + limit; y += stepx) + *y = 100; +} + +void +g4 (int stepx, unsigned int n) +{ + for (unsigned int i = 0; i < n; ++i) + x[stepx * i] = 100; +} + +void +g5 (int stepx, unsigned int limit) +{ + for (unsigned int i = 0; i < limit; i += stepx) + x[i] = 100; +} + +void +g6 (int stepx, unsigned int limit) +{ + for (double *y = x; y < x + limit; y += stepx) + *y = 100; +} + +/* { dg-final { scan-tree-dump-times {want to version containing loop} 12 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {versioned this loop} 12 "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-10.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-10.c new file mode 100644 index 0000000000..f634448c25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-10.c @@ -0,0 +1,52 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Test that we can version a gather-like operation in which a variable + stride is applied to the index. */ + +int +f1 (int *x, int *index, int step, int n) +{ + int res = 0; + for (int i = 0; i < n; ++i) + res += x[index[i] * step]; + return res; +} + +int +f2 (int *x, int *index, int step, int n) +{ + int res = 0; + for (int i = 0; i < n; ++i) + { + int *ptr = x + index[i] * step; + res += *ptr; + } + return res; +} + +int x[1000]; + +int +g1 (int *index, int step, int n) +{ + int res = 0; + for (int i = 0; i < n; ++i) + res += x[index[i] * step]; + return res; +} + +int +g2 (int *index, int step, int n) +{ + int res = 0; + for (int i = 0; i < n; ++i) + { + int *ptr = x + index[i] * step; + res += *ptr; + } + return res; +} + +/* { dg-final { scan-tree-dump-times {address term [^\n]* \* loop-invariant} 4 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {want to version containing loop} 4 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {versioned this loop} 4 "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-11.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-11.c new file mode 100644 index 0000000000..77ff484a4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-11.c @@ -0,0 +1,29 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Test that we don't try to version for something that is never 1. */ + +void +f1 (double *x, int stepx, int n) +{ + if (stepx == 1) + for (int i = 0; i < n; ++i) + x[i] = 100; + else + for (int i = 0; i < n; ++i) + x[stepx * i] = 100; +} + +void +f2 (double *x, int stepx, int n) +{ + if (stepx <= 1) + for (int i = 0; i < n; ++i) + x[i] = 100; + else + for (int i = 0; i < n; ++i) + x[stepx * i] = 100; +} + +/* { dg-final { scan-tree-dump-times {want to version containing loop} 2 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {can never be 1} 2 "lversion" } } */ +/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-12.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-12.c new file mode 100644 index 0000000000..560acc4d80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-12.c @@ -0,0 +1,149 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Test that we don't try to version for a step of 1 when that would + cause the iterations to overlap. */ + +void +f1 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx] = 100; + x[i * stepx + 1] = 99; + } +} + +void +f2 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; i += stepx) + { + x[i] = 100; + x[i + 1] = 99; + } +} + +void +f3 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx - 16] = 100; + x[i * stepx - 15] = 99; + } +} + +void +f4 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; i += stepx) + { + x[i - 16] = 100; + x[i - 15] = 99; + } +} + +void +f5 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx - 16] = 100; + x[i * stepx + 15] = 99; + } +} + +void +f6 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; i += stepx) + { + x[i - 16] = 100; + x[i + 15] = 99; + } +} + +void +f7 (unsigned short *x, int stepx, int n) +{ + for (unsigned short *y = x; y < x + n; y += stepx) + { + y[0] = 100; + y[1] = 99; + } +} + +unsigned short x[1000]; + +void +g1 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx] = 100; + x[i * stepx + 1] = 99; + } +} + +void +g2 (int stepx, int n) +{ + for (int i = 0; i < n; i += stepx) + { + x[i] = 100; + x[i + 1] = 99; + } +} + +void +g3 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx - 16] = 100; + x[i * stepx - 15] = 99; + } +} + +void +g4 (int stepx, int n) +{ + for (int i = 0; i < n; i += stepx) + { + x[i - 16] = 100; + x[i - 15] = 99; + } +} + +void +g5 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx - 16] = 100; + x[i * stepx + 15] = 99; + } +} + +void +g6 (int stepx, int n) +{ + for (int i = 0; i < n; i += stepx) + { + x[i - 16] = 100; + x[i + 15] = 99; + } +} + +void +g7 (int stepx, int n) +{ + for (unsigned short *y = x; y < x + n; y += stepx) + { + y[0] = 100; + y[1] = 99; + } +} + +/* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */ +/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-13.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-13.c new file mode 100644 index 0000000000..c67da047fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-13.c @@ -0,0 +1,109 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Test that we do version for a step of 1 when that would lead the + iterations to access consecutive groups. */ + +void +f1 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 2] = 100; + x[i * stepx * 2 + 1] = 99; + } +} + +void +f2 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 2) + { + x[i] = 100; + x[i + 1] = 99; + } +} + +void +f3 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 2 - 16] = 100; + x[i * stepx * 2 - 15] = 99; + } +} + +void +f4 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 2) + { + x[i - 16] = 100; + x[i - 15] = 99; + } +} + +void +f5 (unsigned short *x, int stepx, int n) +{ + for (unsigned short *y = x; y < x + n; y += stepx * 2) + { + y[0] = 100; + y[1] = 99; + } +} + +unsigned short x[1000]; + +void +g1 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 2] = 100; + x[i * stepx * 2 + 1] = 99; + } +} + +void +g2 (int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 2) + { + x[i] = 100; + x[i + 1] = 99; + } +} + +void +g3 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 2 - 16] = 100; + x[i * stepx * 2 - 15] = 99; + } +} + +void +g4 (int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 2) + { + x[i - 16] = 100; + x[i - 15] = 99; + } +} + +void +g5 (int stepx, int n) +{ + for (unsigned short *y = x; y < x + n; y += stepx * 2) + { + y[0] = 100; + y[1] = 99; + } +} + +/* { dg-final { scan-tree-dump-times {want to version containing loop} 10 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {versioned this loop} 10 "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-14.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-14.c new file mode 100644 index 0000000000..f2926e5650 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-14.c @@ -0,0 +1,149 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Test that we don't try to version for a step of 1 when that would + cause the iterations to leave a gap between accesses. */ + +void +f1 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 4] = 100; + x[i * stepx * 4 + 1] = 99; + } +} + +void +f2 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 4) + { + x[i] = 100; + x[i + 1] = 99; + } +} + +void +f3 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 4 - 16] = 100; + x[i * stepx * 4 - 15] = 99; + } +} + +void +f4 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 4) + { + x[i - 16] = 100; + x[i - 15] = 99; + } +} + +void +f5 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 64 - 16] = 100; + x[i * stepx * 64 + 15] = 99; + } +} + +void +f6 (unsigned short *x, int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 64) + { + x[i - 16] = 100; + x[i + 15] = 99; + } +} + +void +f7 (unsigned short *x, int stepx, int n) +{ + for (unsigned short *y = x; y < x + n; y += stepx * 4) + { + y[0] = 100; + y[1] = 99; + } +} + +unsigned short x[1000]; + +void +g1 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 4] = 100; + x[i * stepx * 4 + 1] = 99; + } +} + +void +g2 (int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 4) + { + x[i] = 100; + x[i + 1] = 99; + } +} + +void +g3 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 4 - 16] = 100; + x[i * stepx * 4 - 15] = 99; + } +} + +void +g4 (int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 4) + { + x[i - 16] = 100; + x[i - 15] = 99; + } +} + +void +g5 (int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[i * stepx * 64 - 16] = 100; + x[i * stepx * 64 + 15] = 99; + } +} + +void +g6 (int stepx, int n) +{ + for (int i = 0; i < n; i += stepx * 64) + { + x[i - 16] = 100; + x[i + 15] = 99; + } +} + +void +g7 (int stepx, int n) +{ + for (unsigned short *y = x; y < x + n; y += stepx * 4) + { + y[0] = 100; + y[1] = 99; + } +} + +/* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */ +/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-2.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-2.c new file mode 100644 index 0000000000..d9a1a99aea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-2.c @@ -0,0 +1,74 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ +/* { dg-require-effective-target size20plus } */ + +/* Versioning for step == 1 in these loops would allow loop interchange, + but otherwise isn't worthwhile. At the moment we decide not to version. */ + +void +f1 (double x[][100], int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j * step][i] = 100; +} + +void +f2 (double x[][100], int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j][i * step] = 100; +} + +void +f3 (double x[][100], int step, int limit) +{ + for (int i = 0; i < 100; ++i) + for (int j = 0; j < limit; j += step) + x[j][i] = 100; +} + +void +f4 (double x[][100], int step, int limit) +{ + for (int i = 0; i < limit; i += step) + for (int j = 0; j < 100; ++j) + x[j][i] = 100; +} + +double x[100][100]; + +void +g1 (int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j * step][i] = 100; +} + +void +g2 (int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j][i * step] = 100; +} + +void +g3 (int step, int limit) +{ + for (int i = 0; i < 100; ++i) + for (int j = 0; j < limit; j += step) + x[j][i] = 100; +} + +void +g4 (int step, int limit) +{ + for (int i = 0; i < limit; i += step) + for (int j = 0; j < 100; ++j) + x[j][i] = 100; +} + +/* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */ +/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-3.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-3.c new file mode 100644 index 0000000000..6565122cb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-3.c @@ -0,0 +1,24 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Versioning these loops for when both steps are 1 allows loop + interchange, but otherwise isn't worthwhile. At the moment we decide + not to version. */ + +void +f1 (double x[][100], int step1, int step2, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j * step1][i * step2] = 100; +} + +void +f2 (double x[][100], int step1, int step2, int limit) +{ + for (int i = 0; i < limit; i += step1) + for (int j = 0; j < limit; j += step2) + x[j][i] = 100; +} + +/* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */ +/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-4.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-4.c new file mode 100644 index 0000000000..0ebb2b0e86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-4.c @@ -0,0 +1,39 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* These shouldn't be versioned; it's extremely likely that the code + is emulating two-dimensional arrays. */ + +void +f1 (double *x, int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[i * step + j] = 100; +} + +void +f2 (double *x, int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j * step + i] = 100; +} + +void +f3 (double *x, int *offsets, int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[i * step + j + offsets[i]] = 100; +} + +void +f4 (double *x, int *offsets, int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j * step + i + offsets[i]] = 100; +} + +/* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */ +/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-5.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-5.c new file mode 100644 index 0000000000..5d4cc2c301 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-5.c @@ -0,0 +1,17 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* There's no information about whether STEP1 or STEP2 is innermost, + so we should assume the code is sensible and version for the inner + evolution, i.e. when STEP2 is 1. */ + +void +f1 (double *x, int step1, int step2, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[i * step1 + j * step2] = 100; +} + +/* { dg-final { scan-tree-dump-times {want to version containing loop for when step2} 1 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {want to version containing loop} 1 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {versioned this loop} 1 "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-6.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-6.c new file mode 100644 index 0000000000..e718c23350 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-6.c @@ -0,0 +1,31 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* The read from y in f1 will be hoisted to the outer loop. In general + it's not worth versioning outer loops when the inner loops don't also + benefit. + + This test is meant to be a slight counterexample, since versioning + does lead to cheaper outer-loop vectorization. However, the benefit + isn't enough to justify the cost. */ + +void +f1 (double *restrict x, double *restrict y, int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[i + j] = y[i * step]; +} + +/* A similar example in which the read can't be hoisted, but could + for example be handled by vectorizer alias checks. */ + +void +f2 (double *x, double *y, int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[i + j] = y[i * step]; +} + +/* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */ +/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-7.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-7.c new file mode 100644 index 0000000000..ac0c201879 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-7.c @@ -0,0 +1,32 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Check that versioning can handle arrays of structures. */ + +struct foo { + int a, b, c; +}; + +void +f1 (struct foo *x, int stepx, int n) +{ + for (int i = 0; i < n; ++i) + { + x[stepx * i].a = 1; + x[stepx * i].b = 2; + x[stepx * i].c = 3; + } +} + +void +f2 (struct foo *x, int stepx, int limit) +{ + for (int i = 0; i < limit; i += stepx) + { + x[i].a = 1; + x[i].b = 2; + x[i].c = 3; + } +} + +/* { dg-final { scan-tree-dump-times {want to version containing loop} 2 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {versioned this loop} 2 "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-8.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-8.c new file mode 100644 index 0000000000..5645b13dc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-8.c @@ -0,0 +1,43 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Versioning for step == 1 in these loops would allow loop interchange, + but otherwise isn't worthwhile. At the moment we decide not to version. */ + +struct foo { + int a[100]; +}; + +void +f1 (struct foo *x, int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j * step].a[i] = 100; +} + +void +f2 (struct foo *x, int step, int n) +{ + for (int i = 0; i < n; ++i) + for (int j = 0; j < n; ++j) + x[j].a[i * step] = 100; +} + +void +f3 (struct foo *x, int step, int limit) +{ + for (int i = 0; i < 100; ++i) + for (int j = 0; j < limit; j += step) + x[j].a[i] = 100; +} + +void +f4 (struct foo *x, int step, int limit) +{ + for (int i = 0; i < limit; i += step) + for (int j = 0; j < 100; ++j) + x[j].a[i] = 100; +} + +/* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */ +/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/loop-versioning-9.c b/SingleSource/Regression/C/gcc-dg/loop-versioning-9.c new file mode 100644 index 0000000000..cfbcd821b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/loop-versioning-9.c @@ -0,0 +1,48 @@ +/* { dg-options "-O3 -fdump-tree-lversion-details" } */ + +/* Check that versioning can handle small groups of accesses. */ + +void +f1 (int *x, int *y, int step, int n) +{ + for (int i = 0; i < n; ++i) + x[i] = y[i * step * 2] + y[i * step * 2 + 1]; +} + +void +f2 (int *x, int *y, __INTPTR_TYPE__ step, int n) +{ + for (int i = 0; i < n; ++i) + x[i] = y[i * step * 2] + y[i * step * 2 + 1]; +} + +void +f3 (int *x, int *y, int step, int n) +{ + for (int i = 0; i < n; ++i) + x[i] = y[i * step * 3] + y[i * step * 3 + 2]; +} + +void +f4 (int *x, int *y, __INTPTR_TYPE__ step, int n) +{ + for (int i = 0; i < n; ++i) + x[i] = y[i * step * 3] + y[i * step * 3 + 2]; +} + +void +f5 (int *x, int *y, int step, int n) +{ + for (int i = 0; i < n; ++i) + x[i] = y[i * step * 4] + y[i * step * 4 + 3]; +} + +void +f6 (int *x, int *y, __INTPTR_TYPE__ step, int n) +{ + for (int i = 0; i < n; ++i) + x[i] = y[i * step * 4] + y[i * step * 4 + 3]; +} + +/* { dg-final { scan-tree-dump-times {want to version containing loop} 6 "lversion" } } */ +/* { dg-final { scan-tree-dump-times {versioned this loop} 6 "lversion" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/lower-subreg-1.c b/SingleSource/Regression/C/gcc-dg/lower-subreg-1.c new file mode 100644 index 0000000000..c62db2c466 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lower-subreg-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { ! { mips64 || { aarch64*-*-* arm*-*-* i?86-*-* ia64-*-* pru-*-* sparc*-*-* x86_64-*-* } } } } } */ +/* { dg-options "-O -fdump-rtl-subreg1" } */ +/* { dg-require-effective-target ilp32 } */ + +long long test (long long a, long long b) { return a | b; } + +/* { dg-final { scan-rtl-dump "Splitting reg" "subreg1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/lsr-div1.c b/SingleSource/Regression/C/gcc-dg/lsr-div1.c new file mode 100644 index 0000000000..962054d34d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lsr-div1.c @@ -0,0 +1,57 @@ +/* Test division by const int generates only one shift. */ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-rtl-combine-all" } */ +/* { dg-options "-O2 -fdump-rtl-combine-all -mtune=cortex-a53" { target aarch64*-*-* } } */ +/* { dg-require-effective-target int32plus } */ + +extern void abort (void); + +#define NOINLINE __attribute__((noinline)) + +static NOINLINE int +f1 (unsigned int n) +{ + return n % 0x33; +} + +static NOINLINE int +f2 (unsigned int n) +{ + return n % 0x12; +} + +int +main () +{ + int a = 0xaaaaaaaa; + int b = 0x55555555; + int c; + c = f1 (a); + if (c != 0x11) + abort (); + c = f1 (b); + if (c != 0x22) + abort (); + c = f2 (a); + if (c != 0xE) + abort (); + c = f2 (b); + if (c != 0x7) + abort (); + return 0; +} + +/* Following replacement pattern of intger division by constant, GCC is expected + to generate UMULL and (x)SHIFTRT. This test checks that considering division + by const 0x33, gcc generates a single LSHIFTRT by 37, instead of + two - LSHIFTRT by 32 and LSHIFTRT by 5. */ + +/* { dg-final { scan-rtl-dump "\\(set \\(subreg:DI \\(reg:SI" "combine" { target aarch64*-*-* } } } */ +/* { dg-final { scan-rtl-dump "\\(lshiftrt:DI \\(reg:DI" "combine" { target aarch64*-*-* } } } */ +/* { dg-final { scan-rtl-dump "\\(const_int 37 " "combine" { target aarch64*-*-* } } } */ + +/* Similarly, considering division by const 0x12, gcc generates a + single LSHIFTRT by 34, instead of two - LSHIFTRT by 32 and LSHIFTRT by 2. */ + +/* { dg-final { scan-rtl-dump "\\(const_int 34 " "combine" { target aarch64*-*-* } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-10.c b/SingleSource/Regression/C/gcc-dg/lvalue-10.c new file mode 100644 index 0000000000..cc5f37ba96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-10.c @@ -0,0 +1,22 @@ +/* Test handling of lvalues of incomplete types. Bugs 36941, 88647 + (invalid), 88827. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +struct S; + +extern struct S var; +extern struct S *vp; + +void +f8 (void) +{ + /* These are valid because there is no constraint violation and the + result of '*' is never converted from an lvalue to an rvalue + (which would yield undefined behavior). */ + &var; + &*vp; + &(var); + &(*vp); + &*&*vp; +} diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-11.c b/SingleSource/Regression/C/gcc-dg/lvalue-11.c new file mode 100644 index 0000000000..d8b5a60c99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-11.c @@ -0,0 +1,40 @@ +/* test that lvalue conversions drops qualifiers, Bug 97702 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + + +const int jc; +extern int j; +extern typeof(0,jc) j; +extern typeof(+jc) j; +extern typeof(-jc) j; +extern typeof(1?jc:0) j; +extern typeof((int)jc) j; +extern typeof((const int)jc) j; + +volatile int kv; +extern int k; +extern typeof(0,kv) k; +extern typeof(+kv) k; +extern typeof(-kv) k; +extern typeof(1?kv:0) k; +extern typeof((int)kv) k; +extern typeof((volatile int)kv) k; + +_Atomic int la; +extern int l; +extern typeof(0,la) l; +extern typeof(+la) l; +extern typeof(-la) l; +extern typeof(1?la:0) l; +extern typeof((int)la) l; +extern typeof((_Atomic int)la) l; + +int * restrict mr; +extern int *m; +extern typeof(0,mr) m; +extern typeof(1?mr:0) m; +extern typeof((int *)mr) m; +extern typeof((int * restrict)mr) m; + + diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-2.c b/SingleSource/Regression/C/gcc-dg/lvalue-2.c new file mode 100644 index 0000000000..7f9372f30e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-2.c @@ -0,0 +1,48 @@ +/* Test diagnostic messages for invalid lvalues and non-modifiable + lvalues. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int a, b; + +void +f0 (void) +{ + (a+b) = 1; /* { dg-error "lvalue required as left operand of assignment" } */ + (a+b)++; /* { dg-error "lvalue required as increment operand" } */ + ++(a+b); /* { dg-error "lvalue required as increment operand" } */ + (a+b)--; /* { dg-error "lvalue required as decrement operand" } */ + --(a+b); /* { dg-error "lvalue required as decrement operand" } */ + &(a+b); /* { dg-error "lvalue required as unary '&' operand" } */ +} + +const int c; +const struct { int x; } d; +struct { const int x; } e; +const int *f; + +void +f1 (void) +{ + c = 1; /* { dg-error "assignment of read-only variable 'c'" } */ + d.x = 1; /* { dg-error "assignment of member 'x' in read-only object" } */ + e.x = 1; /* { dg-error "assignment of read-only member 'x'" } */ + *f = 1; /* { dg-error "assignment of read-only location" } */ + c++; /* { dg-error "increment of read-only variable 'c'" } */ + d.x++; /* { dg-error "increment of member 'x' in read-only object" } */ + e.x++; /* { dg-error "increment of read-only member 'x'" } */ + (*f)++; /* { dg-error "increment of read-only location" } */ + ++c; /* { dg-error "increment of read-only variable 'c'" } */ + ++d.x; /* { dg-error "increment of member 'x' in read-only object" } */ + ++e.x; /* { dg-error "increment of read-only member 'x'" } */ + ++(*f); /* { dg-error "increment of read-only location" } */ + c--; /* { dg-error "decrement of read-only variable 'c'" } */ + d.x--; /* { dg-error "decrement of member 'x' in read-only object" } */ + e.x--; /* { dg-error "decrement of read-only member 'x'" } */ + (*f)--; /* { dg-error "decrement of read-only location" } */ + --c; /* { dg-error "decrement of read-only variable 'c'" } */ + --d.x; /* { dg-error "decrement of member 'x' in read-only object" } */ + --e.x; /* { dg-error "decrement of read-only member 'x'" } */ + --(*f); /* { dg-error "decrement of read-only location" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-3.c b/SingleSource/Regression/C/gcc-dg/lvalue-3.c new file mode 100644 index 0000000000..6a500d4d69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-3.c @@ -0,0 +1,14 @@ +/* Test that assignment of a read-only variable that gets const-ness + from a read-only field is diagnosed. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s { const int a; } x; +typeof (x.a) b; +void +f (void) +{ + x.a = 1; /* { dg-error "assignment of read-only member 'a'" } */ + b = 1; /* { dg-error "assignment of read-only variable 'b'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-4.c b/SingleSource/Regression/C/gcc-dg/lvalue-4.c new file mode 100644 index 0000000000..bc92901341 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-4.c @@ -0,0 +1,8 @@ +/* PR c/27721 */ +/* { dg-do compile } */ + +void foo() +{ + int i(); + i += 0; /* { dg-error "lvalue required" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-5.c b/SingleSource/Regression/C/gcc-dg/lvalue-5.c new file mode 100644 index 0000000000..ff3598ae8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-5.c @@ -0,0 +1,14 @@ +/* Test assignment to elements of a string literal is a warning, not + an error. PR 27676. */ +/* { dg-do compile } */ +/* { dg-options "-O -pedantic-errors" } */ + +void +f (void) +{ + "foo"[0] = 0; /* { dg-warning "assignment of read-only location" } */ + "foo"[0]++; /* { dg-warning "increment of read-only location" } */ + "foo"[0]--; /* { dg-warning "decrement of read-only location" } */ + ++"foo"[0]; /* { dg-warning "increment of read-only location" } */ + --"foo"[0]; /* { dg-warning "decrement of read-only location" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-6.c b/SingleSource/Regression/C/gcc-dg/lvalue-6.c new file mode 100644 index 0000000000..6a847d9478 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-6.c @@ -0,0 +1,17 @@ +/* Test constraints on unary '&': PR 22367. */ + +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +extern void v; +void f1 (void) { &v; } /* { dg-error "taking address of expression of type 'void'" } */ + +extern void *pv; +void f2 (void) { &*pv; } /* { dg-warning "dereferencing" } */ +/* { dg-error "taking address of expression of type 'void'" "C90 only error" { target *-*-* } .-1 } */ + +extern const void cv; +void f3 (void) { &cv; } + +extern const void *pcv; +void f4 (void) { &*pcv; } /* { dg-warning "dereferencing" } */ diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-7.c b/SingleSource/Regression/C/gcc-dg/lvalue-7.c new file mode 100644 index 0000000000..37964e1cd7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-7.c @@ -0,0 +1,16 @@ +/* Test constraints on unary '&': PR 22367. */ + +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +extern void v; +void f1 (void) { &v; } /* { dg-error "taking address of expression of type 'void'" } */ + +extern void *pv; +void f2 (void) { &*pv; } /* { dg-warning "dereferencing" } */ + +extern const void cv; +void f3 (void) { &cv; } + +extern const void *pcv; +void f4 (void) { &*pcv; } /* { dg-warning "dereferencing" } */ diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-8.c b/SingleSource/Regression/C/gcc-dg/lvalue-8.c new file mode 100644 index 0000000000..04eeb71b6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-8.c @@ -0,0 +1,19 @@ +/* PR c/66341 */ +/* { dg-do compile } */ + +void +foo (int *p) +{ + p = 0; + /* A cast does not yield an lvalue. */ + (int *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */ + /* A cast to a qualified type has the same effect as a cast + to the unqualified version of the type. */ + (int *const) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */ + (int *) (char *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */ + (int *) (char *) (int *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */ + (int *) (char *) (int *) (char *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */ + (int *) (double *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */ + (int *) (int *) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */ + (int *) (int *const) p = 0; /* { dg-error "lvalue required as left operand of assignment" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/lvalue-9.c b/SingleSource/Regression/C/gcc-dg/lvalue-9.c new file mode 100644 index 0000000000..382b3ffa90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue-9.c @@ -0,0 +1,77 @@ +/* Test handling of lvalues of incomplete types. Bugs 36941, 88647 + (invalid), 88827. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +struct S; + +extern struct S var; +extern struct S *vp; +extern int i; + +void +f1 (void) +{ + var; /* { dg-error "has an incomplete type" } */ + var, (void) 0; /* { dg-error "has an incomplete type" } */ + (i + ? var /* { dg-error "has an incomplete type" } */ + : var); /* { dg-error "has an incomplete type" } */ +} + +void +f2 (void) +{ + (void) var; /* { dg-error "has an incomplete type" } */ + (void) (var, (void) 0); /* { dg-error "has an incomplete type" } */ + (void) (i + ? var /* { dg-error "has an incomplete type" } */ + : var); /* { dg-error "has an incomplete type" } */ +} + +void +f3 (void) +{ + (const void) var; /* { dg-error "has an incomplete type" } */ + (const void) (var, (void) 0); /* { dg-error "has an incomplete type" } */ + (const void) (i + ? var /* { dg-error "has an incomplete type" } */ + : var); /* { dg-error "has an incomplete type" } */ +} + +void +f4 (void) +{ + *vp; /* { dg-error "invalid use of undefined type" } */ + *vp, (void) 0; /* { dg-error "invalid use of undefined type" } */ + (i + ? *vp /* { dg-error "invalid use of undefined type" } */ + : *vp); /* { dg-error "invalid use of undefined type" } */ +} + +void +f5 (void) +{ + (void) *vp; /* { dg-error "invalid use of undefined type" } */ + (void) (*vp, (void) 0); /* { dg-error "invalid use of undefined type" } */ + (void) (i + ? *vp /* { dg-error "invalid use of undefined type" } */ + : *vp); /* { dg-error "invalid use of undefined type" } */ +} + +void +f6 (void) +{ + (const void) *vp; /* { dg-error "invalid use of undefined type" } */ + (const void) (*vp, (void) 0); /* { dg-error "invalid use of undefined type" } */ + (const void) (i + ? *vp /* { dg-error "invalid use of undefined type" } */ + : *vp); /* { dg-error "invalid use of undefined type" } */ +} + +void +f7 (void) +{ + /* This is invalid because of the constraints on []. */ + &vp[0]; /* { dg-error "invalid use of undefined type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/lvalue1.c b/SingleSource/Regression/C/gcc-dg/lvalue1.c new file mode 100644 index 0000000000..67b013078c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/lvalue1.c @@ -0,0 +1,9 @@ +/* PR c/5225 */ +/* { dg-do compile } */ + +int main() +{ + int i; + +i = 1; /* { dg-error "lvalue required as left operand of assignment" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/m-un-1.c b/SingleSource/Regression/C/gcc-dg/m-un-1.c new file mode 100644 index 0000000000..ad84d44ca1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/m-un-1.c @@ -0,0 +1,37 @@ +/* m-un-1.c: "un" for "uninitialized" */ + +/* +From: Jim Wilson +Date: Wed, 6 Jul 1994 13:11:47 -0700 +To: dje@cygnus.com +Subject: Re: devo/gcc ChangeLog.fsf stmt.c +Cc: cvs-gcc@cygnus.com, tege@cygnus.com + + How about a test case? :-) + +Compile with -O -Wall and the broken compiler gives you: +tmp.c:6: warning: `k' might be used uninitialized in this function +The fixed compiler (and gcc 2.5.8) gives no warning. + +This happens to fix a performance regression in the code generated for +while loops, but that is presumably much much harder to test for. +*/ + +/* { dg-do compile } */ +/* { dg-options "-O -Wall" } */ + +int +sub () +{ + int i = 0; + int j = 0; + int k; /* { dg-bogus "`k' might be used uninitialized" "uninitialized warning regression" } */ + + while (i == 0 && j == 0) + { + k = 10; + i = sub (); + } + + return k; +} diff --git a/SingleSource/Regression/C/gcc-dg/m-un-2.c b/SingleSource/Regression/C/gcc-dg/m-un-2.c new file mode 100644 index 0000000000..141b81bb0f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/m-un-2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-W -Wall" } */ + +typedef __SIZE_TYPE__ size_t; +extern void* malloc (size_t); +extern void free (void*); +extern void* realloc (void*, size_t); + +struct vtable { + void* (* _malloc) (size_t); + void (* _free) (void*); + void* (* _realloc) (void*, size_t); /* { dg-line vtable_realloc } */ +}; + +struct vtable mtable = { + malloc, + free +}; /* { dg-warning "missing initializer" "warning regression" } */ + /* { dg-message "declared here" "warning regression 2" { target *-*-* } vtable_realloc } */ + +/* With designated initializers, we assume you meant to leave out the + initialization of any blank fields. */ +struct vtable mtable2 = { + ._malloc = malloc, + ._realloc = realloc +}; + +struct vtable mtable3 = { + ._free = free, + ._malloc = malloc, + ._realloc = realloc +}; diff --git a/SingleSource/Regression/C/gcc-dg/macro-1.c b/SingleSource/Regression/C/gcc-dg/macro-1.c new file mode 100644 index 0000000000..e1d9d34cd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/macro-1.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ + +short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__))); diff --git a/SingleSource/Regression/C/gcc-dg/macro-fusion-1.c b/SingleSource/Regression/C/gcc-dg/macro-fusion-1.c new file mode 100644 index 0000000000..92f82b2517 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/macro-fusion-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -mtune=corei7 -fdump-rtl-sched2" } */ + +int a[100]; + +double bar (double sum) +{ + int i; + for (i = 0; i < 1000000; i++) + sum += (0.5 + (a[i%100] - 128)); + return sum; +} + +/* { dg-final { scan-rtl-dump-not "compare.*insn.*jump_insn.*jump_insn" "sched2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/macro-fusion-2.c b/SingleSource/Regression/C/gcc-dg/macro-fusion-2.c new file mode 100644 index 0000000000..6dc1e27e3c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/macro-fusion-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -mtune=corei7-avx -fdump-rtl-sched2" } */ + +int a[100]; + +double bar (double sum) +{ + int i = 100000; + while (i != 0) + { + sum += (0.5 + (a[i%100] - 128)); + i--; + } + return sum; +} + +/* { dg-final { scan-rtl-dump-not "compare.*insn.*jump_insn.*jump_insn" "sched2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/mallign.c b/SingleSource/Regression/C/gcc-dg/mallign.c new file mode 100644 index 0000000000..9a18a00c3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/mallign.c @@ -0,0 +1,15 @@ +/* Check that malloc's alignment honors what we trust it + minimally should. */ + +/* { dg-do run } */ +/* { dg-options "-fno-builtin-malloc" } */ + +#include +typedef int word __attribute__((mode(word))); + +int main() +{ + if ((sizeof(word)>1) && ((__UINTPTR_TYPE__)malloc (1) & (sizeof(word)-1))) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/march-generic.c b/SingleSource/Regression/C/gcc-dg/march-generic.c new file mode 100644 index 0000000000..f9c00e4a1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/march-generic.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-skip-if "" { *-*-* } { "-march=*" } { "" } } */ +/* { dg-options "-march=generic -fcf-protection=none" } */ +/* { dg-error "'generic' CPU can be used only for '-mtune=' switch" "" { target *-*-* } 0 } */ +/* { dg-bogus "march" "" { target *-*-* } 0 } */ +int i; diff --git a/SingleSource/Regression/C/gcc-dg/march.c b/SingleSource/Regression/C/gcc-dg/march.c new file mode 100644 index 0000000000..43478bc8a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/march.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-march=*" } { "" } } */ +/* { dg-options "-march=foo" } */ +/* { dg-error "march" "" { target *-*-* } 0 } */ +/* { dg-bogus "mtune" "" { target *-*-* } 0 } */ +/* { dg-prune-output "note: valid arguments" } */ +int i; diff --git a/SingleSource/Regression/C/gcc-dg/max-1.c b/SingleSource/Regression/C/gcc-dg/max-1.c new file mode 100644 index 0000000000..9823dca597 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/max-1.c @@ -0,0 +1,42 @@ +/* PR middle-end/18548 */ +/* Test case reduced by Andrew Pinski */ +/* { dg-do run } */ +/* { dg-options "-O1 " } */ +/* Option -fno-tree-lrs removed By Andrew MacLeod since it is no longer + supported in the compiler beginning with GCC 4.3. */ +/* m32c has varying sized pointers */ +/* { dg-skip-if "" { "m32c-*-*" } { "*" } { "-mcpu=m32c" "-mcpu=m32cm" } } */ + +__extension__ typedef __INTPTR_TYPE__ intptr_t; + +extern void abort (void); + +intptr_t fff[10]; + +void f(intptr_t a, intptr_t b) +{ + intptr_t crcc = b; + intptr_t d = *((intptr_t*)(a+1)); + int i; + + a = d >= b? d:b; + + + for(i=0;i<10;i++) + fff[i] = a; +} + +/* The variable a cannot be a local variable as we get better aliasing + now and decide that the store to a is dead. The better aliasing comes + from better representation of pointer arithmetic. */ +intptr_t a = 10; +int main(void) +{ + int i; + f((intptr_t)(&a)-1,0); + for(i = 0;i<10;i++) + if (fff[i]!=10) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/max.c b/SingleSource/Regression/C/gcc-dg/max.c new file mode 100644 index 0000000000..e979810422 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/max.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +static inline int +max (int a, int b) +{ + return a < b ? b : a; +} + +int +test_00 (int a) +{ + return max (a, a + 8); +} + +int +test_01 (int a) +{ + return max (a, a - 8); +} + +/* { dg-final { scan-tree-dump-not "MAX_EXPR" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memchr-2.c b/SingleSource/Regression/C/gcc-dg/memchr-2.c new file mode 100644 index 0000000000..61357f96d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memchr-2.c @@ -0,0 +1,41 @@ +/* PR tree-optimization/96670 - ICE on memchr with an empty initializer + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } */ + +struct { + int i, j; +} const s = { }; + +void memchr_success_unused (void) +{ + int n = (char *)&s.j - (char *)&s; + char *p = (char *)&s; + __builtin_memchr (p, '\0', n); +} + +void memchr_success_used (void) +{ + int n = (char *)&s.j - (char *)&s; + char *p = (char *)&s; + if (&s != __builtin_memchr (p, '\0', n)) + __builtin_abort (); +} + +void memchr_fail_unused (void) +{ + int n = (char *)&s.j - (char *)&s; + char *p = (char *)&s; + __builtin_memchr (p, '\5', n); +} + +void memchr_fail_used (void) +{ + int n = (char *)&s.j - (char *)&s; + char *p = (char *)&s; + if (__builtin_memchr (p, '\5', n)) + __builtin_abort (); +} + +/* { dg-prune-output "\\\[-Wunused-value" } + { dg-final { scan-tree-dump-not "abort" "optimized" } } + { dg-final { scan-tree-dump-not "memcmp \\(" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memchr-3.c b/SingleSource/Regression/C/gcc-dg/memchr-3.c new file mode 100644 index 0000000000..9c73265a89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memchr-3.c @@ -0,0 +1,25 @@ +/* PR middle-end/97956 - ICE due to type mismatch in pointer_plus_expr + during memchr folding + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __INT8_TYPE__ int8_t; +typedef __INT32_TYPE__ int32_t; + +extern void* memchr (const void*, int, long); /* { dg-warning "-Wbuiltin-declaration-mismatch" "" { target llp64 } } */ + +struct SX +{ + int32_t n; + int8_t a[]; +}; + +const struct SX sx = { 0x1221 }; +const char sx_rep[] = { }; + +void test_find (void) +{ + int n = 0, nb = (const char*)&sx.a - (const char*)&sx; + const char *p = (const char*)&sx, *q = sx_rep; + n += p + 1 == memchr (p, q[1], nb); +} diff --git a/SingleSource/Regression/C/gcc-dg/memchr.c b/SingleSource/Regression/C/gcc-dg/memchr.c new file mode 100644 index 0000000000..27524b8252 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memchr.c @@ -0,0 +1,95 @@ +/* PR middle-end/78257 - missing memcmp optimization with constant arrays + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } + { dg-skip-if "test assumes structs are not packed" { default_packed } } */ + +typedef __INT8_TYPE__ int8_t; +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; +typedef __SIZE_TYPE__ size_t; + +extern void* memchr (const void*, int, size_t); + +/* Verify that initializers for flexible array members are handled + correctly. */ + +struct SX +{ + /* offset */ + /* 0 */ int32_t n; + /* 4 */ int8_t: 1; + /* 6 */ int16_t a[]; +}; + +_Static_assert (__builtin_offsetof (struct SX, a) == 6); + +const struct SX sx = + { + 0x11121314, { 0x2122, 0x3132, 0x4142, 0x5152 } + }; + +const char sx_rep[] = + { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + 0x11, 0x12, 0x13, 0x14, 0, 0, 0x21, 0x22, 0x31, 0x32, 0x41, 0x42, 0x51, 0x52 +#else + 0x14, 0x13, 0x12, 0x11, 0, 0, 0x22, 0x21, 0x32, 0x31, 0x42, 0x41, 0x52, 0x51 +#endif + }; + + +void test_find (void) +{ + int n = 0, nb = (const char*)&sx.a[4] - (const char*)&sx; + const char *p = (const char*)&sx, *q = sx_rep; + + if (nb != sizeof sx_rep) + __builtin_abort (); + + n += p == memchr (p, q[ 0], nb); + n += p + 1 == memchr (p, q[ 1], nb); + n += p + 2 == memchr (p, q[ 2], nb); + n += p + 3 == memchr (p, q[ 3], nb); + n += p + 4 == memchr (p, q[ 4], nb); + n += p + 4 == memchr (p, q[ 5], nb); + n += p + 6 == memchr (p, q[ 6], nb); + n += p + 7 == memchr (p, q[ 7], nb); + n += p + 8 == memchr (p, q[ 8], nb); + n += p + 9 == memchr (p, q[ 9], nb); + n += p + 10 == memchr (p, q[10], nb); + n += p + 11 == memchr (p, q[11], nb); + n += p + 12 == memchr (p, q[12], nb); + n += p + 13 == memchr (p, q[13], nb); + + if (n != 14) + __builtin_abort (); +} + +void test_not_find (void) +{ + int n = 0, nb = (const char*)&sx.a[4] - (const char*)&sx; + const char *p = (const char*)&sx, *q = sx_rep; + + if (nb != sizeof sx_rep) + __builtin_abort (); + + n += 0 == memchr (p, 0xff, nb); + n += 0 == memchr (p + 1, q[ 0], nb - 1); + n += 0 == memchr (p + 2, q[ 1], nb - 2); + n += 0 == memchr (p + 3, q[ 2], nb - 3); + n += 0 == memchr (p + 4, q[ 3], nb - 4); + n += 0 == memchr (p + 6, q[ 4], nb - 6); + n += 0 == memchr (p + 7, q[ 6], nb - 7); + n += 0 == memchr (p + 8, q[ 7], nb - 8); + n += 0 == memchr (p + 9, q[ 8], nb - 9); + n += 0 == memchr (p + 10, q[ 9], nb - 10); + n += 0 == memchr (p + 11, q[10], nb - 11); + n += 0 == memchr (p + 12, q[11], nb - 12); + n += 0 == memchr (p + 13, q[12], nb - 13); + n += 0 == memchr (p + 14, q[13], nb - 14); + + if (n != 14) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcmp-1.c b/SingleSource/Regression/C/gcc-dg/memcmp-1.c new file mode 100644 index 0000000000..ea837ca0f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcmp-1.c @@ -0,0 +1,770 @@ +/* Test memcmp/strncmp builtin expansion for compilation and proper execution. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target ptr32plus } */ +/* { dg-timeout-factor 2 } */ + +#include +#include +#include +#include + +#define STR1(X) #X +#define STR2(X) STR1(X) + +int lib_memcmp(const void *a, const void *b, size_t n) + asm(STR2(__USER_LABEL_PREFIX__) "memcmp"); +int lib_strncmp(const char *a, const char *b, size_t n) + asm(STR2(__USER_LABEL_PREFIX__) "strncmp"); + +#ifndef NRAND +#ifdef TEST_ALL +#define NRAND 10000 +#else +#define NRAND 500 +#endif +#endif +#ifndef TZONE +#ifdef TEST_ALL +#define TZONE 16 +#else +#define TZONE 8 +#endif +#endif + +#define MAX_SZ 600 + +#define DEF_RS(ALIGN) \ +static void test_memcmp_runtime_size_ ## ALIGN (const char *str1, \ + const char *str2, \ + size_t sz, int expect) \ +{ \ + char three[8192] __attribute__ ((aligned (4096))); \ + char four[8192] __attribute__ ((aligned (4096))); \ + char *a, *b; \ + int i,j,a1,a2,r; \ + for (j = 0; j < 2; j++) \ + { \ + for (i = 0; i < 2; i++) \ + { \ + a = three+i*ALIGN+j*(4096-2*i*ALIGN); \ + b = four+i*ALIGN+j*(4096-2*i*ALIGN); \ + memcpy(a,str1,sz); \ + memcpy(b,str2,sz); \ + r = memcmp(a,b,sz); \ + if ( r < 0 && !(expect < 0) ) abort(); \ + if ( r > 0 && !(expect > 0) ) abort(); \ + if ( r == 0 && !(expect == 0) ) abort(); \ + } \ + } \ +} + +DEF_RS(1) +DEF_RS(2) +DEF_RS(4) +DEF_RS(8) +DEF_RS(16) + +static void test_memcmp_runtime_size (const char *str1, const char *str2, + size_t sz, int expect) +{ + char three[8192] __attribute__ ((aligned (4096))); + char four[8192] __attribute__ ((aligned (4096))); + char *a, *b; + int i,j,a1,a2,r; + test_memcmp_runtime_size_1 (str1,str2,sz,expect); + test_memcmp_runtime_size_2 (str1,str2,sz,expect); + test_memcmp_runtime_size_4 (str1,str2,sz,expect); + test_memcmp_runtime_size_8 (str1,str2,sz,expect); + test_memcmp_runtime_size_16 (str1,str2,sz,expect); + for (j = 0; j < 2; j++) + { + for (i = 0; i < 2; i++) + { + for (a1=0; a1 < 2*sizeof(void *); a1++) + { + a = three+i*a1+j*(4096-2*i*a1); + memcpy(a,str1,sz); + for (a2=0; a2 < 2*sizeof(void *); a2++) + { + b = four+i*a2+j*(4096-2*i*a2); + memcpy(b,str2,sz); + r = memcmp(a,b,sz); + if ( r < 0 && !(expect < 0) ) abort(); + if ( r > 0 && !(expect > 0) ) abort(); + if ( r == 0 && !(expect == 0) ) abort(); + } + } + } + } +} + +static void test_driver_memcmp (void (test_memcmp)(const char *, const char *, int), + void (test_strncmp)(const char *, const char *, int), + size_t sz, int align) +{ + char buf1[MAX_SZ*2+TZONE],buf2[MAX_SZ*2+TZONE]; + size_t test_sz = (szTZONE)?(test_sz-TZONE):0); diff_pos < test_sz+TZONE; diff_pos++) + for(zero_pos = ((test_sz>TZONE)?(test_sz-TZONE):0); zero_pos < test_sz+TZONE; zero_pos++) + { + memset(buf1, 'A', 2*test_sz); + memset(buf2, 'A', 2*test_sz); + buf2[diff_pos] = 'B'; + buf1[zero_pos] = 0; + buf2[zero_pos] = 0; + e = lib_memcmp(buf1,buf2,sz); + (*test_memcmp)(buf1,buf2,e); + (*test_memcmp)(buf2,buf1,-e); + (*test_memcmp)(buf2,buf2,0); + test_memcmp_runtime_size (buf1, buf2, sz, e); + test_memcmp_runtime_size (buf2, buf1, sz, -e); + e = lib_strncmp(buf1,buf2,sz); + (*test_strncmp)(buf1,buf2,e); + (*test_strncmp)(buf2,buf1,-e); + (*test_strncmp)(buf2,buf2,0); + /* differing length: */ + buf2[diff_pos] = 0; + e = lib_memcmp(buf1,buf2,sz); + (*test_memcmp)(buf1,buf2,e); + test_memcmp_runtime_size (buf1, buf2, sz, e); + e = lib_strncmp(buf1,buf2,sz); + (*test_strncmp)(buf1,buf2,e); + memset(buf2+diff_pos,'B',sizeof(buf2)-diff_pos); + buf2[zero_pos] = 0; + e = lib_memcmp(buf1,buf2,sz); + (*test_memcmp)(buf1,buf2,e); + (*test_memcmp)(buf2,buf1,-e); + test_memcmp_runtime_size (buf1, buf2, sz, e); + test_memcmp_runtime_size (buf2, buf1, sz, -e); + e = lib_strncmp(buf1,buf2,sz); + (*test_strncmp)(buf1,buf2,e); + (*test_strncmp)(buf2,buf1,-e); + } +} + +#define RUN_TEST(SZ, ALIGN) test_driver_memcmp (test_memcmp_ ## SZ ## _ ## ALIGN, test_strncmp_ ## SZ ## _ ## ALIGN, SZ, ALIGN); + +#define DEF_TEST(SZ, ALIGN) \ + static void test_memcmp_ ## SZ ## _ ## ALIGN (const char *str1, const char *str2, int expect) \ +{ \ + char three[8192] __attribute__ ((aligned (4096))); \ + char four[8192] __attribute__ ((aligned (4096))); \ + char *a, *b; \ + int i,j,r; \ + for (j = 0; j < 2; j++) \ + { \ + for (i = 0; i < 2; i++) \ + { \ + a = three+i*ALIGN+j*(4096-2*i*ALIGN); \ + b = four+i*ALIGN+j*(4096-2*i*ALIGN); \ + memcpy(a,str1,SZ); \ + memcpy(b,str2,SZ); \ + r = memcmp(a,b,SZ); \ + if ( r < 0 && !(expect < 0) ) abort(); \ + if ( r > 0 && !(expect > 0) ) abort(); \ + if ( r == 0 && !(expect == 0) ) abort(); \ + } \ + } \ +} \ +static void test_strncmp_ ## SZ ## _ ## ALIGN (const char *str1, const char *str2, int expect) \ +{ \ + char three[8192] __attribute__ ((aligned (4096))); \ + char four[8192] __attribute__ ((aligned (4096))); \ + char *a, *b; \ + int i,j,r; \ + for (j = 0; j < 2; j++) \ + { \ + for (i = 0; i < 2; i++) \ + { \ + a = three+i*ALIGN+j*(4096-2*i*ALIGN); \ + b = four+i*ALIGN+j*(4096-2*i*ALIGN); \ + memcpy(a,str1,SZ); \ + memcpy(b,str2,SZ); \ + r = strncmp(a,b,SZ); \ + if ( r < 0 && !(expect < 0) ) abort(); \ + if ( r > 0 && !(expect > 0) ) abort(); \ + if ( r == 0 && !(expect == 0) ) abort(); \ + } \ + } \ +} + +#ifdef TEST_ALL +DEF_TEST(1,1) +DEF_TEST(1,2) +DEF_TEST(1,4) +DEF_TEST(1,8) +DEF_TEST(1,16) +DEF_TEST(2,1) +DEF_TEST(2,2) +DEF_TEST(2,4) +DEF_TEST(2,8) +DEF_TEST(2,16) +DEF_TEST(3,1) +DEF_TEST(3,2) +DEF_TEST(3,4) +DEF_TEST(3,8) +DEF_TEST(3,16) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(4,8) +DEF_TEST(4,16) +DEF_TEST(5,1) +DEF_TEST(5,2) +DEF_TEST(5,4) +DEF_TEST(5,8) +DEF_TEST(5,16) +DEF_TEST(6,1) +DEF_TEST(6,2) +DEF_TEST(6,4) +DEF_TEST(6,8) +DEF_TEST(6,16) +DEF_TEST(7,1) +DEF_TEST(7,2) +DEF_TEST(7,4) +DEF_TEST(7,8) +DEF_TEST(7,16) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(8,16) +DEF_TEST(9,1) +DEF_TEST(9,2) +DEF_TEST(9,4) +DEF_TEST(9,8) +DEF_TEST(9,16) +DEF_TEST(10,1) +DEF_TEST(10,2) +DEF_TEST(10,4) +DEF_TEST(10,8) +DEF_TEST(10,16) +DEF_TEST(11,1) +DEF_TEST(11,2) +DEF_TEST(11,4) +DEF_TEST(11,8) +DEF_TEST(11,16) +DEF_TEST(12,1) +DEF_TEST(12,2) +DEF_TEST(12,4) +DEF_TEST(12,8) +DEF_TEST(12,16) +DEF_TEST(13,1) +DEF_TEST(13,2) +DEF_TEST(13,4) +DEF_TEST(13,8) +DEF_TEST(13,16) +DEF_TEST(14,1) +DEF_TEST(14,2) +DEF_TEST(14,4) +DEF_TEST(14,8) +DEF_TEST(14,16) +DEF_TEST(15,1) +DEF_TEST(15,2) +DEF_TEST(15,4) +DEF_TEST(15,8) +DEF_TEST(15,16) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(17,1) +DEF_TEST(17,2) +DEF_TEST(17,4) +DEF_TEST(17,8) +DEF_TEST(17,16) +DEF_TEST(18,1) +DEF_TEST(18,2) +DEF_TEST(18,4) +DEF_TEST(18,8) +DEF_TEST(18,16) +DEF_TEST(19,1) +DEF_TEST(19,2) +DEF_TEST(19,4) +DEF_TEST(19,8) +DEF_TEST(19,16) +DEF_TEST(20,1) +DEF_TEST(20,2) +DEF_TEST(20,4) +DEF_TEST(20,8) +DEF_TEST(20,16) +DEF_TEST(21,1) +DEF_TEST(21,2) +DEF_TEST(21,4) +DEF_TEST(21,8) +DEF_TEST(21,16) +DEF_TEST(22,1) +DEF_TEST(22,2) +DEF_TEST(22,4) +DEF_TEST(22,8) +DEF_TEST(22,16) +DEF_TEST(23,1) +DEF_TEST(23,2) +DEF_TEST(23,4) +DEF_TEST(23,8) +DEF_TEST(23,16) +DEF_TEST(24,1) +DEF_TEST(24,2) +DEF_TEST(24,4) +DEF_TEST(24,8) +DEF_TEST(24,16) +DEF_TEST(25,1) +DEF_TEST(25,2) +DEF_TEST(25,4) +DEF_TEST(25,8) +DEF_TEST(25,16) +DEF_TEST(26,1) +DEF_TEST(26,2) +DEF_TEST(26,4) +DEF_TEST(26,8) +DEF_TEST(26,16) +DEF_TEST(27,1) +DEF_TEST(27,2) +DEF_TEST(27,4) +DEF_TEST(27,8) +DEF_TEST(27,16) +DEF_TEST(28,1) +DEF_TEST(28,2) +DEF_TEST(28,4) +DEF_TEST(28,8) +DEF_TEST(28,16) +DEF_TEST(29,1) +DEF_TEST(29,2) +DEF_TEST(29,4) +DEF_TEST(29,8) +DEF_TEST(29,16) +DEF_TEST(30,1) +DEF_TEST(30,2) +DEF_TEST(30,4) +DEF_TEST(30,8) +DEF_TEST(30,16) +DEF_TEST(31,1) +DEF_TEST(31,2) +DEF_TEST(31,4) +DEF_TEST(31,8) +DEF_TEST(31,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +DEF_TEST(33,1) +DEF_TEST(33,2) +DEF_TEST(33,4) +DEF_TEST(33,8) +DEF_TEST(33,16) +DEF_TEST(34,1) +DEF_TEST(34,2) +DEF_TEST(34,4) +DEF_TEST(34,8) +DEF_TEST(34,16) +DEF_TEST(35,1) +DEF_TEST(35,2) +DEF_TEST(35,4) +DEF_TEST(35,8) +DEF_TEST(35,16) +DEF_TEST(36,1) +DEF_TEST(36,2) +DEF_TEST(36,4) +DEF_TEST(36,8) +DEF_TEST(36,16) +DEF_TEST(37,1) +DEF_TEST(37,2) +DEF_TEST(37,4) +DEF_TEST(37,8) +DEF_TEST(37,16) +DEF_TEST(38,1) +DEF_TEST(38,2) +DEF_TEST(38,4) +DEF_TEST(38,8) +DEF_TEST(38,16) +DEF_TEST(39,1) +DEF_TEST(39,2) +DEF_TEST(39,4) +DEF_TEST(39,8) +DEF_TEST(39,16) +DEF_TEST(40,1) +DEF_TEST(40,2) +DEF_TEST(40,4) +DEF_TEST(40,8) +DEF_TEST(40,16) +DEF_TEST(41,1) +DEF_TEST(41,2) +DEF_TEST(41,4) +DEF_TEST(41,8) +DEF_TEST(41,16) +DEF_TEST(42,1) +DEF_TEST(42,2) +DEF_TEST(42,4) +DEF_TEST(42,8) +DEF_TEST(42,16) +DEF_TEST(43,1) +DEF_TEST(43,2) +DEF_TEST(43,4) +DEF_TEST(43,8) +DEF_TEST(43,16) +DEF_TEST(44,1) +DEF_TEST(44,2) +DEF_TEST(44,4) +DEF_TEST(44,8) +DEF_TEST(44,16) +DEF_TEST(45,1) +DEF_TEST(45,2) +DEF_TEST(45,4) +DEF_TEST(45,8) +DEF_TEST(45,16) +DEF_TEST(46,1) +DEF_TEST(46,2) +DEF_TEST(46,4) +DEF_TEST(46,8) +DEF_TEST(46,16) +DEF_TEST(47,1) +DEF_TEST(47,2) +DEF_TEST(47,4) +DEF_TEST(47,8) +DEF_TEST(47,16) +DEF_TEST(48,1) +DEF_TEST(48,2) +DEF_TEST(48,4) +DEF_TEST(48,8) +DEF_TEST(48,16) +DEF_TEST(49,1) +DEF_TEST(49,2) +DEF_TEST(49,4) +DEF_TEST(49,8) +DEF_TEST(49,16) +DEF_TEST(100,1) +DEF_TEST(100,2) +DEF_TEST(100,4) +DEF_TEST(100,8) +DEF_TEST(100,16) +DEF_TEST(191,1) +DEF_TEST(192,1) +DEF_TEST(193,1) +DEF_TEST(200,1) +DEF_TEST(400,1) +#else +DEF_TEST(1,1) +DEF_TEST(2,1) +DEF_TEST(3,1) +DEF_TEST(4,1) +DEF_TEST(5,1) +DEF_TEST(5,8) +DEF_TEST(6,1) +DEF_TEST(6,4) +DEF_TEST(6,8) +DEF_TEST(7,1) +DEF_TEST(7,2) +DEF_TEST(7,4) +DEF_TEST(7,8) +DEF_TEST(8,1) +DEF_TEST(9,1) +DEF_TEST(16,1) +DEF_TEST(32,1) +DEF_TEST(33,8) +DEF_TEST(49,1) +#endif + +int +main(int argc, char **argv) +{ +#ifdef TEST_ALL + RUN_TEST(1,1) + RUN_TEST(1,2) + RUN_TEST(1,4) + RUN_TEST(1,8) + RUN_TEST(1,16) + RUN_TEST(2,1) + RUN_TEST(2,2) + RUN_TEST(2,4) + RUN_TEST(2,8) + RUN_TEST(2,16) + RUN_TEST(3,1) + RUN_TEST(3,2) + RUN_TEST(3,4) + RUN_TEST(3,8) + RUN_TEST(3,16) + RUN_TEST(4,1) + RUN_TEST(4,2) + RUN_TEST(4,4) + RUN_TEST(4,8) + RUN_TEST(4,16) + RUN_TEST(5,1) + RUN_TEST(5,2) + RUN_TEST(5,4) + RUN_TEST(5,8) + RUN_TEST(5,16) + RUN_TEST(6,1) + RUN_TEST(6,2) + RUN_TEST(6,4) + RUN_TEST(6,8) + RUN_TEST(6,16) + RUN_TEST(7,1) + RUN_TEST(7,2) + RUN_TEST(7,4) + RUN_TEST(7,8) + RUN_TEST(7,16) + RUN_TEST(8,1) + RUN_TEST(8,2) + RUN_TEST(8,4) + RUN_TEST(8,8) + RUN_TEST(8,16) + RUN_TEST(9,1) + RUN_TEST(9,2) + RUN_TEST(9,4) + RUN_TEST(9,8) + RUN_TEST(9,16) + RUN_TEST(10,1) + RUN_TEST(10,2) + RUN_TEST(10,4) + RUN_TEST(10,8) + RUN_TEST(10,16) + RUN_TEST(11,1) + RUN_TEST(11,2) + RUN_TEST(11,4) + RUN_TEST(11,8) + RUN_TEST(11,16) + RUN_TEST(12,1) + RUN_TEST(12,2) + RUN_TEST(12,4) + RUN_TEST(12,8) + RUN_TEST(12,16) + RUN_TEST(13,1) + RUN_TEST(13,2) + RUN_TEST(13,4) + RUN_TEST(13,8) + RUN_TEST(13,16) + RUN_TEST(14,1) + RUN_TEST(14,2) + RUN_TEST(14,4) + RUN_TEST(14,8) + RUN_TEST(14,16) + RUN_TEST(15,1) + RUN_TEST(15,2) + RUN_TEST(15,4) + RUN_TEST(15,8) + RUN_TEST(15,16) + RUN_TEST(16,1) + RUN_TEST(16,2) + RUN_TEST(16,4) + RUN_TEST(16,8) + RUN_TEST(16,16) + RUN_TEST(17,1) + RUN_TEST(17,2) + RUN_TEST(17,4) + RUN_TEST(17,8) + RUN_TEST(17,16) + RUN_TEST(18,1) + RUN_TEST(18,2) + RUN_TEST(18,4) + RUN_TEST(18,8) + RUN_TEST(18,16) + RUN_TEST(19,1) + RUN_TEST(19,2) + RUN_TEST(19,4) + RUN_TEST(19,8) + RUN_TEST(19,16) + RUN_TEST(20,1) + RUN_TEST(20,2) + RUN_TEST(20,4) + RUN_TEST(20,8) + RUN_TEST(20,16) + RUN_TEST(21,1) + RUN_TEST(21,2) + RUN_TEST(21,4) + RUN_TEST(21,8) + RUN_TEST(21,16) + RUN_TEST(22,1) + RUN_TEST(22,2) + RUN_TEST(22,4) + RUN_TEST(22,8) + RUN_TEST(22,16) + RUN_TEST(23,1) + RUN_TEST(23,2) + RUN_TEST(23,4) + RUN_TEST(23,8) + RUN_TEST(23,16) + RUN_TEST(24,1) + RUN_TEST(24,2) + RUN_TEST(24,4) + RUN_TEST(24,8) + RUN_TEST(24,16) + RUN_TEST(25,1) + RUN_TEST(25,2) + RUN_TEST(25,4) + RUN_TEST(25,8) + RUN_TEST(25,16) + RUN_TEST(26,1) + RUN_TEST(26,2) + RUN_TEST(26,4) + RUN_TEST(26,8) + RUN_TEST(26,16) + RUN_TEST(27,1) + RUN_TEST(27,2) + RUN_TEST(27,4) + RUN_TEST(27,8) + RUN_TEST(27,16) + RUN_TEST(28,1) + RUN_TEST(28,2) + RUN_TEST(28,4) + RUN_TEST(28,8) + RUN_TEST(28,16) + RUN_TEST(29,1) + RUN_TEST(29,2) + RUN_TEST(29,4) + RUN_TEST(29,8) + RUN_TEST(29,16) + RUN_TEST(30,1) + RUN_TEST(30,2) + RUN_TEST(30,4) + RUN_TEST(30,8) + RUN_TEST(30,16) + RUN_TEST(31,1) + RUN_TEST(31,2) + RUN_TEST(31,4) + RUN_TEST(31,8) + RUN_TEST(31,16) + RUN_TEST(32,1) + RUN_TEST(32,2) + RUN_TEST(32,4) + RUN_TEST(32,8) + RUN_TEST(32,16) + RUN_TEST(33,1) + RUN_TEST(33,2) + RUN_TEST(33,4) + RUN_TEST(33,8) + RUN_TEST(33,16) + RUN_TEST(34,1) + RUN_TEST(34,2) + RUN_TEST(34,4) + RUN_TEST(34,8) + RUN_TEST(34,16) + RUN_TEST(35,1) + RUN_TEST(35,2) + RUN_TEST(35,4) + RUN_TEST(35,8) + RUN_TEST(35,16) + RUN_TEST(36,1) + RUN_TEST(36,2) + RUN_TEST(36,4) + RUN_TEST(36,8) + RUN_TEST(36,16) + RUN_TEST(37,1) + RUN_TEST(37,2) + RUN_TEST(37,4) + RUN_TEST(37,8) + RUN_TEST(37,16) + RUN_TEST(38,1) + RUN_TEST(38,2) + RUN_TEST(38,4) + RUN_TEST(38,8) + RUN_TEST(38,16) + RUN_TEST(39,1) + RUN_TEST(39,2) + RUN_TEST(39,4) + RUN_TEST(39,8) + RUN_TEST(39,16) + RUN_TEST(40,1) + RUN_TEST(40,2) + RUN_TEST(40,4) + RUN_TEST(40,8) + RUN_TEST(40,16) + RUN_TEST(41,1) + RUN_TEST(41,2) + RUN_TEST(41,4) + RUN_TEST(41,8) + RUN_TEST(41,16) + RUN_TEST(42,1) + RUN_TEST(42,2) + RUN_TEST(42,4) + RUN_TEST(42,8) + RUN_TEST(42,16) + RUN_TEST(43,1) + RUN_TEST(43,2) + RUN_TEST(43,4) + RUN_TEST(43,8) + RUN_TEST(43,16) + RUN_TEST(44,1) + RUN_TEST(44,2) + RUN_TEST(44,4) + RUN_TEST(44,8) + RUN_TEST(44,16) + RUN_TEST(45,1) + RUN_TEST(45,2) + RUN_TEST(45,4) + RUN_TEST(45,8) + RUN_TEST(45,16) + RUN_TEST(46,1) + RUN_TEST(46,2) + RUN_TEST(46,4) + RUN_TEST(46,8) + RUN_TEST(46,16) + RUN_TEST(47,1) + RUN_TEST(47,2) + RUN_TEST(47,4) + RUN_TEST(47,8) + RUN_TEST(47,16) + RUN_TEST(48,1) + RUN_TEST(48,2) + RUN_TEST(48,4) + RUN_TEST(48,8) + RUN_TEST(48,16) + RUN_TEST(49,1) + RUN_TEST(49,2) + RUN_TEST(49,4) + RUN_TEST(49,8) + RUN_TEST(49,16) + RUN_TEST(100,1) + RUN_TEST(100,2) + RUN_TEST(100,4) + RUN_TEST(100,8) + RUN_TEST(100,16) + RUN_TEST(191,1) + RUN_TEST(192,1) + RUN_TEST(193,1) + RUN_TEST(200,1) + RUN_TEST(400,1) +#else + RUN_TEST(1,1) + RUN_TEST(2,1) + RUN_TEST(3,1) + RUN_TEST(4,1) + RUN_TEST(5,1) + RUN_TEST(5,8) + RUN_TEST(6,1) + RUN_TEST(6,4) + RUN_TEST(6,8) + RUN_TEST(7,1) + RUN_TEST(7,2) + RUN_TEST(7,4) + RUN_TEST(7,8) + RUN_TEST(8,1) + RUN_TEST(9,1) + RUN_TEST(16,1) + RUN_TEST(32,1) + RUN_TEST(33,8) + RUN_TEST(49,1) +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/memcmp-2.c b/SingleSource/Regression/C/gcc-dg/memcmp-2.c new file mode 100644 index 0000000000..ff99c12b0a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcmp-2.c @@ -0,0 +1,183 @@ +/* PR middle-end/78257 - missing memcmp optimization with constant arrays + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } */ + +#define assert(e) ((e) ? (void)0 : __builtin_abort ()) + +typedef __INT32_TYPE__ int32_t; + +extern int memcmp (const void*, const void*, __SIZE_TYPE__); + +const int32_t i_0 = 0; +const int32_t j_0 = 0; + +void eq_i0_j0 (void) +{ + const char *pi = (char*)&i_0, *pj = (char*)&j_0; + int n = 0; + + n += 0 == memcmp (pi, pj, sizeof (int32_t)); + n += 0 == memcmp (pi + 1, pj + 1, sizeof (int32_t) - 1); + n += 0 == memcmp (pi + 2, pj + 2, sizeof (int32_t) - 2); + n += 0 == memcmp (pi + 3, pj + 3, sizeof (int32_t) - 3); + n += 0 == memcmp (pi + 4, pj + 4, sizeof (int32_t) - 4); + + assert (n == 5); +} + + +const int32_t i1234 = 1234; +const int32_t j1234 = 1234; + +void eq_i1234_j1245 (void) +{ + const char *pi = (char*)&i1234, *pj = (char*)&j1234; + int n = 0; + + n += 0 == memcmp (pi, pj, sizeof (int32_t)); + n += 0 == memcmp (pi + 1, pj + 1, sizeof (int32_t) - 1); + n += 0 == memcmp (pi + 2, pj + 2, sizeof (int32_t) - 2); + n += 0 == memcmp (pi + 3, pj + 3, sizeof (int32_t) - 3); + n += 0 == memcmp (pi + 4, pj + 4, sizeof (int32_t) - 4); + + assert (n == 5); +} + + +const int32_t a1[2] = { 1234 }; +const int32_t b1[2] = { 1234 }; + +void eq_a1_b1 (void) +{ + const char *pi = (char*)&a1, *pj = (char*)&b1; + int n = 0, nb = sizeof a1; + + n += 0 == memcmp (pi, pj, nb); + n += 0 == memcmp (pi + 1, pj + 1, nb - 1); + n += 0 == memcmp (pi + 2, pj + 2, nb - 2); + n += 0 == memcmp (pi + 3, pj + 3, nb - 3); + n += 0 == memcmp (pi + 4, pj + 4, nb - 4); + n += 0 == memcmp (pi + 5, pj + 5, nb - 5); + n += 0 == memcmp (pi + 6, pj + 6, nb - 6); + n += 0 == memcmp (pi + 7, pj + 7, nb - 7); + n += 0 == memcmp (pi + 8, pj + 8, nb - 8); + + assert (n == 9); +} + +const int32_t a2[2] = { 1234 }; +const int32_t b2[2] = { 1234, 0 }; + +void eq_a2_b2 (void) +{ + const char *pi = (char*)&a2, *pj = (char*)&b2; + int n = 0, nb = sizeof a2; + + n += 0 == memcmp (pi, pj, nb); + n += 0 == memcmp (pi + 1, pj + 1, nb - 1); + n += 0 == memcmp (pi + 2, pj + 2, nb - 2); + n += 0 == memcmp (pi + 3, pj + 3, nb - 3); + n += 0 == memcmp (pi + 4, pj + 4, nb - 4); + n += 0 == memcmp (pi + 5, pj + 5, nb - 5); + n += 0 == memcmp (pi + 6, pj + 6, nb - 6); + n += 0 == memcmp (pi + 7, pj + 7, nb - 7); + n += 0 == memcmp (pi + 8, pj + 8, nb - 8); + + assert (n == 9); +} + + +const int32_t a5[5] = { [3] = 1234, [1] = 0 }; +const int32_t b5[5] = { 0, 0, 0, 1234 }; + +void eq_a5_b5 (void) +{ + int n = 0, b = sizeof a5; + const char *pi = (char*)a5, *pj = (char*)b5; + + n += 0 == memcmp (pi, pj, b); + n += 0 == memcmp (pi + 1, pj + 1, b - 1); + n += 0 == memcmp (pi + 2, pj + 2, b - 2); + n += 0 == memcmp (pi + 3, pj + 3, b - 3); + + n += 0 == memcmp (pi + 4, pj + 4, b - 4); + n += 0 == memcmp (pi + 5, pj + 5, b - 5); + n += 0 == memcmp (pi + 6, pj + 6, b - 6); + n += 0 == memcmp (pi + 7, pj + 7, b - 7); + + n += 0 == memcmp (pi + 8, pj + 8, b - 8); + n += 0 == memcmp (pi + 9, pj + 9, b - 9); + n += 0 == memcmp (pi + 10, pj + 10, b - 10); + n += 0 == memcmp (pi + 11, pj + 11, b - 11); + + n += 0 == memcmp (pi + 12, pj + 12, b - 12); + n += 0 == memcmp (pi + 13, pj + 13, b - 13); + n += 0 == memcmp (pi + 14, pj + 14, b - 14); + n += 0 == memcmp (pi + 15, pj + 15, b - 15); + + n += 0 == memcmp (pi + 16, pj + 16, b - 16); + n += 0 == memcmp (pi + 17, pj + 17, b - 17); + n += 0 == memcmp (pi + 18, pj + 18, b - 18); + n += 0 == memcmp (pi + 19, pj + 19, b - 19); + + assert (n == 20); +} + + +const int32_t a19[19] = { [13] = 13, [8] = 8, [4] = 4, [1] = 1 }; +const int32_t b19[19] = { 0, 1, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 0, 13 }; + +void eq_a19_b19 (void) +{ + int n = 0, b = sizeof a19; + const char *pi = (char*)a19, *pj = (char*)b19; + + n += 0 == memcmp (pi, pj, b); + n += 0 == memcmp (pi + 1, pj + 1, b - 1); + n += 0 == memcmp (pi + 2, pj + 2, b - 2); + n += 0 == memcmp (pi + 3, pj + 3, b - 3); + + n += 0 == memcmp (pi + 14, pj + 14, b - 14); + n += 0 == memcmp (pi + 15, pj + 15, b - 15); + n += 0 == memcmp (pi + 16, pj + 16, b - 16); + n += 0 == memcmp (pi + 17, pj + 17, b - 17); + + n += 0 == memcmp (pi + 28, pj + 28, b - 28); + n += 0 == memcmp (pi + 29, pj + 29, b - 29); + n += 0 == memcmp (pi + 30, pj + 30, b - 30); + n += 0 == memcmp (pi + 31, pj + 31, b - 31); + + n += 0 == memcmp (pi + 42, pj + 42, b - 42); + n += 0 == memcmp (pi + 43, pj + 43, b - 43); + n += 0 == memcmp (pi + 44, pj + 44, b - 44); + n += 0 == memcmp (pi + 45, pj + 45, b - 45); + + n += 0 == memcmp (pi + 56, pj + 56, b - 56); + n += 0 == memcmp (pi + 57, pj + 57, b - 57); + n += 0 == memcmp (pi + 58, pj + 58, b - 58); + n += 0 == memcmp (pi + 59, pj + 59, b - 59); + + assert (n == 20); +} + + +const int32_t A20[20] = { [13] = 14, [8] = 8, [4] = 4, [1] = 1 }; +const int32_t b20[20] = { 0, 1, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 0, 13 }; + +void gt_A20_b20 (void) +{ + int n = memcmp (A20, b20, sizeof A20) > 0; + assert (n == 1); +} + +const int32_t a21[21] = { [13] = 12, [8] = 8, [4] = 4, [1] = 1 }; +const int32_t B21[21] = { 0, 1, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 0, 13 }; + +void lt_a21_B21 (void) +{ + int n = memcmp (a21, B21, sizeof a21) < 0; + assert (n == 1); +} + + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcmp-3.c b/SingleSource/Regression/C/gcc-dg/memcmp-3.c new file mode 100644 index 0000000000..8ddde996c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcmp-3.c @@ -0,0 +1,350 @@ +/* PR middle-end/78257 - missing memcmp optimization with constant arrays + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } + { dg-skip-if "missing data representation" { "pdp11-*-*" } } + { dg-skip-if "test assumes structs are not packed" { default_packed } } */ + +#define offsetof(T, m) __builtin_offsetof (T, m) + +typedef __INT8_TYPE__ int8_t; +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; +typedef __INT64_TYPE__ int64_t; +typedef __SIZE_TYPE__ size_t; + +extern int memcmp (const void*, const void*, size_t); + +const int32_t ia4[4] = { 0x11121314, 0x21222324, 0x31323334, 0x41424344 }; +const int32_t ia4_des[4] = + { [2] = 0x31323334, [0] = 0x11121314, 0x21222324, [3] = 0x41424344 }; +const char ia4_rep[] = + { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + "\x11\x12\x13\x14" "\x21\x22\x23\x24" + "\x31\x32\x33\x34" "\x41\x42\x43\x44" +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + "\x14\x13\x12\x11" "\x24\x23\x22\x21" + "\x34\x33\x32\x31" "\x44\x43\x42\x41" +#endif + }; + +void eq_ia4 (void) +{ + int n = 0, b = sizeof ia4; + const char *p = (const char*)ia4, *q = ia4_rep; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + n += memcmp (p + 8, q + 8, b - 8); + n += memcmp (p + 9, q + 9, b - 9); + n += memcmp (p + 10, q + 10, b - 10); + n += memcmp (p + 11, q + 11, b - 11); + n += memcmp (p + 12, q + 12, b - 12); + n += memcmp (p + 13, q + 13, b - 13); + n += memcmp (p + 14, q + 14, b - 14); + n += memcmp (p + 15, q + 15, b - 15); + n += memcmp (p + 16, q + 16, b - 16); + + p = (const char*)ia4_des; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + n += memcmp (p + 8, q + 8, b - 8); + n += memcmp (p + 9, q + 9, b - 9); + n += memcmp (p + 10, q + 10, b - 10); + n += memcmp (p + 11, q + 11, b - 11); + n += memcmp (p + 12, q + 12, b - 12); + n += memcmp (p + 13, q + 13, b - 13); + n += memcmp (p + 14, q + 14, b - 14); + n += memcmp (p + 15, q + 15, b - 15); + n += memcmp (p + 16, q + 16, b - 16); + + if (n != 0) + __builtin_abort (); +} + +const float fa4[4] = { 1.0, 2.0, 3.0, 4.0 }; +const float fa4_des[4] = { [0] = fa4[0], [1] = 2.0, [2] = fa4[2], [3] = 4.0 }; + +void eq_fa4 (void) +{ + int n = 0, b = sizeof fa4; + const char *p = (const char*)fa4, *q = (const char*)fa4_des; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + n += memcmp (p + 8, q + 8, b - 8); + n += memcmp (p + 9, q + 9, b - 9); + n += memcmp (p + 10, q + 10, b - 10); + n += memcmp (p + 11, q + 11, b - 11); + n += memcmp (p + 12, q + 12, b - 12); + n += memcmp (p + 13, q + 13, b - 13); + n += memcmp (p + 14, q + 14, b - 14); + n += memcmp (p + 15, q + 15, b - 15); + n += memcmp (p + 16, q + 16, b - 16); + + if (n != 0) + __builtin_abort (); +} + +/* Verify "greater than" comparison with the difference in the last byte. */ +const char ia4_xrep_16[sizeof ia4] = + { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + 0x11, 0x12, 0x13, 0x14, 0x21, 0x22, 0x23, 0x24, + 0x31, 0x32, 0x33, 0x34, 0x41, 0x42, 0x43 +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + 0x14, 0x13, 0x12, 0x11, 0x24, 0x23, 0x22, 0x21, + 0x34, 0x33, 0x32, 0x31, 0x44, 0x43, 0x42 +#endif + }; + +void gt_ia4 (void) +{ + int n = 0, b = sizeof ia4; + const char *p = (const char*)ia4, *q = ia4_xrep_16; + + n += 0 < memcmp (p, q, b); + n += 0 < memcmp (p + 1, q + 1, b - 1); + n += 0 < memcmp (p + 2, q + 2, b - 2); + n += 0 < memcmp (p + 3, q + 3, b - 3); + n += 0 < memcmp (p + 4, q + 4, b - 4); + n += 0 < memcmp (p + 5, q + 5, b - 5); + n += 0 < memcmp (p + 6, q + 6, b - 6); + n += 0 < memcmp (p + 7, q + 7, b - 7); + n += 0 < memcmp (p + 8, q + 8, b - 8); + n += 0 < memcmp (p + 9, q + 9, b - 9); + n += 0 < memcmp (p + 10, q + 10, b - 10); + n += 0 < memcmp (p + 11, q + 11, b - 11); + n += 0 < memcmp (p + 12, q + 12, b - 12); + n += 0 < memcmp (p + 13, q + 13, b - 13); + n += 0 < memcmp (p + 14, q + 14, b - 14); + n += 0 < memcmp (p + 15, q + 15, b - 15); + + if (n != 16) + __builtin_abort (); +} + +struct S8_16_32 +{ + int8_t i8; + int16_t i16; + int32_t i32; +}; + +_Static_assert (sizeof (struct S8_16_32) == 8); + +const struct S8_16_32 s8_16_32 = { 1, 0x2122, 0x31323334 }; +const struct S8_16_32 s8_16_32_des = + { .i8 = 1, .i16 = 0x2122, .i32 = 0x31323334 }; + +const char s8_16_32_rep[] = + { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + 1, 0, 0x21, 0x22, 0x31, 0x32, 0x33, 0x34 +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + 1, 0, 0x22, 0x21, 0x34, 0x33, 0x32, 0x31 +#endif + }; + +void eq_s8_16_32 (void) +{ + int n = 0, b = sizeof s8_16_32; + const char *p = (char*)&s8_16_32, *q = s8_16_32_rep; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + + p = (char*)&s8_16_32_des; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + + if (n != 0) + __builtin_abort (); +} + + +struct S8_16_32_64 +{ + /* 0 */ int8_t i8; + /* 1 */ int8_t: 1; + /* 2 */ int16_t i16; + /* 4 */ int32_t: 1; + /* 8 */ int32_t i32; + /* 12 */ int32_t: 1; + /* 16 */ int64_t i64; + /* 24 */ int8_t: 0; +}; + +_Static_assert (offsetof (struct S8_16_32_64, i16) == 2); +_Static_assert (offsetof (struct S8_16_32_64, i32) == 8); +_Static_assert (offsetof (struct S8_16_32_64, i64) == 16); +_Static_assert (sizeof (struct S8_16_32_64) == 24); + +const struct S8_16_32_64 s8_16_32_64 = + { 1, 0x2122, 0x31323334, 0x4142434445464748LLU }; + +const char s8_16_32_64_rep[sizeof s8_16_32_64] = + { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + "\x01" "\x00" "\x21\x22" "\x00\x00\x00\x00" "\x31\x32\x33\x34" + "\x00\x00\x00\x00" "\x41\x42\x43\x44\x45\x46\x47\x48" +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + "\x01" "\x00" "\x22\x21" "\x00\x00\x00\x00" "\x34\x33\x32\x31" + "\x00\x00\x00\x00" "\x48\x47\x46\x45\x44\x43\x42\x41" +#endif + }; + +const struct S8_16_32_64 s8_16_32_64_des = + { .i64 = 0x4142434445464748LLU, .i16 = 0x2122, .i32 = 0x31323334, .i8 = 1 }; + + +void eq_8_16_32_64 (void) +{ + int n = 0, b = sizeof s8_16_32_64; + const char *p = (char*)&s8_16_32_64, *q = s8_16_32_64_rep; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + n += memcmp (p + 8, q + 8, b - 8); + n += memcmp (p + 9, q + 9, b - 9); + n += memcmp (p + 10, q + 10, b - 10); + n += memcmp (p + 11, q + 11, b - 11); + n += memcmp (p + 12, q + 12, b - 12); + n += memcmp (p + 13, q + 13, b - 13); + n += memcmp (p + 14, q + 14, b - 14); + n += memcmp (p + 15, q + 15, b - 15); + n += memcmp (p + 16, q + 16, b - 16); + n += memcmp (p + 17, q + 17, b - 17); + n += memcmp (p + 18, q + 18, b - 18); + n += memcmp (p + 19, q + 19, b - 19); + n += memcmp (p + 20, q + 20, b - 20); + n += memcmp (p + 21, q + 21, b - 21); + n += memcmp (p + 22, q + 22, b - 22); + n += memcmp (p + 23, q + 23, b - 23); + + p = (char*)&s8_16_32_64_des; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + n += memcmp (p + 8, q + 8, b - 8); + n += memcmp (p + 9, q + 9, b - 9); + n += memcmp (p + 10, q + 10, b - 10); + n += memcmp (p + 11, q + 11, b - 11); + n += memcmp (p + 12, q + 12, b - 12); + n += memcmp (p + 13, q + 13, b - 13); + n += memcmp (p + 14, q + 14, b - 14); + n += memcmp (p + 15, q + 15, b - 15); + n += memcmp (p + 16, q + 16, b - 16); + n += memcmp (p + 17, q + 17, b - 17); + n += memcmp (p + 18, q + 18, b - 18); + n += memcmp (p + 19, q + 19, b - 19); + n += memcmp (p + 20, q + 20, b - 20); + n += memcmp (p + 21, q + 21, b - 21); + n += memcmp (p + 22, q + 22, b - 22); + n += memcmp (p + 23, q + 23, b - 23); + + if (n != 0) + __builtin_abort (); +} + +struct S64_x_3 +{ + int64_t i64a[3]; +}; + +_Static_assert (sizeof (struct S64_x_3) == 24); + +const struct S64_x_3 s64_x_3 = + { { 0x0000000021220001LLU, 0x0000000031323334LLU, 0x4142434445464748LLU } }; + +const char s64_x_3_rep[sizeof s64_x_3] = + { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + "\x00\x00\x00\x00\x21\x22\x00\x01" + "\x00\x00\x00\x00\x31\x32\x33\x34" + "\x41\x42\x43\x44\x45\x46\x47\x48" +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + "\x01\x00\x22\x21\x00\x00\x00\x00" + "\x34\x33\x32\x31\x00\x00\x00\x00" + "\x48\x47\x46\x45\x44\x43\x42\x41" +#endif + }; + +void eq_64_x_3 (void) +{ + int n = 0, b = sizeof s8_16_32_64; + const char *p = (char*)&s8_16_32_64, *q = s64_x_3_rep; + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + n += memcmp (p + 8, q + 8, b - 8); + n += memcmp (p + 9, q + 9, b - 9); + n += memcmp (p + 10, q + 10, b - 10); + n += memcmp (p + 11, q + 11, b - 11); + n += memcmp (p + 12, q + 12, b - 12); + n += memcmp (p + 13, q + 13, b - 13); + n += memcmp (p + 14, q + 14, b - 14); + n += memcmp (p + 15, q + 15, b - 15); + n += memcmp (p + 16, q + 16, b - 16); + n += memcmp (p + 17, q + 17, b - 17); + n += memcmp (p + 18, q + 18, b - 18); + n += memcmp (p + 19, q + 19, b - 19); + n += memcmp (p + 20, q + 20, b - 20); + n += memcmp (p + 21, q + 21, b - 21); + n += memcmp (p + 22, q + 22, b - 22); + n += memcmp (p + 23, q + 23, b - 23); + + if (n != 0) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcmp-4.c b/SingleSource/Regression/C/gcc-dg/memcmp-4.c new file mode 100644 index 0000000000..bbac719750 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcmp-4.c @@ -0,0 +1,81 @@ +/* PR middle-end/78257 - missing memcmp optimization with constant arrays + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } */ + +typedef __INT8_TYPE__ int8_t; +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; +typedef __SIZE_TYPE__ size_t; + +extern int memcmp (const void*, const void*, size_t); + +/* Verify that initializers for flexible array members are handled + correctly. */ + +struct Si16_x +{ + int16_t n, a[]; +}; + +const struct Si16_x si16_4 = + { + 0x1112, { 0x2122, 0x3132, 0x4142 } + }; + +const char si16_4_rep[] = + { + 0x12, 0x11, 0x22, 0x21, 0x32, 0x31, 0x42, 0x41 + }; + +void eq_si16_x (void) +{ + int n = 0, b = sizeof si16_4_rep; + const char *p = (const char*)&si16_4, *q = si16_4_rep; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + n += memcmp (p + 8, q + 8, b - 8); + + p = (const char*)&si16_4.n; + + n += memcmp (p, q, b); + n += memcmp (p + 1, q + 1, b - 1); + n += memcmp (p + 2, q + 2, b - 2); + n += memcmp (p + 3, q + 3, b - 3); + n += memcmp (p + 4, q + 4, b - 4); + n += memcmp (p + 5, q + 5, b - 5); + n += memcmp (p + 6, q + 6, b - 6); + n += memcmp (p + 7, q + 7, b - 7); + n += memcmp (p + 8, q + 8, b - 8); + + p = (const char*)si16_4.a; + q = si16_4_rep + 2; + + n += memcmp (p, q, b - 2); + n += memcmp (p + 1, q + 1, b - 3); + n += memcmp (p + 2, q + 2, b - 4); + n += memcmp (p + 3, q + 3, b - 5); + n += memcmp (p + 4, q + 4, b - 6); + n += memcmp (p + 5, q + 5, b - 7); + n += memcmp (p + 6, q + 6, b - 8); + + p = (const char*)&si16_4.a[1]; + q = si16_4_rep + 4; + + n += memcmp (p, q, b - 4); + n += memcmp (p + 1, q + 1, b - 5); + n += memcmp (p + 2, q + 2, b - 6); + n += memcmp (p + 3, q + 3, b - 7); + n += memcmp (p + 4, q + 4, b - 8); + + if (n != 0) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcmp-5.c b/SingleSource/Regression/C/gcc-dg/memcmp-5.c new file mode 100644 index 0000000000..34bae92f6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcmp-5.c @@ -0,0 +1,72 @@ +/* PR middle-end/78257 - missing memcmp optimization with constant arrays + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } */ + +#define A "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \ + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \ + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \ + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \ + "0" + +const char a257[sizeof A - 1] = A; +const char a258[sizeof A] = A; + +_Static_assert (sizeof A == 258); +_Static_assert (sizeof a257 == 257); + +/* Verify that initializers longer than 256 characters (an internal limit + on the size of a buffer used to store representations in) are handled. */ + +void eq_256plus (void) +{ + int n = 0; + + n += __builtin_memcmp (a257, A, sizeof a257); + n += __builtin_memcmp (a257 + 1, A + 1, sizeof a257 - 1); + n += __builtin_memcmp (a257 + 2, A + 2, sizeof a257 - 2); + n += __builtin_memcmp (a257 + 127, A + 127, sizeof a257 - 127); + n += __builtin_memcmp (a257 + 128, A + 128, sizeof a257 - 128); + n += __builtin_memcmp (a257 + 255, A + 255, 2); + n += __builtin_memcmp (a257 + 256, A + 256, 1); + + n += __builtin_memcmp (a258, A, sizeof a257); + n += __builtin_memcmp (a258 + 1, A + 1, sizeof a257 - 1); + n += __builtin_memcmp (a258 + 2, A + 2, sizeof a257 - 2); + n += __builtin_memcmp (a258 + 127, A + 127, sizeof a257 - 127); + n += __builtin_memcmp (a258 + 128, A + 128, sizeof a257 - 128); + n += __builtin_memcmp (a258 + 256, A + 256, 2); + n += __builtin_memcmp (a258 + 257, A + 257, 1); + + if (n) + __builtin_abort (); +} + +#define X "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \ + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \ + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \ + "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \ + "1" + +void lt_256plus (void) +{ + int n = 0; + + n += 0 > __builtin_memcmp (a257, X, sizeof a257); + n += 0 > __builtin_memcmp (a257 + 1, X + 1, sizeof a257 - 1); + n += 0 > __builtin_memcmp (a257 + 2, X + 2, sizeof a257 - 2); + n += 0 > __builtin_memcmp (a257 + 127, X + 127, sizeof a257 - 127); + n += 0 > __builtin_memcmp (a257 + 128, X + 128, sizeof a257 - 128); + n += 0 > __builtin_memcmp (a257 + 255, X + 255, 2); + n += 0 > __builtin_memcmp (a257 + 256, X + 256, 1); + + n += 0 > __builtin_memcmp (a258, X, sizeof a258); + n += 0 > __builtin_memcmp (a258 + 1, X + 1, sizeof a258 - 1); + n += 0 > __builtin_memcmp (a258 + 2, X + 2, sizeof a258 - 2); + n += 0 > __builtin_memcmp (a258 + 127, X + 127, sizeof a257 - 127); + n += 0 > __builtin_memcmp (a258 + 128, X + 128, sizeof a257 - 128); + n += 0 > __builtin_memcmp (a258 + 256, X + 256, 2); + n += 0 == __builtin_memcmp (a258 + 257, X + 257, 1); + + if (n != 14) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/memcmp-6.c b/SingleSource/Regression/C/gcc-dg/memcmp-6.c new file mode 100644 index 0000000000..d57352616c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcmp-6.c @@ -0,0 +1,47 @@ +/* PR tree-optimization/96670 - ICE on memchr with an empty initializer + { dg-do compile } + { dg-options "-O -Wall -fdump-tree-optimized" } */ + +struct { + int i, j; +} const s = { }; + +const char a[sizeof s] = { }; + +void memcmp_success_unused (void) +{ + int n = (char *)&s.j - (char *)&s; + char *p = (char *)&s; + __builtin_memcmp (p, a, n); + __builtin_memcmp (a, p, n); +} + +void memcmp_success_used (void) +{ + int n = (char *)&s.j - (char *)&s; + char *p = (char *)&s; + if (__builtin_memcmp (p, a, n) + || __builtin_memcmp (a, p, n)) + __builtin_abort (); +} + +void memcmp_fail_unused (void) +{ + int n = (char *)&s.j - (char *)&s; + char *p = (char *)&s; + __builtin_memcmp (p, a, n); + __builtin_memcmp (a, p, n); +} + +void memcmp_fail_used (void) +{ + int n = (char *)&s.j - (char *)&s; + char *p = (char *)&s; + if (__builtin_memcmp (p, a, n) + || __builtin_memcmp (a, p, n)) + __builtin_abort (); +} + +/* { dg-prune-output "\\\[-Wunused-value" } + { dg-final { scan-tree-dump-not "abort" "optimized" } } + { dg-final { scan-tree-dump-not "memcmp \\\(" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcmp-pr95189.c b/SingleSource/Regression/C/gcc-dg/memcmp-pr95189.c new file mode 100644 index 0000000000..d8250ecfc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcmp-pr95189.c @@ -0,0 +1,28 @@ +/* PR middle-end/95189 - memcmp being wrongly stripped like strcmp + { dg-do run } + { dg-options "-O2 -Wall" } */ + +char a4[] = "\0abc"; +char a8[] = "\0abcdefg"; +char a16[] = "\0abcdefghijklmno"; + +int cmp4 (void) +{ + return __builtin_memcmp (a4, "\0\0\0\0", 4); +} + +int cmp8 (void) +{ + return __builtin_memcmp (a8, "\0\0\0\0\0\0\0\0", 8); +} + +int cmp16 (void) +{ + return __builtin_memcmp (a16, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16); +} + +int main (void) +{ + if (cmp4 () < 1 || cmp8 () < 1 || cmp16 () < 1) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/memcpy-1.c b/SingleSource/Regression/C/gcc-dg/memcpy-1.c new file mode 100644 index 0000000000..7c0f9449ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcpy-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* PR36598 AVR fail maybe due to cost metrics */ +/* { dg-final { scan-tree-dump-times "nasty_local\\." 0 "optimized" { xfail { "avr-*-*" } } } } */ +struct a {int a,b,c;} a; +int test(struct a a) +{ +struct a nasty_local; +__builtin_memcpy (&nasty_local,&a, sizeof(a)); +return nasty_local.a; +} diff --git a/SingleSource/Regression/C/gcc-dg/memcpy-2.c b/SingleSource/Regression/C/gcc-dg/memcpy-2.c new file mode 100644 index 0000000000..6ad887416e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcpy-2.c @@ -0,0 +1,25 @@ +/* PR middle-end/38454 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dse" } */ + +typedef __SIZE_TYPE__ size_t; + +extern inline __attribute__((gnu_inline, always_inline, artificial)) void * +memcpy (void *__restrict dest, const void *__restrict src, size_t len) +{ + return __builtin___memcpy_chk (dest, /* { dg-warning "writing" } */ + src, len, __builtin_object_size (dest, 0)); +} + +struct S { char buf[10]; } s; + +void +foo (void) +{ + char buf[12]; + char *p = buf + 4; + struct S *q = (struct S *) p; + memcpy (q, &s, sizeof (s)); +} + +/* { dg-final { scan-assembler "__memcpy_chk" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcpy-3.c b/SingleSource/Regression/C/gcc-dg/memcpy-3.c new file mode 100644 index 0000000000..686668de10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcpy-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ +/* { dg-require-effective-target non_strict_align } */ + +int get_int(const void *p) +{ + int w; + __builtin_memcpy(&w, p, sizeof (int)); + return w; +} + +/* { dg-final { scan-tree-dump-not "memcpy" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "MEM" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcpy-4.c b/SingleSource/Regression/C/gcc-dg/memcpy-4.c new file mode 100644 index 0000000000..4c726f0ad7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcpy-4.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-expand" } */ + +#ifdef __mips +__attribute__((nomips16)) +#endif +void +f1 (char *p) +{ + __builtin_memcpy (p, "12345", 5); +} + +/* { dg-final { scan-rtl-dump "mem/u.*mem/u" "expand" { target mips*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcpy-5.c b/SingleSource/Regression/C/gcc-dg/memcpy-5.c new file mode 100644 index 0000000000..92788a5969 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcpy-5.c @@ -0,0 +1,27 @@ +/* { dg-options "-O -fdump-tree-optimized" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +extern void *memcpy (void *, const void *, __SIZE_TYPE__); + +#define TEST(NAME, TYPE) \ + TYPE NAME##x; \ + char NAME##y[sizeof (NAME##x)] __attribute__((aligned (__alignof__ (NAME##x)))); \ + void NAME (void) { memcpy (&NAME##x, &NAME##y, sizeof (NAME##x)); } + +TEST (f, float); +TEST (d, double); +TEST (ld, long double); +TEST (cf, _Complex float); +TEST (cd, _Complex double); +TEST (cld, _Complex long double); +TEST (d8f, float __attribute__((vector_size (8)))); +TEST (d16f, float __attribute__((vector_size (16)))); +TEST (d32f, float __attribute__((vector_size (32)))); +TEST (d64f, float __attribute__((vector_size (64)))); +TEST (d128f, float __attribute__((vector_size (128)))); +TEST (d16d, double __attribute__((vector_size (16)))); +TEST (d32d, double __attribute__((vector_size (32)))); +TEST (d64d, double __attribute__((vector_size (64)))); +TEST (d128d, double __attribute__((vector_size (128)))); + +/* { dg-final { scan-tree-dump-not "memcpy" "optimized" { target i?86-*-* x86_64-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memcpy-6.c b/SingleSource/Regression/C/gcc-dg/memcpy-6.c new file mode 100644 index 0000000000..d4df03903c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memcpy-6.c @@ -0,0 +1,45 @@ +/* Test to verify that overlapping memcpy with const sizes that are powers + of two are folded into into the same code as memmove, but that they + are diagnosed nonetheless. Whether a call is folded depends on + the size of the copy, the alignment, and wheteber else the target + might decide to consider. The test is only run on a small subset + of targets where it's known to pass (see PR testsuite/83483). + { dg-do compile } + { dg-options "-O0 -Wrestrict -fdump-tree-optimized" } + { dg-skip-if "skip non-x86 targets" { ! { i?86-*-* x86_64-*-* } } } + { dg-additional-options "-msse" { target i?86-*-* x86_64-*-* } } */ + +char a[32]; + +void fold_copy_2 (void) +{ + __builtin_memcpy (a + 1, a, 2); /* { dg-warning "\\\[-Wrestrict]" } */ +} + +void fold_copy_4 (void) +{ + __builtin_memcpy (a + 2, a, 4); /* { dg-warning "\\\[-Wrestrict]" } */ +} + +void fold_copy_8 (void) +{ + __builtin_memcpy (a + 3, a, 8); /* { dg-warning "\\\[-Wrestrict]" } */ +} + +void fold_move_2 (void) +{ + __builtin_memmove (a + 1, a, 2); +} + +void fold_move_4 (void) +{ + __builtin_memmove (a + 2, a, 4); +} + +void fold_move_8 (void) +{ + __builtin_memmove (a + 3, a, 8); +} + +/* { dg-final { scan-tree-dump-not "memcpy" "optimized" } } + { dg-final { scan-tree-dump-not "memmove" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memmove-1.c b/SingleSource/Regression/C/gcc-dg/memmove-1.c new file mode 100644 index 0000000000..e22a807609 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memmove-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "memmove" 0 "optimized" } } */ +static const char a[100]={1,2,3,4}; +char b[1000]; +int i,i1; +static inline void +__attribute__ ((always_inline)) +domem (void *dest, const void *src, int len) +{ + __builtin_memmove (dest, src, len); +} +int +t() +{ + domem (b,a,100); + domem (b+i1,(const void *)b,1); +} diff --git a/SingleSource/Regression/C/gcc-dg/memmove-2.c b/SingleSource/Regression/C/gcc-dg/memmove-2.c new file mode 100644 index 0000000000..9d9c8c91fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memmove-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "memmove" 0 "optimized" } } */ + +char a[40]; +extern void bar (char *); + +void +foo (void) +{ + char b[10]; + __builtin_memmove (&a[0], &a[20], 20); + __builtin_memmove (&b[1], &a[25], 9); + bar (b); +} diff --git a/SingleSource/Regression/C/gcc-dg/memmove-3.c b/SingleSource/Regression/C/gcc-dg/memmove-3.c new file mode 100644 index 0000000000..6c786edb95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memmove-3.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "memmove" 3 "optimized" } } */ + +char a[40]; +struct A { char a[30]; }; + +void +foo (struct A *p, char *q, char *r) +{ + char b[10]; + __builtin_memmove (&a[1], &a[19], 20); + __builtin_memmove (&p->a[1], &p->a[9], 10); + __builtin_memmove (q, r, 9); +} diff --git a/SingleSource/Regression/C/gcc-dg/memmove-4.c b/SingleSource/Regression/C/gcc-dg/memmove-4.c new file mode 100644 index 0000000000..5949aaa30c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memmove-4.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +typedef int w __attribute__((mode(word))); + +void b(char *a, char *b, int i) +{ + __builtin_memmove (&a[i], &b[i], sizeof(w)); +} + +/* { dg-final { scan-tree-dump-not "memmove" "optimized" { xfail { ! non_strict_align } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/memset-1.c b/SingleSource/Regression/C/gcc-dg/memset-1.c new file mode 100644 index 0000000000..677ae91bd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memset-1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void warn_memset_zero_len (void) +__attribute__((__warning__ ("memset used with constant zero length parameter;" + " this could be due to transposed parameters"))); + +extern inline __attribute__((gnu_inline, always_inline, artificial)) void * +memset (void *dest, int ch, size_t len) +{ + if (__builtin_constant_p (len) && len == 0) + { + warn_memset_zero_len (); /* { dg-warning "memset used with constant zero" } */ + return dest; + } + return __builtin_memset (dest, ch, len); +} + +char buf[10]; + +int +main (void) +{ + memset (buf, sizeof (buf), 0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/memset-2.c b/SingleSource/Regression/C/gcc-dg/memset-2.c new file mode 100644 index 0000000000..fb4debc6d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/memset-2.c @@ -0,0 +1,11 @@ +/* PR target/63937 */ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O2" } */ + +void +foo (char *p) +{ + p = __builtin_assume_aligned (p, 64); + __builtin_memset (p, 0, 0x100000001ULL); +} + diff --git a/SingleSource/Regression/C/gcc-dg/merge-all-constants-1.c b/SingleSource/Regression/C/gcc-dg/merge-all-constants-1.c new file mode 100644 index 0000000000..53f6c4d0a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/merge-all-constants-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-w -O2 -fmerge-all-constants" } */ + +const char str1[36] = "\000123456789abcdefghijklmnopqrstuvwxyz"; +const char str2[38] = "0123456789abcdefghijklmnopqrstuvwxyz"; +const char str3[10] = "\000123456789abcdefghijklmnopqrstuvwxyz"; + +/* { dg-final { scan-assembler-not "\\.rodata\\.str" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/merge-all-constants-2.c b/SingleSource/Regression/C/gcc-dg/merge-all-constants-2.c new file mode 100644 index 0000000000..852d35e33c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/merge-all-constants-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target string_merging } */ +/* { dg-options "-w -O2 -fmerge-all-constants" } */ + +const char str1[36] = "0123456789abcdefghijklmnopqrstuvwxyz"; +const char str2[37] = "0123456789abcdefghijklmnopqrstuvwxyz"; +const char str3[10] = "0123456789abcdefghijklmnopqrstuvwxyz"; + +/* { dg-final { scan-assembler-not "\\.rodata\[\n\r\]" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/min.c b/SingleSource/Regression/C/gcc-dg/min.c new file mode 100644 index 0000000000..d8472702e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/min.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +static inline int +min (int a, int b) +{ + return a < b ? a : b; +} + +int +test_00 (int a) +{ + return min (a, a + 8); +} + +int +test_01 (int a) +{ + return min (a, a - 8); +} + +/* { dg-final { scan-tree-dump-not "MIN_EXPR" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/minmax-1.c b/SingleSource/Regression/C/gcc-dg/minmax-1.c new file mode 100644 index 0000000000..6c02ed8edd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/minmax-1.c @@ -0,0 +1,82 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-original" } */ + +/* Check that MIN-MAX and MAX-MIN combinations are folded. */ + +extern void abort (void); + +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#define MAX(a,b) ((a) > (b) ? (a) : (b)) + +int f1(int a, int b) +{ + return MIN (MAX (a, b), b); /* == b */ +} + +int f2(int a, int b) +{ + return MAX (MIN (a, b), b); /* == b */ +} + +int f3(int a, int b) +{ + return MIN (MAX (b, a), b); /* == b */ +} + +int f4(int a, int b) +{ + return MAX (MIN (b, a), b); /* == b */ +} + + +int g1(int a, int b) +{ + return MIN (a, MAX (a, b)); /* == a */ +} + +int g2(int a, int b) +{ + return MAX (a, MIN (a, b)); /* == a */ +} + +int g3(int a, int b) +{ + return MIN (a, MAX (b, a)); /* == a */ +} + +int g4(int a, int b) +{ + return MAX (a, MIN (b, a)); /* == a */ +} + +int main(void) +{ + if (f1 (1, 2) != 2) + abort (); + + if (f2 (1, 2) != 2) + abort (); + + if (f3 (1, 2) != 2) + abort (); + + if (f4 (1, 2) != 2) + abort (); + + if (g1 (1, 2) != 1) + abort (); + + if (g2 (1, 2) != 1) + abort (); + + if (g3 (1, 2) != 1) + abort (); + + if (g4 (1, 2) != 1) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "original"} } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "original"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/misaligned-expand-1.c b/SingleSource/Regression/C/gcc-dg/misaligned-expand-1.c new file mode 100644 index 0000000000..b799b6b87c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/misaligned-expand-1.c @@ -0,0 +1,41 @@ +/* Test that expand can generate correct loads of misaligned data even on + strict alignment platforms. */ + +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +extern void abort (); + +typedef unsigned int myint __attribute__((aligned(1))); + +unsigned int +foo (myint *p) +{ + return *p; +} + +#define cst (int) 0xdeadbeef +#define NUM 8 + +struct blah +{ + char c; + myint i[NUM]; +}; + +struct blah g; + +int +main (int argc, char **argv) +{ + int i, k; + for (k = 0; k < NUM; k++) + { + g.i[k] = cst; + i = foo (&g.i[k]); + + if (i != cst) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/misaligned-expand-2.c b/SingleSource/Regression/C/gcc-dg/misaligned-expand-2.c new file mode 100644 index 0000000000..7f6c6d19a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/misaligned-expand-2.c @@ -0,0 +1,40 @@ +/* Test that expand can generate correct stores to misaligned data even on + strict alignment platforms. */ + +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +extern void abort (); + +typedef unsigned int myint __attribute__((aligned(1))); + +void +foo (myint *p, unsigned int i) +{ + *p = i; +} + +#define cst (int) 0xdeadbeef +#define NUM 8 + +struct blah +{ + char c; + myint i[NUM]; +}; + +struct blah g; + +int +main (int argc, char **argv) +{ + int k; + + for (k = 0; k < NUM; k++) + { + foo (&g.i[k], cst); + if (g.i[k] != cst) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/misaligned-expand-3.c b/SingleSource/Regression/C/gcc-dg/misaligned-expand-3.c new file mode 100644 index 0000000000..5b1c7e7e07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/misaligned-expand-3.c @@ -0,0 +1,43 @@ +/* Test that expand can generate correct stores to misaligned data of complex + type even on strict alignment platforms. */ + +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +extern void abort (); + +typedef _Complex float mycmplx __attribute__((aligned(1))); + +void +foo (mycmplx *p, float r, float i) +{ + __real__ *p = r; + __imag__ *p = i; +} + +#define cvr 3.2f +#define cvi 2.5f +#define NUM 8 + +struct blah +{ + char c; + mycmplx x[NUM]; +} __attribute__((packed)); + +struct blah g; + +int +main (int argc, char **argv) +{ + int k; + + for (k = 0; k < NUM; k++) + { + foo (&g.x[k], cvr, cvi); + if (__real__ g.x[k] != cvr + || __imag__ g.x[k] != cvi) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/misc-column.c b/SingleSource/Regression/C/gcc-dg/misc-column.c new file mode 100644 index 0000000000..7dc6e58ec0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/misc-column.c @@ -0,0 +1,40 @@ +/* { dg-options "-fshow-column -Wall -Wfloat-equal -pedantic" } */ + +int i, j; +float a, b; + +int *p; +struct { + int a; + char b; +} *q; + +extern void bar(); + +void foo (void) +{ + if (a == b) /* { dg-warning "9:comparing floating-point with" } */ + bar (); + + if (p < q) /* { dg-warning "9:comparison of distinct pointer types" } */ + bar (); + + if (&p == 0) /* { dg-warning "10:comparison will always evaluate as 'false'" } */ + bar(); + + if (p == 4) /* { dg-warning "9:comparison between pointer and integer" } */ + bar(); + + if (p < 0) /* { dg-warning "9:ordered comparison of pointer with" } */ + bar(); + + -q; /* { dg-error "3:wrong type argument to unary" } */ + + ~q; /* { dg-error "3:wrong type argument to bit" } */ + + ++*q; /* { dg-error "3:wrong type argument to increment" } */ + + i = j / 0; /* { dg-warning "9:division by zero" } */ + + i /= 0; /* { dg-warning "5:division by zero" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/mismatch-decl-1.c b/SingleSource/Regression/C/gcc-dg/mismatch-decl-1.c new file mode 100644 index 0000000000..b6dd5431a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/mismatch-decl-1.c @@ -0,0 +1,22 @@ +/* This test assumes -fbuiltin and not -fansi to get "index" and "memchr" builtin DECLs. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* The bug this is testing is that if a new decl conflicts with an + explicit decl, you don't get the "changes type of builtin" message, + but if there was *also* a builtin, you *also* don't get the "previous + declaration" message, leaving you with no clue where the previous + declaration came from. */ + +extern char foo(int,int); /* { dg-message "previous declaration of 'foo'" "note" } */ +extern char *index(const char *,int); /* { dg-message "previous declaration of 'index'" "note" } */ + +/* This changes the type of "index", which is both a builtin and an + explicit decl. */ +int index; /* { dg-error "redeclared as different kind of symbol" } */ + +/* This changes the type of "memchr", which is only a builtin. */ +int memchr; /* { dg-warning "built-in function 'memchr' declared as non-function" } */ + +/* This changes the type of "foo", which is only an explicit decl. */ +int foo; /* { dg-error "redeclared as different kind of symbol" } */ diff --git a/SingleSource/Regression/C/gcc-dg/missing-field-init-1.c b/SingleSource/Regression/C/gcc-dg/missing-field-init-1.c new file mode 100644 index 0000000000..5f32b021f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-field-init-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Wextra -Wno-missing-field-initializers -std=c99" } */ + +struct s { int a, b, c; }; +struct s s1 = { 1, 2, 3 }; +struct s s2 = { 1, 2 }; /* { dg-bogus "missing initializer" } */ +struct s s3[] = { { 1, 2 }, { 4, 5 } }; /* { dg-bogus "missing initializer" } */ +struct s s4[] = { 1, 2, 3, 4, 5 }; /* { dg-bogus "missing initializer" } */ +struct s s5[] = { 1, 2, 3, 4, 5, 6 }; +struct s s6 = { .a = 1 }; /* { dg-bogus "missing initializer" } */ diff --git a/SingleSource/Regression/C/gcc-dg/missing-field-init-2.c b/SingleSource/Regression/C/gcc-dg/missing-field-init-2.c new file mode 100644 index 0000000000..c5a3f49038 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-field-init-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-field-initializers -std=c99" } */ + +struct s { int a, b, c; }; +struct s s1 = { 1, 2, 3 }; +struct s s2 = { 1, 2 }; /* { dg-warning "(missing initializer)|(near initialization)" } */ +struct s s3[] = { { 1, 2 }, { 4, 5 } }; /* { dg-warning "(missing initializer)|(near initialization)" } */ +struct s s4[] = { 1, 2, 3, 4, 5 }; /* { dg-warning "(missing initializer)|(near initialization)" } */ +struct s s5[] = { 1, 2, 3, 4, 5, 6 }; +/* Designated initializers produce no warning. */ +struct s s6 = { .a = 1 }; /* { dg-bogus "missing initializer" } */ +/* Allow zero-initializing with "= { 0 }". */ +struct s s7 = { 0 }; /* { dg-bogus "missing initializer" } */ +struct s s8 = { 1 }; /* { dg-warning "(missing initializer)|(near initialization)" } */ diff --git a/SingleSource/Regression/C/gcc-dg/missing-header-fixit-1.c b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-1.c new file mode 100644 index 0000000000..2b28357e1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-1.c @@ -0,0 +1,36 @@ +/* Example of a fix-it hint that adds a #include directive, + adding them to the top of the file, given that there is no + pre-existing #include. */ + +/* This is padding (to avoid the generated patch containing DejaGnu + directives). */ + +/* { dg-options "-fdiagnostics-generate-patch" } */ + +void test (int i, int j) +{ + printf ("%i of %i\n", i, j); /* { dg-warning "implicit declaration" } */ + /* { dg-message "include '' or provide a declaration of 'printf'" "" { target *-*-* } .-1 } */ +} + +/* Verify the output from -fdiagnostics-generate-patch. + We expect the patch to begin with a header, containing this + source filename, via an absolute path. + Given the path, we can only capture it via regexps. */ +/* { dg-regexp "\\-\\-\\- .*" } */ +/* { dg-regexp "\\+\\+\\+ .*" } */ +/* Use #if 0/#endif rather than comments, to allow the text to contain + a comment. */ +#if 0 +{ dg-begin-multiline-output "" } +@@ -1,3 +1,4 @@ ++#include + /* Example of a fix-it hint that adds a #include directive, + adding them to the top of the file, given that there is no + pre-existing #include. */ +{ dg-end-multiline-output "" } +#endif + +/* FIXME: should we attempt to skip leading comments when determining the + insertion location? + Similarly, should we attempt to be within single-inclusion guards, etc? */ diff --git a/SingleSource/Regression/C/gcc-dg/missing-header-fixit-2.c b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-2.c new file mode 100644 index 0000000000..5d5f87488f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-2.c @@ -0,0 +1,31 @@ +/* Verify that when we suggest adding #include directives that they + are added to the affected file. */ + +/* The following header file is missing a "#include ". */ + +#include "missing-header-fixit-2.h" + +/* These directives actually apply to the header. */ +/* { dg-warning "implicit declaration of function 'printf'" "" { target *-*-* } 6 } */ +/* { dg-warning "incompatible implicit declaration of built-in function 'printf'" "" { target *-*-* } 6 } */ + +/* { dg-options "-fdiagnostics-generate-patch" } */ + +/* Verify the output from -fdiagnostics-generate-patch. + We expect the patch to begin with a header, containing the + filename of the header, via an absolute path. + Given the path, we can only capture it via regexps. */ +/* { dg-regexp "\\-\\-\\- .*" } */ +/* { dg-regexp "\\+\\+\\+ .*" } */ +/* Use #if 0/#endif rather than comments, to allow the text to contain + a comment. + We expect the *header* to have been patched, adding the missing include. */ +#if 0 +{ dg-begin-multiline-output "" } +@@ -1,3 +1,4 @@ ++#include + /* This is missing-header-fixit-2.h, for use by + missing-header-fixit-2.c */ + +{ dg-end-multiline-output "" } +#endif diff --git a/SingleSource/Regression/C/gcc-dg/missing-header-fixit-2.h b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-2.h new file mode 100644 index 0000000000..c0bf55dcbe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-2.h @@ -0,0 +1,7 @@ +/* This is missing-header-fixit-2.h, for use by + missing-header-fixit-2.c */ + +void test (int i, int j) +{ + printf ("%i of %i\n", i, j); +} diff --git a/SingleSource/Regression/C/gcc-dg/missing-header-fixit-3.c b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-3.c new file mode 100644 index 0000000000..8394010c1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-3.c @@ -0,0 +1,21 @@ +/* Example of a fix-it hint that adds a #include directive, + adding them to the top of the file, given that there is no + pre-existing #include. */ + +/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-show-line-numbers -Wno-implicit-function-declaration" } */ + +void test (int i, int j) +{ + printf ("%i of %i\n", i, j); /* { dg-warning "implicit declaration" } */ + /* { dg-message "include '' or provide a declaration of 'printf'" "" { target *-*-* } 1 } */ +#if 0 +/* { dg-begin-multiline-output "" } + 9 | printf ("%i of %i\n", i, j); + | ^~~~~~ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + +++ |+#include + 1 | /* Example of a fix-it hint that adds a #include directive, + { dg-end-multiline-output "" } */ +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/missing-header-fixit-4.c b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-4.c new file mode 100644 index 0000000000..b6680563dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-4.c @@ -0,0 +1,27 @@ +/* Example of a fix-it hint that adds a #include directive, + adding them after a pre-existing #include directive. */ +#include "empty.h" +int the_next_line; + +/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-show-line-numbers" } */ + +void test (int i, int j) +{ + printf ("%i of %i\n", i, j); /* { dg-line printf } */ + /* { dg-warning "implicit declaration of function" "" { target *-*-* } printf } */ + /* { dg-begin-multiline-output "" } + 10 | printf ("%i of %i\n", i, j); + | ^~~~~~ + { dg-end-multiline-output "" } */ + /* { dg-warning "incompatible implicit declaration" "" { target *-*-* } printf } */ + /* { dg-begin-multiline-output "" } + 10 | printf ("%i of %i\n", i, j); + | ^~~~~~ + { dg-end-multiline-output "" } */ + /* { dg-message "include '' or provide a declaration of 'printf'" "" { target *-*-* } 4 } */ + /* { dg-begin-multiline-output "" } + 3 | #include "empty.h" + +++ |+#include + 4 | int the_next_line; + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/missing-header-fixit-5.c b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-5.c new file mode 100644 index 0000000000..bf44feb24a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-header-fixit-5.c @@ -0,0 +1,42 @@ + +/* Forget to include any standard headers, all for built-in functions. + Rely on -Wimplicit-function-declaration for fixit hints, not on + -Wbuiltin-declaration-mismatch (which misses abs, isdigit, putchar). */ + +/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-show-line-numbers -Wimplicit-function-declaration -Wno-builtin-declaration-mismatch" } */ + +int +foo (char *m, int i) +{ + if (isdigit (m[0])) /* { dg-warning "implicit declaration of function" } */ + /* { dg-begin-multiline-output "" } + 11 | if (isdigit (m[0])) + | ^~~~~~~ + { dg-end-multiline-output "" } */ + /* { dg-begin-multiline-output "" } + +++ |+#include + 1 | + { dg-end-multiline-output "" } */ + { + return abs (i); /* { dg-warning "implicit declaration of function" } */ + /* { dg-begin-multiline-output "" } + 21 | return abs (i); + | ^~~ + { dg-end-multiline-output "" } */ + /* { dg-begin-multiline-output "" } + +++ |+#include + 1 | + { dg-end-multiline-output "" } */ + } + else + putchar (m[0]); /* { dg-warning "implicit declaration of function" } */ + /* { dg-begin-multiline-output "" } + 32 | putchar (m[0]); + | ^~~~~~~ + { dg-end-multiline-output "" } */ + /* { dg-begin-multiline-output "" } + +++ |+#include + 1 | + { dg-end-multiline-output "" } */ + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/missing-symbol-2.c b/SingleSource/Regression/C/gcc-dg/missing-symbol-2.c new file mode 100644 index 0000000000..7ee795dfcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-symbol-2.c @@ -0,0 +1,71 @@ +/* { dg-options "-fdiagnostics-show-caret -Wno-switch-unreachable" } */ + +extern int foo (void); + +void missing_open_paren (void) +{ + if foo ()) /* { dg-line missing_open_paren } */ + { + } + /* { dg-error "expected '\\(' before 'foo'" "" { target c } missing_open_paren } */ + /* { dg-begin-multiline-output "" } + if foo ()) + ^~~ + ( + { dg-end-multiline-output "" } */ + /* { dg-error "expected statement before '\\)' token" "" { target c } missing_open_paren } */ + /* { dg-begin-multiline-output "" } + if foo ()) + ^ + { dg-end-multiline-output "" } */ +} + +void missing_close_square (void) +{ + const char test [42; /* { dg-error "22: expected ']' before ';' token" } */ + /* { dg-begin-multiline-output "" } + const char test [42; + ^ + ] + { dg-end-multiline-output "" } */ +} + +int missing_semicolon (void) +{ + return 42 /* { dg-error "expected ';'" } */ +} +/* { dg-begin-multiline-output "" } + return 42 + ^ + ; + } + ~ + { dg-end-multiline-output "" } */ + + +/* We don't offer a fix-it hint for this case in C, as it could be + colon or ellipsis. + TODO: we could be smarter about error-recovery here; given the + return perhaps we could assume a missing colon. */ + +int missing_colon_in_switch (int val) +{ + switch (val) + { + case 42 + return 42; /* { dg-error "expected ':' or '...' before 'return'" } */ + /* { dg-begin-multiline-output "" } + return 42; + ^~~~~~ + { dg-end-multiline-output "" } */ + + default: + return val; + } +} + +/* { dg-begin-multiline-output "" } + int dummy; + ^~~ + { dg-end-multiline-output "" } */ +int dummy;/* { dg-error "expected declaration or statement at end of input" "" { target c } } */ diff --git a/SingleSource/Regression/C/gcc-dg/missing-symbol-3.c b/SingleSource/Regression/C/gcc-dg/missing-symbol-3.c new file mode 100644 index 0000000000..5c7aaed6a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/missing-symbol-3.c @@ -0,0 +1,50 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +/* A sequence of bogus _Static_assert. + We can offer fix-it hints for some of these, but not all. */ + +void test_static_assert_1 (void) +{ + _Static_assert sizeof(int) >= sizeof(char); /* { dg-error "expected '\\(' before 'sizeof'" } */ + /* { dg-begin-multiline-output "" } + _Static_assert sizeof(int) >= sizeof(char); + ^~~~~~ + ( + { dg-end-multiline-output "" } */ +} + +void test_static_assert_2 (void) +{ + _Static_assert(sizeof(int) >= sizeof(char); /* { dg-error "expected '\\)' before ';' token" } */ + /* { dg-begin-multiline-output "" } + _Static_assert(sizeof(int) >= sizeof(char); + ~ ^ + ) + { dg-end-multiline-output "" } */ +} + +void test_static_assert_3 (void) +{ + _Static_assert(sizeof(int) >= sizeof(char),; /* { dg-error "expected string literal before ';' token" } */ + /* { dg-begin-multiline-output "" } + _Static_assert(sizeof(int) >= sizeof(char),; + ^ + { dg-end-multiline-output "" } */ +} + +void test_static_assert_4 (void) +{ + _Static_assert(sizeof(int) >= sizeof(char), "msg"; /* { dg-error "expected '\\)' before ';' token" } */ + /* { dg-begin-multiline-output "" } + _Static_assert(sizeof(int) >= sizeof(char), "msg"; + ~ ^ + ) + { dg-end-multiline-output "" } */ +} + +/* The final one is correct. */ + +void test_static_assert_5 (void) +{ + _Static_assert(sizeof(int) >= sizeof(char), "msg"); +} diff --git a/SingleSource/Regression/C/gcc-dg/mmix-1.c b/SingleSource/Regression/C/gcc-dg/mmix-1.c new file mode 100644 index 0000000000..802ae18ff6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/mmix-1.c @@ -0,0 +1,42 @@ +/* Origin: + Test that MMIX -mtoplevel-symbols cause a ":" to be prepended on the + right symbols and only there. */ +/* { dg-do compile { target mmix-*-* } } */ +/* { dg-options "-mtoplevel-symbols" } */ + +static int static_variable = 1; +int global_initialized_variable = 2; +extern int extern_declared_variable; +int common_variable; +extern int extern_declared_function (void); +static int static_function (void); + +int global_defined_function () +{ + static int static_variable_in_function = 2009; + return + static_variable + + static_variable_in_function++ + + global_initialized_variable + + common_variable + + extern_declared_function () + + static_function (); +} + +static int +static_function (void) +{ + if (extern_declared_variable) + return 42; + else + return 42 + global_defined_function (); +} + +/* { dg-final { scan-assembler-not ":static_variable" } } */ +/* { dg-final { scan-assembler-not "(^|\[^:\])global_initialized_variable" } } */ +/* { dg-final { scan-assembler-not "\[^:\]extern_declared_variable" } } */ +/* { dg-final { scan-assembler-not "\[^:\]common_variable" } } */ +/* { dg-final { scan-assembler-not "\[^:\]extern_declared_function" } } */ +/* { dg-final { scan-assembler-not ":static_function" } } */ +/* { dg-final { scan-assembler-not "(^|\[^:\])global_defined_function" } } */ +/* { dg-final { scan-assembler-not "\[^:\]extern_declared_variable" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/modmod.c b/SingleSource/Regression/C/gcc-dg/modmod.c new file mode 100644 index 0000000000..e09a20beb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/modmod.c @@ -0,0 +1,12 @@ +/* { dg-options "-O -fdump-tree-optimized-raw" } */ + +int f(int a, int b){ + a %= b; + return a % b; +} +int g(unsigned a, unsigned b){ + a %= b; + return a < b; +} + +/* { dg-final { scan-tree-dump-times "trunc_mod_expr" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/mtune.c b/SingleSource/Regression/C/gcc-dg/mtune.c new file mode 100644 index 0000000000..9195fd1ff1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/mtune.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-mtune=*" } { "" } } */ +/* { dg-options "-mtune=foo" } */ +/* { dg-error "mtune" "mtune" { target *-*-* } 0 } */ +/* { dg-bogus "march" "march" { target *-*-* } 0 } */ +/* { dg-bogus "mcpu" "mcpu" { target *-*-* } 0 } */ +/* { dg-prune-output "note: valid arguments.*" } */ +int i; diff --git a/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-1.c b/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-1.c new file mode 100644 index 0000000000..cea2e3363b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-1.c @@ -0,0 +1,13 @@ +/* PR c/19978 : Test for duplicated warnings (unary operators). */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Woverflow" } */ + +#include + +int +g (void) +{ + return - - - - -INT_MIN; /* { dg-bogus "integer overflow in expression.*integer overflow in expression" } */ + /* { dg-warning "integer overflow in expression" "" { target *-*-* } .-1 } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-2.c b/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-2.c new file mode 100644 index 0000000000..595b6835e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-2.c @@ -0,0 +1,12 @@ +/* PR c/19978 : Test for duplicated warnings (binary operators). */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Woverflow" } */ + +#include + +int +g1 (void) +{ + return INT_MAX + 1 - INT_MAX; /* { dg-bogus "integer overflow in expression.*integer overflow in expression" } */ + /* { dg-warning "integer overflow in expression" "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-3.c b/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-3.c new file mode 100644 index 0000000000..d09e1c71fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/multiple-overflow-warn-3.c @@ -0,0 +1,13 @@ +/* PR 30465 : Test for duplicated warnings in a conversion. */ +/* { dg-do compile } */ +/* { dg-options "-Woverflow" } */ + +short int +g (void) +{ + short int wc = ((short int)1 << (8 * __SIZEOF_INT__ - 1)) - 1; /* { dg-bogus "overflow .* overflow" } */ + /* { dg-warning "overflow" "" { target *-*-* } .-1 } */ + return wc; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/multiword-1.c b/SingleSource/Regression/C/gcc-dg/multiword-1.c new file mode 100644 index 0000000000..c08161791d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/multiword-1.c @@ -0,0 +1,68 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-require-effective-target ilp32 } */ + +typedef unsigned int u32; +typedef unsigned long long u64; + +u64 __attribute__((noinline)) +foo (u32 high, u32 low) +{ + return ((u64)high << 32) | low; +} + +u32 __attribute__((noinline)) +right (u64 t) +{ + return (u32)(t >> 32); +} + +u64 __attribute__((noinline)) +left (u32 t) +{ + return (u64)t << 32; +} + +u32 __attribute__((noinline)) +right2 (u64 t) +{ + return (u32)(t >> 40); +} + +u64 __attribute__((noinline)) +left2 (u32 t) +{ + return (u64)t << 40; +} + +u64 __attribute__((noinline)) +zeroextend (u32 t) +{ + return (u64)t; +} + +extern void abort (); + +int +main () +{ + if (foo (13000, 12000) != 55834574860000ULL) + abort (); + + if (right (55834574860000ULL) != 13000) + abort (); + + if (left (13000) != 55834574848000ULL) + abort (); + + if (right2 (55834574860000ULL) != 50) + abort (); + + if (left2 (13000) != 14293651161088000ULL) + abort (); + + if (zeroextend (13000) != 13000ULL) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/nand.c b/SingleSource/Regression/C/gcc-dg/nand.c new file mode 100644 index 0000000000..ebb6c39e3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nand.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +unsigned f(unsigned x, unsigned y){ + return (x | y) & ~x; +} +unsigned g(unsigned x, unsigned y){ + return ~x & (y | x); +} + +/* { dg-final { scan-tree-dump-times "return ~x & y;" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/nest.c b/SingleSource/Regression/C/gcc-dg/nest.c new file mode 100644 index 0000000000..5734c11f1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nest.c @@ -0,0 +1,28 @@ +/* PR 5967, PR 7114 */ +/* { dg-do run } */ +/* { dg-require-profiling "-pg" } */ +/* { dg-options "-O2 -pg" } */ +/* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */ +/* { dg-error "profiler" "No profiler support" { target xstormy16-*-* } 0 } */ + +extern void abort (void); + +long foo (long x) +{ + long i, sum = 0; + long bar (long z) { return z * 2; } + + for (i = 0; i < x; i++) + sum += bar (i); + + return sum; +} + +int main (void) +{ + if (foo(10) != 90) + abort (); + return 0; +} + +/* { dg-final { cleanup-profile-file } } */ diff --git a/SingleSource/Regression/C/gcc-dg/nested-calls-1.c b/SingleSource/Regression/C/gcc-dg/nested-calls-1.c new file mode 100644 index 0000000000..500fed2fb7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-calls-1.c @@ -0,0 +1,42 @@ +/* PR middle-end/24003 */ +/* Contributed by Eric Botcazou */ + +/* { dg-do run } */ +/* { dg-options "-std=c99 -O -fno-inline" } */ +/* { dg-options "-std=c99 -O -fno-inline -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#include + +typedef unsigned long uns32_t; +typedef unsigned long long uns64_t; + +extern void abort(void); + +uns32_t lo (uns64_t p) +{ + return (uns32_t)p; +} + +uns64_t concat (uns32_t p1, uns32_t p2) +{ +#if LLONG_MAX > 2147483647L + return ((uns64_t)p1 << 32) | p2; +#else + return 0; +#endif +} + +uns64_t lshift32 (uns64_t p1, uns32_t p2) +{ + return concat (lo (p1), p2); +} + +int main(void) +{ +#if LLONG_MAX > 2147483647L + if (lshift32 (0xFFFFFFFF12345678ULL, 0x90ABCDEFUL) != 0x1234567890ABCDEFULL) + abort (); +#endif + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-1.c b/SingleSource/Regression/C/gcc-dg/nested-func-1.c new file mode 100644 index 0000000000..2052a6f40d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-1.c @@ -0,0 +1,35 @@ +/* Test for proper errors for break and continue in nested functions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wno-switch-unreachable" } */ + +void +foo (int a) +{ + switch (a) { + void bar1 (void) { break; } /* { dg-error "break statement" "break switch 1" } */ + } + switch (a) { + case 0: + (void) 0; + void bar2 (void) { break; } /* { dg-error "break statement" "break switch 2" } */ + } + while (1) { + void bar3 (void) { break; } /* { dg-error "break statement" "break while" } */ + } + do { + void bar4 (void) { break; } /* { dg-error "break statement" "break do" } */ + } while (1); + for (;;) { + void bar5 (void) { break; } /* { dg-error "break statement" "break for" } */ + } + while (1) { + void bar6 (void) { continue; } /* { dg-error "continue statement" "continue while" } */ + } + do { + void bar7 (void) { continue; } /* { dg-error "continue statement" "continue do" } */ + } while (1); + for (;;) { + void bar8 (void) { continue; } /* { dg-error "continue statement" "continue for" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-10.c b/SingleSource/Regression/C/gcc-dg/nested-func-10.c new file mode 100644 index 0000000000..e017fba871 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-10.c @@ -0,0 +1,57 @@ +/* PR c/70093 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-require-effective-target alloca } */ + +void __attribute__((noinline, noclone)) +foo (int n) +{ + struct S { int a[n]; }; + + struct S __attribute__((noreturn)) + fn (void) + { + __builtin_abort (); + } + + auto struct S __attribute__((noreturn)) + fn2 (void) + { + __builtin_abort (); + } + + struct S x; + __typeof__ (fn ()) *p = &x; + switch (n) + { + case 1: + fn (); + break; + case 2: + fn2 (); + break; + case 3: + x = fn (); + if (x.a[0] != 42) + __builtin_abort (); + break; + case 4: + if (fn ().a[0] != 42) + __builtin_abort (); + break; + case 5: + if (p->a[0] != 42) + __builtin_abort (); + break; + case 6: + if (fn2 ().a[0] != 42) + __builtin_abort (); + break; + } +} + +int +main (void) +{ + foo (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-11.c b/SingleSource/Regression/C/gcc-dg/nested-func-11.c new file mode 100644 index 0000000000..01096b4147 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-11.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-omit-frame-pointer" } */ + +int __attribute__((noipa)) foo (int i) +{ + int a; + + void __attribute__((noipa)) nested2 (int i) + { + a = i; + } + + void __attribute__((noipa)) nested1 (int i) + { + int b[32]; + + for (int j = 0; j < 32; j++) + b[j] = i + j; + + nested2 (b[i]); + } + + nested1 (i); + + return a; +} + +int main (void) +{ + if (foo (4) != 8) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-12.c b/SingleSource/Regression/C/gcc-dg/nested-func-12.c new file mode 100644 index 0000000000..d617d7e448 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-12.c @@ -0,0 +1,48 @@ +/* PR target/88620 */ +/* { dg-do run } */ +/* { dg-options "-Ofast --param ipa-cp-eval-threshold=0 -fno-guess-branch-probability -fno-inline-small-functions" } */ +/* { dg-require-effective-target alloca } */ + +void +foo (int n) +{ + struct S { int a[n]; }; + + struct S + fn (void) + { + struct S s; + s.a[0] = 42; + return s; + } + + auto struct S + fn2 (void) + { + return fn (); + } + + struct S x; + fn (); + fn2 (); + x = fn (); + + if (x.a[0] != 42) + __builtin_abort (); + + if (fn ().a[0] != 42) + __builtin_abort (); + + __typeof__ (fn ()) *p = &x; + if (p->a[0] != 42) + __builtin_abort (); + + if (fn2 ().a[0] != 42) + __builtin_abort (); +} + +int +main (void) +{ + foo (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-2.c b/SingleSource/Regression/C/gcc-dg/nested-func-2.c new file mode 100644 index 0000000000..14f14c67e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-2.c @@ -0,0 +1,28 @@ +/* PR middle-end/18820 */ +/* Check that we reject nested functions as initializers + of static variables. */ + +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S { + void (*f)(int); +}; + +extern void baz(struct S *); +extern void p(int); + +void foo(void) +{ + int u; + + void bar(int val) + { + u = val; + } + + static struct S s = { bar }; /* { dg-error "(is not constant)|(near initialization)" } */ + + baz(&s); + p(u); +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-3.c b/SingleSource/Regression/C/gcc-dg/nested-func-3.c new file mode 100644 index 0000000000..19e8a6155b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-3.c @@ -0,0 +1,20 @@ +/* Undefined nested function should be a error, whether or not the + function is called. Bug 17807. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (void) +{ + auto int fn (int); /* { dg-error "nested function 'fn' declared but never defined" } */ + auto int fn2 (int); /* { dg-error "nested function 'fn2' declared but never defined" } */ + sizeof(fn(1)); +} + +void +h (void) +{ + auto int hn (int); /* { dg-error "nested function 'hn' declared but never defined" } */ + hn (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-4.c b/SingleSource/Regression/C/gcc-dg/nested-func-4.c new file mode 100644 index 0000000000..36a8c405ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-4.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-pg" } */ +/* { dg-options "-pg -static" { target hppa*-*-hpux* } } */ +/* { dg-require-profiling "-pg" } */ + +extern void abort(void); + +void foo(int i) +{ + void bar(void) + { + if (i != 2) + abort (); + } + + bar(); +} + +int main(void) +{ + foo (2); + return 0; +} + +/* { dg-final { cleanup-profile-file } } */ diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-5.c b/SingleSource/Regression/C/gcc-dg/nested-func-5.c new file mode 100644 index 0000000000..591f8a2c1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-5.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fexceptions" } */ +/* PR28516: ICE generating ARM unwind directives for nested functions. */ +/* { dg-require-effective-target trampolines } */ +/* { dg-require-effective-target exceptions } */ + +void ex(int (*)(void)); +void foo(int i) +{ + int bar(void) + { + return i; + } + ex(bar); +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-6.c b/SingleSource/Regression/C/gcc-dg/nested-func-6.c new file mode 100644 index 0000000000..3bae4db352 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-6.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Winline" } */ + +static inline int foo1 (int a) +{ /* { dg-bogus "function not inlinable" } */ + void bar1 (int b) + {} + return a; +} + +int foo2 (int a) +{ + return foo1 (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-7.c b/SingleSource/Regression/C/gcc-dg/nested-func-7.c new file mode 100644 index 0000000000..44c0945e1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-7.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ + +void foo (void) +{ + int a; + + void bar (void) + { + a = 1; + } +} + +/* { dg-final { scan-tree-dump-not "bar" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-8.c b/SingleSource/Regression/C/gcc-dg/nested-func-8.c new file mode 100644 index 0000000000..ccec27d08f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-8.c @@ -0,0 +1,57 @@ +/* { dg-do run } */ +/* { dg-options "-O -fno-inline" } */ + +extern void abort (void); + +/* Return 0 and clobber the static chain. */ + +int +zero (int n) +{ + int + nested (int m) + { + return m - n; + } + + return nested (n); +} + +/* Return the triple of ARG in a convoluted manner. */ + +int +triple (int arg) +{ + int + read_arg (void) + { + return arg; + } + + int + parent (int nested_arg) + { + int + child1 (void) + { + return parent (zero (5)); + } + + int + child2 (void) + { + return nested_arg + read_arg (); + } + + return (nested_arg == 0 ? 0 : child1 ()) + child2 (); + } + + return parent (arg); +} + +int main(void) +{ + if (triple (13) != 3 * 13) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-func-9.c b/SingleSource/Regression/C/gcc-dg/nested-func-9.c new file mode 100644 index 0000000000..633ab6993d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-func-9.c @@ -0,0 +1,48 @@ +/* PR c/70093 */ +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-require-effective-target alloca } */ + +void +foo (int n) +{ + struct S { int a[n]; }; + + struct S + fn (void) + { + struct S s; + s.a[0] = 42; + return s; + } + + auto struct S + fn2 (void) + { + return fn (); + } + + struct S x; + fn (); + fn2 (); + x = fn (); + + if (x.a[0] != 42) + __builtin_abort (); + + if (fn ().a[0] != 42) + __builtin_abort (); + + __typeof__ (fn ()) *p = &x; + if (p->a[0] != 42) + __builtin_abort (); + + if (fn2 ().a[0] != 42) + __builtin_abort (); +} + +int +main (void) +{ + foo (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/nested-redef-1.c b/SingleSource/Regression/C/gcc-dg/nested-redef-1.c new file mode 100644 index 0000000000..f9326086e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-redef-1.c @@ -0,0 +1,44 @@ +/* Test diagnosis of nested tag redefinitions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 { + struct s0 { int a; } x; /* { dg-error "nested redefinition of 'struct s0'" } */ +}; + +struct s1 { + const struct s1 { int b; } x; /* { dg-error "nested redefinition of 'struct s1'" } */ +}; + +struct s2 { + struct s2 { int c; } *x; /* { dg-error "nested redefinition of 'struct s2'" } */ +}; + +struct s3 { + struct s4 { + struct s5 { + struct s3 { int a; } **x; /* { dg-error "nested redefinition of 'struct s3'" } */ + } y; + } z; +}; + +struct s6; +struct s6 { struct s6 *p; }; + +union u0 { + union u0 { int c; } *x; /* { dg-error "nested redefinition of 'union u0'" } */ +}; + +enum e0 { + E0 = sizeof(enum e0 { E1 }) /* { dg-error "nested redefinition of 'enum e0'" } */ +}; + +enum e1 { + E2 = sizeof(enum e2 { E2 }), /* { dg-error "redeclaration of enumerator 'E2'" } */ + /* { dg-message "note: previous definition" "previous E2" { target *-*-* } .-1 } */ + E3 +}; + +enum e3; +enum e3 { E4 = 0 }; diff --git a/SingleSource/Regression/C/gcc-dg/nested-vla-1.c b/SingleSource/Regression/C/gcc-dg/nested-vla-1.c new file mode 100644 index 0000000000..d1b3dc3c5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-vla-1.c @@ -0,0 +1,64 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-effective-target trampolines } */ + + +int main() +{ + int n = 1; + + struct foo { char x[++n]; } bar(void) { struct foo r; return r; } + + if (2 != n) + __builtin_abort(); + + if (2 != sizeof(bar())) + __builtin_abort(); + + n = 1; + + struct bar { char x[++n]; } (*bar2p)(void); + struct bar bar2(void) { struct bar r; return r; } + bar2p = &bar2; + + if (2 != n) + __builtin_abort(); + + if (2 != sizeof((*bar2p)())) + __builtin_abort(); + + n = 1; + + struct str { char x[++n]; } *bar3(void) + { + struct str* s = __builtin_malloc(sizeof(struct str)); + if (!s) + __builtin_abort(); + struct str t; + *s = t; + return s; + } + + if (2 != n) + __builtin_abort(); + + struct str* p; + + if (2 != sizeof(*(p = bar3()))) + __builtin_abort(); + + __builtin_free(p); + + n = 1; + + struct { char x[++n]; } *bar4(void) { } + + if (2 != n) + __builtin_abort(); +#if 0 + // UB + if (2 != sizeof(*bar4())) + __builtin_abort(); +#endif +} + diff --git a/SingleSource/Regression/C/gcc-dg/nested-vla-2.c b/SingleSource/Regression/C/gcc-dg/nested-vla-2.c new file mode 100644 index 0000000000..294b01d370 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-vla-2.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-effective-target trampolines } */ + + +int main() +{ + int n = 1; + + char tmp[2] = { 0 }; + typeof(char (*)[++n]) bar(void) { return &tmp; } + + if (2 != n) + __builtin_abort(); + + if (2 != sizeof(*bar())) + __builtin_abort(); + + if (2 != n) + __builtin_abort(); + + n = 1; + + typeof(char (*)[++n]) (*bar2)(void) = bar; + + if (2 != n) + __builtin_abort(); + + if (2 != sizeof(*(*bar2)())) + __builtin_abort(); + + if (2 != n) + __builtin_abort(); +} + diff --git a/SingleSource/Regression/C/gcc-dg/nested-vla-3.c b/SingleSource/Regression/C/gcc-dg/nested-vla-3.c new file mode 100644 index 0000000000..d2ba04adab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nested-vla-3.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-effective-target trampolines } */ + + +int main() +{ + int n = 1; + + char tmp[2] = { 0 }; + char (*bar(void))[++n] { return &tmp; } + + if (2 != n) + __builtin_abort(); + + if (2 != sizeof(*bar())) + __builtin_abort(); + + n = 1; + + char (*(*bar2)(void))[++n] = bar; + + if (2 != n) + __builtin_abort(); + + if (2 != sizeof(*(*bar2)())) + __builtin_abort(); + +} + diff --git a/SingleSource/Regression/C/gcc-dg/nextafter-1.c b/SingleSource/Regression/C/gcc-dg/nextafter-1.c new file mode 100644 index 0000000000..646a741151 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nextafter-1.c @@ -0,0 +1,191 @@ +/* PR libstdc++/85466 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-math-errno -fno-trapping-math -fdump-tree-optimized" } */ +/* { dg-add-options ieee } */ +/* { dg-skip-if "not IEEE float" { "pdp11-*-*" } } */ +/* { dg-final { scan-tree-dump-not "nextafter" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "nexttoward" "optimized" } } */ + +#ifndef _NEXT_AFTER_2 +float nextafterf (float, float); +double nextafter (double, double); +long double nextafterl (long double, long double); +float nexttowardf (float, long double); +double nexttoward (double, long double); +long double nexttowardl (long double, long double); +#endif + +#define CHECK(x) if (!(x)) __builtin_abort () + +#ifndef NEED_ERRNO +#define NEED_ERRNO 0 +#endif +#ifndef NEED_EXC +#define NEED_EXC 0 +#endif +#ifndef NO_LONG_DOUBLE +#define NO_LONG_DOUBLE (__LDBL_MANT_DIG__ == 106) +#endif + +#define TEST(name, fn, type, L1, L2, l1, l2, MIN1, \ + MAX1, DENORM_MIN1, EPSILON1, MIN2, MAX2, DENORM_MIN2) \ +void \ +name (void) \ +{ \ + const type a = fn (0.0##L1, 0.0##L2); \ + CHECK (a == 0.0##L1 && !__builtin_signbit (a)); \ + const type b = fn (0.0##L1, -0.0##L2); \ + CHECK (b == 0.0##L1 && __builtin_signbit (b)); \ + const type c = fn (__builtin_nan##l1 (""), 0.0##L2); \ + CHECK (__builtin_isnan##l1 (c)); \ + const type d = fn (2.0##L1, __builtin_nan##l2 ("")); \ + CHECK (__builtin_isnan##l1 (d)); \ + const type e = NEED_EXC ? DENORM_MIN1 : fn (0.0##L1, 8.0##L2); \ + CHECK (e == DENORM_MIN1); \ + const type f = fn (1.0##L1, 8.0##L2); \ + CHECK (f == 1.0##L1 + EPSILON1); \ + const type g = fn (1.0##L1, -8.0##L2); \ + CHECK (g == 1.0##L1 - EPSILON1 / 2.0##L1); \ + const type h = fn (__builtin_inf (), 0.0##L2); \ + CHECK (h == MAX1); \ + const type i = fn (-1.0##L1, -__builtin_inf ()); \ + CHECK (i == -1.0##L1 - EPSILON1); \ + const type j = fn (1.5##L1, __builtin_inf ()); \ + CHECK (j == 1.5##L1 + EPSILON1); \ + const type k = fn (1.5##L1 - EPSILON1, 100.0##L2); \ + CHECK (k == 1.5##L1); \ + const type l \ + = (NEED_EXC || NEED_ERRNO) ? 0.0##L1 : fn (DENORM_MIN1, 0.0##L2); \ + CHECK (l == 0.0##L1 && !__builtin_signbit (l)); \ + const type m \ + = (NEED_EXC || NEED_ERRNO) ? __builtin_inf##l1 () \ + : fn (MAX1, __builtin_inf ()); \ + CHECK (__builtin_isinf##l1 (m) && !__builtin_signbit (m)); \ + const type n \ + = (NEED_EXC || NEED_ERRNO) ? 2.0##L1 * DENORM_MIN1 \ + : fn (DENORM_MIN1, 12.0##L2); \ + CHECK (n == 2.0##L1 * DENORM_MIN1); \ + const type o \ + = (NEED_EXC || NEED_ERRNO) ? 3.0##L1 * DENORM_MIN1 \ + : fn (n, 24.0##L2); \ + CHECK (o == 3.0##L1 * DENORM_MIN1); \ + const type p \ + = (NEED_EXC || NEED_ERRNO) ? 4.0##L1 * DENORM_MIN1 \ + : fn (o, 132.0##L2); \ + CHECK (p == 4.0##L1 * DENORM_MIN1); \ + const type q \ + = (NEED_EXC || NEED_ERRNO) ? DENORM_MIN1 \ + : fn (2.0##L1 * DENORM_MIN1, -__builtin_inf ()); \ + CHECK (q == DENORM_MIN1); \ + const type r \ + = (NEED_EXC || NEED_ERRNO) ? 2.0##L1 * DENORM_MIN1 \ + : fn (3.0##L1 * DENORM_MIN1, DENORM_MIN2); \ + CHECK (r == 2.0##L1 * DENORM_MIN1); \ + const type s \ + = (NEED_EXC || NEED_ERRNO) ? 3.0##L1 * DENORM_MIN1 \ + : fn (4.0##L1 * DENORM_MIN1, 2.0##L2 * DENORM_MIN2); \ + CHECK (s == 3.0##L1 * DENORM_MIN1); \ + const type t \ + = (NEED_EXC || NEED_ERRNO) ? MIN1 - DENORM_MIN1 \ + : fn (MIN1, 0.0##L2); \ + CHECK (t == MIN1 - DENORM_MIN1); \ + const type u \ + = (NEED_EXC || NEED_ERRNO) ? MIN1 - 2.0##L1 * DENORM_MIN1 \ + : fn (MIN1 - DENORM_MIN1, -MIN2); \ + CHECK (u == MIN1 - 2.0##L1 * DENORM_MIN1); \ + const type v \ + = (NEED_EXC || NEED_ERRNO) ? MIN1 - DENORM_MIN1 \ + : fn (MIN1 - 2.0##L1 * DENORM_MIN1, 100.0##L2); \ + CHECK (v == MIN1 - DENORM_MIN1); \ + const type w = fn (MIN1 - DENORM_MIN1, MAX2); \ + CHECK (w == MIN1); \ + const type x = fn (MIN1, 17.0##L2); \ + CHECK (x == MIN1 + DENORM_MIN1); \ + const type y = fn (MIN1 + DENORM_MIN1, __builtin_inf##l2 ()); \ + CHECK (y == MIN1 + 2.0##L1 * DENORM_MIN1); \ + const type z \ + = (NEED_EXC || NEED_ERRNO) ? MIN1 / 2.0##L1 - DENORM_MIN1 \ + : fn (MIN1 / 2.0##L1, -MIN2); \ + CHECK (z == MIN1 / 2.0##L1 - DENORM_MIN1); \ + const type aa \ + = (NEED_EXC || NEED_ERRNO) ? -MIN1 / 4.0##L1 + DENORM_MIN1 \ + : fn (-MIN1 / 4.0##L1, MIN2); \ + CHECK (aa == -MIN1 / 4.0##L1 + DENORM_MIN1); \ + const type ab = fn (MIN1 * 2.0##L1, -MIN2); \ + CHECK (ab == MIN1 * 2.0##L1 - DENORM_MIN1); \ + const type ac = fn (MIN1 * 4.0##L1, MIN2); \ + CHECK (ac == MIN1 * 4.0##L1 - DENORM_MIN1 * 2.0##L1); \ + const type ad = fn (MIN1 * 64.0##L1, MIN2); \ + CHECK (ad == MIN1 * 64.0##L1 - DENORM_MIN1 * 32.0##L1); \ + const type ae \ + = (NEED_EXC || NEED_ERRNO) ? MIN1 / 2.0##L1 \ + : fn (MIN1 / 2.0##L1 - DENORM_MIN1, 100.0##L2); \ + CHECK (ae == MIN1 / 2.0##L1); \ + const type af \ + = (NEED_EXC || NEED_ERRNO) ? -MIN1 / 4.0##L1 \ + : fn (-MIN1 / 4 + DENORM_MIN1, -100.0##L2); \ + CHECK (af == -MIN1 / 4.0##L1); \ + const type ag = fn (MIN1 * 2.0##L1 - DENORM_MIN1, 100.0##L2); \ + CHECK (ag == MIN1 * 2.0##L1); \ + const type ah = fn (MIN1 * 4.0##L1 - 2.0##L1 * DENORM_MIN1, 100.0##L2); \ + CHECK (ah == MIN1 * 4.0##L1); \ + const type ai = fn (MIN1 * 64.0##L1 - 32.0##L1 * DENORM_MIN1, 100.0##L2); \ + CHECK (ai == MIN1 * 64.0##L1); \ + const type aj = fn (MIN1 * 64.0##L1, 100.0##L2); \ + CHECK (aj == MIN1 * 64.0##L1 + 64.0##L1 * DENORM_MIN1); \ + const type ak = fn (MIN1 * 64.0##L1 + DENORM_MIN1 * 64.0##L1, 1024.0##L2); \ + CHECK (ak == MIN1 * 64.0##L1 + 128.0##L1 * DENORM_MIN1); \ + const type al = fn (128.0##L1, 128.0##L2); \ + CHECK (al == 128.0##L1); \ + const type am = fn (128.0##L1, 129.0##L2); \ + CHECK (am == 128.0##L1 + 128.0##L1 * EPSILON1); \ + const type an = fn (-128.0##L1 + -128.0##L1 * EPSILON1, -130.0##L2); \ + CHECK (an == -128.0##L1 - 256.0##L1 * EPSILON1); \ + const type ao = fn (128.0##L1 + 256.0##L1 * EPSILON1, 256.0##L2); \ + CHECK (ao == 128.0##L1 + 384.0##L1 * EPSILON1); \ + const type ap = fn (128.0##L1 + 384.0##L1 * EPSILON1, -0.0##L2); \ + CHECK (ap == 128.0##L1 + 256.0##L1 * EPSILON1); \ + const type aq = fn (128.0##L1 + 256.0##L1 * EPSILON1, 1.0##L2); \ + CHECK (aq == 128.0##L1 + 128.0##L1 * EPSILON1); \ + const type ar = fn (128.0##L1 + 128.0##L1 * EPSILON1, 0.0##L2); \ + CHECK (ar == 128.0##L1); \ + const type as = fn (128.0##L1, 0.0##L2); \ + CHECK (as == 128.0##L1 - 64.0##L1 * EPSILON1); \ + const type at = fn (128.0##L1 - 64.0##L1 * EPSILON1, 5.0##L2); \ + CHECK (at == 128.0##L1 - 128.0##L1 * EPSILON1); \ +} + +TEST (test1, nextafterf, float, F, F, f, f, __FLT_MIN__, __FLT_MAX__, + __FLT_DENORM_MIN__, __FLT_EPSILON__, __FLT_MIN__, __FLT_MAX__, + __FLT_DENORM_MIN__) +TEST (test2, nextafter, double, , , , , __DBL_MIN__, __DBL_MAX__, + __DBL_DENORM_MIN__, __DBL_EPSILON__, __DBL_MIN__, __DBL_MAX__, + __DBL_DENORM_MIN__) +#if !NO_LONG_DOUBLE +TEST (test3, nextafterl, long double, L, L, l, l, __LDBL_MIN__, __LDBL_MAX__, + __LDBL_DENORM_MIN__, __LDBL_EPSILON__, __LDBL_MIN__, __LDBL_MAX__, + __LDBL_DENORM_MIN__) +TEST (test4, nexttowardf, float, F, L, f, l, __FLT_MIN__, __FLT_MAX__, + __FLT_DENORM_MIN__, __FLT_EPSILON__, __LDBL_MIN__, __LDBL_MAX__, + __LDBL_DENORM_MIN__) +TEST (test5, nexttoward, double, , L, , l, __DBL_MIN__, __DBL_MAX__, + __DBL_DENORM_MIN__, __DBL_EPSILON__, __LDBL_MIN__, __LDBL_MAX__, + __LDBL_DENORM_MIN__) +TEST (test6, nexttowardl, long double, L, L, l, l, __LDBL_MIN__, __LDBL_MAX__, + __LDBL_DENORM_MIN__, __LDBL_EPSILON__, __LDBL_MIN__, __LDBL_MAX__, + __LDBL_DENORM_MIN__) +#endif + +int +main () +{ + test1 (); + test2 (); +#if !NO_LONG_DOUBLE + test3 (); + test4 (); + test5 (); + test6 (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/nextafter-2.c b/SingleSource/Regression/C/gcc-dg/nextafter-2.c new file mode 100644 index 0000000000..b36bc8bb7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nextafter-2.c @@ -0,0 +1,31 @@ +/* PR libstdc++/85466 */ +/* { dg-do run } */ +/* { dg-require-effective-target c99_runtime } */ +/* { dg-options "-O2 -fno-builtin" } */ +/* { dg-add-options ieee } */ + +#include + +/* In order to run on systems like the PowerPC that have 3 different long + double types, include math.h so it can choose what is the appropriate + nextafterl function to use. + + If we didn't use -fno-builtin for this test, the PowerPC compiler would have + changed the names of the built-in functions that use long double. The + nextafter-1.c function runs with this mapping. + + Since this test uses -fno-builtin, include math.h, so that math.h can make + the appropriate choice to use. */ +#include + +#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) +# if !__GLIBC_PREREQ (2, 24) +/* Workaround buggy nextafterl in glibc 2.23 and earlier, + see https://sourceware.org/bugzilla/show_bug.cgi?id=20205 */ +# define NO_LONG_DOUBLE 1 +# endif +#endif + +#define _NEXT_AFTER_2 + +#include "nextafter-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/nextafter-3.c b/SingleSource/Regression/C/gcc-dg/nextafter-3.c new file mode 100644 index 0000000000..25a520bb15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nextafter-3.c @@ -0,0 +1,9 @@ +/* PR libstdc++/85466 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fmath-errno -fno-trapping-math -fdump-tree-optimized" } */ +/* { dg-add-options ieee } */ +/* { dg-final { scan-tree-dump-not "nextafter" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "nexttoward" "optimized" } } */ + +#define NEED_ERRNO 1 +#include "nextafter-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/nextafter-4.c b/SingleSource/Regression/C/gcc-dg/nextafter-4.c new file mode 100644 index 0000000000..7e3639b675 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nextafter-4.c @@ -0,0 +1,10 @@ +/* PR libstdc++/85466 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fmath-errno -ftrapping-math -fdump-tree-optimized" } */ +/* { dg-add-options ieee } */ +/* { dg-final { scan-tree-dump-not "nextafter" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "nexttoward" "optimized" } } */ + +#define NEED_ERRNO 1 +#define NEED_EXC 1 +#include "nextafter-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/no-asm-1.c b/SingleSource/Regression/C/gcc-dg/no-asm-1.c new file mode 100644 index 0000000000..dd9ec54a4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-asm-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +/* Verify that these GNU extensions are recognized as keywords in + GNU89 mode. */ + +int asm; /* { dg-error "before .asm." } */ +int inline; /* { dg-warning "empty declaration" } */ +/* { dg-error "empty declaration" "" { target *-*-* } .-1 } */ +int typeof; /* { dg-error "before .typeof." } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-asm-2.c b/SingleSource/Regression/C/gcc-dg/no-asm-2.c new file mode 100644 index 0000000000..3cd41141de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-asm-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -fno-asm" } */ + +/* Verify that these GNU extensions are not recognized as keywords + when using -fno-asm in GNU89 mode. */ + +int asm; /* { dg-bogus "before .asm." } */ +int inline; /* { dg-bogus "empty declaration" } */ +int typeof; /* { dg-bogus "before .typeof." } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-asm-3.c b/SingleSource/Regression/C/gcc-dg/no-asm-3.c new file mode 100644 index 0000000000..ee126add87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-asm-3.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +/* Verify that these GNU extensions are recognized as keywords in + GNU99 mode. */ + +int asm; /* { dg-error "before .asm." } */ +int inline; /* { dg-warning "empty declaration" } */ +/* { dg-error "empty declaration" "" { target *-*-* } .-1 } */ +int typeof; /* { dg-error "before .typeof." } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-asm-4.c b/SingleSource/Regression/C/gcc-dg/no-asm-4.c new file mode 100644 index 0000000000..863e9ebac8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-asm-4.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fno-asm" } */ + +/* Verify that the GNU extensions asm and typeof are not recognized as + keywords when using -fno-asm in GNU89 mode, but that inline (which + is a keyword in C99 but not C89) is recognized. */ + +int asm; /* { dg-bogus "before .asm." } */ +int inline; /* { dg-warning "empty declaration" } */ +/* { dg-error "empty declaration" "" { target *-*-* } .-1 } */ +int typeof; /* { dg-bogus "before .typeof." } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-math-errno-1.c b/SingleSource/Regression/C/gcc-dg/no-math-errno-1.c new file mode 100644 index 0000000000..2659f59c9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-math-errno-1.c @@ -0,0 +1,7 @@ +/* Test __NO_MATH_ERRNO__ is defined with -fno-math-errno. */ +/* { dg-do compile } */ +/* { dg-options "-fno-math-errno" } */ + +#ifndef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ not defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/no-math-errno-2.c b/SingleSource/Regression/C/gcc-dg/no-math-errno-2.c new file mode 100644 index 0000000000..f44a997cad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-math-errno-2.c @@ -0,0 +1,7 @@ +/* Test __NO_MATH_ERRNO__ is defined with -ffast-math. */ +/* { dg-do compile } */ +/* { dg-options "-ffast-math" } */ + +#ifndef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ not defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/no-math-errno-3.c b/SingleSource/Regression/C/gcc-dg/no-math-errno-3.c new file mode 100644 index 0000000000..e19e94f2be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-math-errno-3.c @@ -0,0 +1,7 @@ +/* Test __NO_MATH_ERRNO__ is not defined with -fmath-errno. */ +/* { dg-do compile } */ +/* { dg-options "-fmath-errno" } */ + +#ifdef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/no-math-errno-4.c b/SingleSource/Regression/C/gcc-dg/no-math-errno-4.c new file mode 100644 index 0000000000..c6daa128ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-math-errno-4.c @@ -0,0 +1,17 @@ +/* Test __NO_MATH_ERRNO__ is defined and undefined by pragmas. */ +/* { dg-do compile } */ +/* { dg-options "-fmath-errno" } */ + +#ifdef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ defined" +#endif + +#pragma GCC optimize "-fno-math-errno" +#ifndef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ not defined" +#endif + +#pragma GCC optimize "-fmath-errno" +#ifdef __NO_MATH_ERRNO__ +#error "__NO_MATH_ERRNO__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/no-signed-zeros-1.c b/SingleSource/Regression/C/gcc-dg/no-signed-zeros-1.c new file mode 100644 index 0000000000..3b9cd71c84 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-signed-zeros-1.c @@ -0,0 +1,17 @@ +/* Test __NO_SIGNED_ZEROS__ is defined with -fno-signed-zeros. */ +/* { dg-do compile } */ +/* { dg-options "-fno-signed-zeros" } */ + +#ifndef __NO_SIGNED_ZEROS__ +#error "__NO_SIGNED_ZEROS__ not defined" +#endif + +#pragma GCC optimize "-fsigned-zeros" +#ifdef __NO_SIGNED_ZEROS__ +#error "__NO_SIGNED_ZEROS__ defined" +#endif + +#pragma GCC optimize "-fno-signed-zeros" +#ifndef __NO_SIGNED_ZEROS__ +#error "__NO_SIGNED_ZEROS__ not defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/no-signed-zeros-2.c b/SingleSource/Regression/C/gcc-dg/no-signed-zeros-2.c new file mode 100644 index 0000000000..865a29f686 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-signed-zeros-2.c @@ -0,0 +1,17 @@ +/* Test __NO_SIGNED_ZEROS__ is not defined with -fsigned-zeros. */ +/* { dg-do compile } */ +/* { dg-options "-fsigned-zeros" } */ + +#ifdef __NO_SIGNED_ZEROS__ +#error "__NO_SIGNED_ZEROS__ defined" +#endif + +#pragma GCC optimize "-fno-signed-zeros" +#ifndef __NO_SIGNED_ZEROS__ +#error "__NO_SIGNED_ZEROS__ not defined" +#endif + +#pragma GCC optimize "-fsigned-zeros" +#ifdef __NO_SIGNED_ZEROS__ +#error "__NO_SIGNED_ZEROS__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/no-strict-overflow-1.c b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-1.c new file mode 100644 index 0000000000..f3c2dda296 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of strict-overflow-1.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i) +{ + return i - 5 < 10; +} + +/* { dg-final { scan-tree-dump "-[ ]*5" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-strict-overflow-2.c b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-2.c new file mode 100644 index 0000000000..4cfd9295b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of strict-overflow-2.c. */ + +/* We can only simplify the division when using strict overflow + semantics. */ + +int +foo (int i) +{ + return (i * 100) / 10; +} + +/* { dg-final { scan-tree-dump "100" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-strict-overflow-3.c b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-3.c new file mode 100644 index 0000000000..d68008a3dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-3.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of strict-overflow-3.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i, int j) +{ + return i + 100 < j + 1234; +} + +/* { dg-final { scan-tree-dump "1234" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-strict-overflow-4.c b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-4.c new file mode 100644 index 0000000000..90145ff942 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-4.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of strict-overflow-4.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics or when using wrap overflow semantics. -fno-strict-overflow is + equivalent to -fwrapv. */ + +int +foo (int i) +{ + return i + 1 > i; +} + +/* { dg-final { scan-tree-dump "\[^ \]*_.(\\\(D\\\))? != \[0-9]+" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-strict-overflow-5.c b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-5.c new file mode 100644 index 0000000000..aaeb45aedb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-optimized" } */ + +/* Dual of strict-overflow-5.c. */ + +/* We can only unroll when using strict overflow semantics. */ + +int foo (int i) +{ + int index; + int r=0; + + for (index = i; index <= i+4; index+=2) + r++; + + return r; +} + +/* { dg-final { scan-tree-dump-times "r = 3" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-strict-overflow-6.c b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-6.c new file mode 100644 index 0000000000..0a88119663 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-6.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. */ + +/* VRP test. We can not simplify the conditional when not using + strict overflow semantics. We don't test this with + -fstrict-overflow because it turns into an infinite loop. That is + OK but it would also be OK to not do that. */ + +int +foo () +{ + int i, bits; + for (i = 1, bits = 1; i > 0; i += i) + ++bits; + return bits - sizeof(int) * __CHAR_BIT__; +} + +/* { dg-final { scan-tree-dump "return 0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-strict-overflow-7.c b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-7.c new file mode 100644 index 0000000000..19e1b55bb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-7.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of strict-overflow-6.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (char* p) +{ + return p + 1000 < p; +} + +/* { dg-final { scan-tree-dump "\[+\]\[ \]*1000" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-strict-overflow-8.c b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-8.c new file mode 100644 index 0000000000..51df1c4470 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-strict-overflow-8.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-optimized" } */ + +/* We cannot fold i > 0 because p->a - p->b can be larger than INT_MAX + and thus i can wrap. Dual of Wstrict-overflow-18.c */ + +struct c { unsigned int a; unsigned int b; }; +extern void bar (struct c *); +int +foo (struct c *p) +{ + int i; + int sum = 0; + + for (i = 0; i < p->a - p->b; ++i) + { + if (i > 0) + sum += 2; + bar (p); + } + return sum; +} + +/* { dg-final { scan-tree-dump "i_.* > 0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no-trapping-math-1.c b/SingleSource/Regression/C/gcc-dg/no-trapping-math-1.c new file mode 100644 index 0000000000..f4faec9a7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-trapping-math-1.c @@ -0,0 +1,17 @@ +/* Test __NO_TRAPPING_MATH__ is defined with -fno-trapping-math. */ +/* { dg-do compile } */ +/* { dg-options "-fno-trapping-math" } */ + +#ifndef __NO_TRAPPING_MATH__ +#error "__NO_TRAPPING_MATH__ not defined" +#endif + +#pragma GCC optimize "-ftrapping-math" +#ifdef __NO_TRAPPING_MATH__ +#error "__NO_TRAPPING_MATH__ defined" +#endif + +#pragma GCC optimize "-fno-trapping-math" +#ifndef __NO_TRAPPING_MATH__ +#error "__NO_TRAPPING_MATH__ not defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/no-trapping-math-2.c b/SingleSource/Regression/C/gcc-dg/no-trapping-math-2.c new file mode 100644 index 0000000000..1904b5db45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no-trapping-math-2.c @@ -0,0 +1,17 @@ +/* Test __NO_TRAPPING_MATH__ is not defined with -ftrapping-math. */ +/* { dg-do compile } */ +/* { dg-options "-ftrapping-math" } */ + +#ifdef __NO_TRAPPING_MATH__ +#error "__NO_TRAPPING_MATH__ defined" +#endif + +#pragma GCC optimize "-fno-trapping-math" +#ifndef __NO_TRAPPING_MATH__ +#error "__NO_TRAPPING_MATH__ not defined" +#endif + +#pragma GCC optimize "-ftrapping-math" +#ifdef __NO_TRAPPING_MATH__ +#error "__NO_TRAPPING_MATH__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/no_profile_instrument_function-attr-1.c b/SingleSource/Regression/C/gcc-dg/no_profile_instrument_function-attr-1.c new file mode 100644 index 0000000000..909f8a6847 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no_profile_instrument_function-attr-1.c @@ -0,0 +1,24 @@ +/* { dg-require-effective-target global_constructor } */ +/* { dg-options "-O2 -fprofile-generate -fprofile-update=single -fdump-tree-optimized" } */ + +__attribute__ ((no_profile_instrument_function)) +int foo() +{ + return 0; +} + +__attribute__ ((no_profile_instrument_function)) +int bar() +{ + return 1; +} + +int main () +{ + return foo (); +} + +/* { dg-final { scan-tree-dump-times "__gcov0\[._\]main.* = PROF_edge_counter" 1 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "__gcov_indirect_call_profiler_v" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "__gcov_time_profiler_counter = " 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "__gcov_init" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/no_profile_instrument_function-attr-2.c b/SingleSource/Regression/C/gcc-dg/no_profile_instrument_function-attr-2.c new file mode 100644 index 0000000000..2e93ee5f68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/no_profile_instrument_function-attr-2.c @@ -0,0 +1,15 @@ +/* { dg-require-effective-target global_constructor } */ +/* { dg-options "-O2 -fprofile-generate -fprofile-update=single -fdump-tree-optimized" } */ + +__attribute__ ((no_profile_instrument_function)) +int foo() +{ + return 0; +} + +int bar() +{ + return foo(); +} + +/* { dg-final { scan-tree-dump-not " = foo \\(\\)" "optimized"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/nodfp-1.c b/SingleSource/Regression/C/gcc-dg/nodfp-1.c new file mode 100644 index 0000000000..55019d8c27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nodfp-1.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target {! dfp} } } */ +/* { dg-options "-std=gnu99" } */ + +_Decimal32 x; /* { dg-error "not supported" "reject decimal float" } */ +_Decimal64 y; /* { dg-error "not supported" "reject decimal float" } */ +_Decimal128 z; /* { dg-error "not supported" "reject decimal float" } */ diff --git a/SingleSource/Regression/C/gcc-dg/nofixed-point-1.c b/SingleSource/Regression/C/gcc-dg/nofixed-point-1.c new file mode 100644 index 0000000000..babbe59891 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nofixed-point-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target {! fixed_point} } } */ +/* { dg-options "-std=gnu99" } */ + +_Fract w; /* { dg-error "not supported" "reject fixed-point" } */ +_Sat _Fract x; /* { dg-error "not supported" "reject fixed-point" } */ +_Accum y; /* { dg-error "not supported" "reject fixed-point" } */ +_Sat _Accum z; /* { dg-error "not supported" "reject fixed-point" } */ diff --git a/SingleSource/Regression/C/gcc-dg/nofixed-point-2.c b/SingleSource/Regression/C/gcc-dg/nofixed-point-2.c new file mode 100644 index 0000000000..166a6bcb9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nofixed-point-2.c @@ -0,0 +1,29 @@ +/* PR inline-asm/39059 */ +/* { dg-do compile { target {! fixed_point} } } */ +/* { dg-options "-std=gnu99" } */ + +void +f1 (void) +{ + asm ("" : : "r" (0r)); /* { dg-error "not supported" "reject fixed-point" } */ +} + +__typeof (0r) /* { dg-error "not supported" "reject fixed-point" } */ +b2 (void) /* { dg-bogus "defaults to" } */ +{ + return 0r; /* { dg-error "not supported" "reject fixed-point" } */ +} + +_Accum /* { dg-error "not supported" "reject fixed-point" } */ +f3 (void) +{ + return 0k; /* { dg-error "not supported" "reject fixed-point" } */ +} + +_Sat +/* { dg-error "not supported" "reject fixed-point" { target *-*-* } .-1 } */ +/* { dg-error "is used without" "" { target *-*-* } .-2 } */ +f4 (void) +{ + return 0k; /* { dg-error "not supported" "reject fixed-point" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/non-local-goto-1.c b/SingleSource/Regression/C/gcc-dg/non-local-goto-1.c new file mode 100644 index 0000000000..c8202c9908 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/non-local-goto-1.c @@ -0,0 +1,57 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target nonlocal_goto } */ + +extern void abort (void); + +int global; + +static int foo(void) __attribute__((noinline)); + +static int foo(void) +{ + global = 1; +} + +static int bar(void) +{ + foo (); +} + +int execute(int cmd) +{ + __label__ start; + + void raise(void) + { + goto start; + } + + int last; + + bar (); + + last = 0; + +start: + + if (last == 0) + while (1) + { + last = 1; + raise (); + } + + if (last == 0) + return 0; + else + return cmd; +} + +int main(void) +{ + if (execute (1) == 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/non-local-goto-2.c b/SingleSource/Regression/C/gcc-dg/non-local-goto-2.c new file mode 100644 index 0000000000..aa8d63a27c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/non-local-goto-2.c @@ -0,0 +1,58 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target nonlocal_goto } */ + +extern void abort (void); + +int global; + +static int foo(void) __attribute__((noinline)); + +static int foo(void) +{ + global = 1; +} + +static int bar(void) +{ + foo (); + global = 0; +} + +int execute(int cmd) +{ + __label__ start; + + void raise(void) + { + goto start; + } + + int last; + + bar (); + + last = 0; + +start: + + if (last == 0) + while (1) + { + last = 1; + raise (); + } + + if (last == 0) + return 0; + else + return cmd; +} + +int main(void) +{ + if (execute (1) == 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/nonnull-1.c b/SingleSource/Regression/C/gcc-dg/nonnull-1.c new file mode 100644 index 0000000000..51a8a3373e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nonnull-1.c @@ -0,0 +1,39 @@ +/* Test for the "nonnull" function attribute. */ +/* Origin: Jason Thorpe */ +/* { dg-do compile } */ +/* { dg-options "-Wnonnull" } */ + +#include + +extern void func1 (char *, char *, int) __attribute__((nonnull)); + +extern void func2 (char *, char *) __attribute__((nonnull(1))); + +extern void func3 (char *, int, char *, int) + __attribute__((nonnull(1,3))); + +extern void func4 (char *, char *) __attribute__((nonnull(1))) + __attribute__((nonnull(2))); + +void +foo (int i1, int i2, int i3, char *cp1, char *cp2, char *cp3) +{ + func1(cp1, cp2, i1); + + func1(NULL, cp2, i1); /* { dg-warning "null" "null with argless nonnull 1" } */ + func1(cp1, NULL, i1); /* { dg-warning "null" "null with argless nonnull 2" } */ + func1(cp1, cp2, 0); + + func2(cp1, NULL); + func2(NULL, cp1); /* { dg-warning "null" "null with single explicit nonnull" } */ + + func3(NULL, i2, cp3, i3); /* { dg-warning "null" "null with explicit nonnull 1" } */ + func3(cp3, i2, NULL, i3); /* { dg-warning "null" "null with explicit nonnull 3" } */ + + func1(i1 ? cp1 : NULL, cp2, i3); /* { dg-warning "null" "null with cond expr rhs" } */ + func1(i1 ? NULL : cp1, cp2, i3); /* { dg-warning "null" "null with cond expr lhs" } */ + func1(i1 ? (i2 ? cp1 : NULL) : cp2, cp3, i3); /* { dg-warning "null" "null with nested cond expr" } */ + + func4(NULL, cp1); /* { dg-warning "null" "null with multiple attributes 1" } */ + func4(cp1, NULL); /* { dg-warning "null" "null with multiple attributes 2" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/nonnull-2.c b/SingleSource/Regression/C/gcc-dg/nonnull-2.c new file mode 100644 index 0000000000..4e3e48dd88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nonnull-2.c @@ -0,0 +1,17 @@ +/* Test for the invalid use of the "nonnull" function attribute. */ +/* Origin: Jason Thorpe */ +/* { dg-do compile } */ + +extern void func1 () __attribute__((nonnull)); /* { dg-error "without arguments" } */ + +extern void func2 (char *) __attribute__((nonnull(2))); /* { dg-warning ".nonnull. attribute argument value .2. exceeds the number of function parameters 1" } */ + +extern void func3 (char *) __attribute__((nonnull (foo))); /* { dg-warning ".nonnull. attribute argument is invalid" } */ +/* { dg-error ".foo. undeclared" "undeclared argument" { target *-*-* } .-1 } */ + +extern void func4 (int) __attribute__((nonnull(1))); /* { dg-warning ".nonnull. attribute argument value .1. refers to parameter type .int." } */ + +void +foo (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/nonnull-3.c b/SingleSource/Regression/C/gcc-dg/nonnull-3.c new file mode 100644 index 0000000000..c52fe2c830 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nonnull-3.c @@ -0,0 +1,82 @@ +/* Test for the "nonnull" function attribute on builtins. Use the + "__builtin_" style below so we don't need prototypes. */ +/* Origin: Kaveh R. Ghazi */ +/* { dg-do compile } */ +/* { dg-options "-Wnonnull" } */ + +#include + +void +foo (void *p, char *s) +{ + __builtin_bzero (NULL, 0); /* { dg-warning "null" "pr80936" } */ + __builtin_bcopy (NULL, p, 0); /* { dg-warning "null" "pr80936" } */ + __builtin_bcopy (p, NULL, 0); /* { dg-warning "null" "pr80936" } */ + __builtin_bcmp (NULL, p, 0); /* { dg-warning "null" "pr80936" } */ + __builtin_bcmp (p, NULL, 0); /* { dg-warning "null" "pr80936" } */ + __builtin_index (NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_rindex (NULL, 16); /* { dg-warning "null" "null pointer check" } */ + + __builtin_memcpy (p, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_memcpy (NULL, p, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_memmove (p, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_memmove (NULL, p, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_memcmp (p, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_memcmp (NULL, p, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_memset (NULL, 0, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_mempcpy (p, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_mempcpy (NULL, p, 16); /* { dg-warning "null" "null pointer check" } */ + + __builtin_strcat (NULL, s); /* { dg-warning "null" "null pointer check" } */ + __builtin_strcat (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_strncat (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strncat (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_stpcpy (NULL, s); /* { dg-warning "null" "null pointer check" } */ + __builtin_stpcpy (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_stpncpy (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_stpncpy (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strcpy (NULL, s); /* { dg-warning "null" "null pointer check" } */ + __builtin_strcpy (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_strncpy (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strncpy (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strcasecmp (NULL, s); /* { dg-warning "null" "null pointer check" } */ + __builtin_strcasecmp (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_strncasecmp (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strncasecmp (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strcmp (NULL, s); /* { dg-warning "null" "null pointer check" } */ + __builtin_strcmp (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_strncmp (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strncmp (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strlen (NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_strstr (NULL, s); /* { dg-warning "null" "null pointer check" } */ + __builtin_strstr (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_strpbrk (NULL, s); /* { dg-warning "null" "null pointer check" } */ + __builtin_strpbrk (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_strspn (NULL, s); /* { dg-warning "null" "null pointer check" } */ + __builtin_strspn (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_strchr (NULL, 16); /* { dg-warning "null" "null pointer check" } */ + __builtin_strrchr (NULL, 16); /* { dg-warning "null" "null pointer check" } */ + void *p1 = __builtin_strdup (NULL); /* { dg-warning "null" "null pointer check" } */ + void *p2 = __builtin_strndup (NULL, 16); /* { dg-warning "null" "null pointer check" } */ + + __builtin_nan (NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_nanf (NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_nanl (NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_nans (NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_nansf (NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_nansl (NULL); /* { dg-warning "null" "null pointer check" } */ + + __builtin_puts (NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_fputc (*s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_fputs (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_fputs (NULL, p); /* { dg-warning "null" "null pointer check" } */ + __builtin_fwrite (s, 16, 16, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_fwrite (NULL, 16, 16, p); /* { dg-warning "null" "null pointer check" } */ + __builtin_puts_unlocked (NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_fputc_unlocked (*s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_fputs_unlocked (s, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_fputs_unlocked (NULL, p); /* { dg-warning "null" "null pointer check" } */ + __builtin_fwrite_unlocked (s, 16, 16, NULL); /* { dg-warning "null" "null pointer check" } */ + __builtin_fwrite_unlocked (NULL, 16, 16, p); /* { dg-warning "null" "null pointer check" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/nonnull-4.c b/SingleSource/Regression/C/gcc-dg/nonnull-4.c new file mode 100644 index 0000000000..a28458cd4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nonnull-4.c @@ -0,0 +1,79 @@ +/* PR c/78673 - sprintf missing attribute nonnull on destination argument + Test to verify that calls to user-defined functions declared with + the "nonnull" function attribute are diagnosed. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wnonnull" } */ + +#define N(...) __attribute__ ((nonnull (__VA_ARGS__))) + +void N (1) f1_1 (void*); + +void N (1) f2_1 (void*, void*); +void N (1) N (2) f2_1_2 (void*, void*); + +void N (1) N (3) f3_1_3 (void*, void*, void*); + +void N (1, 2) N (4) g4_1_2_4 (void*, void*, void*, void*); +void N (1, 3) N (4) g4_1_3_4 (void*, void*, void*, void*); +void N (2, 3, 4) g4_2_3_4 (void*, void*, void*, void*); + +void N () g4_all (void*, void*, void*, void*); + +void N (1, 3, 5, 7, 11, 13) +g16_1_3_5_7_11_13 (void*, void*, void*, void*, + void*, void*, void*, void*, + void*, void*, void*, void*, + void*, void*, void*, void*); + +static void* null (void) { return 0; } + +void test (void) +{ + void *p0 = null (); + void *px = &px; + + f1_1 (p0); /* { dg-warning "argument 1 null where non-null expected " } */ + f1_1 (px); + + f2_1 (p0, px); /* { dg-warning "argument 1 null" } */ + f2_1 (px, p0); + f2_1 (p0, p0); /* { dg-warning "argument 1 null" } */ + + f2_1_2 (p0, px); /* { dg-warning "argument 1 null" } */ + f2_1_2 (px, p0); /* { dg-warning "argument 2 null" } */ + f2_1_2 (p0, p0); /* { dg-warning "argument 1 null" } */ + /* { dg-warning "argument 2 null" "argument 2" { target *-*-* } .-1 } */ + + f3_1_3 (p0, px, px); /* { dg-warning "argument 1 null" } */ + f3_1_3 (px, p0, px); + f3_1_3 (px, px, p0); /* { dg-warning "argument 3 null" } */ + f3_1_3 (p0, p0, px); /* { dg-warning "argument 1 null" } */ + f3_1_3 (px, p0, p0); /* { dg-warning "argument 3 null" } */ + f3_1_3 (p0, p0, p0); /* { dg-warning "argument 1 null" } */ + /* { dg-warning "argument 3 null" "argument 3" { target *-*-* } .-1 } */ + + g4_1_2_4 (p0, px, px, px); /* { dg-warning "argument 1 null" } */ + g4_1_2_4 (px, p0, px, px); /* { dg-warning "argument 2 null" } */ + g4_1_2_4 (px, px, p0, px); + g4_1_2_4 (px, px, px, p0); /* { dg-warning "argument 4 null" } */ + + g4_1_3_4 (p0, px, px, px); /* { dg-warning "argument 1 null" } */ + g4_1_3_4 (px, p0, px, px); + g4_1_3_4 (px, px, p0, px); /* { dg-warning "argument 3 null" } */ + g4_1_3_4 (px, px, px, p0); /* { dg-warning "argument 4 null" } */ + + g4_2_3_4 (p0, px, px, px); + g4_2_3_4 (px, p0, px, px); /* { dg-warning "argument 2 null" } */ + g4_2_3_4 (px, px, p0, px); /* { dg-warning "argument 3 null" } */ + g4_2_3_4 (px, px, px, p0); /* { dg-warning "argument 4 null" } */ + + g4_all (p0, px, px, px); /* { dg-warning "argument 1 null" } */ + g4_all (px, p0, px, px); /* { dg-warning "argument 2 null" } */ + g4_all (px, px, p0, px); /* { dg-warning "argument 3 null" } */ + g4_all (px, px, px, p0); /* { dg-warning "argument 4 null" } */ + + g16_1_3_5_7_11_13 (px, px, px, px, px, px, px, px, + px, px, px, px, px, px, px, px); + + g16_1_3_5_7_11_13 (px, p0, px, p0, px, p0, px, p0, p0, p0, px, p0, p0, p0, p0, p0); /* { dg-warning "argument 13 null" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/nonnull-5.c b/SingleSource/Regression/C/gcc-dg/nonnull-5.c new file mode 100644 index 0000000000..ba52fe3dbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nonnull-5.c @@ -0,0 +1,11 @@ +/* Reduced from https://sourceware.org/bugzilla/show_bug.cgi?id=20978 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wnonnull" } */ + +int +foo (const char *name) +{ + if (name) + return 6; + return __builtin_strlen (name); /* { dg-warning "argument 1 null where non-null expected" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/nonnull-6.c b/SingleSource/Regression/C/gcc-dg/nonnull-6.c new file mode 100644 index 0000000000..8f368702e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nonnull-6.c @@ -0,0 +1,15 @@ +/* PR c/100783 - ICE on -Wnonnull and erroneous type + { dg-do compile } + { dg-options "-Wall" } */ + +__attribute__((nonnull (1))) void +f1 (char[][n]); // { dg-error "undeclared" } + +__attribute__((nonnull (2))) void +f2 (int n, char[n][m]); // { dg-error "undeclared" } + +__attribute__((nonnull (1))) void +f3 (char[*][n]); // { dg-error "undeclared" } + +__attribute__((nonnull (1))) void +f4 (char[f1]); // { dg-error "size" } diff --git a/SingleSource/Regression/C/gcc-dg/nop.h b/SingleSource/Regression/C/gcc-dg/nop.h new file mode 100644 index 0000000000..23491a603f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nop.h @@ -0,0 +1,9 @@ +#if defined (__ia64__) || defined (__s390__) || defined (__s390x__) +#define NOP "nop 0" +#elif defined (__MMIX__) +#define NOP "swym 0" +#elif defined (__or1k__) +#define NOP "l.nop" +#else +#define NOP "nop" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/noreorder.c b/SingleSource/Regression/C/gcc-dg/noreorder.c new file mode 100644 index 0000000000..e413b689dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreorder.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* The function order in this file is opposite from what the cgraph + topological sort would output. So we can check the order is preserved. */ + +extern void f2(int); +static int func2(void); + +#ifndef NOREORDER +#define NOREORDER __attribute__((no_reorder)) +#endif + +asm("firstasm"); + +NOREORDER __attribute__((noipa)) int bozo(void) +{ + f2(3); + func2(); +} + +asm("jukjuk"); + +NOREORDER __attribute__((noipa)) static int func1(void) +{ + f2(1); +} + +asm("barbar"); + +NOREORDER __attribute__((noipa)) static int func2(void) +{ + func1(); +} + +asm("lastasm"); + +/* { dg-final { scan-assembler "firstasm.*bozo.*jukjuk.*func1.*barbar.*func2.*lastasm" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/noreorder2.c b/SingleSource/Regression/C/gcc-dg/noreorder2.c new file mode 100644 index 0000000000..558361b628 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreorder2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-toplevel-reorder" } */ + +__attribute__((no_reorder)) int foobar; + +static int barbar; +int bozo; + +/* { dg-final { scan-assembler "foobar" } } */ +/* { dg-final { scan-assembler "bozo" } } */ +/* { dg-final { scan-assembler "barbar" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/noreorder3.c b/SingleSource/Regression/C/gcc-dg/noreorder3.c new file mode 100644 index 0000000000..a0b637f60c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreorder3.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +__attribute__((no_reorder)) int foobar; +static int barbar; +int bozo; + +/* { dg-final { scan-assembler "foobar" } } */ +/* { dg-final { scan-assembler "bozo" } } */ +/* { dg-final { scan-assembler-not "barbar" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/noreorder4.c b/SingleSource/Regression/C/gcc-dg/noreorder4.c new file mode 100644 index 0000000000..632fc33432 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreorder4.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-toplevel-reorder" } */ +#define NOREORDER +#include "noreorder.c" +/* { dg-final { scan-assembler "bozo.*jukjuk.*func1.*barbar.*func2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/noreturn-1.c b/SingleSource/Regression/C/gcc-dg/noreturn-1.c new file mode 100644 index 0000000000..cdbfb8dd66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreturn-1.c @@ -0,0 +1,59 @@ +/* Check for various valid and erroneous "noreturn" cases. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wmissing-noreturn" } */ + +extern void exit (int); + +extern void foo1(void) __attribute__ ((__noreturn__)); +void +foo1(void) +{ +} /* { dg-warning "'noreturn' function does return" "detect falling off end of noreturn" } */ + +extern void foo2(void) __attribute__ ((__noreturn__)); +void +foo2(void) +{ + exit(0); +} /* { dg-bogus "warning:" "this function should not get any warnings" } */ + +extern void foo3(void); +void +foo3(void) +{ +} /* { dg-bogus "warning:" "this function should not get any warnings" } */ + +extern void foo4(void); +void +foo4(void) /* { dg-warning "candidate for attribute 'noreturn'" "detect noreturn candidate" } */ +{ + exit(0); +} + +extern void foo5(void) __attribute__ ((__noreturn__)); +void +foo5(void) +{ + return; /* { dg-warning "'noreturn' has a 'return' statement" "detect invalid return" } */ +} /* { dg-warning "function does return" "detect return from noreturn" { target c } .-1 } */ + +extern void foo6(void); +void +foo6(void) +{ + return; +} /* { dg-bogus "warning:" "this function should not get any warnings" } */ + +extern void foo7(void); +void +foo7(void) +{ + foo6(); +} /* { dg-bogus "warning:" "this function should not get any warnings" } */ + +extern void foo8(void) __attribute__ ((__noreturn__)); +void +foo8(void) +{ + foo7(); +} /* { dg-warning "'noreturn' function does return" "detect return from tail call" } */ diff --git a/SingleSource/Regression/C/gcc-dg/noreturn-2.c b/SingleSource/Regression/C/gcc-dg/noreturn-2.c new file mode 100644 index 0000000000..4214de3144 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreturn-2.c @@ -0,0 +1,12 @@ +/* Check for invalid "noreturn" warning. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wall" } */ +extern void abort (void) __attribute__ ((__noreturn__)); + +void noreturn (int x) __attribute__ ((__noreturn__)); + +void +noreturn (int x) +{ + abort (); +} /* { dg-bogus "does return" "noreturn does return" } */ diff --git a/SingleSource/Regression/C/gcc-dg/noreturn-3.c b/SingleSource/Regression/C/gcc-dg/noreturn-3.c new file mode 100644 index 0000000000..3e727d25f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreturn-3.c @@ -0,0 +1,10 @@ +/* Check for no "noreturn" warning in main. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wmissing-noreturn -fhosted" } */ +extern void exit (int) __attribute__ ((__noreturn__)); + +int +main (void) +{ + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/noreturn-5.c b/SingleSource/Regression/C/gcc-dg/noreturn-5.c new file mode 100644 index 0000000000..e69087a4d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreturn-5.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* Check that 'noreturn' and 'volatile extern' are compatible. + The testsuite uses -ansi -pedantic-errors by default, so this has + to override. */ +extern void xxx (int) __attribute__((noreturn)); +typedef void voidfn (int); +__volatile extern voidfn xxx; diff --git a/SingleSource/Regression/C/gcc-dg/noreturn-6.c b/SingleSource/Regression/C/gcc-dg/noreturn-6.c new file mode 100644 index 0000000000..b4badd41b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreturn-6.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* Check for volatile behavior. */ +extern int xxx (void); +volatile extern int xxx (void); /* { dg-error "not compatible" } */ diff --git a/SingleSource/Regression/C/gcc-dg/noreturn-7.c b/SingleSource/Regression/C/gcc-dg/noreturn-7.c new file mode 100644 index 0000000000..1a60bf94a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreturn-7.c @@ -0,0 +1,42 @@ +/* PR optimization/13394 */ +/* Origin: Carlo Wood */ + +/* Verify that a bogus "function does return" warning is not issued + in presence of tail recursion within a noreturn function. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -Wreturn-type -Wmissing-noreturn -fno-ipa-icf" } */ + + +void f(void) __attribute__ ((__noreturn__)); +void _exit(int status) __attribute__ ((__noreturn__)); + +int z = 0; + +void g() /* { dg-warning "might be candidate" } */ +{ + if (++z > 10) + _exit(0); + g(); +} + +void f() +{ + if (++z > 10) + _exit(0); + f(); +} /* { dg-bogus "does return" } */ + +int h() /* { dg-warning "might be candidate" } */ +{ + if (++z > 10) + _exit(0); + return h(); +} /* { dg-bogus "end of non-void function" } */ + +int k() /* { dg-warning "might be candidate" } */ +{ + if (++z > 10) + _exit(0); + k(); +} /* { dg-warning "control reaches" } */ diff --git a/SingleSource/Regression/C/gcc-dg/noreturn-8.c b/SingleSource/Regression/C/gcc-dg/noreturn-8.c new file mode 100644 index 0000000000..ce41cabfa5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/noreturn-8.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { nonpic || pie_enabled } } } */ +/* { dg-options "-O2" } */ +void exit (int); +void noreturn_autodetection_failed (); +__attribute__ ((noinline)) int +detect_noreturn () +{ + exit (0); +} +int +main (void) +{ + detect_noreturn (); + noreturn_autodetection_failed (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/nrv1.c b/SingleSource/Regression/C/gcc-dg/nrv1.c new file mode 100644 index 0000000000..ca700924a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nrv1.c @@ -0,0 +1,28 @@ +/* Test that the NRV optimization doesn't cause a1 to change too soon. This + is equivalent to c++/19317. */ +/* { dg-do run } */ + +void abort (void); + +struct A +{ + int i[100]; +}; + +struct A a1; + +struct A f () +{ + struct A a2; + a2.i[0] = 42; + /* a1.i[0] should still be 0 until we return. */ + if (a1.i[0] != 0) + abort (); + return a2; +} + +int main() +{ + a1 = f(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/nrv2.c b/SingleSource/Regression/C/gcc-dg/nrv2.c new file mode 100644 index 0000000000..e4d1f9aba3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nrv2.c @@ -0,0 +1,25 @@ +/* Test that the tree_nrv pass works by making sure that we don't generate + a memcpy. Throw in a bit of control flow to make its job a bit harder. */ + +/* { dg-options "-O" } */ + +struct A { int i[100]; }; + +int b; + +struct A f () +{ + struct A a; + if (b) + { + a.i[0] = 42; + return a; + } + else + { + a.i[42] = 1; + return a; + } +} + +/* { dg-final { scan-assembler-not "memcpy" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/nrv3.c b/SingleSource/Regression/C/gcc-dg/nrv3.c new file mode 100644 index 0000000000..6c66ecf883 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nrv3.c @@ -0,0 +1,29 @@ +/* Verify that gimple-level NRV is occurring when values other than the + return slot are call-clobbered. */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +typedef struct { int x[20]; void *y; } S; +typedef struct { int a; S b; } T; +S nrv_candidate (void); +void use_result (S, int); +int *ptr; +void foo (void) +{ + S result; + T result_arr[10][5]; + + int i; + + ptr = &i; + + /* i is call-clobbered for these calls, but result and result_arr + aren't. */ + result = nrv_candidate (); + result_arr[3][4].b = nrv_candidate (); + + use_result (result, i); + use_result (result_arr[3][4].b, i); +} + +/* { dg-final { scan-tree-dump-times "return slot optimization" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/nrv4.c b/SingleSource/Regression/C/gcc-dg/nrv4.c new file mode 100644 index 0000000000..ff83d0c030 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nrv4.c @@ -0,0 +1,32 @@ +/* Verify that NRV optimizations are prohibited when the LHS is an + indirect reference to something that may be call-clobbered. */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +typedef struct { int x[20]; void *y; } S; +S nrv_candidate (void); +void use_result (S); +void make_escape (S *); +S global_S; +void foo (void) +{ + S *result; + S local_S; + + /* We can't perform return slot optimization because global_S is + global and may be clobbered by nrv_candidate. */ + result = &global_S; + *result = nrv_candidate (); + use_result (*result); + + /* We can't perform return slot optimization because local_S is + call_clobbered (its address escapes prior to invoking + nrv_candidate). */ + make_escape (&local_S); + result = &local_S; + *result = nrv_candidate (); + use_result (*result); +} + +/* { dg-final { scan-tree-dump-times "return slot optimization" 0 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/nrv5.c b/SingleSource/Regression/C/gcc-dg/nrv5.c new file mode 100644 index 0000000000..371e713aca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/nrv5.c @@ -0,0 +1,27 @@ +/* Verify that NRV optimizations are prohibited when the LHS is + something that may be call-clobbered. */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +typedef struct { int x[20]; void *y; } S; +typedef struct { int a; S b; } T; +S nrv_candidate (void); +void use_result (S); +void make_escape (S *); +void foo (void) +{ + S result; + T result_arr[10][5]; + + make_escape (&result); + make_escape (&(result_arr[3][4].b)); + + /* Neither call should be allowed to use NRV optimization. */ + result = nrv_candidate (); + result_arr[3][4].b = nrv_candidate (); + + use_result (result); + use_result (result_arr[3][4].b); +} + +/* { dg-final { scan-tree-dump-times "return slot optimization" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/null-pointer-1.c b/SingleSource/Regression/C/gcc-dg/null-pointer-1.c new file mode 100644 index 0000000000..8cc15c6d86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/null-pointer-1.c @@ -0,0 +1,20 @@ +/* PR c/13382 */ +/* Origin: Richard Hutchinson */ + +/* Verify that the null initializer is converted to the right + pointer type. */ + +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +struct t +{ + int aMember; +}; + +struct t *const aPointer = 0; + +void foo() +{ + int anInt = (aPointer == 0) ? 0 : aPointer->aMember; +} diff --git a/SingleSource/Regression/C/gcc-dg/old-style-asm-1.c b/SingleSource/Regression/C/gcc-dg/old-style-asm-1.c new file mode 100644 index 0000000000..c8fb668ff2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/old-style-asm-1.c @@ -0,0 +1,23 @@ +/* PR inline-asm/8832 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -dP -fno-thread-jumps" } */ + +/* Verify that GCC doesn't optimize + old style asm instructions. */ + +void foo(int v) +{ + if (v) + asm ("dummy1"); + + asm ("dummy2"); + + if (v) + asm ("dummy3"); +} + +/* The purpose of the test below is to check that there are two branches + in the generated code, supposedly corresponding to the if-statements. + It tries to check for jump_insn (set (pc) pattern, so that jump_insns + corresponding to return are not taken into account. */ +/* { dg-final { scan-assembler "jump_insn.*set \\(pc\\).*jump_insn.*set \\(pc\\)"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/old-style-param-1.c b/SingleSource/Regression/C/gcc-dg/old-style-param-1.c new file mode 100644 index 0000000000..1742069c9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/old-style-param-1.c @@ -0,0 +1,4 @@ +/* PR c/35750 */ + +void foo(int[]); +void foo(x) int x[](); {} /* { dg-error "array of functions" } */ diff --git a/SingleSource/Regression/C/gcc-dg/old-style-prom-1.c b/SingleSource/Regression/C/gcc-dg/old-style-prom-1.c new file mode 100644 index 0000000000..165ff98270 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/old-style-prom-1.c @@ -0,0 +1,13 @@ +/* Test for prototype followed by old-style definition, as in + dremf-type-compat-1.c but with a non-built-in function. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +float f (float, float); + +float +f (x, y) + float x, y; +{ + return x + y; +} diff --git a/SingleSource/Regression/C/gcc-dg/old-style-prom-2.c b/SingleSource/Regression/C/gcc-dg/old-style-prom-2.c new file mode 100644 index 0000000000..e7e690e141 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/old-style-prom-2.c @@ -0,0 +1,14 @@ +/* Test for prototype followed by old-style definition, as in + dremf-type-compat-2.c but with a non-built-in function. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +float f (float, float); /* { dg-warning "prototype declaration" } */ + +float +f (x, y) + float x; /* { dg-warning "promoted argument 'x' doesn't match prototype" } */ + float y; /* { dg-warning "promoted argument 'y' doesn't match prototype" } */ +{ + return x + y; +} diff --git a/SingleSource/Regression/C/gcc-dg/old-style-prom-3.c b/SingleSource/Regression/C/gcc-dg/old-style-prom-3.c new file mode 100644 index 0000000000..720367f2e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/old-style-prom-3.c @@ -0,0 +1,14 @@ +/* Test for prototype followed by old-style definition, as in + dremf-type-compat-3.c but with a non-built-in function. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +float f (float, float); /* { dg-error "prototype declaration" } */ + +float +f (x, y) + float x; /* { dg-error "promoted argument 'x' doesn't match prototype" } */ + float y; /* { dg-error "promoted argument 'y' doesn't match prototype" } */ +{ + return x + y; +} diff --git a/SingleSource/Regression/C/gcc-dg/old-style-then-proto-1.c b/SingleSource/Regression/C/gcc-dg/old-style-then-proto-1.c new file mode 100644 index 0000000000..e3e6186167 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/old-style-then-proto-1.c @@ -0,0 +1,44 @@ +/* Test for old-style definition followed by prototype declaration. + Mismatched qualifiers used to be wrongly forbidden. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void f1() {} +void f1(void); /* { dg-warning "prototype for 'f1' follows non-prototype definition" } */ + +void f2() {} /* { dg-message "note: previous definition of 'f2'" "note" } */ +void f2(int); /* { dg-error "prototype for 'f2' declares more arguments than previous old-style definition" } */ + +void f3(a) int a; {} /* { dg-message "note: previous definition of 'f3'" "note" } */ +void f3(void); /* { dg-error "prototype for 'f3' declares fewer arguments than previous old-style definition" } */ + +void f4(a) int a; {} +void f4(int); /* { dg-warning "prototype for 'f4' follows non-prototype definition" } */ + +void f5(a) int a; {} /* { dg-message "note: previous definition of 'f5'" "note" } */ +void f5(int, int); /* { dg-error "prototype for 'f5' declares more arguments than previous old-style definition" } */ + +void f6(a) int a; {} /* { dg-message "note: previous definition of 'f6'" "note" } */ +void f6(int, ...); /* { dg-error "conflicting types for 'f6'" } */ + +void f7(a, b) int a, b; {} /* { dg-message "note: previous definition of 'f7'" "note" } */ +void f7(int); /* { dg-error "prototype for 'f7' declares fewer arguments than previous old-style definition" } */ + +void f8(a, b) int a, b; {} /* { dg-message "note: previous definition of 'f8'" "note" } */ +void f8(int, ...); /* { dg-error "conflicting types for 'f8'" } */ + +void f9(a, b) int a, b; {} +void f9(int, int); /* { dg-warning "prototype for 'f9' follows non-prototype definition" } */ + +void f10(a, b) int a, b; {} /* { dg-message "note: previous definition of 'f10'" "note" } */ +void f10(int, long); /* { dg-error "prototype for 'f10' declares argument 2 with incompatible type" } */ + +void f11(a, b) int a, b; {} /* { dg-message "note: previous definition of 'f11'" "note" } */ +void f11(long, int); /* { dg-error "prototype for 'f11' declares argument 1 with incompatible type" } */ + +void f12(a, b) const int a; volatile int b; {} +void f12(volatile int, const int); /* { dg-warning "prototype for 'f12' follows non-prototype definition" } */ + +void f13(a) const int a[2][2]; {} /* { dg-message "note: previous definition of 'f13'" "note" } */ +void f13(volatile int [2][2]); /* { dg-error "prototype for 'f13' declares argument 1 with incompatible type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-1.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-1.c new file mode 100644 index 0000000000..56a2071b5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-1.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mzarch" { target s390*-*-* } } */ + +#include +#define __const_swab64(x) ((uint64_t)( \ + (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \ + (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ + (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ + (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ + (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ + (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ + (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ + (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56))) + + +/* This byte swap implementation is used by the Linux kernel and the + GNU C library. */ + +uint64_t +swap64 (uint64_t in) +{ + return __const_swab64 (in); +} + +/* This variant is currently used by libgcc. The difference is that + the bswap source and destination have a signed integer type which + requires a slightly higher search depth in order to dive through + the cast as well. */ + +typedef int DItype __attribute__ ((mode (DI))); +DItype +swap64_b (DItype u) +{ + return ((((u) & 0xff00000000000000ull) >> 56) + | (((u) & 0x00ff000000000000ull) >> 40) + | (((u) & 0x0000ff0000000000ull) >> 24) + | (((u) & 0x000000ff00000000ull) >> 8) + | (((u) & 0x00000000ff000000ull) << 8) + | (((u) & 0x0000000000ff0000ull) << 24) + | (((u) & 0x000000000000ff00ull) << 40) + | (((u) & 0x00000000000000ffull) << 56)); +} + +/* The OpenSSL variant. */ + +uint64_t +swap64_c (uint64_t x) +{ + uint32_t a = x >> 32; + uint32_t b = (uint32_t) x; + return ((uint64_t) ((((((b)) >> (8)) | (((b)) << (32 - (8)))) & 0xff00ff00L) + | (((((b)) << (8)) | (((b)) >> (32 - (8)))) & 0x00ff00ffL)) << 32) + | (uint64_t) ((((((a)) >> (8)) | (((a)) << (32 - (8)))) & 0xff00ff00L) + | (((((a)) << (8)) | (((a)) >> (32 - (8)))) & 0x00ff00ffL)); +} + + +/* { dg-final { scan-tree-dump-times "= __builtin_bswap64 \\\(" 3 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-2.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-2.c new file mode 100644 index 0000000000..c6d96049e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mzarch" { target s390*-*-* } } */ + +#include + +/* A variant via unsigned short. */ + +uint64_t +swap64_c (uint64_t x) +{ + uint16_t a0 = x >> 48; + uint16_t a1 = x >> 32; + uint16_t a2 = x >> 16; + uint16_t a3 = x; + + return ((uint64_t) (((a0 >> 8) & 0xff) | ((a0 << 8) & 0xff00))) + | ((uint64_t) (((a1 >> 8) & 0xff) | ((a1 << 8) & 0xff00)) << 16) + | ((uint64_t) (((a2 >> 8) & 0xff) | ((a2 << 8) & 0xff00)) << 32) + | ((uint64_t) (((a3 >> 8) & 0xff) | ((a3 << 8) & 0xff00)) << 48); +} + + +/* { dg-final { scan-tree-dump-times "= __builtin_bswap64 \\\(" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-3.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-3.c new file mode 100644 index 0000000000..1888757ccb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapdi-3.c @@ -0,0 +1,64 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-bswap" } */ +/* { dg-additional-options "-mzarch" { target s390*-*-* } } */ + +#include + +unsigned char data[8]; + +struct uint64_st { + unsigned char u0, u1, u2, u3, u4, u5, u6, u7; +}; + +uint64_t read_le64_1 (void) +{ + return (uint64_t) data[0] | ((uint64_t) data[1] << 8) + | ((uint64_t) data[2] << 16) | ((uint64_t) data[3] << 24) + | ((uint64_t) data[4] << 32) | ((uint64_t) data[5] << 40) + | ((uint64_t) data[6] << 48) | ((uint64_t) data[7] << 56); +} + +uint64_t read_le64_2 (struct uint64_st data) +{ + return (uint64_t) data.u0 | ((uint64_t) data.u1 << 8) + | ((uint64_t) data.u2 << 16) | ((uint64_t) data.u3 << 24) + | ((uint64_t) data.u4 << 32) | ((uint64_t) data.u5 << 40) + | ((uint64_t) data.u6 << 48) | ((uint64_t) data.u7 << 56); +} + +uint64_t read_le64_3 (unsigned char *data) +{ + return (uint64_t) *data | ((uint64_t) *(data + 1) << 8) + | ((uint64_t) *(data + 2) << 16) | ((uint64_t) *(data + 3) << 24) + | ((uint64_t) *(data + 4) << 32) | ((uint64_t) *(data + 5) << 40) + | ((uint64_t) *(data + 6) << 48) | ((uint64_t) *(data + 7) << 56); +} + +uint64_t read_be64_1 (void) +{ + return (uint64_t) data[7] | ((uint64_t) data[6] << 8) + | ((uint64_t) data[5] << 16) | ((uint64_t) data[4] << 24) + | ((uint64_t) data[3] << 32) | ((uint64_t) data[2] << 40) + | ((uint64_t) data[1] << 48) | ((uint64_t) data[0] << 56); +} + +uint64_t read_be64_2 (struct uint64_st data) +{ + return (uint64_t) data.u7 | ((uint64_t) data.u6 << 8) + | ((uint64_t) data.u5 << 16) | ((uint64_t) data.u4 << 24) + | ((uint64_t) data.u3 << 32) | ((uint64_t) data.u2 << 40) + | ((uint64_t) data.u1 << 48) | ((uint64_t) data.u0 << 56); +} + +uint64_t read_be64_3 (unsigned char *data) +{ + return (uint64_t) *(data + 7) | ((uint64_t) *(data + 6) << 8) + | ((uint64_t) *(data + 5) << 16) | ((uint64_t) *(data + 4) << 24) + | ((uint64_t) *(data + 3) << 32) | ((uint64_t) *(data + 2) << 40) + | ((uint64_t) *(data + 1) << 48) | ((uint64_t) *data << 56); +} + +/* { dg-final { scan-tree-dump-times "64 bit load in target endianness found at" 3 "bswap" } } */ +/* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 3 "bswap" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswaphi-1.c b/SingleSource/Regression/C/gcc-dg/optimize-bswaphi-1.c new file mode 100644 index 0000000000..a5d8bfd583 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswaphi-1.c @@ -0,0 +1,71 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-bswap" } */ +/* { dg-additional-options "-march=z900" { target s390-*-* } } */ + +#include + +unsigned char data[2]; + +struct uint16_st { + unsigned char u0, u1; +}; + +uint32_t read_le16_1 (void) +{ + return data[0] | (data[1] << 8); +} + +uint32_t read_le16_2 (struct uint16_st data) +{ + return data.u0 | (data.u1 << 8); +} + +uint32_t read_le16_3 (unsigned char *data) +{ + return *data | (*(data + 1) << 8); +} + +uint32_t read_be16_1 (void) +{ + return data[1] | (data[0] << 8); +} + +uint32_t read_be16_2 (struct uint16_st data) +{ + return data.u1 | (data.u0 << 8); +} + +uint32_t read_be16_3 (unsigned char *data) +{ + return *(data + 1) | (*data << 8); +} + +typedef int HItype __attribute__ ((mode (HI))); + +/* Test that detection of significant sign extension works correctly. This + checks that unknown byte markers are set correctly in cast of cast. */ + +HItype +swap16 (HItype in) +{ + return (HItype) (((in >> 0) & 0xFF) << 8) + | (((in >> 8) & 0xFF) << 0); +} + +unsigned short +get_unaligned_16_le (unsigned char *p) +{ + return p[0] | (p[1] << 8); +} + +unsigned short +get_unaligned_16_be (unsigned char *p) +{ + return p[1] | (p[0] << 8); +} + + +/* { dg-final { scan-tree-dump-times "16 bit load in target endianness found at" 4 "bswap" } } */ +/* { dg-final { scan-tree-dump-times "16 bit bswap implementation found at" 4 "bswap" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-1.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-1.c new file mode 100644 index 0000000000..2d24f43e5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-1.c @@ -0,0 +1,92 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-additional-options "-march=z900" { target s390*-*-* } } */ + +#include + +#define __const_swab32(x) ((uint32_t)( \ + (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))) + +/* This byte swap implementation is used by the Linux kernel and the + GNU C library. */ + +uint32_t +swap32_a (uint32_t in) +{ + return __const_swab32 (in); +} + +/* The OpenSSH byte swap implementation. */ +uint32_t +swap32_b (uint32_t in) +{ + uint32_t a; + + a = (in << 16) | (in >> 16); + a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8); + + return a; +} + +/* This variant is currently used by libgcc. The difference is that + the bswap source and destination have a signed integer type which + requires a slightly higher search depth in order to dive through + the cast as well. */ + +typedef int SItype __attribute__ ((mode (SI))); + +SItype +swap32_c (SItype u) +{ + return ((((u) & 0xff000000) >> 24) + | (((u) & 0x00ff0000) >> 8) + | (((u) & 0x0000ff00) << 8) + | (((u) & 0x000000ff) << 24)); +} + +/* This variant comes from gcc.target/sh/pr53568-1.c. It requires to track + which bytes have an unpredictable value (eg. due to sign extension) to + make sure that the final expression have only well defined byte values. */ + +SItype +swap32_d (SItype in) +{ + /* 1x swap.w + 2x swap.b */ + return (((in >> 0) & 0xFF) << 24) + | (((in >> 8) & 0xFF) << 16) + | (((in >> 16) & 0xFF) << 8) + | (((in >> 24) & 0xFF) << 0); +} + +/* This variant is adapted from swap32_d above. It detects missing cast of + MARKER_BYTE_UNKNOWN to uint64_t for the CASE_CONVERT case for host + architecture where a left shift with too big an operand mask its high + bits. */ + +SItype +swap32_e (SItype in) +{ + return (((in >> 0) & 0xFF) << 24) + | (((in >> 8) & 0xFF) << 16) + | (((((int64_t) in) & 0xFF0000FF0000) >> 16) << 8) + | (((in >> 24) & 0xFF) << 0); +} + +/* This variant comes from PR63259. It compiles to a gimple sequence that ends + with a rotation instead of a bitwise OR. */ + +unsigned +swap32_f (unsigned in) +{ + in = ((in & 0xff00ff00) >> 8) | ((in & 0x00ff00ff) << 8); + in = ((in & 0xffff0000) >> 16) | ((in & 0x0000ffff) << 16); + return in; +} + +/* { dg-final { scan-tree-dump-times "= __builtin_bswap32 \\\(" 6 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-2.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-2.c new file mode 100644 index 0000000000..330dfe9944 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-2.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-bswap" } */ +/* { dg-additional-options "-march=z900" { target s390*-*-* } } */ + +#include + +extern unsigned char data[4]; + +struct uint32_st { + unsigned char u0, u1, u2, u3; +}; + +uint32_t read_le32_1 (void) +{ + return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); +} + +uint32_t read_le32_2 (struct uint32_st data) +{ + return data.u0 | (data.u1 << 8) | (data.u2 << 16) | (data.u3 << 24); +} + +uint32_t read_le32_3 (unsigned char *data) +{ + return *data | (*(data + 1) << 8) | (*(data + 2) << 16) + | (*(data + 3) << 24); +} + +uint32_t read_be32_1 (void) +{ + return data[3] | (data[2] << 8) | (data[1] << 16) | (data[0] << 24); +} + +uint32_t read_be32_2 (struct uint32_st data) +{ + return data.u3 | (data.u2 << 8) | (data.u1 << 16) | (data.u0 << 24); +} + +uint32_t read_be32_3 (unsigned char *data) +{ + return *(data + 3) | (*(data + 2) << 8) | (*(data + 1) << 16) + | (*data << 24); +} + +static inline unsigned short +get_unaligned_16_le (unsigned char *p) +{ + return p[0] | (p[1] << 8); +} +unsigned int +get_unaligned_32_le (unsigned char *p) +{ + return get_unaligned_16_le (p) | (get_unaligned_16_le (p + 2) << 16); +} + +static inline unsigned short +get_unaligned_16_be (unsigned char *p) +{ + return p[1] | (p[0] << 8); +} +unsigned int +get_unaligned_32_be (unsigned char *p) +{ + return get_unaligned_16_be (p + 2) | (get_unaligned_16_be (p) << 16); +} + +/* { dg-final { scan-tree-dump-times "32 bit load in target endianness found at" 4 "bswap" } } */ +/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 4 "bswap" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-3.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-3.c new file mode 100644 index 0000000000..7cd1b406a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-3.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-additional-options "-march=z900" { target s390-*-* } } */ + +typedef int SItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); + +/* This variant comes from optimize-bswapsi-1.c swap32_d. It detects a missing + cast of MARKER_BYTE_UNKNOWN to uint64_t for the CASE_CONVERT case for host + architecture where a left shift with too big an operand gives zero. */ + +SItype +swap32 (SItype in) +{ + return (((in >> 0) & 0xFF) << 24) + | (((in >> 8) & 0xFF) << 16) + | (((((DItype) in) & 0xFF00FF0000llu) >> 16) << 8) + | (((in >> 24) & 0xFF) << 0); +} + +/* { dg-final { scan-tree-dump-times "= __builtin_bswap32 \\\(" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-4.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-4.c new file mode 100644 index 0000000000..cfcc8324c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-4.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-options "-O2 -fdump-tree-bswap" } */ +/* { dg-additional-options "-march=z900" { target s390-*-* } } */ + +typedef unsigned char u8; +typedef unsigned int u32; +union __anonunion +{ + u32 value; + u8 bytes[4]; +}; + +u32 +acpi_ut_dword_byte_swap (u32 value) +{ + union __anonunion in; + in.value = value; +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + return ((in.bytes[0] << 24) | (in.bytes[1] << 16) + | (in.bytes[2] << 8) | in.bytes[3]); +#else + return ((in.bytes[3] << 24) | (in.bytes[2] << 16) + | (in.bytes[1] << 8) | in.bytes[0]); +#endif +} + +/* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "bswap" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-5.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-5.c new file mode 100644 index 0000000000..5934aacf75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-5.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-optimized -fno-inline-functions" } */ +/* { dg-additional-options "-march=z900" { target s390-*-* } } */ + +struct L { unsigned int l[2]; }; +union U { double a; struct L l; } u; + +void +foo (double a, struct L *p) +{ + u.a = a; + struct L l = u.l, m; + m.l[0] = (((l.l[1] & 0xff000000) >> 24) + | ((l.l[1] & 0x00ff0000) >> 8) + | ((l.l[1] & 0x0000ff00) << 8) + | ((l.l[1] & 0x000000ff) << 24)); + m.l[1] = (((l.l[0] & 0xff000000) >> 24) + | ((l.l[0] & 0x00ff0000) >> 8) + | ((l.l[0] & 0x0000ff00) << 8) + | ((l.l[0] & 0x000000ff) << 24)); + *p = m; +} + +void +bar (double a, struct L *p) +{ + foo (a, p); +} + +/* { dg-final { scan-tree-dump-times "= __builtin_bswap32 \\\(" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-6.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-6.c new file mode 100644 index 0000000000..75f8aecb5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-6.c @@ -0,0 +1,38 @@ +/* PR tree-optimization/42587 */ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ +/* { dg-additional-options "-march=z900" { target s390-*-* } } */ + +typedef unsigned char u8; +typedef unsigned int u32; +union __anonunion_out_195 +{ + u32 value; + u8 bytes[4]; +}; +union __anonunion_in_196 +{ + u32 value; + u8 bytes[4]; +}; +extern void acpi_ut_track_stack_ptr (void); +u32 acpi_ut_dword_byte_swap (u32 value); +u32 +acpi_ut_dword_byte_swap (u32 value) +{ + union __anonunion_out_195 out; + union __anonunion_in_196 in; + + { + acpi_ut_track_stack_ptr (); + in.value = value; + out.bytes[0] = in.bytes[3]; + out.bytes[1] = in.bytes[2]; + out.bytes[2] = in.bytes[1]; + out.bytes[3] = in.bytes[0]; + return (out.value); + } +} + +/* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-7.c b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-7.c new file mode 100644 index 0000000000..1e4db5e481 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/optimize-bswapsi-7.c @@ -0,0 +1,37 @@ +/* PR tree-optimization/103376 */ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-optimized" } */ +/* { dg-additional-options "-march=z900" { target s390-*-* } } */ + +static unsigned int +f1 (unsigned int x) +{ + return (x << 24) | (x >> 8); +} + +unsigned int +f2 (unsigned *p) +{ + return ((f1 (p[0]) | (p[0] >> 8)) & 0xff000000U) | (p[0] >> 24) | ((p[0] & 0xff00U) << 8) | ((p[0] & 0xff0000U) >> 8); +} + +unsigned int +f3 (unsigned *p) +{ + return ((f1 (p[0]) | (p[0] & 0x00ff00ffU)) & 0xff00ff00U) | (f1 (f1 (f1 (p[0]))) & 0x00ff00ffU); +} + +unsigned int +f4 (unsigned *p) +{ + return (f1 (p[0]) ^ (p[0] >> 8)) ^ (p[0] >> 24) ^ ((p[0] & 0xff00U) << 8) ^ ((p[0] & 0xff0000U) >> 8); +} + +unsigned int +f5 (unsigned *p) +{ + return (((f1 (p[0]) | (p[0] >> 16)) ^ (p[0] >> 8)) & 0xffff0000U) ^ (p[0] >> 24) ^ ((p[0] & 0xff00U) << 8) ^ ((p[0] & 0xff0000U) >> 8); +} + +/* { dg-final { scan-tree-dump-times "= __builtin_bswap32 \\\(" 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/opts-1.c b/SingleSource/Regression/C/gcc-dg/opts-1.c new file mode 100644 index 0000000000..3b90fe97dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/opts-1.c @@ -0,0 +1,9 @@ +/* Test negative forms of various options are rejected. */ +/* { dg-do compile } */ +/* { dg-options "-Wno-strict-aliasing=1 -Wno-strict-overflow=1 -fno-abi-version=1 -fno-lto-compression-level=1 -fno-tree-parallelize-loops=1" } */ + +/* { dg-error "-fno-abi-version" "-fno-abi-version" { target *-*-* } 0 } */ +/* { dg-error "-fno-lto-compression-level" "-fno-lto-compression-level" { target *-*-* } 0 } */ +/* { dg-error "-fno-tree-parallelize-loops" "-fno-tree-parallelize-loops" { target *-*-* } 0 } */ +/* { dg-error "-Wno-strict-overflow" "-Wno-strict-overflow" { target *-*-* } 0 } */ +/* { dg-error "-Wno-strict-aliasing" "-Wno-strict-aliasing" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/opts-2.c b/SingleSource/Regression/C/gcc-dg/opts-2.c new file mode 100644 index 0000000000..f7683635a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/opts-2.c @@ -0,0 +1,8 @@ +/* -O as an operand to another option should not take effect as an + optimization option. */ +/* { dg-do compile } */ +/* { dg-options "-I -O" } */ + +#ifdef __OPTIMIZE__ +#error "__OPTIMIZE__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/opts-3.c b/SingleSource/Regression/C/gcc-dg/opts-3.c new file mode 100644 index 0000000000..50cd1db52d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/opts-3.c @@ -0,0 +1,7 @@ +/* Parameters of -Xassembler should not be interpreted as driver + options (and so cause the driver to exit prematurely, as in this + testcase, or have other unintended effects). */ +/* { dg-do compile } */ +/* { dg-options "-Xassembler -dumpmachine" } */ + +int int x; /* { dg-error "two or more data types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/opts-4.c b/SingleSource/Regression/C/gcc-dg/opts-4.c new file mode 100644 index 0000000000..b549ec623d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/opts-4.c @@ -0,0 +1,8 @@ +/* --dump= should translate to -d with joined operand. */ +/* { dg-do compile } */ +/* { dg-options "--dump=a" } */ + +void f (void) +{ +} + diff --git a/SingleSource/Regression/C/gcc-dg/opts-5.c b/SingleSource/Regression/C/gcc-dg/opts-5.c new file mode 100644 index 0000000000..80bead8485 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/opts-5.c @@ -0,0 +1,5 @@ +/* -fstack-limit should be rejected without an ICE. */ +/* { dg-do compile } */ +/* { dg-options "-fstack-limit" } */ + +/* { dg-error "unrecognized command-line option" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/opts-6.c b/SingleSource/Regression/C/gcc-dg/opts-6.c new file mode 100644 index 0000000000..b0441dc393 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/opts-6.c @@ -0,0 +1,6 @@ +/* Missing option arguments take precedence over wrong-language + warnings. */ +/* { dg-do compile } */ +/* { dg-options "-ftemplate-depth=" } */ + +/* { dg-error "missing argument" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/opts-7.c b/SingleSource/Regression/C/gcc-dg/opts-7.c new file mode 100644 index 0000000000..c54d0b8215 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/opts-7.c @@ -0,0 +1,6 @@ +/* PR driver/71063 */ +/* Test we don't ICE. */ +/* { dg-do compile } */ +/* { dg-options "--help=^" } */ + +/* { dg-error "missing argument to" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/opts-8.c b/SingleSource/Regression/C/gcc-dg/opts-8.c new file mode 100644 index 0000000000..7837197ed4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/opts-8.c @@ -0,0 +1,6 @@ +/* PR target/82880 */ +/* Test we don't ICE or hang. */ +/* { dg-do compile } */ +/* { dg-options "--help=target --help=optimizers" } */ +/* { dg-allow-blank-lines-in-output 1 } */ +/* { dg-prune-output ".*" } */ diff --git a/SingleSource/Regression/C/gcc-dg/ordered-comparison-1.c b/SingleSource/Regression/C/gcc-dg/ordered-comparison-1.c new file mode 100644 index 0000000000..0131c9da8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ordered-comparison-1.c @@ -0,0 +1,21 @@ +/* Test warning for ordered comparison pointer with null pointer constant. */ +/* Tested with no warning option. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +extern void z(); +void *p; + +void f() { + if (z >= 0) + z(); + if (0 >= z) + z(); + if (p >= (void*)0) + z(); + if ((void*)0 >= p) + z(); + if (z >= (void*)0) /* { dg-warning "distinct pointer types lacks a cast" } */ + z(); + if ((void*)0 >=z) /* { dg-warning "distinct pointer types lacks a cast" } */ + z(); +} diff --git a/SingleSource/Regression/C/gcc-dg/ordered-comparison-2.c b/SingleSource/Regression/C/gcc-dg/ordered-comparison-2.c new file mode 100644 index 0000000000..a99d9c32fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ordered-comparison-2.c @@ -0,0 +1,21 @@ +/* Test warning for ordered comparison pointer with null pointer constant. */ +/* Tested with -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ +extern void z(); +void *p; + +void f() { + if (z >= 0) /* { dg-warning "ordered comparison of pointer with" } */ + z(); + if (0 >= z) /* { dg-warning "ordered comparison of pointer with" } */ + z(); + if (p >= (void*)0) + z(); + if ((void*)0 >= p) + z(); + if (z >= (void*)0) /* { dg-warning "distinct pointer types lacks a cast" } */ + z(); + if ((void*)0 >=z) /* { dg-warning "distinct pointer types lacks a cast" } */ + z(); +} diff --git a/SingleSource/Regression/C/gcc-dg/ordered-comparison-3.c b/SingleSource/Regression/C/gcc-dg/ordered-comparison-3.c new file mode 100644 index 0000000000..2e4be4905e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ordered-comparison-3.c @@ -0,0 +1,21 @@ +/* Test warning for ordered comparison pointer with null pointer constant. */ +/* Test with -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ +extern void z(); +void *p; + +void f() { + if ( z >= 0 ) /* { dg-error "ordered comparison of pointer with" } */ + z(); + if ( 0 >= z) /* { dg-error "ordered comparison of pointer with" } */ + z(); + if ( p >= (void*)0 ) + z(); + if ( (void*)0 >= p) + z(); + if (z >= (void*)0) /* { dg-error "distinct pointer types lacks a cast" } */ + z(); + if ((void*)0 >=z) /* { dg-error "distinct pointer types lacks a cast" } */ + z(); +} diff --git a/SingleSource/Regression/C/gcc-dg/ordered-comparison-4.c b/SingleSource/Regression/C/gcc-dg/ordered-comparison-4.c new file mode 100644 index 0000000000..ebe9eddf3e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ordered-comparison-4.c @@ -0,0 +1,21 @@ +/* Test warning for ordered comparison pointer with null pointer constant. */ +/* Test with -Wextra. */ +/* { dg-do compile } */ +/* { dg-options "-Wextra" } */ +extern void z(); +void *p; + +void f() { + if (z >= 0) /* { dg-warning "ordered comparison of pointer with" } */ + z(); + if (0 >= z) /* { dg-warning "ordered comparison of pointer with" } */ + z(); + if (p >= (void*)0) /* { dg-warning "ordered comparison of pointer with null pointer" } */ + z(); + if ((void*)0 >= p) /* { dg-warning "ordered comparison of pointer with null pointer" } */ + z(); + if (z >= (void*)0) /* { dg-warning "distinct pointer types lacks a cast" } */ + z(); + if ((void*)0 >=z) /* { dg-warning "distinct pointer types lacks a cast" } */ + z(); +} diff --git a/SingleSource/Regression/C/gcc-dg/out-of-bounds-1.c b/SingleSource/Regression/C/gcc-dg/out-of-bounds-1.c new file mode 100644 index 0000000000..5c134c096e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/out-of-bounds-1.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/33822 */ +/* Origin: Andrew Pinski */ + +/* { dg-do compile } */ +/* { dg-options "-O -g" } */ +/* { dg-options "-O -g -mstrict-align" { target { powerpc*-*-linux* powerpc*-*-elf* } } } */ + +void ProjectOverlay(const float localTextureAxis[2], char *lump) +{ + const void *d = &localTextureAxis; + int size = sizeof(float)*7 ; + __builtin_memcpy( &lump[ 0 ], d, size ); /* { dg-warning "reading" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-1.c b/SingleSource/Regression/C/gcc-dg/overflow-1.c new file mode 100644 index 0000000000..db51a5ef12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-1.c @@ -0,0 +1,25 @@ +/* PR optimization/13318 */ +/* Origin: */ +/* Reduced testcase: Wolfgang Bangerth */ + +/* Verify that the big multiplier doesn't cause an integer + overflow in the loop optimizer. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct S { + int key; + int rnext,rprev; +}; + +void foo(struct S* H) +{ + int i, k; + for (i=0; i<2; i++){ + struct S* cell=H+k; + cell->key=i*(0xffffffffUL/2); + cell->rnext=k+(1-i); + cell->rprev=k+(1-i); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-2.c b/SingleSource/Regression/C/gcc-dg/overflow-2.c new file mode 100644 index 0000000000..23c22a65de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +/* PR c/24599 */ + +int +main (void) +{ + if ((_Bool)(__INT_MAX__ + 1)) /* { dg-warning "overflow in expression" } */ + return 1; + else + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-1.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-1.c new file mode 100644 index 0000000000..a9d9fbae14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-1.c @@ -0,0 +1,124 @@ +/* Test for diagnostics for constant overflow. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +#include + +enum e { + E0 = INT_MAX, + /* Unsigned overflow wraps around. */ + E1 = UINT_MAX + 1, + /* Overflow in an unevaluated part of an expression is OK (example + in the standard). */ + E2 = 2 || 1 / 0, + E3 = 1 / 0, /* { dg-warning "10:division by zero" } */ + /* { dg-error "3:enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } .-1 } */ + /* But as in DR#031, the 1/0 in an evaluated subexpression means the + whole expression violates the constraints. */ + E4 = 0 * (1 / 0), /* { dg-warning "15:division by zero" } */ + /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } .-1 } */ + E5 = INT_MAX + 1, /* { dg-warning "16:integer overflow in expression" } */ + /* Again, overflow in evaluated subexpression. */ + E6 = 0 * (INT_MAX + 1), /* { dg-warning "21:integer overflow in expression" } */ + /* A cast does not constitute overflow in conversion. */ + E7 = (char) INT_MAX +}; + +struct s { + int a; + int : 0 * (1 / 0); /* { dg-warning "16:division by zero" } */ + /* { dg-error "not an integer constant" "22:integer constant" { target *-*-* } .-1 } */ + int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ +}; + +void +f (void) +{ + /* This expression is not required to be a constant expression, so + it should just involve undefined behavior at runtime. */ + int c = INT_MAX + 1; /* { dg-warning "19:integer overflow in expression" } */ +} + +/* But this expression does need to be constant. */ +static int sc = INT_MAX + 1; /* { dg-warning "25:integer overflow in expression" } */ + +/* The first two of these involve overflow, so are not null pointer + constants. The third has the overflow in an unevaluated + subexpression, so is a null pointer constant. */ +void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ +/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-1 } */ +void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ +/* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ +/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +void *r = (1 ? 0 : INT_MAX+1); + +void +g (int i) +{ + switch (i) + { + case 0 * (1/0): /* { dg-warning "division by zero" } */ + /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } .-1 } */ + ; + case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */ + ; + } +} + +int +h (void) +{ + return INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +} + +int +h1 (void) +{ + return INT_MAX + 1 - INT_MAX; /* { dg-warning "integer overflow in expression" } */ +} + +void fuc (unsigned char); +void fsc (signed char); + +void +h2 (void) +{ + fsc (SCHAR_MAX + 1); + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value " } */ + fsc (UCHAR_MAX); + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value from " } */ + fuc (-1); + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ + fuc (SCHAR_MIN); + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ +} + +void fui (unsigned int); +void fsi (signed int); + +int si; +unsigned ui; + +void +h2i (int x) +{ + /* For some reason, we only give certain warnings for implicit + conversions among values of the same precision with -Wconversion, + while we don't give others at all. */ + fsi ((unsigned)INT_MAX + 1); + si = (unsigned)INT_MAX + 1; + si = x ? (unsigned)INT_MAX + 1 : 1; + fsi ((unsigned)INT_MAX + 2); + si = (unsigned)INT_MAX + 2; + si = x ? (unsigned)INT_MAX + 2 : 1; + fsi (UINT_MAX); + si = UINT_MAX; + fui (-1); + ui = -1; + ui = x ? -1 : 1U; + fui (INT_MIN); + ui = INT_MIN; + ui = x ? INT_MIN : 1U; +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-2.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-2.c new file mode 100644 index 0000000000..9232800fb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-2.c @@ -0,0 +1,135 @@ +/* Test for diagnostics for constant overflow. Test with -Wtraditional-conversion. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Wtraditional-conversion" } */ + +#include + +enum e { + E0 = INT_MAX, + /* Unsigned overflow wraps around. */ + E1 = UINT_MAX + 1, + /* Overflow in an unevaluated part of an expression is OK (example + in the standard). */ + E2 = 2 || 1 / 0, + E3 = 1 / 0, /* { dg-warning "division by zero" } */ + /* { dg-error "enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } .-1 } */ + /* But as in DR#031, the 1/0 in an evaluated subexpression means the + whole expression violates the constraints. */ + E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */ + /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } .-1 } */ + E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */ + /* Again, overflow in evaluated subexpression. */ + E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */ + /* A cast does not constitute overflow in conversion. */ + E7 = (char) INT_MAX +}; + +struct s { + int a; + int : 0 * (1 / 0); /* { dg-warning "division by zero" } */ + /* { dg-error "not an integer constant" "integer constant" { target *-*-* } .-1 } */ + int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ +}; + +void +f (void) +{ + /* This expression is not required to be a constant expression, so + it should just involve undefined behavior at runtime. */ + int c = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +} + +/* But this expression does need to be constant. */ +static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ + +/* The first two of these involve overflow, so are not null pointer + constants. The third has the overflow in an unevaluated + subexpression, so is a null pointer constant. */ +void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ +/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-1 } */ +void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ +/* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ +/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +void *r = (1 ? 0 : INT_MAX+1); + +void +g (int i) +{ + switch (i) + { + case 0 * (1/0): /* { dg-warning "division by zero" } */ + /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } .-1 } */ + ; + case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */ + ; + } +} + +int +h (void) +{ + return INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +} + +int +h1 (void) +{ + return INT_MAX + 1 - INT_MAX; /* { dg-warning "integer overflow in expression" } */ +} + +void fuc (unsigned char); +void fsc (signed char); + +void +h2 (void) +{ + fsc (SCHAR_MAX + 1); + /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + fsc (UCHAR_MAX); + /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from 'int' to 'signed char' changes value " } */ + /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + fuc (-1); + /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ + /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + fuc (SCHAR_MIN); + /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ + /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ + /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ +} + +void fui (unsigned int); +void fsi (signed int); + +int si; +unsigned ui; + +void +h2i (int x) +{ + /* For some reason, we only give certain warnings for implicit + conversions among values of the same precision with -Wtraditional-conversion, + while we don't give others at all. */ + fsi ((unsigned)INT_MAX + 1); /* { dg-warning "passing argument 1 of 'fsi' as signed due to prototype" } */ + si = (unsigned)INT_MAX + 1; + si = x ? (unsigned)INT_MAX + 1 : 1; + fsi ((unsigned)INT_MAX + 2); /* { dg-warning "passing argument 1 of 'fsi' as signed due to prototype" } */ + si = (unsigned)INT_MAX + 2; + si = x ? (unsigned)INT_MAX + 2 : 1; + fsi (UINT_MAX); /* { dg-warning "passing argument 1 of 'fsi' as signed due to prototype" } */ + si = UINT_MAX; + fui (-1); + /* { dg-warning "passing argument 1 of 'fui' as unsigned due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + ui = -1; + ui = x ? -1 : 1U; + fui (INT_MIN); + /* { dg-warning "passing argument 1 of 'fui' as unsigned due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ + ui = INT_MIN; + ui = x ? INT_MIN : 1U; +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-3.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-3.c new file mode 100644 index 0000000000..f64047795c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-3.c @@ -0,0 +1,131 @@ +/* Test for diagnostics for constant overflow. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic" } */ + +#include + +enum e { + E0 = INT_MAX, + /* Unsigned overflow wraps around. */ + E1 = UINT_MAX + 1, + /* Overflow in an unevaluated part of an expression is OK (example + in the standard). */ + E2 = 2 || 1 / 0, + E3 = 1 / 0, /* { dg-warning "division by zero" } */ + /* { dg-error "enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } .-1 } */ + /* But as in DR#031, the 1/0 in an evaluated subexpression means the + whole expression violates the constraints. */ + E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */ + /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } .-1 } */ + E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */ + /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + /* Again, overflow in evaluated subexpression. */ + E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */ + /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + /* A cast does not constitute overflow in conversion. */ + E7 = (char) INT_MAX +}; + +struct s { + int a; + int : 0 * (1 / 0); /* { dg-warning "division by zero" } */ + /* { dg-error "not an integer constant" "integer constant" { target *-*-* } .-1 } */ + int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ + /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */ +}; + +void +f (void) +{ + /* This expression is not required to be a constant expression, so + it should just involve undefined behavior at runtime. */ + int c = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ + +} + +/* But this expression does need to be constant. */ +static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + +/* The first two of these involve overflow, so are not null pointer + constants. The third has the overflow in an unevaluated + subexpression, so is a null pointer constant. */ +void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ +/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */ +/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ +/* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ +/* { dg-warning "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +void *r = (1 ? 0 : INT_MAX+1); + +void +g (int i) +{ + switch (i) + { + case 0 * (1/0): /* { dg-warning "division by zero" } */ + /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } .-1 } */ + ; + case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */ + /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + ; + } +} + +int +h (void) +{ + return INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +} + +int +h1 (void) +{ + return INT_MAX + 1 - INT_MAX; /* { dg-warning "integer overflow in expression" } */ +} + +void fuc (unsigned char); +void fsc (signed char); + +void +h2 (void) +{ + fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value " } */ + fuc (-1); + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ + fuc (SCHAR_MIN); + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ +} + +void fui (unsigned int); +void fsi (signed int); + +int si; +unsigned ui; + +void +h2i (int x) +{ + /* For some reason, we only give certain warnings for implicit + conversions among values of the same precision with -Wconversion, + while we don't give others at all. */ + fsi ((unsigned)INT_MAX + 1); + si = (unsigned)INT_MAX + 1; + si = x ? (unsigned)INT_MAX + 1 : 1; + fsi ((unsigned)INT_MAX + 2); + si = (unsigned)INT_MAX + 2; + si = x ? (unsigned)INT_MAX + 2 : 1; + fsi (UINT_MAX); + si = UINT_MAX; + fui (-1); + ui = -1; + ui = x ? -1 : 1U; + fui (INT_MIN); + ui = INT_MIN; + ui = x ? INT_MIN : 1U; +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-4.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-4.c new file mode 100644 index 0000000000..eb595aa791 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-4.c @@ -0,0 +1,131 @@ +/* Test for diagnostics for constant overflow. Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +#include + +enum e { + E0 = INT_MAX, + /* Unsigned overflow wraps around. */ + E1 = UINT_MAX + 1, + /* Overflow in an unevaluated part of an expression is OK (example + in the standard). */ + E2 = 2 || 1 / 0, + E3 = 1 / 0, /* { dg-warning "division by zero" } */ + /* { dg-error "enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } .-1 } */ + /* But as in DR#031, the 1/0 in an evaluated subexpression means the + whole expression violates the constraints. */ + E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */ + /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } .-1 } */ + E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + /* Again, overflow in evaluated subexpression. */ + E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression of type .int. results in .-\[0-9\]+." } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + /* A cast does not constitute overflow in conversion. */ + E7 = (char) INT_MAX +}; + +struct s { + int a; + int : 0 * (1 / 0); /* { dg-warning "division by zero" } */ + /* { dg-error "not an integer constant" "integer constant" { target *-*-* } .-1 } */ + int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ +}; + +void +f (void) +{ + /* This expression is not required to be a constant expression, so + it should just involve undefined behavior at runtime. */ + int c = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ + +} + +/* But this expression does need to be constant. */ +static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + +/* The first two of these involve overflow, so are not null pointer + constants. The third has the overflow in an unevaluated + subexpression, so is a null pointer constant. */ +void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */ +/* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ +/* { dg-error "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */ +/* { dg-error "initializer element is not constant" "constant" { target *-*-* } .-1 } */ +/* { dg-error "initialization of 'void \\*' from 'int' makes pointer from integer without a cast" "null" { target *-*-* } .-2 } */ +void *r = (1 ? 0 : INT_MAX+1); + +void +g (int i) +{ + switch (i) + { + case 0 * (1/0): /* { dg-warning "division by zero" } */ + /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } .-1 } */ + ; + case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */ + /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ + ; + } +} + +int +h (void) +{ + return INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */ +} + +int +h1 (void) +{ + return INT_MAX + 1 - INT_MAX; /* { dg-warning "integer overflow in expression" } */ +} + +void fuc (unsigned char); +void fsc (signed char); + +void +h2 (void) +{ + fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion" } */ + fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion" } */ + fuc (-1); + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ + fuc (SCHAR_MIN); + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion" } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion" } */ +} + +void fui (unsigned int); +void fsi (signed int); + +int si; +unsigned ui; + +void +h2i (int x) +{ + /* For some reason, we only give certain warnings for implicit + conversions among values of the same precision with -Wconversion, + while we don't give others at all. */ + fsi ((unsigned)INT_MAX + 1); + si = (unsigned)INT_MAX + 1; + si = x ? (unsigned)INT_MAX + 1 : 1; + fsi ((unsigned)INT_MAX + 2); + si = (unsigned)INT_MAX + 2; + si = x ? (unsigned)INT_MAX + 2 : 1; + fsi (UINT_MAX); + si = UINT_MAX; + fui (-1); + ui = -1; + ui = x ? -1 : 1U; + fui (INT_MIN); + ui = INT_MIN; + ui = x ? INT_MIN : 1U; +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-5.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-5.c new file mode 100644 index 0000000000..1a5aa0c605 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-5.c @@ -0,0 +1,7 @@ +/* PR c/27273 */ +/* { dg-do compile } */ +/* { dg-options "-Woverflow" } */ + +unsigned char rx_async(unsigned char p) { + return p & 512; /* { dg-warning "overflow in conversion from .int. to .unsigned char. changes value" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-6.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-6.c new file mode 100644 index 0000000000..b3bc73610c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-6.c @@ -0,0 +1,18 @@ +/* Test non-constant operands in overflowed expressions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Woverflow" } */ + +#include + +int +h1 (int x) +{ + return x * (0 * (INT_MAX + 1)); /* { dg-warning "integer overflow in expression" } */ +} + +int +h2 (int x) +{ + return ((INT_MAX + 1) * 0) * x; /* { dg-warning "integer overflow in expression" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-7.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-7.c new file mode 100644 index 0000000000..7c0ce68df5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-7.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int f(char *device) +{ + return device == ((char *)0 + ~0UL); /* { dg-bogus "overflow" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-8.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-8.c new file mode 100644 index 0000000000..e76bcac5e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-8.c @@ -0,0 +1,23 @@ +#include + +void foo (int j) +{ + int i1 = (int)(double)1.0 + INT_MAX; /* { dg-warning "integer overflow" } */ + int i2 = (int)(double)1 + INT_MAX; /* { dg-warning "integer overflow" } */ + int i3 = 1 + INT_MAX; /* { dg-warning "integer overflow" } */ + int i4 = +1 + INT_MAX; /* { dg-warning "integer overflow" } */ + int i5 = (int)((double)1.0 + INT_MAX); + int i6 = (double)1.0 + INT_MAX; /* { dg-warning "overflow in conversion from .double. to .int. changes value" } */ + int i7 = 0 ? (int)(double)1.0 + INT_MAX : 1; + int i8 = 1 ? 1 : (int)(double)1.0 + INT_MAX; + int i9 = j ? (int)(double)1.0 + INT_MAX : 1; /* { dg-warning "integer overflow" } */ + unsigned int i10 = 0 ? (int)(double)1.0 + INT_MAX : 9U; + unsigned int i11 = 1 ? 9U : (int)(double)1.0 + INT_MAX; + unsigned int i12 = j ? (int)(double)1.0 + INT_MAX : 9U; /* { dg-warning "integer overflow" } */ + int i13 = 1 || (int)(double)1.0 + INT_MAX < 0; + int i14 = 0 && (int)(double)1.0 + INT_MAX < 0; + int i15 = 0 || (int)(double)1.0 + INT_MAX < 0; /* { dg-warning "integer overflow" } */ + int i16 = 1 && (int)(double)1.0 + INT_MAX < 0; /* { dg-warning "integer overflow" } */ + int i17 = j || (int)(double)1.0 + INT_MAX < 0; /* { dg-warning "integer overflow" } */ + int i18 = j && (int)(double)1.0 + INT_MAX < 0; /* { dg-warning "integer overflow" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/overflow-warn-9.c b/SingleSource/Regression/C/gcc-dg/overflow-warn-9.c new file mode 100644 index 0000000000..ae588bd849 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/overflow-warn-9.c @@ -0,0 +1,66 @@ +/* PR c/80731 - poor -Woverflow warnings, missing detail + { dg-do compile } + { dg-options "-Wconversion -Woverflow -Wno-override-init -std=c99" } + { dg-require-effective-target int32plus } */ + +#include + +struct Types +{ + signed char sc; + unsigned char uc; + signed short ss; + unsigned short us; + signed int si; + unsigned int ui; + signed long sl; + unsigned long ul; + signed long long sll; + unsigned long long ull; +}; + +const struct Types t1 = { + /* According to 6.3.1.3 of C11: + -2- Otherwise, if the new type is unsigned, the value is converted + by repeatedly adding or subtracting one more than the maximum + value that can be represented in the new type until the value + is in the range of the new type. + + These conversions are diagnosed by -Wsign-conversion and -Wconversion, + respectively, by mentioning "unsigned conversion" if the conversion + results in sign change, and just "conversion" otherwise, as follows: */ + + .uc = SCHAR_MIN, /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value from .-128. to .128." } */ + .uc = -1, /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value from .-1. to .255." } */ + + .uc = UCHAR_MAX + 1, /* { dg-warning "conversion from 'int' to 'unsigned char' changes value from .256. to .0." } */ + .uc = UCHAR_MAX * 2, /* { dg-warning "conversion from 'int' to 'unsigned char' changes value from .510. to .254." } */ + + /* According to 6.3.1.3 of C11: + -3- Otherwise, the new type is signed and the value cannot be + represented in it; either the result is implementation-defined + or an implementation-defined signal is raised. + + In GCC such conversions wrap and are diagnosed by mentioning "overflow" + if the absolute value of the operand is in excess of the maximum of + the destination of type, and "conversion" otherwise, as follows: */ + + .sc = SCHAR_MAX + 1, /* { dg-warning "conversion from .int. to .signed char. changes value from .128. to .-128." } */ + .sc = SCHAR_MAX + 2, /* { dg-warning "conversion from .int. to .signed char. changes value from .129. to .-127." } */ + .sc = SCHAR_MAX * 2, /* { dg-warning "conversion from .int. to .signed char. changes value from .254. to .-2." } */ + .sc = SCHAR_MAX * 2 + 3, /* { dg-warning "conversion from .int. to .signed char. changes value from .257. to .1." } */ + .sc = SCHAR_MAX * 3 + 3, /* { dg-warning "conversion from .int. to .signed char. changes value from .384. to .-128." } */ + + + .ss = SHRT_MAX + 1, /* { dg-warning "conversion from 'int' to 'short int' changes value from .32768. to .-32768." } */ + .us = USHRT_MAX + 1, /* { dg-warning "unsigned conversion from .int. to .short unsigned int. changes value from .65536. to .0." } */ + + .si = INT_MAX + 1LU, /* { dg-warning "signed conversion from 'long unsigned int. to 'int' changes value from .2147483648. to .-2147483648." } */ + .ui = UINT_MAX + 1L, /* { dg-warning "signed conversion from .long int. to .unsigned int. changes value from .4294967296. to .0." "lp64" { target lp64 } } */ + .ui = UINT_MAX + 1LU, /* { dg-warning "conversion from .long unsigned int. to .unsigned int. changes value from .4294967296. to .0." "lp64" { target lp64 } } */ + + .sl = LONG_MAX + 1LU, /* { dg-warning "signed conversion from .long unsigned int. to .long int. changes value from .9223372036854775808. to .-9223372036854775808." "lp64" { target lp64 } } */ + /* { dg-warning "signed conversion from .long unsigned int. to .long int. changes value from .2147483648. to .-2147483648." "ilp32" { target ilp32 } .-1 } */ + /* { dg-warning "signed conversion from .long unsigned int. to .long int. changes value from .2147483648. to .-2147483648." "llp64" { target llp64 } .-2 } */ + .ul = ULONG_MAX + 1LU /* there should be some warning here */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/pack-test-1.c b/SingleSource/Regression/C/gcc-dg/pack-test-1.c new file mode 100644 index 0000000000..e019e78379 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pack-test-1.c @@ -0,0 +1,154 @@ +/* Test semantics of #pragma pack. + Contributed by Mike Coleman */ + +/* { dg-do compile { target { ! default_packed } } } */ + +/* Mainly we're just testing whether pushing and popping seem to be + working correctly, and verifying the (alignment == 1) case, which + is really the only reason anyone would use this pragma anyway. */ + +#include + +/* generalized compile-time test expression */ +#define test(n, expr) int test_##n [(expr) ? 1 : -1] + +/* Round V down to multiple of A */ +#define floor(v,a) ((v) / (a) * (a)) + +/* Offset of field with alignment A in structure S after a field P of + type PT */ +#define offset(s,p,pt,a) \ + floor ((offsetof(struct s, p) + sizeof (pt) + (a) - 1), a) + +/* regular minimum */ +#define min(a,b) ((a) < (b) ? (a) : (b)) + +/* Check that field A (type AT) followed by field B (type BT) are + packed according to P */ +#define test_pack(n, a, at, b, bt, p) \ + test(n, offsetof (struct SNAME, b) \ + == min (offset (SNAME,a,at,__alignof__(bt)), \ + offset (SNAME,a,at,p))) + +/* Test offset of field F in structs s1 and s2 are the same. */ +#define test_offset(n, s1, s2, f) \ + test (n, (offsetof(struct s1, f) == offsetof(struct s2, f))) + +#define SNAME s0 +#include "pack-test-1.h" + +#undef SNAME +#define SNAME s1 +#pragma pack(push, p1, 1) +#include "pack-test-1.h" + +void SNAME() { + test_pack(0, f0, char, f1, double, 1); + test_pack(1, f2, short, f3, double, 1); + test_pack(2, f4, int, f5, double, 1); +} + +#undef SNAME +#define SNAME s2 +#pragma pack(push, p2, 2) +#include "pack-test-1.h" + +void SNAME() { + test_pack(0, f0, char, f1, double, 2); + test_pack(1, f2, short, f3, double, 2); + test_pack(2, f4, int, f5, double, 2); +} + +#undef SNAME +#define SNAME s3 +#pragma pack(push, p3, 4) +#include "pack-test-1.h" + +void SNAME() { + test_pack(0, f0, char, f1, double, 4); + test_pack(1, f2, short, f3, double, 4); + test_pack(2, f4, int, f5, double, 4); +} + +#undef SNAME +#define SNAME s4 +#pragma pack(pop) +#include "pack-test-1.h" + +void SNAME() { + test_pack(0, f0, char, f1, double, 2); + test_pack(1, f2, short, f3, double, 2); + test_pack(2, f4, int, f5, double, 2); +} + +#undef SNAME +#define SNAME s5 +#pragma pack(pop, p2) +#include "pack-test-1.h" + +void SNAME() { + test_pack(0, f0, char, f1, double, 1); + test_pack(1, f2, short, f3, double, 1); + test_pack(2, f4, int, f5, double, 1); +} + +#undef SNAME +#define SNAME s6 +#pragma pack(pop, p1) +#include "pack-test-1.h" + +void SNAME() { + test_offset (0, s0, SNAME, f0); + test_offset (1, s0, SNAME, f1); + test_offset (2, s0, SNAME, f2); + test_offset (3, s0, SNAME, f3); + test_offset (4, s0, SNAME, f4); + test_offset (5, s0, SNAME, f5); +} + +#undef SNAME +#define SNAME s7 +#pragma pack(1) +#include "pack-test-1.h" + +void SNAME() { + test_pack(0, f0, char, f1, double, 1); + test_pack(1, f2, short, f3, double, 1); + test_pack(2, f4, int, f5, double, 1); +} + +#undef SNAME +#define SNAME s8 +#pragma pack(push, p2, 2) +#include "pack-test-1.h" + +void SNAME() { + test_pack(0, f0, char, f1, double, 2); + test_pack(1, f2, short, f3, double, 2); + test_pack(2, f4, int, f5, double, 2); +} + +#undef SNAME +#define SNAME s9 +#pragma pack(pop) +#include "pack-test-1.h" + +void SNAME() { + test_pack(0, f0, char, f1, double, 1); + test_pack(1, f2, short, f3, double, 1); + test_pack(2, f4, int, f5, double, 1); +} + +#undef SNAME +#define SNAME s10 +#pragma pack() +#include "pack-test-1.h" + +void SNAME() { + test_offset (0, s0, SNAME, f0); + test_offset (1, s0, SNAME, f1); + test_offset (2, s0, SNAME, f2); + test_offset (3, s0, SNAME, f3); + test_offset (4, s0, SNAME, f4); + test_offset (5, s0, SNAME, f5); +} diff --git a/SingleSource/Regression/C/gcc-dg/pack-test-1.h b/SingleSource/Regression/C/gcc-dg/pack-test-1.h new file mode 100644 index 0000000000..f4889fabef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pack-test-1.h @@ -0,0 +1,12 @@ +/* Helper file, included repeatedly by pack-test-1.c. */ + +struct SNAME { + char f0; + double f1; + short f2; + double f3; + int f4; + double f5; + double f6; + double f7; +}; diff --git a/SingleSource/Regression/C/gcc-dg/pack-test-2.c b/SingleSource/Regression/C/gcc-dg/pack-test-2.c new file mode 100644 index 0000000000..5c2f6ae466 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pack-test-2.c @@ -0,0 +1,25 @@ +/* Tests for syntax checking of #pragma pack. + Contributed by Mike Coleman */ + +/* { dg-do compile } */ + +#pragma pack(pop) /* { dg-warning "without matching" } */ + +#pragma pack(push) +#pragma pack(pop) /* reset */ + +#pragma pack(push, foo, 1) +#pragma pack(pop, foo, 1) /* { dg-warning "malformed" } (/ +#pragma pack(pop) /* reset */ + +#pragma pack(push, foo, 1) +#pragma pack(pop, bar) /* { dg-warning "without matching" } */ +#pragma pack(pop) /* reset */ + +#pragma pack(push, foo, 1) +#pragma pack(pop) +#pragma pack(pop, foo) /* { dg-warning "without matching" } */ + +#pragma pack(push, foo, 3) /* { dg-warning "small power of two" } */ + +extern int blah; /* prevent "ISO C forbids an empty translation unit" */ diff --git a/SingleSource/Regression/C/gcc-dg/pack-test-3.c b/SingleSource/Regression/C/gcc-dg/pack-test-3.c new file mode 100644 index 0000000000..bd78fad9b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pack-test-3.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ + +/* Copyright (C) 2003 Free Software Foundation, Inc. + Contributed by Nathan Sidwell 15 Jul 2003 */ + +/* you should not be able to pack a typedef to a struct, only the + underlying struct can be packed. */ + +/* ok */ +struct u1 +{ + char field1; + short field2; + int field3; +}; + +/* ok */ +typedef struct p1 { + char field1; + short field2; + int field3; +} __attribute__ ((packed)) p1_t1; + +/* ok */ +typedef struct __attribute__ ((packed)) p2 { + char field1; + short field2; + int field3; +} p2_t1; + +int ary1[sizeof (struct p1) == sizeof (p1_t1) ? 1 : -1]; +int ary2[sizeof (struct p2) == sizeof (p2_t1) ? 1 : -1]; +int ary3[sizeof (struct p1) == sizeof (struct p2) ? 1 : -1]; + +/* not ok */ +typedef struct u1 __attribute__ ((packed)) u1_t1; /* { dg-warning "attribute ignored" }*/ +typedef struct u1 u1_t2 __attribute__ ((packed)); /* { dg-warning "attribute ignored" }*/ + +typedef struct p3 { + char field1; + short field2; + int field3; +} p3_t1 __attribute__ ((packed)); /* { dg-warning "attribute ignored" }*/ + diff --git a/SingleSource/Regression/C/gcc-dg/pack-test-4.c b/SingleSource/Regression/C/gcc-dg/pack-test-4.c new file mode 100644 index 0000000000..1ad8ee4fb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pack-test-4.c @@ -0,0 +1,36 @@ +/* PR c/11885 + Bug: flag4 was allocated into the same byte as the other flags. + { dg-options "" } + { dg-do run } */ + +extern void abort (void); + +typedef unsigned char uint8_t; + +typedef struct { + uint8_t flag1:2; + uint8_t flag2:1; + uint8_t flag3:1; + + uint8_t flag4; + +} __attribute__ ((packed)) MyType; + +int main (void) +{ + MyType a; + MyType *b = &a; + + b->flag1 = 0; + b->flag2 = 0; + b->flag3 = 0; + + b->flag4 = 0; + + b->flag4++; + + if (b->flag1 != 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pack-test-5.c b/SingleSource/Regression/C/gcc-dg/pack-test-5.c new file mode 100644 index 0000000000..3a52a002bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pack-test-5.c @@ -0,0 +1,22 @@ +/* PR c/11446: packed on a struct takes precedence over aligned on the type + of a field. */ +/* { dg-do run } */ +/* { dg-additional-options "-mno-ms-bitfields" { target *-*-mingw* } } */ + +extern void abort (void); + +struct A { + double d; +} __attribute__ ((aligned)); + +struct B { + char c; + struct A a; +} __attribute__ ((packed)); + +int main () +{ + if (sizeof (struct B) != sizeof (char) + sizeof (struct A)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/packed-array.c b/SingleSource/Regression/C/gcc-dg/packed-array.c new file mode 100644 index 0000000000..b57f3ac035 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/packed-array.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-inline" } */ + +struct usb_interface_descriptor { + unsigned short wMaxPacketSize; + char e; +} __attribute__ ((packed)); + +struct usb_device { + int devnum; + struct usb_interface_descriptor if_desc[2]; +}; + +extern int printf (const char *, ...); + +void foo (unsigned short a) +{ + printf ("%d\n", a); +} + +struct usb_device ndev; + +void usb_set_maxpacket(int n) +{ + int i; + + for(i=0; iif_desc[i].wMaxPacketSize); +} + +int +main() +{ + usb_set_maxpacket(2); + return 0; +} + + + + diff --git a/SingleSource/Regression/C/gcc-dg/packed-vla.c b/SingleSource/Regression/C/gcc-dg/packed-vla.c new file mode 100644 index 0000000000..e673b729b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/packed-vla.c @@ -0,0 +1,32 @@ +/* PR middle-end/27945 */ +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-require-effective-target alloca } */ + +extern int printf (const char *, ...); +extern void abort (); + +int func(int levels) +{ + struct bar { + unsigned char a; + int b[levels]; + } __attribute__ ((__packed__)) bar; + + struct foo { + unsigned char a; + int b[4]; + } __attribute__ ((__packed__)) foo; + + printf("foo %d\n", sizeof(foo)); + printf("bar %d\n", sizeof(bar)); + + if (sizeof (foo) != sizeof (bar)) + abort (); +} + +int main() +{ + func(4); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/param-type-mismatch.c b/SingleSource/Regression/C/gcc-dg/param-type-mismatch.c new file mode 100644 index 0000000000..9e654a9e9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/param-type-mismatch.c @@ -0,0 +1,186 @@ +/* { dg-options "-fdiagnostics-show-caret -Wpointer-sign" } */ + +/* A collection of calls where argument 2 is of the wrong type. */ + +/* decl, with argname. */ + +extern int callee_1 (int one, const char *two, float three); /* { dg-line callee_1 } */ + +int test_1 (int first, int second, float third) +{ + return callee_1 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_1' makes pointer from integer without a cast" } */ + /* { dg-begin-multiline-output "" } + return callee_1 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_1 } */ + /* { dg-begin-multiline-output "" } + extern int callee_1 (int one, const char *two, float three); + ~~~~~~~~~~~~^~~ + { dg-end-multiline-output "" } */ +} + +/* decl, without argname. */ + +extern int callee_2 (int, const char *, float); /* { dg-line callee_2 } */ + +int test_2 (int first, int second, float third) +{ + return callee_2 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_2' makes pointer from integer without a cast" } */ + /* { dg-begin-multiline-output "" } + return callee_2 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_2 } */ + /* { dg-begin-multiline-output "" } + extern int callee_2 (int, const char *, float); + ^~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +/* defn, with argname. */ + +static int callee_3 (int one, const char *two, float three) /* { dg-line callee_3 } */ +{ + return callee_2 (one, two, three); +} + +int test_3 (int first, int second, float third) +{ + return callee_3 (first, second, third); // { dg-warning "passing argument 2 of 'callee_3' makes pointer from integer without a cast" } + /* { dg-begin-multiline-output "" } + return callee_3 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_3 } */ + /* { dg-begin-multiline-output "" } + static int callee_3 (int one, const char *two, float three) + ~~~~~~~~~~~~^~~ + { dg-end-multiline-output "" } */ +} + +/* Trivial decl, with argname. */ + +extern int callee_4 (int one, float two, float three); /* { dg-line callee_4 } */ + +int test_4 (int first, const char *second, float third) +{ + return callee_4 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_4'" } */ + /* { dg-begin-multiline-output "" } + return callee_4 (first, second, third); + ^~~~~~ + | + const char * + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_4 } */ + /* { dg-begin-multiline-output "" } + extern int callee_4 (int one, float two, float three); + ~~~~~~^~~ + { dg-end-multiline-output "" } */ +} + +/* Trivial decl, without argname. */ + +extern int callee_5 (int, float, float); /* { dg-line callee_5 } */ + +int test_5 (int first, const char *second, float third) +{ + return callee_5 (first, second, third); /* { dg-error "incompatible type for argument 2 of 'callee_5'" } */ + /* { dg-begin-multiline-output "" } + return callee_5 (first, second, third); + ^~~~~~ + | + const char * + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_5 } */ + /* { dg-begin-multiline-output "" } + extern int callee_5 (int, float, float); + ^~~~~ + { dg-end-multiline-output "" } */ +} + +/* Callback with name. */ + +extern int callee_6 (int one, int (*two)(int, int), float three); /* { dg-line callee_6 } */ + +int test_6 (int first, int second, float third) +{ + return callee_6 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_6' makes pointer from integer without a cast" } */ + /* { dg-begin-multiline-output "" } + return callee_6 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_6 } */ + /* { dg-begin-multiline-output "" } + extern int callee_6 (int one, int (*two)(int, int), float three); + ~~~~~~^~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +/* Callback without name. */ + +extern int callee_7 (int one, int (*)(int, int), float three); /* { dg-line callee_7 } */ + +int test_7 (int first, int second, float third) +{ + return callee_7 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_7' makes pointer from integer without a cast" } */ + /* { dg-begin-multiline-output "" } + return callee_7 (first, second, third); + ^~~~~~ + | + int + { dg-end-multiline-output "" } */ + /* { dg-message " expected 'int \\(\\*\\)\\(int, int\\)' but argument is of type 'int'" "" { target *-*-* } callee_7 } */ + /* { dg-begin-multiline-output "" } + extern int callee_7 (int one, int (*)(int, int), float three); + ^~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +} + +/* -Wincompatible-pointer-types for a parameter. */ + +extern int callee_8 (int one, float *two, float (three)); /* { dg-line callee_8 } */ + +int test_8 (int first, int *second, float third) +{ + return callee_8 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_8' from incompatible pointer type" } */ + /* { dg-begin-multiline-output "" } + return callee_8 (first, second, third); + ^~~~~~ + | + int * + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'float \\*' but argument is of type 'int \\*'" "" { target *-*-* } callee_8 } */ + /* { dg-begin-multiline-output "" } + extern int callee_8 (int one, float *two, float (three)); + ~~~~~~~^~~ + { dg-end-multiline-output "" } */ +} + +/* -Wpointer-sign for a parameter. */ + +extern int callee_9 (int one, int *two, float (three)); /* { dg-line callee_9 } */ + +int test_9 (int first, unsigned int *second, float third) +{ + return callee_9 (first, second, third); /* { dg-warning "pointer targets in passing argument 2 of 'callee_9' differ in signedness" } */ + /* { dg-begin-multiline-output "" } + return callee_9 (first, second, third); + ^~~~~~ + | + unsigned int * + { dg-end-multiline-output "" } */ + /* { dg-message "expected 'int \\*' but argument is of type 'unsigned int \\*'" "" { target *-*-* } callee_9 } */ + /* { dg-begin-multiline-output "" } + extern int callee_9 (int one, int *two, float (three)); + ~~~~~^~~ + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/parm-forwdecl-1.c b/SingleSource/Regression/C/gcc-dg/parm-forwdecl-1.c new file mode 100644 index 0000000000..470636de95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-forwdecl-1.c @@ -0,0 +1,26 @@ +/* Test GNU parameter forward declarations. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Valid uses. */ +int f1(int a; int a); +int f2(int a; int a) { return 0; } +int f3(int a; int a; int a); +int f4(int a; int a; int a) { return 0; } +int f5(int a; int (*x)[a], int a); +int f6(int a; int (*x)[a], int a) { return 0; } +int f7(int a; int (*x)[a]; int (*y)[x[1][2]], int (*x)[a], int a); +int f8(int a; int (*x)[a]; int (*y)[x[1][2]], int (*x)[a], int a) { return 0; } + +/* Strange uses accepted by GCC 4.0 but not by 3.4 and probably not + desirable to accept. */ +int g1(int a;); /* { dg-error "just a forward declaration" "no parms" { xfail *-*-* } } */ +int g2(int a; __attribute__((unused))); /* { dg-error "just a forward declaration" "no parms" { xfail *-*-* } } */ +int g3(int;); /* { dg-error "just a forward declaration" "no parms" { xfail *-*-* } } */ +int g4(int, long;); /* { dg-error "just a forward declaration" "no parms" { xfail *-*-* } } */ + +/* Invalid uses. */ +int h1(int a; int b); /* { dg-error "just a forward declaration" } */ +int h2(int; int b); /* { dg-error "just a forward declaration" } */ +int h3(int a; long a); /* { dg-error "conflicting types|previous definition|just a forward declaration" } */ diff --git a/SingleSource/Regression/C/gcc-dg/parm-forwdecl-2.c b/SingleSource/Regression/C/gcc-dg/parm-forwdecl-2.c new file mode 100644 index 0000000000..42db4b1572 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-forwdecl-2.c @@ -0,0 +1,8 @@ +/* Test GNU parameter forward declarations. Warning with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +int f1(int a; int a); /* { dg-warning "ISO C forbids forward parameter declarations" } */ +int f2(int a; int a) { return 0; } /* { dg-warning "ISO C forbids forward parameter declarations" } */ diff --git a/SingleSource/Regression/C/gcc-dg/parm-forwdecl-3.c b/SingleSource/Regression/C/gcc-dg/parm-forwdecl-3.c new file mode 100644 index 0000000000..7937532fb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-forwdecl-3.c @@ -0,0 +1,8 @@ +/* Test GNU parameter forward declarations. Error with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +int f1(int a; int a); /* { dg-error "ISO C forbids forward parameter declarations" } */ +int f2(int a; int a) { return 0; } /* { dg-error "ISO C forbids forward parameter declarations" } */ diff --git a/SingleSource/Regression/C/gcc-dg/parm-forwdecl-4.c b/SingleSource/Regression/C/gcc-dg/parm-forwdecl-4.c new file mode 100644 index 0000000000..a210092e1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-forwdecl-4.c @@ -0,0 +1,10 @@ +/* Test GNU parameter forward declarations. OK with + -Wredundant-decls. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wredundant-decls" } */ + +int f1(int a; int a); +int f2(int a; int a) { return 0; } +int f3(int a; int a; int a); +int f4(int a; int a; int a) { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/parm-impl-decl-1.c b/SingleSource/Regression/C/gcc-dg/parm-impl-decl-1.c new file mode 100644 index 0000000000..c1219273c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-impl-decl-1.c @@ -0,0 +1,33 @@ +/* Test implicit function declarations and other odd declarations in + function prototypes. Bug 18239. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +/* Implicit function declaration in attribute in definition (testcase + from bug). */ +int +foo (int __attribute__ ((__mode__ (vector_size(8)))) i) /* { dg-warning "'mode' attribute ignored" } */ +{ + return (long long) i; +} + +/* Various other cases. */ + +int f (int [sizeof(g())]); +int f1 (int [sizeof(g1())]); + +int g () { return 1; } + +int +h (int (*p)[sizeof(i())]) +{ + int g2 (), g3 (); + return (*p)[0] + g3() + g2(); +} + +int i () { return 2; } + +int f2 (int [sizeof(g2())]); +int f3 (int [sizeof(g3())]); +int g3 () { return 4; } diff --git a/SingleSource/Regression/C/gcc-dg/parm-impl-decl-2.c b/SingleSource/Regression/C/gcc-dg/parm-impl-decl-2.c new file mode 100644 index 0000000000..22ea0c6e8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-impl-decl-2.c @@ -0,0 +1,7 @@ +/* Test implicit function declarations and other odd declarations in + function prototypes. Make sure that LABEL_DECLs don't occur. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int k (int [sizeof &&z]); /* { dg-error "label 'z' referenced outside of any function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/parm-impl-decl-3.c b/SingleSource/Regression/C/gcc-dg/parm-impl-decl-3.c new file mode 100644 index 0000000000..20197b5240 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-impl-decl-3.c @@ -0,0 +1,28 @@ +/* Like parm-impl-decl-1.c, but with -g. PR 43381. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-g -std=gnu89" } */ + +int +foo (int __attribute__ ((__mode__ (vector_size(8)))) i) /* { dg-warning "'mode' attribute ignored" } */ +{ + return (long long) i; +} + +int f (int [sizeof(g())]); +int f1 (int [sizeof(g1())]); + +int g () { return 1; } + +int +h (int (*p)[sizeof(i())]) +{ + int g2 (), g3 (); + return (*p)[0] + g3() + g2(); +} + +int i () { return 2; } + +int f2 (int [sizeof(g2())]); +int f3 (int [sizeof(g3())]); +int g3 () { return 4; } diff --git a/SingleSource/Regression/C/gcc-dg/parm-incomplete-1.c b/SingleSource/Regression/C/gcc-dg/parm-incomplete-1.c new file mode 100644 index 0000000000..02d97b933f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-incomplete-1.c @@ -0,0 +1,27 @@ +/* Test warnings and errors for incomplete parameter types. Should + not be warned for in declarations that are not definitions: bug + 17881. Void types may be a special case, especially for unnamed + parameters and when qualified or with a storage class specifier; + see C90 6.5.4.3, DR#017 Q14, C90 TC1, DR#157, C99 J.2 (referencing + C99 6.7.5.3); the precise rules are unclear. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s; +void f (struct s); +void (*g)(struct s); +struct t { void (*p)(struct s); }; + +struct s { int b; }; +void h (struct s x) { } + +void j(struct t2); /* { dg-warning "'struct t2' declared inside parameter list" } */ + +union u; + +void v(union u x) { } /* { dg-error "parameter 1 \\('x'\\) has incomplete type" } */ + +void p(void x); /* { dg-warning "parameter 1 \\('x'\\) has void type" } */ + +void q(const void x); /* { dg-warning "parameter 1 \\('x'\\) has void type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/parm-mismatch-1.c b/SingleSource/Regression/C/gcc-dg/parm-mismatch-1.c new file mode 100644 index 0000000000..d7621bcd6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parm-mismatch-1.c @@ -0,0 +1,18 @@ +/* Test diagnostics for parameter mismatches. Types that cannot match + (). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void f0(); /* { dg-message "note: previous declaration of 'f0'" "note" } */ +void f0(int, ...); /* { dg-error "conflicting types for 'f0'" } */ +/* { dg-message "note: a parameter list with an ellipsis cannot match an empty parameter name list declaration" "note" { target *-*-* } .-1 } */ +void f1(int, ...); /* { dg-message "note: previous declaration of 'f1'" "note" } */ +void f1(); /* { dg-error "conflicting types for 'f1'" } */ +/* { dg-message "note: a parameter list with an ellipsis cannot match an empty parameter name list declaration" "note" { target *-*-* } .-1 } */ +void f2(); /* { dg-message "note: previous declaration of 'f2'" "note" } */ +void f2(char); /* { dg-error "conflicting types for 'f2'" } */ +/* { dg-message "note: an argument type that has a default promotion cannot match an empty parameter name list declaration" "note" { target *-*-* } .-1 } */ +void f3(char); /* { dg-message "note: previous declaration of 'f3'" "note" } */ +void f3(); /* { dg-error "conflicting types for 'f3'" } */ +/* { dg-message "note: an argument type that has a default promotion cannot match an empty parameter name list declaration" "note" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/parse-decl-after-if.c b/SingleSource/Regression/C/gcc-dg/parse-decl-after-if.c new file mode 100644 index 0000000000..09afa37b47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-decl-after-if.c @@ -0,0 +1,11 @@ +/* Parse error recovery +{ dg-do compile } +{ dg-options "-fsyntax-only" } +*/ + +void f(int x) +{ + if (x > 1) + int ret = 1; /* { dg-error "expected expression before 'int'" } */ + +} diff --git a/SingleSource/Regression/C/gcc-dg/parse-decl-after-label.c b/SingleSource/Regression/C/gcc-dg/parse-decl-after-label.c new file mode 100644 index 0000000000..6e2a047eb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-decl-after-label.c @@ -0,0 +1,17 @@ +/* PR 29062 +{ dg-do compile } +{ dg-options "-std=c17 -pedantic-errors -fsyntax-only" } +*/ + +int f(int x) +{ + if (x > 1) + { + goto finish; + } + return x; + + finish: + int ret = 1; /* { dg-error "a label can only be part of a statement and a declaration is not a statement" } */ + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/parse-else-error-2.c b/SingleSource/Regression/C/gcc-dg/parse-else-error-2.c new file mode 100644 index 0000000000..ce59af3813 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-else-error-2.c @@ -0,0 +1,13 @@ +/* PR 23722 */ +/* { dg-do compile } */ +/* { dg-options "-fsyntax-only" } */ +int f() +{ + if (1) + { + return 1; + else /* { dg-error "expected .\}. before 'else'" } */ + { + } + } +} /* { dg-error "expected identifier or '\\(' before .\}. token" } */ diff --git a/SingleSource/Regression/C/gcc-dg/parse-else-error-3.c b/SingleSource/Regression/C/gcc-dg/parse-else-error-3.c new file mode 100644 index 0000000000..13666f595d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-else-error-3.c @@ -0,0 +1,11 @@ +/* PR 23722 */ +/* { dg-do compile } */ +/* { dg-options "-fsyntax-only" } */ +int f() +{ + + else /* { dg-error "'else' without a previous 'if'" } */ + { + return 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/parse-else-error-4.c b/SingleSource/Regression/C/gcc-dg/parse-else-error-4.c new file mode 100644 index 0000000000..617c3f3e3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-else-error-4.c @@ -0,0 +1,14 @@ +/* PR 23722 */ +/* { dg-do compile } */ +/* { dg-options "-fsyntax-only" } */ +int f() +{ + if (1) + { + return 1; + } + else + { + else; /* { dg-error "'else' without a previous 'if'" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/parse-else-error.c b/SingleSource/Regression/C/gcc-dg/parse-else-error.c new file mode 100644 index 0000000000..ca20bdf9ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-else-error.c @@ -0,0 +1,12 @@ +/* PR 23722 */ +/* { dg-do compile } */ +/* { dg-options "-fsyntax-only" } */ +int f() +{ + if (1) + { + return 1; + else /* { dg-error "expected .\}. before 'else'" } */ + { + } +} diff --git a/SingleSource/Regression/C/gcc-dg/parse-error-1.c b/SingleSource/Regression/C/gcc-dg/parse-error-1.c new file mode 100644 index 0000000000..704786f4f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-error-1.c @@ -0,0 +1,10 @@ +/* PR c/28649 */ +/* { dg-do compile } */ + +void foo() +{ + +; /* { dg-error "expected expression" } */ + +; /* { dg-error "expected expression" } */ +} + +int +; /* { dg-error "expected identifier" } */ diff --git a/SingleSource/Regression/C/gcc-dg/parse-error-2.c b/SingleSource/Regression/C/gcc-dg/parse-error-2.c new file mode 100644 index 0000000000..7ab3cd7c05 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-error-2.c @@ -0,0 +1,14 @@ +/* PR c/28649 */ +/* { dg-do compile } */ + +void foo() +{ + +; /* { dg-error "expected expression" } */ +} + +int i; + +void bar() +{ + i++; /* { dg-bogus "undeclared" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/parse-error-3.c b/SingleSource/Regression/C/gcc-dg/parse-error-3.c new file mode 100644 index 0000000000..8e72b8170a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parse-error-3.c @@ -0,0 +1,14 @@ +/* PR c/43384 */ +/* { dg-do compile } */ + +void c_direct(par) + void *par = &&lab; /* { dg-error "is initialized|non-standard|outside of" } */ +{} + +void foo(p, q) + int *p = &q; /* { dg-error "initialized|undeclared" } */ +{} + +void bar(i) + int j = i; /* { dg-error "initialized|undeclared|no such parameter" } */ +{} diff --git a/SingleSource/Regression/C/gcc-dg/parser-pr28152-2.c b/SingleSource/Regression/C/gcc-dg/parser-pr28152-2.c new file mode 100644 index 0000000000..2f3c8f0ebe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parser-pr28152-2.c @@ -0,0 +1,11 @@ +/* PR 28152: error messages should mention __complex__ */ +/* { dg-do compile } */ +/* { dg-options "" } */ +int +main (void) +{ + __complex__ float z; + + z = __complex__ (1.90000007326203904e+19, 0.0); /* { dg-error "__complex__" } */ + z = __complex__ (1.0e+0, 0.0) / z; /* { dg-error "__complex__" "Complex" } */ + /* { dg-error "at end of input" "end of input" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/parser-pr28152.c b/SingleSource/Regression/C/gcc-dg/parser-pr28152.c new file mode 100644 index 0000000000..7e35b4c161 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/parser-pr28152.c @@ -0,0 +1,11 @@ +/* PR 28152: error messages should mention _Complex */ +/* { dg-do compile } */ +/* { dg-options "" } */ +int +main (void) +{ + _Complex float z; + + z = _Complex (1.90000007326203904e+19, 0.0); /* { dg-error "_Complex" } */ + z = _Complex (1.0e+0, 0.0) / z; /* { dg-error "_Complex" "_Complex" } */ + /* { dg-error "at end of input" "end of input" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pedwarn-init.c b/SingleSource/Regression/C/gcc-dg/pedwarn-init.c new file mode 100644 index 0000000000..0777641463 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pedwarn-init.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wpedantic" } */ +/* { dg-prune-output ".*near initialization for.*" } */ + +typedef unsigned vec __attribute__ ((vector_size (2 * sizeof (int)))); +union u { int a; double d; }; +struct S { int i; char fam[]; }; + +int i; +vec v = { 1, 2, 3 }; /* { dg-warning "17:excess elements in vector initializer" } */ +int a1 = { 1, 2 }; /* { dg-warning "15:excess elements in scalar initializer" } */ +int a2[2] = { 1, 2, 3 }; /* { dg-warning "21:excess elements in array initializer" } */ +int a3[] = { [1 ? 1 : i] = 0 }; /* { dg-warning "15:array index in initializer is not an integer constant expression" } */ +int a4[] = { [1 ... 1 ? 2 : i] = 0 }; /* { dg-warning "15:array index in initializer is not an integer constant expression" } */ +/* { dg-warning "ISO C forbids" "ISO C" { target *-*-* } .-1 } */ +char a5[] = ("lol"); /* { dg-warning "13:array initialized from parenthesized string constant" } */ +char a6[] = { ("foo") }; /* { dg-warning "13:array initialized from parenthesized string constant" } */ +char *a7 = (char []) { ("bar") }; /* { dg-warning "12:array initialized from parenthesized string constant" } */ +union u u = { 1, 1.0 }; /* { dg-warning "18:excess elements in union initializer" } */ +struct S s = { 1, 2 }; /* { dg-warning "14:initialization of a flexible array member" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pg-override.c b/SingleSource/Regression/C/gcc-dg/pg-override.c new file mode 100644 index 0000000000..9b8d8fa02c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pg-override.c @@ -0,0 +1,18 @@ +/* Test -fprofile override */ +/* { dg-do compile } */ +/* { dg-options "-fprofile" { target i?86-*-linux* x86_64-*-linux* } } */ +/* { dg-final { scan-assembler-not "mcount" } } */ +/* Origin: Andi Kleen */ +extern void foobar(const char *); + +__attribute__((no_instrument_function)) void func(void) +{ + foobar ("Hello world\n"); +} + +__attribute__((no_instrument_function)) void func2(void) +{ + int i; + for (i = 0; i < 10; i++) + foobar ("Hello world"); +} diff --git a/SingleSource/Regression/C/gcc-dg/pg.c b/SingleSource/Regression/C/gcc-dg/pg.c new file mode 100644 index 0000000000..9b8d8fa02c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pg.c @@ -0,0 +1,18 @@ +/* Test -fprofile override */ +/* { dg-do compile } */ +/* { dg-options "-fprofile" { target i?86-*-linux* x86_64-*-linux* } } */ +/* { dg-final { scan-assembler-not "mcount" } } */ +/* Origin: Andi Kleen */ +extern void foobar(const char *); + +__attribute__((no_instrument_function)) void func(void) +{ + foobar ("Hello world\n"); +} + +__attribute__((no_instrument_function)) void func2(void) +{ + int i; + for (i = 0; i < 10; i++) + foobar ("Hello world"); +} diff --git a/SingleSource/Regression/C/gcc-dg/pic-1.c b/SingleSource/Regression/C/gcc-dg/pic-1.c new file mode 100644 index 0000000000..4bb332ec01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pic-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { ! { *-*-darwin* hppa*-*-* amdgcn*-*-* } } } } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-fpic" } */ + +#if __PIC__ != 1 +# error __PIC__ is not 1! +#endif + +#ifdef __PIE__ +# error __PIE__ is defined! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pic-2.c b/SingleSource/Regression/C/gcc-dg/pic-2.c new file mode 100644 index 0000000000..24260538cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pic-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-fPIC" } */ +/* { dg-skip-if "__PIC__ is always 1 for MIPS" { mips*-*-* } } */ +/* { dg-skip-if "__PIE__ is always defined for GCN" { amdgcn*-*-* } } */ + +#if defined(__CYGWIN__) || defined(__WIN32__) +# if __PIC__ != 1 +# error __PIC__ is not 1! +# endif +#elif __PIC__ != 2 +# error __PIC__ is not 2! +#endif + +#ifdef __PIE__ +# error __PIE__ is defined! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pic-3.c b/SingleSource/Regression/C/gcc-dg/pic-3.c new file mode 100644 index 0000000000..d3eb120652 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pic-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target { ! { *-*-darwin* hppa*64*-*-* mips*-*-linux-* amdgcn*-*-* } } } } */ +/* { dg-options "-fno-pic" } */ + +#if defined(__CYGWIN__) || defined(__WIN32__) +# if __PIC__ != 1 +# error __PIC__ is not 1! +# endif +#elif __PIC__ +# error __PIC__ is defined! +#endif + +#ifdef __PIE__ +# error __PIE__ is defined! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pic-4.c b/SingleSource/Regression/C/gcc-dg/pic-4.c new file mode 100644 index 0000000000..d7acefaf9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pic-4.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target { ! { *-*-darwin* hppa*64*-*-* mips*-*-linux-* amdgcn*-*-* } } } } */ +/* { dg-options "-fno-PIC" } */ + +#if defined(__CYGWIN__) || defined(__WIN32__) +# if __PIC__ != 1 +# error __PIC__ is not 1! +# endif +#elif __PIC__ +# error __PIC__ is defined! +#endif + +#ifdef __PIE__ +# error __PIE__ is defined! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pic-macro-define.c b/SingleSource/Regression/C/gcc-dg/pic-macro-define.c new file mode 100644 index 0000000000..0923432536 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pic-macro-define.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-fPIC" } */ + +#if defined __PIC__ +int main() { + return 0; +} +#else + error "NO __PIC__ DEFINED" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pie-1.c b/SingleSource/Regression/C/gcc-dg/pie-1.c new file mode 100644 index 0000000000..3f6e371668 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { ! { *-*-darwin* hppa*-*-* } } } } */ +/* { dg-options "-fpie" } */ +/* { dg-require-effective-target pie } */ + +#if __PIC__ != 1 +# error __PIC__ is not 1! +#endif + +#if __PIE__ != 1 +# error __PIE__ is not 1! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pie-2.c b/SingleSource/Regression/C/gcc-dg/pie-2.c new file mode 100644 index 0000000000..1838745a11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fPIE" } */ +/* { dg-require-effective-target pie } */ +/* { dg-skip-if "__PIC__ is always 1 for MIPS" { mips*-*-* } } */ + +#if __PIC__ != 2 +# error __PIC__ is not 2! +#endif + +#if __PIE__ != 2 +# error __PIE__ is not 2! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pie-3.c b/SingleSource/Regression/C/gcc-dg/pie-3.c new file mode 100644 index 0000000000..fd4a48da45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-3.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { ! { *-*-darwin* hppa*64*-*-* mips*-*-linux-* amdgcn*-*-* } } } } */ +/* { dg-options "-fno-pie" } */ + +#ifdef __PIC__ +# error __PIC__ is defined! +#endif + +#ifdef __PIE__ +# error __PIE__ is defined! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pie-4.c b/SingleSource/Regression/C/gcc-dg/pie-4.c new file mode 100644 index 0000000000..5523602abe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-4.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target { ! { *-*-darwin* hppa*64*-*-* mips*-*-linux-* amdgcn*-*-* } } } } */ +/* { dg-options "-fno-PIE" } */ + +#ifdef __PIC__ +# error __PIC__ is defined! +#endif + +#ifdef __PIE__ +# error __PIE__ is defined! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pie-5.c b/SingleSource/Regression/C/gcc-dg/pie-5.c new file mode 100644 index 0000000000..d49554f184 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-5.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target pie_enabled } } */ +/* { dg-options "" } */ + +#ifndef __PIC__ +# error __PIC__ is not defined! +#endif + +#ifndef __PIE__ +# error __PIE__ is not defined! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pie-6.c b/SingleSource/Regression/C/gcc-dg/pie-6.c new file mode 100644 index 0000000000..fac1e945f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-6.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target { ! pie_enabled } } } */ +/* { dg-options "" } */ + +#ifdef __PIE__ +# error __PIE__ is defined! +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pie-7.c b/SingleSource/Regression/C/gcc-dg/pie-7.c new file mode 100644 index 0000000000..e118a98baf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-7.c @@ -0,0 +1,7 @@ +/* { dg-do run { target pie } } */ +/* { dg-options "-fno-pie -no-pie" } */ + +int main(void) +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pie-link.c b/SingleSource/Regression/C/gcc-dg/pie-link.c new file mode 100644 index 0000000000..2be07615f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-link.c @@ -0,0 +1,7 @@ +/* { dg-do link { target pie } } */ +/* { dg-options "-fpie -pie" } */ + +int main(void) +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pie-static-1.c b/SingleSource/Regression/C/gcc-dg/pie-static-1.c new file mode 100644 index 0000000000..4273049be7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-static-1.c @@ -0,0 +1,9 @@ +/* { dg-do run } */ +/* { dg-require-effective-target static } */ +/* { dg-require-effective-target pie } */ +/* { dg-options "-static -fpie -pie" } */ + +int main(void) +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pie-static-2.c b/SingleSource/Regression/C/gcc-dg/pie-static-2.c new file mode 100644 index 0000000000..a673c997af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pie-static-2.c @@ -0,0 +1,9 @@ +/* { dg-do run } */ +/* { dg-require-effective-target pie } */ +/* { dg-require-effective-target static } */ +/* { dg-options "-fpie -pie -static" } */ + +int main(void) +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-1.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-1.c new file mode 100644 index 0000000000..8bf6e285d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-1.c @@ -0,0 +1,39 @@ +/* Test diagnostics for arithmetic on void and function pointers. + Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void *p; +void (*f)(void); + +void +g (void) +{ + p + 0; + p + 1; + 0 + p; + 1 + p; + p - 0; + p - 1; + p += 0; + p += 1; + p -= 0; + p -= 1; + f + 0; + f + 1; + 0 + f; + 1 + f; + f - 0; + f - 1; + f += 0; + f += 1; + f -= 0; + f -= 1; + p[0]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + 0[p]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + f[0]; /* { dg-error "subscripted value is pointer to function" } */ + 0[f]; /* { dg-error "subscripted value is pointer to function" } */ + p - p; + f - f; +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-10.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-10.c new file mode 100644 index 0000000000..35e2b11ef9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-10.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +char *foo(char *p, __UINTPTR_TYPE__ i) +{ + return (char *)i + (__UINTPTR_TYPE__)p; +} + +/* Check that we use a POINTER_PLUS_EXPR, not something like + return (char *) ((sizetype) p + (sizetype) i); */ +/* { dg-final { scan-tree-dump-not "sizetype.*sizetype" "original" } } */ + +/* And also that we don't swap the operands. */ +/* { dg-final { scan-tree-dump-not "return p +" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-2.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-2.c new file mode 100644 index 0000000000..d9533f17f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-2.c @@ -0,0 +1,41 @@ +/* Test diagnostics for arithmetic on void and function pointers. + Test with -Wpointer-arith. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wpointer-arith" } */ + +void *p; +void (*f)(void); + +void +g (void) +{ + p + 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p + 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + 0 + p; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + 1 + p; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p - 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p - 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p += 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p += 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p -= 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p -= 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + f + 0; /* { dg-warning "pointer to a function used in arithmetic" } */ + f + 1; /* { dg-warning "pointer to a function used in arithmetic" } */ + 0 + f; /* { dg-warning "pointer to a function used in arithmetic" } */ + 1 + f; /* { dg-warning "pointer to a function used in arithmetic" } */ + f - 0; /* { dg-warning "pointer to a function used in arithmetic" } */ + f - 1; /* { dg-warning "pointer to a function used in arithmetic" } */ + f += 0; /* { dg-warning "pointer to a function used in arithmetic" } */ + f += 1; /* { dg-warning "pointer to a function used in arithmetic" } */ + f -= 0; /* { dg-warning "pointer to a function used in arithmetic" } */ + f -= 1; /* { dg-warning "pointer to a function used in arithmetic" } */ + p[0]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + /* { dg-warning "pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } .-1 } */ + 0[p]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + /* { dg-warning "pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } .-1 } */ + f[0]; /* { dg-error "subscripted value is pointer to function" } */ + 0[f]; /* { dg-error "subscripted value is pointer to function" } */ + p - p; /* { dg-warning "pointer of type 'void \\*' used in subtraction" } */ + f - f; /* { dg-warning "pointer to a function used in subtraction" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-3.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-3.c new file mode 100644 index 0000000000..5a5e302103 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-3.c @@ -0,0 +1,41 @@ +/* Test diagnostics for arithmetic on void and function pointers. + Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +void *p; +void (*f)(void); + +void +g (void) +{ + p + 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p + 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + 0 + p; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + 1 + p; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p - 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p - 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p += 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p += 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p -= 0; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + p -= 1; /* { dg-warning "pointer of type 'void \\*' used in arithmetic" } */ + f + 0; /* { dg-warning "pointer to a function used in arithmetic" } */ + f + 1; /* { dg-warning "pointer to a function used in arithmetic" } */ + 0 + f; /* { dg-warning "pointer to a function used in arithmetic" } */ + 1 + f; /* { dg-warning "pointer to a function used in arithmetic" } */ + f - 0; /* { dg-warning "pointer to a function used in arithmetic" } */ + f - 1; /* { dg-warning "pointer to a function used in arithmetic" } */ + f += 0; /* { dg-warning "pointer to a function used in arithmetic" } */ + f += 1; /* { dg-warning "pointer to a function used in arithmetic" } */ + f -= 0; /* { dg-warning "pointer to a function used in arithmetic" } */ + f -= 1; /* { dg-warning "pointer to a function used in arithmetic" } */ + p[0]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + /* { dg-warning "pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } .-1 } */ + 0[p]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + /* { dg-warning "pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } .-1 } */ + f[0]; /* { dg-error "subscripted value is pointer to function" } */ + 0[f]; /* { dg-error "subscripted value is pointer to function" } */ + p - p; /* { dg-warning "pointer of type 'void \\*' used in subtraction" } */ + f - f; /* { dg-warning "pointer to a function used in subtraction" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-4.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-4.c new file mode 100644 index 0000000000..c6382b1e3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-4.c @@ -0,0 +1,41 @@ +/* Test diagnostics for arithmetic on void and function pointers. + Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +void *p; +void (*f)(void); + +void +g (void) +{ + p + 0; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + p + 1; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + 0 + p; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + 1 + p; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + p - 0; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + p - 1; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + p += 0; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + p += 1; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + p -= 0; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + p -= 1; /* { dg-error "pointer of type 'void \\*' used in arithmetic" } */ + f + 0; /* { dg-error "pointer to a function used in arithmetic" } */ + f + 1; /* { dg-error "pointer to a function used in arithmetic" } */ + 0 + f; /* { dg-error "pointer to a function used in arithmetic" } */ + 1 + f; /* { dg-error "pointer to a function used in arithmetic" } */ + f - 0; /* { dg-error "pointer to a function used in arithmetic" } */ + f - 1; /* { dg-error "pointer to a function used in arithmetic" } */ + f += 0; /* { dg-error "pointer to a function used in arithmetic" } */ + f += 1; /* { dg-error "pointer to a function used in arithmetic" } */ + f -= 0; /* { dg-error "pointer to a function used in arithmetic" } */ + f -= 1; /* { dg-error "pointer to a function used in arithmetic" } */ + p[0]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + /* { dg-error "pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } .-1 } */ + 0[p]; /* { dg-warning "dereferencing 'void \\*' pointer" } */ + /* { dg-error "pointer of type 'void \\*' used in arithmetic" "array 1" { target *-*-* } .-1 } */ + f[0]; /* { dg-error "subscripted value is pointer to function" } */ + 0[f]; /* { dg-error "subscripted value is pointer to function" } */ + p - p; /* { dg-error "pointer of type 'void \\*' used in subtraction" } */ + f - f; /* { dg-error "pointer to a function used in subtraction" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-5.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-5.c new file mode 100644 index 0000000000..47564c049f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-5.c @@ -0,0 +1,17 @@ +/* Test diagnostics for sizeof on void and function types. Test with + no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern const void v; +void f(void); + +void +g (void) +{ + sizeof (v); + sizeof (void); + sizeof (f); + sizeof (void (void)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-6.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-6.c new file mode 100644 index 0000000000..cf5f08b3e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-6.c @@ -0,0 +1,17 @@ +/* Test diagnostics for sizeof on void and function types. Test with + -Wpointer-arith. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wpointer-arith" } */ + +extern const void v; +void f(void); + +void +g (void) +{ + sizeof (v); /* { dg-warning "invalid application of 'sizeof' to a void type" } */ + sizeof (void); /* { dg-warning "invalid application of 'sizeof' to a void type" } */ + sizeof (f); /* { dg-warning "invalid application of 'sizeof' to a function type" } */ + sizeof (void (void)); /* { dg-warning "invalid application of 'sizeof' to a function type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-7.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-7.c new file mode 100644 index 0000000000..a65e428666 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-7.c @@ -0,0 +1,17 @@ +/* Test diagnostics for sizeof on void and function types. Test with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +extern const void v; +void f(void); + +void +g (void) +{ + sizeof (v); /* { dg-warning "invalid application of 'sizeof' to a void type" } */ + sizeof (void); /* { dg-warning "invalid application of 'sizeof' to a void type" } */ + sizeof (f); /* { dg-warning "invalid application of 'sizeof' to a function type" } */ + sizeof (void (void)); /* { dg-warning "invalid application of 'sizeof' to a function type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-8.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-8.c new file mode 100644 index 0000000000..5426b79e26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-8.c @@ -0,0 +1,17 @@ +/* Test diagnostics for sizeof on void and function types. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +extern const void v; +void f(void); + +void +g (void) +{ + sizeof (v); /* { dg-error "invalid application of 'sizeof' to a void type" } */ + sizeof (void); /* { dg-error "invalid application of 'sizeof' to a void type" } */ + sizeof (f); /* { dg-error "invalid application of 'sizeof' to a function type" } */ + sizeof (void (void)); /* { dg-error "invalid application of 'sizeof' to a function type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-arith-9.c b/SingleSource/Regression/C/gcc-dg/pointer-arith-9.c new file mode 100644 index 0000000000..2d26112720 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-arith-9.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void *foo(void) +{ + return (void *)0 - 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pointer-array-atomic.c b/SingleSource/Regression/C/gcc-dg/pointer-array-atomic.c new file mode 100644 index 0000000000..bb63797b23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-array-atomic.c @@ -0,0 +1,60 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ +/* Origin: Martin Uecker */ +void tvoid(void* x); +void transpose0(double* out, _Atomic double* in) { } +void transpose1(double out[2][2], _Atomic double in[2][2]) { } +void transpose2(double out[2][2][2], _Atomic double in[2][2][2]) { } +// return +int (*x2(_Atomic int x[3][3]))[3] { return x; } /* { dg-warning "returning '_Atomic int \\(\\*\\)\\\[3\\\]' from a function with incompatible return type" } */ +_Atomic int (*x3(int x[3][3]))[3] { return x; } /* { dg-warning "returning 'int \\(\\*\\)\\\[3\\\]' from a function with incompatible return type" } */ +void test(void) +{ + double x0[2]; + double y0[2]; + _Atomic double z0[4]; + double x1[2][2]; + double y1[2][2]; + double o1[2][3]; + _Atomic double z1[2][2]; + double x2[2][2][2]; + double y2[2][2][2]; + double o2[2][2][3]; + _Atomic double z2[2][2][2]; + tvoid(z0); + tvoid(z1); + tvoid(z2); + // passing as arguments + transpose0(y0, x0); /* { dg-warning "passing argument 2 of 'transpose0' from incompatible pointer type" } */ + transpose1(y1, o1); /* { dg-warning "passing argument 2 of 'transpose1' from incompatible pointer type" } */ + transpose1(y1, x1); /* { dg-warning "passing argument 2 of 'transpose1' from incompatible pointer type" } */ + transpose2(y2, o2); /* { dg-warning "passing argument 2 of 'transpose2' from incompatible pointer type" } */ + transpose2(y2, x2); /* { dg-warning "passing argument 2 of 'transpose2' from incompatible pointer type" } */ + // initialization + _Atomic double (*x0p) = x0; /* { dg-warning "initialization of '_Atomic double \\*' from incompatible pointer type" } */ + _Atomic double (*x1p)[2] = x1; /* { dg-warning "initialization of '_Atomic double \\(\\*\\)\\\[2\\\]' from incompatible pointer type" } */ + _Atomic double (*x2p)[2][2] = x2; /* { dg-warning "initialization of '_Atomic double \\(\\*\\)\\\[2\\\]\\\[2\\\]' from incompatible pointer type" } */ + // assignment + x0p = x0; /* { dg-warning "assignment to '_Atomic double \\*' from incompatible pointer type" } */ + x1p = x1; /* { dg-warning "assignment to '_Atomic double \\(\\*\\)\\\[2\\\]' from incompatible pointer type" } */ + x2p = x2; /* { dg-warning "assignment to '_Atomic double \\(\\*\\)\\\[2\\\]\\\[2\\\]' from incompatible pointer type" } */ + // subtraction + &(x0[1]) - &(z0[0]); /* { dg-error "invalid operands to binary" } */ + &(x1[1]) - &(z1[0]); /* { dg-error "invalid operands to binary" } */ + &(x2[1]) - &(z2[0]); /* { dg-error "invalid operands to binary" } */ + // comparison + x0 == z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x1 == z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x2 == z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x0 > z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x1 > z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x2 > z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x0 < z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x1 < z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + x2 < z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */ + // conditional expressions + (void)(1 ? x0 : z0); /* { dg-warning "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : z1); /* { dg-warning "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : z2); /* { dg-warning "pointer type mismatch in conditional expression" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pointer-array-quals-1.c b/SingleSource/Regression/C/gcc-dg/pointer-array-quals-1.c new file mode 100644 index 0000000000..498ab22316 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-array-quals-1.c @@ -0,0 +1,106 @@ +/* { dg-do compile } */ +/* Origin: Martin Uecker */ +/* { dg-options "" } */ +void tvoid(void* x); +void transpose0(double* out, const double* in) { } +void transpose1(double out[2][2], const double in[2][2]) { } +void transpose2(double out[2][2][2], const double in[2][2][2]) { } +// return +int (*y2(const int x[3][3]))[3] { return x; } /* { dg-warning "return discards 'const' qualifier from pointer target type" } */ +const int (*y3(int x[3][3]))[3] { return x; } +void test(void) +{ + double x0[2]; + double y0[2]; + const double z0[4]; + double x1[2][2]; + double y1[2][2]; + double o1[2][3]; + const double z1[2][2]; + double x2[2][2][2]; + double y2[2][2][2]; + double o2[2][2][3]; + const double z2[2][2][2]; + // void pointers + tvoid(x0); + tvoid(x1); + tvoid(x2); + tvoid(z0); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z1); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z2); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + void* p; + const void* pc; + p = x0; + p = x1; + p = x2; + p = z0; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + p = z1; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + p = z2; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + pc = x0; + pc = x1; + pc = x2; + pc = z0; + pc = z1; + pc = z2; + transpose0(pc, p); /* { dg-warning "passing argument 1 of 'transpose0' discards 'const' qualifier from pointer target type" } */ + transpose1(pc, p); /* { dg-warning "passing argument 1 of 'transpose1' discards 'const' qualifier from pointer target type" } */ + transpose2(pc, p); /* { dg-warning "passing argument 1 of 'transpose2' discards 'const' qualifier from pointer target type" } */ + transpose0(p, pc); + transpose1(p, pc); + transpose2(p, pc); + // passing as arguments + transpose0(y0, x0); + transpose1(y1, x1); + transpose2(y2, x2); + // initialization + const double (*u0p) = x0; + const double (*u1p)[2] = x1; + const double (*u2p)[2][2] = x2; + double (*v0p) = z0; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */ + double (*v1p)[2] = z1; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */ + double (*v2p)[2][2] = z2; /* { dg-warning "initialization discards 'const' qualifier from pointer target type" } */ + // subtraction + &(x0[1]) - &(z0[0]); + &(x1[1]) - &(z1[0]); + &(x2[1]) - &(z2[0]); + // comparison + x0 == z0; + x1 == z1; + x2 == z2; + x0 < z0; + x1 < z1; + x2 < z2; + x0 > z0; + x1 > z1; + x2 > z2; + // assignment + u0p = x0; + u1p = x1; + u2p = x2; + v0p = z0; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = z1; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = z2; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + // conditional expressions + (void)(1 ? x0 : z0); + (void)(1 ? x1 : z1); + (void)(1 ? x2 : z2); + (void)(1 ? x0 : x1); /* { dg-warning "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : x2); /* { dg-warning "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : x0); /* { dg-warning "pointer type mismatch in conditional expression" } */ + v0p = (1 ? z0 : v0p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? z1 : v1p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? z2 : v2p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v0p = (1 ? x0 : u0p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? x1 : u1p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? x2 : u2p); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + (1 ? x0 : z0)[0] = 1; /* { dg-error "assignment of read-only location" } */ + (1 ? x1 : z1)[0][0] = 1; /* { dg-error "assignment of read-only location" } */ + (1 ? x2 : z2)[0][0][0] = 1; /* { dg-error "assignment of read-only location" } */ + v0p = (1 ? p : z0); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? p : z1); /* { dg-warning "pointer to array loses qualifier in conditional expression" } */ + v2p = (1 ? p : z2); /* { dg-warning "pointer to array loses qualifier in conditional expression" } */ + v0p = (1 ? pc : x0); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? pc : x1); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? pc : x2); /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pointer-array-quals-2.c b/SingleSource/Regression/C/gcc-dg/pointer-array-quals-2.c new file mode 100644 index 0000000000..4c95d8a3a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-array-quals-2.c @@ -0,0 +1,102 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ +/* Origin: Martin Uecker */ +void tvoid(void* x); +void transpose0(double* out, const double* in) { } +void transpose1(double out[2][2], const double in[2][2]) { } +void transpose2(double out[2][2][2], const double in[2][2][2]) { } +// return +int (*x2(const int x[3][3]))[3] { return x; } /* { dg-error "pointers to arrays with different qualifiers|return discards" } */ +const int (*x3(int x[3][3]))[3] { return x; } /* { dg-error "pointers to arrays with different qualifiers" } */ +void test(void) +{ + double x0[2]; + double y0[2]; + const double z0[4]; + double x1[2][2]; + double y1[2][2]; + double o1[2][3]; + const double z1[2][2]; + double x2[2][2][2]; + double y2[2][2][2]; + double o2[2][2][3]; + const double z2[2][2][2]; + // void pointers + tvoid(z0); /* { dg-error "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z1); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + tvoid(z2); /* { dg-warning "passing argument 1 of 'tvoid' discards 'const' qualifier from pointer target type" } */ + void* p; + const void* pc; + p = x0; + p = x1; + p = x2; + p = z0; /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + p = z1; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + p = z2; /* { dg-warning "assignment discards 'const' qualifier from pointer target type" } */ + pc = x0; + pc = x1; + pc = x2; + pc = z0; + pc = z1; + pc = z2; + transpose0(pc, p); /* { dg-error "passing argument 1 of 'transpose0' discards 'const' qualifier from pointer target type" } */ + transpose1(pc, p); /* { dg-error "passing argument 1 of 'transpose1' discards 'const' qualifier from pointer target type" } */ + transpose2(pc, p); /* { dg-error "passing argument 1 of 'transpose2' discards 'const' qualifier from pointer target type" } */ + transpose0(p, pc); + transpose1(p, pc); /* { dg-error "passing argument 2 of 'transpose1' discards 'const' qualifier from pointer target type" } */ + transpose2(p, pc); /* { dg-error "passing argument 2 of 'transpose2' discards 'const' qualifier from pointer target type" } */ + // passing as arguments + transpose0(y0, x0); + transpose1(y1, o1); /* { dg-error "passing argument 2 of 'transpose1' from incompatible pointer type" } */ + transpose1(y1, x1); /* { dg-error "pointers to arrays with different qualifiers" } */ + transpose2(y2, o2); /* { dg-error "passing argument 2 of 'transpose2' from incompatible pointer type" } */ + transpose2(y2, x2); /* { dg-error "pointers to arrays with different qualifiers" } */ + // initialization + const double (*x0p) = x0; + const double (*x1p)[2] = x1; /* { dg-error "pointers to arrays with different qualifiers" } */ + const double (*x2p)[2][2] = x2; /* { dg-error "pointers to arrays with different qualifiers" } */ + double (*v0p) = z0; /* { dg-error "initialization discards 'const' qualifier from pointer target type" } */ + double (*v1p)[2] = z1; /* { dg-error "pointers to arrays with different qualifiers|initialization discards" } */ + double (*v2p)[2][2] = z2; /* { dg-error "pointers to arrays with different qualifiers|initialization discards" } */ + // assignment + x0p = x0; + x1p = x1; /* { dg-error "pointers to arrays with different qualifiers" } */ + x2p = x2; /* { dg-error "pointers to arrays with different qualifiers" } */ + // subtraction + &(x0[1]) - &(z0[0]); + &(x1[1]) - &(z1[0]); /* { dg-error "pointers to arrays with different qualifiers" } */ + &(x2[1]) - &(z2[0]); /* { dg-error "pointers to arrays with different qualifiers" } */ + // comparison + x0 == z0; + x1 == z1; /* { dg-error "pointers to arrays with different qualifiers" } */ + x2 == z2; /* { dg-error "pointers to arrays with different qualifiers" } */ + x0 < z0; + x1 < z1; /* { dg-error "pointers to arrays with different qualifiers" } */ + x2 < z2; /* { dg-error "pointers to arrays with different qualifiers" } */ + x0 > z0; + x1 > z1; /* { dg-error "pointers to arrays with different qualifiers" } */ + x2 > z2; /* { dg-error "pointers to arrays with different qualifiers" } */ + // conditional expressions + (void)(1 ? x0 : z0); + (void)(1 ? x1 : z1); /* { dg-error "pointers to arrays with different qualifiers" } */ + (void)(1 ? x2 : z2); /* { dg-error "pointers to arrays with different qualifiers" } */ + (void)(1 ? x0 : x1); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x1 : x2); /* { dg-error "pointer type mismatch in conditional expression" } */ + (void)(1 ? x2 : x0); /* { dg-error "pointer type mismatch in conditional expression" } */ + v0p = (1 ? z0 : v0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? z1 : v1p); /* { dg-error "pointers to arrays with different qualifiers|assignment discards" } */ + v2p = (1 ? z2 : v2p); /* { dg-error "pointers to arrays with different qualifiers|assignment discards" } */ + v0p = (1 ? x0 : x0p); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? x1 : x1p); /* { dg-error "pointers to arrays with different qualifiers|assignment discards" } */ + v2p = (1 ? x2 : x2p); /* { dg-error "pointers to arrays with different qualifiers|assignment discards" } */ + (1 ? x0 : z0)[0] = 1; /* { dg-error "assignment of read-only location" } */ + (1 ? x1 : z1)[0][0] = 1; /* { dg-error "assignment of read-only location|pointers to arrays" } */ + (1 ? x2 : z2)[0][0][0] = 1; /* { dg-error "assignment of read-only location|pointers to arrays" } */ + v0p = (1 ? p : z0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? p : z1); /* { dg-warning "pointer to array loses qualifier in conditional expression" } */ + v2p = (1 ? p : z2); /* { dg-warning "pointer to array loses qualifier in conditional expression" } */ + v0p = (1 ? pc : x0); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v1p = (1 ? pc : x1); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ + v2p = (1 ? pc : x2); /* { dg-error "assignment discards 'const' qualifier from pointer target type" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pointer-range-check-1.c b/SingleSource/Regression/C/gcc-dg/pointer-range-check-1.c new file mode 100644 index 0000000000..9868658888 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-range-check-1.c @@ -0,0 +1,37 @@ +/* { dg-do compile { target { ilp32 || lp64 } } } */ +/* { dg-options "-O2 -fno-ipa-icf -fdump-tree-optimized" } */ + +/* All four functions should be folded to: + + (sizetype) (a + 15 - b) < 30. */ + +_Bool +f1 (char *a, char *b) +{ + return (a + 16 <= b) || (b + 16 <= a); +} + +_Bool +f2 (char *a, char *b) +{ + return (a + 15 < b) || (b + 15 < a); +} + +_Bool +f3 (char *a, char *b) +{ + return (a + 16 <= b) | (b + 16 <= a); +} + +_Bool +f4 (char *a, char *b) +{ + return (a + 15 < b) | (b + 15 < a); +} + +/* { dg-final { scan-tree-dump-times { = [^\n]* - [^\n]*;} 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times { = [^\n]* \+ [^\n]*;} 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times { = [^\n]*\ > [^\n]*;} 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-not {=[^\n]*\ < [^\n]*;} "optimized" } } */ +/* { dg-final { scan-tree-dump-times { \+ 15} 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times { > 30} 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pointer-range-check-2.c b/SingleSource/Regression/C/gcc-dg/pointer-range-check-2.c new file mode 100644 index 0000000000..4ccc413f23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pointer-range-check-2.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-ipa-icf -fwrapv-pointer -fdump-tree-optimized" } */ + +_Bool +f1 (char *a, char *b) +{ + return (a + 16 <= b) || (b + 16 <= a); +} + +_Bool +f2 (char *a, char *b) +{ + return (a + 15 < b) || (b + 15 < a); +} + +_Bool +f3 (char *a, char *b) +{ + return (a + 16 <= b) | (b + 16 <= a); +} + +_Bool +f4 (char *a, char *b) +{ + return (a + 15 < b) | (b + 15 < a); +} + +/* { dg-final { scan-tree-dump-not { = [^\n]* - [^\n]*;} "optimized" } } */ +/* { dg-final { scan-tree-dump-times { = [^\n]* \+ [^\n]*;} 8 "optimized" } } */ +/* { dg-final { scan-tree-dump-times { \+ 15} 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times { \+ 16} 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/postincr-1.c b/SingleSource/Regression/C/gcc-dg/postincr-1.c new file mode 100644 index 0000000000..752cda40c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/postincr-1.c @@ -0,0 +1,21 @@ +/* Simple test for proper postincrement semantics. */ +/* { dg-do run } */ + +extern void abort (void); + +int i; +int c; +int *f () +{ + ++c; + return &i; +} + +int main () +{ + int r; + r = (*f())++; + if (!(r == 0 && i == 1 && c == 1)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pow-sqrt-1.c b/SingleSource/Regression/C/gcc-dg/pow-sqrt-1.c new file mode 100644 index 0000000000..17003c5d71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pow-sqrt-1.c @@ -0,0 +1,7 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math --param max-pow-sqrt-depth=5" } */ +/* { dg-require-effective-target double64plus } */ + +#define EXPN (-6 * (0.5*0.5*0.5*0.5)) + +#include "pow-sqrt.x" diff --git a/SingleSource/Regression/C/gcc-dg/pow-sqrt-2.c b/SingleSource/Regression/C/gcc-dg/pow-sqrt-2.c new file mode 100644 index 0000000000..96d7ce9c8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pow-sqrt-2.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math --param max-pow-sqrt-depth=5" } */ +/* { dg-require-effective-target double64plus } */ + +#define EXPN (-5.875) +#include "pow-sqrt.x" diff --git a/SingleSource/Regression/C/gcc-dg/pow-sqrt-3.c b/SingleSource/Regression/C/gcc-dg/pow-sqrt-3.c new file mode 100644 index 0000000000..c166586ac6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pow-sqrt-3.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math --param max-pow-sqrt-depth=3" } */ +/* { dg-require-effective-target double64plus } */ + +#define EXPN (1.25) +#include "pow-sqrt.x" diff --git a/SingleSource/Regression/C/gcc-dg/pow-sqrt-synth-1.c b/SingleSource/Regression/C/gcc-dg/pow-sqrt-synth-1.c new file mode 100644 index 0000000000..484b29a8fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pow-sqrt-synth-1.c @@ -0,0 +1,37 @@ +/* { dg-do compile { target sqrt_insn } } */ +/* { dg-options "-fdump-tree-powcabs -Ofast --param max-pow-sqrt-depth=8" } */ +/* { dg-additional-options "-mfloat-abi=softfp -mfpu=neon-vfpv4" { target arm*-*-* } } */ + +double +foo (double a) +{ + return __builtin_pow (a, -5.875); +} + +double +foof (double a) +{ + return __builtin_pow (a, 0.75f); +} + +double +bar (double a) +{ + return __builtin_pow (a, 1.0 + 0.00390625); +} + +double +baz (double a) +{ + return __builtin_pow (a, -1.25) + __builtin_pow (a, 5.75) - __builtin_pow (a, 3.375); +} + +#define N 256 +void +vecfoo (double *a) +{ + for (int i = 0; i < N; i++) + a[i] = __builtin_pow (a[i], 1.25); +} + +/* { dg-final { scan-tree-dump-times "synthesizing" 7 "powcabs" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pow-sqrt.x b/SingleSource/Regression/C/gcc-dg/pow-sqrt.x new file mode 100644 index 0000000000..bd744c611c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pow-sqrt.x @@ -0,0 +1,30 @@ + +extern void abort (void); + + +__attribute__((noinline)) double +real_pow (double x, double pow_exp) +{ + return __builtin_pow (x, pow_exp); +} + +#define EPS (0.000000000000000000001) + +#define SYNTH_POW(X, Y) __builtin_pow (X, Y) +volatile double arg; + +int +main (void) +{ + double i_arg = 0.1; + + for (arg = i_arg; arg < 100.0; arg += 1.0) + { + double synth_res = SYNTH_POW (arg, EXPN); + double real_res = real_pow (arg, EXPN); + + if (__builtin_abs (SYNTH_POW (arg, EXPN) - real_pow (arg, EXPN)) > EPS) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100142.c b/SingleSource/Regression/C/gcc-dg/pr100142.c new file mode 100644 index 0000000000..aec146cb0a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100142.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fpreprocessed" } */ + +void +foo (void) +{ + assert (1); /* { dg-warning "implicit" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100225.c b/SingleSource/Regression/C/gcc-dg/pr100225.c new file mode 100644 index 0000000000..f0efd29fa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100225.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/100225 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fmodulo-sched" } */ +/* { dg-require-effective-target alloca } */ + +void +vorbis_synthesis_lapout (void); + +void +ov_info (int **lappcm, int ov_info_i) +{ + while (ov_info_i < 1) + lappcm[ov_info_i++] = __builtin_alloca (1); + + vorbis_synthesis_lapout (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100239.c b/SingleSource/Regression/C/gcc-dg/pr100239.c new file mode 100644 index 0000000000..1ade810c52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100239.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/100239 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +typedef short __attribute__((__vector_size__ (8 * sizeof (short)))) V; +V v, w; + +void +foo (void) +{ + w = __builtin_shuffle (v != v, 0 < (V) {}, (V) {192} >> 5); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100292.c b/SingleSource/Regression/C/gcc-dg/pr100292.c new file mode 100644 index 0000000000..147c9324d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100292.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32 } */ + +typedef unsigned char __attribute__((__vector_size__ (4))) V; + +extern void bar (V v); + +void +foo (char c) +{ + bar (c <= (V) 127); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100349.c b/SingleSource/Regression/C/gcc-dg/pr100349.c new file mode 100644 index 0000000000..dd7977ac0f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100349.c @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-O2 -w" } + +#include +uint8_t a; +b(int8_t c) { + int d; +e: + uint32_t f; + for (;;) + for (c = 10; c; c++) + if (0 > (a = c) ?: d) { + f = a; + goto e; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100373.c b/SingleSource/Regression/C/gcc-dg/pr100373.c new file mode 100644 index 0000000000..d4cd52a95d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100373.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +int a; +_Thread_local int b; +void c() +{ + long d = b; + a = 0; + b = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100414.c b/SingleSource/Regression/C/gcc-dg/pr100414.c new file mode 100644 index 0000000000..7876f6b56e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100414.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-dce -fno-tree-dse -fchecking" } */ + +int i; +void +foo (void) +{ + i &= i && __builtin_bswap16 (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100464.c b/SingleSource/Regression/C/gcc-dg/pr100464.c new file mode 100644 index 0000000000..46cc37dff5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100464.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ + +int *a; +static int b, c, d, e, g, h; +int f; +void i() { + int *j[] = {&e, &b, &b, &d, &b, &b, &g, &e, &g, &b, &b, + &b, &b, &g, &e, &e, &b, &b, &d, &b, &b, &e, + &e, &g, &b, &b, &b, &b, &g, &e, &g, &c, &e}; + int **k = &j[5]; + for (; f;) + b |= *a; + *k = &h; +} +int main() {} diff --git a/SingleSource/Regression/C/gcc-dg/pr100509.c b/SingleSource/Regression/C/gcc-dg/pr100509.c new file mode 100644 index 0000000000..38e7002ae0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100509.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* { dg-require-alias "" } */ + +struct X { + int a; +}; +const int a = 0; +static struct X A __attribute__((alias("a"))); +void foo() { struct X b = A; } diff --git a/SingleSource/Regression/C/gcc-dg/pr100512.c b/SingleSource/Regression/C/gcc-dg/pr100512.c new file mode 100644 index 0000000000..70b90e04be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100512.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +#include +int a; +void b() { + int16_t *c; + uint16_t d = 2; + if (0 == d) { + uint64_t e; + uint64_t *f = &e; + for (;;) { + if (e += 0 >= 0) + for (;;) + ; + g: + for (; a;) { + int16_t i = &d; + *c = i && *f; + } + } + } + goto g; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr100520.c b/SingleSource/Regression/C/gcc-dg/pr100520.c new file mode 100644 index 0000000000..60f79c2b88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100520.c @@ -0,0 +1,5 @@ +/* PR gcov-profile/100520 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug -fprofile-generate" } */ + +static int f() {} diff --git a/SingleSource/Regression/C/gcc-dg/pr100521.c b/SingleSource/Regression/C/gcc-dg/pr100521.c new file mode 100644 index 0000000000..fd9f0db541 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100521.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +__builtin_clz (int a) +{ + return __builtin_clz(a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100547.c b/SingleSource/Regression/C/gcc-dg/pr100547.c new file mode 100644 index 0000000000..2d3da4eb50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100547.c @@ -0,0 +1,35 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O -g" } */ + +typedef int __attribute__((vector_size( + ((((((((((((((((((((((((((((((8 * sizeof(short)) * sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)))) V; /* { dg-error "number of vector components" } */ +void k() { V w = { 0 }; } diff --git a/SingleSource/Regression/C/gcc-dg/pr100563.c b/SingleSource/Regression/C/gcc-dg/pr100563.c new file mode 100644 index 0000000000..f6a5fcd3a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100563.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-Og -Wno-pointer-to-int-cast" } */ +unsigned long long e(void); +void f(int); +void a() { + short b = -1, c = (int)&b; + unsigned long long d = e(); + f(b >= d); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100590.c b/SingleSource/Regression/C/gcc-dg/pr100590.c new file mode 100644 index 0000000000..8d1e1a0d30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100590.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/100590 */ +/* { dg-do compile { target lra } } */ +/* { dg-options "-O1 -fno-dce -w" } */ + +int +foo (void) +{ + int x; + asm goto ("" : "+r" (x) : : : lab); + return 0; + lab: + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100619.c b/SingleSource/Regression/C/gcc-dg/pr100619.c new file mode 100644 index 0000000000..5df02bdb82 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100619.c @@ -0,0 +1,24 @@ +/* PR c/100619 - ICE on a VLA parameter with too many dimensions + { dg-do compile } + { dg-options "-Wall" } */ + +extern int n; + +#define A10 [n][n][n][n][n][n][n][n][n][n] +#define A100 A10 A10 A10 A10 A10 A10 A10 A10 A10 A10 A10 +#define A1000 A100 A100 A100 A100 A100 A100 A100 A100 A100 A100 A100 + +void f10 (int A10); +void f10 (int A10); + +void f100 (int A100); +void f100 (int A100); + +void f1000 (int A1000); +void f1000 (int A1000); + +void fx_1000 (int [ ]A1000); +void fx_1000 (int [1]A1000); // { dg-warning "-Warray-parameter" } + +void fn_1000 (int [n ]A1000); +void fn_1000 (int [n + 1]A1000); // { dg-warning "-Wvla-parameter" } diff --git a/SingleSource/Regression/C/gcc-dg/pr100680.c b/SingleSource/Regression/C/gcc-dg/pr100680.c new file mode 100644 index 0000000000..4b5ffc6565 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100680.c @@ -0,0 +1,31 @@ +/* PR middle-end/100680 */ +/* { dg-do compile { target size32plus } } */ +/* { dg-options "-O2 -Wstringop-overread" } */ + +struct s { + char a[8]; + int i; + long l; +}; + +extern char ea[8]; +static char sa[8] = { 1, 2, 3, 4 }; + +int +test (void) +{ + const struct s *ps = (const struct s *) 0x12345678L; + if (__builtin_memcmp (ps->a, ps->a, 8)) + return 0; + + if (__builtin_memcmp (ps->a, ea, 8)) /* { dg-bogus "exceeds source size 0" } */ + return 0; + + if (__builtin_memcmp (ps->a, sa, 8)) /* { dg-bogus "exceeds source size 0" } */ + return 0; + + if (__builtin_memcmp (ps->a, "abcdABCD", 8)) /* { dg-bogus "exceeds source size 0" } */ + return 0; + + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100781.c b/SingleSource/Regression/C/gcc-dg/pr100781.c new file mode 100644 index 0000000000..96f0a7a601 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100781.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug " } */ + +struct a { + int b; +}; +long c(short d, long e, struct a f) { +g:; + int h = f.b <= e, i = d, n = h >= d; + if (!n) + goto j; + goto k; +j:; + long l = 5; + if (l) + goto m; + d = 0; +m: + if (d) + return f.b; +k: + goto g; +} +int main() { } + diff --git a/SingleSource/Regression/C/gcc-dg/pr100788.c b/SingleSource/Regression/C/gcc-dg/pr100788.c new file mode 100644 index 0000000000..6f510ecf57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100788.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "--coverage -Wno-error=coverage-invalid-line-number" } */ + +void +foo() // { dg-warning "function starts on a higher line number than it ends" } +{ +#line 1 +} + +int main() +{ + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100790.c b/SingleSource/Regression/C/gcc-dg/pr100790.c new file mode 100644 index 0000000000..31e0effdea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100790.c @@ -0,0 +1,4 @@ +// { dg-do compile } +// { dg-options "-O2 -w" } + +__builtin_clz(int x) { x ? __builtin_clz(x) : 32; } diff --git a/SingleSource/Regression/C/gcc-dg/pr100791.c b/SingleSource/Regression/C/gcc-dg/pr100791.c new file mode 100644 index 0000000000..96cf34f14a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100791.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +static inline int __attribute__((__always_inline__)) +foo () +{ + return log_bad_request(0, __builtin_va_arg_pack()); /* { dg-warning "implicit" } */ +} +void log_bad_request() { foo (0); } /* { dg-warning "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr100834.c b/SingleSource/Regression/C/gcc-dg/pr100834.c new file mode 100644 index 0000000000..4bd2691aca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100834.c @@ -0,0 +1,42 @@ +/* PR tree-optimization/100834 */ +/* { dg-do compile { target size32plus } } */ +/* { dg-options "-O2 -Wall" } */ + +#define PAGE_SIZE 4096 +#define STACK_SIZE PAGE_SIZE + +union registers +{ + struct + { + unsigned long r15, r14, r13, r12, r11, r10, r9, r8; + unsigned long rdi, rsi, rbp, unused, rbx, rdx, rcx, rax; + }; + unsigned long by_index[16]; +}; + +struct per_cpu +{ + union + { + unsigned char stack[STACK_SIZE]; + struct + { + unsigned char __fill[STACK_SIZE - sizeof (union registers)]; + union registers guest_regs; + }; + }; +} __attribute__((aligned (PAGE_SIZE))); + +static inline struct per_cpu * +this_cpu_data (void) +{ + return (struct per_cpu *) 0xdeadbeef; +} + +void +foo (void) +{ + struct per_cpu *cpu_data = this_cpu_data (); + __builtin_memset (&cpu_data->guest_regs, 0, sizeof (cpu_data->guest_regs)); /* { dg-bogus "is out of the bounds" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100843.c b/SingleSource/Regression/C/gcc-dg/pr100843.c new file mode 100644 index 0000000000..695a2ec3f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100843.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -w" } */ + +char c; +void *memset(); +void test_integer_conversion_memset(void *d) { + memset(d, '\0', c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr100887.c b/SingleSource/Regression/C/gcc-dg/pr100887.c new file mode 100644 index 0000000000..027025f32f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr100887.c @@ -0,0 +1,14 @@ +/* PR target/100887 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-psabi -w" } */ +/* { dg-additional-options "-mavx512f" { target { i?86-*-* x86_64-*-* } } } */ + +typedef unsigned long long __attribute__((__vector_size__ (2 * sizeof (long long)))) U; +typedef unsigned long long __attribute__((__vector_size__ (4 * sizeof (long long)))) V; +typedef unsigned long long __attribute__((__vector_size__ (8 * sizeof (long long)))) W; + +U +foo (V v) +{ + return __builtin_shufflevector ((W){}, v, 0, 8); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101008.c b/SingleSource/Regression/C/gcc-dg/pr101008.c new file mode 100644 index 0000000000..8229769c6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101008.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/101008 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ +/* { dg-require-effective-target int32 } */ + +typedef unsigned __attribute__((__vector_size__(32))) U; +typedef unsigned __attribute__((__vector_size__(16))) V; + +int c, r; + +V v; + +void +foo(void) +{ + U u = __builtin_shufflevector (v, (V)(v != c) | (V)(c == v), + 4, 3, 5, 5, 1, 2, 3, 0); + r = ((union { U a; int b; }) u).b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101028.c b/SingleSource/Regression/C/gcc-dg/pr101028.c new file mode 100644 index 0000000000..501e6af37c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101028.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +typedef struct { + double x, y; +} PointInfo; + +typedef struct { + PointInfo point; +} PrimitiveInfo; + +int TraceBezier_alpha, TraceBezier_i; +double TraceBezier_weight; +PointInfo *TraceBezier_points; +PrimitiveInfo *TraceBezier_primitive_info; + +void TracePath() { + double *coefficients; + PointInfo point; + long j; + for (; TraceBezier_i; TraceBezier_i++) { + point.x = point.y = TraceBezier_alpha = 1.0; + j = 0; + for (; j < 4; j++) { + point.x += TraceBezier_alpha * coefficients[j] * + TraceBezier_primitive_info->point.x; + point.y += TraceBezier_alpha * TraceBezier_primitive_info->point.y; + TraceBezier_alpha *= TraceBezier_weight; + TraceBezier_primitive_info++; + } + TraceBezier_points[TraceBezier_i] = point; + TraceBezier_weight += 1.0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101062.c b/SingleSource/Regression/C/gcc-dg/pr101062.c new file mode 100644 index 0000000000..6c37ed8888 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101062.c @@ -0,0 +1,29 @@ +/* PR middle-end/101062 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-toplevel-reorder -frename-registers" } */ + +union U { signed b : 5; }; +int c; +volatile union U d[7] = { { 8 } }; +short e = 1; + +__attribute__((noipa)) void +foo () +{ + d[6].b = 0; + d[6].b = 0; + d[6].b = 0; + d[6].b = 0; + d[6].b = 0; + e = 0; + c = 0; +} + +int +main () +{ + foo (); + if (e != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101145-1.c b/SingleSource/Regression/C/gcc-dg/pr101145-1.c new file mode 100644 index 0000000000..e6f7923d78 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101145-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned foo(unsigned val, unsigned start) +{ + unsigned cnt = 0; + for (unsigned i = start; i > val; ++i) + cnt++; + return cnt; +} + +/* { dg-final { scan-tree-dump "cnt_\[0-9\] = -start_\[0-9\]\\(D\\);" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr101145-2.c b/SingleSource/Regression/C/gcc-dg/pr101145-2.c new file mode 100644 index 0000000000..dad192cfeb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101145-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned foo(unsigned val, unsigned start) +{ + unsigned cnt = 0; + unsigned i = start; + do { + cnt++; + i++; + } while (i > val); + return cnt; +} + +/* Look for start >= val ? -start : 1 */ +/* { dg-final { scan-tree-dump " = start_\[0-9\]\\(D\\) >= val_\[0-9\]\\(D\\);" "optimized" } } */ +/* { dg-final { scan-tree-dump "cnt_\[0-9\] = _\[0-9\]+ \\? _\[0-9\]+ : 1;" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr101156.c b/SingleSource/Regression/C/gcc-dg/pr101156.c new file mode 100644 index 0000000000..5c25bd78a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101156.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fchecking" } */ + +struct S { int i; }; +void baz(struct S *p) +{ + __builtin_setjmp(p--); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101170.c b/SingleSource/Regression/C/gcc-dg/pr101170.c new file mode 100644 index 0000000000..fc8106206b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101170.c @@ -0,0 +1,37 @@ +/* PR middle-end/101170 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +#include + +struct S { int a; int b[4]; } s; +va_list ap; +int i; +long long l; + +struct S +foo (int x) +{ + struct S a = {}; + do + if (x) + return a; + while (1); +} + +__attribute__((noipa)) void +bar (void) +{ + for (; i; i++) + l |= va_arg (ap, long long) << s.b[i]; + if (l) + foo (l); +} + +void +baz (int v, ...) +{ + va_start (ap, v); + bar (); + va_end (ap); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101171.c b/SingleSource/Regression/C/gcc-dg/pr101171.c new file mode 100644 index 0000000000..8d2bcabd3e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101171.c @@ -0,0 +1,13 @@ +/* PR c/101171 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern void foo (void); +int x = 0x1234; + +void +bar (void) +{ + if (x != (sizeof ((enum T) 0x1234))) /* { dg-error "conversion to incomplete type" } */ + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101172.c b/SingleSource/Regression/C/gcc-dg/pr101172.c new file mode 100644 index 0000000000..b9d098bb64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101172.c @@ -0,0 +1,20 @@ +/* PR middle-end/101172 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +union U +{ + int a[3]; + struct + { + int a : 3; + struct this_struct var; /* { dg-error "field 'var' has incomplete type" } */ + } b; +}; + +const union U hello = {.a = {1, 2, 3}}; + +void foo() +{ + int x = hello.b.a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101223.c b/SingleSource/Regression/C/gcc-dg/pr101223.c new file mode 100644 index 0000000000..6d5a247fa6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101223.c @@ -0,0 +1,44 @@ +/* PR tree-optimization/101223 */ +/* { dg-do run } */ +/* { dg-options "-O2 " } */ + +struct { + int a : 1; +} b; +int c = 1, d; +int foo1() { + for (; d < 2; d++) { + int e = ~c, f = 0, g; + if (e) { + f = c; + g = b.a; + b.a = f; + if (b.a >= g) + __builtin_abort(); + } + c = f; + b.a = g; + } + return 0; +} + +int foo2() { + for (; d < 2; d++) { + int e = ~c, f = 0, g; + if (e) { + f = c; + g = b.a; + b.a = f; + if (g <= b.a) + __builtin_abort(); + } + c = f; + b.a = g; + } + return 0; +} +int main () +{ + return foo1() + foo2(); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr101254.c b/SingleSource/Regression/C/gcc-dg/pr101254.c new file mode 100644 index 0000000000..b2460ed86f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101254.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/101254 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +int +foo (long long imin, long long imax) +{ + if (imin > imax) + return 0; + else if (imax - imin < 0 || (imax - imin) + 1 < 0) + return 0; + return 1; +} + +int +main () +{ + long long imax = __LONG_LONG_MAX__; + long long imin = -imax - 1; + if (!foo (-10, 10)) + __builtin_abort (); + if (foo (-10, imax)) + __builtin_abort (); + if (foo (imin, imax)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101266.c b/SingleSource/Regression/C/gcc-dg/pr101266.c new file mode 100644 index 0000000000..d1980891a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101266.c @@ -0,0 +1,8 @@ +/* PR debug/101266 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ + +void +foo (int (*p)[(int){1}]) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101294.c b/SingleSource/Regression/C/gcc-dg/pr101294.c new file mode 100644 index 0000000000..ca59b35f4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101294.c @@ -0,0 +1,15 @@ +/* PR middle-end/101294 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +/* { dg-additional-options "-mavx" { target avx } } */ + +typedef __attribute__((__vector_size__ (sizeof (unsigned long long)))) unsigned long long U; +typedef __attribute__((__vector_size__ (4 * sizeof (unsigned long long)))) unsigned long long V; + +extern U x; + +void +foo (void) +{ + x = __builtin_shufflevector ((U){}, (V){}, 3); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101384.c b/SingleSource/Regression/C/gcc-dg/pr101384.c new file mode 100644 index 0000000000..7030c0a481 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101384.c @@ -0,0 +1,39 @@ +/* PR target/101384 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-psabi -w" } */ + +typedef unsigned char __attribute__((__vector_size__ (16))) U; +typedef unsigned short __attribute__((__vector_size__ (8 * sizeof (short)))) V; + +U u; +V v; + +__attribute__((noipa)) U +foo (void) +{ + U y = (U) { 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, + 0x80, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff } + u; + return y; +} + +__attribute__((noipa)) V +bar (void) +{ + V y = (V) { 0x8000, 0xffff, 0x8000, 0xffff, + 0x8000, 0xffff, 0x8000, 0xffff } + v; + return y; +} + +int +main () +{ + U x = foo (); + for (unsigned i = 0; i < 16; i++) + if (x[i] != ((i & 3) ? 0xff : 0x80)) + __builtin_abort (); + V y = bar (); + for (unsigned i = 0; i < 8; i++) + if (y[i] != ((i & 1) ? 0xffff : 0x8000)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101403.c b/SingleSource/Regression/C/gcc-dg/pr101403.c new file mode 100644 index 0000000000..88df112e91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101403.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +unsigned int foo (unsigned int a) +{ + unsigned int u = 0; + unsigned short b = __builtin_bswap16 (a); + return b >> (u, 12); +} + +int main (void) +{ + unsigned int x = foo (0x80); + if (x != 0x0008) + __builtin_abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr101419.c b/SingleSource/Regression/C/gcc-dg/pr101419.c new file mode 100644 index 0000000000..2cce3836ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101419.c @@ -0,0 +1,62 @@ +/* PR tree-optimization/101419 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; +void baz (int, int) __attribute__((__warning__("detected overflow"))); + +union U { + int i; + char c; +}; + +static void +foo (union U *u) +{ + if (__builtin_object_size (&u->c, 1) < sizeof (u->c)) + baz (__builtin_object_size (&u->c, 1), sizeof (u->c)); /* { dg-bogus "detected overflow" } */ + __builtin_memset (&u->c, 0, sizeof (u->c)); + + if (__builtin_object_size (&u->i, 1) < sizeof (u->i)) + baz (__builtin_object_size (&u->i, 1), sizeof (u->i)); /* { dg-bogus "detected overflow" } */ + __builtin_memset (&u->i, 0, sizeof (u->i)); +} + +void +bar (union U *u) +{ + int i, j; + for (i = 0; i < 1; i++) + { + foo (u); + for (j = 0; j < 2; j++) + asm volatile (""); + } +} + +static void +qux (void *p, size_t q) +{ + if (__builtin_object_size (p, 1) < q) + baz (__builtin_object_size (p, 1), q); /* { dg-bogus "detected overflow" } */ + __builtin_memset (p, 0, q); +} + +static void +corge (union U *u) +{ + qux (&u->c, sizeof (u->c)); + qux (&u->i, sizeof (u->i)); +} + +void +garply (union U *u) +{ + int i, j; + for (i = 0; i < 1; i++) + { + corge (u); + for (j = 0; j < 2; j++) + asm volatile (""); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101496.c b/SingleSource/Regression/C/gcc-dg/pr101496.c new file mode 100644 index 0000000000..091d4ad8f2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101496.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/101496 */ +/* { dg-do compile } */ +/* { dg-options "-O2 " } */ + +int c_1, li_2, us_3, func_14_s_5; + +void func_14() { + { + unsigned uli_8 = 0; + lbl1806324B: + if (uli_8 /= us_3 |= func_14_s_5 < 0 | func_14_s_5 != c_1) { + uli_8 += c_1 >= us_3; + if (uli_8) + ; + else + li_2 &&func_14_s_5 <= c_1 ?: 0; + unsigned *ptr_9 = &uli_8; + } + } + goto lbl1806324B; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr101497.c b/SingleSource/Regression/C/gcc-dg/pr101497.c new file mode 100644 index 0000000000..fcfe0594f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101497.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/101497 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-div-by-zero" } */ + +char uc_1; +int i_4, func_12_uli_6; +void func_12() { + int *ptr_8 = &func_12_uli_6; + *ptr_8 = 0 >= 211 - uc_1 <= 0; + i_4 %= 0; + i_4 *= *ptr_8; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr101741.c b/SingleSource/Regression/C/gcc-dg/pr101741.c new file mode 100644 index 0000000000..6587dca77d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101741.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/101741 */ +/* { dg-do compile } */ +/* { dg-options "-O2 " } */ + +int +foo (void); + +unsigned int +toupper (int c) +{ + c = foo (); + while (c) + c = toupper (c); + + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101836.c b/SingleSource/Regression/C/gcc-dg/pr101836.c new file mode 100644 index 0000000000..096196d9b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101836.c @@ -0,0 +1,60 @@ +/* -fstrict-flex-arrays is aliased with -ftrict-flex-arrays=3, which is the + strictest, only [] is treated as flexible array. */ +/* PR tree-optimization/101836 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstrict-flex-arrays" } */ + +#include "builtin-object-size-common.h" + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + __builtin_printf("ok: %s == %zd\n", #p, p); \ + else \ + { \ + __builtin_printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + FAIL (); \ + } \ +} while (0); + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + expect(__builtin_object_size(normal->c, 1), 16); + expect(__builtin_object_size(trailing_1->c, 1), 4); + expect(__builtin_object_size(trailing_0->c, 1), 0); + expect(__builtin_object_size(trailing_flex->c, 1), -1); +} + +int main(int argc, char *argv[]) +{ + stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); + + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101836_1.c b/SingleSource/Regression/C/gcc-dg/pr101836_1.c new file mode 100644 index 0000000000..e2931ce101 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101836_1.c @@ -0,0 +1,60 @@ +/* -fstrict-flex-arrays=3 is the strictest, only [] is treated as + flexible array. */ +/* PR tree-optimization/101836 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstrict-flex-arrays=3" } */ + +#include + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + printf("ok: %s == %zd\n", #p, p); \ + else \ + { \ + printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + __builtin_abort (); \ + } \ +} while (0); + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + expect(__builtin_object_size(normal->c, 1), 16); + expect(__builtin_object_size(trailing_1->c, 1), 4); + expect(__builtin_object_size(trailing_0->c, 1), 0); + expect(__builtin_object_size(trailing_flex->c, 1), -1); +} + +int main(int argc, char *argv[]) +{ + stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101836_2.c b/SingleSource/Regression/C/gcc-dg/pr101836_2.c new file mode 100644 index 0000000000..7897418772 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101836_2.c @@ -0,0 +1,60 @@ +/* When -fstrict-flex-arrays=2, only [] and [0] are treated as flexiable + arrays. */ +/* PR tree-optimization/101836 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstrict-flex-arrays=2" } */ + +#include + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + printf("ok: %s == %zd\n", #p, p); \ + else \ + { \ + printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + __builtin_abort (); \ + } \ +} while (0); + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + expect(__builtin_object_size(normal->c, 1), 16); + expect(__builtin_object_size(trailing_1->c, 1), 4); + expect(__builtin_object_size(trailing_0->c, 1), -1); + expect(__builtin_object_size(trailing_flex->c, 1), -1); +} + +int main(int argc, char *argv[]) +{ + stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101836_3.c b/SingleSource/Regression/C/gcc-dg/pr101836_3.c new file mode 100644 index 0000000000..0e69388e81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101836_3.c @@ -0,0 +1,60 @@ +/* When -fstrict-flex-arrays=1, [], [0], and [1] are treated as flexible + arrays. */ +/* PR tree-optimization/101836 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstrict-flex-arrays=1" } */ + +#include + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + printf("ok: %s == %zd\n", #p, p); \ + else \ + { \ + printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + __builtin_abort (); \ + } \ +} while (0); + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + expect(__builtin_object_size(normal->c, 1), 16); + expect(__builtin_object_size(trailing_1->c, 1), -1); + expect(__builtin_object_size(trailing_0->c, 1), -1); + expect(__builtin_object_size(trailing_flex->c, 1), -1); +} + +int main(int argc, char *argv[]) +{ + stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101836_4.c b/SingleSource/Regression/C/gcc-dg/pr101836_4.c new file mode 100644 index 0000000000..e0025aa9a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101836_4.c @@ -0,0 +1,60 @@ +/* when -fstrict-flex-arrays=0, all trailing arrays are treated as + flexible arrays. */ +/* PR tree-optimization/101836 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstrict-flex-arrays=0" } */ + +#include + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + printf("ok: %s == %zd\n", #p, p); \ + else \ + { \ + printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + __builtin_abort (); \ + } \ +} while (0); + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + expect(__builtin_object_size(normal->c, 1), -1); + expect(__builtin_object_size(trailing_1->c, 1), -1); + expect(__builtin_object_size(trailing_0->c, 1), -1); + expect(__builtin_object_size(trailing_flex->c, 1), -1); +} + +int main(int argc, char *argv[]) +{ + stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101836_5.c b/SingleSource/Regression/C/gcc-dg/pr101836_5.c new file mode 100644 index 0000000000..0ad8bbf693 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101836_5.c @@ -0,0 +1,60 @@ +/* -fno-strict-flex-arrays is aliased to -fstrict-flex-arrays=0, + all trailing arrays are treated as flexible array. */ +/* PR tree-optimization/101836 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-strict-flex-arrays" } */ + +#include + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + printf("ok: %s == %zd\n", #p, p); \ + else \ + { \ + printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + __builtin_abort (); \ + } \ +} while (0); + +struct trailing_array_1 { + int a; + int b; + int c[4]; +}; + +struct trailing_array_2 { + int a; + int b; + int c[1]; +}; + +struct trailing_array_3 { + int a; + int b; + int c[0]; +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + expect(__builtin_object_size(normal->c, 1), -1); + expect(__builtin_object_size(trailing_1->c, 1), -1); + expect(__builtin_object_size(trailing_0->c, 1), -1); + expect(__builtin_object_size(trailing_flex->c, 1), -1); +} + +int main(int argc, char *argv[]) +{ + stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101858.c b/SingleSource/Regression/C/gcc-dg/pr101858.c new file mode 100644 index 0000000000..61fcca6098 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101858.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +int foo(int a) +{ + if (a < (int*)((__INTPTR_TYPE__)1 << a)) + a = 0; + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101885.c b/SingleSource/Regression/C/gcc-dg/pr101885.c new file mode 100644 index 0000000000..05fd0ed308 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101885.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +int a = 3, c; +short b = 5, d, f; +volatile short e; + +__attribute__((noipa)) void +foo (void) +{ +} + +int +main () +{ + for (f = 0; f != 2; f++) + { + int g = a; + if (b) + if (a) + for (a = b = 0; b <= 3; b++) + ; + for (c = 0; c != 16; ++c) + e; + } + b = d; + foo (); + if (a != 0) + __builtin_abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr101938.c b/SingleSource/Regression/C/gcc-dg/pr101938.c new file mode 100644 index 0000000000..82777554ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101938.c @@ -0,0 +1,28 @@ +// { dg-do run } +// { dg-require-effective-target lp64 } +// { dg-options "-O2 -fwrapv" } + +typedef long long int int64; +#define INT64CONST(x) (x##LL) +/* -9223372036854775808ULL */ +#define INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1) + +static void __attribute__((noipa)) foo(int64 arg1, int64 arg2) { + int64 a1 = -arg1; + int64 a2 = (arg2 < 0) ? arg2 : -arg2; + + if (a1 > a2) { + int64 swap = arg1; + arg1 = arg2; + arg2 = swap; + } + + if (arg1 == INT64_MIN && arg2 == -1) return; + + __builtin_abort(); +} + +int main() { + foo(-1, INT64_MIN); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr101955.c b/SingleSource/Regression/C/gcc-dg/pr101955.c new file mode 100644 index 0000000000..6a04288511 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr101955.c @@ -0,0 +1,63 @@ +/* { dg-do compile { target int32 } } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +__attribute__((noipa)) int +t1 (int x) +{ + int y = x << 31; + int z = y >> 31; + return z; +} + +__attribute__((noipa)) int +t2 (unsigned int x) +{ + int y = x << 31; + int z = y >> 31; + return z; +} + +__attribute__((noipa)) int +t3 (int x) +{ + return (x << 31) >> 31; +} + +__attribute__((noipa)) int +t4 (int x) +{ + return (x << 24) >> 24; +} + +__attribute__((noipa)) int +t5 (int x) +{ + return (x << 16) >> 16; +} + +__attribute__((noipa)) long long +t6 (long long x) +{ + return (x << 63) >> 63; +} + +__attribute__((noipa)) long long +t7 (long long x) +{ + return (x << 56) >> 56; +} + +__attribute__((noipa)) long long +t8 (long long x) +{ + return (x << 48) >> 48; +} + +__attribute__((noipa)) long long +t9 (long long x) +{ + return (x << 32) >> 32; +} + +/* { dg-final { scan-tree-dump-not " >> " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " << " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr102009.c b/SingleSource/Regression/C/gcc-dg/pr102009.c new file mode 100644 index 0000000000..5b3a39bd0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102009.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/102009 */ +/* { dg-do compile } */ + +void *realloc (); /* { dg-message "declared here" } */ + +void * +foo (void *p) +{ + return realloc (p); /* { dg-warning "too few arguments to built-in function 'realloc' expecting " } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102087.c b/SingleSource/Regression/C/gcc-dg/pr102087.c new file mode 100644 index 0000000000..5cd094fc09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102087.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +unsigned __attribute__ ((noinline)) +foo (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) +{ + while (n < ++l) + *a++ = *b++ + 1; + return l; +} + +volatile int a[1]; +unsigned b; +int c; + +int +check () +{ + int d; + for (; b > 1; b++) + for (c = 0; c < 2; c++) + for (d = 0; d < 2; d++) + a[0]; + return 0; +} + +char **clip_image_gfi_0; +int clip_image_y, clip_image_shift; +void +clip_image () +{ + for (; clip_image_y >= clip_image_shift; clip_image_y++) + clip_image_gfi_0[clip_image_shift] + = clip_image_gfi_0[clip_image_y]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102087_1.c b/SingleSource/Regression/C/gcc-dg/pr102087_1.c new file mode 100644 index 0000000000..ba4efe3b41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102087_1.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/102087 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fprefetch-loop-arrays -w" { target x86_64-*-* powerpc*-*-* } } */ + +char **Gif_ClipImage_gfi_0; +int Gif_ClipImage_gfi_1, Gif_ClipImage_y, Gif_ClipImage_shift; +void Gif_ClipImage() { + Gif_ClipImage_y = Gif_ClipImage_gfi_1 - 1; + for (; Gif_ClipImage_y >= Gif_ClipImage_shift; Gif_ClipImage_y++) + Gif_ClipImage_gfi_0[Gif_ClipImage_shift] = + Gif_ClipImage_gfi_0[Gif_ClipImage_y]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr102140.c b/SingleSource/Regression/C/gcc-dg/pr102140.c new file mode 100644 index 0000000000..813ba8766a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102140.c @@ -0,0 +1,23 @@ +/* PR target/102140 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Og -fipa-cp -fno-tree-ccp -fno-tree-ter -Wno-psabi" } */ + +typedef int __attribute__((__vector_size__ (64))) U; +typedef __int128 __attribute__((__vector_size__ (64))) V; + +int a, b; + +static void +bar (char c, V v) +{ + v *= c; + U u = a + (U) v; + (union { U b; }) { u }; + b = 0; +} + +void +foo (void) +{ + bar (1, (V){((__int128) 9223372036854775808ULL) << 64}); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102141.c b/SingleSource/Regression/C/gcc-dg/pr102141.c new file mode 100644 index 0000000000..f3fc8d87d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102141.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/102141 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned int __attribute__((__vector_size__ (4))) v; + +void +foo (unsigned long long x) +{ + v &= (unsigned) (x >> 56 | x >> 40 & 0xff00); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102152.c b/SingleSource/Regression/C/gcc-dg/pr102152.c new file mode 100644 index 0000000000..4e0c1f5a3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102152.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-loop-vectorize -fno-tree-fre" } */ +/* { dg-additional-options "-march=armv8-a+sve" { target aarch64-*-* } } */ + + + +signed char i; + +void +foo (void) +{ + for (i = 0; i < 6; i += 5) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102207.c b/SingleSource/Regression/C/gcc-dg/pr102207.c new file mode 100644 index 0000000000..08540d0c18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102207.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/102207 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2" } */ + +typedef unsigned __int128 u128; + +u128 +foo (unsigned short a) +{ + u128 g; + __builtin_sub_overflow ((unsigned long long) -a, 1, &g); + return g; +} + +int +main () +{ + if (__SIZEOF_LONG_LONG__ * __CHAR_BIT__ != 64 + || __SIZEOF_SHORT__ * __CHAR_BIT__ != 16) + return 0; + if (foo (1) != 0xfffffffffffffffeULL) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102224.c b/SingleSource/Regression/C/gcc-dg/pr102224.c new file mode 100644 index 0000000000..9f09ba5ccb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102224.c @@ -0,0 +1,49 @@ +/* PR target/102224 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +__attribute__((noipa)) float +foo (float x) +{ + return x * __builtin_copysignf (1.0f, x); +} + +__attribute__((noipa)) float +bar (float x, float y) +{ + return x * __builtin_copysignf (1.0f, y); +} + +__attribute__((noipa)) float +baz (float z, float x) +{ + return x * __builtin_copysignf (1.0f, x); +} + +__attribute__((noipa)) float +qux (float z, float x, float y) +{ + return x * __builtin_copysignf (1.0f, y); +} + +int +main () +{ + if (foo (1.0f) != 1.0f + || foo (-4.0f) != 4.0f) + __builtin_abort (); + if (bar (1.25f, 7.25f) != 1.25f + || bar (1.75f, -3.25f) != -1.75f + || bar (-2.25f, 7.5f) != -2.25f + || bar (-3.0f, -4.0f) != 3.0f) + __builtin_abort (); + if (baz (5.5f, 1.0f) != 1.0f + || baz (4.25f, -4.0f) != 4.0f) + __builtin_abort (); + if (qux (1.0f, 1.25f, 7.25f) != 1.25f + || qux (2.0f, 1.75f, -3.25f) != -1.75f + || qux (3.0f, -2.25f, 7.5f) != -2.25f + || qux (4.0f, -3.0f, -4.0f) != 3.0f) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102269.c b/SingleSource/Regression/C/gcc-dg/pr102269.c new file mode 100644 index 0000000000..9d41b8fd7c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102269.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-ftrivial-auto-var-init=zero" } */ + +void fn() { int a[0]; } diff --git a/SingleSource/Regression/C/gcc-dg/pr102273.c b/SingleSource/Regression/C/gcc-dg/pr102273.c new file mode 100644 index 0000000000..568e44ebfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102273.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-ftrivial-auto-var-init=zero" } */ + +void bar(); + +struct A { char d; }; +void foo() +{ + struct A e; + void baz() { bar(e); } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102356.c b/SingleSource/Regression/C/gcc-dg/pr102356.c new file mode 100644 index 0000000000..6fce77043c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102356.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/102356 */ +/* { dg-do compile { target int32plus } } */ +/* { dg-options "-O3 -g" } */ + +signed char a = 0; +unsigned char b = 9; +unsigned long long c = 0xF1FBFC17225F7A57ULL; +int d = 0x3A6667C6; + +unsigned char +foo (unsigned int x) +{ + unsigned int *e = &x; + if ((c /= ((0 * (*e *= b)) <= 0))) + ; + for (d = 9; d > 2; d -= 2) + { + c = -2; + do + if ((*e *= *e)) + { + a = 4; + do + { + a -= 3; + if ((*e *= *e)) + b = 9; + } + while (a > 2); + } + while (c++); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102385.c b/SingleSource/Regression/C/gcc-dg/pr102385.c new file mode 100644 index 0000000000..bdccc9e43b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102385.c @@ -0,0 +1,16 @@ +/* { dg-options "-Wall -Wextra -O2 -fno-toplevel-reorder -fno-tree-ch -fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse -fno-tree-loop-ivcanon -fpredictive-commoning -fdump-tree-pcom-details-blocks -fdump-tree-lim-details-blocks" } */ + +short a, b; +int c[9]; +void(d)() {} +void e() { + a = 0; + for (; a <= 4; a++) { + short *f = &b; + c[a] || (*f = 0); + d(c[a + 2]); + } +} +int main() {return 0;} +/* { dg-final { scan-tree-dump-not "Invalid sum" "pcom" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "lim2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr102463.c b/SingleSource/Regression/C/gcc-dg/pr102463.c new file mode 100644 index 0000000000..ca63f0b876 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102463.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +_Bool _bfd_elf_merge_symbol_h, _bfd_elf_merge_symbol_h_1; +_Bool _bfd_elf_merge_symbol_olddef; +_Bool bfd_is_com_section(); + +void +_bfd_elf_merge_symbol() { + _Bool newdef = bfd_is_com_section(), ntdef, tdef; + _bfd_elf_merge_symbol_olddef = _bfd_elf_merge_symbol_h; + if (_bfd_elf_merge_symbol_h_1) { + ntdef = newdef; + tdef = _bfd_elf_merge_symbol_h; + } else { + ntdef = _bfd_elf_merge_symbol_h; + tdef = newdef; + } + if (tdef && ntdef) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102478.c b/SingleSource/Regression/C/gcc-dg/pr102478.c new file mode 100644 index 0000000000..43bc49b584 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102478.c @@ -0,0 +1,29 @@ +/* PR rtl-optimization/102478 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-if-conversion -Wno-div-by-zero" } */ + +unsigned a, b, c; + +void +foo (void) +{ + c |= __builtin_expect (65535 / a, 0) && 0 / 0; + b = 0; +} + +void +bar (void) +{ + if (a <= 65535) + __builtin_trap (); + b = 0; +} + +void +baz (void) +{ + if (a > 65535) + b = 0; + else + __builtin_trap (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102511.c b/SingleSource/Regression/C/gcc-dg/pr102511.c new file mode 100644 index 0000000000..8a9af34730 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102511.c @@ -0,0 +1,21 @@ +// { dg-do run } +// { dg-options "-O3" } + +char arr_15 [8]; +__attribute__((noipa)) +void test(signed char a, unsigned short b, unsigned long long c, + unsigned short f) { + for (int d = b - 8; d < b; d += 2) + for (short e = 0; e < (unsigned short)((f ? 122 : 0) ^ (a ? c : 0)) - 64055; + e += 3) + arr_15[d] = 42; +} +int main() { + test(37, 8, 12325048486467861044ULL, 45936); + for (int i = 0; i < 8; ++i) + { + if (arr_15[i] != ((i&1) ? 0 : 42)) + __builtin_abort(); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102540.c b/SingleSource/Regression/C/gcc-dg/pr102540.c new file mode 100644 index 0000000000..c12f8fcebf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102540.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-evrp" } */ + + +void kill(); + +static long a; +static unsigned b; +int test1 () { + long c, e; + c = b = a; + e = c ? 2 / (c + 1) : 0; + if (e && !b) + kill (); + a = 0; +} + +/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr102585.c b/SingleSource/Regression/C/gcc-dg/pr102585.c new file mode 100644 index 0000000000..efd066b4a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102585.c @@ -0,0 +1,6 @@ +/* PR debug/102585 */ +/* { dg-do compile } */ +/* { dg-options "-fvar-tracking-assignments -fno-var-tracking" } */ + +#pragma GCC optimize 0 +void d_demangle_callback_Og() { int c = 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr102648.c b/SingleSource/Regression/C/gcc-dg/pr102648.c new file mode 100644 index 0000000000..a0f6386dde --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102648.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ + +void foo(); +static char a, c; +static int d, e; +static short b(short f, short g) { return f * g; } +int main() { + short h = 4; + for (; d;) + if (h) + if(e) { + if (!b(a & 1 | h, 3)) + c = 0; + h = 1; + } + if (c) + foo(); +} + +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr102650.c b/SingleSource/Regression/C/gcc-dg/pr102650.c new file mode 100644 index 0000000000..16ae840260 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102650.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-vrp1" } */ + +static int a = 2, b, c, d; +void foo(void); +int main() { + short e; + int f = -1; + if (b) + c = 0; + c || (f = 2); + for (; d < 1; d++) + e = f + a; + if (!e) + foo(); + return 0; +} + +/* { dg-final { scan-tree-dump-not "foo" "vrp1" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr102738.c b/SingleSource/Regression/C/gcc-dg/pr102738.c new file mode 100644 index 0000000000..cd58c25899 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102738.c @@ -0,0 +1,49 @@ +/* PR tree-optimization/102738 */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ +/* { dg-do compile { target int128 } } */ + +/* Remove arithmetic shift right when the LHS is known to be 0 or -1. */ + +int a1(__int128 f, int g) +{ + /* Leaves f >> 127. */ + return (f >> 127) >> g; +} + +int a2(int f, int g) +{ + /* Leaves f >> 31. */ + return (f >> 31) >> g; +} + +int a3(int f, int g) +{ + if (f == 0 || f == -1) + return f >> g; + __builtin_unreachable(); +} + +int a4(int f, int g) +{ + if (f == 0 || f == 1) + return (-f) >> g; + __builtin_unreachable(); +} + +int a5(int f, int g) +{ + if (f == 0 || f == 1) + return (f-1) >> g; + return 0; +} + +int a6(int f, int g) +{ + if (f == 6 || f == 7) + return (f-7) >> g; + __builtin_unreachable(); +} + +/* { dg-final { scan-tree-dump-times " >> 127" 1 "evrp" } } */ +/* { dg-final { scan-tree-dump-times " >> 31" 1 "evrp" } } */ +/* { dg-final { scan-tree-dump-times " >> " 2 "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr102764.c b/SingleSource/Regression/C/gcc-dg/pr102764.c new file mode 100644 index 0000000000..ea1c634c73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102764.c @@ -0,0 +1,14 @@ +/* PR middle-end/102764 */ +/* Reported by Chengnian Sun */ + +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ + +volatile int a; + +void main (void) +{ + for (int i = 0; i < 1000; i++) + if (i % 17) + a++; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102798.c b/SingleSource/Regression/C/gcc-dg/pr102798.c new file mode 100644 index 0000000000..3a50546a16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102798.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-tree-pta" } */ + +typedef __SIZE_TYPE__ size_t; + +__attribute__((__noipa__)) +void BUF_reverse (unsigned char *out, const unsigned char *in, size_t size) +{ + size_t i; + if (in) + { + out += size - 1; + for (i = 0; i < size; i++) + *out++ = *in++; + } + else + { + unsigned char *q; + char c; + q = out + size - 1; + for (i = 0; i < size ; i++) + { + *out++ = 1; + } + } +} + +int +main (void) +{ + unsigned char buf[40]; + unsigned char buf1[40]; + for (unsigned i = 0; i < sizeof (buf); i++) + buf[i] = i; + BUF_reverse (buf, 0, sizeof (buf)); + for (unsigned i = 0; i < sizeof (buf); i++) + if (buf[i] != 1) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102827.c b/SingleSource/Regression/C/gcc-dg/pr102827.c new file mode 100644 index 0000000000..eed3eba32d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102827.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-vectorize --param ssa-name-def-chain-limit=0" } */ +/* { dg-additional-options "-mavx" { target { x86_64-*-* i?86-*-* } } } */ + +void +test_double_double_nugt_var (double *dest, double *src, int b, int i) +{ + while (i < 1) + { + dest[i] = b ? src[i] : 0.0; + ++i; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102872.c b/SingleSource/Regression/C/gcc-dg/pr102872.c new file mode 100644 index 0000000000..971bb03a5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102872.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void foo(void); + +static int a, b; +int main() { + for (; a; ++a) { + unsigned short d = a; + if (!(b | d) && d) + foo(); + } +} + +/* { dg-final { scan-tree-dump-not "foo" "evrp" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr102892-1.c b/SingleSource/Regression/C/gcc-dg/pr102892-1.c new file mode 100644 index 0000000000..faca3f2f35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102892-1.c @@ -0,0 +1,22 @@ +/* { dg-do link } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-fno-PIC" { target ia32 } } */ +/* { dg-additional-sources "pr102892-2.c" } */ + +static long b[2][1] = {0}; + +extern void bar(void); +extern void foo(void); + +int +main () +{ + long c = 0; + for (long a = 0; a < 1; ++a) + for (; c <= 1; c++) { + bar(); + if (1 == b[c][0]) + foo(); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102892-2.c b/SingleSource/Regression/C/gcc-dg/pr102892-2.c new file mode 100644 index 0000000000..b39bd6c97b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102892-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void +bar (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102897.c b/SingleSource/Regression/C/gcc-dg/pr102897.c new file mode 100644 index 0000000000..8e0d25ee24 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102897.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* Specify C99 to avoid the warning/error on compound literals. */ +/* { dg-options "-O1 -std=c99 -Wno-psabi" } */ + +/* Verify that there is no ICE. */ + +typedef __attribute__((vector_size(8))) signed char int8x8_t; +typedef __attribute__((vector_size(8))) unsigned char uint8x8_t; + +int8x8_t fn1 (int8x8_t val20, char tmp) +{ + uint8x8_t __trans_tmp_3; + __trans_tmp_3 = (uint8x8_t){tmp}; + int8x8_t __a = (int8x8_t) __trans_tmp_3; + return __builtin_shuffle (__a, val20, (uint8x8_t){0}); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr102950.c b/SingleSource/Regression/C/gcc-dg/pr102950.c new file mode 100644 index 0000000000..317568370d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102950.c @@ -0,0 +1,21 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern void link_error(void); + +static signed char a; +static short d(unsigned e) { + signed char b; + short c; + a = b = e; + if (b) + return 0; + if (1 >= e) { + c = e == 0; + if (c) + link_error(); + } + return 0; +} +int main() { d(a ^ 233); } + diff --git a/SingleSource/Regression/C/gcc-dg/pr102983.c b/SingleSource/Regression/C/gcc-dg/pr102983.c new file mode 100644 index 0000000000..ded748af08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr102983.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp -fno-tree-ccp" } */ +void foo(void); + +static int a = 1; + +int main() { + int c = 0; + for (int b = 0; b <= 0; b++) { + if (!a) + foo(); + if (b > c){ + if (c) + continue; + a = 0; + } + c = 1; + } +} + +/* { dg-final { scan-tree-dump-times "Global Exported: c_.*1, 1" 1 "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr103003.c b/SingleSource/Regression/C/gcc-dg/pr103003.c new file mode 100644 index 0000000000..d3d65f8b6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103003.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +typedef char int8_t; +int8_t c_4, uli_5; +unsigned short us_6; +void func_1() { + int uli_9; + short ptr_16ptr_11 = &uli_9; /* { dg-warning "initialization of*" } */ + for (; us_6 <= 6;) + if ((us_6 *= uli_9) < (uli_5 || 0) ?: ((c_4 = us_6) >= us_6) - uli_5) + uli_9 = 9; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103028.c b/SingleSource/Regression/C/gcc-dg/pr103028.c new file mode 100644 index 0000000000..df96c62ddd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103028.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fif-conversion2 -Og" } */ +/* { dg-options "-fif-conversion2 -Og -march=z9-ec" { target { s390x-*-* } } } */ + +unsigned char x; +int foo(void) +{ + unsigned long long i = x; + i = i + 0x80000000; + unsigned long long t = 0xffffffff; + + if (i > t) { + unsigned long long ii; + asm("":"=g"(ii):"0"(i)); + if ((ii <= t)) + __builtin_trap(); + return x; + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103062.c b/SingleSource/Regression/C/gcc-dg/pr103062.c new file mode 100644 index 0000000000..cbc371b4cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103062.c @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options "-O2 -fno-tree-forwprop" } + +void *a, *b, *c; +void foo(void) { + c = (void *)((__INTPTR_TYPE__)a & (__INTPTR_TYPE__)b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103075.c b/SingleSource/Regression/C/gcc-dg/pr103075.c new file mode 100644 index 0000000000..b332fb0143 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103075.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O -frounding-math" } */ + +float +foo (void) +{ + return (float) 0x1699925 * 1.1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103079.c b/SingleSource/Regression/C/gcc-dg/pr103079.c new file mode 100644 index 0000000000..7b10754472 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103079.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fdump-tree-vrp2 -fno-tree-ch" } */ + +int a, b = -2; +int main() { + int d = 0; + int t; + if (b) + goto t1; + if (t) { +t1: + if (!a) + d = b; + while (d > -1) + ; + } + return 0; +} +/* { dg-final { scan-tree-dump "PHI" "vrp2" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr103093.c b/SingleSource/Regression/C/gcc-dg/pr103093.c new file mode 100644 index 0000000000..f42572147a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103093.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int i_0, c_4, uc_7, func_2_c_11; + +short *func_2_ptr_10; + +void func_2() { + uc_7 = 7; + for (; uc_7 <= 60; uc_7 += 1) { + c_4 = 5; + for (; c_4 <= 76; c_4 += 1) { + func_2_ptr_10 = &i_0; /* { dg-warning "assignment to .*" } */ + if ((i_0 |= 5) > 0 ?: (60 && uc_7) | *func_2_ptr_10) + if (func_2_c_11) + for (;;) + ; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103120.c b/SingleSource/Regression/C/gcc-dg/pr103120.c new file mode 100644 index 0000000000..b680a6c0fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103120.c @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-options "-O2" } + +#define radix 10 +__INT32_TYPE__ numDigits(__UINT64_TYPE__ value) +{ + __INT32_TYPE__ n = 1; + while (value > __UINT32_MAX__) + { + n += 4; + value /= radix * radix * radix * radix; + } + __UINT32_TYPE__ v = (__UINT32_TYPE__)value; + while (1) + { + if (v < radix) + return n; + if (v < radix * radix) + return n + 1; + if (v < radix * radix * radix) + return n + 2; + if (v < radix * radix * radix * radix) + return n + 3; + n += 4; + v /= radix * radix * radix * radix; + } +} + +int main() +{ + if (numDigits(__UINT64_MAX__) != 20) + __builtin_abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103184-1.c b/SingleSource/Regression/C/gcc-dg/pr103184-1.c new file mode 100644 index 0000000000..e567f95f63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103184-1.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern char foo; +extern unsigned char bar; + +int +foo1 (void) +{ + return __sync_fetch_and_and (&foo, ~1) & 1; +} + +int +foo2 (void) +{ + return __sync_fetch_and_or (&foo, 1) & 1; +} + +int +foo3 (void) +{ + return __sync_fetch_and_xor (&foo, 1) & 1; +} + +unsigned short +bar1 (void) +{ + return __sync_fetch_and_and (&bar, ~1) & 1; +} + +unsigned short +bar2 (void) +{ + return __sync_fetch_and_or (&bar, 1) & 1; +} + +unsigned short +bar3 (void) +{ + return __sync_fetch_and_xor (&bar, 1) & 1; +} + +/* { dg-final { scan-assembler-times "lock;?\[ \t\]*cmpxchgb" 6 { target { x86_64-*-* i?86-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr103184-2.c b/SingleSource/Regression/C/gcc-dg/pr103184-2.c new file mode 100644 index 0000000000..499761fdbf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103184-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +int +tbit0 (_Atomic int* a, int n) +{ +#define BIT (0x1 << n) + return atomic_fetch_or (a, BIT) & BIT; +#undef BIT +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103207.c b/SingleSource/Regression/C/gcc-dg/pr103207.c new file mode 100644 index 0000000000..69c0f555f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103207.c @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-O2 --param case-values-threshold=1 -w" } + +int f (int i) +{ + switch (i) { + case 2147483647: + return 1; + case 9223372036854775807L: + return 2; + case (2147483647*4)%4: + return 4; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103222.c b/SingleSource/Regression/C/gcc-dg/pr103222.c new file mode 100644 index 0000000000..2a84437b25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103222.c @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-options "-O2" } + +#include +#include +int16_t a; +static uint32_t *b ; +static uint8_t func_2(); +static int32_t func_1() { + int16_t a = 1; + func_2(0, a, a); + return 0; +} +uint8_t func_2(uint32_t p1, uint32_t p2, uint32_t p3) { + int p = 0; + for (15;; a++) { + for (0;;) { + if (p2) + break; + b = &p2; + return p2; + } + p3 = (p2 = p3, p); + } + return 0; +} + +int main() { + func_1(); + if (a != 2) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103248.c b/SingleSource/Regression/C/gcc-dg/pr103248.c new file mode 100644 index 0000000000..da6232d21e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103248.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fixed_point } */ +/* { dg-options "-fnon-call-exceptions" } */ + +_Accum sa; +int c; + +void div_csa() { c /= sa; } diff --git a/SingleSource/Regression/C/gcc-dg/pr103254.c b/SingleSource/Regression/C/gcc-dg/pr103254.c new file mode 100644 index 0000000000..62d2415f21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103254.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-timeout 10 } */ + +short int i; + +void +foo (void) +{ + for (i = 1; i < 2; i += 4) + { + int j; + + for (j = 0; j < 5; j += 4) + { + int k; + + for (k = 0; k < 68; k += 4) + { + i &= j; + j &= i; + } + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103268-1.c b/SingleSource/Regression/C/gcc-dg/pr103268-1.c new file mode 100644 index 0000000000..6d583d55d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103268-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int si; +long +test_types (void) +{ + unsigned int u2 = __atomic_fetch_xor (&si, 0, 5); + return u2; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103268-2.c b/SingleSource/Regression/C/gcc-dg/pr103268-2.c new file mode 100644 index 0000000000..12283bb43d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103268-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern long pscc_a_2_3; +extern int pscc_a_1_4; + +void +pscc (void) +{ + pscc_a_1_4 = __sync_fetch_and_and (&pscc_a_2_3, 1); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr103270.c b/SingleSource/Regression/C/gcc-dg/pr103270.c new file mode 100644 index 0000000000..819310e360 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103270.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +void test(int a, int* i) +{ + for (; a < 5; ++a) + { + int b = 0; + int c = 0; + for (; b != -11; b--) + for (int d = 0; d ==0; d++) + { + *i += c & a; + c = b; + } + } +} + +/* { dg-final { scan-tree-dump-not "extra loop exit heuristics of edge\[^:\]*:" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr103277.c b/SingleSource/Regression/C/gcc-dg/pr103277.c new file mode 100644 index 0000000000..5c206f919c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103277.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fbranch-probabilities -fno-ipa-pure-const" } */ + +__attribute__ ((returns_twice)) void +bar (void) +{ +} + +void +foo (int cond) +{ + if (cond) + bar (); +} /* { dg-message "profile count data" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr103356-1.c b/SingleSource/Regression/C/gcc-dg/pr103356-1.c new file mode 100644 index 0000000000..61d0b81da2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103356-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-forwprop1" } */ + +_Bool foo (_Bool a, _Bool b) +{ + return a == (!b); +} + +/* { dg-final { scan-tree-dump "\[ab\]_\[0-9\]+\\(D\\) \\\^ \[ba\]_\[0-9\]+\\(D\\)" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr103359.c b/SingleSource/Regression/C/gcc-dg/pr103359.c new file mode 100644 index 0000000000..13406f90d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103359.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-evrp" } */ + +void foo(); +static char a, c; +static int d, e; +static short b(short f, short g) { return f * g; } +int main() { + short h = 4; + for (; d;) + if (h) + if(e) { + if (!b(a & 1 | h, 3)) + c = 0; + h = 1; + } + if (c) + foo(); +} + +/* { dg-final { scan-tree-dump-not "c = 0" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr103406.c b/SingleSource/Regression/C/gcc-dg/pr103406.c new file mode 100644 index 0000000000..9c7b83b2e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103406.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#define HUGE __DBL_MAX__ +#define INF (HUGE + HUGE) +#define NAN (INF - INF) + +double foo() { + double x = -NAN; + double y = NAN; + return x + y; +} + +/* { dg-final { scan-tree-dump-not "return 0\.0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr103431.c b/SingleSource/Regression/C/gcc-dg/pr103431.c new file mode 100644 index 0000000000..09f224a390 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103431.c @@ -0,0 +1,21 @@ +/* PR middle-end/103431 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O -fno-tree-bit-ccp -fno-tree-dominator-opts" } */ + +__attribute__((noipa)) +void foo (unsigned short a) +{ + __uint128_t b = 5; + int size = __SIZEOF_INT128__ * __CHAR_BIT__ - 1; + a /= 0xfffffffd; + __uint128_t c = (b << (a & size) | b >> (-(a & size) & size)); + if (c != 5) + __builtin_abort (); +} + +int +main () +{ + foo (0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103440.c b/SingleSource/Regression/C/gcc-dg/pr103440.c new file mode 100644 index 0000000000..b97f45cd3e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103440.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-Os" } */ +/* { dg-timeout 10 } */ + +int a, b, c, d, e; +int main() { + int f = 2, g = 1, h = -3; +L1: + c = b ^ 1; + if (!f) + goto L3; + if (d) + g = e; + f = h; + if (!c) + goto L1; +L2: + if (g) + a = 0; +L3: + if (d == g) + goto L2; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103451.c b/SingleSource/Regression/C/gcc-dg/pr103451.c new file mode 100644 index 0000000000..c701934603 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103451.c @@ -0,0 +1,19 @@ +// { dg-do compile } +// { dg-options "-O2 -w -fnon-call-exceptions -fno-delete-dead-exceptions -fdump-tree-optimized" } + +int func_10_ptr_12; + +void func_10(long li_8) +{ + long *ptr_9 = &li_8; + li_8 &= *ptr_9 / 0 ?: li_8; + for (;;) + func_10_ptr_12 &= 4 ? *ptr_9 : 4; +} + +void func_9_s_8() +{ + func_10(func_9_s_8); +} + +// { dg-final { scan-tree-dump " / 0" "optimized" } } diff --git a/SingleSource/Regression/C/gcc-dg/pr103485.c b/SingleSource/Regression/C/gcc-dg/pr103485.c new file mode 100644 index 0000000000..1afa928692 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103485.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +int foo_v256u128_0; +unsigned __attribute__((__vector_size__ (sizeof(unsigned) * 8))) foo_v256u8_0; + +void +foo (void) +{ + foo_v256u8_0 -= (foo_v256u8_0 >> sizeof (foo_v256u8_0) - 1) + foo_v256u128_0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103587.c b/SingleSource/Regression/C/gcc-dg/pr103587.c new file mode 100644 index 0000000000..1cbc4d52d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103587.c @@ -0,0 +1,7 @@ +/* PR c/103587 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +[[foo::bar( +#pragma GCC ivdep +)]]; /* { dg-warning "attribute ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr103594.c b/SingleSource/Regression/C/gcc-dg/pr103594.c new file mode 100644 index 0000000000..0eae239eea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103594.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O1 -fpic" } */ + +int regex_subst(void) +{ + const void *subst = ""; + return (*(int (*)(int))subst) (0); +} + +int foobar (void) +{ + int x; + return (*(int (*)(void))&x) (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103721-2.c b/SingleSource/Regression/C/gcc-dg/pr103721-2.c new file mode 100644 index 0000000000..aefa1f0f14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103721-2.c @@ -0,0 +1,28 @@ +// { dg-do run } +// { dg-options "-O2" } + +extern void abort (); +struct S { int x; } a[10]; +struct S *b; + +int +main () +{ + int i, j = 0; + struct S *q = a; + + for (i = 100; --i > 0; ) + { + struct S *p; + j++; + if (j >= 10) + j = 0; + p = &a[j]; + + if (p == q) + abort (); + __atomic_thread_fence (__ATOMIC_SEQ_CST); + q = p; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103721.c b/SingleSource/Regression/C/gcc-dg/pr103721.c new file mode 100644 index 0000000000..6ec2e44b30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103721.c @@ -0,0 +1,25 @@ +// { dg-do run } +// { dg-options "-O2" } + +int ipos = 0; +int f (int world) +{ + int searchVolume = world; + int currentVolume = 0; + while (currentVolume != searchVolume && searchVolume) { + currentVolume = searchVolume; + if (ipos != 0) + searchVolume = 0; + else + searchVolume = 1; + } + return (currentVolume); +} +int main() +{ + const int i = f (1111); + __builtin_printf ("%d\n", (int)(i)); + if (i != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103770.c b/SingleSource/Regression/C/gcc-dg/pr103770.c new file mode 100644 index 0000000000..f7867d1284 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103770.c @@ -0,0 +1,27 @@ +/* PR middle-end/103770 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct struct_s { + void* ptr; + void* ptr2; + void* ptr3; +}; + +struct struct_s struct_create(int N, const long vla[N]); + +void fun(int N) +{ + long vla[N]; + struct struct_s st = struct_create(N, vla); +} + + +extern _Complex float g(int N, int dims[N]); + +void f(void) +{ + int dims[1]; + _Complex float val = g(1, dims); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr103775.c b/SingleSource/Regression/C/gcc-dg/pr103775.c new file mode 100644 index 0000000000..4a8c0d6d14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103775.c @@ -0,0 +1,12 @@ +/* PR rtl-optimization/103775 */ +/* { dg-do assemble { target int128 } } */ +/* { dg-options "-Og -fno-forward-propagate -free -g" } */ + +int +foo (char a, short b, int c, __int128 d, char e, short f, int g, __int128 h) +{ + long i = __builtin_clrsbll ((char) h); + __builtin_memset ((char *) &h + 4, d, 3); + c &= (char) h; + return c + i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103793.c b/SingleSource/Regression/C/gcc-dg/pr103793.c new file mode 100644 index 0000000000..d7ed721c97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103793.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-guess-branch-probability" } */ + +extern void bar (void); + +void +foo (int x, int w) +{ + for (int y; y < w; y++) + if (y < x) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103808.c b/SingleSource/Regression/C/gcc-dg/pr103808.c new file mode 100644 index 0000000000..51fc460a90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103808.c @@ -0,0 +1,23 @@ +/* PR debug/103808 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-fcompare-debug -O2 -ftrapv" } */ + +void +foo (__int128 x, int y) +{ + for (;;) + { + __int128 a, b; + + x |= !!y; + a = x + 1; + b = y ? ++y : ++x; + y = a < b; + asm ("" : "+r" (y)); + if (x >> 2) + y *= 2; + + if (y == b) + __builtin_unreachable (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103837.c b/SingleSource/Regression/C/gcc-dg/pr103837.c new file mode 100644 index 0000000000..43593d52b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103837.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/103837 */ +/* { dg-do compile } */ +/* { dg-options "-Og -fcompare-debug -fmove-loop-invariants -fnon-call-exceptions -fexceptions -fdelete-dead-exceptions -fno-tree-dce -w" } */ + +unsigned long int +foo (int x) +{ + double a; + int b; + unsigned long int ret = a; + + for (;;) + { + b = !!((int) a); + a = x; + } + + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103838.c b/SingleSource/Regression/C/gcc-dg/pr103838.c new file mode 100644 index 0000000000..cde44e6e4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103838.c @@ -0,0 +1,28 @@ +/* PR debug/103838 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +#ifdef __SIZEOF_INT128__ +__int128 m; +#else +long long m; +#endif +int n; + +__attribute__((noinline)) void +bar (void) +{ + n += !!m; +} + +void +foo (void) +{ + int i; + + for (i = 0; i < 2; ++i) + { + bar (); + m /= 3; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103845.c b/SingleSource/Regression/C/gcc-dg/pr103845.c new file mode 100644 index 0000000000..45ab518d07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103845.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fharden-compares -fno-ipa-pure-const" } */ + +int +baz (void); + +__attribute__ ((returns_twice)) void +bar (void) +{ +} + +int +quux (int y, int z) +{ + return (y || z >= 0) ? y : z; +} + +int +foo (int x) +{ + int a = 0, b = x == a; + + bar (); + + if (!!baz () < quux (b, a)) + ++x; + + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr103859.c b/SingleSource/Regression/C/gcc-dg/pr103859.c new file mode 100644 index 0000000000..c58be5c15a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103859.c @@ -0,0 +1,23 @@ +/* PR middle-end/103859 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef struct dcmplx dcmplx; + +struct dcmplx { + double re; + double im; +}; + +dcmplx horner(int n, dcmplx p[n], dcmplx x); + +int main(void) +{ + int i, n; + dcmplx x[n + 1], f[n + 1]; + + horner(n + 1, f, x[i]); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr103860.c b/SingleSource/Regression/C/gcc-dg/pr103860.c new file mode 100644 index 0000000000..15eee55808 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103860.c @@ -0,0 +1,31 @@ +/* PR rtl-optimization/103860 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ + +static int d, *e; +int f; + +__attribute__((noinline)) signed char +foo (signed char b, signed char c) +{ + return b + c; +} + +int +main () +{ + signed char l; + for (l = -1; l; l = foo (l, 1)) + { + while (d < 0) + ; + if (d > 0) + { + f = 0; + *e = 0; + } + } + d = 0; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr10392-1.c b/SingleSource/Regression/C/gcc-dg/pr10392-1.c new file mode 100644 index 0000000000..8d599b8af7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr10392-1.c @@ -0,0 +1,63 @@ +/* PR optimization/10392 + * Reporter: marcus@mc.pp.se + * Summary: [3.3/3.4 regression] [SH] optimizer generates faulty array indexing + * Description: + * The address calculation of an index operation on an array on the stack + * can _under some conditions_ get messed up completely + * + * Testcase tweaked by dank@kegel.com + * Problem only happens with -O2 -m4, so it should only happen on sh4, + * but what the heck, let's test other architectures, too. + * Not marked as xfail since it's a regression. +*/ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -m4" { target sh4-*-* } } */ +extern void abort (void); +const char *dont_optimize_function_away; + +const char *use(const char *str) +{ + dont_optimize_function_away = str; + if (str[0] != 'v') + abort(); + if (str[1] < '1' || str[1] > '6') + abort(); + if (str[2]) + abort(); + return str[2] ? "notused" : "v6"; +} + +const char *func(char *a, char *b) +{ + char buf[128]; + unsigned char i; + const char *result; + + char *item[] = { + "v1", + "v2", + }; + + buf[0] = 'v'; + buf[1] = '3'; + buf[2] = 0; + + for (i = 0; i < 2; i++) { + /* bug is: following line passes wild pointer to use() on sh4 -O2 */ + result = use(item[i]); + + use(buf); + use(a); + use(b); + result = use(result); + } + return result; +} + +int main() +{ + func("v4", "v5"); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr103961.c b/SingleSource/Regression/C/gcc-dg/pr103961.c new file mode 100644 index 0000000000..2cd52884e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr103961.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern void abort (); + +extern inline __attribute__ ((__gnu_inline__)) int +sprintf (char *restrict s, const char *restrict fmt, ...) +{ + return __builtin___sprintf_chk (s, 1, __builtin_object_size (s, 1), + fmt, __builtin_va_arg_pack ()); +} + +void +cap_to_text (int c) +{ + char buf[1572]; + char *p; + int n, t; + p = 20 + buf; + for (t = 8; t--; ) + { + for (n = 0; n < c; n++) + p += sprintf (p, "a,"); + p--; + if (__builtin_object_size (p, 1) == 0) + abort (); + } +} + +/* { dg-final { scan-assembler-not "abort" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104198.c b/SingleSource/Regression/C/gcc-dg/pr104198.c new file mode 100644 index 0000000000..de86f49c9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104198.c @@ -0,0 +1,37 @@ +/* Make sure if conversion for two instructions does not break + anything (if it runs). */ + +/* { dg-do run } */ +/* { dg-options "-O2 -std=c99" } */ +/* { dg-require-effective-target int32plus } */ + +#include +#include + +__attribute__ ((noinline)) +int foo (int *a, int n) +{ + int min = 999999; + int bla = 0; + for (int i = 0; i < n; i++) + { + if (a[i] < min) + { + min = a[i]; + bla = 1; + } + } + + if (bla) + min += 1; + return min; +} + +int main() +{ + int a[] = {2, 1, -13, INT_MAX, INT_MIN, 0}; + + int res = foo (a, sizeof (a) / sizeof (a[0])); + + assert (res == (INT_MIN + 1)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104263.c b/SingleSource/Regression/C/gcc-dg/pr104263.c new file mode 100644 index 0000000000..79b548c629 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104263.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/104263 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug -fnon-call-exceptions -fno-inline-small-functions" } */ + +int n; + +int +bar (void) +{ + int a; + + n = 0; + a = 0; + + return n; +} + +__attribute__ ((pure, returns_twice)) int +foo (void) +{ + n = bar () + 1; + foo (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104288.c b/SingleSource/Regression/C/gcc-dg/pr104288.c new file mode 100644 index 0000000000..95eb196f9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104288.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" { keeps_null_pointer_checks } } */ + +void keep(int result) __attribute__((noipa)); +void keep(int result) +{ + if (result) + __builtin_exit(0); +} + +void foo (void *p) __attribute__((nonnull(1))); + +void bar (void *p) +{ + keep (p == 0); + foo (p); + if (!p) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "abort" "evrp" } } */ +/* { dg-final { scan-tree-dump-times "== 0B;" 1 "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104380.c b/SingleSource/Regression/C/gcc-dg/pr104380.c new file mode 100644 index 0000000000..54b2a87cf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104380.c @@ -0,0 +1,32 @@ +/* PR target/104380 */ +/* This test needs runtime that provides __*_chk functions. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -std=c99" } */ + +#define FORTIFY_SOURCE 2 +#include +#include + +static char buf[4096]; +static char gfmt[] = "%Lg"; + +static int __attribute__ ((noipa)) +foo (char *str, const char *fmt, ...) +{ + int ret; + va_list ap; + va_start (ap, fmt); + ret = vsnprintf (str, 4096, fmt, ap); + va_end (ap); + return ret; +} + +int +main () +{ + long double dval = 128.0L; + int ret = foo (buf, gfmt, dval); + if (ret != 3 || __builtin_strcmp (buf, "128") != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104381.c b/SingleSource/Regression/C/gcc-dg/pr104381.c new file mode 100644 index 0000000000..a3aec919be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104381.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -gtoggle -fdump-tree-optimized" } */ + +int foo (int x) +{ + int tem = x + 1; + int tem2 = tem - 1; + return tem2; +} + +int +__attribute__((optimize("no-tree-pre"))) +bar (int x) +{ + int tem = x + 1; + int tem2 = tem - 1; + return tem2; +} + +// { dg-final { scan-tree-dump-not "DEBUG " "optimized" } } diff --git a/SingleSource/Regression/C/gcc-dg/pr104389.c b/SingleSource/Regression/C/gcc-dg/pr104389.c new file mode 100644 index 0000000000..0c6c85a4f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104389.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/104389 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target inf } */ + +__attribute__((noipa)) double +foo (void) +{ + double a = __builtin_huge_val (); + return a * 0.0; +} + +__attribute__((noipa)) long double +bar (void) +{ + return __builtin_huge_vall () * 0.0L; +} + +int +main () +{ + if (!__builtin_isnan (foo ()) || !__builtin_isnanl (bar ())) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104420-1.c b/SingleSource/Regression/C/gcc-dg/pr104420-1.c new file mode 100644 index 0000000000..48385fae0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104420-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options ieee } */ + +double f(int a) +{ + return a * 0.0; +} + +/* { dg-final { scan-tree-dump " \\\* 0.0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104420-2.c b/SingleSource/Regression/C/gcc-dg/pr104420-2.c new file mode 100644 index 0000000000..49d0189672 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104420-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options ieee } */ + +double f(int a) +{ + return a * -0.0; +} + +/* { dg-final { scan-tree-dump " \\\* -0.0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104420-3.c b/SingleSource/Regression/C/gcc-dg/pr104420-3.c new file mode 100644 index 0000000000..962dfff9cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104420-3.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options ieee } */ + +double f(unsigned int a) +{ + return a * 0.0; +} + +/* { dg-final { scan-tree-dump "return 0.0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104420-4.c b/SingleSource/Regression/C/gcc-dg/pr104420-4.c new file mode 100644 index 0000000000..95ed0cc18d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104420-4.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options ieee } */ + +double f(unsigned int a) +{ + return a * -0.0; +} + +/* { dg-final { scan-tree-dump "return -0.0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104427.c b/SingleSource/Regression/C/gcc-dg/pr104427.c new file mode 100644 index 0000000000..397cb13b66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104427.c @@ -0,0 +1,13 @@ +/* PR c/104427 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Float16 x, y; + +int +foo () +{ + return __builtin_assoc_barrier (x + y) - y; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104459.c b/SingleSource/Regression/C/gcc-dg/pr104459.c new file mode 100644 index 0000000000..de8a643d9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104459.c @@ -0,0 +1,38 @@ +/* PR rtl-optimization/104459 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fno-tree-dce -fcompare-debug -w" } */ + +void +foo (int x, int y) +{ + unsigned int a; + + for (;;) + { + short int *p = (short int *) &x; + unsigned int q = 0; + + a /= 2; + if (a) + { + q -= y; + while (q) + ; + } + + if (x) + { + for (q = 0; q != 1; q += 2) + { + unsigned int n; + + n = *p ? 0 : q; + y += n < 1; + + n = a || *p; + if (n % x == 0) + y /= x; + } + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104464.c b/SingleSource/Regression/C/gcc-dg/pr104464.c new file mode 100644 index 0000000000..d36a28678c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104464.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fnon-call-exceptions -fno-tree-dce -fno-tree-forwprop -fsignaling-nans" } */ + +typedef double __attribute__((__vector_size__(16))) F; +F f; + +void +foo(void) +{ + f += (F)(f != (F){}[0]); +} + +/* { dg-xfail-if "-fnon-call-exceptions unsupported" { amdgcn-*-* } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104506-1.c b/SingleSource/Regression/C/gcc-dg/pr104506-1.c new file mode 100644 index 0000000000..5eb71911b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104506-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ +/* PR c/104506: we used to ICE after the error of + changing the type. */ + +void +foo (double x) +/* { dg-message "note: previous definition" "previous definition" { target *-*-* } .-1 } */ +{ + (void)x; + int x; /* { dg-error "redeclared as different kind of symbol" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104506-2.c b/SingleSource/Regression/C/gcc-dg/pr104506-2.c new file mode 100644 index 0000000000..3c3aaaac4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104506-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ +/* PR c/104506: we used to ICE after the error of + changing the type. */ +void +foo (double x) +/* { dg-message "note: previous definition" "previous definition" { target *-*-* } .-1 } */ +{ + x; + int x; /* { dg-error "redeclared as different kind of symbol" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104506-3.c b/SingleSource/Regression/C/gcc-dg/pr104506-3.c new file mode 100644 index 0000000000..b14deb5cf2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104506-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* PR c/104506: we used to ICE after the error of + changing the type. */ +double x; +/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */ +void +foo (void) +{ + x; +} +int x; /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104511.c b/SingleSource/Regression/C/gcc-dg/pr104511.c new file mode 100644 index 0000000000..ad5430c67c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104511.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target dfp } } */ +/* { dg-options "-O -Wno-psabi" } */ + +typedef _Float64 __attribute__((__vector_size__ (32))) F; +typedef _Decimal32 __attribute__((__vector_size__ (16))) D; + +extern void bar (void); + +D g; +void +foo (F f) +{ + D d = __builtin_convertvector (f, D); + bar (); + g = d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104522.c b/SingleSource/Regression/C/gcc-dg/pr104522.c new file mode 100644 index 0000000000..4d1d6309ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104522.c @@ -0,0 +1,14 @@ +/* PR middle-end/104522 */ +/* { dg-do compile } */ +/* { dg-options "-O -fcompare-debug -dP" } */ + +typedef short __attribute__((__vector_size__(16))) V; +long double x; + +void +foo (void) +{ + V t = { 512, 0, 0, 0, 16384 }; + long double u = *(long double *) &t; + x /= u; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104526.c b/SingleSource/Regression/C/gcc-dg/pr104526.c new file mode 100644 index 0000000000..a295308290 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104526.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void foo(void); + +static int a, b = 1, *c = &b; +int main() { + for (; a; a--) { + int d = 2 >> (1 / *c); + if (!d) + foo(); + } +} + +/* { dg-final { scan-tree-dump-not "foo" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104530.c b/SingleSource/Regression/C/gcc-dg/pr104530.c new file mode 100644 index 0000000000..1ec10154e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104530.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void foo(void); + +static int a, *b = &a, c, d = 1; + +int main() { + c = 0 == b; + a = *b; + if (c % d) + for (; d; --d) + foo(); + b = 0; +} + + +/* { dg-final { scan-tree-dump-not "foo" "evrp" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr104544.c b/SingleSource/Regression/C/gcc-dg/pr104544.c new file mode 100644 index 0000000000..275b666923 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104544.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/104544 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +int m, n; +__int128 q; + +void +bar (unsigned __int128 x, int y) +{ + if (x) + q += y; +} + +void +foo (void) +{ + bar (!!q - 1, (m += m ? m : 1) < n); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104558.c b/SingleSource/Regression/C/gcc-dg/pr104558.c new file mode 100644 index 0000000000..382fe5732d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104558.c @@ -0,0 +1,15 @@ +/* PR middle-end/104558 */ +/* { dg-do compile } */ +/* { dg-options "-fabi-version=9" } */ + +struct __attribute__ ((aligned)) A {}; + +struct A a; + +void bar (int, int, int, int, int, int, int, struct A); + +void +foo (void) +{ + bar (0, 1, 2, 3, 4, 5, 6, a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104612.c b/SingleSource/Regression/C/gcc-dg/pr104612.c new file mode 100644 index 0000000000..7d055ed871 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104612.c @@ -0,0 +1,27 @@ +/* PR target/104612 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-msse2 -mfpmath=sse" { target i?86-*-* x86_64-*-* } } */ + +struct V { float x, y; }; + +struct V +foo (struct V v) +{ + struct V ret; + ret.x = __builtin_copysignf (1.0e+0, v.x); + ret.y = __builtin_copysignf (1.0e+0, v.y); + return ret; +} + +float +bar (struct V v) +{ + return __builtin_copysignf (v.x, v.y); +} + +float +baz (struct V v) +{ + return v.x * __builtin_copysignf (1.0f, v.y); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104644.c b/SingleSource/Regression/C/gcc-dg/pr104644.c new file mode 100644 index 0000000000..70bf3a4964 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104644.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/104644 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-overflow" } */ + +int +foo (void) +{ + return __builtin_bswap16 (1.31072e+5f) != (signed char) 1.31072e+5f; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104675-1.c b/SingleSource/Regression/C/gcc-dg/pr104675-1.c new file mode 100644 index 0000000000..af0b4390c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104675-1.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/104675 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +_Complex int +foo (_Complex int a) +{ + return (-1 + -1i) - a; +} + +_Complex int +bar (_Complex int a) +{ + return -a - (1 + 1i); +} + +_Complex int +baz (_Complex int a) +{ + _Complex int b = -1 + -1i; + return b - a; +} + +_Complex int +qux (_Complex int a) +{ + _Complex int b = 1 + 1i; + return -a - b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104675-2.c b/SingleSource/Regression/C/gcc-dg/pr104675-2.c new file mode 100644 index 0000000000..037d0c4f10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104675-2.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/104675 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void baz (int i); + +void +bar (_Complex int c, short s) +{ + c -= s; + baz (__real__ c + __imag__ c); +} + +void +foo (void) +{ + bar (-1 - 1i, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104675-3.c b/SingleSource/Regression/C/gcc-dg/pr104675-3.c new file mode 100644 index 0000000000..3b2eb64940 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104675-3.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/104675 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +_Complex unsigned int +foo (_Complex unsigned int x) +{ + return (x / 2) * 2; +} + +_Complex unsigned int +bar (_Complex unsigned int x) +{ + return (x * 2) / 2; +} + +_Complex unsigned int +baz (_Complex unsigned int x) +{ + _Complex unsigned int y = x / 2; + return y * 2; +} + +_Complex unsigned int +qux (_Complex unsigned int x) +{ + _Complex unsigned int y = x * 2; + return y / 2; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104700-2.c b/SingleSource/Regression/C/gcc-dg/pr104700-2.c new file mode 100644 index 0000000000..e0759cca70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104700-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-ccp -fno-tree-dce -fno-tree-vrp" } */ + +int a, b; +int main() { + int c = 2, d, e = 0; + if (a) + e = 2; + int f, g = -(1L | (e && f && f & e)); + if (g) + L: + g = c; + c = 0; + d = e * g; + if (d) + goto L; + while (e) { + int i = (a && b) * i; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr10474.c b/SingleSource/Regression/C/gcc-dg/pr10474.c new file mode 100644 index 0000000000..a4af536ec2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr10474.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target { { { i?86-*-* x86_64-*-* } && lp64 } || { { powerpc*-*-* && lp64 } || { arm_nothumb || { aarch64*-*-* && lp64 } } } } } } */ +/* { dg-options "-O3 -fdump-rtl-pro_and_epilogue" } */ + +void f(int *i) +{ + if (!i) + return; + else + { + __builtin_printf("Hi"); + *i=0; + } +} + +/* XFAIL due to PR70681. */ +/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" { xfail arm*-*-* powerpc*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr104786.c b/SingleSource/Regression/C/gcc-dg/pr104786.c new file mode 100644 index 0000000000..3076d236d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104786.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90" } */ + +void h(void *di, int num) +{ + char (*t)[num] = di; + __asm__ ("" : "=X"( *t)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104910.c b/SingleSource/Regression/C/gcc-dg/pr104910.c new file mode 100644 index 0000000000..10fed8147d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104910.c @@ -0,0 +1,14 @@ +/* PR target/104910 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-forward-propagate" } */ +/* { dg-additional-options "-fstack-protector-all" { target fstack_protector } } */ + +void +bar (void); + +void +foo (int x) +{ + if (x) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104975.c b/SingleSource/Regression/C/gcc-dg/pr104975.c new file mode 100644 index 0000000000..04532fc444 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104975.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fharden-compares -fno-inline -fno-ipa-pure-const" } */ + +__attribute__ ((pure, returns_twice)) int +bar (int); + +int +quux (void) +{ + return 0; +} + +int +foo (short int x) +{ + x = !x; + bar (quux ()); + + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr104992.c b/SingleSource/Regression/C/gcc-dg/pr104992.c new file mode 100644 index 0000000000..82f8c75559 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr104992.c @@ -0,0 +1,58 @@ +/* PR tree-optimization/104992 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi -fdump-tree-optimized" } */ + +#define vector __attribute__((vector_size(4*sizeof(int)))) + +/* Form from PR. */ +__attribute__((noipa)) unsigned foo(unsigned x, unsigned y) +{ + return x / y * y == x; +} + +__attribute__((noipa)) unsigned bar(unsigned x, unsigned y) { + return x == x / y * y; +} + +/* Signed test case. */ +__attribute__((noipa)) unsigned baz (int x, int y) { + return x / y * y == x; +} + +/* Changed order. */ +__attribute__((noipa)) unsigned qux (unsigned x, unsigned y) { + return y * (x / y) == x; +} + +/* Test for forward propogation. */ +__attribute__((noipa)) unsigned corge(unsigned x, unsigned y) { + int z = x / y; + int q = z * y; + return q == x; +} + +/* Test vector case. */ +__attribute__((noipa)) vector int thud(vector int x, vector int y) { + return x / y * y == x; +} + +/* Complex type should not simplify because mod is different. */ +__attribute__((noipa)) int goo(_Complex int x, _Complex int y) +{ + _Complex int z = x / y; + _Complex int q = z * y; + return q == x; +} + +/* Wrong order. */ +__attribute__((noipa)) unsigned fred (unsigned x, unsigned y) { + return y * x / y == x; +} + +/* Wrong pattern. */ +__attribute__((noipa)) unsigned waldo (unsigned x, unsigned y, unsigned z) { + return x / y * z == x; +} + +/* { dg-final { scan-tree-dump-times " % " 9 "optimized" { target { ! vect_int_mod } } } } */ +/* { dg-final { scan-tree-dump-times " % " 6 "optimized" { target vect_int_mod } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr105049.c b/SingleSource/Regression/C/gcc-dg/pr105049.c new file mode 100644 index 0000000000..b0518c6a18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105049.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-forwprop" } */ + +typedef short __attribute__((__vector_size__ (sizeof(short)))) V; +typedef short __attribute__((__vector_size__ (2*sizeof(short)))) U; +char c; + +U +foo (void) +{ + return __builtin_shufflevector ((V){}, (V){}, 0, 0) & c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105065.c b/SingleSource/Regression/C/gcc-dg/pr105065.c new file mode 100644 index 0000000000..da46d2bb4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105065.c @@ -0,0 +1,16 @@ +/* PR middle-end/105065 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef struct +{ + char filler[17]; +} big_struct; + +big_struct dummy(int size, char array[size]); + +int main() +{ + dummy(0, 0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr105080.c b/SingleSource/Regression/C/gcc-dg/pr105080.c new file mode 100644 index 0000000000..77ee7eeb39 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105080.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wall" } */ + +int main() +{ + char foo[3]; + int i; + + for (i = 0; i < 16; i++) + __builtin_snprintf(foo, sizeof(foo), "%d", i); /* { dg-bogus "truncated" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105094.c b/SingleSource/Regression/C/gcc-dg/pr105094.c new file mode 100644 index 0000000000..da6dc172a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105094.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/105094 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct S { short a; char b[~(__SIZE_TYPE__)0 / __CHAR_BIT__ - 1]; }; +void bar (struct S *); + +void +foo (void) +{ + struct S s = { 5 }; + bar (&s); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105140.c b/SingleSource/Regression/C/gcc-dg/pr105140.c new file mode 100644 index 0000000000..7d30985e85 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105140.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -w -Wno-psabi" } */ +/* { dg-skip-if "PR105147" { powerpc*-*-* s390*-*-* } } */ + +typedef char __attribute__((__vector_size__ (16 * sizeof (char)))) U; +typedef int __attribute__((__vector_size__ (16 * sizeof (int)))) V; + +void bar (); + +bar (int i, int j, int k, V v) +{ +} + +void +foo (void) +{ + bar ((V){}, (V){}, (V){}, (U){}); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105149.c b/SingleSource/Regression/C/gcc-dg/pr105149.c new file mode 100644 index 0000000000..b748f454d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105149.c @@ -0,0 +1,16 @@ +/* PR c/105149 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +void +foo (int s, ...) +{ + int e; + va_list ap; + + va_start (ap, s); + e = va_arg (ap, int (void)) (); /* { dg-error "second argument to 'va_arg' is a function type" } */ + va_end (ap); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105150.c b/SingleSource/Regression/C/gcc-dg/pr105150.c new file mode 100644 index 0000000000..900460c155 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105150.c @@ -0,0 +1,8 @@ +/* PR tree-optimization/105150 */ +/* { dg-options "-w -Ofast" } */ + +#define A(name) __typeof (__builtin_##name (0)) name (); \ + float name##1 () { return !name (1); } \ + double name##2 () { return name (1.0L); } +#define B(name) A(name) A(name##l) +B (sqrt) diff --git a/SingleSource/Regression/C/gcc-dg/pr105165.c b/SingleSource/Regression/C/gcc-dg/pr105165.c new file mode 100644 index 0000000000..055a10528b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105165.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +unsigned int _Complex a0; +unsigned int _Complex +foo (unsigned int _Complex a1, unsigned int _Complex a2) +{ + unsigned int _Complex x; + asm goto ("" : "=r" (x) : : : lab); /* { dg-message "sorry, unimplemented" } */ + a0 = x; + lab: + return x + a1 + a2 + 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105173.c b/SingleSource/Regression/C/gcc-dg/pr105173.c new file mode 100644 index 0000000000..3effb2996b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105173.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target dfp } } */ +/* { dg-options "-Ofast" } */ + +int i; + +int +foo(char c, _Decimal32 d) +{ + d *= i; + d *= -(_Decimal64)c; + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105175.c b/SingleSource/Regression/C/gcc-dg/pr105175.c new file mode 100644 index 0000000000..d8d7edb942 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105175.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wvector-operation-performance" } */ +/* { dg-additional-options "-mno-sse" { target x86_64-*-* i?86-*-* } } */ + +enum { QEMU_MIGRATION_COOKIE_PERSISTENT = 1 }; +struct { + unsigned flags; + unsigned flagsMandatory; +} qemuMigrationCookieGetPersistent_mig; +void qemuMigrationCookieGetPersistent() +{ + qemuMigrationCookieGetPersistent_mig.flags &= /* { dg-bogus "will be expanded" } */ + QEMU_MIGRATION_COOKIE_PERSISTENT; + qemuMigrationCookieGetPersistent_mig.flagsMandatory &= + QEMU_MIGRATION_COOKIE_PERSISTENT; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105211.c b/SingleSource/Regression/C/gcc-dg/pr105211.c new file mode 100644 index 0000000000..9bafe6feb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105211.c @@ -0,0 +1,11 @@ +/* PR rtl-optimization/105211 */ +/* { dg-do compile } */ +/* { dg-options "-Os -ffast-math" } */ +/* { dg-add-options float32 } */ +/* { dg-require-effective-target float32 } */ + +short +foo (_Float32 f) +{ + return __builtin_roundf (f); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105218.c b/SingleSource/Regression/C/gcc-dg/pr105218.c new file mode 100644 index 0000000000..0070057c32 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105218.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/105218 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +int a, c; +void bar (void); + +void +foo (void) +{ + int b = 131; + if (a) + b = c == 2 ? 1 : c; + while (b) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105226.c b/SingleSource/Regression/C/gcc-dg/pr105226.c new file mode 100644 index 0000000000..9c4941dc6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105226.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include +struct longjmp_buf { + jmp_buf buf; +}; +void g (); +void f () +{ + int i, n; + long *a; + long *args; + struct longjmp_buf b; + setjmp (b.buf); + for (;;) + { + for (i = 0; i < n; i++) + a[i] = args[i]; + g (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105250.c b/SingleSource/Regression/C/gcc-dg/pr105250.c new file mode 100644 index 0000000000..4683e0e63a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105250.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-w -Wno-psabi -O2" } */ +/* { dg-skip-if "PR105266" { powerpc*-*-* s390*-*-* } } */ + +typedef int __attribute__((__vector_size__(4))) T; +typedef int __attribute__((__vector_size__(8))) U; +typedef int __attribute__((__vector_size__(16))) V; +typedef int __attribute__((__vector_size__(32))) W; +typedef _Float32 __attribute__((__vector_size__(16))) F; +typedef _Float64 __attribute__((__vector_size__(32))) G; +void foo(); + +foo(int, int, int, int, U, U, V, V, W, W, int, + T, int, U, U, V, V, W, W, T, + T, int, U, U, V, V, W, W, T, + T, int, W, W, T, T, int, int, int, + int, int, int, W, int, int, int, int, int, int, + V, W, T, int, int, U, F, int, int, int, + int, int, int, G) +{ + foo(0, 0, 0, 0, (U){}, (U){}, (V){}, (V){}, (W){}, + (W){}, 2, (T){}, 0, 0, 0, 0, (U){}, (U){}, + (V){}, (V){}, (W){}, (W){}, (T){}, + (T){}, 0, 0, 0, 0, (U){}, (U){}, (V){}, + (V){}, (W){}, (W){}, (T){}, (T){}, 0, 0, 0, + 0, 0, 0, (T){}, + (T){}, (W){}, + (W){}, (T){}, (T){}, 0, 0, 0, 0, 0, 0, (W){}, + (V){}, (W){}, (T){}, 0, 0, (U){}, (F){}); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105257.c b/SingleSource/Regression/C/gcc-dg/pr105257.c new file mode 100644 index 0000000000..4232942d79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105257.c @@ -0,0 +1,16 @@ +/* PR target/105257 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ + +extern int sigsetjmp (void **, int); +void *buf[32]; +void (*fn) (void); + +const char * +bar (void) +{ + sigsetjmp (buf, 0); + fn (); + return ""; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105263.c b/SingleSource/Regression/C/gcc-dg/pr105263.c new file mode 100644 index 0000000000..5cb7fcd09a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105263.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target dfp } } */ +/* { dg-options "-O -ffast-math -w -Wno-psabi" } */ + +typedef _Decimal64 __attribute__((__vector_size__ (8))) U; +typedef _Decimal64 __attribute__((__vector_size__ (16))) V; + +V v; + +U +foo (U u) +{ + u *= u; + u *= -(U){ v[1] }; + return u; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105331.c b/SingleSource/Regression/C/gcc-dg/pr105331.c new file mode 100644 index 0000000000..06cf6d6d90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105331.c @@ -0,0 +1,11 @@ +/* PR target/105331 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +#include + +int +foo (va_list *va) +{ + return va_arg (*va, double _Complex); /* { dg-bogus "may be used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105333.c b/SingleSource/Regression/C/gcc-dg/pr105333.c new file mode 100644 index 0000000000..bd8bd4cd56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105333.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/105333 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Og -fno-tree-coalesce-vars -fno-tree-fre" } */ + +int g; +short s; + +static inline unsigned short +bar (short a, __int128 b) +{ + b ^= (unsigned long) -a; + __builtin_strncpy ((void *) &s, (void *) &a, 1); + b *= 14; + return b; +} + +void +foo (void) +{ + g *= (__int128) bar (1, 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105376.c b/SingleSource/Regression/C/gcc-dg/pr105376.c new file mode 100644 index 0000000000..f19ecf4aab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105376.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target dfp } } */ +/* { dg-options "-O -g" } */ + +void +foo (_Decimal64 d, _Decimal64 e) +{ + d -= -d; + d *= -e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105414.c b/SingleSource/Regression/C/gcc-dg/pr105414.c new file mode 100644 index 0000000000..78772700ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105414.c @@ -0,0 +1,30 @@ +/* { dg-do run { target { *-*-linux* *-*-gnu* } } } */ +/* { dg-options "-O1 -fsignaling-nans -lm" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target issignaling } */ + + +#define _GNU_SOURCE +#include +#include + +int main() +{ + double a = __builtin_nans (""); + + if (issignaling (fmin (a, a))) + __builtin_abort (); + + if (issignaling (fmax (a, a))) + __builtin_abort (); + + double b = __builtin_nan (""); + + if (issignaling (fmin (a, b))) + __builtin_abort (); + + if (issignaling (fmax (a, b))) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105415.c b/SingleSource/Regression/C/gcc-dg/pr105415.c new file mode 100644 index 0000000000..4603c0cb6e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105415.c @@ -0,0 +1,26 @@ +/* PR debug/105415 */ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fcompare-debug" } */ + +int m; +static int n; + +void +foo (void) +{ + int s = 0; + + while (m < 1) + { + s += n; + ++m; + } +} + +void +bar (int *arr, int i) +{ + while (i < 1) + arr[i++] = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105455.c b/SingleSource/Regression/C/gcc-dg/pr105455.c new file mode 100644 index 0000000000..81e9154baa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105455.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fharden-conditional-branches -funroll-loops --param max-loop-header-insns=1" } */ + +__attribute__ ((cold)) void +bar (void); + +void +foo (int x) +{ + if (x) + { + int i; + + for (i = 0; i < 101; ++i) + bar (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105458.c b/SingleSource/Regression/C/gcc-dg/pr105458.c new file mode 100644 index 0000000000..eb58bf21f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105458.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/105458 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fexpensive-optimizations -fno-tree-dominator-opts " } */ + +void +yj (int j4) +{ + int t3; + + for (t3 = 0; t3 < 6; ++t3) + { + short int v4 = t3; + + if (v4 == j4 || v4 > t3) + for (;;) + { + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr105461.c b/SingleSource/Regression/C/gcc-dg/pr105461.c new file mode 100644 index 0000000000..1e6743ccac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105461.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fassociative-math -fsignaling-nans -fvar-tracking -w" } */ + +int +bar (float *x, int y) +{ + *x = y; + + return *x; +} + +__attribute__ ((optimize ("O2"))) void +foo (float *x, int y) +{ + int a = bar (x, y); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105528.c b/SingleSource/Regression/C/gcc-dg/pr105528.c new file mode 100644 index 0000000000..e380d56ee0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105528.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/105528 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi -fcompare-debug" } */ +/* { dg-additional-options "-mavx512f" { target i?86-*-* x86_64-*-* } } */ + +typedef unsigned V __attribute__((__vector_size__ (64))); +V g; + +V +bar (V v) +{ + V w; + v <<= (V){(V){}[53]} >= v & 5; + w[w[5]] -= ~0; + v %= ~0; + return v + w; +} + +void +foo (void) +{ + g -= (V){bar((V){~0})[3]}; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105591.c b/SingleSource/Regression/C/gcc-dg/pr105591.c new file mode 100644 index 0000000000..9554c42e2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105591.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-psabi -O" } */ +/* { dg-additional-options "-mavx" { target x86_64-*-* i?86-*-* } } */ +typedef unsigned long long __attribute__((__vector_size__ (16))) U; +typedef unsigned long long __attribute__((__vector_size__ (32))) V; + +V +foo (U u) +{ + U x = __builtin_shuffle (u, (U) { 0xBE2ED0AB630B33FE }); + return __builtin_shufflevector (u, x, 2, 1, 0, 3); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105597.c b/SingleSource/Regression/C/gcc-dg/pr105597.c new file mode 100644 index 0000000000..e463ec6c19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105597.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/105597 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-int-conversion" } */ + +typedef struct { + int allocated; +} vvec; + +int vvneeds_want, mgpssort; + +void vvinit(vvec *v, int minelems) { v->allocated = -minelems; } + +void vvneeds(vvec *v, int needed) { + if (needed > v->allocated) + if (v->allocated < 0) + ; + else { + int next = v->allocated + (v->allocated >> 1); + vvneeds_want = next; + } +} + +void mgpssort_1() { + vvinit((vvec *) &mgpssort, mgpssort_1); + vvneeds((vvec *) &mgpssort, mgpssort_1); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr105630.c b/SingleSource/Regression/C/gcc-dg/pr105630.c new file mode 100644 index 0000000000..c39ca7dda2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105630.c @@ -0,0 +1,22 @@ +/* PR debug/105630 */ +/* { dg-do compile { target pthread } } */ +/* { dg-options "-O1 -ftree-parallelize-loops=2 -fcompare-debug" } */ + +int m; +static int n; + +void +foo (void) +{ + int *arr[] = { &n, &n, &n }; + int unused = n; + + m = 0; +} + +void +bar (int *arr, int i) +{ + while (i < 1) + arr[i++] = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105635.c b/SingleSource/Regression/C/gcc-dg/pr105635.c new file mode 100644 index 0000000000..aa02f593bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105635.c @@ -0,0 +1,11 @@ +/* PR c/105635 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +void foo (int, int[*]); /* { dg-message "previous declaration of 'foo' with type" } */ + +foo (int x, int y) /* { dg-warning "return type defaults to 'int'" } */ +{ /* { dg-warning "conflicting types for 'foo'" "" { target *-*-* } .-1 } */ + /* { dg-message "declared here" "" { target *-*-* } .-2 } */ + return (x >= 0) != (y < 0); /* { dg-warning "'return' with a value, in function returning void" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105660-1.c b/SingleSource/Regression/C/gcc-dg/pr105660-1.c new file mode 100644 index 0000000000..d4454f04c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105660-1.c @@ -0,0 +1,13 @@ +/* PR105660 + * { dg-do compile } + * { dg-options "-std=c17" } + */ + +void gatherConservativeVars(int, int, int, int, int, int, int Hnvar, int, + int Hnyt, int Hnxyt, int, int Hstep, double[Hnyt], + double[Hnvar][Hstep][Hnxyt]); +void gatherConservativeVars(int, int, int, int, int, int, int Hnvar, int, int Hnyt, + int Hnxyt, int, int Hstep, double[Hnyt], + double[Hnvar][Hstep][Hnxyt]); + + diff --git a/SingleSource/Regression/C/gcc-dg/pr105660-2.c b/SingleSource/Regression/C/gcc-dg/pr105660-2.c new file mode 100644 index 0000000000..29fd82f923 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105660-2.c @@ -0,0 +1,12 @@ +/* PR105660 + * { dg-do compile } + * { dg-options "-Wall -std=c17" } + */ + + +struct bat_gen_conf_s; +void batch_generator_create2(struct bat_gen_conf_s* config, int D, int N, const long bat_dims[D][N], const long tot_dims[D][N], const long tot_strs[D][N], const _Complex float* data[D]); +void batch_generator_create2(struct bat_gen_conf_s* config, int D, int N, const long bat_dims[D][N], const long tot_dims[D][N], const long tot_strs[D][N], const _Complex float* data[D]); + + + diff --git a/SingleSource/Regression/C/gcc-dg/pr105676.c b/SingleSource/Regression/C/gcc-dg/pr105676.c new file mode 100644 index 0000000000..077fc18a17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105676.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wsuggest-attribute=pure" } */ + +__attribute__((const)) +extern int do_expensive_calculation(void); + +__attribute__((const)) +int getval(void) /* { dg-bogus "candidate for attribute" } */ +{ + static int cache = -1; + if (cache == -1) + cache = do_expensive_calculation(); + return cache; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105763.c b/SingleSource/Regression/C/gcc-dg/pr105763.c new file mode 100644 index 0000000000..4c76b17e73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105763.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int rl2_decode_png_bit_depth; +int *rl2_decode_png_p_data; +void png_destroy_read_struct (); +int __attribute__((returns_twice)) _setjmp (); +void rl2_decode_png_row_pointers() +{ + unsigned sample_type = 0; + _setjmp(); + switch (rl2_decode_png_bit_depth) + case 6: + sample_type = 7; + png_destroy_read_struct(); + for (;;) + switch (sample_type) + case 3: + case 5: + *rl2_decode_png_p_data; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105770.c b/SingleSource/Regression/C/gcc-dg/pr105770.c new file mode 100644 index 0000000000..c1e0140292 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105770.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/105770 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -funswitch-loops -fno-tree-forwprop" } */ + +char a; + +void +foo (void) +{ + while (a) + switch (a) + { + case ' ': + case '\t': + return; + } + + __builtin_unreachable (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105825.c b/SingleSource/Regression/C/gcc-dg/pr105825.c new file mode 100644 index 0000000000..d1eb829653 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105825.c @@ -0,0 +1,13 @@ +/* PR target/105825 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mavx" { target avx } } */ + +__int128 j; +int i; + +void +foo (void) +{ + j <<= __builtin_parityll (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105835.c b/SingleSource/Regression/C/gcc-dg/pr105835.c new file mode 100644 index 0000000000..354c81c672 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105835.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +void foo(); + +static int b; + +static short a(short c, unsigned short d) { return c - d; } + +int main() { + int e = -(0 < b); + if (a(1, e)) + b = 0; + else + foo(); +} + +/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr105853.c b/SingleSource/Regression/C/gcc-dg/pr105853.c new file mode 100644 index 0000000000..4f234ac11d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105853.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct { + struct { + short e16[3]; + } +} const eth_addr_zero = {{}}; /* { dg-warning "no semicolon at" } */ +void compose_nd_na_ipv6_src() { + packet_set_nd(eth_addr_zero); /* { dg-warning "implicit declaration" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105856.c b/SingleSource/Regression/C/gcc-dg/pr105856.c new file mode 100644 index 0000000000..dd3aa2f18c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105856.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +#pragma pack(1) +struct { + unsigned f0; +} static g_251 = {6}; +void g_329_3() { + func_19(g_251); /* { dg-warning "implicit declaration" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr105911.c b/SingleSource/Regression/C/gcc-dg/pr105911.c new file mode 100644 index 0000000000..55df3f15af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105911.c @@ -0,0 +1,16 @@ +/* PR target/105911 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2" } */ + +__int128 v, x; +unsigned __int128 w; + +void bar (__int128, __int128); + +void +foo (void) +{ + bar (v /= v, v >> (v &= 0x100000001)); + bar (w /= w, w >> (w &= 0x300000003)); + bar (x /= x, x << (x &= 0x700000007)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105969.c b/SingleSource/Regression/C/gcc-dg/pr105969.c new file mode 100644 index 0000000000..52c63fc2ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105969.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +struct A +{ + char a[0][0][0]; +}; +extern struct A b[][2]; +void f (void) +{ + __builtin_sprintf (b[0][0].a[1][0], "%s", b[0][0].a[1][0]); /* { dg-warning "past the end" } */ + /* { dg-warning "overlaps destination" "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr105972.c b/SingleSource/Regression/C/gcc-dg/pr105972.c new file mode 100644 index 0000000000..73f3385f7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr105972.c @@ -0,0 +1,15 @@ +/* PR c/105972 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +__attribute__((optimize (0))) int +foo (void) +{ + int + bar (x) + int x; + { + return x; + } + return bar (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106027.c b/SingleSource/Regression/C/gcc-dg/pr106027.c new file mode 100644 index 0000000000..735205fb25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106027.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int +foo (unsigned int x, int y) +{ + return x <= (((y != y) < 0) ? y < 1 : 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106061.c b/SingleSource/Regression/C/gcc-dg/pr106061.c new file mode 100644 index 0000000000..bba8d29bf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106061.c @@ -0,0 +1,18 @@ +/* PR ipa/106061 */ +/* { dg-do compile } */ +/* { dg-options "-Og" } */ + +extern void foo (void); + +inline void +bar (int x) +{ + if (x) + foo (); +} + +void +baz (void) +{ + bar (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106063.c b/SingleSource/Regression/C/gcc-dg/pr106063.c new file mode 100644 index 0000000000..467b31dea6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106063.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fno-tree-forwprop --disable-tree-evrp" } */ +typedef __int128 __attribute__((__vector_size__ (16))) V; + +V +foo (V v) +{ + return (v & (V){15}) == v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106099.c b/SingleSource/Regression/C/gcc-dg/pr106099.c new file mode 100644 index 0000000000..01b11442b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106099.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/106099 */ +/* { dg-do compile } */ +/* { dg-options "-O -fharden-compares -fno-tree-forwprop -fno-tree-ch -fno-tree-dominator-opts -fno-tree-ccp -funreachable-traps --param=scev-max-expr-size=1" } */ + +void +foo (void) +{ + for (unsigned i = 0; i == 0; i++) + __builtin_printf ("%d", i); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106114.c b/SingleSource/Regression/C/gcc-dg/pr106114.c new file mode 100644 index 0000000000..64c8b8d390 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106114.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-dom2" } */ + +int printf(const char *, ...); +char a = 139, b; +int main() { + char c = 173; + b = a; + while (c <= a || a < -117) + c = printf("0\n"); + return 0; +} + +/* { dg-final { scan-tree-dump-times "if" 2 "dom2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr106189.c b/SingleSource/Regression/C/gcc-dg/pr106189.c new file mode 100644 index 0000000000..0eca8343c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106189.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds=2 -w" } */ + +int a_n_0_0_a[][0]; +void a_n_0_0() { T(((char *)a_n_0_0_a)[1]); } diff --git a/SingleSource/Regression/C/gcc-dg/pr106198.c b/SingleSource/Regression/C/gcc-dg/pr106198.c new file mode 100644 index 0000000000..00d2758efa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106198.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int printf(const char *, ...); +long a; +int b; +volatile int c; +int main() { + long e = a; + int f = a; + L: + if (b > 0) { + printf("0"); + goto L; + } + if (f) { + printf("%ld", (long)b); + goto L; + } + e >= b && c; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106243-1.c b/SingleSource/Regression/C/gcc-dg/pr106243-1.c new file mode 100644 index 0000000000..cb3b74cbea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106243-1.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/106243 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-psabi" } */ + +#include "pr106243.c" + +int main () { + + if (foo(3) != 1 + || bar(-6) != 0 + || baz(17) != 1 + || qux(-128) != 0 + || foo(127) != 1) { + __builtin_abort(); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106243.c b/SingleSource/Regression/C/gcc-dg/pr106243.c new file mode 100644 index 0000000000..8a7e0bf6a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106243.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/106243 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi -fdump-tree-optimized" } */ + +#define vector __attribute__((vector_size(4*sizeof(int)))) + +/* Test from PR. */ +__attribute__((noipa)) int foo (int x) { + return -x & 1; +} + +/* Other test from PR. */ +__attribute__((noipa)) int bar (int x) { + return (0 - x) & 1; +} + +/* Forward propogation. */ +__attribute__((noipa)) int baz (int x) { + x = -x; + return x & 1; +} + +/* Commutative property. */ +__attribute__((noipa)) int qux (int x) { + return 1 & -x; +} + +/* Vector test case. */ +__attribute__((noipa)) vector int waldo (vector int x) { + return -x & 1; +} + +/* Should not simplify. */ +__attribute__((noipa)) int thud (int x) { + return -x & 2; +} + +/* Should not simplify. */ +__attribute__((noipa)) int corge (int x) { + return -x & -1; +} + +/* { dg-final {scan-tree-dump-times "-" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr106249.c b/SingleSource/Regression/C/gcc-dg/pr106249.c new file mode 100644 index 0000000000..f97b07fb4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106249.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -floop-unroll-and-jam --param unroll-jam-min-percent=0" } */ + +void +foo (double *arr) +{ + int i, j; + + for (i = 0; i < 4; ++i) + for (j = 0; j < 4; ++j) + arr[j] = 0; + + for (i = 1; i < 4; ++i) + for (j = 0; j < 4; ++j) + arr[j] = 1.0 / (i + 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106264.c b/SingleSource/Regression/C/gcc-dg/pr106264.c new file mode 100644 index 0000000000..6b4af4940b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106264.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +double frexp (double, int*); +double modf (double, double*); +double remquo (double, double, int*); + +int f (void) +{ + int y; + frexp (1.0, &y); + return y; +} + +double g (void) +{ + double y; + modf (1.0, &y); + return y; +} + +int h (void) +{ + int y; + remquo (1.0, 1.0, &y); + return y; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr106278.c b/SingleSource/Regression/C/gcc-dg/pr106278.c new file mode 100644 index 0000000000..ab312b3ecf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106278.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +void __assert_fail(); +struct a { + int b; + int c; + int d; + int : 2; +}; +int e, f; +struct a g, i; +const struct a h; +int main() { + struct a j; + g = h; + if (e) + __assert_fail(); + if (f) + j = h; + i = j; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106379-1.c b/SingleSource/Regression/C/gcc-dg/pr106379-1.c new file mode 100644 index 0000000000..7f2575e02d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106379-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-forwprop1" } */ + +_Bool foo (_Bool a, _Bool b) +{ + return !a == !b; +} + +/* { dg-final { scan-tree-dump "\[ab\]_\[0-9\]+\\(D\\) == \[ba\]_\[0-9\]+\\(D\\)" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr106397.c b/SingleSource/Regression/C/gcc-dg/pr106397.c new file mode 100644 index 0000000000..2dd04b8707 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106397.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fprefetch-loop-arrays -w --param l2-cache-size=0 --param prefetch-latency=3 -fprefetch-loop-arrays" } */ +/* { dg-additional-options "-march=i686 -msse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +int +bar (void) +{ + /* No return statement. */ +} + +__attribute__ ((simd)) int +foo (void) +{ + if (bar ()) + return 0; + + __builtin_unreachable (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106421.c b/SingleSource/Regression/C/gcc-dg/pr106421.c new file mode 100644 index 0000000000..73e522afc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106421.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int main(int argc, char **argv) +{ + __label__ loop, end; + void jmp(int c) { goto *(c ? &&loop : &&end); } +loop: + jmp(argc < 0); +end: + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr106465.c b/SingleSource/Regression/C/gcc-dg/pr106465.c new file mode 100644 index 0000000000..0c351a513a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106465.c @@ -0,0 +1,109 @@ +/* PR c/106465 + * { dg-do run } + * { dg-options "-std=gnu99" } + * */ + +int main() +{ + int n = 3; + + void* p = __builtin_malloc(sizeof(struct { char p[16]; })); + + if (!p) + return 0; + + void g1(int m, struct foo { char p[++m]; }* b) /* { dg-warning "struct" } */ + { + if (3 != m) + __builtin_abort(); + + struct foo t; + *b = t; + + if (3 != sizeof(b->p)) + __builtin_abort(); + } + + void g2(struct { char p[++n]; }* b) /* { dg-warning "anonymous struct" } */ + { + if (4 != n) + __builtin_abort(); + + typeof(*b) t; + *b = t; + + if (4 != sizeof(b->p)) + __builtin_abort(); + } + + void g2b(struct { char (*p)[++n]; }* b) /* { dg-warning "anonymous struct" } */ + { + if (5 != n) + __builtin_abort(); + + char tmp[5]; + typeof(*b) t = { &tmp }; + *b = t; + + if (5 != sizeof(*b->p)) + __builtin_abort(); + } + + if (3 != n) + __builtin_abort(); + + g1(2, p); + g2(p); + g2b(p); + n--; + + __builtin_free(p); + + if (4 != n) + __builtin_abort(); + + struct foo { char (*p)[++n]; } x; + + if (5 != n) + __builtin_abort(); + + char tmp1[5]; + x.p = &tmp1; + + struct bar { char (*p)[++n]; }; + + if (6 != n) + __builtin_abort(); + + auto struct z { char (*p)[++n]; } g3(void); + + if (7 != n) + __builtin_abort(); + + struct z g3(void) { }; + + if (7 != n) + __builtin_abort(); + + struct { char (*p)[++n]; } g4(void) { }; + + if (8 != n) + __builtin_abort(); + + __auto_type u = g3(); + + if (8 != n) + __builtin_abort(); + + char tmp2[7]; + u.p = &tmp2; + + if (5 != sizeof *x.p) + __builtin_abort(); + + if (7 != sizeof *u.p) + __builtin_abort(); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr106510.c b/SingleSource/Regression/C/gcc-dg/pr106510.c new file mode 100644 index 0000000000..24e91123f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106510.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void foo (); +void ine_ok() { + float y, x; + if (x < y || x > y || y) + foo (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr106519.c b/SingleSource/Regression/C/gcc-dg/pr106519.c new file mode 100644 index 0000000000..3d4662d8a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106519.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +int bytestart, bytemem_0_0, modlookup_l_p; + +void +modlookup_l() { + long j; + while (modlookup_l_p) + while (bytestart && j && bytemem_0_0) + j = j + 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106617.c b/SingleSource/Regression/C/gcc-dg/pr106617.c new file mode 100644 index 0000000000..4274b55f80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106617.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ + +int nr_cpu_ids; +void fc_setup_exch_mgr() { + (((((((1UL << (((0, 0) + ? ((1) + ? (((nr_cpu_ids)) ? 0 + : ((nr_cpu_ids)) & (21) ? 21 + : ((nr_cpu_ids)) ? 20 + : ((nr_cpu_ids)) & (19) ? 19 + : ((nr_cpu_ids)) ? 18 + : ((nr_cpu_ids)) & (17) ? 17 + : ((nr_cpu_ids)) ? 16 + : ((nr_cpu_ids)) & (15) ? 15 + : ((nr_cpu_ids)) ? 14 + : ((nr_cpu_ids)) & (13) ? 13 + : ((nr_cpu_ids)) ? 12 + : ((nr_cpu_ids)) & (11) ? 11 + : ((nr_cpu_ids)) ? 10 + : ((nr_cpu_ids)) & (9) ? 9 + : ((nr_cpu_ids)) ? 8 + : ((nr_cpu_ids)) & (7) ? 7 + : ((nr_cpu_ids)) ? 6 + : ((nr_cpu_ids)) & (5) ? 5 + : ((nr_cpu_ids)) ? 4 + : ((nr_cpu_ids)) & (3) + ? 3 + : ((nr_cpu_ids)-1) & 1) + : 1) + : 0) + + 1))))) & + (1UL << 2) + ? 2 + : 1)) + ); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106621.c b/SingleSource/Regression/C/gcc-dg/pr106621.c new file mode 100644 index 0000000000..0465de4f14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106621.c @@ -0,0 +1,30 @@ +/* { dg-do compile { target aarch64*-*-* } } */ +/* { dg-options "-mcpu=neoverse-v1 -O2 -fvect-cost-model=dynamic -fno-tree-scev-cprop" } */ + +int m, n; + +void +foo (unsigned int x, short int y) +{ + if (m) + for (;;) + { + ++m; + while (m < 1) + { + n += m + x; + ++m; + } + } + + for (;;) + if (y) + { + ++x; + if (x) + for (y = 0; y < 75; y += 2) + { + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr106719.c b/SingleSource/Regression/C/gcc-dg/pr106719.c new file mode 100644 index 0000000000..772bd4a2d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106719.c @@ -0,0 +1,13 @@ +/* PR debug/106719 */ +/* { dg-do compile { target sync_char_short } } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +extern short int esi, easi[2]; + +void +foo (void) +{ + short int *psi = &easi[1]; + __atomic_nand_fetch (psi, esi, 0); + psi = &easi[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106781.c b/SingleSource/Regression/C/gcc-dg/pr106781.c new file mode 100644 index 0000000000..339c28c41d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106781.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-div-by-zero" } */ + +int n; + +__attribute__ ((noinline, returns_twice)) static int +bar (int) +{ + n /= 0; + + return n; +} + +int +foo (int x) +{ + return bar (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106844.c b/SingleSource/Regression/C/gcc-dg/pr106844.c new file mode 100644 index 0000000000..df68d76f25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106844.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized --param uninit-control-dep-attempts=1" } */ + +struct { + int count; + int array[8]; +} fde_merge_v1; + +void +fde_merge_i2() { + unsigned i1; + do + while (i1 && fde_merge_v1.array[i1 - 1]) /* { dg-warning "uninitialized" } */ + i1--; + while (fde_merge_i2); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106923.c b/SingleSource/Regression/C/gcc-dg/pr106923.c new file mode 100644 index 0000000000..1c89f41881 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106923.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/106923 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -finline-small-functions -fpartial-inlining --param max-inline-insns-single=1 --param uninlined-function-insns=10000" } */ + +int n; + +int +baz (void); + +__attribute__ ((returns_twice)) int +bar (void) +{ + if (baz ()) + ++n; + + return 0; +} + +int +foo (void) +{ + return bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr106938.c b/SingleSource/Regression/C/gcc-dg/pr106938.c new file mode 100644 index 0000000000..7365a8c29f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr106938.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-ipa-pure-const -fno-tree-ccp -Wuninitialized" } */ + +int n; + +void +undefined (void); + +__attribute__ ((returns_twice)) int +zero (void) +{ + return 0; +} + +void +bar (int) +{ + int i; + + for (i = 0; i < -1; ++i) + n = 0; +} + +__attribute__ ((simd)) void +foo (void) +{ + int uninitialized; + + undefined (); + + while (uninitialized < 1) /* { dg-warning "uninitialized" } */ + { + bar (zero ()); + ++uninitialized; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107107.c b/SingleSource/Regression/C/gcc-dg/pr107107.c new file mode 100644 index 0000000000..5ad6a63159 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107107.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-tail-merge" } */ + +static inline void set_longish(int is_long_long, void *p, long x) +{ + if (is_long_long) + *(long long*)p = x; + else + *(long*)p = x; +} +static long test(long long *p, int index, int mode) +{ + *p = 1; + set_longish(mode, p+index, 2); + return *p; +} +long (*volatile vtest)(long long*, int, int) = test; +int main(void) +{ + long long x; + long result = vtest(&x, 0, 1); + if (result != 2 || x != 2) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107109.c b/SingleSource/Regression/C/gcc-dg/pr107109.c new file mode 100644 index 0000000000..e3036f6ff2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107109.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +int printf(const char *, ...); +int a, b; +void c() { + int d, e; + L: + a = (b && a) ^ 2756578370; + d = ~a + (e ^ d) ^ 2756578370; + if (!d) + printf("%d", a); + d = a / e; + goto L; +} +int main() { + if (a) + c(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr107127.c b/SingleSource/Regression/C/gcc-dg/pr107127.c new file mode 100644 index 0000000000..d25cced6b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107127.c @@ -0,0 +1,13 @@ +/* PR c/107127 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int *v; + +_Complex double +foo (_Complex double a, double b, double c) +{ + return v[0] / ((((c * (0 - 0 / a + 699.0 + 7.05 - 286.0 - +-4.65 + 1.57 + 0) * 0.1 - 3.28 + 4.22 + 0.1)) * b + 5.06) + * 1.23 * 8.0 * 12.0 * 16.0 * 2.0 * 2.0 * 0.25 * 0.125 * 18.2 * -15.25 * 0.0001 + * 42.0 * 0.012 - 8.45 + 0 + 88.0 + 6.96 + 867.0 + 9.10 - 7.04 * -1.0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107131.c b/SingleSource/Regression/C/gcc-dg/pr107131.c new file mode 100644 index 0000000000..458b128f88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107131.c @@ -0,0 +1,30 @@ +/* PR target/107131 */ +/* { dg-do run } */ +/* { dg-options "-Os -fno-ipa-vrp -fno-tree-bit-ccp -Wno-psabi" } */ + +typedef unsigned char C; +typedef unsigned long long __attribute__((__vector_size__ (32))) U; +typedef unsigned long long __attribute__((__vector_size__ (64))) V; + +static __attribute__((__noclone__)) C +foo (C o, U x, U y, U z) +{ + V a = __builtin_shufflevector (x, x, 3, 1, 3, 0, 0, 1, 1, 3); + V b = (V) { } >= o; + V c = b <= (V)(b >= (V) { 0, 0, 0, 0, 0, 0x90DF0BE3990AC871ULL }); + U d = __builtin_shufflevector (y, z, 3, 1, 4, 5); + V e = a + c; + U f = ((union { V v; U u[2]; }) e).u[1] + d; + return ((union { U u; C c[32]; }) f).c[9]; +} + +int +main () +{ + if (__SIZEOF_LONG_LONG__ != 8 || __CHAR_BIT__ != 8) + return 0; + C x = foo (0, (U) { }, (U) { }, (U) { }); + if (x != 0xff) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107262.c b/SingleSource/Regression/C/gcc-dg/pr107262.c new file mode 100644 index 0000000000..2ced047464 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107262.c @@ -0,0 +1,13 @@ +/* PR middle-end/107262 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ +/* { dg-add-options bfloat16 } */ +/* { dg-require-effective-target bfloat16_runtime } */ + +__bf16 +foo (__bf16 a) +{ + __bf16 b = 0; + b /= a; + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107300.c b/SingleSource/Regression/C/gcc-dg/pr107300.c new file mode 100644 index 0000000000..836908ee9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107300.c @@ -0,0 +1,19 @@ +/* PR ipa/107300 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fipa-cp-clone -funreachable-traps -fno-inline" } */ + +void +bar (int x, int y) +{ + if (x) + __builtin_unreachable (); + + if (y) + __builtin_abort (); +} + +void +foo (void) +{ + bar (0, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107389.c b/SingleSource/Regression/C/gcc-dg/pr107389.c new file mode 100644 index 0000000000..deb6338070 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107389.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized-alias" } */ + +unsigned foo (void *p) +{ + unsigned i; + __builtin_memcpy (&i, __builtin_assume_aligned (p, 4), sizeof (unsigned)); + return i; +} + +/* Even when not optimizing we should have alignment info on the temporary + feeding the memcpy. */ +/* { dg-final { scan-tree-dump "ALIGN = 4" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr107505.c b/SingleSource/Regression/C/gcc-dg/pr107505.c new file mode 100644 index 0000000000..01270eac91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107505.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-guess-branch-probability" } */ + +int n; + +void +bar (void); + +__attribute__ ((noinline, returns_twice)) int +zero (void) +{ + return 0; +} + +void +foo (void) +{ + int a = zero (); + + for (n = 0; n < 2; ++n) + { + } + + if (a) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107523.c b/SingleSource/Regression/C/gcc-dg/pr107523.c new file mode 100644 index 0000000000..1e5ed46c63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107523.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-O2 " } */ + +int a, b = 1; +unsigned int c = 1; +int main() { + int d = 1, f; + if (b) + d = 0; + a = -1; + b = ~d ^ 465984011; + L1:; + if (b < 2) + f = b; + b = f; + if (f <= a) { + int g = -(a && 1), h = g - f && a, i = ~(c / f) && 1 % (a | h); + if (c) { + g = f; + if (i || (g && (g > -465984012))) + goto L2; + } + c = g | f / c; + } + if (0) + L2: + a = 0; + if (a <= c) + goto L1; + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr107547.c b/SingleSource/Regression/C/gcc-dg/pr107547.c new file mode 100644 index 0000000000..7cd68afc0a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107547.c @@ -0,0 +1,41 @@ +/* PR tree-optimization/107547 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-add-options float16 } */ + +int x; + +void +foo (void) +{ +#define TEST(...) \ + __builtin_acos##__VA_ARGS__ (x); \ + __builtin_asin##__VA_ARGS__ (x); \ + __builtin_acosh##__VA_ARGS__ (x); \ + __builtin_atanh##__VA_ARGS__ (x); \ + __builtin_cosh##__VA_ARGS__ (x); \ + __builtin_sinh##__VA_ARGS__ (x); \ + __builtin_log##__VA_ARGS__ (x); \ + __builtin_log2##__VA_ARGS__ (x); \ + __builtin_log10##__VA_ARGS__ (x); \ + __builtin_log1p##__VA_ARGS__ (x); \ + __builtin_exp##__VA_ARGS__ (x); \ + __builtin_expm1##__VA_ARGS__ (x); \ + __builtin_exp2##__VA_ARGS__ (x); \ + __builtin_sqrt##__VA_ARGS__ (x) + TEST (f); + TEST (); + TEST (l); +#ifdef __FLT16_MAX__ + TEST (f16); +#endif +#ifdef __FLT32_MAX__ + TEST (f32); +#endif +#ifdef __FLT64_MAX__ + TEST (f64); +#endif +#ifdef __FLT128_MAX__ + TEST (f128); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107554.c b/SingleSource/Regression/C/gcc-dg/pr107554.c new file mode 100644 index 0000000000..61ef2bcd90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107554.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O -foptimize-strlen" } */ + +#define ELEMS 0x40000000 + +int a[ELEMS]; +int b[ELEMS]; + +int main() +{ + __builtin_memcpy(a, b, ELEMS*sizeof(int)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107557-1.c b/SingleSource/Regression/C/gcc-dg/pr107557-1.c new file mode 100644 index 0000000000..f14b784dbb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107557-1.c @@ -0,0 +1,25 @@ +/* PR107557 + * { dg-do compile } + * { dg-require-effective-target lto } + * { dg-options "-flto -fsanitize=undefined -fexceptions -Wno-incompatible-pointer-types" } + */ + + +int c[1][3*2]; +int f(int * const m, int (**v)[*m * 2]) +{ + return &(c[0][*m]) == &((*v)[0][*m]); +} +int test(int n, int (*(*fn)(void))[n]) +{ + return (*fn())[0]; +} +int main() +{ + int m = 3; + int (*d)[3*2] = c; + int (*fn[m])(void); + return f(&m, &d) + test(m, &fn); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr107557-2.c b/SingleSource/Regression/C/gcc-dg/pr107557-2.c new file mode 100644 index 0000000000..e680d04516 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107557-2.c @@ -0,0 +1,24 @@ +/* PR107557 + * { dg-do compile } + * { dg-require-effective-target lto } + * { dg-options "-flto -fsanitize=undefined -fexceptions -Wno-incompatible-pointer-types" } + */ + + +int c[1][3*2]; +int f(int * const m, int (**(*v))[*m * 2]) +{ + return &(c[0][*m]) == &((*v)[0][*m]); /* { dg-warning "lacks a cast" } */ +} +int test(int n, int (*(*(*fn))(void))[n]) +{ + return (*(*fn)())[0]; +} +int main() +{ + int m = 3; + int (*d)[3*2] = c; + int (*fn[m])(void); + return f(&m, &d) + test(m, &fn); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr107570.c b/SingleSource/Regression/C/gcc-dg/pr107570.c new file mode 100644 index 0000000000..ba5b535a86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107570.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +long int n; + +void +foo (int *p, int x) +{ + for (;;) + { + for (*p = 0; *p < 1; ++*p) + { + n += *p < 0; + if (n < x) + { + while (x < 1) + ++x; + + __builtin_unreachable (); + } + } + + p = &x; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107585.c b/SingleSource/Regression/C/gcc-dg/pr107585.c new file mode 100644 index 0000000000..820e04b653 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107585.c @@ -0,0 +1,13 @@ +/* PR target/107585 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef unsigned char __attribute__((__vector_size__ (16))) V; +char c; +void bar (int); + +void +foo (void) +{ + bar (((V) (c <= (V){127}))[2]); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107618.c b/SingleSource/Regression/C/gcc-dg/pr107618.c new file mode 100644 index 0000000000..9e73cc1f1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107618.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Og" } */ + +void a(void) __attribute__((__warning__(""))); +int main(void) +{ + unsigned long b = __builtin_object_size(0, 0); + if (__builtin_expect(b < 1, 0)) + a(); /* { dg-bogus "warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107686.c b/SingleSource/Regression/C/gcc-dg/pr107686.c new file mode 100644 index 0000000000..2378103c55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107686.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target { dfp && longlong64 } } } */ +/* { dg-options "-O" } */ +/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */ + +typedef _Decimal64 __attribute__((__vector_size__ (64))) D; +typedef __INT32_TYPE__ __attribute__((__vector_size__ (32))) U; +typedef __INT64_TYPE__ __attribute__((__vector_size__ (64))) V; + +U u; +D d; + +void +foo (void) +{ + d = d < (D) __builtin_convertvector (u, V); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107787.c b/SingleSource/Regression/C/gcc-dg/pr107787.c new file mode 100644 index 0000000000..922dbff8b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107787.c @@ -0,0 +1,13 @@ +/* PR driver/107787 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Werror=array-bounds=1" } */ +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +int a[10]; /* { dg-note "while referencing" } */ + +int* f(void) { + + a[-1] = 0; /* { dg-error "is below array bounds" } */ + + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107805-1.c b/SingleSource/Regression/C/gcc-dg/pr107805-1.c new file mode 100644 index 0000000000..559b6a5586 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107805-1.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +typedef int t; +typedef struct { double a; int b; } t; /* { dg-error "conflicting types" } */ +t x; /* No warning here. */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr107805-2.c b/SingleSource/Regression/C/gcc-dg/pr107805-2.c new file mode 100644 index 0000000000..fa5fa4ce27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107805-2.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +typedef int t; +typedef struct { double a; int b; } t; /* { dg-error "conflicting types" } */ +t char x; /* { dg-error "two or more data types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr107822.c b/SingleSource/Regression/C/gcc-dg/pr107822.c new file mode 100644 index 0000000000..c68ecbe8f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107822.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +int b; +void foo(); +void(a)(); +int main() { + int c; + int *d = &c; + *d = a && 8; + b = 0; + for (; b < 9; ++b) + *d ^= 3; + if (*d) + ; + else + foo(); +} + +/* { dg-final { scan-tree-dump-not "foo" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr107846.c b/SingleSource/Regression/C/gcc-dg/pr107846.c new file mode 100644 index 0000000000..15a661cdb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107846.c @@ -0,0 +1,14 @@ +/* PR c/107846 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -O2" } */ + +#define foo(x, b, n, m) ((unsigned short) (x) << (b - (n + 1) * 8) >> (b - 8) << (m * 8)) +#define bar(x) ((unsigned short) (foo (x, 16, 0, 1) | foo (x, 16, 1, 0))) +#define baz(x) bar (x) +static const int v = 8000; + +unsigned short +qux (int t) +{ + return t != baz (v); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107937.c b/SingleSource/Regression/C/gcc-dg/pr107937.c new file mode 100644 index 0000000000..524850bcfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107937.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +int _setjmp(int); +int regs, vm_debug_engine_vp_0, vm_debug_engine_vp_2; + +void +vm_dispatch_hook(); + + +void +vm_debug_engine() { + int fp; + void *jump_table = &&l_nop; +l_nop: + if (__builtin_expect(vm_debug_engine_vp_2, 0)) + vm_dispatch_hook(); + if (_setjmp(regs)) { + fp = fp; + vm_dispatch_hook(); + goto *jump_table; + } + vm_debug_engine_vp_0 = fp; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107967-1.c b/SingleSource/Regression/C/gcc-dg/pr107967-1.c new file mode 100644 index 0000000000..d099231024 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107967-1.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/107967 */ +/* { dg-do compile { target float64 } } */ +/* { dg-options "-O2 -frounding-math -fno-trapping-math -fdump-tree-optimized" } */ +/* { dg-add-options float64 } */ +/* { dg-final { scan-tree-dump-not "return\[ \t]\*-?Inf;" "optimized" } } */ + +_Float64 +foo (void) +{ + const _Float64 huge = 1.0e+300f64; + return huge * huge; +} + +_Float64 +bar (void) +{ + const _Float64 huge = 1.0e+300f64; + return huge * -huge; +} + +_Float64 +baz (void) +{ + const _Float64 a = 0x1.fffffffffffffp+1023f64; + const _Float64 b = 0x1.fffffffffffffp+970f64; + return a + b; +} + +_Float64 +qux (void) +{ + const _Float64 a = 0x1.fffffffffffffp+1023f64; + const _Float64 b = 0x1.fffffffffffffp+969f64; + return a + b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107967-2.c b/SingleSource/Regression/C/gcc-dg/pr107967-2.c new file mode 100644 index 0000000000..554000cbac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107967-2.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/107967 */ +/* { dg-do compile { target float64 } } */ +/* { dg-options "-O2 -fno-rounding-math -fno-trapping-math -fdump-tree-optimized" } */ +/* { dg-add-options float64 } */ +/* { dg-final { scan-tree-dump-times "return\[ \t]\*-?Inf;" 3 "optimized" } } */ + +_Float64 +foo (void) +{ + const _Float64 huge = 1.0e+300f64; + return huge * huge; +} + +_Float64 +bar (void) +{ + const _Float64 huge = 1.0e+300f64; + return huge * -huge; +} + +_Float64 +baz (void) +{ + const _Float64 a = 0x1.fffffffffffffp+1023f64; + const _Float64 b = 0x1.fffffffffffffp+970f64; + return a + b; +} + +_Float64 +qux (void) +{ + const _Float64 a = 0x1.fffffffffffffp+1023f64; + const _Float64 b = 0x1.fffffffffffffp+969f64; + return a + b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107967-3.c b/SingleSource/Regression/C/gcc-dg/pr107967-3.c new file mode 100644 index 0000000000..9b36a1f785 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107967-3.c @@ -0,0 +1,53 @@ +/* PR tree-optimization/107967 */ +/* { dg-do compile { target float64 } } */ +/* { dg-options "-O2 -fno-rounding-math -fno-trapping-math -fdump-tree-optimized" } */ +/* { dg-add-options float64 } */ +/* { dg-final { scan-tree-dump-times "return\[ \t]\*-?Inf;" 3 "optimized" } } */ + +_Float64 +foo (_Float64 x) +{ + if (x >= 1.0e+300f64) + ; + else + __builtin_unreachable (); + return x * x; +} + +_Float64 +bar (_Float64 x) +{ + if (x >= 1.0e+300f64) + ; + else + __builtin_unreachable (); + return x * -x; +} + +_Float64 +baz (_Float64 a, _Float64 b) +{ + if (a >= 0x1.fffffffffffffp+1023f64) + ; + else + __builtin_unreachable (); + if (b >= 0x1.p+972f64) + ; + else + __builtin_unreachable (); + return a + b; +} + +_Float64 +qux (_Float64 a, _Float64 b) +{ + if (a >= 0x1.fffffffffffffp+1023f64) + ; + else + __builtin_unreachable (); + if (b >= 0x1.fffffffffffffp+969f64) + ; + else + __builtin_unreachable (); + return a + b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107975.c b/SingleSource/Regression/C/gcc-dg/pr107975.c new file mode 100644 index 0000000000..7710f6f4a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107975.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/107975 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-add-options ieee } */ + +double +foo (double x, double y) +{ + if (x == 42.0) + return 1.0; + double r = x * y; + if (!__builtin_isnan (r)) + __builtin_unreachable (); + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr107986-1.c b/SingleSource/Regression/C/gcc-dg/pr107986-1.c new file mode 100644 index 0000000000..1125ab0ea1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr107986-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void bar (); +void foo (int *a) +{ + int qa = 0; + for (int i = 0; i < 3; i++) + if (a[i]) + a[qa++] = 0; +/* Show that we know qa is not negative. */ + if (qa < 0) + bar (); +} + +/* { dg-final { scan-tree-dump-not "bar" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr108043.c b/SingleSource/Regression/C/gcc-dg/pr108043.c new file mode 100644 index 0000000000..0cc0700f30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108043.c @@ -0,0 +1,12 @@ +/* PR c/108043 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef void F (void); + +void +foo (void) +{ + (F) {}; /* { dg-error "compound literal has function type" } */ + (F) { foo }; /* { dg-error "compound literal has function type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108095.c b/SingleSource/Regression/C/gcc-dg/pr108095.c new file mode 100644 index 0000000000..fb76caae72 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108095.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/108095 */ +/* { dg-do compile } */ +/* { dg-options "-Os -g" } */ + +int v; +typedef unsigned T; + +void +foo (void) +{ + unsigned s; + asm goto ("" : "=r" (*(T *) &s) : : : lab); + v = 0; +lab: +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108117.c b/SingleSource/Regression/C/gcc-dg/pr108117.c new file mode 100644 index 0000000000..4b3bebe229 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108117.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-require-effective-target nonlocal_goto } */ +/* { dg-require-effective-target scheduling } */ +/* { dg-options "-O2 -fschedule-insns" } */ + +#include +#include + +jmp_buf ex_buf; + +__attribute__((noipa)) +void fn_throw(int x) +{ + if (x) + longjmp(ex_buf, 1); +} + +int main(void) +{ + int vb = 0; // NB: not volatile, not modified after setjmp + + if (!setjmp(ex_buf)) { + fn_throw(1); + vb = 1; // not reached in the abstract machine + } + + if (vb) { + printf("Failed, vb = %d!\n", vb); + return 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108139.c b/SingleSource/Regression/C/gcc-dg/pr108139.c new file mode 100644 index 0000000000..6f224e3ce6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108139.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O1 -ftree-vrp -fdump-tree-vrp" } */ + +int a, b; +int main() { + int c; + if (a > 1) + a++; + while (a) + if (c == b) + c = a; + return 0; +} + + +/* { dg-final { scan-tree-dump-not "Folding predicate" "vrp2" } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/pr108164.c b/SingleSource/Regression/C/gcc-dg/pr108164.c new file mode 100644 index 0000000000..d76d557876 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108164.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-tree-dce" } */ + +int a, b, c; +int main() +{ + int e = -1; + short f = -1; + for (; c < 1; c++) + while (f >= e) + f++; + for (; a < 2; a++) { + short g = ~(~b | ~f); + int h = -g; + int i = (3 / ~h) / ~b; + b = i; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108241.c b/SingleSource/Regression/C/gcc-dg/pr108241.c new file mode 100644 index 0000000000..06d210fae6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108241.c @@ -0,0 +1,63 @@ +/* PR driver/108241 */ +/* { dg-options "-Os -frounding-math -fvar-tracking-assignments -fno-dce -fno-trapping-math -fno-tree-dce -fno-tree-dse" } */ + +long int n1; +int n2, n3, n4; +char n5; + +void +foo (long int x1, long int x2, int x3, int x4, int x5, char x6, char x7) +{ + char a01 = n2, a02 = x4, a03 = 0; + short int a04; + unsigned short int a05 = x5; + int a06, a07, a08 = a05, a09 = x3, a10 = 0; + long int a11, a12 = x4; + + if (x1) + { + a07 = x6 + (float)0x1000001; + a03 = a12 = a01 = a06 = ~0; + + if (x5) + a11 = n5; + } + else + { + a10 = x3 = n3; + if (n3) + a06 = a05 = x7; + } + + if (n3 < n5) + { + n4 = (x2 == x4) + !n1; + if (n4 % (n1 % x3)) + { + a04 = n4; + a02 = n2; + } + + if (x3) + { + a05 = !n1 % n2; + a08 = n1; + a04 = x5 + a06; + } + + if (a12) + a09 = n3 + n4; + + a12 = a07; + n3 = a11 % x1; + n5 += x6; + n1 = a04; + } + + n4 = x2 % x5 % a11; + a06 = a10 + a08 % a02 == n4; + a09 = a09 == a01 * x7; + n4 = x4; + a12 += x4 / 0xc000000000000000 + !a03; + a03 = !a05; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108263.c b/SingleSource/Regression/C/gcc-dg/pr108263.c new file mode 100644 index 0000000000..688df32665 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108263.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/108263 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int v, *p; + +void +foo (void) +{ + int i; + for (i = 0; ; i++) + { + if (v) + { + __label__ l1; + asm goto ("" : : : : l1); + l1: + return; + } + if (p[i]) + break; + } + asm goto ("" : : "r" (i) : : l2); +l2:; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108264.c b/SingleSource/Regression/C/gcc-dg/pr108264.c new file mode 100644 index 0000000000..ff9aa261d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108264.c @@ -0,0 +1,27 @@ +/* PR middle-end/108264 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ + +int v; +extern int bar (void); + +static inline void +foo (char *d) +{ + switch (bar ()) + { + case 2: + d[0] = d[1] = d[2] = d[3] = v; + break; + case 4: + d[0] = 0; + } +} + +int +baz (int x) +{ + foo ((char *) &x); + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108306.c b/SingleSource/Regression/C/gcc-dg/pr108306.c new file mode 100644 index 0000000000..1044c646de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108306.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-overflow -fsanitize=shift -Warray-bounds" } */ + +enum psi_task_count { + NR_IOWAIT, + NR_PSI_TASK_COUNTS = 4, +}; + +unsigned int tasks[NR_PSI_TASK_COUNTS]; + +static void psi_group_change(unsigned int set) +{ + unsigned int t; + unsigned int state_mask = 0; + + for (t = 0; set; set &= ~(1 << t), t++) + if (set & (1 << t)) + tasks[t]++; +} + +void psi_task_switch(int sleep) +{ + int set = 0; + + if (sleep) + set |= (1 << NR_IOWAIT); + + psi_group_change(set); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108308.c b/SingleSource/Regression/C/gcc-dg/pr108308.c new file mode 100644 index 0000000000..d5cc37d9f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108308.c @@ -0,0 +1,39 @@ +/* PR target/108308 */ +/* { dg-do run { target int32 } } */ +/* { dg-options "-Os -fno-tree-ccp" } */ + +int a = 1, *d = &a, f = 2766708631, h; +unsigned b = -1, c, e, g; + +static void +foo (int j) +{ + if (a) + { + c = ~c; + while (e) + j = 0; + goto k; + } +l: + h = 1; +k: + *d = (!j) | 80; + int m = ~(~(-1 / b) | (a ^ 1)), n = ~(~g / (11 >> m)), o = -1 / n; + if (f) + { + b = 9518150474215344 ^ ~f; + f = 0; + if (c) + goto l; + if (o) + goto k; + } +} + +int +main () +{ + foo (1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108356.c b/SingleSource/Regression/C/gcc-dg/pr108356.c new file mode 100644 index 0000000000..1df6b278e4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108356.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +char a; +static char c = 3; +char d; +void foo(); +short(b)(short e, short f) { return e + f; } +int main() { + unsigned g = 0; + if (c) + ; + else + foo(); + for (; g < 2; g = b(g, 2)) { + d = g ? 0 : a; + if (g) + c = 0; + } +} + + +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr108359.c b/SingleSource/Regression/C/gcc-dg/pr108359.c new file mode 100644 index 0000000000..7cf04f7413 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108359.c @@ -0,0 +1,52 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* PR test case. */ +int b = 10; +int c; +char e; +void foo(); +static char(a)(char f, char g) { return f && g == 1 ? 0 : f % g; } +short(d)(short f, short g) { return f * g; } +int main() { + short h; + int i; + unsigned j; + h = d(b && c, 5); + j = h; + i = a(h, 237); + unsigned k = i; + e = i < 0 || k >= 32 ? 0 : i >> k; + if (e) { + c = 0; + foo(); + } +} + + +/* Also Check that small ranges are broken down and optimized properly + This function should never call foo (). */ + +int otherfunc (int x, int z) { + if (x < 1 || x > 6 ) + return 0; + + if (x == z) + { + if (x >> z > 0) + foo (); + if (x * z > 26 && x * z < 35) + foo (); + if (x + z == 5) + foo (); + if ((x + z) % 2 == 1) + foo (); + if (x / z != 1) + foo (); + + } + return 0; +} + + +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr108375-1.c b/SingleSource/Regression/C/gcc-dg/pr108375-1.c new file mode 100644 index 0000000000..1cbb05b03c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108375-1.c @@ -0,0 +1,14 @@ +/* PR 108375 + * { dg-do compile } + * { dg-options "" } + * */ + +void +f (int a) +{ + goto x; /* { dg-error "jump into scope of identifier with variably modified type" } */ + struct { char (*p)[a]; } B; + x : ; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr108375-2.c b/SingleSource/Regression/C/gcc-dg/pr108375-2.c new file mode 100644 index 0000000000..0401ead5b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108375-2.c @@ -0,0 +1,15 @@ +/* PR 108375 + * { dg-do compile } + * { dg-options "" } + * */ + +void +f (int a) +{ + typedef int A[a]; + goto x; /* { dg-error "jump into scope of identifier with variably modified type" } */ + A *p[2]; + x : ; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr108385.c b/SingleSource/Regression/C/gcc-dg/pr108385.c new file mode 100644 index 0000000000..13babf06d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108385.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void bar(char *); + +/* Ensure that PTR1 = PTR2 + OFF properly picks up the zero and non-zero + properties if PTR1 and PTR2 are known equal or non-equal. */ + +void foo1 (char *p, char *pp, int off) +{ + char *q = p + off; + if (q != p) + { + if (off == 0) + bar (q); + } + else + { + if (off != 0) + bar (p); + } +} + +void foo2 (char *p, char *pp, int off) +{ + char *q = p + off; + if (q == p) + { + if (off != 0) + bar (p); + } + else + { + if (off == 0) + bar (q); + } +} + +/* { dg-final { scan-tree-dump-not "bar" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr108387.c b/SingleSource/Regression/C/gcc-dg/pr108387.c new file mode 100644 index 0000000000..114186b6c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108387.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-ccp" } */ + +void bar2 (unsigned char, unsigned char); + +void +foo1 (char c) +{ + unsigned char t = c; + t *= 2; + unsigned char t1 = t << 7; + bar2 (t, t1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108423-1.c b/SingleSource/Regression/C/gcc-dg/pr108423-1.c new file mode 100644 index 0000000000..0c98d1d46b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108423-1.c @@ -0,0 +1,16 @@ +/* PR108423 + * { dg-do compile } + * { dg-options "-O2 -Wno-int-conversion -Wno-incompatible-pointer-types" } + */ +int f (int n, int (**(*a)(void))[n]) +{ + return (*a())[0]; +} +int g () +{ + int m = 3; + int (*a[m])(void); + return f(m, &a); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr108423-2.c b/SingleSource/Regression/C/gcc-dg/pr108423-2.c new file mode 100644 index 0000000000..006e45a962 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108423-2.c @@ -0,0 +1,16 @@ +/* PR108423 + * { dg-do compile } + * { dg-options "-O2" } + */ + +void f(int n, int (*a(void))[n]) +{ + (a())[0]; +} + +void g(void) +{ + int (*a(void))[1]; + f(1, a); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr108423-3.c b/SingleSource/Regression/C/gcc-dg/pr108423-3.c new file mode 100644 index 0000000000..c1987c42b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108423-3.c @@ -0,0 +1,17 @@ +/* PR108423 + * { dg-do compile } + * { dg-options "-O2" } + */ + +void f(int n, int (*(*b)(void))[n]) +{ + sizeof (*(*b)()); +} + +int (*a(void))[1]; + +void g(void) +{ + f(1, &a); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr108423-4.c b/SingleSource/Regression/C/gcc-dg/pr108423-4.c new file mode 100644 index 0000000000..91336f3f28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108423-4.c @@ -0,0 +1,17 @@ +/* PR108423 + * { dg-do compile } + * { dg-options "-O2" } + */ + +void f(int n, int (*a(void))[n]) +{ + sizeof (*a()); +} + +int (*a(void))[1]; + +void g(void) +{ + f(1, a); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr108423-5.c b/SingleSource/Regression/C/gcc-dg/pr108423-5.c new file mode 100644 index 0000000000..7e4fffb287 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108423-5.c @@ -0,0 +1,17 @@ +/* PR108423 + * { dg-do compile } + * { dg-options "-O2" } + */ + +void f(int n, int (*(*a)(void))[n]) +{ + sizeof ((*a)()); +} + +int (*a(void))[1]; + +void g(void) +{ + f(1, a); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr108423-6.c b/SingleSource/Regression/C/gcc-dg/pr108423-6.c new file mode 100644 index 0000000000..c36e45aaf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108423-6.c @@ -0,0 +1,16 @@ +/* PR108423 + * { dg-do compile } + * { dg-options "-O2" } + */ + +void f(int n, int (*a())[n]) +{ + (a())[0]; +} + +void g(void) +{ + int (*a())[1]; + f(1, a); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr108447.c b/SingleSource/Regression/C/gcc-dg/pr108447.c new file mode 100644 index 0000000000..cfbaba6d0a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108447.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +__attribute__((noipa)) int +foo (float x, float y) +{ + _Bool cmp1 = x <= y; + _Bool cmp2 = x >= y; + if (cmp1 && cmp2) + return 1; + else if (!cmp1 && !cmp2) + return -1; + return 0; +} + +int +main () +{ + if (foo (0.0f, __builtin_nanf ("")) != -1) + __builtin_abort (); + if (foo (__builtin_nanf (""), -42.0f) != -1) + __builtin_abort (); + if (foo (0.0f, -0.0f) != 1) + __builtin_abort (); + if (foo (42.0f, 42.0f) != 1) + __builtin_abort (); + if (foo (42.0f, -0.0f) != 0) + __builtin_abort (); + if (foo (0.0f, -42.0f) != 0) + __builtin_abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr108449.c b/SingleSource/Regression/C/gcc-dg/pr108449.c new file mode 100644 index 0000000000..4a3ae5b3ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108449.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +static int vfork(); /* { dg-warning "used but never defined" } */ +void f() { vfork(); } diff --git a/SingleSource/Regression/C/gcc-dg/pr108463.c b/SingleSource/Regression/C/gcc-dg/pr108463.c new file mode 100644 index 0000000000..6e94e7daed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108463.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/108463 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsched2-use-superblocks -fcompare-debug -Wno-psabi" } */ + +typedef int __attribute__((__vector_size__ (32))) V; +int a; + +void +foo (V v) +{ + a--; + v = (V) v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108573.c b/SingleSource/Regression/C/gcc-dg/pr108573.c new file mode 100644 index 0000000000..5dd18043b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108573.c @@ -0,0 +1,18 @@ +/* PR debug/108573 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +unsigned g; + +int bar (void); +int baz (int); + +void +foo (unsigned short s, long l) +{ + unsigned u = bar (); + s &= __builtin_add_overflow_p (0, u, 0); + s %= g; + s -= l >> s; + baz (s); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108582-1.c b/SingleSource/Regression/C/gcc-dg/pr108582-1.c new file mode 100644 index 0000000000..88c2de369a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108582-1.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-ccp -fno-tree-dce" } */ + +/* + PHI-OPT via match_simplify_replacement used to transform: + if (_25 != 0) + goto ; [25.00%] + else + goto ; [75.00%] + + [local count: 11649864]: + # iftmp.5_13 = PHI <2(7)> + k_22 = k_11 | iftmp.5_13; + + [local count: 105655256]: + # g_9 = PHI <1(2), 0(8), g_8(7)> + # k_12 = PHI + +into: + + _15 = (int) _25; + _28 = -_15; + _4 = _13 & _28; + _6 = _4 | k_11; + + [local count: 105655256]: + # g_9 = PHI <1(2), g_8(7)> + # k_12 = PHI + +Removing the phi-node/assignment of _13. + + */ + +int a, c, d, e, f; +char b; +int main() { + int g = 1; + char h[1] = {0}; + while (a) { + if (f) { + b = 0; + if (d) + continue; + } + if (a < 1) { + g = 0; + goto L; + } + } + while (c) { + char *j = h; + int k; + L: + if (e && !g) + k |= 2 | (*j < 0); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108625.c b/SingleSource/Regression/C/gcc-dg/pr108625.c new file mode 100644 index 0000000000..03fc2889c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108625.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1 -fdump-tree-optimized" } */ + +unsigned char foo(int x) +{ + int t = -x; + unsigned char t1 = t; + unsigned char t2 = t; + /* We may not rewrite this as (unsigned char)(t - x). */ + return t1 + t2; +} + +/* { dg-final { scan-tree-dump-times "x_" 1 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "x_" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr108655.c b/SingleSource/Regression/C/gcc-dg/pr108655.c new file mode 100644 index 0000000000..f407616976 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108655.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/108655 */ +/* { dg-do compile } */ +/* { dg-options "-w -O1 -funreachable-traps" } */ + +void +foo (void) +{ + int i, j; + for (; i;) + ; + for (; i < 6;) + for (j = 0; j < 6; ++j) + i += j; + __builtin_trap (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108657.c b/SingleSource/Regression/C/gcc-dg/pr108657.c new file mode 100644 index 0000000000..37d0b8e863 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108657.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/108657 */ +/* { dg-do run } */ +/* { dg-options "-O3 -ftrivial-auto-var-init=zero" } */ + +int c, e, f; +static int *d = &c; + +__attribute__((noipa)) void +foo (void) +{ + if (c != 1) + __builtin_abort (); +} + +int +main () +{ + for (c = 1; c >= 0; c--) + { + e = 0; + for (int j = 0; j <= 2; j++) + { + short k[1]; + if (e) + break; + e ^= f; + } + } + *d = 1; + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108688.c b/SingleSource/Regression/C/gcc-dg/pr108688.c new file mode 100644 index 0000000000..5f76f0ba83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108688.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/108688 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-pre -fno-tree-fre -fno-tree-dominator-opts -fno-tree-loop-im -fno-code-hoisting" } */ + +union U { signed int d : 7; signed int e : 2; } u; +int a, b; + +void +foo (void) +{ + for (int i = 0; i < 64; i++) + { + u.d = a; + u.d ^= b; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108691.c b/SingleSource/Regression/C/gcc-dg/pr108691.c new file mode 100644 index 0000000000..e412df10f2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108691.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int __attribute__((returns_twice)) setjmp(void*); + +void bbb(void) { + int (*fnptr)(void*) = setjmp; + fnptr(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108692.c b/SingleSource/Regression/C/gcc-dg/pr108692.c new file mode 100644 index 0000000000..fc25bf54e4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108692.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/108692 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +__attribute__((noipa)) int +foo (signed char *x, signed char *y, int n) +{ + int i, r = 0; + signed char a, b; + for (i = 0; i < n; i++) + { + a = x[i]; + b = y[i]; + int c = (unsigned char) a - (unsigned char) b; + r = r + (c < 0 ? -c : c); + } + return r; +} + +int +main () +{ + signed char x[64] = {}, y[64] = {}; + if (__CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4) + return 0; + x[32] = -128; + y[32] = 1; + if (foo (x, y, 64) != 127) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108757-1.c b/SingleSource/Regression/C/gcc-dg/pr108757-1.c new file mode 100644 index 0000000000..7908f4bdcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108757-1.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/108757 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include +#define N 5 +#define M 3 +#define GAP 0 +typedef unsigned int UINT; +typedef int INT; +#define UMAX UINT_MAX +#define IMAX INT_MAX +#define IMIN INT_MIN +#include "pr108757.h" + +/* { dg-final { scan-tree-dump-not " = x_\[0-9\]+\\(D\\) \\+ " "optimized" } } * +/* { dg-final { scan-tree-dump-not " = x_\[0-9\]+\\(D\\) \\- " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " = b_\[0-9\]+ \\+ " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr108757-2.c b/SingleSource/Regression/C/gcc-dg/pr108757-2.c new file mode 100644 index 0000000000..82bebd0994 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108757-2.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/108757 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -fwrapv" } */ + +#include +#define N 4 +#define M 3 +#define GAP 2 +typedef unsigned int UINT; +typedef int INT; +#define UMAX UINT_MAX +#define IMAX INT_MAX +#define IMIN INT_MIN +#include "pr108757.h" + +/* { dg-final { scan-tree-dump-times " = x_\[0-9\]+\\(D\\) \\+ " 16 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " = x_\[0-9\]+\\(D\\) \\- " 3 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\+ x_\[0-9\]+\\(D\\)" 3 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr108757.h b/SingleSource/Regression/C/gcc-dg/pr108757.h new file mode 100644 index 0000000000..5550199c1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108757.h @@ -0,0 +1,233 @@ +#define NOINLINE __attribute__ ((noinline)) +UINT NOINLINE +opt_u1 (UINT x) +{ + if (x < (M * N) - GAP) + return 0; + UINT a = x - (M * N); + UINT b = a / N; + return b + M; +} + +UINT NOINLINE +opt_u2 (UINT x) +{ + if (x > (UMAX - (M * N) + GAP)) + return 0; + UINT a = x + (M * N); + UINT b = a / N; + return b - M; +} + +INT NOINLINE +opt_s1 (INT x) +{ + if (x < (M * N) - GAP) + return 0; + INT a = x - (M * N); + INT b = a / N; + return b + M; +} + +INT NOINLINE +opt_s2 (INT x) +{ + if (x < IMIN + (M * N) - GAP || x > 0) + return 0; + INT a = x - (M * N); + INT b = a / N; + return b + M; +} + +INT NOINLINE +opt_s3 (INT x) +{ + if (x < (M * N) - GAP) + return 0; + INT a = x - (M * N); + INT b = a / -N; + return b + -M; +} + +INT NOINLINE +opt_s4 (INT x) +{ + if (x < IMIN + (M * N) - GAP || x > 0) + return 0; + INT a = x - (M * N); + INT b = a / -N; + return b + -M; +} + +INT NOINLINE +opt_s5 (INT x) +{ + if (x > (-M * N) + GAP) + return 0; + INT a = x - (-M * N); + INT b = a / N; + return b + -M; +} + +INT NOINLINE +opt_s6 (INT x) +{ + if (x > IMAX - (M * N) + GAP || x < 0) + return 0; + INT a = x - (-M * N); + INT b = a / N; + return b + -M; +} + +INT NOINLINE +opt_s7 (INT x) +{ + if (x > (M * -N) + GAP) + return 0; + INT a = x - (M * -N); + INT b = a / -N; + return b + M; +} + +INT NOINLINE +opt_s8 (INT x) +{ + if (x > IMAX - (M * N) + GAP || x < 0) + return 0; + INT a = x - (M * -N); + INT b = a / -N; + return b + M; +} + +UINT NOINLINE +opt_u3 (UINT x) +{ + if (x < (M << N) - GAP) + return 0; + UINT a = x - (M << N); + UINT b = a >> N; + return b + M; +} + +UINT NOINLINE +opt_u4 (UINT x) +{ + if (x > (UMAX - (M << N)) + GAP) + return 0; + UINT a = x + (M << N); + UINT b = a >> N; + return b - M; +} + +INT NOINLINE +opt_s9 (INT x) +{ + if (x < (M << N) - GAP) + return 0; + INT a = x - (M << N); + INT b = a >> N; + return b + M; +} + +INT NOINLINE +opt_s10 (INT x) +{ + if (x < IMIN + (M << N) - GAP || x > 0) + return 0; + INT a = x - (M << N); + INT b = a >> N; + return b + M; +} + +INT NOINLINE +opt_s11 (INT x) +{ + if (x > (-M << N) + GAP) + return 0; + INT a = x - (-M << N); + INT b = a >> N; + return b + -M; +} + +INT NOINLINE +opt_s12 (INT x) +{ + if (x > IMAX - (M << N) + GAP || x < 0) + return 0; + INT a = x - (-M << N); + INT b = a >> N; + return b + -M; +} + +UINT NOINLINE +opt_u5 (UINT x, UINT n, UINT m) +{ + if (n > N || m > M) + return 0; + if (x < (M*N) - GAP) + return 0; + UINT a = x - (m * n); + UINT b = a / n; + return b + m; +} + +UINT NOINLINE +opt_u6 (UINT x, UINT n, UINT m) +{ + if (n > N || m > M) + return 0; + if (x > (UMAX - M*N) + GAP) + return 0; + UINT a = x + (m * n); + UINT b = a / n; + return b - m; +} + +INT NOINLINE +opt_s13 (INT x, INT n, INT m) +{ + if (n > N || m > M || n < 0 || m < 0) + return 0; + if (x < (M*N) - GAP) + return 0; + INT a = x - (m * n); + INT b = a / n; + return b + m; +} + +INT NOINLINE +opt_s14 (INT x, INT n, INT m) +{ + if (n > N || m > M || n < 0 || m < 0) + return 0; + if (x > -M*N + GAP) + return 0; + INT a = x + (m * n); + INT b = a / n; + return b - m; +} + +INT +opt_s15 (INT x, INT n, INT m) +{ + if (n > 0 || m > 0 || n < -N || m < -M) + return 0; + if (x < (M*N) - GAP) + return 0; + INT a = x - (m * n); + INT b = a / n; + return b + m; +} + +INT NOINLINE +opt_s16 (INT x, INT n, INT m) +{ + if (n > 0 || m > 0 || n < -N || m < -M) + return 0; + if (x < 0 || x > (IMAX - M*N) + GAP) + return 0; + INT a = x + (m * n); + INT b = a / n; + return b - m; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr108787.c b/SingleSource/Regression/C/gcc-dg/pr108787.c new file mode 100644 index 0000000000..da3b01b8a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108787.c @@ -0,0 +1,27 @@ +/* PR target/108787 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2" } */ + +__attribute__((noipa)) unsigned __int128 +foo (unsigned long long x, unsigned long long y, unsigned long long z, unsigned long long u, unsigned long long v, unsigned long long w) +{ + unsigned __int128 r, d; + r = ((unsigned __int128) x * u); + d = ((unsigned __int128) y * w); + r += d; + d = ((unsigned __int128) z * v); + r += d; + return r; +} + +int +main () +{ + if (__CHAR_BIT__ != 8 || __SIZEOF_LONG_LONG__ != 8 || __SIZEOF_INT128__ != 16) + return 0; + unsigned __int128 x = foo (0x3efe88da491ULL, 0xd105e9b4a44ULL, 0x4efa677b3dbULL, 0x42c052bac7bULL, 0x99638a13199cULL, 0x56b640d064ULL); + if ((unsigned long long) (x >> 64) != 0x000000000309ff93ULL + || (unsigned long long) x != 0xbd5c98fdf2bdbcafULL) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108805.c b/SingleSource/Regression/C/gcc-dg/pr108805.c new file mode 100644 index 0000000000..280d3f5c37 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108805.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target longlong64 } } */ +/* { dg-options "-O" } */ +/* { dg-additional-options "-msse2" { target x86_64-*-* i?86-*-* } } */ + +typedef __INT8_TYPE__ __attribute__((__vector_size__ (4))) U; +typedef __INT32_TYPE__ __attribute__((__vector_size__ (4))) V; +typedef __UINT64_TYPE__ __attribute__((__vector_size__ (8))) W; + +int i; +U h; +W g; + +U +foo (void) +{ + W w = i != g; + V v = __builtin_convertvector (i | w >> 2, V); + U u = (U) v[0] + h; + return u; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108819.c b/SingleSource/Regression/C/gcc-dg/pr108819.c new file mode 100644 index 0000000000..28fa558b26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108819.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/108819 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-ccp -fno-tree-forwprop" } */ + +int a, b; + +int +main () +{ + int d = 1; + for (; b; b++) + if (a < 1) + while (d <= a && a <= 0UL) + { + int *e = &d; + *e = 0; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108855.c b/SingleSource/Regression/C/gcc-dg/pr108855.c new file mode 100644 index 0000000000..f79638f692 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108855.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +int m; + +int +undefined (int); + +__attribute__ ((pure, returns_twice)) int +bar (void) +{ + m = 1; + while (m) + m = 2; + + return m; +} + +int +foo (void) +{ + return undefined (bar ()); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108862.c b/SingleSource/Regression/C/gcc-dg/pr108862.c new file mode 100644 index 0000000000..065099e4d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108862.c @@ -0,0 +1,27 @@ +/* PR target/108862 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2" } */ + +unsigned long long a[2] = { 0x04a13945d898c296ULL, 0x0000100000000fffULL }; +unsigned long long b[4] = { 0x04a13945d898c296ULL, 0, 0, 0x0000100000000fffULL }; + +__attribute__((noipa)) unsigned __int128 +foo (int x, unsigned long long *y, unsigned long long *z) +{ + unsigned __int128 w = 0; + for (int i = 0; i < x; i++) + w += (unsigned __int128)*y++ * (unsigned __int128)*z--; + return w; +} + +int +main () +{ + unsigned __int128 x = foo (1, &a[0], &a[1]); + unsigned __int128 y = foo (2, &b[0], &b[3]); + if ((unsigned long long) (x >> 64) != 0x0000004a13945dd3ULL + || (unsigned long long) x != 0x9b1c8443b3909d6aULL + || x != y) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108868.c b/SingleSource/Regression/C/gcc-dg/pr108868.c new file mode 100644 index 0000000000..b6f1a79ded --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108868.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int x; +int vfork (void) __attribute__((__leaf__, __returns_twice__)); +int fork (void); +void bar (int, int, int *); + +void +foo (void) +{ + int b = 0; + int r = x ? vfork () : fork (); + bar (r, x, &b); +} + +/* { dg-final { scan-tree-dump "ABNORMAL_DISPATCHER" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr108947.c b/SingleSource/Regression/C/gcc-dg/pr108947.c new file mode 100644 index 0000000000..2fe2f5c6e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108947.c @@ -0,0 +1,21 @@ +/* PR target/108947 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-forward-propagate -Wno-psabi" } */ + +typedef unsigned short __attribute__((__vector_size__ (2 * sizeof (short)))) V; + +__attribute__((__noipa__)) V +foo (V v) +{ + V w = 3 > (v & 3992); + return w; +} + +int +main () +{ + V w = foo ((V) { 0, 9 }); + if (w[0] != 0xffff || w[1] != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr108970.c b/SingleSource/Regression/C/gcc-dg/pr108970.c new file mode 100644 index 0000000000..7def8afd5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr108970.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-loop-vectorize -fno-tree-dce -fno-tree-scev-cprop" } */ + +int m; + +__attribute__ ((noinline, returns_twice)) void +empty (void) +{ +} + +void +foo (void) +{ + while (m < 1) + { + empty (); + ++m; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109008.c b/SingleSource/Regression/C/gcc-dg/pr109008.c new file mode 100644 index 0000000000..9c5614b44c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109008.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/109008 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ffinite-math-only -fexcess-precision=standard" } */ + +__attribute__((noipa)) double +foo (double eps) +{ + double d = __DBL_MAX__ + eps; + if (d == __DBL_MAX__) + if (eps > 16.0) + return eps; + return 0.0; +} + +int +main () +{ +#if __DBL_MANT_DIG__ == 53 && __DBL_MAX_EXP__ == 1024 && __DBL_MIN_EXP__ == -1021 \ + && __FLT_EVAL_METHOD__ == 0 + if (foo (0x0.8p+970) == 0.0) + __builtin_abort (); + if (foo (32.0) == 0.0) + __builtin_abort (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109115.c b/SingleSource/Regression/C/gcc-dg/pr109115.c new file mode 100644 index 0000000000..780477105e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109115.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/109115 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a, b; + +int +main () +{ + unsigned short c = a, e = -1; + if (b) + { + unsigned d = (a ^ 1U) / a & c; + int f = (~d >> ~a) / e; + if (a) + f = a; + a = f; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109187.c b/SingleSource/Regression/C/gcc-dg/pr109187.c new file mode 100644 index 0000000000..1ef14a73d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109187.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 --param sched-autopref-queue-depth=1" } */ + +void f(int *a) +{ + for (;;) + asm("" :: "r"(a[-0x10000000]), "r"(a[0x10000000]), "r"(a[0]) : "memory"); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109230.c b/SingleSource/Regression/C/gcc-dg/pr109230.c new file mode 100644 index 0000000000..9c4ff05468 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109230.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/109230 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-psabi" } */ + +#if __SIZEOF_FLOAT__ == __SIZEOF_INT__ +typedef float V __attribute__((vector_size (4 * sizeof (float)))); +typedef int VI __attribute__((vector_size (4 * sizeof (float)))); + +__attribute__((noipa)) V +foo (V x, V y) +{ + V a = x - y; + V b = y + x; + return __builtin_shuffle (b, a, (VI) { 0, 5, 2, 3 }); +} + +int +main () +{ + V a = (V) { 1.0f, 2.0f, 3.0f, 4.0f }; + V b = (V) { 8.0f, 9.0f, 10.0f, 11.0f }; + V c = foo (a, b); + if (c[0] != 9.0f || c[1] != -7.0f || c[2] != 13.0f || c[3] != 15.0f) + __builtin_abort (); +} +#else +int +main () +{ +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr109238.c b/SingleSource/Regression/C/gcc-dg/pr109238.c new file mode 100644 index 0000000000..0cad823720 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109238.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/109238 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +void foo (void *) __attribute__((noreturn)); +void bar (void *); + +void +baz (void *p) +{ + void *c = __builtin_realloc (p, 16); + if (c) + foo (c); + for (;;) + bar (__builtin_realloc (p, 8)); /* { dg-bogus "pointer 'p' may be used after '__builtin_realloc'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109274.c b/SingleSource/Regression/C/gcc-dg/pr109274.c new file mode 100644 index 0000000000..5dbc0232f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109274.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/109274 */ +/* { dg-do compile } */ +/* { dg-options "-O2 " } */ + +float a, b, c; +int d; +float bar (void); + +void +foo (void) +{ + a = 0 * -(2.0f * c); + d = a != a ? 0 : bar (); + b = c; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr109301.c b/SingleSource/Regression/C/gcc-dg/pr109301.c new file mode 100644 index 0000000000..ab26ea6b6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109301.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/109301 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -ffast-math" } */ + +double x[256]; + +void +foo (void) +{ + for (int i = 0; i < 256; ++i) + for (int j = 0; j < 8; ++j) + x[i] = __builtin_pow (x[i], 0.5); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109303.c b/SingleSource/Regression/C/gcc-dg/pr109303.c new file mode 100644 index 0000000000..f91535991c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109303.c @@ -0,0 +1,24 @@ +/* PR ipa/109303 */ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O2" } */ + +struct __attribute__((packed)) A { char c1; short a1[__INT_MAX__]; }; +struct __attribute__((packed)) B { char c2; short a2[100]; }; +struct S { struct A p1; struct B p2[4]; }; +void bar (short int); + +static void +foo (struct S *q) +{ + for (int i = 0; i < q->p1.c1; i++) + for (int j = 0; j < q->p2[i].c2; j++) + bar (q->p2[i].a2[j]); +} + +int +main () +{ + struct S q = {}; + q.p2[0].c2 = q.p2[1].c2 = 3; + foo (&q); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109304.c b/SingleSource/Regression/C/gcc-dg/pr109304.c new file mode 100644 index 0000000000..d435b04d4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109304.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O3 -fprofile-generate -fPIC -fno-semantic-interposition" } */ + +int PyUnicode_FindChar_i; +int PyUnicode_FindChar() +{ + while (PyUnicode_FindChar_i) + if (PyUnicode_FindChar()) + break; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109327.c b/SingleSource/Regression/C/gcc-dg/pr109327.c new file mode 100644 index 0000000000..827b26f148 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109327.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-ccp" } */ + +int a; +void b(int c) {} +int main() +{ + int d = 0, *e = &a; + if (d) { + int *f = e; + while (a) + b(e != f); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109392.c b/SingleSource/Regression/C/gcc-dg/pr109392.c new file mode 100644 index 0000000000..e5bd9d440f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109392.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/109392 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi" } */ + +typedef short __attribute__ ((__vector_size__ (64))) V; +V v, w; +void bar (void) __attribute__((returns_twice)); + +V +foo (V a, V b) +{ + bar (); + b &= v < b; + return (V) { foo (b, w)[3], (V) {}[3] }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109409.c b/SingleSource/Regression/C/gcc-dg/pr109409.c new file mode 100644 index 0000000000..097a511c07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109409.c @@ -0,0 +1,10 @@ +/* PR c/109409 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +void +foo (int n) +{ + const char c[n] = "1"; /* { dg-error "variable-sized object may not be initialized except with an empty initializer" } */ + __builtin_printf (c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109410.c b/SingleSource/Regression/C/gcc-dg/pr109410.c new file mode 100644 index 0000000000..a6401fc100 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109410.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/109410 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +__attribute__((returns_twice)) int baz (int, int); + +int +bar (int x) +{ + return x; +} + +int +foo (int x, int y) +{ + baz (x, y); + int a = bar (x); + return y || a == 42 || a > 42; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109412.c b/SingleSource/Regression/C/gcc-dg/pr109412.c new file mode 100644 index 0000000000..11adce5250 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109412.c @@ -0,0 +1,20 @@ +/* PR c/107682 */ +/* PR c/109412 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +char bar () = {}; /* { dg-error "function 'bar' is initialized like a variable" } */ + /* { dg-error "invalid initializer" "" { target *-*-* } .-1 } */ + /* { dg-message "near initialization for 'bar'" "" { target *-*-* } .-2 } */ +char baz () = { 1 }; /* { dg-error "function 'baz' is initialized like a variable" } */ + /* { dg-error "invalid initializer" "" { target *-*-* } .-1 } */ + /* { dg-message "near initialization for 'baz'" "" { target *-*-* } .-2 } */ +void +foo () +{ + int qux () = {}; /* { dg-error "function 'qux' is initialized like a variable" } */ + /* { dg-error "invalid initializer" "" { target *-*-* } .-1 } */ + /* { dg-message "near initialization for 'qux'" "" { target *-*-* } .-2 } */ + int corge () = { 1 }; /* { dg-error "function 'corge' is initialized like a variable" } */ + /* { dg-error "invalid initializer" "" { target *-*-* } .-1 } */ +} /* { dg-message "near initialization for 'corge'" "" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr109417.c b/SingleSource/Regression/C/gcc-dg/pr109417.c new file mode 100644 index 0000000000..15711dbbaf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109417.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int printf(const char *, ...); +int c, d, *e, f[1][2], g; +int main() { + int h = 0, *a = &h, **b[1] = {&a}; + while (e) + while (g) { + L: + for (h = 0; h < 2; h++) { + while (d) + for (*e = 0; *e < 1;) + printf("0"); + while (c) + ; + f[g][h] = 0; + } + } + if (h) + goto L; + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr109450-1.c b/SingleSource/Regression/C/gcc-dg/pr109450-1.c new file mode 100644 index 0000000000..aec127f2af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109450-1.c @@ -0,0 +1,21 @@ +/* PR c/109450 + * { dg-do run } + * { dg-options "-std=gnu99" } + * */ + +int bar(int n, struct foo* x) /* { dg-warning "not be visible" } */ +{ + int a = n; + struct foo { char buf[n++]; }* p = x; + return a; +} + +int main() +{ + if (1 != bar(1, 0)) + __builtin_abort(); +} + + + + diff --git a/SingleSource/Regression/C/gcc-dg/pr109450-2.c b/SingleSource/Regression/C/gcc-dg/pr109450-2.c new file mode 100644 index 0000000000..06799f6df2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109450-2.c @@ -0,0 +1,18 @@ +/* PR c/109450 + * { dg-do run } + * { dg-options "-std=gnu99" } + * */ + +int bar(int n, struct foo *x) /* { dg-warning "not be visible" } */ +{ + int a = n; + struct foo { char buf[a++]; }* p = x; + return n == a; +} + +int main() +{ + if (bar(1, 0)) + __builtin_abort(); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr109546.c b/SingleSource/Regression/C/gcc-dg/pr109546.c new file mode 100644 index 0000000000..ba8af0f31f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109546.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ + +void foo(void); +static int a, c; +static int *b = &a; +static int **d = &b; +void assert_fail() __attribute__((__noreturn__)); +int main() { + int *e = *d; + if (e == &a || e == &c); + else { + __builtin_unreachable(); + assert_fail(); + } + if (e == &a || e == &c); + else + foo(); +} + +/* { dg-final { scan-tree-dump-not "assert_fail" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/pr109583.c b/SingleSource/Regression/C/gcc-dg/pr109583.c new file mode 100644 index 0000000000..e3fea3d510 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109583.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/109583 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -Wno-psabi" } */ +/* { dg-additional-options "-mno-avx" { target i?86-*-* x86_64-*-* } } */ + +typedef float v8sf __attribute__((vector_size (8 * sizeof (float)))); +typedef int v8si __attribute__((vector_size (8 * sizeof (int)))); + +#if __SIZEOF_INT__ == __SIZEOF_FLOAT__ +v8sf +foo (v8sf x, v8sf y) +{ + v8sf a = x - y; + v8sf b = x + y; + return __builtin_shuffle (a, b, (v8si) { 0, 9, 2, 11, 4, 13, 6, 15 }); +} + +v8sf +bar (v8sf x, v8sf y) +{ + v8sf a = x + y; + v8sf b = x - y; + return __builtin_shuffle (a, b, (v8si) { 0, 9, 2, 11, 4, 13, 6, 15 }); +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr109732-1.c b/SingleSource/Regression/C/gcc-dg/pr109732-1.c new file mode 100644 index 0000000000..de904eac68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109732-1.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* fre1 is disable because it can figure out that the if return value is just `a` */ +/* { dg-options "-O1 -fdisable-tree-fre1" } */ + +/* This code is done this way to have the false edge as 1st + successor edge of BB2. Normally the true edge would be + the first and you would not hit the bug. Also the way PHIs is + done needs to be such that 0 is first. */ +[[gnu::noipa]] +_Bool f3(_Bool a) +{ + if (a==0) + return 0; + else + return a; +} + +int main() +{ + if (f3(0)) + __builtin_abort(); + if (!f3(1)) + __builtin_abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109732.c b/SingleSource/Regression/C/gcc-dg/pr109732.c new file mode 100644 index 0000000000..d8374705cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109732.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* We need to disable passes which might cause cfg cleanup */ +/* { dg-options "-O1 -fgimple -fdisable-tree-ethread -fdisable-tree-fre1" } */ + +/* This code is done this way to have the false edge as 1st + successor edge of BB2. Normally the true edge would be + the first and you would not hit the bug. */ +[[gnu::noipa]] +_Bool __GIMPLE (ssa, startwith("forwprop1")) +f3 (_Bool a) +{ + _Bool i; + _Bool tt; + + __BB(2): + tt_4 = a_1(D) == _Literal (_Bool)0; + if (tt_4 != _Literal (_Bool)0) + goto __BB3; + else + goto __BB4; + + __BB(3): + goto __BB5; + + __BB(4): + goto __BB5; + + __BB(5): + i_2 = __PHI (__BB4: a_1(D), __BB3: _Literal (_Bool)0); + + return i_2; +} + +int main() +{ + if (f3(0)) + __builtin_abort(); + if (!f3(1)) + __builtin_abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr109970.c b/SingleSource/Regression/C/gcc-dg/pr109970.c new file mode 100644 index 0000000000..068c01f792 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr109970.c @@ -0,0 +1,15 @@ +/* PR109970 + * { dg-do compile } + * { dg-options "-Wstringop-overflow" } + * */ + +void bar(int x, char buf[x]); +void foo(int x; char buf[x], int x); + +int main() +{ + char buf[10]; + bar(11, buf); /* { dg-warning "accessing 11 bytes in a region of size 10" } */ + foo(buf, 11); /* { dg-warning "accessing 11 bytes in a region of size 10" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr110038.c b/SingleSource/Regression/C/gcc-dg/pr110038.c new file mode 100644 index 0000000000..0f578b182c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110038.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O --param=tree-reassoc-width=256" } */ + +unsigned a, b; + +void +foo (unsigned c) +{ + a += b + c + 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110117-1.c b/SingleSource/Regression/C/gcc-dg/pr110117-1.c new file mode 100644 index 0000000000..fd9a9e3268 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110117-1.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vrp -fno-tree-ccp -fno-tree-forwprop" } */ +int a, b, d; +unsigned c; +int main() { + char e = -10; + int f = 1, g = 0; + if (a) { + char h = e; + i: + c = ~h - (-g & f || e); + int j = b % c; + g = j % 9; + if (c) { + if (d) + e = 0; + while (!g) + ; + int k = 0; + l: + if (k) + goto i; + } + } + if (e > -10) { + if (g) + f = 0; + goto l; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110117-2.c b/SingleSource/Regression/C/gcc-dg/pr110117-2.c new file mode 100644 index 0000000000..2e35325808 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110117-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-dominator-opts -fno-tree-vrp -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre -fno-tree-copy-prop" } */ +int f() +{ + int t = 0; + return (t & 1) != 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110266.c b/SingleSource/Regression/C/gcc-dg/pr110266.c new file mode 100644 index 0000000000..0b2acb5a79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110266.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +int Hann_i, PsyBufferUpdate_psyInfo_0, PsyBufferUpdate_i; +double *mdct_data; +double PsyBufferUpdate_sfreq; +void PsyBufferUpdate() { + if (PsyBufferUpdate_psyInfo_0 == 4) + for (; Hann_i;) + ; + { + double xr_0 = cos(PsyBufferUpdate_psyInfo_0); + PsyBufferUpdate_sfreq = sin(PsyBufferUpdate_psyInfo_0); + for (; PsyBufferUpdate_psyInfo_0; PsyBufferUpdate_i++) + mdct_data[PsyBufferUpdate_i] = xr_0 * PsyBufferUpdate_sfreq; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr110436.c b/SingleSource/Regression/C/gcc-dg/pr110436.c new file mode 100644 index 0000000000..8e63ca04cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110436.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +#include "pr83089.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr110461.c b/SingleSource/Regression/C/gcc-dg/pr110461.c new file mode 100644 index 0000000000..cd23a2b161 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110461.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +typedef int v4si __attribute__ ((vector_size (4*sizeof(int)))); +typedef short v4hi __attribute__ ((vector_size (4*sizeof(short)))); + +v4hi res; +v4hi a, b; + +void f(void) +{ + v4si t = __builtin_convertvector (a, v4si); + v4si t1 = __builtin_convertvector (b, v4si); + t ^= t1; + res = __builtin_convertvector (t, v4hi); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110496.c b/SingleSource/Regression/C/gcc-dg/pr110496.c new file mode 100644 index 0000000000..3c3d12fb53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110496.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +long contents, f_num; +int decide(); +int f_MV0__x; +void f() { + unsigned char *rptr; + unsigned char valbuf[6]; + rptr = (unsigned char *)contents; + if (decide()) + do { + __builtin_memcpy(valbuf, &f_MV0__x, sizeof(int)); + (&valbuf[0])[4] = (&valbuf[0])[5] = 0; + } while (0); + else { + int MV0__x = f_num; + __builtin_memcpy(valbuf, &MV0__x, sizeof(int)); + (&valbuf[0])[4] = (&valbuf[0])[5] = 0; + } + rptr[1] = valbuf[4]; + rptr[2] = valbuf[5]; + rptr[4] = valbuf[1]; + rptr[5] = valbuf[2]; + __builtin_memset(valbuf, 0, 8); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110506-2.c b/SingleSource/Regression/C/gcc-dg/pr110506-2.c new file mode 100644 index 0000000000..aabca0fa15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110506-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef unsigned uint32_t; +typedef uint32_t uint32x4 __attribute__((vector_size(16))); +typedef struct { + uint32x4 b, d; +} prng_t; +prng_t prng_rand_128_r_x; +int main_flags; +int main() { + uint32_t ref_crc[] = {7, 3}; + uint32x4 e = (prng_rand_128_r_x.b << 27) + (prng_rand_128_r_x.b >> 32 - 27); + prng_rand_128_r_x.d = e; + if (ref_crc[main_flags]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110506.c b/SingleSource/Regression/C/gcc-dg/pr110506.c new file mode 100644 index 0000000000..10dbd4e6ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110506.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct { + long *sp; + long *csp; +} neko_interp_loop_vm; +int neko_interp_loop_vm_2; +void neko_interp_loop() +{ + void *pc[] = {&&LabelAccGlobal, &&LabelPhysCompare, &&LabelTailCall, + &&LabelLoop, &&LabelMakeArray2}; + long *sp, *csp = neko_interp_loop_vm.csp; +LabelAccGlobal: + neko_interp_loop_vm.sp = sp; + neko_interp_loop_vm.csp = csp; + goto * 0; +LabelTailCall: + csp = sp -= neko_interp_loop_vm_2; +LabelMakeArray2: +LabelPhysCompare: +LabelLoop: + goto * 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110508.c b/SingleSource/Regression/C/gcc-dg/pr110508.c new file mode 100644 index 0000000000..a1f8f55b84 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110508.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/110508 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo (unsigned a, unsigned b, unsigned *c, _Bool d) +{ + __builtin_addc (a, b, d, c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110582.c b/SingleSource/Regression/C/gcc-dg/pr110582.c new file mode 100644 index 0000000000..ae0650d3ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110582.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp2" } */ + +int a, b; +int main() { + char c = a = 0; + for (; c != -3; c++) { + int d = 2; + d ^= 2 && a; + b = a == 0 ? d : d / a; + a = b; + } + for (; (1 + 95 << 24) + b + 1 + 686658714L + b - 2297271457;) + ; +} + +/* { dg-final { scan-tree-dump-not "Folding predicate" "vrp2" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr110699.c b/SingleSource/Regression/C/gcc-dg/pr110699.c new file mode 100644 index 0000000000..be7761358c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110699.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __attribute__((__vector_size__(64))) int T; + +void f(void) { + extern char a[64], b[64]; /* { dg-message "previous" "note" } */ + void *p = a; + T q = *(T *)&b[0]; +} + +void g() { + extern char b; /* { dg-error "conflicting types" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110729.c b/SingleSource/Regression/C/gcc-dg/pr110729.c new file mode 100644 index 0000000000..29b8c1c1f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110729.c @@ -0,0 +1,29 @@ +/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ +/* { dg-require-effective-target o_flag_in_section } */ +/* { dg-options "-ffunction-sections -fpatchable-function-entry=2" } */ +/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ + +/* Verify there are three different link_to symbols for three + .section __patchable_function_entries respectively. */ + +int +f () +{ + return 1; +} + +int +g () +{ + return 2; +} + +int +h () +{ + return 3; +} + +/* { dg-final { scan-assembler-times {.section[\t ]*__patchable_function_entries,.*,\.LPFE0} 1 } } */ +/* { dg-final { scan-assembler-times {.section[\t ]*__patchable_function_entries,.*,\.LPFE1} 1 } } */ +/* { dg-final { scan-assembler-times {.section[\t ]*__patchable_function_entries,.*,\.LPFE2} 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110731.c b/SingleSource/Regression/C/gcc-dg/pr110731.c new file mode 100644 index 0000000000..7da905d316 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110731.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/110731 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2" } */ + +__int128 +foo (void) +{ + struct S { __int128 f : 119; } s = { ((__int128) -18014398509481984) << 64 }; + return s.f / 2; +} + +int +main () +{ + if (foo () != (((__int128) -9007199254740992) << 64)) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110755.c b/SingleSource/Regression/C/gcc-dg/pr110755.c new file mode 100644 index 0000000000..c3bfaa61cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110755.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/110755 */ +/* { dg-do run } */ +/* { dg-require-effective-target fenv } */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-O2 -frounding-math" } */ + +#include + +__attribute__((noipa)) float +foo (float x) +{ + if (x > 0.0) + { + x += 0x1p+23; + x -= 0x1p+23; + x = __builtin_fabsf (x); + } + return x; +} + +int +main () +{ +#ifdef FE_DOWNWARD + fesetround (FE_DOWNWARD); + if (__builtin_signbit (foo (0.5))) + __builtin_abort (); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110777.c b/SingleSource/Regression/C/gcc-dg/pr110777.c new file mode 100644 index 0000000000..253c2a44d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110777.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -w" } */ + +void pm_message (int); +int *findOrAddBackgroundInPalette_palette_pnm; +static void findOrAddBackgroundInPalette(unsigned *paletteSizeP, + int *backgroundIndexP) { + if (*paletteSizeP) { + *backgroundIndexP = (*paletteSizeP)++; + pm_message(0); + } + pm_message(findOrAddBackgroundInPalette_palette_pnm[*backgroundIndexP]); +} +void computeColorMap(int *backgroundIndexP) { + unsigned paletteSize; + findOrAddBackgroundInPalette(&paletteSize, backgroundIndexP); +} +int main() { + unsigned backgroundIndex; + _setjmp(); + computeColorMap(&backgroundIndex); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr110875.c b/SingleSource/Regression/C/gcc-dg/pr110875.c new file mode 100644 index 0000000000..4d6ecbca0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110875.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp2" } */ + +void foo(void); +static int a, b; +static int *c = &a, *d; +static unsigned e; +static short f; +static unsigned g(unsigned char h, char i) { return h + i; } +int main() { + d = &a; + int *j = d; + e = -27; + for (; e > 18; e = g(e, 6)) { + a = 0; + for (; a != -3; a--) { + if (0 != a ^ *j) + for (; b; b++) f = -f; + else if (*c) { + foo(); + break; + } + if (!(((e) >= 235) && ((e) <= 4294967269))) { + __builtin_unreachable(); + } + b = 0; + } + } +} + + +/* { dg-final { scan-tree-dump-not "foo" "vrp2" } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-1.c b/SingleSource/Regression/C/gcc-dg/pr110915-1.c new file mode 100644 index 0000000000..c205e0ed79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-1.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x > y) & (x != 0) --> x > y */ + return (x > y) & (x != 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x < y) & (x != UINT_MAX) --> x < y */ + return (x < y) & (x != UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x > y) & (x != INT_MIN) --> x > y */ + return (x > y) & (x != INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x < y) & (x != INT_MAX) --> x < y */ + return (x < y) & (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " != " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-10.c b/SingleSource/Regression/C/gcc-dg/pr110915-10.c new file mode 100644 index 0000000000..283faec0fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-10.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector unsigned or1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) | (x != 0)) --> true */ + return (x <= y) | (x != 0); +} + +vector unsigned or2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) | (x != UINT_MAX) --> true */ + return (x >= y) | (x != UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x <= y) | (x != INT_MIN) --> true */ + return (x <= y) | (x != INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x >= y) | (x != INT_MAX) --> true */ + return (x >= y) | (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " != " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " <= " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >= " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-11.c b/SingleSource/Regression/C/gcc-dg/pr110915-11.c new file mode 100644 index 0000000000..b3636c6aa2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-11.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector unsigned or1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) | (x == 0) --> x <= y */ + return (x <= y) | (x == 0); +} + +vector unsigned or2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) | (x == UINT_MAX) --> x >= y */ + return (x >= y) | (x == UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x <= y) | (x == INT_MIN) --> x <= y */ + return (x <= y) | (x == INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x >= y) | (x == INT_MAX) --> x >= y */ + return (x >= y) | (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " == " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-12.c b/SingleSource/Regression/C/gcc-dg/pr110915-12.c new file mode 100644 index 0000000000..4108fc4631 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-12.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-dce3 -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector unsigned or1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) | (x == 0) --> x <= y */ + return (x <= y) | (x == 0); +} + +vector unsigned or2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) | (x == UINT_MAX) --> x >= y */ + return (x >= y) | (x == UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x <= y) | (x == INT_MIN) --> x <= y */ + return (x <= y) | (x == INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x >= y) | (x == INT_MAX) --> x >= y */ + return (x >= y) | (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " == " "dce3" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-2.c b/SingleSource/Regression/C/gcc-dg/pr110915-2.c new file mode 100644 index 0000000000..8d406121d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x > y) & (x != 0) --> x > y */ + return (x > y) & (x != 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x < y) & (x != UINT_MAX) --> x < y */ + return (x < y) & (x != UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x > y) & (x != INT_MIN) --> x > y */ + return (x > y) & (x != INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x < y) & (x != INT_MAX) --> x < y */ + return (x < y) & (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " != " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-3.c b/SingleSource/Regression/C/gcc-dg/pr110915-3.c new file mode 100644 index 0000000000..3ac70f55c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-3.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x > y) & (x == 0) --> false */ + return (x > y) & (x == 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x < y) & (x == UINT_MAX) --> false */ + return (x < y) & (x == UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x > y) & (x == INT_MIN) --> false */ + return (x > y) & (x == INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x < y) & (x == INT_MAX) --> false */ + return (x < y) & (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " == " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " > " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " < " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-4.c b/SingleSource/Regression/C/gcc-dg/pr110915-4.c new file mode 100644 index 0000000000..7e8528ccee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-4.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x > y) & (x == 0) --> false */ + return (x > y) & (x == 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x < y) & (x == UINT_MAX) --> false */ + return (x < y) & (x == UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x > y) & (x == INT_MIN) --> false */ + return (x > y) & (x == INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x < y) & (x == INT_MAX) --> false */ + return (x < y) & (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " == " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " > " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-5.c b/SingleSource/Regression/C/gcc-dg/pr110915-5.c new file mode 100644 index 0000000000..41f407b7cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-5.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) & (x == 0) --> x == 0 */ + return (x <= y) & (x == 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) & (x == UINT_MAX) --> x == UINT_MAX */ + return (x >= y) & (x == UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x <= y) & (x == INT_MIN) --> x == INT_MIN */ + return (x <= y) & (x == INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x >= y) & (x == INT_MAX) --> x == INT_MAX */ + return (x >= y) & (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " <= " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " >= " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-6.c b/SingleSource/Regression/C/gcc-dg/pr110915-6.c new file mode 100644 index 0000000000..c5b14787bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-6.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed and1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) & (x == 0) --> x == 0 */ + return (x <= y) & (x == 0); +} + +vector signed and2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) & (x == UINT_MAX) --> x == UINT_MAX */ + return (x >= y) & (x == UINT_MAX); +} + +vector signed and3(vector signed x, vector signed y) +{ + /* (x <= y) & (x == INT_MIN) --> x == INT_MIN */ + return (x <= y) & (x == INT_MIN); +} + +vector signed and4(vector signed x, vector signed y) +{ + /* (x >= y) & (x == INT_MAX) --> x == INT_MAX */ + return (x >= y) & (x == INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " <= " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >= " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-7.c b/SingleSource/Regression/C/gcc-dg/pr110915-7.c new file mode 100644 index 0000000000..f6f7645484 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-7.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed or1(vector unsigned x, vector unsigned y) +{ + /* (x > y) | (x != 0) --> x != 0 */ + return (x > y) | (x != 0); +} + +vector signed or2(vector unsigned x, vector unsigned y) +{ + /* (x < y) | (x != UINT_MAX) --> x != UINT_MAX */ + return (x < y) | (x != UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x > y) | (x != INT_MIN) --> x != INT_MIN */ + return (x > y) | (x != INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x < y) | (x != INT_MAX) --> x != INT_MAX */ + return (x < y) | (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " > " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " < " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-8.c b/SingleSource/Regression/C/gcc-dg/pr110915-8.c new file mode 100644 index 0000000000..b6ed99b70a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-8.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed or1(vector unsigned x, vector unsigned y) +{ + /* (x > y) | (x != 0) --> x != 0 */ + return (x > y) | (x != 0); +} + +vector signed or2(vector unsigned x, vector unsigned y) +{ + /* (x < y) | (x != UINT_MAX) --> x != UINT_MAX */ + return (x < y) | (x != UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x > y) | (x != INT_MIN) --> x != INT_MIN */ + return (x > y) | (x != INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x < y) | (x != INT_MAX) --> x != INT_MAX */ + return (x < y) | (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " > " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110915-9.c b/SingleSource/Regression/C/gcc-dg/pr110915-9.c new file mode 100644 index 0000000000..ee4dc4392d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110915-9.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine -Wno-psabi" } */ + +#include + +#define vector __attribute__((vector_size(sizeof(unsigned)*2))) + +vector signed or1(vector unsigned x, vector unsigned y) +{ + /* (x <= y) | (x != 0) --> true */ + return (x <= y) | (x != 0); +} + +vector signed or2(vector unsigned x, vector unsigned y) +{ + /* (x >= y) | (x != UINT_MAX) --> true */ + return (x >= y) | (x != UINT_MAX); +} + +vector signed or3(vector signed x, vector signed y) +{ + /* (x <= y) | (x != INT_MIN) --> true */ + return (x <= y) | (x != INT_MIN); +} + +vector signed or4(vector signed x, vector signed y) +{ + /* (x >= y) | (x != INT_MAX) --> true */ + return (x >= y) | (x != INT_MAX); +} + +/* { dg-final { scan-tree-dump-not " != " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " <= " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " >= " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr110918.c b/SingleSource/Regression/C/gcc-dg/pr110918.c new file mode 100644 index 0000000000..e2dff27e07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr110918.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ + +static char b = 53; +static unsigned c; +void foo(void); +static int(a)(int d, int e) { return (d ^ e) < 0 ? d : d - e; } +int main() { + { + int f = 2; + c = b; + b = 0; + for (; c <= 6;) { + if (f >= 2) + f = 0; + for (; f >= -9; f = a(f, 8)) + if (!(f >= -8 && f <= 0)) + foo(); + } + } +} + + +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/pr111009.c b/SingleSource/Regression/C/gcc-dg/pr111009.c new file mode 100644 index 0000000000..3accd9ac06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr111009.c @@ -0,0 +1,38 @@ +/* PR tree-optimization/111009 */ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-strict-overflow" } */ + +struct dso { + struct dso * next; + int maj; +}; + +__attribute__((noipa)) static void __dso_id__cmp_(void) {} + +__attribute__((noipa)) +static int bug(struct dso * d, struct dso *dso) +{ + struct dso **p = &d; + struct dso *curr = 0; + + while (*p) { + curr = *p; + // prevent null deref below + if (!dso) return 1; + if (dso == curr) return 1; + + int *a = &dso->maj; + // null deref + if (!(a && *a)) __dso_id__cmp_(); + + p = &curr->next; + } + return 0; +} + +__attribute__((noipa)) +int main(void) { + struct dso d = { 0, 0, }; + bug(&d, 0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr111015.c b/SingleSource/Regression/C/gcc-dg/pr111015.c new file mode 100644 index 0000000000..599a14e6ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr111015.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/111015 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2" } */ + +struct S { unsigned a : 4, b : 4; unsigned __int128 c : 70; } d; + +__attribute__((noipa)) void +foo (unsigned __int128 x, unsigned char y, unsigned char z) +{ + d.a = y; + d.b = z; + d.c = x; +} + +int +main () +{ + foo (-1, 12, 5); + if (d.a != 12 + || d.b != 5 + || d.c != (-1ULL | (((unsigned __int128) 0x3f) << 64))) + __builtin_abort (); + foo (0x123456789abcdef0ULL | (((unsigned __int128) 26) << 64), 7, 11); + if (d.a != 7 + || d.b != 11 + || d.c != (0x123456789abcdef0ULL | (((unsigned __int128) 26) << 64))) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr111039.c b/SingleSource/Regression/C/gcc-dg/pr111039.c new file mode 100644 index 0000000000..bec9983b35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr111039.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int _setjmp (); +void abcd (); +void abcde (); +void compiler_corruption_function(int flags) +{ + int nowait = flags & 1048576, isexpand = flags & 8388608; + abcd(); + _setjmp(flags); + if (nowait && isexpand) + flags &= 0; + abcde(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr111070.c b/SingleSource/Regression/C/gcc-dg/pr111070.c new file mode 100644 index 0000000000..1ebc7adf78 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr111070.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +/* common */ +char c; +/* arrays must be 8 byte aligned, regardless of size */ +char c_ary[1]; + +/* data */ +char d = 1; +char d_ary[1] = {1}; + +int main () +{ + if (((unsigned long)&c_ary[0] & 7) != 0) + return 1; + if (((unsigned long)&d_ary[0] & 7) != 0) + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr111082.c b/SingleSource/Regression/C/gcc-dg/pr111082.c new file mode 100644 index 0000000000..46e36e320d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr111082.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-vect-cost-model" } */ +/* { dg-additional-options "-mavx512f" { target { x86_64-*-* i?86-*-* } } } */ + +long minarray2(const long *input) +{ + if (input[0] < input[1]) + return input[0] ; + return input[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr11459-1.c b/SingleSource/Regression/C/gcc-dg/pr11459-1.c new file mode 100644 index 0000000000..1edd94f814 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr11459-1.c @@ -0,0 +1,6 @@ +/* -ansi -std=c99 should mean -std=c99, but the specs reordered the + options. Bug 11459. */ +/* { dg-do compile } */ +/* { dg-options "-ansi -std=c99 -pedantic" } */ + +long long i; diff --git a/SingleSource/Regression/C/gcc-dg/pr11492.c b/SingleSource/Regression/C/gcc-dg/pr11492.c new file mode 100644 index 0000000000..86435a83e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr11492.c @@ -0,0 +1,12 @@ +/* PR11492 */ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ +int main( void ) +{ + unsigned int a; + unsigned char b; + for ( a = 0, b = 2; a > b * 100; a++ ) /* { dg-bogus "comparison of integer expressions of different signedness" } */ + { ; } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr11864-1.c b/SingleSource/Regression/C/gcc-dg/pr11864-1.c new file mode 100644 index 0000000000..b8d7134193 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr11864-1.c @@ -0,0 +1,42 @@ +/* PR optimization/11864 + * Reporter: Kazumoto Kojima + * Summary: [3.3/3.4 regression] miscompiles zero extension and test + * Description: + * gcc-3.3/3.4 -O2 for sh target may miscompile the combination of zero extension + * and test if it's zero. + * + * Testcase tweaked by dank@kegel.com. Not marked as xfail because it's a regression. + */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort(void); + +int val = 0xff00; + +int f(void) +{ + return val; +} + +unsigned char a[1]; + +void foo(void) +{ + a[0] = f() & 255; + + if (!a[0]) + a[0] = f() & 255; + + if (!a[0]) + a[0] = 1 + (f() & 127); +} + +int main(int argc, char **argv) +{ + foo(); + if (!a[0]) + abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr12603.c b/SingleSource/Regression/C/gcc-dg/pr12603.c new file mode 100644 index 0000000000..f7caef2841 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr12603.c @@ -0,0 +1,8 @@ +/* PR 12603: No return statement warning on function that never returns with -O3. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wall -Wextra -Wreturn-type" } */ +int +this_function_never_returns () +{ + for (;;); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr12625-1.c b/SingleSource/Regression/C/gcc-dg/pr12625-1.c new file mode 100644 index 0000000000..9ad9f28897 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr12625-1.c @@ -0,0 +1,13 @@ +/* Warning for assignment used as truth-value should apply for + bit-fields. */ +/* Origin: bug 12625 from nomura at netapp.com */ +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +static struct { int i:8; } s; + +void +foo () +{ + if (s.i = 0) ; /* { dg-warning "parentheses" "warning for bit-field" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr13519-1.c b/SingleSource/Regression/C/gcc-dg/pr13519-1.c new file mode 100644 index 0000000000..1117a0e16c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr13519-1.c @@ -0,0 +1,47 @@ +/* typeof applied to const+nonconst should be nonconst, as should + typeof applied to other arithmetic expressions. Bug 13519. */ +/* Origin: Debian bug report 208981 + from Kalle Olavi Niemitalo , adapted to a testcase by + Joseph Myers . */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void fn(void) +{ + int n; + const int c; + + { __typeof__(n) a1; a1=0; } + { __typeof__(c) a2; a2=0; } /* { dg-error "read-only" "correct error" } */ + { __typeof__((int)n) a3; a3=0; } + { __typeof__((int)c) a4; a4=0; } /* { dg-bogus "read-only" "bogus error" } */ + { __typeof__((const int)n) a5; a5=0; } + { __typeof__((const int)c) a6; a6=0; } + { __typeof__(0) a7; a7=0; } + { __typeof__(1) a8; a8=0; } + + { __typeof__(n+n) b0; b0=0; } + { __typeof__(n+c) b1; b1=0; } + { __typeof__(c+n) b2; b2=0; } + { __typeof__(c+c) b3; b3=0; } + + { __typeof__(0+n) c0; c0=0; } + { __typeof__(0+c) c1; c1=0; } + { __typeof__(n+0) c2; c2=0; } + { __typeof__(c+0) c3; c3=0; } + + { __typeof__(1+n) d0; d0=0; } + { __typeof__(1+c) d1; d1=0; } + { __typeof__(n+1) d2; d2=0; } + { __typeof__(c+1) d3; d3=0; } + + { __typeof__(((int)n)+((int)n)) e0; e0=0; } + { __typeof__(((int)n)+((int)c)) e1; e1=0; } + { __typeof__(((int)c)+((int)n)) e2; e2=0; } + { __typeof__(((int)c)+((int)c)) e3; e3=0; } + + { __typeof__(((const int)n)+((const int)n)) f0; f0=0; } + { __typeof__(((const int)n)+((const int)c)) f1; f1=0; } + { __typeof__(((const int)c)+((const int)n)) f2; f2=0; } + { __typeof__(((const int)c)+((const int)c)) f3; f3=0; } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr13804-1.c b/SingleSource/Regression/C/gcc-dg/pr13804-1.c new file mode 100644 index 0000000000..5fc17f427c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr13804-1.c @@ -0,0 +1,28 @@ +/* Diagnostics for attempts to access a member not in a structure or + union should name the type involved. Bug 13804. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 { int a; }; +union u0 { long b; }; +typedef struct s0 S0; +typedef union u0 U0; + +struct s0 x0; +S0 x1; +union u0 x2; +U0 x3; +struct s0 *x4; +union u0 *x5; + +void +f (void) +{ + x0.c; /* { dg-error "'struct s0' has no member named 'c'" } */ + x1.c; /* { dg-error "'S0' {aka 'struct s0'} has no member named 'c'" } */ + x2.c; /* { dg-error "'union u0' has no member named 'c'" } */ + x3.c; /* { dg-error "'U0' {aka 'union u0'} has no member named 'c'" } */ + x4->c; /* { dg-error "'struct s0' has no member named 'c'" } */ + x5->c; /* { dg-error "'union u0' has no member named 'c'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr14092-1.c b/SingleSource/Regression/C/gcc-dg/pr14092-1.c new file mode 100644 index 0000000000..61fc8f7016 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr14092-1.c @@ -0,0 +1,20 @@ +/* PR c/14092 + * Origin: bonzini@gnu.org + * rejects-valid + */ +/* { dg-do compile } */ + +/* Define this so that we are more portable. The testcase in the + PR failed on 64-bit hosts. */ +__extension__ typedef __INTPTR_TYPE__ intptr_t; + +typedef struct _PLCI { + unsigned char x; + unsigned char buf[1]; +} PLCI; + +void nl_ind(PLCI * plci) +{ + plci->x = -((intptr_t)(plci->buf)) & 3; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr14475.c b/SingleSource/Regression/C/gcc-dg/pr14475.c new file mode 100644 index 0000000000..0feb5e8e61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr14475.c @@ -0,0 +1,10 @@ +/* This used to ICE because there was no null check in + check_bitfield_type_and_width. */ + +struct tree_common +{ + enum tree_code code : 8; /* { dg-error "ISO C forbids forward references to" "forward ref" } */ + /* { dg-error "type of bit-field .code. is a GCC extension" "extension" { target *-*-* } .-1 } */ + /* { dg-warning "narrower than values of its type" "narrower" { target *-*-* } .-2 } */ + /* { dg-error "incomplete type" "incomplete" { target *-*-* } .-3 } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr14649-1.c b/SingleSource/Regression/C/gcc-dg/pr14649-1.c new file mode 100644 index 0000000000..b9fc4b9461 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr14649-1.c @@ -0,0 +1,16 @@ +/* PR c/14649 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wpedantic" } */ + +double atan(double); + +const double pi = 4*atan(1.0); /* { dg-warning "not a constant expression" } */ + +const double ok = 4*__builtin_atan(1.0); + +double foo() +{ + double ok2 = 4*atan(1.0); + return ok2; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr14765-1.c b/SingleSource/Regression/C/gcc-dg/pr14765-1.c new file mode 100644 index 0000000000..d2b341839c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr14765-1.c @@ -0,0 +1,11 @@ +/* Empty statement expressions should get void type. Bug 14765 from + Serge Belyshev . */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int a; +void fun () +{ + a = 0; + a = ({}); /* { dg-error "not ignored" "void stmt expr" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr14796-1.c b/SingleSource/Regression/C/gcc-dg/pr14796-1.c new file mode 100644 index 0000000000..69328a91bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr14796-1.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +int f (int a) { + return (a << 3) << 6; +} + +int g (int b) { + return (b >> 5) << 5; +} + +unsigned long long h (unsigned long long c) { + return (c << 60) >> 60; +} + +int l (int d) { + return (d << 6) >> 6; +} + +/* { dg-final { scan-tree-dump "a << 9" "gimple" } } */ +/* { dg-final { scan-tree-dump "b & -32" "gimple" } } */ +/* { dg-final { scan-tree-dump "c & 15" "gimple" } } */ +/* { dg-final { scan-tree-dump "d << 6" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr14796-2.c b/SingleSource/Regression/C/gcc-dg/pr14796-2.c new file mode 100644 index 0000000000..d9dc4c8dae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr14796-2.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-fdump-tree-gimple" } */ + +int f (int a) { + return (a << 31) << 6; +} + +unsigned int g (unsigned int a) { + return (a >> 7) >> 25; +} + +int h (int b) { + return (b >> 30) >> 30; +} + +long long j (long long c) { + return (c >> 35) << 35; +} +/* { dg-final { scan-tree-dump-times "= 0" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump "b >> 31" "gimple" } } */ +/* { dg-final { scan-tree-dump "c & -(34359738368|0x800000000)" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr14963.c b/SingleSource/Regression/C/gcc-dg/pr14963.c new file mode 100644 index 0000000000..5a494d4c83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr14963.c @@ -0,0 +1 @@ +X Y(Z); /* { dg-error "" "error before" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15236.c b/SingleSource/Regression/C/gcc-dg/pr15236.c new file mode 100644 index 0000000000..b01a4e8587 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15236.c @@ -0,0 +1,9 @@ +/* PR 15236: pedantic switch modifies treatment of non-ISO compliant + enumerations. */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra -pedantic-errors -Wconversion" } */ +typedef enum OMX_ERRORTYPE +{ + OMX_ErrorNone = 0, + OMX_ErrorInsufficientResources = 0x80001000 /* { dg-error "ISO C restricts enumerator values to range of .int." } */ +} OMX_ERRORTYPE; diff --git a/SingleSource/Regression/C/gcc-dg/pr15347.c b/SingleSource/Regression/C/gcc-dg/pr15347.c new file mode 100644 index 0000000000..a75267f7e4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15347.c @@ -0,0 +1,11 @@ +/* { dg-do link } */ +/* { dg-options "-O" } */ + +extern void link_error (void); +int +main () +{ + if ("<12ers" + 1 == 0) + link_error (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr15360-1.c b/SingleSource/Regression/C/gcc-dg/pr15360-1.c new file mode 100644 index 0000000000..f5f8ad55a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15360-1.c @@ -0,0 +1,24 @@ +/* Static declarations followed by extern are OK even if the extern + declaration is initialized. Bug 15360 from hozelda at + yahoo.com. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +static int a; +static int a; +extern int a; +static int a; + +static int b; +extern int b = 1; /* { dg-warning "initialized and declared" "extern init warning" } */ +static int b; +static int b; + +static int c; /* { dg-message "note: previous declaration" } */ +int c; /* { dg-error "non-static" "correct error" } */ + +static int d; /* { dg-message "note: previous declaration" } */ +int d = 1; /* { dg-error "non-static" "correct error" } */ + +void foo (void) { extern int e = 1; } /* { dg-error "has both" "extern init in function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15443-1.c b/SingleSource/Regression/C/gcc-dg/pr15443-1.c new file mode 100644 index 0000000000..d6106b5b35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15443-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +void f () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */ + +int main () +{ + /* This used to cause an ICE. */ + f (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr15443-2.c b/SingleSource/Regression/C/gcc-dg/pr15443-2.c new file mode 100644 index 0000000000..d97fa2573a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15443-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +struct foo { + int bar; +}; + +typedef struct foo* bar; +void f () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */ +int g () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */ +int* h () __attribute__ ((__malloc__)); +void* i () __attribute__ ((__malloc__)); + +struct foo j () __attribute__ ((__malloc__)); /* { dg-warning "ignored" } */ +struct foo* k () __attribute__ ((__malloc__)); +bar l () __attribute__((malloc)); diff --git a/SingleSource/Regression/C/gcc-dg/pr15649-1.c b/SingleSource/Regression/C/gcc-dg/pr15649-1.c new file mode 100644 index 0000000000..090209c916 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15649-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math -O2" } */ + +double foo (double x) +{ + return __builtin_isgreater (x, 0.0) ? 0.0 : x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr15698-1.c b/SingleSource/Regression/C/gcc-dg/pr15698-1.c new file mode 100644 index 0000000000..cbe613c4fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15698-1.c @@ -0,0 +1,25 @@ +/* Test diagnostics for old-style definition not matching prior + prototype are present and give correct location for that prototype + (bug 15698). Original test. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +int foobar (); + +int func (int blah) +{ + char *rindex(); +} + +int foobar () +{ + return 0; +} + +char *rindex(a, b) + register char *a, b; /* { dg-warning "argument 'a' doesn't match built-in prototype" } */ +{ + return 0; +} + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15698-2.c b/SingleSource/Regression/C/gcc-dg/pr15698-2.c new file mode 100644 index 0000000000..3ad60a9a95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15698-2.c @@ -0,0 +1,9 @@ +/* Test diagnostics for old-style definition not matching prior + prototype are present and give correct location for that prototype + (bug 15698). Prototype at inner scope. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void f() { void g(void); } /* { dg-error "prototype declaration" } */ +void g(a) int a; {} /* { dg-error "number of arguments doesn't match prototype" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15698-3.c b/SingleSource/Regression/C/gcc-dg/pr15698-3.c new file mode 100644 index 0000000000..a7a35059cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15698-3.c @@ -0,0 +1,11 @@ +/* Test diagnostics for old-style definition not matching prior + prototype are present and give correct location for that prototype + (bug 15698). Prototype not last declaration. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void f(); +void f(int); /* { dg-error "prototype declaration" } */ +void f(); +void f(a) long a; {} /* { dg-error "argument 'a' doesn't match prototype" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15698-4.c b/SingleSource/Regression/C/gcc-dg/pr15698-4.c new file mode 100644 index 0000000000..f86a35124d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15698-4.c @@ -0,0 +1,9 @@ +/* Test diagnostics for old-style definition not matching prior + prototype are present and give correct location for that prototype + (bug 15698). Unprototyped built-in function with user prototype. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +int isnan(void); /* { dg-error "prototype declaration" } */ +int isnan(a) int a; {} /* { dg-error "number of arguments doesn't match prototype" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15698-5.c b/SingleSource/Regression/C/gcc-dg/pr15698-5.c new file mode 100644 index 0000000000..288404b4b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15698-5.c @@ -0,0 +1,10 @@ +/* Test diagnostics for old-style definition not matching prior + prototype are present and give correct location for that prototype + (bug 15698). Unprototyped built-in function with user prototype at + inner scope. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void f(void) { int isnan(void); } /* { dg-error "prototype declaration" } */ +int isnan(a) int a; {} /* { dg-error "number of arguments doesn't match prototype" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15698-6.c b/SingleSource/Regression/C/gcc-dg/pr15698-6.c new file mode 100644 index 0000000000..efbc2e42db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15698-6.c @@ -0,0 +1,9 @@ +/* Test diagnostics for old-style definition not matching prior + prototype are present and give correct location for that prototype + (bug 15698). Prototyped built-in function, wrong number of + arguments. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +char *strchr(a) const char *a; { return 0; } /* { dg-warning "number of arguments doesn't match built-in prototype" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15698-7.c b/SingleSource/Regression/C/gcc-dg/pr15698-7.c new file mode 100644 index 0000000000..2393eac61a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15698-7.c @@ -0,0 +1,10 @@ +/* Test diagnostics for old-style definition not matching prior + prototype are present and give correct location for that prototype + (bug 15698). Prototyped built-in function, wrong number of + arguments, with explicit prototype as well. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +char *strchr(const char *, int); /* { dg-error "prototype declaration" } */ +char *strchr(a) const char *a; { return 0; } /* { dg-error "number of arguments doesn't match prototype" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15698-8.c b/SingleSource/Regression/C/gcc-dg/pr15698-8.c new file mode 100644 index 0000000000..ee0c3ae465 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15698-8.c @@ -0,0 +1,11 @@ +/* Test diagnostics for old-style definition not matching prior + prototype are present and give correct location for that prototype + (bug 15698). Prototype refined at inner scope with only refinement + conflicting with definition. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +int f(int (*)[]); +int g() { int f(int (*)[2]); } /* { dg-error "prototype declaration" } */ +int f(a) int (*a)[3]; { return 0; } /* { dg-error "argument 'a' doesn't match prototype" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15749-1.c b/SingleSource/Regression/C/gcc-dg/pr15749-1.c new file mode 100644 index 0000000000..e78816f80e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15749-1.c @@ -0,0 +1,8 @@ +/* Flexible array misuses (that are accepted without -pedantic) should + be OK in system headers even with -pedantic-errors. PR 15749 + from Tuomo dot Tikkanen at nokia dot com. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#include "pr15749-1.h" diff --git a/SingleSource/Regression/C/gcc-dg/pr15749-1.h b/SingleSource/Regression/C/gcc-dg/pr15749-1.h new file mode 100644 index 0000000000..db4a259fe9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15749-1.h @@ -0,0 +1,28 @@ +/* Similar to c99-flex-array-3.c, but a system header so should not + have diagnostics even with -pedantic-errors. */ + +#pragma GCC system_header + +struct flex { int a; int b[]; }; +union rf1 { struct flex a; int b; }; +union rf2 { int a; struct flex b; }; +union rf3 { int a; union rf1 b; }; +union rf4 { union rf2 a; int b; }; + +struct t0 { struct flex a; }; +struct t1 { union rf1 a; }; +struct t2 { union rf2 a; }; +struct t3 { union rf3 a; }; +struct t4 { union rf4 a; }; + +void f0 (struct flex[]); +void f1 (union rf1[]); +void f2 (union rf2[]); +void f3 (union rf3[]); +void f4 (union rf4[]); + +struct flex a0[1]; +union rf1 a1[1]; +union rf2 a2[1]; +union rf3 a3[1]; +union rf4 a4[1]; diff --git a/SingleSource/Regression/C/gcc-dg/pr15784-1.c b/SingleSource/Regression/C/gcc-dg/pr15784-1.c new file mode 100644 index 0000000000..38c569d186 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15784-1.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -fdump-tree-gimple" } */ +/* Test for folding abs(x) where appropriate. */ +#define abs(x) x > 0 ? x : -x +extern double fabs (double); + +int a (int x) { + return (abs(x)) >= 0; +} + +int b (int x) { + return (abs(x)) == 0; +} + +int c (int x) { + return (abs(x)) != 0; +} + +int d (int x) { + return 0 != (abs(x)); +} + +int e (int x) { + return 0 == (abs(x)); +} + +int f (int x) { + return 0 <= (abs(x)); +} + +int g (int x) { + return 0 > (abs(x)); +} + +int h (float x) { + return 0.0 > fabs(x); +} + +int i (float x) { + return fabs(x) == -0.0; +} +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 0 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15784-2.c b/SingleSource/Regression/C/gcc-dg/pr15784-2.c new file mode 100644 index 0000000000..471b6044b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15784-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple -ffast-math" } */ +/* Test for folding abs(x) where appropriate. */ +#define abs(x) x > 0 ? x : -x +extern double fabs (double); + +int a (float x) { + return fabs(x) >= 0.0; +} + +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 0 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15784-3.c b/SingleSource/Regression/C/gcc-dg/pr15784-3.c new file mode 100644 index 0000000000..17bf722bfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15784-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* SH4 without -mieee defaults to -ffinite-math-only. */ +/* { dg-options "-fdump-tree-gimple -fno-finite-math-only" } */ +/* Test for folding abs(x) where appropriate. */ +#define abs(x) x > 0 ? x : -x +extern double fabs (double); + +int a (float x) { + return fabs(x) >= 0.0; +} + +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 1 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15784-4.c b/SingleSource/Regression/C/gcc-dg/pr15784-4.c new file mode 100644 index 0000000000..64ee719eb5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15784-4.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +int a (int x) { + return ~x + 1; /* -x */ +} + +int b (int x) { + return -x -1; /* ~x */ +} + +/* { dg-final { scan-tree-dump "~x_..D.;" "optimized" } } */ +/* { dg-final { scan-tree-dump "-x_..D.;" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr15785-1.c b/SingleSource/Regression/C/gcc-dg/pr15785-1.c new file mode 100644 index 0000000000..47cd3d7b01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15785-1.c @@ -0,0 +1,42 @@ +/* { dg-do link } */ + +extern void link_error (); + +void a (int x) { + if (~ (~x) - x) + link_error (); +} +void b (int x) { + if (- (-x) - x) + link_error (); +} + +void c (int x) { + if (!(- (~x) - x)) + link_error (); +} + +void d (int x) { + if (!(~ (-x) - x)) + link_error (); +} + +void e (int x) { + if (x + ~(x - 1)) + link_error (); +} + +void f (int x) { + if (x + ~(x + (-1))) + link_error (); +} + +int main (int argc, char *argv[]) { + a(argc); + b(argc); + c(argc); + d(argc); + e(argc); + f(argc); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr15825-1.c b/SingleSource/Regression/C/gcc-dg/pr15825-1.c new file mode 100644 index 0000000000..a4b46d4440 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr15825-1.c @@ -0,0 +1,18 @@ +/* PR middle-end/15825 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned int foo(long long high, int unsigned_p) +{ + int i; + if (high < 0) + if (!unsigned_p) + { + i = 1; + goto t; + } + i = 0; +t: + return i; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr16107.c b/SingleSource/Regression/C/gcc-dg/pr16107.c new file mode 100644 index 0000000000..a54d9e1902 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr16107.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +double t (double x) +{ + x = -x; + x = cos (x); + x = -x; + x = cosh (x); + return x; +} + +/* { dg-final { scan-tree-dump-not "-x" "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr16194.c b/SingleSource/Regression/C/gcc-dg/pr16194.c new file mode 100644 index 0000000000..8b44922401 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr16194.c @@ -0,0 +1,78 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* { dg-bogus "internal compiler error" "ICE" { target *-*-* } 0 } */ + +#undef SKIP +#define ASMDECL __asm (REG); +#define CLOBBER_LIST : REG +#define INP_CLOBBER_LIST : CLOBBER_LIST +#if defined (__alpha__) +# define REG "$1" +#elif defined (__CRIS__) || defined (__sh__) +# define REG "r10" +#elif defined (__hppa__) +# define REG "%r10" +#elif defined (__i386__) +# define REG "%eax" +#elif defined (__MMIX__) +# define REG "$8" +#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \ + || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2) +# define REG "6" +#elif defined (__x86_64__) +# define REG "rax" +#elif defined (__m68k__) +# define REG "%d0" +#else +/* Make this test harmless for any target not recognized above. */ +# define SKIP 1 +#endif + +#ifndef SKIP + +struct A +{ + int a; +}; + +struct B +{ + struct A b[3]; +}; + +struct C +{ + struct B c; +}; + +void bug (void) +{ + register char* dst ASMDECL; + __asm__ ("":"=g"(*dst): : REG); +} + +/* The tree optimizers currently prevent us from finding an overlap - + we end up using a copy of dst rather than dst. + But at least make sure we don't get an ICE. */ +void bug2 (void) +{ + register char* dst ASMDECL; + __asm__ ("": :"g"(*dst) CLOBBER_LIST); +} + +void +foo (void) +{ + register struct C *dst ASMDECL; + __asm__ ("" : "=g"(dst->c.b[1].a) INP_CLOBBER_LIST); +} + +#else + +int main () +{ + return 0; +} + +#endif + diff --git a/SingleSource/Regression/C/gcc-dg/pr16302.c b/SingleSource/Regression/C/gcc-dg/pr16302.c new file mode 100644 index 0000000000..0daa513ffb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr16302.c @@ -0,0 +1,76 @@ +/* PR 16302 */ +/* { dg-do compile } */ +/* { dg-options "-Wlogical-op" } */ +void bar (int); +int +foo (int argc, char *argv[]) +{ + if (argc != 1 || argc != 2) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + if (argc || !argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + if (argc && !argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + bar (argc != 1 || argc != 2); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + bar (argc || !argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + bar (argc && !argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + return (argc != 1 || argc != 2) ? 1 : 0 ; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + return (argc || !argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + return (argc && !argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + + if (argc == 2 && argc == 1) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + if (argc || !argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + if (argc && !argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + bar (argc == 2 && argc == 1); /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + bar (argc || !argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + bar (argc && !argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + return (argc == 2 && argc == 1) ? 1 : 0 ; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + return (argc || !argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + return (argc && !argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + + if (argc == 2 && argc == 1) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + if (argc < 0 && argc > 10) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + if (!argc || argc) return 1; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + if (!argc && argc) return 1; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + bar (argc == 2 && argc == 1); /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + bar (argc < 0 && argc > 10); /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + bar (!argc || argc); /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + bar (!argc && argc); /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + return (argc == 2 && argc == 1) ? 1 : 0 ; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + return (argc < 0 && argc > 10) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + return (!argc || argc) ? 1 : 0; /* { dg-warning "'or' of collectively exhaustive tests is always true" } */ + return (!argc && argc) ? 1 : 0; /* { dg-warning "'and' of mutually exclusive tests is always false" } */ + + return 0; +} + +int +foo2 (int argc) +{ + if (5 != 1 || 5 != 2) return 1; + if (5 < 0 && 5 > 10) return 1; + if (1 || 0) return 1; + if (0 && 1) return 1; + if (2 || !2) return 1; + if (2 && !2) return 1; + if (!(!2) || !(2)) return 1; + if (!(!2) && !(2)) return 1; + bar (5 != 1 || 5 != 2); + bar (5 < 0 && 5 > 10); + bar (1 || 0); + bar (0 && 1); + bar (2 || !2); + bar (2 && !2); + return (5 != 1 || 5 != 2) ? 1 : 0 ; + return (5 < 0 && 5 > 10) ? 1 : 0; + return (1 || 0) ? 1 : 0 ; + return (0 && 1) ? 1 : 0; + return (2 || !2) ? 1 : 0; + return (2 && !2) ? 1 : 0; + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr16973.c b/SingleSource/Regression/C/gcc-dg/pr16973.c new file mode 100644 index 0000000000..83274a186b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr16973.c @@ -0,0 +1,13 @@ +/* We were removing the label "a" because + we were removing the BB for it but forgot + to add back the label. */ + +/* { dg-options "" } */ +/* { dg-require-effective-target label_values } */ + +void +f (void) +{ + static __SIZE_TYPE__ x = &&a - &&b; + a : b : return; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr17024-1.c b/SingleSource/Regression/C/gcc-dg/pr17024-1.c new file mode 100644 index 0000000000..d8bdf012b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17024-1.c @@ -0,0 +1,15 @@ +/* PR middle-end/17024 */ +/* { dg-do compile } */ +/* { dg-options "-funsafe-math-optimizations" } */ + +#define MAX2(a,b) (((a)>(b)) ? (a) : (b)) + +void C(double); + +void i(int k) +{ + double c[1]; + C(MAX2(0.,c[k])); + return; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr17036-1.c b/SingleSource/Regression/C/gcc-dg/pr17036-1.c new file mode 100644 index 0000000000..ea2c9caf6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17036-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +int main () +{ + int R, N = 4; + unsigned int A = 2; + signed int B = 2; + ((B >> N) & 1) ? 1 : 0; + ((A >> N) & 1) ? 1 : 0; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr17055-1.c b/SingleSource/Regression/C/gcc-dg/pr17055-1.c new file mode 100644 index 0000000000..31037ab266 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17055-1.c @@ -0,0 +1,25 @@ +/* PR middle-end/17055. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +/* This test used to abort, because we do an "integer" fold to zero, i.e. + x - x = (T)0 where T is the type of x. Unfortunately, fold_convert + was unable to convert integer_zero_node to the appropriate vector type. */ + +typedef float v4sf __attribute__((vector_size(16))); +typedef int v4si __attribute__((vector_size(16))); + +v4sf ivf, ovf; +v4si ivi, ovi; + +void testf (void) +{ + ovf = ivf - ivf; +} + +void testi (void) +{ + ovi = ivi - ivi; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr17112-1.c b/SingleSource/Regression/C/gcc-dg/pr17112-1.c new file mode 100644 index 0000000000..d43868fe07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17112-1.c @@ -0,0 +1,33 @@ +/* PR middle-end/17112 */ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-O2" } */ + +extern void abort(void); + +typedef struct { + int int24:24 __attribute__ ((packed)); +} myint24; + +myint24 x[3] = { + 0x123456, + 0x789abc, + 0xdef012 +}; + +myint24 y[3]; // starts out as zeros + +void foo() +{ + y[1] = x[1]; +} + +int main() +{ + foo(); + + if (y[0].int24 != 0 || y[2].int24 != 0) + abort(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr17188-1.c b/SingleSource/Regression/C/gcc-dg/pr17188-1.c new file mode 100644 index 0000000000..522a14f7d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17188-1.c @@ -0,0 +1,31 @@ +/* A redefinition of an empty struct should be diagnosed the same as a + redefinition of any other tag, but formerly only s2 and s4 were + diagnosed. Bug 17188. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 { }; /* { dg-message "note: originally defined here" } */ +struct s0; +struct s0 { }; /* { dg-error "redefinition of 'struct s0'" } */ + +struct s1 { }; /* { dg-message "note: originally defined here" } */ +struct s1 { }; /* { dg-error "redefinition of 'struct s1'" } */ + +struct s2 { int a : 1; }; /* { dg-message "note: originally defined here" } */ +struct s2 { int a : 1; }; /* { dg-error "redefinition of 'struct s2'" } */ + +struct s3 { }; /* { dg-message "note: originally defined here" } */ +struct s3 { int a : 1; }; /* { dg-error "redefinition of 'struct s3'" } */ + +struct s4 { int a : 1; }; /* { dg-message "note: originally defined here" } */ +struct s4 { }; /* { dg-error "redefinition of 'struct s4'" } */ + +struct s5 { int a : 1; }; +struct s5; + +struct s6; +struct s6 { int a : 1; }; + +struct s7; +struct s7 { }; diff --git a/SingleSource/Regression/C/gcc-dg/pr17301-1.c b/SingleSource/Regression/C/gcc-dg/pr17301-1.c new file mode 100644 index 0000000000..28968fbb2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17301-1.c @@ -0,0 +1,11 @@ +/* Invalid use of __builtin_va_start should not cause an ICE. Bug + 17301. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int +write_format (char *format, ...) +{ + __builtin_va_list p; + __builtin_va_start (p); /* { dg-error "too few arguments to function 'va_start'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr17301-2.c b/SingleSource/Regression/C/gcc-dg/pr17301-2.c new file mode 100644 index 0000000000..b91a2314b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17301-2.c @@ -0,0 +1,9 @@ +/* Invalid use of __builtin_va_start should not cause an ICE. Bug + 17301. Case with no arguments. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo (char *format, ...) +{ + __builtin_va_start (); /* { dg-error "too few arguments to function '__builtin_va_start'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr17319.c b/SingleSource/Regression/C/gcc-dg/pr17319.c new file mode 100644 index 0000000000..5d39e4c570 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17319.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce" } */ + +typedef unsigned long long HARD_REG_ELT_TYPE; +typedef HARD_REG_ELT_TYPE HARD_REG_SET[2]; +static HARD_REG_SET newpat_used_regs; +int try_combine (void) +{ + HARD_REG_ELT_TYPE *scan_tp_ = newpat_used_regs; + scan_tp_[0] = 0; + scan_tp_[1] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr17322.c b/SingleSource/Regression/C/gcc-dg/pr17322.c new file mode 100644 index 0000000000..705787273b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17322.c @@ -0,0 +1,5 @@ +/* PR 17322 */ + +struct s { int a; int b[1]; }; +struct s x; +int *y = ((struct s *)&x.a)->b; diff --git a/SingleSource/Regression/C/gcc-dg/pr17424-1.c b/SingleSource/Regression/C/gcc-dg/pr17424-1.c new file mode 100644 index 0000000000..893b4af13d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17424-1.c @@ -0,0 +1,5 @@ +/* Test for bug 17424: ICE for sizeof an undeclared variable. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +;int foezis = sizeof tni; /* { dg-error "'tni' undeclared" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr17581-1.c b/SingleSource/Regression/C/gcc-dg/pr17581-1.c new file mode 100644 index 0000000000..b63517c840 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17581-1.c @@ -0,0 +1,30 @@ +/* PR rtl-optimization/17581 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +void abort (void); + +int foo(int x) +{ + unsigned long long tmp = 0; + + switch(x) { + case 21: + tmp |= 1; + tmp |= 2; + tmp |= 8; + break; + default: + break; + } + + return (int)tmp; +} + +int main() +{ + if (foo(21) != 11) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr17635.c b/SingleSource/Regression/C/gcc-dg/pr17635.c new file mode 100644 index 0000000000..d2154c3f95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17635.c @@ -0,0 +1,11 @@ +/* PR 17635 */ +/* Contributed by Devang Patel */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +void foo(int i) +{ + while (1) + if (i) ++i; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr17730-1.c b/SingleSource/Regression/C/gcc-dg/pr17730-1.c new file mode 100644 index 0000000000..8f70ad8055 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17730-1.c @@ -0,0 +1,5 @@ +/* Test formatting of message for invalid lvalue. Bug 17730. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +char *p = &'C'; /* { dg-error "lvalue required as unary '&' operand" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr17844-1.c b/SingleSource/Regression/C/gcc-dg/pr17844-1.c new file mode 100644 index 0000000000..d06bbb6d74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17844-1.c @@ -0,0 +1,20 @@ +/* -fshort-enums should affect only the type with which an enum is + compatible, not the type of the enumeration constants which should + still be int. Bug 17844. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-fshort-enums" } */ + +enum e { A, B }; + +enum e ev; +unsigned char uv; +enum e *ep = &uv; +unsigned char *up = &ev; + +int i; +__typeof__(A) te; +int *ip = &te; +__typeof__(B) *tep = &i; + +int x[((sizeof(A) == sizeof(int)) ? 1 : -1)]; diff --git a/SingleSource/Regression/C/gcc-dg/pr17957.c b/SingleSource/Regression/C/gcc-dg/pr17957.c new file mode 100644 index 0000000000..8e90003dc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr17957.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ +__attribute__ ((vector_size (64))) unsigned char v1, v2, v3; +void +vadd (void) +{ + v1 = v2 + v3; +} +void +test_add (void) +{ + vadd (); +} +void +vsub (void) +{ + v1 = v2 - v3; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18079.c b/SingleSource/Regression/C/gcc-dg/pr18079.c new file mode 100644 index 0000000000..a37dc1880b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18079.c @@ -0,0 +1,33 @@ +/* PR c/18079 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +__attribute__ ((noinline)) +__attribute__ ((always_inline)) +int +fn1 (int r) +{ /* { dg-warning "ignoring attribute .always_inline. because it conflicts with attribute .noinline." } */ + return r & 4; +} + +__attribute__ ((noinline, always_inline)) +int +fn2 (int r) +{ /* { dg-warning "ignoring attribute .always_inline. because it conflicts with attribute .noinline." } */ + return r & 4; +} + +__attribute__ ((always_inline)) +__attribute__ ((noinline)) +inline int +fn3 (int r) +{ /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */ + return r & 8; +} + +__attribute__ ((always_inline, noinline)) +inline int +fn4 (int r) +{ /* { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } */ + return r & 8; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18164.c b/SingleSource/Regression/C/gcc-dg/pr18164.c new file mode 100644 index 0000000000..cc753bbf53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18164.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ +void +f (void) +{ + int x; + asm ("" : "" (x)); /* { dg-error "output operand constraint lacks" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18241-1.c b/SingleSource/Regression/C/gcc-dg/pr18241-1.c new file mode 100644 index 0000000000..a37e77dac6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18241-1.c @@ -0,0 +1,111 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Wextra -O1" } */ + +extern void *memset (void*, int, __SIZE_TYPE__); +extern void abort (void); + +struct radix_tree_root { + unsigned int height; + struct radix_tree_node *rnode; +}; + +struct radix_tree_node { + unsigned int count; + void *slots[64]; + unsigned long tags[2][2]; +}; + +struct radix_tree_path { + struct radix_tree_node *node, **slot; + int offset; +}; + +static unsigned long height_to_maxindex[7] = +{0, 63, 4095, 262143, 16777215, 1073741823, 4294967295}; + +static inline void tag_clear(struct radix_tree_node *node, int tag, int offset) +{ + int nr; + volatile unsigned long *addr; +#if(__SIZEOF_INT__ >= 4) + int mask; +#else + long mask; +#endif + + nr = offset; + addr = &node->tags[tag][0]; + + addr += nr >> 5; + mask = 1 << (nr & 0x1f); + *addr &= ~mask; +} + +void *radix_tree_tag_clear(struct radix_tree_root *root, unsigned long index, int tag) +{ + struct radix_tree_path path[7], *pathp = path; + unsigned int height, shift; + void *ret = 0; + + height = root->height; + if (index > height_to_maxindex[height]) + goto out; + + shift = (height - 1) * 6; + pathp->node = 0; + pathp->slot = &root->rnode; + + while (height > 0) { + int offset; + + if (*pathp->slot == 0) + goto out; + + offset = (index >> shift) & (64-1); + pathp[1].offset = offset; + pathp[1].node = *pathp[0].slot; + pathp[1].slot = (struct radix_tree_node **) + (pathp[1].node->slots + offset); + pathp++; + shift -= 6; + height--; + } + + ret = *pathp[0].slot; + if (ret == 0) + goto out; + + do { + int idx; + + tag_clear(pathp[0].node, tag, pathp[0].offset); + for (idx = 0; idx < 2; idx++) { + if (pathp[0].node->tags[tag][idx]) + goto out; + } + pathp--; + } while (pathp[0].node); +out: + return ret; +} + +int main () +{ + struct radix_tree_root r; + struct radix_tree_node node; + void *p = (void *) 0xdeadbeef; + + r.height = 1; + r.rnode = &node; + + memset (&node, 0, sizeof (node)); + + node.count = 1; + node.slots [13] = p; + + radix_tree_tag_clear (&r, 13, 1); + + if (r.rnode->slots[13] != p) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18241-2.c b/SingleSource/Regression/C/gcc-dg/pr18241-2.c new file mode 100644 index 0000000000..a3ff1de0f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18241-2.c @@ -0,0 +1,65 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Wextra -O1" } */ + +extern void *memset (void*, int, __SIZE_TYPE__); +extern void abort (void); + +struct radix_tree_root { + unsigned int height; + struct radix_tree_node *rnode; +}; + +struct radix_tree_node { + unsigned int count; + void *slots[64]; + unsigned long tags[2]; +}; + +struct radix_tree_path { + struct radix_tree_node *node, **slot; + int offset; +}; + +void radix_tree_tag_clear(struct radix_tree_root *root, unsigned long index) +{ + struct radix_tree_path path[7], *pathp = path; + unsigned int height, shift; + volatile unsigned long *addr; + + height = root->height; + + shift = (height - 1) * 6; + path[0].slot = &root->rnode; + + while (height > 0) { + int offset; + + offset = (index >> shift) & (64-1); + pathp[1].offset = offset; + pathp[1].node = *pathp[0].slot; + pathp[1].slot = (struct radix_tree_node **) + (pathp[1].node->slots + offset); + pathp++; + shift -= 6; + height--; + } + + addr = &(pathp->node->tags[0]) + 1; + *addr = 574; +} + +struct radix_tree_root r; +struct radix_tree_node node; + +int main () +{ + r.height = 1; + r.rnode = &node; + + memset (&node, 0, sizeof (node)); + + node.count = 1; + + radix_tree_tag_clear (&r, 13); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18241-3.c b/SingleSource/Regression/C/gcc-dg/pr18241-3.c new file mode 100644 index 0000000000..869b1e9141 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18241-3.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +void abort (void); + +void radix_tree_tag_clear (int *node) +{ + int *path[2], **pathp = path, height; + volatile int *addr; + + height = 1; + pathp[0] = node; + + while (height > 0) { + pathp[1] = pathp[0]; + pathp++; + height--; + } + + addr = pathp[0]; + *addr = 1; +} + +int main () +{ + int n; + radix_tree_tag_clear (&n); + if (n != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18241-4.c b/SingleSource/Regression/C/gcc-dg/pr18241-4.c new file mode 100644 index 0000000000..ad619377b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18241-4.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +void abort (void); + +int f(int i1243) +{ + int i[2], *i1 = i; + i[0] = 1; + volatile int *i2 = i1; + i2[1] = 1; + i1243 = 0; + return i2[1]+i2[0]; +} + + +int main(void) +{ + if( f(100) != 2) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18241-5.c b/SingleSource/Regression/C/gcc-dg/pr18241-5.c new file mode 100644 index 0000000000..0ddb55f75b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18241-5.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +void abort (void); + +int main () +{ + int a; + volatile int *b = &a; + a = 1; + if (*b != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18479.c b/SingleSource/Regression/C/gcc-dg/pr18479.c new file mode 100644 index 0000000000..493574e8a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18479.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ +struct __attribute__ ((visibility("default"))) Foo { int foo; }; /* { dg-warning "attribute ignored on types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr18501.c b/SingleSource/Regression/C/gcc-dg/pr18501.c new file mode 100644 index 0000000000..8794486eea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18501.c @@ -0,0 +1,20 @@ +/* Expected uninitialized variable warning. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +unsigned bmp_iter_set (); +int something (void); + +void +bitmap_print_value_set (void) +{ + unsigned first; /* { dg-warning "may be used" "conditional in loop" { xfail *-*-* } } */ + + for (; bmp_iter_set (); ) + { + if (!first) + something (); + first = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18502-1.c b/SingleSource/Regression/C/gcc-dg/pr18502-1.c new file mode 100644 index 0000000000..038c8104aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18502-1.c @@ -0,0 +1,7 @@ +/* Test that -trigraphs isn't reordered before -std=gnu99. Bug + 18502. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -trigraphs" } */ + +int a??(2??); diff --git a/SingleSource/Regression/C/gcc-dg/pr18520-1.c b/SingleSource/Regression/C/gcc-dg/pr18520-1.c new file mode 100644 index 0000000000..872d3a9462 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18520-1.c @@ -0,0 +1,11 @@ +/* PR middle-end/18520 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern int isnan (double __value) __attribute__ ((__const__)); + +int gsl_isnan (const double x) +{ + return isnan(x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr18596-1.c b/SingleSource/Regression/C/gcc-dg/pr18596-1.c new file mode 100644 index 0000000000..0d8d290dcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18596-1.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-unit-at-a-time -std=gnu89" } */ + +int f(int i) +{ + static int g(); /* { dg-error "invalid storage class" } */ + static int g() { return i; } /* { dg-error "invalid storage class" } */ + return g(); +} + +int k (int i) +{ + static int g (); /* { dg-error "invalid storage class" } */ + int g () { + return i; + } + + return g (); +} + +int l (int i) +{ + auto int g (); + static int g () { /* { dg-error "invalid storage class" } */ + return i; + } + + static int h () { /* { dg-error "invalid storage class" } */ + return 3; + } + return g () + h (); +} + +int m (int i) +{ + static g (); /* { dg-error "invalid storage class" } */ + static g () { return i; } /* { dg-error "invalid storage class" } */ + return g (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18596-2.c b/SingleSource/Regression/C/gcc-dg/pr18596-2.c new file mode 100644 index 0000000000..9b50d01258 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18596-2.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-funit-at-a-time -std=gnu89" } */ + +int f(int i) +{ + static int g(); /* { dg-error "invalid storage class" } */ + static int g() { return i; } /* { dg-error "invalid storage class" } */ + return g(); +} + +int k (int i) +{ + static int g (); /* { dg-error "invalid storage class" } */ + int g () { + return i; + } + + return g (); +} + +int l (int i) +{ + auto int g (); + static int g () { /* { dg-error "invalid storage class" } */ + return i; + } + + static int h () { /* { dg-error "invalid storage class" } */ + return 3; + } + return g () + h (); +} + +int m (int i) +{ + static g (); /* { dg-error "invalid storage class" } */ + static g () { return i; } /* { dg-error "invalid storage class" } */ + return g (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18596-3.c b/SingleSource/Regression/C/gcc-dg/pr18596-3.c new file mode 100644 index 0000000000..97fae653a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18596-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +int foo () +{ + static g () = 0; /* { dg-error "invalid storage class" } */ + static int f () = 1; /* { dg-error "invalid storage class" } */ + auto int h () = 0; /* { dg-error "initialized like a variable" } */ + /* { dg-error "declared but never defined" "nested" { target *-*-* } .-1 } */ + static int i () = { 0 }; /* { dg-error "invalid storage class" } */ + static int j () = /* { dg-error "invalid storage class" } */ + { 0, 0.0 }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18628.c b/SingleSource/Regression/C/gcc-dg/pr18628.c new file mode 100644 index 0000000000..d365075b72 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18628.c @@ -0,0 +1,31 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +/* PR middle-end/18628 exposed a problem in which cse folded a load + from a jump table into the label that was the target of the branch. + Unfortunately, the indirect jump was moved to a different basic + block, and the LABEL_REF copied to the register wasn't enough to + keep the cfg from optimizing the otherwise-unused label away. So + we ended up with a dangling reference to the label. */ + +int i; + +int main() +{ + for (;;) + { + switch (i) + { + case 0: + case 1: + return 1; + + case 2: + case 3: + return 0; + + case 5: + --i; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18725.c b/SingleSource/Regression/C/gcc-dg/pr18725.c new file mode 100644 index 0000000000..0282d3b61e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18725.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (void) +{ + int x = 1; + asm ("" : "" (x), "" (x)); /* { dg-error "output operand constraint lacks" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr18809-1.c b/SingleSource/Regression/C/gcc-dg/pr18809-1.c new file mode 100644 index 0000000000..5be41809da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18809-1.c @@ -0,0 +1,9 @@ +/* PR c/18809 */ +/* Origin: Andrew Pinski */ + +/* { dg-do compile } */ + +void foo(enum E e) {} /* { dg-error "forward ref" "forward" } */ + /* { dg-warning "declared" "declared" { target *-*-* } .-1 } */ + /* { dg-error "incomplete" "incomplete" { target *-*-* } .-2 } */ +void bar() { foo(0); } diff --git a/SingleSource/Regression/C/gcc-dg/pr18921-1.c b/SingleSource/Regression/C/gcc-dg/pr18921-1.c new file mode 100644 index 0000000000..b8c91aa094 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18921-1.c @@ -0,0 +1,20 @@ +/* PR middle-end/18921 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int foo (int k) +{ + unsigned char j = 0; + (k ? 0 : j++) == -1; + return j; +} + +int main () +{ + if (!foo (0)) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr18928-1.c b/SingleSource/Regression/C/gcc-dg/pr18928-1.c new file mode 100644 index 0000000000..406b2fcabb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18928-1.c @@ -0,0 +1,20 @@ +/* PR rtl-optimization/18928 */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ + +const char *toHex( unsigned short u ) +{ + static char hexVal[5]; + int i = 3; + while ( i >= 0 ) { + unsigned short hex = (u & 0x000f); + if ( hex < 0x0a ) + hexVal[i] = '0'+hex; + else + hexVal[i] = 'A'+(hex-0x0a); + i--; + } + hexVal[4] = '\0'; + return hexVal; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr18963-1.c b/SingleSource/Regression/C/gcc-dg/pr18963-1.c new file mode 100644 index 0000000000..df43c6543f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr18963-1.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "" } */ + +static int barf (); + +int foo () +{ + auto int barf (); + int j = 4; + + int barf () { + return j; + } + + return barf (); +} + +static int barf () { + return 3; +} + +extern void exit (int); +extern void abort (); + +int main (int argc, char *argv[]) { + if (foo () != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr19105.c b/SingleSource/Regression/C/gcc-dg/pr19105.c new file mode 100644 index 0000000000..75db50759f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19105.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/19105 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-reassoc1-details" } */ + +enum e +{ + a, b, c, d, e, f, g, h +}; + +int range1 (enum e v, int x) +{ + return x && v != c && v != d && v != e; +} + +int range2 (enum e v, int x) +{ + return x && (v != c && v != d && v != e); +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests v_\[0-9\]*.D. -.2, 2. and -.3, 4.\[\n\r\]* into|Optimizing range tests v_\[0-9\]*.D. -.2, 2. and -.3, 3. and -.4, 4.\[\n\r\]* into" 1 "reassoc1" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr19340.c b/SingleSource/Regression/C/gcc-dg/pr19340.c new file mode 100644 index 0000000000..c75d35d1d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19340.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fschedule-insns2 -fsched2-use-superblocks" } */ +/* { dg-require-effective-target scheduling } */ + +extern double f (double x); + +double g (int a) +{ + int b, c, d, e = 0; + double h; + + for (d = 0; d < a; d++) + for (c = 0; c < a; c++) + b = 1; + + h = (double) e / (double) a; + + if (h) + { + h = 1.0 / h; + h = f (h); + } + else + h = 1.0; + + return h; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr19345.c b/SingleSource/Regression/C/gcc-dg/pr19345.c new file mode 100644 index 0000000000..40c6de4d83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19345.c @@ -0,0 +1,12 @@ +/* We shouldn't crash trying to produce the inlined structure type die debug info. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -g" } */ +inline void bar(char a[], unsigned int l) +{ + asm volatile ("" :: "m" ( *(struct {char x[l]; } *)a)); +} + +void foo(void) +{ + bar (0, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr19402-1.c b/SingleSource/Regression/C/gcc-dg/pr19402-1.c new file mode 100644 index 0000000000..866ac63cb7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19402-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +float test_powif(float x) +{ + return __builtin_powif(x, -1) + + __builtin_powif(x, 0) + + __builtin_powif(x, 1) + + __builtin_powif(x, 2); +} + +double test_powi(double x) +{ + return __builtin_powi(x, -1) + + __builtin_powi(x, 0) + + __builtin_powi(x, 1) + + __builtin_powi(x, 2); +} + +long double test_powil(long double x) +{ + return __builtin_powil(x, -1) + + __builtin_powil(x, 0) + + __builtin_powil(x, 1) + + __builtin_powil(x, 2); +} + +/* { dg-final { scan-assembler-not "__builtin_" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr19402-2.c b/SingleSource/Regression/C/gcc-dg/pr19402-2.c new file mode 100644 index 0000000000..24f1d85b58 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19402-2.c @@ -0,0 +1,83 @@ +/* { dg-do run } */ +/* { dg-options "-fno-inline -Os" } */ +/* { dg-skip-if "long double support is incomplete" { "avr-*-*" } } */ + +void abort(void); + + +float powif(float x, int n) +{ + return __builtin_powif(x, n); +} + +double powi(double x, int n) +{ + return __builtin_powi(x, n); +} + +long double powil(long double x, int n) +{ + return __builtin_powil(x, n); +} + + +float powcif(float x) +{ + return __builtin_powif(x, 5); +} + +double powci(double x) +{ + return __builtin_powi(x, 5); +} + +long double powcil(long double x) +{ + return __builtin_powil(x, 5); +} + + +float powicf(int n) +{ + return __builtin_powif(2.0, n); +} + +double powic(int n) +{ + return __builtin_powi(2.0, n); +} + +long double powicl(int n) +{ + return __builtin_powil(2.0, n); +} + + +int main() +{ + if (__builtin_powi(1.0, 5) != 1.0) + abort(); + if (__builtin_powif(1.0, 5) != 1.0) + abort(); + if (__builtin_powil(1.0, 5) != 1.0) + abort(); + if (powci(1.0) != 1.0) + abort(); + if (powcif(1.0) != 1.0) + abort(); + if (powcil(1.0) != 1.0) + abort(); + if (powi(1.0, -5) != 1.0) + abort(); + if (powif(1.0, -5) != 1.0) + abort(); + if (powil(1.0, -5) != 1.0) + abort(); + if (powic(1) != 2.0) + abort(); + if (powicf(1) != 2.0) + abort(); + if (powicl(1) != 2.0) + abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr19633-1.c b/SingleSource/Regression/C/gcc-dg/pr19633-1.c new file mode 100644 index 0000000000..53c3935126 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19633-1.c @@ -0,0 +1,67 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void link_error (void); + +struct S +{ + int w, x, y, z; +}; + +struct T +{ + int r; + struct S s; +}; + +struct S bar (struct S x, struct S *y) +{ + y->w = 4; + return *y; +} + +void +foo (int a, struct T b) +{ + struct S x; + struct S *c = &x; + if (a) + c = &b.s; + b.s.w = 3; + /* This call should be marked as clobbering 'x' and 'b'. */ + *c = bar (*c, c); + if (b.s.w == 3) + abort (); +} + +float Y; + +struct S bar1 (struct S x, struct S y) +{ + Y = 4; + return x; +} + +void +foo1 (int a, struct T b) +{ + struct S x; + struct S *c = &x; + float z, *k = &z; + if (a) + c = &b.s; + b.s.w = 3; + /* This call should NOT be marked as clobbering 'x' and 'b'. */ + x = bar1 (*c, *c); + if (b.s.w != 3) + link_error (); +} + +int main () +{ + struct T b; + foo (3, b); + foo1 (3, b); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr19633.c b/SingleSource/Regression/C/gcc-dg/pr19633.c new file mode 100644 index 0000000000..66a542a219 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19633.c @@ -0,0 +1,52 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +struct S +{ + int w, x, y, z; +}; + +struct T +{ + int r; + struct S s; +}; + +void link_error (void); +int bar (struct S, int); + +void +foo (int a, struct T b) +{ + struct S *c = 0; + + if (a) + c = &b.s; + + b.s.w = 3; + + /* Since 'c' may be pointing to NULL here, we used to flag it as + pointing anywhere, which was forcing the aliaser to mark as + call-clobbered every other variable pointed-to by 'c' ('b' in + this case). This, in turn, caused the insertion of V_MAY_DEFs + for 'b' at this call-site, which prevented constant propagation + from 'b.s.w = 3' to 'if (b.s.w != 3)'. */ + bar (*c, a); + + if (b.s.w != 3) + link_error (); +} + +int main () +{ + struct T b; + foo (3, b); + return 0; +} + +int X; + +int bar (struct S x, int i) +{ + X = 3; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr19967.c b/SingleSource/Regression/C/gcc-dg/pr19967.c new file mode 100644 index 0000000000..68c7e1cb99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19967.c @@ -0,0 +1,26 @@ +/* PR middle-end/19967 + These functions mentioned below are supposed to return char *. + However, fold_builtin_... had bugs that caused the return types to + be const char *. */ + +/* { dg-do compile } */ +/* { dg-options "-pedantic -std=c99" } */ + +char *strchr(const char *, int); +char *strrchr(const char *, int); +char *index(const char *, int); +char *rindex(const char *, int); +char *strpbrk(const char *, const char *); +char *strstr(const char *, const char *); +char *p; + +void +f (void) +{ + p = strchr(__func__, 'f'); + p = strrchr(__func__, 'f'); + p = index(__func__, 'f'); + p = rindex(__func__, 'f'); + p = strpbrk(__func__, "f"); + p = strstr(__func__, "f"); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr19984.c b/SingleSource/Regression/C/gcc-dg/pr19984.c new file mode 100644 index 0000000000..a628e0e91e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19984.c @@ -0,0 +1,17 @@ +/* PR c/19984 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c99 -Wpedantic" } */ + + +double nan (const char *); + +const double nok = nan (""); /* { dg-warning "(not a constant)|(near initialization)" } */ + +const double ok = __builtin_nan (""); + +double +foo () +{ + double ok2 = nan (""); + return ok2; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr19988.c b/SingleSource/Regression/C/gcc-dg/pr19988.c new file mode 100644 index 0000000000..c6fb52f08f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr19988.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized -fdump-tree-original" } */ + +double foo(double x, double y) +{ + return ((x + 0.1234 * y) * (x - 0.1234 * y)); +} + +/* Keep positive constants during folding. */ +/* { dg-final { scan-tree-dump-times " 1.23" 2 "original" } } */ +/* CSE one multiplication. */ +/* { dg-final { scan-tree-dump-times " \\\* " 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20017.c b/SingleSource/Regression/C/gcc-dg/pr20017.c new file mode 100644 index 0000000000..47c048fdc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20017.c @@ -0,0 +1,41 @@ +/* PR rtl-optimization/20017 + + After CSE/GCSE folds a switch statement to an unconditional jump, + cfg_cleanup did not remove a dead jump table, confusing the CFG + layout code later on. */ + +/* { dg-do compile } */ +/* { dg-options "-O1" } */ +/* { dg-options "-O1 -march=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +int +foo (int *buf, int *p) +{ + int result; + const int *tmp; + + if (*buf) + return 1; + + result = 2; + *buf = 2; + tmp = buf; + switch (*tmp) + { + case 3: + case 4: + case 6: + case 14: + return 1; + + case 0: + result = *p; + + /* Fall through. */ + default: + if (result) + return 1; + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr20054.c b/SingleSource/Regression/C/gcc-dg/pr20054.c new file mode 100644 index 0000000000..292b856d01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20054.c @@ -0,0 +1,23 @@ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing" } */ + + +unsigned int *foo (void); + +char * +bar (double *d) +{ + return (char *) (d + 1) - sizeof (unsigned int); +} + +char +baz (double x) +{ + unsigned int h = *foo (); + unsigned int l = *(unsigned int *) bar (&x); + + return (h & ~0x80000000L) == 0x7FF00000 && l == 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr20100.c b/SingleSource/Regression/C/gcc-dg/pr20100.c new file mode 100644 index 0000000000..988fbda642 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20100.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int func_pure (void) __attribute__ ((pure)); +void func_other (int); +int global_int; +void abort (); +void func_other(int a) +{ + if (a != global_int) + abort (); + global_int++; +} + +int func_pure(void) +{ + return global_int; +} + +int +func_loop (int arg) +{ + // global_int ++; + while (arg--) + func_other (func_pure ()); +} + +int main(void) +{ + func_loop(10); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr20115-1.c b/SingleSource/Regression/C/gcc-dg/pr20115-1.c new file mode 100644 index 0000000000..1be99a5c96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20115-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-dom2" } */ + +extern int foo (void) __attribute__((pure)); + +int bar() +{ + int a = foo (); + a += foo (); + return a; +} + +/* Check that we only have one call to foo. */ +/* { dg-final { scan-tree-dump-times "foo" 1 "dom2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20115.c b/SingleSource/Regression/C/gcc-dg/pr20115.c new file mode 100644 index 0000000000..cea4b48685 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20115.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int func_pure (void); +void func_other (int); +int global_int; +int func_pure (void) { return global_int; } +void func_other (int a) +{ + global_int = a + 1; +} +int f(void) +{ + int a; + a = func_pure(); + func_other (a); + a = func_pure (); // We were removing this function call + return a; +} +void abort (void); + +int main(void) +{ + global_int = 10; + if (f() != 11) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr20126.c b/SingleSource/Regression/C/gcc-dg/pr20126.c new file mode 100644 index 0000000000..10aeec74f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20126.c @@ -0,0 +1,56 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +/* PR target/20126 was not really target-specific, but rather a loop's + failure to take into account the possibility that a DEST_ADDR giv + replacement might fail, such as when you attempt to replace a REG + with a PLUS in one of the register_operands of cmpstrqi_rex_1. */ + +extern void abort (void); + +typedef struct { int a; char b[3]; } S; +S c = { 2, "aa" }, d = { 2, "aa" }; + +void * +bar (const void *x, int y, int z) +{ + return (void *) 0; +} + +int +foo (S *x, S *y) +{ + const char *e, *f, *g; + int h; + + h = y->a; + f = y->b; + e = x->b; + + if (h == 1) + return bar (e, *f, x->a) != 0; + + g = e + x->a - h; + while (e <= g) + { + const char *t = e + 1; + /* The pointer E below increases but the bound H stays constant, + letting the latter exceed the size remaining in the argument + pointed to by the formed, which might be detected by + -Wstringop-overread. */ + if (__builtin_memcmp (e, f, h) == 0) + return 1; + e = t; + } + return 0; +} + +int +main (void) +{ + if (foo (&c, &d) != 1) + abort (); + return 0; +} + +/* { dg-prune-output "-Wstringop-overread" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20130-1.c b/SingleSource/Regression/C/gcc-dg/pr20130-1.c new file mode 100644 index 0000000000..43ba57b62c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20130-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ +int z (int a) { + return a * -1; +} + +int x (int a) { + return -1 * a; +} + +int y (int a) { + return -(-1 * -a); +} +/* { dg-final { scan-tree-dump-times "-a" 3 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20216.c b/SingleSource/Regression/C/gcc-dg/pr20216.c new file mode 100644 index 0000000000..1014ef3e45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20216.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +static unsigned int *buffer; + +void FUNC (void) +{ + unsigned int *base; + int i, j; + + for (i = 0; i < 4; i++) + for (j = 0; j < 1600000; j++) + *base++ = buffer[j]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr20245-1.c b/SingleSource/Regression/C/gcc-dg/pr20245-1.c new file mode 100644 index 0000000000..ac88074066 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20245-1.c @@ -0,0 +1,6 @@ +/* Bug 20245: the parse error should not result in an ICE. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo() x; /* { dg-error "expected" } */ +/* { dg-error "-:expected" "" { target *-*-* } .+1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20368-1.c b/SingleSource/Regression/C/gcc-dg/pr20368-1.c new file mode 100644 index 0000000000..4140397c14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20368-1.c @@ -0,0 +1,12 @@ +/* ICE with -Wstrict-prototypes and typeof an undeclared function. + Bug 20368. */ +/* { dg-do compile } */ +/* { dg-options "-Wstrict-prototypes" } */ + +extern __typeof (f) g; /* { dg-error "'f' undeclared here \\(not in a function\\)" } */ + +int +f (x) /* { dg-warning "function declaration isn't a prototype" } */ + float x; +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr20368-2.c b/SingleSource/Regression/C/gcc-dg/pr20368-2.c new file mode 100644 index 0000000000..7faded6bd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20368-2.c @@ -0,0 +1,12 @@ +/* ICE with -Wstrict-prototypes and typeof an undeclared function. + Bug 20368. Test with -Wmissing-prototypes. */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-prototypes" } */ + +extern __typeof (f) g; /* { dg-error "'f' undeclared here \\(not in a function\\)" } */ + +int +f (x) /* { dg-warning "no previous prototype for 'f'" } */ + float x; +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr20368-3.c b/SingleSource/Regression/C/gcc-dg/pr20368-3.c new file mode 100644 index 0000000000..0d0ea6dfcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20368-3.c @@ -0,0 +1,12 @@ +/* ICE with -Wstrict-prototypes and typeof an undeclared function. + Bug 20368. Test with -Wmissing-declarations. */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-declarations" } */ + +extern __typeof (f) g; /* { dg-error "'f' undeclared here \\(not in a function\\)" } */ + +int +f (x) /* { dg-warning "no previous declaration for 'f'" } */ + float x; +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr20672-1.c b/SingleSource/Regression/C/gcc-dg/pr20672-1.c new file mode 100644 index 0000000000..e47fef3fa4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20672-1.c @@ -0,0 +1,7 @@ +/* EOF must cause an error inside a function, not just set parser->error. + Bug 20672. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +int main(void) +{ +int a; /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20922-1.c b/SingleSource/Regression/C/gcc-dg/pr20922-1.c new file mode 100644 index 0000000000..61a63a07da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20922-1.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-wrapv -fstrict-overflow -fdump-tree-gimple" } */ +int f(int i) +{ + return (i - 2) > i; +} + +int g(int i) +{ + return (i + 2) < i; +} + +int h(int i) +{ + return (i + (-2)) > i; +} + +int j(int i) +{ + return (i - (-2)) < i; +} + +int x(double i) +{ + return (i - 2.0) > i; +} + +int y(double i) +{ + return (i + 2.0) < i; +} + +int z(double i) +{ + return (i + (-2.0)) > i; +} +/* { dg-final { scan-tree-dump-times " = 0" 7 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20922-2.c b/SingleSource/Regression/C/gcc-dg/pr20922-2.c new file mode 100644 index 0000000000..88f285d005 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20922-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fwrapv -fdump-tree-gimple" } */ +int f (int i) +{ + return (i - 2) > i; +} + +int g (int i) +{ + return (i + 2) < i; +} + +int h (double i) +{ + return (i + 2.0) <= i; +} +/* { dg-final { scan-tree-dump-times " = 0" 0 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20922-3.c b/SingleSource/Regression/C/gcc-dg/pr20922-3.c new file mode 100644 index 0000000000..349e60ca42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20922-3.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math -fno-wrapv -fstrict-overflow -fdump-tree-gimple" } */ +int f(int i) +{ + return (i - 2) <= i; +} + +int g(int i) +{ + return (i + 2) >= i; +} + +int h(int i) +{ + return (i + (-2)) <= i; +} + +int x(double i) +{ + return (i - 2.0) <= i; +} + +int y(double i) +{ + return (i + 2.0) >= i; +} + +int z(double i) +{ + return (i + (-2.0)) <= i; +} +/* { dg-final { scan-tree-dump-times " = 1" 6 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20922-4.c b/SingleSource/Regression/C/gcc-dg/pr20922-4.c new file mode 100644 index 0000000000..0c9a7fc833 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20922-4.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-wrapv -fstrict-overflow -fdump-tree-gimple" } */ +int f(int i) +{ + return i < (i - 2); +} + +int g(int i) +{ + return i > (i + 2); +} + +int h(int i) +{ + return i < (i + (-2)); +} + +int j(int i) +{ + return i > (i - (-2)); +} + +int x(double i) +{ + return i < (i - 2.0); +} + +int y(double i) +{ + return i > (i + 2.0); +} + +int z(double i) +{ + return i < (i + (-2.0)); +} +/* { dg-final { scan-tree-dump-times " = 0" 7 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20922-5.c b/SingleSource/Regression/C/gcc-dg/pr20922-5.c new file mode 100644 index 0000000000..ee3d4ef5dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20922-5.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fsignaling-nans -fwrapv -fdump-tree-gimple" } */ +int f(int i) +{ + return i < (i - 2); +} + +int g(int i) +{ + return i > (i + 2); +} + +int h (double i) +{ + return i >= i + 2.0; +} + +int j (double i) +{ + return i > i + 2.0; +} +/* { dg-final { scan-tree-dump-times " = 0" 0 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr20922-6.c b/SingleSource/Regression/C/gcc-dg/pr20922-6.c new file mode 100644 index 0000000000..bef485ead6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr20922-6.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math -fno-wrapv -fstrict-overflow -fdump-tree-gimple" } */ +int f(int i) +{ + return i >= (i - 2); +} + +int g(int i) +{ + return i <= (i + 2); +} + +int h(int i) +{ + return i >= (i + (-2)); +} + +int x(double i) +{ + return i >= (i - 2.0); +} + +int y(double i) +{ + return i <= (i + 2.0); +} + +int z(double i) +{ + return i >= (i + (-2.0)); +} +/* { dg-final { scan-tree-dump-times " = 1" 6 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr21032.c b/SingleSource/Regression/C/gcc-dg/pr21032.c new file mode 100644 index 0000000000..4093d53e3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21032.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized -frounding-math" } */ + +void bar(float x); +void foo(double x) +{ + bar(-x); +} + +/* { dg-final { scan-tree-dump-not "-\\(float\\)" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr21041.c b/SingleSource/Regression/C/gcc-dg/pr21041.c new file mode 100644 index 0000000000..34ed14d1e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21041.c @@ -0,0 +1,42 @@ + +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ + +struct args +{ + short int matrix[8][8]; + char **current; +}; + +int test (struct args *args, char *init, int a, int b) +{ + int i, j, k; + + if (!args || a > b || a < 0) + return -1; + + for (i = 0; i < 2; i++) + { + char *dest = *args->current; + char *p = dest; + + for (j = 0; j < 8; j++) + *p++ = *init++; + + for (k = 0; k < 8; k++) + { + short int *blockvals = &args->matrix[k][0]; + dest[0] += blockvals[0]; + dest[1] += blockvals[1]; + dest[2] += blockvals[2]; + dest[3] += blockvals[3]; + dest[4] += blockvals[4]; + dest[5] += blockvals[5]; + dest[6] += blockvals[6]; + dest[7] += blockvals[7]; + } + } + + return 1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr21085.c b/SingleSource/Regression/C/gcc-dg/pr21085.c new file mode 100644 index 0000000000..6a51adb905 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21085.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* This used to cause excessive use, or a stack overflow, depending on which + came first. */ +void foo (void) +{ + int maxstringlen = 1; + int limit = 0, maxblock = 0, maxblockrem = 0; + maxblockrem = (maxstringlen) % (2147483647 + 1); /* { dg-warning "overflow" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr21137.c b/SingleSource/Regression/C/gcc-dg/pr21137.c new file mode 100644 index 0000000000..199555a501 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21137.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-require-effective-target int32plus } */ + +void foo(); + +void test5_1(int e) +{ + if ((e >> 31) & 64) + foo(); +} + +typedef int myint; + +void test5_2(myint e) +{ + if ((e >> 31) & 64) + foo(); +} + +/* { dg-final { scan-tree-dump-times " < 0" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr21282.c b/SingleSource/Regression/C/gcc-dg/pr21282.c new file mode 100644 index 0000000000..427e393850 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21282.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +extern double floor (double); + +long foo (float f) +{ + return (long) floor (f); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr21419.c b/SingleSource/Regression/C/gcc-dg/pr21419.c new file mode 100644 index 0000000000..120ed7f141 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21419.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +const int i = 0; + +void f(void) +{ + __asm__ __volatile__ ("" : "=m" (i)); /* { dg-error "read-only variable" } */ + +} + +void g(const int set) +{ + __asm__ __volatile__ ("" : "=r" (set)); /* { dg-error "read-only parameter" } */ +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr21643.c b/SingleSource/Regression/C/gcc-dg/pr21643.c new file mode 100644 index 0000000000..4e7f93d351 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21643.c @@ -0,0 +1,89 @@ +/* PR tree-optimization/21643 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-reassoc1-details --param logical-op-non-short-circuit=1" } */ + +int +f1 (unsigned char c) +{ + if (c == 0x22 || c == 0x20 || c < 0x20) + return 1; + return 0; +} + +int +f2 (unsigned char c) +{ + if (c == 0x22 || c <= 0x20) + return 1; + return 0; +} + +int +f3 (unsigned char c) +{ + if (c == 0x22) + return 1; + if (c == 0x20) + return 1; + if (c < 0x20) + return 1; + return 0; +} + +int +f4 (unsigned char c) +{ + if (c == 0x22 || c == 0x20 || c < 0x20) + return 2; + return 0; +} + +int +f5 (unsigned char c) +{ + if (c == 0x22 || c <= 0x20) + return 2; + return 0; +} + +int +f6 (unsigned char c) +{ + if (c == 0x22) + return 2; + if (c == 0x20) + return 2; + if (c < 0x20) + return 2; + return 0; +} + +int +f7 (unsigned char c) +{ + if (c != 0x22 && c != 0x20 && c >= 0x20) + return 0; + return 1; +} + +int +f8 (unsigned char c) +{ + if (c == 0x22 && c <= 0x20) + return 0; + return 1; +} + +int +f9 (unsigned char c) +{ + if (c == 0x22) + return 0; + if (c == 0x20) + return 0; + if (c < 0x20) + return 0; + return 1; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests c_\[0-9\]*.D. -.0, 31. and -.32, 32.\[\n\r\]* into" 6 "reassoc1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr21709-1.c b/SingleSource/Regression/C/gcc-dg/pr21709-1.c new file mode 100644 index 0000000000..0d6f20f326 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21709-1.c @@ -0,0 +1,6 @@ +/* PR middle-end/21709 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +double _Complex f(void) { return 1.0iF / 0.0; } + diff --git a/SingleSource/Regression/C/gcc-dg/pr21858.c b/SingleSource/Regression/C/gcc-dg/pr21858.c new file mode 100644 index 0000000000..41cd240c8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21858.c @@ -0,0 +1,15 @@ +/* Fold used to create a GT_EXPR of pointer vs. integer types, + which caused us to ICE in VRP. */ + +/* { dg-do compile } */ +/* { dg-options "-Os -w" } */ + +unsigned int dsdblm_GetBlockAddress(); +void error_LocalAssert(void); +int dsdblm_CreateBlock(unsigned int address) +{ + address = dsdblm_GetBlockAddress(); + if (address >= (void*)0x00020000) + error_LocalAssert(); + return address; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr21921.c b/SingleSource/Regression/C/gcc-dg/pr21921.c new file mode 100644 index 0000000000..d6a8a2a94b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr21921.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -funsafe-math-optimizations" } */ + +void +Q (double *s, double h) +{ + int i; + if (h > 1) + h = h - 1; + + for (i = 1; i < 3; i++) + if (s[i] / h > 0) + s[0] = h, s[i] = s[i] / h; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr22231.c b/SingleSource/Regression/C/gcc-dg/pr22231.c new file mode 100644 index 0000000000..e87943588b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr22231.c @@ -0,0 +1,7 @@ +/* Test case for PR 22231. -c and -MG are invalid together. */ + +/* { dg-do compile } */ +/* { dg-options "-MG -MD -c" } */ +/* { dg-error "may only be used with .-M." ".-MG. incompatible with .-c." { target *-*-* } 0 } */ + +int anything; diff --git a/SingleSource/Regression/C/gcc-dg/pr22308-1.c b/SingleSource/Regression/C/gcc-dg/pr22308-1.c new file mode 100644 index 0000000000..2b3067577b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr22308-1.c @@ -0,0 +1,13 @@ +/* Bug 22308: C_TYPE_FIELDS_READONLY not updated on type variants. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct foo s; +volatile struct foo t; +struct foo { const int z; }; + +void +bar (void) +{ + t = s; /* { dg-error "assignment of read-only variable 't'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr22311-1.c b/SingleSource/Regression/C/gcc-dg/pr22311-1.c new file mode 100644 index 0000000000..4eec5ce9a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr22311-1.c @@ -0,0 +1,6 @@ +/* Bug 22311: ICE with -fshort-enums on shortened operations. */ +/* { dg-do compile } */ +/* { dg-options "-fshort-enums" } */ + +typedef enum { A = 1 } E; +void f(E e, unsigned char c) { c |= e; } diff --git a/SingleSource/Regression/C/gcc-dg/pr22329.c b/SingleSource/Regression/C/gcc-dg/pr22329.c new file mode 100644 index 0000000000..94e32d6959 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr22329.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +int f(int i) +{ + int k = 0; + if (i == 0) + k = i == 0; + return k; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr22335-1.c b/SingleSource/Regression/C/gcc-dg/pr22335-1.c new file mode 100644 index 0000000000..a2a760bfc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr22335-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdelete-null-pointer-checks" } */ +int t(int *a) +{ + int i; + *a = 1; + i = a == 0; + return i; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr22335-2.c b/SingleSource/Regression/C/gcc-dg/pr22335-2.c new file mode 100644 index 0000000000..afba95521b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr22335-2.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +void abort(void) __attribute__((__noreturn__)); +typedef struct { + int container; +} edge_iterator; +struct ls_expr +{ + int index; + int stores; + struct ls_expr * next; +}; +struct ls_expr * pre_ldst_mems; +edge_iterator ei; +void +store_motion (void) +{ + struct ls_expr * ptr, **prev_next_ptr_ptr; + edge_iterator ei1; + edge_iterator ei2; + int a = ptr != ((void *)0); + for (ptr = pre_ldst_mems, prev_next_ptr_ptr = &pre_ldst_mems; + ptr != ((void *)0); + ptr = *prev_next_ptr_ptr) + if (!((ptr)->stores)) + *prev_next_ptr_ptr = ptr->next; + else + prev_next_ptr_ptr = &ptr->next; + + for (ptr = pre_ldst_mems; ptr != 0; ptr = ptr->next) + ; + ei1 = ei; + ei2 = ei1; + if (!ei2.container) + abort (); + ei2 = ei1; + if (!ei2.container) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr22356-1.c b/SingleSource/Regression/C/gcc-dg/pr22356-1.c new file mode 100644 index 0000000000..118b0b2d3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr22356-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu99" } */ +typedef _Complex float GFC_COMPLEX_4; +void product_c4 (GFC_COMPLEX_4 *src, GFC_COMPLEX_4 *dest, int len) +{ + int n; + GFC_COMPLEX_4 result; + for (n = 0; n < len; n++, src += 1) + result *= *src; + *dest = result; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr22458-1.c b/SingleSource/Regression/C/gcc-dg/pr22458-1.c new file mode 100644 index 0000000000..023fb210c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr22458-1.c @@ -0,0 +1,6 @@ +/* { dg-error "expected declaration or statement" "" { target *-*-* } 0 } */ +/* { dg-options "" } */ + +void foo() +{ + __PRETTY_FUNCTION__; diff --git a/SingleSource/Regression/C/gcc-dg/pr23049.c b/SingleSource/Regression/C/gcc-dg/pr23049.c new file mode 100644 index 0000000000..e58cef8fe1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23049.c @@ -0,0 +1,27 @@ +/* This was an ICE in fold where we tried to fold something like, + + a = 0 == 0 ? 0 : 3988292384 + + after doing if-conversion for the vectorizer. Folding "0 == 0" + should have been done before calling fold on the whole rhs of + the above expression. */ + +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-O3 -ftree-vectorize" } */ + +static unsigned short int crc_table[256]; +void AC3_encode_init(void) +{ + unsigned int c, n, k; + for(n=0; n<256; n++) + { + c = n << 8; + for (k = 0; k < 8; k++) + { + if (c & (1 << 15)) + c = ((c << 1) & 0xffff) ^ (((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16)) & 0xffff); + } + crc_table[n] = c; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr23075.c b/SingleSource/Regression/C/gcc-dg/pr23075.c new file mode 100644 index 0000000000..2d85fb0650 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23075.c @@ -0,0 +1,14 @@ +/* PR c/23075 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wreturn-type" } */ + +int +foo (void) +{ + return; /* { dg-warning "with no value" } */ +} /* { dg-bogus "control reaches end" } */ + +int +bar (void) +{ +} /* { dg-warning "control reaches end" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr23165.c b/SingleSource/Regression/C/gcc-dg/pr23165.c new file mode 100644 index 0000000000..49194a1462 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23165.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-Wempty-body" } */ +void foo (void) +{ + if (0) + a: ; /* { dg-warning "empty body in an" } */ + + +} diff --git a/SingleSource/Regression/C/gcc-dg/pr23200.c b/SingleSource/Regression/C/gcc-dg/pr23200.c new file mode 100644 index 0000000000..56bf59c861 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23200.c @@ -0,0 +1,22 @@ +/* PR inline-asm/23200 */ +/* { dg-do compile { target nonpic } } */ +/* { dg-options "-O0" } */ + +static char var; + +void +foo (void) +{ + asm volatile ("" :: "i" (&var + 1)); +} + +typedef int T[]; +typedef T *P; + +int var2; + +void +bar (void) +{ + asm volatile ("" :: "i"(&(*(P)&var2)[1])); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr23295.c b/SingleSource/Regression/C/gcc-dg/pr23295.c new file mode 100644 index 0000000000..1a7c97cac7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23295.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +int foo(int i) +{ + return -i - 5; +} + +/* { dg-final { scan-tree-dump "-5 - i" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr23408.c b/SingleSource/Regression/C/gcc-dg/pr23408.c new file mode 100644 index 0000000000..b552e23360 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23408.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } */ + +int g (); +static __inline__ int f () { return g (); } +int g () { return f (); } diff --git a/SingleSource/Regression/C/gcc-dg/pr23470-1.c b/SingleSource/Regression/C/gcc-dg/pr23470-1.c new file mode 100644 index 0000000000..2c35036d14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23470-1.c @@ -0,0 +1,13 @@ +/* PR middle-end/23470 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-original" } */ + +void link_error (void); + +int f(double a, double b) +{ + if (((a*a) + (b*b))<0) + link_error(); +} + +/* { dg-final { scan-tree-dump-times "if \\(0\\)" 1 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr23518.c b/SingleSource/Regression/C/gcc-dg/pr23518.c new file mode 100644 index 0000000000..3c6bd2754e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23518.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/23518. + make_range used to transform a + 1 < 0 into a < -1 even when a is + signed and -fwrapv is given. Make sure that no longer happens. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +#include + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int a = INT_MAX; + if ((a < 0) || (a + 1 < 0)) + exit (0); + + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr23547.c b/SingleSource/Regression/C/gcc-dg/pr23547.c new file mode 100644 index 0000000000..210fae7ef8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23547.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } */ +void foo() +{ + void bar() + { + bar(); + } +} + +void foo1(int i) +{ + void bar (char c[1][i]) { } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr23584.c b/SingleSource/Regression/C/gcc-dg/pr23584.c new file mode 100644 index 0000000000..0ac388997a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23584.c @@ -0,0 +1,20 @@ +/* Regression test for PR middle-end/23584 */ +/* Verify that dereferencing an absolute address inside of a function + makes that function impure. */ + +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-ipa-pure-const" } */ + +int test1 (void) +{ + return * (volatile int *) 0x1234; +} + +int test2 (void) +{ + int local = * (volatile int *) 0x1234; + return local; +} + +/* { dg-final { scan-ipa-dump-not "found to be pure: test1" "pure-const" } } */ +/* { dg-final { scan-ipa-dump-not "found to be pure: test2" "pure-const" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr23623.c b/SingleSource/Regression/C/gcc-dg/pr23623.c new file mode 100644 index 0000000000..a0a92e0618 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23623.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fstrict-volatile-bitfields -fdump-rtl-final" } */ + +/* With -fstrict-volatile-bitfields, the volatile accesses to bf2.b + and bf3.b must do unsigned int reads/writes. The non-volatile + accesses to bf1.b are not so constrained. */ + +extern struct +{ + unsigned int b : 1; + unsigned int : 31; +} __attribute__((aligned(4))) bf1; + +extern volatile struct +{ + unsigned int b : 1; + unsigned int : 31; +} __attribute__((aligned(4))) bf2; + +extern struct +{ + volatile unsigned int b : 1; + volatile unsigned int : 31; +} __attribute__((aligned(4))) bf3; + +void writeb(void) +{ + bf1.b = 1; + bf2.b = 1; /* volatile read + volatile write */ + bf3.b = 1; /* volatile read + volatile write */ +} + +extern unsigned int x1, x2, x3; + +void readb(void) +{ + x1 = bf1.b; + x2 = bf2.b; /* volatile write */ + x3 = bf3.b; /* volatile write */ +} + +/* There should be 6 volatile MEMs total, but scan-rtl-dump-times counts + the number of match variables and not the number of matches. Since + the parenthesized subexpression in the regexp introduces an extra match + variable, we need to give a count of 12 instead of 6 here. */ +/* { dg-final { scan-rtl-dump-times "mem/v(/.)*:SI" 12 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr23818.c b/SingleSource/Regression/C/gcc-dg/pr23818.c new file mode 100644 index 0000000000..be0bb9a010 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23818.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/23818 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-dominator-opts" } */ + +#include + +extern void abort (void); + +void +foo (int p[100], int k, ...) +{ + int j, *q; + va_list ap; + + va_start (ap, k); + q = va_arg (ap, int *); + for (j = 0; j < 100; j++) + q[j] = p[j] + 10; + va_end(ap); +} + +int +main (void) +{ + int buf[100], buf2[100], i; + for (i = 0; i < 100; i++) + buf[i] = i + 1; + foo (buf, 0, buf2); + for (i = 0; i < 100; i++) + if (buf2[i] != buf[i] + 10) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr23911.c b/SingleSource/Regression/C/gcc-dg/pr23911.c new file mode 100644 index 0000000000..691f3507db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr23911.c @@ -0,0 +1,21 @@ +/* This was a missed optimization in tree constant propagation + that CSE would catch later on. */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-dce3" } */ + +double _Complex *a; +static const double _Complex b[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + +void +test (void) +{ + a[0] = b[0] + b[1]; + a[1] = b[0] + b[1]; + return; +} + +/* After DCE2 which runs after FRE, the expressions should be fully + constant folded. There should be no loads from b left. */ +/* { dg-final { scan-tree-dump-times {(?n)REALPART_EXPR.*= 1\.0e\+0} 2 "dce3" } } */ +/* { dg-final { scan-tree-dump-times {(?n)IMAGPART_EXPR.*= 0\.0} 2 "dce3" } } */ +/* { dg-final { scan-tree-dump-times "= b" 0 "dce3" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr24101-1.i b/SingleSource/Regression/C/gcc-dg/pr24101-1.i new file mode 100644 index 0000000000..45c165539b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24101-1.i @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-ansi" } */ + +# 1 "/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.0/include/stddef.h" 1 3 4 diff --git a/SingleSource/Regression/C/gcc-dg/pr24101-2.i b/SingleSource/Regression/C/gcc-dg/pr24101-2.i new file mode 100644 index 0000000000..501382da4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24101-2.i @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-ansi" } */ + +# diff --git a/SingleSource/Regression/C/gcc-dg/pr24225.c b/SingleSource/Regression/C/gcc-dg/pr24225.c new file mode 100644 index 0000000000..576802ba58 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24225.c @@ -0,0 +1,16 @@ +/* This was an ICE caused by the compiler-generated stack save/restore + statements around s[b]. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fprofile-arcs" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +int +foo (int a, int b) +{ + if (a) + return 1; + { + int s [b]; + return 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr24293.c b/SingleSource/Regression/C/gcc-dg/pr24293.c new file mode 100644 index 0000000000..5bf7ad17ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24293.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fsyntax-only" } */ + +static struct foo x; /* { dg-error "storage size of 'x' isn't known" } */ +static union bar y; /* { dg-error "storage size of 'y' isn't known" } */ + +typedef struct P p; +static p p_obj; /* { dg-error "storage size of 'p_obj' isn't known" } */ + +static enum e e_var; /* { dg-error "storage size of 'e_var' isn't known" } */ + +extern struct undefined_object object; diff --git a/SingleSource/Regression/C/gcc-dg/pr24367.c b/SingleSource/Regression/C/gcc-dg/pr24367.c new file mode 100644 index 0000000000..6486719099 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24367.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fPIC -funroll-loops" } */ + +char * +test (const char *parent, const char *child) +{ + static char rtn_path[1024]; + char *s = rtn_path; + char *s_end = rtn_path + sizeof (rtn_path); + const char *s2 = child; + + while (*s != '\0') + s++; + while ((s < s_end) && (*s2 != '\0')) + *s++ = *s2++; + return (rtn_path); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr24445.c b/SingleSource/Regression/C/gcc-dg/pr24445.c new file mode 100644 index 0000000000..f34784ced2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24445.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O1 -fpic" } */ +extern int *bar (void) __attribute__ ((__pure__)); +extern char *baz; +void +foo (void) +{ + baz = (char *) bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr24561.c b/SingleSource/Regression/C/gcc-dg/pr24561.c new file mode 100644 index 0000000000..20ac00e0ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24561.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +/* { dg-final { scan-assembler "debug_hook" } } */ +static int debug_hook() +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr24574.c b/SingleSource/Regression/C/gcc-dg/pr24574.c new file mode 100644 index 0000000000..93ce0f6842 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24574.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-phiopt2" } */ + +int f0(int i) +{ + if (i == 0) return 0; + return i/10; +} +int f1(int i) +{ + return i?i/10:0; +} + +int f2(int i) +{ + if (i == 0) return 0; + return i%10; +} +int f3(int i) +{ + return i?i%10:0; +} + +int f4(int i) +{ + if (i == 0) return 0; + return i<<10; +} +int f5(int i) +{ + return i?i<<10:0; +} + +/* We should if-convert all functions to carry out the operation + unconditionally. */ +/* { dg-final { scan-tree-dump-not "= PHI" "phiopt2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr24600.c b/SingleSource/Regression/C/gcc-dg/pr24600.c new file mode 100644 index 0000000000..62bb7cad60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24600.c @@ -0,0 +1,16 @@ +/* This used to ICE on s390 due to a old-loop bug. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +char *strcpy (char *dest, const char *src); + +void test (char *Line, int len) +{ + int z; + + for (z = 1; z <= len; z++) + if (Line[z - 1]) + strcpy (Line + z + 1, Line); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr24615.c b/SingleSource/Regression/C/gcc-dg/pr24615.c new file mode 100644 index 0000000000..9e42911750 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24615.c @@ -0,0 +1,27 @@ + +/* { dg-do compile { target fpic } } */ +/* { dg-options "-Os -fPIC" } */ + +void *memset (void *, int, __SIZE_TYPE__); +void *memcpy (void *, const void *, __SIZE_TYPE__); + +char *alloc (int); + +char * +test (int type, int size, char *data, int len) +{ + char *block = alloc (size); + char *bp = block; + + *bp++ = type; + switch (type) + { + case 0: + case 1: + memset (bp, type == 0 ? 0x00 : 0xff, size); + memcpy (bp, data, len); + } + + return block; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr24620.c b/SingleSource/Regression/C/gcc-dg/pr24620.c new file mode 100644 index 0000000000..926a524d46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24620.c @@ -0,0 +1,27 @@ +/* This used to ICE due to a backend problem on s390. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct rgba +{ + unsigned char r; + unsigned char g; + unsigned char b; + unsigned char a; +}; + +void g (struct rgba); + +void f (void) +{ + struct rgba x; + + x.r = 0; + x.g = 128; + x.b = 128; + x.a = 26; + + g (x); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr24683.c b/SingleSource/Regression/C/gcc-dg/pr24683.c new file mode 100644 index 0000000000..23cb3ab4b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24683.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ +const int *block; +void final(unsigned int j) +{ + unsigned int i; + const unsigned char *data = (const unsigned char *)"\0"; + for (i = 0; i < 8; i++) + for (; j + 63 < 1; j += 64) + block = (const int *) &data[j]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr24820.c b/SingleSource/Regression/C/gcc-dg/pr24820.c new file mode 100644 index 0000000000..0482ca3211 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr24820.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double floor (double); +double bar (double sum) +{ + int i; + for (i = 0; i < 256; i++) + sum += floor (0.5 + (i - 128)); + return sum; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr25023.c b/SingleSource/Regression/C/gcc-dg/pr25023.c new file mode 100644 index 0000000000..58d962c298 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25023.c @@ -0,0 +1,12 @@ +/* PR debug/25023 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern unsigned char v; + +float +foo (void) +{ + return v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr25376.c b/SingleSource/Regression/C/gcc-dg/pr25376.c new file mode 100644 index 0000000000..d66f2e1300 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25376.c @@ -0,0 +1,10 @@ +/* PR25376. Verify that a named section is honored. */ +/* { dg-require-named-sections "" } */ + +void simple (void) __attribute__((section("my_named_section"))); +void simple (void) +{ +} + +/* { dg-final { scan-assembler "my_named_section" } } */ +/* { dg-final { scan-assembler-symbol-section {simple$} {^\.?my_named_section|simple\[DS\]|^\"\.opd\"} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr25521.c b/SingleSource/Regression/C/gcc-dg/pr25521.c new file mode 100644 index 0000000000..82b4cd88ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25521.c @@ -0,0 +1,11 @@ +/* PR middle-end/25521 - place `const volatile' objects in read-only + sections. + + { dg-require-effective-target elf } + { dg-do compile } + { dg-skip-if "" { ! const_volatile_readonly_section } } */ + +const volatile int foo = 30; + +/* { dg-final { scan-assembler {.section C,} { target { rx-*-* } } } } */ +/* { dg-final { scan-assembler-symbol-section {^_?foo$} {^\.(const|s?rodata)} { target { ! "rx-*-*" } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr25529.c b/SingleSource/Regression/C/gcc-dg/pr25529.c new file mode 100644 index 0000000000..336d93b0d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25529.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-require-effective-target int32 } */ + +int +f (unsigned t) +{ + return (t * 2) / 2; +} + +/* { dg-final { scan-tree-dump "\& 2147483647" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr25530.c b/SingleSource/Regression/C/gcc-dg/pr25530.c new file mode 100644 index 0000000000..771b36b9c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25530.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-require-effective-target int32 } */ + +int +f (unsigned t) +{ + return (t / 2) * 2; +} + +/* { dg-final { scan-tree-dump "\& -2|4294967294" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr25559.c b/SingleSource/Regression/C/gcc-dg/pr25559.c new file mode 100644 index 0000000000..a8bce657b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25559.c @@ -0,0 +1,10 @@ +/* PR c/25559 */ +/* { dg-do compile } */ + +#define vs(n) __attribute__((vector_size (n))) +int vs (-1) a; /* { dg-error ".vector_size. attribute argument value '-1' is negative" } */ +int vs (0) b; /* { dg-error "zero vector size" } */ +int vs (1) c; /* { dg-error "multiple of component size" } */ +int vs (sizeof (int) / 2) d; /* { dg-error "multiple of component size" } */ +int vs (sizeof (int)) e; +int vs (sizeof (int) * 2) f; diff --git a/SingleSource/Regression/C/gcc-dg/pr25682.c b/SingleSource/Regression/C/gcc-dg/pr25682.c new file mode 100644 index 0000000000..ecf5669403 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25682.c @@ -0,0 +1,29 @@ +/* PR c/25682 */ +/* { dg-do compile } */ +/* { dg-options "-ansi" } */ +/* { dg-require-effective-target alloca } */ +/* Test whether we don't ICE on questionable constructs where offsetof + should have been used instead. */ + +struct S +{ + char a[4]; + int b; +}; + +char c[(char *) &((struct S *) 0)->b - (char *) 0]; /* { dg-warning "variably modified" } */ +char d[(__UINTPTR_TYPE__) &((struct S *) 8)->b]; /* { dg-warning "variably modified" } */ +char e[sizeof (c) == __builtin_offsetof (struct S, b) ? 1 : -1]; +char f[sizeof (d) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1]; + +extern void bar (char *, char *); + +void +foo (void) +{ + char g[(char *) &((struct S *) 0)->b - (char *) 0]; + char h[(__UINTPTR_TYPE__) &((struct S *) 8)->b]; + char i[sizeof (g) == __builtin_offsetof (struct S, b) ? 1 : -1]; + char j[sizeof (h) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1]; + bar (g, h); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr25795-1.c b/SingleSource/Regression/C/gcc-dg/pr25795-1.c new file mode 100644 index 0000000000..88cd88fc50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25795-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fwhole-program" } */ +/* { dg-final { scan-assembler-not "mystr" } } */ + + +extern const char *mystr; /* normally in a header */ +const char *mystr; +int +main() +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr25795.c b/SingleSource/Regression/C/gcc-dg/pr25795.c new file mode 100644 index 0000000000..37ddc0bca9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25795.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fwhole-program" } */ +/* { dg-final { scan-assembler "mystr" } } */ + + +extern const char *mystr; /* normally in a header */ +const char *mystr __attribute__ ((externally_visible)); +int +main() +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr25801.c b/SingleSource/Regression/C/gcc-dg/pr25801.c new file mode 100644 index 0000000000..10b53d33e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25801.c @@ -0,0 +1,44 @@ +/* PR c/25801 */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +int (*a)[]; +struct S *s; +union U *u; +enum E *e; + +void +f (void) +{ + a++; /* { dg-error "increment of pointer to an incomplete type" } */ + ++a; /* { dg-error "increment of pointer to an incomplete type" } */ + a--; /* { dg-error "decrement of pointer to an incomplete type" } */ + --a; /* { dg-error "decrement of pointer to an incomplete type" } */ + a += 1; /* { dg-error "invalid use of array with unspecified bounds" } */ + a -= 1; /* { dg-error "invalid use of array with unspecified bounds" } */ + a - a; /* { dg-error "arithmetic on pointer to an incomplete type" } */ + + s++; /* { dg-error "increment of pointer to an incomplete type" } */ + ++s; /* { dg-error "increment of pointer to an incomplete type" } */ + s--; /* { dg-error "decrement of pointer to an incomplete type" } */ + --s; /* { dg-error "decrement of pointer to an incomplete type" } */ + s += 1; /* { dg-error "invalid use of undefined type" } */ + s -= 1; /* { dg-error "invalid use of undefined type" } */ + s - s; /* { dg-error "arithmetic on pointer to an incomplete type" } */ + + u++; /* { dg-error "increment of pointer to an incomplete type" } */ + ++u; /* { dg-error "increment of pointer to an incomplete type" } */ + u--; /* { dg-error "decrement of pointer to an incomplete type" } */ + --u; /* { dg-error "decrement of pointer to an incomplete type" } */ + u += 1; /* { dg-error "invalid use of undefined type" } */ + u -= 1; /* { dg-error "invalid use of undefined type" } */ + u - u; /* { dg-error "arithmetic on pointer to an incomplete type" } */ + + e++; /* { dg-error "increment of pointer to an incomplete type" } */ + ++e; /* { dg-error "increment of pointer to an incomplete type" } */ + e--; /* { dg-error "decrement of pointer to an incomplete type" } */ + --e; /* { dg-error "decrement of pointer to an incomplete type" } */ + e += 1; /* { dg-error "invalid use of undefined type" } */ + e -= 1; /* { dg-error "invalid use of undefined type" } */ + e - e; /* { dg-error "arithmetic on pointer to an incomplete type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr25805.c b/SingleSource/Regression/C/gcc-dg/pr25805.c new file mode 100644 index 0000000000..2c083f2034 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr25805.c @@ -0,0 +1,21 @@ +/* When -fzero-initialized-in-bss was in effect, we used to only allocate + storage for d1.a. */ +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-skip-if "packed attribute missing for d1" { "epiphany-*-*" } } */ +extern void abort (void); +extern void exit (int); + +struct { int a; int x[]; } d1 = { 0, 0 }; +int d2 = 0; + +int +main () +{ + d2 = 1; + if (sizeof (d1) != sizeof (int)) + abort (); + if (d1.x[0] != 0) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr26004.c b/SingleSource/Regression/C/gcc-dg/pr26004.c new file mode 100644 index 0000000000..35e6a2feb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26004.c @@ -0,0 +1,11 @@ +/* PR c/26004 */ +/* Bug: the return slot optimization was taking the address of s_3, + causing an error. */ + +struct s_3 { short s[3]; } z_3, s_3; +struct s_3 add_struct_3 (struct s_3 s){} +wack_struct_3 (void) +{ + int i; register struct s_3 u = z_3; + u = add_struct_3 (u); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr26427.c b/SingleSource/Regression/C/gcc-dg/pr26427.c new file mode 100644 index 0000000000..add13ca209 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26427.c @@ -0,0 +1,24 @@ +/* { dg-warning "this target does not support" "" {target *86*-*-darwin* } 0 } */ +/* { dg-do run { target { *-*-darwin* } } } */ +/* { dg-options { -fsection-anchors -O } } */ +/* PR target/26427 */ + +struct a {}; +static const int d = 1; +static const struct a b = {}; +static const int c = 1; +int f(const int *, const struct a *, const int*, const int*); + +int g(void) { + return f(&c, &b, &d, &c); +} + +int f(const int *b, const struct a *c, const int *d, const int *e) { + return *b == *d; +} + +int main(void) { + if (!g()) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr26570.c b/SingleSource/Regression/C/gcc-dg/pr26570.c new file mode 100644 index 0000000000..89cf16c80a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26570.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fprofile-generate -fprofile-use -fopt-info-missed-ipa -Wno-missing-profile" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +unsigned test (unsigned a, unsigned b) +{ + return a / b; +} /* { dg-missed "\[^\n\]*execution counts estimated" } */ +/* { dg-prune-output "function body not available" } */ +/* Ignore inlinable warning on AIX. */ +/* { dg-prune-output "function not inlinable" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr26632.c b/SingleSource/Regression/C/gcc-dg/pr26632.c new file mode 100644 index 0000000000..1cc843ebd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26632.c @@ -0,0 +1,14 @@ +/* PR middle-end/26632 + We used to issue a warning for an implicit cast whose result is not + used. */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int g (void); +long h (void); + +void +f (void) +{ + 0 ? h () : g (); /* { dg-bogus "value computed is not used" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr26717.c b/SingleSource/Regression/C/gcc-dg/pr26717.c new file mode 100644 index 0000000000..d16b576ed2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26717.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math" } */ +_Complex float f (_Complex float a) +{ + _Complex float b = a / a; + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr26719.c b/SingleSource/Regression/C/gcc-dg/pr26719.c new file mode 100644 index 0000000000..3c87df17bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26719.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +void abort (void); + +int table[32][256]; + +int main(void) +{ + int i, j; + + for (i = 0; i < 32; i++) + for (j = 0; j < 256; j++) + table[i][j] = ((signed char)j) * i; + + if (table[9][132] != -1116) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr26729-1.c b/SingleSource/Regression/C/gcc-dg/pr26729-1.c new file mode 100644 index 0000000000..2f55ef7f4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26729-1.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +void abort(void); + +__attribute__((noinline)) +int f (unsigned short word) { + return (word & 0x1) && (((unsigned short) (word & 0x8000)) == 0x8000); +} + +int main(void) { + if (!f(0x8001)) + abort(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr26865.c b/SingleSource/Regression/C/gcc-dg/pr26865.c new file mode 100644 index 0000000000..f49d1d29f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26865.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c99" } */ + +void +foo (void) +{ + char *e = alloca (100); /* { dg-warning "implicit declaration|initialization of 'char \\*' from 'int' makes" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr26961-1.c b/SingleSource/Regression/C/gcc-dg/pr26961-1.c new file mode 100644 index 0000000000..56907d89d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26961-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +long long foo(int i, int j) +{ + return i ? (long long)(!j) : 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr26983.c b/SingleSource/Regression/C/gcc-dg/pr26983.c new file mode 100644 index 0000000000..fc919551d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr26983.c @@ -0,0 +1,20 @@ +/* { dg-do link } */ +/* { dg-require-effective-target indirect_jumps } */ + +/* This used to cause a linker failure because GCC would output + assembler code referencing labels that it had not output. */ + +void *jmpbuf[6]; + +void +foo (void) +{ + __builtin_setjmp (jmpbuf); +} + +int +main (void) +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr27003.c b/SingleSource/Regression/C/gcc-dg/pr27003.c new file mode 100644 index 0000000000..7d886a0496 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27003.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-Os" } */ + +unsigned int +foo (unsigned int x) +{ + unsigned int r = x; + while (--x) + r *= x; + return r; +} + +unsigned long long +bar (unsigned long long x) +{ + unsigned long long r = x; + while (--x) + r *= x; + return r; +} + +extern void abort (void); + +int +main (void) +{ + if (foo (5) != 120 || bar (5) != 120) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27095.c b/SingleSource/Regression/C/gcc-dg/pr27095.c new file mode 100644 index 0000000000..1c3566c618 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27095.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* On MIPS, disable generating hints (R_MIPS_JALR) for PIC calls. In addition + to the load from the GOT this also contains the name of the function so for + each call the function name would appear twice. */ +/* { dg-options "-O2 -mno-relax-pic-calls" { target mips*-*-* } } */ +/* For epiphany, use -mshort-calls to avoid loading the address in two + steps using lowpart and highpart. */ +/* { dg-options "-O2 -mshort-calls" { target epiphany-*-* } } */ + +extern void *memset (void *, int, __SIZE_TYPE__); +extern __SIZE_TYPE__ strlen (const char *); + +int +main (int argc, char **argv) +{ + char x[8] = "abc"; + memset (x, argc, strlen (x)); + return 0; +} +/* { dg-final { scan-assembler-not "(?n)strlen\(.*\n\)+.*strlen" { target { ! { powerpc*-*-darwin* hppa*-*-hpux* ia64-*-hpux* alpha*-*-* tic6x-*-* } } } } } */ +/* hppa*-*-hpux* has an IMPORT statement for strlen (plus the branch). */ +/* *-*-darwin* has something similar. */ +/* tic6x emits a comment at the point where the delayed branch happens. */ +/* { dg-final { scan-assembler-not "(?n)strlen\(.*\n\)+.*strlen\(.*\n\)+.*strlen" { target hppa*-*-hpux* tic6x-*-* } } } */ +/* { dg-final { scan-assembler-not "(?n)bl L_strlen\(.*\n\)+.*bl L_strlen" { target powerpc*-*-darwin* } } } */ +/* ia64-*-hpux* has a global statement, a type statement, and the branch. */ +/* { dg-final { scan-assembler-not "(?n)strlen\(.*\n\)+.*strlen\(.*\n\)+.*strlen\(.*\n\)+.*strlen" { target ia64-*-hpux* } } } */ +/* alpha-*-* has a GOT load and the call. */ +/* { dg-final { scan-assembler-not "(?n)jsr .*,strlen\(.*\n\)+.*jsr .*,strlen" { target alpha*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr27132.c b/SingleSource/Regression/C/gcc-dg/pr27132.c new file mode 100644 index 0000000000..25998bcf01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27132.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +int foo(int i) +{ + return i - -1; +} + +/* { dg-final { scan-tree-dump "i \\+ 1" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr27150-1.c b/SingleSource/Regression/C/gcc-dg/pr27150-1.c new file mode 100644 index 0000000000..5a00cf9f90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27150-1.c @@ -0,0 +1,14 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ +extern int link_error (); +int g(int f) +{ + int a = ((&f)!=0); + if (!a) link_error (); + return a; +} + +int main() +{ + g(10); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27301.c b/SingleSource/Regression/C/gcc-dg/pr27301.c new file mode 100644 index 0000000000..cc55c745a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27301.c @@ -0,0 +1,16 @@ +/* PR c/27301 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu89" } */ +/* { dg-require-effective-target alloca } */ + +void +foo (void *ptr, long n) +{ + __asm__ __volatile__ ("" :: "m" (({ struct { char x[n]; } *p = ptr; *p; }))); +} + +void +bar (void *ptr, long n) +{ + __asm__ __volatile__ ("" :: "m" (*({ struct { char x[n]; } *p = ptr; p; }))); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27314.c b/SingleSource/Regression/C/gcc-dg/pr27314.c new file mode 100644 index 0000000000..d99be5eb80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27314.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ffast-math" } */ + +extern double floor (double); + +inline int bar (double x) +{ + return (int) floor (x); +} + +int foo (int i) +{ + return bar (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27331.c b/SingleSource/Regression/C/gcc-dg/pr27331.c new file mode 100644 index 0000000000..9b5c71e843 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27331.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +struct funny_match +{ + int this, other; +}; + +typedef struct rtx { + int code; +} *rtx; + +extern rtx recog_operand[]; +extern int which_alternative; +extern int nalternatives; + +int +constrain_operands (insn_code_num, strict) + int insn_code_num; + int strict; +{ + char *constraints[10]; + struct funny_match funny_match[10]; + register int c; + int funny_match_index; + + which_alternative = 0; + + while (which_alternative < nalternatives) + { + register int opno; + register char *p = constraints[opno]; + int lose = 0; + funny_match_index = 0; + + while (*p && (c = *p++) != ',') + funny_match[funny_match_index++].other = c - '0'; + + if ((((recog_operand[opno])->code) == 12)) + lose = 1; + + if (!lose) + { + while (--funny_match_index >= 0) + recog_operand[funny_match[funny_match_index].other] + = recog_operand[funny_match[funny_match_index].this]; + return 1; + } + which_alternative++; + } + + if (strict == 0) + return constrain_operands (insn_code_num, -1); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr27335.c b/SingleSource/Regression/C/gcc-dg/pr27335.c new file mode 100644 index 0000000000..d08db30bdb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27335.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-loops" } */ + +extern void bar () __attribute__ ((noreturn)); + +inline double +baz (double *x, unsigned int y) +{ + if (y >= 6) + bar (); + return x[y]; +} + +double *a, *b; + +void +foo () +{ + unsigned int r, s, t; + + for (r = 0; r < 2; r++) + for (t = 0; t < 2; t++) + { + for (s = 0; s < 3; s++) + b[r * 2 + t] += baz (a, 3 * s + t); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27363.c b/SingleSource/Regression/C/gcc-dg/pr27363.c new file mode 100644 index 0000000000..40a3c6b352 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27363.c @@ -0,0 +1,39 @@ +/* PR27363. CSE was breaking on the arm store multiple insn used for + structure copies. */ +/* { dg-do run } */ +/* { dg-options "-Os" } */ +extern void abort (void); + +struct snd_mask { + unsigned int bits[6]; +}; + +static int __attribute__((noinline)) +snd_mask_refine(struct snd_mask *mask) +{ + struct snd_mask old; + + old = *mask; + if (mask->bits[0]==0 && mask->bits[1]==0) + return 1; + + return old.bits[0] != mask->bits[0]; +} + +int main(int argc, char *argv[]) +{ + struct snd_mask mask; + + + mask.bits[0] = 23; + mask.bits[1] = 42; + mask.bits[2] = 0; + mask.bits[3] = 0; + mask.bits[4] = 0; + mask.bits[5] = 0; + + + if (snd_mask_refine(&mask)) + abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27382-1.c b/SingleSource/Regression/C/gcc-dg/pr27382-1.c new file mode 100644 index 0000000000..0b25a7b380 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27382-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +void foo() +{ + L: + !&&L; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr27382-2.c b/SingleSource/Regression/C/gcc-dg/pr27382-2.c new file mode 100644 index 0000000000..97365247ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27382-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +void foo() +{ + L: + &&L != 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr27428-1.c b/SingleSource/Regression/C/gcc-dg/pr27428-1.c new file mode 100644 index 0000000000..93a221c847 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27428-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void foo() +{ + goto L; + if (0..) { L: ; } // { dg-error "too many decimal points" } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr27528.c b/SingleSource/Regression/C/gcc-dg/pr27528.c new file mode 100644 index 0000000000..d63238eab0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27528.c @@ -0,0 +1,23 @@ +/* Check the warnings and errors generated for asm operands that aren't + obviously constant but that are constrained to be constants. */ +/* { dg-options "" } */ + +int bar (int); +void +foo (int *x, int y) +{ + int constant = 0; + asm ("# %0" :: "i" (x)); /* { dg-warning "probably does not match" } */ + /* { dg-error "impossible constraint" "" { target *-*-* } .-1 } */ + + asm ("# %0" :: "i" (bar (*x))); /* { dg-warning "probably does not match" } */ + /* { dg-error "impossible constraint" "" { target *-*-* } .-1 } */ + + asm ("# %0" :: "i" (*x + 0x11)); /* { dg-warning "probably does not match" } */ + /* { dg-error "impossible constraint" "" { target *-*-* } .-1 } */ + + asm ("# %0" :: "i" (constant)); /* { dg-warning "probably does not match" } */ + /* { dg-error "impossible constraint" "" { target *-*-* } .-1 } */ + + asm ("# %0" :: "i" (y * 0)); /* folded */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27531-1.c b/SingleSource/Regression/C/gcc-dg/pr27531-1.c new file mode 100644 index 0000000000..b1ea748acb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27531-1.c @@ -0,0 +1,116 @@ +/* PR target/27531 */ +/* This test case stressed the register allocator into reloading a LABEL_REF + on sparc, but didn't add a REG_LABEL note, ultimately causing the assembly + output to reference a label that had been eliminated. */ +/* { dg-do link } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "requires io" { freestanding } } */ + +typedef struct _IO_FILE FILE; +char const *RCSname; +void *Locks; +void * Head; +struct Revpairs{ + struct Revpairs * rnext; +}; +extern char *strchr(const char *s, int c); +extern int fprintf(FILE *, const char *format, ...); +static void getrevpairs (char*); +static int branchflag; +static struct Revpairs *revlist, *Revlst; + +extern int warn(const char *msg, char *argv); +extern int error(const char *msg, int c, char *argv); +extern int recentdate(void *foo, void *bar); + +char *t; +int main (int argc, char **argv) +{ + FILE *out; + char *a, **newargv; + void *currdate; + int descflag, selectflag; + int onlylockflag; + int onlyRCSflag; + int shownames; + descflag = selectflag = shownames = 1; + onlylockflag = onlyRCSflag = 0; + while (a = *++argv, 0<--argc) + { + switch (*a++) + { + case 'L': + onlylockflag = 1; + case 'N': + shownames = 0; + case 'R': + t = a; + case 'b': + branchflag = 1; + case 'r': + getrevpairs(a); + } + if (onlylockflag && !Locks) + fprintf(out, "%s\n", RCSname); + if (shownames) + while( currdate) + recentdate(Head, currdate); + } +} +void getrevpairs(char *argv) +{ + char c; + struct Revpairs * nextrevpair; + int separator; + if (strchr(argv,':')) + separator = ':'; + else + { + if (strchr(argv,'-') ) + warn("`-' is obsolete in `-r%s'; use `:' instead", argv); + separator = '-'; + } + for (;;) + { + nextrevpair->rnext = revlist; + for (;; c = *++argv) + { + switch (c) + { + default: + continue; + case ' ': + case '\t': + case '\n': + break; + case ':': + case '-': + if (c == separator) + continue; + } + break; + } + if (!c) + break; + error("missing `,' near `%c%s'", c, argv+1); + } +} + +int warn(const char *msg, char *argv) +{ + t = 0; /* this function needs side-effects. */ + return 0; +} + +int error(const char *msg, int c, char *argv) +{ + t = 0; /* this function needs side-effects. */ + return 0; +} + +int recentdate(void *foo, void *bar) +{ + t = 0; /* this function needs side-effects. */ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr27639.c b/SingleSource/Regression/C/gcc-dg/pr27639.c new file mode 100644 index 0000000000..cb7b1429d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27639.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c99" } */ +#if(__SIZEOF_INT__ >= 4) +char heap[50000]; +#else +char heap[32000]; +#endif +int +main () +{ + for (unsigned ix = sizeof (heap); ix--;) + heap[ix] = ix; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27671-2.c b/SingleSource/Regression/C/gcc-dg/pr27671-2.c new file mode 100644 index 0000000000..11dae10b18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27671-2.c @@ -0,0 +1,24 @@ +/* PR rtl-optimization/27671. + The combiner used to simplify "a ^ b == a" to "a" via + simplify_relational_operation_1 in simplify-rtx.c. */ +/* { dg-do run } */ +/* { dg-options "-O1" } */ +/* { dg-options "-O1 -march=pentium4" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern void abort (void) __attribute__ ((noreturn)); +extern void exit (int) __attribute__ ((noreturn)); + +static void __attribute__ ((noinline)) +bar (int k) +{ + int n = k % 2; + if (n == 0) + abort (); +} + +int +main (void) +{ + bar (1); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27758.c b/SingleSource/Regression/C/gcc-dg/pr27758.c new file mode 100644 index 0000000000..d385fc5c94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27758.c @@ -0,0 +1,24 @@ +/* PR target/27758 */ +/* { dg-do run { target fpic } } */ +/* { dg-options "-O0 -fpic" } */ + +typedef int (*fn) (void); + +static inline int +foo (void) +{ + return 1; +} + +fn +test (void) +{ + return foo; +} + +int +main (void) +{ + fn f = test (); + return f () != 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27802-1.c b/SingleSource/Regression/C/gcc-dg/pr27802-1.c new file mode 100644 index 0000000000..839459ac01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27802-1.c @@ -0,0 +1,16 @@ +/* Noreturn functions returning FP types used to confuse reg-stack on x86. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +double bar1() __attribute__((noreturn)); +void foo1() { bar1(); } + +double bar2() __attribute__((noreturn)); +double foo2() { return bar2(); } + +void bar3() __attribute__((noreturn)); +double foo3() { bar3(); } + +double bar4() __attribute__((noreturn)); +double foo4() { bar4(); } + diff --git a/SingleSource/Regression/C/gcc-dg/pr27861-1.c b/SingleSource/Regression/C/gcc-dg/pr27861-1.c new file mode 100644 index 0000000000..8d6d791bca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27861-1.c @@ -0,0 +1,69 @@ +/* PR target/27861 */ +/* The following code used to cause an ICE during RTL expansion, as + expand shift was stripping the SUBREG of a rotate shift count, and + later producing a VAR_DECL tree whose DECL_RTL's mode didn't match + the VAR_DECL's type's mode. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef struct sim_state *SIM_DESC; +typedef enum +{ + SIM_OPEN_STANDALONE, SIM_OPEN_DEBUG +} +SIM_RC; +typedef unsigned int unsigned32 __attribute__ ((__mode__ (__SI__))); +typedef unsigned int unsigned64 __attribute__ ((__mode__ (__DI__))); +typedef unsigned32 unsigned_address; +typedef unsigned_address address_word; +static __inline__ unsigned64 + __attribute__ ((__unused__)) ROTR64 (unsigned64 val, int shift) +{ + unsigned64 result; + result = (((val) >> (shift)) | ((val) << ((64) - (shift)))); + return result; +} +typedef struct _sim_cpu sim_cpu; +enum +{ + TRACE_MEMORY_IDX, TRACE_MODEL_IDX, TRACE_ALU_IDX, TRACE_CORE_IDX, +}; +typedef struct _trace_data +{ + char trace_flags[32]; +} +TRACE_DATA; +typedef enum +{ + nr_watchpoint_types, +} +watchpoint_type; +typedef struct _sim_watchpoints +{ + TRACE_DATA trace_data; +} +sim_cpu_base; +struct _sim_cpu +{ + sim_cpu_base base; +}; +struct sim_state +{ + sim_cpu cpu[1]; +}; +typedef address_word instruction_address; +void trace_result_word1 (); +int +do_dror (SIM_DESC sd, instruction_address cia, int MY_INDEX, unsigned64 x, + unsigned64 y) +{ + unsigned64 result; + result = ROTR64 (x, y); + { + if ((((-1) & (1 << (TRACE_ALU_IDX))) != 0 + && (((&(((&(sd)->cpu[0])))->base.trace_data))-> + trace_flags)[TRACE_ALU_IDX] != 0)) + trace_result_word1 (sd, ((&(sd)->cpu[0])), TRACE_ALU_IDX, (result)); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr27953.c b/SingleSource/Regression/C/gcc-dg/pr27953.c new file mode 100644 index 0000000000..99ae0a3aa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27953.c @@ -0,0 +1,9 @@ +/* PR c/27953 */ + +void foo(struct A a) {} /* { dg-line foo_first } */ +/* { dg-warning "declared inside parameter list" "inside" { target *-*-* } .-1 } */ +/* { dg-error "incomplete type" "incomplete" { target *-*-* } .-2 } */ + +void foo() {} +/* { dg-error "redefinition" "redef" { target *-*-* } .-1 } */ +/* { dg-message "note: previous definition" "previous" { target *-*-* } foo_first } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr27959-2.c b/SingleSource/Regression/C/gcc-dg/pr27959-2.c new file mode 100644 index 0000000000..65894756b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27959-2.c @@ -0,0 +1,94 @@ +/* PR middle-end/27959 */ +/* { dg-do run { target { stdint_types } } } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=z990" { target s390*-*-* } } */ + +#include +extern void abort (void); + +struct B +{ + unsigned int b1, b2, b3; + char b4; +}; + +struct C +{ + char c1; +}; + +struct D +{ + char *d1; + struct C **d2; + unsigned int d3; +}; + +void +__attribute__((noinline)) +foo (void *x, struct B *y, unsigned int *z) +{ + if (x) + abort (); + if (y->b1 != 7 || y->b2 != 5 || y->b3 != 3 || y->b4) + abort (); + if (*z != 2) + abort (); +} + +int +__attribute__((noinline)) +baz (unsigned int *x, unsigned int y) +{ + asm volatile ("" : : "r" (&x), "r" (&y) : "memory"); + return *x + y; +} + +inline int bar (unsigned int *x, unsigned int y) +{ + if (y < *x) + return 0; + return baz (x, y); +} + +unsigned int * +__attribute__((noinline)) +test (struct D *x, unsigned int *y) +{ + struct B b; + uint32_t c; + + bar (y, x->d3); + if ((*(x->d2))->c1) + c = ((uint32_t) x->d1[0] + + ((uint32_t) x->d1[1] << 8) + + ((uint32_t) x->d1[2] << 16) + + ((uint32_t) x->d1[3] << 24)); + else + { + int32_t d; + ((char *) &d)[0] = x->d1[0]; + ((char *) &d)[1] = x->d1[1]; + ((char *) &d)[2] = x->d1[2]; + ((char *) &d)[3] = x->d1[3]; + c = d; + } + b.b4 = 0; + b.b1 = c / 10000L % 10000; + b.b2 = c / 100 % 100; + b.b3 = c % 100; + foo (0, &b, y); + return y; +} + +int +main (void) +{ + uint32_t x = 900070503; + unsigned int y = 2; + struct C c = { 0 }, *cptr = &c; + struct D d = { (char *) &x, &cptr, 0 }; + if (test (&d, &y) != &y) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr27959.c b/SingleSource/Regression/C/gcc-dg/pr27959.c new file mode 100644 index 0000000000..f1fdda1b2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr27959.c @@ -0,0 +1,93 @@ +/* PR middle-end/27959 */ +/* { dg-do run { target { int32plus } } } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=z990" { target s390*-*-* } } */ + +extern void abort (void); + +struct B +{ + unsigned int b1, b2, b3; + char b4; +}; + +struct C +{ + char c1; +}; + +struct D +{ + char *d1; + struct C **d2; + unsigned int d3; +}; + +void +__attribute__((noinline)) +foo (void *x, struct B *y, unsigned int *z) +{ + if (x) + abort (); + if (y->b1 != 7 || y->b2 != 5 || y->b3 != 3 || y->b4) + abort (); + if (*z != 2) + abort (); +} + +int +__attribute__((noinline)) +baz (unsigned int *x, unsigned int y) +{ + asm volatile ("" : : "r" (&x), "r" (&y) : "memory"); + return *x + y; +} + +inline int bar (unsigned int *x, unsigned int y) +{ + if (y < *x) + return 0; + return baz (x, y); +} + +unsigned int * +__attribute__((noinline)) +test (struct D *x, unsigned int *y) +{ + struct B b; + unsigned int c; + + bar (y, x->d3); + if ((*(x->d2))->c1) + c = ((unsigned char) x->d1[0] + + ((unsigned char) x->d1[1] << 8) + + ((unsigned char) x->d1[2] << 16) + + ((short) x->d1[3] << 24)); + else + { + int d; + ((char *) &d)[0] = x->d1[0]; + ((char *) &d)[1] = x->d1[1]; + ((char *) &d)[2] = x->d1[2]; + ((char *) &d)[3] = x->d1[3]; + c = d; + } + b.b4 = 0; + b.b1 = c / 10000L % 10000; + b.b2 = c / 100 % 100; + b.b3 = c % 100; + foo (0, &b, y); + return y; +} + +int +main (void) +{ + unsigned int x = 900070503; + unsigned int y = 2; + struct C c = { 0 }, *cptr = &c; + struct D d = { (char *) &x, &cptr, 0 }; + if (test (&d, &y) != &y) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28121.c b/SingleSource/Regression/C/gcc-dg/pr28121.c new file mode 100644 index 0000000000..9e306f5930 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28121.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int GetMouseButton (); +int ParsePos (); + +short +GetCmd () +{ + int c, c1; + for (c = 255; c == 255;) + { + c = GetMouseButton (); + if (c >= 0) + { + c = ParsePos (c, -1, 0); + c1 = ParsePos (c1, c, 1); + if (c == c1 && (c >= 0 || c == -10)) + { + return c; + } + if (c >= 0 && c1 == -12) + { + return ((((((10) + 1) + 1)) + 1) << 7) | c; + } + c = 255; + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr28162.c b/SingleSource/Regression/C/gcc-dg/pr28162.c new file mode 100644 index 0000000000..8bd28ad24a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28162.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void Lag_max_wght(float corr[], long wght_flg) +{ + float t0, max; + const float *ww; + long i; + if ( wght_flg > 0 ) { + for ( i = 143; i >= 20; i-- ) { + t0 = corr[ - i] * *ww--; + if ( t0 >= max ) + max = t0; + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr28187.c b/SingleSource/Regression/C/gcc-dg/pr28187.c new file mode 100644 index 0000000000..bc3b62d336 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28187.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-vrp -fwrapv" } */ + +extern void bar(int); +void checkgroups(int last, int verbose) +{ + int window = 0; + int outstanding = 0; + while (window < last || outstanding) { + while (outstanding < 47 && window < last) { + if (window < last) { + outstanding++; + if (verbose) + bar(window); + bar(window++); + } + } + if (outstanding > 0) + bar(0); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr28243.c b/SingleSource/Regression/C/gcc-dg/pr28243.c new file mode 100644 index 0000000000..a6d693e224 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28243.c @@ -0,0 +1,54 @@ +/* PR rtl-optimization/28243 */ +/* Reported by Mike Frysinger */ + +/* { dg-do compile } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -ftracer -fPIC" } */ + +struct displayfuncs { + void (*init) (); +} funcs; + +struct gpsdisplay { + struct displayfuncs *funcs; +}; + +void PSDoArc (); + +static void PSMyArc(double cx, double cy, double radx, double rady, double sa, + double ta) +{ + double ea; + double temp; + ea = sa + ta; + while (sa < ea) { + temp = ((sa + 90) / 90) * 90; + PSDoArc(cx, sa, ea < temp ? ea : temp); + sa = temp; + } +} + +static void PSDrawElipse() +{ + float cx; + float cy; + float radx; + float rady; + if (radx != rady) + PSMyArc(cx, cy, radx, rady, 0, 360); +} + +static void PSDrawFillCircle() +{ + PSDrawElipse(); +} + +static struct displayfuncs psfuncs[] = { + PSDrawFillCircle +}; + +void _GPSDraw_CreateDisplay() +{ + struct gpsdisplay *gdisp; + gdisp->funcs = (void *)&psfuncs; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28322-2.c b/SingleSource/Regression/C/gcc-dg/pr28322-2.c new file mode 100644 index 0000000000..20adf5e92b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28322-2.c @@ -0,0 +1,12 @@ +/* PR28322: ignore unknown -Wno-* if no warning is emitted. */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra -Wno-foobar" } */ + +int foo (void) +{ + int i = 1/0; /* { dg-warning "division by zero" } */ + return i; +} + +/* { dg-message "unrecognized command-line option .-Wno-foobar." "" { target *-*-* } 0 } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr28322-3.c b/SingleSource/Regression/C/gcc-dg/pr28322-3.c new file mode 100644 index 0000000000..85926ade9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28322-3.c @@ -0,0 +1,10 @@ +/* PR28322: ignore unknown -Wno-* if no warning is emitted. */ +/* { dg-do compile } */ +/* { dg-options " -fno-foobar -mno-foobar" } */ + +void foo(void) +{ + int i = 1; +} +/* { dg-message "unrecognized command-line option .-fno-foobar." "f" { target *-*-* } 0 } */ +/* { dg-message "unrecognized command-line option .-mno-foobar." "m" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr28322.c b/SingleSource/Regression/C/gcc-dg/pr28322.c new file mode 100644 index 0000000000..99872fca8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28322.c @@ -0,0 +1,8 @@ +/* PR28322: ignore unknown -Wno-* if no warning is emitted. */ +/* { dg-do compile } */ +/* { dg-options " -Wno-foobar -Wno-div-by-zero" } */ + +void foo(void) +{ + int i = 1/0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28402.c b/SingleSource/Regression/C/gcc-dg/pr28402.c new file mode 100644 index 0000000000..1368ac723b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28402.c @@ -0,0 +1,22 @@ +/* { dg-options "" } */ +typedef long long ll; +typedef unsigned long long ull; + +int global; + +#define A(BASE, OP, AMT) \ + ll BASE ## AMT (ll x) { return x OP AMT; } \ + ull BASE ## AMT ## u (ull x) { return x OP AMT; } + +#define B(BASE, OP) \ + A (BASE, OP, 1) \ + A (BASE, OP, 10) \ + A (BASE, OP, 31) \ + A (BASE, OP, 33) \ + A (BASE, OP, 61) \ + A (BASE, OP, global) + +B (left, <<) +B (right, >>) + +/* { dg-final { scan-assembler-not "__\[a-z\]*si3" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr28419.c b/SingleSource/Regression/C/gcc-dg/pr28419.c new file mode 100644 index 0000000000..d418a165b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28419.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +void foo() +const char* p = __FUNCTION__; /* { dg-error "" } */ +/* { dg-error "-:expected" "" { target *-*-* } .+1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr28574.c b/SingleSource/Regression/C/gcc-dg/pr28574.c new file mode 100644 index 0000000000..b86f7f6b68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28574.c @@ -0,0 +1,75 @@ +/* On IA64 This test resulted in a missing jumptable and an undefined + reference to a label. Make sure we can compile and link it with + no undefs at -O2. */ + +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +typedef enum yasm_module_type { + YASM_MODULE_ARCH = 0, + YASM_MODULE_DBGFMT, + YASM_MODULE_OBJFMT, + YASM_MODULE_LISTFMT, + YASM_MODULE_OPTIMIZER +} yasm_module_type; + +struct yasm_module { + const char *name; +}; + +typedef struct yasm_module yasm_arch_module; +typedef struct yasm_module yasm_dbgfmt_module; +typedef struct yasm_module yasm_objfmt_module; +typedef struct yasm_module yasm_listfmt_module; +typedef struct yasm_module yasm_optimizer_module; + +typedef struct module { + void *data; +} module; + +static struct { + module *m; + int n; +} module_types[] = { + {}, +}; + +void +yasm_list_modules(yasm_module_type type, + void (*printfunc) (const char *name)) +{ + int i; + module *modules = module_types[type].m; + yasm_arch_module *arch; + yasm_dbgfmt_module *dbgfmt; + yasm_objfmt_module *objfmt; + yasm_listfmt_module *listfmt; + yasm_optimizer_module *optimizer; + + for (i=0; i<2; i++) { + switch (type) { + case YASM_MODULE_ARCH: + arch = modules[i].data; + printfunc(arch->name); + break; + case YASM_MODULE_DBGFMT: + dbgfmt = modules[i].data; + printfunc(dbgfmt->name); + break; + case YASM_MODULE_OBJFMT: + objfmt = modules[i].data; + printfunc(objfmt->name); + break; + case YASM_MODULE_LISTFMT: + listfmt = modules[i].data; + printfunc(listfmt->name); + break; + case YASM_MODULE_OPTIMIZER: + optimizer = modules[i].data; + printfunc(optimizer->name); + } + } +} + +int +main() {} diff --git a/SingleSource/Regression/C/gcc-dg/pr28685-1.c b/SingleSource/Regression/C/gcc-dg/pr28685-1.c new file mode 100644 index 0000000000..6b7b9175c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28685-1.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -fno-ipa-icf" } */ + +/* Should produce <=. */ +int test1 (int a, int b) +{ + return (a < b || a == b); +} + +/* Should produce <=. */ +int test2 (int a, int b) +{ + int lt = a < b; + int eq = a == b; + + return (lt || eq); +} + +/* Should produce <= (just deleting redundant test). */ +int test3 (int a, int b) +{ + int lt = a <= b; + int eq = a == b; + + return (lt || eq); +} + +/* Should produce <= (operands reversed to test the swap logic). */ +int test4 (int a, int b) +{ + int lt = a < b; + int eq = b == a; + + return (lt || eq); +} + +/* Should produce constant 0. */ +int test5 (int a, int b) +{ + int lt = a < b; + int eq = a == b; + + return (lt && eq); +} + +/* { dg-final { scan-tree-dump-times " <= " 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " == " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr28726.c b/SingleSource/Regression/C/gcc-dg/pr28726.c new file mode 100644 index 0000000000..11232ac86a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28726.c @@ -0,0 +1,29 @@ +/* PR rtl-optimization/28726 */ +/* Origin: Sigurd Schneider */ + +/* { dg-do run } */ +/* { dg-options "-O2 -fsched2-use-superblocks" } */ + +extern void abort (void); + +static double my_loop(void) __attribute__((noinline)); + +static double my_loop(void) +{ + double retval = 0.0; + const unsigned char *start = "\005\b\000"; + const unsigned char *const end = start + 2; + + while (start < end) + retval += *start++; + + return retval; +} + +int main(void) +{ + if (my_loop() != 13.0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28755.c b/SingleSource/Regression/C/gcc-dg/pr28755.c new file mode 100644 index 0000000000..50b56fb890 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28755.c @@ -0,0 +1,24 @@ +/* PR middle-end/28755 */ +/* { dg-do compile } */ +/* { dg-require-effective-target ptr32plus } */ +/* { dg-options "-Os" } */ +/* { dg-final { scan-assembler-times "2112543726\|7deadbee" 2 } } */ +/* { dg-skip-if "integer output is different here" { nvptx-*-* } } */ + +struct S +{ + void *s1; + unsigned s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14; +}; + +const struct S array[] = { + { (void *) 0, 60, 640, 2112543726, 39682, 48, 16, 33, 10, 96, 2, 0, 0, 4 }, + { (void *) 0, 60, 2112543726, 192, 18251, 16, 33, 10, 96, 2, 0, 0, 4, 212 } +}; + +void +foo (struct S *x) +{ + x[0] = array[0]; + x[5] = array[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28796-1.c b/SingleSource/Regression/C/gcc-dg/pr28796-1.c new file mode 100644 index 0000000000..077118a298 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28796-1.c @@ -0,0 +1,62 @@ +/* { dg-do link } */ +/* { dg-options "-ffinite-math-only" } */ + +extern void link_error(void); + +float f; +double d; +long double ld; + +int main() +{ + if (__builtin_isunordered (f, f) != 0) + link_error (); + if (__builtin_isunordered (d, d) != 0) + link_error (); + if (__builtin_isunordered (ld, ld) != 0) + link_error (); + + if (__builtin_isnan (f) != 0) + link_error (); + if (__builtin_isnan (d) != 0) + link_error (); + if (__builtin_isnan (ld) != 0) + link_error (); + if (__builtin_isnanf (f) != 0) + link_error (); + if (__builtin_isnanl (ld) != 0) + link_error (); + + if (__builtin_finite (f) != 1) + link_error (); + if (__builtin_finite (d) != 1) + link_error (); + if (__builtin_finite (ld) != 1) + link_error (); + if (__builtin_finitef (f) != 1) + link_error (); + if (__builtin_finitel (ld) != 1) + link_error (); + + if (__builtin_isinf (f) != 0) + link_error (); + if (__builtin_isinf (d) != 0) + link_error (); + if (__builtin_isinf (ld) != 0) + link_error (); + + if (__builtin_isfinite (f) != 1) + link_error (); + if (__builtin_isfinite (d) != 1) + link_error (); + if (__builtin_isfinite (ld) != 1) + link_error (); + + if (f != f) + link_error (); + if (d != d) + link_error (); + if (ld != ld) + link_error (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28796-2.c b/SingleSource/Regression/C/gcc-dg/pr28796-2.c new file mode 100644 index 0000000000..a56b4abf8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28796-2.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -funsafe-math-optimizations -fno-finite-math-only -DUNSAFE" } */ +/* { dg-add-options ieee } */ + +#include "tg-tests.h" + +int main(void) +{ + return main_tests (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28888.c b/SingleSource/Regression/C/gcc-dg/pr28888.c new file mode 100644 index 0000000000..3bad18b9fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28888.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +static const unsigned char _c30[] = + "statistic of allocated integer registers:"; +void Out__LongInt (); +int +Allocate__WriteStats (void) +{ + register int i0, i1, i2, i3, i4, i5; +l0:i1 = (int) (i5 << 2); + if (i0) + i4 = i5; +l1:i2 += i1; + if (i1) + goto l0; +l3:i0 = i1 == 255; + i1++; + Out__LongInt ((int) i0, (int) 0); + i0 = i4 >= i1; + if (i0) + goto l3; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28911.c b/SingleSource/Regression/C/gcc-dg/pr28911.c new file mode 100644 index 0000000000..e1748f0fd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28911.c @@ -0,0 +1,13 @@ +/* PR target/28911 + The following used to cause crash on m68k-elf because 0x80000000 + was used as an SImode constant. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -m68000" { target m68k-*-* } } */ + +_Complex float +foo (float a) +{ + return __builtin_copysign (a != a, a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr28935.c b/SingleSource/Regression/C/gcc-dg/pr28935.c new file mode 100644 index 0000000000..9a0e70ecf6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr28935.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -ftree-vectorize" } */ + +int col[8]; +int extend_options(int w, int h, int *map, int x, int y, int index) +{ + int dx, dy; + for (dx = -1; dx <= +1; dx++) + { + int index = (dy < 0 ? 6-dx : dy > 0 ? 2+dx : 2*(1+dx)); + if (x+dx >= 0 && x+dx < w && y+dy >= 0 && y+dy < h) + col[index] = map[(y+dy)*w+(x+dx)]; + col[index] = -1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr29091.c b/SingleSource/Regression/C/gcc-dg/pr29091.c new file mode 100644 index 0000000000..6e06c63dad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29091.c @@ -0,0 +1,44 @@ +/* PR c/29091 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +__attribute__ ((vector_size (sizeof (int) * 4))) int a = { 1, 2 }; +int d = 3; +__attribute__ ((vector_size (sizeof (int) * 4))) int b = { 4, 5, 6 }; +int e = 7; +__attribute__ ((vector_size (sizeof (int) * 4))) int c = { }; + +int +main (void) +{ + int *p = (int *) &a; + if (p[0] != 1) + abort (); + if (p[1] != 2) + abort (); + if (p[2] != 0) + abort (); + if (p[3] != 0) + abort (); + p = (int *) &b; + if (p[0] != 4) + abort (); + if (p[1] != 5) + abort (); + if (p[2] != 6) + abort (); + if (p[3] != 0) + abort (); + p = (int *) &c; + if (p[0] != 0) + abort (); + if (p[1] != 0) + abort (); + if (p[2] != 0) + abort (); + if (p[3] != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr29215.c b/SingleSource/Regression/C/gcc-dg/pr29215.c new file mode 100644 index 0000000000..fc1a0af87a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29215.c @@ -0,0 +1,32 @@ +/* PR middle-end/29215 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ + +char buf[5 * sizeof (int) + 1] __attribute__((aligned (__alignof__ (int)))); + +static void +foo (int arg1, int arg2, int arg3, int arg4, int arg5) +{ + __builtin_memcpy (buf, &arg1, sizeof (int)); + __builtin_memcpy (buf + sizeof (int), &arg2, sizeof (int)); + __builtin_memcpy (buf + 2 * sizeof (int), &arg3, sizeof (int)); + __builtin_memcpy (buf + 3 * sizeof (int), &arg4, sizeof (int)); + __builtin_memcpy (buf + 4 * sizeof (int), &arg5, sizeof (int)); +} + +int +main (void) +{ + union { char buf[4]; int i; } u; + u.i = 0; + u.buf[0] = 'a'; + u.buf[1] = 'b'; + u.buf[2] = 'c'; + u.buf[3] = 'd'; + foo (u.i, u.i, u.i, u.i, u.i); + buf[5 * sizeof (int)] = '\0'; + __builtin_puts (buf); + return 0; +} + +/* { dg-final { scan-tree-dump-not "memcpy" "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr29254.c b/SingleSource/Regression/C/gcc-dg/pr29254.c new file mode 100644 index 0000000000..df6ba574a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29254.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Werror" } */ + +int value_compare (); + +int +list_compare (int * list1) +{ + if (list1) + value_compare (); +} + +int func1 (int * f){} + +int +value_compare (int * a) +{ + if (a) + list_compare (a); +} + +int +func2 (const int * fb) +{ + func1 ((int *) fb); /* { dg-bogus "discards qualifiers" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr29299.c b/SingleSource/Regression/C/gcc-dg/pr29299.c new file mode 100644 index 0000000000..9049060fae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29299.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +static int bof __attribute__((used)); +int foo() +{ + static int barbarbarbar __attribute__((used)); +}; + +/* { dg-final { scan-assembler "barbarbarbar" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr29467.c b/SingleSource/Regression/C/gcc-dg/pr29467.c new file mode 100644 index 0000000000..eaf09c2344 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29467.c @@ -0,0 +1,13 @@ +/* PR c/29467 */ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -Wpedantic" } */ + +_Bool b; /* { dg-warning "ISO C90 does not support boolean types" } */ +typedef _Bool B; /* { dg-warning "ISO C90 does not support boolean types" } */ +static _Bool sb; /* { dg-warning "ISO C90 does not support boolean types" } */ + +_Bool /* { dg-warning "ISO C90 does not support boolean types" } */ +foo (_Bool bp) /* { dg-warning "ISO C90 does not support boolean types" } */ +{ + _Bool bl; /* { dg-warning "ISO C90 does not support boolean types" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr29521-2.c b/SingleSource/Regression/C/gcc-dg/pr29521-2.c new file mode 100644 index 0000000000..734652c90c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29521-2.c @@ -0,0 +1,15 @@ +/* PR 29521 : warning for return with expression in function returning void */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +void func (void) { } + +void func2 (void) +{ + return func (); /* { dg-error "ISO C forbids 'return' with expression" } */ +} + +void func3 (void) +{ + return 1; /* { dg-error "'return' with a value" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr29521.c b/SingleSource/Regression/C/gcc-dg/pr29521.c new file mode 100644 index 0000000000..b6fb535fab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29521.c @@ -0,0 +1,15 @@ +/* PR 29521 : warning for return with expression in function returning void */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void func (void) { } + +void func2 (void) +{ + return func (); +} + +void func3 (void) +{ + return 1; /* { dg-warning "'return' with a value" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr29637.c b/SingleSource/Regression/C/gcc-dg/pr29637.c new file mode 100644 index 0000000000..5dfee41b1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29637.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/29637 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +typedef struct __attribute__ ((aligned (8))) +{ + short a, b, c, d; +} A; + +typedef struct +{ + A a[24]; +} B; + +static const A b = { 0, 0, 1, -1 }; + +void +foo (B *x) +{ + int i; + for (i = 0; i <= 20; i += 4) + x->a[i] = b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr29683.c b/SingleSource/Regression/C/gcc-dg/pr29683.c new file mode 100644 index 0000000000..4bed679b56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29683.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-options "-Os -fno-inline-functions" } */ + +void abort (void); + +typedef struct { + int x[7]; +} agg7; + +typedef struct { + int mbr1; + int mbr2; +} agg2; + +int expected = 31415; +agg7 filler; + +int GetConst (agg7 filler, agg2 split) +{ + return expected; +} + +void VerifyValues (agg7 filler, int last_reg, int first_stack, int second_stack) +{ + if (first_stack != 123 || second_stack != expected) + abort (); +} + +void RunTest (agg2 a) +{ + int result; + + result = GetConst (filler, a); + VerifyValues (filler, 0, a.mbr1, result); +} + +int main(void) +{ + agg2 result = {123, 456}; + RunTest (result); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr29736.c b/SingleSource/Regression/C/gcc-dg/pr29736.c new file mode 100644 index 0000000000..54eb9aaaa7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29736.c @@ -0,0 +1,13 @@ +/* PR c/29736 */ + +int __attribute__ ((vector_size (8), vector_size (8))) v; /* { dg-error "invalid vector type" } */ + +extern int __attribute__ ((vector_size (8))) w; +int __attribute__ ((vector_size (8))) w; + +void +foo () +{ + v = v + v; + w = w + w; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr29801.c b/SingleSource/Regression/C/gcc-dg/pr29801.c new file mode 100644 index 0000000000..367b561e7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29801.c @@ -0,0 +1,23 @@ +/* We used to crash in ccp here, because the initial constant value of 2 + was changed to 5. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +static const int a = 2; + +int test (int param) +{ + int *p = (int *) &a; + + if (param) + *p = 5; + + return a; +} + +/* Check that we return the correct (unchanged) value. */ + +/* { dg-final { scan-tree-dump-times "return 2" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 5" 0 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr29921-2.c b/SingleSource/Regression/C/gcc-dg/pr29921-2.c new file mode 100644 index 0000000000..8cf665eede --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29921-2.c @@ -0,0 +1,27 @@ +/* With -ffast-math, the latice value for sum2 used to change from NaN to + VARYING, in turn causing the lattice value of sum1 * sum2 change from + NaN to 0 (since sum1 is believed to be 0 at that moment, and + 0 * VARYING = 0 with -ffast-math), which caused an ICE. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +int +foo (float *array, int end) +{ + int i; + float sum1, sum2; + + sum2 = 0; + for (i = 0; i < end; i++) + sum2 = sum2+array[i]; + sum2 = 1./sum2; + sum1 = 0.; + for (i = 0; i < end; i++) + sum1 = sum1+array[i]; + sum1 = sum1 * sum2; + if (-10.0 / sum1 < 5.E-5) + end = 0; + return end; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr29921.c b/SingleSource/Regression/C/gcc-dg/pr29921.c new file mode 100644 index 0000000000..7689f54ce2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr29921.c @@ -0,0 +1,20 @@ +/* With -ffast-math, the latice value for t changes from -0.0 to 0.0 in this + testcase. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double test (int param) +{ + double a = 0.0, b = -1.0, t; + int i; + + for (i = 0; i < 100; i++) + { + t = a * b; + if (param) + b = 2.0; + } + + return t; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr30045.c b/SingleSource/Regression/C/gcc-dg/pr30045.c new file mode 100644 index 0000000000..6dd22a1df7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30045.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-inline" } */ +int f(int *a) +{ + int __attribute__((nonnull(1))) g(int *b) + { + int **c = &a; + if (b) + return *a + **c; + return *b; + } + if (a) + return g(a); + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr30137-1.c b/SingleSource/Regression/C/gcc-dg/pr30137-1.c new file mode 100644 index 0000000000..4e32ce2984 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30137-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-w -fdump-tree-gimple" } */ + +/* Things that should not be folded. */ + +struct { long base; int tail; void * volatile ptr; } *s; +int foo3 (void) { return s == &s; } +int foo5 (void) { return s->ptr == s->ptr; } + +struct { union { int i; short s } u; } x; +int foo6 (void) { return x.u.i == x.u.s; } + +void **p; +int foo8 (void) { return p == &p; } +int foo9 (void) { return *p == p; } +int foo10 (void) { return *p == &p; } +int foo11 (void) { return p != &p; } +int foo12 (void) { return *p != p; } +int foo13 (void) { return *p != &p; } + +/* { dg-final { scan-tree-dump-not "= 0;" "gimple" } } */ +/* { dg-final { scan-tree-dump-not "= 1;" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr30137-2.c b/SingleSource/Regression/C/gcc-dg/pr30137-2.c new file mode 100644 index 0000000000..ce029b6069 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30137-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-w -fdump-tree-gimple" } */ + +/* Things that should be folded. */ + +struct { long base; int tail; void * volatile ptr; } *s; +int foo1a (void) { return (s == &s->base); } +int foo1b (void) { return (&s->base == s); } +int foo2 (void) { return ((void *)s == (void *) &s->base); } +int foo4 (void) { return s->base == s->base; } +int foo5 (void) { return &s->ptr == &s->ptr; } +int foo6 (void) { return &s->ptr != &s->ptr; } +int foo7 (void) { return &s->base != &s->ptr; } + +struct { union { int i; short s } u; } x; +int foo8 (void) { return &x.u.i == &x.u.s; } + +/* { dg-final { scan-tree-dump-times "= 0" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "= 1" 7 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr30172-1.c b/SingleSource/Regression/C/gcc-dg/pr30172-1.c new file mode 100644 index 0000000000..ee6efdeebb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30172-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-signed-zeros -ffinite-math-only -fdump-tree-gimple" } */ + +_Complex double test1 (double x) { return x + 1.i; } +_Complex double test2 (double x) { return 1 + x * 1.i; } +_Complex double test3 (double x, double y) { return x + y * 1.i; } +_Complex double test4 (double x, double y) { return (x + y * 1.i) * 1.i; } +_Complex double test5 (double x, double y) { return (x + y * 1.i) * -1.i; } + +/* { dg-final { scan-tree-dump "COMPLEX_EXPR " "gimple" } } */ +/* { dg-final { scan-tree-dump "COMPLEX_EXPR <1.0e\\+0, x>" "gimple" } } */ +/* { dg-final { scan-tree-dump "COMPLEX_EXPR " "gimple" } } */ +/* { dg-final { scan-tree-dump " = -y;\n.*COMPLEX_EXPR <\[^,\]*, x>" "gimple" } } */ +/* { dg-final { scan-tree-dump " = -x;\n.*COMPLEX_EXPR + +void link_error (void); + +enum A { + A1 = 0, + A2 = A1 - 1 +}; +enum B { + B1 = 0u, + B2 = B1 - 1 /* { dg-bogus "ISO C restricts enumerator values to range of 'int'" } */ +}; +int main(void) +{ + enum A a = -1; + enum B b = -1; + + if (!(a < 0)) + link_error (); + if (!(A2 < 0)) + link_error (); + if (!(b < 0)) + link_error (); + if (!(B2 < 0)) + link_error (); + + return 0; +} + +enum E1 { e10 = INT_MAX, e11 }; /* { dg-warning "ISO C restricts enumerator values to range of 'int' before C2X" } */ +enum E2 { e20 = (unsigned) INT_MAX, e21 }; /* { dg-warning "ISO C restricts enumerator values to range of 'int' before C2X" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr30286.c b/SingleSource/Regression/C/gcc-dg/pr30286.c new file mode 100644 index 0000000000..d35eacd807 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30286.c @@ -0,0 +1,38 @@ +/* PR middle-end/30286 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftrapv" } */ +/* { dg-require-effective-target trapping } */ + +extern void abort (void); +struct S { struct S *s; }; +struct T { struct S *t[25]; }; + +void +__attribute__((noinline)) +foo (int i, struct T *x, struct S *y) +{ + int j; + for (j = 14; j > i; j--) + x->t[j] = y->s; +} + +int +main (void) +{ + struct S s; + struct T t; + int i; + + s.s = &s; + __builtin_memset (&t, 0, sizeof (t)); + foo (6, &t, &s); + for (i = 0; i < 25; i++) + if (t.t[i] != ((i > 6 && i <= 14) ? &s : (struct S *) 0)) + abort (); + __builtin_memset (&t, 0, sizeof (t)); + foo (-1, &t, &s); + for (i = 0; i < 25; i++) + if (t.t[i] != ((i >= 0 && i <= 14) ? &s : (struct S *) 0)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr30360.c b/SingleSource/Regression/C/gcc-dg/pr30360.c new file mode 100644 index 0000000000..4254c0a38c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30360.c @@ -0,0 +1,25 @@ +/* PR c/30360 */ +/* { dg-do run { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* ia64-*-linux* s390*-*-linux* } } */ +/* { dg-options "-O2 -std=gnu99" } */ + +#define I (__extension__ 1.0iF) +#define H(x) asm ("" : "=m" (x) : "m" (x)) +extern void abort (void); + +int +main (void) +{ + _Complex double a = 1.0 + 1.0 * I, b = 0.0, c; + H (a); + H (b); + c = a / b; + if (!__builtin_isinf (__real__ c) && !__builtin_isinf (__imag__ c)) + abort (); + a = 0.0; + H (a); + H (b); + c = a / b; + if (!__builtin_isnan (__real__ c) || !__builtin_isnan (__imag__ c)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr30457.c b/SingleSource/Regression/C/gcc-dg/pr30457.c new file mode 100644 index 0000000000..795b022e52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30457.c @@ -0,0 +1,26 @@ +/* PR 30457 warn about va_start(ap, invalid) */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +/* Undefined by C99 7.15.1.4p4 (va_start): + "If the parameter parmN is declared with the register storage + class, with a function or array type, or with a type that is + not compatible with the type that results after application of + the default argument promotions, the behavior is undefined." */ + +#include + +void foo(register short paramN, ...) +{ + va_list ap; + + va_start(ap, paramN); /* { dg-warning "undefined behavior when second parameter of 'va_start' is declared with 'register' storage" } */ + + /* Undefined by C99 7.15.1.1p2: */ + (void) va_arg(ap, char); /* { dg-warning "'char' is promoted to 'int' when passed through '...'" "promoted" } */ + /* { dg-message "note: .so you should pass .int. not .char. to .va_arg.." "int not char" { target *-*-* } .-1 } */ + /* { dg-message "note: if this code is reached, the program will abort" "will abort" { target *-*-* } .-2 } */ + + va_end(ap); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr30473.c b/SingleSource/Regression/C/gcc-dg/pr30473.c new file mode 100644 index 0000000000..f01c1cc4a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30473.c @@ -0,0 +1,13 @@ +/* PR middle-end/30473 */ +/* Make sure this doesn't ICE. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int sprintf (char *, const char *, ...); + +void +foo (char *buf1, char *buf2) +{ + sprintf (buf1, "%s", "abcde"); + sprintf (buf2, "%s"); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr30551-2.c b/SingleSource/Regression/C/gcc-dg/pr30551-2.c new file mode 100644 index 0000000000..163a3ce4dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30551-2.c @@ -0,0 +1,8 @@ +/* PR 30551 -Wmain is not enabled by default. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void main(char a) {} /* { dg-bogus "first argument of .main. should be .int." "int" } */ +/* { dg-bogus ".main. takes only zero or two arguments" "zero or two" { target *-*-* } .-1 } */ +/* { dg-bogus "return type of .main. is not .int." "return type" { target *-*-* } .-2 } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr30551-3.c b/SingleSource/Regression/C/gcc-dg/pr30551-3.c new file mode 100644 index 0000000000..9151b1e3ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30551-3.c @@ -0,0 +1,6 @@ +/* PR 30551 -Wmain is enabled by -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ +void main(char a) {} /* { dg-error "first argument of .main. should be .int." "int" } */ +/* { dg-error ".main. takes only zero or two arguments" "zero or two" { target *-*-* } .-1 } */ +/* { dg-error "return type of .main. is not .int." "return type" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr30551-4.c b/SingleSource/Regression/C/gcc-dg/pr30551-4.c new file mode 100644 index 0000000000..6105beeee8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30551-4.c @@ -0,0 +1,8 @@ +/* PR 30551 -Wmain is enabled by -pedantic-errors and can be disabled. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -Wno-main" } */ + +void main(char a) {} /* { dg-bogus "first argument of .main. should be .int." "int" } */ +/* { dg-bogus ".main. takes only zero or two arguments" "zero or two" { target *-*-* } .-1 } */ +/* { dg-bogus "return type of .main. is not .int." "return type" { target *-*-* } .-2 } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr30551-5.c b/SingleSource/Regression/C/gcc-dg/pr30551-5.c new file mode 100644 index 0000000000..30fa871af9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30551-5.c @@ -0,0 +1,7 @@ +/* PR 30551 -Wmain is enabled by -pedantic and can be disabled. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic -Wno-main" } */ + +void main(char a) {} /* { dg-bogus "first argument of .main. should be .int." "int" } */ +/* { dg-bogus ".main. takes only zero or two arguments" "zero or two" { target *-*-* } .-1 } */ +/* { dg-bogus "return type of .main. is not .int." "return type" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr30551-6.c b/SingleSource/Regression/C/gcc-dg/pr30551-6.c new file mode 100644 index 0000000000..fa6bf0c6a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30551-6.c @@ -0,0 +1,6 @@ +/* PR 30551 -Wmain is enabled by -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ +void main(char a) {} /* { dg-warning "first argument of .main. should be .int." "int" } */ +/* { dg-warning ".main. takes only zero or two arguments" "zero or two" { target *-*-* } .-1 } */ +/* { dg-warning "return type of .main. is not .int." "return type" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr30551.c b/SingleSource/Regression/C/gcc-dg/pr30551.c new file mode 100644 index 0000000000..c7b108e859 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30551.c @@ -0,0 +1,6 @@ +/* PR 30551 -Wmain is enabled by -Wall. */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ +void main(char a) {} /* { dg-warning "first argument of .main. should be .int." "int" } */ +/* { dg-warning ".main. takes only zero or two arguments" "zero or two" { target *-*-* } .-1 } */ +/* { dg-warning "return type of .main. is not .int." "return type" { target *-*-* } .-2 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr30643.c b/SingleSource/Regression/C/gcc-dg/pr30643.c new file mode 100644 index 0000000000..67fe111a77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30643.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "undefined" } } */ + +/* Make sure we optimize all calls away. */ + +extern void undefined (void); +struct s { int a, b; }; +void bar (struct s *ps, int *p, int *__restrict__ rp, int *__restrict__ rq) +{ + ps->a = 0; + ps->b = 1; + if (ps->a != 0) + undefined (); + p[0] = 0; + p[1] = 1; + if (p[0] != 0) + undefined (); + rp[0] = 0; + rq[0] = 1; + if (rp[0] != 0) + undefined (); +} +int main (void) { + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr3074-1.c b/SingleSource/Regression/C/gcc-dg/pr3074-1.c new file mode 100644 index 0000000000..4716b79da9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr3074-1.c @@ -0,0 +1,9 @@ +/* PR middle-end/3074 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +void foo(int a) +{ + 5 * (a == 1) | (a == 2); /* { dg-warning "no effect" "no effect" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr30744-1.c b/SingleSource/Regression/C/gcc-dg/pr30744-1.c new file mode 100644 index 0000000000..f08f3be172 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30744-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +#include + +typedef __INTPTR_TYPE__ my_intptr_t; + +typedef struct { + my_intptr_t unique; +} G; + +void r(G* n) +{ + my_intptr_t p; + if (((G *) ((void *)((~(my_intptr_t)(p))))) != ((void *)0)) { + ((G *) ((void *)((~(my_intptr_t)(p)))))->unique = n->unique; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr30762-1.c b/SingleSource/Regression/C/gcc-dg/pr30762-1.c new file mode 100644 index 0000000000..75fb762d50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30762-1.c @@ -0,0 +1,18 @@ +/* PR c/30762 */ +/* { dg-do link } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -O3" } */ +/* { dg-additional-sources pr30762-2.c } */ + +typedef struct { int i; } D; +extern void foo (D); + +void +bar (void) +{ + D d; + d.i = 1; + foo (d); +} + +int main() { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr30762-2.c b/SingleSource/Regression/C/gcc-dg/pr30762-2.c new file mode 100644 index 0000000000..7e914ebfa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30762-2.c @@ -0,0 +1,9 @@ +/* PR c/30762 */ +/* { dg-do compile } */ + +typedef struct { int i; } D; + +void +foo (D x) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr30904.c b/SingleSource/Regression/C/gcc-dg/pr30904.c new file mode 100644 index 0000000000..940ddf3991 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30904.c @@ -0,0 +1,17 @@ +/* { dg-do link } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int t; +extern void link_error(void); +int main (void) +{ + struct { unsigned int a : 7; } s; + s.a = t; + if (s.a >> 8) + link_error (); + if (s.a >> 9) + link_error (); +} + + +/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr30949.c b/SingleSource/Regression/C/gcc-dg/pr30949.c new file mode 100644 index 0000000000..a3f6a14132 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30949.c @@ -0,0 +1,11 @@ +/* PR30949 */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +int func (int x); +void recv (int (* funcptr) (double x)); /* { dg-message "note: expected 'int .\\\*..double.' but argument is of type 'int .\\\*..int.'" } */ +void call (void) +{ + recv (func); /* { dg-error "passing argument 1 of 'recv' from incompatible pointer type" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr30951.c b/SingleSource/Regression/C/gcc-dg/pr30951.c new file mode 100644 index 0000000000..149b8ecaaf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30951.c @@ -0,0 +1,36 @@ +/* { dg-do link } */ + +extern void link_error (void); + +void test (int x, unsigned int y) +{ + if (x + 5 == x) + link_error (); + if (x == x + 10) + link_error (); + if (y + 5 == y) + link_error (); + if (y == y + 10) + link_error (); + if (x + 5 != x) + ; + else + link_error (); + if (x != x + 10) + ; + else + link_error (); + if (y + 5 != y) + ; + else + link_error (); + if (y != y + 10) + ; + else + link_error (); +} + +int main() +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr30957-1.c b/SingleSource/Regression/C/gcc-dg/pr30957-1.c new file mode 100644 index 0000000000..564410913a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr30957-1.c @@ -0,0 +1,36 @@ +/* { dg-do run { xfail { mmix-*-* } } } */ +/* We don't (and don't want to) perform this optimisation on soft-float targets, + where each addition is a library call. / +/* { dg-require-effective-target hard_float } */ +/* -fassociative-math requires -fno-trapping-math and -fno-signed-zeros. */ +/* { dg-options "-O2 -funroll-loops -fassociative-math -fno-trapping-math -fno-signed-zeros -fvariable-expansion-in-unroller -fdump-rtl-loop2_unroll" } */ + +extern void abort (void); +extern void exit (int); + +float __attribute__((noinline)) +foo (float d, int n) +{ + unsigned i; + float accum = d; + + for (i = 0; i < n; i++) + accum += d; + + return accum; +} + +int +main () +{ + /* When compiling standard compliant we expect foo to return -0.0. But the + variable expansion during unrolling optimization (for this testcase enabled + by non-compliant -fassociative-math) instantiates copy(s) of the + accumulator which it initializes with +0.0. Hence we expect that foo + returns +0.0. */ + if (__builtin_copysignf (1.0, foo (0.0 / -5.0, 10)) != 1.0) + abort (); + exit (0); +} + +/* { dg-final { scan-rtl-dump "Expanding Accumulator" "loop2_unroll" { xfail mmix-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr31096-1.c b/SingleSource/Regression/C/gcc-dg/pr31096-1.c new file mode 100644 index 0000000000..3866c7578b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31096-1.c @@ -0,0 +1,59 @@ +/* PR middle-end/31096 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#if __SIZEOF_INT__ < 4 + __extension__ typedef __INT32_TYPE__ int32_t; + __extension__ typedef __UINT32_TYPE__ uint32_t; +#else + typedef int int32_t; + typedef unsigned uint32_t; +#endif + +#define zero(name, op) \ +int32_t name (int32_t a, int32_t b) \ +{ return a * 0 op b * 0; } + +zero(zeq, ==) zero(zne, !=) zero(zlt, <) +zero(zgt, >) zero(zge, >=) zero(zle, <=) + +#define unsign_pos(name, op) \ +int32_t name (uint32_t a, uint32_t b) \ +{ return a * 4 op b * 4; } + +unsign_pos(upeq, ==) unsign_pos(upne, !=) unsign_pos(uplt, <) +unsign_pos(upgt, >) unsign_pos(upge, >=) unsign_pos(uple, <=) + +#define unsign_neg(name, op) \ +int32_t name (uint32_t a, uint32_t b) \ +{ return a * -2 op b * -2; } + +unsign_neg(uneq, ==) unsign_neg(unne, !=) unsign_neg(unlt, <) +unsign_neg(ungt, >) unsign_neg(unge, >=) unsign_neg(unle, <=) + +#define float(name, op) \ +int32_t name (float a, float b) \ +{ return a * 5 op b * 5; } + +float(feq, ==) float(fne, !=) float(flt, <) +float(fgt, >) float(fge, >=) float(fle, <=) + +#define float_val(name, op) \ +int32_t name (int32_t a, int32_t b) \ +{ return a * 54.0 op b * 54.0; } + +float_val(fveq, ==) float_val(fvne, !=) float_val(fvlt, <) +float_val(fvgt, >) float_val(fvge, >=) float_val(fvle, <=) + +#define vec(name, op) \ +int32_t name (int32_t a, int32_t b) \ +{ int32_t c[10]; return a * c[1] op b * c[1]; } + +vec(veq, ==) vec(vne, !=) vec(vlt, <) +vec(vgt, >) vec(vge, >=) vec(vle, <=) + +/* { dg-final { scan-tree-dump-times "\\(D\\) \\* 4" 24 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\(D\\) \\* 4294967294" 12 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\(D\\) \\* 5\\.0e\\+0" 12 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\* 5\\.4e\\+1" 12 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\(D\\) \\* c\\\$1_8\\(D\\)" 12 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr31096.c b/SingleSource/Regression/C/gcc-dg/pr31096.c new file mode 100644 index 0000000000..32c979ed69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31096.c @@ -0,0 +1,36 @@ +/* PR middle-end/31096 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#define signval_pos(name, op) \ +int name (int a, int b) \ +{ return a * 4 op b * 4; } + +signval_pos(peq, ==) signval_pos(pne, !=) signval_pos(plt, <) +signval_pos(pgt, >) signval_pos(pge, >=) signval_pos(ple, <=) + +#define signval_neg(name, op) \ +int name (int a, int b) \ +{ return a * -23 op b * -23; } + +signval_neg(neq, ==) signval_neg(nne, !=) signval_neg(nlt, <) +signval_neg(ngt, >) signval_neg(nge, >=) signval_neg(nle, <=) + +#define vec_pos(name, op) \ +int name (int a[10], int b[10]) \ +{ return a[3] * 4 op b[8] * 4; } + +vec_pos(vpeq, ==) vec_pos(vpne, !=) vec_pos(vplt, <) +vec_pos(vpgt, >) vec_pos(vpge, >=) vec_pos(vple, <=) + +#define vec_neg(name, op) \ +int name (int a[10], int b[10]) \ +{ return a[3] * -23 op b[8] * -23; } + +vec_neg(vneq, ==) vec_neg(vnne, !=) vec_neg(vnlt, <) +vec_neg(vngt, >) vec_neg(vnge, >=) vec_neg(vnle, <=) + +/* { dg-final { scan-tree-dump-not "\\(D\\) \\* 4" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "\\(D\\) \\* -23" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "_1 = b_2\\(D\\)" 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "_1 = MEM\\\[\\(int \\*\\)b" 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr31127.c b/SingleSource/Regression/C/gcc-dg/pr31127.c new file mode 100644 index 0000000000..f45b10ed5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31127.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void ParseStringSidToSid(char *s, int* p) { + int i = 0; + + while (*s) { + while (*s && *s != '-') + s++; + if (*s== '-') + s++; + + p[i++] = *s; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr31490-2.c b/SingleSource/Regression/C/gcc-dg/pr31490-2.c new file mode 100644 index 0000000000..2449ac468b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31490-2.c @@ -0,0 +1,7 @@ +/* PR middle-end/31490 */ +/* { dg-do compile } */ +/* { dg-options "-fpic" { target fpic } } */ +/* { dg-require-named-sections "" } */ + +const char *const x __attribute__((section("foo"))) = ""; +const char *const g __attribute__((section("foo"))) = (const char *) 0; diff --git a/SingleSource/Regression/C/gcc-dg/pr31490-3.c b/SingleSource/Regression/C/gcc-dg/pr31490-3.c new file mode 100644 index 0000000000..e7ccc677de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31490-3.c @@ -0,0 +1,7 @@ +/* PR middle-end/31490 */ +/* { dg-do compile } */ +/* { dg-options "-fpic" { target fpic } } */ +/* { dg-require-named-sections "" } */ + +const char *const x __attribute__((section("foo"))) = (const char *) 0; +const char *const g __attribute__((section("foo"))) = "bar"; diff --git a/SingleSource/Regression/C/gcc-dg/pr31490-4.c b/SingleSource/Regression/C/gcc-dg/pr31490-4.c new file mode 100644 index 0000000000..cbfc68730f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31490-4.c @@ -0,0 +1,10 @@ +/* PR middle-end/31490 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -fpic" { target fpic } } */ +/* { dg-require-named-sections "" } */ + +const char *const x __attribute__((section("foo"))) = ""; +const char *const g __attribute__((section("foo"))) = (const char *) 0; +const char *const y __attribute__((section("bar"))) = (const char *) 0; +const char *const h __attribute__((section("bar"))) = "bar"; diff --git a/SingleSource/Regression/C/gcc-dg/pr31490.c b/SingleSource/Regression/C/gcc-dg/pr31490.c new file mode 100644 index 0000000000..37731b3a33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31490.c @@ -0,0 +1,10 @@ +/* PR middle-end/31490 */ +/* { dg-do compile } */ +/* { dg-require-named-sections "" } */ +/* { dg-require-effective-target ptr32plus } */ + +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; + +int cpu (void *attr) {} +const uintptr_t x __attribute__((section("foo"))) = (uintptr_t)&cpu; +const uintptr_t g __attribute__((section("foo"))) = 0; diff --git a/SingleSource/Regression/C/gcc-dg/pr31507-1.c b/SingleSource/Regression/C/gcc-dg/pr31507-1.c new file mode 100644 index 0000000000..f6a7e747db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31507-1.c @@ -0,0 +1,42 @@ +/* PR target/31507 */ +/* { dg-do run } */ +/* { dg-options "-Os -fno-omit-frame-pointer" } */ +/* { dg-require-effective-target alloca } */ + +extern void abort (void); + +__attribute__((noinline)) void +foo (double d0, double d1, double d2, double d3, + double d4, double d5, double d6, double d7, + float f0, float f1, float f2, float f3, + char *p) +{ + if (d0 != 0 || d1 != 1 || d2 != 2 || d3 != 3) + abort (); + if (d4 != 4 || d5 != 5 || d6 != 6 || d7 != 7) + abort (); + if (f0 != 10 || f1 != 11 || f2 != 12 || f3 != 13) + abort (); + if (__builtin_memcmp (p, "foo", 4) != 0) + abort (); + __builtin_memcpy (p, "bar", 4); +} + +__attribute__((noinline)) void +bar (int x) +{ + char p[x]; + if (x >= sizeof "foo") + __builtin_memcpy (p, "foo", 4); + foo (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, + 10.0f, 11.0f, 12.0f, 13.0f, p); + if (x >= sizeof "bar" && __builtin_memcmp (p, "bar", 4) != 0) + abort (); +} + +int +main (void) +{ + bar (128); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr31507-2.c b/SingleSource/Regression/C/gcc-dg/pr31507-2.c new file mode 100644 index 0000000000..ee2388b7e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31507-2.c @@ -0,0 +1,14 @@ +/* PR target/31507 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-omit-frame-pointer" } */ + +typedef int (*closure_test_type3)(float, float, float, float, float, float, + float, float, double, int, float, float, int, + float, float, int); +int f (closure_test_type3 pcl) +{ + int res; + res = (pcl) + (1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9, 10, 11.11, 12.0, 13, + 19.19, 21.21, 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr31529-1.c b/SingleSource/Regression/C/gcc-dg/pr31529-1.c new file mode 100644 index 0000000000..24d2cdbd83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31529-1.c @@ -0,0 +1,11 @@ +/* { dg-do link } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -fgnu89-inline" } */ +/* { dg-additional-sources "pr31529-2.c" } */ + +int +getline () +{ +} + +int main() { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr31529-2.c b/SingleSource/Regression/C/gcc-dg/pr31529-2.c new file mode 100644 index 0000000000..7f8c40f49e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31529-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +extern __inline +int +getline () +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr31847.c b/SingleSource/Regression/C/gcc-dg/pr31847.c new file mode 100644 index 0000000000..cf8e04dba8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31847.c @@ -0,0 +1,14 @@ +/* PR 31847 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-pre-all" } */ + +extern int bar(int); + +int foo() +{ + int a = 0; + return bar(a); +} + +/* { dg-final { scan-tree-dump-not "Created value for " "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr31866.c b/SingleSource/Regression/C/gcc-dg/pr31866.c new file mode 100644 index 0000000000..d6a2ab0569 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31866.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/31866 */ +/* { dg-do compile { target alpha*-*-* cris-*-* i?86-*-* mmix-*-* powerpc*-*-* rs6000-*-* x86_64-*-* } } */ +/* { dg-options "-O2" } */ + +#if defined (__alpha__) +# define REG "$1" +#elif defined (__CRIS__) +# define REG "r10" +#elif defined (__i386__) +# define REG "%eax" +#elif defined (__MMIX__) +# define REG "$8" +#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \ + || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2) +# define REG "6" +#elif defined (__x86_64__) +# define REG "rax" +#endif + +long int +foo (void) +{ + unsigned long int s; + long int a = (long int) 0; + register long int r asm (REG) = a; + asm ("" : "=r" (s) : "0" (r)); + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr31959.c b/SingleSource/Regression/C/gcc-dg/pr31959.c new file mode 100644 index 0000000000..f8090f45cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr31959.c @@ -0,0 +1,20 @@ +/* PR middle-end/31959 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -fguess-branch-probability" } */ + +struct A { int i; }; + +static inline struct A * +bar (struct A *x) +{ + return x; +} + +void * +foo (struct A *x, int y) +{ + void *p = (void *) 0; + if (__builtin_expect (y >= 6, 0)) + p = bar (x); + return p; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32041.c b/SingleSource/Regression/C/gcc-dg/pr32041.c new file mode 100644 index 0000000000..60837b2043 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32041.c @@ -0,0 +1,12 @@ +/* PR c/32041 */ +/* { dg-do compile } */ + +struct S +{ + int c; + struct { float f; } sa[2]; +}; + +char a[__builtin_offsetof (struct S, sa->f) + == __builtin_offsetof (struct S, sa[0].f) ? 1 : -1]; + diff --git a/SingleSource/Regression/C/gcc-dg/pr32061.c b/SingleSource/Regression/C/gcc-dg/pr32061.c new file mode 100644 index 0000000000..dc1a916f1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32061.c @@ -0,0 +1,10 @@ +/* PR c/32061 + { dg-do compile } + { dg-options "-Wlogical-op -Wall -Wextra" } +*/ +#define FORCE 1 +#define FLAG 1 +int func (int resp, int flags) +{ + return (resp && (FORCE || (FLAG & flags))); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32069.c b/SingleSource/Regression/C/gcc-dg/pr32069.c new file mode 100644 index 0000000000..87a3f187e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32069.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -fsplit-wide-types" } */ + +long long int segfault (long long int a, long long int b) +{ + return a ^ b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32135.c b/SingleSource/Regression/C/gcc-dg/pr32135.c new file mode 100644 index 0000000000..4459656441 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32135.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-Warray-bounds -O2" } */ +struct PhaseEntryType +{ + char raw_field[50 + 1]; +}; +int +ParsePhase (char in_cols[15][250], struct PhaseEntryType *P) +{ + __builtin_strncpy (P->raw_field, in_cols[2], 50); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32176.c b/SingleSource/Regression/C/gcc-dg/pr32176.c new file mode 100644 index 0000000000..e619f2f182 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32176.c @@ -0,0 +1,30 @@ +/* Contributed by Francois-Xavier Coudert */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */ +/* { dg-additional-options "-march=i686 -msse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern void _gfortran_abort (); + +void foo (void) +{ + int i, m; + float xa[21]; + + m = 0; + while (1) + { + i = 0; + while (1) + { + if (xa[(long int)i] == xa[(long int)(i+m)]) + _gfortran_abort (); + if (i == 10) + break; + i++; + } + if (m == 10) + break; + m++; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32207.c b/SingleSource/Regression/C/gcc-dg/pr32207.c new file mode 100644 index 0000000000..cf9bef8099 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32207.c @@ -0,0 +1,9 @@ +/* Test warning for comparison non-null address with null pointer constant. */ +/* Origin: Pawel Sikora */ +/* { dg-do compile } */ +/* { dg-options "-Waddress" } */ +extern void z(); + +void f() { if ( z ) z(); } /* { dg-warning "always evaluate as" } */ +void g() { if ( z != 0 ) z(); } /* { dg-warning "the comparison will always evaluate as 'true'" } */ +void h() { if ( z != (void*)0 ) z(); } /* { dg-warning "the comparison will always evaluate as 'true'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr32293.c b/SingleSource/Regression/C/gcc-dg/pr32293.c new file mode 100644 index 0000000000..fb1268ba1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32293.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned int _IDEC_glbround; +unsigned int _IDEC_glbflags; +typedef unsigned UINT32; +typedef signed SINT32; +typedef unsigned long long UINT64; +typedef signed long long SINT64; +typedef +__attribute__ ((aligned(16))) + struct { + UINT64 w[2]; + } UINT128; + +static __inline UINT64 +unpack_BID128 (UINT64 * psign_x, int *pexponent_x, + UINT128 * pcoefficient_x, UINT128 * px) { + UINT128 coeff; + UINT64 ex; + *psign_x = (px->w[1]) & 0x8000000000000000ull; + ex = (px->w[1]) >> 49; + *pexponent_x = ((int) ex) & 0x3fff; + return coeff.w[0] | coeff.w[1]; +} + +static __inline UINT32 +get_BID32 (UINT32 sgn, int expon, UINT64 coeff, int rmode, + unsigned *fpsc) { + UINT32 r; + + if (((unsigned) expon) > 191) { + r = sgn | 0x78000000ul; + switch (rmode) { + case 0x00002: + if (sgn) + r = sgn | 0x77f8967f; + } + return r; + } + r = expon; + return r; +} + +UINT32 +bid128_to_bid32 (UINT128 x) +{ + UINT128 *px; + UINT128 CX; + UINT64 sign_x; + UINT32 res; + int exponent_x = 0; + px = &x; + if (!unpack_BID128 (&sign_x, &exponent_x, &CX, px)) { + return(res); + } + res = get_BID32 ((UINT32) (sign_x >> 32), + exponent_x, CX.w[0], _IDEC_glbround, &_IDEC_glbflags); + return(res);; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr32328.c b/SingleSource/Regression/C/gcc-dg/pr32328.c new file mode 100644 index 0000000000..7aa709f892 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32328.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +struct barstruct { char const* some_string; }; + +void changethepointer(struct barstruct**); + +void baz() +{ + struct barstruct bar1; + struct barstruct* barptr = &bar1; + changethepointer(&barptr); + barptr->some_string = "Everything OK"; +} + +/* { dg-final { scan-tree-dump "Everything OK" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr32338-1.c b/SingleSource/Regression/C/gcc-dg/pr32338-1.c new file mode 100644 index 0000000000..6a79a8c228 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32338-1.c @@ -0,0 +1,47 @@ +/* PR target/32338 */ +/* { dg-do link } */ +/* { dg-options "-O2 -fno-omit-frame-pointer" } */ + +struct S +{ +}; + +int +__attribute__((noinline)) +foo (struct S *d) +{ + return 2; +} + +int +__attribute__((noinline)) +bar (struct S *d) +{ + return 4; +} + +int +__attribute__((noinline)) +fnl (char const *q) +{ + return __builtin_strlen (q); +} + +int +__attribute__((noinline)) +baz (struct S *d, char const *q) +{ + unsigned int len; + len = fnl (q); + if (len > 512) + return bar (d); + return foo (d); +} + +int +main (int argc, char *argv[]) +{ + if (argc > 30) + return baz ((void *) 0, "abcde"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32338-2.c b/SingleSource/Regression/C/gcc-dg/pr32338-2.c new file mode 100644 index 0000000000..81daddf6a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32338-2.c @@ -0,0 +1,47 @@ +/* PR target/32338 */ +/* { dg-do link } */ +/* { dg-options "-O2 -fno-omit-frame-pointer" } */ + +struct S +{ +}; + +int +__attribute__((noinline)) +foo (void) +{ + return 2; +} + +int +__attribute__((noinline)) +bar (void) +{ + return 4; +} + +int +__attribute__((noinline)) +fnl (void) +{ + return 6; +} + +int +__attribute__((noinline)) +baz (void) +{ + unsigned int len; + len = fnl (); + if (len > 512) + return bar (); + return foo (); +} + +int +main (int argc, char *argv[]) +{ + if (argc > 30) + return baz (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32370.c b/SingleSource/Regression/C/gcc-dg/pr32370.c new file mode 100644 index 0000000000..fc3d724e6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32370.c @@ -0,0 +1,30 @@ +/* PR middle-end/32370 */ +/* { dg-do compile { target i?86-*-* x86_64-*-* ia64-*-* } } */ +/* { dg-options "" { target ia64-*-* } } */ +/* { dg-options "-ffixed-esi" { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-mabi=sysv -ffixed-esi" { target x86_64-*-mingw* } } */ + +#if (defined __i386__ || defined __x86_64__) && ! defined _WIN64 +# define C "=S" +# define TYPE unsigned long +#elif defined __ia64__ || defined _WIN64 +# define C "=a" +# define TYPE unsigned long long +#endif + +#ifdef _WIN64 +__extension__ +#endif +unsigned int +foo (TYPE port) +{ + unsigned int v; + __asm__ __volatile__ ("" : C (v) : "Nd" (port)); /* { dg-error "while reloading\|has impossible\|inconsistent operand constraints" } */ + return v; +} + +void +bar (void) +{ + foo (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32374.c b/SingleSource/Regression/C/gcc-dg/pr32374.c new file mode 100644 index 0000000000..de15d559f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32374.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int *stderr; + +void f (int *, const char *, ...); + +void g (const char *conf_name) +{ + typedef struct + { + const char *label; + const int value; + } Section; + + const Section sections[2] = { {"", 0}, {"", 1} }; + + f (stderr, "", "", conf_name, 0, sections[0]); + f (stderr, "", "", conf_name, 0, sections[0]); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32450.c b/SingleSource/Regression/C/gcc-dg/pr32450.c new file mode 100644 index 0000000000..9606e3021e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32450.c @@ -0,0 +1,36 @@ +/* Contributed by Joost VandeVondele */ + +/* { dg-do run } */ +/* { dg-require-profiling "-pg" } */ +/* { dg-options "-O2 -pg" } */ +/* { dg-options "-O2 -pg -mtune=core2" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */ + +extern void abort (void); + +int stack_pointer; + +void +__attribute__((noinline)) +mystop () +{ + abort (); +} + +void +__attribute__((noinline)) +add () +{ + if (stack_pointer + 1 > 10) + mystop (); + + stack_pointer = stack_pointer + 1; +} + +int main () +{ + add (); + return stack_pointer - 1; +} + +/* { dg-final { cleanup-profile-file } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr32559.c b/SingleSource/Regression/C/gcc-dg/pr32559.c new file mode 100644 index 0000000000..fee1c97907 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32559.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int __attribute__((vector_size (8))) v; + +void foo() +{ + v += ~v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32573.c b/SingleSource/Regression/C/gcc-dg/pr32573.c new file mode 100644 index 0000000000..190f5dbac6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32573.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/32573 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +long long bar (void *); + +int +foo (void *x, long long *y) +{ + char a[256]; + int i = 0; + long long b; + int c; + int d = 0; + int e = 0; + unsigned f = 0; + b = bar (x); + c = (unsigned) b; + while (d < b && d < 65557) + { + f = *(unsigned *) &a[0]; + for (i = c - 4; i > 0; i--) + if (a[i + 0] == 0x50 + && a[i + 1] == 0x4B + && a[i + 3] == 0x06) + { + e = 1; + break; + } + } + return !e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32721.c b/SingleSource/Regression/C/gcc-dg/pr32721.c new file mode 100644 index 0000000000..c9526f67a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32721.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int spinlock[2]; +int main () +{ +volatile int * spinlock0; +volatile int * spinlock1; +spinlock0 = &spinlock[0]; +spinlock1 = &spinlock[1]; + +*spinlock0 = 0; +*spinlock1 = 0; + while (*spinlock0); +} + +/* { dg-final { scan-tree-dump "={v} .*spinlock" "optimized" } } */ +/* { dg-final { scan-tree-dump "spinlock.* ={v}" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr32773.c b/SingleSource/Regression/C/gcc-dg/pr32773.c new file mode 100644 index 0000000000..55b6b1c496 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32773.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fprofile-use -fopt-info-missed-ipa -Wno-missing-profile" } */ +/* { dg-options "-O -m4 -fprofile-use -fopt-info-missed-ipa -Wno-missing-profile" { target sh-*-* } } */ + +void foo (int *p) +{ + if (p) + *p = 0; +} /* { dg-missed "\[^\n\]*execution counts estimated" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr32912-1.c b/SingleSource/Regression/C/gcc-dg/pr32912-1.c new file mode 100644 index 0000000000..0f9f64ac78 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32912-1.c @@ -0,0 +1,47 @@ +/* PR middle-end/32912 */ +/* { dg-do run } */ +/* { dg-options "-O2 -w" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-additional-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ + +extern void abort (void); + +typedef int __m128i __attribute__ ((__vector_size__ (16))); + +__m128i a, b, c, d, e, f; + +void +foo (__m128i x) +{ + a = x ^ ~x; + b = ~x ^ x; + c = x | ~x; + d = ~x | x; + e = x & ~x; + f = ~x & x; +} + +int +main (void) +{ + union { __m128i v; int i[sizeof (__m128i) / sizeof (int)]; } u; + int i; + + for (i = 0; i < sizeof (u.i) / sizeof (u.i[0]); i++) + u.i[i] = i * 49 - 36; + foo (u.v); +#define check(x, val) \ + u.v = (x); \ + for (i = 0; i < sizeof (u.i) / sizeof (u.i[0]); i++) \ + if (u.i[i] != (val)) \ + abort () + + check (a, ~0); + check (b, ~0); + check (c, ~0); + check (d, ~0); + check (e, 0); + check (f, 0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32912-2.c b/SingleSource/Regression/C/gcc-dg/pr32912-2.c new file mode 100644 index 0000000000..2e800784d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32912-2.c @@ -0,0 +1,58 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -w" } */ + +extern void abort (void); + +#if(__SIZEOF_INT__ >= 4) +# define TYPE int +# define TYPED(a) a + +#elif(__SIZEOF_INT__ > 2) +# define TYPE long +# define TYPED(a) a##L + +#else +# define TYPE long long +# define TYPED(a) a##LL +#endif + + +typedef TYPE __m128i __attribute__ ((__vector_size__ (16))); + +__m128i +foo (void) +{ + __m128i x = { 0x11111111, 0x22222222, 0x44444444 }; + return x; +} + +__m128i +bar (void) +{ + __m128i x = { 0x11111111, 0x22222222, 0x44444444 }; + return ~x; +} + +int +main (void) +{ + union { __m128i v; TYPE i[sizeof (__m128i) / sizeof (TYPE)]; } u, v; + int i; + + u.v = foo (); + v.v = bar (); + for (i = 0; i < sizeof (u.i) / sizeof (u.i[0]); i++) + { + if (u.i[i] != ~v.i[i]) + abort (); + + if (i < 3) + { + if (u.i[i] != (TYPED (0x11111111) << i)) + abort (); + } + else if (u.i[i]) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr32912-3.c b/SingleSource/Regression/C/gcc-dg/pr32912-3.c new file mode 100644 index 0000000000..04d9e2dd8f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32912-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-w -O2 -fdump-tree-optimized" } */ + +typedef int __m128i __attribute__ ((__vector_size__ (16))); + +__m128i +bar (void) +{ + __m128i x = { 0x11111111, 0x22222222, 0x44444444 }; + return ~x; +} + +/* { dg-final { scan-tree-dump-not "~\{" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr32975.c b/SingleSource/Regression/C/gcc-dg/pr32975.c new file mode 100644 index 0000000000..8ddb0d8d2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr32975.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/32975 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -finline-functions -fipa-cp" } */ + +static int +f0 (char *s0, char *s1) +{ + return __builtin_strlen (s0) > __builtin_strlen (s1); +} + +int +f1 (char *s, int j) +{ + if (f0 (s, "")) + return 1; + return j; +} + +void +f2 (char *s) +{ + f1 (s, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33007.c b/SingleSource/Regression/C/gcc-dg/pr33007.c new file mode 100644 index 0000000000..c583ab6522 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33007.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -ftrapping-math" } */ +/* { dg-warning ".-fassociative-math. disabled" "" { target *-*-* } 0 } */ + +long +foo (int i) +{ + float x; + x = i; + return __builtin_lroundf (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33017.c b/SingleSource/Regression/C/gcc-dg/pr33017.c new file mode 100644 index 0000000000..851fe71f86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33017.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/33017 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +extern __SIZE_TYPE__ strlen (const char *); +extern void abort (void); + +char * +__attribute__((noinline)) +foo (const char *string) +{ + int len; + static char var[0x104]; + int off; + len = strlen (string); + for (off = 0; off < 64; off++) + var[len + off + 2] = 0x57; + return var; +} + +int +main (void) +{ + char *p = foo ("abcd"); + int i; + for (i = 0; i < 0x104; i++) + if (p[i] != ((i >= 6 && i < 70) ? 0x57 : 0)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33136-1.c b/SingleSource/Regression/C/gcc-dg/pr33136-1.c new file mode 100644 index 0000000000..d07c97eb7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33136-1.c @@ -0,0 +1,54 @@ +/* PR tree-optimization/33136 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +struct S +{ + struct S *a; + int b; + float f; +}; + +static struct S s; + +static int * +__attribute__((noinline, const)) +foo (void) +{ + return &s.b; +} + +float +__attribute__((noinline)) +bar (float *f) +{ + s.f = 1.0; + *f = 4.0; + return s.f; +} + +int +__attribute__((noinline)) +baz (int *x) +{ + s.b = 1; + *x = 4; + return s.b; +} + +int +t (void) +{ + float f = 8.0; + return bar (&f) + baz (foo ()); +} + +int +main (void) +{ + if (t () != 5) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33136-2.c b/SingleSource/Regression/C/gcc-dg/pr33136-2.c new file mode 100644 index 0000000000..760b5a06fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33136-2.c @@ -0,0 +1,60 @@ +/* PR tree-optimization/33136 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +struct S +{ + void *a; + int b; + int *c; +}; +static int d, e; + +static struct S s; + +static int * +__attribute__((noinline, const)) +foo (void) +{ + return &s.b; +} + +int * +__attribute__((noinline)) +bar (int **f) +{ + s.c = &d; + *f = &e; + /* As nothing ever takes the address of any int * field in struct S, + the write to *f can't alias with the s.c field. */ + return s.c; +} + +int +__attribute__((noinline)) +baz (int *x) +{ + s.b = 1; + *x = 4; + /* Function foo takes address of an int field in struct S, + so *x can alias with the s.b field (and it does in this testcase). */ + return s.b; +} + +int +__attribute__((noinline)) +t (void) +{ + int *f = (int *) 0; + return 10 * (bar (&f) != &d) + baz (foo ()); +} + +int +main (void) +{ + if (t () != 4) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33136-3.c b/SingleSource/Regression/C/gcc-dg/pr33136-3.c new file mode 100644 index 0000000000..fcb5972ebf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33136-3.c @@ -0,0 +1,60 @@ +/* PR tree-optimization/33136 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +struct S +{ + void *a; + int b[3]; + double *c; +}; +static double d, e; + +static struct S s; + +static int * +__attribute__((noinline, const)) +foo (void) +{ + return (int *) &s.b; +} + +double * +__attribute__((noinline)) +bar (double **f) +{ + s.c = &d; + *f = &e; + /* As nothing ever takes the address of any double * field in struct S, + the write to *f can't alias with the s.c field. */ + return s.c; +} + +int +__attribute__((noinline)) +baz (int *x) +{ + s.b[0] = 1; + *x = 4; + /* Function foo takes address of an int array field in struct S, + so *x can alias with the s.b field (and it does in this testcase). */ + return s.b[0]; +} + +int +__attribute__((noinline)) +t (void) +{ + double *f = (double *) 0; + return 10 * (bar (&f) != &d) + baz (foo ()); +} + +int +main (void) +{ + if (t () != 4) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33238.c b/SingleSource/Regression/C/gcc-dg/pr33238.c new file mode 100644 index 0000000000..993384a186 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33238.c @@ -0,0 +1,13 @@ +/* PR c/33238 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ +/* { dg-require-effective-target alloca } */ + +void +reverse (void *x, int y, int z) +{ + struct { char w[z]; } *p = x, a; + int i, j; + for (i = y - 1, j = 0; j < y / 2; i--, j++) + ({ a = p[i]; p[i] = p[j]; p[j] = a; }); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33434-1.c b/SingleSource/Regression/C/gcc-dg/pr33434-1.c new file mode 100644 index 0000000000..d646ff74d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33434-1.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/33434 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int k; + +void f1 (int a, int b) +{ + a = 1; + b = 1; + if (a) + while (b --) + k = 1; + else + if (b != 1) + __builtin_abort (); +} + +int main (void) +{ + f1 (1, 1); + if (k != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33434-2.c b/SingleSource/Regression/C/gcc-dg/pr33434-2.c new file mode 100644 index 0000000000..7dd614c0af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33434-2.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/33434 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int k; + +void f1 (int a) +{ + int b; + a = 1; + b = 1; + if (a) + while (b --) + k = 1; + else + if (b != 1) + __builtin_abort (); +} + +int main (void) +{ + f1 (1); + if (k != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33434-3.c b/SingleSource/Regression/C/gcc-dg/pr33434-3.c new file mode 100644 index 0000000000..3e99451fb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33434-3.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/33434 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +int k; + +void __attribute__((noinline)) f2 (int b) +{ + k = b - 1; +} + +void f1 (int a, int b) +{ + f2 (b); + a = 1; + b = 1; + if (a) + while (b --) + k = 1; + else + if (b != 1) + __builtin_abort (); +} + +int main (void) +{ + f1 (1, 1); + if (k != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33434-4.c b/SingleSource/Regression/C/gcc-dg/pr33434-4.c new file mode 100644 index 0000000000..d34675fe4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33434-4.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/33434 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void *baz (void); + +static void * +bar (void *x) +{ + x = baz (); + return x; +} + +void * +foo (void *x) +{ + return bar (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33619.c b/SingleSource/Regression/C/gcc-dg/pr33619.c new file mode 100644 index 0000000000..8011e69e6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33619.c @@ -0,0 +1,45 @@ +/* PR tree-optimization/33619 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#ifdef __powerpc__ +# define REG1 __asm__ ("3") +# define REG2 __asm__ ("4") +#elif defined __x86_64__ +# define REG1 __asm__ ("rdi") +# define REG2 __asm__ ("rsi") +#else +# define REG1 +# define REG2 +#endif + +static inline void +bar (unsigned long x, int y) +{ + register unsigned long p1 REG1 = x; + register unsigned long p2 REG2 = y; + __asm__ volatile ("" : "=r" (p1), "=r" (p2) : "0" (p1), "1" (p2) : "memory"); + if (p1 != 0xdeadUL || p2 != 0xbefUL) + __builtin_abort (); +} + +__attribute__((const, noinline)) int +baz (int x) +{ + return x; +} + +__attribute__((noinline)) void +foo (unsigned long *x, int y) +{ + unsigned long a = *x; + bar (a, baz (y)); +} + +int +main (void) +{ + unsigned long a = 0xdeadUL; + foo (&a, 0xbefUL); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33644.c b/SingleSource/Regression/C/gcc-dg/pr33644.c new file mode 100644 index 0000000000..f3f543cbe9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33644.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/33644 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftrapv" } */ + +extern char *bar (const char *); + +int *m, *b; + +void foo (void) +{ + int *mv; + int p; + char a[17]; + + p = bar (a) - a; + for (mv = m; mv < b; mv++) + if (p && ((*mv & 7) != p)) + *mv=0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33645-1.c b/SingleSource/Regression/C/gcc-dg/pr33645-1.c new file mode 100644 index 0000000000..1ec8a2ff87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33645-1.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/33645 */ +/* { dg-do link } */ +/* { dg-options "-O2 -fno-unit-at-a-time" } */ + +__attribute__((noinline)) int +bar (int *x) +{ + return *x++; +} + +int +main () +{ + static int var1_s; + static int *var1_t = &var1_s; + + return bar (var1_t) != 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33645-2.c b/SingleSource/Regression/C/gcc-dg/pr33645-2.c new file mode 100644 index 0000000000..3c4bcb060e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33645-2.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/33645 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funit-at-a-time" } */ + +__attribute__((noinline)) int +bar (int *x) +{ + return *x++; +} + +int +main () +{ + static int var1_s; + static int *var1_t = &var1_s; + + return bar (var1_t) != 0; +} + +/* { dg-final { scan-assembler-not "var1_t" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr33648.c b/SingleSource/Regression/C/gcc-dg/pr33648.c new file mode 100644 index 0000000000..f5da55cd47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33648.c @@ -0,0 +1,14 @@ +/* PR rtl-optimization/33648 */ +/* { dg-do compile } */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -fmodulo-sched -freorder-blocks-and-partition" } */ + +unsigned res; + +void +foo (unsigned code, int len) +{ + int i; + for (i = 0; i < len; i++) + res |= code & 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33653.c b/SingleSource/Regression/C/gcc-dg/pr33653.c new file mode 100644 index 0000000000..966efecd89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33653.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-shorten" } */ + +void f (volatile char *p) +{ + char c = p[0]; +} + +/* { dg-final { scan-rtl-dump "mem/v" "shorten" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr33666.c b/SingleSource/Regression/C/gcc-dg/pr33666.c new file mode 100644 index 0000000000..1f27b136d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33666.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options { -std=c99 } } */ + +/* This used to fail with type-checking enabled because we stripped + the inner conversion to unsigned int. */ + +void __lock_get_list(void *dp) +{ + if (((__SIZE_TYPE__)dp + 1) & ~1ULL) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33667.c b/SingleSource/Regression/C/gcc-dg/pr33667.c new file mode 100644 index 0000000000..676c4a46da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33667.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +__extension__ typedef __SIZE_TYPE__ size_t; +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned long long int uint64_t; +struct magic { + uint8_t mask_op; + union { + uint64_t _mask; + } _u; + union VALUETYPE { + uint16_t h; + } value; +}; +void cvt_16(union VALUETYPE *p, const struct magic *m) +{ + if (m->_u._mask) + p->h %= (uint16_t) m->_u._mask; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33670.c b/SingleSource/Regression/C/gcc-dg/pr33670.c new file mode 100644 index 0000000000..5232af9654 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33670.c @@ -0,0 +1,19 @@ +/* PR middle-end/33670 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsched-stalled-insns=0" } */ + +struct B +{ + int p; + int n; +}; +extern struct B ***b; +extern int a; + +int +foo (int d, int e) +{ + int c; + for (c = d; c <= e; c++) + b[a][c]->n = b[a][c]->p; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33673.c b/SingleSource/Regression/C/gcc-dg/pr33673.c new file mode 100644 index 0000000000..d238d112cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33673.c @@ -0,0 +1,43 @@ +/* PR rtl-optimization/33673 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-forward-propagate -fno-guess-branch-probability -fno-move-loop-invariants -fno-tree-dominator-opts -fno-tree-loop-optimize" } */ + +extern int f1 (int); +extern int f2 (int); + +extern int *a; + +static void +find_reg (int n) +{ + int i, pass; + unsigned int used[2], used1[2]; + + int c = n ? f1 (a[1]) : f2 (a[1]); + + for (i = 64, pass = 0; pass <= 1 && i >= 64; pass++) + { + if (pass == 1) + { + unsigned int *scan_tp_ = used; + unsigned int *scan_fp_ = used1; + int j; + for (j = 0; j < 2; j++) + *scan_tp_++ = *scan_fp_++; + } + for (i = 0; i < 64; i++) + { + int regno = i; + if (n == 0) + if (i == regno) + break; + } + } +} + +void +global_alloc () +{ + find_reg (0); + find_reg (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33676.c b/SingleSource/Regression/C/gcc-dg/pr33676.c new file mode 100644 index 0000000000..c2344708c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33676.c @@ -0,0 +1,52 @@ +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-options "-O0 -mtune=i386 -fomit-frame-pointer" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +__attribute__((noreturn,noinline)) void abrt (const char *fi, const char *fu) +{ + __builtin_abort (); +} + +__attribute__((noinline)) int f (int k) +{ + return k; +} + +__attribute__((noinline)) int g (int t, int k) +{ + int b; + + switch (t) + { + case 0: + abrt (__FILE__, __FUNCTION__); + + case 1: + b = f (k); + break; + + case 2: + b = f (k); + break; + + case 3: + b = f (k); + break; + + case 4: + b = f (k); + break; + + default: + abrt (__FILE__, __FUNCTION__); + } + + return b; +} + +int main (void) +{ + if (g (3, 1337) != 1337) + abrt (__FILE__, __FUNCTION__); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33691.c b/SingleSource/Regression/C/gcc-dg/pr33691.c new file mode 100644 index 0000000000..93213610d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33691.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +/* ICEd with type-checking enabled. */ + +unsigned int mgaSetTexImages(int i) +{ + return ((i | 0x40) & 0xffffffc0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33692.c b/SingleSource/Regression/C/gcc-dg/pr33692.c new file mode 100644 index 0000000000..08ee332ddf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33692.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +/* We ICEd with type-checking enabled. */ + +typedef struct { int i; } snd_pcm_info_t; +typedef struct { snd_pcm_info_t info; } snd_pcm_shm_ctrl_t; +void snd_pcm_info(snd_pcm_info_t *); +int pcm_shm_cmd(volatile snd_pcm_shm_ctrl_t *ctrl) +{ + snd_pcm_info((snd_pcm_info_t *) &ctrl->info); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr33693.c b/SingleSource/Regression/C/gcc-dg/pr33693.c new file mode 100644 index 0000000000..147c164c4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33693.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +/* This used to ICE with type-checking enabled. */ + +unsigned long modify_field (unsigned long mask, long fieldval) +{ + return (~fieldval & ~mask); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33694.c b/SingleSource/Regression/C/gcc-dg/pr33694.c new file mode 100644 index 0000000000..fa62b9eaed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33694.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-ansi" } */ + +/* This used to ICE with type-checking enabled. */ + +__SIZE_TYPE__ cnfs_mapcntl(long pagesize) +{ + return ~(__SIZE_TYPE__)(pagesize - 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33695.c b/SingleSource/Regression/C/gcc-dg/pr33695.c new file mode 100644 index 0000000000..2d3ffbd668 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33695.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +/* We used to ICE with type-checking enabled. */ + +unsigned int bfstages(int M, float *Utbl, int Ustride) +{ + return ((unsigned int) 1 << M) * Ustride; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33696.c b/SingleSource/Regression/C/gcc-dg/pr33696.c new file mode 100644 index 0000000000..97bbfe8bf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33696.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +/* This used to ICE with type-checking enabled. */ + +typedef unsigned char uint8_t; +typedef unsigned int uint_least32_t; +extern int foo (long int __off); +void write (uint_least32_t chunk_len) +{ + uint8_t tmp[4]; + foo (-(long)chunk_len - sizeof(tmp)); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr33697.c b/SingleSource/Regression/C/gcc-dg/pr33697.c new file mode 100644 index 0000000000..8c5edb6585 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33697.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +/* We used to ICE for this with type-checking enabled. */ + +typedef signed short gint16; +typedef unsigned short guint16; +gint16 dissect_old_pflog(gint16 rnr) +{ + return (guint16) ((guint16) ((guint16)rnr >> 8) | (guint16) ((guint16)rnr << 8)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33724.c b/SingleSource/Regression/C/gcc-dg/pr33724.c new file mode 100644 index 0000000000..7e8eb5ddd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33724.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +/* We ICEd with type-checking enabled. */ + +struct xt_entry_target { + char name[1]; +}; +struct ipt_entry { + unsigned char elems[1]; +}; +void match_different(const unsigned char *); +int dump_entry(struct xt_entry_target *t) +{ + return __builtin_strcmp (t->name, ""); +} +void is_same(const struct ipt_entry *a) +{ + match_different(a->elems); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr33726.c b/SingleSource/Regression/C/gcc-dg/pr33726.c new file mode 100644 index 0000000000..e87cbc5657 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33726.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +/* We used to ICE here with type-checking enabled. */ + +typedef unsigned int U032; +typedef volatile struct X { + U032 Monochrome[1]; + struct { + U032 WidthHeight; + } UnclippedRectangle[1]; +} RivaBitmap; +void writel(void *); +void rivafb_fillrect(RivaBitmap *bm) +{ + writel((void *)&bm->UnclippedRectangle[0].WidthHeight); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr33742.c b/SingleSource/Regression/C/gcc-dg/pr33742.c new file mode 100644 index 0000000000..b905d9ddad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33742.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +typedef unsigned short ush; +extern ush prev[]; + +void fill_window () +{ + register unsigned n, m; + + for (n = 0; n < 32768; n++) + { + m = prev[n]; + prev[n] = (ush) (m >= 0x8000 ? m - 0x8000 : 0); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33826.c b/SingleSource/Regression/C/gcc-dg/pr33826.c new file mode 100644 index 0000000000..d2227743a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33826.c @@ -0,0 +1,49 @@ +/* Regression test for PR middle-end/33826 */ +/* Verify that recursive functions cannot be pure or const. */ + +/* { dg-do compile { target { nonpic || pie_enabled } } } */ +/* { dg-options "-O1 -fdump-tree-local-pure-const1 -fdump-ipa-pure-const" } */ + +int recurse1 (int); +int recurse2b (int); +int norecurse1b (int); + +int recurese1 (int i) +{ + return recurse1 (i+1); +} + +int recurse2a (int i) +{ + return recurse2b (i+1); +} + +int recurse2b (int i) +{ + return recurse2a (i+1); +} + +int norecurse1a (int i) +{ + return norecurse1b (i+1); +} + +int norecurse1b (int i) +{ + return i+1; +} + +/* { dg-final { scan-tree-dump "found to be const: norecurse1a" "local-pure-const1" } } */ +/* { dg-final { scan-tree-dump "found to be const: norecurse1b" "local-pure-const1" } } */ +/* { dg-final { scan-tree-dump-not "found to be pure: recurse1" "local-pure-const1" } } */ +/* { dg-final { scan-tree-dump-not "found to be pure: recurse2a" "local-pure-const1" } } */ +/* { dg-final { scan-tree-dump-not "found to be pure: recurse2b" "local-pure-const1" } } */ +/* { dg-final { scan-tree-dump-not "found to be const: recurse1" "local-pure-const1" } } */ +/* { dg-final { scan-tree-dump-not "found to be const: recurse2a" "local-pure-const1" } } */ +/* { dg-final { scan-tree-dump-not "found to be const: recurse2b" "local-pure-const1" } } */ +/* { dg-final { scan-ipa-dump-not "found to be pure: recurse1" "pure-const" } } */ +/* { dg-final { scan-ipa-dump-not "found to be pure: recurse2a" "pure-const" } } */ +/* { dg-final { scan-ipa-dump-not "found to be pure: recurse2b" "pure-const" } } */ +/* { dg-final { scan-ipa-dump-not "found to be const: recurse1" "pure-const" } } */ +/* { dg-final { scan-ipa-dump-not "found to be const: recurse2a" "pure-const" } } */ +/* { dg-final { scan-ipa-dump-not "found to be const: recurse2b" "pure-const" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr33919-0.h b/SingleSource/Regression/C/gcc-dg/pr33919-0.h new file mode 100644 index 0000000000..21966c6ce1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33919-0.h @@ -0,0 +1 @@ +char *pre_inc_base_file = __BASE_FILE__; diff --git a/SingleSource/Regression/C/gcc-dg/pr33919-1.h b/SingleSource/Regression/C/gcc-dg/pr33919-1.h new file mode 100644 index 0000000000..c7345aa581 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33919-1.h @@ -0,0 +1,2 @@ +#include "pr33919-2.h" +char *inc_base_file = __BASE_FILE__; diff --git a/SingleSource/Regression/C/gcc-dg/pr33919-2.h b/SingleSource/Regression/C/gcc-dg/pr33919-2.h new file mode 100644 index 0000000000..3c22257626 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33919-2.h @@ -0,0 +1 @@ +char *nested_inc_base_file = __BASE_FILE__; diff --git a/SingleSource/Regression/C/gcc-dg/pr33919.c b/SingleSource/Regression/C/gcc-dg/pr33919.c new file mode 100644 index 0000000000..14ea3746cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33919.c @@ -0,0 +1,26 @@ +/* PR preprocessor/pr33919 */ +/* { dg-do run } */ +/* { dg-options "-I . -include ${srcdir}/gcc.dg/pr33919-0.h" } */ + +#include "pr33919-1.h" + +const char *base_file = __BASE_FILE__; + +extern int strcmp (const char *, const char *); +extern void abort (void); + +int +main () +{ + if (!strcmp (pre_inc_base_file, "")) + abort (); + if (strcmp (pre_inc_base_file, __FILE__)) + abort (); + if (strcmp (base_file, __FILE__)) + abort (); + if (strcmp (inc_base_file, __FILE__)) + abort (); + if (strcmp (nested_inc_base_file, __FILE__)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33923.c b/SingleSource/Regression/C/gcc-dg/pr33923.c new file mode 100644 index 0000000000..e933762b1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33923.c @@ -0,0 +1,77 @@ +/* PR target/33923 */ +/* Testcase by Martin Michlmayr */ + +/* { dg-do compile } */ +/* { dg-options "-O3 --param max-partial-antic-length=0" } */ + +static int pendingCommand; +static int currentModifiers; +typedef struct +{ + int (*updateKeys) (int *keyPressed); +} +ProtocolOperations; +static const ProtocolOperations *protocol; +int +brl_readCommand (void) +{ + unsigned long int keys; + int command; + int keyPressed; + unsigned char routingKeys[200]; + int routingKeyCount; + signed char rightVerticalSensor; + if (pendingCommand != (-1)) + { + return command; + } + if (!protocol->updateKeys (&keyPressed)) + { + if (rightVerticalSensor >= 0) + keys |= 1; + if ((routingKeyCount == 0) && keys) + { + if (currentModifiers) + { + doChord:switch (keys); + } + else + { + doCharacter: + command = 0X2200; + if (keys & 0X01UL) + command |= 0001; + if (keys & 0X02UL) + command |= 0002; + if (keys & 0X04UL) + command |= 0004; + if (keys & 0X08UL) + command |= 0010; + if (keys & 0X10UL) + command |= 0020; + if (keys & 0X20UL) + command |= 0040; + if (currentModifiers & (0X0010 | 0X0200)) + command |= 0100; + if (currentModifiers & 0X0040) + command |= 0200; + if (currentModifiers & 0X0100) + command |= 0X020000; + if (currentModifiers & 0X0400) + command |= 0X080000; + if (currentModifiers & 0X0800) + command |= 0X040000; + } + unsigned char key1 = routingKeys[0]; + if (key1 == 0) + { + } else if (key1 == 1) + if (keys) + { + currentModifiers |= 0X0010; + goto doCharacter; + } + } + } + return command; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr33961.c b/SingleSource/Regression/C/gcc-dg/pr33961.c new file mode 100644 index 0000000000..43403ed30a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr33961.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/33961 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-cselim" } */ + +void decode(char *d, int len); + +void decode(char *d, int len) { + int i = len - 1; + while(i >= 0) { + d[i]; + if(d[i] == 0) + d[i]=' '; + if(d[i] == 1) + d[i]='x'; + i--; + } +} + +int main(int argc, char **argv) +{ + decode("this bug is really weird", 24); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr34003-1.c b/SingleSource/Regression/C/gcc-dg/pr34003-1.c new file mode 100644 index 0000000000..ff97fe6d23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34003-1.c @@ -0,0 +1,8 @@ +/* PR bootstrap/34003 */ +/* { dg-do link } */ +/* { dg-options "-O0" } */ +/* { dg-additional-sources "pr34003-2.c" } */ + +extern void foo (void); +int bar (void) { foo (); return 1; } +extern void foo (void); diff --git a/SingleSource/Regression/C/gcc-dg/pr34003-2.c b/SingleSource/Regression/C/gcc-dg/pr34003-2.c new file mode 100644 index 0000000000..a5330567f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34003-2.c @@ -0,0 +1,20 @@ +/* PR bootstrap/34003 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +extern void abort (void); + +int seen = 0; + +void foo (void) +{ + ++seen; +} + +int main (void) +{ + extern int bar (void); + if (bar () != 1 || seen != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr34027-1.c b/SingleSource/Regression/C/gcc-dg/pr34027-1.c new file mode 100644 index 0000000000..0405e357a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34027-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fdump-tree-optimized" } */ + +unsigned long foobar(unsigned long ns) +{ + while(ns >= 10000L) + ns -= 10000L; + return ns; +} + +/* This test was originally introduced to test that we transform + to ns % 10000. See the discussion of PR 32044 why we do not do + that anymore. */ +/* { dg-final { scan-tree-dump-times " % " 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " / " 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr34027-2.c b/SingleSource/Regression/C/gcc-dg/pr34027-2.c new file mode 100644 index 0000000000..94e4ae57b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34027-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +long foo(long n, long m) +{ + return n - (n / m) * m; +} + +/* { dg-final { scan-tree-dump "n % m" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr34088.c b/SingleSource/Regression/C/gcc-dg/pr34088.c new file mode 100644 index 0000000000..88a635d2d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34088.c @@ -0,0 +1,24 @@ +/* PR middle-end/34088 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wall -Werror" } */ + +int F0 (int); +int F1 (int t) { return F0(t); } +int F2 (int t) { return F0(t); } + +extern int X[]; +static inline int foo(int i) +{ + return X[i]; +} + +int bar(int* p) +{ + int i; + + while ( ({ if (foo(*p) && foo(*p)); p; }) ); + + return i; /* { dg-error "is used uninitialized" } */ +} + +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr34171.c b/SingleSource/Regression/C/gcc-dg/pr34171.c new file mode 100644 index 0000000000..6013a0de69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34171.c @@ -0,0 +1,27 @@ +/* Testcase by Martin Michlmayr */ + +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +extern char coredump; +extern void sigemptyset (char *); +struct sigaction +{ + char sa_mask; +}; +void doSignalsSetup (void) +{ + static const int signals[] = { + 1, 2, 3, 4, 6, 8, 11, 13, 14, 15, 30 , 31 + }; + unsigned int i, sig; + struct sigaction sa; + for (i = 0; i < sizeof (signals) / sizeof (int); i++) + { + sig = signals[i]; + if (coredump && + (sig == 4 || sig == 8 || sig == 11 || sig == 10)) + continue; + sigemptyset (&sa.sa_mask); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr34225.c b/SingleSource/Regression/C/gcc-dg/pr34225.c new file mode 100644 index 0000000000..e3373403a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34225.c @@ -0,0 +1,62 @@ +/* PR target/34225 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing -fstack-protector" } */ +/* { dg-require-effective-target fstack_protector } */ +/* { dg-require-effective-target size20plus } */ + +typedef __SIZE_TYPE__ size_t; +extern int sscanf (const char *, const char *, ...); +struct C +{ + char c[240]; +}; +struct O +{ + char **o; +}; +struct P +{ + int p1; + char p2[256]; + char p3[256]; + char p4[256]; +}; + +extern void *s; +extern int f1 (char *, struct C *); +extern void f2 (void *, const char *); +extern void f3 (char *, const char *); +extern int f4 (int, double *, int); + +int +foo (char *a[], struct O *b, int c, int d, struct P *e, int f, int *h, + char *l) +{ + int i, g = 7, m = 0, n; + struct C j[150]; + double *k[150]; + char o[100]; + + if (f1 (o, &j[g]) < 0) + g++; + + while (!m) + { + f2 (s, "xxx"); + for (i = 0; i < f; i++) + if ((!b->o && __builtin_strncmp (l, "abcde", 5) == 0) + || (b->o && !b->o[c])) + { + *e[d].p4 = *e[d].p3 = *e[d].p2 = 0; + sscanf (l, "%s %s %[^\n]", e[d].p3, e[d].p2, e[d].p4); + } + for (n = 0; n < d; n++) + for (i = 0; i < g; i++) + { + f3 (a[i + 1], "foo"); + if (f4 (h[i], k[i], e[n].p1) < 0) + f3 (a[i + 1], "bar"); + } + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr34233.c b/SingleSource/Regression/C/gcc-dg/pr34233.c new file mode 100644 index 0000000000..1982efaa67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34233.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math" } */ + +double foo(void) +{ + return __builtin_pow (0.0, -1.5); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr34263.c b/SingleSource/Regression/C/gcc-dg/pr34263.c new file mode 100644 index 0000000000..be1b3ba31a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34263.c @@ -0,0 +1,59 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* Same test as 990128-1.c. */ + +extern int printf (const char *,...); +extern void abort (void); + +struct s { struct s *n; } *p; +struct s ss; +#define MAX 10 +struct s sss[MAX]; +int count = 0; + +void sub( struct s *p, struct s **pp ); +int look( struct s *p, struct s **pp ); + +int +main() +{ + struct s *pp; + struct s *next; + int i; + + p = &ss; + next = p; + for ( i = 0; i < MAX; i++ ) { + next->n = &sss[i]; + next = next->n; + } + next->n = 0; + + sub( p, &pp ); + if (count != MAX+2) + abort (); + + return( 0 ); +} + +void sub( struct s *p, struct s **pp ) +{ + for ( ; look( p, pp ); ) { + if ( p ) + p = p->n; + else + break; + } +} + +int look( struct s *p, struct s **pp ) +{ + for ( ; p; p = p->n ) + ; + *pp = p; + count++; + return( 1 ); +} + +/* { dg-final { scan-tree-dump "Cleaned-up latch block of loop with single BB" "optimized" { xfail { *-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr34351.c b/SingleSource/Regression/C/gcc-dg/pr34351.c new file mode 100644 index 0000000000..f407170821 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34351.c @@ -0,0 +1,4 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Wall" } */ + +register int * volatile x asm ("ebx"); /* { dg-warning "optimization may eliminate reads and/or writes to register variables" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr34457-1.c b/SingleSource/Regression/C/gcc-dg/pr34457-1.c new file mode 100644 index 0000000000..3dca13df09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34457-1.c @@ -0,0 +1,25 @@ +/* PR c/34457 */ +/* { dg-do link } */ +/* { dg-require-effective-target trampolines } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -O2" } */ +/* { dg-additional-sources "pr34457-2.c" } */ + + +typedef __SIZE_TYPE__ size_t; +extern int printf (const char *, ...); +extern void *memset (void *, int, size_t); + +int bar (int (*p)(), int q, void *r) {} + +int +main(int argc, char **argv) +{ + struct s { int a; char b[argc]; }; + int nested (struct s x) { return x.a + sizeof(x); } + struct s t; + memset (&t, 0, sizeof(t)); + t.a = 123; + printf("%d\n", bar (nested, argc, &t)); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr34457-2.c b/SingleSource/Regression/C/gcc-dg/pr34457-2.c new file mode 100644 index 0000000000..8e251d3abe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34457-2.c @@ -0,0 +1,3 @@ +/* Additional file for PR c/34457. */ + +int x; diff --git a/SingleSource/Regression/C/gcc-dg/pr34668-1.c b/SingleSource/Regression/C/gcc-dg/pr34668-1.c new file mode 100644 index 0000000000..7e242c294c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34668-1.c @@ -0,0 +1,22 @@ +/* PR c/34668 */ +/* { dg-do link } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -O2" } */ +/* { dg-additional-sources "pr34668-2.c" } */ + +struct optab { unsigned code; }; +struct optab optab_table[1]; + +void +init_optab (struct optab *op) +{ + op->code = 0xdead; +} + +void +set_conv_libfunc (void) +{ + init_optab (&optab_table[0]); +} + +int main() { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr34668-2.c b/SingleSource/Regression/C/gcc-dg/pr34668-2.c new file mode 100644 index 0000000000..fab8f173fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34668-2.c @@ -0,0 +1,5 @@ +/* PR c/34668 */ +/* { dg-do compile } */ + +struct optab { unsigned code; }; +extern struct optab optab_table[1]; diff --git a/SingleSource/Regression/C/gcc-dg/pr34825.c b/SingleSource/Regression/C/gcc-dg/pr34825.c new file mode 100644 index 0000000000..40061bad6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34825.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O -funsafe-math-optimizations" } */ + +double foo(double x, double y) +{ + return x == y ? x/y*x/y : 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr34856.c b/SingleSource/Regression/C/gcc-dg/pr34856.c new file mode 100644 index 0000000000..9ae890270d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34856.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -msse2" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2 -maltivec" { target { powerpc*-*-linux* && powerpc_altivec_ok } } } */ +/* { dg-skip-if "no vector type for PSImode" { msp430-*-* } { "-mlarge" } { "" } } */ + +typedef __UINTPTR_TYPE__ uintptr_t; + +#undef __vector +#define __vector __attribute__ ((__vector_size__ (16))) + +typedef __vector signed char qword; +typedef __vector uintptr_t VU; + +extern short g[192 + 16]; + +void f (qword); + +void f1 (unsigned ctr) +{ + VU pin; + + pin = (VU){(uintptr_t) &g[16]}; + do + { + f ((qword) pin); + ctr--; + } + while (ctr); +} + +/* Ignore a warning that is irrelevant to the purpose of this test. */ +/* { dg-prune-output ".*GCC vector passed by reference.*" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr34965.c b/SingleSource/Regression/C/gcc-dg/pr34965.c new file mode 100644 index 0000000000..381e46fae4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34965.c @@ -0,0 +1,13 @@ +/* PR c++/34965 */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int foo (int); + +void +bar (int i, int j, double k) +{ + foo (i && j) (); /* { dg-error "\\(i != 0 \\&\\& j != 0\\)" } */ + foo (!i || !j) (); /* { dg-error "\\(i == 0 \\|\\| j == 0\\)" } */ + foo (!i == !j) (); /* { dg-error "\\(i != 0 \\^ j == 0\\)" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr34969.c b/SingleSource/Regression/C/gcc-dg/pr34969.c new file mode 100644 index 0000000000..02f7dd1aaa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34969.c @@ -0,0 +1,15 @@ +/* PR middle-end/34969 */ +/* { dg-do compile } */ +/* { dg-options "-O -fipa-cp -ffast-math" } */ + +double +foo (double x) +{ + return x * x; +} + +double +bar (void) +{ + return foo (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr34985.c b/SingleSource/Regression/C/gcc-dg/pr34985.c new file mode 100644 index 0000000000..56437509d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr34985.c @@ -0,0 +1,9 @@ +/* PR34985: Warning "defined but not used" despite __attribute__((__used__)) */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra -O2" } */ +static void xxyyzz (void); +static void __attribute__((__used__)) xxyyzz(void) +{ +} + +/* { dg-final { scan-assembler "xxyyzz" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr35045.c b/SingleSource/Regression/C/gcc-dg/pr35045.c new file mode 100644 index 0000000000..9cf649393e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35045.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-skip-if "" { { i?86-*-* x86_64-*-* } && { ia32 && { ! nonpic } } } } */ +/* { dg-skip-if "Not enough registers" { "pdp11-*-*" } } */ +/* { dg-options "-O2 -fgcse-after-reload" } */ + +extern void abort (void); + +__attribute__((noinline)) __complex__ float +give_neg1 (void) +{ + __complex__ float res; + __real__ res = -1.0; + __imag__ res = 1.0; + return res; +} + +__attribute__((noinline)) __complex__ float +mycacoshf (__complex__ float x) +{ + __complex__ float res; + res = give_neg1 (); + + /* We have to use the positive branch. */ + if (__real__ res < 0.0) + { + unsigned a,b,c,d,e,f; + res = -res; + asm __volatile__ ("" : "=r" (a), "=r" (b), "=r" (c), "=r" (d), "=r" (e), "=r" (f)); + } + return res; +} + +int main() +{ + __complex__ float res = mycacoshf(1.0); + if (__imag__ res >= 0.0) + abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35065.c b/SingleSource/Regression/C/gcc-dg/pr35065.c new file mode 100644 index 0000000000..8b272f8ee8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35065.c @@ -0,0 +1,230 @@ +/* PR debug/35065 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -funroll-loops" } */ +typedef int vlc_bool_t; +typedef __SIZE_TYPE__ size_t; +typedef struct vlc_object_t vlc_object_t; +typedef long long int64_t; +#if(__SIZEOF_INT__ >= 4) +typedef unsigned int uint32_t; +#else +typedef unsigned long uint32_t; +#endif +typedef unsigned char uint8_t; +typedef int64_t mtime_t; +typedef uint32_t vlc_fourcc_t; +typedef struct module_t module_t; +typedef struct es_format_t es_format_t; +typedef struct decoder_t decoder_t; +typedef struct decoder_sys_t decoder_sys_t; +typedef struct block_t block_t; +extern void* malloc (size_t); +enum vlc_module_properties { + VLC_MODULE_CB_OPEN, VLC_MODULE_CB_CLOSE, VLC_MODULE_NAME, }; +struct es_format_t { + vlc_fourcc_t i_codec; + int i_extra; + void *p_extra; +}; +struct block_t { + block_t *p_next; + uint32_t i_flags; + mtime_t i_pts; + mtime_t i_dts; + size_t i_buffer; + uint8_t *p_buffer; +}; +block_t* block_New(void*, size_t); +block_t *nal_get_annexeb(decoder_t *, uint8_t *, int); +block_t *block_ChainGather (block_t *); +static inline block_t *block_Duplicate( block_t *p_block ) { + block_t *p_dup = block_New( ((void *)0), p_block->i_buffer ); + p_dup->i_dts = p_block->i_dts; + p_dup->i_pts = p_block->i_pts; +} +static inline void block_ChainAppend( block_t **pp_list, block_t *p_block ) { + if( *pp_list == ((void *)0) ) { + } + else { + block_t *p = *pp_list; + while( p->p_next ) p = p->p_next; + p->p_next = p_block; + } +} +struct decoder_t { + decoder_sys_t * p_sys; + es_format_t fmt_in; +}; +typedef struct bs_s { + uint8_t *p; + uint8_t *p_end; + int i_left; +} bs_t; +static inline uint32_t bs_read( bs_t *s, int i_count ) { + static uint32_t i_mask[33] = { + 0x00, 0x1fffffff,0x3fffffff,0x7fffffff,0xffffffff}; + int i_shr; + uint32_t i_result = 0; + while( i_count > 0 ) { + if( s->p >= s->p_end ) { + break; + } + if( ( i_shr = s->i_left - i_count ) >= 0 ) { + i_result |= ( *s->p >> i_shr )&i_mask[i_count]; + s->i_left -= i_count; + { + s->i_left = 8; + } + return( i_result ); + } + { + i_result |= (*s->p&i_mask[s->i_left]) << -i_shr; + i_count -= s->i_left; + s->p++; + } + } +} +static inline uint32_t bs_read1( bs_t *s ) { + if( s->p < s->p_end ) { + unsigned int i_result; + s->i_left--; + i_result = ( *s->p >> s->i_left )&0x01; + if( s->i_left == 0 ) { + s->p++; + } + return i_result; + } + return 0; +} +int Open ( vlc_object_t * ); +int vlc_module_set ( module_t *, enum vlc_module_properties, void *); +void Close( vlc_object_t * ); +__attribute__((visibility("default"))) int vlc_entry__0_9_0f ( module_t *p_module ) { + { + module_t *p_submodule = p_module; + if (vlc_module_set (p_submodule, VLC_MODULE_CB_OPEN, (void *)(Open)) || vlc_module_set (p_submodule, VLC_MODULE_CB_CLOSE, (void *)(Close))) goto error; + } + error: + return -666; +} +typedef struct { + int i_nal_type; + int i_nal_ref_idc; + int i_frame_type; + int i_frame_num; + int i_bottom_field_flag; + int i_idr_pic_id; + int i_delta_pic_order_cnt0; +} slice_t; +struct decoder_sys_t { + vlc_bool_t b_slice; + block_t *p_frame; + vlc_bool_t b_sps; + vlc_bool_t b_pps; + vlc_bool_t b_header; + block_t *p_sps; + block_t *p_pps; + int i_pic_order_cnt_type; + slice_t slice; +}; +enum { NAL_SLICE = 1, NAL_SLICE_IDR = 5, NAL_SPS = 7, NAL_AU_DELIMITER= 9 }; +static block_t *ParseNALBlock( decoder_t *, block_t * ); +int U16_AT ( uint8_t * ); +int Open( vlc_object_t *p_this ) { + decoder_t *p_dec = (decoder_t*)p_this; + decoder_sys_t *p_sys; + if( p_dec->fmt_in.i_codec != ( ((uint32_t)'h') | ( ((uint32_t)'2') << 8 ) | ( ((uint32_t)'6') << 16 ) | ( ((uint32_t)'4') << 24 ) ) && ( p_dec->fmt_in.i_codec != ( ((uint32_t)'a') | ( ((uint32_t)'v') << 8 ) | ( ((uint32_t)'c') << 16 ) | ( ((uint32_t)'1') << 24 ) ) || p_dec->fmt_in.i_extra < 7 ) ) { + return -666; + } + if( ( p_dec->p_sys = p_sys = malloc( sizeof(decoder_sys_t) ) ) == ((void *)0) ) { + uint8_t *p = &((uint8_t*)p_dec->fmt_in.p_extra)[4]; + int i_sps, i_pps; + int i; + i_sps = (*p++)&0x1f; + for( i = 0; + i < i_sps; + i++ ) { + int i_length = U16_AT( p ); + block_t *p_sps = nal_get_annexeb( p_dec, p + 2, i_length ); + ParseNALBlock( p_dec, p_sps ); + } + } +} +static inline int bs_read_ue( bs_t *s ) { + int i = 0; + while( bs_read1( s ) == 0 && s->p < s->p_end && i < 32 ) { + i++; + } + return( ( 1 << i) - 1 + bs_read( s, i ) ); +} +static inline int bs_read_se( bs_t *s ) { + int val = bs_read_ue( s ); +} +block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; + block_t *p_pic = ((void *)0); + const int i_nal_type = p_frag->p_buffer[4]&0x1f; + if( ( !p_sys->b_sps || !p_sys->b_pps ) && i_nal_type >= NAL_SLICE && i_nal_type <= NAL_SLICE_IDR ) { + } + else if( i_nal_type >= NAL_SLICE && i_nal_type <= NAL_SLICE_IDR ) { + int i_dec = 0, i_first_mb, i_slice_type; + slice_t slice; + bs_t s; + i_first_mb = bs_read_ue( &s ); + switch( (i_slice_type = bs_read_ue( &s )) ) { + } + if( p_sys->i_pic_order_cnt_type == 0 ) { + slice.i_delta_pic_order_cnt0 = bs_read_se( &s ); + } + if( slice.i_frame_num != p_sys->slice.i_frame_num + || slice.i_nal_ref_idc != p_sys->slice.i_nal_ref_idc ) + if( (slice.i_bottom_field_flag != -1) + && (slice.i_bottom_field_flag != p_sys->slice.i_bottom_field_flag) ) + if( p_sys->i_pic_order_cnt_type == 0 && ( slice.i_nal_type != p_sys->slice.i_nal_type || slice.i_idr_pic_id != p_sys->slice.i_idr_pic_id ) ) + do { + if( !p_sys->b_header && p_sys->slice.i_frame_type != 0x0002) + break; + if( p_sys->slice.i_frame_type == 0x0002 && p_sys->p_sps && p_sys->p_pps ) { + block_t *p_sps = block_Duplicate( p_sys->p_sps ); + block_t *p_pps = block_Duplicate( p_sys->p_pps ); + p_sps->i_pts = p_sys->p_frame->i_pts; + block_ChainAppend( &p_sps, p_pps ); + block_ChainAppend( &p_sps, p_sys->p_frame ); + p_sys->b_header = 1; + p_pic = block_ChainGather( p_sps ); + } + } while(0); + } + else if( i_nal_type == NAL_SPS ) { + bs_t s; + if( p_sys->i_pic_order_cnt_type == 0 ) { + } + else if( p_sys->i_pic_order_cnt_type == 1 ) { + int i_cycle; + i_cycle = bs_read_ue( &s ); + while( i_cycle > 0 ) { + bs_read_se(&s ); + } + } + bs_read_ue( &s ); + if( p_sys->b_slice ) + do { + if( !p_sys->b_header && p_sys->slice.i_frame_type != 0x0002) + break; + if( p_sys->slice.i_frame_type == 0x0002 + && p_sys->p_sps && p_sys->p_pps ) + { + block_t *p_sps = block_Duplicate( p_sys->p_sps ); + block_t *p_pps = block_Duplicate( p_sys->p_pps ); + p_sps->i_dts = p_sys->p_frame->i_dts; + p_sps->i_pts = p_sys->p_frame->i_pts; + block_ChainAppend( &p_sps, p_pps ); + block_ChainAppend( &p_sps, p_sys->p_frame ); + p_pic = block_ChainGather( p_sps ); + } + p_pic->i_flags |= p_sys->slice.i_frame_type; + } while(0); + } + block_ChainAppend( &p_sys->p_frame, p_frag ); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35258.c b/SingleSource/Regression/C/gcc-dg/pr35258.c new file mode 100644 index 0000000000..ef1260d00c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35258.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +extern void *memcpy (void *, const void *, __SIZE_TYPE__); +extern int memcmp (const void *, const void *, __SIZE_TYPE__); +extern void abort(void); + +char str[9] = "1234"; + +void +bar (void) +{ +#if __SIZEOF_INT__ >= 4 + unsigned int temp; +#else + __UINT32_TYPE__ temp; +#endif + char *p = &str[2]; + + memcpy (&temp, &str[1], 4); + memcpy (p, &temp, 4); + str[1] = '.'; +} + +int main() +{ + bar(); + if (memcmp (str, "1.234", 5) != 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35264.c b/SingleSource/Regression/C/gcc-dg/pr35264.c new file mode 100644 index 0000000000..a332efc42e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35264.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ +extern void abort(void); +long long __attribute__((noinline)) get(void) +{ + return -2; +} +long long __attribute__((noinline)) get(void); +int __attribute__((noinline)) check(void) +{ + long long lcn; + + lcn = get(); + if (lcn >= 0 || lcn == -1) + return 0; + + return -1; +} +int main() +{ + if (check() == 0) + abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35334.c b/SingleSource/Regression/C/gcc-dg/pr35334.c new file mode 100644 index 0000000000..d4c642e347 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35334.c @@ -0,0 +1,22 @@ +/* PR c++/35334 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */ + +__complex__ unsigned int i; +int j; +char k; +__complex__ double l; +double m; +float n; + +void +foo () +{ + ((__complex__ int)i)(); /* { dg-error "is not a function" } */ + ((__complex__ int)j)(); /* { dg-error "is not a function" } */ + ((__complex__ int)k)(); /* { dg-error "is not a function" } */ + ((__complex__ long double)l)(); /* { dg-error "is not a function" } */ + ((__complex__ long double)m)(); /* { dg-error "is not a function" } */ + ((__complex__ long double)n)(); /* { dg-error "is not a function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35430.c b/SingleSource/Regression/C/gcc-dg/pr35430.c new file mode 100644 index 0000000000..7365ccfcf9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35430.c @@ -0,0 +1,10 @@ +/* PR c/35430 */ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +void +foo (__complex__ int i) +{ + i == 0u; + i == ~1u; /* { dg-warning "comparison of integer expressions of different signedness" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35440.c b/SingleSource/Regression/C/gcc-dg/pr35440.c new file mode 100644 index 0000000000..796d7e0a9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35440.c @@ -0,0 +1,12 @@ +/* PR c/35440 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +struct A {}; +struct B { int i; char j[2]; }; + +void foo (void) +{ + (struct A){}(); /* { dg-error "called object" } */ + (struct B){ .i = 2, .j[1] = 1 }(); /* { dg-error "called object" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35441.c b/SingleSource/Regression/C/gcc-dg/pr35441.c new file mode 100644 index 0000000000..2d48533f31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35441.c @@ -0,0 +1,26 @@ +/* PR c/35441 */ +/* { dg-do compile } */ +/* { dg-options "-fno-diagnostics-show-caret" } */ +/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */ + +void foo1(char **p, char **q) +{ + (p - q)(); /* { dg-error "is not a function" } */ +} + +void foo2(double x, double y) +{ + (x/y)(); /* { dg-error "is not a function" } */ +} + +void foo3(unsigned i, int j) +{ + (i << j | i >> (32 - j))(); /* { dg-error "is not a function" } */ + (i >> j | i << (32 - j))(); /* { dg-error "is not a function" } */ +} + +void foo4(char *p, char *q) +{ + (p < q ? p : q)(); /* { dg-error "is not a function" } */ + (p > q ? p : q)(); /* { dg-error "is not a function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35442.c b/SingleSource/Regression/C/gcc-dg/pr35442.c new file mode 100644 index 0000000000..6534ba4041 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35442.c @@ -0,0 +1,15 @@ +/* PR c/35442 */ +/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */ +/* { dg-options "-mabi=altivec" { target { { powerpc*-*-linux* } && ilp32 } } } */ + +typedef char A __attribute__ ((vector_size (64))); +typedef int B __attribute__ ((vector_size (64))); + +void +foo (A a) +{ + ((B) a) (); /* { dg-error "is not a function" } */ +} + +/* Ignore a warning that is irrelevant to the purpose of this test. */ +/* { dg-prune-output "(.*GCC vector passed by reference.*|.*ABI for * passing parameters with.*)" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr35443.c b/SingleSource/Regression/C/gcc-dg/pr35443.c new file mode 100644 index 0000000000..5dfc299e79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35443.c @@ -0,0 +1,9 @@ +/* PR c/35443 */ +/* { dg-options "" } */ +/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */ + +void +foo () +{ + ({ int i; i; })(); /* { dg-error "is not a function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35445.c b/SingleSource/Regression/C/gcc-dg/pr35445.c new file mode 100644 index 0000000000..30c29f4c3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35445.c @@ -0,0 +1,6 @@ +/* PR c/35445 */ +/* { dg-do compile } */ + +extern int i; +extern int i; /* { dg-message "previous declaration of 'i'" } */ +int i[] = { 0 }; /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr35468.c b/SingleSource/Regression/C/gcc-dg/pr35468.c new file mode 100644 index 0000000000..085c073070 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35468.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/35468 */ +/* { dg-do compile }*/ +/* { dg-options "-O2 -fno-tree-dce" } */ + +char *const f(void) +{ + char *const line = "/dev/ptyXX"; + line[8] = 1; + return line; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35616.c b/SingleSource/Regression/C/gcc-dg/pr35616.c new file mode 100644 index 0000000000..ad2c9e99e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35616.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +typedef void (*listener_fun)( + int a, + int b, + int c); + +struct data_t +{ + int a; + + listener_fun listener; + + int b; + int c; + int d; +}; + +extern void abort(void); +void function_calling_listener (struct data_t data); + +void function_calling_listener (struct data_t data) +{ + data.listener(data.a, data.c, data.d); +} + +void my_listener(int a, int b, int c) +{ + if (a != 42 || b != 44 || c != 45) + abort (); +} + +int main() +{ + struct data_t d; + d.a = 42; + d.b = 43; + d.c = 44; + d.d = 45; + d.listener = my_listener; + function_calling_listener (d); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35635.c b/SingleSource/Regression/C/gcc-dg/pr35635.c new file mode 100644 index 0000000000..b52354f80a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35635.c @@ -0,0 +1,90 @@ +/* PR 35635 */ +/* { dg-do compile } */ +/* { dg-options "-Wconversion -Wsign-conversion" } */ + +struct unsigned_bit { + unsigned int x:1; +} unsigned_bit; +struct signed_bit { + int x:1; +} signed_bit; +int bar; +int bar2; + +void func1() +{ + /* The result of boolean operators fits in unsiged int:1, thus do + not warn. */ + unsigned_bit.x = (bar != 0); /* { dg-bogus "conversion" } */ + unsigned_bit.x = (bar == 0); /* { dg-bogus "conversion" } */ + unsigned_bit.x = (bar <= 0); /* { dg-bogus "conversion" } */ + unsigned_bit.x = (bar >= 0); /* { dg-bogus "conversion" } */ + unsigned_bit.x = (bar < 0); /* { dg-bogus "conversion" } */ + unsigned_bit.x = (bar > 0); /* { dg-bogus "conversion" } */ + unsigned_bit.x = !bar; /* { dg-bogus "conversion" } */ + unsigned_bit.x = (bar || bar2); /* { dg-bogus "conversion" } */ + unsigned_bit.x = (bar && bar2); /* { dg-bogus "conversion" } */ + + /* Both branches of ? fit in the destination, thus do not warn. */ + unsigned_bit.x = bar != 0 ? 1 : 0; /* { dg-bogus "conversion" } */ + unsigned_bit.x = bar != 0 ? 1.0 : 0.0; /* { dg-bogus "conversion" } */ + + /* At least one branch of ? does not fit in the destination, thus + warn. */ + unsigned_bit.x = bar != 0 ? 2 : 0; /* { dg-warning "conversion" } */ + unsigned_bit.x = bar != 0 ? 0 : -1; /* { dg-warning "-Wsign-conversion" } */ +} + +void func2() +{ + signed char schar_x; + + /* Both branches of ? fit in the destination, thus do not warn. */ + schar_x = bar != 0 ? 1 : 0; /* { dg-bogus "conversion" } */ + schar_x = bar != 0 ? 2.0 : 10; /* { dg-bogus "conversion" } */ + + /* At least one branch of ? does not fit in the destination, thus + warn. */ + schar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */ + schar_x = bar != 0 ? (signed char) 1024: -1024; /* { dg-warning "conversion" } */ +} + + + +void func3() +{ + unsigned char uchar_x; + + /* Both branches of ? fit in the destination, thus do not warn. */ + uchar_x = bar != 0 ? 1 : 0; + uchar_x = bar != 0 ? 2.0 : 10; + + /* At least one branch of ? does not fit in the destination, thus + warn. */ + uchar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */ + uchar_x = bar != 0 /* { dg-warning "-Wsign-conversion" } */ + ? (unsigned char) 1024 + : -1; +} + +void func4() +{ + signed_bit.x = -1; /* { dg-bogus "conversion" } */ + signed_bit.x = bar != 0 ? -1.0 : 0.0; /* { dg-bogus "conversion" } */ + signed_bit.x = bar != 0 ? -1 : 0; /* { dg-bogus "conversion" } */ + + + signed_bit.x = 1; /* { dg-warning "conversion" } */ + signed_bit.x = (bar != 0); /* { dg-warning "conversion" } */ + signed_bit.x = (bar == 0); /* { dg-warning "conversion" } */ + signed_bit.x = (bar <= 0); /* { dg-warning "conversion" } */ + signed_bit.x = (bar >= 0); /* { dg-warning "conversion" } */ + signed_bit.x = (bar < 0); /* { dg-warning "conversion" } */ + signed_bit.x = (bar > 0); /* { dg-warning "conversion" } */ + signed_bit.x = !bar; /* { dg-warning "conversion" } */ + signed_bit.x = (bar || bar2); /* { dg-warning "conversion" } */ + signed_bit.x = (bar && bar2); /* { dg-warning "conversion" } */ + signed_bit.x = bar != 0 ? 1 : 0; /* { dg-warning "conversion" } */ + signed_bit.x = bar != 0 ? 2 : 0; /* { dg-warning "conversion" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr35691-1.c b/SingleSource/Regression/C/gcc-dg/pr35691-1.c new file mode 100644 index 0000000000..34dc02ab56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35691-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1-details" } */ + +int foo(int z0, unsigned z1) +{ + int t0 = (z0 == 0); + int t1 = (z1 == 0); + int t2 = (t0 & t1); + return t2; +} + +/* { dg-final { scan-tree-dump "gimple_simplified to _\[0-9\]* = \\(int\\) z1_\[0-9\]*\\(D\\);" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr35691-2.c b/SingleSource/Regression/C/gcc-dg/pr35691-2.c new file mode 100644 index 0000000000..b89ce481c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35691-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1-details" } */ + +int foo(int z0, unsigned z1) +{ + int t0 = (z0 != 0); + int t1 = (z1 != 0); + int t2 = (t0 | t1); + return t2; +} + +/* { dg-final { scan-tree-dump "gimple_simplified to _\[0-9\]* = \\(int\\) z1_\[0-9\]*\\(D\\);" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr35691-3.c b/SingleSource/Regression/C/gcc-dg/pr35691-3.c new file mode 100644 index 0000000000..75b49a6e2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35691-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1-details" } */ + +int foo(int z0, unsigned z1) +{ + int t0 = (z0 == -1); + int t1 = (z1 == -1U); + int t2 = (t0 & t1); + return t2; +} + +/* { dg-final { scan-tree-dump "gimple_simplified to _\[0-9\]* = \\(int\\) z1_\[0-9\]*\\(D\\);" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr35691-4.c b/SingleSource/Regression/C/gcc-dg/pr35691-4.c new file mode 100644 index 0000000000..2d9456bd16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35691-4.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1-details" } */ + +int foo(int z0, unsigned z1) +{ + int t0 = (z0 != -1); + int t1 = (z1 != -1U); + int t2 = (t0 | t1); + return t2; +} + +/* { dg-final { scan-tree-dump "gimple_simplified to _\[0-9\]* = \\(int\\) z1_\[0-9\]*\\(D\\);" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr35691-5.c b/SingleSource/Regression/C/gcc-dg/pr35691-5.c new file mode 100644 index 0000000000..1cde0283b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35691-5.c @@ -0,0 +1,125 @@ +/* PR middle-end/35691 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-reassoc1-details" } */ + +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[xyz]1_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[xyz]1_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[xyz]1_\[0-9]*\\(D\\) \\+\\\[0, 0\\\]\[\n\r]" 1 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[ghi]1_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[ghi]1_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[ghi]1_\[0-9]*\\(D\\) \\+\\\[0, 0\\\]\[\n\r]" 1 "reassoc1" } } */ + +int +f1 (int x1, unsigned int y1, int z1, _Bool d, _Bool e, _Bool f, long long g1, unsigned long long h1, long long i1) +{ + int a = x1 == 0; + int b = y1 == 0; + int c = z1 == 0; + int j = g1 == 0; + int k = h1 == 0; + int l = i1 == 0; + return a && d && j && b && e && l && f && c && k; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[xyz]2_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[xyz]2_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[xyz]2_\[0-9]*\\(D\\) \\+\\\[0, 0\\\]\[\n\r]" 1 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[ghi]2_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[ghi]2_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[ghi]2_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\]\[\n\r]" 1 "reassoc1" } } */ + +int +f2 (int x2, int y2, unsigned int z2, _Bool d, _Bool e, _Bool f, long long g2, unsigned long long h2, long long i2) +{ + int a = x2 == 0; + int b = y2 == 0; + int c = z2 == 0; + int j = g2 == -1LL; + int k = h2 == -1ULL; + int l = i2 == -1LL; + return !a || d || !l || !b || !k || e || f || !c || !j; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[xyz]3_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[xyz]3_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[xyz]3_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\]\[\n\r]" 1 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[ghi]3_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[ghi]3_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[ghi]3_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\]\[\n\r]" 1 "reassoc1" } } */ + +int +f3 (unsigned int x3, int y3, int z3, _Bool d, _Bool e, _Bool f, signed char g3, unsigned char h3, signed char i3) +{ + int a = x3 == -1U; + int b = y3 == -1; + int c = z3 == -1; + int j = g3 == -1; + int k = h3 == (unsigned char) -1U; + int l = i3 == -1; + return a && d && j && b && k && e && f && c && l; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[xyz]4_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[xyz]4_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[xyz]4_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\]\[\n\r]" 1 "reassoc1" } } */ + +int +f4 (int x4, unsigned int y4, unsigned int z4, _Bool d, _Bool e, _Bool f) +{ + int a = x4 == -1U; + int b = y4 == -1U; + int c = z4 == -1; + return !a || d || !b || e || f || !c; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[xyz]5_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[xyz]5_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[xyz]5_\[0-9]*\\(D\\) \\+\\\[0, 0\\\]\[\n\r]" 1 "reassoc1" } } */ + +int +f5 (int x5, int y5, int z5, _Bool d, _Bool e, _Bool f) +{ + int a = x5 == 0; + int b = y5 != 0; + int c = z5 != 0; + return a && d && !b && e && f && !c; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[xyz]6_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[xyz]6_\[0-9]*\\(D\\) \\+\\\[0, 0\\\] and \[xyz]6_\[0-9]*\\(D\\) \\+\\\[0, 0\\\]\[\n\r]" 1 "reassoc1" } } */ + +int +f6 (unsigned int x6, unsigned int y6, unsigned int z6, _Bool d, _Bool e, _Bool f) +{ + int a = x6 == 0; + int b = y6 != 0; + int c = z6 != 0; + return !a || d || b || e || f || c; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[xy]7_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[xy]7_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\]\[\n\r]" 1 "reassoc1" } } */ + +int +f7 (int x7, int y7, int z7, _Bool d, _Bool e, _Bool f) +{ + int a = x7 == -1; + int b = y7 != -1; + int c = z7 == -1; + return a && d && !b && e && f && !c; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[xy]8_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\] and \[xy]8_\[0-9]*\\(D\\) \\+\\\[\[1-9-]\[0-9]*, \[1-9-]\[0-9]*\\\]\[\n\r]" 1 "reassoc1" } } */ + +int +f8 (unsigned int x8, unsigned int y8, unsigned int z8, _Bool d, _Bool e, _Bool f) +{ + int a = x8 == -1; + int b = y8 != -1; + int c = z8 == -1; + return !a || d || b || e || f || c; +} + +/* { dg-final { scan-tree-dump-not "Optimizing range tests \[xyz]9_\[0-9]*\\(D\\)" "reassoc1" } } */ + +int +f9 (int x9, int y9, int z9, _Bool d, _Bool e, _Bool f) +{ + int a = x9 == -1; + int b = y9 == -1; + int c = z9 == -1; + return a || d || b || e || f || c; +} + +/* { dg-final { scan-tree-dump-not "Optimizing range tests \[xyz]0_\[0-9]*\\(D\\)" "reassoc1" } } */ + +int +f0 (int x0, int y0, int z0, _Bool d, _Bool e, _Bool f) +{ + int a = x0 != 0; + int b = y0 != 0; + int c = z0 != 0; + return a && d && b && e && f && c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35691-6.c b/SingleSource/Regression/C/gcc-dg/pr35691-6.c new file mode 100644 index 0000000000..b45bbb8a2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35691-6.c @@ -0,0 +1,72 @@ +/* PR middle-end/35691 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +__attribute__((noinline, noclone)) int +foo (int *p, unsigned long long *q) +{ + int p0 = p[0], p10 = p[10], p12 = p[12], p32 = p[32], p77 = p[77], p85 = p[85], p86 = p[86], p97 = p[97], p98 = p[98]; + unsigned long long q0 = q[0], q10 = q[10], q12 = q[12], q32 = q[32], q77 = q[77], q85 = q[85], q86 = q[86], q97 = q[97], q98 = q[98]; + return p0 == 0 && q0 == -1 && p10 == 0 && q10 == -1 && p12 == 0 && q12 == -1 + && p32 == 0 && q32 == -1 && p77 == 0 && q77 == -1 && p85 == 0 && q85 == -1 + && p86 == 0 && q86 == -1 && p97 == 0 && q97 == -1 && p98 == 0 && q98 == -1; +} + +__attribute__((noinline, noclone)) int +bar (int *p, unsigned long long *q) +{ + int p0 = p[0], p10 = p[10], p12 = p[12], p32 = p[32], p77 = p[77], p85 = p[85], p86 = p[86], p97 = p[97], p98 = p[98]; + unsigned long long q0 = q[0], q10 = q[10], q12 = q[12], q32 = q[32], q77 = q[77], q85 = q[85], q86 = q[86], q97 = q[97], q98 = q[98]; + return p0 != 0 | q0 != -1 | p10 != 0 | q10 != -1 | p12 != 0 | q12 != -1 + | p32 != 0 | q32 != -1 | p77 != 0 | q77 != -1 | p85 != 0 | q85 != -1 + | p86 != 0 | q86 != -1 | p97 != 0 | q97 != -1 | p98 != 0 | q98 != -1; +} + +int p[100]; +unsigned long long q[100]; + +int +main () +{ + int i; + for (i = 0; i < 100; i++) + { + p[i] = 0; + q[i] = -1; + } + asm volatile ("" : : "g" (p), "g" (q) : "memory"); + if (foo (p, q) != 1 || bar (p, q) != 0) + __builtin_abort (); + for (i = 0; i < 100; i++) + { + int f1, b1, f2, b2; + p[i] = 1; + f1 = foo (p, q); + b1 = bar (p, q); + p[i] = 0; + q[i] = 0; + f2 = foo (p, q); + b2 = bar (p, q); + q[i] = -1; + switch (i) + { + case 0: + case 10: + case 12: + case 32: + case 77: + case 85: + case 86: + case 97: + case 98: + if (f1 != 0 || b1 != 1 || f2 != 0 || b2 != 1) + __builtin_abort (); + break; + default: + if (f1 != 1 || b1 != 0 || f2 != 1 || b2 != 0) + __builtin_abort (); + break; + } + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35701.c b/SingleSource/Regression/C/gcc-dg/pr35701.c new file mode 100644 index 0000000000..4144430977 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35701.c @@ -0,0 +1,31 @@ +/* PR 35701 */ +/* { dg-do compile } */ +/* { dg-options "-Wconversion -Wsign-conversion" } */ +/* { dg-require-effective-target int32plus } */ + +typedef struct _my_struct_t { + unsigned int small:1; + unsigned int big:31; +} my_struct_t, *my_struct_p_t; + +void +my_func1(unsigned int sm, unsigned int bi, my_struct_p_t msp) +{ + msp->small = sm; /* { dg-warning "conversion" } */ + msp->big = bi; /* { dg-warning "conversion" } */ +} + +void +my_func2(unsigned int sm, unsigned int bi, my_struct_p_t msp) +{ + msp->small = sm & 1U; + msp->big = bi & 0x7fffffffU; +} + +unsigned short +my_func3(unsigned int sm) +{ + unsigned short res; + res = sm & 0xff20U; + return res; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35729.c b/SingleSource/Regression/C/gcc-dg/pr35729.c new file mode 100644 index 0000000000..fadb8a3168 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35729.c @@ -0,0 +1,17 @@ +/* Target is restricted to x86 type architectures, so that we may + assume something about memory addressing modes. */ + +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && nonpic } } } */ +/* { dg-options "-Os -fdump-rtl-loop2_invariant" } */ + +const volatile int g_361 = 3L; +volatile int g_2 = 0L; +void func_1 (void) +{ + for (g_2 = 0; g_2 > 10; g_2++) + { + int l_357 = g_361; + } +} + +/* { dg-final { scan-rtl-dump-times "Decided to move invariant" 0 "loop2_invariant" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr35736.c b/SingleSource/Regression/C/gcc-dg/pr35736.c new file mode 100644 index 0000000000..f411bb8a92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35736.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wall" } */ + +void foo() +{ + while (1) + for (;;({ continue; })) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35742.c b/SingleSource/Regression/C/gcc-dg/pr35742.c new file mode 100644 index 0000000000..6094727920 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35742.c @@ -0,0 +1,13 @@ +/* PR c/35742 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */ + +void +foo () +{ + for (;;) + ({break;})(); /* { dg-error "is not a function" } */ + for (;;) + ({continue;})(); /* { dg-error "is not a function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35746.c b/SingleSource/Regression/C/gcc-dg/pr35746.c new file mode 100644 index 0000000000..274f4a9682 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35746.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +int foo(int i); + +void bar() +{ + __complex__ int i; + X j; /* { dg-error "unknown" } */ + if (i = foo(j)) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr35899.c b/SingleSource/Regression/C/gcc-dg/pr35899.c new file mode 100644 index 0000000000..5361582d5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr35899.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/35899 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -O2" } */ + +int +foo (void) +{ + int a = bar (); /* { dg-line bar_implicit_decl } */ + return a; +} + +void +bar (void) +/* { dg-warning "conflicting types for" "" { target *-*-* } .-1 } */ +/* { dg-message "note: previous implicit declaration" "" { target *-*-* } bar_implicit_decl } */ +{ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr36015.c b/SingleSource/Regression/C/gcc-dg/pr36015.c new file mode 100644 index 0000000000..fc31535598 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36015.c @@ -0,0 +1,22 @@ +/* PR target/36015 */ +/* { dg-do run } */ +/* { dg-options "-O0" } */ +/* { dg-options "-O0 -mregparm=3" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +static int test (); + +int +main (void) +{ + test (0, 1, 2, 3, 4, 5, 6, 7); + return 0; +} + +static int +test (int a, int b, int c, int d, int e, int f, int g, int h) +{ + if (a != 0 || b != 1 || c != 2 || d != 3 + || e != 4 || f != 5 || g != 6 || h != 7) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36017.c b/SingleSource/Regression/C/gcc-dg/pr36017.c new file mode 100644 index 0000000000..d18c97ddfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36017.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/36017 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#if defined (__AVR__) && (__SIZEOF_DOUBLE__ == __SIZEOF_FLOAT__) +extern double sqrt (double) __asm ("sqrtf"); +#else +extern double sqrt (double); +#endif +extern void abort (void); + +__attribute__((noinline)) double +foo (double a) +{ + double b, c, d = 0.7; + if (a <= d) + b = sqrt (d * a); + else + { + c = (1.0 - d) * (1.0 - a); + b = c > 0 ? 1.0 - sqrt (c) : 1.0; + } + return b; +} + +int +main (void) +{ + double c = foo (0.5); + if (c > 0.5917) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36093.c b/SingleSource/Regression/C/gcc-dg/pr36093.c new file mode 100644 index 0000000000..84746416f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36093.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-skip-if "small alignment" { pdp11-*-* } } */ + +extern void abort (void); + +typedef struct Bar { + char c[129]; +} Bar __attribute__((__aligned__(128))); + +typedef struct Foo { + Bar bar[4]; /* { dg-error "size of array element is not a multiple of its alignment" } */ +} Foo; + +Foo foo[4]; + +int main() +{ + int i, j; + Foo *foop = &foo[0]; + + for (i=0; i < 4; i++) { + Bar *bar = &foop->bar[i]; + for (j=0; j < 129; j++) { + bar->c[j] = 'a' + i; + } + } + + if (foo[0].bar[3].c[128] != 'd') + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36111.c b/SingleSource/Regression/C/gcc-dg/pr36111.c new file mode 100644 index 0000000000..498c39e1be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36111.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fpic" } */ + +typedef struct { + int lock; + int pad0_; +} mutex_t; + +static mutex_t main_arena; + +void __malloc_check_init() +{ + for(;;) + __asm__ __volatile__ ("": "+m"(main_arena.lock) ); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr36194.c b/SingleSource/Regression/C/gcc-dg/pr36194.c new file mode 100644 index 0000000000..ae660e4d57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36194.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +void abort (void); + +__attribute__ ((noinline)) void +f (int i) +{ +#if(__SIZEOF_INT__ >= 4) + if (i != 0x87654321) +#else + if (i != 0x4321) +#endif + abort (); + asm (""); +} + +__attribute__ ((noinline)) void +g (long long a) +{ + f (a); + asm (""); +} + +int +main () +{ + g (0x1234567887654321ll); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36224.c b/SingleSource/Regression/C/gcc-dg/pr36224.c new file mode 100644 index 0000000000..6e23559d6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36224.c @@ -0,0 +1,249 @@ +/* { dg-do run } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +#ifndef ALIGN16 +#define ALIGN16 __attribute__((__aligned__(32))) +#endif + +#define I16_B0 1 +#define I16_B1 23 +#define I16_B2 345 +#define I16_B3 6789 +#define I16_B4 1011 +#define I16_B5 -12 +#define I16_B6 1314 +#define I16_B7 -1516 +#define I16_B8 -1516 +#define I16_B9 1314 +#define I16_B10 -12 +#define I16_B11 1011 +#define I16_B12 6789 +#define I16_B13 345 +#define I16_B14 23 +#define I16_B15 1 + +#define I16_C0 2 +#define I16_C1 31567 +#define I16_C2 1112 +#define I16_C3 13 +#define I16_C4 14 +#define I16_C5 15 +#define I16_C6 -16 +#define I16_C7 17 +#define I16_C8 2 +#define I16_C9 31567 +#define I16_C10 1112 +#define I16_C11 13 +#define I16_C12 14 +#define I16_C13 15 +#define I16_C14 -16 +#define I16_C15 17 + +union ui2 { + int si[16]; + unsigned int ui[16]; +}; + +union us { + short ss[16]; + unsigned short us[16]; +}; + +static union ui2 i32_sa ALIGN16; +static union ui2 i32_ua ALIGN16; + +static union us i16_b ALIGN16 = { + (short)I16_B0, + (short)I16_B1, + (short)I16_B2, + (short)I16_B3, + (short)I16_B4, + (short)I16_B5, + (short)I16_B6, + (short)I16_B7, + (short)I16_B8, + (short)I16_B9, + (short)I16_B10, + (short)I16_B11, + (short)I16_B12, + (short)I16_B13, + (short)I16_B14, + (short)I16_B15, +}; + +static union us i16_c ALIGN16 = { + (short)I16_C0, + (short)I16_C1, + (short)I16_C2, + (short)I16_C3, + (short)I16_C4, + (short)I16_C5, + (short)I16_C6, + (short)I16_C7, + (short)I16_C8, + (short)I16_C9, + (short)I16_C10, + (short)I16_C11, + (short)I16_C12, + (short)I16_C13, + (short)I16_C14, + (short)I16_C15, +}; + +static long i32_sr[16] ALIGN16 = { + ((int)I16_B0) * ((int)I16_C0), + ((int)I16_B1) * ((int)I16_C1), + ((int)I16_B2) * ((int)I16_C2), + ((int)I16_B3) * ((int)I16_C3), + ((int)I16_B4) * ((int)I16_C4), + ((int)I16_B5) * ((int)I16_C5), + ((int)I16_B6) * ((int)I16_C6), + ((int)I16_B7) * ((int)I16_C7), + ((int)I16_B8) * ((int)I16_C8), + ((int)I16_B9) * ((int)I16_C9), + ((int)I16_B10) * ((int)I16_C10), + ((int)I16_B11) * ((int)I16_C11), + ((int)I16_B12) * ((int)I16_C12), + ((int)I16_B13) * ((int)I16_C13), + ((int)I16_B14) * ((int)I16_C14), + ((int)I16_B15) * ((int)I16_C15), +}; + +static unsigned long i32_ur[16] ALIGN16 = { + ((unsigned int)(unsigned short)I16_B0) * ((unsigned int)(unsigned short)I16_C0), + ((unsigned int)(unsigned short)I16_B1) * ((unsigned int)(unsigned short)I16_C1), + ((unsigned int)(unsigned short)I16_B2) * ((unsigned int)(unsigned short)I16_C2), + ((unsigned int)(unsigned short)I16_B3) * ((unsigned int)(unsigned short)I16_C3), + ((unsigned int)(unsigned short)I16_B4) * ((unsigned int)(unsigned short)I16_C4), + ((unsigned int)(unsigned short)I16_B5) * ((unsigned int)(unsigned short)I16_C5), + ((unsigned int)(unsigned short)I16_B6) * ((unsigned int)(unsigned short)I16_C6), + ((unsigned int)(unsigned short)I16_B7) * ((unsigned int)(unsigned short)I16_C7), + ((unsigned int)(unsigned short)I16_B8) * ((unsigned int)(unsigned short)I16_C8), + ((unsigned int)(unsigned short)I16_B9) * ((unsigned int)(unsigned short)I16_C9), + ((unsigned int)(unsigned short)I16_B10) * ((unsigned int)(unsigned short)I16_C10), + ((unsigned int)(unsigned short)I16_B11) * ((unsigned int)(unsigned short)I16_C11), + ((unsigned int)(unsigned short)I16_B12) * ((unsigned int)(unsigned short)I16_C12), + ((unsigned int)(unsigned short)I16_B13) * ((unsigned int)(unsigned short)I16_C13), + ((unsigned int)(unsigned short)I16_B14) * ((unsigned int)(unsigned short)I16_C14), + ((unsigned int)(unsigned short)I16_B15) * ((unsigned int)(unsigned short)I16_C15), +}; + +#ifndef ALIGN32 +#define ALIGN32 __attribute__((__aligned__(32))) +#endif + +#define I32_B0 1 +#define I32_B1 23 +#define I32_B2 345 +#define I32_B3 6789 +#define I32_B4 101112 +#define I32_B5 -13 +#define I32_B6 141516 +#define I32_B7 -1718 + +#define I32_C0 2 +#define I32_C1 45678910 +#define I32_C2 1112 +#define I32_C3 13 +#define I32_C4 14 +#define I32_C5 15 +#define I32_C6 -16 +#define I32_C7 17 + +union ul { + long sl[8]; + unsigned long ul[8]; +}; + +union ui { + int si[8]; + unsigned int ui[8]; +}; + +static union ul i64_sa ALIGN32; +static union ul i64_ua ALIGN32; + +static union ui i32_b ALIGN32 = { + (int)I32_B0, + (int)I32_B1, + (int)I32_B2, + (int)I32_B3, + (int)I32_B4, + (int)I32_B5, + (int)I32_B6, + (int)I32_B7, +}; + +static union ui i32_c ALIGN32 = { + (int)I32_C0, + (int)I32_C1, + (int)I32_C2, + (int)I32_C3, + (int)I32_C4, + (int)I32_C5, + (int)I32_C6, + (int)I32_C7, +}; + +static long i64_sr[8] ALIGN32 = { + ((long)I32_B0) * ((long)I32_C0), + ((long)I32_B1) * ((long)I32_C1), + ((long)I32_B2) * ((long)I32_C2), + ((long)I32_B3) * ((long)I32_C3), + ((long)I32_B4) * ((long)I32_C4), + ((long)I32_B5) * ((long)I32_C5), + ((long)I32_B6) * ((long)I32_C6), + ((long)I32_B7) * ((long)I32_C7), +}; + +static unsigned long i64_ur[8] ALIGN32 = { + ((unsigned long)(unsigned)I32_B0) * ((unsigned long)(unsigned)I32_C0), + ((unsigned long)(unsigned)I32_B1) * ((unsigned long)(unsigned)I32_C1), + ((unsigned long)(unsigned)I32_B2) * ((unsigned long)(unsigned)I32_C2), + ((unsigned long)(unsigned)I32_B3) * ((unsigned long)(unsigned)I32_C3), + ((unsigned long)(unsigned)I32_B4) * ((unsigned long)(unsigned)I32_C4), + ((unsigned long)(unsigned)I32_B5) * ((unsigned long)(unsigned)I32_C5), + ((unsigned long)(unsigned)I32_B6) * ((unsigned long)(unsigned)I32_C6), + ((unsigned long)(unsigned)I32_B7) * ((unsigned long)(unsigned)I32_C7), +}; + + +int main () +{ + int i; + + /* Signed 16x16 -> 32-bit tests */ + for (i = 0; i < 16; i++) + i32_sa.si[i] = ((long)i16_b.ss[i]) * ((long)i16_c.ss[i]); + + for (i = 0; i < 16; i++) + if (i32_sa.si[i] != i32_sr[i]) + __builtin_abort (); + + /* Unsigned 16x16 -> 32-bit tests */ + for (i = 0; i < 16; i++) + i32_ua.ui[i] = ((long)i16_b.us[i]) * ((long)i16_c.us[i]); + + for (i = 0; i < 16; i++) + if (i32_ua.ui[i] != i32_ur[i]) + __builtin_abort (); + + /* Signed 32x32 -> 64-bit tests */ + for (i = 0; i < 8; i++) + i64_sa.sl[i] = ((long)i32_b.si[i]) * ((long)i32_c.si[i]); + + for (i = 0; i < 8; i++) + if (i64_sa.sl[i] != i64_sr[i]) + __builtin_abort (); + + /* Unsigned 32x32 -> 64-bit tests */ + for (i = 0; i < 8; i++) + i64_ua.ul[i] = ((long)i32_b.ui[i]) * ((long)i32_c.ui[i]); + + for (i = 0; i < 8; i++) + if (i64_ua.ul[i] != i64_ur[i]) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36227.c b/SingleSource/Regression/C/gcc-dg/pr36227.c new file mode 100644 index 0000000000..ba0d722493 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36227.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-overflow=3" } */ +typedef __UINTPTR_TYPE__ ptrcast; + +volatile unsigned long * +sat_add(volatile unsigned long *ptr, unsigned long i, volatile unsigned long *end) +{ + if ((ptrcast)ptr + i * sizeof(*ptr) > (ptrcast)ptr) /* { dg-bogus "pointer wraparound" } */ + return ptr + i; + else + return end; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr36300-1.c b/SingleSource/Regression/C/gcc-dg/pr36300-1.c new file mode 100644 index 0000000000..e737ab7ff0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36300-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +extern void abort (void); + +#define VALUE ((int)((long long)U1 * (long long)3) + 2) + +int main(void) +{ + long long Y, Y2; +#if(__SIZEOF_INT__ >= 4) + int U1; +#else + long U1; +#endif + int t; + U1 = -2147483647-1; + + Y = ((long long)(VALUE * VALUE) * 3); + + t = VALUE; + Y2 = ((long long)(t * t) * 3); + + if (Y != Y2) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36300-2.c b/SingleSource/Regression/C/gcc-dg/pr36300-2.c new file mode 100644 index 0000000000..9543332683 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36300-2.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +#define VALUE (unsigned int)((int)((long long)U1 * (long long)3) + 2) + +int main(void) +{ + long long Y, Y2; +#if(__SIZEOF_INT__ >= 4) + int U1; +#else + long U1; +#endif + unsigned int t; + + U1 = -2147483647-1; + + Y = ((long long)(int)(VALUE * VALUE) * 3); + + t = VALUE; + Y2 = ((long long)(int)(t * t) * 3); + + if (Y != Y2) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36489.c b/SingleSource/Regression/C/gcc-dg/pr36489.c new file mode 100644 index 0000000000..5cf221615e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36489.c @@ -0,0 +1,22 @@ +/* PR c/36489 */ +/* { dg-do compile } */ +/* { dg-options "-Woverride-init" } */ + +struct A { int a; int b[3]; }; +union B { int a; int b[3]; }; +int t1[10][10] + = { [1][2] = 11, [1][3] = 12 }; +int t2[10][10] + = { [1][2] = 11, [1] = { [3] = 12 } }; /* { dg-warning "initializ" } */ +int t3[10][10] + = { [1][2] = 11, [1][2] = 12 }; /* { dg-warning "initializ" } */ +struct A t4[2] + = { [0].b[0] = 1, [0].b[1] = 2, [0].b[2] = 3 }; +struct A t5[2] + = { [0].b[0] = 1, [0].b[1] = 2, [0].b = { 3 } }; /* { dg-warning "initializ" } */ +union B t6 + = { .b[0] = 1, .b[1] = 2, .b[2] = 3 }; +union B t7 + = { .b[0] = 1, .b[1] = 2, .b = { 2 } }; /* { dg-warning "initializ" } */ +union B t8 + = { .b[0] = 1, .b[1] = 2, .b[1] = 3 }; /* { dg-warning "initializ" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr36504.c b/SingleSource/Regression/C/gcc-dg/pr36504.c new file mode 100644 index 0000000000..b3db30f4f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36504.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/36504 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fprefetch-loop-arrays -w" } */ +/* { dg-additional-options "-march=i686 -msse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +struct A { struct { int a; } b[8]; }; +struct B { int c; int d; }; +struct C { struct B d; }; + +void bar (struct C *, int); + +struct B +foo (struct C *p, struct A *e, int b) +{ + struct B q; + bar (p, e->b[b].a); + return q; +} + +void +baz (int b, struct A *e) +{ + struct C p; + for (; b; ++b) + p.d = foo (&p, e, b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36508.c b/SingleSource/Regression/C/gcc-dg/pr36508.c new file mode 100644 index 0000000000..3048992364 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36508.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/36508 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-pre" } */ + +void +foo (short *sp) +{ + int k; + k = 1; +#define SP0 *sp++ = 1; + while (1) + { + if (k > 6) + break; + SP0 + k++; + } + k = 1; + while (1) + { + if (k > 6) + break; + SP0 + k++; + } +#define SP1 SP0 SP0 SP0 SP0 SP0 SP0 SP0 SP0 SP0 SP0 SP0 +#define SP2 SP1 SP1 SP1 SP1 SP1 SP1 SP1 SP1 SP1 SP1 SP1 + SP2 +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36584.c b/SingleSource/Regression/C/gcc-dg/pr36584.c new file mode 100644 index 0000000000..1b6e38ca43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36584.c @@ -0,0 +1,267 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -lm" } */ +/* { dg-options "-O2 -msse2 -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-require-effective-target sse2_runtime { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern double fabs (double); +extern void abort (void); + +const int MAX_ITERATIONS = 50; +const double SMALL_ENOUGH = 1.0e-10; +const double RELERROR = 1.0e-12; + +typedef struct p +{ + int ord; + double coef[7]; +} +polynomial; + +static double +polyeval (double x, int n, double *Coeffs) +{ + register int i; + double val; + + val = Coeffs[n]; + for (i = n - 1; i >= 0; i--) + val = val * x + Coeffs[i]; + + return (val); +} + +static int +regula_falsa (int order, double *coef, double a, double b, double *val) +{ + int its; + double fa, fb, x, fx, lfx; + + fa = polyeval (a, order, coef); + fb = polyeval (b, order, coef); + + if (fa * fb > 0.0) + return 0; + + if (fabs (fa) < SMALL_ENOUGH) + { + *val = a; + return 1; + } + + if (fabs (fb) < SMALL_ENOUGH) + { + *val = b; + return 1; + } + + lfx = fa; + + for (its = 0; its < MAX_ITERATIONS; its++) + { + x = (fb * a - fa * b) / (fb - fa); + fx = polyeval (x, order, coef); + if (fabs (x) > RELERROR) + { + if (fabs (fx / x) < RELERROR) + { + *val = x; + return 1; + } + } + else + { + if (fabs (fx) < RELERROR) + { + *val = x; + return 1; + } + } + + if (fa < 0) + { + if (fx < 0) + { + a = x; + fa = fx; + if ((lfx * fx) > 0) + fb /= 2; + } + else + { + b = x; + fb = fx; + if ((lfx * fx) > 0) + fa /= 2; + } + } + else + { + if (fx < 0) + { + b = x; + fb = fx; + if ((lfx * fx) > 0) + fa /= 2; + } + else + { + a = x; + fa = fx; + if ((lfx * fx) > 0) + fb /= 2; + } + } + + if (fabs (b - a) < RELERROR) + { + *val = x; + return 1; + } + + lfx = fx; + } + + return 0; +} + +static int +numchanges (int np, polynomial * sseq, double a) +{ + int changes; + double f, lf; + polynomial *s; + changes = 0; + + lf = polyeval (a, sseq[0].ord, sseq[0].coef); + + for (s = sseq + 1; s <= sseq + np; s++) + { + f = polyeval (a, s->ord, s->coef); + if (lf == 0.0 || lf * f < 0) + changes++; + + lf = f; + } + + return changes; +} + +int +sbisect (int np, polynomial * sseq, double min_value, double max_value, + int atmin, int atmax, double *roots) +{ + double mid; + int n1, n2, its, atmid; + + if ((atmin - atmax) == 1) + { + if (regula_falsa (sseq->ord, sseq->coef, min_value, max_value, roots)) + return 1; + else + { + for (its = 0; its < MAX_ITERATIONS; its++) + { + mid = (min_value + max_value) / 2; + atmid = numchanges (np, sseq, mid); + if ((atmid < atmax) || (atmid > atmin)) + return 0; + + if (fabs (mid) > RELERROR) + { + if (fabs ((max_value - min_value) / mid) < RELERROR) + { + roots[0] = mid; + return 1; + } + } + else + { + if (fabs (max_value - min_value) < RELERROR) + { + roots[0] = mid; + return 1; + } + } + + if ((atmin - atmid) == 0) + min_value = mid; + else + max_value = mid; + } + + roots[0] = mid; + return 1; + } + } + + for (its = 0; its < MAX_ITERATIONS; its++) + { + mid = (min_value + max_value) / 2; + atmid = numchanges (np, sseq, mid); + if ((atmid < atmax) || (atmid > atmin)) + return 0; + + if (fabs (mid) > RELERROR) + { + if (fabs ((max_value - min_value) / mid) < RELERROR) + { + roots[0] = mid; + return 1; + } + } + else + { + if (fabs (max_value - min_value) < RELERROR) + { + roots[0] = mid; + return 1; + } + } + + n1 = atmin - atmid; + n2 = atmid - atmax; + + if ((n1 != 0) && (n2 != 0)) + { + n1 = sbisect (np, sseq, min_value, mid, atmin, atmid, roots); + n2 = sbisect (np, sseq, mid, max_value, atmid, atmax, &roots[n1]); + + return (n1 + n2); + } + + if (n1 == 0) + min_value = mid; + else + max_value = mid; + } + + roots[0] = mid; + return 1; +} + +int +main () +{ + polynomial sseq[7] = { + {6, {0.15735259075109281, -5.1185263411378736, 1.8516070705868664, + 7.348009172322695, -2.2152395279161343, -2.7543325329350692, 1.0}}, + {5, {-0.8530877235229789, 0.61720235686228875, 3.6740045861613475, + -1.4768263519440896, -2.2952771107792245, 1.0}}, + {4, {0.13072124257049417, 2.2220687798791126, -1.6299431586726509, + -1.6718404582408546, 1.0}}, + {3, {0.86776597575462633, -2.1051099695282511, -0.49008580100694688, + 1.0}}, + {2, {-11.117984175064155, 10.89886635045883, 1.0}}, + {1, {0.94453099602191237, -1.0}}, + {0, {-0.068471716890574186}} + }; + + double roots[7]; + int nroots; + + nroots = sbisect (6, sseq, 0.0, 10000000.0, 5, 1, roots); + if (nroots != 4) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36774-1.c b/SingleSource/Regression/C/gcc-dg/pr36774-1.c new file mode 100644 index 0000000000..10a5e5fb09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36774-1.c @@ -0,0 +1,9 @@ +/* Nested functions shouldn't produce warnings if defined before first use. + Bug 36774. Test with -Wmissing-prototypes. */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-prototypes" } */ + +int foo(int a) { /* { dg-warning "no previous prototype" } */ + int bar(int b) { return b; } /* { dg-bogus "no previous prototype" } */ + return bar(a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36774-2.c b/SingleSource/Regression/C/gcc-dg/pr36774-2.c new file mode 100644 index 0000000000..bf394c9cac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36774-2.c @@ -0,0 +1,9 @@ +/* Nested functions shouldn't produce warnings if defined before first use. + Bug 36774. Test with -Wmissing-declarations. */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-declarations" } */ + +int foo(int a) { /* { dg-warning "no previous declaration" } */ + int bar(int b) { return b; } /* { dg-bogus "no previous declaration" } */ + return bar(a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36901-1.c b/SingleSource/Regression/C/gcc-dg/pr36901-1.c new file mode 100644 index 0000000000..63438307ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36901-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ +#include "pr36901-system.h" +void foo(void) +{ + int s = sc; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36901-2.c b/SingleSource/Regression/C/gcc-dg/pr36901-2.c new file mode 100644 index 0000000000..cee367d778 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36901-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -w" } */ +#include "pr36901.h" +void foo(void) +{ + int s = sc; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36901-3.c b/SingleSource/Regression/C/gcc-dg/pr36901-3.c new file mode 100644 index 0000000000..1f35742147 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36901-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ +#include "pr36901.h" +void foo(void) +{ + int s = sc; +} +/* { dg-message "file included" "In file included" { target *-*-* } 0 } */ +/* { dg-error "ordered comparison of pointer with integer zero" "pedantic error" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr36901-4.c b/SingleSource/Regression/C/gcc-dg/pr36901-4.c new file mode 100644 index 0000000000..f1d261657a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36901-4.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -Wsystem-headers" } */ +#include "pr36901-system.h" +void foo(void) +{ + int s = sc; +} +/* { dg-message "from " "In file included" { target *-*-* } 0 } */ +/* { dg-error "ordered comparison of pointer with integer zero" "pedantic error" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr36901-system.h b/SingleSource/Regression/C/gcc-dg/pr36901-system.h new file mode 100644 index 0000000000..6cc1e803d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36901-system.h @@ -0,0 +1,3 @@ +#pragma GCC system_header +#include "pr36901.h" + diff --git a/SingleSource/Regression/C/gcc-dg/pr36901.h b/SingleSource/Regression/C/gcc-dg/pr36901.h new file mode 100644 index 0000000000..cf61c99393 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36901.h @@ -0,0 +1,2 @@ +int sc = (&sc >= 0); + diff --git a/SingleSource/Regression/C/gcc-dg/pr36902.c b/SingleSource/Regression/C/gcc-dg/pr36902.c new file mode 100644 index 0000000000..365a26e26b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36902.c @@ -0,0 +1,58 @@ +/* PR middle-end/36902 Array bound warning with dead code after optimization */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds -Wall -Wextra" } */ +typedef unsigned char __u8; +typedef unsigned short __u16; + +static inline unsigned char * +foo(unsigned char * to, const unsigned char * from, int n) +{ + switch ( n ) + { + case 3: + *to = *from; + break; + case 5: + to[4] = from [4]; + break; + } + return to; +} + +struct { + int size_of_select; + unsigned char pcr_select[4]; +} sel; + +unsigned char buf[64]; +int bar(void) +{ + sel.size_of_select = 3; + foo(buf, sel.pcr_select, sel.size_of_select); + + return 1; +} + + +static inline unsigned char * +foo2(unsigned char * to, const unsigned char * from, int n) +{ + switch ( n ) + { + case 3: + *to = *from; + break; + case 5: + to[4] = from [4]; /* { dg-warning "\\\[-Warray-bounds" } */ + break; + } + return to; +} + +int baz(void) +{ + sel.size_of_select = 5; + foo2(buf, sel.pcr_select, sel.size_of_select); + + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36991.c b/SingleSource/Regression/C/gcc-dg/pr36991.c new file mode 100644 index 0000000000..d090ba105c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36991.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/36991 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef float V __attribute__ ((vector_size (16))); +typedef union { V v[4][4]; } U; + +void +foo (float x, float y, U *z) +{ + z->v[1][0] = z->v[0][1] = (V) { x, y, 0, 0 }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36997.c b/SingleSource/Regression/C/gcc-dg/pr36997.c new file mode 100644 index 0000000000..deb4e81693 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36997.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target x86_64-*-* i?86-*-* } } */ +/* { dg-options "-std=c99 -msse2" } */ + +typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__)); +__m64 _mm_add_si64 (__m64 __m1, __m64 __m2) +{ + return (__m64) __builtin_ia32_paddq ((long long)__m1, (long long)__m2); /* { dg-error "incompatible type" } */ + /* { dg-message "note: expected '__vector.1. long long int' but argument is of type 'long long int'" "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr36998.c b/SingleSource/Regression/C/gcc-dg/pr36998.c new file mode 100644 index 0000000000..bf08ed1233 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr36998.c @@ -0,0 +1,24 @@ +/* PR rtl-optimization/36998 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fasynchronous-unwind-tables" } */ +/* { dg-options "-Os -mpreferred-stack-boundary=2 -fasynchronous-unwind-tables" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-fno-omit-frame-pointer" { target { avr-*-* } } } */ + +void foo (const char *, ...) __attribute__ ((noreturn)); +int bar (const char *, ...); +extern __SIZE_TYPE__ strlen (const char *); +int baz (char *, char *, int, void *); + +void +test (char *w, int x, char *y, char *z) +{ + char *p, b[32]; + for (p = y; *p; p += strlen (p) + 1) + { + baz (w, p, x, z); + foo ("msg1 %s", b); + } + for (p = y; *p; p += strlen (p) + 1) + bar (" %s", p); + foo ("msg2 %s", b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37106-1.c b/SingleSource/Regression/C/gcc-dg/pr37106-1.c new file mode 100644 index 0000000000..ff73b0b8df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37106-1.c @@ -0,0 +1,27 @@ +/* PR c/37106 */ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ +/* { dg-options "-O1 -fpic" { target fpic } } */ + +#define SIZE 256 +float a[SIZE], b[SIZE], c[SIZE]; + +void opt3 (void) __attribute__((__optimize__(3))); + +void +opt3 (void) +{ + int i; + + for (i = 0; i < SIZE; i++) + a[i] = b[i] + c[i]; +} + +void +not_opt3 (void) +{ + int i; + + for (i = 0; i < SIZE; i++) + a[i] = b[i] - c[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37106-2.c b/SingleSource/Regression/C/gcc-dg/pr37106-2.c new file mode 100644 index 0000000000..81f061afab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37106-2.c @@ -0,0 +1,27 @@ +/* PR c/37106 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-options "-O3 -fpic" { target fpic } } */ + +#define SIZE 256 +float a[SIZE], b[SIZE], c[SIZE]; + +void non_opt3 (void) __attribute__((__optimize__(1))); + +void +not_opt3 (void) +{ + int i; + + for (i = 0; i < SIZE; i++) + a[i] = b[i] - c[i]; +} + +void +opt3 (void) +{ + int i; + + for (i = 0; i < SIZE; i++) + a[i] = b[i] + c[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37156.c b/SingleSource/Regression/C/gcc-dg/pr37156.c new file mode 100644 index 0000000000..e86f5950f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37156.c @@ -0,0 +1,21 @@ +/* PR debug/37156 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +__attribute__ ((warning ("is experimental"))) int bar (int, int *, int *, int); + +long long foo (void) +{ + int n, m; + long long r; + bar (0, &n, &m, 0); /* { dg-warning "is experimental" } */ + r = (long long) n; + return r; +} + +void +baz (int n) +{ + int o; + o = foo () - n; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37171.c b/SingleSource/Regression/C/gcc-dg/pr37171.c new file mode 100644 index 0000000000..623089934c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37171.c @@ -0,0 +1,18 @@ +/* PR c/37171 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned int f1 (void) __attribute__((const)); +unsigned int f2 (void) __attribute__((__const)); +unsigned int f3 (void) __attribute__((__const__)); + +unsigned int f4 (void) +{ + return f1 () + f1 () + f1 () + f1 () + + f2 () + f2 () + f2 () + f2 () + + f3 () + f3 () + f3 () + f3 (); +} + +/* { dg-final { scan-tree-dump-times "= f1 \\(\\)" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "= f2 \\(\\)" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "= f3 \\(\\)" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr37186.c b/SingleSource/Regression/C/gcc-dg/pr37186.c new file mode 100644 index 0000000000..bf37757f88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37186.c @@ -0,0 +1,9 @@ +/* PR 37186 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Werror -Wno-error=pointer-sign" } */ + +int foo(signed char *); /* { dg-message "note: expected 'signed char \\*' but argument is of type 'unsigned char \\*'" } */ +int bar(unsigned char *p) +{ + return foo(p); /* { dg-warning "pointer targets in passing argument 1 of 'foo' differ in signedness" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37217.c b/SingleSource/Regression/C/gcc-dg/pr37217.c new file mode 100644 index 0000000000..989eda2cd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37217.c @@ -0,0 +1,10 @@ +/* PR 37217 ICE with -Wconversion */ +/* { dg-do compile } */ +/* { dg-options "-Wconversion" } */ +typedef struct Tcl_ResolvedVarInfo { + char *re_guts; +} regex_t; +void TclReComp(regex_t *re) +{ + if (re->re_guts == ((void *)0)) ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37261.c b/SingleSource/Regression/C/gcc-dg/pr37261.c new file mode 100644 index 0000000000..f226da0684 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37261.c @@ -0,0 +1,14 @@ +/* PR c/37261 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned +foo (int x) +{ + unsigned a = ((x & 1) | 2) & 0x80000000; /* { dg-bogus "integer overflow in expression" } */ + unsigned b = ((x & 2) | 2) & 0x80000000; /* { dg-bogus "integer overflow in expression" } */ + unsigned c = ((x & 4) | 2) & 0x80000000; /* { dg-bogus "integer overflow in expression" } */ + return a + b + c; +} + +/* { dg-final { scan-tree-dump "return 0" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr37289.c b/SingleSource/Regression/C/gcc-dg/pr37289.c new file mode 100644 index 0000000000..0d2d220cd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37289.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +void f(unsigned long x); + +void g(long x) +{ + f((unsigned long)(-1-x)+1); +} + +/* Make sure we do not lose the conversion. */ + +/* { dg-final { scan-tree-dump "-\\\(long unsigned int\\\) x" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr37303.c b/SingleSource/Regression/C/gcc-dg/pr37303.c new file mode 100644 index 0000000000..bd9f4a8a6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37303.c @@ -0,0 +1,5 @@ +/* { dg-do compile { target *-*-elf* *-*-gnu* } } */ +/* { dg-options "-std=c99" } +/* { dg-final { scan-assembler "rdata|rodata" } } */ + +struct S { const int *x; } s = { (const int[]){1, 2, 3} }; diff --git a/SingleSource/Regression/C/gcc-dg/pr37353.c b/SingleSource/Regression/C/gcc-dg/pr37353.c new file mode 100644 index 0000000000..07d73d0ebe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37353.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/37353 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern double exp (double); + +#define A exp (arg); +#define B A A A A A A A A A A +#define C B B B B B B B B B B + +void +foo (double arg) +{ + C +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37360.c b/SingleSource/Regression/C/gcc-dg/pr37360.c new file mode 100644 index 0000000000..d2ca7f3889 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37360.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/37360 */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O3 -fPIC" } */ + +typedef unsigned int UQItype __attribute__ ((mode (QI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); + +extern const UQItype __popcount_tab[256]; +extern int __popcountsi2 (USItype); + +int +__popcountsi2 (USItype x) +{ + int i, ret = 0; + + for (i = 0; i < (4 * 8); i += 8) + ret += __popcount_tab[(x >> i) & 0xff]; + + return ret; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr37438.c b/SingleSource/Regression/C/gcc-dg/pr37438.c new file mode 100644 index 0000000000..b64994c248 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37438.c @@ -0,0 +1,21 @@ +/* PR target/37438 */ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ +/* { dg-options "-Os -march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern int bar (unsigned long long int); +extern int baz (const char *, unsigned int, unsigned short); + +int +foo (unsigned long long int x) +{ + return (x & 0xff) | ((unsigned int) (x >> 12) & ~0xff); +} + +int +test (const char *v, unsigned int w, unsigned long long int x) +{ + unsigned short k; + k = ((bar (x) & 0xff) << 8) | (foo (x) & 0xff); + return baz (v, w, k); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37529.c b/SingleSource/Regression/C/gcc-dg/pr37529.c new file mode 100644 index 0000000000..87361d5c81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37529.c @@ -0,0 +1,9 @@ +/* PR c/37529 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +void +foo () +{ + goto *; /* { dg-error "expected expression before" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37544.c b/SingleSource/Regression/C/gcc-dg/pr37544.c new file mode 100644 index 0000000000..99979cef7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37544.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -msse2 -mtune=core2 -mfpmath=387" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse2_runtime { target { i?86-*-* x86_64-*-* } } } */ + +extern void abort (void); + +int main(void) +{ + double arr[1000]; + double a, b; + + int i; + + for (i = 0; i < 1000; i++) + arr[i] = 4294967296.0 + (double)i; + + a = arr[0]; + b = (unsigned int)((unsigned long long int)a % 4294967296ULL); + + if (b >= 4294967296.0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37561.c b/SingleSource/Regression/C/gcc-dg/pr37561.c new file mode 100644 index 0000000000..e73beccfea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37561.c @@ -0,0 +1,30 @@ +/* PR c++/37561 */ +/* { dg-do compile } */ + +__extension__ __INTPTR_TYPE__ p; +char q; + +void +foo () +{ + ((char *) p)++; /* { dg-error "lvalue" } */ + + ((char *) q)++; /* { dg-error "lvalue" } */ + /* { dg-warning "cast to pointer from integer of different size" "" { target *-*-* } .-1 } */ + + ((char *) p)--; /* { dg-error "lvalue" } */ + + ((char *) q)--; /* { dg-error "lvalue" } */ + /* { dg-warning "cast to pointer from integer of different size" "" { target *-*-* } .-1 } */ + + ++(char *) p; /* { dg-error "lvalue" } */ + + ++(char *) q; /* { dg-error "lvalue" } */ + /* { dg-warning "cast to pointer from integer of different size" "" { target *-*-* } .-1 } */ + + --(char *) p; /* { dg-error "lvalue" } */ + + --(char *) q; /* { dg-error "lvalue" } */ + /* { dg-warning "cast to pointer from integer of different size" "" { target *-*-* } .-1 } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr37645.c b/SingleSource/Regression/C/gcc-dg/pr37645.c new file mode 100644 index 0000000000..ac1e5a9d1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37645.c @@ -0,0 +1,5 @@ +/* PR c/37645 */ +/* { dg-do compile } */ + +typedef int T __attribute__((__weakref__ ("U"))); /* { dg-warning "attribute ignored" } */ +void foo (int i __attribute__((__weakref__ ("j")))); /* { dg-warning "attribute ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr37663.c b/SingleSource/Regression/C/gcc-dg/pr37663.c new file mode 100644 index 0000000000..cf482cbdc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37663.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/37663 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fwrapv" } */ +/* { dg-require-effective-target int32plus } */ + +extern void bar (void); + +void +foo (int x) +{ + x = 1 >= x; + int y = -1885403717; + x = x + (x != y * y); + if (x) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37772.c b/SingleSource/Regression/C/gcc-dg/pr37772.c new file mode 100644 index 0000000000..26051c7e83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37772.c @@ -0,0 +1,20 @@ +/* PR c/37772 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo () +{ + int i; + asm (); /* { dg-error "expected string literal before" } */ + asm (1); /* { dg-error "expected string literal before" } */ + asm (int); /* { dg-error "expected string literal before" } */ + asm (: "=r" (i)); /* { dg-error "expected string literal before" } */ + asm (1 : "=r" (i)); /* { dg-error "expected string literal before" } */ + asm (int : "=r" (i)); /* { dg-error "expected string literal before" } */ + asm (: : "r" (i)); /* { dg-error "expected string literal before" } */ + asm (1 : : "r" (i)); /* { dg-error "expected string literal before" } */ + asm (int : : "r" (i)); /* { dg-error "expected string literal before" } */ + asm (: : : "memory"); /* { dg-error "expected string literal before" } */ + asm (1 : : : "memory"); /* { dg-error "expected string literal before" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37858.c b/SingleSource/Regression/C/gcc-dg/pr37858.c new file mode 100644 index 0000000000..8a81f16129 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37858.c @@ -0,0 +1,11 @@ +/* PR middle-end/37858 */ +/* ??? With -dv removed, this test is a bit silly. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-build_ssa_passes" } */ + +int +main (void) +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr37879.c b/SingleSource/Regression/C/gcc-dg/pr37879.c new file mode 100644 index 0000000000..5dd252782c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37879.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/37879 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +static inline void bar (int) __attribute__ ((noreturn)); +void baz () __attribute__ ((noreturn)); + +inline int +foo (int i) +{ + return i; +} + +int i = 23; +static inline void +bar (int j) +{ + if (j) + asm (""); +} /* { dg-warning "does return" } */ + +void +baz () +{ + int j; + bar (foo (j = i++)); + asm (""); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37908.c b/SingleSource/Regression/C/gcc-dg/pr37908.c new file mode 100644 index 0000000000..e1457faf71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37908.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ +/* { dg-options "-Wsync-nand" } */ +/* { dg-options "-Wsync-nand -march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-Wsync-nand -mcpu=v9" { target sparc*-*-* } } */ + + +extern void abort (void); + +int main (void) +{ + + short xLoc; + short xIn, xOut, xExpect, i = 1; + + xLoc = xIn = ~ (1 << i); + xExpect = ~ (xIn & 0x7F); + + xOut = __sync_nand_and_fetch (&xLoc, 0x7F); /* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" } */ + + if (xOut != xExpect) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr37985.c b/SingleSource/Regression/C/gcc-dg/pr37985.c new file mode 100644 index 0000000000..93e640b4a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr37985.c @@ -0,0 +1,8 @@ +/* PR c37985 */ +/* { dg-do compile } */ +/* { dg-options " -Wall -Wextra " } */ +unsigned char foo(unsigned char a) +{ + a >> 2; /* { dg-warning "no effect" } */ + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38140.c b/SingleSource/Regression/C/gcc-dg/pr38140.c new file mode 100644 index 0000000000..35f6010089 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38140.c @@ -0,0 +1,10 @@ +/* PR middle-end/38140 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing" } */ + +int foo (void *x) +{ + int (*fn) (int); + *(void **)&fn = x; + return fn (6); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38200.c b/SingleSource/Regression/C/gcc-dg/pr38200.c new file mode 100644 index 0000000000..d5391bd889 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38200.c @@ -0,0 +1,16 @@ +/* PR middle-end/38200 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing" } */ + +typedef int (*callptr) (void); +int foo (void **x); +void foo2 (callptr *); +int (*foo_ptr) (void **x) = foo; + +void +bar (void) +{ + void *ptr; + foo2 ((callptr *) &ptr); + *(void **) &foo_ptr = ptr; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38245-1.c b/SingleSource/Regression/C/gcc-dg/pr38245-1.c new file mode 100644 index 0000000000..1978d8dc8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38245-1.c @@ -0,0 +1,35 @@ +/* PR rtl-optimization/38245 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +static inline int +f1 (int si1, int si2) +{ + return si2 == 0 ? si1 : si1 / si2; +} + +static inline unsigned long long +f2 (unsigned long long ui1, unsigned long long ui2) +{ + return ui1 % ui2; +} + +unsigned char g; +volatile unsigned int h; + +void +f3 (void) +{ + if (!((signed char) f1 (0, f2 (g, 2123)) - 1)) + h; +} + +int +main (void) +{ + f3 (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "% 2123" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "0 / " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr38245-2.c b/SingleSource/Regression/C/gcc-dg/pr38245-2.c new file mode 100644 index 0000000000..bb2679c697 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38245-2.c @@ -0,0 +1,109 @@ +/* PR rtl-optimization/38245 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +extern void link_error (void); + +void +f1 (unsigned int a) +{ + if (a != 28) + { + if (4 / a == 5) + link_error (); + } +} + +void +f2 (unsigned int a) +{ + if (4 / a == 5) + link_error (); +} + +void +f3 (unsigned int a) +{ + if (4 / (a & 0xff) == 5) + link_error (); +} + +void +f4 (unsigned int a, unsigned int b) +{ + if ((b & 3) / ((a & 0xff) + 1) == 5) + link_error (); +} + +void +f5 (int a) +{ + if (a != 28) + { + if (4 / a == 5) + link_error (); + } +} + +void +f6 (int a) +{ + if (4 / a == 5) + link_error (); +} + +void +f7 (int a) +{ + if (4 / (a & 0xff) == 5) + link_error (); +} + +void +f8 (int a, int b) +{ + if ((b & 3) / ((a & 0xff) + 1) == 5) + link_error (); +} + +void +f9 (int a, int b) +{ + if (b >= 4) + if ((a / b) == __INT_MAX__ / 2) + link_error (); +} + +void +f10 (unsigned int a, unsigned int b) +{ + if (b >= 16) + if ((a / b) == __INT_MAX__ / 4) + link_error (); +} + +void +f11 (int a, int b) +{ + if (b <= -32) + if ((a / b) == -__INT_MAX__ / 16) + link_error (); +} + +void +f12 (int a, int b) +{ + if (a >= -6 && a <= 4) + if ((a / b) == -7 || (a / b) == 7) + link_error (); +} + +void +f13 (unsigned int a, unsigned int b) +{ + if (a <= 4) + if ((a / b) == 5) + link_error (); +} + +/* { dg-final { scan-tree-dump-not "link_error" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr38245-3.c b/SingleSource/Regression/C/gcc-dg/pr38245-3.c new file mode 100644 index 0000000000..6ef8372a14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38245-3.c @@ -0,0 +1,112 @@ +/* PR rtl-optimization/38245 */ +/* { dg-do run } */ +/* { dg-additional-sources "pr38245-4.c" } */ +/* { dg-options "-O2" } */ + +#include "pr38245-3.h" + +extern void abort (void); + +struct A { int i, j; union { short s[4]; long long l; }; char pad[512]; } a; +int globv = 6; + +void __attribute__((noinline)) +f1 (void) +{ + a.s[2] = b1 (6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21); + a.l = 6; +} + +void __attribute__((noinline)) +f2 (void) +{ + a.s[2] = b2 (6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21); + a.l = 6; +} + +void __attribute__((noinline)) +f3 (void) +{ + struct B b = { 30, 31, { 32, 33 } }; + a.s[2] = b3 (6, 7, 8, 9, 10, 11, 12, b, 14, b, 16, b, 18, 19, 20, 21, + 6, b, 8, b, 10, 11, 12, 13, 14, b, 16, b, 18, 19, 20, 21); + a.l = 6; +} + +void __attribute__((noinline)) +f4 (void) +{ + struct B b = { 30, 31, { 32, 33 } }; + a.s[2] = b4 (6, 7, 8, 9, 10, 11, 12, b, 14, b, 16, b, 18, 19, 20, 21, + 6, b, 8, b, 10, 11, 12, 13, 14, b, 16, b, 18, 19, 20, 21); + a.l = 6; +} + +void __attribute__((noinline)) +f5 (void) +{ + a.s[2] = b5 (6.0, 7, 8, 9, 10, 11, 21.0, 22.0, 23.0); + a.l = 6; +} + +void __attribute__((noinline)) +f6 (void) +{ + a.s[2] = b6 (6.0, 7, 8, 9, 10, 11, 21.0, 22.0, 23.0); + a.l = 6; +} + +void __attribute__((noinline)) +f7 (void) +{ + a.s[2] = b7 (6, 7); + a.l = 6; +} + +void __attribute__((noinline)) +f8 (void) +{ + a.s[2] = b8 (6, 7); + a.l = 6; +} + +void __attribute__((noinline)) +f9 (void) +{ + a.s[2] = b9 (6, 7, 8, 9, 10, 11, 12); + a.l = 6; +} + +void __attribute__((noinline)) +f10 (void) +{ + a.s[2] = b10 (6, 7, 8, 9, 10, 11, 12); + a.l = 6; +} + +int +main (void) +{ + char buf[256]; + int i; + for (i = 0; i < (int) sizeof buf; i++) + buf[i] = i; + asm volatile ("" : : "r" (buf) : "memory"); + f1 (); + f2 (); + f3 (); + f4 (); + f5 (); + f6 (); + f7 (); + f8 (); + f9 (); + f10 (); + asm volatile ("" : : "r" (buf) : "memory"); + for (i = 0; i < (int) sizeof buf; i++) + if (buf[i] != (char) i) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38245-3.h b/SingleSource/Regression/C/gcc-dg/pr38245-3.h new file mode 100644 index 0000000000..b1c2a0f67c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38245-3.h @@ -0,0 +1,35 @@ +/* PR rtl-optimization/38245 */ + +struct B { long a, b; char p[32]; }; +extern int globv; + +extern int b1 (long long, long, long, long, long, long, long, long, + long long, long, long, long, long, long, long, long, + long long, long, long, long, long, long, long, long, + long long, long, long, long, long, long, long, long) + __attribute__((pure, noinline)); +extern int b2 (long long, long, long, long, long, long, long, long, + long long, long, long, long, long, long, long, long, + long long, long, long, long, long, long, long, long, + long long, long, long, long, long, long, long, long) + __attribute__((const, noinline)); +extern int b3 (long long, long, long, long, long, long, long, struct B, + long long, struct B, long, struct B, long, long, long, long, + long long, struct B, long, struct B, long, long, long, long, + long long, struct B, long, struct B, long, long, long, long) + __attribute__((pure, noinline)); +extern int b4 (long long, long, long, long, long, long, long, struct B, + long long, struct B, long, struct B, long, long, long, long, + long long, struct B, long, struct B, long, long, long, long, + long long, struct B, long, struct B, long, long, long, long) + __attribute__((const, noinline)); +extern int b5 () __attribute__((pure, noinline)); +extern int b6 () __attribute__((const, noinline)); +extern int b7 (int, int) + __attribute__((pure, noinline)); +extern int b8 (int, int) + __attribute__((const, noinline)); +extern int b9 (int, int, int, int, int, int, int) + __attribute__((pure, noinline)); +extern int b10 (int, int, int, int, int, int, int) + __attribute__((const, noinline)); diff --git a/SingleSource/Regression/C/gcc-dg/pr38245-4.c b/SingleSource/Regression/C/gcc-dg/pr38245-4.c new file mode 100644 index 0000000000..c9b3d2d8fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38245-4.c @@ -0,0 +1,107 @@ +/* PR rtl-optimization/38245 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include "pr38245-3.h" + +int +b1 (long long a1, long a2, long a3, long a4, + long a5, long a6, long a7, long a8, + long long a9, long a10, long a11, long a12, + long a13, long a14, long a15, long a16, + long long a17, long a18, long a19, long a20, + long a21, long a22, long a23, long a24, + long long a25, long a26, long a27, long a28, + long a29, long a30, long a31, long a32) +{ + return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 + a19 + a20 + + a21 + a22 + a23 + a24 + a25 + a26 + a27 + a28 + a29 + a30 + + a31 + a32 + globv; +} + +int +b2 (long long a1, long a2, long a3, long a4, + long a5, long a6, long a7, long a8, + long long a9, long a10, long a11, long a12, + long a13, long a14, long a15, long a16, + long long a17, long a18, long a19, long a20, + long a21, long a22, long a23, long a24, + long long a25, long a26, long a27, long a28, + long a29, long a30, long a31, long a32) +{ + return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 + a19 + a20 + + a21 + a22 + a23 + a24 + a25 + a26 + a27 + a28 + a29 + a30 + + a31 + a32; +} + +int +b3 (long long a1, long a2, long a3, long a4, + long a5, long a6, long a7, struct B a8, + long long a9, struct B a10, long a11, struct B a12, + long a13, long a14, long a15, long a16, + long long a17, struct B a18, long a19, struct B a20, + long a21, long a22, long a23, long a24, + long long a25, struct B a26, long a27, struct B a28, + long a29, long a30, long a31, long a32) +{ + return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8.a + a9 + a10.a + + a11 + a12.a + a13 + a14 + a15 + a16 + a17 + a18.a + a19 + a20.a + + a21 + a22 + a23 + a24 + a25 + a26.a + a27 + a28.a + a29 + a30 + + a31 + a32 + globv; +} + +int +b4 (long long a1, long a2, long a3, long a4, + long a5, long a6, long a7, struct B a8, + long long a9, struct B a10, long a11, struct B a12, + long a13, long a14, long a15, long a16, + long long a17, struct B a18, long a19, struct B a20, + long a21, long a22, long a23, long a24, + long long a25, struct B a26, long a27, struct B a28, + long a29, long a30, long a31, long a32) +{ + return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8.a + a9 + a10.a + + a11 + a12.a + a13 + a14 + a15 + a16 + a17 + a18.a + a19 + a20.a + + a21 + a22 + a23 + a24 + a25 + a26.a + a27 + a28.a + a29 + a30 + + a31 + a32; +} + +int +b5 (double a1, int a2, int a3, int a4, int a5, int a6, double a7, + double a8, double a9) +{ + return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + globv; +} + +int +b6 (double a1, int a2, int a3, int a4, int a5, int a6, double a7, + double a8, double a9) +{ + return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9; +} + +int +b7 (int a1, int a2) +{ + return a1 + a2 + globv; +} + +int +b8 (int a1, int a2) +{ + return a1 + a2; +} + +int +b9 (int a1, int a2, int a3, int a4, int a5, int a6, int a7) +{ + return a1 + a2 + a3 + a4 + a5 + a6 + a7 + globv; +} + +int +b10 (int a1, int a2, int a3, int a4, int a5, int a6, int a7) +{ + return a1 + a2 + a3 + a4 + a5 + a6 + a7; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38338.c b/SingleSource/Regression/C/gcc-dg/pr38338.c new file mode 100644 index 0000000000..5dfd443492 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38338.c @@ -0,0 +1,19 @@ +/* PR middle-end/38338 */ +/* { dg-options "-O0" } */ +/* { dg-options "-O0 -fPIC" { target fpic } } */ +/* { dg-require-effective-target untyped_assembly } */ + +typedef void (*fnp) (void); + +static char +foo (char x) +{ + return x; +} + +static void * +bar (char x) +{ + void *args = __builtin_apply_args (); + return __builtin_apply ((fnp) foo, args, sizeof (void *)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38364.c b/SingleSource/Regression/C/gcc-dg/pr38364.c new file mode 100644 index 0000000000..6b22e9d78e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38364.c @@ -0,0 +1,80 @@ +/* PR middle-end/38364 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftrapv" } */ +/* { dg-require-effective-target trapping } */ + +extern void abort (void); + +static inline short +f1 (short x, short y) +{ + if (x > 0) + { + if (y > 0) + { + if (x > __SHRT_MAX__ / y) + return x; + } + else if (y < (-__SHRT_MAX__ - 1) / x) + return x; + } + else + { + if (y > 0) + { + if (x < (-__SHRT_MAX__ - 1) / y) + return x; + } + else if (x != 0 && y < __SHRT_MAX__ / x) + return x; + } + return x * y; +} + +static inline signed char +f2 (signed char x, signed char y) +{ + if (((x ^ y) & (((x ^ ((x ^ y) & (1 << (__CHAR_BIT__ - 1)))) - y) ^ y)) < 0) + return x; + return x - y; +} + +unsigned int v; + +int +f3 (int x, unsigned int y) +{ + f1 (1, 1); + return 1; +} + +int +f4 (unsigned short x) +{ + v = x; + return 1; +} + +int +f5 (int x) +{ + if (f2 (x, 1)) + f1 (1, f4 (1)); + return x; +} + +int +f6 (unsigned int x) +{ + f4 (x < (1 != f5 (0))); + return x; +} + +int +main (void) +{ + f6 (1); + if (v != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38615.c b/SingleSource/Regression/C/gcc-dg/pr38615.c new file mode 100644 index 0000000000..8a818a11fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38615.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ + +int t; +extern void abort (void); + +int f(int t, const int *a) +{ + const int b[] = { 1, 2, 3}; + if (!t) + return f(1, b); + return b == a; +} + +int main(void) +{ + if (f(0, 0)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38616.c b/SingleSource/Regression/C/gcc-dg/pr38616.c new file mode 100644 index 0000000000..c693eece22 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38616.c @@ -0,0 +1,16 @@ +/* PR middle-end/38616 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstack-protector" } */ +/* { dg-require-effective-target fstack_protector } */ + +#include + +extern int strcmp (const char *, const char *); + +#define BUFFER "1234567890abcdefghijklmno" +int main (void) +{ + char buffer[1024]=""; + sprintf (buffer, "%s", BUFFER); + return strcmp (buffer, BUFFER); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38645.c b/SingleSource/Regression/C/gcc-dg/pr38645.c new file mode 100644 index 0000000000..6877a75ead --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38645.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo() +{ + volatile int a[1]; + int i, *p = (int*)a; + + a[0] = 1; + for (i = 0; i < 1; ++i) + if (p[i]) + return -1; + return 0; +} + +/* { dg-final { scan-tree-dump "a.0. ={v} 1;" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr38700.c b/SingleSource/Regression/C/gcc-dg/pr38700.c new file mode 100644 index 0000000000..8b7cbc83c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38700.c @@ -0,0 +1,12 @@ +/* PR c/38700 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +/* { dg-require-effective-target label_values } */ + +int +foo () +{ + __UINTPTR_TYPE__ s = __builtin_expect ((__UINTPTR_TYPE__)&&L, 0); +L: + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38902.c b/SingleSource/Regression/C/gcc-dg/pr38902.c new file mode 100644 index 0000000000..d406526242 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38902.c @@ -0,0 +1,131 @@ +/* PR target/38902 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstack-protector" } */ +/* { dg-require-effective-target fstack_protector } */ + +#ifdef DEBUG +#include +#define debug(format, args...) printf (format , ## args) +#else +extern int sprintf (char *, const char *, ...); +#define debug(format, args...) +#endif + +extern void abort (void); + +/* + +Copyright (C) 2009 Canonical, Ltd. +Author: Kees Cook +License: GPLv3 + +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38616 +https://bugs.launchpad.net/ubuntu/+source/gcc-4.3/+bug/316019 +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38902 + +gcc -O2 -fstack-protector truncate.c -o truncate + + Broken: + + Only the first operation fails, so create a new function for each test. + Source must be local (literal or stack) + + __builtin_memmove + __builtin_memcpy + __builtin_strcpy (optimized to __builtin_memcpy?) + sprintf (direct) (optmized to __builtin_strcpy?) + sprintf (via %s) (optmized to __builtin_strcpy?) + + OK: + __builtin_strcat + sprintf (complex format) + + */ + +char *heap = "1234567890abcdefghijklmnopqrstuvwxyz"; + +int failed = 0; + +#define CHECK(count, a...) \ +void test##count (void) \ +{ \ + char *local = "1234567890abcdefghijklmnopqrstuvwxyz"; \ + char buffer[1024]=""; \ + a; \ + if (__builtin_strcmp(buffer, heap) == 0) { \ + debug("Okay(%d):\n\t%s\n", count, # a); \ + } \ + else { \ + debug("Failed(%d):\n\t%s\n", count, # a); \ + failed++; \ + } \ +} + + +CHECK( 0, __builtin_memcpy (buffer, "1234567890abcdefghijklmnopqrstuvwxyz", __builtin_strlen("1234567890abcdefghijklmnopqrstuvwxyz")+1); ); +CHECK( 1, __builtin_memcpy (buffer, local, __builtin_strlen(local)+1); ); +CHECK( 2, __builtin_memcpy (buffer, heap, __builtin_strlen(heap)+1); ); + +CHECK( 3, __builtin_memmove (buffer, "1234567890abcdefghijklmnopqrstuvwxyz", __builtin_strlen("1234567890abcdefghijklmnopqrstuvwxyz")+1); ); +CHECK( 4, __builtin_memmove (buffer, local, __builtin_strlen(local)+1); ); +CHECK( 5, __builtin_memmove (buffer, heap, __builtin_strlen(heap)+1); ); + +CHECK( 6, __builtin_strcpy (buffer, "1234567890abcdefghijklmnopqrstuvwxyz"); ); +CHECK( 7, __builtin_strcpy (buffer, local); ); +CHECK( 8, __builtin_strcpy (buffer, heap); ); + +CHECK( 9, sprintf (buffer, "1234567890abcdefghijklmnopqrstuvwxyz"); ); +CHECK(10, sprintf (buffer, local); ); +CHECK(11, sprintf (buffer, heap); ); + +CHECK(12, sprintf (buffer, "%s", "1234567890abcdefghijklmnopqrstuvwxyz"); ); +CHECK(13, sprintf (buffer, "%s", local); ); +CHECK(14, sprintf (buffer, "%s", heap); ); + +CHECK(15, __builtin_strcat (buffer, "1234567890abcdefghijklmnopqrstuvwxyz"); ); +CHECK(16, __builtin_strcat (buffer, local); ); +CHECK(17, __builtin_strcat (buffer, heap); ); + +void mongoose(void) +{ + char buffer[1024]=""; + sprintf (buffer, "%s", "1234567890abcdefghijklmnopqrstuvwxyz");; + if (__builtin_strcmp(buffer, heap) == 0) { + debug("Okay(%d):\n\t%s\n", -1, "sprintf (buffer, \"%s\", \"1234567890abcdefghijklmnopqrstuvwxyz\");"); + } + else { + debug("Failed(%d):\n\t%s\n", -1, "sprintf (buffer, \"%s\", \"1234567890abcdefghijklmnopqrstuvwxyz\");"); + failed++; + } +} + +int main (int argc, char *argv[]) +{ + test0(); + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + test9(); + test10(); + test11(); + + // wtf, why are these different?! + test12(); + mongoose(); + + test13(); + test14(); + test15(); + test16(); + test17(); + + if (failed) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38932.c b/SingleSource/Regression/C/gcc-dg/pr38932.c new file mode 100644 index 0000000000..4dfaffc777 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38932.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* This variable needed only to exercise FRE instead of CCP. */ +unsigned char g; + +extern void abort(); + +void f (long long int p) +{ + g = 255; + if (p >= (-9223372036854775807LL - 1) - (signed char) g) + p = 1; + + if (p) + abort (); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr38934.c b/SingleSource/Regression/C/gcc-dg/pr38934.c new file mode 100644 index 0000000000..c05742c5ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38934.c @@ -0,0 +1,19 @@ +/* PR middle-end/38934 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu99 -w" } */ + +/* This variable needed only to work around earlier optimizations than VRP. */ +unsigned char g; + +extern void abort (); + +void +f (long long int p) +{ + g = 255; + if (p >= -9223372036854775808LL - (signed char) g) + p = 1; + + if (p) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38957.c b/SingleSource/Regression/C/gcc-dg/pr38957.c new file mode 100644 index 0000000000..f94cd7627b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38957.c @@ -0,0 +1,16 @@ +/* PR c/38957 */ +/* { dg-do compile } */ + +char * +foo (void) +{ + char a[2]; + return a+1; /* { dg-warning "returns address of local variable" } */ +} + +char * +bar (void) +{ + char a[2]; + return a; /* { dg-warning "returns address of local variable" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr38984.c b/SingleSource/Regression/C/gcc-dg/pr38984.c new file mode 100644 index 0000000000..5e68e8858b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr38984.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-delete-null-pointer-checks -fdump-tree-optimized -fno-isolate-erroneous-paths-dereference" } + * */ + +int f(int *p) +{ + int a = *p; + int *null = 0; + *null = 5; + return *p == a; +} + +/* { dg-final { scan-tree-dump-times "\\\*p" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "return 1" "optimized" } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/pr39084.c b/SingleSource/Regression/C/gcc-dg/pr39084.c new file mode 100644 index 0000000000..ff73149215 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39084.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct color { int i; }; /* { dg-message "note: originally defined here" } */ +static const struct color col; +struct color * f(void) +{ + return (struct color *) &col; +} + +struct color { int j; }; /* { dg-error "redefinition of" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr39226.c b/SingleSource/Regression/C/gcc-dg/pr39226.c new file mode 100644 index 0000000000..3d336360ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39226.c @@ -0,0 +1,34 @@ +/* PR target/39226 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mtune=cell -mminimal-toc" { target { powerpc*-*-* && lp64 } } } */ + +#if (__SIZEOF_INT__ == 2) +struct A +{ + char *a; + unsigned int b : 1; + unsigned int c : 15; +}; +#else +struct A +{ + char *a; + unsigned int b : 1; + unsigned int c : 31; +}; +#endif + +struct B +{ + struct A *d; +}; + +void +foo (struct B *x, unsigned long y) +{ + if (x->d[y].c) + return; + if (x->d[y].b) + x->d[y].a = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39323-1.c b/SingleSource/Regression/C/gcc-dg/pr39323-1.c new file mode 100644 index 0000000000..d84009cad1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39323-1.c @@ -0,0 +1,5 @@ +/* PR c/39323 - MAX_OFILE_ALIGNMENT in elfos.h is too big */ +/* { dg-do compile { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ + +int foo __attribute__ ((aligned(1 << 29))) = 20; /* { dg-error "requested alignment" } */ +typedef int __attribute__ ((aligned(1 << 29))) int29; /* { dg-error "requested alignment" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr39323-2.c b/SingleSource/Regression/C/gcc-dg/pr39323-2.c new file mode 100644 index 0000000000..6b6cb2e2bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39323-2.c @@ -0,0 +1,6 @@ +/* PR c/39323 */ +/* { dg-do compile { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ + +int bar __attribute__ ((aligned(1 << 28))) = 20; + +/* { dg-final { scan-assembler ".align\[ \t\]+(268435456|28)\[ \t\]*\n" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr39323-3.c b/SingleSource/Regression/C/gcc-dg/pr39323-3.c new file mode 100644 index 0000000000..2e2c1a2532 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39323-3.c @@ -0,0 +1,7 @@ +/* PR c/39323 */ +/* { dg-do compile { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ + +typedef int __attribute__ ((aligned(1 << 28))) int28; +int28 foo = 20; + +/* { dg-final { scan-assembler ".align\[ \t\]+(268435456|28)\[ \t\]*\n" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr39343.c b/SingleSource/Regression/C/gcc-dg/pr39343.c new file mode 100644 index 0000000000..70df59ef09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39343.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/39343 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +extern inline __attribute__ ((__always_inline__)) int +foo (char *dest) +{ + return __builtin_object_size (dest, 1); +} + +struct S +{ + union + { + struct { int a, b; char c, d; } f; + struct { struct { int a, b; char c, d[255]; } e; } g; + } u; +}; + +int +main (void) +{ + struct S s; + if (foo (s.u.g.e.d) != 255) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39443.c b/SingleSource/Regression/C/gcc-dg/pr39443.c new file mode 100644 index 0000000000..1baa63a998 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39443.c @@ -0,0 +1,18 @@ +/* PR middle-end/39443 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "memcmp" } } */ + +typedef __SIZE_TYPE__ size_t; + +extern int memcmp (const void *s1, const void *s2, size_t n) + __attribute__ ((__nothrow__, __pure__)); +extern __typeof (memcmp) memcmp __asm__ ("memory_compare"); + +int +test (char *s, char *t, int cnt) +{ + if (__builtin_expect (cnt, 0)) + return memcmp (s, t, cnt); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39453.c b/SingleSource/Regression/C/gcc-dg/pr39453.c new file mode 100644 index 0000000000..35815230a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39453.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops" } */ + +int foo(int k, int n) +{ + int i; + for (i = 0; i < n; i += 8) { + int j; + for (j = 0; j < n; j += 8) { + while (k < n) { + k += 8; + } + } + } + return k; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr39455.c b/SingleSource/Regression/C/gcc-dg/pr39455.c new file mode 100644 index 0000000000..ffd1f9edde --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39455.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/39455 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */ +/* { dg-additional-options "-march=i686 -msse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +void +foo (char *x, unsigned long y, unsigned char *z) +{ + unsigned int c[256], *d; + + for (d = c + 1; d < c + 256; ++d) + *d += d[-1]; + x[--c[z[y]]] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39464.c b/SingleSource/Regression/C/gcc-dg/pr39464.c new file mode 100644 index 0000000000..021c54e60b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39464.c @@ -0,0 +1,19 @@ +/* PR c/39464 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +typedef int T __attribute__((may_alias)); +typedef unsigned int U __attribute__((may_alias)); + +void +foo (void *p) +{ + T *a = (int *) p; /* { dg-bogus "initialization from incompatible pointer type" } */ + int *b = (T *) p; /* { dg-bogus "initialization from incompatible pointer type" } */ + U *c = (unsigned int *) p; /* { dg-bogus "initialization from incompatible pointer type" } */ + unsigned int *d = (U *) p; /* { dg-bogus "initialization from incompatible pointer type" } */ + (void) a; + (void) b; + (void) c; + (void) d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39565.c b/SingleSource/Regression/C/gcc-dg/pr39565.c new file mode 100644 index 0000000000..9c14055a43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39565.c @@ -0,0 +1,48 @@ +/* PR39565: Static variable leaves undefined symbol in object file. + Variables codestrs_4 and codestrs_8 should not be undefined, + when this program is compiled at -O2. As a basic sanity test, + verify that this program compiles into an executable and runs. */ + +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +extern void exit (int); +extern int strcmp (const char *, const char *); + +static const union codestrs_t_4 { + struct { + char str_2[sizeof ("Illegal opcode")]; + }; + char str[0]; +} codestrs_4 = { {"Illegal opcode"} }; + +static const union codestrs_t_8 { + struct { + char str_12[sizeof ("Integer divide by zero")]; + }; + char str[0]; +} codestrs_8 = { {"Integer divide by zero"} }; + +const char * +psiginfo (int pinfo) +{ + const char *base = ((void *)0); + + switch (pinfo) + { + case 4: base = codestrs_4.str; break; + case 8: base = codestrs_8.str; break; + } + return base; +} + +int +main (void) +{ + if (strcmp (psiginfo (4), codestrs_4.str)) + abort (); + if (strcmp (psiginfo (8), codestrs_8.str)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39666-1.c b/SingleSource/Regression/C/gcc-dg/pr39666-1.c new file mode 100644 index 0000000000..f1ba499c33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39666-1.c @@ -0,0 +1,22 @@ +/* PR middle-end/39666 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int +foo (int i) +{ + int j; + switch (i) + { + case -__INT_MAX__ - 1 ... -1: + j = 6; + break; + case 0: + j = 5; + break; + case 1 ... __INT_MAX__: + j = 4; + break; + } + return j; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39666-2.c b/SingleSource/Regression/C/gcc-dg/pr39666-2.c new file mode 100644 index 0000000000..9ca119b6a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39666-2.c @@ -0,0 +1,22 @@ +/* PR middle-end/39666 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int +foo (int i) +{ + int j; + switch (i) + { + case -__INT_MAX__ - 1 ... -1: + j = 6; + break; + case 0: + j = 5; + break; + case 2 ... __INT_MAX__: + j = 4; + break; + } + return j; /* { dg-warning "may be used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39712.c b/SingleSource/Regression/C/gcc-dg/pr39712.c new file mode 100644 index 0000000000..9846e33cd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39712.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +int is_table[2][16]; +int is_table_lsf[2][2][16]; +void compute_stereo() +{ + int (*is_tab)[16]; + is_tab = is_table; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39794.c b/SingleSource/Regression/C/gcc-dg/pr39794.c new file mode 100644 index 0000000000..2702ba79ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39794.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/39794 */ +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-loops" } */ + +extern void abort (); + +void +foo (int *a, int n) +{ + int i; + for (i = 0; i < n; i++) + { + a[i] *= 2; + a[i + 1] = a[i - 1] + a[i - 2]; + } +} + +int a[16]; +int ref[16] = { 0, 1, 4, 2, 10, 12, 24, 44, + 72, 136, 232, 416, 736, 1296, 2304, 2032 }; + +int +main () +{ + int i; + for (i = 0; i < 16; i++) + a[i] = i; + foo (a + 2, 16 - 3); + for (i = 0; i < 16; i++) + if (ref[i] != a[i]) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr39867.c b/SingleSource/Regression/C/gcc-dg/pr39867.c new file mode 100644 index 0000000000..fbe09241cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39867.c @@ -0,0 +1,14 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern void link_error (void); + +int main (void) +{ + int exp = -1; + /* Wrong folding of the LHS to an unsigned MAX leads to 4294967295 != 2. */ + if ((exp < 2 ? 2U : (unsigned int) exp) != 2) + link_error (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr39874.c b/SingleSource/Regression/C/gcc-dg/pr39874.c new file mode 100644 index 0000000000..2db8367066 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr39874.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +extern void func(); + +void test1(char *signature) +{ + char ch = signature[0]; + if (ch == 15 || ch == 3) + { + if (ch == 15) func(); + } +} + + +void test2(char *signature) +{ + char ch = signature[0]; + if (ch == 15 || ch == 3) + { + if (ch > 14) func(); + } +} + +/* { dg-final { scan-tree-dump-times " == 15" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not " == 3" "optimized" } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/pr40031.c b/SingleSource/Regression/C/gcc-dg/pr40031.c new file mode 100644 index 0000000000..f6f1f65a7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40031.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ +double c; +double d; +double *f(int a) +{ + if(a) return &c; + return &d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40172-1.c b/SingleSource/Regression/C/gcc-dg/pr40172-1.c new file mode 100644 index 0000000000..a834a8a998 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40172-1.c @@ -0,0 +1,31 @@ +/* PR middle-end/40172 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -W -Werror -Wlogical-op" } */ + +struct rtx_def; +typedef struct rtx_def *rtx; + +extern int foo; +extern int bar; +extern int xxx; + +int +test (void) +{ + if (((rtx) 0 != (rtx) 0) && xxx ? foo : bar) + return 1; + else if ((foo & 0) && xxx) + return 2; + else if (foo & 0) + return 3; + else if (0 && xxx) + return 4; + else if (0) + return 5; + if (((int) 0 != (int) 0) && bar ? foo : xxx) + return 6; + else if (0 != 0 && foo ? xxx : bar) + return 7; + else + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40172-2.c b/SingleSource/Regression/C/gcc-dg/pr40172-2.c new file mode 100644 index 0000000000..17aabb8b5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40172-2.c @@ -0,0 +1,16 @@ +/* PR middle-end/40172 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -W -Werror" } */ + +extern int xxx; + +#define XXX xxx + +int +test (void) +{ + if (!XXX && xxx) + return 4; + else + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40172-3.c b/SingleSource/Regression/C/gcc-dg/pr40172-3.c new file mode 100644 index 0000000000..583aab0f71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40172-3.c @@ -0,0 +1,17 @@ +/* PR middle-end/40172 */ +/* { dg-do compile } */ +/* { dg-xfail-if "" { "*-*-*" } } */ +/* { dg-options "-Wall -W -Werror -Wlogical-op" } */ + +extern int xxx; + +#define XXX xxx + +int +test (void) +{ + if (!XXX && xxx) + return 4; + else + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40209.c b/SingleSource/Regression/C/gcc-dg/pr40209.c new file mode 100644 index 0000000000..4e77df5c2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40209.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fprofile-use -fopt-info -Wno-missing-profile" } */ + +void process(const char *s); + +struct BaseHolder { + unsigned int base_; +}; + +void UInt2Str(struct BaseHolder *b, unsigned int x) { + static const char digit[] = "0123456789abcdefghijklmnopqrstuvwxyz"; + char buf[100]; + int i = 100; + do { + buf[--i] = digit[x % b->base_]; + x /= b->base_; + } while (x > 0); + process(buf); +} + +/* Ignore a warning that is irrelevant to the purpose of this test. */ +/* { dg-prune-output ".*\.gcda not found, execution counts estimated.*" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr40340-1.c b/SingleSource/Regression/C/gcc-dg/pr40340-1.c new file mode 100644 index 0000000000..6307e064c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40340-1.c @@ -0,0 +1,24 @@ +/* PR middle-end/40340 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wno-system-headers -fno-tree-dse" } */ + +#include "pr40340.h" + +static inline +__attribute__ ((always_inline)) +void +test (char *p) +{ + memset (p, 0, 6); +} + +int +main (void) +{ + char buf[4]; + test (buf); + return 0; +} + +/* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "" { target *-*-* } 10 } */ +/* { dg-message "file included" "In file included" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr40340-2.c b/SingleSource/Regression/C/gcc-dg/pr40340-2.c new file mode 100644 index 0000000000..ea76e10082 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40340-2.c @@ -0,0 +1,16 @@ +/* PR middle-end/40340 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wno-system-headers -fno-tree-dse" } */ + +#include "pr40340.h" + +int +main (void) +{ + char buf[4]; + memset (buf, 0, 6); + return 0; +} + +/* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "" { target *-*-* } 10 } */ +/* { dg-message "file included" "In file included" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr40340-3.c b/SingleSource/Regression/C/gcc-dg/pr40340-3.c new file mode 100644 index 0000000000..f771a00e3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40340-3.c @@ -0,0 +1,15 @@ +/* PR middle-end/40340 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wno-system-headers" } */ + +#define TEST2 +#include "pr40340.h" + +int +main (void) +{ + test2 (); + return 0; +} + +/* { dg-bogus "overflow" "" { target *-*-* } 10 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr40340-4.c b/SingleSource/Regression/C/gcc-dg/pr40340-4.c new file mode 100644 index 0000000000..46b34bf47c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40340-4.c @@ -0,0 +1,16 @@ +/* PR middle-end/40340 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wno-array-bounds -Wno-system-headers -g" } */ + +#define TEST3 +#include "pr40340.h" + +int +main (void) +{ + char buf[4]; + test3 (buf); + return 0; +} + +/* { dg-bogus "overflow" "" { target *-*-* } 10 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr40340-5.c b/SingleSource/Regression/C/gcc-dg/pr40340-5.c new file mode 100644 index 0000000000..99e58f2ab7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40340-5.c @@ -0,0 +1,17 @@ +/* PR middle-end/40340 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wsystem-headers -g -fno-tree-dse" } */ + +#define TEST3 +#include "pr40340.h" + +int +main (void) +{ + char buf[4]; + test3 (buf); + return 0; +} + +/* { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" "" { target *-*-* } 10 } */ +/* { dg-message "file included" "In file included" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr40340.h b/SingleSource/Regression/C/gcc-dg/pr40340.h new file mode 100644 index 0000000000..174e076b94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40340.h @@ -0,0 +1,31 @@ +#pragma GCC system_header +typedef __SIZE_TYPE__ size_t; +extern void *memset (void *s, int c, size_t n) + __attribute__ ((nothrow, nonnull (1))); +extern inline +__attribute__ ((always_inline, artificial, gnu_inline, nothrow)) +void * +memset (void *dest, int ch, size_t len) +{ + return __builtin___memset_chk (dest, ch, len, + __builtin_object_size (dest, 0)); +} + +#ifdef TEST2 +static void +__attribute__ ((noinline)) +test2 (void) +{ + char buf[4]; + memset (buf, 0, 6); +} +#endif + +#ifdef TEST3 +static inline void +__attribute__ ((always_inline)) +test3 (char *p) +{ + memset (p, 0, 6); +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr40501.c b/SingleSource/Regression/C/gcc-dg/pr40501.c new file mode 100644 index 0000000000..7610a2062c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40501.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target alpha*-*-* ia64*-*-* i?86-*-* x86_64-*-* s390x-*-* } } */ +/* { dg-options "-O2 -Wno-shift-overflow" } */ +/* { dg-require-effective-target lp64 } */ + +/* PR middle-end/40501 */ + +/* This once failed due to the bswap pass missing to add the type + casts of the signed argument and result to the proper unsigned + types. */ + +typedef long int int64_t; + +int64_t +swap64 (int64_t n) +{ + return (((n & (((int64_t) 0xff) )) << 56) | + ((n & (((int64_t) 0xff) << 8)) << 40) | + ((n & (((int64_t) 0xff) << 16)) << 24) | + ((n & (((int64_t) 0xff) << 24)) << 8) | + ((n & (((int64_t) 0xff) << 32)) >> 8) | + ((n & (((int64_t) 0xff) << 40)) >> 24) | + ((n & (((int64_t) 0xff) << 48)) >> 40) | + ((n & (((int64_t) 0xff) << 56)) >> 56)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40550.c b/SingleSource/Regression/C/gcc-dg/pr40550.c new file mode 100644 index 0000000000..0de5554b14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40550.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "" } */ +/* { dg-additional-options "-msse" { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ + +typedef float v2sf __attribute__ ((vector_size (2 * sizeof(float)))); + +static void test (void) +{ + v2sf a = {1.0, 0.0}; + v2sf b = {0.0, 1.0}; + v2sf d; + d = a + b; +} + +int main () +{ + test (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40669.c b/SingleSource/Regression/C/gcc-dg/pr40669.c new file mode 100644 index 0000000000..cc6bbc9e08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40669.c @@ -0,0 +1,26 @@ +/* PR middle-end/40669 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double _Complex +test (int d, int t, double *x, double *y, double *z, int n, + double _Complex (*fnp) (double)) +{ + int m = n / 2; + double min = y[t], max = z[t], med = x[m * d + t]; + double _Complex result = 0.0; + + if (n == 0) + return 0.0; + + if (min > med) + result += test (d, (t + 1) % d, x + (m + 1) * d, y, z, n - m - 1, fnp); + else if (max < med) + result += test (d, (t + 1) % d, x, y, z, m, fnp); + else + { + result += fnp (y[0] + x[m]); + result += test (d, (t + 1) % d, x + (m + 1) * d, y, z, n - m - 1, fnp); + } + return result; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40792.c b/SingleSource/Regression/C/gcc-dg/pr40792.c new file mode 100644 index 0000000000..41f080e542 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40792.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/40792 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void foo (int, char *, int *); + +void +bar (int *a, int *b, ...) +{ + int c; + char d[256]; + foo (*b, d, &c); +} + +static int a, b; + +void +baz (int c) +{ + bar (&a, &b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40861.c b/SingleSource/Regression/C/gcc-dg/pr40861.c new file mode 100644 index 0000000000..1d955e6168 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40861.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int foo(int i) +{ + return (1LL >> 128 * i) && i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40946.c b/SingleSource/Regression/C/gcc-dg/pr40946.c new file mode 100644 index 0000000000..3fd804e563 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40946.c @@ -0,0 +1,33 @@ +/* PR middle-end/40946 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct A +{ + unsigned char a1[8]; + unsigned short a2, a3, a4, a5, a6, a7; +}; + +int bar (void *, const char *, int); +char *foo (void *, int); + +char * +baz (const char *x, const char *y) +{ + int a = sizeof (struct A) + 2 * (__builtin_strlen (y) + + __builtin_strlen (x) + 24) + 16; + struct A *b = __builtin_malloc (a); + char *c; + int d; + + b->a4 = sizeof (struct A); + c = ((char *) b) + b->a4; + d = ((char *) b) + a - c; + b->a2 = b->a3 = (unsigned short) bar (c, y, d); /* { dg-bogus "array subscript is above array bounds" } */ + c += b->a2; + d = ((char *) b) + a - c; + b->a7 = b->a4 + b->a2; + b->a5 = b->a6 = (unsigned short) bar (c, x, d); + c = foo (b, a); + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40971.c b/SingleSource/Regression/C/gcc-dg/pr40971.c new file mode 100644 index 0000000000..4317638e7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40971.c @@ -0,0 +1,24 @@ +/* PR target/40971 */ +/* { dg-do compile } */ +/* { dg-options "-O -fstack-protector -fno-strict-aliasing" } */ +/* { dg-require-effective-target fstack_protector } */ +/* { dg-require-effective-target size20plus } */ + +extern void bar (char *); + +void +foo (int f, long a) +{ + { + char d[32768]; + bar (d); + } + double b = f; + while (a) + { + char c[sizeof (double)]; + __builtin_memcpy (c, &b, sizeof (c)); + if (*(double *) c != 2.0) + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr40989.c b/SingleSource/Regression/C/gcc-dg/pr40989.c new file mode 100644 index 0000000000..0fbc87082d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr40989.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Werror=implicit" } */ +int main() { + return pippo(); /* { dg-error "" } */ +} +/* { dg-message "warnings being treated as errors" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr41033.c b/SingleSource/Regression/C/gcc-dg/pr41033.c new file mode 100644 index 0000000000..5043be2d11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41033.c @@ -0,0 +1,24 @@ +/* { dg-options "-O1 -fno-strict-aliasing" } */ +/* PR rtl-optimization/41033 */ + +struct X { + int i; + int j; +}; + +int foo(struct X *p, struct X *q) +{ + p->j = 1; + q->i = 0; + return p->j; +} + +extern void abort (void); + +int main() +{ + struct X x; + if (foo (&x, (struct X *)&x.j) != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41123.c b/SingleSource/Regression/C/gcc-dg/pr41123.c new file mode 100644 index 0000000000..076edb46ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41123.c @@ -0,0 +1,46 @@ +/* PR middle-end/41123 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing" } */ + +struct S { char a, b, c, d, e, f, g, h; }; +struct T { int a, b; }; + +struct S +f1 (float _Complex x) +{ + return *(struct S *) & x; +} + +int +f2 (float _Complex x) +{ + struct S f = f1 (x); + return f.b; +} + +struct T +f3 (float _Complex x) +{ + return *(struct T *) & x; +} + +int +f4 (float _Complex x) +{ + struct T f = f3 (x); + return f.a; +} + +int +f5 (float _Complex x) +{ + struct T f = f3 (x); + return f.b; +} + +struct T +f6 (float _Complex x) +{ + struct T f = f3 (x); + return f; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41232.c b/SingleSource/Regression/C/gcc-dg/pr41232.c new file mode 100644 index 0000000000..17ec54899d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41232.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -g" } */ +extern int atoi (const char *); +extern int sprintf (char *, const char *, ...); +void malloc_init() { + char *cptr; + char buf[1]; + int tmbd = atoi(cptr); + if (tmbd > 0) + tmbd = (tmbd <= 124) ? tmbd : 124; + else + tmbd = 0; + sprintf(buf, "%d\n", tmbd); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41241.c b/SingleSource/Regression/C/gcc-dg/pr41241.c new file mode 100644 index 0000000000..42fb2f7e5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41241.c @@ -0,0 +1,34 @@ +/* PR bootstrap/41241 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug -g" } */ +/* { dg-options "-O2 -fcompare-debug -g -march=i586 -mtune=i586 -fomit-frame-pointer" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +typedef struct { int t1; int t2; int t3; } *T; +typedef struct { int s; } S; + +int fn1 (int); +int fn2 (int, int, int); +int fn3 (void); + +static S +bar () +{ + S s = { 0 }; + return s; +} + +void +foo (T x) +{ + int a, b, c, d, e; + T f, g; + S h; + a = x->t2; + fn1 (x->t1); + h = bar (b); + c = fn1 (e); + d = fn3 (); + f->t3 &= g->t3 |= fn2 (0, b, x->t1); + fn2 (0, c, d); + fn2 (0, e, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41248.c b/SingleSource/Regression/C/gcc-dg/pr41248.c new file mode 100644 index 0000000000..0d5a74919e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41248.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +struct __gcov_var { + unsigned int offset; + unsigned int buffer[(1 << 10) + 1]; +} __gcov_var; +unsigned int * gcov_write_words (unsigned int words) { + unsigned int *result; + result = &__gcov_var.buffer[__gcov_var.offset]; + return result; +} + +struct gcov_ctr_summary { }; +struct gcov_summary { + unsigned int checksum; + struct gcov_ctr_summary ctrs[1]; +}; +void __gcov_write_unsigned (unsigned int); +void __gcov_write_summary (unsigned int tag, + const struct gcov_summary *summary) +{ + unsigned ix; + const struct gcov_ctr_summary *csum; + __gcov_write_unsigned (summary->checksum); + for (csum = summary->ctrs, ix = 1; ix--; csum++) { } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41295.c b/SingleSource/Regression/C/gcc-dg/pr41295.c new file mode 100644 index 0000000000..fabff63c92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41295.c @@ -0,0 +1,91 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -g" } */ + +enum reg_class +{ + BASE_REGS, + GENERAL_REGS, + LIM_REG_CLASSES +}; + +static __inline__ unsigned char +hard_reg_set_subset_p (const unsigned long x[4], const unsigned long y[4]) +{ + return ((x[0] & ~y[0]) == 0 + && (x[1] & ~y[1]) == 0 + && (x[2] & ~y[2]) == 0 + && (x[3] & ~y[3]) == 0); +} + +static __inline__ unsigned char +hard_reg_set_equal_p (const unsigned long x[4], const unsigned long y[4]) +{ + return x[0] == y[0] + && x[1] == y[1] + && x[2] == y[2] + && x[3] == y[3]; +} + +extern unsigned long reg_class_contents[(int) LIM_REG_CLASSES][4]; +extern int ira_important_classes_num; +extern enum reg_class ira_important_classes[(int) LIM_REG_CLASSES]; +extern enum reg_class ira_reg_class_intersect[(int) LIM_REG_CLASSES][(int) + LIM_REG_CLASSES]; +extern unsigned char ira_reg_classes_intersect_p[(int) LIM_REG_CLASSES][(int) + LIM_REG_CLASSES]; +extern enum reg_class ira_reg_class_super_classes[(int) LIM_REG_CLASSES][(int) + LIM_REG_CLASSES]; +static unsigned long temp_hard_regset[4]; + +static void +setup_reg_class_relations (void) +{ + int i, cl1, cl2, cl3; + unsigned long temp_set2[4]; + for (cl1 = 0; cl1 < (int) LIM_REG_CLASSES; cl1++) + { + ira_reg_class_super_classes[cl1][0] = LIM_REG_CLASSES; + for (cl2 = 0; cl2 < (int) LIM_REG_CLASSES; cl2++) + { + ira_reg_classes_intersect_p[cl1][cl2] = 0; + { + unsigned long *scan_tp_ = (temp_set2), *scan_fp_ = + (reg_class_contents[cl2]); + scan_tp_[1] = scan_fp_[1]; + scan_tp_[2] = scan_fp_[2]; + scan_tp_[3] = scan_fp_[3]; + } + for (i = 0; i < ira_important_classes_num; i++) + { + cl3 = ira_important_classes[i]; + { + unsigned long *scan_tp_ = (temp_hard_regset), *scan_fp_ = + (reg_class_contents[cl3]); + scan_tp_[0] = scan_fp_[0]; + scan_tp_[1] = scan_fp_[1]; + scan_tp_[3] = scan_fp_[3]; + } + if (!hard_reg_set_subset_p (temp_hard_regset, temp_set2) + || (hard_reg_set_equal_p (temp_hard_regset, temp_set2) + && hard_reg_set_subset_p (reg_class_contents[cl3], + reg_class_contents[(int) + ira_reg_class_intersect + [cl1] + [cl2]]))) + ira_reg_class_intersect[cl1][cl2] = (enum reg_class) cl3; + } + } + } +} + +static void +find_reg_class_closure (void) +{ + setup_reg_class_relations (); +} + +void +ira_init (void) +{ + find_reg_class_closure (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41340.c b/SingleSource/Regression/C/gcc-dg/pr41340.c new file mode 100644 index 0000000000..439046af89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41340.c @@ -0,0 +1,71 @@ +/* PR debug/41340 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -g -fcompare-debug" } */ +/* { dg-options "-O3 -g -fcompare-debug -march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-skip-if "no long pointers" { { ! ilp32 } && { ! lp64 } } } */ + +typedef struct { int t; } *T; +struct S1 { unsigned s1; }; +struct S2 { struct S1 s2; }; +struct S3 { unsigned s3; struct S2 **s4; }; +struct S5 { struct S2 *s5; }; + +__extension__ typedef __INTPTR_TYPE__ ssize_t; + +extern void fn0 (void) __attribute__ ((__noreturn__)); +T fn6 (struct S3); +void fn7 (void); + +static inline __attribute__((always_inline)) int +fn1 (const struct S1 *x) +{ + return x->s1; +} + +static inline __attribute__((always_inline)) int +fn2 (const struct S1 *x, unsigned y) +{ + if (y >= x->s1) + fn0 (); + return 0; +} + +static inline __attribute__((always_inline)) int +fn3 (struct S3 x) +{ + return (x.s3 == fn1 (*x.s4 ? &(*x.s4)->s2 : 0)); +} + +static inline __attribute__((always_inline)) int +fn4 (struct S3 x) +{ + return fn2 (&(*x.s4)->s2, x.s3); +} + +int +fn5 (struct S3 x, T *y) +{ + if (!fn3 (x)) + { + *y = (T) (ssize_t) fn4 (x); + return 1; + } + return 0; +} + +void +test (struct S5 *x) +{ + struct S3 a; + T b; + unsigned char c = 0; + a.s4 = &x->s5; + while (fn5 (a, &b)) + if (!(b->t & 8)) + c = 1; + a.s4 = &x->s5; + while ((b = fn6 (a))) + ; + if (!c) + fn7 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41345.c b/SingleSource/Regression/C/gcc-dg/pr41345.c new file mode 100644 index 0000000000..5753967c5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41345.c @@ -0,0 +1,15 @@ +/* PR bootstrap/41345 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fcompare-debug" } */ +/* { dg-xfail-if "AIX compare debug" { powerpc-ibm-aix* } } */ + +void +foo (int *x) +{ + int a; + for (a = 0; a < 2; a++) + if (x[a]) + goto lab; + __builtin_unreachable (); +lab:; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41454.c b/SingleSource/Regression/C/gcc-dg/pr41454.c new file mode 100644 index 0000000000..d8264bc637 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41454.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-vrp" } */ + +extern void abort (void); + +int main () +{ + int BM_tab2[0400]; + int *BM_tab = BM_tab2; + int *BM_tab_base; + + BM_tab_base = BM_tab; + BM_tab += 0400; + while (BM_tab_base != BM_tab) + { + *--BM_tab = 6; + *--BM_tab = 6; + } + if (BM_tab2[0] != 6) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41470.c b/SingleSource/Regression/C/gcc-dg/pr41470.c new file mode 100644 index 0000000000..7374facea0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41470.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fexceptions" } */ +/* { dg-require-effective-target alloca } */ +/* { dg-require-effective-target exceptions } */ + +void cf (void *); + +void * +af (void *a) +{ + return a; +} +void +bf (void) +{ + void *p; + { + int i = 1; + char v[i]; + p = af (v); + } + cf (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41488.c b/SingleSource/Regression/C/gcc-dg/pr41488.c new file mode 100644 index 0000000000..1e4bf19c7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41488.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ivcanon-scev" } */ + +struct struct_t +{ + int* data; +}; + +void foo (struct struct_t* sp, int start, int end) +{ + int i; + + for (i = 0; i+start < end; i++) + sp->data[i+start] = 0; +} + +/* { dg-final { scan-tree-dump-times "Simplify PEELED_CHREC into POLYNOMIAL_CHREC" 1 "ivcanon" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr41551.c b/SingleSource/Regression/C/gcc-dg/pr41551.c new file mode 100644 index 0000000000..e1123206cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41551.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* Make sure we do not ICE. */ + +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; + +int main(void) +{ + int var, *p = &var; + return (double)(uintptr_t)(p); +} + +/* { dg-prune-output "-Wreturn-local-addr" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr41573.c b/SingleSource/Regression/C/gcc-dg/pr41573.c new file mode 100644 index 0000000000..52961db8f2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41573.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +__inline __attribute__ ((__always_inline__)) char * +strcpy (char *__dest, __const char *__src) +{ + return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); +} + +const char* get_attr(unsigned attr) +{ + static char tmp[256]; + + strcpy(tmp, ""); + return tmp; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41574.c b/SingleSource/Regression/C/gcc-dg/pr41574.c new file mode 100644 index 0000000000..062c004453 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41574.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fno-unsafe-math-optimizations -fdump-rtl-combine" { target { arm*-*-* } } } */ +/* { dg-options "-O2 -fno-unsafe-math-optimizations -fdump-rtl-combine" { target { ! arm*-*-* } } } */ + + +static const double one=1.0; + +double +f(double x) +{ + return x*(one+x); +} + +/* { dg-final { scan-rtl-dump-not "\\(plus:DF \\(mult:DF" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr41619.c b/SingleSource/Regression/C/gcc-dg/pr41619.c new file mode 100644 index 0000000000..9c164e3a60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41619.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-ira-share-save-slots" } */ + +struct A {}; + +int foo(); + +struct A bar(double x) +{ + double y; + if (foo()) + y = 1 / x; + return bar(y); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41643.c b/SingleSource/Regression/C/gcc-dg/pr41643.c new file mode 100644 index 0000000000..7c0743da41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41643.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/41643 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce" } */ + +struct S { int a; }; + +int +f (struct S *x) +{ + int a = x->a; + if (a) + return f (x) + a; + else + return f (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41762.c b/SingleSource/Regression/C/gcc-dg/pr41762.c new file mode 100644 index 0000000000..88d8172f28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41762.c @@ -0,0 +1,31 @@ +/* PR target/41762 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftracer -fsched2-use-superblocks" } */ +/* { dg-options "-O2 -ftracer -fsched2-use-superblocks -fpic" { target fpic } } */ + +extern __SIZE_TYPE__ strlen (const char *); +extern int f1 (void *); +extern char *f2 (void); +extern void f3 (int, int); +static char *a; +char *b, *c, *d, *e; + +void +foo (void) +{ + int f, g, h; + f = (a ? strlen (a) : strlen ("abcde")); + f += (b ? strlen (b) : 0); + f += (c ? strlen (c) : 0); + f += (d ? strlen (d) : 0); + f += (e ? strlen (e) : 0); + h = f1 (strlen); + g = strlen (a); + f3 (g, f); +} + +void +bar (void) +{ + a = f2 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41783.c b/SingleSource/Regression/C/gcc-dg/pr41783.c new file mode 100644 index 0000000000..465b0af872 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41783.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-pre -fno-tree-loop-im" } */ +int db[100]; +int a_global_var, fact; +int main() +{ + int i,j=0; + do + { + for (i=0; i<100; ++i) + db[i] = i; + fact = a_global_var * i; + } + while (j++ < 100); +} +/* We want to have exactly one load (not two) from a_global_var, + and we want that load to be into a PRE temporary. */ +/* { dg-final { scan-tree-dump-times "= a_global_var;" 1 "pre" } } */ +/* { dg-final { scan-tree-dump "pretmp\[^\\n\]* = a_global_var;" "pre" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr41837.c b/SingleSource/Regression/C/gcc-dg/pr41837.c new file mode 100644 index 0000000000..de6bd06d64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41837.c @@ -0,0 +1,42 @@ +/* PR middle-end/41837 */ +/* { dg-do compile } */ +/* { dg-options "-O -fwhole-program -fprofile-generate" } */ + +typedef struct { int a, b; } T1; +typedef struct S1 *T2; +typedef struct S2 *T3; +typedef struct S3 *T4; +typedef struct S4 *T5; +struct S4 { union { int c; } d; }; +struct S2 { int e; T2 f; int g; }; +typedef struct { T3 h; } T6; +typedef struct { int i; } *T7; +struct S3 { T6 j; T7 k; }; + +void f5 (T4); +void f6 (void (*)(T4)); +void f7 (void (*)(T5, T1 *)); + +void +f1 (T4 x) +{ + if (!x->j.h->e) + f5 (x); +} + +void +f2 (void) +{ + f6 (f1); +} + +void +f3 (T5 x, T1 *y) +{ +} + +void +f4 (void) +{ + f7 (f3); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41841.c b/SingleSource/Regression/C/gcc-dg/pr41841.c new file mode 100644 index 0000000000..8bce4e6240 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41841.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/41841 */ +/* { dg-do compile } */ +/* { dg-options "-O -fwhole-program -fipa-cp" } */ + +typedef struct S *T; +typedef struct { } *U; +extern int f1 (void); + +static void +f3 (U x, int y) +{ + T a = (T) x; + y && f1 (); +} + +static void +f2 (T x) +{ + f3 ((U) x, 1); +} + +void *volatile a __attribute__((used)) = f2; diff --git a/SingleSource/Regression/C/gcc-dg/pr41842.c b/SingleSource/Regression/C/gcc-dg/pr41842.c new file mode 100644 index 0000000000..1550ad1bfb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41842.c @@ -0,0 +1,9 @@ +/* PR c/41842 */ +/* { dg-do compile } */ + +void +f () +{ + char x[g (h)]; /* { dg-error "undeclared" } */ +/* { dg-message "undeclared identifier is reported only once" "reminder" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41935.c b/SingleSource/Regression/C/gcc-dg/pr41935.c new file mode 100644 index 0000000000..e6a1b28670 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41935.c @@ -0,0 +1,25 @@ +/* PR middle-end/41935 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +struct A { int a; int b[10]; }; + +int +foo (struct A *p) +{ + return __builtin_offsetof (struct A, b[p->a]); +} + +int +main () +{ + struct A a; + a.a = 7; + if (foo (&a) != 7 * sizeof (int) + __builtin_offsetof (struct A, b)) + abort (); + a.a = 2; + if (foo (&a) != 2 * sizeof (int) + __builtin_offsetof (struct A, b)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr41963.c b/SingleSource/Regression/C/gcc-dg/pr41963.c new file mode 100644 index 0000000000..408a3d24c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr41963.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern float fabsf(float); +extern float sqrtf(float); + +static __attribute__((noinline)) void f (float *dst, float *src) +{ + int i, j; + for (i = 0; i < 2; i++) + { + float len; + dst[0] = src[0]; + dst[1] = src[1]; + len = sqrtf (dst[0] * dst[0] + dst[1] * dst[1]); + if (len > 0.5f) + { + len = 1.0f / len; + dst[0] *= len; + dst[1] *= len; + } + } +} + +extern void abort (void); + +int main() +{ + float dst[2], src[2]; + src[0] = 2.0f; + src[1] = 5.0f; + f (dst, src); + if (fabsf (dst[0] * dst[0] + dst[1] * dst[1] - 1.0f) > 0.01f) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42078.c b/SingleSource/Regression/C/gcc-dg/pr42078.c new file mode 100644 index 0000000000..8107ff5557 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42078.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/42078 */ +/* { dg-do compile } */ +/* { dg-options "-g -O -ffast-math" } */ + +double sqrt (double x); + +float +foo (float x) +{ + float y = sqrt (x); + return x / y; +} + +inline float +bar (float x) +{ + float y = sqrt (x); + float a = y; + float b = y; + float c = y; + return x / y; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42084.c b/SingleSource/Regression/C/gcc-dg/pr42084.c new file mode 100644 index 0000000000..d5aad9642c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42084.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -fno-delete-null-pointer-checks" } */ +extern void abort (void); +int g = 0; +static int __attribute__((noinline)) f (long long a, long long b) +{ + int cmp; + cmp = a > b; + if (&g == 0) + cmp-=2; + else + cmp++; + return cmp; +} + +int main (void) +{ + int ret = f (2, 1); + if (ret != 2) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42215.c b/SingleSource/Regression/C/gcc-dg/pr42215.c new file mode 100644 index 0000000000..e5a75bd305 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42215.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-distribution" } */ + +extern int A[]; +extern int B[]; + +void f(int i) +{ + while (i-- > 0) { + A[i] = 0; + B[i] = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42245-2.c b/SingleSource/Regression/C/gcc-dg/pr42245-2.c new file mode 100644 index 0000000000..e99fe3759d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42245-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining" } */ + +int +strictly_smaller_name (char *s, char *t) +{ + int ss, tt; + while ((*s != '\0') || (*t != '\0')) + { + if (*s == '\0') + ss = '*'; + else + ss = *s++; + if (*t != '\0') + tt = *t; + if (ss == tt) + return 0; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr42245.c b/SingleSource/Regression/C/gcc-dg/pr42245.c new file mode 100644 index 0000000000..a516e7ae54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42245.c @@ -0,0 +1,30 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining" } */ + +extern int N_words; +typedef struct DIS_node_struct DIS_node; +typedef struct CON_list_struct CON_list; + +struct DIS_node_struct +{ + CON_list *cl; +}; + +void +build_DIS_CON_tree (void) +{ + int w; + DIS_node *dnroot, *dn; + CON_list *child, *xchild; + for (w = 0; w < N_words; w++) + { + if (dnroot == ((void *) 0)) + { + dnroot = dn; + for (child = dn->cl; child != ((void *) 0); child = xchild) + { + } + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr42246.c b/SingleSource/Regression/C/gcc-dg/pr42246.c new file mode 100644 index 0000000000..163f2b4a63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42246.c @@ -0,0 +1,36 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops" } */ + +typedef enum +{ + empty = 0, pawn = 1, knight = 2, king = 3, bishop = 5, rook = 6, queen = 7 +} +PIECE; +extern int p_values[15]; +extern int *last[65]; +int +Quiesce (int alpha, int beta, int wtm, int ply) +{ + register int initial_alpha, value, delta; + register int *goodmv, *movep, moves = 0, *sortv, temp; + for (movep = last[ply - 1]; movep < last[ply]; movep++) + if (p_values[(((*movep) >> 15) & 7) + 7] + + p_values[(((*movep) >> 18) & 7) + 7] >= delta) + { + register int done; + register int *end = last[ply - 1] + moves - 1; + do + { + done = 1; + movep = last[ply - 1]; + for (; movep < end; movep++, sortv++) + if (*sortv < *(sortv + 1)) + { + *(movep + 1) = temp; + done = 0; + } + } + while (!done); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr42249.c b/SingleSource/Regression/C/gcc-dg/pr42249.c new file mode 100644 index 0000000000..3289d54d6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42249.c @@ -0,0 +1,37 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining" } */ + +typedef struct TypHeader +{ + unsigned long size; + struct TypHeader **ptr; +} *TypHandle; + +extern TypHandle NewBag (unsigned int type, unsigned long size); +typedef unsigned long TypPoint32; + +TypHandle +QuoPP (TypHandle hdL, TypHandle hdR) +{ + TypHandle hdC; + unsigned long degC; + TypPoint32 *ptC; + unsigned long degL; + TypPoint32 *ptL; + unsigned long degR; + TypPoint32 *ptR; + unsigned long p; + + degL = ((hdL)->size) / sizeof (TypPoint32); + degR = ((hdR)->size) / sizeof (TypPoint32); + degC = degL < degR ? degR : degL; + hdC = NewBag (9, (unsigned long) (degC * sizeof (TypPoint32))); + ptC = (TypPoint32 *) ((TypHandle *) ((hdC)->ptr)); + + for (p = 0; p < degC; p++) + ptC[(((p) < (degR)) ? (ptR)[(p)] : (p))] = + ((((((p) < (degL)) ? (ptL)[(p)] : (p))) < + (degR)) ? (ptR)[((((p) < (degL)) ? (ptL)[(p)] : (p)))] + : ((((p) < (degL)) ? (ptL)[(p)] : (p)))); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr42250.c b/SingleSource/Regression/C/gcc-dg/pr42250.c new file mode 100644 index 0000000000..21b29ba4e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42250.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern double log10 (double __x); +extern double ceil (double __x); +extern double floor (double __x); +extern void free (void *__ptr); +extern void *my_malloc (unsigned int); +extern int num_rr_nodes; +static float get_cblock_trans (int *num_inputs_to_cblock, + int max_inputs_to_cblock, + float trans_cblock_to_lblock_buf, + float trans_sram_bit); +static float trans_per_mux (int num_inputs, float trans_sram_bit); +void +count_routing_transistors (int num_switch, float R_minW_nmos, + float R_minW_pmos) +{ + int *num_inputs_to_cblock; + int iswitch, i, j, iseg, max_inputs_to_cblock; + float input_cblock_trans; + const float trans_sram_bit = 6.; + float trans_cblock_to_lblock_buf; + input_cblock_trans = + get_cblock_trans (num_inputs_to_cblock, max_inputs_to_cblock, + trans_cblock_to_lblock_buf, trans_sram_bit); +} + +static float +get_cblock_trans (int *num_inputs_to_cblock, int max_inputs_to_cblock, + float trans_cblock_to_lblock_buf, float trans_sram_bit) +{ + float *trans_per_cblock; + float trans_count; + int i, num_inputs; + + trans_per_cblock = + (float *) my_malloc ((max_inputs_to_cblock + 1) * sizeof (float)); + for (i = 1; i <= max_inputs_to_cblock; i++) + trans_per_cblock[i] = + trans_per_mux (i, trans_sram_bit) + trans_cblock_to_lblock_buf; + for (i = 0; i < num_rr_nodes; i++) + { + num_inputs = num_inputs_to_cblock[i]; + trans_count += trans_per_cblock[num_inputs]; + } + free (trans_per_cblock); + return (trans_count); +} + +static float +trans_per_mux (int num_inputs, float trans_sram_bit) +{ + int nlevels, ilevel, current_inps; + float ntrans = 0; + + if (num_inputs <= 1) + return (0); + nlevels = ceil (log10 (num_inputs) / log10 (2.) - 0.00001); + current_inps = num_inputs; + for (ilevel = 1; ilevel <= nlevels; ilevel++) + { + ntrans += 2 * floor (current_inps / 2.); + current_inps = ceil (current_inps / 2.); + } + ntrans += trans_sram_bit * nlevels; + return (ntrans); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42388.c b/SingleSource/Regression/C/gcc-dg/pr42388.c new file mode 100644 index 0000000000..a68a2e85b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42388.c @@ -0,0 +1,67 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fmodulo-sched" } */ + +enum rtx_code +{ + INSN, ADDR_VEC, ADDR_DIFF_VEC, CALL_INSN, CODE_LABEL, BARRIER, NOTE +}; +typedef union rtunion_def +{ + int rtint; + char *rtstr; + struct rtx_def *rtx; + struct rtvec_def *rtvec; +} +rtunion; +typedef struct rtx_def +{ + unsigned short code; + rtunion fld[1]; +} + *rtx; +typedef struct rtvec_def +{ + unsigned num_elem; + rtunion elem[1]; +} + *rtvec; +extern rtx emit_barrier (void); +extern rtx emit_note (char *); + +static void +copy_loop_body (rtx *map) +{ + int i; + rtx insn, copy; + rtx pat = copy->fld[3].rtx; + + switch (insn->code) + { + case INSN: + if (insn->fld[7].rtx) + { + } + else if (pat->code == ADDR_VEC || pat->code == ADDR_DIFF_VEC) + { + int diff_vec_p = pat->code == ADDR_DIFF_VEC; + int len = pat->fld[diff_vec_p].rtvec->num_elem; + for (i = 0; i < len; i++) + pat->fld[diff_vec_p].rtvec->elem[i].rtx->fld[5].rtint++; + } + case CALL_INSN: + for (i = 0; i < 64; i++) + map[i] = 0; + case CODE_LABEL: + case BARRIER: + copy = emit_barrier (); + case NOTE: + copy = emit_note ("x"); + } +} +void +unroll_loop (int insn_count, rtx *map) +{ + if (insn_count > 50) + copy_loop_body (map); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr42389.c b/SingleSource/Regression/C/gcc-dg/pr42389.c new file mode 100644 index 0000000000..8bb06ae943 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42389.c @@ -0,0 +1,87 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining -fsched-pressure" } */ + +struct s_linked_f_pointer +{ + struct s_linked_f_pointer *next; + float *fptr; +}; +struct s_trace +{ + int index; +}; +struct s_rr_cost +{ + float base_cost; + float acc_cost; +}; +extern int num_nets; +extern struct s_trace **trace_head; +extern struct s_rr_cost *rr_cost; +struct s_rr_route +{ + float cost; +}; +static int heap_tail; +extern struct s_linked_f_pointer *rr_modified_head; +extern struct s_rr_route *rr_route; + +void +empty_heap (void) +{ + heap_tail = 1; +} + +void +reset_path_costs (void) +{ + struct s_linked_f_pointer *mod_ptr; + if (rr_modified_head != ((void *) 0)) + { + mod_ptr = rr_modified_head; + while (mod_ptr->next != ((void *) 0)) + { + *(mod_ptr->fptr) = 1.e30; + mod_ptr = mod_ptr->next; + } + rr_modified_head = ((void *) 0); + } +} + +static void +route_net (int inet) +{ + int i; + for (i = 1; i < inet; i++) + reset_path_costs (); + empty_heap (); + reset_path_costs (); +} + +void +pathfinder_update_one_cost (int inet, float pres_fac, float acc_fac) +{ + struct s_trace *tptr; + int inode = 0; + + tptr = trace_head[inet]; + inode = tptr->index; + rr_route[inode].cost = rr_cost[inode].base_cost + rr_cost[inode].acc_cost; +} + +int +try_route (int n, float x, float y) +{ + int inet, itry; + float pres_fac; + for (itry = 1; itry <= n; itry++) + { + for (inet = 0; inet < num_nets; inet++) + { + route_net (inet); + pathfinder_update_one_cost (inet, pres_fac, x); + } + pres_fac *= y; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr42396.c b/SingleSource/Regression/C/gcc-dg/pr42396.c new file mode 100644 index 0000000000..b3b7e4e2c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42396.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -ftracer -fsched2-use-superblocks" } */ + +static int i; +extern void baz(int); +void foo() { i = 3; } +void bar() { baz(i ? 2 : 1); } diff --git a/SingleSource/Regression/C/gcc-dg/pr42427.c b/SingleSource/Regression/C/gcc-dg/pr42427.c new file mode 100644 index 0000000000..b5a51cc322 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42427.c @@ -0,0 +1,22 @@ +/* { dg-do assemble { target c99_runtime } } */ +/* { dg-options "-O2 -fexceptions -fnon-call-exceptions -fpeel-loops" } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-require-effective-target exceptions } */ + +#include + +extern double myabs (complex double); + +void +test (double *help, complex double *wm, long nz) +{ + long k; + double znew; + double zold; + for (k = 0; k < nz; k++) + { + znew = myabs (wm[k]); + zold = help[k]; + help[k] = znew; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42461.c b/SingleSource/Regression/C/gcc-dg/pr42461.c new file mode 100644 index 0000000000..0518bfd973 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42461.c @@ -0,0 +1,14 @@ +/* PR rtl-optimization/42461 */ +/* Reported by Patrick Pelissier */ + +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +extern int link_failure (int) __attribute__ ((pure)); + +int main (void) +{ + if (link_failure (0) < 1) + __builtin_unreachable (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42475.c b/SingleSource/Regression/C/gcc-dg/pr42475.c new file mode 100644 index 0000000000..a5edffa78e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42475.c @@ -0,0 +1,28 @@ +/* PR rtl-optimization/42475 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef struct { float x, y; } B; +typedef struct { float z; } C; +typedef struct { B b; C c; } D; + +B +foo (float x, float y) +{ + B b = { .x = x, .y = y }; + return b; +} + +B +bar (B b, B y) +{ + return foo (y.x + b.x, b.y); +} + +B +baz (D p) +{ + D d = { }; + B y = bar (foo (0, (p.c.z) / 2), d.b); + return y; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42611.c b/SingleSource/Regression/C/gcc-dg/pr42611.c new file mode 100644 index 0000000000..f502feac33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42611.c @@ -0,0 +1,20 @@ +/* PR other/42611 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#define L \ + (sizeof (__SIZE_TYPE__) == sizeof (void *) ? __INTPTR_MAX__ \ + : sizeof (__SIZE_TYPE__) == 1 ? __SCHAR_MAX__ \ + : sizeof (__SIZE_TYPE__) == sizeof (short) ? __SHRT_MAX__ \ + : sizeof (__SIZE_TYPE__) == sizeof (int) ? __INT_MAX__ \ + : sizeof (__SIZE_TYPE__) == sizeof (long) ? __LONG_MAX__ \ + : sizeof (__SIZE_TYPE__) == sizeof (long long) ? __LONG_LONG_MAX__ \ + : __INTMAX_MAX__) +struct S { int a; char b[L]; }; /* { dg-error "type .struct S. is too large" } */ + +void +foo (void) +{ + struct S s; /* { dg-warning "size of .s. \[0-9\]+ bytes exceeds maximum object size \[0-9\]+" } */ + asm volatile ("" : : "r" (&s)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42629.c b/SingleSource/Regression/C/gcc-dg/pr42629.c new file mode 100644 index 0000000000..7b5b23264f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42629.c @@ -0,0 +1,29 @@ +/* This failed -fcompare-debug because register pressure computation + took debug insns into account. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fsched-pressure -fschedule-insns -fcompare-debug" { target scheduling } } */ +/* { dg-options "-O1 -fcompare-debug" { target { ! scheduling } } } */ +/* { dg-require-effective-target int32plus } */ + +int lzo_adler32(int adler, char *buf) +{ + int s1 = adler; + int s2 = adler; + s1 += buf[0]; + s2 += s1; + s1 += buf[1]; + s2 += s1; + s1 += buf[2]; + s2 += s1; + s1 += buf[3]; + s2 += s1; + s1 += buf[4]; + s2 += s1; + s1 += buf[5]; + s2 += s1; + s1 += buf[6]; + s2 += s1; + s1 += buf[7]; + s2 += s1; + return (s2 << 16) + s1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42630.c b/SingleSource/Regression/C/gcc-dg/pr42630.c new file mode 100644 index 0000000000..34543dab5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42630.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fvariable-expansion-in-unroller -funroll-loops -fcompare-debug" } */ + +int sum(int *buf, int len) +{ + int s = 0; + while (--len > 0) s += *buf++; + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42631.c b/SingleSource/Regression/C/gcc-dg/pr42631.c new file mode 100644 index 0000000000..4f91444937 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42631.c @@ -0,0 +1,24 @@ +/* The function below expands to a loop whose latch block starts with + a PHI node and the corresponding debug stmt. In RTL, there are no + PHI nodes, but the debug insn that references the incoming k + remains, even though one of the incoming edges has it + uninitialized. After unrolling, however, the debug insn becomes + unconditional, and this exposed a problem in the webizer. Because + DF doesn't combine the uses of an uninitialized pseudo into a + single UD chain, we created a separate web for each use. + Allocating separate registers or stack slots for each uninitialized + use is wasteful, but the problem became more apparent in + -fcompare-debug tests: register numbers went out of sync, and could + have caused codegen differences depending on whether or not the + debug insns were present. The fix was to arrange for web to + combine uninitialized uses into a single web. */ + +/* { dg-do compile } */ +/* { dg-options "-g -O1 -funroll-loops -fcompare-debug" } */ +/* { dg-xfail-if "AIX compare debug" { powerpc-ibm-aix* } } */ + +void foo() +{ + unsigned k; + while (--k > 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42662.c b/SingleSource/Regression/C/gcc-dg/pr42662.c new file mode 100644 index 0000000000..6f416e8267 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42662.c @@ -0,0 +1,48 @@ +/* PR debug/42662 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ + +struct S { unsigned long s[17]; }; + +static inline void +foo (struct S *r, struct S *a, unsigned n) +{ + unsigned b = n / 8; + r->s[0] = (b >= 1 ? : a->s[1 - b]); +} + +static inline void +bar (struct S *r, struct S *a) +{ + r->s[0] = a->s[0] << 1; +} + +static inline void +baz (struct S *r, struct S *a, struct S *b) +{ + unsigned c = 0; + int i; + for (i = 0; i < 3; ++i) + { + unsigned long d = a->s[i]; + long e = d + b->s[i]; + if (c) + ++e == 0; + c = e < d; + r->s[i] = e; + } +} + +void +test (struct S *r, int s, int d) +{ + struct S u; + if (s) + { + bar (&u, r); + foo (r, r, 3); + baz (r, r, &u); + } + u.s[0] = d; + baz (r, r, &u); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42685.c b/SingleSource/Regression/C/gcc-dg/pr42685.c new file mode 100644 index 0000000000..29d6381cf5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42685.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O -funroll-loops -fcompare-debug" } */ + +struct S { + int i; +}; + +extern void baz(int); + +static inline void bar(struct S *s) +{ + baz(s->i); +} + +void foo(int *w, int cond, struct S *s) +{ + int i, n = 0; + while (*w++ != 0) n++; + for (i = 0; i < n; i++) + if (cond == 0) + bar(s + i); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42715.c b/SingleSource/Regression/C/gcc-dg/pr42715.c new file mode 100644 index 0000000000..72bdfc8624 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42715.c @@ -0,0 +1,59 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-fPIC -g -O2 -w" } */ +/* var-tracking failed to clobber the reg holding v at the asm insn, + so v ended up bound to an intermediate PIC expression. */ + +struct A { unsigned a1; char a2[15]; }; +struct B { long b1; unsigned char b2; long b3; }; +struct C { void *c1; unsigned c2; unsigned c3; }; + +static struct A v1; +struct A *const v2 = &v1; + +static inline +int foo (void) +{ + int *v; + __asm__ __volatile__ ("" : "=r" (v)); + return v[1]; +} + +static void +bar (struct C *x) +{ + if (x->c2 == x->c3 && x->c1) + f1 (foo (), x->c1, x->c3 * sizeof (x->c1[0])); +} + +void +baz (struct B *y) +{ + int i; + const char *j; + char *k; + char x[64]; + for (i = 0; i < sizeof (struct B); i++, y) + { + switch (y->b2) + { + case 0x20: + if (__builtin_strchr (j, '=')) + continue; + } + switch (y->b2) + { + case 0x80: + bar (&x); + f2 (y->b3); + case 0x2e: + case 0x4e: + break; + default: + if (v2->a1) + f2 (y->b2); + } + k[0] = '\0'; + if (v2->a1) + f2 (y->b1); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42719.c b/SingleSource/Regression/C/gcc-dg/pr42719.c new file mode 100644 index 0000000000..94a58e41a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42719.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/42719 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftracer -fcompare-debug" } */ + +int *v; + +void +foo (int a) +{ + int i, j; + for (j = i = a; i != -1; j = i, i = v[i]) + ; + v[j] = v[a]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42728.c b/SingleSource/Regression/C/gcc-dg/pr42728.c new file mode 100644 index 0000000000..7b2fbb690f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42728.c @@ -0,0 +1,11 @@ +/* PR debug/42728 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fcompare-debug" } */ + +void +foo (char *a) +{ + char *b; + for (; *a; a++) + a = b++; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42889.c b/SingleSource/Regression/C/gcc-dg/pr42889.c new file mode 100644 index 0000000000..d3421736de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42889.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/42889 */ +/* { dg-do compile } */ +/* { dg-options "-O -fgcse -fcompare-debug" } */ + +extern int A[], B[]; + +int +foo (int x, int c, int i) +{ + if (A[i] && B[i]) + x = x % ((c & 4) ? 8 : 4); + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42916.c b/SingleSource/Regression/C/gcc-dg/pr42916.c new file mode 100644 index 0000000000..d32ba94882 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42916.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -funroll-loops -ftree-vectorize -fcompare-debug" } */ + +int seed; + +static inline int hash(const char *str) +{ + int h = seed++; + int i = 12; + while (i--) + h += (h << 3) ^ *str++; + return h; +} + +void f(const char *str, int *h) +{ + int i = 6; + while (i--) + *h++ = hash(str); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42918.c b/SingleSource/Regression/C/gcc-dg/pr42918.c new file mode 100644 index 0000000000..8a3eef5eee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42918.c @@ -0,0 +1,21 @@ +/* PR debug/42918 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug -ftracer" } */ + +extern int fi (void); +extern void fv (void); + +int +f (int i, int j) +{ + if (!j) + { + fv (); + goto lab; + } + i = fi (); + if (i == j) + fv (); +lab: + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr42963.c b/SingleSource/Regression/C/gcc-dg/pr42963.c new file mode 100644 index 0000000000..b84ea6cb39 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr42963.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cfg" } */ +extern void foo (void); +extern int i; +void +bar (void) +{ + switch (i) + { + case 0: + foo (); + break; + case 1: + break; + } + + + switch (i) + { + case 0: + foo (); + break; + case 1: + break; + } +} +/* { dg-final { scan-tree-dump-times "case 1:" 0 "cfg" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr43058.c b/SingleSource/Regression/C/gcc-dg/pr43058.c new file mode 100644 index 0000000000..bba6f814a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43058.c @@ -0,0 +1,21 @@ +/* PR debug/43058 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ +/* { dg-timeout-factor 4 } */ + +extern void *f1 (void *, void *, void *); +extern void *f2 (const char *, int, int, int, void *(*) ()); +extern void *f3 (const char *); +extern void *f4 (void *s); +extern void *f5 (void *); + +void test (void) +{ +#define X1 f1 (f2 ("a", 1, 0, 0, f5), \ + f4 (({ const char *a = "b"; f3 (a); })), \ + ({ const char *a = "c"; f3 (a); })); +#define X2 X1 X1 X1 X1 X1 X1 X1 X1 X1 X1 +#define X3 X2 X2 X2 X2 X2 X2 X2 X2 X2 X2 +#define X4 X3 X3 X3 X3 X3 X3 X3 X3 X3 X3 + X4 X4 +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43082.c b/SingleSource/Regression/C/gcc-dg/pr43082.c new file mode 100644 index 0000000000..a6e0046167 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43082.c @@ -0,0 +1,10 @@ +/* Test that the compiler does not crash when void expressions are + found inside conditional expressions. PR c/43082. */ +/* { dg-do compile } */ + +void +foo (int x) +{ + if (x ? (void)(0) : (void)(1)) /* { dg-error "void value not ignored as it ought to be" } */ + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43084.c b/SingleSource/Regression/C/gcc-dg/pr43084.c new file mode 100644 index 0000000000..dc75982f45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43084.c @@ -0,0 +1,16 @@ +/* PR debug/43084 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fwhole-program -fcompare-debug" } */ + +struct S +{ + int a; +}; + +int +main () +{ + struct S s; + struct S *p = &s; + return p->a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43139.c b/SingleSource/Regression/C/gcc-dg/pr43139.c new file mode 100644 index 0000000000..4dc725bcc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43139.c @@ -0,0 +1,59 @@ +/* PR target/43139 */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-g -O2 -fpic" } */ + +typedef double T1[10]; +typedef double T2[10][10]; +typedef int T3[10]; + +void __attribute__((noinline)) +fn1 (void) +{ + asm volatile ("" : : : "memory"); +} + +void __attribute__((noinline)) +fn2 (int x, ...) +{ + asm volatile ("" : : "r" (x) : "memory"); +} + +static void +bar (double v, double w, double x, double y, double z) +{ + double a; + if (v / w < 200.0) + { + a = x + (y - x) * __builtin_exp (-v / w); + fn2 (0); + fn2 (1, a * 20.2 / z, z); + fn1 (); + } +} + +static void +baz (T2 u, T2 v, T2 t, T2 x, T1 y, T3 z, double q, int j, int k) +{ + int i = z[k]; + if (u[i][j] > 0.0) + bar (q, x[i][j], v[i][j], t[i][j], y[i]); +} + +static T2 a, b, c, d; +static T1 e; +static T3 f; + +void __attribute__((noinline)) +test (int j, int k, double q) +{ + baz (a, b, c, d, e, f, q, j, k); +} + +int +main (void) +{ + d[0][6] = 1.0; + a[0][6] = 2.0; + test (6, 7, 400.0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43157.c b/SingleSource/Regression/C/gcc-dg/pr43157.c new file mode 100644 index 0000000000..c06f98ac02 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43157.c @@ -0,0 +1,20 @@ +/* { dg-do link } */ +/* { dg-require-effective-target lto } */ +/* { dg-require-linker-plugin "" } */ +/* { dg-options "-O1 -flto -fuse-linker-plugin" } */ + +#define LABEL3(pfx, x) # pfx x +#define LABEL2(pfx, x) LABEL3(pfx, x) +#define LABEL(x) LABEL2(__USER_LABEL_PREFIX__, x) + +unsigned int factorial_ (unsigned int) __asm__ (LABEL ("factorial")); + +unsigned int factorial (unsigned int i) +{ + return i > 1 ? i * factorial_ (i - 1) : 1; +} + +int main (void) +{ + return factorial (5); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43211.c b/SingleSource/Regression/C/gcc-dg/pr43211.c new file mode 100644 index 0000000000..1549619ed1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43211.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +struct T; + +struct S { + void (*bar)(struct S); +}; + +void bar(struct T t) {} /* { dg-error "" } */ + +void foo(struct S *s) +{ + s->bar = bar; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr43213.c b/SingleSource/Regression/C/gcc-dg/pr43213.c new file mode 100644 index 0000000000..d12fb22b1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43213.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +struct S { + int i; +}; + +struct S f(int i) +{ + return *(struct S *)&i; +} + +/* { dg-final { scan-assembler-not "memmove" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr43245.c b/SingleSource/Regression/C/gcc-dg/pr43245.c new file mode 100644 index 0000000000..85490ffaa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43245.c @@ -0,0 +1,18 @@ +/* PR c/43245 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-discarded-qualifiers" } */ + +void +foo (char *p) +{ +} + +char * +bar (void) +{ + const char *s = "foo"; + char *s1 = s; + s1 = s; + foo (s); + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43280.c b/SingleSource/Regression/C/gcc-dg/pr43280.c new file mode 100644 index 0000000000..dfb369b5de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43280.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2" } */ + +#include + +extern void abort (void); + +uint64_t __attribute__((noinline)) +byteswap64(uint64_t x) +{ + uint32_t a = x >> 32; + uint32_t b = (uint32_t) x; + return ((uint64_t) ((((((b)) >> (8)) | (((b)) << (32 - (8)))) & 0xff00ff00L) + | (((((b)) << (8)) | (((b)) >> (32 - (8)))) & 0x00ff00ffL)) << 32) + | (uint64_t) ((((((a)) >> (8)) | (((a)) << (32 - (8)))) & 0xff00ff00L) + | (((((a)) << (8)) | (((a)) >> (32 - (8)))) & 0x00ff00ffL)); +} + +int +main () +{ + uint64_t in = (uint64_t)0x01020304 << 32 | 0x05060708; + uint64_t cmp = (uint64_t)0x08070605 << 32 | 0x04030201; + + if (cmp != byteswap64 (in)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43299.c b/SingleSource/Regression/C/gcc-dg/pr43299.c new file mode 100644 index 0000000000..d71c896893 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43299.c @@ -0,0 +1,28 @@ +/* PR debug/43299 */ +/* { dg-do assemble } */ +/* { dg-options "-g -O2" } */ + +extern void *emit_insn (void *); + +__attribute__((noinline)) +void *gen_load_locked_si (void *x, void *y) +{ + return x; +} + +__attribute__((noinline)) +void *gen_load_locked_di (void *x, void *y) +{ + return x; +} + +void +emit_load_locked (int mode, void *reg, void *mem) +{ + void * (*fn) (void *, void *) = ((void *)0); + if (mode == 9) + fn = gen_load_locked_si; + else if (mode == 10) + fn = gen_load_locked_di; + emit_insn (fn (reg, mem)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43300.c b/SingleSource/Regression/C/gcc-dg/pr43300.c new file mode 100644 index 0000000000..a3d66fe70f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43300.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -w" } */ +/* { dg-options "-Os -w -Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */ + +typedef float V2SF __attribute__ ((vector_size (128))); + +V2SF +foo (int x, V2SF a) +{ + V2SF b; + if (x & 42) + b = a; + else + b = a + (V2SF) {1.0f/0.0f - 1.0f/0.0f, 1.0f/0.0f - 1.0f/0.0f}; + while (x--) + a += b; + + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43305.c b/SingleSource/Regression/C/gcc-dg/pr43305.c new file mode 100644 index 0000000000..c8aeaf23cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43305.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -ffast-math" } */ +extern int ilogbl(long double); +extern int printf(const char *format, ...); + +__attribute__((noinline, noclone)) +int foo(long double x) +{ + return ilogbl(x); +} + +int main() +{ + printf("%d\n", foo(100)); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43317.c b/SingleSource/Regression/C/gcc-dg/pr43317.c new file mode 100644 index 0000000000..de81c44150 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43317.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fwhole-program -g" } */ + +extern void *malloc(__SIZE_TYPE__); + +struct S { + int i; +}; + +int main(int argc, char *argv[]) +{ + int i = argc; + struct S *p = malloc(sizeof (struct S)); + return p[i].i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43379.c b/SingleSource/Regression/C/gcc-dg/pr43379.c new file mode 100644 index 0000000000..e4c3eb55a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43379.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftracer -w" } */ +/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target indirect_jumps } */ + +void *foo(int i, int *p) +{ +lab: + if (p) *p = i; + goto *p; + return &&lab; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr43402.c b/SingleSource/Regression/C/gcc-dg/pr43402.c new file mode 100644 index 0000000000..e6ef2d7d54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43402.c @@ -0,0 +1,60 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -fno-inline" } */ +/* { dg-require-effective-target int32plus } */ + +extern void abort (void); + +static int something; + +static int * converterData[2]={ + &something, &something, +}; + +static struct { + const char *name; + int type; +} const cnvNameType[] = { + { "bocu1", 1 }, + { "utf7", 1 }, + { "utf8", 1 } +}; + + +const int * getAlgorithmicTypeFromName(const char *realName); +const int * +getAlgorithmicTypeFromName(const char *realName) +{ + unsigned mid, start, limit; + unsigned lastMid; + int result; + start = 0; + limit = sizeof(cnvNameType)/sizeof(cnvNameType[0]); + mid = limit; + lastMid = 0xffffffff; + + for (;;) { + mid = (start + limit) / 2; + if (lastMid == mid) { /* Have we moved? */ + break; /* We haven't moved, and it wasn't found. */ + } + lastMid = mid; + result = __builtin_strcmp(realName, cnvNameType[mid].name); + + if (result < 0) { + limit = mid; + } else if (result > 0) { + start = mid; + } else { + return converterData[cnvNameType[mid].type]; + } + } + + return 0; +} + +int main (void) +{ + if (!getAlgorithmicTypeFromName ("utf8")) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43419.c b/SingleSource/Regression/C/gcc-dg/pr43419.c new file mode 100644 index 0000000000..a4306f0485 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43419.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ +/* { dg-add-options ieee } */ +#include + +extern void abort (void); +void __attribute__((noinline)) f (double x) +{ + double pluszero = pow (x, 0.5); + double minuszero = sqrt (x); + if (signbit (pluszero) == signbit (minuszero)) + abort (); +} + +int main(void) +{ + f (-0.0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43513.c b/SingleSource/Regression/C/gcc-dg/pr43513.c new file mode 100644 index 0000000000..9383a802c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43513.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp2" } */ + +void bar (int *); +void foo (char *, int); + +void +foo3 () +{ + const int kIterations = 10; + int results[kIterations]; + int i; + bar (results); + for (i = 0; i < kIterations; i++) + foo ("%d ", results[i]); +} + +/* { dg-final { scan-tree-dump-times "alloca" 0 "ccp2"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr43557-1.c b/SingleSource/Regression/C/gcc-dg/pr43557-1.c new file mode 100644 index 0000000000..5ba467d01c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43557-1.c @@ -0,0 +1,19 @@ +/* PR debug/43557 */ +/* { dg-do link } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -g -O2" } */ +/* { dg-additional-sources "pr43557-2.c" } */ + +struct S +{ + int v; +} g; + +void +f1 (void) +{ + struct S *s = &g; + s->v = 0; +} + +int main() { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr43557-2.c b/SingleSource/Regression/C/gcc-dg/pr43557-2.c new file mode 100644 index 0000000000..890e68e158 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43557-2.c @@ -0,0 +1,10 @@ +/* PR debug/43557 */ +/* { dg-do compile } */ + +extern struct S g; + +void +f2 (void) +{ + &g; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43562.c b/SingleSource/Regression/C/gcc-dg/pr43562.c new file mode 100644 index 0000000000..352c107a93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43562.c @@ -0,0 +1,20 @@ +/* { dg-options "-O0" } */ +/* { dg-do compile } */ + +extern unsigned foo (void); +extern void bar (void); + +__attribute__ ((optimize ("O2"))) +void bak () +{ + unsigned a; + while (1) + { + a = foo (); + while (a) + { + a &= 1; + bar (); + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43564.c b/SingleSource/Regression/C/gcc-dg/pr43564.c new file mode 100644 index 0000000000..39e0f3ac3e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43564.c @@ -0,0 +1,16 @@ +/* { dg-options "-O0" } */ +/* { dg-do compile } */ + +static inline __attribute__ ((__always_inline__)) +unsigned __clz (unsigned input) +{ + unsigned output; + __asm__ __volatile__ ("clz %0, %1":"=r" (output):"r" (input)); +} +__attribute__ ((optimize ("O2"))) +void foo () +{ + unsigned a; + unsigned b; + a = __clz (b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43643.c b/SingleSource/Regression/C/gcc-dg/pr43643.c new file mode 100644 index 0000000000..43896abd85 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43643.c @@ -0,0 +1,25 @@ +/* Contributed by Jürgen Keil */ + +/* { dg-do run } */ +/* { dg-require-profiling "-pg" } */ +/* { dg-options "-O2 -pg" } */ +/* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */ + +extern char *strdup (const char *); + +void +func(char *a, char *b, char *c) +{ + void *p = strdup(a); + p = strdup(b); + p = strdup(c); +} + +int +main(void) +{ + func("a", "b", "c"); + return 0; +} + +/* { dg-final { cleanup-profile-file } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr43670.c b/SingleSource/Regression/C/gcc-dg/pr43670.c new file mode 100644 index 0000000000..f152b4d7a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43670.c @@ -0,0 +1,29 @@ +/* PR debug/43670 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-vrp -fcompare-debug" } */ + +extern void abort (void); + +typedef struct { double T1; } S; + +void +foo (void) +{ + int i, j; + double s; + + S y[2][2]; + S *x[2] = { y[0], y[1] }; + S **p = x; + + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + p[j][i].T1 = 1; + + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + s = p[j][i].T1; + + if (s != 1) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43730.c b/SingleSource/Regression/C/gcc-dg/pr43730.c new file mode 100644 index 0000000000..0d91aef1d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43730.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +extern int (isinfl)(long double); + +int +bugfun(long double x, long double y) +{ + int result; + + if (isinfl(x)) + result = isinfl(y); + else + { + int kx, ky; + kx = ky = 1; + result = (kx == ky); + } + return (result); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43783.c b/SingleSource/Regression/C/gcc-dg/pr43783.c new file mode 100644 index 0000000000..196735b1b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43783.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-skip-if "small alignment" { pdp11-*-* } } */ + +typedef __attribute__((aligned(16))) +struct { + unsigned long long w[3]; +} UINT192; + +UINT192 bid_Kx192[32]; /* { dg-error "size of array element is not a multiple of its alignment" } */ + +extern void abort (void); + +int main() +{ + int i = 0; + unsigned long x = 0; + for (i = 0; i < 32; ++i) + bid_Kx192[i].w[1] = i == 1; + for (i = 0; i < 32; ++i) + x += bid_Kx192[1].w[1]; + if (x != 32) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr43864-2.c b/SingleSource/Regression/C/gcc-dg/pr43864-2.c new file mode 100644 index 0000000000..ea247acdfd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43864-2.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre -fdump-tree-optimized-blocks-details" } */ + +int +f (int c, int b, int d) +{ + int r, e; + + if (c) + r = b + d; + else + { + e = b + d; + r = e; + } + + return r; +} + +/* { dg-final { scan-tree-dump-times "if " 0 "pre"} } */ +/* { dg-final { scan-tree-dump-times "(?n)_.*\\+.*_" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr43864-3.c b/SingleSource/Regression/C/gcc-dg/pr43864-3.c new file mode 100644 index 0000000000..a771d4b68b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43864-3.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-pre -fdump-tree-optimized-blocks-details" } */ + +/* Commutative case. */ + +int f(int c, int b, int d) +{ + int r, e; + + if (c) + r = b + d; + else + { + e = d + b; + r = e; + } + + return r; +} + +/* { dg-final { scan-tree-dump-times "if " 0 "pre"} } */ +/* { dg-final { scan-tree-dump-times "(?n)_.*\\+.*_" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr43864-4.c b/SingleSource/Regression/C/gcc-dg/pr43864-4.c new file mode 100644 index 0000000000..535d1cd004 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43864-4.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre -fdump-tree-optimized-details-blocks" } */ + +/* Different stmt order. */ + +int f(int c, int b, int d) +{ + int r, r2, e; + + if (c) + { + r = b + d; + r2 = d - b; + } + else + { + r2 = d - b; + e = d + b; + r = e; + } + + return r - r2; +} + +/* During PRE elimination we should simplify this to return b * 2. */ +/* { dg-final { scan-tree-dump-times "if " 0 "pre" } } */ +/* { dg-final { scan-tree-dump "_\[0-9\]+ = b_\[0-9\]+\\(D\\) \\* 2;\[\\r\\n\]\[^\\r\\n\]*return _\[0-9\]+;" "pre" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr43864.c b/SingleSource/Regression/C/gcc-dg/pr43864.c new file mode 100644 index 0000000000..12849f5a2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43864.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-pre -fdump-tree-optimized-blocks-details" } */ + +extern void foo (char*, int); +extern void mysprintf (char *, char *); +extern void myfree (void *); +extern int access (char *, int); +extern int fopen (char *, int); + +char * +hprofStartupp (char *outputFileName, char *ctx) +{ + char fileName[1000]; + int fp; + mysprintf (fileName, outputFileName); + if (access (fileName, 1) == 0) + { + myfree (ctx); + return 0; + } + + fp = fopen (fileName, 0); + if (fp == 0) + { + myfree (ctx); + return 0; + } + + foo (outputFileName, fp); + + return ctx; +} + +/* { dg-final { scan-tree-dump-times "myfree \\(" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr43971.c b/SingleSource/Regression/C/gcc-dg/pr43971.c new file mode 100644 index 0000000000..9091fc2732 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr43971.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-delete-null-pointer-checks" } */ + +union ktime { + long tv64; +}; +typedef union ktime ktime_t; +ktime_t +do_one_initcall(ktime_t rettime, ktime_t calltime) +{ + ktime_t delta; + delta = ({ (ktime_t){ .tv64 = (rettime).tv64 - (calltime).tv64 }; }); + return delta; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44012.c b/SingleSource/Regression/C/gcc-dg/pr44012.c new file mode 100644 index 0000000000..bd255ba08f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44012.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgcse" } */ + +extern void fe (); + +extern int i; + +static inline void +FX (void (*f) ()) +{ + fe (); + (*f) (); +} + +static inline void +f4 () +{ + for (;;) + switch (i) + { + case 306: + FX (&fe); + break; + default: + return; + } +} + +static inline void +f3 () +{ + f4 (); + for (;;) + switch (i) + { + case 267: + FX (&f4); + break; + default: + return; + } +} + +static inline void +f2 () +{ + f3 (); + while (i) + FX (&f3); +} + +void +f1 () +{ + f2 (); + while (1) + FX (&f2); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44023.c b/SingleSource/Regression/C/gcc-dg/pr44023.c new file mode 100644 index 0000000000..df22bba83f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44023.c @@ -0,0 +1,47 @@ +/* PR debug/44023 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug -O2" } */ +/* { dg-options "-fcompare-debug -O2 -mcpu=ev67" { target alpha*-*-* } } */ +/* { dg-require-effective-target int32plus } */ + +void +foo (unsigned f, long v, unsigned *w, unsigned a, unsigned b, unsigned e, unsigned c, unsigned d) +{ + unsigned h = v / 4, x[16]; + while (f < h) + { + unsigned i; + f++; + a |= (a >> 30); + d = (d << 30) | ((unsigned) d >> 30); + c = (c << 30) | ((unsigned) c >> 30); + b = 30 | ((unsigned) b >> 30); + d += a = (a << 30) | ((unsigned) a >> 2); + c += ((d << 5) | (d >> 27)) + ((e & (a ^ b))) + 0x5a827999 + x[12]; + a += (c & e); + c = 30 | ((unsigned) c); + i = x[5] ^ x[7] ^ x[8] ^ x[3]; + x[5] = (i << 1) | ((unsigned) i >> 31); + i = x[6] ^ x[2] ^ x[14] ^ x[13]; + x[6] = (i << 1) | (i >> 31); + b += (c | (c >> 5)) + (d ^ e) + 0x6ed9eba1 + (x[7] = (i << 1) | ((unsigned) i >> 31)); + x[8] = i | 1; + e += (a | 5) + b + (i = x[9] ^ x[6], x[10] = (i << (unsigned) i)); + e = 30 | ((unsigned) e >> 30); + i = x[12] ^ x[14] ^ x[12] ^ x[12], (x[12] = 1 | ((unsigned) i)); + i = x[13] ^ x[5] ^ x[10], (x[13] = (i << (unsigned) 1)); + i = x[2] ^ x[7] ^ x[12], (x[15] = i | ((unsigned) i >> 1)); + i = x[2] ^ x[0] ^ x[13], (x[0] = (i << 1) | 31); + e = (e << 30) | 2; + i = x[14] ^ x[2] ^ x[15], (x[2] = i | 1); + x[3] = i | ((unsigned) i); + i = x[14] ^ x[12] ^ x[4], (x[4] = 1 | ((unsigned) i >> 1)); + x[5] = i | 1; + e = (e << 30) | 30; + b += (5 | ((unsigned) e >> 5)) + 0x8f1bbcdc + (x[9] = (i | ((unsigned) i >> 1))); + i = x[2] ^ (x [10] = ((i << 1) | (i >> 1))); + x[13] = (i | ((unsigned) i >> 1)); + (i = x[14] ^ x[0] ^ x[14], (x[14] = ((i << 1) | 31))); + a = *w += a; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44024.c b/SingleSource/Regression/C/gcc-dg/pr44024.c new file mode 100644 index 0000000000..3bcf4311c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44024.c @@ -0,0 +1,15 @@ +/* { dg-do link } */ +/* { dg-options "-O1 -fdelete-null-pointer-checks -fdump-tree-ccp1" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ + +void foo(); +void link_error (void); + +int main() +{ + if (foo == (void *)0) + link_error (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "if \\(foo" "ccp1" { target { ! avr*-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr44028.c b/SingleSource/Regression/C/gcc-dg/pr44028.c new file mode 100644 index 0000000000..33452172bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44028.c @@ -0,0 +1,22 @@ +/* PR debug/44028 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ +/* { dg-options "-O3 -fsched-pressure -fschedule-insns -fcompare-debug" { target i?86-*-* x86_64-*-* } } */ + +struct S { int val[16]; }; + +static inline int +bar (struct S x) +{ + long double pc = 0; + int i; + for (i = 0; i < 16; i++) + pc += x.val[i]; + return pc; +} + +int +foo (struct S x) +{ + return bar (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44061.c b/SingleSource/Regression/C/gcc-dg/pr44061.c new file mode 100644 index 0000000000..60a4260ae9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44061.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +int a[2]; +int foo (int q) +{ + if (__builtin_constant_p (q)) + { + if (q == 4) + return a[4]; /* { dg-bogus "array subscript is above array bounds" } */ + else + return a[0]; + } + else + return a[q]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44136.c b/SingleSource/Regression/C/gcc-dg/pr44136.c new file mode 100644 index 0000000000..31f1924619 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44136.c @@ -0,0 +1,27 @@ +/* PR debug/44136 */ +/* { dg-do compile } */ +/* { dg-options "-w -O2 -g" } */ +/* { dg-options "-w -Wno-psabi -O2 -g -mno-sse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#define vector __attribute((vector_size(16))) +vector float a; + +float +foo (float b) +{ + vector float c = { 0, 0, 0, 0 }; + vector float d = { 0, 0, 0, 0 }; + d += c; + return ((float *)&c)[2]; +} + +float +bar (vector float a, int b, vector float c) +{ + vector float e = c * a; + a = (vector float) { 0, 0, 0, 0 }; + c = (vector float) { 0, 0, 0, 0 }; + float d = ((float *)&a)[0]; + float f = ((float *)&c)[0]; + return d * f; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44194-1.c b/SingleSource/Regression/C/gcc-dg/pr44194-1.c new file mode 100644 index 0000000000..a38270b792 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44194-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile { target { { { { { { { { { { i?86-*-* x86_64-*-* } && x32 } || lp64 } && { ! s390*-*-* } } && { ! hppa*64*-*-* } } && { ! alpha*-*-* } } && { { ! powerpc*-*-linux* } || powerpc_elfv2 } } && { ! nvptx-*-* } } } } } } */ +/* { dg-skip-if "returns that struct in memory" { mmix-*-* } } */ +/* { dg-options "-O2 -fdump-rtl-dse1 -fdump-rtl-final" } */ + +/* Restrict to 64-bit targets since 32-bit targets usually return small + structures in memory. */ + +struct ints { int a, b, c; } foo(); +void bar(int a, int b); + +void func() { + struct ints s = foo(); + bar(s.a, s.b); +} + +/* { dg-final { scan-rtl-dump "global deletions = (2|3)" "dse1" } } */ + +/* Here we want to ignore frame-related instructions, marked as insn/f, + that do things like store the link register to the stack. We also want + to treat insns the same regardless of whether they have a scheduling + :TI marker, so match both "insn " and "insn:". */ +/* { dg-final { scan-rtl-dump-not "insn\[: \]\[^\n\]*set \\(mem(?!\[^\n\]*scratch)" "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr44194-2.c b/SingleSource/Regression/C/gcc-dg/pr44194-2.c new file mode 100644 index 0000000000..23735bd85d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44194-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-dse1" } */ + +struct ints { int a, b, c; } foo(); +void bar(int a, int b); + +void func() { + volatile struct ints s = foo(); + bar(s.a, s.b); +} +/* { dg-final { scan-rtl-dump "global deletions = 0" "dse1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr44214-1.c b/SingleSource/Regression/C/gcc-dg/pr44214-1.c new file mode 100644 index 0000000000..a5377b9e62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44214-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -freciprocal-math -fdump-tree-ccp1" } */ + +typedef double v2df __attribute__ ((vector_size (2 * sizeof (double)))); + +void do_div (v2df *a, v2df *b) +{ + *a = *b / (v2df) { 2.0, 3.0 }; +} + +/* Constant folding should multiply *b by the reciprocals of the + vector elements. The fold does not take place for generic + vectors until the first CCP pass. The string " * " occurs 3 + times: one multiply and two indirect parameters. */ + +/* { dg-final { scan-tree-dump-times " \\\* " 3 "ccp1" } } */ +/* { dg-final { scan-tree-dump-times " / " 0 "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr44214-2.c b/SingleSource/Regression/C/gcc-dg/pr44214-2.c new file mode 100644 index 0000000000..f03fa7a0db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44214-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -freciprocal-math -fdump-tree-original" } */ + +void do_div (_Complex double *a, _Complex double *b) +{ + *a = *b / (4.0 - 5.0fi); +} + +/* Constant folding should multiply *b by the reciprocal of 4 - 5i + = 4/41 + (5/41)i. */ + +/* { dg-final { scan-tree-dump-times " \\\* " 1 "original" } } */ +/* { dg-final { scan-tree-dump-times " / " 0 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr44214-3.c b/SingleSource/Regression/C/gcc-dg/pr44214-3.c new file mode 100644 index 0000000000..705cb8f0a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44214-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ + +typedef double v2df __attribute__ ((vector_size (2 * sizeof (double)))); + +void do_div (v2df *a, v2df *b) +{ + *a = *b / (v2df) { 2.0, 2.0 }; +} + +/* Since 2.0 has an exact reciprocal, constant folding should multiply *b + by the reciprocals of the vector elements. As a result there should be + one vector multiply and zero divides in the optimized code. The fold + does not take place for generic vectors until the first CCP pass. The + string " * " occurs 3 times: one multiply and two indirect parameters. */ + +/* { dg-final { scan-tree-dump-times " \\\* " 3 "ccp1" } } */ +/* { dg-final { scan-tree-dump-times " / " 0 "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr44290-1.c b/SingleSource/Regression/C/gcc-dg/pr44290-1.c new file mode 100644 index 0000000000..05d2454fc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44290-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target naked_functions } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +static void __attribute__((naked)) +foo(void *from, void *to) +{ + asm volatile("dummy"::"r"(from), "r"(to)); +} + +unsigned int fie[2]; + +void fum(void *to) +{ + foo(fie, to); +} + +/* { dg-final { scan-tree-dump "foo \\\(void \\\* from, void \\\* to\\\)" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr44290-2.c b/SingleSource/Regression/C/gcc-dg/pr44290-2.c new file mode 100644 index 0000000000..0733510911 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44290-2.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target naked_functions } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +static unsigned long __attribute__((naked)) +foo (unsigned long base) +{ + asm volatile ("dummy"); +} +unsigned long +bar (void) +{ + static int start, set; + + if (!set) + { + set = 1; + start = foo (0); + } + + return foo (start); +} + +/* { dg-final { scan-tree-dump "foo \\\(long unsigned int base\\\)" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr44337.c b/SingleSource/Regression/C/gcc-dg/pr44337.c new file mode 100644 index 0000000000..57e0549247 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44337.c @@ -0,0 +1,10 @@ +/* PR middle-end/44337 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-dce -fno-tree-dse -w" } */ + +void +foo (void) +{ + _Complex float v[1]; + v[1] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44393.c b/SingleSource/Regression/C/gcc-dg/pr44393.c new file mode 100644 index 0000000000..906d5932a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44393.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -ftree-loop-distribution" } */ + +int i; +void foo () +{ + int **pp = 0, *p = 0; + while (--i) + { + *p++ = 0; + *pp++ = p; + } + i = *p; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr44404.c b/SingleSource/Regression/C/gcc-dg/pr44404.c new file mode 100644 index 0000000000..a0b4ceb98c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44404.c @@ -0,0 +1,35 @@ +/* PR rtl-optimization/44404 + foo() used to be miscompiled on ARM due to a bug in auto-inc-dec.c, + which resulted in "strb r1, [r1], #-36". */ + +/* { dg-do run } */ +/* { dg-options "-O2 -fno-unroll-loops" } */ + +extern char *strcpy (char *, const char *); +extern int strcmp (const char*, const char*); +extern void abort (void); + +char buf[128]; + +void __attribute__((noinline)) +bar (int a, const char *p) +{ + if (strcmp (p, "0123456789abcdefghijklmnopqrstuvwxyz") != 0) + abort (); +} + +void __attribute__((noinline)) +foo (int a) +{ + if (a) + bar (0, buf); + strcpy (buf, "0123456789abcdefghijklmnopqrstuvwxyz"); + bar (0, buf); +} + +int +main (void) +{ + foo (0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44485.c b/SingleSource/Regression/C/gcc-dg/pr44485.c new file mode 100644 index 0000000000..82f05f8ce6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44485.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/44485 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -funsafe-math-optimizations" } */ + +unsigned short b; +int bar (unsigned); + +void +baz (void) +{ + if (bar (0)) + for (b = 0; b < 30; b++) + ; +} + +int +bar (unsigned z) +{ + unsigned short c; + for (; ; z += 1) +l1: + if (z) + goto l2; +l2: + for (z = 0; z < 9; z++) + if (z) + goto l1; + for (c = 0; c; c = (__UINTPTR_TYPE__) baz) + ; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44509.c b/SingleSource/Regression/C/gcc-dg/pr44509.c new file mode 100644 index 0000000000..7c50bd0fc2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44509.c @@ -0,0 +1,9 @@ +/* PR bootstrap/44509 */ +/* { dg-do compile } */ +/* { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } */ + +double +foo (void) +{ + return __DBL_MAX__ - __FLT_MAX__; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44539.c b/SingleSource/Regression/C/gcc-dg/pr44539.c new file mode 100644 index 0000000000..9cfff7a3ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44539.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/44539 */ +/* { dg-do compile } */ +/* { dg-options "-ftracer -freorder-blocks -O2" } */ + +void bar (int file); +extern int baz (void); + +void noret1 () +{ + bar (0); + __builtin_exit (0); +} + +void noret2 () +{ + __builtin_exit (0); +} + +void bar (int i) +{ + if (baz ()) + noret1 (i); +} + +void foo (int i) +{ + if (~i) bar (i); + i ? noret1 () : noret2 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44545.c b/SingleSource/Regression/C/gcc-dg/pr44545.c new file mode 100644 index 0000000000..37f75f16f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44545.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fnon-call-exceptions -ftrapv -fexceptions" } */ +/* { dg-require-effective-target exceptions } */ +void +DrawChunk(int *tabSize, int x) +{ + const int numEnds = 10; + int ends[numEnds + 2]; + if (*tabSize > 0) { + x -= 5; + x = (x + *tabSize) / *tabSize; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr44606.c b/SingleSource/Regression/C/gcc-dg/pr44606.c new file mode 100644 index 0000000000..13cc3efc19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44606.c @@ -0,0 +1,53 @@ +/* PR target/44606 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "requires io" { freestanding } } */ + +#include + +extern void abort (void); + + typedef struct _PixelPacket { unsigned char r, g, b; } + PixelPacket; +#define ARRAYLEN(X) (sizeof(X)/sizeof(X[0])) +PixelPacket q[6]; +#define COLS (ARRAYLEN(q) - 1) +PixelPacket p[2*COLS + 22]; +#define Minify(POS, WEIGHT) do { \ + total_r += (WEIGHT)*(p[POS].r); \ + total_g += (WEIGHT)*(p[POS].g); \ + total_b += (WEIGHT)*(p[POS].b); \ +} while (0) +unsigned long columns = COLS; +int main(void) +{ + static const unsigned char answers[COLS] = { 31, 32, 34, 35, 36 }; + unsigned long x; + for (x = 0; x < sizeof(p)/sizeof(p[0]); x++) { + p[x].b = (x + 34) | 1; + } + for (x = 0; x < columns; x++) { + double total_r = 0, total_g = 0, total_b = 0; + double saved_r = 0, saved_g = 0, saved_b = 0; + Minify(2*x + 0, 3.0); + Minify(2*x + 1, 7.0); + Minify(2*x + 2, 7.0); + saved_r = total_r; + saved_g = total_g; + Minify(2*x + 11, 15.0); + Minify(2*x + 12, 7.0); + Minify(2*x + 18, 7.0); + Minify(2*x + 19, 15.0); + Minify(2*x + 20, 15.0); + Minify(2*x + 21, 7.0); + q[x].r = (unsigned char)(total_r/128.0 + 0.5); + q[x].g = (unsigned char)(total_g/128.0 + 0.5); + q[x].b = (unsigned char)(total_b/128.0 + 0.5); + fprintf(stderr, "r:%f g:%f b:%f\n", saved_r, saved_g, saved_b); + } + for (x = 0; x < COLS; x++) { + if (answers[x] != q[x].b) + abort(); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44674.c b/SingleSource/Regression/C/gcc-dg/pr44674.c new file mode 100644 index 0000000000..c71b49ea5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44674.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fprofile-generate" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +void +jumpfunc (void *p) +{ + void *l = &&jumplabel; +jumplabel: + __builtin_memcpy (p, l, 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44699.c b/SingleSource/Regression/C/gcc-dg/pr44699.c new file mode 100644 index 0000000000..bd2b1a87aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44699.c @@ -0,0 +1,158 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +typedef long unsigned int size_t; +typedef long int intmax_t; +typedef long unsigned int uintmax_t; +extern void *xmalloc (size_t) __attribute__ ((__malloc__)); +extern const char *trim_filename (const char *); +extern void error (const char *, ...); + +static __inline void * +__inline_memcpy_chk (void *__dest, const void *__src, size_t __len) +{ + return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0)); +} + +typedef unsigned int hashval_t; +typedef hashval_t (*htab_hash) (const void *); +typedef int (*htab_eq) (const void *, const void *); +typedef void (*htab_del) (void *); +typedef int (*htab_trav) (void **, void *); +typedef void *(*htab_alloc) (size_t, size_t); +typedef void (*htab_free) (void *); + +typedef void *(*htab_alloc_with_arg) (void *, size_t, size_t); +typedef void (*htab_free_with_arg) (void *, void *); +struct htab { + htab_hash hash_f; + htab_eq eq_f; + htab_del del_f; + void ** entries; + size_t size; + size_t n_elements; + size_t n_deleted; + unsigned int searches; + unsigned int collisions; + htab_alloc alloc_f; + htab_free free_f; + void * alloc_arg; + htab_alloc_with_arg alloc_with_arg_f; + htab_free_with_arg free_with_arg_f; + unsigned int size_prime_index; +}; + +typedef struct htab *htab_t; +enum insert_option {NO_INSERT, INSERT}; +extern void * htab_find (htab_t, const void *); +extern void ** htab_find_slot (htab_t, const void *, enum insert_option); + +enum mode_class { MODE_RANDOM, MODE_CC, MODE_INT, MODE_PARTIAL_INT, MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM, MODE_FLOAT, MODE_DECIMAL_FLOAT, MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MODE_VECTOR_INT, MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM, MODE_VECTOR_UACCUM, MODE_VECTOR_FLOAT, MAX_MODE_CLASS }; + +static const char *const mode_class_names[MAX_MODE_CLASS] = +{ + "MODE_RANDOM", "MODE_CC", "MODE_INT", "MODE_PARTIAL_INT", "MODE_FRACT", "MODE_UFRACT", "MODE_ACCUM", "MODE_UACCUM", "MODE_FLOAT", "MODE_DECIMAL_FLOAT", "MODE_COMPLEX_INT", "MODE_COMPLEX_FLOAT", "MODE_VECTOR_INT", "MODE_VECTOR_FRACT", "MODE_VECTOR_UFRACT", "MODE_VECTOR_ACCUM", "MODE_VECTOR_UACCUM", "MODE_VECTOR_FLOAT" +}; +struct mode_data +{ + struct mode_data *next; + + const char *name; + enum mode_class cl; + unsigned int precision; + unsigned int bytesize; + unsigned int ncomponents; + unsigned int alignment; + const char *format; + + struct mode_data *component; + struct mode_data *wider; + struct mode_data *wider_2x; + + struct mode_data *contained; + + struct mode_data *next_cont; + + const char *file; + unsigned int line; + unsigned int counter; + unsigned int ibit; + unsigned int fbit; +}; + +static struct mode_data *modes[MAX_MODE_CLASS]; +static unsigned int n_modes[MAX_MODE_CLASS]; +static struct mode_data *void_mode; + +static const struct mode_data blank_mode = { + 0, "", MAX_MODE_CLASS, + -1U, -1U, -1U, -1U, + 0, 0, 0, 0, 0, 0, + "", 0, 0, 0, 0 +}; + +static htab_t modes_by_name; + +static __inline__ struct mode_data * +find_mode (const char *name) +{ + struct mode_data key; + + key.name = name; + return (struct mode_data *) htab_find (modes_by_name, &key); +} + +static struct mode_data * +new_mode (enum mode_class cl, const char *name, + const char *file, unsigned int line) +{ + struct mode_data *m; + static unsigned int count = 0; + + m = find_mode (name); + if (m) + { + error ("%s:%d: duplicate definition of mode \"%s\"", + trim_filename (file), line, name); + error ("%s:%d: previous definition here", m->file, m->line); + return m; + } + + m = ((struct mode_data *) xmalloc (sizeof (struct mode_data))); + ((__builtin_object_size (m, 0) != (size_t) -1) ? __builtin___memcpy_chk (m, &blank_mode, sizeof (struct mode_data), __builtin_object_size (m, 0)) : __inline_memcpy_chk (m, &blank_mode, sizeof (struct mode_data))); + m->cl = cl; + m->name = name; + if (file) + m->file = trim_filename (file); + m->line = line; + m->counter = count++; + + m->next = modes[cl]; + modes[cl] = m; + n_modes[cl]++; + + *htab_find_slot (modes_by_name, m, INSERT) = m; + + return m; +} + +static void +make_int_mode (const char *name, + unsigned int precision, unsigned int bytesize, + const char *file, unsigned int line) +{ + struct mode_data *m = new_mode (MODE_INT, name, file, line); + m->bytesize = bytesize; + m->precision = precision; +} + +static void +create_modes (void) +{ +make_int_mode ("HI", -1U, 2, "../../work/gcc/machmode.def", 182); +} + +int +main (int argc, char **argv) +{ + create_modes (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44838.c b/SingleSource/Regression/C/gcc-dg/pr44838.c new file mode 100644 index 0000000000..61608ed0b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44838.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/44838 */ +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-loops" } */ + +extern void abort (); + +void +foo (int *a, int n) +{ + int *lasta = a + n; + for (; a != lasta; a++) + { + *a *= 2; + a[1] = a[-1] + a[-2]; + } +} + +int a[16]; +int ref[16] = { 0, 1, 4, 2, 10, 12, 24, 44, + 72, 136, 232, 416, 736, 1296, 2304, 2032 }; + +int +main () +{ + int i; + for (i = 0; i < 16; i++) + a[i] = i; + foo (a + 2, 16 - 3); + for (i = 0; i < 16; i++) + if (ref[i] != a[i]) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44964.c b/SingleSource/Regression/C/gcc-dg/pr44964.c new file mode 100644 index 0000000000..6c252ee261 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44964.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fkeep-inline-functions -O" } */ + +static inline __attribute__ ((const)) +int baz (int i) +{ + return i; +} + +static __attribute__ ((always_inline)) +inline __attribute__ ((flatten)) +void bar (void) +{ + baz (0); +} + +void +foo (void) +{ + bar (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr44971.c b/SingleSource/Regression/C/gcc-dg/pr44971.c new file mode 100644 index 0000000000..a1faef51be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44971.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug -w" } */ + +typedef struct +{ + int default_screen; +} *_XPrivint; +typedef int FcBool; +typedef struct +{ + struct _XftintInfo *next; +} XftintInfo; +int _XftintInfo; + +void _XftintInfoGet (int * dpy, FcBool createIfNecessary) +{ + int event_base; + &event_base + && dpy[createIfNecessary] != 0; +} + +void _XftCloseint (int dpy, XftintInfo * info,XftintInfo * *prev) +{ + _XftintInfoGet (dpy, 0); + for (prev = &_XftintInfo; info = *prev; prev = &(*prev)->next) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr44974.c b/SingleSource/Regression/C/gcc-dg/pr44974.c new file mode 100644 index 0000000000..a16c558331 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr44974.c @@ -0,0 +1,23 @@ +/* PR middle-end/44974 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-optimize-sibling-calls" } */ + +extern void foo (int status) __attribute__ ((__noreturn__,__noinline__)); +extern void bar (int status) __attribute__ ((__noreturn__,__noinline__)); +extern void _Exit (int status) __attribute__ ((__noreturn__,__noinline__)); + +void +foo (int status) +{ + _Exit (status); +} + +void +_Exit (int status) +{ + bar (status); +} + +/* { dg-final { scan-assembler "call\[^\n\]*_Exit" { target i?86-*-* x86_64-*-* ia64-*-* sparc*-*-* } } } */ +/* { dg-final { scan-assembler "bl\[^\n\]*_Exit" { target powerpc*-*-* } } } */ +/* { dg-final { scan-assembler "brasl\[^\n\]*_Exit" { target { s390*-*-* && lp64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr45055.c b/SingleSource/Regression/C/gcc-dg/pr45055.c new file mode 100644 index 0000000000..899de50498 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45055.c @@ -0,0 +1,42 @@ +/* PR debug/45055 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftracer -fsched-pressure -funroll-loops -fschedule-insns -fcompare-debug" } */ +/* { dg-require-effective-target scheduling } */ + +int colormap[10]; + +extern int bar (); + +void +foo (int *img, int fp, int y, int *ptr, int depth, int c, int t, int xm) +{ + int x, color, count; + for (; y; y--) + { + if (depth) + { + count = bar (); + for (x = xm; x; x--) + { + if (c != 1) + count = color = -1; + if (count == 0) + color = count = bar (); + if (color) + t = bar (fp); + *ptr++ = colormap[t]; + } + } + switch (*img) + { + case 1: + bar (); + case 3: + case -1: + case -3: + bar (); + case -4: + bar (); + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45071.c b/SingleSource/Regression/C/gcc-dg/pr45071.c new file mode 100644 index 0000000000..d1715db1b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45071.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-vrp -ftree-vectorize" } */ + +struct A +{ + int i; +}; + +struct B +{ + struct A a; +}; + +extern void f4 (void *); + +inline void +f3 (struct A *a) +{ + f4 (a); + while (a->i); +} + +static inline void +f2 (struct B *b) +{ + f3 (&b->a); +} + +void +f1 () +{ + struct B *b = 0; + f2 (b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45079.c b/SingleSource/Regression/C/gcc-dg/pr45079.c new file mode 100644 index 0000000000..1ef02ff78f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45079.c @@ -0,0 +1,10 @@ +/* PR c/45079 */ +/* { dg-do compile } */ + +void +foo (const char *p, int cond, int a, int b) +{ + p[cond ? a : b] = '\0'; /* { dg-error "assignment of read-only location" } */ +} + +/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr45083.c b/SingleSource/Regression/C/gcc-dg/pr45083.c new file mode 100644 index 0000000000..c9a4dbfe19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45083.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/45083 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +struct S { char *a; unsigned b; unsigned c; }; +extern int foo (const char *); +extern void bar (int, int); + +static void +baz (void) +{ + struct S cs[1]; /* { dg-message "was declared here" } */ + switch (cs->b) /* { dg-warning "cs\[^\n\r\]*\\.b\[^\n\r\]*is used uninitialized" } */ + { + case 101: + if (foo (cs->a)) /* { dg-warning "cs\[^\n\r\]*\\.a\[^\n\r\]*may be used uninitialized" } */ + bar (cs->c, cs->b); /* { dg-warning "cs\[^\n\r\]*\\.c\[^\n\r\]*may be used uninitialized" } */ + } +} + +void +test (void) +{ + baz (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45101.c b/SingleSource/Regression/C/gcc-dg/pr45101.c new file mode 100644 index 0000000000..d9615725a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45101.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/45101 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgcse -fgcse-las" } */ + +struct +{ + int i; +} *s; + +extern void bar (void); + +void foo () +{ + !s ? s->i++ : bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45105.c b/SingleSource/Regression/C/gcc-dg/pr45105.c new file mode 100644 index 0000000000..a93a21f9ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45105.c @@ -0,0 +1,27 @@ +/* PR debug/45105 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fcompare-debug" } */ + +extern int *baz (int *, int *); + +void +bar (int *p1, int *p2) +{ + int n = *baz (0, 0); + p1[n] = p2[n]; +} + +void +foo (int *p, int l) +{ + int a1[32]; + int a2[32]; + baz (a1, a2); + while (l) + { + if (l & 1) + p = baz (a2, p); + l--; + bar (a1, a2); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45107.c b/SingleSource/Regression/C/gcc-dg/pr45107.c new file mode 100644 index 0000000000..05dbec3217 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45107.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/45107 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fgcse-las" } */ + +extern void bar(int *); + +int foo (int *p) +{ + int i = *p; + if (i != 1) + bar(&i); + *p = i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45259.c b/SingleSource/Regression/C/gcc-dg/pr45259.c new file mode 100644 index 0000000000..7a051af811 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45259.c @@ -0,0 +1,45 @@ +/* PR debug/45259 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -w -fpic" { target fpic } } */ +/* { dg-options "-g -O2 -w" { target { ! fpic } } } */ +/* { dg-require-effective-target indirect_jumps } */ +/* { dg-require-effective-target label_values } */ + +struct S { void (*bar) (long); }; +struct T { struct S *t; }; +int w; +extern int baz (int); + +void +foo (int x, int u, char *z) +{ + struct T *v; + static void *y[256] = { &&l1, &&l2 }; + for (;;) + switch (x) + { + l2: + x = 9; + case 9: + goto *y[*z++]; + case 10: + case 27: + case 54: + case 99: + case 100: + case 120: + case 122: + case 131: + case 132: + case 134: + case 141: + case 142: + v->t->bar (u); + v->t->bar (u); + case 143: + continue; + l1: + default: + baz (w); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45352-1.c b/SingleSource/Regression/C/gcc-dg/pr45352-1.c new file mode 100644 index 0000000000..ea8d047255 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45352-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O3 -fschedule-insns -fschedule-insns2 -fselective-scheduling2 -fsel-sched-pipelining -funroll-loops -fprefetch-loop-arrays" } */ +/* { dg-additional-options "-march=i686 -msse" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +void main1 (float *pa, float *pc) +{ + int i; + float b[256]; + float c[256]; + for (i = 0; i < 256; i++) + b[i] = c[i] = pc[i]; + for (i = 0; i < 256; i++) + pa[i] = b[i] * c[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45352-2.c b/SingleSource/Regression/C/gcc-dg/pr45352-2.c new file mode 100644 index 0000000000..e81ed30f03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45352-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O1 -freorder-blocks -fschedule-insns2 -funswitch-loops -fselective-scheduling2 -fsel-sched-pipelining -funroll-all-loops" } */ +void +foo1 (int *s) +{ + s[0] = s[1]; + while (s[6] - s[8]) + { + s[6] -= s[8]; + if (s[8] || s[0]) + { + s[3] += s[0]; + s[4] += s[1]; + } + s[7]++; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45352-3.c b/SingleSource/Regression/C/gcc-dg/pr45352-3.c new file mode 100644 index 0000000000..c642a70855 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45352-3.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -fprofile-generate -fgcse -fno-gcse-lm -fgcse-sm -fno-ivopts -fno-tree-loop-im -ftree-pre -funroll-loops -fno-web -fschedule-insns2 -fselective-scheduling2 -fsel-sched-pipelining" } */ + +extern volatile float f[]; + +void foo (void) +{ + int i; + for (i = 0; i < 100; i++) + f[i] = 0; + for (i = 0; i < 100; i++) + f[i] = 0; + for (i = 0; i < 100; i++) + if (f[i]) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45352.c b/SingleSource/Regression/C/gcc-dg/pr45352.c new file mode 100644 index 0000000000..7aeac0da37 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45352.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fselective-scheduling2 -fsel-sched-pipelining -fprofile-generate" } */ + +static inline void +bmp_iter_next (int *bi, int *bit_no) +{ + *bi >>= 1; + *bit_no += 1; +} + +int bmp_iter_set (int *bi, int *bit_no); +void bitmap_initialize_stat (int, ...); +void bitmap_clear (void); + +void +df_md_alloc (int bi, int bb_index, void *bb_info) +{ + for (; bmp_iter_set (&bi, &bb_index); bmp_iter_next (&bi, &bb_index)) + + if (bb_info) + bitmap_clear (); + else + bitmap_initialize_stat (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45353.c b/SingleSource/Regression/C/gcc-dg/pr45353.c new file mode 100644 index 0000000000..0d704f8d16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45353.c @@ -0,0 +1,10 @@ +/* PR rtl-optimization/45353 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fschedule-insns -fselective-scheduling" } */ +/* { dg-require-effective-target scheduling } */ + +void +foo () +{ + __builtin_unreachable (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45415.c b/SingleSource/Regression/C/gcc-dg/pr45415.c new file mode 100644 index 0000000000..9574b3a05d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45415.c @@ -0,0 +1,69 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-dominator-opts" } */ + +typedef unsigned long int st; +typedef unsigned long long dt; +typedef union +{ + dt d; + struct + { + st h, l; + } + s; +} t_be; + +typedef union +{ + dt d; + struct + { + st l, h; + } + s; +} t_le; + +#define df(f, t) \ +int \ +f (t afh, t bfh) \ +{ \ + t hh; \ + t hp, lp, dp, m; \ + st ad, bd; \ + int s; \ + s = 0; \ + ad = afh.s.h - afh.s.l; \ + bd = bfh.s.l - bfh.s.h; \ + if (bd > bfh.s.l) \ + { \ + bd = -bd; \ + s = ~s; \ + } \ + lp.d = (dt) afh.s.l * bfh.s.l; \ + hp.d = (dt) afh.s.h * bfh.s.h; \ + dp.d = (dt) ad *bd; \ + dp.d ^= s; \ + hh.d = hp.d + hp.s.h + lp.s.h + dp.s.h; \ + m.d = (dt) lp.s.h + hp.s.l + lp.s.l + dp.s.l; \ + return hh.s.l + m.s.l; \ +} + +df(f_le, t_le) +df(f_be, t_be) + +void abort (void); +void exit (int); +int +main () +{ + t_be x; + x.s.h = 0x10000000U; + x.s.l = 0xe0000000U; + if (x.d == 0x10000000e0000000ULL + && f_be ((t_be) 0x100000000ULL, (t_be) 0x100000000ULL) != -1) + abort (); + if (x.d == 0xe000000010000000ULL + && f_le ((t_le) 0x100000000ULL, (t_le) 0x100000000ULL) != -1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45416.c b/SingleSource/Regression/C/gcc-dg/pr45416.c new file mode 100644 index 0000000000..a3f6a759d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45416.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-skip-if "Skip for Thumb1." { { arm*-*-* } && { arm_thumb1_ok } } } */ +/* { dg-options "-O2" } */ + +int foo(long long a) +{ + if (a & (long long) 0x400) + return 1; + return 0; +} + +/* { dg-final { scan-assembler "andl|bextr" { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } " */ +/* { dg-final { scan-assembler-not "setne" { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } }" */ +/* { dg-final { scan-assembler "and|ubfx" { target arm*-*-* } } } */ +/* { dg-final { scan-assembler-not "moveq" { target arm*-*-* } } }" */ diff --git a/SingleSource/Regression/C/gcc-dg/pr45449.c b/SingleSource/Regression/C/gcc-dg/pr45449.c new file mode 100644 index 0000000000..d7b69a1827 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45449.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-pre -fno-tree-pta -fcompare-debug" } */ + +struct S +{ +}; + +void +baz (void) +{ + struct S s; + &s; +} + +int bar (void); + +void +foo (void) +{ + if (bar ()) + baz (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45461.c b/SingleSource/Regression/C/gcc-dg/pr45461.c new file mode 100644 index 0000000000..db86d86ae5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45461.c @@ -0,0 +1,20 @@ +/* PR middle-end/45461 */ +/* { dg-do compile } */ + +#include + +int +foo (int i, ...) +{ + short e; + va_list ap; + va_start (ap, i); + + e = va_arg (ap, short); /* { dg-warning "is promoted" "promoted" } */ + /* { dg-message "note: \\(so you should pass" "should pass" {target *-*-* } .-1 } */ + /* { dg-message "note: if this code" "if this code" {target *-*-* } .-2 } */ + + va_end (ap); + return e; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr45472.c b/SingleSource/Regression/C/gcc-dg/pr45472.c new file mode 100644 index 0000000000..6cbc392a50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45472.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -fschedule-insns2 -fselective-scheduling2" } */ + +struct S +{ + volatile long vl; + int i; +}; +struct S s1, s2; + +void +foo (int j, int c) +{ + int i; + for (i = 0; i <= j; i++) + { + if (c) + s2.vl += s1.vl; + s1 = s2; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45506.c b/SingleSource/Regression/C/gcc-dg/pr45506.c new file mode 100644 index 0000000000..e934dc93cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45506.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-g -O -w" } */ + +typedef unsigned _GCC_ATTR_ALIGN_u32t; +typedef _GCC_ATTR_ALIGN_u32t _Uint32t __attribute__((__aligned__(4))); +typedef int _Intptrt __attribute__((__mode__(__pointer__))); +typedef unsigned int _Uintptrt __attribute__((__mode__(__pointer__))); +typedef _Intptrt ptrdiff_t; +typedef _Uintptrt uintptr_t; +typedef _Uint32t Elf32_Word; +typedef struct list_head list_head_t; + +struct list_head { + list_head_t *next; +}; + +struct object { }; + +struct objlist { + struct object *object; +}; + +static uintptr_t ldd(void *frame) __attribute__((__used__)); +static list_head_t *_dl_all_objects_ptr; +static void fini_array(struct object *const obj) { + if ((dynvec(obj,(unsigned)26)) != ((Elf32_Word)-1)) { + unsigned i; + const unsigned funcs = (dynvec(obj,(unsigned)28)) / 4; + const Elf32_Word fa = (dynvec(obj,(unsigned)26)); + const int *const p = relative_relocp(obj); + for (i = (funcs ? (funcs - 1) : 0U); i != 0U; i--) { + void (*const func)(void) = (void *) p[i]; + (*func)(); + } + } +} +static void _do_exit_fini(void) { + const struct objlist *o; + for (((o)) = ((void *)(((list_head_t *)(_dl_all_objects_ptr))->next)); + !((((o))) == ((void *)((list_head_t *)(_dl_all_objects_ptr)))); + ((o)) = ((void *)(((list_head_t *)((o)))->next))) + fini_array (o->object); +} +static uintptr_t ldd (void *frame) { + atexit(_do_exit_fini); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45567.c b/SingleSource/Regression/C/gcc-dg/pr45567.c new file mode 100644 index 0000000000..5bf4644077 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45567.c @@ -0,0 +1,9 @@ +/* PR middle-end/45567 */ +/* { dg-do compile } */ +/* { dg-options "-ftree-ter" } */ + +unsigned +foo (char c) +{ + return __builtin_popcountl ((unsigned long) c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45570.c b/SingleSource/Regression/C/gcc-dg/pr45570.c new file mode 100644 index 0000000000..8a25951fcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45570.c @@ -0,0 +1,28 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O3 -fselective-scheduling2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -ftracer" } */ +void +parser_get_next_char (char c, int qm, char *p) +{ + int quote_mode = 0; + for (; *p; p++) + { + if (qm) + { + if (quote_mode == 0 && *p == '"' && *(p - 1)) + { + quote_mode = 1; + continue; + } + if (quote_mode && *p == '"' && *(p - 1)) + quote_mode = 0; + } + if (quote_mode == 0 && *p == c && *(p - 1)) + break; + } +} + +void +parser_get_next_parameter (char *p) +{ + parser_get_next_char (':', 1, p); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45652.c b/SingleSource/Regression/C/gcc-dg/pr45652.c new file mode 100644 index 0000000000..74e284ca4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45652.c @@ -0,0 +1,39 @@ +/* { dg-do run { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling2" } */ + +struct S { + double i[2]; +}; + +void __attribute__ ((noinline)) checkcd (struct S x) +{ + if (x.i[0] != 7.0 || x.i[1] != 8.0) + __builtin_abort (); +} + +void __attribute__ ((noinline)) testvacd (int n, ...) +{ + int i; + __builtin_va_list ap; + __builtin_va_start (ap, n); + for (i = 0; i < n; i++) + { + struct S t = __builtin_va_arg (ap, struct S); + checkcd (t); + } + __builtin_va_end (ap); +} + +void +testitcd (void) +{ + struct S x = { { 7.0, 8.0 } }; + testvacd (2, x, x); +} + +int +main () +{ + testitcd (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45733.c b/SingleSource/Regression/C/gcc-dg/pr45733.c new file mode 100644 index 0000000000..5c83cd42ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45733.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fstrict-overflow -ftree-vectorize" } */ + +typedef __INTPTR_TYPE__ intptr_t; + +intptr_t +foo (void **p, int i) +{ + intptr_t x = 0; + while (i--) + x ^= (intptr_t) p[i]; + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45750.c b/SingleSource/Regression/C/gcc-dg/pr45750.c new file mode 100644 index 0000000000..0359c61c6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45750.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +struct S +{ + int i; +}; + +int invalid[] = 0; /* { dg-error "invalid initializer" } */ + +void foo (void) +{ + if (((struct S *)undeclared)->i); /* { dg-error "undeclared" } */ + /* { dg-message "reported only once" "" { target *-*-* } .-1 } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr45819.c b/SingleSource/Regression/C/gcc-dg/pr45819.c new file mode 100644 index 0000000000..fb59359a70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45819.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized -w" } */ + +struct ehci_regs { + char x; + unsigned int port_status[0]; +} __attribute__ ((packed)); + +struct ehci_hcd { + struct ehci_regs *regs; +}; + +int ehci_hub_control (struct ehci_hcd *ehci, int wIndex) +{ + unsigned int *status_reg = &ehci->regs->port_status[wIndex]; + return *(volatile unsigned int *)status_reg; +} + +/* { dg-final { scan-tree-dump "={v}" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr45865.c b/SingleSource/Regression/C/gcc-dg/pr45865.c new file mode 100644 index 0000000000..6edea31471 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45865.c @@ -0,0 +1,28 @@ +/* PR rtl-optimization/45865 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +typedef union tree_node *tree; +enum ix86_builtin_type { + IX86_BT_LAST_VECT, + IX86_BT_LAST_PTR +}; +extern const enum ix86_builtin_type ix86_builtin_type_ptr_base[]; +extern tree build_qualified_type (tree, int); +extern tree build_pointer_type (tree); +tree +ix86_get_builtin_type (enum ix86_builtin_type tcode, unsigned int index) +{ + tree type, itype; + int quals; + if (tcode <= IX86_BT_LAST_PTR) + quals = 0x0; + else + quals = 0x1; + itype = ix86_get_builtin_type (ix86_builtin_type_ptr_base[index], + index); + if (quals != 0x0) + itype = build_qualified_type (itype, quals); + type = build_pointer_type (itype); + return type; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr45991.c b/SingleSource/Regression/C/gcc-dg/pr45991.c new file mode 100644 index 0000000000..eefce4429e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr45991.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fstrict-overflow" } */ + +struct S +{ + int i; +}; + +char A[64]; + +void foo (char **dst, int i) +{ + char *p = A + 16; + while (i--) + { + int b = ((struct S *) (&p[i * 16 + 4]))->i; + char *c = A + i * 16; + dst[i] = c + b; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46088.c b/SingleSource/Regression/C/gcc-dg/pr46088.c new file mode 100644 index 0000000000..c0ff920eea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46088.c @@ -0,0 +1,12 @@ +/* PR target/46088 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fnon-call-exceptions -fpeel-loops" } */ + +extern void bar (void); + +void +foo (int i) +{ + if (i >> 3) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46130-1.c b/SingleSource/Regression/C/gcc-dg/pr46130-1.c new file mode 100644 index 0000000000..a0a582d278 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46130-1.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/46130 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce" } */ + +#include + +static void +foo (va_list ap) +{ + va_arg (ap, char *)[0]; +} + +void +bar (va_list ap) +{ + foo (ap); +} + +void +baz (va_list ap) +{ + foo (ap); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46130-2.c b/SingleSource/Regression/C/gcc-dg/pr46130-2.c new file mode 100644 index 0000000000..991e5dd183 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46130-2.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/46130 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce" } */ + +extern int bar (int); + +static int foo (int x) +{ + int z, w; + if (x <= 1024) + { + z = 16; + w = 17; + } + else + { + bar (bar (bar (bar (bar (bar (bar (bar (bar (16))))))))); + if (x > 131072) + w = 19; + else + w = 21; + z = 32; + } + w = w + 121; + return z; +} + +int +baz (int x) +{ + return foo (x + 6) + foo (x + 15) + foo (x + 24); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46165.c b/SingleSource/Regression/C/gcc-dg/pr46165.c new file mode 100644 index 0000000000..a13300e7ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46165.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/46165 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-copy-prop -fno-tree-dce" } */ + +extern void foo (void) __attribute__((noreturn)); +void +g (void) +{ + void (*f) (void) = foo; + f (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46171.c b/SingleSource/Regression/C/gcc-dg/pr46171.c new file mode 100644 index 0000000000..f43cab025b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46171.c @@ -0,0 +1,13 @@ +/* PR debug/46171 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-dce -g" } */ + +double bard (); +float barf (float); + +void +foo (float f) +{ + f = barf (f); + double d = bard (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46177-2.c b/SingleSource/Regression/C/gcc-dg/pr46177-2.c new file mode 100644 index 0000000000..91fd20e755 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46177-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-copy-prop -ftree-loop-distribution" } */ + +int A[30], B[30]; + +void +foo (int j) +{ + int i, k; + for (k = 0; k < 10; k++) + if (j) + { + for (; j < k; j++) + ; + for (i = 0; i < k; i++) + A[i] = B[i] = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46177.c b/SingleSource/Regression/C/gcc-dg/pr46177.c new file mode 100644 index 0000000000..397e316340 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46177.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-copy-prop -ftree-loop-distribution" } */ + +extern int A[]; +extern int B[]; + +void +foo (int j, int c) +{ + int i; + + if (c) + for (i = 0; i < j; i++) + A[i] = B[i] = 0; + + for (i = 0; i < j; i++) + A[i] = B[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46184.c b/SingleSource/Regression/C/gcc-dg/pr46184.c new file mode 100644 index 0000000000..fafa7f463d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46184.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-vectorize -fno-tree-copy-prop -fno-tree-dce" } */ + +extern int A[], B[]; + +void +foo (int z) +{ + int j, i; + for (j = 0; j < 32; j++) + { + int curr_a = A[0]; + for (i = 0; i < 16; i++) + curr_a = A[i] ? curr_a : z; + B[j] = curr_a; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr46212.c b/SingleSource/Regression/C/gcc-dg/pr46212.c new file mode 100644 index 0000000000..a549a99050 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46212.c @@ -0,0 +1,24 @@ +/* PR rtl-optimization/46212 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -funroll-loops" } */ +/* { dg-options "-O3 -funroll-loops -march=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-require-effective-target int32plus } */ + +static inline unsigned +foo (void *x) +{ + unsigned y = *(volatile unsigned *) (x); + return (y >> 24) | ((y >> 8) & 0xff00) | ((y & 0xff00) << 8) | (y << 24); +} + +void +bar (void *x, void *y, int z) +{ + unsigned c; + while (z--) + { + c = foo (y); + *(unsigned *) x = (c & 0xf80000) >> 9 | (c & 0xf800) >> 6 + | (c & 0xf8) >> 3 | (c & 0x80000000) >> 16; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46217.c b/SingleSource/Regression/C/gcc-dg/pr46217.c new file mode 100644 index 0000000000..73a8780bd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46217.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ + +int foo(int a) +{ + int t; + *(volatile int *)&t = a; +} + +/* { dg-final { scan-tree-dump "={v}" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr46233.c b/SingleSource/Regression/C/gcc-dg/pr46233.c new file mode 100644 index 0000000000..8916e4bdd3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46233.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/46233 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-dce" } */ + +int +foo () +{ + int i = 0; + while (1) + i += foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46251.c b/SingleSource/Regression/C/gcc-dg/pr46251.c new file mode 100644 index 0000000000..0eeb29fda9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46251.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-ffast-math" } */ + +void foo (long double *x) +{ + __builtin_sincosl (*x, x, x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46252.c b/SingleSource/Regression/C/gcc-dg/pr46252.c new file mode 100644 index 0000000000..6df4f2cb85 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46252.c @@ -0,0 +1,17 @@ +/* PR debug/46252 */ +/* { dg-do compile } */ +/* { dg-options "-O -frerun-cse-after-loop -fno-tree-loop-optimize -funroll-loops -fcompare-debug" } */ + +void bar (void); + +void +foo (float *f) +{ + int i; + for (i = 0; i < 4; i++) + f[i] = i; + bar (); + for (i = 0; i < 4; i++) + if (f[i] != i) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46255.c b/SingleSource/Regression/C/gcc-dg/pr46255.c new file mode 100644 index 0000000000..3a1639085d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46255.c @@ -0,0 +1,13 @@ +/* PR debug/46255 */ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-fcompare-debug -fprofile-generate -O" } */ + +int bar (void); + +void +foo (int i) +{ + while (i) + i = bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46288.c b/SingleSource/Regression/C/gcc-dg/pr46288.c new file mode 100644 index 0000000000..24c8874fe0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46288.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-dce" } */ + +void foo (int i) +{ + __builtin_expect (i, i); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr46307.c b/SingleSource/Regression/C/gcc-dg/pr46307.c new file mode 100644 index 0000000000..c308b5669f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46307.c @@ -0,0 +1,14 @@ +/* PR debug/46307 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +double fma (double, double, double); + +double +foo (double x, double y, double z) +{ + double a = x * y + z; + double b = __builtin_fma (x, y, z); + double c = fma (x, y, z); + return x / y / z; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46309-2.c b/SingleSource/Regression/C/gcc-dg/pr46309-2.c new file mode 100644 index 0000000000..2903fff225 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46309-2.c @@ -0,0 +1,145 @@ +/* PR tree-optimization/46309 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-ipa-icf -fno-jump-tables -fno-bit-tests -fdump-tree-reassoc-details" } */ + +int foo (void); + +void +f1 (int a) +{ + _Bool v1 = (a == 3); + _Bool v2 = (a == 1); + _Bool v3 = (a == 4); + _Bool v4 = (a == 2); + if (v1 || v2 || v3 || v4) + foo (); +} + +void +f2 (int a) +{ + _Bool v1 = (a == 1); + _Bool v2 = (a == 2); + _Bool v3 = (a == 3); + _Bool v4 = (a == 4); + if (v1 || v2 || v3 || v4) + foo (); +} + +void +f3 (unsigned int a) +{ + _Bool v1 = (a <= 31); + _Bool v2 = (a >= 64 && a <= 95); + _Bool v3 = (a >= 128 && a <= 159); + _Bool v4 = (a >= 192 && a <= 223); + if (v1 || v2 || v3 || v4) + foo (); +} + +void +f4 (int a) +{ + _Bool v1 = (a == 3); + _Bool v2 = (a == 1); + _Bool v3 = (a == 4); + _Bool v4 = (a == 2); + _Bool v5 = (a == 7); + _Bool v6 = (a == 5); + _Bool v7 = (a == 8); + _Bool v8 = (a == 6); + if (v1 || v2 || v3 || v4 || v5 || v6 || v7 || v8) + foo (); +} + +void +f5 (int a) +{ + _Bool v1 = (a != 3); + _Bool v2 = (a != 1); + _Bool v3 = (a != 4); + _Bool v4 = (a != 2); + _Bool v5 = (a != 7); + _Bool v6 = (a != 5); + _Bool v7 = (a != 8); + _Bool v8 = (a != 6); + if (v1 && v2 && v3 && v4 && v5 && v6 && v7 && v8) + foo (); +} + +void +f6 (int a) +{ + _Bool v1 = (a != 3); + _Bool v2 = (a != 1); + _Bool v3 = (a != 4); + _Bool v4 = (a != 2); + _Bool v5 = (a != 7); + _Bool v6 = (a != 5); + _Bool v7 = (a != 8); + _Bool v8 = (a != 6); + if ((v1 && v2 && v3 && v4) && (v5 && v6 && v7 && v8)) + foo (); +} + +int +f7 (int a) +{ + _Bool v1 = (a == 3); + _Bool v2 = (a == 1); + _Bool v3 = (a == 4); + _Bool v4 = (a == 2); + _Bool v5 = (a == 7); + _Bool v6 = (a == 5); + _Bool v7 = (a == 8); + _Bool v8 = (a == 6); + return v1 || v2 || v3 || v4 || v5 || v6 || v7 || v8; +} + +_Bool +f8 (int a) +{ + _Bool v1 = (a == 3); + _Bool v2 = (a == 1); + _Bool v3 = (a == 4); + _Bool v4 = (a == 2); + _Bool v5 = (a == 7); + _Bool v6 = (a == 5); + _Bool v7 = (a == 8); + _Bool v8 = (a == 6); + return v1 || v2 || v3 || v4 || v5 || v6 || v7 || v8; +} + +int +f9 (int a) +{ + _Bool v1 = (a != 3); + _Bool v2 = (a != 1); + _Bool v3 = (a != 4); + _Bool v4 = (a != 2); + _Bool v5 = (a != 7); + _Bool v6 = (a != 5); + _Bool v7 = (a != 8); + _Bool v8 = (a != 6); + return v1 && v2 && v3 && v4 && v5 && v6 && v7 && v8; +} + +_Bool +f10 (int a) +{ + _Bool v1 = (a != 3); + _Bool v2 = (a != 1); + _Bool v3 = (a != 4); + _Bool v4 = (a != 2); + _Bool v5 = (a != 7); + _Bool v6 = (a != 5); + _Bool v7 = (a != 8); + _Bool v8 = (a != 6); + return v1 && v2 && v3 && v4 && v5 && v6 && v7 && v8; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2. and -.3, 3. and -.4, 4.\[\n\r\]* into" 2 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.0, 31. and -.64, 95.\[\n\r\]* into" 1 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.128, 159. and -.192, 223.\[\n\r\]* into" 1 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2. and -.3, 3. and -.4, 4. and -.5, 5. and -.6, 6. and -.7, 7. and -.8, 8.\[\n\r\]* into" 7 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[^\r\n\]*_\[0-9\]* -.0, 0. and -.128, 128.\[\n\r\]* into" 1 "reassoc2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr46309.c b/SingleSource/Regression/C/gcc-dg/pr46309.c new file mode 100644 index 0000000000..615d6574ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46309.c @@ -0,0 +1,64 @@ +/* PR tree-optimization/46309 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-reassoc-details --param logical-op-non-short-circuit=1" } */ + +int +f1 (int a) +{ + int v1 = (a == 3); + int v2 = (a == 1); + int v3 = (a == 4); + int v4 = (a == 2); + return v1 || v2 || v3 || v4; +} + +int +f2 (int a) +{ + int v1 = (a == 1); + int v2 = (a == 2); + int v3 = (a == 3); + int v4 = (a == 4); + return v1 || v2 || v3 || v4; +} + +int +f3 (int a) +{ + int v1 = (a == 3); + int v2 = (a == 1); + return v1 || v2; +} + +int +f4 (int a) +{ + int v1 = (a == 1); + int v2 = (a == 2); + return v1 || v2; +} + +int +f5 (unsigned int a) +{ + int v1 = (a <= 31); + int v2 = (a >= 64 && a <= 95); + return v1 || v2; +} + +int +f6 (unsigned int a) +{ + int v1 = (a <= 31); + int v2 = (a >= 64 && a <= 95); + int v3 = (a >= 128 && a <= 159); + int v4 = (a >= 192 && a <= 223); + return v1 || v2 || v3 || v4; +} + +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2. and -.3, 3. and -.4, 4.\[\n\r\]* into" 2 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.3, 3.\[\n\r\]* into" 1 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2.\[\n\r\]* into" 1 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.0, 31. and -.64, 95.\[\n\r\]* into" 2 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.128, 159. and -.192, 223.\[\n\r\]* into" 1 "reassoc1" } } */ +/* { dg-final { scan-tree-dump-times "Optimizing range tests \[^\r\n\]*_\[0-9\]* -.0, 0. and -.128, 128.\[\n\r\]* into" 1 "reassoc2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr46315.c b/SingleSource/Regression/C/gcc-dg/pr46315.c new file mode 100644 index 0000000000..2349284e2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46315.c @@ -0,0 +1,37 @@ +/* PR rtl-optimization/46315 */ +/* Reported by Magnus Granberg */ + +/* { dg-do run } */ +/* { dg-options "-O2 -fno-strict-overflow" } */ + +extern void abort (void); + +static char const * +parse_ranged (char const *s, int digits) +{ + int n = 0; + char const *lim = s + digits; + while (s < lim) + { + unsigned d = *s++ - '0'; + if (9 < d) + return 0; + n = 10 * n + d; + } + return s && 0 <= n && n <= 59 ? s : 0; +} + +int main(void) +{ + const char *s = "10092240"; + + s = parse_ranged (s, 2); + s = parse_ranged (s, 2); + s = parse_ranged (s, 2); + s = parse_ranged (s, 2); + + if (!s || *s != '\0') + abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46355.c b/SingleSource/Regression/C/gcc-dg/pr46355.c new file mode 100644 index 0000000000..e644ec584e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46355.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-distribution -fstrict-overflow" } */ + +void +foo (int *dest, int i, int u, int v) +{ + int j = i; + while (i) + { + dest[j--] = v; + dest[j--] = u; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr46375.c b/SingleSource/Regression/C/gcc-dg/pr46375.c new file mode 100644 index 0000000000..0126bc93da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46375.c @@ -0,0 +1,16 @@ +/* PR debug/46375 */ +/* Reported by Zdenek Sojka */ +/* { dg-do compile } */ +/* { dg-options "-fgcse -fno-tree-dominator-opts -fcompare-debug -O" } */ + +void bar (void); + +void +foo (int **pp) +{ + int *p = 0; + if (pp) + p = *pp; + if (p && *p) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46387.c b/SingleSource/Regression/C/gcc-dg/pr46387.c new file mode 100644 index 0000000000..e06bd3b106 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46387.c @@ -0,0 +1,32 @@ +/* PR debug/46387 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ + +struct S { double x; double y; short z; }; +int a = 0, b = 0, c; +void bar (int, int, int); +void baz (int *, int *, int *); + +void +foo (struct S *v) +{ + int x, y, z; + if (!a && b != 0) + return; + if (v->z) + baz (&x, &y, &z); + else + { + x = v->x; + y = v->y; + } + x = x / (5 + 1); + y = y / (5 + 1); + if (x < 0) + x = 0; + if (x > c - 1) + x = c - 1; + if (b == 0) + bar (x, y, 1); + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46440.c b/SingleSource/Regression/C/gcc-dg/pr46440.c new file mode 100644 index 0000000000..12a9997034 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46440.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/46440 */ +/* { dg-do compile } */ +/* { dg-options "-O -fstack-protector -fno-tree-dominator-opts -fno-tree-fre" } */ +/* { dg-require-effective-target fstack_protector } */ + +int i; + +void bar (char *); + +void +foo (void) +{ + void *l; + char c[64]; + bar (c); + i = 1; + if (i) + l = &&l1; + else + l = &&l2; + goto *l; +l2: + __builtin_abort (); +l1:; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46494.c b/SingleSource/Regression/C/gcc-dg/pr46494.c new file mode 100644 index 0000000000..29f96856b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46494.c @@ -0,0 +1,9 @@ +/* { dg-do compile } +/* { dg-options "-O -fno-tree-ccp -fno-tree-fre -ftree-vrp" } */ + +extern void foo (void) __attribute__((noreturn)); +void g (void) +{ + void (*f) (void) = foo; + f (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46499-1.c b/SingleSource/Regression/C/gcc-dg/pr46499-1.c new file mode 100644 index 0000000000..9815272e68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46499-1.c @@ -0,0 +1,31 @@ +/* PR middle-end/46499 */ +/* { dg-do run } */ +/* { dg-options "-O -fno-omit-frame-pointer -fno-tree-ccp -fno-tree-dominator-opts -finline-small-functions" } */ + +extern void abort (void); + +int count = 0; + +int +foo (void) +{ + count++; + return 0; +} + +int +bar (void) +{ + count++; + return 0; +} + +int +main () +{ + if ((foo () == 1) & (bar () == 1)) + abort (); + if (count != 2) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46499-2.c b/SingleSource/Regression/C/gcc-dg/pr46499-2.c new file mode 100644 index 0000000000..c3a264816d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46499-2.c @@ -0,0 +1,19 @@ +/* PR middle-end/46499 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-dominator-opts" } */ + +extern void abort (void); + +static inline int +foo (void) +{ + return 0; +} + +int +main () +{ + if ((foo () == 1) & (foo () == 1)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46521.c b/SingleSource/Regression/C/gcc-dg/pr46521.c new file mode 100644 index 0000000000..905b3e0c03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46521.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fselective-scheduling2 -fsel-sched-pipelining -fprofile-generate -fno-early-inlining" } */ + +static void bmp_iter_next (int *bi) +{ + *bi >>= 1; +} + +int bmp_iter_set (int *, int); +void bitmap_clear (void); +void bitmap_initialize_stat (void); + +void df_md_alloc (int bi, int bb_index, int bb_info) +{ + for (; bmp_iter_set (&bi, bb_index); bmp_iter_next (&bi)) + if (bb_info) + bitmap_clear (); + else + bitmap_initialize_stat (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46522.c b/SingleSource/Regression/C/gcc-dg/pr46522.c new file mode 100644 index 0000000000..9e8e08ca7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46522.c @@ -0,0 +1,33 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O3 -fkeep-inline-functions -fsel-sched-pipelining -fselective-scheduling2 -funroll-loops" } */ + +struct S +{ + unsigned i, j; +}; + +static inline void +bar (struct S *s) +{ + if (s->i++ == 1) + { + s->i = 0; + s->j++; + } +} + +void +foo1 (struct S *s) +{ + bar (s); +} + +void +foo2 (struct S s1, struct S s2, int i) +{ + while (s1.i != s2.i) { + if (i) + *(unsigned *) 0 |= (1U << s1.i); + bar (&s1); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46571.c b/SingleSource/Regression/C/gcc-dg/pr46571.c new file mode 100644 index 0000000000..435812210e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46571.c @@ -0,0 +1,122 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug -w" } */ + +typedef union tree_node *tree; +typedef unsigned int source_location; +enum tree_code +{ + MINUS_EXPR, + MULT_EXPR, +}; +struct tree_omp_clause +{ + union omp_clause_subcode + { + enum tree_code reduction_code; + } subcode; +}; +union tree_node +{ + struct tree_omp_clause omp_clause; +}; +enum tree_index +{ + TI_ERROR_MARK, +}; +typedef struct +{ + unsigned allocatable:1; + unsigned dimension:1; + unsigned codimension:1; + unsigned external:1; + unsigned optional:1; + unsigned pointer:1; + unsigned contiguous:1; + unsigned referenced:1; +} symbol_attribute; +typedef unsigned int gfc_char_t; +typedef struct gfc_linebuf +{ + source_location location; +} gfc_linebuf; +typedef struct +{ + gfc_char_t *nextc; + gfc_linebuf *lb; +} locus; +typedef struct +{ + struct gfc_symbol *sym; + struct gfc_namelist *next; +} gfc_namelist; +enum +{ + OMP_LIST_PLUS, + OMP_LIST_REDUCTION_FIRST = OMP_LIST_PLUS, + OMP_LIST_MULT, + OMP_LIST_SUB, + OMP_LIST_NUM +}; +typedef struct gfc_omp_clauses +{ + gfc_namelist *lists[OMP_LIST_NUM]; +} gfc_omp_clauses; +typedef struct gfc_symbol +{ + symbol_attribute attr; +} gfc_symbol; +typedef struct gfc_code +{ + locus loc; + union + { + gfc_omp_clauses *omp_clauses; + } ext; +} gfc_code; +typedef struct +{ +} stmtblock_t; + +static tree +gfc_trans_omp_reduction_list (gfc_namelist * namelist, tree list, + enum tree_code reduction_code, locus where) +{ + for (; namelist != ((void *) 0); namelist = namelist->next) + if (namelist->sym->attr.referenced) + { + tree node = build_omp_clause (where.lb->location); + node->omp_clause.subcode.reduction_code = reduction_code; + gfc_trans_omp_array_reduction (namelist->sym, where); + } +} + +static tree +gfc_trans_omp_clauses (stmtblock_t * block, gfc_omp_clauses * clauses, + locus where) +{ + tree omp_clauses = (tree) ((void *) 0); + int list; + for (list = 0; list < OMP_LIST_NUM; list++) + { + gfc_namelist *n = clauses->lists[list]; + enum tree_code reduction_code; + if (n == ((void *) 0)) + continue; + switch (list) + { + case OMP_LIST_MULT: + reduction_code = MULT_EXPR; + break; + case OMP_LIST_SUB: + reduction_code = MINUS_EXPR; + } + gfc_trans_omp_reduction_list (n, omp_clauses, reduction_code, where); + } +} + +void +gfc_trans_omp_parallel_workshare (gfc_code * code) +{ + stmtblock_t block; + gfc_trans_omp_clauses (&block, code->ext.omp_clauses, code->loc); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46585.c b/SingleSource/Regression/C/gcc-dg/pr46585.c new file mode 100644 index 0000000000..32befdfb06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46585.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-fno-dce -fschedule-insns -fselective-scheduling" } */ +void +foo (void) +{ + switch (0) + { + default: + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46614.c b/SingleSource/Regression/C/gcc-dg/pr46614.c new file mode 100644 index 0000000000..92bcf4e016 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46614.c @@ -0,0 +1,57 @@ +/* PR rtl-optimization/46614 */ +/* { dg-do run } */ +/* { dg-options "-O -fno-rename-registers -fsched2-use-superblocks -fschedule-insns2 -funroll-loops" } */ +/* { dg-require-effective-target scheduling } */ + +extern void abort (void); + +struct S +{ + unsigned char a; + unsigned char b; + unsigned int c; + unsigned int e; + unsigned char f; + unsigned int g; +}; + +void bar (struct S *x) +{ + int i; + struct S *p = x; + struct S r[16]; + unsigned j; + for (i = 0; i < 16; i++) + { + r[i].c = p->b + p->c; + j = p->c + p->f; + r[i].a = j + p->b; + r[i].f = p->f + p->e; + r[i].g = p->b + p->c; + } + for (i = 0; i < 16; i++) + { + if (r[i].c != x[i].b + x[i].c + || r[i].a != x[i].c + x[i].f + x[i].b + || r[i].f != x[i].f + x[i].e + || r[i].g != x[i].b + x[i].c) + abort (); + } + for (i = 0; i < 16; i++) + { + r[i].b = p->c; + if (r[i].b != x[i].c) + abort (); + } +} + +int +main () +{ + int i; + struct S x[16]; + for (i = 0; i < 16; i++) + x[i].b = x[i].c = x[i].e = x[i].f = 5; + bar (x); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46620.c b/SingleSource/Regression/C/gcc-dg/pr46620.c new file mode 100644 index 0000000000..8cc71ebbb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46620.c @@ -0,0 +1,76 @@ +/* PR tree-optimization/46620 */ +/* SRA bitfield grouping used to lose track at padding bitfields in + the middle of a word. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include + +struct PCT +{ + unsigned char pi1 : 4; + unsigned char pi2 : 3; + unsigned char pif : 5; + + unsigned char sl : 2; + unsigned char uc : 1; + unsigned char st : 1; + + unsigned char p : 1; + unsigned char cs : 1; + unsigned char ss : 1; + + unsigned char pc : 3; + unsigned char dmv : 4; + unsigned char cv : 4; +}; + +struct rt +{ + struct rt* d; + void (*edo)(void * const); + short lId; + char dac; +}; + +struct pedr +{ + struct rt re; + struct PCT pc; + unsigned char mid; +} ; + +void __attribute__((__noinline__)) +rei(struct rt* const me, unsigned short anId, void *ad ) +{ + asm volatile (""); +} + +void __attribute__((__noinline__)) +pedrdo(void * const p) +{ + asm volatile (""); +} + +void __attribute__((__noinline__)) +pedri (struct pedr* const me, struct PCT ppc, unsigned char pmid) +{ + rei(&(me->re), 0x7604, 0); + me->pc = ppc; + me->mid = pmid; + (me)->re.edo = pedrdo; +} + +int main() +{ + struct PCT ps; + struct pedr pm; + + pm.pc.dmv = 0; + ps.dmv = 1; + pedri(&pm, ps, 32); + + if (pm.pc.dmv != 1) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46647.c b/SingleSource/Regression/C/gcc-dg/pr46647.c new file mode 100644 index 0000000000..a903273fc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46647.c @@ -0,0 +1,29 @@ +/* PR middle-end/46647 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int a; + +int +func1 (void) +{ + __builtin_memset (&a, -1, sizeof (a)); + return 0; +} + +int +func2 (void) +{ + __builtin_memset (&a, 123, sizeof (a)); + return 0; +} + +int +func3 (void) +{ + __builtin_memset (&a, 0, sizeof (a)); + return 0; +} + +/* The xfail for avr, cris-* and pru is due to PR53535. */ +/* { dg-final { scan-tree-dump-not "memset" "optimized" { xfail avr-*-* cris-*-* pru-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr46674.c b/SingleSource/Regression/C/gcc-dg/pr46674.c new file mode 100644 index 0000000000..871b364c3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46674.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-options "-O2" } */ + +#define LABEL3(pfx, x) # pfx x +#define LABEL2(pfx, x) LABEL3(pfx, x) +#define LABEL(x) LABEL2(__USER_LABEL_PREFIX__, x) + +int yum; +void dessert (void) { ++yum; } +extern void jelly (void) __asm__ (LABEL ("jelly2")) __attribute__ ((alias ("dessert"), weak)); +extern void wobbly (void) __attribute__ ((alias ("jelly2"), weak)); + +/* { dg-final { scan-assembler "wobbly" } } */ +/* { dg-final { scan-assembler "jelly2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr46675.c b/SingleSource/Regression/C/gcc-dg/pr46675.c new file mode 100644 index 0000000000..7493f0e603 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46675.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int j; + +void +__attribute__((noinline)) +foo (int n) +{ + int npairs, i; + npairs = n - (-__INT_MAX__ - 1); + + if (npairs > 0) + for (i = 0; i < npairs; i++) + j++; +} + +int +main () +{ + foo (5 - __INT_MAX__ - 1); + + if (j != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46685.c b/SingleSource/Regression/C/gcc-dg/pr46685.c new file mode 100644 index 0000000000..6277bcc2f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46685.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target freorder } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -freorder-blocks-and-partition -fpic" } */ + +__attribute__((noinline, noclone)) +void bar (void *x) +{ + asm volatile ("" : : "r" (x) : "memory"); +} + +__attribute__((noinline, noclone)) +void baz (void) +{ + asm volatile ("" : : : "memory"); +} + +__attribute__((noinline, noclone)) +int foo (int x) +{ + __label__ lab; + if (__builtin_expect (x, 0)) + { + lab: + baz (); + return 2; + } + bar (&&lab); + return 1; +} + +int +main (void) +{ + int x, i; + asm volatile ("" : "=r" (x) : "0" (0)); + for (i = 0; i < 1000000; i++) + foo (x); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46728-12.c b/SingleSource/Regression/C/gcc-dg/pr46728-12.c new file mode 100644 index 0000000000..c383e878c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46728-12.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm" } */ + +#include + +extern void abort (void); + +#define NVALS 6 + +static double +convert_it (double x) +{ + return pow (x, 1.0 / 3.0); +} + +int +main (int argc, char *argv[]) +{ + double values[NVALS] = { 3.0, 1.95, 2.227, 729.0, 64.0, .0008797 }; + double PREC = 0.999999; + unsigned i; + + for (i = 0; i < NVALS; i++) + if (fabs (convert_it (values[i]) / cbrt (values[i])) < PREC) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46728-6.c b/SingleSource/Regression/C/gcc-dg/pr46728-6.c new file mode 100644 index 0000000000..b566391dda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46728-6.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -lm -fno-ident" } */ + +#include + +int +main (int argc, char *argv[]) +{ + volatile double result; + + result = pow (-0.0, 3.0); + result = pow (26.47, -2.0); + result = pow (0.0, 0.0); + result = pow (22.3, 1.0); + result = pow (33.2, -1.0); + + return 0; +} + + +/* { dg-final { scan-assembler-not {pow\M} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr46728-9.c b/SingleSource/Regression/C/gcc-dg/pr46728-9.c new file mode 100644 index 0000000000..7496976205 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46728-9.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm" } */ + +#include + +extern void abort (void); + +#define NVALS 6 + +static double +convert_it (double x) +{ + return pow (x, 0.5); +} + +int +main (int argc, char *argv[]) +{ + double values[NVALS] = { 3.0, 1.95, 2.227, 4.0, 256.0, .0008797 }; + double PREC = 0.999999; + unsigned i; + + for (i = 0; i < NVALS; i++) + if (fabs (convert_it (values[i]) / sqrt (values[i])) < PREC) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr46771.c b/SingleSource/Regression/C/gcc-dg/pr46771.c new file mode 100644 index 0000000000..b44dfd466a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46771.c @@ -0,0 +1,18 @@ +/* PR debug/46771 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-vectorize -fcompare-debug" } */ + +unsigned char v[1600]; + +unsigned char +foo (unsigned char x) +{ + int i; + unsigned char a = x; + unsigned char b = x; + for (i = 0; i < 1600; i++) + a = a < v[i] ? v[i] : a; + for (i = 0; i < 1600; i++) + b = b > v[i] ? v[i] : b; + return a - b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46777.c b/SingleSource/Regression/C/gcc-dg/pr46777.c new file mode 100644 index 0000000000..e9f40a080e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46777.c @@ -0,0 +1,49 @@ +/* PR rtl-optimization/46777 */ +/* { dg-do compile } */ +/* { dg-options "-fgcse -O -fno-tree-dominator-opts -funroll-loops" } */ + +struct S { char s[256]; }; + +static inline int +foo (int x, int y) +{ + switch (x) + { + case 1: + case 2: + return 3; + case 3: + case 4: + return 2; + case 5: + switch (y) + { + case 4: + return 1; + } + } + return 0; +} + +void +bar (struct S *x, int *y, int *z, int **w) +{ + switch (*y ? x->s[*y] : foo (y[1], y[0])) + { + case 3: + if (y + 2 == z) + for (;;) + { + y += 2; + switch (*y ? x->s[*y] : foo (y[1], y[0])) + { + case 6: + break; + default: + *w = y; + } + if (y == z) + break; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46867.c b/SingleSource/Regression/C/gcc-dg/pr46867.c new file mode 100644 index 0000000000..9225bce42e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46867.c @@ -0,0 +1,32 @@ +/* PR debug/46867 */ +/* { dg-do compile } */ +/* { dg-options "-O -g" } */ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +extern void *bar (void); + +void +foo (int x, char *r1, char *r2, __INTPTR_TYPE__ *rp, char *t) +{ + char *tx = tx; + char **cc = bar (); + ptrdiff_t rx = r1 - r2; + for (;;) + { + char *cp1 = (char *) *rp; + char *cp2 = t; + char *s; + ptrdiff_t len = cp1 - tx + rx * (cp2 - cp1); + while (len) + ; + for (s = tx; s; s++) + ; + while (s) + if (s == cc[s - r1]) + if (x) + bar (); + if (cp1) + tx = cp2; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46875.c b/SingleSource/Regression/C/gcc-dg/pr46875.c new file mode 100644 index 0000000000..8b6d23680f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46875.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fselective-scheduling2" } */ + +long +foo (int x, long *y) +{ + long a = 0; + switch (x) + { + case 0: + a = *y; + break; + case 1: + a = *y; + break; + case 2: + a = *y; + break; + case 3: + a = *y; + break; + case 4: + a = *y; + break; + } + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46878-1.c b/SingleSource/Regression/C/gcc-dg/pr46878-1.c new file mode 100644 index 0000000000..b8722a4062 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46878-1.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/46878 */ +/* Make sure this doesn't ICE. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int __foo (void); +int __bar (void); + +struct baz +{ + int *newp; +}; + +int +get_ice (int *op, struct baz *ret) +{ + int *tmpp; + int c; + c = (__foo () != 1); + if (__bar ()) + { + return (1); + } + if (c) + tmpp = op; + if (tmpp) + { + } + else if (c) + { + ret->newp = tmpp; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46893.c b/SingleSource/Regression/C/gcc-dg/pr46893.c new file mode 100644 index 0000000000..ef97e2edfd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46893.c @@ -0,0 +1,13 @@ +/* PR debug/46893 */ +/* { dg-do compile } */ +/* { dg-options "-O -g" } */ + +void +foo (void) +{ + union { unsigned long long l; double d; } u = { 0x7ff0000000000000ULL }; + double v = 0, w = -u.d; + + if (w) + w = v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46909.c b/SingleSource/Regression/C/gcc-dg/pr46909.c new file mode 100644 index 0000000000..c4d2f92686 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46909.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/46909 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +extern void abort (); + +int +__attribute__ ((__noinline__)) +foo (unsigned int x) +{ + if (! (x == 4 || x == 6) || (x == 2 || x == 6)) + return 1; + return -1; +} + +/* { dg-final { scan-tree-dump-times "x_\[0-9\]+\\(D\\) != 4" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "x_\[0-9\]+\\(D\\) != 6" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "x_\[0-9\]+\\(D\\) == 2" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "x_\[0-9\]+\\(D\\) == 6" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr46921.c b/SingleSource/Regression/C/gcc-dg/pr46921.c new file mode 100644 index 0000000000..17dfedd7e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46921.c @@ -0,0 +1,40 @@ +/* PR c/46921 lost side effect when struct initializer expr uses comma + operator */ + +/* { dg-do run } */ +/* { dg-options "" } */ + +extern int printf(const char *, ...); +extern void abort (void); + +typedef struct __uws_0 { } uw_unit; +uw_unit uw_unit_v = {}; + +struct __uws_1 +{ + struct __uws_0 __uwf_1; + struct __uws_1* __uwf_2; +}; + +static int left_hand_eval = 0; + +static void +foo (const char *s) +{ + ++left_hand_eval; + printf("%s", s); +} + +int +main () +{ + struct __uws_1 tmp = {(foo("Inner\n"), uw_unit_v)}; + + printf("Outer\n"); + /* left hand expression in comma operator initializer must always be + evaluated if there are side effects. */ + if (!left_hand_eval) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr46932.c b/SingleSource/Regression/C/gcc-dg/pr46932.c new file mode 100644 index 0000000000..2b39990d03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr46932.c @@ -0,0 +1,14 @@ +/* { dg-options "-O2 -fdump-rtl-auto_inc_dec" } */ +/* { dg-require-effective-target autoincdec } */ + +/* Check that accesses based on the frame pointer do not + use auto increment. */ + +extern void foo(char*); +void t01(char t) +{ + char c = t; + foo(&c); +} + +/* { dg-final { scan-rtl-dump-not "success" "auto_inc_dec" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr47028.c b/SingleSource/Regression/C/gcc-dg/pr47028.c new file mode 100644 index 0000000000..3f80ff1c5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47028.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/47028 */ +/* { dg-do run } */ +/* { dg-options "-O -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts" } */ + +int +fib (int n) +{ + if (n <= 1) + return 1; + return fib (n - 2) + fib (n - 1); +} + +int +main (void) +{ + if (fib (5) != 8) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47086.c b/SingleSource/Regression/C/gcc-dg/pr47086.c new file mode 100644 index 0000000000..473e802bc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47086.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fexceptions -fnon-call-exceptions -ftrapv" } */ +/* { dg-require-effective-target exceptions } */ + +void +foo () +{ + int n = 0; + while (1) + { + int i[n % 1]; + n++; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr47201.c b/SingleSource/Regression/C/gcc-dg/pr47201.c new file mode 100644 index 0000000000..11e1f2ade3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47201.c @@ -0,0 +1,18 @@ +/* PR target/47201 */ +/* { dg-do compile } */ +/* { dg-options "-O -fpic -g" { target fpic } } */ + +union U +{ + __UINTPTR_TYPE__ m; + float d; +} u; + +int +foo (void) +{ + union U v = { + (__UINTPTR_TYPE__)&u + }; + return u.d == v.d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47276.c b/SingleSource/Regression/C/gcc-dg/pr47276.c new file mode 100644 index 0000000000..fb0c12549f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47276.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-require-visibility "" } */ +/* { dg-add-options bind_pic_locally } */ + +#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) +#define ASMNAME2(prefix, cname) STRING (prefix) cname +#define STRING(x) #x + +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +extern void vsyslog (int __pri, __const char *__fmt, int __ap) + __attribute__ ((__format__ (__printf__, 2, 0))); +void +__vsyslog(int pri, const char *fmt, int ap) +{ +} +void +__syslog_chk(int pri, int flag, const char *fmt, ...) +{ +} +void +__vsyslog_chk(int pri, int flag, const char *fmt, int ap) +{ +} +extern __typeof (__vsyslog_chk) __EI___vsyslog_chk __asm__("" ASMNAME ("__vsyslog_chk")); extern __typeof (__vsyslog_chk) __EI___vsyslog_chk __attribute__((alias ("" "__GI___vsyslog_chk"))); +void +__syslog(int pri, const char *fmt, ...) +{ +} +extern __typeof (__syslog) syslog __attribute__ ((alias ("__syslog"))); +extern __typeof (syslog) __EI_syslog __asm__("" ASMNAME ("syslog")); extern __typeof (syslog) __EI_syslog __attribute__((alias ("" "__GI_syslog"))); +extern __typeof (__vsyslog) vsyslog __attribute__ ((alias ("__vsyslog"))); +extern __typeof (vsyslog) __EI_vsyslog __asm__("" ASMNAME ("vsyslog")); extern __typeof (vsyslog) __EI_vsyslog __attribute__((alias ("" "__GI_vsyslog"))); +extern __typeof (syslog) syslog __asm__ ("" ASMNAME ("__GI_syslog")) __attribute__ ((visibility ("hidden"))); +extern __typeof (vsyslog) vsyslog __asm__ ("" ASMNAME ("__GI_vsyslog")) __attribute__ ((visibility ("hidden"))); +extern __typeof (__vsyslog_chk) __vsyslog_chk __asm__ ("" ASMNAME ("__GI___vsyslog_chk")) __attribute__ ((visibility ("hidden"))); diff --git a/SingleSource/Regression/C/gcc-dg/pr47369-1.c b/SingleSource/Regression/C/gcc-dg/pr47369-1.c new file mode 100644 index 0000000000..117b03bfa3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47369-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fPIC" } */ + +struct FILE +{ + int x; +}; +extern struct FILE __sF[]; +extern void bar (struct FILE *); +void dlmalloc_stats() { + bar ((&__sF[2])); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47372-1.c b/SingleSource/Regression/C/gcc-dg/pr47372-1.c new file mode 100644 index 0000000000..a2e5c5b414 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47372-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fPIC -g" } */ + +typedef struct FILE FILE; +int _fwalk(int (*)(FILE *)); +int __sflush(FILE *); +int +fflush(FILE *fp) +{ + return (_fwalk(__sflush)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47372-2.c b/SingleSource/Regression/C/gcc-dg/pr47372-2.c new file mode 100644 index 0000000000..8addcdc5ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47372-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fPIC -g" } */ + +typedef unsigned short ush; +typedef ush Pos; +extern ush prev[]; +void fill_window( unsigned more, unsigned m) +{ + unsigned n; + for (n = 0; n < (unsigned)(1<<15); n++) { + (prev+0x8000)[n] = (Pos)(m >= 0x8000 ? m-0x8000 : 0); + } + for (n = 0; n < 0x8000; n++) { + prev[n] = (Pos)(m >= 0x8000 ? m-0x8000 : 0); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47381-1.c b/SingleSource/Regression/C/gcc-dg/pr47381-1.c new file mode 100644 index 0000000000..738a892083 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47381-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef unsigned IPos; +typedef unsigned char uch; +extern uch window[]; +unsigned max_chain_length; +unsigned strstart; +int longest_match(IPos cur_match, int len, int best_len) +{ + unsigned chain_length = max_chain_length; + register uch *scan = window + strstart; + register uch *match; + register uch scan_end1 = scan[best_len-1]; + register uch scan_end = scan[best_len]; + do { + ; + match = window + cur_match; + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + best_len = len; + } while ( --chain_length != 0); + return best_len; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47381-2.c b/SingleSource/Regression/C/gcc-dg/pr47381-2.c new file mode 100644 index 0000000000..8aa7be720a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47381-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef unsigned long ulg; +long block_start; +typedef unsigned char uch; +extern uch window[]; + unsigned strstart; +ulg flush_block (char *buf, ulg stored_len, int eof); +ulg deflate() +{ + return flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : (char*)((void *)0), (long)strstart - block_start, (1)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47383.c b/SingleSource/Regression/C/gcc-dg/pr47383.c new file mode 100644 index 0000000000..3e2b9ba18a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47383.c @@ -0,0 +1,31 @@ +/* { dg-do run { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ + +static int heap[2*(256 +1+29)+1]; +static int heap_len; +static int heap_max; +void +__attribute__ ((noinline)) +foo (int elems) +{ + int n, m; + int max_code = -1; + int node = elems; + heap_len = 0, heap_max = (2*(256 +1+29)+1); + for (n = 0; n < elems; n++) + heap[++heap_len] = max_code = n; + do { + n = heap[1]; + heap[1] = heap[heap_len--]; + m = heap[1]; + heap[--heap_max] = n; + heap[--heap_max] = m; + } while (heap_len >= 2); +} + +int +main () +{ + foo (286); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47391.c b/SingleSource/Regression/C/gcc-dg/pr47391.c new file mode 100644 index 0000000000..fce34f830f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47391.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/47391 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +const volatile int v = 1; +int i = 0; + +void +foo (void) +{ + i = v; +} + +int +main (void) +{ + foo (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "i = 1;" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr47443.c b/SingleSource/Regression/C/gcc-dg/pr47443.c new file mode 100644 index 0000000000..5a5c43f253 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47443.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/47443 */ +/* { dg-do compile } */ +/* { dg-require-stack-check "generic" } */ +/* { dg-options "-O -fstack-check=generic" } */ + +static inline int bar (char *c, int i) +{ + return c + i > c; +} + +int foo () +{ + char c[100]; + return (bar (c, 1)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47446-1.c b/SingleSource/Regression/C/gcc-dg/pr47446-1.c new file mode 100644 index 0000000000..38c9594a69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47446-1.c @@ -0,0 +1,40 @@ +/* { dg-do assemble } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +enum +{ + __GCONV_OK = 0, + __GCONV_NOCONV, + __GCONV_NODB, + __GCONV_NOMEM, + __GCONV_EMPTY_INPUT, + __GCONV_FULL_OUTPUT, + __GCONV_ILLEGAL_INPUT, + __GCONV_INCOMPLETE_INPUT, + __GCONV_ILLEGAL_DESCRIPTOR, + __GCONV_INTERNAL_ERROR +}; +int +foo (int result) +{ + int irreversible = 0; + switch (result) + { + case __GCONV_ILLEGAL_INPUT: + irreversible = -1L; + break; + case __GCONV_FULL_OUTPUT: + irreversible = -2L; + break; + case __GCONV_INCOMPLETE_INPUT: + irreversible = -3L; + break; + case __GCONV_EMPTY_INPUT: + case __GCONV_OK: + break; + default: + abort (); + } + return irreversible; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47446-2.c b/SingleSource/Regression/C/gcc-dg/pr47446-2.c new file mode 100644 index 0000000000..5410c7f38d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47446-2.c @@ -0,0 +1,41 @@ +/* { dg-do assemble } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fpic" } */ + +extern void abort (void); +enum +{ + __GCONV_OK = 0, + __GCONV_NOCONV, + __GCONV_NODB, + __GCONV_NOMEM, + __GCONV_EMPTY_INPUT, + __GCONV_FULL_OUTPUT, + __GCONV_ILLEGAL_INPUT, + __GCONV_INCOMPLETE_INPUT, + __GCONV_ILLEGAL_DESCRIPTOR, + __GCONV_INTERNAL_ERROR +}; +int +foo (int result) +{ + int irreversible = 0; + switch (result) + { + case __GCONV_ILLEGAL_INPUT: + irreversible = -1L; + break; + case __GCONV_FULL_OUTPUT: + irreversible = -2L; + break; + case __GCONV_INCOMPLETE_INPUT: + irreversible = -3L; + break; + case __GCONV_EMPTY_INPUT: + case __GCONV_OK: + break; + default: + abort (); + } + return irreversible; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47555.c b/SingleSource/Regression/C/gcc-dg/pr47555.c new file mode 100644 index 0000000000..d65265274f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47555.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#define FILL_BACK *ptrRGB++=0; *ptrRGB++=0; *ptrRGB++=0; + + +void uncompact(unsigned char* ptrRGB, const unsigned int* ptrSrc, const unsigned char* ptrRGBcompact, int line, int nbPixLeft) +{ + +#define BIT_2_RGB32 \ + if ((v & 0x00000001)){ nbPixLeft--; *ptrRGB++ = *ptrRGBcompact++; *ptrRGB++ = *ptrRGBcompact++; *ptrRGB++ = *ptrRGBcompact++; } \ + else{ FILL_BACK } \ + v >>= 1; +#define BIT_2_RGB16 \ + if ((v16 & 0x0001)){ nbPixLeft--; *ptrRGB++ = *ptrRGBcompact++; *ptrRGB++ = *ptrRGBcompact++; *ptrRGB++ = *ptrRGBcompact++; } \ + else{ FILL_BACK } \ + v16 >>= 1; + + int x; + unsigned int v, *ptrSrc32bits=(unsigned int*)ptrSrc; + unsigned short v16,*ptrSrc16bits; + + for(x=0; x 1) + abort (); + __asm__ volatile ("" : : "r" (x), "r" (y) : "memory"); + return v1; +} + +__attribute__ ((noinline, noclone)) +void fn3 (void *x, unsigned y, const struct S *z, unsigned w) +{ + __asm__ volatile ("" : : "r" (x), "r" (y), "r" (z), "r" (w) : "memory"); +} + +volatile struct U v2; + +__attribute__ ((noinline, noclone)) +struct U +fn4 (void *x, unsigned y) +{ + __asm__ volatile ("" : : "r" (x), "r" (y) : "memory"); + return v2; +} + +__attribute__ ((noinline, noclone)) +struct S +fn5 (void *x) +{ + __asm__ volatile ("" : : "r" (x) : "memory"); + return v1; +} + +volatile struct T v3; + +__attribute__ ((noinline, noclone)) +struct T fn6 (void *x) +{ + __asm__ volatile ("" : : "r" (x) : "memory"); + return v3; +} + +__attribute__ ((noinline, noclone)) +struct T fn7 (void *x, unsigned y, unsigned z) +{ + __asm__ volatile ("" : : "r" (x), "r" (y), "r" (z) : "memory"); + return v3; +} + +static void +fn8 (struct Y *x, const struct V *y) +{ + void *a = x->y1; + struct S b[4]; + unsigned i, c; + c = fn1 (y->v1); + for (i = 0; i < c; i++) + b[i] = fn2 (x, &y->v2[i]); + fn3 (a, y->v1, b, c); +} + +static inline void +fn9 (void *x, struct S y __attribute__((unused))) +{ + fn4 (x, 8); +} + +static void +fn10 (struct Y *x) +{ + void *a = x->y1; + struct T b __attribute__((unused)) = fn6 (a); + fn9 (a, fn5 (a)); +} + +__attribute__((noinline, noclone)) +int +fn11 (unsigned int x, void *y, const struct W *z, + unsigned int w, const char *v, const char *u) +{ + struct Y a, *t; + unsigned i; + t = &a; + __builtin_memset (t, 0, sizeof *t); + t->y1 = y; + if (x == 0) + { + if (z->w3 & 1) + fn10 (t); + for (i = 0; i < w; i++) + { + if (v[i] == 0) + t->y3[i] = fn7 (y, 0, u[i]); + else + return 0; + } + } + else + for (i = 0; i < w; i++) + t->y3[i] = fn7 (y, v[i], u[i]); + for (i = 0; i < z->w5; i++) + fn8 (t, &z->w2[i]); + return 0; +} + +volatile int i; +const char *volatile p = ""; + +int +main () +{ + struct V v = { .v1 = 0 }; + struct W w = { .w5 = 1, .w2 = &v }; + fn11 (i + 1, (void *) p, &w, i, (const char *) p, (const char *) p); + if (cnt != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47899.c b/SingleSource/Regression/C/gcc-dg/pr47899.c new file mode 100644 index 0000000000..c83bb85e31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47899.c @@ -0,0 +1,26 @@ +/* PR rtl-optimization/47899 */ +/* { dg-do compile } */ +/* { dg-options "-O -funroll-loops" } */ + +extern unsigned int a, b, c; +extern int d; + +static int +foo (void) +{ +lab: + if (b) + for (d = 0; d >= 0; d--) + if (a || c) + for (; c; c++) + ; + else + goto lab; +} + +int +main () +{ + foo (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr47917.c b/SingleSource/Regression/C/gcc-dg/pr47917.c new file mode 100644 index 0000000000..725bc01c8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47917.c @@ -0,0 +1,37 @@ +/* PR middle-end/47917 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +extern int snprintf (char *, __SIZE_TYPE__, const char *, ...); +extern int memcmp (const void *, const void *, __SIZE_TYPE__); +extern void abort (void); + +char buf1[6], buf2[6], buf3[4], buf4[4]; +int i; + +int +foo (void) +{ + int ret = snprintf (buf1, sizeof buf1, "abcde"); + ret += snprintf (buf2, sizeof buf2, "abcdef") * 16; + ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256; + ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 4096; + return ret; +} + +int +main (void) +{ + if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096) + abort (); + if (memcmp (buf1, "abcde", 6) != 0 + || memcmp (buf2, "abcde", 6) != 0 + || memcmp (buf3, "abc", 4) != 0 + || memcmp (buf4, "def", 4) != 0 + || i != 2) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "snprintf" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "sprintf" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr47991.c b/SingleSource/Regression/C/gcc-dg/pr47991.c new file mode 100644 index 0000000000..688be5c02d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr47991.c @@ -0,0 +1,25 @@ +/* PR debug/47991 */ +/* { dg-do compile } */ +/* { dg-options "-g -Os" } */ + +typedef __SIZE_TYPE__ size_t; +extern inline __attribute__ ((__always_inline__)) +void * +memset (void *x, int y, size_t z) +{ + return __builtin___memset_chk (x, y, z, __builtin_object_size (x, 0)); +} + +void +foo (unsigned char *x, unsigned char *y, unsigned char *z, + unsigned char *w, unsigned int v, int u, int t) +{ + int i; + for (i = 0; i < t; i++) + { + memset (z, x[0], v); + memset (w, y[0], v); + x += u; + } + __builtin_memcpy (z, x, u); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48022-1.c b/SingleSource/Regression/C/gcc-dg/pr48022-1.c new file mode 100644 index 0000000000..14eb550307 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48022-1.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/48022 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-overflow" } */ + +int +foo (const char *x) +{ + unsigned long l = 1; + const unsigned char *s = (const unsigned char *) (const char *) (x); + int r = s[0] - ((const unsigned char *) (const char *) ("/"))[0]; + if (l > 0 && r == 0) + r = (s[1] - ((const unsigned char *) (const char *) ("/"))[1]); + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48022-2.c b/SingleSource/Regression/C/gcc-dg/pr48022-2.c new file mode 100644 index 0000000000..41fcb53381 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48022-2.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/48022 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-overflow" } */ + +#include + +int +foo (const char *x) +{ + return strcmp (x, "/"); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48062.c b/SingleSource/Regression/C/gcc-dg/pr48062.c new file mode 100644 index 0000000000..0f4cdde2e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48062.c @@ -0,0 +1,13 @@ +/* PR c/48062 */ +/* { dg-do compile } */ +/* { dg-options "-Wshadow" } */ + +int +main (void) +{ + int i; /* { dg-bogus "shadowed declaration" } */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" + { int i; } +#pragma GCC diagnostic pop +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48067.c b/SingleSource/Regression/C/gcc-dg/pr48067.c new file mode 100644 index 0000000000..779690918c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48067.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -fno-tree-forwprop -fno-tree-reassoc" } */ +/* { dg-options "-O2 -ffast-math -fno-tree-forwprop -fno-tree-reassoc -mfma4" { target x86_64-*-* i?86-*-* } } */ + +float +foo (float x, float cim) +{ + float c = x * cim; + float d = -c; + return c - d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48134.c b/SingleSource/Regression/C/gcc-dg/pr48134.c new file mode 100644 index 0000000000..446ad01b45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48134.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-require-stack-check "specific" } */ +/* { dg-options "-O2 -fstack-check=specific -fno-tree-dse -fno-tree-fre -fno-tree-loop-optimize -g" } */ + +struct S +{ + int w, z; +}; +struct T +{ + struct S s; +}; + +int i; + +static inline struct S +bar (struct S x) +{ + i++; + return x; +} + +int +foo (struct T t, struct S s) +{ + struct S *c = &s; + if (i) + c = &t.s; + t.s.w = 3; + s = bar (*c); + return t.s.w; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48141.c b/SingleSource/Regression/C/gcc-dg/pr48141.c new file mode 100644 index 0000000000..006f5cb144 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48141.c @@ -0,0 +1,17 @@ +/* PR rtl-optimization/48141 */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +#define A i = 0; +#define B A A A A A A A A A A +#define C B B B B B B B B B B +#define D C C C C C C C C C C +#define E D D D D D D D D D D + +int +foo (void) +{ + volatile int i = 0; + E E E E E E E E E E E + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48144.c b/SingleSource/Regression/C/gcc-dg/pr48144.c new file mode 100644 index 0000000000..030202d064 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48144.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -frerun-cse-after-loop -fschedule-insns2 -fselective-scheduling2 -fno-tree-ch -funroll-loops --param=max-sched-extend-regions-iters=2 --param=max-sched-region-blocks=15" } */ +extern void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n); + +void bar (void *, void *, void *); + +void foo + (void *p, char *data, unsigned data_len) +{ + int buffer[8]; + int buf2[8]; + unsigned i; + for (i = 0; i + 8 <= data_len; i += 8) + bar (p, buffer, data + i); + memcpy (buf2, data + i, data_len); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48156.c b/SingleSource/Regression/C/gcc-dg/pr48156.c new file mode 100644 index 0000000000..7b4d529c41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48156.c @@ -0,0 +1,45 @@ +/* PR rtl-optimization/48156 */ +/* { dg-do run } */ +/* { dg-options "-O -fcrossjumping --param min-crossjump-insns=1" } */ + +extern void abort (void); + +static int __attribute__ ((noinline, noclone)) +equals (int s1, int s2) +{ + return s1 == s2; +} + +static int __attribute__ ((noinline, noclone)) +bar (void) +{ + return 1; +} + +static void __attribute__ ((noinline, noclone)) +baz (int f, int j) +{ + if (f != 4 || j != 2) + abort (); +} + +void +foo (int x) +{ + int i = 0, j = bar (); + + if (x == 1) + i = 2; + + if (j && equals (i, j)) + baz (8, i); + else + baz (4, i); +} + +int +main () +{ + foo (1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48159-1.c b/SingleSource/Regression/C/gcc-dg/pr48159-1.c new file mode 100644 index 0000000000..cd67e63852 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48159-1.c @@ -0,0 +1,10 @@ +/* PR debug/48159 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ + +void +foo (double x, int y, double *__restrict z, double *__restrict w) +{ + while (y--) + *z++ = (*w++ = 0) * x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48159-2.c b/SingleSource/Regression/C/gcc-dg/pr48159-2.c new file mode 100644 index 0000000000..25596bf6b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48159-2.c @@ -0,0 +1,22 @@ +/* PR debug/48159 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-distribution -fcompare-debug" } */ + +int foo (int * __restrict__ ia, int * __restrict__ ib, + int * __restrict__ oxa, int * __restrict__ oxb) +{ + int i; + int oya[52], oyb[52]; + for (i = 0; i < 52; i++) + { + int w1 = ia[i]; + int w2 = oxa[i]; + int w3 = ib[i]; + int w4 = oxb[i]; + int w5 = w1 + w2 + 5; + oya[i] = (w1 * w2) >> 10; + int w6 = w3 + w4 + 6; + oyb[i] = (w3 * w4) >> 10; + } + return oya[22] + oyb[21]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48186.c b/SingleSource/Regression/C/gcc-dg/pr48186.c new file mode 100644 index 0000000000..5635f930de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48186.c @@ -0,0 +1,5 @@ +/* PR tree-optimization/48186 */ +/* { dg-do compile } */ +/* { dg-options "-O --param hot-bb-frequency-fraction=0" } */ + +void foo (void) { } diff --git a/SingleSource/Regression/C/gcc-dg/pr48189.c b/SingleSource/Regression/C/gcc-dg/pr48189.c new file mode 100644 index 0000000000..86b995dc98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48189.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/48189 */ +/* { dg-do compile } */ +/* { dg-options "-O --param max-predicted-iterations=0" } */ + +struct S { int s[8]; }; + +void +foo (int *x, struct S *y) +{ + int i; + for (i = 0; y[i].s[i]; i++) + *x++ = y[i].s[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48203.c b/SingleSource/Regression/C/gcc-dg/pr48203.c new file mode 100644 index 0000000000..b4b2b084dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48203.c @@ -0,0 +1,51 @@ +/* PR debug/48203 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +volatile int v; + +void +foo (long a, long b, long c, long d, long e, long f, long g, long h, + long i, long j, long k, long l, long m, long n, long o, long p) +{ + long a2 = a; + long b2 = b; + long c2 = c; + long d2 = d; + long e2 = e; + long f2 = f; + long g2 = g; + long h2 = h; + long i2 = i; + long j2 = j; + long k2 = k; + long l2 = l; + long m2 = m; + long n2 = n; + long o2 = o; + long p2 = p; + v++; +} + +void +bar (int a, int b, int c, int d, int e, int f, int g, int h, + int i, int j, int k, int l, int m, int n, int o, int p) +{ + int a2 = a; + int b2 = b; + int c2 = c; + int d2 = d; + int e2 = e; + int f2 = f; + int g2 = g; + int h2 = h; + int i2 = i; + int j2 = j; + int k2 = k; + int l2 = l; + int m2 = m; + int n2 = n; + int o2 = o; + int p2 = p; + v++; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48213.c b/SingleSource/Regression/C/gcc-dg/pr48213.c new file mode 100644 index 0000000000..cf7d76fa0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48213.c @@ -0,0 +1,14 @@ +/* PR target/48213 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ +/* { dg-options "-g -O2 -fpic" { target fpic } } */ + +struct S { int (*s) (void); }; +int bar (void); + +void +foo (struct S *x) +{ + if (x->s != bar) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48235.c b/SingleSource/Regression/C/gcc-dg/pr48235.c new file mode 100644 index 0000000000..401624ec62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48235.c @@ -0,0 +1,58 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O -fno-guess-branch-probability -fpeel-loops -freorder-blocks-and-partition -fschedule-insns2 -fsel-sched-pipelining -fselective-scheduling2" } */ +struct intC +{ + short x; + short y; +}; + +int size_x; + +static inline int +TileDiffXY (int x, int y) +{ + return (y * size_x) + x; +} + +struct HangarTileTable +{ + struct intC ti; + int hangar_num; +}; + +struct AirportSpec +{ + struct HangarTileTable *depot_table; + int size; +}; + +void Get (); +struct AirportSpec dummy; + +static inline int +GetRotatedTileFromOffset (int *a, struct intC tidc) +{ + if (!*a) + Get (); + switch (*a) + { + case 0: + return (tidc.y << size_x) + tidc.x; + case 1: + return TileDiffXY (tidc.y, dummy.size - tidc.x); + case 2: + return TileDiffXY (tidc.x, dummy.size - tidc.y); + case 3: + return TileDiffXY (dummy.size - 1, tidc.x); + } +} + +int +GetHangarNum (int *a) +{ + int i; + for (i = 0; i < dummy.size; i++) + if (GetRotatedTileFromOffset (a, dummy.depot_table[i].ti)) + return dummy.depot_table[i].hangar_num; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48335-1.c b/SingleSource/Regression/C/gcc-dg/pr48335-1.c new file mode 100644 index 0000000000..7a022eac83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48335-1.c @@ -0,0 +1,48 @@ +/* PR middle-end/48335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-sra" } */ + +typedef long long T __attribute__((may_alias)); + +struct S +{ + _Complex float d __attribute__((aligned (8))); +}; + +void bar (struct S); + +void +f1 (T x) +{ + struct S s; + *(T *) &s.d = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f2 (int x) +{ + struct S s = { .d = 0.0f }; + *(char *) &s.d = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f3 (int x) +{ + struct S s = { .d = 0.0f }; + ((char *) &s.d)[2] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f4 (int x, int y) +{ + struct S s = { .d = 0.0f }; + ((char *) &s.d)[y] = x; + __real__ s.d *= 7.0; + bar (s); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48335-2.c b/SingleSource/Regression/C/gcc-dg/pr48335-2.c new file mode 100644 index 0000000000..a37c0797c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48335-2.c @@ -0,0 +1,58 @@ +/* PR middle-end/48335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-sra" } */ + +typedef long long T __attribute__((may_alias, aligned (1))); +typedef short U __attribute__((may_alias, aligned (1))); + +struct S +{ + _Complex float d __attribute__((aligned (8))); +}; + +void bar (struct S); + +void +f1 (T x) +{ + struct S s; + *(T *) ((char *) &s.d + 1) = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f2 (int x) +{ + struct S s = { .d = 0.0f }; + ((U *)((char *) &s.d + 1))[0] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f3 (int x) +{ + struct S s = { .d = 0.0f }; + ((U *)((char *) &s.d + 1))[1] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f4 (int x) +{ + struct S s = { .d = 0.0f }; + ((U *)((char *) &s.d + 1))[2] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f5 (int x) +{ + struct S s = { .d = 0.0f }; + ((U *)((char *) &s.d + 1))[3] = x; + __real__ s.d *= 7.0; + bar (s); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48335-3.c b/SingleSource/Regression/C/gcc-dg/pr48335-3.c new file mode 100644 index 0000000000..9041f591ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48335-3.c @@ -0,0 +1,48 @@ +/* PR middle-end/48335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-sra" } */ + +typedef short U __attribute__((may_alias, aligned (1))); + +struct S +{ + double d; +}; + +void bar (struct S); + +void +f1 (int x) +{ + struct S s = { .d = 0.0 }; + ((U *)((char *) &s.d + 1))[0] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f2 (int x) +{ + struct S s = { .d = 0.0 }; + ((U *)((char *) &s.d + 1))[1] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f3 (int x) +{ + struct S s = { .d = 0.0 }; + ((U *)((char *) &s.d + 1))[2] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f4 (int x) +{ + struct S s = { .d = 0.0 }; + ((U *)((char *) &s.d + 1))[3] = x; + __real__ s.d *= 7.0; + bar (s); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48335-4.c b/SingleSource/Regression/C/gcc-dg/pr48335-4.c new file mode 100644 index 0000000000..98e9e1eec7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48335-4.c @@ -0,0 +1,39 @@ +/* PR middle-end/48335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-sra" } */ + +typedef short U __attribute__((may_alias, aligned (1))); + +struct S +{ + double d; +}; + +void bar (struct S); + +void +f1 (int x) +{ + struct S s = { .d = 0.0 }; + ((U *)((char *) &s.d + 1))[-1] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f2 (int x) +{ + struct S s = { .d = 0.0 }; + ((U *)((char *) &s.d + 1))[-2] = x; + __real__ s.d *= 7.0; + bar (s); +} + +void +f3 (int x) +{ + struct S s = { .d = 0.0 }; + ((U *)((char *) &s.d + 1))[5] = x; + __real__ s.d *= 7.0; + bar (s); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48335-5.c b/SingleSource/Regression/C/gcc-dg/pr48335-5.c new file mode 100644 index 0000000000..b1895484dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48335-5.c @@ -0,0 +1,38 @@ +/* PR middle-end/48335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-sra" } */ + +typedef long long T __attribute__((may_alias)); + +struct S +{ + _Complex float d __attribute__((aligned (8))); +}; + +int +f1 (struct S x) +{ + struct S s = x; + return *(T *) &s.d; +} + +int +f2 (struct S x) +{ + struct S s = x; + return *(char *) &s.d; +} + +int +f3 (struct S x) +{ + struct S s = x; + return ((char *) &s.d)[2]; +} + +int +f4 (struct S x, int y) +{ + struct S s = x; + return ((char *) &s.d)[y]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48335-6.c b/SingleSource/Regression/C/gcc-dg/pr48335-6.c new file mode 100644 index 0000000000..769130cc4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48335-6.c @@ -0,0 +1,46 @@ +/* PR middle-end/48335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-sra" } */ + +typedef long long T __attribute__((may_alias, aligned (1))); +typedef short U __attribute__((may_alias, aligned (1))); + +struct S +{ + _Complex float d __attribute__((aligned (8))); +}; + +T +f1 (struct S x) +{ + struct S s = x; + return *(T *) ((char *) &s.d + 1); +} + +int +f2 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[0]; +} + +int +f3 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[1]; +} + +int +f4 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[2]; +} + +int +f5 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[3]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48335-7.c b/SingleSource/Regression/C/gcc-dg/pr48335-7.c new file mode 100644 index 0000000000..ddb15ee6ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48335-7.c @@ -0,0 +1,38 @@ +/* PR middle-end/48335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-sra" } */ + +typedef short U __attribute__((may_alias, aligned (1))); + +struct S +{ + double d; +}; + +int +f1 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[0]; +} + +int +f2 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[1]; +} + +int +f3 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[2]; +} + +int +f4 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[3]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48335-8.c b/SingleSource/Regression/C/gcc-dg/pr48335-8.c new file mode 100644 index 0000000000..bb06c157f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48335-8.c @@ -0,0 +1,31 @@ +/* PR middle-end/48335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-sra" } */ + +typedef short U __attribute__((may_alias, aligned (1))); + +struct S +{ + double d; +}; + +int +f1 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[-1]; +} + +int +f2 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[-2]; +} + +int +f3 (struct S x) +{ + struct S s = x; + return ((U *)((char *) &s.d + 1))[5]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48374.c b/SingleSource/Regression/C/gcc-dg/pr48374.c new file mode 100644 index 0000000000..d694a78538 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48374.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -fschedule-insns2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fselective-scheduling2 --param max-sched-extend-regions-iters=2" } */ + +void foo (int y) +{ + switch (y) + { + case 3: + case 5: + case 7: + case 11: + break; + default: + __builtin_unreachable (); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr48442.c b/SingleSource/Regression/C/gcc-dg/pr48442.c new file mode 100644 index 0000000000..88e3497b11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48442.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fselective-scheduling2 --param max-sched-extend-regions-iters=100" } */ +void f (void) +{ + unsigned *a2; + int vertex2; + int c, x2, dx2, dy2, s2; + long m, b; + do + { + if (dx2) + dx2 = dx2 % dy2; + s2 = (dx2 / dy2); + } + while (vertex2); + for (;;) + { + c = x2; + a2 = 0; + if (c) + { + m = b << (c); + *a2 = (*a2 & ~m); + } + x2 += s2; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48524.c b/SingleSource/Regression/C/gcc-dg/pr48524.c new file mode 100644 index 0000000000..d7e46a7906 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48524.c @@ -0,0 +1,6 @@ +/* { dg-do preprocess } */ +/* { dg-options "-specs=${srcdir}/gcc.dg/pr48524.spec -D_TEST_D" } */ +# ifdef _FOO +# error works /* { dg-error "works" } */ +# endif + diff --git a/SingleSource/Regression/C/gcc-dg/pr48552-1.c b/SingleSource/Regression/C/gcc-dg/pr48552-1.c new file mode 100644 index 0000000000..4cd7c59011 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48552-1.c @@ -0,0 +1,54 @@ +/* PR c/48552 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S; + +void +f1 (void *x) +{ + __asm volatile ("" : : "r" (*x)); /* { dg-warning "dereferencing" "deref" } */ +} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */ + +void +f2 (void *x) +{ + __asm volatile ("" : "=r" (*x)); /* { dg-warning "dereferencing" "deref" } */ +} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */ + +void +f3 (void *x) +{ + __asm volatile ("" : : "m" (*x)); /* { dg-warning "dereferencing" } */ +} + +void +f4 (void *x) +{ + __asm volatile ("" : "=m" (*x)); /* { dg-warning "dereferencing" } */ +} + +void +f5 (void *x) +{ + __asm volatile ("" : : "g" (*x)); /* { dg-warning "dereferencing" "deref" } */ +} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */ + +void +f6 (void *x) +{ + __asm volatile ("" : "=g" (*x)); /* { dg-warning "dereferencing" "deref" } */ +} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */ + +void +f7 (struct S *x) +{ + __asm volatile ("" : : "r" (*x)); /* { dg-error "invalid use of undefined type" } */ +} + +void +f8 (struct S *x) +{ + __asm volatile ("" : "=r" (*x)); /* { dg-error "impossible constraint in 'asm'" } */ + /* { dg-error "non-memory output 0 must stay in memory" "memory" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48552-2.c b/SingleSource/Regression/C/gcc-dg/pr48552-2.c new file mode 100644 index 0000000000..e22600a247 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48552-2.c @@ -0,0 +1,54 @@ +/* PR c/48552 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S; + +void +f1 (void *x) +{ + __asm ("" : : "r" (*x)); /* { dg-warning "dereferencing" "deref" } */ +} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */ + +void +f2 (void *x) +{ + __asm ("" : "=r" (*x)); /* { dg-warning "dereferencing" "deref" } */ +} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */ + +void +f3 (void *x) +{ + __asm ("" : : "m" (*x)); /* { dg-warning "dereferencing" } */ +} + +void +f4 (void *x) +{ + __asm ("" : "=m" (*x)); /* { dg-warning "dereferencing" } */ +} + +void +f5 (void *x) +{ + __asm ("" : : "g" (*x)); /* { dg-warning "dereferencing" "deref" } */ +} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */ + +void +f6 (void *x) +{ + __asm ("" : "=g" (*x)); /* { dg-warning "dereferencing" "deref" } */ +} /* { dg-error "invalid use of void expression" "void expr" { target *-*-* } .-1 } */ + +void +f7 (struct S *x) +{ + __asm ("" : : "r" (*x)); /* { dg-error "invalid use of undefined type" } */ +} + +void +f8 (struct S *x) +{ + __asm ("" : "=r" (*x)); /* { dg-error "impossible constraint in 'asm'" } */ + /* { dg-error "non-memory output 0 must stay in memory" "memory" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48616.c b/SingleSource/Regression/C/gcc-dg/pr48616.c new file mode 100644 index 0000000000..555532c641 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48616.c @@ -0,0 +1,136 @@ +/* PR tree-optimization/48616 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-vectorize" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-skip-if "no alignment > 2" { "pdp11-*-*" } } */ + +extern void abort (void); +int a[4] __attribute__((aligned (32))); +int b[4] __attribute__((aligned (32))); +int c[4] __attribute__((aligned (32))); +int d[4] __attribute__((aligned (32))); +int e[4] __attribute__((aligned (32))); + +__attribute__((noinline, noclone)) +int +foo (int x) +{ + asm ("" : "+r" (x)); + return x; +} + +__attribute__((noinline, noclone)) +void +fn1 (int i) +{ + a[0] = b[0] << c[0]; + a[1] = b[1] << c[1]; + a[2] = b[2] << c[2]; + a[3] = b[3] << c[3]; + if (i) + { + d[0] = e[0] >> c[0]; + d[1] = e[1] >> c[1]; + d[2] = e[2] >> c[2]; + d[3] = e[3] >> c[3]; + } +} + +__attribute__((noinline, noclone)) +void +fn2 (int i) +{ + a[0] = b[0] << 1; + a[1] = b[1] << 2; + a[2] = b[2] << 3; + a[3] = b[3] << 4; + if (i) + { + d[0] = e[0] >> 1; + d[1] = e[1] >> 2; + d[2] = e[2] >> 3; + d[3] = e[3] >> 4; + } +} + +__attribute__((noinline, noclone)) +void +fn3 (int i, int j) +{ + int x = foo (j); + a[0] = b[0] << x; + a[1] = b[1] << x; + a[2] = b[2] << x; + a[3] = b[3] << x; + if (i) + { + d[0] = e[0] >> x; + d[1] = e[1] >> x; + d[2] = e[2] >> x; + d[3] = e[3] >> x; + } +} + +__attribute__((noinline, noclone)) +void +fn4 (int i) +{ + a[0] = b[0] << 1; + a[1] = b[1] << 1; + a[2] = b[2] << 1; + a[3] = b[3] << 1; + if (i) + { + d[0] = e[0] >> 1; + d[1] = e[1] >> 1; + d[2] = e[2] >> 1; + d[3] = e[3] >> 1; + } +} + +int +main () +{ + int i; + int *t; + for (i = 0; i < 4; i++) + { + b[i] = 32; + c[i] = i + 1; + e[i] = 32; + } + asm volatile ("" : : "r" (b) : "memory"); + asm volatile ("" : : "r" (c) : "memory"); + asm volatile ("" : "=r" (t) : "0" (d) : "memory"); + fn1 (t != 0); + for (i = 0; i < 4; i++) + { + if (a[i] != (32 << (i + 1)) || d[i] != (32 >> (i + 1))) + abort (); + a[i] = 0; + d[i] = 0; + } + fn2 (t != 0); + for (i = 0; i < 4; i++) + { + if (a[i] != (32 << (i + 1)) || d[i] != (32 >> (i + 1))) + abort (); + a[i] = 0; + d[i] = 0; + } + fn3 (t != 0, t != 0); + for (i = 0; i < 4; i++) + { + if (a[i] != (32 << 1) || d[i] != (32 >> 1)) + abort (); + a[i] = 0; + d[i] = 0; + } + fn4 (t != 0); + for (i = 0; i < 4; i++) + { + if (a[i] != (32 << 1) || d[i] != (32 >> 1)) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48685.c b/SingleSource/Regression/C/gcc-dg/pr48685.c new file mode 100644 index 0000000000..36df0cc5f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48685.c @@ -0,0 +1,11 @@ +/* PR c/48685 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +main () +{ + int v = 1; + (void) (1 == 2 ? (void) 0 : (v = 0)); + return v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48739-1.c b/SingleSource/Regression/C/gcc-dg/pr48739-1.c new file mode 100644 index 0000000000..4dcdca977c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48739-1.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/48739 */ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O1 -ftree-parallelize-loops=2 -fno-tree-dominator-opts" } */ + +extern int g; +extern void bar (void); + +int +foo (int x) +{ + int a, b, *c = (int *) 0; + for (a = 0; a < 10; ++a) + { + bar (); + for (b = 0; b < 5; ++b) + { + x = 0; + c = &x; + g = 1; + } + } + *c = x; + for (x = 0; x != 10; x++) + ; + return g; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48739-2.c b/SingleSource/Regression/C/gcc-dg/pr48739-2.c new file mode 100644 index 0000000000..c79f4e86a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48739-2.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/48739 */ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O1 -ftree-parallelize-loops=2 -fno-tree-dominator-opts" } */ + +extern int g, v[10]; +extern void bar (void); + +int +foo (int x) +{ + int a, b, *c = (int *) 0; + for (a = 0; a < 10; ++a) + { + bar (); + for (b = 0; b < 5; ++b) + { + x = 0; + c = &x; + g = 1; + } + } + *c = x; + for (x = 0; x != 10; x++) + v[x] = x; + return g; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48768.c b/SingleSource/Regression/C/gcc-dg/pr48768.c new file mode 100644 index 0000000000..7d0383e83b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48768.c @@ -0,0 +1,38 @@ +/* PR debug/48768 */ +/* { dg-do compile } */ +/* { dg-options "-O -fcompare-debug" } */ + +int a, b; + +int +bar (void) +{ + int i, j = 1; + for (i = 0; i != 10; i++) + { + lab: + if (i) + { + int *k = &j; + } + else if (j) + goto lab; + } + return 1; +} + +inline int +foo (int x) +{ + unsigned int c = x; + int d = x; + if (bar ()) + for (; c; c++) + while (x >= 0) + if (foo (d) >= 0) + { + d = bar (); + a = b ? b : 1; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48770.c b/SingleSource/Regression/C/gcc-dg/pr48770.c new file mode 100644 index 0000000000..2ebe97063e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48770.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O -fprofile-arcs -fPIC -fno-dce -fno-forward-propagate" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +int test_goto2 (int f) +{ + int i; + for (i = 0; ({_Bool a = i < 10;a;}); i++) + { + if (i == f) + goto lab2; + } + return 4; +lab2: + return 8; +} + +int main () +{ + test_goto2 (30); + return 0; +} + +/* { dg-final { cleanup-coverage-files } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr48774.c b/SingleSource/Regression/C/gcc-dg/pr48774.c new file mode 100644 index 0000000000..91ce361ccb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48774.c @@ -0,0 +1,38 @@ +/* PR target/48774 */ +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-loops" } */ + +extern void abort (void); +unsigned long int s[24] + = { 12, ~1, 12, ~2, 12, ~4, 12, ~8, 12, ~16, 12, ~32, + 12, ~64, 12, ~128, 12, ~256, 12, ~512, 12, ~1024, 12, ~2048 }; +struct { int n; unsigned long *e[12]; } g + = { 12, { &s[0], &s[2], &s[4], &s[6], &s[8], &s[10], &s[12], &s[14], + &s[16], &s[18], &s[20], &s[22] } }; +int c[12]; + +__attribute__((noinline, noclone)) void +foo (void) +{ + int i, j; + for (i = 0; i < g.n; i++) + for (j = 0; j < g.n; j++) + { + if (i == j && j < g.e[0][0] && (g.e[i][1] & (1UL << j))) + abort (); + if (j < g.e[0][0] && (g.e[i][1] & (1UL << j))) + c[i]++; + } +} + +int +main () +{ + int i; + asm volatile ("" : "+m" (s), "+m" (g), "+m" (c)); + foo (); + for (i = 0; i < 12; i++) + if (c[i] != 11) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48784-1.c b/SingleSource/Regression/C/gcc-dg/pr48784-1.c new file mode 100644 index 0000000000..436d8c5518 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48784-1.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fstrict-volatile-bitfields" } */ + +extern void abort (void); + +#pragma pack(1) +volatile struct S0 { + signed a : 7; + unsigned b : 28; /* b can't be fetched with an aligned 32-bit access, */ + /* but it certainly can be fetched with an unaligned access */ +} g = {0,0xfffffff}; + +int main() { + unsigned b = g.b; + if (b != 0xfffffff) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48784-2.c b/SingleSource/Regression/C/gcc-dg/pr48784-2.c new file mode 100644 index 0000000000..966cbdb962 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48784-2.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fno-strict-volatile-bitfields" } */ + +extern void abort (void); + +#pragma pack(1) +volatile struct S0 { + signed a : 7; + unsigned b : 28; /* b can't be fetched with an aligned 32-bit access, */ + /* but it certainly can be fetched with an unaligned access */ +} g = {0,0xfffffff}; + +int main() { + unsigned b = g.b; + if (b != 0xfffffff) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48826.c b/SingleSource/Regression/C/gcc-dg/pr48826.c new file mode 100644 index 0000000000..691f74f4df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48826.c @@ -0,0 +1,10 @@ +/* { dg-options "-O -g -w" } */ + +void bar (int *); + +void +foo () +{ + int *const pc = __builtin_return_address (0); + bar (pc); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr48837.c b/SingleSource/Regression/C/gcc-dg/pr48837.c new file mode 100644 index 0000000000..ffc65b9dc8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48837.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/48837 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +void abort (void); + +__attribute__((noinline)) +int baz(void) +{ + return 1; +} + +inline const int *bar(const int *a, const int *b) +{ + return *a ? a : b; +} + +int foo(int a, int b) +{ + return a || b ? baz() : foo(*bar(&a, &b), 1) + foo(1, 0); +} + +int main(void) +{ + if (foo(0, 0) != 2) + abort(); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr48975.c b/SingleSource/Regression/C/gcc-dg/pr48975.c new file mode 100644 index 0000000000..58658d8714 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr48975.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/48975 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -ffast-math -fno-tree-slp-vectorize" } */ + +static int +foo (int x) +{ + return (x > 0) ? 0 : x + 1; +} + +void +bar (unsigned int x) +{ + int l = 1; +lab: + while (x) + x = foo (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49000.c b/SingleSource/Regression/C/gcc-dg/pr49000.c new file mode 100644 index 0000000000..996b8f6b1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49000.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/49000 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +static int +foo (int x, int y) +{ + return x * y; +} + +static int +bar (int *z) +{ + return *z; +} + +void +baz (void) +{ + int a = 42; + int *b = &a; + foo (bar (&a), 3); +} + +void +test (void) +{ + baz (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49069.c b/SingleSource/Regression/C/gcc-dg/pr49069.c new file mode 100644 index 0000000000..f0fe1f2f08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49069.c @@ -0,0 +1,15 @@ +/* PR target/49069 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-tree-forwprop -Wno-div-by-zero" } */ + +int a; +const unsigned long long b[1] = { 1ULL }; +extern void bar (int); + +void +foo (void) +{ + for (a = 0; a == 1; a = 2) + ; + bar (b[0] == (a == 0 ? a : a / 0)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49120.c b/SingleSource/Regression/C/gcc-dg/pr49120.c new file mode 100644 index 0000000000..50993e69df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49120.c @@ -0,0 +1,12 @@ +/* PR c/49120 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ +/* { dg-require-effective-target alloca } */ + +int +main () +{ + int a = 1; + int c = ({ char b[a + 1]; b[0] = 0; b[0]; }); + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49235.c b/SingleSource/Regression/C/gcc-dg/pr49235.c new file mode 100644 index 0000000000..f1e589f755 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49235.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/49235 */ +/* { dg-do compile { target { int32plus } } } */ +/* { dg-options "-O -fno-delete-null-pointer-checks -fno-tree-scev-cprop -ftree-vectorize -fno-vect-cost-model -w" } */ + +void +foo (void) +{ + unsigned i; + unsigned *p = 0; + for (i = 0; i < 4; ++i) + *p++ = 0; + for (i = 0; i < 4; ++i) + *p++ = 0; +} + +void +bar (void) +{ + unsigned i; + unsigned *p = (unsigned *) (__UINTPTR_TYPE__) 0x12340000; + for (i = 0; i < 4; ++i) + *p++ = 0; + for (i = 0; i < 4; ++i) + *p++ = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49243.c b/SingleSource/Regression/C/gcc-dg/pr49243.c new file mode 100644 index 0000000000..78ac226aa2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49243.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/49243 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Winline" } */ + +extern unsigned long jb[]; +extern int my_setjmp(unsigned long jb[]) __attribute__((returns_twice)); +extern int decode(const char*); + +static inline int wrapper(const char **s_ptr) /* { dg-warning "(inlining failed|function 'wrapper' can never be inlined because it uses setjmp)" } */ +{ + if (my_setjmp(jb) == 0) { + const char *s = *s_ptr; + while (decode(s) != 0) + *s_ptr = ++s; + return 0; + } else + return -1; +} + +void parse(const char *data) +{ + const char *s = data; + if (!(wrapper(&s) == -1 && (s - data) == 1)) /* { dg-message "called from here" } */ + __builtin_abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49307.c b/SingleSource/Regression/C/gcc-dg/pr49307.c new file mode 100644 index 0000000000..e05659a8e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49307.c @@ -0,0 +1,21 @@ +/* PR target/49307 */ +/* { dg-do compile } */ +/* { dg-options "-O -fpic -fstack-protector" } */ +/* { dg-require-effective-target fpic } */ +/* { dg-require-effective-target fstack_protector } */ + +extern void bar (char **pp, void *vp); +extern void free (void *p); + +int +foo (void) +{ + char *p; + char fext[128]; + + p = fext; + bar (&p, (void *)0); + if (p) + free (p); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49496.c b/SingleSource/Regression/C/gcc-dg/pr49496.c new file mode 100644 index 0000000000..06563f3bcd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49496.c @@ -0,0 +1,20 @@ +/* PR debug/49496 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ + +unsigned short u[8], s1[8], s2[8]; + +void bar (unsigned short *); + +void +foo (void) +{ + unsigned short e[8]; + int i; + for (i = 0; i < 8; i++) + { + int tmp = s1[i] * s2[i]; + e[i] = (tmp & 0xffff0000) >> 16; + } + bar (e); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49544.c b/SingleSource/Regression/C/gcc-dg/pr49544.c new file mode 100644 index 0000000000..52f79dd7f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49544.c @@ -0,0 +1,22 @@ +/* PR debug/49544 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ +/* { dg-require-effective-target ptr32plus } */ + +__extension__ typedef __PTRDIFF_TYPE__ ptr_t; + +int baz (int, int, void *); + +static inline __attribute__ ((always_inline)) long +foo (int x, int y, void *z) +{ + if (y < 0) + return baz (x, y, z); + return 0; +} + +long +bar (long x, long y, long z) +{ + return foo (x, y, (void *) (ptr_t) z); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49551.c b/SingleSource/Regression/C/gcc-dg/pr49551.c new file mode 100644 index 0000000000..dda0667f3e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49551.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdata-sections" } */ +/* { dg-skip-if "-fdata-sections not supported" { hppa*-*-hpux* nvptx-*-* } } */ + +int x = 1; +int x; + +/* { dg-final { scan-assembler-not {comm[\t ]+x} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr49602.c b/SingleSource/Regression/C/gcc-dg/pr49602.c new file mode 100644 index 0000000000..bb8eeb0c33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49602.c @@ -0,0 +1,17 @@ +/* PR debug/49602 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ + +static void +foo (int *x) +{ +} + +void +bar (int *x) +{ + int i; + for (i = 0; i == 1; ++i) + x = 0; + foo (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49619.c b/SingleSource/Regression/C/gcc-dg/pr49619.c new file mode 100644 index 0000000000..d0a72a6edd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49619.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/49619 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-fre" } */ + +extern int a, b; + +void +foo (int x) +{ + a = 2; + b = 0; + b = (a && ((a = 1, 0 >= b) || (short) (x + (b & x)))); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49696.c b/SingleSource/Regression/C/gcc-dg/pr49696.c new file mode 100644 index 0000000000..8e5a018fc0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49696.c @@ -0,0 +1,29 @@ +/* { dg-require-effective-target sync_char_short } */ + +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ + +void +foo (short *x) +{ + __sync_val_compare_and_swap (x, 1, 0); + __sync_bool_compare_and_swap (x, 1, 0); + __sync_lock_test_and_set (x, 0); + + __sync_fetch_and_add (x, 0); + __sync_fetch_and_add (x, 0); + __sync_fetch_and_add (x, 0); + __sync_fetch_and_sub (x, 0); + __sync_fetch_and_and (x, 0); + __sync_fetch_and_or (x, 0); + __sync_fetch_and_xor (x, 0); + __sync_fetch_and_nand (x, 0); + + __sync_add_and_fetch (x, 0); + __sync_add_and_fetch (x, 0); + __sync_add_and_fetch (x, 0); + __sync_sub_and_fetch (x, 0); + __sync_and_and_fetch (x, 0); + __sync_or_and_fetch (x, 0); + __sync_xor_and_fetch (x, 0); + __sync_nand_and_fetch (x, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49705.c b/SingleSource/Regression/C/gcc-dg/pr49705.c new file mode 100644 index 0000000000..0c326ae3f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49705.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-overflow" } */ + +struct glyph +{ + long foo, bar, baz; +}; + +extern int fatal (char const *, int, int); + +int +check_image_width (int width, int height) +{ + if ((((((0 * (0 * 2 + width) - 1) < 0) ? - (~ (0 * (0 * 2 + width) + 0) == -1) - ((((0 * (0 * 2 + width) + 1) << (sizeof ((0 * 2 + width) + 0) * 8 - 2)) - 1) * 2 + 1) : (0 * (0 * 2 + width) + 0))) < 0 ? (2 < 0 ? width < ((((0 * (0 * 2 + width) - 1) < 0) ? - (~ (0 * (0 * 2 + width) + 0) == -1) - ((((0 * (0 * 2 + width) + 1) << (sizeof ((0 * 2 + width) + 0) * 8 - 2)) - 1) * 2 + 1) : (0 * (0 * 2 + width) + 0))) - 2 : ((((0 * (0 * 2 + width) - 1) < 0) ? ((((0 * (0 * 2 + width) + 1) << (sizeof ((0 * 2 + width) + 0) * 8 - 2)) - 1) * 2 + 1) : (0 * (0 * 2 + width) - 1))) - 2 < width) : width < 0 ? 2 <= width + 2 : 2 < 0 ? width <= width + 2 : width + 2 < 2) + || ((((((0 * (0 * height + (width + 2)) - 1) < 0) ? - (~ (0 * (0 * height + (width + 2)) + 0) == -1) - ((((0 * (0 * height + (width + 2)) + 1) << (sizeof ((0 * height + (width + 2)) + 0) * 8 - 2)) - 1) * 2 + 1) : (0 * (0 * height + (width + 2)) + 0))) == 0 && (((width + 2) < 0 && 0 < height) || (height < 0 && 0 < (width + 2)))) || (height < 0 ? ((width + 2) < 0 ? (width + 2) < ((((0 * (0 * height + (width + 2)) - 1) < 0) ? ((((0 * (0 * height + (width + 2)) + 1) << (sizeof ((0 * height + (width + 2)) + 0) * 8 - 2)) - 1) * 2 + 1) : (0 * (0 * height + (width + 2)) - 1))) / height : height == -1 ? 0 : ((((0 * (0 * height + (width + 2)) - 1) < 0) ? - (~ (0 * (0 * height + (width + 2)) + 0) == -1) - ((((0 * (0 * height + (width + 2)) + 1) << (sizeof ((0 * height + (width + 2)) + 0) * 8 - 2)) - 1) * 2 + 1) : (0 * (0 * height + (width + 2)) + 0))) / height < (width + 2)) : height == 0 ? 0 : ((width + 2) < 0 ? (width + 2) < ((((0 * (0 * height + (width + 2)) - 1) < 0) ? - (~ (0 * (0 * height + (width + 2)) + 0) == -1) - ((((0 * (0 * height + (width + 2)) + 1) << (sizeof ((0 * height + (width + 2)) + 0) * 8 - 2)) - 1) * 2 + 1) : (0 * (0 * height + (width + 2)) + 0))) / height : ((((0 * (0 * height + (width + 2)) - 1) < 0) ? ((((0 * (0 * height + (width + 2)) + 1) << (sizeof ((0 * height + (width + 2)) + 0) * 8 - 2)) - 1) * 2 + 1) : (0 * (0 * height + (width + 2)) - 1))) / height < (width + 2)))) + || ((9223372036854775807L < 18446744073709551615UL ? 9223372036854775807L : 18446744073709551615UL) / sizeof (struct glyph) + < (width + 2) * height)) + fatal ("screen size %dx%d too big", width, height); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49799.c b/SingleSource/Regression/C/gcc-dg/pr49799.c new file mode 100644 index 0000000000..61ac261be5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49799.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/49799 */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -w" } */ + +static __inline int bar(int a) +{ + int tmp; + + if (a <= 0) a ^= 0xFFFFFFFF; + + return tmp - 1; +} + +void foo(short *K) +{ + short tmp; + short *pptr, P[14]; + + pptr = P; + tmp = bar(*K); + *pptr = (*K << tmp) >> 16; + + if (*P < tmp) + *K++ = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49860.c b/SingleSource/Regression/C/gcc-dg/pr49860.c new file mode 100644 index 0000000000..faa5f1fd7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49860.c @@ -0,0 +1,21 @@ +/* { dg-do assemble } */ +/* { dg-options "-O3 -funroll-all-loops" } */ + +extern char inbuf[]; +extern char outbuf[]; +extern unsigned insize; +extern unsigned inptr; +static int max_len; +static int peek_bits; +void build_tree() { + int len; + char *prefixp; + max_len = inbuf[inptr++]; + peek_bits = ((max_len) <= (12) ? (max_len) : (12)); + prefixp = &outbuf[1< outbuf) *--prefixp = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49899.c b/SingleSource/Regression/C/gcc-dg/pr49899.c new file mode 100644 index 0000000000..b5b32591ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49899.c @@ -0,0 +1,3 @@ +static int foo (void) { return 0; } /* { dg-error "weak declaration of 'foo' being applied to a already existing, static definition" } */ +int foo (void) __attribute__((weak)); + diff --git a/SingleSource/Regression/C/gcc-dg/pr49948.c b/SingleSource/Regression/C/gcc-dg/pr49948.c new file mode 100644 index 0000000000..8a26d8ede3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49948.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/49948 */ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O3 -ftree-parallelize-loops=2" } */ + +extern int a, *b; +int +foo (void) +{ + int c, d = 8, *e[8], i; + if (a <= 7) + { + for (i = 0; i < 8; ++i) + e[i] = &c; + while (--d) + { + a = 0; + b = e[0]; + } + return 0; + } + return b == &d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49994-1.c b/SingleSource/Regression/C/gcc-dg/pr49994-1.c new file mode 100644 index 0000000000..62ac23bfc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49994-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fsched2-use-superblocks -g" } */ +/* { dg-require-effective-target nonlocal_goto } */ + +void x (int a) +{ + __label__ xlab; + void y (int b) + { + switch (b) + { + case 1: + goto xlab; + case 2: + goto xlab; + } + } + y (a); +xlab:; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49994-2.c b/SingleSource/Regression/C/gcc-dg/pr49994-2.c new file mode 100644 index 0000000000..e1ad6e97ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49994-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-omit-frame-pointer -fschedule-insns2 -fsched2-use-superblocks -g" } */ +/* { dg-require-effective-target scheduling } */ + +int +bar (int i) +{ + while (i) + if (i) + return i; +} + +void +foo () +{ + bar (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr49994-3.c b/SingleSource/Regression/C/gcc-dg/pr49994-3.c new file mode 100644 index 0000000000..72930932f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr49994-3.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsched2-use-superblocks -g -w" } */ +/* { dg-options "-O2 -fsched2-use-superblocks -g -mbackchain" { target s390*-*-* } } */ +/* { dg-require-effective-target scheduling } */ + +void * +foo (int offset) +{ + switch (offset) + { + case 0: + return __builtin_return_address (0); + case 1: + return __builtin_return_address (1); + case 2: + return __builtin_return_address (2); + case 3: + return __builtin_return_address (3); + case 4: + return __builtin_return_address (4); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50017.c b/SingleSource/Regression/C/gcc-dg/pr50017.c new file mode 100644 index 0000000000..66bef007da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50017.c @@ -0,0 +1,20 @@ +/* PR debug/50017 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ + +struct S { int r, i; }; + +void +foo (struct S *x, int y) +{ + int i; + for (i = 1; i < y; i++) + { + struct S a, b, c; + a = x[0]; + b = x[i]; + c.r = a.r * b.r - a.i * b.i; + c.i = a.r * b.i + a.i * b.r; + x[i] = c; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50078.c b/SingleSource/Regression/C/gcc-dg/pr50078.c new file mode 100644 index 0000000000..a8aee43fb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50078.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/50078 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned nonvolvar[2]; + +void +test (int arg) +{ + unsigned v = *(volatile unsigned *) (&nonvolvar[arg]); + *(volatile unsigned *) (&nonvolvar[arg]) = v; +} + +/* { dg-final { scan-assembler-times "movl\[^\n\r\]*nonvolvar" 2 { target { { i?86-*-* x86_64-*-* } && nonpic } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr50132.c b/SingleSource/Regression/C/gcc-dg/pr50132.c new file mode 100644 index 0000000000..84a9c731f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50132.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-asynchronous-unwind-tables -g" } */ + +void bar (long double n); + +void foo (int c) +{ + if (c) + bar (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50133.c b/SingleSource/Regression/C/gcc-dg/pr50133.c new file mode 100644 index 0000000000..2c0f490cfb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50133.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/50133 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-vectorize -fno-tree-loop-im" } */ + +extern int A[], B[]; + +void +foo (int z) +{ + int j, i; + for (j = 0; j < 32; j++) + { + int a = A[0]; + for (i = 0; i < 16; i++) + a = A[i] ? a : z; + B[j] = a; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50161.c b/SingleSource/Regression/C/gcc-dg/pr50161.c new file mode 100644 index 0000000000..b76ff9a0c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50161.c @@ -0,0 +1,21 @@ +/* PR middle-end/50161 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-ter -funroll-loops" } */ + +extern void abort (void); + +int +main () +{ + unsigned i; + unsigned long a[16]; + + for (i = 0; i < 16; i++) + a[i] = ~0UL; + + for (i = 0; i < 16; i++) + if (__builtin_popcountl (a[i]) != sizeof (a[i]) * 8) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50193-1.c b/SingleSource/Regression/C/gcc-dg/pr50193-1.c new file mode 100644 index 0000000000..6abc9c4057 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50193-1.c @@ -0,0 +1,10 @@ +/* PR 50193: ARM: ICE on a | (b << negative-constant) */ +/* Ensure that the compiler doesn't ICE. */ + +/* { dg-options "-O2" } */ + +int +foo(int a, int b) +{ + return a | (b << -3); /* { dg-warning "left shift count is negative" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50205.c b/SingleSource/Regression/C/gcc-dg/pr50205.c new file mode 100644 index 0000000000..ff523d07f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50205.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fno-cprop-registers -fno-dce -fno-forward-propagate -fselective-scheduling2 -funroll-loops -fno-web" } */ +extern int a[]; + +void foo (void) +{ + int i; + for (i = 0; i < 199; i++) + { + if (a[i] != i) + __builtin_abort (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50251.c b/SingleSource/Regression/C/gcc-dg/pr50251.c new file mode 100644 index 0000000000..57b3d971ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50251.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target { ! { x86_64-*-mingw* } } } } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mpreferred-stack-boundary=12" { target { { i?86-*-* x86_64-*-* } && lp64 } } } */ + +extern void bar (int*); + +char *p; + +int +main () +{ + int q; + p = __builtin_stack_save (); + bar (&q); + __builtin_stack_restore (p); + bar (&q); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50290.c b/SingleSource/Regression/C/gcc-dg/pr50290.c new file mode 100644 index 0000000000..47680fd9a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50290.c @@ -0,0 +1,27 @@ +/* PR rtl-optimization/50290 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-loop-optimize -fno-tree-vrp -funroll-loops" } */ + +static int +bar (int t[], int b) +{ + int i; + for (i = 0; i < b; i++) + t[i] = i + (i > 0 ? t[i - 1] : 0); + return t[b - 1]; +} + +static int +foo (int b) +{ + int x[b]; + return bar (x, b); +} + +int +main () +{ + if (foo (6) != 15) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50310-1.c b/SingleSource/Regression/C/gcc-dg/pr50310-1.c new file mode 100644 index 0000000000..e82276677e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50310-1.c @@ -0,0 +1,18 @@ +/* PR target/50310 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-options "-O3 -mavx -mno-avx2" { target avx_runtime } } */ + +double s1[4], s2[4]; +long long e[4]; + +int +main () +{ + int i; + asm volatile ("" : : : "memory"); + for (i = 0; i < 4; i++) + e[i] = __builtin_isunordered (s1[i], s2[i]) && s1[i] != s2[i] ? -1 : 0; + asm volatile ("" : : : "memory"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50310-2.c b/SingleSource/Regression/C/gcc-dg/pr50310-2.c new file mode 100644 index 0000000000..29621729e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50310-2.c @@ -0,0 +1,47 @@ +/* PR target/50310 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-options "-O3 -mavx" { target avx_runtime } } */ + +double s1[4], s2[4], s3[64]; + +int +main (void) +{ + int i; + asm volatile ("" : : : "memory"); + for (i = 0; i < 4; i++) + s3[0 * 4 + i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[1 * 4 + i] = (!__builtin_isgreater (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[2 * 4 + i] = __builtin_isgreaterequal (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[3 * 4 + i] = (!__builtin_isgreaterequal (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[4 * 4 + i] = __builtin_isless (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[5 * 4 + i] = (!__builtin_isless (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[6 * 4 + i] = __builtin_islessequal (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[7 * 4 + i] = (!__builtin_islessequal (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[8 * 4 + i] = __builtin_islessgreater (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[9 * 4 + i] = (!__builtin_islessgreater (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[10 * 4 + i] = __builtin_isunordered (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[11 * 4 + i] = (!__builtin_isunordered (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[12 * 4 + i] = s1[i] > s2[i] ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[13 * 4 + i] = s1[i] >= s2[i] ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[14 * 4 + i] = s1[i] < s2[i] ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[15 * 4 + i] = s1[i] <= s2[i] ? -1.0 : 0.0; + asm volatile ("" : : : "memory"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50340.c b/SingleSource/Regression/C/gcc-dg/pr50340.c new file mode 100644 index 0000000000..b608b3836d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50340.c @@ -0,0 +1,46 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O3 -fselective-scheduling2 -funroll-loops" } */ +extern int mode_size[]; +typedef unsigned HARD_REG_SET[ ((64 + 32 - 1) / 32) ]; +enum reload_type { + RELOAD_FOR_INPUT, + RELOAD_FOR_OUTPUT, + RELOAD_FOR_INSN, + RELOAD_FOR_INPUT_ADDRESS, + RELOAD_FOR_OUTPUT_ADDRESS, + RELOAD_FOR_OPERAND_ADDRESS, + RELOAD_FOR_OPADDR_ADDR, + RELOAD_OTHER, + RELOAD_FOR_OTHER_ADDRESS +}; +static HARD_REG_SET reload_reg_used; +static HARD_REG_SET reload_reg_used_in_input_addr[10]; +static HARD_REG_SET reload_reg_used_in_output_addr[10]; +static HARD_REG_SET reload_reg_used_in_input[10]; +static HARD_REG_SET reload_reg_used_in_output[10]; +static HARD_REG_SET reload_reg_used_in_op_addr; +static HARD_REG_SET reload_reg_used_in_op_addr_reload; +static HARD_REG_SET reload_reg_used_in_insn; +static HARD_REG_SET reload_reg_used_in_other_addr; +static HARD_REG_SET reload_reg_used_at_all; +void __attribute__((cold)) mark_reload_reg_in_use (int regno, int opnum, int type, int mode) +{ + int nregs = regno ? 1 : mode_size[mode]; + int i; + for (i = regno; i < nregs + regno; i++) + { + switch (type) + { + case RELOAD_OTHER: reload_reg_used[i / 32u] |= 1 << i % 32u; break; + case RELOAD_FOR_INPUT_ADDRESS: reload_reg_used_in_input_addr[opnum][i / 32u] |= 1 << i % 32u; break; + case RELOAD_FOR_OUTPUT_ADDRESS: reload_reg_used_in_output_addr[opnum][i / 32u] |= 1 << i % 32u; break; + case RELOAD_FOR_OPERAND_ADDRESS: reload_reg_used_in_op_addr[i / 32u] |= 1 << i % 32u; break; + case RELOAD_FOR_OPADDR_ADDR: reload_reg_used_in_op_addr_reload[i / 32u] |= 1 << i % 32u; break; + case RELOAD_FOR_OTHER_ADDRESS: reload_reg_used_in_other_addr[i / 32u] |= 1; break; + case RELOAD_FOR_INPUT: reload_reg_used_in_input[opnum][i / 32u] |= 1 << i % 32u; break; + case RELOAD_FOR_OUTPUT: reload_reg_used_in_output[opnum][i / 32u] |= 1 << i % 32u; break; + case RELOAD_FOR_INSN: reload_reg_used_in_insn[i / 32u] |= 1 << i % 32u; + } + reload_reg_used_at_all[i / 32u] |= 1 << i; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50527.c b/SingleSource/Regression/C/gcc-dg/pr50527.c new file mode 100644 index 0000000000..824c3fc603 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50527.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-Os --param large-stack-frame=30 -Wno-pointer-to-int-cast" } */ + +extern void abort (void); + +void __attribute__((noinline)) +bar (char *a) +{ +} + +void __attribute__((noinline)) +foo (char *a, int b) +{ +} + +void __attribute__((noinline)) +test_align (char *p, int aligned, unsigned int mask) +{ + int p_aligned = ((unsigned long int)p & mask) == 0; + if (aligned != p_aligned) + abort (); +} + +int +main () +{ + const int kIterations = 4; + char results[kIterations]; + int i; + unsigned int mask; + + mask = 0xf; + test_align (results, ((unsigned long int)results & mask) == 0, mask); + mask = 0x7; + test_align (results, ((unsigned long int)results & mask) == 0, mask); + mask = 0x3; + test_align (results, ((unsigned long int)results & mask) == 0, mask); + mask = 0x1; + test_align (results, ((unsigned long int)results & mask) == 0, mask); + + bar (results); + for (i = 0; i < kIterations; i++) + foo ("%d ", results[i]); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50571.c b/SingleSource/Regression/C/gcc-dg/pr50571.c new file mode 100644 index 0000000000..3fb4310d68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50571.c @@ -0,0 +1,11 @@ +/* PR inline-asm/50571 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +static const int var[4] = { 1, 2, 3, 4 }; + +void +foo (void) +{ + __asm volatile ("" : : "m" (*(int *) var)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50604.c b/SingleSource/Regression/C/gcc-dg/pr50604.c new file mode 100644 index 0000000000..1ab465a109 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50604.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/50604 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include "strlenopt.h" + +typedef char T; +extern const T s[]; + +void +foo (T *x) +{ + char *r = malloc (strlen (x)); + strcpy (r, s); + strcat (r, x); + strcat (r, "/"); +} + +const T s[] = "abcdefghijklmnopq"; diff --git a/SingleSource/Regression/C/gcc-dg/pr50613.c b/SingleSource/Regression/C/gcc-dg/pr50613.c new file mode 100644 index 0000000000..27c6fba363 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50613.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/50613 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-ccp" } */ + +#include "strlenopt.h" + +char buf[26]; + +static inline void +bar (char *__restrict dest, const char *__restrict src) +{ + strcpy (dest, src); +} + +void +foo (char *p) +{ + if (strlen (p) < 50) + bar (buf, p); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50717-1.c b/SingleSource/Regression/C/gcc-dg/pr50717-1.c new file mode 100644 index 0000000000..de691a8aec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50717-1.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/50717 */ +/* Ensure that widening multiply-and-accumulate is not used where integer + type promotion or users' casts should prevent it. */ + +/* { dg-options "-O2 -fdump-tree-widening_mul" } */ + +long long +f (unsigned int a, char b, long long c) +{ + return (a * b) + c; +} + +int +g (short a, short b, int c) +{ + return (short)(a * b) + c; +} + +int +h (char a, char b, int c) +{ + return (char)(a * b) + c; +} + +/* { dg-final { scan-tree-dump-times "WIDEN_MULT_PLUS_EXPR" 0 "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr50763-2.c b/SingleSource/Regression/C/gcc-dg/pr50763-2.c new file mode 100644 index 0000000000..a9d12e8f54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50763-2.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef union tree_node *tree; + +struct tree_base +{ + int code; +}; + +struct tree_typed +{ + struct tree_base base; + tree type; +}; + +struct tree_common +{ + struct tree_typed typed; +}; + +struct tree_type_common +{ + tree main_variant; +}; + +union tree_node +{ + struct tree_base base; + struct tree_typed typed; + struct tree_type_common type_common; +}; + +int std_canonical_va_list_type (tree type) +{ + if (type->base.code) + type = type->typed.type; + else + if (type->typed.type->base.code) + type = type->typed.type; + + if (type->type_common.main_variant) + return 1; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50763-5.c b/SingleSource/Regression/C/gcc-dg/pr50763-5.c new file mode 100644 index 0000000000..e5952d09c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50763-5.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge" } */ + +struct inode +{ + unsigned short i_mode; + unsigned int i_flags; +}; + +static inline int +is_sxid (unsigned int mode) +{ + return (mode & 0004000) || ((mode & 0002000) && (mode & 00010)); +}; + +void +gfs2_set_inode_flags (int ip, struct inode *inode) +{ + unsigned int flags = inode->i_flags; + if ((ip == 0) && !is_sxid (inode->i_mode)) + inode->i_flags |= 4096; + inode->i_flags = flags; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50763.c b/SingleSource/Regression/C/gcc-dg/pr50763.c new file mode 100644 index 0000000000..102056f1dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50763.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fno-tree-dominator-opts" } */ + +int bar (int i); + +void +foo (int c, int d) +{ + if (bar (c)) + bar (c); + d = 33; + while (c == d); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50764.c b/SingleSource/Regression/C/gcc-dg/pr50764.c new file mode 100644 index 0000000000..e0cd320db0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50764.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsched2-use-superblocks -ftree-tail-merge" } */ +/* { dg-require-effective-target alloca } */ + +typedef int aligned __attribute__ ((aligned (64))); +extern void abort (void); + +int bar (void *p); + +void +foo (void) +{ + char *p = __builtin_alloca (13); + aligned i; + + if (bar (p) || bar (&i)) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50765.c b/SingleSource/Regression/C/gcc-dg/pr50765.c new file mode 100644 index 0000000000..6e1c697475 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50765.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/50765 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-dce" } */ + +void +foo (long *w, long *x, unsigned char *y, int z) +{ + for (; z < 429; z++) + w[z] = (-19 ^ y[z]) & x[z]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50827.c b/SingleSource/Regression/C/gcc-dg/pr50827.c new file mode 100644 index 0000000000..5d258bfcf0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50827.c @@ -0,0 +1,17 @@ +/* PR debug/50827 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -funroll-loops" } */ + +void +foo (int w, int x, int *y, int *z) +{ + float f; + while (w--) + { + f = x; + if (y) + *y = (__INTPTR_TYPE__) y + w; + if (z) + *z = w; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50908-2.c b/SingleSource/Regression/C/gcc-dg/pr50908-2.c new file mode 100644 index 0000000000..1c06da7b35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50908-2.c @@ -0,0 +1,80 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fno-short-enums" } */ + +typedef struct rtx_def *rtx; +enum debug_info_levels +{ + ARM_FLOAT_ABI_SOFT, ARM_FLOAT_ABI_SOFTFP, ARM_FLOAT_ABI_HARD +}; +struct gcc_options +{ + int x_target_flags; +}; +extern struct gcc_options global_options; +extern int arm_arch_thumb2; +enum rtx_code +{ + UNSPEC, UNSPEC_VOLATILE, ADDR_VEC, SET, CLOBBER, CALL, RETURN, + SIMPLE_RETURN, EH_RETURN, TRAP_IF, CONST_INT, CONST_FIXED, CONST_DOUBLE, + CONST_VECTOR, CONST_STRING, CONST, PC, REG, SCRATCH, SUBREG, + STRICT_LOW_PART, CONCAT, CONCATN, MEM, LABEL_REF, SYMBOL_REF, CC0, + IF_THEN_ELSE, COMPARE, PLUS, MINUS, NEG, MULT, SS_MULT, US_MULT, DIV, + SS_DIV, US_DIV, MOD, UDIV, UMOD, AND, IOR, XOR, NOT, ASHIFT, ROTATE, + ASHIFTRT, LSHIFTRT, ROTATERT, PRE_DEC, PRE_INC, POST_DEC, POST_INC, + PRE_MODIFY, POST_MODIFY, NE, EQ, GE, GT, LE, LT, GEU, GTU, LEU, LTU, + UNORDERED, ORDERED, UNEQ, UNGE, UNGT, UNLE, UNLT, LTGT, SIGN_EXTEND, + ZERO_EXTEND, TRUNCATE, FLOAT_EXTEND, FLOAT_TRUNCATE, FLOAT, FIX, + UNSIGNED_FLOAT, UNSIGNED_FIX, SIGN_EXTRACT, ZERO_EXTRACT, HIGH, LO_SUM, + VEC_MERGE, VEC_SELECT, VEC_CONCAT, VEC_DUPLICATE, SS_PLUS, US_PLUS, + SS_MINUS, SS_NEG, US_NEG, SS_ABS, SS_ASHIFT, US_ASHIFT, US_MINUS, + SS_TRUNCATE, US_TRUNCATE, FMA, VAR_LOCATION, DEBUG_IMPLICIT_PTR, + ENTRY_VALUE, DEBUG_PARAMETER_REF, LAST_AND_UNUSED_RTX_CODE +}; +union rtunion_def +{ +}; +struct rtx_def +{ + enum rtx_code code:16; +} +builtin_info_type; +enum constraint_num +{ + CONSTRAINT__UNKNOWN = + 0, CONSTRAINT_f, CONSTRAINT_t, CONSTRAINT_v, CONSTRAINT_w, CONSTRAINT_x, + CONSTRAINT_y, CONSTRAINT_z, CONSTRAINT_l, CONSTRAINT_h, CONSTRAINT_j, + CONSTRAINT_Pj, CONSTRAINT_PJ, CONSTRAINT_k, CONSTRAINT_b, CONSTRAINT_c, + CONSTRAINT_I, CONSTRAINT_J, CONSTRAINT_K, CONSTRAINT_L, CONSTRAINT_M, + CONSTRAINT_N, CONSTRAINT_O, CONSTRAINT_Pa, CONSTRAINT_Pb, CONSTRAINT_Pc, + CONSTRAINT_Pd, CONSTRAINT_Ps, CONSTRAINT_Pt, CONSTRAINT_Pu, CONSTRAINT_Pv, + CONSTRAINT_Pw, CONSTRAINT_Px, CONSTRAINT_Py, CONSTRAINT_G, CONSTRAINT_H, + CONSTRAINT_Dz, CONSTRAINT_Da, CONSTRAINT_Db, CONSTRAINT_Dc, CONSTRAINT_Di, + CONSTRAINT_Dn, CONSTRAINT_Dl, CONSTRAINT_DL, CONSTRAINT_Dv, CONSTRAINT_Dy, + CONSTRAINT_Ut, CONSTRAINT_Uv, CONSTRAINT_Uy, CONSTRAINT_Un, CONSTRAINT_Um, + CONSTRAINT_Us, CONSTRAINT_Uq, CONSTRAINT_Q, CONSTRAINT_Uu, CONSTRAINT_Uw, + CONSTRAINT__LIMIT +}; +typedef struct VEC_char_base +{ +} +VEC_int_heap; +static inline int +satisfies_constraint_j (rtx op) +{ + long long ival = 0; + return ((((!((global_options.x_target_flags & (1 << 14)) != 0)) + || arm_arch_thumb2) && arm_arch_thumb2)) + && ((((enum rtx_code) (op)->code) == HIGH) + || ((((enum rtx_code) (op)->code) == CONST_INT) + && (((ival & 0xffff0000) == 0)))); +} + +int +constraint_satisfied_p (rtx op, enum constraint_num c) +{ + switch (c) + { + case CONSTRAINT_j: + return satisfies_constraint_j (op); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50908-3.c b/SingleSource/Regression/C/gcc-dg/pr50908-3.c new file mode 100644 index 0000000000..9103e6bdf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50908-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge" } */ + +extern int v1; +extern int v2; +void g (void); + +void +f () +{ + if (v2 || v1) + (!(v1)) ? (void) 0 : (void) g (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr50908.c b/SingleSource/Regression/C/gcc-dg/pr50908.c new file mode 100644 index 0000000000..114dded3ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr50908.c @@ -0,0 +1,179 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -ftree-tail-merge" } */ + +enum Lisp_Type +{ + Lisp_Int0 = 0, Lisp_Int1 = 4, Lisp_Symbol = 2, Lisp_Misc = 3, Lisp_String = + 1, Lisp_Vectorlike = 5, Lisp_Cons = 6, Lisp_Float = 7, +}; +typedef long Lisp_Object; +enum pvec_type +{ + PVEC_NORMAL_VECTOR = 0, PVEC_PROCESS = 0x200, PVEC_FRAME = + 0x400, PVEC_COMPILED = 0x800, PVEC_WINDOW = + 0x1000, PVEC_WINDOW_CONFIGURATION = 0x2000, PVEC_SUBR = + 0x4000, PVEC_CHAR_TABLE = 0x8000, PVEC_BOOL_VECTOR = + 0x10000, PVEC_BUFFER = 0x20000, PVEC_HASH_TABLE = 0x40000, PVEC_TERMINAL = + 0x80000, PVEC_SUB_CHAR_TABLE = 0x100000, PVEC_FONT = + 0x200000, PVEC_OTHER = 0x400000, PVEC_TYPE_MASK = 0x7ffe00 +}; +struct Lisp_Vector +{ + unsigned long size; +}; +struct Lisp_Char_Table +{ + Lisp_Object defalt; + Lisp_Object ascii; +}; +struct Lisp_Sub_Char_Table +{ + Lisp_Object contents[1]; +}; +extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound; +struct buffer_text +{ + unsigned char *beg; + long gpt_byte; + long gap_size; +}; +struct buffer +{ + struct buffer_text *text; + struct region_cache *width_run_cache; + Lisp_Object tab_width; + Lisp_Object ctl_arrow; +}; +extern struct buffer *current_buffer; +extern Lisp_Object Vchar_width_table; +struct frame +{ + long text_lines, text_cols; +}; +struct window +{ + Lisp_Object frame; +}; +extern Lisp_Object Vtruncate_partial_width_windows; +extern struct Lisp_Char_Table *window_display_table (struct window *); +long find_before_next_newline (long, long, long); +long disp_char_vector (struct Lisp_Char_Table *, int); +long char_table_ref (Lisp_Object, int); +struct position * +compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, + width, hscroll, tab_offset, win) + int did_motion, width, hscroll, tab_offset; + long from, fromvpos, fromhpos, to, tovpos, tohpos; + struct window *win; +{ + register long hpos = fromhpos; + register long pos; + long pos_byte; + register int c = 0; + register struct Lisp_Char_Table *dp = window_display_table (win); + long wide_column_end_hpos = 0; + long continuation_glyph_width; + while (1) + { + if (hpos > width) + { + int total_width = width + continuation_glyph_width; + if (!((Vtruncate_partial_width_windows) == (Qnil)) + && (total_width < + (((void) 0, + (struct frame + *) ((long) (((win)->frame) & ~((((long) 1) << 3) - + 1)))))->text_cols)) + { + if (pos <= to) + { + pos = find_before_next_newline (pos, to, 1); + } + if (wide_column_end_hpos > width) + { + hpos -= width; + } + } + } + else + { + Lisp_Object charvec; + c = + *(((((pos_byte)) >= + (current_buffer->text->gpt_byte) ? (current_buffer->text-> + gap_size) : 0) + + ((pos_byte)) + (current_buffer->text->beg) - ((1)))); + if (current_buffer->width_run_cache) + { + if (((((enum Lisp_Type) (((unsigned long) ((charvec))) & + ((((long) 1) << 3) - 1))) == + Lisp_Vectorlike) + && + !(((void) 0, + (struct Lisp_Vector + *) ((long) ((charvec) & ~((((long) 1) << 3) - 1))))-> + size & ((((unsigned long) 1 << (64 - 1)) >> 1))))) + { + unsigned char *ptr; + int bytes, width, wide_column; + do + { + if ((!((*ptr) & 0x80) ? 1 : !((*ptr) & 0x20) ? 2 : + !((*ptr) & 0x10) ? 3 : !((*ptr) & 0x08) ? 4 : 5) != + bytes) + width = bytes * 4; + else + { + if (dp != 0 + && + ((((enum + Lisp_Type) (((unsigned + long) (((((unsigned) (c) < + 0x80) + ? ((((dp)->ascii) == + (Qnil)) ? (dp)-> + defalt + : (((((enum + Lisp_Type) + (((unsigned + long) (((dp)->ascii))) & ((((long) 1) << 3) - 1))) == Lisp_Vectorlike) && (((((void) 0, (struct Lisp_Vector *) ((long) (((dp)->ascii) & ~((((long) 1) << 3) - 1))))->size & (((((unsigned long) 1 << (64 - 1)) >> 1)) | (PVEC_SUB_CHAR_TABLE)))) == (((((unsigned long) 1 << (64 - 1)) >> 1)) | (PVEC_SUB_CHAR_TABLE)))) ? ((void) 0, (struct Lisp_Sub_Char_Table *) ((long) (((dp)->ascii) & ~((((long) 1) << 3) - 1))))->contents[c] : (dp)->ascii)) : disp_char_vector ((dp), (c)))))) & ((((long) 1) << 3) - 1))) == Lisp_Vectorlike) && !(((void) 0, (struct Lisp_Vector *) ((long) (((((unsigned) (c) < 0x80) ? ((((dp)->ascii) == (Qnil)) ? (dp)->defalt : (((((enum Lisp_Type) (((unsigned long) (((dp)->ascii))) & ((((long) 1) << 3) - 1))) == Lisp_Vectorlike) && (((((void) 0, (struct Lisp_Vector *) ((long) (((dp)->ascii) & ~((((long) 1) << 3) - 1))))->size & (((((unsigned long) 1 << (64 - 1)) >> 1)) | (PVEC_SUB_CHAR_TABLE)))) == (((((unsigned long) 1 << (64 - 1)) >> 1)) | (PVEC_SUB_CHAR_TABLE)))) ? ((void) 0, (struct Lisp_Sub_Char_Table *) ((long) (((dp)->ascii) & ~((((long) 1) << 3) - 1))))->contents[c] : (dp)->ascii)) : disp_char_vector ((dp), (c)))) & ~((((long) 1) << 3) - 1))))->size & ((((unsigned long) 1 << (64 - 1)) >> 1))))) + width = + ((void) 0, + (struct Lisp_Vector + *) ((long) (((((unsigned) (c) < + 0x80) ? ((((dp)->ascii) == + (Qnil)) ? (dp)-> + defalt + : (((((enum + Lisp_Type) (((unsigned long) (((dp)->ascii))) & ((((long) 1) << 3) - 1))) == Lisp_Vectorlike) && (((((void) 0, (struct Lisp_Vector *) ((long) (((dp)->ascii) & ~((((long) 1) << 3) - 1))))->size & (((((unsigned long) 1 << (64 - 1)) >> 1)) | (PVEC_SUB_CHAR_TABLE)))) == (((((unsigned long) 1 << (64 - 1)) >> 1)) | (PVEC_SUB_CHAR_TABLE)))) ? ((void) 0, (struct Lisp_Sub_Char_Table *) ((long) (((dp)->ascii) & ~((((long) 1) << 3) - 1))))->contents[c] : (dp)->ascii)) : disp_char_vector ((dp), (c)))) & ~((((long) 1) << 3) - 1))))->size; + else + width = + (((unsigned) (c) < 0x80) ? (c < + 0x20 ? (c == + '\t' + ? ((((long) + (current_buffer-> + tab_width)) + >> (3 - + 1))) + : (c == + '\n' ? 0 + : (((current_buffer->ctl_arrow) == (Qnil)) ? 4 : 2))) : (c < 0x7f ? 1 : ((((current_buffer->ctl_arrow) == (Qnil)) ? 4 : 2)))) : (((long) ((((unsigned) (c) < 0x80) ? ( + { + Lisp_Object + _val; + _val;} + ): char_table_ref ((Vchar_width_table), (c))))) >> (3 - 1))); + if (width > 1) + wide_column = width; + } + } + while (0); + if (wide_column) + wide_column_end_hpos = hpos + wide_column; + } + } + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51012-1.c b/SingleSource/Regression/C/gcc-dg/pr51012-1.c new file mode 100644 index 0000000000..36c788bd52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51012-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-early-inlining -fno-ipa-cp" } */ + +float baz (void) +{ + return 0; +} + +static inline int bar (int (*ibaz) (void)) +{ + return ibaz (); +} + +void foo (void) +{ + bar((int (*)(void))baz); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51012-2.c b/SingleSource/Regression/C/gcc-dg/pr51012-2.c new file mode 100644 index 0000000000..fcc8cea7b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51012-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-early-inlining" } */ + +float baz (void) +{ + return 0; +} + +static inline int bar (int (*ibaz) (void)) +{ + return ibaz (); +} + +void foo (void) +{ + bar((int (*)(void))baz); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51034.c b/SingleSource/Regression/C/gcc-dg/pr51034.c new file mode 100644 index 0000000000..c9b9c27c9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51034.c @@ -0,0 +1,14 @@ +/* PR c/51034 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +struct S; + +int +main () +{ + struct R { typeof (((struct W) {})) x; } r; /* { dg-error "invalid use of undefined type" } */ + struct S { typeof (((struct S) {})) x; } s; /* { dg-error "invalid use of undefined type" } */ + struct T { int x[sizeof ((struct T) {})]; } t;/* { dg-error "invalid use of undefined type" } */ + struct U { int x[sizeof((struct V){})];} u; /* { dg-error "invalid use of undefined type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51039.c b/SingleSource/Regression/C/gcc-dg/pr51039.c new file mode 100644 index 0000000000..863a6ff164 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51039.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O -finline-small-functions -fno-ipa-pure-const" } */ + +float baz (void) +{ + return 0; +} + +static inline int bar (int (*ibaz) (void)) +{ + return ibaz (); +} + +void foo (void) +{ + bar((int (*)(void))baz); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51261.c b/SingleSource/Regression/C/gcc-dg/pr51261.c new file mode 100644 index 0000000000..b599a6b7db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51261.c @@ -0,0 +1,9 @@ +/* PR target/51261 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug" } */ + +void +foo (void *p, int n) +{ + __builtin_memset (p, 0xff, n); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51321.c b/SingleSource/Regression/C/gcc-dg/pr51321.c new file mode 100644 index 0000000000..0e836cfe6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51321.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +int main () +{ + return (__builtin_types_compatible_p (char[1][], char[1][1])); /* { dg-error "array type has incomplete element type" } */ +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr51408.c b/SingleSource/Regression/C/gcc-dg/pr51408.c new file mode 100644 index 0000000000..2cc5cf967b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51408.c @@ -0,0 +1,22 @@ +/* This testcase used to fail because of a bug in + arm.md:*minmax_arithsi. */ + +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +extern void abort (void); + +int __attribute__((noinline)) +foo (int a, int b) +{ + int max = (b > 0) ? b : 0; + return max - a; +} + +int +main (void) +{ + if (foo (3, -1) != -3) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51481.c b/SingleSource/Regression/C/gcc-dg/pr51481.c new file mode 100644 index 0000000000..a35f8f3875 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51481.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/51481 */ +/* { dg-do compile } */ +/* { dg-options "-O -fexceptions -fipa-cp -fipa-cp-clone" } */ +/* { dg-require-effective-target exceptions } */ + +extern const unsigned short int **foo (void) + __attribute__ ((__nothrow__, __const__)); +struct S { unsigned short s1; int s2; }; +extern struct S *s[26]; + +void +bar (int x, struct S *y, ...) +{ + static struct S *t; + __builtin_va_list ap; + __builtin_va_start (ap, y); + if (t != s[7]) + { + const char *p = "aAbBc"; + t = s[7]; + while ((*foo ())[(unsigned char) *p]) + p++; + } + __builtin_printf (x == 0 ? "abc\n" : "def\n"); + if (y != 0) + __builtin_printf ("ghi %d %d", y->s2, y->s1); + __builtin_va_end (ap); +} + +void +baz (char *x) +{ + bar (1, 0, x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51491-2.c b/SingleSource/Regression/C/gcc-dg/pr51491-2.c new file mode 100644 index 0000000000..429ee4e591 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51491-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ +/* { dg-require-effective-target alloca } */ + +int g (int *); + +int +f (int n) +{ + int tt = 0; + int t = 4; + { + int a[t + + (tt != 0 ? 6 : 0) + ]; + tt = g (a); + { + int b[n]; + tt += g (b); + if (n > 20) + tt += 148 * g (b); + tt += b[0]; + } + tt += a[0]; + } + { + int a[4]; + tt += g (a); + tt += a[0]; + } + return tt; +} + +/* { dg-final { scan-tree-dump-times "CLOBBER" 2 "ccp1"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51491.c b/SingleSource/Regression/C/gcc-dg/pr51491.c new file mode 100644 index 0000000000..767769c01f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51491.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-expand" } */ + + +int g(int*); + +int f(void) +{ + int tt = 0; + int t = 4; + { + int a[t]; + tt = g(a); + tt += a[0]; + } + { + int a[4]; + tt += g(a); + tt += a[0]; + } + return tt; +} + +/* { dg-final { scan-rtl-dump-times "Partition" 1 "expand"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51505.c b/SingleSource/Regression/C/gcc-dg/pr51505.c new file mode 100644 index 0000000000..dbcd3226d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51505.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/51505 */ +/* { dg-do compile } */ +/* { dg-options "-O --param max-cse-insns=1" } */ +struct S +{ +char a[256]; +}; + +int bar(struct S, char[16]); + +void foo () +{ + struct S u, s1, s2; + char e[256]; + char i; + e[i] = ~s1.a[i] & s2.a[i]; + if (bar(u, e)) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51519.c b/SingleSource/Regression/C/gcc-dg/pr51519.c new file mode 100644 index 0000000000..3d5d3f2439 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51519.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-guess-branch-probability -findirect-inlining" } */ + +void fe (void); +int i; + +static inline void +FX (void (*f) (void)) +{ + fe (); + (*f) (); +} + +static inline void +f4 () +{ + if (i) + FX (fe); +} + +static inline void +f3 (void) +{ + f4 (); + if (i) + FX (f4); +} + +static inline void +f2 (void) +{ + FX (&f3); +} + +void +f1 (void) +{ + FX (&f2); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51557.c b/SingleSource/Regression/C/gcc-dg/pr51557.c new file mode 100644 index 0000000000..692cd00e9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51557.c @@ -0,0 +1,17 @@ +/* PR debug/51557 */ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fno-asynchronous-unwind-tables -g -fsel-sched-pipelining -fselective-scheduling2" } */ + +extern int baz (void); +extern void bar (int, int, int, int, int, int, int); + +void +synth (int *values, int n_values, int ci, int s1, int v, int s2) +{ + while (--s1) + { + int r1 = values[s1]; + int co = ci ? r1 : baz () < r1; + bar (0, n_values, s1, s2, v, co, 0); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-17.c b/SingleSource/Regression/C/gcc-dg/pr51628-17.c new file mode 100644 index 0000000000..42dc9d745d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-17.c @@ -0,0 +1,10 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-incompatible-pointer-types" } */ + +struct A { + int i; +} __attribute__ ((packed)); + +long* f8 (struct A *p) { return &p->i; } +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-18.c b/SingleSource/Regression/C/gcc-dg/pr51628-18.c new file mode 100644 index 0000000000..03a04eff75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-18.c @@ -0,0 +1,23 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +void foo (int *); + +int * +bar (int n, int k, void *ptr) +{ + struct A + { + int c[k]; + int x[n]; + } __attribute__ ((packed, aligned (4))); + struct A *p = (struct A *) ptr; + + int *p0, *p1; + p0 = p->x; + foo (p0); + p1 = &p->x[1]; + foo (p1); + return &p->x[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-19.c b/SingleSource/Regression/C/gcc-dg/pr51628-19.c new file mode 100644 index 0000000000..91ff39abc8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-19.c @@ -0,0 +1,26 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +void foo (int *); + +int * +bar (int n, int k, void *ptr) +{ + struct A + { + char c[k]; + int x[n]; + } __attribute__ ((packed)); + struct A *p = (struct A *) ptr; + + int *p0, *p1; + p0 = p->x; +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ + foo (p0); + p1 = &p->x[1]; +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ + foo (p1); + return &p->x[1]; +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-20.c b/SingleSource/Regression/C/gcc-dg/pr51628-20.c new file mode 100644 index 0000000000..2249d85098 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-20.c @@ -0,0 +1,11 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-incompatible-pointer-types" } */ + +struct B { int i; }; +struct C { struct B b; } __attribute__ ((packed)); + +extern struct C *p; + +long* g8 (void) { return p; } +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-21.c b/SingleSource/Regression/C/gcc-dg/pr51628-21.c new file mode 100644 index 0000000000..f1adbe6400 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-21.c @@ -0,0 +1,11 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-incompatible-pointer-types" } */ + +struct B { int i; }; +struct C { struct B b; } __attribute__ ((packed)); + +extern struct C p[]; + +long* g8 (void) { return p; } +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-22.c b/SingleSource/Regression/C/gcc-dg/pr51628-22.c new file mode 100644 index 0000000000..25ac36cf0a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-22.c @@ -0,0 +1,9 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-incompatible-pointer-types" } */ + +struct B { int i; }; +struct C { struct B b; } __attribute__ ((packed)); + +int* g4 (struct C *p) { return &p->b; } +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-23.c b/SingleSource/Regression/C/gcc-dg/pr51628-23.c new file mode 100644 index 0000000000..5709be60ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-23.c @@ -0,0 +1,9 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-incompatible-pointer-types" } */ + +struct A { + int i; +} __attribute__ ((packed)); + +char* f0 (struct A *p) { return &p->i; } diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-24.c b/SingleSource/Regression/C/gcc-dg/pr51628-24.c new file mode 100644 index 0000000000..1e454a1dc0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-24.c @@ -0,0 +1,10 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-incompatible-pointer-types" } */ + +struct A { + int i; +} __attribute__ ((packed)); + +short* f2 (struct A *p) { return &p->i; } +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-25.c b/SingleSource/Regression/C/gcc-dg/pr51628-25.c new file mode 100644 index 0000000000..f00d9b1bca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-25.c @@ -0,0 +1,9 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-incompatible-pointer-types" } */ + +struct B { int i; }; +struct C { struct B b; } __attribute__ ((packed)); + +long* g8 (struct C *p) { return p; } +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51628-34.c b/SingleSource/Regression/C/gcc-dg/pr51628-34.c new file mode 100644 index 0000000000..0f6ae34fb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51628-34.c @@ -0,0 +1,25 @@ +/* PR c/51628. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-incompatible-pointer-types" } */ + +struct __attribute__((packed)) S { char p; int a, b, c; }; + +short * +baz (int x, struct S *p) +{ + return (x + ? &p->a +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ + : &p->b); +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ +} + +short * +qux (int x, struct S *p) +{ + return (short *) (x + ? &p->a +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ + : &p->b); +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51644.c b/SingleSource/Regression/C/gcc-dg/pr51644.c new file mode 100644 index 0000000000..e23c02f9fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51644.c @@ -0,0 +1,34 @@ +/* PR middle-end/51644 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -fexceptions" } */ +/* { dg-require-effective-target exceptions } */ + +#include + +extern void baz (int, va_list) __attribute__ ((__noreturn__)); + +__attribute__ ((__noreturn__)) +void +foo (int s, ...) +{ + va_list ap; + va_start (ap, s); + baz (s, ap); + va_end (ap); +} /* { dg-bogus "function does return" } */ + +__attribute__ ((__noreturn__)) +void +bar (int s, ...) +{ + va_list ap1; + va_start (ap1, s); + { + va_list ap2; + va_start (ap2, s); + baz (s, ap1); + baz (s, ap2); + va_end (ap2); + } + va_end (ap1); +} /* { dg-bogus "function does return" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51683.c b/SingleSource/Regression/C/gcc-dg/pr51683.c new file mode 100644 index 0000000000..7a624e4055 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51683.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/51683 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +static inline void * +bar (void *p, void *q, int r) +{ + return __builtin_memcpy (p, q, r); +} + +void * +foo (void *p) +{ + return bar ((void *) 0x12345000, p, 256); + /* Integers converted to pointers are assumed to be the result of + (invalid) arithmetic on null pointers. + { dg-prune-output "writing 256 bytes into a region of size 0" } */ +} + +/* { dg-final { scan-tree-dump "memcpy" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51695.c b/SingleSource/Regression/C/gcc-dg/pr51695.c new file mode 100644 index 0000000000..6eb45400b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51695.c @@ -0,0 +1,52 @@ +/* PR debug/51695 */ +/* { dg-do compile { target { int32plus } } } */ +/* { dg-options "-O2 -g" } */ + +typedef struct +{ + struct { unsigned int t1, t2, t3, t4, t5, t6; } t; + int p; + struct { double X, Y, Z; } r; +} T; +typedef struct { T *h; } S; + +static unsigned int v = 0x12345678; + +int +foo (void) +{ + v = (v & 0x80000000) ? ((v << 1) ^ 0xa398655d) : (v << 1); + return 0; +} + +double +bar (void) +{ + unsigned int o; + v = (v & 0x80000000) ? ((v << 1) ^ 0xa398655d) : (v << 1); + o = v & 0xffff; + return (double) o / 32768.0; +} + +int +baz (void) +{ + foo (); + return 0; +} + +void +test (S *x) +{ + T *t = x->h; + t->t.t1 = foo (); + t->t.t2 = foo (); + t->t.t3 = foo (); + t->t.t4 = foo (); + t->t.t5 = foo (); + t->t.t6 = foo (); + t->p = baz (); + t->r.X = bar (); + t->r.Y = bar (); + t->r.Z = bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51721.c b/SingleSource/Regression/C/gcc-dg/pr51721.c new file mode 100644 index 0000000000..b39adfb50c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51721.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/51721 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +static int a[10], b[10], c[10], d[10]; + +unsigned int +f (unsigned int v) +{ + return v == 17 ? 11 : v; +} + +unsigned int +g (unsigned int v) +{ + return v == 17 ? 17 : v; +} + +void +t (unsigned int s) +{ + if (s >> 1 == 0) + { + a[f (s)] = 0; /* { dg-bogus "array subscript is above array bounds" } */ + a[f (s)] = 0; /* { dg-bogus "array subscript is above array bounds" } */ + b[f (s)] = 0; /* { dg-bogus "array subscript is above array bounds" } */ + c[g (s)] = 0; /* { dg-bogus "array subscript is above array bounds" } */ + c[g (s)] = 0; /* { dg-bogus "array subscript is above array bounds" } */ + d[f (s)] = 0; /* { dg-bogus "array subscript is above array bounds" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51762.c b/SingleSource/Regression/C/gcc-dg/pr51762.c new file mode 100644 index 0000000000..9c59f338c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51762.c @@ -0,0 +1,19 @@ +/* PR debug/51762 */ +/* { dg-do compile } */ +/* { dg-options "-g -Os -fomit-frame-pointer -fno-asynchronous-unwind-tables" } */ + +void noret (void) __attribute__ ((noreturn)); +int bar (void); +void baz (const char *); +static int v = -1; + +void +foo (void) +{ + if (bar () && v == -1) + { + baz ("baz"); + noret (); + } + noret (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51796.c b/SingleSource/Regression/C/gcc-dg/pr51796.c new file mode 100644 index 0000000000..64a6095351 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51796.c @@ -0,0 +1,16 @@ +/* PR bootstrap/51796 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-omit-frame-pointer -fno-tree-dominator-opts -fno-tree-fre -fno-tree-pre" } */ + +void stop (void); +typedef void (*entry_func) (void) __attribute__ ((noreturn)); +extern entry_func entry_addr; +static void bsd_boot_entry (void) +{ + stop (); +} +void bsd_boot (void) +{ + entry_addr = (entry_func) bsd_boot_entry; + (*entry_addr) (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51821.c b/SingleSource/Regression/C/gcc-dg/pr51821.c new file mode 100644 index 0000000000..f2571123f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51821.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99 -O2" } */ +/* { dg-additional-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ + +extern void abort (void); + +unsigned int __attribute__((noinline)) +test (int shift_size) +{ + unsigned long long res = ~0; + + return res << shift_size; +} + +int +main () +{ + int dst = 32; + + if (test (dst) != 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51865.c b/SingleSource/Regression/C/gcc-dg/pr51865.c new file mode 100644 index 0000000000..9b4595cce0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51865.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/51865 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fipa-pta" } */ + +void fn (const char *, const char *) __attribute__ ((__noreturn__)); +int var; + +inline void +foo (void) +{ + if (__builtin_expect (var != 0, 0)) + fn ("a", "b"); +}; + +void +bar (void) +{ + foo (); +}; + +void +baz (void) +{ + foo (); +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr51867.c b/SingleSource/Regression/C/gcc-dg/pr51867.c new file mode 100644 index 0000000000..a022b6ff8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51867.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -fno-math-errno -fdump-rtl-expand" } */ + +extern float sqrtf(float); + +float a(float x) +{ + return sqrtf(x); +} +float b(float x) +{ + return sqrtf(x); +} +/* Here the calls to sqrtf should be expanded into CALL_INSNs, rather than + fpu sqrtf rtl patterns. */ +/* { dg-final { scan-rtl-dump-times "call_insn" 2 "expand" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-12.c b/SingleSource/Regression/C/gcc-dg/pr51879-12.c new file mode 100644 index 0000000000..1aa490791b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-12.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre -fno-code-hoisting" } */ + +__attribute__((pure)) int bar (int); +__attribute__((pure)) int bar2 (int); +void baz (int); + +int x, z; + +void +foo (int y) +{ + int a = 0; + if (y == 6) + { + a += bar (7); + a += bar2 (6); + } + else + { + a += bar2 (6); + a += bar (7); + } + baz (a); +} + +/* { dg-final { scan-tree-dump-times "bar \\(" 1 "pre" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "bar2 \\(" 1 "pre" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-16.c b/SingleSource/Regression/C/gcc-dg/pr51879-16.c new file mode 100644 index 0000000000..ea771c0ce1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-16.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +struct S { + int i; +}; + +extern struct S foo (void); +extern int foo2 (void); + +struct S s; + +int bar (int c) { + int r; + + if (c) + { + s = foo (); + r = foo2 (); + } + else + { + s = foo (); + r = foo2 (); + } + + return r; +} + +/* { dg-final { scan-tree-dump-times "foo \\(" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-times "foo2 \\(" 1 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-17.c b/SingleSource/Regression/C/gcc-dg/pr51879-17.c new file mode 100644 index 0000000000..9ecb9374fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-17.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +struct S { + int i; +}; + +extern struct S foo (void); +extern int foo2 (void); + +struct S s, s2; + +int bar (int c) { + int r; + + if (c) + { + s = foo (); + r = foo2 (); + } + else + { + s2 = foo (); + r = foo2 (); + } + + return r; +} + +/* { dg-final { scan-tree-dump-times "foo \\(" 2 "pre"} } */ +/* { dg-final { scan-tree-dump-times "foo2 \\(" 2 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-18.c b/SingleSource/Regression/C/gcc-dg/pr51879-18.c new file mode 100644 index 0000000000..16012253e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-18.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre -fno-tree-copy-prop -fno-tree-dominator-opts" } */ + +extern int foo (void); + +void bar (int c, int *p) +{ + int *q = p; + + if (c) + *p = foo (); + else + *q = foo (); +} + +/* { dg-final { scan-tree-dump-times "foo \\(" 1 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-2.c b/SingleSource/Regression/C/gcc-dg/pr51879-2.c new file mode 100644 index 0000000000..dd9b455900 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +int bar (int); +void baz (int); + +void +foo (int y) +{ + int a; + if (y) + baz (bar (7) + 6); + else + baz (bar (7) + 6); +} + +/* { dg-final { scan-tree-dump-times "bar \\(" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-times "baz \\(" 1 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-3.c b/SingleSource/Regression/C/gcc-dg/pr51879-3.c new file mode 100644 index 0000000000..674edd48b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +int bar (int); +void baz (int); + +void +foo (int y) +{ + int a; + if (y == 6) + a = bar (7) + 6; + else + a = bar (7) + 6; + baz (a); +} + +/* { dg-final { scan-tree-dump-times "bar \\(" 1 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-4.c b/SingleSource/Regression/C/gcc-dg/pr51879-4.c new file mode 100644 index 0000000000..82a986b545 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-4.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +int bar (int); +void baz (int); + +int foo (int y) +{ + int a, b; + a = bar (7) + 6; + b = bar (7) + 6; + return a + b; +} + +/* { dg-final { scan-tree-dump-times "bar \\(" 2 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-6.c b/SingleSource/Regression/C/gcc-dg/pr51879-6.c new file mode 100644 index 0000000000..42950668cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-6.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + + +int bar (int); +void baz (int); +void bla (int); + +void +foo (int y) +{ + int a; + if (y == 6) + { + bla (5); + a = bar (7); + } + else + { + bla (5); + a = bar (7); + } + baz (a); +} + +/* { dg-final { scan-tree-dump-times "bar \\(" 1 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879-7.c b/SingleSource/Regression/C/gcc-dg/pr51879-7.c new file mode 100644 index 0000000000..bb1a29a0f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879-7.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +int z; + +void +foo (int y) +{ + if (y == 6) + z = 5; + else + z = 5; +} + +/* { dg-final { scan-tree-dump-times "z = 5" 1 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51879.c b/SingleSource/Regression/C/gcc-dg/pr51879.c new file mode 100644 index 0000000000..d295373331 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51879.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +int bar (int); +void baz (int); + +void +foo (int y) +{ + int a; + if (y == 6) + a = bar (7); + else + a = bar (7); + baz (a); +} + +/* { dg-final { scan-tree-dump-times "bar \\(" 1 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr51957-1.c b/SingleSource/Regression/C/gcc-dg/pr51957-1.c new file mode 100644 index 0000000000..d6712b5be2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51957-1.c @@ -0,0 +1,29 @@ +/* PR target/51957 */ +/* { dg-do link } */ +/* { dg-options "-O2 -g -fprofile-use -Wno-missing-profile" } */ +/* { dg-additional-sources "pr51957-2.c" } */ + +int v[128]; +#include "pr51957-1.h" + +void +foo (U *x) +{ + T *a = x->u; + while (1) + { + union R *b; + b = fn1 (); + if (b != w[0] && !(v[b->p->c] == 1)) + { + fn2 (a->t, "foobar", b->p); + b = w[0]; + } + if (b != w[0]) + fn3 (); + if (w[0] && b != w[0]) + fn4 (b->p); + if (b != w[0] && (v[b->p->c] == 1) && fn4 (b->p)) + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51957-1.h b/SingleSource/Regression/C/gcc-dg/pr51957-1.h new file mode 100644 index 0000000000..cfafb2cc57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51957-1.h @@ -0,0 +1,9 @@ +union R { int c; union R *p; }; +extern union R *w[]; +typedef struct { int t; } T; +typedef struct { void *u; } U; +union R *fn1 (void); +void fn2 (int, const char *, union R *); +void fn3 (void); +int fn4 (union R *); +void foo (U *x); diff --git a/SingleSource/Regression/C/gcc-dg/pr51957-2.c b/SingleSource/Regression/C/gcc-dg/pr51957-2.c new file mode 100644 index 0000000000..038921ea34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51957-2.c @@ -0,0 +1,35 @@ +/* PR target/51957 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +#include "pr51957-1.h" + +union R *w[10]; + +union R * +fn1 (void) +{ + return (union R *) 0; +} + +void +fn2 (int x, const char *y, union R *z) +{ +} + +void +fn3 (void) +{ +} + +int +fn4 (union R *x) +{ + return 0; +} + +int +main () +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51990-2.c b/SingleSource/Regression/C/gcc-dg/pr51990-2.c new file mode 100644 index 0000000000..702bab9135 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51990-2.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target alloca } */ + +int y; +extern int foo (int, ...) __attribute__((pure)); + +int +zzz (char *s1, char *s2, int len, int *q, int c) +{ + int z = 5; + unsigned int i, b; + struct s { char a[z]; }; + struct s x; + int y_tmp = 5; + + for (i = 0; i < len; i++) + s1[i] = s2[i]; + + b = z & 0x3; + + len += (b == 0 ? 0 : 1) + z; + + *q = len; + + if (c) + y_tmp = foo (z, x, x) + 4; + + z = foo (z, x, x) + 4; + y = y_tmp; + + return z; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr51990.c b/SingleSource/Regression/C/gcc-dg/pr51990.c new file mode 100644 index 0000000000..4f7e0e4fd3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr51990.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target alloca } */ + +int +zzz (char *s1, char *s2, int len, int *q) +{ + int z = 5; + unsigned int i, b; + struct s { char a[z]; }; + struct s x; + + extern int foo (int, ...) __attribute__((pure)); + + for (i = 0; i < len; i++) + s1[i] = s2[i]; + + b = z & 0x3; + + len += (b == 0 ? 0 : 1) + z; + + *q = len; + return foo (z, x, x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52045.c b/SingleSource/Regression/C/gcc-dg/pr52045.c new file mode 100644 index 0000000000..888ddb6a12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52045.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -ftracer -fno-tree-ccp -fno-tree-copy-prop -fno-tree-dce" } */ + +char *vx; +char buf[20]; + +void +foo (void) +{ + vx = __builtin___stpcpy_chk (buf, vx ? "gh" : "e", sizeof(buf)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52046.c b/SingleSource/Regression/C/gcc-dg/pr52046.c new file mode 100644 index 0000000000..f0873e2008 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52046.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/52046 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fexceptions -fnon-call-exceptions" } */ +/* { dg-require-effective-target exceptions } */ + +extern float a[], b[], c[], d[]; +extern int k[]; + +void +foo (void) +{ + int i; + for (i = 0; i < 1024; ++i) + k[i] = (a[i] < b[i]) | (c[i] < d[i]); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52086.c b/SingleSource/Regression/C/gcc-dg/pr52086.c new file mode 100644 index 0000000000..a12e1ce792 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52086.c @@ -0,0 +1,21 @@ +/* PR target/52086 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ + +struct S { char a; char b[100]; }; +int bar (void); +int baz (int); + +void +foo (struct S *x) +{ + if (bar () & 1) + { + char c = bar (); + baz (4); + x->a += c; + while (x->a) + x->b[c] = bar (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52132.c b/SingleSource/Regression/C/gcc-dg/pr52132.c new file mode 100644 index 0000000000..ed1eb1becd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52132.c @@ -0,0 +1,27 @@ +/* PR debug/52132 */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -O2 -g" } */ + +#if (__SIZEOF_INT__ < __SIZEOF_FLOAT__) \ + && (__SIZEOF_LONG__ == __SIZEOF_FLOAT__) +#define int long +#endif + +int l; +void bar (void); + +void +foo (int *x, float y) +{ + float b; + union { float f; int i; } u = { .f = y }; +#if (__SIZEOF_INT__ < __SIZEOF_FLOAT__) + u.i += 127L << 23; +#else + u.i += 127 << 23; +#endif + u.f = ((-1.0f / 3) * u.f + 2) * u.f - 2.0f / 3; + b = 0.5 * (u.f + l); + if (b >= *x) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52134.c b/SingleSource/Regression/C/gcc-dg/pr52134.c new file mode 100644 index 0000000000..32e67cdab0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52134.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +unsigned f(unsigned t) +{ + return (t*4)&-4; +} +int f1(int t) +{ + return (t*4)&-4; +} + +/* { dg-final { scan-tree-dump-not "\\\&" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr52139.c b/SingleSource/Regression/C/gcc-dg/pr52139.c new file mode 100644 index 0000000000..b2a08a623a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52139.c @@ -0,0 +1,50 @@ +/* PR rtl-optimization/52139 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-dominator-opts -fno-tree-fre" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ +/* { dg-require-effective-target label_values } */ + +void *p; + +void +foo (int a) +{ + switch (a) + { + case 0: + a0: + case 1: + a1: + p = &&a1; + case 2: + a2: + p = &&a2; + case 3: + a3: + p = &&a3; + case 4: + a4: + p = &&a4; + case 5: + a5: + p = &&a5; + case 6: + a6: + p = &&a6; + case 7: + a7: + p = &&a7; + case 8: + a8: + p = &&a8; + case 9: + a9: + p = &&a9; + case 10: + a10: + p = &&a10; + default: + p = &&a0; + } + goto *p; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52171.c b/SingleSource/Regression/C/gcc-dg/pr52171.c new file mode 100644 index 0000000000..45aeff6b8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52171.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "memcmp" } } */ +#include +struct A { int x; } a, b; + +extern char s[], t[]; + +int foo () +{ + return memcmp (&a, &b, sizeof (struct A)) == 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52210.c b/SingleSource/Regression/C/gcc-dg/pr52210.c new file mode 100644 index 0000000000..c7ebeb6087 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52210.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/52210 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void +foo (long *x, long y, long z) +{ + long a = x[0]; + long b = x[1]; + x[0] = a & ~y; + x[1] = b & ~z; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52267.c b/SingleSource/Regression/C/gcc-dg/pr52267.c new file mode 100644 index 0000000000..8362dc23c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52267.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/52267 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int +foo (int a, int b) +{ + if (a > 3 || a < 0) + return a; + a &= 3; + return a & 3; +} + +int +bar (int a) +{ + if (a & ~3) + return a; + return a & 3; +} + +/* { dg-final { scan-tree-dump-not "& 3" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "& -4" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr52283.c b/SingleSource/Regression/C/gcc-dg/pr52283.c new file mode 100644 index 0000000000..070e71aa59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52283.c @@ -0,0 +1,17 @@ +/* Test for case labels not integer constant expressions but folding + to integer constants (used in Linux kernel). */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +extern unsigned int u; + +void +b (int c) +{ + switch (c) + { + case (int) (2 | ((4 < 8) ? 8 : u)): /* { dg-warning "case label is not an integer constant expression" } */ + ; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr52318.c b/SingleSource/Regression/C/gcc-dg/pr52318.c new file mode 100644 index 0000000000..4f367aa1cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52318.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/52318 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -ftracer -fno-tree-ccp -fno-tree-copy-prop -fno-tree-dce" } */ + +int c; +char *p; + +void +foo (int i) +{ + char a[2]; + char b[20]; + p = __builtin___stpcpy_chk (a, "", 2); + p = __builtin___stpcpy_chk (&b[16], i ? "e" : "jkl", 4); + if (c) + foo (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52355.c b/SingleSource/Regression/C/gcc-dg/pr52355.c new file mode 100644 index 0000000000..0a0271f5df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52355.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +void f(char a[16][16][16]) +{ + __asm volatile ("" : : "i" (&a[1][0][0] - &a[0][0][0])); +} + +int main(void) +{ + char a[16][16][16]; + f(a); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52445.c b/SingleSource/Regression/C/gcc-dg/pr52445.c new file mode 100644 index 0000000000..6ab316bc1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52445.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/52445 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim" } */ + +void +foo (char *buf, unsigned long len) +{ + buf[0] = '\n'; + if (len > 1) + buf[1] = '\0'; /* We can't cselim "optimize" this, while + buf[0] doesn't trap, buf[1] could. */ +} + +/* { dg-final { scan-tree-dump-not "cstore\." "cselim" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr52448.c b/SingleSource/Regression/C/gcc-dg/pr52448.c new file mode 100644 index 0000000000..188799bf6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52448.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/52448 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-cselim -fdump-tree-cselim-details" } */ + +extern void perhaps_free_something (void); + +void f1 (int *p, int a, int b, int cond, int cond2) +{ + *p = a; + if (cond) + perhaps_free_something (); + if (cond2) + *p = b; +} + +void f2 (int *p, int a, int b, int *cond, int *cond2) +{ + int i; + *p = a; + for (i = 0; cond[i]; i++) + { + if (cond2[i]) + *p = b; + perhaps_free_something (); + } +} + +/* None of the above conditional stores might be made unconditional. */ +/* { dg-final { scan-tree-dump-not "cstore" "cselim" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr52549.c b/SingleSource/Regression/C/gcc-dg/pr52549.c new file mode 100644 index 0000000000..4d0a3e00a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52549.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +#ifdef __SIZE_TYPE__ +_mark (__SIZE_TYPE__ obj, int i, char *a) +{ + (char *)&(((long *)(obj)) [i]) - a; +} +#elif __SIZEOF_POINTER__ == __SIZEOF_LONG__ +_mark (long obj, int i, char *a) +{ + (char *)&(((long *)(obj)) [i]) - a; +} +#elif __SIZEOF_POINTER__ == __SIZEOF_INT__ +_mark (int obj, int i, char *a) +{ + (char *)&(((int *)(obj)) [i]) - a; +} +#elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__ +__extension__ _mark (long long obj, int i, char *a) +{ + (char *)&(((int *)(obj)) [i]) - a; +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr52578.c b/SingleSource/Regression/C/gcc-dg/pr52578.c new file mode 100644 index 0000000000..47a0484836 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52578.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +long bar (long i) +{ + return (long)((unsigned long)i + 2) - (long)i; +} +long foo (int i) +{ + return (long)((unsigned long)i + 2) - (long)i; +} + +/* { dg-final { scan-tree-dump-times "return 2;" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr52592.c b/SingleSource/Regression/C/gcc-dg/pr52592.c new file mode 100644 index 0000000000..b71eb628de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52592.c @@ -0,0 +1,21 @@ +/* PR middle-end/52592 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -O2 -ffast-math" } */ + +#define T(type, name) \ +type name (type); \ +__attribute__((cold)) \ +int f##name (type x) \ +{ \ + return (int) name (x); \ +} + +T (double, round) +T (float, roundf) +T (long double, roundl) +T (double, rint) +T (float, rintf) +T (long double, rintl) + +/* { dg-final { scan-assembler-not "__builtin_iround" } } */ +/* { dg-final { scan-assembler-not "__builtin_irint" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr52691.c b/SingleSource/Regression/C/gcc-dg/pr52691.c new file mode 100644 index 0000000000..ad07b815a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52691.c @@ -0,0 +1,23 @@ +/* PR middle-end/52691 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +int +foo (int a, ...) +{ + int b = 0, c = 0; + va_list ap; + va_start (ap, a); + if (a > 1) + b = va_arg (ap, double); + if (a > 2) + c = va_arg (ap, long long); + va_end (ap); + return a + b + c; +} + +/* { dg-final { scan-tree-dump "__builtin_next_arg" "optimized" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */ +/* { dg-final { scan-tree-dump "__builtin_next_arg" "optimized" { target { powerpc*-*-darwin* powerpc*-*-aix* } } } } */ +/* { dg-final { scan-tree-dump "__builtin_next_arg" "optimized" { target { powerpc*-*-linux* && lp64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr52734.c b/SingleSource/Regression/C/gcc-dg/pr52734.c new file mode 100644 index 0000000000..a6894954e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52734.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int bbb = 0; + +int __attribute__((noinline,noclone)) aaa(void) +{ + ++bbb; + return 0; +} + +int __attribute__((noinline,noclone)) ccc(void) +{ + int ddd; + /* bbb == 0 */ + if (aaa()) + return bbb; + + /* bbb == 1 */ + ddd = bbb; + /* bbb == ddd == 1 */ + if (aaa ()) + return 0; + /* bbb == 2, ddd == 1 */ + + return ddd; +} + +int main(void) +{ + if (ccc() != 1) + __builtin_abort(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr52769.c b/SingleSource/Regression/C/gcc-dg/pr52769.c new file mode 100644 index 0000000000..138cecb14d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52769.c @@ -0,0 +1,24 @@ +/* PR c/52769 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +typedef struct +{ + int should_be_zero; + char s[6]; + int x; +} foo_t; + +int +main (void) +{ + volatile foo_t foo = { + .s = "123456", + .x = 2 + }; + + if (foo.should_be_zero != 0) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52803.c b/SingleSource/Regression/C/gcc-dg/pr52803.c new file mode 100644 index 0000000000..6774b0c6d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52803.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-move-loop-invariants" } */ + +int main () { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr52808.c b/SingleSource/Regression/C/gcc-dg/pr52808.c new file mode 100644 index 0000000000..8a33d08d86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52808.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftracer" } */ + +int **fn1 () __attribute__ ((__const__)); +int main () +{ + int i; + i = 0; + for (;; i++) + if (*fn1 ()[i] && !'a' <= 0 && i <= 'z' || *fn1 ()[0] && 'a' <= 'z') + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52862.c b/SingleSource/Regression/C/gcc-dg/pr52862.c new file mode 100644 index 0000000000..febe7a8289 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52862.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +void ASMAtomicWritePtrVoid(const void *pv); +void rtThreadDestroy(void) +{ + void * const pvTypeChecked = ((void *)0); + ASMAtomicWritePtrVoid((void *)(pvTypeChecked)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr52880.c b/SingleSource/Regression/C/gcc-dg/pr52880.c new file mode 100644 index 0000000000..5a83de84ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52880.c @@ -0,0 +1,10 @@ +/* PR c/52880 */ +/* { dg-do compile } */ +/* { dg-options "-Woverride-init" } */ + +struct A { int a; int b; }; +struct B { struct A c; int d, e; }; +struct B f = { .c.a = 0, .e = 1, .d = 2, .c.b = 3 }; +struct C { int g; int h; }; +struct D { int i; struct C j; int k; }; +struct D l = { .j.g = 0, .k = 1, .i = 2, .j.h = 3 }; diff --git a/SingleSource/Regression/C/gcc-dg/pr52904.c b/SingleSource/Regression/C/gcc-dg/pr52904.c new file mode 100644 index 0000000000..0b8910fbe1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr52904.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Wstrict-overflow -O2" } */ +extern int foo (int); + +int +wait_reading_process_output (void) +{ + int nfds = 0; + int channel; + + for (channel = 0; channel < 1024; ++channel) + { + if (foo (channel)) + nfds++; + } + + if (nfds < 0) /* { dg-bogus "assuming signed overflow does not occur" "" } */ + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53037-1.c b/SingleSource/Regression/C/gcc-dg/pr53037-1.c new file mode 100644 index 0000000000..3f2269699e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53037-1.c @@ -0,0 +1,82 @@ +/* PR c/53037. */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +/* { dg-require-effective-target int32 } */ + +typedef unsigned long long __u64 + __attribute__((aligned(4),warn_if_not_aligned(8))); + +struct foo1 +{ + int i1; + int i2; + int i3; + __u64 x; /* { dg-warning "'x' offset 12 in 'struct foo1' isn't aligned to 8" } */ +}; /* { dg-warning "alignment 4 of 'struct foo1' is less than 8" } */ + +struct foo2 +{ + int i1; + int i2; + int i3; + __u64 x; /* { dg-warning "'x' offset 12 in 'struct foo2' isn't aligned to 8" } */ +} __attribute__((aligned(8))); + +struct foo3 +{ + int i1; + int i3; + __u64 x; +}; /* { dg-warning "alignment 4 of 'struct foo3' is less than 8" } */ + +struct foo4 +{ + int i1; + int i2; + __u64 x; +} __attribute__((aligned(8))); + +struct foo5 +{ + int i1; + int x __attribute__((warn_if_not_aligned(16))); /* { dg-warning "'x' offset 4 in 'struct foo5' isn't aligned to 16" } */ +}; /* { dg-warning {alignment [0-9]+ of 'struct foo5' is less than 16} } */ + +struct foo6 +{ + int i1; + int x __attribute__((warn_if_not_aligned(16))); /* { dg-warning "'x' offset 4 in 'struct foo6' isn't aligned to 16" } */ +} __attribute__((aligned(16))); + +struct foo7 +{ + int i1; + int i2; + int i3; + int i4; + int x __attribute__((warn_if_not_aligned(16))); +} __attribute__((aligned(16))); + +union bar1 +{ + int i1; + __u64 x; +}; /* { dg-warning "alignment 4 of 'union bar1' is less than 8" } */ + +union bar2 +{ + int i1; + __u64 x; +} __attribute__((aligned(8))); + +union bar3 +{ + int i1; + int x __attribute__((warn_if_not_aligned(16))); +}; /* { dg-warning {alignment [0-9]+ of 'union bar3' is less than 16} } */ + +union bar4 +{ + int i1; + int x __attribute__((warn_if_not_aligned(16))); +} __attribute__((aligned(16))); diff --git a/SingleSource/Regression/C/gcc-dg/pr53037-2.c b/SingleSource/Regression/C/gcc-dg/pr53037-2.c new file mode 100644 index 0000000000..848db3b377 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53037-2.c @@ -0,0 +1,38 @@ +/* PR c/53037. */ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wpacked-not-aligned" } */ +/* { dg-require-effective-target int32 } */ + +struct __attribute__ ((aligned (8))) S8 { char a[8]; }; +struct __attribute__ ((packed)) S1 { + struct S8 s8; +}; /* { dg-warning "alignment 1 of 'struct S1' is less than 8" } */ + +struct __attribute__ ((packed, aligned (8))) S2 { + struct S8 s8; +}; + +struct __attribute__ ((packed, aligned (8))) S3 { + int i1; + struct S8 s8; /* { dg-warning "'s8' offset 4 in 'struct S3' isn't aligned to 8" } */ +}; + +struct __attribute__ ((packed, aligned (8))) S4 { + int i1; + int i2; + struct S8 s8; +}; + +struct __attribute__ ((packed)) S5 { + long long ll; +}; + +union __attribute__ ((packed)) U1 { + int i1; + struct S8 s8; +}; /* { dg-warning "alignment 1 of 'union U1' is less than 8" } */ + +union __attribute__ ((packed, aligned (8))) U2 { + int i1; + struct S8 s8; +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr53037-3.c b/SingleSource/Regression/C/gcc-dg/pr53037-3.c new file mode 100644 index 0000000000..c9b0efd187 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53037-3.c @@ -0,0 +1,38 @@ +/* PR c/53037. */ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wall" } */ +/* { dg-require-effective-target int32 } */ + +struct __attribute__ ((aligned (8))) S8 { char a[8]; }; +struct __attribute__ ((packed)) S1 { + struct S8 s8; +}; /* { dg-warning "alignment 1 of 'struct S1' is less than 8" } */ + +struct __attribute__ ((packed, aligned (8))) S2 { + struct S8 s8; +}; + +struct __attribute__ ((packed, aligned (8))) S3 { + int i1; + struct S8 s8; /* { dg-warning "'s8' offset 4 in 'struct S3' isn't aligned to 8" } */ +}; + +struct __attribute__ ((packed, aligned (8))) S4 { + int i1; + int i2; + struct S8 s8; +}; + +struct __attribute__ ((packed)) S5 { + long long ll; +}; + +union __attribute__ ((packed)) U1 { + int i1; + struct S8 s8; +}; /* { dg-warning "alignment 1 of 'union U1' is less than 8" } */ + +union __attribute__ ((packed, aligned (8))) U2 { + int i1; + struct S8 s8; +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr53037-4.c b/SingleSource/Regression/C/gcc-dg/pr53037-4.c new file mode 100644 index 0000000000..feb3afad2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53037-4.c @@ -0,0 +1,24 @@ +/* PR c/53037. */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +int foo1 __attribute__((warn_if_not_aligned(8))); /* { dg-error "'warn_if_not_aligned' may not be specified for 'foo1'" } */ + +__attribute__((warn_if_not_aligned(8))) +void +foo2 (void) /* { dg-error "'warn_if_not_aligned' may not be specified for 'foo2'" } */ +{ +} + +struct foo3 +{ + int i : 2 __attribute__((warn_if_not_aligned(8))); /* { dg-error "'warn_if_not_aligned' may not be specified for 'i'" } */ +}; + +typedef unsigned int __u32 + __attribute__((aligned(4),warn_if_not_aligned(8))); + +struct foo4 +{ + __u32 i : 2; /* { dg-error "cannot declare bit-field 'i' with 'warn_if_not_aligned' type" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr53060.c b/SingleSource/Regression/C/gcc-dg/pr53060.c new file mode 100644 index 0000000000..503f054077 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53060.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +extern void abort (void); + +int f(void) { return 2; } +unsigned int g(void) { return 5; } +unsigned int h = 1; + +typedef unsigned int vec __attribute__((vector_size(16))); + +vec i = { 1, 2, 3, 4}; + +vec fv1(void) { return i + (h ? f() : g()); } +vec fv2(void) { return (h ? f() : g()) + i; } + +int main() +{ + vec i, j; + j = fv1(); + if (j[0] != 3) abort(); + i = fv2(); + if (i[0] != 3) abort(); + return 0; +} + +/* Ignore a warning that is irrelevant to the purpose of this test. */ +/* { dg-prune-output ".*GCC vector returned by reference.*" } */ +/* { dg-prune-output "changes the ABI" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr53119.c b/SingleSource/Regression/C/gcc-dg/pr53119.c new file mode 100644 index 0000000000..93cd3fd8a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53119.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-braces -Wmissing-field-initializers" } */ + +struct a { + int x, y, z; +}; + +struct b { + struct a w, z; +}; + +int main (void) +{ + struct a az = { 0 }; + struct a anz = { 1 }; /* { dg-warning "missing initializer for" } */ + struct a aez = { 0, 0 }; /* { dg-warning "missing initializer for" } */ + + struct b bz = { 0 }; + struct b bnz = { 0, 0, 0, 0, 0, 0 }; /* { dg-warning "missing braces" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53153.c b/SingleSource/Regression/C/gcc-dg/pr53153.c new file mode 100644 index 0000000000..8899e04e90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53153.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern void bar (void); + +/* Case 181 is not in the range for 'char'. */ +void +foo1 (char *buf) +{ + int x = *buf; + switch (x) + { + case -76: + case 65: + case 181: + bar(); + } +} + +/* All cases are below the range of char. */ +void +foo2 (char *buf) +{ + int x = *buf; + switch (x) + { + case -150: + case -140: + case -130: + bar(); + } +} + +/* All cases are above the range of char. */ +void +foo3 (char *buf) +{ + int x = *buf; + switch (x) + { + case 130: + case 140: + case 150: /* This case is not in the range for 'char'. */ + bar(); + } +} + +/* The bounding cases are partially out of range for char. */ +void +foo4 (char *buf) +{ + int x = *buf; + switch (x) + { + case -130 ... -120: + case 100: + case 120 ... 130: + bar(); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr53174.c b/SingleSource/Regression/C/gcc-dg/pr53174.c new file mode 100644 index 0000000000..37c9390e5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53174.c @@ -0,0 +1,67 @@ +/* PR debug/53174 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -g" } */ + +int w, h; + +void +bar (float (*x)[4], int y, int z) +{ + int a, b, c, d, e, f, g; + + a = 2; + b = 2; + c = 274; + d = 274; + if (!z) + a = 12; + if (!y) + b = 12; + if (z + 266 >= h - 2) + c = 8 + h - z; + if (y + 266 >= w - 2) + d = 8 + w - y; + for (e = a; e < c; e++) + for (f = b, g = e * 276 + f; f < d; f++, g++) + { + float (*h)[4] = x + (g - 277); + float k = (*h)[0]; + float l = (*h)[1]; + float m = (*h)[2]; + h++; + k += (*h)[0]; + l += (*h)[1]; + m += (*h)[2]; + h++; + k += (*h)[0]; + l += (*h)[1]; + m += (*h)[2]; + h += 274; + k += (*h)[0]; + l += (*h)[1]; + m += (*h)[2]; + h += 2; + k += (*h)[0]; + l += (*h)[1]; + m += (*h)[2]; + h += 274; + k += (*h)[0]; + l += (*h)[1]; + m += (*h)[2]; + h++; + k += (*h)[0]; + l += (*h)[1]; + m += (*h)[2]; + h++; + k += (*h)[0]; + l += (*h)[1]; + m += (*h)[2]; + k *= 0.125f; + l *= 0.125f; + m *= 0.125f; + k = k + (x[g][1] - l); + m = m + (x[g][1] - l); + x[g][0] = k; + x[g][2] = m; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53196-1.c b/SingleSource/Regression/C/gcc-dg/pr53196-1.c new file mode 100644 index 0000000000..b33e0432eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53196-1.c @@ -0,0 +1,14 @@ +/* PR c/53196 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +extern int printf (const char *, ...); +struct foo { int i; }; + +int +main () +{ + struct foo f = (struct foo_typo) { }; /* { dg-error "invalid use of undefined type" } */ + printf ("%d\n", f.i); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53196-2.c b/SingleSource/Regression/C/gcc-dg/pr53196-2.c new file mode 100644 index 0000000000..1d47b86e4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53196-2.c @@ -0,0 +1,18 @@ +/* PR c/53196 */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +extern int printf (const char *, ...); +struct foo { int i; }; + +int +main () +{ + struct foo f = (struct foo_typo) { }; + /* { dg-error "invalid use of undefined type" "" { target *-*-* } .-1 } */ + /* { dg-error "ISO C forbids empty initializer braces" "" { target *-*-* } .-2 } */ + + printf ("%d\n", f.i); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr53265.c b/SingleSource/Regression/C/gcc-dg/pr53265.c new file mode 100644 index 0000000000..a72721194c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53265.c @@ -0,0 +1,159 @@ +/* PR tree-optimization/53265 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-require-effective-target size32plus } */ + +void bar (void *); +int baz (int); + +void +fn1 (void) +{ + unsigned int a[128]; + int i; + + for (i = 0; i < 128; ++i) /* { dg-message "note: within this loop" } */ + a[i] = i * 0x02000001; /* { dg-warning "64 invokes undefined behavior" } */ + bar (a); +} + +void +fn2 (void) +{ + unsigned long long a[128]; + int i; + + for (i = 0; i < 128; i++) /* { dg-message "note: within this loop" } */ + a[i] = (i + 1LL) * 0x0123456789ABCDEFLL; /* { dg-warning "112 invokes undefined behavior" } */ + bar (a); +} + +void +fn3 (void) +{ + unsigned char a[16], b[16], c[16]; + int i; + + bar (b); + for (i = 0; i < (int) (sizeof (a) / sizeof (a[0])); i++) /* { dg-message "note: within this loop" } */ + { + c[i + 8] = b[i]; /* { dg-warning "8 invokes undefined behavior" } */ + /* { dg-warning "out of the bounds" "" { target *-*-* } .-1 } */ + a[i + 8] = b[i + 8]; /* { dg-warning "out of the bounds" } */ + } + bar (a); + bar (c); +} + +void +fn4 (void) +{ + unsigned int *a[32], *o, i; + + bar (a); + for (i = 0; i <= sizeof (a) / sizeof (a[0]); i++) /* { dg-message "note: within this loop" } */ + { + o = a[i]; /* { dg-warning "32 invokes undefined behavior" } */ + bar (o); + } +} + +void +fn5 (void) +{ + unsigned short a[23940]; + unsigned int b[1140]; + int j; + + bar (b); + for (j = 0; j < 1140; j++) /* { dg-message "note: within this loop" } */ + a[23940 + j - 950] = b[j]; /* { dg-warning "950 invokes undefined behavior" } */ + bar (a); +} + +void +fn6 (void) +{ + double a[4][3], b[12]; + int i; + bar (b); + for (i = 0; i < 12; i++) /* { dg-message "note: within this loop" } */ + a[0][i] = b[i] / 10000.0; /* { dg-warning "3 invokes undefined behavior" } */ + bar (a); +} + +void +fn7 (void) +{ + int a[16], b, c; + bar (a); + for (b = a[c = 0]; c < 16; b = a[++c]) + /* { dg-warning "15 invokes undefined behavior" "" { target *-*-* } .-1 } */ + /* { dg-message "note: within this loop" "" { target *-*-* } .-2 } */ + baz (b); +} + + +const void *va, *vb, *vc, *vd, *ve; +const void *vf[4]; +void +fn8 (void) +{ + unsigned long i; + vf[0] = va; vf[1] = vb; vf[2] = vc; vf[3] = vd; + for (i = 0; i < (sizeof (vf) / sizeof (vf[0])); i++) + if (!vf[i]) + vf[i] = ve; +} + +int wa, wb[53][5], wc[53][5]; + +void +fn9 (void) +{ + int i, j, k; + for (i = 0; i < 53; i++) + for (j = 16 / (((wa & 1) != 0) ? 8 : 4); j > 0; j--) + { + int d = 1; + if (wb[i][j] == 0 || wc[i][1] != 0) + continue; + for (k = 0; k < j; k++) + if (wc[i + k][1]) + { + d = 0; + break; + } + if (!d) + continue; + wc[i][j] = baz (0); + } +} + +int xa[18]; + +void +fn10 (void) +{ + int i; + for (i = 16; i < 32; i++) /* { dg-message "note: within this loop" } */ + xa[i] = 26; /* { dg-warning "2 invokes undefined behavior" } */ +} + +__attribute__((noinline)) static void +fn11 (int x) +{ + int i = 1; + if (x > 1) + do + baz (i); + while (++i != x); /* { dg-bogus "invokes undefined behavior" } */ +} + +void +fn12 (void) +{ + fn11 (1); + fn11 (1); + fn11 (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53352.c b/SingleSource/Regression/C/gcc-dg/pr53352.c new file mode 100644 index 0000000000..171bcd71ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53352.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +#include + +typedef union +{ + struct + { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + } parts; + unsigned long whole; +} T; + +T *g_t; + +void bar (unsigned long x) +{ + if (x != 0) + abort (); +} + +int main () +{ + T one; + T two; + T tmp1, tmp2; + + one.whole = 0xFFE0E0E0UL; + two.whole = 0xFF000000UL; + tmp1.parts = two.parts; + tmp2.parts = one.parts; + tmp2.parts.c = tmp1.parts.c; + one.parts = tmp2.parts; + + g_t = &one; + bar (0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53358.c b/SingleSource/Regression/C/gcc-dg/pr53358.c new file mode 100644 index 0000000000..494090a42d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53358.c @@ -0,0 +1,22 @@ +/* PR target/53358 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ +/* { dg-additional-options "-mtune=pentium4" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +struct S { unsigned char s, t[17]; }; +int bar (void); + +void +foo (struct S *x) +{ + unsigned char i, z; + if (bar ()) + { + z = bar (); + bar (); + x->s += z; + for (i = 0; i < x->s; i++) + x->t[i] = bar (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53532.c b/SingleSource/Regression/C/gcc-dg/pr53532.c new file mode 100644 index 0000000000..9caea40be9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53532.c @@ -0,0 +1,13 @@ +/* PR c/53532 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S {}; +extern int foo (struct S); + +int +main () +{ + foo ((struct T) {}); /* { dg-error "invalid use of undefined type" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53550.c b/SingleSource/Regression/C/gcc-dg/pr53550.c new file mode 100644 index 0000000000..1008f43a7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53550.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/53550 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */ + +int * +foo (int *x) +{ + int *a = x + 10, *b = x, *c = a; + while (b != c) + *--c = *b++; + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53701.c b/SingleSource/Regression/C/gcc-dg/pr53701.c new file mode 100644 index 0000000000..15bf07d61e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53701.c @@ -0,0 +1,59 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O3 -fselective-scheduling2 -fsel-sched-pipelining" } */ +typedef unsigned short int uint16_t; +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; +typedef struct GFX_VTABLE +{ + int color_depth; + unsigned char *line[]; +} +BITMAP; +extern int _drawing_mode; +extern BITMAP *_drawing_pattern; +extern int _drawing_y_anchor; +extern unsigned int _drawing_x_mask; +extern unsigned int _drawing_y_mask; +extern uintptr_t bmp_write_line (BITMAP *, int); + void +_linear_hline15 (BITMAP * dst, int dx1, int dy, int dx2, int color) +{ + int w; + if (_drawing_mode == 0) + { + int x, curw; + unsigned short *sline = + (unsigned short *) (_drawing_pattern-> + line[((dy) - + _drawing_y_anchor) & _drawing_y_mask]); + unsigned short *s; + unsigned short *d = + ((unsigned short *) (bmp_write_line (dst, dy)) + (dx1)); + s = ((unsigned short *) (sline) + (x)); + if (_drawing_mode == 2) + { + } + else if (_drawing_mode == 3) + { + do + { + w -= curw; + do + { + unsigned long c = (*(s)); + if (!((unsigned long) (c) == 0x7C1F)) + { + (*((uint16_t *) ((uintptr_t) (d))) = ((color))); + } + ((s)++); + } + while (--curw > 0); + s = sline; + curw = + (((w) < + ((int) _drawing_x_mask + + 1)) ? (w) : ((int) _drawing_x_mask + 1)); + } + while (curw > 0); + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53749.c b/SingleSource/Regression/C/gcc-dg/pr53749.c new file mode 100644 index 0000000000..136b5b09c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53749.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +#define N 1024 +unsigned char a[N], b[N], c[N]; + +void f1(void) +{ + int i; + for (i = 0; i < N; ++i) + a[i] = b[i] * c[i]; +} + +void f2(void) +{ + int i; + for (i = 0; i < N; ++i) + a[i] = b[i] * 2; +} + +void f3(void) +{ + int i; + for (i = 0; i < N; ++i) + a[i] = b[i] * 20; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53849.c b/SingleSource/Regression/C/gcc-dg/pr53849.c new file mode 100644 index 0000000000..eddc45fd9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53849.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fno-tree-loop-im" } */ + +extern int *b, *e[8], d; + +void +foo (void) +{ + int i; + for (i = 0; i < 8; ++i) + while (--d) + e[i] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53881-1.c b/SingleSource/Regression/C/gcc-dg/pr53881-1.c new file mode 100644 index 0000000000..435d938a40 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53881-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a, b; +void +fn1 () +{ + int c; + switch (a) + { + case 8: + c = 0; + goto Label; + case 0: + case 1: +Label: + break; + default: + b = 0; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr53881-2.c b/SingleSource/Regression/C/gcc-dg/pr53881-2.c new file mode 100644 index 0000000000..f6f8f8bcb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53881-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a,b,c; +void +fn1 () +{ + switch (a) + { + case 0: + case 10: + b=c; +out_bcon: + break; + case 3: + goto out_bcon; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr53887.c b/SingleSource/Regression/C/gcc-dg/pr53887.c new file mode 100644 index 0000000000..b46126cd2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53887.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +enum +{ Failed, NoError, NoDiskette } +a; +int b, c; +void +fn1 () +{ + if (c) + a << 1; + switch (b) + { + default: + a << 1; + case 0: + b = 0; + case 1: + case NoDiskette: + ; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr53942.c b/SingleSource/Regression/C/gcc-dg/pr53942.c new file mode 100644 index 0000000000..6a51d2673d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53942.c @@ -0,0 +1,34 @@ +/* PR rtl-optimization/53942 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mtune=pentium2" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +struct S +{ + unsigned short w[3]; + unsigned int x, y; +}; + +struct S *baz (void); + +__attribute__ ((noinline)) +static unsigned char +foo (struct S *x, unsigned char y) +{ + unsigned char c = 0; + unsigned char v = x->w[0]; + c |= v; + v = ((x->w[1]) & (1 << y)) ? 1 : 0; + c |= v << 1; + v = ((x->w[2]) & 0xff) & (1 << y); + c |= v << 2; + return c; +} + +void +bar (void) +{ + struct S *s = baz (); + s->x = foo (s, 6); + s->y = foo (s, 7); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr53979-1.c b/SingleSource/Regression/C/gcc-dg/pr53979-1.c new file mode 100644 index 0000000000..aee54f5237 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53979-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +unsigned f1(unsigned a, unsigned b) +{ + return (a ^ b) | a; +} + +/* { dg-final { scan-tree-dump "a | b" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr53979-2.c b/SingleSource/Regression/C/gcc-dg/pr53979-2.c new file mode 100644 index 0000000000..be2607aea3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr53979-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop-details" } */ + +unsigned f(unsigned a, unsigned b) +{ + unsigned t1 = a ^ b; + unsigned t2 = t1 | a; + return t2; +} + +/* { dg-final { scan-tree-dump "gimple_simplified to t2_\[0-9\] = a_\[0-9\]*\\(D\\) | b_\[0-9\]*\\(D\\)" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr54087.c b/SingleSource/Regression/C/gcc-dg/pr54087.c new file mode 100644 index 0000000000..5874e9cd7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54087.c @@ -0,0 +1,18 @@ +/* PR54087. Verify __atomic_sub (val) uses __atomic_add (-val) if there is no + atomic_aub. */ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sync_int_long } */ +/* { dg-final { scan-assembler-times "xadd" 2 } } */ + + +int a; + +int f1(int p) +{ + return __atomic_sub_fetch(&a, p, __ATOMIC_SEQ_CST) == 0; +} + +int f2(int p) +{ + return __atomic_fetch_sub(&a, p, __ATOMIC_SEQ_CST) - p == 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54113.c b/SingleSource/Regression/C/gcc-dg/pr54113.c new file mode 100644 index 0000000000..4c68099b36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54113.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-prototypes" } */ + +inline int foo (void) { return 42; } /* { dg-bogus "no previous prototype" } */ +extern int foo(void); diff --git a/SingleSource/Regression/C/gcc-dg/pr54121.c b/SingleSource/Regression/C/gcc-dg/pr54121.c new file mode 100644 index 0000000000..3e2c0e9bb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54121.c @@ -0,0 +1,95 @@ +/* PR target/54121 */ +/* Reported by Jan Engelhardt */ + +/* { dg-do compile { target fpic } } */ +/* { dg-options "-std=gnu99 -O -fPIC -fprofile-generate" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +typedef __SIZE_TYPE__ size_t; +typedef unsigned char uint8_t; + +extern void *memcpy (void *__restrict __dest, + __const void *__restrict __src, size_t __n) + __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))); + +typedef enum { + LZMA_OK = 0, + LZMA_STREAM_END = 1, + LZMA_NO_CHECK = 2, + LZMA_UNSUPPORTED_CHECK = 3, + LZMA_GET_CHECK = 4, + LZMA_MEM_ERROR = 5, + LZMA_MEMLIMIT_ERROR = 6, + LZMA_FORMAT_ERROR = 7, + LZMA_OPTIONS_ERROR = 8, + LZMA_DATA_ERROR = 9, + LZMA_BUF_ERROR = 10, + LZMA_PROG_ERROR = 11, +} lzma_ret; + +typedef enum { + LZMA_RUN = 0, + LZMA_SYNC_FLUSH = 1, + LZMA_FULL_FLUSH = 2, + LZMA_FINISH = 3 +} lzma_action; + +typedef struct { + void *( *alloc)(void *opaque, size_t nmemb, size_t size); + void ( *free)(void *opaque, void *ptr); + void *opaque; +} lzma_allocator; + +typedef struct lzma_coder_s lzma_coder; + +typedef struct lzma_next_coder_s lzma_next_coder; + +typedef struct lzma_filter_info_s lzma_filter_info; + +typedef lzma_ret (*lzma_init_function)( + lzma_next_coder *next, lzma_allocator *allocator, + const lzma_filter_info *filters); + +typedef lzma_ret (*lzma_code_function)( + lzma_coder *coder, lzma_allocator *allocator, + const uint8_t *restrict in, size_t *restrict in_pos, + size_t in_size, uint8_t *restrict out, + size_t *restrict out_pos, size_t out_size, + lzma_action action); + +typedef void (*lzma_end_function)( + lzma_coder *coder, lzma_allocator *allocator); + +typedef struct { + uint8_t *buf; + size_t pos; + size_t size; +} lzma_dict; + +typedef struct { + lzma_coder *coder; + lzma_ret (*code)(lzma_coder *restrict coder, + lzma_dict *restrict dict, const uint8_t *restrict in, + size_t *restrict in_pos, size_t in_size); +} lzma_lz_decoder; + +struct lzma_coder_s { + lzma_dict dict; + lzma_lz_decoder lz; +}; + +lzma_ret +decode_buffer(lzma_coder *coder, + const uint8_t *restrict in, size_t *restrict in_pos, + size_t in_size, uint8_t *restrict out, size_t *restrict out_pos) +{ + while (1) { + const size_t dict_start = coder->dict.pos; + const lzma_ret ret + = coder->lz.code( coder->lz.coder, &coder->dict, in, in_pos, in_size); + const size_t copy_size = coder->dict.pos - dict_start; + memcpy(out + *out_pos, coder->dict.buf + dict_start, copy_size); + if (ret != LZMA_OK || coder->dict.pos < coder->dict.size) + return ret; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54346.c b/SingleSource/Regression/C/gcc-dg/pr54346.c new file mode 100644 index 0000000000..5ec0609f1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54346.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-dse1 -Wno-psabi" } */ + +typedef int veci __attribute__ ((vector_size (4 * sizeof (int)))); + +void fun (veci a, veci b, veci *i) +{ + veci c = __builtin_shuffle (a, b, __extension__ (veci) {1, 4, 2, 7}); + *i = __builtin_shuffle (c, __extension__ (veci) { 7, 2, 1, 5 }); +} + +/* { dg-final { scan-tree-dump "VEC_PERM_EXPR.*{ 3, 6, 0, 0 }" "dse1" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 1 "dse1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr54355.c b/SingleSource/Regression/C/gcc-dg/pr54355.c new file mode 100644 index 0000000000..0a0b7fa970 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54355.c @@ -0,0 +1,11 @@ +/* PR c/54355 */ +/* { dg-do compile } */ + +void +foo (int i) +{ + switch (i) + { + case 0: T x > /* { dg-error "(label|unknown type|expected)" } */ + } +} /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr54363.c b/SingleSource/Regression/C/gcc-dg/pr54363.c new file mode 100644 index 0000000000..aea0f9057b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54363.c @@ -0,0 +1,12 @@ +/* PR c/54363 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +struct S { char **a; }; + +void +test (void) +{ + struct S b = { .a = (char **) { "a", "b" } }; /* { dg-warning "(initialization|excess elements)" } */ + struct S c = { .a = (char *[]) { "a", "b" } }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54472.c b/SingleSource/Regression/C/gcc-dg/pr54472.c new file mode 100644 index 0000000000..20c85b47ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54472.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -fschedule-insns -fselective-scheduling" } */ + +int main () +{ + int a[3][3][3]; + __builtin_memset (a, 0, sizeof a); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54669.c b/SingleSource/Regression/C/gcc-dg/pr54669.c new file mode 100644 index 0000000000..48967ed5da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54669.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/54669 */ +/* Testcase by Zdenek Sojka */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fexceptions -fnon-call-exceptions" } */ +/* { dg-require-effective-target exceptions } */ + +int a[10]; + +void +foo (void) +{ + int x; + int i; + for (i = 0; i < 1;) + { + int b[3]; + for (i = 0; i < 1; i++) + b[i] = a[i]; + if (&x) + a[0] = b[0]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54676.c b/SingleSource/Regression/C/gcc-dg/pr54676.c new file mode 100644 index 0000000000..cb3a8a2d57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54676.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/54676 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-copy-prop -fno-tree-fre -ftree-vrp" } */ + +struct S +{ + int s:1; +}; + +struct S bar (void); + +#if __SIZEOF_INT__ < 4 +#define int __INT32_TYPE__ +#endif + +int a; + +void +foo (int x) +{ + struct S s = bar (); + while (!a) + { + int l = 94967295; + a = x || (s.s &= l); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54782.c b/SingleSource/Regression/C/gcc-dg/pr54782.c new file mode 100644 index 0000000000..161b043c61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54782.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O -ffast-math -ftree-parallelize-loops=2 -g" } */ + +struct S +{ + int n; + float *a; +}; + +int +foo (struct S *s) +{ + float sum = 0; + int i; + for (i = 0; i < s->n; i++) + sum += s->a[i]; + return sum; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54838.c b/SingleSource/Regression/C/gcc-dg/pr54838.c new file mode 100644 index 0000000000..9ed92f9e1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54838.c @@ -0,0 +1,24 @@ +/* PR middle-end/54838 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-forward-propagate -ftracer" } */ + +void bar (void); + +void +foo (void *b, int *c) +{ +again: + switch (*c) + { + case 1: + if (!b) + { + bar (); + return; + } + goto again; + case 3: + if (!b) + goto again; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54919.c b/SingleSource/Regression/C/gcc-dg/pr54919.c new file mode 100644 index 0000000000..9f1affce23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54919.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/54919 */ +/* Testcase by Zdenek Sojka */ + +/* { dg-do run } */ +/* { dg-options "-O3 -ffast-math -funroll-loops -fvariable-expansion-in-unroller" } */ + +int a[10]; +extern void abort(void) __attribute__((noreturn)); + +int __attribute__((__noinline__, __noclone__)) +foo (void) +{ + double d; + int i; + for (i = 0, d = 0; i < 64; i++) + d--; + return (int) d; +} + +int +main (void) +{ + if (foo () != -64) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr54921.c b/SingleSource/Regression/C/gcc-dg/pr54921.c new file mode 100644 index 0000000000..897877aa00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54921.c @@ -0,0 +1,32 @@ +/* PR rtl-optimization/54921 */ +/* { dg-do run } */ +/* { dg-options "-Os -fno-omit-frame-pointer -fsched2-use-superblocks -ftree-slp-vectorize" } */ +/* { dg-additional-options "-fstack-protector" { target fstack_protector } } */ + +struct A +{ + int a; + char b[32]; +} a, b; + +__attribute__((noinline, noclone)) +struct A +bar (int x) +{ + struct A r; + static int n; + r.a = ++n; + __builtin_memset (r.b, 0, sizeof (r.b)); + r.b[0] = x; + return r; +} + +int +main () +{ + a = bar (3); + b = bar (4); + if (a.a != 1 || a.b[0] != 3 || b.a != 2 || b.b[0] != 4) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr54981.c b/SingleSource/Regression/C/gcc-dg/pr54981.c new file mode 100644 index 0000000000..aa77d60c44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr54981.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-distribute-patterns -fcompare-debug" } */ + +extern void bar(unsigned *, char *); + +void foo(char *s) +{ + unsigned i; + char t[2]; + + bar(&i, t); + + for (i = 0; i < 2; i++) + s[i] = t[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55010.c b/SingleSource/Regression/C/gcc-dg/pr55010.c new file mode 100644 index 0000000000..a3dc41d8d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55010.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/55010 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +long long int a; +unsigned long long int b; + +void +foo (void) +{ + a = (a < 0) / ((a -= b) ? b >= ((b = a) || 0) : 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55019.c b/SingleSource/Regression/C/gcc-dg/pr55019.c new file mode 100644 index 0000000000..1548fb258c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55019.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -funroll-loops" } */ +/* { dg-add-options ieee } */ + +extern void exit (int); +extern void abort (void); + +void +compare (double a, double b) +{ + do + { + double s1 = __builtin_copysign ((double) 1.0, a); + double s2 = __builtin_copysign ((double) 1.0, b); + + if (s1 != s2) + abort (); + + if ((__builtin_isnan (a) != 0) != (__builtin_isnan (b) != 0)) + abort (); + + if ((a != b) != (__builtin_isnan (a) != 0)) + abort (); + } while (0); +} + +int +main () +{ + double a = 0.0; + double b = 0.0; + _Complex double cr = __builtin_complex (a, b); + static _Complex double cs = __builtin_complex (0.0, 0.0); + + compare (__real__ cr, 0.0); + compare (__imag__ cr, 0.0); + compare (__real__ cs, 0.0); + compare (__imag__ cs, 0.0); + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55023.c b/SingleSource/Regression/C/gcc-dg/pr55023.c new file mode 100644 index 0000000000..8f6b300b17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55023.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/55023 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-inline" } */ + +extern void abort (void); +typedef long long int64_t; + +struct foo { + int x; + int y; +}; + +int64_t foo(int64_t a, int64_t b, int64_t c) +{ + return a + b + c; +} + +int64_t bar(int64_t a, struct foo bq, struct foo cq) +{ + int64_t b = bq.x + bq.y; + int64_t c = cq.x + cq.y; + return foo(a, b, c); +} + +int main(void) +{ + int64_t a = 1; + struct foo b = { 2, 3 }; + struct foo c = { 4, 5 }; + if (bar (a, b, c) != 15) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55027.c b/SingleSource/Regression/C/gcc-dg/pr55027.c new file mode 100644 index 0000000000..05082b26b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55027.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized-raw" } */ + +typedef double v2df __attribute__ ((__vector_size__ (2 * sizeof (double)))); + +void f (v2df *x) +{ + *x = 0 + 1 * *x; +} + +/* { dg-final { scan-tree-dump-not "gimple_assign" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr55094.c b/SingleSource/Regression/C/gcc-dg/pr55094.c new file mode 100644 index 0000000000..c445b1a864 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55094.c @@ -0,0 +1,45 @@ +/* PR middle-end/55094 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug -Os" } */ +/* { dg-additional-options "-fomit-frame-pointer -fno-asynchronous-unwind-tables -mpreferred-stack-boundary=2" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern int fn (long); +int v; + +int +foo (int x, long *y) +{ + if (x) + { + fn (y[0]); + __builtin_trap (); + } + __builtin_trap (); +} + +int +bar (int x, long *y) +{ + if (x) + { + fn (y[0]); + v = 1; + __builtin_unreachable (); + } + v = 1; + __builtin_unreachable (); +} + +int +baz (int x, long *y) +{ + if (x) + { + fn (y[0]); + v = 1; + __builtin_unreachable (); + } + v = 1; + int w = 1; + __builtin_unreachable (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55110.c b/SingleSource/Regression/C/gcc-dg/pr55110.c new file mode 100644 index 0000000000..2a031a5290 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55110.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/55110 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vectorize" } */ + +int +foo (int x) +{ + int a, b; + for (b = 0; b < 8; b++) + for (a = 0; a < 2; a++) + x /= 3; + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55122.c b/SingleSource/Regression/C/gcc-dg/pr55122.c new file mode 100644 index 0000000000..a290ae001a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55122.c @@ -0,0 +1,14 @@ +/* PR rtl-optimization/55122 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int i, a; +unsigned long long b; + +void f(void) +{ + for(i = 0; i < 15; i++) + b *= b; + + b *= a ? 0 : b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55150-1.c b/SingleSource/Regression/C/gcc-dg/pr55150-1.c new file mode 100644 index 0000000000..e42066b60c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55150-1.c @@ -0,0 +1,73 @@ +/* PR middle-end/55150 */ +/* { dg-do compile } */ +/* { dg-options "-Os -g" } */ +/* { dg-require-effective-target int32plus } */ + +typedef unsigned int KEY_TABLE_TYPE[(272 / 4)]; + typedef unsigned int u32; + typedef unsigned char u8; + static const u32 Camellia_SBOX[][256] = { + }; + static const u32 SIGMA[] = { + 0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2, 0xc6ef372f, 0xe94f82be, 0x54ff53a5, 0xf1d36f1c, 0x10e527fa, 0xde682d1d, 0xb05688c2, 0xb3e6c1fd }; + int Camellia_Ekeygen (int keyBitLength, const u8 * rawKey, KEY_TABLE_TYPE k) { + register u32 s0, s1, s2, s3; + k[0] = s0 = ( { + u32 r = *(const u32 *) (rawKey); + r; + } + ); + k[2] = s2 = ( { + u32 r = *(const u32 *) (rawKey + 8); + r; + } + ); + k[3] = s3 = ( { + u32 r = *(const u32 *) (rawKey + 12); + r; + } + ); + if (keyBitLength != 128) { + k[8] = s0 = ( { + u32 r = *(const u32 *) (rawKey + 16); + r; + } + ); + if (keyBitLength == 192) { + k[10] = s2 = ~s0; + k[11] = s3 = ~s1; + } + } + s0 ^= k[0], s1 ^= k[1], s2 ^= k[2], s3 ^= k[3]; + if (keyBitLength == 128) { + k[4] = s0, k[5] = s1, k[6] = s2, k[7] = s3; + } + else { + k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3; + s0 ^= k[8], s1 ^= k[9], s2 ^= k[10], s3 ^= k[11]; + do { + register u32 _t0, _t1, _t2, _t3; + _t0 = s2 ^ ((SIGMA + 10))[0]; + _t3 ^= Camellia_SBOX[3][(_t0 >> 8) & 0xff]; + s1 ^= _t3; + } + while (0); + do { + u32 _t0 = s0 >> (32 - 30); + s2 = (s2 << 30) | (s3 >> (32 - 30)); + s3 = (s3 << 30) | _t0; + } + while (0); + k[40] = s0, k[41] = s1, k[42] = s2, k[43] = s3; + k[64] = s1, k[65] = s2, k[66] = s3, k[67] = s0; + s0 = k[8], s1 = k[9], s2 = k[10], s3 = k[11]; + k[36] = s0, k[37] = s1, k[38] = s2, k[39] = s3; + s0 = k[12], s1 = k[13], s2 = k[14], s3 = k[15]; + do { + s1 = (s1 << 15) | (s2 >> (32 - 15)); + } + while (0); + k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3; + k[44] = s1, k[45] = s2, k[46] = s3, k[47] = s0; + } + } diff --git a/SingleSource/Regression/C/gcc-dg/pr55150-2.c b/SingleSource/Regression/C/gcc-dg/pr55150-2.c new file mode 100644 index 0000000000..ed571d6488 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55150-2.c @@ -0,0 +1,55 @@ +/* PR middle-end/55150 */ +/* { dg-do compile } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-Os -g -fPIC" } */ + +typedef unsigned char DES_cblock[8]; + typedef struct DES_ks { + } + DES_key_schedule; +void DES_encrypt1 (long *, DES_key_schedule *, int); + void DES_ede3_cbcm_encrypt (const unsigned char *in, unsigned char *out, long length, DES_key_schedule * ks1, DES_key_schedule * ks2, DES_key_schedule * ks3, DES_cblock * ivec1, DES_cblock * ivec2, int enc) { + register unsigned long tout0, tout1, xor0, xor1, m0, m1; + register long l = length; + unsigned long tin[2]; + unsigned char *iv1, *iv2; + iv1 = &(*ivec1)[0]; + iv2 = &(*ivec2)[0]; + if (enc) { + (m0 = ((unsigned long) (*((iv1)++))), m0 |= ((unsigned long) (*((iv1)++))) << 8L, m0 |= ((unsigned long) (*((iv1)++))) << 16L, m0 |= ((unsigned long) (*((iv1)++))) << 24L); + (m1 = ((unsigned long) (*((iv1)++))), m1 |= ((unsigned long) (*((iv1)++))) << 8L, m1 |= ((unsigned long) (*((iv1)++))) << 16L, m1 |= ((unsigned long) (*((iv1)++))) << 24L); + (tout0 = ((unsigned long) (*((iv2)++))), tout0 |= ((unsigned long) (*((iv2)++))) << 8L, tout0 |= ((unsigned long) (*((iv2)++))) << 16L, tout0 |= ((unsigned long) (*((iv2)++))) << 24L); + for (l -= 8; + l >= -7; + l -= 8) { + DES_encrypt1 (tin, ks3, 1); + DES_encrypt1 (tin, ks1, 1); + } + (*((iv1)++) = (unsigned char) (((m0)) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 8L) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 16L) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 24L) & 0xff)); + (*((iv1)++) = (unsigned char) (((m1)) & 0xff), *((iv1)++) = (unsigned char) (((m1) >> 8L) & 0xff), *((iv1)++) = (unsigned char) (((m1) >> 16L) & 0xff), *((iv1)++) = (unsigned char) (((m1) >> 24L) & 0xff)); + (*((iv2)++) = (unsigned char) (((tout0)) & 0xff), *((iv2)++) = (unsigned char) (((tout0) >> 8L) & 0xff), *((iv2)++) = (unsigned char) (((tout0) >> 16L) & 0xff), *((iv2)++) = (unsigned char) (((tout0) >> 24L) & 0xff)); + } + else { + (m0 = ((unsigned long) (*((iv1)++))), m0 |= ((unsigned long) (*((iv1)++))) << 8L, m0 |= ((unsigned long) (*((iv1)++))) << 16L, m0 |= ((unsigned long) (*((iv1)++))) << 24L); + (xor1 = ((unsigned long) (*((iv2)++))), xor1 |= ((unsigned long) (*((iv2)++))) << 8L, xor1 |= ((unsigned long) (*((iv2)++))) << 16L, xor1 |= ((unsigned long) (*((iv2)++))) << 24L); + for (l -= 8; + l >= -7; + l -= 8) { + DES_encrypt1 (tin, ks3, 1); + if (l < 0) { + { + switch (l + 8) { + case 7: *(--(out)) = (unsigned char) (((tout1) >> 16L) & 0xff); + case 6: *(--(out)) = (unsigned char) (((tout1) >> 8L) & 0xff); + case 5: *(--(out)) = (unsigned char) (((tout1)) & 0xff); + case 4: *(--(out)) = (unsigned char) (((tout0) >> 24L) & 0xff); + case 1: *(--(out)) = (unsigned char) (((tout0)) & 0xff); + } + }; + } + } + (*((iv1)++) = (unsigned char) (((m0)) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 8L) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 16L) & 0xff), *((iv1)++) = (unsigned char) (((m0) >> 24L) & 0xff)); + (*((iv2)++) = (unsigned char) (((xor0)) & 0xff), *((iv2)++) = (unsigned char) (((xor0) >> 8L) & 0xff), *((iv2)++) = (unsigned char) (((xor0) >> 16L) & 0xff), *((iv2)++) = (unsigned char) (((xor0) >> 24L) & 0xff)); + (*((iv2)++) = (unsigned char) (((xor1)) & 0xff), *((iv2)++) = (unsigned char) (((xor1) >> 8L) & 0xff), *((iv2)++) = (unsigned char) (((xor1) >> 16L) & 0xff), *((iv2)++) = (unsigned char) (((xor1) >> 24L) & 0xff)); + } + } diff --git a/SingleSource/Regression/C/gcc-dg/pr55152-2.c b/SingleSource/Regression/C/gcc-dg/pr55152-2.c new file mode 100644 index 0000000000..54db0f2062 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55152-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffinite-math-only -fno-signed-zeros -fstrict-overflow -fdump-tree-optimized" } */ + +double g (double a) +{ + return (a<-a)?a:-a; +} +int f(int a) +{ + return (a<-a)?a:-a; +} + +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr55152.c b/SingleSource/Regression/C/gcc-dg/pr55152.c new file mode 100644 index 0000000000..b1a72cb5a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55152.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffinite-math-only -fno-signed-zeros -fstrict-overflow -fdump-tree-optimized" } */ + +double g (double a) +{ + return (a>=-a)?a:-a; +} +int f(int a) +{ + return (a>=-a)?a:-a; +} + +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr55153.c b/SingleSource/Regression/C/gcc-dg/pr55153.c new file mode 100644 index 0000000000..215090cc42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55153.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/55153 */ +/* { dg-do compile } */ +/* { dg-options "-O -fsched2-use-superblocks -fschedule-insns2" } */ +/* { dg-require-effective-target scheduling } */ + +extern int a[]; + +void +foo (void) +{ + __builtin_prefetch (a, 0, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55191.c b/SingleSource/Regression/C/gcc-dg/pr55191.c new file mode 100644 index 0000000000..568425ce03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55191.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/55191 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a, b; + +void f(void) +{ + b = a || b; + + for(a = 0; a < 2; a++); + while(1); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr55236.c b/SingleSource/Regression/C/gcc-dg/pr55236.c new file mode 100644 index 0000000000..dc66c04c32 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55236.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/55236 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +extern void abort (); + +__attribute__((noinline, noclone)) void +foo (int i) +{ + if (i > 0) + abort (); + i = -i; + if (i < 0) + return; + abort (); +} + +__attribute__((noinline, noclone)) void +bar (int i) +{ + if (i > 0 || (-i) >= 0) + abort (); +} + +int +main () +{ + foo (-__INT_MAX__ - 1); + bar (-__INT_MAX__ - 1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55430.c b/SingleSource/Regression/C/gcc-dg/pr55430.c new file mode 100644 index 0000000000..ac56cacea5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55430.c @@ -0,0 +1,46 @@ +/* PR middle-end/55430 */ +/* { dg-do run { target mmap } } */ +/* { dg-options "-O2" } */ + +#include +#include +#include +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_ANON +#define MAP_ANON 0 +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif +#include + +struct S +{ + unsigned int s1 : 8; + unsigned int s2 : 2; +}; + +__attribute__((noinline, noclone)) int +foo (int x, int y, struct S *z, unsigned int w) +{ + if (z[y].s2 == x && z[y].s1 == w) + return 1; + return 0; +} + +int +main () +{ + char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) + return 0; + if (munmap (p + 65536, 65536) < 0) + return 0; + if ((65536 / sizeof (struct S)) * sizeof (struct S) != 65536) + return 0; + struct S *s = (struct S *) (p + 65536); + return foo (0, 0, s - 1, 0) != 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55570.c b/SingleSource/Regression/C/gcc-dg/pr55570.c new file mode 100644 index 0000000000..5f5555ee47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55570.c @@ -0,0 +1,4 @@ +/* PR c/55570 */ +/* { dg-do compile } */ + +char array[16] __attribute__((aligned (SOME_NOT_DEFINED_MACRO))); /* { dg-error "undeclared here" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr55702.c b/SingleSource/Regression/C/gcc-dg/pr55702.c new file mode 100644 index 0000000000..bf3d3ae5ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55702.c @@ -0,0 +1,9 @@ +/* PR sanitizer/55702 */ +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } */ +/* { dg-options "-fsanitize=thread" } */ + +void +foo () +{ + __builtin_return (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55831.c b/SingleSource/Regression/C/gcc-dg/pr55831.c new file mode 100644 index 0000000000..ce7be63e1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55831.c @@ -0,0 +1,39 @@ +/* PR tree-optimization/55831 */ +/* { dg-do compile } */ +/* { dg-options "-O -fstrict-overflow -ftree-vectorize -Wno-unused-label" } */ + +int g; +short p, q; + +void +foo (void) +{ + short a = p, b = q, i; + + if (a) + { + label: + for (i = 0; i < 8; i++) + b ^= a++; + + if (!b) + g = 0; + } +} + +void +bar (void) +{ + short a = p, b = q, i; + + if (a) + { + label: + for (i = 0; i < 8; i++) + b ^= (a = a + 1); + + if (!b) + g = 0; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr55833.c b/SingleSource/Regression/C/gcc-dg/pr55833.c new file mode 100644 index 0000000000..b35104b44e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55833.c @@ -0,0 +1,29 @@ +/* PR rtl-optimization/55833 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b, c; +int bar (void); + +void foo() +{ + unsigned d, l, *p, k = 1; + + if(bar()) + { +label: + if((a = a <= 0)) + { + if(c) + d = b; + + if (b || d ? l : k ? : 0) + a = d = 0; + + goto label; + } + } + + while(*p++) + goto label; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55838.c b/SingleSource/Regression/C/gcc-dg/pr55838.c new file mode 100644 index 0000000000..d2d6e142ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55838.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/55838 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-loops" } */ + +int a; +unsigned char c; + +void +f (void) +{ + while (c++ < 2) + c = a += 129; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr55940.c b/SingleSource/Regression/C/gcc-dg/pr55940.c new file mode 100644 index 0000000000..85761f6c31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr55940.c @@ -0,0 +1,55 @@ +/* PR target/55940 */ +/* { dg-do run } */ +/* { dg-skip-if "pointer arithmetic can wrap" { msp430-*-* } { "*" } { "-mlarge" } } */ +/* { dg-options "-Os" } */ +/* { dg-additional-options "-mpreferred-stack-boundary=2" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +struct S { int s; unsigned long t; }; + +__attribute__ ((noinline, noclone)) unsigned long long +bar (struct S *x, unsigned long y) +{ + asm volatile ("" : : "r" (x), "r" (y) : "memory"); + return x->s + y; +} + +__attribute__ ((noinline, noclone)) unsigned long long +foo (struct S *x, unsigned long y) +{ + unsigned long a; + if (__builtin_expect (((__UINTPTR_TYPE__) (x) + 0x1000U < 0x2000U), 0)) + return ~0ULL; + if (__builtin_expect (x->s <= 0 || x->s > 9, 0)) + return ~0ULL; + a = x->t >> 12; + if (y == a) + return ~0ULL; + if (x->s == 3) + return x->t + y * 4096; + return bar (x, y); +} + +int va, vb, vc, vd; + +int +main () +{ + struct S s; + asm volatile ("" : : : "memory"); + int a = va, b = vb, c = vc, d = vd; + asm volatile ("" : : : "memory"); + int i; + for (i = 0; i < 64; i++) + if (foo ((struct S *) 0, 0) != ~0ULL) + __builtin_abort (); + s.s = 3; + s.t = 2 << 12; + if (foo (&s, 2) != ~0ULL) + __builtin_abort (); + if (foo (&s, 3) != (2 << 12) + 3 * 4096) + __builtin_abort (); + asm volatile ("" : : : "memory"); + va = a; vb = b; vc = c; vd = d; + asm volatile ("" : : : "memory"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56023.c b/SingleSource/Regression/C/gcc-dg/pr56023.c new file mode 100644 index 0000000000..f1942ac18c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56023.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +void +foo (char *c) +{ + unsigned int x = 0; + unsigned int i; + + for (i = 0; c[i]; i++) + { + if (i >= 5 && x != 1) + break; + else if (c[i] == ' ') + x = i; + else if (c[i] == '/' && c[i + 1] != ' ' && i) + x = i + 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56035.c b/SingleSource/Regression/C/gcc-dg/pr56035.c new file mode 100644 index 0000000000..4e3a77e199 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56035.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/56035 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vectorize -fcse-follow-jumps -fstrict-overflow" } */ + +short a, c, *p; + +void +f (void) +{ + int b; + + if (c) + lbl1: + for (a = 0; a < 1; a++) + { + for (c = 0; c < 1; c++) + { + goto lbl1; + while (*p++) + lbl2: + ; + } + } + + for (;; b++) + { + if (c) + goto lbl2; + lbl3: + for (c = 0; c < 9; c++) + for (c = -17; c < 2; c++) + if (*p) + goto lbl3; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56078.c b/SingleSource/Regression/C/gcc-dg/pr56078.c new file mode 100644 index 0000000000..ba759f2209 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56078.c @@ -0,0 +1,25 @@ +/* PR c/56078 */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +typedef __SIZE_TYPE__ size_t; +extern int memcmp (const void *, const void *, size_t); +extern void abort (void); + +struct T { int a; char b[]; }; +struct T t1 = { .a = 1, .b = "abcd", .b[0] = '2' }; +struct T t2 = { .a = 1, .b = "2bcd" }; +struct T t3 = { .a = 1, .b[2] = 'a' }; +struct T t4 = { .a = 1, .b = { '\0', '\0', 'a' } }; +struct T t5 = { .a = 1, .b = { [0] = 'a', [1] = 'b', [2] = 'c' } }; +struct T t6 = { .a = 1, .b[2] = 'c', .b[1] = 'x', .b[0] = 'a', .b[1] = 'b' }; + +int +main () +{ + if (memcmp (t1.b, t2.b, sizeof ("abcd")) != 0 + || memcmp (t3.b, t4.b, 3) != 0 + || memcmp (t5.b, t6.b, 3) != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56094.c b/SingleSource/Regression/C/gcc-dg/pr56094.c new file mode 100644 index 0000000000..364e368cf0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56094.c @@ -0,0 +1,80 @@ +/* PR tree-optimization/56094 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fdump-tree-optimized-lineno" } */ + +_Bool cond; + +int +fn0 (unsigned char, unsigned long long, unsigned char, + unsigned char, signed short, unsigned int, + unsigned char *); + +extern void fn3 (unsigned char, unsigned char, unsigned char, unsigned char, + unsigned char, unsigned char, unsigned char, unsigned short); +extern void fn7 (int); +extern void fn8 (int); + +static __inline__ __attribute__ ((always_inline)) void +fn1 (unsigned char arg0, unsigned char arg1, unsigned char arg2, + unsigned char arg3, unsigned char arg4, unsigned char arg5, + unsigned short arg6) +{ + asm volatile ("" :: "g" ((unsigned long long) arg0), "g" (arg1), + "g" (arg2), "g" (arg3), "g" (arg4), "g" (arg5), + "g" (arg6)); + if (cond) + { + unsigned char loc0 = 0; + fn3 (loc0, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + } +} + +static __inline__ __attribute__ ((always_inline)) void +fn4 (unsigned int arg0, unsigned long long arg1) +{ + asm volatile ("" :: "g" (arg0), "g" (arg1)); +} + +static __inline__ __attribute__ ((always_inline)) void +fn5 (unsigned int arg0, unsigned char arg1, unsigned int arg2, + unsigned char arg3) +{ + asm volatile ("" :: "g" (arg0), "g" (arg1), + "g" ((unsigned long long) arg2), "g" (arg3)); +} + +static __inline__ __attribute__ ((always_inline)) void +fn6 (unsigned long long arg0, unsigned char arg1, + unsigned char arg2, signed short arg3, + unsigned int arg4, unsigned char * arg5) +{ + asm volatile ("" :: "g" (arg0), "g" ((unsigned long long) arg1), + "g" ((unsigned long long) arg2), "g" (arg3), + "g" (arg4), "g" (arg5)); + if (cond) + { + unsigned char loc0 = 0; + fn0 (loc0, arg0, arg1, arg2, arg3, arg4, arg5); + } +} + +unsigned char b[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa }; +unsigned int q = sizeof (b) / sizeof (b[0]); + +void +foo () +{ + int i; + for (i = 1; i <= 50; i++) + { + fn6 (i + 0x1234, i + 1, i + 0xa, i + 0x1234, q, b); + fn5 (i + 0xabcd, i << 1, i + 0x1234, i << 2); + fn7 (i + 0xdead); + fn8 (i + 0xdead); + fn1 (i, i + 1, i + 2, i + 3, i + 4, i + 5, i << 10); + fn4 (i + 0xfeed, i); + } +} + +/* Verify no statements get the location of the foo () decl. */ +/* { dg-final { scan-tree-dump-not " : 65:1\\\]" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr56098-1.c b/SingleSource/Regression/C/gcc-dg/pr56098-1.c new file mode 100644 index 0000000000..68e71fc0b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56098-1.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/56098 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +volatile int *p; + +void +foo (int x) +{ + *p = 1; + if (x) + *p = 2; +} + +/* { dg-final { scan-tree-dump-not "=\[^\n\r]*\\*p" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr56098-2.c b/SingleSource/Regression/C/gcc-dg/pr56098-2.c new file mode 100644 index 0000000000..cd4bff2f4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56098-2.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/56098 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fhoist-adjacent-loads -fdump-tree-optimized" } */ + +struct S { volatile int i; volatile int j; }; + +int +bar (struct S *x, int y) +{ + int r; + if (y) + r = x->i; + else + r = x->j; + return r; +} + +/* { dg-final { scan-tree-dump-not "r_\[0-9]* =.v. \[^\n\r]*;\[\n\r]* r_\[0-9]* =.v. " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr56117.c b/SingleSource/Regression/C/gcc-dg/pr56117.c new file mode 100644 index 0000000000..2422048156 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56117.c @@ -0,0 +1,9 @@ +/* PR rtl-optimization/56117 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsched2-use-superblocks" } */ + +void +foo (void *p) +{ + __builtin_prefetch (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56125.c b/SingleSource/Regression/C/gcc-dg/pr56125.c new file mode 100644 index 0000000000..d1840a9a05 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56125.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/56125 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern void abort (void); +extern double fabs (double); + +__attribute__((cold)) double +foo (double x, double n) +{ + double u = x / (n * n); + return u; +} + +int +main () +{ + if (fabs (foo (29, 2) - 7.25) > 0.001) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56144.c b/SingleSource/Regression/C/gcc-dg/pr56144.c new file mode 100644 index 0000000000..4b98225900 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56144.c @@ -0,0 +1,35 @@ +/* PR rtl-optimization/56144 */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int a; +union U0 { volatile unsigned f2, f4; }; +volatile int b; +static union U0 c; +volatile unsigned d, f; +volatile int e, g, h, i, j, k, l, m, n, o, p; +int +main () +{ + a = b; + a += c.f2; + a += c.f4; + unsigned q = h; + a += q; + q = g; + a += q; + a += f; + q = e; + a += q; + a += d; + a += 2L; + a += j; + a += i; + a += k; + a += p; + a += o; + a += n; + a += m; + a += l; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56167.c b/SingleSource/Regression/C/gcc-dg/pr56167.c new file mode 100644 index 0000000000..fc377b4756 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56167.c @@ -0,0 +1,15 @@ +/* PR middle-end/56167 */ +/* { dg-do compile } */ + +extern void foo (void) __attribute__ ((error (0))); /* { dg-warning "attribute ignored" } */ +extern void bar (void) __attribute__ ((warning (0))); /* { dg-warning "attribute ignored" } */ +int var __attribute__ ((error ("foo"))); /* { dg-warning "attribute ignored" } */ + +int +main () +{ + foo (); + bar (); + var++; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56228.c b/SingleSource/Regression/C/gcc-dg/pr56228.c new file mode 100644 index 0000000000..6e2b4b1ab9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56228.c @@ -0,0 +1,17 @@ +/* PR target/56228 */ +/* { dg-do assemble } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "accessing program memory with data memory address" { "avr-*-*" } } */ + +short a[14] = { 1, 2 }; +short b[15] = { 3, 4 }; + +int +foo () +{ + void (*fna) (void) = (void (*) (void)) a; + void (*fnb) (void) = (void (*) (void)) b; + fna (); + fnb (); + return a[1] == b[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56275.c b/SingleSource/Regression/C/gcc-dg/pr56275.c new file mode 100644 index 0000000000..b901bb2b19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56275.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */ + +typedef long long v2tw __attribute__ ((vector_size (2 * sizeof (long long)))); + +void tiger_block_v2 (long long in1, v2tw *res) +{ + v2tw i1 = { in1, in1 }; + + *res = i1 << 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56341-1.c b/SingleSource/Regression/C/gcc-dg/pr56341-1.c new file mode 100644 index 0000000000..91cf80ba28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56341-1.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-fstrict-volatile-bitfields" } */ + +extern void abort (void); + +struct test0 +{ + unsigned char b1[2]; +} __attribute__((packed, aligned(2))); + +struct test1 +{ + volatile unsigned long a1; + unsigned char b1[4]; +} __attribute__((packed, aligned(2))); + +struct test2 +{ + struct test0 t0; + struct test1 t1; + struct test0 t2; +} __attribute__((packed, aligned(2))); + +struct test2 xx; +struct test2 *x1 = &xx; + +#define MAGIC 0x12345678 + +void test0 (struct test2* x1) +{ + x1->t1.a1 = MAGIC; +} + +int main() +{ + test0 (x1); + if (xx.t1.a1 != MAGIC) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56341-2.c b/SingleSource/Regression/C/gcc-dg/pr56341-2.c new file mode 100644 index 0000000000..e6f6569f08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56341-2.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-fno-strict-volatile-bitfields" } */ + +extern void abort (void); + +struct test0 +{ + unsigned char b1[2]; +} __attribute__((packed, aligned(2))); + +struct test1 +{ + volatile unsigned long a1; + unsigned char b1[4]; +} __attribute__((packed, aligned(2))); + +struct test2 +{ + struct test0 t0; + struct test1 t1; + struct test0 t2; +} __attribute__((packed, aligned(2))); + +struct test2 xx; +struct test2 *x1 = &xx; + +#define MAGIC 0x12345678 + +void test0 (struct test2* x1) +{ + x1->t1.a1 = MAGIC; +} + +int main() +{ + test0 (x1); + if (xx.t1.a1 != MAGIC) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56350.c b/SingleSource/Regression/C/gcc-dg/pr56350.c new file mode 100644 index 0000000000..899a507ee8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56350.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/56350 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-vectorize" } */ + +int a, b, c; + +void +f (void) +{ + for (; c; c++) + for (b = 0; b < 2; b++) + a /= 8; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56355-1.c b/SingleSource/Regression/C/gcc-dg/pr56355-1.c new file mode 100644 index 0000000000..08b9c2e710 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56355-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-overflow=4" } */ + +int +f (int i) +{ + return __builtin_abs (i * i); /* { dg-warning "assuming signed overflow" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56396.c b/SingleSource/Regression/C/gcc-dg/pr56396.c new file mode 100644 index 0000000000..160545b985 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56396.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/56396 */ +/* { dg-do compile } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fpic -g" } */ + +struct S { char *s; int z; }; +struct T { int t; } *c, u; +void bar (int, const char *); + +inline void * +foo (void *x, char *y, int z) +{ + struct S s; + char b[256]; + s.s = b; + s.z = __builtin___sprintf_chk (s.s, 1, __builtin_object_size (s.s, 2), "Require"); + if (s.z < 0) + bar (u.t | c->t, "rls"); + if (foo (x, s.s, s.z)) + { + } + return (void *) 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56424.c b/SingleSource/Regression/C/gcc-dg/pr56424.c new file mode 100644 index 0000000000..7f28f04471 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56424.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/56424 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fexceptions -fnon-call-exceptions" } */ +/* { dg-require-effective-target exceptions } */ + +extern long double cosl (long double); +extern long double sinl (long double); +extern long double reml (long double, long double); + +long double my_cos (long double arg) +{ + return cosl (arg); +} + +long double my_sin (long double arg) +{ + if (__builtin_fabs (arg) < 1.0) + return arg; + + return sinl (arg); +} + +long double my_cot (long double arg, long double cycle) +{ + long double t = reml (arg, cycle); + return my_cos (t) / my_sin (t); +} + +long double my_tan (long double arg, long double cycle) +{ + long double t = reml (arg, cycle); + return my_sin (t) / my_cos (t); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56436.c b/SingleSource/Regression/C/gcc-dg/pr56436.c new file mode 100644 index 0000000000..cae4d2a4bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56436.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/56426 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a, *c; + +void +f (void) +{ + int b = 0; + + for (a = 0;; a++) + if (--b) + { + if (a) + lbl: + a++; + + c = &b; + goto lbl; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56466.c b/SingleSource/Regression/C/gcc-dg/pr56466.c new file mode 100644 index 0000000000..9d9e27356e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56466.c @@ -0,0 +1,31 @@ +/* PR rtl-optimization/56466 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -w -funroll-loops" } */ + +int a, b, c; + +void +f (void) +{ + for (; b; b++) + { + if (0) + for (; b < 0; b++) + if (1 % 0) + { + while (1) + { + a = 0; + lbl1: + c++; + } + lbl2: + ; + } + + goto lbl1; + } + + a = 0; + goto lbl2; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56494.c b/SingleSource/Regression/C/gcc-dg/pr56494.c new file mode 100644 index 0000000000..e73d674a98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56494.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/56494 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftracer -w" } */ + +char a; +short b; +void bar (int); + +void +foo (void) +{ + bar ((!!b ? : (a *= a / 0)) >= (a = b)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56510.c b/SingleSource/Regression/C/gcc-dg/pr56510.c new file mode 100644 index 0000000000..d018d7d4ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56510.c @@ -0,0 +1,38 @@ +/* PR debug/56510 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +__extension__ typedef __INTPTR_TYPE__ intptr_t; +struct S { unsigned long s1; void **s2[0]; }; +void **a, **b, **c, **d, **e, **f; + +static void ** +baz (intptr_t x, intptr_t y) +{ + void **s = f; + *f = (void **) (y << 8 | (x & 0xff)); + f += y + 1; + return s; +} + +void bar (void); +void +foo (void) +{ + void **g = b[4]; + a = b[2]; + b = b[1]; + g[2] = e; + void **h + = ((void **************************) + a)[1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][66]; + void **i = ((struct S *) h)->s2[4]; + d = baz (4, 3); + d[1] = b; + d[2] = a; + d[3] = bar; + b = d; + g[1] = i[2]; + a = g; + ((void (*) (void)) (i[1])) (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56548.c b/SingleSource/Regression/C/gcc-dg/pr56548.c new file mode 100644 index 0000000000..2aa61d9cc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56548.c @@ -0,0 +1,16 @@ +/* PR middle-end/56548 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-march=pentium3" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +short +foo (short x) +{ + int i; + + for (i = 0; i < 3; i++) + if (x > 0) + x--; + + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56724-1.c b/SingleSource/Regression/C/gcc-dg/pr56724-1.c new file mode 100644 index 0000000000..4276c3f154 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56724-1.c @@ -0,0 +1,33 @@ +/* PR c/56724 */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional-conversion" } */ + +extern void foo (int p[2][]); /* { dg-error "array type has incomplete element type" } */ +extern void foo_i (int, int); +extern void foo_u (unsigned int); +extern void foo_f (int, float); +extern void foo_ll (long long); +extern void foo_cd (int, int, __complex__ double); +extern signed char sc; +extern int i; +extern unsigned int u; +extern float f; +extern double d; +extern __complex__ double cd; + +void +fn () +{ + int p[1][1]; + foo (p); /* { dg-error "8:type of formal parameter" } */ + foo_i (1, f); /* { dg-warning "13:passing argument" } */ + foo_i (1, cd); /* { dg-warning "13:passing argument" } */ + foo_cd (1, 2, f); /* { dg-warning "17:passing argument" } */ + foo_f (9, i); /* { dg-warning "13:passing argument" } */ + foo_cd (2, 2, i); /* { dg-warning "17:passing argument" } */ + foo_f (2, cd); /* { dg-warning "13:passing argument" } */ + foo_f (2, d); /* { dg-warning "13:passing argument" } */ + foo_ll (sc); /* { dg-warning "11:passing argument" } */ + foo_u (i); /* { dg-warning "10:passing argument" } */ + foo_i (1, u); /* { dg-warning "13:passing argument" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56724-2.c b/SingleSource/Regression/C/gcc-dg/pr56724-2.c new file mode 100644 index 0000000000..4abb7d899e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56724-2.c @@ -0,0 +1,31 @@ +/* PR c/56724 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat -Wpedantic" } */ + +enum E1 { A }; +enum E2 { B }; +extern void foo_E (enum E1); +extern void foo_v (void *p); +extern void foo_sc (int, int, signed char *); +extern unsigned char *uc; +extern signed char sc; +extern const signed char *csc; +extern float *f; + +void +foo (void) +{ + void (*fp)(void); + const void (*ffp)(void); + foo_v (fp); /* { dg-warning "10:ISO C forbids passing argument" } */ + foo_E (B); /* { dg-warning "10:enum conversion when passing argument" } */ + foo_sc (1, 2, uc); /* { dg-warning "17:pointer targets in passing argument" } */ + foo_sc (1, 2, f); /* { dg-warning "17:passing argument" } */ + foo_sc (1, 2, sc); /* { dg-warning "17:passing argument" } */ + foo_sc (uc, 2, &sc); /* { dg-warning "11:passing argument" } */ + foo_sc (1, 2, csc); /* { dg-warning "17:passing argument" } */ +} + +typedef void (*fp)(void); +typedef void (*nrfp)(void) __attribute__((noreturn)); +void f1 (nrfp); void f2 (fp x) { f1 (x); } extern int e; /* { dg-warning "38:passing argument" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr56724-3.c b/SingleSource/Regression/C/gcc-dg/pr56724-3.c new file mode 100644 index 0000000000..192d71962a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56724-3.c @@ -0,0 +1,14 @@ +/* PR c/56724 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +extern void xfer (int, int, unsigned char *); +struct T { int a; } t; + +void +call (int x, int y, void *arg) +{ + unsigned char *uc = arg; /* { dg-warning "23:request for implicit conversion" } */ + xfer (x, y, arg); /* { dg-warning "15:request for implicit conversion" } */ + xfer (x, y, t); /* { dg-error "15:incompatible type for" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56727-1.c b/SingleSource/Regression/C/gcc-dg/pr56727-1.c new file mode 100644 index 0000000000..a26edb2bf9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56727-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ + +#define define_func(type) \ + void f_ ## type (type b) { f_ ## type (0); } \ + void __attribute__((noinline, noclone)) f_noinline_ ## type (type b) \ + { f_noinline_ ## type (0); } + +define_func(char) +define_func(short) +define_func(int) +define_func(long) + +int foo(int n) +{ + return (n == 1 || n == 2) ? 1 : foo(n-1) * foo(n-2); +} + +int __attribute__((noinline, noclone)) foo_noinline(int n) +{ + return (n == 1 || n == 2) ? 1 : foo_noinline(n-1) * foo_noinline(n-2); +} + +/* { dg-final { scan-assembler-not "@(PLT|plt)" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-assembler-not "@(PLT|plt)" { target { powerpc*-*-* && ilp32 } } } } */ +/* { dg-final { scan-assembler-not "bl \[a-z_\]*\n\\s*nop" { target { powerpc*-*-* && lp64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr56727-2.c b/SingleSource/Regression/C/gcc-dg/pr56727-2.c new file mode 100644 index 0000000000..77fdf4bc35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56727-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fPIC" } */ +/* { dg-require-alias "" } */ + +__attribute__((noinline, noclone)) +void f (short b) +{ + __builtin_setjmp (0); /* Prevent tailcall */ + f (0); +} + +static void g (short) __attribute__ ((alias ("f"))); + +void h () +{ + g (0); +} + +/* { dg-final { scan-assembler "@(PLT|plt)" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-assembler "@(PLT|plt)" { target { powerpc*-*-linux* && ilp32 } } } } */ +/* { dg-final { scan-assembler "(bl f\n\\s*nop)|(bl f@notoc)" { target { powerpc*-*-linux* && lp64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr56809.c b/SingleSource/Regression/C/gcc-dg/pr56809.c new file mode 100644 index 0000000000..3f1f3115c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56809.c @@ -0,0 +1,32 @@ +/* PR target/56809 */ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +int +foo (int mode, int i) +{ + int x; + + switch (mode) + { + case 0: + x = i + 1; + break; + case 1: + x = i / 2; + break; + case 2: + x = i * 3; + break; + case 3: + x = i + 3; + break; + case 4: + x = i + 5; + break; + default: + x = i - 1; + } + + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56824.c b/SingleSource/Regression/C/gcc-dg/pr56824.c new file mode 100644 index 0000000000..d682d0a810 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56824.c @@ -0,0 +1,18 @@ +/* PR preprocessor/56824 */ +/* { dg-do compile } */ +/* { dg-options "-Waggregate-return" } */ + +struct S { int i; }; +struct S foo (void); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waggregate-return" + +int +main () +{ + foo (); + return 0; +} + +#pragma GCC diagnostic pop diff --git a/SingleSource/Regression/C/gcc-dg/pr56837.c b/SingleSource/Regression/C/gcc-dg/pr56837.c new file mode 100644 index 0000000000..6466b11948 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56837.c @@ -0,0 +1,66 @@ +/* Limit this test to selected targets with IEEE double, 8-byte long long, + supported 4x int vectors, 4-byte int. */ +/* { dg-do compile { target { i?86-*-* x86_64-*-* powerpc*-*-* } } } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-additional-options "-msse2" { target ia32 } } */ +/* { dg-additional-options "-mvsx -maltivec" { target powerpc*-*-* } } */ + +typedef int V __attribute__((__vector_size__ (16))); +#define N 1024 +double d[N]; +long long int l[N]; +_Bool b[N]; +_Complex double c[N]; +V v[N]; + +void +fd (void) +{ + int i; + for (i = 0; i < N; i++) + d[i] = 747708026454360457216.0; +} + +void +fl (void) +{ + int i; + for (i = 0; i < N; i++) + l[i] = 0x7c7c7c7c7c7c7c7cULL; +} + +void +fb (void) +{ + int i; + for (i = 0; i < N; i++) + b[i] = 1; +} + +void +fc (void) +{ + int i; + for (i = 0; i < N; i++) + c[i] = 747708026454360457216.0 + 747708026454360457216.0i; +} + +void +fv (void) +{ + int i; + for (i = 0; i < N; i++) + v[i] = (V) { 0x12121212, 0x12121212, 0x12121212, 0x12121212 }; +} + +/* Look for + __builtin_memset (&d, 68, 8192); + __builtin_memset (&l, 124, 8192); + __builtin_memset (&b, 1, 1024); + __builtin_memset (&c, 68, 16384); + __builtin_memset (&v, 18, 16384); */ +/* { dg-final { scan-tree-dump-times "memset ..d, 68, 8192.;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "memset ..l, 124, 8192.;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "memset ..b, 1, 1024.;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "memset ..c, 68, 16384.;" 1 "optimized" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "memset ..v, 18, 16384.;" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr56847.c b/SingleSource/Regression/C/gcc-dg/pr56847.c new file mode 100644 index 0000000000..b94aae1d89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56847.c @@ -0,0 +1,12 @@ +/* PR rtl-optimization/56847 */ +/* { dg-do compile { target pie } } */ +/* { dg-options "-O2 -fpie" } */ + +struct S { long int a, b; } e; +__thread struct S s; + +void +foo (void) +{ + s = e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56890-1.c b/SingleSource/Regression/C/gcc-dg/pr56890-1.c new file mode 100644 index 0000000000..93b2134e59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56890-1.c @@ -0,0 +1,15 @@ +/* PR target/56890 */ +/* Reported by Rainer Jung */ + +/* { dg-do assemble } */ +/* { dg-options "-O2" } */ + +unsigned int buggy(unsigned int min, unsigned int max) +{ + if (max < 16384) { + unsigned short num16 = 0; + num16 = min + (long) ((double) (max - min + 1.0) * (num16 / (65535 + 1.0))); + return num16; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56890-2.c b/SingleSource/Regression/C/gcc-dg/pr56890-2.c new file mode 100644 index 0000000000..474327e9d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56890-2.c @@ -0,0 +1,19 @@ +/* PR target/56890 */ +/* Reported by Rainer Jung */ + +/* { dg-do assemble } */ +/* { dg-options "-O" } */ + +unsigned int buggy(unsigned int min, unsigned int max) +{ + unsigned int number; + if (max < 16384) { + unsigned short num16; + num16 = min + (long) ((double) (max - min + 1.0) * (num16 / (65535 + 1.0))); + return num16; + } + else { + (number) = min + (long) ((double) (max - min + 1.0) * (number / (4294967295U + 1.0))); + } + return number; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56977.c b/SingleSource/Regression/C/gcc-dg/pr56977.c new file mode 100644 index 0000000000..fde88afed1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56977.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Og" } */ + +__attribute__((__error__("error"))) void error (); + +void f (int i) { + if (__builtin_constant_p (i)) { + error (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56980.c b/SingleSource/Regression/C/gcc-dg/pr56980.c new file mode 100644 index 0000000000..5303c6135f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56980.c @@ -0,0 +1,24 @@ +/* PR c/56980 */ +/* { dg-do compile } */ + +typedef struct A { int i; } B; +typedef union U { int i; } V; +typedef enum E { G } F; + +void foo_s (struct A); /* { dg-message "expected .struct A. but argument is of type 'B \\*' {aka 'struct A \\*'}" } */ +void foo_u (union U); /* { dg-message "expected .union U. but argument is of type 'V \\*' {aka 'union U \\*'}" } */ +void foo_e (enum E); /* { dg-message "expected .enum E. but argument is of type 'F \\*' {aka 'enum E \\*'}" } */ +void foo_sp (B *); /* { dg-message "expected 'B \\*' {aka 'struct A \\*'} but argument is of type .struct B \\*." } */ +void foo_up (V *); /* { dg-message "expected 'V \\*' {aka 'union U \\*'} but argument is of type .union V \\*." } */ +void foo_ep (F *); /* { dg-message "expected 'F \\*' {aka 'enum E \\*'} but argument is of type .enum F \\*." } */ + +void +bar (B *b, V *v, F *f) +{ + foo_s (b); /* { dg-error "incompatible" } */ + foo_u (v); /* { dg-error "incompatible" } */ + foo_e (f); /* { dg-error "incompatible" } */ + foo_sp ((struct B *) b); /* { dg-error "passing argument" } */ + foo_up ((union V *) v); /* { dg-error "passing argument" } */ + foo_ep (__extension__ (enum F *) f); /* { dg-error "passing argument" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56989.c b/SingleSource/Regression/C/gcc-dg/pr56989.c new file mode 100644 index 0000000000..beb980678b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56989.c @@ -0,0 +1,19 @@ +/* PR c/56989 */ +/* { dg-do compile } */ + +extern void voidf (void); +extern int intf (void); + +int +f (void) +{ + if (intf () < 0 + || voidf () < 0) /* { dg-error "10:void value not ignored as it ought to be" } */ + return 1; + + if (voidf () < 0 /* { dg-error "7:void value not ignored as it ought to be" } */ + || intf () < 0) + return 1; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56990.c b/SingleSource/Regression/C/gcc-dg/pr56990.c new file mode 100644 index 0000000000..c857785c83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56990.c @@ -0,0 +1,10 @@ +/* PR sanitizer/56990 */ +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } */ +/* { dg-options "-fsanitize=thread" } */ + +struct S{}; + +void foo(struct S *p) +{ + *p = (struct S){}; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56992.c b/SingleSource/Regression/C/gcc-dg/pr56992.c new file mode 100644 index 0000000000..e945a18ca8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56992.c @@ -0,0 +1,18 @@ +/* PR rtl-optimization/56992 */ +/* { dg-do compile } */ +/* { dg-options "-Og -g" } */ + +inline int +foo (const char *x) +{ + return __builtin_strlen (x); +} + +int +bar (const char *x, unsigned int *y) +{ + unsigned int l = foo (x); + if (l > 15) + l = 15; + *y = l; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56997-1.c b/SingleSource/Regression/C/gcc-dg/pr56997-1.c new file mode 100644 index 0000000000..42458a106c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56997-1.c @@ -0,0 +1,44 @@ +/* Test volatile access to unaligned field. */ +/* { dg-do run } */ +/* { dg-options "-fstrict-volatile-bitfields" } */ + +extern void abort (void); + +#define test_type unsigned short +#define MAGIC (unsigned short)0x102u + +typedef struct s{ + unsigned char Prefix; + test_type Type; +}__attribute((__packed__)) ss; + +volatile ss v; +ss g; + +void __attribute__((noinline)) +foo (test_type u) +{ + v.Type = u; +} + +test_type __attribute__((noinline)) +bar (void) +{ + return v.Type; +} + +int main() +{ + test_type temp; + foo(MAGIC); + __builtin_memcpy(&g, (void *)&v, sizeof(g)); + if (g.Type != MAGIC) + abort (); + + g.Type = MAGIC; + __builtin_memcpy((void *)&v, &g, sizeof(v)); + temp = bar(); + if (temp != MAGIC) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56997-2.c b/SingleSource/Regression/C/gcc-dg/pr56997-2.c new file mode 100644 index 0000000000..759a469bd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56997-2.c @@ -0,0 +1,45 @@ +/* Test volatile access to unaligned field. */ +/* { dg-do run } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fstrict-volatile-bitfields" } */ + +extern void abort (void); + +#define test_type unsigned int +#define MAGIC 0x1020304u + +typedef struct s{ + unsigned char Prefix; + test_type Type; +}__attribute((__packed__)) ss; + +volatile ss v; +ss g; + +void __attribute__((noinline)) +foo (test_type u) +{ + v.Type = u; +} + +test_type __attribute__((noinline)) +bar (void) +{ + return v.Type; +} + +int main() +{ + test_type temp; + foo(MAGIC); + __builtin_memcpy(&g, (void *)&v, sizeof(g)); + if (g.Type != MAGIC) + abort (); + + g.Type = MAGIC; + __builtin_memcpy((void *)&v, &g, sizeof(v)); + temp = bar(); + if (temp != MAGIC) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56997-3.c b/SingleSource/Regression/C/gcc-dg/pr56997-3.c new file mode 100644 index 0000000000..3754b108ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56997-3.c @@ -0,0 +1,44 @@ +/* Test volatile access to unaligned field. */ +/* { dg-do run } */ +/* { dg-options "-fstrict-volatile-bitfields" } */ + +extern void abort (void); + +#define test_type unsigned long long +#define MAGIC 0x102030405060708ull + +typedef struct s{ + unsigned char Prefix; + test_type Type; +}__attribute((__packed__)) ss; + +volatile ss v; +ss g; + +void __attribute__((noinline)) +foo (test_type u) +{ + v.Type = u; +} + +test_type __attribute__((noinline)) +bar (void) +{ + return v.Type; +} + +int main() +{ + test_type temp; + foo(MAGIC); + __builtin_memcpy(&g, (void *)&v, sizeof(g)); + if (g.Type != MAGIC) + abort (); + + g.Type = MAGIC; + __builtin_memcpy((void *)&v, &g, sizeof(v)); + temp = bar(); + if (temp != MAGIC) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr56997-4.c b/SingleSource/Regression/C/gcc-dg/pr56997-4.c new file mode 100644 index 0000000000..ecca9c69c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr56997-4.c @@ -0,0 +1,22 @@ +/* Test volatile access to unaligned field. */ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-volatile-bitfields -fdump-rtl-final" } */ + +#define test_type unsigned short + +typedef struct s{ + unsigned char Prefix[1]; + volatile test_type Type; +}__attribute((__packed__,__aligned__(4))) ss; + +extern volatile ss v; + +void +foo (test_type u) +{ + v.Type = u; +} + +/* The C++ memory model forbids data store race conditions outside the + unaligned data member, therefore only QI or HI access is allowed, no SI. */ +/* { dg-final { scan-rtl-dump-not "mem/v(/.)*:SI" "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr57104.c b/SingleSource/Regression/C/gcc-dg/pr57104.c new file mode 100644 index 0000000000..2539d59c5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57104.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/57104 */ +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } */ +/* { dg-options "-fsanitize=thread" } */ + +register int r asm ("r14"); +int v; + +int +foo (void) +{ + return r + v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57105.c b/SingleSource/Regression/C/gcc-dg/pr57105.c new file mode 100644 index 0000000000..a968f52375 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57105.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fselective-scheduling2 -g" } */ +int bar (int); +int *baz (int *); + +void +foo (int a) +{ + while (bar (0)) + { + int *c = baz (0); + if (a) + { + int i = *baz (c); + } + bar (*baz (c)); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57134.c b/SingleSource/Regression/C/gcc-dg/pr57134.c new file mode 100644 index 0000000000..b834b0b159 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57134.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mstrict-align" { target { powerpc*-*-linux* powerpc*-*-elf* } } } */ + +#include + +typedef struct { + int64_t counter; +} atomic64_t; + +struct buffer_page { + void *a, *b; + atomic64_t entries; +}; + +static __inline__ __attribute__((always_inline)) int64_t +atomic64_read(const atomic64_t *v) +{ + int64_t t; + __asm__ __volatile__("" : "=r"(t) : "m"(v->counter)); + return t; +} + +int rb_remove_pages(void *p) +{ + struct buffer_page *blah = (void *)((intptr_t) p & -4); + return atomic64_read(&blah->entries); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57149.c b/SingleSource/Regression/C/gcc-dg/pr57149.c new file mode 100644 index 0000000000..ab4d5e4089 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57149.c @@ -0,0 +1,50 @@ +/* PR tree-optimization/57149 */ +/* { dg-do compile } */ +/* { dg-options "-Os -Wuninitialized" } */ + +struct A { struct A *a, *b; }; +struct D { struct A e; }; +struct E { unsigned char f; struct { struct A e; } g; }; +struct F { struct E i[32]; }; + +extern int fn0 (void); +extern int fn1 (struct E *, struct D *); + +static inline __attribute__ ((always_inline)) int +fn2 (const struct A *x) +{ + return x->a == x; +} + +static int +fn3 (struct E *x) +{ + struct D *l, *m; + int retval = retval; + if (fn2 (&x->g.e)) + return 0; + for (l = (struct D *) x->g.e.a, m = (struct D *) l->e.a; + &l->e != &x->g.e; + l = m, m = (struct D *) m->e.a) + retval = fn1 (x, l); + return retval; +} + +void +fn4 (struct F *x, unsigned k) +{ + unsigned i; + for (i = 0; i < k; i++) + { + struct E *y = &x->i[i]; + int err = -22; + err = fn3 (y); + if (y->f == 0) + { + if (err > 0) + err = fn0 (); + if (err < 0) /* { dg-bogus "may be used uninitialized in this function" } */ + fn0 (); + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57154.c b/SingleSource/Regression/C/gcc-dg/pr57154.c new file mode 100644 index 0000000000..6e436befe9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57154.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fschedule-insns" } */ +/* { dg-require-effective-target scheduling } */ + +#define PF_FROZEN 0x00010000 +#define likely(x) __builtin_expect(!!(x), 1) + +struct cur +{ + unsigned long flags; +}; +struct cur *cur; + +unsigned long freeze_cnt; + +extern int foo(void *); +extern int slow_path(void *); + +static inline int freezing(void *p) +{ + if (likely(!foo(&freeze_cnt))) + return 0; + return slow_path(p); +} + +extern int blah(void); + +int testcase(int check_kthr_stop) +{ + int was_frozen = 0; + + for (;;) { + if (!freezing(cur) || + (check_kthr_stop && blah())) + cur->flags &= ~PF_FROZEN; + + if (!(cur->flags & PF_FROZEN)) + break; + + was_frozen = 1; + } + + return was_frozen; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57184.c b/SingleSource/Regression/C/gcc-dg/pr57184.c new file mode 100644 index 0000000000..319d3fd531 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57184.c @@ -0,0 +1,13 @@ +/* PR debug/57184 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +struct S {}; +void bar (struct S *const); +static struct S *const c = &(struct S) {}; + +void +foo (void) +{ + bar (c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57233.c b/SingleSource/Regression/C/gcc-dg/pr57233.c new file mode 100644 index 0000000000..484844e491 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57233.c @@ -0,0 +1,172 @@ +/* PR tree-optimization/57233 */ +/* { dg-do run { target { ilp32 || lp64 } } } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +typedef unsigned V4 __attribute__((vector_size(4 * sizeof (int)))); +typedef unsigned V8 __attribute__((vector_size(8 * sizeof (int)))); +typedef unsigned V16 __attribute__((vector_size(16 * sizeof (int)))); +V4 a, b, g; +V8 c, d, h; +V16 e, f, j; + +__attribute__((noinline)) void +f1 (void) +{ + a = (a << 2) | (a >> 30); +} + +__attribute__((noinline)) void +f2 (void) +{ + a = (a << 30) | (a >> 2); +} + +__attribute__((noinline)) void +f3 (void) +{ + a = (a << b) | (a >> (32 - b)); +} + +__attribute__((noinline, noclone)) void +f4 (int x) +{ + a = (a << x) | (a >> (32 - x)); +} + +__attribute__((noinline)) void +f5 (void) +{ + c = (c << 2) | (c >> 30); +} + +__attribute__((noinline)) void +f6 (void) +{ + c = (c << 30) | (c >> 2); +} + +__attribute__((noinline)) void +f7 (void) +{ + c = (c << d) | (c >> (32 - d)); +} + +__attribute__((noinline, noclone)) void +f8 (int x) +{ + c = (c << x) | (c >> (32 - x)); +} + +__attribute__((noinline)) void +f9 (void) +{ + e = (e << 2) | (e >> 30); +} + +__attribute__((noinline)) void +f10 (void) +{ + e = (e << 30) | (e >> 2); +} + +__attribute__((noinline)) void +f11 (void) +{ + e = (e << f) | (e >> (32 - f)); +} + +__attribute__((noinline, noclone)) void +f12 (int x) +{ + e = (e << x) | (e >> (32 - x)); +} + +unsigned +r (void) +{ + static unsigned x = 0xdeadbeefU; + static unsigned y = 0x12347654U; + static unsigned z = 0x1a2b3c4dU; + static unsigned w = 0x87654321U; + unsigned t = x ^ (x << 11); + x = y; + y = z; + z = w; + w = w ^ (w >> 19) ^ t ^ (t >> 8); + return w; +} + +void +init (unsigned int *p, int count, int mod) +{ + int i; + for (i = 0; i < count; i++) + { + unsigned int v = r (); + if (mod) + v = (v % 31) + 1; + p[i] = v; + } +} + +void +check (unsigned int *p, unsigned int *q, int count, unsigned int *s, int ss) +{ + int i; + for (i = 0; i < count; i++) + { + if (s) + ss = s[i]; + if (p[i] != ((q[i] << ss) | (q[i] >> (32 - ss)))) + __builtin_abort (); + } +} + +int +main () +{ + init ((unsigned int *) &a, 4, 0); + init ((unsigned int *) &b, 4, 1); + init ((unsigned int *) &c, 8, 0); + init ((unsigned int *) &d, 8, 1); + init ((unsigned int *) &e, 16, 0); + init ((unsigned int *) &f, 16, 1); + g = a; + h = c; + j = e; + f1 (); + f5 (); + f9 (); + check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 2); + check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 2); + check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 2); + g = a; + h = c; + j = e; + f2 (); + f6 (); + f10 (); + check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 30); + check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 30); + check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 30); + g = a; + h = c; + j = e; + f3 (); + f7 (); + f11 (); + check ((unsigned int *) &a, (unsigned int *) &g, 4, (unsigned int *) &b, 0); + check ((unsigned int *) &c, (unsigned int *) &h, 8, (unsigned int *) &d, 0); + check ((unsigned int *) &e, (unsigned int *) &j, 16, (unsigned int *) &f, 0); + g = a; + h = c; + j = e; + f4 (5); + f8 (5); + f12 (5); + check ((unsigned int *) &a, (unsigned int *) &g, 4, 0, 5); + check ((unsigned int *) &c, (unsigned int *) &h, 8, 0, 5); + check ((unsigned int *) &e, (unsigned int *) &j, 16, 0, 5); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57286.c b/SingleSource/Regression/C/gcc-dg/pr57286.c new file mode 100644 index 0000000000..c6f4530548 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57286.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +typedef int vec __attribute__ ((vector_size (4*sizeof(int)))); +void f (vec *x){ + *x = (*x < 0) | 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57287-2.c b/SingleSource/Regression/C/gcc-dg/pr57287-2.c new file mode 100644 index 0000000000..b41ae64f93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57287-2.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include + +struct node +{ + struct node *next; + char *name; +} *list; + +struct node *list; +struct node *head (void); + +jmp_buf *bar (void); + +int baz (void) +{ + struct node *n; + int varseen = 0; + + list = head (); + for (n = list; n; n = n->next) + { + if (!varseen) + varseen = 1; + + jmp_buf *buf = bar (); /* { dg-bogus "may be used uninitialized" } */ + setjmp (*buf); + } + + if (!varseen) + return 0; + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57287.c b/SingleSource/Regression/C/gcc-dg/pr57287.c new file mode 100644 index 0000000000..47ed5b7988 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57287.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include + +jmp_buf buf; + +void foo (int); +void bar (int) __attribute__((leaf)); + +void enumerate_locals (int indent) +{ + foo (0); + while (indent--) + { + int local_indent = 8 + (8 * indent); + if (local_indent != 8) + { + setjmp (buf); + bar (local_indent); /* { dg-bogus "may be used uninitialized" } */ + } + } + foo (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57300.c b/SingleSource/Regression/C/gcc-dg/pr57300.c new file mode 100644 index 0000000000..13a272de59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57300.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/57300 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ + +extern void abort (void); +int a, b, d[10]; +long long c; + +int +main () +{ + int e; + for (e = 0; e < 10; e++) + d[e] = 1; + if (d[0]) + c = a = (b == 0 || 1 % b); + if (a != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57371-5.c b/SingleSource/Regression/C/gcc-dg/pr57371-5.c new file mode 100644 index 0000000000..ddad25db62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57371-5.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ +/* { dg-require-effective-target dfp } */ + +/* We do not support DFPs. */ + +int foo(short x) { + /* { dg-final { scan-tree-dump "\\(_Decimal32\\)" "optimized" } } */ + return (_Decimal32) x != 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57438-1.c b/SingleSource/Regression/C/gcc-dg/pr57438-1.c new file mode 100644 index 0000000000..9bfd8b9d91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57438-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-O1" } */ +/* { dg-additional-options "-mdynamic-no-pic" { target powerpc*-*-darwin* } } + +/* This is testing that a completely empty function body results in the + insertion of a ud2/trap instruction to prevent a zero-sized FDE, and/or + the function label apparently pointing to following code. */ + +__attribute__((noinline)) +void foo (void) +{ + __builtin_unreachable(); +} + +/* { dg-final { scan-assembler "ud2" { target { i?86-*-darwin* x86_64-*-darwin* } } } } */ +/* { dg-final { scan-assembler "trap" { target { powerpc*-*-darwin* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr57518.c b/SingleSource/Regression/C/gcc-dg/pr57518.c new file mode 100644 index 0000000000..4c84f30bae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57518.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/57518 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-ira" } */ + +char ip[10]; +int total; + +void foo() { + int t; + + t = ip[2]; + total = t & 0x3; +} + +/* { dg-final { scan-rtl-dump-not "REG_EQUIV\[^\n\]*mem\[^\n\]*\"ip\".*subreg" "ira" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr57662.c b/SingleSource/Regression/C/gcc-dg/pr57662.c new file mode 100644 index 0000000000..253bf68914 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57662.c @@ -0,0 +1,47 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options " -O -fno-guess-branch-probability -fpeel-loops -freorder-blocks-and-partition -fschedule-insns2 -fsel-sched-pipelining -fselective-scheduling2 -ftree-pre" } */ + +struct intC +{ + short x; + short y; +}; + +void Get(void); + +int size_x; + +struct +{ + int *depot_table; + struct intC *ti; + int size; +} dummy; + +static inline int +GetRotatedTileFromOffset (int *a, struct intC tidc) +{ + if (!*a) + Get (); + switch (*a) + { + case 0: + return (tidc.y << size_x) + tidc.x; + case 1: + return tidc.y + (dummy.size - tidc.x) * size_x; + case 2: + return tidc.x + (dummy.size - tidc.y) * size_x; + case 3: + return (dummy.size - tidc.x); + } + return 0; +} + +int +GetHangarNum (int *a, int i) +{ + while (dummy.size) + if (GetRotatedTileFromOffset (a, dummy.ti[i])) + return *dummy.depot_table; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr57773.c b/SingleSource/Regression/C/gcc-dg/pr57773.c new file mode 100644 index 0000000000..1c309506d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57773.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Wpedantic" } */ + +enum e { A }; +struct { enum e b: 2; } s1; +struct { signed char b: 2; } s2; +struct { unsigned char b: 2; } s3; +struct { short b: 2; } s4; +struct { unsigned short b: 2; } s5; +struct { long int b: 2; } s6; +struct { unsigned long int b: 2; } s7; +struct { long long int b: 2; } s8; +struct { unsigned long long int b: 2; } s9; diff --git a/SingleSource/Regression/C/gcc-dg/pr57980.c b/SingleSource/Regression/C/gcc-dg/pr57980.c new file mode 100644 index 0000000000..be83536c5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr57980.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/57980 */ +/* { dg-do compile } */ +/* { dg-options "-O -foptimize-sibling-calls -w" } */ + +typedef int V __attribute__ ((vector_size (2 * sizeof (int)))); +extern V f (void); + +V +bar (void) +{ + return -f (); +} + +V +foo (void) +{ + V v = { }; + return v - f (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr58010.c b/SingleSource/Regression/C/gcc-dg/pr58010.c new file mode 100644 index 0000000000..a0fbd31f49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58010.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -ftree-vectorize" } */ + +short a, b, c, d; + +void f(void) +{ + short e; + + for(; e; e++) + for(; b; b++); + + for(d = 0; d < 4; d++) + a ^= (e ^= 1) || c ? : e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr58145-1.c b/SingleSource/Regression/C/gcc-dg/pr58145-1.c new file mode 100644 index 0000000000..6589f92402 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58145-1.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/58145 */ +/* { dg-do compile { target { int32plus } } } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +struct S { unsigned int data : 32; }; +struct T { unsigned int data; }; +volatile struct S s2; + +void +f1 (int val) +{ + struct S s = { .data = val }; + *(volatile struct S *) 0x880000UL = s; +} + +void +f2 (int val) +{ + struct T t = { .data = val }; + *(volatile struct T *) 0x880000UL = t; +} + +void +f3 (int val) +{ + *(volatile unsigned int *) 0x880000UL = val; +} + +void +f4 (int val) +{ + struct S s = { .data = val }; + s2 = s; +} + +/* { dg-final { scan-tree-dump-times " ={v} " 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr58145-2.c b/SingleSource/Regression/C/gcc-dg/pr58145-2.c new file mode 100644 index 0000000000..d26c05bc28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58145-2.c @@ -0,0 +1,50 @@ +/* PR tree-optimization/58145 */ +/* { dg-do compile { target { int32plus } } } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +struct S { unsigned int data : 32; }; +struct T { unsigned int data; }; +volatile struct S s2; + +static inline void +f1 (int val) +{ + struct S s = { .data = val }; + *(volatile struct S *) 0x880000UL = s; +} + +static inline void +f2 (int val) +{ + struct T t = { .data = val }; + *(volatile struct T *) 0x880000UL = t; +} + +static inline void +f3 (int val) +{ + *(volatile unsigned int *) 0x880000UL = val; +} + +static inline void +f4 (int val) +{ + struct S s = { .data = val }; + s2 = s; +} + +void +f5 (void) +{ + int i; + for (i = 0; i < 100; i++) + f1 (0); + for (i = 0; i < 100; i++) + f2 (0); + for (i = 0; i < 100; i++) + f3 (0); + for (i = 0; i < 100; i++) + f4 (0); +} + +/* { dg-final { scan-tree-dump-times " ={v} " 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr58346.c b/SingleSource/Regression/C/gcc-dg/pr58346.c new file mode 100644 index 0000000000..b7940f6cf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58346.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/58346 */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +struct U {}; +static struct U b[1] = { }; +extern void bar (struct U); + +void +foo (void) +{ + bar (b[0]); +} + +void +baz (void) +{ + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr58432.c b/SingleSource/Regression/C/gcc-dg/pr58432.c new file mode 100644 index 0000000000..22a720f142 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58432.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O3 -fprofile-generate" } */ + +struct { + int prefix; + int dir_idx; +} *a; +int b; +void fn1() { + int *c, *d; + for (; b; b++) + if (d[b]) { + c[b] = d[b]; + a[0].dir_idx = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr58463.c b/SingleSource/Regression/C/gcc-dg/pr58463.c new file mode 100644 index 0000000000..da9dec89fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58463.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-ealias-details -O2" } */ + +typedef struct +{ + int data16; +} +list_data; +void +fn1 (list_data * p1) +{ + p1->data16 = p1->data16 & 1 & p1->data16 >> 1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr58668.c b/SingleSource/Regression/C/gcc-dg/pr58668.c new file mode 100644 index 0000000000..3e09508dc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58668.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/58668 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mthumb" { target { { arm*-*-* } && arm_thumb2_ok } } } */ + +void *fn1 (void *); +void *fn2 (void *, const char *); +void fn3 (void *); +void fn4 (void *, int); + +void * +test (void *x) +{ + void *a, *b; + if (!(a = fn1 (x))) + return (void *) 0; + if (!(b = fn2 (a, "w"))) + { + fn3 (a); + return (void *) 0; + } + fn3 (a); + fn4 (b, 1); + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr58742-1.c b/SingleSource/Regression/C/gcc-dg/pr58742-1.c new file mode 100644 index 0000000000..54a0d3f917 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58742-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int * +fx (int *b, int *e) +{ + __SIZE_TYPE__ p = e - b; + /* The first forwprop pass should optimize this to return e; */ + return b + p; +} + +/* { dg-final { scan-tree-dump "return e" "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr58742-2.c b/SingleSource/Regression/C/gcc-dg/pr58742-2.c new file mode 100644 index 0000000000..f162893558 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58742-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +__SIZE_TYPE__ +fx (char *a, __SIZE_TYPE__ sz) +{ + char *b = a + sz; + /* The first forwprop pass should optimize this to return sz; */ + return b - a; +} + +/* { dg-final { scan-tree-dump "return sz" "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr58742-3.c b/SingleSource/Regression/C/gcc-dg/pr58742-3.c new file mode 100644 index 0000000000..3c4d14596c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58742-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int * +fx (int *a, int sz) +{ + int *b = a + sz; + b = b - sz; + /* forwprop together with FRE should optimize this to return a; */ + return b; +} + +/* { dg-final { scan-tree-dump "return a" "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr58805.c b/SingleSource/Regression/C/gcc-dg/pr58805.c new file mode 100644 index 0000000000..b46f776426 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58805.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +/* Type that matches the 'p' constraint. */ +#define TYPE void * + +static inline +void bar (TYPE *r) +{ + TYPE t; + __asm__ ("" : "=&p" (t), "=p" (*r)); +} + +void +foo (int n, TYPE *x, TYPE *y) +{ + if (n == 0) + bar (x); + else + bar (y); +} + +/* { dg-final { scan-tree-dump-times "__asm__" 2 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr58893-0.h b/SingleSource/Regression/C/gcc-dg/pr58893-0.h new file mode 100644 index 0000000000..957bcdc117 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58893-0.h @@ -0,0 +1 @@ +#pragma GCC visibility push(hidden) diff --git a/SingleSource/Regression/C/gcc-dg/pr58893.c b/SingleSource/Regression/C/gcc-dg/pr58893.c new file mode 100644 index 0000000000..c9f8b6b1e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58893.c @@ -0,0 +1,5 @@ +/* PR preprocessor/58893 */ +/* { dg-do compile } */ +/* { dg-options "-include pr58893-0.h -include pr58893-1.h -I${srcdir}/gcc.dg" } */ +/* { dg-error "pr58893-1.h: No such file or directory" "" { target *-*-* } 0 } */ +/* { dg-prune-output "compilation terminated" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr58981.c b/SingleSource/Regression/C/gcc-dg/pr58981.c new file mode 100644 index 0000000000..1c8293e498 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr58981.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-minline-all-stringops" { target { i?86-*-* x86_64-*-* } } } */ + +extern void abort (void); + +#define MAX_OFFSET (sizeof (long long)) +#define MAX_COPY (8 * sizeof (long long)) +#define MAX_EXTRA (sizeof (long long)) + +#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA) + +static union { + char buf[MAX_LENGTH]; + long long align_int; + long double align_fp; +} u; + +char A[MAX_LENGTH]; + +int +main () +{ + int off, len, i; + char *p, *q; + + for (i = 0; i < MAX_LENGTH; i++) + A[i] = 'A'; + + for (off = 0; off < MAX_OFFSET; off++) + for (len = 1; len < MAX_COPY; len++) + { + for (i = 0; i < MAX_LENGTH; i++) + u.buf[i] = 'a'; + + p = __builtin_memcpy (u.buf + off, A, len); + if (p != u.buf + off) + abort (); + + q = u.buf; + for (i = 0; i < off; i++, q++) + if (*q != 'a') + abort (); + + for (i = 0; i < len; i++, q++) + if (*q != 'A') + abort (); + + for (i = 0; i < MAX_EXTRA; i++, q++) + if (*q != 'a') + abort (); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59011.c b/SingleSource/Regression/C/gcc-dg/pr59011.c new file mode 100644 index 0000000000..b0d6c0f30a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59011.c @@ -0,0 +1,23 @@ +/* PR middle-end/59011 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-effective-target alloca } */ + +void +foo (int m) +{ + int a[m]; + void + bar (void) + { + { + int + baz (void) + { + return a[0]; + } + } + a[0] = 42; + } + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59020.c b/SingleSource/Regression/C/gcc-dg/pr59020.c new file mode 100644 index 0000000000..696c9df9ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59020.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/59020 */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fmodulo-sched -fno-inline -march=corei7" } */ + +int a, b, d; +unsigned c; + +void f() +{ + unsigned q; + for(; a; a++) + if(((c %= d && 1) ? : 1) & 1) + for(; b; q++); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59261.c b/SingleSource/Regression/C/gcc-dg/pr59261.c new file mode 100644 index 0000000000..6b912deb09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59261.c @@ -0,0 +1,17 @@ +/* PR middle-end/59261 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef signed char V __attribute__((vector_size (8))); + +void +foo (V *a, V *b) +{ + *a = *b * 3; +} + +void +bar (V *a, V *b) +{ + *a = *b * 4; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59304.c b/SingleSource/Regression/C/gcc-dg/pr59304.c new file mode 100644 index 0000000000..f56ebc374b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59304.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +enum EE + { + ONE, TWO, THREE + }; + +int f (enum EE e) +{ + int r = 0; + +#pragma GCC diagnostic push +#pragma GCC diagnostic error "-Wswitch-enum" + + switch (e) + { + case ONE: + r = 1; + break; + case TWO: + r = 2; + break; + case THREE: + r = 3; + break; + } + +#pragma GCC diagnostic pop + + switch (e) + { + case ONE: + r = 1; + break; + case TWO: + r = 2; + break; + } + + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59350-2.c b/SingleSource/Regression/C/gcc-dg/pr59350-2.c new file mode 100644 index 0000000000..2fea85fcf7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59350-2.c @@ -0,0 +1,29 @@ +/* PR debug/59350 */ + +/* { dg-do compile } */ +/* { dg-options "-O -g " } */ + +typedef struct +{ + void *v; + int len; + int sign; +} ZVALUE; + +extern int pred (ZVALUE); + +static unsigned long +small_factor (ZVALUE z) +{ + if (z.len > 0) + return 0; + + return pred (z) ? -1 : 0; +} + +unsigned long +zfactor (ZVALUE z) +{ + z.sign = 0; + return small_factor (z); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59350.c b/SingleSource/Regression/C/gcc-dg/pr59350.c new file mode 100644 index 0000000000..3d38486760 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59350.c @@ -0,0 +1,86 @@ +/* PR debug/59350 */ +/* Testcase by Ryan Mansfield */ + +/* { dg-do compile } */ +/* { dg-options "-O -g" } */ + +typedef union +{ + char b[2]; + short NotAnInteger; +} +mDNSOpaque16; +typedef mDNSOpaque16 mDNSIPPort; +typedef struct +{ +} +mDNSAddr; +typedef struct DNSQuestion_struct DNSQuestion; +typedef struct mDNS_struct mDNS; +typedef struct __attribute__ ((__packed__)) +{ + mDNSOpaque16 id; + mDNSOpaque16 flags; +} + +DNSMessageHeader; +typedef struct __attribute__ ((__packed__)) +{ + DNSMessageHeader h; +} + +DNSMessage; +struct DNSQuestion_struct +{ + DNSQuestion *next; + long LastQTime; + mDNSOpaque16 TargetQID; +}; +struct mDNS_struct +{ + long timenow; + DNSQuestion *Questions; +}; +extern long mDNSPlatformOneSecond; +typedef enum +{ + kDNSFlag0_QR_Mask = 0x80, kDNSFlag0_QR_Query = 0x00, kDNSFlag0_QR_Response = + 0x80, kDNSFlag0_OP_Mask = 0x78, kDNSFlag0_OP_StdQuery = + 0x00, kDNSFlag0_OP_Iquery = 0x08, kDNSFlag0_OP_Status = + 0x10, kDNSFlag0_OP_Unused3 = 0x18, kDNSFlag0_OP_Notify = + 0x20, kDNSFlag0_OP_Update = 0x28, kDNSFlag0_QROP_Mask = + kDNSFlag0_QR_Mask | kDNSFlag0_OP_Mask, kDNSFlag0_AA = 0x04, kDNSFlag0_TC = + 0x02, kDNSFlag0_RD = 0x01, kDNSFlag1_RA = 0x80, kDNSFlag1_Zero = + 0x40, kDNSFlag1_AD = 0x20, kDNSFlag1_CD = 0x10, kDNSFlag1_RC_Mask = + 0x0F, kDNSFlag1_RC_NoErr = 0x00, kDNSFlag1_RC_FormErr = + 0x01, kDNSFlag1_RC_ServFail = 0x02, kDNSFlag1_RC_NXDomain = + 0x03, kDNSFlag1_RC_NotImpl = 0x04, kDNSFlag1_RC_Refused = + 0x05, kDNSFlag1_RC_YXDomain = 0x06, kDNSFlag1_RC_YXRRSet = + 0x07, kDNSFlag1_RC_NXRRSet = 0x08, kDNSFlag1_RC_NotAuth = + 0x09, kDNSFlag1_RC_NotZone = 0x0A +} +TSIG_ErrorCode; +int uDNS_ReceiveTestQuestionResponse (mDNS * const, DNSMessage * const, + const char * const, + const mDNSAddr * const, + const mDNSIPPort); +void +uDNS_ReceiveMsg (mDNS * const m, DNSMessage * const msg, + const char * const end, const mDNSAddr * const srcaddr, + const mDNSIPPort srcport) +{ + DNSQuestion *qptr; + char StdR = kDNSFlag0_QR_Response | kDNSFlag0_OP_StdQuery; + char QR_OP = (char) (msg->h.flags.b[0] & kDNSFlag0_QROP_Mask); + if (QR_OP == StdR) + { + if (uDNS_ReceiveTestQuestionResponse (m, msg, end, srcaddr, srcport)) + return; + for (qptr = m->Questions; qptr; qptr = qptr->next) + if (msg->h.flags.b[0] & kDNSFlag0_TC + && ((qptr->TargetQID).NotAnInteger == (msg->h.id).NotAnInteger) + && m->timenow - qptr->LastQTime < (60 * mDNSPlatformOneSecond)) + { + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59351.c b/SingleSource/Regression/C/gcc-dg/pr59351.c new file mode 100644 index 0000000000..384058f404 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59351.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Wpedantic" } */ + +unsigned int +foo (void) +{ + return sizeof ((int[]) {}); /* { dg-warning "ISO C forbids empty initializer braces" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59418.c b/SingleSource/Regression/C/gcc-dg/pr59418.c new file mode 100644 index 0000000000..4b54ef2b42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59418.c @@ -0,0 +1,36 @@ +/* PR debug/59418 */ +/* Reported by Ryan Mansfield */ + +/* { dg-do compile } */ +/* { dg-options "-Os -g" } */ +/* { dg-options "-march=armv7-a+fp -mfloat-abi=hard -Os -g" { target { arm*-*-* && { ! arm_thumb1 } } } } */ + +extern int printf (const char *__format, ...); +double bar (const char *, int); + +void +foo (const char *pptr, int caplen) +{ + int type; + const char *tptr; + if (caplen < 4) + { + (void) printf ("foo"); + return; + } + while (tptr < pptr) + { + switch (type) + { + case 0x01: + printf (""); + case 0x0b: + printf (""); + case 0x0e: + printf (""); + case 0x10: + printf ("%1.2fW", bar (tptr, caplen) / 1000.0); + } + } + printf ("foo"); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59471.c b/SingleSource/Regression/C/gcc-dg/pr59471.c new file mode 100644 index 0000000000..bb27fbe339 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59471.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ + +typedef unsigned char uint8x4_t +__attribute__ ((__vector_size__ (4))); + +typedef unsigned short uint16x8_t +__attribute__ ((__vector_size__ (16))); + +typedef unsigned int uint32x4_t +__attribute__ ((__vector_size__ (16))); + +void +foo (uint16x8_t *x, uint8x4_t *y) +{ + *y = (uint8x4_t) ((uint32x4_t) (*x))[0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59523.c b/SingleSource/Regression/C/gcc-dg/pr59523.c new file mode 100644 index 0000000000..49cbe5dd27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59523.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/59523 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target alloca } */ + +int * +foo (int a, int *b, int *c, int *d) +{ + int i, *r = __builtin_alloca (a * sizeof (int)); + __builtin_memcpy (r, d, a * sizeof (int)); + for (i = 0; i < 64; i++) + c[i] += b[i]; + for (i = 0; i < a; i++) + if (r[i] == 0) + r[i] = 1; + return r; +} + +/* { dg-prune-output "-Wreturn-local-addr" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr59605-2.c b/SingleSource/Regression/C/gcc-dg/pr59605-2.c new file mode 100644 index 0000000000..95754815d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59605-2.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-DMAX_COPY=1025" { target { { simulator } || { nvptx-*-* amdgcn*-*-* } } } } */ +/* { dg-additional-options "-minline-stringops-dynamically" { target { i?86-*-* x86_64-*-* } } } */ + +#include "pr59605.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr59605.c b/SingleSource/Regression/C/gcc-dg/pr59605.c new file mode 100644 index 0000000000..5f87c99b01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59605.c @@ -0,0 +1,57 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-minline-stringops-dynamically" { target { i?86-*-* x86_64-*-* } } } */ + +extern void abort (void); + +#define MAX_OFFSET (sizeof (long long)) +#ifndef MAX_COPY +#define MAX_COPY (1024 + 8192) +#endif +#define MAX_EXTRA (sizeof (long long)) + +#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA) + +static union { + char buf[MAX_LENGTH]; + long long align_int; + long double align_fp; +} u; + +char A[MAX_LENGTH]; + +int +main () +{ + int off, len, i; + char *p, *q; + + for (i = 0; i < MAX_LENGTH; i++) + A[i] = 'A'; + + for (off = 0; off < MAX_OFFSET; off++) + for (len = 1; len < MAX_COPY; len++) + { + for (i = 0; i < MAX_LENGTH; i++) + u.buf[i] = 'a'; + + p = __builtin_memcpy (u.buf + off, A, len); + if (p != u.buf + off) + abort (); + + q = u.buf; + for (i = 0; i < off; i++, q++) + if (*q != 'a') + abort (); + + for (i = 0; i < len; i++, q++) + if (*q != 'A') + abort (); + + for (i = 0; i < MAX_EXTRA; i++, q++) + if (*q != 'a') + abort (); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59630.c b/SingleSource/Regression/C/gcc-dg/pr59630.c new file mode 100644 index 0000000000..6a3c72552f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59630.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +_Bool foo() +{ + _Bool (*f)(int) = __builtin_abs; /* { dg-warning "" } */ + return f(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59643.c b/SingleSource/Regression/C/gcc-dg/pr59643.c new file mode 100644 index 0000000000..de78d604bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59643.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/59643 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-pcom-details" } */ + +void +foo (double *a, double *b, double *c, double d, double e, int n) +{ + int i; + for (i = 1; i < n - 1; i++) + a[i] = d * (b[i] + c[i] + a[i - 1] + a[i + 1]) + e * a[i]; +} + +/* { dg-final { scan-tree-dump-times "Before commoning:" 1 "pcom" } } */ +/* { dg-final { scan-tree-dump-times "Unrolling 2 times" 1 "pcom" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr59670.c b/SingleSource/Regression/C/gcc-dg/pr59670.c new file mode 100644 index 0000000000..a68253b4b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59670.c @@ -0,0 +1,15 @@ +/* PR middle-end/59670 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fopenmp-simd" } */ + +int d[1024]; + +int +foo (int j, int b) +{ + int l, c = 0; +#pragma omp simd reduction(+: c) + for (l = 0; l < b; ++l) + c += d[j + l]; + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59717.c b/SingleSource/Regression/C/gcc-dg/pr59717.c new file mode 100644 index 0000000000..64e4f32197 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59717.c @@ -0,0 +1,277 @@ +/* PR c/59717 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -Wno-implicit-function-declaration" } */ + +void +math (double d, int *ex, double *dp) +{ + acos (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + acosh (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + asin (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + asinh (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + atan (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + atanh (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + atan2 (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + cbrt (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + ceil (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + copysign (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + cos (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + cosh (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + erf (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + erfc (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + exp (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + exp2 (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + expm1 (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + fabs (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + fdim (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + floor (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + fma (d, d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + fmax (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + fmin (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + fmod (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + frexp (d, ex); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + hypot (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + /* We don't generate the warning for ilogb. */ + ilogb (d); + ldexp (d, *ex); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + lgamma (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + llrint (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + llround (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + log (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + log10 (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + log1p (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + log2 (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + logb (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + lrint (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + lround (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + modf (d, dp); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + nan (""); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + nearbyint (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + nextafter (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + nexttoward (d, 20.0L); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + pow (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + remainder (d, d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + remquo (d, d, ex); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + rint (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + round (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + scalbln (d, 100L); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + scalbn (d, 100); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + sin (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + sinh (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + sincos (d, dp, dp); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + sqrt (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + tan (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + tanh (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + tgamma (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ + trunc (d); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..math.h.." "" { target *-*-* } .-1 } */ +} + +void +cmplx (double _Complex z) +{ + cabs (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + cacos (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + cacosh (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + carg (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + casin (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + casinh (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + catan (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + catanh (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + ccos (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + ccosh (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + cexp (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + cimag (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + clog (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + conj (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + cpow (z, z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + cproj (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + creal (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + csin (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + csinh (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + csqrt (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + ctan (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ + ctanh (z); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..complex.h.." "" { target *-*-* } .-1 } */ +} + +void +string (void *p, void *q, __SIZE_TYPE__ sz) +{ + memchr (p, 2, sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + /* We don't generate the warning for memcmp. */ + memcmp (p, q, sz); + memcpy (p, q, sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + memmove (p, q, sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + memset (p, 0, sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strcat (p, q); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strchr (p, 'a'); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + /* We don't generate the warning for strcmp. */ + strcmp (p, q); + strcpy (p, q); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strcspn (p, q); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strlen (p); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strncat (p, q, sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + /* We don't generate the warning for strncmp. */ + strncmp (p, q, sz); + strncpy (p, q, sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strpbrk (p, q); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strrchr (p, 'q'); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strspn (p, q); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ + strstr (p, q); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..string.h.." "" { target *-*-* } .-1 } */ +} + +/* Fake FILE. */ +typedef struct { int i; } FILE; + +void +stdio (FILE *fp, void *p, __SIZE_TYPE__ sz) +{ + fprintf (fp, ""); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdio.h.." "" { target *-*-* } .-1 } */ + fscanf (fp, ""); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdio.h.." "" { target *-*-* } .-1 } */ + fwrite (p, sz, sz, fp); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdio.h.." "" { target *-*-* } .-1 } */ + printf (""); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdio.h.." "" { target *-*-* } .-1 } */ + scanf (""); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdio.h.." "" { target *-*-* } .-1 } */ + snprintf ("", sz, ""); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdio.h.." "" { target *-*-* } .-1 } */ + sprintf ("", ""); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdio.h.." "" { target *-*-* } .-1 } */ + sscanf ("", ""); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdio.h.." "" { target *-*-* } .-1 } */ +} + +void +stdlib (void *p, void *q, __SIZE_TYPE__ sz) +{ + abort (); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ + void *p1 = calloc (sz, 1); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ + exit (1); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ + free (p); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ + labs (1L); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ + llabs (1LL); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ + void *p2 = malloc (sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ + void *p3 = realloc (p, sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ + void *p4 = aligned_alloc (sz, sz); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..stdlib.h.." "" { target *-*-* } .-1 } */ +} + +void +inttypes (__INTMAX_TYPE__ j) +{ + imaxabs (j); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..inttypes.h.." "" { target *-*-* } .-1 } */ +} + +struct tm; + +void +timeh (char *s, __SIZE_TYPE__ sz, struct tm *tm) +{ + strftime (s, sz, "", tm); /* { dg-warning "incompatible implicit" } */ + /* { dg-message "include ..time.h.." "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59722.c b/SingleSource/Regression/C/gcc-dg/pr59722.c new file mode 100644 index 0000000000..7626fd22e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59722.c @@ -0,0 +1,36 @@ +/* PR ipa/59722 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +extern void abrt (const char *, int) __attribute__((noreturn)); +void baz (int *, int *); + +static inline int +bar (void) +{ + return 1; +} + +static inline void +foo (int *x, int y (void)) +{ + while (1) + { + int a = 0; + if (*x) + { + baz (x, &a); + while (a && !y ()) + ; + break; + } + abrt ("", 1); + } +} + +void +test (int x) +{ + foo (&x, bar); + foo (&x, bar); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59827.c b/SingleSource/Regression/C/gcc-dg/pr59827.c new file mode 100644 index 0000000000..77e1e9ca20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59827.c @@ -0,0 +1,15 @@ +/* PR middle-end/59827 */ +/* { dg-do compile } */ + +int +foo (int p[2][]) /* { dg-error "array type has incomplete element type" } */ +{ + return p[0][0]; +} + +void +bar (void) +{ + int p[2][1]; + foo (p); /* { dg-error "type of formal parameter 1 is incomplete" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59833.c b/SingleSource/Regression/C/gcc-dg/pr59833.c new file mode 100644 index 0000000000..c75efdef31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59833.c @@ -0,0 +1,19 @@ +/* { dg-do run { target { *-*-linux* *-*-gnu* } } } */ +/* { dg-options "-O0 -lm -fsignaling-nans" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target issignaling } */ + +#define _GNU_SOURCE +#include + +int main (void) +{ + float sNaN = __builtin_nansf (""); + double x = (double) sNaN; + if (issignaling(x)) + { + __builtin_abort(); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59846.c b/SingleSource/Regression/C/gcc-dg/pr59846.c new file mode 100644 index 0000000000..9b01b22631 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59846.c @@ -0,0 +1,39 @@ +/* PR c/59846 */ +/* { dg-do compile } */ +/* { dg-options "-Wlogical-op -Wtype-limits" } */ + +_Bool +fn1 (unsigned int p) +{ + return 0ULL > p; /* { dg-warning "15:comparison is always false due to limited range of data type" } */ +} + +_Bool +fn2 (unsigned int p) +{ + return 0ULL <= p; /* { dg-warning "15:comparison is always true due to limited range of data type" } */ +} + +_Bool +fn3 (unsigned int p) +{ + return p >= 0U; /* { dg-warning "12:comparison of unsigned expression in '>= 0' is always true" } */ +} + +_Bool +fn4 (unsigned int p) +{ + return p < 0U; /* { dg-warning "12:comparison of unsigned expression in '< 0' is always false" } */ +} + +_Bool +fn5 (_Bool p) +{ + return p || !p; /* { dg-warning "12:logical" } */ +} + +_Bool +fn6 (_Bool p) +{ + return p && !p; /* { dg-warning "12:logical" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59860.c b/SingleSource/Regression/C/gcc-dg/pr59860.c new file mode 100644 index 0000000000..6807d9c843 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59860.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char * __attribute__ ((__nothrow__ , __leaf__)) +strcat (char *__restrict __dest, const char *__restrict __src) +{ + return __builtin___strcat_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); +} +static char raw_decode; +void foo (char **argv, char *outfilename) +{ + if (**argv == 'r') + raw_decode = 1; + strcat (outfilename, raw_decode ? ".raw" : ".wav"); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59871.c b/SingleSource/Regression/C/gcc-dg/pr59871.c new file mode 100644 index 0000000000..c881aa198d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59871.c @@ -0,0 +1,22 @@ +/* PR c/59871 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +extern int bar (); + +void +foo (int *p, int i) +{ + p[0] = (bar (), 1, bar ()); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + p[1] = (1, bar ()); /* { dg-warning "left-hand operand of comma expression has no effect" } */ + bar (), 1, bar (); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + bar (), 1; /* { dg-warning "right-hand operand of comma expression has no effect" } */ + 1, bar (); /* { dg-warning "left-hand operand of comma expression has no effect" } */ + (bar (), 1); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + bar (), 5 * i; /* { dg-warning "right-hand operand of comma expression has no effect" } */ + (bar (), 5 * i); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), 7))))))); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), 7)))))); /* { dg-warning "right-hand operand of comma expression has no effect" } */ + bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (7, bar ())))))); /* { dg-warning "left-hand operand of comma expression has no effect" } */ + (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (7, bar ()))))))); /* { dg-warning "left-hand operand of comma expression has no effect" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59920-1.c b/SingleSource/Regression/C/gcc-dg/pr59920-1.c new file mode 100644 index 0000000000..a2f0727670 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59920-1.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/59920 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include + +int bar (void); +void baz (int); + +#define A { int x = bar (); if (setjmp (buf) == 0) baz (x); } +#define B A A A A A A A A A A +#define C B B B B B B B B B B + +extern jmp_buf buf; + +void +foo (void) +{ + C C +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59920-2.c b/SingleSource/Regression/C/gcc-dg/pr59920-2.c new file mode 100644 index 0000000000..f22691324b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59920-2.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/59920 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +/* { dg-require-effective-target label_values } */ +/* { dg-require-effective-target indirect_jumps } */ + +void *bar (void **); +void *baz (int, void **); + +#define A(n) \ + { __label__ l1_##n, l2_##n, l3_##n; \ + static void *a[] = { &&l1_##n, &&l2_##n, &&l3_##n };\ + void *b = bar (a); \ + goto *b; \ + l1_##n: \ + b = baz (1, a); \ + goto *b; \ + l2_##n: \ + b = baz (2, a); \ + goto *b; \ + l3_##n:; \ + } +#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) \ + A(n##5) A(n##6) A(n##7) A(n##8) A(n##9) +#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) \ + B(n##5) B(n##6) B(n##7) B(n##8) B(n##9) + +void +foo (void) +{ + C(1) +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59920-3.c b/SingleSource/Regression/C/gcc-dg/pr59920-3.c new file mode 100644 index 0000000000..e1749c72b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59920-3.c @@ -0,0 +1,48 @@ +/* PR tree-optimization/59920 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ +/* { dg-require-effective-target nonlocal_goto } */ + +void *bar (void **); +void *baz (int, void **); + +#define A(n) __label__ l##n; +#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) \ + A(n##5) A(n##6) A(n##7) A(n##8) A(n##9) +#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) \ + B(n##5) B(n##6) B(n##7) B(n##8) B(n##9) +#define D C(1) + +int +foo (void) +{ + D + int bar (int i) + { + switch (i) + { +#undef A +#define A(n) \ + case n: goto l##n; + D + } + return i; + } + int w = 0; +#undef A +#define A(n) int w##n = 0; + D +#undef A +#define A(n) \ + { l##n:; \ + w##n += bar (10000 + n) - 10000; \ + w##n += bar (10001 + n) - 10000; \ + bar (n + 1); \ + return w##n; \ + } + D +#undef A +#define A(n) w += w##n; + D + return w; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59924.c b/SingleSource/Regression/C/gcc-dg/pr59924.c new file mode 100644 index 0000000000..9063a23943 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59924.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/59924 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -Wall" } */ + +struct S { struct T *a; double b; struct S *c; }; +struct T { struct S *d; }; +extern void bar (double); + +void +foo (struct S * x, int y, int z, int w) +{ + int e; + struct S *f; + for (f = x->a->d; f; f = f->c) + { + if (5 < w) + { + e = -w; + z = w; + } + } + if (y != 0 || z != 0) + { + double g = x->b + (double) e * (double) y; /* { dg-warning "may be used uninitialized" } */ + bar (g * g); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59940.c b/SingleSource/Regression/C/gcc-dg/pr59940.c new file mode 100644 index 0000000000..cec8d07edd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59940.c @@ -0,0 +1,28 @@ +/* PR c/59940 */ +/* { dg-do compile } */ +/* { dg-options "-Wconversion -Woverflow" } */ + +int f (unsigned int); +typedef int sitype __attribute__((mode(SI))); + +int +g (void) +{ + sitype si = 12; + unsigned int ui = -1; /* { dg-warning "21:-Wsign-conversion" } */ + unsigned char uc; + ui = si; /* { dg-warning "8:conversion" } */ + si = 0x80000000; /* { dg-warning "8:-Wsign-conversion" } */ + si = 3.2f; /* { dg-warning "8:conversion" } */ + uc = 256; /* { dg-warning "8:-Woverflow" } */ + si = 0x800000000; /* { dg-warning "8:-Woverflow" } */ + return f (si) /* { dg-warning "13:conversion" } */ + + f (si); /* { dg-warning "15:conversion" } */ +} + +int +y (void) +{ + f (); /* { dg-error "3:too few arguments to function" } */ + g (0xa); /* { dg-error "3:too many arguments to function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59963-1.c b/SingleSource/Regression/C/gcc-dg/pr59963-1.c new file mode 100644 index 0000000000..dbb347f990 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59963-1.c @@ -0,0 +1,14 @@ +/* PR c/59963 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -Wdouble-promotion" } */ + +extern void baz (); +extern void qux (int, ...); + +void +foo (float f) +{ + bar (f); /* { dg-warning "8:implicit conversion" } */ + baz (f); /* { dg-warning "8:implicit conversion" } */ + qux (42, f); /* { dg-warning "12:implicit conversion" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59963-2.c b/SingleSource/Regression/C/gcc-dg/pr59963-2.c new file mode 100644 index 0000000000..9344566fc8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59963-2.c @@ -0,0 +1,37 @@ +/* PR c/59963 */ +/* { dg-do compile } */ +/* { dg-options "-Woverflow -Wconversion" } */ + +extern void bar (unsigned char); +extern void bar8 (unsigned char, unsigned char, unsigned char, unsigned char, + unsigned char, unsigned char, unsigned char, unsigned char); +extern void bazu (unsigned int, ...); +extern void bazi (char, int); +extern int f (short a, short b); + +int +g (void) +{ + return f (0xffffffffL, /* { dg-warning "13:-Woverflow" } */ + 0xffffffffL) /* { dg-warning "13:-Woverflow" } */ + && f (0xffffffffL, /* { dg-warning "16:-Woverflow" } */ + 0xffffffffL); /* { dg-warning "16:-Woverflow" } */ +} + +void +foo (int i) +{ + bar (256); /* { dg-warning "8:-Woverflow" } */ + bar (6.66f); /* { dg-warning "8:conversion" } */ + bar8 (-1, /* { dg-warning "9:-Wsign-conversion" } */ + -2, /* { dg-warning "10:-Wsign-conversion" } */ + -3, /* { dg-warning "11:-Wsign-conversion" } */ + -4, /* { dg-warning "12:-Wsign-conversion" } */ + -5, /* { dg-warning "13:-Wsign-conversion" } */ + -6, /* { dg-warning "14:-Wsign-conversion" } */ + -7, /* { dg-warning "15:-Wsign-conversion" } */ + -8); /* { dg-warning "16:-Wsign-conversion" } */ + bazu (i, i); /* { dg-warning "9:conversion" } */ + bazi (0x8, 0x80000000); /* { dg-warning "14:-Wsign-conversion" "first" { target { ! int16 } } } */ + /* { dg-warning "overflow in conversion from" "second" { target int16 } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59963-3.c b/SingleSource/Regression/C/gcc-dg/pr59963-3.c new file mode 100644 index 0000000000..eafa37473f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59963-3.c @@ -0,0 +1,14 @@ +/* PR c/59963 */ +/* { dg-do compile } */ +/* { dg-options "-Wconversion" } */ + +extern void foo (void *p); + +void +bar (void) +{ + { + /* This must not ICE. */ + int i __attribute__((cleanup (foo))); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr59992.c b/SingleSource/Regression/C/gcc-dg/pr59992.c new file mode 100644 index 0000000000..5434a2fe93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr59992.c @@ -0,0 +1,17 @@ +/* PR debug/59992 */ +/* { dg-do compile } */ +/* { dg-require-effective-target run_expensive_tests } */ +/* { dg-options "-O2 -g" } */ +/* { dg-timeout-factor 16.0 } */ + +#define A(n) if (p[n]) { extern void foo##n (int, int, double, int, int); foo##n (p[n], 5, 8.0, p[n] + p[n + 1], 9); return; } +#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) A(n##8) A(n##9) +#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) B(n##8) B(n##9) +#define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7) C(n##8) C(n##9) +#define E(n) D(n##0) D(n##1) D(n##2) D(n##3) D(n##4) D(n##5) D(n##6) D(n##7) D(n##8) D(n##9) + +void +foo (int *p) +{ + E(1) +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60013.c b/SingleSource/Regression/C/gcc-dg/pr60013.c new file mode 100644 index 0000000000..5c2ec517d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60013.c @@ -0,0 +1,47 @@ +/* PR ipa/60013 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef long int jmp_buf[64]; +extern int _setjmp (jmp_buf) __attribute__ ((__nothrow__)); +struct S { int a, b, c; }; +extern struct S *baz (struct S *); +static jmp_buf j; + +static inline int +bar (int b, int d) +{ + return (b & d) < 0; +} + +struct S * +foo (int a, struct S *b, struct S *c, struct S *d) +{ + if (b->a == 0) + { + switch (a) + { + case 8: + return baz (b); + case 7: + bar (b->c, c->b); + return 0; + case 6: + case 5: + case 4: + return baz (c); + case 3: + case 2: + return baz (d); + } + return 0; + } + if (b->a == 1) + { + if (baz (c)) + return c; + else if (_setjmp (j)) + baz (b); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60036.c b/SingleSource/Regression/C/gcc-dg/pr60036.c new file mode 100644 index 0000000000..07eb6ace98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60036.c @@ -0,0 +1,28 @@ +/* PR c/60036 */ +/* { dg-do compile } */ +/* { dg-options "-Wconversion" } */ + +extern int fn (void); + +void +foo (int i) +{ + unsigned int f = 9; + + /* Don't warn on these. */ + f += fn () || i; + f += fn () && i; + f += ! fn (); + f -= fn () == i; + f |= fn () != i; + f &= fn () < i; + f ^= fn () > i; + f &= fn () <= i; + f ^= fn () >= i; + + /* But warn on the following. */ + f += fn (); /* { dg-warning "conversion" } */ + f += fn () | i; /* { dg-warning "conversion" } */ + f += fn () & i; /* { dg-warning "conversion" } */ + f += fn () ^ i; /* { dg-warning "conversion" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60087.c b/SingleSource/Regression/C/gcc-dg/pr60087.c new file mode 100644 index 0000000000..b3bd811cae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60087.c @@ -0,0 +1,14 @@ +/* PR c/60087 */ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +void +foo (unsigned int ui, int i) +{ + const unsigned char uc = 0; + _Bool b; + b = 0 != ~uc; /* { dg-warning "9:promoted bitwise complement of an unsigned value is always nonzero" } */ + b = 2 != ~uc; /* { dg-warning "9:comparison of promoted bitwise complement of an unsigned value with constant" } */ + b = uc == ~uc; /* { dg-warning "10:comparison of promoted bitwise complement of an unsigned value with unsigned" } */ + b = i == ui; /* { dg-warning "9:comparison of integer expressions of different signedness" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60114.c b/SingleSource/Regression/C/gcc-dg/pr60114.c new file mode 100644 index 0000000000..47845c1691 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60114.c @@ -0,0 +1,32 @@ +/* PR c/60114 */ +/* { dg-do compile } */ +/* { dg-options "-Wconversion" } */ +/* { dg-require-effective-target int32plus } */ + +struct S { int n, u[2]; }; +const signed char z[] = { + [0] = 0x100, /* { dg-warning "-Woverflow" } */ + [2] = 0x101, /* { dg-warning "-Woverflow" } */ +}; +int A[] = { + 0, 0x80000000, /* { dg-warning "16:-Wsign-conversion" } */ + 0xA, 0x80000000, /* { dg-warning "18:-Wsign-conversion" } */ + 0xA, 0xA, 0x80000000 /* { dg-warning "23:-Wsign-conversion" } */ + }; +int *p = (int []) { 0x80000000 }; /* { dg-warning "21:-Wsign-conversion" } */ +union { int k; } u = { .k = 0x80000000 }; /* { dg-warning "29:-Wsign-conversion" } */ +typedef int H[]; +void +foo (void) +{ + signed char a[][3] = { { 0x100, /* { dg-warning "28:-Woverflow" } */ + 1, 0x100 }, /* { dg-warning "24:-Woverflow" } */ + { '\0', 0x100, '\0' } /* { dg-warning "27:-Woverflow" } */ + }; + (const signed char []) { 0x100 }; /* { dg-warning "28:-Woverflow" } */ + (const float []) { 1e0, 1e1, 1e100 }; /* { dg-warning "32:conversion" } */ + struct S s1 = { 0x80000000 }; /* { dg-warning "19:-Wsign-conversion" } */ + struct S s2 = { .n = 0x80000000 }; /* { dg-warning "24:-Wsign-conversion" } */ + struct S s3 = { .u[1] = 0x80000000 }; /* { dg-warning "27:-Wsign-conversion" } */ + H h = { 1, 2, 0x80000000 }; /* { dg-warning "17:-Wsign-conversion" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60139.c b/SingleSource/Regression/C/gcc-dg/pr60139.c new file mode 100644 index 0000000000..96e42ed9c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60139.c @@ -0,0 +1,14 @@ +/* PR c/60139 */ +/* { dg-do compile } */ +/* { dg-options "-Wpedantic -std=gnu89" } */ +/* { dg-prune-output ".*near initialization for.*" } */ + +double sin (double); +void +fn (int *p) +{ + int **a[] = { &p, /* { dg-warning "17:initializer element is not computable at load time" } */ + (void *) 0, &p }; /* { dg-warning "28:initializer element is not computable at load time" } */ + double d[] = { sin (1.0), /* { dg-warning "18:initializer element is not a constant expression" } */ + 8.8, sin (1.0), 2.6 }; /* { dg-warning "23:initializer element is not a constant expression" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60195.c b/SingleSource/Regression/C/gcc-dg/pr60195.c new file mode 100644 index 0000000000..0a50a30be2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60195.c @@ -0,0 +1,56 @@ +/* PR c/60195 */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wpedantic -Wall" } */ + +typedef _Atomic int atomic_int; + +atomic_int +fn1 (void) +{ + atomic_int y = 0; + return y; +} + +atomic_int +fn2 (void) +{ + atomic_int y = 0; + y; + return y; +} + +atomic_int +fn3 (void) +{ + atomic_int y = 0; + y++; + return y; +} + +void +fn4 (void) +{ + atomic_int y; + y = 0; + (void) y; +} + +void +fn5 (void) +{ + atomic_int y = 0; /* { dg-warning "unused variable" } */ +} + +void +fn6 (void) +{ + atomic_int y; /* { dg-warning "set but not used" } */ + y = 0; +} + +void +fn7 (void) +{ + atomic_int y = 0; + y++; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60257.c b/SingleSource/Regression/C/gcc-dg/pr60257.c new file mode 100644 index 0000000000..46c29b0543 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60257.c @@ -0,0 +1,37 @@ +/* PR c/60257 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat -Woverride-init" } */ +/* { dg-prune-output ".*near initialization for.*" } */ + +enum E1 { A }; +enum E2 { B }; + +struct S +{ + enum E1 e: 3; +}; + +struct S s[] = +{ + { B } /* { dg-warning "5:enum conversion in initialization is invalid in C\[+\]\[+\]" } */ +}; + +union U { + int i; + long long int l; +}; + +struct R { + int a; +}; + +void +foo (int i) +{ + union U u = { .i = ++i, .l = 1 }; /* { dg-warning "32:initialized field with side-effects overwritten" } */ + union U u2 = { .i = 1, .l = 3 }; /* { dg-warning "31:initialized field overwritten" } */ + int a[] = { i++, [0] = 1 }; /* { dg-warning "26:initialized field with side-effects overwritten" } */ + int a2[] = { i, [0] = 1 }; /* { dg-warning "25:initialized field overwritten" } */ + struct R r = { 1, .a = 2 }; /* { dg-warning "26:initialized field overwritten" } */ + struct R r2 = { ++i, .a = 2 }; /* { dg-warning "29:initialized field with side-effects overwritten" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60267.c b/SingleSource/Regression/C/gcc-dg/pr60267.c new file mode 100644 index 0000000000..c95def2399 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60267.c @@ -0,0 +1,13 @@ +/* PR c++/60267 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -save-temps" } */ + +void +foo (int *a, int *b, int *c) +{ + int i; +#pragma GCC ivdep + for (i = 0; i < 64; i++) + a[i] = b[i] * c[i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr60351.c b/SingleSource/Regression/C/gcc-dg/pr60351.c new file mode 100644 index 0000000000..29184d9487 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60351.c @@ -0,0 +1,11 @@ +/* PR c/60351 */ +/* { dg-do compile } */ + +void +f (int i) +{ + i >> -1; /* { dg-warning "5:right shift count is negative" } */ + i >> 250; /* { dg-warning "5:right shift count >= width of type" } */ + i << -1; /* { dg-warning "5:left shift count is negative" } */ + i << 250; /* { dg-warning "5:left shift count >= width of type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60485-1.c b/SingleSource/Regression/C/gcc-dg/pr60485-1.c new file mode 100644 index 0000000000..2e5c2e5bf3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60485-1.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +struct S { + int *i[4]; + int *p1; + int *p2; + int *p3; + int *p4; +}; +int **b; +int main() +{ + int i = 1; + struct S s; + s.p3 = &i; + int **p; + if (b) + p = b; + else + p = &s.i[2]; + p += 4; + if (!b) + **p = 0; + if (i != 0) + abort (); + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60485-2.c b/SingleSource/Regression/C/gcc-dg/pr60485-2.c new file mode 100644 index 0000000000..767e61d1c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60485-2.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); +struct S { + int *i[4]; + int *p1; + int *p2; + int *p3; + int *p4; + int **x; +}; +int **b; +int main() +{ + int i = 1; + struct S s; + s.p3 = &i; + int **p; + if (b) + p = b; + else + p = &s.i[2]; + p += 4; + /* prevert fowrprop from creating an offsetted sd constraint and + preserve the pointer offsetting constraint. */ + s.x = p; + p = s.x; + if (!b) + { + int *z = *p; + /* z should point to i (and non-local/escaped). */ + *z = 0; + } + if (i != 0) + abort (); + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60598.c b/SingleSource/Regression/C/gcc-dg/pr60598.c new file mode 100644 index 0000000000..331e8bde26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60598.c @@ -0,0 +1,26 @@ +/* PR target/60598 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ +/* { dg-additional-options "-march=z196 -mtune=zEC12" { target s390*-*-* } } */ + +struct S { unsigned a, b[32]; }; + +void +foo (struct S *x, struct S *y) +{ + unsigned a = y->a, i; + if (x == y) + for (i = 0; i < a - 1 - i; i++) + { + unsigned t = x->b[i]; + x->b[i] = x->b[a - 1 - i]; + x->b[a - 1 - i] = t; + } + else + { + x->a = a; + for (i = 0; i < a; i++) + x->b[i] = y->b[a - 1 - i]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60647-1.c b/SingleSource/Regression/C/gcc-dg/pr60647-1.c new file mode 100644 index 0000000000..99f5919c34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60647-1.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct _wincore +{ + int y; + int width; +}; +int a; +void fn2 (void); +static int fn1 (dpy, winInfo) struct _XDisplay *dpy; +struct _wincore *winInfo; +{ + a = winInfo->width; + fn2 (); +} + +void fn4 (int, int, int); +static int fn3 (dpy, winInfo, visrgn) struct _XDisplay *dpy; +int winInfo, visrgn; +{ + int b = fn1 (0, winInfo); + fn4 (0, 0, visrgn); +} + +int +fn5 (event) struct _XEvent *event; +{ + fn3 (0, 0, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60647-2.c b/SingleSource/Regression/C/gcc-dg/pr60647-2.c new file mode 100644 index 0000000000..60655bf54e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60647-2.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct _wincore +{ + int width, height; +}; + +void fn1 (int); +void fn2 (int, int, int *); + +static void +foo (void *dpy, struct _wincore *winInfo, int offset) +{ + fn1 (winInfo->height); +} + +static void +bar (void *dpy, int winInfo, int *visrgn) +{ + ((void (*) (void *, int, int)) foo) ((void *) 0, winInfo, 0); /* { dg-warning "function called through a non-compatible type" } */ + fn2 (0, 0, visrgn); +} + +void +baz (void *dpy, int win, int prop) +{ + bar ((void *) 0, 0, (int *) 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60704.c b/SingleSource/Regression/C/gcc-dg/pr60704.c new file mode 100644 index 0000000000..8a9af39fff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60704.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-flive-range-shrinkage" } */ +/* { dg-additional-options "-march=amdfam10" { target { i?86-*-* x86_64-*-* } } } */ + +struct S +{ + int n; +}; + +int +foo (struct S s, double a) +{ + return s.n * a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60784.c b/SingleSource/Regression/C/gcc-dg/pr60784.c new file mode 100644 index 0000000000..82b512f7c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60784.c @@ -0,0 +1,25 @@ +/* PR c/60784 */ +/* { dg-do compile } */ +/* { dg-options "-Wextra -std=c99" } */ + +struct A { int i, j; }; +struct B { struct A a; } b1 = { .a.i = 1, .a.j = 1 }; +struct B b2 = { .a.i = 1 }; + +struct C { struct { int a, b; }; } c1 = { .a = 4, .b = 2 }; +struct C c2 = { .a = 4, .b = 2 }; + +struct D { struct A a; }; +struct E { struct D d; }; +struct F { struct E e; } f1 = { .e.d.a.i = 8 }; +struct F f2 = { .e.d.a.i = 8, .e.d.a.j = 3 }; + +struct G { + struct { + struct { + struct { + int a, b, c, d, e, f; + }; + }; + }; +} g = { .b = 2 }; diff --git a/SingleSource/Regression/C/gcc-dg/pr60797.c b/SingleSource/Regression/C/gcc-dg/pr60797.c new file mode 100644 index 0000000000..45090bae50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60797.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { alias } } */ + +extern int foo __attribute__((alias("bar"))); /* { dg-error "supported" } */ +int main() +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60844.c b/SingleSource/Regression/C/gcc-dg/pr60844.c new file mode 100644 index 0000000000..16ed243d74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60844.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/60844 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ +/* { dg-additional-options "-mtune=atom" { target { i?86-*-* x86_64-*-* } } } */ + +void +foo (int *x, int y, int z) +{ + int b, c = x[0], d = x[1]; + for (b = 0; b < 1; b++) + { + int e = (y ? 1 : 0) | (d ? 2 : 0) | (z ? 1 : 0); + e |= (c ? 2 : 0) | ((1 >> b) ? 1 : 0); + x[2 + b] = e; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60866.c b/SingleSource/Regression/C/gcc-dg/pr60866.c new file mode 100644 index 0000000000..a97f4e5cb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60866.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -fselective-scheduling -fno-if-conversion -fschedule-insns" } */ + +int n; + +void +foo (int w, int **dnroot, int **dn) +{ + int *child; + int *xchild = xchild; + for (; w < n; w++) + if (!dnroot) + { + dnroot = dn; + for (child = *dn; child; child = xchild) + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr60915.c b/SingleSource/Regression/C/gcc-dg/pr60915.c new file mode 100644 index 0000000000..2ed0a5f10f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr60915.c @@ -0,0 +1,7 @@ +/* PR c/60915 */ +/* { dg-do compile } */ + +void /* { dg-error "attributes should be specified before the declarator in a function definition" } */ +foo (void) __attribute__((__visibility__("default"))) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61045.c b/SingleSource/Regression/C/gcc-dg/pr61045.c new file mode 100644 index 0000000000..1808cdc259 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61045.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-fstrict-overflow" } */ + +int main () +{ + int a = 0; + int b = __INT_MAX__; + int t = (a - 2) > (b - 1); + if (t != 0) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61053.c b/SingleSource/Regression/C/gcc-dg/pr61053.c new file mode 100644 index 0000000000..1c090e062b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61053.c @@ -0,0 +1,85 @@ +/* PR c/61053 */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Alignas (char) char cc; +_Alignas (short int) char cs; +_Alignas (int) char ci; +_Alignas (long int) char cl; +_Alignas (long long int) char cll; +_Alignas (float) char cf; +_Alignas (double) char cd; +_Alignas (long double) char cld; + +_Alignas (char) short int sc; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) short int ss; +_Alignas (int) short int si; +_Alignas (long int) short int sl; +_Alignas (long long int) short int sll; +_Alignas (float) short int sf; +_Alignas (double) short int sd; +_Alignas (long double) short int sld; + +_Alignas (char) int ic; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) int is; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) int ii; +_Alignas (long int) int il; +_Alignas (long long int) int ill; +_Alignas (float) int if_; +_Alignas (double) int id; +_Alignas (long double) int ild; + +_Alignas (char) long int lic; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) long int lis; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) long int lii; /* { dg-error "cannot reduce alignment" "" { target { ! { ilp32 } } } } */ +_Alignas (long int) long int lil; +_Alignas (long long int) long int lill; +_Alignas (float) long int lif; /* { dg-error "cannot reduce alignment" "" { target { ! { ilp32 } } } } */ +_Alignas (double) long int lid; +_Alignas (long double) long int lild; + +_Alignas (char) long long int llic; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) long long int llis; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) long long int llii; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (long int) long long int llil; /* { dg-error "cannot reduce alignment" "" { target { x32 } } } */ +_Alignas (long long int) long long int llill; +_Alignas (float) long long int llif; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (double) long long int llid; +_Alignas (long double) long long int llild; + +_Alignas (char) float fc; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) float fs; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) float fi; +_Alignas (long int) float fl; +_Alignas (long long int) float fll; +_Alignas (float) float ff; +_Alignas (double) float fd; +_Alignas (long double) float fld; + +_Alignas (char) double dc; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) double ds; /* { dg-error "cannot reduce alignment" } */ +_Alignas (int) double di; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (long int) double dl; /* { dg-error "cannot reduce alignment" "" { target { x32 } } } */ +_Alignas (long long int) double dll; +_Alignas (float) double df; /* { dg-error "cannot reduce alignment" "" { target { ! { ia32 } } } } */ +_Alignas (double) double dd; +_Alignas (long double) double dld; + +_Alignas (char) long double ldc; /* { dg-error "cannot reduce alignment" } */ +_Alignas (short int) long double lds; /* { dg-error "cannot reduce alignment" } */ + +#if __SIZEOF_LONG_DOUBLE__ == 12 +/* Get around PR testsuite/69573 - FAIL: gcc.dg/pr61053.c (test for excess + errors) on targets such as x86_64-apple-darwin15.3.0 where long double + is 16 bytes wide even in LP32. */ +# define X(T) short +#else +# define X(T) T +#endif + +_Alignas (X (int)) long double ldi; /* { dg-error "cannot reduce alignment" } */ +_Alignas (X (long int)) long double ldl; /* { dg-error "cannot reduce alignment" } */ +_Alignas (X (long long int)) long double ldll; /* { dg-error "cannot reduce alignment" } */ +_Alignas (X (float)) long double ldf; /* { dg-error "cannot reduce alignment" } */ +_Alignas (X (double)) long double ldd; /* { dg-error "cannot reduce alignment" } */ +_Alignas (long double) long double ldld; diff --git a/SingleSource/Regression/C/gcc-dg/pr61058.c b/SingleSource/Regression/C/gcc-dg/pr61058.c new file mode 100644 index 0000000000..6f840f418f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61058.c @@ -0,0 +1,10 @@ +/* PR rtl-optimization/61058 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-additional-options "-fno-asynchronous-unwind-tables -mtune=atom" { target i?86-*-* x86_64-*-* } } */ + +void +foo (void) +{ + __builtin_unreachable (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61060.c b/SingleSource/Regression/C/gcc-dg/pr61060.c new file mode 100644 index 0000000000..d2a1365076 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61060.c @@ -0,0 +1,19 @@ +/* PR target/61060 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -ftree-ter" } */ + +typedef __SIZE_TYPE__ size_t; + +extern inline __attribute__ ((gnu_inline, always_inline, artificial)) +void *memset (void *dest, int ch, size_t len) +{ + return __builtin_memset (dest, ch, len); +} + +char buf[10]; + +void +foo (void) +{ + memset (buf, sizeof (buf), 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61077.c b/SingleSource/Regression/C/gcc-dg/pr61077.c new file mode 100644 index 0000000000..d98bf65e7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61077.c @@ -0,0 +1,12 @@ +/* PR c/61077 */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wall" } */ + +_Atomic int +main (_Atomic int argc, _Atomic char **argv) +/* { dg-warning "qualified return type" "return" { target *-*-* } .-1 } */ +/* { dg-warning "qualified parameter type\[^\n\]*int" "parameter" { target *-*-* } .-2 } */ +/* { dg-warning "qualified parameter type\[^\n\]*char" "parameter" { target *-*-* } .-3 } */ +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61096-1.c b/SingleSource/Regression/C/gcc-dg/pr61096-1.c new file mode 100644 index 0000000000..90ffb8087d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61096-1.c @@ -0,0 +1,61 @@ +/* PR c/61077 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fshort-enums -fshort-wchar -Wpedantic" } */ +/* { dg-prune-output ".*near initialization for.*" } */ + +typedef enum { A } schar; +extern int e; +struct S +{ + int a[3]; +}; +struct f +{ + int w; + int x[]; +}; +struct g +{ + struct f f; /* { dg-warning "invalid use of structure with flexible array member" } */ +}; + +char w1[] = L"foo"; /* { dg-error "13:array of .char. from a string literal with type array of" } */ +__WCHAR_TYPE__ w2[] = "foo"; /* { dg-error "23:from a string literal with type array of .char." } */ +__WCHAR_TYPE__ w3[] = U"foo"; /* { dg-error "23:from a string literal with type array of" } */ +schar a1[] = "foo"; /* { dg-error "14:array of inappropriate type initialized from string constant" } */ +int a2[] = (int[]) { 1 }; /* { dg-warning "12:initializer element is not constant" } */ + +int a3 = e; /* { dg-error "10:initializer element is not constant" } */ +int a4 = (e, 1); /* { dg-error "10:initializer element is not constant" } */ +int a5 = a1[0]; /* { dg-error "10:initializer element is not constant" } */ +int a6 = &a3 - &a4; /* { dg-error "10:initializer element is not" } */ +int a7[] = a7; /* { dg-error "12:invalid initializer" } */ + +struct S s = { { 1 }, { 3 } }; /* { dg-error "23:extra brace group at end of initializer" } */ +/* { dg-warning "23:excess elements in struct initializer" "" { target *-*-* } .-1 } */ +struct g g1 = { {0, { 1 } } }; /* { dg-error "21:initialization of flexible array member in a nested context" } */ +struct g g2 = { .f[0] = 1 }; /* { dg-error "20:array index in non-array initializer" } */ + +__extension__ int a8 = { }; +int a9[10] = {[1.2] = 2 }; /* { dg-error "16:array index in initializer not of integer type" } */ +int a10[10] = {[e] = 2 }; /* { dg-error "17:nonconstant array index in initializer" } */ +__extension__ int a11[10] = {[1 ... e] = 1 }; /* { dg-error "31:nonconstant array index in initializer" } */ +int a12 = {[1] = 2 }; /* { dg-error "13:array index in non-array initializer" } */ +int a13[2] = {[-1] = 4 }; /* { dg-error "16:array index in initializer exceeds array bounds" } */ +int a14[2] = {[64] = 4 }; /* { dg-error "16:array index in initializer exceeds array bounds" } */ +__extension__ int a15[10] = {[2 ... 1] = 4 }; /* { dg-error "31:empty index range in initializer" } */ +__extension__ int a16[10] = {[2 ... 100] = 4 }; /* { dg-error "31:array index range in initializer exceeds array bounds" } */ +int a17[] = { .B = 1 }; /* { dg-error "15:field name not in record or union initializer" } */ +int a18[] = { e }; /* { dg-error "15:initializer element is not constant" } */ +char a19[1] = { "x", "x" }; /* { dg-error "22:excess elements in 'char.1.' initializer" } */ + +void +bar (void) +{ + struct f f = { 2, "c" }; /* { dg-error "21:non-static initialization of a flexible array member" } */ +} + +struct +{ + char *v; +} sx[] = { .v = 0 }; /* { dg-error "12:field name not in record or union initializer" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr61096-2.c b/SingleSource/Regression/C/gcc-dg/pr61096-2.c new file mode 100644 index 0000000000..fbea4d9db6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61096-2.c @@ -0,0 +1,10 @@ +/* PR c/61077 */ +/* { dg-do compile } */ + +struct s { char c[1]; }; +extern struct s foo (void); +void +bar (void) +{ + char *t = (foo ()).c; /* { dg-error "13:invalid use of non-lvalue array" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61158.c b/SingleSource/Regression/C/gcc-dg/pr61158.c new file mode 100644 index 0000000000..67eca30b93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61158.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/61158 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +unsigned long long +foo (unsigned int x) +{ + return ((unsigned long long) x & 0x00ff000000000000ULL) >> 40; +} + +/* { dg-final { scan-tree-dump "return 0;" "original" { target { ilp32 || lp64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr61162-2.c b/SingleSource/Regression/C/gcc-dg/pr61162-2.c new file mode 100644 index 0000000000..4aa8493d1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61162-2.c @@ -0,0 +1,48 @@ +/* PR c/61162 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat -Wpointer-sign -Wpedantic" } */ + +enum e { A }; +struct s { int a; }; + +enum e +fn1 (void) +{ + return 0; /* { dg-warning "10:enum conversion from 'int' to 'enum e' in return" } */ +} + +int +fn2 (struct s s) +{ + return s; /* { dg-error "10:incompatible types when returning" } */ +} + +void +fn3 (void) +{ + return 3; /* { dg-warning "10:in function returning void" } */ +} + +int +fn4 (int *a) +{ + return a; /* { dg-warning "10:returning 'int \\*' from a function with return type 'int' makes integer from pointer without a cast" } */ +} + +int * +fn5 (int a) +{ + return a; /* { dg-warning "10:returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */ +} + +unsigned int * +fn6 (int *i) +{ + return i; /* { dg-warning "10:pointer targets in returning 'int \\*' from a function with return type 'unsigned int \\*' differ" } */ +} + +void * +fn7 (void (*fp) (void)) +{ + return fp; /* { dg-warning "10:ISO C forbids return between function pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61162.c b/SingleSource/Regression/C/gcc-dg/pr61162.c new file mode 100644 index 0000000000..7ed0741e6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61162.c @@ -0,0 +1,12 @@ +/* PR c/61162 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +enum e { A }; +enum e +fn1 (void) +{ + enum e e, q = 0; /* { dg-warning "17:enum conversion from 'int' to 'enum e' in initialization is invalid" } */ + e = 0; /* { dg-warning "5:enum conversion from 'int' to 'enum e' in assignment is invalid" } */ + 1; return 0; /* { dg-warning "13:enum conversion from 'int' to 'enum e' in return is invalid" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61220.c b/SingleSource/Regression/C/gcc-dg/pr61220.c new file mode 100644 index 0000000000..d45d1c3c9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61220.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +int a, c, d, e, f, g, h, i, j, k; + +struct S0 +{ + int f0; + int f1; + int f2; +}; + +struct S1 +{ + int f0; + int f1; + struct S0 f2; +} b; + +void +fn1 (struct S1 p) +{ + for (; k; k++) + h = j ? a : a - 1; + d &= i; +} + +int +main () +{ + int l[5] = { 0 }; + fn1 (b); + for (c = 0; c < 3; c++) + for (g = 0; g < 3; g++) + l[c * 2] = e = l[c]; + if (f) + fn1 (b); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61240.c b/SingleSource/Regression/C/gcc-dg/pr61240.c new file mode 100644 index 0000000000..6332918f01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61240.c @@ -0,0 +1,20 @@ +/* PR c/61240 */ +/* { dg-do compile } */ + +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +ptrdiff_t +foo (ptrdiff_t a[4]) +{ + int i[4]; + int *p = i + 2; + static ptrdiff_t b = p - (p - 1); /* { dg-bogus "integer overflow in expression" } */ + static ptrdiff_t c = (p - 1) - p; /* { dg-bogus "integer overflow in expression" } */ + static ptrdiff_t d = (p - 2) - (p - 1);/* { dg-bogus "integer overflow in expression" } */ + static ptrdiff_t e = (p - 1) - (p - 2);/* { dg-bogus "integer overflow in expression" } */ + a[0] = p - (p - 1); /* { dg-bogus "integer overflow in expression" } */ + a[1] = (p - 1) - p; /* { dg-bogus "integer overflow in expression" } */ + a[2] = (p - 2) - (p - 1); /* { dg-bogus "integer overflow in expression" } */ + a[3] = (p - 1) - (p - 2); /* { dg-bogus "integer overflow in expression" } */ + return b + c + d + e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61441.c b/SingleSource/Regression/C/gcc-dg/pr61441.c new file mode 100644 index 0000000000..aaa259130a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61441.c @@ -0,0 +1,65 @@ +/* { dg-do run { target { *-*-linux* *-*-gnu* } } } */ +/* { dg-options "-O1 -lm -fexcess-precision=standard -fsignaling-nans" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target issignaling } */ + +#define _GNU_SOURCE +#include +#include + +void conversion() +{ + float sNaN = __builtin_nansf (""); + double x = (double) sNaN; + if (issignaling(x)) + { + __builtin_abort(); + } +} + +enum op {Add, Mult, Div, Abs}; + +void operation(enum op t) +{ + float x, y; + float sNaN = __builtin_nansf (""); + switch (t) + { + case Abs: + x = fabs(sNaN); + break; + case Add: + x = sNaN + 2.0; + break; + case Mult: + x = sNaN * 2.0; + break; + case Div: + default: + x = sNaN / 2.0; + break; + } + if (t == Abs) + { + if (!issignaling(x)) + { + __builtin_abort(); + } + } + else if (issignaling(x)) + { + __builtin_abort(); + } +} + +int main (void) +{ + conversion(); + operation(Add); + operation(Mult); + operation(Div); +#if __FLT_EVAL_METHOD__ == 0 + operation(Abs); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61529.c b/SingleSource/Regression/C/gcc-dg/pr61529.c new file mode 100644 index 0000000000..392239e715 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61529.c @@ -0,0 +1,27 @@ +/* PR middle-end/61529 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +unsigned int a = 0, b = 0; +unsigned int c; + +int +main () +{ + unsigned int d = 0; + int e[5]; + + for (; b < 1; b++) + d = 0; + for (; d < 1; d++) + a = 0; + for (; a < 1; a++) + ; + + for (c = 0; c < 5; c++) + e[c] = 1; + if (e[0]) + c = 0; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61561.c b/SingleSource/Regression/C/gcc-dg/pr61561.c new file mode 100644 index 0000000000..47d0ff0b81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61561.c @@ -0,0 +1,16 @@ +/* PR c/61561. */ +/* { dg-do assemble } */ +/* { dg-options " -w -O2" } */ +/* { dg-require-effective-target alloca } */ + +int dummy (int a); + +char a; +short b; + +void mmm (void) +{ + char dyn[dummy (3)]; + a = (char)&dyn[0]; + b = (short)&dyn[0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61583.c b/SingleSource/Regression/C/gcc-dg/pr61583.c new file mode 100644 index 0000000000..8424293c17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61583.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +void +f1 (int n, int b) +{ + extern void f2 (int); + int j; + + if (b) + n = 1; + + if (n < 1) + __builtin_unreachable (); + + for (j = 0; j < n; j++) + f2 (j); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61692.c b/SingleSource/Regression/C/gcc-dg/pr61692.c new file mode 100644 index 0000000000..1b619bd753 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61692.c @@ -0,0 +1,174 @@ +/* PR 61692 */ +/* { dg-do compile } */ + +/* Check for ice when exceededing the max # + of parameters to inline asm. */ + +int Labels() +{ + label01: label02: label03: label04: label05: + label06: label07: label08: label09: label10: + label11: label12: label13: label14: label15: + label16: label17: label18: label19: label20: + label21: label22: label23: label24: label25: + label26: label27: label28: label29: label30: + label31: + + __asm__ goto ("" /* Works. */ + : /* no outputs */ + : /* no inputs */ + : /* no clobbers */ + : label01, label02, label03, label04, label05, + label06, label07, label08, label09, label10, + label11, label12, label13, label14, label15, + label16, label17, label18, label19, label20, + label21, label22, label23, label24, label25, + label26, label27, label28, label29, label30); + + __asm__ goto ("" /* { dg-error "more than 30 operands" } */ + : /* no outputs */ + : /* no inputs */ + : /* no clobbers */ + : label01, label02, label03, label04, label05, + label06, label07, label08, label09, label10, + label11, label12, label13, label14, label15, + label16, label17, label18, label19, label20, + label21, label22, label23, label24, label25, + label26, label27, label28, label29, label30, + label31); + + return 0; +} + +int Labels_and_Inputs() +{ + int b01, b02, b03, b04, b05, b06, b07, b08, b09, b10; + int b11, b12, b13, b14, b15, b16, b17, b18, b19, b20; + int b21, b22, b23, b24, b25, b26, b27, b28, b29, b30; + int b31; + + label01: label02: label03: label04: label05: + label06: label07: label08: label09: label10: + label11: label12: label13: label14: label15: + label16: label17: label18: label19: label20: + label21: label22: label23: label24: label25: + label26: label27: label28: label29: label30: + label31: + + b01 = b02 = b03 = b04 = b05 = b06 = b07 = b08 = b09 = b10 = 0; + b11 = b12 = b13 = b14 = b15 = b16 = b17 = b18 = b19 = b20 = 0; + b21 = b22 = b23 = b24 = b25 = b26 = b27 = b28 = b29 = b30 = 0; + b31 = 0; + + __asm__ goto ("" /* Works. */ + : /* no outputs */ + : "m" (b01), "m" (b02), "m" (b03), "m" (b04), "m" (b05), + "m" (b06), "m" (b07), "m" (b08), "m" (b09), "m" (b10), + "m" (b11), "m" (b12), "m" (b13), "m" (b14), "m" (b15), + "m" (b16), "m" (b17), "m" (b18), "m" (b19), "m" (b20), + "m" (b21), "m" (b22), "m" (b23), "m" (b24), "m" (b25), + "m" (b26), "m" (b27), "m" (b28), "m" (b29) + : /* no clobbers */ + : label01); + + __asm__ goto ("" /* { dg-error "more than 30 operands" } */ + : /* no outputs */ + : "m" (b01), "m" (b02), "m" (b03), "m" (b04), "m" (b05), + "m" (b06), "m" (b07), "m" (b08), "m" (b09), "m" (b10), + "m" (b11), "m" (b12), "m" (b13), "m" (b14), "m" (b15), + "m" (b16), "m" (b17), "m" (b18), "m" (b19), "m" (b20), + "m" (b21), "m" (b22), "m" (b23), "m" (b24), "m" (b25), + "m" (b26), "m" (b27), "m" (b28), "m" (b29), "m" (b30) + : /* no clobbers */ + : label01); + + return 0; +} + +int Outputs() +{ + int b01, b02, b03, b04, b05, b06, b07, b08, b09, b10; + int b11, b12, b13, b14, b15, b16, b17, b18, b19, b20; + int b21, b22, b23, b24, b25, b26, b27, b28, b29, b30; + int b31; + + /* Outputs. */ + __asm__ volatile ("" /* Works. */ + : "=m" (b01), "=m" (b02), "=m" (b03), "=m" (b04), "=m" (b05), + "=m" (b06), "=m" (b07), "=m" (b08), "=m" (b09), "=m" (b10), + "=m" (b11), "=m" (b12), "=m" (b13), "=m" (b14), "=m" (b15), + "=m" (b16), "=m" (b17), "=m" (b18), "=m" (b19), "=m" (b20), + "=m" (b21), "=m" (b22), "=m" (b23), "=m" (b24), "=m" (b25), + "=m" (b26), "=m" (b27), "=m" (b28), "=m" (b29), "=m" (b30)); + + __asm__ volatile ("" /* { dg-error "more than 30 operands" } */ + : "=m" (b01), "=m" (b02), "=m" (b03), "=m" (b04), "=m" (b05), + "=m" (b06), "=m" (b07), "=m" (b08), "=m" (b09), "=m" (b10), + "=m" (b11), "=m" (b12), "=m" (b13), "=m" (b14), "=m" (b15), + "=m" (b16), "=m" (b17), "=m" (b18), "=m" (b19), "=m" (b20), + "=m" (b21), "=m" (b22), "=m" (b23), "=m" (b24), "=m" (b25), + "=m" (b26), "=m" (b27), "=m" (b28), "=m" (b29), "=m" (b30), + "=m" (b31)); + + return 0; +} + +int Inputs() +{ + int b01, b02, b03, b04, b05, b06, b07, b08, b09, b10; + int b11, b12, b13, b14, b15, b16, b17, b18, b19, b20; + int b21, b22, b23, b24, b25, b26, b27, b28, b29, b30; + int b31; + + b01 = b02 = b03 = b04 = b05 = b06 = b07 = b08 = b09 = b10 = 0; + b11 = b12 = b13 = b14 = b15 = b16 = b17 = b18 = b19 = b20 = 0; + b21 = b22 = b23 = b24 = b25 = b26 = b27 = b28 = b29 = b30 = 0; + b31 = 0; + + __asm__ volatile ("" /* Works. */ + : /* no outputs */ + : "m" (b01), "m" (b02), "m" (b03), "m" (b04), "m" (b05), + "m" (b06), "m" (b07), "m" (b08), "m" (b09), "m" (b10), + "m" (b11), "m" (b12), "m" (b13), "m" (b14), "m" (b15), + "m" (b16), "m" (b17), "m" (b18), "m" (b19), "m" (b20), + "m" (b21), "m" (b22), "m" (b23), "m" (b24), "m" (b25), + "m" (b26), "m" (b27), "m" (b28), "m" (b29), "m" (b30)); + + __asm__ volatile ("" /* { dg-error "more than 30 operands" } */ + : /* no outputs */ + : "m" (b01), "m" (b02), "m" (b03), "m" (b04), "m" (b05), + "m" (b06), "m" (b07), "m" (b08), "m" (b09), "m" (b10), + "m" (b11), "m" (b12), "m" (b13), "m" (b14), "m" (b15), + "m" (b16), "m" (b17), "m" (b18), "m" (b19), "m" (b20), + "m" (b21), "m" (b22), "m" (b23), "m" (b24), "m" (b25), + "m" (b26), "m" (b27), "m" (b28), "m" (b29), "m" (b30), + "m" (b31)); + + return 0; +} + +int Input_Output() +{ + int b01, b02, b03, b04, b05, b06, b07, b08, b09, b10; + int b11, b12, b13, b14, b15, b16, b17, b18, b19, b20; + int b21, b22, b23, b24, b25, b26, b27, b28, b29, b30; + int b31; + + b01 = b02 = b03 = b04 = b05 = b06 = b07 = b08 = b09 = b10 = 0; + b11 = b12 = b13 = b14 = b15 = b16 = b17 = b18 = b19 = b20 = 0; + b21 = b22 = b23 = b24 = b25 = b26 = b27 = b28 = b29 = b30 = 0; + b31 = 0; + + __asm__ volatile ("" /* Works. */ + : "+m" (b01), "+m" (b02), "+m" (b03), "+m" (b04), "+m" (b05), + "+m" (b06), "+m" (b07), "+m" (b08), "+m" (b09), "+m" (b10), + "+m" (b11), "+m" (b12), "+m" (b13), "+m" (b14), "+m" (b15)); + + __asm__ volatile ("" /* { dg-error "more than 30 operands" } */ + : "+m" (b01), "+m" (b02), "+m" (b03), "+m" (b04), "+m" (b05), + "+m" (b06), "+m" (b07), "+m" (b08), "+m" (b09), "+m" (b10), + "+m" (b11), "+m" (b12), "+m" (b13), "+m" (b14), "+m" (b15), + "+m" (b16)); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61756.c b/SingleSource/Regression/C/gcc-dg/pr61756.c new file mode 100644 index 0000000000..4ca90448f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61756.c @@ -0,0 +1,14 @@ +/* PR target/61756 */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +static volatile atomic_flag guard = ATOMIC_FLAG_INIT; + +void +try_atomic_flag_test_and_set (void) +{ + atomic_flag_test_and_set (&guard); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61762.c b/SingleSource/Regression/C/gcc-dg/pr61762.c new file mode 100644 index 0000000000..4696d53705 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61762.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-release_ssa" } */ + +unsigned int f() +{ + static const char string[] __attribute__((aligned(sizeof(int)))) = "Private"; + + unsigned int priv; + __builtin_memcpy(&priv, &string[0], sizeof(priv)); + return priv; +} + +/* We should have removed the static string and simplified the + memcpy to a store from an integer constant. CCP + already performs the simplification but only after release_ssa + the unused local static is removed. */ + +/* { dg-final { scan-tree-dump-not "Private" "release_ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr61773.c b/SingleSource/Regression/C/gcc-dg/pr61773.c new file mode 100644 index 0000000000..e0b4e60202 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61773.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/61773 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo (char **x) +{ + char *p = __builtin_malloc (64); + char *q = __builtin_malloc (64); + __builtin_strcat (q, "abcde"); + __builtin_strcat (p, "ab"); + p[1] = q[3]; + __builtin_strcat (p, q); + x[0] = p; + x[1] = q; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61776.c b/SingleSource/Regression/C/gcc-dg/pr61776.c new file mode 100644 index 0000000000..8deec9e993 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61776.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fprofile-generate" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +#include + +int cond1, cond2; + +int goo() __attribute__((noinline)); + +int goo() { + if (cond1) + return 1; + else + return 2; +} + +jmp_buf env; +int foo() { + int a; + + setjmp(env); + if (cond2) + a = goo(); + else + a = 3; + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61817-1.c b/SingleSource/Regression/C/gcc-dg/pr61817-1.c new file mode 100644 index 0000000000..d58497fa89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61817-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -ftrack-macro-expansion=0" } */ + +#define A(x) _Static_assert(x, #x) +#define F(x, y, z) a = __LINE__, b = x ## y, c = z + +enum { +#line 10 + F + ( + __LI, + NE__, + __LINE__ + ) +}; + +A(a == 10); +A(b == 10); +A(c == 10); diff --git a/SingleSource/Regression/C/gcc-dg/pr61817-2.c b/SingleSource/Regression/C/gcc-dg/pr61817-2.c new file mode 100644 index 0000000000..b7a860bd7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61817-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -ftrack-macro-expansion=1" } */ + +#define A(x) _Static_assert(x, #x) +#define F(x, y, z) a = __LINE__, b = x ## y, c = z + +enum { +#line 10 + F + ( + __LI, + NE__, + __LINE__ + ) +}; + +A(a == 10); +A(b == 10); +A(c == 14); diff --git a/SingleSource/Regression/C/gcc-dg/pr61852.c b/SingleSource/Regression/C/gcc-dg/pr61852.c new file mode 100644 index 0000000000..f488aca7ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61852.c @@ -0,0 +1,10 @@ +/* PR c/61852 */ +/* { dg-do compile } */ +/* { dg-options "-Wimplicit-function-declaration" } */ + +int +f (int a) +{ + int b = a + a + a + ff (a); /* { dg-warning "23:implicit declaration of function" } */ + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61861.c b/SingleSource/Regression/C/gcc-dg/pr61861.c new file mode 100644 index 0000000000..d9028686e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61861.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-prune-output "expected" } */ + +extern void foo (int); +extern void bar (int, char *); + +#define F __FILE__ /* { dg-error "11:passing argument" } */ +#define T __TIME__ /* { dg-error "11:passing argument" } */ +#define D __DATE__ /* { dg-error "11:passing argument" } */ +#define L __LINE__ /* { dg-error "11:passing argument" } */ + +#define F2 "foo" /* { dg-error "12:passing argument" } */ +#define T2 "foo" /* { dg-error "12:passing argument" } */ +#define D2 "foo" /* { dg-error "12:passing argument" } */ +#define L2 42 /* { dg-error "12:passing argument" } */ + +void +f (void) +{ + foo (__FILE__); /* { dg-error "8:passing argument" } */ + foo (__BASE_FILE__); /* { dg-error "8:passing argument" } */ + foo (__TIME__); /* { dg-error "8:passing argument" } */ + foo (__DATE__); /* { dg-error "8:passing argument" } */ + foo (__TIMESTAMP__); /* { dg-error "8:passing argument" } */ + bar (1, __LINE__); /* { dg-error "11:passing argument" } */ + bar (__COUNTER__, __COUNTER__); /* { dg-error "21:passing argument" } */ + + foo (F); /* { dg-message "8:in expansion of" } */ + foo (T); /* { dg-message "8:in expansion of" } */ + foo (D); /* { dg-message "8:in expansion of" } */ + bar (1, L); /* { dg-message "11:in expansion of" } */ + + foo (F2); /* { dg-message "8:in expansion of" } */ + foo (T2); /* { dg-message "8:in expansion of" } */ + foo (D2); /* { dg-message "8:in expansion of" } */ + bar (1, L2); /* { dg-message "11:in expansion of" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr61868.c b/SingleSource/Regression/C/gcc-dg/pr61868.c new file mode 100644 index 0000000000..4a7e8f6ae2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr61868.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto -frandom-seed=0x12345" } */ +extern int foo (int); +int main () +{ + foo (100); + return 0; +} +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr62004.c b/SingleSource/Regression/C/gcc-dg/pr62004.c new file mode 100644 index 0000000000..c994a411b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62004.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-tail-merge" } */ + +struct node +{ + struct node *next; + struct node *prev; +}; + +struct node node; + +struct head +{ + struct node *first; +}; + +struct head heads[5]; + +int k = 2; + +struct head *head = &heads[2]; + +int +main () +{ + struct node *p; + + node.next = (void*)0; + + node.prev = (void *)head; + + head->first = &node; + + struct node *n = head->first; + + struct head *h = &heads[k]; + + heads[2].first = n->next; + + if ((void*)n->prev == (void *)h) + p = h->first; + else + /* Dead tbaa-unsafe load from ((struct node *)&heads[2])->next. */ + p = n->prev->next; + + return !(p == (void*)0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr62024.c b/SingleSource/Regression/C/gcc-dg/pr62024.c new file mode 100644 index 0000000000..79a0b791f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62024.c @@ -0,0 +1,8 @@ +/* PR c/62024 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -Wpedantic" } */ +/* { dg-require-effective-target sync_char_short } */ + +int *p; +_Static_assert (__atomic_always_lock_free (1, p), ""); /* { dg-warning "is not an integer constant" } */ +_Static_assert (__atomic_always_lock_free (1, 0), ""); /* { dg-warning "is not an integer constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr62030.c b/SingleSource/Regression/C/gcc-dg/pr62030.c new file mode 100644 index 0000000000..b8baf93435 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62030.c @@ -0,0 +1,50 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +struct node +{ + struct node *next; + struct node *prev; +}; + +struct node node; + +struct head +{ + struct node *first; +}; + +struct head heads[5]; + +int k = 2; + +struct head *head = &heads[2]; + +static int __attribute__((noinline)) +foo (void) +{ + node.prev = (void *)head; + head->first = &node; + + struct node *n = head->first; + struct head *h = &heads[k]; + struct node *next = n->next; + + if (n->prev == (void *)h) + h->first = next; + else + n->prev->next = next; + + n->next = h->first; + return n->next == &node; +} + +int +main (void) +{ + if (foo ()) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr62070.c b/SingleSource/Regression/C/gcc-dg/pr62070.c new file mode 100644 index 0000000000..f7b0822201 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62070.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-vectorize" } */ + +int in[8][4]; +int out[4]; + +void +foo (void) +{ + int sum = 1; + int i, j, k; + for (k = 0; k < 4; k++) + { + for (j = 0; j < 4; j++) + for (i = 0; i < 4; i++) + sum *= in[i + k][j]; + out[k] = sum; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr62090-2.c b/SingleSource/Regression/C/gcc-dg/pr62090-2.c new file mode 100644 index 0000000000..af82edeb4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62090-2.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; +extern __inline __attribute__ ((__always_inline__)) +__attribute__ ((__gnu_inline__)) int +snprintf (char *__restrict __s, size_t __n, const char *__restrict __fmt, ...) +{ + return __builtin___snprintf_chk (__s, __n, 2 - 1, + __builtin_object_size (__s, 2 > 1), + __fmt, __builtin_va_arg_pack ()); +} +typedef struct apacket apacket; +struct apacket { + unsigned char data[4096]; +}; +static size_t fill_connect_data(char *buf, size_t bufsize) +{ + return snprintf(buf, bufsize, "host::") + 1; +} +unsigned send_connect(apacket *cp) +{ + return fill_connect_data((char *)cp->data, sizeof(cp->data)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr62090.c b/SingleSource/Regression/C/gcc-dg/pr62090.c new file mode 100644 index 0000000000..42f1345e64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62090.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +long a; +int *b; +extern __inline __attribute__ ((__always_inline__)) +__attribute__ ((__gnu_inline__)) int sprintf (int *p1, char *p2, ...) +{ + a = __builtin_object_size (0, 0); + return __builtin___sprintf_chk (0, 0, a, p2, __builtin_va_arg_pack ()); +} + +void +log_bad_request () +{ + b += sprintf (0, "foo"); +} + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr62167-run.c b/SingleSource/Regression/C/gcc-dg/pr62167-run.c new file mode 100644 index 0000000000..37214a3ece --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62167-run.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-tail-merge" } */ + +struct node +{ + struct node *next; + struct node *prev; +}; + +struct node node; + +struct head +{ + struct node *first; +}; + +struct head heads[5]; + +int k = 2; + +struct head *head = &heads[2]; + +int +main () +{ + struct node *p; + + node.next = (void*)0; + + node.prev = (void *)head; + + head->first = &node; + + struct node *n = head->first; + + struct head *h = &heads[k]; + + heads[2].first = n->next; + + if ((void*)n->prev == (void *)h) + p = h->first; + else + /* Dead tbaa-unsafe load from ((struct node *)&heads[2])->next. */ + p = n->prev->next; + + return !(p == (void*)0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr62167.c b/SingleSource/Regression/C/gcc-dg/pr62167.c new file mode 100644 index 0000000000..7293d642d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62167.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +struct node +{ + struct node *next; + struct node *prev; +}; + +struct node node; + +struct head +{ + struct node *first; +}; + +struct head heads[5]; + +int k = 2; + +struct head *head = &heads[2]; + +int +main () +{ + struct node *p; + + node.next = (void*)0; + + node.prev = (void *)head; + + asm("":"=m"(node.prev)); + + head->first = &node; + + struct node *n = head->first; + + struct head *h = &heads[k]; + + heads[2].first = n->next; + + if ((void*)n->prev == (void *)h) + p = h->first; + else + /* Dead tbaa-unsafe load from ((struct node *)&heads[2])->next. */ + p = n->prev->next; + + return !(p == (void*)0); +} + +/* { dg-final { scan-tree-dump-not "Removing basic block" "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr62294.c b/SingleSource/Regression/C/gcc-dg/pr62294.c new file mode 100644 index 0000000000..c6ec5a7536 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62294.c @@ -0,0 +1,10 @@ +/* PR c/62294 */ +/* { dg-do compile } */ + +#include "pr62294.h" + +void +fn (int *u) +{ + foo (u); /* { dg-error "passing argument 1 of .bar. from incompatible pointer type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr62294.h b/SingleSource/Regression/C/gcc-dg/pr62294.h new file mode 100644 index 0000000000..9be45adeab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr62294.h @@ -0,0 +1,3 @@ +#pragma GCC system_header +#define foo bar +extern void foo (float *); diff --git a/SingleSource/Regression/C/gcc-dg/pr63186.c b/SingleSource/Regression/C/gcc-dg/pr63186.c new file mode 100644 index 0000000000..32aa2afda9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63186.c @@ -0,0 +1,34 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target label_values } */ + +void *a; +int b, c, d; + +void +bar () +{ + switch (c) + { + case 0: + lab: + __asm__ (""); + return; + default: + break; + } + b = 0; + d = 0; + a = &&lab; +} + +void +foo () +{ + bar (); +} + +int +main() +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63284.c b/SingleSource/Regression/C/gcc-dg/pr63284.c new file mode 100644 index 0000000000..dc7fc28b87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63284.c @@ -0,0 +1,42 @@ +/* PR debug/63284 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +int a[10], *b, *d, c, f; +int fn2 (void); +void fn3 (void); +void fn4 (int); + +static int +fn1 (int x) +{ + int e = a[0]; + if (e) + return 1; + if (b) + switch (x) + { + case 1: + if (d) + e = fn2 (); + else + fn3 (); + break; + case 0: + if (d) + { + fn3 (); + if (c) + fn4 (1); + } + else + fn4 (0); + } + return e; +} + +void +fn6 (void) +{ + f = fn1 (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63342.c b/SingleSource/Regression/C/gcc-dg/pr63342.c new file mode 100644 index 0000000000..499d508c13 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63342.c @@ -0,0 +1,26 @@ +/* PR debug/63342 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ + +static __thread double u[9], v[9]; + +void +foo (double **p, double **q) +{ + *p = u; + *q = v; +} + +double +bar (double x) +{ + int i; + double s = 0.0; + for (i = 0; i < 9; i++) + { + double a = x + v[i]; + s += u[i] * a * a; + } + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63387-2.c b/SingleSource/Regression/C/gcc-dg/pr63387-2.c new file mode 100644 index 0000000000..61af608514 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63387-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ +/* { dg-skip-if "using short-double" { avr-*-* } } */ + +int f(double aaa, double bbb){ + int xa = !__builtin_isunordered(aaa, aaa); + int xb = !__builtin_isunordered(bbb, bbb); + return xa & xb; +} + +int g(double aaa, double bbb){ + int xa = !__builtin_isunordered(aaa, bbb); + int xb = !__builtin_isunordered(bbb, bbb); + return xa & xb; +} + +int h(double ccc, float ddd){ + int xc = !__builtin_isunordered(ccc, ccc); + int xd = !__builtin_isunordered(ddd, ddd); + return xc & xd; +} + +/* { dg-final { scan-tree-dump-not "aaa\[^\n\r\]* ord aaa" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "bbb\[^\n\r\]* ord bbb" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "aaa\[^\n\r\]* ord bbb" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "ccc\[^\n\r\]* ord ddd" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63387.c b/SingleSource/Regression/C/gcc-dg/pr63387.c new file mode 100644 index 0000000000..12cddf3a60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63387.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ +/* { dg-skip-if "using short-double" { avr-*-* } } */ + +int f(double aaa, double bbb){ + int xa = __builtin_isunordered(aaa, aaa); + int xb = __builtin_isunordered(bbb, bbb); + return xa | xb; +} + +int g(double aaa, double bbb){ + int xa = __builtin_isunordered(aaa, bbb); + int xb = __builtin_isunordered(bbb, bbb); + return xa | xb; +} + +int h(double ccc, float ddd){ + int xc = __builtin_isunordered(ccc, ccc); + int xd = __builtin_isunordered(ddd, ddd); + return xc | xd; +} + +/* { dg-final { scan-tree-dump-not "aaa\[^\n\r\]* unord aaa" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "bbb\[^\n\r\]* unord bbb" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "aaa\[^\n\r\]* unord bbb" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "ccc\[^\n\r\]* unord ddd" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63453.c b/SingleSource/Regression/C/gcc-dg/pr63453.c new file mode 100644 index 0000000000..e6337aa2f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63453.c @@ -0,0 +1,8 @@ +/* PR c/63453 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +inline int fn1 (void); /* { dg-warning "declared but never defined" } */ +extern inline int fn2 (void); /* { dg-warning "declared but never defined" } */ +inline int __attribute__ ((gnu_inline)) fn3 (void); +extern inline int __attribute__ ((gnu_inline)) fn4 (void); diff --git a/SingleSource/Regression/C/gcc-dg/pr63477.c b/SingleSource/Regression/C/gcc-dg/pr63477.c new file mode 100644 index 0000000000..8fb2f266fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63477.c @@ -0,0 +1,36 @@ +/* PR middle-end/63477 - Bogus warning with -O3 -Warray-bounds: array + subscript is above array bounds + { dg-do compile } + { dg-options "-O3 -Warray-bounds" } */ + +#define MAX_VAL 16 + +typedef struct +{ + int itemList[MAX_VAL + 1]; + unsigned int numItems; +} ItemList; + +void FrobList (ItemList *l) +{ + unsigned int i; + + for (i = 0; i < l->numItems - 1; i++) + { + int minVal = l->itemList[i]; + + unsigned int minIdx = i; + unsigned int idx; + + for (idx = i + 1; idx < l->numItems; ++idx) { + + if (l->itemList[idx] < minVal) /* { dg-bogus "\\\[-Warray-bounds]" } */ + { + minVal = l->itemList[idx]; + minIdx = idx; + } + } + + l->itemList[i] = l->itemList[minIdx]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63480.c b/SingleSource/Regression/C/gcc-dg/pr63480.c new file mode 100644 index 0000000000..e720e0ddd3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63480.c @@ -0,0 +1,14 @@ +/* PR c/63480 */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-field-initializers" } */ + +/* Test that we don't warn about initializing with { }. */ + +struct S { int a, b, c; } s = { }; + +void +foo (void) +{ + struct S s = { }; + struct S s2 = (struct S){ }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63543.c b/SingleSource/Regression/C/gcc-dg/pr63543.c new file mode 100644 index 0000000000..d85e10d202 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63543.c @@ -0,0 +1,21 @@ +/* PR c/63543 */ +/* { dg-do compile } */ + +struct S; +union U; + +int +f1 (struct S *s) +{ + return s->a /* { dg-error "invalid use of undefined type .struct S." } */ + + s->b /* { dg-error "invalid use of undefined type .struct S." } */ + + s->c; /* { dg-error "invalid use of undefined type .struct S." } */ +} + +int +f2 (union U *u) +{ + return u->a /* { dg-error "invalid use of undefined type .union U." } */ + + u->a /* { dg-error "invalid use of undefined type .union U." } */ + + u->a; /* { dg-error "invalid use of undefined type .union U." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63549.c b/SingleSource/Regression/C/gcc-dg/pr63549.c new file mode 100644 index 0000000000..bd0b706726 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63549.c @@ -0,0 +1,7 @@ +/* PR c/63549 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum E e; /* { dg-error "storage size of 'e' isn't known" } */ +int a[10]; +int i = a[e]; /* { dg-error "has an incomplete type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63567-1.c b/SingleSource/Regression/C/gcc-dg/pr63567-1.c new file mode 100644 index 0000000000..97da171563 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63567-1.c @@ -0,0 +1,10 @@ +/* PR c/63567 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Allow initializing objects with static storage duration with + compound literals even. This is being used in Linux kernel. */ + +struct T { int i; }; +struct S { struct T t; }; +static struct S s = (struct S) { .t = { 42 } }; diff --git a/SingleSource/Regression/C/gcc-dg/pr63567-2.c b/SingleSource/Regression/C/gcc-dg/pr63567-2.c new file mode 100644 index 0000000000..5ea2b37c36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63567-2.c @@ -0,0 +1,10 @@ +/* PR c/63567 */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +/* Allow initializing objects with static storage duration with + compound literals. This is being used in Linux kernel. */ + +struct T { int i; }; +struct S { struct T t; }; +static struct S s = (struct S) { .t = { 42 } }; /* { dg-warning "initializer element is not constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63567-3.c b/SingleSource/Regression/C/gcc-dg/pr63567-3.c new file mode 100644 index 0000000000..d62640677b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63567-3.c @@ -0,0 +1,7 @@ +/* PR c/63567 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct T { int i; }; +struct S { struct T t; }; +struct S s = { .t = { (int) { 1 } } }; diff --git a/SingleSource/Regression/C/gcc-dg/pr63567-4.c b/SingleSource/Regression/C/gcc-dg/pr63567-4.c new file mode 100644 index 0000000000..0ca6c45cc2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63567-4.c @@ -0,0 +1,7 @@ +/* PR c/63567 */ +/* { dg-do compile } */ +/* { dg-options "-Wpedantic" } */ + +struct T { int i; }; +struct S { struct T t; }; +struct S s = { .t = { (int) { 1 } } }; /* { dg-warning "initializer element is not constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63568.c b/SingleSource/Regression/C/gcc-dg/pr63568.c new file mode 100644 index 0000000000..5c688b0062 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63568.c @@ -0,0 +1,69 @@ +/* PR middle-end/63568 */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ + +int +fn1 (int a, int b, int m) +{ + int tem1 = a & ~m; + int tem2 = b & m; + return tem1 | tem2; +} + +int +fn2 (int a, int b, int m) +{ + int tem1 = a & ~m; + int tem2 = m & b; + return tem1 | tem2; +} + +int +fn3 (int a, int b, int m) +{ + int tem1 = ~m & a; + int tem2 = m & b; + return tem1 | tem2; +} + +int +fn4 (int a, int b, int m) +{ + int tem1 = ~m & a; + int tem2 = b & m; + return tem1 | tem2; +} + +int +fn5 (int a, int b, int m) +{ + int tem1 = b & m; + int tem2 = a & ~m; + return tem1 | tem2; +} + +int +fn6 (int a, int b, int m) +{ + int tem1 = m & b; + int tem2 = a & ~m; + return tem1 | tem2; +} + +int +fn7 (int a, int b, int m) +{ + int tem1 = m & b; + int tem2 = ~m & a; + return tem1 | tem2; +} + +int +fn8 (int a, int b, int m) +{ + int tem1 = b & m; + int tem2 = ~m & a; + return tem1 | tem2; +} + +/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63593.c b/SingleSource/Regression/C/gcc-dg/pr63593.c new file mode 100644 index 0000000000..08bc8f976d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63593.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-vectorize" } */ + +int in[2 * 4][4]; +int out[4]; + +void +foo (void) +{ + int sum; + int i, j, k; + for (k = 0; k < 4; k++) + { + sum = 1; + for (j = 0; j < 4; j++) + for (i = 0; i < 4; i++) + sum *= in[i + k][j]; + out[k] = sum; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63594-1.c b/SingleSource/Regression/C/gcc-dg/pr63594-1.c new file mode 100644 index 0000000000..b8cd201fd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63594-1.c @@ -0,0 +1,66 @@ +/* PR target/63594 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi" } */ +/* { dg-additional-options "-mno-mmx" { target i?86-*-* x86_64-*-* } } */ +/* { dg-prune-output "non-standard ABI extension" } */ + +#define C1 c +#define C2 C1, C1 +#define C4 C2, C2 +#define C8 C4, C4 +#define C16 C8, C8 +#define C32 C16, C16 +#define C64 C32, C32 +#define C_(n) n +#define C(n) C_(C##n) + +#define T(t,s) \ +typedef t v##t##s __attribute__ ((__vector_size__ (s * sizeof (t)))); \ +v##t##s \ +test1##t##s (t c) \ +{ \ + v##t##s v = { C(s) }; \ + return v; \ +} \ + \ +v##t##s \ +test2##t##s (t *p) \ +{ \ + t c = *p; \ + v##t##s v = { C(s) }; \ + return v; \ +} + +typedef long long llong; + +T(char, 64) +T(char, 32) +T(char, 16) +T(char, 8) +T(char, 4) +T(char, 2) +T(char, 1) +T(short, 32) +T(short, 16) +T(short, 8) +T(short, 4) +T(short, 2) +T(short, 1) +T(int, 16) +T(int, 8) +T(int, 4) +T(int, 2) +T(int, 1) +T(float, 16) +T(float, 8) +T(float, 4) +T(float, 2) +T(float, 1) +T(llong, 8) +T(llong, 4) +T(llong, 2) +T(llong, 1) +T(double, 8) +T(double, 4) +T(double, 2) +T(double, 1) diff --git a/SingleSource/Regression/C/gcc-dg/pr63594-2.c b/SingleSource/Regression/C/gcc-dg/pr63594-2.c new file mode 100644 index 0000000000..5c6bb315ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63594-2.c @@ -0,0 +1,93 @@ +/* PR target/63594 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-psabi" } */ +/* { dg-additional-options "-mno-mmx" { target i?86-*-* x86_64-*-* } } */ +/* { dg-prune-output "non-standard ABI extension" } */ + +#define C1 c +#define C2 C1, C1 +#define C4 C2, C2 +#define C8 C4, C4 +#define C16 C8, C8 +#define C32 C16, C16 +#define C64 C32, C32 +#define C_(n) n +#define C(n) C_(C##n) + +#define T(t,s) \ +typedef t v##t##s __attribute__ ((__vector_size__ (s * sizeof (t)))); \ +__attribute__((noinline, noclone)) v##t##s \ +test1##t##s (t c) \ +{ \ + v##t##s v = { C(s) }; \ + return v; \ +} \ + \ +__attribute__((noinline, noclone)) v##t##s \ +test2##t##s (t *p) \ +{ \ + t c = *p; \ + v##t##s v = { C(s) }; \ + return v; \ +} \ + \ +void \ +test3##t##s (void) \ +{ \ + t c = 17; \ + int i; \ + v##t##s a = test1##t##s (c); \ + for (i = 0; i < s; i++) \ + if (a[i] != 17) \ + __builtin_abort (); \ + v##t##s b = test2##t##s (&c); \ + for (i = 0; i < s; i++) \ + if (a[i] != 17) \ + __builtin_abort (); \ +} + +typedef long long llong; + +#define TESTS \ +T(char, 64) \ +T(char, 32) \ +T(char, 16) \ +T(char, 8) \ +T(char, 4) \ +T(char, 2) \ +T(char, 1) \ +T(short, 32) \ +T(short, 16) \ +T(short, 8) \ +T(short, 4) \ +T(short, 2) \ +T(short, 1) \ +T(int, 16) \ +T(int, 8) \ +T(int, 4) \ +T(int, 2) \ +T(int, 1) \ +T(float, 16) \ +T(float, 8) \ +T(float, 4) \ +T(float, 2) \ +T(float, 1) \ +T(llong, 8) \ +T(llong, 4) \ +T(llong, 2) \ +T(llong, 1) \ +T(double, 8) \ +T(double, 4) \ +T(double, 2) \ +T(double, 1) + +TESTS + +int +main () +{ +#undef T +#define T(t,s) test3##t##s (); + TESTS + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63626.c b/SingleSource/Regression/C/gcc-dg/pr63626.c new file mode 100644 index 0000000000..820337b8d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63626.c @@ -0,0 +1,8 @@ +/* PR c/63626 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +/* Test that we don't output the warning twice. */ + +inline int foo (void); /* { dg-bogus "inline function.*inline function" } */ +/* { dg-warning "inline function .foo. declared but never defined" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63637-1.c b/SingleSource/Regression/C/gcc-dg/pr63637-1.c new file mode 100644 index 0000000000..7a716f98c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63637-1.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/63637 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (void) +{ + int a, b, c; + asm ("# Magic instruction" : "=r" (a)); + asm ("# Magic instruction" : "=r" (b)); + asm ("# Magic instruction" : "=r" (c)); + return a + b + c; +} + +/* { dg-final { scan-assembler-times "# Magic instruction" 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63637-2.c b/SingleSource/Regression/C/gcc-dg/pr63637-2.c new file mode 100644 index 0000000000..44e9d7c96e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63637-2.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/63637 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (void) +{ + int a, b, c; + asm ("# Magic instruction" : "=r" (a) : "r" (0)); + asm ("# Magic instruction" : "=r" (b) : "r" (0)); + asm ("# Magic instruction" : "=r" (c) : "r" (0)); + return a + b + c; +} + +/* { dg-final { scan-assembler-times "# Magic instruction" 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63637-3.c b/SingleSource/Regression/C/gcc-dg/pr63637-3.c new file mode 100644 index 0000000000..51a2ff707e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63637-3.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/63637 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (void) +{ + int a, b, c; + asm ("# Magic instruction" : "=r" (a) : : "memory"); + asm ("# Magic instruction" : "=r" (b) : : "memory"); + asm ("# Magic instruction" : "=r" (c) : : "memory"); + return a + b + c; +} + +/* { dg-final { scan-assembler-times "# Magic instruction" 3 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63637-4.c b/SingleSource/Regression/C/gcc-dg/pr63637-4.c new file mode 100644 index 0000000000..1a914830c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63637-4.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/63637 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (void) +{ + int a, b, c; + asm ("# Magic instruction" : "=r" (a) : "r" (0) : "memory"); + asm ("# Magic instruction" : "=r" (b) : "r" (0) : "memory"); + asm ("# Magic instruction" : "=r" (c) : "r" (0) : "memory"); + return a + b + c; +} + +/* { dg-final { scan-assembler-times "# Magic instruction" 3 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63637-5.c b/SingleSource/Regression/C/gcc-dg/pr63637-5.c new file mode 100644 index 0000000000..fce8593adb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63637-5.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/63637 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (void) +{ + int a, b, c, d, e, f; + asm ("# Magic instruction" : "=r" (a), "=r" (d)); + asm ("# Magic instruction" : "=r" (b), "=r" (e)); + asm ("# Magic instruction" : "=r" (c), "=r" (f)); + return a + b + c; +} + +/* { dg-final { scan-assembler-times "# Magic instruction" 3 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63637-6.c b/SingleSource/Regression/C/gcc-dg/pr63637-6.c new file mode 100644 index 0000000000..1b997c4304 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63637-6.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/63637 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (void) +{ + int a, b, c, d, e, f; + asm ("# Magic instruction" : "=r" (a), "=r" (d) : "r" (0)); + asm ("# Magic instruction" : "=r" (b), "=r" (e) : "r" (0)); + asm ("# Magic instruction" : "=r" (c), "=r" (f) : "r" (0)); + return a + b + c; +} + +/* { dg-final { scan-assembler-times "# Magic instruction" 3 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63665.c b/SingleSource/Regression/C/gcc-dg/pr63665.c new file mode 100644 index 0000000000..046ecae7c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63665.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-fre -fno-tree-copy-prop -fwrapv" } */ + +static inline int +test5 (int x) +{ + int y = 0x80000000; + return x + y; +} + +int +main () +{ + if (test5 (0x80000000) != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63743.c b/SingleSource/Regression/C/gcc-dg/pr63743.c new file mode 100644 index 0000000000..ba492b9fe8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63743.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-rtl-expand-details" } */ + +double +libcall_dep (double x, double y) +{ + double tem = x + y; + return x * tem; +} + +/* { dg-final { scan-rtl-dump-times "Swap operands" 1 "expand" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr63748.c b/SingleSource/Regression/C/gcc-dg/pr63748.c new file mode 100644 index 0000000000..cc353a7e5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63748.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-require-effective-target nonlocal_goto } */ + +#include + +jmp_buf *alloc_jmp_buf (); +int foo (void *); + +int +test (int op, int noside) +{ + void *argvec = 0; + + if (op) + { + jmp_buf *buf = alloc_jmp_buf (); /* { dg-bogus "uninitialized" } */ + setjmp (*buf); + + if (noside) + goto nosideret; + + do_call_it: + + if (noside) + goto nosideret; + + return foo (argvec); + } + + argvec = __builtin_alloca (1); + goto do_call_it; + +nosideret: + return 1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr63762.c b/SingleSource/Regression/C/gcc-dg/pr63762.c new file mode 100644 index 0000000000..df110676ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63762.c @@ -0,0 +1,77 @@ +/* PR middle-end/63762 */ +/* { dg-do assemble } */ +/* { dg-options "-O2" } */ + +#include + +void *astFree (); +void *astMalloc (); +void astNegate (void *); +int astGetNegated (void *); +void astGetRegionBounds (void *, double *, double *); +int astResampleF (void *, ...); + +extern int astOK; + +int +MaskF (int inside, int ndim, const int lbnd[], const int ubnd[], + float in[], float val) +{ + + void *used_region; + float *c, *d, *out, *tmp_out; + double *lbndgd, *ubndgd; + int *lbndg, *ubndg, idim, ipix, nax, nin, nout, npix, npixg, result = 0; + if (!astOK) return result; + lbndg = astMalloc (sizeof (int)*(size_t) ndim); + ubndg = astMalloc (sizeof (int)*(size_t) ndim); + lbndgd = astMalloc (sizeof (double)*(size_t) ndim); + ubndgd = astMalloc (sizeof (double)*(size_t) ndim); + if (astOK) + { + astGetRegionBounds (used_region, lbndgd, ubndgd); + npix = 1; + npixg = 1; + for (idim = 0; idim < ndim; idim++) + { + lbndg[ idim ] = lbnd[ idim ]; + ubndg[ idim ] = ubnd[ idim ]; + npix *= (ubnd[ idim ] - lbnd[ idim ] + 1); + if (npixg >= 0) npixg *= (ubndg[ idim ] - lbndg[ idim ] + 1); + } + if (npixg <= 0 && astOK) + { + if ((inside != 0) == (astGetNegated( used_region ) != 0)) + { + c = in; + for (ipix = 0; ipix < npix; ipix++) *(c++) = val; + result = npix; + } + } + else if (npixg > 0 && astOK) + { + if ((inside != 0) == (astGetNegated (used_region) != 0)) + { + tmp_out = astMalloc (sizeof (float)*(size_t) npix); + if (tmp_out) + { + c = tmp_out; + for (ipix = 0; ipix < npix; ipix++) *(c++) = val; + result = npix - npixg; + } + out = tmp_out; + } + else + { + tmp_out = NULL; + out = in; + } + if (inside) astNegate (used_region); + result += astResampleF (used_region, ndim, lbnd, ubnd, in, NULL, + NULL, NULL, 0, 0.0, 100, val, ndim, + lbnd, ubnd, lbndg, ubndg, out, NULL); + if (inside) astNegate (used_region); + } + } + return result; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63770.c b/SingleSource/Regression/C/gcc-dg/pr63770.c new file mode 100644 index 0000000000..973df34057 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63770.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +char a; + +struct S +{ + int f0:9; +}; + +volatile struct S b; + +int +fn1 () +{ + return (1 & b.f0) < a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63804.c b/SingleSource/Regression/C/gcc-dg/pr63804.c new file mode 100644 index 0000000000..f0a02f26ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63804.c @@ -0,0 +1,52 @@ +/* PR rtl-optimization/63804 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +struct A { int gen; } e; +int a, d; +long b; +enum B { C }; +struct D +{ + enum B type : 1; + int nr : 1; + struct { unsigned ud; } dw1; +}; +enum B c; + +void +fn1 (int p1) +{ + b = p1 & a; +} + +int fn2 (); +void fn3 (); + +void +fn4 (struct D p1, unsigned p2, int p3) +{ + struct D f, g, h, j = p1, l, m = l; + struct A i = e; + if (i.gen) + p2 = 0; + j.type = c; + g = j; + p1 = g; + fn3 (); + int k = p2, v = p1.nr, p = v; + m.dw1.ud = k; + f = m; + h = f; + struct D n = h; + fn3 (n); + { + d = fn2 (); + int o = d; + fn1 (o); + } + if (i.gen) + fn3 (p1); + b = p & a; + fn3 (p3); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63835.c b/SingleSource/Regression/C/gcc-dg/pr63835.c new file mode 100644 index 0000000000..435966b190 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63835.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +int a; + +int +fn1 (int p) +{ + return -p; +} + +void +fn2 () +{ + fn1 (-(unsigned int) a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63856.c b/SingleSource/Regression/C/gcc-dg/pr63856.c new file mode 100644 index 0000000000..6a987e2c8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63856.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ +typedef int v2si __attribute__ ((vector_size (8))); +typedef short v4hi __attribute__ ((vector_size (8))); + +int __attribute__ ((noinline, noclone)) f (v2si A, int N) +{ + return ((v4hi) A)[N]; +} + +int __attribute__ ((noinline, noclone)) g (v2si A, int N) +{ + return ((v4hi) A)[N]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr63877.c b/SingleSource/Regression/C/gcc-dg/pr63877.c new file mode 100644 index 0000000000..5969b39d21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63877.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-declarations" } */ + +inline int foo (void) { return 42; } /* { dg-bogus "no previous declaration" } */ +extern int foo (void); diff --git a/SingleSource/Regression/C/gcc-dg/pr63914.c b/SingleSource/Regression/C/gcc-dg/pr63914.c new file mode 100644 index 0000000000..df8f537b29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr63914.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ +/* { dg-prune-output "non-standard ABI extension" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ +/* { dg-additional-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target int32plus } */ + +typedef float __m128 __attribute__ ((__vector_size__ (16))); +__m128 a, d, e; +int b; +struct dt_interpolation c; +__m128 +fn1 (float p1) +{ + return (__attribute__ ((__vector_size__ (4 * sizeof 0))) float){ p1 }; +} +__m128 +fn2 (float p1) +{ + return fn1 (p1); +} +struct dt_interpolation +{ + int width; +}; +void +fn3 (struct dt_interpolation *p1, int *p2) +{ + int i = 0, n = 0; + while (i < 2 * p1->width) + n = i++; + *p2 = n; +} +void +fn4 () +{ + __m128 f; + fn3 (&c, &b); + __m128 g = fn2 (1.f / b); + e = (__m128){}; + __m128 h = e; + for (int i = 0; i < 2 * c.width; i++) + { + for (; c.width;) + f = a; + h = f; + } + d = h * g; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64007.c b/SingleSource/Regression/C/gcc-dg/pr64007.c new file mode 100644 index 0000000000..cb0e50f6cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64007.c @@ -0,0 +1,50 @@ +/* { dg-options " -O3 " } */ +/* { dg-do run } */ + +#include + +int d, i; + +struct S +{ + int f0; +} *b, c, e, h, **g = &b; + +static struct S *f = &e; + +int +fn1 (int p) +{ + int a = 0; + return a || p < 0 || p >= 2 || 1 >> p; +} + +int +main () +{ + int k = 1, l, *m = &c.f0; + + for (;;) + { + l = fn1 (i); + *m = k && i; + if (l) + { + int n[1] = {0}; + } + break; + } + + *g = &h; + + assert (b); + + if (d) + (*m)--; + d = (f != 0) | (i >= 0); + + if (c.f0 != 0) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64015.c b/SingleSource/Regression/C/gcc-dg/pr64015.c new file mode 100644 index 0000000000..daf839351d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64015.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 " } */ + +int +test (unsigned short a, unsigned char b) +{ + return a > 0xfff2 && b > 252; +} + +/* { dg-final { scan-assembler "ccmp" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr64075.c b/SingleSource/Regression/C/gcc-dg/pr64075.c new file mode 100644 index 0000000000..f913a79eed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64075.c @@ -0,0 +1,9 @@ +/* PR lto/64075 */ +/* { dg-do compile } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto" } */ + +_Complex float test (float a, float b, float c, float d) +{ + return 1.0iF; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64087.c b/SingleSource/Regression/C/gcc-dg/pr64087.c new file mode 100644 index 0000000000..fe3c634762 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64087.c @@ -0,0 +1,35 @@ +/* PR rtl-optimization/64087 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int printf (const char *, ...); + +int a[72], b, c, d, e; + +int +main () +{ + int h; + for (b = 0; b < 72; b++) + { + h = 1; + if (b) + h >>= 1; + a[b] = h; + } + for (; e; e++) + for (c = 0; c < 1;) + for (; d;) + { + printf ("0"); + int g; + for (b = 0; b < 72; b++) + { + g = 1; + if (b) + g >>= 1; + a[b] = g; + } + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64223-1.c b/SingleSource/Regression/C/gcc-dg/pr64223-1.c new file mode 100644 index 0000000000..32c38e6fce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64223-1.c @@ -0,0 +1,12 @@ +/* PR c/64223: Test for duplicated warnings. */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +int printf (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); + +void +foo (void) +{ + printf ("%d\n", 0UL); /* { dg-bogus "expects argument of type.*expects argument of type" } */ + /* { dg-warning "expects argument of type" "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64223-2.c b/SingleSource/Regression/C/gcc-dg/pr64223-2.c new file mode 100644 index 0000000000..0a2b7e460f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64223-2.c @@ -0,0 +1,13 @@ +/* PR c/64223: Test for duplicated warnings. */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +int myprintf (const char *, ...) __attribute__ ((__format__ (printf, 1, 2))); +int myprintf (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); + +void +foo (void) +{ + myprintf ("%d\n", 0UL); /* { dg-bogus "expects argument of type.*expects argument of type" } */ + /* { dg-warning "expects argument of type" "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64252.c b/SingleSource/Regression/C/gcc-dg/pr64252.c new file mode 100644 index 0000000000..a813f5aedc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64252.c @@ -0,0 +1,31 @@ +/* PR target/64252 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target int32plus } */ + +typedef unsigned int V __attribute__((vector_size (32))); + +__attribute__((noinline, noclone)) void +foo (V *a, V *b, V *c, V *d, V *e) +{ + V t = __builtin_shuffle (*a, *b, *c); + V v = __builtin_shuffle (t, (V) { ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U }, (V) { 0, 1, 8, 3, 4, 5, 9, 7 }); + v = v + *d; + *e = v; +} + +int +main () +{ + V a, b, c, d, e; + int i; + a = (V) { 1, 2, 3, 4, 5, 6, 7, 8 }; + b = (V) { 9, 10, 11, 12, 13, 14, 15, 16 }; + c = (V) { 1, 3, 5, 7, 9, 11, 13, 15 }; + d = (V) { 0, 0, 0, 0, 0, 0, 0, 0 }; + foo (&a, &b, &c, &d, &e); + for (i = 0; i < 8; i++) + if (e[i] != ((i == 2 || i == 6) ? ~0U : 2 + 2 * i)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64277.c b/SingleSource/Regression/C/gcc-dg/pr64277.c new file mode 100644 index 0000000000..aebb0fe19d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64277.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/64277 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wall -Werror -fdump-tree-cunroll-details" } */ +/* { dg-final { scan-tree-dump "loop with 4 iterations completely unrolled" "cunroll" } } */ +/* { dg-final { scan-tree-dump "loop with 5 iterations completely unrolled" "cunroll" } } */ + +#if __SIZEOF_INT__ < 4 + __extension__ typedef __INT32_TYPE__ int32_t; +#else + typedef int int32_t; +#endif + +int32_t f1[10]; +void test1 (short a[], short m, unsigned short l) +{ + int32_t i = l; + for (i = i + 5; i < m; i++) + f1[i] = a[i]++; +} + +void test2 (short a[], short m, short l) +{ + int32_t i; + if (m > 5) + m = 5; + for (i = m; i > l; i--) + f1[i] = a[i]++; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64295.c b/SingleSource/Regression/C/gcc-dg/pr64295.c new file mode 100644 index 0000000000..4882f3254e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64295.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O -frounding-math -funsafe-math-optimizations" } */ + +double +f (double g) +{ + return g / 3; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64309.c b/SingleSource/Regression/C/gcc-dg/pr64309.c new file mode 100644 index 0000000000..0a3a009aaf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64309.c @@ -0,0 +1,65 @@ +/* PR middle-end/64309 */ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-original" } */ + +int +fn1 (int n) +{ + return ((1 << n) & 1) != 0; +} + +int +fn2 (int n) +{ + return (1 & (1 << n)) != 0; +} + +int +fn3 (int n) +{ + return ((1 << n) & 1) == 0; +} + +int +fn4 (int n) +{ + return (1 & (1 << n)) == 0; +} + +int +main (void) +{ + if (fn1 (0) != 1 + || fn1 (1) != 0 + || fn1 (2) != 0 + || fn1 (3) != 0 + || fn1 (4) != 0 + || fn1 (5) != 0) + __builtin_abort (); + + if (fn2 (0) != 1 + || fn2 (1) != 0 + || fn2 (2) != 0 + || fn2 (3) != 0 + || fn2 (4) != 0 + || fn2 (5) != 0) + __builtin_abort (); + + if (fn3 (0) != 0 + || fn3 (1) != 1 + || fn3 (2) != 1 + || fn3 (3) != 1 + || fn3 (4) != 1 + || fn3 (5) != 1) + __builtin_abort (); + + if (fn4 (0) != 0 + || fn4 (1) != 1 + || fn4 (2) != 1 + || fn4 (3) != 1 + || fn4 (4) != 1 + || fn4 (5) != 1) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "(<<|>>)" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr64316.c b/SingleSource/Regression/C/gcc-dg/pr64316.c new file mode 100644 index 0000000000..f478aa6117 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64316.c @@ -0,0 +1,42 @@ +/* PR rtl-optimization/64316 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */ + +struct S +{ + unsigned int s; + unsigned long w[]; +}; + +struct S **s; + +int +foo (struct S *x, struct S *y, struct S *z) +{ + unsigned int i; + unsigned long *a, *b, *c; + int r = 0; + for (a = x->w, b = y->w, c = z->w, i = 0; i < x->s; i++, a++) + { + unsigned long d = *b++ & *c++; + if (*a != d) + { + r = 1; + *a = d; + } + } + return r; +} + +void +bar (int x) +{ + int p = x - 1; + do + { + foo (s[x], s[x], s[p]); + p--; + } + while (p > 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64406.c b/SingleSource/Regression/C/gcc-dg/pr64406.c new file mode 100644 index 0000000000..8af8e55777 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64406.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-distribute-patterns -fno-tree-loop-ivcanon -fno-tree-loop-vectorize -ftree-vectorize" } */ + +unsigned in[72]; + +void bar (unsigned out[], unsigned ia[]); + +void +foo () +{ + int i; + unsigned out[72], ia[8]; + for (i = 0; i < 8; i++) + { + out[i * 8] = in[i * 8] + 5; + out[i * 8 + 1] = in[i * 8 + 1] + 6; + out[i * 8 + 2] = in[i * 8 + 2] + 7; + out[i * 8 + 3] = in[i * 8 + 3] + 8; + out[i * 8 + 4] = in[i * 8 + 4] + 9; + out[i * 8 + 5] = in[i * 8 + 5] + 10; + out[i * 8 + 6] = in[i * 8 + 6] + 11; + out[i * 8 + 7] = in[i * 8 + 7] + 12; + ia[i] = in[i]; + } + bar (out, ia); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64417.c b/SingleSource/Regression/C/gcc-dg/pr64417.c new file mode 100644 index 0000000000..1e98b22d64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64417.c @@ -0,0 +1,16 @@ +/* PR c/64417 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct foo { int x; char y[]; }; +struct bar { struct foo f; }; +struct baz { struct bar b; }; + +struct foo a1 = { 1, "abc" }; +struct foo a2 = { 1, { "abc" } }; +struct foo b1[] = { { 1, "abc" } }; /* { dg-error "initialization of flexible array member" } */ +struct foo b2[] = { { 1, { "abc" } } }; /* { dg-error "initialization of flexible array member" } */ +struct bar c1[] = { { { 1, "abc" } } }; /* { dg-error "initialization of flexible array member" } */ +struct bar c2[] = { { { 1, { "abc" } } } }; /* { dg-error "initialization of flexible array member" } */ +struct baz d1[] = { { { { 1, "abc" } } } }; /* { dg-error "initialization of flexible array member" } */ +struct baz d2[] = { { { { 1, { "abc" } } } } }; /* { dg-error "initialization of flexible array member" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr64423.c b/SingleSource/Regression/C/gcc-dg/pr64423.c new file mode 100644 index 0000000000..c228acb05a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64423.c @@ -0,0 +1,13 @@ +/* PR c/64423 */ +/* { dg-do compile } */ +/* { dg-options "-Wchar-subscripts" } */ + +int a[100]; + +int +f (char c) +{ + return a[c] /* { dg-warning "11:array subscript has type .char." } */ + + a[c] /* { dg-warning "14:array subscript has type .char." } */ + + a[c]; /* { dg-warning "16:array subscript has type .char." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64434.c b/SingleSource/Regression/C/gcc-dg/pr64434.c new file mode 100644 index 0000000000..d70550d416 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64434.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-rtl-expand-details" } */ +/* { dg-skip-if "PR64886" { hppa*-*-hpux* } } */ + +#define N 256 +int a1[N], a2[N], a3[N], a4[N]; + +void foo () +{ + int i; + for (i=0; iq) + { + j = *f; + h->q = *f; + } + else + i = (long *) (__INTPTR_TYPE__) (h->q = *f); + *c++ = (__INTPTR_TYPE__) f; + e += 6; + } + else + { + f = baz (); + g = k++; + if (&h->q) + { + j = *f; + h->q = *f; + } + else + i = (long *) (__INTPTR_TYPE__) (h->q = *f); + *c++ = (__INTPTR_TYPE__) f; + e += 6; + } + } +} + +int +main () +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64563.c b/SingleSource/Regression/C/gcc-dg/pr64563.c new file mode 100644 index 0000000000..7223349c41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64563.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/64563 */ +/* { dg-do compile } */ +/* { dg-options "-Os -Wtype-limits" } */ + +int a, b, c, d, f; +unsigned int e; + +void +foo (void) +{ + d = b = (a != (e | 4294967288UL)); + if (!d) + c = f || b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64637.c b/SingleSource/Regression/C/gcc-dg/pr64637.c new file mode 100644 index 0000000000..779ff502df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64637.c @@ -0,0 +1,25 @@ +/* PR c/64637 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +void g (); + +void +f (int b) +{ + for (int i = 0; i < b; i + b) /* { dg-warning "28:statement with no effect" } */ + g (); + // PARM_DECLs still don't have a location, don't expect an exact location. + for (int i = 0; i < b; b) /* { dg-warning "statement with no effect" } */ + g (); + for (int i = 0; i < b; !i) /* { dg-warning "26:statement with no effect" } */ + g (); + for (!b;;) /* { dg-warning "8:statement with no effect" } */ + g (); + for (;; b * 2) /* { dg-warning "13:statement with no effect" } */ + g (); + ({ + b / 5; /* { dg-warning "8:statement with no effect" } */ + b ^ 5; + }); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64663.c b/SingleSource/Regression/C/gcc-dg/pr64663.c new file mode 100644 index 0000000000..9a0bf0d233 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64663.c @@ -0,0 +1,17 @@ +/* PR debug/64663 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -w" } */ + +void +foo (void) +{ + int a[9]; + a[-8] = 0; +} + +void +bar (void) +{ + int a[9]; + a[-9] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64709.c b/SingleSource/Regression/C/gcc-dg/pr64709.c new file mode 100644 index 0000000000..337e3db3e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64709.c @@ -0,0 +1,10 @@ +/* PR c/64709 */ +/* { dg-do compile } */ +/* { dg-options "-Wmissing-field-initializers" } */ + +struct S { int a, b; }; +void +foo (void) +{ + struct S s[] = { { 1, 2 }, { 0 } }; /* { dg-bogus "missing initializer for field" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64715-1.c b/SingleSource/Regression/C/gcc-dg/pr64715-1.c new file mode 100644 index 0000000000..f2c1bd0f97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64715-1.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/64715 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +extern inline __attribute__ ((always_inline, gnu_inline, artificial, nothrow, leaf)) char * +strcpy (char *__restrict dest, const char *__restrict src) +{ + return __builtin___strcpy_chk (dest, src, __builtin_object_size (dest, 2 > 1)); +} + +const char *str1 = "JIHGFEDCBA"; +void bar (char *); + +void +foo () +{ + struct A { char buf1[9]; char buf2[1]; } a; + strcpy (a.buf1 + (0 + 4), str1 + 5); + bar ((char *) &a); +} + +/* { dg-final { scan-tree-dump "__builtin___strcpy_chk\[^;\n\r\]*, 5\\\);" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr64715-2.c b/SingleSource/Regression/C/gcc-dg/pr64715-2.c new file mode 100644 index 0000000000..5c799123f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64715-2.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/64715 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void bar (char *, int); + +void +foo (int x) +{ + char p[16], *q; + q = p; + if (x) + q = p + 3; + __builtin___strcpy_chk (q, "abcdefghijkl", __builtin_object_size (q, 1)); + bar (p, x); +} + +/* { dg-final { scan-tree-dump "__builtin_memcpy \\\(\[^;\n\r\]*, \"abcdefghijkl\", 13\\\);" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr64766.c b/SingleSource/Regression/C/gcc-dg/pr64766.c new file mode 100644 index 0000000000..bf6fb2d590 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64766.c @@ -0,0 +1,9 @@ +/* PR c/64766 */ +/* { dg-do compile } */ + +void +foo () +{ +} + +void foo () = 0; /* { dg-error "is initialized like a variable|invalid initializer" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr64778.c b/SingleSource/Regression/C/gcc-dg/pr64778.c new file mode 100644 index 0000000000..71a2607e79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64778.c @@ -0,0 +1,10 @@ +/* PR c/64778 */ +/* { dg-do compile } */ + +int +foo (int p) +{ + int a; + a ^= foo (,); /* { dg-error "expected expression before|too many arguments" } */ + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64807.c b/SingleSource/Regression/C/gcc-dg/pr64807.c new file mode 100644 index 0000000000..e1bd604be0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64807.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/64807 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2" } */ + +__uint128_t +foo (void) +{ + __uint128_t a = -1; + __uint128_t b = -1; + return a / b; +} + +int +main () +{ + if (foo () != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64817-1.c b/SingleSource/Regression/C/gcc-dg/pr64817-1.c new file mode 100644 index 0000000000..9d016da811 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64817-1.c @@ -0,0 +1,20 @@ +/* PR debug/64817 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -g" } */ + +int a, b, d; + +void +foo (void) +{ + for (b = 0; b < 9; b++) + { + int e; + for (d = 0; d < 5; d++) + { + a &= 231; + a ^= 14; + } + e = (a ^= 1) < 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64817-2.c b/SingleSource/Regression/C/gcc-dg/pr64817-2.c new file mode 100644 index 0000000000..89532a95a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64817-2.c @@ -0,0 +1,13 @@ +/* PR debug/64817 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -g" } */ + +int a; + +void +foo (void) +{ + int e; + a = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((a & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) ^ 1; + e = (a < 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64817-3.c b/SingleSource/Regression/C/gcc-dg/pr64817-3.c new file mode 100644 index 0000000000..3fe0117082 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64817-3.c @@ -0,0 +1,13 @@ +/* PR debug/64817 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -g" } */ + +int a; + +void +foo (void) +{ + int e; + a = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((a & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) & 231) ^ 14) ^ 1; + e = (a > 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64856.c b/SingleSource/Regression/C/gcc-dg/pr64856.c new file mode 100644 index 0000000000..c21d95a780 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64856.c @@ -0,0 +1,13 @@ +/* PR c/64856 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct A { + unsigned long b; +}; + +struct B { + struct A c[5]; +}; + +struct B d = { .c = { [0 ... 4] = (struct A){ .b = 2 } } }; diff --git a/SingleSource/Regression/C/gcc-dg/pr64935-1.c b/SingleSource/Regression/C/gcc-dg/pr64935-1.c new file mode 100644 index 0000000000..0fc6b58cae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64935-1.c @@ -0,0 +1,54 @@ +/* PR rtl-optimization/64935 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89 -Wno-shift-count-overflow -O2 -fcompare-debug" } */ + +int a[] = {}, b[] = {}, c[] = {}, d[] = {}, e[] = {}, f[] = {}, h[] = {}; +int g[] = { 0 }; +int i, l, s, w, x, y, z, t2, t3, t5; +unsigned long j, m, o, t4; +long k, n, p, q, r, t, u, v, t1; +fn1 () +{ + int t6; + for (; i; i++) + { + t5 = a[q] ^ b[p >> 1] ^ c[o >> 1 & 1] ^ d[n >> 1 & 1] ^ e[m >> 1 & 1] + ^ f[l >> 1 & 1] ^ g[0] ^ h[j & 1]; + t4 = a[j] ^ b[q >> 1] ^ c[p] ^ d[o] ^ e[n] ^ f[m] ^ g[l >> 8] ^ h[k]; + t3 = a[k >> 1] ^ b[j & 5] ^ d[p >> 32] ^ e[o >> 4] ^ f[n >> 6] + ^ g[m >> 8] ^ h[l]; + t2 = a[l >> 6] ^ b[k & 1] ^ c[j >> 1] ^ d[q >> 32] ^ e[p >> 4] + ^ f[o >> 6] ^ g[n >> 8] ^ h[m & 1]; + t1 = a[m >> 6] ^ b[l & 1] ^ c[k & 15] ^ d[j >> 2] ^ e[q >> 4] ^ f[p >> 6] + ^ g[o >> 8] ^ h[n & 1]; + z = a[n >> 56] ^ b[m & 15] ^ c[l & 15] ^ d[k >> 2] ^ e[j >> 4] + ^ f[q >> 6] ^ g[p >> 8] ^ h[o & 1]; + y = a[o >> 56] ^ b[n & 15] ^ c[m >> 40] ^ d[l >> 2] ^ e[k >> 4] + ^ f[j >> 6] ^ g[q >> 8] ^ h[p & 1]; + x = a[p >> 56] ^ b[o & 15] ^ c[n >> 40] ^ d[m >> 2] ^ e[l >> 4] + ^ f[k >> 6] ^ g[j >> 8] ^ h[q & 1]; + q = j = t4; + k = t3; + l = t2; + m = t1; + n = z; + o = y; + p = a[t6] ^ b[0] ^ c[w] ^ d[v] ^ e[u] ^ f[t] ^ g[s] ^ h[r]; + t4 = a[r >> 1] ^ b[t6 & 1] ^ d[w >> 1] ^ e[v >> 1] ^ f[u >> 1] + ^ g[t >> 1] ^ h[s]; + t3 = a[s >> 6] ^ b[r & 1] ^ c[t6 & 5] ^ d[0] ^ e[w >> 4] ^ f[v >> 6] + ^ g[u >> 8] ^ h[t & 1]; + t2 = a[t >> 6] ^ b[s] ^ c[r & 15] ^ d[t6 >> 1] ^ e[0] ^ f[w >> 6] + ^ g[v >> 8] ^ h[u & 1]; + t1 = a[u >> 6] ^ b[t & 15] ^ c[s & 5] ^ d[r >> 32] ^ e[t6 >> 4] + ^ g[w >> 8] ^ h[v & 1]; + z = a[v >> 56] ^ b[u >> 48 & 1] ^ c[t >> 40 & 1] ^ d[s] ^ e[r >> 1 & 1] + ^ f[t6 >> 1 & 1] ^ g[0] ^ h[w & 1] ^ z; + t6 = t5; + r = t4; + s = 0; + t = u = t1; + v = z; + w = y; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64935-2.c b/SingleSource/Regression/C/gcc-dg/pr64935-2.c new file mode 100644 index 0000000000..5d7a6b8c6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64935-2.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/64935 */ +/* { dg-do compile } */ +/* { dg-options "-O -fschedule-insns --param=max-sched-ready-insns=1 -fcompare-debug" } */ +/* { dg-require-effective-target scheduling } */ + +void +foo (int *data, unsigned len, const int qlp_coeff[], + unsigned order, int lp, int residual[], int i) +{ + int sum; + sum = 0; + sum += qlp_coeff[1] * data[i - 2]; + sum += qlp_coeff[0] * data[i - 1]; + residual[i] = data[i] - (sum >> lp); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr64992.c b/SingleSource/Regression/C/gcc-dg/pr64992.c new file mode 100644 index 0000000000..43fbcf7ac5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr64992.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +_Bool foo(_Bool x) { return (x << 2) != 0; } +_Bool bar(_Bool x) { return (x << 2) == 0; } + +/* { dg-final { scan-tree-dump-not " << " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr65050.c b/SingleSource/Regression/C/gcc-dg/pr65050.c new file mode 100644 index 0000000000..e29559d3e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65050.c @@ -0,0 +1,23 @@ +/* PR c/65050 */ +/* { dg-do compile } */ + +typedef int A[]; +struct S { int i; A a[5]; } s; /* { dg-error "array type has incomplete element type 'A' {aka 'int\\\[\\\]'}" } */ +extern void foo (int p[2][]); /* { dg-error "array type has incomplete element type .int\\\[\\\]." } */ +extern void bar (A p[2]); /* { dg-error "array type has incomplete element type 'A' {aka 'int\\\[\\\]'}" } */ + +void +foo (int p[2][]) /* { dg-error "array type has incomplete element type .int\\\[\\\]." } */ +{ +} + +void +bar (A p[2]) /* { dg-error "array type has incomplete element type 'A' {aka 'int\\\[\\\]'}" } */ +{ +} + +struct T; +struct T t[5]; /* { dg-error "array type has incomplete element type .struct T." } */ +struct U u[] = { { "abc" } }; /* { dg-error "array type has incomplete element type .struct U." } */ +typedef struct T TT; +TT tt[5]; /* { dg-error "array type has incomplete element type 'TT' {aka 'struct T'}" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr65063.c b/SingleSource/Regression/C/gcc-dg/pr65063.c new file mode 100644 index 0000000000..bcbdbf098d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65063.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-tree-loop-ivcanon -fno-tree-vectorize" } */ + +static int in[8][4]; +static int out[4]; +static const int check_result[] = {0, 16, 256, 4096}; + +static inline void foo () +{ + int sum; + int i, j, k; + for (k = 0; k < 4; k++) + { + sum = 1; + for (j = 0; j < 4; j++) + for (i = 0; i < 4; i++) + sum *= in[i + k][j]; + out[k] = sum; + } +} + +int main () +{ + int i, j, k; + for (i = 0; i < 8; i++) + for (j = 0; j < 4; j++) + in[i][j] = (i + 2) / 3; + foo (); + for (k = 0; k < 4; k++) + if (out[k] != check_result[k]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65066.c b/SingleSource/Regression/C/gcc-dg/pr65066.c new file mode 100644 index 0000000000..291e97a8d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65066.c @@ -0,0 +1,12 @@ +/* PR c/65066 */ +/* { dg-do compile } */ +/* { dg-options "-Wformat -Wformat-signedness" } */ + +extern int sscanf (const char *restrict, const char *restrict, ...); +int *a; + +void +foo () +{ + sscanf (0, "0x%x #", a); /* { dg-warning "expects argument of type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65228.c b/SingleSource/Regression/C/gcc-dg/pr65228.c new file mode 100644 index 0000000000..fd8323876c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65228.c @@ -0,0 +1,11 @@ +/* PR c/65228 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +__auto_type a = b; /* { dg-error "undeclared" } */ + +void +f (void) +{ + __auto_type c = d; /* { dg-error "undeclared" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65321.c b/SingleSource/Regression/C/gcc-dg/pr65321.c new file mode 100644 index 0000000000..294487cab1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65321.c @@ -0,0 +1,31 @@ +/* PR rtl-optimization/65321 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -g" } */ + +int a, b, c, d, e; + +int +foo (void) +{ + int h; + char i; + for (; c > 0;) + { + for (d = 0; d < 2; d++) + { + i = 1 << d; + if (i - a) + { + e = b = 0; + for (; c; c--) + d = 127; + } + } + h = ~d; + if (h > c) + for (;;) + ; + return 0; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65345-1.c b/SingleSource/Regression/C/gcc-dg/pr65345-1.c new file mode 100644 index 0000000000..d11947b459 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65345-1.c @@ -0,0 +1,35 @@ +/* PR c/65345 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +_Atomic int i = 3; + +int a1 = sizeof (i + 1); +int a2 = sizeof (i = 0); +int a3 = sizeof (i++); +int a4 = sizeof (i--); +int a5 = sizeof (-i); + +int b1 = _Alignof (i + 1); +int b2 = _Alignof (i = 0); +int b3 = _Alignof (i++); +int b4 = _Alignof (i--); +int b5 = _Alignof (-i); + +int c1 = i; /* { dg-error "initializer element is not constant" } */ +int c2 = (i ? 1 : 2); /* { dg-error "initializer element is not constant" } */ +int c3[i]; /* { dg-error "variably modified" } */ +int c4 = 0 || i; /* { dg-error "initializer element is not constant" } */ +int c5 = (i += 10); /* { dg-error "initializer element is not constant" } */ + +_Static_assert (_Generic (i, int: 1, default: 0) == 1, "1"); +_Static_assert (_Generic (i + 1, int: 1, default: 0) == 1, "2"); +_Static_assert (_Generic (i = 0, int: 1, default: 0) == 1, "3"); +_Static_assert (_Generic (i++, int: 1, default: 0) == 1, "4"); +_Static_assert (_Generic (i--, int: 1, default: 0) == 1, "5"); + +void fn1 (int a[i + 1]); +void fn2 (int a[i = 0]); +void fn3 (int a[i++]); +void fn4 (int a[i--]); +void fn5 (int a[-i]); diff --git a/SingleSource/Regression/C/gcc-dg/pr65345-2.c b/SingleSource/Regression/C/gcc-dg/pr65345-2.c new file mode 100644 index 0000000000..c9adffb5f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65345-2.c @@ -0,0 +1,60 @@ +/* PR c/65345 */ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_long } */ +/* { dg-options "" } */ + +#define CHECK(X) if (!(X)) __builtin_abort () + +_Atomic int i = 5; +_Atomic int j = 2; + +void +fn1 (int a[i = 0]) +{ +} + +void +fn2 (int a[i += 2]) +{ +} + +void +fn3 (int a[++i]) +{ +} + +void +fn4 (int a[++i]) +{ +} + +void +fn5 (int a[++i][j = 10]) +{ +} + +void +fn6 (int a[i = 7][j--]) +{ +} + +int +main () +{ + int a[10]; + int aa[10][10]; + fn1 (a); + CHECK (i == 0); + fn2 (a); + CHECK (i == 2); + fn3 (a); + CHECK (i == 3); + fn4 (a); + CHECK (i == 4); + fn5 (aa); + CHECK (i == 5); + CHECK (j == 10); + fn6 (aa); + CHECK (i == 7); + CHECK (j == 9); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65345-3.c b/SingleSource/Regression/C/gcc-dg/pr65345-3.c new file mode 100644 index 0000000000..cda9364628 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65345-3.c @@ -0,0 +1,35 @@ +/* PR c/65345 */ +/* { dg-options "" } */ + +_Atomic float i = 3.0f; + +float a1 = sizeof (i + 1.2); +float a2 = sizeof (i = 0); +float a3 = sizeof (i++); +float a4 = sizeof (i--); +float a5 = sizeof (-i); + +float b1 = _Alignof (i + 1); +float b2 = _Alignof (i = 0); +float b3 = _Alignof (i++); +float b4 = _Alignof (i--); +float b5 = _Alignof (-i); + +float c1 = i; /* { dg-error "initializer element is not constant" } */ +float c2 = (i ? 1 : 2); /* { dg-error "initializer element is not constant" } */ +float c3[(int) i]; /* { dg-error "variably modified" } */ +float c4 = 0 || i; /* { dg-error "initializer element is not constant" } */ +float c5 = (i += 10); /* { dg-error "initializer element is not constant" } */ + +_Static_assert (_Generic (i, float: 1, default: 0) == 1, "1"); +_Static_assert (_Generic (i + 1, float: 1, default: 0) == 1, "2"); +_Static_assert (_Generic (i = 0, float: 1, default: 0) == 1, "3"); +_Static_assert (_Generic (i++, float: 1, default: 0) == 1, "4"); +_Static_assert (_Generic (i--, float: 1, default: 0) == 1, "5"); + +_Atomic int sz = 2; +void fn1 (float a[sz + 1]); +void fn2 (float a[sz = 0]); +void fn3 (float a[sz++]); +void fn4 (float a[sz--]); +void fn5 (float a[-sz]); diff --git a/SingleSource/Regression/C/gcc-dg/pr65358.c b/SingleSource/Regression/C/gcc-dg/pr65358.c new file mode 100644 index 0000000000..ba89fd4818 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65358.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +struct pack +{ + int fine; + int victim; + int killer; +}; + +int __attribute__ ((__noinline__, __noclone__)) +bar (int a, int b, struct pack p) +{ + if (a != 20 || b != 30) + __builtin_abort (); + if (p.fine != 40 || p.victim != 50 || p.killer != 60) + __builtin_abort (); + return 0; +} + +int __attribute__ ((__noinline__, __noclone__)) +foo (int arg1, int arg2, int arg3, struct pack p) +{ + return bar (arg2, arg3, p); +} + +int main (void) +{ + struct pack p = { 40, 50, 60 }; + + (void) foo (10, 20, 30, p); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65408.c b/SingleSource/Regression/C/gcc-dg/pr65408.c new file mode 100644 index 0000000000..8eec1d2dc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65408.c @@ -0,0 +1,112 @@ +/* PR middle-end/36043 target/58744 target/65408 */ +/* { dg-do run { target mmap } } */ +/* { dg-options "-O2" } */ + +#include +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_ANON +#define MAP_ANON 0 +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +typedef struct +{ + unsigned char r; + unsigned char g; + unsigned char b; +} __attribute__((packed)) pr58744; + +typedef struct +{ + unsigned short r; + unsigned short g; + unsigned short b; +} pr36043; + +typedef struct +{ + int r; + int g; + int b; +} pr65408; + +__attribute__ ((noinline, noclone)) +void +f1a (pr58744 x) +{ + if (x.r != 1 || x.g != 2 || x.b != 3) + __builtin_abort(); +} + +__attribute__ ((noinline, noclone)) +void +f1 (pr58744 *x) +{ + f1a (*x); +} + +__attribute__ ((noinline, noclone)) +void +f2a (pr36043 x) +{ + if (x.r != 1 || x.g != 2 || x.b != 3) + __builtin_abort(); +} + +__attribute__ ((noinline, noclone)) +void +f2 (pr36043 *x) +{ + f2a (*x); +} + +__attribute__ ((noinline, noclone)) +void +f3a (pr65408 x) +{ + if (x.r != 1 || x.g != 2 || x.b != 3) + __builtin_abort(); +} + +__attribute__ ((noinline, noclone)) +void +f3 (pr65408 *x) +{ + f3a (*x); +} + +int +main () +{ + char *p = mmap ((void *) 0, 131072, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) + return 0; + char *endp = p + 65536; + if (munmap (endp, 65536) < 0) + return 0; + + pr58744 *s1 = (pr58744 *) endp - 1; + s1->r = 1; + s1->g = 2; + s1->b = 3; + f1 (s1); + + pr36043 *s2 = (pr36043 *) endp - 1; + s2->r = 1; + s2->g = 2; + s2->b = 3; + f2 (s2); + + pr65408 *s3 = (pr65408 *) endp - 1; + s3->r = 1; + s3->g = 2; + s3->b = 3; + f3 (s3); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65521.c b/SingleSource/Regression/C/gcc-dg/pr65521.c new file mode 100644 index 0000000000..97879e2e13 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65521.c @@ -0,0 +1,39 @@ +/* PR ipa/65521 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +struct S { int s; }; +int f6 (void *, unsigned long); +int f7 (int, int *, unsigned long); +int f8 (void); +int f9 (void (*) (void)); + +int +f1 (void *p) +{ + return f6 (p, 256UL); +} + +int +f2 (void *p) +{ + return f6 (p, 256UL); +} + +int +f3 (struct S *x) +{ + return f7 (f8 (), &x->s, 16UL); +} + +int +f4 (struct S *x) +{ + return f7 (f8 (), &x->s, 16UL); +} + +void +f5 (void) +{ + f9 (f5); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65533.c b/SingleSource/Regression/C/gcc-dg/pr65533.c new file mode 100644 index 0000000000..49edf15c00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65533.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/65533 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -w" } */ + +struct A { int a[2]; }; +struct B { double b[2]; }; +struct C { double c[4][1]; }; + +static inline void +bar (struct B *x, double y, double z) +{ + x->b[0] = y; + x->b[1] = z; +} + +void baz (struct B *); + +void +foo (struct C *x, struct A *y) +{ + struct B d; + bar (&d, x->c[1][0] * y->a[0] + x->c[0][1] * y->a[1] + x->c[0][0] * x->c[0][1], + x->c[0][0] * y->a[0] + x->c[0][1] * y->a[1] + x->c[0][1] * y->a[0] + x->c[0][0]); + baz (&d); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65658.c b/SingleSource/Regression/C/gcc-dg/pr65658.c new file mode 100644 index 0000000000..4847dc2d5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65658.c @@ -0,0 +1,112 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2 -Wno-implicit" } */ +/* { dg-require-effective-target ptr32plus } */ + +extern int optind; +struct undefinfo +{ + unsigned long l1; + unsigned long l2; +}; +struct undeffoo +{ + char a[64]; + long b[4]; + int c[33]; +}; +struct problem +{ + __UINTPTR_TYPE__ l1; + __UINTPTR_TYPE__ l2; + __UINTPTR_TYPE__ l3; + __UINTPTR_TYPE__ l4; +}; +static unsigned int undef1, undef2, undef3, undef4, undef5, undef6; +static void *undefvp1; +extern struct undefinfo undefinfo; +static int +undefinit1 (void) +{ + struct undeffoo foo; + int i; + for (i = 0; i < 2000; i++) + { + undef6++; + external_function5 (((void *) 0), 0, (void *) &foo); + } +} + +static int +undefinit2 (void *problemp, __UINTPTR_TYPE__ problem) +{ + int ret, u; + if (undefinit1 ()) + return 1; + if (fn10 ()) + return 1; + for (u = 0; u < undef6; u++) + { + ret = external_function1 (3 + u * 10, 10); + if (ret) + return ret; + external_function6 (0, 0, 0, problemp + problem); + return 1; + } +} + +static int +fn6 (struct undefinfo *uip, struct problem *problem) +{ + unsigned long amt; + if (external_function3 (((void *) 0), ((void *) 0), &amt, 0, 0)) + return 1; + problem->l1 = (__UINTPTR_TYPE__) undefvp1; + problem->l4 = uip->l1; + problem->l3 = uip->l2; + return 0; +} + +static int +setup (void) +{ + struct problem problem; + if (fn6 (&undefinfo, &problem)) + return 1; + if (fn2 ()) + return 1; + if (fn4 (101)) + return 1; + if (undefinit2 ((void *) problem.l1, problem.l3 * 4)) /* { dg-bogus "problem.l3" "uninitialized variable warning" } */ + return 1; +} + +int +main (int argc, char **argv) +{ + int optc; + if (external_function (1)) + return 1; + if (external_function (1)) + return 1; + if (external_function (1)) + return 1; + while ((optc = + getopt_long (argc, argv, ((void *) 0), ((void *) 0), + ((void *) 0))) != -1) + { + switch (optc) + { + case 0: + break; + case 'F': + external_function (1); + default: + return 1; + } + } + if ((optind != 99)) + { + return 1; + } + setup (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65779.c b/SingleSource/Regression/C/gcc-dg/pr65779.c new file mode 100644 index 0000000000..7d5c522d04 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65779.c @@ -0,0 +1,42 @@ +/* PR debug/65779 */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +unsigned long +foo (unsigned long x, unsigned char *y, unsigned int z) +{ + unsigned long a = x & 0xffff; + unsigned long b = (x >> 16) & 0xffff; + int k; + if (y == 0) return 1L; + while (z > 0) + { + k = z < 5552 ? z : 5552; + z -= k; + while (k >= 16) + { + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + a += *y++; b += a; + k -= 16; + } + if (k != 0) + do { a += *y++; b += a; } while (--k); + a %= 65521L; + b %= 65521L; + } + return (b << 16) | a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65780-1.c b/SingleSource/Regression/C/gcc-dg/pr65780-1.c new file mode 100644 index 0000000000..5e3226e54f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65780-1.c @@ -0,0 +1,12 @@ +/* PR target/65780 */ +/* { dg-do link { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2" } */ + +int optopt; + +int +main () +{ + optopt = 4; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65780-2.c b/SingleSource/Regression/C/gcc-dg/pr65780-2.c new file mode 100644 index 0000000000..932cbe1c4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65780-2.c @@ -0,0 +1,13 @@ +/* PR target/65780 */ +/* { dg-do link { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-require-effective-target pie } */ +/* { dg-options "-O2 -fpie" } */ + +int optopt; + +int +main () +{ + optopt = 4; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65802.c b/SingleSource/Regression/C/gcc-dg/pr65802.c new file mode 100644 index 0000000000..0721ca81bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65802.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -fexceptions" } */ +/* { dg-require-effective-target exceptions } */ + +#include + +struct S +{ + int (*m_fn1) (void); +} a; + +void +fn1 (int d, ...) +{ + va_list c; + va_start (c, d); + + { + int *d = va_arg (c, int *); + + int **e = &d; + + a.m_fn1 (); + } + + a.m_fn1 (); + + va_end (c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65901.c b/SingleSource/Regression/C/gcc-dg/pr65901.c new file mode 100644 index 0000000000..b40eea3339 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65901.c @@ -0,0 +1,16 @@ +/* PR c/65901 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S; +enum E; +union U; + +void +foo (__builtin_va_list ap) +{ + __builtin_va_arg (ap, void); /* { dg-error "second argument to .va_arg. is of incomplete type .void." } */ + __builtin_va_arg (ap, struct S); /* { dg-error "second argument to .va_arg. is of incomplete type .struct S." } */ + __builtin_va_arg (ap, enum E); /* { dg-error "second argument to .va_arg. is of incomplete type .enum E." } */ + __builtin_va_arg (ap, union U); /* { dg-error "second argument to .va_arg. is of incomplete type .union U." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr65980.c b/SingleSource/Regression/C/gcc-dg/pr65980.c new file mode 100644 index 0000000000..5139ae3614 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr65980.c @@ -0,0 +1,30 @@ +/* PR rtl-optimization/65980 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug" } */ + +typedef struct { int b; } A; +void (*a) (int); +int b; + +int +foo (A *v) +{ + asm goto ("" : : "m" (v->b) : : l); + return 0; +l: + return 1; +} + +int +bar (void) +{ + if (b) + { + if (foo (0) && a) + a (0); + return 0; + } + if (foo (0) && a) + a (0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr66066-1.c b/SingleSource/Regression/C/gcc-dg/pr66066-1.c new file mode 100644 index 0000000000..7a1d342c80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66066-1.c @@ -0,0 +1,37 @@ +/* PR c/66066 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-div-by-zero" } */ + +/* Accept these unless -pedantic-errors/-Werror. */ +int a1 = -1 << 0; +int a2 = -1 << 0 | 0; +int a3 = -1 << 0 & 1; +int a4 = -1 << 2 ^ 1; +int a5 = 4 & -1 << 2; +int a6 = (-1 << 2) ^ (1 >> 1); +int a7 = 0 || (-1 << 1); +int a8 = 0 ? 2 : (-1 << 1); +int a9 = 1 && -1 << 0; +int a10 = !(-1 << 0); + +/* Don't accept these. */ +int b1 = 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b2 = 1 / (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b3 = 0 ? 2 : 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b4 = 0 || 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b5 = 0 * (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b6 = 1 * (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b7 = (1 / 0) * 0; /* { dg-error "initializer element is not constant" } */ +int b8 = (1 / 0) * 1; /* { dg-error "initializer element is not constant" } */ +int b9 = 1 && 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b10 = !(1 / 0); /* { dg-error "initializer element is not constant" } */ +int c1 = 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c2 = 1 / (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c3 = 0 ? 2 : 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c4 = 0 || 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c5 = 0 * (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c6 = 1 * (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c7 = (1 % 0) * 0; /* { dg-error "initializer element is not constant" } */ +int c8 = (1 % 0) * 1; /* { dg-error "initializer element is not constant" } */ +int c9 = 1 && 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c10 = !(1 % 0); /* { dg-error "initializer element is not constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr66066-2.c b/SingleSource/Regression/C/gcc-dg/pr66066-2.c new file mode 100644 index 0000000000..848fe854bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66066-2.c @@ -0,0 +1,37 @@ +/* PR c/66066 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-div-by-zero -Wpedantic" } */ + +/* Accept these unless -pedantic-errors/-Werror. */ +int a1 = -1 << 0; /* { dg-warning "initializer element is not a constant expression" } */ +int a2 = -1 << 0 | 0; /* { dg-warning "initializer element is not a constant expression" } */ +int a3 = -1 << 0 & 1; /* { dg-warning "initializer element is not a constant expression" } */ +int a4 = -1 << 2 ^ 1; /* { dg-warning "initializer element is not a constant expression" } */ +int a5 = 4 & -1 << 2; /* { dg-warning "initializer element is not a constant expression" } */ +int a6 = (-1 << 2) ^ (1 >> 1); /* { dg-warning "initializer element is not a constant expression" } */ +int a7 = 0 || (-1 << 1); /* { dg-warning "initializer element is not a constant expression" } */ +int a8 = 0 ? 2 : (-1 << 1); /* { dg-warning "initializer element is not a constant expression" } */ +int a9 = 1 && -1 << 0; /* { dg-warning "initializer element is not a constant expression" } */ +int a10 = !(-1 << 0); /* { dg-warning "initializer element is not a constant expression" } */ + +/* Don't accept these. */ +int b1 = 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b2 = 1 / (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b3 = 0 ? 2 : 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b4 = 0 || 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b5 = 0 * (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b6 = 1 * (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b7 = (1 / 0) * 0; /* { dg-error "initializer element is not constant" } */ +int b8 = (1 / 0) * 1; /* { dg-error "initializer element is not constant" } */ +int b9 = 1 && 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b10 = !(1 / 0); /* { dg-error "initializer element is not constant" } */ +int c1 = 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c2 = 1 / (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c3 = 0 ? 2 : 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c4 = 0 || 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c5 = 0 * (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c6 = 1 * (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c7 = (1 % 0) * 0; /* { dg-error "initializer element is not constant" } */ +int c8 = (1 % 0) * 1; /* { dg-error "initializer element is not constant" } */ +int c9 = 1 && 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c10 = !(1 % 0); /* { dg-error "initializer element is not constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr66066-3.c b/SingleSource/Regression/C/gcc-dg/pr66066-3.c new file mode 100644 index 0000000000..99ffec6255 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66066-3.c @@ -0,0 +1,37 @@ +/* PR c/66066 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-div-by-zero -pedantic-errors" } */ + +/* Accept these unless -pedantic-errors/-Werror. */ +int a1 = -1 << 0; /* { dg-error "initializer element is not a constant expression" } */ +int a2 = -1 << 0 | 0; /* { dg-error "initializer element is not a constant expression" } */ +int a3 = -1 << 0 & 1; /* { dg-error "initializer element is not a constant expression" } */ +int a4 = -1 << 2 ^ 1; /* { dg-error "initializer element is not a constant expression" } */ +int a5 = 4 & -1 << 2; /* { dg-error "initializer element is not a constant expression" } */ +int a6 = (-1 << 2) ^ (1 >> 1); /* { dg-error "initializer element is not a constant expression" } */ +int a7 = 0 || (-1 << 1); /* { dg-error "initializer element is not a constant expression" } */ +int a8 = 0 ? 2 : (-1 << 1); /* { dg-error "initializer element is not a constant expression" } */ +int a9 = 1 && -1 << 0; /* { dg-error "initializer element is not a constant expression" } */ +int a10 = !(-1 << 0); /* { dg-error "initializer element is not a constant expression" } */ + +/* Don't accept these. */ +int b1 = 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b2 = 1 / (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b3 = 0 ? 2 : 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b4 = 0 || 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b5 = 0 * (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b6 = 1 * (1 / 0); /* { dg-error "initializer element is not constant" } */ +int b7 = (1 / 0) * 0; /* { dg-error "initializer element is not constant" } */ +int b8 = (1 / 0) * 1; /* { dg-error "initializer element is not constant" } */ +int b9 = 1 && 1 / 0; /* { dg-error "initializer element is not constant" } */ +int b10 = !(1 / 0); /* { dg-error "initializer element is not constant" } */ +int c1 = 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c2 = 1 / (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c3 = 0 ? 2 : 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c4 = 0 || 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c5 = 0 * (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c6 = 1 * (1 % 0); /* { dg-error "initializer element is not constant" } */ +int c7 = (1 % 0) * 0; /* { dg-error "initializer element is not constant" } */ +int c8 = (1 % 0) * 1; /* { dg-error "initializer element is not constant" } */ +int c9 = 1 && 1 % 0; /* { dg-error "initializer element is not constant" } */ +int c10 = !(1 % 0); /* { dg-error "initializer element is not constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr66187-1.c b/SingleSource/Regression/C/gcc-dg/pr66187-1.c new file mode 100644 index 0000000000..62aea6978d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66187-1.c @@ -0,0 +1,97 @@ +/* PR tree-optimization/66187 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-wrapv" } */ + +__attribute__((noinline, noclone)) int +f0 (unsigned char x, unsigned char y) +{ + return (x + y) & 0x2ff; +} + +__attribute__((noinline, noclone)) int +f1 (unsigned char x, unsigned char y) +{ + return (x - y) & 0x2ff; +} + +__attribute__((noinline, noclone)) int +f2 (signed char x, signed char y) +{ + return (x + y) & -4; +} + +__attribute__((noinline, noclone)) int +f3 (signed char x, signed char y) +{ + return (x + y) & 0xf8; +} + +__attribute__((noinline, noclone)) int +f4 (signed char x, signed char y) +{ + return (x + y) & 0x78; +} + +__attribute__((noinline, noclone)) int +f5 (unsigned char x, unsigned char y) +{ + int a = x; + int b = y; + int c = a + b; + return c & 0x2ff; +} + +__attribute__((noinline, noclone)) int +f6 (unsigned char x, unsigned char y) +{ + int a = x; + int b = y; + int c = a - b; + return c & 0x2ff; +} + +__attribute__((noinline, noclone)) int +f7 (signed char x, signed char y) +{ + int a = x; + int b = y; + int c = a + b; + return c & -4; +} + +__attribute__((noinline, noclone)) int +f8 (signed char x, signed char y) +{ + int a = x; + int b = y; + int c = a + b; + return c & 0xf8; +} + +__attribute__((noinline, noclone)) int +f9 (signed char x, signed char y) +{ + int a = x; + int b = y; + int c = a + b; + return c & 0x78; +} + +int +main () +{ + if (__SCHAR_MAX__ != 127 || sizeof (int) != 4) + return 0; + if (f0 (0xff, 0xff) != 0xfe + || f1 (0, 1) != 0x2ff + || f2 (-2, 1) != -4 + || f3 (-2, 1) != 0xf8 + || f4 (-2, 1) != 0x78 + || f5 (0xff, 0xff) != 0xfe + || f6 (0, 1) != 0x2ff + || f7 (-2, 1) != -4 + || f8 (-2, 1) != 0xf8 + || f9 (-2, 1) != 0x78) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr66187-2.c b/SingleSource/Regression/C/gcc-dg/pr66187-2.c new file mode 100644 index 0000000000..580b233288 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66187-2.c @@ -0,0 +1,97 @@ +/* PR tree-optimization/66187 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +__attribute__((noinline, noclone)) int +f0 (unsigned char x, unsigned char y) +{ + return (x + y) & 0x2ff; +} + +__attribute__((noinline, noclone)) int +f1 (unsigned char x, unsigned char y) +{ + return (x - y) & 0x2ff; +} + +__attribute__((noinline, noclone)) int +f2 (signed char x, signed char y) +{ + return (x + y) & -4; +} + +__attribute__((noinline, noclone)) int +f3 (signed char x, signed char y) +{ + return (x + y) & 0xf8; +} + +__attribute__((noinline, noclone)) int +f4 (signed char x, signed char y) +{ + return (x + y) & 0x78; +} + +__attribute__((noinline, noclone)) int +f5 (unsigned char x, unsigned char y) +{ + int a = x; + int b = y; + int c = a + b; + return c & 0x2ff; +} + +__attribute__((noinline, noclone)) int +f6 (unsigned char x, unsigned char y) +{ + int a = x; + int b = y; + int c = a - b; + return c & 0x2ff; +} + +__attribute__((noinline, noclone)) int +f7 (signed char x, signed char y) +{ + int a = x; + int b = y; + int c = a + b; + return c & -4; +} + +__attribute__((noinline, noclone)) int +f8 (signed char x, signed char y) +{ + int a = x; + int b = y; + int c = a + b; + return c & 0xf8; +} + +__attribute__((noinline, noclone)) int +f9 (signed char x, signed char y) +{ + int a = x; + int b = y; + int c = a + b; + return c & 0x78; +} + +int +main () +{ + if (__SCHAR_MAX__ != 127 || sizeof (int) != 4) + return 0; + if (f0 (0xff, 0xff) != 0xfe + || f1 (0, 1) != 0x2ff + || f2 (-2, 1) != -4 + || f3 (-2, 1) != 0xf8 + || f4 (-2, 1) != 0x78 + || f5 (0xff, 0xff) != 0xfe + || f6 (0, 1) != 0x2ff + || f7 (-2, 1) != -4 + || f8 (-2, 1) != 0xf8 + || f9 (-2, 1) != 0x78) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr66299-1.c b/SingleSource/Regression/C/gcc-dg/pr66299-1.c new file mode 100644 index 0000000000..df8476462f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66299-1.c @@ -0,0 +1,93 @@ +/* PR tree-optimization/66299 */ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-original" } */ +/* { dg-require-effective-target int32plus } */ + +void +test1 (int x) +{ + if ((0 << x) != 0 + || (1 << x) != 2 + || (2 << x) != 4 + || (3 << x) != 6 + || (4 << x) != 8 + || (5 << x) != 10 + || (6 << x) != 12 + || (7 << x) != 14 + || (8 << x) != 16 + || (9 << x) != 18 + || (10 << x) != 20) + __builtin_abort (); +} + +void +test2 (int x) +{ + if (!((0 << x) == 0 + && (1 << x) == 4 + && (2 << x) == 8 + && (3 << x) == 12 + && (4 << x) == 16 + && (5 << x) == 20 + && (6 << x) == 24 + && (7 << x) == 28 + && (8 << x) == 32 + && (9 << x) == 36 + && (10 << x) == 40)) + __builtin_abort (); +} + +void +test3 (unsigned int x) +{ + if ((0U << x) != 0U + || (1U << x) != 16U + || (2U << x) != 32U + || (3U << x) != 48U + || (4U << x) != 64U + || (5U << x) != 80U + || (6U << x) != 96U + || (7U << x) != 112U + || (8U << x) != 128U + || (9U << x) != 144U + || (10U << x) != 160U) + __builtin_abort (); +} + +void +test4 (unsigned int x) +{ + if (!((0U << x) == 0U + || (1U << x) == 8U + || (2U << x) == 16U + || (3U << x) == 24U + || (4U << x) == 32U + || (5U << x) == 40U + || (6U << x) == 48U + || (7U << x) == 56U + || (8U << x) == 64U + || (9U << x) == 72U + || (10U << x) == 80U)) + __builtin_abort (); +} + +void +test5 (int x) +{ + if ((0 << x) == 1 + || (0 << x) != 0 + || (0x8001U << x) != 0x20000U) + __builtin_abort (); +} + +int +main (void) +{ + test1 (1); + test2 (2); + test3 (4U); + test4 (3U); + test5 (17); +} + +/* { dg-final { scan-tree-dump-not "<<" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr66299-2.c b/SingleSource/Regression/C/gcc-dg/pr66299-2.c new file mode 100644 index 0000000000..c75c539a41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66299-2.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/66299 */ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-optimized -O" } */ +/* { dg-require-effective-target int32plus } */ + +void +test1 (int x, unsigned u) +{ + if ((1U << x) != 64 + || (2 << x) != u + || (x << x) != 384 + || (3 << x) == 9 + || (x << 14) != 98304U + || (1 << x) == 14 + || (3 << 2) != 12) + __builtin_abort (); +} + +void +test2 (int x) +{ + unsigned int t = ((unsigned int) 1U << x); + if (t != 2U) + __builtin_abort (); +} + +int +main (void) +{ + test1 (6, 128U); + test2 (1); +} + +/* { dg-final { scan-tree-dump-not "<<" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr66299-3.c b/SingleSource/Regression/C/gcc-dg/pr66299-3.c new file mode 100644 index 0000000000..ffee04972a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66299-3.c @@ -0,0 +1,68 @@ +/* PR tree-optimization/66299 */ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-original" } */ + +void __attribute__ ((noinline, noclone)) +test1 (int x) +{ + if ((2 << x) == 1 + || (8 << x) == 1 + || (8 << x) == 2 + || (3072 << x) == 3 + || (294912 << x) == 9 + || (45056 << x) == 11 + || (2176 << x) == 17) + __builtin_abort (); +} + +void __attribute__ ((noinline, noclone)) +test2 (int x) +{ + if ((2 << x) != 1 + && (8 << x) != 1 + && (8 << x) != 2 + && (3072 << x) != 3 + && (294912 << x) != 9 + && (45056 << x) != 11 + && (2176 << x) != 17) + ; + else + __builtin_abort (); +} + +void __attribute__ ((noinline, noclone)) +test3 (int x) +{ + if ((3 << x) == 4 + || (1 << x) == 12 + || (40 << x) == 1024 + || (2 << x) == 84 + || (3 << x) == 16384 + || (10 << x) == 6144) + __builtin_abort (); +} + +void __attribute__ ((noinline, noclone)) +test4 (int x) +{ + if ((3 << x) != 4 + && (1 << x) != 12 + && (40 << x) != 1024 + && (2 << x) != 84 + && (3 << x) != 16384 + && (10 << x) != 6144) + ; + else + __builtin_abort (); +} + +int +main (void) +{ + test1 (0); + test2 (1); + test3 (1); + test4 (2); +} + +/* { dg-final { scan-tree-dump-not "(<<|==|!=)" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr66444.c b/SingleSource/Regression/C/gcc-dg/pr66444.c new file mode 100644 index 0000000000..3f92a5c779 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66444.c @@ -0,0 +1,79 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fipa-ra" } */ + +extern void abort (void); + +#if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__) +#define ADD_SUFFIX(a) a ## ULL +#elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__) +#define ADD_SUFFIX(a) a ## UL +#elif (__SIZEOF_INT__ == __SIZEOF_POINTER__) +#define ADD_SUFFIX(a) a ## U +#else +#error Add target support here +#endif + +#if __SIZEOF_POINTER__ <= 4 +/* Use a 16 bit pointer to have a valid pointer for 16-bit to 31-bit pointer + architectures. Using sizeof, we cannot distinguish between 31-bit and 32-bit + pointer types, so we also handle the 32-bit pointer type case here. */ +#define CONST_PTR ADD_SUFFIX (0x800) +#else +/* For x86_64 -m64, the problem reproduces with this 32-bit CONST_PTR, but not + with a 2-power below it. */ +#define CONST_PTR ADD_SUFFIX (0x80000000) +#endif + +int __attribute__((noinline, noclone)) +bar (void) +{ + return 1; +} + +struct S +{ + unsigned long p, q, r; + void *v; +}; + +struct S *s1; +struct S *s2; + +void __attribute__((noinline, noclone)) +fn2 (struct S *x) +{ + s2 = x; +} + +__attribute__((noinline, noclone)) void * +fn1 (struct S *x) +{ + /* Just a statement to make it a non-const function. */ + s1 = x; + + return (void *)0; +} + +int __attribute__((noinline, noclone)) +baz (void) +{ + struct S *x = (struct S *) CONST_PTR; + + x += bar (); + + fn1 (x); + fn2 (x); + + return 0; +} + +int +main (void) +{ + baz (); + + if (s2 != (((struct S *) CONST_PTR) + 1)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr66552.c b/SingleSource/Regression/C/gcc-dg/pr66552.c new file mode 100644 index 0000000000..7583c9ad25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66552.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-lower" } */ + +unsigned a(unsigned x, int n) +{ + return x >> (n % 32); +} + +unsigned b(unsigned x, int n) +{ + return x << (n % 32); +} + +/* { dg-final { scan-tree-dump-not " % " "lower" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr66618-2.c b/SingleSource/Regression/C/gcc-dg/pr66618-2.c new file mode 100644 index 0000000000..3cb2e44c37 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66618-2.c @@ -0,0 +1,10 @@ +/* PR c/66618 */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +int a = "foo"[2]; +int b = 1["bar"]; +int c = "baz"[__INT_MAX__ * -2]; /* { dg-error "initializer element is not constant" } */ +int d = "str"[3]; /* { dg-warning "integer overflow in expression of type" "" { target *-*-* } .-1 } */ +int e = "str"[4]; /* { dg-error "initializer element is not constant" } */ +int f = "str"[-1]; /* { dg-error "initializer element is not constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr66618.c b/SingleSource/Regression/C/gcc-dg/pr66618.c new file mode 100644 index 0000000000..649d4f652d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66618.c @@ -0,0 +1,11 @@ +/* PR c/66618 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +int +foo (void) +{ + const int a = 0; + static int b = a; /* { dg-bogus "initializer element is not constant" } */ + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr66688.c b/SingleSource/Regression/C/gcc-dg/pr66688.c new file mode 100644 index 0000000000..af6f8443a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66688.c @@ -0,0 +1,39 @@ +/* PR tree-optimization/66688 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-reorder-blocks -fcompare-debug" } */ + +struct fdt_header { unsigned magic; } *a; + +int d; + +int +__fswab32 (int p1) +{ + return __builtin_bswap32 (p1); +} + +void +fdt_set_magic (int p1) +{ + struct fdt_header *b = a; + b->magic = __builtin_constant_p (p1) ? : __fswab32 (p1); +} + +int +_fdt_sw_check_header () +{ + int c = ((struct fdt_header *) 1)->magic; + if (c) + return 1; + return 0; +} + +int +fdt_finish () +{ + if (_fdt_sw_check_header ()) + if (d) + return 0; + fdt_set_magic (0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr66869.c b/SingleSource/Regression/C/gcc-dg/pr66869.c new file mode 100644 index 0000000000..916d141998 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66869.c @@ -0,0 +1,6 @@ +/* PR debug/66869 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused-function" } */ + +static void test (void); /* { dg-warning "'test' declared 'static' but never defined" } */ +int i; diff --git a/SingleSource/Regression/C/gcc-dg/pr66899.c b/SingleSource/Regression/C/gcc-dg/pr66899.c new file mode 100644 index 0000000000..23ecc539c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr66899.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fprofile-arcs" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +struct +{ + int authority; +} * a, *b, c, d; +int e, f; +static int +fn1 () +{ + if (a) + goto verified; + if (b) + goto matched; + return -126; +matched: + e = 0; +verified: + if (b) + for (; &c != b; c = d) + ; + return 0; +} + +int +fn2 () +{ + for (;;) + { + f = fn1 (); + switch (f) + { + case -126: + continue; + default: + return 0; + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr67028.c b/SingleSource/Regression/C/gcc-dg/pr67028.c new file mode 100644 index 0000000000..b42fb8110e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67028.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +short c = 0; + +int __attribute__ ((noinline)) f(void) +{ + int d = 5; + signed char e = (c != 1) * -2; + int a = (unsigned short)e > d; + + return a; +} + +int main(void) +{ + if (!f()) + __builtin_abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67029.c b/SingleSource/Regression/C/gcc-dg/pr67029.c new file mode 100644 index 0000000000..f0023e524e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67029.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target { int128 && scheduling } } } */ +/* { dg-options "-O2 -fschedule-insns" } */ +/* { dg-additional-options "-fstack-protector" { target fstack_protector } } */ + +extern void fn2 (char *); +__int128 a, b; +int +fn1 (void) +{ + char e[32]; + fn2 (e); + b = 9 * (a >> 1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67043.c b/SingleSource/Regression/C/gcc-dg/pr67043.c new file mode 100644 index 0000000000..36aa68673f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67043.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fcompare-debug -w" } */ + +extern void rt_mutex_owner (void); +extern void rt_mutex_deadlock_account_lock (int); +extern void signal_pending (void); +__typeof__ (int *) a; +int b; + +int +try_to_take_rt_mutex (int p1) { + rt_mutex_owner (); + if (b) + return 0; + rt_mutex_deadlock_account_lock (p1); + return 1; +} + +void +__rt_mutex_slowlock (int p1) { + int c; + for (;;) { + c = ({ + asm ("" : "=r"(a)); + a; + }); + if (try_to_take_rt_mutex (c)) + break; + if (__builtin_expect (p1 == 0, 0)) + signal_pending (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67077.c b/SingleSource/Regression/C/gcc-dg/pr67077.c new file mode 100644 index 0000000000..555b1e3a04 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67077.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -O2" } */ + +unsigned char buffer[8]; +unsigned long +foo (void) +{ + unsigned long i; + i = buffer[0]; + if (i >= 8) + return i - 7; + i++; + while (i > 8) + { + if (buffer[i-1] != 0) + return 0; + i--; + } + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67088.c b/SingleSource/Regression/C/gcc-dg/pr67088.c new file mode 100644 index 0000000000..b2f77f5de5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67088.c @@ -0,0 +1,18 @@ +/* PR c/67088 */ +/* { dg-do compile } */ +/* { dg-options "-Wpedantic -std=c90" } */ + +enum E { A = 2 }; +int j; +float f; +struct S1 { + double b1:1; /* { dg-error "10:has invalid type" } */ + int b2:j; /* { dg-error "7:width not an integer constant" } */ + int b3:f; /* { dg-error "7:width not an integer constant" } */ + int b4:(int) __builtin_log (100); /* { dg-warning "7:width not an integer constant" } */ + int b5:-2; /* { dg-error "7:negative width" } */ + int b6:0; /* { dg-error "7:zero width" } */ + long int b7:32; /* { dg-warning "12:type of bit-field" } */ + int b8:sizeof (int) * __CHAR_BIT__ * 2; /* { dg-error "7:width of" } */ + __extension__ enum E b9:1; /* { dg-warning "24:is narrower" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr67089-1.c b/SingleSource/Regression/C/gcc-dg/pr67089-1.c new file mode 100644 index 0000000000..e26474977d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67089-1.c @@ -0,0 +1,112 @@ +/* PR target/67089 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int cnt, d; + +__attribute__((noinline, noclone)) +void foo (int x) +{ + asm volatile ("" : "+m" (d) : "g" (x) : "memory"); + cnt++; +} + +#define T(n, type, op, cond) \ +__attribute__((noinline, noclone)) \ +type \ +f##n (type x, type y) \ +{ \ + type r = op; \ + cond; \ + return r; \ +} + +T (1, unsigned int, x - y, if (r > x) foo (0)) +T (2, unsigned long, x - y, if (r <= x) foo (0)) +T (3, unsigned short, x - y, if (x < r) foo (r)) +T (4, unsigned long long, x - y, if (x >= r) foo (0)) +T (5, unsigned int, x - y, if (r >= x) foo (0)) +T (6, unsigned long, x - y, if (r < x) foo (0)) +T (7, unsigned short, x - y, if (x <= r) foo (r)) +T (8, unsigned long long, x - y, if (d || x > r) foo (0)) +T (9, unsigned int, x - y, if (d || r > x) foo (0)) +T (10, unsigned long, x - y, if (d || r <= x) foo (0)) +T (11, unsigned char, x - y, if (d || x < r) foo (0)) +T (12, unsigned long long, x - y, if (d || x >= r) foo (0)) +T (13, unsigned int, x - y, if (d || r >= x) foo (0)) +T (14, unsigned long, x - y, if (d || r < x) foo (0)) +T (15, unsigned short, x - y, if (d || x <= r) foo (0)) +T (16, unsigned long long, x - y, if (d || x > r) foo (0)) + +int +main () +{ + if (f1 (5, 3) != 2U || cnt != 0) abort (); + if (f1 (5, 7) != -2U || cnt != 1) abort (); + if (f1 (5, 5) != 0U || cnt != 1) abort (); + if (f1 (5, 0) != 5U || cnt != 1) abort (); + if (f2 (7, 1) != 6UL || cnt != 2) abort (); + if (f2 (7, 8) != -1UL || cnt != 2) abort (); + if (f2 (9, 9) != 0UL || cnt != 3) abort (); + if (f2 (9, 0) != 9UL || cnt != 4) abort (); + if (f3 (15, 14) != 1 || cnt != 4) abort (); + if (f3 (15, 25) != (unsigned short) -10 || cnt != 5) abort (); + if (f3 (15, 15) != 0 || cnt != 5) abort (); + if (f3 (15, 0) != 15 || cnt != 5) abort (); + if (f4 (9132, 9127) != 5ULL || cnt != 6) abort (); + if (f4 (9132, 9137) != -5ULL || cnt != 6) abort (); + if (f4 (9132, 9132) != 0 || cnt != 7) abort (); + if (f4 (9132, 0) != 9132ULL || cnt != 8) abort (); + if (f5 (5, 3) != 2U || cnt != 8) abort (); + if (f5 (5, 7) != -2U || cnt != 9) abort (); + if (f5 (5, 5) != 0U || cnt != 9) abort (); + if (f5 (5, 0) != 5U || cnt != 10) abort (); + if (f6 (7, 1) != 6UL || cnt != 11) abort (); + if (f6 (7, 8) != -1UL || cnt != 11) abort (); + if (f6 (9, 9) != 0UL || cnt != 12) abort (); + if (f6 (9, 0) != 9UL || cnt != 12) abort (); + if (f7 (15, 14) != 1 || cnt != 12) abort (); + if (f7 (15, 25) != (unsigned short) -10 || cnt != 13) abort (); + if (f7 (15, 15) != 0 || cnt != 13) abort (); + if (f7 (15, 0) != 15 || cnt != 14) abort (); + if (f8 (9132, 9127) != 5ULL || cnt != 15) abort (); + if (f8 (9132, 9137) != -5ULL || cnt != 15) abort (); + if (f8 (9132, 9132) != 0 || cnt != 16) abort (); + if (f8 (9132, 0) != 9132ULL || cnt != 16) abort (); + cnt = 0; + if (f9 (5, 3) != 2U || cnt != 0) abort (); + if (f9 (5, 7) != -2U || cnt != 1) abort (); + if (f9 (5, 5) != 0U || cnt != 1) abort (); + if (f9 (5, 0) != 5U || cnt != 1) abort (); + if (f10 (7, 1) != 6UL || cnt != 2) abort (); + if (f10 (7, 8) != -1UL || cnt != 2) abort (); + if (f10 (9, 9) != 0UL || cnt != 3) abort (); + if (f10 (9, 0) != 9UL || cnt != 4) abort (); + if (f11 (15, 14) != 1 || cnt != 4) abort (); + if (f11 (15, 25) != (unsigned char) -10 || cnt != 5) abort (); + if (f11 (15, 15) != 0 || cnt != 5) abort (); + if (f11 (15, 0) != 15 || cnt != 5) abort (); + if (f12 (9132, 9127) != 5ULL || cnt != 6) abort (); + if (f12 (9132, 9137) != -5ULL || cnt != 6) abort (); + if (f12 (9132, 9132) != 0 || cnt != 7) abort (); + if (f12 (9132, 0) != 9132ULL || cnt != 8) abort (); + if (f13 (5, 3) != 2U || cnt != 8) abort (); + if (f13 (5, 7) != -2U || cnt != 9) abort (); + if (f13 (5, 5) != 0U || cnt != 9) abort (); + if (f13 (5, 0) != 5U || cnt != 10) abort (); + if (f14 (7, 1) != 6UL || cnt != 11) abort (); + if (f14 (7, 8) != -1UL || cnt != 11) abort (); + if (f14 (9, 9) != 0UL || cnt != 12) abort (); + if (f14 (9, 0) != 9UL || cnt != 12) abort (); + if (f15 (15, 14) != 1 || cnt != 12) abort (); + if (f15 (15, 25) != (unsigned short) -10 || cnt != 13) abort (); + if (f15 (15, 15) != 0 || cnt != 13) abort (); + if (f15 (15, 0) != 15 || cnt != 14) abort (); + if (f16 (9132, 9127) != 5ULL || cnt != 15) abort (); + if (f16 (9132, 9137) != -5ULL || cnt != 15) abort (); + if (f16 (9132, 9132) != 0 || cnt != 16) abort (); + if (f16 (9132, 0) != 9132ULL || cnt != 16) abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67089-2.c b/SingleSource/Regression/C/gcc-dg/pr67089-2.c new file mode 100644 index 0000000000..59b27a7d68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67089-2.c @@ -0,0 +1,112 @@ +/* PR target/67089 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int cnt, d; + +__attribute__((noinline, noclone)) +void foo (int x) +{ + asm volatile ("" : "+m" (d) : "g" (x) : "memory"); + cnt++; +} + +#define T(n, type, op, cond) \ +__attribute__((noinline, noclone)) \ +type \ +f##n (type x, type y) \ +{ \ + type r = op; \ + cond; \ + return r; \ +} + +T (1, unsigned int, x - y, if (r > y) foo (0)) +T (2, unsigned long, x - y, if (r <= y) foo (0)) +T (3, unsigned short, x - y, if (y < r) foo (r)) +T (4, unsigned long long, x - y, if (y >= r) foo (0)) +T (5, unsigned int, x - y, if (r >= y) foo (0)) +T (6, unsigned long, x - y, if (r < y) foo (0)) +T (7, unsigned short, x - y, if (y <= r) foo (r)) +T (8, unsigned long long, x - y, if (d || y > r) foo (0)) +T (9, unsigned int, x - y, if (d || r > y) foo (0)) +T (10, unsigned long, x - y, if (d || r <= y) foo (0)) +T (11, unsigned char, x - y, if (d || y < r) foo (0)) +T (12, unsigned long long, x - y, if (d || y >= r) foo (0)) +T (13, unsigned int, x - y, if (d || r >= y) foo (0)) +T (14, unsigned long, x - y, if (d || r < y) foo (0)) +T (15, unsigned short, x - y, if (d || y <= r) foo (0)) +T (16, unsigned long long, x - y, if (d || y > r) foo (0)) + +int +main () +{ + if (f1 (5, 3) != 2U || cnt != 0) abort (); + if (f1 (5, 7) != -2U || cnt != 1) abort (); + if (f1 (5, 5) != 0U || cnt != 1) abort (); + if (f1 (5, 0) != 5U || cnt != 2) abort (); + if (f2 (7, 1) != 6UL || cnt != 2) abort (); + if (f2 (7, 8) != -1UL || cnt != 2) abort (); + if (f2 (9, 9) != 0UL || cnt != 3) abort (); + if (f2 (9, 0) != 9UL || cnt != 3) abort (); + if (f3 (15, 14) != 1 || cnt != 3) abort (); + if (f3 (15, 25) != (unsigned short) -10 || cnt != 4) abort (); + if (f3 (15, 15) != 0 || cnt != 4) abort (); + if (f3 (15, 0) != 15 || cnt != 5) abort (); + if (f4 (9132, 9127) != 5ULL || cnt != 6) abort (); + if (f4 (9132, 9137) != -5ULL || cnt != 6) abort (); + if (f4 (9132, 9132) != 0 || cnt != 7) abort (); + if (f4 (9132, 0) != 9132ULL || cnt != 7) abort (); + if (f5 (5, 3) != 2U || cnt != 7) abort (); + if (f5 (5, 7) != -2U || cnt != 8) abort (); + if (f5 (5, 5) != 0U || cnt != 8) abort (); + if (f5 (5, 0) != 5U || cnt != 9) abort (); + if (f6 (7, 1) != 6UL || cnt != 9) abort (); + if (f6 (7, 8) != -1UL || cnt != 9) abort (); + if (f6 (9, 9) != 0UL || cnt != 10) abort (); + if (f6 (9, 0) != 9UL || cnt != 10) abort (); + if (f7 (15, 14) != 1 || cnt != 10) abort (); + if (f7 (15, 25) != (unsigned short) -10 || cnt != 11) abort (); + if (f7 (15, 15) != 0 || cnt != 11) abort (); + if (f7 (15, 0) != 15 || cnt != 12) abort (); + if (f8 (9132, 9127) != 5ULL || cnt != 13) abort (); + if (f8 (9132, 9137) != -5ULL || cnt != 13) abort (); + if (f8 (9132, 9132) != 0 || cnt != 14) abort (); + if (f8 (9132, 0) != 9132ULL || cnt != 14) abort (); + cnt = 0; + if (f9 (5, 3) != 2U || cnt != 0) abort (); + if (f9 (5, 7) != -2U || cnt != 1) abort (); + if (f9 (5, 5) != 0U || cnt != 1) abort (); + if (f9 (5, 0) != 5U || cnt != 2) abort (); + if (f10 (7, 1) != 6UL || cnt != 2) abort (); + if (f10 (7, 8) != -1UL || cnt != 2) abort (); + if (f10 (9, 9) != 0UL || cnt != 3) abort (); + if (f10 (9, 0) != 9UL || cnt != 3) abort (); + if (f11 (15, 14) != 1 || cnt != 3) abort (); + if (f11 (15, 25) != (unsigned char) -10 || cnt != 4) abort (); + if (f11 (15, 15) != 0 || cnt != 4) abort (); + if (f11 (15, 0) != 15 || cnt != 5) abort (); + if (f12 (9132, 9127) != 5ULL || cnt != 6) abort (); + if (f12 (9132, 9137) != -5ULL || cnt != 6) abort (); + if (f12 (9132, 9132) != 0 || cnt != 7) abort (); + if (f12 (9132, 0) != 9132ULL || cnt != 7) abort (); + if (f13 (5, 3) != 2U || cnt != 7) abort (); + if (f13 (5, 7) != -2U || cnt != 8) abort (); + if (f13 (5, 5) != 0U || cnt != 8) abort (); + if (f13 (5, 0) != 5U || cnt != 9) abort (); + if (f14 (7, 1) != 6UL || cnt != 9) abort (); + if (f14 (7, 8) != -1UL || cnt != 9) abort (); + if (f14 (9, 9) != 0UL || cnt != 10) abort (); + if (f14 (9, 0) != 9UL || cnt != 10) abort (); + if (f15 (15, 14) != 1 || cnt != 10) abort (); + if (f15 (15, 25) != (unsigned short) -10 || cnt != 11) abort (); + if (f15 (15, 15) != 0 || cnt != 11) abort (); + if (f15 (15, 0) != 15 || cnt != 12) abort (); + if (f16 (9132, 9127) != 5ULL || cnt != 13) abort (); + if (f16 (9132, 9137) != -5ULL || cnt != 13) abort (); + if (f16 (9132, 9132) != 0 || cnt != 14) abort (); + if (f16 (9132, 0) != 9132ULL || cnt != 14) abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67089-3.c b/SingleSource/Regression/C/gcc-dg/pr67089-3.c new file mode 100644 index 0000000000..22576e56cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67089-3.c @@ -0,0 +1,112 @@ +/* PR target/67089 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int cnt, d; + +__attribute__((noinline, noclone)) +void foo (int x) +{ + asm volatile ("" : "+m" (d) : "g" (x) : "memory"); + cnt++; +} + +#define T(n, type, op, cond) \ +__attribute__((noinline, noclone)) \ +type \ +f##n (type x, type y) \ +{ \ + type r = op; \ + cond; \ + return r; \ +} + +T (1, unsigned int, x + y, if (r > x) foo (0)) +T (2, unsigned long, x + y, if (r <= x) foo (0)) +T (3, unsigned short, x + y, if (x < r) foo (r)) +T (4, unsigned long long, x + y, if (x >= r) foo (0)) +T (5, unsigned int, x + y, if (r >= x) foo (0)) +T (6, unsigned long, x + y, if (r < x) foo (0)) +T (7, unsigned short, x + y, if (x <= r) foo (r)) +T (8, unsigned long long, x + y, if (d || x > r) foo (0)) +T (9, unsigned int, x + y, if (d || r > x) foo (0)) +T (10, unsigned long, x + y, if (d || r <= x) foo (0)) +T (11, unsigned char, x + y, if (d || x < r) foo (0)) +T (12, unsigned long long, x + y, if (d || x >= r) foo (0)) +T (13, unsigned int, x + y, if (d || r >= x) foo (0)) +T (14, unsigned long, x + y, if (d || r < x) foo (0)) +T (15, unsigned short, x + y, if (d || x <= r) foo (0)) +T (16, unsigned long long, x + y, if (d || x > r) foo (0)) + +int +main () +{ + if (f1 (-7U, 0) != -7U || cnt != 0) abort (); + if (f1 (-7U, 6) != -1U || cnt != 1) abort (); + if (f1 (-7U, 7) != 0U || cnt != 1) abort (); + if (f1 (-7U, 8) != 1U || cnt != 1) abort (); + if (f2 (-9UL, 0) != -9UL || cnt != 2) abort (); + if (f2 (-9UL, 8) != -1UL || cnt != 2) abort (); + if (f2 (-9UL, 9) != 0UL || cnt != 3) abort (); + if (f2 (-9UL, 10) != 1UL || cnt != 4) abort (); + if (f3 (-15, 0) != (unsigned short) -15 || cnt != 4) abort (); + if (f3 (-15, 14) != (unsigned short) -1 || cnt != 5) abort (); + if (f3 (-15, 15) != 0 || cnt != 5) abort (); + if (f3 (-15, 16) != 1 || cnt != 5) abort (); + if (f4 (-9132ULL, 0) != -9132ULL || cnt != 6) abort (); + if (f4 (-9132ULL, 9131) != -1ULL || cnt != 6) abort (); + if (f4 (-9132ULL, 9132) != 0 || cnt != 7) abort (); + if (f4 (-9132ULL, 9133) != 1ULL || cnt != 8) abort (); + if (f5 (-7U, 0) != -7U || cnt != 9) abort (); + if (f5 (-7U, 6) != -1U || cnt != 10) abort (); + if (f5 (-7U, 7) != 0U || cnt != 10) abort (); + if (f5 (-7U, 8) != 1U || cnt != 10) abort (); + if (f6 (-9UL, 0) != -9UL || cnt != 10) abort (); + if (f6 (-9UL, 8) != -1UL || cnt != 10) abort (); + if (f6 (-9UL, 9) != 0UL || cnt != 11) abort (); + if (f6 (-9UL, 10) != 1UL || cnt != 12) abort (); + if (f7 (-15, 0) != (unsigned short) -15 || cnt != 13) abort (); + if (f7 (-15, 14) != (unsigned short) -1 || cnt != 14) abort (); + if (f7 (-15, 15) != 0 || cnt != 14) abort (); + if (f7 (-15, 16) != 1 || cnt != 14) abort (); + if (f8 (-9132ULL, 0) != -9132ULL || cnt != 14) abort (); + if (f8 (-9132ULL, 9131) != -1ULL || cnt != 14) abort (); + if (f8 (-9132ULL, 9132) != 0 || cnt != 15) abort (); + if (f8 (-9132ULL, 9133) != 1ULL || cnt != 16) abort (); + cnt = 0; + if (f9 (-7U, 0) != -7U || cnt != 0) abort (); + if (f9 (-7U, 6) != -1U || cnt != 1) abort (); + if (f9 (-7U, 7) != 0U || cnt != 1) abort (); + if (f9 (-7U, 8) != 1U || cnt != 1) abort (); + if (f10 (-9UL, 0) != -9UL || cnt != 2) abort (); + if (f10 (-9UL, 8) != -1UL || cnt != 2) abort (); + if (f10 (-9UL, 9) != 0UL || cnt != 3) abort (); + if (f10 (-9UL, 10) != 1UL || cnt != 4) abort (); + if (f11 (-15, 0) != (unsigned char) -15 || cnt != 4) abort (); + if (f11 (-15, 14) != (unsigned char) -1 || cnt != 5) abort (); + if (f11 (-15, 15) != 0 || cnt != 5) abort (); + if (f11 (-15, 16) != 1 || cnt != 5) abort (); + if (f12 (-9132ULL, 0) != -9132ULL || cnt != 6) abort (); + if (f12 (-9132ULL, 9131) != -1ULL || cnt != 6) abort (); + if (f12 (-9132ULL, 9132) != 0 || cnt != 7) abort (); + if (f12 (-9132ULL, 9133) != 1ULL || cnt != 8) abort (); + if (f13 (-7U, 0) != -7U || cnt != 9) abort (); + if (f13 (-7U, 6) != -1U || cnt != 10) abort (); + if (f13 (-7U, 7) != 0U || cnt != 10) abort (); + if (f13 (-7U, 8) != 1U || cnt != 10) abort (); + if (f14 (-9UL, 0) != -9UL || cnt != 10) abort (); + if (f14 (-9UL, 8) != -1UL || cnt != 10) abort (); + if (f14 (-9UL, 9) != 0UL || cnt != 11) abort (); + if (f14 (-9UL, 10) != 1UL || cnt != 12) abort (); + if (f15 (-15, 0) != (unsigned short) -15 || cnt != 13) abort (); + if (f15 (-15, 14) != (unsigned short) -1 || cnt != 14) abort (); + if (f15 (-15, 15) != 0 || cnt != 14) abort (); + if (f15 (-15, 16) != 1 || cnt != 14) abort (); + if (f16 (-9132ULL, 0) != -9132ULL || cnt != 14) abort (); + if (f16 (-9132ULL, 9131) != -1ULL || cnt != 14) abort (); + if (f16 (-9132ULL, 9132) != 0 || cnt != 15) abort (); + if (f16 (-9132ULL, 9133) != 1ULL || cnt != 16) abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67089-4.c b/SingleSource/Regression/C/gcc-dg/pr67089-4.c new file mode 100644 index 0000000000..f4f7439f9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67089-4.c @@ -0,0 +1,112 @@ +/* PR target/67089 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort (void); + +int cnt, d; + +__attribute__((noinline, noclone)) +void foo (int x) +{ + asm volatile ("" : "+m" (d) : "g" (x) : "memory"); + cnt++; +} + +#define T(n, type, op, cond) \ +__attribute__((noinline, noclone)) \ +type \ +f##n (type x, type y) \ +{ \ + type r = op; \ + cond; \ + return r; \ +} + +T (1, unsigned int, x + y, if (r > y) foo (0)) +T (2, unsigned long, x + y, if (r <= y) foo (0)) +T (3, unsigned short, x + y, if (y < r) foo (r)) +T (4, unsigned long long, x + y, if (y >= r) foo (0)) +T (5, unsigned int, x + y, if (r >= y) foo (0)) +T (6, unsigned long, x + y, if (r < y) foo (0)) +T (7, unsigned short, x + y, if (y <= r) foo (r)) +T (8, unsigned long long, x + y, if (d || y > r) foo (0)) +T (9, unsigned int, x + y, if (d || r > y) foo (0)) +T (10, unsigned long, x + y, if (d || r <= y) foo (0)) +T (11, unsigned char, x + y, if (d || y < r) foo (0)) +T (12, unsigned long long, x + y, if (d || y >= r) foo (0)) +T (13, unsigned int, x + y, if (d || r >= y) foo (0)) +T (14, unsigned long, x + y, if (d || r < y) foo (0)) +T (15, unsigned short, x + y, if (d || y <= r) foo (0)) +T (16, unsigned long long, x + y, if (d || y > r) foo (0)) + +int +main () +{ + if (f1 (-7U, 0) != -7U || cnt != 1) abort (); + if (f1 (-7U, 6) != -1U || cnt != 2) abort (); + if (f1 (-7U, 7) != 0U || cnt != 2) abort (); + if (f1 (-7U, 8) != 1U || cnt != 2) abort (); + if (f2 (-9UL, 0) != -9UL || cnt != 2) abort (); + if (f2 (-9UL, 8) != -1UL || cnt != 2) abort (); + if (f2 (-9UL, 9) != 0UL || cnt != 3) abort (); + if (f2 (-9UL, 10) != 1UL || cnt != 4) abort (); + if (f3 (-15, 0) != (unsigned short) -15 || cnt != 5) abort (); + if (f3 (-15, 14) != (unsigned short) -1 || cnt != 6) abort (); + if (f3 (-15, 15) != 0 || cnt != 6) abort (); + if (f3 (-15, 16) != 1 || cnt != 6) abort (); + if (f4 (-9132ULL, 0) != -9132ULL || cnt != 6) abort (); + if (f4 (-9132ULL, 9131) != -1ULL || cnt != 6) abort (); + if (f4 (-9132ULL, 9132) != 0 || cnt != 7) abort (); + if (f4 (-9132ULL, 9133) != 1ULL || cnt != 8) abort (); + if (f5 (-7U, 0) != -7U || cnt != 9) abort (); + if (f5 (-7U, 6) != -1U || cnt != 10) abort (); + if (f5 (-7U, 7) != 0U || cnt != 10) abort (); + if (f5 (-7U, 8) != 1U || cnt != 10) abort (); + if (f6 (-9UL, 0) != -9UL || cnt != 10) abort (); + if (f6 (-9UL, 8) != -1UL || cnt != 10) abort (); + if (f6 (-9UL, 9) != 0UL || cnt != 11) abort (); + if (f6 (-9UL, 10) != 1UL || cnt != 12) abort (); + if (f7 (-15, 0) != (unsigned short) -15 || cnt != 13) abort (); + if (f7 (-15, 14) != (unsigned short) -1 || cnt != 14) abort (); + if (f7 (-15, 15) != 0 || cnt != 14) abort (); + if (f7 (-15, 16) != 1 || cnt != 14) abort (); + if (f8 (-9132ULL, 0) != -9132ULL || cnt != 14) abort (); + if (f8 (-9132ULL, 9131) != -1ULL || cnt != 14) abort (); + if (f8 (-9132ULL, 9132) != 0 || cnt != 15) abort (); + if (f8 (-9132ULL, 9133) != 1ULL || cnt != 16) abort (); + cnt = 0; + if (f9 (-7U, 0) != -7U || cnt != 1) abort (); + if (f9 (-7U, 6) != -1U || cnt != 2) abort (); + if (f9 (-7U, 7) != 0U || cnt != 2) abort (); + if (f9 (-7U, 8) != 1U || cnt != 2) abort (); + if (f10 (-9UL, 0) != -9UL || cnt != 2) abort (); + if (f10 (-9UL, 8) != -1UL || cnt != 2) abort (); + if (f10 (-9UL, 9) != 0UL || cnt != 3) abort (); + if (f10 (-9UL, 10) != 1UL || cnt != 4) abort (); + if (f11 (-15, 0) != (unsigned char) -15 || cnt != 5) abort (); + if (f11 (-15, 14) != (unsigned char) -1 || cnt != 6) abort (); + if (f11 (-15, 15) != 0 || cnt != 6) abort (); + if (f11 (-15, 16) != 1 || cnt != 6) abort (); + if (f12 (-9132ULL, 0) != -9132ULL || cnt != 6) abort (); + if (f12 (-9132ULL, 9131) != -1ULL || cnt != 6) abort (); + if (f12 (-9132ULL, 9132) != 0 || cnt != 7) abort (); + if (f12 (-9132ULL, 9133) != 1ULL || cnt != 8) abort (); + if (f13 (-7U, 0) != -7U || cnt != 9) abort (); + if (f13 (-7U, 6) != -1U || cnt != 10) abort (); + if (f13 (-7U, 7) != 0U || cnt != 10) abort (); + if (f13 (-7U, 8) != 1U || cnt != 10) abort (); + if (f14 (-9UL, 0) != -9UL || cnt != 10) abort (); + if (f14 (-9UL, 8) != -1UL || cnt != 10) abort (); + if (f14 (-9UL, 9) != 0UL || cnt != 11) abort (); + if (f14 (-9UL, 10) != 1UL || cnt != 12) abort (); + if (f15 (-15, 0) != (unsigned short) -15 || cnt != 13) abort (); + if (f15 (-15, 14) != (unsigned short) -1 || cnt != 14) abort (); + if (f15 (-15, 15) != 0 || cnt != 14) abort (); + if (f15 (-15, 16) != 1 || cnt != 14) abort (); + if (f16 (-9132ULL, 0) != -9132ULL || cnt != 14) abort (); + if (f16 (-9132ULL, 9131) != -1ULL || cnt != 14) abort (); + if (f16 (-9132ULL, 9132) != 0 || cnt != 15) abort (); + if (f16 (-9132ULL, 9133) != 1ULL || cnt != 16) abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67089-5.c b/SingleSource/Regression/C/gcc-dg/pr67089-5.c new file mode 100644 index 0000000000..f937375737 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67089-5.c @@ -0,0 +1,82 @@ +/* PR target/67089 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-loop-if-convert" } */ + +extern void abort (void); + +int cnt; +unsigned int a[16], b[16], c[16]; + +__attribute__((noinline, noclone)) +void foo (int x) +{ + asm volatile ("" : : "g" (x) : "memory"); + cnt++; +} + +__attribute__((noinline, noclone)) void +f0 (unsigned int x) +{ + for (int i = 0; i < 16; i++) + { + unsigned int r = x - a[i]; + b[i] = r; + c[i] = r > x ? 7 : x; + } +} + +#define T(n, type, op, cond) \ +__attribute__((noinline, noclone)) \ +type \ +f##n (type x) \ +{ \ + type r = op; \ + cond; \ + return r; \ +} + +T (1, unsigned int, x - 2U, if (r > x) foo (0)) +T (2, unsigned long, x - 2U, if (r <= x) foo (0)) +T (3, unsigned short, 2U - x, if (r > 2U) foo (0)) +T (4, unsigned char, 2U - x, if (r <= 2U) foo (0)) +T (5, unsigned int, x + -2U, if (r > x) foo (0)) +T (6, unsigned long, x + -2UL, if (r <= x) foo (0)) +T (7, unsigned short, (unsigned short) -2 + x, if (r > (unsigned short) -2) foo (0)) +T (8, unsigned char, (unsigned char) -2 + x, if (r <= (unsigned char) -2) foo (0)) + +int +main () +{ + int i; + for (i = 0; i < 16; i++) + a[i] = i - 7; + f0 (5); + for (i = 0; i < 16; i++) + if (b[i] != 12U - i || c[i] != 7 - 2 * (i >= 7 && i < 13)) + abort (); + if (f1 (3) != 1 || cnt != 0) abort (); + if (f1 (2) != 0 || cnt != 0) abort (); + if (f1 (1) != -1U || cnt != 1) abort (); + if (f2 (3) != 1 || cnt != 2) abort (); + if (f2 (2) != 0 || cnt != 3) abort (); + if (f2 (1) != -1UL || cnt != 3) abort (); + if (f3 (3) != (unsigned short) -1 || cnt != 4) abort (); + if (f3 (2) != 0 || cnt != 4) abort (); + if (f3 (1) != 1 || cnt != 4) abort (); + if (f4 (3) != (unsigned char) -1 || cnt != 4) abort (); + if (f4 (2) != 0 || cnt != 5) abort (); + if (f4 (1) != 1 || cnt != 6) abort (); + if (f5 (3) != 1 || cnt != 6) abort (); + if (f5 (2) != 0 || cnt != 6) abort (); + if (f5 (1) != -1U || cnt != 7) abort (); + if (f6 (3) != 1 || cnt != 8) abort (); + if (f6 (2) != 0 || cnt != 9) abort (); + if (f6 (1) != -1UL || cnt != 9) abort (); + if (f7 (3) != 1 || cnt != 9) abort (); + if (f7 (2) != 0 || cnt != 9) abort (); + if (f7 (1) != (unsigned short) -1 || cnt != 10) abort (); + if (f8 (3) != 1 || cnt != 11) abort (); + if (f8 (2) != 0 || cnt != 12) abort (); + if (f8 (1) != (unsigned char) -1 || cnt != 12) abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67089-6.c b/SingleSource/Regression/C/gcc-dg/pr67089-6.c new file mode 100644 index 0000000000..b59d75b231 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67089-6.c @@ -0,0 +1,61 @@ +/* PR target/67089 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-vectorize -ftree-loop-if-convert -fdump-tree-widening_mul" } */ + +extern void abort (void); + +int cnt; +unsigned int a[16], b[16], c[16], d; +void foo (int x); + +__attribute__((noinline, noclone)) void +f0 (unsigned int x) +{ + for (int i = 0; i < 16; i++) + { + unsigned int r = x - a[i]; + b[i] = r; + c[i] = r > x ? 7 : x; + } +} + +#define T(n, type, op, cond) \ +__attribute__((noinline, noclone)) \ +type \ +f##n (type x, type y) \ +{ \ + type r = op; \ + cond; \ + return r; \ +} + +T (1, unsigned int, x - y, if (r > x) foo (0)) +T (2, unsigned long, x - y, if (r <= x) foo (0)) +T (3, unsigned short, x - y, if (x < r) foo (r)) +T (4, unsigned long long, x - y, if (x >= r) foo (0)) +T (5, unsigned int, x - y, if (d || r > x) foo (0)) +T (6, unsigned long, x - y, if (d || r <= x) foo (0)) +T (7, unsigned char, x - y, if (d || x < r) foo (0)) +T (8, unsigned long long, x - y, if (d || x >= r) foo (0)) +T (9, unsigned int, x + y, if (r >= x) foo (0)) +T (10, unsigned long, x + y, if (r < x) foo (0)) +T (11, unsigned short, x + y, if (x <= r) foo (r)) +T (12, unsigned long long, x + y, if (d || x > r) foo (0)) +T (13, unsigned int, x + y, if (d || r >= x) foo (0)) +T (14, unsigned long, x + y, if (d || r < x) foo (0)) +T (15, unsigned short, x + y, if (d || x <= r) foo (0)) +T (16, unsigned long long, x + y, if (d || x > r) foo (0)) +T (17, unsigned int, x + y, if (r >= y) foo (0)) +T (18, unsigned long, x + y, if (r < y) foo (0)) +T (19, unsigned short, x + y, if (y <= r) foo (r)) +T (20, unsigned long long, x + y, if (d || y > r) foo (0)) +T (21, unsigned int, x + y, if (d || r >= y) foo (0)) +T (22, unsigned long, x + y, if (d || r < y) foo (0)) +T (23, unsigned short, x + y, if (d || y <= r) foo (0)) +T (24, unsigned long long, x + y, if (d || y > r) foo (0)) +T (25, unsigned short, 2U - x, if (r > 2U) foo (0)) +T (26, unsigned char, 2U - x, if (r <= 2U) foo (0)) + +/* { dg-final { scan-tree-dump-times "ADD_OVERFLOW" 16 "widening_mul" { target { i?86-*-* x86_64-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "SUB_OVERFLOW" 11 "widening_mul" { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } } */ +/* { dg-final { scan-tree-dump-times "SUB_OVERFLOW" 9 "widening_mul" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr67089-7.c b/SingleSource/Regression/C/gcc-dg/pr67089-7.c new file mode 100644 index 0000000000..dc05e3b226 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67089-7.c @@ -0,0 +1,62 @@ +/* PR target/67089 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-if-convert -fdump-tree-widening_mul" } */ + +extern void abort (void); + +int cnt, d; +void foo (int x); + +#define T(n, type, op, cond) \ +__attribute__((noinline, noclone)) \ +type \ +f##n (type x, type y) \ +{ \ + type r = op; \ + cond; \ + return r; \ +} + +T (1, unsigned int, x - y, if (r >= x) foo (0)) +T (2, unsigned long, x - y, if (r < x) foo (0)) +T (3, unsigned short, x - y, if (x <= r) foo (r)) +T (4, unsigned long long, x - y, if (d || x > r) foo (0)) +T (5, unsigned int, x - y, if (d || r >= x) foo (0)) +T (6, unsigned long, x - y, if (d || r < x) foo (0)) +T (7, unsigned short, x - y, if (d || x <= r) foo (0)) +T (8, unsigned long long, x - y, if (d || x > r) foo (0)) +T (9, unsigned int, x - y, if (r > y) foo (0)) +T (10, unsigned long, x - y, if (r <= y) foo (0)) +T (11, unsigned short, x - y, if (y < r) foo (r)) +T (12, unsigned long long, x - y, if (y >= r) foo (0)) +T (13, unsigned int, x - y, if (r >= y) foo (0)) +T (14, unsigned long, x - y, if (r < y) foo (0)) +T (15, unsigned short, x - y, if (y <= r) foo (r)) +T (16, unsigned long long, x - y, if (d || y > r) foo (0)) +T (17, unsigned int, x - y, if (d || r > y) foo (0)) +T (18, unsigned long, x - y, if (d || r <= y) foo (0)) +T (19, unsigned char, x - y, if (d || y < r) foo (0)) +T (20, unsigned long long, x - y, if (d || y >= r) foo (0)) +T (21, unsigned int, x - y, if (d || r >= y) foo (0)) +T (22, unsigned long, x - y, if (d || r < y) foo (0)) +T (23, unsigned short, x - y, if (d || y <= r) foo (0)) +T (24, unsigned long long, x - y, if (d || y > r) foo (0)) +T (25, unsigned int, x + y, if (r > x) foo (0)) +T (26, unsigned long, x + y, if (r <= x) foo (0)) +T (27, unsigned short, x + y, if (x < r) foo (r)) +T (28, unsigned long long, x + y, if (x >= r) foo (0)) +T (29, unsigned int, x + y, if (d || r > x) foo (0)) +T (30, unsigned long, x + y, if (d || r <= x) foo (0)) +T (31, unsigned char, x + y, if (d || x < r) foo (0)) +T (32, unsigned long long, x + y, if (d || x >= r) foo (0)) +T (33, unsigned int, x + y, if (r > y) foo (0)) +T (34, unsigned long, x + y, if (r <= y) foo (0)) +T (35, unsigned short, x + y, if (y < r) foo (r)) +T (36, unsigned long long, x + y, if (y >= r) foo (0)) +T (37, unsigned int, x + y, if (d || r > y) foo (0)) +T (38, unsigned long, x + y, if (d || r <= y) foo (0)) +T (39, unsigned char, x + y, if (d || y < r) foo (0)) +T (40, unsigned long long, x + y, if (d || y >= r) foo (0)) + +/* { dg-final { scan-tree-dump-not "ADD_OVERFLOW" "widening_mul" } } */ +/* { dg-final { scan-tree-dump-not "SUB_OVERFLOW" "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr67107.c b/SingleSource/Regression/C/gcc-dg/pr67107.c new file mode 100644 index 0000000000..e2e11c0f9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67107.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-frounding-math -funsafe-math-optimizations" } */ + +int test () +{ + return 5.0 < 5.0 - 0.1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67271.c b/SingleSource/Regression/C/gcc-dg/pr67271.c new file mode 100644 index 0000000000..977e253179 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67271.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* { dg-require-effective-target int32plus } */ + +extern long int labs (long int j); +int +main () +{ + long *a = (long *)"empty"; + int i = 1441516387; + a[i] = labs (a[i]); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67312.c b/SingleSource/Regression/C/gcc-dg/pr67312.c new file mode 100644 index 0000000000..f1c9fdedbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67312.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -ftree-coalesce-vars" } */ + +void foo (int x, int y) +{ + y = x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67338.c b/SingleSource/Regression/C/gcc-dg/pr67338.c new file mode 100644 index 0000000000..7bfbef29be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67338.c @@ -0,0 +1,4 @@ +/* PR c/67338 */ +/* { dg-do compile { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ + +struct S { __attribute__((aligned (1 << 28))) double a; }; diff --git a/SingleSource/Regression/C/gcc-dg/pr67410.c b/SingleSource/Regression/C/gcc-dg/pr67410.c new file mode 100644 index 0000000000..ff3c4f1686 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67410.c @@ -0,0 +1,15 @@ +/* PR c/67410 */ +/* { dg-do run } */ +/* { dg-options "-std=gnu11" } */ + +struct { + __CHAR16_TYPE__ s[2]; +} a[] = { u"ff", [0].s[0] = u'x', [1] = u"\u1234\u4567", [1].s[0] = u'\u89ab' }; + +int +main () +{ + if (a[0].s[0] != u'x' || a[0].s[1] != u'f' || a[1].s[0] != u'\u89ab' || a[1].s[1] != u'\u4567') + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67432.c b/SingleSource/Regression/C/gcc-dg/pr67432.c new file mode 100644 index 0000000000..74367a9725 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67432.c @@ -0,0 +1,6 @@ +/* PR c/67432 */ +/* { dg-do compile } */ + +enum {}; /* { dg-error "empty enum is invalid" } */ +enum E {}; /* { dg-error "empty enum is invalid" } */ +enum F {} e; /* { dg-error "empty enum is invalid" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr67465.c b/SingleSource/Regression/C/gcc-dg/pr67465.c new file mode 100644 index 0000000000..321fd38cca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67465.c @@ -0,0 +1,53 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -std=gnu99" } */ + +int a, b, c, d, e, h; + +int +fn1 (int p1) +{ + { + int g[2]; + for (int i = 0; i < 1; i++) + g[i] = 0; + if (g[0] < c) + { + a = (unsigned) (1 ^ p1) % 2; + return 0; + } + } + return 0; +} + +void +fn2 () +{ + for (h = 0; h < 1; h++) + { + for (int j = 0; j < 2; j++) + { + for (b = 1; b; b = 0) + a = 1; + for (; b < 1; b++) + ; + if (e) + continue; + a = 2; + } + fn1 (h); + short k = -16; + d = k > a; + } +} + +int +main () +{ + fn2 (); + + if (a != 2) + __builtin_abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr67512.c b/SingleSource/Regression/C/gcc-dg/pr67512.c new file mode 100644 index 0000000000..95f836aea0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67512.c @@ -0,0 +1,15 @@ +/* PR middle-end/67512 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +extern int fn2 (void); +extern int fn3 (int); +void +fn1 (void) +{ + int z, m; + if (1 & m) /* { dg-warning "is used uninitialized" } */ + z = fn2 (); + z = 1 == m ? z : 2 == m; + fn3 (z); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67563.c b/SingleSource/Regression/C/gcc-dg/pr67563.c new file mode 100644 index 0000000000..5a727b832f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67563.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fexceptions" } */ +/* { dg-require-effective-target exceptions } */ + +static void +emit_package (int p1) +{ + int a; + int b[0]; + a = __fprintf_chk (0, 0, ""); +} +void emit_lua () { emit_package (0); } diff --git a/SingleSource/Regression/C/gcc-dg/pr67580.c b/SingleSource/Regression/C/gcc-dg/pr67580.c new file mode 100644 index 0000000000..c2760e5da1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67580.c @@ -0,0 +1,25 @@ +/* PR c/67580 */ +/* { dg-do compile } */ + +struct S { int s; }; +union U { int s; }; +enum E { A }; + +void +f (void) +{ + S s; /* { dg-error "unknown type name .S.; use .struct. keyword to refer to the type" } */ + U u; /* { dg-error "unknown type name .U.; use .union. keyword to refer to the type" } */ + E e; /* { dg-error "unknown type name .E.; use .enum. keyword to refer to the type" } */ +} + +void +g (void) +{ + struct T { int i; }; + union V { int i; }; + enum F { J }; + T t; /* { dg-error "unknown type name .T.; use .struct. keyword to refer to the type" } */ + V v; /* { dg-error "unknown type name .V.; use .union. keyword to refer to the type" } */ + F f; /* { dg-error "unknown type name .F.; use .enum. keyword to refer to the type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67730-1.c b/SingleSource/Regression/C/gcc-dg/pr67730-1.c new file mode 100644 index 0000000000..bb82f6d8e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67730-1.c @@ -0,0 +1,16 @@ +/* PR c/67730 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +#include "pr67730.h" + +extern void bar (unsigned char *); + +unsigned char * +f (void *p) +{ + unsigned char *uc = ONEP; /* { dg-warning "request for implicit conversion" } */ + uc = ONEP; /* { dg-warning "request for implicit conversion" } */ + bar (ONEP); /* { dg-warning "request for implicit conversion" } */ + return ONEP; /* { dg-warning "request for implicit conversion" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67730-2.c b/SingleSource/Regression/C/gcc-dg/pr67730-2.c new file mode 100644 index 0000000000..260cc3e382 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67730-2.c @@ -0,0 +1,22 @@ +/* PR c/67730 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include "pr67730.h" + +extern void bar (int); + +int +fn1 (void) +{ + int a = NULL; /* { dg-warning "initialization of 'int' from 'void \\*' makes integer from pointer" } */ + a = NULL; /* { dg-warning "assignment to 'int' from 'void \\*' makes integer from pointer" } */ + bar (NULL); /* { dg-warning "passing argument 1" } */ + return NULL; /* { dg-warning "returning 'void \\*' from a function with return type 'int' makes integer from pointer" } */ +} + +int +fn2 (void) +{ + RETURN; /* { dg-warning "returning 'void \\*' from a function with return type 'int' makes integer from pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67730.c b/SingleSource/Regression/C/gcc-dg/pr67730.c new file mode 100644 index 0000000000..54d73a62cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67730.c @@ -0,0 +1,11 @@ +/* PR c/67730 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include + +void +fn1 (void) +{ + return NULL; /* { dg-warning "10:.return. with a value" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67730.h b/SingleSource/Regression/C/gcc-dg/pr67730.h new file mode 100644 index 0000000000..9a9afc9a09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67730.h @@ -0,0 +1,32 @@ +#pragma GCC system_header +#define NULL (void *) 0 +#define ONEP (void *) 1 +#define RETURN return NULL + +extern void sysbar (unsigned char *); + +unsigned char * +sysfn1 (void *p) +{ + unsigned char *uc = ONEP; + uc = ONEP; + sysbar (ONEP); + return ONEP; +} + +extern void sysbar2 (int); + +int +sysfn2 (void) +{ + int a = NULL; + a = NULL; + sysbar2 (NULL); + return NULL; +} + +int +sysfn3 (void) +{ + RETURN; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67784-1.c b/SingleSource/Regression/C/gcc-dg/pr67784-1.c new file mode 100644 index 0000000000..d5e85fc0c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67784-1.c @@ -0,0 +1,54 @@ +/* PR c/67784 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int T; + +void +fn1 (void) +{ + for (int T;;) + if (1) + ; + T *x; +} + +void +fn2 (void) +{ + for (int T;;) + if (1) + T = 1; + T *x; +} + +void +fn3 (void) +{ + for (int T;;) + if (1) + { + } + T *x; +} + +void +fn4 (void) +{ + for (int T;;) + if (1) +L: + ; + T *x; +} + +void +fn5 (void) +{ + for (int T;;) + if (1) + ; + else + ; + T *x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67784-2.c b/SingleSource/Regression/C/gcc-dg/pr67784-2.c new file mode 100644 index 0000000000..07af9cbcb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67784-2.c @@ -0,0 +1,54 @@ +/* PR c/67784 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int T; + +void +fn1 (void) +{ + for (typedef int T;;) + if (1) + ; + T *x; /* { dg-error "undeclared" } */ +} + +void +fn2 (void) +{ + for (typedef int T;;) + if (1) + T = 1; /* { dg-error "expected expression" } */ + T *x; /* { dg-error "undeclared" } */ +} + +void +fn3 (void) +{ + for (typedef int T;;) + if (1) + { + } + T *x; /* { dg-error "undeclared" } */ +} + +void +fn4 (void) +{ + for (typedef int T;;) + if (1) +L: + ; + T *x; /* { dg-error "undeclared" } */ +} + +void +fn5 (void) +{ + for (typedef int T;;) + if (1) + ; + else + ; + T *x; /* { dg-error "undeclared" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67784-3.c b/SingleSource/Regression/C/gcc-dg/pr67784-3.c new file mode 100644 index 0000000000..45e3c44b26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67784-3.c @@ -0,0 +1,50 @@ +/* PR c/67784 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int T; + +void +fn1 (void) +{ + if (sizeof (enum { T }) == 0) + ; + T x; +} + +void +fn2 (void) +{ + int i = 0; + if (sizeof (enum { T }) == 0) + i++; + T x; +} + +void +fn3 (void) +{ + if (sizeof (enum { T }) == 0) + { + } + T x; +} + +void +fn4 (void) +{ + if (sizeof (enum { T }) == 0) +L: + ; + T x; +} + +void +fn5 (void) +{ + if (sizeof (enum { T }) == 0) + ; + else + ; + T x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67784-4.c b/SingleSource/Regression/C/gcc-dg/pr67784-4.c new file mode 100644 index 0000000000..54620802a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67784-4.c @@ -0,0 +1,55 @@ +/* PR c/67784 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-switch-unreachable" } */ + +typedef int T; + +void +fn1 (void) +{ + switch (sizeof (enum { T })) + if (1) + ; + T x; +} + +void +fn2 (void) +{ + int i = 0; + switch (sizeof (enum { T })) + if (1) + i++; + T x; +} + +void +fn3 (void) +{ + switch (sizeof (enum { T })) + if (1) + { + } + T x; +} + +void +fn4 (void) +{ + switch (sizeof (enum { T })) + if (1) +L: + ; + T x; +} + +void +fn5 (void) +{ + switch (sizeof (enum { T })) + if (1) + ; + else + ; + T x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67784-5.c b/SingleSource/Regression/C/gcc-dg/pr67784-5.c new file mode 100644 index 0000000000..0934eceeca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67784-5.c @@ -0,0 +1,55 @@ +/* PR c/67784 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int T; + +void +fn1 (void) +{ + while (sizeof (enum { T })) + if (1) + ; + T x; +} + +void +fn2 (void) +{ + int i = 0; + while (sizeof (enum { T })) + if (1) + i++; + T x; +} + +void +fn3 (void) +{ + while (sizeof (enum { T })) + if (1) + { + } + T x; +} + +void +fn4 (void) +{ + while (sizeof (enum { T })) + if (1) +L: + ; + T x; +} + +void +fn5 (void) +{ + while (sizeof (enum { T })) + if (1) + ; + else + ; + T x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67786.c b/SingleSource/Regression/C/gcc-dg/pr67786.c new file mode 100644 index 0000000000..76525e51d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67786.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +int a, b = 10; +char c; + +int +main () +{ + char d; + int e = 5; + for (a = 0; a; a--) + e = 0; + c = (b & 15) ^ e; + d = c > e ? c : c << e; + __builtin_printf ("%d\n", d); + return 0; +} + +/* { dg-output "15" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr67787.c b/SingleSource/Regression/C/gcc-dg/pr67787.c new file mode 100644 index 0000000000..9d132488d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67787.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +int a, c, f, g; +char b; + +static int +fn1 () +{ + char h; + int k = -1, i, j; + for (; b < 16; b++) + ; + __builtin_printf (" "); + if (b < 5) + k++; + if (k) + { + int l = 2; + a = h = b < 0 || b > (127 >> l) ? b : b << 1; + return 0; + } + for (i = 0; i < 1; i++) + for (j = 0; j < 7; j++) + f = 0; + for (c = 0; c; c++) + ; + if (g) + for (;;) + ; + return 0; +} + +int +main () +{ + fn1 (); + + if (a != 32) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67830.c b/SingleSource/Regression/C/gcc-dg/pr67830.c new file mode 100644 index 0000000000..9bfb0c0531 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67830.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/67830 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int a, b, *g, h; +unsigned char c, d; + +int +main () +{ + int f, e = -2; + b = e; + g = &b; + h = c = a + 1; + f = d - h; + *g &= f; + + if (b != -2) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67854.c b/SingleSource/Regression/C/gcc-dg/pr67854.c new file mode 100644 index 0000000000..af994c6458 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67854.c @@ -0,0 +1,11 @@ +/* PR c/67854 */ +/* { dg-do compile } */ + +#include +#include + +void +foo (va_list ap) +{ + va_arg (ap, bool); /* { dg-warning "is promoted to .int. when passed through" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr67964.c b/SingleSource/Regression/C/gcc-dg/pr67964.c new file mode 100644 index 0000000000..a7736c2201 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr67964.c @@ -0,0 +1,22 @@ +/* PR c/67964 */ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ + +extern int fn0 (void) __attribute__ ((const const)); /* { dg-error "expected" } */ +extern int fn1 (void) __attribute__ ((const, const)); +extern int fn2 (void) __attribute__ ((optimize (0) const)); /* { dg-error "expected" } */ +extern int fn3 (void) __attribute__ ((optimize (0), const)); +/* We allow starting/trailing comma. */ +extern int fn4 (void) __attribute__ ((, const)); +extern int fn5 (void) __attribute__ ((const, )); +extern int fn6 (void) __attribute__ ((,,,, const,,,,, )); +extern int fn7 (void) __attribute__ ((,)); +extern int fn8 (void) __attribute__ ((__noreturn__ __noreturn__)); /* { dg-error "expected" } */ +extern int fn9 (void) __attribute__ ((__noreturn__, __noreturn__)); +extern int fn10 (void) __attribute__ ((__cold__ __pure__ __noclone__)); /* { dg-error "expected" } */ +extern int fn11 (void) __attribute__ ((__cold__, __pure__ __noclone__)); /* { dg-error "expected" } */ +int i; +int ii; +extern int a __attribute__ ((alias ("i") unused)); /* { dg-error "expected" } */ +extern int a2 __attribute__ ((alias ("i" "i"))); +struct A { char p[6]; } __attribute__((__packed__ packed)); /* { dg-error "expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr68024.c b/SingleSource/Regression/C/gcc-dg/pr68024.c new file mode 100644 index 0000000000..a750917702 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68024.c @@ -0,0 +1,5 @@ +/* PR c/68024 */ +/* { dg-do compile } */ + +void f (int, ...); +void f (a) int a; {} /* { dg-warning "defined as variadic function without prototype" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr68088_1.c b/SingleSource/Regression/C/gcc-dg/pr68088_1.c new file mode 100644 index 0000000000..49c6aa1454 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68088_1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void bar (unsigned long); + +void +foo (unsigned long aul, unsigned m, unsigned i) +{ + while (1) + { + aul += i; + i = aul % m; + bar (aul); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68090.c b/SingleSource/Regression/C/gcc-dg/pr68090.c new file mode 100644 index 0000000000..87b3b93ed0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68090.c @@ -0,0 +1,13 @@ +/* PR c/68090 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +fn (int i) +{ + (int[(0, 1)]) { 0 }; /* { dg-error "compound literal has variable size" } */ + (int[i]) { 0 }; /* { dg-error "compound literal has variable size" } */ + (int[(0, i)]) { 0 }; /* { dg-error "compound literal has variable size" } */ + (int [][i]){ 0 }; /* { dg-error "compound literal has variable size" } */ + (int [][(1, 2)]){ 0 }; /* { dg-error "compound literal has variable size" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68112.c b/SingleSource/Regression/C/gcc-dg/pr68112.c new file mode 100644 index 0000000000..9c7a59c650 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68112.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Waggressive-loop-optimizations" } */ +/* { dg-require-effective-target int32plus } */ + +int *a; + +void +foo () +{ + for (int i = 0; i < 65536; i++) + *a = i << 24; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68129_1.c b/SingleSource/Regression/C/gcc-dg/pr68129_1.c new file mode 100644 index 0000000000..112331e665 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68129_1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-split-wide-types" } */ + +typedef int V __attribute__ ((vector_size (8 * sizeof (int)))); + +void +foo (V *p, V *q) +{ + *p = (*p == *q); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68134.c b/SingleSource/Regression/C/gcc-dg/pr68134.c new file mode 100644 index 0000000000..522b4c62f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68134.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +#include + +typedef double float64x1_t __attribute__ ((vector_size (8))); +typedef uint64_t uint64x1_t; + +void +foo (void) +{ + float64x1_t arg1 = (float64x1_t) 0x3fedf9d4343c7c80; + float64x1_t arg2 = (float64x1_t) 0x3fcdc53742ea9c40; + uint64x1_t result = (uint64x1_t) (arg1 == arg2); + uint64_t got = result; + uint64_t exp = 0; + if (got != 0) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68162-1.c b/SingleSource/Regression/C/gcc-dg/pr68162-1.c new file mode 100644 index 0000000000..a2c495365f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68162-1.c @@ -0,0 +1,6 @@ +/* Test handling of pointers to arrays of const elements involving a + typedef. PR c/68162. */ + +typedef const double cd; +void f (const double (*)[]); +void g (void) { f ((cd (*)[]) 0); } diff --git a/SingleSource/Regression/C/gcc-dg/pr68193.c b/SingleSource/Regression/C/gcc-dg/pr68193.c new file mode 100644 index 0000000000..2267593e36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68193.c @@ -0,0 +1,15 @@ +/* pr69193 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int +main (void) +{ + int i = 0; + int j = _Generic (i, + int: 0, + long int: (i = (long int) 9223372036854775808UL)); + return i + j; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr68217.c b/SingleSource/Regression/C/gcc-dg/pr68217.c new file mode 100644 index 0000000000..60c8010676 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68217.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1 -fno-tree-ccp" } */ + +int foo (void) +{ + volatile int a = -1; + long long b = (1LL << (sizeof (b) * 8 - 1)); // LLONG_MIN + long long x = (a & b); // x == 0x8000000000000000 + if (x < 1LL) { ; } else { __builtin_abort(); } + return 0; +} + +/* { dg-final { scan-tree-dump "\\\[-INF, -INF\\\]\\\[0, 0\\\]" "vrp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr68286.c b/SingleSource/Regression/C/gcc-dg/pr68286.c new file mode 100644 index 0000000000..d0392e85a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68286.c @@ -0,0 +1,17 @@ +/* PR target/68286 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b, c; +int fn1 () +{ + int d[] = {0}; + for (; c; c++) + { + float e = c; + if (e) + d[0]++; + } + b = d[0]; + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68306-2.c b/SingleSource/Regression/C/gcc-dg/pr68306-2.c new file mode 100644 index 0000000000..4672ebe798 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68306-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */ + +struct { + int tz_minuteswest; + int tz_dsttime; +} a, b; +void fn1() { + b.tz_minuteswest = a.tz_minuteswest; + b.tz_dsttime = a.tz_dsttime; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68306-3.c b/SingleSource/Regression/C/gcc-dg/pr68306-3.c new file mode 100644 index 0000000000..f5a8c102cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68306-3.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mno-altivec -mno-vsx" { target powerpc*-*-* } } */ + +extern void fn2(); +struct { + unsigned qp_num; + unsigned starting_psn; + void *private_data; +} a; +struct { + unsigned id; + unsigned qpn; + unsigned psn; +} b; +void fn1() { + a.qp_num = b.qpn; + a.starting_psn = b.psn; + fn2(b.id); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68306.c b/SingleSource/Regression/C/gcc-dg/pr68306.c new file mode 100644 index 0000000000..54e5b40f22 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68306.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */ + +enum powerpc_pmc_type { PPC_PMC_IBM }; +struct { + unsigned num_pmcs; + enum powerpc_pmc_type pmc_type; +} a; +enum powerpc_pmc_type b; +void fn1() { a.num_pmcs = a.pmc_type = b; } diff --git a/SingleSource/Regression/C/gcc-dg/pr68317.c b/SingleSource/Regression/C/gcc-dg/pr68317.c new file mode 100644 index 0000000000..bd053a7522 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68317.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdisable-tree-ethread" } */ + +/* Note: Threader will collapse loop. */ + +typedef int int32_t __attribute__((mode (__SI__))); + +void bar (int32_t); + +void +foo () +{ + int32_t index = 0; + + for (index; index <= 10; index--) // expected warning here + /* Result of the following multiply will overflow + when converted to signed int32_t. */ + bar ((0xcafe + index) * 0xdead); /* { dg-warning "iteration \[0-9\]+ invokes undefined behavior" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68320.c b/SingleSource/Regression/C/gcc-dg/pr68320.c new file mode 100644 index 0000000000..5d891b9bb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68320.c @@ -0,0 +1,67 @@ +/* PR c/68320 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +fn1 (void) +{ + for (typedef int T;;) + if (1) + ; + T x; /* { dg-error "unknown type name" } */ +} + +void +fn2 (int i) +{ + for (typedef int T;;) + if (1) + i = 5; + T x; /* { dg-error "unknown type name" } */ +} + +void +fn3 (void) +{ + for (typedef int T;;) + if (1) + { + } + T *x; /* { dg-error "unknown type name" } */ +} + +void +fn4 (void) +{ + for (typedef int T;;) + if (1) + ; + T, T; /* { dg-error "undeclared" } */ +} + +void +fn5 (void) +{ + for (typedef int T;;) + if (1) + ; + T = 10; /* { dg-error "undeclared" } */ +} + +void +fn6 (void) +{ + for (typedef int T;;) + if (1) + ; + T[0]; /* { dg-error "undeclared" } */ +} + +void +fn7 (void) +{ + for (typedef int T;;) + if (1) + ; + T (); /* { dg-warning "implicit declaration" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68327.c b/SingleSource/Regression/C/gcc-dg/pr68327.c new file mode 100644 index 0000000000..c3e6a9434a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68327.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, d; +char b, c; + +void +fn1 () +{ + int i = 0; + for (; i < 1; i++) + d = 1; + for (; b; b++) + a = 1 && (d & b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68375.c b/SingleSource/Regression/C/gcc-dg/pr68375.c new file mode 100644 index 0000000000..bbbdd915ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68375.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized-graph" } */ + +int a, c, d, e, g, h; +short f; + +int +foo () +{ +} + +short +fn1 (void) +{ + int j[2]; + for (; e; e++) + if (j[0]) + for (;;) + ; + if (!g) + return f; +} + +int +main (void) +{ + for (; a < 1; a++) + { + for (c = 0; c < 2; c++) + { + d && (f = 0); + h = fn1 (); + } + __builtin_printf ("%d\n", (char) f); + } + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr68412-2.c b/SingleSource/Regression/C/gcc-dg/pr68412-2.c new file mode 100644 index 0000000000..be1dcfa5e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68412-2.c @@ -0,0 +1,15 @@ +/* PR c/68412 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra" } */ + +int +fn1 (int i) +{ + return ({ i; }) == ({ i; }); /* { dg-warning "self-comparison always evaluates to true" } */ +} + +int +fn2 (int i) +{ + return ({ i + 1; }) != ({ i + 1; }); /* { dg-warning "self-comparison always evaluates to false" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68412.c b/SingleSource/Regression/C/gcc-dg/pr68412.c new file mode 100644 index 0000000000..825eb63073 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68412.c @@ -0,0 +1,41 @@ +/* PR c/68412 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra" } */ + +#define M (sizeof (int) * __CHAR_BIT__) + +int +fn1 (int i) +{ + return i == (-1 << 8); /* { dg-warning "left shift of negative value" } */ +} + +int +fn2 (int i) +{ + return i == (1 << M); /* { dg-warning "left shift count" } */ +} + +int +fn3 (int i) +{ + return i == 10 << (M - 1); /* { dg-warning "requires" } */ +} + +int +fn4 (int i) +{ + return i == 1 << -1; /* { dg-warning "left shift count" } */ +} + +int +fn5 (int i) +{ + return i == 1 >> M; /* { dg-warning "right shift count" } */ +} + +int +fn6 (int i) +{ + return i == 1 >> -1; /* { dg-warning "right shift count" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68435.c b/SingleSource/Regression/C/gcc-dg/pr68435.c new file mode 100644 index 0000000000..2c7c8b8dc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68435.c @@ -0,0 +1,53 @@ +/* { dg-do compile { target aarch64*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-fdump-rtl-ce1 -O2 -w --param max-rtl-if-conversion-unpredictable-cost=100" } */ +/* { dg-additional-options "-march=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +typedef struct cpp_reader cpp_reader; +enum cpp_ttype +{ + CPP_EQ = + 0, CPP_NOT, CPP_GREATER, CPP_LESS, CPP_PLUS, CPP_MINUS, CPP_MULT, CPP_DIV, + CPP_MOD, CPP_AND, CPP_OR, CPP_XOR, CPP_RSHIFT, CPP_LSHIFT, CPP_MIN, + CPP_MAX, CPP_COMPL, CPP_AND_AND, CPP_OR_OR, CPP_QUERY, CPP_COLON, + CPP_COMMA, CPP_OPEN_PAREN, CPP_CLOSE_PAREN, CPP_EQ_EQ, CPP_NOT_EQ, + CPP_GREATER_EQ, CPP_LESS_EQ, CPP_PLUS_EQ, CPP_MINUS_EQ, CPP_MULT_EQ, + CPP_DIV_EQ, CPP_MOD_EQ, CPP_AND_EQ, CPP_OR_EQ, CPP_XOR_EQ, CPP_RSHIFT_EQ, + CPP_LSHIFT_EQ, CPP_MIN_EQ, CPP_MAX_EQ, CPP_HASH, CPP_PASTE, + CPP_OPEN_SQUARE, CPP_CLOSE_SQUARE, CPP_OPEN_BRACE, CPP_CLOSE_BRACE, + CPP_SEMICOLON, CPP_ELLIPSIS, CPP_PLUS_PLUS, CPP_MINUS_MINUS, CPP_DEREF, + CPP_DOT, CPP_SCOPE, CPP_DEREF_STAR, CPP_DOT_STAR, CPP_ATSIGN, CPP_NAME, + CPP_NUMBER, CPP_CHAR, CPP_WCHAR, CPP_OTHER, CPP_STRING, CPP_WSTRING, + CPP_HEADER_NAME, CPP_COMMENT, CPP_MACRO_ARG, CPP_PADDING, CPP_EOF, +}; + +static struct op lex (cpp_reader *, int); + +struct op +{ + enum cpp_ttype op; + long value; +}; + +int +_cpp_parse_expr (pfile) +{ + struct op init_stack[20]; + struct op *stack = init_stack; + struct op *top = stack + 1; + int skip_evaluation = 0; + for (;;) + { + struct op op; + op = lex (pfile, skip_evaluation); + switch (op.op) + { + case CPP_OR_OR: + if (top->value) + skip_evaluation++; + else + skip_evaluation--; + } + } +} + +/* { dg-final { scan-rtl-dump "2 true changes made" "ce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr68474.c b/SingleSource/Regression/C/gcc-dg/pr68474.c new file mode 100644 index 0000000000..8ad7def4b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68474.c @@ -0,0 +1,7 @@ +/* { dg-options "-O -funsafe-math-optimizations" } */ + +long double +foo (long double d1, long double d2) +{ + return d1 || __builtin_significandl (d2); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68513.c b/SingleSource/Regression/C/gcc-dg/pr68513.c new file mode 100644 index 0000000000..86f878d5d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68513.c @@ -0,0 +1,125 @@ +/* PR c/68513 */ +/* { dg-do compile } */ +/* { dg-options "-funsafe-math-optimizations -fno-math-errno -O -Wno-div-by-zero" } */ + +int i; +unsigned u; +volatile int *e; + +#define E (i ? *e : 0) + +/* Can't trigger some of them because operand_equal_p will return false + for side-effects. */ + +/* (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x */ +int +fn1 (void) +{ + int r = 0; + r += (short) (E & ~u | i & u); + r += -(short) (E & ~u | i & u); + r += (short) -(E & ~u | i & u); + return r; +} + +/* sqrt(x) < y is x >= 0 && x != +Inf, when y is large. */ +double +fn2 (void) +{ + double r; + r = __builtin_sqrt (E) < __builtin_inf (); + return r; +} + +/* sqrt(x) < c is the same as x >= 0 && x < c*c. */ +double +fn3 (void) +{ + double r; + r = __builtin_sqrt (E) < 1.3; + return r; +} + +/* copysign(x,y)*copysign(x,y) -> x*x. */ +double +fn4 (double y, double x) +{ + return __builtin_copysign (E, y) * __builtin_copysign (E, y); +} + +/* x <= +Inf is the same as x == x, i.e. !isnan(x). */ +int +fn5 (void) +{ + return E <= __builtin_inf (); +} + +/* Fold (A & ~B) - (A & B) into (A ^ B) - B. */ +int +fn6 (void) +{ + return (i & ~E) - (i & E); +} + +/* Fold (A & B) - (A & ~B) into B - (A ^ B). */ +int +fn7 (void) +{ + return (i & E) - (i & ~E); +} + +/* x + (x & 1) -> (x + 1) & ~1 */ +int +fn8 (void) +{ + return E + (E & 1); +} + +/* Simplify comparison of something with itself. */ +int +fn9 (void) +{ + return E <= E | E >= E; +} + +/* Fold (A & ~B) - (A & B) into (A ^ B) - B. */ +int +fn10 (void) +{ + return (i & ~E) - (i & E); +} + +/* abs(x)*abs(x) -> x*x. Should be valid for all types. */ +int +fn11 (void) +{ + return __builtin_abs (E) * __builtin_abs (E); +} + +/* (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) */ +int +fn12 (void) +{ + return (E | 11) & 12; +} + +/* fold_range_test */ +int +fn13 (const char *s) +{ + return s[E] != '\0' && s[E] != '/'; +} + +/* fold_comparison */ +int +fn14 (void) +{ + return (!!i ? : (u *= E / 0)) >= (u = E); +} + +/* fold_mult_zconjz */ +_Complex int +fn15 (_Complex volatile int *z) +{ + return *z * ~*z; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68533.c b/SingleSource/Regression/C/gcc-dg/pr68533.c new file mode 100644 index 0000000000..49e67a9616 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68533.c @@ -0,0 +1,68 @@ +/* PR c/68533 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct T { int t; }; + +void +f1 ( + struct S * /* { dg-warning "declared inside parameter list will not be visible outside of this definition or declaration" } */ + x, + struct T * + y + ) +{ + y->t = 4; +} + +void +f2 ( + struct {int s;} * /* { dg-warning "anonymous struct declared inside parameter list will not be visible outside of this definition or declaration" } */ + x, + struct T * + y + ) +{ + y->t = 5; +} + +void +f3 ( + const void /* { dg-error "'void' as only parameter may not be qualified" } */ + ) +{ +} + +void +f4 ( + void, /* { dg-error "'void' must be the only parameter" } */ + ... + ) +{ +} + +void +f5 ( + int + x; /* { dg-error "parameter 'x' has just a forward declaration" } */ + int y + ) +{ +} + +void +f6 ( + int + x, + void /* { dg-error "'void' must be the only parameter" } */ + ) +{ +} + +void +f7 ( + void, /* { dg-error "'void' must be the only parameter" } */ + int y + ) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68595.c b/SingleSource/Regression/C/gcc-dg/pr68595.c new file mode 100644 index 0000000000..179c6c352d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68595.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b; +char c; +void fn1() { + b = 30; + for (; b <= 32; b++) { + c = -17; + for (; c <= 56; c++) + a -= 0 == (c || b); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68668.c b/SingleSource/Regression/C/gcc-dg/pr68668.c new file mode 100644 index 0000000000..d013aa92ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68668.c @@ -0,0 +1,53 @@ +/* PR c/68668 */ +/* { dg-do compile } */ + +typedef const int T[]; +typedef const int U[1]; + +int +fn1 (T p) +{ + return p[0]; +} + +int +fn2 (U p[2]) +{ + return p[0][0]; +} + +int +fn3 (U p[2][3]) +{ + return p[0][0][0]; +} + +int +fn4 (U *p) +{ + return p[0][0]; +} + +int +fn5 (U (*p)[1]) +{ + return (*p)[0][0]; +} + +int +fn6 (U (*p)[1][2]) +{ + return (*p)[0][0][0]; +} + +int +fn7 (U **p) +{ + return p[0][0][0]; +} + +int +fn8 (U (**p)[1]) +{ + return (*p)[0][0][0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68670-1.c b/SingleSource/Regression/C/gcc-dg/pr68670-1.c new file mode 100644 index 0000000000..cc59402ea2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68670-1.c @@ -0,0 +1,5 @@ +/* PR rtl-optimization/68670 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftracer" } */ + +#include "../gcc-c-torture/execute/pr68376-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr68670-2.c b/SingleSource/Regression/C/gcc-dg/pr68670-2.c new file mode 100644 index 0000000000..7ec40a1805 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68670-2.c @@ -0,0 +1,5 @@ +/* PR rtl-optimization/68670 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftracer" } */ + +#include "../gcc-c-torture/execute/pr68376-2.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr68671.c b/SingleSource/Regression/C/gcc-dg/pr68671.c new file mode 100644 index 0000000000..bec4639f80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68671.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/68671 */ +/* { dg-do run } */ +/* { dg-options " -O2 -fno-tree-dce" } */ + +volatile int a = -1; +volatile int b; + +static inline int +fn1 (signed char p1, int p2) +{ + return (p1 < 0) || (p1 > (1 >> p2)) ? 0 : (p1 << 1); +} + +int +main () +{ + signed char c = a; + b = fn1 (c, 1); + c = ((128 | c) < 0 ? 1 : 0); + if (c != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68730.c b/SingleSource/Regression/C/gcc-dg/pr68730.c new file mode 100644 index 0000000000..8ec6f19ca5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68730.c @@ -0,0 +1,51 @@ +/* PR rtl-optimization/68730 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-if-conversion" } */ +/* { dg-additional-options "-march=x86-64" { target { i?86-*-* x86_64-*-* } } } */ + +int b, d, e; +unsigned long long c = 4100543410106915; + +void +foo (void) +{ + short f, g = 4 % c; + int h = c; + if (h) + { + int i = ~c; + if (~c) + i = 25662; + f = g = i; + h = c - g + ~-f; + c = ~(c * h - f); + } + f = g; + unsigned long long k = g || c; + short l = c ^ g ^ k; + if (g > 25662 || c == 74074520320 || !(g < 2)) + { + k = c; + l = g; + c = ~((k && c) + ~l); + f = ~(f * (c ^ k) | l); + if (c > k) + __builtin_printf ("%d\n", f); + } + short m = -f; + unsigned long long n = c; + c = m * f | n % c; + if (n) + __builtin_printf ("%d\n", f); + while (f < -31807) + ; + c = ~(n | c) | f; + if (n < c) + __builtin_printf ("%lld\n", (long long) f); + for (; d;) + for (; e;) + for (;;) + ; + c = h; + c = l % c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68766.c b/SingleSource/Regression/C/gcc-dg/pr68766.c new file mode 100644 index 0000000000..82b54d4743 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68766.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize -fdbg-cnt=vect_loop:1" } */ +/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-prune-output "\\*\\*\\*dbgcnt:.*limit.*reached" } */ + +int a, b, g, h; +int c[58]; +int d[58]; +int fn1() { + for (; g; g++) + if (a) + c[g] = b; +} + +int fn2() { + fn1(); + for (; h; h++) + d[h] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68785.c b/SingleSource/Regression/C/gcc-dg/pr68785.c new file mode 100644 index 0000000000..f4257da4dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68785.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/68785 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int +foo (void) +{ + return *(int *) ""; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68835-1.c b/SingleSource/Regression/C/gcc-dg/pr68835-1.c new file mode 100644 index 0000000000..47aebe3c1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68835-1.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/68835 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2" } */ + +unsigned __int128 +foo (unsigned long a, unsigned long b) +{ + unsigned __int128 x = (unsigned __int128) a * b; + struct { unsigned __int128 a : 96; } w; + w.a = x; + return w.a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68835-2.c b/SingleSource/Regression/C/gcc-dg/pr68835-2.c new file mode 100644 index 0000000000..dd355b1722 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68835-2.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/68835 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2" } */ + +__attribute__((noinline, noclone)) unsigned __int128 +foo (void) +{ + unsigned __int128 x = (unsigned __int128) 0xffffffffffffffffULL; + struct { unsigned __int128 a : 65; } w; + w.a = x; + w.a += x; + return w.a; +} + +int +main () +{ + unsigned __int128 x = foo (); + if ((unsigned long long) x != 0xfffffffffffffffeULL + || (unsigned long long) (x >> 64) != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68841.c b/SingleSource/Regression/C/gcc-dg/pr68841.c new file mode 100644 index 0000000000..470048cc24 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68841.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-Og -fif-conversion -flive-range-shrinkage -fpeel-loops -frerun-cse-after-loop" } */ + +static inline int +foo (int *x, int y) +{ + int z = *x; + while (y > z) + z *= 2; + return z; +} + +int +main () +{ + int i; + for (i = 1; i < 17; i++) + { + int j; + int k; + j = foo (&i, 7); + if (i >= 7) + k = i; + else if (i >= 4) + k = 8 + (i - 4) * 2; + else if (i == 3) + k = 12; + else + k = 8; + if (j != k) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr68907.c b/SingleSource/Regression/C/gcc-dg/pr68907.c new file mode 100644 index 0000000000..de1c237b82 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr68907.c @@ -0,0 +1,14 @@ +/* PR c/60195 */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wpedantic -Wall" } */ + +_Atomic int a; + +void +fn (void) +{ + ++a; + a++; + --a; + a--; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69015.c b/SingleSource/Regression/C/gcc-dg/pr69015.c new file mode 100644 index 0000000000..9e75db9d0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69015.c @@ -0,0 +1,10 @@ +/* PR target/69015 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-if-conversion" } */ + +void +foo (int c) +{ + if (c) + __builtin_trap (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69032.c b/SingleSource/Regression/C/gcc-dg/pr69032.c new file mode 100644 index 0000000000..e0925cd8c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69032.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fsched-pressure -fsel-sched-pipelining -fselective-scheduling" } */ + +void foo (long long i) +{ + while (i != -1) + { + ++i; + __asm__ (""); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69047.c b/SingleSource/Regression/C/gcc-dg/pr69047.c new file mode 100644 index 0000000000..d562663d86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69047.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-forwprop4" } */ + +__UINT8_TYPE__ +f(__UINT16_TYPE__ b) +{ + __UINT8_TYPE__ a; +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + __builtin_memcpy(&a, &b, sizeof a); +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + __builtin_memcpy(&a, (char *)&b + sizeof a, sizeof a); +#else + a = b; +#endif + return a; +} + +/* { dg-final { scan-tree-dump "_\[0-9\]+ = \\(\[^)\]+\\) b" "forwprop4" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr69070.c b/SingleSource/Regression/C/gcc-dg/pr69070.c new file mode 100644 index 0000000000..f8a82e5cd1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69070.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/69070 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsignaling-nans" } */ + +double +foo (double d) +{ + return __builtin_pow (d, 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69071.c b/SingleSource/Regression/C/gcc-dg/pr69071.c new file mode 100644 index 0000000000..3ae38112fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69071.c @@ -0,0 +1,23 @@ +/* PR target/69071 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ +/* { dg-require-effective-target size20plus } */ + +void *bar (void *); + +void +foo (int c) +{ + unsigned char bf[65400]; + unsigned char *p2 = bar (bf); + unsigned char *p3 = bar (bf); + for (; *p2; p2++, c++) + { + if (c) + { + short of = p2 - bf - 6; + unsigned ofu = of; + __builtin_memcpy (p3, &ofu, sizeof (ofu)); + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69097-1.c b/SingleSource/Regression/C/gcc-dg/pr69097-1.c new file mode 100644 index 0000000000..0c20764128 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69097-1.c @@ -0,0 +1,140 @@ +/* PR tree-optimization/69097 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* All the x % -y below should be optimized into x % y, as + it should never be INT_MIN % -(-1). */ +/* { dg-final { scan-tree-dump-not "-y" "optimized" } } */ + +int +f1 (int x, int y) +{ + if (x == -__INT_MAX__ - 1) + __builtin_unreachable (); + return x % -y; +} + +int +f2 (int x, int y) +{ + if (x < -__INT_MAX__) + __builtin_unreachable (); + return x % -y; +} + +int +f3 (int x, int y) +{ + if (y == -1) + __builtin_unreachable (); + return x % -y; +} + +int +f4 (int x, int y) +{ + if (y < 0) + __builtin_unreachable (); + return x % -y; +} + +int +f5 (int x, int y) +{ + if (y >= -1) + __builtin_unreachable (); + return x % -y; +} + +int +f6 (int x, int y) +{ + if (y < 0 || y > 24) + __builtin_unreachable (); + return x % -y; +} + +int +f7 (int x, int y) +{ + if (y <= -17 || y >= -1) + __builtin_unreachable (); + return x % -y; +} + +int +f8 (int x, int y) +{ + if (y >= -13 && y <= 15) + __builtin_unreachable (); + return x % -y; +} + +int +f9 (int x, int y) +{ + return x % -(y & ~4); +} + +int +f10 (int x, int y) +{ + if (x != -__INT_MAX__ - 1) + return x % -y; + return 34; +} + +int +f11 (int x, int y) +{ + if (x >= -__INT_MAX__) + return x % -y; + return 34; +} + +int +f12 (int x, int y) +{ + if (y != -1) + return x % -y; + return 34; +} + +int +f13 (int x, int y) +{ + if (y >= 0) + return x % -y; + return 34; +} + +int +f14 (int x, int y) +{ + if (y < -1) + return x % -y; + return 34; +} + +int +f15 (int x, int y) +{ + if (y >= 0 && y <= 24) + return x % -y; + return 34; +} + +int +f16 (int x, int y) +{ + if (y > -17 && y < -1) + return x % -y; + return 34; +} + +int +f17 (int x, int y) +{ + if (y < -13 || y > 15) + return x % -y; + return 34; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69097-2.c b/SingleSource/Regression/C/gcc-dg/pr69097-2.c new file mode 100644 index 0000000000..bf7ac0eb07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69097-2.c @@ -0,0 +1,138 @@ +/* PR tree-optimization/69097 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "-y" 17 "optimized" } } */ + +int +f1 (int x, int y) +{ + if (x == -__INT_MAX__) + __builtin_unreachable (); + return x % -y; +} + +int +f2 (int x, int y) +{ + if (x >= -__INT_MAX__ + 1) + __builtin_unreachable (); + return x % -y; +} + +int +f3 (int x, int y) +{ + if (y == -2) + __builtin_unreachable (); + return x % -y; +} + +int +f4 (int x, int y) +{ + if (y < -1) + __builtin_unreachable (); + return x % -y; +} + +int +f5 (int x, int y) +{ + if (y >= 0) + __builtin_unreachable (); + return x % -y; +} + +int +f6 (int x, int y) +{ + if (y < -1 || y > 24) + __builtin_unreachable (); + return x % -y; +} + +int +f7 (int x, int y) +{ + if (y <= -17 || y >= 0) + __builtin_unreachable (); + return x % -y; +} + +int +f8 (int x, int y) +{ + if (y >= -13 && y <= -2) + __builtin_unreachable (); + return x % -y; +} + +int +f9 (int x, int y) +{ + return x % -y; +} + +int +f10 (int x, int y) +{ + if (x != -__INT_MAX__) + return x % -y; + return 34; +} + +int +f11 (int x, int y) +{ + if (x < -__INT_MAX__ + 2) + return x % -y; + return 34; +} + +int +f12 (int x, int y) +{ + if (y != -2) + return x % -y; + return 34; +} + +int +f13 (int x, int y) +{ + if (y >= -1) + return x % -y; + return 34; +} + +int +f14 (int x, int y) +{ + if (y < 0) + return x % -y; + return 34; +} + +int +f15 (int x, int y) +{ + if (y >= -1 && y <= 24) + return x % -y; + return 34; +} + +int +f16 (int x, int y) +{ + if (y > -17 && y < 0) + return x % -y; + return 34; +} + +int +f17 (int x, int y) +{ + if (y < -13 || y > -4) + return x % -y; + return 34; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69156.c b/SingleSource/Regression/C/gcc-dg/pr69156.c new file mode 100644 index 0000000000..522ac00be4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69156.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/69156 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-ccp" } */ + +_Bool +foo () +{ + _Bool (*f) () = __builtin_abs; /* { dg-warning "initialization of '_Bool \\(\\*\\)\\(\\)' from pointer to .__builtin_abs. with incompatible type .int \\\(\\\*\\\)." } */ + return f (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69162.c b/SingleSource/Regression/C/gcc-dg/pr69162.c new file mode 100644 index 0000000000..45644bd2fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69162.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/69162 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +int +foo (void *a) +{ + va_list *b = a; + return va_arg (*b, int); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69167.c b/SingleSource/Regression/C/gcc-dg/pr69167.c new file mode 100644 index 0000000000..bda02263d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69167.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/69167 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int sigsetjmp (char *); +void foo (); +void bar (void (*) (int *)); +extern char t[]; + +void +baz (int *x) +{ + int *a = x; + foo (); + x = 0; + if (sigsetjmp (t)) + while (1) + bar (a ? baz : 0); + if (x) + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69169.c b/SingleSource/Regression/C/gcc-dg/pr69169.c new file mode 100644 index 0000000000..ecf847cba1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69169.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct pgm_slist_t +{ + struct pgm_slist_t *__restrict next; +}; + +void +fn1 (struct pgm_slist_t p1) +{ + +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69172.c b/SingleSource/Regression/C/gcc-dg/pr69172.c new file mode 100644 index 0000000000..908d5a6e47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69172.c @@ -0,0 +1,50 @@ +/* PR tree-optimization/69172 - ICE in make_ssa_name_fn, + at tree-ssanames.c:266 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a; + +void * +f1 (void) +{ + int *b = &a, *c = &a; + return __builtin___mempcpy_chk (b, c, sizeof (int), 0); +} + +void * +f2 (void) +{ + int *b = &a; + return __builtin___mempcpy_chk (b, b, sizeof (int), 0); +} + +void * +f3 (void) +{ + return __builtin___mempcpy_chk (&a, &a, sizeof (int), 0); +} + +void * +f4 (int x) +{ + int *b = &a, *c = &a; + return __builtin___mempcpy_chk (b, c, x, 0); +} + +void * +f5 (int x) +{ + int *b = &a; + return __builtin___mempcpy_chk (b, b, x, 0); +} + +void * +f6 (int x) +{ + return __builtin___mempcpy_chk (&a, &a, x, 0); +} + +/* The calls above violate strict aliasing. Eliminate the -Wrestrict + warnings they trigger. + { dg-prune-output "\\\[-Wrestrict]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr69181-1.c b/SingleSource/Regression/C/gcc-dg/pr69181-1.c new file mode 100644 index 0000000000..e851f0c8a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69181-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target this_will_not_be_matched-*-* } } */ + +/* { dg-begin-multiline-output "" } + This message should never be checked for. + In particular, it shouldn't be checked for in the *next* + test case. + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr69181-2.c b/SingleSource/Regression/C/gcc-dg/pr69181-2.c new file mode 100644 index 0000000000..dca90dcbf1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69181-2.c @@ -0,0 +1,4 @@ +/* Dummy test case, to verify that the dg-begin-multiline-output directive + from pr69181-1.c isn't erroneously expected to be handled in *this* + test case. */ +int make_non_empty; diff --git a/SingleSource/Regression/C/gcc-dg/pr69195.c b/SingleSource/Regression/C/gcc-dg/pr69195.c new file mode 100644 index 0000000000..af373a1223 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69195.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-dce -fno-forward-propagate" } */ + +void __attribute__ ((noinline, noclone)) +foo (int *a, int n) +{ + int *lasta = a + n; + for (; a != lasta; a++) + { + *a *= 2; + a[1] = a[-1] + a[-2]; + } +} + +int +main () +{ + int a[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + int r[16] = { 1, 2, 6, 6, 16, 24, 44, 80, + 136, 248, 432, 768, 1360, 2400, 4256, 3760 }; + unsigned i; + foo (&a[2], 13); + for (i = 0; i < 8; ++i) + if (a[i] != r[i]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69224.c b/SingleSource/Regression/C/gcc-dg/pr69224.c new file mode 100644 index 0000000000..606b7fee2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69224.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ + +struct S { + int a; + int b; + int c; + int d; + int e; + float x[5]; + float y[5]; // Comment these two lines out to + float z[5 - 1]; // remove the warning +}; +void f(struct S *s, float a[], float **b, float c[]) { + if ((s->b == 1) && (s->d > 0)) { + for (int i = 0; i < s->a; i++) { + if (a[i] != 0.0) { + for (int j = 0; j < s->d - 1; j++) { + if ((c[i] >= s->x[j]) && (c[i] <= s->x[j + 1])) { + b[2*j][i] = s->x[j]; + break; + } + } + } + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69238.c b/SingleSource/Regression/C/gcc-dg/pr69238.c new file mode 100644 index 0000000000..3538e63442 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69238.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-dce -fno-forward-propagate -fno-rerun-cse-after-loop -funroll-loops" } */ + + +#define N 32 + +short sa[N]; +short sb[N]; +int ia[N]; +int ib[N]; + +int __attribute__ ((noinline, noclone)) +main1 (int n) +{ + int i; + for (i = 0; i < n; i++) + { + sa[i+7] = sb[i]; + ia[i+3] = ib[i+1]; + } + return 0; +} + +int +main (void) +{ + return main1 (N-7); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69247.c b/SingleSource/Regression/C/gcc-dg/pr69247.c new file mode 100644 index 0000000000..b7406e6822 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69247.c @@ -0,0 +1,14 @@ +/* PR target/69247 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-march=zEC12" { target s390*-*-* } } */ + +void foo (short *); + +void +bar (short x, int y) +{ + if (y) + x = x << 8 | (unsigned short) x >> 8; + foo (&x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69307.c b/SingleSource/Regression/C/gcc-dg/pr69307.c new file mode 100644 index 0000000000..d9d343e973 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69307.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fselective-scheduling2" } */ + +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long int uint64_t; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +u64 __attribute__((noinline, noclone)) +foo(u8 u8_0, u16 u16_0, u32 u32_0, u64 u64_0, u8 u8_1, u16 u16_1, u32 u32_1, u64 u64_1, u8 u8_2, u16 u16_2, u32 u32_2, u64 u64_2, u8 u8_3, u16 u16_3, u32 u32_3, u64 u64_3) +{ + u8 *p8_2 = &u8_2; + u16 *p16_2 = &u16_2; + u8 *p8_3 = &u8_3; + u64 *p64_3 = &u64_3; + p8_2 = &u8_3; + *p8_3 -= *p64_3; + *p8_2 = (u64)*p8_2 % ((u64)*p8_2 | 3); + u8_2 = (u64)u8_2 / ((u64)*p16_2 | 1); + u16_0 = (u64)u16_0 % ((u64)*p8_2 | 3); + return u8_0 + u16_0 + u32_0 + u64_0 + u8_1 + u16_1 + u32_1 + u64_1 + u8_2 + u16_2 + u32_2 + u64_2 + u8_3 + u16_3 + u32_3 + u64_3; +} +int main() +{ + u64 x = 0; + x += foo(3llu, 6llu, 15llu, 28llu, 5llu, 11llu, 20llu, 44llu, 7llu, 10llu, 20llu, 55llu, 0llu, 9llu, 17llu, 48llu); + if (x != 0x1f3) + __builtin_abort(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr69328.c b/SingleSource/Regression/C/gcc-dg/pr69328.c new file mode 100644 index 0000000000..a495596cf6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69328.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b; +void fn1() { + int c; + char *d; + for (; a; ++a) { + int e, f; + e = d[a]; + if (!e && f || !f && e) + ++c; + } + if (c) + b = .499; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69391-1.c b/SingleSource/Regression/C/gcc-dg/pr69391-1.c new file mode 100644 index 0000000000..15e49dc657 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69391-1.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftrack-macro-expansion=0" } */ +#define STR_I(X) #X +#define STR(X) STR_I(X) +#define LINE STR(__LINE__) STR(__LINE__) +int main() +{ + const char *s = LINE; + if (s[0] != '8' || s[1] != '8') + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69391-2.c b/SingleSource/Regression/C/gcc-dg/pr69391-2.c new file mode 100644 index 0000000000..7d2faae50d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69391-2.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftrack-macro-expansion=1" } */ +#define STR_I(X) #X +#define STR(X) STR_I(X) +#define LINE STR(__LINE__) STR(__LINE__) +int main() +{ + const char *s = LINE; + if (s[0] != '8' || s[1] != '8') + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69421.c b/SingleSource/Regression/C/gcc-dg/pr69421.c new file mode 100644 index 0000000000..252e22c185 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69421.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +struct A { double a; }; +double a; + +void +foo (_Bool *x) +{ + long i; + for (i = 0; i < 64; i++) + { + struct A c; + x[i] = c.a || a; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69442.c b/SingleSource/Regression/C/gcc-dg/pr69442.c new file mode 100644 index 0000000000..ee75f92951 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69442.c @@ -0,0 +1,23 @@ +/* PR target/69442 */ +/* { dg-do run } */ +/* { dg-options "-Og" } */ + +unsigned long long __attribute__ ((noinline, noclone)) +foo (unsigned int x, unsigned long long y) +{ + x |= 0xffff; + y -= 0xffULL; + y %= 0xffff0000ffffffe7ULL; + return x + y; +} + +int +main () +{ + if (sizeof (unsigned long long) * __CHAR_BIT__ != 64) + return 0; + + if (foo (0, 0) != 0xffff0000ff19ULL) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69471-1.c b/SingleSource/Regression/C/gcc-dg/pr69471-1.c new file mode 100644 index 0000000000..3eac3b5bdb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69471-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-implicit-function-declaration -Wno-int-conversion -fno-builtin-free -fno-builtin-malloc" } */ + +void * +foo (void * p) +{ + free (p); + return malloc (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69483.c b/SingleSource/Regression/C/gcc-dg/pr69483.c new file mode 100644 index 0000000000..2ab9dc345e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69483.c @@ -0,0 +1,6 @@ +/* PR tree-optimization/69483 */ +/* { dg-do compile } */ + +struct T { struct S *a; }; +struct S b; /* { dg-error "storage size of 'b' isn't known" } */ +struct T c = { &b }; diff --git a/SingleSource/Regression/C/gcc-dg/pr69522.c b/SingleSource/Regression/C/gcc-dg/pr69522.c new file mode 100644 index 0000000000..820168d221 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69522.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ +struct str {}; +struct { + struct str b; + float c[1]; + int d[1]; + float e[2]; + int f[1]; +} a = {{}, 0, {0.5}, 0, 0, {0}}; diff --git a/SingleSource/Regression/C/gcc-dg/pr69535.c b/SingleSource/Regression/C/gcc-dg/pr69535.c new file mode 100644 index 0000000000..4b4dad154d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69535.c @@ -0,0 +1,36 @@ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O -fno-tree-bit-ccp -fno-tree-reassoc" } */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +typedef unsigned __int128 u128; + +void __attribute__((noinline, noclone)) +dirtify_stack(void) +{ + volatile char a[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; +} + +u128 __attribute__ ((noinline, noclone)) +foo(u32 u32_1, u64 u64_1, u128 u128_1, u8 u8_2, u16 u16_2, u32 u32_2, u8 u8_3) +{ + u128_1 /= ~u128_1 | 1; + u8_3 = ((u8_3 << 2) >> 1) << 7; + u32_2 >>= u8_3; + return u128_1 + u32_2 + u8_3; +} + +int +main () +{ + dirtify_stack(); + u128 x = foo(1, 1, 1, 1, 1, 1, 0); + if (x != 1) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69543.c b/SingleSource/Regression/C/gcc-dg/pr69543.c new file mode 100644 index 0000000000..0bb5da0aae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69543.c @@ -0,0 +1,18 @@ +/* PR preprocessor/69543 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") + +void test (char yylval) +{ + char *yyvsp; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69554-1.c b/SingleSource/Regression/C/gcc-dg/pr69554-1.c new file mode 100644 index 0000000000..b979b5596f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69554-1.c @@ -0,0 +1,175 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +/* Various versions of the same C error, with a variety of line spacing, + and of columns, to exercise the line-span handling in + diagnostic-show-locus.c (PR other/69554). */ + +/* All on one line. */ + +int test_1 (const char *p, const char *q) +{ + return (p + 1) + (q + 1); /* { dg-error "invalid operands" } */ +/* { dg-begin-multiline-output "" } + return (p + 1) + (q + 1); + ~~~~~~~ ^ ~~~~~~~ + | | + | const char * + const char * + { dg-end-multiline-output "" } */ +} + +/* On separate lines, but without intervening lines. + This can be printed as a single span of lines. */ + +int test_2 (const char *p, const char *q) +{ + return (p + 1) + + /* { dg-error "invalid operands" } */ + (q + 1); +/* { dg-begin-multiline-output "" } + return (p + 1) + ~~~~~~~ + | + const char * + + + ^ + (q + 1); + ~~~~~~~ + | + const char * + { dg-end-multiline-output "" } */ +} + +/* On separate lines, with an intervening line between lines 1 and 2. + This is printed as 2 "spans" of lines, broken up by the intervening + line. */ + +int test_3 (const char *p, const char *q) +{ + return (p + 1) /* { dg-locus "10" } */ + + + /* { dg-error "invalid operands" } */ + (q + 1); +/* { dg-locus "12" "" { target *-*-* } "51" } */ +/* { dg-begin-multiline-output "" } + return (p + 1) + ~~~~~~~ + | + const char * + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + + + ^ + (q + 1); + ~~~~~~~ + | + const char * + { dg-end-multiline-output "" } */ +} + +/* As above, but the intervening line is between lines 2 and 3, + so that the 2 spans are grouped the other way. */ + +int test_4 (const char *p, const char *q) +{ + return (p + 1) + + /* { dg-error "invalid operands" } */ + + (q + 1); /* { dg-locus "14" } */ +/* { dg-begin-multiline-output "" } + return (p + 1) + ~~~~~~~ + | + const char * + + + ^ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + (q + 1); + ~~~~~~~ + | + const char * + { dg-end-multiline-output "" } */ +} + +/* On separate lines, with intervening lines. + This is printed as 3 "spans" of lines, each span being an + individual line. */ + +int test_5 (const char *p, const char *q) +{ + return (p + 1) /* { dg-locus "10" } */ + + + /* { dg-error "invalid operands" } */ + + (q + 1); /* { dg-locus "14" } */ +/* { dg-locus "12" "" { target *-*-* } "103" } */ +/* { dg-begin-multiline-output "" } + return (p + 1) + ~~~~~~~ + | + const char * + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + + + ^ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + (q + 1); + ~~~~~~~ + | + const char * + { dg-end-multiline-output "" } */ +} + +/* On separate lines, with numerous intervening lines. + This is printed as 3 "spans" of lines, each span being an + individual line. */ + +int test_6 (const char *p, const char *q) +{ + return (p + 1) /* { dg-locus "10" } */ + /* Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Maecenas nisl sapien, rutrum non euismod et, rutrum ac felis. + Morbi nec nisi ipsum. Quisque pulvinar ante nec urna rhoncus, + a cursus nisi commodo. Praesent euismod neque lectus, at + dapibus ipsum gravida in. Pellentesque tempor massa eu viverra + feugiat. Proin eleifend pulvinar urna, ut dapibus metus vehicula + ac. Suspendisse rutrum finibus quam, ac dignissim diam blandit + maximus. In blandit viverra pulvinar. Praesent vel tellus + elementum, placerat lacus quis, ornare lectus. Donec ac + eleifend nulla, sit amet condimentum risus. Vestibulum aliquam + maximus ante non pellentesque. Praesent mollis ante in risus + feugiat hendrerit. Praesent feugiat maximus urna nec blandit. */ + + /* { dg-error "invalid operands" } */ + /* Vestibulum ac nunc eget enim tempor tristique. Suspendisse + potenti. Nam et sollicitudin enim. Morbi sed tincidunt lectus. + Sed facilisis velit at ante maximus feugiat. Sed vestibulum mi + id leo tempor, sed ullamcorper sapien efficitur. Vestibulum purus + lacus, dignissim non magna at, tincidunt luctus nisl. Cum sociis + natoque penatibus et magnis dis parturient montes, nascetur + ridiculus mus. Donec elit elit, laoreet a dolor quis, eleifend + dapibus metus. Proin lectus turpis, eleifend nec pharetra eu, + fermentum in lacus. Morbi sit amet mauris orci. Nam sagittis, + nibh vel fermentum dictum, purus ex hendrerit odio, feugiat + fringilla sapien elit vitae nisl. Fusce mattis commodo risus + nec convallis. */ + (q + 1); /* { dg-locus "14" } */ +/* { dg-locus "12" "" { target *-*-* } "144" } */ +/* { dg-begin-multiline-output "" } + return (p + 1) + ~~~~~~~ + | + const char * + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + + + ^ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + (q + 1); + ~~~~~~~ + | + const char * + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69592.c b/SingleSource/Regression/C/gcc-dg/pr69592.c new file mode 100644 index 0000000000..c791fe9fd2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69592.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/69592 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned int +foo (unsigned int a, unsigned int *b, unsigned int c) +{ + unsigned int d; +#define A(n) d = a + b[n]; if (d < a) c++; a = d; +#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) A(n##8) A(n##9) +#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) B(n##8) B(n##9) +#define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7) C(n##8) C(n##9) +#define E(n) D(n##0) D(n##1) D(n##2) D(n##3) D(n##4) D(n##5) D(n##6) D(n##7) D(n##8) D(n##9) + C(1) C(2) C(3) C(4) C(5) C(6) + return d + c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69615.c b/SingleSource/Regression/C/gcc-dg/pr69615.c new file mode 100644 index 0000000000..43ecf6bd05 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69615.c @@ -0,0 +1,37 @@ +/* PR tree-optimization/69615 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-not " >= 0" "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < 0" "optimized" } } */ +/* { dg-final { scan-tree-dump-not " <= 23" "optimized" } } */ +/* { dg-final { scan-tree-dump-not " > 23" "optimized" } } */ + +extern void foo (void); + +void +f1 (int x) +{ + if (x >= 0 && x <= __INT_MAX__ - 1) + foo (); +} + +void +f2 (int x, int y) +{ + if (x >= 0 && y && x <= __INT_MAX__ - 1) + foo (); +} + +void +f3 (int x) +{ + if (x > -__INT_MAX__ - 1 && x <= 23) + foo (); +} + +void +f4 (int x, int y) +{ + if (x > -__INT_MAX__ - 1 && y && x <= 23) + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69619.c b/SingleSource/Regression/C/gcc-dg/pr69619.c new file mode 100644 index 0000000000..a200bdf310 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69619.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b, c, d; +int e[100]; +void +fn1 () +{ + int *f = &d; + c = 6; + for (; c; c--) + { + b = 0; + for (; b <= 5; b++) + { + short g = e[(b + 2) * 9 + c]; + *f = *f == a && e[(b + 2) * 9 + c]; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69627.c b/SingleSource/Regression/C/gcc-dg/pr69627.c new file mode 100644 index 0000000000..bc48bb1aa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69627.c @@ -0,0 +1,31 @@ +/* PR c/69627 */ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-show-caret" } */ + +void +foo () +{ + float t[2] = { 1, 2 }; + int const *s = 0; + t[1] / s; /* { dg-error "invalid operands to binary /" } */ +/* { dg-begin-multiline-output "" } + t[1] / s; + ~~~~ ^ + | + float + { dg-end-multiline-output "" } */ +} + +void +bar () +{ + float t[2] = { 1, 2 }; + int const *s[2] = { 0, 0 }; + t[1] / s[0]; /* { dg-error "invalid operands to binary /" } */ +/* { dg-begin-multiline-output "" } + t[1] / s[0]; + ~~~~ ^ ~~~~ + | | + float const int * + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69634.c b/SingleSource/Regression/C/gcc-dg/pr69634.c new file mode 100644 index 0000000000..60a5614946 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69634.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-dce -fschedule-insns -fno-tree-vrp -fcompare-debug -Wno-psabi" } */ +/* { dg-additional-options "-mno-sse" { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target scheduling } */ + +typedef unsigned short u16; +typedef short v16u16 __attribute__ ((vector_size (16))); +typedef unsigned v16u32 __attribute__ ((vector_size (16))); +typedef unsigned long long v16u64 __attribute__ ((vector_size (16))); + +u16 +foo(u16 u16_1, v16u16 v16u16_0, v16u32 v16u64_0, v16u16 v16u16_1, v16u32 v16u32_1, v16u64 v16u64_1) +{ + v16u64_1 /= (v16u64){~v16u32_1[1]}; + u16_1 = 0; + u16_1 /= v16u32_1[2]; + v16u64_1 -= (v16u64) v16u16_1; + u16_1 >>= 1; + u16_1 -= ~0; + v16u16_1 /= (v16u16){~u16_1, 1 - v16u64_0[0], 0xffb6}; + return u16_1 + v16u16_0[1] + v16u16_1[3] + v16u64_1[0] + v16u64_1[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69644.c b/SingleSource/Regression/C/gcc-dg/pr69644.c new file mode 100644 index 0000000000..c60b191702 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69644.c @@ -0,0 +1,11 @@ +/* PR target/69644 */ +/* { dg-do compile } */ + +int +main () +{ + unsigned short x = 0x8000; + if (!__sync_bool_compare_and_swap (&x, 0x8000, 0) || x) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69650.c b/SingleSource/Regression/C/gcc-dg/pr69650.c new file mode 100644 index 0000000000..decdb89a0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69650.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +# 9 "somefile" 2 /* { dg-warning "linemarker ignored due to incorrect nesting" } */ +not_a_type a; /* { dg-error "unknown type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr69733.c b/SingleSource/Regression/C/gcc-dg/pr69733.c new file mode 100644 index 0000000000..b4f4621a52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69733.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-W -fdiagnostics-show-caret" } */ + +double val; + +_Atomic double val0() {return val;} /* { dg-warning "qualifiers ignored" } */ +/* { dg-begin-multiline-output "" } + _Atomic double val0() {return val;} + ^~~~~~~ +{ dg-end-multiline-output "" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr69796.c b/SingleSource/Regression/C/gcc-dg/pr69796.c new file mode 100644 index 0000000000..4b725a5076 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69796.c @@ -0,0 +1,10 @@ +/* PR c/69796 */ +/* { dg-do compile } */ + +struct S s; /* { dg-error "storage size of 's' isn't known" } */ + +void +foo () +{ + s a; /* { dg-error "has an incomplete type|expected" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69801.c b/SingleSource/Regression/C/gcc-dg/pr69801.c new file mode 100644 index 0000000000..44271f839a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69801.c @@ -0,0 +1,9 @@ +/* PR middle-end/69801 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { + char c[1]; +} b, c; +int d, e; +void fn1() { e ? (d ? b : c).c : (d ? b : c).c; } diff --git a/SingleSource/Regression/C/gcc-dg/pr69802.c b/SingleSource/Regression/C/gcc-dg/pr69802.c new file mode 100644 index 0000000000..27ee02f36b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69802.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/69802 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct S { unsigned f : 1; }; +int a, d; + +int +foo (void) +{ + unsigned b = 0; + struct S c; + d = ((1 && b) < c.f) & c.f; /* { dg-warning "is used uninitialized" } */ + return a; +} + +int +bar (_Bool c) +{ + unsigned b = 0; + d = ((1 && b) < c) & c; + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69819.c b/SingleSource/Regression/C/gcc-dg/pr69819.c new file mode 100644 index 0000000000..a9594dd050 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69819.c @@ -0,0 +1,5 @@ +/* PR c/69819 */ +/* { dg-do compile } */ + +void foo () { } +int foo[] = { 0 }; /* { dg-error ".foo. redeclared as different kind of symbol" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr69824.c b/SingleSource/Regression/C/gcc-dg/pr69824.c new file mode 100644 index 0000000000..e2913f8f3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69824.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +int bar() { return foo(); } +void baz(int c[foo()]) { return; } diff --git a/SingleSource/Regression/C/gcc-dg/pr69885.c b/SingleSource/Regression/C/gcc-dg/pr69885.c new file mode 100644 index 0000000000..e3a218b815 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69885.c @@ -0,0 +1,13 @@ +/* PR target/69885 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-m68000" { target m68k*-*-* } } */ + +void bar (void); + +void +foo (long long x) +{ + if (x >> 1) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69896.c b/SingleSource/Regression/C/gcc-dg/pr69896.c new file mode 100644 index 0000000000..af141adbf5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69896.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/69896 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-w -O -fcaller-saves -fno-dse -frename-registers -fno-tree-ter" } */ +/* { dg-additional-options "-mno-sse" { target x86_64-*-* i?86-*-* } } */ + +typedef unsigned short A; +typedef unsigned short B __attribute__ ((vector_size (32))); +typedef unsigned int C; +typedef unsigned int D __attribute__ ((vector_size (32))); +typedef unsigned long long E; +typedef unsigned long long F __attribute__ ((vector_size (32))); +typedef unsigned __int128 G; +typedef unsigned __int128 H __attribute__ ((vector_size (32))); + +G __attribute__ ((noinline, noclone)) +foo (A a, C b, E c, G d, A e, C f, E g, G h, B i, D j, F k, H l, B m, D n, F o, H p) +{ + j /= (D) { -c, -c, ~h, 1, ~l[0], -m[0], p[0], 1} | 1; + l %= (H) o | 1; + l[1] = (l[1] << (e & 127)) | (l[1] >> (e & 127)); + return j[6] + l[0] + l[1] + n[7] + o[0] + o[2] + o[3] + p[0] + p[1]; +} + +int +main () +{ + if (__CHAR_BIT__ != 8 || sizeof (A) != 2 || sizeof (C) != 4 || sizeof (E) != 8 || sizeof (G) != 16) + return 0; + G x = foo (0, 1, 2, 3, 4, 5, 6, 7, (B) {}, (D) {}, (F) {}, (H) {}, (B) {}, (D) {}, (F) {}, (H) { 0xffffffffffffffffULL, 0x74a3e4aULL }); + if ((E) x != 0x00000000074a3e49ULL || (E) (x >> 64) != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69900.c b/SingleSource/Regression/C/gcc-dg/pr69900.c new file mode 100644 index 0000000000..2761d9fe0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69900.c @@ -0,0 +1,6 @@ +/* PR c/69900 */ +/* { dg-do compile } */ + +#pragma GCC diagnostic error "-Wunreachable-code" /* { dg-bogus "is not an option that controls warnings" } */ +#pragma GCC diagnostic warning "-Wunreachable-code" /* { dg-bogus "is not an option that controls warnings" } */ +#pragma GCC diagnostic ignored "-Wunreachable-code" /* { dg-bogus "is not an option that controls warnings" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr69915.c b/SingleSource/Regression/C/gcc-dg/pr69915.c new file mode 100644 index 0000000000..4c60c59d40 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69915.c @@ -0,0 +1,15 @@ +/* PR middle-end/69915 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftracer" } */ + +typedef unsigned short V __attribute__ ((vector_size (32))); + +unsigned +foo (unsigned x, unsigned c, V *p) +{ + V v = *p; + if (c < 360) + v = (V) { 0 }; + v *= (V) { x }; + return v[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69956.c b/SingleSource/Regression/C/gcc-dg/pr69956.c new file mode 100644 index 0000000000..37d24d4a94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69956.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ +/* { dg-additional-options "-march=skylake-avx512" { target { i?86-*-* x86_64-*-* } } } */ + +void +fn1 (char *b, char *d, int *c, int i) +{ + for (; i; i++, d++) + if (b[i]) + *d = c[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69960.c b/SingleSource/Regression/C/gcc-dg/pr69960.c new file mode 100644 index 0000000000..e339d30b43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69960.c @@ -0,0 +1,12 @@ +/* PR c/69960 */ +/* { dg-do compile { target int32plus } } */ + +#define TOLOWER(x) (x&~0x20) +#define Word(s) \ + s[1] ? s[2] ? s[3] ? \ + (TOLOWER(s[0]) << 24) + (TOLOWER(s[1]) << 16) + (TOLOWER(s[2]) << 8) + TOLOWER(s[3]) : \ + (TOLOWER(s[0]) << 16) + (TOLOWER(s[1]) << 8) + TOLOWER(s[2]) : \ + (TOLOWER(s[0]) << 8) + TOLOWER(s[1]) : \ + TOLOWER(s[0]) + +const unsigned int _the = Word("the"); diff --git a/SingleSource/Regression/C/gcc-dg/pr69973.c b/SingleSource/Regression/C/gcc-dg/pr69973.c new file mode 100644 index 0000000000..86989548ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69973.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +typedef int v4si __attribute__ ((vector_size (1 << 29))); diff --git a/SingleSource/Regression/C/gcc-dg/pr69974.c b/SingleSource/Regression/C/gcc-dg/pr69974.c new file mode 100644 index 0000000000..101d621200 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69974.c @@ -0,0 +1,13 @@ +/* PR c/69974 */ +/* { dg-do compile } */ + +struct S; +char foo (struct S *); +struct S a; /* { dg-error "storage size of 'a' isn't known" } */ +int b; + +void +bar () +{ + b &= foo (&a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr69990.c b/SingleSource/Regression/C/gcc-dg/pr69990.c new file mode 100644 index 0000000000..efb835ec1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr69990.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-require-effective-target section_anchors } */ +/* { dg-options "-O2 -fsection-anchors -ftree-loop-vectorize" } */ + +#pragma pack(1) +struct S0 { + volatile int f0:12; +} static a[] = {{15}}, c[] = {{15}}; + +struct S0 b[] = {{7}}; + +int __attribute__ ((noinline, noclone)) +ok (int a, int b, int c) +{ + return a == 15 && b == 7 && c == 15 ? 0 : 1; +} + +int +main (void) +{ + struct S0 *f[] = { c, b }; + + return ok (a[0].f0, b[0].f0, f[0]->f0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70017.c b/SingleSource/Regression/C/gcc-dg/pr70017.c new file mode 100644 index 0000000000..3489d5baf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70017.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-stack-check "generic" } */ +/* { dg-options "-fstack-check=generic" } */ + +/* Check that the expected warning is issued for large frames. */ + +#define ONE(s) char a##s[32]; +#define TEN(s) ONE(s##0) ONE(s##1) ONE(s##2) ONE(s##3) ONE(s##4) \ + ONE(s##5) ONE(s##6) ONE(s##7) ONE(s##8) ONE(s##9) +#define HUNDRED(s) TEN(s##0) TEN(s##1) TEN(s##2) TEN(s##3) TEN(s##4) \ + TEN(s##5) TEN(s##6) TEN(s##7) TEN(s##8) TEN(s##9) + +void foo(void) +{ + HUNDRED(a) + HUNDRED(b) +#undef ONE +#define ONE(s) a##s[0] = 0; + HUNDRED(a) + HUNDRED(b) +} /* { dg-warning "frame size too large for reliable stack checking" "" { target { ! alpha*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr70022.c b/SingleSource/Regression/C/gcc-dg/pr70022.c new file mode 100644 index 0000000000..30eb7ece25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70022.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-w -Wno-psabi" } */ + +typedef int v4si __attribute__ ((vector_size (16))); + +int +foo (v4si v) +{ + return v[~0UL]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70026.c b/SingleSource/Regression/C/gcc-dg/pr70026.c new file mode 100644 index 0000000000..32f59e2d34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70026.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +unsigned int a[64], b[64], c[64], d[64], e[64]; + +void +foo () +{ + int i; + for (i = 0; i < 64; i++) + { + d[i] = a[i]; + e[i] = ((b[i] < e[i]) != !c[i]) && !a[i]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70050.c b/SingleSource/Regression/C/gcc-dg/pr70050.c new file mode 100644 index 0000000000..ec6834ddd2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70050.c @@ -0,0 +1,11 @@ +/* PR middle-end/70050 */ +/* { dg-do compile } */ +/* { dg-options "-w -Wno-psabi" } */ + +typedef int v8si __attribute__ ((vector_size (32))); + +v8si +foo (v8si v) +{ + return v %= -v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70110.c b/SingleSource/Regression/C/gcc-dg/pr70110.c new file mode 100644 index 0000000000..42bbe3a956 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70110.c @@ -0,0 +1,39 @@ +/* PR target/70110 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-msse2" { target i?86-*-* x86_64-*-* } } */ + +int a, c, d, f, h; +long long b; + +static inline void +foo (void) +{ + if (a) + foo (); + b = c; +} + +static inline void +bar (int p) +{ + if (p) + f = 0; + b |= c; +} + +void +baz (int g, int i) +{ + for (b = d; (d = 1) != 0; ) + { + if (a) + foo (); + b |= c; + bar (h); + bar (g); + bar (h); + bar (i); + bar (h); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70152.c b/SingleSource/Regression/C/gcc-dg/pr70152.c new file mode 100644 index 0000000000..27a092d199 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70152.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/70152 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a; +int foo (void); +int setjmp (char *); +char buf[64]; + +static int +bar (int x) +{ + x = 0; + setjmp (buf); + for (;;) + { + switch (x) + case 5: + x = foo (); + } +} + +void +baz (void) +{ + bar (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70161-2.c b/SingleSource/Regression/C/gcc-dg/pr70161-2.c new file mode 100644 index 0000000000..d2cb22140c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70161-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-all-graph -fipa-pta" } */ + +void +foo (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70161.c b/SingleSource/Regression/C/gcc-dg/pr70161.c new file mode 100644 index 0000000000..9b77d90b80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70161.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-all-graph" } */ + +void +foo (void) +{ +} + +/* { dg-final { scan-ipa-dump-times "subgraph" 1 "inline.dot" } } */ +/* { dg-final { scan-ipa-dump-times "subgraph" 1 "cp.dot" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr70169.c b/SingleSource/Regression/C/gcc-dg/pr70169.c new file mode 100644 index 0000000000..56e72f34a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70169.c @@ -0,0 +1,42 @@ +/* PR tree-optimization/70169 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing -fno-tree-dce" } */ +/* { dg-skip-if "Program and data reside in different address spaces" { "avr-*-*" } } */ +/* { dg-require-effective-target label_values } */ + +int printf (const char *, ...); + +void +foo () +{ + unsigned char *p = (unsigned char *) &printf; + for (;;) + (*p)++; +} + +void +bar (int x) +{ + unsigned char *p = (unsigned char *) &printf; + int i; + for (i = 0; i < x; i++) + (*p)++; +} + +void +baz (int x, int y) +{ + unsigned char *p = (unsigned char *) &&lab; + int i; + if (y) + { + for (i = 0; i < x; i++) + (*p)++; + } + else + { + lab: + asm volatile (""); + foo (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70174.c b/SingleSource/Regression/C/gcc-dg/pr70174.c new file mode 100644 index 0000000000..59d231e162 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70174.c @@ -0,0 +1,11 @@ +/* PR rtl-optimization/70174 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct S { int f : 4; } a; + +void +foo (void) +{ + a.f = foo; /* { dg-warning "assignment to 'signed char:4' from 'void \\(\\*\\)\\(void\\)' makes integer from pointer without a cast" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70177.c b/SingleSource/Regression/C/gcc-dg/pr70177.c new file mode 100644 index 0000000000..1b2bec11e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70177.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/70177 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int b[128]; + +void +foo (int i, int j) +{ + int c, f, g, h; + for (g = 0; g < 64; g++) + for (h = g, f = 0; f <= i; f++, h++) + for (c = 0; c < j; c++) + b[h] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70219.c b/SingleSource/Regression/C/gcc-dg/pr70219.c new file mode 100644 index 0000000000..bbdbe67c73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70219.c @@ -0,0 +1,18 @@ +/* PR middle-end/70219 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O1 -w -Wno-psabi" } */ + +typedef int B __attribute__ ((vector_size (32))); +typedef int D __attribute__ ((vector_size (32))); +typedef long E __attribute__ ((vector_size (32))); +typedef __int128 F; +typedef __int128 G __attribute__ ((vector_size (32))); + +F +foo (int a, unsigned b, F c, B d, G e, B f, D g, E h, G i) +{ + b /= c; + e /= (G) ~d; + h -= (E){ g[4], e[1], 64, ~f[1] }; + return b + e[1] + h[0] + h[1] + i[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70252.c b/SingleSource/Regression/C/gcc-dg/pr70252.c new file mode 100644 index 0000000000..209e691ece --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70252.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-march=skylake-avx512" { target { i?86-*-* x86_64-*-* } } } */ + +extern unsigned char a [150]; +extern unsigned char b [150]; +extern unsigned char c [150]; +extern unsigned char d [150]; +extern unsigned char e [150]; + +void foo () { + for (int i = 92; i <= 141; i += 2) { + int tmp = (d [i] && b [i]) <= (a [i] > c [i]); + e [i] = tmp >> b [i]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70269.c b/SingleSource/Regression/C/gcc-dg/pr70269.c new file mode 100644 index 0000000000..030cea1e60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70269.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fipa-pta -fdump-ipa-pta-graph" } */ + +void +foo (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70281.c b/SingleSource/Regression/C/gcc-dg/pr70281.c new file mode 100644 index 0000000000..9447fb1f2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70281.c @@ -0,0 +1,9 @@ +/* { dg-options "-Wall -fdiagnostics-show-caret" } */ +int bch_stats_show () +{ + return __builtin_types_compatible_p (unsigned, int) ? "" : ""; /* { dg-warning "cast" } */ +/* { dg-begin-multiline-output "" } + return __builtin_types_compatible_p (unsigned, int) ? "" : ""; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70292.c b/SingleSource/Regression/C/gcc-dg/pr70292.c new file mode 100644 index 0000000000..458cccde83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70292.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O1 -fno-inline -fno-dce -fschedule-insns -fselective-scheduling -fno-tree-dce" } */ + +void bar() {} + +int t106_1mul(unsigned int x, unsigned int y) { + int r; + if (__builtin_mul_overflow(x, y, &r)) { + bar(); + } + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70317.c b/SingleSource/Regression/C/gcc-dg/pr70317.c new file mode 100644 index 0000000000..585212d1fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70317.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/70317 */ +/* { dg-do compile } */ +/* { dg-skip-if "No NaN support" { vax*-*-* pdp11*-*-* } } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +typedef double V __attribute__((vector_size (256))); +typedef __typeof ((V) {} < (V) {}) T; +T a, b; + +__attribute__((noinline, noclone, optimize ("finite-math-only"))) void +foo (V *x) +{ + V z = *x; + a = z <= z; +} + +/* { dg-final { scan-tree-dump "a\[^\n\r]*= . -1, -1," "optimized" } } */ + +__attribute__((noinline, noclone, optimize ("no-finite-math-only"))) void +bar (V *x) +{ + V z = *x; + b = z <= z; +} + +/* { dg-final { scan-tree-dump-not "b\[^\n\r]*= . -1, -1," "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr70326.c b/SingleSource/Regression/C/gcc-dg/pr70326.c new file mode 100644 index 0000000000..8332899d67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70326.c @@ -0,0 +1,20 @@ +/* PR middle-end/70326 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Og -fno-dce -fno-guess-branch-probability -fschedule-insns -fno-tree-coalesce-vars -fno-tree-dce -w -Wno-psabi" } */ + +typedef unsigned int A __attribute__ ((vector_size (32))); +typedef unsigned __int128 B; +typedef unsigned __int128 C __attribute__ ((vector_size (32))); +typedef unsigned __int128 D __attribute__ ((vector_size (32))); + +void +foo (B a, D b, A c, A d, C e) +{ + b /= (D) {11} | 1; + a ^= a <= 10; + e *= (C) d; + e += (C) ~b; + c[0] ^= c[0] <= 0x1234; + a = (a >> 1) | (a << 127); + b += (D) {45, 123}; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70405.c b/SingleSource/Regression/C/gcc-dg/pr70405.c new file mode 100644 index 0000000000..bff390ff06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70405.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/70405 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ +/* { dg-additional-options "-mavx512f" { target i?86-*-* x86_64-*-* } } */ + +typedef short V __attribute__ ((vector_size (32))); + +int +foo (V *p) +{ + V v = *p; + v >>= v; + v -= v[0]; + return v[3]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70418.c b/SingleSource/Regression/C/gcc-dg/pr70418.c new file mode 100644 index 0000000000..81bf93a568 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70418.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + + +int main() +{ + void func(int a, struct {int _[a];} v) {} /* { dg-warning "struct" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr70442.c b/SingleSource/Regression/C/gcc-dg/pr70442.c new file mode 100644 index 0000000000..b9c11ea3d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70442.c @@ -0,0 +1,20 @@ +/* PR target/70442 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-msse2" { target ia32 } } */ + +char a, c; +void +fn1 () +{ + long long b; + long m; + int d; + switch (d) + { + case 5: + b = a; + } + b ^= m; + c = b >> b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70700.c b/SingleSource/Regression/C/gcc-dg/pr70700.c new file mode 100644 index 0000000000..613cd29fc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70700.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-ealias-graph" } */ + +struct S +{ + long m; +}; + +struct S +fn1 (struct S *a) +{ + if (a->m) + a->m |= 2; + return *a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70725.c b/SingleSource/Regression/C/gcc-dg/pr70725.c new file mode 100644 index 0000000000..fc7b674d75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70725.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/70725 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-march=skylake-avx512" { target { i?86-*-* x86_64-*-* } } } */ + +extern short a; +extern int b, d; +extern int c[100]; +extern int e; +extern int f; + +void +fn1 () +{ + for (; e < 2; e = e + 1) + d = a; + for (;;) + for (int g = 0; g < 5; g = g + 1) + for (int h = 0; h < 2; h = h + 1) + for (int i = 0; i < 3; i = i + 1) + c[f + i] = a && b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70747.c b/SingleSource/Regression/C/gcc-dg/pr70747.c new file mode 100644 index 0000000000..0fca7ebd97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70747.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +int *a, b; + +void fn1 () +{ + a = __builtin_malloc (sizeof(int)*2); + b = &a[1] == (0, 0); /* { dg-warning "comparison between pointer and integer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70771.c b/SingleSource/Regression/C/gcc-dg/pr70771.c new file mode 100644 index 0000000000..fea0c5ae39 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70771.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b, c, d; + +static void +fn1 () +{ + for (b = 0; b < 1; b++) + for (c = 0; c < 1; c++) + { + if (a) + break; + b = 1; + } + for (;;) + ; +} + +int +main () +{ + if (d) + fn1 (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70775.c b/SingleSource/Regression/C/gcc-dg/pr70775.c new file mode 100644 index 0000000000..290c860765 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70775.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +struct S +{ + int f1; + int f2; +} a; + +int b, c, d, e; +short f; + +int +fn1 (int p1, unsigned p2) +{ + return p1 + p2; +} + +void +fn2 () +{ + struct S g; + int h; + for (; c; c++) + for (f = -3; f < 3; f = fn1 (f, 8)) + { + a.f1 = e; + if (b) + a = g; + else + for (; h; h++) + d = b; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70807.c b/SingleSource/Regression/C/gcc-dg/pr70807.c new file mode 100644 index 0000000000..9ef2a4d909 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70807.c @@ -0,0 +1,18 @@ +/* PR middle-end/70807 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef int INT; +int a, b, c, d, e, f; +void fn1() { + INT g; + if (d && a) + ; + else if (e && b) + ; + else if (!a && !b && c) + ; + else if (b && d || a && e) + a = 0; + f = g || d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70843.c b/SingleSource/Regression/C/gcc-dg/pr70843.c new file mode 100644 index 0000000000..c3c9212a0f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70843.c @@ -0,0 +1,9 @@ +/* PR middle-end/70843 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (int x, int y) +{ + return ({ int a = 5; a += x; a *= y; a; }) ? : 2; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70852.c b/SingleSource/Regression/C/gcc-dg/pr70852.c new file mode 100644 index 0000000000..2dec082965 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70852.c @@ -0,0 +1,11 @@ +/* PR c/70852 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +extern void *memset (void *, int, __SIZE_TYPE__); +extern int A[]; +void +fn1 (void) +{ + memset (A, 0, 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70859-2.c b/SingleSource/Regression/C/gcc-dg/pr70859-2.c new file mode 100644 index 0000000000..14b3a5452b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70859-2.c @@ -0,0 +1,21 @@ +/* PR c/70859 */ +/* { dg-do compile } */ + +#ifdef _AIX +#define _ISOC99_SOURCE +#endif +#include +#define MAX __SIZE_MAX__ +#define MAX2 SIZE_MAX +#define FIVE 5 + +static void *p; + +void +fn0 (int n) +{ + p = __builtin_alloca_with_align (n, SIZE_MAX); /* { dg-error "39:must be a constant integer" } */ + p = __builtin_alloca_with_align (n, MAX); /* { dg-error "39:must be a constant integer" } */ + p = __builtin_alloca_with_align (n, MAX2); /* { dg-error "39:must be a constant integer" } */ + p = __builtin_alloca_with_align (n, FIVE); /* { dg-error "39:must be a constant integer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70859.c b/SingleSource/Regression/C/gcc-dg/pr70859.c new file mode 100644 index 0000000000..e71b05237b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70859.c @@ -0,0 +1,69 @@ +/* PR c/70859 */ +/* { dg-do compile } */ + +static void *p; +static double *d; +static int r; +__extension__ static _Bool b; + +void +fn0 (int n) +{ + p = __builtin_alloca_with_align (n, 6); /* { dg-error "39:must be a constant integer" } */ + + r += __builtin_isfinite (0); /* { dg-error "28:non-floating-point argument in call" } */ + r += __builtin_isinf (0); /* { dg-error "25:non-floating-point argument in call" } */ + r += __builtin_isinf_sign (0); /* { dg-error "30:non-floating-point argument in call" } */ + r += __builtin_isnan (0); /* { dg-error "25:non-floating-point argument in call" } */ + r += __builtin_isnormal (0); /* { dg-error "28:non-floating-point argument in call" } */ + r += __builtin_signbit (0); /* { dg-error "27:non-floating-point argument in call" } */ + + r += __builtin_isgreater (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_isgreaterequal (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_isless (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_islessequal (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_islessgreater (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + r += __builtin_isunordered (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ + + r += __builtin_fpclassify (1, 2, n, 4, 5, n); /* { dg-error "36:non-const integer argument 3 in call" } */ + r += __builtin_fpclassify (1, 2, 3, 4, 5, 6); /* { dg-error "45:non-floating-point argument in call" } */ + + d = __builtin_assume_aligned (p, n, p); /* { dg-error "39:non-integer argument 3 in call" } */ + + b = __builtin_add_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ + b = __builtin_add_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ + b = __builtin_sub_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ + b = __builtin_sub_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ + b = __builtin_mul_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ + b = __builtin_mul_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ +} + +int +fn1 (void) +{ + if (__builtin_constant_p ()) /* { dg-error "7:too few" } */ + return 0; + if (__builtin_constant_p (1, 2)) /* { dg-error "7:too many" } */ + return 1; + if (__builtin_isfinite ()) /* { dg-error "7:too few" } */ + return 3; + if (__builtin_isfinite (1, 2)) /* { dg-error "7:too many" } */ + return 4; + if (__builtin_isless (0)) /* { dg-error "7:too few" } */ + return 5; + if (__builtin_isless (1, 2, 3)) /* { dg-error "7:too many" } */ + return 6; + if (__builtin_fpclassify (1, 2, 3, 4, 5)) /* { dg-error "7:too few" } */ + return 7; + if (__builtin_fpclassify (1, 2, 3, 4, 5, r, 6)) /* { dg-error "7:too many" } */ + return 8; + if (__builtin_assume_aligned (p)) /* { dg-error "7:too few" } */ + return 9; + if (__builtin_assume_aligned (p, r, p, p)) /* { dg-error "7:too many" } */ + return 10; + if (__builtin_add_overflow ()) /* { dg-error "7:too few" } */ + return 11; + if (__builtin_add_overflow (1, 2, 3, &r)) /* { dg-error "7:too many" } */ + return 12; + return -1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr70920-1.c b/SingleSource/Regression/C/gcc-dg/pr70920-1.c new file mode 100644 index 0000000000..9b7e2d0e53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70920-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +#include + +void f1(); +void f2(); + +void +foo (int *a) +{ + if ((intptr_t) a == 0) + { + f1 (); + if (a) + f2 (); + } +} + +/* { dg-final { scan-tree-dump "if \\(a == 0B\\)" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr70920-2.c b/SingleSource/Regression/C/gcc-dg/pr70920-2.c new file mode 100644 index 0000000000..98072247e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70920-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1-details" } */ + +#include + +void f1(); +void f2(); + +void +foo (int *a) +{ + int cst = 0; + if ((intptr_t) a == cst) + { + f1 (); + if (a) + f2 (); + } +} + +/* { dg-final { scan-tree-dump "gimple_simplified to if \\(a_\[0-9\]*\\(D\\) == 0B\\)" "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr70920-3.c b/SingleSource/Regression/C/gcc-dg/pr70920-3.c new file mode 100644 index 0000000000..8b24cbc734 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70920-3.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple -Wno-int-to-pointer-cast" } */ + +#include + +void f1(); +void f2(); + +void +foo (int a) +{ + if ((int *) a == 0) + { + f1 (); + if (a) + f2 (); + } +} + +/* { dg-final { scan-tree-dump "if \\(a == 0\\)" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr70920-4.c b/SingleSource/Regression/C/gcc-dg/pr70920-4.c new file mode 100644 index 0000000000..70973cb162 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr70920-4.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fdump-tree-ccp1 -Wno-int-to-pointer-cast" } */ + +#include + +void f1(); +void f2(); + +void +foo (int a) +{ + void *cst = 0; + if ((int *) a == cst) + { + f1 (); + if (a) + f2 (); + } +} + +/* { dg-final { scan-tree-dump "if \\(a_\[0-9\]*\\(D\\) == 0\\)" "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71006.c b/SingleSource/Regression/C/gcc-dg/pr71006.c new file mode 100644 index 0000000000..2b45aa01c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71006.c @@ -0,0 +1,16 @@ +/* PR target/71006 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vectorize" } */ + +unsigned char uu, gu, e2; + +void +fs (void) +{ + char *nq = (char *)&gu, *k4 = (char *)&gu; + while (*k4 < 1) + { + uu += (*nq != 0 || e2 != 0); + ++*k4; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71071.c b/SingleSource/Regression/C/gcc-dg/pr71071.c new file mode 100644 index 0000000000..582f1f15a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71071.c @@ -0,0 +1,12 @@ +/* PR bootstrap/71071 */ +/* { dg-do compile } * +/* { dg-options "-O2" } */ + +struct S { unsigned b : 1; } a; + +void +foo () +{ + if (a.b) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71077.c b/SingleSource/Regression/C/gcc-dg/pr71077.c new file mode 100644 index 0000000000..db83bc35d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71077.c @@ -0,0 +1,14 @@ +/* PR c++/71077 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */ + +void +foo (int *a, int n) +{ + int b, c; + for (b = 0; b < n; b++) + for (c = 0; c < 32; c++) + if ((b & 1U) << c) + a[b + c] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71084.c b/SingleSource/Regression/C/gcc-dg/pr71084.c new file mode 100644 index 0000000000..392c5ca239 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71084.c @@ -0,0 +1,40 @@ +/* PR tree-optimization/71084 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +__extension__ typedef __INTPTR_TYPE__ intptr_t; + +void babl_format (void); +void gimp_drawable_get_format (void); +int _setjmp (void); + +enum { + GIMP_RGB_IMAGE, + GIMP_RGBA_IMAGE, + GIMP_GRAY_IMAGE, + GIMP_GRAYA_IMAGE, + GIMP_INDEXED_IMAGE +} run_i; + +int run_height; + +void fn1 () +{ + int type, width; + if (_setjmp ()) + switch (type) + { + case GIMP_RGB_IMAGE: + babl_format (); + case GIMP_RGBA_IMAGE: + case GIMP_GRAY_IMAGE: + babl_format (); + case GIMP_GRAYA_IMAGE: + case GIMP_INDEXED_IMAGE: + gimp_drawable_get_format(); + } + for (; run_height;) + for (; run_i < (long)(intptr_t)fn1; ++run_i) + for (; width;) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71104-1.c b/SingleSource/Regression/C/gcc-dg/pr71104-1.c new file mode 100644 index 0000000000..20c055ad81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71104-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +void foo(void); +int vfork(void); +int *p; + +void bar(void) +{ + foo(); + *p = vfork(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71104-2.c b/SingleSource/Regression/C/gcc-dg/pr71104-2.c new file mode 100644 index 0000000000..03c52a338c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71104-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +struct Foo { char c[1024]; }; +void foo(void); +struct Foo baz(void) __attribute__((returns_twice)); +struct Foo *p; + +void bar(void) +{ + foo(); + *p = baz(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71148.c b/SingleSource/Regression/C/gcc-dg/pr71148.c new file mode 100644 index 0000000000..6aa4920d1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71148.c @@ -0,0 +1,46 @@ +/* PR rtl-optimization/71148 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -funroll-loops" } */ + +int rh, ok, kq, fu; + +void +js (int cs) +{ + rh = fu; + if (fu != 0) + { + cs /= 3; + if (cs <= 0) + { + int z9; + for (z9 = 0; z9 < 2; ++z9) + { + z9 += cs; + ok += z9; + fu += ok; + } + } + } +} + +void +vy (int s3) +{ + int yo, g2 = 0; + sd: + js (g2); + for (yo = 0; yo < 2; ++yo) + { + if (fu != 0) + goto sd; + kq += (s3 != (g2 ? s3 : 0)); + for (s3 = 0; s3 < 72; ++s3) + g2 *= (~0 - 1); + g2 -= yo; + } + for (fu = 0; fu < 18; ++fu) + for (yo = 0; yo < 17; ++yo) + if (g2 < 0) + goto sd; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71279.c b/SingleSource/Regression/C/gcc-dg/pr71279.c new file mode 100644 index 0000000000..4ecc84b642 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71279.c @@ -0,0 +1,14 @@ +/* PR middle-end/71279 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-march=knl" { target { i?86-*-* x86_64-*-* } } } */ + +extern int a, b; +long c[1][1][1]; +long d[1][1]; + +void fn1 () +{ + for (int e = 0; e < b; e = e + 1) + *(e + **c) = (a && *d[1]) - 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71280.c b/SingleSource/Regression/C/gcc-dg/pr71280.c new file mode 100644 index 0000000000..496e3d269e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71280.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/71280 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern char v[]; + +int +foo () +{ + int k = 0; + typedef char T[64]; + for (int i = 0; i < 64; i++) + k += (*(T *) &v[0])[i]; + return k; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71289.c b/SingleSource/Regression/C/gcc-dg/pr71289.c new file mode 100644 index 0000000000..39837b9336 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71289.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized-raw" } */ + +int f(unsigned a, unsigned b, unsigned *c) +{ + if (a > -1 / b) + return -1; + *c = a * b; + return 0; +} + +void g(unsigned long long a, unsigned long long b, unsigned long long *c) +{ + if (a <= -1 / b) + *c = a * b; +} + +/* { dg-final { scan-tree-dump-not "trunc_div_expr" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71343-1.c b/SingleSource/Regression/C/gcc-dg/pr71343-1.c new file mode 100644 index 0000000000..146f5fcd69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71343-1.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned int foo_plus(unsigned int a, unsigned int b) +{ + return (a << 2) + (b << 2); +} + +unsigned int foo_and(unsigned int a, unsigned int b) +{ + return (a << 2) & (b << 2); +} + +unsigned int foo_ior(unsigned int a, unsigned int b) +{ + return (a << 2) | (b << 2); +} + +unsigned int foo_xor(unsigned int a, unsigned int b) +{ + return (a << 2) ^ (b << 2); +} + +unsigned int bar_and(unsigned int a, unsigned int b) +{ + return (a >> 2) & (b >> 2); +} + +unsigned int bar_ior(unsigned int a, unsigned int b) +{ + return (a >> 2) | (b >> 2); +} + +unsigned int bar_xor(unsigned int a, unsigned int b) +{ + return (a >> 2) ^ (b >> 2); +} + +int baz_and(int a, int b) +{ + return (a >> 2) & (b >> 2); +} + +int baz_ior(int a, int b) +{ + return (a >> 2) | (b >> 2); +} + +int baz_xor(int a, int b) +{ + return (a >> 2) ^ (b >> 2); +} + +/* { dg-final { scan-tree-dump-times " << " 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " >> " 6 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr71343-2.c b/SingleSource/Regression/C/gcc-dg/pr71343-2.c new file mode 100644 index 0000000000..11800a9191 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71343-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned int test1(unsigned int a , unsigned int b) +{ + return (a << 2) + (b << 2) == a * 4 + b * 4; +} + +unsigned int test2(unsigned int a , unsigned int b) +{ + return (a << 2) + (b << 2) == (a + b) << 2; +} + +unsigned int test3(unsigned int a , unsigned int b) +{ + return a * 4 + b * 4 == (a + b) * 4; +} + +unsigned int test4(unsigned int a , unsigned int b) +{ + return (a + b) << 2 == (a + b) * 4; +} + +unsigned int test5(unsigned int a , unsigned int b) +{ + return (a << 2) + (b << 2) == (a + b) * 4; +} + +unsigned int test6(unsigned int a , unsigned int b) +{ + return (a + b) << 2 == a * 4 + b * 4; +} + +/* { dg-final { scan-tree-dump-times "return 1" 6 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71362.c b/SingleSource/Regression/C/gcc-dg/pr71362.c new file mode 100644 index 0000000000..fd9cd6a20d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71362.c @@ -0,0 +1,10 @@ +/* PR c/71362 */ +/* { dg-do compile } */ + +extern void foo (int[-1]); /* { dg-error "21:size of unnamed array is negative" } */ + +int +bar (void) +{ + 123 + sizeof (int[-1]); /* { dg-error "20:size of unnamed array is negative" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71478.c b/SingleSource/Regression/C/gcc-dg/pr71478.c new file mode 100644 index 0000000000..17ec7ec62a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71478.c @@ -0,0 +1,19 @@ +/* PR middle-end/71478 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wno-psabi -w" } */ + +typedef unsigned int __attribute__ ((vector_size (8))) uv2si; +typedef int __attribute__ ((vector_size (8))) v2si; + +uv2si bar (v2si); + +uv2si +foo (void) +{ + v2si x = (v2si) (0x00007fff80008000UL); + v2si y = (v2si) (0x8f997fff00000000UL); + uv2si z = x >= y; + uv2si k = bar (x); + uv2si j = k * __builtin_shuffle (z, z, (uv2si) {1, 3}); + return k * j; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71514.c b/SingleSource/Regression/C/gcc-dg/pr71514.c new file mode 100644 index 0000000000..8bfa8051d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71514.c @@ -0,0 +1,23 @@ +/* PR c/71514 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo () +{ +} + +int a, b; + +void +fn1 (void) +{ + __atomic_exchange (&a, &foo, &b, __ATOMIC_RELAXED); /* { dg-error "must not be a pointer to a function" } */ +} + +void +fn2 (int n) +{ + int arr[n]; + __atomic_exchange (&a, &arr, &b, __ATOMIC_RELAXED); /* { dg-error "must be a pointer to a constant size type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71518.c b/SingleSource/Regression/C/gcc-dg/pr71518.c new file mode 100644 index 0000000000..6240ca8f2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71518.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/71518 */ +/* { dg-options "-O3" } */ + +int a, *b[9], c, d, e; + +static int +fn1 () +{ + for (c = 6; c >= 0; c--) + for (d = 0; d < 2; d++) + { + b[d * 2 + c] = 0; + e = a > 1 ? : 0; + if (e == 2) + return 0; + } + return 0; +} + +int +main () +{ + fn1 (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71558.c b/SingleSource/Regression/C/gcc-dg/pr71558.c new file mode 100644 index 0000000000..33a648e108 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71558.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/71588 */ + +/* strcpy must not be pure, but make sure we don't ICE even when + it is declared incorrectly. */ +char *strcpy (char *, const char *) __attribute__ ((__pure__)); +__SIZE_TYPE__ strlen (const char *); +void *malloc (__SIZE_TYPE__); + +char a[20]; + +char * +foo (void) +{ + __SIZE_TYPE__ b = strlen (a); + char *c = malloc (b); + return strcpy (c, a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71581.c b/SingleSource/Regression/C/gcc-dg/pr71581.c new file mode 100644 index 0000000000..dd71dde9ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71581.c @@ -0,0 +1,24 @@ +/* PR middle-end/71581 */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +_Complex float +f1 (void) +{ + float x; + return x; /* { dg-warning "is used uninitialized" } */ +} + +_Complex double +f2 (void) +{ + double x; + return x; /* { dg-warning "is used uninitialized" } */ +} + +_Complex int +f3 (void) +{ + int x; + return x; /* { dg-warning "is used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71585-2.c b/SingleSource/Regression/C/gcc-dg/pr71585-2.c new file mode 100644 index 0000000000..c3010daf49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71585-2.c @@ -0,0 +1,23 @@ +/* Test that stack protection is done on chosen functions. */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */ +/* { dg-options "-O2 -fstack-protector-all" } */ + +/* This test checks the presence of __stack_chk_fail function in assembler. + * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC. + */ +/* { dg-require-effective-target nonpic } */ + +static int foo() +{ + return 0; +} + +#pragma GCC push_options +#pragma GCC optimize ("-fno-stack-protector") + +int main() { foo (); } + +#pragma GCC pop_options + +/* { dg-final { scan-assembler-times "stack_chk_fail" 0 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71585-3.c b/SingleSource/Regression/C/gcc-dg/pr71585-3.c new file mode 100644 index 0000000000..5632915631 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71585-3.c @@ -0,0 +1,24 @@ +/* Test that stack protection is done on chosen functions. */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */ +/* { dg-options "-O2 -fstack-protector-all" } */ + +/* This test checks the presence of __stack_chk_fail function in assembler. + * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC. + */ +/* { dg-require-effective-target nonpic } */ + + +#pragma GCC push_options +#pragma GCC optimize ("-fno-stack-protector") + +int foo() +{ + return 0; +} + +#pragma GCC pop_options + +int main() { foo (); } + +/* { dg-final { scan-assembler-times "stack_chk_fail" 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71585.c b/SingleSource/Regression/C/gcc-dg/pr71585.c new file mode 100644 index 0000000000..444aaa1c35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71585.c @@ -0,0 +1,23 @@ +/* Test that stack protection is done on chosen functions. */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */ +/* { dg-options "-O2 -fstack-protector-all" } */ + +/* This test checks the presence of __stack_chk_fail function in assembler. + * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC. + */ +/* { dg-require-effective-target nonpic } */ + +#pragma GCC push_options + +#pragma GCC optimize ("-fno-stack-protector") +__attribute__((constructor)) void foo() +{ + asm (""); +} + +#pragma GCC pop_options + +int main() { return 0; } + +/* { dg-final { scan-assembler-times "stack_chk_fail" 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71619.c b/SingleSource/Regression/C/gcc-dg/pr71619.c new file mode 100644 index 0000000000..e1404bc9a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71619.c @@ -0,0 +1,11 @@ +/* PR 71619 */ + +/* { dg-do compile } */ +/* { dg-options "-O --param=max-predicted-iterations=0" } */ + +void +foo () +{ + int count = -10; + while (count++); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71632.c b/SingleSource/Regression/C/gcc-dg/pr71632.c new file mode 100644 index 0000000000..e8d5cc54c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71632.c @@ -0,0 +1,53 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-if-convert" } */ + +void +foo (double d, double *p, double *q) +{ + int i; + for (i = 0; i < 64; i++) + { + double t1 = d > p[0] ? 1.0 : 0.0; + double t2 = t1 > p[1] ? 1.0 : 0.0; + double t3 = t2 > p[2] ? 1.0 : 0.0; + double t4 = t3 > p[3] ? 1.0 : 0.0; + double t5 = t4 > p[4] ? 1.0 : 0.0; + double t6 = t5 > p[5] ? 1.0 : 0.0; + double t7 = t6 > p[6] ? 1.0 : 0.0; + double t8 = t7 > p[7] ? 1.0 : 0.0; + double t9 = t8 > p[8] ? 1.0 : 0.0; + double t10 = t9 > p[9] ? 1.0 : 0.0; + double t11 = t10 > p[10] ? 1.0 : 0.0; + double t12 = t11 > p[11] ? 1.0 : 0.0; + double t13 = t12 > p[12] ? 1.0 : 0.0; + double t14 = t13 > p[13] ? 1.0 : 0.0; + double t15 = t14 > p[14] ? 1.0 : 0.0; + double t16 = t15 > p[15] ? 1.0 : 0.0; + double t17 = t16 > p[16] ? 1.0 : 0.0; + double t18 = t17 > p[17] ? 1.0 : 0.0; + double t19 = t18 > p[18] ? 1.0 : 0.0; + double t20 = t19 > p[19] ? 1.0 : 0.0; + double t21 = t20 > p[20] ? 1.0 : 0.0; + double t22 = t21 > p[21] ? 1.0 : 0.0; + double t23 = t22 > p[22] ? 1.0 : 0.0; + double t24 = t23 > p[23] ? 1.0 : 0.0; + double t25 = t24 > p[24] ? 1.0 : 0.0; + double t26 = t25 > p[25] ? 1.0 : 0.0; + double t27 = t26 > p[26] ? 1.0 : 0.0; + double t28 = t27 > p[27] ? 1.0 : 0.0; + double t29 = t28 > p[28] ? 1.0 : 0.0; + double t30 = t29 > p[29] ? 1.0 : 0.0; + double t31 = t30 > p[30] ? 1.0 : 0.0; + double t32 = t31 > p[31] ? 1.0 : 0.0; + double t33 = t32 > p[32] ? 1.0 : 0.0; + double t34 = t33 > p[33] ? 1.0 : 0.0; + double t35 = t34 > p[34] ? 1.0 : 0.0; + double t36 = t35 > p[35] ? 1.0 : 0.0; + double t37 = t36 > p[36] ? 1.0 : 0.0; + double t38 = t37 > p[37] ? 1.0 : 0.0; + double t39 = t38 > p[38] ? 1.0 : 0.0; + *q = t39; + p += 39; + q++; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr71636-1.c b/SingleSource/Regression/C/gcc-dg/pr71636-1.c new file mode 100644 index 0000000000..2df5f96f46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71636-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +unsigned f(unsigned x, unsigned b) +{ + return x & ((1U << b) - 1); +} + +/* { dg-final { scan-tree-dump-not "1 <<" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71636-2.c b/SingleSource/Regression/C/gcc-dg/pr71636-2.c new file mode 100644 index 0000000000..9e9297d4a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71636-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop-details" } */ + +unsigned f(unsigned x, unsigned b) +{ + unsigned t1 = 1U << b; + unsigned t2 = t1 - 1; + unsigned t3 = x & t2; + return t3; +} + +/* { dg-final { scan-tree-dump "_\[0-9\] = ~_\[0-9\]" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71685.c b/SingleSource/Regression/C/gcc-dg/pr71685.c new file mode 100644 index 0000000000..80e5c8f590 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71685.c @@ -0,0 +1,6 @@ +/* PR c/71685 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +extern struct S v, s; +struct S { int t; int p[]; } v = { 4, 0 }; diff --git a/SingleSource/Regression/C/gcc-dg/pr71969-1.c b/SingleSource/Regression/C/gcc-dg/pr71969-1.c new file mode 100644 index 0000000000..a39b05ea9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71969-1.c @@ -0,0 +1,37 @@ +/* PR c/71969 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fno-gnu89-inline -O2 -fdump-tree-einline-details" } */ + +volatile int v; +#define S v++; +#define S10 S S S S S S S S S S +#define S100 S10 S10 S10 S10 S10 S10 S10 S10 S10 S10 + +extern inline void +foo (void) { S100 } + +inline void +bar (void) { S100 } + +static inline void +baz (void) { S100 } + +int +main () +{ + foo (); + foo (); + foo (); + foo (); + bar (); + bar (); + bar (); + bar (); + baz (); + baz (); + baz (); + baz (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "will not early inline" 12 "einline" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71969-2.c b/SingleSource/Regression/C/gcc-dg/pr71969-2.c new file mode 100644 index 0000000000..73839a6d0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71969-2.c @@ -0,0 +1,23 @@ +/* PR c/71969 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fno-gnu89-inline -O2 -fdump-tree-einline-details" } */ + +volatile int v; +#define S v++; +#define S10 S S S S S S S S S S +#define S100 S10 S10 S10 S10 S10 S10 S10 S10 S10 S10 + +extern inline __attribute__((gnu_inline)) void +foo (void) { S100 } + +int +main () +{ + foo (); + foo (); + foo (); + foo (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Inlining foo/\[0-9\]* into main/\[0-9\]*" 4 "einline" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr71969-3.c b/SingleSource/Regression/C/gcc-dg/pr71969-3.c new file mode 100644 index 0000000000..189adfd458 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr71969-3.c @@ -0,0 +1,38 @@ +/* PR c/71969 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fgnu89-inline -O2 -fdump-tree-einline-details" } */ + +volatile int v; +#define S v++; +#define S10 S S S S S S S S S S +#define S100 S10 S10 S10 S10 S10 S10 S10 S10 S10 S10 + +extern inline void +foo (void) { S100 } + +inline void +bar (void) { S100 } + +static inline void +baz (void) { S100 } + +int +main () +{ + foo (); + foo (); + foo (); + foo (); + bar (); + bar (); + bar (); + bar (); + baz (); + baz (); + baz (); + baz (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "will not early inline" 8 "einline" } } */ +/* { dg-final { scan-tree-dump-times "Inlining foo/\[0-9\]* into main/\[0-9\]*" 4 "einline" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr72816.c b/SingleSource/Regression/C/gcc-dg/pr72816.c new file mode 100644 index 0000000000..b1498c7a70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr72816.c @@ -0,0 +1,9 @@ +/* PR c/72816 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +typedef const int A[]; +struct S { + int a; + A b; +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr7356-2.c b/SingleSource/Regression/C/gcc-dg/pr7356-2.c new file mode 100644 index 0000000000..ad67975697 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr7356-2.c @@ -0,0 +1,33 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +int i /* { dg-error "6: expected ';' before 'int'" } */ +int j; +/* { dg-begin-multiline-output "" } + int i + ^ + ; + int j; + ~~~ + { dg-end-multiline-output "" } */ + + +void test (void) +{ + int i /* { dg-error "8: expected ';' before 'int'" } */ + int j; + + /* { dg-begin-multiline-output "" } + int i + ^ + ; + int j; + ~~~ + { dg-end-multiline-output "" } */ +} + +int old_style_params (first, second) + int first; + int second; +{ + return first + second; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr7356.c b/SingleSource/Regression/C/gcc-dg/pr7356.c new file mode 100644 index 0000000000..84baf078b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr7356.c @@ -0,0 +1,17 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +a /* { dg-line stray_token } */ +#include +#include +#include +int main(int argc, char** argv) +{ + return 0; +} + +/* { dg-error "expected ';' before '.*'" "" { target *-*-* } stray_token } */ +/* { dg-begin-multiline-output "" } + a + ^ + ; + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr76783.c b/SingleSource/Regression/C/gcc-dg/pr76783.c new file mode 100644 index 0000000000..22aef56529 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr76783.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-Og -w -Wno-psabi" } */ + +typedef unsigned __int128 u128; +typedef unsigned __int128 v64u128 __attribute__ ((vector_size (64))); + +u128 __attribute__ ((noinline, noclone)) +foo (unsigned c, v64u128 v) +{ + v64u128 u; + if (c) { + u = (v64u128){(u128)0, (u128)0}; + } else { + u = (v64u128){(u128)0, (u128)1}; + } + u += v; + return u[1]; +} + +int +main () +{ + u128 x = foo (0, (v64u128){ }); + if (x != 1) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr77323.c b/SingleSource/Regression/C/gcc-dg/pr77323.c new file mode 100644 index 0000000000..281c334749 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77323.c @@ -0,0 +1,6 @@ +/* PR c/77323 */ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "" } */ + +__int128 a; /* { dg-error "not supported" } */ +_Float128x b; /* { dg-error "not supported" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr77407.c b/SingleSource/Regression/C/gcc-dg/pr77407.c new file mode 100644 index 0000000000..8cad857154 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77407.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fstrict-overflow -fdump-tree-gimple" } */ + +int foo (int c) +{ + if (c != 0) + c /= __builtin_abs (c); + return c; +} + +int bar (int c) +{ + if (c != 0) + c /= -c; + return c; +} + +/* { dg-final { scan-tree-dump-times "/" 0 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr77450.c b/SingleSource/Regression/C/gcc-dg/pr77450.c new file mode 100644 index 0000000000..7c19e86ca0 --- /dev/null +++ b/SingleSource/Regression/C/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/SingleSource/Regression/C/gcc-dg/pr77454.c b/SingleSource/Regression/C/gcc-dg/pr77454.c new file mode 100644 index 0000000000..1bb41c2b17 --- /dev/null +++ b/SingleSource/Regression/C/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/SingleSource/Regression/C/gcc-dg/pr77520.c b/SingleSource/Regression/C/gcc-dg/pr77520.c new file mode 100644 index 0000000000..b237639fb2 --- /dev/null +++ b/SingleSource/Regression/C/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/SingleSource/Regression/C/gcc-dg/pr77521.c b/SingleSource/Regression/C/gcc-dg/pr77521.c new file mode 100644 index 0000000000..f6b1e3ed26 --- /dev/null +++ b/SingleSource/Regression/C/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/SingleSource/Regression/C/gcc-dg/pr77587.c b/SingleSource/Regression/C/gcc-dg/pr77587.c new file mode 100644 index 0000000000..8f5afef6b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77587.c @@ -0,0 +1,15 @@ +/* PR target/77587 */ +/* { dg-do run } */ +/* { dg-require-alias "" } */ +/* { dg-require-weak-override "" } */ +/* { dg-additional-sources "pr77587a.c" } */ + +void +bar (long x, long y, long z) +{ + struct __attribute__((aligned (16))) S { long a, b, c, d; } s; + char *p = (char *) &s; + __asm ("" : "+r" (p)); + if (((__UINTPTR_TYPE__) p) & 15) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr77587a.c b/SingleSource/Regression/C/gcc-dg/pr77587a.c new file mode 100644 index 0000000000..12e144560c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77587a.c @@ -0,0 +1,24 @@ +/* PR target/77587 */ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-require-weak-override "" } */ + +void +foo (long x, long y, long z) +{ +} + +void bar (long x, long y, long z) __attribute__ ((weak, alias ("foo"))); + +void +baz (long x, long y, long z) +{ + bar (0, 0, 0); +} + +int +main () +{ + baz (0, 0, 0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr77621.c b/SingleSource/Regression/C/gcc-dg/pr77621.c new file mode 100644 index 0000000000..e2804522a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77621.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mtune=atom -msse2" { target i?86-*-* x86_64-*-* } } */ + +void +foo (double *x, int *y) +{ + int i; + for (i = 0; i < 8; i++) + x[i] -= y[i] * x[i + 1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr77664.c b/SingleSource/Regression/C/gcc-dg/pr77664.c new file mode 100644 index 0000000000..bcf7b88560 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77664.c @@ -0,0 +1,55 @@ +/* PR tree-optimization/77664 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "tree-ssa/pr77664.c" + +int cnt; + +__attribute__((noinline, noclone)) void +foo (void) +{ + cnt++; +} + +int +main () +{ + fn1 (65534U, 65535U, 7); if (cnt != 1) __builtin_abort (); + fn1 (65534U, 65535U, 0); if (cnt != 1) __builtin_abort (); + fn1 (65535U, 65535U, 1); if (cnt != 1) __builtin_abort (); + fn1 (0, 65535U, 1); if (cnt != 2) __builtin_abort (); + fn1 (-1, 65535U, 1); if (cnt != 2) __builtin_abort (); + fn1 (0, 0, 1); if (cnt != 2) __builtin_abort (); + fn2 (65534U, 65535U, 7); if (cnt != 3) __builtin_abort (); + fn2 (65534U, 65535U, 0); if (cnt != 3) __builtin_abort (); + fn2 (65535U, 65535U, 0); if (cnt != 4) __builtin_abort (); + fn2 (0, 65535U, 0); if (cnt != 4) __builtin_abort (); + fn2 (-1, 65535U, 0); if (cnt != 5) __builtin_abort (); + fn2 (0, 0, 0); if (cnt != 6) __builtin_abort (); + fn3 (-1, 65534U); if (cnt != 7) __builtin_abort (); + fn3 (0, 65534U); if (cnt != 7) __builtin_abort (); + fn3 (65534U, 65534U); if (cnt != 7) __builtin_abort (); + fn3 (65535U, 65534U); if (cnt != 8) __builtin_abort (); + fn3 (0, 0); if (cnt != 8) __builtin_abort (); + fn3 (1, 0); if (cnt != 9) __builtin_abort (); + fn4 (-1, 65534U); if (cnt != 9) __builtin_abort (); + fn4 (0, 65534U); if (cnt != 10) __builtin_abort (); + fn4 (65534U, 65534U); if (cnt != 11) __builtin_abort (); + fn4 (65535U, 65534U); if (cnt != 11) __builtin_abort (); + fn4 (0, 0); if (cnt != 12) __builtin_abort (); + fn4 (1, 0); if (cnt != 12) __builtin_abort (); + fn5 (-1, 65534U); if (cnt != 13) __builtin_abort (); + fn5 (0, 65534U); if (cnt != 13) __builtin_abort (); + fn5 (65534U, 65534U); if (cnt != 13) __builtin_abort (); + fn5 (65535U, 65534U); if (cnt != 14) __builtin_abort (); + fn5 (0, 0); if (cnt != 14) __builtin_abort (); + fn5 (1, 0); if (cnt != 15) __builtin_abort (); + fn6 (-1, 65534U); if (cnt != 15) __builtin_abort (); + fn6 (0, 65534U); if (cnt != 16) __builtin_abort (); + fn6 (65534U, 65534U); if (cnt != 17) __builtin_abort (); + fn6 (65535U, 65534U); if (cnt != 17) __builtin_abort (); + fn6 (0, 0); if (cnt != 18) __builtin_abort (); + fn6 (1, 0); if (cnt != 18) __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr77673.c b/SingleSource/Regression/C/gcc-dg/pr77673.c new file mode 100644 index 0000000000..b41cf04e77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77673.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-require-effective-target bswap } */ +/* { dg-options "-O2 -fPIC -fdump-tree-bswap" } */ +/* { dg-additional-options "-march=z900" { target s390*-*-* } } */ + +void mach_parse_compressed(unsigned char* ptr, unsigned long int* val) +{ + if (ptr[0] < 0xC0U) { + *val = ptr[0] + ptr[1]; + return; + } + + *val = ((unsigned long int)(ptr[0]) << 24) + | ((unsigned long int)(ptr[1]) << 16) + | ((unsigned long int)(ptr[2]) << 8) + | ptr[3]; +} + +/* { dg-final { scan-tree-dump-not "load_dst_\\d+ =.* if \\(" "bswap" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr77834.c b/SingleSource/Regression/C/gcc-dg/pr77834.c new file mode 100644 index 0000000000..a9085b9539 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77834.c @@ -0,0 +1,18 @@ +/* PR target/77834 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-pre -Wno-psabi" } */ +/* { dg-additional-options "-mstringop-strategy=libcall" { target i?86-*-* x86_64-*-* } } */ + +typedef int V __attribute__ ((vector_size (64))); + +V +foo (V u, V v, int w) +{ + do + { + if (u[0]) v ^= u[w]; + } + while ((V) { 0, u[w] }[1]); + u = (V) { v[v[0]], u[u[0]] }; + return v + u; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr77860.c b/SingleSource/Regression/C/gcc-dg/pr77860.c new file mode 100644 index 0000000000..04346b16e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77860.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/77860 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-vrp -fno-tree-forwprop -Wno-psabi" } */ + +typedef unsigned short V __attribute__((vector_size (16))); + +V +foo (V x, V y) +{ + V a = -x; + V b = -y; + return a * b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr77862.c b/SingleSource/Regression/C/gcc-dg/pr77862.c new file mode 100644 index 0000000000..a048cb4a74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77862.c @@ -0,0 +1,20 @@ + +/* PR tree-optimization/77862 */ +/* { dg-do compile } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fPIC -w" } */ + +struct paramed_type +{ +}; +int a; + +int memcmp ( int*, void *, long ); + +void +cur_token (void) +{ + if ( 1 != a || memcmp ( cur_token, "", a ) ) + return; + struct paramed_type b = { }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr77975.c b/SingleSource/Regression/C/gcc-dg/pr77975.c new file mode 100644 index 0000000000..a187ce2b50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr77975.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/77975 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ivcanon-details" } */ + +/* { dg-final { scan-tree-dump-times "Proved that loop 1 iterates 1 times using brute force" 1 "ivcanon" } } */ + +unsigned int +foo (unsigned int *b) +{ + unsigned int a = 8; + while (a) + { + a += 5; + a &= 44; + *b += a; + } + return a; +} + +/* { dg-final { scan-tree-dump-times "Proved that loop 1 iterates 2 times using brute force" 1 "ivcanon" } } */ + +unsigned int +bar (unsigned int *b) +{ + unsigned int a = 3; + while (a) + { + a += 5; + a &= 44; + *b += a; + } + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78138.c b/SingleSource/Regression/C/gcc-dg/pr78138.c new file mode 100644 index 0000000000..cda2fb8a6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78138.c @@ -0,0 +1,24 @@ +/* PR middle-end/78138 - missing warnings on buffer overflow with non-constant + source length + { dg-do compile } + { dg-options "-O2 -Wformat-overflow" } */ + +char d [5]; + +__extension__ typedef __SIZE_TYPE__ size_t; + +void* memcpy (void*, const void*, size_t); +extern char* strcpy (char*, const char*); + +void f (int i, int j) +{ + strcpy (d, j ? "12345" : "123456"); /* { dg-warning ".strcpy. writing between 6 and 7 bytes into a region of size 5 " } */ +} + +void g (void *p) +{ + extern unsigned n; + if (n < 17 || 32 < n) n = 7; + + memcpy (d, p, n); /* { dg-warning ".memcpy. writing between 7 and 32 bytes into a region of size 5" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr78148.c b/SingleSource/Regression/C/gcc-dg/pr78148.c new file mode 100644 index 0000000000..c3c9b2e9a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78148.c @@ -0,0 +1,31 @@ +/* PR target/78148 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +struct A { int a, b; }; +struct B { char c, d; }; +extern void bar (struct A, struct B); +struct C { char e, f; } a; +struct D +{ + int g; + struct C h[4]; +}; +struct D *e; + +struct D +foo (void) +{ + int b; + struct B c; + struct A d; + d.b = c.c = c.d = 0; + bar (d, c); +} + +void +baz () +{ + e->h[0].e = e->h[0].f = 0; + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78185.c b/SingleSource/Regression/C/gcc-dg/pr78185.c new file mode 100644 index 0000000000..d7781b2080 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78185.c @@ -0,0 +1,28 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O" } */ + +#include +#include +#include + +static char var1 = 0L; +static char *var2 = &var1; + +void do_exit (int i) +{ + exit (0); +} + +int main(void) +{ + struct sigaction s; + sigemptyset (&s.sa_mask); + s.sa_handler = do_exit; + s.sa_flags = 0; + sigaction (SIGALRM, &s, NULL); + alarm (1); + /* The following loop is infinite, the division by zero should not + be hoisted out of it. */ + for (; (var1 == 0 ? 0 : (100 / var1)) == *var2; ); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78213.c b/SingleSource/Regression/C/gcc-dg/pr78213.c new file mode 100644 index 0000000000..04bf0381f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78213.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fself-test=$srcdir/selftests" } */ + +/* Verify that -fself-test does not fail on a non empty source. */ + +int i; void bar(); void foo() +{ + while (i--) + bar(); +} + +/* { dg-regexp {^-fself-test: [0-9]+ pass\(es\) in [.0-9]+ seconds$|.*: note: self-tests are not enabled in this build$} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr78241.c b/SingleSource/Regression/C/gcc-dg/pr78241.c new file mode 100644 index 0000000000..b99dfca2ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78241.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-Og -funroll-loops" } */ + +static __attribute__((noinline, noclone)) unsigned +foo (unsigned x) +{ + do + x++; + while (x <= 15); + return x; +} + +int main () +{ + unsigned x = foo (-2); + if (x != (unsigned)-1) + __builtin_abort(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr78333.c b/SingleSource/Regression/C/gcc-dg/pr78333.c new file mode 100644 index 0000000000..ca037e55f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78333.c @@ -0,0 +1,22 @@ +/* { dg-do link } */ +/* { dg-options "-finstrument-functions" } */ + +/* Add empty implementations of __cyg_profile_func_enter() and + __cyg_profile_func_exit() to avoid problems on non-glibc + systems. */ +void __attribute__((no_instrument_function)) +__cyg_profile_func_enter(void *this_fn, void *call_site) +{ +} + +void __attribute__((no_instrument_function)) +__cyg_profile_func_exit(void *this_fn, void *call_site) +{ +} + +extern inline __attribute__((gnu_inline, always_inline)) int foo () { } +int main() +{ + foo (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78384.c b/SingleSource/Regression/C/gcc-dg/pr78384.c new file mode 100644 index 0000000000..d93437dd26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78384.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/78384 + { dg-do compile } + { dg-options "-O3 -w -fsplit-loops" } */ +void +a2 (int wv, int yg, int r9) +{ + while (wv < 1) + { + int vn = r9 % 0; + + while (yg < 1) + { + int lz; + + for (r9 = 0; r9 < 17; ++r9) + { + } + + it: + lz = (yg++ >= 0) ? 2 : 0; + wv = vn < lz; + } + } + goto it; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78408-1.c b/SingleSource/Regression/C/gcc-dg/pr78408-1.c new file mode 100644 index 0000000000..dc9870ac6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78408-1.c @@ -0,0 +1,88 @@ +/* PR c/78408 */ +/* { dg-do compile { target size32plus } } */ +/* { dg-options "-O2 -fdump-tree-fab1-details" } */ +/* { dg-final { scan-tree-dump-times "after previous" 17 "fab1" } } */ + +struct S { char a[33]; }; +struct T { char a[65536]; }; +void bar (int, struct S *, struct S *, struct T *, struct T *); +void baz (char *, char *); + +void +f1 (void) +{ + struct S a, b; + struct T c, d; + a = b = (struct S) {}; + c = d = (struct T) {}; + bar (1, &a, &b, &c, &d); +} + +void +f2 (void) +{ + struct S a, b; + struct T c, d; + b = (struct S) {}; + a = b; + d = (struct T) {}; + c = d; + bar (2, &a, &b, &c, &d); +} + +void +f3 (void) +{ + struct S a, b; + struct T c, d; + __builtin_memset (&b, 0, sizeof (b)); + a = b; + __builtin_memset (&d, 0, sizeof (d)); + c = d; + bar (3, &a, &b, &c, &d); +} + + +void +f4 (void) +{ + struct S a, b; + struct T c, d; + b = (struct S) {}; + __builtin_memcpy (&a, &b, sizeof (b)); + d = (struct T) {}; + __builtin_memcpy (&c, &d, sizeof (d)); + bar (4, &a, &b, &c, &d); +} + +void +f5 (void) +{ + struct S a, b; + struct T c, d; + __builtin_memset (&b, 0, sizeof (b)); + __builtin_memcpy (&a, &b, sizeof (b)); + __builtin_memset (&d, 0, sizeof (d)); + __builtin_memcpy (&c, &d, sizeof (d)); + bar (5, &a, &b, &c, &d); +} + +void +f6 (void) +{ + struct S a, b, e, g; + struct T c, d, f, h; + g = e = a = b = (struct S) {}; + h = f = c = d = (struct T) {}; + bar (6, &a, &b, &c, &d); + bar (6, &e, &g, &f, &h); +} + +void +f7 (void) +{ + char a[64], b[64]; + __builtin_memset (a + 13, 2, 27); + __builtin_memcpy (b + 4, a + 17, 23); + baz (a, b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78408-2.c b/SingleSource/Regression/C/gcc-dg/pr78408-2.c new file mode 100644 index 0000000000..89c9b7eae4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78408-2.c @@ -0,0 +1,39 @@ +/* PR c/78408 */ +/* { dg-do compile { target size32plus } } */ +/* { dg-options "-O2 -fdump-tree-fab1-details" } */ +/* { dg-final { scan-tree-dump-not "after previous" "fab1" } } */ + +struct S { char a[32]; }; +struct T { char a[65536]; }; +void bar (int, struct S *, struct S *, struct T *, struct T *); +void baz (char *, char *); + +void +f1 (void) +{ + struct S a, b; + struct T c, d; + __builtin_memset (&b, 2, sizeof (b)); + a = b; + __builtin_memset (&d, 3, sizeof (d)); + c = d; + bar (3, &a, &b, &c, &d); +} + +void +f2 (void) +{ + char a[64], b[64]; + __builtin_memset (a + 13, 2, 27); + __builtin_memcpy (b + 4, a + 17, 24); + baz (a, b); +} + +void +f3 (void) +{ + char a[64], b[64]; + __builtin_memset (a + 13, 2, 27); + __builtin_memcpy (b + 4, a + 12, 5); + baz (a, b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78445.c b/SingleSource/Regression/C/gcc-dg/pr78445.c new file mode 100644 index 0000000000..bb5327b9f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78445.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/78445 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-if-convert -ftree-vectorize" } */ +/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */ + +int a; + +void +foo (int x, int *y) +{ + while (a != 0) + if (x != 0) + { + *y = a; + x = *y; + } + else + x = a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78468.c b/SingleSource/Regression/C/gcc-dg/pr78468.c new file mode 100644 index 0000000000..a882d9a7de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78468.c @@ -0,0 +1,102 @@ +/* { dg-do run } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O2 -fno-inline" } */ + +/* Test that targets correctly round the size of the outgoing arguments + to a multiple of STACK_BOUNDARY. There is a serious alignment bug if + aligned alloca does not get aligned! */ + +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; +extern void abort (void); + +volatile int xx; +volatile int x = 16; + +void +t1 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, + void *p, int align) +{ + xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7; + if ((int)(uintptr_t)p & (align-1)) + abort (); +} + +void +t2 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, + void *p, int align, int dummy) +{ + xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7; + if ((int)(uintptr_t)p & (align-1)) + abort (); +} + +void +t1_a4 (int size) +{ + void *p = __builtin_alloca_with_align (size, 32); + t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 4); +} + +void +t2_a4 (int size) +{ + void *p = __builtin_alloca_with_align (size, 32); + t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 4, 0); +} + +void +t1_a8 (int size) +{ + void *p = __builtin_alloca_with_align (size, 64); + t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 8); +} + +void +t2_a8 (int size) +{ + void *p = __builtin_alloca_with_align (size, 64); + t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 8, 0); +} + +void +t1_a16 (int size) +{ + void *p = __builtin_alloca_with_align (size, 128); + t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 16); +} + +void +t2_a16 (int size) +{ + void *p = __builtin_alloca_with_align (size, 128); + t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 16, 0); +} + +void +t1_a32 (int size) +{ + void *p = __builtin_alloca_with_align (size, 256); + t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 32); +} + +void +t2_a32 (int size) +{ + void *p = __builtin_alloca_with_align (size, 256); + t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 32, 0); +} + + +int +main () +{ + t1_a4 (x); + t2_a4 (x); + t1_a8 (x); + t2_a8 (x); + t1_a16 (x); + t2_a16 (x); + t1_a32 (x); + t2_a32 (x); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78526.c b/SingleSource/Regression/C/gcc-dg/pr78526.c new file mode 100644 index 0000000000..560e146a12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78526.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/78526 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-sra -g -w" } */ +/* { dg-additional-options "-mavx512bw" { target i?86-*-* x86_64-*-* } } */ + +typedef unsigned U __attribute__ ((vector_size (64))); +typedef unsigned __int128 V __attribute__ ((vector_size (64))); + +static inline V +bar (U u, U x, V v) +{ + v = (V)(U) { 0, ~0 }; + v[x[0]] <<= u[-63]; + return v; +} + +V +foo (U u) +{ + return bar (u, (U) {}, (V) {}); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78540.c b/SingleSource/Regression/C/gcc-dg/pr78540.c new file mode 100644 index 0000000000..68bd9a449c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78540.c @@ -0,0 +1,27 @@ +/* PR middle-end/78540 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -Wno-psabi" } */ +/* { dg-additional-options "-march=core2" { target i?86-*-* x86_64-*-* } } */ + +typedef unsigned __int128 V __attribute__ ((vector_size (64))); +V g; + +static inline V +foo (V a) +{ + V b, c; + c[0] = 0; + a += 2281559097; + c ^= 0; + b[0] = 0; + return 1 + c + b + a; +} + +V +bar () +{ + V a = g, b = g; + a[1] ^= 1; + b[foo (a)[0] & 3] |= 1; + return b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78547.c b/SingleSource/Regression/C/gcc-dg/pr78547.c new file mode 100644 index 0000000000..9300cbc933 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78547.c @@ -0,0 +1,18 @@ +/* PR rtl-optimization/78547 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Os -g -freorder-blocks-algorithm=simple -Wno-psabi" } */ +/* { dg-additional-options "-mstringop-strategy=libcall" { target i?86-*-* x86_64-*-* } } */ + +typedef unsigned __int128 u128; +typedef unsigned __int128 V __attribute__ ((vector_size (64))); + +V +foo (u128 a, u128 b, u128 c, V d) +{ + V e = (V) {a}; + V f = e & 1; + e = 0 != e; + c = c; + f = f << ((V) {c} & 7); + return f + e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78575.c b/SingleSource/Regression/C/gcc-dg/pr78575.c new file mode 100644 index 0000000000..6b27f10706 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78575.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/78575 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -g -Wno-psabi" } */ + +typedef unsigned __int128 V __attribute__((vector_size(64))); + +V g; + +void +foo (V v) +{ + unsigned __int128 x = 1; + int c = v[1] <= ~x; + v &= v[1]; + g = v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78582.c b/SingleSource/Regression/C/gcc-dg/pr78582.c new file mode 100644 index 0000000000..6d125cf8ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78582.c @@ -0,0 +1,19 @@ +/* PR target/78582. */ +/* { dg-options "-fprofile-generate" } */ +/* { dg-do compile } */ +/* { dg-require-effective-target nonlocal_goto } */ + +#include + +void reader_loop () {} + +int +main (int argc, char argv, char env) +{ + int a; + setjmp (0); + argc = a = argc; + reader_loop (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78644-1.c b/SingleSource/Regression/C/gcc-dg/pr78644-1.c new file mode 100644 index 0000000000..d6aafeb7c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78644-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Og -fipa-cp -w -Wno-psabi" } */ + +typedef unsigned __int128 u128; +typedef unsigned __int128 V __attribute__ ((vector_size (64))); + +V x4; + +static V +bar (u128 x2, u128 x3) +{ + while (x4[0]--) + x2 /= x3 >>= 1; + return x2 + x3 + x4; +} + +void +foo (void) +{ + bar (0, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78644-2.c b/SingleSource/Regression/C/gcc-dg/pr78644-2.c new file mode 100644 index 0000000000..3395ddee95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78644-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Og -finline-functions-called-once -w -Wno-psabi" } */ + +typedef unsigned V __attribute__ ((vector_size (64))); +typedef unsigned __int128 U __attribute__ ((vector_size (64))); + +U +bar4 (U u0, U u1) +{ + if (u1[0]) + u1 <<= 1; + return u0 + u1; +} + +V +foo (U u, V v) +{ + v |= (unsigned)bar4(u, (U){})[0]; + return v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78721.c b/SingleSource/Regression/C/gcc-dg/pr78721.c new file mode 100644 index 0000000000..fb2ffc30eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78721.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int a, b, c; + +int fn1 (char e, char f) +{ + return !f || (e && f == 1); +} + +void fn2 (char e) +{ + while (b) + e = 0; + a = 128; + c = fn1 (e, a == e); +} + +int main () +{ + fn2 (0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78725-2.c b/SingleSource/Regression/C/gcc-dg/pr78725-2.c new file mode 100644 index 0000000000..9de489edda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78725-2.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fsplit-loops" } */ + +int a, b, c; + +int main () +{ + int d; + for (; c < 1; c++) + for (d = 0; d < 3; d++) + for (b = 0; b < 1; b++) + if (c >= d) + a = 1; + + if (a != 1) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78725.c b/SingleSource/Regression/C/gcc-dg/pr78725.c new file mode 100644 index 0000000000..ed95790a44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78725.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fsplit-loops" } */ + +int fn1 (int b, int c) +{ + return c < 0 || c > 31 ? 0 : b >> c; +} + +unsigned char d = 255; +int e, f; + +int main () +{ + for (; f < 2; f++) + e = fn1 (1, d++); + if (e != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78768.c b/SingleSource/Regression/C/gcc-dg/pr78768.c new file mode 100644 index 0000000000..72ac3f8712 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78768.c @@ -0,0 +1,15 @@ +/* PR c/78768 - -Walloca-larger-than and -Wformat-overflow warnings disabled + by -flto + { dg-do link } + { dg-require-effective-target lto } + { dg-require-linker-plugin "" } + { dg-options "-O2 -Walloca-larger-than=10 -Wformat -Wformat-overflow -flto" } */ + +int main (void) +{ + char *d = (char *)__builtin_alloca (12); /* { dg-warning "argument to .alloca. is too large" } */ + + __builtin_sprintf (d, "%32s", "x"); /* { dg-warning "directive writing 32 bytes into a region of size 12" "-Wformat-overflow" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78775.c b/SingleSource/Regression/C/gcc-dg/pr78775.c new file mode 100644 index 0000000000..120c252c99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78775.c @@ -0,0 +1,19 @@ +/* PR c/78775 - [7 Regression] ICE in maybe_warn_alloc_args_overflow + { dg-do compile } + { dg-options "-O2" } */ + +int a, b, *c; + +int main (void) +{ + unsigned long d = 0; + while (1) + { + switch (b) + case 'S': + d = a; + c = __builtin_malloc (d); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78888.c b/SingleSource/Regression/C/gcc-dg/pr78888.c new file mode 100644 index 0000000000..77a130cf11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78888.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/78888 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void kill (void); +void keep (void); + +void g (int x) +{ + if (__builtin_toupper ((unsigned char)x) == 'a') + kill (); + if (__builtin_toupper ((unsigned char)x) == 'z') + kill (); + if (__builtin_tolower ((unsigned char)x) == 'A') + kill (); + if (__builtin_tolower ((unsigned char)x) == 'Z') + kill (); + + if (__builtin_toupper ((unsigned char)x) == 'A') + keep (); + if (__builtin_toupper ((unsigned char)x) == 'Z') + keep (); + if (__builtin_tolower ((unsigned char)x) == 'a') + keep (); + if (__builtin_tolower ((unsigned char)x) == 'z') + keep (); +} +/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */ +/* { dg-final { scan-tree-dump-times "keep" 4 "evrp"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr78902.c b/SingleSource/Regression/C/gcc-dg/pr78902.c new file mode 100644 index 0000000000..a9a617cde2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78902.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ + +void *ptr; + +void foo(void) +{ + __builtin_malloc (1); /* { dg-warning "ignoring return value of '__builtin_malloc' declared with attribute 'warn_unused_result'" } */ + __builtin_calloc (10, 20); /* { dg-warning "ignoring return value of '__builtin_calloc' declared with attribute 'warn_unused_result'" } */ + __builtin_alloca (10); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */ + __builtin_realloc (ptr, 100); /* { dg-warning "ignoring return value of '__builtin_realloc' declared with attribute 'warn_unused_result'" } */ + __builtin_aligned_alloc (10, 16); /* { dg-warning "ignoring return value of '__builtin_aligned_alloc' declared with attribute 'warn_unused_result'" } */ + __builtin_strdup ("pes"); /* { dg-warning "ignoring return value of '__builtin_strdup' declared with attribute 'warn_unused_result'" } */ + __builtin_strndup ("pes", 10); /* { dg-warning "ignoring return value of '__builtin_strndup' declared with attribute 'warn_unused_result'" } */ + /* { dg-warning "\\\[-Wstringop-overread" "strndup excessive bound" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78957.c b/SingleSource/Regression/C/gcc-dg/pr78957.c new file mode 100644 index 0000000000..432211935b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78957.c @@ -0,0 +1,6 @@ +/* PR driver/78957 */ +/* { dg-do compile } */ +/* { dg-options "-fno-sso-struct=none" } */ +/* { dg-error "unrecognized command-line option" "" { target *-*-* } 0 } */ + +int i; diff --git a/SingleSource/Regression/C/gcc-dg/pr78965.c b/SingleSource/Regression/C/gcc-dg/pr78965.c new file mode 100644 index 0000000000..43da70b29e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78965.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/78965 */ +/* { dg-do run { target c99_runtime } } */ +/* { dg-options "-O2" } */ + +int +main () +{ + int a = 5, b = 6; + int c = __builtin_snprintf (0, 0, "a%nb%nc", &a, &b); + if (a + b + c != 6) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78973-2.c b/SingleSource/Regression/C/gcc-dg/pr78973-2.c new file mode 100644 index 0000000000..ad292092a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78973-2.c @@ -0,0 +1,25 @@ +/* PR c/78973 - warning: ‘memcpy’: specified size exceeds maximum object + size [-Wstringop-overflow=] + + This is a companion test for the bug above that verifies that the correct + range of the int variable is detected. + + { dg-do compile } + { dg-require-effective-target int32plus } + { dg-options "-O2 -Walloc-size-larger-than=4" } */ + +void *p; + +static void f (int n) +{ + if (n <= 4) + p = __builtin_malloc (n); + /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size 4" "ilp32" { target *-*-* } .-1 } */ +} + +void g (unsigned n) +{ + if (n < 5) + n = 5; + f (n); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr78973.c b/SingleSource/Regression/C/gcc-dg/pr78973.c new file mode 100644 index 0000000000..7dd67cef33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr78973.c @@ -0,0 +1,20 @@ +/* PR c/78973 - warning: ‘memcpy’: specified size exceeds maximum object size + + Test case for what was initially thought to be a false positive but after + deeper investigation turned out to be a true positive. + + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +static void f (void *p, int n) +{ + if (n <= 4) + __builtin_memset (p, 0, n); /* { dg-warning "exceeds maximum object size" "pr79073" { xfail { int16 && { ! msp430_large } } } } */ +} + +void g (void *d, unsigned n) +{ + if (n < 5) + n = 5; + f (d, n); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79080.c b/SingleSource/Regression/C/gcc-dg/pr79080.c new file mode 100644 index 0000000000..de0969d464 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79080.c @@ -0,0 +1,19 @@ +/* PR target/79080 */ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ +/* { dg-additional-options "-mcpu=8548" { target { powerpc*-*-* && ilp32 } } } */ + +int +foo (char x) +{ + int a; + + for (;;) + { + x += 59; + if (x != 0) + a = 0; + else + return 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79214.c b/SingleSource/Regression/C/gcc-dg/pr79214.c new file mode 100644 index 0000000000..2f93eed278 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79214.c @@ -0,0 +1,88 @@ +/* PR preprocessor/79214 - -Wno-system-header defeats strncat buffer overflow + warnings + { dg-do compile } + { dg-options "-O2" } */ + +#include "pr79214.h" + +typedef __SIZE_TYPE__ size_t; + +char d[3]; +char s[4]; + +static size_t range (void) +{ + extern size_t size (); + size_t n = size (); + if (n <= sizeof d) + return sizeof d + 1; + + return n; +} + +void test_bzero (void) +{ + bzero (d, range ()); /* { dg-warning ".__builtin_(bzero|memset). writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +void test_memcpy (void) +{ + memcpy (d, s, range ()); /* { dg-warning ".__builtin_memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +void test_memmove (void) +{ + memmove (d, d + 1, range ()); /* { dg-warning ".__builtin_memmove. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +void test_mempcpy (void) +{ + mempcpy (d, s, range ()); /* { dg-warning ".__builtin_mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +void test_memset (int n) +{ + memset (d, n, range ()); /* { dg-warning ".__builtin_memset. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +void test_strcat (int i) +{ + const char *s = i < 0 ? "123" : "4567"; + + strcat (d, s); /* { dg-warning ".__builtin_strcat. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +char* test_stpcpy (int i) +{ + const char *s = i < 0 ? "123" : "4567"; + + return stpcpy (d, s); /* { dg-warning ".__builtin_stpcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +char* test_stpncpy (int i) +{ + const char *s = i < 0 ? "123" : "4567"; + + return stpncpy (d, s, range ()); /* { dg-warning ".__builtin_stpncpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +char* test_strcpy (int i) +{ + const char *s = i < 0 ? "123" : "4567"; + + return strcpy (d, s); /* { dg-warning ".__builtin_strcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +char* test_strncpy (int i) +{ + const char *s = i < 0 ? "123" : "4567"; + + return strncpy (d, s, range ()); /* { dg-warning ".__builtin_strncpy. writing 4 or more bytes into a region of size 3 overflows the destination" "pr?????" { xfail { *-*-* } } } */ +} + +char* test_strncat (int i) +{ + const char *s = i < 0 ? "123" : "4567"; + + return strncat (d, s, range ()); /* { dg-warning ".__builtin_strncat. specified bound \\\[4, \[0-9\]+] exceeds destination size 3" "pr?????" { xfail { *-*-* } } } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79214.h b/SingleSource/Regression/C/gcc-dg/pr79214.h new file mode 100644 index 0000000000..1481681178 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79214.h @@ -0,0 +1,13 @@ +#pragma GCC system_header + +#define bzero __builtin_bzero +#define memcpy __builtin_memcpy +#define memmove __builtin_memmove +#define mempcpy __builtin_mempcpy +#define memset __builtin_memset +#define strcat __builtin_strcat +#define stpcpy __builtin_stpcpy +#define stpncpy __builtin_stpncpy +#define strcpy __builtin_strcpy +#define strncpy __builtin_strncpy +#define strncat __builtin_strncat diff --git a/SingleSource/Regression/C/gcc-dg/pr79222.c b/SingleSource/Regression/C/gcc-dg/pr79222.c new file mode 100644 index 0000000000..87e9fb68b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79222.c @@ -0,0 +1,13 @@ +/* PR middle-end/79222 - missing -Wstringop-overflow= on a stpcpy overflow + { dg-do compile } + { dg-options "-O2" } */ + +extern char* stpcpy (char*, const char*); + +char d[3]; + +char* f (int i) +{ + const char *s = i < 0 ? "01234567" : "9876543210"; + return stpcpy (d, s); /* { dg-warning ".stpcpy. writing between 9 and 11 bytes into a region of size 3 overflows the destination" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79223.c b/SingleSource/Regression/C/gcc-dg/pr79223.c new file mode 100644 index 0000000000..ef0dd1b7bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79223.c @@ -0,0 +1,37 @@ +/* PR middle-end/79223 - missing -Wstringop-overflow on a memmove overflow + { dg-do compile } + { dg-additional-options "-O2 -Wall -Wno-array-bounds -std=gnu99" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); +extern void* mempcpy (void*, const void*, size_t); +extern void* memmove (void*, const void*, size_t); + +char d[3]; +char s[4]; + +size_t range (void) +{ + extern size_t size (); + size_t n = size (); + if (n <= sizeof d) + return sizeof d + 1; + + return n; +} + +void test_memcpy (void) +{ + memcpy (d, s, range ()); /* { dg-warning ".memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */ +} + +void test_mempcpy (void) +{ + mempcpy (d, s, range ()); /* { dg-warning ".mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */ +} + +void test_memmove (void) +{ + memmove (d + 1, d, range ()); /* { dg-warning ".memmove. writing 4 or more bytes into a region of size 2 overflows the destination" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79255.c b/SingleSource/Regression/C/gcc-dg/pr79255.c new file mode 100644 index 0000000000..bcccec0eec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79255.c @@ -0,0 +1,21 @@ +/* PR bootstrap/79255 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fno-toplevel-reorder -Wno-attributes" } */ + +static inline __attribute__((always_inline)) int foo (int x); + +int +baz (void) +{ + return foo (3) + foo (6) + foo (9); +} + +static inline __attribute__((always_inline)) int +foo (int x) +{ + auto inline int __attribute__((noinline)) bar (int x) + { + return x + 3; + } + return bar (x) + bar (x + 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79342.c b/SingleSource/Regression/C/gcc-dg/pr79342.c new file mode 100644 index 0000000000..958de55d09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79342.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -gsplit-dwarf -g3" } */ +/* { dg-additional-options "-march=skylake -mrtm -mabm" { target x86_64-*-* i?86-*-* } } */ + +int a; +void b(void); + +void e(int *); +int f(void); + +void +c(void) +{ + int d; + e(&d); + if (f()) + b(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79405.c b/SingleSource/Regression/C/gcc-dg/pr79405.c new file mode 100644 index 0000000000..c17baff713 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79405.c @@ -0,0 +1,45 @@ +/* PR rtl-optimization/79405 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +char cz; +long long int xx, u2; + +void +qv (int js, int wl) +{ + if (js != 0) + { + short int sc; + int *at = (int *)≻ + long long int gx = 0; + + for (;;) + { + *at = 0; + js /= sc; + + for (wl = 0; wl < 2; ++wl) + { + xx = gx; + u2 %= xx > 0; + cz /= u2; + + fa: + if (cz != u2) + { + gx |= js; + cz = gx / js; + } + } + } + + yq: + wl /= 0x80000000; + u2 = wl; + u2 |= (wl != 0) | (wl != 0 && gx != 0); + js = u2; + goto fa; + } + goto yq; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79412.c b/SingleSource/Regression/C/gcc-dg/pr79412.c new file mode 100644 index 0000000000..b60d5e1b2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79412.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +int a; +/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */ +void fn1 () +{ + a++; +} +int a[] = {2}; /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr79494.c b/SingleSource/Regression/C/gcc-dg/pr79494.c new file mode 100644 index 0000000000..e8543f8c43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79494.c @@ -0,0 +1,22 @@ +/* PR target/79494 */ +/* { dg-do compile } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-O2 -fsplit-stack -g" } */ + +void +foo (int a) +{ + __label__ lab; + __attribute__((noinline, noclone)) void bar (int b) + { + switch (b) + { + case 1: + goto lab; + case 2: + goto lab; + } + } + bar (a); +lab:; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79499.c b/SingleSource/Regression/C/gcc-dg/pr79499.c new file mode 100644 index 0000000000..509549ff2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79499.c @@ -0,0 +1,13 @@ +/* PR middle-end/79499 */ +/* { dg-do compile { target split_stack } } */ +/* { dg-options "-O2 -fsplit-stack -fno-omit-frame-pointer" } */ + +struct S { struct S *a, *b; }; + +void +foo (struct S *x) +{ + do + x->b = x->a; + while (x = x->a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79538.c b/SingleSource/Regression/C/gcc-dg/pr79538.c new file mode 100644 index 0000000000..4f10d97395 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79538.c @@ -0,0 +1,22 @@ +/* PR middle-end/79538 - missing -Wformat-overflow with %s and non-member array arguments + { dg-do compile } + { dg-options "-O2 -Wformat-overflow" } */ + +char a3[3]; +char a4[4]; +char d[3]; + +void g (int i) +{ + const char *s = i < 0 ? a3 : a4; + __builtin_sprintf (d, "%s", s); /* { dg-warning ".__builtin_sprintf. may write a terminating nul past the end of the destination" } */ + return; +} + +void f () +{ + char des[3]; + char src[] = "abcd"; + __builtin_sprintf (des, "%s", src); /* { dg-warning "directive writing 4 bytes into a region of size 3" } */ + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79570.c b/SingleSource/Regression/C/gcc-dg/pr79570.c new file mode 100644 index 0000000000..a15be9f201 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79570.c @@ -0,0 +1,6 @@ +/* PR target/79570 */ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling2 -fvar-tracking-assignments -g" } */ +/* { dg-warning "changes selective scheduling" "" { target *-*-* } 0 } */ + +#include "pr69956.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr79574-2.c b/SingleSource/Regression/C/gcc-dg/pr79574-2.c new file mode 100644 index 0000000000..995dff4017 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79574-2.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/79574 */ +/* { dg-do compile } */ +/* { dg-options "-Os --param gcse-cost-distance-ratio=2147483647" } */ + +#include "stdarg.h" + +int buf[100]; +int buf1[10]; + +int rd (int *pppp, int n, ...) +{ + va_list argp; + int *p; + int i; + int res; + + va_start (argp, n); + for (; n > 0; n--) + va_arg (argp, double); + p = va_arg (argp, int *); + i = va_arg (argp, int); + + res = p[i]; + __builtin_printf ("%d\n", res); + + return res; +} + +int mpx_test (int argc, const char **argv) +{ + rd (buf1, 2, 10.0d, 10.0d, buf, 100, buf1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79574.c b/SingleSource/Regression/C/gcc-dg/pr79574.c new file mode 100644 index 0000000000..1b666e20d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79574.c @@ -0,0 +1,10 @@ +/* PR rtl-optimization/79574 */ +/* { dg-do compile } */ +/* { dg-options "-Os --param gcse-cost-distance-ratio=2147483647" } */ + +void a (void) +{ + volatile int b; + for (;; b) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79677.c b/SingleSource/Regression/C/gcc-dg/pr79677.c new file mode 100644 index 0000000000..53a3176453 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79677.c @@ -0,0 +1,15 @@ +/* PR c/79677 */ +/* { dg-do compile } */ +/* { dg-options "-Wformat -Werror=format-security -Wformat" } */ +/* { dg-message "some warnings being treated as errors" "" { target *-*-* } 0 } */ + +void foo (char *); + +int +main () +{ + char s[10] = "%s"; + foo (s); + __builtin_printf (s); /* { dg-error "format not a string literal and no format arguments" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79715.c b/SingleSource/Regression/C/gcc-dg/pr79715.c new file mode 100644 index 0000000000..0f0f90f712 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79715.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/79715 - hand-rolled strdup with unused result + not eliminated + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +void f (const char *s) +{ + unsigned n = __builtin_strlen (s) + 1; + char *p = __builtin_malloc (n); + __builtin_memcpy (p, s, n); + __builtin_free (p); +} + +void g (const char *s) +{ + unsigned n = __builtin_strlen (s) + 1; + char *p = __builtin_malloc (n); + __builtin_strcpy (p, s); + __builtin_free (p); +} + +/* { dg-final { scan-tree-dump-not "free" "optimized" } } + { dg-final { scan-tree-dump-not "malloc" "optimized" } } + { dg-final { scan-tree-dump-not "memcpy" "optimized" } } + { dg-final { scan-tree-dump-not "strcpy" "optimized" } } + { dg-final { scan-tree-dump-not "strlen" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr79730.c b/SingleSource/Regression/C/gcc-dg/pr79730.c new file mode 100644 index 0000000000..497823a486 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79730.c @@ -0,0 +1,6 @@ +/* PR c/79730 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +register int x() asm (""); /* { dg-error "invalid storage class" } */ +register float y() asm (""); /* { dg-error "invalid storage class" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr79788-1.c b/SingleSource/Regression/C/gcc-dg/pr79788-1.c new file mode 100644 index 0000000000..5ad546cd23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79788-1.c @@ -0,0 +1,11 @@ +/* PR middle-end/79788 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +long long +foo (long long x, long long y) +{ + if (y > 1234567891234567891234567891234567812 / x) /* { dg-warning "integer constant is too large for its type" } */ + return x; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79788-2.c b/SingleSource/Regression/C/gcc-dg/pr79788-2.c new file mode 100644 index 0000000000..c9447b1f42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79788-2.c @@ -0,0 +1,11 @@ +/* PR middle-end/79788 */ +/* { dg-do compile } */ +/* { dg-options "-ftrapv" } */ + +void bar (void); +void +foo (long long int p, long long int q) +{ + if (p >= 1234567891234567891234567891234567812 + q) /* { dg-warning "integer constant is too large for its type" } */ + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79972.c b/SingleSource/Regression/C/gcc-dg/pr79972.c new file mode 100644 index 0000000000..4d3064fb5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79972.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/79972 */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Walloca -Wvla-larger-than=10000" } */ + +int +f (int dim, int *b, int *c) +{ + /* -Wvla-larger-than is only issued with optimization (see PR 100510). */ + int newcentroid[3][dim]; + int *a = newcentroid[2]; + int i, dist = 0; + __builtin_memcpy (newcentroid, c, sizeof (newcentroid)); + for (i = 0; i < dim; i++) + dist += (a[i] - b[i]) * (a[i] - b[i]); + return dist; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr79983.c b/SingleSource/Regression/C/gcc-dg/pr79983.c new file mode 100644 index 0000000000..1e292d4210 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79983.c @@ -0,0 +1,15 @@ +/* PR c/79983 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct S; +struct S { int i; }; /* { dg-message "originally defined here" } */ +struct S { int i, j; }; /* { dg-error "redefinition of 'struct S'" } */ + +enum E; +enum E { A, B, C }; /* { dg-message "originally defined here" } */ +enum E { D, F }; /* { dg-error "redeclaration of 'enum E'" } */ + +union U; +union U { int i; }; /* { dg-message "originally defined here" } */ +union U { int i; double d; }; /* { dg-error "redefinition of 'union U'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr79985.c b/SingleSource/Regression/C/gcc-dg/pr79985.c new file mode 100644 index 0000000000..7b5a5b2721 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr79985.c @@ -0,0 +1,12 @@ +/* PR rtl-optimization/79985 */ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O3 -fschedule-insns -fselective-scheduling" } */ + +long a; +int b; +void +c () +{ + __asm("" : "=r"(a) : "0"(c)); + __asm("" : "=r"(b)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80020.c b/SingleSource/Regression/C/gcc-dg/pr80020.c new file mode 100644 index 0000000000..4ab1aa8df2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80020.c @@ -0,0 +1,26 @@ +/* PR middle-end/80020 - gcc confused about aligned_alloc argument order + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +void sink (void*); + +void foo (void) +{ + enum { + Align = 32, + Size = 123 + }; + + void *p = __builtin_aligned_alloc (Align, Size); + unsigned n = __builtin_object_size (p, 0); + + if (n != Size) + __builtin_abort (); + + __builtin___memset_chk (p, 0, Size, n); + + sink (p); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } + { dg-final { scan-tree-dump-not "memset_chk" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr80100.c b/SingleSource/Regression/C/gcc-dg/pr80100.c new file mode 100644 index 0000000000..0d462be30a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80100.c @@ -0,0 +1,9 @@ +/* PR middle-end/80100 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +long int +foo (long int x) +{ + return 2L | ((x - 1L) >> (__SIZEOF_LONG__ * __CHAR_BIT__ - 1)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80112.c b/SingleSource/Regression/C/gcc-dg/pr80112.c new file mode 100644 index 0000000000..8d6ef3c88a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80112.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/80112 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fmodulo-sched" } */ +/* { dg-require-effective-target label_values } */ + +void **a; + +void +foo (int c) +{ + void *d[] = {&&e, &&f}; + a = d; + switch (c) + { + f: + c = 9; + /* FALLTHRU */ + case 9: + goto *a++; + e:; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80131-1.c b/SingleSource/Regression/C/gcc-dg/pr80131-1.c new file mode 100644 index 0000000000..0bfe1f4f3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80131-1.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-fdump-tree-gimple" } */ + +/* Checks the simplification of: + 1 << (C - x) to (1 << C) >> x, where C = precision (type) - 1 + f1 is not simplified but f2, f3 and f4 are. */ + +__INT64_TYPE__ f1 (__INT64_TYPE__ i) +{ + return (__INT64_TYPE__)1 << (31 - i); +} + +__INT64_TYPE__ f2 (__INT64_TYPE__ i) +{ + return (__INT64_TYPE__)1 << (63 - i); +} + +__UINT64_TYPE__ f3 (__INT64_TYPE__ i) +{ + return (__UINT64_TYPE__)1 << (63 - i); +} + +__INT32_TYPE__ f4 (__INT32_TYPE__ i) +{ + return (__INT32_TYPE__)1 << (31 - i); +} + +/* { dg-final { scan-tree-dump-times "= 31 -" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "9223372036854775808 >>" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump "2147483648 >>" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr80163.c b/SingleSource/Regression/C/gcc-dg/pr80163.c new file mode 100644 index 0000000000..f65955c0ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80163.c @@ -0,0 +1,23 @@ +/* PR middle-end/80163 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O0" } */ + +typedef __INTPTR_TYPE__ intptr_t; +void bar (void); + +__int128_t * +foo (void) +{ +a: + bar (); +b:; + static __int128_t d = (intptr_t) &&a - (intptr_t) &&b; /* { dg-error "initializer element is not computable at load time" } */ + return &d; +} + +__int128_t * +baz (void) +{ + static __int128_t d = (long) (3 * 4); + return &d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80170.c b/SingleSource/Regression/C/gcc-dg/pr80170.c new file mode 100644 index 0000000000..e400e14142 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80170.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-options "-fgimple -O2 -ftree-slp-vectorize" } */ +/* { dg-require-effective-target ptr32plus } */ + +struct A +{ + void * a; + void * b; +}; + +struct __attribute__((aligned(16))) B +{ + void * pad; + void * misaligned; + void * pad2; + + struct A a; +}; + +__attribute__((noclone, noinline)) +void __GIMPLE (startwith("slp")) +NullB (void * misalignedPtr) +{ + struct B * b; + + bb_2: + b_2 = misalignedPtr_1(D) + _Literal (__SIZETYPE__) -__SIZEOF_POINTER__; + __MEM (b_2).a.a = _Literal (void *) 0; + __MEM (b_2).a.b = _Literal (void *) 0; + return; + +} + +int main() +{ + struct B b; + NullB (&b.misaligned); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80218.c b/SingleSource/Regression/C/gcc-dg/pr80218.c new file mode 100644 index 0000000000..8669ee1275 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80218.c @@ -0,0 +1,28 @@ +/* { dg-options "-O2 -fdump-rtl-ira-details-blocks" } */ +/* { dg-require-effective-target c99_runtime } */ + +#include + +void foo (float *); + +void +f1 (float *x) +{ + x[0] = sqrtf (x[0]); +} + +void +f2 (float *x) +{ + sqrtf (x[0]); + foo (x); +} + +void +f3 (float *x) +{ + acosf (x[0]); + foo (x); +} + +/* { dg-final { scan-rtl-dump-not "Invalid sum" "ira" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr80286.c b/SingleSource/Regression/C/gcc-dg/pr80286.c new file mode 100644 index 0000000000..82f35b5009 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80286.c @@ -0,0 +1,23 @@ +/* PR target/80286 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-psabi" } */ + +typedef int V __attribute__((vector_size (4 * sizeof (int)))); + +__attribute__((noinline, noclone)) V +foo (V x, V y) +{ + return x << y[0]; +} + +int +main () +{ + V x = { 1, 2, 3, 4 }; + V y = { 5, 6, 7, 8 }; + V z = foo (x, y); + V e = { 1 << 5, 2 << 5, 3 << 5, 4 << 5 }; + if (__builtin_memcmp (&z, &e, sizeof (V))) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80463.c b/SingleSource/Regression/C/gcc-dg/pr80463.c new file mode 100644 index 0000000000..cebf2fef1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80463.c @@ -0,0 +1,54 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-g -O2 -fvar-tracking-assignments -fselective-scheduling2 -ftree-loop-vectorize -fnon-call-exceptions -fno-tree-vrp -fno-gcse-lm -fno-tree-loop-im -fno-reorder-blocks-and-partition -fno-reorder-blocks -fno-move-loop-invariants -w" } */ + +short int t2; +int cd, aa, ft; + +void +dh (void) +{ + int qs = 0; + + if (t2 < 1) + { + int bq = 0; + + while (bq < 1) + { + } + + while (t2 < 1) + { + if (t2 == 0) + { + bq = 0; + cd = !!cd; + } + else + { + bq = 1; + cd = bq > qs; + } + + t2 += cd; + bq = (t2 / qs) == bq; + + if (aa != ft) + { + qs %= 0; + while (bq != 0) + { + ro: + ; + } + } + + ++t2; + } + + ia: + goto ro; + } + + goto ia; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80468.c b/SingleSource/Regression/C/gcc-dg/pr80468.c new file mode 100644 index 0000000000..5c312a6289 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80468.c @@ -0,0 +1,10 @@ +/* PR c/80468 */ +/* { dg-do compile { target { ! int128 } } } */ +/* { dg-options "" } */ + +void +foo (void) +{ + __attribute__ ((__vector_size__ (4 * sizeof (unsigned)))) __int128 b; /* { dg-error "is not supported on this target" } */ + 0 != b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80492.c b/SingleSource/Regression/C/gcc-dg/pr80492.c new file mode 100644 index 0000000000..1721b2dee3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80492.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-w -O2 -fdump-tree-optimized" } */ + +static __inline__ __attribute__((__always_inline__)) +void syscall_7 (int val) +{ + register int reg __asm ("4") = val; + __asm __volatile__ ("/* Some Code %0 */" :: "r" (reg)); +} + +void do_syscalls (void) +{ + for (int s = 0; s < 2; s++) + { + syscall_7 (0); + syscall_7 (1); + } +} + +/* { dg-final { scan-tree-dump-times "reg = " 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr80500.c b/SingleSource/Regression/C/gcc-dg/pr80500.c new file mode 100644 index 0000000000..ae3ac0184b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80500.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/80500 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-loops -ftree-loop-if-convert -fvariable-expansion-in-unroller" } */ + +signed char v; + +void +foo (int x) +{ + while (x != 0) + { + v = (x >= 0) + 1; + ++x; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80632.c b/SingleSource/Regression/C/gcc-dg/pr80632.c new file mode 100644 index 0000000000..0d3c7b3c02 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80632.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/80632 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int bar (void); +extern void baz (void); +int a; + +int +foo (void) +{ + int c = 8; + if (bar ()) + { + baz (); + switch (a) + { + case 0: + c = 1; + break; + case 1: + c = 0; + break; + case 2: + c = 0; + break; + case 3: + c = 0; + break; + default: + c = 1; + } + } + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80693.c b/SingleSource/Regression/C/gcc-dg/pr80693.c new file mode 100644 index 0000000000..507177167e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80693.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-options "-O -fno-tree-coalesce-vars" } */ +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned u32; +typedef unsigned long long u64; + +static u64 __attribute__((noinline, noclone)) +foo(u8 u8_0, u16 u16_0, u32 u32_0, u64 u64_0, u16 u16_1) +{ + u16_1 += 0x1051; + u16_1 &= 1; + u8_0 <<= u32_0 & 7; + u16_0 -= !u16_1; + u16_1 >>= ((u16)-u8_0 != 0xff); + return u8_0 + u16_0 + u64_0 + u16_1; +} + +int +main (void) +{ + u64 x = foo(1, 1, 0xffff, 0, 1); + if (x != 0x80) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80747.c b/SingleSource/Regression/C/gcc-dg/pr80747.c new file mode 100644 index 0000000000..8befab2ab1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80747.c @@ -0,0 +1,18 @@ +/* PR rtl-optimization/80747 */ +/* { dg-do compile } */ +/* { dg-options "-fprofile-use -freorder-blocks-and-partition -O1 -foptimize-sibling-calls -Wno-missing-profile" } */ + +int +foo (int a) +{ + int r; + if (a & 1) + r = foo (a - 1); + else if (a) + r = foo (a - 2); + else + return 0; + if (r) + r = r; + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80775.c b/SingleSource/Regression/C/gcc-dg/pr80775.c new file mode 100644 index 0000000000..df4d250687 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80775.c @@ -0,0 +1,21 @@ +/* PR middle-end/80775 ICE: -O3 produces ice in group_case_labels_stmt. */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +typedef struct { short a; } b; +b c[10]; +int d, e, f, g, h; +int +i (void) +{ + f = 0; + for (; f < e; f++) { + switch (g) { + case 1: + d = 1; + case 2: + c[2 + f].a = 1; + } + h += c[f].a; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80776-1.c b/SingleSource/Regression/C/gcc-dg/pr80776-1.c new file mode 100644 index 0000000000..b9bce62d98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80776-1.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wformat-overflow" } */ + +extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int +__attribute__ ((__nothrow__ , __leaf__)) sprintf (char *__restrict __s, const char *__restrict __fmt, ...) +{ + return __builtin___sprintf_chk (__s, 2 - 1, + __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ()); +} +char number[sizeof "999999"]; +int somerandom (void); +void +Foo (void) +{ + int i = somerandom (); + if (! (0 <= i)) + __builtin_unreachable (); + if (! (0 <= i && i <= 999999)) + __builtin_unreachable (); + + /* Legacy evrp sets the range of i to [0, MAX] *before* the first conditional, + and to [0,999999] *before* the second conditional. This is because both + evrp and VRP use trickery to set global ranges when this particular use of + a __builtin_unreachable is in play (see uses of + assert_unreachable_fallthru_edge_p). + + Setting these ranges at the definition site, causes VRP to remove the + unreachable code altogether, leaving the following sprintf unguarded. This + causes the bogus warning below. */ + sprintf (number, "%d", i); /* { dg-bogus "writing" "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80776-2.c b/SingleSource/Regression/C/gcc-dg/pr80776-2.c new file mode 100644 index 0000000000..55cef3b1a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80776-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wformat-overflow" } */ + +extern int sprintf (char *restrict, const char *restrict, ...) + __attribute__ ((__nothrow__)); + extern int foo (void); + +int +Fgenerate_new_buffer_name (void) +{ + char number[2]; + int i = foo (); + if (i < 0) + __builtin_unreachable (); + if (i >= 2) + __builtin_unreachable (); + return sprintf (number, "%d", i); /* { dg-bogus "writing" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80788.c b/SingleSource/Regression/C/gcc-dg/pr80788.c new file mode 100644 index 0000000000..b14d371009 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80788.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/80788 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fwrapv" } */ + +void +foo (signed char x) +{ + signed char a = (x + 1) ^ 128; + x &= !!a; + if (x != 0) + for (;;) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80823.c b/SingleSource/Regression/C/gcc-dg/pr80823.c new file mode 100644 index 0000000000..0a48764bfd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80823.c @@ -0,0 +1,23 @@ +/* PR middle-end/80823 ICE: verify_flow_info failed */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, c; +int b[1]; +static inline int +fn1() { + switch (a) + case 0: + case 2: + return 1; + return 0; +} +void fn2() { + int i; + for (;; ++i) { + c = b[i]; + int d = !fn1(); + if (d) + __asm__(""); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80903.c b/SingleSource/Regression/C/gcc-dg/pr80903.c new file mode 100644 index 0000000000..73d44b0dc4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80903.c @@ -0,0 +1,34 @@ +/* PR rtl-optimization/80903 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -funroll-loops" } */ + +short int a; + +void +foo (int x, short int y, short int z) +{ + if (y != 0) + { + const short int b = 37; + y = 0; + while (y < b) + { + while (y < b) + { + lab: + ++y; + } + for (y = 0; y < b - 1; ++y) + ; + if (z != 0) + { + --a; + y *= a; + } + z = x; + } + x = 0; + } + + goto lab; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr80907.c b/SingleSource/Regression/C/gcc-dg/pr80907.c new file mode 100644 index 0000000000..56e1d36259 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr80907.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ + + + +int x[3]; +int n=2; +void foo() +{ + for(int i=0;i>= 1; + f = b | (f >> b); + return a + c + d + f + g + h; +} + +int +main (void) +{ + if (foo (0, 0, 0, 0, 0, 0, 0, 0) != 0x100) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81020.c b/SingleSource/Regression/C/gcc-dg/pr81020.c new file mode 100644 index 0000000000..4c70236d88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81020.c @@ -0,0 +1,27 @@ +/* PR rtl-optimization/81020 */ +/* { dg-do run } */ +/* { dg-options "-O -fno-tree-bit-ccp -fno-tree-coalesce-vars -fno-tree-vrp" } */ + +unsigned v = 4; + +unsigned long long __attribute__((noipa)) +foo (unsigned x) +{ +#if __SIZEOF_INT__ == 2 + __UINT32_TYPE__ a = v; +#else + unsigned a = v; +#endif + a &= 1; + x |= 0 < a; + a >>= 31; + return x + a; +} + +int +main () +{ + if (foo (2) != 2) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81030.c b/SingleSource/Regression/C/gcc-dg/pr81030.c new file mode 100644 index 0000000000..23da6e528a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81030.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +void __assert_fail (const char *, const char *, unsigned int, const char *); + +int a, b, c, d, e, f, h; +unsigned char g; + +int main () +{ + int i, *j = &b; + if (a) + { + if (h) + { + int **k = &j; + d = 0; + *k = &e; + } + else + for (b = 0; b > -28; b = g) + ; + c || !j ? : __assert_fail ("c || !j", "small.c", 20, "main"); + if (f) + for (i = 0; i < 1; i++) + ; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81165.c b/SingleSource/Regression/C/gcc-dg/pr81165.c new file mode 100644 index 0000000000..8508d893be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81165.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-not " \[/%\] " "optimized" } } */ + +/* Testcase submitted for PR81165, with its main function removed as + it's turned into a compile test. We want to make sure that all of + the divide/remainder computations are removed by tree optimizers. + + We can figure out that we don't need to compute at runtime even the + condition to enter the loop: the initial i==0 would have to be + greater than the sum of two small unsigned values: 1U>>t1 is in the + range 0..1, whereas the char value is bounded by the range 0..127, + being 128 % a positive number (zero would invoke undefined + behavior, so we can assume it doesn't happen). (We know it's + nonnegative because it's 10 times a number that has no more than + the bits for 16, 8 and 1 set.) + + We don't realize that the loop is useless right away: jump + threading helps remove some of the complexity, particularly of the + computation within the loop: t1 is compared with 1, but it can + never be 1. (We could assume as much, since its being 1 would + divide by zero, but we don't.) + + If we don't enter the conditional block, t1 remains at 2; if we do, + it's set to either -1. If we jump thread at the end of the + conditional block, we can figure out the ranges exclude 1 and the + jump body is completely optimized out. However, we used to fail to + consider the block for jump threading due to the amount of + computation in it, without realizing most of it would die in + consequence of the threading. + + We now take the dying code into account when deciding whether or + not to try jump threading. That might enable us to optimize the + function into { if (x2 != 0 || (x1 & 1) == 0) abort (); }. At the + time of this writing, with the patch, we get close, but the test on + x2 only gets as far as ((1 >> x2) == 0). Without the patch, some + of the loop remains. */ + +short x0 = 15; + +void func (){ + volatile int x1 = 1U; + volatile char x2 = 0; + char t0 = 0; + unsigned long t1 = 2LU; + int i = 0; + + if(1>>x2) { + t0 = -1; + t1 = (1&(short)(x1^8U))-1; + } + + while(i > (int)((1U>>t1)+(char)(128%(10*(25LU&(29%x0)))))) { + i += (int)(12L/(1!=(int)t1)); + } + + if (t0 != -1) __builtin_abort(); + if (t1 != 0L) __builtin_abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81192.c b/SingleSource/Regression/C/gcc-dg/pr81192.c new file mode 100644 index 0000000000..c46ac18fd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81192.c @@ -0,0 +1,91 @@ +/* { dg-options "-Os -fgimple -fdump-tree-pre-details -fdisable-tree-evrp -fno-tree-dse" } */ + +#if __SIZEOF_INT__ == 2 +#define unsigned __UINT32_TYPE__ +#define int __INT32_TYPE__ +#endif + +unsigned a; +int b, c; + +void __GIMPLE(ssa, startwith("pre")) fn2 () +{ + int b_lsm6; + int j; + int c0_1; + int iftmp2_8; + + __BB(2): + a = _Literal (unsigned)30; + c0_1 = c; + b_lsm6_9 = b; + goto __BB7; + + __BB(3): + if (j_6(D) != _Literal (int)2147483647) + goto __BB4; + else + goto __BB5; + + __BB(4): + iftmp2_8 = j_6(D) + _Literal (int)1; + goto __BB5; + + __BB(5): + b_lsm6_10 = _Literal (int)2147483647; + goto __BB6; + + __BB(6): + if (c0_1 != _Literal (int) 0) + goto __BB3; + else + goto __BB8; + + __BB(8): + goto __BB7; + + __BB(7): + goto __BB6; + +} + +#if 0 +/* This used to be a C based testcase but ccp3 would now would remove + the setting of iftmp2_8 (in the above gimple) which would cause PRE + not to test what PRE was doing incorrectly. The original code is below. */ +/* Disable tree-evrp because the new version of evrp sees + : + if (j_8(D) != 2147483647) + goto ; [50.00%] + else + goto ; [50.00%] + : + iftmp.2_11 = j_8(D) + 1; + : + # iftmp.2_12 = PHI + +EVRP now recognizes a constant can be propagated into the 3->5 edge and +produces + # iftmp.2_12 = PHI <2147483647(3), iftmp.2_11(4)> +which causes the situation being tested to dissapear before we get to PRE. */ + +/* Likewise disable DSE which also elides the tail merging "opportunity". */ + +static int +fn1 (int p1, int p2) +{ + return p1 > 2147483647 - p2 ? p1 : p1 + p2; +} + +void +fn2 (void) +{ + int j; + a = 30; + for (; a;) + for (; c; b = fn1 (j, 1)) + ; +} +#endif + +/* { dg-final { scan-tree-dump-times "(?n)find_duplicates: duplicate of " 1 "pre" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr81227.c b/SingleSource/Regression/C/gcc-dg/pr81227.c new file mode 100644 index 0000000000..bdaa8cbab2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81227.c @@ -0,0 +1,22 @@ +/* Copy of gcc.c-torture/compile/pr80443.c */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fwrapv" } */ + +struct S { int a : 1; } b, c; +signed char d, e, f; + +void +foo () +{ + while (f) + { + signed char g = b.a; + if (g) + b.a = ~(1 + (d || c.a)); + if (b.a < g && b.a) + g = 0; + if (b.a > c.a) + b.a = g; + c.a = e; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81228.c b/SingleSource/Regression/C/gcc-dg/pr81228.c new file mode 100644 index 0000000000..f7eecc510a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81228.c @@ -0,0 +1,21 @@ +/* PR target/81228. */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-ssa" } */ + +void *a; + +void b () +{ + char c; + long d; + char *e = a; + for (; d; d++) + { + double f, g; + c = g < f || g > f; + e[d] = c; + } +} + +/* Let's make sure we do have a LTGT. */ +/* { dg-final { scan-tree-dump "<>" "ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr81281-1.c b/SingleSource/Regression/C/gcc-dg/pr81281-1.c new file mode 100644 index 0000000000..5fec25d4cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81281-1.c @@ -0,0 +1,150 @@ +/* PR sanitizer/81281 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-not "p_\[0-9]*\\(D\\)" "optimized" } } */ + +long long +f1 (int p, int a, int b) +{ + int c = p + 1; + int d = a + 2; + int e = b + 3; + long long f = p + a; + long long g = p + b; + return f - g; +} + +long long +f2 (int p, int a, int b) +{ + int c = a + 1; + int d = p + 2; + int e = b + 3; + long long f = p + a; + long long g = p + b; + return f - g; +} + +long long +f3 (int p, int a, int b) +{ + int c = b + 1; + int d = p + 2; + int e = a + 3; + long long f = p + a; + long long g = p + b; + return f - g; +} + +signed char +f4 (int p, int a, int b) +{ + int c = p + 1; + int d = a + 2; + int e = b + 3; + signed char f = p + a; + signed char g = p + b; + return f - g; +} + +signed char +f5 (int p, int a, int b) +{ + int c = a + 1; + int d = p + 2; + int e = b + 3; + signed char f = p + a; + signed char g = p + b; + return f - g; +} + +signed char +f6 (int p, int a, int b) +{ + int c = b + 1; + int d = p + 2; + int e = a + 3; + signed char f = p + a; + signed char g = p + b; + return f - g; +} + +long long +f7 (int p, int a) +{ + int c = p + 1; + int d = a + 2; + long long f = p + a; + long long g = p; + return f - g; +} + +long long +f8 (int p, int a) +{ + int c = a + 1; + int d = p + 2; + long long f = p + a; + long long g = p; + return f - g; +} + +signed char +f9 (int p, int a) +{ + int c = p + 1; + int d = a + 2; + signed char f = p + a; + signed char g = p; + return f - g; +} + +signed char +f10 (int p, int a) +{ + int c = a + 1; + int d = p + 2; + signed char f = p + a; + signed char g = p; + return f - g; +} + +long long +f11 (int p, int a) +{ + int c = p + 1; + int d = a + 2; + long long f = p; + long long g = p + a; + return f - g; +} + +long long +f12 (int p, int a) +{ + int c = a + 1; + int d = p + 2; + long long f = p; + long long g = p + a; + return f - g; +} + +signed char +f13 (int p, int a) +{ + int c = p + 1; + int d = a + 2; + signed char f = p; + signed char g = p + a; + return f - g; +} + +signed char +f14 (int p, int a) +{ + int c = a + 1; + int d = p + 2; + signed char f = p; + signed char g = p + a; + return f - g; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81281-2.c b/SingleSource/Regression/C/gcc-dg/pr81281-2.c new file mode 100644 index 0000000000..ba2c648167 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81281-2.c @@ -0,0 +1,80 @@ +/* PR sanitizer/81281 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-not "p_\[0-9]*\\(D\\)" "optimized" } } */ + +typedef __SIZE_TYPE__ size_t; +typedef __INTPTR_TYPE__ T; + +T +f1 (char *p, size_t a, size_t b) +{ + char *c = p + 1; + size_t d = a + 2; + size_t e = b + 3; + T f = (T) (p + a); + T g = (T) (p + b); + return f - g; +} + +T +f2 (char *p, size_t a, size_t b) +{ + size_t c = a + 1; + char *d = p + 2; + size_t e = b + 3; + T f = (T) (p + a); + T g = (T) (p + b); + return f - g; +} + +T +f3 (char *p, size_t a, size_t b) +{ + size_t c = b + 1; + char *d = p + 2; + size_t e = a + 3; + T f = (T) (p + a); + T g = (T) (p + b); + return f - g; +} + +T +f4 (char *p, size_t a) +{ + char *c = p + 1; + size_t d = a + 2; + T f = (T) (p + a); + T g = (T) p; + return f - g; +} + +T +f5 (char *p, size_t a) +{ + size_t c = a + 1; + char *d = p + 2; + T f = (T) (p + a); + T g = (T) p; + return f - g; +} + +T +f6 (char *p, size_t a) +{ + char *c = p + 1; + size_t d = a + 2; + T f = (T) p; + T g = (T) (p + a); + return f - g; +} + +T +f7 (char *p, size_t a) +{ + size_t c = a + 1; + char *d = p + 2; + T f = (T) p; + T g = (T) (p + a); + return f - g; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81281-3.c b/SingleSource/Regression/C/gcc-dg/pr81281-3.c new file mode 100644 index 0000000000..e491835848 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81281-3.c @@ -0,0 +1,105 @@ +/* PR sanitizer/81281 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-not "\[+=-] \?123\[ ;]" "optimized" } } */ + +#ifdef __SIZEOF_INT128__ +__int128 +f1 (int a, long long b) +{ + __int128 f = 123 + a; + __int128 g = 123 + b; + return f - g; +} +#endif + +signed char +f2 (int a, long long b) +{ + signed char f = 123 + a; + signed char g = 123 + b; + return f - g; +} + +signed char +f3 (unsigned int a, unsigned long long b) +{ + signed char f = 123 + a; + signed char g = 123 + b; + return f - g; +} + +unsigned char +f4 (unsigned int a, unsigned long long b) +{ + unsigned char f = 123 + a; + unsigned char g = 123 + b; + return f - g; +} + +/* This isn't optimized yet. */ +#if 0 +long long +f5 (int a) +{ + long long f = 123 + a; + long long g = 123; + return f - g; +} +#endif + +signed char +f6 (long long a) +{ + signed char f = 123 + a; + signed char g = 123; + return f - g; +} + +signed char +f7 (unsigned int a) +{ + signed char f = 123 + a; + signed char g = 123; + return f - g; +} + +unsigned char +f8 (unsigned long int a) +{ + unsigned char f = 123 + a; + unsigned char g = 123; + return f - g; +} + +long long +f9 (int a) +{ + long long f = 123; + long long g = 123 + a; + return f - g; +} + +signed char +f10 (long long a) +{ + signed char f = 123; + signed char g = 123 + a; + return f - g; +} + +signed char +f11 (unsigned int a) +{ + signed char f = 123; + signed char g = 123 + a; + return f - g; +} + +unsigned char +f12 (unsigned long int a) +{ + unsigned char f = 123; + unsigned char g = 123 + a; + return f - g; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81292-1.c b/SingleSource/Regression/C/gcc-dg/pr81292-1.c new file mode 100644 index 0000000000..2a454df88a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81292-1.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +char a[10]; + +int __attribute__ ((noinline, noclone)) +f1 (int n) +{ + a[0] = '1'; + a[1] = '2'; + return strlen (a + 1) < n ? strlen (a) : 100; +} + +int __attribute__ ((noinline, noclone)) +f2 (char *a, int n) +{ + a[0] = '1'; + a[1] = '2'; + return strlen (a + 1) < n ? strlen (a) : 100; +} + +int +main (void) +{ + char b[10]; + strcpy (a + 2, "345"); + strcpy (b + 2, "34567"); + if (f1 (100) != 5 || f2 (b, 100) != 7) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr81292-2.c b/SingleSource/Regression/C/gcc-dg/pr81292-2.c new file mode 100644 index 0000000000..252884abca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81292-2.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +char a[] = { 0, 'a', 0, 'b', 'c', 0, 'd', 'e', 'f', 0 }; + +int __attribute__ ((noinline, noclone)) +f1 (void) +{ + a[0] = '1'; + a[strlen (a)] = '2'; + a[strlen (a)] = '3'; + return strlen (a); +} + +int __attribute__ ((noinline, noclone)) +f2 (char *a) +{ + a[0] = '1'; + a[strlen (a)] = '2'; + a[strlen (a)] = '3'; + return strlen (a); +} + +int +main (void) +{ + char b[] = { 0, 0, 'a', 'b', 0, 0 }; + if (f1 () != 9 || f2 (b) != 5) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 6 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr81345.c b/SingleSource/Regression/C/gcc-dg/pr81345.c new file mode 100644 index 0000000000..14661f5dac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81345.c @@ -0,0 +1,17 @@ +/* PR other/81345 - -Wall resets -Wstringop-overflow to 1 from the default 2 + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds" } */ + +char a[3]; + +void f (const char *s) +{ + __builtin_strncpy (a, s, sizeof a + 1); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +struct S { char a[3]; int i; }; + +void g (struct S *d, const char *s) +{ + __builtin_strncpy (d->a, s, sizeof d->a + 1); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81455.c b/SingleSource/Regression/C/gcc-dg/pr81455.c new file mode 100644 index 0000000000..8ab88639ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81455.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -funswitch-loops" } */ + +void +jh (unsigned int aw, int sn) +{ + int xs; + + for (xs = 0; xs < 1; ++xs) + aw &= 1; + + while (aw < 1 || ++sn < 1) + { + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81564.c b/SingleSource/Regression/C/gcc-dg/pr81564.c new file mode 100644 index 0000000000..13519991f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81564.c @@ -0,0 +1,21 @@ +/* PR middle-end/81564 ICE in group_case_labels_stmt(). */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct a { + int b; + int c; +}; + +void +foo (void) +{ + struct a *e; + switch (e->c) + { + case 7: + case 3: + if (__builtin_expect(!0, 0)) + __builtin_unreachable(); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81578.c b/SingleSource/Regression/C/gcc-dg/pr81578.c new file mode 100644 index 0000000000..a6ef77f20c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81578.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/81578 */ +/* { dg-do compile { target pthread } } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2" } */ + +int +foo (int *x) +{ + int i, r = 1; + for (i = 0; i != 1024; i++) + r *= x[i] < 0; + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81588.c b/SingleSource/Regression/C/gcc-dg/pr81588.c new file mode 100644 index 0000000000..4e83607f2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81588.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/81588 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +long long int a = 5011877430933453486LL, c = 1; +unsigned short b = 24847; + +#include "tree-ssa/pr81588.c" + +int +main () +{ + foo (); + if (c != 0) + __builtin_abort (); + a = 24846; + c = 1; + foo (); + if (c != 1) + __builtin_abort (); + a = -5; + foo (); + if (c != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81592.c b/SingleSource/Regression/C/gcc-dg/pr81592.c new file mode 100644 index 0000000000..a37703af49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81592.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -fno-strict-overflow -Wstrict-overflow=2 -fsanitize=signed-integer-overflow" } */ + +#include + +int proc_keys_show(long expiry, long now) +{ + unsigned long timo; + char xbuf[4]; + + if (now < expiry) { + timo = expiry - now; + if (timo < 60) + sprintf(xbuf, "%lus", timo); + } + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr81621.c b/SingleSource/Regression/C/gcc-dg/pr81621.c new file mode 100644 index 0000000000..fb41eab896 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81621.c @@ -0,0 +1,5 @@ +/* PR target/81621 */ +/* { dg-do compile { target freorder } } */ +/* { dg-options "-Og -fno-split-wide-types -freorder-blocks-and-partition" } */ + +#include "graphite/scop-10.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr81650.c b/SingleSource/Regression/C/gcc-dg/pr81650.c new file mode 100644 index 0000000000..99e84ded30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81650.c @@ -0,0 +1,9 @@ +/* PR driver/81650 */ +/* { dg-do compile } */ +/* { dg-options "-Walloc-size-larger-than=9223372036854775807" } */ + +void * +foo (void) +{ + return __builtin_malloc (5); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81661.c b/SingleSource/Regression/C/gcc-dg/pr81661.c new file mode 100644 index 0000000000..d8d27304dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81661.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/81661 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -ftrapv" } */ + +int a, b, c; + +void +foo (void) +{ + while (a + c > b) + a--; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81695.c b/SingleSource/Regression/C/gcc-dg/pr81695.c new file mode 100644 index 0000000000..c3452580f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81695.c @@ -0,0 +1,11 @@ +/* PR middle-end/81695 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int z[] = { }; + +int +main (void) +{ + __builtin_printf ("%d\n", *(z + 1)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81703.c b/SingleSource/Regression/C/gcc-dg/pr81703.c new file mode 100644 index 0000000000..02edf26743 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81703.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +unsigned g (void) +{ + char d[8]; + const char s[] = "0123"; + __builtin_memcpy (d, s, sizeof s); + return __builtin_strlen (d); +} + +/* { dg-final { scan-tree-dump-not "__builtin_strlen" "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr81737.c b/SingleSource/Regression/C/gcc-dg/pr81737.c new file mode 100644 index 0000000000..493358956e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81737.c @@ -0,0 +1,6 @@ +/* PR middle-end/81737 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern int a[]; +void fn1() { (a + 0)[1]; } diff --git a/SingleSource/Regression/C/gcc-dg/pr81779.c b/SingleSource/Regression/C/gcc-dg/pr81779.c new file mode 100644 index 0000000000..6e796384a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81779.c @@ -0,0 +1,15 @@ +/* PR c/81779 */ +/* { dg-do compile } */ +/* { dg-options "-Wdeclaration-after-statement" } */ + +#include + +bool +f2 (char *p) +{ + if (!p) + return false; + + bool ret = true; /* { dg-warning "ISO C90 forbids mixed declarations and code" } */ + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81795.c b/SingleSource/Regression/C/gcc-dg/pr81795.c new file mode 100644 index 0000000000..b035bd0b53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81795.c @@ -0,0 +1,14 @@ +/* PR c/81795 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++-compat" + +struct S { int f; }; /* { dg-bogus "note: originally defined here" } */ +typedef int S; /* { dg-bogus "invalid in C\[+\]\[+\]" } */ + +typedef int T; /* { dg-bogus "note: originally defined here" } */ +struct T { int f; }; /* { dg-bogus "invalid in C\[+\]\[+\]" } */ + +#pragma GCC diagnostic pop diff --git a/SingleSource/Regression/C/gcc-dg/pr81854.c b/SingleSource/Regression/C/gcc-dg/pr81854.c new file mode 100644 index 0000000000..1021a811be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81854.c @@ -0,0 +1,63 @@ +/* PR c/81854 - weak alias of an incompatible symbol accepted + { dg-do compile } + { dg-require-ifunc "" } + { dg-options "-Wextra" } */ + +const char* __attribute__ ((weak, alias ("f0_target"))) +f0 (void); /* { dg-error "alias between function and variable" } */ + +int f0_target; /* { dg-message "aliased declaration here" } */ + + +const char* __attribute__ ((weak, alias ("f1_target"))) +f1 (void); /* { dg-warning "alias between functions of incompatible types" } */ + +void f1_target (int *p) /* { dg-message "aliased declaration here" } */ +{ + *p = 0; +} + + +const char* __attribute__ ((alias ("f2_target"))) +f2 (void*); /* { dg-warning "alias between functions of incompatible types" } */ + +const char* f2_target (int i) /* { dg-message "aliased declaration here" } */ +{ + (void)&i; + return 0; +} + +int __attribute__ ((ifunc ("f3_resolver"))) +f3 (void); /* { dg-message "resolver indirect function declared here" } */ + +void* f3_resolver (void) /* { dg-warning "ifunc. resolver for .f3. should return .int \\(\\*\\)\\(void\\)." } */ +{ + return 0; +} + + +int __attribute__ ((ifunc ("f4_resolver"))) +f4 (void); /* { dg-message "resolver indirect function declared here" } */ + +typedef void F4 (void); +F4* f4_resolver (void) /* { dg-warning ".ifunc. resolver for .f4. should return .int \\(\\*\\)\\(void\\)" } */ +{ + return 0; +} + +const char* __attribute__ ((ifunc ("f5_resolver"))) +f5 (void); + +typedef const char* F5 (void); +F5* f5_resolver (void) +{ + return 0; +} + +int __attribute__ ((ifunc ("f6_resolver"))) +f6 (void); /* { dg-message "resolver indirect function declared here" } */ + +int f6_resolver (void) /* { dg-error ".ifunc. resolver for 'f6' must return .int \\(\\*\\)\\(void\\)." } */ +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81979.c b/SingleSource/Regression/C/gcc-dg/pr81979.c new file mode 100644 index 0000000000..4ac9addbc0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81979.c @@ -0,0 +1,32 @@ +/* PR target/81979 */ +/* { dg-do link } */ +/* { dg-options "-O2 -w" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ +/* { dg-additional-options "-freorder-blocks-and-partition" { target freorder } } */ + +int d; + +__attribute__((noinline, noclone)) void +foo (int x) +{ + int c; + while (c < 1) + { + int o; + for (o = 0; o < 4; ++o) + c /= (x != 0) ? 2 : x; + } + + d = 1; + for (;;) + ; +} + +int +main () +{ + asm volatile ("" : : "r" (&d) : "memory"); + foo (d); + asm volatile ("" : : "r" (&d) : "memory"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr81988.c b/SingleSource/Regression/C/gcc-dg/pr81988.c new file mode 100644 index 0000000000..dbbf436f27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr81988.c @@ -0,0 +1,22 @@ +/* PR target/81988 */ +/* Testcase by James Cowgill */ + +/* { dg-do assemble } */ +/* { dg-require-effective-target pie } */ +/* { dg-options "-O3 -fpie" } */ + +int c, d; + +short **e; +int *a; + +void foo(void) +{ + int g[64 * 35], *h = g; + do { + short *f = e[d]; + for (int i = 0; i < 4; i++) + a[i] = a[i] + (h[364] + f[4] * h[64] + f[5] * h[i] + f[6] * h[i + 3 * 4] + + f[7] * h[i + 4]); + } while (c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82004.c b/SingleSource/Regression/C/gcc-dg/pr82004.c new file mode 100644 index 0000000000..2dd3eae90a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82004.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/82004 */ +/* { dg-do run } */ +/* { dg-options "-Ofast" } */ + +extern double log10 (double); +extern double pow (double, double); + +__attribute__((noipa)) void +bar (double x) +{ + if (x < 0.001) + __builtin_abort (); + asm volatile ("" : : : "memory"); +} + +int +main () +{ + double d = 0.001; + double e = 10.0; + double f = (log10 (e) - log10 (d)) / 400.0; + double g = log10 (d) - f; + volatile int q = 0; + int i; + if (__builtin_expect (q == 0, 0)) + for (i = 0; i < 400; ++i) + { + g = g + f; + bar (pow (10.0, g)); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82112.c b/SingleSource/Regression/C/gcc-dg/pr82112.c new file mode 100644 index 0000000000..4ca69195ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82112.c @@ -0,0 +1,21 @@ +/* PR target/82112 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90" } */ + +struct S { int a[10]; } bar (void); +int b, c; + +void +foo (void) +{ + __atomic_load (bar ().a, &b, __ATOMIC_ACQUIRE); /* { dg-error "argument 1 of .__atomic_load. must be a non-void pointer type" } */ + __atomic_load (&b, bar ().a, __ATOMIC_ACQUIRE); /* { dg-error "argument 2 of .__atomic_load. must be a pointer type" } */ + __atomic_store (bar ().a, &b, __ATOMIC_SEQ_CST); /* { dg-error "argument 1 of .__atomic_store. must be a non-void pointer type" } */ + __atomic_store (&b, bar ().a, __ATOMIC_SEQ_CST); /* { dg-error "argument 2 of .__atomic_store. must be a pointer type" } */ + __atomic_exchange (bar ().a, &b, &c, __ATOMIC_RELAXED); /* { dg-error "argument 1 of .__atomic_exchange. must be a non-void pointer type" } */ + __atomic_exchange (&b, bar ().a, &c, __ATOMIC_RELAXED); /* { dg-error "argument 2 of .__atomic_exchange. must be a pointer type" } */ + __atomic_exchange (&b, &c, bar ().a, __ATOMIC_RELAXED); /* { dg-error "argument 3 of .__atomic_exchange. must be a pointer type" } */ + __atomic_compare_exchange (bar ().a, &b, &c, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 1 of .__atomic_compare_exchange. must be a non-void pointer type" } */ + __atomic_compare_exchange (&b, bar ().a, &c, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 2 of .__atomic_compare_exchange. must be a pointer type" } */ + __atomic_compare_exchange (&b, &c, bar ().a, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 3 of .__atomic_compare_exchange. must be a pointer type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82123.c b/SingleSource/Regression/C/gcc-dg/pr82123.c new file mode 100644 index 0000000000..34109f1aec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82123.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wformat-overflow=1" } */ + +void acpi_gpiochip_request_interrupt(unsigned short s) +{ + char name[3]; + unsigned int pin = s; + + if (pin <= 255) + __builtin_sprintf(name, "%02X", pin); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr82167.c b/SingleSource/Regression/C/gcc-dg/pr82167.c new file mode 100644 index 0000000000..af3b3a5a1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82167.c @@ -0,0 +1,14 @@ +/* PR c/82167 */ +/* { dg-do compile } */ + +void +fn1 (int a[]) +{ + __builtin_printf ("%zu\n", sizeof (*&a)); /* { dg-warning ".sizeof. on array function parameter .a. will return size of .int \\*." } */ +} + +void +fn2 (int *a[]) +{ + __builtin_printf ("%zu\n", sizeof (*&a)); /* { dg-warning ".sizeof. on array function parameter .a. will return size of .int \\*\\*." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82190.c b/SingleSource/Regression/C/gcc-dg/pr82190.c new file mode 100644 index 0000000000..aa8cc85d8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82190.c @@ -0,0 +1,22 @@ +/* PR target/82190 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-optimize-strlen -fweb" } */ + +char src[64] __attribute__ ((aligned)) = "aaaaaaa"; +char dst[64] __attribute__ ((aligned)); + +int +main () +{ + __builtin_memcpy (dst, src, 6); + if (__builtin_memcmp (dst, src, 6)) + __builtin_abort (); + + __builtin_memcpy (dst, src, 7); + if (__builtin_memcmp (dst, src, 7)) + __builtin_abort (); + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr82274-1.c b/SingleSource/Regression/C/gcc-dg/pr82274-1.c new file mode 100644 index 0000000000..f96b7338fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82274-1.c @@ -0,0 +1,16 @@ +/* PR target/82274 */ +/* { dg-do run } */ +/* { dg-shouldfail "trapv" } */ +/* { dg-options "-ftrapv" } */ + +int +main () +{ +#ifdef __SIZEOF_INT128__ + volatile __int128 m = -(((__int128) 1) << (__CHAR_BIT__ * __SIZEOF_INT128__ / 2)); +#else + volatile long long m = -(1LL << (__CHAR_BIT__ * __SIZEOF_LONG_LONG__ / 2)); +#endif + m = m * m; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82274-2.c b/SingleSource/Regression/C/gcc-dg/pr82274-2.c new file mode 100644 index 0000000000..a9643b5a92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82274-2.c @@ -0,0 +1,26 @@ +/* PR target/82274 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int +main () +{ +#ifdef __SIZEOF_INT128__ + __int128 m = -(((__int128) 1) << (__CHAR_BIT__ * __SIZEOF_INT128__ / 2)); + volatile __int128 mv = m; + __int128 r; +#else + long long m = -(1LL << (__CHAR_BIT__ * __SIZEOF_LONG_LONG__ / 2)); + volatile long long mv = m; + long long r; +#endif + if (!__builtin_mul_overflow (mv, mv, &r)) + __builtin_abort (); + if (!__builtin_mul_overflow_p (mv, mv, r)) + __builtin_abort (); + if (!__builtin_mul_overflow (m, m, &r)) + __builtin_abort (); + if (!__builtin_mul_overflow_p (m, m, r)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82286.c b/SingleSource/Regression/C/gcc-dg/pr82286.c new file mode 100644 index 0000000000..13e22501d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82286.c @@ -0,0 +1,60 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Warray-bounds" } */ + +#include +#include + +#define MAX_MATRIX_SIZE (10) + +typedef struct +{ + unsigned int nof_rows; + unsigned int nof_cols; + float data[MAX_MATRIX_SIZE][MAX_MATRIX_SIZE]; +} MATRIX_TYPE; + +extern void mtrx_decompose_matrix (MATRIX_TYPE * p_input_matrix); + +void +mtrx_decompose_matrix (MATRIX_TYPE * p_input_matrix) +{ + unsigned int row; + unsigned int col; + unsigned int sub; + float sum; + MATRIX_TYPE tmp; + + for (row = 0; row < MAX_MATRIX_SIZE; row++) { + for (col = 0; col < MAX_MATRIX_SIZE; col++) { + tmp.data[row][col] = 0.0; + } + } + tmp.nof_cols = 0; + tmp.nof_rows = 0; + + for (row = 0; row < p_input_matrix->nof_rows; row++) { + for (col = row; col < p_input_matrix->nof_cols; col++) { + sum = 0.0f; + for (sub = 0; sub < row; sub++) { + sum += tmp.data[row][sub] * tmp.data[col][sub]; + } + sum = p_input_matrix->data[col][row] - sum; + if (row == col) { + if (sum >= 0.0) { +#if ERROR + tmp.data[row][col] = sqrtf (sum); +#else + tmp.data[row][col] = sum; +#endif + } + else { + tmp.data[row][col] = 0.0f; + } + } + else { + tmp.data[col][row] = sum / tmp.data[row][row]; + } + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr82386.c b/SingleSource/Regression/C/gcc-dg/pr82386.c new file mode 100644 index 0000000000..8901f2b4cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82386.c @@ -0,0 +1,38 @@ +/* PR target/82386 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ +/* { dg-additional-options "-misel" { target powerpc*-*-* } } */ + +long long int fs; +int vm; + +void +sd (void) +{ + fs = 1; + vm = 2; + goto zf; + + if (0) + { + int y6 = 0; + int *uu = &y6; + short int he; + int of = 0; + + zf: + for (;;) + { + he = of; + if (he || (fs |= vm)) + { + *uu = fs; + fs += vm; + } + if (y6 == vm) + fs |= he; + he = y6 || fs; + fs /= 0; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82389.c b/SingleSource/Regression/C/gcc-dg/pr82389.c new file mode 100644 index 0000000000..eae5957cd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82389.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/82389 */ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-w -O3" } */ + +struct S { char s[0x40000000]; } s; + +void +foo (struct S *p) +{ + char b[0x0ffffffff0000000L]; + *(struct S *)&b[0x0fffffffef000000L] = s; + *p = *(struct S *)&b[0x0fffffffefffffffL]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82404.c b/SingleSource/Regression/C/gcc-dg/pr82404.c new file mode 100644 index 0000000000..53565d310f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82404.c @@ -0,0 +1,17 @@ +// PR middle-end/82404 + +// { dg-do compile } +// { dg-options "-O3 -Wall -fdump-tree-optimized -Wno-return-type" } + +enum eShape { eSquare, eCircle, eShpere, eTetraeder }; + +double test_switch_native(enum eShape shape, double r) { + switch(shape) { + case eSquare: return 2; + case eCircle: return 3; + case eShpere: return 4; + case eTetraeder: return 5; + } +} + +// { dg-final { scan-tree-dump-times "if " 1 optimized } } diff --git a/SingleSource/Regression/C/gcc-dg/pr82596.c b/SingleSource/Regression/C/gcc-dg/pr82596.c new file mode 100644 index 0000000000..5dc67c28e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82596.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/82596 - missing -Warray-bounds on an out-of-bounds + index into string literal + { dg-do compile } + { dg-options "-O2 -Warray-bounds" } */ + +#define SIZE_MAX __SIZE_MAX__ +#define SSIZE_MAX __PTRDIFF_MAX__ +#define SSIZE_MIN (-SSIZE_MAX - 1) + +void sink (int, ...); + +#define T(arg) sink (arg) + +void test_cststring (int i) +{ + T (""[SSIZE_MIN]); /* { dg-warning "below array bounds" "string" { xfail lp64 } } */ + T (""[SSIZE_MIN + 1]); /* { dg-warning "below array bounds" "string" } */ + T (""[-1]); /* { dg-warning "below array bounds" "string" } */ + T (""[0]); + T (""[1]); /* { dg-warning "above array bounds" "string" } */ + T ("0"[2]); /* { dg-warning "above array bounds" "string" } */ + T ("012"[2]); + T ("012"[3]); + T ("012"[4]); /* { dg-warning "above array bounds" "string" } */ + T ("0123"[SSIZE_MAX]); /* { dg-warning "above array bounds" "string" } */ + T ("0123"[SIZE_MAX]); /* { dg-warning "above array bounds" "string" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82597.c b/SingleSource/Regression/C/gcc-dg/pr82597.c new file mode 100644 index 0000000000..98ae264d1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82597.c @@ -0,0 +1,40 @@ +/* PR rtl-optimization/82597 */ +/* { dg-do compile }*/ +/* { dg-options "-O2 -funroll-loops" } */ + +int pb; + +void +ch (unsigned char np, char fc) +{ + unsigned char *y6 = &np; + + if (fc != 0) + { + unsigned char *z1 = &np; + + for (;;) + if (*y6 != 0) + for (fc = 0; fc < 12; ++fc) + { + int hh; + int tp; + + if (fc != 0) + hh = (*z1 != 0) ? fc : 0; + else + hh = pb; + + tp = fc > 0; + if (hh == tp) + *y6 = 1; + } + } + + if (np != 0) + y6 = (unsigned char *)&fc; + if (pb != 0 && *y6 != 0) + for (;;) + { + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82703.c b/SingleSource/Regression/C/gcc-dg/pr82703.c new file mode 100644 index 0000000000..0bd2f91eea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82703.c @@ -0,0 +1,28 @@ +/* PR target/82703 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-sra -ftree-vectorize" } */ + +__attribute__((noinline, noclone)) void +compare (const double *p, const double *q) +{ + for (int i = 0; i < 3; ++i) + if (p[i] != q[i]) + __builtin_abort (); +} + +double vr[3] = { 4, 4, 4 }; + +int +main () +{ + double v1[3] = { 1, 2, 3 }; + double v2[3] = { 3, 2, 1 }; + double v3[3]; + __builtin_memcpy (v3, v1, sizeof (v1)); + for (int i = 0; i < 3; ++i) + v3[i] += v2[i]; + for (int i = 0; i < 3; ++i) + v1[i] += v2[i]; + compare (v3, vr); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82765.c b/SingleSource/Regression/C/gcc-dg/pr82765.c new file mode 100644 index 0000000000..dde0aeba7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82765.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -w" } */ + +int a[1][1]; +int main() { int *b[] = {a, a[1820408606019012862278468], a, a, a}; } diff --git a/SingleSource/Regression/C/gcc-dg/pr82788.c b/SingleSource/Regression/C/gcc-dg/pr82788.c new file mode 100644 index 0000000000..41c442f61a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82788.c @@ -0,0 +1,5 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fstack-clash-protection --param stack-clash-protection-probe-interval=10 --param stack-clash-protection-guard-size=12" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ +/* { dg-skip-if "AArch64 does not support this interval." { aarch64*-*-* } } */ +int main() { int a[1442]; return 0;} diff --git a/SingleSource/Regression/C/gcc-dg/pr82809.c b/SingleSource/Regression/C/gcc-dg/pr82809.c new file mode 100644 index 0000000000..9f74ee8653 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82809.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fno-tree-dominator-opts" } */ + +struct locale_time_t +{ + const char *abday[7]; + const unsigned int *wabday[7]; +}; + +static const unsigned int empty_wstr[1] = { 0 }; + +void +time_read (struct locale_time_t *time) +{ + int cnt; + + for (cnt=0; cnt < 7; cnt++) + { + time->abday[cnt] = ""; + time->wabday[cnt] = empty_wstr; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82863.c b/SingleSource/Regression/C/gcc-dg/pr82863.c new file mode 100644 index 0000000000..b4028169a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82863.c @@ -0,0 +1,12 @@ +/* PR c/82167 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef long long a; +a b; +float +c () +{ + float d = b > 0; + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82875.c b/SingleSource/Regression/C/gcc-dg/pr82875.c new file mode 100644 index 0000000000..52f1de7736 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82875.c @@ -0,0 +1,12 @@ +/* PR middle-end/82875 */ +/* { dg-do compile } */ +/* { dg-options "-ftree-ter" } */ +/* { dg-require-effective-target alloca } */ + +const int a = 100; + +void +foo (void) +{ + int c[a]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82916.c b/SingleSource/Regression/C/gcc-dg/pr82916.c new file mode 100644 index 0000000000..50e467f324 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82916.c @@ -0,0 +1,47 @@ +/* PR bootstrap/82916 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-dse" } */ + +struct A { struct A *next; }; +struct C +{ + int *of; + struct C *parent, *prev, *next; + int depth; + int min; + struct C *min_occ; +}; + +__attribute__((noipa)) struct C * +foo (int *node) +{ + struct A *p = __builtin_malloc (sizeof (struct C)); + if (!p) + return 0; + p->next = 0; + /* Originally placement new. */ + struct C *nw = (struct C *)(void *)p; + nw->of = node; + nw->parent = 0; + nw->prev = 0; + nw->next = 0; + nw->depth = 0; + nw->min_occ = nw; + nw->min = 0; + return nw; +} + +int +main () +{ + int o; + struct C *p = foo (&o); + if (p) + { + if (p->of != &o || p->parent || p->prev || p->next || p->depth + || p->min || p->min_occ != p) + __builtin_abort (); + } + __builtin_free (p); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr82929-2.c b/SingleSource/Regression/C/gcc-dg/pr82929-2.c new file mode 100644 index 0000000000..b886f1cce7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82929-2.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/82929 */ +/* { dg-do compile { target store_merge } } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +void +foo (short *p, short *q, short *r) +{ + p = __builtin_assume_aligned (p, __alignof__ (int)); + q = __builtin_assume_aligned (q, __alignof__ (int)); + r = __builtin_assume_aligned (r, __alignof__ (int)); + short a = q[0]; + short b = q[1]; + short c = ~a; + short d = r[0]; + short e = r[1]; + short f = ~b; + p[0] = c & d; + p[1] = e & f; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 1 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr82929.c b/SingleSource/Regression/C/gcc-dg/pr82929.c new file mode 100644 index 0000000000..123e1919ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82929.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/82929 */ +/* { dg-do compile { target store_merge } } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +void +foo (short *p, short *q, short *r) +{ + short a = q[0]; + short b = q[1]; + short c = ~a; + short d = r[0]; + short e = r[1]; + short f = ~b; + p[0] = c & d; + p[1] = e & f; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 1 "store-merging" { target { ! arm*-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr82975.c b/SingleSource/Regression/C/gcc-dg/pr82975.c new file mode 100644 index 0000000000..422ba6c685 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr82975.c @@ -0,0 +1,20 @@ +/* PR target/82975. */ +/* { dg-do compile } */ +/* { dg-options "-fno-sched-pressure -O2" } */ +/* { dg-additional-options "-mtune=cortex-a57" { target arm*-*-* aarch64*-*-* } } */ + +typedef __SIZE_TYPE__ size_t; + +struct S1 +{ + char pad1; + char val; + short pad2; +}; + +extern char t[256]; + +void foo (struct S1 a, size_t i) +{ + t[i] = a.val; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83034.c b/SingleSource/Regression/C/gcc-dg/pr83034.c new file mode 100644 index 0000000000..875a3fe52c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83034.c @@ -0,0 +1,12 @@ +/* PR debug/83034 */ +/* { dg-do compile } */ +/* { dg-options "-funroll-loops -Ofast -g" } */ + +__attribute__((__simd__)) float expf (float); + +void +foo (float *a, int x) +{ + for (; x; x++) + a[x] = expf (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83044.c b/SingleSource/Regression/C/gcc-dg/pr83044.c new file mode 100644 index 0000000000..6681071bb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83044.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/83044 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -std=gnu89 -O2" } */ + +struct A { int b[0]; }; +struct B { struct A c[0]; }; +void bar (int *); + +void +foo (void) +{ + struct B d; + bar (d.c->b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83047.c b/SingleSource/Regression/C/gcc-dg/pr83047.c new file mode 100644 index 0000000000..db374a9d25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83047.c @@ -0,0 +1,58 @@ +/* PR tree-optimization/83047 */ +/* { dg-do run { target mmap } } */ +/* { dg-options "-O2" } */ + +#include +#include +#include +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_ANON +#define MAP_ANON 0 +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif +#include + +__attribute__((noipa)) void +foo (char *p, char *q, int r) +{ + char a = q[0]; + if (r || a == '\0') + return; + char b = q[1]; + p[0] = a; + p[1] = b; +} + +int +main () +{ + char *p = mmap (NULL, 131072, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) + return 0; + if (munmap (p + 65536, 65536) < 0) + return 0; + p[0] = 'c'; + p[1] = 'd'; + p[65536 - 2] = 'a'; + p[65536 - 1] = 'b'; + volatile int r = 1; + foo (p, p + 65536 - 2, r); + if (p[0] != 'c' || p[1] != 'd') + abort (); + r = 0; + foo (p, p + 65536 - 2, r); + if (p[0] != 'a' || p[1] != 'b') + abort (); + p[0] = 'e'; + p[1] = 'f'; + r = 1; + foo (p, p + 65536 - 1, r); + if (p[0] != 'e' || p[1] != 'f') + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83072-2.c b/SingleSource/Regression/C/gcc-dg/pr83072-2.c new file mode 100644 index 0000000000..f495f2582c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83072-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile} */ +/* { dg-options "-O2 -fdump-tree-evrp-details" } */ + +int f1(int a, int b, int c){ + if(c==0)__builtin_unreachable(); + a *= c; + b *= c; + return a == b; +} + +int f2(int a, int b, int c){ + c |= 1; + a *= c; + b *= c; + return a == b; +} + +/* { dg-final { scan-tree-dump-times "gimple_simplified to" 2 "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr83072.c b/SingleSource/Regression/C/gcc-dg/pr83072.c new file mode 100644 index 0000000000..3bed8d8901 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83072.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre" } */ + +void kill (void); + +int f(int c){ + c |= 1; + if (c == 0) + kill (); + + return c; +} + +/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr83073.c b/SingleSource/Regression/C/gcc-dg/pr83073.c new file mode 100644 index 0000000000..228e189008 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83073.c @@ -0,0 +1,10 @@ +/* { dg-do compile} */ +/* { dg-options "-O2 -fdump-tree-evrp-details -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop" } */ + +int f(int x) +{ + x = x|1; + return x & 1; +} + +/* { dg-final { scan-tree-dump "Folded into: return 1;" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr83089.c b/SingleSource/Regression/C/gcc-dg/pr83089.c new file mode 100644 index 0000000000..5185a70df5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83089.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O2 -ftree-loop-if-convert -ftree-parallelize-loops=2" } */ + +int rl, s8; + +void +it (int zy, short int el) +{ + int hb; + + while (el != 0) + { + hb = el; + for (rl = 0; rl < 200; ++rl) + { + for (s8 = 0; s8 < 2; ++s8) + { + } + if (s8 < 3) + zy = hb; + if (hb == 0) + ++s8; + zy += (s8 != -1); + } + el = zy; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83100-1.c b/SingleSource/Regression/C/gcc-dg/pr83100-1.c new file mode 100644 index 0000000000..ccfb8c6948 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83100-1.c @@ -0,0 +1,7 @@ +/* PR target/83100 */ +/* { dg-do compile { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fcommon -fdata-sections" } */ + +const int a; + +/* { dg-final { scan-assembler "comm" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr83100-2.c b/SingleSource/Regression/C/gcc-dg/pr83100-2.c new file mode 100644 index 0000000000..6dbe93dcd1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83100-2.c @@ -0,0 +1,15 @@ +/* PR target/83100 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fcommon -fdata-sections" } */ +/* { dg-additional-sources pr83100-3.c } */ +/* { dg-skip-if "-fdata-sections not supported" { hppa*-*-hpux* nvptx-*-* } } */ + +const int a; + +int +main () +{ + if (a != 7) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83100-3.c b/SingleSource/Regression/C/gcc-dg/pr83100-3.c new file mode 100644 index 0000000000..a28e852695 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83100-3.c @@ -0,0 +1,6 @@ +/* PR target/83100 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcommon -fdata-sections" } */ +/* { dg-skip-if "-fdata-sections not supported" { hppa*-*-hpux* nvptx-*-* } } */ + +const int a = 7; diff --git a/SingleSource/Regression/C/gcc-dg/pr83100-4.c b/SingleSource/Regression/C/gcc-dg/pr83100-4.c new file mode 100644 index 0000000000..2f83247263 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83100-4.c @@ -0,0 +1,7 @@ +/* PR target/83100 */ +/* { dg-do compile { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fno-common -fdata-sections" } */ + +const int a; + +/* { dg-final { scan-assembler "rodata.a" { target i?86-*-* x86_64-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr83198.c b/SingleSource/Regression/C/gcc-dg/pr83198.c new file mode 100644 index 0000000000..856f2be07d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83198.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/83198 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wno-format" } */ + +int +foo (char *d[6], int x) +{ + int r = 0; + r += __builtin_sprintf (d[0], "%f", x); + r += __builtin_sprintf (d[1], "%a", x); + r += __builtin_sprintf (d[2], "%f", "foo"); + r += __builtin_sprintf (d[3], "%a", "bar"); +#ifdef __SIZEOF_FLOAT128__ + r += __builtin_sprintf (d[4], "%a", 1.0Q); + r += __builtin_sprintf (d[5], "%Lf", 1.0Q); +#endif + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83312.c b/SingleSource/Regression/C/gcc-dg/pr83312.c new file mode 100644 index 0000000000..2eb241dfdf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83312.c @@ -0,0 +1,30 @@ +/* { dg-options "-O2 -Warray-bounds" } */ + +struct ptlrpcd_ctl { + char pc_name[20]; +}; +struct ptlrpcd { + struct ptlrpcd_ctl pd_threads[6]; +}; +struct ptlrpcd *ptlrpcd_init_pd; +static void ptlrpcd_ctl_init(struct ptlrpcd_ctl *pc, int index) { + if (index < 0) + __builtin_snprintf(pc->pc_name, sizeof(pc->pc_name), "ptlrpcd_rcv"); + else + __builtin_snprintf(pc->pc_name, sizeof(pc->pc_name), "ptlrpcd_%d", index); +} +int ptlrpcd_init_ncpts; +static int ptlrpcd_init(int nthreads) { + int j; + if (ptlrpcd_init_ncpts) { + ptlrpcd_ctl_init(&ptlrpcd_init_pd->pd_threads[0], -1); + for (j = 1; j < nthreads; j++) + ptlrpcd_ctl_init(&ptlrpcd_init_pd->pd_threads[j], j); + } + return 0; +} +int ptlrpcd_init_groupsize; +void ptlrpcd_addref(void) { + ptlrpcd_init(ptlrpcd_init_groupsize); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr83323.c b/SingleSource/Regression/C/gcc-dg/pr83323.c new file mode 100644 index 0000000000..6111745550 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83323.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -floop-unroll-and-jam --param unroll-jam-min-percent=0" } */ +int x[1024], y[1024]; + +void __attribute__((noipa)) foo () +{ + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + for (int j = 0; j < 1024; ++j) + if (!y[j]) + x[i] = 1; + } +} + +int main() +{ + y[1023] = 1; + foo (); + if (x[1] != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83361.c b/SingleSource/Regression/C/gcc-dg/pr83361.c new file mode 100644 index 0000000000..815b055602 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83361.c @@ -0,0 +1,40 @@ +/* PR rtl-optimization/83361 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -freorder-blocks-and-partition -Wno-div-by-zero" } */ + +#include + +int yz; + +void +tq (int z3) +{ + unsigned long long int n8 = (unsigned long long int)INT_MAX + 1; + int *ey = &yz; + + if (yz == 0) + { + int bc; + + yz = 1; + while (yz != 0) + { + *ey *= bc; + n8 = !!(1 / ((unsigned long long int)yz == n8)); + ey = &z3; + } + + while (z3 != 0) + { + } + } + + z3 = (n8 != 0) && (*ey != 0); + z3 = yz / z3; + if (z3 < 0) + { + if (yz != 0) + yz = 0; + yz /= 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83363.c b/SingleSource/Regression/C/gcc-dg/pr83363.c new file mode 100644 index 0000000000..e69826890f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83363.c @@ -0,0 +1,26 @@ +/* PR rtl-optimization/83363 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-forward-propagate" } */ + +unsigned char a; +unsigned int b; + +static unsigned short __attribute__ ((noinline, noclone)) +foo (unsigned short x) +{ + x -= b; + x <<= x == 0; + a = ~0; + a >>= (unsigned char) x == 0; + x *= a -= ~a; + return x; +} + +int +main () +{ + asm volatile ("" : : : "memory"); + if (foo (3) != (unsigned short) (3 * (unsigned char) ~0)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83364.c b/SingleSource/Regression/C/gcc-dg/pr83364.c new file mode 100644 index 0000000000..6d38e40ca5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83364.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/83364 */ +/* { dg-do run } */ +/* { dg-options "-O -fno-forward-propagate -fno-tree-coalesce-vars -fno-tree-ter" } */ + +int a; + +static int __attribute__ ((noinline, noclone)) +foo (unsigned char c) +{ + c <<= (long long) c != a; + c = c << 7 | c >> 1; + return c; +} + +int +main () +{ + asm volatile ("" : : : "memory"); + if (foo (0) != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83373.c b/SingleSource/Regression/C/gcc-dg/pr83373.c new file mode 100644 index 0000000000..6b0de0997c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83373.c @@ -0,0 +1,33 @@ +/* PR middle-end/83373 - False positive reported by -Wstringop-overflow + { dg-do compile } + { dg-options "-O2 -Wstringop-overflow" } */ + +typedef __SIZE_TYPE__ size_t; + +char buf[100]; + +void get_data (char*); + +__attribute__ ((nonnull(1, 2))) +inline char* my_strcpy (char* dst, const char* src, size_t size) +{ + size_t len = __builtin_strlen (src); + if (len < size) + __builtin_memcpy (dst, src, len + 1); + else + { + __builtin_memcpy (dst, src, size - 1); /* { dg-bogus "\\\[-Wstringop-oveflow]" } */ + dst[size - 1] = '\0'; + } + + return dst; +} + +void test(void) +{ + char data[20] = "12345"; + + get_data (data); + + my_strcpy (buf, data, sizeof buf); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83393.c b/SingleSource/Regression/C/gcc-dg/pr83393.c new file mode 100644 index 0000000000..a9a6b338e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83393.c @@ -0,0 +1,38 @@ +/* PR rtl-optimization/83393 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-forward-propagate -fno-tree-bit-ccp" } */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; + +u32 a, d; +u64 b; +u8 c; + +static u64 __attribute__ ((noinline, noclone)) +foo (u16 f, u64 g) +{ + f <<= 15; + f *= d; + f -= g %= 44; + f <<= f <= g; + c = 255; + c >>= (u8) f == 0; + f *= g; + c -= ~c; + return f + a + b + f; +} + +int +main (void) +{ +#if (__SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT__ == 4 \ + && __SIZEOF_SHORT__ == 2 && __CHAR_BIT__ == 8) + u64 x = foo (3, 0xE6C0011BBA6DBD7LL); + if (x != 0x1f66e) + __builtin_abort (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83396.c b/SingleSource/Regression/C/gcc-dg/pr83396.c new file mode 100644 index 0000000000..7d8220e115 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83396.c @@ -0,0 +1,12 @@ +/* PR bootstrap/83396 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +int bar (int); +int baz (int); + +int +foo (int x) +{ + return bar (x) || baz (x) != 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83415.c b/SingleSource/Regression/C/gcc-dg/pr83415.c new file mode 100644 index 0000000000..5934c16d97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83415.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +const short __attribute__((vector_size(16))) y = { 0, 1, 2, 3, 4, 5, 6, 7 }; + +int +main (int argc, short *argv[]) +{ + int i = argc; + y[i] = 7 - i; /* { dg-warning "read-only" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83419.c b/SingleSource/Regression/C/gcc-dg/pr83419.c new file mode 100644 index 0000000000..3d4f1d2770 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83419.c @@ -0,0 +1,16 @@ +/* PR debug/83419 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +int a, b; +void foo (int, ...); + +void +bar (void) +{ + if (a || 1 == b) + foo (1); + else + 0; + foo (1, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83422.c b/SingleSource/Regression/C/gcc-dg/pr83422.c new file mode 100644 index 0000000000..adbf7599d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83422.c @@ -0,0 +1,9 @@ +/* PR debug/83422 */ +/* { dg-do compile } */ +/* { dg-options "-O -g --param=max-vartrack-size=1" } */ + +int +foo(int i, int j, int k) +{ + return i + j + k; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83424.c b/SingleSource/Regression/C/gcc-dg/pr83424.c new file mode 100644 index 0000000000..5a304f5029 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83424.c @@ -0,0 +1,30 @@ +/* PR rtl-optimization/83424 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-coalesce-vars" } */ + +typedef unsigned char u8; +typedef unsigned int u32; +typedef unsigned __int128 u128; + +u32 a, c; +u8 b; + +static u128 __attribute__ ((noinline, noclone)) +foo (u128 p) +{ + u8 x = ~b; + p &= c; + x *= -p; + x &= a == 0; + x >>= 1; + return p + x; +} + +int +main (void) +{ + u128 x = foo (0); + if (x != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83463.c b/SingleSource/Regression/C/gcc-dg/pr83463.c new file mode 100644 index 0000000000..9142d273e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83463.c @@ -0,0 +1,20 @@ +/* PR middle-end/83463 */ +/* { dg-do compile } */ +/* { dg-prune-output "conflicting types for built-in" } */ +/* { dg-options "-O2 -Wrestrict -Wno-pointer-to-int-cast" } */ + +int *a; +void *memcpy (); +void +m (void *p1) +{ + memcpy (0, p1, 0); +} + +void +p () +{ + m (p + (long) a); +} + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr83480.c b/SingleSource/Regression/C/gcc-dg/pr83480.c new file mode 100644 index 0000000000..7b57712eae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83480.c @@ -0,0 +1,32 @@ +/* PR debug/83480 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fselective-scheduling2 -ftree-vectorize -freorder-blocks-algorithm=simple -fnon-call-exceptions -fno-guess-branch-probability -fno-peephole2 -fno-tree-sink -fno-tree-scev-cprop" } */ + +signed char a, b; + +void +foo (int x, int y) +{ + for (a = 1; a != 0; ++a) + ; + + for (;;) + { + int c; + + b %= (y != 0 && a != 0) + 1; + if (a != 0) + y = b; + + for (c = 0; c < 50; ++c) + ++x; + + if (a < 1) + { + while (x != 0) + ; + + a /= 0; /* { dg-warning "division by zero" } */ + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83491.c b/SingleSource/Regression/C/gcc-dg/pr83491.c new file mode 100644 index 0000000000..f23cc19c72 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83491.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -funsafe-math-optimizations" } */ + +float a; +float b; +void bar () +{ + a = __builtin_nanf (""); + b = __builtin_powf (a, 2.5F); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83506.c b/SingleSource/Regression/C/gcc-dg/pr83506.c new file mode 100644 index 0000000000..b138c9d3ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83506.c @@ -0,0 +1,14 @@ +/* PR ipa/83506 */ +/* { dg-do compile { target pthread } } */ +/* { dg-options "-O1 -ftree-parallelize-loops=2 -fno-ipa-pure-const" } */ + +unsigned int +foo (unsigned int x, int y) +{ + while (y < 1) + { + x *= 3; + ++y; + } + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83512.c b/SingleSource/Regression/C/gcc-dg/pr83512.c new file mode 100644 index 0000000000..d86e57befc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83512.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/83512 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -freorder-blocks-algorithm=simple" } */ + +int a; + +void +foo (int *x) +{ + for (;;) + { + for (*x = 0; *x < 1; *x++) + ; + ++a; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83517.c b/SingleSource/Regression/C/gcc-dg/pr83517.c new file mode 100644 index 0000000000..9dadbdeddf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83517.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int test(int x) +{ + return (x+x)/x; +} + +/* { dg-final { scan-tree-dump "return 2;" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr83521.c b/SingleSource/Regression/C/gcc-dg/pr83521.c new file mode 100644 index 0000000000..fc7ca04d1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83521.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/83521 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-forwprop" } */ + +int +foo (unsigned int x, int y) +{ + int *z = (int *)&x; + return (y == 0) ? y : *z; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83527.c b/SingleSource/Regression/C/gcc-dg/pr83527.c new file mode 100644 index 0000000000..effef439ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83527.c @@ -0,0 +1,26 @@ +/* PR debug/83527 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +extern void fn2(void); +extern void fn3(void); +int a, b; +void fn1() { + int c; + short d; + switch (a) { + case 32800: + fn2(); + case 32769: + b = 0; + case 32771: + case 32772: + case 32782: + fn3(); + } + if (d || c) { + do + ; + while (0); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83530.c b/SingleSource/Regression/C/gcc-dg/pr83530.c new file mode 100644 index 0000000000..f4d8927de9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83530.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fmodulo-sched -fselective-scheduling2" } */ +int vm, z0; +short int mz; + +int +ny (void) +{ + int ch; + + for (ch = 0; ch < 6; ++ch) + vm += ch / vm; + + return z0 + mz; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83552.c b/SingleSource/Regression/C/gcc-dg/pr83552.c new file mode 100644 index 0000000000..993cdd2658 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83552.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/83364 */ +/* { dg-options "-O2" } */ + +char *b; +char d[100]; +void a (); +void +c (void) +{ + __builtin_strcat (d, "12345"); + if (__builtin_strstr (b, d) == b) + a (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83581.c b/SingleSource/Regression/C/gcc-dg/pr83581.c new file mode 100644 index 0000000000..c145effb88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83581.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/83581 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-copy-prop -fno-tree-loop-im" } */ + +int a, b, c; + +int +foo (int x) +{ + int *d = &x; + while (a < 1) + { + for (b = 0; b < 2; ++b) + { + *d += !!x + 1; + d = &c; + } + ++a; + } + return *d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83585.c b/SingleSource/Regression/C/gcc-dg/pr83585.c new file mode 100644 index 0000000000..2a9cf252ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83585.c @@ -0,0 +1,18 @@ +/* PR debug/83585 */ +/* { dg-do assemble } */ +/* { dg-options "-std=gnu89 -O2 -g -fno-tree-dce -fno-guess-branch-probability" } */ + +int +foo (int x) +{ + int a, b; + for (a = 0; a < 2; ++a) + if (x != 0) + { + for (b = 0; b < 2; ++b) + ; + return 0; + } + + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83593.c b/SingleSource/Regression/C/gcc-dg/pr83593.c new file mode 100644 index 0000000000..eddecc0606 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83593.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/83593 */ +/* { dg-options "-O2 -fno-tree-dominator-opts -fnon-call-exceptions -fno-tree-pre -fexceptions -fno-code-hoisting -fno-tree-fre" } */ + +void +hr (int *ed, signed char *ju) +{ + int kc; + { + int xj; + int *q2 = (*ed == 0) ? &xj : &kc; + + *ju = 0; + kc = *ju; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83595.c b/SingleSource/Regression/C/gcc-dg/pr83595.c new file mode 100644 index 0000000000..b67970e5ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83595.c @@ -0,0 +1,9 @@ +/* PR c/83595 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo () +{ + (())((int){0); /* { dg-error "expected expression before" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83605.c b/SingleSource/Regression/C/gcc-dg/pr83605.c new file mode 100644 index 0000000000..c680f0ce91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83605.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/83605 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftrapv -fexceptions -fnon-call-exceptions" } */ + +int a; + +int +foo (int x) +{ + int b = a; + { + int c; + int *d = (x == 0) ? &c : &b; + + for (a = 0; a < 2; ++a) + c = (x + b) < a; + + return *d; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83609.c b/SingleSource/Regression/C/gcc-dg/pr83609.c new file mode 100644 index 0000000000..eac11fca93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83609.c @@ -0,0 +1,29 @@ +/* PR middle-end/83609 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-forwprop -fno-tree-ccp -fno-tree-fre -fno-tree-pre -fno-code-hoisting" } */ + +#if __SIZEOF_LONG_LONG__ == 2 * __SIZEOF_FLOAT__ +_Complex float +foo (void) +{ + _Complex float c; + *((unsigned long long *)&c) = 0x123456789abcdef0ULL; + return c; +} + +int +main () +{ + union { _Complex float c; unsigned long long l; } u; + u.c = foo (); + if (u.l != 0x123456789abcdef0ULL) + __builtin_abort (); + return 0; +} +#else +int +main () +{ + return 0; +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr83620.c b/SingleSource/Regression/C/gcc-dg/pr83620.c new file mode 100644 index 0000000000..cf6eb91197 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83620.c @@ -0,0 +1,9 @@ +/* PR rtl-optimization/86620 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -flive-range-shrinkage --param=max-sched-ready-insns=0" } */ +/* { dg-error "argument to '--param=max-sched-ready-insns=' is not between 1 and 65536" "" { target *-*-* } 0 } */ + +void +foo (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83621.c b/SingleSource/Regression/C/gcc-dg/pr83621.c new file mode 100644 index 0000000000..668a8dbfe1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83621.c @@ -0,0 +1,13 @@ +/* PR debug/83621 */ +/* { dg-do compile } */ +/* { dg-options "-O -g" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +typedef int __attribute__ ((__vector_size__ (64))) V; +V v; + +void +foo () +{ + V u = v >> 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83623.c b/SingleSource/Regression/C/gcc-dg/pr83623.c new file mode 100644 index 0000000000..ae12448e8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83623.c @@ -0,0 +1,13 @@ +/* PR middle-end/83623 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mmovbe" { target i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +unsigned short __attribute__ ((__vector_size__ (16))) x; + +void +foo (void) +{ + x = x << 8 | x >> 8; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83640.c b/SingleSource/Regression/C/gcc-dg/pr83640.c new file mode 100644 index 0000000000..3b4d1be727 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83640.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/83640 - ice in generic_overlap, at + gimple-ssa-warn-restrict.c:814 + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +char *foo (void); + +void +bar (char *b, char *c) +{ + b = c; + c = foo (); + __builtin_strcat (c, "*/"); + __builtin_strcat (c, b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83645.c b/SingleSource/Regression/C/gcc-dg/pr83645.c new file mode 100644 index 0000000000..4ac2be2d61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83645.c @@ -0,0 +1,14 @@ +/* PR debug/83645 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fno-var-tracking" } */ + +int a, b, c[1]; + +void +foo (void) +{ + int i = 0; + b = a; + for (;;) + c[i++] = 7; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83666.c b/SingleSource/Regression/C/gcc-dg/pr83666.c new file mode 100644 index 0000000000..1c43c43854 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83666.c @@ -0,0 +1,29 @@ +/* PR debug/83666 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -Wno-psabi" } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +typedef int __attribute__ ((vector_size (64))) V; + +int c, d; +short e; +V g; + +V +bar (void) +{ + g[1] = d; + do + { + e += c; + g = g > 0; + } + while (g[1]); + return g; +} + +void +foo (void) +{ + int x = bar ()[3]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83723.c b/SingleSource/Regression/C/gcc-dg/pr83723.c new file mode 100644 index 0000000000..a64fe9b56b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83723.c @@ -0,0 +1,20 @@ +/* PR rtl-optimization/83723 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ +/* { dg-additional-options "-mfpmath=sse -msse2" { target i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-fpie" { target pie } } */ + +int foo (void); +float bar (float); +int *v; + +void +baz (void) +{ + float a = bar (0.0); + bar (a); + if (v) + bar (1.0); + if (a < 1.0) + a = foo () / a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83771.c b/SingleSource/Regression/C/gcc-dg/pr83771.c new file mode 100644 index 0000000000..a5a386e20e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83771.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/83771 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fmodulo-sched -fno-ssa-phiopt" } */ + +long int a; +int b; +int foo (int); + +void +bar (void) +{ + int c; + do + { + c = a / (!!b == 1); + c = !!c + 1; + } + while (foo (c) < 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83801.c b/SingleSource/Regression/C/gcc-dg/pr83801.c new file mode 100644 index 0000000000..d4ad89fc4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83801.c @@ -0,0 +1,27 @@ +/* PR c/83801 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +static const char a[] = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"; +static const char b = a[27]; +struct S { const char c[30]; const char d[30]; }; +static const struct S e[] = { { "01234567890123456789012345678", "90123456789012345678901234567" }, + { "89012345678901234567890123456", "78901234567890123456789012345" } }; +static const char f = e[1].c[4]; + +char +foo (int i) +{ + return a[i]; +} + +char +bar (int i) +{ + return e[0].d[i]; +} + +/* { dg-final { scan-tree-dump {a\[i]} "original" } } */ +/* { dg-final { scan-tree-dump-not {"01234567890123456789012345678901234567890123456789012345678901234567890123456789"\[i]} "original" } } */ +/* { dg-final { scan-tree-dump {e\[0]\.d\[i]} "original" } } */ +/* { dg-final { scan-tree-dump-not {"90123456789012345678901234567"\[i]} "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr83844.c b/SingleSource/Regression/C/gcc-dg/pr83844.c new file mode 100644 index 0000000000..0d26b55566 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83844.c @@ -0,0 +1,37 @@ +/* PR c/83844 */ +/* { dg-do compile { target int32plus } } */ +/* { dg-options "-O0 -Wall" } */ +/* { dg-require-effective-target alloca } */ + +typedef unsigned long long __u64 __attribute__((aligned(4),warn_if_not_aligned(8))); +void bar (void *, void *, void *); + +void +foo (int n) +{ + struct A + { + int i1; + int i2; + int i3[n]; + __u64 x; /* { dg-warning "in 'struct A' may not be aligned to 8" } */ + } __attribute__((aligned (8))); + struct B + { + int i1; + int i2; + long long i3[n]; + __u64 x; + } __attribute__((aligned (8))); + struct C + { + int i1; + int i2; + int i3[2 * n]; + __u64 x; + } __attribute__((aligned (8))); + struct A a; + struct B b; + struct C c; + bar (&a, &b, &c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83852.c b/SingleSource/Regression/C/gcc-dg/pr83852.c new file mode 100644 index 0000000000..68ef78b8e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83852.c @@ -0,0 +1,33 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-std=gnu99 -O2 -fselective-scheduling -fno-if-conversion -fno-tree-dse -w" } */ +long long int uo; +unsigned int vt; + +void +r5 (long long int h8, long long int pu) +{ + short int wj; + long long int *mh = h8; + + for (wj = 0; wj < 3; ++wj) + { + int oq; + long long int ns, xf; + + h8 += 2; + oq = !!h8 && !!wj; + ++uo; + vt ^= oq + uo; + ns = !!uo && !!vt; + xf = (h8 != 0) ? mh : 1; + pu += ns < xf; + } + + for (pu = 0; pu < 1; ++pu) + { + int *sc; + + sc = (int *)&pu; + *sc = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83913.c b/SingleSource/Regression/C/gcc-dg/pr83913.c new file mode 100644 index 0000000000..c898d71a26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83913.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -funroll-all-loops -fselective-scheduling -fsel-sched-pipelining -fschedule-insns -fno-dce -fno-forward-propagate -fno-rerun-cse-after-loop -fno-web" } */ + +int jo, z4; + +int +be (long unsigned int l7, int nt) +{ + int en; + + jo = l7; + for (en = 0; en < 24; ++en) + { + jo = (jo / z4) * (!!jo >= ((!!nt) & 2)); + if (jo == 0) + nt = 0; + else + { + nt = z4; + ++z4; + nt = (long unsigned int) nt == (l7 + 1); + } + } + + return nt; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83922.c b/SingleSource/Regression/C/gcc-dg/pr83922.c new file mode 100644 index 0000000000..8f99f7724b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83922.c @@ -0,0 +1,21 @@ +/* { dg-options "-O -ftree-vectorize" } */ + +int j4; + +void +k1 (int ak) +{ + while (ak < 1) + { + int ur; + + for (ur = 0; ur < 2; ++ur) + { + ++j4; + if (j4 != 0) + j4 = 0; + } + + ++ak; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83930.c b/SingleSource/Regression/C/gcc-dg/pr83930.c new file mode 100644 index 0000000000..8a079af3fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83930.c @@ -0,0 +1,17 @@ +/* PR target/83930 */ +/* { dg-do compile } */ +/* { dg-options "-Og -fno-tree-ccp -w" } */ + +unsigned __attribute__ ((__vector_size__ (16))) v; + +static inline void +bar (unsigned char d) +{ + v /= d; +} + +__attribute__ ((always_inline)) void +foo (void) +{ + bar (4); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83962.c b/SingleSource/Regression/C/gcc-dg/pr83962.c new file mode 100644 index 0000000000..0547e21871 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83962.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-std=gnu99 -O1 -fselective-scheduling2 -fschedule-insns2 -fcse-follow-jumps -fno-ssa-phiopt -fno-guess-branch-probability" } */ +unsigned int ca; + +void +v6 (long long unsigned int as, int p9) +{ + while (p9 < 1) + as = (as != ca) || (as > 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83972.c b/SingleSource/Regression/C/gcc-dg/pr83972.c new file mode 100644 index 0000000000..b8de42cef0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83972.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O1 -fschedule-insns -fselective-scheduling -fsel-sched-pipelining -fvar-tracking-assignments -funroll-loops -fno-tree-dominator-opts -w" } */ + +int s7, p0; + +void +i0 (int ke) +{ + while (ke < 1) + { + if (s7 == 0) + p0 = 0; + else + { + if (p0 == 0) + s7 = 0; + + if (!!s7 || !!p0) + s7 = 0; + else + p0 = 0; + } + + ++ke; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83985.c b/SingleSource/Regression/C/gcc-dg/pr83985.c new file mode 100644 index 0000000000..51cfc49a19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83985.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/83985 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mcpu=e300c3 -mtune=e300c3" { target { powerpc*-*-* && ilp32 } } } */ + +long long int v; + +void +foo (int x) +{ + if (x == 0) + return; + + while (v < 2) + { + signed char *a; + v /= x; + a = v == 0 ? (signed char *) &x : (signed char *) &v; + ++*a; + ++v; + } + + while (1) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr83986.c b/SingleSource/Regression/C/gcc-dg/pr83986.c new file mode 100644 index 0000000000..31a53d9361 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr83986.c @@ -0,0 +1,14 @@ +/* PR rtl-optimization/83986 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -fsched2-use-superblocks -funwind-tables --param max-pending-list-length=1" } */ + +int v; + +int +foo (int x) +{ + v &= !!v && !!x; + if (v != 0) + foo (0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84032.c b/SingleSource/Regression/C/gcc-dg/pr84032.c new file mode 100644 index 0000000000..c295d9a0da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84032.c @@ -0,0 +1,23 @@ +/* PR rtl-optimization/84032 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fmodulo-sched" } */ +/* { dg-additional-options "-mcpu=power6" { target { powerpc-*-* } } } */ + +void +yr (int cm) +{ + int ka = cm; + + for (;;) + { + short int m0; + + for (m0 = 0; m0 < 6; ++m0) + { + ka &= 1; + cm *= 2; + } + + ka = (ka == 0) ? cm : 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84068.c b/SingleSource/Regression/C/gcc-dg/pr84068.c new file mode 100644 index 0000000000..13110d8445 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84068.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-sched-critical-path-heuristic -fno-sched-rank-heuristic --param=max-sched-extend-regions-iters=5 --param sched-pressure-algorithm=2" } */ + +#ifdef __SIZEOF_INT128__ +typedef __int128 largeint; +#else +typedef long long largeint; +#endif + +largeint a; +int b; + +largeint +foo (char d, short e, int f) +{ + b = __builtin_sub_overflow_p (b, 1, (unsigned long)0); + return a + f; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84095.c b/SingleSource/Regression/C/gcc-dg/pr84095.c new file mode 100644 index 0000000000..af2bc0e3f2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84095.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/84095 - false-positive -Wrestrict warnings for + memcpy within array + { dg-do compile } + { dg-options "-O2 -Wrestrict" } */ + +struct { int i; } a[8]; + +void f (void) +{ + int i; + + for (i = 1; i < 8; i++) + __builtin_memcpy (&a[i], &a[0], sizeof(a[0])); /* { dg-bogus "\\\[-Wrestrict]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84100.c b/SingleSource/Regression/C/gcc-dg/pr84100.c new file mode 100644 index 0000000000..fd157ac34a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84100.c @@ -0,0 +1,15 @@ +/* PR c/84100 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "no code alignment > 2" { "pdp11-*-*" } } */ + +void bar (void); + +__attribute__((optimize ("align-loops=16", "align-jumps=16", + "align-labels=16", "align-functions=16"))) +void +foo (void) +{ /* { dg-bogus "bad option" } */ + for (int i = 0; i < 1024; ++i) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84131.c b/SingleSource/Regression/C/gcc-dg/pr84131.c new file mode 100644 index 0000000000..ced2e5d932 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84131.c @@ -0,0 +1,30 @@ +/* PR 94131 - ICE on printf with a VLA string and -fno-tree-ccp + -fno-tree-forwprop + { dg-do compile } + { dg-options "-O1 -fno-tree-ccp -fno-tree-forwprop" } + { dg-require-effective-target alloca } */ + +void rv1 (int n) +{ + char a[n]; + __INTPTR_TYPE__ i = (__INTPTR_TYPE__ )&a[0]; + i &= 3; + + __builtin_memset (a, '\0', sizeof a); + __builtin_printf ("%s", i ? &a[0] : ""); +} + + +void sink (void*); + +void rv2 (int n) +{ + char a[n]; + __INTPTR_TYPE__ i = (__INTPTR_TYPE__)&a[0]; + i &= 3; + + __builtin_memset (a, '\0', sizeof a); + __builtin_printf ("%s", i ? &a[0] : ""); + + sink (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84206.c b/SingleSource/Regression/C/gcc-dg/pr84206.c new file mode 100644 index 0000000000..b4ac9c24c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84206.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fno-forward-propagate -fno-tree-fre -w" } */ + +long long unsigned int ao; +int hk; + +void +b8 (void) +{ + int *w9; + + c8: + ao = 0; + w9 = &ao; + for (;;) + for (hk = 0; hk < 1; ++hk) + for (ao = 0; ao < 4; ++ao) + { + int f4 = (ao != 0) ? *w9 : hk; + + if (f4 != 0) + goto c8; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84225.c b/SingleSource/Regression/C/gcc-dg/pr84225.c new file mode 100644 index 0000000000..f57266c9a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84225.c @@ -0,0 +1,5 @@ +/* PR tree-optimization/84225 */ +/* { dg-do compile { target int32plus } } */ +/* { dg-options "-Ofast -ftrapv" } */ + +#include "torture/pr69714.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr84237.c b/SingleSource/Regression/C/gcc-dg/pr84237.c new file mode 100644 index 0000000000..5a2697f316 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84237.c @@ -0,0 +1,5 @@ +/* PR middle-end/84237 */ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-options "" } */ + +const char __attribute__((__section__(".bss.page_aligned.const"), __aligned__(4096))) zero_page[4096]; diff --git a/SingleSource/Regression/C/gcc-dg/pr84300.c b/SingleSource/Regression/C/gcc-dg/pr84300.c new file mode 100644 index 0000000000..6016799a43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84300.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-g -O2 -fsplit-stack -fno-omit-frame-pointer" } */ + +void trap () { __builtin_trap (); } diff --git a/SingleSource/Regression/C/gcc-dg/pr84309-2.c b/SingleSource/Regression/C/gcc-dg/pr84309-2.c new file mode 100644 index 0000000000..ced55d4a64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84309-2.c @@ -0,0 +1,11 @@ +/* PR middle-end/84309 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ + +double +foo (double x) +{ + return __builtin_pow (2.0, x); +} + +/* { dg-final { scan-tree-dump "__builtin_exp2 " "optimized" { target *-*-linux* *-*-gnu* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr84309.c b/SingleSource/Regression/C/gcc-dg/pr84309.c new file mode 100644 index 0000000000..6fe774e57c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84309.c @@ -0,0 +1,14 @@ +/* PR middle-end/84309 */ +/* { dg-do run { target c99_runtime } } */ +/* { dg-options "-O2 -ffast-math" } */ + +int +main () +{ + unsigned long a = 1024; + unsigned long b = 16 * 1024; + unsigned long c = __builtin_pow (2, (__builtin_log2 (a) + __builtin_log2 (b)) / 2); + if (c != 4096) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84321.c b/SingleSource/Regression/C/gcc-dg/pr84321.c new file mode 100644 index 0000000000..8f8186b58f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84321.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fwrapv" } */ + +int c; + +void +foo (int *a, int b) +{ + int e; + if (b == 1) + return; + for (e = 0; e < (b & ~7); e += 8) + ; + for (++e; e < b;) + c = a[e]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84334.c b/SingleSource/Regression/C/gcc-dg/pr84334.c new file mode 100644 index 0000000000..8cfde69bd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84334.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/84334 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -frounding-math" } */ + +float +foo (void) +{ + float a = 9.999999974752427078783512115478515625e-7f; + float b = 1.999999994950485415756702423095703125e-6f; + float c = 4.999999873689375817775726318359375e-6f; + return a + b + c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84452.c b/SingleSource/Regression/C/gcc-dg/pr84452.c new file mode 100644 index 0000000000..6e961cb04e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84452.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/84452 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +double pow (double, double) __attribute__((simd)); +double exp (double) __attribute__((simd)); +extern double a[1024], b[1024]; + +void +foo (void) +{ + for (int i = 0; i < 1024; ++i) + a[i] = pow (2.0, b[i]); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84503-1.c b/SingleSource/Regression/C/gcc-dg/pr84503-1.c new file mode 100644 index 0000000000..03fb2fbd9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84503-1.c @@ -0,0 +1,68 @@ +/* PR tree-optimization/84503 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __UINTPTR_TYPE__ uintptr_t; + +struct S { int a; unsigned short b; int c, d, e; long f, g, h; int i, j; }; +static struct S *k; +static size_t l = 0; +int m; + +static int +bar (void) +{ + unsigned i; + int j; + if (k[0].c == 0) + { + ++m; + size_t n = l * 2; + struct S *o; + o = (struct S *) __builtin_realloc (k, sizeof (struct S) * n); + if (!o) + __builtin_exit (0); + k = o; + for (i = l; i < n; i++) + { + void *p = (void *) &k[i]; + int q = 0; + size_t r = sizeof (struct S); + if ((((uintptr_t) p) % __alignof__ (long)) == 0 + && r % sizeof (long) == 0) + { + long __attribute__ ((may_alias)) *s = (long *) p; + long *t = (long *) ((char *) s + r); + while (s < t) + *s++ = 0; + } + else + __builtin_memset (p, q, r); + k[i].c = i + 1; + k[i].a = -1; + } + k[n - 1].c = 0; + k[0].c = l; + l = n; + } + j = k[0].c; + k[0].c = k[j].c; + return j; +} + +int +main () +{ + k = (struct S *) __builtin_malloc (sizeof (struct S)); + if (!k) + __builtin_exit (0); + __builtin_memset (k, '\0', sizeof (struct S)); + k->a = -1; + l = 1; + for (int i = 0; i < 15; ++i) + bar (); + if (m != 4) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84503-2.c b/SingleSource/Regression/C/gcc-dg/pr84503-2.c new file mode 100644 index 0000000000..76701f0793 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84503-2.c @@ -0,0 +1,5 @@ +/* PR tree-optimization/84503 */ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-tree-vectorize -fno-ivopts" } */ + +#include "pr84503-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr84607.c b/SingleSource/Regression/C/gcc-dg/pr84607.c new file mode 100644 index 0000000000..710ee94f72 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84607.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +extern void exit(int); +extern void abort(void); +int a[10]; +int foo() +{ + exit (0); + return 0; +} +int main() +{ + if (&a[foo()]) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84614.c b/SingleSource/Regression/C/gcc-dg/pr84614.c new file mode 100644 index 0000000000..98af26ba4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84614.c @@ -0,0 +1,28 @@ +/* PR target/84614 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-Og -fno-split-wide-types -fno-tree-coalesce-vars -g --param=max-combine-insns=3 -fcompare-debug" } */ + +unsigned __int128 a; + +unsigned __int128 +b (unsigned short c, unsigned int d) +{ + unsigned long long e; + __builtin_sub_overflow (0, d, &e); + e >>= c; + c ^= 65535; + d ^= 824; + return c + a + d + e; +} + +int +main () +{ + unsigned __int128 x = b (0, 9); + if (__SIZEOF_INT__ * __CHAR_BIT__ == 32 + && __SIZEOF_LONG_LONG__ * __CHAR_BIT__ == 64 + && __SIZEOF_INT128__ * __CHAR_BIT__ == 128 + && x != (((unsigned __int128) 1 << 64) | 0x10327)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84628.c b/SingleSource/Regression/C/gcc-dg/pr84628.c new file mode 100644 index 0000000000..b8eb53c7dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84628.c @@ -0,0 +1,8 @@ +/* PR ipa/84628 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int f0 (void); +__attribute__((error ("err"))) void f1 (void) { f0 (); f0 (); } +__attribute__((error ("err"))) void f2 (void) { f0 (); f0 (); } +/* { dg-bogus "declared with attribute error" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr84659.c b/SingleSource/Regression/C/gcc-dg/pr84659.c new file mode 100644 index 0000000000..94c885f386 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84659.c @@ -0,0 +1,19 @@ +/* PR rtl-optimization/84659 */ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining -fno-split-wide-types -fno-strict-aliasing -fno-tree-dce" } */ + +void +jk (int **lq, int *k4, long long int qv, int od) +{ + while (**lq < 1) + { + int uo; + + uo = ((od == 0) ? qv : *k4) != 1; + ++**lq; + } + + for (;;) + { + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84670-1.c b/SingleSource/Regression/C/gcc-dg/pr84670-1.c new file mode 100644 index 0000000000..c1ad474aa4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84670-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fno-tree-dominator-opts" } */ + +int a, b, c, d; + +int +foo (void) +{ + __int128 i; +l: + i -= c; + if (b) + goto l; + __builtin_mul_overflow (0, a, &c); + if (d) + goto l; + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84670-2.c b/SingleSource/Regression/C/gcc-dg/pr84670-2.c new file mode 100644 index 0000000000..80fb368549 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84670-2.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +enum b +{ + c, + d +}; +struct e +{ + enum b code; +}; +struct f +{ + unsigned g; +}; +int h, i; +struct a +{ + struct e common; + struct f j; +}; + +struct a k (void) +{ + struct a *l; + do + if (l->common.code == d && l->j.g * 4) + ; + else + i = l->j.g | (l->common.code && l); + while (h && l->common.code == c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84670-3.c b/SingleSource/Regression/C/gcc-dg/pr84670-3.c new file mode 100644 index 0000000000..b60a94a837 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84670-3.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-strict-overflow" } */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef u16 acpi_rs_length; +typedef u32 acpi_rsdesc_size; +struct acpi_resource_source +{ + u16 string_length; + char *string_ptr; +}; +static u16 +acpi_rs_strcpy (char *destination, char *source) +{ + u16 i; + for (i = 0; source[i]; i++) + { + } + return ((u16) (i + 1)); +} +union aml_resource; +acpi_rs_length +acpi_rs_get_resource_source (acpi_rs_length resource_length, + acpi_rs_length minimum_length, + struct acpi_resource_source * resource_source, + union aml_resource * aml, char *string_ptr) +{ + acpi_rsdesc_size total_length; + u8 *aml_resource_source; + if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) + { + resource_source->string_length = + acpi_rs_strcpy (resource_source->string_ptr, + ((char *) (void *) (&aml_resource_source[1]))); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84670-4.c b/SingleSource/Regression/C/gcc-dg/pr84670-4.c new file mode 100644 index 0000000000..0360550818 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84670-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fwrapv" } */ +/* { dg-require-effective-target ptr_eq_long } */ + +char *a; +int b(void) +{ + long d; + if (a) { + char c; + while ((c = *a) && !((unsigned)c - '0' <= 9) && c != ',' && c != '-' + && c != '+') + ++a; + d = (long)a; + } + if (*a) + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84687.c b/SingleSource/Regression/C/gcc-dg/pr84687.c new file mode 100644 index 0000000000..f3ac9ac27d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84687.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/84687 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +int a[64], b; +double pow (double, double); +__attribute__((__simd__)) double exp (double); + +void +foo (double x) +{ + int i; + double c = exp (x); + for (i = 0; i < 64; i++) + { + b = i; + a[i] = pow (12.0, b) * pow (c, i); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84710.c b/SingleSource/Regression/C/gcc-dg/pr84710.c new file mode 100644 index 0000000000..6477244860 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84710.c @@ -0,0 +1,13 @@ +/* PR target/84710 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-forward-propagate" } */ + +char a; +int b; + +void +foo (void) +{ + int d; + b = __builtin_mul_overflow ((char) d, 0xfe, &a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84721.c b/SingleSource/Regression/C/gcc-dg/pr84721.c new file mode 100644 index 0000000000..3ebf3a6c83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84721.c @@ -0,0 +1,6 @@ +/* PR c/84721 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ + +int a[({ int b })]; /* { dg-error "braced-group within expression allowed only inside a function" } */ +int c[({ int d () {}; })]; /* { dg-error "braced-group within expression allowed only inside a function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr84739.c b/SingleSource/Regression/C/gcc-dg/pr84739.c new file mode 100644 index 0000000000..6903425c5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84739.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/84739 */ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ +/* { dg-options "-O2" } */ + +static void baz (void) __attribute__((weakref("bar"))); /* { dg-warning "alias between functions of incompatible types" } */ + +int +foo (int x, int y) +{ + if (x) + y = 0; + if (y) + goto lab; + y = 0; +lab: + return y; +} + +void +bar (int x, int y) /* { dg-message "aliased declaration here" } */ +{ + y = foo (x, y); + if (y != 0) + baz (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84772.c b/SingleSource/Regression/C/gcc-dg/pr84772.c new file mode 100644 index 0000000000..1241d21235 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84772.c @@ -0,0 +1,13 @@ +/* PR target/84772 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +#include + +void +foo (int *x, int y, va_list ap) +{ + __builtin_memset (x, 0, sizeof (int)); + for (int i = 0; i < y; i++) + va_arg (ap, long double); /* { dg-bogus "uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84799.c b/SingleSource/Regression/C/gcc-dg/pr84799.c new file mode 100644 index 0000000000..2b3a48f9e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84799.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int a, g; +long b, f; +short c, d, e; + +static void fn1 () +{ + if (a) + { + long i = 5, j = b / i | c; + int k = b % (d % i) & j; + short l = ~f % (-d / j ^ -e), m = e << (d - l); + if (k) + m = d; + i = d | (i & b); + g = (c | ~f) % i + l; + e = (c - f) & e; + d = m; + } +} + +int main () +{ + b |= 1; + fn1 (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84834.c b/SingleSource/Regression/C/gcc-dg/pr84834.c new file mode 100644 index 0000000000..38c056bb4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84834.c @@ -0,0 +1,15 @@ +/* PR middle-end/84834 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +_Complex int +foo (int a) +{ + return a < 0; +} + +_Complex int +bar (int a) +{ + return (a & 8) ? (_Complex int) 16 : (_Complex int) 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84841.c b/SingleSource/Regression/C/gcc-dg/pr84841.c new file mode 100644 index 0000000000..4f7422a659 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84841.c @@ -0,0 +1,9 @@ +/* PR tree-optimization/84841 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fassociative-math -frounding-math -fno-signed-zeros -fno-trapping-math -fno-tree-forwprop" } */ + +double +foo (double x) +{ + return -x * 0.1 * 0.1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84853.c b/SingleSource/Regression/C/gcc-dg/pr84853.c new file mode 100644 index 0000000000..c74526369a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84853.c @@ -0,0 +1,19 @@ +/* PR c/84853 */ +/* { dg-do compile } */ + +typedef float V __attribute__((__vector_size__ (16))); +typedef int W __attribute__((__vector_size__ (16))); + +void +foo (int x, V *y, V *z, W *w) +{ + *y = *y << x; /* { dg-error "invalid operands to binary <<" } */ + *z = *z << *w; /* { dg-error "invalid operands to binary <<" } */ +} + +void +bar (int x, V *y, V *z, W *w) +{ + *y = *y >> x; /* { dg-error "invalid operands to binary >>" } */ + *z = *z >> *w; /* { dg-error "invalid operands to binary >>" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84875.c b/SingleSource/Regression/C/gcc-dg/pr84875.c new file mode 100644 index 0000000000..257176de20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84875.c @@ -0,0 +1,28 @@ +/* PR debug/84875 */ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ +/* { dg-additional-options "-fpie" { target pie } } */ +/* { dg-additional-options "-march=z196" { target s390*-*-* } } */ + +static long *a[100]; +static int b[100]; +long *c; +int d; +void foo (long *); + +void +bar () +{ + long *g = c; + g--; + d = *g; + if (d) + if (b[d] < 8) + { + *(void **)g = a[d]; + a[d] = g; + b[d]++; + return; + } + foo (g); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84877.c b/SingleSource/Regression/C/gcc-dg/pr84877.c new file mode 100644 index 0000000000..d1fb84763c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84877.c @@ -0,0 +1,38 @@ +/* { dg-do run { xfail { cris-*-* hppa*-*-* sparc*-*-* } } } */ +/* { dg-options "-O2" } */ + +#include + +struct U { + int M0; + int M1; +} __attribute ((aligned (16))); + +volatile struct U p0 = {1, 0}; + +void __attribute__ ((noinline)) +foo (struct U p) +{ + + volatile intptr_t mask = 0b1111; + volatile int dummy[2]; + struct U p1 = p; + dummy[1] = p.M0; + + if ((intptr_t)(&p1) & mask) + __builtin_abort (); + if ((intptr_t)(&p) & mask) + __builtin_abort (); + + if (p1.M0 != dummy[1]) + __builtin_abort (); + if (p1.M1 != p.M1) + __builtin_abort (); +} + +int +main () +{ + foo (p0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84899.c b/SingleSource/Regression/C/gcc-dg/pr84899.c new file mode 100644 index 0000000000..0706fecada --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84899.c @@ -0,0 +1,12 @@ +/* PR target/84899 */ +/* { dg-do compile } */ +/* { dg-options "-O -funroll-all-loops -fno-move-loop-invariants" } */ + +void +foo (int x) +{ + int a = 1 / x, b = 0; + + while ((a + b + 1) < x) + b = __INT_MAX__; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84941.c b/SingleSource/Regression/C/gcc-dg/pr84941.c new file mode 100644 index 0000000000..a3a4fdcbb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84941.c @@ -0,0 +1,11 @@ +/* PR inline-asm/84941 */ +/* { dg-do compile } */ +/* { dg-skip-if "asm operand has impossible constraints" { hppa*-*-* } } */ +/* { dg-options "-O2" } */ + +void +foo (void) +{ + short *b[1] = { 0 }; + asm volatile ("" : "=m,m" (b), "=r,r" (b) : "1,p" (b)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84953.c b/SingleSource/Regression/C/gcc-dg/pr84953.c new file mode 100644 index 0000000000..723a8a67dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84953.c @@ -0,0 +1,11 @@ +/* PR c/84953 */ +/* { dg-do compile } */ + +char *strpbrk (const char *, const char *); + +char * +test (char *p) +{ + p = strpbrk (p, ""); /* { dg-bogus "assignment discards 'const' qualifier from pointer target type" } */ + return p; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr84956.c b/SingleSource/Regression/C/gcc-dg/pr84956.c new file mode 100644 index 0000000000..055a749d63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr84956.c @@ -0,0 +1,27 @@ +/* { dg-options "-O2 -ftree-tail-merge" } */ + +char a; +int c; +unsigned b (); + +unsigned +setjmp () +{ +} + +static void +d () +{ + if (b ()) + c = 3; +} + +void +e () +{ + d (); + a && ({ setjmp (); }); + a && ({ setjmp (); }); + a && ({ setjmp (); }); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr85045.c b/SingleSource/Regression/C/gcc-dg/pr85045.c new file mode 100644 index 0000000000..8c4a7aa36a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85045.c @@ -0,0 +1,9 @@ +/* PR c/85045 */ +/* { dg-do compile } */ +/* { dg-options "-fno-diagnostics-show-caret" } */ + +void +f (double a, double b) +{ + (a / b) (); /* { dg-error "called object .a / b. is not a function or function pointer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85164-1.c b/SingleSource/Regression/C/gcc-dg/pr85164-1.c new file mode 100644 index 0000000000..4c5995e887 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85164-1.c @@ -0,0 +1,7 @@ +/* { dg-options "-O2 -w" } */ +a[]; +b; +c() { + unsigned long d; + b = a[d - 1 >> 3]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85164-2.c b/SingleSource/Regression/C/gcc-dg/pr85164-2.c new file mode 100644 index 0000000000..9e9a7db2bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85164-2.c @@ -0,0 +1,4 @@ +/* { dg-options "-O2 -w" } */ +int a; +long b; +void c() { b = -9223372036854775807L - 1 - a; } diff --git a/SingleSource/Regression/C/gcc-dg/pr85167.c b/SingleSource/Regression/C/gcc-dg/pr85167.c new file mode 100644 index 0000000000..e4277e3ef7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85167.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/85167 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +struct A { long b; }; +int c, d, e; +int bar (void); + +int +foo (void) +{ + long g; + for (; g == c ? 0 : (e = 1); g = ((struct A *)g)->b) + if (bar ()) + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85180.c b/SingleSource/Regression/C/gcc-dg/pr85180.c new file mode 100644 index 0000000000..07c77fbdb4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85180.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +char *bar (void); +__INTPTR_TYPE__ baz (void); + +void +foo (__INTPTR_TYPE__ *q) +{ + char *p = bar (); + __INTPTR_TYPE__ a = baz (); + __INTPTR_TYPE__ b = baz (); + int i = 0; +#define X q[i++] = a; q[i++] = b; a = a + b; b = b + a; +#define Y X X X X X X X X X X +#define Z Y Y Y Y Y Y Y Y Y Y + Z Z Z Z Z Z Z Z Z Z + p[a] = 1; + p[b] = 2; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85195.c b/SingleSource/Regression/C/gcc-dg/pr85195.c new file mode 100644 index 0000000000..fb21ee97c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85195.c @@ -0,0 +1,19 @@ +/* PR middle-end/85195 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Wno-psabi -O -fno-tree-ccp" } */ + +typedef __int128 V __attribute__ ((vector_size (16))); + +extern int bar (V); + +V v; +int i; + +V +foo (void) +{ + do + v *= bar (v & i); + while ((V){}[0]); + return v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85257.c b/SingleSource/Regression/C/gcc-dg/pr85257.c new file mode 100644 index 0000000000..3bf07b3a5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85257.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/85257 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2 -fno-tree-ccp" } */ + +typedef __int128 V __attribute__ ((__vector_size__ (16 * sizeof (__int128)))); + +__int128 __attribute__ ((noipa)) +foo (void) +{ + V v = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + return v[5]; +} + +int +main () +{ + if (foo () != 6) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85300.c b/SingleSource/Regression/C/gcc-dg/pr85300.c new file mode 100644 index 0000000000..87a30b8d41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85300.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/85300 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -g -funroll-all-loops -fno-tree-ter -fno-web" } */ + +void +foo (double x, unsigned char y) +{ + while ((int) x < 1) + { + float a; + + a = y | 0x100; + y = 0; + x = a; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85376.c b/SingleSource/Regression/C/gcc-dg/pr85376.c new file mode 100644 index 0000000000..ede44dd878 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85376.c @@ -0,0 +1,32 @@ +/* PR rtl-optimization/85376 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-Og -fno-dce -fgcse -fno-tree-ccp -fno-tree-copy-prop -Wno-psabi" } */ + +typedef unsigned int U __attribute__ ((vector_size (64))); +typedef unsigned __int128 V __attribute__ ((vector_size (64))); +unsigned int e, i, l; +unsigned char f; +U g, h, k, j; + +static inline V +foo (unsigned char n, unsigned short o, unsigned int p, U q, U r, U s) +{ + unsigned int t; + o <<= 5; + q[7] >>= __builtin_add_overflow (0xfffffff0, __builtin_ffs (n), &s[5]); + t = __builtin_ffs (g[7]); + e *= __builtin_sub_overflow (o, t, &f); + return f + (V) g + (V) h + (V) q + i + (V) j + (V) s + (V) k + l; +} + +int +main () +{ + if (__SIZEOF_INT128__ != 16 || __SIZEOF_INT__ != 4 || __CHAR_BIT__ != 8) + return 0; + V x = foo (0, 1, 5, (U) { }, (U) { }, (U) { }); + for (unsigned i = 0; i < 4; i++) + if ((unsigned int) x[i] != 0x20) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85388-1.c b/SingleSource/Regression/C/gcc-dg/pr85388-1.c new file mode 100644 index 0000000000..8176118e71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85388-1.c @@ -0,0 +1,50 @@ +/* This test needs to use setrlimit to set the stack size, so it can + only run on Unix. */ +/* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */ +/* { dg-require-effective-target cet } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack -fcf-protection" } */ + +#include +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +/* Each recursive call uses 10,000 bytes. We call it 1000 times, + using a total of 10,000,000 bytes. If -fsplit-stack is not + working, that will overflow our stack limit. */ + +static void +down (int i) +{ + char buf[10000]; + + if (i > 0) + { + use_buffer (buf); + down (i - 1); + } +} + +int +main (void) +{ + struct rlimit r; + + /* We set a stack limit because we are usually invoked via make, and + make sets the stack limit to be as large as possible. */ + r.rlim_cur = 8192 * 1024; + r.rlim_max = 8192 * 1024; + if (setrlimit (RLIMIT_STACK, &r) != 0) + abort (); + down (1000); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85388-2.c b/SingleSource/Regression/C/gcc-dg/pr85388-2.c new file mode 100644 index 0000000000..075ab9ed56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85388-2.c @@ -0,0 +1,56 @@ +/* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */ +/* { dg-require-effective-target cet } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-require-effective-target pthread_h } */ +/* { dg-options "-pthread -fsplit-stack -fcf-protection" } */ + +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +/* Each recursive call uses 10,000 bytes. We call it 1000 times, + using a total of 10,000,000 bytes. If -fsplit-stack is not + working, that will overflow our stack limit. */ + +static void +down (int i) +{ + char buf[10000]; + + if (i > 0) + { + use_buffer (buf); + down (i - 1); + } +} + +static void * +thread_routine (void *arg __attribute__ ((unused))) +{ + down (1000); + return NULL; +} + +int +main (void) +{ + int i; + pthread_t tid; + void *dummy; + + i = pthread_create (&tid, NULL, thread_routine, NULL); + if (i != 0) + abort (); + i = pthread_join (tid, &dummy); + if (i != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85388-3.c b/SingleSource/Regression/C/gcc-dg/pr85388-3.c new file mode 100644 index 0000000000..232ef20acf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85388-3.c @@ -0,0 +1,65 @@ +/* This test needs to use setrlimit to set the stack size, so it can + only run on Unix. */ +/* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */ +/* { dg-require-effective-target cet } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack -fcf-protection" } */ + +#include +#include +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +/* Each recursive call uses 10,000 bytes. We call it 1000 times, + using a total of 10,000,000 bytes. If -fsplit-stack is not + working, that will overflow our stack limit. */ + +static void +down (int i, ...) +{ + char buf[10000]; + va_list ap; + + va_start (ap, i); + if (va_arg (ap, int) != 1 + || va_arg (ap, int) != 2 + || va_arg (ap, int) != 3 + || va_arg (ap, int) != 4 + || va_arg (ap, int) != 5 + || va_arg (ap, int) != 6 + || va_arg (ap, int) != 7 + || va_arg (ap, int) != 8 + || va_arg (ap, int) != 9 + || va_arg (ap, int) != 10) + abort (); + + if (i > 0) + { + use_buffer (buf); + down (i - 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + } +} + +int +main (void) +{ + struct rlimit r; + + /* We set a stack limit because we are usually invoked via make, and + make sets the stack limit to be as large as possible. */ + r.rlim_cur = 8192 * 1024; + r.rlim_max = 8192 * 1024; + if (setrlimit (RLIMIT_STACK, &r) != 0) + abort (); + down (1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85388-4.c b/SingleSource/Regression/C/gcc-dg/pr85388-4.c new file mode 100644 index 0000000000..8a3cc14f20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85388-4.c @@ -0,0 +1,69 @@ +/* This test needs to use setrlimit to set the stack size, so it can + only run on Unix. */ +/* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */ +/* { dg-require-effective-target cet } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack -fcf-protection" } */ + +#include +#include +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf, size_t) __attribute__ ((noinline)); +static void +use_buffer (char *buf, size_t c) +{ + size_t i; + + for (i = 0; i < c; ++i) + buf[i] = (char) i; +} + +/* Each recursive call uses 10 * i bytes. We call it 1000 times, + using a total of 5,000,000 bytes. If -fsplit-stack is not working, + that will overflow our stack limit. */ + +static void +down1 (int i) +{ + char buf[10 * i]; + + if (i > 0) + { + use_buffer (buf, 10 * i); + down1 (i - 1); + } +} + +/* Same thing, using alloca. */ + +static void +down2 (int i) +{ + char *buf = alloca (10 * i); + + if (i > 0) + { + use_buffer (buf, 10 * i); + down2 (i - 1); + } +} + +int +main (void) +{ + struct rlimit r; + + /* We set a stack limit because we are usually invoked via make, and + make sets the stack limit to be as large as possible. */ + r.rlim_cur = 8192 * 1024; + r.rlim_max = 8192 * 1024; + if (setrlimit (RLIMIT_STACK, &r) != 0) + abort (); + down1 (1000); + down2 (1000); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85388-5.c b/SingleSource/Regression/C/gcc-dg/pr85388-5.c new file mode 100644 index 0000000000..6c161b9c5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85388-5.c @@ -0,0 +1,54 @@ +/* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */ +/* { dg-require-effective-target cet } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack -fcf-protection" } */ + +/* This test is like split-3.c, but tests with a smaller stack frame, + since that uses a different prologue. */ + +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +/* When using gold, the call to abort will force a stack split. */ + +static void +down (int i, ...) +{ + char buf[1]; + va_list ap; + + va_start (ap, i); + if (va_arg (ap, int) != 1 + || va_arg (ap, int) != 2 + || va_arg (ap, int) != 3 + || va_arg (ap, int) != 4 + || va_arg (ap, int) != 5 + || va_arg (ap, int) != 6 + || va_arg (ap, int) != 7 + || va_arg (ap, int) != 8 + || va_arg (ap, int) != 9 + || va_arg (ap, int) != 10) + abort (); + + if (i > 0) + { + use_buffer (buf); + down (i - 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + } +} + +int +main (void) +{ + down (1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85388-6.c b/SingleSource/Regression/C/gcc-dg/pr85388-6.c new file mode 100644 index 0000000000..b218dfc614 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85388-6.c @@ -0,0 +1,56 @@ +/* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */ +/* { dg-require-effective-target cet } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack -O2 -fcf-protection" } */ +/* { dg-options "-fsplit-stack -O2 -mno-accumulate-outgoing-args -fcf-protection" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* A case that used to fail on 32-bit x86 when optimizing and not + using -maccumulate-args. The stack adjustment of the alloca got + mixed up with the arguments pushed on the stack to the function + before the call of alloca. */ + +#include + +typedef struct { const char* s; int l; } s; + +typedef unsigned long long align16 __attribute__ ((aligned(16))); + +s gobats (const void *, int) __attribute__ ((noinline)); + +s +gobats (const void* p __attribute__ ((unused)), + int l __attribute__ ((unused))) +{ + s v; + v.s = 0; + v.l = 0; + return v; +} + +void check_aligned (void *p) __attribute__ ((noinline)); + +void +check_aligned (void *p) +{ + if (((__SIZE_TYPE__) p & 0xf) != 0) + abort (); +} + +void gap (void *) __attribute__ ((noinline)); + +void gap (void *p) +{ + align16 a; + check_aligned (&a); +} + +int +main (int argc, char **argv) +{ + s *space; + gobats(0, 16); + space = (s *) alloca(sizeof(s) + 1); + *space = (s){0, 16}; + gap(space); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85412.c b/SingleSource/Regression/C/gcc-dg/pr85412.c new file mode 100644 index 0000000000..11b8ceccd1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85412.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-O1 -fpeephole2 -fschedule-insns2 -fsel-sched-pipelining -fselective-scheduling2 -ftree-loop-if-convert -fno-if-conversion -fno-move-loop-invariants -fno-split-wide-types -fno-tree-dominator-opts" } */ +/* { dg-additional-options "-march=bonnell" { target x86_64-*-* } } */ + +__int128 jv; + +void +zm (__int128 g9, unsigned short int sm, short int hk) +{ + while (hk < 1) + { + if (jv == 0) + sm *= g9; + + if (sm < jv) + hk = sm; + + g9 |= sm == hk; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85414.c b/SingleSource/Regression/C/gcc-dg/pr85414.c new file mode 100644 index 0000000000..d061324924 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85414.c @@ -0,0 +1,10 @@ +/* PR middle-end/85414 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Og -fgcse -Wno-uninitialized" } */ + +int +foo (void) +{ + unsigned __int128 c; + return __builtin_mul_overflow_p (59, -c, (short) 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85423.c b/SingleSource/Regression/C/gcc-dg/pr85423.c new file mode 100644 index 0000000000..2650d86f35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85423.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fselective-scheduling2 -fvar-tracking-assignments -fno-guess-branch-probability -fno-peephole2 -fno-ssa-phiopt -fno-tree-pre --param max-jump-thread-duplication-stmts=8 -w" } */ +/* { dg-additional-options "-march=nano" { target i?86-*-* x86_64-*-* } } */ + +int vn, xm; + +void +i1 (int); + +void +mb (int *ap, int ev) +{ + while (vn < 1) + { + i1 (vn); + + ev += *ap && ++vn; + + while (xm < 1) + ++xm; + + if (*ap == 0) + *ap = ev; + + ++vn; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85430.c b/SingleSource/Regression/C/gcc-dg/pr85430.c new file mode 100644 index 0000000000..7b58a3cd56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85430.c @@ -0,0 +1,12 @@ +/* PR target/85430 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-ccp -fno-tree-fre" } */ + +typedef char V __attribute__((vector_size (4))); + +V +foo (V v) +{ + v[(V){}[0]] <<= 1; + return v; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85455.c b/SingleSource/Regression/C/gcc-dg/pr85455.c new file mode 100644 index 0000000000..2028566333 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85455.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fthread-jumps -fno-tree-dominator-opts -fno-tree-reassoc -fno-tree-sink -fno-tree-slsr" } */ + +void +ty (void); + +void +um (void); + +void +au (int qj) +{ + if (qj < 1) + { +vq: + ty (); + } + + um (); + + goto vq; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85467.c b/SingleSource/Regression/C/gcc-dg/pr85467.c new file mode 100644 index 0000000000..fad94fcd83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85467.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/85467 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-ccp" } */ + +#define TEST(N, T) \ +typedef T V##N __attribute__ ((__vector_size__ (sizeof (T)))); \ + \ +V##N \ +bar##N (V##N u, V##N v) \ +{ \ + do \ + v *= (T)((V##N){}[0] ? u[v[0]] : 0); \ + while ((V##N){}[0]); \ + return v; \ +} \ + \ +void \ +foo##N (void) \ +{ \ + bar##N ((V##N){}, (V##N){}); \ +} + +TEST (1, char) +TEST (2, short) +TEST (3, int) +TEST (4, long) +TEST (5, long long) +#ifdef __SIZEOF_INT128__ +TEST (6, __int128) +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr85512.c b/SingleSource/Regression/C/gcc-dg/pr85512.c new file mode 100644 index 0000000000..788ff87f50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85512.c @@ -0,0 +1,48 @@ +/* { dg-do assemble } */ +/* { dg-options "-O -fno-if-conversion" } */ +/* { dg-require-effective-target int32 } */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +u64 +bar0(u8 u8_0, u16 u16_0, u32 u32_0, u64 u64_0, u8 u8_1, u16 u16_1, u32 u32_1, u64 u64_1, u8 u8_2, u16 u16_2, u32 u32_2, u64 u64_2, u8 u8_3, u16 u16_3, u32 u32_3, u64 u64_3); +u64 +bar1(u8 u8_0, u16 u16_0, u32 u32_0, u64 u64_0, u8 u8_1, u16 u16_1, u32 u32_1, u64 u64_1, u8 u8_2, u16 u16_2, u32 u32_2, u64 u64_2, u8 u8_3, u16 u16_3, u32 u32_3, u64 u64_3); +u64 +bar2(u8 u8_0, u16 u16_0, u32 u32_0, u64 u64_0, u8 u8_1, u16 u16_1, u32 u32_1, u64 u64_1, u8 u8_2, u16 u16_2, u32 u32_2, u64 u64_2, u8 u8_3, u16 u16_3, u32 u32_3, u64 u64_3); +u64 +bar0(u8 u8_0, u16 u16_0, u32 u32_0, u64 u64_0, u8 u8_1, u16 u16_1, u32 u32_1, u64 u64_1, u8 u8_2, u16 u16_2, u32 u32_2, u64 u64_2, u8 u8_3, u16 u16_3, u32 u32_3, u64 u64_3) +{ +l0: u32_2 += __builtin_add_overflow_p((u32)(u64)u32_0, (u16)-(u32)u64_2, (u64)-(u64)(unsigned)__builtin_parityll((u16)(u16)(((u64)0x1a6cb5b10 << 0)))); + u8_3 <<= __builtin_add_overflow((u16)~(u32)u64_2, (u16)(u8)(unsigned)__builtin_popcountll((u16)-(u8)(((u64)0x725582 << 0))), &u32_1); + u64_1 -= (u8)~(u8)(0); + u16_3 = (u16_3 >> ((u32)~(u8)(1) & 15)) | (u16_3 << ((16 - ((u32)~(u8)(1) & 15)) & 15)); + u8_2 = __builtin_mul_overflow((u64)(u8)__builtin_bswap32((u32)-(u32)u16_0), (u64)(u16)u16_2, &u8_3) ? (u64)~(u8)u8_3 : (u16)(u16)(((u64)0x7ffffff << 0)); + u32_0 *= (u8)(u8)(((u64)0x1ffffffffffffff << 0)); + u32_1 >>= (u64)~(u64)(((u64)0x61bf860d09fb3a << 0)) >= (u8)(u16)(unsigned)__builtin_parityll((u16)(u8)(((u64)0x6 << 0))); + u16_0 >>= __builtin_add_overflow_p((u64)-(u8)(((u64)0x68b4dda55e3 << 0)), (u16)(u64)__builtin_bswap64((u16)~(u32)__builtin_bswap32((u32)(u32)u8_3)), (u64)(u16)u16_1); + u64_0 += (u8)-(u64)(((u64)0xcc88a5c0292b6ba0 << 0)); + u32_0 += __builtin_mul_overflow((u8)-(u64)(((u64)0xc89172ea72a << 0)), (u64)(u64)u8_2, &u8_3); + u64_0 >>= __builtin_add_overflow((u32)-(u64)(0), (u32)-(u16)u8_1, &u8_2); + u16_1 >>= (u32)(u64)u16_1 & 15; + u16_3 ^= (u16)~(u16)(1); + u32_2 &= (u16)-(u32)(0); +l1: u32_3 = (u32_3 >> ((u64)(u32)u32_1 & 31)) | (u32_3 << ((32 - ((u64)(u32)u32_1 & 31)) & 31)); + u64_1 |= (u64)~(u64)(unsigned)__builtin_parityll((u8)-(u32)u32_1); + u8_3 *= __builtin_add_overflow((u64)-(u32)(((u64)0xffff << 0)), (u32)~(u64)(((u64)0x117e3e << 0)), &u32_2); + u16_3 = (u16_3 << ((u64)~(u8)(((u64)0xf78e81 << 0)) & 15)) | (u16_3 >> ((16 - ((u64)~(u8)(((u64)0xf78e81 << 0)) & 15)) & 15)); + u64_1 = (u64)(u16)bar1((u8)((u32)(u64)(((u64)0x3ffffff << 0))), (u16)((u8)(u16)(((u64)0x5b << 0))), (u32)((u32)~(u8)(1)), (u64)((u8)(u16)(unsigned)__builtin_clrsb((u32)~(u32)(unsigned)__builtin_clrsbll((u8)(u16)(((u64)0xffffffff << 0))))), (u8)((u8)-(u64)(((u64)0x3e43180756484 << 0))), (u16)((u8)(u16)(((u64)0x7 << 0))), (u32)((u64)(u32)(((u64)0x285fa35c89 << 0))), (u64)((u32)(u8)(((u64)0x3ffff << 0))), (u8)((u16)-(u32)(((u64)0x73d01 << 0))), (u16)((u16)-(u16)(((u64)0x1fffffffffffff << 0))), (u32)((u16)(u64)(0)), (u64)((u16)(u32)(((u64)0x4c << 0))), (u8)((u64)-(u64)(((u64)0x3fffffffffffff << 0))), (u16)((u16)~(u16)(((u64)0xfffffffff << 0))), (u32)((u64)(u16)(((u64)0x7edb0cc1c << 0))), (u64)((u32)(u64)(((u64)0x1ffffffffff << 0)))) > (u16)-(u64)(((u64)0x7 << 0)) ? (u16)(u8)u64_2 : (u64)(u16)u32_2; + u32_0 >>= (u8)(u16)(((u64)0x32 << 0)) != (u16)-(u64)u16_3; + u16_1 *= __builtin_mul_overflow_p((u64)(u32)u32_1, (u16)(u8)(((u64)0x4ad149d89bf0be6 << 0)), (u64)(u32)(((u64)0x1bd7589 << 0))); + u8_1 &= (u64)-(u64)u8_0; + u16_3 %= (u16)(u16)(unsigned)__builtin_clrsbll((u32)~(u32)(((u64)0x3db8721fd79 << 0))); + u8_3 >>= (u32)(u8)u8_1 & 7; + u64_1 |= (u8)-(u64)(unsigned)__builtin_ffsll((u32)-(u64)bar2((u8)((u16)(u16)(((u64)0x3 << 0))), (u16)((u32)-(u8)(((u64)0x86af5 << 0))), (u32)((u16)-(u64)__builtin_bswap64((u64)-(u64)(0))), (u64)((u16)(u16)(((u64)0x75138426ec84c6 << 0))), (u8)((u64)(u32)(((u64)0x7fffffffff << 0))), (u16)((u32)~(u8)(((u64)0x71aa939dbdf3 << 0))), (u32)((u16)(u32)(((u64)0x8776ee7dbb651a2d << 0))), (u64)((u8)(u64)(0)), (u8)((u16)(u8)(unsigned)__builtin_clrsbll((u16)~(u32)(((u64)0x8df94655ec8430 << 0)))), (u16)((u16)-(u64)(unsigned)__builtin_clrsbll((u32)(u64)(((u64)0x3090a532 << 0)))), (u32)((u16)~(u16)(1)), (u64)((u8)(u32)(((u64)0x7fffffffffff << 0))), (u8)((u32)~(u64)(0)), (u16)((u8)~(u8)(unsigned)__builtin_ffs((u64)(u64)(0))), (u32)((u16)-(u8)(((u64)0x5dfe702 << 0))), (u64)((u8)(u64)(((u64)0x68f2a584e0 << 0))))); + u32_3 >>= (u32)-(u32)u32_2 & 31; + u8_3 = (u8_3 >> ((u32)-(u8)u8_1 & 7)) | (u8_3 << ((8 - ((u32)-(u8)u8_1 & 7)) & 7)); + u8_2 >>= (u16)-(u64)u64_3 & 7; + u32_1 = (u32_1 >> ((u16)(u16)(1) & 31)) | (u32_1 << ((32 - ((u16)(u16)(1) & 31)) & 31)); + return u8_0 + u16_0 + u32_0 + u64_0 + u8_1 + u16_1 + u32_1 + u64_1 + u8_2 + u16_2 + u32_2 + u64_2 + u8_3 + u16_3 + u32_3 + u64_3; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85529.c b/SingleSource/Regression/C/gcc-dg/pr85529.c new file mode 100644 index 0000000000..0b73228474 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85529.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/85529 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-ssa-phiopt" } */ + +__attribute__((noinline, noclone)) int +foo (int x) +{ + x &= 31; + x -= 25; + x *= 2; + if (x < 0) + return 1; + int y = x >> 2; + if (x >= y) + return 1; + return 0; +} + +int +main () +{ + int i; + for (i = 0; i < 63; i++) + if (foo (i) != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85598.c b/SingleSource/Regression/C/gcc-dg/pr85598.c new file mode 100644 index 0000000000..c84b63f808 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85598.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; +extern void __chk_fail (void); +extern int snprintf (char *, size_t, const char *, ...); + +int main() +{ + char temp[100]; + unsigned int x; + char *str = temp; + for(x=0; x<256; ++x) { + snprintf(str, 4, "%%%02X", x); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85799.c b/SingleSource/Regression/C/gcc-dg/pr85799.c new file mode 100644 index 0000000000..0e937857e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85799.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +void unlikely(); +void likely(); + +inline int expect_false(int b) { + return __builtin_expect(b, 0); +} + +void inline_func_hint(int b) { + if (expect_false(b)) { + unlikely(); + } else { + likely(); + } +} + +/* { dg-final { scan-tree-dump "_builtin_expect heuristics of edge" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr85811.c b/SingleSource/Regression/C/gcc-dg/pr85811.c new file mode 100644 index 0000000000..868f66c32a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85811.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +#include + +int main() { + const double negval = -1.0; + const double nanval = 0.0 / 0.0; + const double val = __builtin_fmax(negval, nanval); + const double absval = __builtin_fabs(val); + printf("fabs(%.16e) = %.16e\n", val, absval); + return absval >= 0 ? 0 : 1; +} + +/* We hope not to see: printf ("fabs(%.16e) = %.16e\n", val_4, val_4); */ +/* { dg-final { scan-tree-dump-not "val_\[0-9\]*, val_\[0-9\]*" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr85859.c b/SingleSource/Regression/C/gcc-dg/pr85859.c new file mode 100644 index 0000000000..7a57a09682 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85859.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-tail-merge -Wno-div-by-zero -O2 -fno-dce -fno-isolate-erroneous-paths-dereference -fno-tree-dce -fno-tree-vrp" } */ +/* { dg-require-effective-target ptr_eq_long } */ + +int b, c, d, e; + +__attribute__ ((noinline, noclone)) +int foo (short f) +{ + f %= 0; + return f; +} + +int +main (void) +{ + b = (unsigned char) __builtin_parity (d); + e ? foo (0) : (__INTPTR_TYPE__) &c; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85876.c b/SingleSource/Regression/C/gcc-dg/pr85876.c new file mode 100644 index 0000000000..64618e5258 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85876.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fschedule-insns -fsel-sched-pipelining -fselective-scheduling -fno-if-conversion -fno-tree-dce" } */ +/* { dg-additional-options "-march=bdver1" { target i?86-*-* x86_64-*-* } } */ + +int ov, rq, ac; + +int +y2 (int); + +void +f8 (int vn) +{ + while (rq < 1) + { + ov *= y2 (ac); + vn += (!!ov && !!ac) + ac; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85899.c b/SingleSource/Regression/C/gcc-dg/pr85899.c new file mode 100644 index 0000000000..eb2b175339 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85899.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fschedule-insns -fselective-scheduling -funroll-loops -fno-gcse -fno-if-conversion -fno-ivopts" } */ + +#define N 4096 +int cb[N]; +int cc[N]; +int cd[N]; + +void init () +{ + int i; + for (i = 0; i < N; ++i) { + cb[i] = 3 * i - 2048; + cc[i] = -5 * i + 93; + cd[i] = i % 2 ? 1 : -1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr85955.c b/SingleSource/Regression/C/gcc-dg/pr85955.c new file mode 100644 index 0000000000..7f67f62dce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr85955.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +extern void sincos(double x, double *sinx, double *cosx); +void apply(void (*f)(double, double *, double *), + double x, double *sinx, double *cosx) +{ + f(x, sinx, cosx); + return; +} +void apply_sincos(double x, double **sinx, double **cosx) +{ + apply(sincos, x, sinx, cosx); + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86010-2.c b/SingleSource/Regression/C/gcc-dg/pr86010-2.c new file mode 100644 index 0000000000..4c82e65aeb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86010-2.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void f (void*); + +void g (char *a) +{ + __builtin_memset (a, 0, 8); + __builtin_memset (a, 0, 8); + + f (a); +} + +void h (char *a) +{ + __builtin_memset (a, 0, 8); + __builtin_memset (a, 0, 7); + + f (a); +} + +/* { dg-final { scan-tree-dump-times "__builtin_memset" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr86010.c b/SingleSource/Regression/C/gcc-dg/pr86010.c new file mode 100644 index 0000000000..ac27989326 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86010.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void f (void*); + +void g (void) +{ + char a[8]; + __builtin_memset (a, 0, 8); + __builtin_memset (a, 0, 8); + + f (a); +} + +void h (void) +{ + char a[8]; + __builtin_memset (a, 0, 8); + __builtin_memset (a, 0, 7); + + f (a); +} + +/* { dg-final { scan-tree-dump-times "__builtin_memset" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr86038.c b/SingleSource/Regression/C/gcc-dg/pr86038.c new file mode 100644 index 0000000000..427a13f18c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86038.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target pthread } */ +/* { dg-options "-O2 -ftracer -ftree-parallelize-loops=2 -fno-tree-scev-cprop --param parloops-schedule=dynamic" } */ + +int +sd (int lw) +{ + while (lw < 1) + ++lw; + + return lw; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86046.c b/SingleSource/Regression/C/gcc-dg/pr86046.c new file mode 100644 index 0000000000..6d4c948cf8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86046.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef int V __attribute__ ((vector_size(4))); +void fn1 () +{ + (V){(1,0)}[1] = 0; // out-of-bound access +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86047.c b/SingleSource/Regression/C/gcc-dg/pr86047.c new file mode 100644 index 0000000000..6192d2d4a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86047.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern void f (int, int); +void g (int a, int b) +{ + int i, j; + for (i = a; i <= b; ++i) + __builtin_memcpy (g, f, 6); + for (j = a; j <= b; ++j) + f(j, i); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr86058.c b/SingleSource/Regression/C/gcc-dg/pr86058.c new file mode 100644 index 0000000000..89628c9719 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86058.c @@ -0,0 +1,19 @@ +/* PR middle-end/86058 - TARGET_MEM_REF causing incorrect message for + -Wmaybe-uninitialized warning + The test fails on a number of non-x86 targets due to pr100073. + { dg-do compile { target i?86-*-* x86_64-*-* } } + { dg-options "-O2 -Wuninitialized -Wmaybe-uninitialized" } */ + +extern void foo (int *); + +void zip (int *out, int indx) +{ + int arr[10]; + + for (int i = 0; i < indx; ++i) + out[i] = arr[i] + 1; // { dg-warning "'arr\\\[i]' may be used uninitialized" "pr99944" { xfail *-*-* } } + // { dg-warning "'arr' may be used uninitialized" "actual" { target *-*-* } .-1 } + + foo (arr); + foo (out); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86064.c b/SingleSource/Regression/C/gcc-dg/pr86064.c new file mode 100644 index 0000000000..3397427256 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86064.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-skip-if "split DWARF unsupported" { *-*-darwin* } } */ +/* { dg-options "-g -O2 -fno-var-tracking-assignments -gsplit-dwarf" } */ + +/* This used to fail with location views (implicitly) enabled, because + var-tracking (not at assignments) creates a range for d starting at + the load after the first call, and we did not split the range, + despite its crossing between hot and cold partitions, because it's + a single range, that we normally extend to the entire function. + However, because the range starts at a (presumed) nonzero view, we + end up outputting a loclist instead of a single location entry. + But then, -gsplit-dwarf selects (startx,length) loclist entries, + and the length ends up computing the difference between symbols in + different subsections. */ + +int a; +__attribute__((__cold__)) void b(); + +void e(int *); +int f(); + +void c() { + int d; + e(&d); + a = d; + if (f()) + b(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86076.c b/SingleSource/Regression/C/gcc-dg/pr86076.c new file mode 100644 index 0000000000..390ca47ba1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86076.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target pthread } } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fno-tree-dce -fno-tree-pre -fno-tree-vrp --param max-loop-header-insns=1" } */ + +int __attribute__ ((noinline)) +lv (int tm) +{ + (void) tm; + + return 0; +} + +void +o7 (int uu) +{ + while (uu < 1) + while (uu != 0) + { + short int ca; + + ca = lv (0); + (void) ca; + ++uu; + } + + lv (lv (0)); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86114.c b/SingleSource/Regression/C/gcc-dg/pr86114.c new file mode 100644 index 0000000000..f829f0039d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86114.c @@ -0,0 +1,42 @@ +/* PR tree-optimization/86114 - ICE in gimple_fold_builtin_strlen with + an invalid call to strnlen + { dg-do compile } + { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; + +extern char* strcmp (const char*, const char*); +extern char* strncmp (const char*, const char*, size_t); +extern char* strlen (const char*); +extern char* strnlen (const char*, size_t); +extern char* strcspn (const char*, const char*); +extern char* strspn (const char*, const char*); +extern char* strxfrm (const char*, const char*, size_t); + +char** q; + +void test_array (const char *s) +{ + extern char a[8]; + + q[0] = strcmp (a, s); + q[1] = strncmp (a, s, 7); + q[2] = strlen (a); + q[3] = strnlen (a, 7); + q[4] = strcspn (a, s); + q[5] = strspn (a, s); + q[6] = strxfrm (a, s, 7); +} + +void test_pointer (const char *s, const char *t) +{ + q[0] = strcmp (s, t); + q[1] = strncmp (s, t, 7); + q[2] = strlen (s); + q[3] = strnlen (s, 7); + q[4] = strcspn (s, t); + q[5] = strspn (s, t); + q[6] = strxfrm (s, s, 7); +} + +/* { dg-prune-output "-Wbuiltin-declaration-mismatch" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr86124.c b/SingleSource/Regression/C/gcc-dg/pr86124.c new file mode 100644 index 0000000000..c8a66ffbfb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86124.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fipa-pta" } */ +/* { dg-skip-if "acessing data memory with program memory address" { "avr-*-*" } } */ + +extern void a (void); + +void b (void) +{ + void *c; + c = a; + *(char *)c = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86134.c b/SingleSource/Regression/C/gcc-dg/pr86134.c new file mode 100644 index 0000000000..3fd21a3230 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86134.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -Werror -Wno-error=main -Wno-foobar" } */ + +void main() {} /* { dg-warning "return type" } */ + +/* { dg-message "unrecognized command-line option" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr86179.c b/SingleSource/Regression/C/gcc-dg/pr86179.c new file mode 100644 index 0000000000..f3dd3675c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86179.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +typedef int int32_t __attribute__((mode (__SI__))); +typedef unsigned uint32_t __attribute__((mode (__SI__))); + +void c(int32_t *d, char *g) +{ + char *a, *b, *e; + int f; + for (; f; f -= 8) { + *d++ = *e++ | (uint32_t)*g++ << 8 | (uint32_t)*b++ << 16 | + (uint32_t)*a++ << 24; + *d++ = *e++ | (uint32_t)*g++ << 8 | (uint32_t)*b++ << 16 | + (uint32_t)*a++ << 24; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86271.c b/SingleSource/Regression/C/gcc-dg/pr86271.c new file mode 100644 index 0000000000..1200533d4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86271.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int main () +{ + int i; + foobar (i, &i); /* { dg-warning "implicit declaration" } */ +} + +int foobar (int a, long long b) +{ + int c; + + c = a % b; + a = a / b; + return a + b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86314.c b/SingleSource/Regression/C/gcc-dg/pr86314.c new file mode 100644 index 0000000000..565fb02eee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86314.c @@ -0,0 +1,20 @@ +// PR target/86314 +// { dg-do run { target sync_int_long_stack } } +// { dg-options "-O2" } + +__attribute__((noinline, noclone)) unsigned long +foo (unsigned long *p) +{ + unsigned long m = 1UL << ((*p & 1) ? 1 : 0); + unsigned long n = __atomic_fetch_or (p, m, __ATOMIC_SEQ_CST); + return (n & m) == 0; +} + +int +main () +{ + unsigned long v = 1; + if (foo (&v) != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86459.c b/SingleSource/Regression/C/gcc-dg/pr86459.c new file mode 100644 index 0000000000..7856a372dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86459.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -fno-var-tracking-assignments -gsplit-dwarf -g3" } */ + +/* Same as pr86064.c but compiled with -g3 it showed an issue in + output_macinfo_op because of a typo in an assert. */ + +int a; +__attribute__((__cold__)) void b(); + +void e(int *); +int f(); + +void c() { + int d; + e(&d); + a = d; + if (f()) + b(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86489.c b/SingleSource/Regression/C/gcc-dg/pr86489.c new file mode 100644 index 0000000000..c7e5573ebc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86489.c @@ -0,0 +1,12 @@ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a = 0, b = 0; +void fn1() { + int c = 0; + for (; a; a--) + c += b; + while ((c - 1) & c) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86572.c b/SingleSource/Regression/C/gcc-dg/pr86572.c new file mode 100644 index 0000000000..6cda55bae2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86572.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +const char buf[40] = "test"; +void test (int x) +{ + if (__builtin_strlen (buf + x) > 4) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr86617.c b/SingleSource/Regression/C/gcc-dg/pr86617.c new file mode 100644 index 0000000000..72135e205b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86617.c @@ -0,0 +1,11 @@ +/* { dg-options "-Os -fdump-rtl-final" } */ + +volatile unsigned char u8; + +void test (void) +{ + u8 = u8 + u8; + u8 = u8 - u8; +} + +/* { dg-final { scan-rtl-dump-times "mem/v" 6 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr86723.c b/SingleSource/Regression/C/gcc-dg/pr86723.c new file mode 100644 index 0000000000..e3fd6b9d4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86723.c @@ -0,0 +1,63 @@ +/* PR tree-optimization/86723 */ +/* { dg-do run { target { ilp32 || lp64 } } } */ +/* { dg-options "-O2" } */ + +__attribute__((noipa)) int +foo (unsigned long long value) +{ + return (((value & 0x00000000000000ffull) << 56) + | ((value & 0x000000000000ff00ull) << 40) + | ((value & 0x0000000000ff0000ull) << 24) + | ((value & 0x00000000ff000000ull) << 8) + | ((value & 0x000000ff00000000ull) >> 8) + | ((value & 0x0000ff0000000000ull) >> 24) + | ((value & 0x00ff000000000000ull) >> 40) + | ((value & 0xff00000000000000ull) >> 56)); +} + +__attribute__((noipa)) int +bar (unsigned long long value) +{ + return (((value & 0x000000ff00000000ull) >> 8) + | ((value & 0x0000ff0000000000ull) >> 24) + | ((value & 0x00ff000000000000ull) >> 40) + | ((value & 0xff00000000000000ull) >> 56)); +} + +__attribute__((noipa)) unsigned long long +baz (unsigned long long value) +{ + return (((value & 0x00000000000000ffull) << 56) + | ((value & 0x000000000000ff00ull) << 40) + | ((value & 0x00000000ff000000ull) << 8) + | ((value & 0x000000ff00000000ull) >> 8) + | ((value & 0x0000ff0000000000ull) >> 24) + | ((value & 0xff00000000000000ull) >> 56)); +} + +__attribute__((noipa)) unsigned int +qux (unsigned int value) +{ + return (((value & 0x000000ff) << 24) + | ((value & 0x00ff0000) >> 8) + | ((value & 0xff000000) >> 24)); +} + +__attribute__((noipa)) unsigned int +corge (unsigned int value) +{ + return (((value & 0x000000ff) << 24) + | ((value & 0xff000000) >> 24)); +} + +int +main () +{ + if (foo (0x0102030405060708ull) != 0x04030201 + || bar (0x0102030405060708ull) != 0x04030201 + || baz (0x0102030405060708ull) != 0x0807000504030001ull + || qux (0x01020304) != 0x04000201 + || corge (0x01020304) != 0x04000001) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86835.c b/SingleSource/Regression/C/gcc-dg/pr86835.c new file mode 100644 index 0000000000..a0ebc7432a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86835.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/86835 */ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math -Wuninitialized" } */ + +__attribute__((noipa)) void +foo (int n, double *x, double *y) +{ /* { dg-bogus "is used uninitialized in this function" "" { target *-*-* } 0 } */ + int i; + double b = y[4]; + for (i = 0; i < n; ++i) + y[3] += __builtin_sin (x[i] / b); + y[0] /= b; + y[1] /= b * b; + y[2] /= b; +} + +int +main () +{ + double y[] = { 16.0, 64.0, 128.0, 0.0, 2.0 }; + foo (0, y, y); + if (__builtin_fabs (y[0] - 8.0) > 0.0001 + || __builtin_fabs (y[1] - 16.0) > 0.0001 + || __builtin_fabs (y[2] - 64.0) > 0.0001 + || y[3] != 0.0 + || y[4] != 2.0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86928.c b/SingleSource/Regression/C/gcc-dg/pr86928.c new file mode 100644 index 0000000000..46b7644836 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86928.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fnon-call-exceptions -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fselective-scheduling -fno-if-conversion -fno-tree-dce -w" } */ + +int kn; + +void +gd (short int sk) +{ + char *as; + + while (sk < 1) + { + char *ci; + + if (*ci == 0) + *as += ci; + + for (kn = 0; kn < 18; ++kn) + { + } + + ++sk; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr86979.c b/SingleSource/Regression/C/gcc-dg/pr86979.c new file mode 100644 index 0000000000..5c78d785a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86979.c @@ -0,0 +1,5 @@ +/* { dg-options "-Og -fPIC -fschedule-insns2 -fselective-scheduling2 -fno-tree-fre --param=max-sched-extend-regions-iters=2" } */ +/* { dg-require-effective-target scheduling } */ +/* { dg-require-effective-target fpic } */ + +#include "../gcc.c-torture/compile/pr69102.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr86991.c b/SingleSource/Regression/C/gcc-dg/pr86991.c new file mode 100644 index 0000000000..5cd16e28c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr86991.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int b; +extern unsigned c[]; +unsigned d; +long e; + +void f() +{ + unsigned g, h; + for (; d; d += 2) { + g = 1; + for (; g; g += 3) { + h = 2; + for (; h < 6; h++) + c[h] = c[h] - b - ~e; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87009.c b/SingleSource/Regression/C/gcc-dg/pr87009.c new file mode 100644 index 0000000000..6f0341d17c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87009.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ +/* { dg-final { scan-tree-dump-times "return s \\^ x;|return x \\^ s;" 4 "original" } } */ + +int f1 (int x, int s) +{ + return ~(~(x|s)|x)|~(~(x|s)|s); +} + +int f2 (int x, int s) +{ + return ~(~(~x&s)&~(x&~s)); +} + +int f3 (int x, int s) +{ + return ~((x|~s)&(~x|s)); +} + +int f4 (int x, int s) +{ + return (x|~s)^(~x|s); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87024.c b/SingleSource/Regression/C/gcc-dg/pr87024.c new file mode 100644 index 0000000000..a8a58aafc2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87024.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-dce" } */ + +static inline void __attribute__((always_inline)) +mp () +{ + (void) __builtin_va_arg_pack_len (); +} + +void +ui (void) +{ + mp (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87025.c b/SingleSource/Regression/C/gcc-dg/pr87025.c new file mode 100644 index 0000000000..059313ccda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87025.c @@ -0,0 +1,22 @@ +/* Ensure we don't ICE when tracking optimization record scopes within + the vectorizer. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fsave-optimization-record -ftree-vectorize -fno-tree-scev-cprop -fno-tree-sink" } */ + +void +fk (unsigned int sf) +{ + for (;;) + { + if (sf != 0) + { + while (sf != 0) + ++sf; + + while (sf < 8) + ++sf; + } + + ++sf; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87047.c b/SingleSource/Regression/C/gcc-dg/pr87047.c new file mode 100644 index 0000000000..cb26ea4dea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87047.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } */ +/* { dg-options "-fdump-rtl-ce1 -O2" } */ + +typedef unsigned long long uint64_t; + +static uint64_t umulh(uint64_t a, uint64_t b) +{ + return (unsigned __int128)a*b >> 64; +} + +uint64_t f(uint64_t a, uint64_t b, int c) +{ + if (c) + a = umulh(a, (b-umulh(a,b))<<44) << 1; + return a; +} + +/* { dg-final { scan-rtl-dump "0 true changes made" "ce1" } } */ +/* { dg-final { scan-assembler-not "cmov" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr87052.c b/SingleSource/Regression/C/gcc-dg/pr87052.c new file mode 100644 index 0000000000..796fe6440c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87052.c @@ -0,0 +1,41 @@ +/* PR middle-end/87052 - STRING_CST printing incomplete in Gimple dumps + { dg-do compile } + { dg-options "-fdump-tree-gimple" } */ + +void sink (const void*, ...); + +void test (void) +{ + const char a[3] = "\000ab"; + + /* Expect the following in the dump: + a = "\x00ab"; */ + + const char b[] = { 'a', 0, 'b', 'c' }; + + /* Expect the following: + b = "a\x00bc"; */ + + const char c[] = ""; + + /* Expect the following: + c = ""; */ + + const char d[0] = { }; + + /* Expect nothing. */ + + const char e[0] = ""; + + /* Expect nothing. */ + + sink (a, b, c, d, e); +} + +/* { dg-final { scan-tree-dump-times "a = \"\\\\x00ab\";" 1 "gimple" } } + { dg-final { scan-tree-dump-times "b = \"a\\\\x00bc\";" 1 "gimple" } } + { dg-final { scan-tree-dump-times "c = \"\";" 1 "gimple" } } + { dg-final { scan-tree-dump-times "d = " 1 "gimple" } } + { dg-final { scan-tree-dump-times "d = {CLOBBER\\(eol\\)}" 1 "gimple" } } + { dg-final { scan-tree-dump-times "e = " 1 "gimple" } } + { dg-final { scan-tree-dump-times "e = {CLOBBER\\(eol\\)}" 1 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr87054.c b/SingleSource/Regression/C/gcc-dg/pr87054.c new file mode 100644 index 0000000000..3cb3b7dac6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87054.c @@ -0,0 +1,29 @@ +// { dg-do run } +// { dg-options "-O2" } + +#ifndef T +# if __SIZEOF_INT128__ && defined __SSE__ +# define T __int128 +# else +# define T long +# endif +#endif +#ifndef R +# ifdef __SSE__ +# define R "x" +# else +# define R "r" +# endif +#endif + + +typedef T A; // #define T to long or __int128 +struct B { char d; A c; } __attribute__((packed)); +struct B b[50]; // many elements to avoid loop unrolling + +int main () { + int i; + for (i = 0; i < sizeof(b) / sizeof(*b); i++) { + asm ("" : "+" R (b[i].c)); // #define R to "r" on ppc or "x" on x86_64 + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87074.c b/SingleSource/Regression/C/gcc-dg/pr87074.c new file mode 100644 index 0000000000..d838fcd8fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87074.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -floop-unroll-and-jam --param unroll-jam-min-percent=0" } */ +long b; +unsigned c[5]; +unsigned long long d = 3; +int e, f, g; + +void h() { + for (; f < 11; f++) { + b = g; + for (e = 0; e < 5; e++) { + c[e] = e - b - (c[e] >> 5); + g = c[e]; + } + } + if (c[0]) + d = 0; +} + +extern void abort(void); +int main() { + h(); + if (d != 0) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87092.c b/SingleSource/Regression/C/gcc-dg/pr87092.c new file mode 100644 index 0000000000..4a6faebbd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87092.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fwrapv" } */ + +int a, b; + +void +c(void) { + if (b) + b = a / b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87099.c b/SingleSource/Regression/C/gcc-dg/pr87099.c new file mode 100644 index 0000000000..47e2315de0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87099.c @@ -0,0 +1,22 @@ +/* PR middle-end/87099 */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-Wstringop-overflow" } */ + +void bar (char *); + +int +foo (int n) +{ + char v[n]; + bar (v); + return __builtin_strncmp (&v[1], "aaa", 3); +} + +int +baz (int n, char *s) +{ + char v[n]; + bar (v); + return __builtin_strncmp (&v[1], s, 3); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87112.c b/SingleSource/Regression/C/gcc-dg/pr87112.c new file mode 100644 index 0000000000..7510956be4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87112.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/87112 - ICE due to strnlen mixing integer types + { dg-do compile } + { dg-options "-Os -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern size_t strnlen (const char*, size_t); + +size_t fi (int i) +{ + int n = i & 3; + return strnlen ("int", n); +} + +size_t fui (unsigned i) +{ + unsigned n = i & 3; + return strnlen ("unsigned", n); +} + +size_t fl (long i) +{ + long n = i & 3; + return strnlen ("long", n); +} + +size_t fsz (size_t i) +{ + size_t n = i & 3; + return strnlen ("size_t", n); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87117-1.c b/SingleSource/Regression/C/gcc-dg/pr87117-1.c new file mode 100644 index 0000000000..06d700871b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87117-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-inline -fno-tree-dce" } */ + +int a, b, c; +long *d; +void fn1() +{ + for (; 0 < a;) + a++; +} +void fn3() +{ + for (; c; c++) + d[c] = 0; +} +void fn2() +{ + if (b) + fn3(); + fn1(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87117-2.c b/SingleSource/Regression/C/gcc-dg/pr87117-2.c new file mode 100644 index 0000000000..aefa813918 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87117-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fcode-hoisting" } */ + +void e(); + +void a(int c, char **d) +{ + char b; + if (1 < c) + b = (char)(__INTPTR_TYPE__)d[0]; + if (1 < c && b) + e(); + while (1 < c) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr8715.c b/SingleSource/Regression/C/gcc-dg/pr8715.c new file mode 100644 index 0000000000..2878a48a4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr8715.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare -std=c99" } */ + +#include + +int foo() +{ + unsigned char b = '1'; + + bool x = ~b; /* { dg-warning "promoted bitwise complement of an unsigned value is always nonzero" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87259.c b/SingleSource/Regression/C/gcc-dg/pr87259.c new file mode 100644 index 0000000000..527a60a37a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87259.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +int a, b, c; +int *e; +float f; +void h() { + for (int g;;) { + float d = b, i = 0 / f, j = a / (f * f), k, l = 0 / d; + c = i + j; + g = l; + e[g] = c / d * k / d; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87261.c b/SingleSource/Regression/C/gcc-dg/pr87261.c new file mode 100644 index 0000000000..9b10d03454 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87261.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +int f1 (int a, int b) +{ + return ~(a|b)|(~a&b); +} + +int f2 (int a, int b) +{ + return (a|b)^(a|~b); +} + +/* { dg-final { scan-tree-dump-times "return \\~a;" 2 "original" } } */ + +int f3 (int a, int b) +{ + return ~(a|b)|(a&b); +} + +/* { dg-final { scan-tree-dump "return \\~\\(a \\^ b\\);" "original" } } */ + +int f4 (int a, int b) +{ + return a^b^(~a|b); +} + +/* { dg-final { scan-tree-dump "return \\~b \\| a;" "original" } } */ + +int f5 (int a, int b) +{ + return (a^b)|~(a|b); +} + +/* { dg-final { scan-tree-dump "return \\~\\(a \\& b\\);" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr87273.c b/SingleSource/Regression/C/gcc-dg/pr87273.c new file mode 100644 index 0000000000..43662f0241 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87273.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fschedule-insns -fsel-sched-pipelining -fselective-scheduling -fno-ssa-phiopt -fno-tree-loop-im" } */ +/* { dg-additional-options "-march=core2" { target i?86-*-* x86_64-*-* } } */ + +int sd; + +void +w5 (int n4) +{ + long int *vq = (long int *) &n4; + + while (n4 < 1) + { + int ks; + + ks = !!(n4 + 1) ? ((++sd) == *vq) : 0; + if (ks == 1 / *vq) + *vq *= sd; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87286.c b/SingleSource/Regression/C/gcc-dg/pr87286.c new file mode 100644 index 0000000000..155ace8021 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87286.c @@ -0,0 +1,4 @@ +/* { dg-options "-Wno-psabi" } */ +enum foo { F }; +typedef enum foo vec_foo __attribute__((vector_size (16))); +vec_foo add (vec_foo x, vec_foo y) { return x + y; } diff --git a/SingleSource/Regression/C/gcc-dg/pr87309.c b/SingleSource/Regression/C/gcc-dg/pr87309.c new file mode 100644 index 0000000000..8bd5a4464e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87309.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-fopt-info-vec-optimized -O3" } */ + +void a() {} /* { dg-bogus "note" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr87314-1.c b/SingleSource/Regression/C/gcc-dg/pr87314-1.c new file mode 100644 index 0000000000..0cb9c07e32 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87314-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +int f(){ int a; return &a==(void *)"hello"; } +int g(){ return "bye"=="hello"; } +int h() { return "bye"=="helloooobye"+8; } + +/* { dg-final { scan-tree-dump-times "hello" 1 "original" } } */ +/* The test in h() should be retained because the result depends on + string merging. */ +/* { dg-final { scan-assembler "hellooo" { target { ! nvptx*-*-* } } } } */ +/* { dg-final { scan-assembler "104, 101, 108, 108, 111, 111, 111" { target { nvptx*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr87320.c b/SingleSource/Regression/C/gcc-dg/pr87320.c new file mode 100644 index 0000000000..b92ba89e42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87320.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/87320 */ +/* { dg-do run } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +static void __attribute__ ((noinline)) +transpose_vector (unsigned long n) +{ + unsigned long data[2 * n]; + for (unsigned long i = 0; i < 2 * n; i++) + data[i] = 4 * i + 2; + + unsigned long transposed[n]; + for (unsigned long i = 0; i < n; i++) + transposed[i] = data[2 * i]; + + for (unsigned long i = 0; i < n; i++) + if (transposed[i] != 8 * i + 2) + __builtin_abort (); +} + +int +main () +{ + transpose_vector (4); + transpose_vector (120); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87347.c b/SingleSource/Regression/C/gcc-dg/pr87347.c new file mode 100644 index 0000000000..2077964e9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87347.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wabsolute-value" } */ + +int a; +int abs(); +void b() { abs(a); } diff --git a/SingleSource/Regression/C/gcc-dg/pr87415.c b/SingleSource/Regression/C/gcc-dg/pr87415.c new file mode 100644 index 0000000000..473384ac47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87415.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +struct A +{ + int b:1; +}; + +int d; + +int main () +{ + struct A e = { 0 }; + if (!d) + e.b = -1; + if (!e.b) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87483.c b/SingleSource/Regression/C/gcc-dg/pr87483.c new file mode 100644 index 0000000000..d3af8dfee5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87483.c @@ -0,0 +1,16 @@ +/* PR c/87483 */ +/* { dg-require-alias "" } */ + +int f (void) { return 0; } +__attribute__ ((alias ("f"))) int g () { return 1; } /* { dg-warning "attribute ignored because function is defined" } */ +__attribute__ ((alias ("f"))) int g2 (); + +int h (void) +{ + return g2 (); +} + +int main() +{ + return h(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87485.c b/SingleSource/Regression/C/gcc-dg/pr87485.c new file mode 100644 index 0000000000..17d1c24c4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87485.c @@ -0,0 +1,30 @@ +/* PR rtl-optimization/87485 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fschedule-insns -fno-guess-branch-probability -fno-isolate-erroneous-paths-dereference -fno-omit-frame-pointer -fno-split-wide-types -fno-tree-ccp -fno-tree-sra" } */ +/* { dg-additional-options "-fstack-protector-strong" { target fstack_protector } } */ +/* { dg-require-effective-target scheduling } */ + +int *a; + +int +foo (__int128 x, int y, int z) +{ + __int128 b; + *a = ((!!y ? y : x) * y | x) * 2; + if (z == 0) + { + unsigned int c = 1; + __int128 *d = &b; + for (*a = 0; *a < 1; *a += y) + ; + *a += b < (c / 0); /* { dg-warning "division by zero" } */ + goto l; + m: + while (b < 1) + ; + ++*a; + } + goto m; + l: + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87490.c b/SingleSource/Regression/C/gcc-dg/pr87490.c new file mode 100644 index 0000000000..61c36e3a69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87490.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/87490 - ICE in expand_builtin_strnlen with a constant + argument and non-constant bound + { dg-do compile } + { dg-options "-O1 -Wall -fno-optimize-strlen" } */ + +void test_O1 (int i) +{ + int n = (i & 3) | 1; + + /* The ICE here triggers at -O1, with tree-ssa-strlen disabled. */ + if (__builtin_strnlen ("", n) != 0) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87600-1.c b/SingleSource/Regression/C/gcc-dg/pr87600-1.c new file mode 100644 index 0000000000..e721cd6e53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87600-1.c @@ -0,0 +1,60 @@ +/* PR rtl-optimization/87600 */ +/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* powerpc*-*-* s390*-*-* x86_64-*-* } } */ +/* { dg-options "-O2" } */ + +#include "pr87600.h" + +/* The following are all valid uses of local register variables. */ + +long +test0 (long arg) +{ + register long var asm (REG1); + asm (ASM0 " %0, %1" : "+&r" (var) : "r" (arg)); + return var; +} + +long +test1 (long arg0, long arg1) +{ + register long var asm (REG1); + asm (ASM1 +#if defined (__i386__) + " %0, 0(%1,%2)" +#elif defined (__s390__) + " %0, %1, 0(%2)" +#else + " %0, 0(%1,%2)" +#endif + : "=&r" (var) : "r" (arg0), "0" (arg1)); + return var + arg1; +} + +long +test2 (void) +{ + register long var1 asm (REG1); + register long var2 asm (REG1); + asm (ASM0 " %0, %1" : "=&r" (var1) : "0" (var2)); + return var1; +} + +long +test3 (void) +{ + register long var1 asm (REG1); + register long var2 asm (REG2); + long var3; + asm (ASM0 " %0, %1" : "=&r" (var1), "=r" (var3) : "1" (var2)); + return var1 + var3; +} + +long +test4 (void) +{ + register long var1 asm (REG1); + register long var2 asm (REG2); + register long var3 asm (REG2); + asm (ASM0 " %0, %1" : "=&r" (var1), "=r" (var2) : "1" (var3)); + return var1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87600-2.c b/SingleSource/Regression/C/gcc-dg/pr87600-2.c new file mode 100644 index 0000000000..e8a9f194b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87600-2.c @@ -0,0 +1,44 @@ +/* PR rtl-optimization/87600 */ +/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* powerpc*-*-* s390*-*-* x86_64-*-* } } */ +/* { dg-options "-O2" } */ + +#include "pr87600.h" + +/* The following are all invalid uses of local register variables. */ + +long +test0 (void) +{ + register long var1 asm (REG1); + register long var2 asm (REG1); + asm ("blah %0 %1" : "=r" (var1), "=r" (var2)); /* { dg-error "invalid hard register usage between output operands" } */ + return var1; +} + +long +test1 (void) +{ + register long var1 asm (REG1); + register long var2 asm (REG2); + asm ("blah %0 %1" : "=r" (var1) : "0" (var2)); /* { dg-error "invalid hard register usage between output operand and matching constraint operand" } */ + return var1; +} + +long +test2 (void) +{ + register long var1 asm (REG1); + register long var2 asm (REG1); + asm ("blah %0 %1" : "=&r" (var1) : "r" (var2)); /* { dg-error "invalid hard register usage between earlyclobber operand and input operand" } */ + return var1; +} + +long +test3 (void) +{ + register long var1 asm (REG1); + register long var2 asm (REG1); + long var3; + asm ("blah %0 %1" : "=&r" (var1), "=r" (var3) : "1" (var2)); /* { dg-error "invalid hard register usage between earlyclobber operand and input operand" } */ + return var1 + var3; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87600.h b/SingleSource/Regression/C/gcc-dg/pr87600.h new file mode 100644 index 0000000000..5b1e2c5e84 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87600.h @@ -0,0 +1,31 @@ +#if defined (__aarch64__) +# define REG1 "x0" +# define REG2 "x1" +# define ASM0 "mov" +# define ASM1 "add" +#elif defined (__arm__) +# define REG1 "r0" +# define REG2 "r1" +# define ASM0 "mov" +# define ASM1 "add" +#elif defined (__i386__) +# define REG1 "%eax" +# define REG2 "%edx" +# define ASM0 "mov" +# define ASM1 "movl" +#elif defined (__powerpc__) || defined (__POWERPC__) +# define REG1 "r3" +# define REG2 "r4" +# define ASM0 "mr" +# define ASM1 "add" +#elif defined (__s390__) +# define REG1 "0" +# define REG2 "1" +# define ASM0 "lgr" +# define ASM1 "lmg" +#elif defined (__x86_64__) +# define REG1 "rax" +# define REG2 "rdx" +# define ASM0 "mov" +# define ASM1 "mov" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr87672.c b/SingleSource/Regression/C/gcc-dg/pr87672.c new file mode 100644 index 0000000000..0b64e5dd63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87672.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +char buf[40]; +void test (int x) +{ + __builtin_strcpy (buf, "test"); + __builtin___strcat_chk (buf, "postfix" + x, sizeof (buf)); +} + +/* { dg-final { scan-tree-dump "memcpy_chk.*, 36\\)" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr87746.c b/SingleSource/Regression/C/gcc-dg/pr87746.c new file mode 100644 index 0000000000..139651674e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87746.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ +/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */ + +typedef struct rtx_def *rtx; +struct replacement { + rtx *where; + rtx *subreg_loc; + int mode; +}; +static struct replacement replacements[150]; +void move_replacements (rtx *x, rtx *y, int n_replacements) +{ + int i; + for (i = 0; i < n_replacements; i++) + if (replacements[i].subreg_loc == x) + replacements[i].subreg_loc = y; + else if (replacements[i].where == x) + { + replacements[i].where = y; + replacements[i].subreg_loc = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87790.c b/SingleSource/Regression/C/gcc-dg/pr87790.c new file mode 100644 index 0000000000..4fa14860ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87790.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-Ofast -fprofile-generate" } */ +/* { dg-additional-options "-march=znver1" { target { x86_64-*-* i?86-*-* } } } */ + +int a, b; +void c(int d[][8]) +{ + int e, f; + for (; b; b++) { + e = d[b][0] % 4 * 21; + if (e >= 21) + e--; + a = d[b][0] - e; + f = 1; + for (; f != 8; f++) + d[b][f] = a; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87793.c b/SingleSource/Regression/C/gcc-dg/pr87793.c new file mode 100644 index 0000000000..d7673316d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87793.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-skip-if "No section attribute" { { hppa*-*-hpux* } && { ! lp64 } } } */ +/* { dg-options "-fpic -Os -g" } */ +/* { dg-require-effective-target fpic } */ + +struct fit_loadable_tbl { + int type; + void (*handler)(int data, int size); +}; + +#define ll_entry_start(_type, _list) \ +({ \ + static char start[0] __attribute__((aligned(4))) \ + __attribute__((unused, section(".u_boot_list_2_"#_list"_1"))); \ + (_type *)&start; \ +}) + +#define ll_entry_end(_type, _list) \ +({ \ + static char end[0] __attribute__((aligned(4))) \ + __attribute__((unused, section(".u_boot_list_2_"#_list"_3"))); \ + (_type *)&end; \ +}) + +#define ll_entry_count(_type, _list) \ + ({ \ + _type *start = ll_entry_start(_type, _list); \ + _type *end = ll_entry_end(_type, _list); \ + unsigned int _ll_result = end - start; \ + _ll_result; \ + }) + +void test(int img_type, int img_data, int img_len) +{ + int i; + const unsigned int count = + ll_entry_count(struct fit_loadable_tbl, fit_loadable); + struct fit_loadable_tbl *fit_loadable_handler = + ll_entry_start(struct fit_loadable_tbl, fit_loadable); + + for (i = 0; i < count; i++, fit_loadable_handler++) + if (fit_loadable_handler->type == img_type) + fit_loadable_handler->handler(img_data, img_len); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87811-2.c b/SingleSource/Regression/C/gcc-dg/pr87811-2.c new file mode 100644 index 0000000000..8b0818756e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87811-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +void bar (void); + +void +foo (int i) +{ + if (__builtin_expect_with_probability (i, 0, 2.0f)) /* { dg-error "probability .* is outside the range \\\[0\\\.0, 1\\\.0\\\]" } */ + bar (); +} + +/* { dg-final { scan-tree-dump-not "__builtin_expect_with_probability heuristics of edge" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr87811-3.c b/SingleSource/Regression/C/gcc-dg/pr87811-3.c new file mode 100644 index 0000000000..720d154a8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87811-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-profile_estimate" } */ + +void bar (void); + +void +foo (int i) +{ + if (__builtin_expect_with_probability (i, 0, 2.0f)) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87811.c b/SingleSource/Regression/C/gcc-dg/pr87811.c new file mode 100644 index 0000000000..110b383597 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87811.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +void bar (void); + +void +foo (int i, double d) +{ + if (__builtin_expect_with_probability (i, 0, d)) /* { dg-error "probability .d. must be constant floating-point expression" } */ + bar (); +} + +/* { dg-final { scan-tree-dump-not "__builtin_expect_with_probability heuristics of edge" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr87826.c b/SingleSource/Regression/C/gcc-dg/pr87826.c new file mode 100644 index 0000000000..cc5f14a49e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87826.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/87826 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -w" } */ + +int c; + +void +foo (int *b) +{ + int e; + for (e = 0; e < 16; ++e) + b[e] = c >> e * 8; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87873.c b/SingleSource/Regression/C/gcc-dg/pr87873.c new file mode 100644 index 0000000000..63d05342b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87873.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-vectorize" } */ + +long k3; +int gs; + +void +s2 (int aj) +{ + while (aj < 1) + { + gs ^= 1; + k3 = (long) gs * 2; + if (k3 != 0) + k3 = 0; + + ++aj; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87874.c b/SingleSource/Regression/C/gcc-dg/pr87874.c new file mode 100644 index 0000000000..80debe0b48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87874.c @@ -0,0 +1,33 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-g -O1 -fgcse -fno-dce -fno-tree-ccp -fno-tree-coalesce-vars -fno-tree-copy-prop -fno-tree-dce -fno-tree-dominator-opts -fno-tree-fre -fno-tree-loop-optimize -fno-tree-sink" } */ + +int *vk; +int m2; +__int128 nb; + +void +em (int u5, int fo, int s7) +{ + for (;;) + { + long int es; + + es = !!u5 ? (!!fo && !!m2) : fo; + if (es == 0) + if (nb == *vk) + { + const unsigned long long int uint64_max = 18446744073709551615ull; + __int128 ks = uint64_max / 2 + 1; + + while (s7 < 1) + while (nb < 2) + { + for (ks = 0; ks < 3; ++ks) + { + } + + ++nb; + } + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr8788-1.c b/SingleSource/Regression/C/gcc-dg/pr8788-1.c new file mode 100644 index 0000000000..2281a02f17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr8788-1.c @@ -0,0 +1,20 @@ +/* PR inline-asm/8788 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef struct { + long x[6]; +} myjmp_buf; + +typedef struct { + myjmp_buf regs; +} my_stack; + +void switch_to_stack (my_stack *stack){ + asm ( /* { dg-error "impossible constraint" } */ +/* { dg-warning "'asm' operand 1" "asm operand 1" { target *-*-* } .-1 } */ + "\n" + : "+r" (stack->regs) + ); +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr87894.c b/SingleSource/Regression/C/gcc-dg/pr87894.c new file mode 100644 index 0000000000..921a9cec46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87894.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +int a, b, c, d; +double e; + +void f(double g[][1]) +{ + for (;;) + { + double h; + for (; b < c; b++) + { + if (b >= 0) + ; + else if (d) + h = 2.0; + else + h = 0.0; + if (e) + g[a][b] = 0.0; + g[a][b] = h; + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr87929.c b/SingleSource/Regression/C/gcc-dg/pr87929.c new file mode 100644 index 0000000000..f64f7ada44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87929.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fexceptions -fnon-call-exceptions -fsignaling-nans" } */ + +#define complex __complex__ +#define _Complex_I (1.0iF) + +extern void f2c_4d__( complex float *, complex float *); +extern void abort (void); + +void f2c_4c__(void) +{ + complex float x,ret_val; + x = 1234 + 5678 * _Complex_I; + f2c_4d__(&ret_val,&x); + if ( x != ret_val ) abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87954.c b/SingleSource/Regression/C/gcc-dg/pr87954.c new file mode 100644 index 0000000000..620657cb1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87954.c @@ -0,0 +1,21 @@ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#define __GFP_DMA 1u +#define __GFP_RECLAIM 0x10u + +#define KMALLOC_DMA 2 +#define KMALLOC_RECLAIM 1 + +unsigned int +imul(unsigned int flags) +{ + int is_dma, type_dma, is_rec; + + is_dma = !!(flags & __GFP_DMA); + type_dma = is_dma * KMALLOC_DMA; + is_rec = !!(flags & __GFP_RECLAIM); + + return type_dma + (is_rec * !is_dma) * KMALLOC_RECLAIM; +} + +/* { dg-final { scan-tree-dump-times { \* } 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr87962.c b/SingleSource/Regression/C/gcc-dg/pr87962.c new file mode 100644 index 0000000000..6a551d3d5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87962.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-march=bdver2" { target { x86_64-*-* i?86-*-* } } } */ + +int a, b; + +int c() +{ + long d, e; + while (a) { + a++; + b = 0; + for (; b++ - 2; d = d >> 1) + e += d; + } + return e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87979.c b/SingleSource/Regression/C/gcc-dg/pr87979.c new file mode 100644 index 0000000000..d3d595f4f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87979.c @@ -0,0 +1,11 @@ +/* PR rtl-optimization/87979 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fmodulo-sched -fno-tree-loop-im" } */ +/* { dg-additional-options "-march=z196" { target { s390*-*-* } } } */ + +void foo(void) +{ + static int m; + for (int i = 0; i < 10; ++i) + m++; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr87985.c b/SingleSource/Regression/C/gcc-dg/pr87985.c new file mode 100644 index 0000000000..c0d07ff918 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr87985.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-slp-vectorize" } */ + +char *bar (void); +__INTPTR_TYPE__ baz (void); + +void +foo (__INTPTR_TYPE__ *q) +{ + char *p = bar (); + __INTPTR_TYPE__ a = baz (); + __INTPTR_TYPE__ b = baz (); + int i = 0; +#define X q[i++] = a; q[i++] = b; a = a + b; b = b + a; +#define Y X X X X X X X X X X +#define Z Y Y Y Y Y Y Y Y Y Y + Z Z Z Z Z Z Z Z Z Z + p[a] = 1; + p[b] = 2; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88007.c b/SingleSource/Regression/C/gcc-dg/pr88007.c new file mode 100644 index 0000000000..4f56ba49a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88007.c @@ -0,0 +1,15 @@ +/* PR other/88007 */ +/* { dg-do compile } */ +/* { dg-options "--param ggc-min-expand=3 --param ggc-min-heapsize=1024" } */ +/* { dg-skip-if "no code alignment > 2" { "pdp11-*-*" } } */ + +void bar (void); + +__attribute__((optimize ("align-loops=16", "align-jumps=16", + "align-labels=16", "align-functions=16"))) +void +foo (void) +{ + for (int i = 0; i < 1024; ++i) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88031.c b/SingleSource/Regression/C/gcc-dg/pr88031.c new file mode 100644 index 0000000000..2c1d1c1391 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88031.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a[512]; +int b; +void d() +{ + unsigned char c; + for (; b; b++) { + c = 1; + for (; c; c <<= 1) { + a[b] <<= 8; + if (b & c) + a[b] = 1; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88069.c b/SingleSource/Regression/C/gcc-dg/pr88069.c new file mode 100644 index 0000000000..2148513501 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88069.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-pre -ftree-vectorize -fno-tree-pta" } */ + +void +qf (void); + +void +mr (short int db) +{ + int vq; + short int *lp = &db; + + for (vq = 0; vq < 1; ++vq) + qf (); + + while (*lp < 2) + { + *lp = db; + lp = (short int *) &vq; + ++*lp; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr88071.c b/SingleSource/Regression/C/gcc-dg/pr88071.c new file mode 100644 index 0000000000..680bf8b74f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88071.c @@ -0,0 +1,5 @@ +/* PR tree-optimization/88071 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fexceptions -fnon-call-exceptions -fopenmp-simd -ftrapv -ftree-loop-vectorize" } */ + +#include "gomp/openmp-simd-2.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr88074-2.c b/SingleSource/Regression/C/gcc-dg/pr88074-2.c new file mode 100644 index 0000000000..a93c19dccc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88074-2.c @@ -0,0 +1,17 @@ +/* PR middle-end/88074 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ +/* { dg-final { scan-tree-dump-not "link_error " "optimized" } } */ + +extern void link_error (void); +int +main () +{ + if (((__FLT128_MAX__ * 0.5 + __FLT128_MAX__ * 0.5i) + / (__FLT128_MAX__ * 0.25 + __FLT128_MAX__ * 0.25i)) + != (_Complex _Float128) 2) + link_error (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88074.c b/SingleSource/Regression/C/gcc-dg/pr88074.c new file mode 100644 index 0000000000..082f620fda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88074.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target c99_runtime } } */ +/* { dg-options "-O" } */ + +#include + +int main() +{ + _Complex double x; + __real x = 3.091e+8; + __imag x = -4.045e+8; + /* This used to spend huge amounts of compile-time inside mpc. */ + volatile _Complex double y = ctan (x); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr8835-1.c b/SingleSource/Regression/C/gcc-dg/pr8835-1.c new file mode 100644 index 0000000000..6e3703baaf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr8835-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +struct s { + char c; +}; + +struct s +foo (void) +{ + struct s s = { 0 }; + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88427.c b/SingleSource/Regression/C/gcc-dg/pr88427.c new file mode 100644 index 0000000000..60b179c671 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88427.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce -fno-tree-fre -Wno-div-by-zero" } */ + +void +uj (int eq, int s4) +{ + short int tm = 0; + + for (;;) + if (eq == s4) + { + tm += !!s4; + if (tm == s4) + { + eq += tm; + for (;;) + eq /= 0; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88444.c b/SingleSource/Regression/C/gcc-dg/pr88444.c new file mode 100644 index 0000000000..01b0d45ed8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88444.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/88444 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vrp -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre" } */ + +int v; + +int +foo (int, int); + +static inline int +bar (long int x) +{ + return !!x ? x : 1; +} + +static inline void +baz (int x) +{ + v += foo (0, 0) + bar (x); +} + +void +qux (void) +{ + int a = 0; + v = v || foo (0, 0); + v = v || foo (0, 0); + v = v || foo (0, 0); + baz (a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88563.c b/SingleSource/Regression/C/gcc-dg/pr88563.c new file mode 100644 index 0000000000..5526a8d015 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88563.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/88563 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O2 -fno-code-hoisting -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-forwprop -fno-tree-fre -fno-tree-pre -fno-tree-vrp" } */ + +int +main () +{ +#if __SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT128__ == 16 && __CHAR_BIT__ == 8 + unsigned __int128 a = 5; + __builtin_mul_overflow (0xffffffffffffffffULL, (unsigned long long) a, &a); + if (a != ((unsigned __int128)4 << 64 | 0xfffffffffffffffb)) + __builtin_abort (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88568.c b/SingleSource/Regression/C/gcc-dg/pr88568.c new file mode 100644 index 0000000000..65d57d7eb4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88568.c @@ -0,0 +1,4 @@ +/* PR c/88568 */ +/* { dg-do compile } */ +/* { dg-require-dll "" } */ +__attribute__((dllimport)) struct S var; /* { dg-bogus "storage size of .var. isn.t known" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88594.c b/SingleSource/Regression/C/gcc-dg/pr88594.c new file mode 100644 index 0000000000..6e3f299405 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88594.c @@ -0,0 +1,16 @@ +/* PR target/88594 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fno-tree-dominator-opts -fno-tree-forwprop -fno-tree-vrp" } */ + +__int128 +foo (__int128 x, __int128 *y) +{ + int a; + __int128 z, r; + for (a = 0; a < 17; ++a) + ; + z = x / a; + r = x % a; + *y = z; + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88598-1.c b/SingleSource/Regression/C/gcc-dg/pr88598-1.c new file mode 100644 index 0000000000..2b62dd9b25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88598-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O -fdump-tree-ccp1" } */ + +typedef int v4si __attribute__ ((vector_size (16))); + +int +main () +{ + volatile v4si x1 = { 4, 5, 6, 7 }; + volatile v4si x2 = { 10, 11, 12, 13 }; + volatile v4si x3 = { 20, 21, 22, 23 }; + + x1 *= (v4si) { 0, 1, 1, 0 }; + x2 *= (v4si) { 1, 0, 0, 1 }; + x3 *= (v4si) { 0, 0, 1, 0 }; + + if (__builtin_memcmp ((void *) &x1, &(v4si) { 0, 5, 6, 0 }, sizeof (v4si)) + || __builtin_memcmp ((void *) &x2, &(v4si) { 10, 0, 0, 13 }, + sizeof (v4si)) + || __builtin_memcmp ((void *) &x3, &(v4si) { 0, 0, 22, 0 }, + sizeof (v4si))) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not { \* } "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88598-2.c b/SingleSource/Regression/C/gcc-dg/pr88598-2.c new file mode 100644 index 0000000000..13017c799c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88598-2.c @@ -0,0 +1,30 @@ +/* { dg-do run { target double64 } } */ +/* { dg-options "-O -fdump-tree-ccp1" } */ +/* { dg-add-options ieee } */ + +typedef double v4df __attribute__ ((vector_size (32))); + +int +main () +{ + volatile v4df x1 = { 4, 5, 6, -7 }; + volatile v4df x2 = { 10, -11, 12, 13 }; + volatile v4df x3 = { 20, 21, 22, 23 }; + + x1 *= (v4df) { 0, 1, 1, 0 }; + x2 *= (v4df) { 1, 0, 0, 1 }; + x3 *= (v4df) { 0.0, -0.0, 1.0, -0.0 }; + + if (__builtin_memcmp ((void *) &x1, &(v4df) { 0, 5, 6, -0.0 }, + sizeof (v4df)) + || __builtin_memcmp ((void *) &x2, &(v4df) { 10, -0.0, 0, 13 }, + sizeof (v4df)) + || __builtin_memcmp ((void *) &x3, &(v4df) { 0, -0.0, 22, -0.0 }, + sizeof (v4df))) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump { \* } "ccp1" } } */ +/* { dg-final { scan-tree-dump-not { \& } "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88598-3.c b/SingleSource/Regression/C/gcc-dg/pr88598-3.c new file mode 100644 index 0000000000..bddfb68b57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88598-3.c @@ -0,0 +1,29 @@ +/* { dg-do run { target double64 } } */ +/* { dg-options "-O -fno-signed-zeros -fdump-tree-ccp1" } */ +/* { dg-add-options ieee } */ + +typedef double v4df __attribute__ ((vector_size (32))); + +int +main () +{ + volatile v4df x1 = { 4, 5, 6, -7 }; + volatile v4df x2 = { 10, -11, 12, 13 }; + volatile v4df x3 = { 20, 21, 22, 23 }; + + x1 *= (v4df) { 0, 1, 1, 0 }; + x2 *= (v4df) { 1, 0, 0, 1 }; + x3 *= (v4df) { 0.0, -0.0, 1.0, -0.0 }; + + if (__builtin_memcmp ((void *) &x1, &(v4df) { 0, 5, 6, 0 }, + sizeof (v4df)) + || __builtin_memcmp ((void *) &x2, &(v4df) { 10, 0, 0, 13 }, + sizeof (v4df)) + || __builtin_memcmp ((void *) &x3, &(v4df) { 0, 0, 22, 0 }, + sizeof (v4df))) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not { \* } "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88598-4.c b/SingleSource/Regression/C/gcc-dg/pr88598-4.c new file mode 100644 index 0000000000..8026394d79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88598-4.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-O -fdump-tree-ccp1" } */ + +typedef int v4si __attribute__ ((vector_size (16))); + +int +main () +{ + volatile v4si x1 = { 4, 5, 6, 7 }; + volatile v4si x2 = { 10, 11, 12, 13 }; + volatile v4si x3 = { 20, 21, 22, 23 }; + + x1 *= (v4si) { 0, 1, 2, 3 }; + x2 *= (v4si) { 1, 0, 2, 0 }; + x3 *= (v4si) { 0, 0, -1, 0 }; + + if (__builtin_memcmp ((void *) &x1, &(v4si) { 0, 5, 12, 21 }, sizeof (v4si)) + || __builtin_memcmp ((void *) &x2, &(v4si) { 10, 0, 24, 0 }, + sizeof (v4si)) + || __builtin_memcmp ((void *) &x3, &(v4si) { 0, 0, -22, 0 }, + sizeof (v4si))) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump { \* } "ccp1" } } */ +/* { dg-final { scan-tree-dump-not { \& } "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88598-5.c b/SingleSource/Regression/C/gcc-dg/pr88598-5.c new file mode 100644 index 0000000000..29d1935c6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88598-5.c @@ -0,0 +1,29 @@ +/* { dg-do run { target double64 } } */ +/* { dg-options "-O -fno-signed-zeros -fdump-tree-ccp1" } */ +/* { dg-add-options ieee } */ + +typedef double v4df __attribute__ ((vector_size (32))); + +int +main () +{ + volatile v4df x1 = { 4, 5, 6, 7 }; + volatile v4df x2 = { 10, 11, 12, 13 }; + volatile v4df x3 = { 20, 21, 22, 23 }; + + x1 *= (v4df) { 0, 1, 2, 3 }; + x2 *= (v4df) { 1, 0, 2, 0 }; + x3 *= (v4df) { 0, 0, -1, 0 }; + + if (__builtin_memcmp ((void *) &x1, &(v4df) { 0, 5, 12, 21 }, sizeof (v4df)) + || __builtin_memcmp ((void *) &x2, &(v4df) { 10, 0, 24, 0 }, + sizeof (v4df)) + || __builtin_memcmp ((void *) &x3, &(v4df) { 0, 0, -22, 0 }, + sizeof (v4df))) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump { \* } "ccp1" } } */ +/* { dg-final { scan-tree-dump-not { \& } "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88660.c b/SingleSource/Regression/C/gcc-dg/pr88660.c new file mode 100644 index 0000000000..c1d0985bb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88660.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wunused-but-set-variable" } */ + +int main(void) +{ + const int i = 0; + switch(i) + { + default: break; + } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/pr88676.c b/SingleSource/Regression/C/gcc-dg/pr88676.c new file mode 100644 index 0000000000..b5fdd9342b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88676.c @@ -0,0 +1,48 @@ +/* PR tree-optimization/88676 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "tree-ssa/pr88676.c" + +__attribute__((noipa)) void +bar (int x, int y, int z) +{ + if (z != 115 && z != 116) + __builtin_abort (); + if (x == 98) + { + if (y != z) + __builtin_abort (); + } + else if (x != 99) + __builtin_abort (); + else if (z == 115) + { + if (y != 116) + __builtin_abort (); + } + else if (y != 115) + __builtin_abort (); +} + +int +main () +{ + if (f1 (0) != 1 || f1 (1) != 2) + __builtin_abort (); + int i; + for (i = -12; i < 12; i++) + { + f2 (i); + f3 (i); + f4 (i); + f5 (i); + f6 (i); + f7 (i); + f8 (i); + f9 (i); + if (f10 (i) != ((i & 1) ? 84 : 85)) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88701.c b/SingleSource/Regression/C/gcc-dg/pr88701.c new file mode 100644 index 0000000000..7aa846d168 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88701.c @@ -0,0 +1,18 @@ +/* PR c/88701 */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +void foo (int [(int (*)[1]) { 0 } == 0]); +void bar (int n, int [(int (*)[n]) { 0 } == 0]); + +int +baz (int a[(int (*)[1]) { 0 } == 0]) +{ + return a[0]; +} + +int +qux (int n, int a[(int (*)[n]) { 0 } == 0]) +{ + return a[0] + n; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-1.c b/SingleSource/Regression/C/gcc-dg/pr88784-1.c new file mode 100644 index 0000000000..b8daae0b33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-1.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool and1(unsigned x, unsigned y) +{ + /* x > y && x != 0 --> x > y */ + return x > y && x != 0; +} + +_Bool and2(unsigned x, unsigned y) +{ + /* x < y && x != UINT_MAX --> x < y */ + return x < y && x != UINT_MAX; +} + +_Bool and3(signed x, signed y) +{ + /* x > y && x != INT_MIN --> x > y */ + return x > y && x != INT_MIN; +} + +_Bool and4(signed x, signed y) +{ + /* x < y && x != INT_MAX --> x < y */ + return x < y && x != INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " != " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-10.c b/SingleSource/Regression/C/gcc-dg/pr88784-10.c new file mode 100644 index 0000000000..958d765655 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-10.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool or1(unsigned x, unsigned y) +{ + /* x <= y || x != 0 --> true */ + return x <= y || x != 0; +} + +_Bool or2(unsigned x, unsigned y) +{ + /* x >= y || x != UINT_MAX --> true */ + return x >= y || x != UINT_MAX; +} + +_Bool or3(signed x, signed y) +{ + /* x <= y || x != INT_MIN --> true */ + return x <= y || x != INT_MIN; +} + +_Bool or4(signed x, signed y) +{ + /* x >= y || x != INT_MAX --> true */ + return x >= y || x != INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " != " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " <= " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >= " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-11.c b/SingleSource/Regression/C/gcc-dg/pr88784-11.c new file mode 100644 index 0000000000..c4b0508244 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-11.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool or1(unsigned x, unsigned y) +{ + /* x <= y || x == 0 --> x <= y */ + return x <= y || x == 0; +} + +_Bool or2(unsigned x, unsigned y) +{ + /* x >= y || x == UINT_MAX --> x >= y */ + return x >= y || x == UINT_MAX; +} + +_Bool or3(signed x, signed y) +{ + /* x <= y || x == INT_MIN --> x <= y */ + return x <= y || x == INT_MIN; +} + +_Bool or4(signed x, signed y) +{ + /* x >= y || x == INT_MAX --> x >= y */ + return x >= y || x == INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " == " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-12.c b/SingleSource/Regression/C/gcc-dg/pr88784-12.c new file mode 100644 index 0000000000..5b60b3883f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-12.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-dce3" } */ + +#include + +_Bool or1(unsigned x, unsigned y) +{ + /* x <= y || x == 0 --> x <= y */ + return x <= y || x == 0; +} + +_Bool or2(unsigned x, unsigned y) +{ + /* x >= y || x == UINT_MAX --> x >= y */ + return x >= y || x == UINT_MAX; +} + +_Bool or3(signed x, signed y) +{ + /* x <= y || x == INT_MIN --> x <= y */ + return x <= y || x == INT_MIN; +} + +_Bool or4(signed x, signed y) +{ + /* x >= y || x == INT_MAX --> x >= y */ + return x >= y || x == INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " == " "dce3" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-2.c b/SingleSource/Regression/C/gcc-dg/pr88784-2.c new file mode 100644 index 0000000000..ed360018b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-2.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool and1(unsigned x, unsigned y) +{ + /* x > y && x != 0 --> x > y */ + return x > y && x != 0; +} + +_Bool and2(unsigned x, unsigned y) +{ + /* x < y && x != UINT_MAX --> x < y */ + return x < y && x != UINT_MAX; +} + +_Bool and3(signed x, signed y) +{ + /* x > y && x != INT_MIN --> x > y */ + return x > y && x != INT_MIN; +} + +_Bool and4(signed x, signed y) +{ + /* x < y && x != INT_MAX --> x < y */ + return x < y && x != INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " != " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-3.c b/SingleSource/Regression/C/gcc-dg/pr88784-3.c new file mode 100644 index 0000000000..8c48e1b894 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-3.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool and1(unsigned x, unsigned y) +{ + /* x > y && x == 0 --> false */ + return x > y && x == 0; +} + +_Bool and2(unsigned x, unsigned y) +{ + /* x < y && x == UINT_MAX --> false */ + return x < y && x == UINT_MAX; +} + +_Bool and3(signed x, signed y) +{ + /* x > y && x == INT_MIN --> false */ + return x > y && x == INT_MIN; +} + +_Bool and4(signed x, signed y) +{ + /* x < y && x == INT_MAX --> false */ + return x < y && x == INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " == " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " > " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " < " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-4.c b/SingleSource/Regression/C/gcc-dg/pr88784-4.c new file mode 100644 index 0000000000..a9aa74cb9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool and1(unsigned x, unsigned y) +{ + /* x > y && x == 0 --> false */ + return x > y && x == 0; +} + +_Bool and2(unsigned x, unsigned y) +{ + /* x < y && x == UINT_MAX --> false */ + return x < y && x == UINT_MAX; +} + +_Bool and3(signed x, signed y) +{ + /* x > y && x == INT_MIN --> false */ + return x > y && x == INT_MIN; +} + +_Bool and4(signed x, signed y) +{ + /* x < y && x == INT_MAX --> false */ + return x < y && x == INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " == " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " > " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-5.c b/SingleSource/Regression/C/gcc-dg/pr88784-5.c new file mode 100644 index 0000000000..b147abbcfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-5.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool and1(unsigned x, unsigned y) +{ + /* x <= y && x == 0 --> x == 0 */ + return x <= y && x == 0; +} + +_Bool and2(unsigned x, unsigned y) +{ + /* x >= y && x == UINT_MAX --> x == UINT_MAX */ + return x >= y && x == UINT_MAX; +} + +_Bool and3(signed x, signed y) +{ + /* x <= y && x == INT_MIN --> x == INT_MIN */ + return x <= y && x == INT_MIN; +} + +_Bool and4(signed x, signed y) +{ + /* x >= y && x == INT_MAX --> x == INT_MAX */ + return x >= y && x == INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " <= " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " >= " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-6.c b/SingleSource/Regression/C/gcc-dg/pr88784-6.c new file mode 100644 index 0000000000..6d5bd7b0c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-6.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool and1(unsigned x, unsigned y) +{ + /* x <= y && x == 0 --> x == 0 */ + return x <= y && x == 0; +} + +_Bool and2(unsigned x, unsigned y) +{ + /* x >= y && x == UINT_MAX --> x == UINT_MAX */ + return x >= y && x == UINT_MAX; +} + +_Bool and3(signed x, signed y) +{ + /* x <= y && x == INT_MIN --> x == INT_MIN */ + return x <= y && x == INT_MIN; +} + +_Bool and4(signed x, signed y) +{ + /* x >= y && x == INT_MAX --> x == INT_MAX */ + return x >= y && x == INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " <= " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >= " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-7.c b/SingleSource/Regression/C/gcc-dg/pr88784-7.c new file mode 100644 index 0000000000..6577ff9e14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-7.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool or1(unsigned x, unsigned y) +{ + /* x > y || x != 0 --> x != 0 */ + return x > y || x != 0; +} + +_Bool or2(unsigned x, unsigned y) +{ + /* x < y || x != UINT_MAX --> x != UINT_MAX */ + return x < y || x != UINT_MAX; +} + +_Bool or3(signed x, signed y) +{ + /* x > y || x != INT_MIN --> x != INT_MIN */ + return x > y || x != INT_MIN; +} + +_Bool or4(signed x, signed y) +{ + /* x < y || x != INT_MAX --> x != INT_MAX */ + return x < y || x != INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " > " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " < " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-8.c b/SingleSource/Regression/C/gcc-dg/pr88784-8.c new file mode 100644 index 0000000000..6bb56a9156 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-8.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool or1(unsigned x, unsigned y) +{ + /* x > y || x != 0 --> x != 0 */ + return x > y || x != 0; +} + +_Bool or2(unsigned x, unsigned y) +{ + /* x < y || x != UINT_MAX --> x != UINT_MAX */ + return x < y || x != UINT_MAX; +} + +_Bool or3(signed x, signed y) +{ + /* x > y || x != INT_MIN --> x != INT_MIN */ + return x > y || x != INT_MIN; +} + +_Bool or4(signed x, signed y) +{ + /* x < y || x != INT_MAX --> x != INT_MAX */ + return x < y || x != INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " > " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88784-9.c b/SingleSource/Regression/C/gcc-dg/pr88784-9.c new file mode 100644 index 0000000000..27e3281c55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88784-9.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool or1(unsigned x, unsigned y) +{ + /* x <= y || x != 0 --> true */ + return x <= y || x != 0; +} + +_Bool or2(unsigned x, unsigned y) +{ + /* x >= y || x != UINT_MAX --> true */ + return x >= y || x != UINT_MAX; +} + +_Bool or3(signed x, signed y) +{ + /* x <= y || x != INT_MIN --> true */ + return x <= y || x != INT_MIN; +} + +_Bool or4(signed x, signed y) +{ + /* x >= y || x != INT_MAX --> true */ + return x >= y || x != INT_MAX; +} + +/* { dg-final { scan-tree-dump-not " != " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " <= " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " >= " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr88855.c b/SingleSource/Regression/C/gcc-dg/pr88855.c new file mode 100644 index 0000000000..be6ffe3675 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88855.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-if-convert -ftree-vrp -fno-tree-copy-prop -fno-tree-dce -fno-tree-dominator-opts" } */ + +typedef int jmp_buf[1]; + +extern void exit(int) __attribute__((__noreturn__)); +extern int setjmpx(jmp_buf) __attribute__((__returns_twice__)); + +jmp_buf jbAnagram; +int a[6]; +int d; +int b () { exit (1); } +int c () { b (); } +int e () +{ + int f = 0; + for (; f < 6; f++) + a[f] = d; + c (); + setjmpx (jbAnagram); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88870.c b/SingleSource/Regression/C/gcc-dg/pr88870.c new file mode 100644 index 0000000000..81f686bd97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88870.c @@ -0,0 +1,24 @@ +/* PR rtl-optimization/88870 */ +/* { dg-do compile } */ +/* { dg-require-effective-target nonlocal_goto } */ +/* { dg-options "-O1 -fexceptions -fnon-call-exceptions -ftrapv -fno-tree-dominator-opts" } */ + +int a, b; + +void +foo (int *x) +{ + int c = 0; + { + int d; + x = &c; + for (;;) + { + x = &d; + b = 0; + d = c + 1; + b = c = 1; + ++a; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88905.c b/SingleSource/Regression/C/gcc-dg/pr88905.c new file mode 100644 index 0000000000..fd2c264732 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88905.c @@ -0,0 +1,22 @@ +/* PR target/88905 */ +/* { dg-do compile } */ +/* { dg-options "-Og -fno-tree-ccp" } */ +/* { dg-additional-options "-mabm" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target int32plus } */ + +int a, b, c; +extern void baz (int); + +static inline int +bar (unsigned u) +{ + int i = __builtin_popcountll (-(unsigned long long) u); + baz (i & c); + return a + b + c; +} + +void +foo (void) +{ + bar (2376498292ULL); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr88928.c b/SingleSource/Regression/C/gcc-dg/pr88928.c new file mode 100644 index 0000000000..0b6c1d70f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr88928.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-pedantic -Waddress-of-packed-member" } */ +struct a { } __attribute__((__packed__)); +void c (struct a **); +void d (const struct a *b) { c ((struct a **) b); } +/* { dg-warning "may result in an unaligned pointer value" "" { target { ! default_packed } } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr89037.c b/SingleSource/Regression/C/gcc-dg/pr89037.c new file mode 100644 index 0000000000..551136741d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89037.c @@ -0,0 +1,24 @@ +/* { dg-do run { target int128 } } */ +/* { dg-options "" } */ + +struct s +{ + __int128 y : 66; +}; +typedef struct s T; +T a[] = { 1, 10000, 0x12345, 0xff000001, 1ULL << 63, (__int128) 1 << 64, + ((__int128) 1 << 64) | 1 }; + +int +main (void) +{ + if (a[0].y != 1 + || a[1].y != 10000 + || a[2].y != 0x12345 + || a[3].y != 0xff000001 + || a[4].y != (1ULL << 63) + || a[5].y != ((__int128) 1 << 64) + || a[6].y != (((__int128) 1 << 64) | 1)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89045.c b/SingleSource/Regression/C/gcc-dg/pr89045.c new file mode 100644 index 0000000000..2b5730d488 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89045.c @@ -0,0 +1,16 @@ +/* PR c/89045 */ +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "" } */ + +int +foo (int x) +{ + int v[(int){ x }]; + v[0] = 0; + int bar (int p[(int){ x }]) + { + return p[0]; + } + return bar (v); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89061.c b/SingleSource/Regression/C/gcc-dg/pr89061.c new file mode 100644 index 0000000000..6b5d913401 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89061.c @@ -0,0 +1,27 @@ +/* PR c/89061 */ +/* { dg-do compile } */ +/* { dg-options "-Wjump-misses-init" } */ + +struct S { int s; }; + +int +foo (int x) +{ + struct S s = { 0 }; + if ((s.s = x) == 0) + goto cleanup; /* { dg-bogus "jump skips variable initialization" } */ + s = (struct S) { .s = 42 }; + cleanup: + return s.s; +} + +int +bar (int x) +{ + struct S *s = &(struct S) { 0 }; + if ((s->s = x) == 0) + goto cleanup; /* { dg-bogus "jump skips variable initialization" } */ + s = &(struct S) { .s = 42 }; + cleanup: + return s->s; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89211.c b/SingleSource/Regression/C/gcc-dg/pr89211.c new file mode 100644 index 0000000000..cf721aa5f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89211.c @@ -0,0 +1,8 @@ +/* PR c/89211 */ +/* { dg-do compile } */ + +void foo (); +void foo () +{ + void foo (struct S); /* { dg-warning "declared inside parameter list" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr8927-1.c b/SingleSource/Regression/C/gcc-dg/pr8927-1.c new file mode 100644 index 0000000000..5c1611ac66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr8927-1.c @@ -0,0 +1,13 @@ +/* Bug 8927: undeclared identifiers should give an error on the line + of that identifier, not on the line of the next token. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo(void) +{ + bar /* { dg-error "undeclared" } */ + /* { dg-message "undeclared identifier is reported only once" "reminder" { target *-*-* } .-1 } */ + + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89278.c b/SingleSource/Regression/C/gcc-dg/pr89278.c new file mode 100644 index 0000000000..609cb1a53a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89278.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/89278 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftrapv -ftree-loop-distribute-patterns --param max-loop-header-insns=2" } */ + +void +foo (int *w, int x, int y, int z) +{ + while (x < y + z) + { + w[x] = 0; + ++x; + } +} + +void +bar (int *__restrict u, int *__restrict w, int x, int y, int z) +{ + while (x < y + z) + { + w[x] = u[x]; + ++x; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89313.c b/SingleSource/Regression/C/gcc-dg/pr89313.c new file mode 100644 index 0000000000..4b75f305b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89313.c @@ -0,0 +1,40 @@ +/* PR rtl-optimization/89313 */ +/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* powerpc*-*-* s390*-*-* x86_64-*-* } } */ +/* { dg-options "-O2" } */ + +#if defined (__aarch64__) +# define REG "x0" +# define ASM "add" +#elif defined (__arm__) +# define REG "r0" +# define ASM "add" +#elif defined (__i386__) +# define REG "%eax" +# define ASM "mov" +#elif defined (__powerpc__) || defined (__POWERPC__) +# define REG "r3" +# define ASM "add" +#elif defined (__s390__) +# define REG "0" +# define ASM "lmg" +#elif defined (__x86_64__) +# define REG "rax" +# define ASM "mov" +#endif + +long +bug (long arg) +{ + register long output asm (REG); + long input = arg; + asm (ASM +#if defined (__i386__) + " %0, 0(%1,%2)" +#elif defined (__s390__) + " %0, %1, 0(%2)" +#else + " %0, 0(%1,%2)" +#endif + : "=&r" (output) : "r" (input), "0" (input)); + return output; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89314.c b/SingleSource/Regression/C/gcc-dg/pr89314.c new file mode 100644 index 0000000000..27b3a510bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89314.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/89314 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wbuiltin-declaration-mismatch -Wextra" } */ + +extern __SIZE_TYPE__ strlen (const float *); /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch" } */ +void bar (void); + +void +foo (float *s) +{ + if (strlen (s) > 0) + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89340.c b/SingleSource/Regression/C/gcc-dg/pr89340.c new file mode 100644 index 0000000000..8636d2218b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89340.c @@ -0,0 +1,9 @@ +/* PR c/89340 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void bar (void) +{ + __attribute__((weak)) void foo () {} /* { dg-error "weak declaration of 'foo' must be public" } */ + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89342.c b/SingleSource/Regression/C/gcc-dg/pr89342.c new file mode 100644 index 0000000000..3bc779c1dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89342.c @@ -0,0 +1,11 @@ +/* PR other/89342 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +__attribute__((optimize("Ofast"))) +void foo (void) +{ + __attribute__((optimize("no-inline"))) + void bar (void) {} + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89350.c b/SingleSource/Regression/C/gcc-dg/pr89350.c new file mode 100644 index 0000000000..172b2487fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89350.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/89350 - Wrong -Wstringop-overflow warning + on a variable offset from the end of an array + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +char buf[128]; +char *src = "HCSparta"; + +int main(int argc, char **argv) +{ + char *dst = buf + sizeof(buf); + + if (argc) + { + dst -= argc; + __builtin_memcpy(dst, src, argc + 0); /* { dg-bogus "\\\[-Warray-bounds|-Wstringop-overflow" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89354.c b/SingleSource/Regression/C/gcc-dg/pr89354.c new file mode 100644 index 0000000000..0c58cc182e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89354.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/89354 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-msse2" { target sse2_runtime } } */ + +static unsigned long long q = 0; + +__attribute__((noipa)) static void +foo (void) +{ + q = (q & ~0x1ffffffffULL) | 0x100000000ULL; +} + +int +main () +{ + __asm volatile ("" : "+m" (q)); + foo (); + if (q != 0x100000000ULL) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89410-1.c b/SingleSource/Regression/C/gcc-dg/pr89410-1.c new file mode 100644 index 0000000000..7423c49600 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89410-1.c @@ -0,0 +1,9 @@ +/* { dg-options "" } */ + +int main(void) +{ + /* This is 0xffffffff. */ +#line 4294967295 +#warning msg + /* { dg-warning "msg" "" { target *-*-* } { -1 } } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89410-2.c b/SingleSource/Regression/C/gcc-dg/pr89410-2.c new file mode 100644 index 0000000000..3cc6d6d063 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89410-2.c @@ -0,0 +1,13 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +int main(void) +{ + /* This is 0x7fffffffffffffff, which truncates to 0xffffffff. */ +#line 9223372036854775807 /* { dg-warning "line number out of range" } */ +#warning msg + /* { dg-begin-multiline-output "" } + #line 9223372036854775807 + ^~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ + /* { dg-warning "msg" "" { target *-*-* } { -1 } } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89434.c b/SingleSource/Regression/C/gcc-dg/pr89434.c new file mode 100644 index 0000000000..42cf7e4cdb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89434.c @@ -0,0 +1,5 @@ +/* PR target/89434 */ +/* { dg-do run } */ +/* { dg-options "-Og" } */ + +#include "../gcc-c-torture/execute/pr89434.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr89435.c b/SingleSource/Regression/C/gcc-dg/pr89435.c new file mode 100644 index 0000000000..d72d087f5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89435.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/89435 */ +/* { dg-do run } */ +/* { dg-options "-O1 -fno-forward-propagate -fno-tree-forwprop -fno-tree-ccp" } */ + +unsigned short a; +unsigned int b, c, d, e, f; + +int +main () +{ +#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 + unsigned char g = e = __builtin_mul_overflow_p (5, 542624702, 0); + d = __builtin_bswap64 (a); + b = __builtin_sub_overflow ((unsigned char) -e, (unsigned int) d, &g); + e = __builtin_mul_overflow (b, c, &a); + f = g + e; + if (f != 0xff) + __builtin_abort (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89438.c b/SingleSource/Regression/C/gcc-dg/pr89438.c new file mode 100644 index 0000000000..2db462364d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89438.c @@ -0,0 +1,22 @@ +/* PR target/89438 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -w" } */ + +struct S { double b, c; struct T { double d, e; } f[16]; } g; +int h, i, j; +double k; + +double +foo (void) +{ + int m; + if (j) + return k; + long a, p = a - 80; + double b, n; + n = b * h + g.f[p].e; + m = n; + double o = 1 ? m : 1.0; + k = i ? -o : o; + return k; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89500.c b/SingleSource/Regression/C/gcc-dg/pr89500.c new file mode 100644 index 0000000000..db7c27bec0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89500.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/89500 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __SIZE_TYPE__ size_t; +extern size_t strlen (const char *); +extern size_t strnlen (const char *, size_t); +extern void bar (char *); + +void +foo (int *a) +{ + char c[64]; + bar (c); + a[0] = strlen (c); + a[1] = strnlen (c, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89506.c b/SingleSource/Regression/C/gcc-dg/pr89506.c new file mode 100644 index 0000000000..2ec4f32118 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89506.c @@ -0,0 +1,14 @@ +/* PR target/89506 */ +/* { dg-do compile } */ +/* { dg-options "-Og -g -w" } */ + +long long a; +int c; + +int +foo (long long d, short e) +{ + __builtin_sub_overflow (0xffffffff, c, &a); + e >>= ~2147483647 != (int) a; + return d + e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89518.c b/SingleSource/Regression/C/gcc-dg/pr89518.c new file mode 100644 index 0000000000..5b289c2054 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89518.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +unsigned foo (unsigned a, unsigned b) +{ + return a/b * b + a%b; +} + +int bar (int a, int b) +{ + return a/b * b + a%b; +} + +/* { dg-final { scan-tree-dump-times "return a;" 2 "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr89520-1.c b/SingleSource/Regression/C/gcc-dg/pr89520-1.c new file mode 100644 index 0000000000..128e8359d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89520-1.c @@ -0,0 +1,13 @@ +/* PR c/89520 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -w" } */ + +#define A(name) __typeof (__builtin_##name (0)) name (); long name##1 () { return name (); } +#define B(name) A(name) A(name##f) A(name##l) +B (ceil) +B (floor) +B (round) +B (trunc) +B (nearbyint) +B (rint) +B (logb) diff --git a/SingleSource/Regression/C/gcc-dg/pr89520-2.c b/SingleSource/Regression/C/gcc-dg/pr89520-2.c new file mode 100644 index 0000000000..8edafa7f4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89520-2.c @@ -0,0 +1,42 @@ +/* PR c/89520 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -w" } */ + +#define A(name) __typeof (__builtin_##name (0)) name (); \ + float name##1 () { return name (); } \ + double name##2 () { return name (); } +#define B(name) A(name) A(name##l) +B (cosh) +B (exp) +B (exp10) +B (exp2) +B (expm1) +B (gamma) +B (j0) +B (j1) +B (lgamma) +B (pow10) +B (sinh) +B (tgamma) +B (y0) +B (y1) +B (acos) +B (acosh) +B (asin) +B (asinh) +B (atan) +B (atanh) +B (cbrt) +B (cos) +B (erf) +B (erfc) +B (log) +B (log10) +B (log2) +B (log1p) +B (sin) +B (tan) +B (tanh) +B (sqrt) +B (fabs) +B (logb) diff --git a/SingleSource/Regression/C/gcc-dg/pr89521-1.c b/SingleSource/Regression/C/gcc-dg/pr89521-1.c new file mode 100644 index 0000000000..ebf2c5932c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89521-1.c @@ -0,0 +1,13 @@ +/* PR c/89521 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -w" } */ + +#define A(name) __typeof (__builtin_##name (0)) name (); long name##1 () { return name (1); } +#define B(name) A(name) A(name##f) A(name##l) +B (ceil) +B (floor) +B (round) +B (trunc) +B (nearbyint) +B (rint) +B (logb) diff --git a/SingleSource/Regression/C/gcc-dg/pr89521-2.c b/SingleSource/Regression/C/gcc-dg/pr89521-2.c new file mode 100644 index 0000000000..5e37c918fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89521-2.c @@ -0,0 +1,42 @@ +/* PR c/89521 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -w" } */ + +#define A(name) __typeof (__builtin_##name (0)) name (); \ + float name##1 () { return name (1); } \ + double name##2 () { return name (1); } +#define B(name) A(name) A(name##l) +B (cosh) +B (exp) +B (exp10) +B (exp2) +B (expm1) +B (gamma) +B (j0) +B (j1) +B (lgamma) +B (pow10) +B (sinh) +B (tgamma) +B (y0) +B (y1) +B (acos) +B (acosh) +B (asin) +B (asinh) +B (atan) +B (atanh) +B (cbrt) +B (cos) +B (erf) +B (erfc) +B (log) +B (log10) +B (log2) +B (log1p) +B (sin) +B (tan) +B (tanh) +B (sqrt) +B (fabs) +B (logb) diff --git a/SingleSource/Regression/C/gcc-dg/pr89525.c b/SingleSource/Regression/C/gcc-dg/pr89525.c new file mode 100644 index 0000000000..099e174875 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89525.c @@ -0,0 +1,11 @@ +/* PR c/89525 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +double sqrt (); /* { dg-bogus "declared here" } */ + +void +foo (void) +{ + sqrt (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89570.c b/SingleSource/Regression/C/gcc-dg/pr89570.c new file mode 100644 index 0000000000..cae5a25c7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89570.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/89570 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vectorize -fno-trapping-math -fno-tree-dce -fno-tree-dominator-opts" } */ +/* { dg-additional-options "-mvsx" { target powerpc_vsx_ok } } */ + +void +foo (double *x, double *y, double *z) +{ + int i; + for (i = 0; i < 7; i += 2) + { + x[i] = y[i] ? z[i] / 2.0 : z[i]; + x[i + 1] = y[i + 1] ? z[i + 1] / 2.0 : z[i + 1]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89590.c b/SingleSource/Regression/C/gcc-dg/pr89590.c new file mode 100644 index 0000000000..441b0f9c47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89590.c @@ -0,0 +1,11 @@ +/* PR middle-end/89590 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -w" } */ + +void free (void *); + +void +foo (void) +{ + ((void (*)()) free) (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89594.c b/SingleSource/Regression/C/gcc-dg/pr89594.c new file mode 100644 index 0000000000..4039f735af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89594.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-if-convert -ftree-loop-vectorize -fno-tree-ch" } */ + +int h3; + +void +in (void) +{ + long int zr; + int ee = 0; + + for (zr = 0; zr < 1; zr = h3) + { + ee = !!h3 ? zr : 0; + + h3 = 0; + while (h3 < 0) + h3 = 0; + } + + h3 = 0; + while (h3 < 1) + h3 = !!ee ? (!!h3 + 1) : 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89679.c b/SingleSource/Regression/C/gcc-dg/pr89679.c new file mode 100644 index 0000000000..0d6e2d2c87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89679.c @@ -0,0 +1,26 @@ +/* PR rtl-optimization/89679 */ +/* { dg-do run } */ +/* { dg-options "-Og -frerun-cse-after-loop -fno-tree-fre" } */ + +unsigned short g; + +void +foo (unsigned long long x) +{ + if (x != 0xffff) + __builtin_abort (); +} + +int +main () +{ +#if __SIZEOF_SHORT__ == 2 && __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8 + unsigned short d = 0; + unsigned long long x, c = ~0; + c = c >> d; + __builtin_memset (&d, c, 2); + x = d + g; + foo (x); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89689.c b/SingleSource/Regression/C/gcc-dg/pr89689.c new file mode 100644 index 0000000000..778643ab7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89689.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +#include +#include +#include + +static inline __attribute__((__artificial__)) void *a(char *c, const char *d, long n) +{ + return __builtin___memcpy_chk(c, d, n, __builtin_object_size(c, 0)); +} +typedef struct { + char *data; + int len; +} sb_t; +const char __sb_slop[1]; +static void inline set0(sb_t *c) +{ + if (c->data != __sb_slop) + c->data[0] = 0; + else + assert (c->data[0] == 0); +} +char buf[5]; +sb_t l = { + .data = buf, + .len = 0 +}; +void o() +{ + char *data = "abcd"; + sb_t h = l; + set0(&h); + a(h.data, data, strlen(data)); + printf("%s\n", h.data); + printf("%d\n", h.data == __sb_slop); + printf("%d\n", h.data == buf); + set0(&h); +} +int main(void) { + o(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89734.c b/SingleSource/Regression/C/gcc-dg/pr89734.c new file mode 100644 index 0000000000..4dc27548ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89734.c @@ -0,0 +1,12 @@ +/* PR c/89734 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef const int CI; +typedef _Atomic int AI; + +CI foo (void); +const int foo (void); + +AI baz (void); +_Atomic int baz (void); diff --git a/SingleSource/Regression/C/gcc-dg/pr89737.c b/SingleSource/Regression/C/gcc-dg/pr89737.c new file mode 100644 index 0000000000..7dc48cdce9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89737.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target indirect_jumps } */ +/* { dg-require-effective-target label_values } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +int a, b; + +void c() { + &&d; + void *e = &&f, *g = &&h; +f: + __attribute__((hot)) h : __attribute__((cold)) for (; a;) goto *g; +d: + for (; b;) + goto *e; +} + +/* { dg-final { scan-tree-dump-times "predicted to even probabilities" 4 "profile_estimate"} } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr89795.c b/SingleSource/Regression/C/gcc-dg/pr89795.c new file mode 100644 index 0000000000..4ceaa433f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89795.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/89795 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-dce -fno-forward-propagate -fno-sched-pressure" } */ + +unsigned char a; +unsigned b, c, d; + +int +main () +{ +#if __CHAR_BIT__ == 8 + unsigned x; + int e, f; + unsigned char g; + e = __builtin_bswap32 (a); + f = __builtin_ffs (~(unsigned short) e); + a = __builtin_mul_overflow ((unsigned char) 0xf7, f, &g); + a |= __builtin_sub_overflow_p (c, 0, (unsigned char) 0); + d = g + b; + x = d; + if (x != 0xf7) + __builtin_abort (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr89984.c b/SingleSource/Regression/C/gcc-dg/pr89984.c new file mode 100644 index 0000000000..471fe92bc8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr89984.c @@ -0,0 +1,20 @@ +/* PR target/89984 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +__attribute__((noipa)) float +foo (float x, float y) +{ + return x * __builtin_copysignf (1.0f, y) + y; +} + +int +main () +{ + if (foo (1.25f, 7.25f) != 1.25f + 7.25f + || foo (1.75f, -3.25f) != -1.75f + -3.25f + || foo (-2.25f, 7.5f) != -2.25f + 7.5f + || foo (-3.0f, -4.0f) != 3.0f + -4.0f) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90010.c b/SingleSource/Regression/C/gcc-dg/pr90010.c new file mode 100644 index 0000000000..5cd5dd2dee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90010.c @@ -0,0 +1,27 @@ +/* PR c++/90010 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +char b[4096] = "abc"; +void bar (char *); + +void +foo () +{ + char d[4096]; + __builtin_snprintf (d, sizeof d, "%sfoobarbazquxquuxquuzthudfred", b); /* { dg-warning "'foobarbazquxquuxquuzthudfred' directive output may be truncated writing 28 bytes into a region of size between 1 and 4096" } */ + /* { dg-message "'__builtin_snprintf' output between 29 and 4124 bytes into a destination of size 4096" "" { target *-*-* } .-1 } */ + bar (d); + __builtin_snprintf (d, sizeof d, "%sfoobarbazquxquuxquuzcorgefred", b); /* { dg-warning "'foobarbazquxquuxquuzcorgefred' directive output may be truncated writing 29 bytes into a region of size between 1 and 4096" } */ + /* { dg-message "'__builtin_snprintf' output between 30 and 4125 bytes into a destination of size 4096" "" { target *-*-* } .-1 } */ + bar (d); + __builtin_snprintf (d, sizeof d, "%sfoobarbazquxquuxquuzcorgewaldo", b); /* { dg-warning "'foobarbazquxquuxquuzcorgewaldo' directive output may be truncated writing 30 bytes into a region of size between 1 and 4096" } */ + /* { dg-message "'__builtin_snprintf' output between 31 and 4126 bytes into a destination of size 4096" "" { target *-*-* } .-1 } */ + bar (d); + __builtin_snprintf (d, sizeof d, "%sfoobarbazquxquuxquuzcorgegarply", b); /* { dg-warning "'foobarbazquxquuxquuzcorgegarply' directive output may be truncated writing 31 bytes into a region of size between 1 and 4096" } */ + /* { dg-message "'__builtin_snprintf' output between 32 and 4127 bytes into a destination of size 4096" "" { target *-*-* } .-1 } */ + bar (d); + __builtin_snprintf (d, sizeof d, "%sfoobarfredquxquuxquuzcorgegarply", b); /* { dg-warning "'foobarfredquxquuxquuzcorgega\.\.\.' directive output may be truncated writing 32 bytes into a region of size between 1 and 4096" } */ + /* { dg-message "'__builtin_snprintf' output between 33 and 4128 bytes into a destination of size 4096" "" { target *-*-* } .-1 } */ + bar (d); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90037.c b/SingleSource/Regression/C/gcc-dg/pr90037.c new file mode 100644 index 0000000000..70f9ad2f83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90037.c @@ -0,0 +1,161 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wnull-dereference" } */ + +typedef __SIZE_TYPE__ size_t; +typedef unsigned long int uintmax_t; + +struct group +{ + char *gr_name; + char *gr_passwd; + unsigned gr_gid; + char **gr_mem; +}; + +struct passwd +{ + char *pw_name; + char *pw_passwd; + + unsigned pw_uid; + unsigned pw_gid; + char *pw_gecos; + char *pw_dir; + char *pw_shell; +}; + +extern struct group *getgrnam (const char *); +extern struct group *getgrgid (unsigned); +extern void endgrent (void); +extern struct passwd *getpwnam (const char *); +extern void endpwent (void); +extern unsigned long int strtoul (const char *__restrict, + char **__restrict, int); + +char const * +parse_with_separator (char const *spec, char const *separator, + unsigned *uid, unsigned *gid, + char **username, char **groupname) +{ + static const char *E_invalid_user = "invalid user"; + static const char *E_invalid_group = "invalid group"; + static const char *E_bad_spec = "invalid spec"; + const char *error_msg; + struct passwd *pwd; + struct group *grp; + char *u; + char const *g; + char *gname = 0; + unsigned unum = *uid; + unsigned gnum = gid ? *gid : (unsigned)-1; + + error_msg = 0; + + if (username) + *username = 0; + + if (groupname) + *groupname = 0; + + u = 0; + if (separator == 0) + { + if (*spec) + u = __builtin_strdup (spec); + } + else + { + size_t ulen = separator - spec; + if (ulen != 0) + { + u = __builtin_malloc (ulen + 1); + __builtin_memcpy (u, spec, ulen + 1); + u[ulen] = '\0'; + } + } + + g = (separator == 0 || *(separator + 1) == '\0' ? 0 : separator + 1); + + if (u != 0) + { + pwd = (*u == '+' ? 0 : getpwnam (u)); + if (pwd == 0) + { + _Bool use_login_group = (separator != 0 && g == 0); + if (use_login_group) + { + error_msg = E_bad_spec; + } + else + { + unsigned long int tmp; + tmp = strtoul (u, 0, 10); + if (tmp <= (1ul << 31) && (unsigned) tmp != (unsigned) -1) + unum = tmp; + else + error_msg = E_invalid_user; + } + } + else + { + unum = pwd->pw_uid; + if (g == 0 && separator != 0) + { + char buf[128]; + gnum = pwd->pw_gid; + grp = getgrgid (gnum); + + gname = buf; + + if (grp) + gname = __builtin_strdup (grp->gr_name); + else + __builtin_snprintf (buf, sizeof(buf), "%ju", (uintmax_t)gnum); + + endgrent (); + } + } + + endpwent (); + } + + if (g != 0 && error_msg == 0) + { + grp = (*g == '+' ? 0 : getgrnam (g)); + if (grp == 0) + { + unsigned long int tmp = strtoul (g, 0, 10); + + if (tmp <= (1ul << 31) && (unsigned) tmp != (unsigned) -1) + gnum = tmp; + else + error_msg = E_invalid_group; + } + else + gnum = grp->gr_gid; + endgrent (); + gname = __builtin_strdup (g); + } + + if (error_msg == 0) + { + *uid = unum; + if (gid) + *gid = gnum; + if (username) + { + *username = u; + u = 0; + } + if (groupname) + { + *groupname = gname; + gname = 0; + } + } + + __builtin_free (u); + __builtin_free (gname); + return error_msg ? error_msg : 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr90082.c b/SingleSource/Regression/C/gcc-dg/pr90082.c new file mode 100644 index 0000000000..a8d76bbc78 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90082.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/90082 */ +/* { dg-do compile } */ +/* { dg-require-effective-target nonlocal_goto } */ +/* { dg-require-effective-target label_values } */ +/* { dg-options "-O1 -fnon-call-exceptions -ftrapv" } */ + +void *buf[5]; + +void +foo (int a) +{ + if (__builtin_setjmp (buf) == 0) + __asm__ ("" : : "n" (a * 2)); /* { dg-error "impossible constraint in 'asm'" } */ + /* { dg-warning "'asm' operand 0 probably does not match constraints" "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90095-1.c b/SingleSource/Regression/C/gcc-dg/pr90095-1.c new file mode 100644 index 0000000000..03968ba741 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90095-1.c @@ -0,0 +1,18 @@ +/* PR middle-end/90095 */ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-bit-ccp" } */ + +unsigned long long a; +unsigned int b; + +int +main () +{ + unsigned int c = 255, d = c |= b; + if (__CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4 || __SIZEOF_LONG_LONG__ != 8) + return 0; + d = __builtin_mul_overflow (-(unsigned long long) d, (unsigned char) - c, &a); + if (d != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90095-2.c b/SingleSource/Regression/C/gcc-dg/pr90095-2.c new file mode 100644 index 0000000000..43f67e1273 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90095-2.c @@ -0,0 +1,5 @@ +/* PR middle-end/90095 */ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-bit-ccp -fno-split-wide-types" } */ + +#include "pr90095-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr90248.c b/SingleSource/Regression/C/gcc-dg/pr90248.c new file mode 100644 index 0000000000..2c89e1e4a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90248.c @@ -0,0 +1,73 @@ +/* PR tree-optimization/90248 */ +/* { dg-do run } */ +/* { dg-options "-Ofast" } */ + +volatile float b1 = -1.f; +volatile float b2 = 0.f; + +__attribute__((noipa)) float +f1 (float x) +{ + return x > 0 ? 1.f : -1.f; +} + +__attribute__((noipa)) float +f2 (float x) +{ + return x >= 0 ? 1.f : -1.f; +} + +__attribute__((noipa)) float +f3 (float x) +{ + return x < 0 ? 1.f : -1.f; +} + +__attribute__((noipa)) float +f4 (float x) +{ + return x <= 0 ? 1.f : -1.f; +} + +__attribute__((noipa)) float +f5 (float x) +{ + return x > 0 ? -1.f : 1.f; +} + +__attribute__((noipa)) float +f6 (float x) +{ + return x >= 0 ? -1.f : 1.f; +} + +__attribute__((noipa)) float +f7 (float x) +{ + return x < 0 ? -1.f : 1.f; +} + +__attribute__((noipa)) float +f8 (float x) +{ + return x <= 0 ? -1.f : 1.f; +} + +int +main () +{ + float a = 0.f; + float b = b1 * b2; + float c = 2.f; + float d = -2.f; + if (f1 (a) != -1.f || f1 (b) != -1.f || f1 (c) != 1.f || f1 (d) != -1.f + || f2 (a) != 1.f || f2 (b) != 1.f || f2 (c) != 1.f || f2 (d) != -1.f + || f3 (a) != -1.f || f3 (b) != -1.f || f3 (c) != -1.f || f3 (d) != 1.f + || f4 (a) != 1.f || f4 (b) != 1.f || f4 (c) != -1.f || f4 (d) != 1.f + || f5 (a) != 1.f || f5 (b) != 1.f || f5 (c) != -1.f || f5 (d) != 1.f + || f6 (a) != -1.f || f6 (b) != -1.f || f6 (c) != -1.f || f6 (d) != 1.f + || f7 (a) != 1.f || f7 (b) != 1.f || f7 (c) != 1.f || f7 (d) != -1.f + || f8 (a) != -1.f || f8 (b) != -1.f || f8 (c) != 1.f || f8 (d) != -1.f) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90263.c b/SingleSource/Regression/C/gcc-dg/pr90263.c new file mode 100644 index 0000000000..3222a5331c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90263.c @@ -0,0 +1,12 @@ +/* PR middle-end/90263 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target glibc } */ + +int *f (int *p, int *q, long n) +{ + return __builtin_mempcpy (p, q, n); +} + +/* { dg-final { scan-assembler "mempcpy" { target { i?86-*-* x86_64-*-* } } } } */ +/* { dg-final { scan-assembler "memcpy" { target { ! { i?86-*-* x86_64-*-* } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr90648.c b/SingleSource/Regression/C/gcc-dg/pr90648.c new file mode 100644 index 0000000000..bf1fa98947 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90648.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +extern double copysign (); +double foo (double x) +{ + return x * copysign (); /* { dg-warning "too few arguments" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90726.c b/SingleSource/Regression/C/gcc-dg/pr90726.c new file mode 100644 index 0000000000..92987de1c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90726.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O2" } */ + +int __GIMPLE (ssa,guessed_local(12348030),startwith("fix_loops")) +un (int dd) +{ + int s2; + int q8; + int nz; + + __BB(2,guessed_local(12348030)): + goto __BB3(guessed(134217728)); + + __BB(3,loop_header(1),guessed_local(37044096)): + nz_7 = __PHI (__BB2: 0, __BB5: nz_10); + q8_13 = dd_9(D) * dd_9(D); + q8_17 = q8_13 * q8_13; + q8_21 = q8_17 * q8_17; + q8_25 = q8_21 * q8_21; + q8_29 = q8_25 * q8_25; + q8_33 = q8_29 * q8_29; + q8_37 = q8_33 * q8_33; + q8_41 = q8_37 * q8_37; + q8_45 = q8_41 * q8_41; + q8_49 = q8_45 * q8_45; + q8_53 = q8_49 * q8_49; + q8_57 = q8_53 * q8_53; + q8_61 = q8_57 * q8_57; + q8_65 = q8_61 * q8_61; + q8_69 = q8_65 * q8_65; + q8_73 = q8_69 * q8_69; + q8_77 = q8_73 * q8_73; + q8_81 = q8_77 * q8_77; + q8_85 = q8_81 * q8_81; + q8_89 = q8_85 * q8_85; + q8_93 = q8_89 * q8_89; + q8_97 = q8_93 * q8_93; + q8_101 = q8_97 * q8_97; + q8_105 = q8_101 * q8_101; + q8_109 = q8_105 * q8_105; + q8_113 = q8_109 * q8_109; + q8_117 = q8_113 * q8_113; + q8_121 = q8_117 * q8_117; + nz_10 = nz_7 + 1; + if (nz_10 != 3) + goto __BB5(guessed(89478485)); + else + goto __BB4(guessed(44739243)); + + __BB(5,guessed_local(24696064)): + goto __BB3(precise(134217728)); + + __BB(4,guessed_local(12348031)): + return q8_121; + +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90733.c b/SingleSource/Regression/C/gcc-dg/pr90733.c new file mode 100644 index 0000000000..7d2a7fb559 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90733.c @@ -0,0 +1,22 @@ +/* PR debug/90733 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -w" } */ + +struct S { unsigned a : 1; }; +union U { struct S b; _Complex unsigned c; }; + +union U +foo (union U d) +{ + union U e = d; + return e; +} + +int +bar (void) +{ + union U x, y; + x.c = x.b.a; + y = foo (x); + return x.c != y.c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90756.c b/SingleSource/Regression/C/gcc-dg/pr90756.c new file mode 100644 index 0000000000..a4ba64acd7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90756.c @@ -0,0 +1,27 @@ +/* PR rtl-optimization/90756 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi" } */ +/* { dg-additional-options "-mno-sse" { target ia32 } } */ +/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */ + +typedef float B __attribute__((vector_size(4 * sizeof (float)))); +typedef unsigned long long C __attribute__((vector_size(4 * sizeof (long long)))); +typedef short D __attribute__((vector_size(4 * sizeof (short)))); +B z; +void foo (C); +C bar (D); +B baz (); +D qux (B); + +void +quux (int x) +{ + B n = z, b = z; + while (1) + switch (x) + { + case 0: n = baz (); /* FALLTHRU */ + case 1: { B o = n; n = b; b = o; } /* FALLTHRU */ + case 2: { D u = qux (b); C v = bar (u); foo (v); } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90760.c b/SingleSource/Regression/C/gcc-dg/pr90760.c new file mode 100644 index 0000000000..6092a4e98c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90760.c @@ -0,0 +1,9 @@ +/* PR c/90760 */ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-require-named-sections "" } */ + +void bar (void) {} +void foo (void) __attribute__ ((alias ("bar"))); /* { dg-error "section of alias 'foo' must match section of its target" } */ +void foo (void) __attribute__ ((section ("baz"))); +void qux (void) __attribute__ ((alias ("bar"), section ("baz"))); /* { dg-error "section of alias 'qux' must match section of its target" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr90838.c b/SingleSource/Regression/C/gcc-dg/pr90838.c new file mode 100644 index 0000000000..759059683a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90838.c @@ -0,0 +1,85 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop2-details" } */ +/* { dg-additional-options "-mbmi" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } */ +/* { dg-additional-options "-march=rv64gc_zbb" { target { rv64 } } } */ +/* { dg-additional-options "-march=rv32gc_zbb" { target { rv32 } } } */ +/* { dg-require-effective-target int32plus } */ + +int ctz1 (unsigned x) +{ + static const char table[32] = "\x00\x01\x1c\x02\x1d\x0e\x18\x03\x1e\x16\x14" + "\x0f\x19\x11\x04\b\x1f\x1b\r\x17\x15\x13\x10\x07\x1a\f\x12\x06\v\x05\n\t"; + + return table[((unsigned)((x & -x) * 0x077CB531U)) >> 27]; +} + +int ctz2 (unsigned x) +{ +#define u 0 + static short table[64] = + { + 32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14, + 10, 4, u, u, 8, u, u,25, u, u, u, u, u,21,27,15, + 31,11, 5, u, u, u, u, u, 9, u, u,24, u, u,20,26, + 30, u, u, u, u,23, u,19,29, u,22,18,28,17,16, u + }; + + x = (x & -x) * 0x0450FBAF; + return table[x >> 26]; +} + +int ctz3 (unsigned x) +{ + static int table[32] = + { + 0, 1, 2,24, 3,19, 6,25, 22, 4,20,10,16, 7,12,26, + 31,23,18, 5,21, 9,15,11,30,17, 8,14,29,13,28,27 + }; + + if (x == 0) return 32; + x = (x & -x) * 0x04D7651F; + return table[x >> 27]; +} + +static const unsigned long long magic = 0x03f08c5392f756cdULL; + +static const char table[64] = { + 0, 1, 12, 2, 13, 22, 17, 3, + 14, 33, 23, 36, 18, 58, 28, 4, + 62, 15, 34, 26, 24, 48, 50, 37, + 19, 55, 59, 52, 29, 44, 39, 5, + 63, 11, 21, 16, 32, 35, 57, 27, + 61, 25, 47, 49, 54, 51, 43, 38, + 10, 20, 31, 56, 60, 46, 53, 42, + 9, 30, 45, 41, 8, 40, 7, 6, +}; + +int ctz4 (unsigned long x) +{ + unsigned long lsb = x & -x; + return table[(lsb * magic) >> 58]; +} + +/* { dg-final { scan-tree-dump-times {= \.CTZ} 4 "forwprop2" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-assembler-times "tzcntq\t" 1 { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-assembler-times "tzcntl\t" 3 { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-assembler-times "andl\t" 2 { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-assembler-not "negq" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-assembler-not "imulq" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-assembler-not "shrq" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ + +/* { dg-final { scan-tree-dump-times {= \.CTZ} 4 "forwprop2" { target aarch64*-*-* } } } */ +/* { dg-final { scan-assembler-times "clz\t" 4 { target aarch64*-*-* } } } */ +/* { dg-final { scan-assembler-times "and\t" 2 { target aarch64*-*-* } } } */ +/* { dg-final { scan-assembler-not "cmp\t.*0" { target aarch64*-*-* } } } */ + +/* { dg-final { scan-tree-dump-times {= \.CTZ} 4 "forwprop2" { target { rv64 } } } } */ +/* { dg-final { scan-assembler-times "ctz\t" 1 { target { rv64 } } } } */ +/* { dg-final { scan-assembler-times "ctzw\t" 3 { target { rv64 } } } } */ +/* { dg-final { scan-assembler-times "andi\t" 2 { target { rv64 } } } } */ +/* { dg-final { scan-assembler-not "mul" { target { rv64 } } } } */ + +/* { dg-final { scan-tree-dump-times {= \.CTZ} 3 "forwprop2" { target { rv32 } } } } */ +/* { dg-final { scan-assembler-times "ctz\t" 3 { target { rv32 } } } } */ +/* { dg-final { scan-assembler-times "andi\t" 1 { target { rv32 } } } } */ +/* { dg-final { scan-assembler-times "mul\t" 1 { target { rv32 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr90866-2.c b/SingleSource/Regression/C/gcc-dg/pr90866-2.c new file mode 100644 index 0000000000..6414799657 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90866-2.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/90866 - ICE in fold_binary_loc, at fold-const.c:9827 + { dg-do compile } + { dg-require-effective-target global_constructor } + { dg-options "-O2 -fsanitize=thread" } + */ + +typedef enum { a } b; +typedef struct { + int c[0]; +} d; +typedef struct { + int *data; +} e; +typedef struct { + e buffer; +} f; +int g, h; + +int i(f *j, d *k, b l, int m) { + if (l) + if (m) { + h = j->buffer.data[0]; + k->c[g] = k->c[g] * 8; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90866.c b/SingleSource/Regression/C/gcc-dg/pr90866.c new file mode 100644 index 0000000000..66c92ee782 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90866.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/90866 - ICE in fold_binary_loc, at fold-const.c:9827 + { dg-do compile } + { dg-options "-O3 -Wall -fno-tree-loop-optimize" } */ + +int a[1024], b[1024]; + +void f (void) +{ + int i = 0; + for ( ; ; i++) + { + b[16] = a[i * 16 + 10]; + b[i * 16 + 11] = a[i * 16 + 11] * 3; + b[i * 16 + 12] = a[i * 16 + 12] * 4; + b[i * 16 + 13] = a[i * 16 + 13] * 4; + b[i * 16 + 14] = a[i * 16 + 14] * 3; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90892.c b/SingleSource/Regression/C/gcc-dg/pr90892.c new file mode 100644 index 0000000000..e4b5310807 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90892.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/90892 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +const char *a = "A\0b"; + +int +main() +{ + if (__builtin_strncmp(a, "A\0", 2) != 0) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr90898.c b/SingleSource/Regression/C/gcc-dg/pr90898.c new file mode 100644 index 0000000000..e992ea34cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr90898.c @@ -0,0 +1,16 @@ +/* PR c/90898 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void *p; +int bar (void); +void baz (int *); + +void +foo (void) +{ + p = __builtin_stack_save (); + int a[(bar (), 2)]; + baz (a); + __builtin_stack_restore (p); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91014.c b/SingleSource/Regression/C/gcc-dg/pr91014.c new file mode 100644 index 0000000000..eb37b333b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91014.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* { dg-require-effective-target alloca } */ + +void foo(void) +{ + __builtin_calloc (1, 1); /* { dg-warning "ignoring return value of '__builtin_calloc' declared with attribute 'warn_unused_result'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91029.c b/SingleSource/Regression/C/gcc-dg/pr91029.c new file mode 100644 index 0000000000..4904764e1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91029.c @@ -0,0 +1,48 @@ +/* PR tree-optimization/91029 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void kill (void); +int xx; + +void f1 (int i) +{ + if ((i % 7) == 3) + { + xx = (i < 0); + if (xx) + kill (); + } +} + +void f2 (int i) +{ + if ((i % 7) > 0) + { + xx = (i < 0); + if (xx) + kill (); + } +} + +void f3 (int i) +{ + if ((i % 7) == -3) + { + xx = (i > 0); + if (xx) + kill (); + } +} + +void f4 (int i) +{ + if ((i % 7) < 0) + { + xx = (i > 0); + if (xx) + kill (); + } +} + +/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr91069.c b/SingleSource/Regression/C/gcc-dg/pr91069.c new file mode 100644 index 0000000000..fdb2cfd062 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91069.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu11" } */ + +typedef double v2df __attribute__((vector_size(2 * sizeof (double)))); +typedef long long v2di __attribute__((vector_size(2 * sizeof (long long)))); + +void foo (v2df *res, v2df *src) +{ + v2df x = *src; + *res = __builtin_shuffle ((v2df) { 1.0, 0.0 }, x, (v2di) { 1, 3 }); +} + +int main() +{ + v2df x = (v2df) { 0.0, 2.0 }; + foo (&x, &x); + if (x[0] != 0.0 || x[1] != 2.0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91134.c b/SingleSource/Regression/C/gcc-dg/pr91134.c new file mode 100644 index 0000000000..8844f42847 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91134.c @@ -0,0 +1,32 @@ +/* PR c/91134 */ +/* { dg-options "-fdiagnostics-show-caret" } */ + +struct X { int member; } x; +struct Y { struct X **x; } y; + +int +foo (void) +{ + struct X *pointer = &x; + struct Y *yp = &y; + struct X **pointerpointer = &pointer; + int i = *pointerpointer->member; /* { dg-error "'pointerpointer' is a pointer to pointer; did you mean to dereference it before applying '->' to it\\\?" } */ +/* { dg-begin-multiline-output "" } + int i = *pointerpointer->member; + ^~ + (* ) + { dg-end-multiline-output "" } */ + int j = pointer.member; /* { dg-error "'pointer' is a pointer; did you mean to use '->'\\\?" } */ +/* { dg-begin-multiline-output "" } + int j = pointer.member; + ^ + -> + { dg-end-multiline-output "" } */ + int k = yp->x->member; /* { dg-error "'yp->x' is a pointer to pointer; did you mean to dereference it before applying '->' to it\\\?" } */ +/* { dg-begin-multiline-output "" } + int k = yp->x->member; + ^~ + (* ) + { dg-end-multiline-output "" } */ + return i + j + k; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91172.c b/SingleSource/Regression/C/gcc-dg/pr91172.c new file mode 100644 index 0000000000..a38a0580f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91172.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-Werror=target-lifetime" } */ +/* { dg-warning "'-Werror\=' argument '-Werror=target-lifetime' is not valid for C" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr91181.c b/SingleSource/Regression/C/gcc-dg/pr91181.c new file mode 100644 index 0000000000..63e33626a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91181.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ +/* { dg-additional-options "-mavx" { target x86_64-*-* i?86-*-* } } */ + +enum { a, b, c }; +float *d, *e; +int f, g, h, i; +int j() +{ + float a; + for (; h; h++) + { + i = h * 4; + a = d[i + b]; + if (a) { + e[i + b] = g < d[i + b] * f * a ? g : d[i + b] * f * a; + e[i + c] = g < d[i + c] * f * a ? g : d[i + c] * f * a; + } + e[i + b] = e[i + c]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91195.c b/SingleSource/Regression/C/gcc-dg/pr91195.c new file mode 100644 index 0000000000..ea3021d014 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91195.c @@ -0,0 +1,25 @@ +/* PR middle-end/91195 */ +/* { dg-do compile } */ +/* { dg-options "-Wmaybe-uninitialized -O2" } */ + +int bar (char*); + +void +foo (char *x, char *y) +{ + char *a[2]; + int b = 0; + + if (x) + a[b++] = x; /* { dg-bogus "may be used uninitialized in this function" } */ + if (y) + a[b++] = y; + + for (int j = 0; j < 4; j++) + switch (j) + { + case 0: + if (b == 0 || bar (a[0])) + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91269.c b/SingleSource/Regression/C/gcc-dg/pr91269.c new file mode 100644 index 0000000000..8c03ba8dab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91269.c @@ -0,0 +1,70 @@ +/* PR target/91269 */ +/* Testcase by Sergei Trofimovich */ + +/* { dg-do assemble } */ +/* { dg-options "-O2 -Wno-int-conversion" } */ +/* { dg-additional-options "-fcall-used-g6 -fPIE -mcpu=niagara4" { target sparc*-*-* } } */ + +struct m; + +enum { a = 2 }; +int b[1]; +int d[2715]; +int e, f, h; +enum { i = 2 } j; +inline int c(int k) { + char *cp; + if (k >= 62 && k <= 247) + cp = b[k]; + if (cp) + return 65533; + return 2; +} +inline int g(int k) { + if (k < sizeof(d)) + return e; + return 0; +} + +int u(struct m*, char*, char*); + +int l(struct m *k, char n, long o, int *p) { + int q, flags = j, r, s, lasttwo = *p; + char inptr, outptr; + while (inptr) { + if (__builtin_expect(h, 0)) + break; + unsigned ch = inptr; + if (lasttwo) { + long need = lasttwo >> 3; + if (__builtin_expect(need > n, 0)) + break; + } else if (s == i) { + long t = c(ch); + if (t != 65533) { + int jch = g(ch); + if (jch & 8) + continue; + } + } + if (ch <= 5) + ; + else { + long t = c(ch); + if (t != 65533) + ; + else { + switch (f >> 8) + case 79: + q = f == 20308 || f == 20350; + if (q) + if (j) + r = u(k, &inptr, &outptr); + s = *p; + if (r) + if (o && flags & a) + break; + } + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91441.c b/SingleSource/Regression/C/gcc-dg/pr91441.c new file mode 100644 index 0000000000..4c785f61e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91441.c @@ -0,0 +1,11 @@ +/* PR target/91441 */ +/* { dg-do compile } */ +/* { dg-options "--param asan-stack=1 -fsanitize=kernel-address" } */ +/* { dg-skip-if "no address sanitizer" { no_fsanitize_address } } */ + +int *bar(int *); +int *f( int a) +{ + return bar(&a); +} +/* { dg-warning ".'-fsanitize=kernel-address' with stack protection is not supported without '-fasan-shadow-offset=' for this target" "" { target riscv*-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr91570.c b/SingleSource/Regression/C/gcc-dg/pr91570.c new file mode 100644 index 0000000000..03f268619e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91570.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/91570 - ICE in get_range_strlen_dynamic on + a conditional of two strings + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern char a[], b[]; + +/* Test case from comment #0 on the bug. */ + +void comment_0 (int i) +{ + a[0] = 0; + b[0] = '1'; + + const char *p = i ? b : a; + + if (__builtin_snprintf (0, 0, "%s", p) < 4) + __builtin_abort (); +} + + +/* Test case from comment #2 on the bug. */ + +void comment_2 (char *s) +{ + char *t = __builtin_strrchr (s, '/'); + __builtin_strcat (s, ".SIF"); + t = t ? t : s; + __builtin_printf ("%s", t); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91720.c b/SingleSource/Regression/C/gcc-dg/pr91720.c new file mode 100644 index 0000000000..4abdace94d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91720.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/91720 */ +/* { dg-do run } */ +/* { dg-options "-Og -fno-forward-propagate -frerun-cse-after-loop -fno-tree-fre" } */ + +unsigned a, b; + +int +main () +{ +#if __CHAR_BIT__ == 8 + unsigned c = 1; + unsigned long long d = 0; + unsigned char e = 0; + e = __builtin_sub_overflow (d, e, &a) ? 0 : 0x80; + e = e << 7 | e >> c; + __builtin_memmove (&d, &a, 2); + b = e; + if (b != 0x40) + __builtin_abort (); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91734.c b/SingleSource/Regression/C/gcc-dg/pr91734.c new file mode 100644 index 0000000000..1cc3e40ccb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91734.c @@ -0,0 +1,97 @@ +/* PR tree-optimization/91734 */ +/* { dg-do run } */ +/* { dg-add-options ieee } */ +/* { dg-additional-options "-O2 -std=gnu99" } */ + +__attribute__((noipa, optimize ("Ofast"))) int +f1 (float x) +{ + return __builtin_sqrtf (x) < __FLT_MIN__; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f2 (float x) +{ + return __builtin_sqrtf (x) < 0x1.2dd3d0p-65f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f3 (float x) +{ + return __builtin_sqrtf (x) >= 0x1.2dd3d0p-65f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f4 (float x) +{ + return __builtin_sqrtf (x) >= 0x1.5642e6p+54f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f5 (float x) +{ + return __builtin_sqrtf (x) > 0x1.5642e6p+54f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f6 (float x) +{ + return __builtin_sqrtf (x) < 0x1.4da1cp-19f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f7 (float x) +{ + return __builtin_sqrtf (x) <= 0x1.4da1cp-19f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f8 (float x) +{ + return __builtin_sqrtf (x) < 0x1.50cb62p-65f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f9 (float x) +{ + return __builtin_sqrtf (x) <= 0x1.4fc00cp-73f; +} + +__attribute__((noipa, optimize ("Ofast"))) int +f10 (float x) +{ + return __builtin_sqrtf (x) < 0x1.001002p+0f; +} + +int +main () +{ + if (__FLT_RADIX__ != 2 + || __FLT_MANT_DIG__ != 24 + || __FLT_MIN_EXP__ != -125 + || __FLT_MAX_EXP__ != 128 + || __FLT_HAS_DENORM__ != 1 + || __FLT_HAS_INFINITY__ != 1) + return 0; + if (!f1 (0.0f) || f1 (0x1.0p-149f)) + __builtin_abort (); + if (!f2 (0x1.63dbc0p-130f)) + __builtin_abort (); + if (f3 (0x1.63dbc0p-130f)) + __builtin_abort (); + if (!f4 (0x1.c996d0p+108f) || !f4 (0x1.c996cep+108f) || f4 (0x1.c996ccp+108f)) + __builtin_abort (); + if (f5 (0x1.c996d0p+108f) || f5 (0x1.c996d2p+108f) || !f5 (0x1.c996d4p+108f)) + __builtin_abort (); + if (!f6 (0x1.b2ce3p-38f) || f6 (0x1.b2ce32p-38f) || f6 (0x1.b2ce34p-38f)) + __builtin_abort (); + if (!f7 (0x1.b2ce3p-38f) || !f7 (0x1.b2ce34p-38f) || !f7 (0x1.b2ce36p-38f) || f7 (0x1.b2ce38p-38f)) + __builtin_abort (); + if (!f8 (0x1.bb166p-130f) || !f8 (0x1.bb168p-130f) || f8 (0x1.bb16ap-130f) || f8 (0x1.bb16cp-130f)) + __builtin_abort (); + if (!f9 (0x1.8p-146f) || !f9 (0x1.ap-146f) || f9 (0x1.cp-146f) || f9 (0x1.ep-146f)) + __builtin_abort (); + if (f10 (0x1.002004p+0f)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91860-1.c b/SingleSource/Regression/C/gcc-dg/pr91860-1.c new file mode 100644 index 0000000000..e715040e33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91860-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-Og -fipa-cp -g --param=max-combine-insns=3" } */ + +char a; +int b; + +static void +bar (short d) +{ + d <<= __builtin_sub_overflow (0, d, &a); + b = __builtin_bswap16 (~d); +} + +void +foo (void) +{ + bar (21043); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91860-2.c b/SingleSource/Regression/C/gcc-dg/pr91860-2.c new file mode 100644 index 0000000000..7b44e648ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91860-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Og -fexpensive-optimizations -fno-tree-fre -g --param=max-combine-insns=4" } */ + +unsigned a, b, c; +void +foo (void) +{ + unsigned short e; + __builtin_mul_overflow (0, b, &a); + __builtin_sub_overflow (59347, 9, &e); + e <<= a & 5; + c = e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91860-3.c b/SingleSource/Regression/C/gcc-dg/pr91860-3.c new file mode 100644 index 0000000000..2b488cc904 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91860-3.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Og -g2 --param=max-combine-insns=3" } */ + +int a, b; + +void +foo (void) +{ + unsigned short d = 46067; + int e = e; + d <<= __builtin_mul_overflow (~0, e, &a); + d |= -68719476735; + b = d; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr91860-4.c b/SingleSource/Regression/C/gcc-dg/pr91860-4.c new file mode 100644 index 0000000000..36f2bd55c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91860-4.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-O2 -g" } */ + +typedef unsigned char u8; +typedef unsigned int u32; +typedef unsigned __int128 u128; + +u32 b, c; + +static inline +u128 bar (u8 d, u128 e) +{ + __builtin_memset (11 + (char *) &e, b, 1); + d <<= e & 7; + d = d | d > 0; + return d + e; +} + +void +foo (void) +{ + c = bar (~0, 5); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr91885.c b/SingleSource/Regression/C/gcc-dg/pr91885.c new file mode 100644 index 0000000000..35be32be55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr91885.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fprofile-generate" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +typedef signed long long int __int64_t; +typedef unsigned long long int __uint64_t; +typedef __int64_t int64_t; +typedef __uint64_t uint64_t; +inline void +BLI_endian_switch_int64 (int64_t *val) +{ + uint64_t tval = *val; + *val = ((tval >> 56)) | ((tval << 40) & 0x00ff000000000000ll) + | ((tval << 24) & 0x0000ff0000000000ll) + | ((tval << 8) & 0x000000ff00000000ll) + | ((tval >> 8) & 0x00000000ff000000ll) + | ((tval >> 24) & 0x0000000000ff0000ll) + | ((tval >> 40) & 0x000000000000ff00ll) | ((tval << 56)); +} +typedef struct anim_index_entry +{ + unsigned long long seek_pos_dts; + unsigned long long pts; +} anim_index_entry; +extern struct anim_index_entry * +MEM_callocN (int); +struct anim_index +{ + int num_entries; + struct anim_index_entry *entries; +}; +struct anim_index * +IMB_indexer_open (const char *name) +{ + char header[13]; + struct anim_index *idx; + int i; + idx->entries = MEM_callocN (8); + if (((1 == 0) != (header[8] == 'V'))) + { + for (i = 0; i < idx->num_entries; i++) + { + BLI_endian_switch_int64 ((int64_t *) &idx->entries[i].seek_pos_dts); + BLI_endian_switch_int64 ((int64_t *) &idx->entries[i].pts); + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92115.c b/SingleSource/Regression/C/gcc-dg/pr92115.c new file mode 100644 index 0000000000..ae506d4508 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92115.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/92115 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fexceptions -ffinite-math-only -fnon-call-exceptions -fsignaling-nans -fno-signed-zeros" } */ + +void +foo (double x) +{ + if (x == 0.0 && !__builtin_signbit (x)) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92162.c b/SingleSource/Regression/C/gcc-dg/pr92162.c new file mode 100644 index 0000000000..ed82595a75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92162.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ + +short int s8; + +void __attribute__ ((simd)) +gn (void) +{ + s8 = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92260.c b/SingleSource/Regression/C/gcc-dg/pr92260.c new file mode 100644 index 0000000000..3dd34763b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92260.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +extern int abs(int); +int e(const unsigned char *g, long h, unsigned char m) +{ + int i = 0; + for (int j = 0; j < h; j++) + { + for (int k = 0; k < 4; k++) + i += abs(g[k] - m); + g += h; + } + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92263.c b/SingleSource/Regression/C/gcc-dg/pr92263.c new file mode 100644 index 0000000000..a79dfd1e35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92263.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-dce -fno-tree-forwprop -Os -ffloat-store" } */ + +extern long double cabsl (_Complex long double); + +typedef struct { + int nsant, nvqd; + _Complex long double *vqd; +} vsorc_t; +vsorc_t vsorc; + +void foo(int next_job, int ain_num, int iped, long t) { + long double zpnorm; + + while (!next_job) + if (ain_num) + { + if (iped == 1) + zpnorm = 0.0; + int indx = vsorc.nvqd-1; + vsorc.vqd[indx] = t*1.0fj; + if (cabsl(vsorc.vqd[indx]) < 1.e-20) + vsorc.vqd[indx] = 0.0fj; + zpnorm = t; + if (zpnorm > 0.0) + iped = vsorc.nsant; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92301.c b/SingleSource/Regression/C/gcc-dg/pr92301.c new file mode 100644 index 0000000000..3ade201ad9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92301.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +unsigned int m; + +#define N 128 +unsigned int a[N]; + +unsigned int +__attribute__((noipa)) +df_count_refs (_Bool include_defs) +{ + int size = 0; + + for (unsigned int regno = 0; regno < m; regno++) + if (include_defs) + size += a[regno]; + return size; +} + +int main(int argc, char **argv) +{ + for (unsigned i = 0; i < N; i++) + a[i] = i; + + if (argc < 2) + m = 17; + + unsigned int r = df_count_refs(1); + __builtin_printf ("r: %d\n", r); + if (r != 136) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92430.c b/SingleSource/Regression/C/gcc-dg/pr92430.c new file mode 100644 index 0000000000..915606893b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92430.c @@ -0,0 +1,25 @@ +// PR rtl-optimization/92430 +// { dg-do compile } +// { dg-options "-Os -fno-if-conversion -fno-tree-dce -fno-tree-loop-optimize -fno-tree-vrp" } + +int eb, ko; + +void +e9 (int pe, int lx) +{ + int ir; + + for (ir = 0; ir < 1; ++ir) + { + for (ko = 0; ko < 1; ++ko) + { + for (eb = 0; eb < 1; ++eb) + ko += pe; + + for (ko = 0; ko < 1; ++ko) + ; + } + + pe = ir = lx; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92493.c b/SingleSource/Regression/C/gcc-dg/pr92493.c new file mode 100644 index 0000000000..d301300c90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92493.c @@ -0,0 +1,29 @@ +/* PR middle-end/92493 - ICE in get_origin_and_offset at gimple-ssa-sprintf.c + { dg-do compile } + { dg-options "-O3 -Wall" } */ + +struct A +{ + int i; + char a[2]; +} *p; + +struct B +{ + short j; + struct A a; +} b; + +void warn (int j) +{ + struct A *q = &b.a; + p = q + j; + __builtin_snprintf (p->a, 8, "%s", p->a); // { dg-warning "\\\[-Wrestrict" } +} + +void nowarn (char *d, int j) +{ + struct A *q = &b.a; + p = q + j; + __builtin_snprintf (d, 8, "%s", p->a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92510.c b/SingleSource/Regression/C/gcc-dg/pr92510.c new file mode 100644 index 0000000000..d468586c0f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92510.c @@ -0,0 +1,16 @@ +/* PR rtl-optimization/92510 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-loop-vectorize -fno-forward-propagate -fno-tree-scev-cprop" } */ + +int v; + +long int +foo (long int x) +{ + signed char i; + + for (i = 0; i < 8; ++i) + x |= !!v; + + return x + i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92591-1.c b/SingleSource/Regression/C/gcc-dg/pr92591-1.c new file mode 100644 index 0000000000..0f9365d06e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92591-1.c @@ -0,0 +1,11 @@ +/* PR rtl-optimization/92591 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fmodulo-sched -fweb -fno-dce -fno-ivopts -fno-sched-pressure -fno-tree-loop-distribute-patterns --param sms-dfa-history=1" } */ +/* { dg-additional-options "-mcpu=e500mc" { target { powerpc-*-* } } } */ + +void +wf (char *mr, int tc) +{ + while (tc-- > 0) + *mr++ = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92591-2.c b/SingleSource/Regression/C/gcc-dg/pr92591-2.c new file mode 100644 index 0000000000..5589fa42b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92591-2.c @@ -0,0 +1,5 @@ +/* PR rtl-optimization/92591 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fmodulo-sched -fmodulo-sched-allow-regmoves --param sms-dfa-history=8" } */ + +#include "../gcc-c-torture/execute/pr61682.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr92741.c b/SingleSource/Regression/C/gcc-dg/pr92741.c new file mode 100644 index 0000000000..8524c86557 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92741.c @@ -0,0 +1,19 @@ +/* { dg-options "-O2 -fexceptions -fnon-call-exceptions -fno-inline" } */ + +typedef int vh __attribute__ ((__vector_size__ (2 * sizeof (int)))); +typedef short int cq __attribute__ ((__vector_size__ (4 * sizeof (short int)))); + +static void +id (int *r8, vh *tu) +{ + *(vh *) r8 = *tu; +} + +void +mr (void) +{ + int r8; + cq he = { 0, }; + + id (&r8, (vh *) &he); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92768.c b/SingleSource/Regression/C/gcc-dg/pr92768.c new file mode 100644 index 0000000000..e2a3f9ccac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92768.c @@ -0,0 +1,7 @@ +/* PR tree-optimization/92768 */ +/* { dg-options "-O2 -fno-signed-zeros -fdump-tree-optimized -w -Wno-psabi" } */ + +typedef float v4sf __attribute__((vector_size(16))); +v4sf f () { return (v4sf) { 0.0, -0.0, 0.0, -0.0 }; } + +/* { dg-final { scan-tree-dump {{ 0\.0, -0\.0, 0\.0, -0\.0 }} "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr92860-2.c b/SingleSource/Regression/C/gcc-dg/pr92860-2.c new file mode 100644 index 0000000000..57af606884 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92860-2.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/92860 */ +/* { dg-do compile } */ +/* { dg-options "-Winline -O2 -fgnu89-inline" } */ + +#pragma GCC push_options +#pragma GCC optimize("-O0") +#pragma GCC pop_options + +inline int q(void); /* { dg-warning "body not available" } */ +inline int t(void) +{ + return q(); /* { dg-message "called from here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr92860.c b/SingleSource/Regression/C/gcc-dg/pr92860.c new file mode 100644 index 0000000000..74207a9d53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr92860.c @@ -0,0 +1,53 @@ +/* PR tree-optimization/92860. */ +/* Testcase derived from 20111227-1.c to ensure that REE is combining + redundant zero extends with zero extend to wider mode. */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-fdump-rtl-ree" } */ + +extern void abort (void); + +unsigned short s; +unsigned int i; +unsigned long l; +unsigned char v = -1; + +void +__attribute__ ((optimize("-O2"))) +baz() +{ +} + +void __attribute__((noinline,noclone)) +bar (int t) +{ + if (t == 2 && s != 0xff) + abort (); + if (t == 1 && i != 0xff) + abort (); + if (t == 0 && l != 0xff) + abort (); +} + +void __attribute__((noinline,noclone)) +foo (unsigned char *a, int t) +{ + unsigned char r = v; + + if (t == 2) + s = (unsigned short) r; + else if (t == 1) + i = (unsigned int) r; + else if (t == 0) + l = (unsigned long) r; + bar (t); +} + +int main(void) +{ + foo (&v, 0); + foo (&v, 1); + foo (&v, 2); + return 0; +} + +/* { dg-final { scan-rtl-dump-not "Elimination opportunities" "ree" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr93054.c b/SingleSource/Regression/C/gcc-dg/pr93054.c new file mode 100644 index 0000000000..1d4680d28e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93054.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +__attribute__ ((returns_twice)) int +bp (int); + +__attribute__ ((noreturn)) int +cb (void) +{ + return bp (cb ()); /* { dg-warning "declared .noreturn." } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93210.c b/SingleSource/Regression/C/gcc-dg/pr93210.c new file mode 100644 index 0000000000..134d32bc50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93210.c @@ -0,0 +1,66 @@ +/* PR tree-optimization/93210 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "(?:return| =) \[0-9]\[0-9a-fA-FxX]*;" 31 "optimized" } } */ + +#ifdef __SIZEOF_INT128__ +typedef unsigned __int128 L; +#else +typedef unsigned long long L; +#endif +struct S { signed char a, b; unsigned char c; }; +struct T { signed char d; struct S e[25]; signed char f; }; +union U { struct T g; L h[10]; }; +const union U u = { { 1, { { 2, 3, 4 }, { 5, 6, 7 }, { 8, 9, 10 }, + { 12, 13, 14 }, { 15, 16, 17 }, { 18, 19, 20 }, + { 22, 23, 24 }, { 25, 26, 27 }, { 28, 29, 30 }, + { 32, 33, 34 }, { 35, 36, 37 }, { 38, 39, 40 }, + { 42, 43, 44 }, { 45, 46, 47 }, { 48, 49, 50 }, + { 52, 53, 54 }, { 55, 56, 57 }, { 58, 59, 60 }, + { 62, 63, 64 }, { 65, 66, 67 }, { 68, 69, 70 }, + { 72, 73, 74 }, { 75, 76, 77 }, { 78, 79, 80 }, + { 82, 83, 84 } }, 85 } }; +const union U v = { { 1, { { 2, 3, 4 }, [1 ... 23] = { 5, 6, 7 }, + { 8, 9, 10 } }, 86 } }; +struct A { char a[5]; char b[16]; char c[7]; }; +union V { struct A d; unsigned int e[10]; }; +const union V w = { { "abcde", "ijkl", "mnopqr" } }; +#define N(n) __attribute__((noipa)) L foo##n (void) { return u.h[n]; } +#define M N(0) N(1) N(2) N(3) N(4) N(5) N(6) N(7) N(8) N(9) +M +#undef N +#define N(n) __attribute__((noipa)) L bar##n (void) { return v.h[n]; } +M +#undef N +#define N(n) __attribute__((noipa)) L baz##n (void) { return w.e[n]; } +M + +typedef L (*F) (void); +F arr[30] = { +#undef N +#define N(n) foo##n, +M +#undef N +#define N(n) bar##n, +M +#undef N +#define N(n) baz##n, +M +}; + +int +main () +{ + const union U *p = &u; + const union U *q = &v; + const union V *r = &w; + __asm ("" : "+g" (p)); + __asm ("" : "+g" (q)); + __asm ("" : "+g" (r)); + for (int i = 0; i < 10; i++) + if (arr[i] () != p->h[i] + || arr[i + 10] () != q->h[i] + || arr[i + 20] () != r->e[i]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93231.c b/SingleSource/Regression/C/gcc-dg/pr93231.c new file mode 100644 index 0000000000..cd0b3f320f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93231.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop2-details -Wno-shift-count-negative" } */ + +int ctz_ice1 (int x) +{ + static const char table[32] = + { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 + }; + + return table[((int)((x & -x) * -0x077CB531)) >> 27]; +} + +int ctz_ice2 (unsigned x) +{ + static const char table[32] = + { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 + }; + + return table[((unsigned)((x & -x) * 0x077CB531U)) >> -27]; +} + +// This should never match +int ctz_fail (unsigned x) +{ + static const unsigned short int table[32] = + u"\x0100\x021c\x0e1d\x0318\x161e\x0f14\x1119\x0804\x1b1f\x170d\x1315\x0710\x0c1a\x0612\x050b\x090a"; + + return table[((x & -x) * 0x077CB531) >> 27]; +} + +/* { dg-final { scan-tree-dump-not {= \.CTZ} "forwprop2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr93376.c b/SingleSource/Regression/C/gcc-dg/pr93376.c new file mode 100644 index 0000000000..49341ff0a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93376.c @@ -0,0 +1,20 @@ +/* PR target/93376 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Og -finline-functions-called-once" } */ + +unsigned a, b, c; + +int +bar (int x) +{ + short s = __builtin_sub_overflow (~x, 0, &b); + a = __builtin_ffsll (~x); + return __builtin_add_overflow_p (-(unsigned __int128) a, s, + (unsigned __int128) 0); +} + +void +foo (void) +{ + c = bar (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93399.c b/SingleSource/Regression/C/gcc-dg/pr93399.c new file mode 100644 index 0000000000..3d9299018b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93399.c @@ -0,0 +1,17 @@ +/* PR middle-end/93399 */ +/* { dg-do assemble } */ +/* { dg-options "-fverbose-asm -dA -g -O3" } */ + +extern inline __attribute__ ((__always_inline__, __gnu_inline__)) char * +strstr (const char *haystack, const char *needle) +{ + return __builtin_strstr (haystack, needle); +} + +int +main (int argc, const char **argv) +{ + char *substr = strstr (argv[0], "\n"); + char *another = strstr (argv[0], "\r\n"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93412.c b/SingleSource/Regression/C/gcc-dg/pr93412.c new file mode 100644 index 0000000000..ba82ae1bb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93412.c @@ -0,0 +1,15 @@ +/* PR target/93412 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Og" } */ + +unsigned char a; +int b; +unsigned c; + +int +foo (int e, int f, int g, int h, int k, int i, short j) +{ + b = __builtin_add_overflow (a, 0, &c); + b = __builtin_add_overflow_p (b, a, (unsigned __int128) 0) ? b : 0; + return e + f + g + a + h + k + i + j + c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93430.c b/SingleSource/Regression/C/gcc-dg/pr93430.c new file mode 100644 index 0000000000..92c0b9f96a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93430.c @@ -0,0 +1,33 @@ +/* PR target/93430 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mavx -mno-avx2" { target avx } } */ + +typedef double V __attribute__((vector_size (4 * sizeof (double)))); +typedef long long VI __attribute__((vector_size (4 * sizeof (long long)))); + +#if __SIZEOF_DOUBLE__ == __SIZEOF_LONG_LONG__ +void +foo (V *x, V *y) +{ + y[0] = __builtin_shuffle (x[0], x[0], (VI) { 0, 0, 0, 0 }); +} + +void +bar (V *x, V *y) +{ + y[0] = __builtin_shuffle (x[0], x[0], (VI) { 1, 1, 1, 1 }); +} + +void +baz (V *x, V *y) +{ + y[0] = __builtin_shuffle (x[0], x[0], (VI) { 2, 2, 2, 2 }); +} + +void +qux (V *x, V *y) +{ + y[0] = __builtin_shuffle (x[0], x[0], (VI) { 3, 3, 3, 3 }); +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr93454.c b/SingleSource/Regression/C/gcc-dg/pr93454.c new file mode 100644 index 0000000000..84c47cfa3e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93454.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/93454 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +#if __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8 +#define A(n) n, n + 0x01010101, n + 0x02020202, n + 0x03030303 +#define B(n) A (n), A (n + 0x04040404), A (n + 0x08080808), A (n + 0x0c0c0c0c) +#define C(n) B (n), B (n + 0x10101010), B (n + 0x20202020), B (n + 0x30303030) +#define D(n) C (n), C (n + 0x40404040), C (n + 0x80808080U), C (n + 0xc0c0c0c0U) +const unsigned int a[64] = { C (0) }; +const unsigned int b[256] = { D (0) }; +const unsigned int c[32] = { B (0), B (0x10101010) }; +const unsigned int d[16] = { B (0) }; +const unsigned int e[8] = { A (0), A (0x04040404) }; + +void +foo (void) +{ + const unsigned char *s = ((const unsigned char *) a) + 1; + const unsigned char *t = ((const unsigned char *) b) + 1; + const unsigned char *u = ((const unsigned char *) c) + 1; + const unsigned char *v = ((const unsigned char *) d) + 1; + const unsigned char *w = ((const unsigned char *) e) + 1; +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/pr93573-1.c b/SingleSource/Regression/C/gcc-dg/pr93573-1.c new file mode 100644 index 0000000000..26ec9b77d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93573-1.c @@ -0,0 +1,12 @@ +/* PR c/93573 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void bar (); + +void +foo (char a) +{ + union C { int d[100.0]; char *e; }; /* { dg-error "has non-integer type" } */ + bar ((union C) &a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93573-2.c b/SingleSource/Regression/C/gcc-dg/pr93573-2.c new file mode 100644 index 0000000000..f8809453b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93573-2.c @@ -0,0 +1,6 @@ +/* PR c/93573 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int f[100.0]; /* { dg-error "has non-integer type" } */ + /* { dg-bogus "variably modified .f. at file scope" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr93576.c b/SingleSource/Regression/C/gcc-dg/pr93576.c new file mode 100644 index 0000000000..13c34f3771 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93576.c @@ -0,0 +1,10 @@ +/* PR c/93576 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo (void) +{ + int b[] = { 0 }; + (char (*)[(1, 7, 2)]) 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93577-1.c b/SingleSource/Regression/C/gcc-dg/pr93577-1.c new file mode 100644 index 0000000000..31023d79d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93577-1.c @@ -0,0 +1,16 @@ +/* Test ICE with variable-size struct initializer: bug 93577. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (int c) +{ + struct s + { + int x[c]; + struct + { + int z; + } nest; + } v = { 1, 2 }; /* { dg-error "variable-sized object may not be initialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93577-2.c b/SingleSource/Regression/C/gcc-dg/pr93577-2.c new file mode 100644 index 0000000000..c61589ea67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93577-2.c @@ -0,0 +1,16 @@ +/* Test ICE with variable-size struct initializer: bug 93577. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (int c) +{ + struct s + { + int x[c]; + struct + { + int a, b; + } nest; + } v = { .nest.b = 1, .nest.a = 2 }; /* { dg-error "variable-sized object may not be initialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93577-3.c b/SingleSource/Regression/C/gcc-dg/pr93577-3.c new file mode 100644 index 0000000000..278146b16b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93577-3.c @@ -0,0 +1,17 @@ +/* Test ICE with variable-size struct initializer: bug 93577. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (int c) +{ + struct s + { + int a; + int x[c]; + struct + { + int a, b; + } nest; + } v = { .a = 2, .nest.b = 1 }; /* { dg-error "variable-sized object may not be initialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93577-4.c b/SingleSource/Regression/C/gcc-dg/pr93577-4.c new file mode 100644 index 0000000000..0ac117c4d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93577-4.c @@ -0,0 +1,17 @@ +/* Test ICE with variable-size struct initializer: bug 93577. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (int c) +{ + struct s + { + int a; + int x[c]; + struct + { + int a, b; + } nest; + } v[2] = { [1].nest.b = 1 }; /* { dg-error "variable-sized object may not be initialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93577-5.c b/SingleSource/Regression/C/gcc-dg/pr93577-5.c new file mode 100644 index 0000000000..68dfc1faaa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93577-5.c @@ -0,0 +1,11 @@ +/* Test ICE with designated initializer in compound literal with bad + type name (ICE seen with early version of fix for bug 93577 but not + covered in other tests). */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void * +f (void) +{ + return &(const bad_type) { .a = 0 }; /* { dg-error "unknown type name" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93577-6.c b/SingleSource/Regression/C/gcc-dg/pr93577-6.c new file mode 100644 index 0000000000..5ec668fd4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93577-6.c @@ -0,0 +1,11 @@ +/* Test ICE with designated initializer in compound literal with bad + type name (ICE seen with early version of fix for bug 93577 but not + covered in other tests). */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void * +f (void) +{ + return &(const bad_type) { [0] = 0 }; /* { dg-error "unknown type name" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93582.c b/SingleSource/Regression/C/gcc-dg/pr93582.c new file mode 100644 index 0000000000..38bf012d0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93582.c @@ -0,0 +1,57 @@ +/* PR tree-optimization/93582 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +struct S { + unsigned int s1:1; + unsigned int s2:1; + unsigned int s3:1; + unsigned int s4:1; + unsigned int s5:4; + unsigned char s6; + unsigned short s7; + unsigned short s8; +}; +struct T { + int t1; + int t2; +}; + +static inline int +bar (struct S *x) +{ + if (x->s4) + return ((struct T *)(x + 1))->t1 + ((struct T *)(x + 1))->t2; /* { dg-bogus "array subscript 1 is outside array bounds of" } */ + else + return 0; +} + +int +foo (int x, int y) +{ + struct S s; /* { dg-bogus "while referencing" } */ + s.s6 = x; + s.s7 = y & 0x1FFF; + s.s4 = 0; + return bar (&s); +} + +static inline int +qux (struct S *x) +{ + int s4 = x->s4; + if (s4) + return ((struct T *)(x + 1))->t1 + ((struct T *)(x + 1))->t2; + else + return 0; +} + +int +baz (int x, int y) +{ + struct S s; + s.s6 = x; + s.s7 = y & 0x1FFF; + s.s4 = 0; + return qux (&s); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93615.c b/SingleSource/Regression/C/gcc-dg/pr93615.c new file mode 100644 index 0000000000..2e98f5200c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93615.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ +/* { dg-require-effective-target exceptions } */ + +#include + +int +main () +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr9365-1.c b/SingleSource/Regression/C/gcc-dg/pr9365-1.c new file mode 100644 index 0000000000..1c3db2fede --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr9365-1.c @@ -0,0 +1,41 @@ +/* PR target/9365 + * Origin: marcus@mc.pp.se + * Testcase tweaked by dank@kegel.com + * gcc 3.4 coverage by joern.rennecke@superh.com + * [3.3 regression] [SH] segfault in gen_far_branch (config/sh/sh.c) + * ice-on-valid-code + * Not marked as xfail since it's a regression +*/ +/* { dg-do compile } */ +/* { dg-options "-O2 -fomit-frame-pointer" } */ + + +void foo(int n, int *p) +{ + switch(n) { + case 100: case 110: case 120: case 130: case 140: case 150: case 160: + case 200: case 210: case 220: case 230: case 240: case 250: case 260: + case 300: case 310: case 320: case 330: case 340: case 350: case 360: + case 400: case 410: case 420: case 430: case 440: case 450: case 460: + case 500: case 510: case 520: case 530: case 540: case 550: case 560: + case 600: case 610: case 620: case 630: case 640: case 650: case 660: + case 700: case 710: case 720: case 730: case 740: case 750: case 760: + case 800: case 810: case 820: case 830: case 840: case 850: case 860: + case 900: case 910: case 920: case 930: case 940: case 950: case 960: + break; + default: + *p = n; + break; + } +} + +int main(int argc, char **argv) +{ + int p; + + (void) argv; + + foo(argc, &p); + + return p; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93661.c b/SingleSource/Regression/C/gcc-dg/pr93661.c new file mode 100644 index 0000000000..bc77fcab69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93661.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +int f () +{ + unsigned x = 0xffffffff; + __builtin_memset (1+(char *) &x, 0, -1); + return (x != 0xf0000000); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93780.c b/SingleSource/Regression/C/gcc-dg/pr93780.c new file mode 100644 index 0000000000..d476df69b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93780.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/93780 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mavx" { target avx } } */ + +typedef float V __attribute__((vector_size (32))); + +float +foo (void) +{ + const float init[6] = {}; + V v = {}; + __builtin_memcpy (&v, init, sizeof (init)); + return v[0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93820-2.c b/SingleSource/Regression/C/gcc-dg/pr93820-2.c new file mode 100644 index 0000000000..be5d36898f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93820-2.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/93820 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fgimple" } */ + +typedef int v4si __attribute__((vector_size(4 * sizeof (int)))); +int a[10]; + +void __GIMPLE (ssa,startwith("store-merging")) +foo (int *p) +{ + int _2; + __BB(2): + _2 = *p_1(D); + a[6] = _2; + a[4] = 1; + __MEM ((int *)&a + _Literal (int *) 16) = _Literal (v4si) { 0, 0, 0, 0 }; + a[3] = 0; + return; +} + +int +main () +{ + int i = 0; + foo (&i); + for (i = 0; i < 10; i++) + if (a[i]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93820.c b/SingleSource/Regression/C/gcc-dg/pr93820.c new file mode 100644 index 0000000000..98d8c20a17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93820.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/93820 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-dse" } */ + +typedef int v4si __attribute__((vector_size(4 * sizeof (int)))); +int a[10]; + +__attribute__((noipa)) int +foo (int *p) +{ + a[6] = *p; + a[4] = 1; + *(((v4si *)&a[0]) + 1) = (v4si) { 0, 0, 0, 0 }; + a[3] = 0; +} + +int +main () +{ + int i = 0; + foo (&i); + for (i = 0; i < 10; i++) + if (a[i]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93874.c b/SingleSource/Regression/C/gcc-dg/pr93874.c new file mode 100644 index 0000000000..154ef50ea5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93874.c @@ -0,0 +1,6 @@ +/* PR middle-end/93874 */ +/* { dg-do compile } */ +/* { dg-options "-fdisable-tree-dse3 -fdump-passes" } */ +/* { dg-prune-output ".*" } */ + +int i; diff --git a/SingleSource/Regression/C/gcc-dg/pr93917.c b/SingleSource/Regression/C/gcc-dg/pr93917.c new file mode 100644 index 0000000000..41d27fb9a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93917.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1" } */ + +void f3(int n); + +void f1(int n) +{ + if(n<0) + __builtin_unreachable(); + f3(n); +} + +void f2(int*n) +{ + if(*n<0) + __builtin_unreachable(); + f3 (*n); +} + +/* { dg-final { scan-tree-dump-times "Global Exported" 2 "vrp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr93953.c b/SingleSource/Regression/C/gcc-dg/pr93953.c new file mode 100644 index 0000000000..bf85c146cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93953.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/93953 */ +/* { dg-do compile } */ +/* { dg-options "-O3 --param=ggc-min-expand=0 --param=ggc-min-heapsize=0" } */ + +int *b, c, e; +float d, g, f; + +void +foo (int l) +{ + for (; l; ++l) + { + float a = g > l; + d += a * b[4 * (l + c * e)]; + f += a * b[4 * (l + c * e) + 1]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93986.c b/SingleSource/Regression/C/gcc-dg/pr93986.c new file mode 100644 index 0000000000..0d533f4dbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93986.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/93986 - ICE in decompose, at wide-int.h:984 + { dg-do compile } + { dg-options "-O1 -foptimize-strlen -ftree-slp-vectorize" } + { dg-require-effective-target alloca } */ + +int dd (void); + +void ya (int cm) +{ + char s2[cm]; + + s2[cm-12] = s2[cm-11] = s2[cm-10] = s2[cm-9] + = s2[cm-8] = s2[cm-7] = s2[cm-6] = s2[cm-5] = ' '; + + if (dd ()) + __builtin_exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr93995.c b/SingleSource/Regression/C/gcc-dg/pr93995.c new file mode 100644 index 0000000000..b89c85db10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr93995.c @@ -0,0 +1,46 @@ +/* PR target/93995 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-trapping-math" } */ + +double s1[4], s2[4], s3[64]; + +int +main (void) +{ + int i; + asm volatile ("" : : : "memory"); + for (i = 0; i < 4; i++) + s3[0 * 4 + i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[1 * 4 + i] = (!__builtin_isgreater (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[2 * 4 + i] = __builtin_isgreaterequal (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[3 * 4 + i] = (!__builtin_isgreaterequal (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[4 * 4 + i] = __builtin_isless (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[5 * 4 + i] = (!__builtin_isless (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[6 * 4 + i] = __builtin_islessequal (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[7 * 4 + i] = (!__builtin_islessequal (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[8 * 4 + i] = __builtin_islessgreater (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[9 * 4 + i] = (!__builtin_islessgreater (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[10 * 4 + i] = __builtin_isunordered (s1[i], s2[i]) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[11 * 4 + i] = (!__builtin_isunordered (s1[i], s2[i])) ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[12 * 4 + i] = s1[i] > s2[i] ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[13 * 4 + i] = s1[i] >= s2[i] ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[14 * 4 + i] = s1[i] < s2[i] ? -1.0 : 0.0; + for (i = 0; i < 4; i++) + s3[15 * 4 + i] = s1[i] <= s2[i] ? -1.0 : 0.0; + asm volatile ("" : : : "memory"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94001.c b/SingleSource/Regression/C/gcc-dg/pr94001.c new file mode 100644 index 0000000000..f83873fa2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94001.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/94001 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce" } */ + +void +bar (int e) +{ + bar (3); + int c; + c = -e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94002.c b/SingleSource/Regression/C/gcc-dg/pr94002.c new file mode 100644 index 0000000000..05a02f3f15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94002.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/94002 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-dce -fno-tree-reassoc" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ + +unsigned a, b; + +void +foo (void) +{ + __builtin_sub_overflow (b, 44852956282LL, &a); + a += ~b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94015.c b/SingleSource/Regression/C/gcc-dg/pr94015.c new file mode 100644 index 0000000000..2c91b23583 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94015.c @@ -0,0 +1,107 @@ +/* PR tree-optimization/94015 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +char buf[10] = "AAAAAAAAA"; + +__attribute__((noipa)) char * +alloc (void) +{ + return buf; +} + +__attribute__((noipa)) void +f1 (void) +{ + char *s = alloc (); + *(char **)s = "1234567"; + s[7] = '\0'; +} + +__attribute__((noipa)) void +f2 (void) +{ + char *s = alloc (); + *(char **)s = "123456"; + s[6] = '\0'; +} + +__attribute__((noipa)) void +f3 (void) +{ + char *s = alloc (); + *(char **)s = "12345"; + s[5] = '\0'; +} + +__attribute__((noipa)) void +f4 (void) +{ + char *s = alloc (); + *(char **)s = "1234"; + s[4] = '\0'; +} + +__attribute__((noipa)) void +f5 (void) +{ + char *s = alloc (); + *(char **)s = "123"; + s[3] = '\0'; +} + +__attribute__((noipa)) void +f6 (void) +{ + char *s = alloc (); + *(char **)s = "12"; + s[2] = '\0'; +} + +__attribute__((noipa)) void +f7 (void) +{ + char *s = alloc (); + *(char **)s = "1"; + s[1] = '\0'; +} + +__attribute__((noipa)) void +f8 (void) +{ + char *s = alloc (); + *(char **)s = ""; + s[0] = '\0'; +} + +int +main () +{ + if (sizeof (char *) > 8) + return 0; + f1 (); + if (buf[7] != 0) + __builtin_abort (); + f2 (); + if (buf[6] != 0) + __builtin_abort (); + f3 (); + if (buf[5] != 0) + __builtin_abort (); + f4 (); + if (buf[4] != 0) + __builtin_abort (); + f5 (); + if (buf[3] != 0) + __builtin_abort (); + f6 (); + if (buf[2] != 0) + __builtin_abort (); + f7 (); + if (buf[1] != 0) + __builtin_abort (); + f8 (); + if (buf[0] != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94026.c b/SingleSource/Regression/C/gcc-dg/pr94026.c new file mode 100644 index 0000000000..deb4efd57d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94026.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int f1(int x) { return ((x >> 8) & 6) != 0; } +int f2(int x) { return ((x << 2) & 24) != 0; } +int f3(unsigned x) { return ((x << 2) & 15) != 0; } +int f4(unsigned x) { return ((x >> 2) & 14) != 0; } + +int fifth (int c) +{ + int a = (c >> 8) & 7; + + if (a >= 2) { + return 1; + } else { + return 0; + } +} +/* { dg-final { scan-tree-dump-not " << " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >> " "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr94114.c b/SingleSource/Regression/C/gcc-dg/pr94114.c new file mode 100644 index 0000000000..8d6d0eb5c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94114.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/94114 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-distribute-patterns -ftrapv" } */ + +void +foo (int *x, int *y, int *z, long int w) +{ + while (y + w > z) + { + x[w] = 0; + --w; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94121.c b/SingleSource/Regression/C/gcc-dg/pr94121.c new file mode 100644 index 0000000000..2a4261ae02 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94121.c @@ -0,0 +1,16 @@ +/* PR target/94121 */ +/* { dg-do compile { target pie } } */ +/* { dg-options "-O2 -fpie -w" } */ + +#define DIFF_MAX __PTRDIFF_MAX__ +#define DIFF_MIN (-DIFF_MAX - 1) + +extern void foo (char *); +extern char v[]; + +void +bar (void) +{ + char *p = v; + foo (&p[DIFF_MIN]); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94166.c b/SingleSource/Regression/C/gcc-dg/pr94166.c new file mode 100644 index 0000000000..71917c4a2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94166.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/94166 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +typedef int __m128i __attribute__((__may_alias__, __vector_size__(4 * sizeof (int)))); +unsigned int b[512]; + +void +foo (unsigned int *x, __m128i *y) +{ +#define A(n) __m128i v##n = y[n]; +#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) \ + A(n##8) A(n##9) A(n##a) A(n##b) A(n##c) A(n##d) A(n##e) A(n##f) +#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) + C(0x) +#undef A +#define A(n) *(__m128i *) &b[4 * n] = v##n; + C(0x) +#undef A +#define A(n) + b[4 * n] + b[4 * n + 1] + b[4 * n + 2] + b[4 * n + 3] + *x = *x + C(0x) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94167.c b/SingleSource/Regression/C/gcc-dg/pr94167.c new file mode 100644 index 0000000000..4b819d3a86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94167.c @@ -0,0 +1,33 @@ +/* PR debug/94167 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +struct S { int g, h; signed char i; int j; signed char k; int l[4]; } a, c; +struct T { signed char g; } e; +int *b, d; +static void foo (); + +void +bar (void) +{ + while (d) + { + int k; + struct T f[3]; + foo (bar, a); + for (k = 0;; k++) + f[k] = e; + } +} + +static inline void +foo (int x, struct S y, struct T z) +{ + for (z.g = 2; z.g; z.g--) + { + c = a = y; + *b |= 6; + if (y.g) + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94172-1.c b/SingleSource/Regression/C/gcc-dg/pr94172-1.c new file mode 100644 index 0000000000..12f84af42d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94172-1.c @@ -0,0 +1,12 @@ +/* PR c/94172 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern enum E e; +enum E { l = 0x100000000ULL }; + +unsigned long long +foo (void) +{ + return e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94172-2.c b/SingleSource/Regression/C/gcc-dg/pr94172-2.c new file mode 100644 index 0000000000..bb7b060d7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94172-2.c @@ -0,0 +1,19 @@ +/* PR c/94172 */ +/* { dg-do compile } */ +/* { dg-options "-Os -g -fshort-enums" } */ + +extern enum E e; +extern void bar (int a); +enum E { F }; + +void +foo (int a) +{ + int l = e; + if (a) + { + __asm volatile ("nop"); + l = 0; + } + bar (l); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94188.c b/SingleSource/Regression/C/gcc-dg/pr94188.c new file mode 100644 index 0000000000..7a73c1bc07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94188.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +struct dm_tree_link { + int list; + int node; +}; +void fn1(void *p) +{ + 0 ? ((struct dm_tree_link *)((char *)p - (char *)&((struct dm_tree_link *)0)->list))->node : 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94189.c b/SingleSource/Regression/C/gcc-dg/pr94189.c new file mode 100644 index 0000000000..f927d55279 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94189.c @@ -0,0 +1,11 @@ +/* PR middle-end/94189 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +const char a[] = { 'a', 'b', 'c', 'd' };/* { dg-message "declared here" } */ + +int +foo (void) +{ + return __builtin_strnlen (a, 5); /* { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94211.c b/SingleSource/Regression/C/gcc-dg/pr94211.c new file mode 100644 index 0000000000..3e160e457f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94211.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/94211 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +long +foo (long a, long b) +{ + if (__builtin_expect (b == 1, 1)) + return a; + int e = a + 1; + return a / b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94234-1.c b/SingleSource/Regression/C/gcc-dg/pr94234-1.c new file mode 100644 index 0000000000..d85563b32d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94234-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1" } */ + +typedef __INTPTR_TYPE__ ssize_t; +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +ptrdiff_t foo (char *a, ssize_t n, ssize_t m) +{ + char *b1 = a + 8 * n; + char *b2 = a + 8 * (n + 1); + + return (b1 + m) - (b2 + m); +} + +/* { dg-final { scan-tree-dump-times "return -8;" 1 "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94234-2.c b/SingleSource/Regression/C/gcc-dg/pr94234-2.c new file mode 100644 index 0000000000..1f4b194dd4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94234-2.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1" } */ + +int use_fn (int a); + +int foo (int n) +{ + int b1 = 8 * (n + 1); + int b2 = 8 * n; + + use_fn (b1 ^ b2); + + return b1 - b2; +} + +unsigned goo (unsigned m_param, unsigned n_param) +{ + unsigned b1 = m_param * (n_param + 2); + unsigned b2 = m_param * (n_param + 1); + + use_fn (b1 ^ b2); + + return b1 - b2; +} + +unsigned hoo (unsigned k_param) +{ + unsigned b1 = k_param * 28; + unsigned b2 = k_param * 15; + unsigned b3 = k_param * 12; + + use_fn (b1 ^ b2 ^ b3); + + return (b1 - b2) - b3; +} + +/* { dg-final { scan-tree-dump-times "return 8;" 1 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "return m_param" 1 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-not "return k_param" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94234-3.c b/SingleSource/Regression/C/gcc-dg/pr94234-3.c new file mode 100644 index 0000000000..9bb9b46bd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94234-3.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +ptrdiff_t foo1 (char *a, size_t n) +{ + char *b1 = a + 8 * n; + char *b2 = a + 8 * (n - 1); + + return b1 - b2; +} + +int use_ptr (char *a, char *b); + +ptrdiff_t foo2 (char *a, size_t n) +{ + char *b1 = a + 8 * (n - 1); + char *b2 = a + 8 * n; + + use_ptr (b1, b2); + + return b1 - b2; +} + +int use_int (int i); + +unsigned goo (unsigned m_param, unsigned n_param) +{ + unsigned b1 = m_param * (n_param + 2); + unsigned b2 = m_param * (n_param + 1); + int r = (int)(b1) - (int)(b2); + + use_int (r); + + return r; +} + +/* { dg-final { scan-tree-dump-times "return 8;" 1 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "return -8;" 1 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "return m_param" 1 "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94269.c b/SingleSource/Regression/C/gcc-dg/pr94269.c new file mode 100644 index 0000000000..49d57044f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94269.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target aarch64*-*-* } } */ +/* { dg-options "-O2 -ftree-loop-vectorize -funsafe-math-optimizations -march=armv8.2-a+sve -msve-vector-bits=256" } */ + +float +foo(long n, float *x, int inc_x, + float *y, int inc_y) +{ + float dot = 0.0; + int ix = 0, iy = 0; + + if (n < 0) { + return dot; + } + + int i = 0; + while (i < n) { + dot += y[iy] * x[ix]; + ix += inc_x; + iy += inc_y; + i++; + } + + return dot; +} + +/* { dg-final { scan-assembler-not "smaddl" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94277.c b/SingleSource/Regression/C/gcc-dg/pr94277.c new file mode 100644 index 0000000000..dfe38e401a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94277.c @@ -0,0 +1,11 @@ +/* PR debug/94277 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug" } */ + +static void foo (void); /* { dg-warning "used but never defined" } */ + +void +bar (void) +{ + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94283.c b/SingleSource/Regression/C/gcc-dg/pr94283.c new file mode 100644 index 0000000000..ac162d6ac7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94283.c @@ -0,0 +1,16 @@ +/* PR debug/94283 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-dce -fcompare-debug" } */ + +void +foo (int *n) +{ + for (int i = 0; i < 32; i++) + { + int x = 0; + x++; + if (i & 4) + x++; + x++; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94286.c b/SingleSource/Regression/C/gcc-dg/pr94286.c new file mode 100644 index 0000000000..106cb751bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94286.c @@ -0,0 +1,11 @@ +/* PR target/94286 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +unsigned a, b; + +int +foo (void) +{ + return __builtin_sub_overflow (a, 0x80000000U, &b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94291.c b/SingleSource/Regression/C/gcc-dg/pr94291.c new file mode 100644 index 0000000000..7d9331b391 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94291.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/94291 */ +/* { dg-do compile } */ +/* { dg-options "-Og" } */ +/* { dg-skip-if "accessing data memory with program memory address" { "avr-*-*" } } */ + +unsigned a; + +unsigned +foo (void) +{ + unsigned x + = (__builtin_sub_overflow ((long long) a, 0, &x) + ? 1 : (__INTPTR_TYPE__) __builtin_memmove (&x, foo, 1)); + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94292.c b/SingleSource/Regression/C/gcc-dg/pr94292.c new file mode 100644 index 0000000000..dd2a29c066 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94292.c @@ -0,0 +1,13 @@ +/* PR target/94292 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -g -fno-tree-dce" } */ + +unsigned short a; +unsigned long long b; + +long long +foo (int d) +{ + d >>= a != (unsigned long long) -a; + return a + b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94344.c b/SingleSource/Regression/C/gcc-dg/pr94344.c new file mode 100644 index 0000000000..361e16eab2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94344.c @@ -0,0 +1,53 @@ +/* PR rtl-optimization/94344 */ +/* { dg-do compile { target { ilp32 || lp64 } } } */ +/* { dg-options "-O2 -fdump-tree-forwprop1" } */ +/* { dg-final { scan-tree-dump-times " r>> 27;" 4 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times " r>> 59;" 4 "forwprop1" } } */ + +int +f1 (int x) +{ + return (x << 5) | (int)((unsigned int)x >> 27); +} + +unsigned int +f2 (int x) +{ + return (x << 5) | ((unsigned int)x >> 27); +} + +long long int +f3 (long long int x) +{ + return (x << 5) | (long long int)((unsigned long long int)x >> 59); +} + +unsigned long long int +f4 (long long int x) +{ + return (x << 5) | ((unsigned long long int)x >> 59); +} + +int +f5 (int x) +{ + return (int)((unsigned int)x >> 27) | (x << 5); +} + +unsigned int +f6 (int x) +{ + return ((unsigned int)x >> 27) | (x << 5); +} + +long long int +f7 (long long int x) +{ + return (long long int)((unsigned long long int)x >> 59) | (x << 5); +} + +unsigned long long int +f8 (long long int x) +{ + return ((unsigned long long int)x >> 59) | (x << 5); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94368.c b/SingleSource/Regression/C/gcc-dg/pr94368.c new file mode 100644 index 0000000000..1267b82209 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94368.c @@ -0,0 +1,25 @@ +/* PR target/94368 */ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-fpic -O1 -fcommon" } */ + +int b, c, d, e, f, h; +short g; +int foo (int) __attribute__ ((__const__)); + +void +bar (void) +{ + while (1) + { + while (1) + { + __atomic_load_n (&e, 0); + if (foo (2)) + __sync_val_compare_and_swap (&c, 0, f); + b = 1; + if (h == e) + break; + } + __sync_val_compare_and_swap (&g, -1, f); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94436.c b/SingleSource/Regression/C/gcc-dg/pr94436.c new file mode 100644 index 0000000000..345b5958a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94436.c @@ -0,0 +1,13 @@ +/* PR middle-end/94436 */ +/* { dg-do compile } */ +/* { dg-options "-Wincompatible-pointer-types" } */ + +struct S { int s; }; +int foo (struct S *); + +int +bar (void) +{ + int s = 0; + return foo ((struct S *) ((char *) &s - (char *) &((struct S *) 0)->s)); /* { dg-bogus "from incompatible pointer type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94526.c b/SingleSource/Regression/C/gcc-dg/pr94526.c new file mode 100644 index 0000000000..9864c4c311 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94526.c @@ -0,0 +1,21 @@ +/* PR middle-end/94526 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +struct S { int val[8 * sizeof (int)]; }; + +void +foo (struct S *x) +{ + struct S *a = x; +} + +void baz (struct S); + +void +bar (void) +{ + struct S b; + foo (&b); + baz (b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94574.c b/SingleSource/Regression/C/gcc-dg/pr94574.c new file mode 100644 index 0000000000..0d18bd8283 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94574.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w -Wno-psabi" } */ + +typedef unsigned int v4si __attribute__((vector_size(16))); +typedef unsigned int v2si __attribute__((vector_size(8))); + +/* The aliasing is somewhat dubious here, but it must compile. */ + +v2si +foo (v4si v) +{ + v2si res; + *(v4si *) &res = v; + return res; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94589-1.c b/SingleSource/Regression/C/gcc-dg/pr94589-1.c new file mode 100644 index 0000000000..de404ea82b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94589-1.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/94589 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[45]" 14 "optimized" } } */ + +#define A __attribute__((noipa)) +A int f1 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == 0; } +A int f2 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != 0; } +A int f3 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c > 0; } +A int f4 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c < 0; } +A int f5 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c >= 0; } +A int f6 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c <= 0; } +A int f7 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == -1; } +A int f8 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != -1; } +A int f9 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c > -1; } +A int f10 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c <= -1; } +A int f11 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == 1; } +A int f12 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != 1; } +A int f13 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c < 1; } +A int f14 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c >= 1; } +A int f15 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == 0; } +A int f16 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != 0; } +A int f17 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c > 0; } +A int f18 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c < 0; } +A int f19 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c >= 0; } +A int f20 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c <= 0; } +A int f21 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == -1; } +A int f22 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != -1; } +A int f23 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c > -1; } +A int f24 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c <= -1; } +A int f25 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == 1; } +A int f26 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != 1; } +A int f27 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c < 1; } +A int f28 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c >= 1; } diff --git a/SingleSource/Regression/C/gcc-dg/pr94589-2.c b/SingleSource/Regression/C/gcc-dg/pr94589-2.c new file mode 100644 index 0000000000..9481b764da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94589-2.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/94589 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g0 -ffast-math -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 14 "optimized" } } */ + +#define A __attribute__((noipa)) +A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 0; } +A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 0; } +A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > 0; } +A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 0; } +A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 0; } +A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= 0; } +A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == -1; } +A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != -1; } +A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > -1; } +A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= -1; } +A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 1; } +A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 1; } +A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 1; } +A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 1; } +A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 0; } +A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 0; } +A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > 0; } +A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 0; } +A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 0; } +A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= 0; } +A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == -1; } +A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != -1; } +A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > -1; } +A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= -1; } +A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 1; } +A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 1; } +A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 1; } +A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 1; } diff --git a/SingleSource/Regression/C/gcc-dg/pr94589-3.c b/SingleSource/Regression/C/gcc-dg/pr94589-3.c new file mode 100644 index 0000000000..df82fab733 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94589-3.c @@ -0,0 +1,97 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -g" } */ + +#include "pr94589-1.c" + +#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort () +#define D(fn, i, r) if (fn (i) != r) __builtin_abort () + +int +main () +{ + C (f1, 7, 8, 0); + C (f1, 8, 8, 1); + C (f1, 9, 8, 0); + C (f2, 7, 8, 1); + C (f2, 8, 8, 0); + C (f2, 9, 8, 1); + C (f3, 7, 8, 0); + C (f3, 8, 8, 0); + C (f3, 9, 8, 1); + C (f4, 7, 8, 1); + C (f4, 8, 8, 0); + C (f4, 9, 8, 0); + C (f5, 7, 8, 0); + C (f5, 8, 8, 1); + C (f5, 9, 8, 1); + C (f6, 7, 8, 1); + C (f6, 8, 8, 1); + C (f6, 9, 8, 0); + C (f7, 7, 8, 1); + C (f7, 8, 8, 0); + C (f7, 9, 8, 0); + C (f8, 7, 8, 0); + C (f8, 8, 8, 1); + C (f8, 9, 8, 1); + C (f9, 7, 8, 0); + C (f9, 8, 8, 1); + C (f9, 9, 8, 1); + C (f10, 7, 8, 1); + C (f10, 8, 8, 0); + C (f10, 9, 8, 0); + C (f11, 7, 8, 0); + C (f11, 8, 8, 0); + C (f11, 9, 8, 1); + C (f12, 7, 8, 1); + C (f12, 8, 8, 1); + C (f12, 9, 8, 0); + C (f13, 7, 8, 1); + C (f13, 8, 8, 1); + C (f13, 9, 8, 0); + C (f14, 7, 8, 0); + C (f14, 8, 8, 0); + C (f14, 9, 8, 1); + D (f15, 4, 0); + D (f15, 5, 1); + D (f15, 6, 0); + D (f16, 4, 1); + D (f16, 5, 0); + D (f16, 6, 1); + D (f17, 4, 0); + D (f17, 5, 0); + D (f17, 6, 1); + D (f18, 4, 1); + D (f18, 5, 0); + D (f18, 6, 0); + D (f19, 4, 0); + D (f19, 5, 1); + D (f19, 6, 1); + D (f20, 4, 1); + D (f20, 5, 1); + D (f20, 6, 0); + D (f21, 4, 1); + D (f21, 5, 0); + D (f21, 6, 0); + D (f22, 4, 0); + D (f22, 5, 1); + D (f22, 6, 1); + D (f23, 4, 0); + D (f23, 5, 1); + D (f23, 6, 1); + D (f24, 4, 1); + D (f24, 5, 0); + D (f24, 6, 0); + D (f25, 4, 0); + D (f25, 5, 0); + D (f25, 6, 1); + D (f26, 4, 1); + D (f26, 5, 1); + D (f26, 6, 0); + D (f27, 4, 1); + D (f27, 5, 1); + D (f27, 6, 0); + D (f28, 4, 0); + D (f28, 5, 0); + D (f28, 6, 1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94589-4.c b/SingleSource/Regression/C/gcc-dg/pr94589-4.c new file mode 100644 index 0000000000..b2557fb07b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94589-4.c @@ -0,0 +1,97 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -g -ffast-math" } */ + +#include "pr94589-2.c" + +#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort () +#define D(fn, i, r) if (fn (i) != r) __builtin_abort () + +int +main () +{ + C (f1, 7.0, 8.0, 0); + C (f1, 8.0, 8.0, 1); + C (f1, 9.0, 8.0, 0); + C (f2, 7.0, 8.0, 1); + C (f2, 8.0, 8.0, 0); + C (f2, 9.0, 8.0, 1); + C (f3, 7.0, 8.0, 0); + C (f3, 8.0, 8.0, 0); + C (f3, 9.0, 8.0, 1); + C (f4, 7.0, 8.0, 1); + C (f4, 8.0, 8.0, 0); + C (f4, 9.0, 8.0, 0); + C (f5, 7.0, 8.0, 0); + C (f5, 8.0, 8.0, 1); + C (f5, 9.0, 8.0, 1); + C (f6, 7.0, 8.0, 1); + C (f6, 8.0, 8.0, 1); + C (f6, 9.0, 8.0, 0); + C (f7, 7.0, 8.0, 1); + C (f7, 8.0, 8.0, 0); + C (f7, 9.0, 8.0, 0); + C (f8, 7.0, 8.0, 0); + C (f8, 8.0, 8.0, 1); + C (f8, 9.0, 8.0, 1); + C (f9, 7.0, 8.0, 0); + C (f9, 8.0, 8.0, 1); + C (f9, 9.0, 8.0, 1); + C (f10, 7.0, 8.0, 1); + C (f10, 8.0, 8.0, 0); + C (f10, 9.0, 8.0, 0); + C (f11, 7.0, 8.0, 0); + C (f11, 8.0, 8.0, 0); + C (f11, 9.0, 8.0, 1); + C (f12, 7.0, 8.0, 1); + C (f12, 8.0, 8.0, 1); + C (f12, 9.0, 8.0, 0); + C (f13, 7.0, 8.0, 1); + C (f13, 8.0, 8.0, 1); + C (f13, 9.0, 8.0, 0); + C (f14, 7.0, 8.0, 0); + C (f14, 8.0, 8.0, 0); + C (f14, 9.0, 8.0, 1); + D (f15, 4.0, 0); + D (f15, 5.0, 1); + D (f15, 6.0, 0); + D (f16, 4.0, 1); + D (f16, 5.0, 0); + D (f16, 6.0, 1); + D (f17, 4.0, 0); + D (f17, 5.0, 0); + D (f17, 6.0, 1); + D (f18, 4.0, 1); + D (f18, 5.0, 0); + D (f18, 6.0, 0); + D (f19, 4.0, 0); + D (f19, 5.0, 1); + D (f19, 6.0, 1); + D (f20, 4.0, 1); + D (f20, 5.0, 1); + D (f20, 6.0, 0); + D (f21, 4.0, 1); + D (f21, 5.0, 0); + D (f21, 6.0, 0); + D (f22, 4.0, 0); + D (f22, 5.0, 1); + D (f22, 6.0, 1); + D (f23, 4.0, 0); + D (f23, 5.0, 1); + D (f23, 6.0, 1); + D (f24, 4.0, 1); + D (f24, 5.0, 0); + D (f24, 6.0, 0); + D (f25, 4.0, 0); + D (f25, 5.0, 0); + D (f25, 6.0, 1); + D (f26, 4.0, 1); + D (f26, 5.0, 1); + D (f26, 6.0, 0); + D (f27, 4.0, 1); + D (f27, 5.0, 1); + D (f27, 6.0, 0); + D (f28, 4.0, 0); + D (f28, 5.0, 0); + D (f28, 6.0, 1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94600-1.c b/SingleSource/Regression/C/gcc-dg/pr94600-1.c new file mode 100644 index 0000000000..149e4f35db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94600-1.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fdump-rtl-final -O2" } */ +/* { dg-additional-options "-DALIGN_VAR" { target { ! non_strict_align } } } */ + +/* Assignments to a whole struct of suitable size (32 bytes) must not be + picked apart into field accesses. */ + +typedef struct { + unsigned int f0 : 4; + unsigned int f1 : 11; + unsigned int f2 : 10; + unsigned int f3 : 7; +} t0; + +static t0 a0[] +#ifdef ALIGN_VAR +__attribute__((aligned (4))) +#endif + = { + { .f0 = 7, .f1 = 99, .f3 = 1, }, + { .f0 = 7, .f1 = 251, .f3 = 1, }, + { .f0 = 8, .f1 = 127, .f3 = 5, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, +}; + +void +foo(void) +{ + __SIZE_TYPE__ i; + __SIZE_TYPE__ base = 0x000a0000; + for (i = 0; i < (sizeof (a0) / sizeof ((a0)[0])); i++) { + *(volatile t0 *) (base + 44 + i * 4) = a0[i]; + } +} + +/* The only volatile accesses should be the obvious writes. */ +/* { dg-final { scan-rtl-dump-times {\(mem/v} 6 "final" } } */ +/* { dg-final { scan-rtl-dump-times {\(set \(mem/v} 6 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94600-2.c b/SingleSource/Regression/C/gcc-dg/pr94600-2.c new file mode 100644 index 0000000000..cb96cc98a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94600-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fdump-rtl-final -O2" } */ + +/* Unrolled version of pr94600-1.c. */ + +typedef struct { + unsigned int f0 : 4; + unsigned int f1 : 11; + unsigned int f2 : 10; + unsigned int f3 : 7; +} t0; + +void +bar(void) +{ + t0 a00 = { .f0 = 7, .f1 = 99, .f3 = 1, }; + t0 a01 = { .f0 = 7, .f1 = 251, .f3 = 1, }; + t0 a02 = { .f0 = 8, .f1 = 127, .f3 = 5, }; + t0 a03 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + t0 a04 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + t0 a05 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + __SIZE_TYPE__ base = 0x000a0000; + + *(volatile t0 *) ((base) + 44 + (0) * 4) = a00; + *(volatile t0 *) ((base) + 44 + (1) * 4) = a01; + *(volatile t0 *) ((base) + 44 + (2) * 4) = a02; + *(volatile t0 *) ((base) + 44 + (3) * 4) = a03; + *(volatile t0 *) ((base) + 44 + (4) * 4) = a04; + *(volatile t0 *) ((base) + 44 + (5) * 4) = a05; +} + +/* { dg-final { scan-rtl-dump-times {\(mem/v} 6 "final" } } */ +/* { dg-final { scan-rtl-dump-times {\(set \(mem/v} 6 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94600-3.c b/SingleSource/Regression/C/gcc-dg/pr94600-3.c new file mode 100644 index 0000000000..2fce9f13cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94600-3.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fdump-rtl-final -O2 -fno-unroll-loops" } */ +/* { dg-additional-options "-DALIGN_VAR" { target { ! non_strict_align } } } */ + +/* Same-address version of pr94600-1.c. */ + +typedef struct { + unsigned int f0 : 4; + unsigned int f1 : 11; + unsigned int f2 : 10; + unsigned int f3 : 7; +} t0; + +static t0 a0[] +#ifdef ALIGN_VAR +__attribute__((aligned (4))) +#endif + = { + { .f0 = 7, .f1 = 99, .f3 = 1, }, + { .f0 = 7, .f1 = 251, .f3 = 1, }, + { .f0 = 8, .f1 = 127, .f3 = 5, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, +}; + +void +foo(void) +{ + __SIZE_TYPE__ i; + __SIZE_TYPE__ base = 0x000a0000; + for (i = 0; i < (sizeof (a0) / sizeof ((a0)[0])); i++) { + *(volatile t0 *) (base + 44) = a0[i]; + } +} + +/* The loop isn't unrolled. */ +/* { dg-final { scan-rtl-dump-times {\(mem/v} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {\(set \(mem/v} 1 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94600-4.c b/SingleSource/Regression/C/gcc-dg/pr94600-4.c new file mode 100644 index 0000000000..c2901abb32 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94600-4.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fdump-rtl-final -O2" } */ + +/* Unrolled version of pr94600-2.c. */ + +typedef struct { + unsigned int f0 : 4; + unsigned int f1 : 11; + unsigned int f2 : 10; + unsigned int f3 : 7; +} t0; + +void +bar(void) +{ + t0 a00 = { .f0 = 7, .f1 = 99, .f3 = 1, }; + t0 a01 = { .f0 = 7, .f1 = 251, .f3 = 1, }; + t0 a02 = { .f0 = 8, .f1 = 127, .f3 = 5, }; + t0 a03 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + t0 a04 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + t0 a05 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + __SIZE_TYPE__ base = 0x000a0000; + + *(volatile t0 *) ((base) + 44) = a00; + *(volatile t0 *) ((base) + 44) = a01; + *(volatile t0 *) ((base) + 44) = a02; + *(volatile t0 *) ((base) + 44) = a03; + *(volatile t0 *) ((base) + 44) = a04; + *(volatile t0 *) ((base) + 44) = a05; +} + +/* { dg-final { scan-rtl-dump-times {\(mem/v} 6 "final" } } */ +/* { dg-final { scan-rtl-dump-times {\(set \(mem/v} 6 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94600-5.c b/SingleSource/Regression/C/gcc-dg/pr94600-5.c new file mode 100644 index 0000000000..3be0249273 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94600-5.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fdump-rtl-final -O2 -fno-unroll-loops" } */ + +/* Target-as-parameter version of pr94600-1.c. */ + +typedef struct { + unsigned int f0 : 4; + unsigned int f1 : 11; + unsigned int f2 : 10; + unsigned int f3 : 7; +} t0 __attribute__((__aligned__(4))); + +static t0 a0[] = { + { .f0 = 7, .f1 = 99, .f3 = 1, }, + { .f0 = 7, .f1 = 251, .f3 = 1, }, + { .f0 = 8, .f1 = 127, .f3 = 5, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, +}; + +void +foo(volatile t0 *b) +{ + __SIZE_TYPE__ i; + for (i = 0; i < (sizeof (a0) / sizeof ((a0)[0])); i++) { + b[i+11] = a0[i]; + } +} + +/* The loop isn't unrolled. */ +/* { dg-final { scan-rtl-dump-times {\(mem/v} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {\(set \(mem/v} 1 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94600-6.c b/SingleSource/Regression/C/gcc-dg/pr94600-6.c new file mode 100644 index 0000000000..c247afef11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94600-6.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fdump-rtl-final -O2" } */ + +/* Target-as-parameter version of pr94600-2.c. */ + +typedef struct { + unsigned int f0 : 4; + unsigned int f1 : 11; + unsigned int f2 : 10; + unsigned int f3 : 7; +} t0 __attribute__((__aligned__(4))); + +void +bar(volatile t0 *b) +{ + t0 a00 = { .f0 = 7, .f1 = 99, .f3 = 1, }; + t0 a01 = { .f0 = 7, .f1 = 251, .f3 = 1, }; + t0 a02 = { .f0 = 8, .f1 = 127, .f3 = 5, }; + t0 a03 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + t0 a04 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + t0 a05 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + + b[11+0] = a00; + b[11+1] = a01; + b[11+2] = a02; + b[11+3] = a03; + b[11+4] = a04; + b[11+5] = a05; +} + +/* { dg-final { scan-rtl-dump-times {\(mem/v} 6 "final" } } */ +/* { dg-final { scan-rtl-dump-times {\(set \(mem/v} 6 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94600-7.c b/SingleSource/Regression/C/gcc-dg/pr94600-7.c new file mode 100644 index 0000000000..81c5231e44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94600-7.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fdump-rtl-final -O2 -fno-unroll-loops" } */ + +/* Target-as-parameter version of pr94600-3.c. */ + +typedef struct { + unsigned int f0 : 4; + unsigned int f1 : 11; + unsigned int f2 : 10; + unsigned int f3 : 7; +} t0 __attribute__((__aligned__(4))); + +static t0 a0[] = { + { .f0 = 7, .f1 = 99, .f3 = 1, }, + { .f0 = 7, .f1 = 251, .f3 = 1, }, + { .f0 = 8, .f1 = 127, .f3 = 5, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, + { .f0 = 5, .f1 = 1, .f3 = 1, }, +}; + +void +foo(volatile t0 *b) +{ + __SIZE_TYPE__ i; + for (i = 0; i < (sizeof (a0) / sizeof ((a0)[0])); i++) { + b[11] = a0[i]; + } +} + +/* { dg-final { scan-rtl-dump-times {\(mem/v} 1 "final" } } */ +/* { dg-final { scan-rtl-dump-times {\(set \(mem/v} 1 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94600-8.c b/SingleSource/Regression/C/gcc-dg/pr94600-8.c new file mode 100644 index 0000000000..201b2add4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94600-8.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-fdump-rtl-final -O2" } */ + +/* Unrolled version of pr94600-2.c. */ + +typedef struct { + unsigned int f0 : 4; + unsigned int f1 : 11; + unsigned int f2 : 10; + unsigned int f3 : 7; +} t0 __attribute__((__aligned__(4))); + +void +bar(volatile t0 *b) +{ + t0 a00 = { .f0 = 7, .f1 = 99, .f3 = 1, }; + t0 a01 = { .f0 = 7, .f1 = 251, .f3 = 1, }; + t0 a02 = { .f0 = 8, .f1 = 127, .f3 = 5, }; + t0 a03 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + t0 a04 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + t0 a05 = { .f0 = 5, .f1 = 1, .f3 = 1, }; + + b[11] = a00; + b[11] = a01; + b[11] = a02; + b[11] = a03; + b[11] = a04; + b[11] = a05; +} + +/* { dg-final { scan-rtl-dump-times {\(mem/v} 6 "final" } } */ +/* { dg-final { scan-rtl-dump-times {\(set \(mem/v} 6 "final" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94705.c b/SingleSource/Regression/C/gcc-dg/pr94705.c new file mode 100644 index 0000000000..96392ab60e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94705.c @@ -0,0 +1,13 @@ +/* PR c/94705 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo (); + +int +bar (void) +{ + foo (baz); /* { dg-error "'baz' undeclared" } */ + /* { dg-message "only once" "" { target *-*-* } .-1 } */ + void __attribute__ ((noinline)) baz (void); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94726.c b/SingleSource/Regression/C/gcc-dg/pr94726.c new file mode 100644 index 0000000000..d6911a644a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94726.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +typedef unsigned int type __attribute__ ( ( vector_size ( 2*sizeof(int) ) ) ) ; +type a , b; +/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */ +void foo ( void ) { + type var = { 2 , 2 } ; + b = __builtin_shuffle ( a , var ) ; +} + +void * a [ ] = { } ; /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94780.c b/SingleSource/Regression/C/gcc-dg/pr94780.c new file mode 100644 index 0000000000..c4b723e24b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94780.c @@ -0,0 +1,13 @@ +/* PR target/94780 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +_Atomic double x; + +double +foo (void) +{ + double bar () { return x; } + x /= 3; + return bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94784.c b/SingleSource/Regression/C/gcc-dg/pr94784.c new file mode 100644 index 0000000000..df6972f64a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94784.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target aarch64*-*-* } } */ +/* { dg-options "-O2 -ftree-slp-vectorize -march=armv8.2-a+sve -msve-vector-bits=256" } */ + +typedef short __attribute__((vector_size (8))) v4hi; + +typedef union U4HI { v4hi v; short a[4]; } u4hi; + +short a[4]; + +void pass_v4hi (v4hi v) { + int j; + u4hi u; + u.v = v; + for (j = 0; j < 4; j++) + a[j] = u.a[j]; +}; diff --git a/SingleSource/Regression/C/gcc-dg/pr94842.c b/SingleSource/Regression/C/gcc-dg/pr94842.c new file mode 100644 index 0000000000..33d9d42644 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94842.c @@ -0,0 +1,11 @@ +/* PR c/94842 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +_Atomic float x = 5; + +void +foo (void) +{ + void bar (float y[(int) (x += 2)]) {} +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94873.c b/SingleSource/Regression/C/gcc-dg/pr94873.c new file mode 100644 index 0000000000..36152176fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94873.c @@ -0,0 +1,27 @@ +/* PR rtl-optimization/94873 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-O -fno-merge-constants -fno-split-wide-types -fno-tree-fre" } */ + +__attribute__((noipa)) void +foo (const char *p, int q) +{ + if (p[0] != '%' || p[1] != '0' || p[2] != '2' || p[3] != 'x' || p[4] != '\0') + __builtin_abort (); +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + if ((unsigned char) q != 0x95) + __builtin_abort (); +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + if ((unsigned char) q != 0) + __builtin_abort (); +#endif +} + +int +main () +{ + union U { __int128 a; char b[sizeof (__int128)]; }; + char x = ((union U){ .a = 0xF4409395252B9560ULL}).b[1]; + for (unsigned i = 0; i < sizeof (x); i++) + foo ("%02x", i[(volatile unsigned char *) &x]); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94899.c b/SingleSource/Regression/C/gcc-dg/pr94899.c new file mode 100644 index 0000000000..9fad057e4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94899.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; +typedef __UINT16_TYPE__ uint16_t; +typedef __UINT32_TYPE__ uint32_t; + +#define MAGIC (~ (uint32_t) 0 / 2 + 1) + +int +f_i16_i16 (int16_t x, int16_t y) +{ + return x + MAGIC < y + MAGIC; +} + +int +f_i16_i32 (int16_t x, int32_t y) +{ + return x + MAGIC < y + MAGIC; +} + +int +f_i32_i32 (int32_t x, int32_t y) +{ + return x + MAGIC < y + MAGIC; +} + +int +f_u32_i32 (uint32_t x, int32_t y) +{ + return x + MAGIC < y + MAGIC; +} + +int +f_u32_u32 (uint32_t x, uint32_t y) +{ + return x + MAGIC < y + MAGIC; +} + +int +f_i32_i32_sub (int32_t x, int32_t y) +{ + return x - MAGIC < y - MAGIC; +} + +/* The addition/subtraction of constants should be optimized away. */ +/* { dg-final { scan-tree-dump-not " \\+ " "optimized"} } */ +/* { dg-final { scan-tree-dump-not " \\- " "optimized"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94920-2.c b/SingleSource/Regression/C/gcc-dg/pr94920-2.c new file mode 100644 index 0000000000..a2d23324cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94920-2.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/94920 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* Form from PR. */ +__attribute__((noipa)) unsigned int foo(int x) { + return x <= 0 ? -x : 0; +} + +/* Changed order. */ +__attribute__((noipa)) unsigned int bar(int x) { + return 0 >= x ? -x : 0; +} + +/* { dg-final {scan-tree-dump-times " MAX_EXPR " 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr94963.c b/SingleSource/Regression/C/gcc-dg/pr94963.c new file mode 100644 index 0000000000..aca9e16130 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94963.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +typedef struct +{ + int p1; + int p2; + int p3; +} P; +struct S +{ + int field; +}; +extern int v2; +extern void foo (struct S *map); +static struct S var; +const P *pv; +int ps; +void +f (void) +{ + if (pv != 0) + for (const P *ph = pv; ph < &pv[ps]; ++ph) + switch (ph->p1) + { + case 1: + v2 = ph->p2; + break; + case 2: + var.field = ph->p3; + break; + } + if (var.field != 0) /* { dg-bogus "uninitialized" } */ + foo (&var); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr94968.c b/SingleSource/Regression/C/gcc-dg/pr94968.c new file mode 100644 index 0000000000..e8b282139c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr94968.c @@ -0,0 +1,8 @@ +/* PR c/94968 */ +/* { dg-do compile } */ + +int +foo (void) +{ + __builtin_speculation_safe_value (1, x); /* { dg-error "undeclared" } */ +} /* { dg-message "each undeclared identifier is reported only once" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr95052.c b/SingleSource/Regression/C/gcc-dg/pr95052.c new file mode 100644 index 0000000000..2ed1a037bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95052.c @@ -0,0 +1,12 @@ +/* PR middle-end/95052 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fconserve-stack" } */ + +void bar (char *); + +void +foo (void) +{ + char buf[70] = ""; + bar (buf); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95115.c b/SingleSource/Regression/C/gcc-dg/pr95115.c new file mode 100644 index 0000000000..e7c3119f0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95115.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ftrapping-math" } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target fenv_exceptions_double } */ + +#include +#include + +__attribute__ ((noipa)) double +x (void) +{ + double d = __builtin_inf (); + return d / d; +} + +int +main (void) +{ + double r = x (); + if (!__builtin_isnan (r)) + abort (); + if (!fetestexcept (FE_INVALID)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95118.c b/SingleSource/Regression/C/gcc-dg/pr95118.c new file mode 100644 index 0000000000..69bc47fd7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95118.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-fre" } */ + +void a(); +void b() { + union { + int c[4]; + long double d; + } e = {{0, 0, 4}}; + a(e.d); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95133.c b/SingleSource/Regression/C/gcc-dg/pr95133.c new file mode 100644 index 0000000000..5e233595ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95133.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-require-effective-target label_values } */ + +extern int a[16]; +void f (int *ip, int x) +{ + int *xp = a; + for (int i=0; i<8; ++i) + { + base: if (x) return; + } + *xp++ = *ip; + goto *(&&base + *ip); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95141.c b/SingleSource/Regression/C/gcc-dg/pr95141.c new file mode 100644 index 0000000000..b6cbba2f90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95141.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +#include + +uint64_t test(uint8_t IA1) +{ + return (uint8_t)(IA1 & 158) & 1UL; /* { dg-bogus "integer overflow" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95171.c b/SingleSource/Regression/C/gcc-dg/pr95171.c new file mode 100644 index 0000000000..af9bde7bc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95171.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fexceptions -ffinite-math-only -fnon-call-exceptions" } */ + +inline double __attribute__ ((always_inline)) +w9 (int q2) +{ + return __builtin_fabs (__builtin_nan ("")) > 0.0 ? 1.0 : q2 / 1.0; +} + +double __attribute__ ((optimize ("-fipa-cp"))) +o7 (int iz) +{ + int rj[1]; + + (void) rj; + + return w9 (iz); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95580.c b/SingleSource/Regression/C/gcc-dg/pr95580.c new file mode 100644 index 0000000000..77d8150baa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95580.c @@ -0,0 +1,16 @@ +/* PR c/95580 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -W -fno-tree-dce -fno-tree-dse" } */ + +void bar (void); + +void +foo (int x) +{ + if (x == 0) + { + void *p = __builtin_malloc (4); + ((char *)p)[1] ^= 1; /* { dg-warning "may be used uninitialized" } */ + } + bar (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95582.c b/SingleSource/Regression/C/gcc-dg/pr95582.c new file mode 100644 index 0000000000..cc2ab46ec9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95582.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O3" } */ + +typedef _Bool bool8 __attribute__((signed_bool_precision(8))); + +bool8 data[16]; + +void __GIMPLE(ssa) foo(int f) +{ + _Bool t; + bool8 tp; + +__BB(2): + t_2 = f_1(D) != 0; + tp_3 = (bool8) t_2; + data[0] = tp_3; + data[1] = tp_3; + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95694.c b/SingleSource/Regression/C/gcc-dg/pr95694.c new file mode 100644 index 0000000000..6f5e1900a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95694.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/68835 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-fno-tree-forwprop -fno-tree-ccp -O1 -fno-tree-dominator-opts -fno-tree-fre" } */ + +__attribute__((noinline, noclone)) unsigned __int128 +foo (void) +{ + unsigned __int128 x = (unsigned __int128) 0xffffffffffffffffULL; + struct { unsigned __int128 a : 65; } w; + w.a = x; + w.a += x; + return w.a; +} + +int +main () +{ + unsigned __int128 x = foo (); + if ((unsigned long long) x != 0xfffffffffffffffeULL + || (unsigned long long) (x >> 64) != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95713.c b/SingleSource/Regression/C/gcc-dg/pr95713.c new file mode 100644 index 0000000000..b167842b96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95713.c @@ -0,0 +1,15 @@ +/* PR target/95713 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi -w" } */ +/* { dg-additional-options "-mavx512bw" { target i?86-*-* x86_64-*-* } } */ + +typedef int v2si __attribute__((vector_size (8))); +typedef short int v2hi __attribute__((vector_size (4))); +void foo (v2hi); + +void +bar (v2si x) +{ + v2hi a = (v2hi) { (short) x[0], (short) x[1] }; + foo (4 > a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95770.c b/SingleSource/Regression/C/gcc-dg/pr95770.c new file mode 100644 index 0000000000..06714ea1fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95770.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +float *a; +void b(float c, float d) +{ + a[0] = a[1] = 0.5f * (c - 2 + d); + a[2] = a[3] = 0.5f * (c + 2 + d); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95853.c b/SingleSource/Regression/C/gcc-dg/pr95853.c new file mode 100644 index 0000000000..fdd3c30c45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95853.c @@ -0,0 +1,59 @@ +/* PR tree-optimization/95853 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-widening_mul" } */ + +#if __SIZEOF_INT128__ +typedef __uint128_t W; +typedef unsigned long long T; +#else +typedef unsigned long long W; +typedef unsigned int T; +#endif + +struct S { int p; T r; }; + +struct S +foo (T x, T y) +{ + W z = (W) x + y; + return (struct S) { z > ~(T) 0, (T) z }; +} + +struct S +bar (T x) +{ + W z = (W) x + 132; + return (struct S) { z > ~(T) 0, (T) z }; +} + +struct S +baz (T x, unsigned short y) +{ + W z = (W) x + y; + return (struct S) { z > ~(T) 0, (T) z }; +} + +struct S +qux (unsigned short x, T y) +{ + W z = (W) x + y; + return (struct S) { z > ~(T) 0, (T) z }; +} + +struct S +corge (T x, T y) +{ + T w = x + y; + W z = (W) x + y; + return (struct S) { z > ~(T) 0, w }; +} + +struct S +garple (T x, T y) +{ + W z = (W) x + y; + T w = x + y; + return (struct S) { z > ~(T) 0, w }; +} + +/* { dg-final { scan-tree-dump-times "ADD_OVERFLOW" 6 "widening_mul" { target { i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr95854.c b/SingleSource/Regression/C/gcc-dg/pr95854.c new file mode 100644 index 0000000000..db45d6aaf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95854.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-vect-cost-model -fno-tree-scev-cprop -ftracer" } */ +/* { dg-additional-options "-march=armv8.5-a+sve2" { target aarch64*-*-* } } */ + +extern void abort (void); +int c, d; +int main() +{ + int e[] = {4, 4, 4, 4, 4, 4, 4, 4, 4}; + d = 8; + for (; d; d--) + for (int a = 0; a <= 8; a++) + { + c = e[1]; + e[d] = 0; + } + if (c != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr95857.c b/SingleSource/Regression/C/gcc-dg/pr95857.c new file mode 100644 index 0000000000..afd6f46ea3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr95857.c @@ -0,0 +1,38 @@ +/* PR tree-optimization/95857 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target label_values } */ + +struct E { int e; }; +int bar (void), baz (void); +void qux (void *); + +void +foo (int x) +{ + struct E a = { 0 }; + struct E i = { 0 }; + qux (&&lab2); + if (baz ()) + i.e = 1; + else + a.e = -2; + switch (a.e) + { + case -2: + lab1: + switch (i.e) + { + case -3: + case 2: + if (i.e-- != 2) + __builtin_unreachable (); + lab2: + baz (); + goto lab1; + case 0: + bar (); + } + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96239.c b/SingleSource/Regression/C/gcc-dg/pr96239.c new file mode 100644 index 0000000000..8af56e12bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96239.c @@ -0,0 +1,54 @@ +/* PR tree-optimization/96239 */ +/* { dg-do run { target { ilp32 || lp64 } } } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " r>> 8;" 1 "optimized" { target bswap } } } */ +/* { dg-final { scan-tree-dump-times " = __builtin_bswap64 " 1 "optimized" { target bswap } } } */ +/* { dg-final { scan-tree-dump-not " >> \(8\|16\|24\|32\|40\|48\|56\);" "optimized" { target bswap } } } */ + +typedef unsigned char V __attribute__((vector_size (2))); +typedef unsigned char W __attribute__((vector_size (8))); + +__attribute__((noipa)) void +foo (unsigned short x, V *p) +{ + *p = (V) { x >> 8, x }; +} + +__attribute__((noipa)) void +bar (unsigned long long x, W *p) +{ + *p = (W) { x >> 56, x >> 48, x >> 40, x >> 32, x >> 24, x >> 16, x >> 8, x }; +} + +__attribute__((noipa)) void +baz (unsigned short x, V *p) +{ + *p = (V) { x, x >> 8 }; +} + +__attribute__((noipa)) void +qux (unsigned long long x, W *p) +{ + *p = (W) { x, x >> 8, x >> 16, x >> 24, x >> 32, x >> 40, x >> 48, x >> 56 }; +} + +int +main () +{ + V a, c, e, g; + W b, d, f, h; + foo (0xcafe, &a); + bar (0xdeadbeefcafebabeULL, &b); + baz (0xdead, &c); + qux (0xfeedbac1beefdeadULL, &d); + e = (V) { 0xca, 0xfe }; + f = (W) { 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe }; + g = (V) { 0xad, 0xde }; + h = (W) { 0xad, 0xde, 0xef, 0xbe, 0xc1, 0xba, 0xed, 0xfe }; + if (__builtin_memcmp (&a, &e, sizeof (V)) + || __builtin_memcmp (&b, &f, sizeof (W)) + || __builtin_memcmp (&c, &g, sizeof (V)) + || __builtin_memcmp (&d, &h, sizeof (W))) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96260.c b/SingleSource/Regression/C/gcc-dg/pr96260.c new file mode 100644 index 0000000000..587afb7611 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96260.c @@ -0,0 +1,10 @@ +/* PR target/96260 */ +/* { dg-do compile } */ +/* { dg-options "--param asan-stack=1 -fsanitize=kernel-address -fasan-shadow-offset=0x100000" } */ +/* { dg-skip-if "no address sanitizer" { no_fsanitize_address } } */ + +int *bar(int *); +int *f( int a) +{ + return bar(&a); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96298.c b/SingleSource/Regression/C/gcc-dg/pr96298.c new file mode 100644 index 0000000000..8f825751ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96298.c @@ -0,0 +1,18 @@ +/* PR rtl-optimization/96298 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-forwprop" } */ + +typedef unsigned char __attribute__ ((__vector_size__ (8))) v64u8; + +v64u8 a; + +int +main (void) +{ + v64u8 x = (a - 1) ^ -a; + for (unsigned i = 0; i < sizeof (x); i++) + if (x[i] != 0xff) + __builtin_abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr96307.c b/SingleSource/Regression/C/gcc-dg/pr96307.c new file mode 100644 index 0000000000..89002b85c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96307.c @@ -0,0 +1,25 @@ +/* PR target/96307 */ +/* { dg-do compile } */ +/* { dg-additional-options "-fsanitize=kernel-address --param=asan-instrumentation-with-call-threshold=8" } */ +/* { dg-skip-if "no address sanitizer" { no_fsanitize_address } } */ + +#include +enum a {test1, test2, test3=INT_MAX}; +enum a a; +enum a *b; + +void reset (void); + +void +t() +{ + if (a != test2) + __builtin_abort (); + if (*b != test2) + __builtin_abort (); + reset (); + if (a != test1) + __builtin_abort (); + if (*b != test1) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96335.c b/SingleSource/Regression/C/gcc-dg/pr96335.c new file mode 100644 index 0000000000..ab243b3d12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96335.c @@ -0,0 +1,12 @@ +/* PR middle-end/96335 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void bar (int, void *) __attribute__((__access__(__read_only__, 2))); + +void +foo (void *x) +{ + void (*fn) () = bar; + fn (0, x); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96370.c b/SingleSource/Regression/C/gcc-dg/pr96370.c new file mode 100644 index 0000000000..b939b2141d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96370.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target dfp } } */ +/* { dg-options "-O2 -ffast-math" } */ + +void c(_Decimal128); +void a(_Decimal128 b) +{ + c(-b * b); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96377-1.c b/SingleSource/Regression/C/gcc-dg/pr96377-1.c new file mode 100644 index 0000000000..75b0c9618e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96377-1.c @@ -0,0 +1,32 @@ +/* { dg-options "-fno-lax-vector-conversions -Wno-psabi" } */ +/* { dg-message "use '-flax-vector-conversions' to permit conversions" "" { target *-*-* } 0 } */ + +typedef int v4si __attribute__((vector_size(16))); +typedef short v8hi __attribute__((vector_size(16))); + +struct s { v8hi x; v4si y; }; +union u1 { v8hi x; v4si y; }; +union u2 { v4si s; v8hi y; }; + +void +foo (v4si i, v8hi h) +{ + struct s x1 = { i, i }; // { dg-error "incompatible types when initializing type '__vector" } + struct s x2 = { h, h }; // { dg-error "incompatible types" } + struct s x3 = { i, h }; // { dg-error "incompatible types" } + struct s x4 = { h, i }; + + union u1 y1 = { i }; // { dg-error "incompatible types" } + union u1 y2 = { h }; + union u2 y3 = { i }; + union u2 y4 = { h }; // { dg-error "incompatible types" } + + v4si z1[] = { i, i }; + v4si z2[] = { i, h }; // { dg-error "incompatible types" } + v4si z3[] = { h, i }; // { dg-error "incompatible types" } + v4si z4[] = { h, h }; // { dg-error "incompatible types" } + v8hi z5[] = { i, i }; // { dg-error "incompatible types" } + v8hi z6[] = { i, h }; // { dg-error "incompatible types" } + v8hi z7[] = { h, i }; // { dg-error "incompatible types" } + v8hi z8[] = { h, h }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96377-2.c b/SingleSource/Regression/C/gcc-dg/pr96377-2.c new file mode 100644 index 0000000000..8355040115 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96377-2.c @@ -0,0 +1,31 @@ +/* { dg-options "-flax-vector-conversions -Wno-psabi" } */ + +typedef int v4si __attribute__((vector_size(16))); +typedef short v8hi __attribute__((vector_size(16))); + +struct s { v8hi x; v4si y; }; +union u1 { v8hi x; v4si y; }; +union u2 { v4si s; v8hi y; }; + +void +foo (v4si i, v8hi h) +{ + struct s x1 = { i, i }; + struct s x2 = { h, h }; + struct s x3 = { i, h }; + struct s x4 = { h, i }; + + union u1 y1 = { i }; + union u1 y2 = { h }; + union u2 y3 = { i }; + union u2 y4 = { h }; + + v4si z1[] = { i, i }; + v4si z2[] = { i, h }; + v4si z3[] = { h, i }; + v4si z4[] = { h, h }; + v8hi z5[] = { i, i }; + v8hi z6[] = { i, h }; + v8hi z7[] = { h, i }; + v8hi z8[] = { h, h }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96377-3.c b/SingleSource/Regression/C/gcc-dg/pr96377-3.c new file mode 100644 index 0000000000..66dce01f27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96377-3.c @@ -0,0 +1,33 @@ +/* { dg-do compile { target aarch64*-*-* } } */ +/* { dg-options "-fno-lax-vector-conversions" } */ +/* { dg-message "use '-flax-vector-conversions' to permit conversions" "" { target *-*-* } 0 } */ + +typedef int v4si __attribute__((vector_size(16))); +typedef short v8hi __attribute__((vector_size(16))); + +struct s { v8hi x; v4si y; }; +union u1 { v8hi x; v4si y; }; +union u2 { v4si s; v8hi y; }; + +void +foo (__Int32x4_t i, __Int16x8_t h) +{ + struct s x1 = { i, i }; // { dg-error "incompatible types when initializing type '__vector" } + struct s x2 = { h, h }; // { dg-error "incompatible types" } + struct s x3 = { i, h }; // { dg-error "incompatible types" } + struct s x4 = { h, i }; + + union u1 y1 = { i }; // { dg-error "incompatible types" } + union u1 y2 = { h }; + union u2 y3 = { i }; + union u2 y4 = { h }; // { dg-error "incompatible types" } + + v4si z1[] = { i, i }; + v4si z2[] = { i, h }; // { dg-error "incompatible types" } + v4si z3[] = { h, i }; // { dg-error "incompatible types" } + v4si z4[] = { h, h }; // { dg-error "incompatible types" } + v8hi z5[] = { i, i }; // { dg-error "incompatible types" } + v8hi z6[] = { i, h }; // { dg-error "incompatible types" } + v8hi z7[] = { h, i }; // { dg-error "incompatible types" } + v8hi z8[] = { h, h }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96377-4.c b/SingleSource/Regression/C/gcc-dg/pr96377-4.c new file mode 100644 index 0000000000..f7aaf49003 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96377-4.c @@ -0,0 +1,32 @@ +/* { dg-do compile { target aarch64*-*-* } } */ +/* { dg-options "-flax-vector-conversions" } */ + +typedef int v4si __attribute__((vector_size(16))); +typedef short v8hi __attribute__((vector_size(16))); + +struct s { v8hi x; v4si y; }; +union u1 { v8hi x; v4si y; }; +union u2 { v4si s; v8hi y; }; + +void +foo (__Int32x4_t i, __Int16x8_t h) +{ + struct s x1 = { i, i }; + struct s x2 = { h, h }; + struct s x3 = { i, h }; + struct s x4 = { h, i }; + + union u1 y1 = { i }; + union u1 y2 = { h }; + union u2 y3 = { i }; + union u2 y4 = { h }; + + v4si z1[] = { i, i }; + v4si z2[] = { i, h }; + v4si z3[] = { h, i }; + v4si z4[] = { h, h }; + v8hi z5[] = { i, i }; + v8hi z6[] = { i, h }; + v8hi z7[] = { h, i }; + v8hi z8[] = { h, h }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96377-5.c b/SingleSource/Regression/C/gcc-dg/pr96377-5.c new file mode 100644 index 0000000000..3d0c24befa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96377-5.c @@ -0,0 +1,33 @@ +/* { dg-do compile { target aarch64*-*-* } } */ +/* { dg-options "-fno-lax-vector-conversions" } */ +/* { dg-message "use '-flax-vector-conversions' to permit conversions" "" { target *-*-* } 0 } */ + +typedef int v4si __attribute__((vector_size(16))); +typedef short v8hi __attribute__((vector_size(16))); + +struct s { __Int16x8_t x; __Int32x4_t y; }; +union u1 { __Int16x8_t x; __Int32x4_t y; }; +union u2 { __Int32x4_t s; __Int16x8_t y; }; + +void +foo (v4si i, v8hi h) +{ + struct s x1 = { i, i }; // { dg-error "incompatible types when initializing type '__Int16x8_t" } + struct s x2 = { h, h }; // { dg-error "incompatible types" } + struct s x3 = { i, h }; // { dg-error "incompatible types" } + struct s x4 = { h, i }; + + union u1 y1 = { i }; // { dg-error "incompatible types" } + union u1 y2 = { h }; + union u2 y3 = { i }; + union u2 y4 = { h }; // { dg-error "incompatible types" } + + v4si z1[] = { i, i }; + v4si z2[] = { i, h }; // { dg-error "incompatible types" } + v4si z3[] = { h, i }; // { dg-error "incompatible types" } + v4si z4[] = { h, h }; // { dg-error "incompatible types" } + v8hi z5[] = { i, i }; // { dg-error "incompatible types" } + v8hi z6[] = { i, h }; // { dg-error "incompatible types" } + v8hi z7[] = { h, i }; // { dg-error "incompatible types" } + v8hi z8[] = { h, h }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96377-6.c b/SingleSource/Regression/C/gcc-dg/pr96377-6.c new file mode 100644 index 0000000000..165327fa29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96377-6.c @@ -0,0 +1,32 @@ +/* { dg-do compile { target aarch64*-*-* } } */ +/* { dg-options "-flax-vector-conversions" } */ + +typedef int v4si __attribute__((vector_size(16))); +typedef short v8hi __attribute__((vector_size(16))); + +struct s { __Int16x8_t x; __Int32x4_t y; }; +union u1 { __Int16x8_t x; __Int32x4_t y; }; +union u2 { __Int32x4_t s; __Int16x8_t y; }; + +void +foo (v4si i, v8hi h) +{ + struct s x1 = { i, i }; + struct s x2 = { h, h }; + struct s x3 = { i, h }; + struct s x4 = { h, i }; + + union u1 y1 = { i }; + union u1 y2 = { h }; + union u2 y3 = { i }; + union u2 y4 = { h }; + + v4si z1[] = { i, i }; + v4si z2[] = { i, h }; + v4si z3[] = { h, i }; + v4si z4[] = { h, h }; + v8hi z5[] = { i, i }; + v8hi z6[] = { i, h }; + v8hi z7[] = { h, i }; + v8hi z8[] = { h, h }; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96392.c b/SingleSource/Regression/C/gcc-dg/pr96392.c new file mode 100644 index 0000000000..fb7de217f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96392.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/96392 */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +double plus0(int x) +{ + return x + 0.0; +} + +double sub0(int x) +{ + return x - 0.0; +} + +double negate(int x) +{ + return 0.0 - x; +} + +double subtract(int x) +{ + return (double)x - (double)x; +} + +/* { dg-final { scan-tree-dump-not " \\+ " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " \\- " "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr96453.c b/SingleSource/Regression/C/gcc-dg/pr96453.c new file mode 100644 index 0000000000..f758e7ec77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96453.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-Og -fno-early-inlining -fno-tree-ccp -fno-tree-dce" } */ +/* { dg-additional-options "-mavx -mno-sse4.2" { target x86_64-*-* i?86-*-* } } */ + +typedef int __attribute__ ((__vector_size__ (16))) U; +typedef unsigned long __attribute__ ((__vector_size__ (16))) V; + +static inline int +bar (unsigned long e, V f) +{ + V g = f != e; + (union {U b;}){(U) g}; +} + +void +foo (void) +{ + int j = bar (8, (V) { }); + for (unsigned i;; i[&j]) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96466.c b/SingleSource/Regression/C/gcc-dg/pr96466.c new file mode 100644 index 0000000000..a8840f5b6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96466.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/96466 */ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-Og -finline-functions-called-once -fno-tree-ccp" } */ + +typedef unsigned long __attribute__ ((__vector_size__ (8))) V; + +V +bar (unsigned long x, V v) +{ + v &= x >= v; + return (V) v; +} + +V +foo (void) +{ + return bar (5, (V) 4441221375); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96514.c b/SingleSource/Regression/C/gcc-dg/pr96514.c new file mode 100644 index 0000000000..891b4da2b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96514.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +int __attribute__ ((pure, returns_twice)) +r0 (void); + +void +vy (int t7) +{ + while (t7 == 0) + r0 (); +} + +void +qw (int t7) +{ + vy (t7); + + if (0) + r0 (); +} + +void __attribute__ ((simd)) +un (int t7) +{ + qw (t7); + qw (t7); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96542.c b/SingleSource/Regression/C/gcc-dg/pr96542.c new file mode 100644 index 0000000000..1080be7e75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96542.c @@ -0,0 +1,27 @@ +/* { dg-do compile} */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ +/* { dg-require-effective-target int32 } */ + +unsigned char +foo (unsigned int x) +{ + _Bool y = x; + return (((unsigned char) ~0) >> y) * 2; +} + +unsigned char +bar (unsigned int x) +{ + return (((unsigned char) ~0) >> (_Bool) x) * 2; +} + +unsigned +baz (unsigned int x) +{ + if (x >= 4) return 32; + return (-1U >> x) * 16; +} + +/* { dg-final { scan-tree-dump-times "return 254" 2 "evrp" } } */ +/* { dg-final { scan-tree-dump "= PHI <32.*, 4294967280" "evrp" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr96558.c b/SingleSource/Regression/C/gcc-dg/pr96558.c new file mode 100644 index 0000000000..2f5739e9e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96558.c @@ -0,0 +1,32 @@ +/* PR target/96558 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fno-expensive-optimizations -fno-gcse" } */ + +int ky; +long int h1; +__int128 f1; + +int +sd (void); + +int __attribute__ ((simd)) +i8 (void) +{ + __int128 vh; + + if (sd () == 0) + h1 = 0; + + do + { + long int lf = (long int) f1 ? h1 : 0; + + ky += lf; + vh = lf | f1; + f1 = 1; + } + while (vh < (f1 ^ 2)); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr96573.c b/SingleSource/Regression/C/gcc-dg/pr96573.c new file mode 100644 index 0000000000..c7d8f9eb99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96573.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/96573 */ +/* { dg-do compile { target { lp64 || ilp32 } } } */ +/* { dg-require-effective-target bswap } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump "__builtin_bswap\|VEC_PERM_EXPR\[^\n\r]*7, 6, 5, 4, 3, 2, 1, 0" "optimized" { xfail vect_variable_length } } } */ + +typedef __SIZE_TYPE__ size_t; + +void * +foo (void * const p) +{ + const size_t m = sizeof (p) - 1; + const unsigned char * const o = (unsigned char*) &p; + void *n; + unsigned char * const q = (unsigned char *) &n; + unsigned char i; + for (i = 0; i <= m; ++i) + q[m - i] = o[i]; + return n; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96579.c b/SingleSource/Regression/C/gcc-dg/pr96579.c new file mode 100644 index 0000000000..982f8ac17a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96579.c @@ -0,0 +1,4 @@ +/* { dg-do compile { target dfp } } */ +/* { dg-options "-O -fno-tree-forwprop -ffast-math -fno-tree-vrp" } */ + +#include "pr96370.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr96674.c b/SingleSource/Regression/C/gcc-dg/pr96674.c new file mode 100644 index 0000000000..790cd85dcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96674.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options "-O -fdump-tree-optimized -fwrapv" } */ +/* { dg-require-effective-target int32 } */ + +#include +#include + +bool __attribute__ ((noipa)) test1 (unsigned a, unsigned b) +{ + return (b == 0) | (a < b); +} + +bool __attribute__ ((noipa)) test2 (int a, int b) +{ + return (b == INT_MIN) | (a < b); +} + +bool __attribute__ ((noipa)) test3 (unsigned a, unsigned b) +{ + return (b != 0) & (a >= b); +} + +bool __attribute__ ((noipa)) test4 (int a, int b) +{ + return (b != INT_MIN) & (a >= b); +} + +int main() +{ + if (!test1 (1, 0) || !test1 (1, 2) || test1 (2, 1) || + !test2 (1, INT_MIN) || !test2 (1, 2) || test2 (2, 1) || + test3 (1, 0) || test3 (1, 2) || !test3 (2, 1) || + test4 (1, INT_MIN) || test4 (1, 2) || !test4 (2, 1)) { + __builtin_abort(); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "\\+ 4294967295;" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\+ -1;" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-1.c b/SingleSource/Regression/C/gcc-dg/pr96695-1.c new file mode 100644 index 0000000000..d4287ab4c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool and1(unsigned *x, unsigned *y) +{ + /* x > y && x != 0 --> x > y */ + return x > y && x != 0; +} + +_Bool and2(unsigned *x, unsigned *y) +{ + /* x < y && x != -1 --> x < y */ + return x < y && x != (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " != " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-10.c b/SingleSource/Regression/C/gcc-dg/pr96695-10.c new file mode 100644 index 0000000000..dfe752526f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-10.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool or1(unsigned *x, unsigned *y) +{ + /* x <= y || x != 0 --> true */ + return x <= y || x != 0; +} + +_Bool or2(unsigned *x, unsigned *y) +{ + /* x >= y || x != -1 --> true */ + return x >= y || x != (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " != " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " <= " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >= " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-11.c b/SingleSource/Regression/C/gcc-dg/pr96695-11.c new file mode 100644 index 0000000000..d3c36168b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-11.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool or1(unsigned *x, unsigned *y) +{ + /* x <= y || x == 0 --> x <= y */ + return x <= y || x == 0; +} + +_Bool or2(unsigned *x, unsigned *y) +{ + /* x >= y || x == -1 --> x >= y */ + return x >= y || x == (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " == " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-12.c b/SingleSource/Regression/C/gcc-dg/pr96695-12.c new file mode 100644 index 0000000000..9ce2ddf8a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-12.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-dce3" } */ + +#include + +_Bool or1(unsigned *x, unsigned *y) +{ + /* x <= y || x == 0 --> x <= y */ + return x <= y || x == 0; +} + +_Bool or2(unsigned *x, unsigned *y) +{ + /* x >= y || x == -1 --> x >= y */ + return x >= y || x == (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " == " "dce3" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-2.c b/SingleSource/Regression/C/gcc-dg/pr96695-2.c new file mode 100644 index 0000000000..6d347c3b26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool and1(unsigned *x, unsigned *y) +{ + /* x > y && x != 0 --> x > y */ + return x > y && x != 0; +} + +_Bool and2(unsigned *x, unsigned *y) +{ + /* x < y && x != -1 --> x < y */ + return x < y && x != (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " != " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-3.c b/SingleSource/Regression/C/gcc-dg/pr96695-3.c new file mode 100644 index 0000000000..b205b27dc8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-3.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool and1(unsigned *x, unsigned *y) +{ + /* x > y && x == 0 --> false */ + return x > y && x == 0; +} + +_Bool and2(unsigned *x, unsigned *y) +{ + /* x < y && x == -1 --> false */ + return x < y && x == (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " == " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " > " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " < " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-4.c b/SingleSource/Regression/C/gcc-dg/pr96695-4.c new file mode 100644 index 0000000000..a5aa8de8dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-4.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool and1(unsigned *x, unsigned *y) +{ + /* x > y && x == 0 --> false */ + return x > y && x == 0; +} + +_Bool and2(unsigned *x, unsigned *y) +{ + /* x < y && x == -1 --> false */ + return x < y && x == (unsigned*)-1; +} + + +/* { dg-final { scan-tree-dump-not " == " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " > " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-5.c b/SingleSource/Regression/C/gcc-dg/pr96695-5.c new file mode 100644 index 0000000000..54d8f1a3a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool and1(unsigned *x, unsigned *y) +{ + /* x <= y && x == 0 --> x == 0 */ + return x <= y && x == 0; +} + +_Bool and2(unsigned *x, unsigned *y) +{ + /* x >= y && x == -1 --> x == -1 */ + return x >= y && x == (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " <= " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " >= " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-6.c b/SingleSource/Regression/C/gcc-dg/pr96695-6.c new file mode 100644 index 0000000000..15745246a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-6.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool and1(unsigned *x, unsigned *y) +{ + /* x <= y && x == 0 --> x == 0 */ + return x <= y && x == 0; +} + +_Bool and2(unsigned *x, unsigned *y) +{ + /* x >= y && x == -1 --> x == -1 */ + return x >= y && x == (unsigned*)-1; +} + + +/* { dg-final { scan-tree-dump-not " <= " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " >= " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-7.c b/SingleSource/Regression/C/gcc-dg/pr96695-7.c new file mode 100644 index 0000000000..7977ae12f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-7.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool or1(unsigned *x, unsigned *y) +{ + /* x > y || x != 0 --> x != 0 */ + return x > y || x != 0; +} + +_Bool or2(unsigned *x, unsigned *y) +{ + /* x < y || x != -1 --> x != -1 */ + return x < y || x != (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " > " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " < " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-8.c b/SingleSource/Regression/C/gcc-dg/pr96695-8.c new file mode 100644 index 0000000000..ecda865f79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-8.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include + +_Bool or1(unsigned *x, unsigned *y) +{ + /* x > y || x != 0 --> x != 0 */ + return x > y || x != 0; +} + +_Bool or2(unsigned *x, unsigned *y) +{ + /* x < y || x != -1 --> x != -1 */ + return x < y || x != (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " > " "optimized" } } */ +/* { dg-final { scan-tree-dump-not " < " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96695-9.c b/SingleSource/Regression/C/gcc-dg/pr96695-9.c new file mode 100644 index 0000000000..b87522c463 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96695-9.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcombine" } */ + +#include + +_Bool or1(unsigned *x, unsigned *y) +{ + /* x <= y || x != 0 --> true */ + return x <= y || x != 0; +} + +_Bool or2(unsigned *x, unsigned *y) +{ + /* x >= y || x != -1 --> true */ + return x >= y || x != (unsigned*)-1; +} + +/* { dg-final { scan-tree-dump-not " != " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " <= " "ifcombine" } } */ +/* { dg-final { scan-tree-dump-not " >= " "ifcombine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96708-negative.c b/SingleSource/Regression/C/gcc-dg/pr96708-negative.c new file mode 100644 index 0000000000..91964d3b97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96708-negative.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +#include + +bool __attribute__ ((noinline)) +test1 (int a, int b) +{ + int tmp = (a < b) ? b : a; + return tmp <= a; +} + +bool __attribute__ ((noinline)) +test2 (int a, int b) +{ + int tmp = (a < b) ? b : a; + return tmp > a; +} + +bool __attribute__ ((noinline)) +test3 (int a, int b) +{ + int tmp = (a > b) ? b : a; + return tmp >= a; +} + +bool __attribute__ ((noinline)) +test4 (int a, int b) +{ + int tmp = (a > b) ? b : a; + return tmp < a; +} + +int main() +{ + if (test1 (1, 2) || !test1 (2, 1) || + !test2 (1, 2) || test2 (2, 1) || + !test3 (1, 2) || test3 (2, 1) || + test4 (1, 2) || !test4 (2, 1)) { + __builtin_abort(); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 0;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not { "return 1;" } "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96708-positive.c b/SingleSource/Regression/C/gcc-dg/pr96708-positive.c new file mode 100644 index 0000000000..65af85344b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96708-positive.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +#include + +bool __attribute__ ((noinline)) +test1(int a, int b) +{ + int tmp = (a < b) ? b : a; + return tmp >= a; +} + +bool __attribute__ ((noinline)) +test2(int a, int b) +{ + int tmp = (a < b) ? b : a; + return tmp < a; +} + +bool __attribute__ ((noinline)) +test3(int a, int b) +{ + int tmp = (a > b) ? b : a; + return tmp <= a; +} + +bool __attribute__ ((noinline)) +test4(int a, int b) +{ + int tmp = (a > b) ? b : a; + return tmp > a; +} + +int main() +{ + if (!test1 (1, 2) || !test1 (2, 1) || + test2 (1, 2) || test2 (2, 1) || + !test3 (1, 2) || !test3 (2, 1) || + test4 (1, 2) || test4 (2, 1)) { + __builtin_abort(); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "return 0;" 3 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 1;" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not { "MAX_EXPR" } "optimized" } } */ +/* { dg-final { scan-tree-dump-not { "MIN_EXPR" } "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr96818.c b/SingleSource/Regression/C/gcc-dg/pr96818.c new file mode 100644 index 0000000000..ea2ac540d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96818.c @@ -0,0 +1,14 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int a, b, c; +void d() { + unsigned short e; + while (b) + ; + e = (e + 5) / a; + switch (e) + case 0: + case 3: + c = a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr96931.c b/SingleSource/Regression/C/gcc-dg/pr96931.c new file mode 100644 index 0000000000..660391588f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr96931.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fpredictive-commoning -fno-tree-loop-im -fdump-tree-pcom-details-blocks" } */ + +int bl; + +void +p3 (void); + +void __attribute__ ((returns_twice)) +ie (void) +{ + p3 (); + + bl = 0; + for (;;) + ++bl; + + ie (); +} +/* { dg-final { scan-tree-dump-not "Invalid sum" "pcom" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr97078.c b/SingleSource/Regression/C/gcc-dg/pr97078.c new file mode 100644 index 0000000000..997d5fb8dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97078.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffloat-store" } */ + +extern void foo (long double); + +void bar (long double d) +{ + foo (d); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97172-2.c b/SingleSource/Regression/C/gcc-dg/pr97172-2.c new file mode 100644 index 0000000000..99cc6c29ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97172-2.c @@ -0,0 +1,9 @@ +/* PR middle-end/97172 - ICE: tree code ‘ssa_name’ is not supported in LTO + streams + { dg-do link } + { dg-options "-Wall -flto -fpic -shared" } + { dg-require-effective-target fpic } + { dg-require-effective-target shared } + { dg-require-effective-target lto } */ + +#include "pr97172.c" diff --git a/SingleSource/Regression/C/gcc-dg/pr97172.c b/SingleSource/Regression/C/gcc-dg/pr97172.c new file mode 100644 index 0000000000..8ae6342db7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97172.c @@ -0,0 +1,81 @@ +/* PR middle-end/97172 - ICE: tree code ‘ssa_name’ is not supported in LTO + streams + { dg-do compile } + { dg-options "-Wall -flto" } + { dg-require-effective-target lto } */ + +int n; + +void fn (int a[n]); +void fnp1 (int a[n + 1]); + +void fx_n (int a[][n]); +void fx_np1 (int a[][n + 1]); + +void f2_n (int a[2][n]); +void f2_np1 (int a[2][n + 1]); + +void fn_3 (int a[n][3]); +void fnp1_3 (int a[n + 1][3]); + +void fn_n (int a[n][n]); +void fn_np1 (int a[n][n + 1]); +void fnp1_np1 (int a[n + 1][n + 1]); + +void fn_n_n (int a[n][n][n]); +void fn_n_np1 (int a[n][n][n + 1]); +void fn_np1_np1 (int a[n][n + 1][n + 1]); +void fnp1_np1_np1 (int a[n + 1][n + 1][n + 1]); + + +void gn (int a[n]) { fn (a); } +void gnp1 (int a[n + 1]) { fnp1 (a); } +void gnd2p1 (int a[n / 2 + 1]) { fnp1 (a); } + +void gx_n (int a[][n]) { fx_n (a); } +void gx_np1 (int a[][n + 1]) { fx_np1 (a); } +void gx_nd2p1 (int a[][n / 2 + 1]) { fx_np1 (a); } + +void g2_n (int a[2][n]) { f2_n (a); } +void g2_np1 (int a[2][n + 1]) { f2_np1 (a); } +void g2_nd2p1 (int a[2][n / 2 + 1]) { f2_np1 (a); } + +void gn_3 (int a[n][3]) { fn_3 (a); } +void gnp1_3 (int a[n + 1][3]) { fnp1_3 (a); } +void gnd2p1_3 (int a[n / 2 + 1][3]) { fnp1_3 (a); } + +void gn_n (int a[n][n]) { fn_n (a); } +void gn_np1 (int a[n][n + 1]) { fn_np1 (a); } +void gnp1_np1 (int a[n + 1][n + 1]) { fnp1_np1 (a); } +void gnd2p1_nd2p1 (int a[n / 2 + 1][n / 2 + 1]) { fnp1_np1 (a); } + +void gn_n_n (int a[n][n][n]) { fn_n_n (a); } +void gn_n_np1 (int a[n][n][n + 1]) { fn_n_np1 (a); } +void gn_np1_np1 (int a[n][n + 1][n + 1]) { fn_np1_np1 (a); } +void gnp1_np1_np1 (int a[n + 1][n + 1][n + 1]) { fnp1_np1_np1 (a); } +void gnd2p1_nd2p1_nd2p1 (int a[n / 2 + 1][n / 2 + 1][n / 2 + 1]) +{ fnp1_np1_np1 (a); } + + +void fna3_1 (int n, + int a[n / 2 + 1], + int b[n / 2 + 1], + int c[n / 2 + 1]); + +void gna3_1 (int n, + int a[n / 2 + 1], + int b[n / 2 + 1], + int c[n / 2 + 1]) { fna3_1 (n, a, b, c); } + +void fna3_2_3_4 (int n, + int a[n / 2 + 1][n / 2 + 2], + int b[n / 2 + 1][n / 2 + 2][n / 2 + 3], + int c[n / 2 + 1][n / 2 + 2][n / 2 + 3][n / 2 + 4]); + +void gna3_2_3_4 (int n, + int a[n / 2 + 1][n / 2 + 2], + int b[n / 2 + 1][n / 2 + 2][n / 2 + 3], + int c[n / 2 + 1][n / 2 + 2][n / 2 + 3][n / 2 + 4]) +{ + fna3_2_3_4 (n, a, b, c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97192.c b/SingleSource/Regression/C/gcc-dg/pr97192.c new file mode 100644 index 0000000000..16647ca67a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97192.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftracer" } */ +/* { dg-additional-options "-mavx512vl" { target x86_64-*-* i?86-*-* } } */ + +typedef int __attribute__ ((__vector_size__ (32))) V; + +int a, b; +V v; + +int +foo (void) +{ + b -= 4 - !a; + V u = 0 != v == a; + return u[0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97238.c b/SingleSource/Regression/C/gcc-dg/pr97238.c new file mode 100644 index 0000000000..746e93a975 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97238.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wno-psabi -w" } */ + +typedef int __attribute__ ((__vector_size__ (8))) V; +int b, c, e; +V d; + +V +foo (void) +{ + return (b || e) | c > d | ((b || e) | c > d); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97315-2.c b/SingleSource/Regression/C/gcc-dg/pr97315-2.c new file mode 100644 index 0000000000..5dd1b6a3fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97315-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void c(int); + +int a; +void b() +{ + if (a >= 2147483647) + c(a + 1); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97317.c b/SingleSource/Regression/C/gcc-dg/pr97317.c new file mode 100644 index 0000000000..fdc1a62d54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97317.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target int32plus } */ + +struct a { + unsigned c : 17; +}; +struct a b; +int d(void) { + short e = b.c; + return e ? 0 : b.c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97322.c b/SingleSource/Regression/C/gcc-dg/pr97322.c new file mode 100644 index 0000000000..f253c0d761 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97322.c @@ -0,0 +1,17 @@ +/* PR target/97322 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo (unsigned long long x, unsigned long long *y) +{ + y[0] = x / 10; + y[1] = x % 10; +} + +void +bar (unsigned int x, unsigned int *y) +{ + y[0] = x / 10; + y[1] = x % 10; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97357.c b/SingleSource/Regression/C/gcc-dg/pr97357.c new file mode 100644 index 0000000000..6b391b7a74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97357.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include +#include + +void * my_malloc (size_t size); + +typedef struct glk { + struct glk *nxt; +} glk; + +typedef struct Lock +{ + glk ByteLock; +} Lock; + +static Lock *l, *lk; + +void bytelocks(glk *rethead, jmp_buf jb) +{ + glk *cur, *cur_lk; + + if (( setjmp (jb)) == 0) + for (cur = &l->ByteLock; cur != ((glk *)0) ; cur = (cur)->nxt) + for (cur_lk = &lk->ByteLock; cur_lk != ((glk *)0); cur_lk = cur_lk->nxt) + { + glk *retrng; + + if(!rethead) + rethead = (glk *) my_malloc (sizeof(glk)); + retrng = (glk *) my_malloc (sizeof(glk)); + + retrng->nxt = rethead; + } + + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97359.c b/SingleSource/Regression/C/gcc-dg/pr97359.c new file mode 100644 index 0000000000..142542e404 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97359.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +typedef unsigned int uint32_t; +int a; +void b(uint32_t c) { + uint32_t *d = &c; + for (; a;) + for (;; (*d %= a) / (*d > 1 > (c > 0)) ?: d) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97360-2.c b/SingleSource/Regression/C/gcc-dg/pr97360-2.c new file mode 100644 index 0000000000..48aebf1b10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97360-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 " } */ + +void *a; +void *b(void); +void *e(void); + +void * +c() { + void *d; + if (d == b && e()) + d = a; + return d; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97371.c b/SingleSource/Regression/C/gcc-dg/pr97371.c new file mode 100644 index 0000000000..ffefad0287 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97371.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +int a, b; +void c() { + if (b >> 38) + a = b; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97378.c b/SingleSource/Regression/C/gcc-dg/pr97378.c new file mode 100644 index 0000000000..27e4a1f432 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97378.c @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int a, b, c; +void d() { +e : { + long f; + long *g = &f; + if ((a != 0) - (b = 0)) + ; + else + a &= (*g %= a *= c) >= (*g || f); + goto e; +} +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97381.c b/SingleSource/Regression/C/gcc-dg/pr97381.c new file mode 100644 index 0000000000..947692cb1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97381.c @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int a; +void b() { + char c = 27; + for (; c <= 85; c += 1) { + a /= 148372120 * c; + if (a) + for (;;) + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97396.c b/SingleSource/Regression/C/gcc-dg/pr97396.c new file mode 100644 index 0000000000..d992c11f23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97396.c @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-O1 -ftree-vrp" } +// { dg-additional-options "-m32" { target { i?86-*-* x86_64-*-* } } } + +unsigned int +po (char *os, unsigned int al) +{ + for (;;) + { + int qx = 0; + + while (al < 1) + { + char *cw; + + cw = os + qx; + if (cw) + return al + qx; + + qx += sizeof *cw; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97459-1.c b/SingleSource/Regression/C/gcc-dg/pr97459-1.c new file mode 100644 index 0000000000..96c7ab6d7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97459-1.c @@ -0,0 +1,54 @@ +/* PR rtl-optimization/97459 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } */ + +#ifdef __SIZEOF_INT128__ +typedef __uint128_t T; +#else +typedef unsigned long long T; +#endif + +T __attribute__((noipa)) foo (T x, T n) { return x % n; } +#define C(n) T __attribute__((noipa)) foo##n (T x) { return x % (n - 10000); } + +#define C1(n) C(n##1) C(n##3) C(n##5) C(n##7) C(n##9) +#define C2(n) C1(n##0) C1(n##1) C1(n##2) C1(n##3) C1(n##4) \ + C1(n##5) C1(n##6) C1(n##7) C1(n##8) C1(n##9) +#ifdef EXPENSIVE +#define C3(n) C2(n##0) C2(n##1) C2(n##2) C2(n##3) C2(n##4) \ + C2(n##5) C2(n##6) C2(n##7) C2(n##8) C2(n##9) +#define C4(n) C3(n##0) C3(n##1) C3(n##2) C3(n##3) C3(n##4) \ + C3(n##5) C3(n##6) C3(n##7) C3(n##8) C3(n##9) +#else +#define C3(n) C2(n##0) C2(n##4) C2(n##9) +#define C4(n) C3(n##0) C3(n##3) C3(n##7) +#endif +#define TESTS C4(1) C1(10010) C1(10012) C1(16144) + +TESTS + +struct S { T x; T (*foo) (T); }; + +#undef C +#define C(n) { n - 10000, foo##n }, + +struct S tests[] = { +TESTS + { 0, 0 } +}; + +int +main () +{ + int i, j, k; + for (k = 0; tests[k].x; k++) + for (i = 0; i < sizeof (T) * __CHAR_BIT__; i++) + for (j = -5; j <= 5; j++) + { + T x = ((T) 1 << i) + j; + if (foo (x, tests[k].x) != tests[k].foo (x)) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97459-2.c b/SingleSource/Regression/C/gcc-dg/pr97459-2.c new file mode 100644 index 0000000000..0e2bfbd5c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97459-2.c @@ -0,0 +1,57 @@ +/* PR rtl-optimization/97459 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } */ + +#ifdef __SIZEOF_INT128__ +typedef __int128_t T; +typedef __uint128_t U; +#else +typedef long long T; +typedef unsigned long long U; +#endif + +T __attribute__((noipa)) foo (T x, T n) { return x % n; } +#define C(n) T __attribute__((noipa)) foo##n (T x) { return x % (n - 10000); } + +#define C1(n) C(n##1) C(n##3) C(n##5) C(n##7) C(n##9) +#define C2(n) C1(n##0) C1(n##1) C1(n##2) C1(n##3) C1(n##4) \ + C1(n##5) C1(n##6) C1(n##7) C1(n##8) C1(n##9) +#ifdef EXPENSIVE +#define C3(n) C2(n##0) C2(n##1) C2(n##2) C2(n##3) C2(n##4) \ + C2(n##5) C2(n##6) C2(n##7) C2(n##8) C2(n##9) +#define C4(n) C3(n##0) C3(n##1) C3(n##2) C3(n##3) C3(n##4) \ + C3(n##5) C3(n##6) C3(n##7) C3(n##8) C3(n##9) +#else +#define C3(n) C2(n##0) C2(n##4) C2(n##9) +#define C4(n) C3(n##0) C3(n##3) C3(n##7) +#endif +#define TESTS C4(1) C1(10010) C1(10012) C1(16144) + +TESTS + +struct S { T x; T (*foo) (T); }; + +#undef C +#define C(n) { n - 10000, foo##n }, + +struct S tests[] = { +TESTS + { 0, 0 } +}; + +int +main () +{ + int i, j, k; + for (k = 0; tests[k].x; k++) + for (i = 0; i < sizeof (T) * __CHAR_BIT__; i++) + for (j = -5; j <= 5; j++) + { + U x = ((U) 1 << i) + j; + if (foo ((T) x, tests[k].x) != tests[k].foo ((T) x) + || foo ((T) -x, tests[k].x) != tests[k].foo ((T) -x)) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97459-3.c b/SingleSource/Regression/C/gcc-dg/pr97459-3.c new file mode 100644 index 0000000000..7fbb7eec28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97459-3.c @@ -0,0 +1,54 @@ +/* PR rtl-optimization/97459 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } */ + +#ifdef __SIZEOF_INT128__ +typedef __uint128_t T; +#else +typedef unsigned long long T; +#endif + +T __attribute__((noipa)) foo (T x, T n) { return x / n; } +#define C(n) T __attribute__((noipa)) foo##n (T x) { return x / (n - 10000); } + +#define C1(n) C(n##1) C(n##3) C(n##5) C(n##7) C(n##9) +#define C2(n) C1(n##0) C1(n##1) C1(n##2) C1(n##3) C1(n##4) \ + C1(n##5) C1(n##6) C1(n##7) C1(n##8) C1(n##9) +#ifdef EXPENSIVE +#define C3(n) C2(n##0) C2(n##1) C2(n##2) C2(n##3) C2(n##4) \ + C2(n##5) C2(n##6) C2(n##7) C2(n##8) C2(n##9) +#define C4(n) C3(n##0) C3(n##1) C3(n##2) C3(n##3) C3(n##4) \ + C3(n##5) C3(n##6) C3(n##7) C3(n##8) C3(n##9) +#else +#define C3(n) C2(n##0) C2(n##4) C2(n##9) +#define C4(n) C3(n##0) C3(n##3) C3(n##7) +#endif +#define TESTS C4(1) C1(10010) C1(10012) C1(16144) + +TESTS + +struct S { T x; T (*foo) (T); }; + +#undef C +#define C(n) { n - 10000, foo##n }, + +struct S tests[] = { +TESTS + { 0, 0 } +}; + +int +main () +{ + int i, j, k; + for (k = 0; tests[k].x; k++) + for (i = 0; i < sizeof (T) * __CHAR_BIT__; i++) + for (j = -5; j <= 5; j++) + { + T x = ((T) 1 << i) + j; + if (foo (x, tests[k].x) != tests[k].foo (x)) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97459-4.c b/SingleSource/Regression/C/gcc-dg/pr97459-4.c new file mode 100644 index 0000000000..33e49a9cb5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97459-4.c @@ -0,0 +1,57 @@ +/* PR rtl-optimization/97459 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } */ + +#ifdef __SIZEOF_INT128__ +typedef __int128_t T; +typedef __uint128_t U; +#else +typedef long long T; +typedef unsigned long long U; +#endif + +T __attribute__((noipa)) foo (T x, T n) { return x / n; } +#define C(n) T __attribute__((noipa)) foo##n (T x) { return x / (n - 10000); } + +#define C1(n) C(n##1) C(n##3) C(n##5) C(n##7) C(n##9) +#define C2(n) C1(n##0) C1(n##1) C1(n##2) C1(n##3) C1(n##4) \ + C1(n##5) C1(n##6) C1(n##7) C1(n##8) C1(n##9) +#ifdef EXPENSIVE +#define C3(n) C2(n##0) C2(n##1) C2(n##2) C2(n##3) C2(n##4) \ + C2(n##5) C2(n##6) C2(n##7) C2(n##8) C2(n##9) +#define C4(n) C3(n##0) C3(n##1) C3(n##2) C3(n##3) C3(n##4) \ + C3(n##5) C3(n##6) C3(n##7) C3(n##8) C3(n##9) +#else +#define C3(n) C2(n##0) C2(n##4) C2(n##9) +#define C4(n) C3(n##0) C3(n##3) C3(n##7) +#endif +#define TESTS C4(1) C1(10010) C1(10012) C1(16144) + +TESTS + +struct S { T x; T (*foo) (T); }; + +#undef C +#define C(n) { n - 10000, foo##n }, + +struct S tests[] = { +TESTS + { 0, 0 } +}; + +int +main () +{ + int i, j, k; + for (k = 0; tests[k].x; k++) + for (i = 0; i < sizeof (T) * __CHAR_BIT__; i++) + for (j = -5; j <= 5; j++) + { + U x = ((U) 1 << i) + j; + if (foo ((T) x, tests[k].x) != tests[k].foo ((T) x) + || foo ((T) -x, tests[k].x) != tests[k].foo ((T) -x)) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97459-5.c b/SingleSource/Regression/C/gcc-dg/pr97459-5.c new file mode 100644 index 0000000000..f658a5a896 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97459-5.c @@ -0,0 +1,56 @@ +/* PR rtl-optimization/97459 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } */ + +#ifdef __SIZEOF_INT128__ +typedef __uint128_t T; +#else +typedef unsigned long long T; +#endif + +T __attribute__((noipa)) foo (T x, T n, T *r) { *r = x % n; return x / n; } +#define C(n) T __attribute__((noipa)) foo##n (T x, T *r) { *r = x % (n - 10000); return x / (n - 10000); } + +#define C1(n) C(n##1) C(n##3) C(n##5) C(n##7) C(n##9) +#define C2(n) C1(n##0) C1(n##1) C1(n##2) C1(n##3) C1(n##4) \ + C1(n##5) C1(n##6) C1(n##7) C1(n##8) C1(n##9) +#ifdef EXPENSIVE +#define C3(n) C2(n##0) C2(n##1) C2(n##2) C2(n##3) C2(n##4) \ + C2(n##5) C2(n##6) C2(n##7) C2(n##8) C2(n##9) +#define C4(n) C3(n##0) C3(n##1) C3(n##2) C3(n##3) C3(n##4) \ + C3(n##5) C3(n##6) C3(n##7) C3(n##8) C3(n##9) +#else +#define C3(n) C2(n##0) C2(n##4) C2(n##9) +#define C4(n) C3(n##0) C3(n##3) C3(n##7) +#endif +#define TESTS C4(1) C1(10010) C1(10012) C1(16144) + +TESTS + +struct S { T x; T (*foo) (T, T *); }; + +#undef C +#define C(n) { n - 10000, foo##n }, + +struct S tests[] = { +TESTS + { 0, 0 } +}; + +int +main () +{ + int i, j, k; + for (k = 0; tests[k].x; k++) + for (i = 0; i < sizeof (T) * __CHAR_BIT__; i++) + for (j = -5; j <= 5; j++) + { + T x = ((T) 1 << i) + j; + T r1, r2; + if (foo (x, tests[k].x, &r1) != tests[k].foo (x, &r2) + || r1 != r2) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97459-6.c b/SingleSource/Regression/C/gcc-dg/pr97459-6.c new file mode 100644 index 0000000000..d4602be57d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97459-6.c @@ -0,0 +1,62 @@ +/* PR rtl-optimization/97459 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-DEXPENSIVE" { target run_expensive_tests } } */ + +#ifdef __SIZEOF_INT128__ +typedef __int128_t T; +typedef __uint128_t U; +#else +typedef long long T; +typedef unsigned long long U; +#endif + +T __attribute__((noipa)) foo (T x, T n, T *r) { *r = x % n; return x / n; } +#define C(n) T __attribute__((noipa)) foo##n (T x, T *r) { *r = x % (n - 10000); return x / (n - 10000); } + +#define C1(n) C(n##1) C(n##3) C(n##5) C(n##7) C(n##9) +#define C2(n) C1(n##0) C1(n##1) C1(n##2) C1(n##3) C1(n##4) \ + C1(n##5) C1(n##6) C1(n##7) C1(n##8) C1(n##9) +#ifdef EXPENSIVE +#define C3(n) C2(n##0) C2(n##1) C2(n##2) C2(n##3) C2(n##4) \ + C2(n##5) C2(n##6) C2(n##7) C2(n##8) C2(n##9) +#define C4(n) C3(n##0) C3(n##1) C3(n##2) C3(n##3) C3(n##4) \ + C3(n##5) C3(n##6) C3(n##7) C3(n##8) C3(n##9) +#else +#define C3(n) C2(n##0) C2(n##4) C2(n##9) +#define C4(n) C3(n##0) C3(n##3) C3(n##7) +#endif +#define TESTS C4(1) C1(10010) C1(10012) C1(16144) + +TESTS + +struct S { T x; T (*foo) (T, T *); }; + +#undef C +#define C(n) { n - 10000, foo##n }, + +struct S tests[] = { +TESTS + { 0, 0 } +}; + +int +main () +{ + int i, j, k; + for (k = 0; tests[k].x; k++) + for (i = 0; i < sizeof (T) * __CHAR_BIT__; i++) + for (j = -5; j <= 5; j++) + { + U x = ((U) 1 << i) + j; + T r1 = 0, r2 = 0; + if (foo ((T) x, tests[k].x, &r1) != tests[k].foo ((T) x, &r2) + || r1 != r2) + __builtin_abort (); + r1 = 0; r2 = 0; + if (foo ((T) -x, tests[k].x, &r1) != tests[k].foo ((T) -x, &r2) + || r1 != r2) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97462.c b/SingleSource/Regression/C/gcc-dg/pr97462.c new file mode 100644 index 0000000000..52c0533c98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97462.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +int a, b; + +void d () +{ + a << ~0 && b; + b = a; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97463.c b/SingleSource/Regression/C/gcc-dg/pr97463.c new file mode 100644 index 0000000000..f93b07ccb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97463.c @@ -0,0 +1,7 @@ +/* PR c/97463 - ICE in warn_parm_ptrarray_mismatch on an incompatible + function redeclaration + { dg-do compile } + { dg-options "-Wall" } */ + +void f (void**); +void f (int n) { } // { dg-error "conflicting types" } diff --git a/SingleSource/Regression/C/gcc-dg/pr97467.c b/SingleSource/Regression/C/gcc-dg/pr97467.c new file mode 100644 index 0000000000..dcbd218f73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97467.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +int a; +long b; +unsigned int c = 1; + +int main () { + int e; + for (; c <= 0; c++) { + int f = 0; + b = e; + a = f || b << c; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97487-1.c b/SingleSource/Regression/C/gcc-dg/pr97487-1.c new file mode 100644 index 0000000000..e79d1f14c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97487-1.c @@ -0,0 +1,9 @@ +/* PR middle-end/97487 */ +/* { dg-do compile } */ +/* { dg-options "-O2 --param max-rtl-if-conversion-unpredictable-cost=0" } */ + +long int __attribute__ ((simd)) +foo (long int x, long int y) +{ + return x < 0 ? y : 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97487-2.c b/SingleSource/Regression/C/gcc-dg/pr97487-2.c new file mode 100644 index 0000000000..0b623814a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97487-2.c @@ -0,0 +1,18 @@ +/* PR middle-end/97487 */ +/* { dg-do compile } */ +/* { dg-options "-O2 --param max-rtl-if-conversion-unpredictable-cost=0 -Wno-psabi -w" } */ + +typedef long long int V __attribute__((vector_size (16))); + +long long int +foo (V x, V y) +{ + long long int t1 = y[0]; + long long int t2 = x[0]; + long long int t3; + if (t2 < 0) + t3 = t1; + else + t3 = 0; + return t3; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97488.c b/SingleSource/Regression/C/gcc-dg/pr97488.c new file mode 100644 index 0000000000..de7396cd4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97488.c @@ -0,0 +1,11 @@ +// { dg-do compile { target int128 } } +// { dg-options "-O1 -ftree-vrp" } + +__int128 +ef (__int128 ms) +{ + int dh = 129; + int *hj = &dh; + + return ms << *hj ? ms : 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97501.c b/SingleSource/Regression/C/gcc-dg/pr97501.c new file mode 100644 index 0000000000..aedac83962 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97501.c @@ -0,0 +1,14 @@ +// { dg-do compile } +// { dg-options "-O2" } + +static int c = 0; + +int main() { + int b = 0; + if (c) { + for (;; b--) + do + b++; + while (b); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97502.c b/SingleSource/Regression/C/gcc-dg/pr97502.c new file mode 100644 index 0000000000..d87af9c183 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97502.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +extern char v[54]; +void bar (char *); +void +foo (void) +{ + int i; + char c[32]; + bar (c); + for (i = 0; i < 32; i++) + c[i] = c[i] && !v[i]; + bar (c); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97505.c b/SingleSource/Regression/C/gcc-dg/pr97505.c new file mode 100644 index 0000000000..f01d912067 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97505.c @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-Os -fsanitize=signed-integer-overflow -fdump-tree-evrp" } + +// Test that .UBSAN_CHECK_SUB(y, x) is treated as y-x for range +// purposes, where X and Y are related to each other. +// +// This effectively checks that range relationals work with builtins. + +void unreachable(); + +int foobar(int x, int y) +{ + if (x < y) + { + int z = y - x; + if (z == 0) + unreachable(); + return z; + } + return 5; +} + +// { dg-final { scan-tree-dump-not "unreachable" "evrp" } } diff --git a/SingleSource/Regression/C/gcc-dg/pr97515.c b/SingleSource/Regression/C/gcc-dg/pr97515.c new file mode 100644 index 0000000000..b4f2481cb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97515.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp2" } */ + +int +e7 (int gg) +{ + int xe = 0; + + while (xe < 1) + { + int ui; + + ui = ~xe; + if (ui == 0) + ui = xe >> gg; + + xe %= !ui; + } + + return xe; +} + +/* EVRP should be able to reduce this to a single goto when we can + * revisit statements to try folding again based on changed inputs. + * Until then, make sure its gone by ccp2. */ + +/* { dg-final { scan-tree-dump-times "goto" 1 "ccp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr97520.c b/SingleSource/Regression/C/gcc-dg/pr97520.c new file mode 100644 index 0000000000..9f66595913 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97520.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-fre" } */ + +char a; +void b() { + char *c[5]; + char *d = &a; + &d; + *(c[4] = d); +} +int main() { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr97534.c b/SingleSource/Regression/C/gcc-dg/pr97534.c new file mode 100644 index 0000000000..b363a322aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97534.c @@ -0,0 +1,9 @@ +/* PR target/97534 - ICE in decompose on arm*-*-*. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -O2 -g" } */ + +int f (int a) +{ + int b; + __atomic_fetch_sub(&b, (int)(-__INT_MAX__ - 1), (int)0); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97539.c b/SingleSource/Regression/C/gcc-dg/pr97539.c new file mode 100644 index 0000000000..def55e1d6e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97539.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -g" } */ + +int a, b; +void c() { + char d; + for (; b;) + for (;;) + for (; d <= 7; d += 1) { + a = 7; + for (; a; a += 1) + e: + d += d; + d ^= 0; + } + goto e; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97555.c b/SingleSource/Regression/C/gcc-dg/pr97555.c new file mode 100644 index 0000000000..625bc6fa14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97555.c @@ -0,0 +1,22 @@ +// { dg-do run } +// { dg-options "-Os" } + +struct { + int a:1; +} b; + +int c, d, e, f = 1, g; + +int main () +{ + for (; d < 3; d++) { + char h = 1 % f, i = ~(0 || ~0); + c = h; + f = ~b.a; + ~b.a | 1 ^ ~i && g; + if (~e) + i = b.a; + b.a = i; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97567-2.c b/SingleSource/Regression/C/gcc-dg/pr97567-2.c new file mode 100644 index 0000000000..c3ead54eaa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97567-2.c @@ -0,0 +1,24 @@ +/* { dg-do compile} */ +/* { dg-options "-O2 -fdump-tree-evrp -fdisable-tree-ethread" } */ + +char a[2]; + +extern int x; + +void foo(void); + +signed char g (signed char min, signed char max) +{ + signed char i = x; + return i < min || max < i ? min : i; +} + +void gg (void) +{ + signed char t = g (0, 9); + /* Ranger should be able to remove the call to foo (). */ + if (t > 9 || t < 0) + foo (); +} + +/* { dg-final { scan-tree-dump-not "foo" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr97567.c b/SingleSource/Regression/C/gcc-dg/pr97567.c new file mode 100644 index 0000000000..8922f27721 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97567.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int a, b, c, d; +void k() { + unsigned f = 1; + long long g = 4073709551615; + for (; a; a++) + for (;;) { + d = 0; + L1: + break; + } + if (f) + for (; a; a++) + ; + g || f; + int i = 0 - f || g; + long long j = g - f; + if (j || f) { + if (g < 4073709551615) + for (;;) + ; + int e = ~f, h = b / ~e; + if (c) + goto L2; + g = f = h; + } + g || d; +L2: + if (c) + goto L1; +} +int main() { k(); return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr97579.c b/SingleSource/Regression/C/gcc-dg/pr97579.c new file mode 100644 index 0000000000..5cd5427a52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97579.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 --param=max-unswitch-insns=1024" } */ +/* { dg-additional-options "-mavx512vl" { target x86_64-*-* i?86-*-* } } */ + +int bad_odd_rows_0_0, rows_bad_row1, rows_bad_group_okay, calc_rows_row2; + +int +rows_bad() { + int i, in_zeroes; + char block; + i = 0; + for (; i < 5; i++) + if (rows_bad_row1 & i) + in_zeroes = 0; + else { + if (!in_zeroes) + in_zeroes = 1; + if (block & 1) + rows_bad_group_okay = 1; + } + if (in_zeroes) + return rows_bad_group_okay; +} + +void +calc_rows() { + for (; calc_rows_row2; calc_rows_row2++) { + rows_bad(); + bad_odd_rows_0_0 = rows_bad(); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97596.c b/SingleSource/Regression/C/gcc-dg/pr97596.c new file mode 100644 index 0000000000..b0726adba2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97596.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2" } */ + +void +q8 (__int128 *uv, unsigned short int nf) +{ + __int128 i4; + + i4 = -nf; + if (i4 << 1 != 0) + *uv += nf; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97721.c b/SingleSource/Regression/C/gcc-dg/pr97721.c new file mode 100644 index 0000000000..c2a2848ba1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97721.c @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-O -fno-tree-dominator-opts" } + +int ot; + +void +z6 (char *tw) +{ + while (ot >= 0) + --ot; + + __builtin_strcpy (&tw[ot], tw); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97725.c b/SingleSource/Regression/C/gcc-dg/pr97725.c new file mode 100644 index 0000000000..2fcb12cc30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97725.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a; +unsigned b; + +int main() { + if (a) { + goto L1; + while (1) + while (1) { + long e = -1L, g; + int f, h, i; + L1: + a = f; + L2: + g = e; + f = h || g; + e = ~(f & b); + if (i || g < -1L) { + ~(g || 0); + break; + } + goto L2; + } + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97737.c b/SingleSource/Regression/C/gcc-dg/pr97737.c new file mode 100644 index 0000000000..eef1c35319 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97737.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a = 1, b, c; + +void d() { + int e = 1; +L1: + b = e; +L2: + e = e / a; + if (!(e || c || e - 1)) + goto L1; + if (!b) + goto L2; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97741.c b/SingleSource/Regression/C/gcc-dg/pr97741.c new file mode 100644 index 0000000000..47115d31d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97741.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra -fno-strict-aliasing -fwrapv -Os -fno-toplevel-reorder -fno-tree-ccp -fno-tree-fre" } */ + +short a = 0; +long b = 0; +char c = 0; +void d() { + int e = 0; +f: + for (a = 6; a;) + c = e; + e = 0; + for (; e == 20; ++e) + for (; b;) + goto f; +} +int main() { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/pr97750.c b/SingleSource/Regression/C/gcc-dg/pr97750.c new file mode 100644 index 0000000000..ff0d436af2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97750.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/97750 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wextra" } */ +/* { dg-require-effective-target ptr_eq_long } */ + +char CopyPlane_src; +long CopyPlane_copy_pitch; +char *CopyFromUswc_src; +int CopyFromUswc_height; +void CopyPlane(char *dst) { + __builtin_memcpy(dst, &CopyPlane_src, CopyPlane_copy_pitch); +} +void CopyFromUswc(long src_pitch) { + char *dst; + for (; CopyFromUswc_height;) { + unsigned unaligned = (long)CopyFromUswc_src; + if (unaligned) + CopyPlane(&dst[unaligned]); + CopyFromUswc_src += src_pitch; + } +} +/* { dg-prune-output "-Wmaybe-uninitialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr97806.c b/SingleSource/Regression/C/gcc-dg/pr97806.c new file mode 100644 index 0000000000..9ec3299c0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97806.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int b; +long c; +int g(); +void h(long *); +void i(long *); +void d() { + int e, f = b - e; + if (g()) + h(&c + f); + else + i(&c + f); + __builtin_memset(0, 0, f * 8); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97830.c b/SingleSource/Regression/C/gcc-dg/pr97830.c new file mode 100644 index 0000000000..3729a65aec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97830.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef enum { LangC } cLanguage; +typedef enum { FunctionOneArg, FunctionStandard } cFunctionType; +void *CCTK_CallFunction_function; +cLanguage CCTK_CallFunction_fdata_0; +cFunctionType CCTK_CallFunction_fdata_1; +void CCTK_CallFunction_data() { + void (*standardfunc)(); + int (*oneargfunc)(); + switch (CCTK_CallFunction_fdata_1) { + case FunctionOneArg: + oneargfunc = CCTK_CallFunction_function; + oneargfunc(CCTK_CallFunction_data); + break; + case FunctionStandard: + switch (CCTK_CallFunction_fdata_0) { + case LangC: + standardfunc = CCTK_CallFunction_function; + standardfunc(CCTK_CallFunction_data); + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97860.c b/SingleSource/Regression/C/gcc-dg/pr97860.c new file mode 100644 index 0000000000..04c0f194bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97860.c @@ -0,0 +1,11 @@ +/* PR c/97860 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo (int n) +{ + typedef int T[0]; + typedef T V[n]; + void bar (V); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97882.c b/SingleSource/Regression/C/gcc-dg/pr97882.c new file mode 100644 index 0000000000..48ea93d53c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97882.c @@ -0,0 +1,144 @@ +/* PR c/97882 - Segmentation Fault on improper redeclaration of function + { dg-do compile } + { dg-options "" } */ + +// Check pointer declaration incompatibiliies. + +extern enum E e_u; // { dg-message "note: previous declaration of 'e_u' with type 'enum E'" "note" } +unsigned e_u; // { dg-error "conflicting types for 'e_u'; have 'unsigned int'" } + + +extern enum E *p; // { dg-message "note: previous declaration of 'p' with type 'enum E \\*'" "note" } +unsigned *p; // { dg-error "conflicting types for 'p'; have 'unsigned int \\*'" } + +extern enum E **p2; // { dg-message "note: previous declaration of 'p2' with type 'enum E \\*\\*'" "note" } +unsigned **p2; // { dg-error "conflicting types for 'p2'; have 'unsigned int \\*\\*'" } + +extern enum E ***p3; // { dg-message "note: previous declaration of 'p3' with type 'enum E \\*\\*\\*'" "note" } +unsigned ***p3; // { dg-error "conflicting types for 'p3'; have 'unsigned int \\*\\*\\*'" } + +extern enum F *q; // { dg-message "note: previous declaration of 'q' with type 'enum F \\*'" "note" } +int *q; // { dg-error "conflicting types for 'q'; have 'int \\*'" } + +extern enum E* r[]; // { dg-message "note: previous declaration of 'r' with type 'enum E \\*\\\[]'" "note" } +extern unsigned *r[1]; // { dg-error "conflicting types for 'r'; have 'unsigned int \\*\\\[1]'" } + +extern enum E **r2[]; // { dg-message "note: previous declaration of 'r2' with type 'enum E \\*\\*\\\[]'" "note" } +extern unsigned **r2[2];// { dg-error "conflicting types for 'r2'; have 'unsigned int \\*\\*\\\[2]'" } + + +typedef enum E* EPAx[]; +typedef unsigned* UPAx[]; + +extern EPAx* peax; // { dg-message "note: previous declaration of 'peax' with type 'enum E \\* \\(\\*\\)\\\[]'" "note" } +extern UPAx* peax; // { dg-error "conflicting types for 'peax'; have 'unsigned int \\* \\(\\*\\)\\\[]'" } + + +/* Check incompatibilities in the return type in a redeclaration + of a function without a prototye. */ + +/* Verify the following isn't rejected. */ +void f_v (); +void f_v (void); + +enum E fE_u (); // { dg-message "previous declaration of 'fE_u' with type 'enum E\\(\\)'" "note" } +unsigned fE_u (); // { dg-error "conflicting types for 'fE_u'; have 'unsigned int\\(\\)'" } + +enum E* fpE_u (); // { dg-message "previous declaration of 'fpE_u' with type 'enum E \\*\\(\\)'" "note" } +unsigned* fpE_u (); // { dg-error "conflicting types for 'fpE_u'; have 'unsigned int \\*\\(\\)'" } + +enum E** fppE_u (); // { dg-message "previous declaration of 'fppE_u' with type 'enum E \\*\\*\\(\\)'" "note" } +unsigned** fppE_u (); // { dg-error "conflicting types for 'fppE_u'; have 'unsigned int \\*\\*\\(\\)'" } + +enum E** fppE_u (); // { dg-message "previous declaration of 'fppE_u' with type 'enum E \\*\\*\\(\\)'" "note" } +unsigned** fppE_u (); // { dg-error "conflicting types for 'fppE_u'; have 'unsigned int \\*\\*\\(\\)'" } + +enum E gE_u (); // { dg-message "previous declaration of 'gE_u' with type 'enum E\\(\\)'" "note" } +unsigned gE_u () // { dg-error "conflicting types for 'gE_u'; have 'unsigned int\\(\\)'" } +{ return 0; } + +enum E** gppE_u (); // { dg-message "previous declaration of 'gppE_u' with type 'enum E \\*\\*\\(\\)'" "note" } +unsigned** gppE_u () // { dg-error "conflicting types for 'gppE_u'; have 'unsigned int \\*\\*\\(\\)'" } +{ return 0; } + +unsigned fu_E (); // { dg-message "previous declaration of 'fu_E' with type 'unsigned int\\(\\)'" "note" } +enum E fu_E (); // { dg-error "conflicting types for 'fu_E'; have 'enum E\\(\\)'" } + +unsigned gu_E (); // { dg-message "previous declaration of 'gu_E' with type 'unsigned int\\(\\)'" "note" } +enum E gu_E () { } // { dg-error "conflicting types for 'gu_E'" } + // { dg-error "incomplete type" "return type" { target *-*-* } .-1 } + +typedef enum E FE_ (); +typedef unsigned Fuv (void); + +FE_* fpF_u (); // // { dg-message "previous declaration of 'fpF_u' with type 'enum E \\(\\*\\(\\)\\)\\(\\)'" "note" } +Fuv* fpF_u (); // { dg-error "conflicting types for 'fpF_u'; have 'unsigned int \\(\\*\\(\\)\\)\\(void\\)'" } + + +typedef void Fv_ (); +typedef void Fvv (void); + +/* Verify the following isn't rejected. */ +Fv_* f (); +Fvv* f (); + + +/* Check incompatibilities in argument types of a function redeclaration. */ + +void fvE_u (enum E); // { dg-message "note: previous declaration of 'fvE_u' with type 'void\\(enum E\\)'" "note" } +void fvE_u (unsigned); // { dg-error "conflicting types for 'fvE_u'; have 'void\\(unsigned int\\)'" } + +void fviE_u (int, enum E); // { dg-message "note: previous declaration of 'fviE_u' with type 'void\\(int, *enum E\\)'" "note" } +void fviE_u (int, unsigned); // { dg-error "conflicting types for 'fviE_u'; have 'void\\(int, *unsigned int\\)'" } + +void fvE_el (enum E, ...); // { dg-message "note: previous declaration of 'fvE_el' with type 'void\\(enum E, \\.\\.\\.\\)'" "note" } +void fvE_el (unsigned, ...); // { dg-error "conflicting types for 'fvE_el'; have 'void\\(unsigned int, \\.\\.\\.\\)'" } + + +/* Check incompatibilities in the return type in a redeclaration + of a nested function without a prototye. */ + +void f1 (void) +{ + enum G f11 (); // { dg-message "note: previous declaration of 'f11' with type 'enum G\\(\\)'" "note" } + unsigned f11 () { } // { dg-error "conflicting types for 'f11'; have 'unsigned int\\(\\)'" } +} + + +void f2 (void) +{ + const enum G f21 (); // { dg-message "note: previous declaration of 'f21' with type 'enum G\\(\\)'" "note" } + unsigned f21 () { } // { dg-error "conflicting types for 'f21'; have 'unsigned int\\(\\)'" } +} + + +void f3 (void) +{ + enum G f31 (); // { dg-message "note: previous declaration of 'f31' with type 'enum G\\(\\)'" "note" } + const unsigned f31 () { } // { dg-error "conflicting types for 'f31'; have 'unsigned int\\(\\)'" } +} + + +void f4 (void) +{ + auto enum G f31 (); // { dg-message "note: previous declaration of 'f31' with type 'enum G\\(\\)'" "note" } + const unsigned f31 () { } // { dg-error "conflicting types for 'f31'; have 'unsigned int\\(\\)'" } +} + + +void f5 (void) +{ + enum G* f51 (); // { dg-message "note: previous declaration of 'f51' with type 'enum G \\*\\(\\)'" "note" } + int* f51 () { } // { dg-error "conflicting types for 'f51'; have 'int \\*\\(\\)'" } +} + + +void f6 (void) +{ + enum G; + void f61 (enum G); // { dg-message "note: previous declaration of 'f61' with type 'void\\(enum G\\)'" "note" } + void f61 (unsigned) // { dg-error "conflicting types for 'f61'; have 'void\\(unsigned int\\)'" } + { } +} + +// { dg-prune-output "nested function '\[^\n\r ]+' declared but never defined" } diff --git a/SingleSource/Regression/C/gcc-dg/pr97897.c b/SingleSource/Regression/C/gcc-dg/pr97897.c new file mode 100644 index 0000000000..084c1cdbfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97897.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void h (); +void f () __attribute__ ((returns_twice)); +void g (_Complex int a) +{ + f (); + if (a != 0) + { + a = 0; + h (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97932.c b/SingleSource/Regression/C/gcc-dg/pr97932.c new file mode 100644 index 0000000000..4a0b304137 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97932.c @@ -0,0 +1,125 @@ +/* Verify that we don't emit ranges that span both + a macro definition location and a macro expansion location. */ + +/* { dg-options "-fdiagnostics-show-caret" } */ + +/* Various cases involving the ranges of the LHS and RHS operands to "-". */ + +/* Case 1 + start token is in macro definition ("&"), + end token is in macro invocation ("a" and "b"). */ + +#define M1(A, B) &A - &B /* { dg-error "invalid operands" } */ + +/* Intervening + material + that + ought + not + to + be + printed. */ + +int test_1 (float a, int b) +{ + return M1(a, b); /* { dg-message "in expansion of macro 'M1'" } */ +} + +/* { dg-begin-multiline-output "" } + #define M1(A, B) &A - &B + ^ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + return M1(a, b); + ^~ + { dg-end-multiline-output "" } */ + +/* Case 2: + start and end tokens are both in macro invocation ("&", and "a"/"b"). */ + +#define M2(A, B) A - B /* { dg-error "invalid operands" } */ + +/* Intervening + material + that + ought + not + to + be + printed. */ + +int test_2 (float a, int b) +{ + return M2(&a, &b); /* { dg-message "in expansion of macro 'M2'" } */ +} + +/* { dg-begin-multiline-output "" } + #define M2(A, B) A - B + ^ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + return M2(&a, &b); + ^~ + { dg-end-multiline-output "" } */ + +/* Case 3: + start token is in macro invocation ("&"), + end token is in macro definition ("a"). */ + +#define M3(OP) OP a - OP b /* { dg-error "invalid operands" } */ + +/* Intervening + material + that + ought + not + to + be + printed. */ + +int test_3 (float a, int b) +{ + return M3(&); /* { dg-message "in expansion of macro 'M3'" } */ +} + +/* { dg-begin-multiline-output "" } + #define M3(OP) OP a - OP b + ^ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + return M3(&); + ^~ + { dg-end-multiline-output "" } */ + + +/* Case 4: + start and end tokens are both in macro definition ("&a"). */ + +#define M4 &a - &b /* { dg-error "invalid operands" } */ + +/* Intervening + material + that + ought + not + to + be + printed. */ + +int test_4 (float a, int b) +{ + return M4; /* { dg-message "in expansion of macro 'M4'" } */ +} + +/* { dg-begin-multiline-output "" } + #define M4 &a - &b + ~~ ^ ~~ + | | + | int * + float * + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } + return M4; + ^~ + { dg-end-multiline-output "" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/pr97953.c b/SingleSource/Regression/C/gcc-dg/pr97953.c new file mode 100644 index 0000000000..6219619d67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97953.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-fre" } */ + +int __attribute__((noipa)) +foo (int flag, int *p) +{ + int val = *p; + if (flag) + { + if (val != 1) + __builtin_unreachable (); + return 0; + } + int val2 = *p; + return val2 == 2; +} + +int main() +{ + int i = 2; + if (foo (0, &i) != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97954.c b/SingleSource/Regression/C/gcc-dg/pr97954.c new file mode 100644 index 0000000000..0be60f500b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97954.c @@ -0,0 +1,12 @@ +/* PR rtl-optimization/97954 */ +/* { dg-do compile { target lra } } */ +/* { dg-options "-O2" } */ + +int +foo (void) +{ + int x; + lab: + asm goto ("": "=r" (x) : : : lab); + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97955.c b/SingleSource/Regression/C/gcc-dg/pr97955.c new file mode 100644 index 0000000000..a5236c76c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97955.c @@ -0,0 +1,7 @@ +/* PR 97955 - ICE in build_array_type_1 on invalid redeclaration of function + with VLA parameter + { dg-do compile } + { dg-options "-Wall" } */ + +void f (int n, int a[n]); +void f (int *b) { } // { dg-error "conflicting types" } diff --git a/SingleSource/Regression/C/gcc-dg/pr97979.c b/SingleSource/Regression/C/gcc-dg/pr97979.c new file mode 100644 index 0000000000..44aaff2ab5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97979.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/97979 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-ccp" } */ + +short a = 0; +int b = 0; + +void +foo (void) +{ + unsigned short d = b; + a = d >> -2U; /* { dg-warning "right shift count >= width of type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr97981.c b/SingleSource/Regression/C/gcc-dg/pr97981.c new file mode 100644 index 0000000000..846b8755c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr97981.c @@ -0,0 +1,15 @@ +/* PR c/97981 */ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ +/* { dg-final { scan-tree-dump-times "atomic_load" 2 "original" } } */ + + +void f(void) +{ + volatile _Atomic int x; + x; + volatile _Atomic double a; + double b; + b = a; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr98029.c b/SingleSource/Regression/C/gcc-dg/pr98029.c new file mode 100644 index 0000000000..148f23ce5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98029.c @@ -0,0 +1,21 @@ +/* pr98029 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +double f2 (void) +{ + volatile double d; + int i; + + for (d = 2.0, i = 0; i < 5; i++, d *= d) /* { dg-bogus "right-hand operand of comma expression has no effect" } */ + ; + + return d; +} + +int g(void) +{ + volatile int x; + (x = 1, (void)1); /* { dg-bogus "right-hand operand of comma expression has no effect" } */ + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98099.c b/SingleSource/Regression/C/gcc-dg/pr98099.c new file mode 100644 index 0000000000..c78d43e838 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98099.c @@ -0,0 +1,13 @@ +/* PR middle-end/98099 */ +/* Reported by G. Steinmetz */ + +/* { dg-do compile { target { dfp && { be || le } } } } */ +/* { dg-options "-fsso-struct=big-endian" { target le } } */ +/* { dg-options "-fsso-struct=little-endian" { target be } } */ + +struct S { _Decimal128 a; }; + +_Decimal128 f (struct S x) +{ + return x.a; /* { dg-message "sorry, unimplemented: reverse storage order" "" { target { ! int128 } } } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr9814-1.c b/SingleSource/Regression/C/gcc-dg/pr9814-1.c new file mode 100644 index 0000000000..51b79f7839 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr9814-1.c @@ -0,0 +1,107 @@ +/* PR tree-optimization/9814 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +extern void abort(void); + +int test1(int x) +{ + if (x & 2) + x |= 2; + return x; +} + +int test2(int x) +{ + if (!(x & 2)) + x |= 2; + return x; +} + +int test3(int x) +{ + if (x & 2) + x ^= 2; + return x; +} + +int test4(int x) +{ + if (!(x & 2)) + x ^= 2; + return x; +} + +int test5(int x) +{ + if (x & 2) + x &= ~2; + return x; +} + +int test6(int x) +{ + if (!(x & 2)) + x &= ~2; + return x; +} + +int main() +{ + if (test1(0) != 0) + abort(); + if (test1(2) != 2) + abort(); + if (test1(5) != 5) + abort(); + if (test1(7) != 7) + abort(); + + if (test2(0) != 2) + abort(); + if (test2(2) != 2) + abort(); + if (test2(5) != 7) + abort(); + if (test2(7) != 7) + abort(); + + if (test3(0) != 0) + abort(); + if (test3(2) != 0) + abort(); + if (test3(5) != 5) + abort(); + if (test3(7) != 5) + abort(); + + if (test4(0) != 2) + abort(); + if (test4(2) != 2) + abort(); + if (test4(5) != 7) + abort(); + if (test4(7) != 7) + abort(); + + if (test5(0) != 0) + abort(); + if (test5(2) != 0) + abort(); + if (test5(5) != 5) + abort(); + if (test5(7) != 5) + abort(); + + if (test6(0) != 0) + abort(); + if (test6(2) != 2) + abort(); + if (test6(5) != 5) + abort(); + if (test6(7) != 7) + abort(); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr98147.c b/SingleSource/Regression/C/gcc-dg/pr98147.c new file mode 100644 index 0000000000..3edc7985f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98147.c @@ -0,0 +1,10 @@ +/* PR target/98147 */ + +char buffer[32] = "foo bar"; + +int +main () +{ + __builtin___clear_cache (buffer, buffer + 32); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98190.c b/SingleSource/Regression/C/gcc-dg/pr98190.c new file mode 100644 index 0000000000..bfdd17d927 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98190.c @@ -0,0 +1,33 @@ +/* PR middle-end/98190 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +static int __attribute__((noipa)) +foo (const char *p, const char *q, const int len) +{ + for (int i = 0; i < len; p++, q++, i++) + { + int equal; + _Bool x, y; + __builtin_memcpy ((char *) &x, p, sizeof x); + __builtin_memcpy ((char *) &y, q, sizeof y); + equal = (x == y); + if (equal <= 0) + return equal; + } + return 1; +} + +int +main () +{ + const _Bool buf[4] = { 1, 0, 0, 0 }; +#ifdef __aarch64__ + register long x4 asm ("x4") = 0xdeadbeefULL; + register long x5 asm ("x5") = 0xcafebabeULL; + asm volatile (""::"r" (x4), "r" (x5)); +#endif + if (foo ((char *) &buf[0], (char *) &buf[0], 1) != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98198.c b/SingleSource/Regression/C/gcc-dg/pr98198.c new file mode 100644 index 0000000000..489afae998 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98198.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +static inline void sub_1 ( ) { + struct struct_1 var_9 , var_10 +} + +static int var_9[1] __attribute__ ( ( section ( ".data" ) ) ) ; +/* { dg-excess-errors "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr98211.c b/SingleSource/Regression/C/gcc-dg/pr98211.c new file mode 100644 index 0000000000..8f14c8f98e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98211.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu90 -O3 -fgimple" } */ + +int test_var_3; +short arr_20[16]; +void __GIMPLE (ssa,startwith("slp")) +test (int var_1, short int a, short int b, short int c, short int d) +{ + _Bool tem2; + _Bool tem; + unsigned int i_5; + int _24; + _Bool _28; + short int _30; + short int _32; + _Bool _29; + _Bool _31; + + __BB(2): + _24 = test_var_3; + tem_25 = _24 != 0; + tem2_26 = var_1_11(D) != 0; + _28 = tem_25 | tem2_26; + _29 = _28 != _Literal (_Bool) 0; + _30 = _29 ? a_16(D) : b_15(D); + arr_20[0u] = _30; + _31 = _28 != _Literal (_Bool) 0; + _32 = _31 ? c_19(D) : d_18(D); + arr_20[8u] = _32; + arr_20[1u] = _30; + arr_20[9u] = _32; + arr_20[2u] = _30; + arr_20[10u] = _32; + arr_20[3u] = _30; + arr_20[11u] = _32; + arr_20[4u] = _30; + arr_20[12u] = _32; + arr_20[5u] = _30; + arr_20[13u] = _32; + arr_20[6u] = _30; + arr_20[14u] = _32; + arr_20[7u] = _30; + arr_20[15u] = _32; + return; +} + + +int +main() +{ + test (1, 0x88, 0x77, 0x77, 0x88); + if (arr_20[0] != 0x88) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98255.c b/SingleSource/Regression/C/gcc-dg/pr98255.c new file mode 100644 index 0000000000..5cbed682cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98255.c @@ -0,0 +1,49 @@ +/* PR tree-optimization/98255 */ +/* { dg-do run } */ +/* { dg-options "-Os" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ + +struct A { volatile unsigned b; unsigned c; }; +int d, *e, h, k, l; +static struct A f; +long g; +static unsigned i = -2U; +volatile int j; + +long +foo (void) +{ + char n[4][4][3] + = { { {9, 2, 8}, {9, 2, 8}, {9, 2, 8}, {9} }, { {8} }, { {8} }, { {2} } }; + while (d) + { + for (; f.c < 4; f.c++) + { + *e = 0; + h = n[f.c + 4][0][d]; + } + while (g) + return n[0][3][i]; + while (1) + { + if (k) + { + j = 0; + if (j) + continue; + } + if (l) + break; + } + } + return 0; +} + +int +main () +{ + asm volatile ("" : "+g" (d), "+g" (g), "+g" (f.c)); + asm volatile ("" : "+g" (e), "+g" (k), "+g" (l)); + foo (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98271.c b/SingleSource/Regression/C/gcc-dg/pr98271.c new file mode 100644 index 0000000000..b453434612 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98271.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/98271 */ +/* PR rtl-optimization/98276 */ +/* PR tree-optimization/98279 */ +/* { dg-do compile } */ +/* { dg-options "-O --param=align-loop-iterations=1197120096074465280 --param=gcse-cost-distance-ratio=2147483648 --param=hot-bb-frequency-fraction=2147483648" } */ +/* { dg-error "argument to .--param=align-loop-iterations=. is bigger than 2147483647" "" { target *-*-* } 0 } */ +/* { dg-error "argument to .--param=gcse-cost-distance-ratio=. is bigger than 2147483647" "" { target *-*-* } 0 } */ +/* { dg-error "argument to .--param=hot-bb-frequency-fraction=. is bigger than 2147483647" "" { target *-*-* } 0 } */ + +void +foo (void) +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98272.c b/SingleSource/Regression/C/gcc-dg/pr98272.c new file mode 100644 index 0000000000..126a61642e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98272.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/98272 */ +/* Reported by Zdenek Sojka */ + +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-forwprop" } */ + +void bar (void); + +void +foo (unsigned char uc) +{ + if (uc >= 5) + return; + + switch (uc) + { + case 0: + case 2: + case 4: + bar (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98287.c b/SingleSource/Regression/C/gcc-dg/pr98287.c new file mode 100644 index 0000000000..031442850c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98287.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/98287 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-ccp -fno-tree-forwprop -Wno-psabi -w" } */ + +typedef unsigned long __attribute__((__vector_size__ (8))) V; +V v; + +static __attribute__((noinline, noclone)) V +bar (unsigned short s) +{ + return v >> s << s | v >> s >> 63; +} + +unsigned long +foo (void) +{ + V x = bar (1); + return x[0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98304-1.c b/SingleSource/Regression/C/gcc-dg/pr98304-1.c new file mode 100644 index 0000000000..dce54ddffe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98304-1.c @@ -0,0 +1,57 @@ +/* PR tree-optimization/98304 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* Signed test function. */ +__attribute__((noipa)) int foo(int n) { + return n - (((n > 63) ? n : 63) & -64); +} + +/* Unsigned test function. */ +__attribute__((noipa)) unsigned int bar(unsigned int n) { + return n - (((n > 63) ? n : 63) & -64); +} + +/* Different power of 2. */ +__attribute__((noipa)) int goo(int n) { + return n - (((n > 31) ? n : 31) & -32); +} + +/* Commutative property (should be identical to foo) */ +__attribute__((noipa)) int baz(int n) { + return n - (((64 > n) ? 63 : n) & -64); +} + +/* < instead of >. */ +__attribute__((noipa)) int fred(int n) { + return n - (((63 < n) ? n : 63) & -64); +} + +/* Constant is not a power of 2 so should not simplify. */ +__attribute__((noipa)) int qux(int n) { + return n - (((n > 62) ? n : 62) & -63); +} + +/* Constant is not a power of 2 so should not simplify. */ +__attribute__((noipa)) unsigned int quux(unsigned int n) { + return n - (((n > 62) ? n : 62) & -63); +} + +/* Constant is a variable so should not simplify. */ +__attribute__((noipa)) int waldo(int n, int x) { + return n - (((n > 63) ? n : 63) & x); +} + +/* Difference between constants is not -1. */ +__attribute__((noipa)) int corge(int n) { + return n - (((n > 1) ? n : 1) & -64); +} + +/* Difference between constants is not -1. */ +__attribute__((noipa)) unsigned int thud(unsigned int n) +{ + return n - (((n > 1) ? n : 1) & -64); +} + +/* { dg-final { scan-tree-dump-times " - " 5 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " <= " 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr98330.c b/SingleSource/Regression/C/gcc-dg/pr98330.c new file mode 100644 index 0000000000..bc68a6fa21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98330.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +float f (__typeof (__builtin_pow) fn, float x) +{ + return fn (x, 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98331.c b/SingleSource/Regression/C/gcc-dg/pr98331.c new file mode 100644 index 0000000000..951b7586a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98331.c @@ -0,0 +1,18 @@ +/* PR debug/98331 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -fcompare-debug" } */ +/* { dg-additional-options "-march=x86-64" { target { i?86-*-* x86_64-*-* } } } */ + +void bar (const char *); +unsigned long long x; + +void +foo (void) +{ + int a = 1; + bar ("foo"); + int b = 2; + __atomic_fetch_add (&x, 1, 0); + int c = 3; + __builtin_unreachable (); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98350-1.c b/SingleSource/Regression/C/gcc-dg/pr98350-1.c new file mode 100644 index 0000000000..a7f10f10d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98350-1.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast --param tree-reassoc-width=2 -fdump-tree-widening_mul" } */ +/* { dg-additional-options "-mfpmath=sse -mfma" { target { i?86-*-* x86_64-*-* } } } */ + +/* Test that the compiler properly optimizes multiply and add + to generate more FMA instructions. */ +#define N 1024 +double a[N]; +double b[N]; +double c[N]; +double d[N]; +double e[N]; +double f[N]; +double g[N]; +double h[N]; +double j[N]; +double k[N]; +double l[N]; +double m[N]; +double o[N]; +double p[N]; + + +void +foo (void) +{ + for (int i = 0; i < N; i++) + { + a[i] += b[i] * c[i] + d[i] * e[i] + f[i] * g[i] + h[i] * j[i] + k[i] * l[i] + m[i]* o[i] + p[i]; + } +} +/* { dg-final { scan-tree-dump-times { = \.FMA \(} 6 "widening_mul" { target { i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr98350-2.c b/SingleSource/Regression/C/gcc-dg/pr98350-2.c new file mode 100644 index 0000000000..bad6455921 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98350-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast --param tree-reassoc-width=2 -fdump-tree-widening_mul" } */ +/* { dg-additional-options "-mfpmath=sse -mfma" { target { i?86-*-* x86_64-*-* } } } */ + +/* Test that the compiler rearrange the ops to generate more FMA. */ + +float +foo1 (float a, float b, float c, float d, float *e) +{ + return *e + a * b + c * d ; +} +/* { dg-final { scan-tree-dump-times { = \.FMA \(} 2 "widening_mul" { target { i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr98420.c b/SingleSource/Regression/C/gcc-dg/pr98420.c new file mode 100644 index 0000000000..c289b845d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98420.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffinite-math-only -frounding-math -fdump-tree-optimized" } */ +double foo (double a) +{ + return a - a; +} + +/* { dg-final { scan-tree-dump " = a_\[0-9\]\\(D\\) - a_\[0-9\]\\(D\\);" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr98721-1.c b/SingleSource/Regression/C/gcc-dg/pr98721-1.c new file mode 100644 index 0000000000..1c7574fb88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98721-1.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/98721 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target alloca } */ + +int +foo (int n) +{ + if (n <= 0) + { + char vla[n]; /* { dg-message "source object 'vla' of size 0" } */ + return __builtin_strlen (vla); /* { dg-warning "'__builtin_strlen' reading 1 or more bytes from a region of size 0" } */ + } + return -1; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98721-2.c b/SingleSource/Regression/C/gcc-dg/pr98721-2.c new file mode 100644 index 0000000000..c8ca542352 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98721-2.c @@ -0,0 +1,8 @@ +/* PR tree-optimization/98721 */ +/* { dg-do compile } */ + +int +foo (void) +{ + return __builtin_strlen (__builtin_alloca_with_align (0, 16)); /* { dg-warning "'__builtin_strlen' reading 1 or more bytes from a region of size 0" } */ +} /* { dg-message "source object '' of size 0" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr98766.c b/SingleSource/Regression/C/gcc-dg/pr98766.c new file mode 100644 index 0000000000..d388fd2aa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98766.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/98766. */ + +/* { dg-do compile } */ +/* { dg-options "-O3 --param=avoid-fma-max-bits=8 " } */ +/* { dg-additional-options "-march=armv8.2-a+sve" { target aarch64*-*-* } } */ + +extern int a[]; +void c(short *d) { + for (int e = 0; e < 9; e++) + a[e] = d[e] * 2; +} + diff --git a/SingleSource/Regression/C/gcc-dg/pr98793.c b/SingleSource/Regression/C/gcc-dg/pr98793.c new file mode 100644 index 0000000000..bb1ae9cc7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98793.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-psabi" } */ + +typedef unsigned char u8; +typedef unsigned char __attribute__((__vector_size__ (8))) v64u8; +typedef unsigned char __attribute__((__vector_size__ (64))) v512u8; +typedef unsigned long long u64; + +u64 gx; +v512u8 gu; +v512u8 gv; + +v64u8 __attribute__((__noipa__)) foo0 (u8 ax, v512u8 au, u64 ay) +{ + u8 lx = ax && (u8) ay; + v512u8 lc = 7 <= au; + v512u8 ld = (u8) (ay && gx) == gu; + v512u8 le = (v512u8) ld + (v512u8) gv; + v512u8 lf = le + lc; + return (((union + { + v512u8 a; + v64u8 b[8]; + }) lf).b[3]) + lx; +} + +int +main (void) +{ + v64u8 x = foo0 (2, (v512u8) { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15 + }, + 2); + for (unsigned i = 0; i < sizeof (x); i++) + if (x[i] != (i ? 0 : 0xff)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98807.c b/SingleSource/Regression/C/gcc-dg/pr98807.c new file mode 100644 index 0000000000..d4eac5aeb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98807.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -Wno-psabi -w" } */ +/* { dg-additional-options "-mno-sse2" { target x86_64-*-* i?86-*-* } } */ + +#include + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +typedef u64 __attribute__((__vector_size__ (16))) v128u64; +u16 foo0_u16_0; +v128u64 foo0_v64u32_0; +u64 foo0_u64_0; +v128u64 foo0_v128u64_2; + +v128u64 +foo0 (u8 u8_0, v128u64 v128u64_0) +{ + u32 u32_1 = u8_0 || (0, 0); + foo0_v128u64_2 - u8_0; + foo0_u16_0 |= foo0_u64_0 && u8_0 > foo0_u64_0 <= u32_1; + v128u64 v128u64_4 = v128u64_0 >= u8_0; + return v128u64_4 + foo0_v64u32_0; +} + +int +main () +{ + v128u64 x = foo0 (3, (v128u64) { 0, 12 }); + if (x[0] != 0) __builtin_abort(); + if (x[1] != 0xffffffffffffffff) __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr98865.c b/SingleSource/Regression/C/gcc-dg/pr98865.c new file mode 100644 index 0000000000..95f7270339 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr98865.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int foo(int x, int y) +{ + return -(x&1) & y; +} + +int bar(int x, int y) +{ + return (x&1) * y; +} + +/* { dg-final { scan-tree-dump-times " \\* " 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pr99104.c b/SingleSource/Regression/C/gcc-dg/pr99104.c new file mode 100644 index 0000000000..807e1da409 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99104.c @@ -0,0 +1,15 @@ +/* PR target/99104 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fsel-sched-pipelining -fselective-scheduling2 -funroll-loops" } */ + +__int128 a; +int b; +int foo (void); + +int __attribute__ ((simd)) +bar (void) +{ + a = ~a; + if (foo ()) + b = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99122-1.c b/SingleSource/Regression/C/gcc-dg/pr99122-1.c new file mode 100644 index 0000000000..5dfc0a85ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99122-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -w" } */ + +void f () +{ + int n = 5; + struct { char a[n]; } x; + g (x, x); +} +int g (double x, double y) +{ + return __builtin_isgreater (x, y); +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99122-2.c b/SingleSource/Regression/C/gcc-dg/pr99122-2.c new file mode 100644 index 0000000000..c0c850f141 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99122-2.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -w" } */ +/* { dg-require-effective-target alloca } */ + +static int foo (); + +int +bar (int n) +{ + struct S { char a[n]; } x; + __builtin_memset (x.a, 0, n); + return foo (n, x); +} + +static inline int +foo (int n, struct T { char a[n]; } b) +{ + int r = 0, i; + for (i = 0; i < n; i++) + r += b.a[i]; + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99122-3.c b/SingleSource/Regression/C/gcc-dg/pr99122-3.c new file mode 100644 index 0000000000..6a908ad86c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99122-3.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -w" } */ + +static int foo (); + +int +bar (int n) +{ + return foo (n, 2.0); +} + +static inline int +foo (int n, struct T { char a[n]; } b) +{ + int r = 0, i; + for (i = 0; i < n; i++) + r += b.a[i]; + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99136.c b/SingleSource/Regression/C/gcc-dg/pr99136.c new file mode 100644 index 0000000000..1bd8446811 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99136.c @@ -0,0 +1,9 @@ +/* PR c/99136 */ +/* { dg-do compile } */ +/* { dg-options "-w -fexcess-precision=standard" } */ + +void +foo (double x) +{ + return 1.0 / x; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99224.c b/SingleSource/Regression/C/gcc-dg/pr99224.c new file mode 100644 index 0000000000..f6e9ac8eba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99224.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ + +void f (char *c, ...) +{ + __builtin_next_arg (*c); /* { dg-warning "not last named argument" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99230.c b/SingleSource/Regression/C/gcc-dg/pr99230.c new file mode 100644 index 0000000000..eb3f982c2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99230.c @@ -0,0 +1,40 @@ +/* PR debug/99230 */ +/* { dg-do compile } */ +/* { dg-options "-O2 --param logical-op-non-short-circuit=0 -fcompare-debug --param=jump-table-max-growth-ratio-for-speed=5000" } */ + +extern void fn2 (void); +extern void fn3 (int); +int a, b; +void +fn1 (void) +{ + int c; + short d; + switch (a) { + case 22000: + fn2 (); + case 22300: + b = 0; + case 22600: + case 22601: + case 22900: + fn3 (1); + case 20100: + fn3 (2); + case 20200: + fn3 (3); + case 20300: + fn3 (4); + case 20400: + fn3 (5); + case 20310: + fn3 (4); + case 20410: + fn3 (5); + } + if (d || c) { + do + ; + while (0); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99296.c b/SingleSource/Regression/C/gcc-dg/pr99296.c new file mode 100644 index 0000000000..4a0b3f0c36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99296.c @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options "-O2 -fno-tree-bit-ccp" } + +struct { + signed a : 1; +} b, c; +void d() { b.a |= c.a |= 0 != 2; } diff --git a/SingleSource/Regression/C/gcc-dg/pr99323-1.c b/SingleSource/Regression/C/gcc-dg/pr99323-1.c new file mode 100644 index 0000000000..6fe14002e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99323-1.c @@ -0,0 +1,17 @@ +/* Verify that fix-it printing doesn't ICE when there are multiple + fix-it hints on a very long line after LINE_MAP_MAX_COLUMN_NUMBER. */ + +/* { dg-options "-Wall -no-integrated-cpp -fdiagnostics-show-caret" } */ +/* { dg-allow-blank-lines-in-output 1 } */ +/* { dg-prune-output ".*" } */ + +typedef struct { +} REFERENCE; +#define LIM2() LIM1() +#define LIM3() LIM2() LIM2() LIM2() LIM2() LIM2() LIM2() +#define LIM4() \ + LIM3() LIM3() LIM3() LIM3() LIM3() LIM3() LIM3() LIM3() LIM3() LIM3() +#define LIM5() \ + LIM4() LIM4() LIM4() LIM4() LIM4() LIM4() LIM4() LIM4() LIM4() LIM4() +#define LIM1() DEF(), +REFERENCE references[] = {LIM5()}; diff --git a/SingleSource/Regression/C/gcc-dg/pr99323-2.c b/SingleSource/Regression/C/gcc-dg/pr99323-2.c new file mode 100644 index 0000000000..d4075b6152 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99323-2.c @@ -0,0 +1,11 @@ +/* Verify that fix-it printing doesn't ICE when there are multiple + fix-it hints on a very long line after LINE_MAP_MAX_COLUMN_NUMBER. */ + +/* { dg-options "-Wall -fdiagnostics-show-caret" } */ +/* { dg-allow-blank-lines-in-output 1 } */ +/* { dg-prune-output ".*" } */ + +typedef struct { +} REFERENCE; + +REFERENCE references[] = {DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(), DEF(),} diff --git a/SingleSource/Regression/C/gcc-dg/pr99578-1.c b/SingleSource/Regression/C/gcc-dg/pr99578-1.c new file mode 100644 index 0000000000..c31d95dbcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99578-1.c @@ -0,0 +1,26 @@ +/* PR middle-end/99578 */ +/* { dg-do compile { target int32 } } */ +/* { dg-options "-O2 -Warray-bounds" } */ + +struct S { int a, b[4]; }; +struct T { int a, b[8192], c[4]; }; + +void +foo (struct S *p) +{ + if (p) return; + __builtin_memset (p->b, 0, sizeof p->b); /* { dg-warning "offset \\\[0, 15\\\] is out of the bounds \\\[0, 0\\\]" } */ +} + +void +bar (struct T *p) +{ + if (p) return; + __builtin_memset (p->c, 0, sizeof p->c); /* { dg-warning "offset \\\[0, 15\\\] is out of the bounds \\\[0, 0\\\]" "" { xfail *-*-* } } */ +} + +void +baz (void) +{ + __builtin_memset ((void *) 0x8004, 0, 16); /* { dg-bogus "is out of the bounds" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99578-2.c b/SingleSource/Regression/C/gcc-dg/pr99578-2.c new file mode 100644 index 0000000000..462b606cae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99578-2.c @@ -0,0 +1,26 @@ +/* PR middle-end/99578 */ +/* { dg-do compile { target int32 } } */ +/* { dg-options "-O2 -Wstringop-overflow" } */ + +struct S { int a, b[4]; }; +struct T { int a, b[8192], c[4]; }; + +void +foo (struct S *p) +{ + if (p) return; + __builtin_memset (p->b, 0, sizeof p->b); /* { dg-warning "writing 16 bytes into a region of size 0 overflows the destination" } */ +} + +void +bar (struct T *p) +{ + if (p) return; + __builtin_memset (p->c, 0, sizeof p->c); /* { dg-warning "writing 16 bytes into a region of size 0 overflows the destination" "" { xfail *-*-* } } */ +} + +void +baz (void) +{ + __builtin_memset ((void *) 0x8004, 0, 16); /* { dg-bogus "overflows the destination" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99578-3.c b/SingleSource/Regression/C/gcc-dg/pr99578-3.c new file mode 100644 index 0000000000..ef563243db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99578-3.c @@ -0,0 +1,13 @@ +/* PR middle-end/99578 */ +/* { dg-do compile { target size32plus } } */ +/* { dg-options "-O2 -Wstringop-overread" } */ + +struct S { unsigned int s; }; +extern struct S v; +extern void *memcpy (void *, const void *, __SIZE_TYPE__); + +void +foo (void) +{ + memcpy (&v, (void *)(0xe8ffc000), sizeof (struct S)); /* { dg-bogus "from a region of size 0" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99708.c b/SingleSource/Regression/C/gcc-dg/pr99708.c new file mode 100644 index 0000000000..b1eaf13308 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99708.c @@ -0,0 +1,7 @@ +/* PR target/99708 */ +/* { dg-do compile } */ + +#ifdef __SIZEOF_FLOAT128__ +__float128 f = 1.0; +#endif +long double l = 1.0; diff --git a/SingleSource/Regression/C/gcc-dg/pr99830.c b/SingleSource/Regression/C/gcc-dg/pr99830.c new file mode 100644 index 0000000000..75226f5c3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99830.c @@ -0,0 +1,10 @@ +/* PR debug/99830 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -fno-expensive-optimizations -fno-split-wide-types -g" } */ + +int foo (long a, __int128 b, short c, int d, unsigned e, __int128 f) +{ + __builtin_memmove (2 + (char *) &f, foo, 1); + c >>= (char) f; + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99882.c b/SingleSource/Regression/C/gcc-dg/pr99882.c new file mode 100644 index 0000000000..ebc074fd5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99882.c @@ -0,0 +1,37 @@ +/* PR tree-optimization/99882 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void +foo (char *p, void *q) +{ + __INTPTR_TYPE__ i = (__INTPTR_TYPE__) q; + p[2] = i; + i >>= 8; + p[3] = i; + i >>= 8; + p[4] = i; + i >>= 8; + p[5] = i; + i >>= 8; + p[6] = i; + i >>= 8; + p[7] = i; + i >>= 8; + p[8] = i; + i >>= 8; + p[9] = i; +} + +void +bar (char *p, void *q) +{ + __INTPTR_TYPE__ i = (__INTPTR_TYPE__) q; + p[2] = i; + i >>= 8; + p[3] = i; + i >>= 8; + p[4] = i; + i >>= 8; + p[5] = i; +} diff --git a/SingleSource/Regression/C/gcc-dg/pr99990.c b/SingleSource/Regression/C/gcc-dg/pr99990.c new file mode 100644 index 0000000000..6878b00ce0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pr99990.c @@ -0,0 +1,12 @@ +/* PR c/99990 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include + +void +foo () +{ + va_arg (0, long); /* { dg-error "first argument to 'va_arg' not of type 'va_list'" } */ + void *b[] = 0; /* { dg-error "invalid initializer" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-align-2.c b/SingleSource/Regression/C/gcc-dg/pragma-align-2.c new file mode 100644 index 0000000000..5cdaff9586 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-align-2.c @@ -0,0 +1,67 @@ +/* { dg-do run { target *-*-solaris2.* } } */ +/* { dg-options "-std=gnu99" } */ + +void abort (void); + +#pragma align 1(x1) +#pragma align 2(x2) +#pragma align 4(x4) +#pragma align 8(x8,y8,z8) +#pragma align 16(x16) +#pragma align 32(x32) +#pragma align 64(x64) +#pragma align 128(x128) + +#define MACRO 128 +#define MACRO2(A) A + +#pragma align MACRO(y128) +#pragma align MACRO2(MACRO) (z128) + +#pragma align 8(not_defined) + +#pragma align 9(odd_align) /* { dg-warning "invalid alignment" } */ +#pragma align 256(high_align) /* { dg-warning "invalid alignment" } */ +#pragma align -1(neg_align) /* { dg-warning "malformed" } */ +#pragma align bad_align /* { dg-warning "malformed" } */ +#pragma align 1(bad_align /* { dg-warning "malformed" } */ + +int x, x1, x2, x4, x8, y8, z8, x16, x32, x64, x128, y128, z128; + +#pragma align 16(x) /* { dg-warning "must appear before" } */ + +int +main () +{ + if (__alignof__ (x4) < 4) + abort (); + + if (__alignof__ (x8) < 8) + abort (); + + if (__alignof__ (y8) < 8) + abort (); + + if (__alignof__ (z8) < 8) + abort (); + + if (__alignof__ (x16) < 16) + abort (); + + if (__alignof__ (x32) < 32) + abort (); + + if (__alignof__ (x64) < 64) + abort (); + + if (__alignof__ (x128) < 128) + abort (); + + if (__alignof__ (y128) < 128) + abort (); + + if (__alignof__ (z128) < 128) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-align.c b/SingleSource/Regression/C/gcc-dg/pragma-align.c new file mode 100644 index 0000000000..4c0138b5f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-align.c @@ -0,0 +1,47 @@ +/* Prove that pragma alignment handling works somewhat. */ + +/* { dg-do run { target { ! default_packed } } } */ + +extern void abort (void); + +struct { + char one; + long two; +} defaultalign; + +#if defined(__LP64__) +#pragma pack(8) +#else +#pragma pack(4) +#endif +struct { + char one; + long two; +} sixteen; + +#pragma pack(1) +struct { + char one; + long two; +} two; + +#pragma pack(2) +struct { + char one; + long two; +} three; + +#pragma pack() +struct { + char one; + long two; +} resetalign; + +main() +{ + if(sizeof(sixteen) < sizeof(defaultalign)) abort(); + if(sizeof(two) >= sizeof(defaultalign)) abort(); + if(sizeof(three) <= sizeof(two)) abort(); + if(sizeof(resetalign) != sizeof(defaultalign)) abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-darwin-2.c b/SingleSource/Regression/C/gcc-dg/pragma-darwin-2.c new file mode 100644 index 0000000000..4bbecef012 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-darwin-2.c @@ -0,0 +1,24 @@ +/* Darwin (Mac OS X) pragma exercises. */ + +/* { dg-do compile { target *-*-darwin* } } */ + +/* The mark pragma is valid at any point in the program. Fortunately + the compiler only needs to ignore it. It's also followed only + by pp-tokens, not necessarily real C tokens. */ + +void foo(void) +{ + if (1) { + ; + } + else if (1) { + ; + } +#pragma mark "last case" "hi" + else if (1) { + ; + } +} + +#pragma mark 802.11x 1_2_3 +#pragma mark •••• marker •••• diff --git a/SingleSource/Regression/C/gcc-dg/pragma-darwin.c b/SingleSource/Regression/C/gcc-dg/pragma-darwin.c new file mode 100644 index 0000000000..c8dd9d4bf1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-darwin.c @@ -0,0 +1,70 @@ +/* Darwin (Mac OS X) pragma exercises. */ + +/* { dg-do run { target *-*-darwin* } } */ +/* { dg-options "-O -Wunused" } */ + +/* The mark pragma is to help decorate IDEs. */ + +extern void abort(void); + +#pragma mark hey hey ho + +/* The options pragma used to do a lot, now it's only for emulating + m68k alignment rules in structs. */ + +#pragma options 23 /* { dg-warning "malformed '#pragma options'" } */ +#pragma options align /* { dg-warning "malformed '#pragma options'" } */ +#pragma options align natural /* { dg-warning "malformed '#pragma options'" } */ +#pragma options align=45 /* { dg-warning "malformed '#pragma options'" } */ +#pragma options align=foo /* { dg-warning "malformed '#pragma options align" } */ + +#ifndef __LP64__ +#pragma options align=mac68k +struct s1 { short f1; int f2; }; +#endif +#pragma options align=power +struct s2 { short f1; int f2; }; +#ifndef __LP64__ +#pragma options align=mac68k +struct s3 { short f1; int f2; }; +#endif +#pragma options align=reset +struct s4 { short f1; int f2; }; + +#pragma options align=natural foo /* { dg-warning "junk at end of '#pragma options'" } */ +/* { dg-warning "malformed '#pragma options align={mac68k|power|reset}', ignoring" "ignoring" { target *-*-* } .-1 } */ + +/* Segment pragmas don't do anything anymore. */ + +#pragma segment foo + +int +main () +{ + int x, z; /* { dg-warning "unused variable 'z'" } */ + #pragma unused (x, y) + +#ifndef __LP64__ + if (sizeof (struct s1) != 6) + abort (); +#endif + if (sizeof (struct s2) != 8) + abort (); +#ifndef __LP64__ + if (sizeof (struct s3) != 6) + abort (); +#endif + if (sizeof (struct s4) != 8) + abort (); + return 0; +} + +void +unused_err_test () +{ + int a, b; + /* Trying to match on '(' or ')' gives regexp headaches, use . instead. */ +#pragma unused /* { dg-warning "missing '.' after '#pragma unused" } */ +#pragma unused (a /* { dg-warning "missing '.' after '#pragma unused" } */ +#pragma unused (b) foo /* { dg-warning "junk at end of '#pragma unused'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-1.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-1.c new file mode 100644 index 0000000000..d0bb0d6f66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +void foo (int); + +int +main() +{ + int a; + int b; + int c; + int d; + +#pragma GCC diagnostic error "-Wuninitialized" + foo(a); /* { dg-error "uninitialized" } */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" + foo(b); +#pragma GCC diagnostic pop + foo(c); /* { dg-error "uninitialized" } */ +#pragma GCC diagnostic pop + foo(d); /* { dg-warning "uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-10.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-10.c new file mode 100644 index 0000000000..a1637bea26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-10.c @@ -0,0 +1,21 @@ +/* PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective + in conjunction with alias attribute + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-alias "" } */ + +void * +__rawmemchr_ppc (const void *s, int c) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Wstringop-overread" + if (c != 0) + return __builtin_memchr (s, c, (unsigned long)-1); // { dg-bogus "specified bound \\d+ exceeds maximum object size" } +#pragma GCC diagnostic pop + + return (char *)s + __builtin_strlen (s); +} + +extern __typeof (__rawmemchr_ppc) __EI___rawmemchr_ppc + __attribute__((alias ("__rawmemchr_ppc"))); diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-2.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-2.c new file mode 100644 index 0000000000..588d618955 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -pedantic -Wno-long-long" } */ +/* { dg-message "warnings being treated as errors" "" { target *-*-* } 0 } */ + +int i = 0LL; + +#pragma GCC diagnostic error "-Wlong-long" + +int j = 1LL; /* { dg-error "long long" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-3.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-3.c new file mode 100644 index 0000000000..b6ee60f167 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-3.c @@ -0,0 +1,64 @@ +/* { dg-do compile } */ +/* { dg-options "-Wswitch-enum -Wsign-compare -fstrict-overflow -Wstrict-overflow -Werror -Wno-error=switch-enum" } */ +/* PR c/66098 - #pragma diagnostic 'ignored' not fully undone by pop for strict-overflow + PR c/66711 - GCC does not correctly restore diagnostic state after pragma GCC diagnostic pop with -Werror +*/ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +void testing2() { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-overflow" + int j = 4; + j + 4 < j; +#pragma GCC diagnostic pop +} + +void testing3() { + int k = 4; + k + 4 < k; /* { dg-error "overflow" "" { xfail *-*-* } } */ +} + +int bar() +{ + unsigned x = 0; + int y = 1; + + /* generates an error - ok */ + x += x < y ? 1 : 0; /* { dg-error "comparison" } */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-compare" + /* generates no diagnostic - ok */ + x += x < y ? 1 : 0; +#pragma GCC diagnostic pop + + x += x < y ? 1 : 0; /* { dg-error "comparison" } */ + + return x; +} + +enum EE { ONE, TWO }; + +int f (enum EE e) +{ + int r = 0; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-enum" + + switch (e) + { + case ONE: + r = 1; + break; + } +#pragma GCC diagnostic pop + + switch (e) /* { dg-warning "switch" } */ + { + case ONE: + r = 1; + break; + } + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-4.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-4.c new file mode 100644 index 0000000000..fc8d4b1feb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-4.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare -Werror=sign-compare -Werror=switch-enum" } */ +/* { dg-message "warnings being treated as errors" "" {target "*-*-*"} 0 } */ + +int bar() +{ + unsigned x = 0; + int y = 1; + + /* generates an error - ok */ + x += x < y ? 1 : 0; /* { dg-error "comparison" } */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-compare" + /* generates no diagnostic - ok */ + x += x < y ? 1 : 0; +#pragma GCC diagnostic pop + + x += x < y ? 1 : 0; /* { dg-error "comparison" } */ + + return x; +} + +enum EE { ONE, TWO }; + +int f (enum EE e) +{ + int r = 0; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-enum" + + switch (e) + { + case ONE: + r = 1; + break; + } +#pragma GCC diagnostic pop + + switch (e) /* { dg-error "switch" } */ + { + case ONE: + r = 1; + break; + } + return r; +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-5.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-5.c new file mode 100644 index 0000000000..1fbe127975 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-5.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +#pragma GCC diagnostic /* { dg-warning "missing" "missing" } */ +/* { dg-warning "24:missing" "wrong column" { xfail *-*-* } .-1 } */ + +#pragma GCC diagnostic warn /* { dg-warning "24:expected" } */ + +#pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-6.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-6.c new file mode 100644 index 0000000000..f2df88d245 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-6.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +#pragma GCC diagnostic error "-Wnoexcept" /* { dg-warning "is valid for C../ObjC.. but not for C" } */ +#pragma GCC diagnostic error "-fstrict-aliasing" /* { dg-warning "not an option that controls warnings" } */ +#pragma GCC diagnostic error "-Werror" /* { dg-warning "not an option that controls warnings" } */ +#pragma GCC diagnostic error "-Wvla2" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind" } */ +/* { dg-message "did you mean '-Wvla'" "" { target *-*-* } .-1 } */ +#pragma GCC diagnostic error "-Walla" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind" } */ +/* { dg-message "did you mean '-Wall'" "" { target *-*-* } .-1 } */ +#pragma GCC diagnostic warning "-Walla" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind" } */ +/* { dg-message "did you mean '-Wall'" "" { target *-*-* } .-1 } */ +int i; diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-7.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-7.c new file mode 100644 index 0000000000..3862e9ba1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-7.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +unsigned long ok = 0UL; +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wtraditional" +unsigned long bad = 1UL; /* { dg-warning "suffix" } */ +/* Note the extra space before the pragma on this next line: */ + #pragma GCC diagnostic pop +unsigned long ok_again = 2UL; /* { dg-bogus "suffix" } */ + +/* Redundant with the previous pop, but just shows that it fails to stop the + * following warning with an unpatched GCC: */ +#pragma GCC diagnostic ignored "-Wtraditional" + +/* { dg-bogus "would be stringified" "" { target *-*-* } .+1 } */ +#define UNW_DEC_PROLOGUE(fmt, body, rlen, arg) \ + do { \ + unw_rlen = rlen; \ + *(int *)arg = body; \ + printf(" %s:%s(rlen=%lu)\n", \ + fmt, (body ? "body" : "prologue"), (unsigned long)rlen); \ + } while (0) diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-8.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-8.c new file mode 100644 index 0000000000..00780606e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-8.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + + +char one[50]; +char two[50]; + +void +test_strncat (void) +{ + (void) __builtin_strcpy (one, "gh"); + (void) __builtin_strcpy (two, "ef"); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow=" +#pragma GCC diagnostic ignored "-Warray-bounds" + (void) __builtin_strncat (one, two, 99); +#pragma GCC diagnostic pop +} + diff --git a/SingleSource/Regression/C/gcc-dg/pragma-diag-9.c b/SingleSource/Regression/C/gcc-dg/pragma-diag-9.c new file mode 100644 index 0000000000..9aac379caf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-diag-9.c @@ -0,0 +1,141 @@ +/* Verify that #pragma GCC diagnostic down the inlining stack suppresses + a warning that would otherwise be issued for inlined calls higher up + the inlining stack. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds" } */ + +extern void* memset (void*, int, __SIZE_TYPE__); + +static void warn0 (int *p) +{ + memset (p, __LINE__, 3); // { dg-warning "\\\[-Wstringop-overflow" } +} + +static void warn1 (int *p) +{ + warn0 (p + 1); +} + +static void warn2 (int *p) +{ + warn1 (p + 1); +} + +int a2[2]; // { dg-message "at offset 12 into destination object 'a2' of size 8" } + +void warn3 (void) +{ + warn2 (a2 + 1); +} + + +// Verify suppression at the innermost frame of the inlining stack. + +static void ignore0 (int *p) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + memset (p, __LINE__, 3); +#pragma GCC diagnostic pop +} + +static void nowarn1_ignore0 (int *p) +{ + ignore0 (p + 1); +} + +static void nowarn2_ignore0 (int *p) +{ + nowarn1_ignore0 (p + 1); +} + +int b2[2]; + +void nowarn3_ignore0 (void) +{ + nowarn2_ignore0 (b2 + 1); +} + + +// Verify suppression at the second innermost frame of the inlining stack. + +static void nowarn0_ignore1 (int *p) +{ + memset (p, __LINE__, 3); +} + +static void ignore1 (int *p) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + nowarn0_ignore1 (p + 1); +#pragma GCC diagnostic pop +} + +void nowarn2_ignore1 (int *p) +{ + ignore1 (p + 1); +} + +int c2[2]; + +void nowarn3_ignore1 (void) +{ + nowarn2_ignore1 (c2 + 1); +} + + +// Verify suppression at the third innermost frame of the inlining stack. + +static void nowarn0_ignore2 (int *p) +{ + memset (p, __LINE__, 3); +} + +static void nowarn1_ignore2 (int *p) +{ + nowarn0_ignore2 (p + 1); +} + +static void ignore2 (int *p) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + nowarn1_ignore2 (p + 1); +#pragma GCC diagnostic pop +} + +int d2[2]; + +void nowarn3_ignore2 (void) +{ + ignore2 (c2 + 1); +} + + +// Verify suppression at the outermost frame of the inlining stack. + +static void nowarn0_ignore3 (int *p) +{ + memset (p, __LINE__, 3); +} + +static void nowarn1_ignore3 (int *p) +{ + nowarn0_ignore3 (p + 1); +} + +static void nowarn2_ignore3 (int *p) +{ + nowarn1_ignore3 (p + 1); +} + +int e2[2]; + +void ignore3 (void) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + nowarn2_ignore3 (e2 + 1); +#pragma GCC diagnostic pop +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-init-fini-2.c b/SingleSource/Regression/C/gcc-dg/pragma-init-fini-2.c new file mode 100644 index 0000000000..91bc622a20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-init-fini-2.c @@ -0,0 +1,15 @@ +/* Tests for #pragma init and #pragma fini. */ + +/* { dg-do link { target *-*-solaris2.* } } */ +/* { dg-options "-fpic" } */ + +#include + +#pragma fini (f) + +void f() { + fprintf (stderr, "f\n"); +} + +int main () { +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-init-fini.c b/SingleSource/Regression/C/gcc-dg/pragma-init-fini.c new file mode 100644 index 0000000000..4013b8dd09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-init-fini.c @@ -0,0 +1,50 @@ +/* Tests for #pragma init and #pragma fini. */ + +/* { dg-do run { target *-*-solaris2.* } } */ + +extern void abort (); + +#pragma init /* { dg-warning "malformed" } */ +#pragma init () /* { dg-warning "malformed" } */ +#pragma init init_func /* { dg-warning "malformed" } */ + +#pragma fini /* { dg-warning "malformed" } */ +#pragma fini () /* { dg-warning "malformed" } */ +#pragma fini fini_func /* { dg-warning "malformed" } */ + +#pragma init (init_func, init_static_func) + +int glob_1, glob_2; + +void init_func (void) +{ + glob_1 = 1; +} + +static void init_static_func (void) +{ + glob_2 = 2; +} + +#pragma fini (fini_func, fini_static_func) + +void fini_func (void) +{ + +} + +static void fini_static_func (void) +{ + +} + +int main() +{ + if (glob_1 != 1) + abort (); + + if (glob_2 != 2) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-message.c b/SingleSource/Regression/C/gcc-dg/pragma-message.c new file mode 100644 index 0000000000..1b7cf09de0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-message.c @@ -0,0 +1,55 @@ +/* Test that #pragma message "..." writes compiler messages. */ + +#pragma message /* { dg-warning "expected a string" } */ +#pragma message 0 /* { dg-warning "expected a string" } */ +#pragma message id /* { dg-warning "expected a string" } */ +#pragma message ( /* { dg-warning "expected a string" } */ +#pragma message (0 /* { dg-warning "expected a string" } */ +#pragma message (id /* { dg-warning "expected a string" } */ +#pragma message () /* { dg-warning "expected a string" } */ +#pragma message (0) /* { dg-warning "expected a string" } */ +#pragma message (id) /* { dg-warning "expected a string" } */ + +/* gcc prefixes '#pragma message ...' output with filename and line number, + then 'note: #pragma message: ', allowing dg-message to check output. + If unexpected pragma messages are printed (anything not caught by a + matching dg-message), dejagnu will report these as excess errors. */ + +#pragma message " +/* { dg-error "17:missing terminating" "" { target *-*-* } .-1 } */ +/* { dg-warning "expected a string" "" { target *-*-* } .-2 } */ +#pragma message "Bad 1 +/* { dg-error "17:missing terminating" "" { target *-*-* } .-1 } */ +/* { dg-warning "expected a string" "" { target *-*-* } .-2 } */ +#pragma message ("Bad 2 +/* { dg-error "18:missing terminating" "" { target *-*-* } .-1 } */ +/* { dg-warning "expected a string" "" { target *-*-* } .-2 } */ +#pragma message ("Bad 3" +/* { dg-warning "malformed '#pragma message" "" { target *-*-* } .-1 } */ + +#pragma message "" junk +/* { dg-warning "junk at end of '#pragma message'" "" { target *-*-* } .-1 } */ + +#pragma message ("") junk +/* { dg-warning "junk at end of '#pragma message'" "" { target *-*-* } .-1 } */ + +#pragma message "" /* No output expected for empty messages. */ +#pragma message ("") + +#pragma message "Okay 1" /* { dg-message "Okay 1" } */ +#pragma message ("Okay 2") /* { dg-message "Okay 2" } */ +#define THREE "3" +#pragma message ("Okay " THREE) /* { dg-message "Okay 3" } */ + +/* Create a TODO() that prints a message on compilation. */ +#define DO_PRAGMA(x) _Pragma (#x) /* { dg-line pragma_loc1 } */ +#define TODO(x) DO_PRAGMA(message ("TODO - " #x)) /* { dg-line pragma_loc2 } */ +TODO(Okay 4) /* { dg-message "in expansion of macro 'TODO'" } */ +/* { dg-message "TODO - Okay 4" "test4.1" { target *-*-* } pragma_loc1 } */ +/* { dg-message "in expansion of macro 'DO_PRAGMA'" "test4.2" { target *-*-* } pragma_loc2 } */ + +#if 0 +#pragma message ("Not printed") +#endif + +int unused; /* Silence `ISO C forbids an empty translation unit' warning. */ diff --git a/SingleSource/Regression/C/gcc-dg/pragma-ms_struct.c b/SingleSource/Regression/C/gcc-dg/pragma-ms_struct.c new file mode 100644 index 0000000000..cc71610146 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-ms_struct.c @@ -0,0 +1,21 @@ +/* Darwin pragma for __attribute__ ((ms_struct)). */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-Wall" } */ + +#pragma ms_struct on + +#pragma ms_struct off + +#pragma ms_struct reset + +#pragma ms_struct /* { dg-warning "malformed" } */ + +#pragma ms_struct on top of spaghetti /* { dg-warning "junk" } */ + +struct foo +{ + int a; + int b; + char c; +}; diff --git a/SingleSource/Regression/C/gcc-dg/pragma-pack-2.c b/SingleSource/Regression/C/gcc-dg/pragma-pack-2.c new file mode 100644 index 0000000000..f44f8dbba3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-pack-2.c @@ -0,0 +1,48 @@ +/* On Solaris, #pragma pack should accept macro expansion. */ + +/* { dg-do run { target *-*-solaris2.* } } */ + +extern void abort (void); + +struct { + char one; + long two; +} defaultalign; + +#define ALIGNHIGH 16 + +#pragma pack(ALIGNHIGH) +struct { + char one; + long two; +} sixteen; + +#define ALIGN1(X) 1 +#pragma pack(ALIGN1(4)) +struct { + char one; + long two; +} two; + +#define ALIGN2(X) X +#pragma pack(ALIGN2(2)) +struct { + char one; + long two; +} three; + +#define EMPTY +#pragma pack(EMPTY) +struct { + char one; + long two; +} resetalign; + +main() +{ + if(sizeof(sixteen) < sizeof(defaultalign)) abort(); + if(sizeof(two) >= sizeof(defaultalign)) abort(); + if(sizeof(three) <= sizeof(two)) abort(); + if(sizeof(resetalign) != sizeof(defaultalign)) abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-pack-3.c b/SingleSource/Regression/C/gcc-dg/pragma-pack-3.c new file mode 100644 index 0000000000..d384314913 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-pack-3.c @@ -0,0 +1,28 @@ +/* PR c++/25294 */ +/* { dg-options "-std=gnu99" } */ +/* Epiphany makes struct S 8-byte aligned. */ +/* { dg-do run { target { ! epiphany-*-* } } } */ + +extern void abort (void); + +struct S +{ + char a[3]; +#pragma pack(1) /* A block comment + that ends on the next line. */ + struct T + { + char b; + int c; + } d; +#pragma pack /*/ */ () // C++ comment + int e; +} s; + +int +main () +{ + if (sizeof (int) == 4 && sizeof (s) != 12) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-pack-4.c b/SingleSource/Regression/C/gcc-dg/pragma-pack-4.c new file mode 100644 index 0000000000..c2ea59e9da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-pack-4.c @@ -0,0 +1,7 @@ +/* PR c/28286 */ +/* { dg-do compile } */ + + +#pragma pack(0.5) /* { dg-warning "invalid constant" } */ +#pragma pack(push,0.5) /* { dg-warning "invalid constant" } */ +#pragma pack(push,x,0.5) /* { dg-warning "invalid constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pragma-pack-5.c b/SingleSource/Regression/C/gcc-dg/pragma-pack-5.c new file mode 100644 index 0000000000..897686f772 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-pack-5.c @@ -0,0 +1,10 @@ +/* Check that pragma pack overrides STRUCTURE_SIZE_BOUNDARY. */ +/* { dg-do compile } */ + +#pragma pack(1) +struct S +{ + char a; +}; + +int test[sizeof(struct S) == 1 ? 1: -1]; diff --git a/SingleSource/Regression/C/gcc-dg/pragma-pop_options-1.c b/SingleSource/Regression/C/gcc-dg/pragma-pop_options-1.c new file mode 100644 index 0000000000..4e969de6c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-pop_options-1.c @@ -0,0 +1,7 @@ +/* Check warnings produced by #pragma GCC push/pop/reset_options. */ +/* { dg-do assemble } */ + +#pragma push_options +#pragma pop_options + +int foo; diff --git a/SingleSource/Regression/C/gcc-dg/pragma-push_macro-1.c b/SingleSource/Regression/C/gcc-dg/pragma-push_macro-1.c new file mode 100644 index 0000000000..ac5d059b5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-push_macro-1.c @@ -0,0 +1,26 @@ +/* Prove that HANDLE_PRAGMA_PUSH_POP_MACRO handling works somewhat. */ + +/* { dg-do link { target *-*-mingw* } } */ + +#define TEXT1 "ABC" +#define TEXT2 "DEF" + +int main() +{ + if (__builtin_strcmp (TEXT1 TEXT2, "ABCDEF") != 0) + link_error (); + +#pragma push_macro("TEXT1") +#undef TEXT1 +#define TEXT1 "XYZ" + + if (__builtin_strcmp (TEXT1 TEXT2, "XYZDEF") != 0) + link_error (); + +#pragma pop_macro("TEXT1") + + if (__builtin_strcmp (TEXT1 TEXT2, "ABCDEF") != 0) + link_error (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-re-1.c b/SingleSource/Regression/C/gcc-dg/pragma-re-1.c new file mode 100644 index 0000000000..78312e5705 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-re-1.c @@ -0,0 +1,10 @@ +/* { dg-final { scan-assembler "bar" } } */ +/* { dg-final { scan-assembler-not "foo" } } */ + +#ifndef __PRAGMA_REDEFINE_EXTNAME +#error +#endif + +#pragma redefine_extname foo bar +extern int foo(void); +int (*p)(void) = foo; diff --git a/SingleSource/Regression/C/gcc-dg/pragma-re-2.c b/SingleSource/Regression/C/gcc-dg/pragma-re-2.c new file mode 100644 index 0000000000..ee7140133e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-re-2.c @@ -0,0 +1,7 @@ + +#pragma redefine_extname /* { dg-warning "malformed" } */ +#pragma redefine_extname foo /* { dg-warning "malformed" } */ +#pragma redefine_extname foo 1 /* { dg-warning "malformed" } */ +#pragma redefine_extname foo bar 2 /* { dg-warning "junk" } */ + +int bar; /* silence `ISO C forbids an empty translation unit' warning */ diff --git a/SingleSource/Regression/C/gcc-dg/pragma-re-3.c b/SingleSource/Regression/C/gcc-dg/pragma-re-3.c new file mode 100644 index 0000000000..3885fe8f04 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-re-3.c @@ -0,0 +1,17 @@ + +#pragma redefine_extname f1 f +#pragma redefine_extname g1 g + +void f() { + extern int f1(); + f1(); +} + +void g() { + g1(); +} + +int main () { + f(); + g(); +} diff --git a/SingleSource/Regression/C/gcc-dg/pragma-re-4.c b/SingleSource/Regression/C/gcc-dg/pragma-re-4.c new file mode 100644 index 0000000000..627e0b6e0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pragma-re-4.c @@ -0,0 +1,17 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. */ +/* Contributed by Carlos O'Donell on 2006-01-27 */ + +/* Origin: Carlos O'Donell */ +/* { dg-final { scan-assembler "_foo" } } */ +/* { dg-final { scan-assembler-not "_foo64" } } */ + +#define foo _foo +#define foo64 _foo64 +extern int foo(void); +extern int foo64(void); +#pragma redefine_extname foo64 foo +int +bar() +{ + return (foo64()); +} diff --git a/SingleSource/Regression/C/gcc-dg/precedence-1.c b/SingleSource/Regression/C/gcc-dg/precedence-1.c new file mode 100644 index 0000000000..089cdfc147 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/precedence-1.c @@ -0,0 +1,153 @@ +/* Test precedence and associativity in expressions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s { int *a; } *p, q, *r[2], *g(); +int *i[2]; +int j[2]; +_Complex double c[2]; + +void +f (void) +{ +#define ASSERT(expr) do { char x[(expr) ? 1 : -1]; } while (0) + /* Postfix and unary operators and casts. */ + *p++; + *p--; + *p->a; + *q.a; + *r[1]; + (*g()).a; + ++i[0]; + --i[0]; + +j[0]; + -j[0]; + ~j[0]; + !j[0]; + __real__ c[1]; + __imag__ c[1]; + ASSERT ((sizeof p++) == (sizeof p)); + ASSERT ((sizeof (int) + 1) == ((sizeof (int)) + 1)); + ASSERT ((__alignof p++) == (__alignof p)); + ASSERT ((__alignof (int) + 1) == ((__alignof (int)) + 1)); + ASSERT ((sizeof __extension__ 1 + 1) == ((sizeof 1) + 1)); + /* Binary operators. */ + ASSERT (((_Bool) 1 * 2) == 2); + ASSERT (((_Bool) 8 / 4) == 0); + ASSERT (((_Bool) 8 % 4) == 1); +#define ASSERT_BIN(C1, O1, C2, O2, C3, V1, V2, V3) \ + do { \ + ASSERT ((C1 O1 C2 O2 C3) == V1); \ + ASSERT (((C1 O1 C2) O2 C3) == V2); \ + ASSERT ((C1 O1 (C2 O2 C3)) == V3); \ + } while (0); + ASSERT_BIN (1, *, 2, *, 3, 6, 6, 6); + ASSERT_BIN (2, *, 2, /, 3, 1, 1, 0); + ASSERT_BIN (2, *, 2, %, 3, 1, 1, 4); + ASSERT_BIN (2, /, 2, *, 3, 3, 3, 0); + ASSERT_BIN (2, /, 2, /, 2, 0, 0, 2); + ASSERT_BIN (2, /, 4, %, 3, 0, 0, 2); + ASSERT_BIN (2, %, 2, *, 3, 0, 0, 2); + ASSERT_BIN (2, %, 9, /, 3, 0, 0, 2); + ASSERT_BIN (2, %, 4, %, 3, 2, 2, 0); + ASSERT_BIN (2, *, 3, +, 4, 10, 10, 14); + ASSERT_BIN (2, *, 3, -, 4, 2, 2, -2); + ASSERT_BIN (2, /, 3, +, 4, 4, 4, 0); + ASSERT_BIN (2, /, 3, -, 4, -4, -4, -2); + ASSERT_BIN (2, %, 3, +, 4, 6, 6, 2); + ASSERT_BIN (2, %, 3, -, 4, -2, -2, 0); + ASSERT_BIN (2, +, 3, *, 4, 14, 20, 14); + ASSERT_BIN (2, +, 3, /, 4, 2, 1, 2); + ASSERT_BIN (2, +, 3, %, 4, 5, 1, 5); + ASSERT_BIN (2, -, 3, *, 4, -10, -4, -10); + ASSERT_BIN (2, -, 3, /, 4, 2, 0, 2); + ASSERT_BIN (2, -, 4, %, 4, 2, -2, 2); + ASSERT_BIN (2, +, 3, +, 4, 9, 9, 9); + ASSERT_BIN (2, +, 3, -, 4, 1, 1, 1); + ASSERT_BIN (2, -, 3, +, 4, 3, 3, -5); + ASSERT_BIN (2, -, 3, -, 4, -5, -5, 3); + ASSERT_BIN (3, +, 2, <<, 4, 80, 80, 35); + ASSERT_BIN (3, +, 2, >>, 4, 0, 0, 3); + ASSERT_BIN (3, -, 2, <<, 4, 16, 16, -29); + ASSERT_BIN (3, -, 2, >>, 4, 0, 0, 3); + ASSERT_BIN (2, <<, 4, +, 3, 256, 35, 256); + ASSERT_BIN (2, <<, 4, -, 3, 4, 29, 4); + ASSERT_BIN (2, >>, 4, +, 3, 0, 3, 0); + ASSERT_BIN (2, >>, 4, -, 3, 1, -3, 1); + ASSERT_BIN (4L, <<, 2L, <<, 3L, 128L, 128L, 262144L); + ASSERT_BIN (4L, <<, 2L, >>, 3L, 2L, 2L, 4L); + ASSERT_BIN (4L, >>, 2L, <<, 3L, 8L, 8L, 0L); + ASSERT_BIN (4L, >>, 2L, >>, 3L, 0L, 0L, 4L); + ASSERT_BIN (2, <<, 5, <, 4, 0, 0, 2); + ASSERT_BIN (2, <<, 5, >, 4, 1, 1, 4); + ASSERT_BIN (2, <<, 5, <=, 4, 0, 0, 2); + ASSERT_BIN (2, <<, 5, >=, 4, 1, 1, 4); + ASSERT_BIN (2, >>, 5, <, 4, 1, 1, 2); + ASSERT_BIN (2, >>, 5, >, 4, 0, 0, 1); + ASSERT_BIN (2, >>, 5, <=, 4, 1, 1, 2); + ASSERT_BIN (2, >>, 5, >=, 4, 0, 0, 1); + ASSERT_BIN (4, <, 3, <<, 2, 1, 0, 1); + ASSERT_BIN (4, <, 20, >>, 2, 1, 0, 1); + ASSERT_BIN (4, >, 3, <<, 2, 0, 4, 0); + ASSERT_BIN (4, >, 3, >>, 2, 1, 0, 1); + ASSERT_BIN (4, <=, 3, <<, 2, 1, 0, 1); + ASSERT_BIN (4, <=, 20, >>, 2, 1, 0, 1); + ASSERT_BIN (4, >=, 3, <<, 2, 0, 4, 0); + ASSERT_BIN (4, >=, 3, >>, 2, 1, 0, 1); + ASSERT_BIN (1, <, 2, <, 3, 1, 1, 0); + ASSERT_BIN (1, <, 2, >, 0, 1, 1, 0); + ASSERT_BIN (1, <, 2, <=, 3, 1, 1, 0); + ASSERT_BIN (0, <, 4, >=, 3, 0, 0, 1); + ASSERT_BIN (1, >, 2, <, 3, 1, 1, 0); + ASSERT_BIN (1, >, 2, >, 3, 0, 0, 1); + ASSERT_BIN (1, >, 2, <=, 3, 1, 1, 0); + ASSERT_BIN (1, >, 2, >=, 3, 0, 0, 1); + ASSERT_BIN (3, <=, 2, <, 3, 1, 1, 0); + ASSERT_BIN (2, <=, 3, >, 0, 1, 1, 0); + ASSERT_BIN (2, <=, 3, <=, 4, 1, 1, 0); + ASSERT_BIN (2, <=, 3, >=, 1, 1, 1, 0); + ASSERT_BIN (0, >=, 2, <, 3, 1, 1, 0); + ASSERT_BIN (1, >=, 2, >, 3, 0, 0, 1); + ASSERT_BIN (0, >=, 2, <=, 3, 1, 1, 0); + ASSERT_BIN (1, >=, 2, >=, 3, 0, 0, 1); + ASSERT_BIN (-1, <, 2, ==, 3, 0, 0, 1); + ASSERT_BIN (1, <, 2, !=, 3, 1, 1, 0); + ASSERT_BIN (1, >, 2, ==, 3, 0, 0, 1); + ASSERT_BIN (1, >, 2, !=, 3, 1, 1, 0); + ASSERT_BIN (0, <=, 2, ==, 3, 0, 0, 1); + ASSERT_BIN (2, <=, 2, !=, 3, 1, 1, 0); + ASSERT_BIN (1, >=, 2, ==, 3, 0, 0, 1); + ASSERT_BIN (0, >=, 2, !=, 3, 1, 1, 0); + ASSERT_BIN (1, ==, 3, <, 2, 0, 1, 0); + ASSERT_BIN (1, ==, 3, >, 2, 1, 0, 1); + ASSERT_BIN (1, ==, 3, <=, 2, 0, 1, 0); + ASSERT_BIN (1, ==, 3, >=, 2, 1, 0, 1); + ASSERT_BIN (1, !=, 2, <, 3, 0, 1, 0); + ASSERT_BIN (1, !=, 2, >, 3, 1, 0, 1); + ASSERT_BIN (1, !=, 2, <=, 3, 0, 1, 0); + ASSERT_BIN (1, !=, 2, >=, 3, 1, 0, 1); + ASSERT_BIN (1, ==, 2, ==, 0, 1, 1, 0); + ASSERT_BIN (1, ==, 2, !=, 0, 0, 0, 1); + ASSERT_BIN (1, !=, 2, ==, 3, 0, 0, 1); + ASSERT_BIN (1, !=, 2, !=, 3, 1, 1, 0); + ASSERT_BIN (0, ==, 2, &, 1, 0, 0, 1); + ASSERT_BIN (0, !=, 2, &, 1, 1, 1, 0); + ASSERT_BIN (1, &, 2, ==, 0, 0, 1, 0); + ASSERT_BIN (1, &, 2, !=, 0, 1, 0, 1); + ASSERT_BIN (1, &, 0x2, ^, 3, 3, 3, 1); + ASSERT_BIN (3, ^, 2, &, 1, 3, 1, 3); + ASSERT_BIN (3, ^, 2, |, 1, 1, 1, 0); + ASSERT_BIN (3, |, 0x2, ^, 1, 3, 2, 3); + ASSERT_BIN (2, |, 0, &&, 2, 1, 1, 2); + ASSERT_BIN (2, &&, 0, |, 2, 1, 2, 1); + ASSERT_BIN (0, &&, 0, ||, 1, 1, 1, 0); + ASSERT_BIN (1, ||, 0, &&, 0, 1, 0, 1); + /* Conditional expressions. */ + ASSERT ((1 || 2 ? 3 : 4) == 3); + ASSERT ((1 || (2 ? 3 : 4)) == 1); + /* Assignment expressions. */ + p = p = p; + /* Expressions. */ + p, p = p; +} diff --git a/SingleSource/Regression/C/gcc-dg/predict-1.c b/SingleSource/Regression/C/gcc-dg/predict-1.c new file mode 100644 index 0000000000..d2e753e624 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate --disable-tree-evrp" } */ + +extern int global; + +int bar(int); + +void foo (int bound) +{ + int i, ret = 0; + for (i = 0; i < bound; i++) + { + if (i > bound) + global += bar (i); + if (i >= bound + 2) + global += bar (i); + if (i > bound - 2) + global += bar (i); + if (i + 2 > bound) + global += bar (i); + if (i == 10) + global += bar (i); + } +} + +/* { dg-final { scan-tree-dump-times "guess loop iv compare heuristics of edge\[^:\]*: 36.00%" 4 "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-10.c b/SingleSource/Regression/C/gcc-dg/predict-10.c new file mode 100644 index 0000000000..a99819a24c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-10.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ +int +ee(int i) +{ + if (i>2) + return (ee(i-1)+ee(i-2))/2; + else + return i; +} +/* { dg-final { scan-tree-dump-times "recursive call" 1 "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-11.c b/SingleSource/Regression/C/gcc-dg/predict-11.c new file mode 100644 index 0000000000..b2ac8cc6f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-11.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ +int *a,n,m; +void test(void); +void +t(void) +{ + int i,j; + for (i=0;i +#include + +void *r; +void *r2; +void *r3; +void *r4; +void *r5; + +void *m (size_t s, int c) +{ + r = malloc (s); + if (r) + memset (r, 0, s); + + r2 = calloc (s, 0); + if (r2) + memset (r2, 0, s); + + r3 = __builtin_malloc (s); + if (r3) + memset (r3, 0, s); + + r4 = __builtin_calloc (s, 0); + if (r4) + memset (r4, 0, s); + + r5 = __builtin_realloc (r4, s); + if (r5) + memset (r4, 0, s); +} + +/* { dg-final { scan-tree-dump-times "malloc returned non-NULL heuristics of edge\[^:\]*: 99.96%" 5 "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-17.c b/SingleSource/Regression/C/gcc-dg/predict-17.c new file mode 100644 index 0000000000..45b618a942 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-17.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate-details" } */ + +extern int global; + +void foo (int base) +{ + for (int i = 0; __builtin_expect_with_probability (i < base, 1, 0.05f); i++) + global++; +} + +/* { dg-final { scan-tree-dump "first match heuristics: 5.00%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 5.00%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "is probably executed at most 19" "profile_estimate"} } */ + diff --git a/SingleSource/Regression/C/gcc-dg/predict-18.c b/SingleSource/Regression/C/gcc-dg/predict-18.c new file mode 100644 index 0000000000..073e742d84 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-18.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +int x; + +short v = 0; +short expected = 0; +short max = ~0; +short m = 0; +short n = 0; +#define STRONG 0 + +void foo (int a, int b) +{ + if (__builtin_expect_with_probability (a < b, 1, 0.6f) > __builtin_expect (b, 0)) + global++; + + if (__builtin_expect_with_probability (a < b, 1, 0.777f) > 0) + global++; + + if (__builtin_expect_with_probability (a < b, 1, 0.99) == __atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED)) + global++; + + if (__builtin_expect_with_probability (a < 10, 1, 0.9f) > __builtin_expect_with_probability (b, 0, 0.8f)) + global++; + + if (a * __builtin_expect_with_probability (m, 0, 0.6f) > 0) + global++; + + if (__builtin_expect_with_probability (n, 0, 0.65f) * a > 0) + global++; +} + +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 54.00%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 77.70%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 98.96%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 71.99%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 40.00%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 35.01%" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-19.c b/SingleSource/Regression/C/gcc-dg/predict-19.c new file mode 100644 index 0000000000..38ca25a160 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-19.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +void foo (int base) +{ + if (__builtin_expect_with_probability (base == 100, 1, 0.001f)) + global++; +} + +/* { dg-final { scan-tree-dump "first match heuristics: 0.10%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 0.10%" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-2.c b/SingleSource/Regression/C/gcc-dg/predict-2.c new file mode 100644 index 0000000000..aa915688c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +int bar(int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i < bound; i++) + { + if (i > bound * bound) + global += bar (i); + if (i > bound + 10) + global += bar (i); + if (i <= bound + 10) + global += bar (i); + if (i > base + 10) + global += bar (i); + if (i < base - 10) + global += bar (i); + } +} + +/* { dg-final { scan-tree-dump-not "guess loop iv compare heuristics of edge\[^:\]*:" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-20.c b/SingleSource/Regression/C/gcc-dg/predict-20.c new file mode 100644 index 0000000000..7bb0d411f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-20.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/86925 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +int a, b; + +void +c () +{ + for (;;) + { + if (__builtin_expect (b < 0, 0)) + break; + if (__builtin_expect (a, 1)) + break; + } + int d = b < 0; + /* We fail to apply __builtin_expect heuristics here. Se PR109210. */ + if (__builtin_expect (d, 0)) + asm(""); +} + +/* { dg-final { scan-tree-dump-times "__builtin_expect heuristics of edge" 2 "profile_estimate" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-21.c b/SingleSource/Regression/C/gcc-dg/predict-21.c new file mode 100644 index 0000000000..5949e5f4c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-21.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate -frounding-math" } */ + +extern int global; + +void foo (int base) +{ + for (int i = 0; __builtin_expect_with_probability (i < base, 1, 0.05f); i++) + global++; +} + +/* { dg-final { scan-tree-dump "first match heuristics: 5.00%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "__builtin_expect_with_probability heuristics of edge .*->.*: 5.00%" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-22.c b/SingleSource/Regression/C/gcc-dg/predict-22.c new file mode 100644 index 0000000000..1aed03fae7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-22.c @@ -0,0 +1,59 @@ +/* { dg-do compile { target freorder } } */ +/* { dg-options "-O2 -fdump-tree-optimized-details-blocks -fdump-rtl-bbpart-details-blocks -freorder-blocks-and-partition" } */ +volatile int v; +void bar (void) __attribute__((leaf, cold)); +void baz (int *); + +void +foo (int x, int y, int z) +{ + static int f __attribute__((section ("mysection"))); + f = 1; + if (__builtin_expect (x, 0)) + if (__builtin_expect (y, 0)) + if (__builtin_expect (z, 0)) + { + f = 2; + bar (); + v += 1; + v *= 2; + v /= 2; + v -= 1; + v += 1; + v *= 2; + v /= 2; + v -= 1; + v += 1; + v *= 2; + v /= 2; + v -= 1; + v += 1; + v *= 2; + v /= 2; + v -= 1; + v += 1; + v *= 2; + v /= 2; + v -= 1; + v += 1; + v *= 2; + v /= 2; + v -= 1; + v += 1; + v *= 2; + v /= 2; + v -= 1; + v += 1; + v *= 2; + v /= 2; + v -= 1; + f = 3; + __builtin_abort (); + } + f = 4; + f = 5; + baz (&f); +} +/* { dg-final { scan-tree-dump-times "Invalid sum" 0 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "count 0 .precise" 1 "optimized"} } */ +/* { dg-final { scan-rtl-dump-times "COLD_PARTITION" 1 "bbpart"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-3.c b/SingleSource/Regression/C/gcc-dg/predict-3.c new file mode 100644 index 0000000000..f3f416345e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-3.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +int bar(int); + +void foo (int bound) +{ + int i, ret = 0; + for (i = 0; i <= bound; i++) + { + if (i < bound - 2) + global += bar (i); + /* The following test is redundant with the loop bound check in the + for stmt and thus eliminated by FRE which makes the controlled + stmt always executed and thus equivalent to 100%. Thus the + heuristic only applies three times. */ + if (i <= bound) + global += bar (i); + if (i + 1 < bound) + global += bar (i); + if (i != bound) + global += bar (i); + } +} + +/* { dg-final { scan-tree-dump-times "guess loop iv compare heuristics of edge\[^:\]*: 64.00%" 3 "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-4.c b/SingleSource/Regression/C/gcc-dg/predict-4.c new file mode 100644 index 0000000000..851afb1cff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +int bar(int); + +void foo (int bound) +{ + int i, ret = 0; + for (i = 0; i < 10; i++) + { + if (i < 5) + global += bar (i); + } +} + +/* { dg-final { scan-tree-dump " loop iv compare heuristics of edge\[^:\]*: 50.00%" "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-5.c b/SingleSource/Regression/C/gcc-dg/predict-5.c new file mode 100644 index 0000000000..5af5db1825 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-5.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +int bar (int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i <= bound; i++) + { + if (i > base) + global += bar (i); + if (i > base + 1) + global += bar (i); + if (i >= base + 3) + global += bar (i); + if (i - 2 >= base) + global += bar (i); + } +} + +/* { dg-final { scan-tree-dump-times "guess loop iv compare heuristics of edge\[^:\]*: 64.00%" 4 "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-6.c b/SingleSource/Regression/C/gcc-dg/predict-6.c new file mode 100644 index 0000000000..08ce5cdb81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-6.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +int bar (int); + +void foo (int base, int bound) +{ + int i, ret = 0; + for (i = base; i <= bound; i++) + { + if (i <= base) + global += bar (i); + if (i < base + 2) + global += bar (i); + if (i <= base + 3) + global += bar (i); + if (i - 1 < base) + global += bar (i); + } +} + +/* { dg-final { scan-tree-dump-times "guess loop iv compare heuristics of edge\[^:\]*: 36.00%" 4 "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-7.c b/SingleSource/Regression/C/gcc-dg/predict-7.c new file mode 100644 index 0000000000..fe34ca5f74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-7.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ + +extern int global; + +int bar (int); + +void foo (int base) +{ + int i; + while (global < 10) + for (i = base; i < 10; i++) + bar (i); +} + +/* { dg-final { scan-tree-dump-times "loop branch heuristics of edge\[^:\]*" 0 "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-8.c b/SingleSource/Regression/C/gcc-dg/predict-8.c new file mode 100644 index 0000000000..ec755e2575 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-8.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2 -fdump-rtl-expand-details-blocks" } */ + +int foo(float a, float b) { + if (a == b) + return 1; + else + return 2; +} + +/* { dg-final { scan-rtl-dump-times "99.\[678]. .guessed" 2 "expand"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/predict-9.c b/SingleSource/Regression/C/gcc-dg/predict-9.c new file mode 100644 index 0000000000..cb68a218a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/predict-9.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-profile_estimate -fno-finite-loops -fdisable-tree-ethread" } */ + +/* Note: Threader causes removal of for loop. */ + +extern int global; +extern int global2; +extern int global3; + +void foo (int base) +{ + int i; + while (global < 10) + { + if(global || global2 || global3) + return; + + for (i = base; i < 10; i++) + if (i > 123) + return; + } +} + +/* { dg-final { scan-tree-dump-times "first match heuristics: 2.20%" 3 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump-times "first match heuristics: 5.50%" 1 "profile_estimate"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/prefetch-loop-arrays-1.c b/SingleSource/Regression/C/gcc-dg/prefetch-loop-arrays-1.c new file mode 100644 index 0000000000..024cc1af56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/prefetch-loop-arrays-1.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/28887 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -march=i686 -msse -w" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +__extension__ typedef __SIZE_TYPE__ size_t; + +struct re_pattern_buffer +{ + size_t re_nsub; +}; + +typedef enum +{ + start_memory, +} re_opcode_t; + +typedef union +{ + struct + { + unsigned matched_something:1; + } bits; +} byte_register_info_type; + +void byte_re_match_2_internal (struct re_pattern_buffer *bufp) +{ + int mcnt; + size_t num_regs = bufp->re_nsub + 1; + byte_register_info_type *reg_info; + for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++) + { + ((reg_info[mcnt]).bits.matched_something) = 0; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/profile-dir-1.c b/SingleSource/Regression/C/gcc-dg/profile-dir-1.c new file mode 100644 index 0000000000..01269f9990 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-dir-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O -fprofile-generate=. -fdump-ipa-cgraph" } */ +/* { dg-final { scan-ipa-dump "Using data file \.\/.*#profile-dir-1.gcda" "cgraph" } } */ + +int +main(void) +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/profile-dir-2.c b/SingleSource/Regression/C/gcc-dg/profile-dir-2.c new file mode 100644 index 0000000000..13081ce253 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-dir-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O -fprofile-generate -fdump-ipa-cgraph" } */ +/* { dg-final { scan-ipa-dump "Using data file .*\/profile-dir-2.gcda" "cgraph" } } */ + +int +main(void) +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/profile-dir-3.c b/SingleSource/Regression/C/gcc-dg/profile-dir-3.c new file mode 100644 index 0000000000..21f975a93e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-dir-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O -fprofile-generate -fprofile-dir=. -fdump-ipa-cgraph" } */ +/* { dg-final { scan-ipa-dump "Using data file \.\/.*#profile-dir-3.gcda" "cgraph" } } */ + +int +main(void) +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/profile-filtering-1.c b/SingleSource/Regression/C/gcc-dg/profile-filtering-1.c new file mode 100644 index 0000000000..f123e24b2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-filtering-1.c @@ -0,0 +1,37 @@ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O2 -fprofile-generate -fprofile-filter-files=.\*filtering-1.c -fdump-tree-optimized" } */ + +extern void abort (void); + +int *p1; +int *p2; +int *p3; + +int ga = 100; + +int +sub (int i, int j) +{ + int k; + int l; + int m; + int n; + p1 = &k; + p2 = &l; + p3 = &m; + k = 20; + l = 30; + m = 40; + n = i / j; + return n + ga; +} + +int +main(void) +{ + if (sub (99, 33) != 103) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "PROF_edge" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/profile-filtering-2.c b/SingleSource/Regression/C/gcc-dg/profile-filtering-2.c new file mode 100644 index 0000000000..98bd3aea00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-filtering-2.c @@ -0,0 +1,37 @@ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O2 -fprofile-generate -fprofile-filter-files=.\*filtering-1.c -fprofile-exclude-files=.\* -fdump-tree-optimized" } */ + +extern void abort (void); + +int *p1; +int *p2; +int *p3; + +int ga = 100; + +int +sub (int i, int j) +{ + int k; + int l; + int m; + int n; + p1 = &k; + p2 = &l; + p3 = &m; + k = 20; + l = 30; + m = 40; + n = i / j; + return n + ga; +} + +int +main(void) +{ + if (sub (99, 33) != 103) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "PROF_edge" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/profile-generate-1.c b/SingleSource/Regression/C/gcc-dg/profile-generate-1.c new file mode 100644 index 0000000000..ed49df9213 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-generate-1.c @@ -0,0 +1,38 @@ +/* Bug 16325. */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O -fprofile-generate" } */ + +extern void abort (void); + +int *p1; +int *p2; +int *p3; + +int ga = 100; + +int +sub (int i, int j) +{ + int k; + int l; + int m; + int n; + p1 = &k; + p2 = &l; + p3 = &m; + k = 20; + l = 30; + m = 40; + n = i / j; + return n + ga; +} + +int +main(void) +{ + if (sub (99, 33) != 103) + abort (); + return 0; +} + +/* { dg-final { cleanup-coverage-files } } */ diff --git a/SingleSource/Regression/C/gcc-dg/profile-generate-2.c b/SingleSource/Regression/C/gcc-dg/profile-generate-2.c new file mode 100644 index 0000000000..eaea065f52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-generate-2.c @@ -0,0 +1,35 @@ +/* PR middle-end/23199 */ +/* Testcase by Ralf Menzel */ + +/* { dg-do compile } */ +/* { dg-options "-O -fprofile-generate" } */ + +union rtunion_def +{ + struct rtx_def *rt_rtx; +}; + +typedef union rtunion_def rtunion; + +struct rtx_def +{ + unsigned int in_struct : 1; + union u { + rtunion fld[1]; + } u; +}; + +typedef struct rtx_def *rtx; + +static void +check_annul_list_true_false (int annul_true_p, rtx delay_list) +{ + rtx temp; + while (1) + { + temp = delay_list; + rtx trial = (((temp)->u.fld[0]).rt_rtx); + if ((annul_true_p && (((trial))->in_struct))) + return; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/profile-generate-3.c b/SingleSource/Regression/C/gcc-dg/profile-generate-3.c new file mode 100644 index 0000000000..212ddee33a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-generate-3.c @@ -0,0 +1,10 @@ +/* { dg-do link } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-fprofile-generate=." } */ + +int +main () +{ + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/profile-generate-4.c b/SingleSource/Regression/C/gcc-dg/profile-generate-4.c new file mode 100644 index 0000000000..c2b999fe4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-generate-4.c @@ -0,0 +1,19 @@ +/* PR106912 */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-options "-O2 -fprofile-generate -ftree-vectorize" } */ + +__attribute__ ((__simd__)) +__attribute__ ((__nothrow__ , __leaf__ , __const__, __noinline__)) +double foo (double x); + +void bar(double *f, int n) +{ + int i; + for (i = 0; i < n; i++) + f[i] = foo(f[i]); +} + +double foo(double x) +{ + return x * x / 3.0; +} diff --git a/SingleSource/Regression/C/gcc-dg/profile-info-section.c b/SingleSource/Regression/C/gcc-dg/profile-info-section.c new file mode 100644 index 0000000000..8f31f3b2c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-info-section.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-skip-if "profile-info-section" { powerpc-ibm-aix* } } */ +/* { dg-options "-fprofile-arcs -fprofile-info-section -fdump-tree-optimized" } */ + +int foo() +{ + return 0; +} + +int bar() +{ + return 1; +} + +int main () +{ + return foo (); +} + +/* { dg-final { scan-tree-dump-not "__gcov_init" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "__gcov_exit" "optimized" } } */ +/* { dg-final { scan-assembler "\.gcov_info" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/profile-update-warning.c b/SingleSource/Regression/C/gcc-dg/profile-update-warning.c new file mode 100644 index 0000000000..63074e383f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/profile-update-warning.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-fprofile-update=atomic -fprofile-generate -march=i386" } */ + +int main(int argc, char *argv[]) +{ + return 0; +} /* { dg-warning "target does not support atomic profile update, single mode is selected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/proto-1.c b/SingleSource/Regression/C/gcc-dg/proto-1.c new file mode 100644 index 0000000000..62d0209b08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/proto-1.c @@ -0,0 +1,5 @@ +/* PR c/28502 */ +/* { dg-do compile } */ + +void foo() {} /* { dg-message "note: previous" } */ +void foo(void[]); /* { dg-error "array of voids" } */ diff --git a/SingleSource/Regression/C/gcc-dg/pthread-init-1.c b/SingleSource/Regression/C/gcc-dg/pthread-init-1.c new file mode 100644 index 0000000000..3346c926c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pthread-init-1.c @@ -0,0 +1,15 @@ +/* Ensure we get clean warning results when using the pthread + * initialization macros. + * + * Origin: Kaveh Ghazi (ghazi@caip.rutgers.edu) 9/27/2006. + */ + +/* { dg-do compile } */ +/* { dg-require-effective-target pthread_h } */ +/* { dg-options "-Wextra -Wall" } */ +/* The definition of PTHREAD_MUTEX_INITIALIZER is missing an initializer for + mutexAttr.mutexAttrType in kernel mode for various VxWorks versions. */ +/* { dg-xfail-if "missing initializer" { vxworks_kernel } } */ + +#include "pthread-init-common.h" + diff --git a/SingleSource/Regression/C/gcc-dg/pthread-init-2.c b/SingleSource/Regression/C/gcc-dg/pthread-init-2.c new file mode 100644 index 0000000000..d7cd66b5c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pthread-init-2.c @@ -0,0 +1,17 @@ +/* Various Solaris versions have been known to have problems with the + * pthread initialization macros when __STDC__ is defined. + * + * Origin: Kaveh Ghazi (ghazi@caip.rutgers.edu) 9/27/2006. + */ + +/* { dg-do compile } */ +/* { dg-require-effective-target pthread_h } */ +/* { dg-options "-Wextra -Wall -ansi" } */ +/* { dg-options "-Wextra -Wall -ansi -D_POSIX_C_SOURCE=199506L" { target { *-*-hpux* } } } */ +/* { dg-options "-Wextra -Wall -ansi -D_XOPEN_SOURCE=500" { target { powerpc-ibm-aix* } } } */ +/* The definition of PTHREAD_MUTEX_INITIALIZER is missing an initializer for + mutexAttr.mutexAttrType in kernel mode for various VxWorks versions. */ +/* { dg-xfail-if "missing initializer" { vxworks_kernel } } */ + +#include "pthread-init-common.h" + diff --git a/SingleSource/Regression/C/gcc-dg/pthread-init-common.h b/SingleSource/Regression/C/gcc-dg/pthread-init-common.h new file mode 100644 index 0000000000..723d997c99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pthread-init-common.h @@ -0,0 +1,39 @@ +/* + * Common code for the pthread-init-*.c tests. + * + * Origin: Kaveh Ghazi (ghazi@caip.rutgers.edu) 9/27/2006. + */ + +#define _GNU_SOURCE + +#include +#define UNUSED __attribute__ ((__unused__)) + +void foo(void) +{ +#ifdef PTHREAD_MUTEX_INITIALIZER + pthread_mutex_t pmutex UNUSED = PTHREAD_MUTEX_INITIALIZER; +#endif +#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + pthread_mutex_t pmutex_rc UNUSED = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +#endif +#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP + pthread_mutex_t pmutex_ec UNUSED = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; +#endif +#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP + pthread_mutex_t pmutex_ad UNUSED = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP; +#endif +#ifdef PTHREAD_COND_INITIALIZER + pthread_cond_t pcond UNUSED = PTHREAD_COND_INITIALIZER; +#endif +#ifdef PTHREAD_RWLOCK_INITIALIZER + pthread_rwlock_t prwlock UNUSED = PTHREAD_RWLOCK_INITIALIZER; +#endif +#ifdef PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP + pthread_rwlock_t prwlock_nrc UNUSED + = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP; +#endif +#ifdef PTHREAD_ONCE_INIT + pthread_once_t ponce UNUSED = PTHREAD_ONCE_INIT; +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/pubtypes-1.c b/SingleSource/Regression/C/gcc-dg/pubtypes-1.c new file mode 100644 index 0000000000..4d675b8e40 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pubtypes-1.c @@ -0,0 +1,47 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-O0 -gdwarf-2 -dA -fno-eliminate-unused-debug-types" } */ +/* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */ +/* { dg-final { scan-assembler "__debug_pubtypes" } } */ +/* { dg-final { scan-assembler "long+\[ \t\]+0x\[0-9a-f]+\[ \t\]+\[#;]+\[ \t\]+Pub Info Length" } } */ +/* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ +/* { dg-final { scan-assembler "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ + + +#include +#include + +struct used_struct +{ + int key; + char *name; +}; + +struct unused_struct +{ + int key1; + int f2; + double f3; + char *f4; + struct unused_struct *next; +}; + +int +main (int argc, char **argv) +{ + int i; + struct used_struct *my_list; + + my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct)); + + for (i = 0; i < 10; i++) + { + my_list[i].key = i; + my_list[i].name = (char *) malloc (11); + sprintf (my_list[i].name, "Alice_%d", i); + } + + for (i = 0; i < 10; i++) + fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pubtypes-2.c b/SingleSource/Regression/C/gcc-dg/pubtypes-2.c new file mode 100644 index 0000000000..116e3489bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pubtypes-2.c @@ -0,0 +1,46 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-O0 -gdwarf-2 -dA" } */ +/* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */ +/* { dg-final { scan-assembler "__debug_pubtypes" } } */ +/* { dg-final { scan-assembler {long+[ \t]+0x14d+[ \t]+[#;]+[ \t]+Pub Info Length} } } */ +/* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ +/* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ + +#include +#include + +struct used_struct +{ + int key; + char *name; +}; + +struct unused_struct +{ + int key1; + int f2; + double f3; + char *f4; + struct unused_struct *next; +}; + +int +main (int argc, char **argv) +{ + int i; + struct used_struct *my_list; + + my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct)); + + for (i = 0; i < 10; i++) + { + my_list[i].key = i; + my_list[i].name = (char *) malloc (11); + sprintf (my_list[i].name, "Alice_%d", i); + } + + for (i = 0; i < 10; i++) + fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pubtypes-3.c b/SingleSource/Regression/C/gcc-dg/pubtypes-3.c new file mode 100644 index 0000000000..3fb3468fb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pubtypes-3.c @@ -0,0 +1,84 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-O0 -gdwarf-2 -dA" } */ +/* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */ +/* { dg-final { scan-assembler "__debug_pubtypes" } } */ +/* { dg-final { scan-assembler {long+[ \t]+0x14d+[ \t]+[#;]+[ \t]+Pub Info Length} } } */ +/* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ +/* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ +/* { dg-final { scan-assembler-not "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ + +#include +#include +#include + +struct used_struct +{ + int key; + char *name; +}; + +struct unused_struct +{ + int key1; + int f2; + double f3; + char *f4; + struct unused_struct *next; +}; + +void +foo (struct used_struct *list) +{ + enum list_name_type { + boy_name, + girl_name, + unknown + }; + + int b_count = 0; + int g_count = 0; + int i; + enum list_name_type *enum_list; + + enum_list = (enum list_name_type *) malloc (10 * sizeof (enum list_name_type)); + + for (i = 0; i < 10; i++) + { + if (strncmp (list[i].name, "Alice", 5) == 0) + { + enum_list[i] = girl_name; + g_count++; + } + else if (strncmp (list[i].name, "David", 5) == 0) + { + enum_list[i] = boy_name; + b_count++; + } + else + enum_list[i] = unknown; + } + +} + +int +main (int argc, char **argv) +{ + int i; + struct used_struct *my_list; + + my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct)); + + for (i = 0; i < 10; i++) + { + my_list[i].key = i; + my_list[i].name = (char *) malloc (11); + sprintf (my_list[i].name, "Alice_%d", i); + } + + foo (my_list); + + for (i = 0; i < 10; i++) + fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pubtypes-4.c b/SingleSource/Regression/C/gcc-dg/pubtypes-4.c new file mode 100644 index 0000000000..83fba8dfab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pubtypes-4.c @@ -0,0 +1,97 @@ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-O0 -gdwarf-2 -dA" } */ +/* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */ +/* { dg-final { scan-assembler "__debug_pubtypes" } } */ +/* { dg-final { scan-assembler {long+[ \t]+0x184+[ \t]+[#;]+[ \t]+Pub Info Length} } } */ +/* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ +/* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ +/* { dg-final { scan-assembler "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ +/* { dg-final { scan-assembler "\"enum_list_array\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ +/* { dg-final { scan-assembler "\"field_union\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ + +#include +#include +#include + +struct used_struct +{ + int key; + char *name; + union field_union + { + char u_c; + int u_i; + long u_l; + double u_d; + } u; +}; + +struct unused_struct +{ + int key1; + int f2; + double f3; + char *f4; + struct unused_struct *next; +}; + +enum list_name_type { + boy_name, + girl_name, + unknown +}; + + +typedef enum list_name_type *enum_list_array; + +enum_list_array enum_list; + +void +foo (struct used_struct *list) +{ + int b_count = 0; + int g_count = 0; + int i; + + enum_list = (enum_list_array) malloc (10 * sizeof (enum list_name_type)); + + for (i = 0; i < 10; i++) + { + if (strncmp (list[i].name, "Alice", 5) == 0) + { + enum_list[i] = girl_name; + g_count++; + } + else if (strncmp (list[i].name, "David", 5) == 0) + { + enum_list[i] = boy_name; + b_count++; + } + else + enum_list[i] = unknown; + } + +} + +int +main (int argc, char **argv) +{ + int i; + struct used_struct *my_list; + + my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct)); + + for (i = 0; i < 10; i++) + { + my_list[i].key = i; + my_list[i].name = (char *) malloc (11); + sprintf (my_list[i].name, "Alice_%d", i); + } + + foo (my_list); + + for (i = 0; i < 10; i++) + fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/pure-1.c b/SingleSource/Regression/C/gcc-dg/pure-1.c new file mode 100644 index 0000000000..9739aa69af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pure-1.c @@ -0,0 +1,15 @@ +/* Regression test for PR middle-end/23584 */ +/* Verify that dereferencing a volatile element in a struct causes + the function not be pure. */ + +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-ipa-pure-const" } */ + +struct test_a { volatile int a; }; + +int func_a(struct test_a *a) +{ + return a->a; +} + +/* { dg-final { scan-ipa-dump-not "found to be pure: func_a" "pure-const" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/pure-2.c b/SingleSource/Regression/C/gcc-dg/pure-2.c new file mode 100644 index 0000000000..318cfd1863 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/pure-2.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wsuggest-attribute=pure -fno-finite-loops" } */ +/* { dg-add-options bind_pic_locally } */ + +extern int extern_const(int a) __attribute__ ((pure)); +extern int v; + +/* Trivial. */ +int +foo1(int a) /* { dg-bogus "normally" "detect pure candidate" } */ +{ /* { dg-warning "pure" "detect pure candidate" { target *-*-* } "10" } */ + return v; +} + +/* Loops known to be normally and extern const calls should be safe. */ +int __attribute__ ((noinline)) +foo2(int n) /* { dg-bogus "normally" "detect pure candidate" } */ +{ /* { dg-warning "pure" "detect pure candidate" { target *-*-* } "17" } */ + int ret = 0; + int i; + for (i=0; i */ +/* { dg-do compile } */ +/* { dg-options "-pedantic -Wdiscarded-array-qualifiers" } */ + +struct s { + int a; + int b[1]; + int c[2][3]; + const int d; + const int e[1]; + const int f[2][3]; +}; + +union u { + int a; + int b[1]; + int c[2][3]; + const int d; + const int e[1]; + const int f[2][3]; +}; + +struct cs { + const struct s x; +}; + +struct s v1; +union u *v2; +const struct s *v3; +const union u v4; +struct cs v5; + +void +f (void) +{ + v1.a = 0; + v1.b[0] = 0; + *v1.b = 0; + v1.c[0][0] = 0; + *v1.c[0] = 0; + **v1.c = 0; + v1.d = 0; /* { dg-error "assignment of read-only" } */ + v1.e[0] = 0; /* { dg-error "assignment of read-only" } */ + *v1.e = 0; /* { dg-error "assignment of read-only" } */ + v1.f[0][0] = 0; /* { dg-error "assignment of read-only" } */ + *v1.f[0] = 0; /* { dg-error "assignment of read-only" } */ + **v1.f = 0; /* { dg-error "assignment of read-only" } */ + + v2->a = 0; + v2->b[0] = 0; + *v2->b = 0; + v2->c[0][0] = 0; + *v2->c[0] = 0; + **v2->c = 0; + v2->d = 0; /* { dg-error "assignment of read-only" } */ + v2->e[0] = 0; /* { dg-error "assignment of read-only" } */ + *v2->e = 0; /* { dg-error "assignment of read-only" } */ + v2->f[0][0] = 0; /* { dg-error "assignment of read-only" } */ + *v2->f[0] = 0; /* { dg-error "assignment of read-only" } */ + **v2->f = 0; /* { dg-error "assignment of read-only" } */ + + v3->a = 0; /* { dg-error "assignment of member" } */ + v3->b[0] = 0; /* { dg-error "assignment of read-only" } */ + *v3->b = 0; /* { dg-error "assignment of read-only" } */ + v3->c[0][0] = 0; /* { dg-error "assignment of read-only" } */ + *v3->c[0] = 0; /* { dg-error "assignment of read-only" } */ + **v3->c = 0; /* { dg-error "assignment of read-only" } */ + v3->d = 0; /* { dg-error "assignment of member" } */ + v3->e[0] = 0; /* { dg-error "assignment of read-only" } */ + *v3->e = 0; /* { dg-error "assignment of read-only" } */ + v3->f[0][0] = 0; /* { dg-error "assignment of read-only" } */ + *v3->f[0] = 0; /* { dg-error "assignment of read-only" } */ + **v3->f = 0; /* { dg-error "assignment of read-only" } */ + + v4.a = 0; /* { dg-error "assignment of member" } */ + v4.b[0] = 0; /* { dg-error "assignment of read-only" } */ + *v4.b = 0; /* { dg-error "assignment of read-only" } */ + v4.c[0][0] = 0; /* { dg-error "assignment of read-only" } */ + *v4.c[0] = 0; /* { dg-error "assignment of read-only" } */ + **v4.c = 0; /* { dg-error "assignment of read-only" } */ + v4.d = 0; /* { dg-error "assignment of member" } */ + v4.e[0] = 0; /* { dg-error "assignment of read-only" } */ + *v4.e = 0; /* { dg-error "assignment of read-only" } */ + v4.f[0][0] = 0; /* { dg-error "assignment of read-only" } */ + *v4.f[0] = 0; /* { dg-error "assignment of read-only" } */ + **v4.f = 0; /* { dg-error "assignment of read-only" } */ + + v5.x.a = 0; /* { dg-error "assignment of member" } */ + v5.x.b[0] = 0; /* { dg-error "assignment of read-only" } */ + *v5.x.b = 0; /* { dg-error "assignment of read-only" } */ + v5.x.c[0][0] = 0; /* { dg-error "assignment of read-only" } */ + *v5.x.c[0] = 0; /* { dg-error "assignment of read-only" } */ + **v5.x.c = 0; /* { dg-error "assignment of read-only" } */ + v5.x.d = 0; /* { dg-error "assignment of member" } */ + v5.x.e[0] = 0; /* { dg-error "assignment of read-only" } */ + *v5.x.e = 0; /* { dg-error "assignment of read-only" } */ + v5.x.f[0][0] = 0; /* { dg-error "assignment of read-only" } */ + *v5.x.f[0] = 0; /* { dg-error "assignment of read-only" } */ + **v5.x.f = 0; /* { dg-error "assignment of read-only" } */ +} + +void +g (void) +{ + { + int *a = &v1.a; + int (*b)[1] = &v1.b; + int (*c)[2][3] = &v1.c; + int (*cc)[3] = v1.c; + const int (*ff)[3] = v1.c; /* { dg-warning "pointers to arrays with different qualifiers" } */ + a = &v1.a; + b = &v1.b; + c = &v1.c; + cc = v1.c; + ff = v1.c; /* { dg-warning "pointers to arrays with different qualifiers" } */ + } + { + const int *d = &v1.d; + const int (*e)[1] = &v1.e; + const int (*f)[2][3] = &v1.f; + const int (*ff)[3] = v1.f; + int (*cc)[3] = v1.f; /* { dg-warning "pointers to arrays with different qualifiers|initialization discards" } */ + d = &v1.d; + e = &v1.e; + f = &v1.f; + ff = v1.f; + cc = v1.f; /* { dg-warning "pointers to arrays with different qualifiers|assignment discards" } */ + } + + { + int *a = &v2->a; + int (*b)[1] = &v2->b; + int (*c)[2][3] = &v2->c; + int (*cc)[3] = v2->c; + const int (*ff)[3] = v2->c; /* { dg-warning "pointers to arrays with different qualifiers" } */ + a = &v2->a; + b = &v2->b; + c = &v2->c; + cc = v2->c; + ff = v2->c; /* { dg-warning "pointers to arrays with different qualifiers" } */ + } + { + const int *d = &v2->d; + const int (*e)[1] = &v2->e; + const int (*f)[2][3] = &v2->f; + const int (*ff)[3] = v2->f; + int (*cc)[3] = v2->f; /* { dg-warning "pointers to arrays with different qualifiers|initialization discards" } */ + d = &v2->d; + e = &v2->e; + f = &v2->f; + ff = v2->f; + cc = v2->f; /* { dg-warning "pointers to arrays with different qualifiers|assignment discards" } */ + } + + { + const int *d = &v3->a; + const int (*e)[1] = &v3->b; + const int (*f)[2][3] = &v3->c; + const int (*ff)[3] = v3->c; + int (*cc)[3] = v3->c; /* { dg-warning "pointers to arrays with different qualifiers|initialization discards" } */ + d = &v3->a; + e = &v3->b; + f = &v3->c; + ff = v3->c; + cc = v3->c; /* { dg-warning "pointers to arrays with different qualifiers|assignment discards" } */ + } + { + const int *d = &v3->d; + const int (*e)[1] = &v3->e; + const int (*f)[2][3] = &v3->f; + const int (*ff)[3] = v3->f; + int (*cc)[3] = v3->f; /* { dg-warning "pointers to arrays with different qualifiers|initialization discards" } */ + d = &v3->d; + e = &v3->e; + f = &v3->f; + ff = v3->f; + cc = v3->f; /* { dg-warning "pointers to arrays with different qualifiers|assignment discards" } */ + } + + { + const int *d = &v4.a; + const int (*e)[1] = &v4.b; + const int (*f)[2][3] = &v4.c; + const int (*ff)[3] = v4.c; + int (*cc)[3] = v4.c; /* { dg-warning "pointers to arrays with different qualifiers|initialization discards" } */ + d = &v4.a; + e = &v4.b; + f = &v4.c; + ff = v4.c; + cc = v4.c; /* { dg-warning "pointers to arrays with different qualifiers|assignment discards" } */ + } + { + const int *d = &v4.d; + const int (*e)[1] = &v4.e; + const int (*f)[2][3] = &v4.f; + const int (*ff)[3] = v4.f; + int (*cc)[3] = v4.f; /* { dg-warning "pointers to arrays with different qualifiers|initialization discards" } */ + d = &v4.d; + e = &v4.e; + f = &v4.f; + ff = v4.f; + cc = v4.f; /* { dg-warning "pointers to arrays with different qualifiers|assignment discards" } */ + } + + { + const int *d = &v5.x.a; + const int (*e)[1] = &v5.x.b; + const int (*f)[2][3] = &v5.x.c; + const int (*ff)[3] = v5.x.c; + int (*cc)[3] = v5.x.c; /* { dg-warning "pointers to arrays with different qualifiers|initialization discards" } */ + d = &v5.x.a; + e = &v5.x.b; + f = &v5.x.c; + ff = v5.x.c; + cc = v5.x.c; /* { dg-warning "pointers to arrays with different qualifiers|assignment discards" } */ + } + { + const int *d = &v5.x.d; + const int (*e)[1] = &v5.x.e; + const int (*f)[2][3] = &v5.x.f; + const int (*ff)[3] = v5.x.f; + int (*cc)[3] = v5.x.f; /* { dg-warning "pointers to arrays with different qualifiers|initialization discards" } */ + d = &v5.x.d; + e = &v5.x.e; + f = &v5.x.f; + ff = v5.x.f; + cc = v5.x.f; /* { dg-warning "pointers to arrays with different qualifiers|assignment discards" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-1.c b/SingleSource/Regression/C/gcc-dg/qual-return-1.c new file mode 100644 index 0000000000..8151995d8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-1.c @@ -0,0 +1,22 @@ +/* Test for warnings for qualified function return types. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wreturn-type -Wignored-qualifiers" } */ + +/* Qualifying a function return type makes no sense. */ + +const int int_fn (void); /* { dg-warning "qualifiers" "int decl" } */ +const int (*int_ptr) (void); /* { dg-warning "qualifiers" "int ptr" } */ +const int int_fn2 (void) { return 0; } /* { dg-warning "qualifiers" "int defn" } */ + +const void void_fn (void); /* { dg-warning "qualifiers" "void decl" } */ +const void (*void_ptr) (void); /* { dg-warning "qualifiers" "void ptr" } */ +const void void_fn2 (void) { } /* { dg-warning "qualified" "void defn" } */ + +volatile void vvoid_fn (void); /* { dg-warning "qualifiers" "void decl" } */ +volatile void (*vvoid_ptr) (void); /* { dg-warning "qualifiers" "void ptr" } */ +volatile void vvoid_fn2 (void) { } /* { dg-warning "qualified" "void defn" } */ + +int *restrict ip_fn (void); /* { dg-warning "qualifiers" "restrict decl" } */ +int *restrict (*ip_ptr) (void); /* { dg-warning "qualifiers" "restrict ptr" } */ +int *restrict ip_fn2 (void) { return (int *)0; }; /* { dg-warning "qualifiers" "restrict defn" } */ diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-10.c b/SingleSource/Regression/C/gcc-dg/qual-return-10.c new file mode 100644 index 0000000000..c7dd6adc4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-10.c @@ -0,0 +1,12 @@ +/* Test qualifiers on function return types in C2X (C2X version of + qual-return-6.c): those qualifiers are now ignored for all purposes, + including _Atomic, but should still get warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wignored-qualifiers" } */ + +const int f1 (void); /* { dg-warning "qualifiers ignored" } */ +volatile int f2 (void) { return 0; } /* { dg-warning "qualifiers ignored" } */ +const volatile void f3 (void) { } /* { dg-warning "qualifiers ignored" } */ +const void f4 (void); /* { dg-warning "qualifiers ignored" } */ +_Atomic int f5 (void); /* { dg-warning "qualifiers ignored" } */ +_Atomic int f6 (void) { return 0; } /* { dg-warning "qualifiers ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-2.c b/SingleSource/Regression/C/gcc-dg/qual-return-2.c new file mode 100644 index 0000000000..1cd1253518 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-2.c @@ -0,0 +1,13 @@ +/* Test for warnings for qualified function return types. -pedantic test. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic -std=gnu99" } */ + +/* Qualifying a function return type makes no sense. */ + +/* The first two of these shouldn't warn (with just -pedantic) as long + as the function is not defined. */ + +volatile void vvoid_fn (void); +volatile void (*vvoid_ptr) (void); +volatile void vvoid_fn2 (void) { } /* { dg-warning "qualified" "volatile defn" } */ diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-3.c b/SingleSource/Regression/C/gcc-dg/qual-return-3.c new file mode 100644 index 0000000000..bd760799d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-3.c @@ -0,0 +1,16 @@ +/* Test for warnings for qualified function return types. Bug 15052 + from Olatunji Ruwase (tjruwase at stanfordalumni.org): qualifiers + should not be lost when merging declarations. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +int foo (); /* { dg-message "note: previous declaration" "different qualifiers" } */ +const int foo () { return 0; } /* { dg-error "conflicting types" "different qualifiers" } */ + +void bar (void); +volatile void bar () { } /* { dg-warning "qualified|volatile" "different qualifiers" } */ + +volatile void baz (void); +void baz () { } /* { dg-warning "not compatible" "different qualifiers" } */ diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-4.c b/SingleSource/Regression/C/gcc-dg/qual-return-4.c new file mode 100644 index 0000000000..7bb5b69197 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-4.c @@ -0,0 +1,10 @@ +/* Test for warnings for qualified function return types. -pedantic + test. Only the definition gets a warning for qualified void return + types, not other such types within the definition. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic -std=gnu99" } */ + +volatile void (*y)(int); + +volatile void (*vvf(int x))(int) { return y; } diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-5.c b/SingleSource/Regression/C/gcc-dg/qual-return-5.c new file mode 100644 index 0000000000..32a08f217d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-5.c @@ -0,0 +1,32 @@ +/* Test qualifiers on function return types after DR#423: those + qualifiers are now ignored for all purposes (but _Atomic is not, + for this purpose, a qualifier). */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +int f1 (void); +const int f1 (void); +volatile int f1 (void) { return 0; } + +int *restrict f2 (void) { return 0; } +int *f2 (void); + +const volatile long f3 (void); +long f3 (void); + +const volatile void f4 (void) { } +void f4 (void); + +_Atomic int f5 (void); /* { dg-message "previous declaration" } */ +int f5 (void); /* { dg-error "conflicting" } */ + +int f6 (void); /* { dg-message "previous declaration" } */ +_Atomic int f6 (void) { return 0; } /* { dg-error "conflicting" } */ + +/* The standard seems unclear regarding the case where restrict is + applied to a function return type that may not be + restrict-qualified; assume here that it is disallowed. */ +restrict int f7 (void); /* { dg-error "restrict" } */ + +typedef void FT (void); +FT *restrict f8 (void); /* { dg-error "restrict" } */ diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-6.c b/SingleSource/Regression/C/gcc-dg/qual-return-6.c new file mode 100644 index 0000000000..5b3ded0696 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-6.c @@ -0,0 +1,12 @@ +/* Test qualifiers on function return types after DR#423: those + qualifiers are now ignored for all purposes (except that _Atomic + still affects the type), but should still get warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -Wignored-qualifiers" } */ + +const int f1 (void); /* { dg-warning "qualifiers ignored" } */ +volatile int f2 (void) { return 0; } /* { dg-warning "qualifiers ignored" } */ +const volatile void f3 (void) { } /* { dg-warning "qualifiers ignored" } */ +const void f4 (void); /* { dg-warning "qualifiers ignored" } */ +_Atomic int f5 (void); /* { dg-warning "qualifiers ignored" } */ +_Atomic int f6 (void) { return 0; } /* { dg-warning "qualifiers ignored" } */ diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-7.c b/SingleSource/Regression/C/gcc-dg/qual-return-7.c new file mode 100644 index 0000000000..96f7f16305 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-7.c @@ -0,0 +1,18 @@ +/* Same as qual-return-3.c but with nested functions. + { dg-do compile } + { dg-options "-std=gnu99" } */ + +void test_local (void) +{ + auto int foo (); /* { dg-message "note: previous declaration" "different qualifiers" } */ + + const int foo () { return 0; } /* { dg-error "conflicting types" "different qualifiers" } */ + + auto void bar (void); + volatile void bar () { } /* { dg-warning "qualified|volatile" "different qualifiers" } */ + + auto volatile void baz (void); + void baz () { } /* { dg-warning "not compatible" "different qualifiers" } */ +} + +/* { dg-prune-output "nested function 'foo' declared but never defined" } */ diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-8.c b/SingleSource/Regression/C/gcc-dg/qual-return-8.c new file mode 100644 index 0000000000..de1e7cb7b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-8.c @@ -0,0 +1,28 @@ +/* Same as qual-return-7.c but in C11 mode. + { dg-do compile } + { dg-options "-std=gnu11" } */ + +void test_local (void) +{ +#if 0 + /* _Atomic is not considered a qualifier and so is not ignored + on a return type. As a result, the redeclaration below isn't + valid. See also qual-return-5.c. */ + auto int fi_ai (); + _Atomic int fi_ai () { return 0; } +#endif + + auto int fi_ci (); + const int fi_ci () { return 0; } + + auto enum E fe_ce (); + + enum E { e }; + const enum E fe_ce () { return 0; } + + auto void fv_vv (void); + volatile void fv_vv () { } + + auto volatile void fvv_v (void); + void fvv_v () { } +} diff --git a/SingleSource/Regression/C/gcc-dg/qual-return-9.c b/SingleSource/Regression/C/gcc-dg/qual-return-9.c new file mode 100644 index 0000000000..7762782edf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/qual-return-9.c @@ -0,0 +1,32 @@ +/* Test qualifiers on function return types in C2X (C2X version of + qual-return-5.c): those qualifiers are now ignored for all purposes, + including _Atomic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int f1 (void); +const int f1 (void); +volatile int f1 (void) { return 0; } + +int *restrict f2 (void) { return 0; } +int *f2 (void); + +const volatile long f3 (void); +long f3 (void); + +const volatile void f4 (void) { } +void f4 (void); + +_Atomic int f5 (void); +int f5 (void); + +int f6 (void); +_Atomic int f6 (void) { return 0; } + +/* The standard seems unclear regarding the case where restrict is + applied to a function return type that may not be + restrict-qualified; assume here that it is disallowed. */ +restrict int f7 (void); /* { dg-error "restrict" } */ + +typedef void FT (void); +FT *restrict f8 (void); /* { dg-error "restrict" } */ diff --git a/SingleSource/Regression/C/gcc-dg/range-test-1.c b/SingleSource/Regression/C/gcc-dg/range-test-1.c new file mode 100644 index 0000000000..93a90ac718 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/range-test-1.c @@ -0,0 +1,168 @@ +/* Test fold-const.c (fold_range_test) optimizations. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include +#include +#include + +#if (INT_MAX == 2147483647) && (INT_MIN == -2147483648) \ + && (SCHAR_MIN == -128) && (SCHAR_MAX == 127) \ + && (UCHAR_MIN == 0) && (UCHAR_MAX == 255) + +#ifndef T + +enum integers +{ + int_smallest = INT_MIN, + int_2ndsmallest = INT_MIN + 1, + int_3rdsmallest = INT_MIN + 2, + int_minus2 = -2, + int_minus1 = -1, + int_zero = 0, + int_one = 1, + int_two = 2, + int_3rdlargest = INT_MAX - 2, + int_2ndlargest = INT_MAX - 1, + int_largest = INT_MAX +}; + +int var; +void +check (void) +{ + ++var; +} + +#define T(IDX, TYPE, TEST, YESARR, NOARR) \ +void __attribute__((noinline)) \ +test##IDX (TYPE x) \ +{ \ + if (TEST) \ + check (); \ +} +#include "range-test-1.c" +#undef T + +int +main (void) +{ + int i, fails = 0; + +#define C , +#define T(IDX, TYPE, TEST, YESARR, NOARR) \ + { \ + static TYPE yesarr##IDX [] = YESARR; \ + static TYPE noarr##IDX [] = NOARR; \ + for (i = 0; i < (int) (sizeof (yesarr##IDX) / sizeof (TYPE)); ++i) \ + { \ + var = 0; \ + test##IDX (yesarr##IDX [i]); \ + if (var != 1) \ + printf ("test" #IDX " failed for yesarr [%u]\n", i), ++fails; \ + } \ + var = 0; \ + for (i = 0; i < (int) (sizeof (noarr##IDX) / sizeof (TYPE)); ++i) \ + { \ + test##IDX (noarr##IDX [i]); \ + if (var != 0) \ + printf ("test" #IDX " failed for noarr [%u]\n", i), ++fails; \ + } \ + } +#include "range-test-1.c" +#undef T + + if (fails) + abort (); + + exit (0); +} + +#else + +/* Use `C' instead of `,' below to separate array entries. */ + +/* These ought to be all optimized into single comparison. */ +T(1, unsigned int, x == 0 || x == 1, + { 0 C 1 }, { -1U C 2 C 12 C 35 C 0x7fffffff C 0x80000000 }) +T(2, unsigned int, x == 0 || x == -1U || x == -2U, + { 0 C -1U C -2U }, { -3U C -6U C 1 C 2 C 12 C 35 C 0x7fffffff C 0x80000000 }) +T(3, unsigned int, x == 0 || x == 1 || x == 2, + { 0 C 1 C 2 }, { -3U C -6U C -1U C -2U C 12 C 35 C 0x7fffffff C 0x80000000 }) +T(4, unsigned int, x == 3 || x == 4 || x == 5 || x == 6, + { 3 C 4 C 5 C 6 }, { -3U C 0 C 1 C 2 C 7 C 8 C 12 C 0x7fffffff C 0x80000000 }) +T(5, unsigned int, x == -3U || x == -4U || x == -5U || x == -6U, + { -3U C -4U C -5U C -6U }, { -7U C -8U C -2U C -1U C 1 C 2 C 0x7fffffff C 0x80000000 }) +T(6, unsigned int, x == -3U || x == -4U || x == -5U, + { -3U C -4U C -5U }, { -6U C -7U C -8U C -2U C -1U C 1 C 2 C 0x7fffffff C 0x80000000 }) +T(7, char *, x == (char *) -3UL || x == (char *) -4UL || x == (char *) -5UL, + { (char *) -3UL C (char *) -4UL C (char *) -5UL }, + { (char *) -6UL C (char *) -20UL C (char *) -2UL C (char *) -1UL C (char *) 0 + C (char *) 1UL C (char *) 35UL C (char *) 0x7fffffffUL C (char *) 0x80000000UL }) +T(8, unsigned long, x == -2UL || x == -1UL || x == 0, + { 0 C -1UL C -2UL }, { -3UL C -6UL C 1 C 2 C 12 C 35 C 0x7fffffff C 0x80000000 }) +T(9, unsigned long, x >= -4UL || x <= 8, + { -4UL C -3UL C -2UL C -1UL C 0 C 1 C 2 C 3 C 4 C 5 C 6 C 7 C 8 }, + { -7UL C -5UL C 9 C 10 C 61 C 127 C 0x7fffffff C 0x80000000 }) +T(10, signed char, x == 0 || x == -1 || x == -2 || x == -3, + { 0 C -1 C -2 C -3 }, { -4 C -5 C 1 C 2 C 3 C 35 C -24 }) +T(11, int, x == 0 || x == 1, + { 0 C 1 }, { -1 C 2 C 12 C 35 C INT_MAX C INT_MIN }) +T(12, int, x == 0 || x == -1 || x == -2, + { 0 C -1 C -2 }, { -3 C -6 C 1 C 2 C 12 C 35 C INT_MAX C INT_MIN }) +T(13, int, x == 0 || x == 1 || x == 2, + { 0 C 1 C 2 }, { -3 C -6 C -1 C -2 C 12 C 35 C INT_MAX C INT_MIN }) +T(14, int, x == 3 || x == 4 || x == 5 || x == 6, + { 3 C 4 C 5 C 6 }, { -3 C 0 C 1 C 2 C 7 C 8 C 12 C INT_MAX C INT_MIN }) +T(15, int, x == -3 || x == -4 || x == -5 || x == -6, + { -3 C -4 C -5 C -6 }, { -7 C -8 C -2 C -1 C 1 C 2 C INT_MAX C INT_MIN }) +T(16, int, x == -3 || x == -4 || x == -5, + { -3 C -4 C -5 }, { -6 C -7 C -8 C -2 C -1 C 1 C 2 C INT_MAX C INT_MIN }) +T(17, unsigned int, (x >= -8U && x <= -3U) || x == -2U || x == -1U || x == 0 || x == 1 || x == 2, + { -8U C -7U C -6U C -5U C -4U C -3U C -2U C -1U C 0 C 1 C 2 }, + { -9U C -10U C 3 C 4 C 12 C -54U C INT_MAX C INT_MIN }) +T(18, int, (x >= -8 && x <= -3) || x == -2 || x == -1 || x == 0 || x == 1 || x == 2, + { -8 C -7 C -6 C -5 C -4 C -3 C -2 C -1 C 0 C 1 C 2 }, + { -9 C -10 C 3 C 4 C 12 C -54 C INT_MAX C INT_MIN }) +T(19, unsigned long, (x >= 0 && x <= 16) || (x >= 18 && x <= -1UL), + { -3UL C -6UL C -1UL C 0 C 1 C 2 C 12 C 15 C 16 C 18 C 19 C 35 C 0x7fffffff + C 0x80000000 }, { 17 }) +T(20, char *, x == (char *) -1UL || x == 0, + { (char *) -1UL C 0 }, { (char *) -6UL C (char *) -20UL C (char *) -2UL + C (char *) 1UL C (char *) 35UL C (char *) 0x7fffffffUL C (char *) 0x80000000UL }) +T(21, enum integers, x == int_zero || x == int_one, + { int_zero C int_one }, { int_minus1 C int_two C 12 C 35 C int_largest C int_smallest }) +T(22, int, x == INT_MIN || x == INT_MAX, + { INT_MIN C INT_MAX }, + { -1 C 0 C 1 C INT_MAX - 1 C INT_MAX - 2 C INT_MIN + 1 C INT_MIN + 2 }) +T(23, int, x == INT_MIN + 1 || x == INT_MIN + 2 || x == INT_MIN || x == INT_MAX, + { INT_MIN + 1 C INT_MIN + 2 C INT_MIN C INT_MAX }, + { -1 C 0 C 1 C INT_MAX - 1 C INT_MAX - 2 C INT_MIN + 3 C INT_MIN + 4 }) +T(24, signed char, x == SCHAR_MIN || x == SCHAR_MAX, + { SCHAR_MIN C SCHAR_MAX }, + { -1 C 0 C 1 C SCHAR_MAX - 1 C SCHAR_MAX - 2 C SCHAR_MIN + 1 C SCHAR_MIN + 2 }) +T(25, enum integers, x == int_smallest || x == int_largest, + { int_smallest C int_largest }, { int_minus1 C int_zero C int_one + C int_2ndsmallest C int_2ndlargest C int_3rdsmallest C int_3rdlargest }) + +/* This should be optimized into unconditional jump. */ +T(o1, unsigned long, (x >= 0 && x <= 16) || (x >= 17 && x <= -1UL), + { -3UL C -6UL C -1UL C 0 C 1 C 2 C 12 C 15 C 16 C 17 C 18 C 19 C 35 C 0x7fffffff + C 0x80000000 }, { }) +T(o2, unsigned long, (x >= 0 && x <= -3UL) || (x == -2UL || x == -1UL), + { -3UL C -6UL C -1UL C 0 C 1 C 2 C 12 C 15 C 16 C 17 C 18 C 19 C 35 C 0x7fffffff + C 0x80000000 }, { }) + +/* This should be eventually optimized into a single comparison. */ +T(td1, unsigned char, x == 0 || x == 4 || x == 1 || x == 5 || x == 2 || x == 6 || x == 3, + { 0 C 1 C 2 C 3 C 4 C 5 C 6 }, { 7 C 8 C 127 C 128 C 254 C 255 }) + +#endif + +#else +int +main (void) +{ + return 0; +} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/range.h b/SingleSource/Regression/C/gcc-dg/range.h new file mode 100644 index 0000000000..0b4d9e80be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/range.h @@ -0,0 +1,57 @@ +#ifndef RANGE_H + +/* Definitions of helper functions and macros to create expressions + in a specified range. Not all the symbols declared here are + defined. */ + +#define SIZE_MAX __SIZE_MAX__ +#define DIFF_MAX __PTRDIFF_MAX__ +#define DIFF_MIN (-DIFF_MAX - 1) + +typedef __INT32_TYPE__ int32_t; +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +static inline ptrdiff_t signed_value (void) +{ + extern volatile ptrdiff_t signed_value_source; + return signed_value_source; +} + +static inline size_t unsigned_value (void) +{ + extern volatile size_t unsigned_value_source; + return unsigned_value_source; +} + +static inline ptrdiff_t signed_range (ptrdiff_t min, ptrdiff_t max) +{ + ptrdiff_t val = signed_value (); + return val < min || max < val ? min : val; +} + +static inline ptrdiff_t signed_anti_range (ptrdiff_t min, ptrdiff_t max) +{ + ptrdiff_t val = signed_value (); + return min <= val && val <= max ? min == DIFF_MIN ? max + 1 : min - 1 : val; +} + +static inline size_t unsigned_range (size_t min, size_t max) +{ + size_t val = unsigned_value (); + return val < min || max < val ? min : val; +} + +static inline size_t unsigned_anti_range (size_t min, size_t max) +{ + size_t val = unsigned_value (); + return min <= val && val <= max ? min == 0 ? max + 1 : min - 1 : val; +} + +#define SR(min, max) signed_range ((min), (max)) +#define UR(min, max) unsigned_range ((min), (max)) + +#define SAR(min, max) signed_anti_range ((min), (max)) +#define UAR(min, max) unsigned_anti_range ((min), (max)) + +#endif /* RANGE_H */ diff --git a/SingleSource/Regression/C/gcc-dg/readonly-loc.c b/SingleSource/Regression/C/gcc-dg/readonly-loc.c new file mode 100644 index 0000000000..c5d1c97d87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/readonly-loc.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +int func() +{ + const int *arr; + const int arr2[5]; + arr[0] = 1; /* { dg-error "assignment of read-only location" "*(arr)" } */ + arr[1] = 1; /* { dg-error "assignment of read-only location" "*(arr + 4u)" } */ + arr2[0] = 1; /* { dg-error "assignment of read-only location" "arr2\[0\]" } */ + arr2[1] = 1; /* { dg-error "assignment of read-only location" "arr2\[1\]" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/real-const-1.c b/SingleSource/Regression/C/gcc-dg/real-const-1.c new file mode 100644 index 0000000000..4c7058d17a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/real-const-1.c @@ -0,0 +1,5 @@ +/* PR middle-end/21781. */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int foo(void) { if (.0e200000000 == 0 ) return 1; } diff --git a/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_1.c b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_1.c new file mode 100644 index 0000000000..80b9f679ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-recip" } */ +/* { dg-additional-options "-fcompare-debug" { target { ! powerpc-ibm-aix* } } } */ + +double res, res2, tmp; +void +foo (double a, double b) +{ + tmp = 1.0 / __builtin_sqrt (a); + res = tmp * tmp; + res2 = a * tmp; +} + +/* { dg-final { scan-tree-dump "Optimizing reciprocal sqrt multiplications" "recip" } } */ +/* { dg-final { scan-tree-dump "Replacing squaring multiplication" "recip" } } */ +/* { dg-final { scan-tree-dump "Replacing original division" "recip" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_2.c b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_2.c new file mode 100644 index 0000000000..fe40bf7d79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ +/* { dg-additional-options "-fcompare-debug" { target { ! powerpc-ibm-aix* } } } */ + +float +foo (float a) +{ + float tmp = 1.0f / __builtin_sqrtf (a); + return a * tmp; +} + +/* { dg-final { scan-tree-dump-not " / " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_3.c b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_3.c new file mode 100644 index 0000000000..7d191b6612 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ +/* { dg-additional-options "-fcompare-debug" { target { ! powerpc-ibm-aix* } } } */ + +double +foo (double a) +{ + double tmp = 1.0f / __builtin_sqrt (a); + return tmp * tmp; +} + +/* { dg-final { scan-tree-dump-not "__builtin_sqrt" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_4.c b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_4.c new file mode 100644 index 0000000000..e192a3fb85 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_4.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-recip" } */ +/* { dg-additional-options "-fcompare-debug" { target { ! powerpc-ibm-aix* } } } */ + +/* The main path doesn't have any multiplications. + Avoid introducing them in the recip pass. */ + +double res, res2, tmp; +void +foo (double a, double b, int c, int d) +{ + tmp = 1.0 / __builtin_sqrt (a); + if (c) + res = tmp * tmp; + + if (d) + res2 = a * tmp; +} + +/* { dg-final { scan-tree-dump-not "Optimizing reciprocal sqrt multiplications" "recip" } } */ +/* { dg-final { scan-tree-dump-not "Replacing squaring multiplication" "recip" } } */ +/* { dg-final { scan-tree-dump-not "Replacing original division" "recip" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_5.c b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_5.c new file mode 100644 index 0000000000..764fbcad18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/recip_sqrt_mult_5.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-recip" } */ +/* { dg-additional-options "-fcompare-debug" { target { ! powerpc-ibm-aix* } } } */ + +/* We want to do the recip_sqrt transformations here there is already + a multiplication on the main path. */ + +double res, res2, tmp; +void +foo (double a, double b, int c, int d) +{ + tmp = 1.0 / __builtin_sqrt (a); + res = tmp * tmp; + + if (d) + res2 = a * tmp; +} + +/* { dg-final { scan-tree-dump "Optimizing reciprocal sqrt multiplications" "recip" } } */ +/* { dg-final { scan-tree-dump "Replacing squaring multiplication" "recip" } } */ +/* { dg-final { scan-tree-dump "Replacing original division" "recip" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/reciprocal-math-1.c b/SingleSource/Regression/C/gcc-dg/reciprocal-math-1.c new file mode 100644 index 0000000000..49173e2316 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/reciprocal-math-1.c @@ -0,0 +1,17 @@ +/* Test __RECIPROCAL_MATH__ is defined with -freciprocal-math. */ +/* { dg-do compile } */ +/* { dg-options "-freciprocal-math" } */ + +#ifndef __RECIPROCAL_MATH__ +#error "__RECIPROCAL_MATH__ not defined" +#endif + +#pragma GCC optimize "-fno-reciprocal-math" +#ifdef __RECIPROCAL_MATH__ +#error "__RECIPROCAL_MATH__ defined" +#endif + +#pragma GCC optimize "-freciprocal-math" +#ifndef __RECIPROCAL_MATH__ +#error "__RECIPROCAL_MATH__ not defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/reciprocal-math-2.c b/SingleSource/Regression/C/gcc-dg/reciprocal-math-2.c new file mode 100644 index 0000000000..959baa794b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/reciprocal-math-2.c @@ -0,0 +1,17 @@ +/* Test __RECIPROCAL_MATH__ is not defined with -fno-reciprocal-math. */ +/* { dg-do compile } */ +/* { dg-options "-fno-reciprocal-math" } */ + +#ifdef __RECIPROCAL_MATH__ +#error "__RECIPROCAL_MATH__ defined" +#endif + +#pragma GCC optimize "-freciprocal-math" +#ifndef __RECIPROCAL_MATH__ +#error "__RECIPROCAL_MATH__ not defined" +#endif + +#pragma GCC optimize "-fno-reciprocal-math" +#ifdef __RECIPROCAL_MATH__ +#error "__RECIPROCAL_MATH__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/redecl-1.c b/SingleSource/Regression/C/gcc-dg/redecl-1.c new file mode 100644 index 0000000000..a7ae0bd504 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-1.c @@ -0,0 +1,103 @@ +/* Test for various situations where a new declaration of an + identifier conflicts with an earlier declaration which isn't in the + same scope. These are all undefined behavior per C89 sections + 6.1.2.2p7, 6.1.2.6p2, and 6.3.2.2p2/footnote 38 (C99 6.2.2p7 and + 6.2.7p2 - implicit declarations are invalid in C99). */ + +/* { dg-do compile } */ +/* { dg-options "-std=c89 -pedantic -Wall -Wno-unused" } */ + +/* Extern at function scope, clashing with extern at file scope */ + +extern int foo1; /* { dg-message "note: previous" } */ +extern int bar1(int); /* { dg-message "note: previous" } */ + +void test1(void) +{ + extern double foo1; /* { dg-error "conflict" } */ + extern double bar1(double); /* { dg-error "conflict" } */ +} + +/* Extern at file scope, clashing with extern at function scope */ + +void test2(void) +{ + extern double foo2; /* { dg-message "note: previous" } */ + extern double bar2(double); /* { dg-message "note: previous" } */ +} + +extern int foo2; /* { dg-error "conflict" } */ +extern int bar2(int); /* { dg-error "conflict" } */ + +/* Extern at function scope, clashing with extern at earlier function + scope. Also, don't be fooled by a typedef at file scope. */ + +typedef float baz3; /* { dg-bogus } */ + +void prime3(void) +{ + extern int foo3; /* { dg-message "note: previous" } */ + extern int bar3(int); /* { dg-message "note: previous" } */ + extern int baz3; /* { dg-message "note: previous" } */ +} + +void test3(void) +{ + extern double foo3; /* { dg-error "conflict" } */ + extern double bar3(double); /* { dg-error "conflict" } */ + extern double baz3; /* { dg-error "conflict" } */ +} + +/* Extern at function scope, clashing with previous implicit decl. */ + +void prime4(void) +{ + bar4(); /* { dg-line implicit_bar4 } */ + /* { dg-warning "implicit declaration of function" "implicit" { target *-*-* } implicit_bar4 } */ +} + +void test4(void) +{ + extern double bar4(double); /* { dg-error "conflict" } */ +/* { dg-message "note: previous implicit declaration" "previous" { target *-*-* } implicit_bar4 } */ +} + +/* Implicit decl, clashing with extern at previous function scope. */ + +void prime5(void) +{ + extern double bar5(double); /* { dg-message "note: previous declaration" "previous 1" } */ +} /* { dg-message "note: previous implicit declaration" "previous 2" { target *-*-* } .-1 } */ + +void test5(void) +{ + bar5(1); /* { dg-warning "implicit declaration of function" } */ +} /* { dg-error "incompatible implicit declaration" "" { target *-*-* } .-1 } */ + +/* Extern then static, both at file scope. */ + +extern int test6(int); /* { dg-message "note: previous" } */ +static int test6(int x) /* { dg-error "follows non-static" } */ +{ return x; } + + +/* Extern then static, extern at previous function scope. */ + +void prime7(void) +{ + extern int test7(int); /* { dg-message "note: previous" } */ +} + +static int test7(int x) /* { dg-error "follows non-static" } */ +{ return x; } + +/* Implicit decl then static. */ + +void prime8(void) +{ + test8(); /* { dg-message "note: previous" } */ + /* { dg-warning "implicit" "implicit" { target *-*-* } .-1 } */ +} + +static int test8(int x) /* { dg-error "follows non-static" } */ +{ return x; } diff --git a/SingleSource/Regression/C/gcc-dg/redecl-10.c b/SingleSource/Regression/C/gcc-dg/redecl-10.c new file mode 100644 index 0000000000..0864311f64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-10.c @@ -0,0 +1,34 @@ +/* Test for multiple declarations and composite types. Check we don't + ICE with nested initializers. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +static int w[]; /* { dg-warning "array 'w' assumed to have one element" } */ +void +f (void) +{ + extern int w[] = { 1, 2 }; /* { dg-error "has both" } */ +} + +int x[]; /* { dg-warning "array 'x' assumed to have one element" } */ +void +g (void) +{ + extern int x[] = { 3, 4, 5 }; /* { dg-error "has both" } */ +} + +static int y[]; /* { dg-warning "array 'y' assumed to have one element" } */ +void +h (void) +{ + extern int y[] = { 6 }; /* { dg-error "has both" } */ +} + +int z[]; /* { dg-warning "array 'z' assumed to have one element" } */ +void +i (void) +{ + extern int z[] = { 7 }; /* { dg-error "has both" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-11.c b/SingleSource/Regression/C/gcc-dg/redecl-11.c new file mode 100644 index 0000000000..3c6f64fca5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-11.c @@ -0,0 +1,9 @@ +/* Some incompatible external linkage declarations were not diagnosed. + Bug 21342. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int f(int (*)[]); +void g() { int f(int (*)[2]); } /* { dg-message "note: previous declaration of 'f'" "note" } */ +int f(int (*)[3]); /* { dg-error "conflicting types for 'f'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/redecl-12.c b/SingleSource/Regression/C/gcc-dg/redecl-12.c new file mode 100644 index 0000000000..9922cf49fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-12.c @@ -0,0 +1,9 @@ +/* Some incompatible external linkage declarations were not diagnosed. + Bug 21342. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern int a[]; +void f(void) { extern int a[]; extern int a[10]; } /* { dg-message "note: previous declaration of 'a'" "note" } */ +extern int a[5]; /* { dg-error "conflicting types for 'a'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/redecl-13.c b/SingleSource/Regression/C/gcc-dg/redecl-13.c new file mode 100644 index 0000000000..556a3cd69b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-13.c @@ -0,0 +1,9 @@ +/* Some incompatible external linkage declarations were not diagnosed. + Bug 21342. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern int a[]; +void f(void) { extern int a[10]; } /* { dg-message "note: previous declaration of 'a'" "note" } */ +extern int a[5]; /* { dg-error "conflicting types for 'a'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/redecl-14.c b/SingleSource/Regression/C/gcc-dg/redecl-14.c new file mode 100644 index 0000000000..1bf1d96ead --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-14.c @@ -0,0 +1,22 @@ +/* Some incompatible external linkage declarations were not diagnosed. + Bug 21342. Test type in inner scope is correct. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int IA[]; +typedef int IA5[5]; +typedef IA *IAP; +typedef IA5 *IA5P; +extern IAP a[]; +void +f (void) +{ + { + extern IA5P a[]; + sizeof (*a[0]); + } + extern IAP a[]; + extern IAP a[5]; + sizeof (*a[0]); /* { dg-error "invalid application of 'sizeof' to incomplete type 'IA' {aka 'int\\\[\\\]'}" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-15.c b/SingleSource/Regression/C/gcc-dg/redecl-15.c new file mode 100644 index 0000000000..06d6523eea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-15.c @@ -0,0 +1,14 @@ +/* Test for ICE with redeclaration in inner scope which is accepted + despite incompatible type. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +void +f (void) +{ + g(); /* { dg-message "note: previous implicit declaration of 'g'" } */ + { + void g(); /* { dg-warning "conflicting types for 'g'" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-16.c b/SingleSource/Regression/C/gcc-dg/redecl-16.c new file mode 100644 index 0000000000..560b373fb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-16.c @@ -0,0 +1,18 @@ +/* PR 21502 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int IA[]; +typedef int IA5[5]; +typedef int IA10[10]; +typedef IA *IAP; +typedef IA5 *IA5P; +typedef IA10 *IA10P; +extern IAP a[]; +void +f (void) +{ + extern IA5P a[]; +} +IAP a[] = { 0 }; /* { dg-message "note: previous definition" } */ +extern IA10P a[]; /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/redecl-17.c b/SingleSource/Regression/C/gcc-dg/redecl-17.c new file mode 100644 index 0000000000..686ebc5897 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-17.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +void (*fp)(const int i); +void (*fp)(int i); + +void foo() +{ + (*fp)(0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/redecl-18.c b/SingleSource/Regression/C/gcc-dg/redecl-18.c new file mode 100644 index 0000000000..f96bbe750f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-18.c @@ -0,0 +1,17 @@ +/* Test redeclaration in an inner scope, with an incomplete type, of a + file-scope initialized array shadowed in an intermediate scope (bug + 88584). */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int a[1] = { 0 }; + +void +f (void) +{ + int a; + { + extern int a[]; + sizeof (a); /* { dg-error "incomplete" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-19.c b/SingleSource/Regression/C/gcc-dg/redecl-19.c new file mode 100644 index 0000000000..cc10685448 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-19.c @@ -0,0 +1,5 @@ +/* We used to ICE in the gimplifier, PR 106764 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +(*a)(); // { dg-note "" } +b(){a()} a; // { dg-error "" } diff --git a/SingleSource/Regression/C/gcc-dg/redecl-2.c b/SingleSource/Regression/C/gcc-dg/redecl-2.c new file mode 100644 index 0000000000..fa0d5e4478 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-2.c @@ -0,0 +1,68 @@ +/* Test for multiple declarations of an identifier at same block + scope: only valid case is all extern. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +fa0 (void) +{ + int a0; /* { dg-message "note: previous declaration" } */ + int a0; /* { dg-error "redeclaration" } */ +} + +void +fa1 (void) +{ + int a1; /* { dg-message "note: previous declaration" } */ + static int a1; /* { dg-error "redeclaration" } */ +} + +void +fa2 (void) +{ + int a2; /* { dg-message "note: previous declaration" } */ + extern int a2; /* { dg-error "follows declaration with no linkage" } */ +} + +void +fa3 (void) +{ + static int a3; /* { dg-message "note: previous declaration" } */ + int a3; /* { dg-error "redeclaration" } */ +} + +void +fa4 (void) +{ + static int a4; /* { dg-message "note: previous declaration" } */ + static int a4; /* { dg-error "redeclaration" } */ +} + +void +fa5 (void) +{ + static int a5; /* { dg-message "note: previous declaration" } */ + extern int a5; /* { dg-error "follows declaration with no linkage" } */ +} + +void +fa6 (void) +{ + extern int a6; /* { dg-message "note: previous declaration" } */ + int a6; /* { dg-error "follows extern declaration" } */ +} + +void +fa7 (void) +{ + extern int a7; /* { dg-message "note: previous declaration" } */ + static int a7; /* { dg-error "follows extern declaration" } */ +} + +void +fa8 (void) +{ + extern int a8; + extern int a8; +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-20.c b/SingleSource/Regression/C/gcc-dg/redecl-20.c new file mode 100644 index 0000000000..07f52115ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-20.c @@ -0,0 +1,9 @@ +/* We used to ICE in the gimplifier, PR 107307 */ +// { dg-do compile } +// { dg-options "-w" } +void f () +{ + const struct { int a[1]; } b; // { dg-note "" } + int *c = b.a; + int *b; // { dg-error "" } +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-21.c b/SingleSource/Regression/C/gcc-dg/redecl-21.c new file mode 100644 index 0000000000..2f2a6548a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-21.c @@ -0,0 +1,9 @@ +/* We used to ICE in the gimplifier, PR 106765 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +struct a { + int b +} c() { + struct a a; // { dg-note "" } + a.b; + d a; // { dg-error "" } diff --git a/SingleSource/Regression/C/gcc-dg/redecl-22.c b/SingleSource/Regression/C/gcc-dg/redecl-22.c new file mode 100644 index 0000000000..7758570fab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-22.c @@ -0,0 +1,9 @@ +/* We used to ICE in the gimplifier, PR 107705 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +int f (void) +{ + int (*p) (void) = 0; // { dg-note "" } + return p (); + int p = 1; // { dg-error "" } +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-23.c b/SingleSource/Regression/C/gcc-dg/redecl-23.c new file mode 100644 index 0000000000..425721df2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-23.c @@ -0,0 +1,6 @@ +/* We used to ICE in the gimplifier, PR 106560. */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a; /* { dg-note "" } */ +void b() { void **c = a; } +a; /* { dg-error "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/redecl-24.c b/SingleSource/Regression/C/gcc-dg/redecl-24.c new file mode 100644 index 0000000000..f0f7a723ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-24.c @@ -0,0 +1,6 @@ +/* We used to ICE in the gimplifier, PR 106560 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a, **b; /* { dg-note "" } */ +c(){b = a;} +a = /* { dg-error "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/redecl-25.c b/SingleSource/Regression/C/gcc-dg/redecl-25.c new file mode 100644 index 0000000000..4232e19d9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-25.c @@ -0,0 +1,9 @@ +/* We used to ICE in the gimplifier, PR 106560 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a; /* { dg-note "" } */ +void b() { + void **c; + c = a /* { dg-error "" } */ +} +a; /* { dg-error "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/redecl-3.c b/SingleSource/Regression/C/gcc-dg/redecl-3.c new file mode 100644 index 0000000000..3181712f0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-3.c @@ -0,0 +1,1180 @@ +/* Test for multiple declarations and composite types. Includes bug + 13801. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +typedef int IA[]; +typedef int A10[10]; + +/* Test all combinations of: a variable declared at file scope (no + type specifiers, or extern, or static), or just inside a function + (with extern), redeclared in an inner scope (with extern), and + redeclared in an inner scope when the previous declaration is + hidden (with extern, and not if the original declaration was + static). Test three times: incomplete variable types; pointers to + incomplete types; functions returning such pointers. */ + +IA a0; +void +f0 (void) +{ + sizeof(a0); /* { dg-error "incomplete" } */ + { + extern IA a0; + sizeof(a0); /* { dg-error "incomplete" } */ + { + int a0; + { + extern IA a0; + sizeof(a0); /* { dg-error "incomplete" } */ + } + } + sizeof(a0); /* { dg-error "incomplete" } */ + } + sizeof(a0); /* { dg-error "incomplete" } */ +} +extern A10 a0; + +IA a1; +void +f1 (void) +{ + sizeof(a1); /* { dg-error "incomplete" } */ + { + extern IA a1; + sizeof(a1); /* { dg-error "incomplete" } */ + { + int a1; + { + extern A10 a1; + sizeof(a1); + } + } + sizeof(a1); /* { dg-error "incomplete" } */ + } + sizeof(a1); /* { dg-error "incomplete" } */ +} +extern A10 a1; + +IA a2; +void +f2 (void) +{ + sizeof(a2); /* { dg-error "incomplete" } */ + { + extern A10 a2; + sizeof(a2); + { + int a2; + { + extern IA a2; + sizeof(a2); /* { dg-error "incomplete" } */ + } + } + sizeof(a2); + } + sizeof(a2); /* { dg-error "incomplete" } */ +} +extern A10 a2; + +IA a3; +void +f3 (void) +{ + sizeof(a3); /* { dg-error "incomplete" } */ + { + extern A10 a3; + sizeof(a3); + { + int a3; + { + extern A10 a3; + sizeof(a3); + } + } + sizeof(a3); + } + sizeof(a3); /* { dg-error "incomplete" } */ +} +extern A10 a3; + +A10 a4; +void +f4 (void) +{ + sizeof(a4); + { + extern IA a4; + sizeof(a4); + { + int a4; + { + extern IA a4; + sizeof(a4); /* { dg-error "incomplete" } */ + } + } + sizeof(a4); + } + sizeof(a4); +} +extern A10 a4; + +A10 a5; +void +f5 (void) +{ + sizeof(a5); + { + extern IA a5; + sizeof(a5); + { + int a5; + { + extern A10 a5; + sizeof(a5); + } + } + sizeof(a5); + } + sizeof(a5); +} +extern A10 a5; + +A10 a6; +void +f6 (void) +{ + sizeof(a6); + { + extern A10 a6; + sizeof(a6); + { + int a6; + { + extern IA a6; + sizeof(a6); /* { dg-error "incomplete" } */ + } + } + sizeof(a6); + } + sizeof(a6); +} +extern A10 a6; + +A10 a7; +void +f7 (void) +{ + sizeof(a7); + { + extern A10 a7; + sizeof(a7); + { + int a7; + { + extern A10 a7; + sizeof(a7); + } + } + sizeof(a7); + } + sizeof(a7); +} +extern A10 a7; + +extern IA a8; +void +f8 (void) +{ + sizeof(a8); /* { dg-error "incomplete" } */ + { + extern IA a8; + sizeof(a8); /* { dg-error "incomplete" } */ + { + int a8; + { + extern IA a8; + sizeof(a8); /* { dg-error "incomplete" } */ + } + } + sizeof(a8); /* { dg-error "incomplete" } */ + } + sizeof(a8); /* { dg-error "incomplete" } */ +} +extern A10 a8; + +extern IA a9; +void +f9 (void) +{ + sizeof(a9); /* { dg-error "incomplete" } */ + { + extern IA a9; + sizeof(a9); /* { dg-error "incomplete" } */ + { + int a9; + { + extern A10 a9; + sizeof(a9); + } + } + sizeof(a9); /* { dg-error "incomplete" } */ + } + sizeof(a9); /* { dg-error "incomplete" } */ +} +extern A10 a9; + +extern IA a10; +void +f10 (void) +{ + sizeof(a10); /* { dg-error "incomplete" } */ + { + extern A10 a10; + sizeof(a10); + { + int a10; + { + extern IA a10; + sizeof(a10); /* { dg-error "incomplete" } */ + } + } + sizeof(a10); + } + sizeof(a10); /* { dg-error "incomplete" } */ +} +extern A10 a10; + +extern IA a11; +void +f11 (void) +{ + sizeof(a11); /* { dg-error "incomplete" } */ + { + extern A10 a11; + sizeof(a11); + { + int a11; + { + extern A10 a11; + sizeof(a11); + } + } + sizeof(a11); + } + sizeof(a11); /* { dg-error "incomplete" } */ +} +extern A10 a11; + +extern A10 a12; +void +f12 (void) +{ + sizeof(a12); + { + extern IA a12; + sizeof(a12); + { + int a12; + { + extern IA a12; + sizeof(a12); /* { dg-error "incomplete" } */ + } + } + sizeof(a12); + } + sizeof(a12); +} +extern A10 a12; + +extern A10 a13; +void +f13 (void) +{ + sizeof(a13); + { + extern IA a13; + sizeof(a13); + { + int a13; + { + extern A10 a13; + sizeof(a13); + } + } + sizeof(a13); + } + sizeof(a13); +} +extern A10 a13; + +extern A10 a14; +void +f14 (void) +{ + sizeof(a14); + { + extern A10 a14; + sizeof(a14); + { + int a14; + { + extern IA a14; + sizeof(a14); /* { dg-error "incomplete" } */ + } + } + sizeof(a14); + } + sizeof(a14); +} +extern A10 a14; + +extern A10 a15; +void +f15 (void) +{ + sizeof(a15); + { + extern A10 a15; + sizeof(a15); + { + int a15; + { + extern A10 a15; + sizeof(a15); + } + } + sizeof(a15); + } + sizeof(a15); +} +extern A10 a15; + +static IA a16; +void +f16 (void) +{ + sizeof(a16); /* { dg-error "incomplete" } */ + { + extern IA a16; + sizeof(a16); /* { dg-error "incomplete" } */ + } + sizeof(a16); /* { dg-error "incomplete" } */ +} +extern A10 a16; + +static IA a17; +void +f17 (void) +{ + sizeof(a17); /* { dg-error "incomplete" } */ + { + extern A10 a17; + sizeof(a17); + } + sizeof(a17); /* { dg-error "incomplete" } */ +} +extern A10 a17; + +static A10 a18; +void +f18 (void) +{ + sizeof(a18); + { + extern IA a18; + sizeof(a18); + } + sizeof(a18); +} +extern A10 a18; + +static A10 a19; +void +f19 (void) +{ + sizeof(a19); + { + extern A10 a19; + sizeof(a19); + } + sizeof(a19); +} +extern A10 a19; + +IA *b0; +void +g0 (void) +{ + sizeof(*b0); /* { dg-error "incomplete" } */ + { + extern IA *b0; + sizeof(*b0); /* { dg-error "incomplete" } */ + { + int b0; + { + extern IA *b0; + sizeof(*b0); /* { dg-error "incomplete" } */ + } + } + sizeof(*b0); /* { dg-error "incomplete" } */ + } + sizeof(*b0); /* { dg-error "incomplete" } */ +} +extern A10 *b0; + +IA *b1; +void +g1 (void) +{ + sizeof(*b1); /* { dg-error "incomplete" } */ + { + extern IA *b1; + sizeof(*b1); /* { dg-error "incomplete" } */ + { + int b1; + { + extern A10 *b1; + sizeof(*b1); + } + } + sizeof(*b1); /* { dg-error "incomplete" } */ + } + sizeof(*b1); /* { dg-error "incomplete" } */ +} +extern A10 *b1; + +IA *b2; +void +g2 (void) +{ + sizeof(*b2); /* { dg-error "incomplete" } */ + { + extern A10 *b2; + sizeof(*b2); + { + int b2; + { + extern IA *b2; + sizeof(*b2); /* { dg-error "incomplete" } */ + } + } + sizeof(*b2); + } + sizeof(*b2); /* { dg-error "incomplete" } */ +} +extern A10 *b2; + +IA *b3; +void +g3 (void) +{ + sizeof(*b3); /* { dg-error "incomplete" } */ + { + extern A10 *b3; + sizeof(*b3); + { + int b3; + { + extern A10 *b3; + sizeof(*b3); + } + } + sizeof(*b3); + } + sizeof(*b3); /* { dg-error "incomplete" } */ +} +extern A10 *b3; + +A10 *b4; +void +g4 (void) +{ + sizeof(*b4); + { + extern IA *b4; + sizeof(*b4); + { + int b4; + { + extern IA *b4; + sizeof(*b4); /* { dg-error "incomplete" } */ + } + } + sizeof(*b4); + } + sizeof(*b4); +} +extern A10 *b4; + +A10 *b5; +void +g5 (void) +{ + sizeof(*b5); + { + extern IA *b5; + sizeof(*b5); + { + int b5; + { + extern A10 *b5; + sizeof(*b5); + } + } + sizeof(*b5); + } + sizeof(*b5); +} +extern A10 *b5; + +A10 *b6; +void +g6 (void) +{ + sizeof(*b6); + { + extern A10 *b6; + sizeof(*b6); + { + int b6; + { + extern IA *b6; + sizeof(*b6); /* { dg-error "incomplete" } */ + } + } + sizeof(*b6); + } + sizeof(*b6); +} +extern A10 *b6; + +A10 *b7; +void +g7 (void) +{ + sizeof(*b7); + { + extern A10 *b7; + sizeof(*b7); + { + int b7; + { + extern A10 *b7; + sizeof(*b7); + } + } + sizeof(*b7); + } + sizeof(*b7); +} +extern A10 *b7; + +extern IA *b8; +void +g8 (void) +{ + sizeof(*b8); /* { dg-error "incomplete" } */ + { + extern IA *b8; + sizeof(*b8); /* { dg-error "incomplete" } */ + { + int b8; + { + extern IA *b8; + sizeof(*b8); /* { dg-error "incomplete" } */ + } + } + sizeof(*b8); /* { dg-error "incomplete" } */ + } + sizeof(*b8); /* { dg-error "incomplete" } */ +} +extern A10 *b8; + +extern IA *b9; +void +g9 (void) +{ + sizeof(*b9); /* { dg-error "incomplete" } */ + { + extern IA *b9; + sizeof(*b9); /* { dg-error "incomplete" } */ + { + int b9; + { + extern A10 *b9; + sizeof(*b9); + } + } + sizeof(*b9); /* { dg-error "incomplete" } */ + } + sizeof(*b9); /* { dg-error "incomplete" } */ +} +extern A10 *b9; + +extern IA *b10; +void +g10 (void) +{ + sizeof(*b10); /* { dg-error "incomplete" } */ + { + extern A10 *b10; + sizeof(*b10); + { + int b10; + { + extern IA *b10; + sizeof(*b10); /* { dg-error "incomplete" } */ + } + } + sizeof(*b10); + } + sizeof(*b10); /* { dg-error "incomplete" } */ +} +extern A10 *b10; + +extern IA *b11; +void +g11 (void) +{ + sizeof(*b11); /* { dg-error "incomplete" } */ + { + extern A10 *b11; + sizeof(*b11); + { + int b11; + { + extern A10 *b11; + sizeof(*b11); + } + } + sizeof(*b11); + } + sizeof(*b11); /* { dg-error "incomplete" } */ +} +extern A10 *b11; + +extern A10 *b12; +void +g12 (void) +{ + sizeof(*b12); + { + extern IA *b12; + sizeof(*b12); + { + int b12; + { + extern IA *b12; + sizeof(*b12); /* { dg-error "incomplete" } */ + } + } + sizeof(*b12); + } + sizeof(*b12); +} +extern A10 *b12; + +extern A10 *b13; +void +g13 (void) +{ + sizeof(*b13); + { + extern IA *b13; + sizeof(*b13); + { + int b13; + { + extern A10 *b13; + sizeof(*b13); + } + } + sizeof(*b13); + } + sizeof(*b13); +} +extern A10 *b13; + +extern A10 *b14; +void +g14 (void) +{ + sizeof(*b14); + { + extern A10 *b14; + sizeof(*b14); + { + int b14; + { + extern IA *b14; + sizeof(*b14); /* { dg-error "incomplete" } */ + } + } + sizeof(*b14); + } + sizeof(*b14); +} +extern A10 *b14; + +extern A10 *b15; +void +g15 (void) +{ + sizeof(*b15); + { + extern A10 *b15; + sizeof(*b15); + { + int b15; + { + extern A10 *b15; + sizeof(*b15); + } + } + sizeof(*b15); + } + sizeof(*b15); +} +extern A10 *b15; + +static IA *b16; +void +g16 (void) +{ + sizeof(*b16); /* { dg-error "incomplete" } */ + { + extern IA *b16; + sizeof(*b16); /* { dg-error "incomplete" } */ + } + sizeof(*b16); /* { dg-error "incomplete" } */ +} +extern A10 *b16; + +static IA *b17; +void +g17 (void) +{ + sizeof(*b17); /* { dg-error "incomplete" } */ + { + extern A10 *b17; + sizeof(*b17); + } + sizeof(*b17); /* { dg-error "incomplete" } */ +} +extern A10 *b17; + +static A10 *b18; +void +g18 (void) +{ + sizeof(*b18); + { + extern IA *b18; + sizeof(*b18); + } + sizeof(*b18); +} +extern A10 *b18; + +static A10 *b19; +void +g19 (void) +{ + sizeof(*b19); + { + extern A10 *b19; + sizeof(*b19); + } + sizeof(*b19); +} +extern A10 *b19; + +IA *c0 (void); +void +h0 (void) +{ + sizeof(*c0()); /* { dg-error "incomplete" } */ + { + extern IA *c0 (void); + sizeof(*c0()); /* { dg-error "incomplete" } */ + { + int c0; + { + extern IA *c0 (void); + sizeof(*c0()); /* { dg-error "incomplete" } */ + } + } + sizeof(*c0()); /* { dg-error "incomplete" } */ + } + sizeof(*c0()); /* { dg-error "incomplete" } */ +} +A10 *c0 (void) { return 0; } + +IA *c1 (void); +void +h1 (void) +{ + sizeof(*c1()); /* { dg-error "incomplete" } */ + { + extern IA *c1 (void); + sizeof(*c1()); /* { dg-error "incomplete" } */ + { + int c1; + { + extern A10 *c1 (void); + sizeof(*c1()); + } + } + sizeof(*c1()); /* { dg-error "incomplete" } */ + } + sizeof(*c1()); /* { dg-error "incomplete" } */ +} +A10 *c1 (void) { return 0; } + +IA *c2 (void); +void +h2 (void) +{ + sizeof(*c2()); /* { dg-error "incomplete" } */ + { + extern A10 *c2 (void); + sizeof(*c2()); + { + int c2; + { + extern IA *c2 (void); + sizeof(*c2()); /* { dg-error "incomplete" } */ + } + } + sizeof(*c2()); + } + sizeof(*c2()); /* { dg-error "incomplete" } */ +} +A10 *c2 (void) { return 0; } + +IA *c3 (void); +void +h3 (void) +{ + sizeof(*c3()); /* { dg-error "incomplete" } */ + { + extern A10 *c3 (void); + sizeof(*c3()); + { + int c3; + { + extern A10 *c3 (void); + sizeof(*c3()); + } + } + sizeof(*c3()); + } + sizeof(*c3()); /* { dg-error "incomplete" } */ +} +A10 *c3 (void) { return 0; } + +A10 *c4 (void); +void +h4 (void) +{ + sizeof(*c4()); + { + extern IA *c4 (void); + sizeof(*c4()); + { + int c4; + { + extern IA *c4 (void); + sizeof(*c4()); /* { dg-error "incomplete" } */ + } + } + sizeof(*c4()); + } + sizeof(*c4()); +} +A10 *c4 (void) { return 0; } + +A10 *c5 (void); +void +h5 (void) +{ + sizeof(*c5()); + { + extern IA *c5 (void); + sizeof(*c5()); + { + int c5; + { + extern A10 *c5 (void); + sizeof(*c5()); + } + } + sizeof(*c5()); + } + sizeof(*c5()); +} +A10 *c5 (void) { return 0; } + +A10 *c6 (void); +void +h6 (void) +{ + sizeof(*c6()); + { + extern A10 *c6 (void); + sizeof(*c6()); + { + int c6; + { + extern IA *c6 (void); + sizeof(*c6()); /* { dg-error "incomplete" } */ + } + } + sizeof(*c6()); + } + sizeof(*c6()); +} +A10 *c6 (void) { return 0; } + +A10 *c7 (void); +void +h7 (void) +{ + sizeof(*c7()); + { + extern A10 *c7 (void); + sizeof(*c7()); + { + int c7; + { + extern A10 *c7 (void); + sizeof(*c7()); + } + } + sizeof(*c7()); + } + sizeof(*c7()); +} +A10 *c7 (void) { return 0; } + +extern IA *c8 (void); +void +h8 (void) +{ + sizeof(*c8()); /* { dg-error "incomplete" } */ + { + extern IA *c8 (void); + sizeof(*c8()); /* { dg-error "incomplete" } */ + { + int c8; + { + extern IA *c8 (void); + sizeof(*c8()); /* { dg-error "incomplete" } */ + } + } + sizeof(*c8()); /* { dg-error "incomplete" } */ + } + sizeof(*c8()); /* { dg-error "incomplete" } */ +} +extern A10 *c8 (void) { return 0; } + +extern IA *c9 (void); +void +h9 (void) +{ + sizeof(*c9()); /* { dg-error "incomplete" } */ + { + extern IA *c9 (void); + sizeof(*c9()); /* { dg-error "incomplete" } */ + { + int c9; + { + extern A10 *c9 (void); + sizeof(*c9()); + } + } + sizeof(*c9()); /* { dg-error "incomplete" } */ + } + sizeof(*c9()); /* { dg-error "incomplete" } */ +} +extern A10 *c9 (void) { return 0; } + +extern IA *c10 (void); +void +h10 (void) +{ + sizeof(*c10()); /* { dg-error "incomplete" } */ + { + extern A10 *c10 (void); + sizeof(*c10()); + { + int c10; + { + extern IA *c10 (void); + sizeof(*c10()); /* { dg-error "incomplete" } */ + } + } + sizeof(*c10()); + } + sizeof(*c10()); /* { dg-error "incomplete" } */ +} +extern A10 *c10 (void) { return 0; } + +extern IA *c11 (void); +void +h11 (void) +{ + sizeof(*c11()); /* { dg-error "incomplete" } */ + { + extern A10 *c11 (void); + sizeof(*c11()); + { + int c11; + { + extern A10 *c11 (void); + sizeof(*c11()); + } + } + sizeof(*c11()); + } + sizeof(*c11()); /* { dg-error "incomplete" } */ +} +extern A10 *c11 (void) { return 0; } + +extern A10 *c12 (void); +void +h12 (void) +{ + sizeof(*c12()); + { + extern IA *c12 (void); + sizeof(*c12()); + { + int c12; + { + extern IA *c12 (void); + sizeof(*c12()); /* { dg-error "incomplete" } */ + } + } + sizeof(*c12()); + } + sizeof(*c12()); +} +extern A10 *c12 (void) { return 0; } + +extern A10 *c13 (void); +void +h13 (void) +{ + sizeof(*c13()); + { + extern IA *c13 (void); + sizeof(*c13()); + { + int c13; + { + extern A10 *c13 (void); + sizeof(*c13()); + } + } + sizeof(*c13()); + } + sizeof(*c13()); +} +extern A10 *c13 (void) { return 0; } + +extern A10 *c14 (void); +void +h14 (void) +{ + sizeof(*c14()); + { + extern A10 *c14 (void); + sizeof(*c14()); + { + int c14; + { + extern IA *c14 (void); + sizeof(*c14()); /* { dg-error "incomplete" } */ + } + } + sizeof(*c14()); + } + sizeof(*c14()); +} +extern A10 *c14 (void) { return 0; } + +extern A10 *c15 (void); +void +h15 (void) +{ + sizeof(*c15()); + { + extern A10 *c15 (void); + sizeof(*c15()); + { + int c15; + { + extern A10 *c15 (void); + sizeof(*c15()); + } + } + sizeof(*c15()); + } + sizeof(*c15()); +} +extern A10 *c15 (void) { return 0; } + +static IA *c16 (void); +void +h16 (void) +{ + sizeof(*c16()); /* { dg-error "incomplete" } */ + { + extern IA *c16 (void); + sizeof(*c16()); /* { dg-error "incomplete" } */ + } + sizeof(*c16()); /* { dg-error "incomplete" } */ +} +static A10 *c16 (void) { return 0; } + +static IA *c17 (void); +void +h17 (void) +{ + sizeof(*c17()); /* { dg-error "incomplete" } */ + { + extern A10 *c17 (void); + sizeof(*c17()); + } + sizeof(*c17()); /* { dg-error "incomplete" } */ +} +static A10 *c17 (void) { return 0; } + +static A10 *c18 (void); +void +h18 (void) +{ + sizeof(*c18()); + { + extern IA *c18 (void); + sizeof(*c18()); + } + sizeof(*c18()); +} +static A10 *c18 (void) { return 0; } + +static A10 *c19 (void); +void +h19 (void) +{ + sizeof(*c19()); + { + extern A10 *c19 (void); + sizeof(*c19()); + } + sizeof(*c19()); +} +static A10 *c19 (void) { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/redecl-4.c b/SingleSource/Regression/C/gcc-dg/redecl-4.c new file mode 100644 index 0000000000..2c214bb02c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-4.c @@ -0,0 +1,32 @@ +/* Test for multiple declarations and composite types, with built-in + functions. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -Wformat -g" } */ + +void +f (void) +{ + int printf; + int strcmp; + { + int printf (const char *, ...); + int strcmp (); + /* Should get format warnings even though the built-in declaration + isn't "visible". */ + printf ( + "%s", 1); /* { dg-warning "15:format" } */ + /* The type of strcmp here should have no prototype. */ + if (0) + strcmp (1); + /* Likewise, implicitly declared memcmp. */ + if (0) + memcmp (1); + } +} + +/* Should still diagnose incompatible prototype for strcmp. */ +int strcmp (void); /* { dg-error "conflict" } */ + +/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" } + { dg-prune-output "\\\[-Wint-conversion]" } */ diff --git a/SingleSource/Regression/C/gcc-dg/redecl-5.c b/SingleSource/Regression/C/gcc-dg/redecl-5.c new file mode 100644 index 0000000000..15b1f8c8ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-5.c @@ -0,0 +1,19 @@ +/* Test for multiple declarations and composite types. Diagnosis of + incompatible implicit declaration. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c89" } */ + +void +f (void) +{ + long z(); /* { dg-message "note: previous implicit declaration" } */ +} + +void +g (void) +{ + z(); /* { dg-error "incompatible" } */ + labs(1); /* { dg-warning "incompatible" } */ + printf("x"); /* { dg-warning "incompatible" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-6.c b/SingleSource/Regression/C/gcc-dg/redecl-6.c new file mode 100644 index 0000000000..164ec974d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-6.c @@ -0,0 +1,24 @@ +/* Test for multiple declarations and composite types. As in bug + 13801. Illustrates how bug causes correct code to be wrongly + diagnosed. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +typedef int IA[]; +typedef int A5[5]; +typedef int A10[10]; + +A10 array10; + +A5 *ap; +void +f (void) +{ + int ap; + { + extern IA *ap; + /* This assignment is valid. */ + ap = &array10; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-7.c b/SingleSource/Regression/C/gcc-dg/redecl-7.c new file mode 100644 index 0000000000..6168562ca5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-7.c @@ -0,0 +1,23 @@ +/* Test for multiple declarations and composite types. Diagnosis of + completion incompatible with implicit initializer. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +int x[]; + +void +f (void) +{ + extern int x[2]; /* { dg-error "completed incompatibly" } */ +} + +/* The following is OK. */ + +int y[]; +void +g (void) +{ + extern int y[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-8.c b/SingleSource/Regression/C/gcc-dg/redecl-8.c new file mode 100644 index 0000000000..9145b9fddb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-8.c @@ -0,0 +1,23 @@ +/* Test for multiple declarations and composite types. Diagnosis of + completion incompatible with implicit initializer. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +static int x[]; + +void +f (void) +{ + extern int x[2]; /* { dg-error "completed incompatibly" } */ +} + +/* The following is OK. */ + +static int y[]; +void +g (void) +{ + extern int y[1]; +} diff --git a/SingleSource/Regression/C/gcc-dg/redecl-9.c b/SingleSource/Regression/C/gcc-dg/redecl-9.c new file mode 100644 index 0000000000..6fe25800e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/redecl-9.c @@ -0,0 +1,30 @@ +/* Test for multiple declarations and composite types, as in bug + 13801. Test types saved from outer scopes are up to date. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int x[]; + +void +f (void) +{ + extern int x[]; +} + +int x[10]; + +void +g (void) +{ + int x; + { + extern int x[10]; + } +} + +void +h (void) +{ + sizeof (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/reg-vol-struct-1.c b/SingleSource/Regression/C/gcc-dg/reg-vol-struct-1.c new file mode 100644 index 0000000000..b885f91794 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/reg-vol-struct-1.c @@ -0,0 +1,18 @@ +/* Test cases of structures with volatile fields declared register: + should be allowed unless register name given but explicitly taking + the address forbidden. */ +/* Origin: Joseph Myers */ + +/* { dg-do compile } */ + +struct S { volatile int field; }; + +void +f (void) +{ + register struct S a; + register struct S b[2]; + register struct S c __asm__("nosuchreg"); /* { dg-error "object with volatile field" "explicit reg name" } */ + &a; /* { dg-error "address of register" "explicit address" } */ + b; /* { dg-error "address of register" "implicit address" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/register-var-1.c b/SingleSource/Regression/C/gcc-dg/register-var-1.c new file mode 100644 index 0000000000..e36f499748 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/register-var-1.c @@ -0,0 +1,14 @@ +/* PR/18160 */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ + +/* This should yield an error even without -pedantic. */ +/* { dg-options "-ansi" } */ + +void g(int *); + +void f(void) +{ + register int x __asm ("eax"); + g(&x); /* { dg-error "address of register variable" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/register-var-2.c b/SingleSource/Regression/C/gcc-dg/register-var-2.c new file mode 100644 index 0000000000..01816d5f42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/register-var-2.c @@ -0,0 +1,14 @@ +/* PR/18160 */ + +/* { dg-do compile } */ + +/* This should yield an error even without -pedantic. */ +/* { dg-options "-ansi" } */ + +void g(int *); + +void f(void) +{ + register int x; + g(&x); /* { dg-error "address of register variable" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/register-var-3.c b/SingleSource/Regression/C/gcc-dg/register-var-3.c new file mode 100644 index 0000000000..dc659f57f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/register-var-3.c @@ -0,0 +1,9 @@ +/* { dg-options "" } */ +/* { dg-do compile } */ +register int r0; /* { dg-error "register name not specified" } */ +register int bp; /* { dg-error "register name not specified" } */ +register int sp; /* { dg-error "register name not specified" } */ +register int r30; /* { dg-error "register name not specified" } */ +register int toc; /* { dg-error "register name not specified" } */ +register int d0; /* { dg-error "register name not specified" } */ +register int a0; /* { dg-error "register name not specified" } */ diff --git a/SingleSource/Regression/C/gcc-dg/return-type-1.c b/SingleSource/Regression/C/gcc-dg/return-type-1.c new file mode 100644 index 0000000000..2507cafa5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/return-type-1.c @@ -0,0 +1,9 @@ +/* Missing warning for falling off the end of a non-void function. + egcs-1.1.2 passes, egcs-ss-19990428 fails. + http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00221.html */ +/* { dg-do compile } */ +/* { dg-options "-O -Wreturn-type" } */ +int +foo(void) +{ +} /* { dg-warning "control reaches end of non-void function" "warning for falling off end of non-void function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/return-type-2.c b/SingleSource/Regression/C/gcc-dg/return-type-2.c new file mode 100644 index 0000000000..183c6a88d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/return-type-2.c @@ -0,0 +1,47 @@ +/* Bogus warnings claiming we fall off the end of a non-void function. + By Kaveh R. Ghazi 8/27/2000. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wreturn-type" } */ + +extern void abort (void) __attribute__ ((__noreturn__)); + +int +foo1 (int i) +{ + if (i) + return i; + + abort (); +} /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */ + +__inline__ int +foo2 (int i) +{ + if (i) + return i; + + abort (); +} /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */ + +static int +foo3 (int i) +{ + if (i) + return i; + + abort (); +} /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */ + +static __inline__ int +foo4 (int i) +{ + if (i) + return i; + + abort (); +} /* { dg-bogus "control reaches end of non-void function" "warning for falling off end of non-void function" } */ + +int bar (int i) +{ + return foo1 (i) + foo2 (i) + foo3 (i) + foo4 (i); +} diff --git a/SingleSource/Regression/C/gcc-dg/return-type-3.c b/SingleSource/Regression/C/gcc-dg/return-type-3.c new file mode 100644 index 0000000000..e06ba7c023 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/return-type-3.c @@ -0,0 +1,14 @@ +/* PR optimization/7189 + This was a missing warning caused by a cfg cleanup after sibling + call optimization. The return clobber insn was cleaned up and + the warning was never issued. */ +/* { dg-do compile } */ +/* { dg-options "-O -foptimize-sibling-calls -Wreturn-type" } */ + +extern void foo(void); + +int +bar (void) +{ + foo(); +} /* { dg-warning "control reaches end of non-void function" "warning for falling off end of non-void function" } */ diff --git a/SingleSource/Regression/C/gcc-dg/rounding-math-1.c b/SingleSource/Regression/C/gcc-dg/rounding-math-1.c new file mode 100644 index 0000000000..3b13549e48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/rounding-math-1.c @@ -0,0 +1,17 @@ +/* Test __ROUNDING_MATH__ is defined with -frounding-math. */ +/* { dg-do compile } */ +/* { dg-options "-frounding-math" } */ + +#ifndef __ROUNDING_MATH__ +#error "__ROUNDING_MATH__ not defined" +#endif + +#pragma GCC optimize "-fno-rounding-math" +#ifdef __ROUNDING_MATH__ +#error "__ROUNDING_MATH__ defined" +#endif + +#pragma GCC optimize "-frounding-math" +#ifndef __ROUNDING_MATH__ +#error "__ROUNDING_MATH__ not defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/rounding-math-2.c b/SingleSource/Regression/C/gcc-dg/rounding-math-2.c new file mode 100644 index 0000000000..6468a84c4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/rounding-math-2.c @@ -0,0 +1,17 @@ +/* Test __ROUNDING_MATH__ is not defined with -fno-rounding-math. */ +/* { dg-do compile } */ +/* { dg-options "-fno-rounding-math" } */ + +#ifdef __ROUNDING_MATH__ +#error "__ROUNDING_MATH__ defined" +#endif + +#pragma GCC optimize "-frounding-math" +#ifndef __ROUNDING_MATH__ +#error "__ROUNDING_MATH__ not defined" +#endif + +#pragma GCC optimize "-fno-rounding-math" +#ifdef __ROUNDING_MATH__ +#error "__ROUNDING_MATH__ defined" +#endif diff --git a/SingleSource/Regression/C/gcc-dg/sabd_1.c b/SingleSource/Regression/C/gcc-dg/sabd_1.c new file mode 100644 index 0000000000..587e3055fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sabd_1.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fwrapv" } */ +/* Make sure vectorized absolute difference behaves same as scalar version. */ + +#define N 16 +signed char a[] = {-100, -100, -100, -100,-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 }; +signed char b[] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; + +signed char out[N]; + +__attribute__ ((noinline,noipa)) +void +foo (void) +{ + for (int i = 0; i < N; i++) + { + signed char diff = b[i] - a[i]; + out[i] = diff > 0 ? diff : -diff; + } +} + +signed char out2[N]; + +__attribute__ ((noinline,noipa)) +void +foo_scalar (void) +{ + for (int i = 0; i < N; i++) + { + asm volatile (""); + signed char diff = b[i] - a[i]; + out2[i] = diff > 0 ? diff : -diff; + } +} + +int +main (void) +{ + foo (); + foo_scalar (); + for (int i = 0; i < N; i++) + if (out[i] != out2[i]) + __builtin_abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/section1.c b/SingleSource/Regression/C/gcc-dg/section1.c new file mode 100644 index 0000000000..e907f193b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/section1.c @@ -0,0 +1,5 @@ +/* PR optimization/6871 */ +/* Constant variables belong in .rodata, not .bss. */ +/* { dg-final { scan-assembler-not "\.bss" } } */ + +const int i = 0; diff --git a/SingleSource/Regression/C/gcc-dg/self-right-shift.c b/SingleSource/Regression/C/gcc-dg/self-right-shift.c new file mode 100644 index 0000000000..c457ee53ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/self-right-shift.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* Self right-shift should be optimized to 0. */ + +int +foo (int i) +{ + return i >> i; +} + +/* { dg-final { scan-tree-dump "return 0;" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/semicolon-fixits.c b/SingleSource/Regression/C/gcc-dg/semicolon-fixits.c new file mode 100644 index 0000000000..e7d532296d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/semicolon-fixits.c @@ -0,0 +1,17 @@ +/* { dg-options "-fdiagnostics-show-caret -Wpedantic" } */ + +/* Struct with extra semicolon. */ +struct s1 { int i;; }; /* { dg-warning "19: extra semicolon in struct or union specified" } */ +/* { dg-begin-multiline-output "" } + struct s1 { int i;; }; + ^ + - + { dg-end-multiline-output "" } */ + +/* Union with extra semicolon. */ +union u1 { int i;; }; /* { dg-warning "18: extra semicolon in struct or union specified" } */ +/* { dg-begin-multiline-output "" } + union u1 { int i;; }; + ^ + - + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/sequence-pt-1.c b/SingleSource/Regression/C/gcc-dg/sequence-pt-1.c new file mode 100644 index 0000000000..2e22b662a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sequence-pt-1.c @@ -0,0 +1,109 @@ +/* Test for sequence point warnings. */ +/* Origin: Michael Meeks in + , + adapted to a testcase by Joseph Myers . */ +/* { dg-do compile } */ +/* { dg-options "-Wsequence-point" } */ + +struct s +{ + int a; +}; + +extern int fn (int); +extern int fnb (int, int); +extern int fnc (int *); +extern int sprintf (char *, const char *, ...); + +typedef __UINTPTR_TYPE__ uintptr_t; + +void +foo (int a, int b, int n, int p, int *ptr, struct s *sptr, + int *ap, int *bp, int **cp, char *ans, int (*fnp[8])(int)) +{ + int len; + + a = a++; /* { dg-warning "undefined" "sequence point warning" } */ + a = --a; /* { dg-warning "undefined" "sequence point warning" } */ + a = ++a + b; /* { dg-warning "undefined" "sequence point warning" } */ + a = a-- + b; /* { dg-warning "undefined" "sequence point warning" } */ + ap[n] = bp[n++]; /* { dg-warning "undefined" "sequence point warning" } */ + ap[--n] = bp[n]; /* { dg-warning "undefined" "sequence point warning" } */ + ap[++n] = bp[--n]; /* { dg-warning "undefined" "sequence point warning" } */ + cp[n][n] = cp[n][n]++; /* { dg-warning "undefined" "sequence point warning" } */ + cp[n][p] = cp[n][n++]; /* { dg-warning "undefined" "sequence point warning" } */ + *ptr++ = (uintptr_t)ptr++; /* { dg-warning "undefined" "sequence point warning" } */ + sptr->a = sptr->a++; /* { dg-warning "undefined" "sequence point warning" } */ + sptr->a = (uintptr_t)(sptr++); /* { dg-warning "undefined" "sequence point warning" } */ + *ptr++ = fn (*ptr); /* { dg-warning "undefined" "sequence point warning" } */ + a = b = a++; /* { dg-warning "undefined" "sequence point warning" } */ + b = a = --b; /* { dg-warning "undefined" "sequence point warning" } */ + a = 1 + (a = 1); /* { dg-warning "undefined" "sequence point warning" } */ + a = (a = b); /* { dg-warning "undefined" "sequence point warning" } */ + a = (a = b) + 1; /* { dg-warning "undefined" "sequence point warning" } */ + a = (bp[a++] = b) + 1; /* { dg-warning "undefined" "sequence point warning" } */ + a = b++ * b++; /* { dg-warning "undefined" "sequence point warning" } */ + a = fnb (b++, b++); /* { dg-warning "undefined" "sequence point warning" } */ + a = (*fnp[b++]) (b++); /* { dg-warning "undefined" "sequence point warning" } */ + a = (*fnp[b]) (b++); /* { dg-warning "undefined" "sequence point warning" } */ + a = (*fnp[b++]) (b); /* { dg-warning "undefined" "sequence point warning" } */ + *ap = fnc (ap++); /* { dg-warning "undefined" "sequence point warning" } */ + (a += b) + (a += n); /* { dg-warning "undefined" "sequence point warning" } */ + a = (b, b++) + (b++, b); /* { dg-warning "undefined" "sequence point warning" } */ + ap[a++] += a; /* { dg-warning "undefined" "sequence point warning" } */ + ap[a+=1] += a; /* { dg-warning "undefined" "sequence point warning" } */ + ap[a++] += a++; /* { dg-warning "undefined" "sequence point warning" } */ + ap[a+=1] += a++; /* { dg-warning "undefined" "sequence point warning" } */ + a = a++, b = a; /* { dg-warning "undefined" "sequence point warning" } */ + b = a, a = a++; /* { dg-warning "undefined" "sequence point warning" } */ + a = (b++ ? n : a) + b; /* { dg-warning "undefined" "sequence point warning" } */ + b ? a = a++ : a; /* { dg-warning "undefined" "sequence point warning" } */ + b && (a = a++); /* { dg-warning "undefined" "sequence point warning" } */ + (a = a++) && b; /* { dg-warning "undefined" "sequence point warning" } */ + b, (a = a++); /* { dg-warning "undefined" "sequence point warning" } */ + (a = a++), b; /* { dg-warning "undefined" "sequence point warning" } */ + a ^= b ^= a ^= b; /* { dg-warning "undefined" "sequence point warning" } */ + + a = a; /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = (a++ && 4); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = ! (a++ && 4); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = - (a++ && 4); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = (double) (a++ && 4); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + len = sprintf (ans, "%d", len++); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = fn (a++); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + b++, (b + b); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + (a = b++), (a = b++); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = (b++, b++); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = b++ && b++; /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = b++ || b++; /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = (b++ ? b++ : a); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + a = (b++ ? a : b++); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + ap[a++] += bp[b]; /* { dg-bogus "undefined" "bogus sequence point warning" } */ + ap[a += 1] += 1; /* { dg-bogus "undefined" "bogus sequence point warning" } */ + *ptr < 128 ? *ptr++ : *(ptr += 2); /* { dg-bogus "undefined" "bogus sequence point warning" } */ + + /* The following will be represented internally with a tree consisting of + many duplicated SAVE_EXPRs. This caused the previous version of the + sequence point warning code to fail by running out of virtual memory. */ + a = ((b & 1 ? 21 : 0) + | (b & 2 ? 22 : 0) + | (b & 3 ? 23 : 0) + | (b & 4 ? 24 : 0) + | (b & 5 ? 25 : 0) + | (b & 6 ? 26 : 0) + | (b & 7 ? 27 : 0) + | (b & 8 ? 28 : 0) + | (b & 9 ? 29 : 0) + | (b & 10 ? 30 : 0) + | (b & 11 ? 31 : 0) + | (b & 12 ? 32 : 0) + | (b & 13 ? 1 : 0) + | (b & 14 ? 2 : 0) + | (b & 15 ? 3 : 0) + | (b & 16 ? 4 : 0) + | (b & 17 ? 5 : 0) + | (b & 18 ? 6 : 0) + | (b & 19 ? 7 : 0) + | (b & 20 ? 8 : 0) + | (b & 21 ? 9 : 0)); +} diff --git a/SingleSource/Regression/C/gcc-dg/sequence-pt-2.c b/SingleSource/Regression/C/gcc-dg/sequence-pt-2.c new file mode 100644 index 0000000000..9a4b618ea5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sequence-pt-2.c @@ -0,0 +1,46 @@ +/* More sequence point warning tests */ +/* { dg-do compile } */ +/* { dg-options "-Wsequence-point" } */ + +struct s { struct s *nxt; int v; } q; + +int x[10]; + +int foo(int *p) +{ + int i = 0; + + /* Test general-lvalue sequence point warnings */ + (*p) = (*p)++; /* { dg-warning "undefined" "sequence point warning" } */ + p[3] = p[3]++; /* { dg-warning "undefined" "sequence point warning" } */ + p[i] = p[i]++; /* { dg-warning "undefined" "sequence point warning" } */ + x[3] = x[3]++; /* { dg-warning "undefined" "sequence point warning" } */ + q.nxt->nxt->v = q.nxt->nxt->v++; /* { dg-warning "undefined" "sequence point warning" } */ + + /* test expressions that appear elsewhere in the C grammar */ + + { int a = i-i++; (void)a;} /* { dg-warning "undefined" "sequence point warning" } */ + + if ((i-i++) != 0) /* { dg-warning "undefined" "sequence point warning" } */ + return i-i++; /* { dg-warning "undefined" "sequence point warning" } */ + + for (i-i++;;) /* { dg-warning "undefined" "sequence point warning" } */ + ; + + for (; (i-i++) != 0; ) /* { dg-warning "undefined" "sequence point warning" } */ + ; + + for (;;i-i++) /* { dg-warning "undefined" "sequence point warning" } */ + ; + + while ((i-i++) != 0) /* { dg-warning "undefined" "sequence point warning" } */ + ; + + do {} while ((i-i++) != 0); /* { dg-warning "undefined" "sequence point warning" } */ + + switch (i-i++) { /* { dg-warning "undefined" "sequence point warning" } */ + case 0: return 1; + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sequence-pt-3.c b/SingleSource/Regression/C/gcc-dg/sequence-pt-3.c new file mode 100644 index 0000000000..58971ca186 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sequence-pt-3.c @@ -0,0 +1,15 @@ +/* More sequence point warning tests */ +/* { dg-do compile } */ +/* { dg-options "-Wsequence-point" } */ + +void bar(int i, int j) +{ + return; +} + +void foo (int i) +{ + int a = i-i++; (void)a; /* { dg-warning "undefined" "sequence point warning" } */ + + bar (i--, i++); /* { dg-warning "undefined" "sequence point warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/sequence-pt-pr17880.c b/SingleSource/Regression/C/gcc-dg/sequence-pt-pr17880.c new file mode 100644 index 0000000000..df706e577f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sequence-pt-pr17880.c @@ -0,0 +1,54 @@ +/* PR 17880 */ +/* { dg-do compile } */ +/* { dg-options "-Wsequence-point" } */ + +int +foo (int x) +{ + unsigned int a; + int b; + + b = (a += 5) > a; /* { dg-warning "undefined" "sequence point warning" } */ + b = (a += 5) + a == 10; /* { dg-warning "undefined" "sequence point warning" } */ + b = (a -= 5) > a; /* { dg-warning "undefined" "sequence point warning" } */ + b = (a -= 5) + a == 10; /* { dg-warning "undefined" "sequence point warning" } */ + b = a-- > a; /* { dg-warning "undefined" "sequence point warning" } */ + b = a-- + a == 10; /* { dg-warning "undefined" "sequence point warning" } */ + b = ++a > a; /* { dg-warning "undefined" "sequence point warning" } */ + b = ++a + a == 10; /* { dg-warning "undefined" "sequence point warning" } */ + + if ((a += 5) > a) return -1; /* { dg-warning "undefined" "sequence point warning" } */ + if ((a += 5) + a == 10) return -1; /* { dg-warning "undefined" "sequence point warning" } */ + if ((a -= 5) > a) return -1; /* { dg-warning "undefined" "sequence point warning" } */ + if ((a -= 5) + a == 10) return -1; /* { dg-warning "undefined" "sequence point warning" } */ + if (a-- > a) return -1; /* { dg-warning "undefined" "sequence point warning" } */ + if (a-- + a == 10) return -1; /* { dg-warning "undefined" "sequence point warning" } */ + if (++a > a) return -1; /* { dg-warning "undefined" "sequence point warning" } */ + if (++a + a == 10) return -1; /* { dg-warning "undefined" "sequence point warning" } */ + do {} while ((a += 5) > a); /* { dg-warning "undefined" "sequence point warning" } */ + while ((a += 5) > a); /* { dg-warning "undefined" "sequence point warning" } */ + for ((a += 5) > a;;); /* { dg-warning "undefined" "sequence point warning" } */ + for (b = (a += 5) > a;;); /* { dg-warning "undefined" "sequence point warning" } */ + for (; (a += 5) > a;); /* { dg-warning "undefined" "sequence point warning" } */ + for (;; b = (a += 5) > a); /* { dg-warning "undefined" "sequence point warning" } */ + for (;; a++ + a++); /* { dg-warning "undefined" "sequence point warning" } */ + if (a) a++ - a--; /* { dg-warning "undefined" "sequence point warning" } */ + ((a +=5) > a) ? a : b; /* { dg-warning "undefined" "sequence point warning" } */ + return (a++ - a--); /* { dg-warning "undefined" "sequence point warning" } */ +} + +void bar (int i) +{ + int a = i++ - i++; /* { dg-warning "undefined" "sequence point warning" } */ +} + +void baz (int i) +{ + switch (i++ + i++) /* { dg-warning "undefined" "sequence point warning" } */ + { + case 1: + i++ - i++; /* { dg-warning "undefined" "sequence point warning" } */ + case 2: + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/setjmp-1.c b/SingleSource/Regression/C/gcc-dg/setjmp-1.c new file mode 100644 index 0000000000..600fb7f1ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/setjmp-1.c @@ -0,0 +1,37 @@ +/* Test for bogus "variable `x' may be clobbered by longjmp" warnings. + Inspired by cse.c:simplify_relational_operation. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wclobbered -Wextra -Wall" } */ +/* { dg-skip-if "" { ! nonlocal_goto } } */ + +#include + +extern void set_float_handler (jmp_buf *); + +#define EQ 0x01 +#define LT 0x02 +#define GT 0x04 + +int +compare_float (double a, double b) /* { dg-bogus "clobbered" "spurious clobbered warning" } */ +{ + jmp_buf handler; + int result; + + a += 1.0; + + if (setjmp (handler)) + { + set_float_handler (0); + return 0; + } + + set_float_handler (&handler); + if (a == b) result = EQ; + else if (a > b) result = LT; + else if (a < b) result = GT; + else result = 0; + set_float_handler (0); + return result; +} diff --git a/SingleSource/Regression/C/gcc-dg/setjmp-2.c b/SingleSource/Regression/C/gcc-dg/setjmp-2.c new file mode 100644 index 0000000000..bd35a25673 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/setjmp-2.c @@ -0,0 +1,48 @@ +/* PR middle-end/17813 */ +/* Origin: Tom Hughes */ +/* { dg-do run { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } */ +/* { dg-options "-O -fomit-frame-pointer" } */ +/* { dg-options "-O -fomit-frame-pointer -march=i386" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#include +#include +#include + +static jmp_buf segv_jmpbuf; + +static void segv_handler(int seg) +{ + __builtin_longjmp(segv_jmpbuf, 1); +} + +static int is_addressable(void *p, size_t size) +{ + volatile char * volatile cp = (volatile char *)p; + volatile int ret; + struct sigaction sa, origsa; + sigset_t mask; + + sa.sa_handler = segv_handler; + sa.sa_flags = 0; + sigfillset(&sa.sa_mask); + sigaction(SIGSEGV, &sa, &origsa); + sigprocmask(SIG_SETMASK, NULL, &mask); + + if (__builtin_setjmp(segv_jmpbuf) == 0) { + while(size--) + *cp++; + ret = 1; + } else + ret = 0; + + sigaction(SIGSEGV, &origsa, NULL); + sigprocmask(SIG_SETMASK, &mask, NULL); + + return ret; +} + +int main(int argc, char **argv) +{ + is_addressable(0x0, 1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/setjmp-3.c b/SingleSource/Regression/C/gcc-dg/setjmp-3.c new file mode 100644 index 0000000000..7522242081 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/setjmp-3.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include + +extern void abort (void); + +jmp_buf buf; + +void raise0(void) +{ + __builtin_longjmp (buf, 1); +} + +int execute(int cmd) +{ + int last = 0; + + if (__builtin_setjmp (buf) == 0) + while (1) + { + last = 1; + raise0 (); + } + + if (last == 0) + return 0; + else + return cmd; +} + +int main(void) +{ + if (execute (1) == 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/setjmp-4.c b/SingleSource/Regression/C/gcc-dg/setjmp-4.c new file mode 100644 index 0000000000..20765f631d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/setjmp-4.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include + +extern void abort (void); + +jmp_buf buf; + +void raise0(void) +{ + __builtin_longjmp (buf, 1); +} + +int execute(int cmd) +{ + int last = 0; + + __builtin_setjmp (buf); + + if (last == 0) + while (1) + { + last = 1; + raise0 (); + } + + if (last == 0) + return 0; + else + return cmd; +} + +int main(void) +{ + if (execute (1) == 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/setjmp-5.c b/SingleSource/Regression/C/gcc-dg/setjmp-5.c new file mode 100644 index 0000000000..584762915d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/setjmp-5.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include + +void bar (int); + +jmp_buf buf; +int v; + +void +foo (void) +{ + int i; + bar (0); + bar (1); + i = 5; + int j = setjmp (buf); + if (j == 0) + bar (2); + v = i; /* { dg-bogus "may be used uninitialized in this function" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/setjmp-6.c b/SingleSource/Regression/C/gcc-dg/setjmp-6.c new file mode 100644 index 0000000000..d821d230ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/setjmp-6.c @@ -0,0 +1,26 @@ +/* PR69569 */ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include + +jmp_buf buf; + +struct str { + int Count; +}; +int fun2(struct str *p1) +{ + int i = 1; + while (1) { + setjmp(buf); + break; + } + for (; i;) { + i = 0; + for (; i < (p1 ? p1->Count : 1); i++) + fun2(p1); + } + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/setjmp-7.c b/SingleSource/Regression/C/gcc-dg/setjmp-7.c new file mode 100644 index 0000000000..44b5bcbfa9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/setjmp-7.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-guess-branch-probability -w" } */ +/* { dg-require-effective-target indirect_jumps } */ + +struct __jmp_buf_tag { }; +typedef struct __jmp_buf_tag jmp_buf[1]; +struct globals { jmp_buf listingbuf; }; +extern struct globals *const ptr_to_globals; +void foo() +{ + if ( _setjmp ( ((*ptr_to_globals).listingbuf ))) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/short-compare-1.c b/SingleSource/Regression/C/gcc-dg/short-compare-1.c new file mode 100644 index 0000000000..b5e01c1c58 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/short-compare-1.c @@ -0,0 +1,20 @@ +/* PR rtl-optimization/19296 */ +/* Origin: Falk Hueffner */ + +/* { dg-do run } */ +/* { dg-options "-O" } */ +/* { dg-options "-O -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern void abort(void); + +void f(unsigned short ad) +{ + if (ad >= 0x4000 && ad < 0xc000) + abort(); +} + +int main(void) +{ + f(0xff00); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/short-compare-2.c b/SingleSource/Regression/C/gcc-dg/short-compare-2.c new file mode 100644 index 0000000000..bf4e6b4bad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/short-compare-2.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/19296 */ +/* Origin: Falk Hueffner */ +/* Testcase by Andrew Pinski */ + +/* { dg-do run } */ +/* { dg-options "-O" } */ +/* { dg-options "-O -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +extern void abort(); + +void f(unsigned short ad) +{ + if ((short) (ad - 0x4000) >= 0) + abort(); +} + +int main(void) +{ + f(0xc000); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/shrink-wrap-alloca.c b/SingleSource/Regression/C/gcc-dg/shrink-wrap-alloca.c new file mode 100644 index 0000000000..b9a2af1c51 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/shrink-wrap-alloca.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ +/* { dg-require-effective-target alloca } */ + +int *p; + +void +test (int a) +{ + if (a > 0) + p = __builtin_alloca (4); +} diff --git a/SingleSource/Regression/C/gcc-dg/shrink-wrap-loop.c b/SingleSource/Regression/C/gcc-dg/shrink-wrap-loop.c new file mode 100644 index 0000000000..ddc99e6b75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/shrink-wrap-loop.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target { { { i?86-*-* x86_64-*-* } && lp64 } || { arm_thumb2 } } } } */ +/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */ + +int foo (int *p1, int *p2); + +int +test (int *p1, int *p2) +{ + int *p; + + for (p = p2; p != 0; p++) + { + if (!foo (p, p1)) + return 0; + } + + return 1; +} +/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/shrink-wrap-pretend.c b/SingleSource/Regression/C/gcc-dg/shrink-wrap-pretend.c new file mode 100644 index 0000000000..6e20ca12e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/shrink-wrap-pretend.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +#include +#include +#include + +#define DEBUG_BUFFER_SIZE 80 +int unifi_debug = 5; + +void +unifi_trace (void* ospriv, int level, const char *fmt, ...) +{ + static char s[DEBUG_BUFFER_SIZE]; + va_list args; + unsigned int len; + + if (!ospriv) + return; + + if (unifi_debug >= level) + { + va_start (args, fmt); + len = vsnprintf (&(s)[0], (DEBUG_BUFFER_SIZE), fmt, args); + va_end (args); + + if (len >= DEBUG_BUFFER_SIZE) + { + (s)[DEBUG_BUFFER_SIZE - 2] = '\n'; + (s)[DEBUG_BUFFER_SIZE - 1] = 0; + } + + printf ("%s", s); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/shrink-wrap-sibcall.c b/SingleSource/Regression/C/gcc-dg/shrink-wrap-sibcall.c new file mode 100644 index 0000000000..193bec2ce6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/shrink-wrap-sibcall.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +unsigned char a, b, d, f, g; + +int test (void); + +int +baz (int c) +{ + if (c == 0) return test (); + if (b & 1) + { + g = 0; + int e = (a & 0x0f) - (g & 0x0f); + + if (!a) b |= 0x80; + a = e + test (); + f = g/5 + a*3879 + b *2985; + } + else + { + f = g + a*39879 + b *25; + } + return test (); +} diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-1.c b/SingleSource/Regression/C/gcc-dg/sibcall-1.c new file mode 100644 index 0000000000..f2bd3ade21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-1.c @@ -0,0 +1,59 @@ +/* Simple check that sibling calls are performed from a + void non-leaf-function taking one int argument calling itself. + + Copyright (C) 2002 Free Software Foundation Inc. + Contributed by Hans-Peter Nilsson */ + +/* { dg-do run } */ +/* { dg-options "-O2 -foptimize-sibling-calls" } */ + +/* See note in recurser_void() as to why we disable threading. */ +/* { dg-additional-options "-fdisable-tree-thread1" } */ + +/* The option -foptimize-sibling-calls is the default, but serves as + marker. Self-recursion tail calls are optimized for all targets, + regardless of presence of sibcall patterns. */ + +extern void abort (void); +extern void exit (int); + +extern void recurser_void (int); +extern void track (int); + +int main () +{ + recurser_void (0); + exit (0); +} + +void +recurser_void (int n) +{ + /* In some architectures like ppc64*, jump threading may thread + paths such that there are two calls into track(), one for + track(0) and one for track(7). The track(7) call can be + transformed into a jump instead of a call, which means that + different calls into track() may end up with a different + &stackpos. This is the reason we disable jump threading for this + test. */ + if (n == 0 || n == 7) + track (n); + + if (n == 10) + return; + + recurser_void (n + 1); +} + +void *trackpoint; + +void __attribute__ ((noipa)) +track (int n) +{ + char stackpos[1]; + + if (n == 0) + trackpoint = stackpos; + else if (n != 7 || trackpoint != stackpos) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-10.c b/SingleSource/Regression/C/gcc-dg/sibcall-10.c new file mode 100644 index 0000000000..e78d88fc8f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-10.c @@ -0,0 +1,85 @@ +/* Simple check that sibling calls are performed from a + void non-leaf-function taking no arguments calling a function which + is about the same as itself. + + Copyright (C) 2002 Free Software Foundation Inc. + Contributed by Hans-Peter Nilsson */ + +/* { dg-do run { xfail { { amdgcn*-*-* cris-*-* csky-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* nvptx*-*-* } || { arm*-*-* && { ! arm32 } } } } } */ +/* -mlongcall disables sibcall patterns. */ +/* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */ +/* -msave-restore disables sibcall patterns. */ +/* { dg-skip-if "" { riscv*-*-* } { "-msave-restore" } { "" } } */ +/* { dg-options "-O2 -foptimize-sibling-calls" } */ + +/* The option -foptimize-sibling-calls is the default, but serves as + marker. This test is xfailed on targets without sibcall patterns + (except targets where the test does not work due to the return address + not saved on the regular stack). */ + +extern void abort (void); +extern void exit (int); + +/* Sibcalls are not supported in MIPS16 mode, which has direct calls but + not direct jumps. */ +#ifdef __mips +#define ATTR __attribute__((nomips16)) +#else +#define ATTR +#endif + +static ATTR void recurser_void1 (void); +static ATTR void recurser_void2 (void); +extern void track (void); +static volatile int v; + +int n = 0; +int main () +{ + recurser_void1 (); + if (v != 5) + abort (); + exit (0); +} + +/* The functions should get the same stack-frame, and best way to make it + reasonably sure is to make them have the same contents (regarding the + n tests). */ + +static void __attribute__((noipa)) ATTR +recurser_void1 (void) +{ + if (n == 0 || n == 7 || n == 8) + track (); + + if (n == 10) + return; + n++; + recurser_void2 (); +} + +static void __attribute__((noipa)) ATTR +recurser_void2 (void) +{ + if (n == 0 || n == 7 || n == 8) + track (); + + if (n == 10) + return; + n++; + v++; + recurser_void1 (); +} + +void *trackpoint; + +void __attribute__ ((noipa)) +track () +{ + char stackpos[1]; + + if (n == 0) + trackpoint = stackpos; + else if ((n != 7 && n != 8) || trackpoint != stackpos) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-11.c b/SingleSource/Regression/C/gcc-dg/sibcall-11.c new file mode 100644 index 0000000000..12f6d9c9c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-11.c @@ -0,0 +1,8 @@ +// Test for sibcall optimization with empty struct. +// { dg-options "-O2" } +/* { dg-additional-options "-fno-PIE" { target ia32 } } */ +// { dg-final { scan-assembler "jmp" { target i?86-*-* x86_64-*-* } } } + +struct A { }; +void f(struct A); +void g(struct A a) { f(a); } diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-2.c b/SingleSource/Regression/C/gcc-dg/sibcall-2.c new file mode 100644 index 0000000000..0d4df82b0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-2.c @@ -0,0 +1,50 @@ +/* Simple check that sibling calls are performed from a + void non-leaf-function taking no arguments calling itself. + + Copyright (C) 2002 Free Software Foundation Inc. + Contributed by Hans-Peter Nilsson */ + +/* { dg-do run } */ +/* { dg-options "-O2 -foptimize-sibling-calls" } */ + +/* The option -foptimize-sibling-calls is the default, but serves as + marker. Self-recursion tail calls are optimized for all targets, + regardless of presence of sibcall patterns. */ + +extern void abort (void); +extern void exit (int); + +extern void recurser_void (void); +extern void track (void); + +int n = 0; +int main () +{ + recurser_void (); + exit (0); +} + +void +recurser_void (void) +{ + if (n == 0 || n == 7) + track (); + + if (n == 10) + return; + n++; + recurser_void (); +} + +void *trackpoint; + +void __attribute__ ((noipa)) +track () +{ + char stackpos[1]; + + if (n == 0) + trackpoint = stackpos; + else if (n != 7 || trackpoint != stackpos) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-3.c b/SingleSource/Regression/C/gcc-dg/sibcall-3.c new file mode 100644 index 0000000000..82ad8c7980 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-3.c @@ -0,0 +1,78 @@ +/* Simple check that sibling calls are performed from a + void non-leaf-function taking one int argument calling a function which + is about the same as itself. + + Copyright (C) 2002 Free Software Foundation Inc. + Contributed by Hans-Peter Nilsson */ + +/* { dg-do run { xfail { { cris-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* nvptx*-*-* } || { arm*-*-* && { ! arm32 } } } } } */ +/* -mlongcall disables sibcall patterns. */ +/* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */ +/* { dg-options "-O2 -foptimize-sibling-calls" } */ + +/* The option -foptimize-sibling-calls is the default, but serves as + marker. This test is xfailed on targets without sibcall patterns + (except targets where the test does not work due to the return address + not saved on the regular stack). */ + +extern void abort (void); +extern void exit (int); + +/* Sibcalls are not supported in MIPS16 mode, which has direct calls but + not direct jumps. */ +#ifdef __mips +#define ATTR __attribute__((nomips16)) +#else +#define ATTR +#endif + +static ATTR void recurser_void1 (int); +static ATTR void recurser_void2 (int); +extern void track (int); + +int main () +{ + recurser_void1 (0); + exit (0); +} + +/* The functions should get the same stack-frame, and best way to make it + reasonably sure is to make them have the same contents (regarding the + n tests). */ + +static void __attribute__((noipa)) ATTR +recurser_void1 (int n) +{ + if (n == 0 || n == 7 || n == 8) + track (n); + + if (n == 10) + return; + + recurser_void2 (n + 1); +} + +static void __attribute__((noipa)) ATTR +recurser_void2 (int n) +{ + if (n == 0 || n == 7 || n == 8) + track (n); + + if (n == 10) + return; + + recurser_void1 (n + 1); +} + +void *trackpoint; + +void __attribute__ ((noipa)) +track (int n) +{ + char stackpos[1]; + + if (n == 0) + trackpoint = stackpos; + else if ((n != 7 && n != 8) || trackpoint != stackpos) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-4.c b/SingleSource/Regression/C/gcc-dg/sibcall-4.c new file mode 100644 index 0000000000..5dcff3f8d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-4.c @@ -0,0 +1,79 @@ +/* Simple check that sibling calls are performed from a + void non-leaf-function taking no arguments calling a function which + is about the same as itself. + + Copyright (C) 2002 Free Software Foundation Inc. + Contributed by Hans-Peter Nilsson */ + +/* { dg-do run { xfail { { cris-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* nvptx*-*-* } || { arm*-*-* && { ! arm32 } } } } } */ +/* -mlongcall disables sibcall patterns. */ +/* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */ +/* { dg-options "-O2 -foptimize-sibling-calls" } */ + +/* The option -foptimize-sibling-calls is the default, but serves as + marker. This test is xfailed on targets without sibcall patterns + (except targets where the test does not work due to the return address + not saved on the regular stack). */ + +extern void abort (void); +extern void exit (int); + +/* Sibcalls are not supported in MIPS16 mode, which has direct calls but + not direct jumps. */ +#ifdef __mips +#define ATTR __attribute__((nomips16)) +#else +#define ATTR +#endif + +static ATTR void recurser_void1 (void); +static ATTR void recurser_void2 (void); +extern void track (void); + +int n = 0; +int main () +{ + recurser_void1 (); + exit (0); +} + +/* The functions should get the same stack-frame, and best way to make it + reasonably sure is to make them have the same contents (regarding the + n tests). */ + +static void __attribute__((noipa)) ATTR +recurser_void1 (void) +{ + if (n == 0 || n == 7 || n == 8) + track (); + + if (n == 10) + return; + n++; + recurser_void2 (); +} + +static void __attribute__((noipa)) ATTR +recurser_void2 (void) +{ + if (n == 0 || n == 7 || n == 8) + track (); + + if (n == 10) + return; + n++; + recurser_void1 (); +} + +void *trackpoint; + +void __attribute__ ((noipa)) +track () +{ + char stackpos[1]; + + if (n == 0) + trackpoint = stackpos; + else if ((n != 7 && n != 8) || trackpoint != stackpos) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-6.c b/SingleSource/Regression/C/gcc-dg/sibcall-6.c new file mode 100644 index 0000000000..8ee72cac44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-6.c @@ -0,0 +1,46 @@ +/* A simple check to see whether indirect calls are + being sibcall optimized on targets that do support + this notion, i.e. have the according call patterns + in place. + + Copyright (C) 2002 Free Software Foundation Inc. + Contributed by Andreas Bauer */ + +/* { dg-do run { target epiphany-*-* i?86-*-* x86_64-*-* s390*-*-* } } */ +/* { dg-skip-if "" { { i?86-*-* x86_64-*-* } && { ia32 && { ! nonpic } } } } */ +/* { dg-options "-O2 -foptimize-sibling-calls -fno-ipa-cp" } */ + +extern void abort (void); +extern void exit (int); + +int foo (int); +int bar (int); + +int (*ptr) (int); +int *f_addr; + +int +main () +{ + ptr = bar; + foo (7); + exit (0); +} + +int __attribute__ ((noinline)) +bar (b) + int b; +{ + if (f_addr == (int*) __builtin_return_address (0)) + return b; + else + abort (); +} + +int __attribute__ ((noinline)) +foo (f) + int f; +{ + f_addr = (int*) __builtin_return_address (0); + return (*ptr)(f); +} diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-7.c b/SingleSource/Regression/C/gcc-dg/sibcall-7.c new file mode 100644 index 0000000000..6d59ca3395 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-7.c @@ -0,0 +1,46 @@ +/* Simple check that tail recursive call optimization is also + controlled by -foptimize-sibling-calls. + + Copyright (C) 2006 Free Software Foundation Inc. + Original test by Hans-Peter Nilsson */ + +/* On IA64 the call frame is allocated on the register stack, not the + normal stack. */ + +/* { dg-do run { target { ! "ia64-*-*" } } } */ +/* { dg-options "-O2 -fno-optimize-sibling-calls" } */ + + +extern void abort (void); + +extern void recurser_void (int); +extern void track (int); + +int main (void) +{ + recurser_void (0); + return 0; +} + +void recurser_void (int n) +{ + if (n == 0 || n == 7) + track (n); + + if (n == 10) + return; + + recurser_void (n + 1); +} + +void *trackpoint; + +void track (int n) +{ + char stackpos[1]; + + if (n == 0) + trackpoint = stackpos; + else if (n != 7 || trackpoint == stackpos) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-8.c b/SingleSource/Regression/C/gcc-dg/sibcall-8.c new file mode 100644 index 0000000000..767040fd04 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-8.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -foptimize-sibling-calls" } */ + +typedef struct { + int data[4]; +} arr16_t; + +int result = 0; + +void func2(int i, int j, arr16_t arr) +{ + result = (arr.data[0] != 1 + || arr.data[1] != 2 + || arr.data[2] != 3 + || arr.data[3] != 4); +} + +void func1(int i, int j, int k, arr16_t a) +{ + func2(i, j, a); +} + +int main(int argc, const char *argv[]) +{ + arr16_t arr = {{1, 2, 3, 4}}; + + func1(0, 0, 0, arr); + return result; +} + diff --git a/SingleSource/Regression/C/gcc-dg/sibcall-9.c b/SingleSource/Regression/C/gcc-dg/sibcall-9.c new file mode 100644 index 0000000000..006dc0d28f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sibcall-9.c @@ -0,0 +1,84 @@ +/* Simple check that sibling calls are performed from a + void non-leaf-function taking one int argument calling a function which + is about the same as itself. + + Copyright (C) 2002 Free Software Foundation Inc. + Contributed by Hans-Peter Nilsson */ + +/* { dg-do run { xfail { { amdgcn*-*-* cris-*-* csky-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* nvptx-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */ +/* -mlongcall disables sibcall patterns. */ +/* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */ +/* -msave-restore disables sibcall patterns. */ +/* { dg-skip-if "" { riscv*-*-* } { "-msave-restore" } { "" } } */ +/* { dg-options "-O2 -foptimize-sibling-calls" } */ + +/* The option -foptimize-sibling-calls is the default, but serves as + marker. This test is xfailed on targets without sibcall patterns + (except targets where the test does not work due to the return address + not saved on the regular stack). */ + +extern void abort (void); +extern void exit (int); + +/* Sibcalls are not supported in MIPS16 mode, which has direct calls but + not direct jumps. */ +#ifdef __mips +#define ATTR __attribute__((nomips16)) +#else +#define ATTR +#endif + +static ATTR void recurser_void1 (int); +static ATTR void recurser_void2 (int); +extern void track (int); +static volatile int v; + +int main () +{ + recurser_void1 (0); + if (v != 5) + abort (); + exit (0); +} + +/* The functions should get the same stack-frame, and best way to make it + reasonably sure is to make them have the same contents (regarding the + n tests). */ + +static void __attribute__((noipa)) ATTR +recurser_void1 (int n) +{ + if (n == 0 || n == 7 || n == 8) + track (n); + + if (n == 10) + return; + + recurser_void2 (n + 1); +} + +static void __attribute__((noipa)) ATTR +recurser_void2 (int n) +{ + if (n == 0 || n == 7 || n == 8) + track (n); + + if (n == 10) + return; + + v++; + recurser_void1 (n + 1); +} + +void *trackpoint; + +void __attribute__ ((noipa)) +track (int n) +{ + char stackpos[1]; + + if (n == 0) + trackpoint = stackpos; + else if ((n != 7 && n != 8) || trackpoint != stackpos) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/signbit-2.c b/SingleSource/Regression/C/gcc-dg/signbit-2.c new file mode 100644 index 0000000000..62bb4047d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/signbit-2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ + +/* This test does not work when the truth type does not match vector type. */ +/* { dg-additional-options "-msse2 -mno-avx512f" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-march=armv8-a" { target aarch64_sve } } */ +/* { dg-additional-options "-maltivec" { target powerpc_altivec_ok } } */ +/* { dg-skip-if "no fallback for MVE" { arm_mve } } */ + +#include + +void fun1(int32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (-x[i]) >> 31; +} + +void fun2(int32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (-x[i]) >> 30; +} + +/* Xfail amdgcn where vector truth type is not integer type. */ +/* { dg-final { scan-tree-dump {\s+>\s+\{ 0(, 0)+ \}} optimized { target vect_shift xfail amdgcn-*-* } } } */ +/* { dg-final { scan-tree-dump {\s+>\s+0} optimized { target { ! vect_shift } } } } */ +/* { dg-final { scan-tree-dump-not {\s+>>\s+31} optimized { xfail amdgcn-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/signbit-3.c b/SingleSource/Regression/C/gcc-dg/signbit-3.c new file mode 100644 index 0000000000..19e9c06c34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/signbit-3.c @@ -0,0 +1,13 @@ +/* { dg-do assemble } */ +/* { dg-options "-O1 --save-temps -fdump-tree-optimized" } */ + +#include + +void fun1(int32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (-x[i]) >> 31; +} + +/* { dg-final { scan-tree-dump-times {\s+>\s+0;} 1 optimized } } */ +/* { dg-final { scan-tree-dump-not {\s+>>\s+31} optimized } } */ diff --git a/SingleSource/Regression/C/gcc-dg/signbit-4.c b/SingleSource/Regression/C/gcc-dg/signbit-4.c new file mode 100644 index 0000000000..bc459ba60a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/signbit-4.c @@ -0,0 +1,65 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -fwrapv" } */ + +#include +#include +#include + +#ifndef N +#define N 65 +#endif + +#ifndef TYPE +#define TYPE int32_t +#endif + +#ifndef DEBUG +#define DEBUG 1 +#endif + +#define BASE ((TYPE) -1 < 0 ? -126 : 4) + +__attribute__ ((noinline, noipa)) +void fun1(TYPE *x, int n) +{ + for (int i = 0; i < n; i++) + x[i] = (-x[i]) >> 31; +} + +__attribute__ ((noinline, noipa, optimize("O0"))) +void fun2(TYPE *x, int n) +{ + for (int i = 0; i < n; i++) + x[i] = (-x[i]) >> 31; +} + +int main () +{ + TYPE a[N]; + TYPE b[N]; + + a[0] = INT_MIN; + b[0] = INT_MIN; + + for (int i = 1; i < N; ++i) + { + a[i] = BASE + i * 13; + b[i] = BASE + i * 13; + if (DEBUG) + printf ("%d: 0x%x\n", i, a[i]); + } + + fun1 (a, N); + fun2 (b, N); + + for (int i = 0; i < N; ++i) + { + if (DEBUG) + printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]); + + if (a[i] != b[i]) + __builtin_abort (); + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/signbit-5.c b/SingleSource/Regression/C/gcc-dg/signbit-5.c new file mode 100644 index 0000000000..0fad56c0ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/signbit-5.c @@ -0,0 +1,71 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +/* This test does not work when the truth type does not match vector type. */ +/* { dg-additional-options "-mno-avx512f" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-march=armv8-a" { target aarch64_sve } } */ +/* { dg-xfail-run-if "truth type does not match vector type" { amdgcn-*-* } } */ + + +#include +#include +#include + +#ifndef N +#define N 65 +#endif + +#ifndef TYPE +#define TYPE int32_t +#endif + +#ifndef DEBUG +#define DEBUG 1 +#endif + +#define BASE ((TYPE) -1 < 0 ? -126 : 4) + +__attribute__ ((noinline, noipa)) +void fun1(TYPE *x, int n) +{ + for (int i = 0; i < n; i++) + x[i] = (-x[i]) >> 31; +} + +__attribute__ ((noinline, noipa, optimize("O1"))) +void fun2(TYPE *x, int n) +{ + for (int i = 0; i < n; i++) + x[i] = (-x[i]) >> 31; +} + +int main () +{ + TYPE a[N]; + TYPE b[N]; + + a[0] = INT_MIN; + b[0] = INT_MIN; + + for (int i = 1; i < N; ++i) + { + a[i] = BASE + i * 13; + b[i] = BASE + i * 13; + if (DEBUG) + printf ("%d: 0x%x\n", i, a[i]); + } + + fun1 (a, N); + fun2 (b, N); + + for (int i = 0; i < N; ++i) + { + if (DEBUG) + printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]); + + if (a[i] != b[i]) + __builtin_abort (); + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/signbit-6.c b/SingleSource/Regression/C/gcc-dg/signbit-6.c new file mode 100644 index 0000000000..da186624cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/signbit-6.c @@ -0,0 +1,72 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +#include +#include +#include + +#ifndef N +#define N 65 +#endif + +#ifndef TYPE +#define TYPE int32_t +#endif + +#ifndef DEBUG +#define DEBUG 1 +#endif + +#define BASE ((TYPE) -1 < 0 ? -126 : 4) + +__attribute__ ((noinline, noipa)) +void fun1(TYPE *x, int n) +{ + for (int i = 0; i < n; i++) + x[i] = (-x[i]) >> 31; +} + +__attribute__ ((noinline, noipa, optimize("O0"))) +void fun2(TYPE *x, int n) +{ + for (int i = 0; i < n; i++) + x[i] = (-x[i]) >> 31; +} + +int main () +{ + TYPE a[N]; + TYPE b[N]; + + a[0] = INT_MIN; + b[0] = INT_MIN; + + for (int i = 1; i < N; ++i) + { + a[i] = BASE + i * 13; + b[i] = BASE + i * 13; + if (DEBUG) + printf ("%d: 0x%x\n", i, a[i]); + } + + fun1 (a, N); + fun2 (b, N); + + if (DEBUG) + printf ("%d = 0x%x == 0x%x\n", 0, a[0], b[0]); + + if (a[0] != 0x0 || b[0] != -1) + __builtin_abort (); + + + for (int i = 1; i < N; ++i) + { + if (DEBUG) + printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]); + + if (a[i] != b[i]) + __builtin_abort (); + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/signbit-sa.c b/SingleSource/Regression/C/gcc-dg/signbit-sa.c new file mode 100644 index 0000000000..3d273a3a2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/signbit-sa.c @@ -0,0 +1,12 @@ +/* Some versions of Solaris give strict-aliasing warnings for + signbit. */ +/* { dg-require-effective-target c99_runtime } */ +/* { dg-options "-std=c99 -O2 -Wstrict-aliasing" } */ + +#include + +int +main (void) +{ + return signbit (1.0f) | signbit (1.0) | signbit (1.0l);; +} diff --git a/SingleSource/Regression/C/gcc-dg/simd-1.c b/SingleSource/Regression/C/gcc-dg/simd-1.c new file mode 100644 index 0000000000..601724834a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-1.c @@ -0,0 +1,62 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +/* Origin: Aldy Hernandez . */ +/* Purpose: Program to test generic SIMD support. */ + +typedef int __attribute__((vector_size (16))) v4si; +typedef short __attribute__((vector_size (16))) v8hi; +typedef int __attribute__((vector_size (8))) v2si; +typedef unsigned int __attribute__((vector_size (16))) uv4si; + +v4si a, b; +v2si c, d; +v8hi e; +uv4si f; + +long long foo; +int foo1; +short foo2 __attribute__((vector_size (8))); + +void +hanneke () +{ + /* Assignment. */ + a = b; + + /* Assignment of different types. */ + b = c; /* { dg-error "incompatible types when assigning" } */ + d = a; /* { dg-error "incompatible types when assigning" } */ + + /* Casting between SIMDs of the same size. */ + e = (typeof (e)) a; + + /* Different signed SIMD assignment. */ + f = a; /* { dg-message "note: use .-flax-vector-conversions. to permit conversions between vectors with differing element types or numbers of subparts" } */ + /* { dg-error "incompatible types when assigning" "" { target *-*-* } .-1 } */ + + /* Casted different signed SIMD assignment. */ + f = (uv4si) a; + + /* Assignment between scalar and SIMD of different size. */ + foo = a; /* { dg-error "incompatible types when assigning" } */ + + /* Casted assignment between scalar and SIMD of same size. */ + foo = (typeof (foo)) foo2; + + /* Casted assignment between scalar and SIMD of different size. */ + foo1 = (typeof (foo1)) foo2; /* { dg-error "cannot convert a vector of type" } */ + + /* Operators on compatible SIMD types. */ + a += b + b; + a -= b; + a *= b; + a /= b; + a = -b; + + /* Operators on incompatible SIMD types. */ + a = b + c; /* { dg-error "invalid operands to binary +" } */ + a = b - c; /* { dg-error "invalid operands to binary -" } */ + a = b * c; /* { dg-error "invalid operands to binary *" } */ + a = b / c; /* { dg-error "invalid operands to binary /" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/simd-1b.c b/SingleSource/Regression/C/gcc-dg/simd-1b.c new file mode 100644 index 0000000000..44c39c2ef9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-1b.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +/* Origin: Aldy Hernandez . */ +/* Purpose: Program to test generic SIMD support. */ + +typedef int __attribute__((vector_size (16))) v4si; +typedef int __attribute__((vector_size (8))) v2si; + +v4si a, b; +v2si c, d; + +void +hanneke () +{ + /* Operators on compatible SIMD types. */ + a %= b; + c &= d; + a |= b; + c ^= d; + a >>= b; + c <<= d; + a = +b; + c = ~d; + + /* Operators on incompatible SIMD types. */ + a = b % c; /* { dg-error "invalid operands to binary" } */ + a = b % c; /* { dg-error "invalid operands to binary" } */ + d = c & b; /* { dg-error "invalid operands to binary" } */ + a = b | c; /* { dg-error "invalid operands to binary" } */ + d = c ^ b; /* { dg-error "invalid operands to binary" } */ + a = b >> c; /* { dg-error "invalid operands to binary" } */ + a = b >> c; /* { dg-error "invalid operands to binary" } */ + d = c << b; /* { dg-error "invalid operands to binary" } */ + d = c << b; /* { dg-error "invalid operands to binary" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/simd-2.c b/SingleSource/Regression/C/gcc-dg/simd-2.c new file mode 100644 index 0000000000..d24e076218 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-2.c @@ -0,0 +1,54 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +/* Origin: Aldy Hernandez . */ +/* Purpose: Program to test generic SIMD support. */ + +typedef float __attribute__((vector_size(8))) v2sf; +typedef float __attribute__((vector_size(16))) v4sf; +typedef double __attribute__((vector_size(16))) v2df; + +v4sf a, b; +v2sf c, d; +v2df e; + +double foo; +float foo1; +v2sf foo2; + +void +hanneke () +{ + /* Assignment. */ + a = b; + + /* Assignment of different types. */ + b = c; /* { dg-error "incompatible types when assigning" } */ + d = a; /* { dg-error "incompatible types when assigning" } */ + + /* Casting between SIMDs of the same size. */ + e = (typeof (e)) a; + + /* Assignment between scalar and SIMD of different size. */ + foo = a; /* { dg-error "incompatible types when assigning" } */ + + /* Casted assignment between scalar and SIMD of same size. */ + foo = (typeof (foo)) foo2; /* { dg-error "aggregate value used where a floating-point was expected" } */ + + /* Casted assignment between scalar and SIMD of different size. */ + foo1 = (typeof (foo1)) foo2; /* { dg-error "aggregate value used where a floating-point was expected" } */ + + /* Operators on compatible SIMD types. */ + a += b + b; + a -= b; + a *= b; + a /= b; + a = +b; + c = -d; + + /* Operators on incompatible SIMD types. */ + a = b + c; /* { dg-error "invalid operands to binary" } */ + a = b - c; /* { dg-error "invalid operands to binary" } */ + a = b * c; /* { dg-error "invalid operands to binary" } */ + a = b / c; /* { dg-error "invalid operands to binary" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/simd-3.c b/SingleSource/Regression/C/gcc-dg/simd-3.c new file mode 100644 index 0000000000..790b1e51e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-3.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-maltivec" { target { powerpc*-*-* && powerpc_altivec_ok } } } */ + +__attribute__ ((vector_size (2))) signed char v1, v2, v3; +void +one (void) +{ + v1 = v2 + v3; +} + +__attribute__ ((vector_size (8))) signed char v4, v5, v6; +void +two (void) +{ + v4 = v5 + v6; +} diff --git a/SingleSource/Regression/C/gcc-dg/simd-4.c b/SingleSource/Regression/C/gcc-dg/simd-4.c new file mode 100644 index 0000000000..f7b28d4522 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-4.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +typedef int myint; + +float __attribute__((vector_size(16))) b; +int __attribute__((vector_size(16))) d; +myint __attribute__((vector_size(16))) d2; +unsigned int __attribute__((vector_size(16))) e; + +void foo() +{ + b + d; /* { dg-error "invalid operands to binary" } */ + d += e; + d2 += d; +} diff --git a/SingleSource/Regression/C/gcc-dg/simd-5.c b/SingleSource/Regression/C/gcc-dg/simd-5.c new file mode 100644 index 0000000000..f53e4abea3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-5.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu89" } */ + +/* Ensure that we don't need a typedef to initialize a vector type. */ +#define vector __attribute__ ((vector_size (8))) +vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */ +vector char y = (vector short) {1,2,3,4}; /* { dg-message "note: use .-flax-vector-conversions. to permit conversions between vectors with differing element types or numbers of subparts" } */ + /* { dg-error "incompatible types when initializing" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/simd-6.c b/SingleSource/Regression/C/gcc-dg/simd-6.c new file mode 100644 index 0000000000..ce5fcf5d8f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-6.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu99" } */ + +/* Ensure that we don't need a typedef to initialize a vector type. */ +#define vector __attribute__ ((vector_size (8))) +vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */ +vector char y = (vector short) {1,2,3,4}; /* { dg-message "note: use .-flax-vector-conversions. to permit conversions between vectors with differing element types or numbers of subparts" } */ + /* { dg-error "incompatible types when initializing" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/simd-7.c b/SingleSource/Regression/C/gcc-dg/simd-7.c new file mode 100644 index 0000000000..42feccb209 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-7.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-w -Wno-psabi" } */ + +#if __SIZEOF_LONG_DOUBLE__ == 16 || __SIZEOF_LONG_DOUBLE__ == 8 +typedef long double a __attribute__((vector_size (16))); + +a __attribute__((noinline)) +sum (a first, a second) +{ + return first + second; +} + +a +foo (a x, a y, a z) +{ + return sum (x, y) + z; +} +#else +int main() {} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/simd-8.c b/SingleSource/Regression/C/gcc-dg/simd-8.c new file mode 100644 index 0000000000..5bc8637c86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/simd-8.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-w -Wno-psabi" } */ + +#if __SIZEOF_LONG_DOUBLE__ == 16 || __SIZEOF_LONG_DOUBLE__ == 8 +typedef long double a __attribute__((vector_size (32))); + +a __attribute__((noinline)) +sum (a first, a second) +{ + return first + second; +} + +a +foo (a x, a y, a z) +{ + return sum (x, y) + z; +} +#else +int main() {} +#endif diff --git a/SingleSource/Regression/C/gcc-dg/sin_cos.c b/SingleSource/Regression/C/gcc-dg/sin_cos.c new file mode 100644 index 0000000000..aa71dcac65 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sin_cos.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* This maps to essentially the same gimple that is generated for + gnat.dg/sin_cos.adb, on platforms that use the wraplf variant of + Ada.Numerics.Aux_Float. The value of EPSILON is not relevant to + the test, but the test must be there to keep the conversions in + different BBs long enough to trigger the problem that prevented the + sincos optimization, because the arguments passed to sin and cos + didn't get unified into a single SSA_NAME in time for sincos. */ + +#include + +#define EPSILON 3.4526697709225118160247802734375e-4 + +static float my_sinf(float x) { + return (float) sin ((double) x); +} + +static float wrap_sinf(float x) { + if (fabs (x) < EPSILON) + return 0; + return my_sinf (x); +} + +static float my_cosf(float x) { + return (float) cos ((double) x); +} + +static float wrap_cosf(float x) { + if (fabs (x) < EPSILON) + return 1; + return my_cosf (x); +} + +float my_sin_cos(float x, float *s, float *c) { + *s = wrap_sinf (x); + *c = wrap_cosf (x); +} + +/* { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* *-w64-mingw* *-*-vxworks* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/sinatan-1.c b/SingleSource/Regression/C/gcc-dg/sinatan-1.c new file mode 100644 index 0000000000..cfbb771a01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sinatan-1.c @@ -0,0 +1,102 @@ +/* { dg-do run { target c99_runtime } } */ +/* { dg-options "-Ofast" } */ +/* { dg-add-options ieee } */ + +extern float sinf (float); +extern float cosf (float); +extern float atanf (float); +extern float sqrtf (float); +extern float nextafterf (float, float); +extern double sin (double); +extern double cos (double); +extern double atan (double); +extern double sqrt (double); +extern double nextafter (double, double); +extern long double sinl (long double); +extern long double cosl (long double); +extern long double atanl (long double); +extern long double sqrtl (long double); +extern long double nextafterl (long double, long double); + +extern void abort (); + +double __attribute__ ((noinline, optimize("Ofast"))) +sinatan (double x) +{ + return sin (atan (x)); +} + +double __attribute__ ((noinline, optimize("Ofast"))) +cosatan (double x) +{ + return cos (atan (x)); +} + +float __attribute__ ((noinline, optimize("Ofast"))) +sinatanf(float x) +{ + return sinf (atanf (x)); +} + +float __attribute__ ((noinline, optimize("Ofast"))) +cosatanf(float x) +{ + return cosf (atanf (x)); +} + +long double __attribute__ ((noinline, optimize("Ofast"))) +sinatanl (long double x) +{ + return sinl (atanl (x)); +} + +long double __attribute__ ((noinline, optimize("Ofast"))) +cosatanl (long double x) +{ + return cosl (atanl (x)); +} + +int +main() +{ + /* Get first x such that 1 + x*x will overflow */ + float fc = nextafterf (sqrtf (__FLT_MAX__ - 1), __FLT_MAX__); + double c = nextafter (sqrt (__DBL_MAX__ - 1), __DBL_MAX__); + long double lc = nextafterl (sqrtl (__LDBL_MAX__ - 1), __LDBL_MAX__); + + /* Force move from FPU to memory, otherwise comparison may + fail due to possible more accurate registers (see 387) */ + volatile float fy; + volatile double y; + volatile long double ly; + + fy = sinatanf (fc); + y = sinatan (c); + ly = sinatanl (lc); + + if (fy != 1.f || y != 1 || ly != 1.L) + abort (); + + fy = cosatanf (fc); + y = cosatan (c); + ly = cosatanl (lc); + + if (fy != 0.f || y != 0. || ly != 0.L) + abort (); + + fy = sinatanf (-fc); + y = sinatan (-c); + ly = sinatanl (-lc); + + if (fy != -1.f || y != -1. || ly != -1.L) + abort (); + + fy = cosatanf (-fc); + y = cosatan (-c); + ly = cosatanl (-lc); + + if (fy != 0.f || y != 0. || ly != 0.L) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sinatan-2.c b/SingleSource/Regression/C/gcc-dg/sinatan-2.c new file mode 100644 index 0000000000..64d6d30153 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sinatan-2.c @@ -0,0 +1,60 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ +/* { dg-require-effective-target c99_runtime } */ + +extern float sinf (float); +extern float cosf (float); +extern float atanf (float); +extern double sin (double); +extern double cos (double); +extern double atan (double); +extern long double sinl (long double); +extern long double cosl (long double); +extern long double atanl (long double); + +double __attribute__ ((noinline)) +sinatan_ (double x) +{ + return sin (atan (x)); +} + +double __attribute__ ((noinline)) +cosatan_ (double x) +{ + return cos (atan (x)); +} + +float __attribute__ ((noinline)) +sinatanf_(float x) +{ + return sinf (atanf (x)); +} + +float __attribute__ ((noinline)) +cosatanf_(float x) +{ + return cosf (atanf (x)); +} + +long double __attribute__ ((noinline)) +sinatanl_ (long double x) +{ + return sinl (atanl (x)); +} + +long double __attribute__ ((noinline)) +cosatanl_ (long double x) +{ + return cosl (atanl (x)); +} + +/* There must be no calls to sin, cos, or atan */ +/* { dg-final { scan-tree-dump-not "sin " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "cos " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "atan " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "sinf " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "cosf " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "atanf " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "sinl " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "cosl " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "atanl " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/sinatan-3.c b/SingleSource/Regression/C/gcc-dg/sinatan-3.c new file mode 100644 index 0000000000..600d475ba5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sinatan-3.c @@ -0,0 +1,65 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ + +extern float sinf (float); +extern float cosf (float); +extern float atanf (float); +extern double sin (double); +extern double cos (double); +extern double atan (double); +extern long double sinl (long double); +extern long double cosl (long double); +extern long double atanl (long double); + +float __attribute__ ((noinline)) +cosatanf_(float x) +{ + float atg = atanf(x); + return cosf(atg) + atg; +} + +double __attribute__ ((noinline)) +cosatan_(double x) +{ + double atg = atan(x); + return cos(atg) + atg; +} + +long double __attribute__ ((noinline)) +cosatanl_(long double x) +{ + long double atg = atanl(x); + return cosl(atg) + atg; +} + +float __attribute__ ((noinline)) +sinatanf_(float x) +{ + float atg = atanf(x); + return sinf(atg) + atg; +} + +double __attribute__ ((noinline)) +sinatan_(double x) +{ + double atg = atan(x); + return sin(atg) + atg; +} + +long double __attribute__ ((noinline)) +sinatanl_(long double x) +{ + long double atg = atanl(x); + return sinl(atg) + atg; +} + +/* There should be calls to both sin and atan */ +/* { dg-final { scan-tree-dump "cos " "optimized" } } */ +/* { dg-final { scan-tree-dump "sin " "optimized" } } */ +/* { dg-final { scan-tree-dump "atan " "optimized" } } */ +/* { dg-final { scan-tree-dump "cosf " "optimized" } } */ +/* { dg-final { scan-tree-dump "sinf " "optimized" } } */ +/* { dg-final { scan-tree-dump "atanf " "optimized" } } */ +/* { dg-final { scan-tree-dump "cosl " "optimized" } } */ +/* { dg-final { scan-tree-dump "sinl " "optimized" } } */ +/* { dg-final { scan-tree-dump "atanl " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/single-precision-constant.c b/SingleSource/Regression/C/gcc-dg/single-precision-constant.c new file mode 100644 index 0000000000..f1a9dc846a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/single-precision-constant.c @@ -0,0 +1,25 @@ +/* Test that double precision constants are correctly handled + when code is compiled with -fsingle-precision-constant */ +/* Origin: Carlos O'Donell */ + +/* { dg-do run } */ +/* { dg-options "-fsingle-precision-constant" } */ + +#include +#include + +#include "builtins-config.h" + +int main (void) +{ + int result = 0; + double local_DBL_MAX = DBL_MAX; + double local_DBL_MIN = DBL_MIN; +#ifdef HAVE_C99_RUNTIME + if (isinf (local_DBL_MAX)) + result |= 1; +#endif + if (local_DBL_MIN <= 0.0) + result |= 1; + return result; +} diff --git a/SingleSource/Regression/C/gcc-dg/sinhatanh-1.c b/SingleSource/Regression/C/gcc-dg/sinhatanh-1.c new file mode 100644 index 0000000000..e3a818be5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sinhatanh-1.c @@ -0,0 +1,62 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ + +extern float sinhf (float); +extern float coshf (float); +extern float atanhf (float); +extern float sqrtf (float); +extern double sinh (double); +extern double cosh (double); +extern double atanh (double); +extern double sqrt (double); +extern long double sinhl (long double); +extern long double coshl (long double); +extern long double atanhl (long double); +extern long double sqrtl (long double); + +double __attribute__ ((noinline)) +sinhatanh_ (double x) +{ + return sinh (atanh (x)); +} + +double __attribute__ ((noinline)) +coshatanh_ (double x) +{ + return cosh (atanh (x)); +} + +float __attribute__ ((noinline)) +sinhatanhf_(float x) +{ + return sinhf (atanhf (x)); +} + +float __attribute__ ((noinline)) +coshatanhf_(float x) +{ + return coshf (atanhf (x)); +} + +long double __attribute__ ((noinline)) +sinhatanhl_ (long double x) +{ + return sinhl (atanhl (x)); +} + +long double __attribute__ ((noinline)) +coshatanhl_ (long double x) +{ + return coshl (atanhl (x)); +} + +/* There must be no calls to sinh, cosh, or atanh */ +/* { dg-final { scan-tree-dump-not "sinh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "cosh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "atanh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "sinfh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "cosfh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "atanfh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "sinlh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "coslh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "atanlh " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/sinhatanh-2.c b/SingleSource/Regression/C/gcc-dg/sinhatanh-2.c new file mode 100644 index 0000000000..ca0b6162c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sinhatanh-2.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ + +extern float sinhf (float); +extern float coshf (float); +extern float atanhf (float); +extern float sqrtf (float); +extern double sinh (double); +extern double cosh (double); +extern double atanh (double); +extern double sqrt (double); +extern long double sinhl (long double); +extern long double coshl (long double); +extern long double atanhl (long double); +extern long double sqrtl (long double); + +float __attribute__ ((noinline)) +coshatanhf_(float x) +{ + float atg = atanhf(x); + return coshf(atg) + atg; +} + +double __attribute__ ((noinline)) +cosatan_(double x) +{ + double atg = atanh(x); + return cosh(atg) + atg; +} + +long double __attribute__ ((noinline)) +cosatanl_(long double x) +{ + long double atg = atanhl(x); + return coshl(atg) + atg; +} + +float __attribute__ ((noinline)) +sinatanf_(float x) +{ + float atg = atanhf(x); + return sinhf(atg) + atg; +} + +double __attribute__ ((noinline)) +sinatan_(double x) +{ + double atg = atanh(x); + return sinh(atg) + atg; +} + +long double __attribute__ ((noinline)) +sinatanl_(long double x) +{ + long double atg = atanhl(x); + return sinhl(atg) + atg; +} + +/* There should be calls to sinh, cosh and atanh */ +/* { dg-final { scan-tree-dump-times "cosh " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "sinh " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "atanh " "2" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "coshf " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "sinhf " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "atanhf " "2" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "coshl " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "sinhl " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "atanhl " "2" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/sinhatanh-3.c b/SingleSource/Regression/C/gcc-dg/sinhatanh-3.c new file mode 100644 index 0000000000..ad0353ae82 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sinhatanh-3.c @@ -0,0 +1,62 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fmath-errno -fdump-tree-optimized" } */ + +extern float sinhf (float); +extern float coshf (float); +extern float atanhf (float); +extern float sqrtf (float); +extern double sinh (double); +extern double cosh (double); +extern double atanh (double); +extern double sqrt (double); +extern long double sinhl (long double); +extern long double coshl (long double); +extern long double atanhl (long double); +extern long double sqrtl (long double); + +double __attribute__ ((noinline)) +sinhatanh_ (double x) +{ + return sinh (atanh (x)); +} + +double __attribute__ ((noinline)) +coshatanh_ (double x) +{ + return cosh (atanh (x)); +} + +float __attribute__ ((noinline)) +sinhatanhf_(float x) +{ + return sinhf (atanhf (x)); +} + +float __attribute__ ((noinline)) +coshatanhf_(float x) +{ + return coshf (atanhf (x)); +} + +long double __attribute__ ((noinline)) +sinhatanhl_ (long double x) +{ + return sinhl (atanhl (x)); +} + +long double __attribute__ ((noinline)) +coshatanhl_ (long double x) +{ + return coshl (atanhl (x)); +} + +/* There should be calls to sinh, cosh and atanh */ +/* { dg-final { scan-tree-dump-times "cosh " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "sinh " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "atanh " "2" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "coshf " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "sinhf " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "atanhf " "2" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "coshl " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "sinhl " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "atanhl " "2" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/sinhovercosh-1.c b/SingleSource/Regression/C/gcc-dg/sinhovercosh-1.c new file mode 100644 index 0000000000..564d3c51b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sinhovercosh-1.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ +/* { dg-require-effective-target c99_runtime } */ + +extern float sinhf (float); +extern float coshf (float); +extern float tanhf (float); +extern float sqrtf (float); +extern double sinh (double); +extern double cosh (double); +extern double sqrt (double); +extern double tanh (double); +extern long double sinhl (long double); +extern long double coshl (long double); +extern long double tanhl (long double); +extern long double sqrtl (long double); + +double __attribute__ ((noinline)) +sinhovercosh_ (double x) +{ + return sinh (x) / cosh (x); +} + +float __attribute__ ((noinline)) +sinhfovercoshf_(float x) +{ + return sinhf (x) / coshf (x); +} + +long double __attribute__ ((noinline)) +sinhlovercoshl_ (long double x) +{ + return sinhl (x) / coshl (x); +} + +/* There must be no calls to sinh, cosh, or atanh */ +/* { dg-final { scan-tree-dump-not "sinh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "cosh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "sinfh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "cosfh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "sinlh " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "coslh " "optimized" } } */ +/* { dg-final { scan-tree-dump-times "tanh " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "tanhl " "1" "optimized" } } */ +/* { dg-final { scan-tree-dump-times "tanhf " "1" "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/sizeof-1.c b/SingleSource/Regression/C/gcc-dg/sizeof-1.c new file mode 100644 index 0000000000..9541a4c273 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sizeof-1.c @@ -0,0 +1,4 @@ +/* PR c/27718 */ +/* { dg-do compile } */ + +int i = sizeof(struct A[]); /* { dg-error "incomplete" } */ diff --git a/SingleSource/Regression/C/gcc-dg/sizeof-2.c b/SingleSource/Regression/C/gcc-dg/sizeof-2.c new file mode 100644 index 0000000000..018ed740aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sizeof-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + + +void foo() +{ + sizeof(,); /* { dg-error "expected expression before" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/slp-1.c b/SingleSource/Regression/C/gcc-dg/slp-1.c new file mode 100644 index 0000000000..bb352020f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/slp-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model" } */ + +struct R { + double d1; + double d2; +}; + +struct R foo (struct R arg) +{ + struct R ret; + ret.d1 = arg.d2 * (0.0 - arg.d1); + ret.d2 = ret.d1; + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/smod-1.c b/SingleSource/Regression/C/gcc-dg/smod-1.c new file mode 100644 index 0000000000..9a847a1d66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/smod-1.c @@ -0,0 +1,25 @@ +/* PR middle-end/18045 */ +/* Contributed by Eric Botcazou */ + +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ +/* { dg-options "-std=c99 -mtune=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +#include + +extern void abort(void); + +long long smod16(long long x) +{ + return x % 16; +} + +int main(void) +{ +#if LLONG_MAX > 2147483647L + if (smod16 (0xFFFFFFFF) != 0xF) + abort (); +#endif + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-1.c b/SingleSource/Regression/C/gcc-dg/sms-1.c new file mode 100644 index 0000000000..098e1aa6e4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-1.c @@ -0,0 +1,42 @@ +/* The same test as loop-3c.c. It failed on ia64 + due to not handling of subreg in the lhs that is fixed. */ +/* { dg-do run } */ +/* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves -fdump-rtl-sms" } */ + + +#include +extern void abort (void); + +void * a[255]; + +__attribute__ ((noinline)) +void +f (int m) +{ + int i; + int sh = 0x100; + i = m; + do + { + a[sh >>= 1] = ((unsigned)i << 3) + (char*)a; + i += 4; + } + while (i < INT_MAX/2 + 1 + 4 * 4); +} + +int +main () +{ + a[0x10] = 0; + a[0x08] = 0; + f (INT_MAX/2 + INT_MAX/4 + 2); + if (a[0x10] || a[0x08]) + abort (); + a[0x10] = 0; + a[0x08] = 0; + f (INT_MAX/2 + 1); + if (! a[0x10] || a[0x08]) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/sms-10.c b/SingleSource/Regression/C/gcc-dg/sms-10.c new file mode 100644 index 0000000000..df3bba24ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-10.c @@ -0,0 +1,115 @@ + /* { dg-do run } */ + /* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves -fdump-rtl-sms" } */ + + +typedef __SIZE_TYPE__ size_t; +extern void *malloc (size_t); +extern void free (void *); +extern void abort (void); + +struct regstat_n_sets_and_refs_t +{ + int sets; + int refs; +}; + +struct regstat_n_sets_and_refs_t *regstat_n_sets_and_refs; + +struct df_reg_info +{ + unsigned int n_refs; +}; + +struct df_d +{ + struct df_reg_info **def_regs; + struct df_reg_info **use_regs; +}; +struct df_d *df; + +static inline int +REG_N_SETS (int regno) +{ + return regstat_n_sets_and_refs[regno].sets; +} + +__attribute__ ((noinline)) + int max_reg_num (void) +{ + return 100; +} + +__attribute__ ((noinline)) + void regstat_init_n_sets_and_refs (void) +{ + unsigned int i; + unsigned int max_regno = max_reg_num (); + + for (i = 0; i < max_regno; i++) + { + (regstat_n_sets_and_refs[i].sets = (df->def_regs[(i)]->n_refs)); + (regstat_n_sets_and_refs[i].refs = + (df->use_regs[(i)]->n_refs) + REG_N_SETS (i)); + } +} + +int a_sets[100] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 +}; + +int a_refs[100] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, + 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, + 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, + 118, 120, + 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, + 152, 154, 156, + 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, + 188, 190, 192, + 194, 196, 198 +}; + +int +main () +{ + struct df_reg_info *b[100], *c[100]; + struct df_d df1; + size_t s = sizeof (struct df_reg_info); + struct regstat_n_sets_and_refs_t a[100]; + + df = &df1; + regstat_n_sets_and_refs = a; + int i; + + for (i = 0; i < 100; i++) + { + b[i] = (struct df_reg_info *) malloc (s); + b[i]->n_refs = i; + c[i] = (struct df_reg_info *) malloc (s); + c[i]->n_refs = i; + } + + df1.def_regs = b; + df1.use_regs = c; + regstat_init_n_sets_and_refs (); + + for (i = 0; i < 100; i++) + if ((a[i].sets != a_sets[i]) || (a[i].refs != a_refs[i])) + abort (); + + for (i = 0; i < 100; i++) + { + free (b[i]); + free (c[i]); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-11.c b/SingleSource/Regression/C/gcc-dg/sms-11.c new file mode 100644 index 0000000000..11408f9e8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-11.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves -fdump-rtl-sms" } */ + +extern void abort (void); + +float out[4][4] = { 6, 6, 7, 5, 6, 7, 5, 5, 6, 4, 4, 4, 6, 2, 3, 4 }; + +void +invert (void) +{ + int i, j, k = 0, swap; + float tmp[4][4] = { 5, 6, 7, 5, 6, 7, 5, 5, 4, 4, 4, 4, 3, 2, 3, 4 }; + + for (i = 0; i < 4; i++) + { + for (j = i + 1; j < 4; j++) + if (tmp[j][i] > tmp[i][i]) + swap = j; + + if (swap != i) + tmp[i][k] = tmp[swap][k]; + } + + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + if (tmp[i][j] != out[i][j]) + abort (); +} + +int +main () +{ + invert (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/sms-12.c b/SingleSource/Regression/C/gcc-dg/sms-12.c new file mode 100644 index 0000000000..3ec50f272f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-12.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-skip-if "" { ! { aarch64*-*-* } } } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fmodulo-sched -funroll-loops -fdump-rtl-sms --param sms-min-sc=1 -fmodulo-sched-allow-regmoves -fPIC" } */ + +extern void abort (void); + +int X[1000]={0}; +int Y[1000]={0}; + +extern void abort (void); + +__attribute__ ((noinline)) +int +foo (int len, long a) +{ + int i; + long res = a; + + len = 1000; + for (i = 0; i < len; i++) + res += X[i]* Y[i]; + + if (res != 601) + abort (); + +} + +int +main () +{ + X[0] = Y[1] = 2; + Y[0] = X[1] = 21; + X[2] = Y[3] = 3; + Y[2] = X[3] = 31; + X[4] = Y[5] = 4; + Y[4] = X[5] = 41; + + foo (6, 3); + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/sms-13.c b/SingleSource/Regression/C/gcc-dg/sms-13.c new file mode 100644 index 0000000000..cd7bb62006 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-13.c @@ -0,0 +1,32 @@ +/* PR target/83507 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fmodulo-sched -fno-tree-ter -fno-tree-coalesce-vars" } */ + +void +foo (unsigned short int x, unsigned char y) +{ + unsigned char *a = &y; + unsigned short int b; + int c; + + while (y < 3) + { + if (x != 0) + ++y; + ++y; + } + + for (c = 0; c < 5; ++c) + { + int d = 1; + d += b > x; + y &= d; + } + + do + { + c += y; + x = c; + } + while (x != 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-2.c b/SingleSource/Regression/C/gcc-dg/sms-2.c new file mode 100644 index 0000000000..f8375f9f05 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-2.c @@ -0,0 +1,33 @@ +/* The same test as 921011-1.c. It can fails on gcc 4.1 due to a dfs + traversal of the loops after versioning. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fmodulo-sched -fdump-rtl-sms" } */ + +int th, h, em, nlwm, nlwS, nlw, sy; +void +fun (nb) + int nb; +{ + + while (nb--) + while (h--) + { + nlw = nlwm; + while (nlw) + { + if (nlwS == 1) + { + } + else + if (nlwS == 1) + { + } + nlwS--; nlw--; + } + if (em) + nlwS--; + if (++sy == th) + sy = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-3.c b/SingleSource/Regression/C/gcc-dg/sms-3.c new file mode 100644 index 0000000000..5e56ecf761 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-3.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fmodulo-sched -funroll-loops -fdump-rtl-sms --param sms-min-sc=1 -fmodulo-sched-allow-regmoves" } */ +/* { dg-options "-O2 -fmodulo-sched -funroll-loops -fdump-rtl-sms --param sms-min-sc=1 -fmodulo-sched-allow-regmoves -fno-sched-pressure" { target powerpc*-*-* } } */ + +extern void abort (void); + +int X[1000]={0}; +int Y[1000]={0}; + +extern void abort (void); + +__attribute__ ((noinline)) +int +foo (int len, long a) +{ + int i; + long res = a; + + len = 1000; + for (i = 0; i < len; i++) + res += X[i]* Y[i]; + + if (res != 601) + abort (); + +} + +int +main () +{ + X[0] = Y[1] = 2; + Y[0] = X[1] = 21; + X[2] = Y[3] = 3; + Y[2] = X[3] = 31; + X[4] = Y[5] = 4; + Y[4] = X[5] = 41; + + foo (6, 3); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-4.c b/SingleSource/Regression/C/gcc-dg/sms-4.c new file mode 100644 index 0000000000..8416b8b9ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-4.c @@ -0,0 +1,36 @@ +/* Inspired from bitmap_or_and function in sbitmap.c. */ +/* { dg-do run } */ +/* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves -fdump-rtl-sms" } */ +/* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves -fdump-rtl-sms --param sms-min-sc=1" { target powerpc*-*-* } } */ + +extern void abort (void); + +int a[5] = { 0, 1, 0, 0, 0 }; +int b[5] = { 0, 1, 0, 1, 0 }; +int c[5] = { 0, 0, 1, 1, 0 }; +int dst[5] = { 0, 0, 0, 0, 0 }; + +__attribute__ ((noinline)) +void +foo (int size, int *ap, int *bp, int *cp, int *dstp) +{ + unsigned int i, n = size; + int changed = 0; + + for (i = 0; i < n; i++) + { + const int tmp = *ap++ | (*bp++ & *cp++); + changed |= *dstp ^ tmp; + *dstp++ = tmp; + } + + if (changed == 0) + abort (); +} + +int +main () +{ + foo (5, a, b, c, dst); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-5.c b/SingleSource/Regression/C/gcc-dg/sms-5.c new file mode 100644 index 0000000000..9ce36a0b69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-5.c @@ -0,0 +1,50 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves -funroll-loops -fdump-rtl-sms --param sms-min-sc=1" } */ +/* This is the same test as loop-2e.c test. It is related to a fix in + the generation of the prolog and epilog. */ + +extern void abort (void); + +__attribute__ ((noinline)) +void f (int *p, int **q) +{ + int i; + for (i = 0; i < 40; i++) + { + *q++ = &p[i]; + } +} + +int main () +{ + void *p; + int *q[40]; + __SIZE_TYPE__ start; + + /* Find the signed middle of the address space. */ + if (sizeof(start) == sizeof(int)) + start = (__SIZE_TYPE__) __INT_MAX__; + else if (sizeof(start) == sizeof(long)) + start = (__SIZE_TYPE__) __LONG_MAX__; + else if (sizeof(start) == sizeof(long long)) + start = (__SIZE_TYPE__) __LONG_LONG_MAX__; + else + return 0; + + /* Arbitrarily align the pointer. */ + start &= -32; + + /* Pretend that's good enough to start address arithmetic. */ + p = (void *)start; + + /* Verify that GIV replacement computes the correct results. */ + q[39] = 0; + f (p, q); + if (q[39] != (int *)p + 39) + abort (); + + return 0; +} + + + diff --git a/SingleSource/Regression/C/gcc-dg/sms-6.c b/SingleSource/Regression/C/gcc-dg/sms-6.c new file mode 100644 index 0000000000..d6fa45a2cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-6.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-require-effective-target size32plus } */ +/* { dg-options "-O2 -fmodulo-sched -fdump-rtl-sms --param sms-min-sc=1" } */ +/* { dg-options "-O2 -fmodulo-sched -fdump-rtl-sms --param sms-min-sc=1 -fmodulo-sched-allow-regmoves -fno-sched-pressure" { target powerpc*-*-* } } */ + +extern void abort (void); + +__attribute__ ((noinline)) +void foo (int * __restrict__ a, int * __restrict__ b, int * __restrict__ c) +{ + int i; + for(i = 0; i < 100; i+=4) + { + a[i] = b[i] * c[i]; + a[i+1] = b[i+1] * c[i+1]; + a[i+2] = b[i+2] * c[i+2]; + a[i+3] = b[i+3] * c[i+3]; + } +} + +int a[100], b[100], c[100]; + +int main() +{ + int i; + int res; + + for(i = 0; i < 100; i++) + { + b[i] = c[i] = i; + } + foo(a, b, c); + + res = 0; + for(i = 0; i < 100; i++) + { + res += a[i]; + } + if(res != 328350) + abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-7.c b/SingleSource/Regression/C/gcc-dg/sms-7.c new file mode 100644 index 0000000000..4fd9bf1e91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-7.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fmodulo-sched -fstrict-aliasing -fdump-rtl-sms -fmodulo-sched-allow-regmoves --param sms-min-sc=1" } */ + +extern void abort (void); + +__attribute__ ((noinline)) +void foo (int * __restrict__ a, int * __restrict__ b, short * c) +{ + int i; + for(i = 0; i < 100; i+=4) + { + a[i] = b[i] * c[i]; + a[i+1] = b[i+1] * c[i+1]; + a[i+2] = b[i+2] * c[i+2]; + a[i+3] = b[i+3] * c[i+3]; + } +} + +int a[100], b[100]; +short c[100]; + +int main() +{ +#if (__SIZEOF_INT__ <= 2) + int i; + long res; +#else + int i, res; +#endif + for(i = 0; i < 100; i++) + { + b[i] = c[i] = i; + } + foo(a, b, c); + + res = 0; + for(i = 0; i < 100; i++) + { + res += a[i]; + } + if(res != 328350) + abort(); + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/sms-8.c b/SingleSource/Regression/C/gcc-dg/sms-8.c new file mode 100644 index 0000000000..dc0a3fc1f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-8.c @@ -0,0 +1,36 @@ +/* This test is a reduced test case for a bug that caused + bootstrapping with -fmodulo-sched. Related to a broken anti-dep + that was not fixed by reg-moves. */ + + /* { dg-do run } */ + /* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves -fdump-rtl-sms --param sms-min-sc=1" } */ + +extern void abort (void); + +__attribute__ ((noinline)) +unsigned long long +foo (long long ixi, unsigned ctr) +{ + unsigned long long irslt = 1; + long long ix = ixi; + + for (; ctr; ctr--) + { + irslt *= ix; + ix *= ix; + } + + if (irslt != 14348907) + abort (); + return irslt; +} + + +int +main () +{ + unsigned long long res; + + res = foo (3, 4); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-9.c b/SingleSource/Regression/C/gcc-dg/sms-9.c new file mode 100644 index 0000000000..c8dc28104a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-9.c @@ -0,0 +1,60 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fmodulo-sched -fmodulo-sched-allow-regmoves" } */ + +#include +#include + +struct df_ref_info +{ + unsigned int *begin; + unsigned int *count; +}; + +extern void *memset (void *s, int c, __SIZE_TYPE__ n); + + +__attribute__ ((noinline)) +int +df_reorganize_refs_by_reg_by_insn (struct df_ref_info *ref_info, + int num, unsigned int start) +{ + unsigned int m = num; + unsigned int offset = 77; + unsigned int r; + + for (r = start; r < m; r++) + { + ref_info->begin[r] = offset; + offset += ref_info->count[r]; + ref_info->count[r] = 0; + } + + return offset; +} + +int +main () +{ + struct df_ref_info temp; + int num = 100; + unsigned int start = 5; + int i, offset; + + temp.begin = malloc (100 * sizeof (unsigned int)); + temp.count = malloc (100 * sizeof (unsigned int)); + + memset (temp.begin, 0, sizeof (unsigned int) * num); + memset (temp.count, 0, sizeof (unsigned int) * num); + + for (i = 0; i < num; i++) + temp.count[i] = i + 1; + + offset = df_reorganize_refs_by_reg_by_insn (&temp, num, start); + + if (offset != 5112) + abort (); + + free (temp.begin); + free (temp.count); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-compare-debug-1.c b/SingleSource/Regression/C/gcc-dg/sms-compare-debug-1.c new file mode 100644 index 0000000000..96b376c392 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-compare-debug-1.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug -fmodulo-sched --param sms-min-sc=1" } */ + +int a, c, e, f, g; +void +h (int i) +{ + a = i; +} +void +j (char *i, long k) +{ + while (k--) + c = *i++; +} +void +l (unsigned char *i, long k) +{ + unsigned char *b = i + k; + while (i < b) + { + h (*i); + i++; + } +} +void +m () +{ + while (e) + { + float d = g; + l ((char *) &d, sizeof (g)); + if (f) + j ((char *) &d, sizeof (g)); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/sms-compare-debug-2.c b/SingleSource/Regression/C/gcc-dg/sms-compare-debug-2.c new file mode 100644 index 0000000000..dca7b65c08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sms-compare-debug-2.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug -fmodulo-sched" } */ + +struct S { int f; signed int g : 2; } a[1], c = {5, 1}, d; +short b; + +__attribute__((noinline, noclone)) void +foo (int x) +{ + if (x != 1) + __builtin_abort (); +} + +int +main () +{ + while (b++ <= 0) + { + struct S e = {1, 1}; + d = e = a[0] = c; + } + foo (a[0].g); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/spec-barrier-3.c b/SingleSource/Regression/C/gcc-dg/spec-barrier-3.c new file mode 100644 index 0000000000..3ed4d39061 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spec-barrier-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Wpedantic" } */ + +/* __builtin_speculation_safe_value returns a value with the same type + as its first argument. There should be a warning if that isn't + type-compatible with the use. */ +int * +f (int x) +{ + return __builtin_speculation_safe_value (x); /* { dg-warning "returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" } */ +} + +/* { dg-prune-output "this target does not define a speculation barrier;" } */ diff --git a/SingleSource/Regression/C/gcc-dg/spec-options.c b/SingleSource/Regression/C/gcc-dg/spec-options.c new file mode 100644 index 0000000000..01d0a0929e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spec-options.c @@ -0,0 +1,16 @@ +/* Check that -mfoo is accepted if defined in a user spec + and that it is not passed on the command line. */ +/* Must be processed in EXTRA_SPECS to run. */ +/* { dg-do run } */ +/* { dg-options "-B${srcdir}/gcc.dg --specs=foo.specs -tfoo" } */ + +extern void abort(void); + +int main(void) +{ +#ifdef FOO + return 0; +#else + abort(); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-fields-2.c b/SingleSource/Regression/C/gcc-dg/spellcheck-fields-2.c new file mode 100644 index 0000000000..76684f71c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-fields-2.c @@ -0,0 +1,40 @@ +/* { dg-options "-fdiagnostics-show-caret" } */ + +union u +{ + int color; + int shape; +}; + +int test (union u *ptr) +{ + return ptr->colour; /* { dg-error "did you mean .color.?" } */ + +/* Verify that we get an underline and a fixit hint. */ +/* { dg-begin-multiline-output "" } + return ptr->colour; + ^~~~~~ + color + { dg-end-multiline-output "" } */ +} + + +/* Verify that we don't offer a fixit hint in the presence of + a macro. */ +int test_macro (union u *ptr) +{ +#define FIELD colour /* { dg-error "did you mean .color.?" } */ + return ptr->FIELD; + +/* { dg-begin-multiline-output "" } + #define FIELD colour + ^~~~~~ + { dg-end-multiline-output "" } */ + +/* { dg-begin-multiline-output "" } + return ptr->FIELD; + ^~~~~ + { dg-end-multiline-output "" } */ + +#undef FIELD +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-fields-3.c b/SingleSource/Regression/C/gcc-dg/spellcheck-fields-3.c new file mode 100644 index 0000000000..003a0b5ea2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-fields-3.c @@ -0,0 +1,66 @@ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-show-caret -std=c99" } */ + +/* Tests of incorrect name initializers. + Verify that we get underlines and, where appropriate, fixit hints. */ + +struct foo +{ + int foo; + int bar; +}; + +union u +{ + int color; + int shape; +}; + +/* Old-style named initializers. */ + +struct foo old_style_f = { + foa: 1, /* { dg-error ".struct foo. has no member named .foa.; did you mean .foo." } */ +/* { dg-begin-multiline-output "" } + foa: 1, + ^~~ + foo + { dg-end-multiline-output "" } */ + + this_does_not_match: 3 /* { dg-error ".struct foo. has no member named .this_does_not_match." } */ + +/* { dg-begin-multiline-output "" } + this_does_not_match: 3 + ^~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +}; + +union u old_style_u = { colour: 3 }; /* { dg-error ".union u. has no member named .colour.; did you mean .color.?" } */ +/* { dg-begin-multiline-output "" } + union u old_style_u = { colour: 3 }; + ^~~~~~ + color + { dg-end-multiline-output "" } */ + +/* C99-style named initializers. */ + +struct foo c99_style_f = { + .foa = 1, /* { dg-error ".struct foo. has no member named .foa.; did you mean .foo." } */ +/* { dg-begin-multiline-output "" } + .foa = 1, + ^~~ + foo + { dg-end-multiline-output "" } */ + + .this_does_not_match = 3 /* { dg-error ".struct foo. has no member named .this_does_not_match." } */ +/* { dg-begin-multiline-output "" } + .this_does_not_match = 3 + ^~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ +}; + +union u c99_style_u = { .colour=3 }; /* { dg-error ".union u. has no member named .colour.; did you mean .color.?" } */ +/* { dg-begin-multiline-output "" } + union u c99_style_u = { .colour=3 }; + ^~~~~~ + color + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-fields.c b/SingleSource/Regression/C/gcc-dg/spellcheck-fields.c new file mode 100644 index 0000000000..44e05e5542 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-fields.c @@ -0,0 +1,63 @@ +/* { dg-do compile } */ + +struct foo +{ + int foo; + int bar; + int baz; +}; + +int test (struct foo *ptr) +{ + return ptr->m_bar; /* { dg-error "'struct foo' has no member named 'm_bar'; did you mean 'bar'?" } */ +} + +int test2 (void) +{ + struct foo instance = {0, 0, 0}; + return instance.m_bar; /* { dg-error "'struct foo' has no member named 'm_bar'; did you mean 'bar'?" } */ +} + +struct s { + struct j { int aa; } kk; + int ab; +}; + +void test3 (struct s x) +{ + x.ac; /* { dg-error "'struct s' has no member named 'ac'; did you mean 'ab'?" } */ +} + +int test4 (struct foo *ptr) +{ + return sizeof (ptr->foa); /* { dg-error "'struct foo' has no member named 'foa'; did you mean 'foo'?" } */ +} + +/* Verify that we don't offer nonsensical suggestions. */ + +int test5 (struct foo *ptr) +{ + return ptr->this_is_unlike_any_of_the_fields; /* { dg-bogus "did you mean" } */ + /* { dg-error "has no member named" "" { target *-*-* } .-1 } */ +} + +union u +{ + int color; + int shape; +}; + +int test6 (union u *ptr) +{ + return ptr->colour; /* { dg-error "'union u' has no member named 'colour'; did you mean 'color'?" } */ +} + +struct has_anon +{ + struct { int color; } s; +}; + +int test7 (struct has_anon *ptr) +{ + return ptr->s.colour; /* { dg-error "'struct ' has no member named 'colour'; did you mean 'color'?" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-2.c b/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-2.c new file mode 100644 index 0000000000..ad6e9d3191 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-2.c @@ -0,0 +1,33 @@ +/* PR c/71858 */ +/* Make sure anticipated builtins are not considered before they are declared. */ +/* { dg-do compile } */ +/* { dg-options "-Wimplicit-function-declaration -fdiagnostics-show-caret" } */ + +int sscafn (const char *, const char *, ...); + +int +test_1 (const char *p) +{ + int i; + return ssacnf (p, "%d", &i); /* { dg-warning "10: implicit declaration of function .ssacnf.; did you mean .sscafn.?" } */ + /* { dg-begin-multiline-output "" } + return ssacnf (p, "%d", &i); + ^~~~~~ + sscafn + { dg-end-multiline-output "" } */ +} + +int scafn (const char *, ...); +int scanf (const char *, ...); + +int +test_2 (void) +{ + int i; + return sacnf ("%d", &i); /* { dg-warning "10: implicit declaration of function .sacnf.; did you mean .scanf.?" } */ + /* { dg-begin-multiline-output "" } + return sacnf ("%d", &i); + ^~~~~ + scanf + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-3.c b/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-3.c new file mode 100644 index 0000000000..94f4078d0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-3.c @@ -0,0 +1,45 @@ +/* PR c/71858 */ +/* Only consider function names, function pointers and macros for implicit function declarations. */ +/* { dg-do compile } */ +/* { dg-options "-Wimplicit-function-declaration -fdiagnostics-show-caret" } */ + +void fn1abcd (void); + +void +test_1 (int fn1bacd) +{ + fn1badc (); /* { dg-warning "3: implicit declaration of function .fn1badc.; did you mean .fn1abcd.?" } */ + /* { dg-begin-multiline-output "" } + fn1badc (); + ^~~~~~~ + fn1abcd + { dg-end-multiline-output "" } */ +} + +void fn2efgh (void); +void (*fn2efhg) (void); + +void +test_2 (void) +{ + fn2fehg (); /* { dg-warning "3: implicit declaration of function .fn2fehg.; did you mean .fn2efhg.?" } */ + /* { dg-begin-multiline-output "" } + fn2fehg (); + ^~~~~~~ + fn2efhg + { dg-end-multiline-output "" } */ +} + +void fn3ijkl (void); +typedef int fn3ijlk; + +void +test_3 (void) +{ + fn3jilk (); /* { dg-warning "3: implicit declaration of function .fn3jilk.; did you mean .fn3ijkl.?" } */ + /* { dg-begin-multiline-output "" } + fn3jilk (); + ^~~~~~~ + fn3ijkl + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-4.c b/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-4.c new file mode 100644 index 0000000000..f9b7d8d0ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers-4.c @@ -0,0 +1,10 @@ +/* { dg-options "-Wimplicit-function-declaration" } */ + +extern double sqrt (double); + +void test (float pf, float inff) +{ + assert (pf == inff); /* { dg-bogus "sqrt" } */ + /* { dg-warning "implicit declaration of function 'assert'" "" { target *-*-* } .-1 } */ + /* { dg-message "header ''" "" { target *-*-* } .-2 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers.c b/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers.c new file mode 100644 index 0000000000..063e3f9eda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-identifiers.c @@ -0,0 +1,136 @@ +/* { dg-do compile } */ +/* { dg-options "-Wimplicit-function-declaration -fdiagnostics-show-caret" } */ + +typedef struct GtkWidget { int dummy; } GtkWidget; + +extern void gtk_widget_show_all (GtkWidget *w); + +void +test_1 (GtkWidget *w) +{ + gtk_widget_showall (w); /* { dg-warning "3: implicit declaration of function .gtk_widget_showall.; did you mean .gtk_widget_show_all.?" } */ + /* { dg-begin-multiline-output "" } + gtk_widget_showall (w); + ^~~~~~~~~~~~~~~~~~ + gtk_widget_show_all + { dg-end-multiline-output "" } */ + + /* Ensure we don't try to suggest "gtk_widget_showall" for subsequent + corrections. */ + gtk_widget_showall_ (w); /* { dg-warning "3: implicit declaration of function .gtk_widget_showall_.; did you mean .gtk_widget_show_all.?" } */ + /* { dg-begin-multiline-output "" } + gtk_widget_showall_ (w); + ^~~~~~~~~~~~~~~~~~~ + gtk_widget_show_all + { dg-end-multiline-output "" } */ + + GtkWidgetShowAll (w); /* { dg-warning "3: implicit declaration of function .GtkWidgetShowAll.; did you mean .gtk_widget_show_all.?" } */ + /* { dg-begin-multiline-output "" } + GtkWidgetShowAll (w); + ^~~~~~~~~~~~~~~~ + gtk_widget_show_all + { dg-end-multiline-output "" } */ +} + +int +test_2 (int param) +{ + return parma * parma; /* { dg-error "10: .parma. undeclared .first use in this function.; did you mean .param." } */ + /* { dg-begin-multiline-output "" } + return parma * parma; + ^~~~~ + param + { dg-end-multiline-output "" } */ +} + +#define MACRO(X) ((X)) + +int +test_3 (int i) +{ + return MACRAME (i); /* { dg-warning "10: implicit declaration of function .MACRAME.; did you mean .MACRO.?" } */ + /* { dg-begin-multiline-output "" } + return MACRAME (i); + ^~~~~~~ + MACRO + { dg-end-multiline-output "" } */ +} + +#define IDENTIFIER_POINTER(X) ((X)) + +int +test_4 (int node) +{ + return IDENTIFIER_PTR (node); /* { dg-warning "10: implicit declaration of function .IDENTIFIER_PTR.; did you mean .IDENTIFIER_POINTER.?" } */ + /* { dg-begin-multiline-output "" } + return IDENTIFIER_PTR (node); + ^~~~~~~~~~~~~~ + IDENTIFIER_POINTER + { dg-end-multiline-output "" } */ +} + + +int +test_5 (void) +{ + return __LINE_; /* { dg-error "10: .__LINE_. undeclared .first use in this function.; did you mean .__LINE__." } */ + /* { dg-begin-multiline-output "" } + return __LINE_; + ^~~~~~~ + __LINE__ + { dg-end-multiline-output "" } */ +} + +#define MAX_ITEMS 100 +int array[MAX_ITEM]; /* { dg-error "11: .MAX_ITEM. undeclared here .not in a function.; did you mean .MAX_ITEMS." } */ + /* { dg-begin-multiline-output "" } + int array[MAX_ITEM]; + ^~~~~~~~ + MAX_ITEMS + { dg-end-multiline-output "" } */ + + +enum foo { + FOO_FIRST, + FOO_SECOND +}; + +int +test_6 (enum foo f) +{ + switch (f) + { + case FOO_FURST: /* { dg-error "10: .FOO_FURST. undeclared .first use in this function.; did you mean .FOO_FIRST." } */ + break; + /* { dg-begin-multiline-output "" } + case FOO_FURST: + ^~~~~~~~~ + FOO_FIRST + { dg-end-multiline-output "" } */ + + case FOO_SECCOND: /* { dg-error "10: .FOO_SECCOND. undeclared .first use in this function.; did you mean .FOO_SECOND." } */ + break; + /* { dg-begin-multiline-output "" } + case FOO_SECCOND: + ^~~~~~~~~~~ + FOO_SECOND + { dg-end-multiline-output "" } */ + + default: + break; + } +} + +int snprintf (char *, __SIZE_TYPE__, const char *, ...); + +void +test_7 (int i, int j) +{ + int buffer[100]; + snprint (buffer, 100, "%i of %i", i, j); /* { dg-warning "3: implicit declaration of function .snprint.; did you mean .snprintf.." } */ + /* { dg-begin-multiline-output "" } + snprint (buffer, 100, "%i of %i", i, j); + ^~~~~~~ + snprintf + { dg-end-multiline-output "" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-inttypes.c b/SingleSource/Regression/C/gcc-dg/spellcheck-inttypes.c new file mode 100644 index 0000000000..24e075433f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-inttypes.c @@ -0,0 +1,82 @@ +/* { dg-options "-std=c99" } */ +/* Prevent AIX from implicitly including inttypes.h. */ +#ifdef _AIX +#define _STD_TYPES_T +#endif +#include +#include +/* Missing . */ + +int8_t i8; +int16_t i16; +int32_t i32; +int64_t i64; + +intptr_t ip; +uintptr_t up; + +/* As an identifier. */ +const char *hex8_fmt = PRIx8; /* { dg-error "'PRIx8' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIx8' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +const char *hex16_fmt = PRIx16; /* { dg-error "'PRIx16' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIx16' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +const char *hex32_fmt = PRIx32; /* { dg-error "'PRIx32' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIx32' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +const char *hex64_fmt = PRIx64; /* { dg-error "'PRIx64' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIx64' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +const char *hexptr_fmt = PRIxPTR; /* { dg-error "'PRIxPTR' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIxPTR' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + +/* As a part of a string-literal. */ +const char *dec8msg_fmt = "Provide %" PRId8 "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */ +/* { dg-message "'PRId8' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +const char *dec16msg_fmt = "Provide %" PRId16 "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */ +/* { dg-message "'PRId16' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +const char *dec32msg_fmt = "Provide %" PRId32 "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */ +/* { dg-message "'PRId32' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +const char *dec64msg_fmt = "Provide %" PRId64 "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */ +/* { dg-message "'PRId64' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +const char *decptrmsg_fmt = "Provide %" PRIdPTR "\n"; /* { dg-error "expected" "expected string-literal" { target *-*-* } } */ +/* { dg-message "'PRIdPTR' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + +void test_printf (void) +{ + printf ("some format strings %s, %s, %s, %s, %s, %s\n", + PRId8, /* { dg-error "'PRId8' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRId8' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + PRIi16, /* { dg-error "'PRIi16' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIi16' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + PRIo32, /* { dg-error "'PRIo32' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIo32' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + PRIu64, /* { dg-error "'PRIu64' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIu64' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + PRIoPTR); /* { dg-error "'PRIoPTR' undeclared" "undeclared identifier" { target *-*-* } } */ +/* { dg-message "'PRIoPTR' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + + printf ("%" PRIo8 "\n", i8); /* { dg-error "expected" } */ +/* { dg-message "'PRIo8' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + printf ("%" PRIo16 "\n", i16); /* { dg-error "expected" } */ +/* { dg-message "'PRIo16' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + printf ("%" PRIo32 "\n", i32); /* { dg-error "expected" } */ +/* { dg-message "'PRIo32' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + printf ("%" PRIo64 "\n", i64); /* { dg-error "expected" } */ +/* { dg-message "'PRIo64' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + printf ("%" PRIoPTR "\n", ip); /* { dg-error "expected" } */ +/* { dg-message "'PRIoPTR' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +} + +void test_scanf (void) +{ + scanf ("%" SCNu8 "\n", &i8); /* { dg-error "expected" } */ +/* { dg-message "'SCNu8' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + scanf ("%" SCNu16 "\n", &i16); /* { dg-error "expected" } */ +/* { dg-message "'SCNu16' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + scanf ("%" SCNu32 "\n", &i32); /* { dg-error "expected" } */ +/* { dg-message "'SCNu32' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + scanf ("%" SCNu64 "\n", &i64); /* { dg-error "expected" } */ +/* { dg-message "'SCNu64' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + scanf ("%" SCNuPTR "\n", &ip); /* { dg-error "expected" } */ +/* { dg-message "'SCNuPTR' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ + scanf ("%" SCNxPTR "\n", &up); /* { dg-error "expected" } */ +/* { dg-message "'SCNxPTR' is defined in header ''; this is probably fixable by adding '#include '" "replacement note" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-1.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-1.c new file mode 100644 index 0000000000..bebb494b6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-1.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-Wcoercion" } */ +/* { dg-error "unrecognized command-line option '-Wcoercion'; did you mean '-Wconversion'?" "" { target *-*-* } 0 } */ + diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-10.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-10.c new file mode 100644 index 0000000000..77c6b5494f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-10.c @@ -0,0 +1,6 @@ +/* Verify that we include -Wno- variants when considering hints + for misspelled options (PR driver/69453). */ + +/* { dg-do compile } */ +/* { dg-options "-fno-if-convert" } */ +/* { dg-error "unrecognized command-line option .-fno-if-convert.; did you mean .-fno-if-conversion.?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-11.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-11.c new file mode 100644 index 0000000000..8e271416aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-11.c @@ -0,0 +1,7 @@ +/* Verify that we provide a hint if the user misspells an option argument + (PR driver/69265). */ + +/* { dg-do compile } */ +/* { dg-options "-ftls-model=global-dinamic" } */ +/* { dg-error "unknown TLS model 'global-dinamic'" "" { target *-*-* } 0 } */ +/* { dg-message "valid arguments to '-ftls-model=' are: global-dynamic initial-exec local-dynamic local-exec; did you mean 'global-dynamic'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-12.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-12.c new file mode 100644 index 0000000000..9fbd944bca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-12.c @@ -0,0 +1,7 @@ +/* Verify that we don't include -Wno- variants for options marked + with RejectNegative when considering hints for misspelled options + (PR driver/71651). */ + +/* { dg-do compile } */ +/* { dg-options "-fno-stack-protector-explicit" } */ +/* { dg-error "unrecognized command-line option .-fno-stack-protector-explicit.; did you mean .-fstack-protector-explicit.." "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-13.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-13.c new file mode 100644 index 0000000000..94db0c5a45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-13.c @@ -0,0 +1,5 @@ +/* PR driver/78863. */ + +/* { dg-do compile } */ +/* { dg-options "-fsanitize" } */ +/* { dg-error "unrecognized command-line option '-fsanitize'; did you mean '-fsanitize='?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-14.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-14.c new file mode 100644 index 0000000000..3cd38ce289 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-14.c @@ -0,0 +1,8 @@ +/* Verify that we offer suggestions for misspelled sanitizer options + (PR driver/78877). */ + +/* { dg-do compile } */ +/* { dg-options "-fsanitize=addres,nul,this-is-not-a-sanitizer-option" } */ +/* { dg-error "unrecognized argument to '-fsanitize=' option: 'addres'; did you mean 'address'" "" { target *-*-* } 0 } */ +/* { dg-error "unrecognized argument to '-fsanitize=' option: 'nul'; did you mean 'null'" "" { target *-*-* } 0 } */ +/* { dg-error "unrecognized argument to '-fsanitize=' option: 'this-is-not-a-sanitizer-option'" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-15.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-15.c new file mode 100644 index 0000000000..c1903345d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-15.c @@ -0,0 +1,7 @@ +/* Verify that we don't offer -fsanitize=all as a suggestion for misspelled + sanitizer options (PR driver/78877). */ + +/* { dg-do compile } */ +/* { dg-options "-fsanitize=al" } */ +/* { dg-bogus "did you mean" "" { target *-*-* } 0 } */ +/* { dg-error "unrecognized argument to '-fsanitize=' option: 'al'" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-16.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-16.c new file mode 100644 index 0000000000..f802e61b66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-16.c @@ -0,0 +1,9 @@ +/* Verify that we don't offer non-recoverable options as suggestions + for misspelled -fsanitize-recover= arguments (PR driver/78877). */ + +/* { dg-do compile } */ +/* { dg-options "-fsanitize-recover=threed" } */ +/* Ensure we don't offer non-recoverable "-fsanitize-recover=thread" + as a suggestion. */ +/* { dg-bogus "did you mean" "" { target *-*-* } 0 } */ +/* { dg-error "unrecognized argument to '-fsanitize-recover=' option: 'threed'" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-17.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-17.c new file mode 100644 index 0000000000..6be5d271e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-17.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-sanitize=threed" } */ +/* { dg-error "unrecognized argument to '-fno-sanitize=' option: 'threed'; did you mean 'thread'" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-18.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-18.c new file mode 100644 index 0000000000..26694f945a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-18.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-fprofile-update" } */ +/* { dg-error "unrecognized command-line option '-fprofile-update'; did you mean '-fprofile-update='?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-19.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-19.c new file mode 100644 index 0000000000..68e85a71d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-19.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-sanitize" } */ +/* { dg-error "unrecognized command-line option '-fno-sanitize'; did you mean '-fno-sanitize='?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-2.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-2.c new file mode 100644 index 0000000000..5156ad3ef1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-2.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-Wthis-should-not-get-a-hint" } */ +/* { dg-bogus "did you mean" "" { target *-*-* } 0 } */ +/* { dg-error "unrecognized command-line option '-Wthis-should-not-get-a-hint'" "" { target *-*-* } 0 } */ + diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-20.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-20.c new file mode 100644 index 0000000000..d856d5a081 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-20.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-Walloc-size-larger-than" } */ +/* { dg-error "unrecognized command-line option '-Walloc-size-larger-than'; did you mean '-Walloc-size-larger-than='?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-21.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-21.c new file mode 100644 index 0000000000..3238af6b3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-21.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-flto=sparta" } */ +/* { dg-error "unrecognized argument to '-flto=' option: 'sparta'" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-22.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-22.c new file mode 100644 index 0000000000..b0ddae2e78 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-22.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-ipa-ynline" } */ +/* { dg-error "unrecognized command-line option '-fdump-ipa-ynline'; did you mean '-fdump-ipa-inline'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-23.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-23.c new file mode 100644 index 0000000000..575a28da50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-23.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize-coverage=tracecmp" } */ + +/* { dg-error "unrecognized argument in option '-fsanitize-coverage=tracecmp'" "" { target *-*-* } 0 } */ +/* { dg-message "valid arguments to '-fsanitize-coverage=' are: trace-cmp trace-pc; did you mean 'trace-cmp'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-24.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-24.c new file mode 100644 index 0000000000..1bd6cc29be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-24.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize-coverage=trace-pc,tracecmp" } */ + +/* { dg-error "unrecognized argument in option '-fsanitize-coverage=trace-pc,tracecmp'" "" { target *-*-* } 0 } */ +/* { dg-message "valid arguments to '-fsanitize-coverage=' are: trace-cmp trace-pc; did you mean 'trace-cmp'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-3.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-3.c new file mode 100644 index 0000000000..cecc50299b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-3.c @@ -0,0 +1,6 @@ +/* Verify that we provide simple suggestions for the arguments of + "-fsanitize=" when it is misspelled (PR driver/69265). */ + +/* { dg-do compile } */ +/* { dg-options "-sanitize=address" } */ +/* { dg-error "unrecognized command-line option '-sanitize=address'; did you mean '-fsanitize=address'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-4.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-4.c new file mode 100644 index 0000000000..ab730edea9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-4.c @@ -0,0 +1,6 @@ +/* Verify that we provide simple suggestions for the arguments of + "-fsanitize-recover=" when it is misspelled (PR driver/69265). */ + +/* { dg-do compile } */ +/* { dg-options "-sanitize-recover=integer-divide-by-0" } */ +/* { dg-error "unrecognized command-line option '-sanitize-recover=integer-divide-by-0'; did you mean '-fsanitize-recover=integer-divide-by-zero'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-5.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-5.c new file mode 100644 index 0000000000..097faf0bce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-5.c @@ -0,0 +1,6 @@ +/* Verify that we provide suggestions (with arguments) for the "-fno-" + variant of "-fsanitize=" when it is misspelled (PR driver/69265). */ + +/* { dg-do compile } */ +/* { dg-options "-no-sanitize=all" } */ +/* { dg-error "unrecognized command-line option '-no-sanitize=all'; did you mean '-fno-sanitize=all'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-6.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-6.c new file mode 100644 index 0000000000..591e214613 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-6.c @@ -0,0 +1,6 @@ +/* Verify that we can generate a suggestion of "--warn-no-abi-tag" + from c.opt's "Wabi-tag" (PR driver/69265). */ + +/* { dg-do compile } */ +/* { dg-options "-fwarn-no-abi-tag" } */ +/* { dg-error "unrecognized command-line option '-fwarn-no-abi-tag'; did you mean '--warn-no-abi-tag'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-7.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-7.c new file mode 100644 index 0000000000..277d7d4687 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-7.c @@ -0,0 +1,6 @@ +/* Verify that we provide a hint if the user misspells an option that + takes an argument (PR driver/69265). */ + +/* { dg-do compile } */ +/* { dg-options "-tls-model=global-dynamic" } */ +/* { dg-error "unrecognized command-line option '-tls-model=global-dynamic'; did you mean '-ftls-model=global-dynamic'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-8.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-8.c new file mode 100644 index 0000000000..43cd5ac31f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-8.c @@ -0,0 +1,6 @@ +/* Verify that we include -Wno- variants when considering hints + for misspelled options (PR driver/69453). */ + +/* { dg-do compile } */ +/* { dg-options "--Wno-narrowing" } */ +/* { dg-error "unrecognized command-line option '--Wno-narrowing'; did you mean '-Wno-narrowing'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-options-9.c b/SingleSource/Regression/C/gcc-dg/spellcheck-options-9.c new file mode 100644 index 0000000000..509f9e5936 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-options-9.c @@ -0,0 +1,6 @@ +/* Verify that we include -Wno- variants when considering hints + for misspelled options (PR driver/69453). */ + +/* { dg-do compile } */ +/* { dg-options "-fmo-unroll-loops" } */ +/* { dg-error "unrecognized command-line option '-fmo-unroll-loops'; did you mean '-fno-unroll-loops'?" "" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-params-2.c b/SingleSource/Regression/C/gcc-dg/spellcheck-params-2.c new file mode 100644 index 0000000000..0f56241f48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-params-2.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "--param does-not-resemble-anything=42" } */ +/* { dg-error "unrecognized command-line option '--param=does-not-resemble-anything=42'" "" { target *-*-* } 0 } */ + diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-params.c b/SingleSource/Regression/C/gcc-dg/spellcheck-params.c new file mode 100644 index 0000000000..4010a5df0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-params.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "--param max-early-inliner-iteration=3" } */ +/* { dg-error "unrecognized command-line option '--param=max-early-inliner-iteration=3'; did you mean '--param=max-early-inliner-iterations='?" "" { target *-*-* } 0 } */ + diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-pr83056.c b/SingleSource/Regression/C/gcc-dg/spellcheck-pr83056.c new file mode 100644 index 0000000000..8b90887bda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-pr83056.c @@ -0,0 +1,11 @@ +enum { TYPE_A }; + +/* Verify that the incorrect "TYPE_B" etc don't get re-used for + suggestions for the later incorrect values. */ + +void pr83056(void) +{ + int b = TYPE_B; /* { dg-error "did you mean 'TYPE_A'" } */ + int c = TYPE_C; /* { dg-error "did you mean 'TYPE_A'" } */ + int d = TYPE_D; /* { dg-error "did you mean 'TYPE_A'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-stdbool.c b/SingleSource/Regression/C/gcc-dg/spellcheck-stdbool.c new file mode 100644 index 0000000000..088896b51c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-stdbool.c @@ -0,0 +1,17 @@ +/* { dg-options "-std=c99" } */ +/* Missing . */ + +bool b; /* { dg-error "unknown type name 'bool'" } */ +/* { dg-message "'bool' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + +int test_true (void) +{ + return true; /* { dg-error "'true' undeclared" } */ + /* { dg-message "'true' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ +} + +int test_false (void) +{ + return false; /* { dg-error "'false' undeclared" } */ + /* { dg-message "'false' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-stdint.c b/SingleSource/Regression/C/gcc-dg/spellcheck-stdint.c new file mode 100644 index 0000000000..f89159415e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-stdint.c @@ -0,0 +1,62 @@ +/* { dg-options "-std=gnu99" } */ +/* Missing . */ + +char c = INT8_MAX; // { dg-error "'INT8_MAX' undeclared" } +// { dg-message "'INT8_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + +short s = INT16_MAX; // { dg-error "'INT16_MAX' undeclared" } +// { dg-message "'INT16_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + +int i = INT32_MAX; // { dg-error "'INT32_MAX' undeclared" } +// { dg-message "'INT32_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + +long l = INT64_MAX; // { dg-error "'INT64_MAX' undeclared" } +// { dg-message "'INT64_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + +intptr_t test_intptr (void) // { dg-error "unknown type name 'intptr_t'" } +// { dg-message "'intptr_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } +{ + return INTPTR_MAX; // { dg-error "'INTPTR_MAX' undeclared" } +// { dg-message "'INTPTR_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } +} + +uintptr_t test_uintptr (void) // { dg-error "unknown type name 'uintptr_t'" } +// { dg-message "'uintptr_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } +{ + return UINTPTR_MAX; // { dg-error "'UINTPTR_MAX' undeclared" } +// { dg-message "'UINTPTR_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } +} + +int8_t i8; // { dg-error "unknown type name 'int8_t'" } +// { dg-message "'int8_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } +int16_t i16; // { dg-error "unknown type name 'int16_t'" } +// { dg-message "'int16_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } +int32_t i32; // { dg-error "unknown type name 'int32_t'" } +// { dg-message "'int32_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } +int64_t i64; // { dg-error "unknown type name 'int64_t'" } +// { dg-message "'int64_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + +void test_uint_t (void) +{ + char bu8[(unsigned int)UINT8_MAX]; // { dg-error "'UINT8_MAX' undeclared" } + // { dg-message "'UINT8_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + char bu16[(unsigned int)UINT16_MAX]; // { dg-error "'UINT16_MAX' undeclared" } + // { dg-message "'UINT16_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + char bu32[(unsigned int)UINT32_MAX]; // { dg-error "'UINT32_MAX' undeclared" } + // { dg-message "'UINT32_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + char bu64[(unsigned int)UINT64_MAX]; // { dg-error "'UINT64_MAX' undeclared" } + // { dg-message "'UINT64_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } + + char ui8 = (uint8_t) 8; // { dg-error "'uint8_t' undeclared" } + // { dg-error "expected" "" { target *-*-* } .-1 } + // { dg-message "'uint8_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-2 } + short ui16 = (uint16_t) 16; // { dg-error "'uint16_t' undeclared" } + // { dg-error "expected" "" { target *-*-* } .-1 } + // { dg-message "'uint16_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-2 } + int ui32 = (uint32_t) 32; // { dg-error "'uint32_t' undeclared" } + // { dg-error "expected" "" { target *-*-* } .-1 } + // { dg-message "'uint32_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-2 } + long ui64 = (uint64_t) 64; // { dg-error "'uint64_t' undeclared" } + // { dg-error "expected" "" { target *-*-* } .-1 } + // { dg-message "'uint64_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-2 } +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-stdlib.c b/SingleSource/Regression/C/gcc-dg/spellcheck-stdlib.c new file mode 100644 index 0000000000..3459fad1d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-stdlib.c @@ -0,0 +1,79 @@ +/* Missing . */ + +void *ptr = NULL; /* { dg-error "'NULL' undeclared here" } */ +/* { dg-message "'NULL' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + +ptrdiff_t pd; /* { dg-error "unknown type name 'ptrdiff_t'" } */ +/* { dg-message "'ptrdiff_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + +wchar_t wc; /* { dg-error "unknown type name 'wchar_t'" } */ +/* { dg-message "'wchar_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + +size_t sz; /* { dg-error "unknown type name 'size_t'" } */ +/* { dg-message "'size_t' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + +/* Missing . */ + +void test_stdio_h (void) +{ + FILE *f; /* { dg-error "unknown type name 'FILE'" } */ + /* { dg-message "'FILE' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + + char buf[BUFSIZ]; /* { dg-error "'BUFSIZ' undeclared" } */ + /* { dg-message "'BUFSIZ' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + + char buf2[FILENAME_MAX]; /* { dg-error "'FILENAME_MAX' undeclared" } */ + /* { dg-message "'FILENAME_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + + stderr; /* { dg-error "'stderr' undeclared" } */ + /* { dg-message "'stderr' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + + stdin; /* { dg-error "'stdin' undeclared" } */ + /* { dg-message "'stdin' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + + stdout; /* { dg-error "'stdout' undeclared" } */ + /* { dg-message "'stdout' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + + EOF; /* { dg-error "'EOF' undeclared" } */ + /* { dg-message "'EOF' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ +} + +/* Missing . */ + +void test_stdlib (int i) +{ + i = EXIT_SUCCESS; /* { dg-error "'EXIT_SUCCESS' undeclared" } */ + /* { dg-message "'EXIT_SUCCESS' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ + i = EXIT_FAILURE; /* { dg-error "'EXIT_FAILURE' undeclared" } */ + /* { dg-message "'EXIT_FAILURE' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ +} + +/* Missing . */ + +int test_errno_h (void) +{ + return errno; /* { dg-error "'errno' undeclared" } */ + /* { dg-message "'errno' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ +} + +/* Missing . */ + +void test_stdarg_h (void) +{ + va_list ap; /* { dg-error "unknown type name 'va_list'" } */ + /* { dg-message "'va_list' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } .-1 } */ +} + +/* Missing . */ +int test_INT_MAX (void) +{ + return INT_MAX; /* { dg-line INT_MAX_line } */ + /* { dg-error "'INT_MAX' undeclared" "" { target *-*-* } INT_MAX_line } */ + /* { dg-bogus "__INT_MAX__" "" { target *-*-* } INT_MAX_line } */ + /* { dg-message "'INT_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } INT_MAX_line } */ +} + +/* Missing . */ +float test_FLT_MAX = FLT_MAX; /* { dg-line FLT_MAX_line } */ +/* { dg-error "'FLT_MAX' undeclared" "" { target *-*-* } FLT_MAX_line } */ +/* { dg-message "'FLT_MAX' is defined in header ''; this is probably fixable by adding '#include '" "" { target *-*-* } FLT_MAX_line } */ diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-transposition.c b/SingleSource/Regression/C/gcc-dg/spellcheck-transposition.c new file mode 100644 index 0000000000..b787c83a4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-transposition.c @@ -0,0 +1,20 @@ +/* PR other/69968. */ + +struct { + int coordx, coordy, coordz; + int coordx1, coordy1, coordz1; +} c; + +/* Consider the misspelling "coorzd1". + + With Levenshtein distance, the misspelling has an edit distance of 2 + to all 6 of the fields (e.g. via a deletion and a substitution for the + first three, and via deletion and insertion for the second three). + + With Damerau-Levenshtein, the misspelling has an edit distance of 1 + via transposition to "coordz1", and 2 to the other fields. */ + +void foo (void) +{ + c.coorzd1 = c.coordy; /* { dg-error "has no member named 'coorzd1'; did you mean 'coordz1'" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/spellcheck-typenames.c b/SingleSource/Regression/C/gcc-dg/spellcheck-typenames.c new file mode 100644 index 0000000000..3717ad89f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spellcheck-typenames.c @@ -0,0 +1,108 @@ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-show-caret" } */ + +void test_1 (signed char e); + +/* PR c/70339. */ +void test_2 (singed char e); /* { dg-error "14: unknown type name .singed.; did you mean .signed.?" } */ +/* { dg-begin-multiline-output "" } + void test_2 (singed char e); + ^~~~~~ + signed + { dg-end-multiline-output "" } */ + +void test_3 (car e); /* { dg-error "14: unknown type name .car.; did you mean .char.?" } */ +/* { dg-begin-multiline-output "" } + void test_3 (car e); + ^~~ + char + { dg-end-multiline-output "" } */ + +/* TODO: this one could be handled better. */ +void test_4 (signed car e); /* { dg-error "25: before .e." } */ +/* { dg-begin-multiline-output "" } + void test_4 (signed car e); + ^ + { dg-end-multiline-output "" } */ + +/* Verify that we handle misspelled typedef names. */ + +typedef struct something {} something_t; + +some_thing_t test_5; /* { dg-error "1: unknown type name .some_thing_t.; did you mean .something_t.?" } */ + /* { dg-begin-multiline-output "" } + some_thing_t test_5; + ^~~~~~~~~~~~ + something_t + { dg-end-multiline-output "" } */ + +/* TODO: we don't yet handle misspelled struct names. */ +struct some_thing test_6; /* { dg-error "storage size of .test_6. isn't known" } */ + /* { dg-begin-multiline-output "" } + struct some_thing test_6; + ^~~~~~ + { dg-end-multiline-output "" } */ + +typedef long int64_t; +int64 i; /* { dg-error "unknown type name 'int64'; did you mean 'int64_t'?" } */ +/* { dg-begin-multiline-output "" } + int64 i; + ^~~~~ + int64_t + { dg-end-multiline-output "" } */ + +/* Verify that gcc doesn't offer nonsensical suggestions. */ + +nonsensical_suggestion_t var; /* { dg-bogus "did you mean" } */ +/* { dg-error "unknown type name" "" { target { *-*-* } } .-1 } */ +/* { dg-begin-multiline-output "" } + nonsensical_suggestion_t var; + ^~~~~~~~~~~~~~~~~~~~~~~~ + { dg-end-multiline-output "" } */ + + +/* In the following, we should suggest inserting "struct" (rather + than "did you mean 'float'") and provide a fixit hint. */ +struct foo_t { + int i; +}; +foo_t *foo_ptr; /* { dg-error "1: unknown type name .foo_t.; use .struct. keyword to refer to the type" } */ +/* { dg-begin-multiline-output "" } + foo_t *foo_ptr; + ^~~~~ + struct + { dg-end-multiline-output "" } */ + + +/* Similarly for unions. */ +union bar_t { + int i; + char j; +}; +bar_t *bar_ptr; /* { dg-error "1: unknown type name .bar_t.; use .union. keyword to refer to the type" } */ +/* { dg-begin-multiline-output "" } + bar_t *bar_ptr; + ^~~~~ + union + { dg-end-multiline-output "" } */ + + +/* Similarly for enums. */ +enum baz { + BAZ_FIRST, + BAZ_SECOND +}; +baz value; /* { dg-error "1: unknown type name .baz.; use .enum. keyword to refer to the type" } */ +/* { dg-begin-multiline-output "" } + baz value; + ^~~ + enum + { dg-end-multiline-output "" } */ + +/* TODO: it would be better to detect the "singed" vs "signed" typo here. */ +singed char ch; /* { dg-error "7: before .char." } */ +/* { dg-begin-multiline-output "" } + singed char ch; + ^~~~~ + ; + { dg-end-multiline-output "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/spill-1.c b/SingleSource/Regression/C/gcc-dg/spill-1.c new file mode 100644 index 0000000000..b85942e87a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/spill-1.c @@ -0,0 +1,15 @@ +/* This caused an ICE during register spilling when targeting thumb. + There are 8 registers available for arithmetic operations (r0-r7) + r7 is the frame pointer, and r0-r3 are used to pass arguments. + Combine was extending the lives of the arguments (in r0-r3) up until the + call to z. This leaves only 3 regs free which isn't enough to preform the + doubleword addition. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-omit-frame-pointer" } */ +void z(int); +int foo(int a, int b, int c, int d, long long *q) +{ + *q=*q+1; + z (a+b+c+d); +} + diff --git a/SingleSource/Regression/C/gcc-dg/split-1.c b/SingleSource/Regression/C/gcc-dg/split-1.c new file mode 100644 index 0000000000..91fcb4aa55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/split-1.c @@ -0,0 +1,49 @@ +/* This test needs to use setrlimit to set the stack size, so it can + only run on Unix. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-solaris* *-*-darwin* } } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack" } */ + +#include +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +/* Each recursive call uses 10,000 bytes. We call it 1000 times, + using a total of 10,000,000 bytes. If -fsplit-stack is not + working, that will overflow our stack limit. */ + +static void +down (int i) +{ + char buf[10000]; + + if (i > 0) + { + use_buffer (buf); + down (i - 1); + } +} + +int +main (void) +{ + struct rlimit r; + + /* We set a stack limit because we are usually invoked via make, and + make sets the stack limit to be as large as possible. */ + r.rlim_cur = 8192 * 1024; + r.rlim_max = 8192 * 1024; + if (setrlimit (RLIMIT_STACK, &r) != 0) + abort (); + down (1000); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/split-2.c b/SingleSource/Regression/C/gcc-dg/split-2.c new file mode 100644 index 0000000000..208169aa09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/split-2.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-require-effective-target pthread_h } */ +/* { dg-options "-pthread -fsplit-stack" } */ + +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +/* Each recursive call uses 10,000 bytes. We call it 1000 times, + using a total of 10,000,000 bytes. If -fsplit-stack is not + working, that will overflow our stack limit. */ + +static void +down (int i) +{ + char buf[10000]; + + if (i > 0) + { + use_buffer (buf); + down (i - 1); + } +} + +static void * +thread_routine (void *arg __attribute__ ((unused))) +{ + down (1000); + return NULL; +} + +int +main (void) +{ + int i; + pthread_t tid; + void *dummy; + + i = pthread_create (&tid, NULL, thread_routine, NULL); + if (i != 0) + abort (); + i = pthread_join (tid, &dummy); + if (i != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/split-3.c b/SingleSource/Regression/C/gcc-dg/split-3.c new file mode 100644 index 0000000000..64bbb8c0ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/split-3.c @@ -0,0 +1,64 @@ +/* This test needs to use setrlimit to set the stack size, so it can + only run on Unix. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-solaris* *-*-darwin* } } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack" } */ + +#include +#include +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +/* Each recursive call uses 10,000 bytes. We call it 1000 times, + using a total of 10,000,000 bytes. If -fsplit-stack is not + working, that will overflow our stack limit. */ + +static void +down (int i, ...) +{ + char buf[10000]; + va_list ap; + + va_start (ap, i); + if (va_arg (ap, int) != 1 + || va_arg (ap, int) != 2 + || va_arg (ap, int) != 3 + || va_arg (ap, int) != 4 + || va_arg (ap, int) != 5 + || va_arg (ap, int) != 6 + || va_arg (ap, int) != 7 + || va_arg (ap, int) != 8 + || va_arg (ap, int) != 9 + || va_arg (ap, int) != 10) + abort (); + + if (i > 0) + { + use_buffer (buf); + down (i - 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + } +} + +int +main (void) +{ + struct rlimit r; + + /* We set a stack limit because we are usually invoked via make, and + make sets the stack limit to be as large as possible. */ + r.rlim_cur = 8192 * 1024; + r.rlim_max = 8192 * 1024; + if (setrlimit (RLIMIT_STACK, &r) != 0) + abort (); + down (1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/split-4.c b/SingleSource/Regression/C/gcc-dg/split-4.c new file mode 100644 index 0000000000..b89164e34d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/split-4.c @@ -0,0 +1,68 @@ +/* This test needs to use setrlimit to set the stack size, so it can + only run on Unix. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-solaris* *-*-darwin* } } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack" } */ + +#include +#include +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf, size_t) __attribute__ ((noinline)); +static void +use_buffer (char *buf, size_t c) +{ + size_t i; + + for (i = 0; i < c; ++i) + buf[i] = (char) i; +} + +/* Each recursive call uses 10 * i bytes. We call it 1000 times, + using a total of 5,000,000 bytes. If -fsplit-stack is not working, + that will overflow our stack limit. */ + +static void +down1 (int i) +{ + char buf[10 * i]; + + if (i > 0) + { + use_buffer (buf, 10 * i); + down1 (i - 1); + } +} + +/* Same thing, using alloca. */ + +static void +down2 (int i) +{ + char *buf = alloca (10 * i); + + if (i > 0) + { + use_buffer (buf, 10 * i); + down2 (i - 1); + } +} + +int +main (void) +{ + struct rlimit r; + + /* We set a stack limit because we are usually invoked via make, and + make sets the stack limit to be as large as possible. */ + r.rlim_cur = 8192 * 1024; + r.rlim_max = 8192 * 1024; + if (setrlimit (RLIMIT_STACK, &r) != 0) + abort (); + down1 (1000); + down2 (1000); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/split-5.c b/SingleSource/Regression/C/gcc-dg/split-5.c new file mode 100644 index 0000000000..601640f22e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/split-5.c @@ -0,0 +1,171 @@ +/* { dg-do run } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-require-effective-target pthread_h } */ +/* { dg-require-effective-target ucontext_h } */ +/* { dg-options "-pthread -fsplit-stack" } */ + +#include +#include +#include + +extern void __splitstack_getcontext (void *context[10]); + +extern void __splitstack_setcontext (void *context[10]); + +extern void *__splitstack_makecontext (size_t, void *context[10], size_t *); + +extern void __splitstack_block_signals (int *, int *); + +extern void __splitstack_block_signals_context (void *context[10], int *, + int *); + +extern void *__splitstack_find (void *, void *, size_t *, void **, void **, + void **); + +extern void *__splitstack_find_context (void *context[10], size_t *, void **, + void **, void **); + +static ucontext_t c1; +static void *s1[10]; + +static ucontext_t c2; +static void *s2[10]; + +static void swap (ucontext_t *, void *fs[10], ucontext_t *, void *ts[10]) + __attribute__ ((no_split_stack)); + +static void +swap (ucontext_t *fu, void *fs[10], ucontext_t *tu, void *ts[10]) +{ + __splitstack_getcontext (fs); + __splitstack_setcontext (ts); + swapcontext (fu, tu); + __splitstack_setcontext (fs); +} + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +static void +down (int i, const char *msg, ucontext_t *me, void *mes[10], + ucontext_t *other, void *others[10]) +{ + char buf[10000]; + + if (i > 0) + { + use_buffer (buf); + swap (me, mes, other, others); + down (i - 1, msg, me, mes, other, others); + } + else + { + int c = 0; + void *stack; + size_t stack_size; + void *next_segment = NULL; + void *next_sp = NULL; + void *initial_sp = NULL; + + stack = __splitstack_find_context (mes, &stack_size, &next_segment, + &next_sp, &initial_sp); + if (stack != NULL) + { + ++c; + while (__splitstack_find (next_segment, next_sp, &stack_size, + &next_segment, &next_sp, &initial_sp) + != NULL) + ++c; + } + } +} + +static void +go1 (void) +{ + down (1000, "go1", &c1, s1, &c2, s2); + pthread_exit (NULL); +} + +static void +go2 (void) +{ + down (1000, "go2", &c2, s2, &c1, s1); + pthread_exit (NULL); +} + +struct thread_context +{ + ucontext_t *u; + void **s; +}; + +static void *start_thread (void *) __attribute__ ((no_split_stack)); + +static void * +start_thread (void *context) +{ + struct thread_context *tc = (struct thread_context *) context; + int block; + + block = 0; + __splitstack_block_signals (&block, NULL); + __splitstack_setcontext (tc->s); + setcontext (tc->u); + abort (); +} + +int +main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused))) +{ + pthread_t tid; + int err; + size_t size; + struct thread_context tc; + int block; + + if (getcontext (&c1) < 0) + abort (); + + c2 = c1; + + c1.uc_stack.ss_sp = __splitstack_makecontext (8192, &s1[0], &size); + if (c1.uc_stack.ss_sp == NULL) + abort (); + c1.uc_stack.ss_flags = 0; + c1.uc_stack.ss_size = size; + c1.uc_link = NULL; + block = 0; + __splitstack_block_signals_context (&s1[0], &block, NULL); + makecontext (&c1, go1, 0); + + c2.uc_stack.ss_sp = __splitstack_makecontext (8192, &s2[0], &size); + if (c2.uc_stack.ss_sp == NULL) + abort (); + c2.uc_stack.ss_flags = 0; + c2.uc_stack.ss_size = size; + c2.uc_link = NULL; + __splitstack_block_signals_context (&s2[0], &block, NULL); + makecontext (&c2, go2, 0); + + block = 0; + __splitstack_block_signals (&block, NULL); + + tc.u = &c1; + tc.s = &s1[0]; + err = pthread_create (&tid, NULL, start_thread, &tc); + if (err != 0) + abort (); + + err = pthread_join (tid, NULL); + if (err != 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/split-6.c b/SingleSource/Regression/C/gcc-dg/split-6.c new file mode 100644 index 0000000000..b32cf8de20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/split-6.c @@ -0,0 +1,53 @@ +/* { dg-do run } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack" } */ + +/* This test is like split-3.c, but tests with a smaller stack frame, + since that uses a different prologue. */ + +#include +#include + +/* Use a noinline function to ensure that the buffer is not removed + from the stack. */ +static void use_buffer (char *buf) __attribute__ ((noinline)); +static void +use_buffer (char *buf) +{ + buf[0] = '\0'; +} + +/* When using gold, the call to abort will force a stack split. */ + +static void +down (int i, ...) +{ + char buf[1]; + va_list ap; + + va_start (ap, i); + if (va_arg (ap, int) != 1 + || va_arg (ap, int) != 2 + || va_arg (ap, int) != 3 + || va_arg (ap, int) != 4 + || va_arg (ap, int) != 5 + || va_arg (ap, int) != 6 + || va_arg (ap, int) != 7 + || va_arg (ap, int) != 8 + || va_arg (ap, int) != 9 + || va_arg (ap, int) != 10) + abort (); + + if (i > 0) + { + use_buffer (buf); + down (i - 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + } +} + +int +main (void) +{ + down (1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/split-7.c b/SingleSource/Regression/C/gcc-dg/split-7.c new file mode 100644 index 0000000000..4933e9cfb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/split-7.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack -O2" } */ +/* { dg-options "-fsplit-stack -O2 -mno-accumulate-outgoing-args" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + +/* A case that used to fail on 32-bit x86 when optimizing and not + using -maccumulate-args. The stack adjustment of the alloca got + mixed up with the arguments pushed on the stack to the function + before the call of alloca. */ + +#include + +typedef struct { const char* s; int l; } s; + +typedef unsigned long long align16 __attribute__ ((aligned(16))); + +s gobats (const void *, int) __attribute__ ((noinline)); + +s +gobats (const void* p __attribute__ ((unused)), + int l __attribute__ ((unused))) +{ + s v; + v.s = 0; + v.l = 0; + return v; +} + +void check_aligned (void *p) __attribute__ ((noinline)); + +void +check_aligned (void *p) +{ + if (((__SIZE_TYPE__) p & 0xf) != 0) + abort (); +} + +void gap (void *) __attribute__ ((noinline)); + +void gap (void *p) +{ + align16 a; + check_aligned (&a); +} + +int +main (int argc, char **argv) +{ + s *space; + gobats(0, 16); + space = (s *) alloca(sizeof(s) + 1); + *space = (s){0, 16}; + gap(space); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/split-8.c b/SingleSource/Regression/C/gcc-dg/split-8.c new file mode 100644 index 0000000000..33662e24c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/split-8.c @@ -0,0 +1,43 @@ +/* { dg-do run } */ +/* { dg-require-effective-target split_stack } */ +/* { dg-options "-fsplit-stack" } */ + +/* Testcase for PR86213. On the first call to __morestack there is a live + value in xmm0, which was being clobbered by a call to getenv(). */ + +#include + +double gd[8]; +int z; + +double bar(double q) __attribute__ ((noinline)); +double foo(double q) __attribute__ ((noinline)); +int ck(double q) __attribute__ ((noinline)); +int main(int argc, char **argv) __attribute__ ((no_split_stack)); + +double bar(double q) +{ + double d[8]; + for (unsigned i = 0; i < 8; ++i) + d[i] = gd[8-i-1]; + return q + d[z&3]; +} + +double foo(double d) +{ + return bar(d); +} + +int ck(double d) +{ + if (d != 64.0) + abort(); + return 0; +} + +typedef double (*fp)(double); +fp g = foo; + +int main(int argc, char **argv) { + return ck(g(64.0)); +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-1.c b/SingleSource/Regression/C/gcc-dg/sso-1.c new file mode 100644 index 0000000000..b2e11bd00d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-1.c @@ -0,0 +1,19 @@ +/* Test support of scalar_storage_order attribute */ + +/* { dg-do compile } */ + +int i; + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +struct __attribute__((scalar_storage_order("big-endian"))) Rec +{ + int *p; +}; +#else +struct __attribute__((scalar_storage_order("little-endian"))) Rec +{ + int *p; +}; +#endif + +struct Rec r = { &i }; /* { dg-error "element is not constant" } */ diff --git a/SingleSource/Regression/C/gcc-dg/sso-10.c b/SingleSource/Regression/C/gcc-dg/sso-10.c new file mode 100644 index 0000000000..9dfa2974a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-10.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-fsso-struct=native" } */ +/* { dg-require-effective-target int32plus } */ + +struct S1 +{ + int i; +}; + + +struct S1 my_s1 = { 0x12345678 }; + +unsigned char big_endian_pattern[4] = { 0x12, 0x34, 0x56, 0x78 }; +unsigned char little_endian_pattern[4] = { 0x78, 0x56, 0x34, 0x12 }; + +int main (void) +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + if (__builtin_memcmp (&my_s1, &little_endian_pattern, 4) != 0) + __builtin_abort (); +#else + if (__builtin_memcmp (&my_s1, &big_endian_pattern, 4) != 0) + __builtin_abort (); +#endif + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-11.c b/SingleSource/Regression/C/gcc-dg/sso-11.c new file mode 100644 index 0000000000..6b50a25485 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-11.c @@ -0,0 +1,36 @@ +/* Test support of scalar_storage_order attribute */ + +/* { dg-do compile } */ + +struct __attribute__((scalar_storage_order("big-endian"))) S1 +{ + int i; +}; + +struct __attribute__((scalar_storage_order("little-endian"))) S2 +{ + int i; +}; + +extern int foo (void *); + +int incompatible_call (int which, struct S1 *s1, struct S2 *s2) +{ + if (which == 1) return foo (s1); else foo (s2); /* { dg-warning "incompatible scalar storage order" } */ +} + +void incompatible_assign (struct S1 *s1, struct S2 *s2) +{ + void *p1, *p2; + p1 = s1, p2 = s2; /* { dg-warning "incompatible scalar storage order" } */ +} + +void incompatible_init (struct S1 *s1, struct S2 *s2) +{ + void *p1 = s1, *p2 = s2; /* { dg-warning "incompatible scalar storage order" } */ +} + +void *incompatible_return (int which, struct S1 *s1, struct S2 *s2) +{ + if (which == 1) return s1; else return s2; /* { dg-warning "incompatible scalar storage order" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-12.c b/SingleSource/Regression/C/gcc-dg/sso-12.c new file mode 100644 index 0000000000..3bed280e17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-12.c @@ -0,0 +1,27 @@ +/* Test scalar_storage_order attribute and pointer fields */ + +/* { dg-do run } */ +/* { dg-options "-Wno-pedantic" } */ + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +struct __attribute__((scalar_storage_order("big-endian"))) Rec +{ + int *p; +}; +#else +struct __attribute__((scalar_storage_order("little-endian"))) Rec +{ + int *p; +}; +#endif + +int main (int argc) +{ + struct Rec r = { &argc }; + int *p = &argc; + + if (__builtin_memcmp (&r.p, &p, sizeof (int *)) != 0) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-13.c b/SingleSource/Regression/C/gcc-dg/sso-13.c new file mode 100644 index 0000000000..ddfde00b75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-13.c @@ -0,0 +1,24 @@ +/* Test support of scalar_storage_order attribute */ + +/* { dg-do compile } */ + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian"))) +#else +#define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian"))) +#endif + +typedef struct tIp6Addr +{ + unsigned int s6_addr32[4]; +} tIp6Addr; + +struct _tBeTimNetAddr +{ + unsigned char isIPv4; + union + { + unsigned int addr; + tIp6Addr addr6; /* { dg-warning "type punning toggles" } */ + } REV_ENDIANNESS u; +} REV_ENDIANNESS; diff --git a/SingleSource/Regression/C/gcc-dg/sso-14.c b/SingleSource/Regression/C/gcc-dg/sso-14.c new file mode 100644 index 0000000000..7b1590ad03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-14.c @@ -0,0 +1,57 @@ +/* PR c/100920 */ +/* Testcase by George Thopas */ + +/* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ + +#include +#include +#include + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian"))) +#else +#define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian"))) +#endif + +struct s_1 { + int val; +} REV_ENDIANNESS; + +typedef struct s_1 t_1; + +struct s_2 { + char val; +} REV_ENDIANNESS; + +typedef struct s_2 t_2; + +struct s12 { + t_1 a[1]; + t_2 b[1]; +} REV_ENDIANNESS; + +typedef struct s12 t_s12; + +union u12 { + t_1 a[1]; + t_2 b[1]; +} REV_ENDIANNESS; + +typedef union u12 t_u12; + +int main(void) +{ + t_s12 *msg1 = __builtin_alloca(10); + t_u12 *msg2 = __builtin_alloca(10); + int same; + + msg1 = malloc (sizeof (t_s12)); + msg2 = malloc (sizeof (t_s12)); + + memset (msg1, 0, sizeof (t_s12)); + memcpy (msg2, msg1, sizeof (t_s12)); + same = memcmp (msg1, msg2, sizeof (t_s12)); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-15.c b/SingleSource/Regression/C/gcc-dg/sso-15.c new file mode 100644 index 0000000000..d8a711d657 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-15.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian"))) +#else +#define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian"))) +#endif + +struct X { int *p; } REV_ENDIANNESS; + +struct X x; + +struct X __attribute__((noinline)) foo (int *p) +{ + struct X x; + x.p = p; + return x; +} + +void __attribute((noinline)) bar (void) +{ + *x.p = 1; +} + +extern void abort (void); + +int main (void) +{ + int i = 0; + x = foo(&i); + bar(); + if (i != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-16.c b/SingleSource/Regression/C/gcc-dg/sso-16.c new file mode 100644 index 0000000000..7bf89385ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-16.c @@ -0,0 +1,100 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-O3" } */ + +typedef __INT32_TYPE__ int32_t; + +#define BIG_ENDIAN __attribute__((scalar_storage_order("big-endian"))) + +/* host order version (little endian)*/ +struct _ip6_addr { + union { + char addr8[16]; + int32_t addr32[4]; + } u; +}; + +typedef struct _ip6_addr t_ip6_addr; + +struct _net_addr { + char is_v4; + union { + int32_t addr; + t_ip6_addr addr6; + } u; +}; + +typedef struct _net_addr t_net_addr; + +/* big endian version */ +struct _be_ip6_addr { + union { + char addr8[16]; + } BIG_ENDIAN u; +} BIG_ENDIAN; + +typedef struct _be_ip6_addr t_be_ip6_addr; + +struct _be_net_addr { + char is_v4; + union { + t_be_ip6_addr addr6; + int32_t addr; + } BIG_ENDIAN u; +} BIG_ENDIAN; + +typedef struct _be_net_addr t_be_net_addr; + +/* convert */ +t_be_ip6_addr be_ip6_addr(const t_ip6_addr ip6) +{ + t_be_ip6_addr rc = { + .u.addr8[0] = ip6.u.addr8[0], + .u.addr8[1] = ip6.u.addr8[1], + .u.addr8[2] = ip6.u.addr8[2], + .u.addr8[3] = ip6.u.addr8[3], + .u.addr8[4] = ip6.u.addr8[4], + .u.addr8[5] = ip6.u.addr8[5], + .u.addr8[6] = ip6.u.addr8[6], + .u.addr8[7] = ip6.u.addr8[7], + .u.addr8[8] = ip6.u.addr8[8], + .u.addr8[9] = ip6.u.addr8[9], + .u.addr8[10] = ip6.u.addr8[10], + .u.addr8[11] = ip6.u.addr8[11], + .u.addr8[12] = ip6.u.addr8[12], + .u.addr8[13] = ip6.u.addr8[13], + .u.addr8[14] = ip6.u.addr8[14], + .u.addr8[15] = ip6.u.addr8[15], + }; + return rc; +} + +t_be_net_addr __attribute__((noipa)) be_net_addr(const t_net_addr ip) +{ + t_be_net_addr rc = {.is_v4 = ip.is_v4 }; + if (ip.is_v4) { + rc.u.addr = ip.u.addr; + } else { + rc.u.addr6 = be_ip6_addr(ip.u.addr6); + } + return rc; +} + +int main(void) +{ + t_be_net_addr out = { }; + + t_net_addr in = { + .is_v4 = 0, + .u.addr6.u.addr8 = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } + }; + + out = be_net_addr(in); + + // actually first 4 bytes are swapped + if (in.u.addr6.u.addr8[0] != out.u.addr6.u.addr8[0]) + __builtin_abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-17.c b/SingleSource/Regression/C/gcc-dg/sso-17.c new file mode 100644 index 0000000000..67e2d3793f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-17.c @@ -0,0 +1,52 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian"))) +#else +#define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian"))) +#endif + +typedef unsigned long long u64; + +union DST { + u64 val; + + struct { + u64 x : 1; + u64 y : 1; + u64 r: 62; + } REV_ENDIANNESS; +} REV_ENDIANNESS; + + +struct SRC { + u64 a; +} REV_ENDIANNESS; + +[[gnu::noipa]] +void foo () {__builtin_abort();} + +[[gnu::noinline]] +int bar(struct SRC *src) +{ + union DST dst; + + dst.val = src->a; + + if (dst.y) { + foo(); + } + return 0; +} + +int main(void) +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + struct SRC t = {-1ull & (~(0x01ull<<62))}; +#else + struct SRC t = {-1ull & (~(0x01ull<<1))}; +#endif + bar(&t); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-2.c b/SingleSource/Regression/C/gcc-dg/sso-2.c new file mode 100644 index 0000000000..0f7218c801 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-2.c @@ -0,0 +1,94 @@ +/* Test support of scalar_storage_order attribute */ + +/* { dg-do compile } */ + +struct __attribute__((scalar_storage_order("big-endian"))) S1 +{ + int i; +}; + +struct __attribute__((scalar_storage_order("little-endian"))) S2 +{ + int i; +}; + +struct __attribute__((scalar_storage_order("other"))) S3 { int i; }; /* { dg-error "must be one of .big-endian. or .little-endian." } */ + +void incompatible_assign (struct S1 *s1, struct S2 *s2) +{ + *s1 = *s2; /* { dg-error "(incompatible types|no match)" } */ +} + +int *addr1 (int which, struct S1 *s1, struct S2 *s2) +{ + return (which == 1 ? &s1->i : &s2->i); /* { dg-error "address of scalar with reverse storage order" } */ +} + +struct __attribute__((scalar_storage_order("big-endian"))) S4 +{ + int a[4]; + struct S2 s2; +}; + +struct __attribute__((scalar_storage_order("little-endian"))) S5 +{ + int a[4]; + struct S1 s1; +}; + +void *addr2 (int which, struct S4 *s4, struct S5 *s5) +{ + return (which == 1 ? (void *)s4->a : (void *)s5->a); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr3 (int which, struct S4 *s4, struct S5 *s5) +{ + return (which == 1 ? (void *)&s4->a : (void *)&s5->a); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr4 (int which, struct S4 *s4, struct S5 *s5) +{ + return (which == 1 ? (void *)&s4->a[0] : (void *)&s5->a[0]); /* { dg-error "address of scalar with reverse storage order" } */ +} + +void *addr5 (int which, struct S4 *s4, struct S5 *s5) +{ + return (which == 1 ? (void *)&s4->s2 : (void *) &s5->s1); /* ok */ +} + +struct __attribute__((scalar_storage_order("big-endian"))) S6 +{ + int a[4][2]; + struct S2 s2[2]; +}; + +struct __attribute__((scalar_storage_order("little-endian"))) S7 +{ + int a[4][2]; + struct S1 s1[2]; +}; + +void *addr6 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)s6->a : (void *)s7->a); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr7 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)&s6->a : (void *)&s7->a); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr8 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)&s6->a[0] : (void *)&s7->a[0]); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr9 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)&s6->a[0][0] : (void *)&s7->a[0][0]); /* { dg-error "address of scalar with reverse storage order" } */ +} + +void *addr10 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)&s6->s2 : (void *)&s7->s1); /* ok */ +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-3.c b/SingleSource/Regression/C/gcc-dg/sso-3.c new file mode 100644 index 0000000000..c7877e8faf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-3.c @@ -0,0 +1,94 @@ +/* Test support of scalar_storage_order attribute */ + +/* { dg-do compile } */ + +struct S1 +{ + int i; +} __attribute__((scalar_storage_order("big-endian"))); + +struct S2 +{ + int i; +} __attribute__((scalar_storage_order("little-endian"))); + +struct S3 { int i; } __attribute__((scalar_storage_order("other"))); /* { dg-error "must be one of .big-endian. or .little-endian." } */ + +void incompatible_assign (struct S1 *s1, struct S2 *s2) +{ + *s1 = *s2; /* { dg-error "(incompatible types|no match)" } */ +} + +int *addr1 (int which, struct S1 *s1, struct S2 *s2) +{ + return (which == 1 ? &s1->i : &s2->i); /* { dg-error "address of scalar with reverse storage order" } */ +} + +struct S4 +{ + int a[4]; + struct S2 s2; +} __attribute__((scalar_storage_order("big-endian"))); + +struct S5 +{ + int a[4]; + struct S1 s1; +} __attribute__((scalar_storage_order("little-endian"))); + +void *addr2 (int which, struct S4 *s4, struct S5 *s5) +{ + return (which == 1 ? (void *)s4->a : (void *)s5->a); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr3 (int which, struct S4 *s4, struct S5 *s5) +{ + return (which == 1 ? (void *)&s4->a : (void *)&s5->a); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr4 (int which, struct S4 *s4, struct S5 *s5) +{ + return (which == 1 ? (void *)&s4->a[0] : (void *)&s5->a[0]); /* { dg-error "address of scalar with reverse storage order" } */ +} + +void *addr5 (int which, struct S4 *s4, struct S5 *s5) +{ + return (which == 1 ? (void *)&s4->s2 : (void *) &s5->s1); /* ok */ +} + +struct S6 +{ + int a[4][2]; + struct S2 s2[2]; +} __attribute__((scalar_storage_order("big-endian"))); + +struct S7 +{ + int a[4][2]; + struct S1 s1[2]; +} __attribute__((scalar_storage_order("little-endian"))); + +void *addr6 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)s6->a : (void *)s7->a); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr7 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)&s6->a : (void *)&s7->a); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr8 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)&s6->a[0] : (void *)&s7->a[0]); /* { dg-warning "address of array with reverse scalar storage order" } */ +} + +void *addr9 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)&s6->a[0][0] : (void *)&s7->a[0][0]); /* { dg-error "address of scalar with reverse storage order" } */ +} + +void *addr10 (int which, struct S6 *s6, struct S7 *s7) +{ + return (which == 1 ? (void *)&s6->s2 : (void *)&s7->s1); /* ok */ +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-4.c b/SingleSource/Regression/C/gcc-dg/sso-4.c new file mode 100644 index 0000000000..9eda11a460 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-4.c @@ -0,0 +1,20 @@ +/* Test support of scalar_storage_order attribute */ + +/* { dg-do compile } */ + +struct S +{ + int i; +}; + +typedef struct S __attribute__((scalar_storage_order("big-endian"))) S1; + +typedef struct S __attribute__((scalar_storage_order("little-endian"))) S2; + +typedef struct S __attribute__((scalar_storage_order("other"))) S3; /* { dg-error "must be one of .big-endian. or .little-endian." } */ + +void incompatible_assign (struct S *s, S1 *s1, S2 *s2) +{ + *s = *s1, *s = *s2; /* { dg-error "(incompatible types|no match)" } */ + *s1 = *s2; /* { dg-error "(incompatible types|no match)" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-5.c b/SingleSource/Regression/C/gcc-dg/sso-5.c new file mode 100644 index 0000000000..8bbb38bf54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-5.c @@ -0,0 +1,24 @@ +/* Test support of scalar_storage_order attribute */ + +/* { dg-do compile } */ + +struct S3 +{ + struct __attribute__((scalar_storage_order("big-endian"))) S1 + { + int i; + } s1; +}; + +struct S4 +{ + struct __attribute__((scalar_storage_order("little-endian"))) S2 + { + int i; + } s2; +}; + +void incompatible_assign (struct S3 *s3, struct S4 *s4) +{ + s3->s1 = s4->s2; /* { dg-error "(incompatible types|no match)" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-6.c b/SingleSource/Regression/C/gcc-dg/sso-6.c new file mode 100644 index 0000000000..559253293b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-6.c @@ -0,0 +1,73 @@ +/* Test support of scalar_storage_order pragma */ + +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +#pragma scalar_storage_order /* { dg-warning "missing .big-endian., .little-endian., or .default." } */ + +#pragma scalar_storage_order big-endian + +struct S1 +{ + int i; +}; + +struct __attribute__((scalar_storage_order("little-endian"))) S2 +{ + int i; +}; + +#pragma scalar_storage_order little-endian + +struct S3 +{ + int i; +}; + +struct __attribute__((scalar_storage_order("big-endian"))) S4 +{ + int i; +}; + +#pragma scalar_storage_order default + +struct S5 +{ + int i; +}; + +#pragma scalar_storage_order other /* { dg-warning "expected .big-endian., .little-endian., or .default." } */ + +struct S1 my_s1 = { 0x12345678 }; +struct S2 my_s2 = { 0x12345678 }; +struct S3 my_s3 = { 0x12345678 }; +struct S4 my_s4 = { 0x12345678 }; +struct S5 my_s5 = { 0x12345678 }; + +unsigned char big_endian_pattern[4] = { 0x12, 0x34, 0x56, 0x78 }; +unsigned char little_endian_pattern[4] = { 0x78, 0x56, 0x34, 0x12 }; + +int main (void) +{ + if (__builtin_memcmp (&my_s1, &big_endian_pattern, 4) != 0) + __builtin_abort (); + + if (__builtin_memcmp (&my_s2, &little_endian_pattern, 4) != 0) + __builtin_abort (); + + if (__builtin_memcmp (&my_s3, &little_endian_pattern, 4) != 0) + __builtin_abort (); + + if (__builtin_memcmp (&my_s4, &big_endian_pattern, 4) != 0) + __builtin_abort (); + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + if (__builtin_memcmp (&my_s5, &little_endian_pattern, 4) != 0) + __builtin_abort (); +#else + if (__builtin_memcmp (&my_s5, &big_endian_pattern, 4) != 0) + __builtin_abort (); +#endif + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-7.c b/SingleSource/Regression/C/gcc-dg/sso-7.c new file mode 100644 index 0000000000..51902ab0e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-7.c @@ -0,0 +1,45 @@ +/* Test support of scalar_storage_order pragma */ + +/* { dg-do run } */ +/* { dg-options "-fsso-struct=big-endian" } */ +/* { dg-require-effective-target int32plus } */ + +struct S1 +{ + int i; +}; + +#pragma scalar_storage_order little-endian + +struct S2 +{ + int i; +}; + +#pragma scalar_storage_order default + +struct S3 +{ + int i; +}; + +struct S1 my_s1 = { 0x12345678 }; +struct S2 my_s2 = { 0x12345678 }; +struct S3 my_s3 = { 0x12345678 }; + +unsigned char big_endian_pattern[4] = { 0x12, 0x34, 0x56, 0x78 }; +unsigned char little_endian_pattern[4] = { 0x78, 0x56, 0x34, 0x12 }; + +int main (void) +{ + if (__builtin_memcmp (&my_s1, &big_endian_pattern, 4) != 0) + __builtin_abort (); + + if (__builtin_memcmp (&my_s2, &little_endian_pattern, 4) != 0) + __builtin_abort (); + + if (__builtin_memcmp (&my_s3, &big_endian_pattern, 4) != 0) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sso-8.c b/SingleSource/Regression/C/gcc-dg/sso-8.c new file mode 100644 index 0000000000..5148188485 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sso-8.c @@ -0,0 +1,45 @@ +/* Test support of scalar_storage_order pragma */ + +/* { dg-do run } */ +/* { dg-options "-fsso-struct=little-endian" } */ +/* { dg-require-effective-target int32plus } */ + +struct S1 +{ + int i; +}; + +#pragma scalar_storage_order big-endian + +struct S2 +{ + int i; +}; + +#pragma scalar_storage_order default + +struct S3 +{ + int i; +}; + +struct S1 my_s1 = { 0x12345678 }; +struct S2 my_s2 = { 0x12345678 }; +struct S3 my_s3 = { 0x12345678 }; + +unsigned char big_endian_pattern[4] = { 0x12, 0x34, 0x56, 0x78 }; +unsigned char little_endian_pattern[4] = { 0x78, 0x56, 0x34, 0x12 }; + +int main (void) +{ + if (__builtin_memcmp (&my_s1, &little_endian_pattern, 4) != 0) + __builtin_abort (); + + if (__builtin_memcmp (&my_s2, &big_endian_pattern, 4) != 0) + __builtin_abort (); + + if (__builtin_memcmp (&my_s3, &little_endian_pattern, 4) != 0) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ssp-1.c b/SingleSource/Regression/C/gcc-dg/ssp-1.c new file mode 100644 index 0000000000..db693327f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ssp-1.c @@ -0,0 +1,23 @@ +/* { dg-do run { target native } } */ +/* { dg-options "-fstack-protector" } */ +/* { dg-require-effective-target fstack_protector } */ + +#include + +void +__stack_chk_fail (void) +{ + exit (0); /* pass */ +} + +int main () +{ + register int i; + char foo[255]; + + // smash stack + for (i = 0; i <= 400; i++) + foo[i] = 42; + + return 1; /* fail */ +} diff --git a/SingleSource/Regression/C/gcc-dg/ssp-2.c b/SingleSource/Regression/C/gcc-dg/ssp-2.c new file mode 100644 index 0000000000..752fe5393f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ssp-2.c @@ -0,0 +1,29 @@ +/* { dg-do run { target native } } */ +/* { dg-options "-fstack-protector" } */ +/* { dg-options "-fstack-protector -Wl,-multiply_defined,suppress" { target *-*-darwin* } } */ +/* { dg-require-effective-target fstack_protector } */ + +#include + +void +__stack_chk_fail (void) +{ + exit (0); /* pass */ +} + +void +overflow() +{ + register int i = 0; + char foo[30]; + + /* Overflow buffer. */ + for (i = 0; i < 50; i++) + foo[i] = 42; +} + +int main (void) +{ + overflow (); + return 1; /* fail */ +} diff --git a/SingleSource/Regression/C/gcc-dg/ssp-3.c b/SingleSource/Regression/C/gcc-dg/ssp-3.c new file mode 100644 index 0000000000..98c12da8ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ssp-3.c @@ -0,0 +1,16 @@ +/* { dg-do assemble } */ +/* { dg-options "-fstack-protector-strong -O1 -frename-registers" } */ +/* { dg-require-effective-target fstack_protector } */ + +extern int bar (const char *s, int *argc); +extern int baz (const char *s); + +char +foo (const char *s) +{ + int argc; + int ret; + if ( !bar (s, &argc)) + ret = baz (s); + return *s; +} diff --git a/SingleSource/Regression/C/gcc-dg/ssp-4.c b/SingleSource/Regression/C/gcc-dg/ssp-4.c new file mode 100644 index 0000000000..402033c240 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ssp-4.c @@ -0,0 +1,18 @@ +/* { dg-do assemble } */ +/* { dg-options "-fstack-protector-strong -O1 -frename-registers" } */ +/* { dg-require-effective-target fstack_protector } */ + +typedef unsigned int uint32_t; +struct ctx +{ + uint32_t A; +}; + +void * +buffer_copy (const struct ctx *ctx, void *resbuf) +{ + uint32_t buffer[4]; + buffer[0] = (ctx->A); + __builtin_memcpy (resbuf, buffer, sizeof (buffer)); + return resbuf; +} diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-10.c b/SingleSource/Regression/C/gcc-dg/stack-check-10.c new file mode 100644 index 0000000000..2f5a090cb7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-10.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + +int f (int *); + +int +g (int a) +{ + return f (&a); +} + +int f1 (void); +int f2 (int); + +int +f3 (void) +{ + return f2 (f1 ()); +} + + +/* If we have caller implicit probes, then we should not need probes in either callee. + Else callees may need probes, particularly if non-leaf functions require a + frame/frame pointer. */ +/* { dg-final { scan-rtl-dump-times "Stack clash no probe" 2 "pro_and_epilogue" { target caller_implicit_probes } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash inline probe" 1 "pro_and_epilogue" { target { ! caller_implicit_probes } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash no probe" 1 "pro_and_epilogue" { target { ! caller_implicit_probes } } } } */ + +/* Neither of these functions are a nonreturn function. */ +/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 2 "pro_and_epilogue" } } */ + +/* If the callee realigns the stack or has a mandatory frame, then both functions + have a residual allocation. Else just g() has a residual allocation. */ +/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 2 "pro_and_epilogue" } } */ + + +/* If the target has frame pointers for non-leafs, then both functions will + need a frame pointer. Otherwise neither should. */ +/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 2 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash no probe small stack adjustment in prologue" 2 "pro_and_epilogue" { target { aarch64*-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-16.c b/SingleSource/Regression/C/gcc-dg/stack-check-16.c new file mode 100644 index 0000000000..9f89a79fc0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-16.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-fstack-clash-protection" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + +int printf (const char *, ...); +void blah (char *space) { } +void mtrace (void); + +int do_test (void) +{ + blah (__builtin_alloca (10)); + mtrace (); + printf ( +#define A(a) "%" #a "$s" +#define B(a) A(a) +#define C(a,b,c,d) B(a##b##c##d) +#define D(a,b,c) C(a,b,c,1) C(a,b,c,2) C(a,b,c,3) C(a,b,c,4) C(a,b,c,5) \ + C(a,b,c,6) C(a,b,c,7) C(a,b,c,8) C(a,b,c,9) +#define E(a,b,c) C(a,b,c,0) D(a,b,c) +#define F(a,b) E(a,b,1) E(a,b,2) E(a,b,3) E(a,b,4) E(a,b,5) \ + E(a,b,6) E(a,b,7) E(a,b,8) E(a,b,9) +#define G(a,b) E(a,b,0) F(a,b) +#define H(a) G(a,1) G(a,2) G(a,3) G(a,4) G(a,5) G(a,6) G(a,7) G(a,8) G(a,9) +#define I(a) G(a,0) H(a) +#define J I(1) I(2) I(3) I(4) I(5) I(6) I(7) I(8) I(9) + D(,,) + F(,) + H() + J + C(10,0,0,0) C(10,0,0,1), +#undef A +#define A(a) "a", + I(0) J + "\n"); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-2.c b/SingleSource/Regression/C/gcc-dg/stack-check-2.c new file mode 100644 index 0000000000..196c4bbfbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-2.c @@ -0,0 +1,66 @@ +/* The goal here is to ensure that we never consider a call to a noreturn + function as a potential tail call. + + Right now GCC discovers potential tail calls by looking at the + predecessors of the exit block. A call to a non-return function + has no successors and thus can never match that first filter. + + But that could change one day and we want to catch it. The problem + is the compiler could potentially optimize a tail call to a nonreturn + function, even if the caller has a frame. That breaks the assumption + that calls probe *sp when saving the return address that some targets + depend on to elide stack probes. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-tree-tailc -fdump-tree-optimized" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + +extern void foo (void) __attribute__ ((__noreturn__)); + + +void +test_direct_1 (void) +{ + foo (); +} + +void +test_direct_2 (void) +{ + return foo (); +} + +void (*indirect)(void)__attribute__ ((noreturn)); + + +void +test_indirect_1 () +{ + (*indirect)(); +} + +void +test_indirect_2 (void) +{ + return (*indirect)();; +} + + +typedef void (*pvfn)() __attribute__ ((noreturn)); + +void (*indirect_casted)(void); + +void +test_indirect_casted_1 () +{ + (*(pvfn)indirect_casted)(); +} + +void +test_indirect_casted_2 (void) +{ + return (*(pvfn)indirect_casted)(); +} +/* { dg-final { scan-tree-dump-not "tail call" "tailc" } } */ +/* { dg-final { scan-tree-dump-not "tail call" "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-3.c b/SingleSource/Regression/C/gcc-dg/stack-check-3.c new file mode 100644 index 0000000000..f0bf7c71a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-3.c @@ -0,0 +1,86 @@ +/* The goal here is to ensure that dynamic allocations via vlas or + alloca calls receive probing. + + Scanning the RTL or assembly code seems like insanity here as does + checking for particular allocation sizes and probe offsets. For + now we just verify that there's an allocation + probe loop and + residual allocation + probe for f?. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-expand -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + +__attribute__((noinline, noclone)) void +foo (char *p) +{ + asm volatile ("" : : "r" (p) : "memory"); +} + +/* Simple VLA, no other locals. */ +__attribute__((noinline, noclone)) void +f0 (int x) +{ + char vla[x]; + foo (vla); +} + +/* Simple VLA, small local frame. */ +__attribute__((noinline, noclone)) void +f1 (int x) +{ + char locals[128]; + char vla[x]; + foo (vla); +} + +/* Small constant alloca, no other locals. */ +__attribute__((noinline, noclone)) void +f2 (int x) +{ + char *vla = __builtin_alloca (128); + foo (vla); +} + +/* Big constant alloca, small local frame. */ +__attribute__((noinline, noclone)) void +f3 (int x) +{ + char locals[128]; + char *vla = __builtin_alloca (16384); + foo (vla); +} + +/* Big constant alloca, small local frame. */ +__attribute__((noinline, noclone)) void +f3a (int x) +{ + char locals[128]; + char *vla = __builtin_alloca (32768); + foo (vla); +} + +/* Nonconstant alloca, no other locals. */ +__attribute__((noinline, noclone)) void +f4 (int x) +{ + char *vla = __builtin_alloca (x); + foo (vla); +} + +/* Nonconstant alloca, small local frame. */ +__attribute__((noinline, noclone)) void +f5 (int x) +{ + char locals[128]; + char *vla = __builtin_alloca (x); + foo (vla); +} + +/* { dg-final { scan-rtl-dump-times "allocation and probing residuals" 7 "expand" } } */ + + +/* { dg-final { scan-rtl-dump-times "allocation and probing in loop" 7 "expand" { target callee_realigns_stack } } } */ +/* { dg-final { scan-rtl-dump-times "allocation and probing in loop" 4 "expand" { target { ! callee_realigns_stack } } } } */ +/* { dg-final { scan-rtl-dump-times "allocation and probing in rotated loop" 1 "expand" { target { ! callee_realigns_stack } } } } */ +/* { dg-final { scan-rtl-dump-times "allocation and probing inline" 1 "expand" { target { ! callee_realigns_stack } } } } */ +/* { dg-final { scan-rtl-dump-times "skipped dynamic allocation and probing loop" 1 "expand" { target { ! callee_realigns_stack } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-4.c b/SingleSource/Regression/C/gcc-dg/stack-check-4.c new file mode 100644 index 0000000000..b0c5c61972 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-4.c @@ -0,0 +1,42 @@ +/* On targets where the call instruction is an implicit probe of *sp, we + elide stack probes as long as the size of the local stack is less than + PROBE_INTERVAL. + + But if the caller were to transform a tail call into a direct jump + we do not have that implicit probe. This normally isn't a problem as + the caller must not have a local frame for that optimization to apply. + + However, a sufficiently smart compiler could realize that the caller's + local stack need not be torn down and thus could transform a call into + a jump if the target is a noreturn function, even if the caller has + a local frame. + + To guard against that, targets that depend on *sp being probed by the + call itself must emit a probe if the target function is a noreturn + function, even if they just allocate a small amount of stack space. + + Rather than try to parse RTL or assembly code, we instead require the + prologue code to emit information into the dump file that we can + scan for. We scan for both the positive and negative cases. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + +extern void arf (char *); + +__attribute__ ((noreturn)) void foo1 () +{ + char x[10]; + while (1) + arf (x); +} + +void foo2 () +{ + char x[10]; + arf (x); +} +/* { dg-final { scan-rtl-dump-times "Stack clash noreturn" 1 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 1 "pro_and_epilogue" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-5.c b/SingleSource/Regression/C/gcc-dg/stack-check-5.c new file mode 100644 index 0000000000..0243147939 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-5.c @@ -0,0 +1,81 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ +/* { dg-skip-if "" { *-*-* } { "-fstack-protector*" } { "" } } */ + + +/* Otherwise the S/390 back-end might save the stack pointer in f2 () + into an FPR. */ +/* { dg-additional-options "-msoft-float" { target { s390x-*-* } } } */ + +extern void foo (char *); +extern void bar (void); + +/* This function allocates no local stack and is a leaf. It should have no + probes on any target and should not require a frame pointer. */ +int +f0 (int x, int y) +{ + asm volatile ("" : : : "memory"); + return x + y; +} + +/* This function allocates no local stack, but is not a leaf. Ideally it + should not need probing and no frame pointer. */ +int +f1 (int x, int y) +{ + asm volatile ("" : : : "memory"); + bar (); +} + +/* This is a leaf with a small frame. On targets with implicit probes in + the caller, this should not need probing. On targets with no implicit + probes in the caller, it may require probes. Ideally it should need no + frame pointer. */ +void +f2 (void) +{ + char buf[512]; + asm volatile ("" : : "g" (&buf) : "memory"); +} + +/* This is a non-leaf with a small frame. On targets with implicit probes in + the caller, this should not need probing. On targets with no implicit + probes in the caller, it may require probes. It should need no frame + pointer. */ +void +f3 (void) +{ + char buf[512]; + foo (buf); +} + +/* If we have caller implicit probes, then we should not need probes. + Else callees may need probes, particularly if non-leaf functions require a + frame/frame pointer. */ +/* { dg-final { scan-rtl-dump-times "Stack clash no probe" 4 "pro_and_epilogue" { target caller_implicit_probes } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash no probe" 2 "pro_and_epilogue" { target { ! caller_implicit_probes } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash inline probes " 2 "pro_and_epilogue" { target { ! caller_implicit_probes } } } } */ + +/* None of these functions are marked with the noreturn attribute. */ +/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 4 "pro_and_epilogue" } } */ + +/* Two functions are leafs, two are not. Verify the target identified them + appropriately. */ +/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 4 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */ +/* AArch64 won't require a probe here due to the allocation amount being less than 1KB. */ +/* { dg-final { scan-rtl-dump-times "Stack clash no probe small stack adjustment in prologue" 3 "pro_and_epilogue" { target { aarch64*-*-* } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash no probe no stack adjustment in prologue" 1 "pro_and_epilogue" { target { aarch64*-*-* } } } } */ + +/* We have selected the size of the array in f2/f3 to be large enough + to not live in the red zone on targets that support it. + + That allows simplification of this test considerably. + f1() should not require any allocations, thus no residuals. + All the rest of the functions require some kind of allocation, + either for the saved fp/rp or the array. */ +/* { dg-final { scan-rtl-dump-times "Stack clash no residual allocation in prologue" 1 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 3 "pro_and_epilogue" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-6.c b/SingleSource/Regression/C/gcc-dg/stack-check-6.c new file mode 100644 index 0000000000..fe75612b73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-6.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ +/* { dg-skip-if "" { *-*-* } { "-fstack-protector*" } { "" } } */ + + +extern void foo (char *); +extern void bar (void); + + +/* This is a leaf with a frame that is large enough to require probing with + a residual allocation, but small enough to probe inline. */ +void +f4 (void) +{ + char buf[4096 + 512]; + asm volatile ("" : : "g" (&buf) : "memory"); +} + + +/* This is a non-leaf with a frame large enough to require probing and + a residual allocation, but small enough to probe inline. */ +void +f5 (void) +{ + char buf[4096 + 512]; + foo (buf); +} + +/* This is a leaf with a frame that is large enough to require probing with + a loop plus a residual allocation. */ +void +f6 (void) +{ + char buf[4096 * 10 + 512]; + asm volatile ("" : : "g" (&buf) : "memory"); +} + + +/* This is a non-leaf with a frame large enough to require probing with + a loop plus a residual allocation. */ +void +f7 (void) +{ + char buf[4096 * 10 + 512]; + foo (buf); +} + +/* { dg-final { scan-rtl-dump-times "Stack clash inline probes" 2 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash probe loop" 2 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 4 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 4 "pro_and_epilogue" } } */ + +/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 4 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-6a.c b/SingleSource/Regression/C/gcc-dg/stack-check-6a.c new file mode 100644 index 0000000000..68dd9bc48a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-6a.c @@ -0,0 +1,20 @@ +/* The goal here is to verify that increasing the size of the guard allows + elimination of all probing on the relevant targets. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=16" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ +/* { dg-skip-if "" { *-*-* } { "-fstack-protector*" } { "" } } */ +/* { dg-skip-if "" { aarch64*-*-* } } */ + + +#include "stack-check-6.c" + +/* { dg-final { scan-rtl-dump-times "Stack clash inline probes" 0 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash probe loop" 0 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 4 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 4 "pro_and_epilogue" } } */ + +/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 4 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-7.c b/SingleSource/Regression/C/gcc-dg/stack-check-7.c new file mode 100644 index 0000000000..b963a2881d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-7.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fstack-clash-protection -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + +/* For further testing, this can be run under valgrind where it's crashed + on aarch64 and ppc64le with -fstack-check=specific. */ + + +__attribute__((noinline, noclone)) void +foo (char *p) +{ + asm volatile ("" : : "r" (p) : "memory"); +} + +__attribute__((noinline, noclone)) void +bar (void) +{ + char buf[131072]; + foo (buf); +} + +__attribute__((noinline, noclone)) void +baz (void) +{ + char buf[12000]; + foo (buf); +} + +int +main () +{ + bar (); + baz (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-8.c b/SingleSource/Regression/C/gcc-dg/stack-check-8.c new file mode 100644 index 0000000000..84d5adef15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-8.c @@ -0,0 +1,139 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fstack-clash-protection -Wno-psabi -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + + +typedef float V __attribute__((vector_size (32))); + +__attribute__((noinline, noclone)) void +foo (char *p) +{ + asm volatile ("" : : "r" (p) : "memory"); +} + +__attribute__((noinline, noclone)) int +f0 (int x, int y) +{ + asm volatile ("" : : : "memory"); + return x + y; +} + +__attribute__((noinline, noclone)) void +f1 (void) +{ + char buf[64]; + foo (buf); +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + char buf[12000]; + foo (buf); +} + +__attribute__((noinline, noclone)) void +f3 (void) +{ + char buf[131072]; + foo (buf); +} + +__attribute__((noinline, noclone)) void +f4 (int x) +{ + char vla[x]; + foo (vla); +} + +__attribute__((noinline, noclone)) void +f5 (int x) +{ + char buf[12000]; + foo (buf); + { + char vla[x]; + foo (vla); + } + { + char vla[x]; + foo (vla); + } +} + +V v; + +__attribute__((noinline, noclone)) int +f6 (int x, int y, V a, V b, V c) +{ + asm volatile ("" : : : "memory"); + v = a + b + c; + return x + y; +} + +__attribute__((noinline, noclone)) void +f7 (V a, V b, V c) +{ + char buf[64]; + foo (buf); + v = a + b + c; +} + +__attribute__((noinline, noclone)) void +f8 (V a, V b, V c) +{ + char buf[12000]; + foo (buf); + v = a + b + c; +} + +__attribute__((noinline, noclone)) void +f9 (V a, V b, V c) +{ + char buf[131072]; + foo (buf); + v = a + b + c; +} + +__attribute__((noinline, noclone)) void +f10 (int x, V a, V b, V c) +{ + char vla[x]; + foo (vla); + v = a + b + c; +} + +__attribute__((noinline, noclone)) void +f11 (int x, V a, V b, V c) +{ + char buf[12000]; + foo (buf); + v = a + b + c; + { + char vla[x]; + foo (vla); + } + { + char vla[x]; + foo (vla); + } +} + +int +main () +{ + f0 (2, 3); + f1 (); + f2 (); + f3 (); + f4 (12000); + f5 (12000); + f6 (2, 3, v, v, v); + f7 (v, v, v); + f8 (v, v, v); + f9 (v, v, v); + f10 (12000, v, v, v); + f11 (12000, v, v, v); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/stack-check-9.c b/SingleSource/Regression/C/gcc-dg/stack-check-9.c new file mode 100644 index 0000000000..b84075b9b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-check-9.c @@ -0,0 +1,2022 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls --param stack-clash-protection-probe-interval=12 --param stack-clash-protection-guard-size=12" } */ +/* { dg-require-effective-target supports_stack_clash_protection } */ + +double f1 (void); +double f2 (double, double); + +double +f3 (void) +{ + double d000 = f1 (); + double d001 = f1 (); + double d002 = f1 (); + double d003 = f1 (); + double d004 = f1 (); + double d005 = f1 (); + double d006 = f1 (); + double d007 = f1 (); + double d008 = f1 (); + double d009 = f1 (); + double d010 = f1 (); + double d011 = f1 (); + double d012 = f1 (); + double d013 = f1 (); + double d014 = f1 (); + double d015 = f1 (); + double d016 = f1 (); + double d017 = f1 (); + double d018 = f1 (); + double d019 = f1 (); + double d020 = f1 (); + double d021 = f1 (); + double d022 = f1 (); + double d023 = f1 (); + double d024 = f1 (); + double d025 = f1 (); + double d026 = f1 (); + double d027 = f1 (); + double d028 = f1 (); + double d029 = f1 (); + double d030 = f1 (); + double d031 = f1 (); + double d032 = f1 (); + double d033 = f1 (); + double d034 = f1 (); + double d035 = f1 (); + double d036 = f1 (); + double d037 = f1 (); + double d038 = f1 (); + double d039 = f1 (); + double d040 = f1 (); + double d041 = f1 (); + double d042 = f1 (); + double d043 = f1 (); + double d044 = f1 (); + double d045 = f1 (); + double d046 = f1 (); + double d047 = f1 (); + double d048 = f1 (); + double d049 = f1 (); + double d050 = f1 (); + double d051 = f1 (); + double d052 = f1 (); + double d053 = f1 (); + double d054 = f1 (); + double d055 = f1 (); + double d056 = f1 (); + double d057 = f1 (); + double d058 = f1 (); + double d059 = f1 (); + double d060 = f1 (); + double d061 = f1 (); + double d062 = f1 (); + double d063 = f1 (); + double d064 = f1 (); + double d065 = f1 (); + double d066 = f1 (); + double d067 = f1 (); + double d068 = f1 (); + double d069 = f1 (); + double d070 = f1 (); + double d071 = f1 (); + double d072 = f1 (); + double d073 = f1 (); + double d074 = f1 (); + double d075 = f1 (); + double d076 = f1 (); + double d077 = f1 (); + double d078 = f1 (); + double d079 = f1 (); + double d080 = f1 (); + double d081 = f1 (); + double d082 = f1 (); + double d083 = f1 (); + double d084 = f1 (); + double d085 = f1 (); + double d086 = f1 (); + double d087 = f1 (); + double d088 = f1 (); + double d089 = f1 (); + double d090 = f1 (); + double d091 = f1 (); + double d092 = f1 (); + double d093 = f1 (); + double d094 = f1 (); + double d095 = f1 (); + double d096 = f1 (); + double d097 = f1 (); + double d098 = f1 (); + double d099 = f1 (); + double d100 = f1 (); + double d101 = f1 (); + double d102 = f1 (); + double d103 = f1 (); + double d104 = f1 (); + double d105 = f1 (); + double d106 = f1 (); + double d107 = f1 (); + double d108 = f1 (); + double d109 = f1 (); + double d110 = f1 (); + double d111 = f1 (); + double d112 = f1 (); + double d113 = f1 (); + double d114 = f1 (); + double d115 = f1 (); + double d116 = f1 (); + double d117 = f1 (); + double d118 = f1 (); + double d119 = f1 (); + double d120 = f1 (); + double d121 = f1 (); + double d122 = f1 (); + double d123 = f1 (); + double d124 = f1 (); + double d125 = f1 (); + double d126 = f1 (); + double d127 = f1 (); + double d128 = f1 (); + double d129 = f1 (); + double d130 = f1 (); + double d131 = f1 (); + double d132 = f1 (); + double d133 = f1 (); + double d134 = f1 (); + double d135 = f1 (); + double d136 = f1 (); + double d137 = f1 (); + double d138 = f1 (); + double d139 = f1 (); + double d140 = f1 (); + double d141 = f1 (); + double d142 = f1 (); + double d143 = f1 (); + double d144 = f1 (); + double d145 = f1 (); + double d146 = f1 (); + double d147 = f1 (); + double d148 = f1 (); + double d149 = f1 (); + double d150 = f1 (); + double d151 = f1 (); + double d152 = f1 (); + double d153 = f1 (); + double d154 = f1 (); + double d155 = f1 (); + double d156 = f1 (); + double d157 = f1 (); + double d158 = f1 (); + double d159 = f1 (); + double d160 = f1 (); + double d161 = f1 (); + double d162 = f1 (); + double d163 = f1 (); + double d164 = f1 (); + double d165 = f1 (); + double d166 = f1 (); + double d167 = f1 (); + double d168 = f1 (); + double d169 = f1 (); + double d170 = f1 (); + double d171 = f1 (); + double d172 = f1 (); + double d173 = f1 (); + double d174 = f1 (); + double d175 = f1 (); + double d176 = f1 (); + double d177 = f1 (); + double d178 = f1 (); + double d179 = f1 (); + double d180 = f1 (); + double d181 = f1 (); + double d182 = f1 (); + double d183 = f1 (); + double d184 = f1 (); + double d185 = f1 (); + double d186 = f1 (); + double d187 = f1 (); + double d188 = f1 (); + double d189 = f1 (); + double d190 = f1 (); + double d191 = f1 (); + double d192 = f1 (); + double d193 = f1 (); + double d194 = f1 (); + double d195 = f1 (); + double d196 = f1 (); + double d197 = f1 (); + double d198 = f1 (); + double d199 = f1 (); + double d200 = f1 (); + double d201 = f1 (); + double d202 = f1 (); + double d203 = f1 (); + double d204 = f1 (); + double d205 = f1 (); + double d206 = f1 (); + double d207 = f1 (); + double d208 = f1 (); + double d209 = f1 (); + double d210 = f1 (); + double d211 = f1 (); + double d212 = f1 (); + double d213 = f1 (); + double d214 = f1 (); + double d215 = f1 (); + double d216 = f1 (); + double d217 = f1 (); + double d218 = f1 (); + double d219 = f1 (); + double d220 = f1 (); + double d221 = f1 (); + double d222 = f1 (); + double d223 = f1 (); + double d224 = f1 (); + double d225 = f1 (); + double d226 = f1 (); + double d227 = f1 (); + double d228 = f1 (); + double d229 = f1 (); + double d230 = f1 (); + double d231 = f1 (); + double d232 = f1 (); + double d233 = f1 (); + double d234 = f1 (); + double d235 = f1 (); + double d236 = f1 (); + double d237 = f1 (); + double d238 = f1 (); + double d239 = f1 (); + double d240 = f1 (); + double d241 = f1 (); + double d242 = f1 (); + double d243 = f1 (); + double d244 = f1 (); + double d245 = f1 (); + double d246 = f1 (); + double d247 = f1 (); + double d248 = f1 (); + double d249 = f1 (); + double d250 = f1 (); + double d251 = f1 (); + double d252 = f1 (); + double d253 = f1 (); + double d254 = f1 (); + double d255 = f1 (); + double d256 = f1 (); + double d257 = f1 (); + double d258 = f1 (); + double d259 = f1 (); + double d260 = f1 (); + double d261 = f1 (); + double d262 = f1 (); + double d263 = f1 (); + double d264 = f1 (); + double d265 = f1 (); + double d266 = f1 (); + double d267 = f1 (); + double d268 = f1 (); + double d269 = f1 (); + double d270 = f1 (); + double d271 = f1 (); + double d272 = f1 (); + double d273 = f1 (); + double d274 = f1 (); + double d275 = f1 (); + double d276 = f1 (); + double d277 = f1 (); + double d278 = f1 (); + double d279 = f1 (); + double d280 = f1 (); + double d281 = f1 (); + double d282 = f1 (); + double d283 = f1 (); + double d284 = f1 (); + double d285 = f1 (); + double d286 = f1 (); + double d287 = f1 (); + double d288 = f1 (); + double d289 = f1 (); + double d290 = f1 (); + double d291 = f1 (); + double d292 = f1 (); + double d293 = f1 (); + double d294 = f1 (); + double d295 = f1 (); + double d296 = f1 (); + double d297 = f1 (); + double d298 = f1 (); + double d299 = f1 (); + double d300 = f1 (); + double d301 = f1 (); + double d302 = f1 (); + double d303 = f1 (); + double d304 = f1 (); + double d305 = f1 (); + double d306 = f1 (); + double d307 = f1 (); + double d308 = f1 (); + double d309 = f1 (); + double d310 = f1 (); + double d311 = f1 (); + double d312 = f1 (); + double d313 = f1 (); + double d314 = f1 (); + double d315 = f1 (); + double d316 = f1 (); + double d317 = f1 (); + double d318 = f1 (); + double d319 = f1 (); + double d320 = f1 (); + double d321 = f1 (); + double d322 = f1 (); + double d323 = f1 (); + double d324 = f1 (); + double d325 = f1 (); + double d326 = f1 (); + double d327 = f1 (); + double d328 = f1 (); + double d329 = f1 (); + double d330 = f1 (); + double d331 = f1 (); + double d332 = f1 (); + double d333 = f1 (); + double d334 = f1 (); + double d335 = f1 (); + double d336 = f1 (); + double d337 = f1 (); + double d338 = f1 (); + double d339 = f1 (); + double d340 = f1 (); + double d341 = f1 (); + double d342 = f1 (); + double d343 = f1 (); + double d344 = f1 (); + double d345 = f1 (); + double d346 = f1 (); + double d347 = f1 (); + double d348 = f1 (); + double d349 = f1 (); + double d350 = f1 (); + double d351 = f1 (); + double d352 = f1 (); + double d353 = f1 (); + double d354 = f1 (); + double d355 = f1 (); + double d356 = f1 (); + double d357 = f1 (); + double d358 = f1 (); + double d359 = f1 (); + double d360 = f1 (); + double d361 = f1 (); + double d362 = f1 (); + double d363 = f1 (); + double d364 = f1 (); + double d365 = f1 (); + double d366 = f1 (); + double d367 = f1 (); + double d368 = f1 (); + double d369 = f1 (); + double d370 = f1 (); + double d371 = f1 (); + double d372 = f1 (); + double d373 = f1 (); + double d374 = f1 (); + double d375 = f1 (); + double d376 = f1 (); + double d377 = f1 (); + double d378 = f1 (); + double d379 = f1 (); + double d380 = f1 (); + double d381 = f1 (); + double d382 = f1 (); + double d383 = f1 (); + double d384 = f1 (); + double d385 = f1 (); + double d386 = f1 (); + double d387 = f1 (); + double d388 = f1 (); + double d389 = f1 (); + double d390 = f1 (); + double d391 = f1 (); + double d392 = f1 (); + double d393 = f1 (); + double d394 = f1 (); + double d395 = f1 (); + double d396 = f1 (); + double d397 = f1 (); + double d398 = f1 (); + double d399 = f1 (); + double d400 = f1 (); + double d401 = f1 (); + double d402 = f1 (); + double d403 = f1 (); + double d404 = f1 (); + double d405 = f1 (); + double d406 = f1 (); + double d407 = f1 (); + double d408 = f1 (); + double d409 = f1 (); + double d410 = f1 (); + double d411 = f1 (); + double d412 = f1 (); + double d413 = f1 (); + double d414 = f1 (); + double d415 = f1 (); + double d416 = f1 (); + double d417 = f1 (); + double d418 = f1 (); + double d419 = f1 (); + double d420 = f1 (); + double d421 = f1 (); + double d422 = f1 (); + double d423 = f1 (); + double d424 = f1 (); + double d425 = f1 (); + double d426 = f1 (); + double d427 = f1 (); + double d428 = f1 (); + double d429 = f1 (); + double d430 = f1 (); + double d431 = f1 (); + double d432 = f1 (); + double d433 = f1 (); + double d434 = f1 (); + double d435 = f1 (); + double d436 = f1 (); + double d437 = f1 (); + double d438 = f1 (); + double d439 = f1 (); + double d440 = f1 (); + double d441 = f1 (); + double d442 = f1 (); + double d443 = f1 (); + double d444 = f1 (); + double d445 = f1 (); + double d446 = f1 (); + double d447 = f1 (); + double d448 = f1 (); + double d449 = f1 (); + double d450 = f1 (); + double d451 = f1 (); + double d452 = f1 (); + double d453 = f1 (); + double d454 = f1 (); + double d455 = f1 (); + double d456 = f1 (); + double d457 = f1 (); + double d458 = f1 (); + double d459 = f1 (); + double d460 = f1 (); + double d461 = f1 (); + double d462 = f1 (); + double d463 = f1 (); + double d464 = f1 (); + double d465 = f1 (); + double d466 = f1 (); + double d467 = f1 (); + double d468 = f1 (); + double d469 = f1 (); + double d470 = f1 (); + double d471 = f1 (); + double d472 = f1 (); + double d473 = f1 (); + double d474 = f1 (); + double d475 = f1 (); + double d476 = f1 (); + double d477 = f1 (); + double d478 = f1 (); + double d479 = f1 (); + double d480 = f1 (); + double d481 = f1 (); + double d482 = f1 (); + double d483 = f1 (); + double d484 = f1 (); + double d485 = f1 (); + double d486 = f1 (); + double d487 = f1 (); + double d488 = f1 (); + double d489 = f1 (); + double d490 = f1 (); + double d491 = f1 (); + double d492 = f1 (); + double d493 = f1 (); + double d494 = f1 (); + double d495 = f1 (); + double d496 = f1 (); + double d497 = f1 (); + double d498 = f1 (); + double d499 = f1 (); + double d500 = f1 (); + double d501 = f1 (); + double d502 = f1 (); + double d503 = f1 (); + double d504 = f1 (); + double d505 = f1 (); + double d506 = f1 (); + double d507 = f1 (); + double d508 = f1 (); + double d509 = f1 (); + double d510 = f1 (); + double d511 = f1 (); + double d512 = f1 (); + double d513 = f1 (); + double d514 = f1 (); + double d515 = f1 (); + double d516 = f1 (); + double d517 = f1 (); + double d518 = f1 (); + double d519 = f1 (); + double d520 = f1 (); + double d521 = f1 (); + double d522 = f1 (); + double d523 = f1 (); + double d524 = f1 (); + double d525 = f1 (); + double d526 = f1 (); + double d527 = f1 (); + double d528 = f1 (); + double d529 = f1 (); + double d530 = f1 (); + double d531 = f1 (); + double d532 = f1 (); + double d533 = f1 (); + double d534 = f1 (); + double d535 = f1 (); + double d536 = f1 (); + double d537 = f1 (); + double d538 = f1 (); + double d539 = f1 (); + double d540 = f1 (); + double d541 = f1 (); + double d542 = f1 (); + double d543 = f1 (); + double d544 = f1 (); + double d545 = f1 (); + double d546 = f1 (); + double d547 = f1 (); + double d548 = f1 (); + double d549 = f1 (); + double d550 = f1 (); + double d551 = f1 (); + double d552 = f1 (); + double d553 = f1 (); + double d554 = f1 (); + double d555 = f1 (); + double d556 = f1 (); + double d557 = f1 (); + double d558 = f1 (); + double d559 = f1 (); + double d560 = f1 (); + double d561 = f1 (); + double d562 = f1 (); + double d563 = f1 (); + double d564 = f1 (); + double d565 = f1 (); + double d566 = f1 (); + double d567 = f1 (); + double d568 = f1 (); + double d569 = f1 (); + double d570 = f1 (); + double d571 = f1 (); + double d572 = f1 (); + double d573 = f1 (); + double d574 = f1 (); + double d575 = f1 (); + double d576 = f1 (); + double d577 = f1 (); + double d578 = f1 (); + double d579 = f1 (); + double d580 = f1 (); + double d581 = f1 (); + double d582 = f1 (); + double d583 = f1 (); + double d584 = f1 (); + double d585 = f1 (); + double d586 = f1 (); + double d587 = f1 (); + double d588 = f1 (); + double d589 = f1 (); + double d590 = f1 (); + double d591 = f1 (); + double d592 = f1 (); + double d593 = f1 (); + double d594 = f1 (); + double d595 = f1 (); + double d596 = f1 (); + double d597 = f1 (); + double d598 = f1 (); + double d599 = f1 (); + double d600 = f1 (); + double d601 = f1 (); + double d602 = f1 (); + double d603 = f1 (); + double d604 = f1 (); + double d605 = f1 (); + double d606 = f1 (); + double d607 = f1 (); + double d608 = f1 (); + double d609 = f1 (); + double d610 = f1 (); + double d611 = f1 (); + double d612 = f1 (); + double d613 = f1 (); + double d614 = f1 (); + double d615 = f1 (); + double d616 = f1 (); + double d617 = f1 (); + double d618 = f1 (); + double d619 = f1 (); + double d620 = f1 (); + double d621 = f1 (); + double d622 = f1 (); + double d623 = f1 (); + double d624 = f1 (); + double d625 = f1 (); + double d626 = f1 (); + double d627 = f1 (); + double d628 = f1 (); + double d629 = f1 (); + double d630 = f1 (); + double d631 = f1 (); + double d632 = f1 (); + double d633 = f1 (); + double d634 = f1 (); + double d635 = f1 (); + double d636 = f1 (); + double d637 = f1 (); + double d638 = f1 (); + double d639 = f1 (); + double d640 = f1 (); + double d641 = f1 (); + double d642 = f1 (); + double d643 = f1 (); + double d644 = f1 (); + double d645 = f1 (); + double d646 = f1 (); + double d647 = f1 (); + double d648 = f1 (); + double d649 = f1 (); + double d650 = f1 (); + double d651 = f1 (); + double d652 = f1 (); + double d653 = f1 (); + double d654 = f1 (); + double d655 = f1 (); + double d656 = f1 (); + double d657 = f1 (); + double d658 = f1 (); + double d659 = f1 (); + double d660 = f1 (); + double d661 = f1 (); + double d662 = f1 (); + double d663 = f1 (); + double d664 = f1 (); + double d665 = f1 (); + double d666 = f1 (); + double d667 = f1 (); + double d668 = f1 (); + double d669 = f1 (); + double d670 = f1 (); + double d671 = f1 (); + double d672 = f1 (); + double d673 = f1 (); + double d674 = f1 (); + double d675 = f1 (); + double d676 = f1 (); + double d677 = f1 (); + double d678 = f1 (); + double d679 = f1 (); + double d680 = f1 (); + double d681 = f1 (); + double d682 = f1 (); + double d683 = f1 (); + double d684 = f1 (); + double d685 = f1 (); + double d686 = f1 (); + double d687 = f1 (); + double d688 = f1 (); + double d689 = f1 (); + double d690 = f1 (); + double d691 = f1 (); + double d692 = f1 (); + double d693 = f1 (); + double d694 = f1 (); + double d695 = f1 (); + double d696 = f1 (); + double d697 = f1 (); + double d698 = f1 (); + double d699 = f1 (); + double d700 = f1 (); + double d701 = f1 (); + double d702 = f1 (); + double d703 = f1 (); + double d704 = f1 (); + double d705 = f1 (); + double d706 = f1 (); + double d707 = f1 (); + double d708 = f1 (); + double d709 = f1 (); + double d710 = f1 (); + double d711 = f1 (); + double d712 = f1 (); + double d713 = f1 (); + double d714 = f1 (); + double d715 = f1 (); + double d716 = f1 (); + double d717 = f1 (); + double d718 = f1 (); + double d719 = f1 (); + double d720 = f1 (); + double d721 = f1 (); + double d722 = f1 (); + double d723 = f1 (); + double d724 = f1 (); + double d725 = f1 (); + double d726 = f1 (); + double d727 = f1 (); + double d728 = f1 (); + double d729 = f1 (); + double d730 = f1 (); + double d731 = f1 (); + double d732 = f1 (); + double d733 = f1 (); + double d734 = f1 (); + double d735 = f1 (); + double d736 = f1 (); + double d737 = f1 (); + double d738 = f1 (); + double d739 = f1 (); + double d740 = f1 (); + double d741 = f1 (); + double d742 = f1 (); + double d743 = f1 (); + double d744 = f1 (); + double d745 = f1 (); + double d746 = f1 (); + double d747 = f1 (); + double d748 = f1 (); + double d749 = f1 (); + double d750 = f1 (); + double d751 = f1 (); + double d752 = f1 (); + double d753 = f1 (); + double d754 = f1 (); + double d755 = f1 (); + double d756 = f1 (); + double d757 = f1 (); + double d758 = f1 (); + double d759 = f1 (); + double d760 = f1 (); + double d761 = f1 (); + double d762 = f1 (); + double d763 = f1 (); + double d764 = f1 (); + double d765 = f1 (); + double d766 = f1 (); + double d767 = f1 (); + double d768 = f1 (); + double d769 = f1 (); + double d770 = f1 (); + double d771 = f1 (); + double d772 = f1 (); + double d773 = f1 (); + double d774 = f1 (); + double d775 = f1 (); + double d776 = f1 (); + double d777 = f1 (); + double d778 = f1 (); + double d779 = f1 (); + double d780 = f1 (); + double d781 = f1 (); + double d782 = f1 (); + double d783 = f1 (); + double d784 = f1 (); + double d785 = f1 (); + double d786 = f1 (); + double d787 = f1 (); + double d788 = f1 (); + double d789 = f1 (); + double d790 = f1 (); + double d791 = f1 (); + double d792 = f1 (); + double d793 = f1 (); + double d794 = f1 (); + double d795 = f1 (); + double d796 = f1 (); + double d797 = f1 (); + double d798 = f1 (); + double d799 = f1 (); + double d800 = f1 (); + double d801 = f1 (); + double d802 = f1 (); + double d803 = f1 (); + double d804 = f1 (); + double d805 = f1 (); + double d806 = f1 (); + double d807 = f1 (); + double d808 = f1 (); + double d809 = f1 (); + double d810 = f1 (); + double d811 = f1 (); + double d812 = f1 (); + double d813 = f1 (); + double d814 = f1 (); + double d815 = f1 (); + double d816 = f1 (); + double d817 = f1 (); + double d818 = f1 (); + double d819 = f1 (); + double d820 = f1 (); + double d821 = f1 (); + double d822 = f1 (); + double d823 = f1 (); + double d824 = f1 (); + double d825 = f1 (); + double d826 = f1 (); + double d827 = f1 (); + double d828 = f1 (); + double d829 = f1 (); + double d830 = f1 (); + double d831 = f1 (); + double d832 = f1 (); + double d833 = f1 (); + double d834 = f1 (); + double d835 = f1 (); + double d836 = f1 (); + double d837 = f1 (); + double d838 = f1 (); + double d839 = f1 (); + double d840 = f1 (); + double d841 = f1 (); + double d842 = f1 (); + double d843 = f1 (); + double d844 = f1 (); + double d845 = f1 (); + double d846 = f1 (); + double d847 = f1 (); + double d848 = f1 (); + double d849 = f1 (); + double d850 = f1 (); + double d851 = f1 (); + double d852 = f1 (); + double d853 = f1 (); + double d854 = f1 (); + double d855 = f1 (); + double d856 = f1 (); + double d857 = f1 (); + double d858 = f1 (); + double d859 = f1 (); + double d860 = f1 (); + double d861 = f1 (); + double d862 = f1 (); + double d863 = f1 (); + double d864 = f1 (); + double d865 = f1 (); + double d866 = f1 (); + double d867 = f1 (); + double d868 = f1 (); + double d869 = f1 (); + double d870 = f1 (); + double d871 = f1 (); + double d872 = f1 (); + double d873 = f1 (); + double d874 = f1 (); + double d875 = f1 (); + double d876 = f1 (); + double d877 = f1 (); + double d878 = f1 (); + double d879 = f1 (); + double d880 = f1 (); + double d881 = f1 (); + double d882 = f1 (); + double d883 = f1 (); + double d884 = f1 (); + double d885 = f1 (); + double d886 = f1 (); + double d887 = f1 (); + double d888 = f1 (); + double d889 = f1 (); + double d890 = f1 (); + double d891 = f1 (); + double d892 = f1 (); + double d893 = f1 (); + double d894 = f1 (); + double d895 = f1 (); + double d896 = f1 (); + double d897 = f1 (); + double d898 = f1 (); + double d899 = f1 (); + double d900 = f1 (); + double d901 = f1 (); + double d902 = f1 (); + double d903 = f1 (); + double d904 = f1 (); + double d905 = f1 (); + double d906 = f1 (); + double d907 = f1 (); + double d908 = f1 (); + double d909 = f1 (); + double d910 = f1 (); + double d911 = f1 (); + double d912 = f1 (); + double d913 = f1 (); + double d914 = f1 (); + double d915 = f1 (); + double d916 = f1 (); + double d917 = f1 (); + double d918 = f1 (); + double d919 = f1 (); + double d920 = f1 (); + double d921 = f1 (); + double d922 = f1 (); + double d923 = f1 (); + double d924 = f1 (); + double d925 = f1 (); + double d926 = f1 (); + double d927 = f1 (); + double d928 = f1 (); + double d929 = f1 (); + double d930 = f1 (); + double d931 = f1 (); + double d932 = f1 (); + double d933 = f1 (); + double d934 = f1 (); + double d935 = f1 (); + double d936 = f1 (); + double d937 = f1 (); + double d938 = f1 (); + double d939 = f1 (); + double d940 = f1 (); + double d941 = f1 (); + double d942 = f1 (); + double d943 = f1 (); + double d944 = f1 (); + double d945 = f1 (); + double d946 = f1 (); + double d947 = f1 (); + double d948 = f1 (); + double d949 = f1 (); + double d950 = f1 (); + double d951 = f1 (); + double d952 = f1 (); + double d953 = f1 (); + double d954 = f1 (); + double d955 = f1 (); + double d956 = f1 (); + double d957 = f1 (); + double d958 = f1 (); + double d959 = f1 (); + double d960 = f1 (); + double d961 = f1 (); + double d962 = f1 (); + double d963 = f1 (); + double d964 = f1 (); + double d965 = f1 (); + double d966 = f1 (); + double d967 = f1 (); + double d968 = f1 (); + double d969 = f1 (); + double d970 = f1 (); + double d971 = f1 (); + double d972 = f1 (); + double d973 = f1 (); + double d974 = f1 (); + double d975 = f1 (); + double d976 = f1 (); + double d977 = f1 (); + double d978 = f1 (); + double d979 = f1 (); + double d980 = f1 (); + double d981 = f1 (); + double d982 = f1 (); + double d983 = f1 (); + double d984 = f1 (); + double d985 = f1 (); + double d986 = f1 (); + double d987 = f1 (); + double d988 = f1 (); + double d989 = f1 (); + double d990 = f1 (); + double d991 = f1 (); + double d992 = f1 (); + double d993 = f1 (); + double d994 = f1 (); + double d995 = f1 (); + double d996 = f1 (); + double d997 = f1 (); + double d998 = f1 (); + double d999 = f1 (); + + double x = 0; + x = f2 (x, d000); + x = f2 (x, d001); + x = f2 (x, d002); + x = f2 (x, d003); + x = f2 (x, d004); + x = f2 (x, d005); + x = f2 (x, d006); + x = f2 (x, d007); + x = f2 (x, d008); + x = f2 (x, d009); + x = f2 (x, d010); + x = f2 (x, d011); + x = f2 (x, d012); + x = f2 (x, d013); + x = f2 (x, d014); + x = f2 (x, d015); + x = f2 (x, d016); + x = f2 (x, d017); + x = f2 (x, d018); + x = f2 (x, d019); + x = f2 (x, d020); + x = f2 (x, d021); + x = f2 (x, d022); + x = f2 (x, d023); + x = f2 (x, d024); + x = f2 (x, d025); + x = f2 (x, d026); + x = f2 (x, d027); + x = f2 (x, d028); + x = f2 (x, d029); + x = f2 (x, d030); + x = f2 (x, d031); + x = f2 (x, d032); + x = f2 (x, d033); + x = f2 (x, d034); + x = f2 (x, d035); + x = f2 (x, d036); + x = f2 (x, d037); + x = f2 (x, d038); + x = f2 (x, d039); + x = f2 (x, d040); + x = f2 (x, d041); + x = f2 (x, d042); + x = f2 (x, d043); + x = f2 (x, d044); + x = f2 (x, d045); + x = f2 (x, d046); + x = f2 (x, d047); + x = f2 (x, d048); + x = f2 (x, d049); + x = f2 (x, d050); + x = f2 (x, d051); + x = f2 (x, d052); + x = f2 (x, d053); + x = f2 (x, d054); + x = f2 (x, d055); + x = f2 (x, d056); + x = f2 (x, d057); + x = f2 (x, d058); + x = f2 (x, d059); + x = f2 (x, d060); + x = f2 (x, d061); + x = f2 (x, d062); + x = f2 (x, d063); + x = f2 (x, d064); + x = f2 (x, d065); + x = f2 (x, d066); + x = f2 (x, d067); + x = f2 (x, d068); + x = f2 (x, d069); + x = f2 (x, d070); + x = f2 (x, d071); + x = f2 (x, d072); + x = f2 (x, d073); + x = f2 (x, d074); + x = f2 (x, d075); + x = f2 (x, d076); + x = f2 (x, d077); + x = f2 (x, d078); + x = f2 (x, d079); + x = f2 (x, d080); + x = f2 (x, d081); + x = f2 (x, d082); + x = f2 (x, d083); + x = f2 (x, d084); + x = f2 (x, d085); + x = f2 (x, d086); + x = f2 (x, d087); + x = f2 (x, d088); + x = f2 (x, d089); + x = f2 (x, d090); + x = f2 (x, d091); + x = f2 (x, d092); + x = f2 (x, d093); + x = f2 (x, d094); + x = f2 (x, d095); + x = f2 (x, d096); + x = f2 (x, d097); + x = f2 (x, d098); + x = f2 (x, d099); + x = f2 (x, d100); + x = f2 (x, d101); + x = f2 (x, d102); + x = f2 (x, d103); + x = f2 (x, d104); + x = f2 (x, d105); + x = f2 (x, d106); + x = f2 (x, d107); + x = f2 (x, d108); + x = f2 (x, d109); + x = f2 (x, d110); + x = f2 (x, d111); + x = f2 (x, d112); + x = f2 (x, d113); + x = f2 (x, d114); + x = f2 (x, d115); + x = f2 (x, d116); + x = f2 (x, d117); + x = f2 (x, d118); + x = f2 (x, d119); + x = f2 (x, d120); + x = f2 (x, d121); + x = f2 (x, d122); + x = f2 (x, d123); + x = f2 (x, d124); + x = f2 (x, d125); + x = f2 (x, d126); + x = f2 (x, d127); + x = f2 (x, d128); + x = f2 (x, d129); + x = f2 (x, d130); + x = f2 (x, d131); + x = f2 (x, d132); + x = f2 (x, d133); + x = f2 (x, d134); + x = f2 (x, d135); + x = f2 (x, d136); + x = f2 (x, d137); + x = f2 (x, d138); + x = f2 (x, d139); + x = f2 (x, d140); + x = f2 (x, d141); + x = f2 (x, d142); + x = f2 (x, d143); + x = f2 (x, d144); + x = f2 (x, d145); + x = f2 (x, d146); + x = f2 (x, d147); + x = f2 (x, d148); + x = f2 (x, d149); + x = f2 (x, d150); + x = f2 (x, d151); + x = f2 (x, d152); + x = f2 (x, d153); + x = f2 (x, d154); + x = f2 (x, d155); + x = f2 (x, d156); + x = f2 (x, d157); + x = f2 (x, d158); + x = f2 (x, d159); + x = f2 (x, d160); + x = f2 (x, d161); + x = f2 (x, d162); + x = f2 (x, d163); + x = f2 (x, d164); + x = f2 (x, d165); + x = f2 (x, d166); + x = f2 (x, d167); + x = f2 (x, d168); + x = f2 (x, d169); + x = f2 (x, d170); + x = f2 (x, d171); + x = f2 (x, d172); + x = f2 (x, d173); + x = f2 (x, d174); + x = f2 (x, d175); + x = f2 (x, d176); + x = f2 (x, d177); + x = f2 (x, d178); + x = f2 (x, d179); + x = f2 (x, d180); + x = f2 (x, d181); + x = f2 (x, d182); + x = f2 (x, d183); + x = f2 (x, d184); + x = f2 (x, d185); + x = f2 (x, d186); + x = f2 (x, d187); + x = f2 (x, d188); + x = f2 (x, d189); + x = f2 (x, d190); + x = f2 (x, d191); + x = f2 (x, d192); + x = f2 (x, d193); + x = f2 (x, d194); + x = f2 (x, d195); + x = f2 (x, d196); + x = f2 (x, d197); + x = f2 (x, d198); + x = f2 (x, d199); + x = f2 (x, d200); + x = f2 (x, d201); + x = f2 (x, d202); + x = f2 (x, d203); + x = f2 (x, d204); + x = f2 (x, d205); + x = f2 (x, d206); + x = f2 (x, d207); + x = f2 (x, d208); + x = f2 (x, d209); + x = f2 (x, d210); + x = f2 (x, d211); + x = f2 (x, d212); + x = f2 (x, d213); + x = f2 (x, d214); + x = f2 (x, d215); + x = f2 (x, d216); + x = f2 (x, d217); + x = f2 (x, d218); + x = f2 (x, d219); + x = f2 (x, d220); + x = f2 (x, d221); + x = f2 (x, d222); + x = f2 (x, d223); + x = f2 (x, d224); + x = f2 (x, d225); + x = f2 (x, d226); + x = f2 (x, d227); + x = f2 (x, d228); + x = f2 (x, d229); + x = f2 (x, d230); + x = f2 (x, d231); + x = f2 (x, d232); + x = f2 (x, d233); + x = f2 (x, d234); + x = f2 (x, d235); + x = f2 (x, d236); + x = f2 (x, d237); + x = f2 (x, d238); + x = f2 (x, d239); + x = f2 (x, d240); + x = f2 (x, d241); + x = f2 (x, d242); + x = f2 (x, d243); + x = f2 (x, d244); + x = f2 (x, d245); + x = f2 (x, d246); + x = f2 (x, d247); + x = f2 (x, d248); + x = f2 (x, d249); + x = f2 (x, d250); + x = f2 (x, d251); + x = f2 (x, d252); + x = f2 (x, d253); + x = f2 (x, d254); + x = f2 (x, d255); + x = f2 (x, d256); + x = f2 (x, d257); + x = f2 (x, d258); + x = f2 (x, d259); + x = f2 (x, d260); + x = f2 (x, d261); + x = f2 (x, d262); + x = f2 (x, d263); + x = f2 (x, d264); + x = f2 (x, d265); + x = f2 (x, d266); + x = f2 (x, d267); + x = f2 (x, d268); + x = f2 (x, d269); + x = f2 (x, d270); + x = f2 (x, d271); + x = f2 (x, d272); + x = f2 (x, d273); + x = f2 (x, d274); + x = f2 (x, d275); + x = f2 (x, d276); + x = f2 (x, d277); + x = f2 (x, d278); + x = f2 (x, d279); + x = f2 (x, d280); + x = f2 (x, d281); + x = f2 (x, d282); + x = f2 (x, d283); + x = f2 (x, d284); + x = f2 (x, d285); + x = f2 (x, d286); + x = f2 (x, d287); + x = f2 (x, d288); + x = f2 (x, d289); + x = f2 (x, d290); + x = f2 (x, d291); + x = f2 (x, d292); + x = f2 (x, d293); + x = f2 (x, d294); + x = f2 (x, d295); + x = f2 (x, d296); + x = f2 (x, d297); + x = f2 (x, d298); + x = f2 (x, d299); + x = f2 (x, d300); + x = f2 (x, d301); + x = f2 (x, d302); + x = f2 (x, d303); + x = f2 (x, d304); + x = f2 (x, d305); + x = f2 (x, d306); + x = f2 (x, d307); + x = f2 (x, d308); + x = f2 (x, d309); + x = f2 (x, d310); + x = f2 (x, d311); + x = f2 (x, d312); + x = f2 (x, d313); + x = f2 (x, d314); + x = f2 (x, d315); + x = f2 (x, d316); + x = f2 (x, d317); + x = f2 (x, d318); + x = f2 (x, d319); + x = f2 (x, d320); + x = f2 (x, d321); + x = f2 (x, d322); + x = f2 (x, d323); + x = f2 (x, d324); + x = f2 (x, d325); + x = f2 (x, d326); + x = f2 (x, d327); + x = f2 (x, d328); + x = f2 (x, d329); + x = f2 (x, d330); + x = f2 (x, d331); + x = f2 (x, d332); + x = f2 (x, d333); + x = f2 (x, d334); + x = f2 (x, d335); + x = f2 (x, d336); + x = f2 (x, d337); + x = f2 (x, d338); + x = f2 (x, d339); + x = f2 (x, d340); + x = f2 (x, d341); + x = f2 (x, d342); + x = f2 (x, d343); + x = f2 (x, d344); + x = f2 (x, d345); + x = f2 (x, d346); + x = f2 (x, d347); + x = f2 (x, d348); + x = f2 (x, d349); + x = f2 (x, d350); + x = f2 (x, d351); + x = f2 (x, d352); + x = f2 (x, d353); + x = f2 (x, d354); + x = f2 (x, d355); + x = f2 (x, d356); + x = f2 (x, d357); + x = f2 (x, d358); + x = f2 (x, d359); + x = f2 (x, d360); + x = f2 (x, d361); + x = f2 (x, d362); + x = f2 (x, d363); + x = f2 (x, d364); + x = f2 (x, d365); + x = f2 (x, d366); + x = f2 (x, d367); + x = f2 (x, d368); + x = f2 (x, d369); + x = f2 (x, d370); + x = f2 (x, d371); + x = f2 (x, d372); + x = f2 (x, d373); + x = f2 (x, d374); + x = f2 (x, d375); + x = f2 (x, d376); + x = f2 (x, d377); + x = f2 (x, d378); + x = f2 (x, d379); + x = f2 (x, d380); + x = f2 (x, d381); + x = f2 (x, d382); + x = f2 (x, d383); + x = f2 (x, d384); + x = f2 (x, d385); + x = f2 (x, d386); + x = f2 (x, d387); + x = f2 (x, d388); + x = f2 (x, d389); + x = f2 (x, d390); + x = f2 (x, d391); + x = f2 (x, d392); + x = f2 (x, d393); + x = f2 (x, d394); + x = f2 (x, d395); + x = f2 (x, d396); + x = f2 (x, d397); + x = f2 (x, d398); + x = f2 (x, d399); + x = f2 (x, d400); + x = f2 (x, d401); + x = f2 (x, d402); + x = f2 (x, d403); + x = f2 (x, d404); + x = f2 (x, d405); + x = f2 (x, d406); + x = f2 (x, d407); + x = f2 (x, d408); + x = f2 (x, d409); + x = f2 (x, d410); + x = f2 (x, d411); + x = f2 (x, d412); + x = f2 (x, d413); + x = f2 (x, d414); + x = f2 (x, d415); + x = f2 (x, d416); + x = f2 (x, d417); + x = f2 (x, d418); + x = f2 (x, d419); + x = f2 (x, d420); + x = f2 (x, d421); + x = f2 (x, d422); + x = f2 (x, d423); + x = f2 (x, d424); + x = f2 (x, d425); + x = f2 (x, d426); + x = f2 (x, d427); + x = f2 (x, d428); + x = f2 (x, d429); + x = f2 (x, d430); + x = f2 (x, d431); + x = f2 (x, d432); + x = f2 (x, d433); + x = f2 (x, d434); + x = f2 (x, d435); + x = f2 (x, d436); + x = f2 (x, d437); + x = f2 (x, d438); + x = f2 (x, d439); + x = f2 (x, d440); + x = f2 (x, d441); + x = f2 (x, d442); + x = f2 (x, d443); + x = f2 (x, d444); + x = f2 (x, d445); + x = f2 (x, d446); + x = f2 (x, d447); + x = f2 (x, d448); + x = f2 (x, d449); + x = f2 (x, d450); + x = f2 (x, d451); + x = f2 (x, d452); + x = f2 (x, d453); + x = f2 (x, d454); + x = f2 (x, d455); + x = f2 (x, d456); + x = f2 (x, d457); + x = f2 (x, d458); + x = f2 (x, d459); + x = f2 (x, d460); + x = f2 (x, d461); + x = f2 (x, d462); + x = f2 (x, d463); + x = f2 (x, d464); + x = f2 (x, d465); + x = f2 (x, d466); + x = f2 (x, d467); + x = f2 (x, d468); + x = f2 (x, d469); + x = f2 (x, d470); + x = f2 (x, d471); + x = f2 (x, d472); + x = f2 (x, d473); + x = f2 (x, d474); + x = f2 (x, d475); + x = f2 (x, d476); + x = f2 (x, d477); + x = f2 (x, d478); + x = f2 (x, d479); + x = f2 (x, d480); + x = f2 (x, d481); + x = f2 (x, d482); + x = f2 (x, d483); + x = f2 (x, d484); + x = f2 (x, d485); + x = f2 (x, d486); + x = f2 (x, d487); + x = f2 (x, d488); + x = f2 (x, d489); + x = f2 (x, d490); + x = f2 (x, d491); + x = f2 (x, d492); + x = f2 (x, d493); + x = f2 (x, d494); + x = f2 (x, d495); + x = f2 (x, d496); + x = f2 (x, d497); + x = f2 (x, d498); + x = f2 (x, d499); + x = f2 (x, d500); + x = f2 (x, d501); + x = f2 (x, d502); + x = f2 (x, d503); + x = f2 (x, d504); + x = f2 (x, d505); + x = f2 (x, d506); + x = f2 (x, d507); + x = f2 (x, d508); + x = f2 (x, d509); + x = f2 (x, d510); + x = f2 (x, d511); + x = f2 (x, d512); + x = f2 (x, d513); + x = f2 (x, d514); + x = f2 (x, d515); + x = f2 (x, d516); + x = f2 (x, d517); + x = f2 (x, d518); + x = f2 (x, d519); + x = f2 (x, d520); + x = f2 (x, d521); + x = f2 (x, d522); + x = f2 (x, d523); + x = f2 (x, d524); + x = f2 (x, d525); + x = f2 (x, d526); + x = f2 (x, d527); + x = f2 (x, d528); + x = f2 (x, d529); + x = f2 (x, d530); + x = f2 (x, d531); + x = f2 (x, d532); + x = f2 (x, d533); + x = f2 (x, d534); + x = f2 (x, d535); + x = f2 (x, d536); + x = f2 (x, d537); + x = f2 (x, d538); + x = f2 (x, d539); + x = f2 (x, d540); + x = f2 (x, d541); + x = f2 (x, d542); + x = f2 (x, d543); + x = f2 (x, d544); + x = f2 (x, d545); + x = f2 (x, d546); + x = f2 (x, d547); + x = f2 (x, d548); + x = f2 (x, d549); + x = f2 (x, d550); + x = f2 (x, d551); + x = f2 (x, d552); + x = f2 (x, d553); + x = f2 (x, d554); + x = f2 (x, d555); + x = f2 (x, d556); + x = f2 (x, d557); + x = f2 (x, d558); + x = f2 (x, d559); + x = f2 (x, d560); + x = f2 (x, d561); + x = f2 (x, d562); + x = f2 (x, d563); + x = f2 (x, d564); + x = f2 (x, d565); + x = f2 (x, d566); + x = f2 (x, d567); + x = f2 (x, d568); + x = f2 (x, d569); + x = f2 (x, d570); + x = f2 (x, d571); + x = f2 (x, d572); + x = f2 (x, d573); + x = f2 (x, d574); + x = f2 (x, d575); + x = f2 (x, d576); + x = f2 (x, d577); + x = f2 (x, d578); + x = f2 (x, d579); + x = f2 (x, d580); + x = f2 (x, d581); + x = f2 (x, d582); + x = f2 (x, d583); + x = f2 (x, d584); + x = f2 (x, d585); + x = f2 (x, d586); + x = f2 (x, d587); + x = f2 (x, d588); + x = f2 (x, d589); + x = f2 (x, d590); + x = f2 (x, d591); + x = f2 (x, d592); + x = f2 (x, d593); + x = f2 (x, d594); + x = f2 (x, d595); + x = f2 (x, d596); + x = f2 (x, d597); + x = f2 (x, d598); + x = f2 (x, d599); + x = f2 (x, d600); + x = f2 (x, d601); + x = f2 (x, d602); + x = f2 (x, d603); + x = f2 (x, d604); + x = f2 (x, d605); + x = f2 (x, d606); + x = f2 (x, d607); + x = f2 (x, d608); + x = f2 (x, d609); + x = f2 (x, d610); + x = f2 (x, d611); + x = f2 (x, d612); + x = f2 (x, d613); + x = f2 (x, d614); + x = f2 (x, d615); + x = f2 (x, d616); + x = f2 (x, d617); + x = f2 (x, d618); + x = f2 (x, d619); + x = f2 (x, d620); + x = f2 (x, d621); + x = f2 (x, d622); + x = f2 (x, d623); + x = f2 (x, d624); + x = f2 (x, d625); + x = f2 (x, d626); + x = f2 (x, d627); + x = f2 (x, d628); + x = f2 (x, d629); + x = f2 (x, d630); + x = f2 (x, d631); + x = f2 (x, d632); + x = f2 (x, d633); + x = f2 (x, d634); + x = f2 (x, d635); + x = f2 (x, d636); + x = f2 (x, d637); + x = f2 (x, d638); + x = f2 (x, d639); + x = f2 (x, d640); + x = f2 (x, d641); + x = f2 (x, d642); + x = f2 (x, d643); + x = f2 (x, d644); + x = f2 (x, d645); + x = f2 (x, d646); + x = f2 (x, d647); + x = f2 (x, d648); + x = f2 (x, d649); + x = f2 (x, d650); + x = f2 (x, d651); + x = f2 (x, d652); + x = f2 (x, d653); + x = f2 (x, d654); + x = f2 (x, d655); + x = f2 (x, d656); + x = f2 (x, d657); + x = f2 (x, d658); + x = f2 (x, d659); + x = f2 (x, d660); + x = f2 (x, d661); + x = f2 (x, d662); + x = f2 (x, d663); + x = f2 (x, d664); + x = f2 (x, d665); + x = f2 (x, d666); + x = f2 (x, d667); + x = f2 (x, d668); + x = f2 (x, d669); + x = f2 (x, d670); + x = f2 (x, d671); + x = f2 (x, d672); + x = f2 (x, d673); + x = f2 (x, d674); + x = f2 (x, d675); + x = f2 (x, d676); + x = f2 (x, d677); + x = f2 (x, d678); + x = f2 (x, d679); + x = f2 (x, d680); + x = f2 (x, d681); + x = f2 (x, d682); + x = f2 (x, d683); + x = f2 (x, d684); + x = f2 (x, d685); + x = f2 (x, d686); + x = f2 (x, d687); + x = f2 (x, d688); + x = f2 (x, d689); + x = f2 (x, d690); + x = f2 (x, d691); + x = f2 (x, d692); + x = f2 (x, d693); + x = f2 (x, d694); + x = f2 (x, d695); + x = f2 (x, d696); + x = f2 (x, d697); + x = f2 (x, d698); + x = f2 (x, d699); + x = f2 (x, d700); + x = f2 (x, d701); + x = f2 (x, d702); + x = f2 (x, d703); + x = f2 (x, d704); + x = f2 (x, d705); + x = f2 (x, d706); + x = f2 (x, d707); + x = f2 (x, d708); + x = f2 (x, d709); + x = f2 (x, d710); + x = f2 (x, d711); + x = f2 (x, d712); + x = f2 (x, d713); + x = f2 (x, d714); + x = f2 (x, d715); + x = f2 (x, d716); + x = f2 (x, d717); + x = f2 (x, d718); + x = f2 (x, d719); + x = f2 (x, d720); + x = f2 (x, d721); + x = f2 (x, d722); + x = f2 (x, d723); + x = f2 (x, d724); + x = f2 (x, d725); + x = f2 (x, d726); + x = f2 (x, d727); + x = f2 (x, d728); + x = f2 (x, d729); + x = f2 (x, d730); + x = f2 (x, d731); + x = f2 (x, d732); + x = f2 (x, d733); + x = f2 (x, d734); + x = f2 (x, d735); + x = f2 (x, d736); + x = f2 (x, d737); + x = f2 (x, d738); + x = f2 (x, d739); + x = f2 (x, d740); + x = f2 (x, d741); + x = f2 (x, d742); + x = f2 (x, d743); + x = f2 (x, d744); + x = f2 (x, d745); + x = f2 (x, d746); + x = f2 (x, d747); + x = f2 (x, d748); + x = f2 (x, d749); + x = f2 (x, d750); + x = f2 (x, d751); + x = f2 (x, d752); + x = f2 (x, d753); + x = f2 (x, d754); + x = f2 (x, d755); + x = f2 (x, d756); + x = f2 (x, d757); + x = f2 (x, d758); + x = f2 (x, d759); + x = f2 (x, d760); + x = f2 (x, d761); + x = f2 (x, d762); + x = f2 (x, d763); + x = f2 (x, d764); + x = f2 (x, d765); + x = f2 (x, d766); + x = f2 (x, d767); + x = f2 (x, d768); + x = f2 (x, d769); + x = f2 (x, d770); + x = f2 (x, d771); + x = f2 (x, d772); + x = f2 (x, d773); + x = f2 (x, d774); + x = f2 (x, d775); + x = f2 (x, d776); + x = f2 (x, d777); + x = f2 (x, d778); + x = f2 (x, d779); + x = f2 (x, d780); + x = f2 (x, d781); + x = f2 (x, d782); + x = f2 (x, d783); + x = f2 (x, d784); + x = f2 (x, d785); + x = f2 (x, d786); + x = f2 (x, d787); + x = f2 (x, d788); + x = f2 (x, d789); + x = f2 (x, d790); + x = f2 (x, d791); + x = f2 (x, d792); + x = f2 (x, d793); + x = f2 (x, d794); + x = f2 (x, d795); + x = f2 (x, d796); + x = f2 (x, d797); + x = f2 (x, d798); + x = f2 (x, d799); + x = f2 (x, d800); + x = f2 (x, d801); + x = f2 (x, d802); + x = f2 (x, d803); + x = f2 (x, d804); + x = f2 (x, d805); + x = f2 (x, d806); + x = f2 (x, d807); + x = f2 (x, d808); + x = f2 (x, d809); + x = f2 (x, d810); + x = f2 (x, d811); + x = f2 (x, d812); + x = f2 (x, d813); + x = f2 (x, d814); + x = f2 (x, d815); + x = f2 (x, d816); + x = f2 (x, d817); + x = f2 (x, d818); + x = f2 (x, d819); + x = f2 (x, d820); + x = f2 (x, d821); + x = f2 (x, d822); + x = f2 (x, d823); + x = f2 (x, d824); + x = f2 (x, d825); + x = f2 (x, d826); + x = f2 (x, d827); + x = f2 (x, d828); + x = f2 (x, d829); + x = f2 (x, d830); + x = f2 (x, d831); + x = f2 (x, d832); + x = f2 (x, d833); + x = f2 (x, d834); + x = f2 (x, d835); + x = f2 (x, d836); + x = f2 (x, d837); + x = f2 (x, d838); + x = f2 (x, d839); + x = f2 (x, d840); + x = f2 (x, d841); + x = f2 (x, d842); + x = f2 (x, d843); + x = f2 (x, d844); + x = f2 (x, d845); + x = f2 (x, d846); + x = f2 (x, d847); + x = f2 (x, d848); + x = f2 (x, d849); + x = f2 (x, d850); + x = f2 (x, d851); + x = f2 (x, d852); + x = f2 (x, d853); + x = f2 (x, d854); + x = f2 (x, d855); + x = f2 (x, d856); + x = f2 (x, d857); + x = f2 (x, d858); + x = f2 (x, d859); + x = f2 (x, d860); + x = f2 (x, d861); + x = f2 (x, d862); + x = f2 (x, d863); + x = f2 (x, d864); + x = f2 (x, d865); + x = f2 (x, d866); + x = f2 (x, d867); + x = f2 (x, d868); + x = f2 (x, d869); + x = f2 (x, d870); + x = f2 (x, d871); + x = f2 (x, d872); + x = f2 (x, d873); + x = f2 (x, d874); + x = f2 (x, d875); + x = f2 (x, d876); + x = f2 (x, d877); + x = f2 (x, d878); + x = f2 (x, d879); + x = f2 (x, d880); + x = f2 (x, d881); + x = f2 (x, d882); + x = f2 (x, d883); + x = f2 (x, d884); + x = f2 (x, d885); + x = f2 (x, d886); + x = f2 (x, d887); + x = f2 (x, d888); + x = f2 (x, d889); + x = f2 (x, d890); + x = f2 (x, d891); + x = f2 (x, d892); + x = f2 (x, d893); + x = f2 (x, d894); + x = f2 (x, d895); + x = f2 (x, d896); + x = f2 (x, d897); + x = f2 (x, d898); + x = f2 (x, d899); + x = f2 (x, d900); + x = f2 (x, d901); + x = f2 (x, d902); + x = f2 (x, d903); + x = f2 (x, d904); + x = f2 (x, d905); + x = f2 (x, d906); + x = f2 (x, d907); + x = f2 (x, d908); + x = f2 (x, d909); + x = f2 (x, d910); + x = f2 (x, d911); + x = f2 (x, d912); + x = f2 (x, d913); + x = f2 (x, d914); + x = f2 (x, d915); + x = f2 (x, d916); + x = f2 (x, d917); + x = f2 (x, d918); + x = f2 (x, d919); + x = f2 (x, d920); + x = f2 (x, d921); + x = f2 (x, d922); + x = f2 (x, d923); + x = f2 (x, d924); + x = f2 (x, d925); + x = f2 (x, d926); + x = f2 (x, d927); + x = f2 (x, d928); + x = f2 (x, d929); + x = f2 (x, d930); + x = f2 (x, d931); + x = f2 (x, d932); + x = f2 (x, d933); + x = f2 (x, d934); + x = f2 (x, d935); + x = f2 (x, d936); + x = f2 (x, d937); + x = f2 (x, d938); + x = f2 (x, d939); + x = f2 (x, d940); + x = f2 (x, d941); + x = f2 (x, d942); + x = f2 (x, d943); + x = f2 (x, d944); + x = f2 (x, d945); + x = f2 (x, d946); + x = f2 (x, d947); + x = f2 (x, d948); + x = f2 (x, d949); + x = f2 (x, d950); + x = f2 (x, d951); + x = f2 (x, d952); + x = f2 (x, d953); + x = f2 (x, d954); + x = f2 (x, d955); + x = f2 (x, d956); + x = f2 (x, d957); + x = f2 (x, d958); + x = f2 (x, d959); + x = f2 (x, d960); + x = f2 (x, d961); + x = f2 (x, d962); + x = f2 (x, d963); + x = f2 (x, d964); + x = f2 (x, d965); + x = f2 (x, d966); + x = f2 (x, d967); + x = f2 (x, d968); + x = f2 (x, d969); + x = f2 (x, d970); + x = f2 (x, d971); + x = f2 (x, d972); + x = f2 (x, d973); + x = f2 (x, d974); + x = f2 (x, d975); + x = f2 (x, d976); + x = f2 (x, d977); + x = f2 (x, d978); + x = f2 (x, d979); + x = f2 (x, d980); + x = f2 (x, d981); + x = f2 (x, d982); + x = f2 (x, d983); + x = f2 (x, d984); + x = f2 (x, d985); + x = f2 (x, d986); + x = f2 (x, d987); + x = f2 (x, d988); + x = f2 (x, d989); + x = f2 (x, d990); + x = f2 (x, d991); + x = f2 (x, d992); + x = f2 (x, d993); + x = f2 (x, d994); + x = f2 (x, d995); + x = f2 (x, d996); + x = f2 (x, d997); + x = f2 (x, d998); + x = f2 (x, d999); + return x; +} + +/* { dg-final { scan-rtl-dump-times "Stack clash inline probes" 1 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 1 "pro_and_epilogue" } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 1 "pro_and_epilogue" } } */ + +/* f3 is not a leaf +/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 1 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */ +/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 1 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-layout-1.c b/SingleSource/Regression/C/gcc-dg/stack-layout-1.c new file mode 100644 index 0000000000..b80d96d7d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-layout-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing -fdump-rtl-expand" } */ +union U { + int a; + float b; +}; +struct A { + union U u1; + char a[100]; +}; +void bar (struct A *); +void foo () + { + { + struct A a; + bar (&a); + } + { + struct A a; + bar (&a); + } + } + +/* { dg-final { scan-rtl-dump-times "Partition" 1 "expand" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-layout-2.c b/SingleSource/Regression/C/gcc-dg/stack-layout-2.c new file mode 100644 index 0000000000..5d5b385f67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-layout-2.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-expand" } */ +void bar( char *); +int foo() +{ + int i=0; + { + char a[8000]; + bar(a); + i += a[0]; + } + { + char a[8192]; + char b[32]; + bar(a); + i += a[0]; + bar(b); + i += a[0]; + } + return i; +} +/* { dg-final { scan-rtl-dump "size 8192" "expand" } } */ +/* { dg-final { scan-rtl-dump "size 32" "expand" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-layout-dynamic-1.c b/SingleSource/Regression/C/gcc-dg/stack-layout-dynamic-1.c new file mode 100644 index 0000000000..7e59f28031 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-layout-dynamic-1.c @@ -0,0 +1,15 @@ +/* Verify that run time aligned local variables are allocated in the prologue + in one pass together with normal local variables. */ +/* { dg-do compile } */ +/* { dg-options "-O0 -fomit-frame-pointer" } */ +/* { dg-require-effective-target ptr32plus } */ + +extern void bar (void *, void *, void *, void *, void *, void *, void *); +void foo (void) +{ + int i, j, k, l, m; + __attribute__ ((aligned(65536))) char runtime_aligned_1[512]; + __attribute__ ((aligned(32768))) char runtime_aligned_2[1024]; + bar (&i, &j, &k, &l, &m, &runtime_aligned_1, &runtime_aligned_2); +} +/* { dg-final { scan-assembler-not "cfi_def_cfa_register" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-usage-1.c b/SingleSource/Regression/C/gcc-dg/stack-usage-1.c new file mode 100644 index 0000000000..21cce0f440 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-usage-1.c @@ -0,0 +1,122 @@ +/* { dg-do compile } */ +/* { dg-options "-fstack-usage -fno-stack-protector" } */ +/* nvptx doesn't have a reg allocator, and hence no stack usage data. */ +/* { dg-skip-if "" { nvptx-*-* } } */ + +/* This is aimed at testing basic support for -fstack-usage in the back-ends. + See the SPARC back-end for example (grep flag_stack_usage_info in sparc.c). + Once it is implemented, adjust SIZE below so that the stack usage for the + function FOO is reported as 256 or 264 in the stack usage (.su) file. + Then check that this is the actual stack usage in the assembly file. */ + +#if defined(__aarch64__) +# define SIZE 256 /* No frame pointer for leaf functions (default) */ +#elif defined(__arc__) +# define SIZE (256-4) +#elif defined(__i386__) +# define SIZE 248 +#elif defined(__x86_64__) +# ifndef _WIN64 +# define SIZE 356 +# else +# define SIZE (256 - 24) +# endif +#elif defined (__sparc__) +# if defined (__arch64__) +# define SIZE 76 +# else +# define SIZE 160 +# endif +#elif defined(__hppa__) +# define SIZE 192 +#elif defined (__alpha__) +# define SIZE 240 +#elif defined (__ia64__) +# define SIZE 272 +#elif defined(__mips__) +# if defined (__mips_abicalls) \ + || (defined _MIPS_SIM && (_MIPS_SIM ==_ABIN32 || _MIPS_SIM==_ABI64)) +# define SIZE 240 +# else +# define SIZE 248 +# endif +#elif defined (__nds32__) +# define SIZE 248 /* 256 - 8 bytes, only $fp and padding bytes are saved in + the register save area under O0 optimization level. */ +#elif defined (__powerpc64__) || defined (__ppc64__) || defined (__POWERPC64__) \ + || defined (__PPC64__) +# if _CALL_ELF == 2 +# define SIZE 208 +# else +# define SIZE 180 +# endif +#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \ + || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2) +# if defined (__ALTIVEC__) +# if defined (__APPLE__) +# define SIZE 204 +# else +# define SIZE 220 +# endif +# elif defined (_AIX) +# define SIZE 208 +# else +# define SIZE 240 +# endif +#elif defined (__riscv) +# if defined (__riscv_32e) +# define SIZE 252 +# else +# define SIZE 240 +# endif +#elif defined (__AVR__) +#if defined (__AVR_3_BYTE_PC__ ) +# define SIZE 251 /* 256 - 2 bytes for Y - 3 bytes for return address */ +#else +# define SIZE 252 /* 256 - 2 bytes for Y - 2 bytes for return address */ +#endif +#elif defined (__s390x__) +# define SIZE 96 /* 256 - 160 bytes for register save area */ +#elif defined (__s390__) +# define SIZE 160 /* 256 - 96 bytes for register save area */ +#elif defined (__epiphany__) +# define SIZE (256 - __EPIPHANY_STACK_OFFSET__) +#elif defined (__RL78__) +# define SIZE 254 +#elif defined (__sh__) +# define SIZE 252 +#elif defined (__frv__) +# define SIZE 248 +#elif defined (xstormy16) +# define SIZE 254 +#elif defined (__nios2__) +# define SIZE 252 +#elif defined (__PRU__) +# define SIZE 252 +#elif defined (__v850__) +#define SIZE 260 +#elif defined (__mn10300__) +#define SIZE 252 +#elif defined (__H8300SX__) || defined (__H8300S__) || defined (__H8300H__) || defined (__H8300__) +#define SIZE 252 +#elif defined (__M32R__) +#define SIZE 252 +#elif defined (__csky__) +# define SIZE 252 +#elif defined (__CRIS__) +# define SIZE 252 +#elif defined (__loongarch_lp64) +# define SIZE 240 /* 256 - 8 bytes for $fp, and 8 bytes for a temp value */ +#else +# define SIZE 256 +#endif + +int foo (void) +{ + char arr[SIZE]; + arr[0] = 1; + return 0; +} + +/* { dg-final { scan-stack-usage "foo\t\(256|264\)\tstatic" } } */ +/* { dg-final { cleanup-stack-usage } } */ diff --git a/SingleSource/Regression/C/gcc-dg/stack-usage-2.c b/SingleSource/Regression/C/gcc-dg/stack-usage-2.c new file mode 100644 index 0000000000..1a9e7f3598 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stack-usage-2.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-Wstack-usage=512" } */ +/* { dg-require-effective-target untyped_assembly } */ + +int foo1 (void) /* { dg-bogus "stack usage" } */ +{ + char arr[16]; + arr[0] = 1; + return 0; +} + +int foo2 (void) /* { dg-warning "stack usage is \[0-9\]* bytes" } */ +{ + char arr[1024]; + arr[0] = 1; + return 0; +} + +/* The actual warning depends on whether stack space is allocated dynamically + or statically. */ +int foo3 (void) /* { dg-warning "stack usage (might be)|(is) \[0-9\]* bytes" } */ +{ + char arr[1024] __attribute__((aligned (512))); + arr[0] = 1; + /* Force dynamic realignment of argument pointer. */ + __builtin_apply ((void (*)()) foo2, 0, 0); + return 0; +} + +int foo4 (int n) /* { dg-warning "stack usage might be unbounded" } */ +{ + char arr[n]; + arr[0] = 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/stackprotectexplicit1.c b/SingleSource/Regression/C/gcc-dg/stackprotectexplicit1.c new file mode 100644 index 0000000000..658c297d9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stackprotectexplicit1.c @@ -0,0 +1,23 @@ +/* { dg-do run { target native } } */ +/* { dg-options "-fstack-protector-explicit" } */ +/* { dg-require-effective-target fstack_protector } */ + +#include + +void +__stack_chk_fail (void) +{ + exit (0); /* pass */ +} + +int __attribute__((stack_protect)) main () +{ + int i; + char foo[255]; + + // smash stack + for (i = 0; i <= 400; i++) + foo[i] = 42; + + return 1; /* fail */ +} diff --git a/SingleSource/Regression/C/gcc-dg/stdckdint-1.c b/SingleSource/Regression/C/gcc-dg/stdckdint-1.c new file mode 100644 index 0000000000..1525a35c51 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stdckdint-1.c @@ -0,0 +1,61 @@ +/* Test C23 Checked Integer Arithmetic macros in . */ +/* { dg-do run } */ +/* { dg-options "-std=c2x" } */ + +#include + +#if __STDC_VERSION_STDCKDINT_H__ != 202311L +# error __STDC_VERSION_STDCKDINT_H__ not defined to 202311L +#endif + +extern void abort (void); + +int +main () +{ + unsigned int a; + if (ckd_add (&a, 1, 2) || a != 3) + abort (); + if (ckd_add (&a, ~2U, 2) || a != ~0U) + abort (); + if (!ckd_add (&a, ~2U, 4) || a != 1) + abort (); + if (ckd_sub (&a, 42, 2) || a != 40) + abort (); + if (!ckd_sub (&a, 11, ~0ULL) || a != 12) + abort (); + if (ckd_mul (&a, 42, 16U) || a != 672) + abort (); + if (ckd_mul (&a, ~0UL, 0) || a != 0) + abort (); + if (ckd_mul (&a, 1, ~0U) || a != ~0U) + abort (); + if (ckd_mul (&a, ~0UL, 1) != (~0UL > ~0U) || a != ~0U) + abort (); + static_assert (_Generic (ckd_add (&a, 1, 1), bool: 1, default: 0)); + static_assert (_Generic (ckd_sub (&a, 1, 1), bool: 1, default: 0)); + static_assert (_Generic (ckd_mul (&a, 1, 1), bool: 1, default: 0)); + signed char b; + if (ckd_add (&b, 8, 12) || b != 20) + abort (); + if (ckd_sub (&b, 8UL, 12ULL) || b != -4) + abort (); + if (ckd_mul (&b, 2, 3) || b != 6) + abort (); + unsigned char c; + if (ckd_add (&c, 8, 12) || c != 20) + abort (); + if (ckd_sub (&c, 8UL, 12ULL) != (-4ULL > (unsigned char) -4U) + || c != (unsigned char) -4U) + abort (); + if (ckd_mul (&c, 2, 3) || c != 6) + abort (); + long long d; + if (ckd_add (&d, ~0U, ~0U) != (~0U + 1ULL < ~0U) + || d != (long long) (2 * (unsigned long long) ~0U)) + abort (); + if (ckd_sub (&d, 0, 0) || d != 0) + abort (); + if (ckd_mul (&d, 16, 1) || d != 16) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/stdckdint-2.c b/SingleSource/Regression/C/gcc-dg/stdckdint-2.c new file mode 100644 index 0000000000..f83e3d7123 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stdckdint-2.c @@ -0,0 +1,95 @@ +/* Test C23 Checked Integer Arithmetic macros in . */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +#include + +int +main () +{ + char a; + bool b; + enum E { E1, E2 } c = E1; + int d; + int *e; + float f; + double g; + long double h; + const int v = 42; + volatile const short w = 5; + ckd_add (&a, 1, 1); + ckd_sub (&a, 1, 1); + ckd_mul (&a, 1, 1); + ckd_add (&b, 1, 1); /* { dg-error "has pointer to boolean type" } */ + ckd_sub (&b, 1, 1); /* { dg-error "has pointer to boolean type" } */ + ckd_mul (&b, 1, 1); /* { dg-error "has pointer to boolean type" } */ + ckd_add (&c, 1, 1); /* { dg-error "has pointer to enumerated type" } */ + ckd_sub (&c, 1, 1); /* { dg-error "has pointer to enumerated type" } */ + ckd_mul (&c, 1, 1); /* { dg-error "has pointer to enumerated type" } */ + ckd_add (&d, (char) 1, 1); + ckd_sub (&d, (char) 1, 1); + ckd_mul (&d, (char) 1, 1); + ckd_add (&d, false, 1); + ckd_sub (&d, false, 1); + ckd_mul (&d, false, 1); + ckd_add (&d, true, 1); + ckd_sub (&d, true, 1); + ckd_mul (&d, true, 1); + ckd_add (&d, c, 1); + ckd_sub (&d, c, 1); + ckd_mul (&d, c, 1); + ckd_add (&d, 1, (char) 1); + ckd_sub (&d, 1, (char) 1); + ckd_mul (&d, 1, (char) 1); + ckd_add (&d, 1, false); + ckd_sub (&d, 1, false); + ckd_mul (&d, 1, false); + ckd_add (&d, 1, true); + ckd_sub (&d, 1, true); + ckd_mul (&d, 1, true); + ckd_add (&d, 1, c); + ckd_sub (&d, 1, c); + ckd_mul (&d, 1, c); + ckd_add (&e, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_sub (&e, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_mul (&e, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_add (&f, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_sub (&f, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_mul (&f, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_add (&g, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_sub (&g, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_mul (&g, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_add (&h, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_sub (&h, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_mul (&h, 1, 1); /* { dg-error "does not have pointer to integral type" } */ + ckd_add (&d, 1.0f, 1); /* { dg-error "does not have integral type" } */ + ckd_sub (&d, 1.0f, 1); /* { dg-error "does not have integral type" } */ + ckd_mul (&d, 1.0f, 1); /* { dg-error "does not have integral type" } */ + ckd_add (&d, 1.0, 1); /* { dg-error "does not have integral type" } */ + ckd_sub (&d, 1.0, 1); /* { dg-error "does not have integral type" } */ + ckd_mul (&d, 1.0, 1); /* { dg-error "does not have integral type" } */ + ckd_add (&d, 1.0L, 1); /* { dg-error "does not have integral type" } */ + ckd_sub (&d, 1.0L, 1); /* { dg-error "does not have integral type" } */ + ckd_mul (&d, 1.0L, 1); /* { dg-error "does not have integral type" } */ + ckd_add (&d, 1, 1.0f); /* { dg-error "does not have integral type" } */ + ckd_sub (&d, 1, 1.0f); /* { dg-error "does not have integral type" } */ + ckd_mul (&d, 1, 1.0f); /* { dg-error "does not have integral type" } */ + ckd_add (&d, 1, 1.0); /* { dg-error "does not have integral type" } */ + ckd_sub (&d, 1, 1.0); /* { dg-error "does not have integral type" } */ + ckd_mul (&d, 1, 1.0); /* { dg-error "does not have integral type" } */ + ckd_add (&d, 1, 1.0L); /* { dg-error "does not have integral type" } */ + ckd_sub (&d, 1, 1.0L); /* { dg-error "does not have integral type" } */ + ckd_mul (&d, 1, 1.0L); /* { dg-error "does not have integral type" } */ + ckd_add (&d, (int *) 0, 1); /* { dg-error "does not have integral type" } */ + ckd_sub (&d, (int *) 0, 1); /* { dg-error "does not have integral type" } */ + ckd_mul (&d, (int *) 0, 1); /* { dg-error "does not have integral type" } */ + ckd_add (&d, 1, (int *) 0); /* { dg-error "does not have integral type" } */ + ckd_sub (&d, 1, (int *) 0); /* { dg-error "does not have integral type" } */ + ckd_mul (&d, 1, (int *) 0); /* { dg-error "does not have integral type" } */ + ckd_add (&v, 1, 1); /* { dg-error "has pointer to 'const' type" } */ + ckd_sub (&v, 1, 1); /* { dg-error "has pointer to 'const' type" } */ + ckd_mul (&v, 1, 1); /* { dg-error "has pointer to 'const' type" } */ + ckd_add (&w, 1, 1); /* { dg-error "has pointer to 'const' type" } */ + ckd_sub (&w, 1, 1); /* { dg-error "has pointer to 'const' type" } */ + ckd_mul (&w, 1, 1); /* { dg-error "has pointer to 'const' type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/stdint-width-1.c b/SingleSource/Regression/C/gcc-dg/stdint-width-1.c new file mode 100644 index 0000000000..3eba9f6cb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stdint-width-1.c @@ -0,0 +1,176 @@ +/* Test TS 18661-1 width macros in . */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -ffreestanding" } */ +/* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */ + +#include +#define __STDC_WANT_IEC_60559_BFP_EXT__ +#include +#ifndef SIGNAL_SUPPRESS +#include +#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/SingleSource/Regression/C/gcc-dg/stdint-width-2.c b/SingleSource/Regression/C/gcc-dg/stdint-width-2.c new file mode 100644 index 0000000000..9838cb2761 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stdint-width-2.c @@ -0,0 +1,175 @@ +/* Test C2X width macros in . */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -ffreestanding" } */ +/* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */ + +#include +#include +#ifndef SIGNAL_SUPPRESS +#include +#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/SingleSource/Regression/C/gcc-dg/stmt-expr-1.c b/SingleSource/Regression/C/gcc-dg/stmt-expr-1.c new file mode 100644 index 0000000000..fdd62528d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stmt-expr-1.c @@ -0,0 +1,11 @@ +/* Test diagnostic for GNU extension: statement expressions. Test + with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +int +f (void) +{ + return ({ 1; }); +} diff --git a/SingleSource/Regression/C/gcc-dg/stmt-expr-2.c b/SingleSource/Regression/C/gcc-dg/stmt-expr-2.c new file mode 100644 index 0000000000..524e8ac87d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stmt-expr-2.c @@ -0,0 +1,11 @@ +/* Test diagnostic for GNU extension: statement expressions. Test + with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic" } */ + +int +f (void) +{ + return ({ 1; }); /* { dg-warning "ISO C forbids braced-groups within expressions" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/stmt-expr-3.c b/SingleSource/Regression/C/gcc-dg/stmt-expr-3.c new file mode 100644 index 0000000000..6ef7e069ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stmt-expr-3.c @@ -0,0 +1,11 @@ +/* Test diagnostic for GNU extension: statement expressions. Test + with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -pedantic-errors" } */ + +int +f (void) +{ + return ({ 1; }); /* { dg-error "ISO C forbids braced-groups within expressions" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/stmt-expr-4.c b/SingleSource/Regression/C/gcc-dg/stmt-expr-4.c new file mode 100644 index 0000000000..d6d01633d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stmt-expr-4.c @@ -0,0 +1,22 @@ + +/* { dg-options "-O2 -std=gnu99" } */ +/* Internal compiler error in iterative_hash_expr */ + +struct tree_string +{ + char str[1]; +}; + +union tree_node +{ + struct tree_string string; +}; + +char *Foo (union tree_node * num_string) +{ + char *str = ((union {const char * _q; char * _nq;}) + ((const char *)(({ __typeof (num_string) const __t + = num_string; __t; }) + ->string.str)))._nq; + return str; +} diff --git a/SingleSource/Regression/C/gcc-dg/stmt-expr-label-1.c b/SingleSource/Regression/C/gcc-dg/stmt-expr-label-1.c new file mode 100644 index 0000000000..a9dd46623f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stmt-expr-label-1.c @@ -0,0 +1,407 @@ +/* Test for labels in statement expressions: bugs 772 and 17913. + goto statements must not jump into statement expressions. + + This tests all combinations of label and goto locations in a given + function. Each combination is tested twice, once with just that + label and goto and once with many others in order to exercise the + different code paths involved with excess labels. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void f0 (void) { goto a; a:({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa0 (void) { p0A:goto p0A; goto a; a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f1 (void) { goto a; ({ a:({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa1 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f2 (void) { goto a; ({ ({a:0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa2 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f3 (void) { goto a; ({ ({0;}); a:({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa3 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f4 (void) { goto a; ({ ({0;}); ({a:0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa4 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f5 (void) { goto a; ({ ({0;}); ({0;}); a:0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa5 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f6 (void) { goto a; ({ ({0;}); ({0;}); 0;}); a:({ ({0;}); ({0;}); 0;}); 0; } +void fa6 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f7 (void) { goto a; ({ ({0;}); ({0;}); 0;}); ({ a:({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa7 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f8 (void) { goto a; ({ ({0;}); ({0;}); 0;}); ({ ({a:0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa8 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f9 (void) { goto a; ({ ({0;}); ({0;}); 0;}); ({ ({0;}); a:({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa9 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f10 (void) { goto a; ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa10 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f11 (void) { goto a; ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); a:0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa11 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f12 (void) { goto a; ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); a:0; } +void fa12 (void) { p0A:goto p0A; goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f13 (void) { a: goto a; ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa13 (void) { a: goto a; P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f14 (void) { a:({ goto a; ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa14 (void) { a:({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f15 (void) { ({ goto a; a:({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa15 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f16 (void) { ({ goto a; ({a:0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa16 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f17 (void) { ({ goto a; ({0;}); a:({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa17 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f18 (void) { ({ goto a; ({0;}); ({a:0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa18 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f19 (void) { ({ goto a; ({0;}); ({0;}); a:0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa19 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f20 (void) { ({ goto a; ({0;}); ({0;}); 0;}); a:({ ({0;}); ({0;}); 0;}); 0; } +void fa20 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f21 (void) { ({ goto a; ({0;}); ({0;}); 0;}); ({ a:({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa21 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f22 (void) { ({ goto a; ({0;}); ({0;}); 0;}); ({ ({a:0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa22 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f23 (void) { ({ goto a; ({0;}); ({0;}); 0;}); ({ ({0;}); a:({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa23 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f24 (void) { ({ goto a; ({0;}); ({0;}); 0;}); ({ ({0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa24 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f25 (void) { ({ goto a; ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); a:0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa25 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f26 (void) { ({ goto a; ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); a:0; } +void fa26 (void) { P0A:goto P0A;({ p01A:goto p01A; goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f27 (void) { ({ a: goto a; ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa27 (void) { P0A:goto P0A;({ a: goto a; P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f28 (void) { a:({ ({ goto a; 0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa28 (void) { a:({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f29 (void) { ({ a:({ goto a; 0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa29 (void) { P0A:goto P0A;({ a:({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f30 (void) { ({ ({ goto a; a:0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa30 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f31 (void) { ({ ({ goto a; 0;}); a:({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa31 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f32 (void) { ({ ({ goto a; 0;}); ({a:0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa32 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f33 (void) { ({ ({ goto a; 0;}); ({0;}); a:0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa33 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f34 (void) { ({ ({ goto a; 0;}); ({0;}); 0;}); a:({ ({0;}); ({0;}); 0;}); 0; } +void fa34 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f35 (void) { ({ ({ goto a; 0;}); ({0;}); 0;}); ({ a:({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa35 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f36 (void) { ({ ({ goto a; 0;}); ({0;}); 0;}); ({ ({a:0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa36 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f37 (void) { ({ ({ goto a; 0;}); ({0;}); 0;}); ({ ({0;}); a:({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa37 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f38 (void) { ({ ({ goto a; 0;}); ({0;}); 0;}); ({ ({0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa38 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f39 (void) { ({ ({ goto a; 0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); a:0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa39 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f40 (void) { ({ ({ goto a; 0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); a:0; } +void fa40 (void) { P0A:goto P0A;({ P01A:goto P01A;({p012A:goto p012A; goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f41 (void) { ({ ({a: goto a; 0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa41 (void) { P0A:goto P0A;({ P01A:goto P01A;({a: goto a; P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f42 (void) { a:({ ({0;}); goto a; ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa42 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f43 (void) { ({ a:({0;}); goto a; ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa43 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f44 (void) { ({ ({a:0;}); goto a; ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa44 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f45 (void) { ({ ({0;}); goto a; a:({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa45 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f46 (void) { ({ ({0;}); goto a; ({a:0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa46 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f47 (void) { ({ ({0;}); goto a; ({0;}); a:0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa47 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f48 (void) { ({ ({0;}); goto a; ({0;}); 0;}); a:({ ({0;}); ({0;}); 0;}); 0; } +void fa48 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f49 (void) { ({ ({0;}); goto a; ({0;}); 0;}); ({ a:({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa49 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f50 (void) { ({ ({0;}); goto a; ({0;}); 0;}); ({ ({a:0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa50 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f51 (void) { ({ ({0;}); goto a; ({0;}); 0;}); ({ ({0;}); a:({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa51 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f52 (void) { ({ ({0;}); goto a; ({0;}); 0;}); ({ ({0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa52 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f53 (void) { ({ ({0;}); goto a; ({0;}); 0;}); ({ ({0;}); ({0;}); a:0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa53 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f54 (void) { ({ ({0;}); goto a; ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); a:0; } +void fa54 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); p01B:goto p01B; goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f55 (void) { ({ ({0;}); a: goto a; ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa55 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a: goto a; P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f56 (void) { a:({ ({0;}); ({ goto a; 0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa56 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f57 (void) { ({ a:({0;}); ({ goto a; 0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa57 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f58 (void) { ({ ({a:0;}); ({ goto a; 0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa58 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f59 (void) { ({ ({0;}); a:({ goto a; 0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa59 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f60 (void) { ({ ({0;}); ({ goto a; a:0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa60 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f61 (void) { ({ ({0;}); ({ goto a; 0;}); a:0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa61 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f62 (void) { ({ ({0;}); ({ goto a; 0;}); 0;}); a:({ ({0;}); ({0;}); 0;}); 0; } +void fa62 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f63 (void) { ({ ({0;}); ({ goto a; 0;}); 0;}); ({ a:({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa63 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f64 (void) { ({ ({0;}); ({ goto a; 0;}); 0;}); ({ ({a:0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa64 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f65 (void) { ({ ({0;}); ({ goto a; 0;}); 0;}); ({ ({0;}); a:({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa65 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f66 (void) { ({ ({0;}); ({ goto a; 0;}); 0;}); ({ ({0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa66 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f67 (void) { ({ ({0;}); ({ goto a; 0;}); 0;}); ({ ({0;}); ({0;}); a:0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa67 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f68 (void) { ({ ({0;}); ({ goto a; 0;}); 0;}); ({ ({0;}); ({0;}); 0;}); a:0; } +void fa68 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({p013A:goto p013A; goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f69 (void) { ({ ({0;}); ({a: goto a; 0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa69 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a: goto a; P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f70 (void) { a:({ ({0;}); ({0;}); goto a; 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa70 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f71 (void) { ({ a:({0;}); ({0;}); goto a; 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa71 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f72 (void) { ({ ({a:0;}); ({0;}); goto a; 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa72 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f73 (void) { ({ ({0;}); a:({0;}); goto a; 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa73 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f74 (void) { ({ ({0;}); ({a:0;}); goto a; 0;}); ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa74 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f75 (void) { ({ ({0;}); ({0;}); goto a; a:0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa75 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f76 (void) { ({ ({0;}); ({0;}); goto a; 0;}); a:({ ({0;}); ({0;}); 0;}); 0; } +void fa76 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f77 (void) { ({ ({0;}); ({0;}); goto a; 0;}); ({ a:({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa77 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f78 (void) { ({ ({0;}); ({0;}); goto a; 0;}); ({ ({a:0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa78 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f79 (void) { ({ ({0;}); ({0;}); goto a; 0;}); ({ ({0;}); a:({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa79 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f80 (void) { ({ ({0;}); ({0;}); goto a; 0;}); ({ ({0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa80 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f81 (void) { ({ ({0;}); ({0;}); goto a; 0;}); ({ ({0;}); ({0;}); a:0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa81 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f82 (void) { ({ ({0;}); ({0;}); goto a; 0;}); ({ ({0;}); ({0;}); 0;}); a:0; } +void fa82 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); p01C:goto p01C; goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f83 (void) { ({ ({0;}); ({0;}); a: goto a; 0;}); ({ ({0;}); ({0;}); 0;}); 0; } +void fa83 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a: goto a; P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f84 (void) { a:({ ({0;}); ({0;}); 0;}); goto a; ({ ({0;}); ({0;}); 0;}); 0; } +void fa84 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f85 (void) { ({ a:({0;}); ({0;}); 0;}); goto a; ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa85 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f86 (void) { ({ ({a:0;}); ({0;}); 0;}); goto a; ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa86 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f87 (void) { ({ ({0;}); a:({0;}); 0;}); goto a; ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa87 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f88 (void) { ({ ({0;}); ({a:0;}); 0;}); goto a; ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa88 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f89 (void) { ({ ({0;}); ({0;}); a:0;}); goto a; ({ ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa89 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f90 (void) { ({ ({0;}); ({0;}); 0;}); goto a; a:({ ({0;}); ({0;}); 0;}); 0; } +void fa90 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f91 (void) { ({ ({0;}); ({0;}); 0;}); goto a; ({ a:({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa91 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f92 (void) { ({ ({0;}); ({0;}); 0;}); goto a; ({ ({a:0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa92 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f93 (void) { ({ ({0;}); ({0;}); 0;}); goto a; ({ ({0;}); a:({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa93 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f94 (void) { ({ ({0;}); ({0;}); 0;}); goto a; ({ ({0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa94 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f95 (void) { ({ ({0;}); ({0;}); 0;}); goto a; ({ ({0;}); ({0;}); a:0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa95 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f96 (void) { ({ ({0;}); ({0;}); 0;}); goto a; ({ ({0;}); ({0;}); 0;}); a:0; } +void fa96 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); p0B:goto p0B; goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f97 (void) { ({ ({0;}); ({0;}); 0;}); a: goto a; ({ ({0;}); ({0;}); 0;}); 0; } +void fa97 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a: goto a; P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f98 (void) { a:({ ({0;}); ({0;}); 0;}); ({ goto a; ({0;}); ({0;}); 0;}); 0; } +void fa98 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f99 (void) { ({ a:({0;}); ({0;}); 0;}); ({ goto a; ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa99 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f100 (void) { ({ ({a:0;}); ({0;}); 0;}); ({ goto a; ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa100 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f101 (void) { ({ ({0;}); a:({0;}); 0;}); ({ goto a; ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa101 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f102 (void) { ({ ({0;}); ({a:0;}); 0;}); ({ goto a; ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa102 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f103 (void) { ({ ({0;}); ({0;}); a:0;}); ({ goto a; ({0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa103 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f104 (void) { ({ ({0;}); ({0;}); 0;}); a:({ goto a; ({0;}); ({0;}); 0;}); 0; } +void fa104 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f105 (void) { ({ ({0;}); ({0;}); 0;}); ({ goto a; a:({0;}); ({0;}); 0;}); 0; } +void fa105 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f106 (void) { ({ ({0;}); ({0;}); 0;}); ({ goto a; ({a:0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa106 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f107 (void) { ({ ({0;}); ({0;}); 0;}); ({ goto a; ({0;}); a:({0;}); 0;}); 0; } +void fa107 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f108 (void) { ({ ({0;}); ({0;}); 0;}); ({ goto a; ({0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa108 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f109 (void) { ({ ({0;}); ({0;}); 0;}); ({ goto a; ({0;}); ({0;}); a:0;}); 0; } +void fa109 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f110 (void) { ({ ({0;}); ({0;}); 0;}); ({ goto a; ({0;}); ({0;}); 0;}); a:0; } +void fa110 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ p02A:goto p02A; goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f111 (void) { ({ ({0;}); ({0;}); 0;}); ({ a: goto a; ({0;}); ({0;}); 0;}); 0; } +void fa111 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a: goto a; P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f112 (void) { a:({ ({0;}); ({0;}); 0;}); ({ ({ goto a; 0;}); ({0;}); 0;}); 0; } +void fa112 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f113 (void) { ({ a:({0;}); ({0;}); 0;}); ({ ({ goto a; 0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa113 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f114 (void) { ({ ({a:0;}); ({0;}); 0;}); ({ ({ goto a; 0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa114 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f115 (void) { ({ ({0;}); a:({0;}); 0;}); ({ ({ goto a; 0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa115 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f116 (void) { ({ ({0;}); ({a:0;}); 0;}); ({ ({ goto a; 0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa116 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f117 (void) { ({ ({0;}); ({0;}); a:0;}); ({ ({ goto a; 0;}); ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa117 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f118 (void) { ({ ({0;}); ({0;}); 0;}); a:({ ({ goto a; 0;}); ({0;}); 0;}); 0; } +void fa118 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f119 (void) { ({ ({0;}); ({0;}); 0;}); ({ a:({ goto a; 0;}); ({0;}); 0;}); 0; } +void fa119 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f120 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({ goto a; a:0;}); ({0;}); 0;}); 0; } +void fa120 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f121 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({ goto a; 0;}); a:({0;}); 0;}); 0; } +void fa121 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f122 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({ goto a; 0;}); ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa122 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f123 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({ goto a; 0;}); ({0;}); a:0;}); 0; } +void fa123 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f124 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({ goto a; 0;}); ({0;}); 0;}); a:0; } +void fa124 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({p024A:goto p024A; goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f125 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({a: goto a; 0;}); ({0;}); 0;}); 0; } +void fa125 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a: goto a; P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f126 (void) { a:({ ({0;}); ({0;}); 0;}); ({ ({0;}); goto a; ({0;}); 0;}); 0; } +void fa126 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f127 (void) { ({ a:({0;}); ({0;}); 0;}); ({ ({0;}); goto a; ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa127 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f128 (void) { ({ ({a:0;}); ({0;}); 0;}); ({ ({0;}); goto a; ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa128 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f129 (void) { ({ ({0;}); a:({0;}); 0;}); ({ ({0;}); goto a; ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa129 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f130 (void) { ({ ({0;}); ({a:0;}); 0;}); ({ ({0;}); goto a; ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa130 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f131 (void) { ({ ({0;}); ({0;}); a:0;}); ({ ({0;}); goto a; ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa131 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f132 (void) { ({ ({0;}); ({0;}); 0;}); a:({ ({0;}); goto a; ({0;}); 0;}); 0; } +void fa132 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f133 (void) { ({ ({0;}); ({0;}); 0;}); ({ a:({0;}); goto a; ({0;}); 0;}); 0; } +void fa133 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f134 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({a:0;}); goto a; ({0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa134 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f135 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); goto a; a:({0;}); 0;}); 0; } +void fa135 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f136 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); goto a; ({a:0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa136 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f137 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); goto a; ({0;}); a:0;}); 0; } +void fa137 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f138 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); goto a; ({0;}); 0;}); a:0; } +void fa138 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); p02B:goto p02B; goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f139 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); a: goto a; ({0;}); 0;}); 0; } +void fa139 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a: goto a; P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f140 (void) { a:({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({ goto a; 0;}); 0;}); 0; } +void fa140 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f141 (void) { ({ a:({0;}); ({0;}); 0;}); ({ ({0;}); ({ goto a; 0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa141 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f142 (void) { ({ ({a:0;}); ({0;}); 0;}); ({ ({0;}); ({ goto a; 0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa142 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f143 (void) { ({ ({0;}); a:({0;}); 0;}); ({ ({0;}); ({ goto a; 0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa143 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f144 (void) { ({ ({0;}); ({a:0;}); 0;}); ({ ({0;}); ({ goto a; 0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa144 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f145 (void) { ({ ({0;}); ({0;}); a:0;}); ({ ({0;}); ({ goto a; 0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa145 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f146 (void) { ({ ({0;}); ({0;}); 0;}); a:({ ({0;}); ({ goto a; 0;}); 0;}); 0; } +void fa146 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f147 (void) { ({ ({0;}); ({0;}); 0;}); ({ a:({0;}); ({ goto a; 0;}); 0;}); 0; } +void fa147 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f148 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({a:0;}); ({ goto a; 0;}); 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa148 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f149 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); a:({ goto a; 0;}); 0;}); 0; } +void fa149 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f150 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({ goto a; a:0;}); 0;}); 0; } +void fa150 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f151 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({ goto a; 0;}); a:0;}); 0; } +void fa151 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f152 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({ goto a; 0;}); 0;}); a:0; } +void fa152 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({p025A:goto p025A; goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f153 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({a: goto a; 0;}); 0;}); 0; } +void fa153 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a: goto a; P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f154 (void) { a:({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); goto a; 0;}); 0; } +void fa154 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f155 (void) { ({ a:({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); goto a; 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa155 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f156 (void) { ({ ({a:0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); goto a; 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa156 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f157 (void) { ({ ({0;}); a:({0;}); 0;}); ({ ({0;}); ({0;}); goto a; 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa157 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f158 (void) { ({ ({0;}); ({a:0;}); 0;}); ({ ({0;}); ({0;}); goto a; 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa158 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f159 (void) { ({ ({0;}); ({0;}); a:0;}); ({ ({0;}); ({0;}); goto a; 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa159 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f160 (void) { ({ ({0;}); ({0;}); 0;}); a:({ ({0;}); ({0;}); goto a; 0;}); 0; } +void fa160 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f161 (void) { ({ ({0;}); ({0;}); 0;}); ({ a:({0;}); ({0;}); goto a; 0;}); 0; } +void fa161 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f162 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({a:0;}); ({0;}); goto a; 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa162 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f163 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); a:({0;}); goto a; 0;}); 0; } +void fa163 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f164 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({a:0;}); goto a; 0;}); 0; } /* { dg-error "jump into statement expression" } */ +void fa164 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f165 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); goto a; a:0;}); 0; } +void fa165 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; a:0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f166 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); goto a; 0;}); a:0; } +void fa166 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); p02C:goto p02C; goto a; P02C:goto P02C;0;}); a:0;P0D:goto P0D; } +void f167 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); a: goto a; 0;}); 0; } +void fa167 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a: goto a; P02C:goto P02C;0;}); P0C:goto P0C;0;P0D:goto P0D; } +void f168 (void) { a:({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); goto a; 0; } +void fa168 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } +void f169 (void) { ({ a:({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa169 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f170 (void) { ({ ({a:0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa170 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f171 (void) { ({ ({0;}); a:({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa171 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f172 (void) { ({ ({0;}); ({a:0;}); 0;}); ({ ({0;}); ({0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa172 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f173 (void) { ({ ({0;}); ({0;}); a:0;}); ({ ({0;}); ({0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa173 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f174 (void) { ({ ({0;}); ({0;}); 0;}); a:({ ({0;}); ({0;}); 0;}); goto a; 0; } +void fa174 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } +void f175 (void) { ({ ({0;}); ({0;}); 0;}); ({ a:({0;}); ({0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa175 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f176 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({a:0;}); ({0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa176 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f177 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); a:({0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa177 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f178 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({a:0;}); 0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa178 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f179 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); a:0;}); goto a; 0; } /* { dg-error "jump into statement expression" } */ +void fa179 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); p0C:goto p0C; goto a; P0C:goto P0C;0;P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f180 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); goto a; a:0; } +void fa180 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); p0C:goto p0C; goto a; a:0;P0D:goto P0D; } +void f181 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); a: goto a; 0; } +void fa181 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a: goto a; P0C:goto P0C;0;P0D:goto P0D; } +void f182 (void) { a:({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; goto a; } +void fa182 (void) { a:({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } +void f183 (void) { ({ a:({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa183 (void) { P0A:goto P0A;({ a:({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f184 (void) { ({ ({a:0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa184 (void) { P0A:goto P0A;({ P01A:goto P01A;({a:0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f185 (void) { ({ ({0;}); a:({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa185 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); a:({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f186 (void) { ({ ({0;}); ({a:0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa186 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({a:0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f187 (void) { ({ ({0;}); ({0;}); a:0;}); ({ ({0;}); ({0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa187 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); a:0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f188 (void) { ({ ({0;}); ({0;}); 0;}); a:({ ({0;}); ({0;}); 0;}); 0; goto a; } +void fa188 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); a:({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } +void f189 (void) { ({ ({0;}); ({0;}); 0;}); ({ a:({0;}); ({0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa189 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ a:({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f190 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({a:0;}); ({0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa190 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({a:0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f191 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); a:({0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa191 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); a:({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f192 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({a:0;}); 0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa192 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({a:0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f193 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); a:0;}); 0; goto a; } /* { dg-error "jump into statement expression" } */ +void fa193 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); a:0;}); P0C:goto P0C;0;p0D:goto p0D; goto a; P0D:goto P0D; } /* { dg-error "jump into statement expression" } */ +void f194 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); a:0; goto a; } +void fa194 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;p0D:goto p0D; goto a; P0D:goto P0D; } +void f195 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0;a: goto a; } +void fa195 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;a: goto a; P0D:goto P0D; } + +/* Match extra informative notes. */ +/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/stmt-expr-label-2.c b/SingleSource/Regression/C/gcc-dg/stmt-expr-label-2.c new file mode 100644 index 0000000000..be7aa52100 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stmt-expr-label-2.c @@ -0,0 +1,27 @@ +/* Test for labels in statement expressions: bugs 772 and 17913. + switch statements must not jump into statement expressions. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (int a) +{ + switch (a) /* { dg-message "here" } */ + { + case 0: + case 1: + ({ + case 2: /* { dg-error "switch jumps into statement expression" } */ + default: /* { dg-error "switch jumps into statement expression" } */ + switch (a) + { + case 3: + default: + ; + } + 0; + }); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/stmt-expr-label-3.c b/SingleSource/Regression/C/gcc-dg/stmt-expr-label-3.c new file mode 100644 index 0000000000..0a6722283f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/stmt-expr-label-3.c @@ -0,0 +1,11 @@ +/* Test for labels in statement expressions: bugs 772 and 17913. + Test the particular case of bug 17913. */ + +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void f(void) { 1 ? 1 : ({ a : 1; 1; }); goto a; } /* { dg-error "jump into statement expression" } */ + +/* Match extra informative notes. */ +/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/store-motion-fgcse-sm.c b/SingleSource/Regression/C/gcc-dg/store-motion-fgcse-sm.c new file mode 100644 index 0000000000..0e988b8081 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store-motion-fgcse-sm.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-pre -fno-tree-loop-im -fgcse-sm -fdump-rtl-store_motion" } */ + +/* tree-pre moves the *sum load out of the loop. ftree-loop-im moves the *sum + store out of the loop, so we disable it, to allow fgcse-sm to do it + instead. */ + +#include + +void __attribute__((noinline)) +f (unsigned int *__restrict__ a, unsigned int *__restrict__ sum, unsigned int n) +{ + unsigned int i; + for (i = 0; i < n; ++i) + *sum += a[i]; +} + +int +main () +{ + unsigned int a[] = { 1, 10, 100 }; + unsigned sum = 1000; + + f (a, &sum, 3); + if (sum != 1111) + abort (); + + return 0; +} + +/* Check that -fgcse-sm did something for f. */ +/* { dg-final { scan-rtl-dump "STORE_MOTION of f, .* basic blocks, 1 insns deleted, 1 insns created" "store_motion" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_1.c b/SingleSource/Regression/C/gcc-dg/store_merging_1.c new file mode 100644 index 0000000000..91ca925be0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_1.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +struct bar { + int a; + char b; + char c; + char d; + char e; + char f; + char g; +}; + +void +foo1 (struct bar *p) +{ + p->b = 0; + p->a = 0; + p->c = 0; + p->d = 0; + p->e = 0; +} + +void +foo2 (struct bar *p) +{ + p->b = 0; + p->a = 0; + p->c = 1; + p->d = 0; + p->e = 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_10.c b/SingleSource/Regression/C/gcc-dg/store_merging_10.c new file mode 100644 index 0000000000..53a6a74c56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_10.c @@ -0,0 +1,56 @@ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +struct S { + unsigned int b1:1; + unsigned int b2:1; + unsigned int b3:1; + unsigned int b4:1; + unsigned int b5:1; + unsigned int b6:27; +}; + +struct T { + unsigned int b1:1; + unsigned int b2:16; + unsigned int b3:14; + unsigned int b4:1; +}; + +__attribute__((noipa)) void +foo (struct S *x) +{ + x->b1 = 1; + x->b2 = 0; + x->b3 = 1; + x->b4 = 1; + x->b5 = 0; +} + +__attribute__((noipa)) void +bar (struct T *x) +{ + x->b1 = 1; + x->b2 = 0; + x->b4 = 0; +} + +struct S s = { 0, 1, 0, 0, 1, 0x3a5f05a }; +struct T t = { 0, 0xf5af, 0x3a5a, 1 }; + +int +main () +{ + asm volatile ("" : : : "memory"); + foo (&s); + bar (&t); + asm volatile ("" : : : "memory"); + if (s.b1 != 1 || s.b2 != 0 || s.b3 != 1 || s.b4 != 1 || s.b5 != 0 || s.b6 != 0x3a5f05a) + __builtin_abort (); + if (t.b1 != 1 || t.b2 != 0 || t.b3 != 0x3a5a || t.b4 != 0) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_11.c b/SingleSource/Regression/C/gcc-dg/store_merging_11.c new file mode 100644 index 0000000000..60ed5cd8bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_11.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +struct S { unsigned char b[2]; unsigned short c; unsigned char d[4]; unsigned long e; }; + +__attribute__((noipa)) void +foo (struct S *p) +{ + p->b[1] = 1; + p->c = 23; + p->d[0] = 4; + p->d[1] = 5; + p->d[2] = 6; + p->d[3] = 7; + p->e = 8; +} + +__attribute__((noipa)) void +bar (struct S *p) +{ + p->b[1] = 9; + p->c = 112; + p->d[0] = 10; + p->d[1] = 11; +} + +struct S s = { { 30, 31 }, 32, { 33, 34, 35, 36 }, 37 }; + +int +main () +{ + asm volatile ("" : : : "memory"); + foo (&s); + asm volatile ("" : : : "memory"); + if (s.b[0] != 30 || s.b[1] != 1 || s.c != 23 || s.d[0] != 4 || s.d[1] != 5 + || s.d[2] != 6 || s.d[3] != 7 || s.e != 8) + __builtin_abort (); + bar (&s); + asm volatile ("" : : : "memory"); + if (s.b[0] != 30 || s.b[1] != 9 || s.c != 112 || s.d[0] != 10 || s.d[1] != 11 + || s.d[2] != 6 || s.d[3] != 7 || s.e != 8) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_12.c b/SingleSource/Regression/C/gcc-dg/store_merging_12.c new file mode 100644 index 0000000000..2a74f3d12b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_12.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +#if __SIZEOF_INT__ == 2 +#define int long +#endif + +struct S { unsigned int b1:1, b2:1, b3:1, b4:1, b5:1, b6:27; }; +void bar (struct S *); +void foo (int x) +{ + struct S s; + s.b2 = 1; s.b3 = 0; s.b4 = 1; s.b5 = 0; s.b1 = x; s.b6 = x; /* { dg-bogus "is used uninitialized in this function" } */ + bar (&s); +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_13.c b/SingleSource/Regression/C/gcc-dg/store_merging_13.c new file mode 100644 index 0000000000..6e5206dd63 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_13.c @@ -0,0 +1,296 @@ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +struct S { unsigned char a, b; unsigned short c; unsigned char d, e, f, g; unsigned long long h; }; + +__attribute__((noipa)) void +f1 (struct S *p) +{ + p->a = 1; + p->b = 2; + p->c = 3; + p->d = 4; + p->e = 5; + p->f = 6; + p->g = 7; +} + +__attribute__((noipa)) void +f2 (struct S *__restrict p, struct S *__restrict q) +{ + p->a = q->a; + p->b = q->b; + p->c = q->c; + p->d = q->d; + p->e = q->e; + p->f = q->f; + p->g = q->g; +} + +__attribute__((noipa)) void +f3 (struct S *p, struct S *q) +{ + unsigned char pa = q->a; + unsigned char pb = q->b; + unsigned short pc = q->c; + unsigned char pd = q->d; + unsigned char pe = q->e; + unsigned char pf = q->f; + unsigned char pg = q->g; + p->a = pa; + p->b = pb; + p->c = pc; + p->d = pd; + p->e = pe; + p->f = pf; + p->g = pg; +} + +__attribute__((noipa)) void +f4 (struct S *p, struct S *q) +{ + unsigned char pa = p->a | q->a; + unsigned char pb = p->b | q->b; + unsigned short pc = p->c | q->c; + unsigned char pd = p->d | q->d; + unsigned char pe = p->e | q->e; + unsigned char pf = p->f | q->f; + unsigned char pg = p->g | q->g; + p->a = pa; + p->b = pb; + p->c = pc; + p->d = pd; + p->e = pe; + p->f = pf; + p->g = pg; +} + +__attribute__((noipa)) void +f5 (struct S *p, struct S *q) +{ + unsigned char pa = p->a & q->a; + unsigned char pb = p->b & q->b; + unsigned short pc = p->c & q->c; + unsigned char pd = p->d & q->d; + unsigned char pe = p->e & q->e; + unsigned char pf = p->f & q->f; + unsigned char pg = p->g & q->g; + p->a = pa; + p->b = pb; + p->c = pc; + p->d = pd; + p->e = pe; + p->f = pf; + p->g = pg; +} + +__attribute__((noipa)) void +f6 (struct S *p, struct S *q) +{ + unsigned char pa = p->a ^ q->a; + unsigned char pb = p->b ^ q->b; + unsigned short pc = p->c ^ q->c; + unsigned char pd = p->d ^ q->d; + unsigned char pe = p->e ^ q->e; + unsigned char pf = p->f ^ q->f; + unsigned char pg = p->g ^ q->g; + p->a = pa; + p->b = pb; + p->c = pc; + p->d = pd; + p->e = pe; + p->f = pf; + p->g = pg; +} + +__attribute__((noipa)) void +f7 (struct S *__restrict p, struct S *__restrict q) +{ + p->a |= q->a; + p->b |= q->b; + p->c |= q->c; + p->d |= q->d; + p->e |= q->e; + p->f |= q->f; + p->g |= q->g; +} + +__attribute__((noipa)) void +f8 (struct S *__restrict p, struct S *__restrict q) +{ + p->a &= q->a; + p->b &= q->b; + p->c &= q->c; + p->d &= q->d; + p->e &= q->e; + p->f &= q->f; + p->g &= q->g; +} + +__attribute__((noipa)) void +f9 (struct S *__restrict p, struct S *__restrict q) +{ + p->a ^= q->a; + p->b ^= q->b; + p->c ^= q->c; + p->d ^= q->d; + p->e ^= q->e; + p->f ^= q->f; + p->g ^= q->g; +} + +__attribute__((noipa)) void +f10 (struct S *__restrict p, struct S *__restrict q) +{ + p->a = ~q->a; + p->b = ~q->b; + p->c = ~q->c; + p->d = ~q->d; + p->e = ~q->e; + p->f = ~q->f; + p->g = ~q->g; +} + +__attribute__((noipa)) void +f11 (struct S *__restrict p, struct S *__restrict q) +{ + p->a = p->a | (unsigned char) ~q->a; + p->b = p->b | (unsigned char) ~q->b; + p->c = p->c | (unsigned short) ~q->c; + p->d = p->d | (unsigned char) ~q->d; + p->e = p->e | (unsigned char) ~q->e; + p->f = p->f | (unsigned char) ~q->f; + p->g = p->g | (unsigned char) ~q->g; +} + +__attribute__((noipa)) void +f12 (struct S *__restrict p, struct S *__restrict q) +{ + p->a = p->a & (unsigned char) ~q->a; + p->b = p->b & (unsigned char) ~q->b; + p->c = p->c & (unsigned short) ~q->c; + p->d = p->d & (unsigned char) ~q->d; + p->e = p->e & (unsigned char) ~q->e; + p->f = p->f & (unsigned char) ~q->f; + p->g = p->g & (unsigned char) ~q->g; +} + +__attribute__((noipa)) void +f13 (struct S *__restrict p, struct S *__restrict q) +{ + p->a = p->a ^ (unsigned char) ~q->a; + p->b = p->b ^ (unsigned char) ~q->b; + p->c = p->c ^ (unsigned short) ~q->c; + p->d = p->d ^ (unsigned char) ~q->d; + p->e = p->e ^ (unsigned char) ~q->e; + p->f = p->f ^ (unsigned char) ~q->f; + p->g = p->g ^ (unsigned char) ~q->g; +} + +struct S s = { 20, 21, 22, 23, 24, 25, 26, 27 }; +struct S t = { 0x71, 0x72, 0x7f04, 0x78, 0x31, 0x32, 0x34, 0xf1f2f3f4f5f6f7f8ULL }; +struct S u = { 28, 29, 30, 31, 32, 33, 34, 35 }; +struct S v = { 36, 37, 38, 39, 40, 41, 42, 43 }; + +int +main () +{ + asm volatile ("" : : : "memory"); + f1 (&s); + asm volatile ("" : : : "memory"); + if (s.a != 1 || s.b != 2 || s.c != 3 || s.d != 4 + || s.e != 5 || s.f != 6 || s.g != 7 || s.h != 27) + __builtin_abort (); + f2 (&s, &u); + asm volatile ("" : : : "memory"); + if (s.a != 28 || s.b != 29 || s.c != 30 || s.d != 31 + || s.e != 32 || s.f != 33 || s.g != 34 || s.h != 27) + __builtin_abort (); + f3 (&s, &v); + asm volatile ("" : : : "memory"); + if (s.a != 36 || s.b != 37 || s.c != 38 || s.d != 39 + || s.e != 40 || s.f != 41 || s.g != 42 || s.h != 27) + __builtin_abort (); + f4 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (36 | 0x71) || s.b != (37 | 0x72) + || s.c != (38 | 0x7f04) || s.d != (39 | 0x78) + || s.e != (40 | 0x31) || s.f != (41 | 0x32) + || s.g != (42 | 0x34) || s.h != 27) + __builtin_abort (); + f3 (&s, &u); + f5 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (28 & 0x71) || s.b != (29 & 0x72) + || s.c != (30 & 0x7f04) || s.d != (31 & 0x78) + || s.e != (32 & 0x31) || s.f != (33 & 0x32) + || s.g != (34 & 0x34) || s.h != 27) + __builtin_abort (); + f2 (&s, &v); + f6 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (36 ^ 0x71) || s.b != (37 ^ 0x72) + || s.c != (38 ^ 0x7f04) || s.d != (39 ^ 0x78) + || s.e != (40 ^ 0x31) || s.f != (41 ^ 0x32) + || s.g != (42 ^ 0x34) || s.h != 27) + __builtin_abort (); + f3 (&s, &v); + f7 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (36 | 0x71) || s.b != (37 | 0x72) + || s.c != (38 | 0x7f04) || s.d != (39 | 0x78) + || s.e != (40 | 0x31) || s.f != (41 | 0x32) + || s.g != (42 | 0x34) || s.h != 27) + __builtin_abort (); + f3 (&s, &u); + f8 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (28 & 0x71) || s.b != (29 & 0x72) + || s.c != (30 & 0x7f04) || s.d != (31 & 0x78) + || s.e != (32 & 0x31) || s.f != (33 & 0x32) + || s.g != (34 & 0x34) || s.h != 27) + __builtin_abort (); + f2 (&s, &v); + f9 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (36 ^ 0x71) || s.b != (37 ^ 0x72) + || s.c != (38 ^ 0x7f04) || s.d != (39 ^ 0x78) + || s.e != (40 ^ 0x31) || s.f != (41 ^ 0x32) + || s.g != (42 ^ 0x34) || s.h != 27) + __builtin_abort (); + f10 (&s, &u); + asm volatile ("" : : : "memory"); + if (s.a != (unsigned char) ~28 || s.b != (unsigned char) ~29 + || s.c != (unsigned short) ~30 || s.d != (unsigned char) ~31 + || s.e != (unsigned char) ~32 || s.f != (unsigned char) ~33 + || s.g != (unsigned char) ~34 || s.h != 27) + __builtin_abort (); + f3 (&s, &v); + f11 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (36 | (unsigned char) ~0x71) || s.b != (37 | (unsigned char) ~0x72) + || s.c != (38 | (unsigned short) ~0x7f04) || s.d != (39 | (unsigned char) ~0x78) + || s.e != (40 | (unsigned char) ~0x31) || s.f != (41 | (unsigned char) ~0x32) + || s.g != (42 | (unsigned char) ~0x34) || s.h != 27) + __builtin_abort (); + f3 (&s, &u); + f12 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (28 & (unsigned char) ~0x71) || s.b != (29 & (unsigned char) ~0x72) + || s.c != (30 & (unsigned short) ~0x7f04) || s.d != (31 & (unsigned char) ~0x78) + || s.e != (32 & (unsigned char) ~0x31) || s.f != (33 & (unsigned char) ~0x32) + || s.g != (34 & (unsigned char) ~0x34) || s.h != 27) + __builtin_abort (); + f2 (&s, &v); + f13 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.a != (36 ^ (unsigned char) ~0x71) || s.b != (37 ^ (unsigned char) ~0x72) + || s.c != (38 ^ (unsigned short) ~0x7f04) || s.d != (39 ^ (unsigned char) ~0x78) + || s.e != (40 ^ (unsigned char) ~0x31) || s.f != (41 ^ (unsigned char) ~0x32) + || s.g != (42 ^ (unsigned char) ~0x34) || s.h != 27) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 13 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_14.c b/SingleSource/Regression/C/gcc-dg/store_merging_14.c new file mode 100644 index 0000000000..9310aaf348 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_14.c @@ -0,0 +1,217 @@ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +struct S { unsigned int i : 8, a : 7, b : 7, j : 10, c : 15, d : 7, e : 10, f : 7, g : 9, k : 16; unsigned long long h; }; + +__attribute__((noipa)) void +f1 (struct S *p) +{ + p->a = 1; + p->b = 2; + p->c = 3; + p->d = 4; + p->e = 5; + p->f = 6; + p->g = 7; +} + +__attribute__((noipa)) void +f2 (struct S *__restrict p, struct S *__restrict q) +{ + p->a = q->a; + p->b = q->b; + p->c = q->c; + p->d = q->d; + p->e = q->e; + p->f = q->f; + p->g = q->g; +} + +__attribute__((noipa)) void +f3 (struct S *p, struct S *q) +{ + unsigned char pa = q->a; + unsigned char pb = q->b; + unsigned short pc = q->c; + unsigned char pd = q->d; + unsigned short pe = q->e; + unsigned char pf = q->f; + unsigned short pg = q->g; + p->a = pa; + p->b = pb; + p->c = pc; + p->d = pd; + p->e = pe; + p->f = pf; + p->g = pg; +} + +__attribute__((noipa)) void +f4 (struct S *p, struct S *q) +{ + unsigned char pa = p->a | q->a; + unsigned char pb = p->b | q->b; + unsigned short pc = p->c | q->c; + unsigned char pd = p->d | q->d; + unsigned short pe = p->e | q->e; + unsigned char pf = p->f | q->f; + unsigned short pg = p->g | q->g; + p->a = pa; + p->b = pb; + p->c = pc; + p->d = pd; + p->e = pe; + p->f = pf; + p->g = pg; +} + +__attribute__((noipa)) void +f5 (struct S *p, struct S *q) +{ + unsigned char pa = p->a & q->a; + unsigned char pb = p->b & q->b; + unsigned short pc = p->c & q->c; + unsigned char pd = p->d & q->d; + unsigned short pe = p->e & q->e; + unsigned char pf = p->f & q->f; + unsigned short pg = p->g & q->g; + p->a = pa; + p->b = pb; + p->c = pc; + p->d = pd; + p->e = pe; + p->f = pf; + p->g = pg; +} + +__attribute__((noipa)) void +f6 (struct S *p, struct S *q) +{ + unsigned char pa = p->a ^ q->a; + unsigned char pb = p->b ^ q->b; + unsigned short pc = p->c ^ q->c; + unsigned char pd = p->d ^ q->d; + unsigned short pe = p->e ^ q->e; + unsigned char pf = p->f ^ q->f; + unsigned short pg = p->g ^ q->g; + p->a = pa; + p->b = pb; + p->c = pc; + p->d = pd; + p->e = pe; + p->f = pf; + p->g = pg; +} + +__attribute__((noipa)) void +f7 (struct S *__restrict p, struct S *__restrict q) +{ + p->a |= q->a; + p->b |= q->b; + p->c |= q->c; + p->d |= q->d; + p->e |= q->e; + p->f |= q->f; + p->g |= q->g; +} + +__attribute__((noipa)) void +f8 (struct S *__restrict p, struct S *__restrict q) +{ + p->a &= q->a; + p->b &= q->b; + p->c &= q->c; + p->d &= q->d; + p->e &= q->e; + p->f &= q->f; + p->g &= q->g; +} + +__attribute__((noipa)) void +f9 (struct S *__restrict p, struct S *__restrict q) +{ + p->a ^= q->a; + p->b ^= q->b; + p->c ^= q->c; + p->d ^= q->d; + p->e ^= q->e; + p->f ^= q->f; + p->g ^= q->g; +} + +struct S s = { 72, 20, 21, 73, 22, 23, 24, 25, 26, 74, 27 }; +struct S t = { 75, 0x71, 0x72, 76, 0x7f04, 0x78, 0x31, 0x32, 0x34, 77, 0xf1f2f3f4f5f6f7f8ULL }; +struct S u = { 78, 28, 29, 79, 30, 31, 32, 33, 34, 80, 35 }; +struct S v = { 81, 36, 37, 82, 38, 39, 40, 41, 42, 83, 43 }; + +int +main () +{ + asm volatile ("" : : : "memory"); + f1 (&s); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != 1 || s.b != 2 || s.j != 73 || s.c != 3 || s.d != 4 + || s.e != 5 || s.f != 6 || s.g != 7 || s.k != 74 || s.h != 27) + __builtin_abort (); + f2 (&s, &u); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != 28 || s.b != 29 || s.j != 73 || s.c != 30 || s.d != 31 + || s.e != 32 || s.f != 33 || s.g != 34 || s.k != 74 || s.h != 27) + __builtin_abort (); + f3 (&s, &v); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != 36 || s.b != 37 || s.j != 73 || s.c != 38 || s.d != 39 + || s.e != 40 || s.f != 41 || s.g != 42 || s.k != 74 || s.h != 27) + __builtin_abort (); + f4 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != (36 | 0x71) || s.b != (37 | 0x72) || s.j != 73 + || s.c != (38 | 0x7f04) || s.d != (39 | 0x78) + || s.e != (40 | 0x31) || s.f != (41 | 0x32) + || s.g != (42 | 0x34) || s.k != 74 || s.h != 27) + __builtin_abort (); + f3 (&s, &u); + f5 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != (28 & 0x71) || s.b != (29 & 0x72) || s.j != 73 + || s.c != (30 & 0x7f04) || s.d != (31 & 0x78) + || s.e != (32 & 0x31) || s.f != (33 & 0x32) + || s.g != (34 & 0x34) || s.k != 74 || s.h != 27) + __builtin_abort (); + f2 (&s, &v); + f6 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != (36 ^ 0x71) || s.b != (37 ^ 0x72) || s.j != 73 + || s.c != (38 ^ 0x7f04) || s.d != (39 ^ 0x78) + || s.e != (40 ^ 0x31) || s.f != (41 ^ 0x32) + || s.g != (42 ^ 0x34) || s.k != 74 || s.h != 27) + __builtin_abort (); + f3 (&s, &v); + f7 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != (36 | 0x71) || s.b != (37 | 0x72) || s.j != 73 + || s.c != (38 | 0x7f04) || s.d != (39 | 0x78) + || s.e != (40 | 0x31) || s.f != (41 | 0x32) + || s.g != (42 | 0x34) || s.k != 74 || s.h != 27) + __builtin_abort (); + f3 (&s, &u); + f8 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != (28 & 0x71) || s.b != (29 & 0x72) || s.j != 73 + || s.c != (30 & 0x7f04) || s.d != (31 & 0x78) + || s.e != (32 & 0x31) || s.f != (33 & 0x32) + || s.g != (34 & 0x34) || s.k != 74 || s.h != 27) + __builtin_abort (); + f2 (&s, &v); + f9 (&s, &t); + asm volatile ("" : : : "memory"); + if (s.i != 72 || s.a != (36 ^ 0x71) || s.b != (37 ^ 0x72) || s.j != 73 + || s.c != (38 ^ 0x7f04) || s.d != (39 ^ 0x78) + || s.e != (40 ^ 0x31) || s.f != (41 ^ 0x32) + || s.g != (42 ^ 0x34) || s.k != 74 || s.h != 27) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 9 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_15.c b/SingleSource/Regression/C/gcc-dg/store_merging_15.c new file mode 100644 index 0000000000..13fcca4aa1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_15.c @@ -0,0 +1,56 @@ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +struct S { unsigned char a, b; unsigned short c; unsigned char d, e, f, g; unsigned long long h; }; + +__attribute__((noipa)) void +f1 (struct S *__restrict p, struct S *__restrict q) +{ + p->a = ~q->a; + p->b = q->b; + p->c = ~q->c; + p->d = ~q->d; + p->e = q->e; + p->f = ~q->f; + p->g = ~q->g; +} + +__attribute__((noipa)) void +f2 (struct S *__restrict p, struct S *__restrict q) +{ + p->a = ~(unsigned char) (p->a & q->a); + p->b = ((unsigned char) ~p->b) & q->b; + p->c = p->c & (unsigned short) ~q->c; + p->d = p->d & q->d; + p->e = p->e & (unsigned char) ~q->e; + p->f = p->f & (unsigned char) ~q->f; + p->g = ~(unsigned char) (p->g & q->g); +} + +struct S s = { 20, 21, 22, 23, 24, 25, 26, 27 }; +struct S u = { 28, 29, 30, 31, 32, 33, 34, 35 }; +struct S v = { 36, 37, 38, 39, 40, 41, 42, 43 }; + +int +main () +{ + asm volatile ("" : : : "memory"); + f1 (&s, &u); + asm volatile ("" : : : "memory"); + if (s.a != (unsigned char) ~28 || s.b != 29 + || s.c != (unsigned short) ~30 || s.d != (unsigned char) ~31 + || s.e != 32 || s.f != (unsigned char) ~33 || s.g != (unsigned char) ~34 + || s.h != 27) + __builtin_abort (); + f2 (&u, &v); + asm volatile ("" : : : "memory"); + if (u.a != (unsigned char) ~(28 & 36) || u.b != (((unsigned char) ~29) & 37) + || u.c != (30 & (unsigned short) ~38) || u.d != (31 & 39) + || u.e != (32 & (unsigned char) ~40) || u.f != (33 & (unsigned char) ~41) + || u.g != (unsigned char) ~(34 & 42) || u.h != 35) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_16.c b/SingleSource/Regression/C/gcc-dg/store_merging_16.c new file mode 100644 index 0000000000..cd83f1c0fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_16.c @@ -0,0 +1,157 @@ +/* Only test on some 64-bit targets which do have bswap{si,di}2 patterns and + are either big or little endian (not pdp endian). */ +/* { dg-do run { target { lp64 && { i?86-*-* x86_64-*-* powerpc*-*-* aarch64*-*-* } } } } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +__attribute__((noipa)) void +f1 (unsigned char *p, unsigned long long q) +{ + p[0] = q; + p[1] = q >> 8; + p[2] = q >> 16; + p[3] = q >> 24; + p[4] = q >> 32; + p[5] = q >> 40; + p[6] = q >> 48; + p[7] = q >> 56; +} + +__attribute__((noipa)) void +f2 (unsigned char *p, unsigned long long q) +{ + p[0] = q >> 56; + p[1] = q >> 48; + p[2] = q >> 40; + p[3] = q >> 32; + p[4] = q >> 24; + p[5] = q >> 16; + p[6] = q >> 8; + p[7] = q; +} + +__attribute__((noipa)) void +f3 (unsigned char *__restrict p, unsigned char *__restrict q) +{ + unsigned char q3 = q[3]; + unsigned char q2 = q[2]; + unsigned char q1 = q[1]; + unsigned char q0 = q[0]; + p[0] = q3; + p[1] = q2; + p[2] = q1; + p[3] = q0; +} + +__attribute__((noipa)) void +f4 (unsigned char *__restrict p, unsigned char *__restrict q) +{ + p[0] = q[3]; + p[1] = q[2]; + p[2] = q[1]; + p[3] = q[0]; +} + +struct S { unsigned char a, b; unsigned short c; }; + +__attribute__((noipa)) void +f5 (struct S *__restrict p, struct S *__restrict q) +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + unsigned char pa = q->c >> 8; + unsigned char pb = q->c; + unsigned short pc = (q->a << 8) | q->b; +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + unsigned char pa = q->c; + unsigned char pb = q->c >> 8; + unsigned short pc = q->a | (q->b << 8); +#endif + p->a = pa; + p->b = pb; + p->c = pc; +} + +__attribute__((noipa)) void +f6 (struct S *__restrict p, struct S *__restrict q) +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + p->a = q->c >> 8; + p->b = q->c; + p->c = (q->a << 8) | q->b; +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + p->a = q->c; + p->b = q->c >> 8; + p->c = q->a | (q->b << 8); +#endif +} + +struct T { unsigned long long a : 8, b : 8, c : 8, d : 8, e : 8, f : 8, g : 8, h : 8; }; + +__attribute__((noipa)) void +f7 (struct T *__restrict p, struct T *__restrict q) +{ + p->a = q->h; + p->b = q->g; + p->c = q->f; + p->d = q->e; + p->e = q->d; + p->f = q->c; + p->g = q->b; + p->h = q->a; +} + +struct S b = { 0x11, 0x12, +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + 0x1413 +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + 0x1314 +#endif + }; +struct T e = { 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28 }; + +int +main () +{ + unsigned char a[8]; + int i; + struct S c, d; + f1 (a, 0x0102030405060708ULL); + for (i = 0; i < 8; ++i) + if (a[i] != 8 - i) + __builtin_abort (); + f2 (a, 0x0102030405060708ULL); + for (i = 0; i < 8; ++i) + if (a[i] != 1 + i) + __builtin_abort (); + f3 (a, a + 4); + for (i = 0; i < 8; ++i) + if (a[i] != (i < 4 ? 8 - i : 1 + i)) + __builtin_abort (); + f2 (a, 0x090a0b0c0d0e0f10ULL); + f4 (a + 4, a); + for (i = 0; i < 8; ++i) + if (a[i] != (i < 4 ? 9 + i : 16 - i)) + __builtin_abort (); + f5 (&c, &b); + if (c.a != 0x14 || c.b != 0x13 +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + || c.c != 0x1112 +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + || c.c != 0x1211 +#endif + ) + __builtin_abort (); + f6 (&d, &c); + if (d.a != 0x11 || d.b != 0x12 || d.c != b.c) + __builtin_abort (); + struct T f; + f7 (&f, &e); + if (f.a != 0x28 || f.b != 0x27 || f.c != 0x26 || f.d != 0x25 + || f.e != 0x24 || f.f != 0x23 || f.g != 0x22 || f.h != 0x21) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 7 "store-merging" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_bswap64" 2 "store-merging" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_bswap32" 4 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_17.c b/SingleSource/Regression/C/gcc-dg/store_merging_17.c new file mode 100644 index 0000000000..76e6b638e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_17.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/83241 */ +/* { dg-do compile { target store_merge } } */ +/* { dg-options "-O2" } */ + +struct S { int a; short b[32]; } e; +struct T { volatile int c; int d; } f; + +void +foo () +{ + struct T g = f; + e.b[0] = 6; + e.b[1] = 6; + e.b[4] = g.d; + e.b[5] = g.d >> 16; + e.a = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_18.c b/SingleSource/Regression/C/gcc-dg/store_merging_18.c new file mode 100644 index 0000000000..fdff6b4d81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_18.c @@ -0,0 +1,51 @@ +/* PR tree-optimization/83843 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ +/* { dg-final { scan-tree-dump-times "Merging successful" 3 "store-merging" { target { store_merge && { ! arm*-*-* } } } } } */ + +__attribute__((noipa)) void +foo (unsigned char *buf, unsigned char *tab) +{ + unsigned v = tab[1] ^ (tab[0] << 8); + buf[0] = ~(v >> 8); + buf[1] = ~v; +} + +__attribute__((noipa)) void +bar (unsigned char *buf, unsigned char *tab) +{ + unsigned v = tab[1] ^ (tab[0] << 8); + buf[0] = (v >> 8); + buf[1] = ~v; +} + +__attribute__((noipa)) void +baz (unsigned char *buf, unsigned char *tab) +{ + unsigned v = tab[1] ^ (tab[0] << 8); + buf[0] = ~(v >> 8); + buf[1] = v; +} + +int +main () +{ + volatile unsigned char l1 = 0; + volatile unsigned char l2 = 1; + unsigned char buf[2]; + unsigned char tab[2] = { l1 + 1, l2 * 2 }; + foo (buf, tab); + if (buf[0] != (unsigned char) ~1 || buf[1] != (unsigned char) ~2) + __builtin_abort (); + buf[0] = l1 + 7; + buf[1] = l2 * 8; + bar (buf, tab); + if (buf[0] != 1 || buf[1] != (unsigned char) ~2) + __builtin_abort (); + buf[0] = l1 + 9; + buf[1] = l2 * 10; + baz (buf, tab); + if (buf[0] != (unsigned char) ~1 || buf[1] != 2) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_19.c b/SingleSource/Regression/C/gcc-dg/store_merging_19.c new file mode 100644 index 0000000000..0a2bbc4bfd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_19.c @@ -0,0 +1,57 @@ +/* PR tree-optimization/83843 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ +/* { dg-final { scan-tree-dump-times "Merging successful" 3 "store-merging" { target store_merge } } } */ + +__attribute__((noipa)) void +foo (unsigned char *buf, unsigned char *tab) +{ + tab = __builtin_assume_aligned (tab, 2); + buf = __builtin_assume_aligned (buf, 2); + unsigned v = tab[1] ^ (tab[0] << 8); + buf[0] = ~(v >> 8); + buf[1] = ~v; +} + +__attribute__((noipa)) void +bar (unsigned char *buf, unsigned char *tab) +{ + tab = __builtin_assume_aligned (tab, 2); + buf = __builtin_assume_aligned (buf, 2); + unsigned v = tab[1] ^ (tab[0] << 8); + buf[0] = (v >> 8); + buf[1] = ~v; +} + +__attribute__((noipa)) void +baz (unsigned char *buf, unsigned char *tab) +{ + tab = __builtin_assume_aligned (tab, 2); + buf = __builtin_assume_aligned (buf, 2); + unsigned v = tab[1] ^ (tab[0] << 8); + buf[0] = ~(v >> 8); + buf[1] = v; +} + +int +main () +{ + volatile unsigned char l1 = 0; + volatile unsigned char l2 = 1; + unsigned char buf[2] __attribute__((aligned (2))); + unsigned char tab[2] __attribute__((aligned (2))) = { l1 + 1, l2 * 2 }; + foo (buf, tab); + if (buf[0] != (unsigned char) ~1 || buf[1] != (unsigned char) ~2) + __builtin_abort (); + buf[0] = l1 + 7; + buf[1] = l2 * 8; + bar (buf, tab); + if (buf[0] != 1 || buf[1] != (unsigned char) ~2) + __builtin_abort (); + buf[0] = l1 + 9; + buf[1] = l2 * 10; + baz (buf, tab); + if (buf[0] != (unsigned char) ~1 || buf[1] != 2) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_2.c b/SingleSource/Regression/C/gcc-dg/store_merging_2.c new file mode 100644 index 0000000000..8cd29f4243 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_2.c @@ -0,0 +1,80 @@ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +struct bar +{ + int a; + unsigned char b; + unsigned char c; + short d; + unsigned char e; + unsigned char f; + unsigned char g; +}; + +__attribute__ ((noinline)) void +foozero (struct bar *p) +{ + p->b = 0; + p->a = 0; + p->c = 0; + p->d = 0; + p->e = 0; + p->f = 0; + p->g = 0; +} + +__attribute__ ((noinline)) void +foo1 (struct bar *p) +{ + p->b = 1; + p->a = 2; + p->c = 3; + p->d = 4; + p->e = 5; + p->f = 0; + p->g = 0xff; +} + +__attribute__ ((noinline)) void +foo2 (struct bar *p, struct bar *p2) +{ + p->b = 0xff; + p2->b = 0xa; + p->a = 0xfffff; + p2->c = 0xc; + p->c = 0xff; + p2->d = 0xbf; + p->d = 0xfff; +} + +int +main (void) +{ + struct bar b1, b2; + foozero (&b1); + foozero (&b2); + + foo1 (&b1); + if (b1.b != 1 || b1.a != 2 || b1.c != 3 || b1.d != 4 || b1.e != 5 + || b1.f != 0 || b1.g != 0xff) + __builtin_abort (); + + foozero (&b1); + /* Make sure writes to aliasing struct pointers preserve the + correct order. */ + foo2 (&b1, &b1); + if (b1.b != 0xa || b1.a != 0xfffff || b1.c != 0xff || b1.d != 0xfff) + __builtin_abort (); + + foozero (&b1); + foo2 (&b1, &b2); + if (b1.a != 0xfffff || b1.b != 0xff || b1.c != 0xff || b1.d != 0xfff + || b2.b != 0xa || b2.c != 0xc || b2.d != 0xbf) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_20.c b/SingleSource/Regression/C/gcc-dg/store_merging_20.c new file mode 100644 index 0000000000..b15582aa16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_20.c @@ -0,0 +1,68 @@ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +extern void abort (void); + +struct S1 { + unsigned int flag : 1; + unsigned int size : 31; +}; + +__attribute__((noipa)) +void foo1 (struct S1 *s, unsigned int size) +{ + s->flag = 1; + s->size = size & 0x7FFFFFFF; +} + +struct S2 { + unsigned int flag : 1; + unsigned int size : 15; + unsigned short count; +}; + +__attribute__((noipa)) +void foo2 (struct S2 *s, unsigned short size) +{ + s->flag = 1; + s->size = size; + s->count = 0xABCD; +} + +struct S3 { + unsigned int n1 : 4; + unsigned int c : 8; + unsigned int n2 : 4; +}; + +__attribute__((noipa)) +void foo3 (struct S3 *s, unsigned char n1, unsigned char c, unsigned char n2) +{ + s->n1 = n1 & 0xF; + s->n2 = n2 & 0xF; + s->c = c; +} + +int main (void) +{ + struct S1 s1; + struct S2 s2; + struct S3 s3; + + foo1 (&s1, 0x12345678); + if (s1.flag != 1 || s1.size != 0x12345678) + abort (); + + foo2 (&s2, 0x1234); + if (s2.flag != 1 || s2.size != 0x1234 || s2.count != 0xABCD) + abort (); + + foo3 (&s3, 0x12, 0x34, 0x56); + if (s3.n1 != 0x2 || s3.c != 0x34 || s3.n2 != 0x6) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 3 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_21.c b/SingleSource/Regression/C/gcc-dg/store_merging_21.c new file mode 100644 index 0000000000..ec0c8e240b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_21.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +extern void abort (void); + +struct S1 { + unsigned int flag : 1; + unsigned int size : 31; +}; + +void foo1 (struct S1 *s, struct S1 *m) +{ + s->flag = 1; + s->size = m->size; +} + +void bar1 (struct S1 *s, struct S1 *m, _Bool flag) +{ + s->flag = flag; + s->size = m->size; +} + +struct S2 { + unsigned int size : 31; + unsigned int flag : 1; +}; + +void foo2 (struct S2 *s, struct S2 *m) +{ + s->size = m->size; + s->flag = 1; +} + +void bar2 (struct S2 *s, struct S2 *m, _Bool flag) +{ + s->flag = flag; + s->size = m->size; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 4 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_22.c b/SingleSource/Regression/C/gcc-dg/store_merging_22.c new file mode 100644 index 0000000000..bcd42358a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_22.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/86844 */ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +void +foo (int *p) +{ + *p = 0; + *((char *)p + 3) = 1; + *((char *)p + 1) = 2; + *((char *)p + 2) = *((char *)p + 38); +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 1 "store-merging" } } */ +/* { dg-final { scan-tree-dump-times "New sequence of 1 stores to replace old one of 3 stores" 1 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_23.c b/SingleSource/Regression/C/gcc-dg/store_merging_23.c new file mode 100644 index 0000000000..dd197fb8db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_23.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/86844 */ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +void +foo (int *p) +{ + *p = 0; + int one = 1; + __builtin_memcpy ((char *) p + 3, &one, sizeof (int)); + *((char *)p + 4) = *((char *)p + 36); + *((char *)p + 1) = 2; +} + +/* { dg-final { scan-tree-dump-not "Merging successful" "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_24.c b/SingleSource/Regression/C/gcc-dg/store_merging_24.c new file mode 100644 index 0000000000..5291bb9e98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_24.c @@ -0,0 +1,75 @@ +/* PR tree-optimization/87859 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging-details" } */ +/* { dg-final { scan-tree-dump "New sequence of \[23] stores to replace old one of 19 stores" "store-merging" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-tree-dump "New sequence of 1 stores to replace old one of 6 stores" "store-merging" { target i?86-*-* x86_64-*-* } } } */ + +struct S { + union F { + struct T { +#define A(n) unsigned n:1; +#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) \ + A(n##5) A(n##6) A(n##7) A(n##8) A(n##9) + B(f) B(f1) B(f2) B(f3) B(f4) B(f5) + A(f60) A(f61) A(f62) A(f63) A(f64) A(f65) A(f66) + } q; + unsigned int i[3]; + } f; +}; + +struct S s = { + .f.q.f0 = 1, .f.q.f1 = 1, .f.q.f2 = 1, .f.q.f5 = 1, .f.q.f6 = 1, + .f.q.f7 = 1, .f.q.f8 = 1, .f.q.f9 = 1, .f.q.f13 = 1, .f.q.f14 = 1, + .f.q.f15 = 1, .f.q.f16 = 1, .f.q.f17 = 1, .f.q.f19 = 1, .f.q.f21 = 1, + .f.q.f66 = 1 +}; + +__attribute__((noipa)) void +bar (unsigned *x) +{ + if (x[0] != s.f.i[0] || x[1] != s.f.i[1] || x[2] != s.f.i[2]) + __builtin_abort (); +} + +__attribute__((noipa)) void +foo (unsigned char *state) +{ + struct S i; + i.f.i[0] = 0; + i.f.i[1] = 0; + i.f.i[2] = 0; + i.f.q.f7 = 1; + i.f.q.f2 = 1; + i.f.q.f21 = 1; + i.f.q.f19 = 1; + i.f.q.f14 = 1; + i.f.q.f5 = 1; + i.f.q.f0 = 1; + i.f.q.f15 = 1; + i.f.q.f16 = 1; + i.f.q.f6 = 1; + i.f.q.f9 = 1; + i.f.q.f17 = 1; + i.f.q.f1 = 1; + i.f.q.f8 = 1; + i.f.q.f13 = 1; + i.f.q.f66 = 1; + if (*state) + { + i.f.q.f37 = 1; + i.f.q.f38 = 1; + i.f.q.f39 = 1; + i.f.q.f40 = 1; + i.f.q.f41 = 1; + i.f.q.f36 = 1; + } + bar (i.f.i); +} + +int +main () +{ + unsigned char z = 0; + foo (&z); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_25.c b/SingleSource/Regression/C/gcc-dg/store_merging_25.c new file mode 100644 index 0000000000..96611b5e57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_25.c @@ -0,0 +1,75 @@ +/* PR tree-optimization/87859 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging-details" } */ +/* { dg-final { scan-tree-dump "New sequence of \[23] stores to replace old one of 14 stores" "store-merging" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-tree-dump "New sequence of 1 stores to replace old one of 6 stores" "store-merging" { target i?86-*-* x86_64-*-* } } } */ + +struct S { + union F { + struct T { +#define A(n) unsigned n:1; +#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) \ + A(n##5) A(n##6) A(n##7) A(n##8) A(n##9) + B(f) B(f1) B(f2) B(f3) B(f4) B(f5) + A(f60) A(f61) A(f62) A(f63) A(f64) A(f65) A(f66) + } q; + unsigned int i[3]; + } f; +}; + +struct S s = { + .f.q.f0 = 1, .f.q.f1 = 1, .f.q.f2 = 1, .f.q.f5 = 1, .f.q.f6 = 1, + .f.q.f7 = 1, .f.q.f8 = 1, .f.q.f9 = 1, .f.q.f13 = 1, .f.q.f14 = 1, + .f.q.f15 = 1, .f.q.f16 = 1, .f.q.f17 = 1, .f.q.f19 = 1, .f.q.f21 = 1, + .f.q.f66 = 1 +}; + +__attribute__((noipa)) void +bar (unsigned *x) +{ + if (x[0] != s.f.i[0] || x[1] != s.f.i[1] || x[2] != s.f.i[2]) + __builtin_abort (); +} + +__attribute__((noipa)) void +foo (unsigned char *state, unsigned char c) +{ + struct S i; + i.f.i[0] = 0; + i.f.i[1] = 0; + i.f.i[2] = 0; + i.f.q.f7 = 1; + i.f.q.f2 = 1; + i.f.q.f21 = 1; + i.f.q.f19 = 1; + i.f.q.f14 = 1; + i.f.q.f5 = 1; + i.f.q.f0 = 1; + i.f.q.f15 = 1; + i.f.q.f16 = 1; + i.f.q.f6 = 1; + i.f.q.f9 = 1; + i.f.q.f17 = c; + i.f.q.f1 = 1; + i.f.q.f8 = 1; + i.f.q.f13 = 1; + i.f.q.f66 = 1; + if (*state) + { + i.f.q.f37 = 1; + i.f.q.f38 = 1; + i.f.q.f39 = 1; + i.f.q.f40 = 1; + i.f.q.f41 = 1; + i.f.q.f36 = 1; + } + bar (i.f.i); +} + +int +main () +{ + unsigned char z = 0; + foo (&z, 1); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_26.c b/SingleSource/Regression/C/gcc-dg/store_merging_26.c new file mode 100644 index 0000000000..0a0b949be6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_26.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/90271 */ +/* { dg-do run { target int32 } } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging-details" } */ +/* { dg-final { scan-tree-dump "New sequence of 1 stores to replace old one of 2 stores" "store-merging" } } */ + +__attribute__((noipa)) void +foo (int *x) +{ + asm volatile ("" : : "r" (x) : "memory"); +} + +__attribute__((noipa)) int +bar () +{ + int x; + foo (&x); + x = 3; + ((char *) &x)[1] = 1; + foo (&x); + return x; +} + +int +main () +{ + int x; + foo (&x); + x = 3; + foo (&x); + ((char *) &x)[1] = 1; + foo (&x); + if (x != bar ()) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_27.c b/SingleSource/Regression/C/gcc-dg/store_merging_27.c new file mode 100644 index 0000000000..d3cd117bdc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_27.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/88709 */ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging-details" } */ +/* { dg-final { scan-tree-dump "New sequence of \[12] stores to replace old one of 3 stores" "store-merging" } } */ + +struct S { char buf[8]; }; + +__attribute__((noipa)) void +bar (struct S *x) +{ + int i; + for (i = 0; i < 8; i++) + if (x->buf[i] != ((i == 1) + (i == 3) * 2)) + __builtin_abort (); +} + +int +main () +{ + __attribute__((aligned(8))) struct S s = {}; + s.buf[1] = 1; + s.buf[3] = 2; + bar (&s); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_28.c b/SingleSource/Regression/C/gcc-dg/store_merging_28.c new file mode 100644 index 0000000000..fadb7fff99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_28.c @@ -0,0 +1,44 @@ +/* PR tree-optimization/88709 */ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fno-ipa-icf -fdump-tree-store-merging-details" } */ +/* { dg-final { scan-tree-dump-times "New sequence of \[24] stores to replace old one of 16 stores" 8 "store-merging" { target { i?86-*-* x86_64-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "New sequence of \[24] stores to replace old one of 6 stores" 1 "store-merging" { target { ! arm*-*-* } } } } */ + +typedef struct S { char data[16]; } S; +void optimize_me (S); +void optimize_me3 (S, S, S); + +void +good () +{ + optimize_me ((S) { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }); +} + +void +bad () +{ + optimize_me ((S) { 1, 2, 3, 4, 5 }); +} + +void +why () +{ + optimize_me ((S) { 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); +} + +void +srsly () +{ + optimize_me3 ((S) { 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + (S) { 11, 12, 13, 14, 15, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, + (S) { 21, 22, 23, 24, 25, 20, 20, 20, 10, 20, 20, 20, 20, 20, 20 }); +} + +void +srsly_not_one_missing () +{ + optimize_me3 ((S) { 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + (S) { 11, 12, 13, 14, 15, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, + (S) { 21, 22, 23, 24, 25, 20, 20, 20, 10, 20, 20, 20, 20, 20, 20, 11 }); +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_29.c b/SingleSource/Regression/C/gcc-dg/store_merging_29.c new file mode 100644 index 0000000000..e7afc9ddfd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_29.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/88709 */ +/* { dg-do run { target int32 } } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging-details" } */ +/* { dg-final { scan-tree-dump "New sequence of 3 stores to replace old one of 6 stores" "store-merging" { target { le && { ! arm*-*-* } } } } } */ +/* { dg-final { scan-tree-dump "New sequence of \[34] stores to replace old one of 6 stores" "store-merging" { target { be && { ! arm*-*-* } } } } } */ + +struct T { char a[1024]; }; + +__attribute__((noipa)) void +bar (struct T *t) +{ + int x = 0x506; + if (__builtin_memcmp (&t->a[97], &x, sizeof (x))) + __builtin_abort (); + __builtin_memset (&t->a[97], '\0', sizeof (x)); + for (int i = 0; i < 8; ++i) + if (t->a[i] != ((i == 54) + 2 * (i == 52) + 3 * (i == 95) + 4 * (i == 96))) + __builtin_abort (); +} + +int +main () +{ + struct T t = {}; + t.a[54] = 1; + t.a[52] = 2; + t.a[95] = 3; + t.a[96] = 4; + int x = 0x506; + __builtin_memcpy (&t.a[97], &x, sizeof (x)); + bar (&t); +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_3.c b/SingleSource/Regression/C/gcc-dg/store_merging_3.c new file mode 100644 index 0000000000..caf356da98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_3.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target non_strict_align } */ +/* { dg-options "-O2 -fdump-tree-store-merging-details" } */ + +/* Make sure stores to volatile addresses don't get combined with + other accesses. */ + +struct bar +{ + int a; + char b; + char c; + volatile short d; + char e; + char f; + char g; +}; + +void +foozero (struct bar *p) +{ + p->b = 0xa; + p->a = 0xb; + p->c = 0xc; + p->d = 0; + p->e = 0xd; + p->f = 0xe; + p->g = 0xf; +} + +/* { dg-final { scan-tree-dump "Volatile access terminates all chains" "store-merging" } } */ +/* { dg-final { scan-tree-dump-times "=\{v\} 0;" 1 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_30.c b/SingleSource/Regression/C/gcc-dg/store_merging_30.c new file mode 100644 index 0000000000..baf94efe73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_30.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/94573 */ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging-details" } */ +/* { dg-final { scan-tree-dump "New sequence of 4 stores to replace old one of 8 stores" "store-merging" { target lp64 } } } */ + +int var[43][12]; + +void +foo (int x) +{ + var[x][0] = 0; + var[x][1] = 0; + var[x][2] = 0; + var[x][3] = 0; + var[x][4] = 0; + var[x][5] = 0; + var[x][6] = 0; + var[x][7] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_31.c b/SingleSource/Regression/C/gcc-dg/store_merging_31.c new file mode 100644 index 0000000000..32c21eb053 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_31.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/97053 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +struct S { short a; char b[9]; int c; char d; int e; }; + +__attribute__((noipa)) void +foo (char *x, char *y) +{ + if (__builtin_strcmp (x, "ABCDXXXX") != 0 + || __builtin_strcmp (y, "ABCDXXXX") != 0) + __builtin_abort (); +} + +int +main () +{ + char a[9] = "XXXXXXXX"; + struct S b = {}; + __builtin_memcpy (a, "ABCD", 4); + b.a = 5; + __builtin_memcpy (b.b, a, 8); + b.d = 'X'; + b.e = 1; + foo (a, b.b); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_32.c b/SingleSource/Regression/C/gcc-dg/store_merging_32.c new file mode 100644 index 0000000000..8c90489bde --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_32.c @@ -0,0 +1,129 @@ +/* PR tree-optimization/97053 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-dse" } */ + +struct __attribute__((packed, may_alias)) S { long long s; }; +struct __attribute__((packed, may_alias)) T { short t; }; + +__attribute__((noipa)) void +test (char *p, char *q, int s) +{ + if ((s & 1) == 0) + { + if (*(short __attribute__((may_alias)) *) &p[sizeof (short)] + != *(short __attribute__((may_alias)) *) &q[sizeof (short)] + || (((struct S __attribute__((may_alias)) *) &p[1])->s + != ((struct S __attribute__((may_alias)) *) &q[1])->s) + || (*(short __attribute__((may_alias)) *) &p[2 * sizeof (short)] + != *(short __attribute__((may_alias)) *) &q[2 * sizeof (short)])) + __builtin_abort (); + } + else + { + if (*(short __attribute__((may_alias)) *) &p[sizeof (short)] + != *(short __attribute__((may_alias)) *) &q[sizeof (short)] + || (((struct S __attribute__((may_alias)) *) &p[1])->s + != ((struct S __attribute__((may_alias)) *) &q[1])->s) + || (((struct T __attribute__((may_alias)) *) &p[2 * sizeof (short) - 1])->t + != ((struct T __attribute__((may_alias)) *) &q[2 * sizeof (short) - 1])->t) + || p[3 * sizeof (short) - 2] != q[3 * sizeof (short) - 2]) + __builtin_abort (); + } +} + +__attribute__((noipa)) void +foo (long long *p, char *q, char *r, char *s) +{ + char a[64] __attribute__((aligned (__alignof (short)))); + *(short __attribute__((may_alias)) *) &a[sizeof (short)] = 1; + ((struct S __attribute__((may_alias)) *) &a[1])->s = p[0]; + *(short __attribute__((may_alias)) *) &a[2 * sizeof (short)] = 2; + *(short __attribute__((may_alias)) *) &q[sizeof (short)] = 1; + ((struct S __attribute__((may_alias)) *) &r[1])->s = p[0]; + *(short __attribute__((may_alias)) *) &s[2 * sizeof (short)] = 2; + test (a, q, 0); +} + +__attribute__((noipa)) void +bar (long long *p, char *q, char *r, char *s, char *t) +{ + char a[64] __attribute__((aligned (__alignof (short)))); + *(short __attribute__((may_alias)) *) &a[sizeof (short)] = 1; + ((struct S __attribute__((may_alias)) *) &a[1])->s = p[0]; + ((struct T __attribute__((may_alias)) *) &a[2 * sizeof (short) - 1])->t = 2; + a[3 * sizeof (short) - 2] = 3; + *(short __attribute__((may_alias)) *) &q[sizeof (short)] = 1; + ((struct S __attribute__((may_alias)) *) &r[1])->s = p[0]; + ((struct T __attribute__((may_alias)) *) &s[2 * sizeof (short) - 1])->t = 2; + t[3 * sizeof (short) - 2] = 3; + test (a, q, 1); +} + +__attribute__((noipa)) void +baz (long long *p, char *q, char *r, char *s) +{ + char a[64] __attribute__((aligned (__alignof (short)))); + *(short __attribute__((may_alias)) *) &a[2 * sizeof (short)] = 2; + ((struct S __attribute__((may_alias)) *) &a[1])->s = p[0]; + *(short __attribute__((may_alias)) *) &a[sizeof (short)] = 1; + *(short __attribute__((may_alias)) *) &q[2 * sizeof (short)] = 2; + ((struct S __attribute__((may_alias)) *) &r[1])->s = p[0]; + *(short __attribute__((may_alias)) *) &s[sizeof (short)] = 1; + test (a, q, 2); +} + +__attribute__((noipa)) void +qux (long long *p, char *q, char *r, char *s, char *t) +{ + char a[64] __attribute__((aligned (__alignof (short)))); + *(short __attribute__((may_alias)) *) &a[2 * sizeof (short) - 1] = 2; + ((struct S __attribute__((may_alias)) *) &a[1])->s = p[0]; + a[3 * sizeof (short) - 2] = 3; + *(short __attribute__((may_alias)) *) &a[sizeof (short)] = 1; + ((struct T __attribute__((may_alias)) *) &q[2 * sizeof (short) - 1])->t = 2; + ((struct S __attribute__((may_alias)) *) &r[1])->s = p[0]; + s[3 * sizeof (short) - 2] = 3; + ((struct T __attribute__((may_alias)) *) &t[sizeof (short)])->t = 1; + test (a, q, 3); +} + +__attribute__((noipa)) void +corge (long long *p, char *q, char *r, char *s, short u[3]) +{ + char a[64] __attribute__((aligned (__alignof (short)))); + *(short __attribute__((may_alias)) *) &a[2 * sizeof (short)] = u[2]; + ((struct S __attribute__((may_alias)) *) &a[1])->s = p[0]; + *(short __attribute__((may_alias)) *) &a[sizeof (short)] = u[1]; + *(short __attribute__((may_alias)) *) &q[2 * sizeof (short)] = u[2]; + ((struct S __attribute__((may_alias)) *) &r[1])->s = p[0]; + *(short __attribute__((may_alias)) *) &s[sizeof (short)] = u[1]; + test (a, q, 4); +} + +__attribute__((noipa)) void +garply (long long *p, char *q, char *r, char *s, short u[3]) +{ + char a[64] __attribute__((aligned (__alignof (short)))); + *(short __attribute__((may_alias)) *) &a[sizeof (short)] = u[1]; + ((struct S __attribute__((may_alias)) *) &a[1])->s = p[0]; + *(short __attribute__((may_alias)) *) &a[2 * sizeof (short)] = u[2]; + *(short __attribute__((may_alias)) *) &s[sizeof (short)] = u[1]; + ((struct S __attribute__((may_alias)) *) &r[1])->s = p[0]; + *(short __attribute__((may_alias)) *) &q[2 * sizeof (short)] = u[2]; + test (a, q, 6); +} + +int +main () +{ + char a[64] __attribute__((aligned (__alignof (short)))); + long long p = -1LL; + short u[] = { 1, 2, 3 }; + foo (&p, &a[0], &a[0], &a[0]); + bar (&p, &a[0], &a[0], &a[0], &a[0]); + baz (&p, &a[0], &a[0], &a[0]); + qux (&p, &a[0], &a[0], &a[0], &a[0]); + corge (&p, &a[0], &a[0], &a[0], u); + garply (&p, &a[0], &a[0], &a[0], u); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_4.c b/SingleSource/Regression/C/gcc-dg/store_merging_4.c new file mode 100644 index 0000000000..719c2c038e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +/* Check that we can merge interleaving stores that are guaranteed + to be non-aliasing. */ + +struct bar +{ + int a; + char b; + char c; + short d; + char e; + char f; + char g; +}; + +void +foozero (struct bar *restrict p, struct bar *restrict p2) +{ + p->b = 0xff; + p2->b = 0xa; + p->a = 0xfffff; + p2->a = 0xab; + p2->c = 0xc; + p->c = 0xff; + p2->d = 0xbf; + p->d = 0xfff; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_5.c b/SingleSource/Regression/C/gcc-dg/store_merging_5.c new file mode 100644 index 0000000000..b0cb0da78e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_5.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +/* Make sure that non-aliasing non-constant interspersed stores do not + stop chains. */ + +struct bar { + int a; + char b; + char c; + char d; + char e; + char g; +}; + +void +foo1 (struct bar *p, char tmp) +{ + p->a = 0; + p->b = 0; + p->g = tmp; + p->c = 0; + p->d = 0; + p->e = 0; +} + + +/* { dg-final { scan-tree-dump-times "Merging successful" 1 "store-merging" } } + { dg-final { scan-tree-dump-times "MEM\\\[.*\\\]" 1 "store-merging" { target { ! store_merge } } } } + { dg-final { scan-tree-dump-times "MEM \\\[.*\\\]" 1 "store-merging" { target { store_merge && ilp32 } } } } + { dg-final { scan-tree-dump-times "MEM \\\[.*\\\]" 1 "store-merging" { target { store_merge && lp64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_6.c b/SingleSource/Regression/C/gcc-dg/store_merging_6.c new file mode 100644 index 0000000000..314829da6d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_6.c @@ -0,0 +1,53 @@ +/* { dg-do run } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +/* Check that we can widen accesses to bitfields. */ + +struct bar { + int a : 3; + unsigned char b : 4; + unsigned char c : 1; + char d; + char e; + char f; + char g; +}; + +__attribute__ ((noinline)) void +foozero (struct bar *p) +{ + p->b = 0; + p->a = 0; + p->c = 0; + p->d = 0; + p->e = 0; + p->f = 0; + p->g = 0; +} + +__attribute__ ((noinline)) void +foo1 (struct bar *p) +{ + p->b = 3; + p->a = 2; + p->c = 1; + p->d = 4; + p->e = 5; +} + +int +main (void) +{ + struct bar p; + foozero (&p); + foo1 (&p); + if (p.a != 2 || p.b != 3 || p.c != 1 || p.d != 4 || p.e != 5 + || p.f != 0 || p.g != 0) + __builtin_abort (); + + return 0; +} + + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_7.c b/SingleSource/Regression/C/gcc-dg/store_merging_7.c new file mode 100644 index 0000000000..dbe000a463 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_7.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +/* Check that we can merge consecutive array members through the pointer. + PR rtl-optimization/23684. */ + +void +foo (char *input) +{ + input = __builtin_assume_aligned (input, 8); + input[0] = 'H'; + input[1] = 'e'; + input[2] = 'l'; + input[3] = 'l'; + input[4] = 'o'; + input[5] = ' '; + input[6] = 'w'; + input[7] = 'o'; + input[8] = 'r'; + input[9] = 'l'; + input[10] = 'd'; + input[11] = '\0'; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 1 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_8.c b/SingleSource/Regression/C/gcc-dg/store_merging_8.c new file mode 100644 index 0000000000..d719e0a225 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_8.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */ + +struct baz { + struct bar { + int a; + char b; + char c; + char d; + char e; + char f; + char g; + } a[4]; +} x; +struct baz *xx = &x; + +void +foo1 (int i) +{ + x.a[i].b = 0; + x.a[i].a = 0; + x.a[i].c = 0; + x.a[i].d = 0; + x.a[i].e = 0; +} + +void +foo2 (int i) +{ + x.a[i].b = 0; + x.a[i].a = 0; + x.a[i].c = 1; + x.a[i].d = 0; + x.a[i].e = 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/store_merging_9.c b/SingleSource/Regression/C/gcc-dg/store_merging_9.c new file mode 100644 index 0000000000..4c9f21ef62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/store_merging_9.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/82434 */ +/* { dg-do compile } */ +/* { dg-require-effective-target store_merge } */ +/* { dg-options "-O2 -fdump-tree-store-merging" } */ + +enum E { E0, E1, E2 = __INT_MAX__, E3 = -__INT_MAX__ - 1 }; + +struct bar { + enum E a; + char b; + _Bool c; + short d; +}; + +void +foo1 (struct bar *p) +{ + p->b = 0; + p->a = E0; + p->c = (_Bool) 0; + p->d = 0; +} + +void +foo2 (struct bar *p) +{ + p->b = 0; + p->a = E0; + p->c = (_Bool) 1; + p->d = 0; +} + +/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmp-1.c b/SingleSource/Regression/C/gcc-dg/strcmp-1.c new file mode 100644 index 0000000000..c5b4db9fe3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmp-1.c @@ -0,0 +1,635 @@ +/* Test strcmp builtin expansion for compilation and proper execution. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target ptr32plus } */ + +#include +#include +#include + +#define RUN_TEST(SZ, ALIGN) test_strcmp_ ## SZ ## _ ## ALIGN () + +#define DEF_TEST(SZ, ALIGN) \ +static void test_strcmp_ ## SZ ## _ ## ALIGN (void) { \ + char one[3 * (SZ > 10 ? SZ : 10)]; \ + char two[3 * (SZ > 10 ? SZ : 10)]; \ + char three[8192] __attribute__ ((aligned (4096))); \ + char four[8192] __attribute__ ((aligned (4096))); \ + int i,j; \ + memset(one,0,sizeof(one)); \ + memset(two,0,sizeof(two)); \ + memset(three,0,sizeof(three)); \ + memset(four,0,sizeof(four)); \ + for (i = 0 ; i < SZ ; i++) \ + { \ + int r1; \ + char *a = one + (i & 1) * ALIGN; \ + char *b = two + (i & 1) * ALIGN; \ + memset(a, '-', SZ); \ + memset(b, '-', SZ); \ + a[i] = '1'; \ + b[i] = '2'; \ + a[SZ] = 0; \ + b[SZ] = 0; \ + if (!((r1 = strcmp (b, a)) > 0)) \ + abort (); \ + if (!((r1 = strcmp (a, b)) < 0)) \ + abort (); \ + b[i] = '1'; \ + if (!((r1 = strcmp (a, b)) == 0)) \ + abort (); \ + for(j = i; j < SZ ; j++) \ + { \ + a[j] = '1'; \ + b[j] = '2'; \ + } \ + if (!((r1 = strcmp (b, a)) > 0)) \ + abort (); \ + if (!((r1 = strcmp (a, b)) < 0)) \ + abort (); \ + for(j = 0; j < i ; j++) \ + { \ + memset(a, '-', SZ); \ + memset(b, '-', SZ); \ + a[j] = '\0'; \ + a[j+1] = '1'; \ + b[j] = '\0'; \ + b[j+1] = '2'; \ + if ((r1 = strcmp (b, a)) != 0) \ + abort (); \ + } \ + a = three + 4096 - (SZ / 2 + (i & 1) * ALIGN); \ + b = four + 4096 - (SZ / 2 + (i & 1) * ALIGN); \ + memset(a, '-', SZ); \ + memset(b, '-', SZ); \ + a[i] = '1'; \ + b[i] = '2'; \ + a[SZ] = 0; \ + b[SZ] = 0; \ + if (!((r1 = strcmp(b, a)) > 0)) \ + abort (); \ + if (!((r1 = strcmp(a, b)) < 0)) \ + abort (); \ + b[i] = '1'; \ + if (!((r1 = strcmp(a, b)) == 0)) \ + abort (); \ + } \ +} + +#ifdef TEST_ALL +DEF_TEST(1,1) +DEF_TEST(1,2) +DEF_TEST(1,4) +DEF_TEST(1,8) +DEF_TEST(1,16) +DEF_TEST(2,1) +DEF_TEST(2,2) +DEF_TEST(2,4) +DEF_TEST(2,8) +DEF_TEST(2,16) +DEF_TEST(3,1) +DEF_TEST(3,2) +DEF_TEST(3,4) +DEF_TEST(3,8) +DEF_TEST(3,16) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(4,8) +DEF_TEST(4,16) +DEF_TEST(5,1) +DEF_TEST(5,2) +DEF_TEST(5,4) +DEF_TEST(5,8) +DEF_TEST(5,16) +DEF_TEST(6,1) +DEF_TEST(6,2) +DEF_TEST(6,4) +DEF_TEST(6,8) +DEF_TEST(6,16) +DEF_TEST(7,1) +DEF_TEST(7,2) +DEF_TEST(7,4) +DEF_TEST(7,8) +DEF_TEST(7,16) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(8,16) +DEF_TEST(9,1) +DEF_TEST(9,2) +DEF_TEST(9,4) +DEF_TEST(9,8) +DEF_TEST(9,16) +DEF_TEST(10,1) +DEF_TEST(10,2) +DEF_TEST(10,4) +DEF_TEST(10,8) +DEF_TEST(10,16) +DEF_TEST(11,1) +DEF_TEST(11,2) +DEF_TEST(11,4) +DEF_TEST(11,8) +DEF_TEST(11,16) +DEF_TEST(12,1) +DEF_TEST(12,2) +DEF_TEST(12,4) +DEF_TEST(12,8) +DEF_TEST(12,16) +DEF_TEST(13,1) +DEF_TEST(13,2) +DEF_TEST(13,4) +DEF_TEST(13,8) +DEF_TEST(13,16) +DEF_TEST(14,1) +DEF_TEST(14,2) +DEF_TEST(14,4) +DEF_TEST(14,8) +DEF_TEST(14,16) +DEF_TEST(15,1) +DEF_TEST(15,2) +DEF_TEST(15,4) +DEF_TEST(15,8) +DEF_TEST(15,16) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(17,1) +DEF_TEST(17,2) +DEF_TEST(17,4) +DEF_TEST(17,8) +DEF_TEST(17,16) +DEF_TEST(18,1) +DEF_TEST(18,2) +DEF_TEST(18,4) +DEF_TEST(18,8) +DEF_TEST(18,16) +DEF_TEST(19,1) +DEF_TEST(19,2) +DEF_TEST(19,4) +DEF_TEST(19,8) +DEF_TEST(19,16) +DEF_TEST(20,1) +DEF_TEST(20,2) +DEF_TEST(20,4) +DEF_TEST(20,8) +DEF_TEST(20,16) +DEF_TEST(21,1) +DEF_TEST(21,2) +DEF_TEST(21,4) +DEF_TEST(21,8) +DEF_TEST(21,16) +DEF_TEST(22,1) +DEF_TEST(22,2) +DEF_TEST(22,4) +DEF_TEST(22,8) +DEF_TEST(22,16) +DEF_TEST(23,1) +DEF_TEST(23,2) +DEF_TEST(23,4) +DEF_TEST(23,8) +DEF_TEST(23,16) +DEF_TEST(24,1) +DEF_TEST(24,2) +DEF_TEST(24,4) +DEF_TEST(24,8) +DEF_TEST(24,16) +DEF_TEST(25,1) +DEF_TEST(25,2) +DEF_TEST(25,4) +DEF_TEST(25,8) +DEF_TEST(25,16) +DEF_TEST(26,1) +DEF_TEST(26,2) +DEF_TEST(26,4) +DEF_TEST(26,8) +DEF_TEST(26,16) +DEF_TEST(27,1) +DEF_TEST(27,2) +DEF_TEST(27,4) +DEF_TEST(27,8) +DEF_TEST(27,16) +DEF_TEST(28,1) +DEF_TEST(28,2) +DEF_TEST(28,4) +DEF_TEST(28,8) +DEF_TEST(28,16) +DEF_TEST(29,1) +DEF_TEST(29,2) +DEF_TEST(29,4) +DEF_TEST(29,8) +DEF_TEST(29,16) +DEF_TEST(30,1) +DEF_TEST(30,2) +DEF_TEST(30,4) +DEF_TEST(30,8) +DEF_TEST(30,16) +DEF_TEST(31,1) +DEF_TEST(31,2) +DEF_TEST(31,4) +DEF_TEST(31,8) +DEF_TEST(31,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +DEF_TEST(33,1) +DEF_TEST(33,2) +DEF_TEST(33,4) +DEF_TEST(33,8) +DEF_TEST(33,16) +DEF_TEST(34,1) +DEF_TEST(34,2) +DEF_TEST(34,4) +DEF_TEST(34,8) +DEF_TEST(34,16) +DEF_TEST(35,1) +DEF_TEST(35,2) +DEF_TEST(35,4) +DEF_TEST(35,8) +DEF_TEST(35,16) +DEF_TEST(36,1) +DEF_TEST(36,2) +DEF_TEST(36,4) +DEF_TEST(36,8) +DEF_TEST(36,16) +DEF_TEST(37,1) +DEF_TEST(37,2) +DEF_TEST(37,4) +DEF_TEST(37,8) +DEF_TEST(37,16) +DEF_TEST(38,1) +DEF_TEST(38,2) +DEF_TEST(38,4) +DEF_TEST(38,8) +DEF_TEST(38,16) +DEF_TEST(39,1) +DEF_TEST(39,2) +DEF_TEST(39,4) +DEF_TEST(39,8) +DEF_TEST(39,16) +DEF_TEST(40,1) +DEF_TEST(40,2) +DEF_TEST(40,4) +DEF_TEST(40,8) +DEF_TEST(40,16) +DEF_TEST(41,1) +DEF_TEST(41,2) +DEF_TEST(41,4) +DEF_TEST(41,8) +DEF_TEST(41,16) +DEF_TEST(42,1) +DEF_TEST(42,2) +DEF_TEST(42,4) +DEF_TEST(42,8) +DEF_TEST(42,16) +DEF_TEST(43,1) +DEF_TEST(43,2) +DEF_TEST(43,4) +DEF_TEST(43,8) +DEF_TEST(43,16) +DEF_TEST(44,1) +DEF_TEST(44,2) +DEF_TEST(44,4) +DEF_TEST(44,8) +DEF_TEST(44,16) +DEF_TEST(45,1) +DEF_TEST(45,2) +DEF_TEST(45,4) +DEF_TEST(45,8) +DEF_TEST(45,16) +DEF_TEST(46,1) +DEF_TEST(46,2) +DEF_TEST(46,4) +DEF_TEST(46,8) +DEF_TEST(46,16) +DEF_TEST(47,1) +DEF_TEST(47,2) +DEF_TEST(47,4) +DEF_TEST(47,8) +DEF_TEST(47,16) +DEF_TEST(48,1) +DEF_TEST(48,2) +DEF_TEST(48,4) +DEF_TEST(48,8) +DEF_TEST(48,16) +DEF_TEST(49,1) +DEF_TEST(49,2) +DEF_TEST(49,4) +DEF_TEST(49,8) +DEF_TEST(49,16) +DEF_TEST(100,1) +DEF_TEST(100,2) +DEF_TEST(100,4) +DEF_TEST(100,8) +DEF_TEST(100,16) +#else +DEF_TEST(3,1) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(5,1) +DEF_TEST(6,1) +DEF_TEST(7,1) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(9,1) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +DEF_TEST(100,1) +DEF_TEST(100,2) +DEF_TEST(100,4) +DEF_TEST(100,8) +DEF_TEST(100,16) +#endif + +int +main(int argc, char **argv) +{ + +#ifdef TEST_ALL + RUN_TEST(1,1); + RUN_TEST(1,2); + RUN_TEST(1,4); + RUN_TEST(1,8); + RUN_TEST(1,16); + RUN_TEST(2,1); + RUN_TEST(2,2); + RUN_TEST(2,4); + RUN_TEST(2,8); + RUN_TEST(2,16); + RUN_TEST(3,1); + RUN_TEST(3,2); + RUN_TEST(3,4); + RUN_TEST(3,8); + RUN_TEST(3,16); + RUN_TEST(4,1); + RUN_TEST(4,2); + RUN_TEST(4,4); + RUN_TEST(4,8); + RUN_TEST(4,16); + RUN_TEST(5,1); + RUN_TEST(5,2); + RUN_TEST(5,4); + RUN_TEST(5,8); + RUN_TEST(5,16); + RUN_TEST(6,1); + RUN_TEST(6,2); + RUN_TEST(6,4); + RUN_TEST(6,8); + RUN_TEST(6,16); + RUN_TEST(7,1); + RUN_TEST(7,2); + RUN_TEST(7,4); + RUN_TEST(7,8); + RUN_TEST(7,16); + RUN_TEST(8,1); + RUN_TEST(8,2); + RUN_TEST(8,4); + RUN_TEST(8,8); + RUN_TEST(8,16); + RUN_TEST(9,1); + RUN_TEST(9,2); + RUN_TEST(9,4); + RUN_TEST(9,8); + RUN_TEST(9,16); + RUN_TEST(10,1); + RUN_TEST(10,2); + RUN_TEST(10,4); + RUN_TEST(10,8); + RUN_TEST(10,16); + RUN_TEST(11,1); + RUN_TEST(11,2); + RUN_TEST(11,4); + RUN_TEST(11,8); + RUN_TEST(11,16); + RUN_TEST(12,1); + RUN_TEST(12,2); + RUN_TEST(12,4); + RUN_TEST(12,8); + RUN_TEST(12,16); + RUN_TEST(13,1); + RUN_TEST(13,2); + RUN_TEST(13,4); + RUN_TEST(13,8); + RUN_TEST(13,16); + RUN_TEST(14,1); + RUN_TEST(14,2); + RUN_TEST(14,4); + RUN_TEST(14,8); + RUN_TEST(14,16); + RUN_TEST(15,1); + RUN_TEST(15,2); + RUN_TEST(15,4); + RUN_TEST(15,8); + RUN_TEST(15,16); + RUN_TEST(16,1); + RUN_TEST(16,2); + RUN_TEST(16,4); + RUN_TEST(16,8); + RUN_TEST(16,16); + RUN_TEST(17,1); + RUN_TEST(17,2); + RUN_TEST(17,4); + RUN_TEST(17,8); + RUN_TEST(17,16); + RUN_TEST(18,1); + RUN_TEST(18,2); + RUN_TEST(18,4); + RUN_TEST(18,8); + RUN_TEST(18,16); + RUN_TEST(19,1); + RUN_TEST(19,2); + RUN_TEST(19,4); + RUN_TEST(19,8); + RUN_TEST(19,16); + RUN_TEST(20,1); + RUN_TEST(20,2); + RUN_TEST(20,4); + RUN_TEST(20,8); + RUN_TEST(20,16); + RUN_TEST(21,1); + RUN_TEST(21,2); + RUN_TEST(21,4); + RUN_TEST(21,8); + RUN_TEST(21,16); + RUN_TEST(22,1); + RUN_TEST(22,2); + RUN_TEST(22,4); + RUN_TEST(22,8); + RUN_TEST(22,16); + RUN_TEST(23,1); + RUN_TEST(23,2); + RUN_TEST(23,4); + RUN_TEST(23,8); + RUN_TEST(23,16); + RUN_TEST(24,1); + RUN_TEST(24,2); + RUN_TEST(24,4); + RUN_TEST(24,8); + RUN_TEST(24,16); + RUN_TEST(25,1); + RUN_TEST(25,2); + RUN_TEST(25,4); + RUN_TEST(25,8); + RUN_TEST(25,16); + RUN_TEST(26,1); + RUN_TEST(26,2); + RUN_TEST(26,4); + RUN_TEST(26,8); + RUN_TEST(26,16); + RUN_TEST(27,1); + RUN_TEST(27,2); + RUN_TEST(27,4); + RUN_TEST(27,8); + RUN_TEST(27,16); + RUN_TEST(28,1); + RUN_TEST(28,2); + RUN_TEST(28,4); + RUN_TEST(28,8); + RUN_TEST(28,16); + RUN_TEST(29,1); + RUN_TEST(29,2); + RUN_TEST(29,4); + RUN_TEST(29,8); + RUN_TEST(29,16); + RUN_TEST(30,1); + RUN_TEST(30,2); + RUN_TEST(30,4); + RUN_TEST(30,8); + RUN_TEST(30,16); + RUN_TEST(31,1); + RUN_TEST(31,2); + RUN_TEST(31,4); + RUN_TEST(31,8); + RUN_TEST(31,16); + RUN_TEST(32,1); + RUN_TEST(32,2); + RUN_TEST(32,4); + RUN_TEST(32,8); + RUN_TEST(32,16); + RUN_TEST(33,1); + RUN_TEST(33,2); + RUN_TEST(33,4); + RUN_TEST(33,8); + RUN_TEST(33,16); + RUN_TEST(34,1); + RUN_TEST(34,2); + RUN_TEST(34,4); + RUN_TEST(34,8); + RUN_TEST(34,16); + RUN_TEST(35,1); + RUN_TEST(35,2); + RUN_TEST(35,4); + RUN_TEST(35,8); + RUN_TEST(35,16); + RUN_TEST(36,1); + RUN_TEST(36,2); + RUN_TEST(36,4); + RUN_TEST(36,8); + RUN_TEST(36,16); + RUN_TEST(37,1); + RUN_TEST(37,2); + RUN_TEST(37,4); + RUN_TEST(37,8); + RUN_TEST(37,16); + RUN_TEST(38,1); + RUN_TEST(38,2); + RUN_TEST(38,4); + RUN_TEST(38,8); + RUN_TEST(38,16); + RUN_TEST(39,1); + RUN_TEST(39,2); + RUN_TEST(39,4); + RUN_TEST(39,8); + RUN_TEST(39,16); + RUN_TEST(40,1); + RUN_TEST(40,2); + RUN_TEST(40,4); + RUN_TEST(40,8); + RUN_TEST(40,16); + RUN_TEST(41,1); + RUN_TEST(41,2); + RUN_TEST(41,4); + RUN_TEST(41,8); + RUN_TEST(41,16); + RUN_TEST(42,1); + RUN_TEST(42,2); + RUN_TEST(42,4); + RUN_TEST(42,8); + RUN_TEST(42,16); + RUN_TEST(43,1); + RUN_TEST(43,2); + RUN_TEST(43,4); + RUN_TEST(43,8); + RUN_TEST(43,16); + RUN_TEST(44,1); + RUN_TEST(44,2); + RUN_TEST(44,4); + RUN_TEST(44,8); + RUN_TEST(44,16); + RUN_TEST(45,1); + RUN_TEST(45,2); + RUN_TEST(45,4); + RUN_TEST(45,8); + RUN_TEST(45,16); + RUN_TEST(46,1); + RUN_TEST(46,2); + RUN_TEST(46,4); + RUN_TEST(46,8); + RUN_TEST(46,16); + RUN_TEST(47,1); + RUN_TEST(47,2); + RUN_TEST(47,4); + RUN_TEST(47,8); + RUN_TEST(47,16); + RUN_TEST(48,1); + RUN_TEST(48,2); + RUN_TEST(48,4); + RUN_TEST(48,8); + RUN_TEST(48,16); + RUN_TEST(49,1); + RUN_TEST(49,2); + RUN_TEST(49,4); + RUN_TEST(49,8); + RUN_TEST(49,16); +#else + RUN_TEST(3,1); + RUN_TEST(4,1); + RUN_TEST(4,2); + RUN_TEST(4,4); + RUN_TEST(5,1); + RUN_TEST(6,1); + RUN_TEST(7,1); + RUN_TEST(8,1); + RUN_TEST(8,2); + RUN_TEST(8,4); + RUN_TEST(8,8); + RUN_TEST(9,1); + RUN_TEST(16,1); + RUN_TEST(16,2); + RUN_TEST(16,4); + RUN_TEST(16,8); + RUN_TEST(16,16); + RUN_TEST(32,1); + RUN_TEST(32,2); + RUN_TEST(32,4); + RUN_TEST(32,8); + RUN_TEST(32,16); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_1.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_1.c new file mode 100644 index 0000000000..b1e0bc3b27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_1.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-fdump-tree-lower" } */ + +#include +#include + +int cmp1 (char *p) +{ + return strncmp (p, "fis", 4); +} +int cmp2 (char *q) +{ + return strncmp ("fis", q, 4); +} + +int main () +{ + + char *p = "fish"; + char *q = "fis\0"; + + if (cmp1 (p) == 0 || cmp2 (q) != 0) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "strcmp \\(" 2 "lower" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_10.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_10.c new file mode 100644 index 0000000000..d7f94ac4d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_10.c @@ -0,0 +1,130 @@ +/* Verify that strncmp equalities aren't eliminated when the trailing array + type referenced by a member pointer is smaller than the string in cases + when the pointer pointed to by the enclosing object references an object + sufficiently large to store a string of equal length. + { dg-do compile } + { dg-options "-O2 -Wall -Wextra -Wno-stringop-overread -fdump-tree-optimized" } */ + +void init (void*); + +struct A1 { char i, a[1]; }; + +void f1_arr (void) +{ + char a[9]; + init (a); + + struct A1 *p = (struct A1*)a; + + if (__builtin_strncmp (p->a, "01234567", 8) == 0) + { + extern void array_test (void); + array_test (); + } +} + +void f1_ptr (void) +{ + void *p; + init (&p); + + struct A1 *q = (struct A1*)p; + + if (__builtin_strncmp (q->a, "0123456789", 10) == 0) + { + extern void pointer_test (void); + pointer_test (); + } +} + +void f1_struct (void) +{ + struct { char a[9]; } b; + init (&b); + + struct A1 *p = (struct A1*)&b; + + if (__builtin_strncmp (p->a, "01234567", 8) == 0) + { + extern void struct_test (void); + struct_test (); + } +} + +void f1_memptr (void) +{ + struct { void *p; } b; + init (&b); + + struct A1 *p = (struct A1*)b.p; + + if (__builtin_strncmp (p->a, "0123456789", 10) == 0) + { + extern void memptr_test (void); + memptr_test (); + } +} + + +struct A2 { char i, a[2]; }; + +void f2_arr (void) +{ + char a[8]; + init (a); + + struct A2 *p = (struct A2*)a; + + if (__builtin_strncmp (p->a, "0123456", 7) == 0) + { + extern void array_test (void); + array_test (); + } +} + +void f2_ptr (void) +{ + void *p; + init (&p); + + struct A2 *q = (struct A2*)p; + + if (__builtin_strncmp (q->a, "0123456789", 10) == 0) + { + extern void pointer_test (void); + pointer_test (); + } +} + +void f2_struct (void) +{ + struct { char a[8]; } b; + init (&b); + + struct A2 *p = (struct A2*)&b; + + if (__builtin_strncmp (p->a, "0123456", 7) == 0) + { + extern void struct_test (void); + struct_test (); + } +} + +void f2_memptr (void) +{ + struct { void *p; } b; + init (&b); + + struct A2 *p = (struct A2*)b.p; + + if (__builtin_strncmp (p->a, "0123456789", 10) == 0) + { + extern void memptr_test (void); + memptr_test (); + } +} + +/* { dg-final { scan-tree-dump-times "array_test" 2 "optimized" } } + { dg-final { scan-tree-dump-times "pointer_test" 2 "optimized" } } + { dg-final { scan-tree-dump-times "struct_test" 2 "optimized" } } + { dg-final { scan-tree-dump-times "memptr_test" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_11.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_11.c new file mode 100644 index 0000000000..945e083199 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_11.c @@ -0,0 +1,16 @@ +/* Verify that strcmp doesn't make assumptions about the size of a weak + symbol. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +/* An ordinary definition of A with more elements might be provided + in another translation unit. Even though that would be undefined + (the type of the actual definition must be the same as the type + of the weak declaration) this test verifies that GCC doesn't rely + on the size of this A for optimization (as a matter of QoI). */ +__attribute__ ((weak)) char a[3]; + +int cmp_a3_x (void) +{ + return __builtin_strcmp (a, "1234567") == 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_12.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_12.c new file mode 100644 index 0000000000..d8077b62f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_12.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/96758 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int v = 1; + +int +main () +{ + const char *s = v ? "a" : "b"; + char x[5]; + char y[5] = "a\0a"; + __builtin_memcpy (x, y, sizeof (y)); + if (__builtin_strncmp (x, s, 4) != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_2.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_2.c new file mode 100644 index 0000000000..f31761be17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_2.c @@ -0,0 +1,68 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +char s[100] = {'a','b','c','d'}; +typedef struct { char s[8]; int x; } S; + +__attribute__ ((noinline)) int +f1 (S *s) +{ + /* Member arrays not handled due to the fix for PR 92765. */ + return 0; // __builtin_strcmp (s->s, "abc") != 0; +} + +__attribute__ ((noinline)) int +f2 (void) +{ + return __builtin_strcmp (s, "abc") != 0; +} + +__attribute__ ((noinline)) int +f3 (S *s) +{ + return 0; // __builtin_strcmp ("abc", s->s) != 0; +} + +__attribute__ ((noinline)) int +f4 (void) +{ + return __builtin_strcmp ("abc", s) != 0; +} + +__attribute__ ((noinline)) int +f5 (S *s) +{ + return 0; // __builtin_strncmp (s->s, "abc", 3) != 0; +} + +__attribute__ ((noinline)) int +f6 (void) +{ + return __builtin_strncmp (s, "abc", 2) != 0; +} + +__attribute__ ((noinline)) int +f7 (S *s) +{ + return 0; // __builtin_strncmp ("abc", s->s, 3) != 0; +} + +__attribute__ ((noinline)) int +f8 (void) +{ + return __builtin_strncmp ("abc", s, 2) != 0; +} + +int main (void) +{ + S ss = {{'a','b','c'}, 2}; + + if (f1 (&ss) != 0 || f2 () != 1 || f3 (&ss) != 0 || + f4 () != 1 || f5 (&ss) != 0 || f6 () != 0 || + f7 (&ss) != 0 || f8 () != 0) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "cmp_eq \\(" 4 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_3.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_3.c new file mode 100644 index 0000000000..35941bee57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_3.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +__attribute__ ((noinline)) int +f1 (void) +{ + char *s0= "abcd"; + char s[8]; + __builtin_strcpy (s, s0); + return __builtin_strcmp (s, "abc") != 0; +} + +__attribute__ ((noinline)) int +f2 (void) +{ + char *s0 = "ab"; + char s[8]; + __builtin_strcpy (s, s0); + return __builtin_strcmp ("abc", s) != 0; +} + +int main (void) +{ + if (f1 () != 1 + || f2 () != 1) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "strcmp" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_4.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_4.c new file mode 100644 index 0000000000..b07fbb6b7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_4.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +typedef struct { char s[8]; int x; } S; + +extern int max_i; + +int f_param (S s) +{ + int result = 0; + for (int i = 0; i < max_i; i++) + result += __builtin_strcmp (s.s, "abc") != 0 ? 2 : 1; + return result; +} + + +S s; + +int f_object (void) +{ + int result = 0; + for (int i = 0; i < max_i; i++) + result += __builtin_strcmp (s.s, "abc") != 0 ? 2 : 1; + return result; +} + +/* { dg-final { scan-tree-dump-times "cmp_eq \\(" 2 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_5.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_5.c new file mode 100644 index 0000000000..d368277bfb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_5.c @@ -0,0 +1,80 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-rtl-expand" } */ + +typedef struct { char s[8]; int x; } S; +__attribute__ ((noinline)) int +f1 (S * s) +{ + int result = 0; + result += __builtin_strncmp (s->s, "ab", 2); + result += __builtin_strncmp (s->s, "abc", 3); + return result; +} + +__attribute__ ((noinline)) int +f2 (char *p) +{ + int result = 0; + result += __builtin_strncmp (p, "ab", 2); + result += __builtin_strncmp (p, "abc", 3); + return result; +} + +__attribute__ ((noinline)) int +f3 (S * s) +{ + int result = 0; + result += __builtin_strcmp (s->s, "a"); + result += __builtin_strcmp (s->s, "ab"); + return result; +} + +__attribute__ ((noinline)) int +f4 (char *p) +{ + int result = 0; + result += __builtin_strcmp (p, "a"); + result += __builtin_strcmp (p, "ab"); + return result; +} + +__attribute__ ((noinline)) int +f5 (S * s) +{ + int result = 0; + result += __builtin_memcmp (s->s, "ab", 2); + result += __builtin_memcmp (s->s, "abc", 3); + return result; +} + +__attribute__ ((noinline)) int +f6 (char *p) +{ + int result = 0; + result += __builtin_memcmp (p, "ab", 2); + result += __builtin_memcmp (p, "abc", 3); + return result; +} + +int main (void) +{ + S ss = {{'a','b','c'}, 2}; + char *s = "abcd"; + + if (f1 (&ss) != 0 || f2 (s) != 0) + __builtin_abort (); + + if (f3 (&ss) <= 0 || f4 (s) <= 0) + __builtin_abort (); + + if (f5 (&ss) != 0 || f6 (s) != 0) + __builtin_abort (); + + return 0; + +} + + +/* { dg-final { scan-rtl-dump-times "__builtin_strcmp" 0 "expand" } } */ +/* { dg-final { scan-rtl-dump-times "__builtin_strncmp" 0 "expand" } } */ +/* { dg-final { scan-rtl-dump-times "__builtin_memcmp" 0 "expand" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_6.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_6.c new file mode 100644 index 0000000000..06b7e3480d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_6.c @@ -0,0 +1,207 @@ +/* Verify that strcmp and strncmp calls with mixed constant and + non-constant strings are evaluated correctly. + { dg-do run } + { dg-options "-O2" } */ + +#include "strlenopt.h" + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + __builtin_abort ())) + +__attribute__ ((noclone, noinline)) int +test_strlen_gt2_strcmp_abcd (const char *s) +{ + if (strlen (s) < 3) + return -1; + + return strcmp (s, "abcd") == 0; +} + +__attribute__ ((noclone, noinline)) int +test_strlen_lt6_strcmp_abcd (const char *s) +{ + if (strlen (s) > 5) + return -1; + + return strcmp (s, "abcd") == 0; +} + +__attribute__ ((noclone, noinline)) int +test_strcpy_strcmp_abc (const char *s) +{ + char a[5]; + strcpy (a, s); + return strcmp (a, "abc") == 0; +} + +__attribute__ ((noclone, noinline)) int +test_strcpy_abc_strcmp (const char *s) +{ + char a[4], b[6]; + strcpy (a, "abc"); + strcpy (b, s); + return strcmp (a, b) == 0; +} + +/* Exercise strcmp of two strings between 1 and 3 characters long + stored in arrays of the same known size. */ +char ga4[4], gb4[4]; + +__attribute__ ((noclone, noinline)) int +test_store_0_nulterm_strcmp_same_size_arrays (void) +{ + ga4[0] = gb4[0] = 'x'; + ga4[3] = gb4[3] = '\0'; + return strcmp (ga4, gb4) == 0; +} + +__attribute__ ((noclone, noinline)) int +test_store_0_nulterm_strncmp_bound_2_same_size_arrays (void) +{ + ga4[0] = gb4[0] = 'x'; + ga4[3] = gb4[3] = '\0'; + return strncmp (ga4, gb4, 2) == 0; +} + +__attribute__ ((noclone, noinline)) int +test_store_0_nulterm_strncmp_bound_equal_same_size_arrays (void) +{ + ga4[0] = gb4[0] = 'x'; + ga4[3] = gb4[3] = '\0'; + return strncmp (ga4, gb4, 4) == 0; +} + +/* Exercise strcmp of two strings between 0 and 3 characters long + stored in arrays of the same known size. */ + +__attribute__ ((noclone, noinline)) int +test_nulterm_strcmp_same_size_arrays (void) +{ + ga4[3] = gb4[3] = '\0'; + return strcmp (ga4, gb4) == 0; +} + +/* Exercise strcmp of two strings between 1 and 3 and 1 and 4 characters + long, respectively, stored in arrays of known but different sizes. */ +char gc5[5]; + +__attribute__ ((noclone, noinline)) int +test_store_0_nulterm_strcmp_arrays (void) +{ + ga4[0] = gc5[0] = 'x'; + ga4[3] = gc5[4] = '\0'; + return strcmp (ga4, gc5) == 0; +} + +/* Exercise strcmp of two strings between 0 and 3 and 1 and 4 characters + long, respectively, stored in arrays of known but different sizes. */ + +__attribute__ ((noclone, noinline)) int +test_nulterm_strcmp_arrays (void) +{ + ga4[3] = gc5[4] = '\0'; + return strcmp (ga4, gc5) == 0; +} + + +__attribute__ ((noclone, noinline)) int +test_strcpy_strncmp_abcd (const char *s) +{ + char a[6]; + strcpy (a, s); + return strcmp (a, "abcd") == 0; +} + +__attribute__ ((noclone, noinline)) int +test_strcpy_abcd_strncmp_3 (const char *s) +{ + char a[6], b[8]; + strcpy (a, "abcd"); + strcpy (b, s); + return strncmp (a, b, 3) == 0; +} + +__attribute__ ((noclone, noinline)) int +test_strcpy_abcd_strncmp_4 (const char *s) +{ + char a[6], b[8]; + strcpy (a, "abcd"); + strcpy (b, s); + return strncmp (a, b, 4) == 0; +} + + +int main (void) +{ + test_strlen_gt2_strcmp_abcd ("abcd"); + test_strlen_lt6_strcmp_abcd ("abcd"); + + A (0 == test_strcpy_strcmp_abc ("ab")); + A (0 != test_strcpy_strcmp_abc ("abc")); + A (0 == test_strcpy_strcmp_abc ("abcd")); + + A (0 == test_strcpy_abc_strcmp ("ab")); + A (0 != test_strcpy_abc_strcmp ("abc")); + A (0 == test_strcpy_abc_strcmp ("abcd")); + + strcpy (ga4, "abc"); strcpy (gb4, "abd"); + A (0 == test_store_0_nulterm_strcmp_same_size_arrays ()); + strcpy (ga4, "abd"); strcpy (gb4, "abc"); + A (0 == test_store_0_nulterm_strcmp_same_size_arrays ()); + strcpy (ga4, "abc"); strcpy (gb4, "abc"); + A (0 != test_store_0_nulterm_strcmp_same_size_arrays ()); + + strcpy (ga4, "abc"); strcpy (gb4, "acd"); + A (0 == test_store_0_nulterm_strncmp_bound_2_same_size_arrays ()); + strcpy (ga4, "acd"); strcpy (gb4, "abc"); + A (0 == test_store_0_nulterm_strncmp_bound_2_same_size_arrays ()); + strcpy (ga4, "abc"); strcpy (gb4, "abc"); + A (0 != test_store_0_nulterm_strncmp_bound_2_same_size_arrays ()); + + strcpy (ga4, "abc"); strcpy (gb4, "abd"); + A (0 == test_store_0_nulterm_strncmp_bound_equal_same_size_arrays ()); + strcpy (ga4, "abd"); strcpy (gb4, "abc"); + A (0 == test_store_0_nulterm_strncmp_bound_equal_same_size_arrays ()); + strcpy (ga4, "abc"); strcpy (gb4, "abc"); + A (0 != test_store_0_nulterm_strncmp_bound_equal_same_size_arrays ()); + + strcpy (ga4, "abc"); strcpy (gb4, "abd"); + A (0 == test_nulterm_strcmp_same_size_arrays ()); + strcpy (ga4, "abd"); strcpy (gb4, "abc"); + A (0 == test_nulterm_strcmp_same_size_arrays ()); + strcpy (ga4, "abc"); strcpy (gb4, "abc"); + A (0 != test_nulterm_strcmp_same_size_arrays ()); + + strcpy (ga4, "abc"); strcpy (gc5, "abcd"); + A (0 == test_store_0_nulterm_strcmp_arrays ()); + strcpy (ga4, "abd"); strcpy (gc5, "abcd"); + A (0 == test_store_0_nulterm_strcmp_arrays ()); + strcpy (ga4, "abc"); strcpy (gc5, "abc"); + A (0 != test_store_0_nulterm_strcmp_arrays ()); + + strcpy (ga4, "abc"); strcpy (gc5, "abcd"); + A (0 == test_nulterm_strcmp_arrays ()); + strcpy (ga4, "abd"); strcpy (gc5, "abc"); + A (0 == test_nulterm_strcmp_arrays ()); + strcpy (ga4, "abc"); strcpy (gc5, "abc"); + A (0 != test_nulterm_strcmp_arrays ()); + + A (0 == test_strcpy_strncmp_abcd ("ab")); + A (0 == test_strcpy_strncmp_abcd ("abc")); + A (0 != test_strcpy_strncmp_abcd ("abcd")); + A (0 == test_strcpy_strncmp_abcd ("abcde")); + + A (0 == test_strcpy_abcd_strncmp_3 ("ab")); + A (0 != test_strcpy_abcd_strncmp_3 ("abc")); + A (0 != test_strcpy_abcd_strncmp_3 ("abcd")); + A (0 != test_strcpy_abcd_strncmp_3 ("abcde")); + + A (0 == test_strcpy_abcd_strncmp_4 ("ab")); + A (0 == test_strcpy_abcd_strncmp_4 ("abc")); + A (0 != test_strcpy_abcd_strncmp_4 ("abcd")); + A (0 != test_strcpy_abcd_strncmp_4 ("abcde")); +} diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_7.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_7.c new file mode 100644 index 0000000000..5e713170e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_7.c @@ -0,0 +1,119 @@ +/* PR tree-optimization/92501 - strncmp with constant unterminated arrays + not folded + { dg-do compile } + { dg-options "-O1 -Wall -fdump-tree-forwprop1" } */ + +/* Unterminated arrays of the size encoded in name. */ +const char a1[] = { '1' }; +const char a12[] = { '1', '2' }; +const char a112[] = { '1', '1', '2' }; +const char a123[] = { '1', '2', '3' }; + +/* Nul-terminated strings of the length encoded in name. */ +const char s[] = ""; +const char s1[] = "1"; +const char s12[] = "12"; +const char s112[] = "112"; +const char s123[] = "123"; + +extern void failure_on_line (int); + +/* Verify that the test in 'if (EQL strncmp (S, T, N))' is folded. */ +#define T(eql, s, t, n) do { \ + if (!(eql __builtin_strncmp (s, t, n))) \ + failure_on_line (__LINE__); \ + } while (0) + + +void test (void) +{ + /* Mixed array and string. */ + T (0 ==, a1, "", 0); + T (0 ==, a1, s, 0); + T (0 !=, a1, "", 1); + T (0 !=, a1, s, 1); + + /* The following two are safe to fold because while strncmp compares + at most N bytes it doesn't compare any bytes past the first nul. */ + T (0 !=, a1, "", 9); + T (0 !=, a1, s, 9); + + T (0 ==, a1, "1", 0); + T (0 ==, a1, s1, 0); + T (0 ==, a1, "1", 1); + T (0 ==, a1, s1, 1); + T (0 ==, a1, "12", 1); + T (0 ==, a1, s12, 1); + + /* As above, the following three are also safe to fold. */ + T (0 !=, a1, s12 + 1, 1); + T (0 !=, a1, s12 + 1, 2); + T (0 !=, a1, s12 + 1, 9); + + T (0 ==, a12, s, 0); + T (0 ==, a12, "", 0); + T (0 ==, a12, s1, 0); + T (0 ==, a12, "1", 0); + T (0 ==, a12, s1, 1); + T (0 ==, a12, "1", 1); + T (0 !=, a12, s1, 2); + T (0 !=, a12, "1", 2); + T (0 ==, a12, s12, 0); + T (0 ==, a12, "12", 0); + T (0 ==, a12, s12, 1); + T (0 ==, a12, "12", 1); + T (0 ==, a12, s12, 2); + T (0 ==, a12, "12", 2); + T (0 ==, a12, s123, 2); + T (0 ==, a12, "123", 2); + + T (0 ==, a12 + 0, s123 + 1, 0); + T (0 !=, a12 + 0, s123 + 1, 1); + T (0 !=, a12 + 0, s123 + 1, 2); + T (0 ==, a12 + 1, s123 + 0, 0); + T (0 !=, a12 + 1, s123 + 0, 1); + T (0 !=, a12 + 1, s123 + 0, 2); + T (0 ==, a12 + 1, s123 + 1, 1); + T (0 !=, a12 + 1, s123 + 2, 1); + T (0 !=, a12 + 1, s123 + 3, 1); + + T (0 ==, a12 + 1, "123" + 1, 1); + T (0 !=, a12 + 1, "123" + 2, 1); + T (0 !=, a12 + 1, "123" + 3, 1); + T (0 !=, a12 + 1, "123" + 3, 9); + + /* Both arguments arrays. */ + T (0 ==, a112 + 0, a1, 1); + T (0 ==, a112 + 1, a1, 1); + T (0 !=, a112 + 2, a1, 1); + + T (0 ==, a1, a112 + 0, 1); + T (0 ==, a1, a112 + 1, 1); + T (0 !=, a1, a112 + 2, 1); + + T (0 ==, a112 + 0, a12, 0); + T (0 ==, a112 + 0, a12, 1); + T (0 !=, a112 + 0, a12, 2); + + T (0 ==, a112 + 1, a12, 2); + T (0 !=, a112 + 1, a12 + 1, 1); + T (0 ==, a112 + 2, a12 + 1, 1); + + /* Mixed array and string. */ + T (0 ==, s112 + 0, a12, 0); + T (0 ==, s112 + 0, a12, 1); + T (0 !=, s112 + 0, a12, 2); + + T (0 ==, s112 + 1, a12, 0); + T (0 ==, s112 + 1, a12, 1); + T (0 ==, s112 + 1, a12, 2); + T (0 !=, s112 + 2, a12, 2); + + T (0 ==, a112 + 0, s1, 1); + T (0 ==, a112 + 1, s1, 1); + T (0 !=, a112 + 2, s1, 1); +} + +/* { dg-final { scan-tree-dump-not "strcmp" "forwprop1" } } + { dg-final { scan-tree-dump-not "strncmp" "forwprop1" } } + { dg-final { scan-tree-dump-not "failure_on_line_" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_8.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_8.c new file mode 100644 index 0000000000..a90c0d371b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_8.c @@ -0,0 +1,177 @@ +/* PR tree-optimization/92683 - strncmp incorrect result with equal substrings + and nonconst bound + { dg-do compile } + { dg-options "-O1 -Wall -fdump-tree-forwprop1" } */ + +#define SIZE_MAX __SIZE_MAX__ + +#define S123 "123" +#define S1234 "1234" + +typedef __SIZE_TYPE__ size_t; + +#ifndef ident +# define ident(n) n +#endif + +extern void failure_on_line (int); + +/* Verify that the test in 'if (EQL strncmp (S, T, N))' is folded. */ +#define T(eql, s, t, n) do { \ + max = ident (n); \ + if (!(eql __builtin_strncmp (s, t, max))) \ + failure_on_line (__LINE__); \ + } while (0) + +void test_literal (void) +{ + size_t max; + + T (0 ==, S123, S1234, 0); + T (0 ==, S123, S1234, 1); + T (0 ==, S123, S1234, 2); + T (0 ==, S123, S1234, 3); + T (0 >, S123, S1234, 4); + T (0 >, S123, S1234, 5); + T (0 >, S123, S1234, SIZE_MAX - 2); + T (0 >, S123, S1234, SIZE_MAX - 1); + T (0 >, S123, S1234, SIZE_MAX); + + T (0 ==, S123 + 1, S1234, 0); + T (0 <, S123 + 1, S1234, 1); + T (0 <, S123 + 1, S1234, 2); + T (0 <, S123 + 1, S1234, 3); + T (0 <, S123 + 1, S1234, 4); + T (0 <, S123 + 1, S1234, SIZE_MAX - 2); + T (0 <, S123 + 1, S1234, SIZE_MAX - 1); + T (0 <, S123 + 1, S1234, SIZE_MAX); + + T (0 ==, S123 + 1, S1234 + 1, 0); + T (0 ==, S123 + 1, S1234 + 1, 1); + T (0 ==, S123 + 1, S1234 + 1, 2); + T (0 >, S123 + 1, S1234 + 1, 3); + T (0 >, S123 + 1, S1234 + 1, SIZE_MAX - 1); + T (0 >, S123 + 1, S1234 + 1, SIZE_MAX); + + T (0 ==, S123 + 3, S1234 + 1, 0); + T (0 >, S123 + 3, S1234 + 1, 1); + T (0 >, S123 + 3, S1234 + 1, 2); + T (0 >, S123 + 3, S1234 + 1, 3); + T (0 >, S123 + 3, S1234 + 1, SIZE_MAX - 1); + T (0 >, S123 + 3, S1234 + 1, SIZE_MAX); + + int zero = 0; + + T (zero ==, S123, S1234, 0); + T (zero ==, S123, S1234, 1); + T (zero ==, S123, S1234, 2); + T (zero ==, S123, S1234, 3); + T (zero >, S123, S1234, 4); + T (zero >, S123, S1234, 5); + T (zero >, S123, S1234, SIZE_MAX - 2); + T (zero >, S123, S1234, SIZE_MAX - 1); + T (zero >, S123, S1234, SIZE_MAX); + + T (zero ==, S123 + 1, S1234, 0); + T (zero <, S123 + 1, S1234, 1); + T (zero <, S123 + 1, S1234, 2); + T (zero <, S123 + 1, S1234, 3); + T (zero <, S123 + 1, S1234, 4); + T (zero <, S123 + 1, S1234, SIZE_MAX - 2); + T (zero <, S123 + 1, S1234, SIZE_MAX - 1); + T (zero <, S123 + 1, S1234, SIZE_MAX); + + T (zero ==, S123 + 1, S1234 + 1, 0); + T (zero ==, S123 + 1, S1234 + 1, 1); + T (zero ==, S123 + 1, S1234 + 1, 2); + T (zero >, S123 + 1, S1234 + 1, 3); + T (zero >, S123 + 1, S1234 + 1, SIZE_MAX - 1); + T (zero >, S123 + 1, S1234 + 1, SIZE_MAX); + + T (zero ==, S123 + 3, S1234 + 1, 0); + T (zero >, S123 + 3, S1234 + 1, 1); + T (zero >, S123 + 3, S1234 + 1, 2); + T (zero >, S123 + 3, S1234 + 1, 3); + T (zero >, S123 + 3, S1234 + 1, SIZE_MAX - 1); + T (zero >, S123 + 3, S1234 + 1, SIZE_MAX); +} + +const char s123[] = S123; +const char s1234[] = S1234; + +void test_cst_array (void) +{ + size_t max; + + T (0 ==, s123, s1234, 0); + T (0 ==, s123, s1234, 1); + T (0 ==, s123, s1234, 2); + T (0 ==, s123, s1234, 3); + T (0 >, s123, s1234, 4); + T (0 >, s123, s1234, 5); + T (0 >, s123, s1234, SIZE_MAX - 2); + T (0 >, s123, s1234, SIZE_MAX - 1); + T (0 >, s123, s1234, SIZE_MAX); + + T (0 ==, s123 + 1, s1234, 0); + T (0 <, s123 + 1, s1234, 1); + T (0 <, s123 + 1, s1234, 2); + T (0 <, s123 + 1, s1234, 3); + T (0 <, s123 + 1, s1234, 4); + T (0 <, s123 + 1, s1234, SIZE_MAX - 2); + T (0 <, s123 + 1, s1234, SIZE_MAX - 1); + T (0 <, s123 + 1, s1234, SIZE_MAX); + + T (0 ==, s123 + 1, s1234 + 1, 0); + T (0 ==, s123 + 1, s1234 + 1, 1); + T (0 ==, s123 + 1, s1234 + 1, 2); + T (0 >, s123 + 1, s1234 + 1, 3); + T (0 >, s123 + 1, s1234 + 1, SIZE_MAX - 1); + T (0 >, s123 + 1, s1234 + 1, SIZE_MAX); + + T (0 ==, s123 + 3, s1234 + 1, 0); + T (0 >, s123 + 3, s1234 + 1, 1); + T (0 >, s123 + 3, s1234 + 1, 2); + T (0 >, s123 + 3, s1234 + 1, 3); + T (0 >, s123 + 3, s1234 + 1, SIZE_MAX - 1); + T (0 >, s123 + 3, s1234 + 1, SIZE_MAX); + + int zero = 0; + + T (zero ==, s123, s1234, 0); + T (zero ==, s123, s1234, 1); + T (zero ==, s123, s1234, 2); + T (zero ==, s123, s1234, 3); + T (zero >, s123, s1234, 4); + T (zero >, s123, s1234, 5); + T (zero >, s123, s1234, SIZE_MAX - 2); + T (zero >, s123, s1234, SIZE_MAX - 1); + T (zero >, s123, s1234, SIZE_MAX); + + T (zero ==, s123 + 1, s1234, 0); + T (zero <, s123 + 1, s1234, 1); + T (zero <, s123 + 1, s1234, 2); + T (zero <, s123 + 1, s1234, 3); + T (zero <, s123 + 1, s1234, 4); + T (zero <, s123 + 1, s1234, SIZE_MAX - 2); + T (zero <, s123 + 1, s1234, SIZE_MAX - 1); + T (zero <, s123 + 1, s1234, SIZE_MAX); + + T (zero ==, s123 + 1, s1234 + 1, 0); + T (zero ==, s123 + 1, s1234 + 1, 1); + T (zero ==, s123 + 1, s1234 + 1, 2); + T (zero >, s123 + 1, s1234 + 1, 3); + T (zero >, s123 + 1, s1234 + 1, SIZE_MAX - 1); + T (zero >, s123 + 1, s1234 + 1, SIZE_MAX); + + T (zero ==, s123 + 3, s1234 + 1, 0); + T (zero >, s123 + 3, s1234 + 1, 1); + T (zero >, s123 + 3, s1234 + 1, 2); + T (zero >, s123 + 3, s1234 + 1, 3); + T (zero >, s123 + 3, s1234 + 1, SIZE_MAX - 1); + T (zero >, s123 + 3, s1234 + 1, SIZE_MAX); +} + +/* { dg-final { scan-tree-dump-not "strcmp" "forwprop1" } } + { dg-final { scan-tree-dump-not "strncmp" "forwprop1" } } + { dg-final { scan-tree-dump-not "failure_on_line_" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strcmpopt_9.c b/SingleSource/Regression/C/gcc-dg/strcmpopt_9.c new file mode 100644 index 0000000000..15f6b63d19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strcmpopt_9.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/92683 - strncmp incorrect result with equal substrings + and nonconst bound + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define ident(n) ident (n) + +__attribute__ ((noclone, noinline, noipa)) size_t +ident (size_t x) +{ + return x; +} + +int nfails; + +__attribute__ ((noclone, noinline, noipa)) void +failure_on_line (int line) +{ + __builtin_printf ("failure on line %i\n", line); + ++nfails; +} + +#include "strcmpopt_8.c" + +int main (void) +{ + test_literal (); + test_cst_array (); + + if (nfails) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strict-flex-array-1.c b/SingleSource/Regression/C/gcc-dg/strict-flex-array-1.c new file mode 100644 index 0000000000..5b8a79363b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-flex-array-1.c @@ -0,0 +1,33 @@ +/* testing the correct usage of attribute strict_flex_array. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + + +int x __attribute__ ((strict_flex_array (1))); /* { dg-error "'strict_flex_array' attribute may not be specified for 'x'" } */ + +int [[gnu::strict_flex_array(1)]] x; /* { dg-warning "'strict_flex_array' attribute does not apply to types" } */ + +struct trailing { + int a; + int c __attribute ((strict_flex_array)); /* { dg-error "wrong number of arguments specified for 'strict_flex_array' attribute" } */ +}; + +struct trailing_1 { + int a; + int b; + int c __attribute ((strict_flex_array (2))); /* { dg-error "'strict_flex_array' attribute may not be specified for a non-array field" } */ +}; + +extern int d; + +struct trailing_array_2 { + int a; + int b; + int c[1] __attribute ((strict_flex_array (d))); /* { dg-error "'strict_flex_array' attribute argument not an integer" } */ +}; + +struct trailing_array_3 { + int a; + int b; + int c[0] __attribute ((strict_flex_array (5))); /* { dg-error "'strict_flex_array' attribute argument '5' is not an integer constant between 0 and 3" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/strict-flex-array-2.c b/SingleSource/Regression/C/gcc-dg/strict-flex-array-2.c new file mode 100644 index 0000000000..2b80c2365f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-flex-array-2.c @@ -0,0 +1,60 @@ +/* test the combination of attribute strict_flex_array and option + -fstrict-flex-arrays: when both attribute and option specified, + attribute will have higher priority. */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstrict-flex-arrays=3" } */ + +#include + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + printf("ok: %s == %zd\n", #p, p); \ + else \ + { \ + printf("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + __builtin_abort (); \ + } \ +} while (0); + +struct trailing_array_1 { + int a; + int b; + int c[4] __attribute__ ((strict_flex_array (0))); +}; + +struct trailing_array_2 { + int a; + int b; + int c[1] __attribute__ ((strict_flex_array (1))); +}; + +struct trailing_array_3 { + int a; + int b; + int c[0] __attribute__ ((strict_flex_array (2))); +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + expect(__builtin_object_size(normal->c, 1), -1); + expect(__builtin_object_size(trailing_1->c, 1), -1); + expect(__builtin_object_size(trailing_0->c, 1), -1); + expect(__builtin_object_size(trailing_flex->c, 1), -1); +} + +int main(int argc, char *argv[]) +{ + stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strict-flex-array-3.c b/SingleSource/Regression/C/gcc-dg/strict-flex-array-3.c new file mode 100644 index 0000000000..f74ed96c75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-flex-array-3.c @@ -0,0 +1,60 @@ +/* test the combination of attribute strict_flex_array and option + -fstrict-flex-arrays: when both attribute and option specified, + attribute will have higher priority. */ +/* { dg-do run } */ +/* { dg-options "-O2 -fstrict-flex-arrays=0" } */ + +#include "builtin-object-size-common.h" + +#define expect(p, _v) do { \ + size_t v = _v; \ + if (p == v) \ + __builtin_printf ("ok: %s == %zd\n", #p, p); \ + else \ + { \ + __builtin_printf ("WAT: %s == %zd (expected %zd)\n", #p, p, v); \ + FAIL (); \ + } \ +} while (0); + +struct trailing_array_1 { + int a; + int b; + int c[4] __attribute__ ((strict_flex_array (1))); +}; + +struct trailing_array_2 { + int a; + int b; + int c[1] __attribute__ ((strict_flex_array (2))); +}; + +struct trailing_array_3 { + int a; + int b; + int c[0] __attribute__ ((strict_flex_array (3))); +}; +struct trailing_array_4 { + int a; + int b; + int c[]; +}; + +void __attribute__((__noinline__)) stuff( + struct trailing_array_1 *normal, + struct trailing_array_2 *trailing_1, + struct trailing_array_3 *trailing_0, + struct trailing_array_4 *trailing_flex) +{ + expect(__builtin_object_size(normal->c, 1), 16); + expect(__builtin_object_size(trailing_1->c, 1), 4); + expect(__builtin_object_size(trailing_0->c, 1), 0); + expect(__builtin_object_size(trailing_flex->c, 1), -1); +} + +int main(int argc, char *argv[]) +{ + stuff((void *)argv[0], (void *)argv[0], (void *)argv[0], (void *)argv[0]); + + DONE (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strict-overflow-1.c b/SingleSource/Regression/C/gcc-dg/strict-overflow-1.c new file mode 100644 index 0000000000..184502f01c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-overflow-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-1.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i) +{ + return i - 5 < 10; +} + +/* { dg-final { scan-tree-dump-not "-\[ \]*5" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strict-overflow-2.c b/SingleSource/Regression/C/gcc-dg/strict-overflow-2.c new file mode 100644 index 0000000000..f23c43aa89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-overflow-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-2.c. */ + +/* We can only simplify the division when using strict overflow + semantics. */ + +int +foo (int i) +{ + return (i * 100) / 10; +} + +/* { dg-final { scan-tree-dump-not "\\\* 100" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strict-overflow-3.c b/SingleSource/Regression/C/gcc-dg/strict-overflow-3.c new file mode 100644 index 0000000000..8ef9147620 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-overflow-3.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-3.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i, int j) +{ + return i + 100 < j + 1234; +} + +/* { dg-final { scan-tree-dump-not "1234" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strict-overflow-4.c b/SingleSource/Regression/C/gcc-dg/strict-overflow-4.c new file mode 100644 index 0000000000..7200e0b780 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-overflow-4.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-4.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (int i) +{ + return i + 1 > i; +} + +/* { dg-final { scan-tree-dump "return 1;" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strict-overflow-5.c b/SingleSource/Regression/C/gcc-dg/strict-overflow-5.c new file mode 100644 index 0000000000..9085f1532b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-overflow-5.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -fdump-tree-optimized" } */ + +/* We can only unroll when using strict overflow semantics. */ + +int foo (int i) +{ + int index; + int r=0; + + for (index = i; index <= i+4; index+=2) + r++; + + return r; +} + +/* { dg-final { scan-tree-dump "return 3" "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/strict-overflow-6.c b/SingleSource/Regression/C/gcc-dg/strict-overflow-6.c new file mode 100644 index 0000000000..971c72ea1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strict-overflow-6.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -fdump-tree-optimized" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-7.c. */ + +/* We can only simplify the conditional when using strict overflow + semantics. */ + +int +foo (char* p) +{ + return p + 1000 < p; +} + +/* { dg-final { scan-tree-dump-not "\[+\]\[ \]*1000" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/string-opt-1.c b/SingleSource/Regression/C/gcc-dg/string-opt-1.c new file mode 100644 index 0000000000..7945ef39c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/string-opt-1.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +char *buffer; +char *test; + +#define SIZE 100 + +char * +__attribute__((noinline)) +my_memcpy (char *d, char *s, unsigned l) +{ + return __builtin_memcpy (d, s, l); +} + +char * +__attribute__((noinline)) +my_mempcpy (char *d, char *s, unsigned l) +{ + return __builtin_mempcpy (d, s, l); +} + +void +run_test (char *d, char *s, unsigned l) +{ + char *r = my_mempcpy (d, s, l); + if (r != d + l) + __builtin_abort (); + + r = my_memcpy (d, s, l); + if (r != d) + __builtin_abort (); +} + +int +main (void) +{ + const char* const foo = "hello world"; + unsigned l = __builtin_strlen (foo) + 1; + + buffer = __builtin_malloc (SIZE); + __builtin_memcpy (buffer, foo, l); + test = __builtin_malloc (SIZE); + + run_test (test, buffer, l); + + return 0; +} + +/* { dg-final { scan-assembler "mempcpy" } } */ +/* { dg-final { scan-assembler "memcpy" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-1.c b/SingleSource/Regression/C/gcc-dg/strlenopt-1.c new file mode 100644 index 0000000000..24772c1449 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-1.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +foo (char *p, char *r) +{ + char *q = malloc (strlen (p) + strlen (r) + 64); + if (q == NULL) return NULL; + /* This strcpy can be optimized into memcpy, using the remembered + strlen (p). */ + strcpy (q, p); + /* These two strcat can be optimized into memcpy. The first one + could be even optimized into a *ptr = '/'; store as the '\0' + is immediately overwritten. */ + strcat (q, "/"); + strcat (q, "abcde"); + /* This can also be optimized into memcpy. */ + strcat (q, r); + return q; +} + +int +main () +{ + char *volatile p = "string1"; + char *volatile r = "string2"; + char *q = foo (p, r); + if (q != NULL) + { + if (strcmp (q, "string1/abcdestring2")) + abort (); + free (q); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-10.c b/SingleSource/Regression/C/gcc-dg/strlenopt-10.c new file mode 100644 index 0000000000..6e2c2597b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-10.c @@ -0,0 +1,82 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) size_t +fn1 (char *p) +{ + char *q; + /* This can be optimized into memcpy and the size can be decreased to one, + as it is immediately overwritten. */ + strcpy (p, "z"); + q = strchr (p, '\0'); + *q = 32; + /* This strlen can't be optimized away, string length is unknown here. */ + return strlen (p); +} + +__attribute__((noinline, noclone)) void +fn2 (char *p, const char *z, size_t *lp) +{ + char *q, *r; + char buf[64]; + size_t l[10]; + /* The first strlen stays, all the strcpy calls can be optimized + into memcpy and all other strlen calls and all strchr calls + optimized away. */ + l[0] = strlen (z); + strcpy (buf, z); + strcpy (p, "abcde"); + q = strchr (p, '\0'); + strcpy (q, "efghi"); + r = strchr (q, '\0'); + strcpy (r, "jkl"); + l[1] = strlen (p); + l[2] = strlen (q); + l[3] = strlen (r); + strcpy (r, buf); + l[4] = strlen (p); + l[5] = strlen (q); + l[6] = strlen (r); + strcpy (r, "mnopqr"); + l[7] = strlen (p); + l[8] = strlen (q); + l[9] = strlen (r); + memcpy (lp, l, sizeof l); +} + +int +main () +{ + char buf[64]; + size_t l[10]; + const char *volatile z = "ABCDEFG"; + memset (buf, '\0', sizeof buf); + if (fn1 (buf) != 2 || buf[0] != 'z' || buf[1] != 32 || buf[2] != '\0') + abort (); + fn2 (buf, z, l); + if (memcmp (buf, "abcdeefghimnopqr", 17) != 0) + abort (); + if (l[0] != 7) + abort (); + if (l[1] != 13 || l[2] != 8 || l[3] != 3) + abort (); + if (l[4] != 17 || l[5] != 12 || l[6] != 7) + abort (); + if (l[7] != 16 || l[8] != 11 || l[9] != 6) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op + to expand the memcpy call at the end of fn2. */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 8 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { no_alignment_constraints} } } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "\\*q_\[0-9\]* = 32;" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(\[^\n\r\]*, 1\\)" 1 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-11.c b/SingleSource/Regression/C/gcc-dg/strlenopt-11.c new file mode 100644 index 0000000000..952de0730f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-11.c @@ -0,0 +1,75 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) void +fn1 (char *p, const char *z, size_t *lp) +{ + char *q, *r, *s; + char buf[64]; + size_t l[11]; + /* The first strlen stays, all the strcpy calls can be optimized + into memcpy and most other strlen calls and all strchr calls + optimized away. l[6] = strlen (r); and l[9] = strlen (r); need + to stay, because we need to invalidate the knowledge about + r strlen after strcpy (q, "jklmnopqrst"). */ + l[0] = strlen (z); + strcpy (buf, z); + strcpy (p, "abcde"); + q = strchr (p, '\0'); + strcpy (q, "efghi"); + r = strchr (q, '\0'); + strcpy (r, buf); + l[1] = strlen (p); + l[2] = strlen (q); + l[3] = strlen (r); + strcpy (q, "jklmnopqrst"); + l[4] = strlen (p); + l[5] = strlen (q); + l[6] = strlen (r); + s = strchr (q, '\0'); + strcpy (s, buf); + l[7] = strlen (p); + l[8] = strlen (q); + l[9] = strlen (r); + l[10] = strlen (s); + memcpy (lp, l, sizeof l); +} + +int +main () +{ + char buf[64]; + size_t l[11]; + const char *volatile z = "ABCDEFG"; + memset (buf, '\0', sizeof buf); + fn1 (buf, z, l); + if (memcmp (buf, "abcdejklmnopqrstABCDEFG", 24) != 0) + abort (); + if (l[0] != 7) + abort (); + if (l[1] != 17 || l[2] != 12 || l[3] != 7) + abort (); + if (l[4] != 16 || l[5] != 11 || l[6] != 6) + abort (); + if (l[7] != 23 || l[8] != 18 || l[9] != 13 || l[10] != 7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen1" } } */ +/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op + to expand the memcpy call at the end of fn1. */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ +/* Where the memcpy is expanded, the assignemts to elements of l are + propagated. */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.0. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.6. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.9. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;" 3 "strlen1" { target { no_alignment_constraints } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-12.c b/SingleSource/Regression/C/gcc-dg/strlenopt-12.c new file mode 100644 index 0000000000..1005fc6709 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-12.c @@ -0,0 +1,90 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +fn1 (char *p, size_t *l) +{ + char *q = strcat (p, "abcde"); + *l = strlen (p); + return q; +} + +__attribute__((noinline, noclone)) char * +fn2 (char *p, const char *q, size_t *l1, size_t *l2) +{ + size_t l = strlen (q); + char *r = strcat (p, q); + *l1 = l; + *l2 = strlen (p); + return r; +} + +__attribute__((noinline, noclone)) char * +fn3 (char *p, const char *q, size_t *l) +{ + char *r = strcpy (p, q); + *l = strlen (p); + return r; +} + +__attribute__((noinline, noclone)) char * +fn4 (char *p, const char *q, size_t *l) +{ + char *r = strcat (p, q); + *l = strlen (p); + return r; +} + +__attribute__((noinline, noclone)) char * +fn5 (char *p, const char *q, size_t *l1, size_t *l2, size_t *l3) +{ + size_t l = strlen (q); + size_t ll = strlen (p); + char *r = strcat (p, q); + *l1 = l; + *l2 = strlen (p); + *l3 = ll; + return r; +} + +__attribute__((noinline, noclone)) char * +fn6 (char *p, const char *q, size_t *l1, size_t *l2) +{ + size_t l = strlen (p); + char *r = strcat (p, q); + *l1 = strlen (p); + *l2 = l; + return r; +} + +int +main () +{ + char buf[64]; + const char *volatile q = "fgh"; + size_t l, l1, l2, l3; + memset (buf, '\0', sizeof buf); + memset (buf, 'a', 3); + if (fn1 (buf, &l) != buf || l != 8 || memcmp (buf, "aaaabcde", 9) != 0) + abort (); + if (fn2 (buf, q, &l1, &l2) != buf || l1 != 3 || l2 != 11 + || memcmp (buf, "aaaabcdefgh", 12) != 0) + abort (); + if (fn3 (buf, q, &l) != buf || l != 3 + || memcmp (buf, "fgh\0bcdefgh", 12) != 0) + abort (); + if (fn4 (buf, q, &l) != buf || l != 6 + || memcmp (buf, "fghfgh\0efgh", 12) != 0) + abort (); + l1 = 0; + l2 = 0; + if (fn5 (buf, q, &l1, &l2, &l3) != buf || l1 != 3 || l2 != 9 || l3 != 6 + || memcmp (buf, "fghfghfgh\0h", 12) != 0) + abort (); + if (fn6 (buf, q, &l1, &l2) != buf || l1 != 12 || l2 != 9 + || memcmp (buf, "fghfghfghfgh", 13) != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-12g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-12g.c new file mode 100644 index 0000000000..fb0eeb2e82 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-12g.c @@ -0,0 +1,6 @@ +/* This test needs runtime that provides stpcpy function. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2" } */ + +#define USE_GNU +#include "strlenopt-12.c" diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-13.c b/SingleSource/Regression/C/gcc-dg/strlenopt-13.c new file mode 100644 index 0000000000..4c6d526678 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-13.c @@ -0,0 +1,73 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) void +fn1 (char *p, const char *y, const char *z, size_t *lp) +{ + char *q, *r, *s; + char buf1[64], buf2[64]; + size_t l[8]; + /* These two strlen calls stay, all strcpy calls are optimized into + memcpy, all strchr calls optimized away, and most other strlen + calls too. */ + l[0] = strlen (y); + l[1] = strlen (z); + strcpy (buf1, y); + strcpy (buf2, z); + strcpy (p, "abcde"); + q = strchr (p, '\0'); + strcpy (q, "efghi"); + r = strchr (q, '\0'); + strcpy (r, buf1); + l[2] = strlen (p); + l[3] = strlen (q); + l[4] = strlen (r); + strcpy (r, buf2); + /* Except for these two calls, strlen (r) before and after the above + is non-constant, so adding l[4] - l[1] to all previous strlens + might make the expressions already too complex. */ + l[5] = strlen (p); + l[6] = strlen (q); + /* This one is of course optimized, it is l[1]. */ + l[7] = strlen (r); + memcpy (lp, l, sizeof l); +} + +int +main () +{ + char buf[64]; + size_t l[8]; + const char *volatile y = "ABCDEFG"; + const char *volatile z = "HIJK"; + memset (buf, '\0', sizeof buf); + fn1 (buf, y, z, l); + if (memcmp (buf, "abcdeefghiHIJK", 15) != 0) + abort (); + if (l[0] != 7 || l[1] != 4) + abort (); + if (l[2] != 17 || l[3] != 12 || l[4] != 7) + abort (); + if (l[5] != 14 || l[6] != 9 || l[7] != 4) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 4 "strlen1" } } */ +/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op + to expand the memcpy call at the end of fn1. */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ +/* Where the memcpy is expanded, the assignemts to elements of l are + propagated. */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.0. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.1. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.5. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]* l.6. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */ +/* { dg-final { scan-tree-dump-times " _\[0-9\]* = strlen \\(\[^\n\r\]*;" 4 "strlen1" { target { no_alignment_constraints } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-14g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-14g.c new file mode 100644 index 0000000000..81ddcc2d40 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-14g.c @@ -0,0 +1,116 @@ +/* This test needs runtime that provides stpcpy and mempcpy functions. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ +/* Bionic targets don't have mempcpy */ +/* { dg-require-effective-target non_bionic } */ + +#define USE_GNU +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +fn1 (char *p, size_t *l1, size_t *l2) +{ + char *a = mempcpy (p, "abcde", 6); + /* This strlen needs to stay. */ + size_t la = strlen (a); + /* This strlen can be optimized into 5. */ + size_t lp = strlen (p); + *l1 = la; + *l2 = lp; + return a; +} + +__attribute__((noinline, noclone)) char * +fn2 (char *p, const char *q, size_t *l1, size_t *l2, size_t *l3) +{ + /* This strlen needs to stay. */ + size_t lq = strlen (q); + char *a = mempcpy (p, q, lq + 1); + /* This strlen needs to stay. */ + size_t la = strlen (a); + /* This strlen can be optimized into lq. */ + size_t lp = strlen (p); + *l1 = lq; + *l2 = la; + *l3 = lp; + return a; +} + +__attribute__((noinline, noclone)) char * +fn3 (char *p, size_t *l1, size_t *l2) +{ + char *a = stpcpy (p, "abcde"); + /* This strlen can be optimized into 0. */ + size_t la = strlen (a); + /* This strlen can be optimized into 5. */ + size_t lp = strlen (p); + *l1 = la; + *l2 = lp; + return a; +} + +__attribute__((noinline, noclone)) char * +fn4 (char *p, const char *q, size_t *l1, size_t *l2, size_t *l3) +{ + /* This strlen needs to stay. */ + size_t lq = strlen (q); + char *a = stpcpy (p, q); + /* This strlen can be optimized into 0. */ + size_t la = strlen (a); + /* This strlen can be optimized into lq. */ + size_t lp = strlen (p); + *l1 = lq; + *l2 = la; + *l3 = lp; + return a; +} + +__attribute__((noinline, noclone)) char * +fn5 (char *p, const char *q, size_t *l1, size_t *l2) +{ + char *a = stpcpy (p, q); + /* This strlen can be optimized into 0. */ + size_t la = strlen (a); + /* This strlen can be optimized into a - p. */ + size_t lp = strlen (p); + *l1 = la; + *l2 = lp; + return a; +} + +int +main () +{ + char buf[64]; + const char *volatile q = "ABCDEFGH"; + size_t l1, l2, l3; + memset (buf, '\0', sizeof buf); + memset (buf + 6, 'z', 7); + if (fn1 (buf, &l1, &l2) != buf + 6 || l1 != 7 || l2 != 5 + || memcmp (buf, "abcde\0zzzzzzz", 14) != 0) + abort (); + if (fn2 (buf, q, &l1, &l2, &l3) != buf + 9 || l1 != 8 || l2 != 4 || l3 != 8 + || memcmp (buf, "ABCDEFGH\0zzzz", 14) != 0) + abort (); + if (fn3 (buf, &l1, &l2) != buf + 5 || l1 != 0 || l2 != 5 + || memcmp (buf, "abcde\0GH\0zzzz", 14) != 0) + abort (); + l3 = 0; + memset (buf, 'n', 9); + if (fn4 (buf, q, &l1, &l2, &l3) != buf + 8 || l1 != 8 || l2 != 0 || l3 != 8 + || memcmp (buf, "ABCDEFGH\0zzzz", 14) != 0) + abort (); + memset (buf, 'm', 9); + if (fn5 (buf, q, &l1, &l2) != buf + 8 || l1 != 0 || l2 != 8 + || memcmp (buf, "ABCDEFGH\0zzzz", 14) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "mempcpy \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 2 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-14gf.c b/SingleSource/Regression/C/gcc-dg/strlenopt-14gf.c new file mode 100644 index 0000000000..54cff838a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-14gf.c @@ -0,0 +1,25 @@ +/* This test needs runtime that provides stpcpy, mempcpy and __*_chk + functions. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ +/* Bionic targets don't have mempcpy */ +/* { dg-require-effective-target non_bionic } */ + +#define FORTIFY_SOURCE 2 +#include "strlenopt-14g.c" + +/* Compared to strlenopt-14gf.c, strcpy_chk with string literal as + second argument isn't being optimized by builtins.c into + memcpy. */ +/* { dg-final { scan-tree-dump-times "strlen \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__memcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__mempcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__strcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__strcat_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__stpcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "mempcpy \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 2 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-15.c b/SingleSource/Regression/C/gcc-dg/strlenopt-15.c new file mode 100644 index 0000000000..b72c096ffa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-15.c @@ -0,0 +1,59 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) size_t +fn1 (char *p, size_t l) +{ + memcpy (p, "abcdef", l); + /* This strlen can't be optimized, as l is unknown. */ + return strlen (p); +} + +__attribute__((noinline, noclone)) size_t +fn2 (char *p, const char *q, size_t *lp) +{ + size_t l = strlen (q), l2; + memcpy (p, q, 7); + /* This strlen can't be optimized, as l might be bigger than 7. */ + l2 = strlen (p); + *lp = l; + return l2; +} + +__attribute__((noinline, noclone)) char * +fn3 (char *p) +{ + *p = 0; + return p + 1; +} + +int +main () +{ + char buf[64]; + const char *volatile q = "ABCDEFGH"; + const char *volatile q2 = "IJ\0KLMNOPQRS"; + size_t l; + memset (buf, '\0', sizeof buf); + memset (buf + 2, 'a', 7); + if (fn1 (buf, 3) != 9 || memcmp (buf, "abcaaaaaa", 10) != 0) + abort (); + if (fn1 (buf, 7) != 6 || memcmp (buf, "abcdef\0aa", 10) != 0) + abort (); + if (fn2 (buf, q, &l) != 9 || l != 8 || memcmp (buf, "ABCDEFGaa", 10) != 0) + abort (); + if (fn2 (buf, q2, &l) != 2 || l != 2 || memcmp (buf, "IJ\0KLMNaa", 10) != 0) + abort (); + if (fn3 (buf) != buf + 1 || memcmp (buf, "\0J\0KLMNaa", 10) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-16g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-16g.c new file mode 100644 index 0000000000..e847a7aa74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-16g.c @@ -0,0 +1,33 @@ +/* This test needs runtime that provides stpcpy function. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define USE_GNU +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +fn1 (char *p, const char *q) +{ + /* This strcpy can be optimized into stpcpy. */ + strcpy (p, q); + /* And this strchr into the return value from it. */ + return strchr (p, '\0'); +} + +int +main () +{ + char buf[64]; + const char *volatile q = "ABCDEFGH"; + if (fn1 (buf, q) != buf + 8 || memcmp (buf, "ABCDEFGH", 9) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "mempcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-17g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-17g.c new file mode 100644 index 0000000000..9e6373c065 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-17g.c @@ -0,0 +1,56 @@ +/* This test needs runtime that provides stpcpy function. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define USE_GNU +#include "strlenopt.h" + +__attribute__((noinline, noclone)) int +foo (const char *p) +{ + static int c; + const char *q[] = { "123498765abcde", "123498765..", "129abcde", "129abcde" }; + if (strcmp (p, q[c]) != 0) + abort (); + return c++; +} + +__attribute__((noinline, noclone)) void +bar (const char *p, const char *q) +{ + size_t l; + /* This strlen stays. */ + char *a = __builtin_alloca (strlen (p) + 50); + /* strcpy can be optimized into memcpy. */ + strcpy (a, p); + /* strcat into stpcpy. */ + strcat (a, q); + /* This strlen can be optimized away. */ + l = strlen (a); + /* This becomes memcpy. */ + strcat (a, "abcde"); + if (!foo (a)) + /* And this one too. */ + strcpy (a + l, ".."); + foo (a); +} + +int +main () +{ + const char *volatile s1 = "1234"; + const char *volatile s2 = "98765"; + const char *volatile s3 = "12"; + const char *volatile s4 = "9"; + bar (s1, s2); + bar (s3, s4); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 3 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "mempcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-18g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-18g.c new file mode 100644 index 0000000000..0c219b8372 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-18g.c @@ -0,0 +1,81 @@ +/* This test needs runtime that provides stpcpy function. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define USE_GNU +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +fn1 (int x, int y, int z) +{ + static char buf[40]; + const char *p; + switch (x) + { + case 0: + p = "abcd"; + break; + case 1: + p = "efgh"; + break; + case 2: + p = "ijkl"; + break; + default: + p = "mnopq"; + break; + } + if (y) + { + strcpy (buf, p); + if (z) + strcat (buf, "ABCDEFG"); + else + strcat (buf, "HIJKLMN"); + } + else + { + strcpy (buf, p + 1); + if (z) + strcat (buf, "OPQ"); + else + strcat (buf, "RST"); + } + return buf; +} + +int +main () +{ + int i; + for (i = 0; i < 5; i++) + { + const char *p = "abcdefghijklmnopq" + (i < 3 ? i : 3) * 4; + const char *q; + int j = i >= 3; + fn1 (i ? 0 : 1, 1, 1); + q = fn1 (i, 0, 0); + if (memcmp (q, p + 1, 3 + j) != 0 || memcmp (q + 3 + j, "RST", 4) != 0) + abort (); + fn1 (i ? 0 : 1, 0, 1); + q = fn1 (i, 1, 0); + if (memcmp (q, p, 4 + j) != 0 || memcmp (q + 4 + j, "HIJKLMN", 8) != 0) + abort (); + fn1 (i ? 0 : 1, 1, 0); + q = fn1 (i, 0, 1); + if (memcmp (q, p + 1, 3 + j) != 0 || memcmp (q + 3 + j, "OPQ", 4) != 0) + abort (); + fn1 (i ? 0 : 1, 0, 0); + q = fn1 (i, 1, 1); + if (memcmp (q, p, 4 + j) != 0 || memcmp (q + 4 + j, "ABCDEFG", 8) != 0) + abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 2 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-19.c b/SingleSource/Regression/C/gcc-dg/strlenopt-19.c new file mode 100644 index 0000000000..814f51b27f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-19.c @@ -0,0 +1,80 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +fn1 (int x, int y, int z) +{ + static char buf[40]; + const char *p; + switch (x) + { + case 0: + p = "abcd"; + /* Prevent cswitch optimization. */ + asm volatile ("" : : : "memory"); + break; + case 1: + p = "efgh"; + break; + case 2: + p = "ijkl"; + break; + default: + p = "mnop"; + break; + } + if (y) + { + strcpy (buf, p); + if (z) + strcat (buf, "ABCDEFG"); + else + strcat (buf, "HIJKLMN"); + } + else + { + strcpy (buf, p + 1); + if (z) + strcat (buf, "OPQ"); + else + strcat (buf, "RST"); + } + return buf; +} + +int +main () +{ + int i; + for (i = 0; i < 5; i++) + { + const char *p = "abcdefghijklmnop" + (i < 3 ? i : 3) * 4; + const char *q; + fn1 (i ? 0 : 1, 1, 1); + q = fn1 (i, 0, 0); + if (memcmp (q, p + 1, 3) != 0 || memcmp (q + 3, "RST", 4) != 0) + abort (); + fn1 (i ? 0 : 1, 0, 1); + q = fn1 (i, 1, 0); + if (memcmp (q, p, 4) != 0 || memcmp (q + 4, "HIJKLMN", 8) != 0) + abort (); + fn1 (i ? 0 : 1, 1, 0); + q = fn1 (i, 0, 1); + if (memcmp (q, p + 1, 3) != 0 || memcmp (q + 3, "OPQ", 4) != 0) + abort (); + fn1 (i ? 0 : 1, 0, 0); + q = fn1 (i, 1, 1); + if (memcmp (q, p, 4) != 0 || memcmp (q + 4, "ABCDEFG", 8) != 0) + abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-1f.c b/SingleSource/Regression/C/gcc-dg/strlenopt-1f.c new file mode 100644 index 0000000000..e7d817f9da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-1f.c @@ -0,0 +1,17 @@ +/* This test needs runtime that provides __*_chk functions. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinu* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define FORTIFY_SOURCE 2 +#include "strlenopt-1.c" + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__memcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__strcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__strcat_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__stpcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-2.c b/SingleSource/Regression/C/gcc-dg/strlenopt-2.c new file mode 100644 index 0000000000..b09f7c17e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-2.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +foo (char *p, char *r) +{ + char buf[26]; + if (strlen (p) + strlen (r) + 9 > 26) + return NULL; + /* This strcpy can be optimized into memcpy, using the remembered + strlen (p). */ + strcpy (buf, p); + /* These two strcat can be optimized into memcpy. The first one + could be even optimized into a *ptr = '/'; store as the '\0' + is immediately overwritten. */ + strcat (buf, "/"); + strcat (buf, "abcde"); + /* This strcpy can be optimized into memcpy, using the remembered + strlen (r). */ + strcat (buf, r); + /* And this can be optimized into memcpy too. */ + strcat (buf, "fg"); + return strdup (buf); +} + +int +main () +{ + char *volatile p = "string1"; + char *volatile r = "string2"; + char *q = foo (p, r); + if (q != NULL) + { + if (strcmp (q, "string1/abcdestring2fg")) + abort (); + free (q); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 5 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-20.c b/SingleSource/Regression/C/gcc-dg/strlenopt-20.c new file mode 100644 index 0000000000..79db12bc10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-20.c @@ -0,0 +1,94 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) const char * +fn1 (int x, int y) +{ + const char *p; + switch (x) + { + case 0: + p = "abcd"; + /* Prevent cswitch optimization. */ + asm volatile ("" : : : "memory"); + break; + case 1: + p = "efgh"; + break; + case 2: + p = "ijkl"; + break; + default: + p = "mnop"; + break; + } + if (y) + /* strchr should be optimized into p + 4 here. */ + return strchr (p, '\0'); + else + /* and strlen into 3. */ + return p + strlen (p + 1); +} + +__attribute__((noinline, noclone)) size_t +fn2 (char *p, char *q) +{ + size_t l; + /* Both strcpy calls can be optimized into memcpy, strlen needs to stay. */ + strcpy (p, "abc"); + p[3] = 'd'; + l = strlen (p); + strcpy (q, p); + return l; +} + +__attribute__((noinline, noclone)) char * +fn3 (char *p) +{ + char *c; + /* The strcpy call can be optimized into memcpy, strchr needs to stay, + strcat is optimized into memcpy. */ + strcpy (p, "abc"); + p[3] = 'd'; + c = strchr (p, '\0'); + strcat (p, "efgh"); + return c; +} + +int +main () +{ + int i; + char buf[64], buf2[64]; + for (i = 0; i < 5; i++) + { + const char *p = "abcdefghijklmnop" + (i < 3 ? i : 3) * 4; + const char *q; + q = fn1 (i, 1); + if (memcmp (q - 4, p, 4) != 0 || q[0] != '\0') + abort (); + q = fn1 (i, 0); + if (memcmp (q - 3, p, 4) != 0 || q[1] != '\0') + abort (); + } + memset (buf, '\0', sizeof buf); + memset (buf + 4, 'z', 2); + if (fn2 (buf, buf2) != 6 + || memcmp (buf, "abcdzz", 7) != 0 + || memcmp (buf2, "abcdzz", 7) != 0) + abort (); + memset (buf, '\0', sizeof buf); + memset (buf + 4, 'z', 2); + if (fn3 (buf) != buf + 6 || memcmp (buf, "abcdzzefgh", 11) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-21.c b/SingleSource/Regression/C/gcc-dg/strlenopt-21.c new file mode 100644 index 0000000000..7924ff30b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-21.c @@ -0,0 +1,65 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +struct S { char *p; size_t l; }; + +__attribute__((noinline, noclone)) struct S +foo (char *x, int n) +{ + int i; + char a[64]; + char *p = strchr (x, '\0'); + struct S s; + /* strcpy here is optimized into memcpy, length computed as p - x + 1. */ + strcpy (a, x); + /* strcat here is optimized into memcpy. */ + strcat (p, "abcd"); + for (i = 0; i < n; i++) + if ((i % 123) == 53) + /* strcat here is optimized into strlen and memcpy. */ + strcat (a, "efg"); + s.p = strdup (a); + /* The strlen should be optimized here into 4. */ + s.l = strlen (p); + return s; +} + +int +main () +{ + char buf[32]; + struct S s; + buf[0] = 'z'; + buf[1] = '\0'; + s = foo (buf, 0); + if (s.l != 4 || memcmp (buf, "zabcd", 6) != 0) + abort (); + if (s.p == NULL) + return 0; + if (memcmp (s.p, "z", 2) != 0) + abort (); + s = foo (buf, 60); + if (s.l != 4 || memcmp (buf, "zabcdabcd", 10) != 0) + abort (); + if (s.p == NULL) + return 0; + if (memcmp (s.p, "zabcdefg", 9) != 0) + abort (); + s = foo (buf, 240); + if (s.l != 4 || memcmp (buf, "zabcdabcdabcd", 14) != 0) + abort (); + if (s.p == NULL) + return 0; + if (memcmp (s.p, "zabcdabcdefgefg", 16) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 3 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-22.c b/SingleSource/Regression/C/gcc-dg/strlenopt-22.c new file mode 100644 index 0000000000..2d127b1183 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-22.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) size_t +bar (char *p, char *q) +{ + size_t l1, l2, l3; + char *r = strchr (p, '\0'); + strcpy (r, "abcde"); + char *s = strchr (r, '\0'); + strcpy (s, q); + l1 = strlen (p); + l2 = strlen (r); + l3 = strlen (s); + return l1 + l2 + l3; +} + +int +main () +{ + char buf[16] = "01234"; + + if (bar (buf, "56789") != 30) + abort (); + + if (memcmp (buf, "01234abcde56789", 16) != 0) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-22g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-22g.c new file mode 100644 index 0000000000..6ee6bef63a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-22g.c @@ -0,0 +1,13 @@ +/* This test needs runtime that provides stpcpy function. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define USE_GNU +#include "strlenopt-22.c" + +/* { dg-final { scan-tree-dump-times "strlen \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-23.c b/SingleSource/Regression/C/gcc-dg/strlenopt-23.c new file mode 100644 index 0000000000..75dab2ae0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-23.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/57230 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "strlenopt.h" + +int +main () +{ + char p[] = "hello world"; + p[0] = (char) (strlen (p) - 1); + if (strlen (p) != 11) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-24.c b/SingleSource/Regression/C/gcc-dg/strlenopt-24.c new file mode 100644 index 0000000000..275b5602b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-24.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/57230 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +int +main () +{ + char p[] = "hello world"; + if (strlen (p) != 11) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-25.c b/SingleSource/Regression/C/gcc-dg/strlenopt-25.c new file mode 100644 index 0000000000..faed5bec88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-25.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +int +main () +{ + char p[] = "foobar"; + int len, len2; + len = strlen (p); + p[0] = 'O'; + len2 = strlen (p); + return len - len2; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-26.c b/SingleSource/Regression/C/gcc-dg/strlenopt-26.c new file mode 100644 index 0000000000..0385aceaad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-26.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) size_t +fn1 (char *p, const char *r) +{ + size_t len1 = strlen (r); + char *q = strchr (p, '\0'); + *q = '\0'; + return len1 - strlen (r); // This strlen should be optimized into len1. +} + +int +main (void) +{ + char p[] = "foobar"; + const char *volatile q = "xyzzy"; + return fn1 (p, q); +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-27.c b/SingleSource/Regression/C/gcc-dg/strlenopt-27.c new file mode 100644 index 0000000000..e3655930b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-27.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) size_t +fn1 (char *p) +{ + strcpy (p, "foobar"); + return strlen (p + 2); // This strlen should be optimized into 4. +} + +int +main (void) +{ + char p[] = "barfoo"; + if (fn1 (p) != 4) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-28.c b/SingleSource/Regression/C/gcc-dg/strlenopt-28.c new file mode 100644 index 0000000000..6bdbed7e9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-28.c @@ -0,0 +1,59 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +volatile int v; + +size_t +f1 (void) +{ + char a[30]; + v += 1; + memcpy (a, "1234567", 8); + memcpy (a + 7, "89abcdefg", 10); + memcpy (a + 16, "h", 2); + return strlen (a); // This strlen should be optimized into 17. +} + +size_t +f2 (void) +{ + char a[30]; + v += 2; + strcpy (a, "1234567"); + strcpy (a + 7, "89abcdefg"); + strcpy (a + 16, "h"); + return strlen (a); // This strlen should be optimized into 17. +} + +size_t +f3 (char *a) +{ + v += 3; + memcpy (a, "1234567", 8); + memcpy (a + 7, "89abcdefg", 10); + memcpy (a + 16, "h", 2); + return strlen (a); // This strlen should be optimized into 17. +} + +size_t +f4 (char *a) +{ + v += 4; + strcpy (a, "1234567"); + strcpy (a + 7, "89abcdefg"); + strcpy (a + 16, "h"); + return strlen (a); // This strlen should be optimized into 17. +} + +int +main () +{ + char a[30]; + if (f1 () != 17 || f2 () != 17 || f3 (a) != 17 || f4 (a) != 17) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-29.c b/SingleSource/Regression/C/gcc-dg/strlenopt-29.c new file mode 100644 index 0000000000..8922101f54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-29.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/71707 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +char a[32]; +size_t b; + +__attribute__((noinline, noclone)) char * +foo (void) +{ + char *p = memcpy (a, "a", 2) + 1; + memcpy (&a[1], "b", 2); + b = strlen (a) + strlen (&a[1]) + strlen (p); + return p; +} + +int +main () +{ + if (foo () != &a[1] || b != 4) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-2f.c b/SingleSource/Regression/C/gcc-dg/strlenopt-2f.c new file mode 100644 index 0000000000..c0c7f388eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-2f.c @@ -0,0 +1,17 @@ +/* This test needs runtime that provides __*_chk functions. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define FORTIFY_SOURCE 2 +#include "strlenopt-2.c" + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__memcpy_chk \\(" 5 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__strcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__strcat_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__stpcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-3.c b/SingleSource/Regression/C/gcc-dg/strlenopt-3.c new file mode 100644 index 0000000000..a748f011c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-3.c @@ -0,0 +1,64 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) size_t +fn1 (char *p, char *q) +{ + size_t s = strlen (q); + strcpy (p, q); + return s - strlen (p); +} + +__attribute__((noinline, noclone)) size_t +fn2 (char *p, char *q) +{ + size_t s = strlen (q); + memcpy (p, q, s + 1); + return s - strlen (p); +} + +__attribute__((noinline, noclone)) size_t +fn3 (char *p) +{ + memcpy (p, "abcd", 5); + return strlen (p); +} + +__attribute__((noinline, noclone)) size_t +fn4 (char *p) +{ + memcpy (p, "efg\0hij", 6); + return strlen (p); +} + +int +main () +{ + char buf[64]; + char *volatile p = buf; + char *volatile q = "ABCDEF"; + buf[7] = 'G'; + if (fn1 (p, q) != 0 || memcmp (buf, "ABCDEF\0G", 8)) + abort (); + q = "HIJ"; + if (fn2 (p + 1, q) != 0 || memcmp (buf, "AHIJ\0F\0G", 8)) + abort (); + buf[6] = 'K'; + if (fn3 (p + 1) != 4 || memcmp (buf, "Aabcd\0KG", 8)) + abort (); + if (fn4 (p) != 3 || memcmp (buf, "efg\0hiKG", 8)) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "return 0" 3 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 4" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 3" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-30.c b/SingleSource/Regression/C/gcc-dg/strlenopt-30.c new file mode 100644 index 0000000000..2a3098ba96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-30.c @@ -0,0 +1,63 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +__attribute__((no_icf)) +_Bool f1(char *s) +{ + return __builtin_strstr (s, "hello") == s; +} + +__attribute__((no_icf)) +_Bool f2(char *s) +{ + return s == __builtin_strstr (s, "hello"); +} + +__attribute__((no_icf)) +_Bool f3(char *s) +{ + return s != __builtin_strstr (s, "hello"); +} + +__attribute__((no_icf)) +_Bool f4() +{ + char *foo_f4(void); + char *t1 = foo_f4(); + char *t2 = __builtin_strstr (t1, "hello"); + _Bool t3 = t2 == t1; + return t3; +} + +__attribute__((no_icf)) +void f5(char *s) +{ + char *t1 = __builtin_strstr (s, "hello"); + void foo_f5(void); + if (t1 != s) + foo_f5(); +} + +/* Do not perform transform, since strlen (t) + is unknown. */ + +__attribute__((no_icf)) +_Bool f6(char *s, char *t) +{ + return __builtin_strstr (s, t) == s; +} + +/* Do not perform transform in this case, since + t1 doesn't have single use. */ + +__attribute__((no_icf)) +_Bool f7(char *s) +{ + void foo_f7(char *); + + char *t1 = __builtin_strstr (s, "hello"); + foo_f7 (t1); + return (t1 == s); +} + +/* { dg-final { scan-tree-dump-times "__builtin_strncmp" 5 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-31.c b/SingleSource/Regression/C/gcc-dg/strlenopt-31.c new file mode 100644 index 0000000000..bdd46ba000 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-31.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) int +bar (char *p1, const char *q) +{ + strcpy (p1, "abcde"); + char *p2 = strchr (p1, '\0'); + strcpy (p2, q); + char *p3 = strchr (p2, '\0'); + memcpy (p3, "x", 2); + return strlen (p1); +} + +int +main (void) +{ + char buffer[10]; + int res = bar (buffer, "foo"); + if (strcmp (buffer, "abcdefoox") != 0 || res != 9) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-31g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-31g.c new file mode 100644 index 0000000000..eee4b57a4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-31g.c @@ -0,0 +1,9 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define USE_GNU +#include "strlenopt-31.c" + +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-not "strlen \\(" "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-32.c b/SingleSource/Regression/C/gcc-dg/strlenopt-32.c new file mode 100644 index 0000000000..4220314fb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-32.c @@ -0,0 +1,193 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +char temp[30]; +volatile int v; + +size_t __attribute__ ((noinline, noclone)) +f1 (void) +{ + char a[30]; + v += 1; + memcpy (a, "1234567", 7); + memcpy (a + 7, "89abcdefg", 9); + memcpy (a + 16, "h", 2); + return strlen (a); // This strlen should be optimized into 17. +} + +size_t __attribute__ ((noinline, noclone)) +f2 (char *a) +{ + v += 2; + memcpy (a, "1234567", 7); + memcpy (a + 7, "89abcdefg", 9); + memcpy (a + 16, "h", 2); + return strlen (a); // This strlen should be optimized into 17. +} + +size_t __attribute__ ((noinline, noclone)) +f3 (void) +{ + char a[30]; + v += 3; + a[0] = '1'; + memcpy (a + 1, "2345678", 8); + return strlen (a); // This strlen should be optimized into 8. +} + +size_t __attribute__ ((noinline, noclone)) +f4 (char *a) +{ + v += 4; + a[0] = '1'; + memcpy (a + 1, "2345678", 8); + return strlen (a); // This strlen should be optimized into 8. +} + +size_t __attribute__ ((noinline, noclone)) +f5 (void) +{ + char a[30]; + v += 5; + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + memcpy (a + 3, "456", 3); + a[6] = '7'; + a[7] = 0; + return strlen (a); // This strlen should be optimized into 7. +} + +size_t __attribute__ ((noinline, noclone)) +f6 (char *a) +{ + v += 6; + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + memcpy (a + 3, "456", 3); + a[6] = '7'; + a[7] = 0; + return strlen (a); // This strlen should be optimized into 7. +} + +size_t __attribute__ ((noinline, noclone)) +f7 (void) +{ + char a[30]; + v += 7; + strcpy (a, "abcde"); + int len1 = strlen (a); + a[2] = '_'; + int len2 = strlen (a); + return len1 + len2; // This should be optimized into 10. +} + +size_t __attribute__ ((noinline, noclone)) +f8 (char *a) +{ + v += 8; + strcpy (a, "abcde"); + int len1 = strlen (a); + a[2] = '_'; + int len2 = strlen (a); + return len1 + len2; // This should be optimized into 10. +} + +size_t __attribute__ ((noinline, noclone)) +f9 (char b) +{ + char a[30]; + v += 9; + strcpy (a, "foo.bar"); + a[4] = b; + a[3] = 0; + return strlen (a); // This should be optimized into 3. +} + +size_t __attribute__ ((noinline, noclone)) +f10 (char *a, char b) +{ + v += 10; + strcpy (a, "foo.bar"); + a[4] = b; + a[3] = 0; + return strlen (a); // This should be optimized into 3. +} + +size_t __attribute__ ((noinline, noclone)) +f11 (void) +{ + char a[30]; + v += 11; + strcpy (temp, "123456"); + memcpy (a, temp, 7); + return strlen (a); // This should be optimized into 6. +} + +size_t __attribute__ ((noinline, noclone)) +f12 (char *a) +{ + v += 12; + strcpy (temp, "123456"); + memcpy (a, temp, 7); + return strlen (a); // This should be optimized into 6. +} + +size_t __attribute__ ((noinline, noclone)) +f13 (void) +{ + char a[30]; + v += 13; + strcpy (temp, "1234567"); + memcpy (a, temp, 7); + a[7] = 0; + return strlen (a); // This should be optimized into 7. +} + +size_t __attribute__ ((noinline, noclone)) +f14 (char *a) +{ + v += 14; + strcpy (temp, "1234567"); + memcpy (a, temp, 7); + a[7] = 0; + return strlen (a); // This should be optimized into 7. +} + +size_t __attribute__ ((noinline, noclone)) +f15 (void) +{ + char a[30]; + v += 15; + strcpy (temp, "12345679"); + memcpy (a, temp, 7); + a[7] = 0; + return strlen (a); // This should be optimized into 7. +} + +size_t __attribute__ ((noinline, noclone)) +f16 (char *a) +{ + v += 16; + strcpy (temp, "123456789"); + memcpy (a, temp, 7); + a[7] = 0; + return strlen (a); // This should be optimized into 7. +} + +int +main () +{ + char a[30]; + if (f1 () != 17 || f2 (a) != 17 || f3 () != 8 || f4 (a) != 8 + || f5 () != 7 || f6 (a) != 7 || f7 () != 10 || f8 (a) != 10 + || f9 ('_') != 3 || f10 (a, '_') != 3 || f11 () != 6 || f12 (a) != 6 + || f13 () != 7 || f14 (a) != 7 || f15 () != 7 || f16 (a) != 7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-33.c b/SingleSource/Regression/C/gcc-dg/strlenopt-33.c new file mode 100644 index 0000000000..4903a91a0a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-33.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +volatile int v; + +size_t __attribute__ ((noinline, noclone)) +f1 (char *b) +{ + char a[30]; + v += 1; + strcpy (a, b); + // This needs to stay. + int len1 = strlen (a); + a[0] = '_'; + a[1] = 0; + return len1 + strlen (a); +} + +size_t __attribute__ ((noinline, noclone)) +f2 (char *a, char *b) +{ + v += 2; + strcpy (a, b); + // This needs to stay. + int len1 = strlen (a); + a[0] = '_'; + a[1] = 0; + return len1 + strlen (a); +} + +int +main () +{ + char a[30]; + if (f1 ("foo") != 4 || f2 (a, "foobar") != 7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-33g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-33g.c new file mode 100644 index 0000000000..1950008324 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-33g.c @@ -0,0 +1,44 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define USE_GNU +#include "strlenopt.h" + +volatile int v; + +size_t __attribute__ ((noinline, noclone)) +f1 (char *b) +{ + char a[30]; + v += 1; + // Should be converted to stpcpy. + strcpy (a, b); + int len1 = strlen (a); + a[0] = '_'; + a[1] = 0; + return len1 + strlen (a); +} + +size_t __attribute__ ((noinline, noclone)) +f2 (char *a, char *b) +{ + v += 2; + // Should be converted to stpcpy. + strcpy (a, b); + int len1 = strlen (a); + a[0] = '_'; + a[1] = 0; + return len1 + strlen (a); +} + +int +main () +{ + char a[30]; + if (f1 ("foo") != 4 || f2 (a, "foobar") != 7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 2 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-34.c b/SingleSource/Regression/C/gcc-dg/strlenopt-34.c new file mode 100644 index 0000000000..1979370cb5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-34.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +volatile int v; + +size_t __attribute__ ((noinline, noclone)) +f1 (char b) +{ + char a[30]; + v += 1; + strcpy (a, "foo.bar"); + a[3] = b; + a[4] = 0; + return strlen (a); +} + +size_t __attribute__ ((noinline, noclone)) +f2 (char *a, char b) +{ + v += 2; + strcpy (a, "foo.bar"); + a[3] = b; + a[4] = 0; + return strlen (a); +} + +int +main () +{ + char a[30]; + if (f1 ('_') != 4 || f1 (0) != 3 || f2 (a, '_') != 4 || f2 (a, 0) != 3) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-35.c b/SingleSource/Regression/C/gcc-dg/strlenopt-35.c new file mode 100644 index 0000000000..d175fd7ff5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-35.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +volatile int v; + +size_t +f1 (char *a1) +{ + v += 1; + size_t x = strlen (a1); + char *a2 = a1 + x; + a2[0] = '1'; + a2[1] = '2'; + a2[2] = '3'; + a2[3] = 0; + return strlen (a1); +} + +int +main () +{ + char a[30]; + strcpy (a, "abcd"); + if (f1 (a) != 7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 1 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-36.c b/SingleSource/Regression/C/gcc-dg/strlenopt-36.c new file mode 100644 index 0000000000..56e59a431a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-36.c @@ -0,0 +1,37 @@ +/* PR tree-optimization/78450 - strlen(s) return value can be assumed + to be less than the size of s + { dg-do compile } + { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +extern char a7[7], a6[6], a5[5], a4[4], a3[3], a2[2], a1[1]; +extern char a0[0]; /* Intentionally not tested here. */ +extern char ax[]; /* Same. */ + +extern void failure_on_line (int); + +#define TEST_FAIL(line) \ + do { \ + failure_on_line (line); \ + } while (0) + +#define T(expr) \ + if (!(expr)) TEST_FAIL (__LINE__); else (void)0 + + +void test_array (void) +{ + T (strlen (a7) < sizeof a7); + T (strlen (a6) < sizeof a6); + T (strlen (a5) < sizeof a5); + T (strlen (a4) < sizeof a4); + T (strlen (a3) < sizeof a3); + + /* The following two calls are folded too early which defeats + the strlen() optimization. + T (strlen (a2) == 1); + T (strlen (a1) == 0); */ +} + +/* { dg-final { scan-tree-dump-not "failure_on_line" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-37.c b/SingleSource/Regression/C/gcc-dg/strlenopt-37.c new file mode 100644 index 0000000000..865653c18d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-37.c @@ -0,0 +1,83 @@ +/* PR tree-optimization/78450 - strlen(s) return value can be assumed + to be less than the size of s + { dg-do compile } + { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +extern char ax[]; + +struct MemArray7 { char a7[7]; }; +struct MemArray6 { char a6[6]; }; +struct MemArray5 { char a5[5]; }; +struct MemArray4 { char a4[4]; }; +struct MemArray3 { char a3[3]; }; +struct MemArray2 { char a2[2]; }; +struct MemArray1 { char a1[1]; }; +struct MemArray0 { int n; char a0[0]; }; +struct MemArrayX { int n; char ax[]; }; + +struct MemArrays +{ + struct MemArray7 *ma7; + struct MemArray6 *ma6; + struct MemArray5 *ma5; + struct MemArray4 *ma4; + struct MemArray3 *ma3; + struct MemArray2 *ma2; + struct MemArray1 *ma1; + struct MemArray0 *ma0; + struct MemArrayX *max; +}; + +extern void if_stmt_on_line (int); +extern void else_stmt_on_line (int); + +#define T(expr) \ + (!!(expr) ? if_stmt_on_line (__LINE__) : else_stmt_on_line (__LINE__)) + +void test_memarray_lt (struct MemArrays *p) +{ + T (strlen (p->ma7->a7) < sizeof p->ma7->a7); + T (strlen (p->ma6->a6) < sizeof p->ma6->a6); + T (strlen (p->ma5->a5) < sizeof p->ma5->a5); + T (strlen (p->ma4->a4) < sizeof p->ma4->a4); + T (strlen (p->ma3->a3) < sizeof p->ma3->a3); + T (strlen (p->ma2->a2) < sizeof p->ma2->a2); + T (strlen (p->ma1->a1) < sizeof p->ma1->a1); + + T (strlen (p->ma0->a0) < 1); + T (strlen (p->max->ax) < 1); +} + +void test_memarray_eq (struct MemArrays *p) +{ + T (strlen (p->ma7->a7) == sizeof p->ma7->a7); + T (strlen (p->ma6->a6) == sizeof p->ma6->a6); + T (strlen (p->ma5->a5) == sizeof p->ma5->a5); + T (strlen (p->ma4->a4) == sizeof p->ma4->a4); + T (strlen (p->ma3->a3) == sizeof p->ma3->a3); + T (strlen (p->ma2->a2) == sizeof p->ma2->a2); + T (strlen (p->ma1->a1) == sizeof p->ma1->a1); + + T (strlen (p->ma0->a0) == 1); + T (strlen (p->max->ax) == 1); +} + +void test_memarray_gt (struct MemArrays *p) +{ + T (strlen (p->ma7->a7) > sizeof p->ma7->a7); + T (strlen (p->ma6->a6) > sizeof p->ma6->a6); + T (strlen (p->ma5->a5) > sizeof p->ma5->a5); + T (strlen (p->ma4->a4) > sizeof p->ma4->a4); + T (strlen (p->ma3->a3) > sizeof p->ma3->a3); + T (strlen (p->ma2->a2) > sizeof p->ma2->a2); + T (strlen (p->ma1->a1) > sizeof p->ma1->a1); + + T (strlen (p->ma0->a0) > 1); + T (strlen (p->max->ax) > 1); + } + +/* Verify that no if or else statements have been eliminated. + { dg-final { scan-tree-dump-times "if_stmt_on_line" 27 "optimized" } } + { dg-final { scan-tree-dump-times "else_stmt_on_line" 27 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-38.c b/SingleSource/Regression/C/gcc-dg/strlenopt-38.c new file mode 100644 index 0000000000..7c39f3a175 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-38.c @@ -0,0 +1,49 @@ +/* PR tree-optimization/83444 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-not "abort \\(\\)" "optimized" } } */ + +#include "strlenopt.h" + +void +foo (void) +{ + char a[5] = "012"; + strcpy (a, ""); + if (strlen (a) != 0) + abort (); +} + +void +bar (void) +{ + char a[5] = "012"; + char b[7] = ""; + strcpy (a, b); + if (strlen (a) != 0) + abort (); +} + +struct S { char a[4]; char b[5]; char c[7]; }; + +void +baz (void) +{ + struct S s; + strcpy (s.b, "012"); + strcpy (s.c, ""); + strcpy (s.b, s.c); + if (s.b[0] != 0) + abort (); +} + +void +boo (void) +{ + struct S s; + strcpy (s.b, "012"); + strcpy (s.c, ""); + strcpy (s.b, s.c); + if (strlen (s.b) != 0) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-39.c b/SingleSource/Regression/C/gcc-dg/strlenopt-39.c new file mode 100644 index 0000000000..c65b4bfc1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-39.c @@ -0,0 +1,66 @@ +/* PR tree-optimization/83444 + { dg-do compile { target i?86-*-* x86_64-*-* } } + { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define STR "1234567" + +const char str[] = STR; + +char dst[10]; + +void copy_from_global_str (void) +{ + strcpy (dst, str); + + if (strlen (dst) != sizeof str - 1) + abort (); +} + +void copy_from_local_str (void) +{ + const char s[] = STR; + + strcpy (dst, s); + + if (strlen (dst) != sizeof s - 1) + abort (); +} + +void copy_from_local_memstr (void) +{ + struct { + char s[sizeof STR]; + } x = { STR }; + + strcpy (dst, x.s); + + if (strlen (dst) != sizeof x.s - 1) + abort (); +} + +void copy_to_local_str (void) +{ + char d[sizeof STR]; + + strcpy (d, str); + + if (strlen (d) != sizeof str - 1) + abort (); +} + +void copy_to_local_memstr (void) +{ + struct { + char d[sizeof STR]; + } x; + + strcpy (x.d, str); + + if (strlen (x.d) != sizeof str- 1) + abort (); +} + +/* Verify that all calls to strlen have been eliminated. + { dg-final { scan-tree-dump-not "(abort|strlen) \\(\\)" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-4.c b/SingleSource/Regression/C/gcc-dg/strlenopt-4.c new file mode 100644 index 0000000000..1d0a6e615b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-4.c @@ -0,0 +1,74 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +/* If stpcpy can't be used, this is optimized into + strcpy (p, q); strcat (p, r); memcpy (p + strlen (p), "abcd", 5); + If stpcpy can be used (see strlenopt-4g.c test), + this is optimized into + memcpy (stpcpy (stpcpy (p, q), r), "abcd", 5); */ +__attribute__((noinline, noclone)) void +foo (char *p, const char *q, const char *r) +{ + strcpy (p, q); + strcat (p, r); + strcat (p, "abcd"); +} + +/* If stpcpy can't be used, this is optimized into + memcpy (p, "abcd", 4); strcpy (p + 4, q); strcat (p, r); + If stpcpy can be used, this is optimized into + memcpy (p, "abcd", 4); strcpy (stpcpy (p + 4, q), r); */ +__attribute__((noinline, noclone)) void +bar (char *p, const char *q, const char *r) +{ + strcpy (p, "abcd"); + strcat (p, q); + strcat (p, r); +} + +/* If stpcpy can't be used, this is optimized into + strcat (p, q); memcpy (t1 = p + strlen (p), "abcd", 4); + strcpy (t1 + 4, r); memcpy (p + strlen (p), "efgh", 5); + If stpcpy can be used, this is optimized into + t1 = stpcpy (p + strlen (p), q); memcpy (t1, "abcd", 4); + memcpy (stpcpy (t1 + 4, r), "efgh", 5); */ +__attribute__((noinline, noclone)) void +baz (char *p, const char *q, const char *r) +{ + strcat (p, q); + strcat (p, "abcd"); + strcat (p, r); + strcat (p, "efgh"); +} + +char buf[64]; + +int +main () +{ + char *volatile p = buf; + const char *volatile q = "ij"; + const char *volatile r = "klmno"; + foo (p, q, r); + if (memcmp (buf, "ijklmnoabcd\0\0\0\0\0\0\0\0", 20) != 0) + abort (); + memset (buf, '\0', sizeof buf); + bar (p, q, r); + if (memcmp (buf, "abcdijklmno\0\0\0\0\0\0\0\0", 20) != 0) + abort (); + memset (buf, 'v', 3); + memset (buf + 3, '\0', -3 + sizeof buf); + baz (p, q, r); + if (memcmp (buf, "vvvijabcdklmnoefgh\0", 20) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 3 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 3 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-40.c b/SingleSource/Regression/C/gcc-dg/strlenopt-40.c new file mode 100644 index 0000000000..7a97ebb8fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-40.c @@ -0,0 +1,428 @@ +/* PR tree-optimization/83671 - fix for false positive reported by + -Wstringop-overflow does not work with inlining + { dg-do compile } + { dg-options "-O1 -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define DIFF_MAX __PTRDIFF_MAX__ + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macros to emit a call to funcation named + call_in_{true,false}_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM_TRUE(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +#define ELIM_FALSE(expr) \ + if (!!(expr)) FAIL (in_false_branch_not_eliminated); else (void)0 + +/* Macro to emit a call to a function named + call_made_in_{true,false}_branch_on_line_NNN() + for each call that's expected to be retained. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that the expected number of both kinds of calls appears in output + (a pair for each line with the invocation of the KEEP() macro. */ +#define KEEP(expr) \ + if (expr) \ + FAIL (made_in_true_branch); \ + else \ + FAIL (made_in_false_branch) + +typedef char A3[3], A5[5], A7[7], AX[]; + +typedef A3 A7_3[7]; +typedef A3 AX_3[]; +typedef A5 A7_5[7]; +typedef A7 A5_7[5]; + +extern A7_3 a7_3; +extern A5_7 a5_7; +extern AX_3 ax_3; + +extern A3 a3; +extern A7 a5; +extern A7 a7; +extern AX ax; + +extern A3 *pa3; +extern A5 *pa5; +extern A7 *pa7; + +extern A7_3 *pa7_3; +extern AX_3 *pax_3; +extern A5_7 *pa5_7; +extern A7_5 *pa7_5; + +extern char *ptr; + +struct MemArrays0 { + A7_3 a7_3; + A5_7 a5_7; + char a3[3], a5[5], a0[0]; +}; +struct MemArraysX { char a3[3], a5[5], ax[]; }; +struct MemArrays7 { char a3[3], a5[5], a7[7]; }; + +struct MemArrays0 ma0_3_5_7[3][5][7]; + +void elim_strings (int i) +{ + ELIM_TRUE (strlen (i < 0 ? "123" : "321") == 3); + ELIM_FALSE (strlen (i < 0 ? "123" : "321") > 3); + ELIM_FALSE (strlen (i < 0 ? "123" : "321") < 3); + + ELIM_TRUE (strlen (i < 0 ? "123" : "4321") >= 3); + ELIM_FALSE (strlen (i < 0 ? "123" : "4321") > 4); + ELIM_FALSE (strlen (i < 0 ? "123" : "4321") < 3); + + ELIM_TRUE (strlen (i < 0 ? "1234" : "321") >= 3); + ELIM_FALSE (strlen (i < 0 ? "1234" : "321") < 3); + ELIM_FALSE (strlen (i < 0 ? "1234" : "321") > 4); + + ELIM_TRUE (strlen (i < 0 ? "123" : "4321") <= 4); + ELIM_TRUE (strlen (i < 0 ? "1234" : "321") <= 4); + + ELIM_TRUE (strlen (i < 0 ? "1" : "123456789") <= 9); + ELIM_TRUE (strlen (i < 0 ? "1" : "123456789") >= 1); +} + +/* Verify that strlen calls involving uninitialized global arrays + of known size are eliminated when they appear in expressions + that test for results that must be true. */ +void elim_global_arrays (int i) +{ + /* Verify that the expression involving the strlen call as well + as whatever depends on it is eliminated from the test output. + All these expressions must be trivially true. */ + ELIM_TRUE (strlen (a7_3[0]) < sizeof a7_3); + ELIM_TRUE (strlen (a7_3[1]) < sizeof a7_3 - sizeof *a7_3); + ELIM_TRUE (strlen (a7_3[6]) < sizeof a7_3 - 5 * sizeof *a7_3); + ELIM_TRUE (strlen (a7_3[i]) < sizeof a7_3); + + ELIM_TRUE (strlen (a5_7[0]) < sizeof a5_7); + ELIM_TRUE (strlen (a5_7[1]) < sizeof a5_7 - sizeof *a5_7); + ELIM_TRUE (strlen (a5_7[4]) < sizeof a5_7 - 3 * sizeof *a5_7); + ELIM_TRUE (strlen (a5_7[i]) < sizeof a5_7); + + /* Even when treating a multi-dimensional array as a single string + the length must be less DIFF_MAX - (ax_3[i] - ax_3[0]) but GCC + doesn't do that computation yet so avoid testing it. */ + ELIM_TRUE (strlen (ax_3[0]) < DIFF_MAX); + ELIM_TRUE (strlen (ax_3[1]) < DIFF_MAX); + ELIM_TRUE (strlen (ax_3[9]) < DIFF_MAX); + ELIM_TRUE (strlen (ax_3[i]) < DIFF_MAX); + + ELIM_TRUE (strlen (a3) < sizeof a3); + ELIM_TRUE (strlen (a7) < sizeof a7); + + ELIM_TRUE (strlen (ax) != DIFF_MAX); + /* ELIM_TRUE (strlen (ax) != DIFF_MAX - 1); */ + /* ELIM_TRUE (strlen (ax) < DIFF_MAX - 1); */ +} + +void elim_pointer_to_arrays (void) +{ + /* Unfortunately, GCC cannot be trusted not to misuse a pointer + to a smaller array to point to an object of a bigger type so + the strlen range optimization must assume each array pointer + points effectively to an array of an unknown bound. */ + ELIM_TRUE (strlen (*pa7) < DIFF_MAX); + ELIM_TRUE (strlen (*pa5) < DIFF_MAX); + ELIM_TRUE (strlen (*pa3) < DIFF_MAX); + + ELIM_TRUE (strlen ((*pa7_3)[0]) < DIFF_MAX); + ELIM_TRUE (strlen ((*pa7_3)[1]) < DIFF_MAX); + ELIM_TRUE (strlen ((*pa7_3)[6]) < DIFF_MAX); + + ELIM_TRUE (strlen ((*pax_3)[0]) < DIFF_MAX); + ELIM_TRUE (strlen ((*pax_3)[1]) < DIFF_MAX); + ELIM_TRUE (strlen ((*pax_3)[9]) < DIFF_MAX); + + ELIM_TRUE (strlen ((*pa5_7)[0]) < DIFF_MAX); + ELIM_TRUE (strlen ((*pa5_7)[1]) < DIFF_MAX); + ELIM_TRUE (strlen ((*pa5_7)[4]) < DIFF_MAX); +} + +void elim_global_arrays_and_strings (int i) +{ + ELIM_TRUE (strlen (i < 0 ? a3 : "") < 3); + ELIM_TRUE (strlen (i < 0 ? a3 : "1") < 3); + ELIM_TRUE (strlen (i < 0 ? a3 : "12") < 3); + ELIM_TRUE (strlen (i < 0 ? a3 : "123") < 4); + + ELIM_FALSE (strlen (i < 0 ? a3 : "") > 3); + ELIM_FALSE (strlen (i < 0 ? a3 : "1") > 3); + ELIM_FALSE (strlen (i < 0 ? a3 : "12") > 3); + ELIM_FALSE (strlen (i < 0 ? a3 : "123") > 4); + + ELIM_TRUE (strlen (i < 0 ? a7 : "") < 7); + ELIM_TRUE (strlen (i < 0 ? a7 : "1") < 7); + ELIM_TRUE (strlen (i < 0 ? a7 : "12") < 7); + ELIM_TRUE (strlen (i < 0 ? a7 : "123") < 7); + ELIM_TRUE (strlen (i < 0 ? a7 : "123456") < 7); + ELIM_TRUE (strlen (i < 0 ? a7 : "1234567") < 8); + + ELIM_FALSE (strlen (i < 0 ? a7 : "") > 6); + ELIM_FALSE (strlen (i < 0 ? a7 : "1") > 6); + ELIM_FALSE (strlen (i < 0 ? a7 : "12") > 6); + ELIM_FALSE (strlen (i < 0 ? a7 : "123") > 6); + ELIM_FALSE (strlen (i < 0 ? a7 : "123456") > 7); + ELIM_FALSE (strlen (i < 0 ? a7 : "1234567") > 8); +} + +void elim_member_arrays_obj (int i) +{ + ELIM_TRUE (strlen (ma0_3_5_7[0][0][0].a3) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[0][0][1].a3) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[0][0][2].a3) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[0][0][6].a3) < sizeof ma0_3_5_7); + + ELIM_TRUE (strlen (ma0_3_5_7[1][0][0].a3) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[2][0][1].a3) < sizeof ma0_3_5_7); + + ELIM_TRUE (strlen (ma0_3_5_7[1][1][0].a3) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[2][4][6].a3) < sizeof ma0_3_5_7); + + ELIM_TRUE (strlen (ma0_3_5_7[0][0][0].a5) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[0][0][1].a5) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[0][0][2].a5) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[0][0][6].a5) < sizeof ma0_3_5_7); + + ELIM_TRUE (strlen (ma0_3_5_7[1][0][0].a5) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[2][0][1].a5) < sizeof ma0_3_5_7); + + ELIM_TRUE (strlen (ma0_3_5_7[1][1][0].a5) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[2][4][6].a5) < sizeof ma0_3_5_7); + + ELIM_TRUE (strlen (ma0_3_5_7[0][0][0].a7_3[0]) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[2][4][6].a7_3[2]) < sizeof ma0_3_5_7); + + ELIM_TRUE (strlen (ma0_3_5_7[0][0][0].a5_7[0]) < sizeof ma0_3_5_7); + ELIM_TRUE (strlen (ma0_3_5_7[2][4][6].a5_7[4]) < sizeof ma0_3_5_7); +} + + +#line 1000 + +/* Verify that strlen calls involving uninitialized global arrays + of unknown size are not eliminated when they appear in expressions + that test for results that need not be true. */ +void keep_global_arrays (int i) +{ + KEEP (strlen (a7_3[0]) < 2); + KEEP (strlen (a7_3[1]) < 2); + KEEP (strlen (a7_3[6]) < 2); + KEEP (strlen (a7_3[i]) < 2); + + KEEP (strlen (a5_7[0]) < 6); + KEEP (strlen (a5_7[1]) < 6); + KEEP (strlen (a5_7[4]) < 6); + KEEP (strlen (a5_7[i]) < 6); + + /* Verify also that tests (and strlen calls) are not eliminated + for results greater than what would the size of the innermost + array suggest might be possible (in case the element array is + not nul-terminated), even though such calls are undefined. */ + KEEP (strlen (a5_7[0]) > sizeof a5_7 - 2); + KEEP (strlen (a5_7[1]) > sizeof a5_7 - sizeof a5_7[1] - 2); + KEEP (strlen (a5_7[i]) > sizeof a5_7 - 2); + + KEEP (strlen (ax_3[0]) < 2); + KEEP (strlen (ax_3[1]) < 2); + KEEP (strlen (ax_3[2]) < 2); + KEEP (strlen (ax_3[i]) < 2); + + /* Here again, verify that the ax_3 matrix is treated essentially + as a flat array of unknown bound for the benefit of all the + undefined code out there that might rely on it. */ + KEEP (strlen (ax_3[0]) > 3); + KEEP (strlen (ax_3[1]) > 9); + KEEP (strlen (ax_3[2]) > 99); + KEEP (strlen (ax_3[i]) > 999); + + KEEP (strlen (a3) < 2); + KEEP (strlen (a7) < 6); + + KEEP (strlen (a3 + i) < 2); + KEEP (strlen (a7 + i) < 2); + + /* The length of an array of unknown size may be as large as + DIFF_MAX - 2. */ + KEEP (strlen (ax) != DIFF_MAX - 2); + KEEP (strlen (ax) < DIFF_MAX - 2); + KEEP (strlen (ax) < 999); + KEEP (strlen (ax) < 1); +} + +void keep_pointer_to_arrays (int i) +{ + KEEP (strlen (*pa7) < 6); + KEEP (strlen (*pa5) < 4); + KEEP (strlen (*pa3) < 2); + + /* Since GCC cannot be trusted not to misuse a pointer to a smaller + array to point to an object of a larger type verify that the bound + in a pointer to an array of a known bound isn't relied on for + the strlen range optimization. If GCC is fixed to avoid these + misuses these tests can be removed. */ + KEEP (strlen (*pa7) > sizeof *pa7); + KEEP (strlen (*pa5) > sizeof *pa5); + KEEP (strlen (*pa3) > sizeof *pa3); + + KEEP (strlen ((*pa7_3)[0]) < 2); + KEEP (strlen ((*pa7_3)[1]) < 2); + KEEP (strlen ((*pa7_3)[6]) < 2); + KEEP (strlen ((*pa7_3)[i]) < 2); + + /* Same as above. */ + KEEP (strlen ((*pa7_3)[0]) > sizeof *pa7_3); + KEEP (strlen ((*pa7_3)[i]) > sizeof *pa7_3); + + KEEP (strlen ((*pax_3)[0]) < 2); + KEEP (strlen ((*pax_3)[1]) < 2); + KEEP (strlen ((*pax_3)[9]) < 2); + KEEP (strlen ((*pax_3)[i]) < 2); + + /* Same as above. */ + KEEP (strlen ((*pax_3)[0]) > 3); + KEEP (strlen ((*pax_3)[i]) > 333); + + KEEP (strlen ((*pa5_7)[0]) < 6); + KEEP (strlen ((*pa5_7)[1]) < 6); + KEEP (strlen ((*pa5_7)[4]) < 6); + KEEP (strlen ((*pa5_7)[i]) < 6); + + /* Same as above. */ + KEEP (strlen ((*pa5_7)[0]) > sizeof *pa5_7); + KEEP (strlen ((*pa5_7)[i]) > sizeof *pa5_7); + } + +void keep_global_arrays_and_strings (int i) +{ + KEEP (strlen (i < 0 ? a3 : "") < 2); + KEEP (strlen (i < 0 ? a3 : "1") < 2); + KEEP (strlen (i < 0 ? a3 : "12") < 2); + KEEP (strlen (i < 0 ? a3 : "123") < 3); + + KEEP (strlen (i < 0 ? a7 : "") < 5); + KEEP (strlen (i < 0 ? a7 : "1") < 5); + KEEP (strlen (i < 0 ? a7 : "12") < 5); + KEEP (strlen (i < 0 ? a7 : "123") < 5); + KEEP (strlen (i < 0 ? a7 : "123456") < 6); + KEEP (strlen (i < 0 ? a7 : "1234567") < 6); + + /* Verify that a matrix is treated as a flat array even in a conditional + expression (i.e., don't assume that a7_3[0] is nul-terminated, even + though calling strlen() on such an array is undefined). */ + KEEP (strlen (i < 0 ? a7_3[0] : "") > 7); + KEEP (strlen (i < 0 ? a7_3[i] : "") > 7); +} + +void keep_member_arrays_obj (int i) +{ + KEEP (strlen (ma0_3_5_7[0][0][0].a3) < 2); + KEEP (strlen (ma0_3_5_7[0][0][1].a3) < 2); + KEEP (strlen (ma0_3_5_7[0][0][2].a3) < 2); + KEEP (strlen (ma0_3_5_7[0][0][6].a3) < 2); + + KEEP (strlen (ma0_3_5_7[1][0][0].a3) < 2); + KEEP (strlen (ma0_3_5_7[2][0][1].a3) < 2); + + KEEP (strlen (ma0_3_5_7[1][1][0].a3) < 2); + KEEP (strlen (ma0_3_5_7[2][4][6].a3) < 2); + + KEEP (strlen (ma0_3_5_7[0][0][0].a5) < 4); + KEEP (strlen (ma0_3_5_7[0][0][1].a5) < 4); + KEEP (strlen (ma0_3_5_7[0][0][2].a5) < 4); + KEEP (strlen (ma0_3_5_7[0][0][6].a5) < 4); + + KEEP (strlen (ma0_3_5_7[1][0][0].a5) < 4); + KEEP (strlen (ma0_3_5_7[2][0][1].a5) < 4); + + KEEP (strlen (ma0_3_5_7[1][1][0].a5) < 4); + KEEP (strlen (ma0_3_5_7[2][4][6].a5) < 4); + + KEEP (strlen (ma0_3_5_7[0][0][0].a7_3[0]) < 2); + KEEP (strlen (ma0_3_5_7[2][4][6].a7_3[2]) < 2); + + KEEP (strlen (ma0_3_5_7[0][0][0].a5_7[0]) < 6); + KEEP (strlen (ma0_3_5_7[2][4][6].a5_7[4]) < 6); + + /* Again, verify that the .a3 array isn't assumed to necessarily + be nul-terminated. */ + KEEP (strlen (ma0_3_5_7[0][0][0].a3) > 2); + KEEP (strlen (ma0_3_5_7[0][0][6].a3) > 2); + KEEP (strlen (ma0_3_5_7[0][0][i].a3) > 2); +} + +void keep_member_arrays_ptr (struct MemArrays0 *ma0, + struct MemArraysX *max, + struct MemArrays7 *ma7, + int i) +{ + KEEP (strlen (ma0->a7_3[0]) > 0); + KEEP (strlen (ma0->a7_3[0]) < 2); + KEEP (strlen (ma0->a7_3[1]) < 2); + KEEP (strlen (ma0->a7_3[6]) < 2); + KEEP (strlen (ma0->a7_3[6]) < 2); + KEEP (strlen (ma0->a7_3[i]) > 0); + KEEP (strlen (ma0->a7_3[i]) < 2); + KEEP (strlen (ma0->a7_3[i]) < 2); + + /* Again, verify that the member array isn't assumed to necessarily + be nul-terminated. */ + KEEP (strlen (ma0->a7_3[0]) > sizeof ma0->a7_3); + KEEP (strlen (ma0->a7_3[i]) > sizeof ma0->a7_3); + + KEEP (strlen (ma0->a5_7[0]) < 5); + KEEP (strlen (ma0[0].a5_7[0]) < 5); + KEEP (strlen (ma0[1].a5_7[0]) < 5); + KEEP (strlen (ma0[9].a5_7[0]) < 5); + KEEP (strlen (ma0[9].a5_7[4]) < 5); + KEEP (strlen (ma0[i].a5_7[4]) < 5); + KEEP (strlen (ma0[i].a5_7[i]) < 5); + + /* Same as above. */ + KEEP (strlen (ma0[i].a5_7[i]) > sizeof ma0[i].a5_7); + + KEEP (strlen (ma0->a0) < DIFF_MAX - 2); + KEEP (strlen (ma0->a0) < 999); + KEEP (strlen (ma0->a0) < 1); + + KEEP (strlen (max->ax) < DIFF_MAX - 2); + KEEP (strlen (max->ax) < 999); + KEEP (strlen (max->ax) < 1); + + KEEP (strlen (ma7->a7) < DIFF_MAX - 2); + KEEP (strlen (ma7->a7) < 999); + KEEP (strlen (ma7->a7) < 1); +} + +void keep_pointers (const char *s) +{ + KEEP (strlen (ptr) < DIFF_MAX - 2); + KEEP (strlen (ptr) < 999); + KEEP (strlen (ptr) < 1); + + KEEP (strlen (s) < DIFF_MAX - 2); + KEEP (strlen (s) < 999); + KEEP (strlen (s) < 1); +} + + +/* { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated_" 0 "optimized" } } + { dg-final { scan-tree-dump-times "call_in_false_branch_not_eliminated_" 0 "optimized" } } + + { dg-final { scan-tree-dump-times "call_made_in_true_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 119 "optimized" } } + { dg-final { scan-tree-dump-times "call_made_in_false_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 119 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-41.c b/SingleSource/Regression/C/gcc-dg/strlenopt-41.c new file mode 100644 index 0000000000..c5e8eb6d8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-41.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/83671 - fix for false positive reported by + -Wstringop-overflow does not work with inlining + Verify that the length the empty string is folded to zero even at -O1 + regardless of offset into it. + Also verify that the length of a non-empty string isn't folded given + a variable offset. + { dg-do compile } + { dg-options "-O1 -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +inline unsigned length (const char *s) +{ + return __builtin_strlen (s); +} + +void check_length_cst (int i) +{ + unsigned len = length (&""[i]); + + if (len) + __builtin_abort (); +} + +void check_length_var (int i) +{ + unsigned len = length (&"1"[i]); + + if (len != 1) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-times "abort" 1 "optimized" } } + { dg-final { scan-tree-dump-times "strlen" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-42.c b/SingleSource/Regression/C/gcc-dg/strlenopt-42.c new file mode 100644 index 0000000000..019b89e756 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-42.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/83781 - Bootstrap failed on x86 with --with-arch=corei7 + --with-cpu=corei7 + Verify that the upper bound of the size of an array of pointers + to strings isn't considered to be the upper bound of the lengths + of the pointed-to strings. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +const char* const ap[32] = { "1", "12", "123" }; + +char d4[4]; +char d7[7]; + +void nowarn_range_ptr_var_1 (int i) +{ + __builtin_sprintf (d4, "%s", ap[i]); +} + +void nowarn_range_ptr_var_2 (int i, int j) +{ + __builtin_sprintf (d7, "%s%s", ap[i], ap[j]); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-43.c b/SingleSource/Regression/C/gcc-dg/strlenopt-43.c new file mode 100644 index 0000000000..13539fcb86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-43.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/83896 - ice in get_string_len on a call to strlen + with non-constant length + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +extern char a[5]; +extern char b[]; + +void f (void) +{ + if (strlen (b) != 4) + memcpy (a, b, sizeof a); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-44.c b/SingleSource/Regression/C/gcc-dg/strlenopt-44.c new file mode 100644 index 0000000000..0af78acaf1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-44.c @@ -0,0 +1,92 @@ +/* PR tree-optimization/86083 - handle non-constant assignments in strlen + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +#include "range.h" +#include "strlenopt.h" + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ASSERT_ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +/* Macro to emit a call to a function named + call_made_in_{true,false}_branch_on_line_NNN() + for each call that's expected to be retained. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that the expected number of both kinds of calls appears in output + (a pair for each line with the invocation of the KEEP() macro. */ +#define ASSERT_KEEP(expr) \ + if (expr) \ + FAIL (made_in_true_branch); \ + else \ + FAIL (made_in_false_branch) + + +#define ELIM(init, i, c, res) \ + do { \ + char a[] = init; \ + a[i] = c; \ + ASSERT_ELIM (strlen (a) == res); \ + } while (0) + +#define KEEP(init, i, c, res) \ + do { \ + char a[] = init; \ + a[i] = c; \ + ASSERT_KEEP (strlen (a) == res); \ + } while (0) + + +void test_elim_range (char c) +{ + ELIM ("1", 0, UR (1, 2), 1); + ELIM ("1", 0, UR (1, 127), 1); + ELIM ("1", 0, UR ('0', '9'), 1); + + ELIM ("12", 0, UR (1, 127), 2); + ELIM ("12", 1, UR (1, 127), 2); + + ELIM ("123", 0, UR (1, 9), 3); + ELIM ("123", 1, UR (10, 99), 3); + ELIM ("123", 2, UR (100, 127), 3); +} + +void test_elim_anti_range (const char *s) +{ + char c = *s++; + ELIM ("123", 0, c ? c : 'x', 3); + + c = *s++; + ELIM ("1234", 1, c ? c : 'y', 4); + + c = *s++; + ELIM ("123", 2, c ? c : 'z', 3); +} + +#line 1000 + +void test_keep (void) +{ + size_t uchar_max = (unsigned char)-1; + + KEEP ("1", 0, UR (1, uchar_max + 1), 1); + KEEP ("1\0\3", 1, UR (1, 2), 2); +} + +/* { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated_" 0 "optimized" } } + + { dg-final { scan-tree-dump-times "call_made_in_true_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 2 "optimized" } } + { dg-final { scan-tree-dump-times "call_made_in_false_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-45.c b/SingleSource/Regression/C/gcc-dg/strlenopt-45.c new file mode 100644 index 0000000000..31c1e538f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-45.c @@ -0,0 +1,231 @@ +/* PR tree-optimization/81384 - built-in form of strnlen missing + Test to verify that strnlen built-in expansion works correctly + in the absence of tree strlen optimization. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-stringop-overflow -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern size_t strnlen (const char *, size_t); + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +/* Macro to emit a call to a function named + call_made_in_{true,false}_branch_on_line_NNN() + for each call that's expected to be retained. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that the expected number of both kinds of calls appears in output + (a pair for each line with the invocation of the KEEP() macro. */ +#define KEEP(expr) \ + if (expr) \ + FAIL (made_in_true_branch); \ + else \ + FAIL (made_in_false_branch) + +extern char c; +extern char a1[1]; +extern char a3[3]; +extern char a5[5]; +extern char a3_7[3][7]; +extern char ax[]; + +void elim_strnlen_arr_cst (void) +{ + /* The length of a string stored in a one-element array must be zero. + The result reported by strnlen() for such an array can be non-zero + only when the bound is equal to 1 (in which case the result must + be one). */ + ELIM (strnlen (&c, 0) == 0); + ELIM (strnlen (&c, 1) < 2); + ELIM (strnlen (&c, 2) == 0); + ELIM (strnlen (&c, 9) == 0); + ELIM (strnlen (&c, PTRDIFF_MAX) == 0); + ELIM (strnlen (&c, SIZE_MAX) == 0); + ELIM (strnlen (&c, -1) == 0); + + ELIM (strnlen (a1, 0) == 0); + ELIM (strnlen (a1, 1) < 2); + ELIM (strnlen (a1, 2) == 0); + ELIM (strnlen (a1, 9) == 0); + ELIM (strnlen (a1, PTRDIFF_MAX) == 0); + ELIM (strnlen (a1, SIZE_MAX) == 0); + ELIM (strnlen (a1, -1) == 0); + + ELIM (strnlen (a3, 0) == 0); + ELIM (strnlen (a3, 1) < 2); + ELIM (strnlen (a3, 2) < 3); + ELIM (strnlen (a3, 3) < 4); + ELIM (strnlen (a3, 9) < 4); + ELIM (strnlen (a3, PTRDIFF_MAX) < 4); + ELIM (strnlen (a3, SIZE_MAX) < 4); + ELIM (strnlen (a3, -1) < 4); + + ELIM (strnlen (a3_7[0], 0) == 0); + ELIM (strnlen (a3_7[0], 1) < 2); + ELIM (strnlen (a3_7[0], 2) < 3); + ELIM (strnlen (a3_7[0], 3) < 4); + ELIM (strnlen (a3_7[0], 9) <= 9); + ELIM (strnlen (a3_7[0], PTRDIFF_MAX) <= sizeof a3_7); + ELIM (strnlen (a3_7[0], SIZE_MAX) <= sizeof a3_7); + ELIM (strnlen (a3_7[0], -1) <= sizeof a3_7); + + ELIM (strnlen (a3_7[2], 0) == 0); + ELIM (strnlen (a3_7[2], 1) < 2); + ELIM (strnlen (a3_7[2], 2) < 3); + ELIM (strnlen (a3_7[2], 3) < 4); + ELIM (strnlen (a3_7[2], 9) <= 9); + ELIM (strnlen (a3_7[2], PTRDIFF_MAX) < sizeof a3_7); + ELIM (strnlen (a3_7[2], SIZE_MAX) < sizeof a3_7); + ELIM (strnlen (a3_7[2], -1) < sizeof a3_7); + + ELIM (strnlen ((char*)a3_7, 0) == 0); + ELIM (strnlen ((char*)a3_7, 1) < 2); + ELIM (strnlen ((char*)a3_7, 2) < 3); + ELIM (strnlen ((char*)a3_7, 3) < 4); + ELIM (strnlen ((char*)a3_7, 9) < 10); + ELIM (strnlen ((char*)a3_7, 19) < 20); + ELIM (strnlen ((char*)a3_7, 21) <= sizeof a3_7); + ELIM (strnlen ((char*)a3_7, 23) <= sizeof a3_7); + ELIM (strnlen ((char*)a3_7, PTRDIFF_MAX) <= sizeof a3_7); + ELIM (strnlen ((char*)a3_7, SIZE_MAX) <= sizeof a3_7); + ELIM (strnlen ((char*)a3_7, -1) <= sizeof a3_7); + + ELIM (strnlen (ax, 0) == 0); + ELIM (strnlen (ax, 1) < 2); + ELIM (strnlen (ax, 2) < 3); + ELIM (strnlen (ax, 9) < 10); + ELIM (strnlen (ax, PTRDIFF_MAX) < PTRDIFF_MAX); + ELIM (strnlen (ax, SIZE_MAX) < PTRDIFF_MAX); + ELIM (strnlen (ax, -1) < PTRDIFF_MAX); +} + + +void elim_strnlen_str_cst (void) +{ + const char *s0 = ""; + const char *s1 = "1"; + const char *s3 = "123"; + + ELIM (strnlen (s0, 0) == 0); + ELIM (strnlen (s0, 1) == 0); + ELIM (strnlen (s0, 9) == 0); + ELIM (strnlen (s0, PTRDIFF_MAX) == 0); + ELIM (strnlen (s0, SIZE_MAX) == 0); + ELIM (strnlen (s0, -1) == 0); + + ELIM (strnlen (s1, 0) == 0); + ELIM (strnlen (s1, 1) == 1); + ELIM (strnlen (s1, 9) == 1); + ELIM (strnlen (s1, PTRDIFF_MAX) == 1); + ELIM (strnlen (s1, SIZE_MAX) == 1); + ELIM (strnlen (s1, -2) == 1); + + ELIM (strnlen (s3, 0) == 0); + ELIM (strnlen (s3, 1) == 1); + ELIM (strnlen (s3, 2) == 2); + ELIM (strnlen (s3, 3) == 3); + ELIM (strnlen (s3, 9) == 3); + ELIM (strnlen (s3, PTRDIFF_MAX) == 3); + ELIM (strnlen (s3, SIZE_MAX) == 3); + ELIM (strnlen (s3, -2) == 3); +} + +void elim_strnlen_range (char *s) +{ + const char *s0 = ""; + const char *s1 = "1"; + const char *s3 = "123"; + + size_t n_0_1 = (size_t)s & 1; + size_t n_0_2 = ((size_t)s & 3) < 3 ? ((size_t)s & 3) : 2; + size_t n_0_3 = (size_t)s & 3; + size_t n_1_2 = n_0_1 + 1; + + ELIM (strnlen (s0, n_0_1) == 0); + ELIM (strnlen (s0, n_0_2) == 0); + ELIM (strnlen (s0, n_1_2) == 0); + + ELIM (strnlen (s1, n_0_1) < 2); + ELIM (strnlen (s1, n_0_2) < 2); + ELIM (strnlen (s1, n_0_3) < 2); + + ELIM (strnlen (s1, n_1_2) > 0); + ELIM (strnlen (s1, n_1_2) < 2); + + ELIM (strnlen (s3, n_0_1) < 2); + ELIM (strnlen (s3, n_0_2) < 3); + ELIM (strnlen (s3, n_0_3) < 4); + + ELIM (strnlen (s3, n_1_2) > 0); + ELIM (strnlen (s3, n_1_2) < 4); +} + + +#line 1000 + +void keep_strnlen_arr_cst (void) +{ + KEEP (strnlen (&c, 1) == 0); + KEEP (strnlen (&c, 1) == 1); + + KEEP (strnlen (a1, 1) == 0); + KEEP (strnlen (a1, 1) == 1); + + KEEP (strnlen (ax, 9) < 9); +} + +struct FlexArrays +{ + char c; + char a0[0]; /* Access to internal zero-length arrays are undefined. */ + char a1[1]; +}; + +void keep_strnlen_memarr_cst (struct FlexArrays *p) +{ + KEEP (strnlen (&p->c, 1) == 0); + KEEP (strnlen (&p->c, 1) == 1); + +#if 0 + /* Accesses to internal zero-length arrays are undefined so avoid + exercising them. */ + KEEP (strnlen (p->a0, 1) == 0); + KEEP (strnlen (p->a0, 1) == 1); + KEEP (strnlen (p->a0, 9) < 9); +#endif + + KEEP (strnlen (p->a1, 1) == 0); + KEEP (strnlen (p->a1, 1) == 1); + + KEEP (strnlen (p->a1, 2) == 0); + KEEP (strnlen (p->a1, 2) == 1); + KEEP (strnlen (p->a1, 2) == 2); + + KEEP (strnlen (p->a1, 9) < 9); +} + +/* { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated_" 0 "optimized" } } + + { dg-final { scan-tree-dump-times "call_made_in_true_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 13 "optimized" } } + { dg-final { scan-tree-dump-times "call_made_in_false_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 13 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-46.c b/SingleSource/Regression/C/gcc-dg/strlenopt-46.c new file mode 100644 index 0000000000..170b901bb7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-46.c @@ -0,0 +1,148 @@ +/* PR tree-optimization/86204 - wrong strlen result after prior strnlen + { dg-do run } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define NOIPA __attribute__ ((noipa)) + +char a[] = "12345"; + +NOIPA void f0 (void) +{ + unsigned n0 = strnlen (a, 0); + unsigned n1 = strlen (a); + + if (n0 != 0 || n1 != 5) + abort (); +} + +NOIPA void f1 (void) +{ + unsigned n0 = strnlen (a, 1); + unsigned n1 = strlen (a); + + if (n0 != 1 || n1 != 5) + abort (); +} + +NOIPA void f2 (void) +{ + unsigned n0 = strnlen (a, 2); + unsigned n1 = strlen (a); + + if (n0 != 2 || n1 != 5) + abort (); +} + +NOIPA void f3 (void) +{ + unsigned n0 = strnlen (a, 3); + unsigned n1 = strlen (a); + + if (n0 != 3 || n1 != 5) + abort (); +} + +NOIPA void f4 (void) +{ + unsigned n0 = strnlen (a, 4); + unsigned n1 = strlen (a); + + if (n0 != 4 || n1 != 5) + abort (); +} + +NOIPA void f5 (void) +{ + unsigned n0 = strnlen (a, 5); + unsigned n1 = strlen (a); + + if (n0 != 5 || n1 != 5) + abort (); +} + +NOIPA void f6 (void) +{ + unsigned n0 = strnlen (a, 6); + unsigned n1 = strlen (a); + + if (n0 != 5 || n1 != 5) + abort (); +} + +NOIPA void fx (unsigned n) +{ + unsigned n0 = strnlen (a, n); + unsigned n1 = strlen (a); + + unsigned min = n < 5 ? n : 5; + if (n0 != min || n1 != 5) + abort (); +} + +NOIPA void g2 (void) +{ + strcpy (a, "123"); + unsigned n0 = strnlen (a, 2); + unsigned n1 = strlen (a); + + if (n0 != 2 || n1 != 3) + abort (); +} + +NOIPA void g7 (void) +{ + strcpy (a, "123"); + unsigned n0 = strnlen (a, 7); + unsigned n1 = strlen (a); + + if (n0 != 3 || n1 != 3) + abort (); +} + +NOIPA void gx (unsigned n) +{ + strcpy (a, "123"); + unsigned n0 = strnlen (a, n); + unsigned n1 = strlen (a); + + unsigned min = n < 3 ? n : 3; + if (n0 != min || n1 != 3) + abort (); +} + +int main (void) +{ + f0 (); + f1 (); + f2 (); + f3 (); + f4 (); + f5 (); + f6 (); + fx (2); + fx (7); + + g2 (); + g7 (); + gx (2); + gx (7); +} + + +/* For targets like Solaris 10 that don't define strnlen(). */ + +NOIPA size_t +strnlen (const char *s, size_t n) +{ + size_t len = 0; + while (*s++ && n--) + ++len; + return len; +} + +/* Verify that at least some of the 11 calls to strnlen have been + folded (this number of folded calls may need to be adjusted up + if the strnlen optimization improves, but it should not go down. + { dg-final { scan-tree-dump-times "= strnlen" 7 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-47.c b/SingleSource/Regression/C/gcc-dg/strlenopt-47.c new file mode 100644 index 0000000000..68945c7c1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-47.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/86400 - set::set::set= sizeof a) + abort(); +} + +void g (void) +{ + extern char b[3][2][1]; + int n = strlen (b[2][1]); + if (n >= sizeof b) + abort(); +} + +void h (void) +{ + extern char c[4][3][2][1]; + int n = strlen (c[3][2][1]); + if (n >= sizeof c) + abort(); +} + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "optimized" } } + { dg-final { scan-tree-dump-times "abort" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-49.c b/SingleSource/Regression/C/gcc-dg/strlenopt-49.c new file mode 100644 index 0000000000..bbea0e2db7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-49.c @@ -0,0 +1,53 @@ +/* PR tree-optimization/86428 - strlen of const array initialized with + a string of the same length not folded + { dg-do compile } + { dg-options "-O0 -Wall -fdump-tree-gimple" } */ + +#include "strlenopt.h" + +const char a1[1] = "\0"; +const char a2[2] = "1\0"; +const char a3[3] = "12\0"; +const char a8[8] = "1234567\0"; +const char a9[9] = "12345678\0"; + +const char ax[9] = "12345678\0\0\0\0"; /* { dg-warning "initializer-string for array of 'char' is too long" } */ +const char ay[9] = "\00012345678\0\0\0\0"; /* { dg-warning "initializer-string for array of 'char' is too long" } */ + + +int len1 (void) +{ + size_t len0 = strlen (a1); + return len0; +} + +int len (void) +{ + size_t len = strlen (a2) + strlen (a3) + strlen (a8) + strlen (a9); + return len; +} + +int lenx (void) +{ + size_t lenx = strlen (ax); + return lenx; +} + +int leny (void) +{ + size_t leny = strlen (ay); + return leny; +} + +int cmp88 (void) +{ + int cmp88 = memcmp (a8, "1234567\0", sizeof a8); + return cmp88; +} + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } } + { dg-final { scan-tree-dump-times "len0 = 0;" 1 "gimple" } } + { dg-final { scan-tree-dump-times "len = 18;" 1 "gimple" } } + { dg-final { scan-tree-dump-times "lenx = 8;" 1 "gimple" } } + { dg-final { scan-tree-dump-times "leny = 0;" 1 "gimple" } } + { dg-final { scan-tree-dump-times "cmp88 = 0;" 1 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-4g.c b/SingleSource/Regression/C/gcc-dg/strlenopt-4g.c new file mode 100644 index 0000000000..bf8aebb2ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-4g.c @@ -0,0 +1,13 @@ +/* This test needs runtime that provides stpcpy function. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define USE_GNU +#include "strlenopt-4.c" + +/* { dg-final { scan-tree-dump-times "strlen \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 5 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-4gf.c b/SingleSource/Regression/C/gcc-dg/strlenopt-4gf.c new file mode 100644 index 0000000000..16eb5b0454 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-4gf.c @@ -0,0 +1,18 @@ +/* This test needs runtime that provides stpcpy and __*_chk functions. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#define USE_GNU +#define FORTIFY_SOURCE 2 +#include "strlenopt-4.c" + +/* { dg-final { scan-tree-dump-times "strlen \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__memcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__strcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__strcat_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "__stpcpy_chk \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 5 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-5.c b/SingleSource/Regression/C/gcc-dg/strlenopt-5.c new file mode 100644 index 0000000000..5a31322bfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-5.c @@ -0,0 +1,56 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +foo (char *p, const char *q) +{ + char *e = strchr (p, '\0'); + strcat (p, q); + return e; +} + +__attribute__((noinline, noclone)) char * +bar (char *p) +{ + memcpy (p, "abcd", 5); + return strchr (p, '\0'); +} + +__attribute__((noinline, noclone)) void +baz (char *p) +{ + char *e = strchr (p, '\0'); + strcat (e, "abcd"); +} + +char buf[64]; + +int +main () +{ + char *volatile p = buf; + const char *volatile q = "ij"; + memset (buf, 'v', 3); + if (foo (p, q) != buf + 3 + || memcmp (buf, "vvvij\0\0\0\0", 10) != 0) + abort (); + memset (buf, '\0', sizeof buf); + if (bar (p) != buf + 4 + || memcmp (buf, "abcd\0\0\0\0\0", 10) != 0) + abort (); + memset (buf, 'v', 2); + memset (buf + 2, '\0', -2 + sizeof buf); + baz (p); + if (memcmp (buf, "vvabcd\0\0\0", 10) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-50.c b/SingleSource/Regression/C/gcc-dg/strlenopt-50.c new file mode 100644 index 0000000000..8e7c9dbd93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-50.c @@ -0,0 +1,116 @@ +/* PR tree-optimization/86415 - strlen() not folded for substrings + within constant arrays + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-gimple -fdump-tree-ccp" } */ + +#include "strlenopt.h" + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name) CAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +#define T(s, n) ELIM (strlen (s) == n) + +/* 11111 + 0 1 23 4 567 8 901234 */ +#define STR "1\00012\000123\0001234\0" + +const char a[] = STR; +const char b[20] = STR; + +void test_literal (void) +{ + /* Verify that strlen() of substrings within a string literal are + correctly folded. */ + T (STR, 1); T (STR + 1, 0); T (STR + 2, 2); T (STR + 3, 1); + T (STR + 4, 0); T (STR + 5, 3); T (STR + 6, 2); T (STR + 7, 1); + T (STR + 8, 0); T (STR + 9, 4); T (STR + 10, 3); T (STR + 11, 2); + T (STR + 12, 1); T (STR + 13, 0); T (STR + 14, 0); + + T (&(STR[0]), 1); T (&(STR[ 1]), 0); T (&(STR[ 2]), 2); + T (&(STR[ 3]), 1); T (&(STR[ 4]), 0); T (&(STR[ 5]), 3); + T (&(STR[ 6]), 2); T (&(STR[ 7]), 1); T (&(STR[ 8]), 0); + T (&(STR[ 9]), 4); T (&(STR[10]), 3); T (&(STR[11]), 2); + T (&(STR[12]), 1); T (&(STR[13]), 0); T (&(STR[14]), 0); + + T (&(STR[0]) + 1, 0); T (&(STR[ 1]) + 1, 2); T (&(STR[ 2]) + 1, 1); + T (&(STR[ 3]) + 1, 0); T (&(STR[ 4]) + 1, 3); T (&(STR[ 5]) + 1, 2); + T (&(STR[ 6]) + 1, 1); T (&(STR[ 7]) + 1, 0); T (&(STR[ 8]) + 1, 4); + T (&(STR[ 9]) + 1, 3); T (&(STR[10]) + 1, 2); T (&(STR[11]) + 1, 1); + T (&(STR[12]) + 1, 0); T (&(STR[13]) + 1, 0); T (&(STR[13]) - 13, 1); + T (&(STR[13]) - 12, 0); T (&(STR[13]) - 11, 2); T (&(STR[13]) - 10, 1); +} + +void test_array (void) +{ + /* Verify that strlen() of substrings within a fully initialized + array are correctly folded. */ + T (a, 1); T (a + 1, 0); T (a + 2, 2); T (a + 3, 1); + T (a + 4, 0); T (a + 5, 3); T (a + 6, 2); T (a + 7, 1); + T (a + 8, 0); T (a + 9, 4); T (a + 10, 3); T (a + 11, 2); + T (a + 12, 1); T (a + 13, 0); T (a + 14, 0); + + /* Verify that strlen() of substrings within a partially initialized + array are also correctly folded, including those referring to + the empty substrings in the implicitly initialized elements. */ + T (b, 1); T (b + 1, 0); T (b + 2, 2); T (b + 3, 1); + T (b + 4, 0); T (b + 5, 3); T (b + 6, 2); T (b + 7, 1); + T (b + 8, 0); T (b + 9, 4); T (b + 10, 3); T (b + 11, 2); + T (b + 12, 1); T (b + 13, 0); T (b + 14, 0); T (b + 15, 0); + T (b + 16, 0); T (b + 17, 0); T (b + 18, 0); T (b + 19, 0); +} + +void test_array_ref_plus (void) +{ + /* Verify that strlen() of substrings within a fully initialized + array referred to by array indices with offsets are correctly + folded. */ + T (&a[ 0], 1); T (&a[ 0] + 1, 0); + T (&a[ 1], 0); T (&a[ 1] + 1, 2); + T (&a[ 2], 2); T (&a[ 2] + 1, 1); T (&a[ 2] + 2, 0); + T (&a[ 3], 1); T (&a[ 3] + 1, 0); + T (&a[ 4], 0); T (&a[ 4] + 1, 3); + T (&a[ 5], 3); T (&a[ 5] + 1, 2); + T (&a[ 5] + 2, 1); T (&a[ 5] + 3, 0); T (&a[ 5] + 4, 4); + T (&a[ 6], 2); T (&a[ 6] + 1, 1); T (&a[ 6] + 2, 0); + T (&a[ 7], 1); T (&a[ 7] + 1, 0); + T (&a[ 8], 0); T (&a[ 8] + 1, 4); + T (&a[ 9], 4); T (&a[ 9] + 1, 3); T (&a[ 9] + 2, 2); + T (&a[ 9] + 3, 1); T (&a[ 9] + 4, 0); T (&a[ 9] + 5, 0); + T (&a[10], 3); T (&a[10] + 1, 2); T (&a[10] + 2, 1); + T (&a[10] + 3, 0); T (&a[10] + 4, 0); + T (&a[11], 2); T (&a[11] + 1, 1); T (&a[11] + 2, 0); + T (&a[12], 1); T (&a[12] + 1, 0); T (&a[12] + 2, 0); + T (&a[13], 0); T (&a[13] + 1, 0); + T (&a[14], 0); +} + +void test_array_ref (void) +{ + T (&a[ 0], 1); T (&a[ 1], 0); T (&a[ 2], 2); T (&a[ 3], 1); + T (&a[ 4], 0); T (&a[ 5], 3); T (&a[ 6], 2); T (&a[ 7], 1); + T (&a[ 8], 0); T (&a[ 9], 4); T (&a[10], 3); T (&a[11], 2); + T (&a[12], 1); T (&a[13], 0); T (&a[14], 0); + + T (&b[ 0], 1); T (&b[ 1], 0); T (&b[ 2], 2); T (&b[ 3], 1); + T (&b[ 4], 0); T (&b[ 5], 3); T (&b[ 6], 2); T (&b[ 7], 1); + T (&b[ 8], 0); T (&b[ 9], 4); T (&b[10], 3); T (&b[11], 2); + T (&b[12], 1); T (&b[13], 0); T (&b[14], 0); T (&b[15], 0); + T (&b[16], 0); T (&b[17], 0); T (&b[18], 0); T (&b[19], 0); +} + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } } + { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated" 0 "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-51.c b/SingleSource/Regression/C/gcc-dg/strlenopt-51.c new file mode 100644 index 0000000000..22a89385f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-51.c @@ -0,0 +1,87 @@ +/* PR tree-optimization/77357 - strlen of constant strings not folded + { dg-do compile } + { dg-options "-O0 -Wall -fdump-tree-gimple" } */ + +#include "strlenopt.h" + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name, counter) \ + CAT (CAT (CAT (call_ ## name ##_on_line_, __LINE__), _), counter) + +#define FAIL(name, counter) do { \ + extern void FAILNAME (name, counter) (void); \ + FAILNAME (name, counter)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated, __COUNTER__); else (void)0 + +#define T(s, n) ELIM (strlen (s) == n) + + +struct S +{ + char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8], a9[9]; +}; + +#define S0 "" +#define S1 "1" +#define S2 "12" +#define S3 "123" +#define S4 "1234" +#define S5 "12345" +#define S6 "123456" +#define S7 "1234567" +#define S8 "12345678" + +const char a9[][9] = { S0, S1, S2, S3, S4, S5, S6, S7, S8 }; + +void test_elim_a9 (unsigned i) +{ + ELIM (strlen (&a9[0][i]) > 0); + ELIM (strlen (&a9[1][i]) > 1); + ELIM (strlen (&a9[2][i]) > 2); + ELIM (strlen (&a9[3][i]) > 3); + ELIM (strlen (&a9[4][i]) > 4); + ELIM (strlen (&a9[5][i]) > 5); + ELIM (strlen (&a9[6][i]) > 6); + ELIM (strlen (&a9[7][i]) > 7); + ELIM (strlen (&a9[8][i]) > 8); +} + +const char a9_9[][9][9] = { + { S0, S1, S2, S3, S4, S5, S6, S7, S8 }, + { S1, S2, S3, S4, S5, S6, S7, S8, S0 }, + { S2, S3, S4, S5, S6, S7, S8, S0, S1 }, + { S3, S4, S5, S6, S7, S8, S0, S1, S2 }, + { S4, S5, S6, S7, S8, S0, S1, S2, S3 }, + { S5, S6, S7, S8, S0, S1, S2, S3, S4 }, + { S6, S7, S8, S0, S1, S2, S3, S4, S5 }, + { S7, S8, S0, S1, S2, S3, S4, S5, S6 }, + { S8, S0, S1, S2, S3, S4, S5, S6, S7 } +}; + +void test_elim_a9_9 (unsigned i) +{ +#undef T +#define T(I) \ + ELIM (strlen (&a9_9[I][0][i]) > (0 + I) % 9); \ + ELIM (strlen (&a9_9[I][1][i]) > (1 + I) % 9); \ + ELIM (strlen (&a9_9[I][2][i]) > (2 + i) % 9); \ + ELIM (strlen (&a9_9[I][3][i]) > (3 + I) % 9); \ + ELIM (strlen (&a9_9[I][4][i]) > (4 + I) % 9); \ + ELIM (strlen (&a9_9[I][5][i]) > (5 + I) % 9); \ + ELIM (strlen (&a9_9[I][6][i]) > (6 + I) % 9); \ + ELIM (strlen (&a9_9[I][7][i]) > (7 + I) % 9); \ + ELIM (strlen (&a9_9[I][8][i]) > (8 + I) % 9) + + T (0); T (1); T (2); T (3); T (4); T (5); T (6); T (7); T (8); +} + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-52.c b/SingleSource/Regression/C/gcc-dg/strlenopt-52.c new file mode 100644 index 0000000000..97b3da7cd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-52.c @@ -0,0 +1,288 @@ +/* PR tree-optimization/77357 - strlen of constant strings not folded + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-gimple -fdump-tree-ccp" } */ + +#include "strlenopt.h" + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name) CAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +#define T(s, n) ELIM (strlen (s) == n) + + +struct S +{ + char a1[1], a2[2], a3[3], a4[4], a5[5], a6[6], a7[7], a8[8], a9[9]; +}; + +#define S0 "" +#define S1 "1" +#define S2 "12" +#define S3 "123" +#define S4 "1234" +#define S5 "12345" +#define S6 "123456" +#define S7 "1234567" +#define S8 "12345678" + +const char a9[][9] = { S0, S1, S2, S3, S4, S5, S6, S7, S8 }; + +const char a_1_9[1][9] = { S8 }; +const char a_2_9[2][9] = { S8, S7}; + +const char a9_9[][9][9] = { + { S0, S0, S0, S0, S0, S0, S0, S0, S0 }, + { S0, S1, S1, S1, S1, S1, S1, S1, S1 }, + { S0, S1, S2, S2, S2, S2, S2, S2, S2 }, + { S0, S1, S2, S3, S3, S3, S3, S3, S3 }, + { S0, S1, S2, S3, S4, S4, S4, S4, S4 }, + { S0, S1, S2, S3, S4, S5, S5, S5, S5 }, + { S0, S1, S2, S3, S4, S5, S6, S6, S6 }, + { S0, S1, S2, S3, S4, S5, S6, S7, S7 }, + { S0, S1, S2, S3, S4, S5, S6, S7, S8 } +}; + +const struct S s = { S0, S1, S2, S3, S4, S5, S6, S7, S8 }; + +const struct S sa[9] = { + { S0, S0, S0, S0, S0, S0, S0, S0, S0 }, + { S0, S1, S1, S1, S1, S1, S1, S1, S1 }, + { S0, S1, S2, S2, S2, S2, S2, S2, S2 }, + { S0, S1, S2, S3, S3, S3, S3, S3, S3 }, + { S0, S1, S2, S3, S4, S4, S4, S4, S4 }, + { S0, S1, S2, S3, S4, S5, S5, S5, S5 }, + { S0, S1, S2, S3, S4, S5, S6, S6, S6 }, + { S0, S1, S2, S3, S4, S5, S6, S7, S7 }, + { S0, S1, S2, S3, S4, S5, S6, S7, S8 } +}; + +const struct S sa3_5_7[3][5][7] = { + [1][2][3].a2 = S1, [1][3][5].a3 = S2, [2][4][5].a4 = S3 +}; + + +void test_global_array (void) +{ + T (a9[0], 0); T (a9[0] + 0, 0); T (a9[0] + 0, 0); T (a9[0] + 0, 0); + T (a9[1], 1); T (a9[1] + 1, 0); T (a9[1] + 1, 0); T (a9[1] + 1, 0); + T (a9[2], 2); + T (a9[2] + 1, 1); + T (a9[2] + 2, 0); + T (a9[2] + 2, 0); + + T (a9[3], 3); T (a9[3] + 1, 2); T (a9[3] + 2, 1); T (a9[3] + 3, 0); + T (a9[4], 4); T (a9[4] + 1, 3); T (a9[4] + 2, 2); T (a9[4] + 3, 1); + T (a9[5], 5); T (a9[5] + 1, 4); T (a9[5] + 2, 3); T (a9[5] + 3, 2); + T (a9[6], 6); T (a9[6] + 1, 5); T (a9[6] + 2, 4); T (a9[6] + 3, 3); + T (a9[7], 7); T (a9[7] + 1, 6); T (a9[7] + 2, 5); T (a9[7] + 3, 4); + T (a9[8], 8); T (a9[8] + 1, 7); T (a9[8] + 2, 6); T (a9[8] + 3, 5); + + T (a_1_9[0], 8); + T (a_1_9[0] + 1, 7); + T (a_1_9[0] + 7, 1); + T (a_1_9[0] + 8, 0); + + T (a_2_9[0], 8); + T (a_2_9[0] + 1, 7); + T (a_2_9[0] + 7, 1); + T (a_2_9[0] + 8, 0); + + T (a_2_9[1], 7); + T (a_2_9[1] + 1, 6); + T (a_2_9[1] + 6, 1); + T (a_2_9[1] + 7, 0); + T (a_2_9[1] + 8, 0); +} + +void test_global_array_array (void) +{ + T (a9_9[0][0], 0); T (a9_9[1][0], 0); T (a9_9[2][0], 0); + T (a9_9[0][1], 0); T (a9_9[1][1], 1); T (a9_9[2][1], 1); + T (a9_9[0][2], 0); T (a9_9[1][2], 1); T (a9_9[2][2], 2); + T (a9_9[0][3], 0); T (a9_9[1][3], 1); T (a9_9[2][3], 2); + T (a9_9[0][4], 0); T (a9_9[1][4], 1); T (a9_9[2][4], 2); + T (a9_9[0][5], 0); T (a9_9[1][5], 1); T (a9_9[2][5], 2); + T (a9_9[0][6], 0); T (a9_9[1][6], 1); T (a9_9[2][6], 2); + T (a9_9[0][7], 0); T (a9_9[1][7], 1); T (a9_9[2][7], 2); + T (a9_9[0][8], 0); T (a9_9[1][8], 1); T (a9_9[2][8], 2); + + T (a9_9[3][0], 0); T (a9_9[4][0], 0); T (a9_9[5][0], 0); + T (a9_9[3][1], 1); T (a9_9[4][1], 1); T (a9_9[5][1], 1); + T (a9_9[3][2], 2); T (a9_9[4][2], 2); T (a9_9[5][2], 2); + T (a9_9[3][3], 3); T (a9_9[4][3], 3); T (a9_9[5][3], 3); + T (a9_9[3][4], 3); T (a9_9[4][4], 4); T (a9_9[5][4], 4); + T (a9_9[3][5], 3); T (a9_9[4][5], 4); T (a9_9[5][5], 5); + T (a9_9[3][6], 3); T (a9_9[4][6], 4); T (a9_9[5][6], 5); + T (a9_9[3][7], 3); T (a9_9[4][7], 4); T (a9_9[5][7], 5); + T (a9_9[3][8], 3); T (a9_9[4][8], 4); T (a9_9[5][8], 5); + + T (a9_9[6][0], 0); T (a9_9[7][0], 0); T (a9_9[8][0], 0); + T (a9_9[6][1], 1); T (a9_9[7][1], 1); T (a9_9[8][1], 1); + T (a9_9[6][2], 2); T (a9_9[7][2], 2); T (a9_9[8][2], 2); + T (a9_9[6][3], 3); T (a9_9[7][3], 3); T (a9_9[8][3], 3); + T (a9_9[6][4], 4); T (a9_9[7][4], 4); T (a9_9[8][4], 4); + T (a9_9[6][5], 5); T (a9_9[7][5], 5); T (a9_9[8][5], 5); + T (a9_9[6][6], 6); T (a9_9[7][6], 6); T (a9_9[8][6], 6); + T (a9_9[6][7], 6); T (a9_9[7][7], 7); T (a9_9[8][7], 7); + T (a9_9[6][8], 6); T (a9_9[7][8], 7); T (a9_9[8][8], 8); + + + T (a9_9[0][0] + 1, 0); T (a9_9[1][0] + 1, 0); T (a9_9[2][0] + 2, 0); + T (a9_9[0][1] + 2, 0); T (a9_9[1][1] + 1, 0); T (a9_9[2][1] + 2, 0); + T (a9_9[0][2] + 3, 0); T (a9_9[1][2] + 1, 0); T (a9_9[2][2] + 2, 0); + T (a9_9[0][3] + 4, 0); T (a9_9[1][3] + 1, 0); T (a9_9[2][3] + 2, 0); + T (a9_9[0][4] + 5, 0); T (a9_9[1][4] + 1, 0); T (a9_9[2][4] + 2, 0); + T (a9_9[0][5] + 6, 0); T (a9_9[1][5] + 1, 0); T (a9_9[2][5] + 2, 0); + T (a9_9[0][6] + 7, 0); T (a9_9[1][6] + 1, 0); T (a9_9[2][6] + 2, 0); + T (a9_9[0][7] + 8, 0); T (a9_9[1][7] + 1, 0); T (a9_9[2][7] + 2, 0); +} + +void test_global_struct (void) +{ + T (s.a1, 0); + T (s.a2, 1); + T (s.a3, 2); + T (s.a4, 3); + T (s.a5, 4); + T (s.a6, 5); + T (s.a7, 6); + T (s.a8, 7); + T (s.a9, 8); +} + +void test_global_struct_array (void) +{ + T (sa[0].a1, 0); T (sa[1].a1, 0); T (sa[2].a1, 0); T (sa[3].a1, 0); + T (sa[0].a2, 0); T (sa[1].a2, 1); T (sa[2].a2, 1); T (sa[3].a2, 1); + T (sa[0].a3, 0); T (sa[1].a3, 1); T (sa[2].a3, 2); T (sa[3].a3, 2); + T (sa[0].a4, 0); T (sa[1].a4, 1); T (sa[2].a4, 2); T (sa[3].a4, 3); + T (sa[0].a5, 0); T (sa[1].a5, 1); T (sa[2].a5, 2); T (sa[3].a5, 3); + T (sa[0].a6, 0); T (sa[1].a6, 1); T (sa[2].a6, 2); T (sa[3].a6, 3); + T (sa[0].a7, 0); T (sa[1].a7, 1); T (sa[2].a7, 2); T (sa[3].a7, 3); + T (sa[0].a8, 0); T (sa[1].a8, 1); T (sa[2].a8, 2); T (sa[3].a8, 3); + T (sa[0].a9, 0); T (sa[1].a9, 1); T (sa[2].a9, 2); T (sa[3].a9, 3); + + T (sa[4].a1, 0); T (sa[5].a1, 0); T (sa[6].a1, 0); T (sa[7].a1, 0); + T (sa[4].a2, 1); T (sa[5].a2, 1); T (sa[6].a2, 1); T (sa[7].a2, 1); + T (sa[4].a3, 2); T (sa[5].a3, 2); T (sa[6].a3, 2); T (sa[7].a3, 2); + T (sa[4].a4, 3); T (sa[5].a4, 3); T (sa[6].a4, 3); T (sa[7].a4, 3); + T (sa[4].a5, 4); T (sa[5].a5, 4); T (sa[6].a5, 4); T (sa[7].a5, 4); + T (sa[4].a6, 4); T (sa[5].a6, 5); T (sa[6].a6, 5); T (sa[7].a6, 5); + T (sa[4].a7, 4); T (sa[5].a7, 5); T (sa[6].a7, 6); T (sa[7].a7, 6); + T (sa[4].a8, 4); T (sa[5].a8, 5); T (sa[6].a8, 6); T (sa[7].a8, 7); + T (sa[4].a9, 4); T (sa[5].a9, 5); T (sa[6].a9, 6); T (sa[7].a9, 7); + + T (sa[8].a1, 0); + T (sa[8].a2, 1); T (sa[8].a2 + 1, 0); + T (sa[8].a3, 2); T (sa[8].a3 + 1, 1); T (sa[8].a3 + 2, 0); + T (sa[8].a4, 3); T (sa[8].a4 + 1, 2); T (sa[8].a4 + 2, 1); + T (sa[8].a5, 4); T (sa[8].a5 + 1, 3); T (sa[8].a5 + 2, 2); + T (sa[8].a6, 5); T (sa[8].a6 + 1, 4); T (sa[8].a6 + 2, 3); + T (sa[8].a7, 6); T (sa[8].a7 + 1, 5); T (sa[8].a7 + 2, 4); + T (sa[8].a8, 7); T (sa[8].a8 + 1, 6); T (sa[8].a8 + 2, 5); + T (sa[8].a9, 8); T (sa[8].a9 + 1, 7); T (sa[8].a9 + 2, 6); + + + T (sa3_5_7[1][2][3].a2, 1); + T (sa3_5_7[1][3][5].a3, 2); + T (sa3_5_7[2][4][5].a4, 3); + + T (sa3_5_7[0][0][0].a1, 0); + T (sa3_5_7[0][0][0].a2, 0); + T (sa3_5_7[0][0][0].a3, 0); + T (sa3_5_7[0][0][0].a4, 0); + T (sa3_5_7[0][0][0].a5, 0); + T (sa3_5_7[0][0][0].a6, 0); + T (sa3_5_7[0][0][0].a7, 0); + T (sa3_5_7[0][0][0].a8, 0); + T (sa3_5_7[0][0][0].a9, 0); + + T (sa3_5_7[0][0][1].a1, 0); + T (sa3_5_7[0][0][1].a2, 0); + T (sa3_5_7[0][0][1].a3, 0); + T (sa3_5_7[0][0][1].a4, 0); + T (sa3_5_7[0][0][1].a5, 0); + T (sa3_5_7[0][0][1].a6, 0); + T (sa3_5_7[0][0][1].a7, 0); + T (sa3_5_7[0][0][1].a8, 0); + T (sa3_5_7[0][0][1].a9, 0); + + T (sa3_5_7[0][1][0].a1, 0); + T (sa3_5_7[0][1][0].a2, 0); + T (sa3_5_7[0][1][0].a3, 0); + T (sa3_5_7[0][1][0].a4, 0); + T (sa3_5_7[0][1][0].a5, 0); + T (sa3_5_7[0][1][0].a6, 0); + T (sa3_5_7[0][1][0].a7, 0); + T (sa3_5_7[0][1][0].a8, 0); + T (sa3_5_7[0][1][0].a9, 0); + + T (sa3_5_7[1][0][0].a1, 0); + T (sa3_5_7[1][0][0].a2, 0); + T (sa3_5_7[1][0][0].a3, 0); + T (sa3_5_7[1][0][0].a4, 0); + T (sa3_5_7[1][0][0].a5, 0); + T (sa3_5_7[1][0][0].a6, 0); + T (sa3_5_7[1][0][0].a7, 0); + T (sa3_5_7[1][0][0].a8, 0); + T (sa3_5_7[1][0][0].a9, 0); +} + + +struct SS { + char a9[9][9]; + struct S sa9[9]; +}; + +const struct SS ssa[] = { + [1] = { + .a9 = { [3] = S3, [7] = S7 }, + .sa9 = { [5] = { .a5 = S4, .a7 = S6 } } + }, + [5] = { + .a9 = { [1] = S8, [5] = S4 }, + .sa9 = { [3] = { .a3 = S2, .a6 = S3 } } + } +}; + +void test_global_struct_struct_array (void) +{ + T (ssa[0].a9[0], 0); + T (ssa[0].a9[3], 0); + T (ssa[0].sa9[5].a5, 0); + T (ssa[0].sa9[5].a7, 0); + + T (ssa[1].a9[0], 0); + + T (ssa[1].a9[3], 3); + T (ssa[1].a9[7], 7); + T (ssa[1].sa9[5].a5, 4); + T (ssa[1].sa9[5].a7, 6); + + T (ssa[2].a9[3], 0); + T (ssa[2].a9[7], 0); + T (ssa[2].sa9[5].a5, 0); + T (ssa[2].sa9[5].a7, 0); + + T (ssa[5].a9[1], 8); + T (ssa[5].a9[5], 4); + T (ssa[5].sa9[3].a3, 2); + T (ssa[5].sa9[3].a6, 3); +} + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } } + { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated" 0 "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-53.c b/SingleSource/Regression/C/gcc-dg/strlenopt-53.c new file mode 100644 index 0000000000..489c22b693 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-53.c @@ -0,0 +1,116 @@ +/* PR tree-optimization/86415 - strlen() not folded for substrings + within constant arrays + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-gimple -fdump-tree-ccp" } */ + +#include "strlenopt.h" + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name) CAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +#define T(s, n) ELIM (strlen (s) == n) + +/* 11111 + 0 1 23 4 567 8 901234 */ +#define STR "1\00012\000123\0001234\0" + +const char a[] = STR; +const char b[20] = STR; + +void test_literal (void) +{ + /* Verify that strlen() of substrings within a string literal are + correctly folded. */ + T (STR, 1); T (STR + 1, 0); T (STR + 2, 2); T (STR + 3, 1); + T (STR + 4, 0); T (STR + 5, 3); T (STR + 6, 2); T (STR + 7, 1); + T (STR + 8, 0); T (STR + 9, 4); T (STR + 10, 3); T (STR + 11, 2); + T (STR + 12, 1); T (STR + 13, 0); T (STR + 14, 0); + + T (&(STR[0]), 1); T (&(STR[ 1]), 0); T (&(STR[ 2]), 2); + T (&(STR[ 3]), 1); T (&(STR[ 4]), 0); T (&(STR[ 5]), 3); + T (&(STR[ 6]), 2); T (&(STR[ 7]), 1); T (&(STR[ 8]), 0); + T (&(STR[ 9]), 4); T (&(STR[10]), 3); T (&(STR[11]), 2); + T (&(STR[12]), 1); T (&(STR[13]), 0); T (&(STR[14]), 0); + + T (&(STR[0]) + 1, 0); T (&(STR[ 1]) + 1, 2); T (&(STR[ 2]) + 1, 1); + T (&(STR[ 3]) + 1, 0); T (&(STR[ 4]) + 1, 3); T (&(STR[ 5]) + 1, 2); + T (&(STR[ 6]) + 1, 1); T (&(STR[ 7]) + 1, 0); T (&(STR[ 8]) + 1, 4); + T (&(STR[ 9]) + 1, 3); T (&(STR[10]) + 1, 2); T (&(STR[11]) + 1, 1); + T (&(STR[12]) + 1, 0); T (&(STR[13]) + 1, 0); T (&(STR[13]) - 13, 1); + T (&(STR[13]) - 12, 0); T (&(STR[13]) - 11, 2); T (&(STR[13]) - 10, 1); +} + +void test_array (void) +{ + /* Verify that strlen() of substrings within a fully initialized + array are correctly folded. */ + T (a, 1); T (a + 1, 0); T (a + 2, 2); T (a + 3, 1); + T (a + 4, 0); T (a + 5, 3); T (a + 6, 2); T (a + 7, 1); + T (a + 8, 0); T (a + 9, 4); T (a + 10, 3); T (a + 11, 2); + T (a + 12, 1); T (a + 13, 0); T (a + 14, 0); + + /* Verify that strlen() of substrings within a partially initialized + array are also correctly folded, including those referring to + the empty substrings in the implicitly initialized elements. */ + T (b, 1); T (b + 1, 0); T (b + 2, 2); T (b + 3, 1); + T (b + 4, 0); T (b + 5, 3); T (b + 6, 2); T (b + 7, 1); + T (b + 8, 0); T (b + 9, 4); T (b + 10, 3); T (b + 11, 2); + T (b + 12, 1); T (b + 13, 0); T (b + 14, 0); T (b + 15, 0); + T (b + 16, 0); T (b + 17, 0); T (b + 18, 0); T (b + 19, 0); +} + +void test_array_ref_plus (void) +{ + /* Verify that strlen() of substrings within a fully initialized + array referred to by array indices with offsets are correctly + folded. */ + T (&a[ 0], 1); T (&a[ 0] + 1, 0); + T (&a[ 1], 0); T (&a[ 1] + 1, 2); + T (&a[ 2], 2); T (&a[ 2] + 1, 1); T (&a[ 2] + 2, 0); + T (&a[ 3], 1); T (&a[ 3] + 1, 0); + T (&a[ 4], 0); T (&a[ 4] + 1, 3); + T (&a[ 5], 3); T (&a[ 5] + 1, 2); + T (&a[ 5] + 2, 1); T (&a[ 5] + 3, 0); T (&a[ 5] + 4, 4); + T (&a[ 6], 2); T (&a[ 6] + 1, 1); T (&a[ 6] + 2, 0); + T (&a[ 7], 1); T (&a[ 7] + 1, 0); + T (&a[ 8], 0); T (&a[ 8] + 1, 4); + T (&a[ 9], 4); T (&a[ 9] + 1, 3); T (&a[ 9] + 2, 2); + T (&a[ 9] + 3, 1); T (&a[ 9] + 4, 0); T (&a[ 9] + 5, 0); + T (&a[10], 3); T (&a[10] + 1, 2); T (&a[10] + 2, 1); + T (&a[10] + 3, 0); T (&a[10] + 4, 0); + T (&a[11], 2); T (&a[11] + 1, 1); T (&a[11] + 2, 0); + T (&a[12], 1); T (&a[12] + 1, 0); T (&a[12] + 2, 0); + T (&a[13], 0); T (&a[13] + 1, 0); + T (&a[14], 0); +} + +void test_array_ref (void) +{ + T (&a[ 0], 1); T (&a[ 1], 0); T (&a[ 2], 2); T (&a[ 3], 1); + T (&a[ 4], 0); T (&a[ 5], 3); T (&a[ 6], 2); T (&a[ 7], 1); + T (&a[ 8], 0); T (&a[ 9], 4); T (&a[10], 3); T (&a[11], 2); + T (&a[12], 1); T (&a[13], 0); T (&a[14], 0); + + T (&b[ 0], 1); T (&b[ 1], 0); T (&b[ 2], 2); T (&b[ 3], 1); + T (&b[ 4], 0); T (&b[ 5], 3); T (&b[ 6], 2); T (&b[ 7], 1); + T (&b[ 8], 0); T (&b[ 9], 4); T (&b[10], 3); T (&b[11], 2); + T (&b[12], 1); T (&b[13], 0); T (&b[14], 0); T (&b[15], 0); + T (&b[16], 0); T (&b[17], 0); T (&b[18], 0); T (&b[19], 0); +} + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } } + { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated" 0 "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-54.c b/SingleSource/Regression/C/gcc-dg/strlenopt-54.c new file mode 100644 index 0000000000..d4e57ff625 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-54.c @@ -0,0 +1,109 @@ +/* PR tree-optimization/86042 - missing strlen optimization after second strcpy + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to function named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +void elim_after_duplicate_strcpy (void) +{ +#define T(N, assign, off, str, r0, r1) \ + do { \ + char a[N]; \ + strcpy (a, assign); \ + unsigned n0 = strlen (a); \ + strcpy (a + off, str); \ + unsigned n1 = strlen (a); \ + ELIM (n0 == r0 && n1 == r1); \ + } while (0) + + T (2, "", 0, "1", 0, 1); + + T (2, "1", 0, "2", 1, 1); + T (2, "1", 1, "", 1, 1); + + T (3, "\0", 0, "1", 0, 1); + T (3, "1", 1, "2", 1, 2); + + T (3, "12", 0, "23", 2, 2); + T (3, "12", 1, "3", 2, 2); + T (3, "12", 2, "", 2, 2); + + T (4, "1", 1, "23", 1, 3); + T (4, "12", 1, "23", 2, 3); + + T (4, "123", 0, "234", 3, 3); + T (4, "123", 1, "34", 3, 3); + T (4, "123", 2, "4", 3, 3); + T (4, "123", 3, "", 3, 3); + + T (5, "1234", 0, "1", 4, 1); + T (5, "1234", 0, "12", 4, 2); + T (5, "1234", 0, "123", 4, 3); + T (5, "1234", 0, "1234", 4, 4); + + T (5, "123", 1, "234", 3, 4); + T (6, "123", 2, "234", 3, 5); +} + +void elim_after_init_memcpy (void) +{ +#undef T +#define T(init, off, str, n, res) \ + do { \ + char a[] = init; \ + memcpy (a + off, str, n); \ + ELIM (strlen (a) == res); \ + } while (0) + + T ("\0", 0, "1", 2, 1); + T ("\0\0", 0, "12", 3, 2); + +#define INIT { '1', '2', '3', '4' } + T (INIT, 0, "", 1, 0); + T (INIT, 0, "1", 2, 1); + T (INIT, 0, "12", 3, 2); + T (INIT, 0, "123", 4, 3); + + T ("1234", 0, "2", 1, 4); + T ("1234", 0, "23", 2, 4); + T ("1234", 0, "234", 3, 4); + T ("1234", 0, "2345", 4, 4); + T ("1234", 0, "2345", 5, 4); + + T ("1234", 1, "2", 1, 4); + T ("1234", 1, "23", 2, 4); + T ("1234", 1, "234", 3, 4); + T ("1234", 1, "234", 4, 4); + + T ("1234", 2, "3", 1, 4); + T ("1234", 2, "3", 2, 3); + T ("1234", 2, "34", 2, 4); + T ("1234", 2, "34", 3, 4); + + T ("12\00034", 0, "1", 1, 2); + T ("12\00034", 0, "1", 2, 1); + + T ("AB\000CD", 0, "ab", 2, 2); + T ("AB\000CD", 0, "ab", 3, 2); + T ("AB\000CD", 0, "ab\000c", 4, 2); +} + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "optimized" } } + { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-55.c b/SingleSource/Regression/C/gcc-dg/strlenopt-55.c new file mode 100644 index 0000000000..ca89ecd3c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-55.c @@ -0,0 +1,231 @@ +/* PR tree-optimization/71625 - missing strlen optimization on different + array initialization style + + Verify that strlen() of braced initialized array is folded + { dg-do compile } + { dg-options "-O1 -Wall -fdump-tree-gimple -fdump-tree-optimized" } + { dg-require-effective-target large_initializer } */ + +#include "strlenopt.h" + +#define S \ + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" \ + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \ + "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" \ + "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" \ + "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" \ + "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" \ + "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" \ + "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" \ + "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \ + "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \ + "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \ + "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \ + "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \ + "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \ + "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \ + "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" + +/* Arrays of char, signed char, and unsigned char to verify that + the length and contents of all are the same as that of the string + literal above. */ + +const char c256[] = { + S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], S[8], S[9], S[10], + S[11], S[12], S[13], S[14], S[15], S[16], S[17], S[18], S[19], S[20], + S[21], S[22], S[23], S[24], S[25], S[26], S[27], S[28], S[29], S[30], + S[31], S[32], S[33], S[34], S[35], S[36], S[37], S[38], S[39], S[40], + S[41], S[42], S[43], S[44], S[45], S[46], S[47], S[48], S[49], S[50], + S[51], S[52], S[53], S[54], S[55], S[56], S[57], S[58], S[59], S[60], + S[61], S[62], S[63], S[64], S[65], S[66], S[67], S[68], S[69], S[70], + S[71], S[72], S[73], S[74], S[75], S[76], S[77], S[78], S[79], S[80], + S[81], S[82], S[83], S[84], S[85], S[86], S[87], S[88], S[89], S[90], + S[91], S[92], S[93], S[94], S[95], S[96], S[97], S[98], S[99], S[100], + S[101], S[102], S[103], S[104], S[105], S[106], S[107], S[108], S[109], + S[110], S[111], S[112], S[113], S[114], S[115], S[116], S[117], S[118], + S[119], S[120], S[121], S[122], S[123], S[124], S[125], S[126], S[127], + S[128], S[129], S[130], S[131], S[132], S[133], S[134], S[135], S[136], + S[137], S[138], S[139], S[140], S[141], S[142], S[143], S[144], S[145], + S[146], S[147], S[148], S[149], S[150], S[151], S[152], S[153], S[154], + S[155], S[156], S[157], S[158], S[159], S[160], S[161], S[162], S[163], + S[164], S[165], S[166], S[167], S[168], S[169], S[170], S[171], S[172], + S[173], S[174], S[175], S[176], S[177], S[178], S[179], S[180], S[181], + S[182], S[183], S[184], S[185], S[186], S[187], S[188], S[189], S[190], + S[191], S[192], S[193], S[194], S[195], S[196], S[197], S[198], S[199], + S[200], S[201], S[202], S[203], S[204], S[205], S[206], S[207], S[208], + S[209], S[210], S[211], S[212], S[213], S[214], S[215], S[216], S[217], + S[218], S[219], S[220], S[221], S[222], S[223], S[224], S[225], S[226], + S[227], S[228], S[229], S[230], S[231], S[232], S[233], S[234], S[235], + S[236], S[237], S[238], S[239], S[240], S[241], S[242], S[243], S[244], + S[245], S[246], S[247], S[248], S[249], S[250], S[251], S[252], S[253], + S[254], S[255] /* = NUL */ +}; + +const signed char sc256[] = { + S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], S[8], S[9], S[10], + S[11], S[12], S[13], S[14], S[15], S[16], S[17], S[18], S[19], S[20], + S[21], S[22], S[23], S[24], S[25], S[26], S[27], S[28], S[29], S[30], + S[31], S[32], S[33], S[34], S[35], S[36], S[37], S[38], S[39], S[40], + S[41], S[42], S[43], S[44], S[45], S[46], S[47], S[48], S[49], S[50], + S[51], S[52], S[53], S[54], S[55], S[56], S[57], S[58], S[59], S[60], + S[61], S[62], S[63], S[64], S[65], S[66], S[67], S[68], S[69], S[70], + S[71], S[72], S[73], S[74], S[75], S[76], S[77], S[78], S[79], S[80], + S[81], S[82], S[83], S[84], S[85], S[86], S[87], S[88], S[89], S[90], + S[91], S[92], S[93], S[94], S[95], S[96], S[97], S[98], S[99], S[100], + S[101], S[102], S[103], S[104], S[105], S[106], S[107], S[108], S[109], + S[110], S[111], S[112], S[113], S[114], S[115], S[116], S[117], S[118], + S[119], S[120], S[121], S[122], S[123], S[124], S[125], S[126], S[127], + S[128], S[129], S[130], S[131], S[132], S[133], S[134], S[135], S[136], + S[137], S[138], S[139], S[140], S[141], S[142], S[143], S[144], S[145], + S[146], S[147], S[148], S[149], S[150], S[151], S[152], S[153], S[154], + S[155], S[156], S[157], S[158], S[159], S[160], S[161], S[162], S[163], + S[164], S[165], S[166], S[167], S[168], S[169], S[170], S[171], S[172], + S[173], S[174], S[175], S[176], S[177], S[178], S[179], S[180], S[181], + S[182], S[183], S[184], S[185], S[186], S[187], S[188], S[189], S[190], + S[191], S[192], S[193], S[194], S[195], S[196], S[197], S[198], S[199], + S[200], S[201], S[202], S[203], S[204], S[205], S[206], S[207], S[208], + S[209], S[210], S[211], S[212], S[213], S[214], S[215], S[216], S[217], + S[218], S[219], S[220], S[221], S[222], S[223], S[224], S[225], S[226], + S[227], S[228], S[229], S[230], S[231], S[232], S[233], S[234], S[235], + S[236], S[237], S[238], S[239], S[240], S[241], S[242], S[243], S[244], + S[245], S[246], S[247], S[248], S[249], S[250], S[251], S[252], S[253], + S[254], S[255] /* = NUL */ +}; + +const unsigned char uc256[] = { + S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], S[8], S[9], S[10], + S[11], S[12], S[13], S[14], S[15], S[16], S[17], S[18], S[19], S[20], + S[21], S[22], S[23], S[24], S[25], S[26], S[27], S[28], S[29], S[30], + S[31], S[32], S[33], S[34], S[35], S[36], S[37], S[38], S[39], S[40], + S[41], S[42], S[43], S[44], S[45], S[46], S[47], S[48], S[49], S[50], + S[51], S[52], S[53], S[54], S[55], S[56], S[57], S[58], S[59], S[60], + S[61], S[62], S[63], S[64], S[65], S[66], S[67], S[68], S[69], S[70], + S[71], S[72], S[73], S[74], S[75], S[76], S[77], S[78], S[79], S[80], + S[81], S[82], S[83], S[84], S[85], S[86], S[87], S[88], S[89], S[90], + S[91], S[92], S[93], S[94], S[95], S[96], S[97], S[98], S[99], S[100], + S[101], S[102], S[103], S[104], S[105], S[106], S[107], S[108], S[109], + S[110], S[111], S[112], S[113], S[114], S[115], S[116], S[117], S[118], + S[119], S[120], S[121], S[122], S[123], S[124], S[125], S[126], S[127], + S[128], S[129], S[130], S[131], S[132], S[133], S[134], S[135], S[136], + S[137], S[138], S[139], S[140], S[141], S[142], S[143], S[144], S[145], + S[146], S[147], S[148], S[149], S[150], S[151], S[152], S[153], S[154], + S[155], S[156], S[157], S[158], S[159], S[160], S[161], S[162], S[163], + S[164], S[165], S[166], S[167], S[168], S[169], S[170], S[171], S[172], + S[173], S[174], S[175], S[176], S[177], S[178], S[179], S[180], S[181], + S[182], S[183], S[184], S[185], S[186], S[187], S[188], S[189], S[190], + S[191], S[192], S[193], S[194], S[195], S[196], S[197], S[198], S[199], + S[200], S[201], S[202], S[203], S[204], S[205], S[206], S[207], S[208], + S[209], S[210], S[211], S[212], S[213], S[214], S[215], S[216], S[217], + S[218], S[219], S[220], S[221], S[222], S[223], S[224], S[225], S[226], + S[227], S[228], S[229], S[230], S[231], S[232], S[233], S[234], S[235], + S[236], S[237], S[238], S[239], S[240], S[241], S[242], S[243], S[244], + S[245], S[246], S[247], S[248], S[249], S[250], S[251], S[252], S[253], + S[254], S[255] /* = NUL */ +}; + +const __CHAR16_TYPE__ c16_4[] = { + 1, 0x7fff, 0x8000, 0xffff, + 0x10000 /* { dg-warning "\\\[-Woverflow]" } */ +}; + +const char a2_implicit[2] = { }; +const char a3_implicit[3] = { }; + +const char a3_nul[3] = { 0 }; +const char a5_nul1[3] = { [1] = 0 }; +const char a7_nul2[3] = { [2] = 0 }; + +const char ax_2_nul[] = { '1', '2', '\0' }; +const char ax_3_nul[] = { '1', '2', '3', '\0' }; + +const char ax_3_des_nul[] = { [3] = 0, [2] = '3', [1] = '2', [0] = '1' }; + +const char ax_3[] = { '1', '2', '3' }; +const char a3_3[3] = { '1', '2', '3' }; + +const char ax_100_3[] = { '1', '2', '3', [100] = '\0' }; + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name) CAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +#define T(s, n) ELIM (strlen (s) == n) + +void test_nulstring (void) +{ + T (a2_implicit, 0); + T (a3_implicit, 0); + + T (a3_nul, 0); + T (a5_nul1, 0); + T (a7_nul2, 0); + + T (ax_2_nul, 2); + T (ax_3_nul, 3); + T (ax_3_des_nul, 3); + + T (ax_100_3, 3); + T (ax_100_3 + 4, 0); + ELIM (101 == sizeof ax_100_3); + ELIM ('\0' == ax_100_3[100]); + + /* Verify that all three character arrays have the same length + as the string literal they are initialized with. */ + T (S, 255); + T (c256, 255); + T ((const char*)sc256, 255); + T ((const char*)uc256, 255); + + /* Verify that all three character arrays have the same contents + as the string literal they are initialized with. */ + ELIM (0 == memcmp (c256, S, sizeof c256)); + ELIM (0 == memcmp (c256, (const char*)sc256, sizeof c256)); + ELIM (0 == memcmp (c256, (const char*)uc256, sizeof c256)); + + ELIM (0 == strcmp (c256, (const char*)sc256)); + ELIM (0 == strcmp (c256, (const char*)uc256)); + + /* Verify that the char16_t array has the expected contents. */ + ELIM (c16_4[0] == 1 && c16_4[1] == 0x7fff + && c16_4[2] == 0x8000 && c16_4[3] == 0xffff + && c16_4[4] == 0); +} + +/* Verify that excessively large initializers don't run out of + memory. Also verify that the they have the expected size and + contents. */ + +#define MAX (__PTRDIFF_MAX__ - 1) + +const char large_string[] = { 'a', [1234] = 'b', [MAX] = '\0' }; + +const void test_large_string_size (void) +{ + ELIM (sizeof large_string == MAX + 1); + + /* The following expressions are not folded without optimization. */ + ELIM ('a' == large_string[0]); + ELIM ('\0' == large_string[1233]); + ELIM ('b' == large_string[1234]); + ELIM ('\0' == large_string[1235]); + ELIM ('\0' == large_string[MAX - 1]); +} + + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } } + { dg-final { scan-tree-dump-times "memcmp" 0 "gimple" } } + { dg-final { scan-tree-dump-times "strcmp" 0 "gimple" } } + { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-56.c b/SingleSource/Regression/C/gcc-dg/strlenopt-56.c new file mode 100644 index 0000000000..ffd02f1b6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-56.c @@ -0,0 +1,50 @@ +/* PR tree-optimization/71625 - conversion of braced initializers to strings + Verify that array elements have the expected values regardless of sign + and non-ASCII execution character set. + { dg-do compile } + { dg-require-iconv "IBM1047" } + { dg-options "-O -Wall -fexec-charset=IBM1047 -fdump-tree-gimple -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +const char a[] = { 'a', 129, 0 }; +const signed char b[] = { 'b', 130, 0 }; +const unsigned char c[] = { 'c', 131, 0 }; + +const char s[] = "a\201"; +const signed char ss[] = "b\202"; +const unsigned char us[] = "c\203"; + + +#define A(expr) ((expr) ? (void)0 : __builtin_abort ()) + +void test_values (void) +{ + A (a[0] == a[1]); + A (a[1] == 'a'); + + A (b[0] == b[1]); + A (b[1] == (signed char)'b'); + + A (c[0] == c[1]); + A (c[1] == (unsigned char)'c'); +} + +void test_lengths (void) +{ + A (2 == strlen (a)); + A (2 == strlen ((const char*)b)); + A (2 == strlen ((const char*)c)); +} + +void test_contents (void) +{ + A (0 == strcmp (a, s)); + A (0 == strcmp ((const char*)b, (const char*)ss)); + A (0 == strcmp ((const char*)c, (const char*)us)); +} + + +/* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } } + { dg-final { scan-tree-dump-times "strcmp" 0 "gimple" } } + { dg-final { scan-tree-dump-times "abort" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-57.c b/SingleSource/Regression/C/gcc-dg/strlenopt-57.c new file mode 100644 index 0000000000..2f67babec8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-57.c @@ -0,0 +1,49 @@ +/* PR tree-optimization/86914 - wrong code with strlen() of poor-man's + flexible array member plus offset + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +struct A0 { char i, a[0]; }; +struct A1 { char i, a[1]; }; +struct A9 { char i, a[9]; }; +struct Ax { char i, a[]; }; + +extern int a[]; + +extern struct A0 a0; +extern struct A1 a1; +extern struct A9 a9; +extern struct Ax ax; + +void test_var_flexarray_cst_off (void) +{ + /* Use arbitrary constants greater than 16 in case GCC ever starts + unrolling strlen() calls with small array arguments. */ + a[0] = 17 < strlen (a0.a + 1); // { dg-warning "\\\[-Warray-bounds|-Wstringop-overread" } + a[1] = 19 < strlen (a1.a + 1); // { dg-warning "\\\[-Wstringop-overread" } + a[2] = 23 < strlen (a9.a + 9); // { dg-warning "\\\[-Wstringop-overread" } + a[3] = 29 < strlen (ax.a + 3); +} + +void test_ptr_flexarray_cst_off (struct A0 *p0, struct A1 *p1, + struct A9 *p9, struct Ax *px) +{ + a[0] = 17 < strlen (p0->a + 1); + a[1] = 19 < strlen (p1->a + 1); + a[2] = 23 < strlen (p9->a + 9); + a[3] = 29 < strlen (px->a + 3); +} + +void test_ptr_flexarray_var_off (struct A0 *p0, struct A1 *p1, + struct A9 *p9, struct Ax *px, + int i) +{ + a[0] = 17 < strlen (p0->a + i); + a[1] = 19 < strlen (p1->a + i); + a[2] = 23 < strlen (p9->a + i); + a[3] = 29 < strlen (px->a + i); +} + +/* { dg-final { scan-tree-dump-times "strlen" 12 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-58.c b/SingleSource/Regression/C/gcc-dg/strlenopt-58.c new file mode 100644 index 0000000000..034961cd81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-58.c @@ -0,0 +1,93 @@ +/* PR tree-optimization/86711 - wrong folding of memchr + + Verify that calls to memchr() with constant arrays initialized + with wide string literals are folded. + + { dg-do compile } + { dg-options "-O1 -Wall -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +typedef __WCHAR_TYPE__ wchar_t; + +extern void* memchr (const void*, int, size_t); + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name) CAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +#define T(s, n) ELIM (strlen (s) == n) + + +static const wchar_t wc = L'1'; +static const wchar_t ws1[] = L"1"; +static const wchar_t wsx[] = L"\x12345678"; /* { dg-warning "hex escape" "" { target { ! 4byte_wchar_t } } } */ +static const wchar_t ws4[] = L"\x00123456\x12005678\x12340078\x12345600"; /* { dg-warning "hex escape" "" { target { ! 4byte_wchar_t } } } */ + +void test_wide (void) +{ + int i0 = 0; + int i1 = i0 + 1; + int i2 = i1 + 1; + int i3 = i2 + 1; + int i4 = i3 + 1; + + ELIM (memchr (L"" + 1, 0, 0) == 0); + ELIM (memchr (&wc + 1, 0, 0) == 0); + ELIM (memchr (L"\x12345678", 0, sizeof (wchar_t)) == 0); /* { dg-warning "hex escape" "" { target { ! 4byte_wchar_t } } } */ + + const size_t nb = sizeof ws4; + const size_t nwb = sizeof (wchar_t); + + const char *pws1 = (const char*)ws1; + const char *pws4 = (const char*)ws4; + const char *pwsx = (const char*)wsx; + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + ELIM (memchr (ws1, 0, sizeof ws1) == pws1 + 1); + ELIM (memchr (wsx, 0, sizeof wsx) == pwsx + sizeof *wsx); + + ELIM (memchr (&ws4[0], 0, nb) == pws4 + 3); + ELIM (memchr (&ws4[1], 0, nb - 1 * nwb) == pws4 + 1 * nwb + 2); + ELIM (memchr (&ws4[2], 0, nb - 2 * nwb) == pws4 + 2 * nwb + 1); + ELIM (memchr (&ws4[3], 0, nb - 3 * nwb) == pws4 + 3 * nwb + 0); + ELIM (memchr (&ws4[4], 0, nb - 4 * nwb) == pws4 + 4 * nwb + 0); + + ELIM (memchr (&ws4[i0], 0, nb) == pws4 + 3); + ELIM (memchr (&ws4[i1], 0, nb - 1 * nwb) == pws4 + 1 * nwb + 2); + ELIM (memchr (&ws4[i2], 0, nb - 2 * nwb) == pws4 + 2 * nwb + 1); + ELIM (memchr (&ws4[i3], 0, nb - 3 * nwb) == pws4 + 3 * nwb + 0); + ELIM (memchr (&ws4[i4], 0, nb - 4 * nwb) == pws4 + 4 * nwb + 0); +#else + ELIM (memchr (ws1, 0, sizeof ws1) == pws1 + 0); + ELIM (memchr (wsx, 0, sizeof wsx) == pwsx + sizeof *wsx); + + ELIM (memchr (&ws4[0], 0, nb) == pws4 + 0); + ELIM (memchr (&ws4[1], 0, nb - 1 * nwb) == pws4 + 1 * nwb + 1); + ELIM (memchr (&ws4[2], 0, nb - 2 * nwb) == pws4 + 2 * nwb + 2); + ELIM (memchr (&ws4[3], 0, nb - 3 * nwb) == pws4 + 3 * nwb + 3); + ELIM (memchr (&ws4[4], 0, nb - 4 * nwb) == pws4 + 4 * nwb + 0); + + ELIM (memchr (&ws4[i0], 0, nb) == pws4 + 0); + ELIM (memchr (&ws4[i1], 0, nb - 1 * nwb) == pws4 + 1 * nwb + 1); + ELIM (memchr (&ws4[i2], 0, nb - 2 * nwb) == pws4 + 2 * nwb + 2); + ELIM (memchr (&ws4[i3], 0, nb - 3 * nwb) == pws4 + 3 * nwb + 3); + ELIM (memchr (&ws4[i4], 0, nb - 4 * nwb) == pws4 + 4 * nwb + 0); +#endif +} + +/* { dg-final { scan-tree-dump-times "memchr" 0 "optimized" } } + { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-59.c b/SingleSource/Regression/C/gcc-dg/strlenopt-59.c new file mode 100644 index 0000000000..9bacf87487 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-59.c @@ -0,0 +1,73 @@ +/* Verify that strlen() calls with constant conditional expressions are + eliminated as expected. + + { dg-do compile } + { dg-options "-O1 -fdump-tree-optimized" } */ + +extern void abort (void); +extern __SIZE_TYPE__ strlen (const char*); + + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macros to emit a call to funcation named + call_failed_to_be_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if ((expr)) FAIL (test_not_eliminated); else (void)0 + +extern char a3[3]; +extern char a7[7]; + +struct MemArrays { char a[7], b[9]; }; + +struct MemArrays ma; + +void test_elim_condexpr (int i) +{ + ELIM (6 < strlen (i ? "" : "123456")); + ELIM (6 < strlen (i ? "123456" : "")); + + ELIM (4 < strlen (i < 1 ? "a" : i == 1 ? "ab" : "abc")); + + ELIM (3 < strlen (i ? "" : a3)); + ELIM (3 < strlen (i ? a3 : "1")); + + ELIM (6 < strlen (i ? "12" : a7)); + ELIM (6 < strlen (i ? a7 : "123")); + + ELIM (6 < strlen (i ? "1234" : a7)); + ELIM (7 < strlen (i ? a7 : "1234567")); + + ELIM (3 < strlen (i < 1 ? "a" : i == 1 ? "ab" : a3)); + ELIM (3 < strlen (i < 1 ? "a" : i == 1 ? a3 : "abc")); + ELIM (3 < strlen (i < 1 ? a3 : i == 1 ? "a" : "abc")); + + ELIM (6 < strlen (i < 1 ? "a" : i == 1 ? "ab" : a7)); + ELIM (6 < strlen (i < 1 ? "a" : i == 1 ? a7 : "abc")); + ELIM (6 < strlen (i < 1 ? a7 : i == 1 ? "a" : "abc")); + + ELIM (6 < strlen (i < 1 ? "a" : i == 1 ? a7 : a3)); + ELIM (6 < strlen (i < 1 ? a7 : i == 1 ? "a" : a3)); + + { + enum { maxlen = sizeof ma - 1 }; + ELIM (maxlen < strlen (ma.a)); + } + + { + enum { maxlen = sizeof ma - __builtin_offsetof (struct MemArrays, b) - 1 }; + ELIM (maxlen < strlen (ma.b)); + } +} + +/* { dg-final { scan-tree-dump-times "test_not_eliminated_" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-6.c b/SingleSource/Regression/C/gcc-dg/strlenopt-6.c new file mode 100644 index 0000000000..dcbe778a27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-6.c @@ -0,0 +1,85 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +foo (char *x) +{ +#ifdef PR50262_FIXED + /* Once PTA is fixed, we'll need just one strlen here, + without the memcpy. */ + char *p = x; + char *q = malloc (strlen (p) + 64); +#else + /* This is here just because PTA can't figure that + *q = '\0' store below can't change p's length. + In this case we have one strlen and one memcpy here. */ + char b[64]; + char *q = malloc (strlen (x) + 64); + char *p = strcpy (b, x); +#endif + char *r; + if (q == NULL) return NULL; + /* This store can be optimized away once strcat is + replaced with memcpy. */ + *q = '\0'; + /* These two strcat calls can be optimized into memcpy calls. */ + strcat (q, p); + strcat (q, "/"); + /* The strchr can be optimized away, as we know the current + string length as well as end pointer. */ + r = strchr (q, '\0'); + /* This store can go, as it is overwriting '\0' with the same + character. */ + *r = '\0'; + /* And this strcat can be again optimized into memcpy call. */ + strcat (q, "abcde"); + return q; +} + +__attribute__((noinline, noclone)) char * +bar (char *p) +{ + char buf[26]; + char *r; + if (strlen (p) + 9 > 26) + return NULL; + *buf = '\0'; + strcat (buf, p); + strcat (buf, "/"); + r = strchr (buf, '\0'); + *r = '\0'; + strcat (buf, "abcde"); + return strdup (buf); +} + +int +main () +{ + char *volatile p = "string1"; + char *volatile r = "string2"; + char *q = foo (p); + if (q != NULL) + { + if (strcmp (q, "string1/abcde")) + abort (); + memset (q, '\0', 14); + free (q); + } + q = bar (p); + if (q != NULL) + { + if (strcmp (q, "string1/abcde")) + abort (); + free (q); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-60.c b/SingleSource/Regression/C/gcc-dg/strlenopt-60.c new file mode 100644 index 0000000000..a581136840 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-60.c @@ -0,0 +1,58 @@ +/* PR tree-optimization/89500 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 10;" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 5;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 0;" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "strnlen " 1 "optimized" } } */ + +#include "strlenopt.h" + +void foo (char *); + +size_t +f1 (void) +{ + char a[10] = "0123456789"; + return strnlen (a, 10); +} + +size_t +f2 (void) +{ + char a[10] = "0123456789"; + return strnlen (a, 5); +} + +size_t +f3 (void) +{ + char a[10] = "0123456789"; + return strnlen (a, 0); +} + +size_t +f4 (void) +{ + char a[20]; + foo (a); + memcpy (a, "0123456789", 10); + return strnlen (a, 10); +} + +size_t +f5 (void) +{ + char a[20]; + foo (a); + memcpy (a, "0123456789", 10); + return strnlen (a, 14); +} + +size_t +f6 (void) +{ + char a[20]; + foo (a); + return strnlen (a, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-61.c b/SingleSource/Regression/C/gcc-dg/strlenopt-61.c new file mode 100644 index 0000000000..3ddfa2ebc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-61.c @@ -0,0 +1,218 @@ +/* PR tree-optimization/89688 - -Wstringop-overflow confused by const + 2D array of char + { dg-do compile } + { dg-options "-Wall -fdump-tree-gimple -fdump-tree-optimized" } */ + +typedef __SIZE_TYPE__ size_t; + +size_t strlen (const char*); +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern __attribute__ ((noreturn)) void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +#define A(ref, len) \ + if (strlen (ref) != len) FAIL (failure); else (void)0 + +const char a3_4[3][4] = { { 1 }, { 1, 2 }, { 1, 2, 3 } }; + +void test_a4_4 (void) +{ + A (a3_4[0], 1); + A (a3_4[1], 2); + A (a3_4[2], 3); + + A (&a3_4[0][0], 1); + A (&a3_4[0][1], 0); + A (&a3_4[0][2], 0); + A (&a3_4[0][3], 0); + + A (&a3_4[1][0], 2); + A (&a3_4[1][1], 1); + A (&a3_4[1][2], 0); + A (&a3_4[1][3], 0); + + A (&a3_4[2][0], 3); + A (&a3_4[2][1], 2); + A (&a3_4[2][2], 1); + A (&a3_4[2][3], 0); +} + + +const char a3_4_5[3][4][5] = + { + { { 1 }, { 1, 2 }, { 1, 2, 3 }, { 1, 2, 3, 4 } }, + { { 1, 2 }, { 1, 2, 3 }, { 1, 2, 3, 4 }, { 1 } }, + { { 1, 2, 3 }, { 1, 2, 3, 4 }, { 1 }, { 1, 2 } }, + }; + +void test_a3_4_5 (void) +{ + A (a3_4_5[0][0], 1); + A (a3_4_5[0][1], 2); + A (a3_4_5[0][2], 3); + A (a3_4_5[0][3], 4); + + A (a3_4_5[1][0], 2); + A (a3_4_5[1][1], 3); + A (a3_4_5[1][2], 4); + A (a3_4_5[1][3], 1); + + A (a3_4_5[2][0], 3); + A (a3_4_5[2][1], 4); + A (a3_4_5[2][2], 1); + A (a3_4_5[2][3], 2); +} + + +struct S +{ + char a3[3]; + char a4_5[4][5]; +}; + +const struct S sa4[4] = + { + { .a3 = { 0 }, + .a4_5 = + { + { 1 }, { 1, 2 }, { 1, 2, 3 }, { 1, 2, 3, 4 } + } + }, + { .a3 = { 1 }, + .a4_5 = + { + { 1, 2 }, { 1, 2, 3 }, { 1, 2, 3, 4 }, { 1 } + } + }, + { .a3 = { 1, 2 }, + .a4_5 = + { + { 1, 2, 3 }, { 1, 2, 3, 4 }, { 1 }, { 1, 2 } + } + }, + { .a3 = { 1 }, + .a4_5 = + { + { 1, 2, 3, 4 }, "1", { 1, 2 }, "123" + } + } + }; + +void test_sa4 (void) +{ + A (sa4[0].a3, 0); + A (sa4[0].a4_5[0], 1); + A (sa4[0].a4_5[1], 2); + A (sa4[0].a4_5[2], 3); + A (sa4[0].a4_5[3], 4); + + A (sa4[1].a3, 1); + A (sa4[1].a4_5[0], 2); + A (sa4[1].a4_5[1], 3); + A (sa4[1].a4_5[2], 4); + A (sa4[1].a4_5[3], 1); + + A (sa4[2].a3, 2); + A (sa4[2].a4_5[0], 3); + A (sa4[2].a4_5[1], 4); + A (sa4[2].a4_5[2], 1); + A (sa4[2].a4_5[3], 2); + + A (sa4[3].a3, 1); + A (sa4[3].a4_5[0], 4); + A (sa4[3].a4_5[1], 1); + A (sa4[3].a4_5[2], 2); + A (sa4[3].a4_5[3], 3); +} + + +struct T +{ + struct S sa2[2]; + char a4[4]; +}; + +const struct T ta2[2] = + { + [0] = + { + .sa2 = + { + [0] = + { .a3 = { 0 }, + .a4_5 = + { + { 1 }, { 1, 2 }, { 1, 2, 3 }, { 1, 2, 3, 4 } + } + }, + [1] = + { .a3 = { 1 }, + .a4_5 = + { + { 1, 2 }, { 1, 2, 3 }, { 1, 2, 3, 4 }, { 1 } + } + }, + }, + .a4 = "12" + }, + + [1] = + { + .sa2 = + { + [0] = + { .a3 = { 1, 2 }, + .a4_5 = + { + { 1, 2, 3 }, { 1, 2, 3, 4 }, { 1 }, { 1, 2 } + } + }, + { .a3 = { 1 }, + .a4_5 = + { + { 1, 2, 3, 4 }, "1", { 1, 2 }, "123" + } + } + }, + .a4 = "123" + } + }; + +void test_ta2 (void) +{ + A (ta2[0].sa2[0].a3, 0); + A (ta2[0].sa2[0].a4_5[0], 1); + A (ta2[0].sa2[0].a4_5[1], 2); + A (ta2[0].sa2[0].a4_5[2], 3); + A (ta2[0].sa2[0].a4_5[3], 4); + + A (ta2[0].sa2[1].a3, 1); + A (ta2[0].sa2[1].a4_5[0], 2); + A (ta2[0].sa2[1].a4_5[1], 3); + A (ta2[0].sa2[1].a4_5[2], 4); + A (ta2[0].sa2[1].a4_5[3], 1); + + A (ta2[0].a4, 2); + + A (ta2[1].sa2[0].a3, 2); + A (ta2[1].sa2[0].a4_5[0], 3); + A (ta2[1].sa2[0].a4_5[1], 4); + A (ta2[1].sa2[0].a4_5[2], 1); + A (ta2[1].sa2[0].a4_5[3], 2); + + A (ta2[1].sa2[1].a3, 1); + A (ta2[1].sa2[1].a4_5[0], 4); + A (ta2[1].sa2[1].a4_5[1], 1); + A (ta2[1].sa2[1].a4_5[2], 2); + A (ta2[1].sa2[1].a4_5[3], 3); + + A (ta2[1].a4, 3); +} + +/* { dg-final { scan-tree-dump-not "failure" "optimized" } } + { dg-final { scan-tree-dump-not "strlen1" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-62.c b/SingleSource/Regression/C/gcc-dg/strlenopt-62.c new file mode 100644 index 0000000000..569c18a916 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-62.c @@ -0,0 +1,190 @@ +/* PR tree-optimization/90662 - strlen of a string in a vla plus offset + not folded + { dg-do compile } + { dg-require-effective-target alloca } + { dg-options "-O2 -Wall -fdump-tree-gimple -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define FAILNAME(name, counter) \ + CAT (CAT (CAT (call_ ## name ##_on_line_, __LINE__), _), counter) + +#define FAIL(name, counter) do { \ + extern void FAILNAME (name, counter) (void); \ + FAILNAME (name, counter)(); \ + } while (0) + +/* Macro to emit a call to funcation named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated, __COUNTER__); else (void)0 + +#define ARGS(...) __VA_ARGS__ + +void sink (void*, ...); + + +#define T(Type, expect, init, p) \ + do { \ + Type vla[n]; \ + char *ptr = strcpy ((char*)vla, init); \ + ELIM (expect == strlen (p)); \ + sink (ptr); \ + } while (0) + +void test_char_vla_local (int n) +{ + T (char, 0, "", vla); + T (char, 0, "\0", vla); + T (char, 1, "1", vla); + T (char, 2, "12", vla); + T (char, 3, "123", vla); + + T (char, 2, "123", vla + 1); + T (char, 1, "123", &vla[2]); + T (char, 0, "123", &vla[1] + 2); + + T (char, 2, "123", &vla[2] - 1); + T (char, 3, "123", &vla[1] - 1); + + T (char, 0, "", ptr); + T (char, 0, "\0", ptr); + T (char, 1, "1", ptr); + T (char, 2, "12", ptr); + T (char, 3, "123", ptr); + + T (char, 2, "123", ptr + 1); + T (char, 1, "123", &ptr[2]); + T (char, 0, "123", &ptr[1] + 2); +} + +void test_int16_vla_local (int n) +{ + T (int16_t, 0, "", (char*)vla); + T (int16_t, 0, "\0", (char*)vla); + T (int16_t, 1, "1", (char*)vla); + T (int16_t, 2, "12", (char*)vla); + T (int16_t, 3, "123", (char*)vla); + + T (int16_t, 2, "1234", (char*)(vla + 1)); + T (int16_t, 2, "123456", (char*)&vla[2]); + T (int16_t, 1, "123456", (char*)&vla[2] + 1); + T (int16_t, 0, "123456", (char*)&vla[2] + 2); + T (int16_t, 0, "123456", (char*)(&vla[1] + 2)); + + T (int16_t, 3, "123456", (char*)&vla[2] - 1); + T (int16_t, 4, "123456", (char*)&vla[2] - 2); + + T (int16_t, 0, "", ptr); + T (int16_t, 0, "\0", ptr); + T (int16_t, 1, "1", ptr); + T (int16_t, 2, "12", ptr); + T (int16_t, 3, "123", ptr); + + T (int16_t, 2, "123", ptr + 1); + T (int16_t, 1, "123", &ptr[2]); + T (int16_t, 0, "123", &ptr[1] + 2); +} + +void test_int_vla_local (int n) +{ + T (int16_t, 0, "", (char*)vla); + T (int16_t, 0, "\0", (char*)vla); + T (int16_t, 1, "1", (char*)vla); + T (int16_t, 2, "12", (char*)vla); + T (int16_t, 3, "123", (char*)vla); + + T (int16_t, 2, "1234", (char*)(vla + 1)); + T (int16_t, 2, "123456", (char*)&vla[2]); + T (int16_t, 1, "123456", (char*)&vla[2] + 1); + T (int16_t, 0, "123456", (char*)&vla[2] + 2); + T (int16_t, 0, "123456", (char*)(&vla[1] + 2)); + + T (int, 0, "", ptr); + T (int, 0, "\0", ptr); + T (int, 1, "1", ptr); + T (int, 2, "12", ptr); + T (int, 3, "123", ptr); + + T (int, 2, "123", ptr + 1); + T (int, 1, "123", &ptr[2]); + T (int, 0, "123", &ptr[1] + 2); +} + + +#undef T +#define T(Type, expect, parr, init, p) \ + do { \ + Type (*parray)[] = *ppa++; \ + char *ptr = strcpy ((char*)parr, init); \ + (void)&ptr; \ + ELIM (expect == strlen (p)); \ + } while (0) + +/* Have the function take a pointer to pointers to arrays so that each + test case can use its own pointer to avoid interference between. */ + +void test_char_array_ptr (char (**ppa)[]) +{ + T (char, 0, *parray, "", *parray); + T (char, 0, *parray, "", &(*parray)[0]); + + T (char, 1, *parray, "1", &(*parray)[0]); + T (char, 0, *parray, "1", &(*parray)[1]); + + T (char, 2, *parray, "12", &(*parray)[0]); + T (char, 1, *parray, "12", &(*parray)[1]); + T (char, 0, *parray, "12", &(*parray)[2]); + + T (char, 3, *parray, "123", &(*parray)[0]); + T (char, 2, *parray, "123", &(*parray)[1]); + T (char, 1, *parray, "123", &(*parray)[2]); + T (char, 0, *parray, "123", &(*parray)[3]); + + T (char, 3, *parray, "123", ptr); + T (char, 2, *parray, "123", &ptr[1]); + T (char, 1, *parray, "123", &ptr[2]); + T (char, 0, *parray, "123", &ptr[3]); +} + +void test_int16_array_ptr (int16_t (**ppa)[]) +{ + T (int16_t, 0, *parray, "", (char*)*parray); + T (int16_t, 0, *parray, "", (char*)&(*parray)[0]); + + T (int16_t, 1, *parray, "1", (char*)&(*parray)[0]); + T (int16_t, 0, *parray, "12", (char*)&(*parray)[1]); + + T (int16_t, 2, *parray, "12", (char*)&(*parray)[0]); + T (int16_t, 1, *parray, "12", (char*)&(*parray)[0] + 1); + T (int16_t, 2, *parray, "1234", (char*)&(*parray)[1]); + T (int16_t, 1, *parray, "1234", (char*)&(*parray)[1] + 1); + T (int16_t, 0, *parray, "1234", (char*)&(*parray)[2]); + + T (int16_t, 6, *parray, "123456", (char*)&(*parray)[0]); + T (int16_t, 5, *parray, "123456", (char*)&(*parray)[0] + 1); + T (int16_t, 0, *parray, "123456", (char*)&(*parray)[0] + 6); + T (int16_t, 4, *parray, "123456", (char*)&(*parray)[1]); + T (int16_t, 3, *parray, "123456", (char*)&(*parray)[1] + 1); + T (int16_t, 0, *parray, "123456", (char*)&(*parray)[1] + 4); + T (int16_t, 2, *parray, "123456", (char*)&(*parray)[2]); + T (int16_t, 1, *parray, "123456", (char*)&(*parray)[2] + 1); + T (int16_t, 0, *parray, "123456", (char*)&(*parray)[2] + 2); + T (int16_t, 0, *parray, "123456", (char*)&(*parray)[3]); + + T (int16_t, 3, *parray, "123", (char*)ptr); + T (int16_t, 2, *parray, "123", (char*)&ptr[1]); + T (int16_t, 1, *parray, "123", (char*)&ptr[2]); + T (int16_t, 0, *parray, "123", (char*)&ptr[3]); +} + +/* { dg-final { scan-tree-dump-times "strlen" 0 "optimized" } } + { dg-final { scan-tree-dump-times "not_eliminated" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-63.c b/SingleSource/Regression/C/gcc-dg/strlenopt-63.c new file mode 100644 index 0000000000..f77db6bbe7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-63.c @@ -0,0 +1,158 @@ +/* PR tree-optimization/90662 - strlen of a string in a vla plus offset + not folded + Verify that strlen of pointers to char arrays are computed correctly + (whether folded or not). + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + __builtin_abort ())) + +typedef char A5[5]; + +A5 a5[5]; +A5* p[5] = { &a5[4], &a5[3], &a5[2], &a5[1], &a5[0] }; + +__attribute__ ((noclone, noinline, noipa)) +void deref_deref (void) +{ + strcpy (**p, "12345"); + A (strlen (**p) == 5); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_0 (void) +{ + strcpy (*p[0], ""); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_1 (void) +{ + strcpy (*p[1], "1"); + A (strlen (*p[1]) == 1); + A (strlen (&(*p[1])[1]) == 0); + + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_2 (void) +{ + strcpy (*p[2], "12"); + A (strlen (*p[2]) == 2); + A (strlen (&(*p[2])[1]) == 1); + A (strlen (&(*p[2])[2]) == 0); + + A (strlen (*p[1]) == 1); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_3 (void) +{ + strcpy (*p[3], "123"); + A (strlen (*p[3]) == 3); + A (strlen (&(*p[3])[1]) == 2); + A (strlen (&(*p[3])[2]) == 1); + A (strlen (&(*p[3])[3]) == 0); + + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 1); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_4 (void) +{ + strcpy (*p[4], "1234"); + A (strlen (*p[4]) == 4); + A (strlen (&(*p[4])[1]) == 3); + A (strlen (&(*p[4])[2]) == 2); + A (strlen (&(*p[4])[3]) == 1); + A (strlen (&(*p[4])[4]) == 0); + + A (strlen (*p[3]) == 3); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 1); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_4_x (void) +{ + strcpy (*p[4], ""); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 3); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 1); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_3_x (void) +{ + strcpy (&(*p[3])[0], "1"); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 1); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 1); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_2_x (void) +{ + strcpy (*p[2], "12"); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 1); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 1); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_1_x (void) +{ + strcpy (*p[1], "123"); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 1); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 3); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_0_x (void) +{ + strcpy (*p[0], "1234"); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 1); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 3); + A (strlen (*p[0]) == 4); +} + +int main (void) +{ + deref_deref (); + + deref_idx_0 (); + deref_idx_1 (); + deref_idx_2 (); + deref_idx_3 (); + deref_idx_4 (); + + deref_idx_4_x (); + deref_idx_3_x (); + deref_idx_2_x (); + deref_idx_1_x (); + deref_idx_0_x (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-64.c b/SingleSource/Regression/C/gcc-dg/strlenopt-64.c new file mode 100644 index 0000000000..5451457dc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-64.c @@ -0,0 +1,182 @@ +/* PR tree-optimization/90662 - strlen of a string in a vla plus offset + not folded + Verify that strlen of pointers to wide character arrays (emulated + by int16_t) are computed correctly (whether folded or not). + { dg-do run } + { dg-options "-O2 -Wall -Wno-incompatible-pointer-types" } */ + +#include "strlenopt.h" + +typedef __INT16_TYPE__ int16_t; + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + __builtin_abort ())) + +typedef int16_t A5[5]; + +A5 a5[5]; +A5* p[5] = { &a5[4], &a5[3], &a5[2], &a5[1], &a5[0] }; + +__attribute__ ((noclone, noinline, noipa)) +void deref_deref (void) +{ + strcpy (**p, "12345"); + A (strlen (**p) == 5); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_0 (void) +{ + strcpy (*p[0], ""); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_1 (void) +{ + strcpy (*p[1], "12"); + A (strlen (*p[1]) == 2); + A (strlen (&(*p[1])[1]) == 0); + + A (strlen ((char*)*p[1] + 1) == 1); + A (strlen ((char*)*p[1] + 2) == 0); + A (strlen ((char*)*p[1] + 3) == 0); + + A (strlen ((char*)&(*p[1])[1] + 1) == 0); + + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_2 (void) +{ + strcpy (*p[2], "1234"); + A (strlen (*p[2]) == 4); + A (strlen (&(*p[2])[1]) == 2); + A (strlen (&(*p[2])[2]) == 0); + + A (strlen ((char*)*p[2] + 1) == 3); + A (strlen ((char*)*p[2] + 2) == 2); + A (strlen ((char*)*p[2] + 3) == 1); + A (strlen ((char*)*p[2] + 4) == 0); + A (strlen ((char*)*p[2] + 5) == 0); + + A (strlen ((char*)&(*p[2])[1] + 1) == 1); + A (strlen ((char*)&(*p[2])[1] + 2) == 0); + + A (strlen (*p[1]) == 2); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_3 (void) +{ + strcpy (*p[3], "123456"); + A (strlen (*p[3]) == 6); + A (strlen (&(*p[3])[1]) == 4); + A (strlen (&(*p[3])[2]) == 2); + A (strlen (&(*p[3])[3]) == 0); + + A (strlen ((char*)*p[3] + 1) == 5); + A (strlen ((char*)*p[3] + 2) == 4); + A (strlen ((char*)*p[3] + 3) == 3); + A (strlen ((char*)*p[3] + 4) == 2); + A (strlen ((char*)*p[3] + 5) == 1); + A (strlen ((char*)*p[3] + 6) == 0); + + A (strlen (*p[2]) == 4); + A (strlen (*p[1]) == 2); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_4 (void) +{ + strcpy (*p[4], "12345678"); + A (strlen (*p[4]) == 8); + A (strlen (&(*p[4])[1]) == 6); + A (strlen (&(*p[4])[2]) == 4); + A (strlen (&(*p[4])[3]) == 2); + A (strlen (&(*p[4])[4]) == 0); + + A (strlen (*p[3]) == 6); + A (strlen (*p[2]) == 4); + A (strlen (*p[1]) == 2); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_4_x (void) +{ + strcpy (*p[4], ""); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 6); + A (strlen (*p[2]) == 4); + A (strlen (*p[1]) == 2); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_3_x (void) +{ + strcpy (&(*p[3])[0], "1"); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 1); + A (strlen (*p[2]) == 4); + A (strlen (*p[1]) == 2); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_2_x (void) +{ + strcpy (*p[2], "12"); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 1); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 2); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_1_x (void) +{ + strcpy (*p[1], "123"); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 1); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 3); + A (strlen (*p[0]) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) +void deref_idx_0_x (void) +{ + strcpy (*p[0], "1234"); + A (strlen (*p[4]) == 0); + A (strlen (*p[3]) == 1); + A (strlen (*p[2]) == 2); + A (strlen (*p[1]) == 3); + A (strlen (*p[0]) == 4); +} + +int main (void) +{ + deref_deref (); + + deref_idx_0 (); + deref_idx_1 (); + deref_idx_2 (); + deref_idx_3 (); + deref_idx_4 (); + + deref_idx_4_x (); + deref_idx_3_x (); + deref_idx_2_x (); + deref_idx_1_x (); + deref_idx_0_x (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-65.c b/SingleSource/Regression/C/gcc-dg/strlenopt-65.c new file mode 100644 index 0000000000..521d7ac2b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-65.c @@ -0,0 +1,179 @@ +/* PRE tree-optimization/90626 - fold strcmp(a, b) == 0 to zero when + one string length is exact and the other is unequal + { dg-do compile } + { dg-options "-O2 -Wall -Wno-string-compare -fdump-tree-optimized -ftrack-macro-expansion=0" } */ + +#include "strlenopt.h" + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to function named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM_IF_TRUE(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +/* Macro to emit a call to a function named + call_made_in_{true,false}_branch_on_line_NNN() + for each call that's expected to be retained. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that the expected number of both kinds of calls appears in output + (a pair for each line with the invocation of the KEEP() macro. */ +#define TEST_KEEP(expr) \ + if (expr) \ + FAIL (made_in_true_branch); \ + else \ + FAIL (made_in_false_branch) + +#define FOLD(init1, init2, arg1, arg2, bnd) \ + do { \ + char a[8], b[8]; \ + sink (a, b); \ + memcpy (a, init1, sizeof init1 - 1); \ + memcpy (b, init2, sizeof init2 - 1); \ + ELIM_IF_TRUE (0 != CMPFUNC (arg1, arg2, bnd)); \ + } while (0) + +#define KEEP(init1, init2, arg1, arg2, bnd) \ + do { \ + char a[8], b[8]; \ + sink (a, b); \ + memcpy (a, init1, sizeof init1 - 1); \ + memcpy (b, init2, sizeof init2 - 1); \ + TEST_KEEP (0 == CMPFUNC (arg1, arg2, bnd)); \ + } while (0) + +const char s0[1] = ""; +const char s00[2] = "\0"; +const char s10[2] = "1"; +const char s20[2] = "2"; + +void sink (void*, ...); + +void test_strcmp_elim (void) +{ +#undef CMPFUNC +#define CMPFUNC(a, b, dummy) strcmp (a, b) + + FOLD (s00, s10, "\0", "1", -1); + FOLD (s00, s10, "\0", b, -1); + FOLD (s00, s10, "\0", s10, -1); + + FOLD (s00, s10, s0, "1", -1); + FOLD (s00, s10, s0, b, -1); + FOLD (s00, s10, s0, s10, -1); + + FOLD ("\0", "1", s0, "1", -1); + FOLD ("\0", "1", s0, b, -1); + FOLD ("\0", "1", s0, s10, -1); + + FOLD ("2", "\0", "2", "\0", -1); + FOLD ("2", "\0", s20, s0, -1); + + FOLD ("\0", "1", a, b, -1); + FOLD ("2", "\0", a, b, -1); + + FOLD ("4\0", "44", a, b, -1); + FOLD ("55", "5\0", a, b, -1); + + FOLD ("666\0", "6666", a, "6666", -1); + FOLD ("666\0", "6666", a, b, -1); + FOLD ("7777", "777\0", a, b, -1); + + /* Avoid testing substrings of equal length with different characters. + The optimization doesn't have access to the contents of the strings + so it can't determine whether they are equal. + + FOLD ("111\0", "112", a, b, -1); + FOLD ("112", "111\0", a, b, -1); */ +} + +const char s123[] = "123"; +const char s1230[] = "123\0"; + +const char s1234[] = "1234"; +const char s12340[] = "1234\0"; + +void test_strncmp_elim (void) +{ +#undef CMPFUNC +#define CMPFUNC(a, b, n) strncmp (a, b, n) + + FOLD (s1230, s1234, "123", "1234", 4); + FOLD (s1234, s1230, "1234", "123", 4); + + FOLD (s1230, s1234, "123", s1234, 4); + FOLD (s1234, s1230, "1234", s123, 4); + + FOLD (s1230, s1234, s123, "1234", 4); + FOLD (s1234, s1230, s1234, "123", 4); + + FOLD (s1230, s1234, s123, b, 4); + FOLD (s1234, s1230, s1234, b, 4); + + FOLD (s1230, s1234, a, b, 4); + FOLD (s1234, s1230, a, b, 4); + + FOLD ("123\0", "1234", a, b, 5); + FOLD ("1234", "123\0", a, b, 5); +} + + +#line 1000 + +void test_strcmp_keep (const char *s, const char *t) +{ +#undef CMPFUNC +#define CMPFUNC(a, b, dummy) strcmp (a, b) + + KEEP ("123", "123\0", a, b, /* bnd = */ -1); + KEEP ("123\0", "123", a, b, -1); + + { + char a[8], b[8]; + sink (a, b); + strcpy (a, s); + strcpy (b, t); + TEST_KEEP (0 == strcmp (a, b)); + } +} + + +void test_strncmp_keep (const char *s, const char *t) +{ +#undef CMPFUNC +#define CMPFUNC(a, b, n) strncmp (a, b, n) + + KEEP ("1", "1", a, b, 2); + + KEEP ("1\0", "1", a, b, 2); + KEEP ("1", "1\0", a, b, 2); + + KEEP ("12\0", "12", a, b, 2); + KEEP ("12", "12\0", a, b, 2); + + KEEP ("111\0", "111", a, b, 3); + KEEP ("112", "112\0", a, b, 3); + + { + char a[8], b[8]; + sink (a, b); + strcpy (a, s); + strcpy (b, t); + TEST_KEEP (0 == strncmp (a, b, sizeof a)); + } +} + +/* { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated_" 0 "optimized" } } + + { dg-final { scan-tree-dump-times "call_made_in_true_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 11 "optimized" } } + { dg-final { scan-tree-dump-times "call_made_in_false_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 11 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-66.c b/SingleSource/Regression/C/gcc-dg/strlenopt-66.c new file mode 100644 index 0000000000..469f3fd845 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-66.c @@ -0,0 +1,114 @@ +/* PRE tree-optimization/90626 - fold strcmp(a, b) == 0 to zero when + one string length is exact and the other is unequal + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + __builtin_abort ())) + + +__attribute__ ((noclone, noinline, noipa)) void +clobber (void *p, int x, size_t n) +{ + for (volatile unsigned char *q = p; n--; ) + *q = x; +} + +__attribute__ ((noclone, noinline, noipa)) void +test_strcmp (void) +{ + char a[8], b[8]; + strcpy (a, "1235"); + strcpy (b, "1234"); + + A (strcmp (a, b)); + + clobber (a, 0, sizeof a); + clobber (b, 0, sizeof b); + clobber (b + 4, '5', 1); + + memcpy (a, "1234", 4); + memcpy (b, "1234", 4); + + A (0 > strcmp (a, b)); + A (0 < strcmp (b, a)); +} + +__attribute__ ((noclone, noinline, noipa)) void +test_strncmp (void) +{ + char a[8], b[8]; + strcpy (a, "1235"); + strcpy (b, "1234"); + + A (0 == strncmp (a, b, 1)); + A (0 == strncmp (a, b, 2)); + A (0 == strncmp (a, b, 3)); + A (0 < strncmp (a, b, 4)); + A (0 > strncmp (b, a, 4)); + + clobber (a, 0, sizeof a); + clobber (b, 0, sizeof b); + clobber (b + 4, '5', 1); + + memcpy (a, "1234", 4); + memcpy (b, "1234", 4); + + A (0 == strncmp (a, b, 4)); + A (0 > strncmp (a, b, 5)); + A (0 < strncmp (b, a, 5)); +} + + +__attribute__ ((noclone, noinline, noipa)) void +test_strncmp_a4_cond_s5_s2_2 (const char *s, int i) +{ + char a4[4]; + strcpy (a4, s); + A (0 == strncmp (a4, i ? "12345" : "12", 2)); +} + + +__attribute__ ((noclone, noinline, noipa)) void +test_strncmp_a4_cond_a5_s2_5 (const char *s, const char *t, int i) +{ + char a4[4], a5[5]; + strcpy (a4, s); + strcpy (a5, t); + A (0 == strncmp (a4, i ? a5 : "12", 5)); +} + +__attribute__ ((noclone, noinline, noipa)) void +test_strncmp_a4_cond_a5_a3_n (const char *s1, const char *s2, const char *s3, + int i, unsigned n) +{ + char a3[3], a4[4], a5[5]; + strcpy (a3, s1); + strcpy (a4, s2); + strcpy (a5, s3); + A (0 == strncmp (a4, i ? a5 : a3, n)); +} + + +int main (void) +{ + test_strcmp (); + test_strncmp (); + test_strncmp_a4_cond_s5_s2_2 ("12", 0); + test_strncmp_a4_cond_a5_s2_5 ("12", "1234", 0); + + test_strncmp_a4_cond_a5_a3_n ("12", "1", "1", 0, 1); + test_strncmp_a4_cond_a5_a3_n ("", "1", "1234", 1, 1); + + test_strncmp_a4_cond_a5_a3_n ("12", "12", "1", 0, 2); + test_strncmp_a4_cond_a5_a3_n ("", "12", "1234", 1, 2); + + test_strncmp_a4_cond_a5_a3_n ("12", "123", "1", 0, 2); + test_strncmp_a4_cond_a5_a3_n ("", "123", "1234", 1, 3); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-67.c b/SingleSource/Regression/C/gcc-dg/strlenopt-67.c new file mode 100644 index 0000000000..e1b1de27d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-67.c @@ -0,0 +1,52 @@ +/* PR tree-optimization/90989 - incorrrect strlen result after second strcpy + into the same destination. + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +// #include "strlenopt.h" + +char a[4]; + +int f4 (void) +{ + char b[4]; + __builtin_strcpy (b, "12"); + + int i = __builtin_strcmp (a, b); + + __builtin_strcpy (b, "123"); + if (__builtin_strlen (b) != 3) + __builtin_abort (); + + return i; +} + +int f6 (void) +{ + char b[6]; + __builtin_strcpy (b, "1234"); + + int i = __builtin_strcmp (a, b); + + __builtin_strcpy (b, "12345"); + if (__builtin_strlen (b) != 5) + __builtin_abort (); + + return i; +} + +int f8 (void) +{ + char b[8]; + __builtin_strcpy (b, "1234"); + + int i = __builtin_strcmp (a, b); + + __builtin_strcpy (b, "1234567"); + if (__builtin_strlen (b) != 7) + __builtin_abort (); + + return i; +} + +/* { dg-final { scan-tree-dump-times "abort|strlen" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-68.c b/SingleSource/Regression/C/gcc-dg/strlenopt-68.c new file mode 100644 index 0000000000..f77162f2c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-68.c @@ -0,0 +1,383 @@ +/* PR tree-optimization/83431 - Verify that snprintf (0, 0, "%s", + with an argument that's a conditional expression evaluates to + the expected result regardless of the order of the expression + operands. + { dg-do run } + { dg-skip-if "UNIX 2003 return behavior not supported" { hppa*-*-hpux* } } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + __builtin_abort ())) + +const char gs0[] = ""; +const char gs3[] = "123"; + +char gc; +char ga5[7]; + +struct S { char n, ma7[7], max[]; }; + + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs0_gs3_ga5_m1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs0 : 0 < i ? gs3 : ga5; + + A (snprintf (0, 0, "%s", p) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs0_gs3_ga5_0 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs0 : 0 < i ? gs3 : ga5; + + A (snprintf (0, 0, "%s", p) == 4); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs0_gs3_ga5_p1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs0 : 0 < i ? gs3 : ga5; + + A (snprintf (0, 0, "%s", p) == 3); +} + + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs0_ga5_gs3_m1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs0 : 0 < i ? ga5 : gs3; + + A (snprintf (0, 0, "%s", p) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs0_ga5_gs3_0 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs0 : 0 < i ? ga5 : gs3; + + A (snprintf (0, 0, "%s", p) == 3); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs0_ga5_gs3_p1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs0 : 0 < i ? ga5 : gs3; + + A (snprintf (0, 0, "%s", p) == 4); +} + + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_ga5_gs0_gs3_m1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? ga5 : 0 < i ? gs0 : gs3; + + A (snprintf (0, 0, "%s", p) == 4); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_ga5_gs0_gs3_0 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? ga5 : 0 < i ? gs0 : gs3; + + A (snprintf (0, 0, "%s", p) == 3); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_ga5_gs0_gs3_p1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? ga5 : 0 < i ? gs0 : gs3; + + A (snprintf (0, 0, "%s", p) == 0); +} + + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_ga5_gs3_gs0_m1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? ga5 : 0 < i ? gs3 : gs0; + + A (snprintf (0, 0, "%s", p) == 4); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_ga5_gs3_gs0_0 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? ga5 : 0 < i ? gs3 : gs0; + + A (snprintf (0, 0, "%s", p) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_ga5_gs3_gs0_p1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? ga5 : 0 < i ? gs3 : gs0; + + A (snprintf (0, 0, "%s", p) == 3); +} + + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs3_gs0_ga5_m1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs3 : 0 < i ? gs0 : ga5; + + A (snprintf (0, 0, "%s", p) == 3); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs3_gs0_ga5_0 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs3 : 0 < i ? gs0 : ga5; + + A (snprintf (0, 0, "%s", p) == 4); +} + +__attribute__ ((noclone, noinline, noipa)) void +equal_4_gs3_gs0_ga5_p1 (int i) +{ + strcpy (ga5, "1234"); + const char *p = i < 0 ? gs3 : 0 < i ? gs0 : ga5; + + A (snprintf (0, 0, "%s", p) == 0); +} + + +/* Similar to the above but with memcpy creating a string at least + four characters long, and the address of the NUL character. */ + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gc_gs3_ga5_m1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? &gc : 0 < i ? gs3 : ga5; + + A (snprintf (0, 0, "%s", p) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gc_gs3_ga5_0 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? &gc : 0 < i ? gs3 : ga5; + + A (snprintf (0, 0, "%s", p) == 4); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gc_gs3_ga5_p1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? &gc : 0 < i ? gs3 : ga5; + + A (snprintf (0, 0, "%s", p) == 3); +} + + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gc_ga5_gs3_m1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? &gc : 0 < i ? ga5 : gs3; + + A (snprintf (0, 0, "%s", p) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gc_ga5_gs3_0 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? &gc : 0 < i ? ga5 : gs3; + + A (snprintf (0, 0, "%s", p) == 3); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gc_ga5_gs3_p1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? &gc : 0 < i ? ga5 : gs3; + + A (snprintf (0, 0, "%s", p) == 4); +} + + +__attribute__ ((noclone, noinline, noipa)) void +min_4_ga5_gc_gs3_m1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? ga5 : 0 < i ? &gc : gs3; + + A (snprintf (0, 0, "%s", p) == 4); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_ga5_gc_gs3_0 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? ga5 : 0 < i ? &gc : gs3; + + A (snprintf (0, 0, "%s", p) == 3); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_ga5_gc_gs3_p1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? ga5 : 0 < i ? &gc : gs3; + + A (snprintf (0, 0, "%s", p) == 0); +} + + +__attribute__ ((noclone, noinline, noipa)) void +min_4_ga5_gs3_gc_m1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? ga5 : 0 < i ? gs3 : &gc; + + A (snprintf (0, 0, "%s", p) == 4); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_ga5_gs3_gc_0 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? ga5 : 0 < i ? gs3 : &gc; + + A (snprintf (0, 0, "%s", p) == 0); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_ga5_gs3_gc_p1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? ga5 : 0 < i ? gs3 : &gc; + + A (snprintf (0, 0, "%s", p) == 3); +} + + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gs3_gc_ga5_m1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? gs3 : 0 < i ? &gc : ga5; + + A (snprintf (0, 0, "%s", p) == 3); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gs3_gc_ga5_0 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? gs3 : 0 < i ? &gc : ga5; + + A (snprintf (0, 0, "%s", p) == 4); +} + +__attribute__ ((noclone, noinline, noipa)) void +min_4_gs3_gc_ga5_p1 (int i) +{ + gc = 0; + memcpy (ga5, "1234", 4); + const char *p = i < 0 ? gs3 : 0 < i ? &gc : ga5; + + A (snprintf (0, 0, "%s", p) == 0); +} + + +int main (void) +{ + equal_4_gs0_gs3_ga5_m1 (-1); + equal_4_gs0_gs3_ga5_0 ( 0); + equal_4_gs0_gs3_ga5_p1 (+1); + + equal_4_gs0_ga5_gs3_m1 (-1); + equal_4_gs0_ga5_gs3_0 ( 0); + equal_4_gs0_ga5_gs3_p1 (+1); + + equal_4_ga5_gs0_gs3_m1 (-1); + equal_4_ga5_gs0_gs3_0 ( 0); + equal_4_ga5_gs0_gs3_p1 (+1); + + equal_4_ga5_gs3_gs0_m1 (-1); + equal_4_ga5_gs3_gs0_0 ( 0); + equal_4_ga5_gs3_gs0_p1 (+1); + + equal_4_gs3_gs0_ga5_m1 (-1); + equal_4_gs3_gs0_ga5_0 ( 0); + equal_4_gs3_gs0_ga5_p1 (+1); + + /* Same as aabove but with memcpy creating a string at least four + characters long. */ + memset (ga5, 0, sizeof ga5); + min_4_gc_gs3_ga5_m1 (-1); + memset (ga5, 0, sizeof ga5); + min_4_gc_gs3_ga5_0 ( 0); + memset (ga5, 0, sizeof ga5); + min_4_gc_gs3_ga5_p1 (+1); + + memset (ga5, 0, sizeof ga5); + min_4_gc_ga5_gs3_m1 (-1); + memset (ga5, 0, sizeof ga5); + min_4_gc_ga5_gs3_0 ( 0); + memset (ga5, 0, sizeof ga5); + min_4_gc_ga5_gs3_p1 (+1); + + memset (ga5, 0, sizeof ga5); + min_4_ga5_gc_gs3_m1 (-1); + memset (ga5, 0, sizeof ga5); + min_4_ga5_gc_gs3_0 ( 0); + memset (ga5, 0, sizeof ga5); + min_4_ga5_gc_gs3_p1 (+1); + + memset (ga5, 0, sizeof ga5); + min_4_ga5_gs3_gc_m1 (-1); + memset (ga5, 0, sizeof ga5); + min_4_ga5_gs3_gc_0 ( 0); + memset (ga5, 0, sizeof ga5); + min_4_ga5_gs3_gc_p1 (+1); + + memset (ga5, 0, sizeof ga5); + min_4_gs3_gc_ga5_m1 (-1); + memset (ga5, 0, sizeof ga5); + min_4_gs3_gc_ga5_0 ( 0); + memset (ga5, 0, sizeof ga5); + min_4_gs3_gc_ga5_p1 (+1); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-69.c b/SingleSource/Regression/C/gcc-dg/strlenopt-69.c new file mode 100644 index 0000000000..9df6eeccb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-69.c @@ -0,0 +1,132 @@ +/* PR tree-optimization/90879 - fold zero-equality of strcmp between + a longer string and a smaller array + { dg-do compile } + { dg-options "-O2 -Wall -Wno-string-compare -fdump-tree-optimized -ftrack-macro-expansion=0" } */ + +#include "strlenopt.h" + +#define A(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("assertion failed on line %i: %s\n", \ + __LINE__, #expr), \ + __builtin_abort ())) + +void clobber (void*, ...); + +struct S { char a4[4], c; }; + +extern char a4[4]; +extern char b4[4]; + +/* Verify that comparison of string literals with arrays with unknown + content but size that prevents them from comparing equal is folded + to a constant. */ + +void test_array_lit (void) +{ + A (strcmp (a4, "1234")); clobber (a4); + A (strcmp (a4, "12345")); clobber (a4); + A (strcmp (a4, "123456")); clobber (a4); + A (strcmp ("1234", a4)); clobber (a4); + A (strcmp ("12345", a4)); clobber (a4); + A (strcmp ("123456", a4)); clobber (a4); +} + +void test_memarray_lit (struct S *p) +{ +#if 0 + /* Member arrays not handled due to the fix for PR 92765. */ + A (strcmp (p->a4, "1234")); + A (strcmp (p->a4, "12345")); + A (strcmp (p->a4, "123456")); + + A (strcmp ("1234", p->a4)); + A (strcmp ("12345", p->a4)); + A (strcmp ("123456", p->a4)); +#endif +} + +/* Verify that the equality of empty strings is folded. */ + +void test_empty_string (void) +{ + A (0 == strcmp ("", "")); + + *a4 = '\0'; + A (0 == strcmp (a4, "")); + A (0 == strcmp ("", a4)); + A (0 == strcmp (a4, a4)); + + char s[8] = ""; + A (0 == strcmp (a4, s)); + + a4[1] = '\0'; + b4[1] = '\0'; + A (0 == strcmp (a4 + 1, b4 + 1)); + + a4[2] = '\0'; + b4[2] = '\0'; + A (0 == strcmp (&a4[2], &b4[2])); + +#if 0 + /* The following isn't handled yet due to PR 92155. */ + clobber (a4, b4); + + memset (a4, 0, sizeof a4); + memset (b4, 0, sizeof b4); + A (0 == strcmp (a4, b4)); +#endif +} + +/* Verify that comparison of dynamically created strings with unknown + arrays is folded. */ + +void test_array_copy (void) +{ + char s[8]; + strcpy (s, "1234"); + A (strcmp (a4, s)); + + strcpy (s, "12345"); + A (strlen (s) == 5); + A (strcmp (a4, s)); clobber (a4); + + strcpy (s, "123456"); + A (strcmp (a4, s)); clobber (a4); + + strcpy (s, "1234"); + A (strcmp (s, a4)); clobber (a4); + + strcpy (s, "12345"); + A (strcmp (s, a4)); clobber (a4); + + strcpy (s, "123456"); + A (strcmp (s, a4)); clobber (a4); +} + + +void test_array_bounded (void) +{ + A (strncmp (a4, "12345", 5)); clobber (a4); + A (strncmp ("54321", a4, 5)); clobber (a4); + + A (strncmp (a4, "123456", 5)); clobber (a4); + A (strncmp ("654321", a4, 5)); clobber (a4); +} + +void test_array_copy_bounded (void) +{ + char s[8]; + strcpy (s, "12345"); + A (strncmp (a4, s, 5)); clobber (a4); + strcpy (s, "54321"); + A (strncmp (s, a4, 5)); clobber (a4); + + strcpy (s, "123456"); + A (strncmp (a4, s, 5)); clobber (a4); + strcpy (s, "654321"); + A (strncmp (s, a4, 5)); clobber (a4); +} + +/* { dg-final { scan-tree-dump-not "abort|strcmp|strncmp" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-7.c b/SingleSource/Regression/C/gcc-dg/strlenopt-7.c new file mode 100644 index 0000000000..ba62c03962 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-7.c @@ -0,0 +1,51 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +char buf[64]; + +__attribute__((noinline, noclone)) size_t +foo (void) +{ + char *p = memcpy (buf, "abcdefgh", 9); + /* This store can be optimized away as... */ + *p = '\0'; + /* ... the following strcat can be optimized into memcpy, + which overwrites that '\0'. */ + strcat (p, "ijk"); + /* This should be optimized into return 3. */ + return strlen (p); +} + +__attribute__((noinline, noclone)) size_t +bar (char *p) +{ + char *r = strchr (p, '\0'); + /* This store shouldn't be optimized away, because we + want to crash if p is e.g. a string literal. */ + *r = '\0'; + /* This strlen can be optimized into 0. */ + return strlen (r); +} + +int +main () +{ + char *volatile p = buf; + if (foo () != 3 || memcmp (buf, "ijk\0efgh\0", 10) != 0) + abort (); + if (bar (p) != 0 || memcmp (buf, "ijk\0efgh\0", 10) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 2 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "\\*r_\[0-9\]* = 0;" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "return 3;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 0;" 2 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-70.c b/SingleSource/Regression/C/gcc-dg/strlenopt-70.c new file mode 100644 index 0000000000..0853023c3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-70.c @@ -0,0 +1,331 @@ +/* PR tree-optimization/91183 - strlen of a strcpy result with a conditional + source not folded + Test to verify that strlen can determine string lengths from wider stores + than narrow characters. This matters because on targets that can handle + unaligned stores and where GCC lowers multi-character stores into smaller + numbers of wider stores. + { dg-do compile } + { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define CHAR_BIT __CHAR_BIT__ + +typedef __UINT16_TYPE__ uint16_t; +typedef __UINT32_TYPE__ uint32_t; +typedef __UINT64_TYPE__ uint64_t; +typedef __UINT64_TYPE__ uint64_t; + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macros to emit a call to function named + call_failed_to_be_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if ((expr)) FAIL (not_eliminated); else (void)0 + +/* Verify that 'strlen (A) EXPECT' is folded to true. When non-null, + the first sizeof (INIT) - 1 bytes of the INIT arrray are stored + in A first, followed by *(TYPE*)A = ASSIGN. */ +#define T(init, type, off, assign, expect) do { \ + char a[32]; \ + memcpy (a, init ? init : "", init ? sizeof init - 1 : 0); \ + *(type*)(a + off) = assign; \ + ELIM (!(strlen (a) expect)); \ + } while (0) + +/* Same as T but works around the optimizer dropping the initializing + store before the assignment and defeating the strlen optimization. */ +#define TX(init, type, off, assign, expect) do { \ + char a[32]; \ + strcpy (a, init + 2); \ + strcat (a, init + sizeof (init) - 3); \ + *(type*)(a + off) = assign; \ + ELIM (!(strlen (a) expect)); \ + } while (0) + +/* Evaluates to an element at index I of the literal S padded with nuls + on the right. */ +#define ELT(s, i) ((s "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")[i]) + +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +/* Form a big-endian 16, 32, 64, and 128-byte integer from a string. */ +# define I16(s) (((uint16_t)ELT (s, 0) << 8) + (uint16_t)ELT (s, 1)) +# define I32(s) \ + (((uint32_t)ELT (s, 0) << 24) \ + + ((uint32_t)ELT (s, 1) << 16) \ + + ((uint32_t)ELT (s, 2) << 8) \ + + (uint32_t)ELT (s, 3)) +# define I64(s) \ + (((uint64_t)ELT (s, 0) << 56) \ + + ((uint64_t)ELT (s, 1) << 48) \ + + ((uint64_t)ELT (s, 2) << 40) \ + + ((uint64_t)ELT (s, 3) << 32) \ + + ((uint64_t)ELT (s, 4) << 24) \ + + ((uint64_t)ELT (s, 5) << 16) \ + + ((uint64_t)ELT (s, 6) << 8) \ + + ELT (s, 7)) +# define I128(s) \ + (((uint128_t)ELT (s, 0) << (64 + 56)) \ + + ((uint128_t)ELT (s, 1) << (64 + 48)) \ + + ((uint128_t)ELT (s, 2) << (64 + 40)) \ + + ((uint128_t)ELT (s, 3) << (64 + 32)) \ + + ((uint128_t)ELT (s, 4) << (64 + 24)) \ + + ((uint128_t)ELT (s, 5) << (64 + 16)) \ + + ((uint128_t)ELT (s, 6) << (64 + 8)) \ + + ((uint128_t)ELT (s, 7) << 64) \ + + ((uint128_t)ELT (s, 8) << 56) \ + + ((uint128_t)ELT (s, 9) << 48) \ + + ((uint128_t)ELT (s, 10) << 40) \ + + ((uint128_t)ELT (s, 11) << 32) \ + + ((uint128_t)ELT (s, 12) << 24) \ + + ((uint128_t)ELT (s, 13) << 16) \ + + ((uint128_t)ELT (s, 14) << 8) \ + + (uint128_t)ELT (s, 15)) + +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +/* Form a little-endian 16, 32, 64, and 128-byte integer from a string. */ +# define I16(s) (((uint16_t)ELT (s, 1) << 8) + (uint16_t)ELT (s, 0)) +# define I32(s) \ + (((uint32_t)ELT (s, 3) << 24) \ + + ((uint32_t)ELT (s, 2) << 16) \ + + ((uint32_t)ELT (s, 1) << 8) \ + + (uint32_t)ELT (s, 0)) +# define I64(s) \ + (((uint64_t)ELT (s, 7) << 56) \ + + ((uint64_t)ELT (s, 6) << 48) \ + + ((uint64_t)ELT (s, 5) << 40) \ + + ((uint64_t)ELT (s, 4) << 32) \ + + ((uint64_t)ELT (s, 3) << 24) \ + + ((uint64_t)ELT (s, 2) << 16) \ + + ((uint64_t)ELT (s, 1) << 8) \ + + ELT (s, 0)) +# define I128(s) \ + (((uint128_t)ELT (s, 15) << (64 + 56)) \ + + ((uint128_t)ELT (s, 14) << (64 + 48)) \ + + ((uint128_t)ELT (s, 13) << (64 + 40)) \ + + ((uint128_t)ELT (s, 12) << (64 + 32)) \ + + ((uint128_t)ELT (s, 11) << (64 + 24)) \ + + ((uint128_t)ELT (s, 10) << (64 + 16)) \ + + ((uint128_t)ELT (s, 9) << (64 + 8)) \ + + ((uint128_t)ELT (s, 8) << 64) \ + + ((uint128_t)ELT (s, 7) << 56) \ + + ((uint128_t)ELT (s, 6) << 48) \ + + ((uint128_t)ELT (s, 5) << 40) \ + + ((uint128_t)ELT (s, 4) << 32) \ + + ((uint128_t)ELT (s, 3) << 24) \ + + ((uint128_t)ELT (s, 2) << 16) \ + + ((uint128_t)ELT (s, 1) << 8) \ + + (uint128_t)ELT (s, 0)) +#endif + +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + +void store_16bit_be (void) +{ + T ("xxx", uint16_t, 0, 0x0001, == 0); + T ("xxx", uint16_t, 0, 0x0010, == 0); + T ("xxx", uint16_t, 0, 0x0011, == 0); + T ("xxx", uint16_t, 0, 0x0100, == 1); + T ("xxx", uint16_t, 0, 0x1000, == 1); + T ("xxx", uint16_t, 0, 0x1100, == 1); +} + +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + +void store_16bit_le (int i) +{ + uint16_t x0000 = I16 ("\0\0"); + uint16_t x0001 = 0x0001; + uint16_t x0010 = 0x0010; + uint16_t x0011 = 0x0011; + uint16_t x0100 = 0x0100; + uint16_t x1000 = 0x1000; + uint16_t x1100 = 0x1100; + + T (0, uint16_t, 0, x0000, == 0); + T ("x", uint16_t, 0, x0000, == 0); + T ("xx", uint16_t, 0, x0000, == 0); + T ("xxxx", uint16_t, 0, x0000, == 0); + T (0, uint16_t, 0, x0001, == 1); + T ("\0\0\0", uint16_t, 0, x0001, == 1); + T (0, uint16_t, 0, x0010, == 1); + T ("x\0\0", uint16_t, 0, x0010, == 1); + T (0, uint16_t, 0, x0011, == 1); + T ("xx\0", uint16_t, 0, x0011, == 1); + T (0, uint16_t, 0, x0100, == 0); + T ("\0\0\0", uint16_t, 0, x0100, == 0); + T (0, uint16_t, 0, x1000, == 0); + T ("x\0\0", uint16_t, 0, x1000, == 0); + T (0, uint16_t, 0, x1100, == 0); + T ("xx\0", uint16_t, 0, x1100, == 0); + + // FIXME: This fails because of the next test but succeeds on its own. + // T (0, uint16_t, 0, i ? x0001 : x0010, == 1); + T ("xxx", uint16_t, 0, i ? x0100 : x1100, == 0); +} + +#endif + +void store_32bit (volatile int i) +{ + T (0, uint32_t, 0, 0, == 0); + T ("x", uint32_t, 0, 0, == 0); + T ("xx", uint32_t, 0, 0, == 0); + T ("xxx", uint32_t, 0, 0, == 0); + T ("xxxx", uint32_t, 0, 0, == 0); + + T ("\0", uint32_t, 1, 0, == 0); + T ("x", uint32_t, 1, 0, == 1); + T ("xx", uint32_t, 2, 0, == 2); + T ("xxx", uint32_t, 3, 0, == 3); + + T ("xxx", uint32_t, 0, I32 ("\1\0\0\0"), == 1); + T ("xxx", uint32_t, 0, I32 ("\0\1\0\0"), == 0); + T ("xxx", uint32_t, 0, I32 ("\0\0\1\0"), == 0); + T ("xxx", uint32_t, 0, I32 ("\0\0\0\1"), == 0); + + T ("xxx", uint32_t, 0, I32 ("\1\2\0\0"), == 2); + T ("xxx", uint32_t, 0, I32 ("\0\1\2\0"), == 0); + T ("xxx", uint32_t, 0, I32 ("\0\0\1\2"), == 0); + + T ("xxx", uint32_t, 0, I32 ("\1\2\3\0"), == 3); + T ("xxx", uint32_t, 0, I32 ("\0\1\2\3"), == 0); + + uint32_t x123_ = I32 ("123\0"); + uint32_t x12__ = I32 ("12\0\0"); + uint32_t x1___ = I32 ("1\0\0\0"); + + // FIXME: Upper bound not implemented yet. + /* T ("xxxx", uint32_t, 0, i ? x123_ : x12__, <= 3); */ + T ("xxxx", uint32_t, 0, i ? x123_ : x12__, >= 2); + T ("xxxx", uint32_t, 0, i ? x12__ : x123_, >= 2); + /* T ("xxxx", uint32_t, 0, i ? x123_ : x1___, <= 3); */ + T ("xxxx", uint32_t, 0, i ? x123_ : x1___, >= 1); + T ("xxxx", uint32_t, 0, i ? x1___ : x123_, >= 1); + + TX ("abcde", uint32_t, 0, i ? I32 ("1234") : I32 ("1235"), == 5); + TX ("abcde", uint32_t, 1, i ? I32 ("1234") : I32 ("1235"), == 5); + + TX ("abcdef", uint32_t, 0, i ? I32 ("1235") : I32 ("1234"), == 6); + TX ("abcdef", uint32_t, 1, i ? I32 ("1235") : I32 ("1234"), == 6); + TX ("abcdef", uint32_t, 2, i ? I32 ("1235") : I32 ("1234"), == 6); + TX ("abcdef", uint32_t, 3, i ? I32 ("124\0") : I32 ("123\0"), == 6); + TX ("abcdef", uint32_t, 3, i ? I32 ("12\0\0") : I32 ("13\0\0"), == 5); + + TX ("abcdef", uint32_t, 3, i ? I32 ("12\0\0") : I32 ("123\0"), >= 5); + /* FIXME: Upper bound not implemented yet. */ + /* TX ("abcdef", uint32_t, 3, i ? I32 ("12\0\0") : I32 ("123\0"), < 7); */ +} + +void store_64bit (int i) +{ + T ("xxxxxxx", uint64_t, 0, I64 ("\1\0\0\0\0\0\0\0\0"), == 1); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\1\0\0\0\0\0\0\0"), == 0); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\0\1\0\0\0\0\0\0"), == 0); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\0\0\1\0\0\0\0\0"), == 0); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\0\0\0\1\0\0\0\0"), == 0); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\0\0\0\0\1\0\0\0"), == 0); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\0\0\0\0\0\1\0\0"), == 0); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\0\0\0\0\0\0\1\0"), == 0); + + T ("xxxxxxx", uint64_t, 0, I64 ("\1\2\0\0\0\0\0\0\0"), == 2); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\1\2\0\0\0\0\0\0"), == 0); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\0\1\2\0\0\0\0\0"), == 0); + + T ("xxxxxxx", uint64_t, 0, I64 ("\1\2\3\0\0\0\0\0\0"), == 3); + T ("xxxxxxx", uint64_t, 0, I64 ("\0\1\2\3\0\0\0\0\0"), == 0); + + T ("xxxxxxx", uint64_t, 0, I64 ("\1\2\3\4\0\0\0\0\0"), == 4); + T ("xxxxxxx", uint64_t, 0, I64 ("\1\2\3\4\5\0\0\0\0"), == 5); + T ("xxxxxxx", uint64_t, 0, I64 ("\1\2\3\4\5\6\0\0\0"), == 6); + T ("xxxxxxx", uint64_t, 0, I64 ("\1\2\3\4\5\6\7\0\0"), == 7); + + uint64_t x7777777_ = I64 ("\7\7\7\7\7\7\7"); + uint64_t x666666__ = I64 ("\6\6\6\6\6\6\0"); + uint64_t x4444____ = I64 ("\4\4\4\4\0\0\0"); + uint64_t x4343____ = I64 ("\4\3\4\3\0\0\0"); + uint64_t x1_______ = I64 ("\1\0\0\0\0\0\0"); + + /* FIXME: Upper bound not implemented yet. */ + /* T ("x\0xxxxxx", uint64_t, 0, i ? x7777777_ : x666666__, <= 7); */ + T ("xx\0xxxxx", uint64_t, 0, i ? x7777777_ : x666666__, >= 6); + T ("xxx\0xxxx", uint64_t, 1, i ? x7777777_ : x666666__, >= 7); + /* T ("xxx\0xxxx", uint64_t, 0, i ? x666666__ : x1, <= 6); */ + T ("xxxx\0xxx", uint64_t, 0, i ? x666666__ : x1_______, >= 1); + T ("xxxxxx\0x", uint64_t, 0, i ? x4444____ : x4343____, == 4); +} + +#if __SIZEOF_INT128__ + +typedef __uint128_t uint128_t; + +void store_128bit (void) +{ + uint128_t x1 = I128 ("\1"); + uint128_t x1z1 = I128 ("\0\1"); + uint128_t x2z1 = I128 ("\0\0\1"); + uint128_t x3z1 = I128 ("\0\0\0\1"); + uint128_t x4z1 = I128 ("\0\0\0\0\1"); + uint128_t x5z1 = I128 ("\0\0\0\0\0\1"); + uint128_t x6z1 = I128 ("\0\0\0\0\0\0\1"); + uint128_t x7z1 = I128 ("\0\0\0\0\0\0\0\1"); + uint128_t x8z1 = I128 ("\0\0\0\0\0\0\0\0\1"); + uint128_t x9z1 = I128 ("\0\0\0\0\0\0\0\0\0\1"); + uint128_t x10z1 = I128 ("\0\0\0\0\0\0\0\0\0\0\1"); + uint128_t x11z1 = I128 ("\0\0\0\0\0\0\0\0\0\0\0\1"); + uint128_t x12z1 = I128 ("\0\0\0\0\0\0\0\0\0\0\0\0\1"); + uint128_t x13z1 = I128 ("\0\0\0\0\0\0\0\0\0\0\0\0\0\1"); + uint128_t x14z1 = I128 ("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1"); + uint128_t x15z1 = I128 ("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1"); + + T ("xxxxxxx", uint128_t, 0, x1, == 1); + T ("xxxxxxx", uint128_t, 0, x1z1, == 0); + T ("xxxxxxx", uint128_t, 0, x2z1, == 0); + T ("xxxxxxx", uint128_t, 0, x3z1, == 0); + T ("xxxxxxx", uint128_t, 0, x4z1, == 0); + T ("xxxxxxx", uint128_t, 0, x5z1, == 0); + T ("xxxxxxx", uint128_t, 0, x6z1, == 0); + T ("xxxxxxx", uint128_t, 0, x7z1, == 0); + T ("xxxxxxx", uint128_t, 0, x8z1, == 0); + T ("xxxxxxx", uint128_t, 0, x9z1, == 0); + T ("xxxxxxx", uint128_t, 0, x10z1, == 0); + T ("xxxxxxx", uint128_t, 0, x11z1, == 0); + T ("xxxxxxx", uint128_t, 0, x12z1, == 0); + T ("xxxxxxx", uint128_t, 0, x13z1, == 0); + T ("xxxxxxx", uint128_t, 0, x14z1, == 0); + T ("xxxxxxx", uint128_t, 0, x15z1, == 0); + + T ("xxxxxxx", uint128_t, 0, I128 ("\2\1"), == 2); + T ("xxxxxxx", uint128_t, 0, I128 ("\0\2\1"), == 0); + + T ("xxxxxxx", uint128_t, 0, I128 ("\3\2\1"), == 3); + T ("xxxxxxx", uint128_t, 0, I128 ("\0\3\2\1"), == 0); + + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4"), == 4); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5"), == 5); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6"), == 6); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7"), == 7); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7\10"), == 8); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7\10\11"), == 9); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7\10\11\12"), == 10); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7\10\11\12\13"), == 11); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7\10\11\12\13\14"), == 12); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7\10\11\12\13\14\15"), == 13); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7\10\11\12\13\14\15\16"), == 14); + T ("xxxxxxx", uint128_t, 0, I128 ("\1\2\3\4\5\6\7\10\11\12\13\14\15\16\17"), == 15); +} + +#endif // __SIZEOF_INT128__ + +/* { dg-final { scan-tree-dump-times "strlen" 0 "optimized" } } + { dg-final { scan-tree-dump-times "_not_eliminated_" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-71.c b/SingleSource/Regression/C/gcc-dg/strlenopt-71.c new file mode 100644 index 0000000000..fd4c4a9e1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-71.c @@ -0,0 +1,223 @@ +/* PR tree-optimization/91183 - strlen of a strcpy result with a conditional + source not folded + Runtime test to verify that multibyte stores are handled correctly. + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define CHAR_BIT __CHAR_BIT__ + +typedef __UINT16_TYPE__ uint16_t; +typedef __UINT32_TYPE__ uint32_t; + +#define NOIPA __attribute__ ((noclone, noinline, noipa)) + +/* Prevent the optimizer from detemining invariants from prior tests. */ +NOIPA void terminate (void) +{ + __builtin_abort (); +} + +#define VERIFY(expr, str) \ + do { \ + const unsigned expect = strlen (str); \ + const unsigned len = strlen (expr); \ + if (len != expect) \ + { \ + __builtin_printf ("line %i: strlen(%s) == %u failed: " \ + "got %u with a = \"%.*s\"\n", \ + __LINE__, #expr, expect, len, \ + (int)sizeof a, a); \ + terminate (); \ + } \ + if (memcmp (a, str, expect + 1)) \ + { \ + __builtin_printf ("line %i: expected string \"%s\", " \ + "got a = \"%.*s\"\n", \ + __LINE__, str, (int)sizeof a, a); \ + terminate (); \ + } \ + } while (0) + + +#define ELT(s, i) ((s "\0\0\0\0")[i]) + +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define I16(s) (((uint16_t)ELT (s, 0) << 8) + (uint16_t)ELT (s, 1)) +# define I32(s) \ + (((uint32_t)ELT (s, 0) << 24) \ + + ((uint32_t)ELT (s, 1) << 16) \ + + ((uint32_t)ELT (s, 2) << 8) \ + + (uint32_t)ELT (s, 3)) +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define I16(s) (((uint16_t)ELT (s, 1) << 8) + (uint16_t)ELT (s, 0)) +# define I32(s) \ + (((uint32_t)ELT (s, 3) << 24) \ + + ((uint32_t)ELT (s, 2) << 16) \ + + ((uint32_t)ELT (s, 1) << 8) \ + + (uint32_t)ELT (s, 0)) +#endif + +char a[32]; + +NOIPA void +i16_1 (void) +{ + *(uint16_t*)a = I16 ("12"); + *(uint16_t*)(a + 2) = I16 ("3"); + VERIFY (a, "123"); + + *(uint16_t*)(a + 1) = I16 ("23"); + VERIFY (a, "123"); + + *(uint16_t*)(a) = I16 ("12"); + VERIFY (a, "123"); + + *(uint16_t*)(a + 1) = I16 ("2"); + VERIFY (a, "12"); + + *(uint16_t*)(a + 3) = I16 ("45"); + *(uint16_t*)(a + 2) = I16 ("34"); + VERIFY (a, "12345"); +} + +NOIPA void +i16_2 (void) +{ + strcpy (a, "12"); + strcat (a, "34"); + + *(uint16_t*)a = I16 ("12"); + VERIFY (a, "1234"); + + *(uint16_t*)(a + 1) = I16 ("12"); + VERIFY (a, "1124"); + + *(uint16_t*)(a + 2) = I16 ("12"); + VERIFY (a, "1112"); + + *(uint16_t*)(a + 3) = I16 ("12"); + VERIFY (a, "11112"); + + *(uint16_t*)(a + 4) = I16 ("12"); + VERIFY (a, "111112"); +} + + +NOIPA void +i32_1 (void) +{ + *(uint32_t*)a = I32 ("1234"); + VERIFY (a, "1234"); + + *(uint32_t*)(a + 1) = I32 ("2345"); + VERIFY (a, "12345"); +} + +NOIPA void +i32_2 (void) +{ + strcpy (a, "12"); + strcat (a, "34"); + + *(uint32_t*)a = I32 ("1234"); + VERIFY (a, "1234"); + + *(uint32_t*)(a + 4) = I32 ("567"); + VERIFY (a, "1234567"); + + *(uint32_t*)(a + 7) = I32 ("89\0"); + VERIFY (a, "123456789"); + + *(uint32_t*)(a + 3) = I32 ("4567"); + VERIFY (a, "123456789"); + + *(uint32_t*)(a + 2) = I32 ("3456"); + VERIFY (a, "123456789"); + + *(uint32_t*)(a + 1) = I32 ("2345"); + VERIFY (a, "123456789"); +} + + +NOIPA void +i32_3 (void) +{ + strcpy (a, "1234"); + strcat (a, "5678"); + + *(uint32_t*)a = I32 ("1234"); + VERIFY (a, "12345678"); + + *(uint32_t*)(a + 1) = I32 ("234"); + VERIFY (a, "1234"); + + *(uint32_t*)(a + 2) = I32 ("3456"); + VERIFY (a, "12345678"); + + *(uint32_t*)(a + 3) = I32 ("4567"); + VERIFY (a, "12345678"); + + *(uint32_t*)(a + 4) = I32 ("5678"); + VERIFY (a, "12345678"); + + *(uint32_t*)(a + 5) = I32 ("6789"); + VERIFY (a, "123456789"); + + *(uint32_t*)(a + 6) = I32 ("789A"); + VERIFY (a, "123456789A"); +} + +volatile int vzero = 0; + +NOIPA void +i32_4 (void) +{ + strcpy (a, "1234"); + strcat (a, "5678"); + + *(uint32_t*)a = vzero ? I32 ("1\0\0\0") : I32 ("1234"); + VERIFY (a, "12345678"); + + *(uint32_t*)a = vzero ? I32 ("12\0\0") : I32 ("1234"); + VERIFY (a, "12345678"); + + *(uint32_t*)a = vzero ? I32 ("123\0") : I32 ("1234"); + VERIFY (a, "12345678"); + + *(uint32_t*)a = vzero ? I32 ("1234") : I32 ("1234"); + VERIFY (a, "12345678"); + + *(uint32_t*)a = vzero ? I32 ("1235") : I32 ("1234"); + VERIFY (a, "12345678"); + + *(uint32_t*)a = vzero ? I32 ("1234") : I32 ("123\0"); + VERIFY (a, "123"); + + *(uint32_t*)(a + 3) = vzero ? I32 ("456\0") : I32 ("4567"); + VERIFY (a, "12345678"); +} + + +int main () +{ + memset (a, 0, sizeof a); + i16_1 (); + + memset (a, 0, sizeof a); + i16_2 (); + + + memset (a, 0, sizeof a); + i32_1 (); + + memset (a, 0, sizeof a); + i32_2 (); + + memset (a, 0, sizeof a); + i32_3 (); + + memset (a, 0, sizeof a); + i32_4 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-72.c b/SingleSource/Regression/C/gcc-dg/strlenopt-72.c new file mode 100644 index 0000000000..9c00a95162 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-72.c @@ -0,0 +1,69 @@ +/* PR tree-optimization/91183 - strlen of a strcpy result with a conditional + source not folded + Test to verify that strlen can determine string lengths from wider stores + than narrow characters. This matters because on targets that can handle + unaligned stores and where GCC lowers multi-character stores into smaller + numbers of wider stores. + { dg-do compile } + { dg-options "-O2 -fdump-tree-optimized" } + On strictly aligned targets the consecutive char assignments used + by the test aren't merged. When they involve multiple trailing nuls + these assignments then defeat the strlen optimization as a result of + pr83821. When the bug is resolved the directive below can be removed. + { dg-require-effective-target non_strict_align } */ + +#include "strlenopt.h" + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macros to emit a call to function named + call_failed_to_be_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if ((expr)) FAIL (not_eliminated); else (void)0 + +#undef T +#define T(N, ncpy, expect, assign) do { \ + char a[N], b[N]; \ + assign; \ + memcpy (b, a, ncpy); \ + ELIM (!(expect == strlen (b))); \ + } while (0) + +void test_copy (void) +{ + T (2, 1, 0, (a[0] = 0)); + T (2, 2, 0, (a[0] = 0, a[1] = 0)); + T (2, 2, 1, (a[0] = '1', a[1] = 0)); + T (4, 3, 2, (a[0] = '1', a[1] = '2', a[2] = 0)); + // Not handled due to pr83821: + // T (4, 3, 1, (a[0] = '1', a[1] = 0, a[2] = '2')); + T (4, 2, 1, (a[0] = '1', a[1] = 0, a[2] = 0, a[3] = 0)); + // Not handled due to pr83821: + // T (4, 3, 1, (a[0] = '1', a[1] = 0, a[2] = 0, a[3] = 0)); + T (4, 4, 1, (a[0] = '1', a[1] = 0, a[2] = 0, a[3] = 0)); + T (4, 3, 2, (a[0] = '1', a[1] = '2', a[2] = 0, a[3] = 0)); + T (4, 4, 2, (a[0] = '1', a[1] = '2', a[2] = 0, a[3] = 0)); + T (4, 4, 3, (a[0] = '1', a[1] = '2', a[2] = '3', a[3] = 0)); + T (5, 4, 1, (a[0] = '1', a[1] = 0, a[2] = 0, a[3] = 0)); + T (5, 4, 2, (a[0] = '1', a[1] = '2', a[2] = 0, a[3] = 0)); + T (5, 4, 3, (a[0] = '1', a[1] = '2', a[2] = '3', a[3] = 0)); + // Not handled: + // T (5, 5, 1, (a[0] = '1', a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 0)); + // T (5, 5, 2, (a[0] = '1', a[1] = '2', a[2] = 0, a[3] = 0, a[4] = 0)); + // T (5, 5, 3, (a[0] = '1', a[1] = '2', a[2] = '3', a[3] = 0, a[4] = 0)); + T (5, 5, 4, (a[0] = '1', a[1] = '2', a[2] = '3', a[3] = '4', a[4] = 0)); +} + + +/* { dg-final { scan-tree-dump-times "strlen" 0 "optimized" } } + { dg-final { scan-tree-dump-times "_not_eliminated_" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-73.c b/SingleSource/Regression/C/gcc-dg/strlenopt-73.c new file mode 100644 index 0000000000..6e15303dc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-73.c @@ -0,0 +1,144 @@ +/* PR tree-optimization/91183 - strlen of a strcpy result with a conditional + source not folded + Test to verify that strlen can determine string lengths from stores + involving PHI nodes with distinct strings of the same length of at + least 16 bytes. + + { dg-do compile } + { dg-options "-O2 -fdump-tree-optimized" } + On strictly aligned targets the consecutive char assignments used + by the test aren't merged. When they involve multiple trailing nuls + these assignments then defeat the strlen optimization as a result of + pr83821. When the bug is resolved the directive below can be removed. + { dg-require-effective-target non_strict_align } */ + +#include "strlenopt.h" + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macros to emit a call to function named + call_failed_to_be_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if ((expr)) FAIL (not_eliminated); else (void)0 + +#define T(expect, N, ncpy, cond) do { \ + char CONCAT (arr_, __LINE__)[N]; \ + char *pa = CONCAT (arr_, __LINE__); \ + memcpy (pa, cond, ncpy); \ + ELIM (!(expect strlen (pa))); \ + sink (pa); \ + } while (0) + +void sink (void*); + +const char a32[33] = "0123456789abcdef0123456789abcdef"; +const char b32[33] = "fedcba9876543210fedcba9876543210"; + +const char a16[33] = "0123456789abcdef"; +const char b16[33] = "fedcba9876543210"; + +int i0, i1, i2; + +void test_copy_cond_equal_length (void) +{ + // The test below is represented as this: + // # iftmp.0_3 = PHI <&b16(2), &a16(3)> + // MEM [(char * {ref-all})&a] + // = MEM [(char * {ref-all})iftmp.0_3]; + // _2 = strlen (&a); + T (16 ==, 17, 17, i0 ? a16 : b16); + T (16 ==, 17, 17, i0 ? a16 : b16); + T (15 ==, 17, 16, (i0 ? a16 : b16) + 1); + T (14 ==, 17, 15, (i0 ? a16 : b16) + 2); + T ( 0 ==, 17, 1, (i0 ? a16 : b16) + 16); + + T (31 ==, 33, 32, (i0 ? a32 : b32) + 1); + T (30 ==, 33, 31, (i0 ? a32 : b32) + 2); + T (29 ==, 33, 30, (i0 ? a32 : b32) + 3); + T ( 1 ==, 33, 2, (i0 ? a32 : b32) + 31); + T ( 0 ==, 33, 1, (i0 ? a32 : b32) + 32); +} + +#if (defined(__i386__) && defined(__SSE__)) || defined(__x86_64__) || defined(__aarch64__) \ + || defined(__s390__) || defined(__powerpc64__) + +/* The following tests assume GCC transforms the memcpy calls into + long long assignments which it does only on targets that define + the MOVE_MAX macro to 8 or higher. Enable on a set of targets + known to do that. */ + +const char a4[16] = "0123"; +const char b4[16] = "3210"; + +void test_copy_cond_unequal_length_i64 (void) +{ + T (2 <, 16, 8, i0 ? a4 + 1 : b4 + 0); + T (1 <, 16, 8, i0 ? a4 + 1 : b4 + 2); + T (0 <, 16, 8, i0 ? a4 + 1 : b4 + 3); + + T (1 <, 16, 8, i0 ? a4 + 2 : b4 + 0); + T (1 <, 16, 8, i0 ? a4 + 2 : b4 + 1); + T (0 <, 16, 8, i0 ? a4 + 2 : b4 + 3); +} + +#endif + + +#if defined(__x86_64__) && __SIZEOF_INT128__ == 16 + +/* The following tests assume GCC transforms the memcpy calls into + int128_t assignments which it does only on targets that define + the MOVE_MAX macro to 16. That's only s390 and x86_64 with + int128_t support. */ + +const char a8[32] = "01234567"; +const char b8[32] = "76543210"; + +void test_copy_cond_unequal_length_i128 (void) +{ + T (6 <, 32, 16, i0 ? a8 + 1 : b8 + 0); + T (5 <, 32, 16, i0 ? a8 + 1 : b8 + 2); + T (4 <, 32, 16, i0 ? a8 + 1 : b8 + 3); + T (3 <, 32, 16, i0 ? a8 + 1 : b8 + 4); + T (2 <, 32, 16, i0 ? a8 + 1 : b8 + 5); + T (1 <, 32, 16, i0 ? a8 + 1 : b8 + 6); + T (0 <, 32, 16, i0 ? a8 + 1 : b8 + 7); + + T (5 <, 32, 16, i0 ? a8 + 2 : b8 + 0); + T (5 <, 32, 16, i0 ? a8 + 2 : b8 + 1); + T (3 <, 32, 16, i0 ? a8 + 2 : b8 + 3); + T (2 <, 32, 16, i0 ? a8 + 2 : b8 + 4); + T (1 <, 32, 16, i0 ? a8 + 2 : b8 + 5); + T (0 <, 32, 16, i0 ? a8 + 2 : b8 + 6); + + T (4 <, 32, 16, i0 ? a8 + 3 : b8 + 0); + T (4 <, 32, 16, i0 ? a8 + 3 : b8 + 1); + T (4 <, 32, 16, i0 ? a8 + 3 : b8 + 2); + T (3 <, 32, 16, i0 ? a8 + 3 : b8 + 4); + T (2 <, 32, 16, i0 ? a8 + 3 : b8 + 5); + T (1 <, 32, 16, i0 ? a8 + 3 : b8 + 6); + T (0 <, 32, 16, i0 ? a8 + 3 : b8 + 7); + + T (3 <, 32, 16, i0 ? a8 + 4 : b8 + 0); + T (3 <, 32, 16, i0 ? a8 + 4 : b8 + 1); + T (3 <, 32, 16, i0 ? a8 + 4 : b8 + 2); + T (3 <, 32, 16, i0 ? a8 + 4 : b8 + 3); + T (2 <, 32, 16, i0 ? a8 + 4 : b8 + 5); + T (1 <, 32, 16, i0 ? a8 + 4 : b8 + 6); + T (0 <, 32, 16, i0 ? a8 + 4 : b8 + 7); +} + +#endif /* Support for i128_t stores. */ + +/* { dg-final { scan-tree-dump-times "strlen" 0 "optimized" } } + { dg-final { scan-tree-dump-times "_not_eliminated_" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-74.c b/SingleSource/Regression/C/gcc-dg/strlenopt-74.c new file mode 100644 index 0000000000..19e9a60858 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-74.c @@ -0,0 +1,175 @@ +/* PR tree-optimization/91294 - wrong strlen result of a conditional with + an offset + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define NOIPA __attribute__ ((noclone, noinline, noipa)) + +#define CAT(a, b) a ## b +#define CONCAT(a, b) CAT (a, b) +#define UNIQ_NAME(name) CONCAT (name, __LINE__) + +extern int last_line; +int nfails; + +char buf[32]; + +#define VERIFY(expr, nbytes, expect) \ + NOIPA void UNIQ_NAME (test_)(void) \ + { \ + memcpy (buf, (expr), (nbytes)); \ + const size_t len = strlen (buf); \ + if (len != expect) \ + { \ + ++nfails; \ + __builtin_printf ("line %i: strlen(%s) == %zu failed: " \ + "got %zu\n", \ + __LINE__ - 1000 + last_line + 2, \ + #expr, (size_t)expect, \ + len); \ + } \ + } typedef void DummyType + +const char a8[12] = "01234567"; +const char b8[12] = "76543210"; +const char c4[12] = "0123"; + +int i0, i1 = 1, i2 = 2; + +int last_line = __LINE__; +#line 1000 +VERIFY (i0 ? (a8 + 0) : (b8 + 0), 9, 8); +VERIFY (i0 ? (a8 + 0) : (b8 + 1), 8, 7); +VERIFY (i0 ? (a8 + 0) : (b8 + 2), 8, 6); +VERIFY (i0 ? (a8 + 0) : (b8 + 2), 7, 6); +VERIFY (i0 ? (a8 + 0) : (b8 + 3), 8, 5); +VERIFY (i0 ? (a8 + 0) : (b8 + 3), 7, 5); +VERIFY (i0 ? (a8 + 0) : (b8 + 3), 6, 5); +VERIFY (i0 ? (a8 + 0) : (b8 + 4), 8, 4); +VERIFY (i0 ? (a8 + 0) : (b8 + 4), 7, 4); +VERIFY (i0 ? (a8 + 0) : (b8 + 4), 6, 4); +VERIFY (i0 ? (a8 + 0) : (b8 + 4), 5, 4); +VERIFY (i0 ? (a8 + 0) : (b8 + 5), 7, 3); +VERIFY (i0 ? (a8 + 0) : (b8 + 5), 6, 3); +VERIFY (i0 ? (a8 + 0) : (b8 + 5), 5, 3); +VERIFY (i0 ? (a8 + 0) : (b8 + 5), 4, 3); +VERIFY (i0 ? (a8 + 0) : (b8 + 6), 3, 2); +VERIFY (i0 ? (a8 + 0) : (b8 + 7), 2, 1); +VERIFY (i0 ? (a8 + 1) : (b8 + 0), 8, 8); +VERIFY (i0 ? (a8 + 2) : (b8 + 0), 7, 7); +VERIFY (i0 ? (a8 + 1) : (b8 + 1), 8, 7); +VERIFY (i0 ? (a8 + 1) : (b8 + 2), 7, 6); +VERIFY (i0 ? (a8 + 2) : (b8 + 1), 8, 7); // FAIL +VERIFY (i0 ? (a8 + 2) : (b8 + 2), 7, 6); +VERIFY (i0 ? (a8 + 0) : (b8 + 0), 9, 8); +VERIFY (i0 ? (a8 + 0) : (b8 + 1), 8, 7); +VERIFY (i0 ? (a8 + 0) : (b8 + 2), 7, 6); +VERIFY (i0 ? (a8 + 1) : (b8 + 0), 9, 8); +VERIFY (i0 ? (a8 + 2) : (b8 + 0), 9, 8); +VERIFY (i0 ? (a8 + 1) : (b8 + 1), 8, 7); +VERIFY (i0 ? (a8 + 1) : (b8 + 2), 7, 6); +VERIFY (i0 ? (a8 + 2) : (b8 + 1), 8, 7); // FAIL +VERIFY (i0 ? (a8 + 2) : (b8 + 2), 7, 6); +VERIFY (i0 ? (a8 + 0) : (c4 + 0), 9, 4); +VERIFY (i0 ? (a8 + 0) : (c4 + 1), 9, 3); +VERIFY (i0 ? (a8 + 0) : (c4 + 3), 9, 1); +VERIFY (i0 ? (a8 + 0) : (c4 + 4), 8, 0); +VERIFY (i0 ? (a8 + 1) : (c4 + 0), 8, 4); +VERIFY (i0 ? (a8 + 1) : (c4 + 1), 8, 3); +VERIFY (i0 ? (a8 + 1) : (c4 + 2), 8, 2); +VERIFY (i0 ? (a8 + 1) : (c4 + 3), 8, 1); +VERIFY (i0 ? (a8 + 1) : (c4 + 4), 8, 0); +VERIFY (i0 ? (a8 + 2) : (c4 + 0), 8, 4); +VERIFY (i0 ? (a8 + 2) : (c4 + 1), 8, 3); +VERIFY (i0 ? (a8 + 2) : (c4 + 2), 8, 2); +VERIFY (i0 ? (a8 + 2) : (c4 + 3), 8, 1); +VERIFY (i0 ? (a8 + 2) : (c4 + 4), 8, 0); +VERIFY ((i0 ? a8 : b8) + 1, 8, 7); +VERIFY ((i0 ? a8 : b8) + 2, 8, 6); +VERIFY ((i0 ? a8 : b8) + 2, 7, 6); +VERIFY ((i0 ? a8 : b8) + 3, 3, 3); +VERIFY ((i0 ? a8 : b8) + 3, 1, 1); +VERIFY ((i0 ? a8 : c4) + 1, 8, 3); +VERIFY ((i0 ? a8 : c4) + 3, 8, 1); +VERIFY ((i0 ? a8 : c4) + 4, 8, 0); +VERIFY ((i0 ? a8 + 1: b8 + 2) + 1, 9, 5); +VERIFY ((i0 ? a8 + i1: b8 + i2) + 1, 8, 5); +VERIFY ((i0 ? a8 + i1: b8 + 2) + 1, 8, 5); +VERIFY ((i0 ? a8 + i2: b8 + i1) + 1, 8, 6); +VERIFY ((i0 ? a8 + 2: b8 + i1) + 1, 8, 6); + +#define T(N) test_ ## N (); memset (buf, 0, sizeof buf) + +int main (void) +{ + T (1000); + T (1001); + T (1002); + T (1003); + T (1004); + T (1005); + T (1006); + T (1007); + T (1008); + T (1009); + + T (1010); + T (1011); + T (1012); + T (1013); + T (1014); + T (1015); + T (1016); + T (1017); + T (1018); + T (1019); + + T (1020); + T (1021); + T (1022); + T (1023); + T (1024); + T (1025); + T (1026); + T (1027); + T (1028); + T (1029); + + T (1030); + T (1031); + T (1032); + T (1033); + T (1034); + T (1035); + T (1036); + T (1037); + T (1038); + T (1039); + + T (1040); + T (1041); + T (1042); + T (1043); + T (1044); + T (1045); + T (1046); + T (1047); + T (1048); + T (1049); + + T (1050); + T (1051); + T (1052); + T (1053); + T (1054); + T (1055); + T (1056); + T (1057); + T (1058); + + if (nfails) + abort (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-75.c b/SingleSource/Regression/C/gcc-dg/strlenopt-75.c new file mode 100644 index 0000000000..e57f0c4bcf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-75.c @@ -0,0 +1,118 @@ +/* PR tree-optimization/91294 - strlen result of a conditional with + an offset + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define NOIPA __attribute__ ((noclone, noinline, noipa)) + +int i = 0; + +const char s[] = "1234567"; + +char a[32]; + +/* Exercise a memcpy overwriting a destination string of known length + with a source argument involving a conditional expression with strings + of unqual lengths, with the selected one being the longer of the two + and resulting in no change to the length of the overwritten destination + string. */ +NOIPA void test_memcpy_same_length () +{ + memcpy (a, "123456789a", 11); + memcpy (a + 6, i ? "78\0" : "789\0", 4); + if (strlen (a) != 9) + abort (); +} + +/* Same as above but with strcpy/strcat. */ + +NOIPA void test_strcpy_strcat_same_length () +{ + strcpy (a, "12345678"); + strcat (a, "9a"); + memcpy (a + 6, i ? "78\0" : "789\0", 4); + if (strlen (a) != 9) + abort (); +} + +/* Same as above but using a memcpy of a power-of-two size that gets + (on some targets) transformed into a single MEM_REF assignment. */ + +NOIPA void test_assign_same_length () +{ + memcpy (a, s, 8); + memcpy (a + 5, i ? "67\0" : "678\0", 4); + if (strlen (a) != 8) + abort (); +} + +/* Same as above but resulting in increasing the length of the destination + string. */ + +NOIPA void test_memcpy_lengthen () +{ + memcpy (a, "123456789a", 11); + memcpy (a + 8, i ? "9a\0" : "9ab\0", 4); + if (strlen (a) != 11) + abort (); +} + +NOIPA void test_strcpy_strcat_lengthen () +{ + strcpy (a, "12345678"); + strcat (a, "9a"); + memcpy (a + 8, i ? "9a\0" : "9ab\0", 4); + if (strlen (a) != 11) + abort (); +} + +NOIPA void test_assign_lengthen () +{ + memcpy (a, s, 8); + memcpy (a + 6, i ? "78\0" : "789\0", 4); + if (strlen (a) != 9) + abort (); +} + +NOIPA void test_memcpy_shorten () +{ + memcpy (a, "123456789a", 11); + memcpy (a + 6, i ? "789\0" : "78\0", 4); + if (strlen (a) != 8) + abort (); +} + +NOIPA void test_strcpy_strcat_shorten () +{ + strcpy (a, "12345678"); + strcat (a, "9a"); + memcpy (a + 6, i ? "789\0" : "78\0", 4); + if (strlen (a) != 8) + abort (); +} + +NOIPA void test_assign_shorten () +{ + memcpy (a, s, 8); + memcpy (a + 6, i ? "789\0" : "78\0", 4); + if (strlen (a) != 8) + abort (); +} + + +int main (void) +{ + test_memcpy_same_length (); + test_strcpy_strcat_same_length (); + test_assign_same_length (); + + test_memcpy_lengthen (); + test_strcpy_strcat_lengthen (); + test_assign_lengthen (); + + test_memcpy_shorten (); + test_strcpy_strcat_shorten (); + test_assign_shorten (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-76.c b/SingleSource/Regression/C/gcc-dg/strlenopt-76.c new file mode 100644 index 0000000000..30ccd166a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-76.c @@ -0,0 +1,174 @@ +/* PR tree-optimization/91294 - strlen result of a conditional with + an offset + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define NOIPA __attribute__ ((noclone, noinline, noipa)) + +#define assert(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("line %i %s: assertion failed: %s\n", \ + __LINE__, __func__, #expr), \ + __builtin_abort ())) + +int i = 0; + +const char s[] = "1234567"; + +char a[32]; + +NOIPA void lower_bound_assign_into_empty (void) +{ + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + assert (strlen (a) == 3); +} + +NOIPA void lower_bound_assign_into_longest (void) +{ + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + assert (strlen (a) == 31); +} + + +NOIPA void lower_bound_assign_into_empty_idx_3 (int idx) +{ + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + a[idx] = 'x'; + assert (strlen (a) == 4); +} + +NOIPA void lower_bound_assign_into_longest_idx_2 (int idx) +{ + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + a[idx] = '\0'; + assert (strlen (a) == 2); +} + + +NOIPA void lower_bound_memcpy_into_empty (void) +{ + memcpy (a, "123", 3); + assert (strlen (a) == 3); +} + +NOIPA void lower_bound_memcpy_into_longest (void) +{ + memcpy (a, "123", 3); + assert (strlen (a) == 31); +} + + +NOIPA void lower_bound_memcpy_memcpy_into_empty (void) +{ + memcpy (a, "123", 3); + memcpy (a + 2, "345", 3); + assert (strlen (a) == 5); +} + +NOIPA void lower_bound_memcpy_memcpy_into_longest (void) +{ + memcpy (a, "123", 3); + memcpy (a + 2, "345", 3); + assert (strlen (a) == 31); +} + + +NOIPA void memove_forward_strlen (void) +{ + char a[] = "123456"; + + memmove (a, a + 1, sizeof a - 1); + + assert (strlen (a) == 5); +} + +NOIPA void memove_backward_into_empty_strlen (void) +{ + strcpy (a, "123456"); + + memmove (a + 1, a, 6); + + assert (strlen (a) == 7); +} + +NOIPA void memove_backward_into_longest_strlen (void) +{ + memcpy (a, "123456", 6); + + memmove (a + 1, a, 6); + + assert (strlen (a) == 31); +} + +NOIPA void memove_strcmp (void) +{ + /* Test derived from libstdc++-v3's + 20_util/specialized_algorithms/memory_management_tools/1.cc */ + + char a[] = "123456"; + char b[] = "000000"; + + memmove (b, a, sizeof a); + + assert (strlen (a) == 6); + assert (strlen (b) == 6); + assert (strcmp (a, b) == 0); +} + + +int main (void) +{ + memset (a, '\0', sizeof a); + lower_bound_assign_into_empty (); + + memset (a, 'x', sizeof a - 1); + a[sizeof a - 1] = '\0'; + lower_bound_assign_into_longest (); + + memset (a, '\0', sizeof a); + lower_bound_assign_into_empty_idx_3 (3); + + memset (a, 'x', sizeof a - 1); + a[sizeof a - 1] = '\0'; + lower_bound_assign_into_longest_idx_2 (2); + + memset (a, '\0', sizeof a); + lower_bound_memcpy_into_empty (); + + memset (a, 'x', sizeof a - 1); + a[sizeof a - 1] = '\0'; + lower_bound_memcpy_into_longest (); + + memset (a, 'x', sizeof a - 1); + a[sizeof a - 1] = '\0'; + lower_bound_memcpy_into_longest (); + + memset (a, '\0', sizeof a); + lower_bound_memcpy_memcpy_into_empty (); + + memset (a, 'x', sizeof a - 1); + a[sizeof a - 1] = '\0'; + lower_bound_memcpy_memcpy_into_longest (); + + memove_forward_strlen (); + + memset (a, '\0', sizeof a); + memove_backward_into_empty_strlen (); + + memset (a, 'x', sizeof a - 1); + a[sizeof a - 1] = '\0'; + memove_backward_into_longest_strlen (); + + memove_strcmp (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-77.c b/SingleSource/Regression/C/gcc-dg/strlenopt-77.c new file mode 100644 index 0000000000..76cd11d6ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-77.c @@ -0,0 +1,84 @@ +/* PR tree-optimization/91315 - missing strlen lower bound of a string + known to be at least N characters + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to function named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ASSERT_ELIM(expr) \ + if (!!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +char a[32]; + +void lower_bound_assign_1 (void) +{ + a[0] = '1'; + ASSERT_ELIM (strlen (a) < 1); +} + +void lower_bound_assign_2 (void) +{ + a[0] = '1'; + a[1] = '2'; + ASSERT_ELIM (strlen (a) < 2); +} + +void lower_bound_assign_3 (void) +{ + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + ASSERT_ELIM (strlen (a) < 3); +} + +void lower_bound_memcpy (void) +{ + memcpy (a, "123", 3); + ASSERT_ELIM (strlen (a) < 3); +} + +void lower_bound_memcpy_memcpy_2 (void) +{ + memcpy (a, "123", 3); + memcpy (a + 2, "345", 3); + ASSERT_ELIM (strlen (a) < 5); +} + +void lower_bound_memcpy_memcpy_3 (void) +{ + memcpy (a, "123", 3); + memcpy (a + 3, "456", 3); + ASSERT_ELIM (strlen (a) < 6); +} + +/* FIXME: Not optimized yet. +void lower_bound_stpcpy_stpcpy_assign (void) +{ + *stpcpy (strcpy (a, "123"), "4567") = '8'; + ASSERT_ELIM (strlen (a) < 8); +} +*/ + +void lower_bound_strcpy_strcat_assign (void) +{ + strcpy (a, "123"); + strcat (a, "45"); + a[5] = '6'; + ASSERT_ELIM (strlen (a) < 6); +} + +/* { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated_" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-78.c b/SingleSource/Regression/C/gcc-dg/strlenopt-78.c new file mode 100644 index 0000000000..c028723e59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-78.c @@ -0,0 +1,166 @@ +/* PR middle-end/91490 - bogus argument missing terminating nul warning + on strlen of a flexible array member + Verify that strlen calls with a flexible array member (and its common + forms) of declaraed objects are folded. + { dg-do compile } + { dg-options "-Wall -fdump-tree-gimple" } */ + +#include "strlenopt.h" + +extern void* memchr (const void*, int, size_t); + +struct A1 { char n, a[1]; }; +struct A2 { char n, a[2]; }; +struct A3 { char n, a[3]; }; +struct Ax { char n, a[]; }; + +const struct A1 a1_0 = { 0 }; +const struct A1 a1_0_ = { 0, { } }; +const struct A1 a1_0_0 = { 0, { 0 } }; + +const struct A2 a2_1_ = { 1, { } }; +const struct A2 a2_1_1 = { 1, { 1 } }; +const struct A2 a2_1_1_0 = { 1, { 1, 0 } }; + +const struct A3 aa3_1_[2] = { { 1 } }; + +const struct Ax ax = { 3, { 3, 2, 1, 0 } }; + +struct BxA1 { int n; struct A1 a[]; }; +struct BxA2 { int n; struct A2 a[]; }; + +const struct BxA2 bx = { 2, { { 2, { 2, 1 } }, { 2, { 1, 0 } } } }; + +#if 0 + +// Not implemented yet. + +int mchr1, mchr1__, mchr1_0, mchr2_1, mchr2, mchr2_1_0, mchrax, mchrbx; + +void test_memchr_flexarray (void) +{ + mchr1 = 0 != memchr (&a1_0, '1', sizeof a1_0); + mchr1__ = 0 != memchr (&a1_0_, '2', sizeof a1_0_); + mchr1_0 = 0 != memchr (&a1_0_0, '3', sizeof a1_0_0); + + mchr2 = 0 != memchr (&a2_1_, '4', sizeof a2_1_); + mchr2_1 = 0 != memchr (&a2_1_1, '\001', sizeof a2_1_1); + mchr2_1_0 = 0 != memchr (&a2_1_1_0, '\001', sizeof a2_1_1_0); + + mchrax = (const char*)&ax + sizeof ax - 1 == memchr (&ax, '\001', sizeof ax); + mchrbx = (const char*)&bx + sizeof bx - 1 == memchr (&bx, '\001', sizeof bx); +} + +#endif + + +int schr1, schr1__, schr1_0, schr2_1, schr2, schr2_1_0, schrax, schrbx; + +void test_strchr_flexarray (void) +{ + schr1 = 0 != strchr (a1_0.a, '1'); + schr1__ = 0 != strchr (a1_0_.a, '2'); + schr1_0 = 0 != strchr (a1_0_0.a, '3'); + + schr2 = 0 != strchr (a2_1_.a, '4'); + schr2_1 = 0 != strchr (a2_1_1.a, '\001'); + schr2_1_0 = 0 != strchr (a2_1_1_0.a, '\001'); + + schrax = 0 != strchr (ax.a, '\001'); + schrbx = 0 != strchr (bx.a[1].a, '\0'); + + /* { dg-final { scan-tree-dump "schr1 = 0;" "gimple" } } + { dg-final { scan-tree-dump "schr1__ = 0;" "gimple" } } + { dg-final { scan-tree-dump "schr1_0 = 0;" "gimple" } } + { dg-final { scan-tree-dump "schr2 = 0;" "gimple" } } + { dg-final { scan-tree-dump "schr2_1 = 1;" "gimple" } } + { dg-final { scan-tree-dump "schr2_1_0 = 1;" "gimple" } } + { dg-final { scan-tree-dump "schrax = 1;" "gimple" } } + { dg-final { scan-tree-dump "schrbx = 1;" "gimple" } } */ +} + + +int scmp1, scmp1__, scmp1_0, scmp2_1, scmp2, scmp2_1_0, scmpax, scmpbx; + +void test_strcmp_flexarray (void) +{ + scmp1 = 0 == strcmp (a1_0.a, "1"); + scmp1__ = 0 == strcmp (a1_0_.a, "2"); + scmp1_0 = 0 == strcmp (a1_0_0.a, "3"); + + scmp2 = 0 == strcmp (a2_1_.a, "4"); + scmp2_1 = 0 == strcmp (a2_1_1.a, "\001"); + scmp2_1_0 = 0 == strcmp (a2_1_1_0.a, "\001"); + + scmpax = 0 == strcmp (ax.a, "\003\002\001"); + scmpbx = 0 == strcmp (bx.a[1].a, "\001"); + + /* { dg-final { scan-tree-dump "scmp1 = 0;" "gimple" } } + { dg-final { scan-tree-dump "scmp1__ = 0;" "gimple" } } + { dg-final { scan-tree-dump "scmp1_0 = 0;" "gimple" } } + { dg-final { scan-tree-dump "scmp2 = 0;" "gimple" } } + { dg-final { scan-tree-dump "scmp2_1 = 1;" "gimple" } } + { dg-final { scan-tree-dump "scmp2_1_0 = 1;" "gimple" } } + { dg-final { scan-tree-dump "scmpax = 1;" "gimple" } } + { dg-final { scan-tree-dump "scmpbx = 1;" "gimple" } } */ +} + + +int len1, len1__, len1_0, len2_1, len2, len2_1_0, lenax, lenbx; + +void test_strlen_flexarray (void) +{ + len1 = strlen (a1_0.a); + len1__ = strlen (a1_0_.a); + len1_0 = strlen (a1_0_0.a); + + len2 = strlen (a2_1_.a); + len2_1 = strlen (a2_1_1.a); + len2_1_0 = strlen (a2_1_1_0.a); + + lenax = strlen (ax.a); + lenbx = strlen (bx.a[1].a); + + /* { dg-final { scan-tree-dump "len1 = 0;" "gimple" } } + { dg-final { scan-tree-dump "len1__ = 0;" "gimple" } } + { dg-final { scan-tree-dump "len1_0 = 0;" "gimple" } } + { dg-final { scan-tree-dump "len2 = 0;" "gimple" } } + { dg-final { scan-tree-dump "len2_1 = 1;" "gimple" } } + { dg-final { scan-tree-dump "len2_1_0 = 1;" "gimple" } } + { dg-final { scan-tree-dump "lenax = 3;" "gimple" } } + { dg-final { scan-tree-dump "lenbx = 1;" "gimple" } } */ +} + + +int schraa3, scmpaa3, lenaa3; + +void test_trailing_array_empty_init (void) +{ + schraa3 = ((aa3_1_[0].a == strchr (aa3_1_[0].a, 0)) + + (aa3_1_[1].a == strchr (aa3_1_[1].a, 0))); + + scmpaa3 = strcmp (aa3_1_[0].a, aa3_1_[1].a); + lenaa3 = strlen (aa3_1_[0].a) + strlen (aa3_1_[1].a); + + /* { dg-final { scan-tree-dump "schraa3 = 2;" "gimple" } } + { dg-final { scan-tree-dump "scmpaa3 = 0;" "gimple" } } + { dg-final { scan-tree-dump "lenaa3 = 0;" "gimple" } } */ +} + +union U4 { char a[4]; int i; }; +const union U4 u4[2] = { { "123" } }; + +int ulen0, ulen1; + +void test_union_init (void) +{ + ulen0 = strlen (u4[0].a); + ulen1 = strlen (u4[1].a); + + /* { dg-final { scan-tree-dump "ulen0 = 3;" "gimple" } } + { dg-final { scan-tree-dump "ulen1 = 0;" "gimple" } } */ +} + +/* { dg-final { scan-tree-dump-not "strchr *\\(" "gimple" } } + { dg-final { scan-tree-dump-not "strcmp *\\(" "gimple" } } + { dg-final { scan-tree-dump-not "strlen *\\(" "gimple" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-79.c b/SingleSource/Regression/C/gcc-dg/strlenopt-79.c new file mode 100644 index 0000000000..362cbfbe27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-79.c @@ -0,0 +1,46 @@ +/* PR tree-optimization/91914 - Invalid strlen folding for offset into struct + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#define assert(expr) \ + ((expr) \ + ? (void)0 \ + : (__builtin_printf ("%s:%i: assertion failed: %s\n", \ + __FILE__, __LINE__, #expr), \ + __builtin_abort ())) + +extern __SIZE_TYPE__ strlen (const char*); + +struct stringpool_t +{ + char s1[sizeof ("1")]; + char s2[sizeof ("12")]; + char s3[sizeof ("123")]; + char s4[sizeof ("1234")]; + char s5[sizeof ("12345")]; +}; + +static const struct stringpool_t stringpool_contents = + { + "1", "12", "123", "1234", "12345" + }; + +#define stringpool ((const char *) &stringpool_contents) + +volatile int i0 = 0, i2 = 2, i5 = 5, i9 = 9, i14 = 14; + +int main (void) +{ + /* These shouldn't trigger warnings. */ + assert (strlen (stringpool) == 1); + assert (strlen (stringpool + 2) == 2); + assert (strlen (stringpool + 5) == 3); + assert (strlen (stringpool + 9) == 4); + assert (strlen (stringpool + 14) == 5); + + assert (strlen (stringpool + i0) == 1); + assert (strlen (stringpool + i2) == 2); + assert (strlen (stringpool + i5) == 3); + assert (strlen (stringpool + i9) == 4); + assert (strlen (stringpool + i14) == 5); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-8.c b/SingleSource/Regression/C/gcc-dg/strlenopt-8.c new file mode 100644 index 0000000000..b47a23b231 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-8.c @@ -0,0 +1,50 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +/* Yes, there are people who write code like this. */ + +__attribute__((noinline, noclone)) char * +foo (int r) +{ + char buf[10] = ""; + strcat (buf, r ? "r" : "w"); + strcat (buf, "b"); + return strdup (buf); +} + +__attribute__((noinline, noclone)) char * +bar (int r) +{ + char buf[10] = {}; + strcat (buf, r ? "r" : "w"); + strcat (buf, "b"); + return strdup (buf); +} + +int +main () +{ + char *q = foo (1); + if (q != NULL) + { + if (strcmp (q, "rb")) + abort (); + free (q); + } + q = bar (0); + if (q != NULL) + { + if (strcmp (q, "wb")) + abort (); + free (q); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-80.c b/SingleSource/Regression/C/gcc-dg/strlenopt-80.c new file mode 100644 index 0000000000..a8adbf1eed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-80.c @@ -0,0 +1,109 @@ +/* PR tree-optimization/91996 - fold strlen relational expressions + + The optimization is only implemented for MEM_REF stores and other + targets than those below may not transform the memcpy call into + such a store. + { dg-do compile { target { { aarch64*-*-* i?86-*-* x86_64-*-* } || { { powerpc*-*-* } && lp64 } } } } + + { dg-options "-O2 -Wall -fdump-tree-optimized" } + { dg-additional-options "-msse" { target i?86-*-* x86_64-*-* } } */ + +#define CHAR_BIT __CHAR_BIT__ +#define SIZE_MAX __SIZE_MAX__ +#define LEN_MAX (__PTRDIFF_MAX__ - 2) + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; + +extern void* memcpy (void*, const void*, size_t); +extern size_t strlen (const char*); + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT (a, b) + +extern void sink (void*, ...); +extern void failure_on_line (int); + +extern char src[]; +extern char dst[]; + +/* Copy (1 << NCPYLOG) bytes from an unknown string SRC with strlen (SRC) + in the range [MINSRCLEN, MAXSRCLEN] into DST + DSTOFF and verify that + strlen (DST + DSTOFF) is in the range [MINDSTLEN, MAXDSTLEN]. */ +#define MIN_MAX(dst, dstoff, src, \ + minsrclen, maxsrclen, mindstlen, maxdstlen, ncpylog) \ + void CAT (test_on_line_, __LINE__) (void) \ + { \ + size_t srclen = strlen (src); \ + if ((minsrclen) <= srclen && srclen <= (maxsrclen)) { \ + char *d = (dst) + (dstoff); \ + memcpy (d, src, (size_t)1 << (ncpylog)); \ + size_t dstlen = strlen (d); \ + if (dstlen < (mindstlen) || (maxdstlen) < dstlen) \ + { \ + failure_on_line (__LINE__); \ + } \ + sink (dst, src); \ + } \ + } typedef void dummy_type + +// Verify the lower bound of the resulting strlen range. +#define MIN(dst, dstoff, src, minsrclen, mindstlen, ncpylog) \ + MIN_MAX (dst, dstoff, src, minsrclen, LEN_MAX, mindstlen, LEN_MAX, ncpylog) + +MIN (dst, 0, src, 2, 1, 0); +MIN (dst, 0, src, 3, 1, 0); +MIN (dst, 0, src, 3, 2, 1); +MIN (dst, 0, src, 3, 2, 2); +MIN (dst, 0, src, 3, 2, 3); + +MIN (dst, 1, src, 2, 1, 0); +MIN (dst, 1, src, 3, 1, 0); +MIN (dst, 1, src, 3, 2, 1); +MIN (dst, 1, src, 3, 2, 2); +MIN (dst, 1, src, 3, 2, 3); + +MIN (dst, 2, src, 2, 1, 0); +MIN (dst, 3, src, 3, 1, 0); +MIN (dst, 4, src, 3, 2, 1); +MIN (dst, 5, src, 3, 2, 2); +MIN (dst, 6, src, 3, 2, 3); + + +MIN (dst, 0, src, 5, 1, 0); +MIN (dst, 0, src, 5, 2, 1); +MIN (dst, 0, src, 5, 4, 2); +MIN (dst, 0, src, 5, 5, 3); + +#if __aarch64__ || __x86_64__ +/* Of the targets above only aarch64 and x86_64 transform memcpy calls + of (2 << 4) bytes into MEM_REF. */ +MIN (dst, 0, src, 5, 5, 4); +#endif + +MIN (dst, 11, src, 5, 1, 0); +MIN (dst, 22, src, 5, 2, 1); +MIN (dst, 33, src, 5, 4, 2); +MIN (dst, 44, src, 5, 5, 3); + +#if __aarch64__ || __x86_64__ +MIN (dst, 55, src, 5, 5, 4); +#endif + +MIN (dst, 11, src, LEN_MAX, 1, 0); +MIN (dst, 22, src, LEN_MAX, 2, 1); +MIN (dst, 33, src, LEN_MAX, 4, 2); +MIN (dst, 44, src, LEN_MAX, 5, 3); +MIN (dst, 55, src, LEN_MAX, 5, 4); +MIN (dst, 66, src, LEN_MAX, 9, 8); +MIN (dst, 66, src, LEN_MAX, LEN_MAX, sizeof (ptrdiff_t) * CHAR_BIT - 1); + + +MIN_MAX (dst, 0, src, 3, 5, 1, LEN_MAX, 0); +MIN_MAX (dst, 0, src, 3, 5, 2, LEN_MAX, 1); +MIN_MAX (dst, 0, src, 3, 5, 3, LEN_MAX, 2); + +/* Upper bound not implemented yet. + MIN_MAX (dst, 0, src, 3, 5, 3, 5, 3); */ + +/* { dg-final { scan-tree-dump-times "failure_on_line \\(" 0 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-81.c b/SingleSource/Regression/C/gcc-dg/strlenopt-81.c new file mode 100644 index 0000000000..f493514cfc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-81.c @@ -0,0 +1,195 @@ +/* PR tree-optimization/91996 - fold non-constant strlen relational expressions + { dg-do run } + { dg-options "-O2 -Wall -Wno-unused-local-typedefs" } */ + +typedef __SIZE_TYPE__ size_t; + +#define NOIPA __attribute__ ((noipa)) + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT (a, b) + +/* Used in tests where EXPR is expected to be folded to false. */ +#define ELIM(expr) \ + if (expr) { \ + extern void \ + CAT (CAT (test_on_line_, __LINE__), _not_eliminated)(void); \ + CAT (CAT (test_on_line_, __LINE__), _not_eliminated)(); \ + } typedef void dummy_type + + +/* Set the alignment for targets that depend on it in order to + optimize away the ELIM calls. See pr92128. */ +__attribute__ ((aligned(4))) char a[32], b[32]; + +void init (void) +{ + __builtin_strncpy (a, "abcdefgh", sizeof a); + __builtin_strncpy (b, "0123456789", sizeof b); +} + +NOIPA void fail (const char *func) +{ + __builtin_printf ("failure in %s\n", func); + __builtin_abort (); +} + +NOIPA void test_global_cpy_4 (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + + char *d = a; + __builtin_memcpy (d, b, 4); + + size_t dlen = __builtin_strlen (d); + if (dlen != 8) // cannot be eliminated + fail ("test_global"); +} + + +NOIPA void test_global_cpy_10 (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + + char *d = a; + __builtin_memcpy (d, b, 10); + + size_t dlen = __builtin_strlen (d); + if (dlen != 10) // cannot be eliminated + fail ("test_global_cpy_10"); +} + +NOIPA void test_global_cpy_11 (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + + char *d = a; + __builtin_memcpy (d, b, 11); + + size_t dlen = __builtin_strlen (d); + if (dlen != 10) // cannot be eliminated + fail ("test_global_cpy_11"); +} + +NOIPA void test_global_cpy_20 (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + + char *d = a; + __builtin_memcpy (d, b, 20); + + size_t dlen = __builtin_strlen (d); + if (dlen != 10) // cannot be eliminated + fail ("test_global_cpy_20"); +} + +NOIPA void test_local_cpy_4 (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + +/* Set the alignment for targets that depend on it in order to + optimize away the ELIM calls. See pr92128. */ + __attribute__ ((aligned(4))) char a[10] = "abcdefgh"; + char *d = a; + __builtin_memcpy (d, b, 4); + + size_t dlen = __builtin_strlen (d); + ELIM (dlen != 8); +} + +NOIPA void test_local_cpy_10 (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + + char a[32] = "abcdefgh"; + char *d = a; + __builtin_memcpy (d, b, 10); + + /* B can be longer than 9 and A can initially be longer than 10 + so the test below cannot be eliminated. */ + size_t dlen = __builtin_strlen (d); + if (dlen != 10) + fail ("test_local_cpy_10"); +} + +NOIPA void test_local_cpy_11 (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + + char a[32] = "abcdefgh"; + char *d = a; + __builtin_memcpy (d, b, 11); + + size_t dlen = __builtin_strlen (d); + if (dlen != 10) + fail ("test_global_cpy_20"); +} + +NOIPA void test_local_cpy_20 (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + + char a[32] = "abcdefgh"; + char *d = a; + __builtin_memcpy (d, b, 20); + + size_t dlen = __builtin_strlen (d); + if (dlen != 10) + fail ("test_global_cpy_20"); +} + +NOIPA void test_global_length_eq (void) +{ + size_t blen = __builtin_strlen (b); + if (blen != 10) return; + + size_t alen = __builtin_strlen (a); + if (alen != 8) return; + + char *d = a; + __builtin_memcpy (d, b, 4); + + size_t dlen = __builtin_strlen (d); + ELIM (dlen != 8); +} + + +NOIPA void test_global_length_gt (void) +{ + size_t blen = __builtin_strlen (b); + if (blen < 9) return; + + size_t alen = __builtin_strlen (a); + if (alen < 8) return; + + char *d = a; + __builtin_memcpy (d, b, 4); + + size_t dlen = __builtin_strlen (d); + ELIM (dlen < 8); +} + +#define TEST(name) do { init (); test_ ## name (); } while (0) + +int main (void) +{ + TEST (local_cpy_4); + TEST (local_cpy_10); + TEST (local_cpy_11); + TEST (local_cpy_20); + + TEST (global_cpy_4); + TEST (global_cpy_10); + TEST (global_cpy_11); + TEST (global_cpy_20); + TEST (global_length_eq); + TEST (global_length_gt); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-82.c b/SingleSource/Regression/C/gcc-dg/strlenopt-82.c new file mode 100644 index 0000000000..8070f6ccf3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-82.c @@ -0,0 +1,224 @@ +/* PR tree-optimization/83821 - local aggregate initialization defeats + strlen optimization + + Avoid exercising targets other than x86_64 in LP64 mode due to PR 83543 + - strlen of a local array member not optimized on some targets + { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } + + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define CAT(x, y) x ## y +#define CONCAT(x, y) CAT (x, y) +#define FAILNAME(name) CONCAT (call_ ## name ##_on_line_, __LINE__) + +#define FAIL(name) do { \ + extern void FAILNAME (name) (void); \ + FAILNAME (name)(); \ + } while (0) + +/* Macro to emit a call to function named + call_in_true_branch_not_eliminated_on_line_NNN() + for each call that's expected to be eliminated. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that no such call appears in output. */ +#define ELIM(expr) \ + if (!(expr)) FAIL (in_true_branch_not_eliminated); else (void)0 + +/* Macro to emit a call to a function named + call_made_in_{true,false}_branch_on_line_NNN() + for each call that's expected to be retained. The dg-final + scan-tree-dump-time directive at the bottom of the test verifies + that the expected number of both kinds of calls appears in output + (a pair for each line with the invocation of the KEEP() macro. */ +#define KEEP(expr) \ + if (expr) \ + FAIL (made_in_true_branch); \ + else \ + FAIL (made_in_false_branch) + +#define STR10 "0123456789" +#define STR20 STR10 STR10 +#define STR30 STR20 STR10 +#define STR40 STR20 STR20 + +void elim_char_array_init_consecutive (void) +{ + char a[][10] = { "1", "12", "123", "1234", "12345", "12345" }; + + ELIM (strlen (a[0]) == 1); + ELIM (strlen (a[1]) == 2); + ELIM (strlen (a[2]) == 3); + ELIM (strlen (a[3]) == 4); + ELIM (strlen (a[4]) == 5); +} + +void elim_char_array_cpy_consecutive (void) +{ + char a[5][10]; + + strcpy (a[0], "12345"); + strcpy (a[1], "1234"); + strcpy (a[2], "123"); + strcpy (a[3], "12"); + strcpy (a[4], "1"); + + ELIM (strlen (a[0]) == 5); + ELIM (strlen (a[1]) == 4); + ELIM (strlen (a[2]) == 3); + ELIM (strlen (a[3]) == 2); + ELIM (strlen (a[4]) == 1); +} + +void elim_clear_char_array_cpy_consecutive (void) +{ + char a[5][10] = { }; + + strcpy (a[0], "12345"); + strcpy (a[1], "1234"); + strcpy (a[2], "123"); + strcpy (a[3], "12"); + strcpy (a[4], "1"); + + ELIM (strlen (a[0]) == 5); + ELIM (strlen (a[1]) == 4); + ELIM (strlen (a[2]) == 3); + ELIM (strlen (a[3]) == 2); + ELIM (strlen (a[4]) == 1); +} + +struct Consec +{ + char s1[sizeof STR40]; + char s2[sizeof STR40]; + const char *p1; + const char *p2; +}; + +void elim_struct_init_consecutive (void) +{ + struct Consec a = { STR10, STR10, STR10, STR10 }; + + ELIM (strlen (a.s1) == sizeof STR10 - 1); + ELIM (strlen (a.s2) == sizeof STR10 - 1); + ELIM (strlen (a.p1) == sizeof STR10 - 1); + ELIM (strlen (a.p2) == sizeof STR10 - 1); +} + +void elim_struct_array_init_consecutive (void) +{ + struct Consec a[2] = { + { STR10, STR20, STR30, STR40 }, + { STR40, STR30, STR20, STR10 } + }; + + ELIM (strlen (a[0].s1) == sizeof STR10 - 1); + ELIM (strlen (a[0].s2) == sizeof STR20 - 1); + ELIM (strlen (a[0].p1) == sizeof STR30 - 1); + ELIM (strlen (a[0].p2) == sizeof STR40 - 1); + + ELIM (strlen (a[1].s1) == sizeof STR40 - 1); + ELIM (strlen (a[1].s2) == sizeof STR30 - 1); + ELIM (strlen (a[1].p1) == sizeof STR20 - 1); + ELIM (strlen (a[1].p2) == sizeof STR10 - 1); +} + +struct NonConsec +{ + char s1[sizeof STR40]; + int i1; + char s2[sizeof STR40]; + int i2; + const char *p1; + int i3; + const char *p2; + int i4; +}; + +void elim_struct_init_nonconsecutive (void) +{ + struct NonConsec b = { STR10, 123, STR20, 456, b.s1, 789, b.s2, 123 }; + + ELIM (strlen (b.s1) == sizeof STR10 - 1); + ELIM (strlen (b.s2) == sizeof STR20 - 1); + ELIM (strlen (b.p1) == sizeof STR10 - 1); + ELIM (strlen (b.p2) == sizeof STR20 - 1); +} + +void elim_struct_assign_tmp_nonconsecutive (void) +{ + struct NonConsec b = { "a", 1, "b", 2, "c", 3, "d", 4 }; + + b = (struct NonConsec){ STR10, 123, STR20, 456, STR30, 789, STR40, 123 }; + + ELIM (strlen (b.s1) == sizeof STR10 - 1); + ELIM (strlen (b.s2) == sizeof STR20 - 1); + ELIM (strlen (b.p1) == sizeof STR30 - 1); + ELIM (strlen (b.p2) == sizeof STR40 - 1); +} + +const struct NonConsec bcst = { + STR40, -1, STR30, -2, STR20, -3, STR10, -4 +}; + +void elim_struct_assign_cst_nonconsecutive (void) +{ + struct NonConsec b = { "a", 1, "b", 2, "c", 3, "d" }; + + b = bcst; + + ELIM (strlen (b.s1) == sizeof STR40 - 1); + ELIM (strlen (b.s2) == sizeof STR30 - 1); + ELIM (strlen (b.p1) == sizeof STR20 - 1); + ELIM (strlen (b.p2) == sizeof STR10 - 1); +} + +void elim_struct_copy_cst_nonconsecutive (void) +{ + struct NonConsec b = { "a", 1, "b", 2, "c", 3, "d" }; + memcpy (&b, &bcst, sizeof b); + + /* ELIM (strlen (b.s1) == sizeof STR40 - 1); + ELIM (strlen (b.s2) == sizeof STR30 - 1); */ + ELIM (strlen (b.p1) == sizeof STR20 - 1); + ELIM (strlen (b.p2) == sizeof STR10 - 1); +} + + +#line 1000 + +int sink (void*); + +void keep_init_nonconsecutive (void) +{ + struct NonConsec b = { + STR10, 123, STR20, 456, b.s1, 789, b.s2, + sink (&b) + }; + + KEEP (strlen (b.s1) == sizeof STR10 - 1); + KEEP (strlen (b.s2) == sizeof STR10 - 1); + KEEP (strlen (b.p1) == sizeof STR10 - 1); + KEEP (strlen (b.p2) == sizeof STR10 - 1); +} + +void keep_assign_tmp_nonconsecutive (void) +{ + struct NonConsec b = { "a", 1, "b", 2, "c", 3, "d", 4 }; + + b = (struct NonConsec){ + STR10, 123, STR20, 456, STR30, 789, STR40, + sink (&b) + }; + + KEEP (strlen (b.s1) == sizeof STR10 - 1); + KEEP (strlen (b.s2) == sizeof STR20 - 1); + KEEP (strlen (b.p1) == sizeof STR30 - 1); + KEEP (strlen (b.p2) == sizeof STR40 - 1); +} + +/* { dg-final { scan-tree-dump-times "call_in_true_branch_not_eliminated_" 0 "optimized" } } + + { dg-final { scan-tree-dump-times "call_made_in_true_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 8 "optimized" } } + { dg-final { scan-tree-dump-times "call_made_in_false_branch_on_line_1\[0-9\]\[0-9\]\[0-9\]" 8 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-83.c b/SingleSource/Regression/C/gcc-dg/strlenopt-83.c new file mode 100644 index 0000000000..baa80cf964 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-83.c @@ -0,0 +1,84 @@ +/* PR tree-optimization/83821 - local aggregate initialization defeats + strlen optimization + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } + { dg-require-effective-target alloca } */ + +#include "strlenopt.h" +char *p_p2, *p_p5, *p_p9, *p_p14; + +unsigned n0, n1, n2, n3, n4; + + +static inline __attribute__ ((always_inline)) void +elim_strlen_of_consecutive_strcpy (char *p) +{ + p_p2 = p + 2; + __builtin_strcpy (p_p2, "12"); + + p_p5 = p_p2 + 3; + __builtin_strcpy (p_p5, "124"); + + p_p9 = p_p5 + 4; + __builtin_strcpy (p_p9, "1245"); + + p_p14 = p_p9 + 5; + + n0 = __builtin_strlen (p); + n1 = __builtin_strlen (p_p2); + n2 = __builtin_strlen (p_p5); + n3 = __builtin_strlen (p_p9); + + /* The following isn't handled yet: + n4 = __builtin_strlen (p_p14); */ + + if (n0 || n1 != 2 || n2 != 3 || n3 != 4) + __builtin_abort (); +} + + +void elim_strlen_of_consecutive_strcpy_in_alloca (unsigned n) +{ + /* Only known sizes are handled so far. */ + n = 14; + + char *p = __builtin_alloca (n); + + *p = '\0'; + + elim_strlen_of_consecutive_strcpy (p); +} + + +void elim_strlen_of_consecutive_strcpy_in_vla (unsigned n) +{ + /* Only known sizes are handled so far. */ + n = 14; + + char vla[n]; + + *vla = '\0'; + + elim_strlen_of_consecutive_strcpy (vla); +} + +void elim_strlen_of_consecutive_strcpy_in_malloc (unsigned n) +{ + char *p = __builtin_malloc (n); + + *p = '\0'; + + elim_strlen_of_consecutive_strcpy (p); +} + + +void elim_strlen_of_consecutive_strcpy_in_calloc (unsigned n) +{ + char *p = __builtin_calloc (n, 1); + + /* Do not store into *P to verify that strlen knows it's zero. */ + + elim_strlen_of_consecutive_strcpy (p); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-84.c b/SingleSource/Regression/C/gcc-dg/strlenopt-84.c new file mode 100644 index 0000000000..0c9da3c1b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-84.c @@ -0,0 +1,136 @@ +/* PR tree-optimization/83821 - local aggregate initialization defeats + strlen optimization + Verify that stores that overwrite an interior nul are correctly + reflected in strlen results. + { dg-do run } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +#define false (0 == 1) +#define true (0 == 0) +#define assert(e) \ + ((e) ? (void)0 : (__builtin_printf ("assertion failed on line %i\n", \ + __LINE__), __builtin_abort ())) + +#define ATTR(...) __attribute__ ((__VA_ARGS__)) + +static inline int ATTR (always_inline) +assign_and_get_length (char *p, _Bool clear) +{ + p[0] = 'a'; + + if (clear) + p[1] = 0; + + p[2] = 'c'; + + if (clear) + p[3] = 0; + + p[1] = 'b'; + + return __builtin_strlen (p); +} + +ATTR (noipa) void array_get_length (void) +{ + char a[4]; + unsigned n = assign_and_get_length (a, true); + assert (n == 3); +} + +ATTR (noipa) void clear_array_get_length (void) +{ + char a[4] = { }; + unsigned n = assign_and_get_length (a, false); + assert (n == 3); +} + +ATTR (noipa) void calloc_get_length (void) +{ + char *p = __builtin_calloc (5, 1); + unsigned n = assign_and_get_length (p, false); + assert (n == 3); +} + +ATTR (noipa) void malloc_get_length (void) +{ + char *p = __builtin_malloc (5); + unsigned n = assign_and_get_length (p, true); + assert (n == 3); +} + +ATTR (noipa) void vla_get_length (int n) +{ + char a[n]; + unsigned len = assign_and_get_length (a, true); + assert (len == 3); +} + + +static inline void ATTR (always_inline) +assign_and_test_length (char *p, _Bool clear) +{ + p[0] = 'a'; + + if (clear) + p[1] = 0; + + p[2] = 'c'; + + if (clear) + p[3] = 0; + + unsigned n0 = __builtin_strlen (p); + + p[1] = 'b'; + + unsigned n1 = __builtin_strlen (p); + assert (n0 != n1); +} + +ATTR (noipa) void array_test_length (void) +{ + char a[4]; + assign_and_test_length (a, true); +} + +ATTR (noipa) void clear_array_test_length (void) +{ + char a[4] = { }; + assign_and_test_length (a, false); +} + +ATTR (noipa) void calloc_test_length (void) +{ + char *p = __builtin_calloc (5, 1); + assign_and_test_length (p, false); +} + +ATTR (noipa) void malloc_test_length (void) +{ + char *p = __builtin_malloc (5); + assign_and_test_length (p, true); +} + +ATTR (noipa) void vla_test_length (int n) +{ + char a[n]; + assign_and_test_length (a, true); +} + +int main (void) +{ + array_get_length (); + clear_array_get_length (); + calloc_get_length (); + malloc_get_length (); + vla_get_length (4); + + array_test_length (); + clear_array_test_length (); + calloc_test_length (); + malloc_test_length (); + vla_test_length (4); +} + diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-85.c b/SingleSource/Regression/C/gcc-dg/strlenopt-85.c new file mode 100644 index 0000000000..2ba1ee0570 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-85.c @@ -0,0 +1,44 @@ +/* PR tree-optimization/83821 - local aggregate initialization defeats + strlen optimization + Verify that a strlen() call is eliminated for a pointer to a region + of memory allocated by calloc() even if one or more nul bytes are + written into it. + { dg-do compile } + { dg-options "-O2 -fno-tree-vectorize -fdump-tree-optimized" } */ + +unsigned n0, n1; + +void* elim_strlen_calloc_store_memset_1 (unsigned a, unsigned b) +{ + char *p = __builtin_calloc (a, 1); + + p[0] = '\0'; + p[1] = '\0'; + p[2] = '\0'; + p[3] = '\0'; + + __builtin_memset (p, 0, b); + + n0 = __builtin_strlen (p); + + return p; +} + +void* elim_strlen_calloc_store_memset_2 (unsigned a, unsigned b, unsigned c) +{ + char *p = __builtin_calloc (a, 1); + + p[1] = '\0'; + __builtin_memset (p, 0, b); + + n0 = __builtin_strlen (p); + + p[3] = 0; + __builtin_memset (p, 0, c); + + n1 = __builtin_strlen (p); + + return p; +} + +/* { dg-final { scan-tree-dump-not "__builtin_strlen" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-86.c b/SingleSource/Regression/C/gcc-dg/strlenopt-86.c new file mode 100644 index 0000000000..d202944355 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-86.c @@ -0,0 +1,57 @@ +/* PR tree-optimization/83821 - local aggregate initialization defeats + strlen optimization + Verify that a strlen() call is not eliminated for a pointer to a region + of memory allocated by calloc() if a byte is written into the region + that isn't known to be nul. + { dg-do compile } + { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned n0, n1; + +void* +keep_strlen_calloc_store_cst_memset (int i, unsigned a, unsigned b) +{ + char *p = __builtin_calloc (a, 1); + + p[i] = 'x'; + + __builtin_memset (p, 0, b); + + n0 = __builtin_strlen (p); + + return p; +} + +void* +keep_strlen_calloc_store_var_memset (int i, int x, unsigned a, unsigned b) +{ + char *p = __builtin_calloc (a, 1); + + p[i] = x; + + __builtin_memset (p, 0, b); + + n0 = __builtin_strlen (p); + + return p; +} + +void* +keep_strlen_calloc_store_memset_2 (int i, int x, unsigned a, unsigned b, unsigned c) +{ + char *p = __builtin_calloc (a, 1); + + p[i] = x; + __builtin_memset (p, 0, b); + + n0 = __builtin_strlen (p); + + p[3] = x; + __builtin_memset (p, 0, c); + + n1 = __builtin_strlen (p); + + return p; +} + +/* { dg-final { scan-tree-dump-times "__builtin_strlen" 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-87.c b/SingleSource/Regression/C/gcc-dg/strlenopt-87.c new file mode 100644 index 0000000000..082c7b2f73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-87.c @@ -0,0 +1,105 @@ +/* PR tree-optimization/92157 - incorrect strcmp() == 0 result for unknown + strings​ + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + + +char a2[2], a3[3]; + + +static inline __attribute__ ((always_inline)) int +verify_not_equal (const char *s, const char *t, int x) +{ + int n = x < 0 ? strlen (s) : 0 < x ? strlen (t) : strlen (s) + strlen (t); + + if (strcmp (t, s) == 0) + abort (); + + return n; +} + +__attribute__ ((noipa)) int test_a2_s (const char *s) +{ + return verify_not_equal (a2, s, 0); +} + +__attribute__ ((noipa)) int test_a2_a3 (void) +{ + return verify_not_equal (a2, a3, 0); +} + +__attribute__ ((noipa)) int test_a3_a2 (void) +{ + return verify_not_equal (a3, a2, 0); +} + +__attribute__ ((noipa)) int test_s_a2 (const char *s) +{ + return verify_not_equal (s, a2, 0); +} + + +__attribute__ ((noipa)) int test_a2_s_1 (const char *s) +{ + return verify_not_equal (a2, s, -1); +} + +__attribute__ ((noipa)) int test_a2_a3_1 (void) +{ + return verify_not_equal (a2, a3, -1); +} + +__attribute__ ((noipa)) int test_a3_a2_1 (void) +{ + return verify_not_equal (a3, a2, -1); +} + +__attribute__ ((noipa)) int test_s_a2_1 (const char *s) +{ + return verify_not_equal (s, a2, -1); +} + + +__attribute__ ((noipa)) int test_a2_s_2 (const char *s) +{ + return verify_not_equal (a2, s, +1); +} + +__attribute__ ((noipa)) int test_a2_a3_2 (void) +{ + return verify_not_equal (a2, a3, +1); +} + +__attribute__ ((noipa)) int test_a3_a2_2 (void) +{ + return verify_not_equal (a3, a2, +1); +} + +__attribute__ ((noipa)) int test_s_a2_2 (const char *s) +{ + return verify_not_equal (s, a2, +1); +} + +int main (void) +{ + a2[0] = '1'; + a3[0] = '1'; + a3[0] = '2'; + + test_a2_s (""); + test_a2_a3 (); + test_a3_a2 (); + test_s_a2 (""); + + test_a2_s_1 (""); + test_a2_a3_1 (); + test_a3_a2_1 (); + test_s_a2_1 (""); + + test_a2_s_2 (""); + test_a2_a3_2 (); + test_a3_a2_2 (); + test_s_a2_2 (""); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-88.c b/SingleSource/Regression/C/gcc-dg/strlenopt-88.c new file mode 100644 index 0000000000..cadd0defa7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-88.c @@ -0,0 +1,196 @@ +/* PR tree-optimization/92226 - live nul char store to array eliminated + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +#define NOIPA __attribute__ ((noipa)) + +unsigned nfails; + +char a[8]; + +void test (int line, const char *func, size_t expect) +{ + size_t len = strlen (a); + if (len == expect) + return; + + ++nfails; + + __builtin_printf ("assertion failed in %s on line %i: " + "strlen (\"%s\") == %zu, got %zu\n", + func, line, a, expect, len); +} + +NOIPA const char* str (size_t n) +{ + return "9876543210" + 10 - n; +} + +#define T(name, CMPEXP, LEN, IDX, EXPECT) \ + NOIPA static void name (void) \ + { \ + const char *s = str (LEN); \ + if (strlen (s) CMPEXP) \ + { \ + strcpy (a, s); \ + a[IDX] = 0; \ + test (__LINE__, #name, EXPECT); \ + } \ + } typedef void dummy_type + + +T (len_eq_1_store_nul_0, == 1, 1, 0, 0); +T (len_eq_1_store_nul_1, == 1, 1, 1, 1); +T (len_eq_1_store_nul_2, == 1, 1, 2, 1); +T (len_eq_1_store_nul_3, == 1, 1, 3, 1); +T (len_eq_1_store_nul_4, == 1, 1, 4, 1); + +T (len_eq_2_store_nul_0, == 2, 2, 0, 0); +T (len_eq_2_store_nul_1, == 2, 2, 1, 1); +T (len_eq_2_store_nul_2, == 2, 2, 2, 2); +T (len_eq_2_store_nul_3, == 2, 2, 3, 2); +T (len_eq_2_store_nul_4, == 2, 2, 4, 2); + +T (len_eq_3_store_nul_0, == 3, 3, 0, 0); +T (len_eq_3_store_nul_1, == 3, 3, 1, 1); +T (len_eq_3_store_nul_2, == 3, 3, 2, 2); +T (len_eq_3_store_nul_3, == 3, 3, 3, 3); +T (len_eq_3_store_nul_4, == 3, 3, 4, 3); + + +T (len_gt_1_store_nul_0, > 2, 2, 0, 0); +T (len_gt_1_store_nul_1, > 2, 2, 1, 1); +T (len_gt_1_store_nul_2, > 2, 2, 2, 2); +T (len_gt_1_store_nul_3, > 2, 2, 3, 2); +T (len_gt_1_store_nul_4, > 2, 2, 4, 2); + +T (len_gt_2_store_nul_0, > 2, 3, 0, 0); +T (len_gt_2_store_nul_1, > 2, 3, 1, 1); +T (len_gt_2_store_nul_2, > 2, 3, 2, 2); +T (len_gt_2_store_nul_3, > 2, 3, 3, 3); +T (len_gt_2_store_nul_4, > 2, 3, 4, 3); + +T (len_gt_3_store_nul_0, > 2, 4, 0, 0); +T (len_gt_3_store_nul_1, > 2, 4, 1, 1); +T (len_gt_3_store_nul_2, > 2, 4, 2, 2); +T (len_gt_3_store_nul_3, > 2, 4, 3, 3); +T (len_gt_3_store_nul_4, > 2, 4, 4, 4); + + +T (len_1_lt_4_store_nul_0, < 4, 1, 0, 0); +T (len_1_lt_4_store_nul_1, < 4, 1, 1, 1); +T (len_1_lt_4_store_nul_2, < 4, 1, 2, 1); +T (len_1_lt_4_store_nul_3, < 4, 1, 3, 1); +T (len_1_lt_4_store_nul_4, < 4, 1, 4, 1); +T (len_1_lt_4_store_nul_5, < 4, 1, 5, 1); +T (len_1_lt_4_store_nul_6, < 4, 1, 6, 1); +T (len_1_lt_4_store_nul_7, < 4, 1, 7, 1); + +T (len_2_lt_4_store_nul_0, < 4, 2, 0, 0); +T (len_2_lt_4_store_nul_1, < 4, 2, 1, 1); +T (len_2_lt_4_store_nul_2, < 4, 2, 2, 2); +T (len_2_lt_4_store_nul_3, < 4, 2, 3, 2); +T (len_2_lt_4_store_nul_4, < 4, 2, 4, 2); +T (len_2_lt_4_store_nul_5, < 4, 2, 5, 2); +T (len_2_lt_4_store_nul_6, < 4, 2, 6, 2); +T (len_2_lt_4_store_nul_7, < 4, 2, 7, 2); + +T (len_3_lt_4_store_nul_0, < 4, 3, 0, 0); +T (len_3_lt_4_store_nul_1, < 4, 3, 1, 1); +T (len_3_lt_4_store_nul_2, < 4, 3, 2, 2); +T (len_3_lt_4_store_nul_3, < 4, 3, 3, 3); +T (len_3_lt_4_store_nul_4, < 4, 3, 4, 3); +T (len_3_lt_4_store_nul_5, < 4, 3, 5, 3); +T (len_3_lt_4_store_nul_6, < 4, 3, 6, 3); +T (len_3_lt_4_store_nul_7, < 4, 3, 7, 3); + +T (len_7_lt_8_store_nul_0, < 8, 7, 0, 0); +T (len_7_lt_8_store_nul_1, < 8, 7, 1, 1); +T (len_7_lt_8_store_nul_2, < 8, 7, 2, 2); +T (len_7_lt_8_store_nul_3, < 8, 7, 3, 3); +T (len_7_lt_8_store_nul_4, < 8, 7, 4, 4); +T (len_7_lt_8_store_nul_5, < 8, 7, 5, 5); +T (len_7_lt_8_store_nul_6, < 8, 7, 6, 6); +T (len_7_lt_8_store_nul_7, < 8, 7, 7, 7); + + +int main (void) +{ + len_eq_1_store_nul_0 (); + len_eq_1_store_nul_1 (); + len_eq_1_store_nul_2 (); + len_eq_1_store_nul_3 (); + len_eq_1_store_nul_4 (); + + len_eq_2_store_nul_0 (); + len_eq_2_store_nul_1 (); + len_eq_2_store_nul_2 (); + len_eq_2_store_nul_3 (); + len_eq_2_store_nul_4 (); + + len_eq_3_store_nul_0 (); + len_eq_3_store_nul_1 (); + len_eq_3_store_nul_2 (); + len_eq_3_store_nul_3 (); + len_eq_3_store_nul_4 (); + + + len_gt_1_store_nul_0 (); + len_gt_1_store_nul_1 (); + len_gt_1_store_nul_2 (); + len_gt_1_store_nul_3 (); + len_gt_1_store_nul_4 (); + + len_gt_2_store_nul_0 (); + len_gt_2_store_nul_1 (); + len_gt_2_store_nul_2 (); + len_gt_2_store_nul_3 (); + len_gt_2_store_nul_4 (); + + len_gt_3_store_nul_0 (); + len_gt_3_store_nul_1 (); + len_gt_3_store_nul_2 (); + len_gt_3_store_nul_3 (); + len_gt_3_store_nul_4 (); + + len_1_lt_4_store_nul_0 (); + len_1_lt_4_store_nul_1 (); + len_1_lt_4_store_nul_2 (); + len_1_lt_4_store_nul_3 (); + len_1_lt_4_store_nul_4 (); + len_1_lt_4_store_nul_5 (); + len_1_lt_4_store_nul_6 (); + len_1_lt_4_store_nul_7 (); + + len_2_lt_4_store_nul_0 (); + len_2_lt_4_store_nul_1 (); + len_2_lt_4_store_nul_2 (); + len_2_lt_4_store_nul_3 (); + len_2_lt_4_store_nul_4 (); + len_2_lt_4_store_nul_5 (); + len_2_lt_4_store_nul_6 (); + len_2_lt_4_store_nul_7 (); + + len_3_lt_4_store_nul_0 (); + len_3_lt_4_store_nul_1 (); + len_3_lt_4_store_nul_2 (); + len_3_lt_4_store_nul_3 (); + len_3_lt_4_store_nul_4 (); + len_3_lt_4_store_nul_5 (); + len_3_lt_4_store_nul_6 (); + len_3_lt_4_store_nul_7 (); + + len_7_lt_8_store_nul_0 (); + len_7_lt_8_store_nul_1 (); + len_7_lt_8_store_nul_2 (); + len_7_lt_8_store_nul_3 (); + len_7_lt_8_store_nul_4 (); + len_7_lt_8_store_nul_5 (); + len_7_lt_8_store_nul_6 (); + len_7_lt_8_store_nul_7 (); + + if (nfails) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-89.c b/SingleSource/Regression/C/gcc-dg/strlenopt-89.c new file mode 100644 index 0000000000..ead451ffb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-89.c @@ -0,0 +1,89 @@ +/* PR tree-optimization/92226 - live nul char store to array eliminated + { dg-do compile } + { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +#define NOIPA __attribute__ ((noipa)) + +/* Verify that the nul store into the destination is only eliminated + when overwrites the existing terminating nul added by the strcpy call. + Also verify that the second strlen call is eliminated in all cases. */ +#define T(SIZE, IDX) \ + NOIPA void test_ ## SIZE ## _store_nul_ ## IDX (const char *s) \ + { \ + extern char a ## SIZE[SIZE]; \ + char *d = a ## SIZE; \ + size_t len = SIZE - 1; \ + size_t idx = IDX; \ + if (strlen (s) == len) \ + { \ + strcpy (d, s); \ + d[idx] = 0; \ + if (strlen (d) != idx) \ + abort (); \ + } \ + } typedef void dummy_type + + +T (1, 0); // expect nul store to be eliminated + +T (2, 0); // nul store must be retained +T (2, 1); // expect nul store to be eliminated + +// Same as above but for larger arrays. +T (3, 0); +T (3, 1); +T (3, 2); + +T (4, 0); +T (4, 1); +T (4, 2); +T (4, 3); + +T (5, 0); +T (5, 1); +T (5, 2); +T (5, 3); +T (5, 4); + +T (6, 0); +T (6, 1); +T (6, 2); +T (6, 3); +T (6, 4); +T (6, 5); + +T (7, 0); +T (7, 1); +T (7, 2); +T (7, 3); +T (7, 4); +T (7, 5); +T (7, 6); + +T (8, 0); +T (8, 1); +T (8, 2); +T (8, 3); +T (8, 4); +T (8, 5); +T (8, 6); +T (8, 7); + +/* Verify that each function makes just one call to strlen to compute + the length of its argument (and not also to compute the length of + the copy): + { dg-final { scan-tree-dump-times "strlen \\(s_" 36 "strlen1" } } + { dg-final { scan-tree-dump-not "strlen \\(\\&a" "strlen1" } } + + Verify that nul stores into the last array element have been eliminated + (they are preceded by a strcpy storing into all the elements of the array: + { dg-final { scan-tree-dump-not "a1\\\] = 0;" "strlen1" } } + { dg-final { scan-tree-dump-not "a2 \\\+ 1B\\\] = 0;" "strlen1" } } + { dg-final { scan-tree-dump-not "a3 \\\+ 2B\\\] = 0;" "strlen1" } } + { dg-final { scan-tree-dump-not "a4 \\\+ 3B\\\] = 0;" "strlen1" } } + { dg-final { scan-tree-dump-not "a5 \\\+ 4B\\\] = 0;" "strlen1" } } + { dg-final { scan-tree-dump-not "a6 \\\+ 5B\\\] = 0;" "strlen1" } } + { dg-final { scan-tree-dump-not "a7 \\\+ 6B\\\] = 0;" "strlen1" } } + { dg-final { scan-tree-dump-not "a8 \\\+ 7B\\\] = 0;" "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-9.c b/SingleSource/Regression/C/gcc-dg/strlenopt-9.c new file mode 100644 index 0000000000..df6b594946 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-9.c @@ -0,0 +1,107 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-code-hoisting -fdump-tree-strlen -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +__attribute__((noinline, noclone)) char * +fn1 (int r) +{ + char *p = r ? "a" : "bc"; + /* String length for p varies, therefore strchr below isn't + optimized away. */ + return strchr (p, '\0'); +} + +__attribute__((noinline, noclone)) size_t +fn2 (int r) +{ + char *p, q[10]; + strcpy (q, "abc"); + p = r ? "a" : q; + /* String length is constant for both alternatives, and strlen is + optimized away. */ + return strlen (p); +} + +__attribute__((noinline, noclone)) size_t +fn3 (char *p, int n) +{ + int i; + p = strchr (p, '\0'); + /* strcat here can be optimized into memcpy. */ + strcat (p, "abcd"); + for (i = 0; i < n; i++) + if ((i % 123) == 53) + /* strcat here is optimized into strlen and memcpy. */ + strcat (p, "efg"); + /* The strlen here can't be optimized away, as in the loop string + length of p might change. */ + return strlen (p); +} + +char buf[64]; + +__attribute__((noinline, noclone)) size_t +fn4 (char *x, int n) +{ + int i; + size_t l; + char a[64]; + char *p = strchr (x, '\0'); + /* strcpy here is optimized into memcpy, length computed as p - x + 1. */ + strcpy (a, x); + /* strcat here is optimized into memcpy. */ + strcat (p, "abcd"); + for (i = 0; i < n; i++) + if ((i % 123) == 53) + /* strcat here is optimized into strlen and memcpy. */ + strcat (a, "efg"); + /* The strlen should be optimized here into 4. */ + l = strlen (p); + /* This stays strcpy. */ + strcpy (buf, a); + return l; +} + +int +main () +{ + volatile int l = 1; + char b[64]; + + if (memcmp (fn1 (l) - 1, "a", 2) != 0) + abort (); + if (memcmp (fn1 (!l) - 2, "bc", 3) != 0) + abort (); + if (fn2 (l) != 1 || fn2 (!l) != 3) + abort (); + memset (b, '\0', sizeof b); + memset (b, 'a', 3); + if (fn3 (b, 10) != 4 || memcmp (b, "aaaabcd", 8) != 0) + abort (); + if (fn3 (b, 128) != 7 || memcmp (b, "aaaabcdabcdefg", 15) != 0) + abort (); + if (fn3 (b, 256) != 10 || memcmp (b, "aaaabcdabcdefgabcdefgefg", 25) != 0) + abort (); + if (fn4 (b, 10) != 4 + || memcmp (b, "aaaabcdabcdefgabcdefgefgabcd", 29) != 0 + || memcmp (buf, "aaaabcdabcdefgabcdefgefg", 25) != 0) + abort (); + if (fn4 (b, 128) != 4 + || memcmp (b, "aaaabcdabcdefgabcdefgefgabcdabcd", 33) != 0 + || memcmp (buf, "aaaabcdabcdefgabcdefgefgabcdefg", 32) != 0) + abort (); + if (fn4 (b, 256) != 4 + || memcmp (b, "aaaabcdabcdefgabcdefgefgabcdabcdabcd", 37) != 0 + || memcmp (buf, "aaaabcdabcdefgabcdefgefgabcdabcdefgefg", 39) != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "strlen \\(" 5 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */ +/* { dg-final { scan-tree-dump-times "return 4;" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-90.c b/SingleSource/Regression/C/gcc-dg/strlenopt-90.c new file mode 100644 index 0000000000..2d4dad1867 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-90.c @@ -0,0 +1,83 @@ +/* PR tree-optimization/92226 - live nul char store to array eliminated + { dg-do compile } + { dg-options "-O2 -fdump-tree-strlen" } */ + +#include "strlenopt.h" + +#define NOIPA __attribute__ ((noipa)) + +#define T(MIN, MAX, SIZE, IDX) \ + NOIPA void \ + test_ ## MIN ## _ ## MAX ## _ ## SIZE ## _ ## IDX (const char *s) \ + { \ + extern char a ## SIZE[SIZE]; \ + char *d = a ## SIZE; \ + size_t len = strlen (s); \ + size_t idx = IDX; \ + if (MIN <= len && len <= MAX) \ + { \ + strcpy (d, s); \ + d[idx] = 0; \ + if (strlen (d) != idx) \ + abort (); \ + } \ + } typedef void dummy_type + + +/* The final nul store must be retained but the second strlen call should + be eliminated because the final length of the destination after the nul + store must be equal to the index of the store. */ +T (0, 2, 4, 0); + +/* Not handled yet (see below): + T (0, 2, 4, 1); */ + +/* Not handled yet: in addition to the cases above, the second strlen + call can also be eliminated in those below because in both the final + length of the destination after the nul store must be in the same + range as the length of the source. + T (0, 2, 4, 2); + T (0, 2, 4, 3); */ + +T (2, 3, 4, 0); +T (2, 3, 4, 1); + +/* Not handled yet (see above): + T (2, 3, 4, 2); + T (2, 3, 4, 3); */ + +T (3, 4, 5, 0); +T (3, 4, 5, 1); +T (3, 4, 5, 2); + +/* Not handled yet (see above): + T (3, 4, 5, 3); + T (3, 4, 5, 4); */ + +T (3, 4, 6, 0); +T (3, 4, 6, 1); +T (3, 4, 6, 2); + +/* Not handled yet (see above): + T (3, 4, 6, 3); + T (3, 4, 6, 4); + T (3, 4, 6, 5); */ + + +/* Verify that each function makes just one call to strlen to compute + the length of its argument (and not also to compute the length of + the copy): + { dg-final { scan-tree-dump-times "strlen \\(s_" 9 "strlen1" } } + { dg-final { scan-tree-dump-not "strlen \\(\\&a" "strlen1" } } + + Verify that nul stores into the destination have not been eliminated: + { dg-final { scan-tree-dump-times "a4\\\] = 0;" 2 "strlen1" } } + { dg-final { scan-tree-dump-times "a4 \\\+ 1B\\\] = 0;" 1 "strlen1" } } + + { dg-final { scan-tree-dump-times "a5\\\] = 0;" 1 "strlen1" } } + { dg-final { scan-tree-dump-times "a5 \\\+ 1B\\\] = 0;" 1 "strlen1" } } + { dg-final { scan-tree-dump-times "a5 \\\+ 2B\\\] = 0;" 1 "strlen1" } } + + { dg-final { scan-tree-dump-times "a6\\\] = 0;" 1 "strlen1" } } + { dg-final { scan-tree-dump-times "a6 \\\+ 1B\\\] = 0;" 1 "strlen1" } } + { dg-final { scan-tree-dump-times "a6 \\\+ 2B\\\] = 0;" 1 "strlen1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-91.c b/SingleSource/Regression/C/gcc-dg/strlenopt-91.c new file mode 100644 index 0000000000..a30556128e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-91.c @@ -0,0 +1,125 @@ +/* PR tree-optimization/92412 - excessive errno aliasing assumption defeats + optimization + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* alloca (size_t); +extern void* calloc (size_t, size_t); +extern void* malloc (size_t); + +extern const char exta[4]; +static char stata[] = "123"; + +void sink (const void*, ...); + +#define T(ptr, alloc) do { \ + const char *p = ptr; \ + if (p[0] != '1' || p[1] != '2' || p[2] != '3' || p[3] != '\0' \ + || __builtin_strlen (p) != 3) \ + return; \ + \ + void *q = alloc; \ + __builtin_strcpy (q, p); \ + \ + if (p[0] != '1' || p[1] != '2' || p[2] != '3' || p[3] != '\0' \ + || __builtin_strlen (p) != 3 \ + || __builtin_strlen (q) != 3) \ + __builtin_abort (); \ + \ + sink (p, q); \ + } while (0) + + +void alloca_test_local (unsigned n) +{ + char loca[] = "123"; + T (loca, alloca (n)); +} + +void alloca_test_extern_const (unsigned n) +{ + T (exta, alloca (n)); +} + +void alloca_test_static (unsigned n) +{ + T (stata, alloca (n)); +} + + +// Verify fix for PR tree-optimization/92412. +void calloc_test_local (unsigned m, unsigned n) +{ + char loca[] = "123"; + T (loca, calloc (m, n)); +} + +void calloc_test_extern_const (unsigned m, unsigned n) +{ + T (exta, calloc (m, n)); +} + +void calloc_test_static (unsigned m, unsigned n) +{ + T (stata, calloc (m, n)); +} + + +// Verify fix for PR tree-optimization/92412. +void malloc_test_local (unsigned n) +{ + char loca[] = "123"; + T (loca, malloc (n)); +} + +void malloc_test_extern_const (unsigned n) +{ + T (exta, malloc (n)); +} + +void malloc_test_static (unsigned n) +{ + T (stata, malloc (n)); +} + + +#undef T +#define T(ptr, n) do { \ + const char *p = ptr; \ + if (p[0] != '1' || p[1] != '2' || p[2] != '3' || p[3] != '\0' \ + || __builtin_strlen (p) != 3) \ + return; \ + \ + char vla[n]; \ + char *q = vla; \ + __builtin_strcpy (q, p); \ + \ + if (p[0] != '1' || p[1] != '2' || p[2] != '3' || p[3] != '\0' \ + || __builtin_strlen (p) != 3 \ + || __builtin_strlen (q) != 3) \ + __builtin_abort (); \ + \ + sink (p, vla); \ + } while (0) + + +void vla_test_local (unsigned n) +{ + char loca[] = "123"; + T (loca, n); +} + +void vla_test_extern_const (unsigned n) +{ + T (exta, n); +} + +void vla_test_static (unsigned n) +{ + T (stata, n); +} + +/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-92.c b/SingleSource/Regression/C/gcc-dg/strlenopt-92.c new file mode 100644 index 0000000000..a9383e6558 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-92.c @@ -0,0 +1,58 @@ +/* PR tree-optimization/92765 - wrong code for strcmp of a union member + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#include "strlenopt.h" + +__attribute__((noipa)) int +copy (char *x, int y) +{ + if (y == 0) + strcpy (x, "abcd"); + return y; +} + +__attribute__((noipa)) char * +alloc_2_copy_compare (int x) +{ + char *p; + if (x) + p = malloc (4); + else + p = calloc (16, 1); + + char *q = p + 2; + if (copy (q, x)) + return p; + + if (strcmp (q, "abcd") != 0) + abort (); + + return p; +} + +char a5[5], a6[6], a7[7]; + +__attribute__((noipa)) char * +decl_3_copy_compare (int x) +{ + char *p = x < 0 ? a5 : 0 < x ? a6 : a7; + char *q = p + 1; + if (copy (q, x)) + return p; + + if (strcmp (q, "abcd") != 0) + abort (); + + return p; +} + +int main () +{ + free (alloc_2_copy_compare (0)); + free (alloc_2_copy_compare (1)); + + decl_3_copy_compare (-1); + decl_3_copy_compare (0); + decl_3_copy_compare (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-93.c b/SingleSource/Regression/C/gcc-dg/strlenopt-93.c new file mode 100644 index 0000000000..dc5f12d2ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-93.c @@ -0,0 +1,71 @@ +/* Verify that strlen doesn't (inadvertently) use the size of an array + of char pointers to put an upper bound on the length of the strings + they point to. + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +void eaa_test (void) +{ + extern char eaa[4][4]; + + char (*p)[4] = eaa; + + if (!*p) + return; + + /* The longest string stored in EAA is 15 characters. */ + if (__builtin_strlen (*p) > 14) + { + extern void eaa_ok (void); + eaa_ok (); + } + + if (__builtin_strlen (*p) > 15) + { + extern void eaa_fail (void); + eaa_fail (); + } +} + +/* { dg-final { scan-tree-dump-times "eaa_ok" 1 "optimized" } } + { dg-final { scan-tree-dump-not "eaa_fail" "optimized" } } */ + + +void epa_test (void) +{ + extern char* epa[4]; + char **p = epa; + + if (*p && __builtin_strlen (*p) > 123) + { + extern void epa_ok (void); + epa_ok (); + } +} + +/* { dg-final { scan-tree-dump-times "epa_ok" 1 "optimized" } } */ + + +static char* spa[4]; + +void spa_test (void) +{ + char **p = spa; + + if (*p && __builtin_strlen (*p) > 123) + { + extern void spa_ok (); + spa_ok (); + } +} + +/* { dg-final { scan-tree-dump-times "spa_ok" 1 "optimized" } } */ + + +void sink (void*, ...); + +void init (void) +{ + /* Make believe even the static array SA may be non-zero. */ + sink (spa); +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-94.c b/SingleSource/Regression/C/gcc-dg/strlenopt-94.c new file mode 100644 index 0000000000..c2a23d3588 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-94.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/93982 - Assignment incorrectly omitted by + -foptimize-strlen + { dg-do run } + { dg-options "-O2 -Wall" } */ + +struct A { const char **a; }; +const char *buf[5]; + +__attribute__((noipa)) struct A +foo (char *p) +{ + struct A r = { (const char **) p }; + r.a[0] = "12345678"; + r.a[1] = ""; + r.a[2] = ""; + r.a[3] = ""; + r.a[4] = ""; + return r; +} + +int +main () +{ + struct A r = foo ((char *) &buf[0]); + if (!r.a[1] || r.a[1][0] != '\0') + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt-95.c b/SingleSource/Regression/C/gcc-dg/strlenopt-95.c new file mode 100644 index 0000000000..6e0a79d3e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt-95.c @@ -0,0 +1,65 @@ +/* Verify strlen results of vector assignments. + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +#include "strlenopt.h" + +#define V(N) __attribute__ ((vector_size (N))) + +typedef V (1) char VC1; +typedef V (2) char VC2; +typedef V (4) char VC4; +typedef V (8) char VC8; +typedef V (16) char VC16; + +extern char a[]; + +#define A(expr) ((expr) ? (void)0 : abort ()) + +void test_fold (int i) +{ + *(VC4*)a = (VC4){ }; + A (strlen (a) == 0); + A (!a[1] && !a[2] && !a[3]); + + *(VC4*)a = (VC4){ 0, 1 }; + A (strlen (a) == 0); + A (a[1] == 1 && !a[2] && !a[3]); + + *(VC4*)a = (VC4){ 1 }; + A (strlen (a) == 1); + A (!a[1] && !a[2] && !a[3]); + + *(VC4*)a = (VC4){ 1, 0, 3 }; + A (strlen (a) == 1); + A (!a[1] && a[2] == 3 && !a[3]); + + *(VC4*)a = (VC4){ 1, 2 }; + A (strlen (a) == 2); + A (!a[2] && !a[3]); + + *(VC4*)a = (VC4){ 1, 2, 0, 4 }; + A (strlen (a) == 2); + A (!a[2] && a[3] == 4); + + *(VC4*)a = (VC4){ 1, 2, 3 }; + A (strlen (a) == 3); + A (!a[3]); + + *(VC8*)a = (VC8){ 1, 2, 3, 0, 5 }; + A (strlen (a) == 3); + + *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6 }; + A (strlen (a) == 3); + + *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6, 7, 8 }; + A (strlen (a) == 3); + A (strlen (a + 1) == 2); + A (strlen (a + 2) == 1); + A (strlen (a + 3) == 0); + + A (a[4] == 5 && a[5] == 6 && a[6] == 7 && a[7] == 8); +} + +/* { dg-final { scan-tree-dump-not "abort \\(" "optimized" } } + { dg-final { scan-tree-dump-not "strlen \\(" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/strlenopt.h b/SingleSource/Regression/C/gcc-dg/strlenopt.h new file mode 100644 index 0000000000..a3ca951ddc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strlenopt.h @@ -0,0 +1,73 @@ +/* This is a replacement of needed parts from and + for -foptimize-strlen testing, to ensure we are testing the builtins + rather than whatever the OS has in its headers. */ + +#define NULL ((void *) 0) +typedef __SIZE_TYPE__ size_t; +extern void abort (void); +void *calloc (size_t, size_t); +void *malloc (size_t); +void free (void *); +char *strdup (const char *); +size_t strlen (const char *); +size_t strnlen (const char *, size_t); +void *memcpy (void *__restrict, const void *__restrict, size_t); +void *memmove (void *, const void *, size_t); +char *strcpy (char *__restrict, const char *__restrict); +char *strcat (char *__restrict, const char *__restrict); +char *strchr (const char *, int); +int strcmp (const char *, const char *); +int strncmp (const char *, const char *, size_t); +void *memset (void *, int, size_t); +int memcmp (const void *, const void *, size_t); +int strcmp (const char *, const char *); +#ifdef USE_GNU +void *mempcpy (void *__restrict, const void *__restrict, size_t); +char *stpcpy (char *__restrict, const char *__restrict); +#endif + +int sprintf (char * __restrict, const char *__restrict, ...); +int snprintf (char * __restrict, size_t, const char *__restrict, ...); + +#if defined(FORTIFY_SOURCE) && FORTIFY_SOURCE > 0 && __OPTIMIZE__ +# define bos(ptr) __builtin_object_size (ptr, FORTIFY_SOURCE > 0) +# define bos0(ptr) __builtin_object_size (ptr, 0) + +extern inline __attribute__((gnu_inline, always_inline, artificial)) void * +memcpy (void *__restrict dest, const void *__restrict src, size_t len) +{ + return __builtin___memcpy_chk (dest, src, len, bos0 (dest)); +} + +extern inline __attribute__((gnu_inline, always_inline, artificial)) void * +memmove (void *dest, const void *src, size_t len) +{ + return __builtin___memmove_chk (dest, src, len, bos0 (dest)); +} + +extern inline __attribute__((gnu_inline, always_inline, artificial)) char * +strcpy (char *__restrict dest, const char *__restrict src) +{ + return __builtin___strcpy_chk (dest, src, bos (dest)); +} + +extern inline __attribute__((gnu_inline, always_inline, artificial)) char * +strcat (char *__restrict dest, const char *__restrict src) +{ + return __builtin___strcat_chk (dest, src, bos (dest)); +} + +# ifdef USE_GNU +extern inline __attribute__((gnu_inline, always_inline, artificial)) void * +mempcpy (void *__restrict dest, const void *__restrict src, size_t len) +{ + return __builtin___mempcpy_chk (dest, src, len, bos0 (dest)); +} + +extern inline __attribute__((gnu_inline, always_inline, artificial)) char * +stpcpy (char *__restrict dest, const char *__restrict src) +{ + return __builtin___stpcpy_chk (dest, src, bos (dest)); +} +# endif +#endif diff --git a/SingleSource/Regression/C/gcc-dg/strncmp-1.c b/SingleSource/Regression/C/gcc-dg/strncmp-1.c new file mode 100644 index 0000000000..f9d26f76e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strncmp-1.c @@ -0,0 +1,635 @@ +/* Test strncmp builtin expansion for compilation and proper execution. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target ptr32plus } */ + +#include +#include +#include + +#define RUN_TEST(SZ, ALIGN) test_strncmp_ ## SZ ## _ ## ALIGN () + +#define DEF_TEST(SZ, ALIGN) \ +static void test_strncmp_ ## SZ ## _ ## ALIGN (void) { \ + char one[3 * (SZ > 10 ? SZ : 10)]; \ + char two[3 * (SZ > 10 ? SZ : 10)]; \ + char three[8192] __attribute__ ((aligned (4096))); \ + char four[8192] __attribute__ ((aligned (4096))); \ + int i,j; \ + memset(one,0,sizeof(one)); \ + memset(two,0,sizeof(two)); \ + memset(three,0,sizeof(three)); \ + memset(four,0,sizeof(four)); \ + for (i = 0 ; i < SZ ; i++) \ + { \ + int r1; \ + char *a = one + (i & 1) * ALIGN; \ + char *b = two + (i & 1) * ALIGN; \ + memset(a, '-', SZ); \ + memset(b, '-', SZ); \ + a[i] = '1'; \ + b[i] = '2'; \ + a[SZ] = 0; \ + b[SZ] = 0; \ + if (!((r1 = strncmp (b, a, SZ)) > 0)) \ + abort (); \ + if (!((r1 = strncmp (a, b, SZ)) < 0)) \ + abort (); \ + b[i] = '1'; \ + if (!((r1 = strncmp (a, b, SZ)) == 0)) \ + abort (); \ + for(j = i; j < SZ ; j++) \ + { \ + a[j] = '1'; \ + b[j] = '2'; \ + } \ + if (!((r1 = strncmp (b, a, SZ)) > 0)) \ + abort (); \ + if (!((r1 = strncmp (a, b, SZ)) < 0)) \ + abort (); \ + for(j = 0; j < i ; j++) \ + { \ + memset(a, '-', SZ); \ + memset(b, '-', SZ); \ + a[j] = '\0'; \ + a[j+1] = '1'; \ + b[j] = '\0'; \ + b[j+1] = '2'; \ + if ((r1 = strncmp (b, a, SZ)) != 0) \ + abort (); \ + } \ + a = three + 4096 - (SZ / 2 + (i & 1) * ALIGN); \ + b = four + 4096 - (SZ / 2 + (i & 1) * ALIGN); \ + memset(a, '-', SZ); \ + memset(b, '-', SZ); \ + a[i] = '1'; \ + b[i] = '2'; \ + a[SZ] = 0; \ + b[SZ] = 0; \ + if (!((r1 = strncmp(b, a, SZ)) > 0)) \ + abort (); \ + if (!((r1 = strncmp(a, b, SZ)) < 0)) \ + abort (); \ + b[i] = '1'; \ + if (!((r1 = strncmp(a, b, SZ)) == 0)) \ + abort (); \ + } \ +} + +#ifdef TEST_ALL +DEF_TEST(1,1) +DEF_TEST(1,2) +DEF_TEST(1,4) +DEF_TEST(1,8) +DEF_TEST(1,16) +DEF_TEST(2,1) +DEF_TEST(2,2) +DEF_TEST(2,4) +DEF_TEST(2,8) +DEF_TEST(2,16) +DEF_TEST(3,1) +DEF_TEST(3,2) +DEF_TEST(3,4) +DEF_TEST(3,8) +DEF_TEST(3,16) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(4,8) +DEF_TEST(4,16) +DEF_TEST(5,1) +DEF_TEST(5,2) +DEF_TEST(5,4) +DEF_TEST(5,8) +DEF_TEST(5,16) +DEF_TEST(6,1) +DEF_TEST(6,2) +DEF_TEST(6,4) +DEF_TEST(6,8) +DEF_TEST(6,16) +DEF_TEST(7,1) +DEF_TEST(7,2) +DEF_TEST(7,4) +DEF_TEST(7,8) +DEF_TEST(7,16) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(8,16) +DEF_TEST(9,1) +DEF_TEST(9,2) +DEF_TEST(9,4) +DEF_TEST(9,8) +DEF_TEST(9,16) +DEF_TEST(10,1) +DEF_TEST(10,2) +DEF_TEST(10,4) +DEF_TEST(10,8) +DEF_TEST(10,16) +DEF_TEST(11,1) +DEF_TEST(11,2) +DEF_TEST(11,4) +DEF_TEST(11,8) +DEF_TEST(11,16) +DEF_TEST(12,1) +DEF_TEST(12,2) +DEF_TEST(12,4) +DEF_TEST(12,8) +DEF_TEST(12,16) +DEF_TEST(13,1) +DEF_TEST(13,2) +DEF_TEST(13,4) +DEF_TEST(13,8) +DEF_TEST(13,16) +DEF_TEST(14,1) +DEF_TEST(14,2) +DEF_TEST(14,4) +DEF_TEST(14,8) +DEF_TEST(14,16) +DEF_TEST(15,1) +DEF_TEST(15,2) +DEF_TEST(15,4) +DEF_TEST(15,8) +DEF_TEST(15,16) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(17,1) +DEF_TEST(17,2) +DEF_TEST(17,4) +DEF_TEST(17,8) +DEF_TEST(17,16) +DEF_TEST(18,1) +DEF_TEST(18,2) +DEF_TEST(18,4) +DEF_TEST(18,8) +DEF_TEST(18,16) +DEF_TEST(19,1) +DEF_TEST(19,2) +DEF_TEST(19,4) +DEF_TEST(19,8) +DEF_TEST(19,16) +DEF_TEST(20,1) +DEF_TEST(20,2) +DEF_TEST(20,4) +DEF_TEST(20,8) +DEF_TEST(20,16) +DEF_TEST(21,1) +DEF_TEST(21,2) +DEF_TEST(21,4) +DEF_TEST(21,8) +DEF_TEST(21,16) +DEF_TEST(22,1) +DEF_TEST(22,2) +DEF_TEST(22,4) +DEF_TEST(22,8) +DEF_TEST(22,16) +DEF_TEST(23,1) +DEF_TEST(23,2) +DEF_TEST(23,4) +DEF_TEST(23,8) +DEF_TEST(23,16) +DEF_TEST(24,1) +DEF_TEST(24,2) +DEF_TEST(24,4) +DEF_TEST(24,8) +DEF_TEST(24,16) +DEF_TEST(25,1) +DEF_TEST(25,2) +DEF_TEST(25,4) +DEF_TEST(25,8) +DEF_TEST(25,16) +DEF_TEST(26,1) +DEF_TEST(26,2) +DEF_TEST(26,4) +DEF_TEST(26,8) +DEF_TEST(26,16) +DEF_TEST(27,1) +DEF_TEST(27,2) +DEF_TEST(27,4) +DEF_TEST(27,8) +DEF_TEST(27,16) +DEF_TEST(28,1) +DEF_TEST(28,2) +DEF_TEST(28,4) +DEF_TEST(28,8) +DEF_TEST(28,16) +DEF_TEST(29,1) +DEF_TEST(29,2) +DEF_TEST(29,4) +DEF_TEST(29,8) +DEF_TEST(29,16) +DEF_TEST(30,1) +DEF_TEST(30,2) +DEF_TEST(30,4) +DEF_TEST(30,8) +DEF_TEST(30,16) +DEF_TEST(31,1) +DEF_TEST(31,2) +DEF_TEST(31,4) +DEF_TEST(31,8) +DEF_TEST(31,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +DEF_TEST(33,1) +DEF_TEST(33,2) +DEF_TEST(33,4) +DEF_TEST(33,8) +DEF_TEST(33,16) +DEF_TEST(34,1) +DEF_TEST(34,2) +DEF_TEST(34,4) +DEF_TEST(34,8) +DEF_TEST(34,16) +DEF_TEST(35,1) +DEF_TEST(35,2) +DEF_TEST(35,4) +DEF_TEST(35,8) +DEF_TEST(35,16) +DEF_TEST(36,1) +DEF_TEST(36,2) +DEF_TEST(36,4) +DEF_TEST(36,8) +DEF_TEST(36,16) +DEF_TEST(37,1) +DEF_TEST(37,2) +DEF_TEST(37,4) +DEF_TEST(37,8) +DEF_TEST(37,16) +DEF_TEST(38,1) +DEF_TEST(38,2) +DEF_TEST(38,4) +DEF_TEST(38,8) +DEF_TEST(38,16) +DEF_TEST(39,1) +DEF_TEST(39,2) +DEF_TEST(39,4) +DEF_TEST(39,8) +DEF_TEST(39,16) +DEF_TEST(40,1) +DEF_TEST(40,2) +DEF_TEST(40,4) +DEF_TEST(40,8) +DEF_TEST(40,16) +DEF_TEST(41,1) +DEF_TEST(41,2) +DEF_TEST(41,4) +DEF_TEST(41,8) +DEF_TEST(41,16) +DEF_TEST(42,1) +DEF_TEST(42,2) +DEF_TEST(42,4) +DEF_TEST(42,8) +DEF_TEST(42,16) +DEF_TEST(43,1) +DEF_TEST(43,2) +DEF_TEST(43,4) +DEF_TEST(43,8) +DEF_TEST(43,16) +DEF_TEST(44,1) +DEF_TEST(44,2) +DEF_TEST(44,4) +DEF_TEST(44,8) +DEF_TEST(44,16) +DEF_TEST(45,1) +DEF_TEST(45,2) +DEF_TEST(45,4) +DEF_TEST(45,8) +DEF_TEST(45,16) +DEF_TEST(46,1) +DEF_TEST(46,2) +DEF_TEST(46,4) +DEF_TEST(46,8) +DEF_TEST(46,16) +DEF_TEST(47,1) +DEF_TEST(47,2) +DEF_TEST(47,4) +DEF_TEST(47,8) +DEF_TEST(47,16) +DEF_TEST(48,1) +DEF_TEST(48,2) +DEF_TEST(48,4) +DEF_TEST(48,8) +DEF_TEST(48,16) +DEF_TEST(49,1) +DEF_TEST(49,2) +DEF_TEST(49,4) +DEF_TEST(49,8) +DEF_TEST(49,16) +DEF_TEST(100,1) +DEF_TEST(100,2) +DEF_TEST(100,4) +DEF_TEST(100,8) +DEF_TEST(100,16) +#else +DEF_TEST(3,1) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(5,1) +DEF_TEST(6,1) +DEF_TEST(7,1) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(9,1) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +DEF_TEST(100,1) +DEF_TEST(100,2) +DEF_TEST(100,4) +DEF_TEST(100,8) +DEF_TEST(100,16) +#endif + +int +main(int argc, char **argv) +{ + +#ifdef TEST_ALL + RUN_TEST(1,1); + RUN_TEST(1,2); + RUN_TEST(1,4); + RUN_TEST(1,8); + RUN_TEST(1,16); + RUN_TEST(2,1); + RUN_TEST(2,2); + RUN_TEST(2,4); + RUN_TEST(2,8); + RUN_TEST(2,16); + RUN_TEST(3,1); + RUN_TEST(3,2); + RUN_TEST(3,4); + RUN_TEST(3,8); + RUN_TEST(3,16); + RUN_TEST(4,1); + RUN_TEST(4,2); + RUN_TEST(4,4); + RUN_TEST(4,8); + RUN_TEST(4,16); + RUN_TEST(5,1); + RUN_TEST(5,2); + RUN_TEST(5,4); + RUN_TEST(5,8); + RUN_TEST(5,16); + RUN_TEST(6,1); + RUN_TEST(6,2); + RUN_TEST(6,4); + RUN_TEST(6,8); + RUN_TEST(6,16); + RUN_TEST(7,1); + RUN_TEST(7,2); + RUN_TEST(7,4); + RUN_TEST(7,8); + RUN_TEST(7,16); + RUN_TEST(8,1); + RUN_TEST(8,2); + RUN_TEST(8,4); + RUN_TEST(8,8); + RUN_TEST(8,16); + RUN_TEST(9,1); + RUN_TEST(9,2); + RUN_TEST(9,4); + RUN_TEST(9,8); + RUN_TEST(9,16); + RUN_TEST(10,1); + RUN_TEST(10,2); + RUN_TEST(10,4); + RUN_TEST(10,8); + RUN_TEST(10,16); + RUN_TEST(11,1); + RUN_TEST(11,2); + RUN_TEST(11,4); + RUN_TEST(11,8); + RUN_TEST(11,16); + RUN_TEST(12,1); + RUN_TEST(12,2); + RUN_TEST(12,4); + RUN_TEST(12,8); + RUN_TEST(12,16); + RUN_TEST(13,1); + RUN_TEST(13,2); + RUN_TEST(13,4); + RUN_TEST(13,8); + RUN_TEST(13,16); + RUN_TEST(14,1); + RUN_TEST(14,2); + RUN_TEST(14,4); + RUN_TEST(14,8); + RUN_TEST(14,16); + RUN_TEST(15,1); + RUN_TEST(15,2); + RUN_TEST(15,4); + RUN_TEST(15,8); + RUN_TEST(15,16); + RUN_TEST(16,1); + RUN_TEST(16,2); + RUN_TEST(16,4); + RUN_TEST(16,8); + RUN_TEST(16,16); + RUN_TEST(17,1); + RUN_TEST(17,2); + RUN_TEST(17,4); + RUN_TEST(17,8); + RUN_TEST(17,16); + RUN_TEST(18,1); + RUN_TEST(18,2); + RUN_TEST(18,4); + RUN_TEST(18,8); + RUN_TEST(18,16); + RUN_TEST(19,1); + RUN_TEST(19,2); + RUN_TEST(19,4); + RUN_TEST(19,8); + RUN_TEST(19,16); + RUN_TEST(20,1); + RUN_TEST(20,2); + RUN_TEST(20,4); + RUN_TEST(20,8); + RUN_TEST(20,16); + RUN_TEST(21,1); + RUN_TEST(21,2); + RUN_TEST(21,4); + RUN_TEST(21,8); + RUN_TEST(21,16); + RUN_TEST(22,1); + RUN_TEST(22,2); + RUN_TEST(22,4); + RUN_TEST(22,8); + RUN_TEST(22,16); + RUN_TEST(23,1); + RUN_TEST(23,2); + RUN_TEST(23,4); + RUN_TEST(23,8); + RUN_TEST(23,16); + RUN_TEST(24,1); + RUN_TEST(24,2); + RUN_TEST(24,4); + RUN_TEST(24,8); + RUN_TEST(24,16); + RUN_TEST(25,1); + RUN_TEST(25,2); + RUN_TEST(25,4); + RUN_TEST(25,8); + RUN_TEST(25,16); + RUN_TEST(26,1); + RUN_TEST(26,2); + RUN_TEST(26,4); + RUN_TEST(26,8); + RUN_TEST(26,16); + RUN_TEST(27,1); + RUN_TEST(27,2); + RUN_TEST(27,4); + RUN_TEST(27,8); + RUN_TEST(27,16); + RUN_TEST(28,1); + RUN_TEST(28,2); + RUN_TEST(28,4); + RUN_TEST(28,8); + RUN_TEST(28,16); + RUN_TEST(29,1); + RUN_TEST(29,2); + RUN_TEST(29,4); + RUN_TEST(29,8); + RUN_TEST(29,16); + RUN_TEST(30,1); + RUN_TEST(30,2); + RUN_TEST(30,4); + RUN_TEST(30,8); + RUN_TEST(30,16); + RUN_TEST(31,1); + RUN_TEST(31,2); + RUN_TEST(31,4); + RUN_TEST(31,8); + RUN_TEST(31,16); + RUN_TEST(32,1); + RUN_TEST(32,2); + RUN_TEST(32,4); + RUN_TEST(32,8); + RUN_TEST(32,16); + RUN_TEST(33,1); + RUN_TEST(33,2); + RUN_TEST(33,4); + RUN_TEST(33,8); + RUN_TEST(33,16); + RUN_TEST(34,1); + RUN_TEST(34,2); + RUN_TEST(34,4); + RUN_TEST(34,8); + RUN_TEST(34,16); + RUN_TEST(35,1); + RUN_TEST(35,2); + RUN_TEST(35,4); + RUN_TEST(35,8); + RUN_TEST(35,16); + RUN_TEST(36,1); + RUN_TEST(36,2); + RUN_TEST(36,4); + RUN_TEST(36,8); + RUN_TEST(36,16); + RUN_TEST(37,1); + RUN_TEST(37,2); + RUN_TEST(37,4); + RUN_TEST(37,8); + RUN_TEST(37,16); + RUN_TEST(38,1); + RUN_TEST(38,2); + RUN_TEST(38,4); + RUN_TEST(38,8); + RUN_TEST(38,16); + RUN_TEST(39,1); + RUN_TEST(39,2); + RUN_TEST(39,4); + RUN_TEST(39,8); + RUN_TEST(39,16); + RUN_TEST(40,1); + RUN_TEST(40,2); + RUN_TEST(40,4); + RUN_TEST(40,8); + RUN_TEST(40,16); + RUN_TEST(41,1); + RUN_TEST(41,2); + RUN_TEST(41,4); + RUN_TEST(41,8); + RUN_TEST(41,16); + RUN_TEST(42,1); + RUN_TEST(42,2); + RUN_TEST(42,4); + RUN_TEST(42,8); + RUN_TEST(42,16); + RUN_TEST(43,1); + RUN_TEST(43,2); + RUN_TEST(43,4); + RUN_TEST(43,8); + RUN_TEST(43,16); + RUN_TEST(44,1); + RUN_TEST(44,2); + RUN_TEST(44,4); + RUN_TEST(44,8); + RUN_TEST(44,16); + RUN_TEST(45,1); + RUN_TEST(45,2); + RUN_TEST(45,4); + RUN_TEST(45,8); + RUN_TEST(45,16); + RUN_TEST(46,1); + RUN_TEST(46,2); + RUN_TEST(46,4); + RUN_TEST(46,8); + RUN_TEST(46,16); + RUN_TEST(47,1); + RUN_TEST(47,2); + RUN_TEST(47,4); + RUN_TEST(47,8); + RUN_TEST(47,16); + RUN_TEST(48,1); + RUN_TEST(48,2); + RUN_TEST(48,4); + RUN_TEST(48,8); + RUN_TEST(48,16); + RUN_TEST(49,1); + RUN_TEST(49,2); + RUN_TEST(49,4); + RUN_TEST(49,8); + RUN_TEST(49,16); +#else + RUN_TEST(3,1); + RUN_TEST(4,1); + RUN_TEST(4,2); + RUN_TEST(4,4); + RUN_TEST(5,1); + RUN_TEST(6,1); + RUN_TEST(7,1); + RUN_TEST(8,1); + RUN_TEST(8,2); + RUN_TEST(8,4); + RUN_TEST(8,8); + RUN_TEST(9,1); + RUN_TEST(16,1); + RUN_TEST(16,2); + RUN_TEST(16,4); + RUN_TEST(16,8); + RUN_TEST(16,16); + RUN_TEST(32,1); + RUN_TEST(32,2); + RUN_TEST(32,4); + RUN_TEST(32,8); + RUN_TEST(32,16); +#endif + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strncmp-2.c b/SingleSource/Regression/C/gcc-dg/strncmp-2.c new file mode 100644 index 0000000000..0d84f93276 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strncmp-2.c @@ -0,0 +1,124 @@ +/* Test strncmp builtin expansion for compilation and proper execution. */ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target ptr32plus } */ + +#include +#include +#include +#include +#include +#include + +int lib_memcmp(const void *a, const void *b, size_t n) asm("memcmp"); +int lib_strncmp(const char *a, const char *b, size_t n) asm("strncmp"); + +static void test_driver_strncmp (void (test_strncmp)(const char *, const char *, int), + void (test_memcmp)(const void *, const void *, int), + size_t sz) +{ + long pgsz = sysconf(_SC_PAGESIZE); + char buf1[sz+1]; + char *buf2; +#if _POSIX_C_SOURCE >= 200112L + if ( posix_memalign ((void **)&buf2, pgsz, 2*pgsz) ) abort (); +#else + if ( !(buf2 = valloc(2*pgsz))) abort (); +#endif + char *p2; + int r,i,e; + + r = mprotect (buf2+pgsz,pgsz,PROT_NONE); + if (r < 0) abort(); + + memset(buf1,'A',sz); + for(i=10; i>=0; i--) { + p2 = buf2+pgsz-sz-i; + memset(p2,'A',sz); + e = lib_strncmp(buf1,p2,sz); + (*test_strncmp)(buf1,p2,e); + e = lib_memcmp(buf1,p2,sz); + (*test_memcmp)(buf1,p2,e); + } + mprotect (buf2+pgsz,pgsz,PROT_READ|PROT_WRITE); + free(buf2); +} + +#define RUN_TEST(SZ) test_driver_strncmp (test_strncmp_ ## SZ, test_memcmp_ ## SZ, SZ); + +#define DEF_TEST(SZ) \ +__attribute__((noinline)) \ +void test_strncmp_ ## SZ (const char *str1, const char *str2, int expect) \ +{ \ + int r; \ + r = strncmp(str1,str2,SZ); \ + if ( r < 0 && !(expect < 0) ) abort(); \ + if ( r > 0 && !(expect > 0) ) abort(); \ + if ( r == 0 && !(expect == 0) ) abort(); \ +} \ +__attribute__((noinline)) \ +void test_memcmp_ ## SZ (const void *p1, const void *p2, int expect) \ +{ \ + int r; \ + r = memcmp(p1,p2,SZ); \ + if ( r < 0 && !(expect < 0) ) abort(); \ + if ( r > 0 && !(expect > 0) ) abort(); \ + if ( r == 0 && !(expect == 0) ) abort(); \ +} + +DEF_TEST(1) +DEF_TEST(2) +DEF_TEST(3) +DEF_TEST(4) +DEF_TEST(5) +DEF_TEST(6) +DEF_TEST(7) +DEF_TEST(8) +DEF_TEST(9) +DEF_TEST(10) +DEF_TEST(11) +DEF_TEST(12) +DEF_TEST(13) +DEF_TEST(14) +DEF_TEST(15) +DEF_TEST(16) +DEF_TEST(32) +DEF_TEST(64) +DEF_TEST(65) +DEF_TEST(66) +DEF_TEST(67) +DEF_TEST(68) +DEF_TEST(69) +DEF_TEST(70) +DEF_TEST(71) + +int +main(int argc, char **argv) +{ + RUN_TEST(1) ; + RUN_TEST(2) ; + RUN_TEST(3) ; + RUN_TEST(4) ; + RUN_TEST(5) ; + RUN_TEST(6) ; + RUN_TEST(7) ; + RUN_TEST(8) ; + RUN_TEST(9) ; + RUN_TEST(10); + RUN_TEST(11); + RUN_TEST(12); + RUN_TEST(13); + RUN_TEST(14); + RUN_TEST(15); + RUN_TEST(16); + RUN_TEST(32); + RUN_TEST(64); + RUN_TEST(65); + RUN_TEST(66); + RUN_TEST(67); + RUN_TEST(68); + RUN_TEST(69); + RUN_TEST(70); + RUN_TEST(71); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/strncmp-3.c b/SingleSource/Regression/C/gcc-dg/strncmp-3.c new file mode 100644 index 0000000000..0e8101cd61 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strncmp-3.c @@ -0,0 +1,57 @@ +/* PR middle-end/95189 - memcmp being wrongly stripped like strcmp + { dg-do run } + { dg-options "-O2 -Wall" } */ + +#define AB_D "ab\0d" +#define ABCDEF_H "abcdef\0h" +#define ABCDEFGHIJKLMN_P "abcdefghijklmn\0p" + +char ab_d[] = AB_D; +char abcdef_h[] = ABCDEF_H; + +extern int strncmp (const char*, const char*, __SIZE_TYPE__); + +__attribute__((noipa)) void sink (const void *p, ...) { (void)&p; } + +#define strncmp(a, b, n) (sink (a, b), strncmp (a, b, n)) + +int main (void) +{ + int zero = 0; + + zero += strncmp (ab_d, AB_D, 1); + zero += strncmp (ab_d, AB_D, 2); + zero += strncmp (ab_d, AB_D, 3); + zero += strncmp (ab_d, AB_D, 4); + zero += strncmp (ab_d, AB_D, 5); + + zero += strncmp (ab_d, ABCDEF_H, 1); + zero += strncmp (ab_d, ABCDEF_H, 2); + + zero += strncmp (abcdef_h, AB_D, 2); + + zero += strncmp (abcdef_h, ABCDEF_H, 2); + zero += strncmp (abcdef_h, ABCDEF_H, 3); + zero += strncmp (abcdef_h, ABCDEF_H, 4); + zero += strncmp (abcdef_h, ABCDEF_H, 5); + zero += strncmp (abcdef_h, ABCDEF_H, 6); + zero += strncmp (abcdef_h, ABCDEF_H, 7); + zero += strncmp (abcdef_h, ABCDEF_H, 8); + zero += strncmp (abcdef_h, ABCDEF_H, 9); + + if (zero != 0) + __builtin_abort (); + + int neg = 0; + + neg -= strncmp (ab_d, ABCDEF_H, 3) < 0; + neg -= strncmp (ab_d, ABCDEF_H, 4) < 0; + neg -= strncmp (ab_d, ABCDEF_H, 5) < 0; + neg -= strncmp (ab_d, ABCDEF_H, 6) < 0; + neg -= strncmp (ab_d, ABCDEF_H, 7) < 0; + neg -= strncmp (ab_d, ABCDEF_H, 8) < 0; + neg -= strncmp (ab_d, ABCDEF_H, 9) < 0; + + if (neg != -7) + __builtin_abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/strncpy-fix-1.c b/SingleSource/Regression/C/gcc-dg/strncpy-fix-1.c new file mode 100644 index 0000000000..b4fd4aa487 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/strncpy-fix-1.c @@ -0,0 +1,11 @@ +/* Test that use of strncpy does not result in a "value computed is + not used" warning. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wno-stringop-truncation" } */ + +#include +void +f (char *s) +{ + strncpy (s, "::", 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-alias-1.c b/SingleSource/Regression/C/gcc-dg/struct-alias-1.c new file mode 100644 index 0000000000..6cfadcf2cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-alias-1.c @@ -0,0 +1,22 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +struct S { + int a[3]; + int x; +}; + +extern void link_error(void); +static int i; + +int main() +{ + struct S s; + + s.x = 0; + s.a[i] = 1; + if (s.x != 0) + link_error (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-by-value-1.c b/SingleSource/Regression/C/gcc-dg/struct-by-value-1.c new file mode 100644 index 0000000000..ae7adb5fc8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-by-value-1.c @@ -0,0 +1,84 @@ +/* Test structure passing by value. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -G0" { target { nios2-*-* } } } */ + +#define T(N) \ +struct S##N { unsigned char i[N]; }; \ +struct S##N g1s##N, g2s##N, g3s##N; \ + \ +void \ +init##N (struct S##N *p, int i) \ +{ \ + int j; \ + for (j = 0; j < N; j++) \ + p->i[j] = i + j; \ +} \ + \ +void \ +check##N (struct S##N *p, int i) \ +{ \ + int j; \ + for (j = 0; j < N; j++) \ + if (p->i[j] != i + j) abort (); \ +} \ + \ +void \ +test##N (struct S##N s1, struct S##N s2, \ + struct S##N s3) \ +{ \ + check##N (&s1, 64); \ + check##N (&s2, 128); \ + check##N (&s3, 192); \ +} \ + \ +void \ +test2_##N (struct S##N s1, struct S##N s2) \ +{ \ + test##N (s1, g2s##N, s2); \ +} \ + \ +void \ +testit##N (void) \ +{ \ + init##N (&g1s##N, 64); \ + check##N (&g1s##N, 64); \ + init##N (&g2s##N, 128); \ + check##N (&g2s##N, 128); \ + init##N (&g3s##N, 192); \ + check##N (&g3s##N, 192); \ + test##N (g1s##N, g2s##N, g3s##N); \ + test2_##N (g1s##N, g3s##N); \ +} + +extern void abort (void); +extern void exit (int); + +T(0) T(1) T(2) T(3) T(4) T(5) T(6) T(7) +T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15) +T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23) +T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31) +T(32) T(33) T(34) T(35) T(36) T(37) T(38) T(39) +T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) +T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55) +T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63) + +#undef T + +int +main () +{ +#define T(N) testit##N (); + +T(0) T(1) T(2) T(3) T(4) T(5) T(6) T(7) +T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15) +T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23) +T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31) +T(32) T(33) T(34) T(35) T(36) T(37) T(38) T(39) +T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) +T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55) +T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63) + +#undef T + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-by-value-2.c b/SingleSource/Regression/C/gcc-dg/struct-by-value-2.c new file mode 100644 index 0000000000..8d5d0bb01c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-by-value-2.c @@ -0,0 +1,15 @@ +/* This testcase caused a sanity check to abort on SPARC64 + because of a discrepancy between two functions involved + in the calculation of structure layout. */ + +/* { dg-do compile } */ + +struct S { float f1; int i1; int i2; float f2; }; + +extern void foo(struct S); + +void bar(void) +{ + struct S s; + foo(s); +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-empty-1.c b/SingleSource/Regression/C/gcc-dg/struct-empty-1.c new file mode 100644 index 0000000000..7797465673 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-empty-1.c @@ -0,0 +1,10 @@ +/* Test diagnostics for empty structures and unions. Test with no + special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 {}; +union u0 {}; +struct s1 { int : 1; }; +union u1 { int : 1; }; diff --git a/SingleSource/Regression/C/gcc-dg/struct-empty-2.c b/SingleSource/Regression/C/gcc-dg/struct-empty-2.c new file mode 100644 index 0000000000..1f06a1b176 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-empty-2.c @@ -0,0 +1,10 @@ +/* Test diagnostics for empty structures and unions. Test with + -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +struct s0 {}; /* { dg-warning "struct has no members" } */ +union u0 {}; /* { dg-warning "union has no members" } */ +struct s1 { int : 1; }; /* { dg-warning "struct has no named members" } */ +union u1 { int : 1; }; /* { dg-warning "union has no named members" } */ diff --git a/SingleSource/Regression/C/gcc-dg/struct-empty-3.c b/SingleSource/Regression/C/gcc-dg/struct-empty-3.c new file mode 100644 index 0000000000..6e5baa9cff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-empty-3.c @@ -0,0 +1,10 @@ +/* Test diagnostics for empty structures and unions. Test with + -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +struct s0 {}; /* { dg-error "struct has no members" } */ +union u0 {}; /* { dg-error "union has no members" } */ +struct s1 { int : 1; }; /* { dg-error "struct has no named members" } */ +union u1 { int : 1; }; /* { dg-error "union has no named members" } */ diff --git a/SingleSource/Regression/C/gcc-dg/struct-in-proto-1.c b/SingleSource/Regression/C/gcc-dg/struct-in-proto-1.c new file mode 100644 index 0000000000..162ba914aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-in-proto-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +int foo(struct S { int i; } s) { + return sizeof(struct S); /* { dg-bogus "incomplete type" "S visible here" } */ +} +int bar(void) { + return sizeof(struct S); /* { dg-error "incomplete type" "not here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-incompl-1.c b/SingleSource/Regression/C/gcc-dg/struct-incompl-1.c new file mode 100644 index 0000000000..c32b2d5384 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-incompl-1.c @@ -0,0 +1,7 @@ +/* PR c/26818 */ +/* { dg-do compile } */ + +struct __attribute__ ((packed)) A +{ + struct B b; /* { dg-error "incomplete" } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/struct-parse-1.c b/SingleSource/Regression/C/gcc-dg/struct-parse-1.c new file mode 100644 index 0000000000..9ceac8afad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-parse-1.c @@ -0,0 +1,11 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. */ +/* Contributed by Carlos O'Donell on 2006-03-31 */ + +/* This code caused the C frontend to loop + forever exhausting all system memory, or ICE */ +/* Origin: Carlos O'Donell */ + +/* { dg-options "-std=c99" } */ +struct s { int a; int b; struct t c; }; /* { dg-error "field 'c' has incomplete type" } */ +struct s d = { .b = 0 }; + diff --git a/SingleSource/Regression/C/gcc-dg/struct-parse-2.c b/SingleSource/Regression/C/gcc-dg/struct-parse-2.c new file mode 100644 index 0000000000..6d01f3e88a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-parse-2.c @@ -0,0 +1,13 @@ +/* PR c/35437 */ +/* { dg-do compile } */ + +struct A +{ + int i; + struct A a; /* { dg-error "has incomplete type" } */ +}; + +void foo() +{ + struct A b = { 0 }; +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-ret-1.c b/SingleSource/Regression/C/gcc-dg/struct-ret-1.c new file mode 100644 index 0000000000..330c76ab84 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-ret-1.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-options { -O2 } } */ +extern void abort (void); +extern void exit (int); +typedef struct { + int x; + int y; +} point_t; + +int main(int argc, char *argv[]); +int printPoints(point_t a, point_t b); +point_t toPoint(int x1, int y1); + +int +main(int argc, char *argv[]) +{ + + if (printPoints(toPoint(0, 0), toPoint(1000, 1000)) != 1) + abort(); + else + exit(0); + + return 0; +} + +int +printPoints(point_t a, point_t b) +{ + if (a.x != 0 + || a.y != 0 + || b.x != 1000 + || b.y != 1000) + return 0; + else + return 1; +} + +point_t +toPoint(int x1, int y1) +{ + point_t p; + + p.x = x1; + p.y = y1; + + return p; +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-ret-2.c b/SingleSource/Regression/C/gcc-dg/struct-ret-2.c new file mode 100644 index 0000000000..0d9b86f6fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-ret-2.c @@ -0,0 +1,15 @@ +/* Simplified by Alexandre Oliva + from bug report by Helmut Jarausch + + Copyright (C) 1999 Free Software Foundation */ + +/* { dg-do compile } */ +/* { dg-options "-O3 -w" } */ + +struct { + unsigned i[4]; +} foo() {} + +void bar() { + foo(); +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-ret-3.c b/SingleSource/Regression/C/gcc-dg/struct-ret-3.c new file mode 100644 index 0000000000..4c0a0e6e1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-ret-3.c @@ -0,0 +1,113 @@ +/* PR middle-end/31309 */ +/* Origin: Peeter Joot */ + +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-add-options stack_size } */ + +#include +#include +#include +#include +#include + +#if defined(STACK_SIZE) && (STACK_SIZE < 128*1024) + #define CHUNK_SIZE 4096 +#else + #define CHUNK_SIZE 16384 +#endif + +unsigned long ossAlignX(unsigned long i, unsigned long X) +{ + return ((i + (X - 1)) & ~(unsigned long) (X - 1)); +} + +struct STRUCT_6_BYTES +{ + unsigned char slot[sizeof(unsigned short)]; + unsigned char page[sizeof(unsigned int)]; +}; + +struct SQLU_DICT_INFO_0 +{ + void *pBlah; + char bSomeFlag1; + char bSomeFlag2; + struct STRUCT_6_BYTES dRID; +}; + +struct SQLU_DATAPART_0 +{ + struct SQLU_DICT_INFO_0 *pDictRidderInfo; +}; + +struct XXX +{ + struct SQLU_DATAPART_0 *m_pDatapart; +}; + +struct STRUCT_6_BYTES INIT_6_BYTES_ZERO() +{ + struct STRUCT_6_BYTES ridOut = {{0,0}, {0,0,0,0}}; + return ridOut; +} + +void Initialize(struct XXX *this, int iIndex) +{ + struct SQLU_DICT_INFO_0 *pDictRidderInfo + = this->m_pDatapart[iIndex].pDictRidderInfo; + pDictRidderInfo->bSomeFlag1 = 0; + pDictRidderInfo->bSomeFlag2 = 0; + pDictRidderInfo->dRID = INIT_6_BYTES_ZERO(); +} + +int main(void) +{ + int rc; + + struct stuff + { + char c0[CHUNK_SIZE-sizeof(struct XXX)]; + struct XXX o; + char c1[CHUNK_SIZE*2-sizeof(struct SQLU_DATAPART_0)]; + struct SQLU_DATAPART_0 dp; + char c2[CHUNK_SIZE*2-sizeof(struct SQLU_DICT_INFO_0)]; + struct SQLU_DICT_INFO_0 di; + char c3[CHUNK_SIZE]; + }; + + char buf[sizeof(struct stuff)+CHUNK_SIZE]; + struct stuff *u + = (struct stuff *)ossAlignX((unsigned long)&buf[0], CHUNK_SIZE); + + /* This test assumes system memory page + size of CHUNK_SIZE bytes or less. */ + if (sysconf(_SC_PAGESIZE) > CHUNK_SIZE) + return 0; + + memset(u, 1, sizeof(struct stuff)); + u->c1[0] = '\xAA'; + u->c2[0] = '\xBB'; + u->c3[0] = '\xCC'; + + rc = mprotect(u->c1, CHUNK_SIZE, PROT_NONE); + if (rc == -1) + printf("mprotect:c1: %d: %d(%s)\n", rc, errno, strerror(errno)); + + rc = mprotect(u->c2, CHUNK_SIZE, PROT_NONE); + if (rc == -1) + printf("mprotect:c2: %d: %d(%s)\n", rc, errno, strerror(errno)); + + rc = mprotect(u->c3, CHUNK_SIZE, PROT_NONE); + if (rc == -1) + printf("mprotect:c3: %d: %d(%s)\n", rc, errno, strerror(errno)); + + u->o.m_pDatapart = &u->dp; + u->dp.pDictRidderInfo = &u->di; + Initialize(&u->o, 0); + + mprotect(u->c1, CHUNK_SIZE, PROT_READ|PROT_WRITE); + mprotect(u->c2, CHUNK_SIZE, PROT_READ|PROT_WRITE); + mprotect(u->c3, CHUNK_SIZE, PROT_READ|PROT_WRITE); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-ret-libc.c b/SingleSource/Regression/C/gcc-dg/struct-ret-libc.c new file mode 100644 index 0000000000..723e1cd029 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-ret-libc.c @@ -0,0 +1,16 @@ +/* Test evolved from source from Simona Perri + and Gerald Pfeifer. + + Copyright (C) 2003 Free Software Foundation */ + +/* { dg-do run } */ + +#include + +int main () +{ + div_t d = div (20, 5); + if ((d.quot != 4) || (d.rem)) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/struct-semi-1.c b/SingleSource/Regression/C/gcc-dg/struct-semi-1.c new file mode 100644 index 0000000000..8ac90eaee7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-semi-1.c @@ -0,0 +1,19 @@ +/* Test diagnostics for missing and extra semicolons in structures. + Test with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s0 { ; }; +struct s1 { + int a; + ; + int b; +}; +struct s2 { + ; + int c +}; /* { dg-warning "no semicolon at end of struct or union" } */ +struct s3 { + int d +}; /* { dg-warning "no semicolon at end of struct or union" } */ diff --git a/SingleSource/Regression/C/gcc-dg/struct-semi-2.c b/SingleSource/Regression/C/gcc-dg/struct-semi-2.c new file mode 100644 index 0000000000..1c336c5f4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-semi-2.c @@ -0,0 +1,20 @@ +/* Test diagnostics for missing and extra semicolons in structures. + Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +struct s0 { ; }; /* { dg-warning "extra semicolon in struct or union specified" } */ +/* { dg-warning "struct has no members" "empty" { target *-*-* } .-1 } */ +struct s1 { + int a; + ; /* { dg-warning "extra semicolon in struct or union specified" } */ + int b; +}; +struct s2 { + ; /* { dg-warning "extra semicolon in struct or union specified" } */ + int c +}; /* { dg-warning "no semicolon at end of struct or union" } */ +struct s3 { + int d +}; /* { dg-warning "no semicolon at end of struct or union" } */ diff --git a/SingleSource/Regression/C/gcc-dg/struct-semi-3.c b/SingleSource/Regression/C/gcc-dg/struct-semi-3.c new file mode 100644 index 0000000000..e114cfa6d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-semi-3.c @@ -0,0 +1,20 @@ +/* Test diagnostics for missing and extra semicolons in structures. + Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +struct s0 { ; }; /* { dg-error "extra semicolon in struct or union specified" } */ +/* { dg-error "struct has no members" "empty" { target *-*-* } .-1 } */ +struct s1 { + int a; + ; /* { dg-error "extra semicolon in struct or union specified" } */ + int b; +}; +struct s2 { + ; /* { dg-error "extra semicolon in struct or union specified" } */ + int c +}; /* { dg-error "no semicolon at end of struct or union" } */ +struct s3 { + int d +}; /* { dg-error "no semicolon at end of struct or union" } */ diff --git a/SingleSource/Regression/C/gcc-dg/struct-semi-4.c b/SingleSource/Regression/C/gcc-dg/struct-semi-4.c new file mode 100644 index 0000000000..6f4dc7c0a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/struct-semi-4.c @@ -0,0 +1,7 @@ +/* Test for missing semicolons in structures: anonymous structures and + similar cases. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct s { struct { int a; } }; /* { dg-warning "no semicolon" } */ +int *f (struct s *p) { return &p->a; } diff --git a/SingleSource/Regression/C/gcc-dg/subnot.c b/SingleSource/Regression/C/gcc-dg/subnot.c new file mode 100644 index 0000000000..d621bacd27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/subnot.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +float g(float a, float b) +{ + return ~(int)a - ~(int)b; +} + +/* { dg-final { scan-tree-dump-not "~" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/superblock.c b/SingleSource/Regression/C/gcc-dg/superblock.c new file mode 100644 index 0000000000..6b4419adaf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/superblock.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-asynchronous-unwind-tables -fsched2-use-superblocks -fdump-rtl-sched2 -fdump-rtl-bbro -fno-stack-protector" } */ +/* { dg-require-effective-target scheduling } */ + +typedef int aligned __attribute__ ((aligned (64))); +extern void abort (void); + +int bar (void *p); + +void +foo (void) +{ + char *p = __builtin_alloca (13); + aligned i; + + if (bar (p) || bar (&i)) + abort (); +} + +/* { dg-final { scan-rtl-dump-times "0 uses" 0 "bbro"} } */ +/* { dg-final { scan-rtl-dump-times "ADVANCING TO" 2 "sched2"} } */ + diff --git a/SingleSource/Regression/C/gcc-dg/switch-1.c b/SingleSource/Regression/C/gcc-dg/switch-1.c new file mode 100644 index 0000000000..1879790dd1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-fpic -O2" } */ + +void f (char *s) +{ + for (;;) + { + int t = 6; + switch (t) + { + case 2: + *s = '2'; + case 6: case 4: case 3: case 1: + break; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/switch-10.c b/SingleSource/Regression/C/gcc-dg/switch-10.c new file mode 100644 index 0000000000..9e5926745b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-10.c @@ -0,0 +1,23 @@ +/* { dg-options "-O2 -fdump-tree-cfg" } */ +#include + +void foo (void); +void bar (void); + +void +test (uint8_t ch) +{ + switch (ch) + { + case 0: + foo (); + break; + + case 1 ... 255: + bar (); + break; + } +} + +/* Switch statement is converted to GIMPLE condition. */ +/* { dg-final { scan-tree-dump-not "switch" "cfg" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/switch-2.c b/SingleSource/Regression/C/gcc-dg/switch-2.c new file mode 100644 index 0000000000..cedb69f7b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-2.c @@ -0,0 +1,10 @@ +/* PR c/9262 */ +/* Originator: Rasmus Hahn */ +/* { dg-do compile } */ + +int foo(int i) +{ + switch (i) + case 3: + return 1, +} /* { dg-error "parse error|syntax error|expected" } */ diff --git a/SingleSource/Regression/C/gcc-dg/switch-3.c b/SingleSource/Regression/C/gcc-dg/switch-3.c new file mode 100644 index 0000000000..593c42d8b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-3.c @@ -0,0 +1,12 @@ +/* PR c/9262 */ +/* Originator: Rasmus Hahn */ +/* { dg-do compile } */ + +int foo(int i) +{ + switch (i) + case 3: + return 1; + case 4: /* { dg-error "not within a switch statement" } */ + return 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/switch-4.c b/SingleSource/Regression/C/gcc-dg/switch-4.c new file mode 100644 index 0000000000..f2d85300d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-4.c @@ -0,0 +1,24 @@ +/* PR middle-end/17657 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern signed char foo(int); + +void bar (void) +{ + signed char tmp = foo (0); + int t1 = tmp; + switch (t1) + { + case 1: foo (1); break; + case 2: foo (2); break; + case 3: foo (3); break; + case 4: foo (4); break; + case 5: foo (5); break; + case 6: foo (6); break; + case 7: foo (7); break; + case 255: foo (8); break; + default: break; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/switch-5.c b/SingleSource/Regression/C/gcc-dg/switch-5.c new file mode 100644 index 0000000000..a097d446c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-5.c @@ -0,0 +1,75 @@ +/* Test diagnostics for switch statements and labels therein. Test + with no special options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +f (int a, double d, void *p) +{ + switch (d) /* { dg-error "switch quantity not an integer" } */ + { + } + switch (p) /* { dg-error "switch quantity not an integer" } */ + { + } + switch (a) + { + case (void *)0: ; /* { dg-error "pointers are not permitted as case values" } */ + } + switch (a) + { + case (double)0: ; /* { dg-error "case label does not reduce to an integer constant" } */ + } + switch (a) + { + case (char)0: ; + } + switch (a) + { + case 0 ... 0: ; + } + switch (a) + { + case 0 ... -1: ; /* { dg-warning "empty range specified" } */ + } + switch (a) + { + case 0 ... -2: ; /* { dg-warning "empty range specified" } */ + } + switch (a) + { + case 0: + default: /* { dg-message "this is the first default label" } */ + case 1: + default: ; /* { dg-error "multiple default labels in one switch" } */ + } + switch (a) + { + case 0: /* { dg-message "previously used here" } */ + case 1: + case 0: ; /* { dg-error "duplicate case value" } */ + } + case 1: ; /* { dg-error "case label not within a switch statement" } */ + default: ; /* { dg-error "'default' label not within a switch statement" } */ + break; /* { dg-error "break statement not within loop or switch" } */ + continue; /* { dg-error "continue statement not within a loop" } */ + switch (a) + { + case a: ; /* { dg-error "case label does not reduce to an integer constant" } */ + } + switch (a) + { + case 0: /* { dg-message "this is the first entry overlapping that value" } */ + case -1 ... 1: /* { dg-error "duplicate \\(or overlapping\\) case value" } */ + case 2 ... 3: /* { dg-message "previously used here" } */ + case 2: /* { dg-error "duplicate case value" } */ + case 4 ... 7: /* { dg-message "this is the first entry overlapping that value" } */ + case 6 ... 9: ; /* { dg-error "duplicate \\(or overlapping\\) case value" } */ + } + switch (a) + { + case 0: + continue; /* { dg-error "continue statement not within a loop" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/switch-6.c b/SingleSource/Regression/C/gcc-dg/switch-6.c new file mode 100644 index 0000000000..25d1d96b26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-6.c @@ -0,0 +1,14 @@ +/* Test diagnostics for switch statements and labels therein. Test + for case ranges with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +void +f (int a) +{ + switch (a) + { + case 0 ... 0: ; /* { dg-warning "range expressions in switch statements are non-standard" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/switch-7.c b/SingleSource/Regression/C/gcc-dg/switch-7.c new file mode 100644 index 0000000000..29cb825699 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-7.c @@ -0,0 +1,14 @@ +/* Test diagnostics for switch statements and labels therein. Test + for case ranges with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +void +f (int a) +{ + switch (a) + { + case 0 ... 0: ; /* { dg-error "range expressions in switch statements are non-standard" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/switch-8.c b/SingleSource/Regression/C/gcc-dg/switch-8.c new file mode 100644 index 0000000000..fcb3f602ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-8.c @@ -0,0 +1,10 @@ +/* PR middle-end/18493 */ +/* { dg-do link } */ + +int main() { +goto bug; +switch(0) { +bug: return 0; +} +} + diff --git a/SingleSource/Regression/C/gcc-dg/switch-9.c b/SingleSource/Regression/C/gcc-dg/switch-9.c new file mode 100644 index 0000000000..2ae89d0951 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-9.c @@ -0,0 +1,25 @@ +/* PR middle-end/18859 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo(int a) +{ + switch (a) + { + case 0 ... -1: /* { dg-warning "empty range" } */ + a = a+2; + break; + + case 1 ... 2: + a = 0; + break; + + case 3 ... 4: + a = 1; + break; + + case 5 ... 6: + a = 0; + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/switch-A.c b/SingleSource/Regression/C/gcc-dg/switch-A.c new file mode 100644 index 0000000000..3bc04c0172 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-A.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +void foo() +{ + switch (,) { } /* { dg-error "expected expression before" } */ +} + diff --git a/SingleSource/Regression/C/gcc-dg/switch-warn-1.c b/SingleSource/Regression/C/gcc-dg/switch-warn-1.c new file mode 100644 index 0000000000..58fbd7d486 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-warn-1.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +extern void abort (void); +extern void exit (int); + +/* Check that out-of-bounds case warnings work in the case that the + testing expression is promoted. */ +int +foo1 (unsigned char i) +{ + switch (i) + { + case -1: /* { dg-warning "case label value is less than minimum value for type|statement will never be executed" } */ + return 1; + case 256: /* { dg-warning "case label value exceeds maximum value for type" } */ + return 2; + default: + return 3; + } +} + +/* Like above, but for case ranges that need to be satured. */ +int +foo2 (unsigned char i) +{ + switch (i) + { + case -1 ... 1: /* { dg-warning "lower value in case label range less than minimum value for type" } */ + return 1; + case 254 ... 256: /* { dg-warning "upper value in case label range exceeds maximum value for type" } */ + return 2; + default: + return 3; + } +} + +int +main (void) +{ + if (foo1 (10) != 3) + abort (); + if (foo2 (10) != 3) + abort (); + exit (0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/switch-warn-2.c b/SingleSource/Regression/C/gcc-dg/switch-warn-2.c new file mode 100644 index 0000000000..76fd982b57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-warn-2.c @@ -0,0 +1,26 @@ +/* This should not warn about the case label being out of range. */ +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +extern void abort (void); +extern void exit (int); + +int +foo (unsigned int i) +{ + switch (i) + { + case 123456123456ULL: /* { dg-warning "conversion from .long long unsigned int. to .unsigned int. changes value" } */ + return 0; + default: + return 3; + } +} + +int +main (void) +{ + if (foo (10) != 3) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/switch-warn-3.c b/SingleSource/Regression/C/gcc-dg/switch-warn-3.c new file mode 100644 index 0000000000..e13b4f58a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/switch-warn-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-Wswitch-enum" } */ + +enum a { a0, a1, a2, a3 }; + +int error(enum a aa) +{ + switch ( aa ) + { + case a0 ... a3: + return 1; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sync-1.c b/SingleSource/Regression/C/gcc-dg/sync-1.c new file mode 100644 index 0000000000..f8cabe47a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sync-1.c @@ -0,0 +1,40 @@ +/* Validate that the __sync builtins are overloaded properly. */ +/* { dg-do compile } */ +/* { dg-options "-Werror" } */ + +#define TEST1(TYPE, BUILTIN) \ +void t_##TYPE##BUILTIN(TYPE *p) \ +{ \ + __typeof(BUILTIN(p, 1)) *pp; \ + pp = p; \ +} + +#define TEST2(BUILTIN) \ + TEST1(int, BUILTIN) \ + TEST1(long, BUILTIN) + +TEST2(__sync_fetch_and_add) +TEST2(__sync_fetch_and_sub) +TEST2(__sync_fetch_and_or) +TEST2(__sync_fetch_and_and) +TEST2(__sync_fetch_and_xor) +TEST2(__sync_fetch_and_nand) + +TEST2(__sync_add_and_fetch) +TEST2(__sync_sub_and_fetch) +TEST2(__sync_or_and_fetch) +TEST2(__sync_and_and_fetch) +TEST2(__sync_xor_and_fetch) +TEST2(__sync_nand_and_fetch) + +TEST2(__sync_lock_test_and_set) + +#define TEST3(TYPE) \ +void t_##TYPE##__sync_val_compare_and_swap(TYPE *p) \ +{ \ + __typeof(__sync_val_compare_and_swap(p, 1, 2)) *pp; \ + pp = p; \ +} + +TEST3(int) +TEST3(long) diff --git a/SingleSource/Regression/C/gcc-dg/sync-2.c b/SingleSource/Regression/C/gcc-dg/sync-2.c new file mode 100644 index 0000000000..28c1d43375 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sync-2.c @@ -0,0 +1,106 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ +/* { dg-options "-ansi" } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "fetch_and_nand" { target *-*-* } 0 } */ +/* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "nand_and_fetch" { target *-*-* } 0 } */ + +/* Test functionality of the intrinsics for 'short' and 'char'. */ + +extern void abort (void); +extern void *memcpy (void *, const void *, __SIZE_TYPE__); +extern int memcmp (const void *, const void *, __SIZE_TYPE__); + +static char AI[18]; +static char init_qi[18] = { 3,5,7,9,0,0,0 ,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; + +static void +do_qi (void) +{ + if (__sync_fetch_and_add(AI+4, 1) != 0) + abort (); + if (__sync_fetch_and_add(AI+5, 4) != 0) + abort (); + if (__sync_fetch_and_add(AI+6, 22) != 0) + abort (); + if (__sync_fetch_and_sub(AI+7, 12) != 0) + abort (); + if (__sync_fetch_and_and(AI+8, 7) != (char)-1) + abort (); + if (__sync_fetch_and_or(AI+9, 8) != 0) + abort (); + if (__sync_fetch_and_xor(AI+10, 9) != 0) + abort (); + if (__sync_fetch_and_nand(AI+11, 7) != (char)-1) + abort (); + + if (__sync_add_and_fetch(AI+12, 1) != 1) + abort (); + if (__sync_sub_and_fetch(AI+13, 12) != (char)-12) + abort (); + if (__sync_and_and_fetch(AI+14, 7) != 7) + abort (); + if (__sync_or_and_fetch(AI+15, 8) != 8) + abort (); + if (__sync_xor_and_fetch(AI+16, 9) != 9) + abort (); + if (__sync_nand_and_fetch(AI+17, 7) != (char)~7) + abort (); +} + +static short AL[18]; +static short init_hi[18] = { 3,5,7,9,0,0,0 ,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; + +static void +do_hi (void) +{ + if (__sync_fetch_and_add(AL+4, 1) != 0) + abort (); + if (__sync_fetch_and_add(AL+5, 4) != 0) + abort (); + if (__sync_fetch_and_add(AL+6, 22) != 0) + abort (); + if (__sync_fetch_and_sub(AL+7, 12) != 0) + abort (); + if (__sync_fetch_and_and(AL+8, 7) != -1) + abort (); + if (__sync_fetch_and_or(AL+9, 8) != 0) + abort (); + if (__sync_fetch_and_xor(AL+10, 9) != 0) + abort (); + if (__sync_fetch_and_nand(AL+11, 7) != -1) + abort (); + + if (__sync_add_and_fetch(AL+12, 1) != 1) + abort (); + if (__sync_sub_and_fetch(AL+13, 12) != -12) + abort (); + if (__sync_and_and_fetch(AL+14, 7) != 7) + abort (); + if (__sync_or_and_fetch(AL+15, 8) != 8) + abort (); + if (__sync_xor_and_fetch(AL+16, 9) != 9) + abort (); + if (__sync_nand_and_fetch(AL+17, 7) != ~7) + abort (); +} + +int main() +{ + memcpy(AI, init_qi, sizeof(init_qi)); + memcpy(AL, init_hi, sizeof(init_hi)); + + do_qi (); + do_hi (); + + if (memcmp (AI, test_qi, sizeof(test_qi))) + abort (); + if (memcmp (AL, test_hi, sizeof(test_hi))) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sync-3.c b/SingleSource/Regression/C/gcc-dg/sync-3.c new file mode 100644 index 0000000000..93e79d072f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sync-3.c @@ -0,0 +1,103 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ +/* { dg-options "-ansi" } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* Test functionality of the intrinsics for 'short' and 'char'. */ + +extern void abort (void); +extern void *memcpy (void *, const void *, __SIZE_TYPE__); +extern int memcmp (const void *, const void *, __SIZE_TYPE__); + +static char AI[18] __attribute__((__aligned__ (4))); +static char init_qi[18] = { 3,5,7,9,0,0,0 ,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; + +static void +do_qi (void) +{ + if (__sync_fetch_and_add(AI+4, 1) != 0) + abort (); + if (__sync_fetch_and_add(AI+5, 4) != 0) + abort (); + if (__sync_fetch_and_add(AI+6, 22) != 0) + abort (); + if (__sync_fetch_and_sub(AI+7, 12) != 0) + abort (); + if (__sync_fetch_and_and(AI+8, 7) != (char)-1) + abort (); + if (__sync_fetch_and_or(AI+9, 8) != 0) + abort (); + if (__sync_fetch_and_xor(AI+10, 9) != 0) + abort (); + if (__sync_fetch_and_nand(AI+11, 7) != (char)-1) /* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" } */ + abort (); + + if (__sync_add_and_fetch(AI+12, 1) != 1) + abort (); + if (__sync_sub_and_fetch(AI+13, 12) != (char)-12) + abort (); + if (__sync_and_and_fetch(AI+14, 7) != 7) + abort (); + if (__sync_or_and_fetch(AI+15, 8) != 8) + abort (); + if (__sync_xor_and_fetch(AI+16, 9) != 9) + abort (); + if (__sync_nand_and_fetch(AI+17, 7) != (char)~7) /* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" } */ + abort (); +} + +static short AL[18]; +static short init_hi[18] = { 3,5,7,9,0,0,0 ,0 ,-1,0,0,-1,0,0 ,-1,0,0,-1 }; +static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7 ,8,9,~7,1,-12,7 ,8,9,~7 }; + +static void +do_hi (void) +{ + if (__sync_fetch_and_add(AL+4, 1) != 0) + abort (); + if (__sync_fetch_and_add(AL+5, 4) != 0) + abort (); + if (__sync_fetch_and_add(AL+6, 22) != 0) + abort (); + if (__sync_fetch_and_sub(AL+7, 12) != 0) + abort (); + if (__sync_fetch_and_and(AL+8, 7) != -1) + abort (); + if (__sync_fetch_and_or(AL+9, 8) != 0) + abort (); + if (__sync_fetch_and_xor(AL+10, 9) != 0) + abort (); + if (__sync_fetch_and_nand(AL+11, 7) != -1) + abort (); + + if (__sync_add_and_fetch(AL+12, 1) != 1) + abort (); + if (__sync_sub_and_fetch(AL+13, 12) != -12) + abort (); + if (__sync_and_and_fetch(AL+14, 7) != 7) + abort (); + if (__sync_or_and_fetch(AL+15, 8) != 8) + abort (); + if (__sync_xor_and_fetch(AL+16, 9) != 9) + abort (); + if (__sync_nand_and_fetch(AL+17, 7) != ~7) + abort (); +} + +int main() +{ + memcpy(AI, init_qi, sizeof(init_qi)); + memcpy(AL, init_hi, sizeof(init_hi)); + + do_qi (); + do_hi (); + + if (memcmp (AI, test_qi, sizeof(test_qi))) + abort (); + if (memcmp (AL, test_hi, sizeof(test_hi))) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/sync-fetch-bool.c b/SingleSource/Regression/C/gcc-dg/sync-fetch-bool.c new file mode 100644 index 0000000000..1d156a970b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sync-fetch-bool.c @@ -0,0 +1,54 @@ +/* PR c/68966 - atomic_fetch_* on atomic_bool not diagnosed + Test to verify that calls to __sync_fetch_op funcions with a _Bool + argument are rejected. This is necessary because GCC expects that + all initialized _Bool objects have a specific representation and + allowing atomic operations to change it would break the invariant. */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors -std=c11" } */ + + +void test_sync_atomic_bool (_Atomic _Bool *a) +{ + __sync_fetch_and_add (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_add." } */ + __sync_fetch_and_sub (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_sub." } */ + __sync_fetch_and_and (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_and." } */ + __sync_fetch_and_xor (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_xor." } */ + __sync_fetch_and_or (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_or." } */ + __sync_fetch_and_nand (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_nand." } */ + + __sync_add_and_fetch (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_add_and_fetch." } */ + __sync_sub_and_fetch (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_sub_and_fetch." } */ + __sync_and_and_fetch (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_and_and_fetch." } */ + __sync_xor_and_fetch (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_xor_and_fetch." } */ + __sync_or_and_fetch (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_or_and_fetch." } */ + __sync_nand_and_fetch (a, 1); /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__sync_nand_and_fetch." } */ + + /* The following are valid and must be accepted. */ + __sync_bool_compare_and_swap (a, 0, 1); + __sync_val_compare_and_swap (a, 0, 1); + __sync_lock_test_and_set (a, 1); + __sync_lock_release (a); +} + +void test_sync_bool (_Bool *b) +{ + __sync_fetch_and_add (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_add." } */ + __sync_fetch_and_sub (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_sub." } */ + __sync_fetch_and_and (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_and." } */ + __sync_fetch_and_xor (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_xor." } */ + __sync_fetch_and_or (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_or." } */ + __sync_fetch_and_nand (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_fetch_and_nand." } */ + + __sync_add_and_fetch (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_add_and_fetch." } */ + __sync_sub_and_fetch (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_sub_and_fetch." } */ + __sync_and_and_fetch (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_and_and_fetch." } */ + __sync_xor_and_fetch (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_xor_and_fetch." } */ + __sync_or_and_fetch (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_or_and_fetch." } */ + __sync_nand_and_fetch (b, 1); /* { dg-error "operand type ._Bool \\*. is incompatible with argument 1 of .__sync_nand_and_fetch." } */ + + /* The following are valid and must be accepted. */ + __sync_bool_compare_and_swap (b, 0, 1); + __sync_val_compare_and_swap (b, 0, 1); + __sync_lock_test_and_set (b, 1); + __sync_lock_release (b); +} diff --git a/SingleSource/Regression/C/gcc-dg/sync-fetch.c b/SingleSource/Regression/C/gcc-dg/sync-fetch.c new file mode 100644 index 0000000000..44b6cdc2a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/sync-fetch.c @@ -0,0 +1,115 @@ +/* PR c/69405 - [6 Regression] ICE in c_tree_printer on an invalid + __atomic_fetch_add */ +/* Test to verify that the diagnostic doesn't cause an ICE when any + of the arguments to __atomic_fetch_OP is undeclared. */ +/* { dg-do compile } */ + +void test_add_undeclared_first_arg (void) +{ + int a = 0; + __atomic_fetch_add (&a, &b, 0); /* { dg-error ".b. undeclared" } */ +} + +void test_sub_undeclared_first_arg (void) +{ + int a = 0; + __atomic_fetch_sub (&a, &b, 0); /* { dg-error ".b. undeclared" } */ +} + +void test_or_undeclared_first_arg (void) +{ + int a = 0; + __atomic_fetch_or (&a, &b, 0); /* { dg-error ".b. undeclared" } */ +} + +void test_and_undeclared_first_arg (void) +{ + int a = 0; + __atomic_fetch_and (&a, &b, 0); /* { dg-error ".b. undeclared" } */ +} + +void test_xor_undeclared_first_arg (void) +{ + int a = 0; + __atomic_fetch_xor (&a, &b, 0); /* { dg-error ".b. undeclared" } */ +} + +void test_nand_undeclared_first_arg (void) +{ + int a = 0; + __atomic_fetch_nand (&a, &b, 0); /* { dg-error ".b. undeclared" } */ +} + + +void test_add_undeclared_second_arg (void) +{ + int b = 0; + __atomic_fetch_add (&a, &b, 0); /* { dg-error ".a. undeclared" } */ +} + +void test_sub_undeclared_second_arg (void) +{ + int b = 0; + __atomic_fetch_sub (&a, &b, 0); /* { dg-error ".a. undeclared" } */ +} + +void test_or_undeclared_second_arg (void) +{ + int b = 0; + __atomic_fetch_or (&a, &b, 0); /* { dg-error ".a. undeclared" } */ +} + +void test_and_undeclared_second_arg (void) +{ + int b = 0; + __atomic_fetch_and (&a, &b, 0); /* { dg-error ".a. undeclared" } */ +} + +void test_xor_undeclared_second_arg (void) +{ + int b = 0; + __atomic_fetch_xor (&a, &b, 0); /* { dg-error ".a. undeclared" } */ +} + +void test_nand_undeclared_second_arg (void) +{ + int b = 0; + __atomic_fetch_nand (&a, &b, 0); /* { dg-error ".a. undeclared" } */ +} + + +void test_add_undeclared_third_arg (void) +{ + int a = 0, b = 0; + __atomic_fetch_add (&a, &b, m); /* { dg-error ".m. undeclared" } */ +} + +void test_sub_undeclared_third_arg (void) +{ + int a = 0, b = 0; + __atomic_fetch_sub (&a, &b, m); /* { dg-error ".m. undeclared" } */ +} + +void test_or_undeclared_third_arg (void) +{ + int a = 0, b = 0; + __atomic_fetch_or (&a, &b, m); /* { dg-error ".m. undeclared" } */ +} + +void test_and_undeclared_third_arg (void) +{ + int a = 0, b = 0; + __atomic_fetch_and (&a, &b, m); /* { dg-error ".m. undeclared" } */ +} + +void test_xor_undeclared_third_arg (void) +{ + int a = 0, b = 0; + __atomic_fetch_xor (&a, &b, m); /* { dg-error ".m. undeclared" } */ +} + +void test_nand_undeclared_third_arg (void) +{ + int a = 0, b = 0; + __atomic_fetch_nand (&a, &b, m); /* { dg-error ".m. undeclared" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/system-binary-constants-1.c b/SingleSource/Regression/C/gcc-dg/system-binary-constants-1.c new file mode 100644 index 0000000000..ca162154fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/system-binary-constants-1.c @@ -0,0 +1,18 @@ +/* + Origin: Dodji Seketeli + { dg-options "-std=iso9899:1999 -pedantic" } + { dg-do compile } + */ + +#include "system-binary-constants-1.h" + +int +foo (void) +{ +#if BINARY_INT_CONSTANT_IN_SYSTEM_HEADER /* A binary constant defined + in system header. No + warning. */ + return 23; +#endif + return 0b1101; /* { dg-warning "binary constants are a C2X feature or GCC extension" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/system-binary-constants-1.h b/SingleSource/Regression/C/gcc-dg/system-binary-constants-1.h new file mode 100644 index 0000000000..85f291742f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/system-binary-constants-1.h @@ -0,0 +1,3 @@ +#pragma GCC system_header + +#define BINARY_INT_CONSTANT_IN_SYSTEM_HEADER 0b1101 diff --git a/SingleSource/Regression/C/gcc-dg/tail-merge-store.c b/SingleSource/Regression/C/gcc-dg/tail-merge-store.c new file mode 100644 index 0000000000..6f323a0e1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/tail-merge-store.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */ + +int z; +int x; + +void +f (int c, int d) +{ + if (c) + z = 5; + else + { + if (d) + x = 4; + z = 5; + } +} + +/* { dg-final { scan-tree-dump-times "duplicate of" 1 "pre"} } */ +/* { dg-final { scan-tree-dump-times "z = 5" 1 "pre"} } */ diff --git a/SingleSource/Regression/C/gcc-dg/tanhbysinh.c b/SingleSource/Regression/C/gcc-dg/tanhbysinh.c new file mode 100644 index 0000000000..9dbe133ec7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/tanhbysinh.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fdump-tree-optimized" } */ +/* { dg-require-effective-target c99_runtime } */ + +extern float sinhf (float); +extern float tanhf (float); +extern double sinh (double); +extern double tanh (double); +extern long double sinhl (long double); +extern long double tanhl (long double); + +double __attribute__ ((noinline)) +tanhbysinh_ (double x) +{ + return tanh (x) / sinh (x); +} + +float __attribute__ ((noinline)) +tanhbysinhf_ (float x) +{ + return tanhf (x) / sinhf (x); +} + +long double __attribute__ ((noinline)) +tanhbysinhl_ (long double x) +{ + return tanhl (x) / sinhl (x); +} + + +/* There must be no calls to sinh or atanh */ +/* There must be calls to cosh */ +/* {dg-final { scan-tree-dump-not "sinh " "optimized" } } */ +/* {dg-final { scan-tree-dump-not "tanh " "optimized" }} */ +/* {dg-final { scan-tree-dump-not "sinhf " "optimized" } } */ +/* {dg-final { scan-tree-dump-not "tanhf " "optimized" }} */ +/* {dg-final { scan-tree-dump-not "sinhl " "optimized" } } */ +/* {dg-final { scan-tree-dump-not "tanhl " "optimized" }} */ +/* { dg-final { scan-tree-dump "cosh " "optimized" } } */ +/* { dg-final { scan-tree-dump "coshf " "optimized" } } */ +/* { dg-final { scan-tree-dump "coshl " "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/tg-tests.h b/SingleSource/Regression/C/gcc-dg/tg-tests.h new file mode 100644 index 0000000000..0cf1f64525 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/tg-tests.h @@ -0,0 +1,166 @@ +/* Test various type-generic builtins by calling "main_tests()". */ + +#define FP_NAN 1 +#define FP_INFINITE 2 +#define FP_NORMAL 3 +#define FP_SUBNORMAL 4 +#define FP_ZERO 5 +#define fpclassify(X) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (X)) + +void __attribute__ ((__noinline__)) +foo_1 (float f, double d, long double ld, + int res_unord, int res_isnan, int res_isinf, + int res_isinf_sign, int res_isfin, int res_isnorm, + int res_signbit, int classification) +{ + if (__builtin_isunordered (f, 0) != res_unord) + __builtin_abort (); + if (__builtin_isunordered (0, f) != res_unord) + __builtin_abort (); + if (__builtin_isunordered (d, 0) != res_unord) + __builtin_abort (); + if (__builtin_isunordered (0, d) != res_unord) + __builtin_abort (); + if (__builtin_isunordered (ld, 0) != res_unord) + __builtin_abort (); + if (__builtin_isunordered (0, ld) != res_unord) + __builtin_abort (); + + if (__builtin_isnan (f) != res_isnan) + __builtin_abort (); + if (__builtin_isnan (d) != res_isnan) + __builtin_abort (); + if (__builtin_isnan (ld) != res_isnan) + __builtin_abort (); + if (__builtin_isnanf (f) != res_isnan) + __builtin_abort (); + if (__builtin_isnanl (ld) != res_isnan) + __builtin_abort (); + + if (__builtin_isinf (f) != res_isinf) + __builtin_abort (); + if (__builtin_isinf (d) != res_isinf) + __builtin_abort (); + if (__builtin_isinf (ld) != res_isinf) + __builtin_abort (); + if (__builtin_isinff (f) != res_isinf) + __builtin_abort (); + if (__builtin_isinfl (ld) != res_isinf) + __builtin_abort (); + + if (__builtin_isinf_sign (f) != res_isinf_sign) + __builtin_abort (); + if (__builtin_isinf_sign (d) != res_isinf_sign) + __builtin_abort (); + if (__builtin_isinf_sign (ld) != res_isinf_sign) + __builtin_abort (); + + if (__builtin_isnormal (f) != res_isnorm) + __builtin_abort (); + if (__builtin_isnormal (d) != res_isnorm) + __builtin_abort (); + if (__builtin_isnormal (ld) != res_isnorm) + __builtin_abort (); + + if (__builtin_isfinite (f) != res_isfin) + __builtin_abort (); + if (__builtin_isfinite (d) != res_isfin) + __builtin_abort (); + if (__builtin_isfinite (ld) != res_isfin) + __builtin_abort (); + + if (__builtin_finitef (f) != res_isfin) + __builtin_abort (); + if (__builtin_finite (f) != res_isfin) + __builtin_abort (); + if (__builtin_finite (d) != res_isfin) + __builtin_abort (); + if (__builtin_finitel (d) != res_isfin) + __builtin_abort (); + if (__builtin_finitel (ld) != res_isfin) + __builtin_abort (); + + /* Sign bit of zeros and nans is not preserved in unsafe math mode. */ +#ifdef UNSAFE + if (!res_isnan && f != 0 && d != 0 && ld != 0) +#endif + { + if ((__builtin_signbit (f) ? 1 : 0) != res_signbit) + __builtin_abort (); + if ((__builtin_signbit (d) ? 1 : 0) != res_signbit) + __builtin_abort (); + if ((__builtin_signbit (ld) ? 1 : 0) != res_signbit) + __builtin_abort (); + if ((__builtin_signbitf (f) ? 1 : 0) != res_signbit) + __builtin_abort (); + if ((__builtin_signbitl (ld) ? 1 : 0) != res_signbit) + __builtin_abort (); + } + + /* Subnormals can abruptly underflow to zero in unsafe math + mode, so bypass testing these numbers if necessary. */ +#ifdef UNSAFE + if (classification != FP_SUBNORMAL) +#endif + { + if (fpclassify(f) != classification) + __builtin_abort (); + if (fpclassify(d) != classification) + __builtin_abort (); + if (fpclassify(ld) != classification) + __builtin_abort (); + } +} + +void __attribute__ ((__noinline__)) +foo (float f, double d, long double ld, + int res_unord, int res_isnan, int res_isinf, + int res_isfin, int res_isnorm, int classification) +{ + foo_1 (f, d, ld, res_unord, res_isnan, res_isinf, res_isinf, res_isfin, res_isnorm, 0, classification); + /* Try all the values negated as well. All will have the sign bit set, + except for the nan. */ + foo_1 (-f, -d, -ld, res_unord, res_isnan, res_isinf, -res_isinf, res_isfin, res_isnorm, 1, classification); +} + +int __attribute__ ((__noinline__)) +main_tests (void) +{ + volatile float f; + volatile double d; + volatile long double ld; + + /* Test NaN. */ + f = __builtin_nanf(""); d = __builtin_nan(""); ld = __builtin_nanl(""); + foo(f, d, ld, /*unord=*/ 1, /*isnan=*/ 1, /*isinf=*/ 0, /*isfin=*/ 0, /*isnorm=*/ 0, FP_NAN); + + /* Test infinity. */ + f = __builtin_inff(); d = __builtin_inf(); ld = __builtin_infl(); + foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INFINITE); + + /* Test zero. */ + f = 0; d = 0; ld = 0; + foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 0, FP_ZERO); + + /* Test one. */ + f = 1; d = 1; ld = 1; + foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL); + + /* Test minimum values. */ + f = __FLT_MIN__; d = __DBL_MIN__; ld = __LDBL_MIN__; + foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL); + + /* Test subnormal values. */ + f = __FLT_MIN__/2; d = __DBL_MIN__/2; ld = __LDBL_MIN__/2; + foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 0, FP_SUBNORMAL); + + /* Test maximum values. */ + f = __FLT_MAX__; d = __DBL_MAX__; ld = __LDBL_MAX__; + foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL); + + /* Test overflow values. */ + f = __FLT_MAX__*2; d = __DBL_MAX__*2; ld = __LDBL_MAX__*2; + foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INFINITE); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/titype-1.c b/SingleSource/Regression/C/gcc-dg/titype-1.c new file mode 100644 index 0000000000..31c01a681a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/titype-1.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ + +/* Not all platforms support TImode integers. */ +#if (defined(__LP64__) && !defined(__hppa__)) || defined(_WIN64) +typedef int TItype __attribute__ ((mode (TI))); +#else +typedef long TItype; +#endif + +#include + +extern void abort(void); + + +void foo(int i, ...) +{ + TItype q; + va_list va; + + va_start(va, i); + q = va_arg(va, TItype); + va_end(va); + + if (q != 5) + abort(); +} + +int main(void) +{ + TItype q = 5; + + foo(1, q); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/trampoline-1.c b/SingleSource/Regression/C/gcc-dg/trampoline-1.c new file mode 100644 index 0000000000..e3dcf573a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/trampoline-1.c @@ -0,0 +1,52 @@ +/* PR target/12865 */ +/* Origin: Waldek Hebisch */ + +/* { dg-do run } */ +/* { dg-require-effective-target trampolines } */ +/* { dg-options "-O2" } */ + +/* This used to fail on various versions of Solaris 2 because the + trampoline couldn't be made executable. */ + +extern void abort(void); +extern double fabs(double); + +void foo (void) +{ + const int correct[1100] = {1, 0, -2, 0, 1, 0, 1, -1, -10, -30, -67}; + int i; + + double x1 (void) {return 1; } + double x2 (void) {return -1;} + double x3 (void) {return -1;} + double x4 (void) {return 1; } + double x5 (void) {return 0; } + + typedef double pfun(void); + + double a (int k, pfun x1, pfun x2, pfun x3, pfun x4, pfun x5) + { + double b (void) + { + k = k - 1; + return a (k, b, x1, x2, x3, x4 ); + } + + if (k <= 0) + return x4 () + x5 (); + else + return b (); + } + + for (i=0; i<=10; i++) + { + if (fabs(a( i, x1, x2, x3, x4, x5 ) - correct [i]) > 0.1) + abort(); + } +} + +int main (void) +{ + foo (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/transparent-union-1.c b/SingleSource/Regression/C/gcc-dg/transparent-union-1.c new file mode 100644 index 0000000000..3f0c260c90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/transparent-union-1.c @@ -0,0 +1,85 @@ +/* PR c/20043 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +extern void f0 (int *); +extern void f0 (int *__restrict); + +extern void f1 (int *__restrict); +extern void f1 (int *); + +typedef union { int *i; long *l; } U2 + __attribute__((transparent_union)); +extern void f2 (U2); +extern void f2 (int *); + +typedef union { int *__restrict i; long *__restrict l; } U3 + __attribute__((transparent_union)); +extern void f3 (U3); +extern void f3 (int *__restrict); + +extern void f4 (U3); +extern void f4 (int *); + +extern void f5 (U2); +extern void f5 (int *__restrict); + +typedef union { long *l; int *i; } U6 + __attribute__((transparent_union)); +extern void f6 (U6); +extern void f6 (int *); + +typedef union { long *__restrict l; int *__restrict i; } U7 + __attribute__((transparent_union)); +extern void f7 (U7); +extern void f7 (int *__restrict); + +extern void f8 (U7); +extern void f8 (int *); + +extern void f9 (U6); +extern void f9 (int *__restrict); + +extern void f10 (U2); +extern void f11 (U3); +extern void f12 (U6); +extern void f13 (U7); + +int i; +long l; + +int +main (void) +{ + f0 (&i); + f0 (&l); /* { dg-warning "passing argument 1 of 'f0' from incompatible pointer type" } */ + f1 (&i); + f1 (&l); /* { dg-warning "passing argument 1 of 'f1' from incompatible pointer type" } */ + f2 (&i); + f2 (&l); /* { dg-warning "passing argument 1 of 'f2' from incompatible pointer type" } */ + f3 (&i); + f3 (&l); /* { dg-warning "passing argument 1 of 'f3' from incompatible pointer type" } */ + f4 (&i); + f4 (&l); /* { dg-warning "passing argument 1 of 'f4' from incompatible pointer type" } */ + f5 (&i); + f5 (&l); /* { dg-warning "passing argument 1 of 'f5' from incompatible pointer type" } */ + f6 (&i); + f6 (&l); /* { dg-warning "passing argument 1 of 'f6' from incompatible pointer type" } */ + f7 (&i); + f7 (&l); /* { dg-warning "passing argument 1 of 'f7' from incompatible pointer type" } */ + f8 (&i); + f8 (&l); /* { dg-warning "passing argument 1 of 'f8' from incompatible pointer type" } */ + f9 (&i); + f9 (&l); /* { dg-warning "passing argument 1 of 'f9' from incompatible pointer type" } */ + f10 (&i); + f10 (&l); + f11 (&i); + f11 (&l); + f12 (&i); + f12 (&l); + f13 (&i); + f13 (&l); + return 0; +} + +/* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/transparent-union-2.c b/SingleSource/Regression/C/gcc-dg/transparent-union-2.c new file mode 100644 index 0000000000..adc2076179 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/transparent-union-2.c @@ -0,0 +1,18 @@ +/* PR c/20043 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +typedef union { int *i; long *l; } U + __attribute__((transparent_union)); + +extern void f0 (U); /* { dg-message "note: previous declaration" } */ +extern void f0 (void *); /* { dg-error "conflicting types" } */ + +extern void f1 (U); /* { dg-message "note: previous declaration" } */ +extern void f1 (unsigned long); /* { dg-error "conflicting types" } */ + +extern void f2 (void *); /* { dg-message "note: previous declaration" } */ +extern void f2 (U); /* { dg-error "conflicting types" } */ + +extern void f3 (unsigned long); /* { dg-message "note: previous declaration" } */ +extern void f3 (U); /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/transparent-union-3.c b/SingleSource/Regression/C/gcc-dg/transparent-union-3.c new file mode 100644 index 0000000000..7f0dda54fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/transparent-union-3.c @@ -0,0 +1,22 @@ +/* Test for ICEs on invalid transparent unions (empty or no named + members). Bug 21213. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum e { A }; + +union __attribute__((__transparent_union__)) ue1 { enum e; }; /* { dg-warning "declaration does not declare anything" "not anything" } */ +/* { dg-warning "union cannot be made transparent" "cannot" { target *-*-* } .-1 } */ +union ue2 { enum e; } __attribute__((__transparent_union__)); /* { dg-warning "declaration does not declare anything" "not anything" } */ +/* { dg-warning "union cannot be made transparent" "cannot" { target *-*-* } .-1 } */ + +union __attribute__((__transparent_union__)) ui1 { int; }; /* { dg-warning "declaration does not declare anything" "not anything" } */ +/* { dg-warning "union cannot be made transparent" "cannot" { target *-*-* } .-1 } */ +union ui2 { int; } __attribute__((__transparent_union__)); /* { dg-warning "declaration does not declare anything" "no anything" } */ +/* { dg-warning "union cannot be made transparent" "cannot" { target *-*-* } .-1 } */ + +union __attribute__((__transparent_union__)) u1 { }; +/* { dg-warning "union cannot be made transparent" "" { target *-*-* } .-1 } */ +union u2 { } __attribute__((__transparent_union__)); +/* { dg-warning "union cannot be made transparent" "" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/transparent-union-4.c b/SingleSource/Regression/C/gcc-dg/transparent-union-4.c new file mode 100644 index 0000000000..f661cf2cb5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/transparent-union-4.c @@ -0,0 +1,9 @@ +/* Test for ICE on transparent union with function pointer and + -pedantic. Bug 22240. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +typedef union { union w *u; int *i; } H __attribute__ ((transparent_union)); +void (*h) (H); +void g (int *s) { h (s); } /* { dg-warning "ISO C prohibits argument conversion to union type" } */ diff --git a/SingleSource/Regression/C/gcc-dg/transparent-union-5.c b/SingleSource/Regression/C/gcc-dg/transparent-union-5.c new file mode 100644 index 0000000000..47e245e247 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/transparent-union-5.c @@ -0,0 +1,37 @@ +/* PR 24255 */ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +extern void abort (void); + +union wait { int w_status; }; + +typedef union +{ + union wait *uptr; + int *iptr; +} WAIT_STATUS __attribute__ ((__transparent_union__)); + +int status; +union wait wstatus; + +void __attribute__((noinline)) +test1 (WAIT_STATUS s) +{ + if (s.iptr != &status) + abort (); +} + +void __attribute__((noinline)) +test2 (WAIT_STATUS s) +{ + if (s.uptr != &wstatus) + abort (); +} + +int main() +{ + test1 (&status); + test2 (&wstatus); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/transparent-union-6.c b/SingleSource/Regression/C/gcc-dg/transparent-union-6.c new file mode 100644 index 0000000000..dcad69b278 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/transparent-union-6.c @@ -0,0 +1,17 @@ +/* PR c/54391 - transparent_union typedef'ing inconsistent + { dg-do compile } + { dg-options "-Wall" } */ + +typedef union m30_u m30_t; + +union __attribute__((transparent_union)) m30_u { + int u; +}; + +double make_double (m30_t); + +double f (void) +{ + int bar = 17; + return make_double (bar); +} diff --git a/SingleSource/Regression/C/gcc-dg/trunc-1.c b/SingleSource/Regression/C/gcc-dg/trunc-1.c new file mode 100644 index 0000000000..a78cceb598 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/trunc-1.c @@ -0,0 +1,15 @@ +/* Origin: PR c/675 from aj@suse.de. */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +#include + +int +main (void) +{ + size_t len; + + len = ~(sizeof (size_t) - 1); /* { dg-bogus "truncated" "bogus truncation warning" } */ + + return len - len; +} diff --git a/SingleSource/Regression/C/gcc-dg/two-types-1.c b/SingleSource/Regression/C/gcc-dg/two-types-1.c new file mode 100644 index 0000000000..43d236b911 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-1.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +typedef int x, y; +x y z; /* { dg-error "" } */ diff --git a/SingleSource/Regression/C/gcc-dg/two-types-10.c b/SingleSource/Regression/C/gcc-dg/two-types-10.c new file mode 100644 index 0000000000..6c2b79bd52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-10.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +typedef enum a { XYZ } a; /* { dg-message "previous declaration" } */ +enum a a; /* { dg-error "redeclared" } */ +struct b { enum a a : 8; }; diff --git a/SingleSource/Regression/C/gcc-dg/two-types-2.c b/SingleSource/Regression/C/gcc-dg/two-types-2.c new file mode 100644 index 0000000000..0fffae53fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-2.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +typedef int x, y; +x struct f z; /* { dg-error "two or more " } */ diff --git a/SingleSource/Regression/C/gcc-dg/two-types-3.c b/SingleSource/Regression/C/gcc-dg/two-types-3.c new file mode 100644 index 0000000000..233f9da5be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-3.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +struct f { +} +int z(); /* { dg-error "expected ';', identifier or " "" { target *-*-* } } */ diff --git a/SingleSource/Regression/C/gcc-dg/two-types-4.c b/SingleSource/Regression/C/gcc-dg/two-types-4.c new file mode 100644 index 0000000000..5ffb153717 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-4.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +int f() +{ + struct f { + } + int z; /* { dg-error "expected ';', identifier or " } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/two-types-5.c b/SingleSource/Regression/C/gcc-dg/two-types-5.c new file mode 100644 index 0000000000..9b5ca8f64d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-5.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +struct f {} +struct g {} /* { dg-error "expected ';', identifier or " } */ +int f(); /* { dg-error "expected ';', identifier or " } */ diff --git a/SingleSource/Regression/C/gcc-dg/two-types-6.c b/SingleSource/Regression/C/gcc-dg/two-types-6.c new file mode 100644 index 0000000000..a0a79316f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-6.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +struct s { + struct f {} + struct g {} x; /* { dg-error "expected ';', identifier or " } */ +}; diff --git a/SingleSource/Regression/C/gcc-dg/two-types-7.c b/SingleSource/Regression/C/gcc-dg/two-types-7.c new file mode 100644 index 0000000000..f7a28d9c20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-7.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +struct s { + struct f {} + enum a { X } /* { dg-error "expected ';', identifier or " } */ + struct g {} /* { dg-error "expected identifier " } */ +}; /* { dg-warning "no semicolon" } */ diff --git a/SingleSource/Regression/C/gcc-dg/two-types-8.c b/SingleSource/Regression/C/gcc-dg/two-types-8.c new file mode 100644 index 0000000000..666b9a9c62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-8.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +enum x { XYZ } +struct g { enum x a; }; /* { dg-error "expected ';', identifier or " } */ + +int f(struct g *x) +{ + return x->a == XYZ; /* { dg-bogus " has no member " } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/two-types-9.c b/SingleSource/Regression/C/gcc-dg/two-types-9.c new file mode 100644 index 0000000000..0234c55b01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/two-types-9.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +struct f {} +static int a, b; /* { dg-error "expected ';', identifier or " } */ + +int f() +{ + return a - b; /* { dg-bogus "invalid operands " } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/type-convert-var.c b/SingleSource/Regression/C/gcc-dg/type-convert-var.c new file mode 100644 index 0000000000..f7b191ce2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/type-convert-var.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fexcess-precision=fast -O1 -fdump-tree-optimized" } */ +void foo (float a, float b, float *c) +{ + double e = (double)a * (double)b; + *c = (float)e; +} + +/* { dg-final { scan-tree-dump-not {double} "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/typedef-init.c b/SingleSource/Regression/C/gcc-dg/typedef-init.c new file mode 100644 index 0000000000..52928da9a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typedef-init.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } // suppress default -pedantic-errors */ + +/* This code used to be a legitimate, if dubious, extension. However, + it's been broken since GCC 3.0 (caused ICE) and we have now removed + the extension. See PR c/7353. */ + +/* Case A: just the bare name = initializer. */ + +typedef A = 0; /* { dg-error "initialized" "A" } */ +A a; /* { dg-bogus "" "A error cascade" } */ + +/* Case B: with a type also. */ + +typedef int B = 0; /* { dg-error "initialized" "B" } */ +B b; /* { dg-bogus "" "B error cascade" } */ diff --git a/SingleSource/Regression/C/gcc-dg/typedef-redecl.c b/SingleSource/Regression/C/gcc-dg/typedef-redecl.c new file mode 100644 index 0000000000..8ac5282fb7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typedef-redecl.c @@ -0,0 +1,6 @@ +/* Redeclaration of typedef (invalid but accepted in system headers) + causes ICE; PR 13656. Test case by Richard Sandiford , + reduced from glibc. */ + +#include "typedef-redecl.h" +x a; diff --git a/SingleSource/Regression/C/gcc-dg/typedef-redecl.h b/SingleSource/Regression/C/gcc-dg/typedef-redecl.h new file mode 100644 index 0000000000..9fa7da05db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typedef-redecl.h @@ -0,0 +1,7 @@ +/* Redeclaration of typedef (invalid but accepted in system headers) + causes ICE; PR 13656. Test case by Richard Sandiford , + reduced from glibc. */ + +#pragma GCC system_header +typedef int x; +typedef int x; diff --git a/SingleSource/Regression/C/gcc-dg/typedef-redecl2.c b/SingleSource/Regression/C/gcc-dg/typedef-redecl2.c new file mode 100644 index 0000000000..c2314c78ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typedef-redecl2.c @@ -0,0 +1,13 @@ +/* PR c/70297 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#define N 64 + +typedef int T; +typedef int T __attribute__((aligned (N))); +typedef int T __attribute__((aligned (N * 2))); +typedef int T __attribute__((aligned (N))); +typedef int T; + +_Static_assert (_Alignof (T) == N * 2, "N * 2"); diff --git a/SingleSource/Regression/C/gcc-dg/typedef-var-1.c b/SingleSource/Regression/C/gcc-dg/typedef-var-1.c new file mode 100644 index 0000000000..2cda92d3d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typedef-var-1.c @@ -0,0 +1,14 @@ +/* PR c/91815 */ +/* { dg-do compile } */ + +int f (void) +{ + extern int t; + extern float v; + + return (v > 0.0f); +} + +typedef float t; + +t v = 4.5f; diff --git a/SingleSource/Regression/C/gcc-dg/typedef-var-2.c b/SingleSource/Regression/C/gcc-dg/typedef-var-2.c new file mode 100644 index 0000000000..bc119a0558 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typedef-var-2.c @@ -0,0 +1,16 @@ +/* PR c/91815 */ +/* { dg-do compile } */ + +int f (void) +{ + extern float v; +/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */ + return (v > 0.0f); +} + +extern int t; +/* { dg-message "note: previous declaration" "previous declaration" { target *-*-* } .-1 } */ + +typedef float t; /* { dg-error "redeclared as different kind of symbol" } */ + +t v = 4.5f; /* { dg-error "conflicting types" } */ diff --git a/SingleSource/Regression/C/gcc-dg/typename-vla-1.c b/SingleSource/Regression/C/gcc-dg/typename-vla-1.c new file mode 100644 index 0000000000..1616513128 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typename-vla-1.c @@ -0,0 +1,17 @@ +/* PR c/21536 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + int a = 1; + if (sizeof (*(++a, (char (*)[a])0)) != 2) + abort (); + exit (0); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/typename-vla-2.c b/SingleSource/Regression/C/gcc-dg/typename-vla-2.c new file mode 100644 index 0000000000..24d3db8f58 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typename-vla-2.c @@ -0,0 +1,19 @@ +/* { dg-do run } + * { dg-options "-std=c99" } + * */ + + +static char tmp[2]; + +static int f(int n, char (*x)[sizeof (*(++n, (char (*)[n])&tmp))]) +{ + return sizeof *x; +} + +int main (void) +{ + if (2 != f(1, &tmp)) + __builtin_abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/typename-vla-3.c b/SingleSource/Regression/C/gcc-dg/typename-vla-3.c new file mode 100644 index 0000000000..2bd683e1b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typename-vla-3.c @@ -0,0 +1,18 @@ +/* { dg-do run } + * { dg-options "-std=c99" } + * */ + +static char tmp[2]; + +static int f(int n, char (*x)[sizeof *(++n, (struct { char (*x)[n]; }){ &tmp }).x]) /* { dg-warning "anonymous struct" } */ +{ + return sizeof *x; +} + +int main (void) +{ + if (2 != f(1, &tmp)) + __builtin_abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/typename-vla-4.c b/SingleSource/Regression/C/gcc-dg/typename-vla-4.c new file mode 100644 index 0000000000..a05c782b55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typename-vla-4.c @@ -0,0 +1,23 @@ +/* { dg-do run } + * { dg-options "-std=gnu99" } + * */ + +int main() +{ + int n = 1; + sizeof(int[n++]); + typeof(int[n++]); /* { dg-warning "empty declaration" } */ + struct { int x[n++]; }; /* { dg-warning "no instance" } */ + struct foo { int x[n++]; }; + struct { int x[n++]; } x; + struct bar { int x[n++]; } y; + (int(*)[n++])0; + (typeof(int(*)[n++]))0; + (struct { int x[n++]; }*)0; + (struct q { int x[n++]; }*)0; + typeof(struct { int x[n++]; }); /* { dg-warning "empty declaration" } */ + typeof(struct r { int x[n++]; }); /* { dg-warning "empty declaration" } */ + + if (13 != n) + __builtin_abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/typename-vla-5.c b/SingleSource/Regression/C/gcc-dg/typename-vla-5.c new file mode 100644 index 0000000000..4644d25df1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typename-vla-5.c @@ -0,0 +1,14 @@ +/* { dg-do run } + * { dg-options "-std=gnu99" } + * */ + +int +main (void) +{ + int a = 1; + char tmp[2]; + if (sizeof (*(++a, (struct { char (*x)[a]; }){ &tmp }).x) != 2) + __builtin_abort (); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/typename-vla-6.c b/SingleSource/Regression/C/gcc-dg/typename-vla-6.c new file mode 100644 index 0000000000..58831df549 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typename-vla-6.c @@ -0,0 +1,16 @@ +/* { dg-do run } + * { dg-options "-std=gnu99" } + * */ + + + +int +main (void) +{ + int a = 1; + char tmp[2]; + if ((++a, sizeof(*((struct { char (*x)[a]; }){ &tmp }).x)) != 2) + __builtin_abort (); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/typeof-1.c b/SingleSource/Regression/C/gcc-dg/typeof-1.c new file mode 100644 index 0000000000..233b39425b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typeof-1.c @@ -0,0 +1,27 @@ +/* Test typeof with __asm redirection. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int foo1; +extern int foo1 __asm ("bar1"); +int foo1 = 1; + +extern int foo2 (int); +extern int foo2 (int) __asm ("bar2"); +int foo2 (int x) +{ + return x; +} + +extern int foo3; +extern __typeof (foo3) foo3 __asm ("bar3"); +int foo3 = 1; + +extern int foo4 (int); +extern __typeof (foo4) foo4 __asm ("bar4"); +int foo4 (int x) +{ + return x; +} + +// { dg-final { scan-assembler-not "foo" } } diff --git a/SingleSource/Regression/C/gcc-dg/typeof-2.c b/SingleSource/Regression/C/gcc-dg/typeof-2.c new file mode 100644 index 0000000000..68f91c6c36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typeof-2.c @@ -0,0 +1,63 @@ +/* Test qualifier preservation of typeof and discarded for __auto_type. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +/* Check that the qualifiers are preserved for atomic types. */ + +extern int i; + +extern int * p; + +extern int _Atomic const ci; +extern __typeof (ci) ci; + +extern int _Atomic volatile vi; +extern __typeof (vi) vi; + +extern int * _Atomic restrict ri; +extern __typeof (ri) ri; + +/* Check that the qualifiers are discarded for atomic types. */ + +void f(void) +{ + __auto_type aci = ci; + int *paci = &aci; + + __auto_type avi = vi; + int *pavi = &avi; + + __auto_type ari = ri; + int **pari = &ari; +} + +/* Check that the qualifiers are preserved for non-atomic types. */ + +extern int const j; + +extern int volatile k; + +extern int * restrict q; + +extern int const nci; +extern __typeof (nci) j; + +extern int volatile nvi; +extern __typeof (nvi) k; + +extern int * restrict nri; +extern __typeof (nri) q; + +/* Check that the qualifiers are discarded for non-atomic types. */ + +void g(void) +{ + __auto_type aci = nci; + int *paci = &aci; + + __auto_type avi = nvi; + int *pavi = &avi; + + __auto_type ari = nri; + int **pari = &ari; +} diff --git a/SingleSource/Regression/C/gcc-dg/typespec-1.c b/SingleSource/Regression/C/gcc-dg/typespec-1.c new file mode 100644 index 0000000000..65736546bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/typespec-1.c @@ -0,0 +1,937 @@ +/* Test for valid and invalid combinations of type specifiers. + This test covers combinations of the reserved word type specifiers + other than _Complex and _Imaginary, and a typedef name as the first + specifier only. Within those constraints, there are no GCC extensions + and what is accepted should be exactly what C99 permits. All + sequences are tested which do not have a shorter invalid initial + subsequence. Within the given constraints, there are no valid sequences + with an invalid initial subsequence. + + In particular, the example of PR c/4319 should be rejected unconditionally, + not requiring -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +typedef char type; +void *x0; +char *x1; +short *x2; +int *x3; +long *x4; +float *x5; +double *x6; +signed *x7; +unsigned *x8; +_Bool *x9; +type *x10; +void void *x11; /* { dg-error "" "void void" } */ +void char *x12; /* { dg-error "" "void char" } */ +void short *x13; /* { dg-error "" "void short" } */ +void int *x14; /* { dg-error "" "void int" } */ +void long *x15; /* { dg-error "" "void long" } */ +void float *x16; /* { dg-error "" "void float" } */ +void double *x17; /* { dg-error "" "void double" } */ +void signed *x18; /* { dg-error "" "void signed" } */ +void unsigned *x19; /* { dg-error "" "void unsigned" } */ +void _Bool *x20; /* { dg-error "" "void _Bool" } */ +char void *x21; /* { dg-error "" "char void" } */ +char char *x22; /* { dg-error "" "char char" } */ +char short *x23; /* { dg-error "" "char short" } */ +char int *x24; /* { dg-error "" "char int" } */ +char long *x25; /* { dg-error "" "char long" } */ +char float *x26; /* { dg-error "" "char float" } */ +char double *x27; /* { dg-error "" "char double" } */ +char signed *x28; +char unsigned *x29; +char _Bool *x30; /* { dg-error "" "char _Bool" } */ +short void *x31; /* { dg-error "" "short void" } */ +short char *x32; /* { dg-error "" "short char" } */ +short short *x33; /* { dg-error "" "short short" } */ +short int *x34; +short long *x35; /* { dg-error "" "short long" } */ +short float *x36; /* { dg-error "" "short float" } */ +short double *x37; /* { dg-error "" "short double" } */ +short signed *x38; +short unsigned *x39; +short _Bool *x40; /* { dg-error "" "short _Bool" } */ +int void *x41; /* { dg-error "" "int void" } */ +int char *x42; /* { dg-error "" "int char" } */ +int short *x43; +int int *x44; /* { dg-error "" "int int" } */ +int long *x45; +int float *x46; /* { dg-error "" "int float" } */ +int double *x47; /* { dg-error "" "int double" } */ +int signed *x48; +int unsigned *x49; +int _Bool *x50; /* { dg-error "" "int _Bool" } */ +long void *x51; /* { dg-error "" "long void" } */ +long char *x52; /* { dg-error "" "long char" } */ +long short *x53; /* { dg-error "" "long short" } */ +long int *x54; +long long *x55; +long float *x56; /* { dg-error "" "long float" } */ +long double *x57; +long signed *x58; +long unsigned *x59; +long _Bool *x60; /* { dg-error "" "long _Bool" } */ +float void *x61; /* { dg-error "" "float void" } */ +float char *x62; /* { dg-error "" "float char" } */ +float short *x63; /* { dg-error "" "float short" } */ +float int *x64; /* { dg-error "" "float int" } */ +float long *x65; /* { dg-error "" "float long" } */ +float float *x66; /* { dg-error "" "float float" } */ +float double *x67; /* { dg-error "" "float double" } */ +float signed *x68; /* { dg-error "" "float signed" } */ +float unsigned *x69; /* { dg-error "" "float unsigned" } */ +float _Bool *x70; /* { dg-error "" "float _Bool" } */ +double void *x71; /* { dg-error "" "double void" } */ +double char *x72; /* { dg-error "" "double char" } */ +double short *x73; /* { dg-error "" "double short" } */ +double int *x74; /* { dg-error "" "double int" } */ +double long *x75; +double float *x76; /* { dg-error "" "double float" } */ +double double *x77; /* { dg-error "" "double double" } */ +double signed *x78; /* { dg-error "" "double signed" } */ +double unsigned *x79; /* { dg-error "" "double unsigned" } */ +double _Bool *x80; /* { dg-error "" "double _Bool" } */ +signed void *x81; /* { dg-error "" "signed void" } */ +signed char *x82; +signed short *x83; +signed int *x84; +signed long *x85; +signed float *x86; /* { dg-error "" "signed float" } */ +signed double *x87; /* { dg-error "" "signed double" } */ +signed signed *x88; /* { dg-error "" "signed signed" } */ +signed unsigned *x89; /* { dg-error "" "signed unsigned" } */ +signed _Bool *x90; /* { dg-error "" "signed _Bool" } */ +unsigned void *x91; /* { dg-error "" "unsigned void" } */ +unsigned char *x92; +unsigned short *x93; +unsigned int *x94; +unsigned long *x95; +unsigned float *x96; /* { dg-error "" "unsigned float" } */ +unsigned double *x97; /* { dg-error "" "unsigned double" } */ +unsigned signed *x98; /* { dg-error "" "unsigned signed" } */ +unsigned unsigned *x99; /* { dg-error "" "unsigned unsigned" } */ +unsigned _Bool *x100; /* { dg-error "" "unsigned _Bool" } */ +_Bool void *x101; /* { dg-error "" "_Bool void" } */ +_Bool char *x102; /* { dg-error "" "_Bool char" } */ +_Bool short *x103; /* { dg-error "" "_Bool short" } */ +_Bool int *x104; /* { dg-error "" "_Bool int" } */ +_Bool long *x105; /* { dg-error "" "_Bool long" } */ +_Bool float *x106; /* { dg-error "" "_Bool float" } */ +_Bool double *x107; /* { dg-error "" "_Bool double" } */ +_Bool signed *x108; /* { dg-error "" "_Bool signed" } */ +_Bool unsigned *x109; /* { dg-error "" "_Bool unsigned" } */ +_Bool _Bool *x110; /* { dg-error "" "_Bool _Bool" } */ +type void *x111; /* { dg-error "" "type void" } */ +type char *x112; /* { dg-error "" "type char" } */ +type short *x113; /* { dg-error "" "type short" } */ +type int *x114; /* { dg-error "" "type int" } */ +type long *x115; /* { dg-error "" "type long" } */ +type float *x116; /* { dg-error "" "type float" } */ +type double *x117; /* { dg-error "" "type double" } */ +type signed *x118; /* { dg-error "" "type signed" } */ +type unsigned *x119; /* { dg-error "" "type unsigned" } */ +type _Bool *x120; /* { dg-error "" "type _Bool" } */ +char signed void *x121; /* { dg-error "" "char signed void" } */ +char signed char *x122; /* { dg-error "" "char signed char" } */ +char signed short *x123; /* { dg-error "" "char signed short" } */ +char signed int *x124; /* { dg-error "" "char signed int" } */ +char signed long *x125; /* { dg-error "" "char signed long" } */ +char signed float *x126; /* { dg-error "" "char signed float" } */ +char signed double *x127; /* { dg-error "" "char signed double" } */ +char signed signed *x128; /* { dg-error "" "char signed signed" } */ +char signed unsigned *x129; /* { dg-error "" "char signed unsigned" } */ +char signed _Bool *x130; /* { dg-error "" "char signed _Bool" } */ +char unsigned void *x131; /* { dg-error "" "char unsigned void" } */ +char unsigned char *x132; /* { dg-error "" "char unsigned char" } */ +char unsigned short *x133; /* { dg-error "" "char unsigned short" } */ +char unsigned int *x134; /* { dg-error "" "char unsigned int" } */ +char unsigned long *x135; /* { dg-error "" "char unsigned long" } */ +char unsigned float *x136; /* { dg-error "" "char unsigned float" } */ +char unsigned double *x137; /* { dg-error "" "char unsigned double" } */ +char unsigned signed *x138; /* { dg-error "" "char unsigned signed" } */ +char unsigned unsigned *x139; /* { dg-error "" "char unsigned unsigned" } */ +char unsigned _Bool *x140; /* { dg-error "" "char unsigned _Bool" } */ +short int void *x141; /* { dg-error "" "short int void" } */ +short int char *x142; /* { dg-error "" "short int char" } */ +short int short *x143; /* { dg-error "" "short int short" } */ +short int int *x144; /* { dg-error "" "short int int" } */ +short int long *x145; /* { dg-error "" "short int long" } */ +short int float *x146; /* { dg-error "" "short int float" } */ +short int double *x147; /* { dg-error "" "short int double" } */ +short int signed *x148; +short int unsigned *x149; +short int _Bool *x150; /* { dg-error "" "short int _Bool" } */ +short signed void *x151; /* { dg-error "" "short signed void" } */ +short signed char *x152; /* { dg-error "" "short signed char" } */ +short signed short *x153; /* { dg-error "" "short signed short" } */ +short signed int *x154; +short signed long *x155; /* { dg-error "" "short signed long" } */ +short signed float *x156; /* { dg-error "" "short signed float" } */ +short signed double *x157; /* { dg-error "" "short signed double" } */ +short signed signed *x158; /* { dg-error "" "short signed signed" } */ +short signed unsigned *x159; /* { dg-error "" "short signed unsigned" } */ +short signed _Bool *x160; /* { dg-error "" "short signed _Bool" } */ +short unsigned void *x161; /* { dg-error "" "short unsigned void" } */ +short unsigned char *x162; /* { dg-error "" "short unsigned char" } */ +short unsigned short *x163; /* { dg-error "" "short unsigned short" } */ +short unsigned int *x164; +short unsigned long *x165; /* { dg-error "" "short unsigned long" } */ +short unsigned float *x166; /* { dg-error "" "short unsigned float" } */ +short unsigned double *x167; /* { dg-error "" "short unsigned double" } */ +short unsigned signed *x168; /* { dg-error "" "short unsigned signed" } */ +short unsigned unsigned *x169; /* { dg-error "" "short unsigned unsigned" } */ +short unsigned _Bool *x170; /* { dg-error "" "short unsigned _Bool" } */ +int short void *x171; /* { dg-error "" "int short void" } */ +int short char *x172; /* { dg-error "" "int short char" } */ +int short short *x173; /* { dg-error "" "int short short" } */ +int short int *x174; /* { dg-error "" "int short int" } */ +int short long *x175; /* { dg-error "" "int short long" } */ +int short float *x176; /* { dg-error "" "int short float" } */ +int short double *x177; /* { dg-error "" "int short double" } */ +int short signed *x178; +int short unsigned *x179; +int short _Bool *x180; /* { dg-error "" "int short _Bool" } */ +int long void *x181; /* { dg-error "" "int long void" } */ +int long char *x182; /* { dg-error "" "int long char" } */ +int long short *x183; /* { dg-error "" "int long short" } */ +int long int *x184; /* { dg-error "" "int long int" } */ +int long long *x185; +int long float *x186; /* { dg-error "" "int long float" } */ +int long double *x187; /* { dg-error "" "int long double" } */ +int long signed *x188; +int long unsigned *x189; +int long _Bool *x190; /* { dg-error "" "int long _Bool" } */ +int signed void *x191; /* { dg-error "" "int signed void" } */ +int signed char *x192; /* { dg-error "" "int signed char" } */ +int signed short *x193; +int signed int *x194; /* { dg-error "" "int signed int" } */ +int signed long *x195; +int signed float *x196; /* { dg-error "" "int signed float" } */ +int signed double *x197; /* { dg-error "" "int signed double" } */ +int signed signed *x198; /* { dg-error "" "int signed signed" } */ +int signed unsigned *x199; /* { dg-error "" "int signed unsigned" } */ +int signed _Bool *x200; /* { dg-error "" "int signed _Bool" } */ +int unsigned void *x201; /* { dg-error "" "int unsigned void" } */ +int unsigned char *x202; /* { dg-error "" "int unsigned char" } */ +int unsigned short *x203; +int unsigned int *x204; /* { dg-error "" "int unsigned int" } */ +int unsigned long *x205; +int unsigned float *x206; /* { dg-error "" "int unsigned float" } */ +int unsigned double *x207; /* { dg-error "" "int unsigned double" } */ +int unsigned signed *x208; /* { dg-error "" "int unsigned signed" } */ +int unsigned unsigned *x209; /* { dg-error "" "int unsigned unsigned" } */ +int unsigned _Bool *x210; /* { dg-error "" "int unsigned _Bool" } */ +long int void *x211; /* { dg-error "" "long int void" } */ +long int char *x212; /* { dg-error "" "long int char" } */ +long int short *x213; /* { dg-error "" "long int short" } */ +long int int *x214; /* { dg-error "" "long int int" } */ +long int long *x215; +long int float *x216; /* { dg-error "" "long int float" } */ +long int double *x217; /* { dg-error "" "long int double" } */ +long int signed *x218; +long int unsigned *x219; +long int _Bool *x220; /* { dg-error "" "long int _Bool" } */ +long long void *x221; /* { dg-error "" "long long void" } */ +long long char *x222; /* { dg-error "" "long long char" } */ +long long short *x223; /* { dg-error "" "long long short" } */ +long long int *x224; +long long long *x225; /* { dg-error "" "long long long" } */ +long long float *x226; /* { dg-error "" "long long float" } */ +long long double *x227; /* { dg-error "" "long long double" } */ +long long signed *x228; +long long unsigned *x229; +long long _Bool *x230; /* { dg-error "" "long long _Bool" } */ +long double void *x231; /* { dg-error "" "long double void" } */ +long double char *x232; /* { dg-error "" "long double char" } */ +long double short *x233; /* { dg-error "" "long double short" } */ +long double int *x234; /* { dg-error "" "long double int" } */ +long double long *x235; /* { dg-error "" "long double long" } */ +long double float *x236; /* { dg-error "" "long double float" } */ +long double double *x237; /* { dg-error "" "long double double" } */ +long double signed *x238; /* { dg-error "" "long double signed" } */ +long double unsigned *x239; /* { dg-error "" "long double unsigned" } */ +long double _Bool *x240; /* { dg-error "" "long double _Bool" } */ +long signed void *x241; /* { dg-error "" "long signed void" } */ +long signed char *x242; /* { dg-error "" "long signed char" } */ +long signed short *x243; /* { dg-error "" "long signed short" } */ +long signed int *x244; +long signed long *x245; +long signed float *x246; /* { dg-error "" "long signed float" } */ +long signed double *x247; /* { dg-error "" "long signed double" } */ +long signed signed *x248; /* { dg-error "" "long signed signed" } */ +long signed unsigned *x249; /* { dg-error "" "long signed unsigned" } */ +long signed _Bool *x250; /* { dg-error "" "long signed _Bool" } */ +long unsigned void *x251; /* { dg-error "" "long unsigned void" } */ +long unsigned char *x252; /* { dg-error "" "long unsigned char" } */ +long unsigned short *x253; /* { dg-error "" "long unsigned short" } */ +long unsigned int *x254; +long unsigned long *x255; +long unsigned float *x256; /* { dg-error "" "long unsigned float" } */ +long unsigned double *x257; /* { dg-error "" "long unsigned double" } */ +long unsigned signed *x258; /* { dg-error "" "long unsigned signed" } */ +long unsigned unsigned *x259; /* { dg-error "" "long unsigned unsigned" } */ +long unsigned _Bool *x260; /* { dg-error "" "long unsigned _Bool" } */ +double long void *x261; /* { dg-error "" "double long void" } */ +double long char *x262; /* { dg-error "" "double long char" } */ +double long short *x263; /* { dg-error "" "double long short" } */ +double long int *x264; /* { dg-error "" "double long int" } */ +double long long *x265; /* { dg-error "" "double long long" } */ +double long float *x266; /* { dg-error "" "double long float" } */ +double long double *x267; /* { dg-error "" "double long double" } */ +double long signed *x268; /* { dg-error "" "double long signed" } */ +double long unsigned *x269; /* { dg-error "" "double long unsigned" } */ +double long _Bool *x270; /* { dg-error "" "double long _Bool" } */ +signed char void *x271; /* { dg-error "" "signed char void" } */ +signed char char *x272; /* { dg-error "" "signed char char" } */ +signed char short *x273; /* { dg-error "" "signed char short" } */ +signed char int *x274; /* { dg-error "" "signed char int" } */ +signed char long *x275; /* { dg-error "" "signed char long" } */ +signed char float *x276; /* { dg-error "" "signed char float" } */ +signed char double *x277; /* { dg-error "" "signed char double" } */ +signed char signed *x278; /* { dg-error "" "signed char signed" } */ +signed char unsigned *x279; /* { dg-error "" "signed char unsigned" } */ +signed char _Bool *x280; /* { dg-error "" "signed char _Bool" } */ +signed short void *x281; /* { dg-error "" "signed short void" } */ +signed short char *x282; /* { dg-error "" "signed short char" } */ +signed short short *x283; /* { dg-error "" "signed short short" } */ +signed short int *x284; +signed short long *x285; /* { dg-error "" "signed short long" } */ +signed short float *x286; /* { dg-error "" "signed short float" } */ +signed short double *x287; /* { dg-error "" "signed short double" } */ +signed short signed *x288; /* { dg-error "" "signed short signed" } */ +signed short unsigned *x289; /* { dg-error "" "signed short unsigned" } */ +signed short _Bool *x290; /* { dg-error "" "signed short _Bool" } */ +signed int void *x291; /* { dg-error "" "signed int void" } */ +signed int char *x292; /* { dg-error "" "signed int char" } */ +signed int short *x293; +signed int int *x294; /* { dg-error "" "signed int int" } */ +signed int long *x295; +signed int float *x296; /* { dg-error "" "signed int float" } */ +signed int double *x297; /* { dg-error "" "signed int double" } */ +signed int signed *x298; /* { dg-error "" "signed int signed" } */ +signed int unsigned *x299; /* { dg-error "" "signed int unsigned" } */ +signed int _Bool *x300; /* { dg-error "" "signed int _Bool" } */ +signed long void *x301; /* { dg-error "" "signed long void" } */ +signed long char *x302; /* { dg-error "" "signed long char" } */ +signed long short *x303; /* { dg-error "" "signed long short" } */ +signed long int *x304; +signed long long *x305; +signed long float *x306; /* { dg-error "" "signed long float" } */ +signed long double *x307; /* { dg-error "" "signed long double" } */ +signed long signed *x308; /* { dg-error "" "signed long signed" } */ +signed long unsigned *x309; /* { dg-error "" "signed long unsigned" } */ +signed long _Bool *x310; /* { dg-error "" "signed long _Bool" } */ +unsigned char void *x311; /* { dg-error "" "unsigned char void" } */ +unsigned char char *x312; /* { dg-error "" "unsigned char char" } */ +unsigned char short *x313; /* { dg-error "" "unsigned char short" } */ +unsigned char int *x314; /* { dg-error "" "unsigned char int" } */ +unsigned char long *x315; /* { dg-error "" "unsigned char long" } */ +unsigned char float *x316; /* { dg-error "" "unsigned char float" } */ +unsigned char double *x317; /* { dg-error "" "unsigned char double" } */ +unsigned char signed *x318; /* { dg-error "" "unsigned char signed" } */ +unsigned char unsigned *x319; /* { dg-error "" "unsigned char unsigned" } */ +unsigned char _Bool *x320; /* { dg-error "" "unsigned char _Bool" } */ +unsigned short void *x321; /* { dg-error "" "unsigned short void" } */ +unsigned short char *x322; /* { dg-error "" "unsigned short char" } */ +unsigned short short *x323; /* { dg-error "" "unsigned short short" } */ +unsigned short int *x324; +unsigned short long *x325; /* { dg-error "" "unsigned short long" } */ +unsigned short float *x326; /* { dg-error "" "unsigned short float" } */ +unsigned short double *x327; /* { dg-error "" "unsigned short double" } */ +unsigned short signed *x328; /* { dg-error "" "unsigned short signed" } */ +unsigned short unsigned *x329; /* { dg-error "" "unsigned short unsigned" } */ +unsigned short _Bool *x330; /* { dg-error "" "unsigned short _Bool" } */ +unsigned int void *x331; /* { dg-error "" "unsigned int void" } */ +unsigned int char *x332; /* { dg-error "" "unsigned int char" } */ +unsigned int short *x333; +unsigned int int *x334; /* { dg-error "" "unsigned int int" } */ +unsigned int long *x335; +unsigned int float *x336; /* { dg-error "" "unsigned int float" } */ +unsigned int double *x337; /* { dg-error "" "unsigned int double" } */ +unsigned int signed *x338; /* { dg-error "" "unsigned int signed" } */ +unsigned int unsigned *x339; /* { dg-error "" "unsigned int unsigned" } */ +unsigned int _Bool *x340; /* { dg-error "" "unsigned int _Bool" } */ +unsigned long void *x341; /* { dg-error "" "unsigned long void" } */ +unsigned long char *x342; /* { dg-error "" "unsigned long char" } */ +unsigned long short *x343; /* { dg-error "" "unsigned long short" } */ +unsigned long int *x344; +unsigned long long *x345; +unsigned long float *x346; /* { dg-error "" "unsigned long float" } */ +unsigned long double *x347; /* { dg-error "" "unsigned long double" } */ +unsigned long signed *x348; /* { dg-error "" "unsigned long signed" } */ +unsigned long unsigned *x349; /* { dg-error "" "unsigned long unsigned" } */ +unsigned long _Bool *x350; /* { dg-error "" "unsigned long _Bool" } */ +short int signed void *x351; /* { dg-error "" "short int signed void" } */ +short int signed char *x352; /* { dg-error "" "short int signed char" } */ +short int signed short *x353; /* { dg-error "" "short int signed short" } */ +short int signed int *x354; /* { dg-error "" "short int signed int" } */ +short int signed long *x355; /* { dg-error "" "short int signed long" } */ +short int signed float *x356; /* { dg-error "" "short int signed float" } */ +short int signed double *x357; /* { dg-error "" "short int signed double" } */ +short int signed signed *x358; /* { dg-error "" "short int signed signed" } */ +short int signed unsigned *x359; /* { dg-error "" "short int signed unsigned" } */ +short int signed _Bool *x360; /* { dg-error "" "short int signed _Bool" } */ +short int unsigned void *x361; /* { dg-error "" "short int unsigned void" } */ +short int unsigned char *x362; /* { dg-error "" "short int unsigned char" } */ +short int unsigned short *x363; /* { dg-error "" "short int unsigned short" } */ +short int unsigned int *x364; /* { dg-error "" "short int unsigned int" } */ +short int unsigned long *x365; /* { dg-error "" "short int unsigned long" } */ +short int unsigned float *x366; /* { dg-error "" "short int unsigned float" } */ +short int unsigned double *x367; /* { dg-error "" "short int unsigned double" } */ +short int unsigned signed *x368; /* { dg-error "" "short int unsigned signed" } */ +short int unsigned unsigned *x369; /* { dg-error "" "short int unsigned unsigned" } */ +short int unsigned _Bool *x370; /* { dg-error "" "short int unsigned _Bool" } */ +short signed int void *x371; /* { dg-error "" "short signed int void" } */ +short signed int char *x372; /* { dg-error "" "short signed int char" } */ +short signed int short *x373; /* { dg-error "" "short signed int short" } */ +short signed int int *x374; /* { dg-error "" "short signed int int" } */ +short signed int long *x375; /* { dg-error "" "short signed int long" } */ +short signed int float *x376; /* { dg-error "" "short signed int float" } */ +short signed int double *x377; /* { dg-error "" "short signed int double" } */ +short signed int signed *x378; /* { dg-error "" "short signed int signed" } */ +short signed int unsigned *x379; /* { dg-error "" "short signed int unsigned" } */ +short signed int _Bool *x380; /* { dg-error "" "short signed int _Bool" } */ +short unsigned int void *x381; /* { dg-error "" "short unsigned int void" } */ +short unsigned int char *x382; /* { dg-error "" "short unsigned int char" } */ +short unsigned int short *x383; /* { dg-error "" "short unsigned int short" } */ +short unsigned int int *x384; /* { dg-error "" "short unsigned int int" } */ +short unsigned int long *x385; /* { dg-error "" "short unsigned int long" } */ +short unsigned int float *x386; /* { dg-error "" "short unsigned int float" } */ +short unsigned int double *x387; /* { dg-error "" "short unsigned int double" } */ +short unsigned int signed *x388; /* { dg-error "" "short unsigned int signed" } */ +short unsigned int unsigned *x389; /* { dg-error "" "short unsigned int unsigned" } */ +short unsigned int _Bool *x390; /* { dg-error "" "short unsigned int _Bool" } */ +int short signed void *x391; /* { dg-error "" "int short signed void" } */ +int short signed char *x392; /* { dg-error "" "int short signed char" } */ +int short signed short *x393; /* { dg-error "" "int short signed short" } */ +int short signed int *x394; /* { dg-error "" "int short signed int" } */ +int short signed long *x395; /* { dg-error "" "int short signed long" } */ +int short signed float *x396; /* { dg-error "" "int short signed float" } */ +int short signed double *x397; /* { dg-error "" "int short signed double" } */ +int short signed signed *x398; /* { dg-error "" "int short signed signed" } */ +int short signed unsigned *x399; /* { dg-error "" "int short signed unsigned" } */ +int short signed _Bool *x400; /* { dg-error "" "int short signed _Bool" } */ +int short unsigned void *x401; /* { dg-error "" "int short unsigned void" } */ +int short unsigned char *x402; /* { dg-error "" "int short unsigned char" } */ +int short unsigned short *x403; /* { dg-error "" "int short unsigned short" } */ +int short unsigned int *x404; /* { dg-error "" "int short unsigned int" } */ +int short unsigned long *x405; /* { dg-error "" "int short unsigned long" } */ +int short unsigned float *x406; /* { dg-error "" "int short unsigned float" } */ +int short unsigned double *x407; /* { dg-error "" "int short unsigned double" } */ +int short unsigned signed *x408; /* { dg-error "" "int short unsigned signed" } */ +int short unsigned unsigned *x409; /* { dg-error "" "int short unsigned unsigned" } */ +int short unsigned _Bool *x410; /* { dg-error "" "int short unsigned _Bool" } */ +int long long void *x411; /* { dg-error "" "int long long void" } */ +int long long char *x412; /* { dg-error "" "int long long char" } */ +int long long short *x413; /* { dg-error "" "int long long short" } */ +int long long int *x414; /* { dg-error "" "int long long int" } */ +int long long long *x415; /* { dg-error "" "int long long long" } */ +int long long float *x416; /* { dg-error "" "int long long float" } */ +int long long double *x417; /* { dg-error "" "int long long double" } */ +int long long signed *x418; +int long long unsigned *x419; +int long long _Bool *x420; /* { dg-error "" "int long long _Bool" } */ +int long signed void *x421; /* { dg-error "" "int long signed void" } */ +int long signed char *x422; /* { dg-error "" "int long signed char" } */ +int long signed short *x423; /* { dg-error "" "int long signed short" } */ +int long signed int *x424; /* { dg-error "" "int long signed int" } */ +int long signed long *x425; +int long signed float *x426; /* { dg-error "" "int long signed float" } */ +int long signed double *x427; /* { dg-error "" "int long signed double" } */ +int long signed signed *x428; /* { dg-error "" "int long signed signed" } */ +int long signed unsigned *x429; /* { dg-error "" "int long signed unsigned" } */ +int long signed _Bool *x430; /* { dg-error "" "int long signed _Bool" } */ +int long unsigned void *x431; /* { dg-error "" "int long unsigned void" } */ +int long unsigned char *x432; /* { dg-error "" "int long unsigned char" } */ +int long unsigned short *x433; /* { dg-error "" "int long unsigned short" } */ +int long unsigned int *x434; /* { dg-error "" "int long unsigned int" } */ +int long unsigned long *x435; +int long unsigned float *x436; /* { dg-error "" "int long unsigned float" } */ +int long unsigned double *x437; /* { dg-error "" "int long unsigned double" } */ +int long unsigned signed *x438; /* { dg-error "" "int long unsigned signed" } */ +int long unsigned unsigned *x439; /* { dg-error "" "int long unsigned unsigned" } */ +int long unsigned _Bool *x440; /* { dg-error "" "int long unsigned _Bool" } */ +int signed short void *x441; /* { dg-error "" "int signed short void" } */ +int signed short char *x442; /* { dg-error "" "int signed short char" } */ +int signed short short *x443; /* { dg-error "" "int signed short short" } */ +int signed short int *x444; /* { dg-error "" "int signed short int" } */ +int signed short long *x445; /* { dg-error "" "int signed short long" } */ +int signed short float *x446; /* { dg-error "" "int signed short float" } */ +int signed short double *x447; /* { dg-error "" "int signed short double" } */ +int signed short signed *x448; /* { dg-error "" "int signed short signed" } */ +int signed short unsigned *x449; /* { dg-error "" "int signed short unsigned" } */ +int signed short _Bool *x450; /* { dg-error "" "int signed short _Bool" } */ +int signed long void *x451; /* { dg-error "" "int signed long void" } */ +int signed long char *x452; /* { dg-error "" "int signed long char" } */ +int signed long short *x453; /* { dg-error "" "int signed long short" } */ +int signed long int *x454; /* { dg-error "" "int signed long int" } */ +int signed long long *x455; +int signed long float *x456; /* { dg-error "" "int signed long float" } */ +int signed long double *x457; /* { dg-error "" "int signed long double" } */ +int signed long signed *x458; /* { dg-error "" "int signed long signed" } */ +int signed long unsigned *x459; /* { dg-error "" "int signed long unsigned" } */ +int signed long _Bool *x460; /* { dg-error "" "int signed long _Bool" } */ +int unsigned short void *x461; /* { dg-error "" "int unsigned short void" } */ +int unsigned short char *x462; /* { dg-error "" "int unsigned short char" } */ +int unsigned short short *x463; /* { dg-error "" "int unsigned short short" } */ +int unsigned short int *x464; /* { dg-error "" "int unsigned short int" } */ +int unsigned short long *x465; /* { dg-error "" "int unsigned short long" } */ +int unsigned short float *x466; /* { dg-error "" "int unsigned short float" } */ +int unsigned short double *x467; /* { dg-error "" "int unsigned short double" } */ +int unsigned short signed *x468; /* { dg-error "" "int unsigned short signed" } */ +int unsigned short unsigned *x469; /* { dg-error "" "int unsigned short unsigned" } */ +int unsigned short _Bool *x470; /* { dg-error "" "int unsigned short _Bool" } */ +int unsigned long void *x471; /* { dg-error "" "int unsigned long void" } */ +int unsigned long char *x472; /* { dg-error "" "int unsigned long char" } */ +int unsigned long short *x473; /* { dg-error "" "int unsigned long short" } */ +int unsigned long int *x474; /* { dg-error "" "int unsigned long int" } */ +int unsigned long long *x475; +int unsigned long float *x476; /* { dg-error "" "int unsigned long float" } */ +int unsigned long double *x477; /* { dg-error "" "int unsigned long double" } */ +int unsigned long signed *x478; /* { dg-error "" "int unsigned long signed" } */ +int unsigned long unsigned *x479; /* { dg-error "" "int unsigned long unsigned" } */ +int unsigned long _Bool *x480; /* { dg-error "" "int unsigned long _Bool" } */ +long int long void *x481; /* { dg-error "" "long int long void" } */ +long int long char *x482; /* { dg-error "" "long int long char" } */ +long int long short *x483; /* { dg-error "" "long int long short" } */ +long int long int *x484; /* { dg-error "" "long int long int" } */ +long int long long *x485; /* { dg-error "" "long int long long" } */ +long int long float *x486; /* { dg-error "" "long int long float" } */ +long int long double *x487; /* { dg-error "" "long int long double" } */ +long int long signed *x488; +long int long unsigned *x489; +long int long _Bool *x490; /* { dg-error "" "long int long _Bool" } */ +long int signed void *x491; /* { dg-error "" "long int signed void" } */ +long int signed char *x492; /* { dg-error "" "long int signed char" } */ +long int signed short *x493; /* { dg-error "" "long int signed short" } */ +long int signed int *x494; /* { dg-error "" "long int signed int" } */ +long int signed long *x495; +long int signed float *x496; /* { dg-error "" "long int signed float" } */ +long int signed double *x497; /* { dg-error "" "long int signed double" } */ +long int signed signed *x498; /* { dg-error "" "long int signed signed" } */ +long int signed unsigned *x499; /* { dg-error "" "long int signed unsigned" } */ +long int signed _Bool *x500; /* { dg-error "" "long int signed _Bool" } */ +long int unsigned void *x501; /* { dg-error "" "long int unsigned void" } */ +long int unsigned char *x502; /* { dg-error "" "long int unsigned char" } */ +long int unsigned short *x503; /* { dg-error "" "long int unsigned short" } */ +long int unsigned int *x504; /* { dg-error "" "long int unsigned int" } */ +long int unsigned long *x505; +long int unsigned float *x506; /* { dg-error "" "long int unsigned float" } */ +long int unsigned double *x507; /* { dg-error "" "long int unsigned double" } */ +long int unsigned signed *x508; /* { dg-error "" "long int unsigned signed" } */ +long int unsigned unsigned *x509; /* { dg-error "" "long int unsigned unsigned" } */ +long int unsigned _Bool *x510; /* { dg-error "" "long int unsigned _Bool" } */ +long long int void *x511; /* { dg-error "" "long long int void" } */ +long long int char *x512; /* { dg-error "" "long long int char" } */ +long long int short *x513; /* { dg-error "" "long long int short" } */ +long long int int *x514; /* { dg-error "" "long long int int" } */ +long long int long *x515; /* { dg-error "" "long long int long" } */ +long long int float *x516; /* { dg-error "" "long long int float" } */ +long long int double *x517; /* { dg-error "" "long long int double" } */ +long long int signed *x518; +long long int unsigned *x519; +long long int _Bool *x520; /* { dg-error "" "long long int _Bool" } */ +long long signed void *x521; /* { dg-error "" "long long signed void" } */ +long long signed char *x522; /* { dg-error "" "long long signed char" } */ +long long signed short *x523; /* { dg-error "" "long long signed short" } */ +long long signed int *x524; +long long signed long *x525; /* { dg-error "" "long long signed long" } */ +long long signed float *x526; /* { dg-error "" "long long signed float" } */ +long long signed double *x527; /* { dg-error "" "long long signed double" } */ +long long signed signed *x528; /* { dg-error "" "long long signed signed" } */ +long long signed unsigned *x529; /* { dg-error "" "long long signed unsigned" } */ +long long signed _Bool *x530; /* { dg-error "" "long long signed _Bool" } */ +long long unsigned void *x531; /* { dg-error "" "long long unsigned void" } */ +long long unsigned char *x532; /* { dg-error "" "long long unsigned char" } */ +long long unsigned short *x533; /* { dg-error "" "long long unsigned short" } */ +long long unsigned int *x534; +long long unsigned long *x535; /* { dg-error "" "long long unsigned long" } */ +long long unsigned float *x536; /* { dg-error "" "long long unsigned float" } */ +long long unsigned double *x537; /* { dg-error "" "long long unsigned double" } */ +long long unsigned signed *x538; /* { dg-error "" "long long unsigned signed" } */ +long long unsigned unsigned *x539; /* { dg-error "" "long long unsigned unsigned" } */ +long long unsigned _Bool *x540; /* { dg-error "" "long long unsigned _Bool" } */ +long signed int void *x541; /* { dg-error "" "long signed int void" } */ +long signed int char *x542; /* { dg-error "" "long signed int char" } */ +long signed int short *x543; /* { dg-error "" "long signed int short" } */ +long signed int int *x544; /* { dg-error "" "long signed int int" } */ +long signed int long *x545; +long signed int float *x546; /* { dg-error "" "long signed int float" } */ +long signed int double *x547; /* { dg-error "" "long signed int double" } */ +long signed int signed *x548; /* { dg-error "" "long signed int signed" } */ +long signed int unsigned *x549; /* { dg-error "" "long signed int unsigned" } */ +long signed int _Bool *x550; /* { dg-error "" "long signed int _Bool" } */ +long signed long void *x551; /* { dg-error "" "long signed long void" } */ +long signed long char *x552; /* { dg-error "" "long signed long char" } */ +long signed long short *x553; /* { dg-error "" "long signed long short" } */ +long signed long int *x554; +long signed long long *x555; /* { dg-error "" "long signed long long" } */ +long signed long float *x556; /* { dg-error "" "long signed long float" } */ +long signed long double *x557; /* { dg-error "" "long signed long double" } */ +long signed long signed *x558; /* { dg-error "" "long signed long signed" } */ +long signed long unsigned *x559; /* { dg-error "" "long signed long unsigned" } */ +long signed long _Bool *x560; /* { dg-error "" "long signed long _Bool" } */ +long unsigned int void *x561; /* { dg-error "" "long unsigned int void" } */ +long unsigned int char *x562; /* { dg-error "" "long unsigned int char" } */ +long unsigned int short *x563; /* { dg-error "" "long unsigned int short" } */ +long unsigned int int *x564; /* { dg-error "" "long unsigned int int" } */ +long unsigned int long *x565; +long unsigned int float *x566; /* { dg-error "" "long unsigned int float" } */ +long unsigned int double *x567; /* { dg-error "" "long unsigned int double" } */ +long unsigned int signed *x568; /* { dg-error "" "long unsigned int signed" } */ +long unsigned int unsigned *x569; /* { dg-error "" "long unsigned int unsigned" } */ +long unsigned int _Bool *x570; /* { dg-error "" "long unsigned int _Bool" } */ +long unsigned long void *x571; /* { dg-error "" "long unsigned long void" } */ +long unsigned long char *x572; /* { dg-error "" "long unsigned long char" } */ +long unsigned long short *x573; /* { dg-error "" "long unsigned long short" } */ +long unsigned long int *x574; +long unsigned long long *x575; /* { dg-error "" "long unsigned long long" } */ +long unsigned long float *x576; /* { dg-error "" "long unsigned long float" } */ +long unsigned long double *x577; /* { dg-error "" "long unsigned long double" } */ +long unsigned long signed *x578; /* { dg-error "" "long unsigned long signed" } */ +long unsigned long unsigned *x579; /* { dg-error "" "long unsigned long unsigned" } */ +long unsigned long _Bool *x580; /* { dg-error "" "long unsigned long _Bool" } */ +signed short int void *x581; /* { dg-error "" "signed short int void" } */ +signed short int char *x582; /* { dg-error "" "signed short int char" } */ +signed short int short *x583; /* { dg-error "" "signed short int short" } */ +signed short int int *x584; /* { dg-error "" "signed short int int" } */ +signed short int long *x585; /* { dg-error "" "signed short int long" } */ +signed short int float *x586; /* { dg-error "" "signed short int float" } */ +signed short int double *x587; /* { dg-error "" "signed short int double" } */ +signed short int signed *x588; /* { dg-error "" "signed short int signed" } */ +signed short int unsigned *x589; /* { dg-error "" "signed short int unsigned" } */ +signed short int _Bool *x590; /* { dg-error "" "signed short int _Bool" } */ +signed int short void *x591; /* { dg-error "" "signed int short void" } */ +signed int short char *x592; /* { dg-error "" "signed int short char" } */ +signed int short short *x593; /* { dg-error "" "signed int short short" } */ +signed int short int *x594; /* { dg-error "" "signed int short int" } */ +signed int short long *x595; /* { dg-error "" "signed int short long" } */ +signed int short float *x596; /* { dg-error "" "signed int short float" } */ +signed int short double *x597; /* { dg-error "" "signed int short double" } */ +signed int short signed *x598; /* { dg-error "" "signed int short signed" } */ +signed int short unsigned *x599; /* { dg-error "" "signed int short unsigned" } */ +signed int short _Bool *x600; /* { dg-error "" "signed int short _Bool" } */ +signed int long void *x601; /* { dg-error "" "signed int long void" } */ +signed int long char *x602; /* { dg-error "" "signed int long char" } */ +signed int long short *x603; /* { dg-error "" "signed int long short" } */ +signed int long int *x604; /* { dg-error "" "signed int long int" } */ +signed int long long *x605; +signed int long float *x606; /* { dg-error "" "signed int long float" } */ +signed int long double *x607; /* { dg-error "" "signed int long double" } */ +signed int long signed *x608; /* { dg-error "" "signed int long signed" } */ +signed int long unsigned *x609; /* { dg-error "" "signed int long unsigned" } */ +signed int long _Bool *x610; /* { dg-error "" "signed int long _Bool" } */ +signed long int void *x611; /* { dg-error "" "signed long int void" } */ +signed long int char *x612; /* { dg-error "" "signed long int char" } */ +signed long int short *x613; /* { dg-error "" "signed long int short" } */ +signed long int int *x614; /* { dg-error "" "signed long int int" } */ +signed long int long *x615; +signed long int float *x616; /* { dg-error "" "signed long int float" } */ +signed long int double *x617; /* { dg-error "" "signed long int double" } */ +signed long int signed *x618; /* { dg-error "" "signed long int signed" } */ +signed long int unsigned *x619; /* { dg-error "" "signed long int unsigned" } */ +signed long int _Bool *x620; /* { dg-error "" "signed long int _Bool" } */ +signed long long void *x621; /* { dg-error "" "signed long long void" } */ +signed long long char *x622; /* { dg-error "" "signed long long char" } */ +signed long long short *x623; /* { dg-error "" "signed long long short" } */ +signed long long int *x624; +signed long long long *x625; /* { dg-error "" "signed long long long" } */ +signed long long float *x626; /* { dg-error "" "signed long long float" } */ +signed long long double *x627; /* { dg-error "" "signed long long double" } */ +signed long long signed *x628; /* { dg-error "" "signed long long signed" } */ +signed long long unsigned *x629; /* { dg-error "" "signed long long unsigned" } */ +signed long long _Bool *x630; /* { dg-error "" "signed long long _Bool" } */ +unsigned short int void *x631; /* { dg-error "" "unsigned short int void" } */ +unsigned short int char *x632; /* { dg-error "" "unsigned short int char" } */ +unsigned short int short *x633; /* { dg-error "" "unsigned short int short" } */ +unsigned short int int *x634; /* { dg-error "" "unsigned short int int" } */ +unsigned short int long *x635; /* { dg-error "" "unsigned short int long" } */ +unsigned short int float *x636; /* { dg-error "" "unsigned short int float" } */ +unsigned short int double *x637; /* { dg-error "" "unsigned short int double" } */ +unsigned short int signed *x638; /* { dg-error "" "unsigned short int signed" } */ +unsigned short int unsigned *x639; /* { dg-error "" "unsigned short int unsigned" } */ +unsigned short int _Bool *x640; /* { dg-error "" "unsigned short int _Bool" } */ +unsigned int short void *x641; /* { dg-error "" "unsigned int short void" } */ +unsigned int short char *x642; /* { dg-error "" "unsigned int short char" } */ +unsigned int short short *x643; /* { dg-error "" "unsigned int short short" } */ +unsigned int short int *x644; /* { dg-error "" "unsigned int short int" } */ +unsigned int short long *x645; /* { dg-error "" "unsigned int short long" } */ +unsigned int short float *x646; /* { dg-error "" "unsigned int short float" } */ +unsigned int short double *x647; /* { dg-error "" "unsigned int short double" } */ +unsigned int short signed *x648; /* { dg-error "" "unsigned int short signed" } */ +unsigned int short unsigned *x649; /* { dg-error "" "unsigned int short unsigned" } */ +unsigned int short _Bool *x650; /* { dg-error "" "unsigned int short _Bool" } */ +unsigned int long void *x651; /* { dg-error "" "unsigned int long void" } */ +unsigned int long char *x652; /* { dg-error "" "unsigned int long char" } */ +unsigned int long short *x653; /* { dg-error "" "unsigned int long short" } */ +unsigned int long int *x654; /* { dg-error "" "unsigned int long int" } */ +unsigned int long long *x655; +unsigned int long float *x656; /* { dg-error "" "unsigned int long float" } */ +unsigned int long double *x657; /* { dg-error "" "unsigned int long double" } */ +unsigned int long signed *x658; /* { dg-error "" "unsigned int long signed" } */ +unsigned int long unsigned *x659; /* { dg-error "" "unsigned int long unsigned" } */ +unsigned int long _Bool *x660; /* { dg-error "" "unsigned int long _Bool" } */ +unsigned long int void *x661; /* { dg-error "" "unsigned long int void" } */ +unsigned long int char *x662; /* { dg-error "" "unsigned long int char" } */ +unsigned long int short *x663; /* { dg-error "" "unsigned long int short" } */ +unsigned long int int *x664; /* { dg-error "" "unsigned long int int" } */ +unsigned long int long *x665; +unsigned long int float *x666; /* { dg-error "" "unsigned long int float" } */ +unsigned long int double *x667; /* { dg-error "" "unsigned long int double" } */ +unsigned long int signed *x668; /* { dg-error "" "unsigned long int signed" } */ +unsigned long int unsigned *x669; /* { dg-error "" "unsigned long int unsigned" } */ +unsigned long int _Bool *x670; /* { dg-error "" "unsigned long int _Bool" } */ +unsigned long long void *x671; /* { dg-error "" "unsigned long long void" } */ +unsigned long long char *x672; /* { dg-error "" "unsigned long long char" } */ +unsigned long long short *x673; /* { dg-error "" "unsigned long long short" } */ +unsigned long long int *x674; +unsigned long long long *x675; /* { dg-error "" "unsigned long long long" } */ +unsigned long long float *x676; /* { dg-error "" "unsigned long long float" } */ +unsigned long long double *x677; /* { dg-error "" "unsigned long long double" } */ +unsigned long long signed *x678; /* { dg-error "" "unsigned long long signed" } */ +unsigned long long unsigned *x679; /* { dg-error "" "unsigned long long unsigned" } */ +unsigned long long _Bool *x680; /* { dg-error "" "unsigned long long _Bool" } */ +int long long signed void *x681; /* { dg-error "" "int long long signed void" } */ +int long long signed char *x682; /* { dg-error "" "int long long signed char" } */ +int long long signed short *x683; /* { dg-error "" "int long long signed short" } */ +int long long signed int *x684; /* { dg-error "" "int long long signed int" } */ +int long long signed long *x685; /* { dg-error "" "int long long signed long" } */ +int long long signed float *x686; /* { dg-error "" "int long long signed float" } */ +int long long signed double *x687; /* { dg-error "" "int long long signed double" } */ +int long long signed signed *x688; /* { dg-error "" "int long long signed signed" } */ +int long long signed unsigned *x689; /* { dg-error "" "int long long signed unsigned" } */ +int long long signed _Bool *x690; /* { dg-error "" "int long long signed _Bool" } */ +int long long unsigned void *x691; /* { dg-error "" "int long long unsigned void" } */ +int long long unsigned char *x692; /* { dg-error "" "int long long unsigned char" } */ +int long long unsigned short *x693; /* { dg-error "" "int long long unsigned short" } */ +int long long unsigned int *x694; /* { dg-error "" "int long long unsigned int" } */ +int long long unsigned long *x695; /* { dg-error "" "int long long unsigned long" } */ +int long long unsigned float *x696; /* { dg-error "" "int long long unsigned float" } */ +int long long unsigned double *x697; /* { dg-error "" "int long long unsigned double" } */ +int long long unsigned signed *x698; /* { dg-error "" "int long long unsigned signed" } */ +int long long unsigned unsigned *x699; /* { dg-error "" "int long long unsigned unsigned" } */ +int long long unsigned _Bool *x700; /* { dg-error "" "int long long unsigned _Bool" } */ +int long signed long void *x701; /* { dg-error "" "int long signed long void" } */ +int long signed long char *x702; /* { dg-error "" "int long signed long char" } */ +int long signed long short *x703; /* { dg-error "" "int long signed long short" } */ +int long signed long int *x704; /* { dg-error "" "int long signed long int" } */ +int long signed long long *x705; /* { dg-error "" "int long signed long long" } */ +int long signed long float *x706; /* { dg-error "" "int long signed long float" } */ +int long signed long double *x707; /* { dg-error "" "int long signed long double" } */ +int long signed long signed *x708; /* { dg-error "" "int long signed long signed" } */ +int long signed long unsigned *x709; /* { dg-error "" "int long signed long unsigned" } */ +int long signed long _Bool *x710; /* { dg-error "" "int long signed long _Bool" } */ +int long unsigned long void *x711; /* { dg-error "" "int long unsigned long void" } */ +int long unsigned long char *x712; /* { dg-error "" "int long unsigned long char" } */ +int long unsigned long short *x713; /* { dg-error "" "int long unsigned long short" } */ +int long unsigned long int *x714; /* { dg-error "" "int long unsigned long int" } */ +int long unsigned long long *x715; /* { dg-error "" "int long unsigned long long" } */ +int long unsigned long float *x716; /* { dg-error "" "int long unsigned long float" } */ +int long unsigned long double *x717; /* { dg-error "" "int long unsigned long double" } */ +int long unsigned long signed *x718; /* { dg-error "" "int long unsigned long signed" } */ +int long unsigned long unsigned *x719; /* { dg-error "" "int long unsigned long unsigned" } */ +int long unsigned long _Bool *x720; /* { dg-error "" "int long unsigned long _Bool" } */ +int signed long long void *x721; /* { dg-error "" "int signed long long void" } */ +int signed long long char *x722; /* { dg-error "" "int signed long long char" } */ +int signed long long short *x723; /* { dg-error "" "int signed long long short" } */ +int signed long long int *x724; /* { dg-error "" "int signed long long int" } */ +int signed long long long *x725; /* { dg-error "" "int signed long long long" } */ +int signed long long float *x726; /* { dg-error "" "int signed long long float" } */ +int signed long long double *x727; /* { dg-error "" "int signed long long double" } */ +int signed long long signed *x728; /* { dg-error "" "int signed long long signed" } */ +int signed long long unsigned *x729; /* { dg-error "" "int signed long long unsigned" } */ +int signed long long _Bool *x730; /* { dg-error "" "int signed long long _Bool" } */ +int unsigned long long void *x731; /* { dg-error "" "int unsigned long long void" } */ +int unsigned long long char *x732; /* { dg-error "" "int unsigned long long char" } */ +int unsigned long long short *x733; /* { dg-error "" "int unsigned long long short" } */ +int unsigned long long int *x734; /* { dg-error "" "int unsigned long long int" } */ +int unsigned long long long *x735; /* { dg-error "" "int unsigned long long long" } */ +int unsigned long long float *x736; /* { dg-error "" "int unsigned long long float" } */ +int unsigned long long double *x737; /* { dg-error "" "int unsigned long long double" } */ +int unsigned long long signed *x738; /* { dg-error "" "int unsigned long long signed" } */ +int unsigned long long unsigned *x739; /* { dg-error "" "int unsigned long long unsigned" } */ +int unsigned long long _Bool *x740; /* { dg-error "" "int unsigned long long _Bool" } */ +long int long signed void *x741; /* { dg-error "" "long int long signed void" } */ +long int long signed char *x742; /* { dg-error "" "long int long signed char" } */ +long int long signed short *x743; /* { dg-error "" "long int long signed short" } */ +long int long signed int *x744; /* { dg-error "" "long int long signed int" } */ +long int long signed long *x745; /* { dg-error "" "long int long signed long" } */ +long int long signed float *x746; /* { dg-error "" "long int long signed float" } */ +long int long signed double *x747; /* { dg-error "" "long int long signed double" } */ +long int long signed signed *x748; /* { dg-error "" "long int long signed signed" } */ +long int long signed unsigned *x749; /* { dg-error "" "long int long signed unsigned" } */ +long int long signed _Bool *x750; /* { dg-error "" "long int long signed _Bool" } */ +long int long unsigned void *x751; /* { dg-error "" "long int long unsigned void" } */ +long int long unsigned char *x752; /* { dg-error "" "long int long unsigned char" } */ +long int long unsigned short *x753; /* { dg-error "" "long int long unsigned short" } */ +long int long unsigned int *x754; /* { dg-error "" "long int long unsigned int" } */ +long int long unsigned long *x755; /* { dg-error "" "long int long unsigned long" } */ +long int long unsigned float *x756; /* { dg-error "" "long int long unsigned float" } */ +long int long unsigned double *x757; /* { dg-error "" "long int long unsigned double" } */ +long int long unsigned signed *x758; /* { dg-error "" "long int long unsigned signed" } */ +long int long unsigned unsigned *x759; /* { dg-error "" "long int long unsigned unsigned" } */ +long int long unsigned _Bool *x760; /* { dg-error "" "long int long unsigned _Bool" } */ +long int signed long void *x761; /* { dg-error "" "long int signed long void" } */ +long int signed long char *x762; /* { dg-error "" "long int signed long char" } */ +long int signed long short *x763; /* { dg-error "" "long int signed long short" } */ +long int signed long int *x764; /* { dg-error "" "long int signed long int" } */ +long int signed long long *x765; /* { dg-error "" "long int signed long long" } */ +long int signed long float *x766; /* { dg-error "" "long int signed long float" } */ +long int signed long double *x767; /* { dg-error "" "long int signed long double" } */ +long int signed long signed *x768; /* { dg-error "" "long int signed long signed" } */ +long int signed long unsigned *x769; /* { dg-error "" "long int signed long unsigned" } */ +long int signed long _Bool *x770; /* { dg-error "" "long int signed long _Bool" } */ +long int unsigned long void *x771; /* { dg-error "" "long int unsigned long void" } */ +long int unsigned long char *x772; /* { dg-error "" "long int unsigned long char" } */ +long int unsigned long short *x773; /* { dg-error "" "long int unsigned long short" } */ +long int unsigned long int *x774; /* { dg-error "" "long int unsigned long int" } */ +long int unsigned long long *x775; /* { dg-error "" "long int unsigned long long" } */ +long int unsigned long float *x776; /* { dg-error "" "long int unsigned long float" } */ +long int unsigned long double *x777; /* { dg-error "" "long int unsigned long double" } */ +long int unsigned long signed *x778; /* { dg-error "" "long int unsigned long signed" } */ +long int unsigned long unsigned *x779; /* { dg-error "" "long int unsigned long unsigned" } */ +long int unsigned long _Bool *x780; /* { dg-error "" "long int unsigned long _Bool" } */ +long long int signed void *x781; /* { dg-error "" "long long int signed void" } */ +long long int signed char *x782; /* { dg-error "" "long long int signed char" } */ +long long int signed short *x783; /* { dg-error "" "long long int signed short" } */ +long long int signed int *x784; /* { dg-error "" "long long int signed int" } */ +long long int signed long *x785; /* { dg-error "" "long long int signed long" } */ +long long int signed float *x786; /* { dg-error "" "long long int signed float" } */ +long long int signed double *x787; /* { dg-error "" "long long int signed double" } */ +long long int signed signed *x788; /* { dg-error "" "long long int signed signed" } */ +long long int signed unsigned *x789; /* { dg-error "" "long long int signed unsigned" } */ +long long int signed _Bool *x790; /* { dg-error "" "long long int signed _Bool" } */ +long long int unsigned void *x791; /* { dg-error "" "long long int unsigned void" } */ +long long int unsigned char *x792; /* { dg-error "" "long long int unsigned char" } */ +long long int unsigned short *x793; /* { dg-error "" "long long int unsigned short" } */ +long long int unsigned int *x794; /* { dg-error "" "long long int unsigned int" } */ +long long int unsigned long *x795; /* { dg-error "" "long long int unsigned long" } */ +long long int unsigned float *x796; /* { dg-error "" "long long int unsigned float" } */ +long long int unsigned double *x797; /* { dg-error "" "long long int unsigned double" } */ +long long int unsigned signed *x798; /* { dg-error "" "long long int unsigned signed" } */ +long long int unsigned unsigned *x799; /* { dg-error "" "long long int unsigned unsigned" } */ +long long int unsigned _Bool *x800; /* { dg-error "" "long long int unsigned _Bool" } */ +long long signed int void *x801; /* { dg-error "" "long long signed int void" } */ +long long signed int char *x802; /* { dg-error "" "long long signed int char" } */ +long long signed int short *x803; /* { dg-error "" "long long signed int short" } */ +long long signed int int *x804; /* { dg-error "" "long long signed int int" } */ +long long signed int long *x805; /* { dg-error "" "long long signed int long" } */ +long long signed int float *x806; /* { dg-error "" "long long signed int float" } */ +long long signed int double *x807; /* { dg-error "" "long long signed int double" } */ +long long signed int signed *x808; /* { dg-error "" "long long signed int signed" } */ +long long signed int unsigned *x809; /* { dg-error "" "long long signed int unsigned" } */ +long long signed int _Bool *x810; /* { dg-error "" "long long signed int _Bool" } */ +long long unsigned int void *x811; /* { dg-error "" "long long unsigned int void" } */ +long long unsigned int char *x812; /* { dg-error "" "long long unsigned int char" } */ +long long unsigned int short *x813; /* { dg-error "" "long long unsigned int short" } */ +long long unsigned int int *x814; /* { dg-error "" "long long unsigned int int" } */ +long long unsigned int long *x815; /* { dg-error "" "long long unsigned int long" } */ +long long unsigned int float *x816; /* { dg-error "" "long long unsigned int float" } */ +long long unsigned int double *x817; /* { dg-error "" "long long unsigned int double" } */ +long long unsigned int signed *x818; /* { dg-error "" "long long unsigned int signed" } */ +long long unsigned int unsigned *x819; /* { dg-error "" "long long unsigned int unsigned" } */ +long long unsigned int _Bool *x820; /* { dg-error "" "long long unsigned int _Bool" } */ +long signed int long void *x821; /* { dg-error "" "long signed int long void" } */ +long signed int long char *x822; /* { dg-error "" "long signed int long char" } */ +long signed int long short *x823; /* { dg-error "" "long signed int long short" } */ +long signed int long int *x824; /* { dg-error "" "long signed int long int" } */ +long signed int long long *x825; /* { dg-error "" "long signed int long long" } */ +long signed int long float *x826; /* { dg-error "" "long signed int long float" } */ +long signed int long double *x827; /* { dg-error "" "long signed int long double" } */ +long signed int long signed *x828; /* { dg-error "" "long signed int long signed" } */ +long signed int long unsigned *x829; /* { dg-error "" "long signed int long unsigned" } */ +long signed int long _Bool *x830; /* { dg-error "" "long signed int long _Bool" } */ +long signed long int void *x831; /* { dg-error "" "long signed long int void" } */ +long signed long int char *x832; /* { dg-error "" "long signed long int char" } */ +long signed long int short *x833; /* { dg-error "" "long signed long int short" } */ +long signed long int int *x834; /* { dg-error "" "long signed long int int" } */ +long signed long int long *x835; /* { dg-error "" "long signed long int long" } */ +long signed long int float *x836; /* { dg-error "" "long signed long int float" } */ +long signed long int double *x837; /* { dg-error "" "long signed long int double" } */ +long signed long int signed *x838; /* { dg-error "" "long signed long int signed" } */ +long signed long int unsigned *x839; /* { dg-error "" "long signed long int unsigned" } */ +long signed long int _Bool *x840; /* { dg-error "" "long signed long int _Bool" } */ +long unsigned int long void *x841; /* { dg-error "" "long unsigned int long void" } */ +long unsigned int long char *x842; /* { dg-error "" "long unsigned int long char" } */ +long unsigned int long short *x843; /* { dg-error "" "long unsigned int long short" } */ +long unsigned int long int *x844; /* { dg-error "" "long unsigned int long int" } */ +long unsigned int long long *x845; /* { dg-error "" "long unsigned int long long" } */ +long unsigned int long float *x846; /* { dg-error "" "long unsigned int long float" } */ +long unsigned int long double *x847; /* { dg-error "" "long unsigned int long double" } */ +long unsigned int long signed *x848; /* { dg-error "" "long unsigned int long signed" } */ +long unsigned int long unsigned *x849; /* { dg-error "" "long unsigned int long unsigned" } */ +long unsigned int long _Bool *x850; /* { dg-error "" "long unsigned int long _Bool" } */ +long unsigned long int void *x851; /* { dg-error "" "long unsigned long int void" } */ +long unsigned long int char *x852; /* { dg-error "" "long unsigned long int char" } */ +long unsigned long int short *x853; /* { dg-error "" "long unsigned long int short" } */ +long unsigned long int int *x854; /* { dg-error "" "long unsigned long int int" } */ +long unsigned long int long *x855; /* { dg-error "" "long unsigned long int long" } */ +long unsigned long int float *x856; /* { dg-error "" "long unsigned long int float" } */ +long unsigned long int double *x857; /* { dg-error "" "long unsigned long int double" } */ +long unsigned long int signed *x858; /* { dg-error "" "long unsigned long int signed" } */ +long unsigned long int unsigned *x859; /* { dg-error "" "long unsigned long int unsigned" } */ +long unsigned long int _Bool *x860; /* { dg-error "" "long unsigned long int _Bool" } */ +signed int long long void *x861; /* { dg-error "" "signed int long long void" } */ +signed int long long char *x862; /* { dg-error "" "signed int long long char" } */ +signed int long long short *x863; /* { dg-error "" "signed int long long short" } */ +signed int long long int *x864; /* { dg-error "" "signed int long long int" } */ +signed int long long long *x865; /* { dg-error "" "signed int long long long" } */ +signed int long long float *x866; /* { dg-error "" "signed int long long float" } */ +signed int long long double *x867; /* { dg-error "" "signed int long long double" } */ +signed int long long signed *x868; /* { dg-error "" "signed int long long signed" } */ +signed int long long unsigned *x869; /* { dg-error "" "signed int long long unsigned" } */ +signed int long long _Bool *x870; /* { dg-error "" "signed int long long _Bool" } */ +signed long int long void *x871; /* { dg-error "" "signed long int long void" } */ +signed long int long char *x872; /* { dg-error "" "signed long int long char" } */ +signed long int long short *x873; /* { dg-error "" "signed long int long short" } */ +signed long int long int *x874; /* { dg-error "" "signed long int long int" } */ +signed long int long long *x875; /* { dg-error "" "signed long int long long" } */ +signed long int long float *x876; /* { dg-error "" "signed long int long float" } */ +signed long int long double *x877; /* { dg-error "" "signed long int long double" } */ +signed long int long signed *x878; /* { dg-error "" "signed long int long signed" } */ +signed long int long unsigned *x879; /* { dg-error "" "signed long int long unsigned" } */ +signed long int long _Bool *x880; /* { dg-error "" "signed long int long _Bool" } */ +signed long long int void *x881; /* { dg-error "" "signed long long int void" } */ +signed long long int char *x882; /* { dg-error "" "signed long long int char" } */ +signed long long int short *x883; /* { dg-error "" "signed long long int short" } */ +signed long long int int *x884; /* { dg-error "" "signed long long int int" } */ +signed long long int long *x885; /* { dg-error "" "signed long long int long" } */ +signed long long int float *x886; /* { dg-error "" "signed long long int float" } */ +signed long long int double *x887; /* { dg-error "" "signed long long int double" } */ +signed long long int signed *x888; /* { dg-error "" "signed long long int signed" } */ +signed long long int unsigned *x889; /* { dg-error "" "signed long long int unsigned" } */ +signed long long int _Bool *x890; /* { dg-error "" "signed long long int _Bool" } */ +unsigned int long long void *x891; /* { dg-error "" "unsigned int long long void" } */ +unsigned int long long char *x892; /* { dg-error "" "unsigned int long long char" } */ +unsigned int long long short *x893; /* { dg-error "" "unsigned int long long short" } */ +unsigned int long long int *x894; /* { dg-error "" "unsigned int long long int" } */ +unsigned int long long long *x895; /* { dg-error "" "unsigned int long long long" } */ +unsigned int long long float *x896; /* { dg-error "" "unsigned int long long float" } */ +unsigned int long long double *x897; /* { dg-error "" "unsigned int long long double" } */ +unsigned int long long signed *x898; /* { dg-error "" "unsigned int long long signed" } */ +unsigned int long long unsigned *x899; /* { dg-error "" "unsigned int long long unsigned" } */ +unsigned int long long _Bool *x900; /* { dg-error "" "unsigned int long long _Bool" } */ +unsigned long int long void *x901; /* { dg-error "" "unsigned long int long void" } */ +unsigned long int long char *x902; /* { dg-error "" "unsigned long int long char" } */ +unsigned long int long short *x903; /* { dg-error "" "unsigned long int long short" } */ +unsigned long int long int *x904; /* { dg-error "" "unsigned long int long int" } */ +unsigned long int long long *x905; /* { dg-error "" "unsigned long int long long" } */ +unsigned long int long float *x906; /* { dg-error "" "unsigned long int long float" } */ +unsigned long int long double *x907; /* { dg-error "" "unsigned long int long double" } */ +unsigned long int long signed *x908; /* { dg-error "" "unsigned long int long signed" } */ +unsigned long int long unsigned *x909; /* { dg-error "" "unsigned long int long unsigned" } */ +unsigned long int long _Bool *x910; /* { dg-error "" "unsigned long int long _Bool" } */ +unsigned long long int void *x911; /* { dg-error "" "unsigned long long int void" } */ +unsigned long long int char *x912; /* { dg-error "" "unsigned long long int char" } */ +unsigned long long int short *x913; /* { dg-error "" "unsigned long long int short" } */ +unsigned long long int int *x914; /* { dg-error "" "unsigned long long int int" } */ +unsigned long long int long *x915; /* { dg-error "" "unsigned long long int long" } */ +unsigned long long int float *x916; /* { dg-error "" "unsigned long long int float" } */ +unsigned long long int double *x917; /* { dg-error "" "unsigned long long int double" } */ +unsigned long long int signed *x918; /* { dg-error "" "unsigned long long int signed" } */ +unsigned long long int unsigned *x919; /* { dg-error "" "unsigned long long int unsigned" } */ +unsigned long long int _Bool *x920; /* { dg-error "" "unsigned long long int _Bool" } */ diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-1-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-1-utf8.c new file mode 100644 index 0000000000..72136737b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-1-utf8.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99 -g" } */ +void abort (void); + +int main (void) +{ + int À = 1; + int à = 2; + int  = 3; + int whÿ = 4; + int aÄbÑδe = 5; + + if (À != 1) + abort (); + if (à != 2) + abort (); + if ( != 3) + abort (); + if (whÿ != 4) + abort (); + if (aÄbÑδe != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-1.c b/SingleSource/Regression/C/gcc-dg/ucnid-1.c new file mode 100644 index 0000000000..067a6922a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-1.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99 -g" } */ +void abort (void); + +int main (void) +{ + int \u00C0 = 1; + int \u00C1 = 2; + int \U000000C2 = 3; + int wh\u00ff = 4; + int a\u00c4b\u0441\U000003b4e = 5; + + if (\u00C0 != 1) + abort (); + if (\u00c1 != 2) + abort (); + if (\u00C2 != 3) + abort (); + if (wh\u00ff != 4) + abort (); + if (a\u00c4b\u0441\U000003b4e != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-10-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-10-utf8.c new file mode 100644 index 0000000000..86830b8b22 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-10-utf8.c @@ -0,0 +1,11 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Test #pragma pack diagnostics. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } } */ + +#pragma pack(push) +#pragma pack(pop, ó) /* { dg-warning "pop, \\\\U000000f3.*push, \\\\U000000f3" } */ +#pragma pack(ç) /* { dg-warning "unknown action '\\\\U000000e7'" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-10.c b/SingleSource/Regression/C/gcc-dg/ucnid-10.c new file mode 100644 index 0000000000..1a2d3e8a5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-10.c @@ -0,0 +1,10 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Test #pragma pack diagnostics. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } } */ + +#pragma pack(push) +#pragma pack(pop, \u00f3) /* { dg-warning "pop, \\\\U000000f3.*push, \\\\U000000f3" } */ +#pragma pack(\u00e7) /* { dg-warning "unknown action '\\\\U000000e7'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-11-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-11-utf8.c new file mode 100644 index 0000000000..c6a89bae77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-11-utf8.c @@ -0,0 +1,7 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-skip-if "-fdata-sections not supported" { { hppa*-*-hpux* } && { ! lp64 } } } */ +/* { dg-options "-std=c99 -fdata-sections -g" } */ + +#include "ucnid-3-utf8.c" diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-11.c b/SingleSource/Regression/C/gcc-dg/ucnid-11.c new file mode 100644 index 0000000000..d7b729e598 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-11.c @@ -0,0 +1,7 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-skip-if "-fdata-sections not supported" { { hppa*-*-hpux* } && { ! lp64 } } } */ +/* { dg-options "-std=c99 -fdata-sections -g" } */ + +#include "ucnid-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-12-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-12-utf8.c new file mode 100644 index 0000000000..cfdffba8f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-12-utf8.c @@ -0,0 +1,7 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-skip-if "-ffunction-sections not supported" { { hppa*-*-hpux* } && { ! lp64 } } } */ +/* { dg-options "-std=c99 -ffunction-sections -g" } */ + +#include "ucnid-4-utf8.c" diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-12.c b/SingleSource/Regression/C/gcc-dg/ucnid-12.c new file mode 100644 index 0000000000..987ac1dd48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-12.c @@ -0,0 +1,7 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-skip-if "-ffunction-sections not supported" { { hppa*-*-hpux* } && { ! lp64 } } } */ +/* { dg-options "-std=c99 -ffunction-sections -g" } */ + +#include "ucnid-4.c" diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-13-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-13-utf8.c new file mode 100644 index 0000000000..41536c3a74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-13-utf8.c @@ -0,0 +1,15 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Miscellaneous diagnostics. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wpacked" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } } */ + +int a __attribute__((À)); /* { dg-warning "'\\\\U000000c0' attribute directive ignored" } */ + +extern void à (void) __attribute__((deprecated)); +void g (void) { à (); } /* { dg-warning "'\\\\U000000c1' is deprecated" } */ + +struct  { char c; } __attribute__((packed)); /* { dg-warning "'\\\\U000000c2'" } */ + +void h (void) { asm ("%[Ã]" : : ); } /* { dg-error "undefined named operand '\\\\U000000c3'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-13.c b/SingleSource/Regression/C/gcc-dg/ucnid-13.c new file mode 100644 index 0000000000..2928cd2ed9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-13.c @@ -0,0 +1,15 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Miscellaneous diagnostics. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wpacked" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } } */ + +int a __attribute__((\u00c0)); /* { dg-warning "'\\\\U000000c0' attribute directive ignored" } */ + +extern void \u00c1 (void) __attribute__((deprecated)); +void g (void) { \u00c1 (); } /* { dg-warning "'\\\\U000000c1' is deprecated" } */ + +struct \u00c2 { char c; } __attribute__((packed)); /* { dg-warning "'\\\\U000000c2'" } */ + +void h (void) { asm ("%[\u00c3]" : : ); } /* { dg-error "undefined named operand '\\\\U000000c3'" } */ diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-14-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-14-utf8.c new file mode 100644 index 0000000000..e781ed6b4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-14-utf8.c @@ -0,0 +1,23 @@ +/* Test miscellaneous uses of UTF-8 in identifiers compile and run OK, + with debug info enabled. */ +/* { dg-do run } */ +/* { dg-options "-std=c99 -g" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + struct À { int Ã; } x; + struct À *y = &x; + y->à = 1; + if (x.à != 1) + abort (); + goto ÿ; + ÿ: ; + enum e {  = 4 }; + if ( != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-14.c b/SingleSource/Regression/C/gcc-dg/ucnid-14.c new file mode 100644 index 0000000000..8d4eb71465 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-14.c @@ -0,0 +1,23 @@ +/* Test miscellaneous uses of UCNs in identifiers compile and run OK, + with debug info enabled. */ +/* { dg-do run } */ +/* { dg-options "-std=c99 -g" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + struct \u00C0 { int \u00C1; } x; + struct \u00C0 *y = &x; + y->\u00C1 = 1; + if (x.\U000000C1 != 1) + abort (); + goto \u00ff; + \u00ff: ; + enum e { \u00C2 = 4 }; + if (\u00C2 != 4) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-15-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-15-utf8.c new file mode 100644 index 0000000000..e2336891b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-15-utf8.c @@ -0,0 +1,38 @@ +/* Test combinations of UTF-8 in various parts of identifiers. */ +/* { dg-do run } */ +/* { dg-xfail-if "" { "powerpc-ibm-aix*" } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99" } */ + +extern void abort (void); + +int Ï€ = 3; +int π² = 9; +int Ï€p1 = 4; +int twoÏ€ = 6; +int four_plus_Ï€_ = 7; +int 😀ÀÃÂÃÄÅßàáâãäaÃ¥bæçèéêcëìígîïð7ñ9__òóô4õöÆ3ÇÈÉÊËabcÃŒÃÃŽÃÃÑÒÓÔÕÖ😄😅🤣😂_ÿ = 2; +int Ï€\u03C0 = 9; + +int main() { + if (Ï€ != 3) + abort (); + + if (π² != 9) + abort (); + + if (Ï€p1 != 4) + abort (); + + if (twoÏ€ != 6) + abort (); + + if (four_plus_Ï€_ != 7) + abort () ; + + if (😀ÀÃÂÃÄÅßàáâãäaÃ¥bæçèéêcëìígîïð7ñ9__òóô4õöÆ3ÇÈÉÊËabcÃŒÃÃŽÃÃÑÒÓÔÕÖ😄😅🤣😂_ÿ != 2) + abort (); + + if(ππ != π²) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-16-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-16-utf8.c new file mode 100644 index 0000000000..0b9befa4ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-16-utf8.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-require-iconv "latin1" } */ +/* { dg-options "-std=c99 -g -finput-charset=latin1" } */ +/* { dg-final { scan-file ucnid-16-utf8.s "²" } } */ + +/* This superscript is encoded in latin1; verify that we still get UTF-8 in the output. */ +int x² = 9; diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-2-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-2-utf8.c new file mode 100644 index 0000000000..70f9464638 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-2-utf8.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -g" } */ +void abort (void); + +static int À = 1; +static int à = 2; +static int  = 3; +static int whÿ = 4; +static int aÄbÑδe = 5; + +int main (void) +{ + + if (À != 1) + abort (); + if (à != 2) + abort (); + if ( != 3) + abort (); + if (whÿ != 4) + abort (); + if (aÄbÑδe != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-2.c b/SingleSource/Regression/C/gcc-dg/ucnid-2.c new file mode 100644 index 0000000000..35df3f08a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-2.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -g" } */ +void abort (void); + +static int \u00C0 = 1; +static int \u00C1 = 2; +static int \U000000C2 = 3; +static int wh\u00ff = 4; +static int a\u00c4b\u0441\U000003b4e = 5; + +int main (void) +{ + + if (\u00C0 != 1) + abort (); + if (\u00c1 != 2) + abort (); + if (\u00C2 != 3) + abort (); + if (wh\u00ff != 4) + abort (); + if (a\u00c4b\u0441\U000003b4e != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-3-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-3-utf8.c new file mode 100644 index 0000000000..f8509a6432 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-3-utf8.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -g" } */ +void abort (void); + +int À = 1; +int à = 2; +int  = 3; +int whÿ = 4; +int aÄbÑδe = 5; + +int main (void) +{ + + if (À != 1) + abort (); + if (à != 2) + abort (); + if ( != 3) + abort (); + if (whÿ != 4) + abort (); + if (aÄbÑδe != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-3.c b/SingleSource/Regression/C/gcc-dg/ucnid-3.c new file mode 100644 index 0000000000..746524901c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-3.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -g" } */ +void abort (void); + +int \u00C0 = 1; +int \u00C1 = 2; +int \U000000C2 = 3; +int wh\u00ff = 4; +int a\u00c4b\u0441\U000003b4e = 5; + +int main (void) +{ + + if (\u00C0 != 1) + abort (); + if (\u00c1 != 2) + abort (); + if (\u00C2 != 3) + abort (); + if (wh\u00ff != 4) + abort (); + if (a\u00c4b\u0441\U000003b4e != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-4-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-4-utf8.c new file mode 100644 index 0000000000..bf1c403b48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-4-utf8.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -g" } */ +void abort (void); + +int À(void) { return 1; } +int Ã(void) { return 2; } +int Â(void) { return 3; } +int whÿ(void) { return 4; } +int aÄbÑδe(void) { return 5; } + +int main (void) +{ + + if (À() != 1) + abort (); + if (Ã() != 2) + abort (); + if (Â() != 3) + abort (); + if (whÿ() != 4) + abort (); + if (aÄbÑδe() != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-4.c b/SingleSource/Regression/C/gcc-dg/ucnid-4.c new file mode 100644 index 0000000000..c8e61c302a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-4.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -g" } */ +void abort (void); + +int \u00C0(void) { return 1; } +int \u00C1(void) { return 2; } +int \U000000C2(void) { return 3; } +int wh\u00ff(void) { return 4; } +int a\u00c4b\u0441\U000003b4e(void) { return 5; } + +int main (void) +{ + + if (\u00C0() != 1) + abort (); + if (\u00c1() != 2) + abort (); + if (\u00C2() != 3) + abort (); + if (wh\u00ff() != 4) + abort (); + if (a\u00c4b\u0441\U000003b4e() != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-5-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-5-utf8.c new file mode 100644 index 0000000000..43310b6ada --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-5-utf8.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-skip-if "No dollar in identifiers" { avr-*-* powerpc-ibm-aix* } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -fdollars-in-identifiers -g" } */ +void abort (void); + +int a$b(void) { return 1; } +int a$b😀(void) { return 2; } + +int main (void) +{ + + if (a$b() != 1) + abort (); + + if (a$b😀() != 2) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-5.c b/SingleSource/Regression/C/gcc-dg/ucnid-5.c new file mode 100644 index 0000000000..6f0f475303 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-5.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-skip-if "No dollar in identifiers" { avr-*-* powerpc-ibm-aix* } } */ +/* { dg-options "-std=c99 -fdollars-in-identifiers -g" } */ +void abort (void); + +int a$b(void) { return 1; } + +int main (void) +{ + + if (a\u0024b() != 1) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-6-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-6-utf8.c new file mode 100644 index 0000000000..36ce52bc57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-6-utf8.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { "powerpc-ibm-aix*" } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -save-temps -g" } */ +void abort (void); + +int À(void) { return 1; } +int Ã(void) { return 2; } +int Â(void) { return 3; } +int whÿ(void) { return 4; } +int aÄbÑδe(void) { return 5; } + +int main (void) +{ + + if (À() != 1) + abort (); + if (Ã() != 2) + abort (); + if (Â() != 3) + abort (); + if (whÿ() != 4) + abort (); + if (aÄbÑδe() != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-6.c b/SingleSource/Regression/C/gcc-dg/ucnid-6.c new file mode 100644 index 0000000000..a6f4fd4c11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-6.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-xfail-if "" { "powerpc-ibm-aix*" } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -save-temps -g" } */ +void abort (void); + +int \u00C0(void) { return 1; } +int \u00C1(void) { return 2; } +int \U000000C2(void) { return 3; } +int wh\u00ff(void) { return 4; } +int a\u00c4b\u0441\U000003b4e(void) { return 5; } + +int main (void) +{ + + if (\u00C0() != 1) + abort (); + if (\u00c1() != 2) + abort (); + if (\u00C2() != 3) + abort (); + if (wh\u00ff() != 4) + abort (); + if (a\u00c4b\u0441\U000003b4e() != 5) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-7-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-7-utf8.c new file mode 100644 index 0000000000..07f5ca0f9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-7-utf8.c @@ -0,0 +1,9 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { "powerpc-ibm-aix*" } } */ + +void *p = &é; /* { dg-error "'\\\\U000000e9' undeclared" } */ +void *q = &Ḁ; /* { dg-error "'\\\\U00001e00' undeclared" } */ diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-7.c b/SingleSource/Regression/C/gcc-dg/ucnid-7.c new file mode 100644 index 0000000000..fe265af7f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-7.c @@ -0,0 +1,9 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { "powerpc-ibm-aix*" } } */ + +void *p = &\u00e9; /* { dg-error "'\\\\U000000e9' undeclared" } */ +void *q = &\u1e00; /* { dg-error "'\\\\U00001e00' undeclared" } */ diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-8-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-8-utf8.c new file mode 100644 index 0000000000..e6c440d977 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-8-utf8.c @@ -0,0 +1,16 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Further tests of C front-end diagnostics. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wvla" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } } */ + +int a __attribute__((__mode__(é))); /* { dg-error "unknown machine mode '\\\\U000000e9'" } */ +struct s1 { int é : 0; }; /* { dg-error "zero width for bit-field '\\\\U000000e9'" } */ + +void f (int b) { int é[b]; } /* { dg-warning "variable length array '\\\\U000000e9'" } */ + +void g (static int é); /* { dg-error "storage class specified for parameter '\\\\U000000e9'" } */ + +struct s2 { int á; } é = { { 0 } }; /* { dg-warning "braces around scalar initializer" } */ +/* { dg-message "near initialization for '\\\\U000000e9\\.\\\\U000000e1'" "UCN diag" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-8.c b/SingleSource/Regression/C/gcc-dg/ucnid-8.c new file mode 100644 index 0000000000..369b86a5d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-8.c @@ -0,0 +1,16 @@ +/* Verify diagnostics for extended identifiers refer to UCNs (in the C + locale). Further tests of C front-end diagnostics. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wvla" } */ +/* { dg-require-ascii-locale "" } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } } */ + +int a __attribute__((__mode__(\u00e9))); /* { dg-error "unknown machine mode '\\\\U000000e9'" } */ +struct s1 { int \u00e9 : 0; }; /* { dg-error "zero width for bit-field '\\\\U000000e9'" } */ + +void f (int b) { int \u00e9[b]; } /* { dg-warning "variable length array '\\\\U000000e9'" } */ + +void g (static int \u00e9); /* { dg-error "storage class specified for parameter '\\\\U000000e9'" } */ + +struct s2 { int \u00e1; } \u00e9 = { { 0 } }; /* { dg-warning "braces around scalar initializer" } */ +/* { dg-message "near initialization for '\\\\U000000e9\\.\\\\U000000e1'" "UCN diag" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-9-utf8.c b/SingleSource/Regression/C/gcc-dg/ucnid-9-utf8.c new file mode 100644 index 0000000000..c9371966da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-9-utf8.c @@ -0,0 +1,25 @@ +/* Test __func__ with extended identifiers and character set + conversions. */ +/* { dg-do run } */ +/* { dg-xfail-if "" { "powerpc-ibm-aix*" } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -fexec-charset=ISO-8859-1 -g" } */ +/* { dg-require-iconv "ISO-8859-1" } */ + +extern int strcmp (const char *, const char *); +extern void abort (void); +extern void exit (int); + +void +é (void) +{ + if (strcmp (__func__, "é") != 0) + abort (); +} + +int +main (void) +{ + é (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/ucnid-9.c b/SingleSource/Regression/C/gcc-dg/ucnid-9.c new file mode 100644 index 0000000000..ac61c92117 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/ucnid-9.c @@ -0,0 +1,25 @@ +/* Test __func__ with extended identifiers and character set + conversions. */ +/* { dg-do run } */ +/* { dg-xfail-if "" { "powerpc-ibm-aix*" } } */ +/* { dg-skip-if "" { ! ucn } } */ +/* { dg-options "-std=c99 -fexec-charset=ISO-8859-1 -g" } */ +/* { dg-require-iconv "ISO-8859-1" } */ + +extern int strcmp (const char *, const char *); +extern void abort (void); +extern void exit (int); + +void +\u00e9 (void) +{ + if (strcmp (__func__, "\u00e9") != 0) + abort (); +} + +int +main (void) +{ + \u00e9 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/unaligned-1.c b/SingleSource/Regression/C/gcc-dg/unaligned-1.c new file mode 100644 index 0000000000..5df1b37e36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unaligned-1.c @@ -0,0 +1,49 @@ +/* PR middle-end/7847 */ +/* Originator: */ +/* { dg-do run } */ + +/* This used to fail on SPARC at runtime because of + an unaligned memory access. */ + +typedef char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; + +typedef struct { + uint32_t address; + uint16_t size; +} __attribute__ ((packed)) sml_agl_data_t; + +typedef struct { + sml_agl_data_t data[9]; +} __attribute__ ((packed)) sml_agli_t; + +typedef struct { + sml_agli_t sml_agli; +} __attribute__ ((packed)) dsi_t; + +typedef struct { + int a; + dsi_t dsi_pack; +} dvd_priv_t; + +int dvd_read_sector(dvd_priv_t *d, unsigned char* data) +{ + int i, skip=0; + + for (i=0; i < 9; i++) + if ((skip=d->dsi_pack.sml_agli.data[i].address) != 0) + break; + + return skip; +} + +int main(void) +{ + static dvd_priv_t dvd_priv; + dvd_read_sector(&dvd_priv, 0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/unclosed-init.c b/SingleSource/Regression/C/gcc-dg/unclosed-init.c new file mode 100644 index 0000000000..0a0ca21840 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unclosed-init.c @@ -0,0 +1,3 @@ +int unclosed[] = { /* { dg-message "18: to match this '.'" } */ + 42 + /* { dg-error "-: expected '.' at end of input" "" { target *-*-* } .+1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/uninit-1-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-1-O0.c new file mode 100644 index 0000000000..4fe5d6b111 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-1-O0.c @@ -0,0 +1,30 @@ +/* Spurious uninitialized variable warnings, case 1. + Taken from cppfiles.c (merge_include_chains) */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +struct list +{ + struct list *next; + int id; +}; + +extern void free (void *); + +void remove_dupes (struct list *el) +{ + struct list *p, *q, *r; /* { dg-bogus "r" "uninitialized variable warning" } */ + + for (p = el; p; p = p->next) + { + for (q = el; q != p; q = q->next) + if (q->id == p->id) + { + r->next = p->next; + free (p); + p = r; + break; + } + r = p; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-1.c b/SingleSource/Regression/C/gcc-dg/uninit-1.c new file mode 100644 index 0000000000..060ec250ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-1.c @@ -0,0 +1,30 @@ +/* Spurious uninitialized variable warnings, case 1. + Taken from cppfiles.c (merge_include_chains) */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +struct list +{ + struct list *next; + int id; +}; + +extern void free (void *); + +void remove_dupes (struct list *el) +{ + struct list *p, *q, *r; /* { dg-bogus "r" "uninitialized variable warning" } */ + + for (p = el; p; p = p->next) + { + for (q = el; q != p; q = q->next) + if (q->id == p->id) + { + r->next = p->next; + free (p); + p = r; + break; + } + r = p; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-10-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-10-O0.c new file mode 100644 index 0000000000..f761ac91c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-10-O0.c @@ -0,0 +1,109 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ +/* On Alpha EV4, dead code elimination and cfg simplification conspired + to leave the register containing 'C' marked live, though all references + to the variable had been removed. */ + +struct operand_data +{ + struct operand_data *next; + int index; + const char *predicate; + const char *constraint; + int mode; + unsigned char n_alternatives; + char address_p; + char strict_low; + char eliminable; + char seen; +}; + +struct data +{ + struct data *next; + const char *name; + const char *template; + int code_number; + int index_number; + int lineno; + int n_operands; + int n_dups; + int n_alternatives; + int operand_number; + int output_format; + struct operand_data operand[40]; +}; + +extern void message_with_line (int, const char *, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +extern int have_error; + +extern char *strchr (__const char *__s, int __c) __attribute__ ((__pure__)); + +void +validate_insn_alternatives (d) + struct data *d; +{ + int n = 0, start; + + for (start = 0; start < d->n_operands; start++) + if (d->operand[start].n_alternatives > 0) + { + int len, i; + const char *p; + char c; /* { dg-bogus "used uninitialized" "uninitialized variable warning" } */ + int which_alternative = 0; + int alternative_count_unsure = 0; + + for (p = d->operand[start].constraint; (c = *p); p += len) + { + len = 1; + + if (len < 1 || (len > 1 && strchr (",#*+=&%!0123456789", c))) + { + message_with_line (d->lineno, + "invalid length %d for char '%c' in alternative %d of operand %d", + len, c, which_alternative, start); + len = 1; + have_error = 1; + } + + if (c == ',') + { + which_alternative++; + continue; + } + + for (i = 1; i < len; i++) + if (p[i] == '\0') + { + message_with_line (d->lineno, + "NUL in alternative %d of operand %d", + which_alternative, start); + alternative_count_unsure = 1; + break; + } + else if (strchr (",#*", p[i])) + { + message_with_line (d->lineno, + "'%c' in alternative %d of operand %d", + p[i], which_alternative, start); + alternative_count_unsure = 1; + } + } + if (alternative_count_unsure) + have_error = 1; + else if (n == 0) + n = d->operand[start].n_alternatives; + else if (n != d->operand[start].n_alternatives) + { + message_with_line (d->lineno, + "wrong number of alternatives in operand %d", + start); + have_error = 1; + } + } + + + d->n_alternatives = n; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-10.c b/SingleSource/Regression/C/gcc-dg/uninit-10.c new file mode 100644 index 0000000000..0d62020df9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-10.c @@ -0,0 +1,109 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ +/* On Alpha EV4, dead code elimination and cfg simplification conspired + to leave the register containing 'C' marked live, though all references + to the variable had been removed. */ + +struct operand_data +{ + struct operand_data *next; + int index; + const char *predicate; + const char *constraint; + int mode; + unsigned char n_alternatives; + char address_p; + char strict_low; + char eliminable; + char seen; +}; + +struct data +{ + struct data *next; + const char *name; + const char *template; + int code_number; + int index_number; + int lineno; + int n_operands; + int n_dups; + int n_alternatives; + int operand_number; + int output_format; + struct operand_data operand[40]; +}; + +extern void message_with_line (int, const char *, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +extern int have_error; + +extern char *strchr (__const char *__s, int __c) __attribute__ ((__pure__)); + +void +validate_insn_alternatives (d) + struct data *d; +{ + int n = 0, start; + + for (start = 0; start < d->n_operands; start++) + if (d->operand[start].n_alternatives > 0) + { + int len, i; + const char *p; + char c; /* { dg-bogus "used uninitialized" "uninitialized variable warning" } */ + int which_alternative = 0; + int alternative_count_unsure = 0; + + for (p = d->operand[start].constraint; (c = *p); p += len) + { + len = 1; + + if (len < 1 || (len > 1 && strchr (",#*+=&%!0123456789", c))) + { + message_with_line (d->lineno, + "invalid length %d for char '%c' in alternative %d of operand %d", + len, c, which_alternative, start); + len = 1; + have_error = 1; + } + + if (c == ',') + { + which_alternative++; + continue; + } + + for (i = 1; i < len; i++) + if (p[i] == '\0') + { + message_with_line (d->lineno, + "NUL in alternative %d of operand %d", + which_alternative, start); + alternative_count_unsure = 1; + break; + } + else if (strchr (",#*", p[i])) + { + message_with_line (d->lineno, + "'%c' in alternative %d of operand %d", + p[i], which_alternative, start); + alternative_count_unsure = 1; + } + } + if (alternative_count_unsure) + have_error = 1; + else if (n == 0) + n = d->operand[start].n_alternatives; + else if (n != d->operand[start].n_alternatives) + { + message_with_line (d->lineno, + "wrong number of alternatives in operand %d", + start); + have_error = 1; + } + } + + + d->n_alternatives = n; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-11-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-11-O0.c new file mode 100644 index 0000000000..23af4f69aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-11-O0.c @@ -0,0 +1,42 @@ +/* Positive test for uninitialized variables. */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +int sink; + +void f1(int parm) /* { dg-bogus "uninitialized" "parameter" } */ +{ + sink = parm; /* { dg-bogus "uninitialized" "parameter" } */ +} + +void f2(void) +{ + int x; + sink = x; /* { dg-warning "is used" "unconditional" } */ +} + +void f3(int p) +{ + int x; /* { dg-warning "may be used" "conditional" { xfail *-*-* } } */ + if (p) + x = p; + sink = x; +} + +void f4(int p) +{ + int x; /* { dg-bogus "uninitialized" "easy if" } */ + if (p) + x = 1; + else + x = 2; + sink = x; +} + +void f5(void) +{ + int x, i; /* { dg-bogus "uninitialized" "easy loop" } */ + for (i = 0; i < 10; ++i) + x = 1; + sink = x; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-11.c b/SingleSource/Regression/C/gcc-dg/uninit-11.c new file mode 100644 index 0000000000..2730534e90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-11.c @@ -0,0 +1,42 @@ +/* Positive test for uninitialized variables. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +int sink; + +void f1(int parm) /* { dg-bogus "uninitialized" "parameter" } */ +{ + sink = parm; /* { dg-bogus "uninitialized" "parameter" } */ +} + +void f2(void) +{ + int x; + sink = x; /* { dg-warning "is used" "unconditional" } */ +} + +void f3(int p) +{ + int x; + if (p) + x = p; + sink = x; /* { dg-warning "may be used" "conditional" } */ +} + +void f4(int p) +{ + int x; /* { dg-bogus "uninitialized" "easy if" } */ + if (p) + x = 1; + else + x = 2; + sink = x; +} + +void f5(void) +{ + int x, i; /* { dg-bogus "uninitialized" "easy loop" } */ + for (i = 0; i < 10; ++i) + x = 1; + sink = x; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-12-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-12-O0.c new file mode 100644 index 0000000000..7c0664e4df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-12-O0.c @@ -0,0 +1,12 @@ +/* PR 23497 */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +typedef _Complex float C; +C foo() +{ + C f; + __real__ f = 0; + __imag__ f = 0; + return f; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-12.c b/SingleSource/Regression/C/gcc-dg/uninit-12.c new file mode 100644 index 0000000000..7889e5370e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-12.c @@ -0,0 +1,12 @@ +/* PR 23497 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +typedef _Complex float C; +C foo() +{ + C f; + __real__ f = 0; + __imag__ f = 0; + return f; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-13-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-13-O0.c new file mode 100644 index 0000000000..af80fa88ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-13-O0.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +typedef _Complex float C; +C foo() +{ + C f; + __imag__ f = 0; /* { dg-warning "is used" "unconditional" { xfail *-*-* } } */ + return f; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-13.c b/SingleSource/Regression/C/gcc-dg/uninit-13.c new file mode 100644 index 0000000000..5e88a8a945 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-13.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +typedef _Complex float C; +C foo() +{ + C f; + __imag__ f = 0; + return f; /* { dg-warning "is used" "unconditional" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-14-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-14-O0.c new file mode 100644 index 0000000000..abde6ca86e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-14-O0.c @@ -0,0 +1,20 @@ +/* PR 24931 */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +struct p { + short x, y; +}; + +struct s { + int i; + struct p p; +}; + +struct s f() +{ + struct s s; + s.p = (struct p){}; + s.i = (s.p.x || s.p.y); + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-14.c b/SingleSource/Regression/C/gcc-dg/uninit-14.c new file mode 100644 index 0000000000..41b4f622ae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-14.c @@ -0,0 +1,20 @@ +/* PR 24931 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +struct p { + short x, y; +}; + +struct s { + int i; + struct p p; +}; + +struct s f() +{ + struct s s; + s.p = (struct p){}; + s.i = (s.p.x || s.p.y); + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-15-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-15-O0.c new file mode 100644 index 0000000000..1ddddee138 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-15-O0.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +/* XFAIL for now, the uninitialized pass runs before inlining only at -O0. */ + +inline int __attribute__((always_inline)) +foo (int i) +{ + if (i) return 1; /* { dg-warning "is used uninitialized" {} { xfail *-*-* } } */ + return 0; +} + +void baz(); + +void bar() +{ + int j; /* { dg-message "declared here" } */ + for (; foo(j); ++j) /* { dg-warning "is used uninitialized" } */ + baz(); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-15.c b/SingleSource/Regression/C/gcc-dg/uninit-15.c new file mode 100644 index 0000000000..7352662f62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-15.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/17506 + We used to 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) + But it is of course ok if we warn in bar about uninitialized use + of j. (not xfailed alternative) */ +/* { dg-do compile } */ +/* { dg-options "-O1 -Wuninitialized" } */ + +inline int +foo (int i) +{ + if (i) /* { dg-warning "used uninitialized" "" { xfail *-*-* } } */ + return 1; + return 0; +} + +void baz (void); + +void +bar (void) +{ + int j; /* { dg-message "note: 'j' was declared here" } */ + for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" } */ + baz (); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-16.c b/SingleSource/Regression/C/gcc-dg/uninit-16.c new file mode 100644 index 0000000000..e039f70261 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-16.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int foo, bar; + +static +void decode_reloc(int reloc, int *is_alt) +{ + if (reloc >= 20) + *is_alt = 1; + else if (reloc >= 10) + *is_alt = 0; +} + +void testfunc() +{ + int alt_reloc; + + decode_reloc(foo, &alt_reloc); + + if (alt_reloc) /* { dg-warning "may be used uninitialized" } */ + bar = 42; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-17-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-17-O0.c new file mode 100644 index 0000000000..0eaef05336 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-17-O0.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +typedef _Complex float C; +C foo(int cond) +{ + C f; + __imag__ f = 0; + if (cond) + { + __real__ f = 1; + return f; + } + return f; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-17.c b/SingleSource/Regression/C/gcc-dg/uninit-17.c new file mode 100644 index 0000000000..8a95f15c5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-17.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +typedef _Complex float C; +C foo(int cond) +{ + C f; + __imag__ f = 0; + if (cond) + { + __real__ f = 1; + return f; + } + return f; /* { dg-warning "may be used" "unconditional" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-18.c b/SingleSource/Regression/C/gcc-dg/uninit-18.c new file mode 100644 index 0000000000..223983e107 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-18.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +char *foo(int bar, char *baz) +{ + char *tmp; + + if (bar & 3) + tmp = baz; + + switch (bar) { + case 1: + tmp[5] = 7; /* { dg-bogus "may be used uninitialized" } */ + break; + case 2: + tmp[11] = 15; /* { dg-bogus "may be used uninitialized" } */ + break; + default: + tmp = 0; + break; + } + + return tmp; /* { dg-bogus "may be used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-19.c b/SingleSource/Regression/C/gcc-dg/uninit-19.c new file mode 100644 index 0000000000..a54e60d37c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-19.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ +/* { dg-additional-options "-finline-small-functions" { target avr-*-* } } */ + +int a, l, m; +float *b; +float c, d, e, g, h; +unsigned char i, k; +void +fn1 (int p1, float *f1, float *f2, float *f3, unsigned char *c1, float *f4, + unsigned char *c2, float *p10) +{ + if (p1 & 8) + b[3] = p10[a]; + /* { dg-warning "may be used uninitialized" "" { target { { nonpic || pie_enabled } || { hppa*64*-*-* *-*-darwin* } } } .-1 } */ +} + +void +fn2 () +{ + float *n; + if (l & 6) + n = &c + m; + fn1 (l, &d, &e, &g, &i, &h, &k, n); + /* { dg-warning "may be used uninitialized" "" { target { ! { { nonpic || pie_enabled } || { hppa*64*-*-* *-*-darwin* } } } } .-1 } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-2-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-2-O0.c new file mode 100644 index 0000000000..62a23fa6b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-2-O0.c @@ -0,0 +1,52 @@ +/* Spurious uninitialized variable warnings, case 2. + Taken from cpphash.c (macroexpand) */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +struct definition +{ + int nargs; + int rest_args; +}; + +struct cpp_reader; + +enum cpp_token +{ + CPP_EOF, CPP_POP, CPP_COMMA, CPP_RPAREN +}; + +extern enum cpp_token macarg (struct cpp_reader *, int); + +void +macroexpand (struct cpp_reader *pfile, struct definition *defn) +{ + int nargs = defn->nargs; + + if (nargs >= 0) + { + enum cpp_token token; /* { dg-bogus "token" "uninitialized variable warning" } */ + int i, rest_args; + i = 0; + rest_args = 0; + do + { + if (rest_args) + continue; + if (i < nargs || (nargs == 0 && i == 0)) + { + /* if we are working on last arg which absorbs rest of args... */ + if (i == nargs - 1 && defn->rest_args) + rest_args = 1; + token = macarg (pfile, rest_args); + } + else + token = macarg (pfile, 0); + if (token == CPP_EOF || token == CPP_POP) + return; + + i++; + } + while (token == CPP_COMMA); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-2.c b/SingleSource/Regression/C/gcc-dg/uninit-2.c new file mode 100644 index 0000000000..352bbac06c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-2.c @@ -0,0 +1,52 @@ +/* Spurious uninitialized variable warnings, case 2. + Taken from cpphash.c (macroexpand) */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +struct definition +{ + int nargs; + int rest_args; +}; + +struct cpp_reader; + +enum cpp_token +{ + CPP_EOF, CPP_POP, CPP_COMMA, CPP_RPAREN +}; + +extern enum cpp_token macarg (struct cpp_reader *, int); + +void +macroexpand (struct cpp_reader *pfile, struct definition *defn) +{ + int nargs = defn->nargs; + + if (nargs >= 0) + { + enum cpp_token token; /* { dg-bogus "token" "uninitialized variable warning" } */ + int i, rest_args; + i = 0; + rest_args = 0; + do + { + if (rest_args) + continue; + if (i < nargs || (nargs == 0 && i == 0)) + { + /* if we are working on last arg which absorbs rest of args... */ + if (i == nargs - 1 && defn->rest_args) + rest_args = 1; + token = macarg (pfile, rest_args); + } + else + token = macarg (pfile, 0); + if (token == CPP_EOF || token == CPP_POP) + return; + + i++; + } + while (token == CPP_COMMA); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-20.c b/SingleSource/Regression/C/gcc-dg/uninit-20.c new file mode 100644 index 0000000000..12001aee99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-20.c @@ -0,0 +1,18 @@ +/* Spurious uninitialized variable warnings, from gdb */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ +struct os { struct o *o; }; +struct o { struct o *next; struct os *se; }; +void f(struct o *o){ + struct os *s; + if(o) s = o->se; + while(o && s == o->se){ + s++; // here `o' is non-zero and thus s is initialized + s == o->se // `?' is essential, `if' does not trigger the warning + ? (o = o->next, o ? s = o->se : 0) + : 0; + } +} + + + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-21.c b/SingleSource/Regression/C/gcc-dg/uninit-21.c new file mode 100644 index 0000000000..34e84bd0af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-21.c @@ -0,0 +1,33 @@ +/* PR69537, spurious warning because of a missed optimization. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-short-enums -Wuninitialized" } */ + +enum clnt_stat { + RPC_SUCCESS=0, + RPC_CANTENCODEARGS=1, +}; + +int do_ypcall_tr (); + +static int +yp_master (char **outname) +{ + // Replacing enum clnt_stat with int avoids the warning. + enum clnt_stat result; + result = do_ypcall_tr (); + if (result != 0) + return result; + *outname = __builtin_strdup ("foo"); + return 0; +} + +int +yp_update (void) +{ + char *master; + int r; + if ((r = yp_master (&master)) != 0) + return r; + __builtin_free (master); /* { dg-bogus "uninitialized" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-22.c b/SingleSource/Regression/C/gcc-dg/uninit-22.c new file mode 100644 index 0000000000..37d1071c75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-22.c @@ -0,0 +1,69 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wuninitialized --param vect-max-version-for-alias-checks=20" } */ + +#include + +#define A1 2896 /* (1/sqrt(2))<<12 */ +#define A2 2217 +#define A3 3784 +#define A4 -5352 + +#define IDCT_TRANSFORM(dest,s0,s1,s2,s3,s4,s5,s6,s7,d0,d1,d2,d3,d4,d5,d6,d7,munge,src) {\ + const int a0 = (src)[s0] + (src)[s4]; \ + const int a1 = (src)[s0] - (src)[s4]; \ + const int a2 = (src)[s2] + (src)[s6]; \ + const int a3 = (A1*((src)[s2] - (src)[s6])) >> 11; \ + const int a4 = (src)[s5] + (src)[s3]; \ + const int a5 = (src)[s5] - (src)[s3]; \ + const int a6 = (src)[s1] + (src)[s7]; \ + const int a7 = (src)[s1] - (src)[s7]; \ + const int b0 = a4 + a6; \ + const int b1 = (A3*(a5 + a7)) >> 11; \ + const int b2 = ((A4*a5) >> 11) - b0 + b1; \ + const int b3 = (A1*(a6 - a4) >> 11) - b2; \ + const int b4 = ((A2*a7) >> 11) + b3 - b1; \ + (dest)[d0] = munge(a0+a2 +b0); \ + (dest)[d1] = munge(a1+a3-a2+b2); \ + (dest)[d2] = munge(a1-a3+a2+b3); \ + (dest)[d3] = munge(a0-a2 -b4); \ + (dest)[d4] = munge(a0-a2 +b4); \ + (dest)[d5] = munge(a1-a3+a2-b3); \ + (dest)[d6] = munge(a1+a3-a2-b2); \ + (dest)[d7] = munge(a0+a2 -b0); \ +} + +#define MUNGE_NONE(x) (x) +#define IDCT_COL(dest,src) IDCT_TRANSFORM(dest,0,8,16,24,32,40,48,56,0,8,16,24,32,40,48,56,MUNGE_NONE,src) + +#define MUNGE_ROW(x) (((x) + 0x7F)>>8) +#define IDCT_ROW(dest,src) IDCT_TRANSFORM(dest,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,MUNGE_ROW,src) + +static inline void bink_idct_col(int *dest, const int32_t *src) +{ + if ((src[8]|src[16]|src[24]|src[32]|src[40]|src[48]|src[56])==0) { + dest[0] = + dest[8] = + dest[16] = + dest[24] = + dest[32] = + dest[40] = + dest[48] = + dest[56] = src[0]; + } else { + IDCT_COL(dest, src); + } +} + +int bink_idct_put_c(uint8_t *dest, int linesize, int32_t *block) +{ + int i; + int temp[64]; + for (i = 0; i < 8; i++) + bink_idct_col(&temp[i], &block[i]); + for (i = 0; i < 8; i++) { + IDCT_ROW( (&dest[i*linesize]), (&temp[8*i]) ); + } + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-23.c b/SingleSource/Regression/C/gcc-dg/uninit-23.c new file mode 100644 index 0000000000..87b4e989b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-23.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/78455 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int ij; + +void +ql (void) +{ + int m5 = 0; + + for (;;) + { + if (0) + for (;;) + { + int *go; + int *t4 = go; /* { dg-warning "is used uninitialized" } */ + + l1: + *t4 = (*t4 != 0) ? 0 : 2; /* { dg-warning "is used uninitialized" } */ + } + + if (ij != 0) + goto l1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-24.c b/SingleSource/Regression/C/gcc-dg/uninit-24.c new file mode 100644 index 0000000000..30fe1e510f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-24.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized" } */ + +int foo (int x) +{ + int y; + if (x) + return *(&y + 1); /* { dg-bogus "may be used uninitialized" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-25-gimple.c b/SingleSource/Regression/C/gcc-dg/uninit-25-gimple.c new file mode 100644 index 0000000000..0c0acd6b83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-25-gimple.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O -Wmaybe-uninitialized" } */ + +unsigned int __GIMPLE (ssa,startwith("uninit1")) +foo (unsigned int v) +{ + unsigned int undef; /* { dg-warning "may be used uninitialized" } */ + unsigned int _2; + unsigned int _9; + unsigned int _10; + + __BB(2): + if (v_4(D) != 1u) + goto __BB3; + else + goto __BB4; + + __BB(3): + undef_8 = 8u; // 'undef' is defined conditionally (under 'v != 1' predicate) + goto __BB4; + + __BB(4): + // An undef value flows into a phi. + undef_1 = __PHI (__BB2: undef_5(D), __BB3: undef_8); + if (v_4(D) != 2u) // This condition is neither a superset nor a subset of 'v != 1'. + goto __BB5; + else + goto __BB6; + + __BB(5): + _9 = undef_1; // The phi value is used here (under 'v != 2' predicate). + goto __BB7; + + __BB(6): + _10 = v_4(D); + goto __BB7; + + __BB(7): + _2 = __PHI (__BB5: _9, __BB6: _10); + return _2; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-25.c b/SingleSource/Regression/C/gcc-dg/uninit-25.c new file mode 100644 index 0000000000..ffffce3f91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-25.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized" } */ + +extern unsigned bar (void); +extern void quux (void); + +unsigned foo (unsigned v) +{ + unsigned u; + if (v != 1) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 1) is false then (v != 2) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + if (v != 2) + return u; /* { dg-warning "may be used uninitialized" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-26.c b/SingleSource/Regression/C/gcc-dg/uninit-26.c new file mode 100644 index 0000000000..60ac48cdc5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-26.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized" } */ + +extern unsigned bar (void); +extern void quux (void); + +unsigned foo (unsigned v) +{ + unsigned u; + if (v != 100) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 100) is false then (v < 105) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + if (v < 105) /* v == 100 falls into this range. */ + return u; /* { dg-warning "may be used uninitialized" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-27-gimple.c b/SingleSource/Regression/C/gcc-dg/uninit-27-gimple.c new file mode 100644 index 0000000000..f75469d8ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-27-gimple.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O -Wmaybe-uninitialized" } */ + +unsigned int __GIMPLE (ssa,startwith("uninit1")) +foo (unsigned int v) +{ + unsigned int undef; /* { dg-bogus "may be used uninitialized" } */ + unsigned int _2; + unsigned int _9; + unsigned int _10; + + __BB(2): + if (v_4(D) != 100u) + goto __BB3; + else + goto __BB4; + + __BB(3): + undef_8 = 8u; // 'undef' is defined conditionally (under 'v != 100' predicate) + goto __BB4; + + __BB(4): + // An undef value flows into a phi. + undef_1 = __PHI (__BB2: undef_5(D), __BB3: undef_8); + if (v_4(D) < 100u) + goto __BB5; + else + goto __BB6; + + __BB(5): + _9 = undef_1; // The phi value is used here (under 'v < 100' predicate). + goto __BB7; + + __BB(6): + _10 = v_4(D); + goto __BB7; + + __BB(7): + _2 = __PHI (__BB5: _9, __BB6: _10); + return _2; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-28-gimple.c b/SingleSource/Regression/C/gcc-dg/uninit-28-gimple.c new file mode 100644 index 0000000000..0648b8a4aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-28-gimple.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O -Wmaybe-uninitialized" } */ + +unsigned int __GIMPLE (ssa,startwith("uninit1")) +foo (unsigned int v) +{ + /* Uninit warning here would be bogus, because (16 & 3) == 0 and therefore + if v == 16, the uninit value is not used (the use is properly guarded). */ + unsigned int undef; /* { dg-bogus "may be used uninitialized" } */ + unsigned int _2; + unsigned int _9; + unsigned int _10; + unsigned pred; + + __BB(2): + if (v_4(D) != 16u) + goto __BB3; + else + goto __BB4; + + /* 'undef' is defined conditionally (under 'v != 16' predicate) */ + __BB(3): + undef_8 = 8u; + goto __BB4; + + /* An undef value flows into a phi. */ + __BB(4): + undef_1 = __PHI (__BB2: undef_5(D), __BB3: undef_8); + pred = v_4(D) & 3u; + if (pred != 0u) + goto __BB5; + else + goto __BB6; + + /* The phi value is used here (under 'v & 3' predicate). */ + __BB(5): + _9 = undef_1; + goto __BB7; + + __BB(6): + _10 = v_4(D); + goto __BB7; + + __BB(7): + _2 = __PHI (__BB5: _9, __BB6: _10); + return _2; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-29-gimple.c b/SingleSource/Regression/C/gcc-dg/uninit-29-gimple.c new file mode 100644 index 0000000000..cb5bc97164 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-29-gimple.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O -Wmaybe-uninitialized" } */ + +unsigned int __GIMPLE (ssa,startwith("uninit1")) +foo (unsigned int v) +{ + unsigned int undef; /* { dg-warning "may be used uninitialized" } */ + unsigned int _2; + unsigned int _9; + unsigned int _10; + unsigned pred; + + __BB(2): + pred = v_4(D) & 3u; + if (pred != 0u) + goto __BB3; + else + goto __BB4; + + /* 'undef' is defined conditionally (under 'v & 3' predicate) */ + __BB(3): + undef_8 = 8u; + goto __BB4; + + /* An undef value flows into a phi. */ + __BB(4): + undef_1 = __PHI (__BB2: undef_5(D), __BB3: undef_8); + if (v_4(D) != 16u) + goto __BB5; + else + goto __BB6; + + /* The phi value is used here (under 'v != 16' predicate). */ + __BB(5): + _9 = undef_1; + goto __BB7; + + __BB(6): + _10 = v_4(D); + goto __BB7; + + __BB(7): + _2 = __PHI (__BB5: _9, __BB6: _10); + return _2; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-3-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-3-O0.c new file mode 100644 index 0000000000..d3dcf14ede --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-3-O0.c @@ -0,0 +1,33 @@ +/* Spurious uninit variable warnings, case 3. + Inspired by cppexp.c (parse_charconst) */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +extern void error (char *); + +int +parse_charconst (const char *start, const char *end) +{ + int c; /* { dg-bogus "c" "uninitialized variable warning" } */ + int nchars, retval; + + nchars = 0; + retval = 0; + while (start < end) + { + c = *start++; + if (c == '\'') + break; + nchars++; + retval += c; + retval <<= 8; + } + + if (nchars == 0) + return 0; + + if (c != '\'') + error ("malformed character constant"); + + return retval; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-3.c b/SingleSource/Regression/C/gcc-dg/uninit-3.c new file mode 100644 index 0000000000..ac5bfec8e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-3.c @@ -0,0 +1,33 @@ +/* Spurious uninit variable warnings, case 3. + Inspired by cppexp.c (parse_charconst) */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +extern void error (char *); + +int +parse_charconst (const char *start, const char *end) +{ + int c; /* { dg-bogus "c" "uninitialized variable warning" } */ + int nchars, retval; + + nchars = 0; + retval = 0; + while (start < end) + { + c = *start++; + if (c == '\'') + break; + nchars++; + retval += c; + retval <<= 8; + } + + if (nchars == 0) + return 0; + + if (c != '\'') + error ("malformed character constant"); + + return retval; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-30-gimple.c b/SingleSource/Regression/C/gcc-dg/uninit-30-gimple.c new file mode 100644 index 0000000000..8c91f79d50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-30-gimple.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O -Wmaybe-uninitialized" } */ + +unsigned int __GIMPLE (ssa,startwith("uninit1")) +foo (unsigned int v) +{ + unsigned int undef; /* { dg-bogus "may be used uninitialized" } */ + unsigned int _2; + unsigned int _9; + unsigned int _10; + + __BB(2): + if (v_4(D) < 100u) + goto __BB3; + else + goto __BB4; + + /* 'undef' is defined conditionally (under 'v < 100' predicate). */ + __BB(3): + undef_8 = 8u; + goto __BB4; + + /* An undef value flows into a phi. */ + __BB(4): + undef_1 = __PHI (__BB2: undef_5(D), __BB3: undef_8); + if (v_4(D) == 42u) + goto __BB5; + else + goto __BB6; + + /* The phi value is used here (under 'v == 42' predicate). */ + __BB(5): + _9 = undef_1; + goto __BB7; + + __BB(6): + _10 = v_4(D); + goto __BB7; + + __BB(7): + _2 = __PHI (__BB5: _9, __BB6: _10); + return _2; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-31-gimple.c b/SingleSource/Regression/C/gcc-dg/uninit-31-gimple.c new file mode 100644 index 0000000000..01118ef982 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-31-gimple.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O -Wmaybe-uninitialized" } */ + +unsigned int __GIMPLE (ssa,startwith("uninit1")) +foo (unsigned int v) +{ + /* If v == 2, then undef is used w/o being initialized. */ + unsigned int undef; /* { dg-warning "may be used uninitialized" } */ + unsigned int _2; + unsigned int _9; + unsigned int _10; + unsigned int pred2; + unsigned int pred1; + + __BB(2): + pred2 = v_4(D) & 5u; + if (pred2 != 0u) + goto __BB3; + else + goto __BB4; + + /* 'undef' is defined conditionally (under 'v & 5' predicate). */ + __BB(3): + undef_8 = 8u; + goto __BB4; + + /* An undef value flows into a phi. */ + __BB(4): + undef_1 = __PHI (__BB2: undef_5(D), __BB3: undef_8); + pred1 = v_4(D) & 3u; + if (pred1 != 0u) + goto __BB5; + else + goto __BB6; + + /* The phi value is used here (under 'v & 3' predicate). */ + __BB(5): + _9 = undef_1; + goto __BB7; + + __BB(6): + _10 = v_4(D); + goto __BB7; + + __BB(7): + _2 = __PHI (__BB5: _9, __BB6: _10); + return _2; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-32.c b/SingleSource/Regression/C/gcc-dg/uninit-32.c new file mode 100644 index 0000000000..cf9efa0f06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-32.c @@ -0,0 +1,313 @@ +/* PR middle-end/10138 - warn for uninitialized arrays passed as const* + arguments + { dg-do compile } + { dg-options "-O -Wall" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +void* alloca (size_t); +void* malloc (size_t); +void* realloc (void*, size_t); + +void fpi (int*); +void fpci (const int*); +void fpcv (const void*); + + +void nowarn_scalar_fpi (void) +{ + int x; + fpi (&x); +} + +void nowarn_scalar_plus_cst_fpi (void) +{ + int x; + // This deserves a warning other than -Wuninitialized. + fpi (&x + 1); +} + +void nowarn_scalar_plus_var_fpi (int i) +{ + int x; + // Same as above, this deserves a warning other than -Wuninitialized. + fpi (&x + i); +} + +void nowarn_array_assign_fpci (void) +{ + int a[2]; + a[0] = 0; + fpci (a); +} + +void nowarn_array_assign_plus_cst_fpci (void) +{ + int a[4]; + a[1] = 0; + a[2] = 1; + fpci (a + 1); +} + +void nowarn_array_init_fpci (void) +{ + int a[4] = { 0 }; + fpci (a); +} + +void nowarn_array_compound_fpi (void) +{ + fpi ((int[2]){ 1 }); +} + +void nowarn_array_compound_fpci (void) +{ + fpci ((int[3]){ 1 }); +} + +void warn_array_fpci (void) +{ + int a[4]; // { dg-message "declared here" }" + fpci (a); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void warn_array_plus_cst_fpci (void) +{ + int a[4]; + fpci (a + 1); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void warn_array_plus_var_fpci (int i) +{ + int a[4]; + fpci (a + i); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void nowarn_array_end_fpci (void) +{ + int a[4]; + /* This should be diagnosed by a warning other than -Wuninitialized + because the just-past-the-end pointer cannot be dereferenced and + the function doesn't take any other pointer to tell where the start + of the array is. -Wuninitialized isn't appropriate because there + is nothing to initialize at that offset. */ + fpci (a + 4); +} + +void warn_matrix_fpcv (void) +{ + int a[2][2]; + fpci (a[1]); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void warn_scalar_fpcv (void) +{ + int i; + fpci (&i); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void warn_scalar_plus_cst_fpcv (void) +{ + int x; + /* Same as above, this deserves a warning other than -Wuninitialized + for passing the function a past-the-end pointer with no other + argument. */ + fpci (&x + 1); +} + +void warn_scalar_plus_var_fpcv (int i) +{ + int x; + fpci (&x + i); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void nowarn_struct_assign_fpci (void) +{ + struct { int a, b; } s; + s.a = 0; + fpci (&s.a); +} + +void warn_struct_assign_fpci (void) +{ + struct { int a, b; } s; + s.a = 0; + fpci (&s.b); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void nowarn_struct_init_fpci (void) +{ + struct { int a, b; } s = { 0 }; + fpci (&s.a); + fpci (&s.b); +} + +void nowarn_struct_compound_fpci (void) +{ + struct S { int a, b; }; + fpci (&(struct S){ }.a); + fpci (&(struct S){ }.b); +} + +/* Verify that passing a just-past-the-end pointer to a const pointer + argument to a function that takes another argument is not diagnosed + since the two arguments together could outline a range. */ +void nowarn_fp_p (void) +{ + extern void fpi_pci (int*, const int*); + + { + int i; + fpi_pci (&i, &i + 1); + } + { + int j; + fpi_pci (&j + 1, &j + 1); + } + + extern void fpc_pcc (char*, const char*); + + { + char a[2]; + fpc_pcc (a, a + 2); + } + { + char a[3]; + fpc_pcc (a, a + 3); + } + + extern void fpcc_pcc (const char*, const char*); + + { + char a[4]; + fpcc_pcc (a + 4, a + 4); + } +} + + +/* Verify passing addresses of empty uninitialized objects doesn't + trigger a warning. */ +void nowarn_fpcEmpty (void) +{ + struct Empty { }; + extern void fpcEmpty (const struct Empty*); + + /* Since Empty has no members warning for it isn't really necessary. + See also PR 38908. */ + struct Empty s; + fpcEmpty (&s); +} + + +/* Verify passing addresses of uninitialized objects to functions + declared without a proptotype doesn't trigger a warning. */ +void nowarn_noproto (void) +{ + extern void fnoproto (); + int i, a[2]; + + fnoproto (&i, a, a + 2); +} + + +/* Verify passing addresses of uninitialized objects to variadic + functions doesn't trigger a warning. */ +void nowarn_vararg (void) +{ + extern void fvararg (int, ...); + + int i, a[2]; + + fvararg (0, &i, a, a + 2); +} + + +void nowarn_alloca_assign_fpci (unsigned n) +{ + int *p = (int*)alloca (n); + p[0] = 0; + fpci (p); +} + +void nowarn_alloca_assign_plus_cst_fpci (unsigned n) +{ + int *p = (int*)alloca (n); + p[1] = 0; + p[2] = 1; + fpci (p + 1); +} + +void warn_alloca_fpci (unsigned n) +{ + int *p = (int*)alloca (n); + fpci (p); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void warn_alloca_assign_plus_cst_fpci (unsigned n) +{ + int *p = (int*)alloca (n); + p[1] = 0; + p[2] = 1; + fpci (p + 3); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + + +void nowarn_vla_assign_fpci (unsigned n) +{ + int a[n]; + a[0] = 0; + fpci (a); +} + +void nowarn_vla_assign_plus_cst_fpci (unsigned n) +{ + int vla[n]; + vla[1] = 0; + vla[2] = 1; + fpci (vla + 1); +} + +void warn_vla_fpci (unsigned n) +{ + int vla[n]; // { dg-message "declared here" "pr?????" { xfail *-*-* } }" + fpci (vla); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void warn_vla_assign_plus_cst_fpci (unsigned n) +{ + int vla[n]; // { dg-message "declared here" "pr?????" { xfail *-*-* } }" + vla[1] = 0; + vla[2] = 1; + fpci (vla + 3); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + + +void nowarn_malloc_assign_fpci (unsigned n) +{ + int *p = (int*)malloc (n); + p[0] = 0; + fpci (p); +} + +void nowarn_malloc_assign_plus_cst_fpci (unsigned n) +{ + int *p = (int*)malloc (n); + p[1] = 0; + p[2] = 1; + fpci (p + 1); +} + +void warn_malloc_fpci (unsigned n) +{ + int *p = (int*)malloc (n); + fpci (p); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} + +void warn_malloc_assign_plus_cst_fpci (unsigned n) +{ + int *p = (int*)malloc (n); // { dg-message "allocated here" "pr?????" { xfail *-*-* } }" + p[1] = 0; + p[2] = 1; + fpci (p + 3); // { dg-warning "\\\[-Wmaybe-uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-33.c b/SingleSource/Regression/C/gcc-dg/uninit-33.c new file mode 100644 index 0000000000..732d33e006 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-33.c @@ -0,0 +1,145 @@ +/* PR middle-end/10138 - warn for uninitialized arrays passed as const* + arguments + Verify that passing pointers to uninitialized objects to arguments + to functions declared with attribute access is diagnosed where expected. + { dg-do compile } + { dg-options "-O -Wall" } */ + +#define RO(...) __attribute__ ((access (read_only, __VA_ARGS__))) +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) +#define WO(...) __attribute__ ((access (write_only, __VA_ARGS__))) + +RO (1) void fpri (int*); // { dg-message "in a call to 'fpri' declared with attribute 'access \\\(read_only, 1\\\)' here" } + +RO (1) void fpcri (const int*); + +RO (1, 2) void fpcri1_2 (const int*, int); + + +void warn_scalar_fpri (void) +{ + int i; // { dg-message "declared here" } + fpri (&i); // { dg-warning "'i' is used uninitialized" } +} + +void nowarn_scalar_plus_fpri (void) +{ + int i; + /* This gets a -Wstringop-overflow for reading past the end but not + -Wuninitialized because there's nothing to initialize there. */ + fpri (&i + 1); // { dg-warning "\\\[-Wstringop-overread" } +} + +void nowarn_array_assign_fpcri (void) +{ + int a[2]; + a[0] = 0; + fpcri (a); +} + +void nowarn_array_init_fpcri (void) +{ + int a[4] = { 0 }; + fpcri (a); +} + +void nowarn_array_compound_fpri (void) +{ + fpri ((int[2]){ 0 }); +} + +void nowarn_array_compound_fpcri (void) +{ + fpcri ((int[3]){ 1 }); +} + +void warn_scalar_fpcri (void) +{ + int i; + fpcri (&i); // { dg-warning "\\\[-Wuninitialized" } +} + +void warn_array_fpcri (void) +{ + int a[4]; + fpcri (a); // { dg-warning "\\\[-Wuninitialized" } +} + +void warn_array_plus_cst_fpcri (void) +{ + int a[4]; + fpcri (a + 1); // { dg-warning "\\\[-Wuninitialized" } +} + +void warn_array_plus_var_fpcri (int i) +{ + int a[4]; + fpcri (a + i); // { dg-warning "\\\[-Wuninitialized" } +} + +void nowarn_struct_assign_fpcri (void) +{ + struct { int a, b; } s; + s.a = 0; + fpcri (&s.a); +} + +void warn_struct_assign_fpcri (void) +{ + struct { int a, b; } s; + s.a = 0; + fpcri (&s.b); // { dg-warning "\\\[-Wuninitialized" } +} + +void nowarn_struct_init_fpcri (void) +{ + struct { int a, b; } s = { 0 }; + fpcri (&s.a); + fpcri (&s.b); +} + +void nowarn_struct_compound_fpcri (void) +{ + struct S { int a, b; }; + fpcri (&(struct S){ }.a); + fpcri (&(struct S){ }.b); +} + + +void nowarn_scalar_fpcri1_2 (void) +{ + int i; + fpcri1_2 (&i, 0); +} + +void nowarn_array_assign_fpcri1_2 (void) +{ + int a[2]; + a[0] = 0; + fpcri1_2 (a, 1); +} + +void nowarn_array_assign_fpcri1_2_plus_cst (void) +{ + int a[3]; + a[1] = 0; + fpcri1_2 (a + 1, 1); +} + +void nowarn_array_init_fpcri1_2 (void) +{ + int a[4] = { 0 }; + fpcri1_2 (a, 2); +} + +void warn_array_fpcri1_2_rd1 (void) +{ + int a[4]; + fpcri1_2 (a, 1); // { dg-warning "\\\[-Wuninitialized" } +} + +void warn_array_fpcri1_2_rd2 (void) +{ + int a[4]; + fpcri1_2 (a, 2); // { dg-warning "\\\[-Wuninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-34.c b/SingleSource/Regression/C/gcc-dg/uninit-34.c new file mode 100644 index 0000000000..9de618347e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-34.c @@ -0,0 +1,58 @@ +/* PR middle-end/10138 - warn for uninitialized arrays passed as const* + arguments + Verify that passing pointers to uninitialized objects to arguments + to functions declared with attribute access is diagnosed where expected. + { dg-do compile } + { dg-options "-O -Wall" } */ + +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) + +RW (1) RW (3) void +f4pi (int*, int*, int*, int*); // { dg-message "in a call to 'f4pi' declared with attribute 'access \\\(read_write, \[13\]\\\)'" } + + +void nowarn_scalar (void) +{ + int i1 = 0, i2, i3 = 1, i4; + f4pi (&i1, &i2, &i3, &i4); +} + +void warn_scalar_1 (void) +{ + int i1; // { dg-message "declared here" } + int i2, i3 = 1, i4; + + f4pi (&i1, &i2, &i3, &i4); // { dg-warning "'i1' may be used uninitialized" } +} + +void warn_scalar_2 (void) +{ + int j1 = 0, j2, j4; + int j3; + + f4pi (&j1, &j2, &j3, &j4); // { dg-warning "'j3' may be used uninitialized" } +} + + +void nowarn_array_init (void) +{ + int a1[4] = { 0 }, a2[5], a3[6] = { 0 }, a4[7]; + + f4pi (a1, a2, a3, a4); +} + +void warn_array_1 (void) +{ + int a1[4]; // { dg-message "'a1' declared here" } + int a2[5], a3[6] = { 0 }, a4[7]; + + f4pi (a1, a2, a3, a4); // { dg-warning "'a1' may be used uninitialized" } +} + +void warn_array_2 (void) +{ + int a1[4] = { 0 }, a2[5], a4[7]; + int a3[6]; // { dg-message "'a3' declared here" } + + f4pi (a1, a2, a3, a4); // { dg-warning "'a3' may be used uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-36.c b/SingleSource/Regression/C/gcc-dg/uninit-36.c new file mode 100644 index 0000000000..f6307ce591 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-36.c @@ -0,0 +1,238 @@ +/* PR middle-end/10138 - warn for uninitialized arrays passed as const* + arguments + Verify that passing pointers to uninitialized objects to const + arguments to built-ins is diagnosed where expected. + { dg-do compile } + { dg-options "-O -Wall" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +void* alloca (size_t); +void* malloc (size_t); +void* realloc (void*, size_t); + +void* memcpy (void*, const void*, size_t); +char* strcpy (char*, const char*); +size_t strlen (const char*); + +void sink (void*); + +void nowarn_array_memcpy (void *d, unsigned n) +{ + int a[2]; + /* Diagnose this? */ + memcpy (d, a, n /* Non-constant to avoid folding into MEM_REF. */); +} + +void nowarn_array_plus_cst_memcpy (void *d, unsigned n) +{ + int a[3]; + /* Diagnose this? */ + memcpy (d, a + 1, n); +} + +void nowarn_array_plus_var_memcpy (void *d, unsigned n, int i) +{ + int a[4]; + /* Diagnose this? */ + memcpy (d, a + i, n); +} + +void nowarn_array_assign_memcpy (char *d, unsigned n) +{ + int a[3]; + a[1] = 3; + memcpy (d, a, n); +} + +void nowarn_array_init_memcpy (char *d, unsigned n) +{ + int a[4] = { 0 }; + memcpy (d, a, n); +} + +void nowarn_array_compound_memcpy (void *d, unsigned n) +{ + memcpy (d, (int[2]){ 0 }, n); +} + +void nowarn_struct_assign_memcpy (void *d, unsigned n) +{ + struct S { int a, b, c, d; } s; + s.b = 1; + s.d = 2; + memcpy (d, &s, n); +} + + +void nowarn_array_init_strcpy (char *d[], unsigned n) +{ + char a[8] = "012"; + + strcpy (d[0], a); + strcpy (d[1], a + 1); + strcpy (d[1], a + 2); + strcpy (d[1], a + 3); + strcpy (d[1], a + 4); + strcpy (d[1], a + 5); + strcpy (d[1], a + 6); + strcpy (d[1], a + 7); +} + + +void nowarn_array_assign_strcpy (char *d[], unsigned n) +{ + char a[8]; + a[0] = '0'; + a[1] = '1'; + a[2] = '2'; + a[3] = '\0'; + + strcpy (d[0], a); + strcpy (d[1], a + 1); + strcpy (d[1], a + 2); + strcpy (d[1], a + 3); +} + +void warn_array_plus_cst_strcpy (char *d, unsigned n) +{ + char a[8]; + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + a[3] = '\0'; + + strcpy (d, a + 4); // { dg-warning "\\\[-Wuninitialized" } + strcpy (d, a + 5); // { dg-warning "\\\[-Wuninitialized" } + strcpy (d, a + 6); // { dg-warning "\\\[-Wuninitialized" } + strcpy (d, a + 7); // { dg-warning "\\\[-Wuninitialized" } +} + +void nowarn_array_plus_var_strcpy (char *d, int i) +{ + char a[8]; + a[0] = '1'; + a[1] = '2'; + a[2] = '3'; + a[3] = '\0'; + + strcpy (d, a + i); +} + + +size_t nowarn_array_assign_strlen (const char *s) +{ + char a[8]; + a[0] = s[0]; + a[1] = s[1]; + a[2] = s[2]; + a[3] = s[3]; + + size_t n = 0; + + n += strlen (a); + n += strlen (a + 1); + n += strlen (a + 2); + n += strlen (a + 3); + return n; +} + +size_t warn_array_plus_cst_strlen (const char *s) +{ + char a[8]; + a[0] = s[0]; + a[1] = s[1]; + a[2] = s[2]; + a[3] = s[3]; + + return strlen (a + 4); // { dg-warning "\\\[-Wuninitialized" } +} + +size_t nowarn_array_plus_var_strlen (const char *s, int i) +{ + char a[8]; + a[0] = s[0]; + a[1] = s[1]; + a[2] = s[2]; + a[3] = s[3]; + + return strlen (a + i); +} + + +size_t nowarn_alloca_assign_strlen (int i) +{ + char *p = (char*)alloca (8); + p[i] = '\0'; + return strlen (p); +} + +size_t nowarn_alloca_escape_strlen (int i) +{ + char *p = (char*)alloca (8); + sink (p); + return strlen (p); +} + +size_t warn_alloca_strlen (void) +{ + char *p = (char*)alloca (8); + return strlen (p); // { dg-warning "\\\[-Wuninitialized" } +} + + +size_t nowarn_malloc_assign_strlen (int i) +{ + char *p = (char*)malloc (8); + p[i] = '\0'; + return strlen (p); +} + +size_t nowarn_malloc_escape_strlen (int i) +{ + char *p = (char*)malloc (8); + sink (p); + return strlen (p); +} + +size_t warn_malloc_strlen (void) +{ + char *p = (char*)malloc (8); + return strlen (p); // { dg-warning "\\\[-Wuninitialized" } +} + + +size_t nowarn_realloc_strlen (void *p) +{ + char *q = (char*)realloc (p, 8); + return strlen (q); +} + + +size_t nowarn_vla_assign_strlen (int n, int i) +{ + char vla[n]; + vla[i] = '\0'; + return strlen (vla); +} + +size_t nowarn_vla_strcpy_strlen (int n, const char *s, int i) +{ + char vla[n]; + strcpy (vla, s); + return strlen (vla + i); +} + +size_t nowarn_vla_escape_strlen (int n, int i) +{ + char vla[n]; + sink (vla); + return strlen (vla); +} + +size_t warn_vla_strlen (unsigned n) +{ + char vla[n]; + return strlen (vla); // { dg-warning "\\\[-Wuninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-37.c b/SingleSource/Regression/C/gcc-dg/uninit-37.c new file mode 100644 index 0000000000..b8c49ad17c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-37.c @@ -0,0 +1,154 @@ +/* PR middle-end/10138 - warn for uninitialized arrays passed as const arguments + Verify that -Wuninitialized and -Wmaybe-uninitialized trigger (or don't) + when passing uninitialized variables by reference to functions declared + with or without attribute access and with (or without) const qualified + arguments of array, VLA, or pointer types. + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#define NONE /* none */ +#define RO(...) __attribute__ ((access (read_only, __VA_ARGS__))) +#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) +#define WO(...) __attribute__ ((access (write_only, __VA_ARGS__))) +#define X(...) __attribute__ ((access (none, __VA_ARGS__))) + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT (x, y) +#define UNIQ(pfx) CAT (pfx, __LINE__) + +extern void sink (void*); + + +#define T1(attr, name, type) \ + void UNIQ (CAT (test_, name))(void) { \ + extern attr void UNIQ (name)(type); \ + int x; \ + UNIQ (name)(&x); \ + sink (&x); \ + } + +#define T2(attr, name, types) \ + void UNIQ (CAT (test_, name))(void) { \ + extern attr void UNIQ (name)(types); \ + int x; \ + UNIQ (name)(1, &x); \ + sink (&x); \ + } + + +typedef int IA_[]; +typedef const int CIA_[]; + +T1 (NONE, fia_, IA_); +T1 (NONE, fcia_, CIA_); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (RO (1), froia_, IA_); // { dg-warning "\\\[-Wuninitialized" } +T1 (RW (1), frwia_, IA_); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (WO (1), fwoia_, IA_); +T1 (X (1), fxia_, IA_); + + +typedef int IA1[1]; +typedef const int CIA1[1]; + +T1 (NONE, fia1, IA1); +T1 (NONE, fcia1, CIA1); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (RO (1), froia1, IA1); // { dg-warning "\\\[-Wuninitialized" } +T1 (RW (1), frwia1, IA1); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (WO (1), fwoia1, IA1); +T1 (X (1), fxia1, IA1); + + +#define IARS1 int[restrict static 1] +#define CIARS1 const int[restrict static 1] + +T1 (NONE, fiars1, IARS1); +T1 (NONE, fciars1, CIARS1);// { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (RO (1), froiars1, IARS1); // { dg-warning "\\\[-Wuninitialized" } +T1 (RW (1), frwiars1, IARS1); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (WO (1), fwoiars1, IARS1); +T1 (X (1), fxiars1, IARS1); + + +#define IAS1 int[static 1] +#define CIAS1 const int[static 1] + +T1 (NONE, fias1, IAS1); +T1 (NONE, fcias1, CIAS1); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (RO (1), froias1, IAS1); // { dg-warning "\\\[-Wuninitialized" } +T1 (RW (1), frwias1, IAS1); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (WO (1), fwoias1, IAS1); +T1 (X (1), fxias1, IAS1); + + +#define IAX int[*] +#define CIAX const int[*] + +T1 (NONE, fiax, IAX); +T1 (NONE, fciax, CIAX); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (RO (1), froiax, IAX); // { dg-warning "\\\[-Wuninitialized" } +T1 (RW (1), frwiax, IAX); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (WO (1), fwoiax, IAX); +T1 (X (1), fxiax, IAX); + + +#define IAN int n, int[n] +#define CIAN int n, const int[n] + +T2 (NONE, fian, IAN); +T2 (NONE, fcian, CIAN); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T2 (RO (2, 1), froian, IAN); // { dg-warning "\\\[-Wuninitialized" } +T2 (RW (2, 1), frwian, IAN); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T2 (WO (2, 1), fwoian, IAN); +T2 (X (2, 1), fxian, IAN); + + +typedef int* IP; +typedef const int* CIP; + +T1 (NONE, fip, IP); +T1 (NONE, fcip, CIP); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (RO (1), froip, IP); // { dg-warning "\\\[-Wuninitialized" } +T1 (RW (1), frwip, IP); // { dg-warning "\\\[-Wmaybe-uninitialized" } +T1 (WO (1), fwoip, IP); +T1 (X (1), fxip, IP); + + +/* Verify that the notes printed after the warning mention attribute + access only when the attribute is explicitly used in the declaration + and not otherwise. */ + +void test_note_cst_restrict (void) +{ + extern void + fccar (const char[restrict]); // { dg-message "by argument 1 of type 'const char\\\[restrict]' to 'fccar'" "note" } + + char a[1]; // { dg-message "'a' declared here" "note" } + fccar (a); // { dg-warning "'a' may be used uninitialized" } +} + +void test_note_vla (int n) +{ + extern void + fccvla (const char[n]); // { dg-message "by argument 1 of type 'const char\\\[n]' to 'fccvla'" "note" } + + char a[2]; // { dg-message "'a' declared here" "note" } + fccvla (a); // { dg-warning "'a' may be used uninitialized" } +} + +void test_note_ro (void) +{ + extern RO (1) void + frocar (char[restrict]); // { dg-message "in a call to 'frocar' declared with attribute 'access \\\(read_only, 1\\\)'" "note" } + + char a[3]; // { dg-message "'a' declared here" "note" } + frocar (a); // { dg-warning "'a' is used uninitialized" } +} + +void test_note_rw (void) +{ + extern RW (1) void + frwcar (char[restrict]); // { dg-message "in a call to 'frwcar' declared with attribute 'access \\\(read_write, 1\\\)'" "note" } + + char a[4]; // { dg-message "'a' declared here" "note" } + frwcar (a); // { dg-warning "'a' may be used uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-38.c b/SingleSource/Regression/C/gcc-dg/uninit-38.c new file mode 100644 index 0000000000..9a202430b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-38.c @@ -0,0 +1,53 @@ +/* Verify that dereferencing uninitialized VLAs correctly reflects + offsets into the objects. + The test's main purpose is to exercise the formatting of MEM_REFs. + If -Wuninitialized gets smarter and detects uninitialized accesses + before they're turned into MEM_REFs the test will likely need to + be adjusted. Ditto if -Wuninitialized output changes for some + other reason. + { dg-do compile { target { { lp64 || ilp32 } || llp64 } } } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0 -fno-ipa-modref" } + { dg-require-effective-target alloca } */ + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT(x, y) +#define UNIQ(name) CAT (name, __LINE__) + +typedef __SIZE_TYPE__ size_t; + +extern void* malloc (size_t); + +void sink (void*, ...); + +#define T(Type, idx, off) \ + __attribute__ ((noipa)) \ + void UNIQ (test_)(int n) \ + { \ + char a[n], *p = a; \ + Type *q = (Type*)((char*)p + off); \ + sink (p, q[idx]); \ + } \ + typedef void dummy_type + +T (int, 0, 0); // { dg-warning "'\\*\\(int \\*\\)a' is used uninitialized" } +T (int, 0, 1); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)'" } +T (int, 0, 2); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)a \\+ 2\\)'" } +T (int, 0, 3); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)a \\+ 3\\)'" } +T (int, 0, 4); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[1]'" } +T (int, 0, 5); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[1]'" } +T (int, 0, 6); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 2\\)\\)\\\[1]'" } +T (int, 0, 7); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 3\\)\\)\\\[1]'" } +T (int, 0, 8); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[2]'" } +T (int, 0, 9); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[2]'" } + + +T (int, 1, 0); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[1]' is used uninitialized" } +T (int, 1, 1); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[1]'" } +T (int, 1, 2); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 2\\)\\)\\\[1]'" } +T (int, 1, 3); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 3\\)\\)\\\[1]'" } +T (int, 1, 4); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[2]'" } +T (int, 1, 5); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[2]'" } +T (int, 1, 6); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 2\\)\\)\\\[2]'" } +T (int, 1, 7); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 3\\)\\)\\\[2]'" } +T (int, 1, 8); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[3]'" } +T (int, 1, 9); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[3]'" } diff --git a/SingleSource/Regression/C/gcc-dg/uninit-39.c b/SingleSource/Regression/C/gcc-dg/uninit-39.c new file mode 100644 index 0000000000..4d17f14725 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-39.c @@ -0,0 +1,48 @@ +/* PR c/98592 - ICE in gimple_canonical_types_compatible_p while formatting + a MEM_REF + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +void f (int); + +void vlaNx3_to_pia1 (int n) +{ + int a[n][3]; + + /* The VLA isn't formatted correctly due to PR 98587. Just verify + there is no ICE and a warning is issued. */ + f (((*(int(*)[4])&a[1][2]))[3]); // { dg-warning "\\\[-Wuninitialized" } +} + +void vlaNxN_to_pia1 (int n) +{ + int a[n][n]; + + /* Same as above. */ + f (((*(int(*)[4])&a[1][2]))[3]); // { dg-warning "\\\[-Wuninitialized" } +} + +void vlaNxN_to_pvla4xN (int n) +{ + int a[n][n]; + + /* Same as above. */ + f (((*(int(*)[4][n])&a[1][2]))[3][4]); // { dg-warning "\\\[-Wuninitialized" } +} + +void vlaN_to_pia2 (int n) +{ + int a[n]; + + /* Same as above. */ + f (((*(int(*)[3][4])&a[1]))[2][3]); // { dg-warning "\\\[-Wuninitialized" } +} + +void vlaN_to_pvlaNx4 (int n) +{ + int a[n]; + + /* Same as above. */ + f (((*(int(*)[n][4])&a[1]))[1][3]); // { dg-warning "\\\[-Wuninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-4-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-4-O0.c new file mode 100644 index 0000000000..0b9aeea7dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-4-O0.c @@ -0,0 +1,52 @@ +/* Spurious uninit variable warnings, case 4. + Simplified version of cppexp.c (cpp_parse_expr). + + This one is really fragile, it gets it right if you take out case + 1, or if the structure is replaced by an int, or if the structure + has fewer members (!) */ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +extern void abort (void); + +struct operation { + short op; + char rprio; + char flags; + char unsignedp; + long value; +}; + +extern struct operation cpp_lex (void); + +void +cpp_parse_expr (void) +{ + int rprio; /* { dg-bogus "rprio" "uninitialized variable warning PR19833" } */ + struct operation op; + + for (;;) + { + op = cpp_lex (); + + switch (op.op) + { + case 0: + break; + case 1: + return; + case 2: + rprio = 1; + break; + default: + return; + } + + if (op.op == 0) + return; + + if (rprio != 1) + abort(); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-4.c b/SingleSource/Regression/C/gcc-dg/uninit-4.c new file mode 100644 index 0000000000..d39ecac77c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-4.c @@ -0,0 +1,52 @@ +/* Spurious uninit variable warnings, case 4. + Simplified version of cppexp.c (cpp_parse_expr). + + This one is really fragile, it gets it right if you take out case + 1, or if the structure is replaced by an int, or if the structure + has fewer members (!) */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +extern void abort (void); + +struct operation { + short op; + char rprio; + char flags; + char unsignedp; + long value; +}; + +extern struct operation cpp_lex (void); + +void +cpp_parse_expr (void) +{ + int rprio; /* { dg-bogus "rprio" "uninitialized variable warning PR19833" } */ + struct operation op; + + for (;;) + { + op = cpp_lex (); + + switch (op.op) + { + case 0: + break; + case 1: + return; + case 2: + rprio = 1; + break; + default: + return; + } + + if (op.op == 0) + return; + + if (rprio != 1) + abort(); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-40.c b/SingleSource/Regression/C/gcc-dg/uninit-40.c new file mode 100644 index 0000000000..567707a885 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-40.c @@ -0,0 +1,50 @@ +/* PR tree-optimization/98597 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-vectorize -Wuninitialized" } */ + +union U { double d; int i; float f; }; +struct S { char a; int b; char c; unsigned d; union U e; int f[3]; unsigned g[3]; }; +struct T { char t; struct S u; int v; }; +typedef short V[2][2]; +void baz (V *); + +static inline int +bar (char *p) +{ + return *(int *) p; +} + +void +foo (int *q) +{ + struct T t; + t.t = 1; + t.u.c = 2; + char *pt = (char *) &t; + q[0] = bar (pt + __builtin_offsetof (struct T, u.b)); /* { dg-warning "'t\\.u\\.b' is used uninitialized" } */ + q[1] = bar (pt + __builtin_offsetof (struct T, u.e)); /* { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)&t \\+ offsetof\\(struct T, u\\.e\\)\\)' is used uninitialized" } */ + q[2] = bar (pt + __builtin_offsetof (struct T, v)); /* { dg-warning "'t\\.v' is used uninitialized" } */ + q[3] = bar (pt + __builtin_offsetof (struct T, u.d)); /* { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)&t \\+ offsetof\\(struct T, u\\.d\\)\\)' is used uninitialized" } */ + q[4] = bar (pt + __builtin_offsetof (struct T, u.f[2])); /* { dg-warning "'t\\.u\\.f\\\[2\\\]' is used uninitialized" } */ + q[5] = bar (pt + __builtin_offsetof (struct T, u.g[2])); /* { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)&t \\+ offsetof\\(struct T, u\\.g\\\[2\\\]\\)\\)' is used uninitialized" } */ + int s[3]; + s[0] = 1; + char *ps = (char *) s; + q[6] = bar (ps + sizeof (int)); /* { dg-warning "'s\\\[1\\\]' is used uninitialized" } */ + unsigned w[2][2]; + w[0][0] = 1; + char *pw = (char *) w; + q[7] = bar (pw + 3 * sizeof (unsigned)); /* { dg-warning "'\\*\\(int \\*\\)\\(&w\\\[1\\\]\\\[1\\\]\\)' is used uninitialized" } */ + struct T x[3][3]; + x[0][0].t = 1; + char *px = (char *) x; + q[8] = bar (px + 5 * sizeof (struct T) + __builtin_offsetof (struct T, u.b)); /* { dg-warning "'x\\\[1\\\]\\\[2\\\]\\.u\\.b' is used uninitialized" } */ + q[9] = bar (px + 6 * sizeof (struct T) + __builtin_offsetof (struct T, u.d)); /* { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)&x\\\[2\\\]\\\[0\\\] \\+ offsetof\\(struct T, u\\.d\\)\\)' is used uninitialized" } */ +#if defined(__i386__) || defined(__x86_64__) + /* memcpy folding is too target dependent to test it everywhere. */ + V u[2], v[2]; + u[0][0][0] = 1; + __builtin_memcpy (&v[1], &u[1], sizeof (V)); /* { dg-warning "'u' is used uninitialized" "" { target i?86-*-* x86_64-*-* } } */ + baz (&v[1]); +#endif +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-41.c b/SingleSource/Regression/C/gcc-dg/uninit-41.c new file mode 100644 index 0000000000..f2e17a81d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-41.c @@ -0,0 +1,122 @@ +/* Verify that calls to non-modifying built-ins aren't considered + potentially modifying. + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +void* alloca (size_t); +void* calloc (size_t, size_t); +void* malloc (size_t); +int printf (const char *, ...); +int scanf (const char *, ...); +int sprintf (char *, const char *, ...); +int snprintf (char *, size_t, const char *, ...); +int puts (const char *); +char* strcpy (char*, const char*); +size_t strlen (const char*); + +void noproto (); + +void sink (int, ...); + +extern char a[]; + +void nowarn_noproto (const char *fmt) +{ + int i; + noproto (&i); + sink (i); +} + +void nowarn_scanf (const char *fmt) +{ + int i; + scanf ("%i", &i); + sink (i); +} + +void test_puts_sprintf_alloca (const char *fmt) +{ + char *p; + { + p = alloca (8); + sprintf (a, fmt, p); // fmt might contain %n + puts (p); + } + + { + p = alloca (8); + snprintf (0, 0, fmt, p); // same as above + puts (p); + } +} + +void test_puts_alloca (const char *s) +{ + char *p = alloca (8); + + { + char a[] = "foo"; + puts (a); + } + + puts (p); // { dg-warning "-Wuninitialized" } + + { + p = alloca (strlen (s) + 1); + strcpy (p, s); + puts (p); + } + + { + /* Verify that the puts() calls above isn't considered to have + potentially modified *P, and same for the one below. */ + p = alloca (strlen (s)); + puts (p); // { dg-warning "-Wuninitialized" } + puts (p + 1); // { dg-warning "-Wuninitialized" } + } +} + + +void test_puts_malloc (const char *s, const char *t) +{ + char *p; + + { + p = malloc (strlen (s) + 1); + strcpy (p, s); + puts (p); + } + + { + p = malloc (strlen (t)); + puts (p); // { dg-warning "-Wuninitialized" } + } +} + + +void test_puts_vla (const char *s, const char *t) +{ + { + char a[strlen (s) + 1]; + strcpy (a, s); + puts (a); + } + + { + char b[strlen (t)]; + puts (b); // { dg-warning "-Wuninitialized" } + } +} + + +void test_printf_puts (const char *s) +{ + char *p = __builtin_malloc (1); + + printf ("%s", s); + + puts (p); // { dg-warning "-Wuninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-42.c b/SingleSource/Regression/C/gcc-dg/uninit-42.c new file mode 100644 index 0000000000..efaaacdf9b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-42.c @@ -0,0 +1,87 @@ +/* PR middle-end/101734 - missing warning reading from a write-only object + Verify that reading objects pointed to by arguments + declared with attribute access none or write-only is diagnosed by + -Wmaybe-uninitialized. + { dg-do compile } + { dg-options "-Wall" } */ + +#define A(mode, ...) __attribute__ ((access (mode, __VA_ARGS__))) + +void sink (void *, ...); + + +A (write_only, 1, 2) +int nowarn_wo_assign_r0 (int *p, int n) +{ + *p = n; + return *p; +} + +A (write_only, 1, 2) +int nowarn_wo_sink_r0 (int *p, int n) +{ + sink (p, p + 1, p + n); + return *p; +} + +A (write_only, 1, 2) +int warn_wo_r0 (int *p, int n) +{ + return *p; // { dg-warning "'\\*p' may be used uninitialized \\\[-Wmaybe-uninitialized" } +} + + +A (write_only, 1, 2) +int nowarn_wo_w1_r1 (int *p, int n) +{ + p[1] = n; + return p[1]; +} + +A (write_only, 1, 2) +int warn_wo_r1 (int *p, int n) +{ + return p[1]; // { dg-warning "'p\\\[1]' may be used uninitialized" } +} + + +A (write_only, 1, 2) +int nowarn_wo_rwi_rj (int *p, int n, int i, int j) +{ + p[i] = n; + return p[j]; +} + +A (write_only, 1, 2) + int warn_wo_ri (int *p, int n, int i) +{ + return p[i]; // { dg-warning " may be used uninitialized" } +} + + + +A (none, 1, 2) +int* nowarn_none_sink_return (int *p, int n) +{ + sink (p, p + 1, p + n); + return p; +} + +A (none, 1, 2) +int warn_none_r0 (int *p, int n) +{ + (void)&n; + return *p; // { dg-warning "'\\*p' may be used uninitialized" } +} + +A (none, 1, 2) +int warn_none_r1 (int *p, int n) +{ + return p[1]; // { dg-warning "'p\\\[1]' may be used uninitialized" } +} + +A (write_only, 1, 2) +int warn_none_ri (int *p, int n, int i) +{ + return p[i]; // { dg-warning " may be used uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-5-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-5-O0.c new file mode 100644 index 0000000000..d9784b3f76 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-5-O0.c @@ -0,0 +1,39 @@ +/* Spurious uninitialized-variable warnings. */ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +extern void use(int); +extern void foo(void); + +void +func1(int cond) +{ + int x; /* { dg-bogus "x" "uninitialized variable warning" } */ + + if(cond) + x = 1; + + foo(); + + if(cond) + use(x); +} + +void +func2 (int cond) +{ + int x; /* { dg-bogus "x" "uninitialized variable warning" } */ + int flag = 0; + + if(cond) + { + x = 1; + flag = 1; + } + + foo(); + + if(flag) + use(x); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-5.c b/SingleSource/Regression/C/gcc-dg/uninit-5.c new file mode 100644 index 0000000000..df2a27c447 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-5.c @@ -0,0 +1,39 @@ +/* Spurious uninitialized-variable warnings. */ +/* Disable jump threading, etc to test compiler analysis. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized -fno-tree-dce -fno-tree-vrp -fno-tree-dominator-opts" } */ + +extern void use(int); +extern void foo(void); + +void +func1(int cond) +{ + int x; /* { dg-bogus "x" "uninitialized variable warning" } */ + + if(cond) + x = 1; + + foo(); + + if(cond) + use(x); +} + +void +func2 (int cond) +{ + int x; /* { dg-bogus "x" "uninitialized variable warning" } */ + int flag = 0; + + if(cond) + { + x = 1; + flag = 1; + } + + foo(); + + if(flag) + use(x); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-6-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-6-O0.c new file mode 100644 index 0000000000..fe9815efbb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-6-O0.c @@ -0,0 +1,47 @@ +/* Spurious uninitialized variable warnings. + This one inspired by java/class.c:build_utf8_ref. */ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -ftrack-macro-expansion=2" } */ + +#include + +struct tree +{ + struct tree *car; + struct tree *cdr; + int type, data; +}; + +extern void *malloc(size_t); + +#define INTEGER_T 1 +#define PTR_T 2 + +#define APPEND(TREE, LAST, TYPE, VALUE) \ +do { \ + struct tree *tmp = malloc (sizeof (struct tree)); \ + tmp->car = 0; tmp->cdr = 0; tmp->type = TYPE; \ + tmp->data = VALUE; \ + if (TREE->car) \ + LAST->cdr = tmp; /* { dg-bogus "field" "uninitialized variable warning" { xfail *-*-* } } */ \ + else \ + TREE->car = tmp; \ + LAST = tmp; \ +} while(0) + +struct tree * +make_something(int a, int b, int c) +{ + struct tree *rv; + struct tree *field; + + rv = malloc (sizeof (struct tree)); + rv->car = 0; + + APPEND(rv, field, INTEGER_T, a); + APPEND(rv, field, PTR_T, b); + APPEND(rv, field, INTEGER_T, c); + + return rv; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-6.c b/SingleSource/Regression/C/gcc-dg/uninit-6.c new file mode 100644 index 0000000000..009e124fcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-6.c @@ -0,0 +1,47 @@ +/* Spurious uninitialized variable warnings. + This one inspired by java/class.c:build_utf8_ref. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +#include + +struct tree +{ + struct tree *car; + struct tree *cdr; + int type, data; +}; + +extern void *malloc(size_t); + +#define INTEGER_T 1 +#define PTR_T 2 + +#define APPEND(TREE, LAST, TYPE, VALUE) \ +do { \ + struct tree *tmp = malloc (sizeof (struct tree)); \ + tmp->car = 0; tmp->cdr = 0; tmp->type = TYPE; \ + tmp->data = VALUE; \ + if (TREE->car) \ + LAST->cdr = tmp; \ + else \ + TREE->car = tmp; \ + LAST = tmp; \ +} while(0) + +struct tree * +make_something(int a, int b, int c) +{ + struct tree *rv; + struct tree *field; + + rv = malloc (sizeof (struct tree)); + rv->car = 0; + + APPEND(rv, field, INTEGER_T, a); /* { dg-bogus "field" "uninitialized variable warning" } */ + APPEND(rv, field, PTR_T, b); + APPEND(rv, field, INTEGER_T, c); + + return rv; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-8-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-8-O0.c new file mode 100644 index 0000000000..b386896c7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-8-O0.c @@ -0,0 +1,32 @@ +/* Uninitialized variable warning tests... + Inspired by part of optabs.c:expand_binop. + May be the same as uninit-1.c. */ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +#include + +void +add_bignums (int *out, int *x, int *y) +{ + int p, sum; + int carry; /* { dg-bogus "carry" "uninitialized variable warning" } */ + + p = 0; + for (; *x; x++, y++, out++, p++) + { + if (p) + sum = *x + *y + carry; + else + sum = *x + *y; + + if (sum < 0) + { + carry = 1; + sum -= INT_MAX; + } + else + carry = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-8.c b/SingleSource/Regression/C/gcc-dg/uninit-8.c new file mode 100644 index 0000000000..98700f4aa1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-8.c @@ -0,0 +1,32 @@ +/* Uninitialized variable warning tests... + Inspired by part of optabs.c:expand_binop. + May be the same as uninit-1.c. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +#include + +void +add_bignums (int *out, int *x, int *y) +{ + int p, sum; + int carry; /* { dg-bogus "carry" "uninitialized variable warning" } */ + + p = 0; + for (; *x; x++, y++, out++, p++) + { + if (p) + sum = *x + *y + carry; + else + sum = *x + *y; + + if (sum < 0) + { + carry = 1; + sum -= INT_MAX; + } + else + carry = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-9-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-9-O0.c new file mode 100644 index 0000000000..ac24e7a836 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-9-O0.c @@ -0,0 +1,42 @@ +/* Spurious uninitialized variable warnings. Slight variant on the + documented case, inspired by reg-stack.c:record_asm_reg_life. */ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ +/* { dg-require-effective-target alloca } */ + +struct foo +{ + int type; + struct foo *car; + struct foo *cdr; + char *data; + int data2; +}; + +extern void use(struct foo *); + +#define CLOBBER 6 +#define PARALLEL 3 + +void +func(struct foo *list, int count) +{ + int n_clobbers = 0; + int i; + struct foo **clob_list; /* { dg-bogus "clob_list" "uninitialized variable warning" } */ + + if(list[0].type == PARALLEL) + { + clob_list = __builtin_alloca(count * sizeof(struct foo *)); + + for(i = 1; i < count; i++) + { + if(list[i].type == CLOBBER) + clob_list[n_clobbers++] = &list[i]; + } + } + + for(i = 0; i < n_clobbers; i++) + use(clob_list[i]); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-9.c b/SingleSource/Regression/C/gcc-dg/uninit-9.c new file mode 100644 index 0000000000..d1af7328a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-9.c @@ -0,0 +1,42 @@ +/* Spurious uninitialized variable warnings. Slight variant on the + documented case, inspired by reg-stack.c:record_asm_reg_life. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ +/* { dg-require-effective-target alloca } */ + +struct foo +{ + int type; + struct foo *car; + struct foo *cdr; + char *data; + int data2; +}; + +extern void use(struct foo *); + +#define CLOBBER 6 +#define PARALLEL 3 + +void +func(struct foo *list, int count) +{ + int n_clobbers = 0; + int i; + struct foo **clob_list; /* { dg-bogus "clob_list" "uninitialized variable warning" } */ + + if(list[0].type == PARALLEL) + { + clob_list = __builtin_alloca(count * sizeof(struct foo *)); + + for(i = 1; i < count; i++) + { + if(list[i].type == CLOBBER) + clob_list[n_clobbers++] = &list[i]; + } + } + + for(i = 0; i < n_clobbers; i++) + use(clob_list[i]); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-A-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-A-O0.c new file mode 100644 index 0000000000..6937691156 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-A-O0.c @@ -0,0 +1,117 @@ +/* Inspired by part of java/parse.y. + May be a real bug in CSE. */ + +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +struct tree +{ + struct tree *car, *cdr, *wfl; + int code; + struct { unsigned int renp:1; + unsigned int rtnp:1; + unsigned int rpnp:1; } flags; +}; +typedef struct tree *tree; +#define NULL_TREE ((tree)0) + +/* Codes */ +enum +{ + CALL_EXPR, NEW_ARRAY_EXPR, NEW_CLASS_EXPR, CONVERT_EXPR, + ARRAY_REF, CONDITIONAL_EXPR, STRING_CST, EXPR_WITH_FILE_LOCATION +}; + +/* Flags */ +#define RESOLVE_EXPRESSION_NAME_P(t) ((t)->flags.renp) +#define RESOLVE_TYPE_NAME_P(t) ((t)->flags.rtnp) +#define RESOLVE_PACKAGE_NAME_P(t) ((t)->flags.rpnp) + +/* Macros */ +#define EXPR_WFL_QUALIFICATION(t) ((t)->wfl) +#define QUAL_WFL(t) ((t)->wfl) +#define EXPR_WFL_NODE(t) ((t)->wfl) +#define TREE_CODE(t) ((t)->code) +#define TREE_OPERAND(t,x) ((t)->car) +#define CLASSTYPE_SUPER(t) ((t)->car) +#define IDENTIFIER_LOCAL_VALUE(t) ((t)->car) +#define TREE_CHAIN(t) ((t)->cdr) +#define QUAL_RESOLUTION(t) ((t)->cdr) + +extern tree current_class, this_identifier_node; +extern tree super_identifier_node, length_identifier_node; + +tree resolve_and_layout (tree, tree); +tree lookup_field_wrapper (tree, tree); + +void +qualify_ambiguous_name (id) + tree id; +{ + tree qual, qual_wfl, decl; + tree name; /* { dg-bogus "name" "uninitialized variable warning" } */ + tree ptr_type; /* { dg-bogus "ptr_type" "uninitialized variable warning" } */ + int again, new_array_found = 0; + int super_found = 0, this_found = 0; + + qual = EXPR_WFL_QUALIFICATION (id); + do { + qual_wfl = QUAL_WFL (qual); + switch (TREE_CODE (qual_wfl)) + { + case CALL_EXPR: + qual_wfl = TREE_OPERAND (qual_wfl, 0); + if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION) + { + qual = EXPR_WFL_QUALIFICATION (qual_wfl); + qual_wfl = QUAL_WFL (qual); + } + break; + case NEW_ARRAY_EXPR: + qual = TREE_CHAIN (qual); + new_array_found = again = 1; + continue; + case NEW_CLASS_EXPR: + case CONVERT_EXPR: + qual_wfl = TREE_OPERAND (qual_wfl, 0); + break; + case ARRAY_REF: + while (TREE_CODE (qual_wfl) == ARRAY_REF) + qual_wfl = TREE_OPERAND (qual_wfl, 0); + break; + default: + break; + } + + name = EXPR_WFL_NODE (qual_wfl); + ptr_type = current_class; + again = 0; + + } while (again); + + /* If you put straightforward uses of name and ptr_type here + instead of the if-else sequence below, the warnings go away. + Therefore I suspect a real bug. */ + + if (!this_found && !super_found && (decl = IDENTIFIER_LOCAL_VALUE (name))) + { + RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; + QUAL_RESOLUTION (qual) = decl; + } + else if ((decl = lookup_field_wrapper (ptr_type, name)) + || (new_array_found && name == length_identifier_node)) + { + RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; + QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl); + } + else if ((decl = resolve_and_layout (name, NULL_TREE))) + { + RESOLVE_TYPE_NAME_P (qual_wfl) = 1; + QUAL_RESOLUTION (qual) = decl; + } + else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR + || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF) + RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; + else + RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-A.c b/SingleSource/Regression/C/gcc-dg/uninit-A.c new file mode 100644 index 0000000000..28f7fe9fcf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-A.c @@ -0,0 +1,117 @@ +/* Inspired by part of java/parse.y. + May be a real bug in CSE. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct tree +{ + struct tree *car, *cdr, *wfl; + int code; + struct { unsigned int renp:1; + unsigned int rtnp:1; + unsigned int rpnp:1; } flags; +}; +typedef struct tree *tree; +#define NULL_TREE ((tree)0) + +/* Codes */ +enum +{ + CALL_EXPR, NEW_ARRAY_EXPR, NEW_CLASS_EXPR, CONVERT_EXPR, + ARRAY_REF, CONDITIONAL_EXPR, STRING_CST, EXPR_WITH_FILE_LOCATION +}; + +/* Flags */ +#define RESOLVE_EXPRESSION_NAME_P(t) ((t)->flags.renp) +#define RESOLVE_TYPE_NAME_P(t) ((t)->flags.rtnp) +#define RESOLVE_PACKAGE_NAME_P(t) ((t)->flags.rpnp) + +/* Macros */ +#define EXPR_WFL_QUALIFICATION(t) ((t)->wfl) +#define QUAL_WFL(t) ((t)->wfl) +#define EXPR_WFL_NODE(t) ((t)->wfl) +#define TREE_CODE(t) ((t)->code) +#define TREE_OPERAND(t,x) ((t)->car) +#define CLASSTYPE_SUPER(t) ((t)->car) +#define IDENTIFIER_LOCAL_VALUE(t) ((t)->car) +#define TREE_CHAIN(t) ((t)->cdr) +#define QUAL_RESOLUTION(t) ((t)->cdr) + +extern tree current_class, this_identifier_node; +extern tree super_identifier_node, length_identifier_node; + +tree resolve_and_layout (tree, tree); +tree lookup_field_wrapper (tree, tree); + +void +qualify_ambiguous_name (id) + tree id; +{ + tree qual, qual_wfl, decl; + tree name; /* { dg-bogus "name" "uninitialized variable warning" } */ + tree ptr_type; /* { dg-bogus "ptr_type" "uninitialized variable warning" } */ + int again, new_array_found = 0; + int super_found = 0, this_found = 0; + + qual = EXPR_WFL_QUALIFICATION (id); + do { + qual_wfl = QUAL_WFL (qual); + switch (TREE_CODE (qual_wfl)) + { + case CALL_EXPR: + qual_wfl = TREE_OPERAND (qual_wfl, 0); + if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION) + { + qual = EXPR_WFL_QUALIFICATION (qual_wfl); + qual_wfl = QUAL_WFL (qual); + } + break; + case NEW_ARRAY_EXPR: + qual = TREE_CHAIN (qual); + new_array_found = again = 1; + continue; + case NEW_CLASS_EXPR: + case CONVERT_EXPR: + qual_wfl = TREE_OPERAND (qual_wfl, 0); + break; + case ARRAY_REF: + while (TREE_CODE (qual_wfl) == ARRAY_REF) + qual_wfl = TREE_OPERAND (qual_wfl, 0); + break; + default: + break; + } + + name = EXPR_WFL_NODE (qual_wfl); + ptr_type = current_class; + again = 0; + + } while (again); + + /* If you put straightforward uses of name and ptr_type here + instead of the if-else sequence below, the warnings go away. + Therefore I suspect a real bug. */ + + if (!this_found && !super_found && (decl = IDENTIFIER_LOCAL_VALUE (name))) + { + RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; + QUAL_RESOLUTION (qual) = decl; + } + else if ((decl = lookup_field_wrapper (ptr_type, name)) + || (new_array_found && name == length_identifier_node)) + { + RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; + QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl); + } + else if ((decl = resolve_and_layout (name, NULL_TREE))) + { + RESOLVE_TYPE_NAME_P (qual_wfl) = 1; + QUAL_RESOLUTION (qual) = decl; + } + else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR + || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF) + RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; + else + RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-B-2.c b/SingleSource/Regression/C/gcc-dg/uninit-B-2.c new file mode 100644 index 0000000000..ee8a885817 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-B-2.c @@ -0,0 +1,16 @@ +/* Origin: PR c/179 inverse of uninit-B-O0.c, we should not warn. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ +extern void foo (int *); +extern void bar (int); + +void +baz (void) +{ + int i; + foo (&i); /* { dg-bogus "is used uninitialized" "uninit i warning" } */ + if (i) + bar (i); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-B-O0-2.c b/SingleSource/Regression/C/gcc-dg/uninit-B-O0-2.c new file mode 100644 index 0000000000..dfa3de97e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-B-O0-2.c @@ -0,0 +1,16 @@ +/* Origin: PR c/179 inverse of uninit-B-O0.c, we should not warn. */ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wuninitialized" } */ +extern void foo (int *); +extern void bar (int); + +void +baz (void) +{ + int i; + foo (&i); /* { dg-bogus "is used uninitialized" "uninit i warning" } */ + if (i) + bar (i); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-B-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-B-O0.c new file mode 100644 index 0000000000..b01e4fa945 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-B-O0.c @@ -0,0 +1,15 @@ +/* Origin: PR c/179 from Gray Watson , adapted as a testcase + by Joseph Myers . */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ +extern void foo (int *); +extern void bar (int); + +void +baz (void) +{ + int i; + if (i) /* { dg-warning "'i' is used uninitialized" } */ + bar (i); + foo (&i); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-B.c b/SingleSource/Regression/C/gcc-dg/uninit-B.c new file mode 100644 index 0000000000..adb1461d95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-B.c @@ -0,0 +1,15 @@ +/* Origin: PR c/179 from Gray Watson , adapted as a testcase + by Joseph Myers . */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ +extern void foo (int *); +extern void bar (int); + +void +baz (void) +{ + int i; + if (i) /* { dg-warning "is used uninitialized" "uninit i warning" } */ + bar (i); + foo (&i); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-C-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-C-O0.c new file mode 100644 index 0000000000..305dd36707 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-C-O0.c @@ -0,0 +1,21 @@ +/* Spurious uninitialized variable warning, inspired by libgcc2.c. */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +/* Not all platforms support TImode integers. */ +#if defined(__LP64__) && !defined(__hppa__) +typedef int TItype __attribute__ ((mode (TI))); +#else +typedef long TItype; +#endif + + +TItype +__subvdi3 (TItype a, TItype b) +{ + TItype w; + + w = a - b; + + return w; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-C.c b/SingleSource/Regression/C/gcc-dg/uninit-C.c new file mode 100644 index 0000000000..741106cb46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-C.c @@ -0,0 +1,21 @@ +/* Spurious uninitialized variable warning, inspired by libgcc2.c. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +/* Not all platforms support TImode integers. */ +#if defined(__LP64__) && !defined(__hppa__) +typedef int TItype __attribute__ ((mode (TI))); +#else +typedef long TItype; +#endif + + +TItype +__subvdi3 (TItype a, TItype b) +{ + TItype w; + + w = a - b; + + return w; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-H-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-H-O0.c new file mode 100644 index 0000000000..97221462c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-H-O0.c @@ -0,0 +1,33 @@ +/* PR 14204 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Werror" } */ + +#if defined __alpha__ +# define ASM __asm__("$30") +#elif defined __i386__ +# define ASM __asm__("esp") +#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (_POWER) +# define ASM __asm__("r1") +#elif defined __s390__ +# define ASM __asm__("r15") +#elif defined __mips +# define ASM __asm__("$sp") +#elif defined __sparc__ +# define ASM __asm__("sp") +#elif defined __ia64__ +# define ASM __asm__("r12") +#elif defined __hppa__ +# define ASM __asm__("%r30") +#elif defined __xtensa__ +# define ASM __asm__("sp") +#else +/* The register name should be target-dependent so for other targets, + we just silence the test. */ +# define ASM = 0 +#endif + +void *load_PCB (void) +{ + register void *sp ASM; + return sp; /* { dg-bogus "uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-H.c b/SingleSource/Regression/C/gcc-dg/uninit-H.c new file mode 100644 index 0000000000..b93bf8daac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-H.c @@ -0,0 +1,33 @@ +/* PR 14204 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wall -Werror" } */ + +#if defined __alpha__ +# define ASM __asm__("$30") +#elif defined __i386__ +# define ASM __asm__("esp") +#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (_POWER) +# define ASM __asm__("r1") +#elif defined __s390__ +# define ASM __asm__("r15") +#elif defined __mips +# define ASM __asm__("$sp") +#elif defined __sparc__ +# define ASM __asm__("sp") +#elif defined __ia64__ +# define ASM __asm__("r12") +#elif defined __hppa__ +# define ASM __asm__("%r30") +#elif defined __xtensa__ +# define ASM __asm__("sp") +#else +/* The register name should be target-dependent so for other targets, + we just silence the test. */ +# define ASM = 0 +#endif + +void *load_PCB (void) +{ + register void *sp ASM; + return sp; /* { dg-bogus "uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-I-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-I-O0.c new file mode 100644 index 0000000000..e4b68ba47b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-I-O0.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +int sys_msgctl (void) +{ + struct { int mode; } setbuf; + return setbuf.mode; /* { dg-warning "'setbuf\.mode' is used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-I.c b/SingleSource/Regression/C/gcc-dg/uninit-I.c new file mode 100644 index 0000000000..e59b2add74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-I.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int sys_msgctl (void) +{ + struct { int mode; } setbuf; + return setbuf.mode; /* { dg-warning "'setbuf\.mode' is used" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr100250.c b/SingleSource/Regression/C/gcc-dg/uninit-pr100250.c new file mode 100644 index 0000000000..d47fc24cc5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr100250.c @@ -0,0 +1,30 @@ +/* PR middle-end/100250 - ICE related to -Wmaybe-uninitialized + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +extern void f (int D, const int[D], const int[D]); + +void g (int D, const int a[D], const int b[D], const int c[D], const int d[D]) +{ + int c2[D]; + + for (int i = 0; i < D; i++) { + + if (a[i] >= D) __builtin_abort (); + if (b[i] != d[a[i]]) __builtin_abort (); + + c2[a[i]] = c[i]; + } + + f (D, d, c2); +} + +void h (int D, const int d[D]) +{ + int a[D]; + int b[D]; + int c[D]; + + g (D, a, b, c, d); // { dg-warning "-Wmaybe-uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr100732.c b/SingleSource/Regression/C/gcc-dg/uninit-pr100732.c new file mode 100644 index 0000000000..9c847ce1fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr100732.c @@ -0,0 +1,21 @@ +/* PR middle-end/100732 - ICE on sprintf %s with integer argument + { dg-do compile } + { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +void nowarn_s_i (char *d, int i) +{ + __builtin_sprintf (d, "%s", i); // { dg-warning "\\\[-Wformat" } +} + +void warn_s_i (char *d) +{ + int i; + __builtin_sprintf (d, "%s", i); // { dg-warning "\\\[-Wformat" } + // { dg-warning "\\\[-Wuninitialized" "" { target *-*-* } .-1 } +} + +void warn_i_i (char *d) +{ + int i; + __builtin_sprintf (d, "%i", i); // { dg-warning "\\\[-Wuninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr101300.c b/SingleSource/Regression/C/gcc-dg/uninit-pr101300.c new file mode 100644 index 0000000000..840fd0b2d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr101300.c @@ -0,0 +1,54 @@ +/* PR middle-end/101300 - -fsanitize=undefined suppresses -Wuninitialized + for a VLA read at -O0 + { dg-do compile } + { dg-options "-O0 -Wall -fsanitize=undefined" } + { dg-require-effective-target alloca } */ + +int warn_vla_rd0 (int n) +{ + char a[n]; + return a[0]; // { dg-warning "\\\[-Wuninitialized]" } +} + +int warn_vla_rd1 (int n) +{ + char a[n]; + return a[1]; // { dg-warning "\\\[-Wuninitialized]" } +} + +int warn_vla_rdi (int n, int i) +{ + char a[n]; + return a[i]; // { dg-warning "\\\[-Wuninitialized]" } +} + + +int warn_vla_wr0_rd2_1_0 (int n) +{ + char a[n]; + a[0] = __LINE__; + int x = a[2]; // { dg-warning "\\\[-Wuninitialized]" } + int y = a[1]; // { dg-warning "\\\[-Wuninitialized]" } + int z = a[0]; + return x + y + z; +} + +int warn_vla_wr1_rd2_1_0 (int n) +{ + char a[n]; + a[1] = __LINE__; + int x = a[2]; // { dg-warning "\\\[-Wuninitialized]" } + int y = a[1]; + int z = a[0]; // { dg-warning "\\\[-Wuninitialized]" } + return x + y + z; +} + +int warn_vla_wr2_rd2_1_0 (int n) +{ + char a[n]; + a[2] = __LINE__; + int x = a[2]; + int y = a[1]; // { dg-warning "\\\[-Wuninitialized]" } + int z = a[0]; // { dg-warning "\\\[-Wuninitialized]" } + return x + y + z; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr101494.c b/SingleSource/Regression/C/gcc-dg/uninit-pr101494.c new file mode 100644 index 0000000000..3c68d14959 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr101494.c @@ -0,0 +1,61 @@ +/* PR middle-end/101494 - bogus -Wmaybe-uninitialized on memrchr of size 0 + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +typedef __SIZE_TYPE__ size_t; + +void* alloca (size_t); + +__attribute__ ((malloc, alloc_size (1))) void* alloc (size_t); + +__attribute__ ((access (read_only, 1, 2))) void* sink (void*, size_t); + +void test_alloca_zero (size_t i) +{ + char *p = alloca (0); + sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" } +} + +void test_alloca_zero_pi (size_t i) +{ + char *p = alloca (0); + sink (p + i, 0); +} + +void test_alloca_cst (void) +{ + char *p = alloca (7); + sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" } +} + +void test_alloca_cst_p1 (void) +{ + char *p = alloca (7); + sink (p + 1, 0); // { dg-bogus "\\\[-Wuninitialized" } +} + +void test_alloca_cst_p7 (void) +{ + char *p = alloca (7); + sink (p + 7, 0); // { dg-bogus "\\\[-Wuninitialized" } +} + +void test_alloca_var (size_t n) +{ + char *p = alloca (n); + sink (p, 0); // { dg-bogus "\\\[-Wuninitialized" } +} + +void test_alloca_var_p1 (size_t n) +{ + char *p = alloca (n); + sink (p + 1, 0); // { dg-bogus "\\\[-Wuninitialized" } +} + +void test_alloca_var_pn (size_t n) +{ + char *p = alloca (n); + sink (p + n, 0); // { dg-bogus "\\\[-Wuninitialized" } +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr101573.c b/SingleSource/Regression/C/gcc-dg/uninit-pr101573.c new file mode 100644 index 0000000000..a574844b79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr101573.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wuninitialized" } */ + +int main(int argc, char **argv) +{ + int a; + for(; a < 5; ++a) /* { dg-warning "is used uninitialized" } */ + ; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr101912.c b/SingleSource/Regression/C/gcc-dg/uninit-pr101912.c new file mode 100644 index 0000000000..cb7d7516e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr101912.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int getint (void); +int +tzloadbody (void) +{ + int n = getint (); + int prevcorr; + int leapcnt = 0; + for (int i = 0; i < n; i++) + { + int corr = getint (); + if (corr < 1 || (corr == 1 && !(leapcnt == 0 || (prevcorr < corr ? corr == prevcorr + 1 : (corr == prevcorr || corr == prevcorr - 1))))) /* { dg-bogus "uninitialized" "pr101912" } */ + return -1; + + prevcorr = corr; + leapcnt++; + } + return leapcnt; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr102403-c2.c b/SingleSource/Regression/C/gcc-dg/uninit-pr102403-c2.c new file mode 100644 index 0000000000..81811432da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr102403-c2.c @@ -0,0 +1,34 @@ +/* PR middle-end/102403 - ICE in init_from_control_deps, at + gimple-predicate-analysis.cc:2364 + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +extern int a[], b, c, d, e, f, g, h; + +inline void foo (void) { b = 1 ^ a[b ^ (c & 1)]; } + +void bar (void); + +int main (void) +{ + if (!f && ~h) + { + if (g) + goto L2; + } + else + { + int m = 0; // { dg-message "declared here" } + L1: + e = m; + L2: + m ^= 1; // { dg-warning "-Wmaybe-uninitialized" } + if (d) + bar (); + + for (int j = 0; j < 10; j++) + foo (); + + goto L1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr102403.c b/SingleSource/Regression/C/gcc-dg/uninit-pr102403.c new file mode 100644 index 0000000000..1e62e988fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr102403.c @@ -0,0 +1,49 @@ +/* PR middle-end/102403 - ICE in init_from_control_deps, at + gimple-predicate-analysis.cc:2364 + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +int __fmaf (void) +{ + int a = 0; + int b, c, d, e, f; + + int r = 0; + + switch (b) // { dg-warning "-Wuninitialized" } + { + default: + c |= 1; + + case 0: + if (c == 0) + a = 1; + + switch (d) { + case 15: + f = c; + break; + + case 11: + case 6: + case 4: + f = c; + case 10: + e = a; + } + + if (e == 0) // { dg-warning "-Wmaybe-uninitialized" } + f = 0; + + r = f; + } + + // The return statement below gets the unhelpful warning: + // 'f' may be used uninitialized in this function [-Wmaybe-uninitialized] + return r; +} + +/* Prune out warnings issued on the wrong lines, such as: + uninit-pr102403.c:9:13: warning: ‘d’ is used uninitialized [-Wuninitialized] + { dg-prune-output "-Wuninitialized" } + { dg-prune-output "-Wmaybe-uninitialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr105109.c b/SingleSource/Regression/C/gcc-dg/uninit-pr105109.c new file mode 100644 index 0000000000..001003ca26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr105109.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +static void foo(int dim,float _Complex f0[]) +{ + int d; + f0[0] -= 3.14; /* { dg-bogus "uninitialized" } */ + for (d = 0; d < dim; ++d) f0[0] += 3.14; +} +void bar(int dim, const float _Complex u_t[], float _Complex f0[]) +{ + float _Complex exp[1] = {0.}; + foo(dim, exp); + f0[0] = u_t[0] - exp[0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr106155-1.c b/SingleSource/Regression/C/gcc-dg/uninit-pr106155-1.c new file mode 100644 index 0000000000..5c4410deec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr106155-1.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-ivopts -Wuninitialized" } */ + +int *e; +int f1 (void); +void f2 (int); +long f3 (void *, long, int *); +void f4 (void *); +int *fh; + +void tst (void) +{ + int status; + unsigned char badData[3][3] = { { 7 }, { 16 }, { 23 } }; + int badDataSize[3] = { 1, 1, 1 }; + int i; + + for (i = 0; i < 3; i++) + { + int emax; + if (i == 2) + emax = f1 (); + status = f3 (&badData[i][0], badDataSize[i], fh); + if (status) + { + f1 (); + f1 (); + f1 (); + } + f4 (fh); + *e = 0; + f1 (); + /* When threading the following out of the loop uninit + analysis needs to pick up the loop exit condition + to match up with this guard. + ??? This doesn't work reliably when IVOPTs is run. */ + if (i == 2) + f2 (emax); /* { dg-bogus "uninitialized" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr106866.c b/SingleSource/Regression/C/gcc-dg/uninit-pr106866.c new file mode 100644 index 0000000000..530e274118 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr106866.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-ipa-pure-const -Wuninitialized" } */ + +int n; + +void +empty (int) +{ +} + +int +bar (int x) +{ + return n + x + 1; +} + +__attribute__ ((pure, returns_twice)) int +foo (void) +{ + int uninitialized; + + if (n) + { + if (bar (0)) + return 0; + + __builtin_unreachable (); + } + + while (uninitialized < 1) /* { dg-warning "uninitialized" } */ + { + foo (); + empty (bar (0) == foo ()); + ++uninitialized; + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr106881.c b/SingleSource/Regression/C/gcc-dg/uninit-pr106881.c new file mode 100644 index 0000000000..343b13ed73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr106881.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fexceptions -Wuninitialized" } */ + +void l_free (void *); +char *l_settings_get_string (); +void eap_append_secret (); +inline void auto_free(void *a) { + void **p = a; + l_free(*p); /* { dg-warning "uninitialized" } */ +} +void eap_gtc_check_settings() { + char *identity __attribute__((cleanup(auto_free))); + char password __attribute__((cleanup(auto_free))); + identity = l_settings_get_string(); + eap_append_secret(); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr107839.c b/SingleSource/Regression/C/gcc-dg/uninit-pr107839.c new file mode 100644 index 0000000000..c2edcfaee2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr107839.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int f (int); +void g (int c) +{ + int v; + if (c) + v = f(0); + while (1) + if (c) + f(v + v); /* { dg-bogus "uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr108547.c b/SingleSource/Regression/C/gcc-dg/uninit-pr108547.c new file mode 100644 index 0000000000..d8f6c9ff87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr108547.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int func_7_uc_10li_19 (int); +int li_4, li_5, us_8; +unsigned char func_7_ptr_13, func_7_uc_14; +void func_7_ptr_18() { + if (li_5) { + for (;;) + ; + short s_15; + for (; func_7_uc_14;) { + us_8 = 7; + for (; us_8; us_8 += 1) + lblD2AF1FAB: + if (us_8) + li_4 = 1; + func_7_uc_14 += (__INTPTR_TYPE__)func_7_ptr_18; + if (func_7_ptr_13 & 1 && (func_7_uc_14 &= func_7_ptr_13)) + s_15 %= func_7_uc_10li_19(s_15); /* { dg-warning "uninitialized" } */ + } + } + goto lblD2AF1FAB; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr19430-2.c b/SingleSource/Regression/C/gcc-dg/uninit-pr19430-2.c new file mode 100644 index 0000000000..9617efc23f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr19430-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +int *p, *q; + +int foo (int b) +{ + int i, j = 0; + int *x; + p = &i; + q = &j; + if (b) + x = p; /* { dg-warning "i. may be used uninitialized" } */ + else + x = q; + return *x; +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr19430-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-pr19430-O0.c new file mode 100644 index 0000000000..e9e264deb5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr19430-O0.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wuninitialized" } */ +extern int bar (int); +extern void baz (int *); + +int +foo (int i) +{ + int j; /* { dg-warning "'j' may be used uninitialized" "uninitialized" { xfail *-*-* } } */ + + if (bar (i)) { + baz (&j); + } else { + } + + return j; +} + +int foo2( void ) { + int rc; + return rc; /* { dg-warning "'rc' is used uninitialized" } */ + *&rc = 0; +} + +extern int printf(const char *, ...); +void frob(int *pi); + +int main(void) +{ + int i; + printf("i = %d\n", i); /* { dg-warning "'i' is used uninitialized" } */ + frob(&i); + + return 0; +} + +void foo3(int*); +void bar3(void) { + int x; + if(x) /* { dg-warning "'x' is used uninitialized" } */ + foo3(&x); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr19430.c b/SingleSource/Regression/C/gcc-dg/uninit-pr19430.c new file mode 100644 index 0000000000..417cdc6331 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr19430.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ +extern int bar (int); +extern void baz (int *); +int +foo (int i) +{ + int j; /* { dg-warning "'j' may be used uninitialized" "uninitialized" { xfail *-*-* } } */ + + if (bar (i)) { + baz (&j); + } else { + } + + return j; +} + + + +int foo2( void ) { + int rc; + return rc; /* { dg-warning "'rc' is used uninitialized" } */ + *&rc = 0; +} + +extern int printf(const char *, ...); +void frob(int *pi); + +int main(void) +{ + int i; + printf("i = %d\n", i); /* { dg-warning "'i' is used uninitialized" } */ + frob(&i); + + return 0; +} + +void foo3(int*); +void bar3(void) { + int x; + if(x) /* { dg-warning "'x' is used uninitialized" "uninitialized" } */ + foo3(&x); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr20644-O0.c b/SingleSource/Regression/C/gcc-dg/uninit-pr20644-O0.c new file mode 100644 index 0000000000..a335d8cb4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr20644-O0.c @@ -0,0 +1,24 @@ +/* PR 20644 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wuninitialized" } */ +int foo () +{ + int i = 0; + int j; + + if (1 == i) + return j; /* { dg-bogus "uninitialized" "uninitialized" } */ + + return 0; +} + +int bar () +{ + int i = 1; + int j; + + if (1 == i) + return j; /* { dg-warning "uninitialized" "uninitialized" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr20644.c b/SingleSource/Regression/C/gcc-dg/uninit-pr20644.c new file mode 100644 index 0000000000..a9a73241ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr20644.c @@ -0,0 +1,25 @@ +/* PR 20644 */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ +int foo () +{ + int i = 0; + int j; + + if (1 == i) + return j; + + return 0; +} + +int bar () +{ + int i = 1; + int j; + /* { dg-warning "uninitialized" "uninitialized" { target *-*-* } .-1 } */ + + if (1 == i) + return j; + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr40635.c b/SingleSource/Regression/C/gcc-dg/uninit-pr40635.c new file mode 100644 index 0000000000..fab7c3d49d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr40635.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +struct hostent { + char **h_addr_list; +}; +struct hostent *gethostbyname(const char*); +int socket(void); +int close(int); +int connect(int, const char*); + +int get_tcp_socket(const char *machine) +{ + struct hostent *hp; + int s42, x; + char **addr; + + hp = gethostbyname(machine); + x = 0; + for (addr = hp->h_addr_list; *addr; addr++) + { + s42 = socket(); + if (s42 < 0) + return -1; + x = connect(s42, *addr); + if (x == 0) + break; + close(s42); + } + if (x < 0) + return -1; + return s42; /* { dg-warning "uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr40943.c b/SingleSource/Regression/C/gcc-dg/uninit-pr40943.c new file mode 100644 index 0000000000..2b6e9131cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr40943.c @@ -0,0 +1,10 @@ +/* PR middle-end/40943 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +void +foo (void) +{ + int *p; + *p = 3; /* { dg-warning "is used uninitialized" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr44547.c b/SingleSource/Regression/C/gcc-dg/uninit-pr44547.c new file mode 100644 index 0000000000..ee1035ad7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr44547.c @@ -0,0 +1,61 @@ +/* PR tree-optimization/44547 - -Wuninitialized reports false warning + in nested switch statements + { dg-do compile } + { dg-options "-O1 -Wall" } */ + +__attribute__ ((noipa)) int test_O1 (int argc) +{ + switch( argc ) + { + case 1: + case 2: + case 4: + { + int n; + switch( argc ) + { + case 1: + case 2: + case 4: + n = argc; + break; + } + + return n; + + break; + } + } + + return 0; +} + + +#pragma GCC optimize ("2") + +__attribute__ ((noipa)) int test_O2 (int argc) +{ + switch( argc ) + { + case 1: + case 2: + case 4: + { + int n; + switch( argc ) + { + case 1: + case 2: + case 4: + n = argc; + break; + } + + return n; + + break; + } + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr50476.c b/SingleSource/Regression/C/gcc-dg/uninit-pr50476.c new file mode 100644 index 0000000000..37201841ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr50476.c @@ -0,0 +1,18 @@ +/* PR middle-end/50476 - Warn of pointer set to object whose lifetime is limited + { dg-do compile } + { dg-options "-O1 -Wall" } */ + +int *x = 0; + +void f (void) +{ + int y = 1; + x = &y; // { dg-warning "\\\[-Wdangling-pointer" } +} + +int g (void) +{ + f (); + + return *x; // { dg-warning "\\\[-Wuninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr55060.c b/SingleSource/Regression/C/gcc-dg/uninit-pr55060.c new file mode 100644 index 0000000000..b2f2cb148a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr55060.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/55060 - False un-initialized variable warnings + { dg-do compile } + { dg-options "-O1 -Wuninitialized" } */ + +static void a(int *i) { } +static void b(int p) { } +int foo(void) { + int i; + a(&i); + b(i); // { dg-bogus "\\\[-Wuninitialized" } + return 0; +} + +static void c(int *i) { } +extern void d(int p); +int bar(void) { + int i; + c(&i); + d(i); // { dg-warning "\\\[-Wuninitialized" } + return 0; +} + +extern void e(int *i); +static void f(int p) {}; +int baz(void) { + int i; + e(&i); + f(i); // { dg-bogus "\\\[-Wuninitialized" } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr59970.c b/SingleSource/Regression/C/gcc-dg/uninit-pr59970.c new file mode 100644 index 0000000000..145af657a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr59970.c @@ -0,0 +1,79 @@ +/* PR tree-optimization/59970 - Bogus -Wmaybe-uninitialized at low optimization + levels + { dg-do compile } + { dg-options "-Wall" } */ + +#pragma GCC push_options +#pragma GCC optimize ("1") + +__attribute__ ((noipa)) int +d_demangle_callback_O1 (const char *mangled) +{ + enum { DCT_TYPE, DCT_GLOBAL_DTORS } type; + int dc; + + /* Fails for -Og and -O1. */ + if (mangled) + type = DCT_GLOBAL_DTORS; + else + type = DCT_TYPE; + + /* If both cases assign the same value, all is fine. */ + switch (type) + { + case DCT_TYPE: + dc = 0 /* 1 */; + break; + case DCT_GLOBAL_DTORS: + dc = /* 0 */ 1; + break; + + /* If this is added, all is fine. */ +#ifdef ABORT + default: + __builtin_unreachable (); +#endif + } + + return dc; // { dg-bogus "uninitialized" } +} + +#pragma GCC pop_options + + +#pragma GCC optimize ("Og") + +__attribute__ ((noipa)) int +d_demangle_callback_Og (const char *mangled) +{ + enum { DCT_TYPE, DCT_GLOBAL_DTORS } type; + int dc; + + /* Fails for -Og. */ + /* Removing either the function call or the array dereference, it'll be like + the TOGGLE1 case. */ + extern int cmp (void); + if (cmp () && mangled[0]) + type = DCT_GLOBAL_DTORS; + else + type = DCT_TYPE; + + /* If both cases assign the same value, all is fine. */ + switch (type) + { + case DCT_TYPE: + dc = 0 /* 1 */; + break; + case DCT_GLOBAL_DTORS: + dc = /* 0 */ 1; + break; + + /* If this is added, all is fine. */ +#ifdef ABORT + default: + __builtin_unreachable (); +#endif + } + + return dc; // { dg-bogus "uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr61112.c b/SingleSource/Regression/C/gcc-dg/uninit-pr61112.c new file mode 100644 index 0000000000..d8f9c80291 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr61112.c @@ -0,0 +1,89 @@ +/* PR tree-optimization/61112 - repeated conditional triggers false-positive + -Wmaybe-uninitialized warning + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +int p; + +void foo_c0 (int x, int y, int z) +{ + int w; + if (x) + w = z; + if (y) + w = __LINE__; + + if (x || y) + p = w; // { dg-bogus "-Wmaybe-uninitialized" } +} + + +void foo_c5_1_1 (int x, int y, int z, int a) +{ + int w; + if (x) + w = z; + if (y) + w = __LINE__; + if (a) + w = __LINE__; + + if (x || y || a) + p = w; +} + +void foo_c5_1_2 (int x, int y, int z, int a) +{ + int w; + if (x) + w = z; + if (y) + w = __LINE__; + if (a) + w = __LINE__; + + if (x || a || y) + p = w; +} + +void foo_c5_1_3 (int x, int y, int z, int a) +{ + int w; + if (x) + w = z; + if (y) + w = __LINE__; + if (a) + w = __LINE__; + + if (a || x || y) + p = w; +} + +void foo_c5_2 (int x, int y, int z, int a) +{ + int w; + if (x) + w = __LINE__; + if (y) + w = z; + if (a) + w = __LINE__; + + if (x || y || a) + p = w; // { dg-bogus "-Wmaybe-uninitialized" } +} + +void foo_c5_3 (int x, int y, int z, int a) +{ + int w; + if (x) + w = __LINE__; + if (y) + w = __LINE__; + if (a) + w = z; + + if (x || y || a) + p = w; // { dg-bogus "-Wmaybe-uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr61409.c b/SingleSource/Regression/C/gcc-dg/uninit-pr61409.c new file mode 100644 index 0000000000..c27a67bd07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr61409.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int *rw; +int line_height; +int pixel_width; +int text_cols; +int width1, width2, width3; + +void *pointer; + +void f (int i, int j) +{ + void *ptr; + if (i) + { + if (j) + return; + ptr = pointer; + } + pixel_width = 1234 + width1 + 2 * width2 + 2 * width3; + *rw = text_cols + line_height; + if (i) + rw=ptr; /* { dg-bogus "uninitialized" "bogus warning" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr61677.c b/SingleSource/Regression/C/gcc-dg/uninit-pr61677.c new file mode 100644 index 0000000000..a982fae31a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr61677.c @@ -0,0 +1,26 @@ +/* PR tree-optimization/61677 - False positive with -Wmaybe-uninitialized + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void *xmalloc (void); + +struct menu { struct menu *parent; }; + +struct jump_key { int offset; }; + +void f (struct menu *menu) +{ + int i; + struct menu *submenu[8], *location; + struct jump_key *jump; + location = menu; + for (i = 0; menu && i < 8; menu = menu->parent) + submenu[i++] = menu; + if (location) + jump = xmalloc (); + while (--i >= 0) { + menu = submenu[i]; + if (location) + jump->offset = 42; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr61869.c b/SingleSource/Regression/C/gcc-dg/uninit-pr61869.c new file mode 100644 index 0000000000..ef4f436447 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr61869.c @@ -0,0 +1,47 @@ +/* PR tree-optimization/61869 - Spurious uninitialized warning (lim1 pass, + pretty-printed internal var + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef struct data { + struct data *next; +} data; + +typedef struct list { + unsigned dummy; + struct list *next; + data *start; + int flags; +} list; + +typedef struct iterator { + struct data *ptr; + unsigned dummy; +} iterator; + +iterator start (list *a) { + iterator i = { + *(a->flags ? &a->start : 0), + 0 + }; + return i; +} + +void g (iterator *i); + +void f (list *b) +{ + list *a; + iterator i; // { dg-bogus "-Wmaybe-uninitialized" } + + for (a = b; a; a = a->next) + for (i = start (a); i.ptr; i.ptr = i.ptr->next) + { + if (i.ptr) + return; + } + + for (a = b; a; a = a->next) + for (i = start (a); i.ptr; i.ptr = i.ptr->next) + g(&i); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr63660.c b/SingleSource/Regression/C/gcc-dg/uninit-pr63660.c new file mode 100644 index 0000000000..eab7c7401b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr63660.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +typedef struct +{ + int a; + int b; + int c; + int d; + int e; + int f; + int g; + int h; + int i; + int j; +} X; + +X *XX(int); + +int G(); + +static void F() +{ + X *x; + int m, n; + int xa, xb, xc, xd, xe, xf, xg, xh, xi, xj; + + m = G(); + n = G(); + if ( n & 1 ) xa = G(); + if ( n & 2 ) xb = G(); + if ( n & 4 ) xc = G(); + if ( n & 32 ) xd = G(); + if ( n & 16 ) xe = G(); + if ( n & 64 ) xf = G(); + if ( n & 256 ) xg = G(); + if ( n & 512 ) xh = G(); + if ( n & 1024 ) xi = G(); + if ( n & 2048 ) xj = G(); + + if ( m >= 64 ) return; + x = XX(m); + if ( n & 1 ) x->a = xa; + if ( n & 2 ) x->b = xb; + if ( n & 4 ) x->c = xc; + if ( n & 32 ) x->d = xd; + if ( n & 16 ) x->e = xe; + if ( n & 64 ) x->f = xf; + if ( n & 256 ) x->g = xg; + if ( n & 512 ) x->h = xh; + if ( n & 1024 ) x->i = xi; + if ( n & 2048 ) x->j = xj; /* { dg-bogus "uninitialized" } */ +} + +void H() +{ + F(); +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr65178.c b/SingleSource/Regression/C/gcc-dg/uninit-pr65178.c new file mode 100644 index 0000000000..21eb354fa7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr65178.c @@ -0,0 +1,21 @@ +/* PR tree-optimizatiom/65178 - incorrect -Wmaybe-uninitialized when using + nested loops + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void *bar (int); + +char *foo (void) +{ + char *c = "bla"; + char *buf; + for (int a = 1;; a = 0) + { + for (char *s = c; *s; ++s) + { + } + if (!a) break; + buf = (char *) bar (1); + } + return buf; // { dg-bogus "\\\[-Wmaybe-uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr65182.c b/SingleSource/Regression/C/gcc-dg/uninit-pr65182.c new file mode 100644 index 0000000000..45b538d1a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr65182.c @@ -0,0 +1,44 @@ +/* PR middle-end/65182 - -Wuninitialized fails when pointer to variable + later passed to function + { dg-do compile } + { dg-options "-O0 -Wall" } */ + +void bar (int *a); + +int baz (void); + +__attribute__ ((noipa)) void foo_O0 (int *b) +{ + int a; + + if (a) // { dg-warning "\\\[-Wuninitialized" } + { + *b = 0; + return; + } + + bar (&a); + + a = baz (); + + *b = a + 2; +} + +#pragma GCC optimize ("2") + +__attribute__ ((noipa)) void foo_O2 (int *b) +{ + int a; + + if (a) // { dg-warning "\\\[-Wuninitialized" } + { + *b = 0; + return; + } + + bar (&a); + + a = baz (); + + *b = a + 3; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr65244-1.c b/SingleSource/Regression/C/gcc-dg/uninit-pr65244-1.c new file mode 100644 index 0000000000..7c1d910d54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr65244-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +extern void __attribute__((noreturn)) abort (void); + +int foo (int flag, int val) +{ + int tem; + if (flag) + { + if (val == 0) + abort (); + tem = val; + } + /* large - prevent jump threading */ + __asm__ volatile ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + if (flag) + return tem; /* { dg-bogus "uninitialized" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr65244-2.c b/SingleSource/Regression/C/gcc-dg/uninit-pr65244-2.c new file mode 100644 index 0000000000..a28893cdcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr65244-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Og -Wuninitialized -ftree-bit-ccp -fno-thread-jumps -fdump-tree-uninit2" } */ + +void exit(int __status) __attribute__ ((__noreturn__)); +int posix_memalign(void **__memptr, __SIZE_TYPE__ __alignment, + __SIZE_TYPE__ __size); + +void *f(void) +{ + void *ptr; + + if (posix_memalign(&ptr, 16, 256) != 0) + exit(1); + + return ptr; /* { dg-bogus "uninitialized" } */ +} + +/* Make sure the uninit pass has something to do, add to the set of + disabled optimizations if not. */ +/* { dg-final { scan-tree-dump "# ptr_. = PHI" "uninit2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr65686.c b/SingleSource/Regression/C/gcc-dg/uninit-pr65686.c new file mode 100644 index 0000000000..1962ab76b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr65686.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -fdump-tree-optimized" } */ + +typedef unsigned mytype; + +struct S { + mytype *pu; +}; + +mytype f(struct S *e) +{ + mytype x; /* { dg-bogus { "uninitialized" } } */ + if(&x != e->pu) + __builtin_memcpy(&x, e->pu, sizeof(unsigned)); + return x; +} + +/* { dg-final { scan-tree-dump-not "if" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr78295.c b/SingleSource/Regression/C/gcc-dg/uninit-pr78295.c new file mode 100644 index 0000000000..485c22931d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr78295.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wno-psabi" } */ + +typedef double vectype __attribute__ ((__vector_size__ (16))); + +vectype +f (double x) +{ + vectype t; + for (int i = 0; i < 2; i++) + t[i] = x; /* { dg-bogus "uninitialized" } */ + return t; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr78548.c b/SingleSource/Regression/C/gcc-dg/uninit-pr78548.c new file mode 100644 index 0000000000..12e06dd175 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr78548.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -w -O2" } */ + +char a; +int b; +unsigned c, d; +short e; +int main_f; +int main ( ) { +L0: + if ( e ) goto L1; + b = c & d || a; + if ( !c ) printf ( "", ( long long ) main_f ); + if ( d || !c ) { + printf ( "%llu\n", ( long long ) main ); + goto L2; + } + unsigned g = b; +L1: + b = g; +L2: + if ( b ) goto L0; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr81782.c b/SingleSource/Regression/C/gcc-dg/uninit-pr81782.c new file mode 100644 index 0000000000..7d1e90203f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr81782.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-Wmaybe-uninitialized" } */ + +int +foo (void) +{ + char empty_array[] = { }; + int i, ret = 0; + + for (i = 0; i < (int) (sizeof (empty_array) / sizeof (empty_array[0])); i++) + ret = empty_array[i]; /* { dg-bogus "uninitialized" } */ + + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr81897-2.c b/SingleSource/Regression/C/gcc-dg/uninit-pr81897-2.c new file mode 100644 index 0000000000..644de65522 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr81897-2.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-ccp -fno-tree-dse -Wmaybe-uninitialized" } */ + +int oo; + +void +pc (int *tt) +{ + int cf = 0; + + if (*tt != 0) + { + if (0) + { + int *qg; + int uj = 0; + + t6: + tt = &cf; + if (oo != 0) + { + ++uj; /* { dg-warning "may be used uninit" } */ + *qg = !!oo && !!uj; /* { dg-warning "may be used uninit" } */ + } + } + cf = 0; + goto t6; + } + + if (oo != 0) + { + *tt = 1; + goto t6; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr81897.c b/SingleSource/Regression/C/gcc-dg/uninit-pr81897.c new file mode 100644 index 0000000000..0323050839 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr81897.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int f(void); +static inline void rcu_read_unlock(void) +{ + static _Bool __warned; + if (f() && !__warned && !f()) { + __warned = 1; + } +} +int inet6_rtm_getroute(void) +{ + int dst; + int fibmatch = f(); + + if (!fibmatch) + dst = f(); + rcu_read_unlock(); + if (fibmatch) + dst = 0; + + return dst; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr89230-1.c b/SingleSource/Regression/C/gcc-dg/uninit-pr89230-1.c new file mode 100644 index 0000000000..bf536e2e65 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr89230-1.c @@ -0,0 +1,26 @@ +/* PR middle-end/89230 - Bogus uninited usage warning with printf + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct S { int i, j; }; + +/* attribute__ ((malloc)) */ struct S* f (void); + +int g (void) +{ + struct S *p = f (); + struct S *q; // { dg-bogus "" "uninitialized" { xfail *-*-* } } + + if (p->i || !(q = f ()) || p->j != q->i) + { + __builtin_printf ("%i", p->i); + + if (p->i) + return 1; + + if (!q) // { dg-bogus "\\\[-Wmaybe-uninitialized" "" { xfail *-*-* } } + return 2; + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr89230-2.c b/SingleSource/Regression/C/gcc-dg/uninit-pr89230-2.c new file mode 100644 index 0000000000..473d2da5d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr89230-2.c @@ -0,0 +1,54 @@ +/* PR middle-end/89230 - Bogus uninited usage warning with printf + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern void* memset (void*, int, size_t); +extern int printf (const char*, ...); +extern int rand (void); + +struct S +{ + int a; + int b; +}; + +struct H +{ + int c; + int d; +}; + +void getblk (void* blk) +{ + struct S* s = (struct S*) blk; + memset (blk, 0, 512); + s->a = rand () & 1; +} + +struct H* gethdr (void* blk) +{ + memset (blk, 0, 512); + return rand () & 1 ? (struct H*) blk : 0; +} + +int main (void) +{ + char blk[512], tmp[512]; + struct S *s = (struct S*) blk; + struct H *h; + + getblk (blk); + + if (s->a || !(h = gethdr (tmp)) || s->a != h->d) { + + printf ("%d\n", s->b); + if (s->a) + printf ("s->a = %d\n", s->a); + else if (!h) + printf ("!h\n"); + else + printf ("h->d = %d\n", h->d); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr89296.c b/SingleSource/Regression/C/gcc-dg/uninit-pr89296.c new file mode 100644 index 0000000000..9d81b32b97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr89296.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int get_a_value (); +void printk(const char *); +void test_func() +{ + int loop; + while (!loop) { /* { dg-warning "is used uninitialized" } */ + loop = get_a_value(); + printk("..."); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr90394-1-gimple.c b/SingleSource/Regression/C/gcc-dg/uninit-pr90394-1-gimple.c new file mode 100644 index 0000000000..f8feb6b896 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr90394-1-gimple.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O -Wmaybe-uninitialized" } */ + +unsigned int __GIMPLE (ssa,startwith("uninit1")) +foo (unsigned int v) +{ + /* The warning is not bogus, because (5 & 3) != 0 and therefore if v == 5, + the value of undef is used without being initialized. */ + unsigned int undef; /* { dg-warning "may be used uninitialized" } */ + unsigned int _2; + unsigned int _9; + unsigned int _10; + unsigned pred; + + __BB(2): + if (v_4(D) != 5u) + goto __BB3; + else + goto __BB4; + + /* 'undef' is defined conditionally (under 'v != 5' predicate) */ + __BB(3): + undef_8 = 8u; + goto __BB4; + + /* An undef value flows into a phi. */ + __BB(4): + undef_1 = __PHI (__BB2: undef_5(D), __BB3: undef_8); + pred = v_4(D) & 3u; + if (pred != 0u) + goto __BB5; + else + goto __BB6; + + /* The phi value is used here (under 'v & 3' predicate). */ + __BB(5): + _9 = undef_1; + goto __BB7; + + __BB(6): + _10 = v_4(D); + goto __BB7; + + __BB(7): + _2 = __PHI (__BB5: _9, __BB6: _10); + return _2; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr90394.c b/SingleSource/Regression/C/gcc-dg/uninit-pr90394.c new file mode 100644 index 0000000000..16e750d6b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr90394.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-fre -Wuninitialized" } */ +int pz; +int zi; + +void +uk (void) +{ + int th = 1; + int *gw = &zi; + + for (zi = 0; zi < 2; ++zi) + { + int a2 = 0; + + for (zi = 0; zi < 1; ++zi) + { + th = a2 * 2; + + og: + for (pz = 0; pz < 1; ++pz) + { + } + } + + pz = !!*gw ? *gw : pz; + pz = (!!th ? (pz & 1) : 0); + if (pz == 0) + ++a2; + } + + goto og; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr93100.c b/SingleSource/Regression/C/gcc-dg/uninit-pr93100.c new file mode 100644 index 0000000000..7cb02227bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr93100.c @@ -0,0 +1,75 @@ +/* PR tree-optimization/93100 - gcc -fsanitize=address inhibits -Wuninitialized + { dg-do compile } + { dg-options "-Wall -fsanitize=address" } + { dg-skip-if "no address sanitizer" { no_fsanitize_address } } */ + +struct A +{ + _Bool b; + int i; +}; + +void warn_A_b_O0 (void) +{ + struct A a; + + if (a.b) // { dg-warning "\\\[-Wuninitialized" } + { + (void)&a; + } +} + +void warn_A_i_O0 (void) +{ + struct A a; + + if (a.i) // { dg-warning "\\\[-Wuninitialized" } + { + (void)&a; + } +} + +#pragma GCC optimize ("1") + +void warn_A_b_O1 (void) +{ + struct A a; + + if (a.b) // { dg-warning "\\\[-Wuninitialized" } + { + (void)&a; + } +} + +void warn_A_i_O1 (void) +{ + struct A a; + + if (a.i) // { dg-warning "\\\[-Wuninitialized" } + { + (void)&a; + } +} + + +#pragma GCC optimize ("2") + +void warn_A_b_O2 (void) +{ + struct A a; + + if (a.b) // { dg-warning "\\\[-Wuninitialized" } + { + (void)&a; + } +} + +void warn_A_i_O2 (void) +{ + struct A a; + + if (a.i) // { dg-warning "\\\[-Wuninitialized" } + { + (void)&a; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr95136.c b/SingleSource/Regression/C/gcc-dg/uninit-pr95136.c new file mode 100644 index 0000000000..47d16c5bbb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr95136.c @@ -0,0 +1,63 @@ +/* PR middle-end/95136 - missing -Wuninitialized on an array access with + a variable offset + { dg-do compile } + { dg-options "-O -Wall" } */ + +#define NOIPA __attribute__ ((noipa)) + +NOIPA int a1_addr_varidx_plus_cst (int i) +{ + int a[4]; // { dg-message "'a' declared here" } + int *p = &a[i + 1]; + return *p; // { dg-warning "'a|a\\\[]' is used uninitialized" } +} + +NOIPA int a1_plus_addr_varidx_cst (int i) +{ + int a[4]; // { dg-message "'a' declared here" } + int *p = &a[i] + 1; + return *p; // { dg-warning "'a' is used uninitialized" } +} + +NOIPA int a1_plus_addr_cstidx_var (int i) +{ + int a[4]; // { dg-message "'a' declared here" } + int *p = &a[1] + i; + return *p; // { dg-warning "'a' is used uninitialized" } +} + +NOIPA int a1_plus_addr_varidx_var (int i, int j) +{ + int a[4]; // { dg-message "'a' declared here" } + int *p = &a[i] + j; + return *p; // { dg-warning "'a' is used uninitialized" } +} + + +NOIPA int a2_addr_varidx_plus_cst (int i, int j) +{ + int a[4][4]; // { dg-message "'a' declared here" } + int *p = &a[i + 1][j + 1]; + return *p; // { dg-warning "'a|a\\\[]\\\[]' is used uninitialized" } +} + +NOIPA int a2_plus_addr_varidx_cst (int i, int j) +{ + int a[4][4]; // { dg-message "'a' declared here" } + int *p = &a[i][j] + 1; + return *p; // { dg-warning "'a' is used uninitialized" } +} + +NOIPA int a2_plus_addr_cstidx_var (int i) +{ + int a[4][4]; // { dg-message "'a' declared here" } + int *p = &a[1][1] + i; + return *p; // { dg-warning "'a' is used uninitialized" } +} + +NOIPA int a2_plus_addr_varidx_var (int i, int j, int k) +{ + int a[4][4]; // { dg-message "'a' declared here" } + int *p = &a[i][j] + k; + return *p; // { dg-warning "'a' is used uninitialized" } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr98578.c b/SingleSource/Regression/C/gcc-dg/uninit-pr98578.c new file mode 100644 index 0000000000..db566c7913 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr98578.c @@ -0,0 +1,111 @@ +/* PR middle-end/98578 - ICE warning on uninitialized VLA access + { dg-do compile } + { dg-options "-O2 -Wall -fno-ipa-modref" } + { dg-require-effective-target alloca } */ + +void* malloc (__SIZE_TYPE__); + +void T (int, ...); + +void vla_n (int n, int i) +{ + int a1[n]; + + /* a1[I] should be formatted as as a1[I] (or, for I == 0, perhaps + as *a1), but definitely not as *a1[I]. This is a bug in VLA + formatting. */ + T (a1[0]); // { dg-warning "'a1\\\[0]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "'\\*a1\\\[0]' is used uninitialized" "spurious star" { target *-*-* } .-1 } + T (a1[1]); // { dg-warning "a1\\\[1]' is used uninitialized" } + T (a1[i]); // { dg-warning "a1\\\[i]' is used uninitialized" } +} + +void vla_n_2 (int n, int i) +{ + int a2[n][2]; + + T (a2[0][0]); // { dg-warning "a2\\\[0]\\\[0]' is used uninitialized" } + T (a2[2][1]); // { dg-warning "a2\\\[2]\\\[1]' is used uninitialized" } + T (a2[3][i]); // { dg-warning "a2\\\[3]\\\[i]' is used uninitialized" } + T (a2[i][0]); // { dg-warning "a2\\\[i]\\\[0]' is used uninitialized" } + T (a2[i][i]); // { dg-warning "a2\\\[i]\\\[i]' is used uninitialized" } +} + + +void vla_3_n (int n, int i) +{ + int a2[3][n]; + + T (a2[0][0]); // { dg-warning "a2\\\[0]\\\[0]' is used uninitialized" } + T (a2[1][2]); // { dg-warning "a2\\\[1]\\\[2]' is used uninitialized" } + T (a2[2][i]); // { dg-warning "a2\\\[2]\\\[i]' is used uninitialized" } + T (a2[i][3]); // { dg-warning "a2\\\[i]\\\[3]' is used uninitialized" } + T (a2[i][i]); // { dg-warning "a2\\\[i]\\\[i]' is used uninitialized" } +} + + +void vla_n_n (int n, int i) +{ + int a2[n][n]; + + T (a2[0][0]); // { dg-warning "a2\\\[0]\\\[0]' is used uninitialized" } + T (a2[4][5]); // { dg-warning "a2\\\[4]\\\[5]' is used uninitialized" } + T (a2[6][i]); // { dg-warning "a2\\\[6]\\\[i]' is used uninitialized" } + T (a2[i][7]); // { dg-warning "a2\\\[i]\\\[7]' is used uninitialized" } + T (a2[i][i]); // { dg-warning "a2\\\[i]\\\[i]' is used uninitialized" } +} + + +void char_ptr_n (int n, int i) +{ + char *p = malloc (n); + + T (p[0]); // { dg-warning "'\\\*p' is used uninitialized" } + T (p[1]); // { dg-warning "'p\\\[1]' is used uninitialized" } + T (p[i]); // { dg-warning "'p\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "is used uninitialized" "POINTER_PLUS_EXPR" { target *-*-* } .-1 } +} + + +void int_ptr_n (int n, int i) +{ + int *p = malloc (n); + + T (p[0]); // { dg-warning "'\\\*p' is used uninitialized" } + T (p[1]); // { dg-warning "'p\\\[1]' is used uninitialized" } + T (p[i]); // { dg-warning "'p\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "is used uninitialized" "POINTER_PLUS_EXPR" { target *-*-* } .-1 } +} + + +void int_arr_ptr_n (int n, int i) +{ + int (*p)[n] = malloc (n); + + T ((*p)[0]); // { dg-warning "\\(\\*p\\)\\\[0]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[0]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[1]); // { dg-warning "\\(\\*p\\)\\\[1]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[1]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[i]); // { dg-warning "\\(\\*p\\)\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[i]' is used uninitialized" "missing parens" { target *-*-* } .-1 } +} + + +void int_arr_ptr_n_n (int n, int i) +{ + int (*p)[n][n] = malloc (n); + + T ((*p)[0][0]); // { dg-warning "\\(\\*p\\)\\\[0]\\\[0]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[0]\\\[0]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[1][2]); // { dg-warning "\\(\\*p\\)\\\[1]\\\[2]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[1]\\\[2]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[0][i]); // { dg-warning "\\(\\*p\\)\\\[0]\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[0]\\\[i]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[3][i]); // { dg-warning "\\(\\*p\\)\\\[3]\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[3]\\\[i]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[i][i]); // { dg-warning "\\(\\*p\\)\\\[i]\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[i]\\\[i]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + + T ((*p)[i][i + 1]); // { dg-warning "\\(\\*p\\)\\\[i]\\\[i \\+ 1]' is used uninitialized" "pr98588" { xfail *-*-* } } + // { dg-warning "\\*p\\\[i]\\\[]' is used uninitialized" "missing parens" { target *-*-* } .-1 } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pr98583.c b/SingleSource/Regression/C/gcc-dg/uninit-pr98583.c new file mode 100644 index 0000000000..6159c9512f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pr98583.c @@ -0,0 +1,32 @@ +/* PR middle-end/98583 - missing -Wuninitialized reading from a second VLA + in its own block + { dg-do compile } + { dg-options "-O2 -Wall" } + { dg-require-effective-target alloca } */ + +void f (int*); +void g (int); + +void h1 (int n) +{ + int a[n]; + f (a); + + int b[n]; + g (b[1]); // { dg-warning "\\\[-Wuninitialized" } +} + +void h2 (int n, int i, int j) +{ + if (i) + { + int a[n]; + f (a); + } + + if (j) + { + int b[n]; + g (b[1]); // { dg-warning "\\\[-Wmaybe-uninitialized" } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-10.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-10.c new file mode 100644 index 0000000000..468b4d3ad4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-10.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +enum demangle_component_type { + DEMANGLE_COMPONENT_NAME, + DEMANGLE_COMPONENT_REFERENCE +}; +struct demangle_component { + enum demangle_component_type type; +} d_print_comp_inner_mod_inner, *d_print_comp_inner_dc; +struct d_print_mod { + struct d_print_mod *next; +}; +struct d_print_info { + int templates; + struct d_print_mod *modifiers; +}; +void d_print_comp_inner(struct d_print_info *dpi) +{ + int saved_templates, need_template_restore = 0; + switch (d_print_comp_inner_dc->type) { + case DEMANGLE_COMPONENT_NAME: + goto modifier; + case DEMANGLE_COMPONENT_REFERENCE: + saved_templates = dpi->templates; + need_template_restore = 1; + modifier: + struct d_print_mod dpm; + dpm.next = dpi->modifiers; + d_print_comp_inner_mod_inner = *d_print_comp_inner_dc; + d_print_comp_inner(dpi); + dpi->modifiers = dpm.next; + if (need_template_restore) + dpi->templates = saved_templates; /* { dg-bogus "uninitialized" } */ + } +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-11.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-11.c new file mode 100644 index 0000000000..734df379ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-11.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized" } */ + +extern unsigned bar (void); +extern void quux (void); +int z; +unsigned foo (unsigned v, int y) +{ + unsigned u; + if (v != 1) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 1) is false then (v != 2) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + // This variation from uninit-25.c causes compute_control_dep_chain + // to run into a defect but simple_control_dep_chain saves us here + if (y) + z = 1; + if (v != 1) + return u; /* { dg-bogus "may be used uninitialized" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-12.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-12.c new file mode 100644 index 0000000000..4c66486fb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-12.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wmaybe-uninitialized -fdump-tree-uninit1" } */ + +extern unsigned bar (void); +extern void quux (void); +int z; +unsigned foo (unsigned v, int y, int w) +{ + unsigned u; + if (v != 1) + u = bar (); + + // Prevent the "dom" pass from changing the CFG layout based on the inference + // 'if (v != 1) is false then (v != 2) is true'. (Now it would have to + // duplicate the loop in order to do so, which is deemed expensive.) + for (int i = 0; i < 10; i++) + quux (); + + // This variantion from uninit-pred-11.c caused compute_control_dep_chain + // to run into a defect, producing z != 0 && v != 1, omitting !(i<10) + // from the path predicate + if (w) + { + if (y) + z = 1; + if (v != 1) + return u; /* { dg-bogus "may be used uninitialized" } */ + } + + return 0; +} + +/* Make sure predicate analysis picked up the loop exit condition. */ +/* { dg-final { scan-tree-dump "AND \\(NOT \\((ivtmp|doloop)" "uninit1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-2_a.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-2_a.c new file mode 100644 index 0000000000..5edf21d309 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-2_a.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar (void); +void blah (int); + +int foo (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = 1; + } + + if (m) + g++; + else + bar(); + + if (flag) + blah(v); /* { dg-bogus "uninitialized" "bogus uninitialized var warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-2_b.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-2_b.c new file mode 100644 index 0000000000..ac7697e3c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-2_b.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar (void); +void blah (int); + +int foo (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = 1; + } + + if (m) + g++; + else + bar(); + + /* Wrong guard */ + if (!flag) + blah(v); /* { dg-warning "uninitialized" "real uninitialized var warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-2_c.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-2_c.c new file mode 100644 index 0000000000..bf094d1277 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-2_c.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2 -fno-tree-tail-merge" } */ + +int g; +void bar (void); +void blah (int); + +int foo (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = 1; + } + + if (m) g++; + else bar(); + + if (flag) + blah(v); /* { dg-bogus "uninitialized" "bogus uninitialized var warning" } */ + + return 0; +} + +int foo_2 (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = 1; + } + + if (m) g++; + else bar(); + + if (flag) + blah(v); /* { dg-bogus "uninitialized" "bogus uninitialized var warning" } */ + else + blah(v); /* { dg-warning "uninitialized" "real uninitialized var warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-3_a.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_a.c new file mode 100644 index 0000000000..0ef0650aec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_a.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = 1; + } + + if (m) + g++; + else + bar(); + + if (r > 0) + if (flag) + blah(v); /* {dg-bogus "uninitialized" "bogus warning" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-3_b.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_b.c new file mode 100644 index 0000000000..978210d507 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_b.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = 1; + } + + if (m) + g++; + else + bar(); + + if (r > 0) + goto use; + if (flag) + { +use: + blah(v); /* { dg-warning "uninitialized" "real warning" } */ + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-3_c.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_c.c new file mode 100644 index 0000000000..1309790786 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_c.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = -1; + } + + if (m) + g++; + else + bar(); + + if (r > 0) + if (flag < 0) + blah(v); /* {dg-bogus "uninitialized" "bogus warning" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-3_d.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_d.c new file mode 100644 index 0000000000..9f938763ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_d.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = -1; + } + + if (m) + g++; + else + bar(); + + if (r > 0) + if (flag == -1) + blah(v); /* {dg-bogus "uninitialized" "bogus warning" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-3_e.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_e.c new file mode 100644 index 0000000000..66e2a3a931 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-3_e.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int m, int r) +{ + int flag = 0; + int v; + + if (n) + { + v = r; + flag = -1; + } + + if (m) + g++; + else + bar(); + + if (r > 0) + if (flag <= 0 ) + blah(v); /* { dg-warning "uninitialized" "real warning" } */ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-4_a.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-4_a.c new file mode 100644 index 0000000000..7b2d291a66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-4_a.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); +int foo (int n, int m, int r, int t) +{ + int flag = 0; + int v; + + if (t) + { + if (n) + { + v = r; /* init path 1 */ + flag = 1; + } + + if (m) + g++; + else + bar(); + + if (flag) /* properly guarded */ + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + } + else + { + v = r+1; /* init path 2 */ + flag = 2; + } + + if (m) + g++; + else + bar(); + + if (flag) /* properly guarded */ + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-4_b.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-4_b.c new file mode 100644 index 0000000000..3766395889 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-4_b.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); +int foo (int n, int m, int r, int t) +{ + int flag = 0; + int v; + + if (t) + { + if (n) + { + v = r; /* init path 1 */ + flag = 1; + } + + if (m) g++; + else bar(); + + if (flag) /* properly guarded */ + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + } + else + { + v = r+1; /* init path 2 */ + flag = 2; + } + + if (m) g++; + else bar(); + + if (g) /* guard can not be determined statically to be safe */ + blah(v); /* { dg-warning "uninitialized" "real warning" } */ + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-5_a.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-5_a.c new file mode 100644 index 0000000000..5ced8971c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-5_a.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -Wno-attributes -O2" } */ + +int g; +int bar(); +int blah(int); +void t(int); + +static int +__attribute__((always_inline)) +foo (int n, int* v, int r) +{ + int flag = 0; + if (r > n) + { + *v = bar(); + flag = 1; + } + + if (n > g) + g++; + else + bar(); + + return flag; +} + +int a[100]; +int b[100]; +int blah(int n) +{ + int i; + for (i = 0 ; i < n; i++) + { + int v; + if (!foo (n, &v, b[i])) + return 0; + t (v); /* { dg-bogus "uninitialized" "bogus warning" } */ + } + return 1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-5_b.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-5_b.c new file mode 100644 index 0000000000..e8da256569 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-5_b.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -Wno-attributes -O2" } */ + +int g; +int bar(); +int blah(int); +void t(int); + +static int +__attribute__((always_inline)) +foo (int n, int* v, int r) +{ + int flag = 0; + if (r > n) + { + *v = bar(); + flag = 1; + } + + if (n > g) + g++; + else + bar(); + + return flag; +} + +int a[100]; +int b[100]; +int blah(int n) +{ + int i; + for (i = 0 ; i < n; i++) + { + int v; + if (foo (n, &v, b[i])) + return 0; + t (v); /* { dg-warning "uninitialized" "real warning" } */ + } + return 1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-6_a.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_a.c new file mode 100644 index 0000000000..aa44f76160 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_a.c @@ -0,0 +1,40 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n && l) + v = r; + + if (m) g++; + else bar(); + + if ( n && l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n && l) + v = r; + + if (m) g++; + else bar(); + + if (n) + blah (v); /* { dg-warning "uninitialized" "warning" } */ + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-6_b.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_b.c new file mode 100644 index 0000000000..dcc9a14a3c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_b.c @@ -0,0 +1,46 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n) + if (l) + v = r; + + if (m) g++; + else bar(); + + if ( n && l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if (l) + if (n) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n) + if (l) + v = r; + + if (m) g++; + else bar(); + + if (n || l) + blah (v); /* { dg-warning "uninitialized" "warning" } */ + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-6_c.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_c.c new file mode 100644 index 0000000000..f60868dad2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_c.c @@ -0,0 +1,46 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n > 10) + if (l) + v = r; + + if (m) g++; + else bar(); + + if ( (n > 10) && l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if (l) + if (n > 12) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n > 10) + if (l) + v = r; + + if (m) g++; + else bar(); + + if (n > 8 ) + if (l) + blah (v); /* { dg-warning "uninitialized" "warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-6_d.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_d.c new file mode 100644 index 0000000000..704c3e6e1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_d.c @@ -0,0 +1,24 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n) + v = r; + + if (m) g++; + else bar(); + + if ( n && l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-6_e.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_e.c new file mode 100644 index 0000000000..21f429daf4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-6_e.c @@ -0,0 +1,43 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n > 10) + v = r; + + if (m) g++; + else bar(); + + if ( (n > 10) && (l < 100)) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n > 100 ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n > 10) + v = r; + + if (m) g++; + else bar(); + + if ( n < 10) + blah (v); /* { dg-warning "uninitialized" "warning" } */ + + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-7_a.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-7_a.c new file mode 100644 index 0000000000..c2ba2a4248 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-7_a.c @@ -0,0 +1,54 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n || l) + v = r; + + if (m) g++; + else bar(); + + if ( n && l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( l ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n || l) + v = r; + + if (m) g++; + else bar(); + + if ( n && l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if (m || l) + blah (v); /* { dg-warning "uninitialized" "warning" } */ + + if ( l ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-7_b.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-7_b.c new file mode 100644 index 0000000000..338d18c95e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-7_b.c @@ -0,0 +1,23 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n > 10) + v = r; + + if (m) g++; + else bar(); + + if (( n > 10) || (l != 100)) + blah (v); /* { dg-warning "uninitialized" "warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-7_c.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-7_c.c new file mode 100644 index 0000000000..1bbe5014de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-7_c.c @@ -0,0 +1,33 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n) + v = r; + + if (m) g++; + else bar(); + + if (n ) + { + if (l) + g++; + else + goto l; + } + else + { +l: + blah (v); /* { dg-warning "uninitialized" "warning" } */ + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-7_d.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-7_d.c new file mode 100644 index 0000000000..06111731a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-7_d.c @@ -0,0 +1,54 @@ + +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Wuninitialized -O2 -mbranch-cost=0" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n || l) + v = r; + + if (m) g++; + else bar(); + + if ( n && l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( l ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n || l) + v = r; + + if (m) g++; + else bar(); + + if ( n && l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if (m || l) + blah (v); /* { dg-warning "uninitialized" "warning" } */ + + if ( l ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-8_a.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-8_a.c new file mode 100644 index 0000000000..c4cdf48598 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-8_a.c @@ -0,0 +1,47 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ +/* Pick a particular tuning to pin down BRANCH_COST. */ +/* { dg-additional-options "-mtune=cortex-a15" { target arm*-*-* } } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n || m || r || l) + v = r; + + if (m) g++; + else bar(); + + if ( n || m || r || l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( l ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n || m || r ) + v = r; + + if (m) g++; + else bar(); + + if ( n || m || r || l) + blah(v); /* { dg-warning "uninitialized" "warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-8_b.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-8_b.c new file mode 100644 index 0000000000..d9c3c42c30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-8_b.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* ??? Jump threading makes a mess of the logical-op-non-short-circuit=0 case + so force it our way. */ +/* { dg-options "-Wuninitialized -O2 --param logical-op-non-short-circuit=1" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n < 10 || m > 100 || r < 20 || l) + v = r; + + if (m) g++; + else bar(); + + if ( n < 10 || m > 100 || r < 20 ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n < 10 || m > 100 || r < 10 ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n < 10 || m > 100 || r < 20 || l) + v = r; + + if (m) g++; + else bar(); + + if ( n < 10 || m > 100 || r < 20 ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n < 10 || m > 100 || r < 30 ) + blah(v); /* { dg-warning "uninitialized" "warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-8_c.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-8_c.c new file mode 100644 index 0000000000..39d1bcd934 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-8_c.c @@ -0,0 +1,39 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n < 10 && m > 100 && r < 20 ) + v = r; + + if (m) g++; + else bar(); + + if ( n <= 8 && m > 101 && r < 19 ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n < 10 && m > 100 && r < 20 ) + v = r; + + if (m) g++; + else bar(); + + if ( n <= 8 && m > 99 && r < 19 ) + blah(v); /* { dg-warning "uninitialized" "warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-8_d.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-8_d.c new file mode 100644 index 0000000000..ccdea2967a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-8_d.c @@ -0,0 +1,45 @@ + +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Wuninitialized -O2 -mbranch-cost=0" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if (n || m || r || l) + v = r; + + if (m) g++; + else bar(); + + if ( n || m || r || l) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( n ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + if ( l ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if (n || m || r ) + v = r; + + if (m) g++; + else bar(); + + if ( n || m || r || l) + blah(v); /* { dg-warning "uninitialized" "warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-9_a.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-9_a.c new file mode 100644 index 0000000000..67fb8ab977 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-9_a.c @@ -0,0 +1,23 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if ( (n < 10) && (m == l) && (r < 20) ) + v = r; + + if (m) g++; + else bar(); + + if ( (n <= 8) && (m == l) && (r < 19) ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-pred-9_b.c b/SingleSource/Regression/C/gcc-dg/uninit-pred-9_b.c new file mode 100644 index 0000000000..0f508fa56e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-pred-9_b.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -O2" } */ + +int g; +void bar(); +void blah(int); + +int foo (int n, int l, int m, int r) +{ + int v; + + if ( (n < 10) && (m != 100) && (r < 20) ) + v = r; + + if (m) g++; + else bar(); + + if (l > 100) + if ( (n <= 9) && (m < 100) && (r < 19) ) + blah(v); /* { dg-bogus "uninitialized" "bogus warning" { xfail powerpc*-*-* cris-*-* riscv*-*-* } } */ + + if ( (n <= 8) && (m < 99) && (r < 19) ) + blah(v); /* { dg-bogus "uninitialized" "pr101674" { xfail mmix-*-* } } */ + + return 0; +} + +int foo_2 (int n, int l, int m, int r) +{ + int v; + + if ( (n < 10) && (m != 100) && (r < 20) ) + v = r; + + if (m) g++; + else bar(); + + if (l > 100) + if ( (n <= 8) && (m < 101) && (r < 19) ) + blah(v); /* { dg-warning "uninitialized" "real warning" } */ + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-suppress.c b/SingleSource/Regression/C/gcc-dg/uninit-suppress.c new file mode 100644 index 0000000000..53e6bcf118 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-suppress.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-ccp -fno-tree-vrp -O2 -Wuninitialized -Wno-maybe-uninitialized" } */ +void blah(); +void bar (int); +int gflag; + +void foo() +{ + int v; + if (gflag) + v = 10; + + blah(); /* *gflag may be killed, but compiler won't know */ + + if (gflag) + bar(v); /* { dg-bogus "uninitialized" "should be suppressed" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-suppress_2.c b/SingleSource/Regression/C/gcc-dg/uninit-suppress_2.c new file mode 100644 index 0000000000..b617609f5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-suppress_2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-tree-dominator-opts -fno-tree-ccp -fno-tree-vrp -fno-tree-fre -fno-tree-pre -fno-code-hoisting -O2 -Wuninitialized -Werror=uninitialized -Wno-error=maybe-uninitialized" } */ +void blah(); +void bar (int); +int gflag; + +void foo() +{ + int v; + if (gflag) + v = 10; + + blah(); /* *gflag may be killed, but compiler won't know */ + + if (gflag) + bar(v); /* { dg-warning "uninitialized" "should not be promoted to error" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/uninit-suppress_3.c b/SingleSource/Regression/C/gcc-dg/uninit-suppress_3.c new file mode 100644 index 0000000000..7bbe9edc60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/uninit-suppress_3.c @@ -0,0 +1,98 @@ +/* PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration + site + { dg-do compile } + { dg-options "-O1 -Wall" } */ + +struct A +{ + int x; +}; + +// Verify that suppression works at every inlining level. + +static int f0 (int *x) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + + return ++*x; + +#pragma GCC diagnostic pop +} + +static int f1 (int *p, int n) +{ + struct A a; + for (int i = 0; i < n; ++i) { + if (p[i] > 1) { + a = (struct A){p[i]}; + } + } + + return f0 (&a.x); +} + +int f2 (void) +{ + int a[] = { 1, 2, 3, 4 }; + return f1 (a, 4); +} + + +static int g0 (int *x) +{ + return ++*x; +} + +static int g1 (int *p, int n) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + + struct A a; + for (int i = 0; i < n; ++i) { + if (p[i] > 1) { + a = (struct A){p[i]}; + } + } + + return g0 (&a.x); + +#pragma GCC diagnostic pop +} + +int g2 (void) +{ + int a[] = { 1, 2, 3, 4, 5 }; + return g1 (a, 5); +} + + +static int h0 (int *x) +{ + return ++*x; +} + +static int h1 (int *p, int n) +{ + struct A a; + for (int i = 0; i < n; ++i) { + if (p[i] > 1) { + a = (struct A){p[i]}; + } + } + + return h0 (&a.x); +} + +int h2 (void) +{ + int a[] = { 1, 2, 3, 4, 5, 6 }; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + + return h1 (a, 6); + +#pragma GCC diagnostic pop +} diff --git a/SingleSource/Regression/C/gcc-dg/union-1.c b/SingleSource/Regression/C/gcc-dg/union-1.c new file mode 100644 index 0000000000..0dd2df9b06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-1.c @@ -0,0 +1,22 @@ +/* PR target/15783 */ +/* Origin: Paul Pluzhnikov */ + +/* This used to ICE on SPARC 64-bit because the back-end was + returning an invalid construct for the return value of fu2. */ + +/* { dg-do compile } */ + +union u2 { + struct + { + int u2s_a, u2s_b, u2s_c, u2s_d, u2s_e; + } u2_s; + double u2_d; +} u2a; + +union u2 fu2(); + +void unions() +{ + u2a = fu2(); +} diff --git a/SingleSource/Regression/C/gcc-dg/union-2.c b/SingleSource/Regression/C/gcc-dg/union-2.c new file mode 100644 index 0000000000..edc8a7abf1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-2.c @@ -0,0 +1,28 @@ +/* This used to segfault on SPARC 64-bit at runtime because + the stack pointer was clobbered by the function call. */ + +/* { dg-do run } */ + +#include + +union U +{ + long l1[2]; +}; + +union U u; + +void foo (int z, ...) +{ + int i; + va_list ap; + va_start(ap,z); + i = va_arg(ap, int); + va_end(ap); +} + +int main(void) +{ + foo (1, 1, 1, 1, 1, u); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/union-3.c b/SingleSource/Regression/C/gcc-dg/union-3.c new file mode 100644 index 0000000000..3e89b755af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-3.c @@ -0,0 +1,10 @@ +/* PR target/27421 */ +/* { dg-do compile } */ + +union A +{ + int i; + void x[1]; /* { dg-error "array of voids" } */ +}; + +void foo(union A a) {} diff --git a/SingleSource/Regression/C/gcc-dg/union-4.c b/SingleSource/Regression/C/gcc-dg/union-4.c new file mode 100644 index 0000000000..0ed98206c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-4.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-rtl-cse1" } */ + +extern void abort(void); + +typedef unsigned int uint32; +typedef unsigned long long uint64; + +typedef union { + uint32 i32; + uint64 i64; +} u64; + +void foo(void) +{ + u64 data; + data.i64 = 1; + if (data.i32 != 1) + abort (); +} + +/* { dg-final { scan-rtl-dump-not "abort" "cse1" { target i?86-*-* x86_64-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/union-5.c b/SingleSource/Regression/C/gcc-dg/union-5.c new file mode 100644 index 0000000000..ea65f4b027 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-5.c @@ -0,0 +1,46 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -fgcse -fno-split-wide-types" } */ + +extern void abort(void); + +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +typedef struct +{ + uint16_t thread; + uint16_t phase; +} s32; + +typedef union +{ + uint32_t i; + s32 s; +} u32; + +typedef union +{ + uint64_t i; + u32 u; +} u64; + +static __attribute__((noinline)) +void foo(int val) +{ + u64 data; + uint32_t thread; + + data.u.i = 0x10000L; + thread = data.u.s.thread; + if (val) + abort (); + if (thread) + abort (); +} + +int main(void) +{ + foo (0); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/union-cast-1.c b/SingleSource/Regression/C/gcc-dg/union-cast-1.c new file mode 100644 index 0000000000..1d7f4d549d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-cast-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ +/* A combine of two extensions to C89 are used here. + First casts to unions is used. + Second subscripting non lvalue arrays, this is in C99. */ + +union vx {short f[8]; int v;}; +int vec; + +void +foo5 (int vec) +{ + ((union vx) vec).f[5] = 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/union-cast-2.c b/SingleSource/Regression/C/gcc-dg/union-cast-2.c new file mode 100644 index 0000000000..9aac5caa29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-cast-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c89 -pedantic-errors" } */ +/* PR 23155 + We should get two error messages, one about union cast + and the other about array access for non lvalues. */ + + +union vx {short f[8]; int v;}; +int vec; + +void +foo5 (int vec) +{ + ((union vx) vec).f[5] = 1; /* { dg-error "(forbids subscripting)|(forbids casts to union type)" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/union-cast-3.c b/SingleSource/Regression/C/gcc-dg/union-cast-3.c new file mode 100644 index 0000000000..5f9b9f8687 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-cast-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ +/* PR 23155 + We should get one error messag, one about union cast. */ + + +union vx {short f[8]; int v;}; +int vec; + +void +foo5 (int vec) +{ + ((union vx) vec).f[5] = 1; /* { dg-error "forbids casts to union type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/union-cast-4.c b/SingleSource/Regression/C/gcc-dg/union-cast-4.c new file mode 100644 index 0000000000..a1c98ba14a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-cast-4.c @@ -0,0 +1,8 @@ +/* PR c/35748 */ + +union U { void x[1]; }; /* { dg-error "array of voids" } */ + +void foo() +{ + (union U)0; /* { dg-error "type not present" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/union-duplicate-field.c b/SingleSource/Regression/C/gcc-dg/union-duplicate-field.c new file mode 100644 index 0000000000..da9a945d9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/union-duplicate-field.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +int a0; + +struct S +{ + int a1; + union { + int a0; + int a1; /* { dg-error "duplicate member" } */ + int a2, a3, a4, a5, a6, a7, a8, a9; + int a10, a11, a12, a13, a14, a15; + }; +}; + +int f() +{ + struct S s; + return s.a0; +} diff --git a/SingleSource/Regression/C/gcc-dg/unordered-1.c b/SingleSource/Regression/C/gcc-dg/unordered-1.c new file mode 100644 index 0000000000..1310532de3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unordered-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +void bar (int); + +void foo (int i, float f) +{ + bar (__builtin_isgreater (i, i)); /* { dg-error "non-floating-point" } */ + bar (__builtin_isgreater (f, i)); + bar (__builtin_isgreater (i, f)); + bar (__builtin_isgreater (f, 2)); + bar (__builtin_isgreater (f, 2.0f)); + bar (__builtin_isgreater (f, 2.0)); + bar (__builtin_isgreater (2, f)); + bar (__builtin_isgreater (2.0f, f)); + bar (__builtin_isgreater (2.0, f)); + bar (__builtin_isgreater (&f, i)); /* { dg-error "non-floating-point" } */ + bar (__builtin_isgreater (f, &i)); /* { dg-error "non-floating-point" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/unordered-2.c b/SingleSource/Regression/C/gcc-dg/unordered-2.c new file mode 100644 index 0000000000..0696d37cfb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unordered-2.c @@ -0,0 +1,51 @@ +/* { dg-do link } */ + +void link_error (); + +int main() +{ + if (__builtin_isgreater(1.0,2.0) != 0) + link_error (); + if (__builtin_isgreater(3.0,3.0) != 0) + link_error (); + if (__builtin_isgreater(5.0,4.0) == 0) + link_error (); + + if (__builtin_isgreaterequal(1.0,2.0) != 0) + link_error (); + if (__builtin_isgreaterequal(3.0,3.0) == 0) + link_error (); + if (__builtin_isgreaterequal(5.0,4.0) == 0) + link_error (); + + if (__builtin_isless(1.0,2.0) == 0) + link_error (); + if (__builtin_isless(3.0,3.0) != 0) + link_error (); + if (__builtin_isless(5.0,4.0) != 0) + link_error (); + + if (__builtin_islessequal(1.0,2.0) == 0) + link_error (); + if (__builtin_islessequal(3.0,3.0) == 0) + link_error (); + if (__builtin_islessequal(5.0,4.0) != 0) + link_error (); + + if (__builtin_islessgreater(1.0,2.0) == 0) + link_error (); + if (__builtin_islessgreater(3.0,3.0) != 0) + link_error (); + if (__builtin_islessgreater(5.0,4.0) == 0) + link_error (); + + if (__builtin_isunordered(1.0,2.0) != 0) + link_error (); + if (__builtin_isunordered(3.0,3.0) != 0) + link_error (); + if (__builtin_isunordered(5.0,4.0) != 0) + link_error (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/unordered-3.c b/SingleSource/Regression/C/gcc-dg/unordered-3.c new file mode 100644 index 0000000000..d08abd0ca0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unordered-3.c @@ -0,0 +1,80 @@ +/* { dg-do link } */ +/* { dg-options "-fno-finite-math-only" } */ + +void link_error (); + +void test1() +{ + if (__builtin_isgreater(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isgreater(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_isgreaterequal(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isgreaterequal(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_isless(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isless(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_islessequal(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_islessequal(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_islessgreater(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_islessgreater(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_isunordered(1.0,__builtin_nan("")) == 0) + link_error (); + if (__builtin_isunordered(__builtin_nan(""),1.0) == 0) + link_error (); +} + + +void test2(double x) +{ + if (__builtin_isgreater(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isgreater(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_isgreaterequal(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isgreaterequal(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_isless(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isless(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_islessequal(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_islessequal(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_islessgreater(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_islessgreater(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_isunordered(x,__builtin_nan("")) == 0) + link_error (); + if (__builtin_isunordered(__builtin_nan(""),x) == 0) + link_error (); +} + + +int main() +{ + test1 (); + test2 (1.0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/unroll-1.c b/SingleSource/Regression/C/gcc-dg/unroll-1.c new file mode 100644 index 0000000000..fc6f39a975 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-1.c @@ -0,0 +1,28 @@ +/* PR optimization/8599 */ +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-loops -fdump-rtl-loop2_unroll-details-blocks" } */ +/* { dg-options "-mtune=k6 -O2 -funroll-loops -fdump-rtl-loop2_unroll-details-blocks" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ + + +extern void abort (void); + +int array[6] = { 1,2,3,4,5,6 }; + +void foo() +{ + int i; + + for (i = 0; i < 5; i++) + array[i] = 0; +} + +int main() +{ + foo(); + if (array[0] || array [1] || array[2] || array[3] || array[4]) + abort (); + if (array[5] != 6) + abort (); + return 0; +} +/* { dg-final { scan-rtl-dump-not "Invalid sum" "loop2_unroll" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-10.c b/SingleSource/Regression/C/gcc-dg/unroll-10.c new file mode 100644 index 0000000000..0559915f2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-10.c @@ -0,0 +1,13 @@ +/* { dg-options "-O3 -fdump-tree-unrolljam" } */ + +void +f (int *restrict x, int *restrict y, int z[restrict 100][100]) +{ + for (int j = 0; j < 100; ++j) + for (int i = 0; i < 100; ++i) + x[i] += y[i] * z[j][i]; +} + +/* The loop should be unrolled 2 times, leaving one load from x, + one load from y and 2 loads from z. */ +/* { dg-final { scan-tree-dump-times { = \(*\*} 4 "unrolljam" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-2.c b/SingleSource/Regression/C/gcc-dg/unroll-2.c new file mode 100644 index 0000000000..8baceaac16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cunrolli-details=stderr -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fenable-tree-cunrolli" } */ + +/* Blank lines can occur in the output of + -fdump-tree-cunrolli-details=stderr. */ +/* { dg-allow-blank-lines-in-output 1 } */ + +unsigned a[100], b[100]; +inline void bar() +{ + a[10] = b[10]; +} + +int foo(void) +{ + int i; + bar(); + for (i = 0; i < 2; i++) /* { dg-optimized "loop with 2 iterations completely unrolled" } */ + { + a[i]= b[i] + 1; + } + return 1; +} + +int foo2(void) +{ + int i; + for (i = 0; i < 2; i++) /* { dg-optimized "loop with 2 iterations completely unrolled" } */ + { + a[i]= b[i] + 1; + } + return 1; +} +/* { dg-prune-output ".*" } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-3.c b/SingleSource/Regression/C/gcc-dg/unroll-3.c new file mode 100644 index 0000000000..fbc8378c73 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-3.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cunrolli-details-blocks -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunrolli=foo -fenable-tree-cunrolli=foo" } */ + +unsigned a[100], b[100]; +inline void bar() +{ + a[10] = b[10]; +} + +int foo(void) +{ + int i; + bar(); + for (i = 0; i < 2; i++) + { + a[i]= b[i] + 1; + } + return 1; +} + +int foo2(void) +{ + int i; + for (i = 0; i < 2; i++) + { + a[i]= b[i] + 1; + } + return 1; +} + +/* { dg-final { scan-tree-dump-times "loop with 2 iterations completely unrolled" 1 "cunrolli" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "cunrolli" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-4.c b/SingleSource/Regression/C/gcc-dg/unroll-4.c new file mode 100644 index 0000000000..055ef3f354 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cunrolli-details-blocks -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fenable-tree-cunrolli=foo -fdisable-tree-cunrolli=foo2" } */ + +unsigned a[100], b[100]; +inline void bar() +{ + a[10] = b[10]; +} + +int foo(void) +{ + int i; + bar(); + for (i = 0; i < 2; i++) + { + a[i]= b[i] + 1; + } + return 1; +} + +int foo2(void) +{ + int i; + for (i = 0; i < 2; i++) + { + a[i]= b[i] + 1; + } + return 1; +} + +/* { dg-final { scan-tree-dump-times "loop with 2 iterations completely unrolled" 1 "cunrolli" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "cunrolli" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-5.c b/SingleSource/Regression/C/gcc-dg/unroll-5.c new file mode 100644 index 0000000000..1f22b1fa5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-5.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-cunrolli-details-blocks -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fenable-tree-cunrolli=foo2 -fdisable-tree-cunrolli=foo" } */ + +unsigned a[100], b[100]; +inline void bar() +{ + a[10] = b[10]; +} + +int foo(void) +{ + int i; + bar(); + for (i = 0; i < 2; i++) + { + a[i]= b[i] + 1; + } + return 1; +} + +int foo2(void) +{ + int i; + for (i = 0; i < 2; i++) + { + a[i]= b[i] + 1; + } + return 1; +} + +/* { dg-final { scan-tree-dump-times "loop with 2 iterations completely unrolled" 1 "cunrolli" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "cunrolli" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-6.c b/SingleSource/Regression/C/gcc-dg/unroll-6.c new file mode 100644 index 0000000000..7664bbff10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-6.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-rtl-loop2_unroll-details-blocks -funroll-loops" } */ +/* { dg-require-effective-target int32plus } */ + +void abort (void); +int *a; +/* Fails on MIPS16 because equality checks are implemented using XOR. + It's unlikely MIPS16 users would want unrolling anyway. */ +#ifdef __mips +__attribute__((nomips16)) +#endif +int t() +{ + int i; + for (i=0;i<1000000;i++) + if (a[i]) + return 1; + return 0; +} +#ifdef __mips +__attribute__((nomips16)) +#endif +int t2() +{ + int i; + for (i=0;i<3000000;i++) + if (a[i]) + abort (); + return 0; +} +/* { dg-final { scan-rtl-dump-times " upper bound: 999999" 1 "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump-not "realistic bound: 999999" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump-times " upper bound: 2999999" 1 "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump-times "realistic bound: 2999999" 1 "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump-not "Invalid sum" "loop2_unroll" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-7.c b/SingleSource/Regression/C/gcc-dg/unroll-7.c new file mode 100644 index 0000000000..17c5e533c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-7.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-vectorize -fdump-rtl-loop2_unroll-blocks-details -funroll-loops" } */ +/* { dg-require-effective-target int32plus } */ + +extern int *a; + +int t(void) +{ + int i; + for (i=0;i<1000000;i++) + a[i]++; +} +/* { dg-final { scan-rtl-dump "Unrolled loop" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump "number of iterations: .const_int 999999" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump "upper bound: 999999" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump "realistic bound: 999999" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump "considering unrolling loop with constant number of iterations" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump-not "Invalid sum" "loop2_unroll" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-8.c b/SingleSource/Regression/C/gcc-dg/unroll-8.c new file mode 100644 index 0000000000..4388f47d4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-8.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-loop2_unroll-details-blocks -funroll-loops" } */ +/* { dg-additional-options "-fno-tree-vectorize" { target amdgcn-*-* } } */ + +struct a {int a[7];}; +int t(struct a *a, int n) +{ + int i; + for (i=0;ia[i]++; +} +/* { dg-final { scan-rtl-dump-not "Unrolled loop" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump "likely upper bound: 6" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump "realistic bound: -1" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump "Not unrolling loop, doesn't roll" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump-not "Invalid sum" "loop2_unroll" } } */ +/* { dg-final { scan-rtl-dump-not "upper bound: -1" "loop2_unroll" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-9.c b/SingleSource/Regression/C/gcc-dg/unroll-9.c new file mode 100644 index 0000000000..2d65ec3691 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-9.c @@ -0,0 +1,12 @@ +/* { dg-options "-O3 -fdump-tree-unrolljam -fno-math-errno" } */ + +void +f (float *restrict x, float y[100][100]) +{ + for (int j = 0; j < 100; ++j) + for (int i = 0; i < 100; ++i) + x[i] += __builtin_expf (y[j][i]); +} + +/* The loop should be unrolled 2 times, without a tail loop. */ +/* { dg-final { scan-tree-dump-times "__builtin_expf" 2 "unrolljam" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unroll-and-jam.c b/SingleSource/Regression/C/gcc-dg/unroll-and-jam.c new file mode 100644 index 0000000000..b8f4f16dc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unroll-and-jam.c @@ -0,0 +1,126 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -floop-unroll-and-jam -fno-tree-loop-im --param unroll-jam-min-percent=0 -fdump-tree-unrolljam-details" } */ +/* { dg-additional-options "--param max-completely-peel-times=16" { target { s390*-*-* } } } */ +/* { dg-require-effective-target int32plus } */ + +#include +extern unsigned int a[]; +extern unsigned int b[]; +extern unsigned int aa[][1024]; +unsigned int checksum; +void checkaa(void) +{ + unsigned sum = 1; + unsigned long i, j; + for (i = 0; i < 1024; i++) { + for (j = 0; j < 16; j++) { + sum += aa[j][i]*31+47; + } + } + checksum = checksum * 27 + sum; + //printf(" %d\n", sum); +} + +void checkb(void) +{ + unsigned sum = 1; + unsigned long i, j; + for (i = 0; i < 1024; i++) { + sum += b[i]*31+47; + } + checksum = checksum * 27 + sum; + //printf(" %d\n", sum); +} + +#define TEST(name, body, test) \ +static void __attribute__((noinline,noclone)) name (unsigned long n, unsigned long m) \ +{ \ + unsigned i, j; \ + for (i = 1; i < m; i++) { \ + for (j = 1; j < n; j++) { \ + body; \ + } \ + } \ + test; \ +} \ +static void __attribute__((noinline,noclone,optimize("O1"))) name ## noopt (unsigned long n, unsigned long m) \ +{ \ + unsigned long i, j; \ + for (i = 1; i < m; i++) { \ + for (j = 1; j < n; j++) { \ + body; \ + } \ + } \ + test; \ +} +TEST(foo1, aa[i+1][j+1]=aa[i][j] * aa[i][j] / 2, checkaa()) //ok, -1,-1 +TEST(foo2, aa[i][j+1]=3*aa[i+1][j], checkaa()) //notok, 1,-1 +TEST(foo3, aa[i+1][j-1]=aa[i][j] * aa[i][j] / 2, checkaa()) //notok, -1,1 +TEST(foo4, aa[i][j] = aa[i-1][j+1] * aa[i-1][j+1] / 2, checkaa()) //notok, -1,1 +TEST(foo5, aa[i][j] = aa[i+1][j+1] * aa[i+1][j+1] / 2, checkaa()) //ok, 1,1 +TEST(foo6, aa[i][j] = aa[i+1][j] * aa[i+1][j] / 2, checkaa()) //ok, -1,0 +TEST(foo61, aa[i][0] = aa[i+1][0] * aa[i+1][0] / 2, checkaa()) //notok, -1,0 +TEST(foo62, aa[i][j/2] = aa[i+1][j/2] * aa[i+1][j/2] / 2, checkaa()) //notok, not affine +TEST(foo63, aa[i][j%2] = aa[i+1][j%2] * aa[i+1][j%2] / 2, checkaa()) //notok, not affine +TEST(foo7, aa[i+1][j] = aa[i][j] * aa[i][j] / 2, checkaa()) //ok, 1,0 +TEST(foo9, b[j] = 3*b[j+1] + 1, checkb()) //notok, 0,-1 +TEST(foo10, b[j] = 3*b[j] + 1, checkb()) //ok, 0,0 +extern int f; +TEST(foo11, f = b[i-1] = 1 + 3* b[i+1], checkb()) //ok, 2,0 but must reduce unroll factor to 2, (it would be incorrect with unroll-by-3, which the profitability would suggest) + +/* foo8 should work as well, but currently doesn't because the distance + vectors we compute are too pessimistic. We compute + (0,1), (1,1) and (1,-1) + and the last one causes us to lose. */ +TEST(foo8, b[j+1] = 3*b[j] + 1, checkb()) //ok, 0,1 + +int f; +unsigned int a[1024]; +unsigned int b[1024]; +unsigned int aa[16][1024]; +void init(void) +{ + unsigned long i,j; + for (i = 0; i < 1024; i++) { + for (j = 0; j < 16; j++) { + aa[j][i] = ((j+1)*2+i+1) % 17; + } + a[i] = ((i+1)*31) % 19; + b[i] = ((i+1)*47) % 23; + } + checksum = 1; +} + +#define RUN(name) \ + printf(" %s\n", #name); \ + init();for(i=0;i<4;i++)name##noopt(32,8); checka = checksum; \ + init();for(i=0;i<4;i++)name(32,8); \ + if (checka != checksum) fail = 1; \ + printf("%sok %s\n", checka != checksum ? "NOT " : "", #name); + +int main() +{ + int fail = 0; + int i; + unsigned checka; + RUN(foo1); + RUN(foo2); + RUN(foo3); + RUN(foo4); + RUN(foo5); + RUN(foo6); + RUN(foo61); + RUN(foo62); + RUN(foo63); + RUN(foo7); + RUN(foo8); + RUN(foo9); + RUN(foo10); + RUN(foo11); + if (fail) + __builtin_abort(); + return fail; +} + +/* Six loops should be unroll-jammed (actually seven, but see above). */ +/* { dg-final { scan-tree-dump-times "applying unroll and jam" 6 "unrolljam" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/unsigned-long-compare.c b/SingleSource/Regression/C/gcc-dg/unsigned-long-compare.c new file mode 100644 index 0000000000..74e7638f1c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unsigned-long-compare.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. */ +/* Contributed by Carlos O'Donell on 2006-01-30 */ + +/* Test a division corner case where the expression simplifies + to a comparison, and the optab expansion is wrong. The optab + expansion emits a function whose return is unbiased and needs + adjustment. */ +/* Origin: Carlos O'Donell */ +/* { dg-do run } */ +/* { dg-options "" } */ +#include + +#define BIG_CONSTANT 0xFFFFFFFF80000000ULL + +int main (void) +{ + unsigned long long OneULL = 1ULL; + unsigned long long result; + + result = OneULL / BIG_CONSTANT; + if (result) + abort (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/unused-1.c b/SingleSource/Regression/C/gcc-dg/unused-1.c new file mode 100644 index 0000000000..8db7c2ccff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-1.c @@ -0,0 +1,11 @@ +/* Missing `unused parameter' warning. + egcs-1.1.2 fails, egcs-ss-19990418 passes. + http://gcc.gnu.org/ml/gcc-bugs/1998-09/msg00199.html */ +/* { dg-do compile } */ +/* { dg-options "-O -Wall -W" } */ +int +f(c) + char c; /* { dg-warning "unused parameter" "unused parameter warning" } */ +{ + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/unused-2.c b/SingleSource/Regression/C/gcc-dg/unused-2.c new file mode 100644 index 0000000000..454606ec95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-2.c @@ -0,0 +1,18 @@ +/* Copyright (C) 2000 Free Software Foundation. + + by Alexandre Oliva */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -finline-functions -Wunused -Wreturn-type" } */ + +static void +foo () +{ + skip_it: ; /* { dg-warning "defined but not used" "unused label warning" } */ +} + +void +bar () +{ + foo (); +} diff --git a/SingleSource/Regression/C/gcc-dg/unused-3.c b/SingleSource/Regression/C/gcc-dg/unused-3.c new file mode 100644 index 0000000000..cd64abd4b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-3.c @@ -0,0 +1,15 @@ +/* Copyright (C) 2000 Free Software Foundation. */ +/* Added extra line-breaks to check that diagnostics refer to correct token. + --Per Bothner. */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +typedef short unused_type __attribute__ ((unused)); +int +main () +{ + short + x /* { dg-warning "unused variable" "unused variable warning" } */ + ; + unused_type y; +} diff --git a/SingleSource/Regression/C/gcc-dg/unused-4.c b/SingleSource/Regression/C/gcc-dg/unused-4.c new file mode 100644 index 0000000000..5323600800 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-4.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused -O3" } */ + +static const int i = 0; /* { dg-warning "defined but not used" } */ +static void f() { } /* { dg-warning "defined but not used" } */ +static inline void g() { } diff --git a/SingleSource/Regression/C/gcc-dg/unused-5.c b/SingleSource/Regression/C/gcc-dg/unused-5.c new file mode 100644 index 0000000000..bdd5c8ecd4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-5.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ +/* { dg-final { scan-assembler "string_to_look_for" } } */ +/* nvptx outputs strings as array of ints. */ +/* { dg-skip-if "" { nvptx-*-* } } */ + +/* 'volatile' variables get output and don't produce a warning about being + unused. */ +static volatile char string[] + = "string_to_look_for"; /* { dg-bogus "not used" } */ diff --git a/SingleSource/Regression/C/gcc-dg/unused-6-WallWextra.c b/SingleSource/Regression/C/gcc-dg/unused-6-WallWextra.c new file mode 100644 index 0000000000..d2d80be062 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-6-WallWextra.c @@ -0,0 +1,11 @@ +/* PR 28875 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wextra -Wall" } */ +static int t(int i) /* { dg-warning "unused parameter" "unused parameter warning" } */ +{ + return 0; +} +int tt() +{ + return t(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/unused-6-no.c b/SingleSource/Regression/C/gcc-dg/unused-6-no.c new file mode 100644 index 0000000000..0923cfb813 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-6-no.c @@ -0,0 +1,11 @@ +/* PR 28875 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -Wextra -Wno-unused-parameter -Wall" } */ +static int t(int i) /* { dg-bogus "unused parameter" "unused parameter warning" } */ +{ + return 0; +} +int tt() +{ + return t(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/unused-6.c b/SingleSource/Regression/C/gcc-dg/unused-6.c new file mode 100644 index 0000000000..7651ecb28c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-6.c @@ -0,0 +1,11 @@ + +/* { dg-do compile } */ +/* { dg-options "-O3 -Wunused-parameter" } */ +static int t(int i) /* { dg-warning "unused parameter" "unused parameter warning" } */ +{ + return 0; +} +int tt() +{ + return t(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/unused-7.c b/SingleSource/Regression/C/gcc-dg/unused-7.c new file mode 100644 index 0000000000..d2b9c3c1b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-7.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +static int a = 10; /* { dg-warning "defined but not used" } */ + diff --git a/SingleSource/Regression/C/gcc-dg/unused-8a.c b/SingleSource/Regression/C/gcc-dg/unused-8a.c new file mode 100644 index 0000000000..b9b5690515 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-8a.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra -Wno-unused" } */ + +void foo(int x) { } diff --git a/SingleSource/Regression/C/gcc-dg/unused-8b.c b/SingleSource/Regression/C/gcc-dg/unused-8b.c new file mode 100644 index 0000000000..5b4b894937 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-8b.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wno-unused -Wextra" } */ + +void foo(int x) { } diff --git a/SingleSource/Regression/C/gcc-dg/unused-9.c b/SingleSource/Regression/C/gcc-dg/unused-9.c new file mode 100644 index 0000000000..bdf36e1f50 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-9.c @@ -0,0 +1,13 @@ +/* PR c/98260 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + + +void g(void) +{ + int i = 0; + volatile int x; + (x, i++); /* { dg-bogus "set but not used" } */ +} + + diff --git a/SingleSource/Regression/C/gcc-dg/unused-variable-1.c b/SingleSource/Regression/C/gcc-dg/unused-variable-1.c new file mode 100644 index 0000000000..cb86c3bc8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-variable-1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused-variable" } */ + +static int a = 0; /* { dg-warning "defined but not used" } */ +static const int b = 0; /* { dg-warning "defined but not used" } */ +static int c __attribute__ ((unused)) = 0; +static const char rcsid[] __attribute__ ((unused)) = "version-string"; diff --git a/SingleSource/Regression/C/gcc-dg/unused-variable-2.c b/SingleSource/Regression/C/gcc-dg/unused-variable-2.c new file mode 100644 index 0000000000..0496466a45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-variable-2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused-variable -Wno-unused-const-variable" } */ + +static int a = 0; /* { dg-warning "defined but not used" } */ +static const int b = 0; +static int c __attribute__ ((unused)) = 0; +static const char rcsid[] = "version-string"; diff --git a/SingleSource/Regression/C/gcc-dg/unused-variable-3.c b/SingleSource/Regression/C/gcc-dg/unused-variable-3.c new file mode 100644 index 0000000000..6aca95813e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unused-variable-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused-variable" } */ + +static const int cmain = 42; /* { dg-warning "defined but not used" } */ + +/* Don't warn for unused static consts in headers, + unless -Wunused-const-variable=2. */ +#line 1 "header.h" +static const int cheader = 42; diff --git a/SingleSource/Regression/C/gcc-dg/unwind-1.c b/SingleSource/Regression/C/gcc-dg/unwind-1.c new file mode 100644 index 0000000000..a035af1f2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/unwind-1.c @@ -0,0 +1,7 @@ +/* { dg-do assemble { target { ! { powerpc-ibm-aix* nvptx-*-* } } } } */ +/* { dg-options "-fleading-underscore -funwind-tables" } */ + +void func(void) __asm("_func"); +void _func(int x) {} +void func(void) {} + diff --git a/SingleSource/Regression/C/gcc-dg/utf-array-short-wchar.c b/SingleSource/Regression/C/gcc-dg/utf-array-short-wchar.c new file mode 100644 index 0000000000..81b452a33a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-array-short-wchar.c @@ -0,0 +1,46 @@ +/* Contributed by Kris Van Hees */ +/* Expected errors for char16_t/char32_t string literals. */ +/* { dg-do compile } */ +/* { dg-require-effective-target wchar } */ +/* { dg-options "-std=gnu99 -fshort-wchar" } */ + +#include + +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; + +const char s_0[] = "ab"; +const char s_1[] = u"ab"; /* { dg-error "from a string literal with type array of" } */ +const char s_2[] = U"ab"; /* { dg-error "from a string literal with type array of" } */ +const char s_3[] = L"ab"; /* { dg-error "from a string literal with type array of" } */ +const char s_4[] = u8"ab"; + +const char16_t s16_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ +const char16_t s16_1[] = u"ab"; +const char16_t s16_2[] = U"ab"; /* { dg-error "from a string literal with type array of" } */ +const char16_t s16_3[] = L"ab"; +const char16_t s16_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ + +const char16_t s16_5[0] = u"ab"; /* { dg-warning " is too long" } */ +const char16_t s16_6[1] = u"ab"; /* { dg-warning " is too long" } */ +const char16_t s16_7[2] = u"ab"; +const char16_t s16_8[3] = u"ab"; +const char16_t s16_9[4] = u"ab"; + +const char32_t s32_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ +const char32_t s32_1[] = u"ab"; /* { dg-error "from a string literal with type array of" } */ +const char32_t s32_2[] = U"ab"; +const char32_t s32_3[] = L"ab"; /* { dg-error "from a string literal with type array of" } */ +const char32_t s32_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ + +const char32_t s32_5[0] = U"ab"; /* { dg-warning " is too long" } */ +const char32_t s32_6[1] = U"ab"; /* { dg-warning " is too long" } */ +const char32_t s32_7[2] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ +const char32_t s32_8[3] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ +const char32_t s32_9[4] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ + +const wchar_t sw_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ +const wchar_t sw_1[] = u"ab"; +const wchar_t sw_2[] = U"ab"; /* { dg-error "from a string literal with type array of" } */ +const wchar_t sw_3[] = L"ab"; +const wchar_t sw_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ diff --git a/SingleSource/Regression/C/gcc-dg/utf-array.c b/SingleSource/Regression/C/gcc-dg/utf-array.c new file mode 100644 index 0000000000..7f0cb915e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-array.c @@ -0,0 +1,46 @@ +/* Contributed by Kris Van Hees */ +/* Expected errors for char16_t/char32_t string literals. */ +/* { dg-do compile } */ +/* { dg-require-effective-target wchar } */ +/* { dg-options "-std=gnu99" } */ + +#include + +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; + +const char s_0[] = "ab"; +const char s_1[] = u"ab"; /* { dg-error "from a string literal with type array of" } */ +const char s_2[] = U"ab"; /* { dg-error "from a string literal with type array of" } */ +const char s_3[] = L"ab"; /* { dg-error "from a string literal with type array of .(long |short )?(unsigned )?int." } */ +const char s_4[] = u8"ab"; + +const char16_t s16_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ +const char16_t s16_1[] = u"ab"; +const char16_t s16_2[] = U"ab"; /* { dg-error "from a string literal with type array of" } */ +const char16_t s16_3[] = L"ab"; /* { dg-error "from a string literal with type array of .(long |short )?(unsigned )?int." "" { target { ! wchar_t_char16_t_compatible } } } */ +const char16_t s16_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ + +const char16_t s16_5[0] = u"ab"; /* { dg-warning " is too long" } */ +const char16_t s16_6[1] = u"ab"; /* { dg-warning " is too long" } */ +const char16_t s16_7[2] = u"ab"; +const char16_t s16_8[3] = u"ab"; +const char16_t s16_9[4] = u"ab"; + +const char32_t s32_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ +const char32_t s32_1[] = u"ab"; /* { dg-error "from a string literal with type array of" } */ +const char32_t s32_2[] = U"ab"; +const char32_t s32_3[] = L"ab"; /* { dg-error "from a string literal with type array of .(long |short )?(unsigned )?int." "" { target { ! wchar_t_char32_t_compatible } } } */ +const char32_t s32_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ + +const char32_t s32_5[0] = U"ab"; /* { dg-warning " is too long" } */ +const char32_t s32_6[1] = U"ab"; /* { dg-warning " is too long" } */ +const char32_t s32_7[2] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ +const char32_t s32_8[3] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ +const char32_t s32_9[4] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ + +const wchar_t sw_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ +const wchar_t sw_1[] = u"ab"; /* { dg-error "from a string literal with type array of" "" { target { ! wchar_t_char16_t_compatible } } } */ +const wchar_t sw_2[] = U"ab"; /* { dg-error "from a string literal with type array of" "" { target { ! wchar_t_char32_t_compatible } } } */ +const wchar_t sw_3[] = L"ab"; +const wchar_t sw_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ diff --git a/SingleSource/Regression/C/gcc-dg/utf-badconcat.c b/SingleSource/Regression/C/gcc-dg/utf-badconcat.c new file mode 100644 index 0000000000..61ce495ed3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-badconcat.c @@ -0,0 +1,22 @@ +/* Contributed by Kris Van Hees */ +/* Test unsupported concatenation of char16_t/char32_t* string literals. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void *s0 = u"a" "b"; +void *s1 = "a" u"b"; +void *s2 = u"a" U"b"; /* { dg-error "non-standard concatenation" } */ +void *s3 = U"a" u"b"; /* { dg-error "non-standard concatenation" } */ +void *s4 = u"a" L"b"; /* { dg-error "non-standard concatenation" } */ +void *s5 = L"a" u"b"; /* { dg-error "non-standard concatenation" } */ +void *s6 = u"a" u"b"; +void *s7 = U"a" "b"; +void *s8 = "a" U"b"; +void *s9 = U"a" L"b"; /* { dg-error "non-standard concatenation" } */ +void *sa = L"a" U"b"; /* { dg-error "non-standard concatenation" } */ +void *sb = U"a" U"b"; +void *sc = L"a" "b"; +void *sd = "a" L"b"; +void *se = L"a" L"b"; + +int main () {} diff --git a/SingleSource/Regression/C/gcc-dg/utf-badconcat2.c b/SingleSource/Regression/C/gcc-dg/utf-badconcat2.c new file mode 100644 index 0000000000..ea71a7f685 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-badconcat2.c @@ -0,0 +1,15 @@ +/* Test unsupported concatenation of UTF-8 string literals. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void *s0 = u8"a" "b"; +void *s1 = "a" u8"b"; +void *s2 = u8"a" u8"b"; +void *s3 = u8"a" u"b"; /* { dg-error "non-standard concatenation" } */ +void *s4 = u"a" u8"b"; /* { dg-error "non-standard concatenation" } */ +void *s5 = u8"a" U"b"; /* { dg-error "non-standard concatenation" } */ +void *s6 = U"a" u8"b"; /* { dg-error "non-standard concatenation" } */ +void *s7 = u8"a" L"b"; /* { dg-error "non-standard concatenation" } */ +void *s8 = L"a" u8"b"; /* { dg-error "non-standard concatenation" } */ + +int main () {} diff --git a/SingleSource/Regression/C/gcc-dg/utf-cvt.c b/SingleSource/Regression/C/gcc-dg/utf-cvt.c new file mode 100644 index 0000000000..d9927824e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-cvt.c @@ -0,0 +1,59 @@ +/* Contributed by Kris Van Hees */ +/* Test the char16_t and char32_t promotion rules. */ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-std=gnu99 -Wall -Wconversion -Wsign-conversion" } */ + +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; + +extern void f_c (char); +extern void fsc (signed char); +extern void fuc (unsigned char); +extern void f_s (short); +extern void fss (signed short); +extern void fus (unsigned short); +extern void f_i (int); +extern void fsi (signed int); +extern void fui (unsigned int); +extern void f_l (long); +extern void fsl (signed long); +extern void ful (unsigned long); +extern void f_ll (long long); +extern void fsll (signed long long); +extern void full (unsigned long long); + +void m (char16_t c0, char32_t c1) +{ + f_c (c0); /* { dg-warning "conversion from .char16_t\[^\n\r\]*. to .char. may change value" } */ + fsc (c0); /* { dg-warning "may change value" } */ + fuc (c0); /* { dg-warning "may change value" } */ + f_s (c0); /* { dg-warning "change the sign" } */ + fss (c0); /* { dg-warning "change the sign" } */ + fus (c0); + f_i (c0); + fsi (c0); + fui (c0); + f_l (c0); + fsl (c0); + ful (c0); + f_ll (c0); + fsll (c0); + full (c0); + + f_c (c1); /* { dg-warning "may change value" } */ + fsc (c1); /* { dg-warning "may change value" } */ + fuc (c1); /* { dg-warning "may change value" } */ + f_s (c1); /* { dg-warning "may change value" } */ + fss (c1); /* { dg-warning "may change value" } */ + fus (c1); /* { dg-warning "may change value" } */ + f_i (c1); /* { dg-warning "change the sign" "" { target { ! int16 } } } */ + fsi (c1); /* { dg-warning "change the sign" "" { target { ! int16 } } } */ + fui (c1); + f_l (c1); /* { dg-warning "change the sign" "" { target { llp64 || ilp32 } } } */ + fsl (c1); /* { dg-warning "change the sign" "" { target { llp64 || ilp32 } } } */ + ful (c1); + f_ll (c1); + fsll (c1); + full (c1); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf-dflt.c b/SingleSource/Regression/C/gcc-dg/utf-dflt.c new file mode 100644 index 0000000000..18ca30e8b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-dflt.c @@ -0,0 +1,25 @@ +/* Contributed by Kris Van Hees */ +/* If not gnu99, the u and U prefixes should be parsed as separate tokens. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +const unsigned short c0 = u'a'; /* { dg-error "undeclared" "undeclared" } */ + /* { dg-error "expected ',' or ';'" "expected" { target *-*-* } .-1 } */ +const unsigned long c1 = U'a'; /* { dg-error "undeclared" "undeclared" } */ + /* { dg-error "expected ',' or ';'" "expected" { target *-*-* } .-1 } */ + +#define u 1 + +#define U 2 + + +const unsigned short c2 = u'a'; +const unsigned long c3 = U'a'; + +#undef u +#undef U +#define u "a" +#define U "b" + +const void *s0 = u"a"; +const void *s1 = U"a"; + +int main () {} diff --git a/SingleSource/Regression/C/gcc-dg/utf-dflt2.c b/SingleSource/Regression/C/gcc-dg/utf-dflt2.c new file mode 100644 index 0000000000..5e38b09c9b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-dflt2.c @@ -0,0 +1,12 @@ +/* If not gnu99, the u8 prefix should be parsed as separate tokens. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +const void *s0 = u8"a"; /* { dg-error "undeclared" "undeclared" } */ + /* { dg-error "expected ',' or ';'" "expected" { target *-*-* } .-1 } */ + +#define u8 "a" + +const void *s1 = u8"a"; + +int main () {} diff --git a/SingleSource/Regression/C/gcc-dg/utf-inc-init.c b/SingleSource/Regression/C/gcc-dg/utf-inc-init.c new file mode 100644 index 0000000000..531d21b269 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-inc-init.c @@ -0,0 +1,45 @@ +/* Contributed by Kris Van Hees */ +/* Test incremental initializers for char16_t/char32_t arrays. */ +/* { dg-do run { target int32plus } } */ +/* { dg-options "-std=gnu99" } */ + +typedef __SIZE_TYPE__ size_t; +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; + +extern int memcmp (const void *, const void *, size_t); +extern void abort (void); +extern void exit (int); + +struct A { + char16_t S[6]; + int M; +} a[] = { { { u"foo" }, 1 }, [0].S[2] = u'x', [0].S[4] = u'y' }; +struct A b[] = { { { u"foo" }, 1 }, [0] = { .S[0] = u'b' } }; +struct A c[] = { { { u"foo" }, 1 }, [0].S = { u"a" }, [0].M = 2 }; + +struct B { + char32_t S[6]; + int M; +} d[] = { { { U"foo" }, 1 }, [0].S[2] = U'x', [0].S[4] = U'y' }; +struct B e[] = { { { U"foo" }, 1 }, [0] = { .S[0] = U'b' } }; +struct B f[] = { { { U"foo" }, 1 }, [0].S = { U"a" }, [0].M = 2 }; + +int main (void) +{ + if (memcmp (a[0].S, u"fox\0y", 6 * sizeof(char16_t)) || a[0].M != 1) + abort (); + if (memcmp (b[0].S, u"b\0\0\0\0", 6) || b[0].M) + abort (); + if (memcmp (c[0].S, u"a\0\0\0\0", 6) || c[0].M != 2) + abort (); + + if (memcmp (d[0].S, U"fox\0y", 6 * sizeof(char32_t)) || d[0].M != 1) + abort (); + if (memcmp (e[0].S, U"b\0\0\0\0", 6) || e[0].M) + abort (); + if (memcmp (f[0].S, U"a\0\0\0\0", 6) || f[0].M != 2) + abort (); + + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf-type.c b/SingleSource/Regression/C/gcc-dg/utf-type.c new file mode 100644 index 0000000000..1aa6020cbe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf-type.c @@ -0,0 +1,18 @@ +/* Contributed by Kris Van Hees */ +/* Ensure that __CHAR16_TYPE__ and __CHAR32_TYPE__ exist, and are of the + correct width. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; + +extern void abort (void); + +int main () +{ + if (sizeof (char16_t) != sizeof (u'a')) + abort(); + if (sizeof (char32_t) != sizeof (U'a')) + abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf16-1.c b/SingleSource/Regression/C/gcc-dg/utf16-1.c new file mode 100644 index 0000000000..f2343d2a94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf16-1.c @@ -0,0 +1,67 @@ +/* Contributed by Kris Van Hees */ +/* Test the support for char16_t character constants. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef __CHAR16_TYPE__ char16_t; + +extern void abort (void); + +char16_t c0 = u'a'; +char16_t c1 = u'\0'; +char16_t c2 = u'\u0024'; +char16_t c3 = u'\u2029'; +char16_t c4 = u'\u8010'; + +char16_t c5 = 'a'; +char16_t c6 = U'a'; +char16_t c7 = U'\u2029'; +char16_t c8 = U'\u8010'; +char16_t c9 = L'a'; +char16_t ca = L'\u2029'; +char16_t cb = L'\u8010'; + +#define A 0x0061 +#define D 0x0024 +#define X 0x2029 +#define Y 0x8010 + +int main () +{ + if (sizeof (u'a') != sizeof (char16_t)) + abort (); + if (sizeof (u'\0') != sizeof (char16_t)) + abort (); + if (sizeof (u'\u0024') != sizeof (char16_t)) + abort (); + if (sizeof (u'\u2029') != sizeof (char16_t)) + abort (); + if (sizeof (u'\u8010') != sizeof (char16_t)) + abort (); + + if (c0 != A) + abort (); + if (c1 != 0x0000) + abort (); + if (c2 != D) + abort (); + if (c3 != X) + abort (); + if (c4 != Y) + abort (); + + if (c5 != A) + abort (); + if (c6 != A) + abort (); + if (c7 != X) + abort (); + if (c8 != Y) + abort (); + if (c9 != A) + abort (); + if (ca != X) + abort (); + if (cb != Y) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf16-2.c b/SingleSource/Regression/C/gcc-dg/utf16-2.c new file mode 100644 index 0000000000..7fc5ef1ab6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf16-2.c @@ -0,0 +1,32 @@ +/* Contributed by Kris Van Hees */ +/* Test the support for char16_t* string literals. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef __CHAR16_TYPE__ char16_t; + +extern void abort (void); + +char16_t *s0 = u"ab"; +char16_t *s1 = u"a\u0024"; +char16_t *s2 = u"a\u2029"; +char16_t *s3 = u"a\U00064321"; + +#define A 0x0061 +#define B 0x0062 +#define D 0x0024 +#define X 0x2029 +#define Y1 0xD950 +#define Y2 0xDF21 + +int main () +{ + if (s0[0] != A || s0[1] != B || s0[2] != 0x0000) + abort (); + if (s1[0] != A || s1[1] != D || s0[2] != 0x0000) + abort (); + if (s2[0] != A || s2[1] != X || s0[2] != 0x0000) + abort (); + if (s3[0] != A || s3[1] != Y1 || s3[2] != Y2 || s3[3] != 0x0000) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf16-3.c b/SingleSource/Regression/C/gcc-dg/utf16-3.c new file mode 100644 index 0000000000..ed2eb408bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf16-3.c @@ -0,0 +1,49 @@ +/* Contributed by Kris Van Hees */ +/* Test concatenation of char16_t* string literals. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef __CHAR16_TYPE__ char16_t; + +extern void abort (void); + +char16_t *s0 = u"a" u"b"; + +char16_t *s1 = u"a" "b"; +char16_t *s2 = "a" u"b"; +char16_t *s3 = u"a" "\u2029"; +char16_t *s4 = "\u2029" u"b"; +char16_t *s5 = u"a" "\U00064321"; +char16_t *s6 = "\U00064321" u"b"; + +#define A 0x0061 +#define B 0x0062 +#define X 0x2029 +#define Y1 0xD950 +#define Y2 0xDF21 + +int main () +{ + if (sizeof ((u"a" u"b")[0]) != sizeof (char16_t)) + abort (); + if (sizeof ((u"a" "b")[0]) != sizeof (char16_t)) + abort (); + if (sizeof (( "a" u"b")[0]) != sizeof (char16_t)) + abort (); + + if (s0[0] != A || s0[1] != B || s0[2] != 0x0000) + abort (); + + if (s1[0] != A || s1[1] != B || s1[2] != 0x0000) + abort (); + if (s2[0] != A || s2[1] != B || s2[2] != 0x0000) + abort (); + if (s3[0] != A || s3[1] != X || s3[2] != 0x0000) + abort (); + if (s4[0] != X || s4[1] != B || s4[2] != 0x0000) + abort (); + if (s5[0] != A || s5[1] != Y1 || s5[2] != Y2 || s5[3] != 0x0000) + abort (); + if (s6[0] != Y1 || s6[1] != Y2 || s6[2] != B || s6[3] != 0x0000) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf16-4.c b/SingleSource/Regression/C/gcc-dg/utf16-4.c new file mode 100644 index 0000000000..60e00f60ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf16-4.c @@ -0,0 +1,21 @@ +/* Contributed by Kris Van Hees */ +/* Expected errors for char16_t character constants. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +typedef __CHAR16_TYPE__ char16_t; + +char16_t c0 = u''; /* { dg-error "empty character" } */ +char16_t c1 = u'ab'; /* { dg-warning "constant too long" } */ +char16_t c2 = u'\U00064321'; /* { dg-warning "constant too long" } */ + +char16_t c3 = 'a'; +char16_t c4 = U'a'; +char16_t c5 = U'\u2029'; +char16_t c6 = U'\U00064321'; /* { dg-warning "conversion from .(long )?unsigned int. to 'char16_t' {aka '(short )?unsigned int'} changes value from .410401. to .17185." } */ +char16_t c7 = L'a'; +char16_t c8 = L'\u2029'; +char16_t c9 = L'\U00064321'; /* { dg-warning "conversion" "" { target { 4byte_wchar_t } } } */ + /* { dg-warning "constant too long" "" { target { ! 4byte_wchar_t } } .-1 } */ + +int main () {} diff --git a/SingleSource/Regression/C/gcc-dg/utf32-1.c b/SingleSource/Regression/C/gcc-dg/utf32-1.c new file mode 100644 index 0000000000..f9d24c4d0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf32-1.c @@ -0,0 +1,44 @@ +/* Contributed by Kris Van Hees */ +/* Test the support for char32_t character constants. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef __CHAR32_TYPE__ char32_t; + +extern void abort (void); + +char32_t c0 = U'a'; +char32_t c1 = U'\0'; +char32_t c2 = U'\u0024'; +char32_t c3 = U'\u2029'; +char32_t c4 = U'\U00064321'; + +#define A 0x00000061 +#define D 0x00000024 +#define X 0x00002029 +#define Y 0x00064321 + +int main () +{ + if (sizeof (U'a') != sizeof (char32_t)) + abort (); + if (sizeof (U'\0') != sizeof (char32_t)) + abort (); + if (sizeof (U'\u0024') != sizeof (char32_t)) + abort (); + if (sizeof (U'\u2029') != sizeof (char32_t)) + abort (); + if (sizeof (U'\U00064321') != sizeof (char32_t)) + abort (); + + if (c0 != A) + abort (); + if (c1 != 0x0000) + abort (); + if (c2 != D) + abort (); + if (c3 != X) + abort (); + if (c4 != Y) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf32-2.c b/SingleSource/Regression/C/gcc-dg/utf32-2.c new file mode 100644 index 0000000000..c0d23fb36e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf32-2.c @@ -0,0 +1,31 @@ +/* Contributed by Kris Van Hees */ +/* Test the support for char32_t* string constants. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef __CHAR32_TYPE__ char32_t; + +extern void abort (void); + +char32_t *s0 = U"ab"; +char32_t *s1 = U"a\u0024"; +char32_t *s2 = U"a\u2029"; +char32_t *s3 = U"a\U00064321"; + +#define A 0x00000061 +#define B 0x00000062 +#define D 0x00000024 +#define X 0x00002029 +#define Y 0x00064321 + +int main () +{ + if (s0[0] != A || s0[1] != B || s0[2] != 0x00000000) + abort (); + if (s1[0] != A || s1[1] != D || s0[2] != 0x00000000) + abort (); + if (s2[0] != A || s2[1] != X || s0[2] != 0x00000000) + abort (); + if (s3[0] != A || s3[1] != Y || s3[2] != 0x00000000) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf32-3.c b/SingleSource/Regression/C/gcc-dg/utf32-3.c new file mode 100644 index 0000000000..de7b2aa353 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf32-3.c @@ -0,0 +1,48 @@ +/* Contributed by Kris Van Hees */ +/* Test concatenation of char32_t* string literals. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef __CHAR32_TYPE__ char32_t; + +extern void abort (void); + +char32_t *s0 = U"a" U"b"; + +char32_t *s1 = U"a" "b"; +char32_t *s2 = "a" U"b"; +char32_t *s3 = U"a" "\u2029"; +char32_t *s4 = "\u2029" U"b"; +char32_t *s5 = U"a" "\U00064321"; +char32_t *s6 = "\U00064321" U"b"; + +#define A 0x00000061 +#define B 0x00000062 +#define X 0x00002029 +#define Y 0x00064321 + +int main () +{ + if (sizeof ((U"a" U"b")[0]) != sizeof (char32_t)) + abort (); + if (sizeof ((U"a" "b")[0]) != sizeof (char32_t)) + abort (); + if (sizeof (( "a" U"b")[0]) != sizeof (char32_t)) + abort (); + + if (s0[0] != A || s0[1] != B || s0[2] != 0x00000000) + abort (); + + if (s1[0] != A || s1[1] != B || s1[2] != 0x00000000) + abort (); + if (s2[0] != A || s2[1] != B || s2[2] != 0x00000000) + abort (); + if (s3[0] != A || s3[1] != X || s3[2] != 0x00000000) + abort (); + if (s4[0] != X || s4[1] != B || s4[2] != 0x00000000) + abort (); + if (s5[0] != A || s5[1] != Y || s5[2] != 0x00000000) + abort (); + if (s6[0] != Y || s6[1] != B || s6[2] != 0x00000000) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/utf32-4.c b/SingleSource/Regression/C/gcc-dg/utf32-4.c new file mode 100644 index 0000000000..aa7f66a368 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf32-4.c @@ -0,0 +1,20 @@ +/* Contributed by Kris Van Hees */ +/* Expected errors for char32_t character constants. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +typedef __CHAR32_TYPE__ char32_t; + +char32_t c0 = U''; /* { dg-error "empty character" } */ +char32_t c1 = U'ab'; /* { dg-warning "constant too long" } */ +char32_t c2 = U'\U00064321'; + +char32_t c3 = 'a'; +char32_t c4 = u'a'; +char32_t c5 = u'\u2029'; +char32_t c6 = u'\U00064321'; /* { dg-warning "constant too long" } */ +char32_t c7 = L'a'; +char32_t c8 = L'\u2029'; +char32_t c9 = L'\U00064321'; /* { dg-warning "constant too long" "" { target { ! 4byte_wchar_t } } } */ + +int main () {} diff --git a/SingleSource/Regression/C/gcc-dg/utf8-1.c b/SingleSource/Regression/C/gcc-dg/utf8-1.c new file mode 100644 index 0000000000..e287e06568 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf8-1.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ +/* { dg-require-iconv "ISO-8859-2" } */ +/* { dg-options "-std=gnu99 -fexec-charset=ISO-8859-2" } */ + +const char *str1 = "h\u00e1\U0000010Dky "; +const char *str2 = "\u010d\u00E1rky\n"; +const char *str3 = u8"h\u00e1\U0000010Dky "; +const char *str4 = u8"\u010d\u00E1rky\n"; +const char *str5 = "h\u00e1\U0000010Dky " "\u010d\u00E1rky\n"; +const char *str6 = u8"h\u00e1\U0000010Dky " "\u010d\u00E1rky\n"; +const char *str7 = "h\u00e1\U0000010Dky " u8"\u010d\u00E1rky\n"; +#define u8 +const char *str8 = u8"h\u00e1\U0000010Dky " u8"\u010d\u00E1rky\n"; + +const char latin2_1[] = "\x68\xe1\xe8\x6b\x79\x20"; +const char latin2_2[] = "\xe8\xe1\x72\x6b\x79\n"; +const char utf8_1[] = "\x68\xc3\xa1\xc4\x8d\x6b\x79\x20"; +const char utf8_2[] = "\xc4\x8d\xc3\xa1\x72\x6b\x79\n"; + +int +main (void) +{ + if (__builtin_strcmp (str1, latin2_1) != 0 + || __builtin_strcmp (str2, latin2_2) != 0 + || __builtin_strcmp (str3, utf8_1) != 0 + || __builtin_strcmp (str4, utf8_2) != 0 + || __builtin_strncmp (str5, latin2_1, sizeof (latin2_1) - 1) != 0 + || __builtin_strcmp (str5 + sizeof (latin2_1) - 1, latin2_2) != 0 + || __builtin_strncmp (str6, utf8_1, sizeof (utf8_1) - 1) != 0 + || __builtin_strcmp (str6 + sizeof (utf8_1) - 1, utf8_2) != 0 + || __builtin_strncmp (str7, utf8_1, sizeof (utf8_1) - 1) != 0 + || __builtin_strcmp (str7 + sizeof (utf8_1) - 1, utf8_2) != 0 + || __builtin_strncmp (str8, utf8_1, sizeof (utf8_1) - 1) != 0 + || __builtin_strcmp (str8 + sizeof (utf8_1) - 1, utf8_2) != 0) + __builtin_abort (); + if (sizeof ("a" u8"b"[0]) != 1 + || sizeof (u8"a" "b"[0]) != 1 + || sizeof (u8"a" u8"b"[0]) != 1 + || sizeof ("a" "\u010d") != 3 + || sizeof ("a" u8"\u010d") != 4 + || sizeof (u8"a" "\u010d") != 4 + || sizeof (u8"a" "\u010d") != 4) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/utf8-2.c b/SingleSource/Regression/C/gcc-dg/utf8-2.c new file mode 100644 index 0000000000..b3b873dfd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/utf8-2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target wchar } */ +/* { dg-options "-std=gnu99" } */ + +#include + +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; + +const char s0[] = u8"ab"; +const char16_t s1[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ +const char32_t s2[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ +const wchar_t s3[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ + +const char t0[0] = u8"ab"; /* { dg-warning " is too long" } */ +const char t1[1] = u8"ab"; /* { dg-warning " is too long" } */ +const char t2[2] = u8"ab"; +const char t3[3] = u8"ab"; +const char t4[4] = u8"ab"; + +const char u0[0] = u8"\u2160."; /* { dg-warning " is too long" } */ +const char u1[1] = u8"\u2160."; /* { dg-warning " is too long" } */ +const char u2[2] = u8"\u2160."; /* { dg-warning " is too long" } */ +const char u3[3] = u8"\u2160."; /* { dg-warning " is too long" } */ +const char u4[4] = u8"\u2160."; +const char u5[5] = u8"\u2160."; +const char u6[6] = u8"\u2160."; diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-1.c b/SingleSource/Regression/C/gcc-dg/va-arg-1.c new file mode 100644 index 0000000000..ecd0e4d84b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +#include + +va_list v; +volatile int i; + +void foo() +{ + i = va_arg(v, char); /* { dg-warning "is promoted to|so you should|abort" "char" } */ + i = va_arg(v, short); /* { dg-warning "is promoted to|abort" "short" } */ + i = va_arg(v, float); /* { dg-warning "is promoted to|abort" "float" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-2.c b/SingleSource/Regression/C/gcc-dg/va-arg-2.c new file mode 100644 index 0000000000..e1c915ffc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-2.c @@ -0,0 +1,12 @@ +/* is not supported anymore, but we do install a stub + file which issues an #error telling the user to convert their code. */ + +/* { dg-do compile } */ + +#include /* { dg-bogus "varargs.h" "missing file" } */ + +/* { dg-message "file included from" "file included from" { target *-*-* } 0 } */ +/* { dg-error "no longer implements" "#error 1" { target *-*-* } 4 } */ +/* { dg-error "Revise your code" "#error 2" { target *-*-* } 5 } */ + +int x; /* prevent empty-translation-unit warning */ diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-3.c b/SingleSource/Regression/C/gcc-dg/va-arg-3.c new file mode 100644 index 0000000000..ef2344b4f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* PR 14498. */ +#include +extern void baz(char *); +void bar (va_list *args) +{ + if (args) + { + char *s = va_arg(*args, char *); + baz(s); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-4.c b/SingleSource/Regression/C/gcc-dg/va-arg-4.c new file mode 100644 index 0000000000..6d737c4832 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-4.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +#include +extern void baz(...); /* { dg-error "requires a named argument" } */ diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-5.c b/SingleSource/Regression/C/gcc-dg/va-arg-5.c new file mode 100644 index 0000000000..a00616ee20 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-5.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-fallow-parameterless-variadic-functions" } */ +#include +extern void baz(...); diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-pack-1.c b/SingleSource/Regression/C/gcc-dg/va-arg-pack-1.c new file mode 100644 index 0000000000..888f3d7800 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-pack-1.c @@ -0,0 +1,52 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgnu89-inline" } */ + +int bar (int, const char *, int, ...); +int baz (int, const char *, long int); + +int +f1 (int x, ...) +{ + return bar (5, "", 6, __builtin_va_arg_pack ()); /* { dg-error "invalid use of" } */ +} + +extern inline __attribute__((always_inline)) int +f2 (int y, ...) +{ + return bar (y, "", __builtin_va_arg_pack ()); /* { dg-error "invalid use of" } */ +} + +extern inline __attribute__((always_inline)) int +f3 (int y, ...) +{ + return bar (y, "", 5, __builtin_va_arg_pack ()); +} + +extern inline __attribute__((always_inline)) int +f4 (int y, ...) +{ + return bar (y, "", 4, __builtin_va_arg_pack (), 6); /* { dg-error "invalid use of" } */ +} + +extern inline __attribute__((always_inline)) int +f5 (int y, ...) +{ + return baz (y, "", __builtin_va_arg_pack ()); /* { dg-error "invalid use of" } */ +} + +extern inline __attribute__((always_inline)) int +f6 (int y, ...) +{ + return __builtin_va_arg_pack (); /* { dg-error "invalid use of" } */ +} + +int +test (void) +{ + int a = f2 (5, "a", 6); + a += f3 (6, "ab", 17LL); + a += f4 (7, 1, 2, 3); + a += f5 (8, 7L); + a += f6 (9); + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-pack-2.c b/SingleSource/Regression/C/gcc-dg/va-arg-pack-2.c new file mode 100644 index 0000000000..417248a2a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-pack-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern void noreturn (int status, ...); + +extern inline __attribute ((always_inline)) void +error (int status, ...) +{ + if (__builtin_constant_p (status)) + noreturn (status, __builtin_va_arg_pack ()); +} + +void +f (void) +{ + error (1); +} diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-pack-len-1.c b/SingleSource/Regression/C/gcc-dg/va-arg-pack-len-1.c new file mode 100644 index 0000000000..409c345850 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-pack-len-1.c @@ -0,0 +1,122 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include + +extern int error_open_missing_mode (void) + __attribute__((__error__ ("open with O_CREAT needs 3 arguments, only 2 were given"))); +extern int warn_open_too_many_arguments (void) + __attribute__((__warning__ ("open called with more than 3 arguments"))); +extern void abort (void); + +char expected_char; + +__attribute__((noinline)) int +myopen2 (const char *path, int oflag) +{ + if (expected_char++ != path[0] || path[1] != '\0') + abort (); + switch (path[0]) + { + case 'f': + if (oflag != 0x2) + abort (); + break; + case 'g': + if (oflag != 0x43) + abort (); + /* In real __open_2 this would terminate the program: + open with O_CREAT without third argument. */ + return -6; + default: + abort (); + } + return 0; +} + +__attribute__((noinline)) int +myopenva (const char *path, int oflag, ...) +{ + int mode = 0; + va_list ap; + if ((oflag & 0x40) != 0) + { + va_start (ap, oflag); + mode = va_arg (ap, int); + va_end (ap); + } + if (expected_char++ != path[0] || path[1] != '\0') + abort (); + switch (path[0]) + { + case 'a': + if (oflag != 0x43 || mode != 0644) + abort (); + break; + case 'b': + if (oflag != 0x3) + abort (); + break; + case 'c': + if (oflag != 0x2) + abort (); + break; + case 'd': + if (oflag != 0x43 || mode != 0600) + abort (); + break; + case 'e': + if (oflag != 0x3) + abort (); + break; + default: + abort (); + } + return 0; +} + +extern inline __attribute__((always_inline, gnu_inline)) int +myopen (const char *path, int oflag, ...) +{ + if (__builtin_va_arg_pack_len () > 1) + warn_open_too_many_arguments (); + + if (__builtin_constant_p (oflag)) + { + if ((oflag & 0x40) != 0 && __builtin_va_arg_pack_len () < 1) + { + error_open_missing_mode (); + return myopen2 (path, oflag); + } + return myopenva (path, oflag, __builtin_va_arg_pack ()); + } + + if (__builtin_va_arg_pack_len () < 1) + return myopen2 (path, oflag); + + return myopenva (path, oflag, __builtin_va_arg_pack ()); +} + +volatile int l0; + +int +main (void) +{ + expected_char = 'a'; + if (myopen ("a", 0x43, 0644)) + abort (); + if (myopen ("b", 0x3, 0755)) + abort (); + if (myopen ("c", 0x2)) + abort (); + if (myopen ("d", l0 + 0x43, 0600)) + abort (); + if (myopen ("e", l0 + 0x3, 0700)) + abort (); + if (myopen ("f", l0 + 0x2)) + abort (); + /* Invalid use of myopen, but only detectable at runtime. */ + if (myopen ("g", l0 + 0x43) != -6) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/va-arg-pack-len-2.c b/SingleSource/Regression/C/gcc-dg/va-arg-pack-len-2.c new file mode 100644 index 0000000000..c3fa856fda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/va-arg-pack-len-2.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +extern int error_open_missing_mode (void) + __attribute__((__error__ ("open with O_CREAT needs 3 arguments, only 2 were given"))); +extern int warn_open_too_many_arguments (void) + __attribute__((__warning__ ("open called with more than 3 arguments"))); + +extern int myopen2 (const char *path, int oflag); +extern int myopenva (const char *path, int oflag, ...); + +extern inline __attribute__((always_inline, gnu_inline)) int +myopen (const char *path, int oflag, ...) +{ + if (__builtin_va_arg_pack_len () > 1) + warn_open_too_many_arguments (); /* { dg-warning "called with more than 3" } */ + + if (__builtin_constant_p (oflag)) + { + if ((oflag & 0x40) != 0 && __builtin_va_arg_pack_len () < 1) + { + error_open_missing_mode (); /* { dg-error "needs 3 arguments, only 2 were given" } */ + return myopen2 (path, oflag); + } + return myopenva (path, oflag, __builtin_va_arg_pack ()); + } + + if (__builtin_va_arg_pack_len () < 1) + return myopen2 (path, oflag); + + return myopenva (path, oflag, __builtin_va_arg_pack ()); +} + +int +main (void) +{ + myopen ("h", 0x43); + myopen ("i", 0x43, 0644, 0655); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/var-expand1.c b/SingleSource/Regression/C/gcc-dg/var-expand1.c new file mode 100644 index 0000000000..3d536cef2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/var-expand1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* We don't (and don't want to) perform this optimisation on soft-float + targets, where each addition is a library call. */ +/* { dg-require-effective-target hard_float } */ +/* { dg-options "-O2 -funroll-loops --fast-math -fvariable-expansion-in-unroller -fdump-rtl-loop2_unroll" } */ +/* { dg-additional-options "--param max-completely-peel-times=16 --param max-unroll-times=8" { target s390*-*-* } } */ + +extern void abort (void); + +float array[30] = { 1,2,3,4,5,6,7,8,9,10 }; + +int foo (int n) +{ + unsigned i; + float accum = 1.0; + + for (i = 0; i < n; i++) + accum += array[i]; + + return accum; +} + +int main (void) +{ + return foo (10); +} + +/* { dg-final { scan-rtl-dump "Expanding Accumulator" "loop2_unroll" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/var-expand2.c b/SingleSource/Regression/C/gcc-dg/var-expand2.c new file mode 100644 index 0000000000..499de55cb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/var-expand2.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-loops -ffast-math -fvariable-expansion-in-unroller" } */ + +extern void abort (void); + +float array[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + +int +foo (int n) +{ + unsigned i; + float accum = 0; + + for (i = 0; i < n; i++) + accum += array[i]; + + if (accum != 55) + abort (); + + return 0; +} + +int +main (void) +{ + return foo (10); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/var-expand3.c b/SingleSource/Regression/C/gcc-dg/var-expand3.c new file mode 100644 index 0000000000..b81cef0453 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/var-expand3.c @@ -0,0 +1,57 @@ +/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ +/* { dg-options "-O2 -funroll-loops -ffast-math -fvariable-expansion-in-unroller -maltivec -fdump-rtl-loop2_unroll" } */ + +#include "altivec.h" +extern void abort (void); +extern void exit (int); + +#define N 256 + +float in1[N] __attribute__ ((__aligned__ (16))) = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57}; +float in2[N] __attribute__ ((__aligned__ (16))) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; + +float +foo (int n) +{ + unsigned i; + vector float vp1, vp2, vp3, vaccum, vzero, vtmp; + float accum = 1.0; + + vzero = (vector float){0, 0, 0, 0}; + + vaccum = vzero; + + for (i = 0; i < n; i++) + { + vp1 = vec_ld (i * 16, in1); + vp2 = vec_ld (i * 16, in2); + + vaccum = vec_madd (vp1, vp2, vaccum); + + } + vtmp = vec_sld (vaccum, vaccum, 8); + vp1 = vec_add (vaccum, vtmp); + vtmp = vec_sld (vp1, vp1, 4); + vp2 = vec_add (vp1, vtmp); + + vec_ste (vp2, 0, &accum); + if (accum != 1518) + return 0; + + return accum; +} + +int +main (void) +{ + if (!foo (3)) + abort (); + + exit (0); +} + +/* { dg-final { scan-rtl-dump "Expanding Accumulator" "loop2_unroll" } } */ + + + + diff --git a/SingleSource/Regression/C/gcc-dg/variable-sized-type-flex-array.c b/SingleSource/Regression/C/gcc-dg/variable-sized-type-flex-array.c new file mode 100644 index 0000000000..3924937bad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/variable-sized-type-flex-array.c @@ -0,0 +1,31 @@ +/* Test for -Wflex-array-member-not-at-end on structure/union with + C99 flexible array members being embedded into another structure. */ +/* { dg-do compile } */ +/* { dg-options "-Wflex-array-member-not-at-end" } */ + +struct flex { int n; int data[]; }; +struct out_flex_end { int m; struct flex flex_data; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +struct out_flex_mid { struct flex flex_data; int m; }; /* { dg-warning "structure containing a flexible array member is not at the end of another structure" } */ +/* since the warning has been issued for out_flex_mid, no need to + issue warning again when it is included in another structure/union. */ +struct outer_flex_mid { struct out_flex_mid out_flex_data; int p; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +union flex_union_mid { int a; struct outer_flex_mid b; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ + + +struct flex0 { int n; int data[0]; }; +struct out_flex_end0 { int m; struct flex0 flex_data; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +struct out_flex_mid0 { struct flex0 flex_data; int m; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +struct outer_flex_mid0 { struct out_flex_mid0 out_flex_data; int p; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +union flex_union_mid0 { int a; struct outer_flex_mid0 b; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ + +struct flex1 { int n; int data[1]; }; +struct out_flex_end1 { int m; struct flex1 flex_data; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +struct out_flex_mid1 { struct flex1 flex_data; int m; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +struct outer_flex_mid1 { struct out_flex_mid1 out_flex_data; int p; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +union flex_union_mid1 { int a; struct outer_flex_mid1 b; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ + +struct flexn { int n; int data[8]; }; +struct out_flex_endn { int m; struct flexn flex_data; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ +struct out_flex_midn { struct flexn flex_data; int m; }; /* { dg-bogus"structure containing a flexible array member is not at the end of another structure" } */ +struct outer_flex_midn { struct out_flex_midn out_flex_data; int p; }; /* { dg-bogus"structure containing a flexible array member is not at the end of another structure" } */ +union flex_union_midn { int a; struct outer_flex_midn b; }; /* { dg-bogus "structure containing a flexible array member is not at the end of another structure" } */ diff --git a/SingleSource/Regression/C/gcc-dg/varpool-1.c b/SingleSource/Regression/C/gcc-dg/varpool-1.c new file mode 100644 index 0000000000..cb7aebdb9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/varpool-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "unnecesary_static_initialized_variable" } } */ + +static int unnecesary_static_initialized_variable; +static int *unnecesary_static_initialized_variable2 = + &unnecesary_static_initialized_variable; +static inline int +simplify_after_inline (int param1, int *param2) +{ + if (unnecesary_static_initialized_variable != param1) + return unnecesary_static_initialized_variable; + if (unnecesary_static_initialized_variable2 != param2) + return unnecesary_static_initialized_variable; +} + +int +main () +{ + return simplify_after_inline (unnecesary_static_initialized_variable, + unnecesary_static_initialized_variable2) + + simplify_after_inline (unnecesary_static_initialized_variable, + unnecesary_static_initialized_variable2); +} diff --git a/SingleSource/Regression/C/gcc-dg/vec-andxor1.c b/SingleSource/Regression/C/gcc-dg/vec-andxor1.c new file mode 100644 index 0000000000..4aa454e663 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vec-andxor1.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +typedef int vec __attribute__((vector_size(4*sizeof(int)))); + +__attribute__((noinline,noclone)) +void f (vec *x) { + *x = (*x & 1) ^ 1; +} + +int main() { + vec x = { 1, 2, 3, 4 }; + f(&x); + if (x[0] != 0 || x[1] != 1) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/CMakeLists.txt b/SingleSource/Regression/C/gcc-dg/vect/CMakeLists.txt new file mode 100644 index 0000000000..7d674a50ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/CMakeLists.txt @@ -0,0 +1,139 @@ +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../DgOptions.txt) +include(${CMAKE_CURRENT_SOURCE_DIR}/DgVectTestList.txt) + +set(TestsToSkip) + +## +## Main Test Blacklist for Clang +## + +# Tests with features unsupported by Clang (usually GCC extensions) +# (Big list of naughty tests) +set(UnsupportedTests + # Unsupported flags + pr48765.c + pr63530.c + + # `#pragma GCC unroll 0` is invalid in Clang + pr97832-4.c + pr97832-2.c + pr97832-3.c + vect-93.c + pr79920.c + vect-double-reduc-6.c + fast-math-vect-pr29925.c + no-vfa-vect-101.c + no-vfa-vect-102.c + vect-105.c + + # requires -mpowerpc64 + vect-82_64.c + vect-83_64.c + + # unknown argument: '-finline-stringops' + pr113002.c + + # Requires cosf + tsvc/vect-tsvc-s451.c + + # Variable array in sturcture + pr111882.c + + # "ssa" attributes are invalid in Clang + slp-reduc-10a.c + slp-reduc-10b.c + slp-reduc-10c.c + slp-reduc-10d.c + slp-reduc-10e.c + bb-slp-48.c + vect-cond-arith-2.c + vect-ifcvt-19.c + + # Unknown flag '-fno-delete-dead-exceptions' + pr103253.c + + # We don't have `long long` vect + pr101145_3.c + + # Needs libm + fast-math-bb-slp-call-1.c + fast-math-bb-slp-call-2.c + fast-math-bb-slp-call-3.c + fast-math-vect-call-1.c + fast-math-vect-call-2.c + + # error: address of vector element requested + bb-slp-pr54400.c + + # The rest + fast-math-vect-pr29925.c + # no-vfa-vect-101.c + no-vfa-vect-102.c + pr51581-1.c + pr51581-2.c + pr59651.c + pr63530.c + pr79920.c + vect-105.c + vect-93.c + vect-cond-arith-3.c + vect-cond-arith-7.c + vect-double-reduc-6.c + vect-fma-1.c + vect-reduc-mul_1.c + vect-reduc-mul_2.c + vect-reduc-or_1.c + vect-reduc-or_2.c + vect-simd-16.c + vect-simd-clone-16.c + vect-simd-clone-16b.c + vect-simd-clone-16c.c + vect-simd-clone-16d.c + vect-simd-clone-16e.c + vect-simd-clone-16f.c + vect-simd-clone-17.c + vect-simd-clone-17b.c + vect-simd-clone-17c.c + vect-simd-clone-17d.c + vect-simd-clone-17e.c + vect-simd-clone-17f.c + vect-simd-clone-18.c + vect-simd-clone-18b.c + vect-simd-clone-18c.c + vect-simd-clone-18d.c + vect-simd-clone-18e.c + vect-simd-clone-18f.c + vect-simd-clone-20.c +) +list(APPEND TestsToSkip ${UnsupportedTests}) + +set(TestFiles ${VECT_EXP_TESTS}) + +foreach(TestToSkip ${TestsToSkip}) + list(REMOVE_ITEM TestFiles ${TestToSkip}) +endforeach() + +foreach(File ${TestFiles}) + set(MaybeCFlags) + set(MaybeLDFlags) + + # Add Test-specific CFLAGS/LDFLAGS here + + if(${File} IN_LIST TestRequiresLibM) + list(APPEND MaybeLDFlags "-lm") + endif() + + if(${File} IN_LIST TestRequiresWNoReturnType) + list(APPEND MaybeCFlags "-Wno-return-type") + endif() + + if(${File} IN_LIST TestRequiresFWrapV) + list(APPEND MaybeCFlags "-fwrapv") + endif() + + gcc_torture_execute_test(${File} + DG_DO_DEFAULT "run" + PREFIX "GCC-DG-VECT" + CFLAGS ${MaybeCFlags} + LDFLAGS ${MaybeLDFlags}) +endforeach() diff --git a/SingleSource/Regression/C/gcc-dg/vect/DgVectTestList.txt b/SingleSource/Regression/C/gcc-dg/vect/DgVectTestList.txt new file mode 100644 index 0000000000..0a27602dc2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/DgVectTestList.txt @@ -0,0 +1,1821 @@ +set(VECT_EXP_TESTS + aligned-section-anchors-nest-1.c + aligned-section-anchors-vect-70.c + aligned-section-anchors-vect-71.c + aligned-section-anchors-vect-72.c + bb-slp-10.c + bb-slp-11.c + bb-slp-13.c + bb-slp-14.c + bb-slp-15.c + bb-slp-16.c + bb-slp-17.c + bb-slp-18.c + bb-slp-19.c + bb-slp-1.c + bb-slp-20.c + bb-slp-21.c + bb-slp-22.c + bb-slp-23.c + bb-slp-24.c + bb-slp-25.c + bb-slp-26.c + bb-slp-27.c + bb-slp-28.c + bb-slp-29.c + bb-slp-2.c + bb-slp-30.c + bb-slp-31.c + bb-slp-32.c + bb-slp-33.c + bb-slp-34.c + bb-slp-35.c + bb-slp-36.c + bb-slp-37.c + bb-slp-38.c + bb-slp-39.c + bb-slp-3.c + bb-slp-40.c + bb-slp-41.c + bb-slp-42.c + bb-slp-43.c + bb-slp-44.c + bb-slp-45.c + bb-slp-46.c + bb-slp-47.c + bb-slp-48.c + bb-slp-49.c + bb-slp-4.c + bb-slp-50.c + bb-slp-51.c + bb-slp-52.c + bb-slp-53.c + bb-slp-54.c + bb-slp-55.c + bb-slp-56.c + bb-slp-57.c + bb-slp-58.c + bb-slp-59.c + bb-slp-5.c + bb-slp-60.c + bb-slp-61.c + bb-slp-62.c + bb-slp-63.c + bb-slp-64.c + bb-slp-65.c + bb-slp-66.c + bb-slp-67.c + bb-slp-68.c + bb-slp-69.c + bb-slp-6.c + bb-slp-70.c + bb-slp-71.c + bb-slp-72.c + bb-slp-73.c + bb-slp-74.c + bb-slp-75.c + bb-slp-7.c + bb-slp-8a.c + bb-slp-8b.c + bb-slp-8.c + bb-slp-9.c + bb-slp-bool-1.c + bb-slp-cond-1.c + bb-slp-div-1.c + bb-slp-div-2.c + bb-slp-layout-10.c + bb-slp-layout-11.c + bb-slp-layout-12.c + bb-slp-layout-13.c + bb-slp-layout-14.c + bb-slp-layout-15.c + bb-slp-layout-16.c + bb-slp-layout-17.c + bb-slp-layout-18.c + bb-slp-layout-19.c + bb-slp-layout-1.c + bb-slp-layout-20.c + bb-slp-layout-21.c + bb-slp-layout-2.c + bb-slp-layout-3.c + bb-slp-layout-4.c + bb-slp-layout-5.c + bb-slp-layout-6.c + bb-slp-layout-7.c + bb-slp-layout-8.c + bb-slp-layout-9.c + bb-slp-over-widen-1.c + bb-slp-over-widen-2.c + bb-slp-pattern-1.c + bb-slp-pattern-2.c + bb-slp-phis-1.c + bb-slp-pow-1.c + bb-slp-pr100778-1.c + bb-slp-pr101207.c + bb-slp-pr101242.c + bb-slp-pr101615-1.c + bb-slp-pr101615-2.c + bb-slp-pr101668.c + bb-slp-pr101756.c + bb-slp-pr103800.c + bb-slp-pr104240.c + bb-slp-pr106019.c + bb-slp-pr54400.c + bb-slp-pr58135.c + bb-slp-pr65935.c + bb-slp-pr69907.c + bb-slp-pr78205.c + bb-slp-pr80705.c + bb-slp-pr81635-1.c + bb-slp-pr81635-2.c + bb-slp-pr81635-3.c + bb-slp-pr81635-4.c + bb-slp-pr90006.c + bb-slp-pr92596.c + bb-slp-pr95271.c + bb-slp-pr95335.c + bb-slp-pr95839-2.c + bb-slp-pr95839-3.c + bb-slp-pr95839.c + bb-slp-pr95839-v8.c + bb-slp-pr95866.c + bb-slp-pr97486.c + bb-slp-pr97496.c + bb-slp-pr97615.c + bb-slp-pr97626.c + bb-slp-pr97633.c + bb-slp-pr97650.c + bb-slp-pr97706.c + bb-slp-pr97709.c + bb-slp-pr97732.c + bb-slp-pr97746.c + bb-slp-pr98137.c + bb-slp-pr98516-1.c + bb-slp-pr98516-2.c + bb-slp-pr98544.c + bb-slp-pr98685.c + bb-slp-pr98854.c + bb-slp-subgroups-1.c + bb-slp-subgroups-2.c + bb-slp-subgroups-3.c + fast-math-bb-slp-call-1.c + fast-math-bb-slp-call-2.c + fast-math-bb-slp-call-3.c + fast-math-ifcvt-1.c + fast-math-pr35982.c + fast-math-pr43074.c + fast-math-pr44152.c + fast-math-pr55281.c + fast-math-slp-27.c + fast-math-slp-38.c + fast-math-vect-call-1.c + fast-math-vect-call-2.c + fast-math-vect-complex-3.c + fast-math-vect-outer-7.c + fast-math-vect-pow-1.c + fast-math-vect-pow-2.c + fast-math-vect-pr25911.c + fast-math-vect-pr29925.c + fast-math-vect-reduc-5.c + fast-math-vect-reduc-7.c + fast-math-vect-reduc-8.c + fast-math-vect-reduc-9.c + ggc-pr37574.c + nodump-forwprop-22.c + nodump-pr23073.c + nodump-vect-opt-info-1.c + nodump-vect-opt-info-2.c + no-fast-math-vect16.c + no-fre-pre-pr50208.c + no-math-errno-slp-32.c + no-math-errno-vect-pow-1.c + no-scevccp-noreassoc-outer-1.c + no-scevccp-noreassoc-outer-2.c + no-scevccp-noreassoc-outer-3.c + no-scevccp-noreassoc-outer-4.c + no-scevccp-noreassoc-outer-5.c + no-scevccp-noreassoc-slp-reduc-7.c + no-scevccp-outer-10a.c + no-scevccp-outer-10b.c + no-scevccp-outer-10.c + no-scevccp-outer-11.c + no-scevccp-outer-12.c + no-scevccp-outer-13.c + no-scevccp-outer-14.c + no-scevccp-outer-15.c + no-scevccp-outer-16.c + no-scevccp-outer-17.c + no-scevccp-outer-18.c + no-scevccp-outer-19.c + no-scevccp-outer-1.c + no-scevccp-outer-20.c + no-scevccp-outer-21.c + no-scevccp-outer-22.c + no-scevccp-outer-2.c + no-scevccp-outer-3.c + no-scevccp-outer-4.c + no-scevccp-outer-5.c + no-scevccp-outer-6.c + no-scevccp-outer-6-global.c + no-scevccp-outer-7.c + no-scevccp-outer-8.c + no-scevccp-outer-9a.c + no-scevccp-outer-9b.c + no-scevccp-outer-9.c + no-scevccp-pr49199.c + no-scevccp-pr86725-1.c + no-scevccp-pr86725-2.c + no-scevccp-pr86725-3.c + no-scevccp-pr86725-4.c + no-scevccp-pr86725-5.c + no-scevccp-slp-30.c + no-scevccp-slp-31.c + no-scevccp-vect-iv-1.c + no-scevccp-vect-iv-2.c + no-scevccp-vect-iv-3.c + no-section-anchors-vect-31.c + no-section-anchors-vect-34.c + no-section-anchors-vect-36.c + no-section-anchors-vect-64.c + no-section-anchors-vect-65.c + no-section-anchors-vect-66.c + no-section-anchors-vect-68.c + no-section-anchors-vect-69.c + no-section-anchors-vect-outer-4h.c + no-trapping-math-1.c + no-trapping-math-2.c + no-trapping-math-vect-111.c + no-trapping-math-vect-ifcvt-11.c + no-trapping-math-vect-ifcvt-12.c + no-trapping-math-vect-ifcvt-13.c + no-trapping-math-vect-ifcvt-14.c + no-trapping-math-vect-ifcvt-15.c + no-tree-dom-vect-bug.c + no-tree-fre-pr50039.c + no-tree-pre-pr45241.c + no-tree-pre-slp-29.c + no-tree-reassoc-bb-slp-12.c + no-tree-sra-bb-slp-pr50730.c + no-vfa-pr29145.c + no-vfa-vect-101.c + no-vfa-vect-102a.c + no-vfa-vect-102.c + no-vfa-vect-37.c + no-vfa-vect-43.c + no-vfa-vect-45.c + no-vfa-vect-49.c + no-vfa-vect-51.c + no-vfa-vect-53.c + no-vfa-vect-57.c + no-vfa-vect-61.c + no-vfa-vect-79.c + no-vfa-vect-depend-1.c + no-vfa-vect-depend-2.c + no-vfa-vect-depend-3.c + no-vfa-vect-dv-2.c + O1-pr33854.c + O1-pr41008.c + O3-pr36098.c + O3-pr39675-2.c + O3-pr41881.c + O3-pr45971.c + O3-pr46077.c + O3-pr49087.c + O3-pr70130.c + O3-pr85794.c + O3-pr87546.c + O3-slp-reduc-10.c + O3-vect-pr32243.c + O3-vect-pr34223.c + O3-vect-pr61917.c + O-pr46167.c + Os-vect-95.c + pr100756.c + pr101145_1.c + pr101145_2.c + pr101145_3.c + pr101145.c + pr101145inf_1.c + pr101145inf.c + pr101445.c + pr101505.c + pr102046.c + pr102318.c + pr102832.c + pr103116-1.c + pr103116-2.c + pr103253.c + pr103494.c + pr103517.c + pr103544.c + pr103581.c + pr103744-1.c + pr103744-2.c + pr103761.c + pr103864.c + pr104112-1.c + pr104112-2.c + pr104152.c + pr104445.c + pr104595.c + pr104782.c + pr105219.c + pr106081.c + pr106250.c + pr106914.c + pr107160.c + pr107212-1.c + pr107212-2.c + pr107229-1.c + pr107229-2.c + pr107229-3.c + pr107275.c + pr107302.c + pr107326.c + pr108314.c + pr108316.c + pr108608.c + pr108950.c + pr109011-1.c + pr109011-2.c + pr109011-3.c + pr109011-4.c + pr109011-5.c + pr109025.c + pr109473.c + pr109502.c + pr110142.c + pr110381.c + pr110838.c + pr111754.c + pr111764.c + pr111846.c + pr111860-2.c + pr111860-3.c + pr111860.c + pr111882.c + pr111915.c + pr112818.c + pr113002.c + pr16105.c + pr18308.c + pr18400.c + pr18425.c + pr18536.c + pr20122.c + pr21591.c + pr21969.c + pr22480.c + pr22506.c + pr23816-1.c + pr23816-2.c + pr23831.c + pr24049.c + pr24059.c + pr24300.c + pr25371.c + pr25413a.c + pr25413.c + pr26359.c + pr27151.c + pr28952.c + pr30771.c + pr30784.c + pr30795.c + pr30843.c + pr30858.c + pr31041.c + pr31343.c + pr31699.c + pr32216.c + pr32224.c + pr32230.c + pr32366.c + pr32421.c + pr32824.c + pr33369.c + pr33373b.c + pr33373.c + pr33597.c + pr33707.c + pr33804.c + pr33833.c + pr33846.c + pr33866.c + pr33953.c + pr34005.c + pr34195.c + pr34407.c + pr34591.c + pr36228.c + pr36493.c + pr36630.c + pr37027.c + pr37385.c + pr37474.c + pr37482.c + pr37539.c + pr37730.c + pr38529.c + pr39529.c + pr40074.c + pr40238.c + pr40254.c + pr40542.c + pr41956.c + pr42193.c + pr42395.c + pr42604.c + pr42709.c + pr43430-1.c + pr43430-2.c + pr43432.c + pr43434.c + pr43842.c + pr44507.c + pr45633.c + pr45752.c + pr45847.c + pr45902.c + pr46009.c + pr46032.c + pr46049.c + pr46052.c + pr46126.c + pr46663.c + pr47001.c + pr47139.c + pr48052.c + pr48172.c + pr48377.c + pr48765.c + pr49038.c + pr49093.c + pr49318.c + pr49352.c + pr49478.c + pr49610.c + pr49771.c + pr49926.c + pr50014.c + pr50451.c + pr50635.c + pr50727.c + pr51000.c + pr51015.c + pr51074.c + pr51301.c + pr51581-1.c + pr51581-2.c + pr51581-3.c + pr51581-4.c + pr51590.c + pr51799.c + pr52091.c + pr52252-ld.c + pr52252-st.c + pr52298.c + pr52870.c + pr53185-2.c + pr53185.c + pr53773.c + pr55857-1.c + pr55857-2.c + pr56541.c + pr56625.c + pr56695.c + pr56787.c + pr56826.c + pr56918.c + pr56920.c + pr56933.c + pr57206.c + pr57558-1.c + pr57558-2.c + pr57705.c + pr57741-1.c + pr57741-2.c + pr57741-3.c + pr58508.c + pr59354.c + pr59519-1.c + pr59519-2.c + pr59591-1.c + pr59591-2.c + pr59594.c + pr59651.c + pr59984.c + pr60012.c + pr60092-2.c + pr60092.c + pr60196-1.c + pr60196-2.c + pr60276.c + pr60382.c + pr60482.c + pr60505.c + pr60656.c + pr60841.c + pr61194.c + pr61634.c + pr61680.c + pr62021.c + pr62073.c + pr62075.c + pr62171.c + pr63148.c + pr63189.c + pr63341-1.c + pr63341-2.c + pr63379.c + pr63530.c + pr63605.c + pr64252.c + pr64404.c + pr64421.c + pr64493.c + pr64495.c + pr64829.c + pr64844.c + pr65206.c + pr65310.c + pr65494.c + pr65518.c + pr65930-1.c + pr65930-2.c + pr65947-10.c + pr65947-11.c + pr65947-12.c + pr65947-13.c + pr65947-14.c + pr65947-1.c + pr65947-2.c + pr65947-3.c + pr65947-4.c + pr65947-5.c + pr65947-6.c + pr65947-7.c + pr65947-8.c + pr65947-9.c + pr65951.c + pr66142.c + pr66251.c + pr66253.c + pr66278.c + pr66623.c + pr66636.c + pr66677.c + pr66951.c + pr67790.c + pr68305.c + pr68339.c + pr68417.c + pr68445.c + pr68482.c + pr68502-1.c + pr68502-2.c + pr68577.c + pr69083.c + pr69652.c + pr69783.c + pr69820.c + pr70021.c + pr70138-1.c + pr70138-2.c + pr70354-1.c + pr70354-2.c + pr71259.c + pr71264.c + pr71407.c + pr71416-1.c + pr71416-2.c + pr71439.c + pr71667.c + pr71752.c + pr71818.c + pr71823.c + pr71854.c + pr72866.c + pr77503.c + pr77724.c + pr78005.c + pr78558.c + pr78938.c + pr79347.c + pr79824-1.c + pr79824-2.c + pr79887.c + pr79920.c + pr80631-1.c + pr80631-2.c + pr80815-1.c + pr80815-2.c + pr80815-3.c + pr80928.c + pr81082.c + pr81136.c + pr81196-2.c + pr81196.c + pr81410.c + pr81633.c + pr81740-1.c + pr81740-2.c + pr81815.c + pr82108.c + pr82289.c + pr82436.c + pr83202-1.c + pr83338.c + pr83857.c + pr83867.c + pr83914.c + pr83965-2.c + pr83965.c + pr84201.c + pr84265.c + pr84357.c + pr84419.c + pr84711.c + pr85286.c + pr85586.c + pr85597.c + pr85793.c + pr86749.c + pr86858.c + pr86871.c + pr86927.c + pr87288-1.c + pr87288-2.c + pr87288-3.c + pr88497-1.c + pr88497-2.c + pr88497-3.c + pr88497-4.c + pr88497-5.c + pr88497-6.c + pr88497-7.c + pr88598-1.c + pr88598-2.c + pr88598-3.c + pr88598-4.c + pr88598-5.c + pr88598-6.c + pr88903-1.c + pr88903-2.c + pr89268.c + pr89440.c + pr90018.c + pr91114.c + pr91293-1.c + pr91293-2.c + pr91293-3.c + pr91403.c + pr91665.c + pr91750.c + pr92205.c + pr92324-1.c + pr92324-2.c + pr92324-3.c + pr92324-4.c + pr92347.c + pr92420.c + pr92429.c + pr92554.c + pr92555.c + pr92558.c + pr92677.c + pr92710.c + pr92723.c + pr93069.c + pr93094.c + pr93247-1.c + pr93247-2.c + pr93767.c + pr93843-1.c + pr93843-2.c + pr94443.c + pr94606.c + pr94727.c + pr94994.c + pr95272.c + pr95495.c + pr95539.c + pr95570.c + pr95856.c + pr95897.c + pr95916.c + pr96698.c + pr96783-1.c + pr96783-2.c + pr96854.c + pr96920.c + pr97081-2.c + pr97081.c + pr97085.c + pr97139.c + pr97173.c + pr97236.c + pr97241.c + pr97428.c + pr97457.c + pr97558-2.c + pr97558.c + pr97678.c + pr97693.c + pr97730.c + pr97753.c + pr97760.c + pr97769.c + pr97832-1.c + pr97832-2.c + pr97832-3.c + pr97832-4.c + pr97835.c + pr97838.c + pr97929.c + pr98048.c + pr98069.c + pr98302.c + pr98308.c + pr98560-1.c + pr98560-2.c + pr98674.c + pr98848.c + pr99102.c + pr99253.c + pr99412.c + pr99540.c + pr99856.c + section-anchors-pr27770.c + section-anchors-vect-69.c + slp-10.c + slp-11a.c + slp-11b.c + slp-11c.c + slp-12a.c + slp-12b.c + slp-12c.c + slp-13-big-array.c + slp-13.c + slp-14.c + slp-15.c + slp-16.c + slp-17.c + slp-18.c + slp-19a.c + slp-19b.c + slp-19c.c + slp-1.c + slp-20.c + slp-21.c + slp-22.c + slp-23.c + slp-24-big-array.c + slp-24.c + slp-25.c + slp-26.c + slp-28.c + slp-2.c + slp-33.c + slp-34-big-array.c + slp-34.c + slp-35.c + slp-36.c + slp-37.c + slp-38.c + slp-39.c + slp-3-big-array.c + slp-3.c + slp-41.c + slp-42.c + slp-43.c + slp-44.c + slp-45.c + slp-46.c + slp-47.c + slp-48.c + slp-49.c + slp-4-big-array.c + slp-4.c + slp-50.c + slp-5.c + slp-6.c + slp-7.c + slp-8.c + slp-9.c + slp-cond-1.c + slp-cond-2-big-array.c + slp-cond-2.c + slp-cond-3.c + slp-cond-4.c + slp-cond-5.c + slp-mask-store-1.c + slp-multitypes-10.c + slp-multitypes-11-big-array.c + slp-multitypes-11.c + slp-multitypes-12.c + slp-multitypes-13.c + slp-multitypes-1.c + slp-multitypes-2.c + slp-multitypes-3.c + slp-multitypes-4.c + slp-multitypes-5.c + slp-multitypes-6.c + slp-multitypes-7.c + slp-multitypes-8.c + slp-multitypes-9.c + slp-perm-10.c + slp-perm-11.c + slp-perm-12.c + slp-perm-1.c + slp-perm-2.c + slp-perm-3.c + slp-perm-4.c + slp-perm-5.c + slp-perm-6.c + slp-perm-7.c + slp-perm-8.c + slp-perm-9.c + slp-reduc-10a.c + slp-reduc-10b.c + slp-reduc-10c.c + slp-reduc-10d.c + slp-reduc-10e.c + slp-reduc-11.c + slp-reduc-1.c + slp-reduc-2.c + slp-reduc-3.c + slp-reduc-4.c + slp-reduc-5.c + slp-reduc-6.c + slp-reduc-7.c + slp-reduc-8.c + slp-reduc-9.c + slp-reduc-sad-2.c + slp-reduc-sad.c + slp-simd-clone-1.c + slp-simd-clone-2.c + slp-widen-mult-half.c + slp-widen-mult-s16.c + slp-widen-mult-u8.c + trapv-vect-reduc-4.c + tsvc/vect-tsvc-s000.c + tsvc/vect-tsvc-s1111.c + tsvc/vect-tsvc-s1112.c + tsvc/vect-tsvc-s1113.c + tsvc/vect-tsvc-s1115.c + tsvc/vect-tsvc-s1119.c + tsvc/vect-tsvc-s111.c + tsvc/vect-tsvc-s112.c + tsvc/vect-tsvc-s113.c + tsvc/vect-tsvc-s114.c + tsvc/vect-tsvc-s115.c + tsvc/vect-tsvc-s1161.c + tsvc/vect-tsvc-s116.c + tsvc/vect-tsvc-s118.c + tsvc/vect-tsvc-s119.c + tsvc/vect-tsvc-s1213.c + tsvc/vect-tsvc-s121.c + tsvc/vect-tsvc-s1221.c + tsvc/vect-tsvc-s122.c + tsvc/vect-tsvc-s1232.c + tsvc/vect-tsvc-s123.c + tsvc/vect-tsvc-s1244.c + tsvc/vect-tsvc-s124.c + tsvc/vect-tsvc-s1251.c + tsvc/vect-tsvc-s125.c + tsvc/vect-tsvc-s126.c + tsvc/vect-tsvc-s1279.c + tsvc/vect-tsvc-s127.c + tsvc/vect-tsvc-s1281.c + tsvc/vect-tsvc-s128.c + tsvc/vect-tsvc-s13110.c + tsvc/vect-tsvc-s131.c + tsvc/vect-tsvc-s132.c + tsvc/vect-tsvc-s1351.c + tsvc/vect-tsvc-s141.c + tsvc/vect-tsvc-s1421.c + tsvc/vect-tsvc-s151.c + tsvc/vect-tsvc-s152.c + tsvc/vect-tsvc-s161.c + tsvc/vect-tsvc-s162.c + tsvc/vect-tsvc-s171.c + tsvc/vect-tsvc-s172.c + tsvc/vect-tsvc-s173.c + tsvc/vect-tsvc-s174.c + tsvc/vect-tsvc-s175.c + tsvc/vect-tsvc-s176.c + tsvc/vect-tsvc-s2101.c + tsvc/vect-tsvc-s2102.c + tsvc/vect-tsvc-s2111.c + tsvc/vect-tsvc-s211.c + tsvc/vect-tsvc-s212.c + tsvc/vect-tsvc-s221.c + tsvc/vect-tsvc-s222.c + tsvc/vect-tsvc-s2233.c + tsvc/vect-tsvc-s2244.c + tsvc/vect-tsvc-s2251.c + tsvc/vect-tsvc-s2275.c + tsvc/vect-tsvc-s231.c + tsvc/vect-tsvc-s232.c + tsvc/vect-tsvc-s233.c + tsvc/vect-tsvc-s235.c + tsvc/vect-tsvc-s241.c + tsvc/vect-tsvc-s242.c + tsvc/vect-tsvc-s243.c + tsvc/vect-tsvc-s244.c + tsvc/vect-tsvc-s251.c + tsvc/vect-tsvc-s252.c + tsvc/vect-tsvc-s253.c + tsvc/vect-tsvc-s254.c + tsvc/vect-tsvc-s255.c + tsvc/vect-tsvc-s256.c + tsvc/vect-tsvc-s257.c + tsvc/vect-tsvc-s258.c + tsvc/vect-tsvc-s261.c + tsvc/vect-tsvc-s2710.c + tsvc/vect-tsvc-s2711.c + tsvc/vect-tsvc-s2712.c + tsvc/vect-tsvc-s271.c + tsvc/vect-tsvc-s272.c + tsvc/vect-tsvc-s273.c + tsvc/vect-tsvc-s274.c + tsvc/vect-tsvc-s275.c + tsvc/vect-tsvc-s276.c + tsvc/vect-tsvc-s277.c + tsvc/vect-tsvc-s278.c + tsvc/vect-tsvc-s279.c + tsvc/vect-tsvc-s281.c + tsvc/vect-tsvc-s291.c + tsvc/vect-tsvc-s292.c + tsvc/vect-tsvc-s293.c + tsvc/vect-tsvc-s3110.c + tsvc/vect-tsvc-s31111.c + tsvc/vect-tsvc-s3111.c + tsvc/vect-tsvc-s3112.c + tsvc/vect-tsvc-s3113.c + tsvc/vect-tsvc-s311.c + tsvc/vect-tsvc-s312.c + tsvc/vect-tsvc-s313.c + tsvc/vect-tsvc-s314.c + tsvc/vect-tsvc-s315.c + tsvc/vect-tsvc-s316.c + tsvc/vect-tsvc-s317.c + tsvc/vect-tsvc-s318.c + tsvc/vect-tsvc-s319.c + tsvc/vect-tsvc-s321.c + tsvc/vect-tsvc-s322.c + tsvc/vect-tsvc-s323.c + tsvc/vect-tsvc-s3251.c + tsvc/vect-tsvc-s331.c + tsvc/vect-tsvc-s332.c + tsvc/vect-tsvc-s341.c + tsvc/vect-tsvc-s342.c + tsvc/vect-tsvc-s343.c + tsvc/vect-tsvc-s351.c + tsvc/vect-tsvc-s352.c + tsvc/vect-tsvc-s353.c + tsvc/vect-tsvc-s4112.c + tsvc/vect-tsvc-s4113.c + tsvc/vect-tsvc-s4114.c + tsvc/vect-tsvc-s4115.c + tsvc/vect-tsvc-s4116.c + tsvc/vect-tsvc-s4117.c + tsvc/vect-tsvc-s4121.c + tsvc/vect-tsvc-s421.c + tsvc/vect-tsvc-s422.c + tsvc/vect-tsvc-s423.c + tsvc/vect-tsvc-s424.c + tsvc/vect-tsvc-s431.c + tsvc/vect-tsvc-s441.c + tsvc/vect-tsvc-s442.c + tsvc/vect-tsvc-s443.c + tsvc/vect-tsvc-s451.c + tsvc/vect-tsvc-s452.c + tsvc/vect-tsvc-s453.c + tsvc/vect-tsvc-s471.c + tsvc/vect-tsvc-s481.c + tsvc/vect-tsvc-s482.c + tsvc/vect-tsvc-s491.c + tsvc/vect-tsvc-va.c + tsvc/vect-tsvc-vag.c + tsvc/vect-tsvc-vas.c + tsvc/vect-tsvc-vbor.c + tsvc/vect-tsvc-vdotr.c + tsvc/vect-tsvc-vif.c + tsvc/vect-tsvc-vpv.c + tsvc/vect-tsvc-vpvpv.c + tsvc/vect-tsvc-vpvts.c + tsvc/vect-tsvc-vpvtv.c + tsvc/vect-tsvc-vsumr.c + tsvc/vect-tsvc-vtv.c + tsvc/vect-tsvc-vtvtv.c + unswitch-loops-pr26969.c + vec-scal-opt1.c + vec-scal-opt2.c + vec-scal-opt.c + vect-100.c + vect-103.c + vect-104.c + vect-105-big-array.c + vect-105.c + vect-106.c + vect-107.c + vect-108.c + vect-109.c + vect-10-big-array.c + vect-10.c + vect-110.c + vect-112-big-array.c + vect-112.c + vect-113.c + vect-114.c + vect-115.c + vect-116.c + vect-117.c + vect-118.c + vect-119.c + vect-11a.c + vect-11.c + vect-120.c + vect-121.c + vect-122.c + vect-123.c + vect-124.c + vect-125.c + vect-126.c + vect-12.c + vect-13.c + vect-14.c + vect-15-big-array.c + vect-15.c + vect-17.c + vect-18.c + vect-19.c + vect-1-big-array.c + vect-1.c + vect-20.c + vect-21.c + vect-22.c + vect-23.c + vect-24.c + vect-25.c + vect-26.c + vect-27.c + vect-28.c + vect-29.c + vect-2-big-array.c + vect-2.c + vect-30.c + vect-31-big-array.c + vect-31.c + vect-32-big-array.c + vect-32.c + vect-32-chars.c + vect-33-big-array.c + vect-33.c + vect-34-big-array.c + vect-34.c + vect-35-big-array.c + vect-35.c + vect-36-big-array.c + vect-36.c + vect-38.c + vect-3.c + vect-40.c + vect-42.c + vect-44.c + vect-46.c + vect-48.c + vect-4.c + vect-50.c + vect-52.c + vect-54.c + vect-56.c + vect-58.c + vect-5.c + vect-60.c + vect-62.c + vect-63.c + vect-64.c + vect-65.c + vect-66.c + vect-67.c + vect-68.c + vect-6-big-array.c + vect-6.c + vect-70.c + vect-71.c + vect-72.c + vect-73-big-array.c + vect-73.c + vect-74-big-array.c + vect-74.c + vect-75-big-array.c + vect-75.c + vect-76-big-array.c + vect-76.c + vect-77-alignchecks.c + vect-77.c + vect-77-global.c + vect-78-alignchecks.c + vect-78.c + vect-78-global.c + vect-7.c + vect-80-big-array.c + vect-80.c + vect-82_64.c + vect-82.c + vect-83_64.c + vect-83.c + vect-85-big-array.c + vect-85.c + vect-86.c + vect-87.c + vect-88.c + vect-89-big-array.c + vect-89.c + vect-8.c + vect-91.c + vect-92.c + vect-93.c + vect-95.c + vect-96.c + vect-97-big-array.c + vect-97.c + vect-98-big-array.c + vect-98.c + vect-99.c + vect-9.c + vect-aggressive-1.c + vect-alias-check-10.c + vect-alias-check-11.c + vect-alias-check-12.c + vect-alias-check-13.c + vect-alias-check-14.c + vect-alias-check-15.c + vect-alias-check-16.c + vect-alias-check-17.c + vect-alias-check-18.c + vect-alias-check-19.c + vect-alias-check-1.c + vect-alias-check-20.c + vect-alias-check-2.c + vect-alias-check-3.c + vect-alias-check-4.c + vect-alias-check-5.c + vect-alias-check-6.c + vect-alias-check-7.c + vect-alias-check-8.c + vect-alias-check-9.c + vect-alias-check.c + vect-align-1.c + vect-align-2.c + vect-align-3.c + vect-align-4.c + vect-all-big-array.c + vect-all.c + vect-avg-10.c + vect-avg-11.c + vect-avg-12.c + vect-avg-13.c + vect-avg-14.c + vect-avg-15.c + vect-avg-16.c + vect-avg-1.c + vect-avg-2.c + vect-avg-3.c + vect-avg-4.c + vect-avg-5.c + vect-avg-6.c + vect-avg-7.c + vect-avg-8.c + vect-avg-9.c + vect-bic-bitmask-10.c + vect-bic-bitmask-11.c + vect-bic-bitmask-12.c + vect-bic-bitmask-23.c + vect-bic-bitmask-2.c + vect-bic-bitmask-3.c + vect-bic-bitmask-4.c + vect-bic-bitmask-5.c + vect-bic-bitmask-6.c + vect-bic-bitmask-8.c + vect-bic-bitmask-9.c + vect-bitfield-read-1.c + vect-bitfield-read-1-not.c + vect-bitfield-read-2.c + vect-bitfield-read-2-not.c + vect-bitfield-read-3.c + vect-bitfield-read-4.c + vect-bitfield-read-5.c + vect-bitfield-read-6.c + vect-bitfield-read-7.c + vect-bitfield-read-8.c + vect-bitfield-read-9.c + vect-bitfield-write-1.c + vect-bitfield-write-2.c + vect-bitfield-write-3.c + vect-bitfield-write-4.c + vect-bitfield-write-5.c + vect-bool-1.c + vect-bool-cmp-2.c + vect-bool-cmp.c + vect-bswap16a.c + vect-bswap16.c + vect-bswap32.c + vect-bswap64.c + vect-complex-1.c + vect-complex-2.c + vect-complex-4.c + vect-complex-5.c + vect-cond-10.c + vect-cond-11.c + vect-cond-12.c + vect-cond-13.c + vect-cond-1.c + vect-cond-2.c + vect-cond-3.c + vect-cond-4.c + vect-cond-5.c + vect-cond-6.c + vect-cond-7.c + vect-cond-8.c + vect-cond-9.c + vect-cond-arith-1.c + vect-cond-arith-2.c + vect-cond-arith-3.c + vect-cond-arith-4.c + vect-cond-arith-5.c + vect-cond-arith-6.c + vect-cond-arith-7.c + vect-cond-arith-8.c + vect-cond-reduc-1.c + vect-cond-reduc-2.c + vect-cond-reduc-3.c + vect-cond-reduc-4.c + vect-cond-reduc-5.c + vect-cond-reduc-6.c + vect-cond-reduc-in-order-2-signed-zero.c + vect-cost-model-1.c + vect-cost-model-2.c + vect-cost-model-3.c + vect-cost-model-4.c + vect-cost-model-5.c + vect-cost-model-6.c + vect-cselim-1.c + vect-cselim-2.c + vect-ctor-1.c + vect-debug-pr41926.c + vect-div-bitmask-1.c + vect-div-bitmask-2.c + vect-div-bitmask-3.c + vect-div-bitmask-4.c + vect-div-bitmask-5.c + vect-double-reduc-1.c + vect-double-reduc-2.c + vect-double-reduc-3.c + vect-double-reduc-4.c + vect-double-reduc-5.c + vect-double-reduc-6-big-array.c + vect-double-reduc-6.c + vect-double-reduc-7.c + vect-dv-1.c + vect-early-break_10.c + vect-early-break_11.c + vect-early-break_12.c + vect-early-break_13.c + vect-early-break_14.c + vect-early-break_15.c + vect-early-break_16.c + vect-early-break_17.c + vect-early-break_18.c + vect-early-break_19.c + vect-early-break_1.c + vect-early-break_20.c + vect-early-break_21.c + vect-early-break_22.c + vect-early-break_23.c + vect-early-break_24.c + vect-early-break_25.c + vect-early-break_26.c + vect-early-break_27.c + vect-early-break_28.c + vect-early-break_29.c + vect-early-break_2.c + vect-early-break_30.c + vect-early-break_31.c + vect-early-break_32.c + vect-early-break_33.c + vect-early-break_34.c + vect-early-break_35.c + vect-early-break_36.c + vect-early-break_37.c + vect-early-break_38.c + vect-early-break_39.c + vect-early-break_3.c + vect-early-break_40.c + vect-early-break_41.c + vect-early-break_42.c + vect-early-break_43.c + vect-early-break_44.c + vect-early-break_45.c + vect-early-break_46.c + vect-early-break_47.c + vect-early-break_48.c + vect-early-break_49.c + vect-early-break_4.c + vect-early-break_50.c + vect-early-break_51.c + vect-early-break_52.c + vect-early-break_53.c + vect-early-break_54.c + vect-early-break_55.c + vect-early-break_56.c + vect-early-break_57.c + vect-early-break_58.c + vect-early-break_59.c + vect-early-break_5.c + vect-early-break_60.c + vect-early-break_61.c + vect-early-break_62.c + vect-early-break_63.c + vect-early-break_64.c + vect-early-break_65.c + vect-early-break_66.c + vect-early-break_67.c + vect-early-break_68.c + vect-early-break_69.c + vect-early-break_6.c + vect-early-break_70.c + vect-early-break_71.c + vect-early-break_72.c + vect-early-break_73.c + vect-early-break_74.c + vect-early-break_75.c + vect-early-break_76.c + vect-early-break_77.c + vect-early-break_78.c + vect-early-break_79.c + vect-early-break_7.c + vect-early-break_80.c + vect-early-break_81.c + vect-early-break_82.c + vect-early-break_83.c + vect-early-break_84.c + vect-early-break_85.c + vect-early-break_86.c + vect-early-break_87.c + vect-early-break_88.c + vect-early-break_89.c + vect-early-break_8.c + vect-early-break_90.c + vect-early-break_91.c + vect-early-break_92.c + vect-early-break_93.c + vect-early-break_9.c + vect-early-break-run_10.c + vect-early-break-run_1.c + vect-early-break-run_2.c + vect-early-break-run_3.c + vect-early-break-run_4.c + vect-early-break-run_5.c + vect-early-break-run_6.c + vect-early-break-run_7.c + vect-early-break-run_8.c + vect-early-break-run_9.c + vect-early-break-template_1.c + vect-early-break-template_2.c + vect-epilogues-2.c + vect-epilogues.c + vect-float-extend-1.c + vect-floatint-conversion-1.c + vect-floatint-conversion-2.c + vect-float-truncate-1.c + vect-fma-1.c + vect-fma-2.c + vect-fma-3.c + vect-fmax-1.c + vect-fmax-2.c + vect-fmax-3.c + vect-fmin-1.c + vect-fmin-2.c + vect-fmin-3.c + vect-fold-1.c + vect-gather-1.c + vect-gather-2.c + vect-gather-3.c + vect-gather-4.c + vect-gather-5.c + vect-gather-6.c + vect-ifcvt-10.c + vect-ifcvt-11.c + vect-ifcvt-16.c + vect-ifcvt-17.c + vect-ifcvt-18.c + vect-ifcvt-19.c + vect-ifcvt-20.c + vect-ifcvt-2.c + vect-ifcvt-3.c + vect-ifcvt-4.c + vect-ifcvt-5.c + vect-ifcvt-6.c + vect-ifcvt-7.c + vect-ifcvt-9.c + vect-intfloat-conversion-1.c + vect-intfloat-conversion-2.c + vect-intfloat-conversion-3.c + vect-intfloat-conversion-4a.c + vect-intfloat-conversion-4b.c + vect-iv-10.c + vect-iv-11.c + vect-iv-1.c + vect-iv-2.c + vect-iv-3.c + vect-iv-4.c + vect-iv-5.c + vect-iv-6.c + vect-iv-7.c + vect-iv-8a-big-array.c + vect-iv-8a.c + vect-iv-8-big-array.c + vect-iv-8.c + vect-iv-9.c + vect-ivdep-1.c + vect-ivdep-2.c + vect-live-1.c + vect-live-2.c + vect-live-3.c + vect-live-4.c + vect-live-5.c + vect-live-6.c + vect-live-slp-1.c + vect-live-slp-2.c + vect-live-slp-3.c + vect-load-lanes-peeling-1.c + vect-mask-load-1.c + vect-mask-loadstore-1.c + vect-mask-store-move-1.c + vect-mixed-size-cond-1.c + vect-mulhrs-1.c + vect-mulhrs-2.c + vect-mulhrs-3.c + vect-mulhrs-4.c + vect-mult-const-pattern-1.c + vect-mult-const-pattern-2.c + vect-multi-peel-gaps.c + vect-multitypes-10.c + vect-multitypes-11.c + vect-multitypes-12.c + vect-multitypes-13.c + vect-multitypes-14.c + vect-multitypes-15.c + vect-multitypes-16.c + vect-multitypes-17.c + vect-multitypes-1.c + vect-multitypes-2.c + vect-multitypes-3.c + vect-multitypes-4.c + vect-multitypes-5.c + vect-multitypes-6.c + vect-multitypes-7.c + vect-multitypes-8.c + vect-multitypes-9.c + vect-mult-pattern-1.c + vect-mult-pattern-2.c + vect-nb-iter-ub-1.c + vect-nb-iter-ub-2.c + vect-nb-iter-ub-3.c + vect-neg-store-1.c + vect-neg-store-2.c + vect-nest-cycle-1.c + vect-nest-cycle-2.c + vect-nest-cycle-3.c + vect-nop-move.c + vect-novector-pragma.c + vect-ooo-group-1.c + vect-outer-1a-big-array.c + vect-outer-1a.c + vect-outer-1b-big-array.c + vect-outer-1b.c + vect-outer-1-big-array.c + vect-outer-1.c + vect-outer-2a-big-array.c + vect-outer-2a.c + vect-outer-2b.c + vect-outer-2-big-array.c + vect-outer-2.c + vect-outer-2c-big-array.c + vect-outer-2c.c + vect-outer-2d.c + vect-outer-3a-big-array.c + vect-outer-3a.c + vect-outer-3b.c + vect-outer-3-big-array.c + vect-outer-3.c + vect-outer-3c.c + vect-outer-4a-big-array.c + vect-outer-4a.c + vect-outer-4b-big-array.c + vect-outer-4b.c + vect-outer-4.c + vect-outer-4c-big-array.c + vect-outer-4c.c + vect-outer-4d-big-array.c + vect-outer-4d.c + vect-outer-4e.c + vect-outer-4f.c + vect-outer-4g.c + vect-outer-4i.c + vect-outer-4j.c + vect-outer-4k.c + vect-outer-4l.c + vect-outer-4m-big-array.c + vect-outer-4m.c + vect-outer-5.c + vect-outer-6.c + vect-outer-call-1.c + vect-outer-fir-big-array.c + vect-outer-fir.c + vect-outer-fir-lb-big-array.c + vect-outer-fir-lb.c + vect-outer-pr69720.c + vect-outer-simd-1.c + vect-outer-simd-2.c + vect-outer-simd-3.c + vect-outer-slp-1.c + vect-outer-slp-2.c + vect-outer-slp-3.c + vect-over-widen-10.c + vect-over-widen-11.c + vect-over-widen-12.c + vect-over-widen-13.c + vect-over-widen-14.c + vect-over-widen-15.c + vect-over-widen-16.c + vect-over-widen-17.c + vect-over-widen-18.c + vect-over-widen-19.c + vect-over-widen-1-big-array.c + vect-over-widen-1.c + vect-over-widen-20.c + vect-over-widen-21.c + vect-over-widen-22.c + vect-over-widen-23.c + vect-over-widen-2-big-array.c + vect-over-widen-2.c + vect-over-widen-3-big-array.c + vect-over-widen-3.c + vect-over-widen-4-big-array.c + vect-over-widen-4.c + vect-over-widen-5.c + vect-over-widen-6.c + vect-over-widen-7.c + vect-over-widen-8.c + vect-over-widen-9.c + vect-peel-1.c + vect-peel-1-epilogue.c + vect-peel-1-src.c + vect-peel-2.c + vect-peel-2-epilogues.c + vect-peel-2-src.c + vect-peel-3.c + vect-peel-3-epilogue.c + vect-peel-3-src.c + vect-peel-4.c + vect-peel-4-epilogue.c + vect-peel-4-src.c + vect-pr111779.c + vect-pr69848.c + vect-pre-interact.c + vect-profile-1.c + vect-recip.c + vect-recurr-1.c + vect-recurr-2.c + vect-recurr-3.c + vect-recurr-4.c + vect-recurr-5.c + vect-recurr-6.c + vect-reduc-10.c + vect-reduc-11.c + vect-reduc-1.c + vect-reduc-1char-big-array.c + vect-reduc-1char.c + vect-reduc-1short.c + vect-reduc-2.c + vect-reduc-2char-big-array.c + vect-reduc-2char.c + vect-reduc-2short.c + vect-reduc-3.c + vect-reduc-6.c + vect-reduc-7.c + vect-reduc-8.c + vect-reduc-9.c + vect-reduc-dot-10.c + vect-reduc-dot-11.c + vect-reduc-dot-12.c + vect-reduc-dot-13.c + vect-reduc-dot-14.c + vect-reduc-dot-15.c + vect-reduc-dot-16.c + vect-reduc-dot-17.c + vect-reduc-dot-18.c + vect-reduc-dot-19.c + vect-reduc-dot-1.c + vect-reduc-dot-20.c + vect-reduc-dot-21.c + vect-reduc-dot-22.c + vect-reduc-dot-2.c + vect-reduc-dot-3.c + vect-reduc-dot-4.c + vect-reduc-dot-5.c + vect-reduc-dot-6.c + vect-reduc-dot-7.c + vect-reduc-dot-8.c + vect-reduc-dot-9.c + vect-reduc-dot-s16a.c + vect-reduc-dot-s16b.c + vect-reduc-dot-s16c.c + vect-reduc-dot-s8a.c + vect-reduc-dot-s8b.c + vect-reduc-dot-s8c.c + vect-reduc-dot-u16a.c + vect-reduc-dot-u16b.c + vect-reduc-dot-u8a.c + vect-reduc-dot-u8b.c + vect-reduc-epilogue-gaps.c + vect-reduc-in-order-1.c + vect-reduc-in-order-2.c + vect-reduc-in-order-3.c + vect-reduc-in-order-4.c + vect-reduc-mul_1.c + vect-reduc-mul_2.c + vect-reduc-or_1.c + vect-reduc-or_2.c + vect-reduc-pattern-1a.c + vect-reduc-pattern-1b-big-array.c + vect-reduc-pattern-1b.c + vect-reduc-pattern-1c-big-array.c + vect-reduc-pattern-1c.c + vect-reduc-pattern-2a.c + vect-reduc-pattern-2b-big-array.c + vect-reduc-pattern-2b.c + vect-reduc-pattern-2c.c + vect-reduc-pattern-3.c + vect-reduc-sad-1.c + vect-reduc-sad-2.c + vect-reduc-sad-3.c + vect-reduc-sad-4.c + vect-reduc-sad-5.c + vect-reduc-sad-6.c + vect-reduc-sad-7.c + vect-reduc-sad-8.c + vect-reduc-sad.c + vect-rounding-btrunc.c + vect-rounding-btruncf.c + vect-rounding-ceil.c + vect-rounding-ceilf.c + vect-rounding-floor.c + vect-rounding-floorf.c + vect-rounding-lceil.c + vect-rounding-lfloor.c + vect-rounding-nearbyint.c + vect-rounding-nearbyintf.c + vect-rounding-round.c + vect-rounding-roundf.c + vect-sdivmod-1.c + vect-sdiv-pow2-1.c + vect-shift-1.c + vect-shift-2-big-array.c + vect-shift-2.c + vect-shift-3.c + vect-shift-4.c + vect-shift-5.c + vect-simd-10.c + vect-simd-11.c + vect-simd-12.c + vect-simd-13.c + vect-simd-14.c + vect-simd-15.c + vect-simd-16.c + vect-simd-17.c + vect-simd-18.c + vect-simd-19.c + vect-simd-1.c + vect-simd-20.c + vect-simd-2.c + vect-simd-3.c + vect-simd-4.c + vect-simd-5.c + vect-simd-6.c + vect-simd-7.c + vect-simd-8.c + vect-simd-9.c + vect-simd-clone-10a.c + vect-simd-clone-10.c + vect-simd-clone-11.c + vect-simd-clone-12a.c + vect-simd-clone-12.c + vect-simd-clone-13.c + vect-simd-clone-14.c + vect-simd-clone-15.c + vect-simd-clone-16b.c + vect-simd-clone-16.c + vect-simd-clone-16c.c + vect-simd-clone-16d.c + vect-simd-clone-16e.c + vect-simd-clone-16f.c + vect-simd-clone-17b.c + vect-simd-clone-17.c + vect-simd-clone-17c.c + vect-simd-clone-17d.c + vect-simd-clone-17e.c + vect-simd-clone-17f.c + vect-simd-clone-18b.c + vect-simd-clone-18.c + vect-simd-clone-18c.c + vect-simd-clone-18d.c + vect-simd-clone-18e.c + vect-simd-clone-18f.c + vect-simd-clone-19.c + vect-simd-clone-1.c + vect-simd-clone-20.c + vect-simd-clone-2.c + vect-simd-clone-3.c + vect-simd-clone-4.c + vect-simd-clone-5.c + vect-simd-clone-6.c + vect-simd-clone-7.c + vect-simd-clone-8.c + vect-simd-clone-9.c + vect-singleton_1.c + vect-strided-a-mult.c + vect-strided-a-u16-i2.c + vect-strided-a-u16-i4.c + vect-strided-a-u16-mult.c + vect-strided-a-u32-mult.c + vect-strided-a-u8-i2-gap.c + vect-strided-a-u8-i8-gap2-big-array.c + vect-strided-a-u8-i8-gap2.c + vect-strided-a-u8-i8-gap7-big-array.c + vect-strided-a-u8-i8-gap7.c + vect-strided-epilogue-1.c + vect-strided-float.c + vect-strided-mult.c + vect-strided-mult-char-ls.c + vect-strided-same-dr.c + vect-strided-shift-1.c + vect-strided-store-a-u8-i2.c + vect-strided-store.c + vect-strided-store-u16-i4.c + vect-strided-store-u32-i2.c + vect-strided-u16-i2.c + vect-strided-u16-i3.c + vect-strided-u16-i4.c + vect-strided-u32-i4.c + vect-strided-u32-i8.c + vect-strided-u32-mult.c + vect-strided-u8-i2.c + vect-strided-u8-i2-gap.c + vect-strided-u8-i8.c + vect-strided-u8-i8-gap2-big-array.c + vect-strided-u8-i8-gap2.c + vect-strided-u8-i8-gap4-big-array.c + vect-strided-u8-i8-gap4.c + vect-strided-u8-i8-gap4-unknown.c + vect-strided-u8-i8-gap7-big-array.c + vect-strided-u8-i8-gap7.c + vect-tail-nomask-1.c + vect-version-1.c + vect-version-2.c + vect-vfa-01.c + vect-vfa-02.c + vect-vfa-03.c + vect-vfa-04.c + vect-vfa-slp.c + vect-widen-mult-1.c + vect-widen-mult-2.c + vect-widen-mult-3.c + vect-widen-mult-4.c + vect-widen-mult-const-s16.c + vect-widen-mult-const-u16.c + vect-widen-mult-extern-1.c + vect-widen-mult-half.c + vect-widen-mult-half-u8.c + vect-widen-mult-s16.c + vect-widen-mult-s8.c + vect-widen-mult-sum.c + vect-widen-mult-u16.c + vect-widen-mult-u8.c + vect-widen-mult-u8-s16-s32.c + vect-widen-mult-u8-u32.c + vect-widen-shift-s16.c + vect-widen-shift-s8.c + vect-widen-shift-u16.c + vect-widen-shift-u8.c + wrapv-vect-7.c + wrapv-vect-reduc-2char.c + wrapv-vect-reduc-2short.c + wrapv-vect-reduc-dot-s8b.c + wrapv-vect-reduc-pattern-2c.c +) diff --git a/SingleSource/Regression/C/gcc-dg/vect/O-pr46167.c b/SingleSource/Regression/C/gcc-dg/vect/O-pr46167.c new file mode 100644 index 0000000000..fc6e8a3fcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O-pr46167.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +int foo (char c, int i) +{ + int s = 0; + while (i--) + s += c; + return s; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/O1-pr33854.c b/SingleSource/Regression/C/gcc-dg/vect/O1-pr33854.c new file mode 100644 index 0000000000..2c4613efb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O1-pr33854.c @@ -0,0 +1,21 @@ +/* Testcase by Martin Michlmayr */ +/* { dg-do compile } */ + +extern void *malloc (__SIZE_TYPE__ __size); +typedef struct VMatrix_ VMatrix; +struct VMatrix_ +{ + int dim; + int t2; +}; +void uniform_correlation_matrix (VMatrix * v) +{ + double *xbar = ((void *) 0); + int m = v->dim; + int i; + xbar = malloc (m * sizeof *xbar); + for (i = 0; i < m; i++) + xbar[i] /= m; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/O1-pr41008.c b/SingleSource/Regression/C/gcc-dg/vect/O1-pr41008.c new file mode 100644 index 0000000000..17579a34b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O1-pr41008.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +double heating[2][2]; + +void foo (int, int); + +void map_do() +{ + int jsav, ksav, k, j; + + for(k = 0; k < 2; k++) + for(j = 0; j < 2; j++) + if (heating[k][j] > 0.) + { + jsav = j; + ksav = k; + } + + foo (jsav, ksav); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/O3-pr36098.c b/SingleSource/Regression/C/gcc-dg/vect/O3-pr36098.c new file mode 100644 index 0000000000..8e41717082 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O3-pr36098.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +typedef struct { + int iatom[3]; + int blocknr; +} t_sortblock; + +#define DIM 3 + +void foo (int ncons, t_sortblock *sb, int *iatom) +{ + int i, m; + + for(i=0; (ia[0][j][i] = s[i][0]; + img->a[1][j][i] = s[j][1]; + img->a[2][j][i] = s0; + } + } +} + +const int s[16][2] = { { 1, 16 }, { 2, 15 }, { 3, 14 }, { 4, 13 }, + { 5, 12 }, { 6, 11 }, { 7, 10 }, { 8, 9 }, + { 9, 8 }, { 10, 7 }, { 11, 6 }, { 12, 5 }, + { 13, 4 }, { 14, 3 }, { 15, 2 }, { 16, 1 } }; +const struct foo expected += { { { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, + { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 } }, + { { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }, + { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 }, + { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }, + { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 }, + { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 }, + { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 }, + { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, + { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }, + { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, + { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, + { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, + { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }, + { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }, + { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }, + { { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } } }, + 0 }; + +int +main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < 8; i++) + Loop_err (images + i, s, -1); + +#pragma GCC novector + for (i = 0; i < 8; i++) + if (__builtin_memcmp (&expected, images + i, sizeof (expected))) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/O3-pr85794.c b/SingleSource/Regression/C/gcc-dg/vect/O3-pr85794.c new file mode 100644 index 0000000000..0def0fa085 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O3-pr85794.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +int a, b, *c, d; +int *f[6]; + +void +foo (void) +{ + for (b = 1; b >= 0; b--) + for (d = 0; d <= 3; d++) + a |= f[b * 5] != c; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/O3-pr87546.c b/SingleSource/Regression/C/gcc-dg/vect/O3-pr87546.c new file mode 100644 index 0000000000..0d3b71474c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O3-pr87546.c @@ -0,0 +1,29 @@ +#include "tree-vect.h" + +int a; +long b, f; +signed char c, g; +short int d = 219; +int e[64]; + +__attribute__((noipa)) void +foo (void) +{ + asm volatile ("" : : "g" (&a), "g" (&d) : "memory"); + for (c = 0; c < 64; c++) + { + g = d < 0 ? d : d >> a; + f = g + b; + e[c] = f; + } + if (e[1] != (signed char) d) + __builtin_abort (); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/O3-slp-reduc-10.c b/SingleSource/Regression/C/gcc-dg/vect/O3-slp-reduc-10.c new file mode 100644 index 0000000000..42a59f4a15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O3-slp-reduc-10.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 +#define TYPE int +#define RESULT 755918 + +__attribute__ ((noinline)) TYPE fun2 (TYPE *x, TYPE *y, unsigned int n) +{ + int i, j; + TYPE dot = 14; + + for (i = 0; i < n / 2; i++) + for (j = 0; j < 2; j++) + dot += *(x++) * *(y++); + + return dot; +} + +int main (void) +{ + TYPE a[N], b[N], dot; + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = i; + b[i] = i+8; + } + + dot = fun2 (a, b, N); + if (dot != RESULT) + abort(); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { vect_int_mult && {! vect_no_align } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr32243.c b/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr32243.c new file mode 100644 index 0000000000..68a7e5ddf9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr32243.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +typedef struct __GLcontextRec GLcontext; + +struct gl_renderbuffer +{ + struct gl_renderbuffer *Wrapped; + void (*PutValues) (GLcontext * ctx, struct gl_renderbuffer * rb, + int count, const int x[], const int y[], + const void *values, const char *mask); +}; + +void +put_mono_values_s8 (GLcontext * ctx, struct gl_renderbuffer *s8rb, + int count, const int x[], const int y[], + const void *value, const char *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + int temp[4096], i; + const char val = *((char *) value); + for (i = 0; i < count; i++) + if (!mask || mask[i]) + temp[i] = (temp[i] & 0xffffff) | val; + dsrb->PutValues (ctx, dsrb, count, x, y, temp, mask); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr34223.c b/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr34223.c new file mode 100644 index 0000000000..7d13f1c2e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr34223.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define M 10 +#define N 3 + +void __attribute__((noinline)) +foo (int n, int *ub, int *uc) +{ + int i, j, tmp1; + + for (i = 0; i < n; i++) + { + tmp1 = 0; + for (j = 0; j < M; j++) + { + tmp1 += uc[i] * ((int)(j << N) / M); + } + ub[i] = tmp1; + } +} + +int main() +{ + int uc[16], ub[16]; + check_vect (); + foo (16, uc, ub); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_int_mult } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr61917.c b/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr61917.c new file mode 100644 index 0000000000..75bd17106e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/O3-vect-pr61917.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a, b, c, d; + +int +fn1 () +{ + for (; c; c++) + for (b = 0; b < 2; b++) + d = a - d; + return d; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/Os-vect-95.c b/SingleSource/Regression/C/gcc-dg/vect/Os-vect-95.c new file mode 100644 index 0000000000..8039be89fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/Os-vect-95.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +void bar (float *pd, float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + if (pd[i] != 5.0) + abort (); + } + + return; +} + + +int +main1 (int n, float * __restrict__ pd, float * __restrict__ pa, float * __restrict__ pb, float * __restrict__ pc) +{ + int i; + + for (i = 0; i < n; i++) + { + pa[i] = pb[i] * pc[i]; + pd[i] = 5.0; + } + + bar (pd,pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float d[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (N,&d[1],a,b,c); + main1 (N-2,&d[1],a,b,c); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-nest-1.c b/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-nest-1.c new file mode 100644 index 0000000000..24b2fa86da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-nest-1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target section_anchors } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +static int a[N][N]; +static int b[N][N]; +static int c[N][N]; + +void clobber(int *); + +int *foo(void) +{ + int i; + int j; + + clobber (&a[0][0]); + clobber (&b[0][0]); + clobber (&c[0][0]); + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + c[j][i] += a[j][i] + c[j][i]; + } + } + return &c[0][0]; +} + +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 3 "increase_alignment" { xfail vect_element_align_preferred } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-70.c b/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-70.c new file mode 100644 index 0000000000..7010a52b58 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-70.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target section_anchors } */ +/* { dg-require-effective-target vect_int } */ + +#define N 32 + +/* Increase alignment of struct if an array's offset is multiple of alignment of + vector type corresponding to it's scalar type. + For the below test-case: + offsetof(e) == 8 bytes. + i) For arm: let x = alignment of vector type corresponding to int, + x == 8 bytes. + Since offsetof(e) % x == 0, set DECL_ALIGN(a, b, c) to x. + ii) For aarch64, ppc: x == 16 bytes. + Since offsetof(e) % x != 0, don't increase alignment of a, b, c. +*/ + +static struct A { + int p1, p2; + int e[N]; +} a, b, c; + +int foo(void) +{ + for (int i = 0; i < N; i++) + a.e[i] = b.e[i] + c.e[i]; + + return a.e[0]; +} + +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target aarch64*-*-* } } } */ +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target powerpc64*-*-* } } } */ +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 3 "increase_alignment" { target arm*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-71.c b/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-71.c new file mode 100644 index 0000000000..7cbd1dcf30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-71.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target section_anchors } */ +/* { dg-require-effective-target vect_int } */ + +/* Should not increase alignment of the struct because + sizeof (A.e) < sizeof(corresponding vector type). */ + +#define N 3 + +static struct A { + int p1, p2; + int e[N]; +} a, b, c; + +int foo(void) +{ + for (int i = 0; i < N; i++) + a.e[i] = b.e[i] + c.e[i]; + + return a.e[0]; +} + +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target aarch64*-*-* } } } */ +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target powerpc64*-*-* } } } */ +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target arm*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-72.c b/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-72.c new file mode 100644 index 0000000000..873fabe9f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/aligned-section-anchors-vect-72.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target section_anchors } */ +/* { dg-require-effective-target vect_int } */ + +#define N 32 + +/* Clone of section-anchors-vect-70.c having nested struct. */ + +struct S +{ + int e[N]; +}; + +static struct A { + int p1, p2; + struct S s; +} a, b, c; + +int foo(void) +{ + for (int i = 0; i < N; i++) + a.s.e[i] = b.s.e[i] + c.s.e[i]; + + return a.s.e[0]; +} + +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target aarch64*-*-* } } } */ +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target powerpc64*-*-* } } } */ +/* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 3 "increase_alignment" { target arm*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-1.c new file mode 100644 index 0000000000..3dc5e746cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-1.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +unsigned int out[N*8]; +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 (int dummy) +{ + int i; + unsigned int *pin = &in[0]; + unsigned int *pout = &out[0]; + + for (i = 0; i < N; i++) + { + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + asm volatile ("" ::: "memory"); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + || out[i*8 + 1] != in[i*8 + 1] + || out[i*8 + 2] != in[i*8 + 2] + || out[i*8 + 3] != in[i*8 + 3] + || out[i*8 + 4] != in[i*8 + 4] + || out[i*8 + 5] != in[i*8 + 5] + || out[i*8 + 6] != in[i*8 + 6] + || out[i*8 + 7] != in[i*8 + 7]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (33); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "can't force alignment" "slp1" } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-10.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-10.c new file mode 100644 index 0000000000..697dc4ed83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-10.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int *pin = &in[0]; + unsigned int *pout = &out[1]; + unsigned int a0, a1, a2, a3; + + /* Misaligned store. */ + a0 = *pin++ + 23; + a1 = *pin++ + 142; + a2 = *pin++ + 2; + a3 = *pin++ + 31; + + *pout++ = a0 * x; + *pout++ = a1 * y; + *pout++ = a2 * x; + *pout++ = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[1] != (in[0] + 23) * x + || out[2] != (in[1] + 142) * y + || out[3] != (in[2] + 2) * x + || out[4] != (in[3] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump "unsupported unaligned access" "slp2" { target { ! vect_element_align } } } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_element_align } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-11.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-11.c new file mode 100644 index 0000000000..ff43253425 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-11.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_pack_trunc } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int *pin = &in[0]; + unsigned int *pout = &out[0]; + short a0, a1, a2, a3; + + a0 = *pin++ + 23; + a1 = *pin++ + 142; + a2 = *pin++ + 2; + a3 = *pin++ + 31; + + *pout++ = a0 * x; + *pout++ = a1 * y; + *pout++ = a2 * x; + *pout++ = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect64 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-13.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-13.c new file mode 100644 index 0000000000..fdff76e9f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-13.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[2] + 2; + a3 = in[3] + 31; + + out[0] = a0 * x; + out[1] = a1 * y; + out[2] = a2 * x; + out[3] = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-14.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-14.c new file mode 100644 index 0000000000..62ee757ebe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-14.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + /* Not consecutive load with permutation - supported with building up + the vector from scalars. */ + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[1] + 2; + a3 = in[3] + 31; + + out[0] = a0 * x; + out[1] = a1 * y; + out[2] = a2 * x; + out[3] = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[1] + 2) * x + || out[3] != (in[3] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-15.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-15.c new file mode 100644 index 0000000000..efe7d6a649 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-15.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + if (x > y) + x = x + y; + else + y = x; + + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[2] + 2; + a3 = in[3] + 31; + + out[0] = a0 * x; + out[1] = a1 * y; + out[2] = a2 * x; + out[3] = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-16.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-16.c new file mode 100644 index 0000000000..76430e0915 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-16.c @@ -0,0 +1,71 @@ +/* { dg-require-effective-target vect_int } */ +/* The SLP vectorization happens as part of the if-converted loop body. */ +/* { dg-additional-options "-fdump-tree-vect-details" } */ + +#include +#include "tree-vect.h" + +#define N 32 + +unsigned int out[N*8]; +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned int arr[N] = {0,1,2,3,4,5,6,7}; + +__attribute__ ((noinline)) int +main1 (int dummy) +{ + int i; + unsigned int *pin = &in[0]; + unsigned int *pout = &out[0]; + unsigned int a = 0; + + for (i = 0; i < N; i++) + { + *pout++ = *pin++ + a; + *pout++ = *pin++ + a; + *pout++ = *pin++ + a; + *pout++ = *pin++ + a; + *pout++ = *pin++ + a; + *pout++ = *pin++ + a; + *pout++ = *pin++ + a; + *pout++ = *pin++ + a; + if (arr[i] = i) + a = i; + else + a = 2; + } + + a = 0; + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + a + || out[i*8 + 1] != in[i*8 + 1] + a + || out[i*8 + 2] != in[i*8 + 2] + a + || out[i*8 + 3] != in[i*8 + 3] + a + || out[i*8 + 4] != in[i*8 + 4] + a + || out[i*8 + 5] != in[i*8 + 5] + a + || out[i*8 + 6] != in[i*8 + 6] + a + || out[i*8 + 7] != in[i*8 + 7] + a) + abort (); + + if (arr[i] = i) + a = i; + else + a = 2; + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (33); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-17.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-17.c new file mode 100644 index 0000000000..e7bb06bf81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-17.c @@ -0,0 +1,63 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int b[N]; +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + if (x > y) + x = x + y; + else + y = x; + + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[2] + 2; + a3 = in[3] + 31; + + b[0] = a0; + b[1] = a1; + + out[0] = a0 * x; + out[1] = a1 * y; + out[2] = a2 * x; + out[3] = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y + || b[0] != in[0] + 23 + || b[1] != in[1] + 142) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* We need V2SI vector add support for the b[] vectorization, if we don't + have that we might only see the store vectorized. In any case we have + two subgraph entries. */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target { vect_int_mult && vect64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-18.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-18.c new file mode 100644 index 0000000000..db3f0ba7fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-18.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[2] + 2; + a3 = in[3] + 31; + + out[0] = a0 * x; + out[1] = a1 * y; + out[2] = a2 * x; + out[3] = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != a0 * x + || out[1] != a1 * y + || out[2] != a2 * x + || out[3] != a3 * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-19.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-19.c new file mode 100644 index 0000000000..7e3ccb4847 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-19.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned short out[N]; +unsigned short in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +int i; +__attribute__ ((noinline)) int +main1 () +{ + unsigned short *pin = &in[0]; + unsigned short *pout = &out[0]; + + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + + if (i) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != in[0] + || out[1] != in[1] + || out[2] != in[2] + || out[3] != in[3] + || out[4] != in[4] + || out[5] != in[5] + || out[6] != in[6] + || out[7] != in[7] + || out[8] != in[8]) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-2.c new file mode 100644 index 0000000000..cb1b38dda1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-2.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N*8]; +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 (int dummy) +{ + int i; + unsigned int *pin = &in[0]; + unsigned int *pout = &out[0]; + + for (i = 0; i < N*2; i++) + { + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + + /* Avoid loop vectorization. */ + if (dummy) + __asm__ volatile ("" : : : "memory"); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + || out[i*8 + 1] != in[i*8 + 1] + || out[i*8 + 2] != in[i*8 + 2] + || out[i*8 + 3] != in[i*8 + 3] + || out[i*8 + 4] != in[i*8 + 4] + || out[i*8 + 5] != in[i*8 + 5] + || out[i*8 + 6] != in[i*8 + 6] + || out[i*8 + 7] != in[i*8 + 7]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (33); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-20.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-20.c new file mode 100644 index 0000000000..7b25f91fbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-20.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int b[N]; +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + if (x > y) + x = x + y; + else + y = x; + + /* Two SLP instances in the basic block. */ + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[2] + 2; + a3 = in[3] + 31; + + b[0] = -a0; + b[1] = -a1; + b[2] = -a2; + b[3] = -a3; + + out[0] = a0 * x; + out[1] = a1 * y; + out[2] = a2 * x; + out[3] = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y + || b[0] != -(in[0] + 23) + || b[1] != -(in[1] + 142) + || b[2] != -(in[2] + 2) + || b[3] != -(in[3] + 31)) + + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" { target vect_int_mult } } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target vect_int_mult } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "slp2" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-21.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-21.c new file mode 100644 index 0000000000..45054cd3c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-21.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int b[N]; +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + /* Two SLP instances in one basic block. */ + if (x > y) + x = x + y; + else + y = x; + + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[2] + 2; + a3 = in[3] + 31; + + b[0] = a0; + b[1] = a1; + b[2] = a2; + b[3] = a3; + + out[0] = a0 * x; + out[1] = a1 * y; + out[2] = a2 * x; + out[3] = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y + || b[0] != (in[0] + 23) + || b[1] != (in[1] + 142) + || b[2] != (in[2] + 2) + || b[3] != (in[3] + 31)) + + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "slp2" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-22.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-22.c new file mode 100644 index 0000000000..7bf7e2c4fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-22.c @@ -0,0 +1,67 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int b[N]; +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[2] + 2; + a3 = in[3] + 31; + + if (x > y) + { + b[0] = a0; + b[1] = a1; + b[2] = a2; + b[3] = a3; + } + else + { + out[0] = a0 * (x + 1); + out[1] = a1 * (y + 1); + out[2] = a2 * (x + 1); + out[3] = a3 * (y + 1); + } + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if ((x <= y + && (out[0] != (in[0] + 23) * (x + 1) + || out[1] != (in[1] + 142) * (y + 1) + || out[2] != (in[2] + 2) * (x + 1) + || out[3] != (in[3] + 31) * (y + 1))) + || (x > y + && (b[0] != (in[0] + 23) + || b[1] != (in[1] + 142) + || b[2] != (in[2] + 2) + || b[3] != (in[3] + 31)))) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */ +/* { dg-final { scan-tree-dump "vectorizing SLP node starting from: _\[0-9\]+ = _\[0-9\]+ \\\* a0" "slp2" { target vect_int_mult } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-23.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-23.c new file mode 100644 index 0000000000..ed4a595822 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-23.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +int a[N], b[N]; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + + /* This statement is ignored in vectorization of this basic block. */ + a[x] = b [y]; + + a0 = in[0] + 23; + a1 = in[1] + 142; + a2 = in[2] + 2; + a3 = in[3] + 31; + + out[0] = a0 * x; + out[1] = a1 * y; + out[2] = a2 * x; + out[3] = a3 * y; + + if (x) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-24.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-24.c new file mode 100644 index 0000000000..6de8dd8aff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-24.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define A 3 +#define N 256 + +short src[N], dst[N]; + +void foo (short * __restrict__ dst, short * __restrict__ src, int h, + int stride) +{ + int i; + h /= 8; + for (i = 0; i < h; i++) + { + dst[0] += A*src[0]; + dst[1] += A*src[1]; + dst[2] += A*src[2]; + dst[3] += A*src[3]; + dst[4] += A*src[4]; + dst[5] += A*src[5]; + dst[6] += A*src[6]; + dst[7] += A*src[7]; + dst += stride; + src += stride; + asm volatile ("" ::: "memory"); + } +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + dst[i] = 0; + src[i] = i; + } + + foo (dst, src, N, 8); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (dst[i] != A * i) + abort (); + } + + return 0; +} + +/* Exclude POWER8 (only POWER cpu for which vect_element_align is true) + because loops have vectorized before SLP gets a shot. */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" { target { vect_element_align && { ! powerpc*-*-* } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-25.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-25.c new file mode 100644 index 0000000000..d44d585ff2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-25.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define A 3 +#define B 4 +#define N 256 + +short src[N], dst[N]; + +void foo (short * __restrict__ dst, short * __restrict__ src, int h, + int stride) +{ + int i; + h /= 16; + for (i = 0; i < h; i++) + { + dst[0] += A*src[0] + src[stride]; + dst[1] += A*src[1] + src[1+stride]; + dst[2] += A*src[2] + src[2+stride]; + dst[3] += A*src[3] + src[3+stride]; + dst[4] += A*src[4] + src[4+stride]; + dst[5] += A*src[5] + src[5+stride]; + dst[6] += A*src[6] + src[6+stride]; + dst[7] += A*src[7] + src[7+stride]; + dst += 8; + src += 8; + asm volatile ("" ::: "memory"); + } +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + dst[i] = 0; + src[i] = i; + } + + foo (dst, src, N, 8); + +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (dst[i] != A * i + i + 8) + abort (); + } + + return 0; +} + +/* Exclude POWER8 (only POWER cpu for which vect_element_align is true) + because loops have vectorized before SLP gets a shot. */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" { target { vect_element_align && { ! powerpc*-*-* } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-26.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-26.c new file mode 100644 index 0000000000..fde062e86c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-26.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define A 3 +#define B 4 +#define N 256 + +char src[N], dst[N]; + +void __attribute__((noinline,noclone)) +foo (char * __restrict__ dst, char * __restrict__ src, int h, int stride) +{ + int i; + h /= 16; + for (i = 0; i < h; i++) + { + dst[0] += A*src[0] + src[stride]; + dst[1] += A*src[1] + src[1+stride]; + dst[2] += A*src[2] + src[2+stride]; + dst[3] += A*src[3] + src[3+stride]; + dst[4] += A*src[4] + src[4+stride]; + dst[5] += A*src[5] + src[5+stride]; + dst[6] += A*src[6] + src[6+stride]; + dst[7] += A*src[7] + src[7+stride]; + dst += 8; + src += 8; + asm volatile ("" ::: "memory"); + } +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + dst[i] = 0; + src[i] = i/8; + } + + foo (dst, src, N, 8); + +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (dst[i] != A * src[i] + src[i+8]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" { target { vect64 && vect_hw_misalign } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-27.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-27.c new file mode 100644 index 0000000000..3647dd97c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-27.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define A 3 +#define N 16 + +short src[N], dst[N]; + +void foo (int a) +{ + dst[0] += a*src[0]; + dst[1] += a*src[1]; + dst[2] += a*src[2]; + dst[3] += a*src[3]; + dst[4] += a*src[4]; + dst[5] += a*src[5]; + dst[6] += a*src[6]; + dst[7] += a*src[7]; +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + dst[i] = 0; + src[i] = i; + } + + foo (A); + +#pragma GCC novector + for (i = 0; i < 8; i++) + { + if (dst[i] != A * i) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target { vect_int_mult && { vect_unpack && vect_pack_trunc } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-28.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-28.c new file mode 100644 index 0000000000..c92b687aa4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-28.c @@ -0,0 +1,71 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define A 300 +#define N 16 + +char src[N]; +short dst[N]; +short src1[N], dst1[N]; + +void foo (int a) +{ + dst[0] = (short) (a * (int) src[0]); + dst[1] = (short) (a * (int) src[1]); + dst[2] = (short) (a * (int) src[2]); + dst[3] = (short) (a * (int) src[3]); + dst[4] = (short) (a * (int) src[4]); + dst[5] = (short) (a * (int) src[5]); + dst[6] = (short) (a * (int) src[6]); + dst[7] = (short) (a * (int) src[7]); + dst[8] = (short) (a * (int) src[8]); + dst[9] = (short) (a * (int) src[9]); + dst[10] = (short) (a * (int) src[10]); + dst[11] = (short) (a * (int) src[11]); + dst[12] = (short) (a * (int) src[12]); + dst[13] = (short) (a * (int) src[13]); + dst[14] = (short) (a * (int) src[14]); + dst[15] = (short) (a * (int) src[15]); + + dst1[0] += src1[0]; + dst1[1] += src1[1]; + dst1[2] += src1[2]; + dst1[3] += src1[3]; + dst1[4] += src1[4]; + dst1[5] += src1[5]; + dst1[6] += src1[6]; + dst1[7] += src1[7]; +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + dst[i] = 2; + dst1[i] = 0; + src[i] = i; + src1[i] = i+2; + } + + foo (A); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (dst[i] != A * i + || (i < N/2 && dst1[i] != i + 2)) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target { vect_int_mult && { vect_pack_trunc && vect_unpack } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-29.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-29.c new file mode 100644 index 0000000000..9272f02b2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-29.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define A 3 +#define B 4 +#define N 256 + +short src[N], dst[N]; + +void foo (short * __restrict__ dst, short * __restrict__ src, int h, + int stride) +{ + int i; + h /= 16; + for (i = 0; i < h; i++) + { + dst[0] = A*src[0] + B*src[1]; + dst[1] = A*src[1] + B*src[2]; + dst[2] = A*src[2] + B*src[3]; + dst[3] = A*src[3] + B*src[4]; + dst[4] = A*src[4] + B*src[5]; + dst[5] = A*src[5] + B*src[6]; + dst[6] = A*src[6] + B*src[7]; + dst[7] = A*src[7] + B*src[8]; + dst += stride; + src += stride; + asm volatile ("" ::: "memory"); + } +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + dst[i] = 0; + src[i] = i; + } + + foo (dst, src, N, 8); + +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (dst[i] != A * src[i] + B * src[i+1]) + abort (); + } + + return 0; +} + +/* Exclude POWER8 (only POWER cpu for which vect_element_align is true) + because loops have vectorized before SLP gets a shot. */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" { target { { vect_int_mult && vect_element_align } && { ! powerpc*-*-* } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-3.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-3.c new file mode 100644 index 0000000000..26366706ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-3.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +int i; +__attribute__ ((noinline)) int +main1 () +{ + unsigned int *pin = &in[0]; + unsigned int *pout = &out[0]; + + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + + if (i) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != in[0] + || out[1] != in[1] + || out[2] != in[2] + || out[3] != in[3]) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-30.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-30.c new file mode 100644 index 0000000000..c3d7ae11ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-30.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int a[32]; + +void __attribute__((noinline)) +test1(void) +{ + a[0] = 1; + a[1] = 1; + a[2] = 1; + a[3] = 1; + a[4] = 1; + a[5] = 1; + a[6] = 1; + a[7] = 1; + a[8] = 1; + a[9] = 1; + a[10] = 1; + a[11] = 1; + a[12] = 1; + a[13] = 1; + a[14] = 1; + a[15] = 1; + a[16] = 1; + a[17] = 1; + a[18] = 1; + a[19] = 1; + a[20] = 1; + a[21] = 1; + a[22] = 1; + a[23] = 1; + a[24] = 1; + a[25] = 1; + a[26] = 1; + a[27] = 1; + a[28] = 1; + a[29] = 1; + a[30] = 1; + a[31] = 1; + asm ("" : : : "memory"); + a[21] = 0; +} + +int main() +{ + check_vect (); + test1(); + return a[21]; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-31.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-31.c new file mode 100644 index 0000000000..6a131e7a91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-31.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +typedef double vec __attribute__ ((vector_size (2 * sizeof (double)))); +vec a; + +void f(){ + a[0]=1+2*a[0]*a[0]; + a[1]=1+2*a[1]*a[1]; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-32.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-32.c new file mode 100644 index 0000000000..84cc4370f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-32.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fvect-cost-model=dynamic" } */ + +void bar (int *); +int foo (int *p, int a, int b) +{ + int x[4]; + int tem0, tem1, tem2, tem3; + int sum = 0; + p = __builtin_assume_aligned (p, __BIGGEST_ALIGNMENT__); + tem0 = p[0] + 1 + a; + sum += tem0; + x[0] = tem0; + tem1 = p[1] + 2 + b; + sum += tem1; + x[1] = tem1; + tem2 = p[2] + 3 + b; + sum += tem2; + x[2] = tem2; + tem3 = p[3] + 4 + a; + sum += tem3; + x[3] = tem3; + bar (x); + return sum; +} + +/* { dg-final { scan-tree-dump "vectorization is not profitable" "slp2" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-33.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-33.c new file mode 100644 index 0000000000..74af8dd27a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-33.c @@ -0,0 +1,65 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +extern void abort (void); + +void __attribute__((noinline,noclone)) +test(int *__restrict__ a, int *__restrict__ b) +{ + a[0] = b[0]; + a[1] = b[1]; + a[2] = b[2]; + a[3] = b[3]; + a[5] = 0; + a[6] = 0; + a[7] = 0; + a[8] = 0; +} + +int main() +{ + int a[9]; + int b[4]; + b[0] = 1; + __asm__ volatile (""); + b[1] = 2; + __asm__ volatile (""); + b[2] = 3; + __asm__ volatile (""); + b[3] = 4; + __asm__ volatile (""); + a[4] = 7; + check_vect (); + test(a, b); + if (a[0] != 1) + abort (); + __asm__ volatile (""); + if (a[1] != 2) + abort (); + __asm__ volatile (""); + if (a[2] != 3) + abort (); + __asm__ volatile (""); + if (a[3] != 4) + abort (); + __asm__ volatile (""); + if (a[4] != 7) + abort (); + __asm__ volatile (""); + if (a[5] != 0) + abort (); + __asm__ volatile (""); + if (a[6] != 0) + abort (); + __asm__ volatile (""); + if (a[7] != 0) + abort (); + __asm__ volatile (""); + if (a[8] != 0) + abort (); + __asm__ volatile (""); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "slp2" { target { vect_element_align || vect_hw_misalign } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-34.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-34.c new file mode 100644 index 0000000000..a625c45514 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-34.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +extern void abort (void); + +int a[8], b[8]; + +void __attribute__((noinline,noclone)) +foo(void) +{ + a[0] = b[3]; + a[1] = b[2]; + a[2] = b[1]; + a[3] = b[0]; + a[4] = b[2]; + a[5] = b[3]; + a[6] = b[4]; + a[7] = b[5]; +} + +int main() +{ + int i; + check_vect (); + for (i = 0; i < 8; ++i) + b[i] = i; + foo (); + if (a[0] != 3 || a[1] != 2 || a[2] != 1 || a[3] != 0 + || a[4] != 2 || a[5] != 3 || a[6] != 4 || a[7] != 5) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" { target vect_perm } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-35.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-35.c new file mode 100644 index 0000000000..81b228b304 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-35.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void foo (int * __restrict__ p, short * __restrict__ q) +{ + p[0] = q[0] + 1; + p[1] = q[1] + 1; + p[2] = q[2] + 1; + p[3] = q[3] + 1; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" { target vect_hw_misalign } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-36.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-36.c new file mode 100644 index 0000000000..fbcedd0a15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-36.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +extern void abort (void); + +int a[8], b[8]; + +void __attribute__((noinline,noclone)) +foo(void) +{ + a[0] = b[0]; + a[1] = b[0]; + a[2] = b[3]; + a[3] = b[3]; + a[4] = b[4]; + a[5] = b[7]; + a[6] = b[4]; + a[7] = b[7]; +} + +int main() +{ + int i; + check_vect (); + for (i = 0; i < 8; ++i) + b[i] = i; + foo (); + if (a[0] != 0 || a[1] != 0 || a[2] != 3 || a[3] != 3 + || a[4] != 4 || a[5] != 7 || a[6] != 4 || a[7] != 7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" { target vect_perm } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-37.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-37.c new file mode 100644 index 0000000000..dbbba87985 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-37.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +extern void abort (void); + +int a[16]; +int b[4]; + +void __attribute__((noinline)) +foo (void) +{ + b[0] = a[0]; + b[1] = a[4]; + b[2] = a[8]; + b[3] = a[12]; +} + +int main() +{ + int i; + check_vect (); + for (i = 0; i < 16; ++i) + { + a[i] = i; + __asm__ volatile (""); + } + foo (); + if (b[0] != 0 || b[1] != 4 || b[2] != 8 || b[3] != 12) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-38.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-38.c new file mode 100644 index 0000000000..a7bc032252 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-38.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +extern void abort (void); + +int a[8], b[8]; +int x; + +void __attribute__((noinline,noclone)) +bar (void) +{ + x = 1; +} + +void __attribute__((noinline,noclone)) +foo(void) +{ + a[0] = b[0]; + a[1] = b[0]; + a[2] = b[3]; + a[3] = b[3]; + bar (); + a[4] = b[4]; + a[5] = b[7]; + a[6] = b[4]; + a[7] = b[7]; +} + +int main() +{ + int i; + check_vect (); + for (i = 0; i < 8; ++i) + b[i] = i; + foo (); + if (a[0] != 0 || a[1] != 0 || a[2] != 3 || a[3] != 3 + || a[4] != 4 || a[5] != 7 || a[6] != 4 || a[7] != 7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" { target vect_perm } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-39.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-39.c new file mode 100644 index 0000000000..f05ce8f284 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-39.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double x[1024]; + +void foo (double *p) +{ + x[0] = 1.; + x[1] = 2.; + *p = 7.; // aliasing store + x[0] = x[0] + 1; + x[1] = x[1] + 1; + *p = 8.; // aliasing store + x[1] = x[1] + 1; + x[0] = x[0] + 1; +} + +/* See that we vectorize three SLP instances. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "slp2" { target { ! { s390*-*-* riscv*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 5 "slp2" { target { s390*-*-* riscv*-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-4.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-4.c new file mode 100644 index 0000000000..9e36963c91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-4.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned short out[N]; +unsigned short in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +int i; +__attribute__ ((noinline)) int +main1 () +{ + unsigned short *pin = &in[0]; + unsigned short *pout = &out[0]; + + *pout++ = *pin++; + *pout++ = *pin++; + + if (i) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != in[0] + || out[1] != in[1]) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-40.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-40.c new file mode 100644 index 0000000000..66fb4e07f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-40.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fvect-cost-model=dynamic" } */ +/* { dg-require-effective-target vect_char_add } */ + +char g_d[1024], g_s1[1024], g_s2[1024]; +void foo(void) +{ + char *d = g_d, *s1 = g_s1, *s2 = g_s2; + + for ( int y = 0; y < 128; y++ ) + { + d[0 ] = s1[0 ] + s2[0 ]; + d[1 ] = s1[1 ] + s2[1 ]; + d[2 ] = s1[2 ] + s2[2 ]; + d[3 ] = s1[3 ] + s2[3 ]; + d[4 ] = s1[4 ] + s2[4 ]; + d[5 ] = s1[5 ] + s2[5 ]; + d[6 ] = s1[6 ] + s2[6 ]; + d[7 ] = s1[7 ] + s2[7 ]; + d[8 ] = s1[8 ] + s2[8 ]; + d[9 ] = s1[9 ] + s2[9 ]; + d[10] = s1[10] + s2[10]; + d[11] = s1[11] + s2[11]; + d[12] = s1[12] + s2[12]; + d[13] = s1[13] + s2[13]; + d[14] = s1[14] + s2[14]; + d[15] = s1[15] + s2[15]; + d += 16; + } +} + +/* See that we vectorize an SLP instance. */ +/* { dg-final { scan-tree-dump "Analyzing vectorizable constructor" "slp1" } } */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-41.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-41.c new file mode 100644 index 0000000000..72245115f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-41.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_int } */ + +#define ARR_SIZE 1000 + +void __attribute__((optimize (0))) +foo (int *a, int *b) +{ + int i; + for (i = 0; i < (ARR_SIZE - 2); ++i) + a[i] = b[0] + b[1] + b[i+1] + b[i+2]; +} + +/* Disable pre-slp FRE to avoid unexpected SLP on the epilogue + of the 1st loop. */ +void __attribute__((optimize("-fno-tree-fre"))) +bar (int *a, int *b) +{ + int i; + for (i = 0; i < (ARR_SIZE - 2); ++i) + { + a[i] = b[0]; + } + for (i = 0; i < (ARR_SIZE - 2); ++i) + { + a[i] = a[i] + b[1]; + } + for (i = 0; i < (ARR_SIZE - 2); ++i) + { + a[i] = a[i] + b[i+1]; + } + for (i = 0; i < (ARR_SIZE - 2); ++i) + { + a[i] = a[i] + b[i+2]; + } +} + +int main () +{ + int a1[ARR_SIZE]; + int a2[ARR_SIZE]; + int b[ARR_SIZE]; + int i; + + for (i = 0; i < ARR_SIZE; i++) + { + a1[i] = 0; + a2[i] = 0; + b[i] = i; + } + + foo (a1, b); + bar (a2, b); + + for (i = 0; i < ARR_SIZE; i++) + if (a1[i] != a2[i]) + return 1; + + return 0; + +} +/* { dg-final { scan-tree-dump-not "vectorizing stmts using SLP" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-42.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-42.c new file mode 100644 index 0000000000..69fd096849 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-42.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include "tree-vect.h" + +#define ARR_SIZE 1024 + +void __attribute__((noipa)) +foo (int a[][ARR_SIZE], int *b) +{ + int i; + for (i = 0; i < ARR_SIZE; ++i) + { + a[0][i] += b[0]; + a[1][i] += b[1]; + a[2][i] += b[2]; + a[3][i] += b[3]; + } +} + +int +main () +{ + int a[4][ARR_SIZE]; + int b[4]; + + check_vect (); + + for (int i = 0; i < 4; ++i) + { + b[i] = 20 * i; + for (int j = 0; j < ARR_SIZE; ++j) + a[i][j] = (i + 1) * ARR_SIZE - j; + } + + foo (a, b); + + for (int i = 0; i < 4; ++i) +#pragma GCC novector + for (int j = 0; j < ARR_SIZE; ++j) + if (a[i][j] != (i + 1) * ARR_SIZE - j + 20 * i) + __builtin_abort (); + + return 0; + +} + +/* See that we do not try to vectorize the uniform CTORs. */ +/* { dg-final { scan-tree-dump-not "Analyzing vectorizable constructor" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-43.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-43.c new file mode 100644 index 0000000000..dad2d24262 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-43.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +void +f (int *restrict x, short *restrict y) +{ + x[0] = x[0] == 1 & y[0] == 2; + x[1] = x[1] == 1 & y[1] == 2; + x[2] = x[2] == 1 & y[2] == 2; + x[3] = x[3] == 1 & y[3] == 2; + x[4] = x[4] == 1 & y[4] == 2; + x[5] = x[5] == 1 & y[5] == 2; + x[6] = x[6] == 1 & y[6] == 2; + x[7] = x[7] == 1 & y[7] == 2; +} + +/* { dg-final { scan-tree-dump-not "mixed mask and nonmask" "slp2" } } */ +/* { dg-final { scan-tree-dump-not "vector operands from scalars" "slp2" { target { { vect_int && vect_bool_cmp } && { vect_unpack && vect_hw_misalign } } xfail { vect_variable_length && { ! vect256 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-44.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-44.c new file mode 100644 index 0000000000..a342f05615 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-44.c @@ -0,0 +1,39 @@ +typedef struct { + unsigned long a; + unsigned long b; + unsigned long c; +} data_o; +typedef struct { + unsigned long c; + unsigned long gap1; + unsigned long b; + unsigned long gap2; + unsigned long a; + unsigned long x; +} data_i; + +volatile unsigned long gx; +void __attribute__((noipa)) +bar(unsigned long x) +{ + gx = x; +} + +void __attribute__((noipa)) +foo(data_o *o, data_i *i) +{ + o->a = i->a; + o->b = i->b; + o->c = i->c; + bar (i->x); +} + +int main() +{ + unsigned long data[9]; + if ((__UINTPTR_TYPE__)data & 15 != 0) + foo ((data_o *)&data[6], (data_i *)data); + else + foo ((data_o *)data, (data_i *)&data[3]); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-45.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-45.c new file mode 100644 index 0000000000..d24ef2a038 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-45.c @@ -0,0 +1,36 @@ +/* { dg-require-effective-target vect_double } */ + +#include "tree-vect.h" + +extern void abort (void); + +double a[8], b[8]; +int x; + +void __attribute__((noinline,noclone)) +bar (void) +{ + x = 1; +} + +void __attribute__((noinline,noclone)) +foo(int i) +{ + double tem1 = a[2*i]; + double tem2 = 2*a[2*i+1]; + bar (); + b[2*i] = 2*tem1; + b[2*i+1] = tem2; +} + +int main() +{ + int i; + check_vect (); + for (i = 0; i < 8; ++i) + b[i] = i; + foo (2); + return 0; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-46.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-46.c new file mode 100644 index 0000000000..4eceea44ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-46.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +int a[4], b[4]; +int foo () +{ + int tem0 = a[0] + b[0]; + int temx = tem0 * 17; /* this fails without a real need */ + int tem1 = a[1] + b[1]; + int tem2 = a[2] + b[2]; + int tem3 = a[3] + b[3]; + int temy = tem3 * 13; + a[0] = tem0; + a[1] = tem1; + a[2] = tem2; + a[3] = tem3; + return temx / temy; +} + +/* We should extract the live lane from the vectorized add rather than + keeping the original scalar add. + ??? Because of a too conservative check we fail for temx here. */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ +/* { dg-final { scan-tree-dump "extracting lane for live stmt" "slp2" } } */ +/* { dg-final { scan-tree-dump-times "extracting lane for live stmt" 2 "slp2" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-not "tem3_\[0-9\]\+ = " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "tem0_\[0-9\]\+ = " "optimized" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-47.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-47.c new file mode 100644 index 0000000000..9583b09cfb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-47.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +int bar(); +int foo (int *a, int b, int c) +{ + int tem0 = bar (); + int tem1 = tem0 + b; + int tem3 = tem1 + c; + a[0] = tem3; + a[1] = tem3 + 1; + a[2] = tem3 + 2; + a[3] = tem3 + 3; + return tem1; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-48.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-48.c new file mode 100644 index 0000000000..dfae6177b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-48.c @@ -0,0 +1,55 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fgimple -fdump-tree-optimized" } */ +/* { dg-require-effective-target vect_double } */ + +double a[2]; + +void __GIMPLE (ssa,startwith ("fix_loops")) +foo (double x) +{ + double tem2; + double tem1; + double _1; + double _2; + double _3; + double _4; + + __BB(2): + _1 = a[0]; + _2 = x_6(D) * 3.0e+0; + tem1_7 = _1 + _2; + _3 = x_6(D) + 1.0e+0; + _4 = a[1]; + tem2_8 = _4 + _3; + a[0] = tem1_7; + a[1] = tem2_8; + return; +} + +void __GIMPLE (ssa,startwith ("fix_loops")) +bar (double x) +{ + double tem2; + double tem1; + double _1; + double _2; + double _3; + double _4; + + __BB(2): + _1 = a[0]; + _2 = x_6(D) * 3.0e+0; + tem1_7 = _1 + _2; + _3 = x_6(D) + 1.0e+0; + _4 = a[1]; + /* Once with operands swapped. */ + tem2_8 = _3 + _4; + a[0] = tem1_7; + a[1] = tem2_8; + return; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" } } */ +/* We want to vectorize as { a[0], a[1] } + { x*3, x+1 } and thus + elide one add in each function. */ +/* { dg-final { scan-tree-dump-times " \\+ " 4 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-49.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-49.c new file mode 100644 index 0000000000..e7101fcff4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-49.c @@ -0,0 +1,28 @@ +/* This checks that vectorized constructors have the correct ordering. */ +/* { dg-require-effective-target vect_int } */ + +typedef int V __attribute__((__vector_size__(16))); + +__attribute__((__noipa__)) void +foo (unsigned int x, V *y) +{ + unsigned int a[4] = { x + 0, x + 2, x + 4, x + 6 }; + for (unsigned int i = 0; i < 3; ++i) + if (a[i] == 1234) + a[i]--; + *y = (V) { a[3], a[2], a[1], a[0] }; +} + +int +main () +{ + V b; + foo (0, &b); + if (b[0] != 6 || b[1] != 4 || b[2] != 2 || b[3] != 0) + __builtin_abort (); + return 0; +} + +/* See that we vectorize an SLP instance. */ +/* { dg-final { scan-tree-dump "Analyzing vectorizable constructor" "slp1" } } */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-5.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-5.c new file mode 100644 index 0000000000..bb78e1b29e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-5.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned short out[N]; +unsigned short in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + unsigned short *pin = &in[0]; + unsigned short *pout = &out[0]; + + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + + /* Check results. */ + if (out[0] != in[0] + || out[1] != in[1] + || out[2] != in[2] + || out[3] != in[3] + || out[4] != in[4] + || out[5] != in[5] + || out[6] != in[6] + || out[7] != in[7]) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-50.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-50.c new file mode 100644 index 0000000000..80216be4eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-50.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double a[2]; +double b[2]; +double c[2]; +double d[2]; +double e[2]; +void foo(double x) +{ + double tembc0 = b[1] + c[1]; + double tembc1 = b[0] + c[0]; + double temde0 = d[0] + e[1]; + double temde1 = d[1] + e[0]; + a[0] = tembc0 + temde0; + a[1] = tembc1 + temde1; +} + +/* We should common the permutation on the tembc{0,1} operands. */ +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 2 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-51.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-51.c new file mode 100644 index 0000000000..1481018428 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-51.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double a[2]; +double b[2]; +double c[2]; +double e[2]; +void foo(double x) +{ + double tembc0 = b[1] + c[1]; + double tembc1 = b[0] + c[0]; + double temde0 = 5 + e[1]; + double temde1 = 11 + e[0]; + a[0] = tembc0 + temde0; + a[1] = tembc1 + temde1; +} + +/* We should common the permutations on the tembc{0,1} and temde{0,1} + operands. */ +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\r\\n\]* VEC_PERM_EXPR" 1 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-52.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-52.c new file mode 100644 index 0000000000..5194af8cc4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-52.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +int a, e; +void g(float); +typedef struct { + float b, c; +} d; +d f; +void h(double i, double j) { + if (a && e) + return; + f.b = j; + f.c = i; + g(i); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-53.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-53.c new file mode 100644 index 0000000000..f3b5f31744 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-53.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double a[2], b[2]; + +void foo(double x, double y) +{ + double breakme1 = y + 3.; + double a1 = b[1] + 2.; + double breakme0 = x; + double a0 = b[0] + 1.; + a[0] = a0 * breakme0; + a[1] = a1 * breakme1; +} + +/* We should vectorize the SLP opportunity starting from the + grouped store to a[] including the load from b[] at the + leaf even though the multiplication requires another + vector invariant to be built. */ +/* { dg-final { scan-tree-dump "transform load" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-54.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-54.c new file mode 100644 index 0000000000..d05ce33310 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-54.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double a[2], b[2], c[2]; + +void foo(int flag) +{ + double tem1, tem2; + if (flag) + { + tem1 = a[0]; + tem2 = a[1]; + } + else + { + tem1 = b[0]; + tem2 = b[1]; + } + c[0] = tem1; + c[1] = tem2; +} + +/* { dg-final { scan-tree-dump-times "transform load" 2 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-55.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-55.c new file mode 100644 index 0000000000..57a042b0ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-55.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +typedef struct { + int a; + int b; + int c; + int d; +} e; +e *f; +int g; +void h() { + e *i; + if (g) { + i->c = f[g].b; + i->d = f[g].a; + } else + i->c = i->d = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-56.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-56.c new file mode 100644 index 0000000000..90d1751249 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-56.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +typedef struct { + double a, b; +} c; +int d, e; +int i(void); +void h(c, c); +void f() { + c a, g; + do { + a.a = e ?: g.a; + a.b = g.b + d; + h(g, a); + g = a; + } while (i()); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-57.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-57.c new file mode 100644 index 0000000000..6f13507fd6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-57.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ffast-math" } */ +/* { dg-require-effective-target vect_float } */ + +float *a; +typedef struct { + int c; + float bbmax[3]; +} d; +d e; +int f[3]; +int g, h, i, j; +float k, k; +void l() +{ + for (unsigned z = 0; z < 2048; ++z) { + { + j = e.bbmax[1] > k ? e.bbmax[1] : k; + } + e.bbmax[1] = j; + { i = e.bbmax[2] > k ? e.bbmax[2] : k; } + e.bbmax[2] = i; + f[2] = a[2]; + { + float b; + h = e.bbmax[1] > b ? e.bbmax[1] : b; + } + e.bbmax[1] = h; + { + float b; + g = e.bbmax[2] > b ? e.bbmax[2] : b; + } + e.bbmax[2] = g; + } +} + +/* { dg-final { scan-tree-dump-times "transform load" 1 "slp1" { target { { x86_64-*-* i?86-*-* } && lp64 } } } } */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp1" { target { { x86_64-*-* i?86-*-* } && lp64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-58.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-58.c new file mode 100644 index 0000000000..5a3d3b75aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-58.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double x[1024]; +void bar (void); + +void foo (void) +{ + double tem1 = x[0]; + double tem2 = x[1]; + for (int i = 0; i < 511; ++i) + { + x[2*i] = tem1; + x[2*i+1] = tem2; + bar (); + tem1 = x[2*(i+1)]; + tem2 = x[2*(i+1)+1]; + } +} + +/* We should be able to vectorize the cycle in one SLP attempt including + both load groups. */ +/* { dg-final { scan-tree-dump-times "transform load" 2 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-59.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-59.c new file mode 100644 index 0000000000..815b44e1f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-59.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "-fdump-tree-loopdone" } */ + +double x[1024]; +void bar (void); + +void foo (void) +{ + double tem1 = x[0]; + double tem2 = x[1]; + for (int i = 0; i < 511; ++i) + { + x[2*i] = tem2; + x[2*i+1] = tem1; + bar (); + tem1 = x[2*(i+1)]; + tem2 = x[2*(i+1)+1]; + } +} + +/* We should be able to vectorize the cycle in one SLP attempt including + both load groups and do only one permutation. */ +/* { dg-final { scan-tree-dump-times "transform load" 2 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 1 "loopdone" } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-6.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-6.c new file mode 100644 index 0000000000..fa3e76dbcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-6.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int *pin = &in[0]; + unsigned int *pout = &out[0]; + unsigned int a0, a1, a2, a3; + + a0 = *pin++ + 23; + a1 = *pin++ + 142; + a2 = *pin++ + 2; + a3 = *pin++ + 31; + + *pout++ = a0 * x; + *pout++ = a1 * y; + *pout++ = a2 * x; + *pout++ = a3 * y; + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-60.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-60.c new file mode 100644 index 0000000000..52643bfd75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-60.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +enum { a = 1, b }; +float *c, *e; +float d, h; +int f, g; +void i() +{ + float j = h; + for (; g;) + for (; f; f++) + { + c[a] = j * d; + c[b] = h * d; + j = 0; + h = e[2]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-61.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-61.c new file mode 100644 index 0000000000..3323a2bb2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-61.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +struct a { + enum { b, c } d; + unsigned e; + unsigned f; +}; +void j(struct a *a, int i, int h) +{ + unsigned f = a->f; + switch (a->d) + while (1) + { + if (i) + { + case b: + if (h) + goto k; + } + else + f = 0; + case c:; + } +k: + a->e = a->f = f; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-62.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-62.c new file mode 100644 index 0000000000..84ee04c101 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-62.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +typedef struct { + char a; + int b[]; +} c; +int d, f; +c e; +void g() { + int h, i, j; + for (; i;) + switch (i) + case 4: { + h = (__UINTPTR_TYPE__)g >= 3; + for (; h; h -= 1) + if (d) + j = f; + } + for (; i < 3; i++) + e.b[i] = j; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-63.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-63.c new file mode 100644 index 0000000000..6519c9752f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-63.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +struct { + unsigned a; + unsigned c; +} d; +int e, g; +void h(unsigned b) { + unsigned a, c; + while (e) { + if (b) { + ++e; + continue; + } + c = g; + if (g) + a |= 10; + } + d.a = a; + d.c = c; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-64.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-64.c new file mode 100644 index 0000000000..dcb6a1455c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-64.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +enum { a, b }; +double *c, *e; +int d, f; +void g() { + for (;;) { + c[a] = c[b] = d * e[b]; + f = d -= f; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-65.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-65.c new file mode 100644 index 0000000000..ec1707be9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-65.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */ + +int *a; +int b, c, d, e; +void f() { + int g; + for (;;) + for (; b;) + if (d) + for (; c;) + if (g) + e += a[1] = a[2] = e; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-66.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-66.c new file mode 100644 index 0000000000..b59a2cc724 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-66.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +typedef struct { + double a, b; +} c; +typedef struct { + c d; + long coordinates; +} e; +int f; +c g; +e h; +void k(int); +int n(); +void j() { int i; k(i); } +void k(int l) { + double a; + int b; + c m[4]; + long i; + for (; l;) + do { + g.a = b ?: a; + m[3] = g; + if (f) + m[0] = m[1] = m[3]; + i = 0; + for (; i < 4; i++) + (&h + i)->d = m[i]; + } while (n()); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-67.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-67.c new file mode 100644 index 0000000000..ff959c7ac9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-67.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +float a[6]; + +void foo (float x, float y) +{ + a[0] = 1.; + a[1] = 2.; + a[2] = 3.; + a[3] = 4.; + a[4] = 5.; + a[5] = x + y; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-68.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-68.c new file mode 100644 index 0000000000..2dd3d8ee90 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-68.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "-mavx" { target avx } } */ + +double x[10], y[6], z[4]; + +void foo () +{ + x[0] = y[0]; + x[1] = y[1]; + x[2] = y[2]; + x[3] = y[3]; + x[4] = y[4]; + x[5] = y[5]; + x[6] = z[0] + 1.; + x[7] = z[1] + 1.; + x[8] = z[2] + 1.; + x[9] = z[3] + 1.; +} + +/* We want to have the store group split into 4, 2, 4 when using 32byte vectors. + Unfortunately it does not work when 64-byte vectors are available. */ +/* { dg-final { scan-tree-dump-not "from scalars" "slp2" { xfail vect512 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-69.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-69.c new file mode 100644 index 0000000000..16c0d7428c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-69.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_condition } */ + +_Bool arr[16]; + +void foo(char *q) +{ + char *p = __builtin_assume_aligned (q, 16); + _Bool b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15; + b0 = p[0] != 0; + b1 = p[1] != 0; + b2 = p[2] != 0; + b3 = p[3] != 0; + b4 = p[4] != 0; + b5 = p[5] != 0; + b6 = p[6] != 0; + b7 = p[7] != 0; + b8 = p[8] != 0; + b9 = p[9] != 0; + b10 = p[10] != 0; + b11 = p[11] != 0; + b12 = p[12] != 0; + b13 = p[13] != 0; + b14 = p[14] != 0; + b15 = p[15] != 0; + arr[0] = b0; + arr[1] = b1; + arr[2] = b2; + arr[3] = b3; + arr[4] = b4; + arr[5] = b5; + arr[6] = b6; + arr[7] = b7; + arr[8] = b8; + arr[9] = b9; + arr[10] = b10; + arr[11] = b11; + arr[12] = b12; + arr[13] = b13; + arr[14] = b14; + arr[15] = b15; +} + +/* { dg-final { scan-tree-dump "transform load" "slp2" } } */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-7.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-7.c new file mode 100644 index 0000000000..ebe8189d31 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-7.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int *pin = &in[0]; + unsigned int *pout = &out[0]; + unsigned int a0, a1, a2, a3; + + /* Non isomorphic, even 64-bit subgroups. */ + a0 = *pin++ + 23; + a1 = *pin++ * 142; + a2 = *pin++ + 2; + a3 = *pin++ * 31; + + /* But we can still vectorize the multiplication or the store. */ + *pout++ = a0 * x; + *pout++ = a1 * y; + *pout++ = a2 * x; + *pout++ = a3 * y; + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] * 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] * 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-70.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-70.c new file mode 100644 index 0000000000..0eb70112bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-70.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mavx512vl -mavx512vpopcntdq" { target avx512vpopcntdq } } */ + +typedef unsigned uv4si __attribute__((vector_size(16))); + +uv4si __attribute__((noinline)) +vpopctf (uv4si a) +{ + uv4si r; + r[2] = __builtin_popcount (a[2]); + r[1] = __builtin_popcount (a[1]); + r[0] = __builtin_popcount (a[0]); + r[3] = __builtin_popcount (a[3]); + return r; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" { target avx512vpopcntdq } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-71.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-71.c new file mode 100644 index 0000000000..4c8a418e39 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-71.c @@ -0,0 +1,30 @@ +#include "tree-vect.h" + +int a[4], b[4]; + +void __attribute__((noipa)) +foo(int x, int y) +{ + int tem0 = x + 1; + int tem1 = y + 2; + int tem2 = x + 3; + int tem3 = y + 4; + a[0] = tem0 + b[1]; + a[1] = tem1 + b[0]; + a[2] = tem2 + b[2]; + a[3] = tem3 + b[3]; +} + +int main() +{ + check_vect (); + + b[0] = 10; + b[1] = 14; + b[2] = 18; + b[3] = 22; + foo (-1, -3); + if (a[0] != 14 || a[1] != 9 || a[2] != 20 || a[3] != 23) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-72.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-72.c new file mode 100644 index 0000000000..3f5bfc2445 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-72.c @@ -0,0 +1,27 @@ +#include "tree-vect.h" + +double x[2], y[2], z[2], w[2]; + +void __attribute__((noipa)) foo () +{ + double tem0 = x[1] + y[1]; + double tem1 = x[0] - y[0]; + double tem2 = z[1] * tem0; + double tem3 = z[0] * tem1; + z[0] = tem2 - w[0]; + z[1] = tem3 + w[1]; +} + +int main() +{ + check_vect (); + + x[0] = 1.; x[1] = 2.; + y[0] = 7.; y[1] = -5.; + z[0] = 2.; z[1] = 3.; + w[0] = 9.; w[1] = -5.; + foo (); + if (z[0] != -18. || z[1] != -17.) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-73.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-73.c new file mode 100644 index 0000000000..96c6cdde4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-73.c @@ -0,0 +1,27 @@ +#include "tree-vect.h" + +double x[2], y[2], z[2], w[2]; + +void __attribute__((noipa)) foo () +{ + double tem0 = x[1] + y[1]; + double tem1 = x[0] - y[0]; + double tem2 = z[1] * tem0; + double tem3 = z[0] * tem1; + z[0] = tem2 - w[1]; + z[1] = tem3 + w[0]; +} + +int main() +{ + check_vect (); + + x[0] = 1.; x[1] = 2.; + y[0] = 7.; y[1] = -5.; + z[0] = 2.; z[1] = 3.; + w[0] = 9.; w[1] = -5.; + foo (); + if (z[0] != -4. || z[1] != -3.) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-74.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-74.c new file mode 100644 index 0000000000..49d787c198 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-74.c @@ -0,0 +1,30 @@ +/* { dg-require-effective-target vect_double } */ + +#include "tree-vect.h" + +double a[2], b[2], c[2]; + +void __attribute__((noipa)) foo () +{ + double tem0 = a[1] + b[1]; + double tem1 = a[0] - b[0]; + c[0] = 2. * tem0; + c[1] = 5. * tem1; +} + +int main() +{ + check_vect (); + + a[0] = 1.; a[1] = 3.; + b[0] = -5.; b[1] = 13.; + foo (); + if (c[0] != 32. || c[1] != 30.) + __builtin_abort (); + return 0; +} + +/* We'd like to see at most one VEC_PERM_EXPR, not one for a blend + and one for a permute materialized somewhere else. But addsub + pattern recog can likely get in the way here. */ +/* { dg-final { scan-tree-dump-times " \[^ \]\+ = VEC_PERM_EXPR" 1 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-75.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-75.c new file mode 100644 index 0000000000..1abac136f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-75.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-ffast-math" } */ +/* { dg-additional-options "-msse2 -mfpmath=sse" { target { x86_64-*-* i?86-*-* } } } */ + +float x[4]; + +float test1 (float a) +{ + return x[0] + x[2] + x[1] + x[3] + a; +} + +float test2 (void) +{ + return x[3] + x[2] + x[1] + 1.f + x[0]; +} + +float test3 (float a) +{ + return x[0] + a + x[2] + x[1] + x[3] + 1.f; +} + +/* We currently require a .REDUC_PLUS direct internal function but do not + have a dejagnu target for this. */ +/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 3 "slp2" { target { x86_64-*-* i?86-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8.c new file mode 100644 index 0000000000..b653469ac4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y, unsigned int *pin, unsigned int *pout) +{ + int i; + unsigned int a0, a1, a2, a3; + + /* pin and pout may alias. But since all the loads are before the first + store the basic block is vectorizable. */ + a0 = *pin++ + 23; + a1 = *pin++ + 142; + a2 = *pin++ + 2; + a3 = *pin++ + 31; + + *pout++ = a0 * x; + *pout++ = a1 * y; + *pout++ = a2 * x; + *pout++ = a3 * y; + + if (i) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3, &in[0], &out[0]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_hw_misalign } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8a.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8a.c new file mode 100644 index 0000000000..381593b450 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8a.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y, unsigned int *pin, unsigned int *pout) +{ + int i; + unsigned int a0, a1, a2, a3; + + /* pin and pout may alias, and loads and stores are mixed. The basic block + cannot be vectorized. */ + a0 = *pin++ + 23; + *pout++ = a0 * x; + a1 = *pin++ + 142; + *pout++ = a1 * y; + a2 = *pin++ + 2; + *pout++ = a2 * x; + a3 = *pin++ + 31; + *pout++ = a3 * y; + + if (i) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3, &in[0], &out[0]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 0 "slp2" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8b.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8b.c new file mode 100644 index 0000000000..03a47fdc78 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-8b.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int a0, a1, a2, a3; + unsigned int *pin = &in[0]; + unsigned int *pout = &out[0]; + + /* pin and pout are different, so despite the fact that loads and stores + are mixed the basic block is vectorizable. */ + a0 = *pin++ + 23; + *pout++ = a0 * x; + a1 = *pin++ + 142; + *pout++ = a1 * y; + a2 = *pin++ + 2; + *pout++ = a2 * x; + a3 = *pin++ + 31; + *pout++ = a3 * y; + + if (i) + __asm__ volatile ("" : : : "memory"); + + /* Check results. */ + if (out[0] != (in[0] + 23) * x + || out[1] != (in[1] + 142) * y + || out[2] != (in[2] + 2) * x + || out[3] != (in[3] + 31) * y) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_hw_misalign } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-9.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-9.c new file mode 100644 index 0000000000..2a42411afe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-9.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int *pin = &in[1]; + unsigned int *pout = &out[0]; + unsigned int a0, a1, a2, a3; + + /* Misaligned load. */ + a0 = *pin++ + 23; + a1 = *pin++ + 142; + a2 = *pin++ + 2; + a3 = *pin++ + 31; + + *pout++ = a0 * x; + *pout++ = a1 * y; + *pout++ = a2 * x; + *pout++ = a3 * y; + + /* Check results. */ + if (out[0] != (in[1] + 23) * x + || out[1] != (in[2] + 142) * y + || out[2] != (in[3] + 2) * x + || out[3] != (in[4] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "transform load" 1 "slp2" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-bool-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-bool-1.c new file mode 100644 index 0000000000..bf39b21b4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-bool-1.c @@ -0,0 +1,44 @@ +#include "tree-vect.h" + +void __attribute__ ((noipa)) +f1 (_Bool *x, unsigned short *y) +{ + x[0] = (y[0] == 1); + x[1] = (y[1] == 1); +} + +void __attribute__ ((noipa)) +f2 (_Bool *x, unsigned short *y) +{ + x[0] = (y[0] == 1); + x[1] = (y[1] == 1); + x[2] = (y[2] == 1); + x[3] = (y[3] == 1); + x[4] = (y[4] == 1); + x[5] = (y[5] == 1); + x[6] = (y[6] == 1); + x[7] = (y[7] == 1); +} + +_Bool x[8]; +unsigned short y[8] = { 11, 1, 9, 5, 1, 44, 1, 1 }; + +int +main (void) +{ + check_vect (); + + f1 (x, y); + + if (x[0] || !x[1]) + __builtin_abort (); + + x[1] = 0; + + f2 (x, y); + + if (x[0] || !x[1] || x[2] | x[3] || !x[4] || x[5] || !x[6] || !x[7]) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-cond-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-cond-1.c new file mode 100644 index 0000000000..8faf6b6e3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-cond-1.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-additional-options "-fdump-tree-vect-details" } */ + +#include "tree-vect.h" + +#define N 128 + +__attribute__((noinline, noclone)) void +foo (int *a, int stride) +{ + int i; + + for (i = 0; i < N/stride; i++, a += stride) + { + a[0] = a[0] ? 1 : 5; + a[1] = a[1] ? 2 : 6; + a[2] = a[2] ? 3 : 7; + a[3] = a[3] ? 4 : 8; + } +} + + +int a[N]; +int main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = i; + asm volatile ("" ::: "memory"); + } + + foo (a, 4); + +#pragma GCC novector + for (i = 1; i < N; i++) + if (a[i] != i%4 + 1) + abort (); + + if (a[0] != 5) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump {(no need for alias check [^\n]* when VF is 1|no alias between [^\n]* when [^\n]* is outside \(-16, 16\))} "vect" { target vect_element_align } } } */ +/* { dg-final { scan-tree-dump-times "loop vectorized" 1 "vect" { target { vect_element_align && { ! { amdgcn-*-* } } } } } } */ +/* { dg-final { scan-tree-dump-times "loop vectorized" 2 "vect" { target { amdgcn-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-div-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-div-1.c new file mode 100644 index 0000000000..1eea9233b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-div-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-msve-vector-bits=256" { target aarch64_sve } } */ + +int x[8]; + +void +f (void) +{ + x[0] /= 2; + x[1] /= 3; + x[2] /= 4; + x[3] /= 5; + x[4] /= 6; + x[5] /= 7; + x[6] /= 8; + x[7] /= 9; +} + +/* We can vectorize the store from a CTOR built from scalar division + results but ideally we'd like to see vectorizing the load and the + division as well. */ +/* { dg-final { scan-tree-dump "transform load" "slp2" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-div-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-div-2.c new file mode 100644 index 0000000000..dd17e8c1c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-div-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +int x[4], y[4], z[4]; + +void +f (void) +{ + x[0] += y[0] / z[0] * 2; + x[1] += y[1] / z[1] * 2; + x[2] += y[2] / z[2] * 2; + x[3] += y[3] / z[3] * 2; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-1.c new file mode 100644 index 0000000000..c1d4ba3ecb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a[4], b[4], c[4], d[4]; + +void f1() +{ + a[0] = (b[1] << c[3]) - d[1]; + a[1] = (b[0] << c[2]) - d[0]; + a[2] = (b[3] << c[1]) - d[3]; + a[3] = (b[2] << c[0]) - d[2]; +} + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 3 "slp2" { target { vect_var_shift && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-10.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-10.c new file mode 100644 index 0000000000..e2c86f3bd7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-10.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os -fno-tree-loop-vectorize" } */ + +#include "bb-slp-layout-9.c" + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 1 "slp1" { target { vect_int && { vect_perm && vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-11.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-11.c new file mode 100644 index 0000000000..d9b5349b70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-11.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +int a[4], b[4], c[400], d[400]; + +void f1() +{ + int a0 = a[0] - b[0]; + int a1 = a[1] + b[1]; + int a2 = a[2] - b[2]; + int a3 = a[3] + b[3]; + int b0 = a0; + int b1 = a1; + int b2 = a2; + int b3 = a3; + for (int i = 0; i < 100; ++i) + { + a0 += c[i * 4 + 1]; + a1 += c[i * 4 + 0]; + a2 += c[i * 4 + 3]; + a3 += c[i * 4 + 2]; + b0 ^= d[i * 4 + 3]; + b1 ^= d[i * 4 + 2]; + b2 ^= d[i * 4 + 1]; + b3 ^= d[i * 4 + 0]; + } + a[0] = a0 ^ b0; + a[1] = a1 ^ b1; + a[2] = a2 ^ b2; + a[3] = a3 ^ b3; +} + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 4 "slp1" { target { vect_int && vect_perm } } } } */ +/* { dg-final { scan-tree-dump "duplicating permutation node" "slp1" { target { vect_int && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-12.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-12.c new file mode 100644 index 0000000000..3bf48af35d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-12.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os -fno-tree-loop-vectorize" } */ + +#include "bb-slp-layout-11.c" + +/* It would be better to keep the original three permutations. */ +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 3 "slp1" { target { vect_int && { vect_perm && vect_hw_misalign } } xfail { *-*-* } } } } */ +/* { dg-final { scan-tree-dump-not "duplicating permutation node" "slp1" { target { vect_int && { vect_perm && vect_hw_misalign } } xfail { *-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-13.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-13.c new file mode 100644 index 0000000000..9669ade252 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-13.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a[4], b[4], c[4], d[4]; + +void f1() +{ + a[0] = (b[1] << c[3]) - (d[1] >> c[3]); + a[1] = (b[0] << c[2]) - (d[0] >> c[2]); + a[2] = (b[3] << c[1]) - (d[3] >> c[1]); + a[3] = (b[2] << c[0]) - (d[2] >> c[0]); +} + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 3 "slp2" { target { vect_var_shift && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-14.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-14.c new file mode 100644 index 0000000000..159bb15c41 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-14.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os" } */ + +#include "bb-slp-layout-13.c" + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 2 "slp2" { target { vect_var_shift && { vect_perm && vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-15.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-15.c new file mode 100644 index 0000000000..d87fc1e929 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-15.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a[4], b[4], c[4], d[4]; + +void f1() +{ + a[0] = (b[3] << c[3]) - d[0]; + a[1] = (b[2] << c[2]) - d[2]; + a[2] = (b[1] << c[1]) - d[4]; + a[3] = (b[0] << c[0]) - d[6]; +} + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 1 "slp2" { target { vect_var_shift && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-16.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-16.c new file mode 100644 index 0000000000..559583a016 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-16.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os" } */ + +#include "bb-slp-layout-15.c" + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 1 "slp2" { target { vect_var_shift && { vect_perm && vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-17.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-17.c new file mode 100644 index 0000000000..f64a2d9823 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-17.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +int a[8], b[8]; + +int f1() +{ + a[0] = b[4] + 1; + a[1] = b[5] + 1; + a[2] = b[6] + 1; + a[3] = b[7] + 1; + a[4] = b[0] + 1; + a[5] = b[1] + 1; + a[6] = b[2] + 1; + a[7] = b[3] + 1; +} + +unsigned short c[2], d[2]; +void f2() { + c[0] += d[1]; + c[1] += d[0]; +} + +typedef int v4si __attribute__((vector_size(16))); +void f3(v4si x) { + a[0] = b[1] + x[1]; + a[1] = b[0] + x[3]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-18.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-18.c new file mode 100644 index 0000000000..ff46272250 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-18.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float} */ +/* { dg-additional-options "-w -Wno-psabi -ffast-math" } */ + +typedef float v4sf __attribute__((vector_size(sizeof(float)*4))); + +float __attribute__((noipa)) +f(v4sf v0, v4sf v1) +{ + return v0[0]*v1[0]+v0[1]*v1[1]+v0[2]*v1[2]+v0[3]*v1[3]; +} + +/* We are lacking an effective target for .REDUC_PLUS support. */ +/* { dg-final { scan-tree-dump-times "basic block part vectorized" 1 "slp2" { target x86_64-*-* aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-not " = VEC_PERM_EXPR" "slp2" { target x86_64-*-* aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-19.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-19.c new file mode 100644 index 0000000000..847a07bd5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-19.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +extern int a[][4], b[][4], c[][4], d[4], e[4]; +void f() +{ + int t0 = a[0][3]; + int t1 = a[1][3]; + int t2 = a[2][3]; + int t3 = a[3][3]; + int a0 = 0, a1 = 0, a2 = 0, a3 = 0, b0 = 0, b1 = 0, b2 = 0, b3 = 0; + for (int j = 0; j < 100; ++j) + for (int i = 0; i < 400; i += 4) + { + a0 += b[i][3] * t0; + a1 += b[i][2] * t1; + a2 += b[i][1] * t2; + a3 += b[i][0] * t3; + b0 += c[i][3] * t0; + b1 += c[i][2] * t1; + b2 += c[i][1] * t2; + b3 += c[i][0] * t3; + } + d[0] = a0; + d[1] = a1; + d[2] = a2; + d[3] = a3; + e[0] = b0; + e[1] = b1; + e[2] = b2; + e[3] = b3; +} + +/* On older powerpc hardware (POWER7 and earlier), the default flag + -mno-allow-movmisalign prevents vectorization. On POWER8 and later, + when vect_hw_misalign is true, vectorization occurs. For other + targets, ! vect_no_align is a sufficient test. */ + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 3 "slp1" { target { { vect_int_mult && vect_perm } && { { ! powerpc*-*-* } || { vect_hw_misalign } } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-2.c new file mode 100644 index 0000000000..f12290ba84 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-2.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os" } */ + +#include "bb-slp-layout-1.c" + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 2 "slp2" { target { vect_var_shift && { vect_perm && vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-20.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-20.c new file mode 100644 index 0000000000..ed7816b3f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-20.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +extern int a[][4], b[][4], c[][4], d[4], e[4]; +void f() +{ + int t0 = a[0][3]; + int t1 = a[1][3]; + int t2 = a[2][3]; + int t3 = a[3][3]; + int a0 = 0, a1 = 0, a2 = 0, a3 = 0, b0 = 0, b1 = 0, b2 = 0, b3 = 0; + for (int i = 0; i < 400; i += 4) + { + a0 += b[i][3] * t0; + a1 += b[i][2] * t1; + a2 += b[i][1] * t2; + a3 += b[i][0] * t3; + b0 += c[i][3] * t0; + b1 += c[i][2] * t1; + b2 += c[i][1] * t2; + b3 += c[i][0] * t3; + } + d[0] = a0; + d[1] = a1; + d[2] = a2; + d[3] = a3; + e[0] = b0; + e[1] = b1; + e[2] = b2; + e[3] = b3; +} + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 3 "slp1" { target { vect_int_mult && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-21.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-21.c new file mode 100644 index 0000000000..c851d58c97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-21.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=bdver2" { target x86_64-*-* i?86-*-* } } */ + +int rl2GeomExport64_little_endian, rl2GeomExport64_little_endian_arch; +void rl2GeomExport64(unsigned char *p, double value) { + union { + unsigned char byte[8]; + double double_value; + } convert; + convert.double_value = value; + if (rl2GeomExport64_little_endian_arch) + if (rl2GeomExport64_little_endian) { + *(p + 7) = convert.byte[0]; + *(p + 6) = convert.byte[1]; + *(p + 5) = convert.byte[2]; + *(p + 4) = convert.byte[3]; + *(p + 3) = convert.byte[4]; + *(p + 2) = convert.byte[5]; + *(p + 1) = convert.byte[6]; + *p = convert.byte[7]; + } else + *p = convert.byte[7]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-3.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-3.c new file mode 100644 index 0000000000..82c2720ae5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a[4], b[4], c[4], d[4]; + +void f1() +{ + a[0] = (b[3] << c[3]) - d[3]; + a[1] = (b[2] << c[2]) - d[2]; + a[2] = (b[1] << c[1]) - d[1]; + a[3] = (b[0] << c[0]) - d[0]; +} + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 1 "slp2" { target { vect_var_shift && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-4.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-4.c new file mode 100644 index 0000000000..45bd6c800b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-4.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os" } */ + +#include "bb-slp-layout-3.c" + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 1 "slp2" { target { vect_var_shift && { vect_perm && vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-5.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-5.c new file mode 100644 index 0000000000..b59a159227 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-5.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a[4], b[4], c[4]; + +void f1() +{ + a[0] = b[3] - c[3]; + a[1] = b[2] + c[2]; + a[2] = b[1] - c[1]; + a[3] = b[0] + c[0]; +} + +/* { dg-final { scan-tree-dump "absorbing input layouts" "slp2" { target { vect_int && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-6.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-6.c new file mode 100644 index 0000000000..06f53084f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-6.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os" } */ + +#include "bb-slp-layout-5.c" + +/* { dg-final { scan-tree-dump "absorbing input layouts" "slp2" { target { vect_int && { vect_perm && vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-7.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-7.c new file mode 100644 index 0000000000..7a20c60064 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-7.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +int a[4], b[400]; + +void f1() +{ + for (int i = 0; i < 100; ++i) + { + a[0] += b[i * 4 + 3]; + a[1] += b[i * 4 + 2]; + a[2] += b[i * 4 + 1]; + a[3] += b[i * 4 + 0]; + } +} + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 2 "slp1" { target { vect_int && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-8.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-8.c new file mode 100644 index 0000000000..ef2f0c693b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-8.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os -fno-tree-loop-vectorize" } */ + +#include "bb-slp-layout-7.c" + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 1 "slp1" { target { vect_int && { vect_perm && vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-9.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-9.c new file mode 100644 index 0000000000..c8418620be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-layout-9.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +int a[4], b[400], c[400], d[40000]; + +void f1() +{ + int a0 = a[0]; + int a1 = a[1]; + int a2 = a[2]; + int a3 = a[3]; + for (int i = 0; i < 100; ++i) + { + a0 ^= c[i * 4 + 0]; + a1 ^= c[i * 4 + 1]; + a2 ^= c[i * 4 + 2]; + a3 ^= c[i * 4 + 3]; + for (int j = 0; j < 100; ++j) + { + a0 += d[i * 400 + j * 4 + 1]; + a1 += d[i * 400 + j * 4 + 0]; + a2 += d[i * 400 + j * 4 + 3]; + a3 += d[i * 400 + j * 4 + 2]; + } + b[i * 4 + 0] = a0; + b[i * 4 + 1] = a1; + b[i * 4 + 2] = a2; + b[i * 4 + 3] = a3; + } + a[0] = a0; + a[1] = a1; + a[2] = a2; + a[3] = a3; +} + +/* { dg-final { scan-tree-dump-times "add new stmt: \[^\\n\\r\]* = VEC_PERM_EXPR" 2 "slp1" { target { vect_int && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-over-widen-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-over-widen-1.c new file mode 100644 index 0000000000..7646c4f5a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-over-widen-1.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +/* Deliberate use of signed >>. */ +#define DEF_LOOP(SIGNEDNESS) \ + void __attribute__ ((noipa)) \ + f_##SIGNEDNESS (SIGNEDNESS char *restrict a, \ + SIGNEDNESS char *restrict b, \ + SIGNEDNESS char *restrict c) \ + { \ + a[0] = (b[0] + c[0]) >> 1; \ + a[1] = (b[1] + c[1]) >> 1; \ + a[2] = (b[2] + c[2]) >> 1; \ + a[3] = (b[3] + c[3]) >> 1; \ + a[4] = (b[4] + c[4]) >> 1; \ + a[5] = (b[5] + c[5]) >> 1; \ + a[6] = (b[6] + c[6]) >> 1; \ + a[7] = (b[7] + c[7]) >> 1; \ + a[8] = (b[8] + c[8]) >> 1; \ + a[9] = (b[9] + c[9]) >> 1; \ + a[10] = (b[10] + c[10]) >> 1; \ + a[11] = (b[11] + c[11]) >> 1; \ + a[12] = (b[12] + c[12]) >> 1; \ + a[13] = (b[13] + c[13]) >> 1; \ + a[14] = (b[14] + c[14]) >> 1; \ + a[15] = (b[15] + c[15]) >> 1; \ + } + +DEF_LOOP (signed) +DEF_LOOP (unsigned) + +#define N 16 + +#define TEST_LOOP(SIGNEDNESS, BASE_B, BASE_C) \ + { \ + SIGNEDNESS char a[N], b[N], c[N]; \ + for (int i = 0; i < N; ++i) \ + { \ + b[i] = BASE_B + i * 15; \ + c[i] = BASE_C + i * 14; \ + asm volatile ("" ::: "memory"); \ + } \ + f_##SIGNEDNESS (a, b, c); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + if (a[i] != (BASE_B + BASE_C + i * 29) >> 1) \ + __builtin_abort (); \ + } + +int +main (void) +{ + check_vect (); + + TEST_LOOP (signed, -128, -120); + TEST_LOOP (unsigned, 4, 10); + + return 0; +} + +/* { dg-final { scan-tree-dump "demoting int to signed short" "slp2" { target { ! vect_widen_shift } } } } */ +/* { dg-final { scan-tree-dump "demoting int to unsigned short" "slp2" { target { ! vect_widen_shift } } } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "slp2" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "note: Basic block will be vectorized" 2 "slp2" { target vect_hw_misalign } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-over-widen-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-over-widen-2.c new file mode 100644 index 0000000000..d9838c0917 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-over-widen-2.c @@ -0,0 +1,67 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +/* Deliberate use of signed >>. */ +#define DEF_LOOP(SIGNEDNESS) \ + void __attribute__ ((noipa)) \ + f_##SIGNEDNESS (SIGNEDNESS char *restrict a, \ + SIGNEDNESS char *restrict b, \ + SIGNEDNESS char c) \ + { \ + a[0] = (b[0] + c) >> 1; \ + a[1] = (b[1] + c) >> 1; \ + a[2] = (b[2] + c) >> 1; \ + a[3] = (b[3] + c) >> 1; \ + a[4] = (b[4] + c) >> 1; \ + a[5] = (b[5] + c) >> 1; \ + a[6] = (b[6] + c) >> 1; \ + a[7] = (b[7] + c) >> 1; \ + a[8] = (b[8] + c) >> 1; \ + a[9] = (b[9] + c) >> 1; \ + a[10] = (b[10] + c) >> 1; \ + a[11] = (b[11] + c) >> 1; \ + a[12] = (b[12] + c) >> 1; \ + a[13] = (b[13] + c) >> 1; \ + a[14] = (b[14] + c) >> 1; \ + a[15] = (b[15] + c) >> 1; \ + } + +DEF_LOOP (signed) +DEF_LOOP (unsigned) + +#define N 16 + +#define TEST_LOOP(SIGNEDNESS, BASE_B, C) \ + { \ + SIGNEDNESS char a[N], b[N], c[N]; \ + for (int i = 0; i < N; ++i) \ + { \ + b[i] = BASE_B + i * 15; \ + asm volatile ("" ::: "memory"); \ + } \ + f_##SIGNEDNESS (a, b, C); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + if (a[i] != (BASE_B + C + i * 15) >> 1) \ + __builtin_abort (); \ + } + +int +main (void) +{ + check_vect (); + + TEST_LOOP (signed, -128, -120); + TEST_LOOP (unsigned, 4, 250); + + return 0; +} + +/* { dg-final { scan-tree-dump "demoting int to signed short" "slp2" { target { ! vect_widen_shift } } } } */ +/* { dg-final { scan-tree-dump "demoting int to unsigned short" "slp2" { target { ! vect_widen_shift } } } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "slp2" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "note: Basic block will be vectorized" 2 "slp2" { target vect_hw_misalign } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pattern-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pattern-1.c new file mode 100644 index 0000000000..a3ff0f5b3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pattern-1.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned short X[N]; +unsigned short Y[N]; +unsigned int result[N]; + +/* unsigned short->unsigned int widening-mult. */ +__attribute__ ((noinline, noclone)) void +foo (void) +{ + result[0] = (unsigned int) (X[0] * Y[0]); + result[1] = (unsigned int) (X[1] * Y[1]); + result[2] = (unsigned int) (X[2] * Y[2]); + result[3] = (unsigned int) (X[3] * Y[3]); + result[4] = (unsigned int) (X[4] * Y[4]); + result[5] = (unsigned int) (X[5] * Y[5]); + result[6] = (unsigned int) (X[6] * Y[6]); + result[7] = (unsigned int) (X[7] * Y[7]); +} + +int main (void) +{ + int i, tmp; + + check_vect (); + + for (i = 0; i < N; i++) + { + X[i] = i; + Y[i] = 64-i; + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + __asm__ volatile (""); + tmp = X[i] * Y[i]; + if (result[i] != tmp) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "slp2" { target { vect_widen_mult_hi_to_si || vect_unpack } } } } */ +/* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 8 "slp2" { target vect_widen_mult_hi_to_si_pattern } } } */ +/* { dg-final { scan-tree-dump-times "pattern recognized" 8 "slp2" { target vect_widen_mult_hi_to_si_pattern } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pattern-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pattern-2.c new file mode 100644 index 0000000000..05fde3a7fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pattern-2.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-additional-options "-fno-tree-vectorize -ftree-slp-vectorize -ftree-loop-if-convert" } */ + +#include "tree-vect.h" + +#define N 128 + +__attribute__((noinline, noclone)) void +foo (short * __restrict__ a, int * __restrict__ b, int stride) +{ + int i; + + for (i = 0; i < N/stride; i++, a += stride, b += stride) + { + a[0] = b[0] ? 1 : 7; + a[1] = b[1] ? 2 : 7; + a[2] = b[2] ? 3 : 0; + a[3] = b[3] ? 4 : 7; + a[4] = b[4] ? 5 : 0; + a[5] = b[5] ? 6 : 0; + a[6] = b[6] ? 7 : 0; + a[7] = b[7] ? 8 : 7; + } +} + +short a[N]; +int b[N]; +int main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = i; + b[i] = -i; + } + + foo (a, b, 8); + +#pragma GCC novector + for (i = 1; i < N; i++) + if (a[i] != i%8 + 1) + abort (); + + if (a[0] != 7) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" { target { vect_element_align && vect_pack_trunc } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-phis-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-phis-1.c new file mode 100644 index 0000000000..014c13b850 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-phis-1.c @@ -0,0 +1,20 @@ +/* From gcc.c-torture/execute/loop-13.c */ +/* { dg-do compile } */ +/* { dg-additional-options "-march=cascadelake" { target x86_64-*-* i?86-*-* } } */ +#define TYPE long + +void +scale (TYPE *alpha, TYPE *x, int n) +{ + int i, ix; + + if (*alpha != 1) + for (i = 0, ix = 0; i < n; i++, ix += 2) + { + TYPE tmpr, tmpi; + tmpr = *alpha * x[ix]; + tmpi = *alpha * x[ix + 1]; + x[ix] = tmpr; + x[ix + 1] = tmpi; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pow-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pow-1.c new file mode 100644 index 0000000000..c186c7b66c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pow-1.c @@ -0,0 +1,33 @@ +/* { dg-additional-options "-fno-math-errno -fdisable-tree-sincos" } */ +/* { dg-require-effective-target vect_float } */ + +void __attribute__ ((noipa)) +f (float *a) +{ + a[0] = a[0] * a[0]; + a[1] = __builtin_powf (a[1], 2); + a[2] = a[2] * a[2]; + a[3] = __builtin_powf (a[3], 2); +} + +float a[4] = { 1, 2, 3, 4 }; + +int +main (void) +{ + f (a); +#pragma GCC novector + for (int i = 0; i < 4; ++i) + { + if (a[i] != (i + 1) * (i + 1)) + __builtin_abort (); + asm volatile ("" ::: "memory"); + } + return 0; +} + +/* On older powerpc hardware (POWER7 and earlier), the default flag + -mno-allow-movmisalign prevents vectorization. On POWER8 and later, + when vect_hw_misalign is true, vectorization occurs. */ + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target {{ ! powerpc*-*-* } || { powerpc*-*-* && vect_hw_misalign }} } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr100778-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr100778-1.c new file mode 100644 index 0000000000..9f8b7eecef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr100778-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double foo (int x, double *p) +{ + double res = p[0] + p[1]; + double tem = p[0] / x; + if (x) + { + p[0] = tem; + p[1] /= x; + } + return res + tem; +} + +/* We may not SLP vectorize the FP division because it can trap and it + is distributed between two basic-blocks. */ +/* { dg-final { scan-tree-dump "Build SLP failed: different BB for PHI or possibly trapping operation in _\[0-9\]+ = _\[0-9\]+ / _\[0-9\]+;" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101207.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101207.c new file mode 100644 index 0000000000..554255e72b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101207.c @@ -0,0 +1,24 @@ +/* { dg-additional-options "-ffast-math" } */ + +#include "tree-vect.h" + +double a[2]; +double x, y; + +void __attribute__((noipa)) foo () +{ + x = a[1] - a[0]; + y = a[0] + a[1]; +} + +int main() +{ + check_vect (); + + a[0] = 0.; + a[1] = 1.; + foo (); + if (x != 1. || y != 1.) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101242.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101242.c new file mode 100644 index 0000000000..d8854468df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101242.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ + +typedef struct { + double real; + double imag; +} complex; +typedef struct { + complex e[3][3]; +} su3_matrix; +su3_matrix check_su3_c; +double check_su3_ar, check_su3_ari, check_su3_max; +int arireturn(); +int check_su3() { + check_su3_ar = check_su3_c.e[0][0].real * check_su3_c.e[1][0].real + + check_su3_c.e[0][0].imag * check_su3_c.e[1][0].imag + + check_su3_c.e[0][1].real * check_su3_c.e[1][1].real + + check_su3_c.e[0][1].imag * check_su3_c.e[1][1].imag + + check_su3_c.e[0][2].real * check_su3_c.e[1][2].real + + check_su3_c.e[0][2].imag * check_su3_c.e[1][2].imag; + check_su3_max = check_su3_c.e[0][0].real * check_su3_c.e[2][0].real + + check_su3_c.e[0][0].imag * check_su3_c.e[2][0].imag + + check_su3_c.e[0][1].real * check_su3_c.e[2][1].real + + check_su3_c.e[0][1].imag * check_su3_c.e[2][1].imag + + check_su3_c.e[0][2].real * check_su3_c.e[2][2].real + + check_su3_c.e[0][2].imag * check_su3_c.e[2][2].imag; + check_su3_ari = check_su3_ar; + if (check_su3_ari) + check_su3_max = check_su3_c.e[1][0].real * check_su3_c.e[2][0].real + + check_su3_c.e[1][0].imag * check_su3_c.e[2][0].imag + + check_su3_c.e[1][1].real * check_su3_c.e[2][1].real + + check_su3_c.e[1][1].imag * check_su3_c.e[2][1].imag + + check_su3_c.e[1][2].real * check_su3_c.e[2][2].real + + check_su3_c.e[1][2].imag * check_su3_c.e[2][2].imag; + if (check_su3_max) + arireturn(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101615-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101615-1.c new file mode 100644 index 0000000000..0c41787ab1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101615-1.c @@ -0,0 +1,29 @@ +/* { dg-additional-options "-w -Wno-psabi" } */ + +#include "tree-vect.h" + +typedef int v4si __attribute__((vector_size(16))); + +int a[4]; +int b[4]; + +void __attribute__((noipa)) +foo (v4si x) +{ + b[0] = a[3] + x[0]; + b[1] = a[2] + x[1]; + b[2] = a[1] + x[2]; + b[3] = a[0] + x[3]; +} + +int main() +{ + check_vect (); + for (int i = 0; i < 4; ++i) + a[i] = i; + v4si x = (v4si) { 8, 6, 4, 2 }; + foo (x); + if (b[0] != 11 || b[1] != 8 || b[2] != 5 || b[3] != 2) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101615-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101615-2.c new file mode 100644 index 0000000000..d4768af6a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101615-2.c @@ -0,0 +1,24 @@ +/* { dg-additional-options "-O3 -w -Wno-psabi" } */ + +#include "tree-vect.h" + +int res[6] = { 5, 7, 11, 3, 3, 3 }; +int a[6] = {5, 5, 8}; +int c; + +int main() +{ + check_vect (); + for (int b = 0; b <= 4; b++) + for (; c <= 4; c++) { + a[0] |= 1; + for (int e = 0; e <= 4; e++) + a[e + 1] |= 3; + } + +#pragma GCC novector + for (int d = 0; d < 6; d++) + if (a[d] != res[d]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101668.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101668.c new file mode 100644 index 0000000000..147286a6f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101668.c @@ -0,0 +1,58 @@ +/* { dg-additional-options "-w -Wno-psabi" } */ + +#include "tree-vect.h" + +typedef int v4si __attribute__((vector_size(16))); +typedef int v8si __attribute__((vector_size(32))); + +void __attribute__((noipa)) test_lo (v4si *dst, v8si src) +{ + (*dst)[0] = src[0]; + (*dst)[1] = src[1]; + (*dst)[2] = src[2]; + (*dst)[3] = src[3]; +} + +void __attribute__((noipa)) test_hi (v4si *dst, v8si src) +{ + (*dst)[0] = src[4]; + (*dst)[1] = src[5]; + (*dst)[2] = src[6]; + (*dst)[3] = src[7]; +} + +void __attribute__((noipa)) test_even (v4si *dst, v8si src) +{ + (*dst)[0] = src[0]; + (*dst)[1] = src[2]; + (*dst)[2] = src[4]; + (*dst)[3] = src[6]; +} + +void __attribute__((noipa)) test_odd (v4si *dst, v8si src) +{ + (*dst)[0] = src[1]; + (*dst)[1] = src[3]; + (*dst)[2] = src[5]; + (*dst)[3] = src[7]; +} + +int main() +{ + check_vect (); + v8si v = (v8si) { 0, 1, 2, 3, 4, 5, 6, 7 }; + v4si dst; + test_lo (&dst, v); + if (dst[0] != 0 || dst[1] != 1 || dst[2] != 2 || dst[3] != 3) + abort (); + test_hi (&dst, v); + if (dst[0] != 4 || dst[1] != 5 || dst[2] != 6 || dst[3] != 7) + abort (); + test_even (&dst, v); + if (dst[0] != 0 || dst[1] != 2 || dst[2] != 4 || dst[3] != 6) + abort (); + test_odd (&dst, v); + if (dst[0] != 1 || dst[1] != 3 || dst[2] != 5 || dst[3] != 7) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101756.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101756.c new file mode 100644 index 0000000000..de7f180692 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr101756.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* SIMD support can emit additional diagnostics. */ +/* { dg-additional-options "-w" } */ + +__attribute__ ((simd)) int +tq (long int ea, int of, int kk) +{ + int bc; + + for (bc = 0; bc < 2; ++bc) + { + ++ea; + of |= !!kk < !!ea; + } + + return of; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr103800.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr103800.c new file mode 100644 index 0000000000..33c2d2081c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr103800.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +int a; +long b; +extern int c[], d[]; +extern _Bool e[]; +void f() { + if (a) + ; + for (;;) { + for (int g = 2; g; g = a) + d[g] = 0; + for (int h = 1; h < 13; h++) + e[h] = b ? (short)c[4 + h - 1] : c[4 + h - 1]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr104240.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr104240.c new file mode 100644 index 0000000000..1045f31d4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr104240.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_cond_mixed } */ + +void foo (int *c, float *x, float *y) +{ + c = __builtin_assume_aligned (c, __BIGGEST_ALIGNMENT__); + x = __builtin_assume_aligned (x, __BIGGEST_ALIGNMENT__); + y = __builtin_assume_aligned (y, __BIGGEST_ALIGNMENT__); + c[0] = x[0] < y[0]; + c[1] = y[1] > x[1]; + c[2] = x[2] < y[2]; + c[3] = x[3] < y[3]; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr106019.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr106019.c new file mode 100644 index 0000000000..218d7cca33 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr106019.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +void f(double *p, long i) +{ + p[i+0] += 1; + p[i+1] += 1; +} +void g(double *p, long i) +{ + double *q = p + i; + q[0] += 1; + q[1] += 1; +} + +/* { dg-final { scan-tree-dump-not "can't determine dependence" slp2 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr54400.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr54400.c new file mode 100644 index 0000000000..6ecd51103e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr54400.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_float} */ +/* { dg-additional-options "-w -Wno-psabi -ffast-math" } */ + +#include "tree-vect.h" + +typedef float v4sf __attribute__((vector_size(sizeof(float)*4))); + +float __attribute__((noipa)) +f(v4sf v) +{ + return v[0]+v[1]+v[2]+v[3]; +} + +float __attribute__((noipa)) +g(float *v) +{ + return v[0]+v[1]+v[2]+v[3]; +} + +float __attribute__((noipa)) +h(float *v) +{ + return 2*v[0]+3*v[1]+4*v[2]+5*v[3]; +} + +int +main () +{ + check_vect (); + v4sf v = (v4sf) { 1.f, 3.f, 4.f, 2.f }; + if (f (v) != 10.f) + abort (); + if (g (&v[0]) != 10.f) + abort (); + if (h (&v[0]) != 37.f) + abort (); + return 0; +} + +/* We are lacking an effective target for .REDUC_PLUS support. */ +/* { dg-final { scan-tree-dump-times "basic block part vectorized" 3 "slp2" { target x86_64-*-* aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-not " = VEC_PERM_EXPR" "slp2" { target x86_64-*-* aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr58135.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr58135.c new file mode 100644 index 0000000000..d3ac0de7f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr58135.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int a[100]; +void foo () +{ + a[0] = a[1] = a[2] = a[3] = a[4]= 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr65935.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr65935.c new file mode 100644 index 0000000000..9ef1330b47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr65935.c @@ -0,0 +1,75 @@ +/* { dg-additional-options "-O3" } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "-mprefer-vector-width=128" { target x86_64-*-* i?86-*-* } } */ + +#include "tree-vect.h" + +extern void abort (void); +extern void *malloc (__SIZE_TYPE__); + +struct site { + struct { + struct { + double real; + double imag; + } e[3][3]; + } link[32]; + double phase[32]; +} *lattice; +int sites_on_node; + +void rephase (void) +{ + int i,j,k,dir; + struct site *s; + for(i=0,s=lattice;ilink[dir].e[j][k].real *= s->phase[dir]; + s->link[dir].e[j][k].imag *= s->phase[dir]; + } + /* Avoid loop vectorizing the outer loop after unrolling + the inners. */ + __asm__ volatile ("" : : : "memory"); + } +} + +int main() +{ + int i,j,k; + check_vect (); + sites_on_node = 1; + lattice = malloc (sizeof (struct site) * sites_on_node); + for (i = 0; i < 32; ++i) + { + lattice->phase[i] = i; + for (j = 0; j < 3; ++j) + for (k = 0; k < 3; ++k) + { + lattice->link[i].e[j][k].real = 1.0; + lattice->link[i].e[j][k].imag = 1.0; + __asm__ volatile ("" : : : "memory"); + } + } + rephase (); + for (i = 0; i < 32; ++i) + for (j = 0; j < 3; ++j) +#pragma GCC novector + for (k = 0; k < 3; ++k) + if (lattice->link[i].e[j][k].real != i + || lattice->link[i].e[j][k].imag != i) + abort (); + return 0; +} + +/* We should also be able to use 2-lane SLP to initialize the real and + imaginary components in the first loop of main. */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 10 "slp1" { target {! { vect1024 } } } } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 11 "slp1" { target { { vect1024 } } } } } */ +/* We should see the s->phase[dir] operand splatted and no other operand built + from scalars. See PR97334. */ +/* { dg-final { scan-tree-dump "Using a splat" "slp1" } } */ +/* { dg-final { scan-tree-dump-times "Building vector operands from scalars" 0 "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr69907.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr69907.c new file mode 100644 index 0000000000..f63b42a271 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr69907.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* Disable for vectorization using partial vectors since it would have only + one iteration left, consequently BB vectorization won't happen. */ +/* { dg-additional-options "-O3 --param=vect-partial-vector-usage=0" } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#if VECTOR_BITS > 512 +#define N (VECTOR_BITS * 10 / 16) +#else +#define N 320 +#endif + +void foo(unsigned *p1, unsigned short *p2) +{ + int n; + for (n = 0; n < N; n++) + p1[n] = p2[n * 2]; +} + +/* Disable for SVE because for long or variable-length vectors we don't + get an unrolled epilogue loop. Also disable for AArch64 Advanced SIMD, + because there we can vectorize the epilogue using mixed vector sizes. + Likewise for AMD GCN and RVV. */ +/* { dg-final { scan-tree-dump "BB vectorization with gaps at the end of a load is not supported" "slp1" { target { { ! aarch64*-*-* } && { { ! amdgcn*-*-* } && { ! riscv_v } } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr78205.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr78205.c new file mode 100644 index 0000000000..27cba9beed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr78205.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +double x[2], a[4], b[4], c[5]; + +void foo () +{ + a[0] = c[0]; + a[1] = c[1]; + a[2] = c[0]; + a[3] = c[1]; + b[0] = c[2]; + b[1] = c[3]; + b[2] = c[2]; + b[3] = c[3]; + x[0] = c[4]; + x[1] = c[4]; +} + +/* We may not vectorize the store to x[] as it accesses c out-of bounds + but we do want to vectorize the other two store groups. But we may + end up using scalar loads to vectorize the last group. */ + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 3 "slp2" } } */ +/* { dg-final { scan-tree-dump-times "BB vectorization with gaps at the end of a load is not supported" 1 "slp2" } } */ +/* { dg-final { scan-tree-dump-times " = c\\\[4\\\];" 1 "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr80705.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr80705.c new file mode 100644 index 0000000000..189e3d14bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr80705.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-require-profiling "-fprofile-generate" } */ +/* { dg-additional-options "-fprofile-generate" } */ + +extern int isspace (int); + +int foo(const char *txt, char *buf) +{ + const char *s; + char *d; + int ws = 1; + for (s=txt, d=buf; *s; ) + { + if (*s=='/' && *(s+1)=='/') { + + s += 2; + while (*s && *s!='\r' && *s!='\n') + s++; + } + else if (*s=='"') { + + s++; + while (*s && *s!='\r' && *s!='\n' && *s!='"') + if (*s++=='\\') + s++; + if (*s=='"') + s++; + } + else { + if (*s && !isspace(*s)) + ws = 0; + + + *d++ = *s++; + + } + } + *d = '\0'; + + return ws; +} + +/* { dg-final { scan-tree-dump "base object not addressable" "slp1" } } */ +/* { dg-final { scan-tree-dump-not "MEM\[^\r\n\]*__gcov\[^\r\n\]* = vect_cst" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-1.c new file mode 100644 index 0000000000..dcba9a02d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-1.c @@ -0,0 +1,92 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target lp64 } */ + +void +f1 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < 1000; i += 4) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +void +f2 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 2; i < ~0U - 4; i += 4) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +void +f3 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < ~0U - 3; i += 4) + { + double a = q[i + 2] + p[i + 2]; + double b = q[i + 3] + p[i + 3]; + q[i + 2] = a; + q[i + 3] = b; + } +} + +void +f4 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < 500; i += 6) + for (unsigned int j = 0; j < 500; j += 4) + { + double a = q[j] + p[i]; + double b = q[j + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +void +f5 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 2; i < 1000; i += 4) + { + double a = q[i - 2] + p[i - 2]; + double b = q[i - 1] + p[i - 1]; + q[i - 2] = a; + q[i - 1] = b; + } +} + +double p[1000]; +double q[1000]; + +void +f6 (int n) +{ + for (unsigned int i = 0; i < n; i += 4) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 6 "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-2.c new file mode 100644 index 0000000000..56c4bbf86d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-2.c @@ -0,0 +1,64 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize -fno-tree-dominator-opts" } */ +/* { dg-require-effective-target lp64 } */ + +double p[1000]; +double q[1000]; + +void +f1 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 2; i < ~0U - 4; i += 4) + { + double a = q[i + 2] + p[i + 2]; + double b = q[i + 3] + p[i + 3]; + q[i + 2] = a; + q[i + 3] = b; + } +} + +void +f2 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < ~0U - 3; i += 4) + { + double a = q[i + 4] + p[i + 4]; + double b = q[i + 5] + p[i + 5]; + q[i + 4] = a; + q[i + 5] = b; + } +} + +void +f3 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < 1000; i += 4) + { + double a = q[i - 2] + p[i - 2]; + double b = q[i - 1] + p[i - 1]; + q[i - 2] = a; + q[i - 1] = b; + } +} + +void +f4 (double *p, double *q) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 2; i < 1000; i += 4) + { + double a = q[i - 4] + p[i - 4]; + double b = q[i - 3] + p[i - 3]; + q[i - 4] = a; + q[i - 3] = b; + } +} + +/* { dg-final { scan-tree-dump-not "optimized: basic block" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-3.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-3.c new file mode 100644 index 0000000000..793f185990 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-3.c @@ -0,0 +1,62 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target lp64 } */ + +void +f1 (double *p, double *q, unsigned int n) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < n; i += 4) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +void +f2 (double *p, double *q, unsigned int n) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < n; i += 2) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +void +f3 (double *p, double *q, unsigned int n) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < n; i += 6) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +void +f4 (double *p, double *q, unsigned int start, unsigned int n) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = start & -2; i < n; i += 2) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 4 "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-4.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-4.c new file mode 100644 index 0000000000..67ee809826 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr81635-4.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-loop-vectorize -fno-tree-dominator-opts" } */ +/* { dg-require-effective-target lp64 } */ + +/* A ranger based DOM causes many more SSA names to be exported, which + causes slp1 to vectorize more things. Disabling DOM to avoid + disturbing this test. */ + +void +f1 (double *p, double *q, unsigned int n) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < n; i += 1) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +void +f2 (double *p, double *q, unsigned int n) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = 0; i < n; i += 3) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +void +f3 (double *p, double *q, unsigned int start, unsigned int n) +{ + p = (double *) __builtin_assume_aligned (p, sizeof (double) * 2); + q = (double *) __builtin_assume_aligned (q, sizeof (double) * 2); + for (unsigned int i = start; i < n; i += 2) + { + double a = q[i] + p[i]; + double b = q[i + 1] + p[i + 1]; + q[i] = a; + q[i + 1] = b; + } +} + +/* { dg-final { scan-tree-dump-not "optimized: basic block" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr90006.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr90006.c new file mode 100644 index 0000000000..7d82e94e97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr90006.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-math-errno" } */ +/* { dg-additional-options "-march=x86-64" { target x86_64-*-* i?86-*-* } } */ + +long int lrint(double x); + +int a, b; +union c { + int d; +}; + +int e() +{ + int f, g, h; + long i, j, k; + double l, m = b = lrint(0.3127); + a = b >> 16 >> 8 & 255; + ((union c *)e)->d = a; + k = m; + h = k >> 16 >> 8 & 255; + ((union c *)(e + 4))->d = h; + j = lrint(l); + g = j >> 16 >> 8 & 255; + ((union c *)(e + 8))->d = g; + i = lrint(0.292); + f = i >> 16 >> 8 & 255; + ((union c *)(e + 12))->d = f; + return 0; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" { target { { x86_64-*-* i?86-*-* } && ilp32 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr92596.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr92596.c new file mode 100644 index 0000000000..f3dd08d987 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr92596.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +typedef struct { + long n[5]; +} secp256k1_fe; + +secp256k1_fe a; + +void fn1(int p1) { a.n[0] = a.n[1] = a.n[2] = p1; } +void fn2() { + int b; + fn1(!b); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95271.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95271.c new file mode 100644 index 0000000000..f6e266cce5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95271.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-additional-options "-march=cooperlake" { target x86_64-*-* i?86-*-* } } */ + +#include + +int a; +struct b c; +int64_t d; +struct b { + uint64_t address; + uint64_t e; +}; +void f() +{ + d = (int64_t)(&a)[0] << 56 | (int64_t)((unsigned char *)&a)[1] << 48 | + (int64_t)((unsigned char *)&a)[2] << 40 | + (int64_t)((unsigned char *)&a)[3] << 32 | + (int64_t)((unsigned char *)&a)[4] << 24 | ((unsigned char *)&a)[5] << 16 | + ((unsigned char *)&a)[6] << 8 | ((unsigned char *)&a)[7]; + c.address = c.e = d; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95335.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95335.c new file mode 100644 index 0000000000..42a70222e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95335.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +float *a; +float b; +void +fn1(float p1[][3]) +{ + float c, d, e, f; + f = a[1] * a[1] * d; + b = a[1] * a[2] * d; + p1[1][1] = f + c; + p1[1][2] = b + e; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-2.c new file mode 100644 index 0000000000..5a831ae7ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "-w -Wno-psabi" } */ + +typedef double __attribute__((vector_size(16))) v2df; + +v2df f(v2df a, v2df b) +{ + return (v2df){a[0] + b[0], a[1] + b[1]}; +} + +v2df g(v2df a, v2df b) +{ + return (v2df){a[0] + b[1], a[1] + b[0]}; +} + +/* Verify we manage to vectorize this with using the original vectors + and do not end up with any vector CTORs. */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" } } */ +/* { dg-final { scan-tree-dump-not "vect_cst" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-3.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-3.c new file mode 100644 index 0000000000..aaee8febf3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-3.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-w -Wno-psabi" } */ + +typedef float __attribute__((vector_size(32))) v8f32; + +v8f32 f(v8f32 a, v8f32 b) +{ + /* Check that we vectorize this CTOR without any loads. */ + return (v8f32){a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3], + a[4] + b[4], a[5] + b[5], a[6] + b[6], a[7] + b[7]}; +} + +/* { dg-final { scan-tree-dump-not "from scalars" "slp2" } } */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-v8.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-v8.c new file mode 100644 index 0000000000..fea7f00fd6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839-v8.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect64 } */ +/* { dg-additional-options "-w -Wno-psabi" } */ + +typedef float __attribute__((vector_size(8))) v2f32; + +v2f32 f(v2f32 a, v2f32 b) +{ + /* Check that we vectorize this CTOR without any loads. */ + return (v2f32){a[0] + b[0], a[1] + b[1]}; +} + +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839.c new file mode 100644 index 0000000000..d87bbf125c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95839.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-w -Wno-psabi" } */ + +typedef float __attribute__((vector_size(16))) v4f32; + +v4f32 f(v4f32 a, v4f32 b) +{ + /* Check that we vectorize this CTOR without any loads. */ + return (v4f32){a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]}; +} + +/* { dg-final { scan-tree-dump-not "from scalars" "slp2" } } */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95866.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95866.c new file mode 100644 index 0000000000..14826b53ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr95866.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +int x[4]; +int j[4]; +void foo() +{ + x[0] = (x[0] << j[0]) + j[0]; + x[1] = (x[1] << j[0]) + j[1]; + x[2] = (x[2] << j[0]) + j[2]; + x[3] = (x[3] << j[0]) + j[3]; +} + +/* The scalar shift argument should be extracted from the available vector. */ +/* { dg-final { scan-tree-dump "BIT_FIELD_REF" "slp2" { target sse2 } } } */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97486.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97486.c new file mode 100644 index 0000000000..17d48a7fe6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97486.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +struct { + int *end_info; + int *fp; +} png_load_body_c; + +int *png_set_longjmp_fn(); + +void setjmp(); + +void png_load_body() +{ + int *fp; + int png_ptr, info_ptr, *end_info; + if (!fp) + return; + if (png_ptr) { + info_ptr = 0; + end_info = png_set_longjmp_fn(); + } + png_load_body_c.end_info = end_info; + png_load_body_c.fp = fp; + if (png_ptr) + png_set_longjmp_fn(); + setjmp(info_ptr); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97496.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97496.c new file mode 100644 index 0000000000..fa9e980158 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97496.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +int a; +int b[1024]; +void c(unsigned g) { + if (a) { + long e = g, d = e; + int f = 0; + for (; f < 4; f++) { + b[f] = d; + d >>= 8; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97615.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97615.c new file mode 100644 index 0000000000..b4a8aa2f4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97615.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +short *a; +int e, f; + +void +foo (int c, int d) +{ + short *a1, *a2, *a3; + a1 = a++; + *a1 = c; + a2 = a++; + *a2 = *a1; + a3 = a++; + *a3 = d; +} + +void +bar (void) +{ + foo (e + f - 2, e + f - 1); + foo (e + f - 1, 0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97626.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97626.c new file mode 100644 index 0000000000..943d8a62de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97626.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +struct { + int x; + int y; +} do_plasma_rect; + +int do_plasma_context_0, do_plasma_x2, do_plasma_y2, do_plasma_plasma_depth, + do_plasma_xm, do_plasma_ym; +void gegl_buffer_set(); + +void do_plasma(int x1, int y1) { + if (__builtin_expect(({ + int _g_boolean_var_; + if (do_plasma_context_0) + _g_boolean_var_ = 1; + else + _g_boolean_var_ = 0; + _g_boolean_var_; + }), + 0)) { + do_plasma_rect.x = x1; + do_plasma_rect.y = y1; + gegl_buffer_set(); + } + do_plasma_xm = (x1 + do_plasma_x2) / 2; + do_plasma_ym = (y1 + do_plasma_y2) / 2; + if (do_plasma_plasma_depth) { + do_plasma_rect.x = do_plasma_xm; + do_plasma_rect.y = do_plasma_ym; + return; + } + do_plasma(do_plasma_xm, do_plasma_ym); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97633.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97633.c new file mode 100644 index 0000000000..ab0ae1de9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97633.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +extern short i (void); + +struct { + short a; + short b; +} c; + +int d, e; +static int f = 1; + +void g () { + if (e) { + if (f) + goto L; + while (d) { + i (); + short j = d, k = i (), l = k; + L: + if (!(d && e) || l) + goto L; + c.a = j; + c.b = k; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97650.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97650.c new file mode 100644 index 0000000000..f9c91fb582 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97650.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Os -fallow-store-data-races" } */ + +short a=0; +unsigned long *volatile *volatile *volatile *b; +unsigned long *volatile *volatile *volatile **c[7]; +void d() { + short e=0; + for (; a;) { + e = 0; + for (; e < 7; e++) + c[e] = &b; + } +} +int main() { return 0; } diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97706.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97706.c new file mode 100644 index 0000000000..228ae700e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97706.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ + +_Bool arr[16]; +void bar(); +void foo(int n, char *p) +{ + _Bool b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15; + do + { + b0 = p[0] != 0; + b1 = p[1] != 0; + b2 = p[2] != 0; + b3 = p[3] != 0; + b4 = p[4] != 0; + b5 = p[5] != 0; + b6 = p[6] != 0; + b7 = p[7] != 0; + b8 = p[8] != 0; + b9 = p[9] != 0; + b10 = p[10] != 0; + b11 = p[11] != 0; + b12 = p[12] != 0; + b13 = p[13] != 0; + b14 = p[14] != 0; + b15 = p[15] != 0; + arr[0] = b0; + arr[1] = b1; + arr[2] = b2; + arr[3] = b3; + arr[4] = b4; + arr[5] = b5; + arr[6] = b6; + arr[7] = b7; + arr[8] = b8; + arr[9] = b9; + arr[10] = b10; + arr[11] = b11; + arr[12] = b12; + arr[13] = b13; + arr[14] = b14; + arr[15] = b15; + bar (); + } + while (--n); + arr[0] = b0; + arr[1] = b1; + arr[2] = b2; + arr[3] = b3; + arr[4] = b4; + arr[5] = b5; + arr[6] = b6; + arr[7] = b7; + arr[8] = b8; + arr[9] = b9; + arr[10] = b10; + arr[11] = b11; + arr[12] = b12; + arr[13] = b13; + arr[14] = b14; + arr[15] = b15; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97709.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97709.c new file mode 100644 index 0000000000..56ec0f6bda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97709.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +int a; +struct b { + int c; + int d; +}; +void k (struct b); +struct b +e() +{ + void *f[] = {&&g, &&h, &&i, &&j}; + int d, c; +j: + goto *(void*)(__INTPTR_TYPE__)a; +g: + d = 0; +h: + c = 1; + goto *(void*)(__INTPTR_TYPE__)a; +i: + { + struct b b = {c, d}; + k(b); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97732.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97732.c new file mode 100644 index 0000000000..5187090797 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97732.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +struct S { int a, b; } *e; +int d; + +void +foo (struct S *x) +{ + for (e = x; d; d++, e++) + e->a = e->b = (int) (__UINTPTR_TYPE__) e; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97746.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97746.c new file mode 100644 index 0000000000..c5a615d125 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr97746.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int a, b; +short c; + +extern void f (short*); + +void d() +{ + short e[2] = {0, 0}; + while (a) + { + f(e); + int g = 0 || a, h = 8 && c; + short i = c; + c = h & g; + if (b) + b = g || i; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98137.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98137.c new file mode 100644 index 0000000000..ecf7df21e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98137.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-require-effective-target vect_double } */ + +void +gemm (const double* __restrict__ A, const double* __restrict__ B, + double* __restrict__ C) +{ + unsigned int l_m = 0; + unsigned int l_n = 0; + unsigned int l_k = 0; + + for ( l_n = 0; l_n < 9; l_n++ ) { + /* Use -O3 so this loop is unrolled completely early. */ + for ( l_m = 0; l_m < 10; l_m++ ) { C[(l_n*10)+l_m] = 0.0; } + for ( l_k = 0; l_k < 17; l_k++ ) { + /* Use -O3 so this loop is unrolled completely early. */ + for ( l_m = 0; l_m < 10; l_m++ ) { + C[(l_n*10)+l_m] += A[(l_k*20)+l_m] * B[(l_n*20)+l_k]; + } + } + } +} + +/* Exact scanning is difficult but we expect all loads and stores + and computations to be vectorized. */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98516-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98516-1.c new file mode 100644 index 0000000000..7fd055de82 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98516-1.c @@ -0,0 +1,24 @@ +double a[4], b[2]; + +void __attribute__((noipa)) +foo () +{ + double a0 = a[0]; + double a1 = a[1]; + double a2 = a[2]; + double a3 = a[3]; + b[0] = a1 - a3; + b[1] = a0 + a2; +} + +int main() +{ + a[0] = 1.; + a[1] = 2.; + a[2] = 3.; + a[3] = 4.; + foo (); + if (b[0] != -2 || b[1] != 4) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98516-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98516-2.c new file mode 100644 index 0000000000..d8a09615cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98516-2.c @@ -0,0 +1,34 @@ +float a[8], b[4]; + +void __attribute__((noipa)) +foo () +{ + float a0 = a[0]; + float a1 = a[1]; + float a2 = a[2]; + float a3 = a[3]; + float a4 = a[4]; + float a5 = a[5]; + float a6 = a[6]; + float a7 = a[7]; + b[0] = a1 - a5; + b[1] = a0 + a4; + b[2] = a3 - a7; + b[3] = a2 + a6; +} + +int main() +{ + a[0] = 1.; + a[1] = 2.; + a[2] = 3.; + a[3] = 4.; + a[4] = 5.; + a[5] = 6.; + a[6] = 7.; + a[7] = 8.; + foo (); + if (b[0] != -4 || b[1] != 6 || b[2] != -4 || b[3] != 10) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98544.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98544.c new file mode 100644 index 0000000000..70a89f3a66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98544.c @@ -0,0 +1,30 @@ +double a[2], b[2], c[2], d[2]; + +void __attribute__((noipa)) +foo() +{ + double a0 = a[0]; + double a1 = a[1]; + double b0 = b[0]; + double b1 = b[1]; + double c0 = c[0]; + double c1 = c[1]; + double tem1 = a1 - b1; + double tem2 = a0 + b0; + d[0] = tem1 * c1; + d[1] = tem2 * c0; +} + +int main() +{ + a[0] = 1.; + a[1] = 2.; + b[0] = 3.; + b[1] = 4.; + c[0] = 2.; + c[1] = 3.; + foo (); + if (d[0] != -6. || d[1] != 8.) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98685.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98685.c new file mode 100644 index 0000000000..b213335da7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98685.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +char onelock_lock[16]; +void write(void); + +void lockit(int count) { + for (; count;) { + int pid, i; + char *p; + for (i = 0, p = (char *)&pid; i < sizeof 0; i++) + onelock_lock[i] = *p++; + write(); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98854.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98854.c new file mode 100644 index 0000000000..0c8141e1d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-pr98854.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +double a[1024]; + +int bar(); +void foo (int n) +{ + double x = 0, y = 0; + int i = 1023; + do + { + x += a[i] + a[i+1]; + y += a[i] / a[i+1]; + if (bar ()) + break; + } + while (--i); + /* We want to avoid vectorizing the LC PHI and insert vector CTORs + inside of the loop where it is only needed here. */ + a[0] = x; + a[1] = y; +} + +/* { dg-final { scan-tree-dump-not "vectorizing SLP node starting from: ._\[0-9\]+ = PHI" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-1.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-1.c new file mode 100644 index 0000000000..bea3b92ba7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-1.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_int } */ +/* PR tree-optimization/67682. */ + +#include "tree-vect.h" + +int __attribute__((__aligned__(8))) a[8]; +int __attribute__((__aligned__(8))) b[4]; + +__attribute__ ((noinline)) void +test () +{ + a[0] = b[0]; + a[1] = b[1]; + a[2] = b[2]; + a[3] = b[3]; + a[4] = 0; + a[5] = 0; + a[6] = 0; + a[7] = 0; +} + +int +main (int argc, char **argv) +{ + check_vect (); + + for (int i = 0; i < 8; i++) + a[i] = 1; + for (int i = 0; i < 4; i++) + b[i] = i + 4; + __asm__ volatile ("" : : : "memory"); + test (a, b); + __asm__ volatile ("" : : : "memory"); +#pragma GCC novector + for (int i = 0; i < 4; i++) + if (a[i] != i+4) + abort (); +#pragma GCC novector + for (int i = 4; i < 8; i++) + if (a[i] != 0) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-2.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-2.c new file mode 100644 index 0000000000..9431bcb9d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-2.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ +/* PR tree-optimization/67682. */ + +#include "tree-vect.h" + +int __attribute__((__aligned__(8))) a[8]; +int __attribute__((__aligned__(8))) b[4]; + +__attribute__ ((noinline)) void +test () +{ + a[0] = b[2] + 1; + a[1] = b[0] + 2; + a[2] = b[1] + 3; + a[3] = b[1] + 4; + a[4] = b[3] * 3; + a[5] = b[0] * 4; + a[6] = b[2] * 5; + a[7] = b[1] * 7; +} + +int +main (int argc, char **argv) +{ + check_vect (); + + for (int i = 0; i < 8; i++) + a[i] = 1; + for (int i = 0; i < 4; i++) + b[i] = i + 4; + __asm__ volatile ("" : : : "memory"); + test (a, b); + __asm__ volatile ("" : : : "memory"); + if ((a[0] != 7) || a[1] != 6 || (a[2] != 8) || (a[3] != 9) + || (a[4] != 21) || (a[5] != 16) || (a[6] != 30) || (a[7] != 35)) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target { ! vect256 } } } } */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target { vect256 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-3.c b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-3.c new file mode 100644 index 0000000000..fb719915db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/bb-slp-subgroups-3.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_int_mult } */ +/* PR tree-optimization/67682. */ + +#include "tree-vect.h" + +int __attribute__((__aligned__(8))) a[8]; +int __attribute__((__aligned__(8))) b[8]; + +__attribute__ ((noinline)) void +test () +{ + a[0] = b[0] + 1; + a[1] = b[1] + 2; + a[2] = b[2] + 3; + a[3] = b[3] + 4; + a[4] = b[0] * 3; + a[5] = b[2] * 4; + a[6] = b[4] * 5; + a[7] = b[6] * 7; +} + +int +main (int argc, char **argv) +{ + check_vect (); + + for (int i = 0; i < 8; i++) + a[i] = 1; + for (int i = 0; i < 8; i++) + b[i] = i + 4; + __asm__ volatile ("" : : : "memory"); + test (a, b); + __asm__ volatile ("" : : : "memory"); + if ((a[0] != 5) || (a[1] != 7) || (a[2] != 9) || (a[3] != 11) + || (a[4] != 12) || (a[5] != 24) || (a[6] != 40) || (a[7] != 70)) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */ +/* Because we disable the cost model, targets with variable-length + vectors can end up vectorizing the store to a[0..7] on its own. + With the cost model we do something sensible. */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target { ! amdgcn-*-* } xfail vect_variable_length } } } */ + +/* amdgcn can do this in one vector. */ +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target amdgcn-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-int.c b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-int.c new file mode 100644 index 0000000000..cead05f1cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-int.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +#define TYPE int32_t +#define N 16 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_byte } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_int } && ! target { aarch64_sve2 } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-long.c b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-long.c new file mode 100644 index 0000000000..0d21f57666 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-long.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_long } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define UNROLL + +#define TYPE int64_t +#define N 16 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_long } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_long } && ! target { aarch64_sve2 } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" { target { vect_long_long } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" { target { vect_long_long } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" { target { vect_long_long } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-short.c b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-short.c new file mode 100644 index 0000000000..8928386a51 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-short.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define UNROLL + +#define TYPE int16_t +#define N 16 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_short } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_short } && ! target { aarch64_sve2 } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-int.c b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-int.c new file mode 100644 index 0000000000..4ab4b9a446 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-int.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define UNROLL + +#define TYPE uint32_t +#define N 16 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_int } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_int } && ! target { aarch64_sve2 } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-long.c b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-long.c new file mode 100644 index 0000000000..38aa9c0b9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-long.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define UNROLL + +#define TYPE uint64_t +#define N 16 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_long } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_long } && ! target { aarch64_sve2 } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" { target { vect_long_long } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" { target { vect_long_long } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-short.c b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-short.c new file mode 100644 index 0000000000..8846c9889f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/bb-slp-complex-add-pattern-unsigned-short.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define UNROLL + +#define TYPE uint16_t +#define N 16 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_short } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_short } && ! target { aarch64_sve2 } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/complex-add-pattern-template.c b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-add-pattern-template.c new file mode 100644 index 0000000000..658af294f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-add-pattern-template.c @@ -0,0 +1,75 @@ +void add90 (TYPE a[restrict N], TYPE b[restrict N], TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i+=2) + { + c[i] = a[i] - b[i+1]; + c[i+1] = a[i+1] + b[i]; + } +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ + +void add270 (TYPE a[restrict N], TYPE b[restrict N], TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i+=2) + { + c[i] = a[i] + b[i+1]; + c[i+1] = a[i+1] - b[i]; + } +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ + +void addMixed (TYPE a[restrict N], TYPE b[restrict N], TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i+=4) + { + c[i] = a[i] - b[i+1]; + c[i+1] = a[i+1] + b[i]; + c[i+2] = a[i+2] + b[i+3]; + c[i+3] = a[i+3] - b[i+2]; + } +} + +void add90HandUnrolled (TYPE a[restrict N], TYPE b[restrict N], + TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < (N /2); i+=4) + { + c[i] = a[i] - b[i+1]; + c[i+2] = a[i+2] - b[i+3]; + c[i+1] = a[i+1] + b[i]; + c[i+3] = a[i+3] + b[i+2]; + } +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ + +void add90Hybrid (TYPE a[restrict N], TYPE b[restrict N], TYPE c[restrict N], + TYPE d[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i+=2) + { + c[i] = a[i] - b[i+1]; + c[i+1] = a[i+1] + b[i]; + d[i] = a[i] - b[i]; + d[i+1] = a[i+1] - b[i+1]; + } +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/complex-add-template.c b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-add-template.c new file mode 100644 index 0000000000..f37ab98813 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-add-template.c @@ -0,0 +1,109 @@ +#include + +void add0 (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = a[i] + b[i]; +} + +void add90snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I); +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ + +void add180snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I * I); +} + +void add270snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I * I * I); +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ + +void add90fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = (a[i] * I) + b[i]; +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ + +void add180fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = (a[i] * I * I) + b[i]; +} + +void add270fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = (a[i] * I * I * I) + b[i]; +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ + +void addconjfst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = ~a[i] + b[i]; +} + +void addconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = a[i] + ~b[i]; +} + +void addconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = ~a[i] + ~b[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mla-template.c b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mla-template.c new file mode 100644 index 0000000000..4b5c42b29f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mla-template.c @@ -0,0 +1,101 @@ +#include + +void fma0 (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i]; +} + +void fma90snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I); +} + +void fma180snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I * I); +} + +void fma270snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I * I * I); +} + +void fma90fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += (a[i] * I) * b[i]; +} + +void fma180fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += (a[i] * I * I) * b[i]; +} + +void fma270fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += (a[i] * I * I * I) * b[i]; +} + +void fmaconjfst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += ~a[i] * b[i]; +} + +void fmaconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * ~b[i]; +} + +void fmaconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += ~a[i] * ~b[i]; +} + +void fma_elem (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b; +} + + +void fma_elemconjfst (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += ~a[i] * b; +} + +void fma_elemconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * ~b; +} + +void fma_elemconjboth (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += ~a[i] * ~b; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mls-template.c b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mls-template.c new file mode 100644 index 0000000000..1954be8b06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mls-template.c @@ -0,0 +1,101 @@ +#include + +void fms0 (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i]; +} + +void fms90snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I); +} + +void fms180snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I * I); +} + +void fms270snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I * I * I); +} + +void fms90fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= (a[i] * I) * b[i]; +} + +void fms180fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= (a[i] * I * I) * b[i]; +} + +void fms270fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= (a[i] * I * I * I) * b[i]; +} + +void fmsconjfst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= ~a[i] * b[i]; +} + +void fmsconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * ~b[i]; +} + +void fmsconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= ~a[i] * ~b[i]; +} + +void fms_elem (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b; +} + + +void fms_elemconjfst (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= ~a[i] * b; +} + +void fms_elemconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * ~b; +} + +void fms_elemconjboth (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= ~a[i] * ~b; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mul-template.c b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mul-template.c new file mode 100644 index 0000000000..770565c450 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-mul-template.c @@ -0,0 +1,71 @@ +#include + +void mul0 (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i]; +} + +void mul90snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I); +} + +void mul180snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I * I); +} + +void mul270snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I * I * I); +} + +void mul90fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I) * b[i]; +} + +void mul180fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I * I) * b[i]; +} + +void mul270fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I * I * I) * b[i]; +} + +void mulconjfst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = ~a[i] * b[i]; +} + +void mulconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * ~b[i]; +} + +void mulconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = ~a[i] * ~b[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/complex-operations-run.c b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-operations-run.c new file mode 100644 index 0000000000..14ac512a8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-operations-run.c @@ -0,0 +1,103 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#include +#include +#include +#include +#include + +#define PREF old +#pragma GCC push_options +#pragma GCC optimize ("no-tree-vectorize") +# include "complex-operations.c" +#pragma GCC pop_options +#undef PREF + +#define PREF new +# include "complex-operations.c" +#undef PREF + +#define TYPE double +#define TYPE2 double +#define EP pow(2, -45) + +#define xstr(s) str(s) +#define str(s) #s + +#define FCMP(A, B) \ + ((fabs (creal (A) - creal (B)) <= EP) && (fabs (cimag (A) - cimag (B)) <= EP)) + +#define CMP(A, B) \ + (FCMP(A,B) ? "PASS" : "FAIL") + +#define COMPARE(A,B) \ + memset (&c1, 0, sizeof (c1)); \ + memset (&c2, 0, sizeof (c2)); \ + A; B; \ + if (!FCMP(c1[0],c2[0]) || !FCMP(c1[1], c2[1])) \ + { \ + printf ("=> %s vs %s\n", xstr (A), xstr (B)); \ + printf ("%a\n", creal (c1[0]) - creal (c2[0])); \ + printf ("%a\n", cimag (c1[1]) - cimag (c2[1])); \ + printf ("%.2f+%.2fI == %.2f+%.2fI (%s)\n", creal (c1[0]), cimag (c1[0]), creal (c2[0]), cimag (c2[0]), CMP (c1[0], c2[0])); \ + printf ("%.2f+%.2fI == %.2f+%.2fI (%s)\n", creal (c1[1]), cimag (c1[1]), creal (c2[1]), cimag (c2[1]), CMP (c1[1], c2[1])); \ + printf ("\n"); \ + __builtin_abort (); \ + } + +int main () +{ + TYPE2 complex a[] = { 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I }; + TYPE complex b[] = { 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I }; + TYPE complex c2[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + TYPE complex c1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + TYPE diff1, diff2; + + COMPARE(fma0_old(a, b, c1), fma0_new(a, b, c2)); + COMPARE(fma90_old(a, b, c1), fma90_new(a, b, c2)); + COMPARE(fma180_old(a, b, c1), fma180_new(a, b, c2)); + COMPARE(fma270_old(a, b, c1), fma270_new(a, b, c2)); + COMPARE(fma0_snd_old(a, b, c1), fma0_snd_new(a, b, c2)); + COMPARE(fma90_snd_old(a, b, c1), fma90_snd_new(a, b, c2)); + COMPARE(fma180_snd_old(a, b, c1), fma180_snd_new(a, b, c2)); + COMPARE(fma270_snd_old(a, b, c1), fma270_snd_new(a, b, c2)); + COMPARE(fma_conj_first_old(a, b, c1), fma_conj_first_new(a, b, c2)); + COMPARE(fma_conj_second_old(a, b, c1), fma_conj_second_new(a, b, c2)); + COMPARE(fma_conj_both_old(a, b, c1), fma_conj_both_new(a, b, c2)); + COMPARE(fms0_old(a, b, c1), fms0_new(a, b, c2)); + COMPARE(fms90_old(a, b, c1), fms90_new(a, b, c2)); + COMPARE(fms180_old(a, b, c1), fms180_new(a, b, c2)); + COMPARE(fms270_old(a, b, c1), fms270_new(a, b, c2)); + COMPARE(fms0_snd_old(a, b, c1), fms0_snd_new(a, b, c2)); + COMPARE(fms90_snd_old(a, b, c1), fms90_snd_new(a, b, c2)); + COMPARE(fms180_snd_old(a, b, c1), fms180_snd_new(a, b, c2)); + COMPARE(fms270_snd_old(a, b, c1), fms270_snd_new(a, b, c2)); + COMPARE(fms_conj_first_old(a, b, c1), fms_conj_first_new(a, b, c2)); + COMPARE(fms_conj_second_old(a, b, c1), fms_conj_second_new(a, b, c2)); + COMPARE(fms_conj_both_old(a, b, c1), fms_conj_both_new(a, b, c2)); + COMPARE(mul0_old(a, b, c1), mul0_new(a, b, c2)); + COMPARE(mul90_old(a, b, c1), mul90_new(a, b, c2)); + COMPARE(mul180_old(a, b, c1), mul180_new(a, b, c2)); + COMPARE(mul270_old(a, b, c1), mul270_new(a, b, c2)); + COMPARE(mul0_snd_old(a, b, c1), mul0_snd_new(a, b, c2)); + COMPARE(mul90_snd_old(a, b, c1), mul90_snd_new(a, b, c2)); + COMPARE(mul180_snd_old(a, b, c1), mul180_snd_new(a, b, c2)); + COMPARE(mul270_snd_old(a, b, c1), mul270_snd_new(a, b, c2)); + COMPARE(mul_conj_first_old(a, b, c1), mul_conj_first_new(a, b, c2)); + COMPARE(mul_conj_second_old(a, b, c1), mul_conj_second_new(a, b, c2)); + COMPARE(mul_conj_both_old(a, b, c1), mul_conj_both_new(a, b, c2)); + COMPARE(add0_old(a, b, c1), add0_new(a, b, c2)); + COMPARE(add90_old(a, b, c1), add90_new(a, b, c2)); + COMPARE(add180_old(a, b, c1), add180_new(a, b, c2)); + COMPARE(add270_old(a, b, c1), add270_new(a, b, c2)); + COMPARE(add0_snd_old(a, b, c1), add0_snd_new(a, b, c2)); + COMPARE(add90_snd_old(a, b, c1), add90_snd_new(a, b, c2)); + COMPARE(add180_snd_old(a, b, c1), add180_snd_new(a, b, c2)); + COMPARE(add270_snd_old(a, b, c1), add270_snd_new(a, b, c2)); + COMPARE(add_conj_first_old(a, b, c1), add_conj_first_new(a, b, c2)); + COMPARE(add_conj_second_old(a, b, c1), add_conj_second_new(a, b, c2)); + COMPARE(add_conj_both_old(a, b, c1), add_conj_both_new(a, b, c2)); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/complex-operations.c b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-operations.c new file mode 100644 index 0000000000..fdce995481 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/complex-operations.c @@ -0,0 +1,358 @@ +#include +#include + +#ifndef PREF +#define PREF c +#endif + +#define FX(N,P) P ## _ ## N +#define MK(N,P) FX(P,N) + +#define N 32 +#define TYPE double + +// ------ FMA + +// Complex FMA instructions rotating the result + +__attribute__((noinline,noipa)) +void MK(fma0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fma90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i] * I; +} + +__attribute__((noinline,noipa)) +void MK(fma180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i] * I * I; +} + +__attribute__((noinline,noipa)) +void MK(fma270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i] * I * I * I; +} + +// Complex FMA instructions rotating the second parameter. + + +__attribute__((noinline,noipa)) +void MK(fma0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fma90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I); +} + +__attribute__((noinline,noipa)) +void MK(fma180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I * I); +} + +__attribute__((noinline,noipa)) +void MK(fma270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I * I * I); +} + +// Complex FMA instructions with conjucated values. + + +__attribute__((noinline,noipa)) +void MK(fma_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += conj (a[i]) * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fma_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * conj (b[i]); +} + +__attribute__((noinline,noipa)) +void MK(fma_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += conj (a[i]) * conj (b[i]); +} + +// ----- FMS + +// Complex FMS instructions rotating the result + +__attribute__((noinline,noipa)) +void MK(fms0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fms90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i] * I; +} + +__attribute__((noinline,noipa)) +void MK(fms180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i] * I * I; +} + +__attribute__((noinline,noipa)) +void MK(fms270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i] * I * I * I; +} + +// Complex FMS instructions rotating the second parameter. + +__attribute__((noinline,noipa)) +void MK(fms0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fms90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I); +} + +__attribute__((noinline,noipa)) +void MK(fms180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I * I); +} + +__attribute__((noinline,noipa)) +void MK(fms270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I * I * I); +} + +// Complex FMS instructions with conjucated values. + +__attribute__((noinline,noipa)) +void MK(fms_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= conj (a[i]) * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fms_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * conj (b[i]); +} + +__attribute__((noinline,noipa)) +void MK(fms_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= conj (a[i]) * conj (b[i]); +} + + +// ----- MUL + +// Complex MUL instructions rotating the result + +__attribute__((noinline,noipa)) +void MK(mul0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(mul90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i] * I; +} + +__attribute__((noinline,noipa)) +void MK(mul180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i] * I * I; +} + +__attribute__((noinline,noipa)) +void MK(mul270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i] * I * I * I; +} + +// Complex MUL instructions rotating the second parameter. + +__attribute__((noinline,noipa)) +void MK(mul0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(mul90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I); +} + +__attribute__((noinline,noipa)) +void MK(mul180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I * I); +} + +__attribute__((noinline,noipa)) +void MK(mul270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I * I * I); +} + +// Complex FMS instructions with conjucated values. + +__attribute__((noinline,noipa)) +void MK(mul_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = conj (a[i]) * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(mul_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * conj (b[i]); +} + +__attribute__((noinline,noipa)) +void MK(mul_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = conj (a[i]) * conj (b[i]); +} + + +// ----- ADD + +// Complex ADD instructions rotating the result + +__attribute__((noinline,noipa)) +void MK(add0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + b[i]; +} + +__attribute__((noinline,noipa)) +void MK(add90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] + b[i]) * I; +} + +__attribute__((noinline,noipa)) +void MK(add180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] + b[i]) * I * I; +} + +__attribute__((noinline,noipa)) +void MK(add270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] + b[i]) * I * I * I; +} + +// Complex ADD instructions rotating the second parameter. + +__attribute__((noinline,noipa)) +void MK(add0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + b[i]; +} + +__attribute__((noinline,noipa)) +void MK(add90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I); +} + +__attribute__((noinline,noipa)) +void MK(add180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I * I); +} + +__attribute__((noinline,noipa)) +void MK(add270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I * I * I); +} + +// Complex ADD instructions with conjucated values. + +__attribute__((noinline,noipa)) +void MK(add_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = conj (a[i]) + b[i]; +} + +__attribute__((noinline,noipa)) +void MK(add_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + conj (b[i]); +} + +__attribute__((noinline,noipa)) +void MK(add_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = conj (a[i]) + conj (b[i]); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/complex.exp b/SingleSource/Regression/C/gcc-dg/vect/complex/complex.exp new file mode 100644 index 0000000000..efd018f697 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/complex.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_file $srcdir/$subdir/../vect.exp diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-double.c new file mode 100644 index 0000000000..2e611b77c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-double.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +#define UNROLL + +#define TYPE double +#define N 16 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_double } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_double } } } } */ + +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-float.c new file mode 100644 index 0000000000..1e63a5f2c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-float.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +#define UNROLL + +#define TYPE float +#define N 16 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_float } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_float } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c new file mode 100644 index 0000000000..0ae49c1643 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-add-template.c" + +/* Vectorization is failing for these cases. They should work but for now ignore. */ + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-double.c new file mode 100644 index 0000000000..3f5619b78c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-double.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define UNROLL + +#define TYPE double +#define N 16 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_double } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_double } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-float.c new file mode 100644 index 0000000000..a961a85277 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-float.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +#define UNROLL + +#define TYPE float +#define N 16 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_float } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_float } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c new file mode 100644 index 0000000000..e30df0ff0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ + +#define UNROLL + +#define TYPE _Float16 +#define N 16 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { target { vect_complex_add_half } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { target { vect_complex_add_half } && ! target { arm*-*-* } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-double.c new file mode 100644 index 0000000000..b77c847403 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-double.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-fdump-tree-vect-details" } */ + +#define TYPE double +#define N 16 +#include "complex-mla-template.c" + +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-float.c new file mode 100644 index 0000000000..cd68fd1900 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-float.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-additional-options "-fdump-tree-vect-details" } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE float +#define N 16 +#include "complex-mla-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c new file mode 100644 index 0000000000..510092028d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-mla-template.c" + +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "slp1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "slp1" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-double.c new file mode 100644 index 0000000000..9d9839417a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-double.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-fdump-tree-vect-details" } */ + +#define TYPE double +#define N 16 +#include "complex-mls-template.c" + +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-float.c new file mode 100644 index 0000000000..cf540a08ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-additional-options "-fdump-tree-vect-details" } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE float +#define N 16 +#include "complex-mls-template.c" + +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c new file mode 100644 index 0000000000..217401bae5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-mls-template.c" + +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "slp1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "slp1" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-double.c new file mode 100644 index 0000000000..dcac519cd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-double.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-fdump-tree-vect-details" } */ + +#define TYPE double +#define N 16 +#include "complex-mul-template.c" + +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-float.c new file mode 100644 index 0000000000..27280ae2ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE float +#define N 16 +#include "complex-mul-template.c" + +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "slp1" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c new file mode 100644 index 0000000000..309b168dfb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-additional-options "-fno-tree-loop-vectorize" } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-mul-template.c" + +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "slp1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "slp1" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-double.c new file mode 100644 index 0000000000..5cff373b80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-double.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE double +#define N 200 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_double } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_double } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-float.c new file mode 100644 index 0000000000..312df88ee6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-float.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE float +#define N 200 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_float } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_float } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-half-float.c new file mode 100644 index 0000000000..046f014240 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-half-float.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-add-template.c" + +/* Vectorization is failing for these cases. They should work but for now ignore. */ + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-double.c new file mode 100644 index 0000000000..9c8b99bc00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-double.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE double +#define N 200 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_double } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_double } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-float.c new file mode 100644 index 0000000000..ca5f5b257d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-float.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE float +#define N 200 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_float } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_float } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-half-float.c new file mode 100644 index 0000000000..c6617f5dad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-add-pattern-half-float.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_half } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_half } && ! target { arm*-*-* } } } } */ + +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-double.c new file mode 100644 index 0000000000..3ec46e5cf6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-double.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE double +#define N 200 +#include "complex-mla-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-float.c new file mode 100644 index 0000000000..af59323023 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-float.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE float +#define N 200 +#include "complex-mla-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-half-float.c new file mode 100644 index 0000000000..7beb6b8b5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mla-half-float.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-mla-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-double.c new file mode 100644 index 0000000000..fc4cd6151c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-double.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE double +#define N 200 +#include "complex-mls-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-float.c new file mode 100644 index 0000000000..a931ca6138 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE float +#define N 200 +#include "complex-mls-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-half-float.c new file mode 100644 index 0000000000..dd153e4990 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mls-half-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-mls-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-double.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-double.c new file mode 100644 index 0000000000..b6b21529a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-double.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE double +#define N 200 +#include "complex-mul-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-float.c new file mode 100644 index 0000000000..aa8efb4c2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-float.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE float +#define N 200 +#include "complex-mul-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-half-float.c b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-half-float.c new file mode 100644 index 0000000000..5133162574 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/fast-math-complex-mul-half-float.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-require-effective-target float16 } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-mul-template.c" +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL_CONJ" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-1.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-1.c new file mode 100644 index 0000000000..ae16b8956a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +float f[12][100]; + +void bad1(float v1, float v2) +{ + for (int r = 0; r < 100; r += 4) + { + int i = r + 1; + f[0][r] = f[1][r] * (f[2][r] + v2) - f[1][i] * (f[2][i] + v1); + f[0][i] = f[1][r] * (f[2][i] + v1) + f[1][i] * (f[2][r] + v2); + f[0][r+2] = f[1][r+2] * (f[2][r+2] + v2) - f[1][i+2] * (f[2][i+2] + v1); + f[0][i+2] = f[1][r+2] * (f[2][i+2] + v1) + f[1][i+2] * (f[2][r+2] + v2); + // ^^^^^^^ ^^^^^^^ + } +} + +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" { target { vect_float } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-2.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-2.c new file mode 100644 index 0000000000..aeee34d40a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +float f[12][100]; + +void bad1(float v1, float v2) +{ + for (int r = 0; r < 100; r += 2) + { + int i = r + 1; + f[0][r] = f[1][r] * (f[2][r] + v1) - f[1][i] * (f[2][i] + v2); + f[0][i] = f[1][r] * (f[2][i] + v1) + f[1][i] * (f[2][r] + v2); + } +} + +/* { dg-final { scan-tree-dump-not "Found COMPLEX_MUL" "vect" { target { vect_float } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-3.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-3.c new file mode 100644 index 0000000000..210540bd18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +float f[12][100]; + +void good1(float v1, float v2) +{ + for (int r = 0; r < 100; r += 2) + { + int i = r + 1; + f[0][r] = f[1][r] * (f[2][r] + v2) - f[1][i] * (f[2][i] + v1); + f[0][i] = f[1][r] * (f[2][i] + v1) + f[1][i] * (f[2][r] + v2); + } +} + +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" { target { vect_float } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-4.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-4.c new file mode 100644 index 0000000000..b4c3d9ece5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +float f[12][100]; + +void good1() +{ + for (int r = 0; r < 100; r += 2) + { + int i = r + 1; + f[0][r] = f[1][r] * f[2][r] - f[1][i] * f[2][i]; + f[0][i] = f[1][r] * f[2][i] + f[1][i] * f[2][r]; + } +} + +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" { target { vect_float } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-5.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-5.c new file mode 100644 index 0000000000..34bec587aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-5.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +float f[12][100]; + +void good2() +{ + for (int r = 0; r < 100; r += 2) + { + int i = r + 1; + f[0][r] = f[1][r] * (f[2][r] + 1) - f[1][i] * (f[2][i] + 1); + f[0][i] = f[1][r] * (f[2][i] + 1) + f[1][i] * (f[2][r] + 1); + } +} + +/* { dg-final { scan-tree-dump "Found COMPLEX_MUL" "vect" { target { vect_float } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-6.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-6.c new file mode 100644 index 0000000000..8da0d867f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-6.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +float f[12][100]; + +void bad1() +{ + for (int r = 0; r < 100; r += 2) + { + int i = r + 1; + f[0][r] = f[1][r] * f[2][r] - f[1][i] * f[3][i]; + f[0][i] = f[1][r] * f[2][i] + f[1][i] * f[3][r]; + // ^^^^^^^ ^^^^^^^ + } +} + +/* { dg-final { scan-tree-dump-not "Found COMPLEX_MUL" "vect" { target { vect_float } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-7.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-7.c new file mode 100644 index 0000000000..bac9cc1ce5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-7.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +float f[12][100]; + +void bad2() +{ + for (int r = 0; r < 100; r += 2) + { + int i = r + 1; + f[0][r] = f[1][r] * (f[2][r] + 1) - f[1][i] * f[2][i]; + f[0][i] = f[1][r] * (f[2][i] + 1) + f[1][i] * f[2][r]; + // ^^^^ + } +} + +/* { dg-final { scan-tree-dump-not "Found COMPLEX_MUL" "vect" { target { vect_float } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-8.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-8.c new file mode 100644 index 0000000000..ce70292e96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-8.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +float f[12][100]; + +void bad3() +{ + for (int r = 0; r < 100; r += 2) + { + int i = r + 1; + f[0][r] = f[1][r] * f[2][r] - f[1][r] * f[2][i]; + f[0][i] = f[1][r] * f[2][i] + f[1][i] * f[2][r]; + // ^^^^^^^ + } +} + +/* { dg-final { scan-tree-dump-not "Found COMPLEX_MUL" "vect" { target { vect_float } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-9.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-9.c new file mode 100644 index 0000000000..a513821b12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr102819-9.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#include +#include + +#define N 200 +#define TYPE float +#define TYPE2 float + +void g (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + { + c[i] -= a[i] * b[0]; + } +} + +/* The pattern overlaps with COMPLEX_ADD so we need to support consuming ADDs in COMPLEX_FMS. */ + +/* { dg-final { scan-tree-dump "Found COMPLEX_FMS" "vect" { xfail { vect_float } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/pr103169.c b/SingleSource/Regression/C/gcc-dg/vect/complex/pr103169.c new file mode 100644 index 0000000000..1bfabbd85a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/pr103169.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target { vect_double } } } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-additional-options "-O2 -fvect-cost-model=unlimited" } */ + +_Complex double b_0, c_0; + +void +mul270snd (void) +{ + c_0 = b_0 * 1.0iF * 1.0iF; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-byte.c b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-byte.c new file mode 100644 index 0000000000..bf7c135fa1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-byte.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE int8_t +#define N 200 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_byte } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_byte } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-int.c b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-int.c new file mode 100644 index 0000000000..2fd2a9f061 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-int.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE int32_t +#define N 200 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_int } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_int } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-long.c b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-long.c new file mode 100644 index 0000000000..7097715525 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-long.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define UNROLL + +#define TYPE int64_t +#define N 200 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_long } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_long } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" { target { vect_long_long } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" { target { vect_long_long } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-short.c b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-short.c new file mode 100644 index 0000000000..8cbb8ac0c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-short.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE int16_t +#define N 200 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_short } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_short } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-byte.c b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-byte.c new file mode 100644 index 0000000000..9477f0d92d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-byte.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE uint8_t +#define N 200 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_byte } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_byte } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-int.c b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-int.c new file mode 100644 index 0000000000..41f60042ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-int.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE uint32_t +#define N 200 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_int } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_int } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-long.c b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-long.c new file mode 100644 index 0000000000..7708ac495b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-long.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define UNROLL + +#define TYPE uint64_t +#define N 200 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_long } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_long } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" { target { vect_long_long } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" { target { vect_long_long } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-short.c b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-short.c new file mode 100644 index 0000000000..6260be4d12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/complex/vect-complex-add-pattern-unsigned-short.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ + +#define TYPE uint16_t +#define N 200 +#include +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" { target { vect_complex_add_short } } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" { target { vect_complex_add_short } } } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT270" "vect" } } */ +/* { dg-final { scan-tree-dump "Found COMPLEX_ADD_ROT90" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c new file mode 100644 index 0000000000..6bce4ea092 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/costmodel-fast-math-vect-pr29925.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "../../tree-vect.h" + +__attribute__ ((noinline)) void +interp_pitch(float *exc, float *interp, int pitch, int len) +{ + int i,k; + int maxj; + + maxj=3; + for (i=0;i +#include "../../tree-vect.h" + +#define N 32 + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +struct s tmp = { 1 }; + +int main1 () +{ + int i; + + /* unaligned */ + for (i = 0; i < N/2; i++) + { + tmp.b[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +#define N 16 +struct test { + char ca[N]; +}; + +extern struct test s; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/costmodel-vect-68.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/costmodel-vect-68.c new file mode 100644 index 0000000000..cfe7b85368 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/costmodel-vect-68.c @@ -0,0 +1,91 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "../../tree-vect.h" + +#define N 32 + +struct s{ + int m; + int n[N][N][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e; /* array e.n is aligned */ +}; + +int main1 () +{ + int i,j; + struct test1 tmp1; + + /* 1. unaligned */ + for (i = 0; i < N; i++) + { + tmp1.a.n[1][2][i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +#define N 16 +#define DIFF 242 + +unsigned char ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +void +main1 (unsigned char x, unsigned char max_result, unsigned char min_result) +{ + int i; + unsigned char udiff = 2; + unsigned char umax = x; + unsigned char umin = x; + + for (i = 0; i < N; i++) { + udiff += (unsigned char)(ub[i] - uc[i]); + } + + for (i = 0; i < N; i++) { + umax = umax < uc[i] ? uc[i] : umax; + } + + for (i = 0; i < N; i++) { + umin = umin > uc[i] ? uc[i] : umin; + } + + /* check results: */ + if (udiff != DIFF) + abort (); + if (umax != max_result) + abort (); + if (umin != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ +/* { dg-final { scan-tree-dump-times "vectorization not profitable" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/i386-costmodel-vect.exp b/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/i386-costmodel-vect.exp new file mode 100644 index 0000000000..4f27bb1f81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/i386/i386-costmodel-vect.exp @@ -0,0 +1,74 @@ +# Copyright (C) 1997-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp + +# Exit immediately if this isn't a x86 target. +if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then { + return +} + +# Set up flags used for tests that don't specify options. +set DEFAULT_VECTCFLAGS "" + +# These flags are used for all targets. +lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fvect-cost-model=dynamic" + +# If the target system supports vector instructions, the default action +# for a test is 'run', otherwise it's 'compile'. Save current default. +# Executing vector instructions on a system without hardware vector support +# is also disabled by a call to check_vect, but disabling execution here is +# more efficient. +global dg-do-what-default +set save-dg-do-what-default ${dg-do-what-default} + +if { ![check_effective_target_sse2] } then { + return +} +lappend DEFAULT_VECTCFLAGS "-msse2" +if [check_sse2_hw_available] { + set dg-do-what-default run +} else { + set dg-do-what-default compile +} + +# Initialize `dg'. +dg-init + +lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-vect-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +#### Tests with special options +global SAVED_DEFAULT_VECTCFLAGS +set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS + +# -ffast-math tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-ffast-math" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-fast-math-vect*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# Clean up. +set dg-do-what-default ${save-dg-do-what-default} + +# All done. +dg-finish diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c new file mode 100644 index 0000000000..d9f173b521 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#define N 16 + +const unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +unsigned int out[N]; + +__attribute__ ((noinline)) int +main1 (void) +{ + const unsigned int *pin = &in[1]; + unsigned int *pout = &out[0]; + + /* Misaligned load. */ + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + + return 0; +} + +/* Verify that the assembly contains vector instructions alone + with no word loads (lw, lwu, lwz, lwzu, or their indexed forms) + or word stores (stw, stwu, stwx, stwux, or their indexed forms). */ + +/* { dg-final { scan-assembler "\t(lvx|lxv|lvsr|stxv|plxv|pstxv)" } } */ +/* { dg-final { scan-assembler-not "\tlwz?u?x? " { xfail { powerpc-ibm-aix* } } } } */ +/* { dg-final { scan-assembler-not "\tstwu?x? " } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-bb-slp-9a.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-bb-slp-9a.c new file mode 100644 index 0000000000..df0191815a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-bb-slp-9a.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_int } */ + +#include "../../tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (void) +{ + unsigned int *pin = &in[1]; + unsigned int *pout = &out[0]; + + /* Misaligned load. */ + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + *pout++ = *pin++; + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + /* Check results. */ + if (out[0] != in[1] + || out[1] != in[2] + || out[2] != in[3] + || out[3] != in[4]) + abort(); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-fast-math-vect-pr29925.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-fast-math-vect-pr29925.c new file mode 100644 index 0000000000..34445dc6e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-fast-math-vect-pr29925.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "../../tree-vect.h" + +__attribute__ ((noinline)) void +interp_pitch(float *exc, float *interp, int pitch, int len) +{ + int i,k; + int maxj; + + maxj=3; + for (i=0;i +#include "../../tree-vect.h" + +__attribute__ ((noinline)) void +ggSpectrum_Set8(float * data, float d) +{ + int i; + + /* PR92127, disable unroll to avoid unexpected profit calculation. */ + #pragma GCC unroll 0 + for (i = 0; i < 8; i++) + data[i] = d; +} + +__attribute__ ((noinline)) void +ggSpectrum_Set20(float * data, float d) +{ + int i; + + for (i = 0; i < 20; i++) + data[i] = d; +} + +/* { dg-final { scan-tree-dump-times "vectorization not profitable" 1 "vect" { target { ! vect_hw_misalign } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! vect_hw_misalign } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-pr82255.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-pr82255.c new file mode 100644 index 0000000000..9317ee2e15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-pr82255.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +/* PR82255: Ensure we don't require a vec_construct cost when we aren't + going to generate a strided load. */ + +extern int abs (int __x) __attribute__ ((__nothrow__, __leaf__)) +__attribute__ ((__const__)); + +static int +foo (unsigned char *w, int i, unsigned char *x, int j) +{ + int tot = 0; + for (int a = 0; a < 16; a++) + { +#pragma GCC unroll 16 + for (int b = 0; b < 16; b++) + tot += abs (w[b] - x[b]); + w += i; + x += j; + } + return tot; +} + +void +bar (unsigned char *w, unsigned char *x, int i, int *result) +{ + *result = foo (w, 16, x, i); +} + +/* { dg-final { scan-tree-dump-times "vec_construct" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-12.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-12.c new file mode 100644 index 0000000000..9e57cae975 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-12.c @@ -0,0 +1,121 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "../../tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + float out2[N*8], fa[N*4]; + unsigned int ia[N], ib[N*2]; + + for (i = 0; i < N; i++) + { + + a0 = in[i*8] + 5; + a1 = in[i*8 + 1] + 6; + a2 = in[i*8 + 2] + 7; + a3 = in[i*8 + 3] + 8; + a4 = in[i*8 + 4] + 9; + a5 = in[i*8 + 5] + 10; + a6 = in[i*8 + 6] + 11; + a7 = in[i*8 + 7] + 12; + + b0 = a0 * 3; + b1 = a1 * 2; + b2 = a2 * 12; + b3 = a3 * 5; + b4 = a4 * 8; + b5 = a5 * 4; + b6 = a6 * 3; + b7 = a7 * 2; + + out[i*8] = b0 - 2; + out[i*8 + 1] = b1 - 3; + out[i*8 + 2] = b2 - 2; + out[i*8 + 3] = b3 - 1; + out[i*8 + 4] = b4 - 8; + out[i*8 + 5] = b5 - 7; + out[i*8 + 6] = b6 - 3; + out[i*8 + 7] = b7 - 7; + + ia[i] = b6; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (in[i*8] + 5) * 3 - 2 + || out[i*8 + 1] != (in[i*8 + 1] + 6) * 2 - 3 + || out[i*8 + 2] != (in[i*8 + 2] + 7) * 12 - 2 + || out[i*8 + 3] != (in[i*8 + 3] + 8) * 5 - 1 + || out[i*8 + 4] != (in[i*8 + 4] + 9) * 8 - 8 + || out[i*8 + 5] != (in[i*8 + 5] + 10) * 4 - 7 + || out[i*8 + 6] != (in[i*8 + 6] + 11) * 3 - 3 + || out[i*8 + 7] != (in[i*8 + 7] + 12) * 2 - 7 + || ia[i] != (in[i*8 + 6] + 11) * 3) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = (in[i*4] + 2) * 3; + out[i*4 + 1] = (in[i*4 + 1] + 2) * 7; + out[i*4 + 2] = (in[i*4 + 2] + 7) * 3; + out[i*4 + 3] = (in[i*4 + 3] + 7) * 7; + + ib[i] = 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != (in[i*4] + 2) * 3 + || out[i*4 + 1] != (in[i*4 + 1] + 2) * 7 + || out[i*4 + 2] != (in[i*4 + 2] + 7) * 3 + || out[i*4 + 3] != (in[i*4 + 3] + 7) * 7 + || ib[i] != 7) + abort (); + } + + for (i = 0; i < N*4; i++) + { + out2[i*2] = (float) (in[i*2] * 2 + 11) ; + out2[i*2 + 1] = (float) (in[i*2 + 1] * 3 + 7); + + fa[i] = (float) in[i*2+1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*4; i++) + { + if (out2[i*2] != (float) (in[i*2] * 2 + 11) + || out2[i*2 + 1] != (float) (in[i*2 + 1] * 3 + 7) + || fa[i] != (float) in[i*2+1]) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" {target { vect_strided8 && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" {target { vect_strided8 && vect_int_mult } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-33.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-33.c new file mode 100644 index 0000000000..4afbeea992 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-33.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "../../tree-vect.h" + +#define N 32 + +struct s{ + short a; /* aligned */ + char b[N-1]; /* unaligned (offset 2B) */ +}; + +int main1 () +{ + int i; + struct s tmp; + + /* unaligned */ + for (i = 0; i < N/4; i++) + { + tmp.b[2*i] = 5; + tmp.b[2*i+1] = 15; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +struct mystr { + int f1; + int f2; +}; + +struct mystr af[16] = { + 10, 11, 12, 13, 14, 15, 16, 17, + 20, 21, 22, 23, 24, 25, 26, 27, + 30, 31, 32, 33, 34, 35, 36, 37, + 40, 41, 42, 43, 44, 45, 46, 47 +}; + +struct mystr bf[16] = { + 12, 13, 14, 15, 16, 17, 18, 19, + 22, 23, 24, 25, 26, 27, 28, 29, + 32, 33, 34, 35, 36, 37, 38, 39, + 42, 43, 44, 45, 46, 47, 48, 49 +}; + +struct mystr cf[16]; + +int res1[16] = { + 22, 26, 30, 34, 42, 46, 50, 54, + 62, 66, 70, 74, 82, 86, 90, 94, +}; + +int res2[16] = { + 24, 28, 32, 36, 44, 48, 52, 56, + 64, 68, 72, 76, 84, 88, 92, 96, +}; + +__attribute__ ((noinline)) void +foo (void) +{ + int i; + + for (i = 0; i < 16; i++) + { + cf[i].f1 = af[i].f1 + bf[i].f1; + cf[i].f2 = af[i].f2 + bf[i].f2; + } +} + + + +int +main (void) +{ + int i; + + check_vect (); + foo (); + + /* Check resiults. */ +#pragma GCC novector + for (i = 0; i < 16; i++) + { + if (cf[i].f1 != res1[i]) + abort (); + if (cf[i].f2 != res2[i]) + abort (); + + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorization not profitable" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-perm.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-perm.c new file mode 100644 index 0000000000..e5c4dceddf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-slp-perm.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* Specify power9 to ensure the vectorization is profitable + and test point stands, otherwise it could be not profitable + to vectorize. */ +/* { dg-additional-options "-mdejagnu-cpu=power9 -mpower9-vector" } */ + +/* Verify we cost the exact count for required vec_perm. */ + +int x[1024], y[1024]; + +void +foo () +{ + for (int i = 0; i < 512; ++i) + { + x[2 * i] = y[1023 - (2 * i)]; + x[2 * i + 1] = y[1023 - (2 * i + 1)]; + } +} + +/* { dg-final { scan-tree-dump-times "2 times vec_perm" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-31a.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-31a.c new file mode 100644 index 0000000000..454a714a30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-31a.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "../../tree-vect.h" + +#define N 32 + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +int main1 () +{ + int i; + struct s tmp; + + /* unaligned */ + for (i = 0; i < N/2; i++) + { + tmp.b[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +#define N 32 + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +int main1 () +{ + int i; + struct s tmp; + + /* aligned */ + for (i = 0; i < N/2; i++) + { + tmp.c[i] = 6; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +#define N 32 + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +int main1 () +{ + int i; + struct s tmp; + + /* aligned */ + for (i = 0; i < N/2; i++) + { + tmp.d.k[i] = 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +#define N 16 +struct test { + char ca[N]; +}; + +extern struct test s; + +__attribute__((noipa)) int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + return main1 (); +} + +/* Peeling to align the store is used. Overhead of peeling is too high. */ +/* { dg-final { scan-tree-dump-times "vectorization not profitable" 1 "vect" { target { ! natural_alignment_32 } } } } */ + +/* Vectorization occurs, either because overhead of versioning is not + too high, or because the hardware supports efficient unaligned accesses. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { natural_alignment_32 } } } } */ + +/* Versioning to align the store is used. Overhead of versioning is not + too high. */ +/* { dg-final { scan-tree-dump-times "loop versioned for vectorization to enhance alignment" 1 "vect" { target { natural_alignment_32 && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-68a.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-68a.c new file mode 100644 index 0000000000..648e19f107 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-68a.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "../../tree-vect.h" + +#define N 32 + +struct s{ + int m; + int n[N][N][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e; /* array e.n is aligned */ +}; + +int main1 () +{ + int i,j; + struct test1 tmp1; + + /* 1. unaligned */ + for (i = 0; i < N; i++) + { + tmp1.a.n[1][2][i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +#define N 32 + +struct s{ + int m; + int n[N][N][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e; /* array e.n is aligned */ +}; + +int main1 () +{ + int i,j; + struct test1 tmp1; + + /* 2. aligned */ + for (i = 3; i < N-1; i++) + { + tmp1.a.n[1][2][i] = 6; + } + + /* check results: */ +#pragma GCC novector + for (i = 3; i < N-1; i++) + { + if (tmp1.a.n[1][2][i] != 6) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-68c.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-68c.c new file mode 100644 index 0000000000..d71a202d8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-68c.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "../../tree-vect.h" + +#define N 32 + +struct s{ + int m; + int n[N][N][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e; /* array e.n is aligned */ +}; + +int main1 () +{ + int i,j; + struct test1 tmp1; + + /* 3. aligned */ + for (i = 0; i < N; i++) + { + tmp1.e.n[1][2][i] = 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (tmp1.e.n[1][2][i] != 7) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76a.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76a.c new file mode 100644 index 0000000000..f18da3fc1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76a.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-tree-loop-distribute-patterns" } */ + +#include +#include "../../tree-vect.h" + +#define N 16 +#define OFF 4 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(16))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10}; + +int main1 (int *pib) +{ + int i; + int ia[N+OFF]; + int ic[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10}; + + for (i = OFF; i < N; i++) + { + ia[i] = pib[i - OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = OFF; i < N; i++) + { + if (ia[i] != pib[i - OFF]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (&ib[OFF]); + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76b.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76b.c new file mode 100644 index 0000000000..cbbfbb2465 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76b.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-tree-loop-distribute-patterns" } */ + +#include +#include "../../tree-vect.h" + +/* On Power7 without misalign vector support, this case is to check it's not + profitable to perform vectorization by peeling to align the store. */ +#define N 14 +#define OFF 4 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(16))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10}; + +int main1 (int *pib) +{ + int i; + int ia[N+OFF]; + int ic[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10}; + + for (i = OFF; i < N; i++) + { + pib[i - OFF] = ic[i]; + } + + + /* check results: */ +#pragma GCC novector + for (i = OFF; i < N; i++) + { + if (pib[i - OFF] != ic[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (&ib[OFF]); + return 0; +} + +/* Peeling to align the store is used. Overhead of peeling is too high. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { vector_alignment_reachable && {! vect_no_align} } } } } */ +/* { dg-final { scan-tree-dump-times "vectorization not profitable" 1 "vect" { target { vector_alignment_reachable && {! vect_hw_misalign} } } } } */ + +/* Versioning to align the store is used. Overhead of versioning is not too high. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_no_align || {! vector_alignment_reachable} } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76c.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76c.c new file mode 100644 index 0000000000..2a672122bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-76c.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-tree-loop-distribute-patterns" } */ + +#include +#include "../../tree-vect.h" + +#define N 32 +#define OFF 4 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(16))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10}; +int ic[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10}; + +int main1 (int *pib) +{ + int i; + int ia[N+OFF]; + + for (i = OFF; i < N; i++) + { + ia[i] = ic[i - OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = OFF; i < N; i++) + { + if (ia[i] != ic[i - OFF]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (&ib[OFF]); + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-outer-fir.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-outer-fir.c new file mode 100644 index 0000000000..9c659f8392 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-outer-fir.c @@ -0,0 +1,71 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "../../tree-vect.h" + +#define N 40 +#define M 128 +float in[N+M]; +float coeff[M]; +float out[N]; +float fir_out[N]; + +/* Vectorized. Fixed misaligment in the inner-loop. */ +__attribute__ ((noinline)) void foo (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + out[i] = 0; + } + + for (k = 0; k < 4; k++) { + for (i = 0; i < N; i++) { + diff = 0; + for (j = k; j < M; j+=4) { + diff += in[j+i]*coeff[j]; + } + out[i] += diff; + } + } +} + +/* Vectorized. Changing misalignment in the inner-loop. */ +__attribute__ ((noinline)) void fir (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j++) { + diff += in[j+i]*coeff[j]; + } + fir_out[i] = diff; + } +} + + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < M; i++) + coeff[i] = i; + for (i = 0; i < N+M; i++) + in[i] = i; + + foo (); + fir (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + if (out[i] != fir_out[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-reduc-1char.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-reduc-1char.c new file mode 100644 index 0000000000..82b614bc4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-reduc-1char.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "../../tree-vect.h" + +#define N 16 +#define DIFF 242 + +void +main1 (unsigned char x, unsigned char max_result, unsigned char min_result) +{ + int i; + unsigned char ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + unsigned char udiff = 2; + unsigned char umax = x; + unsigned char umin = x; + + for (i = 0; i < N; i++) { + udiff += (unsigned char)(ub[i] - uc[i]); + } + + for (i = 0; i < N; i++) { + umax = umax < uc[i] ? uc[i] : umax; + } + + for (i = 0; i < N; i++) { + umin = umin > uc[i] ? uc[i] : umin; + } + + /* check results: */ + if (udiff != DIFF) + abort (); + if (umax != max_result) + abort (); + if (umin != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ +/* { dg-final { scan-tree-dump-times "vectorization not profitable" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-reversed.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-reversed.c new file mode 100644 index 0000000000..651274be03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-reversed.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-additional-options "-mvsx" } */ + +/* Verify we do cost the required vec_perm. */ + +int x[1024], y[1024]; + +void +foo () +{ + for (int i = 0; i < 512; ++i) + { + x[2 * i] = y[1023 - (2 * i)]; + x[2 * i + 1] = y[1023 - (2 * i + 1)]; + } +} +/* The reason why it doesn't check the exact count is that + retrying for the epilogue with partial vector capability + like Power10 can result in more than 1 vec_perm. */ +/* { dg-final { scan-tree-dump {\mvec_perm\M} "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-store-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-store-1.c new file mode 100644 index 0000000000..ab5f330149 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-store-1.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-O3" } + +/* This test case is partially extracted from case + gcc.dg/vect/vect-avg-16.c, it's to verify we don't + cost a store with vec_to_scalar when we shouldn't. */ + +void +test (signed char *restrict a, signed char *restrict b, signed char *restrict c, + int n) +{ + for (int j = 0; j < n; ++j) + { + for (int i = 0; i < 16; ++i) + a[i] = (b[i] + c[i]) >> 1; + a += 20; + b += 20; + c += 20; + } +} + +/* { dg-final { scan-tree-dump-times "vec_to_scalar" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-store-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-store-2.c new file mode 100644 index 0000000000..72b67cf904 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/costmodel-vect-store-2.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-additional-options "-mvsx" } */ + +/* Verify we do cost the required vec_perm. */ + +int +foo (int *a, int *b, int len) +{ + int i; + int *a1 = a; + int *a0 = a1 - 4; + for (i = 0; i < len; i++) + { + *b = *a0 + *a1; + b--; + a0++; + a1++; + } + return 0; +} + +/* The reason why it doesn't check the exact count is that + we can get more than 1 vec_perm when it's compiled with + partial vector capability like Power10 (retrying for + the epilogue) or it's complied without unaligned vector + memory access support (realign). */ +/* { dg-final { scan-tree-dump {\mvec_perm\M} "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/ppc-costmodel-vect.exp b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/ppc-costmodel-vect.exp new file mode 100644 index 0000000000..17b7af56ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/ppc/ppc-costmodel-vect.exp @@ -0,0 +1,89 @@ +# Copyright (C) 1997-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp + +# Exit immediately if this isn't a powerpc target. +if { ![istarget powerpc*-*-*] } then { + return +} + +# Skip targets not supporting -maltivec. +if ![is-effective-target powerpc_altivec_ok] { + return +} + +# Set up flags used for tests that don't specify options. +set DEFAULT_VECTCFLAGS "" + +# These flags are used for all targets. +lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fvect-cost-model=dynamic" "-fno-common" + +# If the target system supports vector instructions, the default action +# for a test is 'run', otherwise it's 'compile'. Save current default. +# Executing vector instructions on a system without hardware vector support +# is also disabled by a call to check_vect, but disabling execution here is +# more efficient. +global dg-do-what-default +set save-dg-do-what-default ${dg-do-what-default} + +lappend DEFAULT_VECTCFLAGS "-maltivec" +if [check_vmx_hw_available] { + set dg-do-what-default run +} else { + if [is-effective-target ilp32] { + # Specify a cpu that supports VMX for compile-only tests. + lappend DEFAULT_VECTCFLAGS "-mcpu=970" + } + set dg-do-what-default compile +} + +# Initialize `dg'. +dg-init + +set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS + +lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" +lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details" + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-pr*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-vect-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-slp-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-bb-slp*.\[cS\]]] \ + "" $VECT_SLP_CFLAGS + +#### Tests with special options +global SAVED_DEFAULT_VECTCFLAGS +set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS + +# -ffast-math tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-ffast-math" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-fast-math-vect*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# Clean up. +set dg-do-what-default ${save-dg-do-what-default} + +# All done. +dg-finish diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-1.c new file mode 100644 index 0000000000..4f019ccae6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic" } */ + +int a, *b[9], c, d, e; + +static int +fn1 () +{ + for (c = 6; c >= 0; c--) + for (d = 0; d < 2; d++) + { + b[d * 2 + c] = 0; + e = a > 1 ? : 0; + if (e == 2) + return 0; + } + return 0; +} + +int +main () +{ + fn1 (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-2.c new file mode 100644 index 0000000000..6fc8062f23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-2.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -Ofast -ftree-vectorize --param riscv-autovec-lmul=dynamic" } */ + +typedef struct rtx_def *rtx; +struct replacement { + rtx *where; + rtx *subreg_loc; + int mode; +}; +static struct replacement replacements[150]; +void move_replacements (rtx *x, rtx *y, int n_replacements) +{ + int i; + for (i = 0; i < n_replacements; i++) + if (replacements[i].subreg_loc == x) + replacements[i].subreg_loc = y; + else if (replacements[i].where == x) + { + replacements[i].where = y; + replacements[i].subreg_loc = 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-3.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-3.c new file mode 100644 index 0000000000..c1f698b9a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-ice-3.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O2 -ftree-vectorize -flto -fno-use-linker-plugin -flto-partition=none --param riscv-autovec-lmul=dynamic" } */ + +void (*foo[6][6]) (int); +void bar (hdR) + int hdR; +{ } +void xxx () +{ + unsigned int i, j; + for (i = 0; i < 6; ++i) + for (j = 0; j < 6; ++j) + foo [i][j] = bar; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-mixed-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-mixed-1.c new file mode 100644 index 0000000000..e654fc6bf8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul-mixed-1.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, int32_t *__restrict d2, int32_t *__restrict d3, + int32_t *__restrict d4, int32_t *__restrict d5, int n) +{ + for (int i = 0; i < n; i++) + a[i] = d5[i] + b[i]; + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + + a[i] * a2[i] * a3[i] * a4[i] * a5[i] * c[i] * c2[i] * c3[i] + * c4[i] * c5[i] * d[i] * d2[i] * d3[i] * d4[i] * d5[i]; + } +} + +/* { dg-final { scan-assembler {e32,m2} } } */ +/* { dg-final { scan-assembler {e32,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-1.c new file mode 100644 index 0000000000..f481c8094c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-1.c @@ -0,0 +1,91 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, + int32_t *__restrict d2, + int32_t *__restrict d3, + int32_t *__restrict d4, + int32_t *__restrict d5, + int32_t *__restrict e, + int32_t *__restrict e2, + int32_t *__restrict e3, + int32_t *__restrict e4, + int32_t *__restrict e5, + int32_t *__restrict f, + int32_t *__restrict f2, + int32_t *__restrict f3, + int32_t *__restrict f4, + int32_t *__restrict f5, + int32_t *__restrict g, + int32_t *__restrict g2, + int32_t *__restrict g3, + int32_t *__restrict g4, + int32_t *__restrict g5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + + e[i] = c2[i] + c2[i]; + e2[i] = c2[i] + d2[i]; + e3[i] = d3[i] + d3[i]; + e4[i] = c4[i] + a4[i]; + e5[i] = a[i] + a4[i]; + a5[i] = a[i] + a4[i]; + + f[i] = e2[i] + c2[i]; + f2[i] = e2[i] + d2[i]; + f3[i] = e3[i] + d3[i]; + f4[i] = e4[i] + a4[i]; + f5[i] = e[i] + a4[i]; + f5[i] = e5[i] + a4[i]; + + g[i] = f2[i] + c2[i]; + g2[i] = f2[i] + d2[i]; + g3[i] = f3[i] + d3[i]; + g4[i] = f4[i] + a4[i]; + g5[i] = f[i] + a4[i]; + g5[i] = f5[i] + a4[i]; + + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i] + * e[i] * e2[i] * e3[i] * e4[i] * e5[i] + * f[i] * f2[i] * f3[i] * f4[i] * f5[i] + * g[i] * g2[i] * g3[i] * g4[i] * g5[i]; + } +} + +/* { dg-final { scan-assembler {e32,m1} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-2.c new file mode 100644 index 0000000000..e044c65e7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-2.c @@ -0,0 +1,63 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fno-schedule-insns -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, + int32_t *__restrict d2, + int32_t *__restrict d3, + int32_t *__restrict d4, + int32_t *__restrict d5, + int32_t *__restrict e, + int32_t *__restrict e2, + int32_t *__restrict e3, + int32_t *__restrict e4, + int32_t *__restrict e5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + e[i] = a2[i] + c2[i]; + e2[i] = d2[i] + a2[i]; + e3[i] = d3[i] + a3[i]; + e4[i] = d4[i] + a4[i]; + e5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i] + * e[i] * e2[i] * e3[i] * e4[i] * e5[i]; + } +} + +/* FIXME: Choosing LMUL = 1 is not the optimal since it can be LMUL = 2 if we apply instruction scheduler. */ +/* { dg-final { scan-assembler {e32,m1} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-3.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-3.c new file mode 100644 index 0000000000..212788a93c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-3.c @@ -0,0 +1,91 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int8_t *__restrict a, int8_t *__restrict b, int8_t *__restrict c, + int8_t *__restrict a2, int8_t *__restrict b2, int8_t *__restrict c2, + int8_t *__restrict a3, int8_t *__restrict b3, int8_t *__restrict c3, + int8_t *__restrict a4, int8_t *__restrict b4, int8_t *__restrict c4, + int8_t *__restrict a5, int8_t *__restrict b5, int8_t *__restrict c5, + int8_t *__restrict d, + int8_t *__restrict d2, + int8_t *__restrict d3, + int8_t *__restrict d4, + int8_t *__restrict d5, + int8_t *__restrict e, + int8_t *__restrict e2, + int8_t *__restrict e3, + int8_t *__restrict e4, + int8_t *__restrict e5, + int8_t *__restrict f, + int8_t *__restrict f2, + int8_t *__restrict f3, + int8_t *__restrict f4, + int8_t *__restrict f5, + int8_t *__restrict g, + int8_t *__restrict g2, + int8_t *__restrict g3, + int8_t *__restrict g4, + int8_t *__restrict g5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + + e[i] = c2[i] + c2[i]; + e2[i] = c2[i] + d2[i]; + e3[i] = d3[i] + d3[i]; + e4[i] = c4[i] + a4[i]; + e5[i] = a[i] + a4[i]; + a5[i] = a[i] + a4[i]; + + f[i] = e2[i] + c2[i]; + f2[i] = e2[i] + d2[i]; + f3[i] = e3[i] + d3[i]; + f4[i] = e4[i] + a4[i]; + f5[i] = e[i] + a4[i]; + f5[i] = e5[i] + a4[i]; + + g[i] = f2[i] + c2[i]; + g2[i] = f2[i] + d2[i]; + g3[i] = f3[i] + d3[i]; + g4[i] = f4[i] + a4[i]; + g5[i] = f[i] + a4[i]; + g5[i] = f5[i] + a4[i]; + + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i] + * e[i] * e2[i] * e3[i] * e4[i] * e5[i] + * f[i] * f2[i] * f3[i] * f4[i] * f5[i] + * g[i] * g2[i] * g3[i] * g4[i] * g5[i]; + } +} + +/* { dg-final { scan-assembler {e8,m1} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-4.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-4.c new file mode 100644 index 0000000000..2e2ff9dc74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-4.c @@ -0,0 +1,121 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, + int32_t *__restrict d2, + int32_t *__restrict d3, + int32_t *__restrict d4, + int32_t *__restrict d5, + int32_t *__restrict e, + int32_t *__restrict e2, + int32_t *__restrict e3, + int32_t *__restrict e4, + int32_t *__restrict e5, + int32_t *__restrict f, + int32_t *__restrict f2, + int32_t *__restrict f3, + int32_t *__restrict f4, + int32_t *__restrict f5, + int32_t *__restrict g, + int32_t *__restrict g2, + int32_t *__restrict g3, + int32_t *__restrict g4, + int32_t *__restrict g5, + + int32_t *__restrict gg, + int32_t *__restrict gg2, + int32_t *__restrict gg3, + int32_t *__restrict gg4, + int32_t *__restrict gg5, + + int32_t *__restrict ggg, + int32_t *__restrict ggg2, + int32_t *__restrict ggg3, + int32_t *__restrict ggg4, + int32_t *__restrict ggg5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + + e[i] = c2[i] + c2[i]; + e2[i] = c2[i] + d2[i]; + e3[i] = d3[i] + d3[i]; + e4[i] = c4[i] + a4[i]; + e5[i] = a[i] + a4[i]; + a5[i] = a[i] + a4[i]; + + f[i] = e2[i] + c2[i]; + f2[i] = e2[i] + d2[i]; + f3[i] = e3[i] + d3[i]; + f4[i] = e4[i] + a4[i]; + f5[i] = e[i] + a4[i]; + f5[i] = e5[i] + a4[i]; + + g[i] = f2[i] + c2[i]; + g2[i] = f2[i] + d2[i]; + g3[i] = f3[i] + d3[i]; + g4[i] = f4[i] + a4[i]; + g5[i] = f[i] + a4[i]; + g5[i] = f5[i] + a4[i]; + + + gg[i] = f2[i] + c2[i]; + gg2[i] = f2[i] + d2[i]; + gg3[i] = f3[i] + d3[i]; + gg4[i] = f4[i] + a4[i]; + gg5[i] = f[i] + a4[i]; + gg5[i] = f5[i] + a4[i]; + + + ggg[i] = f2[i] + c2[i]; + ggg2[i] = f2[i] + d2[i]; + ggg3[i] = f3[i] + d3[i]; + ggg4[i] = f4[i] + a4[i]; + ggg5[i] = f[i] + a4[i]; + ggg5[i] = f5[i] + a4[i]; + + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i] + * e[i] * e2[i] * e3[i] * e4[i] * e5[i] + * f[i] * f2[i] * f3[i] * f4[i] * f5[i] + * g[i] * g2[i] * g3[i] * g4[i] * g5[i] + * gg[i] * gg2[i] * gg3[i] * gg4[i] * gg5[i] + * ggg[i] * ggg2[i] * ggg3[i] * ggg4[i] * ggg5[i]; + } +} + +/* { dg-final { scan-assembler {e32,m1} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-5.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-5.c new file mode 100644 index 0000000000..80eb38c998 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-5.c @@ -0,0 +1,149 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, + int32_t *__restrict d2, + int32_t *__restrict d3, + int32_t *__restrict d4, + int32_t *__restrict d5, + int32_t *__restrict e, + int32_t *__restrict e2, + int32_t *__restrict e3, + int32_t *__restrict e4, + int32_t *__restrict e5, + int32_t *__restrict f, + int32_t *__restrict f2, + int32_t *__restrict f3, + int32_t *__restrict f4, + int32_t *__restrict f5, + int32_t *__restrict g, + int32_t *__restrict g2, + int32_t *__restrict g3, + int32_t *__restrict g4, + int32_t *__restrict g5, + + int32_t *__restrict gg, + int32_t *__restrict gg2, + int32_t *__restrict gg3, + int32_t *__restrict gg4, + int32_t *__restrict gg5, + + int32_t *__restrict ggg, + int32_t *__restrict ggg2, + int32_t *__restrict ggg3, + int32_t *__restrict ggg4, + int32_t *__restrict ggg5, + + int32_t *__restrict gggg, + int32_t *__restrict gggg2, + int32_t *__restrict gggg3, + int32_t *__restrict gggg4, + int32_t *__restrict gggg5, + + int32_t *__restrict ggggg, + int32_t *__restrict ggggg2, + int32_t *__restrict ggggg3, + int32_t *__restrict ggggg4, + int32_t *__restrict ggggg5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + + e[i] = c2[i] + c2[i]; + e2[i] = c2[i] + d2[i]; + e3[i] = d3[i] + d3[i]; + e4[i] = c4[i] + a4[i]; + e5[i] = a[i] + a4[i]; + a5[i] = a[i] + a4[i]; + + f[i] = e2[i] + c2[i]; + f2[i] = e2[i] + d2[i]; + f3[i] = e3[i] + d3[i]; + f4[i] = e4[i] + a4[i]; + f5[i] = e[i] + a4[i]; + f5[i] = e5[i] + a4[i]; + + g[i] = f2[i] + c2[i]; + g2[i] = f2[i] + d2[i]; + g3[i] = f3[i] + d3[i]; + g4[i] = f4[i] + a4[i]; + g5[i] = f[i] + a4[i]; + g5[i] = f5[i] + a4[i]; + + + gg[i] = f2[i] + c2[i]; + gg2[i] = f2[i] + d2[i]; + gg3[i] = f3[i] + d3[i]; + gg4[i] = f4[i] + a4[i]; + gg5[i] = f[i] + a4[i]; + gg5[i] = f5[i] + a4[i]; + + + ggg[i] = f2[i] + c2[i]; + ggg2[i] = f2[i] + d2[i]; + ggg3[i] = f3[i] + d3[i]; + ggg4[i] = f4[i] + a4[i]; + ggg5[i] = f[i] + a4[i]; + ggg5[i] = f5[i] + a4[i]; + + gggg[i] = f2[i] + c2[i]; + gggg2[i] = f2[i] + d2[i]; + gggg3[i] = f3[i] + d3[i]; + gggg4[i] = f4[i] + a4[i]; + gggg5[i] = f[i] + a4[i]; + gggg5[i] = f5[i] + a4[i]; + + ggggg[i] = f2[i] + c2[i]; + ggggg2[i] = f2[i] + d2[i]; + ggggg3[i] = f3[i] + d3[i]; + ggggg4[i] = f4[i] + a4[i]; + ggggg5[i] = f[i] + a4[i]; + ggggg5[i] = f5[i] + a4[i]; + + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i] + * e[i] * e2[i] * e3[i] * e4[i] * e5[i] + * f[i] * f2[i] * f3[i] * f4[i] * f5[i] + * g[i] * g2[i] * g3[i] * g4[i] * g5[i] + * gg[i] * gg2[i] * gg3[i] * gg4[i] * gg5[i] + * ggg[i] * ggg2[i] * ggg3[i] * ggg4[i] * ggg5[i] + * gggg[i] * gggg2[i] * gggg3[i] * gggg4[i] * gggg5[i] + * ggggg[i] * ggggg2[i] * ggggg3[i] * ggggg4[i] * ggggg5[i]; + } +} + +/* { dg-final { scan-assembler {e32,m1} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-6.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-6.c new file mode 100644 index 0000000000..3dd594e3f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-6.c @@ -0,0 +1,150 @@ + +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int8_t *__restrict a, int8_t *__restrict b, int8_t *__restrict c, + int8_t *__restrict a2, int8_t *__restrict b2, int8_t *__restrict c2, + int8_t *__restrict a3, int8_t *__restrict b3, int8_t *__restrict c3, + int8_t *__restrict a4, int8_t *__restrict b4, int8_t *__restrict c4, + int8_t *__restrict a5, int8_t *__restrict b5, int8_t *__restrict c5, + int8_t *__restrict d, + int8_t *__restrict d2, + int8_t *__restrict d3, + int8_t *__restrict d4, + int8_t *__restrict d5, + int8_t *__restrict e, + int8_t *__restrict e2, + int8_t *__restrict e3, + int8_t *__restrict e4, + int8_t *__restrict e5, + int8_t *__restrict f, + int8_t *__restrict f2, + int8_t *__restrict f3, + int8_t *__restrict f4, + int8_t *__restrict f5, + int8_t *__restrict g, + int8_t *__restrict g2, + int8_t *__restrict g3, + int8_t *__restrict g4, + int8_t *__restrict g5, + + int8_t *__restrict gg, + int8_t *__restrict gg2, + int8_t *__restrict gg3, + int8_t *__restrict gg4, + int8_t *__restrict gg5, + + int8_t *__restrict ggg, + int8_t *__restrict ggg2, + int8_t *__restrict ggg3, + int8_t *__restrict ggg4, + int8_t *__restrict ggg5, + + int8_t *__restrict gggg, + int8_t *__restrict gggg2, + int8_t *__restrict gggg3, + int8_t *__restrict gggg4, + int8_t *__restrict gggg5, + + int8_t *__restrict ggggg, + int8_t *__restrict ggggg2, + int8_t *__restrict ggggg3, + int8_t *__restrict ggggg4, + int8_t *__restrict ggggg5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + + e[i] = c2[i] + c2[i]; + e2[i] = c2[i] + d2[i]; + e3[i] = d3[i] + d3[i]; + e4[i] = c4[i] + a4[i]; + e5[i] = a[i] + a4[i]; + a5[i] = a[i] + a4[i]; + + f[i] = e2[i] + c2[i]; + f2[i] = e2[i] + d2[i]; + f3[i] = e3[i] + d3[i]; + f4[i] = e4[i] + a4[i]; + f5[i] = e[i] + a4[i]; + f5[i] = e5[i] + a4[i]; + + g[i] = f2[i] + c2[i]; + g2[i] = f2[i] + d2[i]; + g3[i] = f3[i] + d3[i]; + g4[i] = f4[i] + a4[i]; + g5[i] = f[i] + a4[i]; + g5[i] = f5[i] + a4[i]; + + + gg[i] = f2[i] + c2[i]; + gg2[i] = f2[i] + d2[i]; + gg3[i] = f3[i] + d3[i]; + gg4[i] = f4[i] + a4[i]; + gg5[i] = f[i] + a4[i]; + gg5[i] = f5[i] + a4[i]; + + + ggg[i] = f2[i] + c2[i]; + ggg2[i] = f2[i] + d2[i]; + ggg3[i] = f3[i] + d3[i]; + ggg4[i] = f4[i] + a4[i]; + ggg5[i] = f[i] + a4[i]; + ggg5[i] = f5[i] + a4[i]; + + gggg[i] = f2[i] + c2[i]; + gggg2[i] = f2[i] + d2[i]; + gggg3[i] = f3[i] + d3[i]; + gggg4[i] = f4[i] + a4[i]; + gggg5[i] = f[i] + a4[i]; + gggg5[i] = f5[i] + a4[i]; + + ggggg[i] = f2[i] + c2[i]; + ggggg2[i] = f2[i] + d2[i]; + ggggg3[i] = f3[i] + d3[i]; + ggggg4[i] = f4[i] + a4[i]; + ggggg5[i] = f[i] + a4[i]; + ggggg5[i] = f5[i] + a4[i]; + + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i] + * e[i] * e2[i] * e3[i] * e4[i] * e5[i] + * f[i] * f2[i] * f3[i] * f4[i] * f5[i] + * g[i] * g2[i] * g3[i] * g4[i] * g5[i] + * gg[i] * gg2[i] * gg3[i] * gg4[i] * gg5[i] + * ggg[i] * ggg2[i] * ggg3[i] * ggg4[i] * ggg5[i] + * gggg[i] * gggg2[i] * gggg3[i] * gggg4[i] * gggg5[i] + * ggggg[i] * ggggg2[i] * ggggg3[i] * ggggg4[i] * ggggg5[i]; + } +} + +/* { dg-final { scan-assembler {e8,m1} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-7.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-7.c new file mode 100644 index 0000000000..87b943cca4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul1-7.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -Wno-psabi -fdump-tree-vect-details" } */ + +#include "riscv_vector.h" + +vint32m8_t +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, int32_t *__restrict d2, int32_t *__restrict d3, + int32_t *__restrict d4, int32_t *__restrict d5, int n, vint32m8_t vector) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + + a[i] * a2[i] * a3[i] * a4[i] * a5[i] * c[i] * c2[i] * c3[i] + * c4[i] * c5[i] * d[i] * d2[i] * d3[i] * d4[i] * d5[i]; + } + return vector; +} + +/* { dg-final { scan-assembler {e32,m1} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-1.c new file mode 100644 index 0000000000..0079aa02a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-1.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, + int32_t *__restrict d2, + int32_t *__restrict d3, + int32_t *__restrict d4, + int32_t *__restrict d5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i]; + } +} + +/* { dg-final { scan-assembler {e32,m2} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-2.c new file mode 100644 index 0000000000..d8a0e66a65 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-2.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int8_t *__restrict a, int8_t *__restrict b, int8_t *__restrict c, + int8_t *__restrict a2, int8_t *__restrict b2, int8_t *__restrict c2, + int8_t *__restrict a3, int8_t *__restrict b3, int8_t *__restrict c3, + int8_t *__restrict a4, int8_t *__restrict b4, int8_t *__restrict c4, + int8_t *__restrict a5, int8_t *__restrict b5, int8_t *__restrict c5, + int8_t *__restrict d, + int8_t *__restrict d2, + int8_t *__restrict d3, + int8_t *__restrict d4, + int8_t *__restrict d5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i]; + } +} + +/* { dg-final { scan-assembler {e8,m2} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-3.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-3.c new file mode 100644 index 0000000000..0079aa02a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-3.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, + int32_t *__restrict d2, + int32_t *__restrict d3, + int32_t *__restrict d4, + int32_t *__restrict d5, + int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + a[i] * a2[i] * a3[i] * a4[i] + * a5[i] * c[i] * c2[i] * c3[i] * c4[i] * c5[i] + * d[i] * d2[i] * d3[i] * d4[i] * d5[i]; + } +} + +/* { dg-final { scan-assembler {e32,m2} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-4.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-4.c new file mode 100644 index 0000000000..23269196b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-4.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include "riscv_vector.h" + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, int32_t *__restrict d2, int32_t *__restrict d3, + int32_t *__restrict d4, int32_t *__restrict d5, int n) +{ + vint32m1_t v = __riscv_vle32_v_i32m1 (a, 32); + __riscv_vse32_v_i32m1 (c, v, 32); + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + + a[i] * a2[i] * a3[i] * a4[i] * a5[i] * c[i] * c2[i] * c3[i] + * c4[i] * c5[i] * d[i] * d2[i] * d3[i] * d4[i] * d5[i]; + } +} + +/* { dg-final { scan-assembler {e32,m2} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-5.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-5.c new file mode 100644 index 0000000000..2ef88a307b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-5.c @@ -0,0 +1,52 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include +typedef int8_t v128qi __attribute__ ((vector_size (128))); + +v128qi global_v; + +v128qi +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, int32_t *__restrict d2, int32_t *__restrict d3, + int32_t *__restrict d4, int32_t *__restrict d5, int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + + a[i] * a2[i] * a3[i] * a4[i] * a5[i] * c[i] * c2[i] * c3[i] + * c4[i] * c5[i] * d[i] * d2[i] * d3[i] * d4[i] * d5[i]; + } + return global_v + 3; +} + +/* { dg-final { scan-assembler {e32,m2} } } */ +/* { dg-final { scan-assembler {e8,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-6.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-6.c new file mode 100644 index 0000000000..5eec2b0c4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-6.c @@ -0,0 +1,51 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include +typedef int8_t v128qi __attribute__ ((vector_size (128))); + +v128qi global_v; + +v128qi +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, int32_t *__restrict d2, int32_t *__restrict d3, + int32_t *__restrict d4, int32_t *__restrict d5, int n) +{ + for (int i = 0; i < 128; i++) + b[i] = global_v[i] + 8; + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d2[i] = a2[i] + c2[i]; + d3[i] = a3[i] + c3[i]; + d4[i] = a4[i] + c4[i]; + d5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i] + a[i]; + + c2[i] = a[i] + c[i]; + c3[i] = b5[i] * a5[i]; + c4[i] = a2[i] * a3[i]; + c5[i] = b5[i] * a2[i]; + c[i] = a[i] + c3[i]; + c2[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i] + + a[i] * a2[i] * a3[i] * a4[i] * a5[i] * c[i] * c2[i] * c3[i] + * c4[i] * c5[i] * d[i] * d2[i] * d3[i] * d4[i] * d5[i]; + } + return global_v + 3; +} + +/* { dg-final { scan-assembler {e32,m2} } } */ +/* { dg-final { scan-assembler {e8,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-7.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-7.c new file mode 100644 index 0000000000..87e963edc4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul2-7.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic" } */ + +int +x264_pixel_8x8 (unsigned char *pix1, unsigned char *pix2, int i_stride_pix2) +{ + int i_sum = 0; + for (int y = 0; y < 8; y++) + { + i_sum += __builtin_abs (pix1[0] - pix2[0]); + i_sum += __builtin_abs (pix1[1] - pix2[1]); + i_sum += __builtin_abs (pix1[2] - pix2[2]); + i_sum += __builtin_abs (pix1[3] - pix2[3]); + i_sum += __builtin_abs (pix1[4] - pix2[4]); + i_sum += __builtin_abs (pix1[5] - pix2[5]); + i_sum += __builtin_abs (pix1[6] - pix2[6]); + i_sum += __builtin_abs (pix1[7] - pix2[7]); + pix1 += 16; + pix2 += i_stride_pix2; + } + return i_sum; +} + +/* { dg-final { scan-assembler {e32,m2} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-1.c new file mode 100644 index 0000000000..08dc7ca92d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-1.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict c, + int32_t *__restrict a2, int32_t *__restrict b2, int32_t *__restrict c2, + int32_t *__restrict a3, int32_t *__restrict b3, int32_t *__restrict c3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict c4, + int32_t *__restrict a5, int32_t *__restrict b5, int32_t *__restrict c5, + int32_t *__restrict d, int32_t *__restrict d2, int32_t *__restrict d3, + int32_t *__restrict d4, int32_t *__restrict d5, int n, int m) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d[i] = a[i] - a2[i]; + d2[i] = a2[i] * a[i]; + d3[i] = a3[i] * a2[i]; + d4[i] = a2[i] * d2[i]; + d5[i] = a[i] * a2[i] * a3[i] * a4[i] * d[i]; + } +} + +/* { dg-final { scan-assembler {e32,m4} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-10.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-10.c new file mode 100644 index 0000000000..e47af25aa9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-10.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +int +bar (int *x, int a, int b, int n) +{ + x = __builtin_assume_aligned (x, __BIGGEST_ALIGNMENT__); + int sum1 = 0; + int sum2 = 0; + for (int i = 0; i < n; ++i) + { + sum1 += x[2*i] - a; + sum1 += x[2*i+1] * b; + sum2 += x[2*i] - b; + sum2 += x[2*i+1] * a; + } + return sum1 + sum2; +} + +/* { dg-final { scan-assembler {e32,m4} } } */ +/* { dg-final { scan-assembler-not {jr} } } */ +/* { dg-final { scan-assembler-times {ret} 2 } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-11.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-11.c new file mode 100644 index 0000000000..48b24279b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-11.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +void +foo (int *__restrict a, int *__restrict b, int *__restrict c, int *__restrict d, + int *__restrict e, int *__restrict f, int n) +{ + for (int i = 0; i < n; i++) + a[i] = b[i] != f[i] ? c[i] * d[i] : e[i]; +} + +/* { dg-final { scan-assembler {e32,m4} } } */ +/* { dg-final { scan-assembler-not {jr} } } */ +/* { dg-final { scan-assembler-times {ret} 1 } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Maximum lmul = 16" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-2.c new file mode 100644 index 0000000000..b9a9229ed9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-2.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int8_t *__restrict a, int8_t *__restrict b, int8_t *__restrict c, + int8_t *__restrict a2, int8_t *__restrict b2, int8_t *__restrict c2, + int8_t *__restrict a3, int8_t *__restrict b3, int8_t *__restrict c3, + int8_t *__restrict a4, int8_t *__restrict b4, int8_t *__restrict c4, + int8_t *__restrict a5, int8_t *__restrict b5, int8_t *__restrict c5, + int8_t *__restrict d, int8_t *__restrict d2, int8_t *__restrict d3, + int8_t *__restrict d4, int8_t *__restrict d5, int n, int m) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + d[i] = a[i] - a2[i]; + d2[i] = a2[i] * a[i]; + d3[i] = a3[i] * a2[i]; + d4[i] = a2[i] * d2[i]; + d5[i] = a[i] * a2[i] * a3[i] * a4[i] * d[i]; + } +} + +/* { dg-final { scan-assembler {e8,m4} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c new file mode 100644 index 0000000000..9af91b0b86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void foo2 (int64_t *__restrict a, + int8_t *__restrict b, + int8_t *__restrict c, + int8_t *__restrict a2, + int8_t *__restrict b2, + int8_t *__restrict c2, + int8_t *__restrict a3, + int8_t *__restrict b3, + int8_t *__restrict c3, + int8_t *__restrict a4, + int8_t *__restrict b4, + int8_t *__restrict c4, + int64_t *__restrict a5, + int8_t *__restrict b5, + int8_t *__restrict c5, + int n) +{ + for (int i = 0; i < n; i++){ + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i]+ a[i]; + + a[i] = a[i] + c[i]; + b5[i] = a[i] + c[i]; + a2[i] = a[i] + c2[i]; + a3[i] = a[i] + c3[i]; + a4[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i]+ a[i]; + } +} + +/* { dg-final { scan-assembler {e32,m4} } } */ +/* { dg-final { scan-assembler {e64,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-5.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-5.c new file mode 100644 index 0000000000..2a881da0b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-5.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void foo2 (int16_t *__restrict a, + int32_t *__restrict b, + int32_t *__restrict c, + int32_t *__restrict a2, + int32_t *__restrict b2, + int32_t *__restrict c2, + int32_t *__restrict a3, + int32_t *__restrict b3, + int32_t *__restrict c3, + int32_t *__restrict a4, + int32_t *__restrict b4, + int32_t *__restrict c4, + int16_t *__restrict a5, + int32_t *__restrict b5, + int32_t *__restrict c5, + int n) +{ + for (int i = 0; i < n; i++){ + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i]+ a[i]; + + a[i] = a[i] + c[i]; + b5[i] = a[i] + c[i]; + a2[i] = a[i] + c2[i]; + a3[i] = a[i] + c3[i]; + a4[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i]+ a[i]; + } +} + +/* { dg-final { scan-assembler {e16,m2} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ +/* { dg-final { scan-tree-dump "start = 8, end = 10" "vect" } } */ +/* { dg-final { scan-tree-dump "2: type = unsigned short, start = 0, end = 34" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-6.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-6.c new file mode 100644 index 0000000000..d2766f5984 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-6.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=scalable -fselective-scheduling -fdump-tree-vect-details" } */ + +#include + +void +foo (uint8_t *restrict a, uint8_t *restrict b, int n) +{ + for (int i = 0; i < n; ++i) + { + a[i * 8] = b[i * 8 + 7] + 1; + a[i * 8 + 1] = b[i * 8 + 6] + 2; + a[i * 8 + 2] = b[i * 8 + 5] + 3; + a[i * 8 + 3] = b[i * 8 + 4] + 4; + a[i * 8 + 4] = b[i * 8 + 3] + 5; + a[i * 8 + 5] = b[i * 8 + 2] + 6; + a[i * 8 + 6] = b[i * 8 + 1] + 7; + a[i * 8 + 7] = b[i * 8 + 0] + 8; + } +} + +/* { dg-final { scan-assembler {e8,m4} } } */ +/* { dg-final { scan-assembler-times {csrr} 1 } } */ +/* Since we don't support VLA SLP for LMUL = 8, dynamic LMUL cost model start from LMUL = 4. */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Maximum lmul = 8" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-7.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-7.c new file mode 100644 index 0000000000..45bceaac0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-7.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void foo2 (int8_t *__restrict a, + int64_t *__restrict b, + int64_t *__restrict c, + int64_t *__restrict a2, + int64_t *__restrict b2, + int64_t *__restrict c2, + int64_t *__restrict a3, + int64_t *__restrict b3, + int64_t *__restrict c3, + int64_t *__restrict a4, + int64_t *__restrict b4, + int64_t *__restrict c4, + int8_t *__restrict a5, + int64_t *__restrict b5, + int64_t *__restrict c5, + int n) +{ + for (int i = 0; i < n; i++){ + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i]+ a[i]; + + a[i] = a[i] + c[i]; + b5[i] = a[i] + c[i]; + a2[i] = a[i] + c2[i]; + a3[i] = a[i] + c3[i]; + a4[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i]+ a[i]; + } +} + +/* { dg-final { scan-assembler {e64,m4} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-8.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-8.c new file mode 100644 index 0000000000..362c49f141 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-8.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=scalable -fselective-scheduling -fdump-tree-vect-details" } */ + +#include + +void +foo (uint8_t *restrict a, uint8_t *restrict b, int n) +{ + for (int i = 0; i < n; ++i) + { + a[i * 16] = b[i * 16 + 15] + 1; + a[i * 16 + 1] = b[i * 16 + 14] + 2; + a[i * 16 + 2] = b[i * 16 + 13] + 3; + a[i * 16 + 3] = b[i * 16 + 12] + 4; + a[i * 16 + 4] = b[i * 16 + 11] + 5; + a[i * 16 + 5] = b[i * 16 + 10] + 6; + a[i * 16 + 6] = b[i * 16 + 9] + 7; + a[i * 16 + 7] = b[i * 16 + 8] + 8; + + a[i * 16 + 8] = b[i * 16 + 7] + 1; + a[i * 16 + 9] = b[i * 16 + 6] + 2; + a[i * 16 + 10] = b[i * 16 + 5] + 3; + a[i * 16 + 11] = b[i * 16 + 4] + 4; + a[i * 16 + 12] = b[i * 16 + 3] + 5; + a[i * 16 + 13] = b[i * 16 + 2] + 6; + a[i * 16 + 14] = b[i * 16 + 1] + 7; + a[i * 16 + 15] = b[i * 16 + 0] + 8; + } +} + +/* { dg-final { scan-assembler {e8,m4} } } */ +/* { dg-final { scan-assembler-times {csrr} 1 } } */ +/* Since we don't support VLA SLP for LMUL = 8, dynamic LMUL cost model start from LMUL = 4. */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Maximum lmul = 8" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-9.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-9.c new file mode 100644 index 0000000000..7fda83ab97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul4-9.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fselective-scheduling -fdump-tree-vect-details" } */ + +#include + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum,x; + + for (i = 0; i < n; i++) { + sum = 0; + for (j = 0; j < n; j++) { + sum += (i + j); + } + a[i] = sum; + } + return 0; +} + +/* { dg-final { scan-assembler-not {jr} } } */ +/* { dg-final { scan-assembler-times {ret} 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-1.c new file mode 100644 index 0000000000..702a3b74f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = a[i] + b[i]; +} + +/* { dg-final { scan-assembler {e32,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-10.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-10.c new file mode 100644 index 0000000000..95b0600a9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-10.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +int +foo (int *x, int n, int res) +{ + for (int i = 0; i < n; ++i) + { + res += x[i * 2]; + res += x[i * 2 + 1]; + } + return res; +} + +/* { dg-final { scan-assembler {e32,m8} } } */ +/* { dg-final { scan-assembler-times {csrr} 1 } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-11.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-11.c new file mode 100644 index 0000000000..83df2bc46e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-11.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void foo2 (int64_t *__restrict a, + int32_t *__restrict b, + int32_t *__restrict c, + int32_t *__restrict a2, + int32_t *__restrict b2, + int32_t *__restrict c2, + int32_t *__restrict a3, + int32_t *__restrict b3, + int32_t *__restrict c3, + int32_t *__restrict a4, + int32_t *__restrict b4, + int32_t *__restrict c4, + int64_t *__restrict a5, + int32_t *__restrict b5, + int32_t *__restrict c5, + int n) +{ + for (int i = 0; i < n; i++){ + a[i] = b[i] + c[i]; + b5[i] = b[i] + c[i]; + a2[i] = b2[i] + c2[i]; + a3[i] = b3[i] + c3[i]; + a4[i] = b4[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a5[i] + b5[i]+ a[i]; + + a[i] = a[i] + c[i]; + b5[i] = a[i] + c[i]; + a2[i] = a[i] + c2[i]; + a3[i] = a[i] + c3[i]; + a4[i] = a[i] + c4[i]; + a5[i] = a[i] + a4[i]; + a[i] = a[i] + b5[i]+ a[i]; + } +} + +/* { dg-final { scan-assembler {e64,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-12.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-12.c new file mode 100644 index 0000000000..d0f354279f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-12.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=scalable -fselective-scheduling -fdump-tree-vect-details" } */ + +void +foo (int *restrict a, int *restrict b, int n) +{ + for (int i = 0; i < n; ++i) + { + a[i * 8] = b[i * 8 + 7] + 1; + a[i * 8 + 1] = b[i * 8 + 6] + 2; + a[i * 8 + 2] = b[i * 8 + 5] + 3; + a[i * 8 + 3] = b[i * 8 + 4] + 4; + a[i * 8 + 4] = b[i * 8 + 3] + 5; + a[i * 8 + 5] = b[i * 8 + 2] + 6; + a[i * 8 + 6] = b[i * 8 + 1] + 7; + a[i * 8 + 7] = b[i * 8 + 0] + 8; + } +} + +/* { dg-final { scan-assembler {e32,m8} } } */ +/* { dg-final { scan-assembler-times {csrr} 1 } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-13.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-13.c new file mode 100644 index 0000000000..baef4e3901 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-13.c @@ -0,0 +1,74 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +void +f (int *restrict a, int *restrict b, int *restrict c, int *restrict d, int n) +{ + for (int i = 0; i < n; i++) + { + int tmp = b[i] + 15; + int tmp2 = tmp + b[i]; + c[i] = tmp2 + b[i]; + d[i] = tmp + tmp2 + b[i]; + } +} + +void +f2 (int *restrict a, int *restrict b, int *restrict c, int *restrict d, int n) +{ + for (int i = 0; i < n; i++) + { + int tmp = 15 - b[i]; + int tmp2 = tmp * b[i]; + c[i] = tmp2 * b[i]; + d[i] = tmp * tmp2 * b[i]; + } +} + +void +f3 (int *restrict a, int *restrict b, int *restrict c, int *restrict d, int n) +{ + for (int i = 0; i < n; i++) + { + int tmp = b[i] & 15; + int tmp2 = tmp * b[i]; + c[i] = tmp2 * b[i]; + d[i] = tmp * tmp2 * b[i]; + } +} + +void +f4 (int *restrict a, int *restrict b, int *restrict c, int *restrict d, int n) +{ + for (int i = 0; i < n; i++) + { + int tmp = b[i] | 15; + int tmp2 = tmp * b[i]; + c[i] = tmp2 * b[i]; + d[i] = tmp * tmp2 * b[i]; + } +} + +void +f5 (int *restrict a, int *restrict b, int *restrict c, int *restrict d, int n) +{ + for (int i = 0; i < n; i++) + { + int tmp = b[i] ^ 15; + int tmp2 = tmp * b[i]; + c[i] = tmp2 * b[i]; + d[i] = tmp * tmp2 * b[i]; + } +} + +/* { dg-final { scan-assembler-times {e32,m8} 5 } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-assembler-not {jr} } } */ +/* { dg-final { scan-assembler-not {e32,m4} } } */ +/* { dg-final { scan-assembler-not {e32,m2} } } */ +/* { dg-final { scan-assembler-not {e32,m1} } } */ +/* { dg-final { scan-assembler-times {ret} 5 } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 5 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 5 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 5 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-2.c new file mode 100644 index 0000000000..c3d0d5d574 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int16_t *__restrict b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = a[i] + b[i]; +} + +/* { dg-final { scan-assembler {e16,m4} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-3.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-3.c new file mode 100644 index 0000000000..a575427f8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int8_t *__restrict a, int8_t *__restrict b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = a[i] + b[i]; +} + +/* { dg-final { scan-assembler {e8,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-4.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-4.c new file mode 100644 index 0000000000..b55bcad6a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-4.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include +#include + +void +foo (size_t *__restrict a, size_t *__restrict b, int n) +{ + for (int i = 0; i < n; i++) + a[i] = a[i] + b[i]; +} + +/* { dg-final { scan-assembler {e64,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-5.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-5.c new file mode 100644 index 0000000000..307dd69e2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-5.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int8_t *__restrict a, int8_t *__restrict b, int n) +{ + for (int i = 0; i < n; i++){ + a[i] = a[i] + b[i]; + a[i] = a[i] + b[i]; + a[i] = a[i] + b[i]; + a[i] = a[i] + b[i]; + a[i] = a[i] + b[i]; + a[i] = a[i] + b[i]; + a[i] = a[i] + b[i]; + } +} + +/* { dg-final { scan-assembler {e8,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-6.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-6.c new file mode 100644 index 0000000000..9a7eb421d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-6.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int8_t *__restrict a, int8_t *__restrict b, int8_t *__restrict a2, + int8_t *__restrict b2, int8_t *__restrict a3, int8_t *__restrict b3, + int8_t *__restrict a4, int8_t *__restrict b4, int8_t *__restrict a5, + int8_t *__restrict b5, int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] * a2[i] * b2[i] * a3[i] * b3[i] * a4[i] * b4[i] * a5[i] * b5[i]; + } +} + +/* { dg-final { scan-assembler {e8,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-7.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-7.c new file mode 100644 index 0000000000..103d22b23a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-7.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int32_t *__restrict a, int32_t *__restrict b, int32_t *__restrict a2, + int32_t *__restrict b2, int32_t *__restrict a3, int32_t *__restrict b3, + int32_t *__restrict a4, int32_t *__restrict b4, int32_t *__restrict a5, + int32_t *__restrict b5, int n) +{ + for (int i = 0; i < n; i++) + { + a[i] = b[i] * a2[i] * b2[i] * a3[i] * b3[i] * a4[i] * b4[i] * a5[i] * b5[i]; + } +} + +/* { dg-final { scan-assembler {e32,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-8.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-8.c new file mode 100644 index 0000000000..0255bdf8cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-8.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +int8_t +foo (int8_t *__restrict a, int8_t init, int n) +{ + for (int i = 0; i < n; i++) + init += a[i]; + return init; +} + +/* { dg-final { scan-assembler {e8,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c new file mode 100644 index 0000000000..e6cc1ad83e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +int64_t +foo (int64_t *__restrict a, int64_t init, int n) +{ + for (int i = 0; i < n; i++) + init += a[i]; + return init; +} + +/* { dg-final { scan-assembler {e64,m8} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 8" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 2" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/no-dynamic-lmul-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/no-dynamic-lmul-1.c new file mode 100644 index 0000000000..6752f254fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/no-dynamic-lmul-1.c @@ -0,0 +1,64 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include + +void +foo (int8_t *restrict a) +{ + for (int i = 0; i < 4096; ++i) + a[i] = a[i]-16; +} + +void +foo2 (int16_t *restrict a) +{ + for (int i = 0; i < 2048; ++i) + a[i] = a[i]-16; +} + +void +foo3 (int32_t *restrict a) +{ + for (int i = 0; i < 1024; ++i) + a[i] = a[i]-16; +} + +void +foo4 (int64_t *restrict a) +{ + for (int i = 0; i < 512; ++i) + a[i] = a[i]-16; +} + +void +foo5 (int8_t *restrict a) +{ + for (int i = 0; i < 16; ++i) + a[i] = a[i]-16; +} + +void +foo6 (int16_t *restrict a) +{ + for (int i = 0; i < 16; ++i) + a[i] = a[i]-16; +} + +void +foo7 (int32_t *restrict a) +{ + for (int i = 0; i < 16; ++i) + a[i] = a[i]-16; +} + +void +foo8 (int64_t *restrict a) +{ + for (int i = 0; i < 16; ++i) + a[i] = a[i]-16; +} + +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ +/* { dg-final { scan-assembler-times {vsetvli} 4 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 4 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111153-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111153-1.c new file mode 100644 index 0000000000..51c91f7410 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111153-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -mtune=generic-ooo -ffast-math" } */ + +#define DEF_REDUC_PLUS(TYPE) \ + TYPE __attribute__ ((noinline, noclone)) \ + reduc_plus_##TYPE (TYPE *__restrict a, int n) \ + { \ + TYPE r = 0; \ + for (int i = 0; i < n; ++i) \ + r += a[i]; \ + return r; \ + } + +#define TEST_PLUS(T) T (int) T (float) + +TEST_PLUS (DEF_REDUC_PLUS) + +/* { dg-final { scan-assembler-not {vsetivli\s+zero,\s*4} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111317.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111317.c new file mode 100644 index 0000000000..d4bea242a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111317.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param=riscv-autovec-lmul=m1" } */ + +void +foo (char *__restrict a, short *__restrict b, int n) +{ + for (int i = 0; i < n; i++) + b[i] = (short) a[i]; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*[a-x0-9]+,\s*e16,\s*m1,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli} 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr11153-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr11153-2.c new file mode 100644 index 0000000000..d361f1fc7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr11153-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -ffast-math" } */ + +#define DEF_REDUC_PLUS(TYPE) \ + TYPE __attribute__ ((noinline, noclone)) \ + reduc_plus_##TYPE (TYPE *__restrict a, int n) \ + { \ + TYPE r = 0; \ + for (int i = 0; i < n; ++i) \ + r += a[i]; \ + return r; \ + } + +#define TEST_PLUS(T) T (int) T (float) + +TEST_PLUS (DEF_REDUC_PLUS) + +/* { dg-final { scan-assembler-not {vsetivli\s+zero,\s*4} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111848.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111848.c new file mode 100644 index 0000000000..5a673f509f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr111848.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic -fdump-tree-vect-details" } */ + +#include +void +f3 (uint8_t *restrict a, uint8_t *restrict b, + uint8_t *restrict c, uint8_t *restrict d, + int n) +{ + for (int i = 0; i < n; ++i) + { + a[i * 8] = c[i * 8] + d[i * 8]; + a[i * 8 + 1] = c[i * 8] + d[i * 8 + 1]; + a[i * 8 + 2] = c[i * 8 + 2] + d[i * 8 + 2]; + a[i * 8 + 3] = c[i * 8 + 2] + d[i * 8 + 3]; + a[i * 8 + 4] = c[i * 8 + 4] + d[i * 8 + 4]; + a[i * 8 + 5] = c[i * 8 + 4] + d[i * 8 + 5]; + a[i * 8 + 6] = c[i * 8 + 6] + d[i * 8 + 6]; + a[i * 8 + 7] = c[i * 8 + 6] + d[i * 8 + 7]; + b[i * 8] = c[i * 8 + 1] + d[i * 8]; + b[i * 8 + 1] = c[i * 8 + 1] + d[i * 8 + 1]; + b[i * 8 + 2] = c[i * 8 + 3] + d[i * 8 + 2]; + b[i * 8 + 3] = c[i * 8 + 3] + d[i * 8 + 3]; + b[i * 8 + 4] = c[i * 8 + 5] + d[i * 8 + 4]; + b[i * 8 + 5] = c[i * 8 + 5] + d[i * 8 + 5]; + b[i * 8 + 6] = c[i * 8 + 7] + d[i * 8 + 6]; + b[i * 8 + 7] = c[i * 8 + 7] + d[i * 8 + 7]; + } +} + +/* { dg-final { scan-assembler {e8,m4} } } */ +/* { dg-final { scan-assembler-not {jr} } } */ +/* { dg-final { scan-assembler-times {ret} 1 } } */ +/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it has unexpected spills" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr112387-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr112387-1.c new file mode 100644 index 0000000000..ee44b5f09e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr112387-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-tree-vect-details" } */ + +#include + +void +f2 (uint64_t *__restrict y, uint64_t *__restrict x, + uint64_t *__restrict indices, uint64_t n) +{ + for (int64_t i = 0; i < n; ++i) + { + y[i * 2] = x[indices[i * 2]] + 1; + y[i * 2 + 1] = x[indices[i * 2 + 1]] + 2; + } +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect } } */ +/* { dg-final { scan-assembler-not "vlseg" } } */ +/* { dg-final { scan-assembler-not "vsseg" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr112387-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr112387-2.c new file mode 100644 index 0000000000..d9fcad6de9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr112387-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -mtune=generic-ooo -O3 -ftree-vectorize -fdump-tree-vect-details" } */ + +#include + +void +f2 (uint64_t *__restrict y, uint64_t *__restrict x, + uint64_t *__restrict indices, uint64_t n) +{ + for (int64_t i = 0; i < n; ++i) + { + y[i * 2] = x[indices[i * 2]] + 1; + y[i * 2 + 1] = x[indices[i * 2 + 1]] + 2; + } +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect } } */ +/* { dg-final { scan-assembler-not "vlseg" } } */ +/* { dg-final { scan-assembler-not "vsseg" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-1.c new file mode 100644 index 0000000000..2dc39ad8e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=fixed-vlmax -fdump-tree-vect-details" } */ + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum,x; + + for (i = 0; i < n; i++) { + sum = 0; + for (j = 0; j < n; j++) { + sum += (i + j); + } + a[i] = sum; + } + return 0; +} + +/* { dg-final { scan-assembler {e32,m4} } } */ +/* { dg-final { scan-assembler-not {jr} } } */ +/* { dg-final { scan-assembler-times {ret} 1 } } */ +/* { dg-final { scan-tree-dump-times "Preferring smaller LMUL loop because it has unexpected spills" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-2.c new file mode 100644 index 0000000000..bc4f40d4b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=fixed-vlmax -fdump-tree-vect-details" } */ + +#define TYPE double +#define N 200 + +#include + +void addconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ +#if defined (UNROLL) +#pragma GCC unroll 16 +#endif + for (int i=0; i < N; i++) + c[i] = ~a[i] + ~b[i]; +} + +/* { dg-final { scan-assembler {e64,m4} } } */ +/* { dg-final { scan-tree-dump-times "Maximum lmul = 4, At most 16 number of live V_REG" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-3.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-3.c new file mode 100644 index 0000000000..c80936246d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-3.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=fixed-vlmax" } */ + +int f[12][100]; + +void bad1(int v1, int v2) +{ + for (int r = 0; r < 100; r += 4) + { + int i = r + 1; + f[0][r] = f[1][r] * (f[2][r]) - f[1][i] * (f[2][i]); + f[0][i] = f[1][r] * (f[2][i]) + f[1][i] * (f[2][r]); + f[0][r+2] = f[1][r+2] * (f[2][r+2]) - f[1][i+2] * (f[2][i+2]); + f[0][i+2] = f[1][r+2] * (f[2][i+2]) + f[1][i+2] * (f[2][r+2]); + } +} + +/* { dg-final { scan-assembler {e32,m2} } } */ +/* { dg-final { scan-assembler-not {jr} } } */ +/* { dg-final { scan-assembler-times {ret} 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-4.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-4.c new file mode 100644 index 0000000000..5c55a66ed7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-4.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -Ofast -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=fixed-vlmax -fno-schedule-insns -fno-schedule-insns2" } */ + +typedef struct rtx_def *rtx; +struct replacement { + rtx *where; + rtx *subreg_loc; + int mode; +}; +static struct replacement replacements[150]; +void move_replacements (rtx *x, rtx *y, int n_replacements) +{ + int i; + for (i = 0; i < n_replacements; i++) + if (replacements[i].subreg_loc == x) + replacements[i].subreg_loc = y; + else if (replacements[i].where == x) + { + replacements[i].where = y; + replacements[i].subreg_loc = 0; + } +} + +/* { dg-final { scan-assembler {e64,m2} } } */ +/* { dg-final { scan-assembler-not {e64,m4} } } */ +/* { dg-final { scan-assembler-not {jr} } } */ +/* { dg-final { scan-assembler {ret} } } */ +/* { dg-final { scan-assembler-not {sp} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-5.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-5.c new file mode 100644 index 0000000000..117d54f68f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/pr113112-5.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=fixed-vlmax -fno-schedule-insns -fno-schedule-insns2" } */ + +typedef struct { + int iatom[3]; + int blocknr; +} t_sortblock; + +#define DIM 3 + +void foo (int ncons, t_sortblock *sb, int *iatom) +{ + int i, m; + + for(i=0; (i +#define _RISCV_VECTOR_WRAP_H + +#endif diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/rvv-costmodel-vect.exp b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/rvv-costmodel-vect.exp new file mode 100644 index 0000000000..84f9e3d3e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/rvv-costmodel-vect.exp @@ -0,0 +1,52 @@ +# Copyright (C) 2023-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp + +# Exit immediately if this isn't a riscv target. +if { ![istarget riscv*-*-*] } then { + return +} + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +set gcc_march "rv64gcv_zvfh" +set gcc_mabi "lp64d" +if [istarget riscv32-*-*] then { + set gcc_march "rv32gcv_zvfh" + set gcc_mabi "ilp32d" +} + +# Initialize `dg'. +dg-init + +# Main loop. +set CFLAGS "$DEFAULT_CFLAGS -march=$gcc_march -mabi=$gcc_mabi -O3" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ + "" $CFLAGS + +# All done. +dg-finish diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-1.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-1.c new file mode 100644 index 0000000000..1ef4215e72 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */ + +void +foo (int *__restrict a, int *__restrict b, int *__restrict c) +{ + for (int i = 0; i < 16; i++) + a[i] = b[i] + c[i]; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*4,\s*e32,\s*m1,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetvli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-10.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-10.c new file mode 100644 index 0000000000..3ddffa37fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-10.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=m4 -fno-schedule-insns -fno-schedule-insns2" } */ + +#include + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + } + a[i] = sum; + } + return 0; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*8,\s*e32,\s*m2,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*16,\s*e32,\s*m4,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 2 } } */ +/* { dg-final { scan-assembler-not {vsetvli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-11.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-11.c new file mode 100644 index 0000000000..7625ec5c4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-11.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -fno-schedule-insns -fno-schedule-insns2" } */ + +#include + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + } + a[i] = sum; + } + return 0; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*8,\s*e32,\s*m2,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-x0-9]+,\s*e32,\s*m8,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli} 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-12.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-12.c new file mode 100644 index 0000000000..7625ec5c4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-12.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -fno-schedule-insns -fno-schedule-insns2" } */ + +#include + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + } + a[i] = sum; + } + return 0; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*8,\s*e32,\s*m2,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-x0-9]+,\s*e32,\s*m8,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli} 1 } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-2.c new file mode 100644 index 0000000000..ca203f5084 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=m2" } */ + +void +foo (int *__restrict a, int *__restrict b, int *__restrict c) +{ + for (int i = 0; i < 16; i++) + a[i] = b[i] + c[i]; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*8,\s*e32,\s*m2,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetvli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-3.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-3.c new file mode 100644 index 0000000000..f8e5335078 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=m4" } */ + +void +foo (int *__restrict a, int *__restrict b, int *__restrict c) +{ + for (int i = 0; i < 16; i++) + a[i] = b[i] + c[i]; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*16,\s*e32,\s*m4,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetvli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-4.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-4.c new file mode 100644 index 0000000000..4859d570c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-4.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8" } */ + +void +foo (int *__restrict a, int *__restrict b, int *__restrict c) +{ + for (int i = 0; i < 16; i++) + a[i] = b[i] + c[i]; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*16,\s*e32,\s*m4,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetvli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-5.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-5.c new file mode 100644 index 0000000000..8a568028bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-5.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=dynamic" } */ + +void +foo (int *__restrict a, int *__restrict b, int *__restrict c) +{ + for (int i = 0; i < 16; i++) + a[i] = b[i] + c[i]; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*16,\s*e32,\s*m4,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetvli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-6.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-6.c new file mode 100644 index 0000000000..46ebd5fd49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-6.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8" } */ + +void +foo (int *__restrict a, int *__restrict b, int *__restrict c) +{ + for (int i = 0; i < 32; i++) + a[i] = b[i] + c[i]; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-x0-9]+,\s*e32,\s*m8,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetivli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-7.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-7.c new file mode 100644 index 0000000000..f5aceca32d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-7.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=dynamic" } */ + +void +foo (int *__restrict a, int *__restrict b, int *__restrict c) +{ + for (int i = 0; i < 32; i++) + a[i] = b[i] + c[i]; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-x0-9]+,\s*e32,\s*m8,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetivli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-8.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-8.c new file mode 100644 index 0000000000..ea6a7cbe2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-8.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */ + +#include + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + } + a[i] = sum; + } + return 0; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*4,\s*e32,\s*m1,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetvli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-9.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-9.c new file mode 100644 index 0000000000..7f03cb9ecb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/riscv/rvv/vla_vs_vls-9.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 --param=riscv-autovec-lmul=m2" } */ + +#include + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + } + a[i] = sum; + } + return 0; +} + +/* { dg-final { scan-assembler-times {vsetivli\s+zero,\s*8,\s*e32,\s*m2,\s*t[au],\s*m[au]} 1 } } */ +/* { dg-final { scan-assembler-times {vsetivli} 1 } } */ +/* { dg-final { scan-assembler-not {vsetvli} } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-alignpeel.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-alignpeel.c new file mode 100644 index 0000000000..9e20b4a72c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-alignpeel.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void func(double * __restrict__ v1, double * v2, unsigned n) +{ + for (unsigned i = 0; i < n; ++i) + v1[i] = v2[i]; +} + +/* { dg-final { scan-tree-dump-not "Alignment of access forced using peeling" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-fast-math-vect-pr29925.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-fast-math-vect-pr29925.c new file mode 100644 index 0000000000..6bce4ea092 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-fast-math-vect-pr29925.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "../../tree-vect.h" + +__attribute__ ((noinline)) void +interp_pitch(float *exc, float *interp, int pitch, int len) +{ + int i,k; + int maxj; + + maxj=3; + for (i=0;i +#include "../../tree-vect.h" + +#define N 16 + +void dacP98FillRGBMap (unsigned char *pBuffer) +{ + unsigned long dw, dw1; + unsigned long *pdw = (unsigned long *)(pBuffer); + + for( dw = 256, dw1 = 0; dw; dw--, dw1 += 0x01010101) + { + *pdw++ = dw1; + *pdw++ = dw1; + *pdw++ = dw1; + *pdw++ = dw1; + } +} + +/* Even with SSE2 we should only generate one IV for the induction. */ +/* { dg-final { scan-tree-dump-times "# vect_vec_iv" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr64909.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr64909.c new file mode 100644 index 0000000000..796b6104de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr64909.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-mtune=bdver1" } */ + +unsigned short a[32]; +unsigned int b[32]; +void t() +{ + int i; + for (i=0;i<12;i++) + b[i]=a[i]; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr69297.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr69297.c new file mode 100644 index 0000000000..ef74785f6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr69297.c @@ -0,0 +1,101 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=core-avx2 -fdump-tree-slp-details" } */ + +#define abs(x) (x) < 0 ? -(x) : (x) +int +foo (int* diff) +{ + int k, satd = 0, m[16], d[16]; + + m[ 0] = diff[ 0] + diff[12]; + m[ 4] = diff[ 4] + diff[ 8]; + m[ 8] = diff[ 4] - diff[ 8]; + m[12] = diff[ 0] - diff[12]; + m[ 1] = diff[ 1] + diff[13]; + m[ 5] = diff[ 5] + diff[ 9]; + m[ 9] = diff[ 5] - diff[ 9]; + m[13] = diff[ 1] - diff[13]; + m[ 2] = diff[ 2] + diff[14]; + m[ 6] = diff[ 6] + diff[10]; + m[10] = diff[ 6] - diff[10]; + m[14] = diff[ 2] - diff[14]; + m[ 3] = diff[ 3] + diff[15]; + m[ 7] = diff[ 7] + diff[11]; + m[11] = diff[ 7] - diff[11]; + m[15] = diff[ 3] - diff[15]; + + d[ 0] = m[ 0] + m[ 4]; + d[ 8] = m[ 0] - m[ 4]; + d[ 4] = m[ 8] + m[12]; + d[12] = m[12] - m[ 8]; + d[ 1] = m[ 1] + m[ 5]; + d[ 9] = m[ 1] - m[ 5]; + d[ 5] = m[ 9] + m[13]; + d[13] = m[13] - m[ 9]; + d[ 2] = m[ 2] + m[ 6]; + d[10] = m[ 2] - m[ 6]; + d[ 6] = m[10] + m[14]; + d[14] = m[14] - m[10]; + d[ 3] = m[ 3] + m[ 7]; + d[11] = m[ 3] - m[ 7]; + d[ 7] = m[11] + m[15]; + d[15] = m[15] - m[11]; + + m[ 0] = d[ 0] + d[ 3]; + m[ 1] = d[ 1] + d[ 2]; + m[ 2] = d[ 1] - d[ 2]; + m[ 3] = d[ 0] - d[ 3]; + m[ 4] = d[ 4] + d[ 7]; + m[ 5] = d[ 5] + d[ 6]; + m[ 6] = d[ 5] - d[ 6]; + m[ 7] = d[ 4] - d[ 7]; + m[ 8] = d[ 8] + d[11]; + m[ 9] = d[ 9] + d[10]; + m[10] = d[ 9] - d[10]; + m[11] = d[ 8] - d[11]; + m[12] = d[12] + d[15]; + m[13] = d[13] + d[14]; + m[14] = d[13] - d[14]; + m[15] = d[12] - d[15]; + + d[ 0] = m[ 0] + m[ 1]; + d[ 1] = m[ 0] - m[ 1]; + d[ 2] = m[ 2] + m[ 3]; + d[ 3] = m[ 3] - m[ 2]; + d[ 4] = m[ 4] + m[ 5]; + d[ 5] = m[ 4] - m[ 5]; + d[ 6] = m[ 6] + m[ 7]; + d[ 7] = m[ 7] - m[ 6]; + d[ 8] = m[ 8] + m[ 9]; + d[ 9] = m[ 8] - m[ 9]; + d[10] = m[10] + m[11]; + d[11] = m[11] - m[10]; + d[12] = m[12] + m[13]; + d[13] = m[12] - m[13]; + d[14] = m[14] + m[15]; + d[15] = m[15] - m[14]; + /* The following obviously profitable part should not make + the former unprofitable one profitable. */ + diff[16 + 16] = diff[16]; + diff[17 + 16] = diff[17]; + diff[18 + 16] = diff[18]; + diff[19 + 16] = diff[19]; + diff[20 + 16] = diff[20]; + diff[21 + 16] = diff[21]; + diff[22 + 16] = diff[22]; + diff[23 + 16] = diff[23]; + diff[24 + 16] = diff[24]; + diff[25 + 16] = diff[25]; + diff[26 + 16] = diff[26]; + diff[27 + 16] = diff[27]; + diff[28 + 16] = diff[28]; + diff[29 + 16] = diff[29]; + diff[30 + 16] = diff[30]; + diff[31 + 16] = diff[31]; + for (k=0; k<16; k++) + satd += abs(d[k]); + return satd; +} + +/* { dg-final { scan-tree-dump "vectorization is not profitable" "slp1" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing SLP tree" 1 "slp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr83202.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr83202.c new file mode 100644 index 0000000000..bdec20fea2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr83202.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +void test(double data[4][2]) +{ + for (int i = 0; i < 4; i++) + { + data[i][0] = data[i][0] * data[i][0]; + data[i][1] = data[i][1] * data[i][1]; + } +} + +/* We should vectorize this with SLP and V2DF vectors. */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr84986.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr84986.c new file mode 100644 index 0000000000..af868415f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-pr84986.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_long_long } */ + +int N; +long long fn1(void) { + short i; + long long a; + i = a = 0; + while (i < N) + a -= i++; + return a; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-31.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-31.c new file mode 100644 index 0000000000..085cb986b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-31.c @@ -0,0 +1,94 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-tree-loop-distribute-patterns" } */ + +#include +#include "../../tree-vect.h" + +#define N 32 + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +struct s tmp = { 1 }; + +int main1 () +{ + int i; + + /* unaligned */ + for (i = 0; i < N/2; i++) + { + tmp.b[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +#define N 16 +struct test { + char ca[N]; +}; + +extern struct test s; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-68.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-68.c new file mode 100644 index 0000000000..cfe7b85368 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-68.c @@ -0,0 +1,91 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "../../tree-vect.h" + +#define N 32 + +struct s{ + int m; + int n[N][N][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e; /* array e.n is aligned */ +}; + +int main1 () +{ + int i,j; + struct test1 tmp1; + + /* 1. unaligned */ + for (i = 0; i < N; i++) + { + tmp1.a.n[1][2][i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "../../tree-vect.h" + +#define N 16 +#define DIFF 242 + +unsigned char ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +void +main1 (unsigned char x, unsigned char max_result, unsigned char min_result) +{ + int i; + unsigned char udiff = 2; + unsigned char umax = x; + unsigned char umin = x; + + for (i = 0; i < N; i++) { + udiff += (unsigned char)(ub[i] - uc[i]); + } + + for (i = 0; i < N; i++) { + umax = umax < uc[i] ? uc[i] : umax; + } + + for (i = 0; i < N; i++) { + umin = umin > uc[i] ? uc[i] : umin; + } + + /* check results: */ + if (udiff != DIFF) + abort (); + if (umax != max_result) + abort (); + if (umin != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ +/* { dg-final { scan-tree-dump-times "vectorization not profitable" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-slp-2.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-slp-2.c new file mode 100644 index 0000000000..1b7ac34cca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-slp-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-slp-details" } */ + +int a[4], b[4]; +void foo() +{ + a[0] = b[0] / 7; + a[1] = b[1] / 7; + a[2] = b[2] / 7; + a[3] = b[3] / 7; +} + +/* We should cost the original division stmt, not the scalar pattern stmts. */ +/* { dg-final { scan-tree-dump-times " / 7 1 times scalar_stmt costs" 4 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-slp.c b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-slp.c new file mode 100644 index 0000000000..819c4f62f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/costmodel-vect-slp.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-slp-details" } */ + +#define N 4 + +int s1[N], s2[N], s3[N]; +void escape(int, int, int, int); + +void +foo () +{ + int t1, t2, t3, t4; + + t1 = s1[0] + s2[0] + s3[0]; + t2 = s1[1] + s2[1] + s3[1]; + t3 = s1[2] + s2[2] + s3[2]; + t4 = s1[3] + s2[3] + s3[3]; + + s3[0] = t1 - s1[0] * s2[0]; + s3[1] = t2 - s1[1] * s2[1]; + s3[2] = t3 - s1[2] * s2[2]; + s3[3] = t4 - s1[3] * s2[3]; + + escape (t1, t2, t3, t4); +} + +/* { dg-final { scan-tree-dump-not "vectorization is not profitable" "slp2" } } */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp new file mode 100644 index 0000000000..a2c548a2d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp @@ -0,0 +1,74 @@ +# Copyright (C) 1997-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp + +# Exit immediately if this isn't a x86 target. +if { (![istarget x86_64-*-*] && ![istarget i?86-*-*]) + || [is-effective-target ia32] } then { + return +} + +# Set up flags used for tests that don't specify options. +set DEFAULT_VECTCFLAGS "" + +# These flags are used for all targets. +lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fvect-cost-model=dynamic" + +# If the target system supports vector instructions, the default action +# for a test is 'run', otherwise it's 'compile'. Save current default. +# Executing vector instructions on a system without hardware vector support +# is also disabled by a call to check_vect, but disabling execution here is +# more efficient. +global dg-do-what-default +set save-dg-do-what-default ${dg-do-what-default} + +lappend DEFAULT_VECTCFLAGS "-msse2" +if [check_sse2_hw_available] { + set dg-do-what-default run +} else { + set dg-do-what-default compile +} + +# Initialize `dg'. +dg-init + +lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-pr*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-vect-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +#### Tests with special options +global SAVED_DEFAULT_VECTCFLAGS +set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS + +# -ffast-math tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-ffast-math" +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/costmodel-fast-math-vect*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# Clean up. +set dg-do-what-default ${save-dg-do-what-default} + +# All done. +dg-finish diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-1.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-1.c new file mode 100644 index 0000000000..d9f19d9043 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-1.c @@ -0,0 +1,49 @@ +#include "tree-vect.h" + +extern float copysignf (float, float); +extern float sqrtf (float); +extern float fabsf (float); +extern void abort (void); +float a[64], b[64], c[64], d[64]; + +__attribute__((noinline, noclone)) void +f1 (void) +{ + a[0] = copysignf (b[0], c[0]) + 1.0f + sqrtf (d[0]); + a[1] = copysignf (b[1], c[1]) + 2.0f + sqrtf (d[1]); + a[2] = copysignf (b[2], c[2]) + 3.0f + sqrtf (d[2]); + a[3] = copysignf (b[3], c[3]) + 4.0f + sqrtf (d[3]); + a[4] = copysignf (b[4], c[4]) + 5.0f + sqrtf (d[4]); + a[5] = copysignf (b[5], c[5]) + 6.0f + sqrtf (d[5]); + a[6] = copysignf (b[6], c[6]) + 7.0f + sqrtf (d[6]); + a[7] = copysignf (b[7], c[7]) + 8.0f + sqrtf (d[7]); +} + +__attribute__((noinline, noclone)) int +main1 () +{ + int i; + + for (i = 0; i < 8; i++) + { + asm (""); + b[i] = (i & 1) ? -4 * i : 4 * i; + c[i] = (i & 2) ? -8 * i : 8 * i; + d[i] = i * i; + } + f1 (); +#pragma GCC novector + for (i = 0; i < 8; i++) + if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + i + i - a[i]) >= 0.0001f) + abort (); + return 0; +} + +int +main () +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target { vect_call_copysignf && vect_call_sqrtf } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-2.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-2.c new file mode 100644 index 0000000000..76bb044914 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-2.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_double } */ + +#include "tree-vect.h" + +extern long int lrint (double); +extern void abort (void); +long int a[64]; +double b[64]; + +__attribute__((noinline, noclone)) void +f1 (void) +{ + a[0] = lrint (b[0]) + 1; + a[1] = lrint (b[1]) + 2; + a[2] = lrint (b[2]) + 3; + a[3] = lrint (b[3]) + 4; + a[4] = lrint (b[4]) + 5; + a[5] = lrint (b[5]) + 6; + a[6] = lrint (b[6]) + 7; + a[7] = lrint (b[7]) + 8; +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + a[0] = lrint (b[0]); + a[1] = lrint (b[1]); + a[2] = lrint (b[2]); + a[3] = lrint (b[3]); + a[4] = lrint (b[4]); + a[5] = lrint (b[5]); + a[6] = lrint (b[6]); + a[7] = lrint (b[7]); +} + +__attribute__((noinline, noclone)) int +main1 () +{ + int i; + + for (i = 0; i < 8; i++) + { + asm (""); + b[i] = ((i & 1) ? -4 * i : 4 * i) + 0.25; + } + f1 (); +#pragma GCC novector + for (i = 0; i < 8; i++) + if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1 + i) + abort (); + else + a[i] = 131.25; + f2 (); +#pragma GCC novector + for (i = 0; i < 8; i++) + if (a[i] != ((i & 1) ? -4 * i : 4 * i)) + abort (); + return 0; +} + +int +main () +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target vect_call_lrint } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-3.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-3.c new file mode 100644 index 0000000000..fd2c8be695 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-bb-slp-call-3.c @@ -0,0 +1,74 @@ +#include "tree-vect.h" + +extern double sqrt (double); +extern double fabs (double); +extern double ceil (double); +extern double floor (double); + +extern void abort (void); + +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +typedef struct { + int initialHeight, initialWidth; + int rotatedHeight, rotatedWidth; + int autoCropHeight, autoCropWidth; +} ufraw_data; + +void __attribute__((noinline,noclone)) +ufraw_test(ufraw_data *uf) +{ + int iWidth = uf->initialWidth; + int iHeight = uf->initialHeight; + double aspectRatio = ((double)iWidth) / iHeight; + double midX = iWidth / 2.0 - 0.5; + double midY = iHeight / 2.0 - 0.5; + double maxX = 0, maxY = 0; + double minX = 999999, minY = 999999; + double lastX = 0, lastY = 0, area = 0; + double scale; + int i; + for (i = 0; i < iWidth + iHeight - 1; i++) + { + int x, y; + if (i < iWidth) { // Trace the left border of the image + x = i; + y = 0; + } else { // Trace the bottom border of the image + x = iWidth - 1; + y = i - iWidth + 1; + } + double srcX = x - midX; + double srcY = y - midY; + // A digital planimeter: + area += srcY * lastX - srcX * lastY; + lastX = srcX; + lastY = srcY; + maxX = MAX(maxX, fabs(srcX)); + maxY = MAX(maxY, fabs(srcY)); + if (fabs(srcX / srcY) > aspectRatio) + minX = MIN(minX, fabs(srcX)); + else + minY = MIN(minY, fabs(srcY)); + } + scale = sqrt((iWidth - 1) * (iHeight - 1) / area); + uf->rotatedWidth = MIN(ceil(2 * maxX + 1.0) * scale, 2 * iWidth); + uf->rotatedHeight = MIN(ceil(2 * maxY + 1.0) * scale, 2 * iHeight); + uf->autoCropWidth = MIN(floor(2 * minX) * scale, 2 * iWidth); + uf->autoCropHeight = MIN(floor(2 * minY) * scale, 2 * iHeight); + if (uf->autoCropWidth != 3) + abort (); +} + +int main() +{ + ufraw_data uf_data; + ufraw_data *uf = &uf_data; + check_vect (); + uf->initialWidth = 4; + uf->initialHeight = 5; + ufraw_test(uf); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-ifcvt-1.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-ifcvt-1.c new file mode 100644 index 0000000000..f51202e085 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-ifcvt-1.c @@ -0,0 +1,17 @@ +/* PR 47892 */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_condition } */ + +void +bestseries9 (float * __restrict__ arr, int len) +{ + int i; + for (i = 0; i < len; ++i) + { + float or = arr[i]; + arr[i] = (or > 0.0f) * (2 - or * or); + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr35982.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr35982.c new file mode 100644 index 0000000000..50ea7ffc1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr35982.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_intfloat_cvt } */ + +struct mem +{ + float avg; + int len; +}; + +float method2_int16 (struct mem *mem) +{ + int i; + float avg; + + for (i = 0; i < 100; ++i) + avg += mem[i].avg * (float) mem[i].len; + + return avg; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_extract_even_odd || vect_strided2 } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { vect_extract_even_odd || vect_strided2 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr43074.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr43074.c new file mode 100644 index 0000000000..b3e9884e9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr43074.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +float +pvslockprocess(float *fout, float *fin, int framesize) +{ + int i; + float mag=0.0f, diff; + for (i = 0; i < framesize; i += 2) { + mag += fin[i]; + fout[i] = fin[i]; + fout[i+1] = fin[i+1]; + } + return mag; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr44152.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr44152.c new file mode 100644 index 0000000000..4dd3b6f846 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr44152.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +_Complex float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + { 10.0F + 20.0iF, 11.0F + 21.0iF, 12.0F + 22.0iF, 13.0F + 23.0iF, + 14.0F + 24.0iF, 15.0F + 25.0iF, 16.0F + 26.0iF, 17.0F + 27.0iF, + 18.0F + 28.0iF, 19.0F + 29.0iF, 20.0F + 30.0iF, 21.0F + 31.0iF, + 22.0F + 32.0iF, 23.0F + 33.0iF, 24.0F + 34.0iF, 25.0F + 35.0iF }; + +_Complex float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + +__attribute__ ((noinline)) _Complex float +foo (int x) +{ + int i; + _Complex float *p = a + x; + _Complex float sum = 10.0F + 20.0iF; + + for (i = 0; i < N; i++) + { + sum += *p; + p++; + } + + c[0] = sum + 66.0F + 86.0iF; + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr55281.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr55281.c new file mode 100644 index 0000000000..49232616b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-pr55281.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/55281 */ +/* { dg-do compile } */ + +static inline float +bar (float k, float j) +{ + float l = 0.0f; + if (k > j) + l = k; + float t = k / j; + float v = t * t; + if (k == 0) + v = 0.0f; + if (t > 0.4f) + v += 0.7; + if (l != 0) + v = 1.5 - v; + return v; +} + +void +foo (int *a, int b, float *d, float *e, int *f) +{ + int i, l; + for (l = 0; l != b; ++l) + for (i = 0; i != 8; ++i) + f[i] = e[i] + bar (a[i], d[i]); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-slp-27.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-slp-27.c new file mode 100644 index 0000000000..3597b3acef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-slp-27.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +float x[2*256+1]; + +void foo(void) +{ + int i; + for (i=0; i<256; ++i) + { + x[2*i] = x[2*i] * x[2*i]; + x[2*i+1] = x[2*i+1] * x[2*i+1]; + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_strided2 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-slp-38.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-slp-38.c new file mode 100644 index 0000000000..96751faae7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-slp-38.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double self[1024]; +double a[1024][1024]; +double b[1024]; + +void __attribute__((noinline,noclone)) +foo (void) +{ + int i, j; + for (i = 0; i < 1024; i+=6) + for (j = 0; j < 1024; j+=6) + { + self[i] = self[i] + a[i][j]*b[j]; + self[i+1] = self[i+1] + a[i][j+1]*b[j+1]; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! vect_strided6 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-call-1.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-call-1.c new file mode 100644 index 0000000000..ad22f6e82b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-call-1.c @@ -0,0 +1,104 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +#include "tree-vect.h" + +extern float copysignf (float, float); +extern float sqrtf (float); +extern float fabsf (float); +extern void abort (void); +float a[64], b[64], c[64], d[64]; + +__attribute__((noinline, noclone)) void +f1 (int n) +{ + int i; + for (i = 0; i < n; i++) + { + a[4 * i + 0] = copysignf (b[4 * i + 0], c[4 * i + 0]) + 1.0f + sqrtf (d[4 * i + 0]); + a[4 * i + 1] = copysignf (b[4 * i + 1], c[4 * i + 1]) + 2.0f + sqrtf (d[4 * i + 1]); + a[4 * i + 2] = copysignf (b[4 * i + 2], c[4 * i + 2]) + 3.0f + sqrtf (d[4 * i + 2]); + a[4 * i + 3] = copysignf (b[4 * i + 3], c[4 * i + 3]) + 4.0f + sqrtf (d[4 * i + 3]); + } +} + +__attribute__((noinline, noclone)) void +f2 (int n) +{ + int i; + for (i = 0; i < 2 * n; i++) + { + a[2 * i + 0] = copysignf (b[2 * i + 0], c[2 * i + 0]) + 1.0f + sqrtf (d[2 * i + 0]); + a[2 * i + 1] = copysignf (b[2 * i + 1], c[2 * i + 1]) + 2.0f + sqrtf (d[2 * i + 1]); + } +} + +__attribute__((noinline, noclone)) void +f3 (void) +{ + int i; + for (i = 0; i < 64; i++) + a[i] = copysignf (b[i], c[i]) + 1.0f + sqrtf (d[i]); +} + +__attribute__((noinline, noclone)) void +f4 (int n) +{ + int i; + for (i = 0; i < 2 * n; i++) + { + a[3 * i + 0] = copysignf (b[3 * i + 0], c[3 * i + 0]) + 1.0f + sqrtf (d[3 * i + 0]); + a[3 * i + 1] = copysignf (b[3 * i + 1], c[3 * i + 1]) + 2.0f + sqrtf (d[3 * i + 1]); + a[3 * i + 2] = copysignf (b[3 * i + 2], c[3 * i + 2]) + 3.0f + sqrtf (d[3 * i + 2]); + } +} + +__attribute__((noinline, noclone)) int +main1 () +{ + int i; + + for (i = 0; i < 64; i++) + { + asm (""); + b[i] = (i & 1) ? -4 * i : 4 * i; + c[i] = (i & 2) ? -8 * i : 8 * i; + d[i] = i * i; + } + f1 (16); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + (i & 3) + i - a[i]) >= 0.0001f) + abort (); + else + a[i] = 131.25; + f2 (16); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + (i & 1) + i - a[i]) >= 0.0001f) + abort (); + else + a[i] = 131.25; + f3 (); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + i - a[i]) >= 0.0001f) + abort (); + else + a[i] = 131.25; + f4 (10); +#pragma GCC novector + for (i = 0; i < 60; i++) + if (fabsf (((i & 2) ? -4 * i : 4 * i) + 1 + (i % 3) + i - a[i]) >= 0.0001f) + abort (); + return 0; +} + +int +main () +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" { target { vect_call_copysignf && vect_call_sqrtf } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target { { vect_call_copysignf && vect_call_sqrtf } && vect_perm3_int } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-call-2.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-call-2.c new file mode 100644 index 0000000000..d51e17ff65 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-call-2.c @@ -0,0 +1,135 @@ +/* { dg-require-effective-target vect_double } */ + +#include "tree-vect.h" + +extern long int lrint (double); +extern void abort (void); +long int a[64]; +double b[64]; + +__attribute__((noinline, noclone)) void +f1 (int n) +{ + int i; + for (i = 0; i < n; i++) + { + a[4 * i + 0] = lrint (b[4 * i + 0]) + 1; + a[4 * i + 1] = lrint (b[4 * i + 1]) + 2; + a[4 * i + 2] = lrint (b[4 * i + 2]) + 3; + a[4 * i + 3] = lrint (b[4 * i + 3]) + 4; + } +} + +__attribute__((noinline, noclone)) void +f2 (int n) +{ + int i; + for (i = 0; i < 2 * n; i++) + { + a[2 * i + 0] = lrint (b[2 * i + 0]) + 1; + a[2 * i + 1] = lrint (b[2 * i + 1]) + 2; + } +} + +__attribute__((noinline, noclone)) void +f3 (void) +{ + int i; + for (i = 0; i < 64; i++) + a[i] = lrint (b[i]) + 1; +} + +__attribute__((noinline, noclone)) void +f4 (int n) +{ + int i; + for (i = 0; i < n; i++) + { + a[4 * i + 0] = lrint (b[4 * i + 0]); + a[4 * i + 1] = lrint (b[4 * i + 1]); + a[4 * i + 2] = lrint (b[4 * i + 2]); + a[4 * i + 3] = lrint (b[4 * i + 3]); + } +} + +__attribute__((noinline, noclone)) void +f5 (int n) +{ + int i; + for (i = 0; i < 2 * n; i++) + { + a[2 * i + 0] = lrint (b[2 * i + 0]); + a[2 * i + 1] = lrint (b[2 * i + 1]); + } +} + +__attribute__((noinline, noclone)) void +f6 (void) +{ + int i; + for (i = 0; i < 64; i++) + a[i] = lrint (b[i]); +} + +__attribute__((noinline, noclone)) int +main1 () +{ + int i; + + for (i = 0; i < 64; i++) + { + asm (""); + b[i] = ((i & 1) ? -4 * i : 4 * i) + 0.25; + } + f1 (16); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1 + (i & 3)) + abort (); + else + a[i] = 131.25; + f2 (16); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1 + (i & 1)) + abort (); + else + a[i] = 131.25; + f3 (); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1) + abort (); + else + a[i] = 131.25; + f4 (16); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (a[i] != ((i & 1) ? -4 * i : 4 * i)) + abort (); + else + a[i] = 131.25; + f5 (16); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (a[i] != ((i & 1) ? -4 * i : 4 * i)) + abort (); + else + a[i] = 131.25; + f6 (); +#pragma GCC novector + for (i = 0; i < 64; i++) + if (a[i] != ((i & 1) ? -4 * i : 4 * i)) + abort (); + return 0; +} + +int +main () +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 6 "vect" { target vect_call_lrint } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target vect_call_lrint } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-complex-3.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-complex-3.c new file mode 100644 index 0000000000..07992cf72d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-complex-3.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +_Complex float a[N] = + { 10.0F + 20.0iF, 11.0F + 21.0iF, 12.0F + 22.0iF, 13.0F + 23.0iF, + 14.0F + 24.0iF, 15.0F + 25.0iF, 16.0F + 26.0iF, 17.0F + 27.0iF, + 18.0F + 28.0iF, 19.0F + 29.0iF, 20.0F + 30.0iF, 21.0F + 31.0iF, + 22.0F + 32.0iF, 23.0F + 33.0iF, 24.0F + 34.0iF, 25.0F + 35.0iF }; +_Complex float b[N] = + { 30.0F + 40.0iF, 31.0F + 41.0iF, 32.0F + 42.0iF, 33.0F + 43.0iF, + 34.0F + 44.0iF, 35.0F + 45.0iF, 36.0F + 46.0iF, 37.0F + 47.0iF, + 38.0F + 48.0iF, 39.0F + 49.0iF, 40.0F + 50.0iF, 41.0F + 51.0iF, + 42.0F + 52.0iF, 43.0F + 53.0iF, 44.0F + 54.0iF, 45.0F + 55.0iF }; + +_Complex float c[N]; +_Complex float res[N] = + { -500.0F + 1000.0iF, -520.0F + 1102.0iF, + -540.0F + 1208.0iF, -560.0F + 1318.0iF, + -580.0F + 1432.0iF, -600.0F + 1550.0iF, + -620.0F + 1672.0iF, -640.0F + 1798.0iF, + -660.0F + 1928.0iF, -680.0F + 2062.0iF, + -700.0F + 2200.0iF, -720.0F + 2342.0iF, + -740.0F + 2488.0iF, -760.0F + 2638.0iF, + -780.0F + 2792.0iF, -800.0F + 2950.0iF }; + + +__attribute__ ((noinline)) void +foo (void) +{ + int i; + + for (i = 0; i < N; i++) + c[i] = a[i] * b[i]; + +} + +int +main (void) +{ + int i; + check_vect (); + + foo (); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (c[i] != res[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-outer-7.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-outer-7.c new file mode 100644 index 0000000000..50ce3547ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-outer-7.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +float dvec[256]; + +void test1 (float x) +{ + long i, j; + for (i = 0; i < 256; ++i) + for (j = 0; j < 131072; ++j) + dvec[i] *= x; +} + +void test2 (float x) +{ + long i, j; + for (i = 0; i < 256; ++i) + for (j = 0; j < 131072; ++j) + dvec[i] *= 1.001f; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pow-1.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pow-1.c new file mode 100644 index 0000000000..6da61daa81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pow-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +float x[256]; + +void foo(void) +{ + int i; + for (i=0; i<256; ++i) + x[i] = x[i] * x[i]; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pow-2.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pow-2.c new file mode 100644 index 0000000000..fdcc4a50cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pow-2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +typedef double d_type; +struct +{ + d_type x; + d_type y; +} S[100]; + +#define N 16 +d_type foo (d_type t); + +d_type +main1 () +{ + int i; + d_type t; + + for (i = 0; i < N; i++) + { + t = (d_type) i / (d_type) 10; + S[5].x = t * t; + } + return S[5].x; +} + +int +main (void) +{ + d_type tmp = main1 (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pr25911.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pr25911.c new file mode 100644 index 0000000000..e1d0d4571f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pr25911.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +float bessel_Kn_scaled_small_x(int n) +{ + int k; + float k_term, sum1; + for(k=1; k<=n-1; k++) + { + k_term *= -1/(k * (n-k)); + sum1 += k_term; + } + return sum1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pr29925.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pr29925.c new file mode 100644 index 0000000000..9c58a48547 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-pr29925.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +__attribute__ ((noinline)) +void interp_pitch(float *exc, float *interp, int pitch, int len) +{ + int i,k; + int maxj; + + maxj=3; + for (i=0;i +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +int main1 (float x, float max_result) +{ + int i; + float diff = 2; + float max = x; + float min = 10; + + for (i = 0; i < N; i++) { + diff += (b[i] - c[i]); + } + + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != 0) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (100, 100); + main1 (0, 15); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-7.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-7.c new file mode 100644 index 0000000000..15e7248ea8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-7.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_double } */ + +/* need -funsafe-math-optimizations to vectorize the summation. + also need -ffinite-math-only to create the min/max expr. */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +double b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +double c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +int main1 (double x, double max_result) +{ + int i; + double diff = 2; + double max = x; + double min = 10; + + for (i = 0; i < N; i++) { + diff += (b[i] - c[i]); + } + + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != 0) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (100, 100); + main1 (0, 15); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-8.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-8.c new file mode 100644 index 0000000000..840d07cb8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-8.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +extern float x[128] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +extern float y[128] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +extern float z[128] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +float f (unsigned n) +{ + float ret = 0.0; + unsigned i; + for (i = 0; i < n; i++) + { + float diff = x[i] - y[i]; + ret -= diff * diff * z[i]; + } + return ret; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-9.c b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-9.c new file mode 100644 index 0000000000..0e9440caa9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/fast-math-vect-reduc-9.c @@ -0,0 +1,29 @@ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +float x[1024]; +float +test (void) +{ + int i; + float gosa = 0.0; + for (i = 0; i < 1024; ++i) + { + float tem = x[i]; + gosa += tem * tem; + } + return gosa; +} + +int main (void) +{ + check_vect (); + + if (test () != 0.0) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/ggc-pr37574.c b/SingleSource/Regression/C/gcc-dg/vect/ggc-pr37574.c new file mode 100644 index 0000000000..9ea0974548 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/ggc-pr37574.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +#include + +unsigned short in[40 +128]; +int main (void) { + int i = 0, j = 0; + unsigned int diff; + unsigned int s=0,sum=0; + for (i = 0; i < 40;i++) + { + diff = 0; + for (j = 0; j < 128;j+=8) + diff += in[j+i]; + s += ((unsigned short)diff>>3); + } + if (s != sum) + return -1; + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/gimplefe-40.c b/SingleSource/Regression/C/gcc-dg/vect/gimplefe-40.c new file mode 100644 index 0000000000..3c5bb4cf6e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/gimplefe-40.c @@ -0,0 +1,24 @@ +/* { dg-do compile { target { int128 && vect_float } } } */ +/* { dg-options "-fgimple -Wno-psabi -w" } */ +/* { dg-additional-options "-maltivec" { target { powerpc*-*-* && powerpc_altivec_ok } } } */ + +typedef float v4sf __attribute__((vector_size(16))); +v4sf __GIMPLE (ssa) +load (const void * p) +{ + __int128 unsigned _3; + v4sf _4; + v4sf _6; + float _5; + + __BB(2): + _3 = __MEM <__int128 unsigned, 8> ((char *)p_2(D)); + _4 = __VIEW_CONVERT (_3); +#if __SIZEOF_FLOAT__ == 4 + _5 = __BIT_FIELD_REF (_4, 32, 64); +#else + _5 = 1.0f; +#endif + _6 = __BIT_INSERT (_4, _5, 0); + return _6; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/gimplefe-41.c b/SingleSource/Regression/C/gcc-dg/vect/gimplefe-41.c new file mode 100644 index 0000000000..e52a3a559a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/gimplefe-41.c @@ -0,0 +1,40 @@ +/* { dg-do compile { target { vect_double && vect_long_long } } } */ +/* { dg-options "-fgimple -Wno-psabi -w" } */ +/* { dg-additional-options "-msse2" { target x86_64-*-* i?86-*-* } } */ + +typedef double __v2df __attribute__ ((__vector_size__ (16))); +typedef unsigned long long __v2di __attribute__ ((__vector_size__ (16))); + +__v2df __GIMPLE (ssa) +_mm_add_sd (__v2df x, __v2df y) +{ + __v2df z; + double _1; + double _2; + double _3; + __v2df _7; + + __BB(2): + _1 = __BIT_FIELD_REF (x_4(D), 64u, 0u); + _2 = __BIT_FIELD_REF (y_5(D), 64u, 0u); + _3 = _1 + _2; + _7 = _Literal (__v2df) {_3, _3}; + z_6 = __VEC_PERM (x_4(D), _7, _Literal (__v2di) { 2ul, 1ul }); + return z_6; +} + +__v2df __GIMPLE (ssa) +_mm_add_sd2 (__v2df x, __v2df y) +{ + __v2df z; + double _1; + double _2; + double _3; + + __BB(2): + _1 = __BIT_FIELD_REF (x_4(D), 64u, 0u); + _2 = __BIT_FIELD_REF (y_5(D), 64u, 0u); + _3 = _1 + _2; + z_6 = __BIT_INSERT (x_4(D), _3, 0); + return z_6; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/group-no-gaps-1.c b/SingleSource/Regression/C/gcc-dg/vect/group-no-gaps-1.c new file mode 100644 index 0000000000..bcea180b2f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/group-no-gaps-1.c @@ -0,0 +1,108 @@ +/* { dg-require-effective-target mmap } */ + +#include +#include + +#define COUNT 320 +#define MMAP_SIZE 0x20000 +#define ADDRESS1 0x1122000000 +#define ADDRESS2 (ADDRESS1 + MMAP_SIZE * 16) +#define TYPE unsigned int + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#define RHS0(B) b[B] +#define RHS1(B) RHS0(B) + b[(B) + 1] +#define RHS2(B) RHS1(B) + b[(B) + 2] +#define RHS3(B) RHS2(B) + b[(B) + 3] +#define RHS4(B) RHS3(B) + b[(B) + 4] +#define RHS5(B) RHS4(B) + b[(B) + 5] +#define RHS6(B) RHS5(B) + b[(B) + 6] +#define RHS7(B) RHS6(B) + b[(B) + 7] + +#define LHS0(B) a[B] +#define LHS1(B) LHS0(B) = a[(B) + 1] +#define LHS2(B) LHS1(B) = a[(B) + 2] +#define LHS3(B) LHS2(B) = a[(B) + 3] +#define LHS4(B) LHS3(B) = a[(B) + 4] +#define LHS5(B) LHS4(B) = a[(B) + 5] +#define LHS6(B) LHS5(B) = a[(B) + 6] +#define LHS7(B) LHS6(B) = a[(B) + 7] + +#define DEF_GROUP_SIZE(MULT, GAP, NO_GAP) \ + void __attribute__((noinline, noclone)) \ + gap_load_##MULT (TYPE *__restrict a, TYPE *__restrict b) \ + { \ + for (int i = 0; i < COUNT; i++) \ + a[i] = RHS##GAP (i * MULT); \ + } \ + void __attribute__((noinline, noclone)) \ + no_gap_load_##MULT (TYPE *__restrict a, TYPE *__restrict b) \ + { \ + for (int i = 0; i < COUNT; i++) \ + a[i] = RHS##NO_GAP (i * MULT); \ + } \ + void __attribute__((noinline, noclone)) \ + gap_store_##MULT (TYPE *__restrict a, TYPE *__restrict b) \ + { \ + for (int i = 0; i < COUNT; i++) \ + LHS##GAP (i * MULT) = b[i]; \ + } \ + void __attribute__((noinline, noclone)) \ + no_gap_store_##MULT (TYPE *__restrict a, TYPE *__restrict b) \ + { \ + for (int i = 0; i < COUNT; i++) \ + LHS##NO_GAP (i * MULT) = b[i]; \ + } + +#define USE_GROUP_SIZE(MULT) \ + gap_load_##MULT (end_x - COUNT, end_y - COUNT * MULT + 1); \ + no_gap_load_##MULT (end_x - COUNT, end_y - COUNT * MULT); \ + gap_store_##MULT (end_x - COUNT * MULT + 1, end_y - COUNT); \ + no_gap_store_##MULT (end_x - COUNT * MULT, end_y - COUNT) + +DEF_GROUP_SIZE (2, 0, 1) +DEF_GROUP_SIZE (3, 1, 2) +DEF_GROUP_SIZE (4, 2, 3) +DEF_GROUP_SIZE (5, 3, 4) +DEF_GROUP_SIZE (6, 4, 5) +DEF_GROUP_SIZE (7, 5, 6) +DEF_GROUP_SIZE (8, 6, 7) + +int +main (void) +{ + void *x, *y; + TYPE *end_x, *end_y; + + x = mmap ((void *) ADDRESS1, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (x == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + + y = mmap ((void *) ADDRESS2, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (y == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + + end_x = (TYPE *) ((char *) x + MMAP_SIZE); + end_y = (TYPE *) ((char *) y + MMAP_SIZE); + + USE_GROUP_SIZE (2); + USE_GROUP_SIZE (3); + USE_GROUP_SIZE (4); + USE_GROUP_SIZE (5); + USE_GROUP_SIZE (6); + USE_GROUP_SIZE (7); + USE_GROUP_SIZE (8); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/if-cvt-stores-vect-ifcvt-18.c b/SingleSource/Regression/C/gcc-dg/vect/if-cvt-stores-vect-ifcvt-18.c new file mode 100644 index 0000000000..fc710637ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/if-cvt-stores-vect-ifcvt-18.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 50 + +typedef struct { + short a; + short b; +} data; + +data in1[N], in2[N], out[N]; +short result[N*2] = {10,-7,11,-6,12,-5,13,-4,14,-3,15,-2,16,-1,17,0,18,1,19,2,20,3,21,4,22,5,23,6,24,7,25,8,26,9,27,10,28,11,29,12,30,13,31,14,32,15,33,16,34,17,35,18,36,19,37,20,38,21,39,22,40,23,41,24,42,25,43,26,44,27,45,28,46,29,47,30,48,31,49,32,50,33,51,34,52,35,53,36,54,37,55,38,56,39,57,40,58,41,59,42}; +short out1[N], out2[N]; + +__attribute__ ((noinline)) void +foo () +{ + int i; + short c, d; + + for (i = 0; i < N; i++) + { + c = in1[i].b; + d = in2[i].b; + + if (c >= d) + { + out[i].b = in1[i].a; + out[i].a = d + 5; + } + else + { + out[i].b = d - 12; + out[i].a = in2[i].a + d; + } + } +} + +int +main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + in1[i].a = i; + in1[i].b = i + 2; + in2[i].a = 5; + in2[i].b = i + 5; + __asm__ volatile (""); + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i].a != result[2*i] || out[i].b != result[2*i+1]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { { vect_no_align && { ! vect_hw_misalign } } || { ! vect_strided2 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-fast-math-vect16.c b/SingleSource/Regression/C/gcc-dg/vect/no-fast-math-vect16.c new file mode 100644 index 0000000000..5f87128933 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-fast-math-vect16.c @@ -0,0 +1,39 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float_strict } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 240 + +__attribute__ ((noinline)) +int main1 () +{ + int i; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + float diff; + + diff = 0; + for (i = 0; i < N; i++) { + diff += (b[i] - c[i]); + } + + /* check results: */ + if (diff != DIFF) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times {using an in-order \(fold-left\) reduction} 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-fre-pre-pr50208.c b/SingleSource/Regression/C/gcc-dg/vect/no-fre-pre-pr50208.c new file mode 100644 index 0000000000..996e5860ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-fre-pre-pr50208.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +char c; +int a, b; + +void foo (int j) +{ + int i; + while (--j) + { + b = 3; + for (i = 0; i < 2; ++i) + a = b ^ c; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-math-errno-slp-32.c b/SingleSource/Regression/C/gcc-dg/vect/no-math-errno-slp-32.c new file mode 100644 index 0000000000..18064cc3e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-math-errno-slp-32.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double x[256]; + +void foo(void) +{ + int i; + for (i=0; i<128; ++i) + { + x[2*i] = __builtin_pow (x[2*i], 0.5); + x[2*i+1] = __builtin_pow (x[2*i+1], 0.5); + } +} + +/* { dg-final { scan-tree-dump "pattern recognized" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-math-errno-vect-pow-1.c b/SingleSource/Regression/C/gcc-dg/vect/no-math-errno-vect-pow-1.c new file mode 100644 index 0000000000..8e3989a328 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-math-errno-vect-pow-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double x[256]; + +void foo(void) +{ + int i; + for (i=0; i<256; ++i) + x[i] = __builtin_pow (x[i], 0.5); +} + +/* { dg-final { scan-tree-dump "pattern recognized" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-1.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-1.c new file mode 100644 index 0000000000..aeaf8146b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-1.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j,k=0; + int sum,x; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + i++; + } + a[k++] = sum; + } +} + +int main (void) +{ + int i,j,k=0; + int sum; + + check_vect (); + + foo (); + + /* check results: */ +#pragma GCC novector + for (i=0; i +#include "tree-vect.h" + +#define N 40 +int a[200*N+N]; + +__attribute__ ((noinline)) void +foo (){ + int i,j; + int sum,s=0; + + for (i = 0; i < 200*N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + i++; + } + a[i] = sum; + } +} + +int main (void) +{ + int i,j,k=0; + int sum,s=0; + + check_vect (); + + foo (); + + /* check results: */ +#pragma GCC novector + for (i=0; i<200*N; i++) + { + sum = 0; + for (j = 0; j < N; j++){ + sum += (j + i); + i++; + } + if (a[i] != sum) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-3.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-3.c new file mode 100644 index 0000000000..494ff0b6f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-3.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + } + a[i] = sum; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + foo (); + + /* check results: */ +#pragma GCC novector + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,s=0; + + for (i = 0; i < 200*N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += (i + j); + i++; + } + s += sum; + } + return s; +} + +__attribute__ ((noinline)) +int bar (int i, int j) +{ +return (i + j); +} + +int main (void) +{ + int i,j,k=0; + int sum,s=0; + int res; + + check_vect (); + + res = foo (); + + /* check results: */ + for (i=0; i<200*N; i++) + { + sum = 0; + for (j = 0; j < N; j++){ + sum += bar (i, j); + i++; + } + s += sum; + } + if (res != s) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-5.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-5.c new file mode 100644 index 0000000000..ba766a3f15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-noreassoc-outer-5.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = 0; + x = a[i]; + for (j = 0; j < N; j++) { + sum += (x + j); + } + a[i] = sum + i + x; + } +} + +int main (void) +{ + int i,j; + int sum; + int aa[N]; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 16 +#define MAX 121 + +unsigned int ub[N] = {0,3,6,9,12,15,18,121,24,27,113,33,36,39,42,45}; + +/* Vectorization of reduction using loop-aware SLP (with unrolling). */ + +__attribute__ ((noinline)) +int main1 (int n) +{ + int i; + unsigned int max = 50; + + for (i = 0; i < n; i++) { + max = max < ub[2*i] ? ub[2*i] : max; + max = max < ub[2*i + 1] ? ub[2*i + 1] : max; + } + + /* Check results: */ + if (max != MAX) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N/2); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail vect_no_int_min_max } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-1.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-1.c new file mode 100644 index 0000000000..0834fd3d86 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +#define N 40 +signed short image[N][N]; +signed short block[N][N]; + +/* memory references in the inner-loop */ + +__attribute__ ((noinline)) unsigned int +foo (){ + int i,j; + unsigned int diff = 0; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + diff += (image[i][j] - block[i][j]); + } + } + return diff; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-10.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-10.c new file mode 100644 index 0000000000..d2eee349a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-10.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 40 + +int a[N]; +int b[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum,x,y; + + for (i = 0; i < N/2; i++) { + sum = 0; + x = b[2*i]; + y = b[2*i+1]; + for (j = 0; j < n; j++) { + sum += j; + } + a[2*i] = sum + x; + a[2*i+1] = sum + y; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; +int b[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum,x,y; + + if (n<=0) + return 0; + + for (i = 0; i < N/2; i++) { + sum = 0; + x = b[2*i]; + y = b[2*i+1]; + j = 0; + do { + sum += j; + } while (++j < n); + a[2*i] = sum + x; + a[2*i+1] = sum + y; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; +int b[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum,x,y; + + if (n<=0) + return 0; + + for (i = 0; i < N/2; i++) { + sum = 0; + x = b[2*i]; + y = b[2*i+1]; + for (j = 0; j < n; j++) { + sum += j; + } + a[2*i] = sum + x; + a[2*i+1] = sum + y; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum; + + for (i = 0; i < n; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] = sum; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +int a[N]; +short b[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] = sum; + b[i] = (short)sum; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + foo (); + + /* check results: */ +#pragma GCC novector + for (i=0; i +#include "tree-vect.h" + +#define N 16 + +unsigned short in[N]; + +__attribute__ ((noinline)) unsigned int +foo (short scale){ + int i; + unsigned short j; + unsigned int sum = 0; + unsigned short sum_j; + + for (i = 0; i < N; i++) { + sum_j = 0; + for (j = 0; j < N; j++) { + sum_j += j; + } + sum += ((unsigned int) in[i] * (unsigned int) sum_j) >> scale; + } + return sum; +} + +__attribute__ ((noinline)) unsigned short +bar (void) +{ + unsigned short j; + unsigned short sum_j; + sum_j = 0; + for (j = 0; j < N; j++) { + sum_j += j; + } + return sum_j; +} + +int main (void) +{ + int i; + unsigned short j, sum_j; + unsigned int sum = 0; + unsigned int res; + + check_vect (); + + for (i=0; i> 2; + } + if (res != sum) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { target vect_widen_mult_hi_to_si } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-14.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-14.c new file mode 100644 index 0000000000..411cc8fea4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-14.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +__attribute__ ((noinline)) unsigned short +foo (short scale){ + int i; + unsigned short j; + unsigned short sum = 0; + unsigned short sum_j; + + for (i = 0; i < N; i++) { + sum_j = 0; + for (j = 0; j < N; j++) { + sum_j += j; + } + sum += sum_j; + } + return sum; +} + +__attribute__ ((noinline)) unsigned short +bar (void) +{ + unsigned short j; + unsigned short sum_j; + sum_j = 0; + for (j = 0; j < N; j++) { + sum_j += j; + } + return sum_j; +} + +int main (void) +{ + int i; + unsigned short j, sum_j; + unsigned short sum = 0; + unsigned short res; + + check_vect (); + + res = foo (2); + + /* check results: */ + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int x){ + int i,j; + int sum; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] = sum + i + x; + } +} + +int main (void) +{ + int i,j; + int sum; + int aa[N]; + + check_vect (); + + foo (3); + + /* check results: */ +#pragma GCC novector + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i; + unsigned short j; + int sum = 0; + unsigned short sum_j; + + for (i = 0; i < N; i++) { + sum += i; + + sum_j = 0; + for (j = 0; j < N; j++) { + sum_j += j; + } + a[i] = sum_j + 5; + } + return sum; +} + +int main (void) +{ + int i; + unsigned short j, sum_j; + int sum = 0; + int res; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; +int b[N]; +int c[N]; + +__attribute__ ((noinline)) int +foo (){ + int i; + unsigned short j; + int sum = 0; + unsigned short sum_j; + + for (i = 0; i < N; i++) { + int diff = b[i] - c[i]; + + sum_j = 0; + for (j = 0; j < N; j++) { + sum_j += j; + } + a[i] = sum_j + 5; + + sum += diff; + } + return sum; +} + +int main (void) +{ + int i; + unsigned short j, sum_j; + int sum = 0; + int res; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum; + + for (i = 0; i < N/2; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += j; + } + a[2*i] = sum; + a[2*i+1] = 2*sum; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned short a[N]; +unsigned int b[N]; + +__attribute__ ((noinline)) int +foo (){ + unsigned short i,j; + unsigned short sum; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] = sum; + b[i] = (unsigned int)sum; + } +} + +int main (void) +{ + int i,j; + short sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; +int b[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum,x,y; + + for (i = 0; i < N/2; i++) { + sum = 0; + x = b[2*i]; + y = b[2*i+1]; + for (j = 0; j < N; j++) { + sum += j; + } + a[2*i] = sum + x; + a[2*i+1] = sum + y; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i; + unsigned short j; + int sum = 0; + unsigned short sum_j; + + for (i = 0; i < N; i++) { + sum += i; + + sum_j = i; + for (j = 0; j < N; j++) { + sum_j += j; + } + a[i] = sum_j + 5; + } + return sum; +} + +int main (void) +{ + int i; + unsigned short j, sum_j; + int sum = 0; + int res; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum; + + if (n<=0) + return 0; + + /* inner-loop index j used after the inner-loop */ + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < n; j+=2) { + sum += j; + } + a[i] = sum + j; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum; + + /* inner-loop step > 1 */ + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j+=2) { + sum += j; + } + a[i] = sum; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +/* induction variable k advances through inner and outer loops. */ + +__attribute__ ((noinline)) int +foo (int n){ + int i,j,k=0; + int sum; + + if (n<=0) + return 0; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < n; j+=2) { + sum += k++; + } + a[i] = sum + j; + } +} + +int main (void) +{ + int i,j,k=0; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (){ + int i,j; + int sum; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] += sum + i; + } +} + +int main (void) +{ + int i,j; + int sum; + int aa[N]; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int * __restrict__ b, int k){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = b[i]; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] = sum; + } + + return a[k]; +} + +int main (void) +{ + int i,j; + int sum; + int b[N]; + int a[N]; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +__attribute__ ((noinline)) int +foo (int * __restrict__ b, int k){ + int i,j; + int sum,x; + int a[N]; + + for (i = 0; i < N; i++) { + sum = b[i]; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] = sum; + } + + return a[k]; +} + +int main (void) +{ + int i,j; + int sum; + int b[N]; + int a[N]; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#if VECTOR_BITS > 256 +#define N (VECTOR_BITS / 16) +#else +#define N 16 +#endif + +unsigned short in[N]; +unsigned short coef[N]; +unsigned short a[N]; + +__attribute__ ((noinline)) unsigned int +foo (short scale){ + int i; + unsigned short j; + unsigned int sum = 0; + unsigned short sum_j; + + for (i = 0; i < N; i++) { + sum_j = 0; + for (j = 0; j < N; j++) { + sum_j += j; + } + a[i] = sum_j; + sum += ((unsigned int) in[i] * (unsigned int) coef[i]) >> scale; + } + return sum; +} + +unsigned short +bar (void) +{ + unsigned short j; + unsigned short sum_j; + + sum_j = 0; + for (j = 0; j < N; j++) { + sum_j += j; + } + + return sum_j; +} + +int main (void) +{ + int i; + unsigned short j, sum_j; + unsigned int sum = 0; + unsigned int res; + + check_vect (); + + for (i=0; i> 2; + } + if (res != sum) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { target vect_widen_mult_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-8.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-8.c new file mode 100644 index 0000000000..0ed589b47e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-outer-8.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 40 + + +__attribute__ ((noinline)) int +foo (int *a){ + int i,j; + int sum; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] = sum; + } +} + +int main (void) +{ + int i,j; + int sum; + int a[N]; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < n; j++) { + sum += j; + } + a[i] = sum; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum; + + if (n<=0) + return 0; + + for (i = 0; i < N; i++) { + sum = 0; + j = 0; + do { + sum += j; + }while (++j < n); + a[i] = sum; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum; + + if (n<=0) + return 0; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < n; j++) { + sum += j; + } + a[i] = sum; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; i 0); + } + return xe; +} + +/* { dg-final { scan-tree-dump "reduction used in loop" "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not "OUTER LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-pr86725-5.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-pr86725-5.c new file mode 100644 index 0000000000..6e7c9d8a77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-pr86725-5.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O -w" } */ + +unsigned int foo; +int +nr (unsigned int xe, unsigned int qqn) +{ + unsigned int oo, wo = 0; + + for (oo = 0; oo < 4; ++oo) + { + unsigned int qq = qqn; + do + { + wo += 1; + xe += qq; + } + while (qq-- > 0); + } + foo = wo; + return xe; +} + +/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-slp-30.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-slp-30.c new file mode 100644 index 0000000000..534bee4a16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-slp-30.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int +main1 () +{ + int i, j; + unsigned short out[N*8], a[N]; + + for (j = 0; j < N; j++) + { + for (i = 0; i < N; i++) + { + out[i*4] = 8; + out[i*4 + 1] = 18; + out[i*4 + 2] = 28; + out[i*4 + 3] = 38; + } + a[j] = 8; + } + + /* check results: */ + for (j = 0; j < N; j++) + { +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != 8 + || out[i*4 + 1] != 18 + || out[i*4 + 2] != 28 + || out[i*4 + 3] != 38) + abort(); + } + + if (a[j] != 8) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-slp-31.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-slp-31.c new file mode 100644 index 0000000000..22817a57ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-slp-31.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int +main1 () +{ + int i, j; + unsigned short out[N*8], a[N][N]; + + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + a[i][j] = 8; + } + out[i*4] = 8; + out[i*4 + 1] = 18; + out[i*4 + 2] = 28; + out[i*4 + 3] = 38; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (a[i][j] != 8) + abort (); + } + if (out[i*4] != 8 + || out[i*4 + 1] != 18 + || out[i*4 + 2] != 28 + || out[i*4 + 3] != 38) + abort(); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-1.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-1.c new file mode 100644 index 0000000000..b78af245a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-1.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 26 + +__attribute__ ((noinline)) int main1 (int X) +{ + int s = X; + int i; + + /* vectorization of reduction with induction. + Need -fno-tree-scev-cprop or else the loop is eliminated. */ + for (i = 0; i < N; i++) + s += i; + + return s; +} + +int main (void) +{ + int s; + check_vect (); + + s = main1 (3); + if (s != 328) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-2.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-2.c new file mode 100644 index 0000000000..57ebd5c92a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-2.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + int arr1[N]; + int k = 0; + int m = 3, i = 0; + + /* Vectorization of induction that is used after the loop. */ + + do { + k = k + 2; + arr1[i] = k; + m = m + k; + i++; + } while (i < N); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (arr1[i] != 2+2*i) + abort (); + } + + return m + k; +} + +int main (void) +{ + int res; + + check_vect (); + + res = main1 (); + if (res != 32 + 275) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-3.c b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-3.c new file mode 100644 index 0000000000..6f2b2210b1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-scevccp-vect-iv-3.c @@ -0,0 +1,33 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 256 +#define N (VECTOR_BITS / 16 + 10) +#else +#define N 26 +#endif + +__attribute__ ((noinline)) +unsigned int main1 () +{ + unsigned short i; + unsigned int intsum = 0; + + /* vectorization of reduction with induction, and widenning sum: + sum shorts into int. + Need -fno-tree-scev-cprop or else the loop is eliminated. */ + for (i = 0; i < N; i++) + { + intsum += i; + } + + return intsum; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" { target vect_widen_sum_hi_to_si } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-31.c b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-31.c new file mode 100644 index 0000000000..a1311504d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-31.c @@ -0,0 +1,103 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +/* N / 2 bytes has to be worth vectorizing even with peeling. */ +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 4 / 8) +#else +#define N 64 +#endif + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +struct s tmp; +__attribute__ ((noinline)) +int main1 () +{ + int i; + + /* unaligned */ + for (i = 0; i < N/2; i++) + { + tmp.b[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 16 + +struct { + char ca[N]; +} s = {}; +char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-36.c b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-36.c new file mode 100644 index 0000000000..3eada6057d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-36.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 8) +#else +#define N 32 +#endif + +struct { + char ca[N]; + char cb[N]; +} s; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.cb[i] = 3*i; + __asm__ volatile (""); + } + + for (i = 0; i < N; i++) + { + s.ca[i] = s.cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != s.cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-64.c b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-64.c new file mode 100644 index 0000000000..19fbe331b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-64.c @@ -0,0 +1,99 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define NINTS (VECTOR_BITS / 32) +#else +#define NINTS 4 +#endif + +#define N (NINTS * 4) + +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ia[N][NINTS][N + 1]; +int ic[N][N][NINTS - 1][2 * N + 2]; +int id[N][N][N + NINTS]; + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + /* Multidimensional array. Not aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][j] = ib[i]; + } + } + + /* Multidimensional array. Aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ic[i][1][1][j] = ib[i]; + } + } + + /* Multidimensional array. Not aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + id[i][1][j+1] = ib[i]; + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[i][1][j] != ib[i]) + abort(); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ic[i][1][1][j] != ib[i]) + abort(); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (id[i][1][j+1] != ib[i]) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail vect_element_align_preferred } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-65.c b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-65.c new file mode 100644 index 0000000000..d51ef31aea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-65.c @@ -0,0 +1,87 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define M 4 + +int ib[M][M][N] = {{{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}}; +int ia[M][M][N]; +int ic[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. Load and store. */ + for (i = 0; i < M; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][j] = ib[2][i][j]; + } + } + + /* check results: */ + for (i = 0; i < M; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[i][1][j] != ib[2][i][j]) + abort(); + } + } + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. Load. */ + for (i = 0; i < M; i++) + { + for (j = 0; j < N; j++) + { + ic[j] = ib[2][i][j]; + } + } + + /* check results: */ + for (i = 0; i < M; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ic[j] != ib[2][i][j]) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-66.c b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-66.c new file mode 100644 index 0000000000..e3d4d6ac57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-66.c @@ -0,0 +1,88 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +int ia[8][5][N+2]; +int ic[16][16][5][N+2]; + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + /* Multidimensional array. Aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < N; j++) + { + ia[2][6][j] = 5; + } + } + + /* check results: */ + for (i = 0; i < 16; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[2][6][j] != 5) + abort(); + } + } + /* Multidimensional array. Aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < N; j++) + ia[3][6][j+2] = 5; + } + + /* check results: */ + for (i = 0; i < 16; i++) + { +#pragma GCC novector + for (j = 2; j < N+2; j++) + { + if (ia[3][6][j] != 5) + abort(); + } + } + + /* Multidimensional array. Not aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < N; j++) + { + ic[2][1][6][j+1] = 5; + } + } + + /* check results: */ + for (i = 0; i < 16; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ic[2][1][6][j+1] != 5) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { target { {! vect_aligned_arrays} && {vect_sizes_32B_16B} } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { {vect_aligned_arrays} && {! vect_sizes_32B_16B} } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-68.c b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-68.c new file mode 100644 index 0000000000..36b79c2907 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-section-anchors-vect-68.c @@ -0,0 +1,100 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-skip-if "AArch64 tiny code model does not support programs larger than 1MiB" {aarch64_tiny} } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 64 + +struct s{ + int m; + int n[N][N][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e; /* array e.n is aligned */ +}; + +struct test1 tmp1; + +__attribute__ ((noinline)) +int main1 () +{ + int i,j; + + /* 1. unaligned */ + for (i = 0; i < N; i++) + { + tmp1.a.n[1][2][i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define NINTS (VECTOR_BITS / 32) +#else +#define NINTS 4 +#endif + +#define N (NINTS * 6) + +struct s{ + int m; + int n[N][N][N]; +}; + +struct s2{ + int m; + int n[N-1][N-1][N-1]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int pad[NINTS - 2]; + struct s e; /* array e.n is aligned */ +}; + +struct test2{ + struct s2 a; /* array a.n is unaligned */ + int b; + int c; + struct s2 e; /* array e.n is aligned */ +}; + + +struct test1 tmp1[4]; +struct test2 tmp2[4]; + +__attribute__ ((noinline)) +int main1 () +{ + int i,j; + + /* 1. unaligned (known misalignment) */ + for (i = 0; i < N; i++) + { + tmp1[2].a.n[1][2][i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + + +#define N 40 +#define M 128 +unsigned short a[M][N]; +unsigned int out[N]; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) +void +foo (){ + int i,j; + unsigned int diff; + + for (i = 0; i < N; i++) { + for (j = 0; j < M; j++) { + a[j][i] = 4; + } + out[i]=5; + } +} + +int main (void) +{ + int i, j; + check_vect (); + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { +#pragma GCC novector + for (j = 0; j < M; j++) { + if (a[j][i] != 4) + abort (); + } + if (out[i] != 5) + abort (); + } + + return 0; +} + + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-1.c b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-1.c new file mode 100644 index 0000000000..d682387038 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-1.c @@ -0,0 +1,11 @@ +/* Test for pr30485. */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ +void +foo (float a[32], float b[2][32]) +{ + int i; + for (i = 0; i < 32; i++) + a[i] = (b[0][i] > b[1][i]) ? b[0][i] : b[1][i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-2.c b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-2.c new file mode 100644 index 0000000000..8358b6e543 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-2.c @@ -0,0 +1,39 @@ +/* Test for pr30485. */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + float a[N]; + + /* Condition in loop. */ + /* This loop is vectorized on platforms that support vect_condition. */ + for (i = 0; i < N; i++) + { + a[i] = (b[i] > 0 ? b[i] : 0); + } + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != b[i]) + abort (); + } + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_condition } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-111.c b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-111.c new file mode 100644 index 0000000000..ae5d23fab8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-111.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + float a[N]; + + /* Condition in loop. */ + /* This loop is vectorized on platforms that support vect_condition. */ + for (i = 0; i < N; i++) + { + a[i] = (b[i] > 0 ? b[i] : 0); + } + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != b[i]) + abort (); + } + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target i?86-*-* x86_64-*-* ia64-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-11.c b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-11.c new file mode 100644 index 0000000000..4aaff3430a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-11.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +float B[N] = {0,0,42,42,42,0,0,0,0,0,42,42,42,42,42,0}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] >= MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-12.c b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-12.c new file mode 100644 index 0000000000..c644523a00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-12.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +float B[N] = {0,0,0,42,42,0,0,0,0,0,42,42,42,42,42,0}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + for (i = 0; i < 16; i++) + A[i] = ( A[i] > MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-13.c b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-13.c new file mode 100644 index 0000000000..5902f61f95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-13.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +float B[N] = {42,42,42,0,0,42,42,42,42,42,0,0,0,0,0,42}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] <= MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-14.c b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-14.c new file mode 100644 index 0000000000..5902f61f95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-14.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +float B[N] = {42,42,42,0,0,42,42,42,42,42,0,0,0,0,0,42}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] <= MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-15.c b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-15.c new file mode 100644 index 0000000000..7f436a69e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-trapping-math-vect-ifcvt-15.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +float B[N] = {42,42,0,0,0,42,42,42,42,42,0,0,0,0,0,42}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] < MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-tree-dom-vect-bug.c b/SingleSource/Regression/C/gcc-dg/vect/no-tree-dom-vect-bug.c new file mode 100644 index 0000000000..d31157713b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-tree-dom-vect-bug.c @@ -0,0 +1,30 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +long stack_vars_sorted[32]; + +__attribute__ ((noinline)) int +main1 (long n) +{ + long si; + + for (si = 0; si < n; ++si) + stack_vars_sorted[si] = si; +} + +int main () +{ + long si; + + check_vect (); + main1 (32); + +#pragma GCC novector + for (si = 0; si < 32; ++si) + if (stack_vars_sorted[si] != si) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-tree-fre-pr50039.c b/SingleSource/Regression/C/gcc-dg/vect/no-tree-fre-pr50039.c new file mode 100644 index 0000000000..a1824ccb01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-tree-fre-pr50039.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +extern unsigned char g_5; +extern int g_31, g_76; +int main(void) { + int i, j; + for (j=0; j < 2; ++j) { + g_31 = -3; + for (i=0; i < 2; ++i) + g_76 = (g_31 ? g_31+1 : 0) ^ g_5; + } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-tree-pre-pr45241.c b/SingleSource/Regression/C/gcc-dg/vect/no-tree-pre-pr45241.c new file mode 100644 index 0000000000..6535fd7e59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-tree-pre-pr45241.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/45241 */ +/* { dg-do compile } */ + +int +foo (short x) +{ + short i, y; + int sum; + + for (i = 0; i < x; i++) + y = x * i; + + for (i = x; i > 0; i--) + sum += y; + + return sum; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-tree-pre-slp-29.c b/SingleSource/Regression/C/gcc-dg/vect/no-tree-pre-slp-29.c new file mode 100644 index 0000000000..8491d5f007 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-tree-pre-slp-29.c @@ -0,0 +1,79 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned short in2[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +int +main1 (unsigned short *in) +{ + int i; + unsigned short out[N*8]; + + for (i = 0; i < N; i++) + { + out[i*4] = in[i*4]; + out[i*4 + 1] = in[i*4 + 1]; + out[i*4 + 2] = in[i*4 + 2]; + out[i*4 + 3] = in[i*4 + 3]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != in[i*4] + || out[i*4 + 1] != in[i*4 + 1] + || out[i*4 + 2] != in[i*4 + 2] + || out[i*4 + 3] != in[i*4 + 3]) + abort (); + } + + return 0; +} + +int +main2 (unsigned short * __restrict__ in, unsigned short * __restrict__ out) +{ + int i; + + for (i = 0; i < N; i++) + { + out[i*4] = in[i*4]; + out[i*4 + 1] = in[i*4 + 1]; + out[i*4 + 2] = in[i*4 + 2]; + out[i*4 + 3] = in[i*4 + 3]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != in[i*4] + || out[i*4 + 1] != in[i*4 + 1] + || out[i*4 + 2] != in[i*4 + 2] + || out[i*4 + 3] != in[i*4 + 3]) + abort (); + } + + return 0; +} + +int main (void) +{ + unsigned short out[N*8]; + + check_vect (); + + main1 (&in2[5]); + main2 (&in2[3], &out[3]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-tree-reassoc-bb-slp-12.c b/SingleSource/Regression/C/gcc-dg/vect/no-tree-reassoc-bb-slp-12.c new file mode 100644 index 0000000000..2202362f3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-tree-reassoc-bb-slp-12.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int out[N]; +unsigned int in1[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +unsigned int in2[N] = {10,11,12,13,14,15,16,17,18,19,110,111,112,113,114,115}; + +__attribute__ ((noinline)) int +main1 (unsigned int x, unsigned int y) +{ + int i; + unsigned int *pin1 = &in1[0]; + unsigned int *pin2 = &in2[0]; + unsigned int *pout = &out[0]; + unsigned int a0, a1, a2, a3; + + a0 = *pin2++ - *pin1++ + 23; + a1 = *pin2++ - *pin1++ + 142; + a2 = *pin2++ - *pin1++ + 2; + a3 = *pin2++ - *pin1++ + 31; + + *pout++ = a0 * x; + *pout++ = a1 * y; + *pout++ = a2 * x; + *pout++ = a3 * y; + + /* Check results. */ + if (out[0] != (in2[0] - in1[0] + 23) * x + || out[1] != (in2[1] - in1[1] + 142) * y + || out[2] != (in2[2] - in1[2] + 2) * x + || out[3] != (in2[3] - in1[3] + 31) * y) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (2, 3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-tree-sra-bb-slp-pr50730.c b/SingleSource/Regression/C/gcc-dg/vect/no-tree-sra-bb-slp-pr50730.c new file mode 100644 index 0000000000..e837418a87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-tree-sra-bb-slp-pr50730.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +typedef __complex__ float Value; +typedef struct { + Value a[16 / sizeof (Value)]; +} A; + +A sum(A a,A b) +{ + a.a[0]+=b.a[0]; + a.a[1]+=b.a[1]; + return a; +} + +/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-pr29145.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-pr29145.c new file mode 100644 index 0000000000..45cca1d199 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-pr29145.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-ipa-icf" } */ + +#include +#include "tree-vect.h" + +__attribute__ ((noinline)) +void with_restrict(int * __restrict p) +{ + int i; + int *q = p - 1; + + for (i = 0; i < 1000; ++i) { + p[i] = q[i]; + } +} + +__attribute__ ((noinline)) +void without_restrict(int * p) +{ + int i; + int *q = p - 1; + + for (i = 0; i < 1000; ++i) { + p[i] = q[i]; + } +} + +int main(void) +{ + int i; + int a[1002]; + int b[1002]; + + check_vect (); + + for (i = 0; i < 1002; ++i) { + a[i] = b[i] = i; + } + + with_restrict(a + 1); + without_restrict(b + 1); + +#pragma GCC novector + for (i = 0; i < 1002; ++i) { + if (a[i] != b[i]) + abort(); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-101.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-101.c new file mode 100644 index 0000000000..73b92177da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-101.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +#define N 9 + +struct extraction +{ + int a[N]; + int b[N]; +}; + +static int a[N] = {1,2,3,4,5,6,7,8,9}; +static int b[N] = {2,3,4,5,6,7,8,9,0}; + +__attribute__ ((noinline)) +int main1 (int x, int y) { + int i; + struct extraction *p; + p = (struct extraction *) malloc (sizeof (struct extraction)); + + /* Not vectorizable: different unknown offset. */ +#pragma GCC unroll 0 + for (i = 0; i < N; i++) + { + *((int *)p + x + i) = a[i]; + *((int *)p + y + i) = b[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (p->a[i] != a[i] || p->b[i] != b[i]) + abort(); + } + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (0, N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "can't determine dependence" 1 "vect" { target { ! vect_multiple_sizes } } } } */ +/* { dg-final { scan-tree-dump "can't determine dependence" "vect" { target vect_multiple_sizes } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-102.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-102.c new file mode 100644 index 0000000000..9a3fdab128 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-102.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +#define N 9 + +struct extraction +{ + int a[N]; + int b[N]; +}; + +static int a[N] = {1,2,3,4,5,6,7,8,9}; +static int b[N] = {2,3,4,5,6,7,8,9,9}; + +__attribute__ ((noinline)) +int main1 (int x, int y) { + int i; + struct extraction *p; + p = (struct extraction *) malloc (sizeof (struct extraction)); + + for (i = 0; i < N; i++) + { + p->a[i] = a[i]; + asm volatile ("" ::: "memory"); + } + + /* Not vectorizable: distance 1. */ +#pragma GCC unroll 0 + for (i = 0; i < N - 1; i++) + { + *((int *)p + x + i + 1) = *((int *)p + x + i); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (p->a[i] != 1) + abort(); + } + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (0, N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" { target { ! vect_multiple_sizes } } } } */ +/* { dg-final { scan-tree-dump "possible dependence between data-refs" "vect" { target vect_multiple_sizes } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-102a.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-102a.c new file mode 100644 index 0000000000..439347c3bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-102a.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +#define N 9 + +struct extraction +{ + int a[N]; + int b[N]; +}; + +static int a[N] = {1,2,3,4,5,6,7,8,9}; +static int b[N] = {2,3,4,5,6,7,8,9,9}; + +__attribute__ ((noinline)) +int main1 (int x, int y) { + int i; + struct extraction *p; + p = (struct extraction *) malloc (sizeof (struct extraction)); + + for (i = 0; i < N; i++) + { + p->a[i] = a[i]; + asm volatile ("" ::: "memory"); + } + + /* Not vectorizable: distance 1. */ + for (i = 0; i < N - 1; i++) + { + p->a[x + i + 1] = p->a[x + i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (p->a[i] != 1) + abort(); + } + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (0, N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" { target { ! vect_multiple_sizes } } } } */ +/* { dg-final { scan-tree-dump "possible dependence between data-refs" "vect" { target vect_multiple_sizes } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-37.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-37.c new file mode 100644 index 0000000000..f59eb69d99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-37.c @@ -0,0 +1,64 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +char x[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +char cb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 (char *y) +{ + struct { + char *p; + char *q; + } s; + int i; + + /* Not vectorized - can't antialias the pointer s.p from the array cb. */ + s.p = y; + for (i = 0; i < N; i++) + { + s.p[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.p[i] != cb[i]) + abort (); + } + + /* Not vectorized - can't antialias the pointer s.p from the pointer s.q. */ + s.q = cb; + for (i = 0; i < N; i++) + { + s.p[i] = s.q[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.p[i] != s.q[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (x); +} + +/* Currently the loops fail to vectorize due to aliasing problems. + If/when the aliasing problems are resolved, unalignment may + prevent vectorization on some targets. */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "can't determine dependence" 2 "vect" { target { ! vect_multiple_sizes } } } } */ +/* { dg-final { scan-tree-dump "can't determine dependence" "vect" { target vect_multiple_sizes } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-43.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-43.c new file mode 100644 index 0000000000..6b4542f594 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-43.c @@ -0,0 +1,95 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + + +__attribute__ ((noinline)) int +main1 (float *pa, float *pb, float *pc) +{ + int i; + float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + for (i = 0; i < N; i++) + { + b[i] = pb[i]; + c[i] = pc[i]; + } + + /* Vectorizable: pa may not alias pb and/or pc, even though their + addresses escape. &pa would need to escape to point to escaped memory. */ + for (i = 0; i < N; i++) + { + pa[i] = b[i] * c[i]; + } + + bar (pa,b,c); + + return 0; +} + +__attribute__ ((noinline)) int +main2 (float *pa, float *pb, float *pc) +{ + int i; + float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + for (i = 0; i < N; i++) + { + b[i] = pb[i]; + c[i] = pc[i]; + } + + /* Vectorizable: pb and pc addresses do not escape. */ + for (i = 0; i < N; i++) + { + pa[i] = b[i] * c[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (b[i] * c[i])) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (a,b,c); + main2 (a,b,c); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 6 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-45.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-45.c new file mode 100644 index 0000000000..5db05288c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-45.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (const float *pa, const float *pb, const float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + +/* Unaligned pointer accesses, with unknown alignment. + The loop bound is known and divisible by the vectorization factor. + Can't prove that the pointers don't alias. + vect-51.c is similar to this one with one difference: + the loop bound is unknown. + vect-44.c is similar to this one with one difference: + Aliasing is not a problem. */ + +__attribute__ ((noinline)) int +main1 (float *pa, float *pb, float *pc) +{ + int i; + + for (i = 0; i < N; i++) + { + pa[i] = pb[i] * pc[i]; + } + + bar (pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + float a[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (a,b,c); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-49.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-49.c new file mode 100644 index 0000000000..a33375f94f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-49.c @@ -0,0 +1,62 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + +/* Unaligned pointer read accesses, aligned pointer write access. + The loop bound is known and divisible by the vectorization factor. + Can't prove that the pointers don't alias. + vect-53.c is similar to this one with one difference: + the loop bound is unknown. + vect-48.c is similar to this one with one difference: + aliasing is not a problem. */ + +__attribute__ ((noinline)) int +main1 (float *pb, float *pc) +{ + float pa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + int i; + + for (i = 0; i < N; i++) + { + pa[i] = pb[i] * pc[i]; + } + + bar (pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + float b[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60}; + float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (b,c); + main1 (&b[1],c); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-51.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-51.c new file mode 100644 index 0000000000..5ebb8fea0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-51.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (const float *pa, const float *pb, const float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + +/* Unaligned pointer accesses, with unknown alignment. + The loop bound is unknown. + Can't prove that the pointers don't alias. + vect-45.c is similar to this one with one difference: + the loop bound is known. + vect-50.c is similar to this one with one difference: + Aliasing is not a problem. */ + +__attribute__ ((noinline)) int +main1 (int n, float *pa, float *pb, float *pc) +{ + int i; + + for (i = 0; i < n; i++) + { + pa[i] = pb[i] * pc[i]; + } + + bar (pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + float a[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (N,a,b,c); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-53.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-53.c new file mode 100644 index 0000000000..b6d251ec48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-53.c @@ -0,0 +1,63 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (const float *pa, const float *pb, const float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + +/* Unaligned pointer read accesses, aligned pointer write access. + The loop bound is unknown. + Can't prove that the pointers don't alias. + vect-49.c is similar to this one with one difference: + the loop bound is known. + vect-52.c is similar to this one with one difference: + aliasing is not a problem. */ + +__attribute__ ((noinline)) int +main1 (int n, float *pb, float *pc) +{ + float pa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + int i; + + for (i = 0; i < n; i++) + { + pa[i] = pb[i] * pc[i]; + } + + bar (pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float b[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60}; + float c[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; + + check_vect (); + + main1 (N,&b[1],c); + main1 (N,&b[1],&c[1]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-57.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-57.c new file mode 100644 index 0000000000..6291dd9d53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-57.c @@ -0,0 +1,75 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (pa[i] != (pb[i+1] * pc[i+1])) + abort (); + } + + return; +} + +__attribute__ ((noinline)) +void foo (float *pb, float *pc) +{ + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + memcpy (pb, b, sizeof (b)); + memcpy (pc, c, sizeof (c)); +} + +/* Unaligned pointer read accesses with known alignment, + and an unaligned write access with unknown alignment. + The loop bound is known and divisible by the vectorization factor. + Can't prove that the pointers don't alias. + vect-61.c is similar to this one with one difference: + the loop bound is unknown. + vect-56.c is similar to this one with two differences: + aliasing is a problem, and the write access is aligned. */ + +__attribute__ ((noinline)) int +main1 (float *pa) +{ + int i; + float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float *pb = b; + float *pc = c; + + foo (pb, pc); + + for (i = 0; i < N/2; i++) + { + pa[i] = pb[i+1] * pc[i+1]; + } + + bar (pa, pb, pc); + + return 0; +} + +int main (void) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + check_vect (); + main1 (a); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-61.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-61.c new file mode 100644 index 0000000000..d0334e3ba9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-61.c @@ -0,0 +1,77 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (pa[i] != (pb[i+1] * pc[i+1])) + abort (); + } + + return; +} + +__attribute__ ((noinline)) +void foo (float *pb, float *pc) +{ + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + memcpy (pb, b, sizeof (b)); + memcpy (pc, c, sizeof (c)); +} + +/* Unaligned pointer read accesses with known alignment, + and an unaligned write access with unknown alignment. + The loop bound is iunknown. + Can't prove that the pointers don't alias. + vect-57.c is similar to this one with one difference: + the loop bound is known. + vect-60.c is similar to this one with two differences: + aliasing is not a problem, and the write access is unaligned. */ + +__attribute__ ((noinline)) int +main1 (int n , float *pa) +{ + int i; + float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float *pb = b; + float *pc = c; + + foo (pb, pc); + + for (i = 0; i < n/2; i++) + { + pa[i] = pb[i+1] * pc[i+1]; + } + + bar (pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + int n=N; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + check_vect (); + main1 (n,a); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-79.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-79.c new file mode 100644 index 0000000000..37e474f8a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-79.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float fa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float fb[N+4] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0}; +float fc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5}; + +/* Like vect-80.c but the pointers are not annotated as restricted, + and therefore can't be antialiased. */ + +__attribute__ ((noinline)) int +main1 (float *pa, float *pb, float *pc) +{ + int i; + float *q = pb + 4; + + for (i = 0; i < N; i++) + { + pa[i] = q[i] * pc[i]; + } + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != q[i] * pc[i]) + abort(); + } + + return 0; +} + + +int main (void) +{ + check_vect (); + + main1 (fa, fb, fc); + + return 0; +} + +/* Currently the loops fail to vectorize due to aliasing problems. + If/when the aliasing problems are resolved, unalignment may + prevent vectorization on some targets. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "can't determine dependence" 1 "vect" { target { ! vect_multiple_sizes } } } } */ +/* { dg-final { scan-tree-dump "can't determine dependence" "vect" { target vect_multiple_sizes } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-1.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-1.c new file mode 100644 index 0000000000..e808c87158 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-1.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 17 + +int ia[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48}; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48}; +int res[N] = {12,24,36,48,60,72,84,96,108,120,132,144,156,168,180,192,48}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + /* Not vectorizable due to data dependence: dependence distance 1. */ + for (i = 0; i < N - 1; i++) + { + ia[i+1] = ia[i] * 4; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N - 1; i++) + { + if (ia[i] != 0) + abort (); + } + + /* Vectorizable. Dependence distance -1. */ + for (i = 0; i < N - 1; i++) + { + ib[i] = ib[i+1] * 4; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N - 1; i++) + { + if (ib[i] != res[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect(); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" {xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "dependence distance negative" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-2.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-2.c new file mode 100644 index 0000000000..25a3409ae5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-2.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 17 + +int ia[N] = {48,45,42,39,36,33,30,27,24,21,18,15,12,9,6,3,0}; +int ib[N] = {48,45,42,39,36,33,30,27,24,21,18,15,12,9,6,3,0}; +int res[N] = {48,192,180,168,156,144,132,120,108,96,84,72,60,48,36,24,12}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + /* Not vectorizable due to data dependence: dependence distance 1. */ + for (i = N - 2; i >= 0; i--) + { + ia[i] = ia[i+1] * 4; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != 0) + abort (); + } + + /* Vectorizable. Dependence distance -1. */ + for (i = N - 2; i >= 0; i--) + { + ib[i+1] = ib[i] * 4; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ib[i] != res[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" {xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "dependence distance negative" 1 "vect" { target { ! vect_multiple_sizes } } } } */ +/* { dg-final { scan-tree-dump "dependence distance negative" "vect" { target vect_multiple_sizes } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-3.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-3.c new file mode 100644 index 0000000000..d1d70dda2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-depend-3.c @@ -0,0 +1,187 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +int ia[N + 1]; +int ib[N + 1]; + +/* Vectorizable. Dependence distance -1. */ +__attribute__((noinline)) void +f1 (void) +{ + int i; + for (i = 0; i < N; i++) + { + ia[i + 1] = 1; + ib[i] = ia[i]; + } +} + +/* Not vectorizable due to data dependence: dependence distance 1. */ +__attribute__((noinline)) void +f2 (void) +{ + int i; + for (i = 0; i < N; i++) + { + ia[i] = 1; + ib[i] = ia[i + 1]; + } +} + +/* Not vectorizable due to data dependence: dependence distance 1. */ +__attribute__((noinline)) void +f3 (void) +{ + int i; + for (i = N - 1; i >= 0; i--) + { + ia[i + 1] = 1; + ib[i] = ia[i]; + } +} + +/* Vectorizable. Dependence distance -1. */ +__attribute__((noinline)) void +f4 (void) +{ + int i; + for (i = N - 1; i >= 0; i--) + { + ia[i] = 1; + ib[i] = ia[i + 1]; + } +} + +/* Vectorizable. Dependence distance -1. */ +__attribute__((noinline)) void +f5 (void) +{ + int i; + for (i = 0; i < N; i++) + { + ia[i + 1] = 1; + ia[i] = 2; + } +} + +/* Not vectorizable due to data dependence: dependence distance 1. */ +__attribute__((noinline)) void +f6 (void) +{ + int i; + for (i = 0; i < N; i++) + { + ia[i] = 1; + ia[i + 1] = 2; + } +} + +/* Not vectorizable due to data dependence: dependence distance 1. */ +__attribute__((noinline)) void +f7 (void) +{ + int i; + for (i = N - 1; i >= 0; i--) + { + ia[i + 1] = 1; + ia[i] = 2; + } +} + +/* Vectorizable. Dependence distance -1. */ +__attribute__((noinline)) void +f8 (void) +{ + int i; + for (i = N - 1; i >= 0; i--) + { + ia[i] = 1; + ia[i + 1] = 2; + } +} + +__attribute__ ((noinline)) int +main1 (void) +{ + int i, j; + + for (j = 0; j < 8; j++) + { + for (i = 0; i <= N; i++) + { + ia[i] = i + 3; + ib[i] = i + N + 3; + asm (""); + } + + switch (j) + { + case 0: f1 (); break; + case 1: f2 (); break; + case 2: f3 (); break; + case 3: f4 (); break; + case 4: f5 (); break; + case 5: f6 (); break; + case 6: f7 (); break; + case 7: f8 (); break; + } + +#pragma GCC novector + for (i = 0; i <= N; i++) + { + int ea = i + 3; + int eb = i + N + 3; + switch (j) + { + case 0: + if (i) ea = 1; + if (i == 0) eb = 3; + else if (i != N) eb = 1; + break; + case 1: + if (i != N) ea = 1; + if (i != N) eb = i + 4; + break; + case 2: + if (i) ea = 1; + if (i != N) eb = i + 3; + break; + case 3: + if (i != N) ea = 1; + if (i < N - 1) eb = 1; + else if (i == N - 1) eb = 67; + break; + case 4: + ea = 1 + (i != N); + break; + case 5: + ea = 2 - (i != N); + break; + case 6: + ea = 1 + (i == 0); + break; + case 7: + ea = 2 - (i == 0); + break; + } + if (ia[i] != ea || ib[i] != eb) + abort (); + } + } + + return 0; +} + +int main () +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" {xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "dependence distance negative" 4 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-dv-2.c b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-dv-2.c new file mode 100644 index 0000000000..407b683961 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/no-vfa-vect-dv-2.c @@ -0,0 +1,80 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define MAX 42 + +extern void abort(void); + +int main () +{ + int A[N]; + int B[N]; + int C[N]; + int D[N]; + int E[N] = {0,1,2,0}; + + int i, j; + + check_vect (); + + for (i = 0; i < N; i++) + { + A[i] = i; + B[i] = i; + C[i] = i; + D[i] = i; + } + + /* Vectorizable */ + for (i = 0; i < N-20; i++) + { + A[i] = A[i+20]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N-20; i++) + { + if (A[i] != D[i+20]) + abort (); + } + + /* Vectorizable */ + for (i = 0; i < 16; i++) + { + B[i] = B[i] + 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < 16; i++) + { + if (B[i] != C[i] + 5) + abort (); + } + + /* Not vectorizable */ + for (i = 0; i < 4; i++) + { + C[i+3] = C[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < 4; i++) + { + if (C[i] != E[i]) + abort (); + } + + return 0; +} + + +/* The initialization induction loop (with aligned access) is also vectorized. */ +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/nodump-forwprop-22.c b/SingleSource/Regression/C/gcc-dg/vect/nodump-forwprop-22.c new file mode 100644 index 0000000000..ed80afbe3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/nodump-forwprop-22.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_perm } */ +/* { dg-additional-options "-fdump-tree-cddce1 -fno-tree-fre" } */ + +typedef double vec __attribute__((vector_size (2 * sizeof (double)))); +void f (vec *px, vec *y, vec *z) +{ + vec x = *px; + vec t1 = { x[1], x[0] }; + vec t2 = { x[0], x[1] }; + *y = t1; + *z = t2; +} + +/* Optimization in forwprop1, cleanup in cddce1. */ + +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 1 "cddce1" } } */ +/* { dg-final { scan-tree-dump-not "BIT_FIELD_REF" "cddce1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/nodump-pr23073.c b/SingleSource/Regression/C/gcc-dg/vect/nodump-pr23073.c new file mode 100644 index 0000000000..d13279919a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/nodump-pr23073.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +extern struct { + int o[2]; + int p[2]; +} d; + +void C() +{ + int i; + + for( i=0; i<2; ++i ) + { + d.o[i] = 0; + d.p[i] = 0; + } + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/nodump-vect-opt-info-1.c b/SingleSource/Regression/C/gcc-dg/vect/nodump-vect-opt-info-1.c new file mode 100644 index 0000000000..6834b9a9d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/nodump-vect-opt-info-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target vect_int } } */ +/* { dg-additional-options "-std=c99 -fopt-info-vec -O3" } */ + +void +vadd (int *dst, int *op1, int *op2, int count) +{ +/* { dg-prune-output " version\[^\n\r]* alignment" } */ +/* { dg-optimized "21: loop vectorized" "" { target *-*-* } .+2 } */ +/* { dg-optimized "21: loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */ + for (int i = 0; i < count; ++i) + dst[i] = op1[i] + op2[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/nodump-vect-opt-info-2.c b/SingleSource/Regression/C/gcc-dg/vect/nodump-vect-opt-info-2.c new file mode 100644 index 0000000000..bcdf7f0767 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/nodump-vect-opt-info-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target vect_int } } */ +/* { dg-additional-options "-fopt-info-vec-all -O3" } */ + +extern void accumulate (int x, int *a); + +int test_missing_function_defn (int *arr, int n) /* { dg-note "5: vectorized 0 loops in function" } */ +/* { dg-prune-output "note: " } as we're not interested in matching any further + notes. */ +{ + int sum = 0; + for (int i = 0; i < n; ++i) /* { dg-missed "21: couldn't vectorize loop" } */ + accumulate (arr[i], &sum); /* { dg-missed "5: statement clobbers memory: accumulate \\(.*\\);" } */ + return sum; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr100756.c b/SingleSource/Regression/C/gcc-dg/vect/pr100756.c new file mode 100644 index 0000000000..7847f3eb88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr100756.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int +foo (int * restrict a, int n) +{ + int i, result = 0; + + a = __builtin_assume_aligned (a, __BIGGEST_ALIGNMENT__); + for (i = 0; i < n * 16; i++) + result += a[i]; + return result; +} + +/* { dg-final { scan-tree-dump-not "epilog loop required" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101145.c b/SingleSource/Regression/C/gcc-dg/vect/pr101145.c new file mode 100644 index 0000000000..cd11c030d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101145.c @@ -0,0 +1,187 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-O3" } */ +#include + +unsigned __attribute__ ((noinline)) +foo (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) +{ + while (n < ++l) + *a++ = *b++ + 1; + return l; +} + +unsigned __attribute__ ((noinline)) +foo_1 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned) +{ + while (UINT_MAX - 64 < ++l) + *a++ = *b++ + 1; + return l; +} + +unsigned __attribute__ ((noinline)) +foo_2 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) +{ + l = UINT_MAX - 32; + while (n < ++l) + *a++ = *b++ + 1; + return l; +} + +unsigned __attribute__ ((noinline)) +foo_3 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) +{ + while (n <= ++l) + *a++ = *b++ + 1; + return l; +} + +unsigned __attribute__ ((noinline)) +foo_4 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) +{ // infininate + while (0 <= ++l) + *a++ = *b++ + 1; + return l; +} + +unsigned __attribute__ ((noinline)) +foo_5 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) +{ + //no loop + l = UINT_MAX; + while (n < ++l) + *a++ = *b++ + 1; + return l; +} + +unsigned __attribute__ ((noinline)) +bar (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) +{ + while (--l < n) + *a++ = *b++ + 1; + return l; +} + +unsigned __attribute__ ((noinline)) +bar_1 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned) +{ + while (--l < 64) + *a++ = *b++ + 1; + return l; +} + +unsigned __attribute__ ((noinline)) +bar_2 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) +{ + l = 32; + while (--l < n) + *a++ = *b++ + 1; + return l; +} + + +int a[3200], b[3200]; +int fail; + +int +main () +{ + unsigned l, n; + unsigned res; + /* l > n*/ + n = UINT_MAX - 64; + l = n + 32; + res = foo (a, b, l, n); + if (res != 0) + fail++; + + l = n; + res = foo (a, b, l, n); + if (res != 0) + fail++; + + l = n - 1; + res = foo (a, b, l, n); + if (res != l + 1) + fail++; + + l = n - 32; + res = foo (a, b, l, n); + if (res != l + 1) + fail++; + + l = UINT_MAX; + res = foo (a, b, l, n); + if (res != 0) + fail++; + + l = n + 32; + res = foo_1 (a, b, l, n); + if (res != 0) + fail++; + + l = n + 32; + res = foo_2 (a, b, l, n); + if (res != 0) + fail++; + + l = n; + res = foo_3 (a, b, l, n); + if (res != 0) + fail++; + + l = n - 1; + res = foo_3 (a, b, l, n); + if (res != 0) + fail++; + + l = n - 2; + res = foo_3 (a, b, l, n); + if (res != l + 1) + fail++; + + res = foo_5 (a, b, l, n); + if (res != 0) + fail++; + + n = 64; + l = n - 32; + res = bar (a, b, l, n); + res++; + if (res != 0) + fail++; + + l = n; + res = bar (a, b, l, n); + res++; + if (res != 0) + fail++; + + l = n + 1; + res = bar (a, b, l, n); + res++; + if (res != l) + fail++; + + l = 0; + res = bar (a, b, l, n); + res++; + if (res != l) + fail++; + + l = 32; + res = bar_1 (a, b, l, n); + res++; + if (res != 0) + fail++; + + res = bar_1 (a, b, l, n); + res++; + if (res != 0) + fail++; + + if (fail) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 7 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101145.inc b/SingleSource/Regression/C/gcc-dg/vect/pr101145.inc new file mode 100644 index 0000000000..615d2e5e55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101145.inc @@ -0,0 +1,65 @@ +TYPE __attribute__ ((noinline)) +foo_sign (int *__restrict__ a, int *__restrict__ b, TYPE l, TYPE n) +{ + TYPE i; + for (i = l; n < i; i += C) + *a++ = *b++ + 1; + return i; +} + +TYPE __attribute__ ((noinline)) +bar_sign (int *__restrict__ a, int *__restrict__ b, TYPE l, TYPE n) +{ + TYPE i; + for (i = l; i < n; i -= C) + *a++ = *b++ + 1; + return i; +} + +int __attribute__ ((noinline)) neq (int a, int b) { return a != b; } + +int a[1000], b[1000]; +int fail; + +int +main () +{ + TYPE res; + TYPE l; + TYPE n; + n = N_BASE; + l = n - C; + res = foo_sign (a, b, l, n); + if (res != l) + fail++; + + l = n; + res = foo_sign (a, b, l, n); + if (res != l) + fail++; + + l = n + C; + res = foo_sign (a, b, l, n); + if (neq ((res - MIN) / C, 0)) + fail++; + + n = N_BASE_DOWN; + l = n - C; + res = bar_sign (a, b, l, n); + if (neq ((MAX - res) / C, 0)) + fail++; + + l = n; + res = bar_sign (a, b, l, n); + if (res != l) + fail++; + + l = n + C; + res = bar_sign (a, b, l, n); + if (res != l) + fail++; + + if (fail) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101145_1.c b/SingleSource/Regression/C/gcc-dg/vect/pr101145_1.c new file mode 100644 index 0000000000..24a9da63e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101145_1.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_char_add } */ +/* { dg-additional-options "-O3" } */ +#define TYPE signed char +#define MIN -128 +#define MAX 127 +#define N_BASE (MAX - 32) +#define N_BASE_DOWN (MIN + 32) + +#define C 3 + +#include "pr101145.inc" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101145_2.c b/SingleSource/Regression/C/gcc-dg/vect/pr101145_2.c new file mode 100644 index 0000000000..9091f60606 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101145_2.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_char_add } */ +/* { dg-additional-options "-O3" } */ +#define TYPE unsigned char +#define MIN 0 +#define MAX 255 +#define N_BASE (MAX - 32 + 1) +#define N_BASE_DOWN (MIN + 32) + +#define C 2 + +#include "pr101145.inc" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101145_3.c b/SingleSource/Regression/C/gcc-dg/vect/pr101145_3.c new file mode 100644 index 0000000000..001e5f38a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101145_3.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_long_long } */ +/* { dg-additional-options "-O3" } */ +#define TYPE int * +#define MIN ((TYPE)0) +#define MAX ((TYPE)((long long)-1)) +#define N_BASE (MIN - 32) +#define N_BASE_DOWN (MIN + 32) + +#define C 1 + +#include "pr101145.inc" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101145inf.c b/SingleSource/Regression/C/gcc-dg/vect/pr101145inf.c new file mode 100644 index 0000000000..ed49f5670b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101145inf.c @@ -0,0 +1,25 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O3" } */ +#include +#include "pr101145inf.inc" + +__attribute__ ((noinline)) +unsigned foo(unsigned val, unsigned start) +{ + unsigned cnt = 0; + for (unsigned i = start; val <= i; i+=16) + cnt++; + return cnt; +} + +void test_finite () +{ + unsigned n = foo (16, UINT_MAX - 32); + if (n != 3) + __builtin_abort (); +} + +void test_infinite () +{ + foo (15, UINT_MAX - 32); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101145inf.inc b/SingleSource/Regression/C/gcc-dg/vect/pr101145inf.inc new file mode 100644 index 0000000000..4aa3d04918 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101145inf.inc @@ -0,0 +1,28 @@ +#include +#include +#include + +void test_finite (); +void test_infinite (); + +void do_exit (int i) +{ + exit (0); +} + +int main(void) +{ + test_finite (); + struct sigaction s; + sigemptyset (&s.sa_mask); + s.sa_handler = do_exit; + s.sa_flags = 0; + sigaction (SIGALRM, &s, NULL); + alarm (1); + + test_infinite (); + + __builtin_abort (); + return 1; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101145inf_1.c b/SingleSource/Regression/C/gcc-dg/vect/pr101145inf_1.c new file mode 100644 index 0000000000..4ee3e31c7f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101145inf_1.c @@ -0,0 +1,23 @@ +/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ +/* { dg-options "-O3" } */ +#include +#include "pr101145inf.inc" + +__attribute__ ((noinline)) +unsigned foo(unsigned val, unsigned start) +{ + unsigned cnt = 0; + for (unsigned i = start; i < val; i-=16) + cnt++; + return cnt; +} + +void test_finite () +{ + foo (UINT_MAX - 15, 32); +} + +void test_infinite () +{ + foo (UINT_MAX - 14, 32); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101445.c b/SingleSource/Regression/C/gcc-dg/vect/pr101445.c new file mode 100644 index 0000000000..57a94954cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101445.c @@ -0,0 +1,27 @@ +#include "tree-vect.h" + +int a[35] = { 1, 1, 3 }; + +void __attribute__((noipa)) +foo () +{ + for (int b = 4; b >= 0; b--) + { + int tem = a[b * 5 + 3 + 1]; + a[b * 5 + 3] = tem; + a[b * 5 + 2] = tem; + a[b * 5 + 1] = tem; + a[b * 5 + 0] = tem; + } +} + +int main() +{ + check_vect (); + foo (); +#pragma GCC novector + for (int d = 0; d < 25; d++) + if (a[d] != 0) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr101505.c b/SingleSource/Regression/C/gcc-dg/vect/pr101505.c new file mode 100644 index 0000000000..e2b8945a5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr101505.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O1" } */ + +int n2; + +__attribute__ ((simd)) char +w7 (void) +{ + short int xb = n2; + int qp; + + for (qp = 0; qp < 2; ++qp) + xb = xb < 1; + + return xb; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr102046.c b/SingleSource/Regression/C/gcc-dg/vect/pr102046.c new file mode 100644 index 0000000000..ae48b497dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr102046.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -fvect-cost-model=dynamic" } */ +/* { dg-additional-options "-march=btver2" { target x86_64-*-* i?86-*-* } } */ + +struct S +{ + unsigned a, b; +}; + +struct S g; + +void +foo (struct S *o) +{ + struct S s = g; + s.b *= 3; + s.a -= s.a / 2; + *o = s; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr102318.c b/SingleSource/Regression/C/gcc-dg/vect/pr102318.c new file mode 100644 index 0000000000..cc58efacec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr102318.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +void +vec_slp_int16_t (short int *restrict a, short int *restrict b, int n) +{ + short int x0 = b[0]; + short int x1 = b[1]; + short int x2 = b[2]; + short int x3 = b[3]; + for (int i = 0; i < n; ++i) + { + x0 += a[i * 4]; + x1 += a[i * 4 + 1]; + x2 += a[i * 4 + 2]; + x3 += a[i * 4 + 3]; + } + b[0] = x0; + b[1] = x1; + b[2] = x2; + b[3] = x3; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr102832.c b/SingleSource/Regression/C/gcc-dg/vect/pr102832.c new file mode 100644 index 0000000000..7cb4db5e4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr102832.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-march=armv8.2-a+sve -msve-vector-bits=128" { target aarch64-*-* } } */ + +int a, b; +char c; +signed char d(int e, int f) { return e - f; } +void g() { + a = 0; + for (; a >= -17; a = d(a, 1)) + c ^= b; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103116-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr103116-1.c new file mode 100644 index 0000000000..d3639fc8cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103116-1.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target mmap } */ + +#include +#include + +#define COUNT 128 +#define MMAP_SIZE 0x20000 +#define ADDRESS 0x1122000000 +#define TYPE unsigned int + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +void __attribute__((noipa)) +loop (TYPE *restrict x, TYPE *restrict y) +{ + for (int i = 0; i < COUNT; ++i) + { + x[i * 4] = y[i * 2] + 1; + x[i * 4 + 1] = y[i * 2] + 2; + x[i * 4 + 2] = y[i * 2 + 1] + 3; + x[i * 4 + 3] = y[i * 2 + 1] + 4; + } +} + +TYPE x[COUNT * 4]; + +int +main (void) +{ + void *y; + TYPE *end_y; + + y = mmap ((void *) ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (y == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + + end_y = (TYPE *) ((char *) y + MMAP_SIZE); + + loop (x, end_y - COUNT * 2); + + return 0; +} + +/* { dg-final { scan-tree-dump "Data access with gaps requires scalar epilogue loop" "vect" { target { vect_perm && vect_int } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103116-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr103116-2.c new file mode 100644 index 0000000000..aa9797a940 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103116-2.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target mmap } */ +/* { dg-additional-options "-mssse3" { target x86_64-*-* i?86-*-* } } */ + +#include +#include +#include "tree-vect.h" + +#define COUNT 128 +#define MMAP_SIZE 0x20000 +#define ADDRESS 0x1122000000 +#define TYPE unsigned short +#define GROUP_SIZE 2 + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +void __attribute__((noipa)) +loop (TYPE *restrict x, TYPE *restrict y) +{ + for (int i = 0; i < COUNT; ++i) + { + x[i * 8] = y[i * GROUP_SIZE] + 1; + x[i * 8 + 1] = y[i * GROUP_SIZE] + 2; + x[i * 8 + 2] = y[i * GROUP_SIZE + 1] + 3; + x[i * 8 + 3] = y[i * GROUP_SIZE + 1] + 4; + x[i * 8 + 4] = y[i * GROUP_SIZE] + 5; + x[i * 8 + 5] = y[i * GROUP_SIZE] + 6; + x[i * 8 + 6] = y[i * GROUP_SIZE + 1] + 7; + x[i * 8 + 7] = y[i * GROUP_SIZE + 1] + 8; + } +} + +TYPE x[COUNT * 8]; + +int +main (void) +{ + void *y; + TYPE *end_y; + + check_vect (); + + y = mmap ((void *) ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (y == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + + end_y = (TYPE *) ((char *) y + MMAP_SIZE); + + loop (x, end_y - COUNT * GROUP_SIZE); + + return 0; +} + +/* { dg-final { scan-tree-dump "peeling for gaps insufficient for access" "vect" { target { vect_perm_short } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103253.c b/SingleSource/Regression/C/gcc-dg/vect/pr103253.c new file mode 100644 index 0000000000..abe3f09f38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103253.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fopenmp } */ +/* { dg-additional-options "-O2 -fexceptions -fopenmp -fno-delete-dead-exceptions -fno-trapping-math" } */ + +double +do_work (double do_work_pri) +{ + int i; + +#pragma omp simd + for (i = 0; i < 17; ++i) + do_work_pri = (!i ? 0.5 : i) * 2.0; + + return do_work_pri; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103494.c b/SingleSource/Regression/C/gcc-dg/vect/pr103494.c new file mode 100644 index 0000000000..b544bf2379 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103494.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +typedef int T1; +typedef signed char T2; + +T1 +f (T1 *d, T2 *x, int n) +{ + unsigned char res = 0; + for (int i = 0; i < n; ++i) + res += d[x[i]]; + return res; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103517.c b/SingleSource/Regression/C/gcc-dg/vect/pr103517.c new file mode 100644 index 0000000000..de87fc48f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103517.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } } */ + +int a; +short b, c; +extern short d[]; +void e() { + for (short f = 1; f < (short)a; f += 2) + if (d[f + 1]) { + b = d[f]; + c = d[f + 1]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103544.c b/SingleSource/Regression/C/gcc-dg/vect/pr103544.c new file mode 100644 index 0000000000..c8bdee86e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103544.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-march=haswell" { target x86_64-*-* i?86-*-* } } */ + +int crash_me(char* ptr, unsigned long size) +{ + short result[16] = {0}; + + unsigned long no_iters = 0; + for(unsigned long i = 0; i < size - 12; i+= 13){ + for(unsigned long j = 0; j < 12; j++){ + result[j] += ptr[i + j] - '0'; + } + no_iters++; + } + + int result_int = 0; + for(int j = 0; j < 12; j++){ + int bit_value = result[j] > no_iters/2 ? 1 : 0; + result_int |= bit_value; + } + + return result_int; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103581.c b/SingleSource/Regression/C/gcc-dg/vect/pr103581.c new file mode 100644 index 0000000000..92695c83d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103581.c @@ -0,0 +1,60 @@ +/* { dg-additional-options "-mavx2 -mtune-ctrl=use_gather" { target avx2_runtime } } */ + +#include "tree-vect.h" + +#define MASKGATHER(SUFF, TYPE1, TYPE2) \ +TYPE1 * __attribute__((noipa)) \ +maskgather ## SUFF (int n, TYPE2 *indices, TYPE1 *data) \ +{ \ + TYPE1 *out = __builtin_malloc (sizeof (TYPE1) * n); \ + for (int i = 0; i < n; ++i) \ + { \ + TYPE2 d = indices[i]; \ + if (d > 1) \ + out[i] = data[d]; \ + } \ + return out; \ +} + +MASKGATHER(udiusi, unsigned long long, unsigned int) +MASKGATHER(usiusi, unsigned int, unsigned int) +MASKGATHER(udiudi, unsigned long long, unsigned long long) +MASKGATHER(usiudi, unsigned int, unsigned long long) + +int +main() +{ + check_vect (); + + unsigned int idx4[32], data4[32]; + unsigned long long idx8[32], data8[32]; + for (int i = 0; i < 32; ++i) + { + idx4[i] = i; + idx8[i] = i; + data4[i] = i; + data8[i] = i; + } + unsigned long long *resudiusi = maskgatherudiusi (16, idx4, data8); + unsigned int *resusiusi = maskgatherusiusi (16, idx4, data4); + unsigned long long *resudiudi = maskgatherudiudi (16, idx8, data8); + unsigned int *resusiudi = maskgatherusiudi (16, idx8, data4); +#pragma GCC novector + for (int i = 0; i < 16; ++i) + { + unsigned int d = idx4[i]; + if (d > 1) + { + if (resudiusi[i] != data4[d]) + __builtin_abort (); + if (resudiudi[i] != data4[d]) + __builtin_abort (); + if (resusiudi[i] != data4[d]) + __builtin_abort (); + if (resusiusi[i] != data4[d]) + __builtin_abort (); + } + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103744-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr103744-1.c new file mode 100644 index 0000000000..1bc81e26fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103744-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int r; + +void +foo (short int *s, short int *d1, short int *d2, int z) +{ + int *a; + + while (z < 1) + { + int i; + + i = *s++ - (*d1++ + *d2++); + r += a[i]; + i = *s++ - (*d1++ + *d2++); + r += a[i]; + ++z; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103744-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr103744-2.c new file mode 100644 index 0000000000..52307abf24 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103744-2.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ + +int +f1 (int *restrict x, unsigned short *restrict y) +{ + int res = 0; + for (int i = 0; i < 100; i += 2) + { + unsigned short i1 = y[i + 0] + 1; + unsigned short i2 = y[i + 1] + 2; + res += x[i1]; + res += x[i2]; + } + return res; +} + +void +f2 (int *restrict x, unsigned short *restrict y) +{ + int res1 = 0; + int res2 = 0; + for (int i = 0; i < 100; i += 2) + { + unsigned short i1 = y[i + 0] + 1; + unsigned short i2 = y[i + 1] + 2; + res1 += x[i1]; + res2 += x[i2]; + } + x[0] = res1; + x[1] = res2; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103761.c b/SingleSource/Regression/C/gcc-dg/vect/pr103761.c new file mode 100644 index 0000000000..0982a63eb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103761.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +void f(long *restrict x, int *restrict y, short *restrict z, int *restrict a) +{ + for (int i = 0; i < 100; i += 4) + { + x[i] = (long) y[z[i]] + 1; + x[i + 1] = (long) y[z[i + 1]] + 2; + x[i + 2] = (long) y[z[i + 2]] + 3; + x[i + 3] = (long) y[z[i + 3]] + 4; + a[i] += 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr103864.c b/SingleSource/Regression/C/gcc-dg/vect/pr103864.c new file mode 100644 index 0000000000..464d5731a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr103864.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -fno-tree-reassoc" } */ + +void +crash_me (short int *crash_me_result, int i, char crash_me_ptr_0) +{ + while (i < 1) + { + int j; + + for (j = 0; j < 2; ++j) + crash_me_result[j] += crash_me_ptr_0 + 1; + + i += 3; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr104112-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr104112-1.c new file mode 100644 index 0000000000..84e69b8517 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr104112-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-additional-options "-march=armv8.2-a+sve -msve-vector-bits=512" { target aarch64-*-* } } */ + +void +boom(int n, double *a, double *x) +{ + int i, j; + double temp; + + for (j = n; j >= 1; --j) + { + temp = x[j]; + for (i = j - 1; i >= 1; --i) + temp += a[i + j] * x[i]; + x[j] = temp; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr104112-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr104112-2.c new file mode 100644 index 0000000000..7469b3c5d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr104112-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* Diagnose vector ops that are later decomposed. */ +/* { dg-additional-options "-Wvector-operation-performance" } */ + +unsigned short foo (unsigned short *a, int n) +{ + unsigned short sum = 0; + for (int i = 0; i < n; ++i) + sum += a[i]; + return sum; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr104152.c b/SingleSource/Regression/C/gcc-dg/vect/pr104152.c new file mode 100644 index 0000000000..3a313c32dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr104152.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-additional-options "-march=armv8.2-a+sve" { target aarch64-*-* } } */ + +#define M_PI 3.14f +#define NK 24 +#define DIM 3 + +typedef float rvec_ [3]; + +static rvec_ v0[NK] = { + { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 1, 1, 0 }, { 1, -1, 0 }, + { 1, 0, 1 }, { 1, 0, -1 }, { 0, 1, 1 }, { 0, 1, -1 }, { 1, 1, 1 }, + { 1, 1, -1 }, { 1, -1, 1 }, { -1, 1, 1 }, { 2, 0, 0 }, { 0, 2, 0 }, + { 0, 0, 2 }, { 3, 0, 0 }, { 0, 3, 0 }, { 0, 0, 3 }, { 4, 0, 0 }, + { 0, 4, 0 }, { 0, 0, 4 } }; + +static inline float iprod__(const rvec_ a, const rvec_ b) +{ + return (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]); +} + +int badaboum(rvec_ cm_mol, float **tc) +{ + float sx; + int k, d; + rvec_ kfac[3]; + + for (k = 0; k < DIM; k++) + for (d = 0; d < DIM; d++) + kfac[k][d] = M_PI * v0[k][d] / v0[d][d]; + + for (k = 0; k < DIM; k++) + { + sx = __builtin_sinf(iprod__(kfac[k], cm_mol)); + tc[k][0] += sx * iprod__(v0[k], cm_mol); + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr104445.c b/SingleSource/Regression/C/gcc-dg/vect/pr104445.c new file mode 100644 index 0000000000..8ec3b3b0f1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr104445.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mavx -mno-mmx" { target x86_64-*-* i?86-*-* } } */ + +signed char a; +signed char f (int i, int j) +{ + signed char c; + while (i != 0) + { + a ^= j; + ++c; + ++i; + } + return c; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr104595.c b/SingleSource/Regression/C/gcc-dg/vect/pr104595.c new file mode 100644 index 0000000000..bb7d79aa69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr104595.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ + +#define N 256 +typedef char T; +extern T a[N]; +extern T b[N]; +extern T c[N]; +extern _Bool pb[N]; +extern char pc[N]; + +void predicate_by_bool() +{ + for (int i = 0; i < N; i++) + c[i] = pb[i] ? a[i] : b[i]; +} + +void predicate_by_char() +{ + for (int i = 0; i < N; i++) + c[i] = pc[i] ? a[i] : b[i]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr104782.c b/SingleSource/Regression/C/gcc-dg/vect/pr104782.c new file mode 100644 index 0000000000..7b8ca6ca25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr104782.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-march=armv8.2-a+sve -msve-vector-bits=128" { target aarch64-*-* } } */ + +int a, b, c; +static int d; +short *q; +void f() { + int *p = &d; + b = 9; + for (b = 9; b; b--) { + a = 2; + for (c = 2; c <= 9; c++) { + for (int i = 0; i < 3; i++) + *p |= (*q)++; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr105219.c b/SingleSource/Regression/C/gcc-dg/vect/pr105219.c new file mode 100644 index 0000000000..46cc3cf52b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr105219.c @@ -0,0 +1,30 @@ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mtune=intel" { target x86_64-*-* i?86-*-* } } */ +/* { dg-additional-options "-mtune=thunderx" { target aarch64*-*-* } } */ + +#include "tree-vect.h" + +int data[128]; + +void __attribute((noipa)) +foo (int *data, int n) +{ + for (int i = 0; i < n; ++i) + data[i] = i; +} + +int main() +{ + check_vect (); + for (int start = 0; start < 16; ++start) + for (int n = 1; n < 3*16; ++n) + { + __builtin_memset (data, 0, sizeof (data)); + foo (&data[start], n); +#pragma GCC novector + for (int j = 0; j < n; ++j) + if (data[start + j] != j) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr106081.c b/SingleSource/Regression/C/gcc-dg/vect/pr106081.c new file mode 100644 index 0000000000..8f97af2d64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr106081.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ffast-math -fdump-tree-optimized" } */ +/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_unpack } */ +/* { dg-require-effective-target vect_intdouble_cvt } */ +/* { dg-require-effective-target vect_perm } */ + +struct pixels +{ + short a,b,c,d; +} *pixels; +struct dpixels +{ + double a,b,c,d; +}; + +double +test(double *k) +{ + struct dpixels results={}; + for (int u=0; u<1000*16;u++,k--) + { + results.a += *k*pixels[u].a; + results.b += *k*pixels[u].b; + results.c += *k*pixels[u].c; + results.d += *k*pixels[u].d; + } + return results.a+results.b*2+results.c*3+results.d*4; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM" 4 "optimized" { target x86_64-*-* i?86-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr106250.c b/SingleSource/Regression/C/gcc-dg/vect/pr106250.c new file mode 100644 index 0000000000..7f25f55186 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr106250.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int +foo (unsigned long int x, int y, int z) +{ + int ret = 0; + + while (y < 1) + { + x *= 2; + ret = x == z; + z = y; + ++y; + } + + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr106914.c b/SingleSource/Regression/C/gcc-dg/vect/pr106914.c new file mode 100644 index 0000000000..9d9b3e3008 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr106914.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fprofile-generate" } */ +/* { dg-additional-options "-mavx512vl" { target x86_64-*-* i?86-*-* } } */ + +int *mask_slp_int64_t_8_2_x, *mask_slp_int64_t_8_2_y, *mask_slp_int64_t_8_2_z; + +void +__attribute__mask_slp_int64_t_8_2() { + for (int i; i; i += 8) { + mask_slp_int64_t_8_2_x[i + 6] = + mask_slp_int64_t_8_2_y[i + 6] ? mask_slp_int64_t_8_2_z[i] : 1; + mask_slp_int64_t_8_2_x[i + 7] = + mask_slp_int64_t_8_2_y[i + 7] ? mask_slp_int64_t_8_2_z[i + 7] : 2; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107160.c b/SingleSource/Regression/C/gcc-dg/vect/pr107160.c new file mode 100644 index 0000000000..f5883ac0ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107160.c @@ -0,0 +1,39 @@ +#include + +#define N 128 +float fl[N]; + +__attribute__ ((noipa)) void +init () +{ + for (int i = 0; i < N; i++) + fl[i] = i; +} + +__attribute__ ((noipa)) float +foo (int n1) +{ + float sum0, sum1, sum2, sum3; + sum0 = sum1 = sum2 = sum3 = 0.0f; + + int n = (n1 / 4) * 4; + for (int i = 0; i < n; i += 4) + { + sum0 += fabs (fl[i]); + sum1 += fabs (fl[i + 1]); + sum2 += fabs (fl[i + 2]); + sum3 += fabs (fl[i + 3]); + } + + return sum0 + sum1 + sum2 + sum3; +} + +int +main () +{ + init (); + float res = foo (80); + if (res != 3160) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107212-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr107212-1.c new file mode 100644 index 0000000000..453d932463 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107212-1.c @@ -0,0 +1,25 @@ +#include "tree-vect.h" + +int main() +{ + check_vect (); + + unsigned int tab[6][2] = { {69, 73}, {36, 40}, {24, 16}, + {16, 11}, {4, 5}, {3, 1} }; + + int sum_0 = 0; + int sum_1 = 0; + + for(int t=0; t<6; t++) { + sum_0 += tab[t][0]; + sum_1 += tab[t][1]; + } + + int x1 = (sum_0 < 100); + int x2 = (sum_0 > 200); + + if (x1 || x2 || sum_1 != 146) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107212-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr107212-2.c new file mode 100644 index 0000000000..bdfece72d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107212-2.c @@ -0,0 +1,21 @@ +#include "tree-vect.h" + +int sum_1 = 0; + +int main() +{ + check_vect (); + + unsigned int tab[6][2] = {{150, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}; + + int sum_0 = 0; + + for (int t = 0; t < 6; t++) { + sum_0 += tab[t][0]; + sum_1 += tab[t][0]; + } + + if (sum_0 < 100 || sum_0 > 200) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107229-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr107229-1.c new file mode 100644 index 0000000000..67b432383d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107229-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* PR tree-optimization/107229. */ + +int a, c; +struct { + long d; + int : 8; + int : 27; + int e : 21; +} f; +void g(int b) { a = a & 1; } +int main() { + while (c) + g(f.e); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107229-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr107229-2.c new file mode 100644 index 0000000000..88bffb63d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107229-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* PR tree-optimization/107229. */ + +int a, c; +struct { + long f; + long g; + long d; + int : 8; + int : 27; + int e : 21; +} f; +void g(int b) { a = a & 1; } +int main() { + while (c) + g(f.e); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107229-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr107229-3.c new file mode 100644 index 0000000000..4abd8c1453 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107229-3.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* PR tree-optimization/107229. */ + +int a, c; +struct { + long f; + long g; + long d; + int : 8; + int : 32; + int : 2; + int e : 21; +} f; +void g(int b) { a = a & 1; } +int main() { + while (c) + g(f.e); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107275.c b/SingleSource/Regression/C/gcc-dg/vect/pr107275.c new file mode 100644 index 0000000000..16327c46ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107275.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +struct st +{ + int a : 1; +}; + +void +foo (struct st *s, int n) +{ + for (int i = 0; i < n; ++i) + { + s[i].a = i; + __asm__ __volatile__ ("":::"memory"); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107302.c b/SingleSource/Regression/C/gcc-dg/vect/pr107302.c new file mode 100644 index 0000000000..293f7e4067 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107302.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-pre" } */ + +int a[2000]; +int s292_im1; + +void +s292() { + for (int i = 0; i < 2000; i++) { + a[i] = s292_im1; + s292_im1 = i; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr107326.c b/SingleSource/Regression/C/gcc-dg/vect/pr107326.c new file mode 100644 index 0000000000..333a515e74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr107326.c @@ -0,0 +1,24 @@ +/* PR107326 */ +/* { dg-do compile } */ +struct Gsymtab { + unsigned int : 8; + unsigned int visited_somewhere : 1; +}; + +extern struct Gsymtab glob_symtab[]; + +int +visit_children (int i) +{ + int numvisited = 0; + + while (i < 1) + { + if (glob_symtab[i].visited_somewhere) + ++numvisited; + + ++i; + } + + return numvisited; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr108314.c b/SingleSource/Regression/C/gcc-dg/vect/pr108314.c new file mode 100644 index 0000000000..07260e0691 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr108314.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv9-a" { target aarch64-*-* } } */ + +int x, y, z; + +void f(void) +{ + int t = 4; + for (; x; x++) + { + if (y) + continue; + t = 0; + } + z = t; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr108316.c b/SingleSource/Regression/C/gcc-dg/vect/pr108316.c new file mode 100644 index 0000000000..540b7f2aed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr108316.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +extern _Bool a[]; + +void +foo (short i, int b[][64][1]) +{ + for (; i < 64; i += 4) + a[i] = b[0][i] != 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr108608.c b/SingleSource/Regression/C/gcc-dg/vect/pr108608.c new file mode 100644 index 0000000000..fff5c1a893 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr108608.c @@ -0,0 +1,25 @@ +#include "tree-vect.h" + +double __attribute__((noipa)) +foo (double m, float *ptr) +{ + for (int i = 0; i < 256; i++) + m = __builtin_fmax (m, ptr[i]); + return m; +} + +int +main (void) +{ + check_vect (); + float ptr[256]; +#pragma GCC novector + for (int j = 0; j < 16; ++j) + { + for (int i = 0; i < 256; ++i) + ptr[i] = i == 128 + j ? 2 + j : i == 161 ? 1 : 0; + if (foo (0, ptr) != 2 + j) + __builtin_abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr108950.c b/SingleSource/Regression/C/gcc-dg/vect/pr108950.c new file mode 100644 index 0000000000..563c4b9df3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr108950.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_simd_clones } */ + +int m; +short int n; + +__attribute__ ((simd)) int +foo (void) +{ + m += n; + m += n; +} + +/* { dg-final { scan-tree-dump-not "widen_sum" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr109011-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr109011-1.c new file mode 100644 index 0000000000..9bb8ee10a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr109011-1.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/109011 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-unroll-loops --param=vect-epilogues-nomask=0 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mavx512cd" { target { { i?86-*-* x86_64-*-* } && avx512cd } } } */ +/* { dg-additional-options "-mavx512vpopcntdq" { target { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } } } */ +/* { dg-additional-options "-mpower8-vector" { target powerpc_p8vector_ok } } */ +/* { dg-additional-options "-march=z13 -mzarch" { target s390_vx } } */ + +void +foo (long long *p, long long *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = __builtin_popcountll (q[i]); +} + +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */ + +void +bar (long long *p, long long *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = __builtin_clzll (q[i]); +} + +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512cd } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr109011-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr109011-2.c new file mode 100644 index 0000000000..6d18eb28bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr109011-2.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/109011 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-unroll-loops --param=vect-epilogues-nomask=0 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mavx512cd -mbmi -mlzcnt -mno-avx512vpopcntdq" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } */ +/* { dg-additional-options "-mpower9-vector" { target powerpc_p9vector_ok } } */ +/* { dg-additional-options "-march=z13 -mzarch" { target s390_vx } } */ + +void +foo (int *p, int *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = __builtin_ctz (q[i]); +} + +void +bar (int *p, int *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = q[i] ? __builtin_ctz (q[i]) : __SIZEOF_INT__ * __CHAR_BIT__; +} + +void +baz (int *p, int *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = __builtin_ffs (q[i]); +} + +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 3 "optimized" { target powerpc_p9vector_ok } } } */ +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 2 "optimized" { target s390_vx } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target s390_vx } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr109011-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr109011-3.c new file mode 100644 index 0000000000..0c6c826179 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr109011-3.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/109011 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-unroll-loops --param=vect-epilogues-nomask=0 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mno-avx512cd -mbmi -mlzcnt -mavx512vpopcntdq" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } */ +/* { dg-additional-options "-mpower8-vector -mno-power9-vector" { target powerpc_p8vector_ok } } */ + +void +foo (int *p, int *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = __builtin_ctz (q[i]); +} + +void +bar (int *p, int *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = q[i] ? __builtin_ctz (q[i]) : __SIZEOF_INT__ * __CHAR_BIT__; +} + +void +baz (int *p, int *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = __builtin_ffs (q[i]); +} + +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target powerpc_p8vector_ok } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr109011-4.c b/SingleSource/Regression/C/gcc-dg/vect/pr109011-4.c new file mode 100644 index 0000000000..7bb337794b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr109011-4.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/109011 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-unroll-loops --param=vect-epilogues-nomask=0 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mavx512cd -mbmi -mlzcnt -mno-avx512vpopcntdq" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } */ +/* { dg-additional-options "-mpower9-vector" { target powerpc_p9vector_ok } } */ +/* { dg-additional-options "-march=z13 -mzarch" { target s390_vx } } */ + +void +foo (long long *p, long long *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = 2 * q[i] + __builtin_ctzll (q[i]); +} + +void +bar (long long *p, long long *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = q[i] ? __builtin_ctzll (q[i]) : __SIZEOF_LONG_LONG__ * __CHAR_BIT__; +} + +void +baz (long long *p, long long *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = __builtin_ffsll (q[i]); +} + +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 3 "optimized" { target powerpc_p9vector_ok } } } */ +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 2 "optimized" { target s390_vx } } } */ +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target s390_vx } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr109011-5.c b/SingleSource/Regression/C/gcc-dg/vect/pr109011-5.c new file mode 100644 index 0000000000..61fac0bb54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr109011-5.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/109011 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-unroll-loops --param=vect-epilogues-nomask=0 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mno-avx512cd -mbmi -mlzcnt -mavx512vpopcntdq" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } */ +/* { dg-additional-options "-mpower8-vector -mno-power9-vector" { target powerpc_p8vector_ok } } */ + +void +foo (long long *p, long long *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = 2 * q[i] + __builtin_ctzll (q[i]); +} + +void +bar (long long *p, long long *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = q[i] ? __builtin_ctzll (q[i]) : __SIZEOF_LONG_LONG__ * __CHAR_BIT__; +} + +void +baz (long long *p, long long *q) +{ +#pragma omp simd + for (int i = 0; i < 2048; ++i) + p[i] = __builtin_ffsll (q[i]); +} + +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */ +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target powerpc_p8vector_ok } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr109025.c b/SingleSource/Regression/C/gcc-dg/vect/pr109025.c new file mode 100644 index 0000000000..13fb0ce4ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr109025.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +int func_4(int t, int b) +{ + for (int tt1 = 0; tt1 < 128 ; tt1 ++) + { + for (int tt = 0; tt < 128; tt ++) + if (b) + t |= 3; + t |= 3; + } + return t; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr109473.c b/SingleSource/Regression/C/gcc-dg/vect/pr109473.c new file mode 100644 index 0000000000..9dee5515dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr109473.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O" } */ + +struct spa_buffer { + __UINT32_TYPE__ *metas; +}; +void do_port_use_buffers(struct spa_buffer **buffers, void *endptr, void *mem) +{ + for (int i = 0; i < 128; i++) + { + for (int j = 0; j < 128; j++) + endptr = (void *)((__UINTPTR_TYPE__)endptr + buffers[i]->metas[j]); + if (endptr > mem) + return; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr109502.c b/SingleSource/Regression/C/gcc-dg/vect/pr109502.c new file mode 100644 index 0000000000..fb67d909bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr109502.c @@ -0,0 +1,20 @@ +/* { dg-additional-options "-O" } */ + +unsigned g; + +unsigned +foo (void) +{ + unsigned a = !g; + a += !(a % 6); + return a; +} + +int +main () +{ + unsigned x = foo (); + if (x != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr110142.c b/SingleSource/Regression/C/gcc-dg/vect/pr110142.c new file mode 100644 index 0000000000..a88dbe400f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr110142.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +void test(short *x, unsigned short *y, int n) +{ + for (int i = 0; i < n; i++) + x[i] = (y[i] - x[i]) >> 1; +} + +/* { dg-final { scan-tree-dump-not "widen_minus" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr110381.c b/SingleSource/Regression/C/gcc-dg/vect/pr110381.c new file mode 100644 index 0000000000..278f4426c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr110381.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_float_strict } */ + +#include "tree-vect.h" + +struct FOO { + double a; + double b; + double c; +}; + +double __attribute__((noipa)) +sum_8_foos(const struct FOO* foos) +{ + double sum = 0; + + for (int i = 0; i < 8; ++i) + { + struct FOO foo = foos[i]; + + /* Need to use an in-order reduction here, preserving + the load permutation. */ + sum += foo.a; + sum += foo.c; + sum += foo.b; + } + + return sum; +} + +int main() +{ + struct FOO foos[8]; + + check_vect (); + + __builtin_memset (foos, 0, sizeof (foos)); + foos[0].a = __DBL_MAX__; + foos[0].b = 5; + foos[0].c = -__DBL_MAX__; + + if (sum_8_foos (foos) != 5) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr110838.c b/SingleSource/Regression/C/gcc-dg/vect/pr110838.c new file mode 100644 index 0000000000..00ad6ffbd2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr110838.c @@ -0,0 +1,29 @@ +#include "tree-vect.h" + +short a[32], b[32]; + +void __attribute__((noipa)) foo () +{ + for (int i = 0; i < 32; ++i) + a[i] = b[i] >> 16; +} + +void __attribute__((noipa)) bar (int n) +{ + int np = n & 31; + for (int i = 0; i < 32; ++i) + a[i] = b[i] >> np; +} + +int main () +{ + check_vect (); + b[0] = -8; + foo (); + if (a[0] != -1) + abort (); + bar (16); + if (a[0] != -1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr111754.c b/SingleSource/Regression/C/gcc-dg/vect/pr111754.c new file mode 100644 index 0000000000..014472f147 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr111754.c @@ -0,0 +1,14 @@ +/* PR middle-end/111754 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -fdump-tree-forwprop1 -Wno-psabi" } */ + +typedef float __attribute__((__vector_size__ (16))) F; + +F foo (F a, F b) +{ + F v = (F) { 9 }; + return __builtin_shufflevector (v, v, 1, 0, 1, 2); +} + +/* { dg-final { scan-tree-dump-not "VEC_PERM_EXPR" "forwprop1" } } */ +/* { dg-final { scan-tree-dump "(return| =) \{ 0.0, 9.0e\\+0, 0.0, 0.0 \}" "forwprop1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr111764.c b/SingleSource/Regression/C/gcc-dg/vect/pr111764.c new file mode 100644 index 0000000000..f4e110f3bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr111764.c @@ -0,0 +1,16 @@ +#include "tree-vect.h" + +short b = 2; + +int main() +{ + check_vect (); + + for (int a = 1; a <= 9; a++) + b = b * b; + if (b != 0) + __builtin_abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr111846.c b/SingleSource/Regression/C/gcc-dg/vect/pr111846.c new file mode 100644 index 0000000000..d283882f26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr111846.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -ffast-math" } */ +/* { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } } */ + +extern __attribute__((__simd__)) float powf(float, float); +float gv[0][10]; +float eq_set_bands_real_adj[0]; +void eq_set_bands_real() { + for (int c = 0; c < 10; c++) + for (int i = 0; i < 10; i++) + gv[c][i] = powf(0, eq_set_bands_real_adj[i]) - 1; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr111860-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr111860-2.c new file mode 100644 index 0000000000..07f64ffb53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr111860-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-sink -ftree-vectorize" } */ +int buffer_ctrl_ctx_0, buffer_ctrl_p1, buffer_ctrl_cmd; + +int +buffer_ctrl (long ret, int i) +{ + switch (buffer_ctrl_cmd) + { + case 1: + buffer_ctrl_ctx_0 = 0; + for (; i; i++) + if (buffer_ctrl_p1) + ret++; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr111860-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr111860-3.c new file mode 100644 index 0000000000..07f64ffb53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr111860-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-sink -ftree-vectorize" } */ +int buffer_ctrl_ctx_0, buffer_ctrl_p1, buffer_ctrl_cmd; + +int +buffer_ctrl (long ret, int i) +{ + switch (buffer_ctrl_cmd) + { + case 1: + buffer_ctrl_ctx_0 = 0; + for (; i; i++) + if (buffer_ctrl_p1) + ret++; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr111860.c b/SingleSource/Regression/C/gcc-dg/vect/pr111860.c new file mode 100644 index 0000000000..36f0774601 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr111860.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +int optimize_path_n, optimize_path_d; +int *optimize_path_d_0; +extern void path_threeOpt( long); +void optimize_path() { + int i; + long length; + i = 0; + for (; i <= optimize_path_n; i++) + optimize_path_d = 0; + i = 0; + for (; i < optimize_path_n; i++) + length += optimize_path_d_0[i]; + path_threeOpt(length); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr111882.c b/SingleSource/Regression/C/gcc-dg/vect/pr111882.c new file mode 100644 index 0000000000..024ad57b69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr111882.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options { -fdump-tree-ifcvt-all } } */ + +static void __attribute__((noipa)) f(int n) { + int i, j; + struct S { char d[n]; int a; int b : 17; int c : 12; }; + struct S A[100][1111]; + for (i = 0; i < 100; i++) { + asm volatile("" : : "g"(&A[0][0]) : "memory"); + for (j = 0; j < 1111; j++) A[i][j].b = 2; + } +} +void g(void) { f(1); } + +/* { dg-final { scan-tree-dump-not "Bitfield OK to lower" "ifcvt" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr111915.c b/SingleSource/Regression/C/gcc-dg/vect/pr111915.c new file mode 100644 index 0000000000..8614bac519 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr111915.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-vrp -fno-tree-dominator-opts -fno-tree-ccp" } */ + +void +foo (int * __restrict a, int * __restrict b, int * __restrict w) +{ + for (int i = 0; i < 16; ++i) + { + *a += w[2*i+0]; + *b += w[2*i&1]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr112818.c b/SingleSource/Regression/C/gcc-dg/vect/pr112818.c new file mode 100644 index 0000000000..61a30a576b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr112818.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +extern char tag_data[]; +struct pppoe_tag { + unsigned short tag_type; + unsigned short tag_len; +}; + +char code; +int *add_tag_pack; +void *add_tag_data; +short e; +long c, d; + +static int add_tag(int type, int len) { + short a, b; + struct pppoe_tag *tag = (struct pppoe_tag *)add_tag_pack; + if (e + len || len < 0) + return 1; + b = __builtin_bswap16(type); + tag->tag_type = b; + a = __builtin_bswap16(len); + tag->tag_len = a; + if (add_tag_data) + __builtin___memcpy_chk(tag_data, add_tag_data, len, c); + return 0; +} +void pppoe_serv_read() { + switch (code) + case 9: { + add_tag(2, d); + add_tag(0, 2); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr113002.c b/SingleSource/Regression/C/gcc-dg/vect/pr113002.c new file mode 100644 index 0000000000..186710f64b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr113002.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-finline-stringops -Os" } */ + +typedef __int128 v64u128 __attribute__((vector_size(64))); +int c; +v64u128 u; +void foo() { + if (c) + u = (v64u128){0}; + else + u = (v64u128){1}; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr16105.c b/SingleSource/Regression/C/gcc-dg/vect/pr16105.c new file mode 100644 index 0000000000..3302835cbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr16105.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +#define VECTOR_SIZE 512 + +extern void check(const float * __restrict__ v); + +void square(const float * __restrict__ a, + float * __restrict__ out) +{ + unsigned int i; + for (i = 0; i < VECTOR_SIZE; i++) { + float ai = a[i]; + float a2 = ai * ai; + out[i] = a2; + } + check(out); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr18308.c b/SingleSource/Regression/C/gcc-dg/vect/pr18308.c new file mode 100644 index 0000000000..797ab99c8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr18308.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O -funroll-loops" } */ +void foo(); + +void bar(int j) +{ + int i, k=0; + for (i = 0; i < 2; ++i) + if (j) k = 2; + + if (k) foo(); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr18400.c b/SingleSource/Regression/C/gcc-dg/vect/pr18400.c new file mode 100644 index 0000000000..dd96d87be9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr18400.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int b[N] = {0,3,6,9,12,15,18,21}; +int a[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + a[i] = b[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != b[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr18425.c b/SingleSource/Regression/C/gcc-dg/vect/pr18425.c new file mode 100644 index 0000000000..2fa1b79943 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr18425.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* ??? Using "long" isn't quite right; we're testing vectors of pointers here. + But since no extant target supports sizeof(long) != sizeof(void*)... */ +/* { dg-require-effective-target vect_long } */ + +char ** _M_allocate(); +void +_M_fill_insert(unsigned int __n) +{ + char **__new_start = _M_allocate(); + char *__tmp = 0; + for (; __n > 0; --__n, ++__new_start) + *__new_start = __tmp; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr18536.c b/SingleSource/Regression/C/gcc-dg/vect/pr18536.c new file mode 100644 index 0000000000..33ee3a5ddc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr18536.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int main1 (short a, short *b) +{ + while (++a < 4) *b++ = 2; + + return 0; +} + +int main (void) +{ + int i = 0; + short x[N]; + + check_vect (); + + main1 (0, x); + + /* check results: */ +#pragma GCC novector + while (++i < 4) + { + if (x[i-1] != 2) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr20122.c b/SingleSource/Regression/C/gcc-dg/vect/pr20122.c new file mode 100644 index 0000000000..3a0387e772 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr20122.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +short Kernshort[24] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +static void VecBug(short Kernel[8][24]) __attribute__((noinline)); +static void VecBug2(short Kernel[8][24]) __attribute__((noinline)); + +/* Kernel may alias Kernshort - a global array. + Use versioning for aliasing. */ +static void VecBug(short Kernel[8][24]) +{ + int k,i; + for (k = 0; k<8; k++) + for (i = 0; i<24; i++) + Kernshort[i] = Kernel[k][i]; +} + +/* Vectorizable: Kernshort2 is local. */ +static void VecBug2(short Kernel[8][24]) +{ + int k,i; + short Kernshort2[24] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + for (k = 0; k<8; k++) + for (i = 0; i<24; i++) + Kernshort2[i] = Kernel[k][i]; + + for (k = 0; k<8; k++) +#pragma GCC novector + for (i = 0; i<24; i++) + if (Kernshort2[i] != Kernel[k][i]) + abort (); +} + +int main (int argc, char **argv) +{ + check_vect (); + + short Kernel[8][24]; + int k,i; + + for (k = 0; k<8; k++) + for (i = 0; i<24; i++) + { + Kernel[k][i] = 0; + /* Don't get into the game of versioning vs. peeling. */ + __asm__ volatile ("" : : : "memory"); + } + + VecBug(Kernel); + VecBug2(Kernel); + + return 0; +} + +/* The loops in VecBug and VecBug2 require versioning for alignment. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr21591.c b/SingleSource/Regression/C/gcc-dg/vect/pr21591.c new file mode 100644 index 0000000000..d7bbc57e47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr21591.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +struct a +{ + int length; + int a1[256]; +}; + +struct a *malloc1(__SIZE_TYPE__) __attribute__((malloc)); +void free(void*); + +struct a *p, *q, *r; + +void f(void) +{ + struct a *a = malloc1(sizeof(struct a)); + struct a *b = malloc1(sizeof(struct a)); + struct a *c = malloc1(sizeof(struct a)); + int i; + + for (i = 0; i < 256; i++) + { + b->a1[i] = i; + c->a1[i] = i; + } + for (i = 0; i < 256; i++) + { + a->a1[i] = b->a1[i] + c->a1[i]; + } + p = a; + q = b; + r = c; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr21969.c b/SingleSource/Regression/C/gcc-dg/vect/pr21969.c new file mode 100644 index 0000000000..388fc3129d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr21969.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +typedef float vsf __attribute__((vector_size(2048))); diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr22480.c b/SingleSource/Regression/C/gcc-dg/vect/pr22480.c new file mode 100644 index 0000000000..5a2ab7cb2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr22480.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_shift } */ + +void +test_1 (void) +{ + static unsigned int bm[16]; + int j; + for (j = 0; j < 16; j++) + bm[j] <<= 8; +} + +void +test_2 (int a) +{ + static unsigned int bm[16]; + int j; + for (j = 0; j < 16; j++) + bm[j] <<= a; +} + +void +test_3 (void) +{ + static unsigned bm[16]; + int am[16]; + int j; + for (j = 0; j < 16;j++) + bm[j] <<= am[j]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr22506.c b/SingleSource/Regression/C/gcc-dg/vect/pr22506.c new file mode 100644 index 0000000000..672ff90f3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr22506.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +float x[3]; + +void foo() +{ + int i; + + for (i=0; i<3; ++i) x[i]=0; + for (i=0; i<2; ++i) ; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr23816-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr23816-1.c new file mode 100644 index 0000000000..216c4eb7a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr23816-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ + +void +foo (float a[32], float b[2][32]) +{ + int i; + for (i = 0; i < 32; i++) + a[i] = (b[0][i] > b[1][i]) ? b[0][i] : b[1][i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr23816-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr23816-2.c new file mode 100644 index 0000000000..620f284174 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr23816-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ + +void +foo (double a[32], double b[2][32]) +{ + int i; + for (i = 0; i < 32; i++) + a[i] = (b[0][i] > b[1][i]) ? b[0][i] : b[1][i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr23831.c b/SingleSource/Regression/C/gcc-dg/vect/pr23831.c new file mode 100644 index 0000000000..a0320d7aef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr23831.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void foo (void) +{ + static unsigned int bm[16]; + int j; + for (j = 0; j < 16; j++) + bm[j] = bm[j] * 8; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr24049.c b/SingleSource/Regression/C/gcc-dg/vect/pr24049.c new file mode 100644 index 0000000000..9f822fb80e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr24049.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O1 --param ggc-min-heapsize=0 --param ggc-min-expand=0" } */ + +void unscrunch (unsigned char *, int *); + +int DES_CBCUpdate(unsigned char * output, int len) +{ + int work[2]; + unsigned int i; + for(i = 0;i < len/8;i++) + unscrunch (&output[8*i], work); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr24059.c b/SingleSource/Regression/C/gcc-dg/vect/pr24059.c new file mode 100644 index 0000000000..8a46b4a9af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr24059.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ + +struct pred_data +{ + unsigned char codes[((int) 100)]; +}; + +void compute_predicate_codes (char *codes, struct pred_data *p) +{ + int i; + for (i = 0; i < ((int) 100); i++) + codes[i] = p->codes[i] ? 2 : 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr24300.c b/SingleSource/Regression/C/gcc-dg/vect/pr24300.c new file mode 100644 index 0000000000..115800c5dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr24300.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ + +static int *** foo (int); + +void +bar () +{ + int ***p = foo (2); +} + +extern int *nd; +extern int ***tc; +extern int *ap; +extern int *as; +extern float ss; + +static int *** +foo (int Fc) +{ + int i, j, s, p, n, t; + + n = 0; + for (s = 0; s < 4; s++) + n += nd[s]; + + for (i = 0; i < n; i++) + { + p = ap[i]; + s = as[i]; + for (j = 0; j < Fc; j++) + tc[p][s][j] = i * ss + j; + } + + return (tc); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr25371.c b/SingleSource/Regression/C/gcc-dg/vect/pr25371.c new file mode 100644 index 0000000000..65a11593d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr25371.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +void slow_close(int n) +{ + int i; + double *mm; + + for (i=0;i<2*n;i++) + for (i=0;i<2*n;i++) + *(mm+i*2*n+i) = 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr25413.c b/SingleSource/Regression/C/gcc-dg/vect/pr25413.c new file mode 100644 index 0000000000..266ef3109f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr25413.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_double } */ + +#include +#include "tree-vect.h" + +#define N 8 + +struct +{ + char c; + double d[N]; +} a; + +__attribute__ ((noinline)) +int main1() +{ + int i; + for ( i=0; in = n; + m->ref = 1; + m->state = OCT_EMPTY; + m->closed = (oct_t*)((void *)0); + m->c = (num_t*)((void *)0); + /*octfapg_timing_exit("oct_empty",3);*/ + return m; +} + +oct_t* +octfapg_alloc (const var_t n) +{ + size_t nn = (2*(size_t)(n)*((size_t)(n)+1)); + oct_t* m; + m = octfapg_empty(n); + m->c = ((num_t*) octfapg_mm_malloc (sizeof(num_t)*(nn))); + ; + m->state = OCT_NORMAL; + m->closed = (oct_t*)((void *)0); + return m; +} + +oct_t* +octfapg_universe (const var_t n) +{ + oct_t* m; + size_t i, nn = (2*(size_t)(n)*((size_t)(n)+1)); + m = octfapg_alloc(n); + for (i=0;ic+i) = num__infty; + for (i=0;i<2*n;i++) *(m->c+((size_t)(i)+(((size_t)(i)+1)*((size_t)(i)+1))/2)) = (num_t)(0); + m->state = OCT_CLOSED; + return m; +} + +int main (void) +{ + int i; + check_vect (); + + oct_t *p = octfapg_universe(10); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vector alignment may not be reachable" 1 "vect" { target { ! vector_alignment_reachable } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { ! vector_alignment_reachable } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr26359.c b/SingleSource/Regression/C/gcc-dg/vect/pr26359.c new file mode 100644 index 0000000000..5b445a9bda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr26359.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-dce6-details" } */ + +int a[256], b[256], c[256]; + +void +foo () { + int i; + + for (i=0; i<256; i++){ + a[i] = b[i] + c[i]; + } +} + +/* { dg-final { scan-tree-dump-times "Deleting : vect_" 0 "dce6" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr27151.c b/SingleSource/Regression/C/gcc-dg/vect/pr27151.c new file mode 100644 index 0000000000..23fce79e92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr27151.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +/* We were creating a float vector for the vis_type == 1 + test, which we ICEd on. Now we simply punt here. */ + +float vs_data[75]; +void vis_clear_data () +{ + int vis_type, i; + for (i = 0; i < 75; i++) + { + vs_data[i] = (vis_type == 1); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr28952.c b/SingleSource/Regression/C/gcc-dg/vect/pr28952.c new file mode 100644 index 0000000000..1f424b93e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr28952.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +/* We were ICE because we wanted to check the type of the + elements of a conditional before we knew it was a conditional. */ + +struct player_spaceship +{ + _Bool structure[32]; +}; +struct player +{ + struct player_spaceship spaceship; +}; +struct packet_spaceship_info +{ + char structure[32 + 1]; +}; +void lsend_packet_spaceship_info (struct packet_spaceship_info *); +void +send_spaceship_info (void) +{ + int j; + struct player *pplayer; + struct packet_spaceship_info info; + struct player_spaceship *ship = &pplayer->spaceship; + for (j = 0; j < 32; j++) + { + info.structure[j] = ship->structure[j] ? '1' : '0'; + } + lsend_packet_spaceship_info (&info); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr30771.c b/SingleSource/Regression/C/gcc-dg/vect/pr30771.c new file mode 100644 index 0000000000..291df2371c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr30771.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int a[128]; + +int +main() +{ + short i; + + for (i=0; i<64; i++){ + a[i] = (int)i; + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr30784.c b/SingleSource/Regression/C/gcc-dg/vect/pr30784.c new file mode 100644 index 0000000000..ad1fa05d8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr30784.c @@ -0,0 +1,30 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +long stack_vars_sorted[32]; + +int +main1 (long n) +{ + long si; + + for (si = 0; si < n; ++si) + stack_vars_sorted[si] = si; +} + +int main () +{ + long si; + + check_vect (); + main1 (32); + +#pragma GCC novector + for (si = 0; si < 32; ++si) + if (stack_vars_sorted[si] != si) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr30795.c b/SingleSource/Regression/C/gcc-dg/vect/pr30795.c new file mode 100644 index 0000000000..e5c3951a2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr30795.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +char bigDone[260]; +int runningOrder[260]; + +int +main() +{ + int i; + for (i = 0; i <= 255; i++) { + bigDone [i] = ((char)0); + runningOrder[i] = i; + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr30843.c b/SingleSource/Regression/C/gcc-dg/vect/pr30843.c new file mode 100644 index 0000000000..8acbffd3d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr30843.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_long } */ + +#include +#include "tree-vect.h" + +#define N 16 + +void dacP98FillRGBMap (unsigned char *pBuffer) +{ + unsigned long dw, dw1; + unsigned long *pdw = (unsigned long *)(pBuffer); + + for( dw = 256, dw1 = 0; dw; dw--, dw1 += 0x01010101) + { + *pdw++ = dw1; + *pdw++ = dw1; + *pdw++ = dw1; + *pdw++ = dw1; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_interleave || vect_strided4 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr30858.c b/SingleSource/Regression/C/gcc-dg/vect/pr30858.c new file mode 100644 index 0000000000..cc92318d7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr30858.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int +foo (int ko) +{ + int j,i = 0; + for (j = 0; j < ko; j++) + i += (i > 10) ? -5 : 7; + return i; +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump "Unknown def-use cycle pattern." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr31041.c b/SingleSource/Regression/C/gcc-dg/vect/pr31041.c new file mode 100644 index 0000000000..6362d84a25 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr31041.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +struct UNewTrie +{ + int index[(0x110000 >> 1)]; +}; +typedef struct UNewTrie UNewTrie; +void +utrie_open_3_4 () +{ + UNewTrie *trie; + int i, j; + { + i = 0; + do + { + trie->index[i++] = j; + j += 1; + } + while (i < 5); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr31343.c b/SingleSource/Regression/C/gcc-dg/vect/pr31343.c new file mode 100644 index 0000000000..e72daf0e5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr31343.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +#define N 16 + +struct +{ + unsigned int x; + unsigned int y; +} pS [100]; + +void +main1 () +{ + int i, j; + unsigned int ub[N] = + { 1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45 }; + unsigned int uc[N] = + { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + unsigned int udiffx, udiffy; + + for (i = 0; i < N; i++) + { + pS[i].x = 0; + pS[i].y = 0; + for (j = 0; j < N; j++) + { + udiffx = (ub[j] - uc[j]); + udiffy = (ub[j] - uc[j]); + pS[i].x = udiffx; + pS[i].y = udiffy; + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr31699.c b/SingleSource/Regression/C/gcc-dg/vect/pr31699.c new file mode 100644 index 0000000000..b0b9971fcf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr31699.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include +#include "tree-vect.h" + +float x[256]; + +__attribute__ ((noinline)) +float *foo(void) +{ + float *z = malloc (sizeof(float) * 256); + + int i; + for (i=0; i<256; ++i) + z[i] = x[i] + 1.0f; + + return z; +} + + +int main() +{ + int i; + + check_vect (); + + for (i = 0; i < 256; i++) + x[i] = (float) i; + + foo(); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_intfloat_cvt } } } */ +/* { dg-final { scan-tree-dump-times "vector alignment may not be reachable" 1 "vect" { target { ! vector_alignment_reachable } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { ! vector_alignment_reachable } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr32216.c b/SingleSource/Regression/C/gcc-dg/vect/pr32216.c new file mode 100644 index 0000000000..d448fe78ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr32216.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_floatint_cvt } */ + +unsigned int wlookup2[203]; + +void +SetSoundVariables (int x) +{ + for (x = 1; x < 32; x++) + { + wlookup2[x] = (double) 16 / x; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr32224.c b/SingleSource/Regression/C/gcc-dg/vect/pr32224.c new file mode 100644 index 0000000000..2ef90b903b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr32224.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +typedef unsigned long int *mp_ptr; +typedef const unsigned long int *mp_srcptr; +void +gmpz_export (void *data) +{ + mp_srcptr zp; + int count, i; + mp_ptr __dst = ((mp_ptr) data); + mp_srcptr __src = (zp); + + for (i = 0; i < count; i++) + { + __asm__ ("checkme": "=r" (*__dst):"0" (*(__src))); + __src++; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr32230.c b/SingleSource/Regression/C/gcc-dg/vect/pr32230.c new file mode 100644 index 0000000000..7df47e4dc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr32230.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +typedef struct filter_buffer filter_buffer_t; +struct filter_buffer +{ + char buf[1]; +}; +typedef struct sbuf_header sbuf_header_t; +struct sbuf_header +{ + char buf[1]; +} +const_f (filter_buffer_t *buf) +{ + float val; + int i; + + for (i = 0; i < 10; i++) + ((float*) (&((sbuf_header_t *) (__PTRDIFF_TYPE__)((buf) == (filter_buffer_t *)&(buf)->buf[0]))->buf[0]))[i] = val; +} + + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr32366.c b/SingleSource/Regression/C/gcc-dg/vect/pr32366.c new file mode 100644 index 0000000000..cc1cd72f13 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr32366.c @@ -0,0 +1,14 @@ +/* Testcase by Martin Michlmayr */ + +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +void +stream_test (void) +{ + static float input[20]; + int k; + for (k = 0; k < 20; k++) + input[k] = k * 1.0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr32421.c b/SingleSource/Regression/C/gcc-dg/vect/pr32421.c new file mode 100644 index 0000000000..f88ce373d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr32421.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + + +int f(int **__restrict a, int ** __restrict b) +{ + int i; + for(i= 0;i<32;i++) + a[i] = b[i] + 1; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr32824.c b/SingleSource/Regression/C/gcc-dg/vect/pr32824.c new file mode 100644 index 0000000000..c3b8b3721b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr32824.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int a[16*100]; +int e; +void foo(void) +{ + int i; + for(i = 0;i<16*100;i++) + e += a[i]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33369.c b/SingleSource/Regression/C/gcc-dg/vect/pr33369.c new file mode 100644 index 0000000000..8838db8376 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33369.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +typedef struct tagPOINT +{ + int x; + int y; +} POINT; + +void +f (POINT * ptBuf) +{ + int i; + for (i = 0; i < 4; i++) + { + ptBuf[i].x = ((ptBuf[i].x) << 4); + ptBuf[i].y = ((ptBuf[i].y) << 4); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33373.c b/SingleSource/Regression/C/gcc-dg/vect/pr33373.c new file mode 100644 index 0000000000..1a10e457c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33373.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-shift-overflow" } */ +void DOSMEM_FillIsrTable(int*isr) { + int i; + + for (i=0; i<256; i++) + isr[i]=(((short)((i*4) & 0xFFFF)) | (0xf000 & 0xFFFF) << 16); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33373b.c b/SingleSource/Regression/C/gcc-dg/vect/pr33373b.c new file mode 100644 index 0000000000..fc5e6eb249 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33373b.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +void f (unsigned int *d, unsigned int *s, int w) +{ + int i; + for (i = 0; i < w; ++i) + d [i] = s [i] * (unsigned short) (~d [i] >> 24); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33597.c b/SingleSource/Regression/C/gcc-dg/vect/pr33597.c new file mode 100644 index 0000000000..0befb49d00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33597.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; + +void +rgb15to24_C (const uint8_t * src, uint8_t * dst, long src_size) +{ + const uint16_t *end; + const uint16_t *s = (uint16_t *)src; + uint8_t *d = (uint8_t *)dst; + + end = s + src_size/2; + while (s < end) + { + uint16_t bgr = *s++; + + *d++ = (bgr&0x1F)<<3; + *d++ = (bgr&0x3E0)>>2; + *d++ = (bgr&0x7C00)>>7; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33707.c b/SingleSource/Regression/C/gcc-dg/vect/pr33707.c new file mode 100644 index 0000000000..b55314264f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33707.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int +foo (char *a, unsigned n) +{ + int i; + a[0] = 0; + for (i = 16; i < n; i++) + a[i] = a[i-16]; +} +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33804.c b/SingleSource/Regression/C/gcc-dg/vect/pr33804.c new file mode 100644 index 0000000000..0db13674b4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33804.c @@ -0,0 +1,17 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void f(unsigned char *s, unsigned char *d, int n) { + int i; + for (i = 0; i < n; i += 4) { + d[i + 0] += s[i + 0]; + d[i + 1] += s[i + 1]; + d[i + 2] += s[i + 2]; + d[i + 3] += s[i + 3]; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33833.c b/SingleSource/Regression/C/gcc-dg/vect/pr33833.c new file mode 100644 index 0000000000..de31dc089f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33833.c @@ -0,0 +1,34 @@ +/* Testcase by Martin Michlmayr */ +/* { dg-do compile } */ + +#define signed +typedef unsigned __PTRDIFF_TYPE__ uintptr_t; +#undef signed + +struct list_head +{ + struct list_head *prev; +}; +struct prio_array +{ + struct list_head queue[100]; +}; +struct rq +{ + struct prio_array *active, arrays[2]; +} per_cpu__runqueues; + +void sched_init (uintptr_t __ptr) +{ + int j, k; + struct prio_array *array; + struct rq *rq; + rq = (&(*( { (typeof (&per_cpu__runqueues)) (__ptr); } ))); + for (j = 0; j < 2; j++) + { + array = rq->arrays + j; + for (k = 0; k < 100; k++) + (array->queue + k)->prev = array->queue; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33846.c b/SingleSource/Regression/C/gcc-dg/vect/pr33846.c new file mode 100644 index 0000000000..8f8e7e76e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33846.c @@ -0,0 +1,23 @@ +/* Testcase by Martin Michlmayr */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_shift } */ + +int clamp_val (int i) +{ + return ~i >> 31; +} + +typedef __PTRDIFF_TYPE__ intptr_t; + +void _mix_some_samples (intptr_t buf, int *mix_buffer, int mix_size) +{ + int i; + signed int *p = mix_buffer; + for (i = mix_size ; i > 0; i--) + { + *((short *) buf) = clamp_val ((*p) + 0x800000); + buf += 2; + p++; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33866.c b/SingleSource/Regression/C/gcc-dg/vect/pr33866.c new file mode 100644 index 0000000000..737b2e8db2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33866.c @@ -0,0 +1,31 @@ +/* Testcase by Martin Michlmayr */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_long } */ + +typedef struct +{ + long *coords; +} +fill_iter_info; + +extern int H5Diterate (fill_iter_info *); + +void test_select_fill_hyper_simple (long *offset) +{ + long start[2]; + int num_points; + long points[16][2]; + fill_iter_info iter_info; + int i, j; + iter_info.coords = (long *) points; + for (j = i = 0, num_points = 0; j < (int) start[1]; j++, num_points++) + { + points[num_points][0] = i + start[0]; + points[num_points][1] = j + start[1]; + } + H5Diterate (&iter_info); +} + +/* Needs interleaving support. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_interleave || vect_strided2 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr33953.c b/SingleSource/Regression/C/gcc-dg/vect/pr33953.c new file mode 100644 index 0000000000..d376cf904b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr33953.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +typedef unsigned int UINT32; + +void blockmove_NtoN_blend_noremap32 (const UINT32 *srcdata, int srcwidth, + int srcheight, int srcmodulo, + UINT32 *dstdata, int dstmodulo, + int srcshift) +{ + UINT32 *end; + + while (srcheight) + { + while (dstdata <= end - 8) + { + dstdata[0] |= srcdata[0] << srcshift; + dstdata[1] |= srcdata[1] << srcshift; + dstdata[2] |= srcdata[2] << srcshift; + dstdata[3] |= srcdata[3] << srcshift; + dstdata[4] |= srcdata[4] << srcshift; + dstdata[5] |= srcdata[5] << srcshift; + dstdata[6] |= srcdata[6] << srcshift; + dstdata[7] |= srcdata[7] << srcshift; + dstdata += 8; + srcdata += 8; + } + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! vect_multiple_sizes } xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { target vect_multiple_sizes xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr34005.c b/SingleSource/Regression/C/gcc-dg/vect/pr34005.c new file mode 100644 index 0000000000..4ee121e241 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr34005.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/34005 */ +/* { dg-do compile } */ + +/* Testcase by Martin Michlmayr */ + +void XdmcpUnwrap (unsigned char *output, int k) +{ + int i; + unsigned char blocks[2][8]; + k = (k == 0) ? 1 : 0; + + for (i = 0; i < 8; i++) + output[i] = blocks[k][i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr34195.c b/SingleSource/Regression/C/gcc-dg/vect/pr34195.c new file mode 100644 index 0000000000..e36950ba42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr34195.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +#define M 11 + +struct S +{ + float x; + float y; +} pS[100]; + +float a[1000]; +float b[1000]; + +void +foo (int n) +{ + int i, j; + + for (i = 0; i < n; i++) + { + pS[i].x = 0; + pS[i].y = 0; + + for (j = 0; j < M; j++) + { + pS[i].x += (a[i]+b[i]); + pS[i].y += (a[i]-b[i]); + } + } +} + +/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr34407.c b/SingleSource/Regression/C/gcc-dg/vect/pr34407.c new file mode 100644 index 0000000000..a9a39bc408 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr34407.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +extern int ReadBlobByte (void); + +void ReadRLEImage (unsigned char *p) +{ + unsigned char background_color[4] = { 0, 1, 2, 3 }; + long j; + + unsigned long number_planes = ReadBlobByte(); + + for (j = 0; j < (long) number_planes; j++) + *p++ = background_color[j]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr34591.c b/SingleSource/Regression/C/gcc-dg/vect/pr34591.c new file mode 100644 index 0000000000..88b6a64702 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr34591.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +int av_resample(int filter_length, short *src, short *filter) +{ + int i; + int val=0; + for(i=0; i + +struct mystr +{ + int f1; + int f2; +}; + +struct mystr a[16]; +struct mystr b[16]; +int res1, res2; + + +void +foo (void) +{ + int i; + int sum1 = 0; + int sum2 = 0; + + for (i = 0; i < 16; i++) + { + sum1 += a[i].f1 + b[i].f1; + sum2 += a[i].f2 + b[i].f2; + } + + res1 = sum1; + res2 = sum2; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_add } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail vect_no_int_add } } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr37385.c b/SingleSource/Regression/C/gcc-dg/vect/pr37385.c new file mode 100644 index 0000000000..1d17208941 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr37385.c @@ -0,0 +1,19 @@ +/* Testcase by Martin Michlmayr */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +typedef int int_t; +typedef void (*fun_t) (int); +fun_t fun_tab[400] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +void foo (int_t a); + +void +bar () +{ + int i; + + for (i = 0; i < 400; i++) + fun_tab[i] = foo; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr37474.c b/SingleSource/Regression/C/gcc-dg/vect/pr37474.c new file mode 100644 index 0000000000..f23522f6a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr37474.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#include + +#define M00 100 +#define M10 216 +#define M01 1322 +#define M11 13 +#define M02 74 +#define M12 191 + +#define N 16 + +void foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput) +{ + unsigned int i, a, b, c, d, e, f; + + for (i = 0; i < N / 3; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + d = *pInput++; + e = *pInput++; + f = *pInput++; + + a = a + d; + b = b + e; + c = c + f; + + *pOutput++ = M00 * a + M01 * b + M02 * c; + *pOutput++ = M10 * a + M11 * b + M12 * c; + } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr37482.c b/SingleSource/Regression/C/gcc-dg/vect/pr37482.c new file mode 100644 index 0000000000..e52266d8a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr37482.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void SexiALI_Convert(void *vdest, void *vsrc, unsigned int frames) +{ + unsigned int x; + short *src = vsrc; + unsigned char *dest = vdest; + for(x=0;x<256;x++) + { + int tmp; + tmp = *src; + src++; + tmp += *src; + src++; + *dest++ = tmp; + *dest++ = tmp; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr37539.c b/SingleSource/Regression/C/gcc-dg/vect/pr37539.c new file mode 100644 index 0000000000..c7934eb384 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr37539.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +__attribute__ ((noinline)) void +ayuv2yuyv_ref (int *d, int *src, int n) +{ + char *dest = (char *)d; + int i; + + for(i=0;i>16; + dest[i*4 + 1] = (src[i*2 + 1])>>8; + dest[i*4 + 2] = (src[i*2 + 0])>>16; + dest[i*4 + 3] = (src[i*2 + 0])>>0; + } + + /* Check results. */ +#pragma GCC novector + for(i=0;i>16 + || dest[i*4 + 1] != (src[i*2 + 1])>>8 + || dest[i*4 + 2] != (src[i*2 + 0])>>16 + || dest[i*4 + 3] != (src[i*2 + 0])>>0) + abort(); + } +} + +int main () +{ + int d[256], src[128], i; + + check_vect (); + + for (i = 0; i < 128; i++) + src[i] = i; + + ayuv2yuyv_ref(d, src, 128); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { vect_strided4 && vect_strided2 } } } } */ + + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr37730.c b/SingleSource/Regression/C/gcc-dg/vect/pr37730.c new file mode 100644 index 0000000000..feaae960e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr37730.c @@ -0,0 +1,17 @@ +/* PR middle-end/37730 */ +/* { dg-do compile } */ + +void sdp_seq_alloc (void *); + +void +add_opush (void) +{ + unsigned char formats[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xff }; + void *dtds[sizeof (formats)]; + unsigned int i; + unsigned char dtd = 0x08; + for (i = 0; i < sizeof (formats); i++) + dtds[i] = &dtd; + sdp_seq_alloc (dtds); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr38529.c b/SingleSource/Regression/C/gcc-dg/vect/pr38529.c new file mode 100644 index 0000000000..9b5919d670 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr38529.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +float a[4]; + +void foo() +{ + int i, j; + + for (i = 0; i < 4; ++i) + for (j = 0; j < 17; ++j) + a[i] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr39529.c b/SingleSource/Regression/C/gcc-dg/vect/pr39529.c new file mode 100644 index 0000000000..b40ab4669c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr39529.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +void +foo (void) +{ + char a[1024]; + char *p = &a[0]; + char *p2; + + p2 = p + 1024; + do + { + p += 2; + *(p-2) = 1; + *(p-1) = 1; + } while (p < p2); +} + + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr40074.c b/SingleSource/Regression/C/gcc-dg/vect/pr40074.c new file mode 100644 index 0000000000..b75061a811 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr40074.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +typedef struct { + int a; + int b; + int c; + int d; +} s; + + +s arr[N] = {{7,0,1,5}, {7,2,3,5}, {7,4,5,5}, {7,6,7,5}, {7,8,9,5}, {7,10,11,5}, {7,12,13,5}, {7,14,15,5}, {7,16,17,5}, {7,18,19,5}, {7,20,21,5}, {7,22,23,5}, {7,24,25,5}, {7,26,27,5}, {7,28,29,5}, {7,30,31,5}}; + +__attribute__ ((noinline)) int +main1 () +{ + s *p = arr, *q = arr + 1; + int res[N]; + int i; + + for (i = 0; i < N-1; i++) + { + res[i] = p->b + p->d + q->b; + p++; + q++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N-1; i++) + { + if (res[i] != arr[i].b + arr[i].d + arr[i+1].b) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + main1 (); + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr40238.c b/SingleSource/Regression/C/gcc-dg/vect/pr40238.c new file mode 100644 index 0000000000..c039067334 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr40238.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ + +extern int xdo_rb_ctr_row( int *pos_code); + +int xgp_ahd_interpolate (int tile) +{ + int p[4]; + + switch (tile) { + default: + case 0: + case 1: + p[0] = 0; p[1] = 1; p[2] = 2; p[3] = 3; + break; + case 2: + case 3: + p[0] = 1; p[1] = 0; p[2] = 3; p[3] = 2; + break; + case 4: + case 5: + p[0] = 3; p[1] = 2; p[2] = 1; p[3] = 0; + break; + case 6: + case 7: + p[0] = 2; p[1] = 3; p[2] = 0; p[3] = 1; + break; + } + + xdo_rb_ctr_row(p); + xdo_rb_ctr_row(p); + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr40254.c b/SingleSource/Regression/C/gcc-dg/vect/pr40254.c new file mode 100644 index 0000000000..04fc3eb9b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr40254.c @@ -0,0 +1,37 @@ +#include +#include "tree-vect.h" + +struct s +{ + int *x; + int x1; + int x2; + int x3; + int *y; +}; + +struct s arr[64] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo (int i, int *in_x, int *in_y) +{ + arr[i].x = in_x; + arr[i].y = in_y; +} + +int +main (void) +{ + int a, b; + + check_vect (); + + foo (5, &a, &b); + + if (arr[5].x != &a || arr[5].y != &b) + abort (); + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr40542.c b/SingleSource/Regression/C/gcc-dg/vect/pr40542.c new file mode 100644 index 0000000000..980919a360 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr40542.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +void +volarr_cpy(char *d, volatile char *s) +{ + int i; + + for (i = 0; i < 16; i++) + d[i] = s[i]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr41956.c b/SingleSource/Regression/C/gcc-dg/vect/pr41956.c new file mode 100644 index 0000000000..5f639a1391 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr41956.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void K (int *gpwgts, int *badminpwgt, int *badmaxpwgt) +{ + int i; + for (i = 0; i < 10; i += 2) { + badminpwgt[i] = badminpwgt[i+1] = gpwgts[i]+gpwgts[i]; + badmaxpwgt[i] = badmaxpwgt[i+1] = gpwgts[i]+gpwgts[i]; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr42193.c b/SingleSource/Regression/C/gcc-dg/vect/pr42193.c new file mode 100644 index 0000000000..e4b95f7b54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr42193.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_long } */ + +#include + +unsigned long in[6], out[6]; + +void foo () +{ + unsigned long a, b, c, d, e, f; + + a = in[0]; + b = in[1]; + c = in[2]; + d = in[3]; + e = in[4]; + f = in[5]; + + out[0] = 2 * a + 7 * b + 8 * c + 31 * d + 10 * e + 21 * f; + out[1] = 3 * a + 6 * b + 12 * c + 13 * d + 15 * e + 28 * f; + out[2] = 4 * a + 5 * b + 72 * c + 23 * d + 14 * e + 24 * f; + out[3] = 8 * a + 71 * b + 18 * c + 33 * d + 13 * e + 25 * f; + out[4] = 12 * a + 16 * b + 19 * c + 41 * d + 22 * e + 26 * f; + out[5] = 17 * a + 15 * b + 13 * c + 14 * d + 11 * e + 9 * f; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr42395.c b/SingleSource/Regression/C/gcc-dg/vect/pr42395.c new file mode 100644 index 0000000000..e724d6892c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr42395.c @@ -0,0 +1,10 @@ +/* PR debug/42395 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -g" } */ + +void foo(int j, int *A) +{ + int i; + for (i = 0; i < j; i ++) A[i] = i; + for (; i < 4096; i ++) A[i] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr42604.c b/SingleSource/Regression/C/gcc-dg/vect/pr42604.c new file mode 100644 index 0000000000..d19c646282 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr42604.c @@ -0,0 +1,34 @@ +/* PR debug/42604 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -g -ffast-math" } */ + +unsigned *d; +unsigned short e; +int f; +float h[3][4]; + +void +test (unsigned short *b) +{ + int a, c, i; + float g[3]; + unsigned j[32] = { 10, 0x63707274 }; + for (i = 0; i < (int) j[0]; i++) + { + j[i * 3 + 2] = d[0]; + d[0] += (j[i * 3 + 3] + 3) & -4; + } + for (a = 0; a < e; a++) + { + g[0] = g[1] = g[2] = 0; + for (c = 0; c < f; c++) + { + g[0] += h[0][c] * b[c]; + g[1] += h[1][c] * b[c]; + } + for (c = 0; c < 3; c++) + b[c] = 0 > ((int) g[c] < 65535 ? ((int) g[c]) : 65535) + ? 0 : ((int) g[c]) < 65535 ? (int) g[c] : 65535; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr42709.c b/SingleSource/Regression/C/gcc-dg/vect/pr42709.c new file mode 100644 index 0000000000..77818c4f0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr42709.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int *res[N]; + +int +main1 (int *a, int *b, int *c, int *d) +{ + int i; + + for (i = 0; i < N/2; i+=4) + { + res[i] = a + 16; + res[i+1] = b + 16; + res[i+2] = c + 16; + res[i+3] = d + 16; + asm volatile ("" ::: "memory"); + } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr43430-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr43430-1.c new file mode 100644 index 0000000000..9a6246f4b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr43430-1.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +typedef int myint; +myint data_ch1[N + 1] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 }; +myint data_ch2[N + 1] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 }; +#define SUM 480 + +__attribute__ ((noinline)) int +foo (myint * s1, myint * s2, int stride) +{ + int score = 0; + int x; + for (x = 0; x < N; x++) + score += ((s1[x] - s1[x + stride] + s2[x + stride]) >= 0 ? + s1[x] + s2[x + stride] : + s2[x + stride]); + + if (score != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (data_ch1, data_ch2, 1); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_condition } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr43430-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr43430-2.c new file mode 100644 index 0000000000..71de5657d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr43430-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +typedef unsigned char uint8_t; +int +vsad16_c (void *c, uint8_t * s1, uint8_t * s2, int stride, int h) +{ + int score = 0; + int x, y; + for (x = 0; x < 16; x++) + score += ((s1[x] - s1[x + stride] + s2[x + stride]) >= 0 ? + s1[x] + s2[x + stride] : + s2[x + stride]); + return score; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_condition } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr43432.c b/SingleSource/Regression/C/gcc-dg/vect/pr43432.c new file mode 100644 index 0000000000..bc82fa96e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr43432.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + + +void vector_fmul_reverse_c(float *dst, const float *src0, const float *src1, +int len){ + int i; + src1 += len-1; + for(i=0; i= 1 * 8 ? left : left >> right; +} + +static int8_t +safe_rshift_func_int8_t_s_u (int8_t left, unsigned int right) +{ + return left || right >= 1 * 8 ? left : left >> right; +} + + +static uint32_t +safe_add_func_uint32_t_u_u (uint32_t ui1, uint16_t ui2) +{ + return ui1 + ui2; +} + +int16_t g_4; +int8_t g_4_8; +uint32_t g_9[1]; +uint32_t g_9_8[2]; +void +int161 (void) +{ + int32_t l_2; + + for (l_2 = -25; l_2; l_2 = safe_add_func_uint32_t_u_u (l_2, 1)) + g_9[0] ^= safe_rshift_func_int16_t_s_u (g_4, 1); +} + +int +int81 (void) +{ + int32_t l_2; + + for (l_2 = -25; l_2; l_2 = safe_add_func_uint32_t_u_u (l_2, 1)) + { + g_9[0] ^= safe_rshift_func_int8_t_s_u (g_4_8, 1); + g_9[1] ^= safe_rshift_func_int8_t_s_u (g_4_8, 1); + } + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr44507.c b/SingleSource/Regression/C/gcc-dg/vect/pr44507.c new file mode 100644 index 0000000000..aeac8cd703 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr44507.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int seeIf256ByteArrayIsConstant( + unsigned char *pArray) +{ + int index; + unsigned int curVal, orVal, andVal; + int bytesAreEqual = 0; + + if (pArray != 0) + { + for (index = 0, orVal = 0, andVal = 0xFFFFFFFF; + index < 64; + index += (int)sizeof(unsigned int)) + { + curVal = *((unsigned int *)(&pArray[index])); + orVal = orVal | curVal; + andVal = andVal & curVal; + } + + if (!((orVal == andVal) + && ((orVal >> 8) == (andVal & 0x00FFFFFF)))) + abort (); + } + + return 0; +} + + +int main(int argc, char** argv) +{ + unsigned char array1[64] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }; + + argv = argv; + argc = argc; + + check_vect (); + + return seeIf256ByteArrayIsConstant(&array1[0]); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr45633.c b/SingleSource/Regression/C/gcc-dg/vect/pr45633.c new file mode 100644 index 0000000000..18fde3b88c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr45633.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/45633 */ +/* { dg-do compile } */ + +int s[32]; +unsigned char *t[32]; + +void +foo (void) +{ + int i; + for (i = 0; i < 32; i++) + t[i] -= s[i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr45752.c b/SingleSource/Regression/C/gcc-dg/vect/pr45752.c new file mode 100644 index 0000000000..3c87d9b04f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr45752.c @@ -0,0 +1,162 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ +/* { dg-additional-options "--param tree-reassoc-width=1" } */ + +#include +#include "tree-vect.h" + +#define M00 100 +#define M10 216 +#define M20 23 +#define M30 237 +#define M40 437 + +#define M01 1322 +#define M11 13 +#define M21 27271 +#define M31 2280 +#define M41 284 + +#define M02 74 +#define M12 191 +#define M22 500 +#define M32 111 +#define M42 1114 + +#define M03 134 +#define M13 117 +#define M23 11 +#define M33 771 +#define M43 71 + +#define M04 334 +#define M14 147 +#define M24 115 +#define M34 7716 +#define M44 16 + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 5 / 32) +#else +#define N 20 +#endif + +void foo (unsigned int *__restrict__ pInput, + unsigned int *__restrict__ pOutput, + unsigned int *__restrict__ pInput2, + unsigned int *__restrict__ pOutput2) +{ + unsigned int i, a, b, c, d, e; + + for (i = 0; i < N / 5; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + d = *pInput++; + e = *pInput++; + + *pOutput++ = M00 * a + M01 * b + M02 * c + M03 * d + M04 * e; + *pOutput++ = M10 * a + M11 * b + M12 * c + M13 * d + M14 * e; + *pOutput++ = M20 * a + M21 * b + M22 * c + M23 * d + M24 * e; + *pOutput++ = M30 * a + M31 * b + M32 * c + M33 * d + M34 * e; + *pOutput++ = M40 * a + M41 * b + M42 * c + M43 * d + M44 * e; + + + a = *pInput2++; + b = *pInput2++; + c = *pInput2++; + d = *pInput2++; + e = *pInput2++; + + *pOutput2++ = M00 * a + M01 * b + M02 * c + M03 * d + M04 * e; + *pOutput2++ = M10 * a + M11 * b + M12 * c + M13 * d + M14 * e; + *pOutput2++ = M20 * a + M21 * b + M22 * c + M23 * d + M24 * e; + *pOutput2++ = M30 * a + M31 * b + M32 * c + M33 * d + M34 * e; + *pOutput2++ = M40 * a + M41 * b + M42 * c + M43 * d + M44 * e; + + } +} + +int main (int argc, const char* argv[]) +{ + unsigned int input[N], output[N], i, input2[N], output2[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i%256; + input2[i] = i + 2; + output[i] = 0; + output2[i] = 0; + __asm__ volatile (""); + } + +#if N == 20 + unsigned int check_results[N] + = { 3208, 1334, 28764, 35679, 2789, 13028, 4754, 168364, 91254, 12399, + 22848, 8174, 307964, 146829, 22009, 32668, 11594, 447564, 202404, + 31619 }; + unsigned int check_results2[N] + = { 7136, 2702, 84604, 57909, 6633, 16956, 6122, 224204, 113484, 16243, + 26776, 9542, 363804, 169059, 25853, 36596, 12962, 503404, 224634, + 35463 }; +#else + volatile unsigned int check_results[N]; + volatile unsigned int check_results2[N]; + + for (i = 0; i < N / 5; i++) + { + unsigned int a = input[i * 5]; + unsigned int b = input[i * 5 + 1]; + unsigned int c = input[i * 5 + 2]; + unsigned int d = input[i * 5 + 3]; + unsigned int e = input[i * 5 + 4]; + + check_results[i * 5] = M00 * a + M01 * b + M02 * c + M03 * d + M04 * e; + check_results[i * 5 + 1] = (M10 * a + M11 * b + M12 * c + + M13 * d + M14 * e); + check_results[i * 5 + 2] = (M20 * a + M21 * b + M22 * c + + M23 * d + M24 * e); + check_results[i * 5 + 3] = (M30 * a + M31 * b + M32 * c + + M33 * d + M34 * e); + check_results[i * 5 + 4] = (M40 * a + M41 * b + M42 * c + + M43 * d + M44 * e); + + a = input2[i * 5]; + b = input2[i * 5 + 1]; + c = input2[i * 5 + 2]; + d = input2[i * 5 + 3]; + e = input2[i * 5 + 4]; + + check_results2[i * 5] = M00 * a + M01 * b + M02 * c + M03 * d + M04 * e; + check_results2[i * 5 + 1] = (M10 * a + M11 * b + M12 * c + + M13 * d + M14 * e); + check_results2[i * 5 + 2] = (M20 * a + M21 * b + M22 * c + + M23 * d + M24 * e); + check_results2[i * 5 + 3] = (M30 * a + M31 * b + M32 * c + + M33 * d + M34 * e); + check_results2[i * 5 + 4] = (M40 * a + M41 * b + M42 * c + + M43 * d + M44 * e); + + asm volatile ("" ::: "memory"); + } +#endif + + foo (input, output, input2, output2); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (output[i] != check_results[i] + || output2[i] != check_results2[i]) + abort (); + + return 0; +} + +/* Currently interleaving is not supported for a group-size of 5. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "gaps requires scalar epilogue loop" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" {target { ! { vect_load_lanes && vect_strided5 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr45847.c b/SingleSource/Regression/C/gcc-dg/vect/pr45847.c new file mode 100644 index 0000000000..0e5b6dcecd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr45847.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + + +long long foo (long long *__restrict a, int *__restrict b, int *__restrict c ) +{ + int i; + long long sum=0; + for (i=0;i<256;i++) + sum += (long long)b[i] * c[i]; + + return sum; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr45902.c b/SingleSource/Regression/C/gcc-dg/vect/pr45902.c new file mode 100644 index 0000000000..74510bf94b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr45902.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +short res[N]; +short a[N]; + +int +main1 () +{ + int i; + + for (i = 0; i < N/4; i+=4) + { + res[i] = a[i] >> 8; + res[i+1] = a[i+1] >> 8; + res[i+2] = a[i+2] >> 8; + res[i+3] = a[i+3] >> 8; + } +} + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + a[i] = i; + + main1 (); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (res[i] != a[i] >> 8) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr46009.c b/SingleSource/Regression/C/gcc-dg/vect/pr46009.c new file mode 100644 index 0000000000..fe73dbf5db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr46009.c @@ -0,0 +1,75 @@ +/* PR tree-optimization/46009 */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int a[1024] __attribute__((aligned)); +int b[1024] __attribute__((aligned)); +int c[1024] __attribute__((aligned)); +int d[1024] __attribute__((aligned)); +int e[1024] __attribute__((aligned)); + +void __attribute__((noinline)) +foo (void) +{ + int i, g; + for (i = 0; i < 1024; i++) + { + g = a[i] + b[i] + c[i] * d[i];; + e[i] = g < 10 ? 1 : g; + } +} + +void __attribute__((noinline)) +bar (void) +{ + int i, g; + for (i = 0; i < 1024; i++) + { + g = a[i] + b[i] + c[i] * d[i];; + if (g < 10) + e[i] = 1; + else + e[i] = g; + } +} + +int +main (void) +{ + int i; + check_vect (); + for (i = 0; i < 1024; i++) + { + asm volatile ("" : "+r" (i)); + a[i] = i % 10; + b[i] = i % 10; + c[i] = 1; + d[i] = -1; + e[i] = -1; + } + foo (); +#pragma GCC novector + for (i = 0; i < 1024; i++) + { + int g; + asm volatile ("" : "+r" (i)); + g = 2 * (i % 10) - 1; + if (e[i] != (g < 10 ? 1 : g)) + abort (); + e[i] = -1; + } + bar (); +#pragma GCC novector + for (i = 0; i < 1024; i++) + { + int g; + asm volatile ("" : "+r" (i)); + g = 2 * (i % 10) - 1; + if (e[i] != (g < 10 ? 1 : g)) + abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_int_mult } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr46032.c b/SingleSource/Regression/C/gcc-dg/vect/pr46032.c new file mode 100644 index 0000000000..bad87453a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr46032.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fopenmp } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fopenmp -fipa-pta" } */ + +extern void abort (void); + +#define nEvents 1000 + +static void __attribute__((noinline, noclone, optimize("-fno-tree-vectorize"))) +init (unsigned *results, unsigned *pData) +{ + unsigned int i; + for (i = 0; i < nEvents; ++i) + pData[i] = i % 3; +} + +static void __attribute__((noinline, noclone, optimize("-fno-tree-vectorize"))) +check (unsigned *results) +{ + unsigned sum = 0; + for (int idx = 0; idx < (int)nEvents; idx++) + sum += results[idx]; + + if (sum != 1998) + abort (); +} + +int +main (void) +{ + unsigned results[nEvents]; + unsigned pData[nEvents]; + unsigned coeff = 2; + + init (&results[0], &pData[0]); + +#pragma omp parallel for + for (int idx = 0; idx < (int)nEvents; idx++) + results[idx] = coeff * pData[idx]; + + check (&results[0]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-not "versioning for alias required" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr46049.c b/SingleSource/Regression/C/gcc-dg/vect/pr46049.c new file mode 100644 index 0000000000..ffc72e5602 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr46049.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +typedef __INT16_TYPE__ int16_t; +typedef __INT32_TYPE__ int32_t; + +static inline int32_t bar (int16_t x, int16_t y) +{ + return x * y; +} + +void foo (int16_t i, int16_t *p, int16_t x) +{ + while (i--) + { + *p = bar (*p, x) >> 15; + p++; + *p = bar (*p, x) >> 15; + p++; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr46052.c b/SingleSource/Regression/C/gcc-dg/vect/pr46052.c new file mode 100644 index 0000000000..3de8109107 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr46052.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +int i; +int a[2]; + +static inline char bar (void) +{ + return i ? i : 1; +} + +void foo (int n) +{ + while (n--) + { + a[0] ^= bar (); + a[1] ^= bar (); + } +} + +static inline char bar1 (void) +{ +} + +void foo1 (int n) +{ + while (n--) + { + a[0] ^= bar1 (); + a[1] ^= bar1 (); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr46126.c b/SingleSource/Regression/C/gcc-dg/vect/pr46126.c new file mode 100644 index 0000000000..5f535498b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr46126.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; + +typedef struct TypHeader { + struct TypHeader * * ptr; + unsigned char type; + } * TypHandle; + extern TypHandle (* EvTab[81]) ( TypHandle hd ); + TypHandle FunApplyRel ( TypHandle hdCall ) + { + TypHandle hdApp; + TypHandle * ptApp; + long lp; + long lc; + hdApp = ((uintptr_t)(((TypHandle*)((hdCall)->ptr))[1])&1 ? +(((TypHandle*)((hdCall)->ptr))[1]) : (* +EvTab[(((uintptr_t)(((TypHandle*)((hdCall)->ptr))[1]) & 1) ? 1 : +((((TypHandle*)((hdCall)->ptr))[1])->type))])((((TypHandle*)((hdCall)->ptr))[1]))); + ptApp = ((TypHandle*)((hdApp)->ptr)); + ptApp[1] = ((TypHandle) (uintptr_t) (((long)(lp) << 2) + 1)); + ptApp[2] = ((TypHandle) (uintptr_t) (((long)(lc) << 2) + 1)); + } + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr46663.c b/SingleSource/Regression/C/gcc-dg/vect/pr46663.c new file mode 100644 index 0000000000..c2e56bb253 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr46663.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O -fexceptions" } */ +/* { dg-require-effective-target exceptions } */ + +typedef __attribute__ ((const)) int (*bart) (void); + +int foo (bart bar, int m) +{ + int i, j = 0; + for (i = 0; i < m; i++) + j += bar(); + return j; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr47001.c b/SingleSource/Regression/C/gcc-dg/vect/pr47001.c new file mode 100644 index 0000000000..53e0a4fc47 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr47001.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +extern void abort (void); + +#define N 128 + +int a[N]; + +int main1 (int res0, int res1) +{ + int i; + int sum0 = 0, sum1 = 0; + + for (i = 0; i < N/2; i++) { + sum1 += a[2*i]; + sum0 += a[2*i]; + } + + /* Check results: */ + if (sum0 != res0 + || sum1 != res1) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr47139.c b/SingleSource/Regression/C/gcc-dg/vect/pr47139.c new file mode 100644 index 0000000000..042ad74e1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr47139.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int d; + +void +foo () +{ + int a = 0; + unsigned char b; + for (b = 1; b; b++) + { + d = a; + a |= b; + } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr48052.c b/SingleSource/Regression/C/gcc-dg/vect/pr48052.c new file mode 100644 index 0000000000..071e0bc7b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr48052.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int_mult } */ + +int foo(int* A, int* B, unsigned start, unsigned BS) +{ + int s = 0; + for (unsigned k = start; k < start + BS; k++) + { + s += A[k] * B[k]; + } + + return s; +} + +int bar(int* A, int* B, unsigned BS) +{ + int s = 0; + for (unsigned k = 0; k < BS; k++) + { + s += A[k] * B[k]; + } + + return s; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr48172.c b/SingleSource/Regression/C/gcc-dg/vect/pr48172.c new file mode 100644 index 0000000000..850e9b92bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr48172.c @@ -0,0 +1,35 @@ +#include "tree-vect.h" + +extern void *memset(void *s, int c, __SIZE_TYPE__ n); +extern void abort (void); + +#define ASIZE 1028 +#define HALF (ASIZE/2) + +int main() { + unsigned int array[ASIZE]; + int i; + + check_vect (); + + memset(array, 0, sizeof(array)); + + /* initialize first half of the array */ + for (i = 0; i < HALF; i++) + array[i] = i; + + /* fill second half of array in by summing earlier elements of the array + gcc 4.5.1 and 4.5.2 incorrectly vectorize this loop! aray[1025] is left + at 0 for ASIZE=1028 */ + for (i = 0; i < HALF-1; i++) + array[HALF+i] = array[2*i] + array[2*i + 1]; + + /* see if we have any failures */ +#pragma GCC novector + for (i = 0; i < HALF - 1; i++) + if (array[HALF+i] != array[2*i] + array[2*i + 1]) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr48377.c b/SingleSource/Regression/C/gcc-dg/vect/pr48377.c new file mode 100644 index 0000000000..a526de9769 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr48377.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/48377 */ +/* { dg-require-effective-target non_strict_align } */ + +#include "tree-vect.h" + +typedef unsigned int U __attribute__((__aligned__ (1), __may_alias__)); + +__attribute__((noinline, noclone)) unsigned int +foo (const char *s, int len) +{ + const U *p = (const U *) s; + unsigned int f = len / sizeof (unsigned int), hash = len, i; + + for (i = 0; i < f; ++i) + hash += *p++; + return hash; +} + +char buf[64] __attribute__((aligned (32))); + +int +main (void) +{ + check_vect (); + return foo (buf + 1, 26) != 26; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr48765.c b/SingleSource/Regression/C/gcc-dg/vect/pr48765.c new file mode 100644 index 0000000000..b091a145d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr48765.c @@ -0,0 +1,84 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */ +/* { dg-additional-options "-O3 -mcpu=power6 -mno-power9-vector -mno-power8-vector -mno-vsx" } */ + +enum reg_class +{ + NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS, XGRF_REGS, ALL_REGS, + LIM_REG_CLASSES +}; +enum machine_mode +{ + VOIDmode, QImode, HImode, PSImode, SImode, PDImode, DImode, TImode, OImode, + QFmode, HFmode, TQFmode, SFmode, DFmode, XFmode, TFmode, SCmode, DCmode, + XCmode, TCmode, CQImode, CHImode, CSImode, CDImode, CTImode, COImode, + BLKmode, CCmode, CCEVENmode, MAX_MACHINE_MODE +}; +typedef struct rtx_def +{ + int mode:8; +} + *rtx; +extern rtx *regno_reg_rtx; +typedef unsigned int HARD_REG_ELT_TYPE; +typedef HARD_REG_ELT_TYPE HARD_REG_SET[((64 + 32 - 1) / 32)]; +extern int reg_alloc_order[64]; +extern int max_regno; +extern int *reg_n_calls_crossed; +extern short *reg_renumber; +static int *reg_where_dead; +static int *reg_where_born; +static int *reg_order; +static char *regs_change_size; +static HARD_REG_SET *after_insn_hard_regs; +static int stupid_find_reg (int, enum reg_class, enum machine_mode, int, int, + int); +enum reg_class reg_preferred_class (int); +void +stupid_life_analysis (f, nregs, file) + int nregs, file; + rtx f; +{ + register int i; + for (i = (((64)) + 3) + 1; i < max_regno; i++) + { + register int r = reg_order[i]; + if ((int) LIM_REG_CLASSES > 1) + reg_renumber[r] = + stupid_find_reg (reg_n_calls_crossed[r], reg_preferred_class (r), + ((regno_reg_rtx[r])->mode), reg_where_born[r], + reg_where_dead[r], regs_change_size[r]); + } +} + +static int +stupid_find_reg (call_preserved, class, mode, born_insn, dead_insn, + changes_size) + int call_preserved, born_insn, dead_insn, changes_size; + enum reg_class class; + enum machine_mode mode; +{ + register int i, ins; + HARD_REG_SET used, this_reg; + for (ins = born_insn; ins < dead_insn; ins++) + do + { + register HARD_REG_ELT_TYPE *scan_tp_ = (used), *scan_fp_ = + (after_insn_hard_regs[ins]); + for (i = 0; i < ((64 + 32 - 1) / 32); i++) + *scan_tp_++ |= *scan_fp_++; + } + while (0); + for (i = 0; i < 64; i++) + { + int regno = reg_alloc_order[i]; + if (((used)[(regno) / ((unsigned) 32)] & + (((HARD_REG_ELT_TYPE) (1)) << ((regno) % ((unsigned) 32))))) + { + register int j; + if (j == regno) + return regno; + } + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr49038.c b/SingleSource/Regression/C/gcc-dg/vect/pr49038.c new file mode 100644 index 0000000000..b9e812600b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr49038.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target mmap } */ + +#include +#include +#include "tree-vect.h" + +#define COUNT 320 +#define MMAP_SIZE 0x10000 +#define ADDRESS 0x1122000000 +#define TYPE unsigned short + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +void __attribute__((noinline)) +foo (TYPE *__restrict a, TYPE *__restrict b) +{ + int n; + + for (n = 0; n < COUNT; n++) + a[n] = b[n * 2]; +} + +int +main (void) +{ + void *x; + size_t b_offset; + + check_vect (); + + x = mmap ((void *) ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (x == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + + b_offset = MMAP_SIZE - (2 * COUNT - 1) * sizeof (TYPE); + foo ((unsigned short *) x, + (unsigned short *) ((char *) x + b_offset)); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr49093.c b/SingleSource/Regression/C/gcc-dg/vect/pr49093.c new file mode 100644 index 0000000000..dd1d8cc047 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr49093.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O1 -fno-tree-fre" } */ + +volatile unsigned char g_324[4] = {0, 1, 0, 1}; +void foo (int); +int x, y; +void func_81(void) +{ + int l_466, l_439[7] = {0}, g_97; +lbl_473: + if (x) { + for (g_97 = 0; (g_97 < 4); ++g_97) { + if (y) + goto lbl_473; + g_324[g_97]; + l_466 = l_439[g_97]; + } + foo(l_466); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr49318.c b/SingleSource/Regression/C/gcc-dg/vect/pr49318.c new file mode 100644 index 0000000000..abe76fa6b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr49318.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ + +typedef enum { GL_FALSE } GLenum; +typedef unsigned char GLboolean; +typedef int GLint; +typedef unsigned int GLuint; +typedef float GLfloat; +typedef double GLdouble; +typedef struct gl_context GLcontext; +struct gl_context { + GLfloat TextureMatrix[16]; + GLenum Primitive; +}; +void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params ) { + GLuint i; + for (i=0; i<16; i++) + params[i] = (GLint) ctx->TextureMatrix[i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr49352.c b/SingleSource/Regression/C/gcc-dg/vect/pr49352.c new file mode 100644 index 0000000000..2d5e723d7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr49352.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/49352 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -fcompare-debug" } */ + +int +foo (int *x, int *y, int n) +{ + int i, j; + int dot = 0; + for (i = 0; i < n; i++) + for (j = 0; j < 2; j++) + dot += *(x++) * *(y++); + return dot; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr49478.c b/SingleSource/Regression/C/gcc-dg/vect/pr49478.c new file mode 100644 index 0000000000..c740fd31e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr49478.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#include + +#define N 64 + +unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +unsigned int +foo (int len) { + int i; + unsigned int result = 0; + unsigned short prod; + + for (i=0; i 1); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr49771.c b/SingleSource/Regression/C/gcc-dg/vect/pr49771.c new file mode 100644 index 0000000000..1d8b9b34dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr49771.c @@ -0,0 +1,29 @@ +extern void abort (void); + +#include +#include "tree-vect.h" + +static int a[1000]; + +int +foo (void) +{ + int j; + int i; + for (i = 0; i < 1000; i++) + for (j = 0; j < 1000; j++) + a[j] = a[i] + 1; + return a[0]; +} + +int +main (void) +{ + int res; + check_vect (); + res = foo (); + if (res != 1999) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr49926.c b/SingleSource/Regression/C/gcc-dg/vect/pr49926.c new file mode 100644 index 0000000000..c7bca69e46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr49926.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int a, b, c[10]; + +void +foo (unsigned int x, int y, int z, int *w) +{ + do + { + *w = z; + y = x; + if (y) + for (b = -4; b; b++) + { + z = y &= a &= 1; + y &= c[b + 4]; + } + } + while (1); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr50014.c b/SingleSource/Regression/C/gcc-dg/vect/pr50014.c new file mode 100644 index 0000000000..6ed43c681a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr50014.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int f(unsigned char *s, int n) +{ + int sum = 0; + int i; + + for (i = 0; i < n; i++) + sum += 256 * s[i]; + + return sum; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr50451.c b/SingleSource/Regression/C/gcc-dg/vect/pr50451.c new file mode 100644 index 0000000000..b749a2c6cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr50451.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int +foo (int integral, int decimal, int power_ten) +{ + while (power_ten > 0) + { + integral *= 10; + decimal *= 10; + power_ten--; + } + + return integral+decimal; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr50635.c b/SingleSource/Regression/C/gcc-dg/vect/pr50635.c new file mode 100644 index 0000000000..3d84357049 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr50635.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +typedef signed long int32_t; +typedef char int8_t; + +void f0a(int32_t * result, int32_t * arg1, int8_t * arg2, int32_t temp_3) +{ + int idx; + for (idx=0;idx<10;idx += 1) + { + int32_t temp_4; + int32_t temp_12; + + temp_4 = (-2 & arg2[idx]) + temp_3; + temp_12 = -2 * arg2[idx] + temp_4; + result[idx] = temp_12; + } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr50727.c b/SingleSource/Regression/C/gcc-dg/vect/pr50727.c new file mode 100644 index 0000000000..9b6d9e0038 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr50727.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +typedef unsigned char uint8_t; +typedef unsigned long uint32_t; +void +f0a (uint32_t * __restrict__ result, uint32_t * arg2, + uint8_t * __restrict__ arg4) +{ + int idx; + for (idx = 0; idx < 429; idx += 1) + { + uint32_t temp_9; + uint32_t temp_11; + temp_9 = ((-19 | arg4[idx]) >> arg2[idx]); + temp_11 = (((-19 ^ arg4[idx]) & arg2[idx]) ^ temp_9); + result[idx] = temp_11; + } +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51000.c b/SingleSource/Regression/C/gcc-dg/vect/pr51000.c new file mode 100644 index 0000000000..2be1e60e04 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51000.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +_Bool a[2048]; +int b[2048]; + +void +foo () +{ + int i; + for (i = 0; i < 2048; i += 4) + { + a[i] = b[i] <= 10; + a[i + 3] = b[i + 1] <= 10; + a[i + 2] = b[i + 2] <= 10; + a[i + 1] = b[i + 3] <= 10; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51015.c b/SingleSource/Regression/C/gcc-dg/vect/pr51015.c new file mode 100644 index 0000000000..3dadeadf17 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51015.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +typedef unsigned long long __u64; +static __u64 ext2_max_sizes[16 - 10 + 1]; + +void e2fsck_pass1() +{ + int i; + __u64 max_sizes; + + for (i = 10; i <= 16; i++) { + max_sizes = 12 + (1ULL << ((i) - 2)); + max_sizes = max_sizes + (1ULL << ((i) - 2)) * (1ULL << ((i) - 2)); + max_sizes = max_sizes + (1ULL << ((i) - 2)) * (1ULL << ((i) - 2)) * (1ULL <<((i) - 2)); + ext2_max_sizes[i - 10] = max_sizes; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51074.c b/SingleSource/Regression/C/gcc-dg/vect/pr51074.c new file mode 100644 index 0000000000..d6c8cea1f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51074.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/51074 */ + +#include "tree-vect.h" + +struct S { int a, b; } s[8]; + +int +main () +{ + int i; + check_vect (); + for (i = 0; i < 8; i++) + { + s[i].b = 0; + s[i].a = i; + } + asm volatile ("" : : : "memory"); +#pragma GCC novector + for (i = 0; i < 8; i++) + if (s[i].b != 0 || s[i].a != i) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51301.c b/SingleSource/Regression/C/gcc-dg/vect/pr51301.c new file mode 100644 index 0000000000..b060c8eb62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51301.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +typedef signed char int8_t; +typedef signed long long int64_t; +int64_t +f0a (int8_t * __restrict__ arg1) +{ + int idx; + int64_t result = 0; + for (idx = 0; idx < 416; idx += 1) + result += arg1[idx] << (arg1[idx] == arg1[idx]); + return result; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51581-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr51581-1.c new file mode 100644 index 0000000000..8ba9279ec9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51581-1.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/51581 */ + +#include "tree-vect.h" + +#define main main1 +#include "../../gcc.c-torture/execute/pr51581-1.c" +#undef main + +int +main () +{ + int i; + check_vect (); + asm (""); + return main1 (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51581-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr51581-2.c new file mode 100644 index 0000000000..9f87386a13 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51581-2.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/51581 */ + +#include "tree-vect.h" + +#define main main1 +#include "../../gcc.c-torture/execute/pr51581-2.c" +#undef main + +int +main () +{ + int i; + check_vect (); + asm (""); + return main1 (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51581-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr51581-3.c new file mode 100644 index 0000000000..25acceef0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51581-3.c @@ -0,0 +1,120 @@ +/* PR tree-optimization/51581 */ + +#include "tree-vect.h" + +int a[8], b[8]; +unsigned int c[8], d[8]; + +void +f1 (void) +{ + a[0] = b[0] / 8; + a[1] = b[1] / 8; + a[2] = b[2] / 8; + a[3] = b[3] / 8; + a[4] = b[4] / 8; + a[5] = b[5] / 8; + a[6] = b[6] / 8; + a[7] = b[7] / 8; +} + +void +f2 (void) +{ + c[0] = d[0] / 3; + c[1] = d[1] / 3; + c[2] = d[2] / 3; + c[3] = d[3] / 3; + c[4] = d[4] / 3; + c[5] = d[5] / 3; + c[6] = d[6] / 3; + c[7] = d[7] / 3; +} + +void +f3 (void) +{ + a[0] = b[0] / 8; + a[1] = b[1] / 4; + a[2] = b[2] / 8; + a[3] = b[3] / 4; + a[4] = b[4] / 8; + a[5] = b[5] / 4; + a[6] = b[6] / 8; + a[7] = b[7] / 4; +} + +void +f4 (void) +{ + c[0] = d[0] / 3; + c[1] = d[1] / 5; + c[2] = d[2] / 3; + c[3] = d[3] / 5; + c[4] = d[4] / 3; + c[5] = d[5] / 5; + c[6] = d[6] / 3; + c[7] = d[7] / 5; +} + +void +f5 (void) +{ + a[0] = b[0] / 14; + a[1] = b[1] / 15; + a[2] = b[2] / 14; + a[3] = b[3] / 15; + a[4] = b[4] / 14; + a[5] = b[5] / 15; + a[6] = b[6] / 14; + a[7] = b[7] / 15; +} + +void +f6 (void) +{ + c[0] = d[0] / 6; + c[1] = d[1] / 5; + c[2] = d[2] / 6; + c[3] = d[3] / 5; + c[4] = d[4] / 6; + c[5] = d[5] / 5; + c[6] = d[6] / 13; + c[7] = d[7] / 5; +} + +int +main () +{ + int i; + check_vect (); + asm (""); + for (i = 0; i < 8; i++) + { + asm (""); + b[i] = i - 4; + d[i] = i - 4; + } + f1 (); + f2 (); +#pragma GCC novector + for (i = 0; i < 8; i++) + if (a[i] != b[i] / 8 || c[i] != d[i] / 3) + abort (); + f3 (); + f4 (); +#pragma GCC novector + for (i = 0; i < 8; i+= 2) + if (a[i] != b[i] / 8 || a[i + 1] != b[i + 1] / 4 + || c[i] != d[i] / 3 || c[i + 1] != d[i + 1] / 5) + abort (); + f5 (); + f6 (); +#pragma GCC novector + for (i = 0; i < 8; i+= 2) + if (a[i] != b[i] / 14 || a[i + 1] != b[i + 1] / 15 + || c[i] != d[i] / (i == 6 ? 13 : 6) || c[i + 1] != d[i + 1] / 5) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51581-4.c b/SingleSource/Regression/C/gcc-dg/vect/pr51581-4.c new file mode 100644 index 0000000000..f6234f3e7c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51581-4.c @@ -0,0 +1,168 @@ +/* PR tree-optimization/51581 */ + +#include "tree-vect.h" + +short int a[16], b[16]; +unsigned short int c[16], d[16]; + +void +f1 (void) +{ + a[0] = b[0] / 8; + a[1] = b[1] / 8; + a[2] = b[2] / 8; + a[3] = b[3] / 8; + a[4] = b[4] / 8; + a[5] = b[5] / 8; + a[6] = b[6] / 8; + a[7] = b[7] / 8; + a[8] = b[8] / 8; + a[9] = b[9] / 8; + a[10] = b[10] / 8; + a[11] = b[11] / 8; + a[12] = b[12] / 8; + a[13] = b[13] / 8; + a[14] = b[14] / 8; + a[15] = b[15] / 8; +} + +void +f2 (void) +{ + c[0] = d[0] / 3; + c[1] = d[1] / 3; + c[2] = d[2] / 3; + c[3] = d[3] / 3; + c[4] = d[4] / 3; + c[5] = d[5] / 3; + c[6] = d[6] / 3; + c[7] = d[7] / 3; + c[8] = d[8] / 3; + c[9] = d[9] / 3; + c[10] = d[10] / 3; + c[11] = d[11] / 3; + c[12] = d[12] / 3; + c[13] = d[13] / 3; + c[14] = d[14] / 3; + c[15] = d[15] / 3; +} + +void +f3 (void) +{ + a[0] = b[0] / 8; + a[1] = b[1] / 4; + a[2] = b[2] / 8; + a[3] = b[3] / 4; + a[4] = b[4] / 8; + a[5] = b[5] / 4; + a[6] = b[6] / 8; + a[7] = b[7] / 4; + a[8] = b[8] / 8; + a[9] = b[9] / 4; + a[10] = b[10] / 8; + a[11] = b[11] / 4; + a[12] = b[12] / 8; + a[13] = b[13] / 4; + a[14] = b[14] / 8; + a[15] = b[15] / 4; +} + +void +f4 (void) +{ + c[0] = d[0] / 3; + c[1] = d[1] / 5; + c[2] = d[2] / 3; + c[3] = d[3] / 5; + c[4] = d[4] / 3; + c[5] = d[5] / 5; + c[6] = d[6] / 3; + c[7] = d[7] / 5; + c[8] = d[8] / 3; + c[9] = d[9] / 5; + c[10] = d[10] / 3; + c[11] = d[11] / 5; + c[12] = d[12] / 3; + c[13] = d[13] / 5; + c[14] = d[14] / 3; + c[15] = d[15] / 5; +} + +void +f5 (void) +{ + a[0] = b[0] / 14; + a[1] = b[1] / 15; + a[2] = b[2] / 14; + a[3] = b[3] / 15; + a[4] = b[4] / 14; + a[5] = b[5] / 15; + a[6] = b[6] / 14; + a[7] = b[7] / 15; + a[8] = b[8] / 14; + a[9] = b[9] / 15; + a[10] = b[10] / 14; + a[11] = b[11] / 15; + a[12] = b[12] / 14; + a[13] = b[13] / 15; + a[14] = b[14] / 14; + a[15] = b[15] / 15; +} + +void +f6 (void) +{ + c[0] = d[0] / 6; + c[1] = d[1] / 5; + c[2] = d[2] / 6; + c[3] = d[3] / 5; + c[4] = d[4] / 6; + c[5] = d[5] / 5; + c[6] = d[6] / 13; + c[7] = d[7] / 5; + c[8] = d[8] / 6; + c[9] = d[9] / 5; + c[10] = d[10] / 6; + c[11] = d[11] / 5; + c[12] = d[12] / 6; + c[13] = d[13] / 5; + c[14] = d[14] / 13; + c[15] = d[15] / 5; +} + +int +main () +{ + int i; + check_vect (); + asm (""); + for (i = 0; i < 16; i++) + { + asm (""); + b[i] = i - 8; + d[i] = i - 8; + } + f1 (); + f2 (); +#pragma GCC novector + for (i = 0; i < 16; i++) + if (a[i] != b[i] / 8 || c[i] != d[i] / 3) + abort (); + f3 (); + f4 (); +#pragma GCC novector + for (i = 0; i < 16; i+= 2) + if (a[i] != b[i] / 8 || a[i + 1] != b[i + 1] / 4 + || c[i] != d[i] / 3 || c[i + 1] != d[i + 1] / 5) + abort (); + f5 (); + f6 (); +#pragma GCC novector + for (i = 0; i < 16; i+= 2) + if (a[i] != b[i] / 14 || a[i + 1] != b[i + 1] / 15 + || c[i] != d[i] / ((i & 7) == 6 ? 13 : 6) || c[i + 1] != d[i + 1] / 5) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51590.c b/SingleSource/Regression/C/gcc-dg/vect/pr51590.c new file mode 100644 index 0000000000..55757ecbd4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51590.c @@ -0,0 +1,34 @@ +/* PR middle-end/51590 */ +/* { dg-do compile } */ + +struct S { long a, b; }; + +extern void baz (char *); + +static void +bar (struct S *x) +{ + char c[8]; + int i; + + for (i = 0; i < 8; i++) + c[i] = x->a >> ((7 - i) * 8); + + baz (c); +} + +void +foo (const char *x, struct S *y) +{ + struct S d = *y; + int i; + + for (i = 0; *x; x++) + i++; + + if (i != 1) + return; + + bar (&d); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr51799.c b/SingleSource/Regression/C/gcc-dg/vect/pr51799.c new file mode 100644 index 0000000000..84f402a78b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr51799.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned long uint32_t; +void +f0a (uint32_t * __restrict__ result, int8_t * __restrict__ arg1, + uint32_t * __restrict__ arg4, int8_t temp_6) +{ + int idx; + for (idx = 0; idx < 416; idx += 1) + { + result[idx] = (uint8_t)(((arg1[idx] << 7) + arg4[idx]) * temp_6); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr52091.c b/SingleSource/Regression/C/gcc-dg/vect/pr52091.c new file mode 100644 index 0000000000..33bc7aa8dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr52091.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_int } */ + +/* PR tree-optimization/52091 */ + +#include "tree-vect.h" + +int b, c, d, f; +unsigned h; +extern void abort (void); + +int +main () +{ + check_vect (); + d = -1; + h = 65; + asm volatile ("" : : : "memory"); + for (f = 0; f < 4; f++) + { + h &= (unsigned short) d; + for (b = 0; b <= 1; b++) + { + c = 0; + d &= 1; + } + } + asm volatile ("" : : : "memory"); + if (b != 2 || c != 0 || d != 1 || f != 4 || h != 1) + abort (); + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr52252-ld.c b/SingleSource/Regression/C/gcc-dg/vect/pr52252-ld.c new file mode 100644 index 0000000000..e17cabe104 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr52252-ld.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mssse3" { target { i?86-*-* x86_64-*-* } } } */ +#define byte unsigned char + +void +matrix_mul (byte *in, byte *out, int size) +{ + int i; + for (i = 0; i < size; i++) + { + byte in0 = in[0]; + byte in1 = in[1]; + byte in2 = in[2]; + byte out0, out1, out2, out3; + out0 = in0 + in1; + out1 = in0 + in2; + out2 = in1 + in2; + out3 = in0 + in1 + in2; + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = out3; + in += 3; + out += 4; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr52252-st.c b/SingleSource/Regression/C/gcc-dg/vect/pr52252-st.c new file mode 100644 index 0000000000..5954d45f5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr52252-st.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mssse3" { target { i?86-*-* x86_64-*-* } } } */ + +#define byte unsigned char + +void +matrix_mul (byte *in, byte *out, int size) +{ + int i; + for (i = 0; i < size; i++) + { + out[0] = in[0] + in[1] + in[3]; + out[1] = in[0] + in[2] + in[4]; + out[2] = in[1] + in[2] + in[4]; + in += 4; + out += 3; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr52298.c b/SingleSource/Regression/C/gcc-dg/vect/pr52298.c new file mode 100644 index 0000000000..e1185e662b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr52298.c @@ -0,0 +1,33 @@ +/* { dg-additional-options "-O1 -fno-tree-pre -fno-tree-loop-im" } */ + +#include "tree-vect.h" + +extern void abort (void); +int c[80]; + +__attribute__((noinline)) int +foo (void) +{ + int l = 0; + int a, b; + + for (a = 3; a >= 0; a--) + for (b = 7; b >= 0; b--) + l |= c[a+60]; + return l; +} + +int +main () +{ + int i; + check_vect (); + for (i = 0; i < 60; i++) + c[i] = 1; + for (; i < 64; i++) + c[i] = 1 << (i - 59); + if (foo () != 30) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr52870.c b/SingleSource/Regression/C/gcc-dg/vect/pr52870.c new file mode 100644 index 0000000000..25df674957 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr52870.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O1" } */ + +void foo (unsigned long int); + +long +test (int *x) +{ + unsigned long sx, xprec; + + sx = *x >= 0 ? *x : -*x; + + xprec = sx * 64; + + if (sx < 16384) + foo (sx); + + return xprec; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr53185-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr53185-2.c new file mode 100644 index 0000000000..51614e70d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr53185-2.c @@ -0,0 +1,30 @@ +#include "tree-vect.h" + +void __attribute__((noinline,noclone)) +fn1 (int * __restrict f, int * __restrict d, unsigned short a, int c) +{ + unsigned short e; + for (e = 0; e < a; ++e) + f[e] = d[e * c]; +} + +extern void abort (void); + +int main () +{ + int a[32], b[3 * 32]; + int i, off; + check_vect (); + for (i = 0; i < 3 * 32; ++i) + b[i] = i; + for (off = 0; off < 8; ++off) + { + fn1 (&a[off], &b[off], 32 - off, 3); +#pragma GCC novector + for (i = 0; i < 32 - off; ++i) + if (a[off+i] != b[off+i*3]) + abort (); + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr53185.c b/SingleSource/Regression/C/gcc-dg/vect/pr53185.c new file mode 100644 index 0000000000..fc73b4d3a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr53185.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +unsigned short a, e; +int *b, *d; +int c; +extern int fn2(); +void fn1 () { + void *f; + for (;;) { + fn2 (); + b = f; + e = 0; + for (; e < a; ++e) + b[e] = d[e * c]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr53773.c b/SingleSource/Regression/C/gcc-dg/vect/pr53773.c new file mode 100644 index 0000000000..213e74e0b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr53773.c @@ -0,0 +1,26 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-do compile } */ +/* Disable BB vectorization, we now can cover the whole loop with that + when the target supports .REDUC_PLUS for integers, we don't have a + good target selector for this. */ +/* { dg-additional-options "-fdump-tree-optimized -fno-tree-slp-vectorize" } */ + +int +foo (int integral, int decimal, int power_ten) +{ + while (power_ten > 0) + { + integral *= 10; + decimal *= 10; + power_ten--; + } + + return integral+decimal; +} + +/* We can avoid a scalar tail when using fully-masked loops with a fixed + vector length. */ +/* { dg-final { scan-tree-dump-times "\\* 10" 2 "optimized" { target { { ! vect_fully_masked } || vect_variable_length } } } } */ +/* { dg-final { scan-tree-dump-times "\\* 10" 0 "optimized" { target { vect_fully_masked && { ! vect_variable_length } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr55857-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr55857-1.c new file mode 100644 index 0000000000..efd64f7d1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr55857-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +void +foo (int *data, unsigned len, const int qlp_coeff[], int lp, int residual[]) +{ + int i; + int sum; + for(i = 0; i < (int)len; i++) + { + sum = 0; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp); + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr55857-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr55857-2.c new file mode 100644 index 0000000000..5d07913da7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr55857-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +void foo (int *data, unsigned len, const int qlp_coeff[], + unsigned order, int lp, int residual[]) +{ + int i; + int sum; + if(order == 2) + for(i = 0; i < (int)len; i++) + { + sum = 0; + sum += qlp_coeff[1] * data[i-2]; + sum += qlp_coeff[0] * data[i-1]; + residual[i] = data[i] - (sum >> lp); + } + else + for(i = 0; i < (int)len; i++) + residual[i] = data[i] - ((qlp_coeff[0] * data[i-1]) >> lp); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr56541.c b/SingleSource/Regression/C/gcc-dg/vect/pr56541.c new file mode 100644 index 0000000000..fa86142716 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr56541.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_condition } */ + +float a,b,c,d; + +float z[1024]; int ok[1024]; +const float rBig = 150.; + +void foo() +{ + int i; + + for (i=0; i!=1024; ++i) + { + float rR = a*z[i]; + float rL = b*z[i]; + float rMin = (rR0) ? rMin : rBig; + rMin = (rMin>0) ? rMin : rMax; + ok[i] = rMin-c0; --i) + d[n-i] = 0.0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr57558-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr57558-1.c new file mode 100644 index 0000000000..e03aa0f27b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr57558-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +typedef unsigned int u_int; +void foo (u_int* __restrict x, u_int* __restrict y, u_int n) +{ + u_int i; + for (i=1; i<=n; i++, x++, y++) + *x += *y; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr57558-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr57558-2.c new file mode 100644 index 0000000000..ba8600351c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr57558-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void foo (int *a, int len) +{ + unsigned short i; + + for (i = 1; i < (len - 1); i++) + a[i] = a[i+1]; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr57705.c b/SingleSource/Regression/C/gcc-dg/vect/pr57705.c new file mode 100644 index 0000000000..39c32946d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr57705.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int a[1024]; +unsigned char b[1024]; + +extern void abort (void); + +__attribute__((noinline, noclone)) void +foo (int k, int m) +{ + int i, k2 = k; + for (i = 0; i < 1024; i++) + { + a[i] = k2; + k2 += m + 1; + } +} + +__attribute__((noinline, noclone)) void +bar (int k, int m) +{ + int i, k2 = k; + for (i = 0; i < 1024; i++) + { + k2 += m + 1; + a[i] = k2; + } +} + +__attribute__((noinline, noclone)) void +baz (int k, int m) +{ + int i, k2 = k; + for (i = 0; i < 1024; i++) + { + a[i] = k2; + b[i] = i; + k2 += m + 1; + } +} + +int +main () +{ + int i; + check_vect (); + foo (5, 3); +#pragma GCC novector + for (i = 0; i < 1024; i++) + if (a[i] != 5 + 4 * i) + abort (); + bar (5, 3); +#pragma GCC novector + for (i = 0; i < 1024; i++) + if (a[i] != 9 + 4 * i) + abort (); + baz (5, 3); +#pragma GCC novector + for (i = 0; i < 1024; i++) + if (a[i] != 5 + 4 * i || b[i] != (unsigned char) i) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 3 "vect" { target vect_pack_trunc } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 2 "vect" { target { ! vect_pack_trunc } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr57741-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr57741-1.c new file mode 100644 index 0000000000..ec8c41a048 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr57741-1.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/57741 */ +/* { dg-do compile } */ + +void +foo (float *p, float *q, float x) +{ + int i; + float f = 1.0f, g = 2.0f; + for (i = 0; i < 1024; i++) + { + *p++ = f; + f += x; + } + for (i = 0; i < 1024; i++) + { + *q++ = g; + g += 0.5f; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr57741-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr57741-2.c new file mode 100644 index 0000000000..6addd76b42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr57741-2.c @@ -0,0 +1,44 @@ +/* PR tree-optimization/57741 */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-ffast-math" } */ + +#include "tree-vect.h" + +extern void abort (void); + +__attribute__((noinline, noclone)) void +foo (float *p, float *q, float x) +{ + int i; + p = (float *) __builtin_assume_aligned (p, 32); + q = (float *) __builtin_assume_aligned (q, 32); + float f = 1.0f, g = 2.0f; + for (i = 0; i < 1024; i++) + { + *p++ = f; + f += x; + } + for (i = 0; i < 1024; i++) + { + *q++ = g; + g += 0.5f; + } +} + +float p[1024] __attribute__((aligned (32))) = { 17.0f }; +float q[1024] __attribute__((aligned (32))) = { 17.0f }; + +int +main () +{ + int i; + check_vect (); + foo (p, q, 1.5f); +#pragma GCC novector + for (i = 0; i < 1024; i++) + if (p[i] != 1.0f + i * 1.5f || q[i] != 2.0f + i * 0.5f) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr57741-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr57741-3.c new file mode 100644 index 0000000000..916fa13151 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr57741-3.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/57741 */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-ffast-math" } */ + +#include "tree-vect.h" + +extern void abort (void); + +float p[1024] __attribute__((aligned (32))) = { 17.0f }; +float q[1024] __attribute__((aligned (32))) = { 17.0f }; +char r[1024] __attribute__((aligned (32))) = { 1 }; + +__attribute__((noinline, noclone)) void +foo (float x) +{ + int i; + float f = 1.0f, g = 2.0f; + for (i = 0; i < 1024; i++) + { + p[i] = f; + f += x; + q[i] = g; + g += 0.5f; + r[i]++; + } +} + +int +main () +{ + int i; + check_vect (); + r[0] = 0; + foo (1.5f); +#pragma GCC novector + for (i = 0; i < 1024; i++) + if (p[i] != 1.0f + i * 1.5f || q[i] != 2.0f + i * 0.5f || r[i] != 1) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr58508.c b/SingleSource/Regression/C/gcc-dg/vect/pr58508.c new file mode 100644 index 0000000000..c18b1cf23e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr58508.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + + +/* The GCC vectorizer generates loop versioning for the following loop + since there may exist aliasing between A and B. The predicate checks + if A may alias with B across all iterations. Then for the loop in + the true body, we can assert that *B is a loop invariant so that + we can hoist the load of *B before the loop body. */ + +void test1 (int* a, int* b) +{ + int i; + for (i = 0; i < 100000; ++i) + a[i] = *b + 1; +} + +/* A test case with nested loops. The load of b[j+1] in the inner + loop should be hoisted. */ + +void test2 (int* a, int* b) +{ + int i, j; + for (j = 0; j < 100000; ++j) + for (i = 0; i < 100000; ++i) + a[i] = b[j+1] + 1; +} + +/* A test case with ifcvt transformation. */ + +void test3 (int* a, int* b) +{ + int i, t; + for (i = 0; i < 10000; ++i) + { + if (*b > 0) + t = *b * 2; + else + t = *b / 2; + a[i] = t; + } +} + +/* A test case in which the store in the loop can be moved outside + in the versioned loop with alias checks. Note this loop won't + be vectorized. */ + +void test4 (int* a, int* b) +{ + int i; + for (i = 0; i < 100000; ++i) + *a += b[i]; +} + +/* A test case in which the load and store in the loop to b + can be moved outside in the versioned loop with alias checks. + Note this loop won't be vectorized. */ + +void test5 (int* a, int* b) +{ + int i; + for (i = 0; i < 100000; ++i) + { + *b += a[i]; + a[i] = *b; + } +} + +/* { dg-final { scan-tree-dump-times "hoist" 8 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "hoist" 3 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr59354.c b/SingleSource/Regression/C/gcc-dg/vect/pr59354.c new file mode 100644 index 0000000000..d479d00cee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr59354.c @@ -0,0 +1,39 @@ +/* { dg-additional-options "-O3" } */ + +#include "tree-vect.h" + +void abort (void); + +unsigned int a[256]; +unsigned char b[256]; + +__attribute__ ((noinline)) void +main1() +{ + int i, z, x, y; + + for(i = 0; i < 256; i++) + { + a[i] = i % 5; + __asm__ volatile (""); + } + + for (z = 0; z < 16; z++) + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + b[y*64 + z*4 + x] = a[z*16 + y*4 + x]; + + if (b[4] != 1) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loop" "vect" { target { vect_pack_trunc } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr59519-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr59519-1.c new file mode 100644 index 0000000000..48cc790eca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr59519-1.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/59519 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +int a, b, c, d; + +void +foo (void) +{ + for (; d; d++) + for (b = 0; b < 14; b++) + { + c |= 1; + if (a) + break; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr59519-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr59519-2.c new file mode 100644 index 0000000000..13db9616bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr59519-2.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/59519 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +struct S { int f0; } d; +int a[8] = { 0 }, b, c, e; + +void +foo (void) +{ + for (; e < 1; e++) + for (b = 0; b < 7; b++) + { + c |= (a[b + 1] != 0); + if (d.f0) + break; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr59591-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr59591-1.c new file mode 100644 index 0000000000..e768fb3e1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr59591-1.c @@ -0,0 +1,54 @@ +/* PR tree-optimization/59591 */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#ifndef CHECK_H +#include "tree-vect.h" +#endif + +extern void abort (void); + +int p[256], q[256], r[256], t[256]; + +__attribute__((noinline, noclone)) void +foo (void) +{ + int i; + #pragma omp simd safelen(64) + for (i = 0; i < 256; i++) + if (r[i] > 32) + t[i] = p[q[i] * 3L + 2L]; +} + +__attribute__((noinline, noclone)) void +bar (void) +{ + int i; + for (i = 0; i < 256; i++) + { + r[i] = ((i >> 2) & (1 << (i & 3))) ? 32 + i : 32 - i; + q[i] = r[i] > 32 ? ((i * 7) % 84) : 99 + i; + p[i] = i * 11; + t[i] = i * 13; + } + foo (); +#pragma GCC novector + for (i = 0; i < 256; i++) + if ((i >> 2) & (1 << (i & 3))) + { + if (t[i] != (((i * 7) % 84) * 3 + 2) * 11) + abort (); + } + else if (t[i] != i * 13) + abort (); +} + +#ifndef CHECK_H +int +main () +{ + check_vect (); + bar (); + return 0; +} +#endif + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr59591-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr59591-2.c new file mode 100644 index 0000000000..3bdf4252cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr59591-2.c @@ -0,0 +1,55 @@ +/* PR tree-optimization/59591 */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#ifndef CHECK_H +#include "tree-vect.h" +#endif + +extern void abort (void); + +long long int p[256], r[256], t[256]; +int q[256]; + +__attribute__((noinline, noclone)) void +foo (void) +{ + int i; + #pragma omp simd safelen(64) + for (i = 0; i < 256; i++) + if (r[i] > 32LL) + t[i] = p[q[i]]; +} + +__attribute__((noinline, noclone)) void +bar (void) +{ + int i; + for (i = 0; i < 256; i++) + { + r[i] = ((i >> 2) & (1 << (i & 3))) ? 32 + i : 32 - i; + q[i] = r[i] > 32 ? ((i * 7) % 256) : 258 + i; + p[i] = i * 11; + t[i] = i * 13; + } + foo (); +#pragma GCC novector + for (i = 0; i < 256; i++) + if ((i >> 2) & (1 << (i & 3))) + { + if (t[i] != ((i * 7) % 256) * 11) + abort (); + } + else if (t[i] != i * 13) + abort (); +} + +#ifndef CHECK_H +int +main () +{ + check_vect (); + bar (); + return 0; +} +#endif + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr59594.c b/SingleSource/Regression/C/gcc-dg/vect/pr59594.c new file mode 100644 index 0000000000..e3ece8abf7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr59594.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/59594 */ + +#include "tree-vect.h" + +#define N 1024 +int b[N + 2]; + +int +main () +{ + int i; + check_vect (); + for (i = 0; i < N + 1; i++) + { + b[i] = i; + asm (""); + } + for (i = N; i >= 0; i--) + { + b[i + 1] = b[i]; + b[i] = 1; + } + if (b[0] != 1) + __builtin_abort (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (b[i + 1] != i) + __builtin_abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr59651.c b/SingleSource/Regression/C/gcc-dg/vect/pr59651.c new file mode 100644 index 0000000000..44efce3339 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr59651.c @@ -0,0 +1,3 @@ +/* PR tree-optimization/59561 */ +#include "../torture/pr59651.c" + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr59984.c b/SingleSource/Regression/C/gcc-dg/vect/pr59984.c new file mode 100644 index 0000000000..c00c226715 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr59984.c @@ -0,0 +1,66 @@ +/* PR c/59984 */ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#include "tree-vect.h" + +#define N 128 + +int a[N]; + +#pragma omp declare simd +__attribute__((noinline)) void +foo (int in, int *out1, int *out2) +{ + *out1 = in * in - 1; + *out2 = in * in + 1; +} + +#pragma omp declare simd linear (out1, out2) +__attribute__((noinline)) void +bar (int in, int *out1, int *out2) +{ + *out1 = in * in - 1; + *out2 = in * in + 1; +} + +__attribute__((noinline)) void +test (void) +{ + int i; + for (i = 0; i < N; i++) + a[i] = i; +#pragma omp simd + for (i = 0; i < N; i++) + { + int v1, v2; + foo (a[i], &v1, &v2); + a[i] = v1 * v2; + } +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * i * i * i - 1) + __builtin_abort (); + for (i = 0; i < N; i++) + a[i] = i; +#pragma omp simd + for (i = 0; i < N; i++) + { + int v1, v2; + bar (a[i], &v1, &v2); + a[i] = v1 * v2; + } +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * i * i * i - 1) + __builtin_abort (); +} + +int +main () +{ + check_vect (); + test (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60012.c b/SingleSource/Regression/C/gcc-dg/vect/pr60012.c new file mode 100644 index 0000000000..cb0eb6be16 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60012.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-version-for-alias-checks=0" } */ + +typedef struct +{ + short real; + short imag; +} complex16_t; + +void +libvector_AccSquareNorm_ref (unsigned int *acc, + const complex16_t *x, unsigned len) +{ + unsigned i; + for (i = 0; i < len; i++) + acc[i] += ((unsigned int)((int)x[i].real * x[i].real)) + + ((unsigned int)((int)x[i].imag * x[i].imag)); +} + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { vect_extract_even_odd } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60092-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr60092-2.c new file mode 100644 index 0000000000..7b77c20cfb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60092-2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int posix_memalign(void **memptr, __SIZE_TYPE__ alignment, __SIZE_TYPE__ size); +void bar (int *); + +int *foo (int n) +{ + int *p; + int *q; + void *tem; + if (posix_memalign (&tem, 256, n * sizeof (int)) != 0) + return (void *)0; + p = (int *)tem; + if (posix_memalign (&tem, 256, n * sizeof (int)) != 0) + return (void *)0; + q = (int *)tem; + bar (q); + int i; + for (i = 0; i < n; ++i) + p[i] = q[i] + q[i]; + return p; +} + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Peeling for alignment will be applied" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Vectorizing an unaligned access" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60092.c b/SingleSource/Regression/C/gcc-dg/vect/pr60092.c new file mode 100644 index 0000000000..1d9876d423 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60092.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void bar (int *); + +int *foo (int n) +{ + int *p = __builtin_aligned_alloc (256, n * sizeof (int)); + int *q = __builtin_aligned_alloc (256, n * sizeof (int)); + bar (q); + int i; + for (i = 0; i < n; ++i) + p[i] = q[i] + q[i]; + return p; +} + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Peeling for alignment will be applied" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Vectorizing an unaligned access" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60196-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr60196-1.c new file mode 100644 index 0000000000..07bca49fb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60196-1.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/63189 */ +/* { dg-additional-options "-fwrapv" } */ + +#include "tree-vect.h" + +__attribute__((noinline, noclone)) static int +bar (const short *a, int len) +{ + int x; + int x1 = 0; + + for (x = 0; x < len; x++) + x1 += x * a[x]; + return x1; +} + +__attribute__((noinline, noclone)) void +foo (void) +{ + short stuff[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1 }; + if (bar (stuff, 9) != 36) + abort (); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60196-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr60196-2.c new file mode 100644 index 0000000000..fef9cd1c92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60196-2.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/63189 */ + +#include "tree-vect.h" + +static const short a[8] = {1, 1, 1, 1, 1, 1, 1, 1 }; +static const unsigned char b[8] = {0, 0, 0, 0, 0, 0, 0, 0 }; + +__attribute__((noinline, noclone)) static int +bar (void) +{ + int sum = 0, i; + for (i = 0; i < 8; ++i) + sum += a[i] * b[i]; + return sum; +} + +__attribute__((noinline, noclone)) void +foo (void) +{ + if (bar () != 0) + abort (); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60276.c b/SingleSource/Regression/C/gcc-dg/vect/pr60276.c new file mode 100644 index 0000000000..824e2a336b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60276.c @@ -0,0 +1,54 @@ +#include "tree-vect.h" + +extern void abort (void); + +static void +foo (int *out, const int *lp, unsigned samples) +{ + int x, target; + for (x = 0, target = 0; x < (int)samples; x += 2, target++) + { + out[x] = lp[target]; + out[x - 1] = out[x - 2] + out[x]; + } +} + +static void +foo_novec (int *out, const int *lp, unsigned samples) +{ + int x, target; + for (x = 0, target = 0; x < (int)samples; x += 2, target++) + { + out[x] = lp[target]; + out[x - 1] = out[x - 2] + out[x]; + __asm__ volatile ("" : : : "memory"); + } +} + +int main(void) +{ + const int lp[25] = { + 0, 2, 4, 6, 8, + 10, 12, 14, 16, + 18, 20, 22, 24, + 26, 28, 30, 32, + 34, 36, 38, 40, + 42, 44, 46, 48, + }; + int out[49] = {0}; + int out2[49] = {0}; + int s; + + check_vect (); + + foo (out + 2, lp + 1, 48); + foo_novec (out2 + 2, lp + 1, 48); + +#pragma GCC novector + for (s = 0; s < 49; s++) + if (out[s] != out2[s]) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60382.c b/SingleSource/Regression/C/gcc-dg/vect/pr60382.c new file mode 100644 index 0000000000..e68229590a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60382.c @@ -0,0 +1,31 @@ +#include "tree-vect.h" + +int a, b, c, e, f; + +void +foo () +{ + for (b = 0; b < 3; b++) + if (e) + { + for (c = 0; c < 4; c++) + { + if (b) + continue; + f = 1; + for (a = 0; a < 2; a++) + f |= 1; + } + for (;;) + ; + } +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60482.c b/SingleSource/Regression/C/gcc-dg/vect/pr60482.c new file mode 100644 index 0000000000..4c5c20c810 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60482.c @@ -0,0 +1,19 @@ +/* PR middle-end/60482 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-require-effective-target vect_int } */ + +double +foo (double *x, int n) +{ + double p = 0.0; + int i; + x = __builtin_assume_aligned (x, 128); + if (n % 128) + __builtin_unreachable (); + for (i = 0; i < n; i++) + p += x[i]; + return p; +} + +/* { dg-final { scan-tree-dump-not "epilog loop required" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60505.c b/SingleSource/Regression/C/gcc-dg/vect/pr60505.c new file mode 100644 index 0000000000..839b4d2c37 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60505.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wall -Werror" } */ + +void foo(char *in, char *out, int num) +{ + int i; + char ovec[16] = {0}; + + for(i = 0; i < num ; ++i) + out[i] = (ovec[i] = in[i]); + out[num] = ovec[num/2]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60656.c b/SingleSource/Regression/C/gcc-dg/vect/pr60656.c new file mode 100644 index 0000000000..70ec0f68dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60656.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_long } */ + +#include "tree-vect.h" + +__attribute__ ((noinline)) long +foo () +{ + int v[] = {5000, 5001, 5002, 5003}; + long s = 0; + int i; + + for(i = 0; i < 4; ++i) + { + long P = v[i]; + s += P * P * P; + } + return s; +} + +long +bar () +{ + int v[] = {5000, 5001, 5002, 5003}; + long s = 0; + int i; + + for(i = 0; i < 4; ++i) + { + long P = v[i]; + s += P * P * P; + __asm__ volatile (""); + } + return s; +} + +int main() +{ + check_vect (); + + if (foo () != bar ()) + abort (); + return 0; +} + +/* P * P * P requires a widening multiplication first as well as a longxlong->long after that. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_mult_si_to_di_pattern && vect_long_mult } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr60841.c b/SingleSource/Regression/C/gcc-dg/vect/pr60841.c new file mode 100644 index 0000000000..fd5d2e5504 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr60841.c @@ -0,0 +1,182 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ffast-math" } */ + +/* This testcase shouldn't consume much memory or produce a 1GB vectorizer + dump file due to SLP tree explosion. */ + +struct S { int f1, f2, f3, f4; } a; +struct T { short f3, f2, f1, f4; }; +int b, c, d, e, f, g; +unsigned long z; + +void +foo (struct T *p, struct T *q, int x, int w) +{ + for (; x; x++) + { + struct S h; + int i; + struct T j; + struct T *r; + h = a; + g = 0; + r = p + 2 * (c + 4) + 1; + j = *r; + r = p; + f = r->f1 - 1; + b = +1.0 + f * f; + i = (r->f2 + j.f2) / 2; + f = r->f3 - 1; + b += 1.0 - i * f * f; + f = r->f4 - 1; + if (b) + b += -1.0 - i * f; + if (b / w) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g = 1; + } + r++; + f = r->f1; + i = (r->f2 + j.f2) / 2; + f = r->f3 - 1; + b += 1.0 - i * f * f; + i = (r->f4); + if (b * 65535UL / w) + { + h.f1 += 10.0 * r->f1; + h.f2 += 10.0 * r->f2; + h.f3 += 10.0 * r->f3; + h.f4 += 10.0 * r->f4; + g += 10.0; + } + r++; + f = r->f1; + z = 5UL * i; + f = r->f2; + i = (r->f3 + j.f3) / 2; + b = -i * f * f; + i = (r->f4 + j.f4) / 2; + if (b * 65535UL / 25.0f) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g += 8.0; + } + r++; + f = r->f1 - j.f1; + b = 1 * 2.0 * i * f * f; + f = r->f2; + b += 4.0 * f; + i = r->f3 / 2; + f = r->f4 - 1; + if (b * 1) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g += 8.0; + } + b = 4.0 * 1 * f; + if (b * 65535UL / 25.0f) + { + h.f1 += 20.0 * r->f1; + h.f2 += 20.0 * r->f2; + h.f3 += 20.0 * r->f3; + h.f4 += 20.0 * r->f4; + g += 20.0; + } + b = 5 * (0.0 - i); + if (b < 0) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g += 8.0; + } + r = p + 2 * (c + 4); + i = (r->f1 + j.f1); + b = 1 * 2.0 * i * 1; + f = r->f2 - 1; + i = (r->f3 + j.f3) / 2; + b = 5 * (0.0 - i) * f * f; + i = (r->f4 + j.f4) / 2; + if (b * 65535UL / 25.0f) + { + h.f1 += 10.0 * r->f1; + h.f2 += 10.0 * r->f2; + h.f3 += 10.0 * r->f3; + h.f4 += 10.0 * r->f4; + g += 10.0; + } + r++; + f = r->f1; + b = 5UL * i * f; + i = (r->f2 + j.f2) / 2; + f = r->f3 - 1; + b = 5 * (0.0 - i) * f * f; + f = r->f4 - 1; + if (b * 65535UL / 25.0f) + { + h.f1 += 40.0 * r->f1; + h.f2 += 40.0 * r->f2; + h.f3 += 40.0 * r->f3; + h.f4 += 40.0 * r->f4; + g += 40.0; + } + r++; + i = (r->f1 + j.f1); + b = 5 * i * f; + f = r->f2; + b = 4.0 * f * f; + f = r->f3; + i = (r->f4 + j.f4) / 2; + b = 5 * (0.0 - i) * f * f; + if (b * 25.0f) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g += 8.0; + } + r = p + 4 * (c + 4); + i = r->f1 / 2; + b = 5 * (1.0 + i); + i = r->f2 + j.f2; + f = r->f3 - 1; + b = 5 * (0.0 - i) * f * f; + i = (r->f4 + j.f4) / 2; + if (b * 65535UL / 25.0f) + { + h.f1 += 5.0 * r->f1; + h.f2 += 5.0 * r->f2; + h.f3 += 5.0 * r->f3; + h.f4 += 5.0 * r->f4; + g += 5.0; + } + b = 5 * (1.0 + i); + if (b < 0) + { + h.f1 += 5.0 * r->f1; + h.f2 += 5.0 * r->f2; + h.f3 += 5.0 * r->f3; + h.f4 += 5.0 * r->f4; + g += 5.0; + } + q->f1 = (h.f1 + g / 2 - 1) / g; + q->f2 = (h.f2 + g / 2 - 1) / g; + q->f3 = (h.f3 + g / 2 - 1) / g; + q->f4 = (h.f4 + g / 2 - 1) / g; + p++; + q++; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr61194.c b/SingleSource/Regression/C/gcc-dg/vect/pr61194.c new file mode 100644 index 0000000000..8cd38b3d5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr61194.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_cond_mixed } */ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +static float x[1024]; +static float y[1024]; +static float z[1024]; +static float w[1024]; + +void __attribute__((noinline,noclone)) barX() +{ + int i; + for (i=0; i<1024; ++i) + z[i] = ((x[i]>0) & (w[i]<0)) ? z[i] : y[i]; +} + +int main() +{ + int i; + + check_vect (); + + for (i = 0; i < 1024; ++i) + { + x[i] = -10 + i; + w[i] = 100 - i; + z[i] = 0.; + y[i] = 1.; + __asm__ volatile ("" : : : "memory"); + } + + barX(); + +#pragma GCC novector + for (i = 0; i < 1024; ++i) + if (z[i] != ((x[i]>0 && w[i]<0) ? 0. : 1.)) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr61634.c b/SingleSource/Regression/C/gcc-dg/vect/pr61634.c new file mode 100644 index 0000000000..fa49cec760 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr61634.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +int a, b, c, d; +short *e; +void fn1 (int p1[], int p2, int p3[], int p4[], int p5[], int *p6) +{ + int f; + c = *p1; + d = *p5; + (void)p6; + for (; a; a--) + { + f = *e >> 2; + *e++ = f; + b += f * f; + f = *e >> 2; + *e++ = f; + } + p4[0] = p3[0]; + for (;; p2--) + ; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr61680.c b/SingleSource/Regression/C/gcc-dg/vect/pr61680.c new file mode 100644 index 0000000000..bb24014bdf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr61680.c @@ -0,0 +1,52 @@ + +#include "tree-vect.h" + +double v[4096][4]; + +__attribute__((noinline, noclone)) void +bar (double p[][4]) +{ + int i; + double d = 172.0; +#pragma GCC novector + for (i = 0; i < 4096; i++) + { + if (p[i][0] != 6.0 || p[i][1] != 6.0 || p[i][2] != 10.0) + __builtin_abort (); + if (__builtin_fabs (p[i][3] - d) > 0.25) + __builtin_abort (); + } +} + +__attribute__((noinline, noclone)) void +foo (void) +{ + int i; + double w[4096][4], t; + for (i = 0; i < 4096; i++) + { + w[i][0] = v[i][0] + 2.0; + w[i][1] = v[i][1] + 1.0; + w[i][2] = v[i][2] + 4.0; + w[i][3] = (w[i][0] * w[i][0] + w[i][1] * w[i][1] + w[i][2] * w[i][2]); + } + bar (w); +} + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < 4096; i++) + { + v[i][0] = 4.0; + v[i][1] = 5.0; + v[i][2] = 6.0; + } + foo (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr62021.c b/SingleSource/Regression/C/gcc-dg/vect/pr62021.c new file mode 100644 index 0000000000..460fadb3f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr62021.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#pragma omp declare simd linear(y) +__attribute__((noinline)) int * +foo (int *x, int y) +{ + return x + y; +} + +int a[1024]; +int *b[1024] = { &a[0] }; + +int +main () +{ + int i; + check_vect (); + for (i = 0; i < 1024; i++) + b[i] = &a[1023 - i]; + #pragma omp simd + for (i = 0; i < 1024; i++) + b[i] = foo (b[i], i); +#pragma GCC novector + for (i = 0; i < 1024; i++) + if (b[i] != &a[1023]) + __builtin_abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr62073.c b/SingleSource/Regression/C/gcc-dg/vect/pr62073.c new file mode 100644 index 0000000000..806e1a4ee9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr62073.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O1" } */ + +struct S0 +{ + int f7; +}; +struct S0 g_50; +int g_70; +int g_76; + +int foo (long long p_56, int * p_57) +{ + int *l_77; + int l_101; + + for (; g_70;) + { + int **l_78 = &l_77; + if (g_50.f7) + continue; + *l_78 = 0; + } + for (g_76 = 1; g_76 >= 0; g_76--) + { + int *l_90; + for (l_101 = 4; l_101 >= 0; l_101--) + if (l_101) + *l_90 = 0; + else + { + int **l_113 = &l_77; + *l_113 = p_57; + } + } + + return *l_77; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr62075.c b/SingleSource/Regression/C/gcc-dg/vect/pr62075.c new file mode 100644 index 0000000000..e42bff5971 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr62075.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +int a[16][2]; +struct A +{ + int b[16][2]; + int c[16][1]; +}; + +void +foo (struct A *x) +{ + int i; + for (i = 0; i < 16; ++i) + { + x->b[i][0] = a[i][0]; + x->c[i][0] = 0 != a[i][0]; + x->b[i][1] = a[i][1]; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr62171.c b/SingleSource/Regression/C/gcc-dg/vect/pr62171.c new file mode 100644 index 0000000000..dc96713d1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr62171.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +struct omp_data_i +{ + double *__restrict__ results; + double *__restrict__ pData; + double *__restrict__ coeff; +}; + +#define nEvents 1000000 + +double __attribute__((noinline, noclone)) +f (struct omp_data_i *__restrict__ p, int argc) +{ + + int idx; + + for (idx = 0; idx < nEvents; idx++) + ((p->results))[idx] = (*(p->coeff)) * ((p->pData))[idx]; + + return ((p->results))[argc]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "versioned" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr63148.c b/SingleSource/Regression/C/gcc-dg/vect/pr63148.c new file mode 100644 index 0000000000..c562fdd045 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr63148.c @@ -0,0 +1,91 @@ + +#include "tree-vect.h" + +/* Extracted from MultiSource/Benchmarks/TSVC/tsc.inc + From LLVM test-suite */ + +#define N 40 + +int dummy(double[N], double[N], double[N], double[N]); + +double array[256*256] __attribute__((aligned(32))); + +double x[N] __attribute__((aligned(32))); +double temp; +int temp_int; +struct GlobalData +{ + __attribute__((aligned(32))) double a[N]; + int pad1[3]; + __attribute__((aligned(32))) double b[N]; + int pad2[5]; + __attribute__((aligned(32))) double c[N]; + int pad3[7]; + __attribute__((aligned(32))) double d[N]; + int pad4[11]; +} global_data; + +__attribute__((aligned(32))) double * const a = global_data.a; +__attribute__((aligned(32))) double * const b = global_data.b; +__attribute__((aligned(32))) double * const c = global_data.c; +__attribute__((aligned(32))) double * const d = global_data.d; + +void init(void); +void check(double *_a, double *_b); +int s221(void) +{ + int i; + + init(); + for (i = 1; i < N; i++) + { + a[i] += c[i] * d[i]; + b[i] = b[i - 1] + a[i] + d[i]; + } + check(a, b); + return 0; +} + +int set1d(double arr[N], double value) +{ + int i; + + for (i = 0; i < N; i++) { + arr[i] = value; + } + return 0; +} + +void init(void) +{ + set1d(a, 1); + set1d(b, 2); + set1d(c, 3); + set1d(d, 4); +} + +void abort(void); + +void check(double *_a, double *_b) +{ + int i; + + double suma = 0; + double sumb = 0; + for (i = 0; i < N; i++){ + suma += _a[i]; + sumb += _b[i]; + } + if (suma != 508) + abort(); + if (sumb != 13340.00) + abort(); +} + +int main(int argc, char *argv[]) +{ + check_vect (); + s221(); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr63189.c b/SingleSource/Regression/C/gcc-dg/vect/pr63189.c new file mode 100644 index 0000000000..dc8904730d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr63189.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/63189 */ + +#include "tree-vect.h" + +short int d[16] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; + +__attribute__((noinline, noclone)) void +foo (void) +{ + int j, s = 0; + for (j = 0; j < 8; j++) + s += d[j] * j; + if (s != 7) + abort (); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr63341-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr63341-1.c new file mode 100644 index 0000000000..bb54e6a1b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr63341-1.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/63341 */ + +#include "tree-vect.h" + +typedef union U { unsigned short s; unsigned char c; } __attribute__((packed)) U; +struct S { char e __attribute__((aligned (64))); U s[32]; }; +struct S t = {0, {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, + {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, + {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, + {25}, {26}, {27}, {28}, {29}, {30}, {31}, {32}}}; +unsigned short d[32] = { 1 }; + +__attribute__((noinline, noclone)) void +foo () +{ + int i; + for (i = 0; i < 32; i++) + d[i] = t.s[i].s; + if (__builtin_memcmp (d, t.s, sizeof d)) + abort (); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr63341-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr63341-2.c new file mode 100644 index 0000000000..aa338263a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr63341-2.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/63341 */ + +#include "tree-vect.h" + +typedef union U { unsigned short s; unsigned char c; } __attribute__((packed)) U; +struct S { char e __attribute__((aligned (64))); U s[32]; }; +struct S t = {0, {{0x5010}, {0x5111}, {0x5212}, {0x5313}, {0x5414}, {0x5515}, {0x5616}, {0x5717}, + {0x5818}, {0x5919}, {0x5a1a}, {0x5b1b}, {0x5c1c}, {0x5d1d}, {0x5e1e}, {0x5f1f}, + {0x6020}, {0x6121}, {0x6222}, {0x6323}, {0x6424}, {0x6525}, {0x6626}, {0x6727}, + {0x6828}, {0x6929}, {0x6a2a}, {0x6b2b}, {0x6c2c}, {0x6d2d}, {0x6e2e}, {0x6f2f}}}; +unsigned short d[32] = { 1 }; + +__attribute__((noinline, noclone)) void +foo () +{ + int i; + for (i = 0; i < 32; i++) + d[i] = t.s[i].s + 4; +#pragma GCC novector + for (i = 0; i < 32; i++) + if (d[i] != t.s[i].s + 4) + abort (); + else + asm volatile ("" : : : "memory"); +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr63379.c b/SingleSource/Regression/C/gcc-dg/vect/pr63379.c new file mode 100644 index 0000000000..2c739a7c83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr63379.c @@ -0,0 +1,41 @@ +/* PR tree-optimization/63379 */ + +#include "tree-vect.h" + +extern void abort (void); + +typedef struct { + int x; + int y; +} Point; + +Point pt_array[25]; + +void __attribute__((noinline,noclone)) +generate_array(void) +{ + unsigned int i; + for (i = 0; i<25; i++) + { + pt_array[i].x = i; + pt_array[i].y = 1000+i; + } +} + +int main() +{ + check_vect (); + generate_array (); + Point min_pt = pt_array[0]; + Point *ptr, *ptr_end; + for (ptr = pt_array+1, ptr_end = pt_array+25; ptr != ptr_end; ++ptr) + { + min_pt.x = (min_pt.x < ptr->x) ? min_pt.x : ptr->x; + min_pt.y = (min_pt.y < ptr->y) ? min_pt.y : ptr->y; + } + + if (min_pt.x != 0 || min_pt.y != 1000) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr63530.c b/SingleSource/Regression/C/gcc-dg/vect/pr63530.c new file mode 100644 index 0000000000..2def834ff8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr63530.c @@ -0,0 +1,33 @@ +/* { dg-additional-options "-funroll-loops --param \"max-completely-peeled-insns=400\"" } */ + +/* PR tree-optimization/63530 */ +/* On armv7 hardware, following options cause run time failure */ +/* -march=armv7-a -mfloat-abi=hard -mfpu=neon -marm -O2 -ftree-vectorize */ +/* -funroll-loops --param "max-completely-peeled-insns=400" */ + +#include "tree-vect.h" + +#include + +typedef struct { + unsigned char map[256]; + int i; +} A, *AP; + +AP __attribute__ ((noinline)) +foo (int n) +{ + AP b = (AP)calloc (1, sizeof (A)); + int i; + for (i = n; i < 256; i++) + b->map[i] = i; + return b; +} + +int +main() +{ + AP p = foo(3); + check_vect (); + return p->map[30] - p->map[20] - p->map[10]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr63605.c b/SingleSource/Regression/C/gcc-dg/vect/pr63605.c new file mode 100644 index 0000000000..8d76d21cc8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr63605.c @@ -0,0 +1,21 @@ +#include "tree-vect.h" + +extern void abort (void); + +int a, b[8] = { 2, 0, 0, 0, 0, 0, 0, 0 }, c[8]; + +int +main () +{ + int d; + check_vect (); + for (; a < 8; a++) + { + d = b[a] >> 1; + c[a] = d != 0; + } + if (c[0] != 1) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr64252.c b/SingleSource/Regression/C/gcc-dg/vect/pr64252.c new file mode 100644 index 0000000000..89070c27ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr64252.c @@ -0,0 +1,65 @@ +/* PR target/64252 */ +/* Test correctness of size 3 store groups permutation. */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#define N 50 + +enum num3 +{ + a, b, c +}; + +struct flags +{ + enum num3 f; + unsigned int c; + unsigned int p; +}; + +struct flagsN +{ + struct flags a[N]; +}; + +void +bar (int n, struct flagsN *ff) +{ + struct flagsN *fc; + for (fc = ff + 1; fc < (ff + n); fc++) + { + int i; + for (i = 0; i < N; ++i) + { + ff->a[i].f = 0; + ff->a[i].c = i; + ff->a[i].p = -1; + } + for (i = 0; i < n; i++) + { + int j; + for (j = 0; j < N - n; ++j) + { + fc->a[i + j].f = 0; + fc->a[i + j].c = j + i; + fc->a[i + j].p = -1; + } + } + } +} + +struct flagsN q[2]; + +int main() +{ + int i; + check_vect (); + bar(2, q); +#pragma GCC novector + for (i = 0; i < N; i++) + if (q[0].a[i].f != 0 || q[0].a[i].c != i || q[0].a[i].p != -1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr64404.c b/SingleSource/Regression/C/gcc-dg/vect/pr64404.c new file mode 100644 index 0000000000..6fecf9ecae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr64404.c @@ -0,0 +1,58 @@ +/* { dg-additional-options "--param=sccvn-max-alias-queries-per-access=1" } */ + +#include "tree-vect.h" + +extern void abort (void); + +typedef struct +{ + int l, h; +} tFPinterval; + +tFPinterval X[1024]; +tFPinterval Y[1024]; +tFPinterval Z[1024]; + +void __attribute__((noinline)) +Compute (void) +{ + int d; + for (d = 0; d < 1024; d++) + { + Y[d].l = X[d].l + X[d].h; + Y[d].h = Y[d].l; + Z[d].l = X[d].l; + Z[d].h = X[d].h; + } +} + +int +main (void) +{ + int d; + + check_vect (); + + for (d = 0; d < 1024; d++) + { + X[d].l = d; + X[d].h = d + 1; + __asm__ volatile (""); + } + + Compute (); + +#pragma GCC novector + for (d = 0; d < 1024; d++) + { + if (Y[d].l != X[d].l + X[d].h + || Y[d].h != Y[d].l + || Z[d].l != X[d].l + || Z[d].h != X[d].h) + abort (); + __asm__ volatile (""); + } + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr64421.c b/SingleSource/Regression/C/gcc-dg/vect/pr64421.c new file mode 100644 index 0000000000..47afd22d93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr64421.c @@ -0,0 +1,36 @@ +/* PR middle-end/64421 */ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#pragma omp declare simd linear (y) notinbranch +int foo (int x, int y) __asm ("bar"); + +#pragma omp declare simd linear (y) notinbranch +int +foo (int x, int y) +{ + return x + y; +} + +int a[1024] = { 1, 2 }; + +int +main () +{ + int i; + check_vect (); + #pragma omp simd + for (i = 0; i < 1024; i++) + a[i] = foo (a[i], i); + if (a[0] != 1 || a[1] != 3) + abort (); +#pragma GCC novector + for (i = 2; i < 1024; i++) + if (a[i] != i) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr64493.c b/SingleSource/Regression/C/gcc-dg/vect/pr64493.c new file mode 100644 index 0000000000..d3faf84bcc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr64493.c @@ -0,0 +1,29 @@ +#include "tree-vect.h" + +int a, b, c, d, e, f, g, h; + +int +main () +{ + check_vect (); + + for (; a; a--) + for (d = 1; d <= 0; d++) +#pragma GCC novector + for (; d;) + if (h) + { + if (!g) __builtin_abort (); + if (!0) __builtin_abort (); + } + + for (f = 4; f; f--) + { + for (b = 0; b < 2; b++) + c |= 1; + e |= c; + } + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr64495.c b/SingleSource/Regression/C/gcc-dg/vect/pr64495.c new file mode 100644 index 0000000000..c48f9389aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr64495.c @@ -0,0 +1,33 @@ +#include +#include "tree-vect.h" + +int a, b, c, d, e, f, g, i, j; +static int *h = &e; + +int +main () +{ + check_vect (); + + for (; a;) + for (; g; g++) +#pragma GCC novector + for (; f; f++) + if (j) + { + assert(b); + assert(0); + } + for (i = 24; i; i--) + { + for (c = 0; c < 6; c++) + d |= 1; + *h |= d; + } + + if (e != 1) + __builtin_abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr64829.c b/SingleSource/Regression/C/gcc-dg/vect/pr64829.c new file mode 100644 index 0000000000..6a9f3d785f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr64829.c @@ -0,0 +1,65 @@ +/* { dg-do compile } */ + +typedef unsigned char Uint8; +typedef int Sint32; +typedef unsigned int Uint32; + +typedef union RMColorDataRef +{ + Uint8* data8; +} RMColorDataRef; + +typedef struct RMColorData +{ + Uint32 dataCount; + RMColorDataRef dataRef; +} RMColorData; + +typedef struct RMColorTable +{ + Uint8 dataCompsOut; + RMColorDataRef dataRef; +} RMColorTable; + +int fail ( const RMColorData * pInColor, + RMColorData * pOutColor, + const RMColorTable * pColorTable ) +{ + Uint32 comp; + Uint8 nCompOut; + + Sint32 result; + + Uint32 interpFrac1, interpFrac2, interpFrac3; + Sint32 val0, val1, val2, val3; + + Uint8 * pOut; + + const Uint8 * pClutData; + const Uint8 * pCornerPoint0; + + Uint8 lastOut[((8) > (4) ? (8) : (4))]; + + pOut = pOutColor->dataRef.data8; + pClutData = pColorTable->dataRef.data8; + + nCompOut = pColorTable->dataCompsOut; + + pCornerPoint0 = pClutData; + + for (comp = 0; comp < nCompOut; comp++) + { + val0 = *pCornerPoint0++; + + result = val0 << 4; + + result += (val1 - val0) * interpFrac1; + result += (val2 - val1) * interpFrac2; + result += (val3 - val2) * interpFrac3; + + *pOut++ = lastOut[comp] = (Uint8)(result >> 4); + } + + return (0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr64844.c b/SingleSource/Regression/C/gcc-dg/vect/pr64844.c new file mode 100644 index 0000000000..cd3eacd99a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr64844.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "-ffast-math" } */ + +#include "tree-vect.h" + +extern void abort (void); + +typedef __SIZE_TYPE__ size_t; + +static double +compute(size_t n, double const * __restrict a, double const * __restrict b) +{ + double res = 0.0; + size_t i; + for (i = 0; i < n; ++i) + res += a[i] + b[i]; + return res; +} + +void init(double *, double *); + +int +main() +{ + double ary1[1024]; + double ary2[1024]; + size_t i; + + check_vect (); + + // Initialize arrays + for (i = 0; i < 1024; ++i) + { + ary1[i] = 1 / (double)(i + 1); + ary2[i] = 1 + 1 / (double) (i + 1); + __asm__ volatile ("" : : : "memory"); + } + + // Compute two results using different starting elements + if ((int) compute (512, &ary1[0], &ary2[0]) != 525 + || (int) compute(512, &ary1[1], &ary2[1]) != 523) + abort (); + + return 0; +} + +/* All targets should allow vectorizing this by some means of + dealing with the known misalignment in loop 2. */ + +/* { dg-final { scan-tree-dump-times "loop vectorized" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65206.c b/SingleSource/Regression/C/gcc-dg/vect/pr65206.c new file mode 100644 index 0000000000..3b6262622c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65206.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "-fno-trapping-math -fno-allow-store-data-races" } */ +/* { dg-additional-options "-mavx" { target avx } } */ + +#define N 1024 + +double a[N], b[N]; + +void foo () +{ + for (int i = 0; i < N; ++i) + if (b[i] < 3.) + a[i] += b[i]; +} + +/* We get a .MASK_STORE because while the load of a[i] does not trap + the store would introduce store data races. Make sure we still + can handle the data dependence with zero distance. */ + +/* { dg-final { scan-tree-dump-not "versioning for alias required" "vect" { target { vect_masked_store || avx } } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { vect_masked_store || avx } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65310.c b/SingleSource/Regression/C/gcc-dg/vect/pr65310.c new file mode 100644 index 0000000000..57e90d45c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65310.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ + +struct a +{ + int a[100]; +}; +typedef struct a b __attribute__ ((aligned (32))); +typedef struct a c __attribute__ ((aligned (4))); + +int t(b *a) +{ + int i; + c *ptr = a; + for (i=0;i<100;i++) + ptr->a[i]++; +} + +/* The memory access is through a pointer of type c which means + *ptr is not aligned. */ + +/* { dg-final { scan-tree-dump "can't force alignment" "vect" { xfail vect_element_align_preferred } } } */ +/* { dg-final { scan-tree-dump-not "misalign = 0" "vect" { xfail vect_element_align_preferred } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65494.c b/SingleSource/Regression/C/gcc-dg/vect/pr65494.c new file mode 100644 index 0000000000..fe51e716b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65494.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast -funroll-loops" } */ + +typedef unsigned char uchar; +typedef struct rgb_ {uchar r; uchar g; uchar b;} rgb; +#define N 512 +rgb in[N], out[N]; +float c[N]; +void foo(int n) +{ + int i, j; + for (i = 0; i < n; i++) //in and out are RGB byte arrays + { + float r = 0, g = 0, b = 0; + for (j = 0; j < 5; j++) + { + r += (float)in[i + j].r * c[j]; + g += (float)in[i + j].g * c[j]; + b += (float)in[i + j].b * c[j]; + } + out[i].r = (uchar)r; + out[i].g = (uchar)g; + out[i].b = (uchar)b; + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { vect_float && vect_intfloat_cvt } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65518.c b/SingleSource/Regression/C/gcc-dg/vect/pr65518.c new file mode 100644 index 0000000000..189a65534f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65518.c @@ -0,0 +1,54 @@ +#include "tree-vect.h" + +#if VECTOR_BITS > 256 +#define NINTS (VECTOR_BITS / 32) +#else +#define NINTS 8 +#endif + +#define N (NINTS * 2) +#define RESULT (NINTS * (NINTS - 1) / 2 * N + NINTS) + +extern void abort (void); + +typedef struct giga +{ + unsigned int g[N]; +} giga; + +unsigned long __attribute__((noinline,noclone)) +addfst(giga const *gptr, int num) +{ + unsigned int retval = 0; + int i; + for (i = 0; i < num; i++) + retval += gptr[i].g[0]; + return retval; +} + +int main () +{ + struct giga g[NINTS]; + unsigned int n = 1; + int i, j; + check_vect (); + for (i = 0; i < NINTS; ++i) + for (j = 0; j < N; ++j) + { + g[i].g[j] = n++; + __asm__ volatile (""); + } + if (addfst (g, NINTS) != RESULT) + abort (); + return 0; +} + +/* We don't want to vectorize the single-element interleaving in the way + we currently do that (without ignoring not needed vectors in the + gap between gptr[0].g[0] and gptr[1].g[0]), because that's very + sub-optimal and causes memory explosion (even though the cost model + should reject that in the end). */ + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops in function" 2 "vect" { target {! riscv*-*-* } } } } */ +/* We end up using gathers for the strided load on RISC-V which would be OK. */ +/* { dg-final { scan-tree-dump "using gather/scatter for strided/grouped access" "vect" { target { riscv*-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65930-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr65930-1.c new file mode 100644 index 0000000000..895fbf8869 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65930-1.c @@ -0,0 +1,26 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +unsigned __attribute__((noipa)) +bar (unsigned int *x) +{ + int sum = 4; + x = __builtin_assume_aligned (x, __BIGGEST_ALIGNMENT__); + for (int i = 0; i < 16; ++i) + sum += x[i]; + return sum; +} + +int +main() +{ + static int a[16] __attribute__((aligned(__BIGGEST_ALIGNMENT__))) + = { 1, 3, 5, 8, 9, 10, 17, 18, 23, 29, 30, 55, 42, 2, 3, 1 }; + check_vect (); + if (bar (a) != 260) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65930-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr65930-2.c new file mode 100644 index 0000000000..9cfb9b102d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65930-2.c @@ -0,0 +1,28 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int __attribute__((noipa)) +bar (unsigned int *x, int n) +{ + int sum = 4; + x = __builtin_assume_aligned (x, __BIGGEST_ALIGNMENT__); + for (int i = 0; i < n; ++i) + sum += x[i*4+0]+ x[i*4 + 1] + x[i*4 + 2] + x[i*4 + 3]; + return sum; +} + +int +main () +{ + static int a[16] __attribute__((aligned(__BIGGEST_ALIGNMENT__))) + = { 1, 3, 5, 8, 9, 10, 17, 18, 23, 29, 30, 55, 42, 2, 3, 1 }; + check_vect (); + if (bar (a, 4) != 260) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-1.c new file mode 100644 index 0000000000..9fc74a1ab2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-1.c @@ -0,0 +1,47 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 32 + +/* Simple condition reduction. */ + +int +condition_reduction (int *a, int min_v) +{ + int last = 66; /* High start value. */ + + for (int i = 0; i < N; i++) + if (a[i] < min_v) + last = i; + + return last; +} + +int +main (void) +{ + int a[N] = { + 11, -12, 13, 14, 15, 16, 17, 18, 19, 20, + 1, 2, -3, 4, 5, 6, 7, -8, 9, 10, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32 + }; + + check_vect (); + + int ret = condition_reduction (a, 1); + + if (ret != 17) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 2 "vect" { target { ! vect_fold_extract_last } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-10.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-10.c new file mode 100644 index 0000000000..e4a1d9419c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-10.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 32 + +/* Non-integer data types. */ + +float +condition_reduction (float *a, float min_v) +{ + float last = 0; + + for (int i = 0; i < N; i++) + if (a[i] < min_v) + last = a[i]; + + return last; +} + +int +main (void) +{ + float a[N] = { + 11.5, 12.2, 13.22, 14.1, 15.2, 16.3, 17, 18.7, 19, 20, + 1, 2, 3.3, 4.3333, 5.5, 6.23, 7, 8.63, 9, 10.6, + 21, 22.12, 23.55, 24.76, 25, 26, 27.34, 28.765, 29, 30, + 31.111, 32.322 + }; + + check_vect (); + + float ret = condition_reduction (a, 16.7); + + if (ret != (float)10.6) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-11.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-11.c new file mode 100644 index 0000000000..1c54979ede --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-11.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 37 + +/* Re-use the result of the condition inside the loop. Will fail to + vectorize. */ + +unsigned int +condition_reduction (unsigned int *a, unsigned int min_v, unsigned int *b) +{ + unsigned int last = N + 65; + + for (unsigned int i = 0; i < N; i++) + { + if (b[i] < min_v) + last = i; + a[i] = last; + } + return last; +} + +int +main (void) +{ + unsigned int a[N] = { + 31, 32, 33, 34, 35, 36, 37, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 + }; + unsigned int b[N] = { + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 31, 32, 33, 34, 35, 36, 37 + }; + + check_vect (); + + unsigned int ret = condition_reduction (a, 16, b); + + if (ret != 29) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-12.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-12.c new file mode 100644 index 0000000000..9788eea0f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-12.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 32 + +/* Simple condition reduction where the result is a negative of the induction. + Will fail to vectorize to a simple case. */ + +signed int +condition_reduction (signed int *a, signed int min_v) +{ + signed int last = -1; + + for (signed int i = 0; i < N; i++) + if (a[i] < min_v) + last = -i; + + return last; +} + +int +main (void) +{ + signed int a[N] = { + 11, -12, 13, 14, 15, 16, 17, 18, 19, 20, + 1, 2, -3, 4, 5, 6, 7, -8, 9, 10, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32 + }; + + check_vect (); + + signed int ret = condition_reduction (a, 16); + + if (ret != -19) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target { vect_fold_extract_last && { ! vect_multiple_sizes } } } } } */ +/* { dg-final { scan-tree-dump "optimizing condition reduction with FOLD_EXTRACT_LAST" "vect" { target { vect_fold_extract_last && vect_multiple_sizes } } } } */ +/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-13.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-13.c new file mode 100644 index 0000000000..079b5f91ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-13.c @@ -0,0 +1,48 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 32 + +/* Simple condition reduction with a reversed loop. */ + +int +condition_reduction (int *a, int min_v) +{ + int last = -1; + + for (int i = N-1; i >=0; i--) + if (a[i] < min_v) + last = i; + + return last; +} + +int +main (void) +{ + int a[N] = { + 17, 28, 13, 14, 15, 16, 17, 18, 19, 20, + 1, 2, -3, 4, 5, 6, 7, -8, 9, 10, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32 + }; + + check_vect (); + + int ret = condition_reduction (a, 16); + + if (ret != 2) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 2 "vect" { xfail vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target { vect_fold_extract_last && { ! vect_multiple_sizes } } } } } */ +/* { dg-final { scan-tree-dump "optimizing condition reduction with FOLD_EXTRACT_LAST" "vect" { target { vect_fold_extract_last && vect_multiple_sizes } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-14.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-14.c new file mode 100644 index 0000000000..3b76fda212 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-14.c @@ -0,0 +1,47 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 27 + +/* Condition reduction with matches only in even lanes at runtime. */ + +int +condition_reduction (int *a, int min_v) +{ + int last = N + 96; + + for (int i = 0; i < N; i++) + if (a[i] > min_v) + last = i; + + return last; +} + +int +main (void) +{ + int a[N] = { + 47, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 21, 22, 23, 24, 25, 26, 27 + }; + + check_vect (); + + int ret = condition_reduction (a, 46); + + /* loop should have found a value of 0, not default N + 96. */ + if (ret != 0) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 2 "vect" { target { ! vect_fold_extract_last } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-2.c new file mode 100644 index 0000000000..58ba5f764d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-2.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 254 + +/* Non-simple condition reduction. */ + +unsigned char +condition_reduction (unsigned char *a, unsigned char min_v) +{ + unsigned char last = 65; + + for (unsigned char i = 0; i < N; i++) + if (a[i] < min_v) + last = a[i]; + + return last; +} + +int +main (void) +{ + unsigned char a[N] = { + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32 + }; + __builtin_memset (a+32, 43, N-32); + + check_vect (); + + unsigned char ret = condition_reduction (a, 16); + + if (ret != 10) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-3.c new file mode 100644 index 0000000000..6b4077e1a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-3.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 37 + +/* Non-simple condition reduction with additional variable and unsigned + types. */ + +unsigned int +condition_reduction (unsigned int *a, unsigned int min_v, unsigned int *b) +{ + unsigned int last = N + 65; + unsigned int aval; + + for (unsigned int i = 0; i < N; i++) + { + aval = a[i]; + if (b[i] < min_v) + last = aval; + } + return last; +} + + +int +main (void) +{ + unsigned int a[N] = { + 31, 32, 33, 34, 35, 36, 37, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 + }; + unsigned int b[N] = { + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 31, 32, 33, 34, 35, 36, 37 + }; + + check_vect (); + + unsigned int ret = condition_reduction (a, 16, b); + + if (ret != 13) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-4.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-4.c new file mode 100644 index 0000000000..471fbe2da2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-4.c @@ -0,0 +1,48 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 27 + +/* Condition reduction with no valid matches at runtime. */ + +int +condition_reduction (int *a, int min_v) +{ + int last = N + 96; + + for (int i = 0; i < N; i++) + if (a[i] > min_v) + last = i; + + return last; +} + +int +main (void) +{ + int a[N] = { + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 21, 22, 23, 24, 25, 26, 27 + }; + + check_vect (); + + int ret = condition_reduction (a, 46); + + /* loop should never have found a value. */ + if (ret != N + 96) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 2 "vect" { target { ! vect_fold_extract_last } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-5.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-5.c new file mode 100644 index 0000000000..4e3f765cd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-5.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#if VECTOR_BITS > 256 +#define N (VECTOR_BITS / 8) +#else +#define N 32 +#endif + +/* Condition reduction where loop size is not known at compile time. Will fail + to vectorize. Version inlined into main loop will vectorize. */ + +unsigned char +condition_reduction (unsigned char *a, unsigned char min_v, int count) +{ + unsigned char last = 65; + + for (int i = 0; i < count; i++) + if (a[i] < min_v) + last = a[i]; + + return last; +} + +int +main (void) +{ + unsigned char a[N] = { + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32 + }; + for (int i = 32; i < N; ++i) + { + a[i] = 70 + (i & 3); + asm volatile ("" ::: "memory"); + } + + check_vect (); + + unsigned char ret = condition_reduction (a, 16, N); + + if (ret != 10) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target { ! vect_fold_extract_last } } } } */ +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump "loop size is greater than data size" "vect" { xfail vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-6.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-6.c new file mode 100644 index 0000000000..dde96d7a55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-6.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 30 + +/* Condition reduction where loop type is different than the data type. */ + +int +condition_reduction (int *a, int min_v) +{ + int last = N + 65; + + for (char i = 0; i < N; i++) + if (a[i] < min_v) + last = a[i]; + + return last; +} + + +int +main (void) +{ + int a[N] = { + 67, 32, 45, 43, 21, -11, 12, 3, 4, 5, + 6, 76, -32, 56, -32, -1, 4, 5, 6, 99, + 43, 22, -3, 22, 16, 34, 55, 31, 87, 324 + }; + + check_vect (); + + int ret = condition_reduction (a, 16); + + if (ret != -3) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-7.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-7.c new file mode 100644 index 0000000000..58c46df5c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-7.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 43 + +/* Condition reduction with comparison is a different type to the data. Will + fail to vectorize. */ + +int __attribute__ ((noipa)) +condition_reduction (short *a, int min_v, int *b) +{ + int last = N + 65; + short aval; + + for (int i = 0; i < N; i++) + { + aval = a[i]; + if (b[i] < min_v) + last = aval; + } + return last; +} + +int +main (void) +{ + short a[N] = { + 31, -32, 133, 324, 335, 36, 37, 45, 11, 65, + 1, -28, 3, 48, 5, -68, 7, 88, 89, 180, + 121, -122, 123, 124, -125, 126, 127, 128, 129, 130, + 11, 12, 13, 14, -15, -16, 17, 18, 19, 20, + 33, 27, 99 + }; + int b[N] = { + 11, -12, -13, 14, 15, 16, 17, 18, 19, 20, + 21, -22, 23, 24, -25, 26, 27, 28, 29, 30, + 1, 62, 3, 14, -15, 6, 37, 48, 99, 10, + 31, -32, 33, 34, -35, 36, 37, 56, 54, 22, + 73, 2, 87 + }; + + check_vect (); + + int ret = condition_reduction (a, 16, b); + + if (ret != 27) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "optimizing condition reduction with FOLD_EXTRACT_LAST" "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-8.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-8.c new file mode 100644 index 0000000000..9ced4dbb69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-8.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 27 + +/* Condition reduction with multiple types in the comparison. Will fail to + vectorize on architectures requiring matching vector sizes. */ + +int +condition_reduction (char *a, int min_v) +{ + int last = N + 65; + + for (int i = 0; i < N; i++) + if (a[i] < min_v) + last = a[i]; + + return last; +} + + +int +main (void) +{ + char a[N] = { + 1, 28, 3, 48, 5, 68, 7, -88, 89, 180, + 121, 122, -123, 124, 12, -12, 12, 67, 84, 122, + 67, 55, 112, 22, 45, 23, 111 + }; + + check_vect (); + + int ret = condition_reduction (a, 16); + + if (ret != 12) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" { target { ! { vect_fold_extract_last } } } } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { vect_fold_extract_last } } } } */ +/* { dg-final { scan-tree-dump "multiple types in double reduction or condition reduction" "vect" { target { ! { vect_fold_extract_last } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65947-9.c b/SingleSource/Regression/C/gcc-dg/vect/pr65947-9.c new file mode 100644 index 0000000000..1f29530601 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65947-9.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +extern void abort (void) __attribute__ ((noreturn)); + +#define N 255 + +/* Condition reduction with maximum possible loop size. Will fail to + vectorize because the vectorisation requires a slot for default values. */ + +signed char __attribute__((noinline,noclone)) +condition_reduction (signed char *a, signed char min_v) +{ + signed char last = -72; + + for (int i = 0; i < N; i++) + if (a[i] < min_v) + last = a[i]; + + return last; +} + +int +main () +{ + signed char a[N] = { + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32 + }; + __builtin_memset (a+32, 43, N-32); + + check_vect (); + + signed char ret = condition_reduction (a, 16); + if (ret != 10) + abort (); + + ret = condition_reduction (a, 1); + if (ret != -72) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" { target { ! vect_fold_extract_last } } } } */ +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump "loop size is greater than data size" "vect" { target { ! vect_fold_extract_last } } } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 1 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr65951.c b/SingleSource/Regression/C/gcc-dg/vect/pr65951.c new file mode 100644 index 0000000000..cfd3237318 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr65951.c @@ -0,0 +1,63 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 512 + +/* These multiplications should be vectorizable with additions when + no vector shift is available. */ + +__attribute__ ((noinline)) void +foo (int *arr) +{ + for (int i = 0; i < N; i++) + arr[i] *= 2; +} + +__attribute__ ((noinline)) void +foo2 (int *arr) +{ + for (int i = 0; i < N; i++) + arr[i] *= 4; +} + +int +main (void) +{ + check_vect (); + int data[N]; + int i; + + for (i = 0; i < N; i++) + { + data[i] = i; + __asm__ volatile (""); + } + + foo (data); + for (i = 0; i < N; i++) + { + if (data[i] / 2 != i) + __builtin_abort (); + __asm__ volatile (""); + } + + for (i = 0; i < N; i++) + { + data[i] = i; + __asm__ volatile (""); + } + + foo2 (data); + for (i = 0; i < N; i++) + { + if (data[i] / 4 != i) + __builtin_abort (); + __asm__ volatile (""); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr66142.c b/SingleSource/Regression/C/gcc-dg/vect/pr66142.c new file mode 100644 index 0000000000..7abd00ca85 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr66142.c @@ -0,0 +1,44 @@ +/* PR middle-end/66142 */ +/* { dg-do compile } */ +/* { dg-additional-options "-ffast-math -fopenmp-simd --param early-inlining-insns=14" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +struct A { float x, y; }; +struct B { struct A t, w; }; + +static inline float +bar (const struct B *x) +{ + struct A r; + float b, c, d; + r.x = x->t.x; + r.y = x->t.y; + b = r.x * x->w.x + r.y * x->w.y; + c = b + r.x * r.x + r.y * r.y; + if (c > 0.0f) + return c + 3.0f; + return 0.0f; +} + +void +foo (float *a, float *b, float *c) +{ + int i; + float z = 0.0f; + float u = *a; +#pragma omp simd + for (i = 0; i < 32; i++) + { + float x = b[i]; + float y = c[i]; + struct B r; + r.t.x = 1.0f; + r.t.y = u; + r.w.x = x; + r.w.y = y; + z += bar (&r); + } + *a = z; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target { vect_condition && vect_float } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr66251.c b/SingleSource/Regression/C/gcc-dg/vect/pr66251.c new file mode 100644 index 0000000000..355590e69a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr66251.c @@ -0,0 +1,80 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_doubleint_cvt } */ +/* { dg-require-effective-target vect_intdouble_cvt } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ +/* { dg-require-effective-target vect_hw_misalign } */ + +#include "tree-vect.h" + +void __attribute__((noinline,noclone)) +test1(_Complex double *a, _Complex int *b, int stride, int n) +{ + int i; + for (i = 0; i < n; i++) + { + a[i*stride] = b[i*stride]; + } +} + +void __attribute__((noinline,noclone)) +test2(_Complex int *a, _Complex double *b, int stride, int n) +{ + int i; + for (i = 0; i < n; i++) + { + a[i*stride] = b[i*stride]; + } +} + +_Complex int ia[256]; +_Complex double da[256]; + +extern void abort (void); + +int main () +{ + int i; + int stride; + + check_vect (); + + for (stride = 1; stride < 15; stride++) + { + for (i = 0; i < 256; i++) + { + __real__ ia[i] = (i + stride) % 19; + __imag__ ia[i] = (i + stride) % 23; + __asm__ volatile (""); + } + + test1(da, ia, stride, 256/stride); + +#pragma GCC novector + for (i = 0; i < 256/stride; i++) + { + if (da[i*stride] != ia[i*stride]) + abort (); + } + + for (i = 0; i < 256; i++) + { + __real__ da[i] = (i + stride + 1) % 29; + __imag__ da[i] = (i + stride + 1) % 31; + __asm__ volatile (""); + } + + test2(ia, da, stride, 256/stride); + +#pragma GCC novector + for (i = 0; i < 256/stride; i++) + { + if (da[i*stride] != ia[i*stride]) + abort (); + } + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr66253.c b/SingleSource/Regression/C/gcc-dg/vect/pr66253.c new file mode 100644 index 0000000000..6b99b4f3b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr66253.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_hw_misalign } */ + +#include "tree-vect.h" + +void __attribute__((noinline,noclone)) +test1(_Complex double * __restrict__ a, _Complex double * __restrict__ b, + double * __restrict__ c, int stride, int n) +{ + int i; + for (i = 0; i < n; i++) + { + a[i*stride] = 0.5 * b[i*stride] * c[i*stride]; + } +} + +double ca[256]; +_Complex double ia[256]; +_Complex double da[256]; + +extern void abort (void); + +int main () +{ + int i; + int stride; + + check_vect (); + + for (stride = 1; stride < 15; stride++) + { + for (i = 0; i < 256; i++) + { + __real__ ia[i] = (i + stride) % 19; + __imag__ ia[i] = (i + stride) % 23; + ca[i] = (i + stride) % 29; + __asm__ volatile (""); + } + + test1(da, ia, ca, stride, 256/stride); + +#pragma GCC novector + for (i = 0; i < 256/stride; i++) + { + if (da[i*stride] != 0.5 * ia[i*stride] * ca[i*stride]) + abort (); + } + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr66278.c b/SingleSource/Regression/C/gcc-dg/vect/pr66278.c new file mode 100644 index 0000000000..3e0e2ec5e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr66278.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +#define N 101 + +typedef unsigned int __uint32_t; + +int main(int argc, char **argv) +{ + __uint32_t array[N][N][N]; + + const unsigned int next = argc == 3 ? 0 : 1; + + for (unsigned i = next; i < N; i++) + array[3][3][i] = array[3][3][i] - 10; + + return array[3][3][argc]; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" } } */ +/* { dg-require-effective-target vect_int } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr66623.c b/SingleSource/Regression/C/gcc-dg/vect/pr66623.c new file mode 100644 index 0000000000..f90c673f82 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr66623.c @@ -0,0 +1,86 @@ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +extern void abort (void); + +#define OP * +#define INIT 1.0 + +float __attribute__((noinline,noclone)) +foo (float *__restrict__ i) +{ + float l = INIT; + int a; + int b; + + for (a = 0; a < 4; a++) + for (b = 0; b < 4; b++) + l = l OP i[b]; + + return l; +} + +float __attribute__((noinline,noclone)) +foo_ref (float *__restrict__ i) +{ + float l = INIT; + + l = l OP i[0]; + l = l OP i[1]; + l = l OP i[2]; + l = l OP i[3]; + + l = l OP i[0]; + l = l OP i[1]; + l = l OP i[2]; + l = l OP i[3]; + + l = l OP i[0]; + l = l OP i[1]; + l = l OP i[2]; + l = l OP i[3]; + + l = l OP i[0]; + l = l OP i[1]; + l = l OP i[2]; + l = l OP i[3]; + + return l; +} + +union u +{ + float f; + unsigned int u; +}; + +int +main (void) +{ + union u res, res2; + float a[4]; + + if (sizeof (float) != sizeof (unsigned int)) + return 0; + + check_vect (); + + a[0] = 0.01; + a[1] = 0.01; + a[2] = 0.01; + a[3] = 1.0; + + res.f = foo_ref (a); + + res2.f = foo (a); + + if (res.u != res2.u) + abort (); + + return 0; +} + +/* need -ffast-math to vectorize this loop. */ +/* ARM NEON passes -ffast-math to these tests, so expect this to fail. */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { xfail arm_neon_ok } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr66636.c b/SingleSource/Regression/C/gcc-dg/vect/pr66636.c new file mode 100644 index 0000000000..c0733ffa5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr66636.c @@ -0,0 +1,30 @@ +/* { dg-additional-options "-mavx2" { target avx_runtime } } */ + +#include "tree-vect.h" + +extern void abort (void); + +struct X { double x; double y; }; + +void __attribute__((noinline,noclone)) +foo (struct X *x, double px, int s) +{ + int i; + for (i = 0; i < 256; ++i) + { + x[i*s].x = px; + x[i*s].y = i + px; + } +} + +int main() +{ + struct X x[512]; + int i; + check_vect (); + foo (x, 1., 2); + if (x[0].x != 1. || x[0].y != 1. + || x[510].x != 1. || x[510].y != 256.) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr66677.c b/SingleSource/Regression/C/gcc-dg/vect/pr66677.c new file mode 100644 index 0000000000..b95ac46d57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr66677.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-msse4" { target x86_64-*-* i?86-*-* } } */ + +int *a, *b; +void fn1(char *p1) +{ + int x; + for (; x; x += 2) + { + a[x] = p1[0]; + a[x + 1] = 0; + b[x] = b[x + 1] = p1[1]; + p1 += 4; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr66951.c b/SingleSource/Regression/C/gcc-dg/vect/pr66951.c new file mode 100644 index 0000000000..628e1ee77b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr66951.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +int a, b[16], c, d; + +void +fn1 () +{ + for (; d; d++) + { + for (a = 0; a < 2; a++) + ; + c ^= b[d]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr67790.c b/SingleSource/Regression/C/gcc-dg/vect/pr67790.c new file mode 100644 index 0000000000..32eacd91fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr67790.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +struct { + int x_advance; + int y_advance; +} a[256]; + +int b, c; + +void __attribute__((noinline,noclone)) fn1() +{ + for (int i = 0; i < 256; i++) + { + c -= a[i].x_advance; + b -= a[i].y_advance; + } +} + +int main() +{ + check_vect (); + + for (int i = 0; i < 256; ++i) + { + a[i].x_advance = i; + a[i].y_advance = -i + 3; + __asm__ volatile ("" : : : "memory"); + } + + fn1(); + + if (c != -32640 || b != 31872) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr68305.c b/SingleSource/Regression/C/gcc-dg/vect/pr68305.c new file mode 100644 index 0000000000..12297a934f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr68305.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */ + +int a, b; + +void +fn1 () +{ + int c, d; + for (; b; b++) + a = a ^ !c ^ !d; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr68339.c b/SingleSource/Regression/C/gcc-dg/vect/pr68339.c new file mode 100644 index 0000000000..28fa294ada --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr68339.c @@ -0,0 +1,17 @@ +/* PR middle-end/68339 */ +/* { dg-do compile } */ +/* { dg-additional-options "--param ggc-min-heapsize=0 --param ggc-min-expand=0 -fopenmp-simd" } */ + +#pragma omp declare simd notinbranch +int +f1 (int x) +{ + return x; +} + +#pragma omp declare simd notinbranch +int +f2 (int x) +{ + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr68417.c b/SingleSource/Regression/C/gcc-dg/vect/pr68417.c new file mode 100644 index 0000000000..bddd9f909a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr68417.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_condition } */ + +#define N 16 + +typedef struct { + int x; + int y; +} Point; + +void +foo(Point *p1, Point *p2, Point *p3, int *data) +{ + int m, m1, m2; + int i; + + for (i = 0; i < N; i++) { + m = *data++; + + m1 = p1->x - m; + m2 = p2->x + m; + + p3->y = (m1 >= m2) ? p1->y : p2->y; + + p1++; + p2++; + p3++; + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr68445.c b/SingleSource/Regression/C/gcc-dg/vect/pr68445.c new file mode 100644 index 0000000000..15bffdc7e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr68445.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void IMB_double_fast_x (int *destf, int *dest, int y, int *p1f) +{ + int i; + for (i = y; i > 0; i--) + { + *dest++ = 0; + destf[0] = destf[4] = p1f[0]; + destf[1] = destf[5] = p1f[1]; + destf[2] = destf[6] = p1f[2]; + destf[3] = destf[7] = p1f[3]; + destf += 8; + p1f += 4; + } +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { xfail vect_variable_length } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr68482.c b/SingleSource/Regression/C/gcc-dg/vect/pr68482.c new file mode 100644 index 0000000000..28a921acae --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr68482.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void test(int* input, int* out, unsigned x1, unsigned x2) +{ + unsigned i, j; + unsigned end = x1; + + for(i = j = 0; i < 1000; i++) { + int sum = 0; + end += x2; + for( ; j < end; j++) + sum += input[j]; + out[i] = sum; + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr68502-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr68502-1.c new file mode 100644 index 0000000000..cc6e6cd9a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr68502-1.c @@ -0,0 +1,49 @@ +#include +#include "tree-vect.h" + +typedef struct { + double *I; + double W; + double X; + double V; + double U; + double P; + double Q; + double R; +} f1_neuron; + +f1_neuron *f1_layer; + +int numf1s = 1000; + +void __attribute__((noinline,noclone)) +reset_nodes() +{ + int i; + + for (i=0;i +#include "tree-vect.h" + +typedef struct { + short I; + int W; + int X; + int V; + int U; + int P; + int Q; + int R; +} __attribute__((packed)) f1_neuron; + +f1_neuron *f1_layer; + +int numf1s = 1000; + +void __attribute__((noinline,noclone)) +reset_nodes() +{ + int i; + + for (i=0;i> b ? a : b; + d |= c == 1 ^ 1 == f; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr69652.c b/SingleSource/Regression/C/gcc-dg/vect/pr69652.c new file mode 100644 index 0000000000..29fe28c5c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr69652.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ffast-math" } */ +/* { dg-additional-options "-mavx" { target { i?86-*-* x86_64-*-* } } } */ + +void fn1(double **matrix, int column, int row, int n) +{ + int k; + for (k = 0; k < n; k++) + if (matrix[row][k] != matrix[column][k]) + { + matrix[column][k] = -matrix[column][k]; + matrix[row][k] = matrix[row][k] - matrix[column][k]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr69783.c b/SingleSource/Regression/C/gcc-dg/vect/pr69783.c new file mode 100644 index 0000000000..5df95d0ce4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr69783.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-Ofast -funroll-loops" } */ + +#define NXX 516 +#define NYY 516 +#define IND(x,y) ((x) + (y)*NXX) +float **In, **Out, **V; + +void foo(int I, int J, int K1, int K2, int L1, int L2 ) +{ + for(int i=0; i < I; i++) + { + float *v = V[i]; + + for(int j=0; j < J; j++) + { + float *in = In[j]; + float *out = Out[j]; + for(int l=L1; l= *(k + *(j + *b)) != (a != 8)) - 5105075050047261684; + asm volatile ("" : : : "memory"); + for (i = 0; i < 44; i++) + for (j = 0; j < 17; j++) +#pragma GCC novector + for (k = 0; k < 2; k++) + if (c[i][j][k] != -5105075050047261684) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71264.c b/SingleSource/Regression/C/gcc-dg/vect/pr71264.c new file mode 100644 index 0000000000..b372c00832 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71264.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +typedef unsigned char uint8_t; +typedef uint8_t footype __attribute__((vector_size(4))); + +void test(uint8_t *ptr, uint8_t *mask) +{ + footype mv; + ptr = __builtin_assume_aligned (ptr, __alignof__ (footype)); + mask = __builtin_assume_aligned (mask, __alignof__ (footype)); + __builtin_memcpy(&mv, mask, sizeof(mv)); + for (unsigned i = 0; i < 16; i += 4) + { + footype temp; + __builtin_memcpy(&temp, &ptr[i], sizeof(temp)); + temp ^= mv; + __builtin_memcpy(&ptr[i], &temp, sizeof(temp)); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71407.c b/SingleSource/Regression/C/gcc-dg/vect/pr71407.c new file mode 100644 index 0000000000..761990de9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71407.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +int a, c, d; +short b; + +void +fn1 () +{ + int e; + for (; c; c++) + { + for (; a; a++) + b = (short) a || e; + e = d; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71416-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr71416-1.c new file mode 100644 index 0000000000..b2845787c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71416-1.c @@ -0,0 +1,18 @@ +#include "tree-vect.h" + +short a; +char b, e; +static short c; +int d, f; +int main() { + short g; + check_vect (); + for (; e; ++e) { + d = a; + f = 0; + if (b) + d = f = g >= c; + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71416-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr71416-2.c new file mode 100644 index 0000000000..d846ef17ef --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71416-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ + +int a, b, d, e, f, g; +int *c; +void fn2 (int *); +void fn1() { fn2(&e); } + +void fn2(int *p1) { + for (;;) { + for (; a; a++) + if (*p1 = g || --f, b) + if (*c) + d = *p1; + if (*p1) + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71439.c b/SingleSource/Regression/C/gcc-dg/vect/pr71439.c new file mode 100644 index 0000000000..1f596a8e4d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71439.c @@ -0,0 +1,18 @@ +#include "tree-vect.h" + +int a, b, c; +short fn1(int p1, int p2) { return p1 + p2; } + +int main() { + check_vect (); + a = 0; + for (; a < 30; a = fn1(a, 4)) { + c = b; + b = 6; + } + + if (c != 6) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71667.c b/SingleSource/Regression/C/gcc-dg/vect/pr71667.c new file mode 100644 index 0000000000..e7012efa88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71667.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-g" } */ + +unsigned int mu; +int pt; + +void +qf (void) +{ + int gy; + long int vz; + + for (;;) + { + for (gy = 0; gy < 80; ++gy) + { + vz = mu; + ++mu; + pt = (vz != 0) && (pt != 0); + } + while (gy < 81) + while (gy < 83) + { + vz = (vz != 0) ? 0 : mu; + ++gy; + } + pt = vz; + ++mu; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71752.c b/SingleSource/Regression/C/gcc-dg/vect/pr71752.c new file mode 100644 index 0000000000..8d26754b4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71752.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +unsigned int q4, yg; + +unsigned int +w6 (unsigned int z5, unsigned int jv) +{ + unsigned int *f2 = &jv; + + while (*f2 < 21) + { + q4 -= jv; + z5 -= jv; + f2 = &yg; + ++(*f2); + } + return z5; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71818.c b/SingleSource/Regression/C/gcc-dg/vect/pr71818.c new file mode 100644 index 0000000000..2946551f8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71818.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +char a; +short b; +int c, d; +void fn1() { + char e = 75, g; + unsigned char *f = &e; + a = 21; + for (; a <= 48; a++) { + for (; e <= 6;) + ; + g -= e -= b || g <= c; + } + d = *f; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71823.c b/SingleSource/Regression/C/gcc-dg/vect/pr71823.c new file mode 100644 index 0000000000..079cde41ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71823.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/71823 */ +/* { dg-do compile } */ +/* { dg-additional-options "-mfma" { target i?86-*-* x86_64-*-* } } */ + +float a[4], b[4]; + +int +main () +{ + int i; + for (i = 0; i < 4; ++i) + b[i] = __builtin_fma (1024.0f, 1024.0f, a[i]); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr71854.c b/SingleSource/Regression/C/gcc-dg/vect/pr71854.c new file mode 100644 index 0000000000..6dc2c53a8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr71854.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/71854 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -ftree-loop-if-convert" } */ + +char a, f = 1; +int b, c, e[8]; +short d; + +short +foo (short x) +{ + return x >= 2 || x >> c ? x : x << c; +} + +int +main () +{ + while (f) + for (d = 0; d <= 7; d++) + { + f = 7 >> b ? a : a << b; + e[d] = foo (f); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr72866.c b/SingleSource/Regression/C/gcc-dg/vect/pr72866.c new file mode 100644 index 0000000000..a2ccbbbece --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr72866.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/72866 */ +/* { dg-do compile } */ + +unsigned int dl; +int rx, lb; + +void +fo (int jv, int be) +{ + const unsigned int xw = 16; + unsigned int ya, wo; + + for (ya = 0; ya < 2; ++ya) + for (wo = 0; wo < xw; ++wo) + { + dl += (jv ? be : rx); + rx += ((lb == 0) + 1); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr77503.c b/SingleSource/Regression/C/gcc-dg/vect/pr77503.c new file mode 100644 index 0000000000..609e7fb5fd --- /dev/null +++ b/SingleSource/Regression/C/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" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr77724.c b/SingleSource/Regression/C/gcc-dg/vect/pr77724.c new file mode 100644 index 0000000000..b3411d6811 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr77724.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +int a[81]; +int b, c; + +void +fn1() +{ + int d = b; + for (; c; --c) + a[c + d] = a[c]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr78005.c b/SingleSource/Regression/C/gcc-dg/vect/pr78005.c new file mode 100644 index 0000000000..6da7acf50c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr78005.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ +#include "tree-vect.h" + +#define N 20 +int u[N] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; +int z[N] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; +int res4[N] = {0, 1, 8, 3, 22, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; +int res5[N] = {0, 1, 8, 3, 22, 5, 36, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; +int res6[N] = {0, 1, 8, 3, 22, 5, 36, 7, 50, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; +int res7[N] = {0, 1, 8, 3, 22, 5, 36, 7, 50, 9, 64, 11, 12, 13, 14, 15, 16, 17, 18, 19}; +int res8[N] = {0, 1, 8, 3, 22, 5, 36, 7, 50, 9, 64, 11, 78, 13, 14, 15, 16, 17, 18, 19}; +int res9[N] = {0, 1, 8, 3, 22, 5, 36, 7, 50, 9, 64, 11, 78, 13, 92, 15, 16, 17, 18, 19}; +int res10[N] = {0, 1, 8, 3, 22, 5, 36, 7, 50, 9, 64, 11, 78, 13, 92, 15, 106, 17, 18, 19}; + +__attribute__ ((noinline)) void +foo (int n, int d) +{ + int i; + for (i = 2; i < n; i++) + u[2*i-2] = u[2*i-2] + d * (z[i-1] + z[i] + z[i-1] + z[i] + z[i-1] + z[i]); +} + +#define check_u(x) \ + foo (x, 2); \ + _Pragma("GCC novector") \ + for (i = 0; i < N; i++) \ + { \ + if (u[i] != res##x[i]) \ + abort (); \ + u[i] = i; \ + } + +int main(void) +{ + int i; + + check_vect (); + + /* Need to check for all possible vector factors. */ + check_u(4); + check_u(5); + check_u(6); + check_u(7); + check_u(8); + check_u(9); + check_u(10); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr78558.c b/SingleSource/Regression/C/gcc-dg/vect/pr78558.c new file mode 100644 index 0000000000..2c28426eb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr78558.c @@ -0,0 +1,45 @@ +/* PR tree-optimization/78558 */ + +#include "tree-vect.h" + +struct S +{ + char p[48]; + unsigned long long q, r, s; +} s[50]; + +struct D +{ + unsigned long long q, r; +} d[50]; + +void +foo (void) +{ + unsigned long i; + for (i = 0; i < 50; ++i) + { + d[i].q = s[i].q; + d[i].r = s[i].r; + } +} + +int +main () +{ + check_vect (); + unsigned long i; + for (i = 0; i < 50; ++i) + { + s[i].q = i; + s[i].r = 50 * i; + } + asm volatile ("" : : "g" (s), "g" (d) : "memory"); + foo (); + asm volatile ("" : : "g" (s), "g" (d) : "memory"); +#pragma GCC novector + for (i = 0; i < 50; ++i) + if (d[i].q != i || d[i].r != 50 * i) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr78938.c b/SingleSource/Regression/C/gcc-dg/vect/pr78938.c new file mode 100644 index 0000000000..095e674adf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr78938.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/78938 */ +/* { dg-do compile } */ +/* { dg-additional-options "-mavx512bw" { target i?86-*-* x86_64-*-* } } */ + +short int v; + +int +foo (char x, int *b) +{ + int a = 1; + for (; x < 1; x++) + { + int c = *b != v; + int d = x != 0; + a = c == d ? 2 : 0; + } + return a; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr79347.c b/SingleSource/Regression/C/gcc-dg/vect/pr79347.c new file mode 100644 index 0000000000..6825420ec8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr79347.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-vect-all" } */ + +short *a; +int c; +void n(void) +{ + for (int i = 0; i +#include +#include "tree-vect.h" + +#define COUNT 320 +#define MMAP_SIZE 0x10000 +#define ADDRESS 0x1122000000 +#define TYPE double + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +void __attribute__((noinline)) +foo (TYPE *__restrict a, TYPE *__restrict b) +{ + int n; + + b = __builtin_assume_aligned (b, sizeof (TYPE) * 2); + a = __builtin_assume_aligned (a, sizeof (TYPE) * 2); + for (n = 0; n < COUNT; n++) + a[n] = b[n * 4]; +} + +int +main (void) +{ + void *x; + size_t b_offset; + + check_vect (); + + x = mmap ((void *) ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (x == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + + b_offset = MMAP_SIZE - (4 * COUNT - 2) * sizeof (TYPE); + foo ((TYPE *) x, (TYPE *) ((char *) x + b_offset)); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr79824-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr79824-2.c new file mode 100644 index 0000000000..629b97e21b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr79824-2.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target mmap } */ + +#include +#include +#include "tree-vect.h" + +#define COUNT 320 +#define MMAP_SIZE 0x10000 +#define ADDRESS 0x1122000000 +#define TYPE double + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +void __attribute__((noinline)) +foo (TYPE *__restrict a, TYPE *__restrict b) +{ + int n; + + b = __builtin_assume_aligned (b, sizeof (TYPE) * 2); + a = __builtin_assume_aligned (a, sizeof (TYPE) * 2); + for (n = 0; n < COUNT; n++) + { + a[n] = b[n * 4] + b[n * 4 + 1]; + } +} + +int +main (void) +{ + void *x; + size_t b_offset; + + check_vect (); + + x = mmap ((void *) ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (x == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + + b_offset = MMAP_SIZE - (4 * COUNT - 2) * sizeof (TYPE); + foo ((TYPE *) x, (TYPE *) ((char *) x + b_offset)); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr79887.c b/SingleSource/Regression/C/gcc-dg/vect/pr79887.c new file mode 100644 index 0000000000..4a7d1b05b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr79887.c @@ -0,0 +1,14 @@ +/* Test for pr79887. */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ +/* { dg-additional-options "-fno-trapping-math --param vect-epilogues-nomask=1" } */ +/* { dg-additional-options "-mavx512ifma" { target x86_64-*-* i?86-*-* } } */ + +void +foo (float a[32], float b[2][32]) +{ + int i; + for (i = 0; i < 32; i++) + a[i] = (b[0][i] > b[1][i]) ? b[0][i] : b[1][i]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr79920.c b/SingleSource/Regression/C/gcc-dg/vect/pr79920.c new file mode 100644 index 0000000000..38e0fef779 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr79920.c @@ -0,0 +1,45 @@ +/* { dg-additional-options "-O3 -fno-fast-math" } */ + +#include "tree-vect.h" + +double __attribute__((noinline,noclone)) +compute_integral (double w_1[18]) +{ + double A = 0; + double t33[2][6] = {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; + double t43[2] = {0.0, 0.0}; + double t31[2][2] = {{1.0, 1.0}, {1.0, 1.0}}; + double t32[2][3] = {{0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}}; + + for (int ip_1 = 0; ip_1 < 2; ++ip_1) + { +#pragma GCC unroll 0 + for (int i_0 = 0; i_0 < 6; ++i_0) + t33[ip_1][i_0] = ((w_1[i_0*3] * t32[ip_1][0]) + + (w_1[i_0*3+2] * t32[ip_1][2])); + t43[ip_1] = 2.0; + } + for (int i_0 = 0; i_0 < 6; ++i_0) + A += t43[1]*t33[1][i_0]; + return A; +} + +int main() +{ + check_vect (); + + double w_1[18] = {0., 1.0, 1.0, + 0., 1.0, 1.0, + 0., 1.0, 1.0, + 0., 1.0, 1.0, + 0., 1.0, 1.0, + 0., 1.0, 1.0}; + double A = compute_integral(w_1); + if (A != 12.0) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times {using an in-order \(fold-left\) reduction} 1 "vect" { target vect_double } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { vect_double && { vect_perm && vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr80631-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr80631-1.c new file mode 100644 index 0000000000..cbb9a6ff69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr80631-1.c @@ -0,0 +1,78 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* PR tree-optimization/80631 */ + +#include "tree-vect.h" + +int v[8] = { 77, 1, 79, 3, 4, 3, 6, 7 }; + +__attribute__((noipa)) void +f1 (void) +{ + int k, r = -1; + for (k = 0; k < 8; k++) + if (v[k] == 77) + r = k; + if (r != 0) + abort (); +} + +__attribute__((noipa)) void +f2 (void) +{ + int k, r = 4; + for (k = 0; k < 8; k++) + if (v[k] == 79) + r = k; + if (r != 2) + abort (); +} + +__attribute__((noipa)) void +f3 (void) +{ + int k, r = -17; + for (k = 0; k < 8; k++) + if (v[k] == 78) + r = k; + if (r != -17) + abort (); +} + +__attribute__((noipa)) void +f4 (void) +{ + int k, r = 7; + for (k = 0; k < 8; k++) + if (v[k] == 78) + r = k; + if (r != 7) + abort (); +} + +__attribute__((noipa)) void +f5 (void) +{ + int k, r = -1; + for (k = 0; k < 8; k++) + if (v[k] == 3) + r = k; + if (r != 5) + abort (); +} + +int +main () +{ + check_vect (); + f1 (); + f2 (); + f3 (); + f4 (); + f5 (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 5 "vect" { target vect_condition } } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 5 "vect" { target vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 5 "vect" { target { { ! vect_fold_extract_last } && vect_condition } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr80631-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr80631-2.c new file mode 100644 index 0000000000..4e58627517 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr80631-2.c @@ -0,0 +1,79 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* PR tree-optimization/80631 */ + +#include "tree-vect.h" + +int v[8] = { 77, 1, 79, 3, 4, 3, 6, 7 }; + +__attribute__((noipa)) void +f1 (void) +{ + int k, r = -1; + for (k = 7; k >= 0; k--) + if (v[k] == 77) + r = k; + if (r != 0) + abort (); +} + +__attribute__((noipa)) void +f2 (void) +{ + int k, r = 4; + for (k = 7; k >= 0; k--) + if (v[k] == 79) + r = k; + if (r != 2) + abort (); +} + +__attribute__((noipa)) void +f3 (void) +{ + int k, r = -17; + for (k = 7; k >= 0; k--) + if (v[k] == 78) + r = k; + if (r != -17) + abort (); +} + +__attribute__((noipa)) void +f4 (void) +{ + int k, r = 7; + for (k = 7; k >= 0; k--) + if (v[k] == 78) + r = k; + if (r != 7) + abort (); +} + +__attribute__((noipa)) void +f5 (void) +{ + int k, r = -1; + for (k = 7; k >= 0; k--) + if (v[k] == 3) + r = k; + if (r != 3) + abort (); +} + +int +main () +{ + check_vect (); + f1 (); + f2 (); + f3 (); + f4 (); + f5 (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 5 "vect" { target vect_condition } } } */ +/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 5 "vect" { target vect_condition xfail vect_fold_extract_last } } } */ +/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 5 "vect" { target { { ! vect_multiple_sizes } && vect_fold_extract_last } } } } */ +/* { dg-final { scan-tree-dump "optimizing condition reduction with FOLD_EXTRACT_LAST" "vect" { target { vect_multiple_sizes && vect_fold_extract_last } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr80815-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr80815-1.c new file mode 100644 index 0000000000..98c06c0bb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr80815-1.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" +int arr[2048]; + +__attribute__ ((noinline)) int +foo (int *a, int *b) +{ + int i; + int *a1 = a; + int *a0 = a1 - 512; + for (i = 0; i < 500; i++) + { + *b = *a0 + *a1; + b++; + a0--; + a1--; + } + return 0; +} + +int main (void) +{ + int *a = &arr[1027]; + int *b = &arr[1024]; + + int i; + for (i = 0; i < 2048; i++) + arr[i] = i; + + foo (a, b); + + if (arr[1026] != 2053 || arr[1027] != 2054) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr80815-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr80815-2.c new file mode 100644 index 0000000000..3ffff0be3b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr80815-2.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" +int arr[2048]; +int res[100] = { 13198, 13224, 12735, 12760, 12270, 12294, + 11803, 11826, 11334, 11356, 10863, 10884, + 10390, 10410, 9915, 9934, 9438, 9456, + 8959, 8976, 8478, 8494, 7995, 8010, + 7510, 7524, 7023, 7036, 6534, 6546, + 6043, 6054, 5550, 5560, 5055, 5064, + 4558, 4566, 4059, 4066, 3558, 3564, + 3055, 3060, 2550, 2554, 2043, 0}; + +__attribute__ ((noinline)) int +foo (int *a, int *b) +{ + int i; + int *a1 = a; + int *a0 = a1 - 512; + for (i = 0; i < 50; i++) + { + *b = *a0 + *a1; + b--; + a0--; + a1--; + } + return 0; +} + +int main (void) +{ + int *a = &arr[1024]; + int *b = &arr[1022]; + + int i; + for (i = 0; i < 2048; i++) + arr[i] = i; + + foo (a, b); + +#pragma GCC novector + for (i = 973; i < 1020; i++) + if (arr[i] != res[i - 973]) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr80815-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr80815-3.c new file mode 100644 index 0000000000..5e2be5262e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr80815-3.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" +int arr[2048]; +int res[100] = { 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130, + 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110, + 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090, + 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070, + 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 3078, 2050}; + +__attribute__ ((noinline)) int +foo (int *a, int *b, int len) +{ + int i; + int *a1 = a; + int *a0 = a1 - 4; + for (i = 0; i < len; i++) + { + *b = *a0 + *a1; + b--; + a0++; + a1++; + } + return 0; +} + +int main (void) +{ + int *a = &arr[1027]; + int *b = &arr[1024]; + + int i; + for (i = 0; i < 2048; i++) + arr[i] = i; + + foo (a, b, 50); + +#pragma GCC novector + for (i = 975; i < 1025; i++) + if (arr[i] != res[i - 975]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "improved number of alias checks from \[0-9\]* to 1" "vect" { target vect_perm } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr80928.c b/SingleSource/Regression/C/gcc-dg/vect/pr80928.c new file mode 100644 index 0000000000..34566c4535 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr80928.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int a[1020]; + +void __attribute__((noinline)) +foo () +{ + for (int i = 0; i < 1020; i += 5) + { + a[i] = i; + a[i+1] = i; + a[i+2] = i; + a[i+3] = i; + a[i+4] = i; + } +} + +int main () +{ + check_vect (); + + foo (); + + /* check results */ +#pragma GCC novector + for (int i = 0; i < 1020; ++i) + if (a[i] != ((i + 4) / 5) * 5) + abort (); + + return 0; +} + +/* Make sure we are not triggering hybrid SLP due to the IV update. */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr81082.c b/SingleSource/Regression/C/gcc-dg/vect/pr81082.c new file mode 100644 index 0000000000..1195fc7113 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr81082.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int +f (int *x, int b1, int b2, int b3) +{ + int foo = 0; + for (int i1 = 0; i1 < b1; ++i1) + for (int i2 = 0; i2 < b2; ++i2) + for (int i3 = 0; i3 < b3; ++i3) + foo += x[i1 * b2 * b3 + i2 * b3 + (i3 - 1)]; + return foo; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr81136.c b/SingleSource/Regression/C/gcc-dg/vect/pr81136.c new file mode 100644 index 0000000000..99405b5cdf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr81136.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +#include "tree-vect.h" + +#if VECTOR_BITS > 256 +#define ALIGNMENT (VECTOR_BITS / 8) +#else +#define ALIGNMENT 32 +#endif + +struct __attribute__((aligned (ALIGNMENT))) +{ + char misaligner; + int foo[100]; + int bar[100]; +} *a; + +void +fn1 (int n) +{ + int *b = a->foo; + for (int i = 0; i < n; i++) + a->bar[i] = b[i]; +} + +/* { dg-final { scan-tree-dump-not "Unknown misalignment" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr81196-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr81196-2.c new file mode 100644 index 0000000000..b5861c17b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr81196-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* For negative stride we need to reverse the aligned load. */ +/* { dg-require-effective-target vect_perm } */ + +void b (int *p) +{ + p = (int *)__builtin_assume_aligned(p, __BIGGEST_ALIGNMENT__); + int *q = p + 255; + for(; p < q; ++p, --q) + { + int t = *p; + *p = *q; + *q = t; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr81196.c b/SingleSource/Regression/C/gcc-dg/vect/pr81196.c new file mode 100644 index 0000000000..97d40a0243 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr81196.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm_short } */ + +void b(short*p){ + p=(short*)__builtin_assume_aligned(p,64); + short*q=p+255; + for(;p= 0; b--) + for (c = 0; c <= 6; c++) + a[c + 1][b + 2] = a[c][b + 1]; + for (i = 0; i < 8; i++) +#pragma GCC novector + for (d = 0; d < 10; d++) + if (a[i][d] != (i == 3 && d == 6) * 4) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr81740-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr81740-2.c new file mode 100644 index 0000000000..7b2bfe139f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr81740-2.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_hw_misalign } */ + +#include "tree-vect.h" + +int a[8][10] = { [2][5] = 4 }, c; + +int +main () +{ + short b; + int i, d; + check_vect (); + for (b = 4; b >= 0; b--) + for (c = 6; c >= 0; c--) + a[c + 1][b + 2] = a[c][b + 1]; + for (i = 0; i < 8; i++) +#pragma GCC novector + for (d = 0; d < 10; d++) + if (a[i][d] != (i == 3 && d == 6) * 4) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr81815.c b/SingleSource/Regression/C/gcc-dg/vect/pr81815.c new file mode 100644 index 0000000000..79f345a641 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr81815.c @@ -0,0 +1,24 @@ +int __attribute__ ((noinline, noclone)) +f (int *x, int n) +{ + int b = 13; + for (int i = 0; i < n; ++i) + { + int next = x[i]; + b = b < 100 ? next : 200; + } + return b; +} + +static int res[32]; + +int +main (void) +{ + for (int i = 0; i < 32; ++i) + res[i] = i; + res[15] = 100; + if (f (res, 32) != 200) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr82108.c b/SingleSource/Regression/C/gcc-dg/vect/pr82108.c new file mode 100644 index 0000000000..074c416b7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr82108.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +void __attribute__((noinline,noclone)) +downscale_2 (const float* src, int src_n, float* dst) +{ + int i; + + for (i = 0; i < src_n; i += 2) { + const float* a = src; + const float* b = src + 4; + + dst[0] = (a[0] + b[0]) / 2; + dst[1] = (a[1] + b[1]) / 2; + dst[2] = (a[2] + b[2]) / 2; + dst[3] = (a[3] + b[3]) / 2; + + src += 2 * 4; + dst += 4; + } +} + +int main () +{ + const float in[4 * 4] = { + 1, 2, 3, 4, + 5, 6, 7, 8, + + 1, 2, 3, 4, + 5, 6, 7, 8 + }; + float out[2 * 4]; + + check_vect (); + + downscale_2 (in, 4, out); + + if (out[0] != 3 || out[1] != 4 || out[2] != 5 || out[3] != 6 + || out[4] != 3 || out[5] != 4 || out[6] != 5 || out[7] != 6) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr82289.c b/SingleSource/Regression/C/gcc-dg/vect/pr82289.c new file mode 100644 index 0000000000..ae3001f306 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr82289.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ + +int a, b, c, *d, *f[1]; + +void fn1 (int *j) +{ + int e, g, h = 1; + for (; e; e++) + { + if (g > 0) + { + d = j; + return; + } + if (!h) + while (g) + ; + while (h < 1) + if (a) + { + fn1 (&h); + h = 0; + } + f[e] = &c; + } + while (1) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr82436.c b/SingleSource/Regression/C/gcc-dg/vect/pr82436.c new file mode 100644 index 0000000000..4129e15447 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr82436.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast -fno-tree-scev-cprop" } */ +/* { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } } */ + +struct reflection_type +{ + int h; + int k; + int l; + double f_exp; + double f_sigma; + _Complex double f_calc; + double f_pred; + double i_exp; + double i_sigma; + double i_pred; +}; + +double y, w; +int foo (struct reflection_type *r, int n, unsigned s) +{ + int i; + y = 0; + w = 0; + for (i = 1; i < n; ++i) + { + struct reflection_type *x = &r[i*s]; + double fpred = x->f_pred; + double fexp = x->f_exp; + double tem = (fpred - fexp); + y += __builtin_fabs (tem / x->f_sigma); + w += __builtin_fabs (tem / fexp); + } + return i; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr83202-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr83202-1.c new file mode 100644 index 0000000000..ac12f07983 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr83202-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +void test(double data[16][16]) +{ + for (int i = 0; i < 16; i++) + { + for (int j = 0; j < i; j+=4) + { + data[i][j] *= data[i][j]; + data[i][j+1] *= data[i][j+1]; + data[i][j+2] *= data[i][j+2]; + data[i][j+3] *= data[i][j+3]; + } + } +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ +/* { dg-final { scan-tree-dump "ectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr83338.c b/SingleSource/Regression/C/gcc-dg/vect/pr83338.c new file mode 100644 index 0000000000..e266063041 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr83338.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/83338 */ +/* { dg-do compile } */ + +void +foo (char **p, char **q, __PTRDIFF_TYPE__ *r) +{ + int i; + for (i = 0; i < 1024; i++) + r[i] = p[i] - q[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr83857.c b/SingleSource/Regression/C/gcc-dg/vect/pr83857.c new file mode 100644 index 0000000000..f90f5d43a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr83857.c @@ -0,0 +1,29 @@ +/* { dg-additional-options "-ffast-math" } */ + +#define N 100 + +double __attribute__ ((noinline, noclone)) +f (double *x, double y) +{ + double a = 0; + for (int i = 0; i < N; ++i) + { + a += y; + x[i * 2] += a; + x[i * 2 + 1] += a; + } + return a - y; +} + +double x[N * 2]; + +int +main (void) +{ + if (f (x, 5) != (N - 1) * 5) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" { target vect_double } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_double } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr83867.c b/SingleSource/Regression/C/gcc-dg/vect/pr83867.c new file mode 100644 index 0000000000..aab5bb7378 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr83867.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O -ftrapv" } */ + +int +k5 (int u5, int aw) +{ + int v6; + + while (u5 < 1) + { + while (v6 < 4) + ++v6; + + v6 = 0; + aw += u5 > 0; + ++u5; + } + + return aw; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr83914.c b/SingleSource/Regression/C/gcc-dg/vect/pr83914.c new file mode 100644 index 0000000000..0bef7986bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr83914.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +struct s { struct s *ptrs[16]; } *a, *b; +int c; +void +foo (int n) +{ + for (; n; a = b, n--) + { + b = a + 1; + for (c = 8; c; c--) + a->ptrs[c] = b; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr83965-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr83965-2.c new file mode 100644 index 0000000000..b9e3260dbe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr83965-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast -ftrapv" } */ + +int c; +unsigned char d; +int e (unsigned char *f) +{ + int g; + for (int a; a; a++) + { + for (int b = 0; b < 6; b++) + g += __builtin_abs (f[b] - d); + f += c; + } + return g; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr83965.c b/SingleSource/Regression/C/gcc-dg/vect/pr83965.c new file mode 100644 index 0000000000..5bf0f9020d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr83965.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ftrapv" } */ + +int +mac (const short *a, const short *b, int sqr, int *sum) +{ + int i; + int dotp = *sum; + + for (i = 0; i < 150; i++) + { + dotp += b[i] * a[i]; + sqr += b[i] * b[i]; + } + + *sum = dotp; + return sqr; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr84201.c b/SingleSource/Regression/C/gcc-dg/vect/pr84201.c new file mode 100644 index 0000000000..1cc6d1ff13 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr84201.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast --param vect-induction-float=0" } */ + +void foo (float *a, float f, float s, int n) +{ + for (int i = 0; i < n; ++i) + { + a[i] = f; + f += s; + } +} + +void bar (double *a, double f, double s, int n) +{ + for (int i = 0; i < n; ++i) + { + a[i] = f; + f += s; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr84265.c b/SingleSource/Regression/C/gcc-dg/vect/pr84265.c new file mode 100644 index 0000000000..59984aead0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr84265.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +struct a +{ + unsigned long b; + unsigned long c; + int d; + int *e; + char f; +}; + +struct +{ + int g; + struct a h[]; +} i; + +int j, k; +void l () +{ + for (; k; k++) + j += (int) (i.h[k].c - i.h[k].b); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr84357.c b/SingleSource/Regression/C/gcc-dg/vect/pr84357.c new file mode 100644 index 0000000000..cd3cc4a92e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr84357.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wall" } */ + +#define COUNT 32 + +typedef struct s1 { + unsigned char c; +} s1; + +typedef struct s2 +{ + char pad; + s1 arr[COUNT]; +} s2; + +typedef struct s3 { + s1 arr[COUNT]; +} s3; + +s2 * get_s2(); +s3 * gActiveS3; +void foo() +{ + s3 * three = gActiveS3; + s2 * two = get_s2(); + + for (int i = 0; i < COUNT; i++) + { + two->arr[i].c = three->arr[i].c; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr84419.c b/SingleSource/Regression/C/gcc-dg/vect/pr84419.c new file mode 100644 index 0000000000..4864f8eb93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr84419.c @@ -0,0 +1,21 @@ +#include + +#define SIZE 400 + +int foo[SIZE]; +char bar[SIZE]; + +void __attribute__ ((noinline)) foo_func(void) +{ + int i; + for (i = 1; i < SIZE; i++) + if (bar[i]) + foo[i] = 1; +} + +int main() +{ + memset(bar, 1, sizeof(bar)); + foo_func(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr84711.c b/SingleSource/Regression/C/gcc-dg/vect/pr84711.c new file mode 100644 index 0000000000..12e9f60114 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr84711.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-options "-O2 -Wno-psabi" } */ +/* { dg-additional-options "-msse" { target i?86-*-* x86_64-*-* } } */ + +typedef int v4si + __attribute__ ((vector_size (16))); + +int fn1 (v4si p) +{ + return p[0]; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr85286.c b/SingleSource/Regression/C/gcc-dg/vect/pr85286.c new file mode 100644 index 0000000000..320ed6b7e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr85286.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/45241 */ +/* { dg-do compile } */ +/* { dg-additional-options "--param scev-max-expr-complexity=0" } */ + +int +foo (short x) +{ + short i, y; + int sum; + + for (i = 0; i < x; i++) + y = x * i; + + for (i = x; i > 0; i--) + sum += y; + + return sum; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr85586.c b/SingleSource/Regression/C/gcc-dg/vect/pr85586.c new file mode 100644 index 0000000000..a4a170a1fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr85586.c @@ -0,0 +1,45 @@ +#define N 100 + +void __attribute__ ((noipa)) +foo (int *out, int *in, int step) +{ + for (int i = 0; i < N; ++i) + { + out[0] = in[i]; + out[1] = 2; + out += step; + } +} + +int in[N]; +int out[N * 2]; + +int +main (void) +{ + for (int i = 0; i < N; ++i) + { + in[i] = i * (i + 1); + asm volatile ("" ::: "memory"); + } + + foo (out, in, 1); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (out[i] != in[i]) + __builtin_abort (); + if (out[N] != 2) + __builtin_abort (); + + foo (out + N - 1, in, -1); + if (out[0] != in[N - 1]) + __builtin_abort (); +#pragma GCC novector + for (int i = 1; i <= N; ++i) + if (out[i] != 2) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target { { ! vect_no_align } && vect_int } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr85597.c b/SingleSource/Regression/C/gcc-dg/vect/pr85597.c new file mode 100644 index 0000000000..cf615f9c46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr85597.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mfma" { target { x86_64-*-* i?86-*-* } } } */ + +extern double fma (double, double, double); + +static inline void +bar (int i, double *D, double *S) +{ + while (i-- > 0) + { + D[0] = fma (1, S[0], D[0]); + D[1] = fma (1, S[1], D[1]); + D[2] = fma (1, S[2], D[2]); + D[3] = fma (1, S[3], D[3]); + D += 4; + S += 4; + } +} + +void +foo (double *d, double *s) +{ + bar (10, d, s); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr85793.c b/SingleSource/Regression/C/gcc-dg/vect/pr85793.c new file mode 100644 index 0000000000..9b5d518200 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr85793.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_perm } */ + +int a, c, d; +long b[6]; +void fn1() { + for (; a < 2; a++) { + c = 0; + for (; c <= 5; c++) + d &= b[a * 3]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr86749.c b/SingleSource/Regression/C/gcc-dg/vect/pr86749.c new file mode 100644 index 0000000000..803bcb0c62 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr86749.c @@ -0,0 +1,26 @@ +/* { dg-additional-options "-O3" } */ + +#include "tree-vect.h" + +short a, b, f, g; +int c = 4, d, e = -1L; +long h = 4; + +int +main () +{ + check_vect (); + + long i; + for (; d <= 55; d++) + { + g = c >= 2 ? 0 : b << c; + f = g - a; + i = (f ^ 9223372036854775807) < 0 ? f : h; + e &= i; + } + if (e != 4) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr86858.c b/SingleSource/Regression/C/gcc-dg/vect/pr86858.c new file mode 100644 index 0000000000..6c3c6eca7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr86858.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +int a, b, c, d; +char e(char f, char g) { return f + g; } +void h() { + for (; c; ++c) { + d = 0; + for (; d != 8; d = e(d, 3)) { + a = b && a; + b = c; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr86871.c b/SingleSource/Regression/C/gcc-dg/vect/pr86871.c new file mode 100644 index 0000000000..a1816819e4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr86871.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +extern int b[]; +extern int c[]; +void g(int f) { + for (; f; f++) { + int d = 0; + for (int e = -1; e <= 1; e++) { + int a = f + e; + if (a) + d = *(c + a); + } + *(b + f) = d; + } + } diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr86927.c b/SingleSource/Regression/C/gcc-dg/vect/pr86927.c new file mode 100644 index 0000000000..794092bc4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr86927.c @@ -0,0 +1,15 @@ +#include "tree-vect.h" + +int a[28]; +int main() +{ + check_vect (); + a[4] = 1; + int c = 1; + for (int b = 0; b < 8; b++) + if (a[b]) + c = 0; + if (c) + abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr87288-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr87288-1.c new file mode 100644 index 0000000000..ec968dfcd0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr87288-1.c @@ -0,0 +1,50 @@ +#include "tree-vect.h" + +#define N (VECTOR_BITS / 32) +#define MAX_COUNT 4 + +void __attribute__ ((noipa)) +run (int *restrict a, int *restrict b, int count) +{ + for (int i = 0; i < count * N; ++i) + { + a[i * 2] = b[i * 2] + count; + a[i * 2 + 1] = count; + } +} + +void __attribute__ ((noipa)) +check (int *restrict a, int count) +{ +#pragma GCC novector + for (int i = 0; i < count * N; ++i) + if (a[i * 2] != i * 41 + count || a[i * 2 + 1] != count) + __builtin_abort (); + if (a[count * 2 * N] != 999) + __builtin_abort (); +} + +int a[N * MAX_COUNT * 2 + 1], b[N * MAX_COUNT * 2]; + +int +main (void) +{ + check_vect (); + + for (int i = 0; i < N * MAX_COUNT; ++i) + { + b[i * 2] = i * 41; + asm volatile ("" ::: "memory"); + } + + for (int i = 0; i <= MAX_COUNT; ++i) + { + a[i * 2 * N] = 999; + run (a, b, i); + check (a, i); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times {LOOP VECTORIZED} 1 "vect" { target { { vect_int && vect_perm } && vect_element_align } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr87288-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr87288-2.c new file mode 100644 index 0000000000..03c7f88a6a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr87288-2.c @@ -0,0 +1,65 @@ +#include "tree-vect.h" + +#define N (VECTOR_BITS / 32) +#define MAX_COUNT 4 + +#define RUN_COUNT(COUNT) \ + void __attribute__ ((noipa)) \ + run_##COUNT (int *restrict a, int *restrict b) \ + { \ + for (int i = 0; i < N * COUNT; ++i) \ + { \ + a[i * 2] = b[i * 2] + COUNT; \ + a[i * 2 + 1] = COUNT; \ + } \ + } + +RUN_COUNT (1) +RUN_COUNT (2) +RUN_COUNT (3) +RUN_COUNT (4) + +void __attribute__ ((noipa)) +check (int *restrict a, int count) +{ +#pragma GCC novector + for (int i = 0; i < count * N; ++i) + if (a[i * 2] != i * 41 + count || a[i * 2 + 1] != count) + __builtin_abort (); + if (a[count * 2 * N] != 999) + __builtin_abort (); +} + +int a[N * MAX_COUNT * 2 + 1], b[N * MAX_COUNT * 2]; + +int +main (void) +{ + check_vect (); + + for (int i = 0; i < N * MAX_COUNT; ++i) + { + b[i * 2] = i * 41; + asm volatile ("" ::: "memory"); + } + + a[N * 2] = 999; + run_1 (a, b); + check (a, 1); + + a[N * 4] = 999; + run_2 (a, b); + check (a, 2); + + a[N * 6] = 999; + run_3 (a, b); + check (a, 3); + + a[N * 8] = 999; + run_4 (a, b); + check (a, 4); + + return 0; +} + +/* { dg-final { scan-tree-dump {LOOP VECTORIZED} "vect" { target { { vect_int && vect_perm } && vect_element_align } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr87288-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr87288-3.c new file mode 100644 index 0000000000..0475990992 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr87288-3.c @@ -0,0 +1,65 @@ +#include "tree-vect.h" + +#define N (VECTOR_BITS / 32) +#define MAX_COUNT 4 + +#define RUN_COUNT(COUNT) \ + void __attribute__ ((noipa)) \ + run_##COUNT (int *restrict a, int *restrict b) \ + { \ + for (int i = 0; i < N * COUNT + 1; ++i) \ + { \ + a[i * 2] = b[i * 2] + COUNT; \ + a[i * 2 + 1] = COUNT; \ + } \ + } + +RUN_COUNT (1) +RUN_COUNT (2) +RUN_COUNT (3) +RUN_COUNT (4) + +void __attribute__ ((noipa)) +check (int *restrict a, int count) +{ +#pragma GCC novector + for (int i = 0; i < count * N + 1; ++i) + if (a[i * 2] != i * 41 + count || a[i * 2 + 1] != count) + __builtin_abort (); + if (a[count * 2 * N + 2] != 999) + __builtin_abort (); +} + +int a[N * MAX_COUNT * 2 + 3], b[N * MAX_COUNT * 2 + 2]; + +int +main (void) +{ + check_vect (); + + for (int i = 0; i < N * MAX_COUNT + 1; ++i) + { + b[i * 2] = i * 41; + asm volatile ("" ::: "memory"); + } + + a[N * 2 + 2] = 999; + run_1 (a, b); + check (a, 1); + + a[N * 4 + 2] = 999; + run_2 (a, b); + check (a, 2); + + a[N * 6 + 2] = 999; + run_3 (a, b); + check (a, 3); + + a[N * 8 + 2] = 999; + run_4 (a, b); + check (a, 4); + + return 0; +} + +/* { dg-final { scan-tree-dump {LOOP VECTORIZED} "vect" { target { { vect_int && vect_perm } && vect_element_align } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88497-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr88497-1.c new file mode 100644 index 0000000000..885ec70942 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88497-1.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vsx_hw { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target sse2_runtime { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-reassoc1" } */ +/* { dg-additional-options "-mvsx" { target { powerpc*-*-* } } } */ +/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */ + +/* To test reassoc can undistribute vector bit_field_ref summation. + + arg1 and arg2 are two arrays whose elements of type vector double. + Assuming: + A0 = arg1[0], A1 = arg1[1], A2 = arg1[2], A3 = arg1[3], + B0 = arg2[0], B1 = arg2[1], B2 = arg2[2], B3 = arg2[3], + + Then: + V0 = A0 * B0, V1 = A1 * B1, V2 = A2 * B2, V3 = A3 * B3, + + reassoc transforms + + accumulator += V0[0] + V0[1] + V1[0] + V1[1] + V2[0] + V2[1] + + V3[0] + V3[1]; + + into: + + T = V0 + V1 + V2 + V3 + accumulator += T[0] + T[1]; + + Fewer bit_field_refs, only two for 128 or more bits vector. */ + +typedef double v2df __attribute__ ((vector_size (16))); +__attribute__ ((noinline)) double +test (double accumulator, v2df arg1[], v2df arg2[]) +{ + v2df temp; + temp = arg1[0] * arg2[0]; + accumulator += temp[0] + temp[1]; + temp = arg1[1] * arg2[1]; + accumulator += temp[0] + temp[1]; + temp = arg1[2] * arg2[2]; + accumulator += temp[0] + temp[1]; + temp = arg1[3] * arg2[3]; + accumulator += temp[0] + temp[1]; + return accumulator; +} + +extern void abort (void); + +int +main () +{ + v2df v2[4] = {{1.0, 2.0}, {4.0, 8.0}, {1.0, 3.0}, {9.0, 27.0}}; + v2df v3[4] = {{1.0, 4.0}, {16.0, 64.0}, {1.0, 2.0}, {3.0, 4.0}}; + double acc = 100.0; + double res = test (acc, v2, v3); + if (res != 827.0) + abort (); + return 0; +} +/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 2 "reassoc1" { target { powerpc*-*-* i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88497-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr88497-2.c new file mode 100644 index 0000000000..8da5920903 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88497-2.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target powerpc_altivec_ok { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target sse2 { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-reassoc1" } */ +/* { dg-additional-options "-maltivec" { target { powerpc*-*-* } } } */ +/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */ + +/* To test reassoc can undistribute vector bit_field_ref on multiplication. + + v1, v2, v3, v4 of type vector float. + + reassoc transforms + + accumulator *= v1[0] * v1[1] * v1[2] * v1[3] * + v2[0] * v2[1] * v2[2] * v2[3] * + v3[0] * v3[1] * v3[2] * v3[3] * + v4[0] * v4[1] * v4[2] * v4[3] ; + + into: + + T = v1 * v2 * v3 * v4; + accumulator *= T[0] * T[1] * T[2] * T[3]; + + Fewer bit_field_refs, only four for 128 or more bits vector. */ + +typedef float v4sf __attribute__ ((vector_size (16))); +float +test (float accumulator, v4sf v1, v4sf v2, v4sf v3, v4sf v4) +{ + accumulator *= v1[0] * v1[1] * v1[2] * v1[3]; + accumulator *= v2[0] * v2[1] * v2[2] * v2[3]; + accumulator *= v3[0] * v3[1] * v3[2] * v3[3]; + accumulator *= v4[0] * v4[1] * v4[2] * v4[3]; + return accumulator; +} +/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 4 "reassoc1" { target { powerpc*-*-* i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88497-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr88497-3.c new file mode 100644 index 0000000000..449f282e85 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88497-3.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target powerpc_altivec_ok { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target sse2 { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-reassoc1" } */ +/* { dg-additional-options "-maltivec" { target { powerpc*-*-* } } } */ +/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */ + +/* To test reassoc can undistribute vector bit_field_ref on bitwise AND. + + v1, v2, v3, v4 of type vector int. + + reassoc transforms + + accumulator &= v1[0] & v1[1] & v1[2] & v1[3] & + v2[0] & v2[1] & v2[2] & v2[3] & + v3[0] & v3[1] & v3[2] & v3[3] & + v4[0] & v4[1] & v4[2] & v4[3] ; + + into: + + T = v1 & v2 & v3 & v4; + accumulator &= T[0] & T[1] & T[2] & T[3]; + + Fewer bit_field_refs, only four for 128 or more bits vector. */ + +typedef int v4si __attribute__ ((vector_size (16))); +int +test (int accumulator, v4si v1, v4si v2, v4si v3, v4si v4) +{ + accumulator &= v1[0] & v1[1] & v1[2] & v1[3]; + accumulator &= v2[0] & v2[1] & v2[2] & v2[3]; + accumulator &= v3[0] & v3[1] & v3[2] & v3[3]; + accumulator &= v4[0] & v4[1] & v4[2] & v4[3]; + return accumulator; +} +/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 4 "reassoc1" { target { powerpc*-*-* i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88497-4.c b/SingleSource/Regression/C/gcc-dg/vect/pr88497-4.c new file mode 100644 index 0000000000..f7b6c91c91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88497-4.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target powerpc_altivec_ok { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target sse2 { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-reassoc1" } */ +/* { dg-additional-options "-maltivec" { target { powerpc*-*-* } } } */ +/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */ + +/* To test reassoc can undistribute vector bit_field_ref on bitwise IOR. + + v1, v2, v3, v4 of type vector int. + + reassoc transforms + + accumulator |= v1[0] | v1[1] | v1[2] | v1[3] | + v2[0] | v2[1] | v2[2] | v2[3] | + v3[0] | v3[1] | v3[2] | v3[3] | + v4[0] | v4[1] | v4[2] | v4[3] ; + + into: + + T = v1 | v2 | v3 | v4; + accumulator |= T[0] | T[1] | T[2] | T[3]; + + Fewer bit_field_refs, only four for 128 or more bits vector. */ + +typedef int v4si __attribute__ ((vector_size (16))); +int +test (int accumulator, v4si v1, v4si v2, v4si v3, v4si v4) +{ + accumulator |= v1[0] | v1[1] | v1[2] | v1[3]; + accumulator |= v2[0] | v2[1] | v2[2] | v2[3]; + accumulator |= v3[0] | v3[1] | v3[2] | v3[3]; + accumulator |= v4[0] | v4[1] | v4[2] | v4[3]; + return accumulator; +} +/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 4 "reassoc1" { target { powerpc*-*-* i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88497-5.c b/SingleSource/Regression/C/gcc-dg/vect/pr88497-5.c new file mode 100644 index 0000000000..cbd12241c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88497-5.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target powerpc_altivec_ok { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target sse2 { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2 -ffast-math -fdump-tree-reassoc1" } */ +/* { dg-additional-options "-maltivec" { target { powerpc*-*-* } } } */ +/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */ + +/* To test reassoc can undistribute vector bit_field_ref on bitwise XOR. + + v1, v2, v3, v4 of type vector int. + + reassoc transforms + + accumulator ^= v1[0] ^ v1[1] ^ v1[2] ^ v1[3] ^ + v2[0] ^ v2[1] ^ v2[2] ^ v2[3] ^ + v3[0] ^ v3[1] ^ v3[2] ^ v3[3] ^ + v4[0] ^ v4[1] ^ v4[2] ^ v4[3] ; + + into: + + T = v1 ^ v2 ^ v3 ^ v4; + accumulator ^= T[0] ^ T[1] ^ T[2] ^ T[3]; + + Fewer bit_field_refs, only four for 128 or more bits vector. */ + +typedef int v4si __attribute__ ((vector_size (16))); +int +test (int accumulator, v4si v1, v4si v2, v4si v3, v4si v4) +{ + accumulator ^= v1[0] ^ v1[1] ^ v1[2] ^ v1[3]; + accumulator ^= v2[0] ^ v2[1] ^ v2[2] ^ v2[3]; + accumulator ^= v3[0] ^ v3[1] ^ v3[2] ^ v3[3]; + accumulator ^= v4[0] ^ v4[1] ^ v4[2] ^ v4[3]; + return accumulator; +} +/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 4 "reassoc1" { target { powerpc*-*-* i?86-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88497-6.c b/SingleSource/Regression/C/gcc-dg/vect/pr88497-6.c new file mode 100644 index 0000000000..0146518a98 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88497-6.c @@ -0,0 +1,65 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target avx512f } */ +/* { dg-options "-O2 -mavx512f -ffast-math -fdump-tree-reassoc1" } */ + +/* To test reassoc can undistribute vector bit_field_ref on multiple + vector machine modes. + + v1, v2 of type vector 4 x float + v3, v4 of type vector 8 x float + v5, v6 of type vector 16 x float + + reassoc transforms + + accumulator += v1[0] + v1[1] + v1[2] + v1[3] + + v2[0] + v2[1] + v2[2] + v2[3] + + v3[0] + v3[1] + v3[2] + v3[3] + + v3[4] + v3[5] + v3[6] + v3[7] + + v4[0] + v4[1] + v4[2] + v4[3] + + v4[4] + v4[5] + v4[6] + v4[7] + + v5[0] + v5[1] + v5[2] + v5[3] + + v5[4] + v5[5] + v5[6] + v5[7] + + v5[8] + v5[9] + v5[10] + v5[11] + + v5[12] + v5[13] + v5[14] + v5[15] + + v6[0] + v6[1] + v6[2] + v6[3] + + v6[4] + v6[5] + v6[6] + v6[7] + + v6[8] + v6[9] + v6[10] + v6[11] + + v6[12] + v6[13] + v6[14] + v6[15] ; + + into: + + T12 = v1 + v2; + T34 = v3 + v4; + T56 = v5 + v6; + accumulator += T12[0] + T12[1] + T12[2] + T12[3] + + accumulator += T34[0] + T34[1] + T34[2] + T34[3] + + accumulator += T34[4] + T34[5] + T34[6] + T34[7] + + accumulator += T56[0] + T56[1] + T56[2] + T56[3] + + accumulator += T56[4] + T56[5] + T56[6] + T56[7] + + accumulator += T56[8] + T56[9] + T56[10] + T56[11] + + accumulator += T56[12] + T56[13] + T56[14] + T56[15] ; */ + +typedef float v4sf __attribute__((vector_size(16))); +typedef float v8sf __attribute__((vector_size(32))); +typedef float v16sf __attribute__((vector_size(64))); + +float +test (float accumulator, v4sf v1, v4sf v2, v8sf v3, v8sf v4, v16sf v5, v16sf v6) +{ + accumulator += v1[0] + v1[1] + v1[2] + v1[3]; + accumulator += v2[0] + v2[1] + v2[2] + v2[3]; + accumulator += v3[0] + v3[1] + v3[2] + v3[3]; + accumulator += v3[4] + v3[5] + v3[6] + v3[7]; + accumulator += v4[0] + v4[1] + v4[2] + v4[3]; + accumulator += v4[4] + v4[5] + v4[6] + v4[7]; + accumulator += v5[0] + v5[1] + v5[2] + v5[3]; + accumulator += v5[4] + v5[5] + v5[6] + v5[7]; + accumulator += v5[8] + v5[9] + v5[10] + v5[11]; + accumulator += v5[12] + v5[13] + v5[14] + v5[15]; + accumulator += v6[0] + v6[1] + v6[2] + v6[3]; + accumulator += v6[4] + v6[5] + v6[6] + v6[7]; + accumulator += v6[8] + v6[9] + v6[10] + v6[11]; + accumulator += v6[12] + v6[13] + v6[14] + v6[15]; + return accumulator; +} +/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 28 "reassoc1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88497-7.c b/SingleSource/Regression/C/gcc-dg/vect/pr88497-7.c new file mode 100644 index 0000000000..d20ed71284 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88497-7.c @@ -0,0 +1,76 @@ +/* { dg-require-effective-target avx512f_runtime } */ +/* { dg-options "-O2 -mavx512f -ffast-math -fdump-tree-reassoc1" } */ + +/* To test reassoc can undistribute vector bit_field_ref on multiple + vector machine modes, bypass those modes with only one candidate. + + v1, v2 of type vector 4 x float + v3 of type vector 8 x float + v5, v6 of type vector 16 x float + + reassoc transforms + + accumulator += v1[0] + v1[1] + v1[2] + v1[3] + + v2[0] + v2[1] + v2[2] + v2[3] + + v3[0] + v3[1] + v3[2] + v3[3] + + v3[4] + v3[5] + v3[6] + v3[7] + + v5[0] + v5[1] + v5[2] + v5[3] + + v5[4] + v5[5] + v5[6] + v5[7] + + v5[8] + v5[9] + v5[10] + v5[11] + + v5[12] + v5[13] + v5[14] + v5[15] + + v6[0] + v6[1] + v6[2] + v6[3] + + v6[4] + v6[5] + v6[6] + v6[7] + + v6[8] + v6[9] + v6[10] + v6[11] + + v6[12] + v6[13] + v6[14] + v6[15] ; + + into: + + T12 = v1 + v2; + T56 = v5 + v6; + accumulator += T12[0] + T12[1] + T12[2] + T12[3] + + accumulator += v3[0] + v3[1] + v3[2] + v3[3] + + accumulator += v3[4] + v3[5] + v3[6] + v3[7] + + accumulator += T56[0] + T56[1] + T56[2] + T56[3] + + accumulator += T56[4] + T56[5] + T56[6] + T56[7] + + accumulator += T56[8] + T56[9] + T56[10] + T56[11] + + accumulator += T56[12] + T56[13] + T56[14] + T56[15] ; */ + +typedef float v4sf __attribute__((vector_size(16))); +typedef float v8sf __attribute__((vector_size(32))); +typedef float v16sf __attribute__((vector_size(64))); + +__attribute__ ((noinline)) +float test(float accumulator, v4sf v1, v4sf v2, v8sf v3, v16sf v5, v16sf v6) { + accumulator += v1[0] + v1[1] + v1[2] + v1[3]; + accumulator += v2[0] + v2[1] + v2[2] + v2[3]; + accumulator += v3[0] + v3[1] + v3[2] + v3[3]; + accumulator += v3[4] + v3[5] + v3[6] + v3[7]; + accumulator += v5[0] + v5[1] + v5[2] + v5[3]; + accumulator += v5[4] + v5[5] + v5[6] + v5[7]; + accumulator += v5[8] + v5[9] + v5[10] + v5[11]; + accumulator += v5[12] + v5[13] + v5[14] + v5[15]; + accumulator += v6[0] + v6[1] + v6[2] + v6[3]; + accumulator += v6[4] + v6[5] + v6[6] + v6[7]; + accumulator += v6[8] + v6[9] + v6[10] + v6[11]; + accumulator += v6[12] + v6[13] + v6[14] + v6[15]; + return accumulator; +} + +extern void abort (void); + +int +main () +{ + v4sf v1 = {1.0, 2.0, 3.0, 4.0 }; + v4sf v2 = {5.0, 6.0, 7.0, 8.0 }; + v8sf v3 = {9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 }; + v16sf v5 = {17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0}; + v16sf v6 = {33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0}; + float acc = 24.0; + double res = test (acc, v1, v2, v3, v5, v6); + if (res != 1200.0) + abort(); + return 0; +} + +/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 28 "reassoc1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88598-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr88598-1.c new file mode 100644 index 0000000000..d4a0014f54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88598-1.c @@ -0,0 +1,54 @@ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N 4 + +int a[N]; + +int __attribute__ ((noipa)) +f1 (void) +{ + int b[N] = { 15, 0, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] & b[i]; + return res; +} + +int __attribute__ ((noipa)) +f2 (void) +{ + int b[N] = { 0, 31, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] & b[i]; + return res; +} + +int __attribute__ ((noipa)) +f3 (void) +{ + int b[N] = { 0, 0, 0, -1 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] & b[i]; + return res; +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < N; ++i) + a[i] = 0xe0 + i; + + if (f1 () != (a[0] & 15) + || f2 () != (a[1] & 31) + || f3 () != a[N - 1]) + __builtin_abort (); + + return 0; +} + +/* ??? We need more constant folding for this to work with fully-masked + loops. */ +/* { dg-final { scan-tree-dump-not {REDUC_PLUS} "optimized" { xfail { aarch64_sve || riscv_v } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88598-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr88598-2.c new file mode 100644 index 0000000000..57d0c885be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88598-2.c @@ -0,0 +1,54 @@ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N 4 + +int a[N]; + +int __attribute__ ((noipa)) +f1 (void) +{ + int b[N] = { 1, 0, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +int __attribute__ ((noipa)) +f2 (void) +{ + int b[N] = { 0, 1, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +int __attribute__ ((noipa)) +f3 (void) +{ + int b[N] = { 0, 0, 0, 1 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < N; ++i) + a[i] = 0xe0 + i; + + if (f1 () != a[0] + || f2 () != a[1] + || f3 () != a[N - 1]) + __builtin_abort (); + + return 0; +} + +/* ??? We need more constant folding for this to work with fully-masked + loops. */ +/* { dg-final { scan-tree-dump-not {REDUC_PLUS} "optimized" { xfail { aarch64_sve || riscv_v } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88598-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr88598-3.c new file mode 100644 index 0000000000..ee3a9effd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88598-3.c @@ -0,0 +1,54 @@ +/* { dg-additional-options "-ffast-math -fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N 4 + +float a[N]; + +float __attribute__ ((noipa)) +f1 (void) +{ + float b[N] = { 1, 0, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +float __attribute__ ((noipa)) +f2 (void) +{ + float b[N] = { 0, 1, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +float __attribute__ ((noipa)) +f3 (void) +{ + float b[N] = { 0, 0, 0, 1 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < N; ++i) + a[i] = 0xe0 + i; + + if (f1 () != a[0] + || f2 () != a[1] + || f3 () != a[N - 1]) + __builtin_abort (); + + return 0; +} + +/* ??? We need more constant folding for this to work with fully-masked + loops. */ +/* { dg-final { scan-tree-dump-not {REDUC_PLUS} "optimized" { xfail { aarch64_sve || riscv_v } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88598-4.c b/SingleSource/Regression/C/gcc-dg/vect/pr88598-4.c new file mode 100644 index 0000000000..08923b93c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88598-4.c @@ -0,0 +1,50 @@ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N 4 + +int a[N]; + +int __attribute__ ((noipa)) +f1 (void) +{ + int b[N] = { 0, 15, 15, 15 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] & b[i]; + return res; +} + +int __attribute__ ((noipa)) +f2 (void) +{ + int b[N] = { 0, 31, 0, 31 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] & b[i]; + return res; +} + +int __attribute__ ((noipa)) +f3 (void) +{ + int b[N] = { -1, -1, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] & b[i]; + return res; +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < N; ++i) + a[i] = 0xe0 + i; + + if (f1 () != (a[1] & 15) + (a[2] & 15) + (a[3] & 15) + || f2 () != (a[1] & 31) + (a[3] & 31) + || f3 () != a[0] + a[1]) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88598-5.c b/SingleSource/Regression/C/gcc-dg/vect/pr88598-5.c new file mode 100644 index 0000000000..929b40bc46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88598-5.c @@ -0,0 +1,50 @@ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N 4 + +int a[N]; + +int __attribute__ ((noipa)) +f1 (void) +{ + int b[N] = { 0, 1, 1, 1 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +int __attribute__ ((noipa)) +f2 (void) +{ + int b[N] = { 0, 1, 0, 1 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +int __attribute__ ((noipa)) +f3 (void) +{ + int b[N] = { 1, 1, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < N; ++i) + a[i] = 0xe0 + i; + + if (f1 () != a[1] + a[2] + a[3] + || f2 () != a[1] + a[3] + || f3 () != a[0] + a[1]) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88598-6.c b/SingleSource/Regression/C/gcc-dg/vect/pr88598-6.c new file mode 100644 index 0000000000..2d6e0d73fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88598-6.c @@ -0,0 +1,50 @@ +/* { dg-additional-options "-ffast-math -fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N 4 + +float a[N]; + +float __attribute__ ((noipa)) +f1 (void) +{ + float b[N] = { 0, 1, 1, 1 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +float __attribute__ ((noipa)) +f2 (void) +{ + float b[N] = { 0, 1, 0, 1 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +float __attribute__ ((noipa)) +f3 (void) +{ + float b[N] = { 1, 1, 0, 0 }, res = 0; + for (int i = 0; i < N; ++i) + res += a[i] * b[i]; + return res; +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < N; ++i) + a[i] = 0xe0 + i; + + if (f1 () != a[1] + a[2] + a[3] + || f2 () != a[1] + a[3] + || f3 () != a[0] + a[1]) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88903-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr88903-1.c new file mode 100644 index 0000000000..0f78ccc995 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88903-1.c @@ -0,0 +1,27 @@ +#include "tree-vect.h" + +int x[1024]; + +void __attribute__((noinline)) +foo() +{ + for (int i = 0; i < 512; ++i) + { + x[2*i] = x[2*i] << ((i+1) & 31); + x[2*i+1] = x[2*i+1] << ((i+1) & 31); + } +} + +int +main() +{ + check_vect (); + for (int i = 0; i < 1024; ++i) + x[i] = i; + foo (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != i << ((i/2+1) & 31)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr88903-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr88903-2.c new file mode 100644 index 0000000000..8a1cf9c523 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr88903-2.c @@ -0,0 +1,29 @@ +#include "tree-vect.h" + +int x[1024]; +int y[1024]; +int z[1024]; + +void __attribute__((noinline)) foo() +{ + for (int i = 0; i < 512; ++i) + { + x[2*i] = x[2*i] << y[2*i]; + x[2*i+1] = x[2*i+1] << y[2*i]; + z[2*i] = y[2*i]; + z[2*i+1] = y[2*i+1]; + } +} + +int main() +{ + check_vect (); + for (int i = 0; i < 1024; ++i) + x[i] = i, y[i] = i % 8; + foo (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != i << ((i & ~1) % 8)) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr89268.c b/SingleSource/Regression/C/gcc-dg/vect/pr89268.c new file mode 100644 index 0000000000..35875ff06a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr89268.c @@ -0,0 +1,7 @@ +/* PR tree-optimization/89268 */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ +/* { dg-additional-options "-fno-trapping-math --param vect-epilogues-nomask=1" } */ +/* { dg-additional-options "-mavx512ifma -mtune=intel" { target x86_64-*-* i?86-*-* } } */ + +#include "pr79887.c" diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr89440.c b/SingleSource/Regression/C/gcc-dg/vect/pr89440.c new file mode 100644 index 0000000000..d84527edb4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr89440.c @@ -0,0 +1,31 @@ +/* { dg-additional-options "-ffast-math" } */ + +#include "tree-vect.h" + +float __attribute__((noinline,noclone)) +f (float x) +{ + int i; + float j; + float a = 0; + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 4; ++j) + { + a += 1; + x += a; + } + } + return x; +} + +int +main() +{ + check_vect (); + if (f (1.0f) != 137.0f) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" { target vect_float } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr90018.c b/SingleSource/Regression/C/gcc-dg/vect/pr90018.c new file mode 100644 index 0000000000..08ca326f7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr90018.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_double } */ + +#include "tree-vect.h" + +void __attribute__((noinline,noclone)) +foo (double *a4, int n) +{ + for (int i = 0; i < n; ++i) + { + /* We may not apply interleaving to the group (a), (b) because of (c). + Instead group (d) and (b). */ + double tem1 = a4[i*4] + a4[i*4+n*4] /* (a) */; + double tem2 = a4[i*4+2*n*4+1]; + a4[i*4+n*4+1] = tem1; /* (c) */ + a4[i*4+1] = tem2; + double tem3 = a4[i*4] - tem2; + double tem4 = tem3 + a4[i*4+n*4] /* (d) */; + a4[i*4+n*4+1] = tem4 + a4[i*4+n*4+1] /* (b) */; + } +} +int main(int argc, char **argv) +{ + int n = 11; + double a4[4 * n * 3]; + double a42[4 * n * 3]; + check_vect (); + for (int i = 0; i < 4 * n * 3; ++i) + { + a4[i] = a42[i] = i; + __asm__ volatile ("": : : "memory"); + } + foo (a4, n); + for (int i = 0; i < n; ++i) + { + double tem1 = a42[i*4] + a42[i*4+n*4]; + double tem2 = a42[i*4+2*n*4+1]; + a42[i*4+n*4+1] = tem1; + a42[i*4+1] = tem2; + double tem3 = a42[i*4] - tem2; + double tem4 = tem3 + a42[i*4+n*4]; + a42[i*4+n*4+1] = tem4 + a42[i*4+n*4+1]; + __asm__ volatile ("": : : "memory"); + } +#pragma GCC novector + for (int i = 0; i < 4 * n * 3; ++i) + if (a4[i] != a42[i]) + __builtin_abort (); + return 0; +} + +/* For v2df we try to use SLP and fail miserably. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sizes_32B_16B } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr91114.c b/SingleSource/Regression/C/gcc-dg/vect/pr91114.c new file mode 100644 index 0000000000..3343d1e0d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr91114.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +void +ne (double *zu) +{ + int h3; + +#pragma omp simd simdlen (4) + for (h3 = 0; h3 < 4; ++h3) + zu[h3] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr91293-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr91293-1.c new file mode 100644 index 0000000000..e05b5b9c6e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr91293-1.c @@ -0,0 +1,18 @@ +/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */ + +long long a; +unsigned b, c; +int d = 62; +void e(long long *f, int p2) { *f = p2; } +int main() +{ + for (int g = 2; g <= d; g++) + { + b += g + 4; + c += 5 - g; + } + e(&a, b); + if (a != 2196) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr91293-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr91293-2.c new file mode 100644 index 0000000000..d01e6ff2aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr91293-2.c @@ -0,0 +1,18 @@ +/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */ + +long long a; +unsigned b, c; +int d = 62; +void e(long long *f, int p2) { *f = p2; } +int main() +{ + for (int g = 2; g <= d; g++) + { + c += 5 - g; + b += g + 4; + } + e(&a, b); + if (a != 2196) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr91293-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr91293-3.c new file mode 100644 index 0000000000..64490f48a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr91293-3.c @@ -0,0 +1,19 @@ +/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */ + +long long a; +unsigned b, c; +int d = 62; +void e(long long *f, int p2) { *f = p2; } +int xx = 5, yy = 4; +int main() +{ + for (int g = 2; g <= d; g++) + { + c += xx - g; + b += yy + g; + } + e(&a, b); + if (a != 2196) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr91403.c b/SingleSource/Regression/C/gcc-dg/vect/pr91403.c new file mode 100644 index 0000000000..5b9b76060a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr91403.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +extern int a[][1000000]; +int b; +void c() +{ + for (int d = 2; d <= 9; d++) + for (int e = 32; e <= 41; e++) + b += a[d][5]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr91665.c b/SingleSource/Regression/C/gcc-dg/vect/pr91665.c new file mode 100644 index 0000000000..6b69ea030b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr91665.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/91665 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ + +short int v; + +void +foo (short int x, short int y) +{ + short int *p = &v; + + x = 1; + while (x != 0) + x += ++y || (*p = x); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr91750.c b/SingleSource/Regression/C/gcc-dg/vect/pr91750.c new file mode 100644 index 0000000000..3586f1168a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr91750.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int val[1024]; +void +foo (int n) +{ + int i; + for (int j = 0, i = n; j < 1024; ++j, i=(unsigned)i+1) + val[j] = i; +} + +/* Make sure the induction IV uses an unsigned increment. */ +/* { dg-final { scan-tree-dump {vector\([][0-9,]*\) unsigned int} "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92205.c b/SingleSource/Regression/C/gcc-dg/vect/pr92205.c new file mode 100644 index 0000000000..ea06660de1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92205.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int b(int n, unsigned char *a) +{ + int d = 0; + a = __builtin_assume_aligned (a, __BIGGEST_ALIGNMENT__); + for (int c = 0; c < n; ++c) + d |= a[c]; + return d; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_unpack && { ! vect_no_bitwise } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92324-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr92324-1.c new file mode 100644 index 0000000000..e37fa781dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92324-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +unsigned a, b; +int c, d; +unsigned e(int f) { + if (a > f) + return a; + return f; +} +void g() { + for (; c; c++) + d = e(d); + b = d; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92324-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr92324-2.c new file mode 100644 index 0000000000..c7805fc62d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92324-2.c @@ -0,0 +1,21 @@ +#include "tree-vect.h" + +unsigned b[1024]; + +int __attribute__((noipa)) +foo (int n) +{ + int res = 0; + for (int i = 0; i < n; ++i) + res = res > b[i] ? res : b[i]; + return res; +} + +int main () +{ + check_vect (); + b[15] = (unsigned)__INT_MAX__ + 1; + if (foo (16) != -__INT_MAX__ - 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92324-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr92324-3.c new file mode 100644 index 0000000000..db5c399d4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92324-3.c @@ -0,0 +1,27 @@ +#include "tree-vect.h" + +int a[1024]; +unsigned b[1024]; + +int __attribute__((noipa)) +foo (int n) +{ + int res = 0; + for (int i = 0; i < n; ++i) + { + res = res > a[i] ? res : a[i]; + res = res > b[i] ? res : b[i]; + } + return res; +} + +int main () +{ + check_vect (); + b[3] = (unsigned)__INT_MAX__ + 1; + if (foo (4) != -__INT_MAX__ - 1) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "vectorized \[1-9\] loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92324-4.c b/SingleSource/Regression/C/gcc-dg/vect/pr92324-4.c new file mode 100644 index 0000000000..57e117ca10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92324-4.c @@ -0,0 +1,32 @@ +#include "tree-vect.h" + +unsigned a[1024]; +int gres1, gres2; + +int __attribute__((noipa)) +foo (int n) +{ + int res1 = 0; + int res2 = 0; + for (int i = 0; i < n; ++i) + { + res1 = res1 > a[2*i] ? res1 : a[2*i]; + res2 = res2 > a[2*i+1] ? res2 : a[2*i+1]; + } + gres1 = res1; + gres2 = res2; +} + +int main () +{ + check_vect (); + a[30] = (unsigned)__INT_MAX__ + 1; + a[31] = (unsigned)__INT_MAX__ + 1; + foo (16); + if (gres1 != -__INT_MAX__ - 1 + || gres2 != -__INT_MAX__ - 1) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92347.c b/SingleSource/Regression/C/gcc-dg/vect/pr92347.c new file mode 100644 index 0000000000..f75b2596a2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92347.c @@ -0,0 +1,18 @@ +/* Copied from PR 92347. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target { i?86-*-* x86_64-*-* } } } */ + +int by; + +#pragma omp declare simd +int +zp (int); + +void +qh (int oh) +{ +#pragma omp simd + for (by = 0; by < oh; ++by) + by = zp (by); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92420.c b/SingleSource/Regression/C/gcc-dg/vect/pr92420.c new file mode 100644 index 0000000000..e56eb0e12f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92420.c @@ -0,0 +1,49 @@ +/* { dg-additional-options "-mavx2" { target avx_runtime } } */ + +#include "tree-vect.h" + +#define N 16 +struct C { int r, i; }; +struct C a[N], b[N], c[N], d[N], e[N]; + +__attribute__((noipa)) static void +foo (struct C *__restrict x, struct C *__restrict y, struct C *__restrict z, int w) +{ + int i; + for (int i = 0; i < w; i++) + { + z[i].r = x[i].r * y[-1 - i].r - x[i].i * y[-1 - i].i; + z[i].i = x[i].i * y[-1 - i].r + x[i].r * y[-1 - i].i; + } +} + +__attribute__((noipa)) static void +bar (struct C *__restrict x, struct C *__restrict y, struct C *__restrict z, int w) +{ + int i; + for (int i = 0; i < w; i++) + { + z[i].r = x[i].r * y[i].r - x[i].i * y[i].i; + z[i].i = x[i].i * y[i].r + x[i].r * y[i].i; + } +} + +int +main () +{ + check_vect (); + int i; + for (i = 0; i < N; ++i) + { + a[i].r = N - i; a[i].i = i - N; + b[i].r = i - N; b[i].i = i + N; + c[i].r = -1 - i; c[i].i = 2 * N - 1 - i; + } + foo (a, b + N, d, N); + bar (a, c, e, N); +#pragma GCC novector + for (i = 0; i < N; ++i) + if (d[i].r != e[i].r || d[i].i != e[i].i) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92429.c b/SingleSource/Regression/C/gcc-dg/vect/pr92429.c new file mode 100644 index 0000000000..7885cd6e4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92429.c @@ -0,0 +1,14 @@ +/* PR92429 */ +/* { dg-do compile } */ +/* { dg-additional-options "-O1 -fno-tree-fre" } */ +/* { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } } */ + +void +as (int *gl, int k1) +{ + while (k1 < 1) + { + gl[k1] = gl[k1] * gl[k1] / 2; + ++k1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92554.c b/SingleSource/Regression/C/gcc-dg/vect/pr92554.c new file mode 100644 index 0000000000..006375b1d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92554.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +short int w9; + +void __attribute__ ((simd)) +zc (int in) +{ + int va = 1; + + w9 *= va != 0 ? in < 0 : 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92555.c b/SingleSource/Regression/C/gcc-dg/vect/pr92555.c new file mode 100644 index 0000000000..b174e1c612 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92555.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fwrapv" } */ + +signed char rq; + +signed char +pu (int tr, int al) +{ + signed char x8; + + while (tr != 0) + { + for (x8 = 0; x8 >= 0; x8 += 2) + ; + + rq ^= al ^ 1; + ++x8; + ++tr; + } + + return x8; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92558.c b/SingleSource/Regression/C/gcc-dg/vect/pr92558.c new file mode 100644 index 0000000000..11f41320ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92558.c @@ -0,0 +1,25 @@ +/* { dg-additional-options "-mavx2" { target avx2_runtime } } */ + +void __attribute__((noipa)) +foo (int * __restrict wsum, int * __restrict cff, int * __restrict weight) +{ + for (int i = 0; i < 16; ++i) + { + *wsum += weight[2*i+0]; + *cff += weight[2*i+1]; + } +} + +int main() +{ + int weight[32]; + for (int i = 0; i < 32; ++i) + weight[i] = i; + int wsum = 0, cff = 0; + foo (&wsum, &cff, weight); + if (wsum != 240 || cff != 256) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92677.c b/SingleSource/Regression/C/gcc-dg/vect/pr92677.c new file mode 100644 index 0000000000..3f85b29524 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92677.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +int a, c; +int *b; +long d; +double *e; + +void fn1() { + long f; + double g, h; + while (c) { + if (d) { + g = *e; + *(b + 4) = g; + } + if (f) { + h = *(e + 2); + *(b + 6) = h; + } + e += a; + b += 8; + c--; + d += 2; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92710.c b/SingleSource/Regression/C/gcc-dg/vect/pr92710.c new file mode 100644 index 0000000000..2986d4ce06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92710.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#pragma omp declare simd +_Bool foo (_Bool) __attribute__((const)); + +void +f (_Bool *restrict x, char *restrict y, char *restrict z) +{ + for (int i = 0; i < 128; ++i) + x[i] = foo (y[i] == z[i]); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr92723.c b/SingleSource/Regression/C/gcc-dg/vect/pr92723.c new file mode 100644 index 0000000000..0d60883cad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr92723.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void +foo (unsigned long long *x, unsigned long long *y, int z) +{ + int i; + for (i = 0; i < 1024; i++) + x[i] = (y[i] >> z) | (y[i] << (-z & (__SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 1))); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr93069.c b/SingleSource/Regression/C/gcc-dg/vect/pr93069.c new file mode 100644 index 0000000000..45c740dbe9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr93069.c @@ -0,0 +1,10 @@ +/* PR target/93069 */ +/* { dg-do assemble { target vect_simd_clones } } */ +/* { dg-options "-O2 -fopenmp-simd" } */ + +#pragma omp declare simd +int +foo (int x, int y) +{ + return x == 0 ? x : y; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr93094.c b/SingleSource/Regression/C/gcc-dg/vect/pr93094.c new file mode 100644 index 0000000000..79c3e891db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr93094.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -fno-tree-pre" } */ +/* { dg-additional-options "-mavx512bw" { target x86_64-*-* i?86-*-* } } */ + +void +ll (char *un, char *rr, int te, int fp, int nb) +{ + const int xe = nb & 1; + + while (fp-- != 0) + { + if ((rr[0] & xe) == 0) + un[0] = 0; + + un += te; + rr += te; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr93247-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr93247-1.c new file mode 100644 index 0000000000..a3087b81d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr93247-1.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=skylake" { target x86_64-*-* i?86-*-* } } */ + +typedef struct { + unsigned num; +} VEC_tree_base; + +enum { + LTO_DECL_STREAM_NAMESPACE_DECL, + LTO_DECL_STREAM_LABEL_DECL, + LTO_N_DECL_STREAMS +}; + +struct lto_tree_ref_encoder { + VEC_tree_base *trees; +} typedef *lto_out_decl_state_ptr; + +typedef struct { + lto_out_decl_state_ptr vec[1]; +} VEC_lto_out_decl_state_ptr_base; + +VEC_lto_out_decl_state_ptr_base *a; +int f; +long g; +int +fn1(struct lto_tree_ref_encoder *p1) { + int i; + long b; + i = 0; + for (; i < LTO_N_DECL_STREAMS; i++) { + struct lto_tree_ref_encoder c = *p1; + int d; + VEC_tree_base *e = c.trees; + d = e ? e->num : 0; + b += d; + } + return b; +} +int +fn2() { + lto_out_decl_state_ptr h; + struct lto_tree_ref_encoder j; + unsigned k; + for (; k < f; k++) { + h = a->vec[k]; + j = *h; + g += fn1(&j); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr93247-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr93247-2.c new file mode 100644 index 0000000000..e229e15d87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr93247-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } } */ + +int +foo (int *a, double *b, int *c) +{ + int f, g = 0; + for (f = 0; f < 100; f++) + if (b[f] && c[a[f]]) + g++; + return g; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr93767.c b/SingleSource/Regression/C/gcc-dg/vect/pr93767.c new file mode 100644 index 0000000000..5f95d7bd35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr93767.c @@ -0,0 +1,13 @@ +int +main () +{ + int a[10], b; + for (b = 6; b >= 3; b--) + { + a[b] = 1; + a[b + 2] = a[3]; + } + if (a[5] != 1) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr93843-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr93843-1.c new file mode 100644 index 0000000000..23a79ca4c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr93843-1.c @@ -0,0 +1,21 @@ +char a; +struct S { short b, c; } d; + +__attribute__((noipa)) void +foo (int x) +{ + if (x != 4) + __builtin_abort (); +} + +int +main () +{ + short *g = &d.c, *h = &d.b; + char e = 4 - a; + int f; + *h = *g = e; + for (f = 0; f < 2; f++) + foo (d.c); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr93843-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr93843-2.c new file mode 100644 index 0000000000..5fae3e5be1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr93843-2.c @@ -0,0 +1,11 @@ +char in[2] = {2, 2}; +short out[2] = {}; + +int +main() +{ + for (int i = 0; i < 2; ++i) + out[i] = in[i]; + asm("":::"memory"); + if (out[0] != 2) __builtin_abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr94443.c b/SingleSource/Regression/C/gcc-dg/vect/pr94443.c new file mode 100644 index 0000000000..f8cbaf1b9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr94443.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=znver2" { target { x86_64-*-* i?86-*-* } } } */ + +/* Check it to be compiled successfully without any ICE. */ + +int a; +unsigned *b; + +void foo() +{ + for (unsigned i; i <= a; ++i, ++b) + ; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr94606.c b/SingleSource/Regression/C/gcc-dg/vect/pr94606.c new file mode 100644 index 0000000000..f0e7c4cd0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr94606.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv8.2-a+sve -msve-vector-bits=256" { target aarch64*-*-* } } */ + +const short mask[] = { 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 1, 1 }; + +int +foo (short *restrict x, short *restrict y) +{ + for (int i = 0; i < 16; ++i) + if (mask[i]) + x[i] += y[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr94727.c b/SingleSource/Regression/C/gcc-dg/vect/pr94727.c new file mode 100644 index 0000000000..3840871134 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr94727.c @@ -0,0 +1,24 @@ +/* { dg-additional-options "-O3" } */ + +unsigned char a[16][32]; +long b[16][32]; +unsigned long c; +_Bool d; + +void __attribute__((noipa)) +foo (void) +{ + for (int j = 0; j < 8; j++) + for (int i = 0; i < 17; ++i) + b[j][i] = (a[j][i] < c) > d; +} + +int +main (void) +{ + c = 1; + foo (); + if (!b[0][0]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr94994.c b/SingleSource/Regression/C/gcc-dg/vect/pr94994.c new file mode 100644 index 0000000000..2f598eacd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr94994.c @@ -0,0 +1,62 @@ +#include +#include "tree-vect.h" + +#define BLOCK_SIZE (sizeof (uint32_t)) + +struct unaligned { + uint32_t x; +} __attribute__((packed, may_alias)); + +static inline uint32_t +load_unaligned (const char *p) +{ + return ((struct unaligned *) p)->x; +} + +static inline void +store_unaligned (uint32_t x, char *p) +{ + ((struct unaligned *) p)->x = x; +} + +void __attribute__((noipa)) +copy (char *dst, const char *src, size_t n) +{ + for (size_t i = 0; i < n; i += BLOCK_SIZE) + store_unaligned (load_unaligned (src + i), dst + i); +} + +#define INPUT_SIZE 64 +#define MAX_STEP 32 + +char x[INPUT_SIZE + MAX_STEP]; + +int +main (void) +{ + check_vect (); + + for (unsigned int i = 1; i < MAX_STEP; ++i) + { + for (unsigned int j = 0; j < INPUT_SIZE + MAX_STEP; ++j) + x[j] = j + 10; + copy (x + i, x, INPUT_SIZE); +#pragma GCC novector + for (int j = 0; j < INPUT_SIZE + i; ++j) + { + int expected; + if (j < i) + expected = j + 10; + else if (i >= BLOCK_SIZE) + expected = j % i + 10; + else if ((j - i) % BLOCK_SIZE < i) + expected = x[j - i]; + else + expected = j - i + 10; + if (x[j] != expected) + __builtin_abort (); + } + } + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr95272.c b/SingleSource/Regression/C/gcc-dg/vect/pr95272.c new file mode 100644 index 0000000000..47698ff3e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr95272.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +enum { a = 5, b }; +typedef struct { + int c[b]; +} d; +extern d e[]; +int f; +int g[6]; +void h() { + int i; + for (; f; f++) { + i = 0; + for (; i < b; i++) + if (e[f].c[i]) + g[i] = e[f].c[i]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr95495.c b/SingleSource/Regression/C/gcc-dg/vect/pr95495.c new file mode 100644 index 0000000000..683f0f26a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr95495.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +typedef struct { + int a; + int b; +} c; +int d, f, g; +c e[4]; +void +h() +{ + for (; f; f++) { + g += e[f].a >> 1 | e[f].a & 1; + d += e[f].b >> 1 | e[f].b & 1; + } +} + +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr95539.c b/SingleSource/Regression/C/gcc-dg/vect/pr95539.c new file mode 100644 index 0000000000..de3b393879 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr95539.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ + +typedef unsigned short uint16_t; +typedef short __v8hi __attribute__ ((__vector_size__ (16))); +typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__)); +extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__)) +_mm_set_epi16 (short __q7, short __q6, short __q5, short __q4, + short __q3, short __q2, short __q1, short __q0) +{ + return __extension__ (__m128i)(__v8hi){ + __q0, __q1, __q2, __q3, __q4, __q5, __q6, __q7 }; +} +void gcm_HashMult_hw(__m128i *x, const unsigned char *buf, unsigned int count) +{ + unsigned i; + __m128i bin __attribute__((aligned(16))); + for (i = 0; i < count; i++, buf += 16) + { + bin = _mm_set_epi16(((uint16_t)buf[0] << 8) | buf[1], + ((uint16_t)buf[2] << 8) | buf[3], + ((uint16_t)buf[4] << 8) | buf[5], + ((uint16_t)buf[6] << 8) | buf[7], + ((uint16_t)buf[8] << 8) | buf[9], + ((uint16_t)buf[10] << 8) | buf[11], + ((uint16_t)buf[12] << 8) | buf[13], + ((uint16_t)buf[14] << 8) | buf[15]); + *(x++) = bin; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr95570.c b/SingleSource/Regression/C/gcc-dg/vect/pr95570.c new file mode 100644 index 0000000000..b936261400 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr95570.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv8.2-a+sve -msve-vector-bits=256 -mstrict-align -fwrapv" { target aarch64*-*-* } } */ + +int x[8][32]; + +void +foo (int start) +{ + for (int i = start; i < start + 16; i++) + x[start][i] = i; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr95856.c b/SingleSource/Regression/C/gcc-dg/vect/pr95856.c new file mode 100644 index 0000000000..19a86a62d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr95856.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +typedef struct { + float xmin, xmax; +} rctf; + +typedef struct { + rctf tot; +} View2D; + +View2D graph_main_area_draw_v2d; + +void get_graph_keyframe_extents(); + +void +graph_main_area_draw() { + get_graph_keyframe_extents(); + graph_main_area_draw_v2d.tot.xmin -= 10.0f; + graph_main_area_draw_v2d.tot.xmax += 10.0f; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr95897.c b/SingleSource/Regression/C/gcc-dg/vect/pr95897.c new file mode 100644 index 0000000000..a17b72dd04 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr95897.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +double foo (double x, int n) +{ + double s = 0.; + for (int i = 0; i < n; ++i) + { + s += x; + s += x; + s += x; + } + return s; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr95916.c b/SingleSource/Regression/C/gcc-dg/vect/pr95916.c new file mode 100644 index 0000000000..61b8ca3fa0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr95916.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +extern short var_3, var_8; +extern int var_5; +extern char var_10; +extern int arr_99[][16]; +void test() +{ + for (; 0 < var_10;) + for (long a = var_8;; a++) + arr_99[4][a] = var_3 << var_5; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr96698.c b/SingleSource/Regression/C/gcc-dg/vect/pr96698.c new file mode 100644 index 0000000000..1d141c1dff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr96698.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +void test(int a, int* i) +{ + for (; a < 5; ++a) + { + int b = 0; + int c = 0; + for (; b != -11; b--) + for (int d = 0; d ==0; d++) + { + *i += c & a; + c = b; + } + } +} + +/* We should be able to vectorize the inner cycle. */ +/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr96783-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr96783-1.c new file mode 100644 index 0000000000..36b08f4e43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr96783-1.c @@ -0,0 +1,37 @@ +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (long *a, int off, int n) +{ + for (int i = 0; i < n; ++i) + { + long tem1 = a[0]; + long tem2 = a[1]; + long tem3 = a[2]; + long tem4 = a[off + 1]; + a[0] = tem4; + long tem5 = a[off + 2]; + a[1] = tem5; + long tem6 = a[off + 3]; + a[2] = tem6; + a[off + 1] = tem1; + a[off + 2] = tem2; + a[off + 3] = tem3; + a -= 3; + } +} + +int main () +{ + long a[3 * 9]; + check_vect (); + for (int i = 0; i < 3 * 9; ++i) + a[i] = i; + foo (a + 3 * 5, 6-1, 5); + const long b[3 * 8] = { 0, 1, 2, 21, 22, 23, 18, 19, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }; +#pragma GCC novector + for (int i = 0; i < 3 * 8; ++i) + if (a[i] != b[i]) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr96783-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr96783-2.c new file mode 100644 index 0000000000..2a900d0259 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr96783-2.c @@ -0,0 +1,28 @@ +#include "tree-vect.h" + +long a[1024]; +long b[1024]; + +void __attribute__((noipa)) foo () +{ + for (int i = 0; i < 256; ++i) + { + a[3*i] = b[1023 - 3*i - 2]; + a[3*i + 1] = b[1023 - 3*i - 1]; + a[3*i + 2] = b[1023 - 3*i]; + } +} + +int main() +{ + for (int i = 0; i < 1024; ++i) + b[i] = i; + foo (); +#pragma GCC novector + for (int i = 0; i < 256; ++i) + if (a[3*i] != 1023 - 3*i - 2 + || a[3*i+1] != 1023 - 3*i - 1 + || a[3*i+2] != 1023 - 3*i) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr96854.c b/SingleSource/Regression/C/gcc-dg/vect/pr96854.c new file mode 100644 index 0000000000..e3980d4130 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr96854.c @@ -0,0 +1,20 @@ +/* { dg-additional-options "-ffast-math" } */ + +double _Complex __attribute__((noipa)) +foo (double _Complex acc, const double _Complex *x, const double _Complex* y, int N) +{ + for (int c = 0; c < N; ++c) + acc -= x[c] * y[c]; + return acc; +} + +int +main() +{ + static const double _Complex y[] = { 1, 2, }; + static const double _Complex x[] = { 1, 3, }; + double _Complex ref = foo (0, x, y, 2); + if (__builtin_creal (ref) != -7.) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr96920.c b/SingleSource/Regression/C/gcc-dg/vect/pr96920.c new file mode 100644 index 0000000000..af5da4ae52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr96920.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int a[1024]; +int b[2048]; + +void foo (int x, int y) +{ + for (int i = 0; i < 1024; ++i) + { + int tem0 = b[2*i]; + int tem1 = b[2*i+1]; + for (int j = 0; j < 32; ++j) + { + int tem = tem0; + tem0 = tem1; + tem1 = tem; + a[i] += tem0; + } + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97081-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr97081-2.c new file mode 100644 index 0000000000..436e897cd2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97081-2.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/97081 */ + +#include "tree-vect.h" + +unsigned short s[1024]; +unsigned char c[1024]; + +__attribute__((noipa)) void +foo (int n) +{ + for (int i = 0; i < 1024; i++) + s[i] = (s[i] << n) | (s[i] >> (__SIZEOF_SHORT__ * __CHAR_BIT__ - n)); + for (int i = 0; i < 1024; i++) + c[i] = (c[i] << n) | (c[i] >> (__CHAR_BIT__ - n)); +} + +int +main () +{ + check_vect (); + for (int i = 0; i < 1024; i++) + { + s[i] = i; + c[i] = i; + } + foo (3); +#pragma GCC novector + for (int i = 0; i < 1024; i++) + if (s[i] != (unsigned short) ((i << 3) | (i >> (__SIZEOF_SHORT__ * __CHAR_BIT__ - 3))) + || c[i] != (unsigned char) ((((unsigned char) i) << 3) | (((unsigned char) i) >> (__CHAR_BIT__ - 3)))) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97081.c b/SingleSource/Regression/C/gcc-dg/vect/pr97081.c new file mode 100644 index 0000000000..bc83c88c01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97081.c @@ -0,0 +1,26 @@ +#include "tree-vect.h" + +#define EXEC_ROR2(a, b, sz) (a >> b) | (a << (64 - b)) + +#define TYPE __UINT64_TYPE__ + +void __attribute__((noipa)) +exec_VRORudi_i(TYPE *__restrict__ pvd, + TYPE *__restrict__ const pva, unsigned char IMM) +{ + unsigned char I2 = IMM & 63; + + for (unsigned i = 0; i < 4; i++) + pvd[i] = EXEC_ROR2(pva[i], I2, 8); +} + +int main() +{ + check_vect (); + + TYPE pvd[4], pva[4] = { 0x0102030405060708, 0x0102030405060708, 0x0102030405060708, 0x0102030405060708 }; + exec_VRORudi_i (pvd, pva, 7); + if (pvd[0] != 0x10020406080a0c0e) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97085.c b/SingleSource/Regression/C/gcc-dg/vect/pr97085.c new file mode 100644 index 0000000000..ffde9f1099 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97085.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv8.2-a+sve" { target aarch64-*-* } } */ + +int a, b, c, d; +short e, g; +unsigned short f; +void h() { + for (; d; d++) { + g = d; + e = b == 0 ? 1 : a % b; + c ^= (f = e) > (g == 5); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97139.c b/SingleSource/Regression/C/gcc-dg/vect/pr97139.c new file mode 100644 index 0000000000..1b9f31c7db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97139.c @@ -0,0 +1,27 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int pix[4]; + +int __attribute__((noipa)) foo (void) +{ + pix[0] = pix[0] / 4; + pix[1] = pix[1] / 4; + pix[2] = pix[2] / 4; + pix[3] = pix[3] / 4; + return pix[0] + pix[1] + pix[2] + pix[3]; +} + +int main () +{ + check_vect (); + + pix[0] = 8; + pix[1] = 16; + pix[2] = 32; + pix[3] = 64; + if (foo () != 30) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97173.c b/SingleSource/Regression/C/gcc-dg/vect/pr97173.c new file mode 100644 index 0000000000..fd4a889316 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97173.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +typedef struct { + char *track; + char *clocks; + char *fm; + char *weak; +} disk_t; + +disk_t disk_update_tlens_d; +int disk_update_tlens_d_0; + +void disk_update_tlens() { + disk_update_tlens_d.track = disk_update_tlens_d.clocks = + disk_update_tlens_d.track + disk_update_tlens_d_0; + disk_update_tlens_d.fm = disk_update_tlens_d.clocks + disk_update_tlens_d_0; + disk_update_tlens_d.weak = disk_update_tlens_d.fm; + disk_update_tlens_d.track[2] = 5; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97236.c b/SingleSource/Regression/C/gcc-dg/vect/pr97236.c new file mode 100644 index 0000000000..9d3dc20d95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97236.c @@ -0,0 +1,43 @@ +typedef unsigned char __uint8_t; +typedef __uint8_t uint8_t; +typedef struct plane_t { + uint8_t *p_pixels; + int i_lines; + int i_pitch; +} plane_t; + +typedef struct { + plane_t p[5]; +} picture_t; + +#define N 4 + +void __attribute__((noipa)) +picture_Clone(picture_t *picture, picture_t *res) +{ + for (int i = 0; i < N; i++) { + res->p[i].p_pixels = picture->p[i].p_pixels; + res->p[i].i_lines = picture->p[i].i_lines; + res->p[i].i_pitch = picture->p[i].i_pitch; + } +} + +int +main() +{ + picture_t aaa, bbb; + uint8_t pixels[10] = {1, 1, 1, 1, 1, 1, 1, 1}; + + for (unsigned i = 0; i < N; i++) + aaa.p[i].p_pixels = pixels; + + picture_Clone (&aaa, &bbb); + + uint8_t c = 0; + for (unsigned i = 0; i < N; i++) + c += bbb.p[i].p_pixels[0]; + + if (c != N) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97241.c b/SingleSource/Regression/C/gcc-dg/vect/pr97241.c new file mode 100644 index 0000000000..d4be8f6094 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97241.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 --param max-loop-header-insns=2" } */ + +short int *ev; +int l4; + +short int +a7 (void) +{ + short int uo = ev[0], ie = uo; + + for (int kp = 0; kp < l4; kp += 4) + { + uo += ev[kp + 1]; + ie += ev[kp]; + } + + return uo + ie; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97428.c b/SingleSource/Regression/C/gcc-dg/vect/pr97428.c new file mode 100644 index 0000000000..60dd984cfd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97428.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" { target riscv*-*-* } } */ + +typedef struct { double re, im; } dcmlx_t; +typedef struct { double re[4], im[4]; } dcmlx4_t; + +void foo_i2(dcmlx4_t dst[], const dcmlx_t src[], int n) +{ + for (int i = 0; i < n; ++i) { + dcmlx_t s00 = src[i*4+0]; + dcmlx_t s01 = src[i*4+1]; + dcmlx_t s02 = src[i*4+2]; + dcmlx_t s03 = src[i*4+3]; + + dcmlx_t s10 = src[i*4+0+n]; + dcmlx_t s11 = src[i*4+1+n]; + dcmlx_t s12 = src[i*4+2+n]; + dcmlx_t s13 = src[i*4+3+n]; + + dst[i*2+0].re[0] = s00.re; + dst[i*2+0].re[1] = s01.re; + dst[i*2+0].re[2] = s02.re; + dst[i*2+0].re[3] = s03.re; + dst[i*2+0].im[0] = s00.im; + dst[i*2+0].im[1] = s01.im; + dst[i*2+0].im[2] = s02.im; + dst[i*2+0].im[3] = s03.im; + + dst[i*2+1].re[0] = s10.re; + dst[i*2+1].re[1] = s11.re; + dst[i*2+1].re[2] = s12.re; + dst[i*2+1].re[3] = s13.re; + dst[i*2+1].im[0] = s10.im; + dst[i*2+1].im[1] = s11.im; + dst[i*2+1].im[2] = s12.im; + dst[i*2+1].im[3] = s13.im; + } +} + +/* The first step to produce optimal code is to appropriately detect the + load and store groups. */ +/* { dg-final { scan-tree-dump "Detected interleaving load of size 8" "vect" } } */ +/* { dg-final { scan-tree-dump "Detected interleaving store of size 16" "vect" } } */ +/* We're not able to peel & apply re-aligning to make accesses well-aligned for !vect_hw_misalign, + but we could by peeling the stores for alignment and applying re-aligning loads. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { xfail { ! vect_hw_misalign } } } } */ +/* { dg-final { scan-tree-dump-not "gap of 6 elements" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97457.c b/SingleSource/Regression/C/gcc-dg/vect/pr97457.c new file mode 100644 index 0000000000..506ba249b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97457.c @@ -0,0 +1,15 @@ +/* { dg-additional-options "-O3" } */ + +int a; +long c; +signed char d(char e, char f) { return e + f; } +int main(void) { + for (; a <= 1; a++) { + c = -8; + for (; c != 3; c = d(c, 1)) + ; + } + char b = c; + if (b != 3) + __builtin_abort(); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97558-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr97558-2.c new file mode 100644 index 0000000000..109ab0ac5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97558-2.c @@ -0,0 +1,54 @@ +/* { dg-additional-options "-O3 -fno-tree-forwprop -fno-tree-scev-cprop" } */ + +#include "tree-vect.h" + +#define N 40 + +int a[N]; +int b[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum,x,y; + + if (n<=0) + return 0; + + for (i = 0; i < N/2; i++) { + sum = 0; + x = b[2*i]; + y = b[2*i+1]; + for (j = 0; j < n; j++) { + sum += j; + } + a[2*i] = sum + x; + a[2*i+1] = sum + y; + } +} + +int main (void) +{ + int i,j; + int sum; + + check_vect (); + + for (i=0; id1; + int *b = p1->h1; + for (int a = 0; a; a++, d += 4) + fn1(d, *b++); +} + +void fn3() { fn2(&(&c)->otmp); } diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97832-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr97832-1.c new file mode 100644 index 0000000000..063fc7bd71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97832-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-require-effective-target vect_double } */ + +double a[1024], b[1024], c[1024]; + +void foo() +{ + for (int i = 0; i < 256; ++i) + { + a[2*i] = a[2*i] + b[2*i] - c[2*i]; + a[2*i+1] = a[2*i+1] - b[2*i+1] - c[2*i+1]; + } +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97832-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr97832-2.c new file mode 100644 index 0000000000..7d8d269143 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97832-2.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-require-effective-target vect_double } */ + +void foo1x1(double* restrict y, const double* restrict x, int clen) +{ + int xi = clen & 2; + double f_re = x[0+xi+0]; + double f_im = x[4+xi+0]; + int clen2 = (clen+xi) * 2; +#pragma GCC unroll 0 + for (int c = 0; c < clen2; c += 8) { + // y[c] = y[c] - x[c]*conj(f); +#pragma GCC unroll 4 + for (int k = 0; k < 4; ++k) { + double x_re = x[c+0+k]; + double x_im = x[c+4+k]; + double y_re = y[c+0+k]; + double y_im = y[c+4+k]; + y_re = y_re - x_re * f_re - x_im * f_im;; + y_im = y_im + x_re * f_im - x_im * f_re; + y[c+0+k] = y_re; + y[c+4+k] = y_im; + } + } +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { target { ! { vect_load_lanes && vect_strided8 } } } } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" { target { ! { vect_load_lanes && vect_strided8 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97832-3.c b/SingleSource/Regression/C/gcc-dg/vect/pr97832-3.c new file mode 100644 index 0000000000..c0603e1432 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97832-3.c @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-require-effective-target vect_double } */ + +void foo(double* restrict y, const double* restrict x0, const double* restrict x1, int clen) +{ + int xi = clen & 2; + double f00_re = x0[0+xi+0]; + double f10_re = x1[0+xi+0]; + double f01_re = x0[0+xi+1]; + double f11_re = x1[0+xi+1]; + double f00_im = x0[4+xi+0]; + double f10_im = x1[4+xi+0]; + double f01_im = x0[4+xi+1]; + double f11_im = x1[4+xi+1]; + int clen2 = (clen+xi) * 2; + double* y0 = &y[0]; + double* y1 = &y[clen2]; + #pragma GCC unroll 0 + for (int c = 0; c < clen2; c += 8) { + // y0[c] = y0[c] - x0[c]*conj(f00) - x1[c]*conj(f10); + // y1[c] = y1[c] - x0[c]*conj(f01) - x1[c]*conj(f11); + #pragma GCC unroll 4 + for (int k = 0; k < 4; ++k) { + double x0_re = x0[c+0+k]; + double x0_im = x0[c+4+k]; + double y0_re = y0[c+0+k]; + double y0_im = y0[c+4+k]; + double y1_re = y1[c+0+k]; + double y1_im = y1[c+4+k]; + y0_re = y0_re - x0_re * f00_re - x0_im * f00_im; + y0_im = y0_im + x0_re * f00_im - x0_im * f00_re; + y1_re = y1_re - x0_re * f01_re - x0_im * f01_im; + y1_im = y1_im + x0_re * f01_im - x0_im * f01_re; + double x1_re = x1[c+0+k]; + double x1_im = x1[c+4+k]; + y0_re = y0_re - x1_re * f10_re - x1_im * f10_im; + y0_im = y0_im + x1_re * f10_im - x1_im * f10_re; + y1_re = y1_re - x1_re * f11_re - x1_im * f11_im; + y1_im = y1_im + x1_re * f11_im - x1_im * f11_re; + y0[c+0+k] = y0_re; + y0[c+4+k] = y0_im; + y1[c+0+k] = y1_re; + y1[c+4+k] = y1_im; + } + } +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { target { ! { vect_load_lanes && vect_strided8 } } } } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" { target { ! { vect_load_lanes && vect_strided8 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97832-4.c b/SingleSource/Regression/C/gcc-dg/vect/pr97832-4.c new file mode 100644 index 0000000000..c03442816a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97832-4.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ +/* { dg-require-effective-target vect_double } */ + +void foo1x1(double* restrict y, const double* restrict x, int clen) +{ + int xi = clen & 2; + double f_re = x[0+xi+0]; + double f_im = x[4+xi+0]; + int clen2 = (clen+xi) * 2; +#pragma GCC unroll 0 + for (int c = 0; c < clen2; c += 8) { +#pragma GCC unroll 4 + for (int k = 0; k < 4; ++k) { + double x_re = x[k]; + double x_im = x[c+4+k]; + double y_re = y[c+0+k]; + double y_im = y[c+4+k]; + y_re = y_re - x_re * f_re - x_im * f_im;; + y_im = y_im + x_re * f_im - x_im * f_re; + y[c+0+k] = y_re; + y[c+4+k] = y_im; + } + } +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { target { ! { vect_load_lanes && vect_strided8 } } } } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" { target { ! { vect_load_lanes && vect_strided8 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97835.c b/SingleSource/Regression/C/gcc-dg/vect/pr97835.c new file mode 100644 index 0000000000..a90c773eac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97835.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +struct co { + int gx; + int ty; +}; + +void +x0 (struct co *yy, long int kc, int wi, int md) +{ + while (wi < 1) + { + yy[wi].gx = md; + yy[wi].ty = wi; + md += kc; + ++wi; + } +} + +/* We don't yet support SLP inductions for variable length vectors. */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { xfail vect_variable_length } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97838.c b/SingleSource/Regression/C/gcc-dg/vect/pr97838.c new file mode 100644 index 0000000000..06ec0358f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97838.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +int a, b, c, d; + +void f() { + while (c++) { + int e = -1; + d = a ? e / a : e; + b ^= ~d; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr97929.c b/SingleSource/Regression/C/gcc-dg/vect/pr97929.c new file mode 100644 index 0000000000..a027b31715 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr97929.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +#include +#define ARR_SIZE 1024 +extern void foo (int32_t *bar, int16_t a) +{ + for( int i = 0; i < ARR_SIZE;i++) + { + bar[i] = a + 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr98048.c b/SingleSource/Regression/C/gcc-dg/vect/pr98048.c new file mode 100644 index 0000000000..e61a376cb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr98048.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +extern short var_0; +extern int var_3; +extern int arr_277[]; +int a(int b, int c) { return b < c ? b : c; } +int e; +void test() +{ + e = var_0; + for (int d = 0; d < 9; d++) + if (var_3) + arr_277[d] = a(var_0, -var_0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr98069.c b/SingleSource/Regression/C/gcc-dg/vect/pr98069.c new file mode 100644 index 0000000000..e60549fb30 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr98069.c @@ -0,0 +1,22 @@ +long long int var_3 = -166416893043554447LL; +short var_8 = (short)27092; +unsigned int var_17 = 75036300U; +short arr_165[23]; + +static long c(long e, long f) { return f ? e : f; } +void __attribute((noipa)) test() +{ + for (int b = 0; b < 19; b = var_17) + for (int d = (int)(~c(-2147483647 - 1, var_3)) - 2147483647; d < 22; d++) + arr_165[d] = var_8; +} + +int main() +{ + for (unsigned i_3 = 0; i_3 < 23; ++i_3) + arr_165[i_3] = (short)-8885; + test(); + if (arr_165[0] != 27092) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr98302.c b/SingleSource/Regression/C/gcc-dg/vect/pr98302.c new file mode 100644 index 0000000000..dec6016762 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr98302.c @@ -0,0 +1,22 @@ +#include "tree-vect.h" + +int c = 1705; +char a; +long f = 50887638; +unsigned long long *h(unsigned long long *k, unsigned long long *l) { + return *k ? k : l; +} +void aa() {} +int main() { + check_vect (); + + long d = f; + for (char g = 0; g < (char)c - 10; g += 2) { + unsigned long long i = d, j = 4; + a = *h(&i, &j) << ((d ? 169392992 : 0) - 169392955LL); + } + if (a) + __builtin_abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr98308.c b/SingleSource/Regression/C/gcc-dg/vect/pr98308.c new file mode 100644 index 0000000000..aeec9771c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr98308.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-march=skylake-avx512" { target avx512f } } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +extern unsigned long long int arr_86[]; +extern unsigned long long int arr_87[][15]; + +void test(_Bool a, unsigned short c[][15], unsigned char d[]) +{ + for (short h = 0; h < 10; h++) + for (char i = 0; i < 15; i += 2) + { + arr_86[0] = d[0]; + arr_87[h][0] = a ? c[h][i] : 0; + } +} +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr98560-1.c b/SingleSource/Regression/C/gcc-dg/vect/pr98560-1.c new file mode 100644 index 0000000000..2583fc48f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr98560-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -fno-tree-vrp -fno-tree-fre -fno-tree-pre -fno-code-hoisting -fvect-cost-model=dynamic" } */ +/* { dg-additional-options "-msve-vector-bits=128" { target aarch64_sve } } */ + +#include + +void +f (uint16_t *restrict dst, uint32_t *restrict src1, float *restrict src2) +{ + int i = 0; + for (int j = 0; j < 4; ++j) + { + uint16_t tmp = src1[i] >> 1; + dst[i] = (uint16_t) (src2[i] < 0 && i < 4 ? tmp : 1); + i += 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr98560-2.c b/SingleSource/Regression/C/gcc-dg/vect/pr98560-2.c new file mode 100644 index 0000000000..7759a5e820 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr98560-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -fno-tree-vrp -fno-tree-fre -fno-tree-pre -fno-code-hoisting -fvect-cost-model=dynamic" } */ +/* { dg-additional-options "-msve-vector-bits=128" { target aarch64_sve } } */ + +#include + +void +f (uint16_t *restrict dst, uint32_t *restrict src1, float *restrict src2) +{ + int i = 0; + for (int j = 0; j < 4; ++j) + { + uint16_t tmp = src1[i] >> 1; + dst[i] = (uint16_t) (src2[i] == 0 && i < 4 ? tmp : 1); + i += 1; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr98674.c b/SingleSource/Regression/C/gcc-dg/vect/pr98674.c new file mode 100644 index 0000000000..0f1b6cb060 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr98674.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-msse2" { target sse2 } } */ + +void swap(short *p, int cnt) +{ + while (cnt-- > 0) + { + *p = ((*p << 8) & 0xFF00) | ((*p >> 8) & 0x00FF); + ++p; + } +} + +/* Dependence analysis should not fail. */ +/* { dg-final { scan-tree-dump "dependence distance == 0" "vect" } } */ +/* On x86 with SSE2 we can vectorize this with psllw/psrlw. */ +/* { dg-final { scan-tree-dump "loop vectorized" "vect" { target sse2 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr98848.c b/SingleSource/Regression/C/gcc-dg/vect/pr98848.c new file mode 100644 index 0000000000..5cf7c9fee5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr98848.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/98848 */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +short a[9000]; + +int +foo (void) +{ + int b = a[0]; + int i; + for (i = 1; i < 9000; i ++) + if (a[i] < b) + b = a[i]; + return b; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { xfail { vect_no_int_add || vect_no_int_min_max } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr99102.c b/SingleSource/Regression/C/gcc-dg/vect/pr99102.c new file mode 100644 index 0000000000..0d030d15c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr99102.c @@ -0,0 +1,20 @@ +/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model -fdump-tree-vect-details" } */ +/* { dg-additional-options "-msve-vector-bits=256" { target aarch64_sve256_hw } } */ +long a[44]; +short d, e = -7; +__attribute__((noipa)) void b(char f, short j, short k, unsigned l) { + for (int g = 0; g < 9; g += f) + for (int b = 0; b < 90; b -= k) + for (int h = 0; h < f; h++) + for (short i = 0; i < 15; i += 4) + if (!l) + a[i] = j; +} +int main() { + for (long c = 0; c < 2; ++c) + a[c] = 7; + b(9, d, e, 5); + if (!a[0]) + __builtin_abort(); +} +/* { dg-final { scan-tree-dump "MASK_SCATTER_STORE" "vect" { target aarch64_sve256_hw } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr99253.c b/SingleSource/Regression/C/gcc-dg/vect/pr99253.c new file mode 100644 index 0000000000..3e8d865dc4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr99253.c @@ -0,0 +1,20 @@ +#include "tree-vect.h" + +int a = 0; +static int b = 0; +long c = 0; + +int +main() +{ + check_vect (); + for (int d = 0; d < 8; d++) + { + a ^= c; + b = a; + a ^= 1; + } + if (a != 0 || b != 1) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr99412.c b/SingleSource/Regression/C/gcc-dg/vect/pr99412.c new file mode 100644 index 0000000000..e3e94a052c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr99412.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast --param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +/* From TSVC s352. */ + +typedef float real_t; + +#define LEN_1D 32000 +#define LEN_2D 256 + +real_t a[LEN_1D],b[LEN_1D]; +real_t foo () +{ + real_t dot = (real_t)0.; + for (int i = 0; i < LEN_1D; i += 5) { + dot = dot + a[i] * b[i] + a[i + 1] * b[i + 1] + a[i + 2] + * b[i + 2] + a[i + 3] * b[i + 3] + a[i + 4] * b[i + 4]; + } + + return dot; +} + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr99540.c b/SingleSource/Regression/C/gcc-dg/vect/pr99540.c new file mode 100644 index 0000000000..9136b099d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr99540.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ftrapv -ffloat-store -march=armv8.2-a+sve" { target aarch64*-*-* } } */ + +float *MSalign2m2m_rec_initverticalw, *MSalign2m2m_rec_currentw; + +void +match_ribosum (int MSalign2m2m_rec_i, int MSalign2m2m_rec_lgth1, + int MSalign2m2m_rec_lgth2) +{ + float **WMMTX; + + while (MSalign2m2m_rec_i < 1) + WMMTX[MSalign2m2m_rec_i++][0] = MSalign2m2m_rec_initverticalw[0]; + + while (MSalign2m2m_rec_i < MSalign2m2m_rec_lgth1) + MSalign2m2m_rec_initverticalw[MSalign2m2m_rec_i++] += 0.1; + + while (MSalign2m2m_rec_i < MSalign2m2m_rec_lgth2) + MSalign2m2m_rec_currentw[MSalign2m2m_rec_i++] += 0.1; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/pr99856.c b/SingleSource/Regression/C/gcc-dg/vect/pr99856.c new file mode 100644 index 0000000000..e5d2a45be5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/pr99856.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_unpack } */ +/* { dg-require-effective-target vect_pack_trunc } */ + +#define SHIFTFORDIV255(a)\ + ((((a) >> 8) + a) >> 8) + +#define DIV255(a)\ + SHIFTFORDIV255(a + 0x80) + +typedef unsigned char uint8_t; + +void +opSourceOver_premul(uint8_t* restrict Rrgba, + const uint8_t* restrict Srgba, + const uint8_t* restrict Drgba, int len) +{ + Rrgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__); + Srgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__); + Drgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__); + int i = 0; + for (; i < len*4; i += 4) + { + uint8_t Sa = Srgba[i + 3]; + Rrgba[i + 0] = DIV255(Srgba[i + 0] * 255 + Drgba[i + 0] * (255 - Sa)); + Rrgba[i + 1] = DIV255(Srgba[i + 1] * 255 + Drgba[i + 1] * (255 - Sa)); + Rrgba[i + 2] = DIV255(Srgba[i + 2] * 255 + Drgba[i + 2] * (255 - Sa)); + Rrgba[i + 3] = DIV255(Srgba[i + 3] * 255 + Drgba[i + 3] * (255 - Sa)); + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/section-anchors-pr27770.c b/SingleSource/Regression/C/gcc-dg/vect/section-anchors-pr27770.c new file mode 100644 index 0000000000..1154b40d48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/section-anchors-pr27770.c @@ -0,0 +1,31 @@ +/* { dg-require-effective-target section_anchors } */ + +#include +#include "tree-vect.h" + +short x; +static short f[100] = {0}; +int +bar (void) +{ + return f[0]; +} +void +foo (void) +{ + int i; + for (i = 0; i < 100; i++) + f[i]++; +} +int main (void) +{ + int i; + check_vect (); + foo (); +#pragma GCC novector + for (i = 0; i < 100; i++) + if (f[i]!=1) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/section-anchors-vect-69.c b/SingleSource/Regression/C/gcc-dg/vect/section-anchors-vect-69.c new file mode 100644 index 0000000000..dbf65605e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/section-anchors-vect-69.c @@ -0,0 +1,127 @@ +/* { dg-require-effective-target section_anchors } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0" } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define NINTS (VECTOR_BITS / 32) +#else +#define NINTS 4 +#endif + +#define N (NINTS * 8) + +struct s{ + int m; + int n[N][N][N]; +}; + +struct s2{ + int m; + int n[N-1][N-1][N-1]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int pad[NINTS - 2]; + struct s e; /* array e.n is aligned */ +}; + +struct test2{ + struct s2 a; + int b; + int c; + struct s2 e; +}; + + +struct test1 tmp1[4]; +struct test2 tmp2[4]; + +int main1 () +{ + int i,j; + + /* 1. unaligned */ + for (i = 0; i < N; i++) + { + tmp1[2].a.n[1][2][i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 128 + +int +main1 () +{ + int i; + unsigned short out[N*8]; + + for (i = 0; i < N; i++) + { + out[i*4] = 8; + out[i*4 + 1] = 18; + out[i*4 + 2] = 28; + out[i*4 + 3] = 38; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != 8 + || out[i*4 + 1] != 18 + || out[i*4 + 2] != 28 + || out[i*4 + 3] != 38) + abort (); + } + + for (i = 0; i < N; i++) + { + out[i*8] = 8; + out[i*8 + 1] = 7; + out[i*8 + 2] = 81; + out[i*8 + 3] = 28; + out[i*8 + 4] = 18; + out[i*8 + 5] = 85; + out[i*8 + 6] = 5; + out[i*8 + 7] = 4; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != 8 + || out[i*8 + 1] != 7 + || out[i*8 + 2] != 81 + || out[i*8 + 3] != 28 + || out[i*8 + 4] != 18 + || out[i*8 + 5] != 85 + || out[i*8 + 6] != 5 + || out[i*8 + 7] != 4) + abort (); + } + + /* SLP with unrolling by 8. */ + for (i = 0; i < N; i++) + { + out[i*5] = 8; + out[i*5 + 1] = 7; + out[i*5 + 2] = 81; + out[i*5 + 3] = 28; + out[i*5 + 4] = 18; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*5] != 8 + || out[i*5 + 1] != 7 + || out[i*5 + 2] != 81 + || out[i*5 + 3] != 28 + || out[i*5 + 4] != 18) + abort (); + } + + /* SLP with unrolling by 8. */ + for (i = 0; i < N/2; i++) + { + out[i*9] = 8; + out[i*9 + 1] = 7; + out[i*9 + 2] = 81; + out[i*9 + 3] = 28; + out[i*9 + 4] = 18; + out[i*9 + 5] = 85; + out[i*9 + 6] = 5; + out[i*9 + 7] = 4; + out[i*9 + 8] = 14; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*9] != 8 + || out[i*9 + 1] != 7 + || out[i*9 + 2] != 81 + || out[i*9 + 3] != 28 + || out[i*9 + 4] != 18 + || out[i*9 + 5] != 85 + || out[i*9 + 6] != 5 + || out[i*9 + 7] != 4 + || out[i*9 + 8] != 14) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target {! vect_strided5 } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target vect_strided5 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-10.c b/SingleSource/Regression/C/gcc-dg/vect/slp-10.c new file mode 100644 index 0000000000..2759b66f77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-10.c @@ -0,0 +1,116 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + float out2[N*8]; + + for (i = 0; i < N; i++) + { + + a0 = in[i*8] + 5; + a1 = in[i*8 + 1] + 6; + a2 = in[i*8 + 2] + 7; + a3 = in[i*8 + 3] + 8; + a4 = in[i*8 + 4] + 9; + a5 = in[i*8 + 5] + 10; + a6 = in[i*8 + 6] + 11; + a7 = in[i*8 + 7] + 12; + + b0 = a0 * 3; + b1 = a1 * 2; + b2 = a2 * 12; + b3 = a3 * 5; + b4 = a4 * 8; + b5 = a5 * 4; + b6 = a6 * 3; + b7 = a7 * 2; + + out[i*8] = b0 - 2; + out[i*8 + 1] = b1 - 3; + out[i*8 + 2] = b2 - 2; + out[i*8 + 3] = b3 - 1; + out[i*8 + 4] = b4 - 8; + out[i*8 + 5] = b5 - 7; + out[i*8 + 6] = b6 - 3; + out[i*8 + 7] = b7 - 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (in[i*8] + 5) * 3 - 2 + || out[i*8 + 1] != (in[i*8 + 1] + 6) * 2 - 3 + || out[i*8 + 2] != (in[i*8 + 2] + 7) * 12 - 2 + || out[i*8 + 3] != (in[i*8 + 3] + 8) * 5 - 1 + || out[i*8 + 4] != (in[i*8 + 4] + 9) * 8 - 8 + || out[i*8 + 5] != (in[i*8 + 5] + 10) * 4 - 7 + || out[i*8 + 6] != (in[i*8 + 6] + 11) * 3 - 3 + || out[i*8 + 7] != (in[i*8 + 7] + 12) * 2 - 7) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = (in[i*4] + 2) * 3; + out[i*4 + 1] = (in[i*4 + 1] + 2) * 7; + out[i*4 + 2] = (in[i*4 + 2] + 7) * 3; + out[i*4 + 3] = (in[i*4 + 3] + 7) * 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != (in[i*4] + 2) * 3 + || out[i*4 + 1] != (in[i*4 + 1] + 2) * 7 + || out[i*4 + 2] != (in[i*4 + 2] + 7) * 3 + || out[i*4 + 3] != (in[i*4 + 3] + 7) * 7) + abort (); + } + + for (i = 0; i < N*4; i++) + { + out2[i*2] = (float) (in[i*2] * 2 + 5) ; + out2[i*2 + 1] = (float) (in[i*2 + 1] * 3 + 7); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*4; i++) + { + if (out2[i*2] != (float) (in[i*2] * 2 + 5) + || out2[i*2 + 1] != (float) (in[i*2 + 1] * 3 + 7)) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" {target {vect_uintfloat_cvt && vect_int_mult} } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" {target {{! { vect_uintfloat_cvt}} && vect_int_mult} } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" {target {{! { vect_uintfloat_cvt}} && { ! {vect_int_mult}}} } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" {target { vect_uintfloat_cvt && vect_int_mult }} } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" {target {{! { vect_uintfloat_cvt}} && vect_int_mult} } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" {target {{! { vect_uintfloat_cvt}} && { ! {vect_int_mult}}} } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-11a.c b/SingleSource/Regression/C/gcc-dg/vect/slp-11a.c new file mode 100644 index 0000000000..fcb7cf6c7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-11a.c @@ -0,0 +1,75 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + + /* Different operations - not SLPable. */ + for (i = 0; i < N; i++) + { + a0 = in[i*8] + 5; + a1 = in[i*8 + 1] * 51072; + a2 = in[i*8 + 2] + 7; + a3 = in[i*8 + 3] + 8; + a4 = in[i*8 + 4] + 9; + a5 = in[i*8 + 5] + 10; + a6 = in[i*8 + 6] + 11; + a7 = in[i*8 + 7] + 12; + + b0 = a0 * 3; + b1 = a1 * 51072; + b2 = a2 * 12; + b3 = a3 * 5; + b4 = a4 * 8; + b5 = a5 * 4; + b6 = a6 * 3; + b7 = a7 * 2; + + out[i*8] = b0 - 2; + out[i*8 + 1] = b1 - 3; + out[i*8 + 2] = b2 - 2; + out[i*8 + 3] = b3 - 1; + out[i*8 + 4] = b4 - 8; + out[i*8 + 5] = b5 - 7; + out[i*8 + 6] = b6 - 3; + out[i*8 + 7] = b7 - 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (in[i*8] + 5) * 3 - 2 + || out[i*8 + 1] != (in[i*8 + 1] * 51072) * 51072 - 3 + || out[i*8 + 2] != (in[i*8 + 2] + 7) * 12 - 2 + || out[i*8 + 3] != (in[i*8 + 3] + 8) * 5 - 1 + || out[i*8 + 4] != (in[i*8 + 4] + 9) * 8 - 8 + || out[i*8 + 5] != (in[i*8 + 5] + 10) * 4 - 7 + || out[i*8 + 6] != (in[i*8 + 6] + 11) * 3 - 3 + || out[i*8 + 7] != (in[i*8 + 7] + 12) * 2 - 7) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_strided8 && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { vect_strided8 && vect_int_mult } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-11b.c b/SingleSource/Regression/C/gcc-dg/vect/slp-11b.c new file mode 100644 index 0000000000..df64c8db35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-11b.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + + /* Requires permutation for SLP. */ + for (i = 0; i < N*2; i++) + { + out[i*4] = (in[i*4] + 2) * 3; + out[i*4 + 1] = (in[i*4 + 2] + 2) * 7; + out[i*4 + 2] = (in[i*4 + 1] + 7) * 3; + out[i*4 + 3] = (in[i*4 + 3] + 3) * 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != (in[i*4] + 2) * 3 + || out[i*4 + 1] != (in[i*4 + 2] + 2) * 7 + || out[i*4 + 2] != (in[i*4 + 1] + 7) * 3 + || out[i*4 + 3] != (in[i*4 + 3] + 3) * 7) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { vect_strided4 || vect_perm } && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm && vect_int_mult } xfail vect_load_lanes } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-11c.c b/SingleSource/Regression/C/gcc-dg/vect/slp-11c.c new file mode 100644 index 0000000000..0f680cd4e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-11c.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + float out[N*8]; + + /* Different operations - not SLPable. */ + for (i = 0; i < N*4; i++) + { + out[i*2] = ((float) in[i*2] * 2 + 6) ; + out[i*2 + 1] = (float) (in[i*2 + 1] * 3 + 7); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*4; i++) + { + if (out[i*2] != ((float) in[i*2] * 2 + 6) + || out[i*2 + 1] != (float) (in[i*2 + 1] * 3 + 7)) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { vect_uintfloat_cvt && vect_strided2 } && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { { vect_uintfloat_cvt && vect_strided2 } && vect_int_mult } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-12a.c b/SingleSource/Regression/C/gcc-dg/vect/slp-12a.c new file mode 100644 index 0000000000..973de6ada2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-12a.c @@ -0,0 +1,80 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned int ia[N]; + + for (i = 0; i < N; i++) + { + + a0 = in[i*8] + 5; + a1 = in[i*8 + 1] + 6; + a2 = in[i*8 + 2] + 7; + a3 = in[i*8 + 3] + 8; + a4 = in[i*8 + 4] + 9; + a5 = in[i*8 + 5] + 10; + a6 = in[i*8 + 6] + 11; + a7 = in[i*8 + 7] + 12; + + b0 = a0 * 3; + b1 = a1 * 2; + b2 = a2 * 12; + b3 = a3 * 5; + b4 = a4 * 8; + b5 = a5 * 4; + b6 = a6 * 3; + b7 = a7 * 2; + + out[i*8] = b0 - 2; + out[i*8 + 1] = b1 - 3; + out[i*8 + 2] = b2 - 2; + out[i*8 + 3] = b3 - 1; + out[i*8 + 4] = b4 - 8; + out[i*8 + 5] = b5 - 7; + out[i*8 + 6] = b6 - 3; + out[i*8 + 7] = b7 - 7; + + ia[i] = b6; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (in[i*8] + 5) * 3 - 2 + || out[i*8 + 1] != (in[i*8 + 1] + 6) * 2 - 3 + || out[i*8 + 2] != (in[i*8 + 2] + 7) * 12 - 2 + || out[i*8 + 3] != (in[i*8 + 3] + 8) * 5 - 1 + || out[i*8 + 4] != (in[i*8 + 4] + 9) * 8 - 8 + || out[i*8 + 5] != (in[i*8 + 5] + 10) * 4 - 7 + || out[i*8 + 6] != (in[i*8 + 6] + 11) * 3 - 3 + || out[i*8 + 7] != (in[i*8 + 7] + 12) * 2 - 7 + || ia[i] != (in[i*8 + 6] + 11) * 3) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_strided8 && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { vect_strided8 && vect_int_mult } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { { vect_strided8 && {! vect_load_lanes } } && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! { vect_strided8 && vect_int_mult } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-12b.c b/SingleSource/Regression/C/gcc-dg/vect/slp-12b.c new file mode 100644 index 0000000000..e2ea24d6c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-12b.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_uintfloat_cvt } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 64 + +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +int +main1 () +{ + int i; + float out2[N*8], fa[N*4]; + + for (i = 0; i < N; i++) + { + out2[i*2] = (float) (in[i*2] * 2 + 11) ; + out2[i*2 + 1] = (float) (in[i*2 + 1] * 3 + 7); + + fa[i] = (float) in[i*2+1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out2[i*2] != (float) (in[i*2] * 2 + 11) + || out2[i*2 + 1] != (float) (in[i*2 + 1] * 3 + 7) + || fa[i] != (float) in[i*2+1]) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_strided2 && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { vect_strided2 && vect_int_mult } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_strided2 && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! { vect_strided2 && vect_int_mult } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-12c.c b/SingleSource/Regression/C/gcc-dg/vect/slp-12c.c new file mode 100644 index 0000000000..9c48dff3bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-12c.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned int ia[N*2]; + + for (i = 0; i < N*2; i++) + { + out[i*4] = (in[i*4] + 2) * 3; + out[i*4 + 1] = (in[i*4 + 1] + 2) * 7; + out[i*4 + 2] = (in[i*4 + 2] + 7) * 3; + out[i*4 + 3] = (in[i*4 + 3] + 7) * 7; + + ia[i] = 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != (in[i*4] + 2) * 3 + || out[i*4 + 1] != (in[i*4 + 1] + 2) * 7 + || out[i*4 + 2] != (in[i*4 + 2] + 7) * 3 + || out[i*4 + 3] != (in[i*4 + 3] + 7) * 7 + || ia[i] != 7) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_int_mult } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! vect_int_mult } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-13-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/slp-13-big-array.c new file mode 100644 index 0000000000..ca70856c1d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-13-big-array.c @@ -0,0 +1,140 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +int +main1 () +{ + int i; + unsigned short out[N*8]; + unsigned short in[N*8]; + unsigned int in2[N*8]; + unsigned int out2[N*8]; + + for (i = 0; i < N*8; i++) + { + in[i] = in2[i] = i; + asm volatile ("" ::: "memory"); + } + + /* Induction is SLPable. */ + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8] + i; + out[i*8 + 1] = in[i*8 + 1] + i; + out[i*8 + 2] = in[i*8 + 2] + i; + out[i*8 + 3] = in[i*8 + 3] + i; + out[i*8 + 4] = in[i*8 + 4] + i; + out[i*8 + 5] = in[i*8 + 5] + i; + out[i*8 + 6] = in[i*8 + 6] + i; + out[i*8 + 7] = in[i*8 + 7] + i; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + i + || out[i*8 + 1] != in[i*8 + 1] + i + || out[i*8 + 2] != in[i*8 + 2] + i + || out[i*8 + 3] != in[i*8 + 3] + i + || out[i*8 + 4] != in[i*8 + 4] + i + || out[i*8 + 5] != in[i*8 + 5] + i + || out[i*8 + 6] != in[i*8 + 6] + i + || out[i*8 + 7] != in[i*8 + 7] + i) + abort (); + } + + /* Induction is SLPable. */ + for (i = 0; i < N/2; i++) + { + out2[i*12] = in2[i*12] + i; + out2[i*12 + 1] = in2[i*12 + 1] + i; + out2[i*12 + 2] = in2[i*12 + 2] + i; + out2[i*12 + 3] = in2[i*12 + 3] + i; + out2[i*12 + 4] = in2[i*12 + 4] + i; + out2[i*12 + 5] = in2[i*12 + 5] + i; + out2[i*12 + 6] = in2[i*12 + 6] + i; + out2[i*12 + 7] = in2[i*12 + 7] + i; + out2[i*12 + 8] = in2[i*12 + 8] + i; + out2[i*12 + 9] = in2[i*12 + 9] + i; + out2[i*12 + 10] = in2[i*12 + 10] + i; + out2[i*12 + 11] = in2[i*12 + 11] + i; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out2[i*12] != in2[i*12] + i + || out2[i*12 + 1] != in2[i*12 + 1] + i + || out2[i*12 + 2] != in2[i*12 + 2] + i + || out2[i*12 + 3] != in2[i*12 + 3] + i + || out2[i*12 + 4] != in2[i*12 + 4] + i + || out2[i*12 + 5] != in2[i*12 + 5] + i + || out2[i*12 + 6] != in2[i*12 + 6] + i + || out2[i*12 + 7] != in2[i*12 + 7] + i + || out2[i*12 + 8] != in2[i*12 + 8] + i + || out2[i*12 + 9] != in2[i*12 + 9] + i + || out2[i*12 + 10] != in2[i*12 + 10] + i + || out2[i*12 + 11] != in2[i*12 + 11] + i) + abort (); + } + + /* Not power of 2 but SLPable. */ + for (i = 0; i < N/2; i++) + { + out2[i*12] = in2[i*12] + 1; + out2[i*12 + 1] = in2[i*12 + 1] + 2; + out2[i*12 + 2] = in2[i*12 + 2] + 3; + out2[i*12 + 3] = in2[i*12 + 3] + 4; + out2[i*12 + 4] = in2[i*12 + 4] + 5; + out2[i*12 + 5] = in2[i*12 + 5] + 6; + out2[i*12 + 6] = in2[i*12 + 6] + 7; + out2[i*12 + 7] = in2[i*12 + 7] + 8; + out2[i*12 + 8] = in2[i*12 + 8] + 9; + out2[i*12 + 9] = in2[i*12 + 9] + 10; + out2[i*12 + 10] = in2[i*12 + 10] + 11; + out2[i*12 + 11] = in2[i*12 + 11] + 12; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out2[i*12] != in2[i*12] + 1 + || out2[i*12 + 1] != in2[i*12 + 1] + 2 + || out2[i*12 + 2] != in2[i*12 + 2] + 3 + || out2[i*12 + 3] != in2[i*12 + 3] + 4 + || out2[i*12 + 4] != in2[i*12 + 4] + 5 + || out2[i*12 + 5] != in2[i*12 + 5] + 6 + || out2[i*12 + 6] != in2[i*12 + 6] + 7 + || out2[i*12 + 7] != in2[i*12 + 7] + 8 + || out2[i*12 + 8] != in2[i*12 + 8] + 9 + || out2[i*12 + 9] != in2[i*12 + 9] + 10 + || out2[i*12 + 10] != in2[i*12 + 10] + 11 + || out2[i*12 + 11] != in2[i*12 + 11] + 12) + abort (); + } + + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { { vect_interleave && vect_extract_even_odd } && { ! vect_pack_trunc } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { ! vect_pack_trunc } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { { vect_interleave && vect_extract_even_odd } && vect_pack_trunc } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target vect_pack_trunc xfail vect_variable_length } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-13.c b/SingleSource/Regression/C/gcc-dg/vect/slp-13.c new file mode 100644 index 0000000000..b7f947e6db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-13.c @@ -0,0 +1,134 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned short out[N*8]; + unsigned short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned int in2[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned int out2[N*8]; + + /* Induction is SLPable. */ + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8] + i; + out[i*8 + 1] = in[i*8 + 1] + i; + out[i*8 + 2] = in[i*8 + 2] + i; + out[i*8 + 3] = in[i*8 + 3] + i; + out[i*8 + 4] = in[i*8 + 4] + i; + out[i*8 + 5] = in[i*8 + 5] + i; + out[i*8 + 6] = in[i*8 + 6] + i; + out[i*8 + 7] = in[i*8 + 7] + i; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + i + || out[i*8 + 1] != in[i*8 + 1] + i + || out[i*8 + 2] != in[i*8 + 2] + i + || out[i*8 + 3] != in[i*8 + 3] + i + || out[i*8 + 4] != in[i*8 + 4] + i + || out[i*8 + 5] != in[i*8 + 5] + i + || out[i*8 + 6] != in[i*8 + 6] + i + || out[i*8 + 7] != in[i*8 + 7] + i) + abort (); + } + + /* Induction is SLPable. */ + for (i = 0; i < N/2; i++) + { + out2[i*12] = in2[i*12] + i; + out2[i*12 + 1] = in2[i*12 + 1] + i; + out2[i*12 + 2] = in2[i*12 + 2] + i; + out2[i*12 + 3] = in2[i*12 + 3] + i; + out2[i*12 + 4] = in2[i*12 + 4] + i; + out2[i*12 + 5] = in2[i*12 + 5] + i; + out2[i*12 + 6] = in2[i*12 + 6] + i; + out2[i*12 + 7] = in2[i*12 + 7] + i; + out2[i*12 + 8] = in2[i*12 + 8] + i; + out2[i*12 + 9] = in2[i*12 + 9] + i; + out2[i*12 + 10] = in2[i*12 + 10] + i; + out2[i*12 + 11] = in2[i*12 + 11] + i; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out2[i*12] != in2[i*12] + i + || out2[i*12 + 1] != in2[i*12 + 1] + i + || out2[i*12 + 2] != in2[i*12 + 2] + i + || out2[i*12 + 3] != in2[i*12 + 3] + i + || out2[i*12 + 4] != in2[i*12 + 4] + i + || out2[i*12 + 5] != in2[i*12 + 5] + i + || out2[i*12 + 6] != in2[i*12 + 6] + i + || out2[i*12 + 7] != in2[i*12 + 7] + i + || out2[i*12 + 8] != in2[i*12 + 8] + i + || out2[i*12 + 9] != in2[i*12 + 9] + i + || out2[i*12 + 10] != in2[i*12 + 10] + i + || out2[i*12 + 11] != in2[i*12 + 11] + i) + abort (); + } + + /* Not power of 2 but SLPable. */ + for (i = 0; i < N/2; i++) + { + out2[i*12] = in2[i*12] + 1; + out2[i*12 + 1] = in2[i*12 + 1] + 2; + out2[i*12 + 2] = in2[i*12 + 2] + 3; + out2[i*12 + 3] = in2[i*12 + 3] + 4; + out2[i*12 + 4] = in2[i*12 + 4] + 5; + out2[i*12 + 5] = in2[i*12 + 5] + 6; + out2[i*12 + 6] = in2[i*12 + 6] + 7; + out2[i*12 + 7] = in2[i*12 + 7] + 8; + out2[i*12 + 8] = in2[i*12 + 8] + 9; + out2[i*12 + 9] = in2[i*12 + 9] + 10; + out2[i*12 + 10] = in2[i*12 + 10] + 11; + out2[i*12 + 11] = in2[i*12 + 11] + 12; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out2[i*12] != in2[i*12] + 1 + || out2[i*12 + 1] != in2[i*12 + 1] + 2 + || out2[i*12 + 2] != in2[i*12 + 2] + 3 + || out2[i*12 + 3] != in2[i*12 + 3] + 4 + || out2[i*12 + 4] != in2[i*12 + 4] + 5 + || out2[i*12 + 5] != in2[i*12 + 5] + 6 + || out2[i*12 + 6] != in2[i*12 + 6] + 7 + || out2[i*12 + 7] != in2[i*12 + 7] + 8 + || out2[i*12 + 8] != in2[i*12 + 8] + 9 + || out2[i*12 + 9] != in2[i*12 + 9] + 10 + || out2[i*12 + 10] != in2[i*12 + 10] + 11 + || out2[i*12 + 11] != in2[i*12 + 11] + 12) + abort (); + } + + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { { vect_interleave && vect_extract_even_odd } && { ! vect_pack_trunc } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { ! vect_pack_trunc } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { { vect_interleave && vect_extract_even_odd } && vect_pack_trunc } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target vect_pack_trunc xfail vect_variable_length } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-14.c b/SingleSource/Regression/C/gcc-dg/vect/slp-14.c new file mode 100644 index 0000000000..ccf23c1e44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-14.c @@ -0,0 +1,116 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned short in2[N*16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +int +main1 (int n) +{ + int i; + unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + unsigned short out2[N*16]; + + /* Multiple types are now SLPable. */ + for (i = 0; i < n; i++) + { + a0 = in[i*8] + 5; + a1 = in[i*8 + 1] + 6; + a2 = in[i*8 + 2] + 7; + a3 = in[i*8 + 3] + 8; + a4 = in[i*8 + 4] + 9; + a5 = in[i*8 + 5] + 10; + a6 = in[i*8 + 6] + 11; + a7 = in[i*8 + 7] + 12; + + b0 = a0 * 3; + b1 = a1 * 2; + b2 = a2 * 12; + b3 = a3 * 5; + b4 = a4 * 8; + b5 = a5 * 4; + b6 = a6 * 3; + b7 = a7 * 2; + + out[i*8] = b0 - 2; + out[i*8 + 1] = b1 - 3; + out[i*8 + 2] = b2 - 2; + out[i*8 + 3] = b3 - 1; + out[i*8 + 4] = b4 - 8; + out[i*8 + 5] = b5 - 7; + out[i*8 + 6] = b6 - 3; + out[i*8 + 7] = b7 - 7; + + out2[i*16] = in2[i*16] + 2; + out2[i*16 + 1] = in2[i*16 + 1] + 3; + out2[i*16 + 2] = in2[i*16 + 2] + 4; + out2[i*16 + 3] = in2[i*16 + 3] + 3; + out2[i*16 + 4] = in2[i*16 + 4] + 2; + out2[i*16 + 5] = in2[i*16 + 5] + 3; + out2[i*16 + 6] = in2[i*16 + 6] + 2; + out2[i*16 + 7] = in2[i*16 + 7] + 4; + out2[i*16 + 8] = in2[i*16 + 8] + 2; + out2[i*16 + 9] = in2[i*16 + 9] + 5; + out2[i*16 + 10] = in2[i*16 + 10] + 2; + out2[i*16 + 11] = in2[i*16 + 11] + 3; + out2[i*16 + 12] = in2[i*16 + 12] + 4; + out2[i*16 + 13] = in2[i*16 + 13] + 4; + out2[i*16 + 14] = in2[i*16 + 14] + 3; + out2[i*16 + 15] = in2[i*16 + 15] + 2; +} + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (out[i*8] != (in[i*8] + 5) * 3 - 2 + || out[i*8 + 1] != (in[i*8 + 1] + 6) * 2 - 3 + || out[i*8 + 2] != (in[i*8 + 2] + 7) * 12 - 2 + || out[i*8 + 3] != (in[i*8 + 3] + 8) * 5 - 1 + || out[i*8 + 4] != (in[i*8 + 4] + 9) * 8 - 8 + || out[i*8 + 5] != (in[i*8 + 5] + 10) * 4 - 7 + || out[i*8 + 6] != (in[i*8 + 6] + 11) * 3 - 3 + || out[i*8 + 7] != (in[i*8 + 7] + 12) * 2 - 7) + abort (); + + if (out2[i*16] != in2[i*16] + 2 + || out2[i*16 + 1] != in2[i*16 + 1] + 3 + || out2[i*16 + 2] != in2[i*16 + 2] + 4 + || out2[i*16 + 3] != in2[i*16 + 3] + 3 + || out2[i*16 + 4] != in2[i*16 + 4] + 2 + || out2[i*16 + 5] != in2[i*16 + 5] + 3 + || out2[i*16 + 6] != in2[i*16 + 6] + 2 + || out2[i*16 + 7] != in2[i*16 + 7] + 4 + || out2[i*16 + 8] != in2[i*16 + 8] + 2 + || out2[i*16 + 9] != in2[i*16 + 9] + 5 + || out2[i*16 + 10] != in2[i*16 + 10] + 2 + || out2[i*16 + 11] != in2[i*16 + 11] + 3 + || out2[i*16 + 12] != in2[i*16 + 12] + 4 + || out2[i*16 + 13] != in2[i*16 + 13] + 4 + || out2[i*16 + 14] != in2[i*16 + 14] + 3 + || out2[i*16 + 15] != in2[i*16 + 15] + 2) + abort (); + + } + + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_int_mult } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_int_mult } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-15.c b/SingleSource/Regression/C/gcc-dg/vect/slp-15.c new file mode 100644 index 0000000000..13a0f3e301 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-15.c @@ -0,0 +1,118 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned int in2[N*16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned int out2[N*16]; + +int +main1 (int n) +{ + int i; + unsigned int a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + + for (i = 0; i < n; i++) + { + a0 = in[i*8] + 5; + a1 = in[i*8 + 1] + 6; + a2 = in[i*8 + 2] + 7; + a3 = in[i*8 + 3] + 8; + a4 = in[i*8 + 4] + 9; + a5 = in[i*8 + 5] + 10; + a6 = in[i*8 + 6] + 11; + a7 = in[i*8 + 7] + 12; + + b0 = a0 * 3; + b1 = a1 * 2; + b2 = a2 * 12; + b3 = a3 * 5; + b4 = a4 * 8; + b5 = a5 * 4; + b6 = a6 * 3; + b7 = a7 * 2; + + out[i*8] = b0 - 2; + out[i*8 + 1] = b1 - 3; + out[i*8 + 2] = b2 - 2; + out[i*8 + 3] = b3 - 1; + out[i*8 + 4] = b4 - 8; + out[i*8 + 5] = b5 - 7; + out[i*8 + 6] = b6 - 3; + out[i*8 + 7] = b7 - 7; + + out2[i*16] = in2[i*16] * 2; + out2[i*16 + 1] = in2[i*16 + 1] * 3; + out2[i*16 + 2] = in2[i*16 + 2] * 4; + out2[i*16 + 3] = in2[i*16 + 3] * 3; + out2[i*16 + 4] = in2[i*16 + 4] * 2; + out2[i*16 + 5] = in2[i*16 + 5] * 3; + out2[i*16 + 6] = in2[i*16 + 6] * 2; + out2[i*16 + 7] = in2[i*16 + 7] * 4; + out2[i*16 + 8] = in2[i*16 + 8] * 2; + out2[i*16 + 9] = in2[i*16 + 9] * 5; + out2[i*16 + 10] = in2[i*16 + 10] * 2; + out2[i*16 + 11] = in2[i*16 + 11] * 3; + out2[i*16 + 12] = in2[i*16 + 12] * 4; + out2[i*16 + 13] = in2[i*16 + 13] * 4; + out2[i*16 + 14] = in2[i*16 + 14] * 3; + out2[i*16 + 15] = in2[i*16 + 15] * 2; +} + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (out[i*8] != (in[i*8] + 5) * 3 - 2 + || out[i*8 + 1] != (in[i*8 + 1] + 6) * 2 - 3 + || out[i*8 + 2] != (in[i*8 + 2] + 7) * 12 - 2 + || out[i*8 + 3] != (in[i*8 + 3] + 8) * 5 - 1 + || out[i*8 + 4] != (in[i*8 + 4] + 9) * 8 - 8 + || out[i*8 + 5] != (in[i*8 + 5] + 10) * 4 - 7 + || out[i*8 + 6] != (in[i*8 + 6] + 11) * 3 - 3 + || out[i*8 + 7] != (in[i*8 + 7] + 12) * 2 - 7) + abort (); + + if (out2[i*16] != in2[i*16] * 2 + || out2[i*16 + 1] != in2[i*16 + 1] * 3 + || out2[i*16 + 2] != in2[i*16 + 2] * 4 + || out2[i*16 + 3] != in2[i*16 + 3] * 3 + || out2[i*16 + 4] != in2[i*16 + 4] * 2 + || out2[i*16 + 5] != in2[i*16 + 5] * 3 + || out2[i*16 + 6] != in2[i*16 + 6] * 2 + || out2[i*16 + 7] != in2[i*16 + 7] * 4 + || out2[i*16 + 8] != in2[i*16 + 8] * 2 + || out2[i*16 + 9] != in2[i*16 + 9] * 5 + || out2[i*16 + 10] != in2[i*16 + 10] * 2 + || out2[i*16 + 11] != in2[i*16 + 11] * 3 + || out2[i*16 + 12] != in2[i*16 + 12] * 4 + || out2[i*16 + 13] != in2[i*16 + 13] * 4 + || out2[i*16 + 14] != in2[i*16 + 14] * 3 + || out2[i*16 + 15] != in2[i*16 + 15] * 2) + abort (); + + } + + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" {target vect_int_mult } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" {target { ! { vect_int_mult } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" {target vect_int_mult } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" {target { ! { vect_int_mult } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-16.c b/SingleSource/Regression/C/gcc-dg/vect/slp-16.c new file mode 100644 index 0000000000..44ba730bda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-16.c @@ -0,0 +1,71 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned int out[N*8]; +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned int in2[N*16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned int out2[N*16]; + +int +main1 () +{ + int i; + unsigned int a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + + /* SLP group of size that is not a multiple of vector size. + Unrolling by 2. */ + for (i = 0; i < N; i++) + { + a0 = in[i*2] + 5; + a1 = in[i*2 + 1] + 6; + + b0 = a0 * 3; + b1 = a1 * 2; + + out[i*2] = b0 - 2; + out[i*2 + 1] = b1 - 3; + + out2[i*6] = in2[i*6] * 2; + out2[i*6 + 1] = in2[i*6 + 1] * 3; + out2[i*6 + 2] = in2[i*6 + 2] * 4; + out2[i*6 + 3] = in2[i*6 + 3] * 2; + out2[i*6 + 4] = in2[i*6 + 4] * 4; + out2[i*6 + 5] = in2[i*6 + 5] * 3; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*2] != (in[i*2] + 5) * 3 - 2 + || out[i*2 + 1] != (in[i*2 + 1] + 6) * 2 - 3 + || out2[i*6] != in2[i*6] * 2 + || out2[i*6 + 1] != in2[i*6 + 1] * 3 + || out2[i*6 + 2] != in2[i*6 + 2] * 4 + || out2[i*6 + 3] != in2[i*6 + 3] * 2 + || out2[i*6 + 4] != in2[i*6 + 4] * 4 + || out2[i*6 + 5] != in2[i*6 + 5] * 3) + abort (); + } + + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_int_mult } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_int_mult && {! vect_strided6 } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-17.c b/SingleSource/Regression/C/gcc-dg/vect/slp-17.c new file mode 100644 index 0000000000..c759a5f014 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-17.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned short out[N*8]; +unsigned short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned short in2[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned short out2[N*8]; + +int +main1 () +{ + int i; + + for (i = 0; i < N*2; i++) + { + out[i*2] = in[i*2] + 5; + out[i*2 + 1] = in[i*2 + 1] + 6; + + out2[i*4] = in2[i*4] + 2; + out2[i*4 + 1] = in2[i*4 + 1] + 2; + out2[i*4 + 2] = in2[i*4 + 2] + 1; + out2[i*4 + 3] = in2[i*4 + 3] + 3; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*2] != in[i*2] + 5 + || out[i*2 + 1] != in[i*2 + 1] + 6 + || out2[i*4] != in2[i*4] + 2 + || out2[i*4 + 1] != in2[i*4 + 1] + 2 + || out2[i*4 + 2] != in2[i*4 + 2] + 1 + || out2[i*4 + 3] != in2[i*4 + 3] + 3) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-18.c b/SingleSource/Regression/C/gcc-dg/vect/slp-18.c new file mode 100644 index 0000000000..f31088cb76 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-18.c @@ -0,0 +1,98 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_intfloat_cvt } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + float out2[N*8]; + + for (i = 0; i < N; i++) + { + + a0 = in[i*8] + 5; + a1 = in[i*8 + 1] + 6; + a2 = in[i*8 + 2] + 7; + a3 = in[i*8 + 3] + 8; + a4 = in[i*8 + 4] + 9; + a5 = in[i*8 + 5] + 10; + a6 = in[i*8 + 6] + 11; + a7 = in[i*8 + 7] + 12; + + b0 = a0 * 3; + b1 = a1 * 2; + b2 = a2 * 12; + b3 = a3 * 5; + b4 = a4 * 8; + b5 = a5 * 4; + b6 = a6 * 3; + b7 = a7 * 2; + + out[i*8] = b0 - 2; + out[i*8 + 1] = b1 - 3; + out[i*8 + 2] = b2 - 2; + out[i*8 + 3] = b3 - 1; + out[i*8 + 4] = b4 - 8; + out[i*8 + 5] = b5 - 7; + out[i*8 + 6] = b6 - 3; + out[i*8 + 7] = b7 - 7; + + + out2[i*8] = (float) b0; + out2[i*8 + 1] = (float) b1; + out2[i*8 + 2] = (float) b2; + out2[i*8 + 3] = (float) b3; + out2[i*8 + 4] = (float) b4; + out2[i*8 + 5] = (float) b5; + out2[i*8 + 6] = (float) b6; + out2[i*8 + 7] = (float) b7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (in[i*8] + 5) * 3 - 2 + || out[i*8 + 1] != (in[i*8 + 1] + 6) * 2 - 3 + || out[i*8 + 2] != (in[i*8 + 2] + 7) * 12 - 2 + || out[i*8 + 3] != (in[i*8 + 3] + 8) * 5 - 1 + || out[i*8 + 4] != (in[i*8 + 4] + 9) * 8 - 8 + || out[i*8 + 5] != (in[i*8 + 5] + 10) * 4 - 7 + || out[i*8 + 6] != (in[i*8 + 6] + 11) * 3 - 3 + || out[i*8 + 7] != (in[i*8 + 7] + 12) * 2 - 7) + abort (); + + if (out2[i*8] != (float) ((in[i*8] + 5) * 3) + || out2[i*8 + 1] != (float) ((in[i*8 + 1] + 6) * 2) + || out2[i*8 + 2] != (float) ((in[i*8 + 2] + 7) * 12) + || out2[i*8 + 3] != (float) ((in[i*8 + 3] + 8) * 5) + || out2[i*8 + 4] != (float) ((in[i*8 + 4] + 9) * 8) + || out2[i*8 + 5] != (float) ((in[i*8 + 5] + 10) * 4) + || out2[i*8 + 6] != (float) ((in[i*8 + 6] + 11) * 3) + || out2[i*8 + 7] != (float) ((in[i*8 + 7] + 12) * 2)) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-19a.c b/SingleSource/Regression/C/gcc-dg/vect/slp-19a.c new file mode 100644 index 0000000000..ca7a0a8e45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-19a.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int +main1 () +{ + unsigned int i; + unsigned int out[N*8]; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned int ia[N*2]; + + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8]; + out[i*8 + 1] = in[i*8 + 1]; + out[i*8 + 2] = in[i*8 + 2]; + out[i*8 + 3] = in[i*8 + 3]; + out[i*8 + 4] = in[i*8 + 4]; + out[i*8 + 5] = in[i*8 + 5]; + out[i*8 + 6] = in[i*8 + 6]; + out[i*8 + 7] = in[i*8 + 7]; + + ia[i] = in[i*8 + 2]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + || out[i*8 + 1] != in[i*8 + 1] + || out[i*8 + 2] != in[i*8 + 2] + || out[i*8 + 3] != in[i*8 + 3] + || out[i*8 + 4] != in[i*8 + 4] + || out[i*8 + 5] != in[i*8 + 5] + || out[i*8 + 6] != in[i*8 + 6] + || out[i*8 + 7] != in[i*8 + 7] + || ia[i] != in[i*8 + 2]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! vect_strided8 } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_strided8 } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! vect_strided8} } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-19b.c b/SingleSource/Regression/C/gcc-dg/vect/slp-19b.c new file mode 100644 index 0000000000..4d53ac698d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-19b.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int +main1 () +{ + unsigned int i; + unsigned int out[N*8]; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned int ia[N*2], a0, a1, a2, a3; + + for (i = 0; i < N*2; i++) + { + a0 = in[i*4] + 1; + a1 = in[i*4 + 1] + 2; + a2 = in[i*4 + 2] + 3; + a3 = in[i*4 + 3] + 4; + + out[i*4] = a0; + out[i*4 + 1] = a1; + out[i*4 + 2] = a2; + out[i*4 + 3] = a3; + + ia[i] = a2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != in[i*4] + 1 + || out[i*4 + 1] != in[i*4 + 1] + 2 + || out[i*4 + 2] != in[i*4 + 2] + 3 + || out[i*4 + 3] != in[i*4 + 3] + 4 + || ia[i] != in[i*4 + 2] + 3) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided4 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! vect_strided4 } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_strided4 } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! vect_strided4 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-19c.c b/SingleSource/Regression/C/gcc-dg/vect/slp-19c.c new file mode 100644 index 0000000000..188ab37a0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-19c.c @@ -0,0 +1,109 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 32) +#else +#define N 16 +#endif + +int +main1 () +{ + unsigned int i; + unsigned int out[N*8]; +#if N == 16 + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +#else + unsigned int in[N * 8]; + for (unsigned int i = 0; i < N * 8; ++i) + { + in[i] = i & 63; + asm volatile ("" ::: "memory"); + } +#endif + unsigned int ia[N*2], a0, a1, a2, a3; + + /* The last stmt requires interleaving of not power of 2 size - not + vectorizable. */ + for (i = 0; i < N/2; i++) + { + out[i*12] = in[i*12]; + out[i*12 + 1] = in[i*12 + 1]; + out[i*12 + 2] = in[i*12 + 2]; + out[i*12 + 3] = in[i*12 + 3]; + out[i*12 + 4] = in[i*12 + 4]; + out[i*12 + 5] = in[i*12 + 5]; + out[i*12 + 6] = in[i*12 + 6]; + out[i*12 + 7] = in[i*12 + 7]; + out[i*12 + 8] = in[i*12 + 8]; + out[i*12 + 9] = in[i*12 + 9]; + out[i*12 + 10] = in[i*12 + 10]; + out[i*12 + 11] = in[i*12 + 11]; + + ia[i] = in[i*12 + 7]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*12] != in[i*12] + || out[i*12 + 1] != in[i*12 + 1] + || out[i*12 + 2] != in[i*12 + 2] + || out[i*12 + 3] != in[i*12 + 3] + || out[i*12 + 4] != in[i*12 + 4] + || out[i*12 + 5] != in[i*12 + 5] + || out[i*12 + 6] != in[i*12 + 6] + || out[i*12 + 7] != in[i*12 + 7] + || out[i*12 + 8] != in[i*12 + 8] + || out[i*12 + 9] != in[i*12 + 9] + || out[i*12 + 10] != in[i*12 + 10] + || out[i*12 + 11] != in[i*12 + 11] + || ia[i] != in[i*12 + 7]) + abort (); + } + + /* Hybrid SLP with unrolling by 2. */ + for (i = 0; i < N; i++) + { + out[i*6] = in[i*6]; + out[i*6 + 1] = in[i*6 + 1]; + out[i*6 + 2] = in[i*6 + 2]; + out[i*6 + 3] = in[i*6 + 3]; + out[i*6 + 4] = in[i*6 + 4]; + out[i*6 + 5] = in[i*6 + 5]; + + ia[i] = i; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*6] != in[i*6] + || out[i*6 + 1] != in[i*6 + 1] + || out[i*6 + 2] != in[i*6 + 2] + || out[i*6 + 3] != in[i*6 + 3] + || out[i*6 + 4] != in[i*6 + 4] + || out[i*6 + 5] != in[i*6 + 5] + || ia[i] != i) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-2.c b/SingleSource/Regression/C/gcc-dg/vect/slp-2.c new file mode 100644 index 0000000000..d0de3577eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-2.c @@ -0,0 +1,148 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int +main1 (unsigned short a0, unsigned short a1, unsigned short a2, + unsigned short a3, unsigned short a4, unsigned short a5, + unsigned short a6, unsigned short a7, unsigned short a8, + unsigned short a9, unsigned short a10, unsigned short a11, + unsigned short a12, unsigned short a13, unsigned short a14, + unsigned short a15) +{ + int i; + unsigned short out[N*16]; + + for (i = 0; i < N; i++) + { + out[i*4] = a8; + out[i*4 + 1] = a1; + out[i*4 + 2] = a2; + out[i*4 + 3] = a3; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != a8 + || out[i*4 + 1] != a1 + || out[i*4 + 2] != a2 + || out[i*4 + 3] != a3) + abort (); + } + + for (i = 0; i < N; i++) + { + out[i*16] = a8; + out[i*16 + 1] = a7; + out[i*16 + 2] = a1; + out[i*16 + 3] = a2; + out[i*16 + 4] = a8; + out[i*16 + 5] = a5; + out[i*16 + 6] = a5; + out[i*16 + 7] = a4; + out[i*16 + 8] = a12; + out[i*16 + 9] = a13; + out[i*16 + 10] = a14; + out[i*16 + 11] = a15; + out[i*16 + 12] = a6; + out[i*16 + 13] = a9; + out[i*16 + 14] = a0; + out[i*16 + 15] = a7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*16] != a8 + || out[i*16 + 1] != a7 + || out[i*16 + 2] != a1 + || out[i*16 + 3] != a2 + || out[i*16 + 4] != a8 + || out[i*16 + 5] != a5 + || out[i*16 + 6] != a5 + || out[i*16 + 7] != a4 + || out[i*16 + 8] != a12 + || out[i*16 + 9] != a13 + || out[i*16 + 10] != a14 + || out[i*16 + 11] != a15 + || out[i*16 + 12] != a6 + || out[i*16 + 13] != a9 + || out[i*16 + 14] != a0 + || out[i*16 + 15] != a7) + abort (); + } + + /* SLP with unrolling by 8. */ + for (i = 0; i < N; i++) + { + out[i*3] = a8; + out[i*3 + 1] = a1; + out[i*3 + 2] = a2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*3] != a8 + || out[i*3 + 1] != a1 + || out[i*3 + 2] != a2) + abort (); + } + + /* SLP with unrolling by 8. */ + for (i = 0; i < N; i++) + { + out[i*11] = a8; + out[i*11 + 1] = a7; + out[i*11 + 2] = a1; + out[i*11 + 3] = a2; + out[i*11 + 4] = a8; + out[i*11 + 5] = a5; + out[i*11 + 6] = a5; + out[i*11 + 7] = a4; + out[i*11 + 8] = a12; + out[i*11 + 9] = a13; + out[i*11 + 10] = a14; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*11] != a8 + || out[i*11 + 1] != a7 + || out[i*11 + 2] != a1 + || out[i*11 + 3] != a2 + || out[i*11 + 4] != a8 + || out[i*11 + 5] != a5 + || out[i*11 + 6] != a5 + || out[i*11 + 7] != a4 + || out[i*11 + 8] != a12 + || out[i*11 + 9] != a13 + || out[i*11 + 10] != a14) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { xfail vect_variable_length } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-20.c b/SingleSource/Regression/C/gcc-dg/vect/slp-20.c new file mode 100644 index 0000000000..ea19095f9f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-20.c @@ -0,0 +1,116 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int +main1 (unsigned short a0, unsigned short a1, unsigned short a2, + unsigned short a3, unsigned short a4, unsigned short a5, + unsigned short a6, unsigned short a7, unsigned short a8) +{ + int i; + unsigned short out[N*8], out2[N*8], b0, b1, b2, b3, b4, b5, b6, b7, b8; + + for (i = 0; i < N; i++) + { + b0 = a0 + 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 + 5; + b4 = a4 + 4; + b5 = a5 + 3; + + out[i*4] = b0; + out[i*4 + 1] = b1; + out[i*4 + 2] = b2; + out[i*4 + 3] = b3; + + out2[i*4] = b0; + out2[i*4 + 1] = b1; + out2[i*4 + 2] = b4; + out2[i*4 + 3] = b5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != b0 + || out[i*4 + 1] != b1 + || out[i*4 + 2] != b2 + || out[i*4 + 3] != b3) + abort (); + + if (out2[i*4] != b0 + || out2[i*4 + 1] != b1 + || out2[i*4 + 2] != b4 + || out2[i*4 + 3] != b5) + abort (); + } + + for (i = 0; i < N; i++) + { + b0 = a0 + 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 + 5; + b4 = a4 + 4; + b5 = a5 + 3; + b6 = a6 + 2; + b7 = a7 + 1; + b8 = a8 + 9; + + out[i*4] = b0; + out[i*4 + 1] = b1; + out[i*4 + 2] = b2; + out[i*4 + 3] = b3; + + out2[i*8] = b0; + out2[i*8 + 1] = b1; + out2[i*8 + 2] = b4; + out2[i*8 + 3] = b5; + out2[i*8 + 4] = b6; + out2[i*8 + 5] = b2; + out2[i*8 + 6] = b7; + out2[i*8 + 7] = b8; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != b0 + || out[i*4 + 1] != b1 + || out[i*4 + 2] != b2 + || out[i*4 + 3] != b3) + abort (); + + if (out2[i*8] != b0 + || out2[i*8 + 1] != b1 + || out2[i*8 + 2] != b4 + || out2[i*8 + 3] != b5 + || out2[i*8 + 4] != b6 + || out2[i*8 + 5] != b2 + || out2[i*8 + 6] != b7 + || out2[i*8 + 7] != b8) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (8,7,6,5,4,3,2,1,0); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-21.c b/SingleSource/Regression/C/gcc-dg/vect/slp-21.c new file mode 100644 index 0000000000..712a73b69d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-21.c @@ -0,0 +1,219 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int +main1 () +{ + unsigned short i; + unsigned short out[N*8], out2[N*8], b0, b1, b2, b3, b4, a0, a1, a2, a3, b5; + unsigned short in[N*8]; + + for (i = 0; i < N*8; i++) + { + in[i] = i; + } + + /* Different operations in both cases - vectorization with interleaving. */ + for (i = 0; i < N; i++) + { + a0 = in[i*4]; + a1 = in[i*4 + 1]; + a2 = in[i*4 + 2]; + a3 = in[i*4 + 3]; + + b0 = a0 * 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 * 5; + + b4 = a2 + 4; + b5 = a3 + 3; + + out[i*4] = b0; + out[i*4 + 1] = b1; + out[i*4 + 2] = b2; + out[i*4 + 3] = b3; + + out2[i*4] = b0; + out2[i*4 + 1] = b1; + out2[i*4 + 2] = b4; + out2[i*4 + 3] = b5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + a0 = in[i*4]; + a1 = in[i*4 + 1]; + a2 = in[i*4 + 2]; + a3 = in[i*4 + 3]; + + b0 = a0 * 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 * 5; + + b4 = a2 + 4; + b5 = a3 + 3; + + if (out[i*4] != b0 + || out[i*4 + 1] != b1 + || out[i*4 + 2] != b2 + || out[i*4 + 3] != b3) + abort (); + + if (out2[i*4] != b0 + || out2[i*4 + 1] != b1 + || out2[i*4 + 2] != b4 + || out2[i*4 + 3] != b5) + abort (); + } + + /* Different operations in the first case - vectorization with interleaving. */ + for (i = 0; i < N; i++) + { + a0 = in[i*4]; + a1 = in[i*4 + 1]; + a2 = in[i*4 + 2]; + a3 = in[i*4 + 3]; + + b0 = a0 + 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 * 5; + + b4 = a2 + 4; + b5 = a3 + 3; + + out[i*4] = b0; + out[i*4 + 1] = b1; + out[i*4 + 2] = b2; + out[i*4 + 3] = b3; + + out2[i*4] = b0; + out2[i*4 + 1] = b1; + out2[i*4 + 2] = b4; + out2[i*4 + 3] = b5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + a0 = in[i*4]; + a1 = in[i*4 + 1]; + a2 = in[i*4 + 2]; + a3 = in[i*4 + 3]; + + b0 = a0 + 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 * 5; + + b4 = a2 + 4; + b5 = a3 + 3; + + if (out[i*4] != b0 + || out[i*4 + 1] != b1 + || out[i*4 + 2] != b2 + || out[i*4 + 3] != b3) + abort (); + + if (out2[i*4] != b0 + || out2[i*4 + 1] != b1 + || out2[i*4 + 2] != b4 + || out2[i*4 + 3] != b5) + abort (); + } + + + /* Different operations in the second case - vectorization with interleaving. */ + for (i = 0; i < N; i++) + { + a0 = in[i*4]; + a1 = in[i*4 + 1]; + a2 = in[i*4 + 2]; + a3 = in[i*4 + 3]; + + b0 = a0 + 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 + 5; + + b4 = a2 * 4; + b5 = a3 + 3; + + out[i*4] = b0; + out[i*4 + 1] = b1; + out[i*4 + 2] = b2; + out[i*4 + 3] = b3; + + out2[i*4] = b0; + out2[i*4 + 1] = b1; + out2[i*4 + 2] = b4; + out2[i*4 + 3] = b5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + a0 = in[i*4]; + a1 = in[i*4 + 1]; + a2 = in[i*4 + 2]; + a3 = in[i*4 + 3]; + + b0 = a0 + 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 + 5; + + b4 = a2 * 4; + b5 = a3 + 3; + + if (out[i*4] != b0 + || out[i*4 + 1] != b1 + || out[i*4 + 2] != b2 + || out[i*4 + 3] != b3) + abort (); + + if (out2[i*4] != b0 + || out2[i*4 + 1] != b1 + || out2[i*4 + 2] != b4 + || out2[i*4 + 3] != b5) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target { vect_strided4 || vect_extract_even_odd } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! { vect_strided4 || vect_extract_even_odd } } } } } */ +/* Some targets can vectorize the second of the three main loops using + hybrid SLP. For 128-bit vectors, the required 4->3 permutations are: + + { 0, 1, 2, 4, 5, 6, 8, 9 } + { 2, 4, 5, 6, 8, 9, 10, 12 } + { 5, 6, 8, 9, 10, 12, 13, 14 } + + Not all vect_perm targets support that, and it's a bit too specific to have + its own effective-target selector, so we just test targets directly. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { powerpc64*-*-* s390*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_strided4 && { ! { powerpc64*-*-* s390*-*-* } } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! { vect_strided4 } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-22.c b/SingleSource/Regression/C/gcc-dg/vect/slp-22.c new file mode 100644 index 0000000000..2c083dc4ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-22.c @@ -0,0 +1,135 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int +main1 (unsigned short a0, unsigned short a1, unsigned short a2, + unsigned short a3, unsigned short a4, unsigned short a5, + unsigned short a6, unsigned short a7, unsigned short a8) +{ + int i; + unsigned short out[N*8], out2[N*8], out3[N*8], b0, b1, b2, b3, b4, b5, b6, b7, b8; + + for (i = 0; i < N; i++) + { + b0 = a0 + 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 + 5; + b4 = a4 + 4; + b5 = a5 + 3; + + out[i*4] = b0; + out[i*4 + 1] = b1; + out[i*4 + 2] = b2; + out[i*4 + 3] = b3; + + out2[i*4] = b0; + out2[i*4 + 1] = b1; + out2[i*4 + 2] = b4; + out2[i*4 + 3] = b5; + + out3[i*4] = b2; + out3[i*4 + 1] = b1; + out3[i*4 + 2] = b4; + out3[i*4 + 3] = b5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != b0 + || out[i*4 + 1] != b1 + || out[i*4 + 2] != b2 + || out[i*4 + 3] != b3) + abort (); + + + if (out2[i*4] != b0 + || out2[i*4 + 1] != b1 + || out2[i*4 + 2] != b4 + || out2[i*4 + 3] != b5) + abort (); + + if (out3[i*4] != b2 + || out3[i*4 + 1] != b1 + || out3[i*4 + 2] != b4 + || out3[i*4 + 3] != b5) + abort (); + } + + for (i = 0; i < N; i++) + { + b0 = a0 + 8; + b1 = a1 + 7; + b2 = a2 + 6; + b3 = a3 + 5; + b4 = a4 + 4; + b5 = a5 + 3; + b6 = a6 + 2; + b7 = a7 + 1; + b8 = a8 + 9; + + out[i*4] = b0; + out[i*4 + 1] = b1; + out[i*4 + 2] = b2; + out[i*4 + 3] = b3; + + out2[i*8] = b0; + out2[i*8 + 1] = b1; + out2[i*8 + 2] = b4; + out2[i*8 + 3] = b5; + out2[i*8 + 4] = b6; + out2[i*8 + 5] = b2; + out2[i*8 + 6] = b7; + out2[i*8 + 7] = b8; + + out3[2*i + 1] = a0; + out3[2*i] = b8; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != b0 + || out[i*4 + 1] != b1 + || out[i*4 + 2] != b2 + || out[i*4 + 3] != b3) + abort (); + + if (out2[i*8] != b0 + || out2[i*8 + 1] != b1 + || out2[i*8 + 2] != b4 + || out2[i*8 + 3] != b5 + || out2[i*8 + 4] != b6 + || out2[i*8 + 5] != b2 + || out2[i*8 + 6] != b7 + || out2[i*8 + 7] != b8) + abort (); + + if (out3[2*i] != b8 + || out3[2*i+1] != a0) + abort(); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (8,7,6,5,4,3,2,1,0); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 6 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-23.c b/SingleSource/Regression/C/gcc-dg/vect/slp-23.c new file mode 100644 index 0000000000..8836acf033 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-23.c @@ -0,0 +1,118 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + int a; + int b; + int c; + int d; + int e; + int f; + int g; + int h; +} s; + +int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + + for (i = 0; i < N; i++) + { + res[i].c = ptr->c + ptr->c; + res[i].a = ptr->a + ptr->a; + res[i].d = ptr->d + ptr->d; + res[i].b = ptr->b + ptr->b; + res[i].f = ptr->f + ptr->f; + res[i].e = ptr->e + ptr->e; + res[i].h = ptr->h + ptr->h; + res[i].g = ptr->g + ptr->g; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].c + arr[i].c + || res[i].a != arr[i].a + arr[i].a + || res[i].d != arr[i].d + arr[i].d + || res[i].b != arr[i].b + arr[i].b + || res[i].f != arr[i].f + arr[i].f + || res[i].e != arr[i].e + arr[i].e + || res[i].h != arr[i].h + arr[i].h + || res[i].g != arr[i].g + arr[i].g) + abort(); + } + + ptr = arr; + for (i = 0; i < N; i++) + { + res[i].c = ptr->c + ptr->c; + res[i].a = ptr->a + ptr->a; + res[i].d = ptr->d + ptr->d; + res[i].b = ptr->b + ptr->b; + res[i].f = ptr->f + ptr->f; + res[i].e = ptr->e + ptr->e; + res[i].h = ptr->e + ptr->e; + res[i].g = ptr->g + ptr->g; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].c + arr[i].c + || res[i].a != arr[i].a + arr[i].a + || res[i].d != arr[i].d + arr[i].d + || res[i].b != arr[i].b + arr[i].b + || res[i].f != arr[i].f + arr[i].f + || res[i].e != arr[i].e + arr[i].e + || res[i].h != arr[i].e + arr[i].e + || res[i].g != arr[i].g + arr[i].g) + abort(); + } + +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + arr[i].f = i * 5; + arr[i].g = i - 3; + arr[i].h = 56; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { vect_strided8 && { ! { vect_no_align} } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! { vect_strided8 || vect_no_align } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! vect_perm } } } } */ +/* SLP fails for the second loop with variable-length SVE because + the load size is greater than the minimum vector size. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_perm xfail { { aarch64_sve || riscv_v } && vect_variable_length } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-24-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/slp-24-big-array.c new file mode 100644 index 0000000000..5eaea9600a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-24-big-array.c @@ -0,0 +1,95 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; +} s; + +unsigned char ub[N*2]; +unsigned char uc[N]; + +unsigned char check_diff = 2; + +void +main1 (unsigned char x, unsigned char max_result, unsigned char min_result, s *arr) +{ + int i; + unsigned char udiff = 2; + unsigned char umax = x; + unsigned char umin = x; + unsigned char ua1[N*2]; + s *pIn = arr; + s out[N]; + + for (i = 0; i < N; i++) { + udiff += (unsigned char) (ub[i] - uc[i]); + + ua1[2*i+1] = ub[2*i+1]; + ua1[2*i] = ub[2*i]; + + out[i].d = pIn->d - 1; + out[i].b = pIn->b - 4; + out[i].c = pIn->c - 8; + out[i].a = pIn->a - 3; + + pIn++; + } + +#pragma GCC novector + for (i = 0; i < N; i++) { + if (ua1[2*i] != ub[2*i] + || ua1[2*i+1] != ub[2*i+1] + || out[i].a != arr[i].a - 3 + || out[i].b != arr[i].b - 4 + || out[i].c != arr[i].c - 8 + || out[i].d != arr[i].d - 1) + abort (); + } + + /* check results: */ + if (udiff != check_diff) + abort (); +} + +int main (void) +{ + int i; + s arr[N]; + + check_diff = 2; + ub[0] = uc[0] = 1; + for (i = 1; i < N; i++) { + ub[i] = (i%5 == 0)?i*3:i; + uc[i] = i; + check_diff += (unsigned char) (ub[i] - uc[i]); + asm volatile ("" ::: "memory"); + } + for (; i < 2*N; i++) { + ub[i] = 0; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + arr[i].a = i + 9; + arr[i].b = i * 2 + 10; + arr[i].c = 17; + arr[i].d = i+34; + asm volatile ("" ::: "memory"); + } + check_vect (); + + main1 (100, 100, 1, arr); + main1 (0, 15, 0, arr); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && ilp32 } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { xfail { vect_no_align && ilp32 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-24.c b/SingleSource/Regression/C/gcc-dg/vect/slp-24.c new file mode 100644 index 0000000000..59178f2c0f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-24.c @@ -0,0 +1,81 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; +} s; + +unsigned char ub[N*2] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +void +main1 (unsigned char x, unsigned char max_result, unsigned char min_result, s *arr) +{ + int i; + unsigned char udiff = 2; + unsigned char umax = x; + unsigned char umin = x; + unsigned char ua1[N*2]; + s *pIn = arr; + s out[N]; + + for (i = 0; i < N; i++) { + udiff += (unsigned char)(ub[i] - uc[i]); + + ua1[2*i+1] = ub[2*i+1]; + ua1[2*i] = ub[2*i]; + + out[i].d = pIn->d - 1; + out[i].b = pIn->b - 4; + out[i].c = pIn->c - 8; + out[i].a = pIn->a - 3; + + pIn++; + } + +#pragma GCC novector + for (i = 0; i < N; i++) { + if (ua1[2*i] != ub[2*i] + || ua1[2*i+1] != ub[2*i+1] + || out[i].a != arr[i].a - 3 + || out[i].b != arr[i].b - 4 + || out[i].c != arr[i].c - 8 + || out[i].d != arr[i].d - 1) + abort(); + } + + /* check results: */ + if (udiff != DIFF) + abort (); +} + +int main (void) +{ + int i; + s arr[N]; + + for (i = 0; i < N; i++) + { + arr[i].a = i + 9; + arr[i].b = i * 2 + 10; + arr[i].c = 17; + arr[i].d = i+34; + asm volatile ("" ::: "memory"); + } + check_vect (); + + main1 (100, 100, 1, arr); + main1 (0, 15, 0, arr); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && ilp32 } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { xfail { vect_no_align && ilp32 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-25.c b/SingleSource/Regression/C/gcc-dg/vect/slp-25.c new file mode 100644 index 0000000000..9e3b5bbc94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-25.c @@ -0,0 +1,64 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 128 + +/* Unaligned stores. */ + +int ia[N+2]; +short sa[N+2]; + +int main1 (int n) +{ + int i; + + for (i = 1; i <= N/2; i++) + { + ia[2*i] = 25; + ia[2*i + 1] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= N/2; i++) + { + if (ia[2*i] != 25 + || ia[2*i + 1] != 5) + abort (); + } + + for (i = 1; i <= n/2; i++) + { + sa[2*i] = 25; + sa[2*i + 1] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= n/2; i++) + { + if (sa[2*i] != 25 + || sa[2*i + 1] != 5) + abort (); + } + + + return 0; +} + +int main (void) +{ + + check_vect (); + + return main1 (N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail { { ! vect_unaligned_possible } || { ! vect_natural_alignment } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-26.c b/SingleSource/Regression/C/gcc-dg/vect/slp-26.c new file mode 100644 index 0000000000..cfb763bf51 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-26.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned short out[N*8], a[N], b[N] = {3,0x8031,0x7fff,0x8032,0xffff,0,0x8030,0x8000}; + + /* Partial SLP is not supported. */ + for (i = 0; i < N; i++) + { + out[i*4] = in[i*4]; + out[i*4 + 1] = in[i*4 + 1]; + out[i*4 + 2] = in[i*4 + 2]; + out[i*4 + 3] = in[i*4 + 3]; + + a[i] = b[i] / 0x8031; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*4] != in[i*4] + || out[i*4 + 1] != in[i*4 + 1] + || out[i*4 + 2] != in[i*4 + 2] + || out[i*4 + 3] != in[i*4 + 3] + || a[i] != b[i] / 0x8031) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { mips_msa || { amdgcn-*-* || { riscv_v || loongarch_sx } } } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { mips_msa || { amdgcn-*-* || { riscv_v || loongarch_sx } } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! { mips_msa || { amdgcn-*-* || { riscv_v || loongarch_sx } } } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { mips_msa || { amdgcn-*-* || { riscv_v || loongarch_sx } } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-28.c b/SingleSource/Regression/C/gcc-dg/vect/slp-28.c new file mode 100644 index 0000000000..67b7be29b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-28.c @@ -0,0 +1,97 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 4 / 16) +#else +#define N 32 +#endif + +unsigned short in[N] = {}; +unsigned short in2[N] = {}; +unsigned short in3[N] = {}; + +int +main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + in[i] = in2[i] = in3[i] = i; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N/4; i++) + { + in[i*4] = in[i*4] + 5; + in[i*4 + 1] = in[i*4 + 1] + 5; + in[i*4 + 2] = in[i*4 + 2] + 5; + in[i*4 + 3] = in[i*4 + 3] + 5; + + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (in[i] != i+5) + abort (); + } + + /* Not vectorizable because of data dependencies. */ + for (i = 1; i < N/4; i++) + { + in2[i*4] = in2[(i-1)*4] + 5; + in2[i*4 + 1] = in2[(i-1)*4 + 1] + 5; + in2[i*4 + 2] = in2[(i-1)*4 + 2] + 5; + in2[i*4 + 3] = in2[(i-1)*4 + 3] + 5; + + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (in2[i] != (i % 4) + (i / 4) * 5) + abort (); + } + + /* Not vectorizable because of data dependencies: distance 3 is greater than + the actual VF with SLP (2), but the analysis fail to detect that for now. */ + for (i = 3; i < N/4; i++) + { + in3[i*4] = in3[(i-3)*4] + 5; + in3[i*4 + 1] = in3[(i-3)*4 + 1] + 5; + in3[i*4 + 2] = in3[(i-3)*4 + 2] + 5; + in3[i*4 + 3] = in3[(i-3)*4 + 3] + 5; + + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (in3[i] != (i % 12) + (i / 12) * 5) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! vect32 } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect32 } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! vect32 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-3-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/slp-3-big-array.c new file mode 100644 index 0000000000..615a79f4a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-3-big-array.c @@ -0,0 +1,156 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 96 + +unsigned short in[N*8]; + +int +main1 () +{ + int i; + unsigned short out[N*8]; + + for (i = 0; i < N*8; i++) + { + in[i] = i&63; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8]; + out[i*8 + 1] = in[i*8 + 1]; + out[i*8 + 2] = in[i*8 + 2]; + out[i*8 + 3] = in[i*8 + 3]; + out[i*8 + 4] = in[i*8 + 4]; + out[i*8 + 5] = in[i*8 + 5]; + out[i*8 + 6] = in[i*8 + 6]; + out[i*8 + 7] = in[i*8 + 7]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + || out[i*8 + 1] != in[i*8 + 1] + || out[i*8 + 2] != in[i*8 + 2] + || out[i*8 + 3] != in[i*8 + 3] + || out[i*8 + 4] != in[i*8 + 4] + || out[i*8 + 5] != in[i*8 + 5] + || out[i*8 + 6] != in[i*8 + 6] + || out[i*8 + 7] != in[i*8 + 7]) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = in[i*4]; + out[i*4 + 1] = in[i*4 + 1]; + out[i*4 + 2] = in[i*4 + 2]; + out[i*4 + 3] = in[i*4 + 3]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != in[i*4] + || out[i*4 + 1] != in[i*4 + 1] + || out[i*4 + 2] != in[i*4 + 2] + || out[i*4 + 3] != in[i*4 + 3]) + abort (); + } + + for (i = 0; i < N/2; i++) + { + out[i*16] = in[i*16]; + out[i*16 + 1] = in[i*16 + 1]; + out[i*16 + 2] = in[i*16 + 2]; + out[i*16 + 3] = in[i*16 + 3]; + out[i*16 + 4] = in[i*16 + 4]; + out[i*16 + 5] = in[i*16 + 5]; + out[i*16 + 6] = in[i*16 + 6]; + out[i*16 + 7] = in[i*16 + 7]; + out[i*16 + 8] = in[i*16 + 8]; + out[i*16 + 9] = in[i*16 + 9]; + out[i*16 + 10] = in[i*16 + 10]; + out[i*16 + 11] = in[i*16 + 11]; + out[i*16 + 12] = in[i*16 + 12]; + out[i*16 + 13] = in[i*16 + 13]; + out[i*16 + 14] = in[i*16 + 14]; + out[i*16 + 15] = in[i*16 + 15]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*16] != in[i*16] + || out[i*16 + 1] != in[i*16 + 1] + || out[i*16 + 2] != in[i*16 + 2] + || out[i*16 + 3] != in[i*16 + 3] + || out[i*16 + 4] != in[i*16 + 4] + || out[i*16 + 5] != in[i*16 + 5] + || out[i*16 + 6] != in[i*16 + 6] + || out[i*16 + 7] != in[i*16 + 7] + || out[i*16 + 8] != in[i*16 + 8] + || out[i*16 + 9] != in[i*16 + 9] + || out[i*16 + 10] != in[i*16 + 10] + || out[i*16 + 11] != in[i*16 + 11] + || out[i*16 + 12] != in[i*16 + 12] + || out[i*16 + 13] != in[i*16 + 13] + || out[i*16 + 14] != in[i*16 + 14] + || out[i*16 + 15] != in[i*16 + 15]) + abort (); + } + + /* SLP with unrolling by 8. */ + for (i = 0; i < N/4; i++) + { + out[i*9] = in[i*9]; + out[i*9 + 1] = in[i*9 + 1]; + out[i*9 + 2] = in[i*9 + 2]; + out[i*9 + 3] = in[i*9 + 3]; + out[i*9 + 4] = in[i*9 + 4]; + out[i*9 + 5] = in[i*9 + 5]; + out[i*9 + 6] = in[i*9 + 6]; + out[i*9 + 7] = in[i*9 + 7]; + out[i*9 + 8] = in[i*9 + 8]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + if (out[i*9] != in[i*9] + || out[i*9 + 1] != in[i*9 + 1] + || out[i*9 + 2] != in[i*9 + 2] + || out[i*9 + 3] != in[i*9 + 3] + || out[i*9 + 4] != in[i*9 + 4] + || out[i*9 + 5] != in[i*9 + 5] + || out[i*9 + 6] != in[i*9 + 6] + || out[i*9 + 7] != in[i*9 + 7] + || out[i*9 + 8] != in[i*9 + 8]) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-3.c b/SingleSource/Regression/C/gcc-dg/vect/slp-3.c new file mode 100644 index 0000000000..183c7e65c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-3.c @@ -0,0 +1,151 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 12 + +unsigned short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; + +int +main1 () +{ + int i; + unsigned short out[N*8]; + + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8]; + out[i*8 + 1] = in[i*8 + 1]; + out[i*8 + 2] = in[i*8 + 2]; + out[i*8 + 3] = in[i*8 + 3]; + out[i*8 + 4] = in[i*8 + 4]; + out[i*8 + 5] = in[i*8 + 5]; + out[i*8 + 6] = in[i*8 + 6]; + out[i*8 + 7] = in[i*8 + 7]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + || out[i*8 + 1] != in[i*8 + 1] + || out[i*8 + 2] != in[i*8 + 2] + || out[i*8 + 3] != in[i*8 + 3] + || out[i*8 + 4] != in[i*8 + 4] + || out[i*8 + 5] != in[i*8 + 5] + || out[i*8 + 6] != in[i*8 + 6] + || out[i*8 + 7] != in[i*8 + 7]) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = in[i*4]; + out[i*4 + 1] = in[i*4 + 1]; + out[i*4 + 2] = in[i*4 + 2]; + out[i*4 + 3] = in[i*4 + 3]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != in[i*4] + || out[i*4 + 1] != in[i*4 + 1] + || out[i*4 + 2] != in[i*4 + 2] + || out[i*4 + 3] != in[i*4 + 3]) + abort (); + } + + for (i = 0; i < N/2; i++) + { + out[i*16] = in[i*16]; + out[i*16 + 1] = in[i*16 + 1]; + out[i*16 + 2] = in[i*16 + 2]; + out[i*16 + 3] = in[i*16 + 3]; + out[i*16 + 4] = in[i*16 + 4]; + out[i*16 + 5] = in[i*16 + 5]; + out[i*16 + 6] = in[i*16 + 6]; + out[i*16 + 7] = in[i*16 + 7]; + out[i*16 + 8] = in[i*16 + 8]; + out[i*16 + 9] = in[i*16 + 9]; + out[i*16 + 10] = in[i*16 + 10]; + out[i*16 + 11] = in[i*16 + 11]; + out[i*16 + 12] = in[i*16 + 12]; + out[i*16 + 13] = in[i*16 + 13]; + out[i*16 + 14] = in[i*16 + 14]; + out[i*16 + 15] = in[i*16 + 15]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*16] != in[i*16] + || out[i*16 + 1] != in[i*16 + 1] + || out[i*16 + 2] != in[i*16 + 2] + || out[i*16 + 3] != in[i*16 + 3] + || out[i*16 + 4] != in[i*16 + 4] + || out[i*16 + 5] != in[i*16 + 5] + || out[i*16 + 6] != in[i*16 + 6] + || out[i*16 + 7] != in[i*16 + 7] + || out[i*16 + 8] != in[i*16 + 8] + || out[i*16 + 9] != in[i*16 + 9] + || out[i*16 + 10] != in[i*16 + 10] + || out[i*16 + 11] != in[i*16 + 11] + || out[i*16 + 12] != in[i*16 + 12] + || out[i*16 + 13] != in[i*16 + 13] + || out[i*16 + 14] != in[i*16 + 14] + || out[i*16 + 15] != in[i*16 + 15]) + abort (); + } + + /* SLP with unrolling by 8. */ + for (i = 0; i < N/4; i++) + { + out[i*9] = in[i*9]; + out[i*9 + 1] = in[i*9 + 1]; + out[i*9 + 2] = in[i*9 + 2]; + out[i*9 + 3] = in[i*9 + 3]; + out[i*9 + 4] = in[i*9 + 4]; + out[i*9 + 5] = in[i*9 + 5]; + out[i*9 + 6] = in[i*9 + 6]; + out[i*9 + 7] = in[i*9 + 7]; + out[i*9 + 8] = in[i*9 + 8]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + if (out[i*9] != in[i*9] + || out[i*9 + 1] != in[i*9 + 1] + || out[i*9 + 2] != in[i*9 + 2] + || out[i*9 + 3] != in[i*9 + 3] + || out[i*9 + 4] != in[i*9 + 4] + || out[i*9 + 5] != in[i*9 + 5] + || out[i*9 + 6] != in[i*9 + 6] + || out[i*9 + 7] != in[i*9 + 7] + || out[i*9 + 8] != in[i*9 + 8]) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { { ! { vect_partial_vectors || vect32 } } || s390_vx } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target { { vect_partial_vectors || vect32 } && { ! s390_vx } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target { { ! { vect_partial_vectors || vect32 } } || s390_vx } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target { { vect_partial_vectors || vect32 } && { ! s390_vx } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-33.c b/SingleSource/Regression/C/gcc-dg/vect/slp-33.c new file mode 100644 index 0000000000..c382093c23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-33.c @@ -0,0 +1,114 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 8 + +int +main1 () +{ + int i; + unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + float out2[N*8]; + + /* SLP with unrolling by 4. */ + for (i = 0; i < N; i++) + { + a0 = in[i*7] + 5; + a1 = in[i*7 + 1] + 6; + a2 = in[i*7 + 2] + 7; + a3 = in[i*7 + 3] + 8; + a4 = in[i*7 + 4] + 9; + a5 = in[i*7 + 5] + 10; + a6 = in[i*7 + 6] + 11; + + b0 = a0 * 3; + b1 = a1 * 2; + b2 = a2 * 12; + b3 = a3 * 5; + b4 = a4 * 8; + b5 = a5 * 4; + b6 = a6 * 3; + + out[i*7] = b0 - 2; + out[i*7 + 1] = b1 - 3; + out[i*7 + 2] = b2 - 2; + out[i*7 + 3] = b3 - 1; + out[i*7 + 4] = b4 - 8; + out[i*7 + 5] = b5 - 7; + out[i*7 + 6] = b6 - 3; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*7] != (in[i*7] + 5) * 3 - 2 + || out[i*7 + 1] != (in[i*7 + 1] + 6) * 2 - 3 + || out[i*7 + 2] != (in[i*7 + 2] + 7) * 12 - 2 + || out[i*7 + 3] != (in[i*7 + 3] + 8) * 5 - 1 + || out[i*7 + 4] != (in[i*7 + 4] + 9) * 8 - 8 + || out[i*7 + 5] != (in[i*7 + 5] + 10) * 4 - 7 + || out[i*7 + 6] != (in[i*7 + 6] + 11) * 3 - 3) + abort (); + } + + /* SLP with unrolling by 4. */ + for (i = 0; i < N*2; i++) + { + out[i*3] = (in[i*3] + 2) * 3; + out[i*3 + 1] = (in[i*3 + 1] + 2) * 7; + out[i*3 + 2] = (in[i*3 + 2] + 7) * 3; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*3] != (in[i*3] + 2) * 3 + || out[i*3 + 1] != (in[i*3 + 1] + 2) * 7 + || out[i*3 + 2] != (in[i*3 + 2] + 7) * 3) + abort (); + } + + /* SLP with unrolling by 4. */ + for (i = 0; i < N*2; i++) + { + out2[i*3] = (float) (in[i*3] * 2 + 5) ; + out2[i*3 + 1] = (float) (in[i*3 + 1] * 3 + 7); + out2[i*3 + 2] = (float) (in[i*3 + 2] * 5 + 4); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out2[i*3] != (float) (in[i*3] * 2 + 5) + || out2[i*3 + 1] != (float) (in[i*3 + 1] * 3 + 7) + || out2[i*3 + 2] != (float) (in[i*3 + 2] * 5 + 4)) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" {target {vect_uintfloat_cvt && vect_int_mult} } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" {target {{! { vect_uintfloat_cvt}} && vect_int_mult} } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" {target {{! { vect_uintfloat_cvt}} && {! {vect_int_mult}}} } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" {target {vect_uintfloat_cvt && vect_int_mult} xfail { vect_variable_length && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" {target {{! { vect_uintfloat_cvt}} && vect_int_mult} } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" {target {{! { vect_uintfloat_cvt}} && {! {vect_int_mult}}} } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-34-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/slp-34-big-array.c new file mode 100644 index 0000000000..db0e440639 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-34-big-array.c @@ -0,0 +1,67 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +unsigned short in[N*8]; +unsigned short in2[N*8]; + +int +main1 () +{ + int i; + unsigned short out[N*8]; + unsigned short out2[N*8]; + + for (i = 0; i < N*8; i++) + { + in[i] = in2[i] = i; + asm volatile ("" ::: "memory"); + } + + /* SLP with unrolling by 8. */ + for (i = 0; i < N; i++) + { + out[i*3] = in[i*3] + 5; + out[i*3 + 1] = in[i*3 + 1] + 6; + out[i*3 + 2] = in[i*3 + 2] + 16; + + out2[i*5] = in2[i*5] + 2; + out2[i*5 + 1] = in2[i*5 + 1] + 2; + out2[i*5 + 2] = in2[i*5 + 2] + 1; + out2[i*5 + 3] = in2[i*5 + 3] + 3; + out2[i*5 + 4] = in2[i*5 + 4] + 13; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*3] != in[i*3] + 5 + || out[i*3 + 1] != in[i*3 + 1] + 6 + || out[i*3 + 2] != in[i*3 + 2] + 16 + || out2[i*5] != in2[i*5] + 2 + || out2[i*5 + 1] != in2[i*5 + 1] + 2 + || out2[i*5 + 2] != in2[i*5 + 2] + 1 + || out2[i*5 + 3] != in2[i*5 + 3] + 3 + || out2[i*5 + 4] != in2[i*5 + 4] + 13) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target {! vect_strided5 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-34.c b/SingleSource/Regression/C/gcc-dg/vect/slp-34.c new file mode 100644 index 0000000000..53b8284d08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-34.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned short in2[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +int +main1 () +{ + int i; + unsigned short out[N*8]; + unsigned short out2[N*8]; + + /* SLP with unrolling by 8. */ + for (i = 0; i < N; i++) + { + out[i*3] = in[i*3] + 5; + out[i*3 + 1] = in[i*3 + 1] + 6; + out[i*3 + 2] = in[i*3 + 2] + 16; + + out2[i*5] = in2[i*5] + 2; + out2[i*5 + 1] = in2[i*5 + 1] + 2; + out2[i*5 + 2] = in2[i*5 + 2] + 1; + out2[i*5 + 3] = in2[i*5 + 3] + 3; + out2[i*5 + 4] = in2[i*5 + 4] + 13; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*3] != in[i*3] + 5 + || out[i*3 + 1] != in[i*3 + 1] + 6 + || out[i*3 + 2] != in[i*3 + 2] + 16 + || out2[i*5] != in2[i*5] + 2 + || out2[i*5 + 1] != in2[i*5 + 1] + 2 + || out2[i*5 + 2] != in2[i*5 + 2] + 1 + || out2[i*5 + 3] != in2[i*5 + 3] + 3 + || out2[i*5 + 4] != in2[i*5 + 4] + 13) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target {! vect_strided5 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-35.c b/SingleSource/Regression/C/gcc-dg/vect/slp-35.c new file mode 100644 index 0000000000..2c9d168e09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-35.c @@ -0,0 +1,72 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + int a; + int b; + int c; + int d; + int e; +} s; + +int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + + /* SLP with unrolling by 4. */ + for (i = 0; i < N; i++) + { + res[i].c = ptr->c + ptr->c; + res[i].a = ptr->a + ptr->a; + res[i].d = ptr->d + ptr->d; + res[i].b = ptr->b + ptr->b; + res[i].e = ptr->e + ptr->e; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].c + arr[i].c + || res[i].a != arr[i].a + arr[i].a + || res[i].d != arr[i].d + arr[i].d + || res[i].b != arr[i].b + arr[i].b + || res[i].e != arr[i].e + arr[i].e) + abort(); + } + +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target {! vect_strided5 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-36.c b/SingleSource/Regression/C/gcc-dg/vect/slp-36.c new file mode 100644 index 0000000000..98458ac32c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-36.c @@ -0,0 +1,75 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#define N 32 + +/* All the loops are vectorizable on platforms with vector shift argument. */ + +void +test_1 (void) +{ + static unsigned int bm[N]; + static unsigned int cm[N]; + int j; + + /* Vectorizable on platforms with scalar shift argument. */ + for (j = 0; j < N/2; j++) + { + bm[2*j] <<= 8; + bm[2*j+1] <<= 8; + } + + /* Not vectorizable on platforms with scalar shift argument. */ + for (j = 0; j < N/2; j++) + { + cm[2*j] <<= 8; + cm[2*j+1] <<= 7; + } +} + +void +test_2 (int a, int b) +{ + static unsigned int bm[N]; + static unsigned int cm[N]; + int j; + + /* Vectorizable on platforms with scalar shift argument. */ + for (j = 0; j < N/2; j++) + { + bm[2*j] <<= a; + bm[2*j+1] <<= a; + } + + /* Not vectorizable on platforms with scalar shift argument. */ + for (j = 0; j < N/2; j++) + { + cm[2*j] <<= a; + cm[2*j+1] <<= b; + } +} + +void +test_3 (void) +{ + static unsigned int bm[N]; + int am[N]; + int j; + + /* Not vectorizable on platforms with scalar shift argument. */ + for (j = 0; j < N/2; j++) + { + bm[2*j] <<= am[j]; + bm[2*j+1] <<= am[j]; + } + + /* Not vectorizable on platforms with scalar shift argument. */ + for (j = 0; j < N/2; j++) + { + bm[2*j] <<= am[2*j]; + bm[2*j+1] <<= am[2*j+1]; + } + +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-37.c b/SingleSource/Regression/C/gcc-dg/vect/slp-37.c new file mode 100644 index 0000000000..caee2bb508 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-37.c @@ -0,0 +1,63 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + int a; + int b; + void *c; +} s1; + +int +foo1 (s1 *arr) +{ + int i; + s1 *ptr = arr; + + /* Vectorized as a strided SLP pair of accesses to and a single + strided access to c. */ + for (i = 0; i < N; i++) + { + ptr->a = 6; + ptr->b = 7; + ptr->c = 0; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (arr[i].a != 6 + || arr[i].b != 7 + || arr[i].c != 0) + abort(); + } +} + +int main (void) +{ + int i; + s1 arr1[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr1[i].a = i; + arr1[i].b = i * 2; + arr1[i].c = (void *)arr1; + asm volatile ("" ::: "memory"); + } + + + foo1 (arr1); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_hw_misalign } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_hw_misalign } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-38.c b/SingleSource/Regression/C/gcc-dg/vect/slp-38.c new file mode 100644 index 0000000000..e6bd919135 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-38.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +typedef struct { + float l, h; +} tFPinterval; + +tFPinterval X[1024]; +tFPinterval Y[1024]; +tFPinterval Z[1024]; + +void Compute(void) +{ + int d; + for (d= 0; d < 1024; d++) + { + Y[d].l= X[d].l + X[d].h; + Y[d].h= Y[d].l; + Z[d].l= X[d].l; + Z[d].h= X[d].h; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target { vect_float && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-39.c b/SingleSource/Regression/C/gcc-dg/vect/slp-39.c new file mode 100644 index 0000000000..85d32eaf74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-39.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double x[1024], y[1024], z[1024]; +void foo (double w) +{ + int i; + for (i = 0; i < 1023; i+=2) + { + z[i] = x[i] + 1; + z[i+1] = x[i+1] + w; + } +} +void bar (double w) +{ + int i; + for (i = 0; i < 1023; i+=2) + { + z[i] = x[i] + w; + z[i+1] = x[i+1] + 1; + } +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-4-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/slp-4-big-array.c new file mode 100644 index 0000000000..fcda45ff36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-4-big-array.c @@ -0,0 +1,135 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int +main1 () +{ + int i; + unsigned short out[N*8]; + unsigned short in[N*8]; + unsigned int ia[N*2]; + + for (i = 0; i < N*8; i++) + { + in[i] = i; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8]; + out[i*8 + 1] = in[i*8 + 1]; + out[i*8 + 2] = in[i*8 + 2]; + out[i*8 + 3] = in[i*8 + 3]; + out[i*8 + 4] = in[i*8 + 4]; + out[i*8 + 5] = in[i*8 + 5]; + out[i*8 + 6] = in[i*8 + 6]; + out[i*8 + 7] = in[i*8 + 7]; + + ia[i] = 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + || out[i*8 + 1] != in[i*8 + 1] + || out[i*8 + 2] != in[i*8 + 2] + || out[i*8 + 3] != in[i*8 + 3] + || out[i*8 + 4] != in[i*8 + 4] + || out[i*8 + 5] != in[i*8 + 5] + || out[i*8 + 6] != in[i*8 + 6] + || out[i*8 + 7] != in[i*8 + 7] + || ia[i] != 7) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = in[i*4]; + out[i*4 + 1] = in[i*4 + 1]; + out[i*4 + 2] = in[i*4 + 2]; + out[i*4 + 3] = in[i*4 + 3]; + + ia[i] = 12; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != in[i*4] + || out[i*4 + 1] != in[i*4 + 1] + || out[i*4 + 2] != in[i*4 + 2] + || out[i*4 + 3] != in[i*4 + 3] + || ia[i] != 12) + abort (); + } + + for (i = 0; i < N/2; i++) + { + out[i*16] = in[i*16]; + out[i*16 + 1] = in[i*16 + 1]; + out[i*16 + 2] = in[i*16 + 2]; + out[i*16 + 3] = in[i*16 + 3]; + out[i*16 + 4] = in[i*16 + 4]; + out[i*16 + 5] = in[i*16 + 5]; + out[i*16 + 6] = in[i*16 + 6]; + out[i*16 + 7] = in[i*16 + 7]; + out[i*16 + 8] = in[i*16 + 8]; + out[i*16 + 9] = in[i*16 + 9]; + out[i*16 + 10] = in[i*16 + 10]; + out[i*16 + 11] = in[i*16 + 11]; + out[i*16 + 12] = in[i*16 + 12]; + out[i*16 + 13] = in[i*16 + 13]; + out[i*16 + 14] = in[i*16 + 14]; + out[i*16 + 15] = in[i*16 + 15]; + + ia[i] = 21; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*16] != in[i*16] + || out[i*16 + 1] != in[i*16 + 1] + || out[i*16 + 2] != in[i*16 + 2] + || out[i*16 + 3] != in[i*16 + 3] + || out[i*16 + 4] != in[i*16 + 4] + || out[i*16 + 5] != in[i*16 + 5] + || out[i*16 + 6] != in[i*16 + 6] + || out[i*16 + 7] != in[i*16 + 7] + || out[i*16 + 8] != in[i*16 + 8] + || out[i*16 + 9] != in[i*16 + 9] + || out[i*16 + 10] != in[i*16 + 10] + || out[i*16 + 11] != in[i*16 + 11] + || out[i*16 + 12] != in[i*16 + 12] + || out[i*16 + 13] != in[i*16 + 13] + || out[i*16 + 14] != in[i*16 + 14] + || out[i*16 + 15] != in[i*16 + 15] + || ia[i] != 21) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-4.c b/SingleSource/Regression/C/gcc-dg/vect/slp-4.c new file mode 100644 index 0000000000..29e741df02 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-4.c @@ -0,0 +1,129 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int +main1 () +{ + int i; + unsigned short out[N*8]; + unsigned short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned int ia[N*2]; + + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8]; + out[i*8 + 1] = in[i*8 + 1]; + out[i*8 + 2] = in[i*8 + 2]; + out[i*8 + 3] = in[i*8 + 3]; + out[i*8 + 4] = in[i*8 + 4]; + out[i*8 + 5] = in[i*8 + 5]; + out[i*8 + 6] = in[i*8 + 6]; + out[i*8 + 7] = in[i*8 + 7]; + + ia[i] = 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + || out[i*8 + 1] != in[i*8 + 1] + || out[i*8 + 2] != in[i*8 + 2] + || out[i*8 + 3] != in[i*8 + 3] + || out[i*8 + 4] != in[i*8 + 4] + || out[i*8 + 5] != in[i*8 + 5] + || out[i*8 + 6] != in[i*8 + 6] + || out[i*8 + 7] != in[i*8 + 7] + || ia[i] != 7) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = in[i*4]; + out[i*4 + 1] = in[i*4 + 1]; + out[i*4 + 2] = in[i*4 + 2]; + out[i*4 + 3] = in[i*4 + 3]; + + ia[i] = 12; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != in[i*4] + || out[i*4 + 1] != in[i*4 + 1] + || out[i*4 + 2] != in[i*4 + 2] + || out[i*4 + 3] != in[i*4 + 3] + || ia[i] != 12) + abort (); + } + + for (i = 0; i < N/2; i++) + { + out[i*16] = in[i*16]; + out[i*16 + 1] = in[i*16 + 1]; + out[i*16 + 2] = in[i*16 + 2]; + out[i*16 + 3] = in[i*16 + 3]; + out[i*16 + 4] = in[i*16 + 4]; + out[i*16 + 5] = in[i*16 + 5]; + out[i*16 + 6] = in[i*16 + 6]; + out[i*16 + 7] = in[i*16 + 7]; + out[i*16 + 8] = in[i*16 + 8]; + out[i*16 + 9] = in[i*16 + 9]; + out[i*16 + 10] = in[i*16 + 10]; + out[i*16 + 11] = in[i*16 + 11]; + out[i*16 + 12] = in[i*16 + 12]; + out[i*16 + 13] = in[i*16 + 13]; + out[i*16 + 14] = in[i*16 + 14]; + out[i*16 + 15] = in[i*16 + 15]; + + ia[i] = 21; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*16] != in[i*16] + || out[i*16 + 1] != in[i*16 + 1] + || out[i*16 + 2] != in[i*16 + 2] + || out[i*16 + 3] != in[i*16 + 3] + || out[i*16 + 4] != in[i*16 + 4] + || out[i*16 + 5] != in[i*16 + 5] + || out[i*16 + 6] != in[i*16 + 6] + || out[i*16 + 7] != in[i*16 + 7] + || out[i*16 + 8] != in[i*16 + 8] + || out[i*16 + 9] != in[i*16 + 9] + || out[i*16 + 10] != in[i*16 + 10] + || out[i*16 + 11] != in[i*16 + 11] + || out[i*16 + 12] != in[i*16 + 12] + || out[i*16 + 13] != in[i*16 + 13] + || out[i*16 + 14] != in[i*16 + 14] + || out[i*16 + 15] != in[i*16 + 15] + || ia[i] != 21) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-41.c b/SingleSource/Regression/C/gcc-dg/vect/slp-41.c new file mode 100644 index 0000000000..b96de4fbcb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-41.c @@ -0,0 +1,70 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ +/* { dg-require-effective-target vect_hw_misalign } */ + +#include "tree-vect.h" + +void __attribute__((noinline,noclone)) +testi (int *p, short *q, int stride, int n) +{ + int i; + for (i = 0; i < n; ++i) + { + q[i*4+0] = p[i*stride+0]; + q[i*4+1] = p[i*stride+1]; + q[i*4+2] = p[i*stride+2]; + q[i*4+3] = p[i*stride+3]; + } +} + +void __attribute__((noinline,noclone)) +testi2 (int *q, short *p, int stride, int n) +{ + int i; + for (i = 0; i < n; ++i) + { + q[i*4+0] = p[i*stride+0]; + q[i*4+1] = p[i*stride+1]; + q[i*4+2] = p[i*stride+2]; + q[i*4+3] = p[i*stride+3]; + } +} + +int ia[256]; +short sa[256]; + +extern void abort (void); + +int main() +{ + int i; + + check_vect (); + + for (i = 0; i < 256; ++i) + { + ia[i] = sa[i] = i; + __asm__ volatile (""); + } + testi (ia, sa, 8, 32); +#pragma GCC novector + for (i = 0; i < 128; ++i) + if (sa[i] != ia[(i / 4) * 8 + i % 4]) + abort (); + + for (i = 0; i < 256; ++i) + { + ia[i] = sa[i] = i; + __asm__ volatile (""); + } + testi2 (ia, sa, 8, 32); +#pragma GCC novector + for (i = 0; i < 128; ++i) + if (ia[i] != sa[(i / 4) * 8 + i % 4]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-42.c b/SingleSource/Regression/C/gcc-dg/vect/slp-42.c new file mode 100644 index 0000000000..6b78246c2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-42.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int p[4096], q[4096]; + +void foo (int n) +{ + int i; + for (i = 0; i < n; ++i) + { + p[i*4+0] = q[i*8+0] + q[i*8+4]; + p[i*4+1] = q[i*8+1] + q[i*8+5]; + p[i*4+2] = q[i*8+2] + q[i*8+6]; + p[i*4+3] = q[i*8+3] + q[i*8+7]; + } +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { xfail vect_variable_length } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-43.c b/SingleSource/Regression/C/gcc-dg/vect/slp-43.c new file mode 100644 index 0000000000..3d8ffb1132 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-43.c @@ -0,0 +1,85 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-O3 -fno-version-loops-for-strides" } */ + +#include +#include "tree-vect.h" + +/* AVX512BW has V64QImode, make char_1 vectorizable with that. */ +#define MAX_VEC_ELEMENTS 64 + +#define FOO(T,N) \ +void __attribute__((noinline,noclone)) \ +foo_ ## T ## _ ## N (T * __restrict__ in_, T * __restrict__ out_, int s) \ +{ \ + T *in = __builtin_assume_aligned (in_, __BIGGEST_ALIGNMENT__); \ + T *out = __builtin_assume_aligned (out_, __BIGGEST_ALIGNMENT__); \ + for (int i = 0; i < MAX_VEC_ELEMENTS; i++) \ + { \ + for (int j = 0; j < N; ++j) \ + out[j] = in[j]; \ + in += s*N; \ + out += N; \ + } \ +} + +#define TEST(T,N) \ + _Pragma("GCC novector") \ + do { \ + memset (out, 0, 4096); \ + foo_ ## T ## _ ## N ((T *)in, (T *)out, 1); \ + if (memcmp (in, out, sizeof (T) * MAX_VEC_ELEMENTS * N) != 0) \ + __builtin_abort (); \ + _Pragma("GCC novector") \ + for (int i = sizeof (T) * MAX_VEC_ELEMENTS * N; i < 4096; ++i) \ + if (out[i] != 0) \ + __builtin_abort (); \ + } while (0) + +FOO(char, 1) +FOO(char, 2) +FOO(char, 3) +FOO(char, 4) +FOO(char, 6) +FOO(char, 8) +FOO(int, 1) +FOO(int, 2) +FOO(int, 3) +FOO(int, 4) +FOO(int, 6) +FOO(int, 8) +FOO(int, 16) + +char in[4096] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +char out[4096] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); + +int main() +{ + check_vect (); + + for (int i = 0; i < 4096; ++i) + { + in[i] = i; + __asm__ volatile ("" : : : "memory"); + } + + TEST(char, 1); + TEST(char, 2); + TEST(char, 3); + TEST(char, 4); + TEST(char, 6); + TEST(char, 8); + TEST(int, 1); + TEST(int, 2); + TEST(int, 3); + TEST(int, 4); + TEST(int, 6); + TEST(int, 8); + TEST(int, 16); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 13 "vect" { target vect_hw_misalign } } } */ +/* For ! vect_hw_misalign it depends on vector size and actual alignment + requirements of the target which functions can be vectorized. Avoid + that bean-counting and per-target listing here. */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-44.c b/SingleSource/Regression/C/gcc-dg/vect/slp-44.c new file mode 100644 index 0000000000..445440bd45 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-44.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void IMB_double_fast_x (int * __restrict__ destf, + int * __restrict__ dest, int y, + int * __restrict__ p1f) +{ + int i; + for (i = y; i > 0; i--) + { + *dest++ = 0; + destf[0] = p1f[0]; + destf[1] = p1f[1]; + destf[2] = p1f[2]; + destf[3] = p1f[3]; + destf[4] = p1f[8]; + destf[5] = p1f[9]; + destf[6] = p1f[10]; + destf[7] = p1f[11]; + destf += 8; + p1f += 12; + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_hw_misalign && vect_perm } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-45.c b/SingleSource/Regression/C/gcc-dg/vect/slp-45.c new file mode 100644 index 0000000000..f340330045 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-45.c @@ -0,0 +1,82 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-O3 -fno-version-loops-for-strides" } */ + +#include +#include "tree-vect.h" + +/* AVX512BW has V64QImode, make char_1 vectorizable with that. */ +#define MAX_VEC_ELEMENTS 64 + +#define FOO(T,N) \ +void __attribute__((noinline,noclone)) \ +foo_ ## T ## _ ## N (T * __restrict__ in_, T * __restrict__ out_, int s) \ +{ \ + T *in = __builtin_assume_aligned (in_, __BIGGEST_ALIGNMENT__); \ + T *out = __builtin_assume_aligned (out_, __BIGGEST_ALIGNMENT__); \ + for (int i = 0; i < MAX_VEC_ELEMENTS; i++) \ + { \ + for (int j = 0; j < N; ++j) \ + out[j] = in[j]; \ + in += N; \ + out += s*N; \ + } \ +} + +#define TEST(T,N) \ + _Pragma("GCC novector") \ + do { \ + memset (out, 0, 4096); \ + foo_ ## T ## _ ## N ((T *)in, (T *)out, 1); \ + if (memcmp (in, out, sizeof (T) * MAX_VEC_ELEMENTS * N) != 0) \ + __builtin_abort (); \ + _Pragma("GCC novector") \ + for (int i = sizeof (T) * MAX_VEC_ELEMENTS * N; i < 4096; ++i) \ + if (out[i] != 0) \ + __builtin_abort (); \ + } while (0) + +FOO(char, 1) +FOO(char, 2) +FOO(char, 3) +FOO(char, 4) +FOO(char, 6) +FOO(char, 8) +FOO(int, 1) +FOO(int, 2) +FOO(int, 3) +FOO(int, 4) +FOO(int, 6) +FOO(int, 8) +FOO(int, 16) + +char in[4096] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +char out[4096] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); + +int main() +{ + check_vect (); + + for (int i = 0; i < 4096; ++i) + { + in[i] = i; + __asm__ volatile ("" : : : "memory"); + } + + TEST(char, 1); + TEST(char, 2); + TEST(char, 3); + TEST(char, 4); + TEST(char, 6); + TEST(char, 8); + TEST(int, 1); + TEST(int, 2); + TEST(int, 3); + TEST(int, 4); + TEST(int, 6); + TEST(int, 8); + TEST(int, 16); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 13 "vect" { target vect_hw_misalign } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-46.c b/SingleSource/Regression/C/gcc-dg/vect/slp-46.c new file mode 100644 index 0000000000..bf44547365 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-46.c @@ -0,0 +1,101 @@ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ + +#include "tree-vect.h" + +double x[1024], y[1024]; + +void __attribute__((noipa)) foo() +{ + for (int i = 0; i < 512; ++i) + { + x[2*i] = y[i]; + x[2*i+1] = y[i]; + } +} + +void __attribute__((noipa)) bar() +{ + for (int i = 0; i < 512; ++i) + { + x[2*i] = y[2*i]; + x[2*i+1] = y[2*i]; + } +} + +void __attribute__((noipa)) baz() +{ + for (int i = 0; i < 512; ++i) + { + x[2*i] = y[511-i]; + x[2*i+1] = y[511-i]; + } +} + +void __attribute__((noipa)) boo() +{ + for (int i = 0; i < 512; ++i) + { + x[2*i] = y[2*(511-i)]; + x[2*i+1] = y[2*(511-i)]; + } +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + y[i] = i; + __asm__ volatile (""); + } + + foo (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != y[i/2]) + abort (); + + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + __asm__ volatile (""); + } + + bar (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != y[2*(i/2)]) + abort (); + + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + __asm__ volatile (""); + } + + baz (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != y[511 - i/2]) + abort (); + + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + __asm__ volatile (""); + } + + boo (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != y[2*(511 - i/2)]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { xfail vect_load_lanes } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-47.c b/SingleSource/Regression/C/gcc-dg/vect/slp-47.c new file mode 100644 index 0000000000..7772bb71c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-47.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int x[1024], y[1024]; + +void __attribute__((noipa)) foo() +{ + for (int i = 0; i < 512; ++i) + { + x[2*i] = y[1023 - (2*i)]; + x[2*i+1] = y[1023 - (2*i+1)]; + } +} + +void __attribute__((noipa)) bar() +{ + for (int i = 0; i < 512; ++i) + { + x[2*i] = y[1023 - (2*i+1)]; + x[2*i+1] = y[1023 - (2*i)]; + } +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + y[i] = i; + __asm__ volatile (""); + } + + foo (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != y[1023 - i]) + abort (); + + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + __asm__ volatile (""); + } + + bar (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != y[1023 - i^1]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-48.c b/SingleSource/Regression/C/gcc-dg/vect/slp-48.c new file mode 100644 index 0000000000..38f533233d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-48.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int x[1024], y[1024]; + +void __attribute__((noipa)) foo() +{ + for (int i = 0; i < 512; ++i) + { + x[1023 - (2*i+1)] = y[2*i]; + x[1023 - (2*i)] = y[2*i+1]; + } +} + +void __attribute__((noipa)) bar() +{ + for (int i = 0; i < 512; ++i) + { + x[1023 - (2*i+1)] = y[2*i+1]; + x[1023 - (2*i)] = y[2*i]; + } +} + +int +main () +{ + check_vect (); + + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + y[i] = i; + __asm__ volatile (""); + } + + foo (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != y[1023 - i^1]) + abort (); + + for (int i = 0; i < 1024; ++i) + { + x[i] = 0; + __asm__ volatile (""); + } + + bar (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + if (x[i] != y[1023 - i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-49.c b/SingleSource/Regression/C/gcc-dg/vect/slp-49.c new file mode 100644 index 0000000000..b2433c9207 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-49.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int a[1024]; + +void __attribute__((noipa)) +foo(int k) +{ + int j = 5; + for (int i = 0; i < 512; ++i) + { + a[2*i] = j; + a[2*i+1] = k; + j++; + k+=3; + } +} + +int +main() +{ + check_vect (); + + foo (17); + +#pragma GCC novector + for (int i = 0; i < 512; ++i) + { + if (a[2*i] != 5 + i + || a[2*i+1] != 17 + 3 * i) + __builtin_abort (); + } + + return 0; +} + +/* We don't yet support SLP inductions for variable length vectors. */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { xfail vect_variable_length } } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-5.c b/SingleSource/Regression/C/gcc-dg/vect/slp-5.c new file mode 100644 index 0000000000..6d51f6a732 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-5.c @@ -0,0 +1,128 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int +main1 () +{ + int i; + unsigned int out[N*8]; + unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + unsigned short ia[N]; + unsigned int ib[N*2]; + + /* Multiple types with SLP of the smaller type. */ + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8]; + out[i*8 + 1] = in[i*8 + 1]; + out[i*8 + 2] = in[i*8 + 2]; + out[i*8 + 3] = in[i*8 + 3]; + out[i*8 + 4] = in[i*8 + 4]; + out[i*8 + 5] = in[i*8 + 5]; + out[i*8 + 6] = in[i*8 + 6]; + out[i*8 + 7] = in[i*8 + 7]; + + ia[i] = 7; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + || out[i*8 + 1] != in[i*8 + 1] + || out[i*8 + 2] != in[i*8 + 2] + || out[i*8 + 3] != in[i*8 + 3] + || out[i*8 + 4] != in[i*8 + 4] + || out[i*8 + 5] != in[i*8 + 5] + || out[i*8 + 6] != in[i*8 + 6] + || out[i*8 + 7] != in[i*8 + 7] + || ia[i] != 7) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = in[i*4]; + out[i*4 + 1] = in[i*4 + 1]; + out[i*4 + 2] = in[i*4 + 2]; + out[i*4 + 3] = in[i*4 + 3]; + + ib[i] = 12; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != in[i*4] + || out[i*4 + 1] != in[i*4 + 1] + || out[i*4 + 2] != in[i*4 + 2] + || out[i*4 + 3] != in[i*4 + 3] + || ib[i] != 12) + abort (); + } + + for (i = 0; i < N/2; i++) + { + out[i*16] = in[i*16]; + out[i*16 + 1] = in[i*16 + 1]; + out[i*16 + 2] = in[i*16 + 2]; + out[i*16 + 3] = in[i*16 + 3]; + out[i*16 + 4] = in[i*16 + 4]; + out[i*16 + 5] = in[i*16 + 5]; + out[i*16 + 6] = in[i*16 + 6]; + out[i*16 + 7] = in[i*16 + 7]; + out[i*16 + 8] = in[i*16 + 8]; + out[i*16 + 9] = in[i*16 + 9]; + out[i*16 + 10] = in[i*16 + 10]; + out[i*16 + 11] = in[i*16 + 11]; + out[i*16 + 12] = in[i*16 + 12]; + out[i*16 + 13] = in[i*16 + 13]; + out[i*16 + 14] = in[i*16 + 14]; + out[i*16 + 15] = in[i*16 + 15]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*16] != in[i*16] + || out[i*16 + 1] != in[i*16 + 1] + || out[i*16 + 2] != in[i*16 + 2] + || out[i*16 + 3] != in[i*16 + 3] + || out[i*16 + 4] != in[i*16 + 4] + || out[i*16 + 5] != in[i*16 + 5] + || out[i*16 + 6] != in[i*16 + 6] + || out[i*16 + 7] != in[i*16 + 7] + || out[i*16 + 8] != in[i*16 + 8] + || out[i*16 + 9] != in[i*16 + 9] + || out[i*16 + 10] != in[i*16 + 10] + || out[i*16 + 11] != in[i*16 + 11] + || out[i*16 + 12] != in[i*16 + 12] + || out[i*16 + 13] != in[i*16 + 13] + || out[i*16 + 14] != in[i*16 + 14] + || out[i*16 + 15] != in[i*16 + 15]) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-50.c b/SingleSource/Regression/C/gcc-dg/vect/slp-50.c new file mode 100644 index 0000000000..17509e622a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-50.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ffast-math" } */ + +typedef int Quantum; +typedef struct { + Quantum blue, green; +} PixelPacket; +PixelPacket *EnhanceImage_image_q; +int EnhanceImage_image_x; +float EnhanceImage_image_distance_squared_total_weight; +void EnhanceImage_image_distance_squared() +{ + float zero_1; + for (; EnhanceImage_image_x; EnhanceImage_image_x++) { + EnhanceImage_image_distance_squared_total_weight += 5.0; + EnhanceImage_image_q->green = EnhanceImage_image_q->blue = + zero_1 + EnhanceImage_image_distance_squared_total_weight / 2 - 1; + EnhanceImage_image_q++; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-6.c b/SingleSource/Regression/C/gcc-dg/vect/slp-6.c new file mode 100644 index 0000000000..ea9f788973 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-6.c @@ -0,0 +1,124 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned int in2[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +int +main1 () +{ + int i; + unsigned short out[N*8]; + unsigned int out2[N*8]; + + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8] + 5; + out[i*8 + 1] = in[i*8 + 1] + 6; + out[i*8 + 2] = in[i*8 + 2] + 7; + out[i*8 + 3] = in[i*8 + 3] + 8; + out[i*8 + 4] = in[i*8 + 4] + 9; + out[i*8 + 5] = in[i*8 + 5] + 10; + out[i*8 + 6] = in[i*8 + 6] + 11; + out[i*8 + 7] = in[i*8 + 7] + 12; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + 5 + || out[i*8 + 1] != in[i*8 + 1] + 6 + || out[i*8 + 2] != in[i*8 + 2] + 7 + || out[i*8 + 3] != in[i*8 + 3] + 8 + || out[i*8 + 4] != in[i*8 + 4] + 9 + || out[i*8 + 5] != in[i*8 + 5] + 10 + || out[i*8 + 6] != in[i*8 + 6] + 11 + || out[i*8 + 7] != in[i*8 + 7] + 12) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = in[i*4] + 2; + out[i*4 + 1] = in[i*4 + 1] + 2; + out[i*4 + 2] = in[i*4 + 2] + 1; + out[i*4 + 3] = in[i*4 + 3] + 3; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != in[i*4] + 2 + || out[i*4 + 1] != in[i*4 + 1] + 2 + || out[i*4 + 2] != in[i*4 + 2] + 1 + || out[i*4 + 3] != in[i*4 + 3] + 3) + abort (); + } + + for (i = 0; i < N/2; i++) + { + out2[i*16] = in2[i*16] * 2; + out2[i*16 + 1] = in2[i*16 + 1] * 3; + out2[i*16 + 2] = in2[i*16 + 2] * 4; + out2[i*16 + 3] = in2[i*16 + 3] * 3; + out2[i*16 + 4] = in2[i*16 + 4] * 2; + out2[i*16 + 5] = in2[i*16 + 5] * 3; + out2[i*16 + 6] = in2[i*16 + 6] * 2; + out2[i*16 + 7] = in2[i*16 + 7] * 4; + out2[i*16 + 8] = in2[i*16 + 8] * 2; + out2[i*16 + 9] = in2[i*16 + 9] * 5; + out2[i*16 + 10] = in2[i*16 + 10] * 2; + out2[i*16 + 11] = in2[i*16 + 11] * 3; + out2[i*16 + 12] = in2[i*16 + 12] * 4; + out2[i*16 + 13] = in2[i*16 + 13] * 4; + out2[i*16 + 14] = in2[i*16 + 14] * 3; + out2[i*16 + 15] = in2[i*16 + 15] * 2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out2[i*16] != in2[i*16] * 2 + || out2[i*16 + 1] != in2[i*16 + 1] * 3 + || out2[i*16 + 2] != in2[i*16 + 2] * 4 + || out2[i*16 + 3] != in2[i*16 + 3] * 3 + || out2[i*16 + 4] != in2[i*16 + 4] * 2 + || out2[i*16 + 5] != in2[i*16 + 5] * 3 + || out2[i*16 + 6] != in2[i*16 + 6] * 2 + || out2[i*16 + 7] != in2[i*16 + 7] * 4 + || out2[i*16 + 8] != in2[i*16 + 8] * 2 + || out2[i*16 + 9] != in2[i*16 + 9] * 5 + || out2[i*16 + 10] != in2[i*16 + 10] * 2 + || out2[i*16 + 11] != in2[i*16 + 11] * 3 + || out2[i*16 + 12] != in2[i*16 + 12] * 4 + || out2[i*16 + 13] != in2[i*16 + 13] * 4 + || out2[i*16 + 14] != in2[i*16 + 14] * 3 + || out2[i*16 + 15] != in2[i*16 + 15] * 2) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" {target vect_int_mult} } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" {target { ! { vect_int_mult } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" {target vect_int_mult } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" {target { ! { vect_int_mult } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-7.c b/SingleSource/Regression/C/gcc-dg/vect/slp-7.c new file mode 100644 index 0000000000..2845a99ded --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-7.c @@ -0,0 +1,130 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned int in[N*8] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned short in2[N*16] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +int +main1 () +{ + int i; + unsigned int out[N*8], ia[N*2]; + unsigned short sa[N], out2[N*16]; + + for (i = 0; i < N; i++) + { + out[i*8] = in[i*8] + 5; + out[i*8 + 1] = in[i*8 + 1] + 6; + out[i*8 + 2] = in[i*8 + 2] + 7; + out[i*8 + 3] = in[i*8 + 3] + 8; + out[i*8 + 4] = in[i*8 + 4] + 9; + out[i*8 + 5] = in[i*8 + 5] + 10; + out[i*8 + 6] = in[i*8 + 6] + 11; + out[i*8 + 7] = in[i*8 + 7] + 12; + + ia[i] = in[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != in[i*8] + 5 + || out[i*8 + 1] != in[i*8 + 1] + 6 + || out[i*8 + 2] != in[i*8 + 2] + 7 + || out[i*8 + 3] != in[i*8 + 3] + 8 + || out[i*8 + 4] != in[i*8 + 4] + 9 + || out[i*8 + 5] != in[i*8 + 5] + 10 + || out[i*8 + 6] != in[i*8 + 6] + 11 + || out[i*8 + 7] != in[i*8 + 7] + 12 + || ia[i] != in[i]) + abort (); + } + + for (i = 0; i < N*2; i++) + { + out[i*4] = in[i*4] + 1; + out[i*4 + 1] = in[i*4 + 1] + 2; + out[i*4 + 2] = in[i*4 + 2] + 3; + out[i*4 + 3] = in[i*4 + 3] + 4; + + ia[i] = in[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*2; i++) + { + if (out[i*4] != in[i*4] + 1 + || out[i*4 + 1] != in[i*4 + 1] + 2 + || out[i*4 + 2] != in[i*4 + 2] + 3 + || out[i*4 + 3] != in[i*4 + 3] + 4 + || ia[i] != in[i]) + abort (); + } + + for (i = 0; i < N; i++) + { + out2[i*16] = in2[i*16] * 2; + out2[i*16 + 1] = in2[i*16 + 1] * 3; + out2[i*16 + 2] = in2[i*16 + 2] * 4; + out2[i*16 + 3] = in2[i*16 + 3] * 3; + out2[i*16 + 4] = in2[i*16 + 4] * 2; + out2[i*16 + 5] = in2[i*16 + 5] * 3; + out2[i*16 + 6] = in2[i*16 + 6] * 2; + out2[i*16 + 7] = in2[i*16 + 7] * 4; + out2[i*16 + 8] = in2[i*16 + 8] * 2; + out2[i*16 + 9] = in2[i*16 + 9] * 5; + out2[i*16 + 10] = in2[i*16 + 10] * 2; + out2[i*16 + 11] = in2[i*16 + 11] * 3; + out2[i*16 + 12] = in2[i*16 + 12] * 4; + out2[i*16 + 13] = in2[i*16 + 13] * 4; + out2[i*16 + 14] = in2[i*16 + 14] * 3; + out2[i*16 + 15] = in2[i*16 + 15] * 2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out2[i*16] != in2[i*16] * 2 + || out2[i*16 + 1] != in2[i*16 + 1] * 3 + || out2[i*16 + 2] != in2[i*16 + 2] * 4 + || out2[i*16 + 3] != in2[i*16 + 3] * 3 + || out2[i*16 + 4] != in2[i*16 + 4] * 2 + || out2[i*16 + 5] != in2[i*16 + 5] * 3 + || out2[i*16 + 6] != in2[i*16 + 6] * 2 + || out2[i*16 + 7] != in2[i*16 + 7] * 4 + || out2[i*16 + 8] != in2[i*16 + 8] * 2 + || out2[i*16 + 9] != in2[i*16 + 9] * 5 + || out2[i*16 + 10] != in2[i*16 + 10] * 2 + || out2[i*16 + 11] != in2[i*16 + 11] * 3 + || out2[i*16 + 12] != in2[i*16 + 12] * 4 + || out2[i*16 + 13] != in2[i*16 + 13] * 4 + || out2[i*16 + 14] != in2[i*16 + 14] * 3 + || out2[i*16 + 15] != in2[i*16 + 15] * 2) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target vect_short_mult } } }*/ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { ! { vect_short_mult } } } } }*/ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" { target vect_short_mult } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { ! { vect_short_mult } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-8.c b/SingleSource/Regression/C/gcc-dg/vect/slp-8.c new file mode 100644 index 0000000000..8647249f54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-8.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +int main1 () +{ + int i; + float fa[N]; + + /* int -> float */ + for (i = 0; i < N/4; i++) + { + fa[4*i] = (float) ib[4*i]; + fa[4*i + 1] = (float) ib[4*i + 1]; + fa[4*i + 2] = (float) ib[4*i + 2]; + fa[4*i + 3] = (float) ib[4*i + 3]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + if (fa[4*i] != (float) ib[4*i] + || fa[4*i + 1] != (float) ib[4*i + 1] + || fa[4*i + 2] != (float) ib[4*i + 2] + || fa[4*i + 3] != (float) ib[4*i + 3]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-9.c b/SingleSource/Regression/C/gcc-dg/vect/slp-9.c new file mode 100644 index 0000000000..4fb6953cce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-9.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-early-inlining" } */ + +#include +#include "tree-vect.h" + +#define N 64 + +short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int result[N]; + +/* short->int widening-mult */ +int +foo1(int len) { + int i; + + for (i=0; i b[2*i+1] ? 51 : 12; + } +} + +__attribute__((noinline, noclone)) void +f4 (void) +{ + int i; + for (i = 0; i < N/2; ++i) + { + int d0 = d[2*i], e0 = e[2*i]; + int d1 = d[2*i+1], e1 = e[2*i+1]; + k[2*i] = a[2*i] >= b[2*i] ? d0 : e0; + k[2*i+1] = a[2*i+1] >= b[2*i+1] ? d1 : e1; + } +} + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break; + case 1: a[i] = 0; b[i] = 0; break; + case 2: a[i] = i + 1; b[i] = - i - 1; break; + case 3: a[i] = i; b[i] = i + 7; break; + case 4: a[i] = i; b[i] = i; break; + case 5: a[i] = i + 16; b[i] = i + 3; break; + case 6: a[i] = - i - 5; b[i] = - i; break; + case 7: a[i] = - i; b[i] = - i; break; + case 8: a[i] = - i; b[i] = - i - 7; break; + } + d[i] = i; + e[i] = 2 * i; + } + f1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 ? 17 : 0)) + abort (); + + f2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: + case 6: + if (k[i] != ((i/9 % 2) == 0 ? 0 : 7)) + abort (); + break; + case 1: + case 5: + case 7: + if (k[i] != ((i/9 % 2) == 0 ? 4 : 24)) + abort (); + break; + case 2: + case 4: + case 8: + if (k[i] != ((i/9 % 2) == 0 ? 24 : 4)) + abort (); + break; + case 3: + if (k[i] != ((i/9 % 2) == 0 ? 7 : 0)) + abort (); + break; + } + } + + f3 (); + + f4 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 ? e[i] : d[i])) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-cond-2-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-2-big-array.c new file mode 100644 index 0000000000..cb7eb94b3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-2-big-array.c @@ -0,0 +1,131 @@ +/* { dg-require-effective-target vect_cond_mixed } */ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +#define N 128 +int d[N], e[N], f[N]; +unsigned char k[N]; +float a[N], b[N]; + +__attribute__((noinline, noclone)) void +f1 (void) +{ + int i; + for (i = 0; i < N/4; i++) + { + k[4*i] = a[4*i] < b[4*i] ? 17 : 0; + k[4*i+1] = a[4*i+1] < b[4*i+1] ? 17 : 0; + k[4*i+2] = a[4*i+2] < b[4*i+2] ? 17 : 0; + k[4*i+3] = a[4*i+3] < b[4*i+3] ? 17 : 0; + } +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + int i; + for (i = 0; i < N/2; ++i) + { + k[2*i] = a[2*i] < b[2*i] ? 0 : 24; + k[2*i+1] = a[2*i+1] < b[2*i+1] ? 7 : 4; + } +} + +__attribute__((noinline, noclone)) void +f3 (void) +{ + int i; + for (i = 0; i < N/2; ++i) + { + k[2*i] = a[2*i] < b[2*i] ? 51 : 12; + k[2*i+1] = a[2*i+1] > b[2*i+1] ? 51 : 12; + } +} + +__attribute__((noinline, noclone)) void +f4 (void) +{ + int i; + for (i = 0; i < N/2; ++i) + { + int d0 = d[2*i], e0 = e[2*i]; + int d1 = d[2*i+1], e1 = e[2*i+1]; + f[2*i] = a[2*i] >= b[2*i] ? d0 : e0; + f[2*i+1] = a[2*i+1] >= b[2*i+1] ? d1 : e1; + } +} + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break; + case 1: a[i] = 0; b[i] = 0; break; + case 2: a[i] = i + 1; b[i] = - i - 1; break; + case 3: a[i] = i; b[i] = i + 7; break; + case 4: a[i] = i; b[i] = i; break; + case 5: a[i] = i + 16; b[i] = i + 3; break; + case 6: a[i] = - i - 5; b[i] = - i; break; + case 7: a[i] = - i; b[i] = - i; break; + case 8: a[i] = - i; b[i] = - i - 7; break; + } + d[i] = i; + e[i] = 2 * i; + } + + f1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 ? 17 : 0)) + abort (); + + f2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: + case 6: + if (k[i] != ((i/9 % 2) == 0 ? 0 : 7)) + abort (); + break; + case 1: + case 5: + case 7: + if (k[i] != ((i/9 % 2) == 0 ? 4 : 24)) + abort (); + break; + case 2: + case 4: + case 8: + if (k[i] != ((i/9 % 2) == 0 ? 24 : 4)) + abort (); + break; + case 3: + if (k[i] != ((i/9 % 2) == 0 ? 7 : 0)) + abort (); + break; + } + } + + f3 (); + + f4 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (f[i] != ((i % 3) == 0 ? e[i] : d[i])) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-cond-2.c b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-2.c new file mode 100644 index 0000000000..1dcee46cd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-2.c @@ -0,0 +1,131 @@ +/* { dg-require-effective-target vect_cond_mixed } */ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +#define N 32 +int d[N], e[N], f[N]; +unsigned char k[N]; +float a[N], b[N]; + +__attribute__((noinline, noclone)) void +f1 (void) +{ + int i; + for (i = 0; i < N/4; i++) + { + k[4*i] = a[4*i] < b[4*i] ? 17 : 0; + k[4*i+1] = a[4*i+1] < b[4*i+1] ? 17 : 0; + k[4*i+2] = a[4*i+2] < b[4*i+2] ? 17 : 0; + k[4*i+3] = a[4*i+3] < b[4*i+3] ? 17 : 0; + } +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + int i; + for (i = 0; i < N/2; ++i) + { + k[2*i] = a[2*i] < b[2*i] ? 0 : 24; + k[2*i+1] = a[2*i+1] < b[2*i+1] ? 7 : 4; + } +} + +__attribute__((noinline, noclone)) void +f3 (void) +{ + int i; + for (i = 0; i < N/2; ++i) + { + k[2*i] = a[2*i] < b[2*i] ? 51 : 12; + k[2*i+1] = a[2*i+1] > b[2*i+1] ? 51 : 12; + } +} + +__attribute__((noinline, noclone)) void +f4 (void) +{ + int i; + for (i = 0; i < N/2; ++i) + { + int d0 = d[2*i], e0 = e[2*i]; + int d1 = d[2*i+1], e1 = e[2*i+1]; + f[2*i] = a[2*i] >= b[2*i] ? d0 : e0; + f[2*i+1] = a[2*i+1] >= b[2*i+1] ? d1 : e1; + } +} + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break; + case 1: a[i] = 0; b[i] = 0; break; + case 2: a[i] = i + 1; b[i] = - i - 1; break; + case 3: a[i] = i; b[i] = i + 7; break; + case 4: a[i] = i; b[i] = i; break; + case 5: a[i] = i + 16; b[i] = i + 3; break; + case 6: a[i] = - i - 5; b[i] = - i; break; + case 7: a[i] = - i; b[i] = - i; break; + case 8: a[i] = - i; b[i] = - i - 7; break; + } + d[i] = i; + e[i] = 2 * i; + } + + f1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 ? 17 : 0)) + abort (); + + f2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: + case 6: + if (k[i] != ((i/9 % 2) == 0 ? 0 : 7)) + abort (); + break; + case 1: + case 5: + case 7: + if (k[i] != ((i/9 % 2) == 0 ? 4 : 24)) + abort (); + break; + case 2: + case 4: + case 8: + if (k[i] != ((i/9 % 2) == 0 ? 24 : 4)) + abort (); + break; + case 3: + if (k[i] != ((i/9 % 2) == 0 ? 7 : 0)) + abort (); + break; + } + } + + f3 (); + + f4 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (f[i] != ((i % 3) == 0 ? e[i] : d[i])) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-cond-3.c b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-3.c new file mode 100644 index 0000000000..64904b001e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-3.c @@ -0,0 +1,84 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +#define N 128 + +/* Comparison in int, then/else and result in unsigned char. */ + +static inline unsigned char +foo (int x, int y, int a, int b) +{ + if (x >= y) + return a; + else + return b; +} + +__attribute__((noinline, noclone)) void +bar (unsigned char * __restrict__ a, unsigned char * __restrict__ b, + unsigned char * __restrict__ c, unsigned char * __restrict__ d, + unsigned char * __restrict__ e, int w) +{ + int i; + for (i = 0; i < N/16; i++, a += 16, b += 16, c += 16, d += 16, e += 16) + { + e[0] = foo (c[0], d[0], a[0] * w, b[0] * w); + e[1] = foo (c[1], d[1], a[1] * w, b[1] * w); + e[2] = foo (c[2], d[2], a[2] * w, b[2] * w); + e[3] = foo (c[3], d[3], a[3] * w, b[3] * w); + e[4] = foo (c[4], d[4], a[4] * w, b[4] * w); + e[5] = foo (c[5], d[5], a[5] * w, b[5] * w); + e[6] = foo (c[6], d[6], a[6] * w, b[6] * w); + e[7] = foo (c[7], d[7], a[7] * w, b[7] * w); + e[8] = foo (c[8], d[8], a[8] * w, b[8] * w); + e[9] = foo (c[9], d[9], a[9] * w, b[9] * w); + e[10] = foo (c[10], d[10], a[10] * w, b[10] * w); + e[11] = foo (c[11], d[11], a[11] * w, b[11] * w); + e[12] = foo (c[12], d[12], a[12] * w, b[12] * w); + e[13] = foo (c[13], d[13], a[13] * w, b[13] * w); + e[14] = foo (c[14], d[14], a[14] * w, b[14] * w); + e[15] = foo (c[15], d[15], a[15] * w, b[15] * w); + } +} + + +unsigned char a[N], b[N], c[N], d[N], e[N]; + +int main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = i; + b[i] = 5; + e[i] = 0; + + switch (i % 9) + { + case 0: asm (""); c[i] = i; d[i] = i + 1; break; + case 1: c[i] = 0; d[i] = 0; break; + case 2: c[i] = i + 1; d[i] = i - 1; break; + case 3: c[i] = i; d[i] = i + 7; break; + case 4: c[i] = i; d[i] = i; break; + case 5: c[i] = i + 16; d[i] = i + 3; break; + case 6: c[i] = i - 5; d[i] = i; break; + case 7: c[i] = i; d[i] = i; break; + case 8: c[i] = i; d[i] = i - 7; break; + } + } + + bar (a, b, c, d, e, 2); +#pragma GCC novector + for (i = 0; i < N; i++) + if (e[i] != ((i % 3) == 0 ? 10 : 2 * i)) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-cond-4.c b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-4.c new file mode 100644 index 0000000000..0e1bd3b409 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-4.c @@ -0,0 +1,86 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +#define N 128 + +/* Comparison in short, then/else and result in int. */ +static inline int +foo (short x, short y, int a, int b) +{ + if (x >= y) + return a; + else + return b; +} + +__attribute__((noinline, noclone)) void +bar (short * __restrict__ a, short * __restrict__ b, + short * __restrict__ c, short * __restrict__ d, + int * __restrict__ e, int w) +{ + int i; + int stride = 16; + + for (i = 0; i < N/stride; i++, a += stride, b += stride, c += stride, + d += stride, e += stride) + { + e[0] = foo (c[0], d[0], a[0], b[0]); + e[1] = foo (c[1], d[1], a[1], b[1]); + e[2] = foo (c[2], d[2], a[2], b[2]); + e[3] = foo (c[3], d[3], a[3], b[3]); + e[4] = foo (c[4], d[4], a[4], b[4]); + e[5] = foo (c[5], d[5], a[5], b[5]); + e[6] = foo (c[6], d[6], a[6], b[6]); + e[7] = foo (c[7], d[7], a[7], b[7]); + e[8] = foo (c[8], d[8], a[8], b[8]); + e[9] = foo (c[9], d[9], a[9], b[9]); + e[10] = foo (c[10], d[10], a[10], b[10]); + e[11] = foo (c[11], d[11], a[11], b[11]); + e[12] = foo (c[12], d[12], a[12], b[12]); + e[13] = foo (c[13], d[13], a[13], b[13]); + e[14] = foo (c[14], d[14], a[14], b[14]); + e[15] = foo (c[15], d[15], a[15], b[15]); + } +} + + +short a[N], b[N], c[N], d[N]; +int e[N]; + +int main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = i; + b[i] = 5; + e[i] = 0; + + switch (i % 9) + { + case 0: asm (""); c[i] = - i - 1; d[i] = i + 1; break; + case 1: c[i] = 0; d[i] = 0; break; + case 2: c[i] = i + 1; d[i] = - i - 1; break; + case 3: c[i] = i; d[i] = i + 7; break; + case 4: c[i] = i; d[i] = i; break; + case 5: c[i] = i + 16; d[i] = i + 3; break; + case 6: c[i] = - i - 5; d[i] = - i; break; + case 7: c[i] = - i; d[i] = - i; break; + case 8: c[i] = - i; d[i] = - i - 7; break; + } + } + + bar (a, b, c, d, e, 2); +#pragma GCC novector + for (i = 0; i < N; i++) + if (e[i] != ((i % 3) == 0 ? 5 : i)) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-cond-5.c b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-5.c new file mode 100644 index 0000000000..f0a703f003 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-cond-5.c @@ -0,0 +1,82 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +#define N 128 + +static inline int +foo (int x, int y, int a, int b) +{ + if (x >= y && a > b) + return a; + else + return b; +} + +__attribute__((noinline, noclone)) void +bar (int * __restrict__ a, int * __restrict__ b, + int * __restrict__ c, int * __restrict__ d, + int * __restrict__ e, int w) +{ + int i; + for (i = 0; i < N/16; i++, a += 16, b += 16, c += 16, d += 16, e += 16) + { + e[0] = foo (c[0], d[0], a[0] * w, b[0] * w); + e[1] = foo (c[1], d[1], a[1] * w, b[1] * w); + e[2] = foo (c[2], d[2], a[2] * w, b[2] * w); + e[3] = foo (c[3], d[3], a[3] * w, b[3] * w); + e[4] = foo (c[4], d[4], a[4] * w, b[4] * w); + e[5] = foo (c[5], d[5], a[5] * w, b[5] * w); + e[6] = foo (c[6], d[6], a[6] * w, b[6] * w); + e[7] = foo (c[7], d[7], a[7] * w, b[7] * w); + e[8] = foo (c[8], d[8], a[8] * w, b[8] * w); + e[9] = foo (c[9], d[9], a[9] * w, b[9] * w); + e[10] = foo (c[10], d[10], a[10] * w, b[10] * w); + e[11] = foo (c[11], d[11], a[11] * w, b[11] * w); + e[12] = foo (c[12], d[12], a[12] * w, b[12] * w); + e[13] = foo (c[13], d[13], a[13] * w, b[13] * w); + e[14] = foo (c[14], d[14], a[14] * w, b[14] * w); + e[15] = foo (c[15], d[15], a[15] * w, b[15] * w); + } +} + + +int a[N], b[N], c[N], d[N], e[N]; + +int main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = i; + b[i] = 5; + e[i] = 0; + + switch (i % 9) + { + case 0: asm (""); c[i] = i; d[i] = i + 1; break; + case 1: c[i] = 0; d[i] = 0; break; + case 2: c[i] = i + 1; d[i] = i - 1; break; + case 3: c[i] = i; d[i] = i + 7; break; + case 4: c[i] = i; d[i] = i; break; + case 5: c[i] = i + 16; d[i] = i + 3; break; + case 6: c[i] = i - 5; d[i] = i; break; + case 7: c[i] = i; d[i] = i; break; + case 8: c[i] = i; d[i] = i - 7; break; + } + } + + bar (a, b, c, d, e, 2); +#pragma GCC novector + for (i = 0; i < N; i++) + if (e[i] != ((i % 3) == 0 || i <= 5 ? 10 : 2 * i)) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { i?86-*-* x86_64-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-mask-store-1.c b/SingleSource/Regression/C/gcc-dg/vect/slp-mask-store-1.c new file mode 100644 index 0000000000..fdd9032da9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-mask-store-1.c @@ -0,0 +1,38 @@ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (unsigned * __restrict x, int * __restrict flag) +{ + for (int i = 0; i < 32; ++i) + { + if (flag[2*i+0]) + x[2*i+0] = x[2*i+0] + 3; + if (flag[2*i+1]) + x[2*i+1] = x[2*i+1] + 177; + } +} + +unsigned x[16]; +int flag[32] = { 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +unsigned res[16] = { 3, 177, 0, 0, 0, 177, 3, 0, 3, 177, 0, 0, 0, 177, 3, 0 }; + +int +main () +{ + check_vect (); + + foo (x, flag); + + if (__builtin_memcmp (x, res, sizeof (x)) != 0) + abort (); + for (int i = 0; i < 32; ++i) + if (flag[i] != 0 && flag[i] != 1) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target { vect_masked_store && vect_masked_load } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-1.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-1.c new file mode 100644 index 0000000000..605f6ab8ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-1.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) int +main1 () +{ + int i; + unsigned short sout[N*8]; + unsigned int iout[N*8]; + + for (i = 0; i < N; i++) + { + sout[i*4] = 8; + sout[i*4 + 1] = 18; + sout[i*4 + 2] = 28; + sout[i*4 + 3] = 38; + + iout[i*4] = 8; + iout[i*4 + 1] = 18; + iout[i*4 + 2] = 28; + iout[i*4 + 3] = 38; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (sout[i*4] != 8 + || sout[i*4 + 1] != 18 + || sout[i*4 + 2] != 28 + || sout[i*4 + 3] != 38 + || iout[i*4] != 8 + || iout[i*4 + 1] != 18 + || iout[i*4 + 2] != 28 + || iout[i*4 + 3] != 38) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-10.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-10.c new file mode 100644 index 0000000000..06d9029e92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-10.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +struct s +{ + unsigned char a; + unsigned char b; +}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + struct s out[N*4]; + + for (i = 0; i < N*4; i++) + { + out[i].a = (unsigned char) in[i*2] + 1; + out[i].b = (unsigned char) in[i*2 + 1] + 2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*4; i++) + { + if (out[i].a != (unsigned char) in[i*2] + 1 + || out[i].b != (unsigned char) in[i*2 + 1] + 2) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_pack_trunc } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_pack_trunc } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-11-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-11-big-array.c new file mode 100644 index 0000000000..2792b93273 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-11-big-array.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 144 + +struct s +{ + int a; + int b; + int c; +}; + +char in[N*3]; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + struct s out[N]; + + for (i = 0; i < N; i++) + { + in[i] = i&127; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + out[i].a = (int) in[i*3] + 1; + out[i].b = (int) in[i*3 + 1] + 2; + out[i].c = (int) in[i*3 + 2] + 3; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i].a != (int) in[i*3] + 1 + || out[i].b != (int) in[i*3 + 1] + 2 + || out[i].c != (int) in[i*3 + 2] + 3) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_unpack xfail { vect_variable_length && vect_load_lanes } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-11.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-11.c new file mode 100644 index 0000000000..5c75dc12b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-11.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 18 + +struct s +{ + int a; + int b; + int c; +}; + +char in[N*3] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + struct s out[N]; + + for (i = 0; i < N; i++) + { + out[i].a = (int) in[i*3] + 1; + out[i].b = (int) in[i*3 + 1] + 2; + out[i].c = (int) in[i*3 + 2] + 3; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i].a != (int) in[i*3] + 1 + || out[i].b != (int) in[i*3 + 1] + 2 + || out[i].c != (int) in[i*3 + 2] + 3) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ +/* The epilogues are vectorized using partial vectors. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_unpack && { { ! vect_partial_vectors_usage_1 } || s390_vx } } xfail { vect_variable_length && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { { vect_unpack && vect_partial_vectors_usage_1 } && { ! s390_vx } } xfail { vect_variable_length && vect_load_lanes } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-12.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-12.c new file mode 100644 index 0000000000..1311982220 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-12.c @@ -0,0 +1,67 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) int +main1 () +{ + int i; + unsigned short sout[N*8]; + unsigned int iout[N*8]; + unsigned char cout[N*8]; + + for (i = 0; i < N; i++) + { + sout[i*4] = 8; + sout[i*4 + 1] = 18; + sout[i*4 + 2] = 28; + sout[i*4 + 3] = 38; + + iout[i*4] = 8; + iout[i*4 + 1] = 18; + iout[i*4 + 2] = 28; + iout[i*4 + 3] = 38; + + cout[i*4] = 1; + cout[i*4 + 1] = 2; + cout[i*4 + 2] = 3; + cout[i*4 + 3] = 4; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (sout[i*4] != 8 + || sout[i*4 + 1] != 18 + || sout[i*4 + 2] != 28 + || sout[i*4 + 3] != 38 + || iout[i*4] != 8 + || iout[i*4 + 1] != 18 + || iout[i*4 + 2] != 28 + || iout[i*4 + 3] != 38 + || cout[i*4] != 1 + || cout[i*4 + 1] != 2 + || cout[i*4 + 2] != 3 + || cout[i*4 + 3] != 4) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-13.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-13.c new file mode 100644 index 0000000000..bbbbb2c64b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-13.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +void +f (long *x, int n) +{ + for (int i = 0; i < n; i++) + { + x[i * 2] = 1L << i; + x[i * 2 + 1] = 1L << i; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-2.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-2.c new file mode 100644 index 0000000000..c15baa00dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-2.c @@ -0,0 +1,82 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) int +main1 (unsigned short a0, unsigned short a1, unsigned short a2, + unsigned short a3, unsigned short a4, unsigned short a5, + unsigned short a6, unsigned short a7, unsigned short a8, + unsigned short a9, unsigned short a10, unsigned short a11, + unsigned short a12, unsigned short a13, unsigned short a14, + unsigned short a15, unsigned char b0, unsigned char b1) +{ + int i; + unsigned short out[N*16]; + unsigned char out2[N*16]; + + for (i = 0; i < N; i++) + { + out[i*16] = a8; + out[i*16 + 1] = a7; + out[i*16 + 2] = a1; + out[i*16 + 3] = a2; + out[i*16 + 4] = a8; + out[i*16 + 5] = a5; + out[i*16 + 6] = a5; + out[i*16 + 7] = a4; + out[i*16 + 8] = a12; + out[i*16 + 9] = a13; + out[i*16 + 10] = a14; + out[i*16 + 11] = a15; + out[i*16 + 12] = a6; + out[i*16 + 13] = a9; + out[i*16 + 14] = a0; + out[i*16 + 15] = a7; + + out2[i*2] = b1; + out2[i*2+1] = b0; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*16] != a8 + || out[i*16 + 1] != a7 + || out[i*16 + 2] != a1 + || out[i*16 + 3] != a2 + || out[i*16 + 4] != a8 + || out[i*16 + 5] != a5 + || out[i*16 + 6] != a5 + || out[i*16 + 7] != a4 + || out[i*16 + 8] != a12 + || out[i*16 + 9] != a13 + || out[i*16 + 10] != a14 + || out[i*16 + 11] != a15 + || out[i*16 + 12] != a6 + || out[i*16 + 13] != a9 + || out[i*16 + 14] != a0 + || out[i*16 + 15] != a7 + || out2[i*2] != b1 + || out2[i*2 + 1] != b0) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,20,21); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-3.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-3.c new file mode 100644 index 0000000000..c79906a8d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-3.c @@ -0,0 +1,92 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned char in2[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + unsigned int out[N*8]; + unsigned char out2[N*8]; + + for (i = 0; i < N/2; i++) + { + out[i*8] = in[i*8] + 5; + out[i*8 + 1] = in[i*8 + 1] + 6; + out[i*8 + 2] = in[i*8 + 2] + 7; + out[i*8 + 3] = in[i*8 + 3] + 8; + out[i*8 + 4] = in[i*8 + 4] + 9; + out[i*8 + 5] = in[i*8 + 5] + 10; + out[i*8 + 6] = in[i*8 + 6] + 11; + out[i*8 + 7] = in[i*8 + 7] + 12; + + out2[i*16] = in2[i*16] + 2; + out2[i*16 + 1] = in2[i*16 + 1] + 3; + out2[i*16 + 2] = in2[i*16 + 2] + 4; + out2[i*16 + 3] = in2[i*16 + 3] + 3; + out2[i*16 + 4] = in2[i*16 + 4] + 2; + out2[i*16 + 5] = in2[i*16 + 5] + 3; + out2[i*16 + 6] = in2[i*16 + 6] + 2; + out2[i*16 + 7] = in2[i*16 + 7] + 4; + out2[i*16 + 8] = in2[i*16 + 8] + 2; + out2[i*16 + 9] = in2[i*16 + 9] + 5; + out2[i*16 + 10] = in2[i*16 + 10] + 2; + out2[i*16 + 11] = in2[i*16 + 11] + 3; + out2[i*16 + 12] = in2[i*16 + 12] + 4; + out2[i*16 + 13] = in2[i*16 + 13] + 4; + out2[i*16 + 14] = in2[i*16 + 14] + 3; + out2[i*16 + 15] = in2[i*16 + 15] + 2; + + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (out[i*8] != in[i*8] + 5 + || out[i*8 + 1] != in[i*8 + 1] + 6 + || out[i*8 + 2] != in[i*8 + 2] + 7 + || out[i*8 + 3] != in[i*8 + 3] + 8 + || out[i*8 + 4] != in[i*8 + 4] + 9 + || out[i*8 + 5] != in[i*8 + 5] + 10 + || out[i*8 + 6] != in[i*8 + 6] + 11 + || out[i*8 + 7] != in[i*8 + 7] + 12 + || out2[i*16] != in2[i*16] + 2 + || out2[i*16 + 1] != in2[i*16 + 1] + 3 + || out2[i*16 + 2] != in2[i*16 + 2] + 4 + || out2[i*16 + 3] != in2[i*16 + 3] + 3 + || out2[i*16 + 4] != in2[i*16 + 4] + 2 + || out2[i*16 + 5] != in2[i*16 + 5] + 3 + || out2[i*16 + 6] != in2[i*16 + 6] + 2 + || out2[i*16 + 7] != in2[i*16 + 7] + 4 + || out2[i*16 + 8] != in2[i*16 + 8] + 2 + || out2[i*16 + 9] != in2[i*16 + 9] + 5 + || out2[i*16 + 10] != in2[i*16 + 10] + 2 + || out2[i*16 + 11] != in2[i*16 + 11] + 3 + || out2[i*16 + 12] != in2[i*16 + 12] + 4 + || out2[i*16 + 13] != in2[i*16 + 13] + 4 + || out2[i*16 + 14] != in2[i*16 + 14] + 3 + || out2[i*16 + 15] != in2[i*16 + 15] + 2) + + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail sparc*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { xfail sparc*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-4.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-4.c new file mode 100644 index 0000000000..b221f70507 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-4.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + int out[N*8]; + + for (i = 0; i < N; i++) + { + out[i*8] = (int) in[i*8] + 1; + out[i*8 + 1] = (int) in[i*8 + 1] + 2; + out[i*8 + 2] = (int) in[i*8 + 2] + 3; + out[i*8 + 3] = (int) in[i*8 + 3] + 4; + out[i*8 + 4] = (int) in[i*8 + 4] + 5; + out[i*8 + 5] = (int) in[i*8 + 5] + 6; + out[i*8 + 6] = (int) in[i*8 + 6] + 7; + out[i*8 + 7] = (int) in[i*8 + 7] + 8; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (int) in[i*8] + 1 + || out[i*8 + 1] != (int) in[i*8 + 1] + 2 + || out[i*8 + 2] != (int) in[i*8 + 2] + 3 + || out[i*8 + 3] != (int) in[i*8 + 3] + 4 + || out[i*8 + 4] != (int) in[i*8 + 4] + 5 + || out[i*8 + 5] != (int) in[i*8 + 5] + 6 + || out[i*8 + 6] != (int) in[i*8 + 6] + 7 + || out[i*8 + 7] != (int) in[i*8 + 7] + 8) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_unpack } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-5.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-5.c new file mode 100644 index 0000000000..3237773e1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-5.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +short in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + int out[N*8]; + + for (i = 0; i < N; i++) + { + out[i*8] = (short) in[i*8] + 1; + out[i*8 + 1] = (short) in[i*8 + 1] + 2; + out[i*8 + 2] = (short) in[i*8 + 2] + 3; + out[i*8 + 3] = (short) in[i*8 + 3] + 4; + out[i*8 + 4] = (short) in[i*8 + 4] + 5; + out[i*8 + 5] = (short) in[i*8 + 5] + 6; + out[i*8 + 6] = (short) in[i*8 + 6] + 7; + out[i*8 + 7] = (short) in[i*8 + 7] + 8; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (short) in[i*8] + 1 + || out[i*8 + 1] != (short) in[i*8 + 1] + 2 + || out[i*8 + 2] != (short) in[i*8 + 2] + 3 + || out[i*8 + 3] != (short) in[i*8 + 3] + 4 + || out[i*8 + 4] != (short) in[i*8 + 4] + 5 + || out[i*8 + 5] != (short) in[i*8 + 5] + 6 + || out[i*8 + 6] != (short) in[i*8 + 6] + 7 + || out[i*8 + 7] != (short) in[i*8 + 7] + 8) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_pack_trunc } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_pack_trunc } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-6.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-6.c new file mode 100644 index 0000000000..e62d16b6de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-6.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + unsigned char out[N*8]; + + for (i = 0; i < N; i++) + { + out[i*8] = (unsigned char) in[i*8] + 1; + out[i*8 + 1] = (unsigned char) in[i*8 + 1] + 2; + out[i*8 + 2] = (unsigned char) in[i*8 + 2] + 3; + out[i*8 + 3] = (unsigned char) in[i*8 + 3] + 4; + out[i*8 + 4] = (unsigned char) in[i*8 + 4] + 5; + out[i*8 + 5] = (unsigned char) in[i*8 + 5] + 6; + out[i*8 + 6] = (unsigned char) in[i*8 + 6] + 7; + out[i*8 + 7] = (unsigned char) in[i*8 + 7] + 8; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (unsigned char) in[i*8] + 1 + || out[i*8 + 1] != (unsigned char) in[i*8 + 1] + 2 + || out[i*8 + 2] != (unsigned char) in[i*8 + 2] + 3 + || out[i*8 + 3] != (unsigned char) in[i*8 + 3] + 4 + || out[i*8 + 4] != (unsigned char) in[i*8 + 4] + 5 + || out[i*8 + 5] != (unsigned char) in[i*8 + 5] + 6 + || out[i*8 + 6] != (unsigned char) in[i*8 + 6] + 7 + || out[i*8 + 7] != (unsigned char) in[i*8 + 7] + 8) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_pack_trunc } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_pack_trunc } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-7.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-7.c new file mode 100644 index 0000000000..08ab2dc3d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-7.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +char in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + int out[N*8]; + + for (i = 0; i < N; i++) + { + out[i*8] = (int) in[i*8] + 1; + out[i*8 + 1] = (int) in[i*8 + 1] + 2; + out[i*8 + 2] = (int) in[i*8 + 2] + 3; + out[i*8 + 3] = (int) in[i*8 + 3] + 4; + out[i*8 + 4] = (int) in[i*8 + 4] + 5; + out[i*8 + 5] = (int) in[i*8 + 5] + 6; + out[i*8 + 6] = (int) in[i*8 + 6] + 7; + out[i*8 + 7] = (int) in[i*8 + 7] + 8; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i*8] != (int) in[i*8] + 1 + || out[i*8 + 1] != (int) in[i*8 + 1] + 2 + || out[i*8 + 2] != (int) in[i*8 + 2] + 3 + || out[i*8 + 3] != (int) in[i*8 + 3] + 4 + || out[i*8 + 4] != (int) in[i*8 + 4] + 5 + || out[i*8 + 5] != (int) in[i*8 + 5] + 6 + || out[i*8 + 6] != (int) in[i*8 + 6] + 7 + || out[i*8 + 7] != (int) in[i*8 + 7] + 8) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_unpack } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-8.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-8.c new file mode 100644 index 0000000000..0b67ecc8e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-8.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +char in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + int out[N*8]; + + for (i = 0; i < N*4; i++) + { + out[i*2] = (int) in[i*2] + 1; + out[i*2 + 1] = (int) in[i*2 + 1] + 2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*4; i++) + { + if (out[i*2] != (int) in[i*2] + 1 + || out[i*2 + 1] != (int) in[i*2 + 1] + 2) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_unpack } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-9.c b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-9.c new file mode 100644 index 0000000000..4926148316 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-multitypes-9.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned int in[N*8] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + unsigned char out[N*8]; + + for (i = 0; i < N*4; i++) + { + out[i*2] = (unsigned char) in[i*2] + 1; + out[i*2 + 1] = (unsigned char) in[i*2 + 1] + 2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N*4; i++) + { + if (out[i*2] != (unsigned char) in[i*2] + 1 + || out[i*2 + 1] != (unsigned char) in[i*2 + 1] + 2) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_pack_trunc } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_pack_trunc } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-1.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-1.c new file mode 100644 index 0000000000..dbb107f95f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-1.c @@ -0,0 +1,89 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define M00 100 +#define M10 216 +#define M20 23 +#define M01 1322 +#define M11 13 +#define M21 27271 +#define M02 74 +#define M12 191 +#define M22 500 + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 3 / 32 + 4) +#else +#define N 16 +#endif + +void foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput) +{ + unsigned int i, a, b, c; + + for (i = 0; i < N / 3; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + + *pOutput++ = M00 * a + M01 * b + M02 * c; + *pOutput++ = M10 * a + M11 * b + M12 * c; + *pOutput++ = M20 * a + M21 * b + M22 * c; + } +} + +int main (int argc, const char* argv[]) +{ + unsigned int input[N], output[N], i; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i%256; + output[i] = 0; + __asm__ volatile (""); + } + +#if N == 16 + unsigned int check_results[N] = {1470, 395, 28271, 5958, 1655, 111653, 10446, 2915, 195035, 14934, 4175, 278417, 19422, 5435, 361799, 0}; +#else + volatile unsigned int check_results[N] = {}; + + for (unsigned int i = 0; i < N / 3; i++) + { + unsigned int a = input[i * 3]; + unsigned int b = input[i * 3 + 1]; + unsigned int c = input[i * 3 + 2]; + + check_results[i * 3] = M00 * a + M01 * b + M02 * c; + check_results[i * 3 + 1] = M10 * a + M11 * b + M12 * c; + check_results[i * 3 + 2] = M20 * a + M21 * b + M22 * c; + + asm volatile ("" ::: "memory"); + } +#endif + + foo (input, output); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (output[i] != check_results[i]) + abort (); + __asm__ volatile (""); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_int && {! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-10.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-10.c new file mode 100644 index 0000000000..03de4c61b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-10.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int a[256], b[256]; + +void __attribute__((noinline)) +foo (void) +{ + int i; + for (i = 0; i < 32; ++i) + { + b[i*8+0] = a[i*8+0]; + b[i*8+1] = a[i*8+0]; + b[i*8+2] = a[i*8+3]; + b[i*8+3] = a[i*8+3]; + b[i*8+4] = a[i*8+4]; + b[i*8+5] = a[i*8+6]; + b[i*8+6] = a[i*8+4]; + b[i*8+7] = a[i*8+6]; + } +} + +int main () +{ + int i; + + check_vect (); + + for (i = 0; i < 256; ++i) + { + a[i] = i; + __asm__ volatile (""); + } + + foo (); + +#pragma GCC novector + for (i = 0; i < 32; ++i) + if (b[i*8+0] != i*8+0 + || b[i*8+1] != i*8+0 + || b[i*8+2] != i*8+3 + || b[i*8+3] != i*8+3 + || b[i*8+4] != i*8+4 + || b[i*8+5] != i*8+6 + || b[i*8+6] != i*8+4 + || b[i*8+7] != i*8+6) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ +/* SLP fails for variable-length SVE because the load size is greater + than the minimum vector size. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_perm xfail { { aarch64_sve || riscv_v } && vect_variable_length } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-11.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-11.c new file mode 100644 index 0000000000..0d25d9d93b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-11.c @@ -0,0 +1,36 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int a[64]; +int b[128]; + +void __attribute__((noinline, noclone)) +foo (int s) +{ + int i; + for (i = 0; i < 32; ++i) + { + a[2*i] = b[i*s+1]; + a[2*i+1] = b[i*s]; + } +} + +int main () +{ + int i; + check_vect (); + for (i = 0; i < 128; ++i) + { + b[i] = i; + __asm__ volatile (""); + } + foo (4); +#pragma GCC novector + for (i = 0; i < 64; ++i) + if (a[i] != (4*(i/2) + (i & 1) ^ 1)) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target vect_perm } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-12.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-12.c new file mode 100644 index 0000000000..2bd29b8c12 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-12.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-msse4" { target { i?86-*-* x86_64-*-* } } } */ + +#include "tree-vect.h" + +extern void abort (void); + +unsigned char a[64]; +short b[88]; + +void __attribute__((noinline)) +test(unsigned char * __restrict__ dst, short * __restrict__ tptr) +{ + int i; + for (i = 0; i < 8; i++) + { + dst[0] = (tptr[0] - tptr[0 + 3]); + dst[1] = (tptr[1] - tptr[1 + 3]); + dst[2] = (tptr[2] - tptr[2 + 3]); + dst[3] = (tptr[3] - tptr[3 + 3]); + dst[4] = (tptr[4] - tptr[4 + 3]); + dst[5] = (tptr[5] - tptr[5 + 3]); + dst[6] = (tptr[6] - tptr[6 + 3]); + dst[7] = (tptr[7] - tptr[7 + 3]); + dst += 8; + tptr += 11; + } +} + +int main() +{ + int i; + + check_vect (); + + for (i = 0; i < 88; ++i) + { + b[i] = i; + __asm__ volatile (""); + } + + test (a, b); + +#pragma GCC novector + for (i = 0; i < 64; ++i) + if (a[i] != 253) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm && vect_hw_misalign } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-2.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-2.c new file mode 100644 index 0000000000..41fd159adc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-2.c @@ -0,0 +1,62 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define M00 100 +#define M10 216 +#define M01 1322 +#define M11 13 +#define M02 74 +#define M12 191 + +#define N 16 + +void __attribute__((noinline)) +foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput) +{ + unsigned int i, a, b; + + for (i = 0; i < N / 2; i++) + { + a = *pInput++; + b = *pInput++; + + *pOutput++ = M00 * a + M01 * b; + *pOutput++ = M10 * a + M11 * b; + } +} + +int main (int argc, const char* argv[]) +{ + unsigned int input[N], output[N], i; + unsigned int check_results[N] = {1322, 13, 4166, 471, 7010, 929, 9854, 1387, 12698, 1845, 15542, 2303, 18386, 2761, 21230, 3219}; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i%256; + output[i] = 0; + __asm__ volatile (""); + } + + foo (input, output); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (output[i] != check_results[i]) + abort (); + __asm__ volatile (""); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm && {! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-3.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-3.c new file mode 100644 index 0000000000..9ea35ba5af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-3.c @@ -0,0 +1,76 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define M00 100 +#define M10 216 +#define M20 23 +#define M30 237 +#define M01 1322 +#define M11 13 +#define M21 27271 +#define M31 2280 +#define M02 74 +#define M12 191 +#define M22 500 +#define M32 111 +#define M03 134 +#define M13 117 +#define M23 11 +#define M33 771 + +#define N 16 + +void foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput) +{ + unsigned int i, a, b, c, d; + + for (i = 0; i < N / 4; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + d = *pInput++; + + *pOutput++ = M00 * a + M01 * b + M02 * c + M03 * d; + *pOutput++ = M10 * a + M11 * b + M12 * c + M13 * d; + *pOutput++ = M20 * a + M21 * b + M22 * c + M23 * d; + *pOutput++ = M30 * a + M31 * b + M32 * c + M33 * d; + } +} + +int main (int argc, const char* argv[]) +{ + unsigned int input[N], output[N], i; + unsigned int check_results[N] = {1872, 746, 28304, 4815, 8392, 2894, 139524, 18411, 14912, 5042, 250744, 32007, 21432, 7190, 361964, 45603}; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i%256; + output[i] = 0; + __asm__ volatile (""); + } + + foo (input, output); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (output[i] != check_results[i]) + abort (); + __asm__ volatile (""); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm && {! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-4.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-4.c new file mode 100644 index 0000000000..f4bda39c83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-4.c @@ -0,0 +1,118 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include +#include "tree-vect.h" + +#define M00 100 +#define M10 216 +#define M20 23 +#define M30 237 +#define M40 437 + +#define M01 1322 +#define M11 13 +#define M21 27271 +#define M31 2280 +#define M41 284 + +#define M02 74 +#define M12 191 +#define M22 500 +#define M32 111 +#define M42 1114 + +#define M03 134 +#define M13 117 +#define M23 11 +#define M33 771 +#define M43 71 + +#define M04 334 +#define M14 147 +#define M24 115 +#define M34 7716 +#define M44 16 + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 5 / 32) +#else +#define N 20 +#endif + +void foo (unsigned int *__restrict__ pInput, unsigned int *__restrict__ pOutput) +{ + unsigned int i, a, b, c, d, e; + + for (i = 0; i < N / 5; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + d = *pInput++; + e = *pInput++; + + *pOutput++ = M00 * a + M01 * b + M02 * c + M03 * d + M04 * e; + *pOutput++ = M10 * a + M11 * b + M12 * c + M13 * d + M14 * e; + *pOutput++ = M20 * a + M21 * b + M22 * c + M23 * d + M24 * e; + *pOutput++ = M30 * a + M31 * b + M32 * c + M33 * d + M34 * e; + *pOutput++ = M40 * a + M41 * b + M42 * c + M43 * d + M44 * e; + } +} + +int main (int argc, const char* argv[]) +{ + unsigned int input[N], output[N], i; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i%256; + output[i] = 0; + asm volatile ("" ::: "memory"); + } + +#if N == 20 + unsigned int check_results[N] + = {3208, 1334, 28764, 35679, 2789, 13028, 4754, 168364, 91254, 12399, + 22848, 8174, 307964, 146829, 22009, 32668, 11594, 447564, 202404, 31619}; +#else + volatile unsigned int check_results[N]; + + for (i = 0; i < N / 5; i++) + { + unsigned int a = input[i * 5]; + unsigned int b = input[i * 5 + 1]; + unsigned int c = input[i * 5 + 2]; + unsigned int d = input[i * 5 + 3]; + unsigned int e = input[i * 5 + 4]; + + check_results[i * 5] = M00 * a + M01 * b + M02 * c + M03 * d + M04 * e; + check_results[i * 5 + 1] = (M10 * a + M11 * b + M12 * c + + M13 * d + M14 * e); + check_results[i * 5 + 2] = (M20 * a + M21 * b + M22 * c + + M23 * d + M24 * e); + check_results[i * 5 + 3] = (M30 * a + M31 * b + M32 * c + + M33 * d + M34 * e); + check_results[i * 5 + 4] = (M40 * a + M41 * b + M42 * c + + M43 * d + M44 * e); + asm volatile (""); + } +#endif + + foo (input, output); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (output[i] != check_results[i]) + abort (); + + return 0; +} + +/* Currently interleaving is not supported for a group-size of 5. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "gaps requires scalar epilogue loop" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! { vect_load_lanes && vect_strided5 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-5.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-5.c new file mode 100644 index 0000000000..7128cf4715 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-5.c @@ -0,0 +1,113 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define M00 100 +#define M10 216 +#define M20 23 +#define M01 1322 +#define M11 13 +#define M21 27271 +#define M02 74 +#define M12 191 +#define M22 500 + +#define K00 405 +#define K10 112 +#define K01 4322 +#define K11 135 + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 3 / 32 + 4) +#else +#define N 16 +#endif + +void foo (int *__restrict__ pInput, int *__restrict__ pOutput, + int *__restrict__ pInput2, int *__restrict__ pOutput2) +{ + int i, a, b, c, d, e; + + for (i = 0; i < N / 3; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + + d = *pInput2++; + e = *pInput2++; + + *pOutput++ = M00 * a + M01 * b + M02 * c; + *pOutput++ = M10 * a + M11 * b + M12 * c; + *pOutput++ = M20 * a + M21 * b + M22 * c; + + *pOutput2++ = K00 * d + K01 * e; + *pOutput2++ = K10 * d + K11 * e; + } +} + +int main (int argc, const char* argv[]) +{ + int input[N], output[N], i; + int input2[N], output2[N]; + + check_vect (); + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i%256; + input2[i] = i%256; + output[i] = 0; + output2[i] = 0; + __asm__ volatile (""); + } + +#if N == 16 + int check_results[N] = { 1470, 395, 28271, 5958, 1655, 111653, 10446, 2915, + 195035, 14934, 4175, 278417, 19422, 5435, 361799, + 0 }; + int check_results2[N] = { 4322, 135, 13776, 629, 23230, 1123, 32684, 1617, + 42138, 2111, 0, 0, 0, 0, 0, 0 }; +#else + volatile int check_results[N] = {}; + volatile int check_results2[N] = {}; + + for (int i = 0; i < N / 3; i++) + { + int a = input[i * 3]; + int b = input[i * 3 + 1]; + int c = input[i * 3 + 2]; + int d = input2[i * 2]; + int e = input2[i * 2 + 1]; + + check_results[i * 3] = M00 * a + M01 * b + M02 * c; + check_results[i * 3 + 1] = M10 * a + M11 * b + M12 * c; + check_results[i * 3 + 2] = M20 * a + M21 * b + M22 * c; + + check_results2[i * 2] = K00 * d + K01 * e; + check_results2[i * 2 + 1] = K10 * d + K11 * e; + + asm volatile ("" ::: "memory"); + } +#endif + + foo (input, output, input2, output2); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (output[i] != check_results[i] || output2[i] != check_results2[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_int && { ! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-6.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-6.c new file mode 100644 index 0000000000..5cc6261d69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-6.c @@ -0,0 +1,110 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define M00 100 +#define M10 216 +#define M20 23 +#define M01 1322 +#define M11 13 +#define M21 27271 +#define M02 74 +#define M12 191 +#define M22 500 + +#define K00 405 +#define K10 112 +#define K01 4322 +#define K11 135 + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 3 / 32 + 4) +#else +#define N 16 +#endif + +void foo (int *__restrict__ pInput, int *__restrict__ pOutput, + int *__restrict__ pInput2, int *__restrict__ pOutput2) +{ + int i, a, b, c, d, e; + + for (i = 0; i < N / 3; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + + d = *pInput2++; + e = *pInput2++; + + *pOutput++ = M00 * a + M01 * b + M02 * c; + *pOutput++ = M10 * a + M11 * b + M12 * c; + *pOutput++ = M20 * a + M21 * b + M22 * c; + + /* Regular SLP - no permutation required. */ + *pOutput2++ = K00 * d; + *pOutput2++ = K10 * e; + } +} + +int main (int argc, const char* argv[]) +{ + int input[N], output[N], i; + int input2[N], output2[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i%256; + input2[i] = i%256; + output[i] = 0; + output2[i] = 0; + __asm__ volatile (""); + } + +#if N == 16 + int check_results[N] = { 1470, 395, 28271, 5958, 1655, 111653, 10446, 2915, + 195035, 14934, 4175, 278417, 19422, 5435, 361799, + 0 }; + int check_results2[N] = { 0, 112, 810, 336, 1620, 560, 2430, 784, 3240, 1008, + 0, 0, 0, 0, 0, 0 }; +#else + volatile int check_results[N] = {}; + volatile int check_results2[N] = {}; + + for (int i = 0; i < N / 3; i++) + { + int a = input[i * 3]; + int b = input[i * 3 + 1]; + int c = input[i * 3 + 2]; + int d = input2[i * 2]; + int e = input2[i * 2 + 1]; + + check_results[i * 3] = M00 * a + M01 * b + M02 * c; + check_results[i * 3 + 1] = M10 * a + M11 * b + M12 * c; + check_results[i * 3 + 2] = M20 * a + M21 * b + M22 * c; + + check_results2[i * 2] = K00 * d; + check_results2[i * 2 + 1] = K10 * e; + + asm volatile ("" ::: "memory"); + } +#endif + + foo (input, output, input2, output2); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (output[i] != check_results[i] || output2[i] != check_results2[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_perm3_int } } } */ +/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes xfail vect_perm3_int } } } */ +/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes xfail vect_perm3_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-7.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-7.c new file mode 100644 index 0000000000..df13c37bc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-7.c @@ -0,0 +1,104 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define M00 100 +#define M10 216 +#define M20 23 +#define M01 1322 +#define M11 13 +#define M21 27271 +#define M02 74 +#define M12 191 +#define M22 500 + +#define K00 405 +#define K10 112 +#define K01 4322 +#define K11 135 + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 3 / 32 + 4) +#else +#define N 16 +#endif + +/* SLP with load permutation and loop-based vectorization. */ +void foo (int *__restrict__ pInput, int *__restrict__ pOutput, + int *__restrict__ pInput2, int *__restrict__ pOutput2) +{ + int i, a, b, c, d; + + for (i = 0; i < N / 3; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + d = *pInput2++; + + *pOutput++ = M00 * a + M01 * b + M02 * c; + *pOutput++ = M10 * a + M11 * b + M12 * c; + *pOutput++ = M20 * a + M21 * b + M22 * c; + + /* Loop-based vectorization. */ + *pOutput2++ = K00 * d; + } +} + +int main (int argc, const char* argv[]) +{ + int input[N], output[N], i; + int input2[N], output2[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i%256; + input2[i] = i%256; + output[i] = 0; + output2[i] = 0; + asm volatile ("" ::: "memory"); + } + +#if N == 16 + int check_results[N] = {1470, 395, 28271, 5958, 1655, 111653, 10446, 2915, 195035, 14934, 4175, 278417, 19422, 5435, 361799, 0}; + int check_results2[N] = {0, 405, 810, 1215, 1620, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +#else + volatile int check_results[N] = {}; + volatile int check_results2[N] = {}; + + for (int i = 0; i < N / 3; i++) + { + int a = input[i * 3]; + int b = input[i * 3 + 1]; + int c = input[i * 3 + 2]; + int d = input2[i]; + + check_results[i * 3] = M00 * a + M01 * b + M02 * c; + check_results[i * 3 + 1] = M10 * a + M11 * b + M12 * c; + check_results[i * 3 + 2] = M20 * a + M21 * b + M22 * c; + + check_results2[i] = K00 * d; + + asm volatile ("" ::: "memory"); + } +#endif + + foo (input, output, input2, output2); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (output[i] != check_results[i] || output2[i] != check_results2[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_perm } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_int && { ! vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_int && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-8.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-8.c new file mode 100644 index 0000000000..029be5485b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-8.c @@ -0,0 +1,70 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 512 +#define N (VECTOR_BITS * 6 / 16) +#else +#define N 200 +#endif + +void __attribute__((noinline)) +foo (unsigned char *__restrict__ pInput, unsigned char *__restrict__ pOutput) +{ + unsigned char a, b, c; + unsigned int i; + + for (i = 0; i < N / 3; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + + *pOutput++ = a + b + c + 3; + *pOutput++ = a + b + c + 12; + *pOutput++ = a + b + c + 1; + } +} + +int main (int argc, const char* argv[]) +{ + unsigned char input[N], output[N]; + unsigned char check_results[N]; + unsigned int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i; + output[i] = 0; + __asm__ volatile (""); + } + + for (i = 0; i < N / 3; i++) + { + check_results[3*i] = 9 * i + 6; + check_results[3*i+1] = 9 * i + 15; + check_results[3*i+2] = 9 * i + 4; + __asm__ volatile ("" : : : "memory"); + } + + foo (input, output); + +#pragma GCC novector + for (i = 0; i < N - (N % 3); i++) + if (output[i] != check_results[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_perm_byte } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_byte && { { ! vect_load_lanes } && { { ! vect_partial_vectors_usage_1 } || s390_vx } } } } } } */ +/* The epilogues are vectorized using partial vectors. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { vect_perm3_byte && { { ! vect_load_lanes } && { vect_partial_vectors_usage_1 && { ! s390_vx } } } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "Built SLP cancelled: can use load/store-lanes" "vect" { target { vect_perm3_byte && vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump "LOAD_LANES" "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump "STORE_LANES" "vect" { target vect_load_lanes } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-perm-9.c b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-9.c new file mode 100644 index 0000000000..89400fb456 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-perm-9.c @@ -0,0 +1,64 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N (VECTOR_BITS * 6 / 16) + +void __attribute__((noinline)) +foo (unsigned short *__restrict__ pInput, unsigned short *__restrict__ pOutput) +{ + unsigned short i, a, b, c; + + for (i = 0; i < N / 3; i++) + { + a = *pInput++; + b = *pInput++; + c = *pInput++; + + *pOutput++ = a + b + c + 3; + *pOutput++ = a + b + c + 12; + *pOutput++ = a + b + c + 1; + } +} + +int main (int argc, const char* argv[]) +{ + unsigned short input[N], output[N], i; + unsigned short check_results[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + input[i] = i; + output[i] = 0; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N / 3; i++) + { + check_results[3*i] = 9 * i + 6; + check_results[3*i+1] = 9 * i + 15; + check_results[3*i+2] = 9 * i + 4; + __asm__ volatile ("" : : : "memory"); + } + + foo (input, output); + +#pragma GCC novector + for (i = 0; i < N - (N % 3); i++) + if (output[i] != check_results[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" { target { ! { { vect_perm_short || vect32 } || vect_load_lanes } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { vect_perm_short || vect32 } || vect_load_lanes } } } } */ +/* We don't try permutes with a group size of 3 for variable-length + vectors. */ +/* { dg-final { scan-tree-dump "permutation requires at least three vectors" "vect" { target { vect_perm_short && { ! vect_perm3_short } } xfail vect_variable_length } } } */ +/* { dg-final { scan-tree-dump-not "permutation requires at least three vectors" "vect" { target vect_perm3_short } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { { ! { vect_perm3_short || vect32 } } || vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { { vect_perm3_short || vect32 } && { ! vect_load_lanes } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-1.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-1.c new file mode 100644 index 0000000000..b9bddb8599 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-1.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned int uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Vectorization of reduction using loop-aware SLP. */ + +__attribute__ ((noinline)) +int main1 (int n, int res0, int res1, int res2, int res3) +{ + int i; + unsigned int udiff0 = 5, udiff1 = 10, udiff2 = 20, udiff3 = 30; + + for (i = 0; i < n; i++) { + udiff3 += (ub[4*i + 3] - uc[4*i + 3]); + udiff2 += (ub[4*i + 2] - uc[4*i + 2]); + udiff1 += (ub[4*i + 1] - uc[4*i + 1]); + udiff0 += (ub[4*i] - uc[4*i]); + } + + /* Check results: */ + if (udiff0 != res0 + || udiff1 != res1 + || udiff2 != res2 + || udiff3 != res3) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N/4, 53, 66, 84, 102); + main1 (N/4 - 1, 29, 40, 56, 72); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_add } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail vect_no_int_add } } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10a.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10a.c new file mode 100644 index 0000000000..d3c2c2d7f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10a.c @@ -0,0 +1,82 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fgimple" } */ + +int __GIMPLE (ssa,guessed_local(118111600),startwith("dce3")) +foo (int * x, int n) +{ + int i; + int sum; + int _1; + long unsigned int _2; + long unsigned int _3; + int * _4; + int _5; + __SIZETYPE__ _7; + __SIZETYPE__ _8; + int * _9; + int _10; + __SIZETYPE__ _11; + __SIZETYPE__ _12; + int * _13; + int _14; + __SIZETYPE__ _15; + __SIZETYPE__ _16; + int * _17; + int _18; + + __BB(2,guessed_local(118111600)): + if (n_21(D) > 0) + goto __BB5(guessed(119453778)); + else + goto __BB7(guessed(14763950)); + + __BB(5,guessed_local(105119324)): + goto __BB3(precise(134217728)); + + __BB(3,loop_header(1),guessed_local(955630224)): + sum_30 = __PHI (__BB5: 0, __BB6: sum_27); + i_32 = __PHI (__BB5: 0, __BB6: i_28); + _1 = i_32 * 4; + _2 = (long unsigned int) _1; + _3 = _2 * 4ul; + _4 = x_23(D) + _3; + _5 = __MEM (_4); + sum_24 = _5 + sum_30; + _7 = _2 + 1ul; + _8 = _7 * 4ul; + _9 = x_23(D) + _8; + _10 = __MEM (_9); + sum_25 = _10 + sum_24; + _11 = _2 + 2ul; + _12 = _11 * 4ul; + _13 = x_23(D) + _12; + _14 = __MEM (_13); + sum_26 = _14 + sum_25; + _15 = _2 + 3ul; + _16 = _15 * 4ul; + _17 = x_23(D) + _16; + _18 = __MEM (_17); + sum_27 = _18 + sum_26; + i_28 = i_32 + 1; + if (n_21(D) > i_28) + goto __BB6(guessed(119453778)); + else + goto __BB8(guessed(14763950)); + + __BB(8,guessed_local(105119324)): + goto __BB4(precise(134217728)); + + __BB(6,guessed_local(850510900)): + goto __BB3(precise(134217728)); + + __BB(7,guessed_local(12992276)): + goto __BB4(precise(134217728)); + + __BB(4,guessed_local(118111601)): + sum_31 = __PHI (__BB7: 0, __BB8: sum_27); + return sum_31; + +} + +/* { dg-final { scan-tree-dump "Decided to SLP 1 instances" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10b.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10b.c new file mode 100644 index 0000000000..6a0d55def3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10b.c @@ -0,0 +1,82 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fgimple" } */ + +int __GIMPLE (ssa,guessed_local(118111600),startwith("dce3")) +foo (int * x, int n) +{ + int i; + int sum; + int _1; + long unsigned int _2; + long unsigned int _3; + int * _4; + int _5; + __SIZETYPE__ _7; + __SIZETYPE__ _8; + int * _9; + int _100; + __SIZETYPE__ _11; + __SIZETYPE__ _12; + int * _13; + int _14; + __SIZETYPE__ _15; + __SIZETYPE__ _16; + int * _17; + int _18; + + __BB(2,guessed_local(118111600)): + if (n_21(D) > 0) + goto __BB5(guessed(119453778)); + else + goto __BB7(guessed(14763950)); + + __BB(5,guessed_local(105119324)): + goto __BB3(precise(134217728)); + + __BB(3,loop_header(1),guessed_local(955630224)): + sum_30 = __PHI (__BB5: 0, __BB6: sum_27); + i_32 = __PHI (__BB5: 0, __BB6: i_28); + _1 = i_32 * 4; + _2 = (long unsigned int) _1; + _3 = _2 * 4ul; + _4 = x_23(D) + _3; + _5 = __MEM (_4); + sum_24 = _5 + sum_30; + _7 = _2 + 1ul; + _8 = _7 * 4ul; + _9 = x_23(D) + _8; + _100 = __MEM (_9); + sum_25 = sum_24 + _100; + _11 = _2 + 2ul; + _12 = _11 * 4ul; + _13 = x_23(D) + _12; + _14 = __MEM (_13); + sum_26 = _14 + sum_25; + _15 = _2 + 3ul; + _16 = _15 * 4ul; + _17 = x_23(D) + _16; + _18 = __MEM (_17); + sum_27 = _18 + sum_26; + i_28 = i_32 + 1; + if (n_21(D) > i_28) + goto __BB6(guessed(119453778)); + else + goto __BB8(guessed(14763950)); + + __BB(8,guessed_local(105119324)): + goto __BB4(precise(134217728)); + + __BB(6,guessed_local(850510900)): + goto __BB3(precise(134217728)); + + __BB(7,guessed_local(12992276)): + goto __BB4(precise(134217728)); + + __BB(4,guessed_local(118111601)): + sum_31 = __PHI (__BB7: 0, __BB8: sum_27); + return sum_31; + +} + +/* { dg-final { scan-tree-dump "Decided to SLP 1 instances" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10c.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10c.c new file mode 100644 index 0000000000..20df262676 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10c.c @@ -0,0 +1,82 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fgimple" } */ + +int __GIMPLE (ssa,guessed_local(118111600),startwith("dce3")) +foo (int * x, int n) +{ + int i; + int sum; + int _1; + long unsigned int _2; + long unsigned int _3; + int * _4; + int _5; + __SIZETYPE__ _7; + __SIZETYPE__ _8; + int * _9; + int _10; + __SIZETYPE__ _11; + __SIZETYPE__ _12; + int * _13; + int _100; + __SIZETYPE__ _15; + __SIZETYPE__ _16; + int * _17; + int _18; + + __BB(2,guessed_local(118111600)): + if (n_21(D) > 0) + goto __BB5(guessed(119453778)); + else + goto __BB7(guessed(14763950)); + + __BB(5,guessed_local(105119324)): + goto __BB3(precise(134217728)); + + __BB(3,loop_header(1),guessed_local(955630224)): + sum_30 = __PHI (__BB5: 0, __BB6: sum_27); + i_32 = __PHI (__BB5: 0, __BB6: i_28); + _1 = i_32 * 4; + _2 = (long unsigned int) _1; + _3 = _2 * 4ul; + _4 = x_23(D) + _3; + _5 = __MEM (_4); + sum_24 = _5 + sum_30; + _7 = _2 + 1ul; + _8 = _7 * 4ul; + _9 = x_23(D) + _8; + _10 = __MEM (_9); + sum_25 = _10 + sum_24; + _11 = _2 + 2ul; + _12 = _11 * 4ul; + _13 = x_23(D) + _12; + _100 = __MEM (_13); + sum_26 = sum_25 + _100; + _15 = _2 + 3ul; + _16 = _15 * 4ul; + _17 = x_23(D) + _16; + _18 = __MEM (_17); + sum_27 = _18 + sum_26; + i_28 = i_32 + 1; + if (n_21(D) > i_28) + goto __BB6(guessed(119453778)); + else + goto __BB8(guessed(14763950)); + + __BB(8,guessed_local(105119324)): + goto __BB4(precise(134217728)); + + __BB(6,guessed_local(850510900)): + goto __BB3(precise(134217728)); + + __BB(7,guessed_local(12992276)): + goto __BB4(precise(134217728)); + + __BB(4,guessed_local(118111601)): + sum_31 = __PHI (__BB7: 0, __BB8: sum_27); + return sum_31; + +} + +/* { dg-final { scan-tree-dump "Decided to SLP 1 instances" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10d.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10d.c new file mode 100644 index 0000000000..8a512d5c14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10d.c @@ -0,0 +1,82 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fgimple" } */ + +int __GIMPLE (ssa,guessed_local(118111600),startwith("dce3")) +foo (int * x, int n) +{ + int i; + int sum; + int _1; + long unsigned int _2; + long unsigned int _3; + int * _4; + int _5; + __SIZETYPE__ _7; + __SIZETYPE__ _8; + int * _9; + int _10; + __SIZETYPE__ _11; + __SIZETYPE__ _12; + int * _13; + int _14; + __SIZETYPE__ _15; + __SIZETYPE__ _16; + int * _17; + int _100; + + __BB(2,guessed_local(118111600)): + if (n_21(D) > 0) + goto __BB5(guessed(119453778)); + else + goto __BB7(guessed(14763950)); + + __BB(5,guessed_local(105119324)): + goto __BB3(precise(134217728)); + + __BB(3,loop_header(1),guessed_local(955630224)): + sum_30 = __PHI (__BB5: 0, __BB6: sum_27); + i_32 = __PHI (__BB5: 0, __BB6: i_28); + _1 = i_32 * 4; + _2 = (long unsigned int) _1; + _3 = _2 * 4ul; + _4 = x_23(D) + _3; + _5 = __MEM (_4); + sum_24 = _5 + sum_30; + _7 = _2 + 1ul; + _8 = _7 * 4ul; + _9 = x_23(D) + _8; + _10 = __MEM (_9); + sum_25 = _10 + sum_24; + _11 = _2 + 2ul; + _12 = _11 * 4ul; + _13 = x_23(D) + _12; + _14 = __MEM (_13); + sum_26 = _14 + sum_25; + _15 = _2 + 3ul; + _16 = _15 * 4ul; + _17 = x_23(D) + _16; + _100 = __MEM (_17); + sum_27 = sum_26 + _100; + i_28 = i_32 + 1; + if (n_21(D) > i_28) + goto __BB6(guessed(119453778)); + else + goto __BB8(guessed(14763950)); + + __BB(8,guessed_local(105119324)): + goto __BB4(precise(134217728)); + + __BB(6,guessed_local(850510900)): + goto __BB3(precise(134217728)); + + __BB(7,guessed_local(12992276)): + goto __BB4(precise(134217728)); + + __BB(4,guessed_local(118111601)): + sum_31 = __PHI (__BB7: 0, __BB8: sum_27); + return sum_31; + +} + +/* { dg-final { scan-tree-dump "Decided to SLP 1 instances" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10e.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10e.c new file mode 100644 index 0000000000..268ec9db77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-10e.c @@ -0,0 +1,82 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fgimple" } */ + +int __GIMPLE (ssa,guessed_local(118111600),startwith("dce3")) +foo (int * x, int n) +{ + int i; + int sum; + int _1; + long unsigned int _2; + long unsigned int _3; + int * _4; + int _100; + __SIZETYPE__ _7; + __SIZETYPE__ _8; + int * _9; + int _10; + __SIZETYPE__ _11; + __SIZETYPE__ _12; + int * _13; + int _14; + __SIZETYPE__ _15; + __SIZETYPE__ _16; + int * _17; + int _18; + + __BB(2,guessed_local(118111600)): + if (n_21(D) > 0) + goto __BB5(guessed(119453778)); + else + goto __BB7(guessed(14763950)); + + __BB(5,guessed_local(105119324)): + goto __BB3(precise(134217728)); + + __BB(3,loop_header(1),guessed_local(955630224)): + sum_30 = __PHI (__BB5: 0, __BB6: sum_27); + i_32 = __PHI (__BB5: 0, __BB6: i_28); + _1 = i_32 * 4; + _2 = (long unsigned int) _1; + _3 = _2 * 4ul; + _4 = x_23(D) + _3; + _100 = __MEM (_4); + sum_24 = sum_30 + _100; + _7 = _2 + 1ul; + _8 = _7 * 4ul; + _9 = x_23(D) + _8; + _10 = __MEM (_9); + sum_25 = _10 + sum_24; + _11 = _2 + 2ul; + _12 = _11 * 4ul; + _13 = x_23(D) + _12; + _14 = __MEM (_13); + sum_26 = _14 + sum_25; + _15 = _2 + 3ul; + _16 = _15 * 4ul; + _17 = x_23(D) + _16; + _18 = __MEM (_17); + sum_27 = _18 + sum_26; + i_28 = i_32 + 1; + if (n_21(D) > i_28) + goto __BB6(guessed(119453778)); + else + goto __BB8(guessed(14763950)); + + __BB(8,guessed_local(105119324)): + goto __BB4(precise(134217728)); + + __BB(6,guessed_local(850510900)): + goto __BB3(precise(134217728)); + + __BB(7,guessed_local(12992276)): + goto __BB4(precise(134217728)); + + __BB(4,guessed_local(118111601)): + sum_31 = __PHI (__BB7: 0, __BB8: sum_27); + return sum_31; + +} + +/* { dg-final { scan-tree-dump "Decided to SLP 1 instances" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-11.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-11.c new file mode 100644 index 0000000000..260d65cd49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-11.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double dotprod(const double *a, const double *b, unsigned long long n) +{ + double d1 = 0.0; + double d2 = 0.0; + + for (unsigned long long i = 0; i < n; i += 2) { + d1 += a[i] * b[i]; + d2 += a[i + 1] * b[i + 1]; + } + + return (d1 + d2); +} + +/* We should use a SLP reduction even without -ffast-math by using a + VF of one. */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { xfail vect_variable_length } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-2.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-2.c new file mode 100644 index 0000000000..aa09d01975 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-2.c @@ -0,0 +1,45 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned int uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Vectorization of reduction using loop-aware SLP (with unrolling). */ + +__attribute__ ((noinline)) +int main1 (int n, int res0, int res1, int res2, int res3) +{ + int i; + unsigned int udiff0 = 5, udiff1 = 10; + + for (i = 0; i < n; i++) { + udiff1 += (ub[2*i + 1] - uc[2*i + 1]); + udiff0 += (ub[2*i] - uc[2*i]); + } + + /* Check results: */ + if (udiff0 != res0 + || udiff1 != res1) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N/2, 117, 138, 84, 102); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_add } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail vect_no_int_add } } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-3.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-3.c new file mode 100644 index 0000000000..9e29757717 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-3.c @@ -0,0 +1,65 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param=vect-epilogues-nomask=0" } */ + +#include +#include "tree-vect.h" + +#define N 64 + +#define DOT1 21834 +#define DOT2 21876 + +unsigned short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* short->short->int dot product. + Not detected as a dot-product pattern. + Requires support for non-widneing multiplication and widening-summation. + Vectorized with loop-aware SLP. */ +__attribute__ ((noinline)) unsigned int +foo1(int len, int *result1, int *result2) +{ + int i; + unsigned int res1 = 10, res2 = 20; + unsigned short prod; + + for (i=0; i +#include "tree-vect.h" + +#define N 128 + +unsigned int uc[N]; + +/* Vectorization of reduction using loop-aware SLP. */ + +__attribute__ ((noinline)) +int main1 (int n, int res0, int res1, int res2, int res3, int res4, int res5, int res6, int res7) +{ + int i; + unsigned int max0 = 5, max1 = 10, max2 = 20, max3 = 30, max4 = 2, max5 = 13, max6 = 7, max7 = 313; + + for (i = 0; i < n; i++) { + max2 = max2 < uc[8*i+2] ? uc[8*i+2] : max2; + max3 = max3 < uc[8*i+3] ? uc[8*i+3] : max3; + max1 = max1 < uc[8*i+1] ? uc[8*i+1] : max1; + max7 = max7 < uc[8*i+7] ? uc[8*i+7] : max7; + max6 = max6 < uc[8*i+6] ? uc[8*i+6] : max6; + max0 = max0 < uc[8*i] ? uc[8*i] : max0; + max4 = max4 < uc[8*i+4] ? uc[8*i+4] : max4; + max5 = max5 < uc[8*i+5] ? uc[8*i+5] : max5; + } + + /* Check results: */ + if (max0 != res0 + || max1 != res1 + || max2 != res2 + || max3 != res3 + || max4 != res4 + || max5 != res5 + || max6 != res6 + || max7 != res7) + abort (); + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + uc[i] = i+3; + __asm__ volatile (""); + } + + main1 (N/8, 123, 124, 125, 126, 127, 128, 129, 313); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ +/* For variable-length SVE, the number of scalar statements in the + reduction exceeds the number of elements in a 128-bit granule. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! vect_multiple_sizes } xfail { vect_no_int_min_max || { aarch64_sve && vect_variable_length } } } } } */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { target { vect_multiple_sizes && { ! { vect_load_lanes && vect_strided8 } } } } } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" { xfail { aarch64_sve && vect_variable_length } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-5.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-5.c new file mode 100644 index 0000000000..11f5a7414c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-5.c @@ -0,0 +1,49 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int c[N]; + +/* Vectorization of reduction using loop-aware SLP. */ + +__attribute__ ((noinline)) +int main1 (int n, int res0, int res1) +{ + int i; + int max0 = -100, max1 = -313; + + for (i = 0; i < n; i++) { + max1 = max1 < c[2*i+1] ? c[2*i+1] : max1; + max0 = max0 < c[2*i] ? c[2*i] : max0; + } + + /* Check results: */ + if (max0 != res0 + || max1 != res1) + abort (); + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + c[i] = (i+3) * -1; + + c[0] = c[1] = -100; + main1 (N/2, -5, -6); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail vect_no_int_min_max } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail vect_no_int_min_max } } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-6.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-6.c new file mode 100644 index 0000000000..1fd15aa3c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-6.c @@ -0,0 +1,50 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int a[N], b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* Vectorization of reduction. Loop-aware SLP is not possible, because of + different arrays. */ + +__attribute__ ((noinline)) +int main1 (int n, int res0, int res1) +{ + int i; + int sum0 = 0, sum1 = 0; + + for (i = 0; i < n; i++) { + sum1 += a[2*i]; + sum0 += b[2*i]; + } + + /* Check results: */ + if (sum0 != res0 + || sum1 != res1) + abort (); + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + a[i] = b[i] = i; + + main1 (N/2, 4032, 4032); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail { vect_no_int_add || { ! { vect_unpack || vect_strided2 } } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "different interleaving chains in one node" 1 "vect" { target { ! vect_no_int_add } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-7.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-7.c new file mode 100644 index 0000000000..8b52635f09 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-7.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +unsigned int ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned int uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Vectorization of reduction using loop-aware SLP (with two copies). */ + +__attribute__ ((noinline)) +int main1 (int n, int res0, int res1, int res2, int res3, + int res4, int res5, int res6, int res7) +{ + int i; + unsigned int udiff0 = 5, udiff1 = 10, udiff2 = 20, udiff3 = 30; + unsigned int udiff4 = 45, udiff5 = 50, udiff6 = 60, udiff7 = 70; + + for (i = 0; i < n; i++) { + udiff7 += (ub[8*i + 7] - uc[8*i + 7]); + udiff6 += (ub[8*i + 6] - uc[8*i + 6]); + udiff5 += (ub[8*i + 5] - uc[8*i + 5]); + udiff4 += (ub[8*i + 4] - uc[8*i + 4]); + udiff3 += (ub[8*i + 3] - uc[8*i + 3]); + udiff2 += (ub[8*i + 2] - uc[8*i + 2]); + udiff1 += (ub[8*i + 1] - uc[8*i + 1]); + udiff0 += (ub[8*i] - uc[8*i]); + } + + /* Check results: */ + if (udiff0 != res0 + || udiff1 != res1 + || udiff2 != res2 + || udiff3 != res3 + || udiff4 != res4 + || udiff5 != res5 + || udiff6 != res6 + || udiff7 != res7) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N/8, 37, 50, 68, 86, 109, 122, 140, 158); + main1 (N/8 - 1, 21, 32, 48, 64, 85, 96, 112, 128); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_add } } } */ +/* For variable-length SVE, the number of scalar statements in the + reduction exceeds the number of elements in a 128-bit granule. */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail { vect_no_int_add || { { aarch64_sve && vect_variable_length } || { riscv_v && vect_variable_length } } } } } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" { xfail { aarch64_sve && vect_variable_length } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-8.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-8.c new file mode 100644 index 0000000000..618c800e57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-8.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +static int a[512], b[512]; + +void __attribute__((noinline,noclone)) +foo (int *sum1p, int *sum2p, int *sum3p) +{ + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + /* Check that we vectorize a reduction chain and a SLP reduction + at the same time. */ + for (int i = 0; i < 256; ++i) + { + sum1 += a[2*i]; + sum1 += a[2*i + 1]; + sum2 += b[2*i]; + sum3 += b[2*i + 1]; + } + *sum1p = sum1; + *sum2p = sum2; + *sum3p = sum3; +} + +int main() +{ + check_vect (); + + for (int i = 0; i < 256; ++i) + { + a[2*i] = i; + a[2*i + 1] = i/2; + b[2*i] = i + 1; + b[2*i + 1] = i/2 + 1; + __asm__ volatile ("" : : : "memory"); + } + int sum1, sum2, sum3; + foo (&sum1, &sum2, &sum3); + if (sum1 != 48896 || sum2 != 32896 || sum3 != 16512) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-9.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-9.c new file mode 100644 index 0000000000..bee642ee99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-9.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int_mult } */ + +int +bar (int *x, int a, int b, int n) +{ + x = __builtin_assume_aligned (x, __BIGGEST_ALIGNMENT__); + int sum1 = 0; + int sum2 = 0; + for (int i = 0; i < n; ++i) + { + /* Reduction chain vectorization fails here because of the + different operations but we can still vectorize both + reductions as SLP reductions, saving IVs. */ + sum1 += x[2*i] - a; + sum1 += x[2*i+1] * b; + sum2 += x[2*i] - b; + sum2 += x[2*i+1] * a; + } + return sum1 + sum2; +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-sad-2.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-sad-2.c new file mode 100644 index 0000000000..7d9255e48f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-sad-2.c @@ -0,0 +1,31 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_usad_char } */ +/* With AVX256 or more we do not pull off the trick eliding the epilogue. */ +/* { dg-additional-options "-mprefer-avx128" { target { x86_64-*-* i?86-*-* } } } */ + +typedef unsigned char uint8_t; +int x264_pixel_sad_8x8( uint8_t *pix1, uint8_t *pix2, int i_stride_pix2 ) +{ + int i_sum = 0; + for( int y = 0; y < 8; y++ ) + { + i_sum += __builtin_abs( pix1[0] - pix2[0] ); + i_sum += __builtin_abs( pix1[1] - pix2[1] ); + i_sum += __builtin_abs( pix1[2] - pix2[2] ); + i_sum += __builtin_abs( pix1[3] - pix2[3] ); + i_sum += __builtin_abs( pix1[4] - pix2[4] ); + i_sum += __builtin_abs( pix1[5] - pix2[5] ); + i_sum += __builtin_abs( pix1[6] - pix2[6] ); + i_sum += __builtin_abs( pix1[7] - pix2[7] ); + pix1 += 16; + pix2 += i_stride_pix2; + } + return i_sum; +} + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ +/* { dg-final { scan-tree-dump-not "access with gaps requires scalar epilogue loop" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-sad.c b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-sad.c new file mode 100644 index 0000000000..977cfabde1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-reduc-sad.c @@ -0,0 +1,62 @@ +/* { dg-require-effective-target vect_usad_char } */ + +#include "tree-vect.h" + +typedef unsigned short uint16_t; +typedef unsigned char uint8_t; + +extern int abs (int); +extern void abort (void); + +int __attribute__((noinline,noclone)) +foo (uint8_t *pix1, uint8_t *pix2, int i_stride_pix2) +{ + int i_sum = 5; + for( int y = 0; y < 16; y++ ) + { + i_sum += abs ( pix1[0] - pix2[0] ); + i_sum += abs ( pix1[1] - pix2[1] ); + i_sum += abs ( pix1[2] - pix2[2] ); + i_sum += abs ( pix1[3] - pix2[3] ); + i_sum += abs ( pix1[4] - pix2[4] ); + i_sum += abs ( pix1[5] - pix2[5] ); + i_sum += abs ( pix1[6] - pix2[6] ); + i_sum += abs ( pix1[7] - pix2[7] ); + i_sum += abs ( pix1[8] - pix2[8] ); + i_sum += abs ( pix1[9] - pix2[9] ); + i_sum += abs ( pix1[10] - pix2[10] ); + i_sum += abs ( pix1[11] - pix2[11] ); + i_sum += abs ( pix1[12] - pix2[12] ); + i_sum += abs ( pix1[13] - pix2[13] ); + i_sum += abs ( pix1[14] - pix2[14] ); + i_sum += abs ( pix1[15] - pix2[15] ); + pix1 += 16; + pix2 += i_stride_pix2; + } + return i_sum; +} + +int +main () +{ + check_vect (); + + uint8_t X[16*16]; + uint8_t Y[16*16]; + + for (int i = 0; i < 16*16; ++i) + { + X[i] = i; + Y[i] = 16*16 - i; + __asm__ volatile (""); + } + + if (foo (X, Y, 16) != 32512 + 5) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-simd-clone-1.c b/SingleSource/Regression/C/gcc-dg/vect/slp-simd-clone-1.c new file mode 100644 index 0000000000..6ccbb39b56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-simd-clone-1.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#include "tree-vect.h" + +int x[1024]; + +#pragma omp declare simd simdlen(4) notinbranch +__attribute__((noinline)) int +foo (int a, int b) +{ + return a + b; +} + +void __attribute__((noipa)) +bar (void) +{ +#pragma omp simd + for (int i = 0; i < 512; i++) + { + x[2*i+0] = foo (x[2*i+0], x[2*i+0]); + x[2*i+1] = foo (x[2*i+1], x[2*i+1]); + } +} + +int +main () +{ + int i; + check_vect (); + +#pragma GCC novector + for (i = 0; i < 1024; i++) + x[i] = i; + + bar (); + +#pragma GCC novector + for (i = 0; i < 1024; i++) + if (x[i] != i + i) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-simd-clone-2.c b/SingleSource/Regression/C/gcc-dg/vect/slp-simd-clone-2.c new file mode 100644 index 0000000000..98387c9248 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-simd-clone-2.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx2" { target avx2_runtime } } */ + +#include "tree-vect.h" + +int x[1024]; + +#pragma omp declare simd simdlen(4) inbranch +__attribute__((noinline)) int +foo (int a, int b) +{ + return a + b; +} + +void __attribute__((noipa)) +bar (void) +{ +#pragma omp simd + for (int i = 0; i < 512; i++) + { + if (x[2*i+0] < 10) + x[2*i+0] = foo (x[2*i+0], x[2*i+0]); + if (x[2*i+1] < 20) + x[2*i+1] = foo (x[2*i+1], x[2*i+1]); + } +} + +int +main () +{ + int i; + check_vect (); + +#pragma GCC novector + for (i = 0; i < 1024; i++) + x[i] = i; + + bar (); + +#pragma GCC novector + for (i = 0; i < 1024; i++) + { + if (((i & 1) && i < 20) + || (!(i & 1) && i < 10)) + { + if (x[i] != i + i) + abort (); + } + else if (x[i] != i) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" { target avx2_runtime } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-widen-mult-half.c b/SingleSource/Regression/C/gcc-dg/vect/slp-widen-mult-half.c new file mode 100644 index 0000000000..72811eb852 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-widen-mult-half.c @@ -0,0 +1,55 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 32 +#define COEF 32470 +#define COEF2 324700 + +unsigned char in[N]; +int out[N]; +int out2[N]; + +__attribute__ ((noinline)) void +foo () +{ + int i; + + for (i = 0; i < N/2; i++) + { + out[2*i] = in[2*i] * COEF; + out2[2*i] = in[2*i] + COEF2; + out[2*i+1] = in[2*i+1] * COEF; + out2[2*i+1] = in[2*i+1] + COEF2; + } +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + __asm__ volatile (""); + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (out[i] != in[i] * COEF || out2[i] != in[i] + COEF2) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_mult_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_widen_mult_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ +/* { dg-final { scan-tree-dump-times "pattern recognized" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/slp-widen-mult-s16.c b/SingleSource/Regression/C/gcc-dg/vect/slp-widen-mult-s16.c new file mode 100644 index 0000000000..f8ec1fa730 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/slp-widen-mult-s16.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; + +int result[N]; + +/* short->int widening-mult */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; + +unsigned short result[N]; + +/* char->short widening-mult */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +int main1 (int x, int max_result) +{ + int i; + int b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + int diff = 2; + int max = x; + int min = 10; + + for (i = 0; i < N; i++) { + diff += (b[i] - c[i]); + } + + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != 0) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100); + main1 (0, 15); + return 0; +} + +/* We can't handle the first loop with variable-length vectors and so + fall back to the fixed-length mininum instead. */ +/* { dg-final { scan-tree-dump-times "Detected reduction\\." 3 "vect" { target { ! vect_multiple_sizes } xfail vect_variable_length } } } */ +/* { dg-final { scan-tree-dump "Detected reduction\\." "vect" { target vect_multiple_sizes } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! vect_no_int_min_max } } } } */ +/* { dg-final { scan-tree-dump-times {using an in-order \(fold-left\) reduction} 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tree-vect.h b/SingleSource/Regression/C/gcc-dg/vect/tree-vect.h new file mode 100644 index 0000000000..c4b8144121 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tree-vect.h @@ -0,0 +1,93 @@ +/* Check if system supports SIMD */ +#include + +#if defined(__i386__) || defined(__x86_64__) +# include "cpuid.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern void abort (void); +extern void exit (int); +#ifdef __cplusplus +} +#endif + +static void +sig_ill_handler (int sig) +{ + exit(0); +} + +static void __attribute__((noinline)) +check_vect (void) +{ + signal(SIGILL, sig_ill_handler); +#if defined(__PAIRED__) + /* 750CL paired-single instruction, 'ps_mul %v0,%v0,%v0'. */ + asm volatile (".long 0x10000032"); +#elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__) || defined(powerpc) + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); +#elif defined(__i386__) || defined(__x86_64__) + { + unsigned int a, b, c, d, + want_level, want_b = 0, want_c = 0, want_d = 0; + + /* Determine what instruction set we've been compiled for, and detect + that we're running with it. This allows us to at least do a compile + check for, e.g. SSE4.1 when the machine only supports SSE2. */ +# if defined(__AVX2__) + want_level = 7, want_b = bit_AVX2; +# elif defined(__AVX__) + want_level = 1, want_c = bit_AVX; +# elif defined(__SSE4_2__) + want_level = 1, want_c = bit_SSE4_2; +# elif defined(__SSE4_1__) + want_level = 1, want_c = bit_SSE4_1; +# elif defined(__SSSE3__) + want_level = 1, want_c = bit_SSSE3; +# else + want_level = 1, want_d = bit_SSE2; +# endif + + if (!__get_cpuid_count (want_level, 0, &a, &b, &c, &d) + || ((b & want_b) | (c & want_c) | (d & want_d)) == 0) + exit (0); + } +#elif defined(__sparc__) + asm volatile (".word\t0x81b007c0"); +#elif defined(__arm__) + { + /* On some processors without NEON support, this instruction may + be a no-op, on others it may trap, so check that it executes + correctly. */ + long long a = 0, b = 1; + asm ("vorr %P0, %P1, %P2" + : "=w" (a) + : "0" (a), "w" (b)); + if (a != 1) + exit (0); + } +#elif defined(__mips_msa) + asm volatile ("or.v $w0,$w0,$w0"); +#endif + signal (SIGILL, SIG_DFL); +} + +#if defined (__ARM_FEATURE_SVE) +# if __ARM_FEATURE_SVE_BITS == 0 +# define VECTOR_BITS 1024 +# else +# define VECTOR_BITS __ARM_FEATURE_SVE_BITS +# endif +#else +# define VECTOR_BITS 128 +#endif + +/* Which most of our tests are going to #define for internal use, and + which might be exposed by system headers related to signal.h on some + targets, notably VxWorks. */ +#undef OFFSET + diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/license.txt b/SingleSource/Regression/C/gcc-dg/vect/tsvc/license.txt new file mode 100644 index 0000000000..e16b36cb15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/license.txt @@ -0,0 +1,29 @@ +Copyright (c) 2011 University of Illinois at Urbana-Champaign. All rights reserved. + +Developed by: Polaris Research Group + University of Illinois at Urbana-Champaign + http://polaris.cs.uiuc.edu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal with the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + 3. Neither the names of Polaris Research Group, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to endorse + or promote products derived from this Software without specific prior + written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +WITH THE SOFTWARE. diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/tsvc.h b/SingleSource/Regression/C/gcc-dg/vect/tsvc/tsvc.h new file mode 100644 index 0000000000..d910c384fc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/tsvc.h @@ -0,0 +1,1439 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +#define iterations 10000 +#define LEN_1D 32000 +#define LEN_2D 256 +#define ARRAY_ALIGNMENT 64 + +#pragma GCC push_options +#pragma GCC optimize "-fno-tree-vectorize" + +#include +#include +#if __has_include() +#include +#endif +#if __has_include() +#include +#endif +#include +#include + +typedef float real_t; +#define ABS fabsf + +int dummy(real_t[LEN_1D], real_t[LEN_1D], real_t[LEN_1D], real_t[LEN_1D], + real_t[LEN_1D], real_t[LEN_2D][LEN_2D], real_t[LEN_2D][LEN_2D], + real_t[LEN_2D][LEN_2D], real_t); + +__attribute__((aligned(ARRAY_ALIGNMENT))) +real_t flat_2d_array[LEN_2D * LEN_2D]; +__attribute__((aligned(ARRAY_ALIGNMENT))) real_t x[LEN_1D]; +__attribute__((aligned(ARRAY_ALIGNMENT))) real_t a[LEN_1D], b[LEN_1D], + c[LEN_1D], d[LEN_1D], e[LEN_1D], aa[LEN_2D][LEN_2D], bb[LEN_2D][LEN_2D], + cc[LEN_2D][LEN_2D], tt[LEN_2D][LEN_2D]; +__attribute__((aligned(ARRAY_ALIGNMENT))) int indx[LEN_1D]; + +real_t* __restrict__ xx; +real_t* yy; + +void set_1d_array(real_t * arr, int length, real_t value, int stride); +void set_2d_array(real_t arr[LEN_2D][LEN_2D], real_t value, int stride); + +struct args_t { + struct timeval t1; + struct timeval t2; + void * __restrict__ arg_info; +}; + +enum {SET1D_RECIP_IDX = -1, SET1D_RECIP_IDX_SQ = -2}; + +real_t sum1d(real_t arr[LEN_1D]); +real_t sum2d(real_t arr[LEN_2D][LEN_2D]); + +real_t sum_x(); +real_t sum_a(); +real_t sum_b(); +real_t sum_c(); +real_t sum_e(); + +real_t sum_half_xx(); + +real_t sum_a_aa(); + +real_t sum_aa(); +real_t sum_bb(); +real_t sum_cc(); +real_t sum_xx(); + +real_t sum_aa_bb(); + +real_t sum_flat_2d_array(); + +real_t sum1d(real_t arr[LEN_1D]){ + real_t ret = 0.; + for (int i = 0; i < LEN_1D; i++) + ret += arr[i]; + return ret; +} + +real_t sum2d(real_t arr[LEN_2D][LEN_2D]){ + real_t sum = 0.; + for (int i = 0; i < LEN_2D; i++){ + for (int j = 0; j < LEN_2D; j++){ + sum += arr[i][j]; + } + } + + return sum; +} + +real_t sum_x() +{ + return sum1d(x); +} + +real_t sum_xx() +{ + return sum1d(xx); +} + +real_t sum_a() +{ + return sum1d(a); +} + +real_t sum_b() +{ + return sum1d(b); +} + +real_t sum_a_aa() +{ + return sum1d(a) + sum2d(aa); +} + +real_t sum_c() +{ + return sum1d(c); +} + +real_t sum_e() +{ + return sum1d(e); +} + +real_t sum_aa() +{ + return sum2d(aa); +} + +real_t sum_bb() +{ + return sum2d(bb); +} + +real_t sum_aa_bb() +{ + return sum2d(aa) + sum2d(bb); +} + +real_t sum_cc() +{ + return sum2d(cc); +} + +real_t sum_half_xx() +{ + real_t temp = 00; + + for (int i = 0; i < LEN_1D/2; i++){ + temp += xx[i]; + } + + return temp; +} + +real_t sum_flat_2d_array() +{ + real_t sum = 0.; + + for (int i = 0; i < LEN_2D*LEN_2D; i++){ + sum += flat_2d_array[i]; + } + + return sum; +} + + +void set_1d_array(real_t * arr, int length, real_t value, int stride) +{ + if (stride == SET1D_RECIP_IDX) { + for (int i = 0; i < length; i++) { + arr[i] = 1. / (real_t) (i+1); + } + } else if (stride == SET1D_RECIP_IDX_SQ) { + for (int i = 0; i < length; i++) { + arr[i] = 1. / (real_t) ((i+1) * (i+1)); + } + } else { + for (int i = 0; i < length; i += stride) { + arr[i] = value; + } + } +} + +void set_2d_array(real_t arr[LEN_2D][LEN_2D], real_t value, int stride) +{ + for (int i = 0; i < LEN_2D; i++) { + set_1d_array(arr[i], LEN_2D, value, stride); + } +} + +void init(int** ip, real_t* s1, real_t* s2){ +#if !defined (__APPLE__) && !defined (_AIX) && !defined(__DragonFly__) + xx = (real_t*) memalign(ARRAY_ALIGNMENT, LEN_1D*sizeof(real_t)); + *ip = (int *) memalign(ARRAY_ALIGNMENT, LEN_1D*sizeof(real_t)); +#else +# if defined (__APPLE__) \ + && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060 + /* We have no aligned allocator, but malloc is guaranteed to return + alignment suitable for the largest vector item. */ + xx = (real_t*) malloc (LEN_1D*sizeof(real_t)); + *ip = (int *) malloc (LEN_1D*sizeof(real_t)); +# else + posix_memalign ((void*)&xx, ARRAY_ALIGNMENT, LEN_1D*sizeof(real_t)); + posix_memalign ((void*)ip, ARRAY_ALIGNMENT, LEN_1D*sizeof(real_t)); +# endif +#endif + + for (int i = 0; i < LEN_1D; i = i+5){ + (*ip)[i] = (i+4); + (*ip)[i+1] = (i+2); + (*ip)[i+2] = (i); + (*ip)[i+3] = (i+3); + (*ip)[i+4] = (i+1); + } + + set_1d_array(a, LEN_1D, 1.,1); + set_1d_array(b, LEN_1D, 1.,1); + set_1d_array(c, LEN_1D, 1.,1); + set_1d_array(d, LEN_1D, 1.,1); + set_1d_array(e, LEN_1D, 1.,1); + set_1d_array(x, LEN_1D, 1.,1); + set_2d_array(aa, 0.,SET1D_RECIP_IDX); + set_2d_array(bb, 0.,SET1D_RECIP_IDX); + set_2d_array(cc, 0.,SET1D_RECIP_IDX); + + for (int i = 0; i < LEN_1D; i++) { + indx[i] = (i+1) % 4+1; + } + + *s1 = 1.0; + *s2 = 2.0; +} + +int initialise_arrays(const char* name) +{ + real_t any=0.; + real_t zero=0.; + real_t half=.5; + real_t one=1.; + real_t two=2.; + real_t small = .000001; + int unit =1; + int frac = SET1D_RECIP_IDX; + int frac2 = SET1D_RECIP_IDX_SQ; + + if (!strcmp(name, "s000")) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = 1+i; + b[i] = 2+i; + c[i] = 3+i; + d[i] = 4+i; + e[i] = 5+i; + } + } else if (!strcmp(name, "s111")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + set_1d_array(c, LEN_1D, any,frac2); + set_1d_array(d, LEN_1D, any,frac2); + set_1d_array(e, LEN_1D, any,frac2); + } else if (!strcmp(name, "s112")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s113")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s114")) { + set_2d_array(aa, any,frac); + set_2d_array(bb, any,frac2); + } else if (!strcmp(name, "s115")) { + set_1d_array(a, LEN_1D, one,unit); + set_2d_array(aa,small,unit); + set_2d_array(bb,small,unit); + set_2d_array(cc,small,unit); + } else if (!strcmp(name, "s116")) { + set_1d_array(a, LEN_1D, one,unit); + } else if (!strcmp(name, "s118")) { + set_1d_array(a, LEN_1D, one,unit); + set_2d_array(bb,small,unit); + } else if (!strcmp(name, "s119")) { + set_2d_array(aa, one,unit); + set_2d_array(bb, any,frac2); + } else if (!strcmp(name, "s121")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s122")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s123")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s124")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s125")) { + set_1d_array(flat_2d_array, LEN_2D*LEN_2D,zero,unit); + set_2d_array(aa, one,unit); + set_2d_array(bb,half,unit); + set_2d_array(cc, two,unit); + } else if (!strcmp(name, "s126")) { + set_2d_array(bb, one,unit); + set_1d_array( flat_2d_array, LEN_2D*LEN_2D,any,frac); + set_2d_array(cc, any,frac); + } else if (!strcmp(name, "s127")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s128")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, two,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, one,unit); + } else if (!strcmp(name, "s131")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s132")) { + set_2d_array(aa, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s141")) { + set_1d_array( flat_2d_array, LEN_2D*LEN_2D, one,unit); + set_2d_array(bb, any,frac2); + } else if (!strcmp(name, "s151")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s152")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D,zero,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s161")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array( &b[0], LEN_1D/2, one,2); + set_1d_array( &b[1], LEN_1D/2,-one,2); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s162")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s171")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s172")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s173")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s174")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s175")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s176")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s211")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s212")) { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, any,frac); + } else if (!strcmp(name, "s221")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + } else if (!strcmp(name, "s222")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + } else if (!strcmp(name, "s231")) { + set_2d_array(aa, one,unit); + set_2d_array(bb, any,frac2); + } else if (!strcmp(name, "s232")) { + set_2d_array(aa, one,unit); + set_2d_array(bb,zero,unit); + } else if (!strcmp(name, "s233")) { + set_2d_array(aa, any,frac); + set_2d_array(bb, any,frac); + set_2d_array(cc, any,frac); + } else if (!strcmp(name, "s234")) { + set_2d_array(aa, one,unit); + set_2d_array(bb, any,frac); + set_2d_array(cc, any,frac); + } else if (!strcmp(name, "s235")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + set_2d_array(aa, one,unit); + set_2d_array(bb, any, frac2); + } else if (!strcmp(name, "s241")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, one,unit); + } else if (!strcmp(name, "s242")) { + set_1d_array(a, LEN_1D,small,unit); + set_1d_array(b, LEN_1D,small,unit); + set_1d_array(c, LEN_1D,small,unit); + set_1d_array(d, LEN_1D,small,unit); + } else if (!strcmp(name, "s243")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s244")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D,small,unit); + set_1d_array(d, LEN_1D,small,unit); + } else if (!strcmp(name, "s251")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s252")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + } else if (!strcmp(name, "s253")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D,small,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, any,frac); + } else if (!strcmp(name, "s254")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + } else if (!strcmp(name, "s255")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + } else if (!strcmp(name, "s256")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, two,frac); + set_2d_array(aa, two,unit); + set_2d_array(bb, one,unit); + } else if (!strcmp(name, "s257")) { + set_1d_array(a, LEN_1D, one,unit); + set_2d_array(aa, two,unit); + set_2d_array(bb, one,unit); + } else if (!strcmp(name, "s258")) { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D,zero,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D,zero,unit); + set_2d_array(aa, any,frac); + } else if (!strcmp(name, "s261")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + set_1d_array(c, LEN_1D, any,frac2); + set_1d_array(d, LEN_1D, one,unit); + } else if (!strcmp(name, "s271")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s272")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, two,unit); + } else if (!strcmp(name, "s273")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D,small,unit); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s274")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s275")) { + set_2d_array(aa, one,unit); + set_2d_array(bb,small,unit); + set_2d_array(cc,small,unit); + } else if (!strcmp(name, "s276")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + } else if (!strcmp(name, "s277")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array( b, LEN_1D/2, one,unit); + set_1d_array( &b[LEN_1D/2], LEN_1D/2,-one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s278")) { + set_1d_array( a, LEN_1D/2,-one,unit); + set_1d_array( &a[LEN_1D/2], LEN_1D/2,one,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s279")) { + set_1d_array( a, LEN_1D/2,-one,unit); + set_1d_array( &a[LEN_1D/2], LEN_1D/2,one,unit); +// set_1d_array(a, LEN_1D, -one,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s2710")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s2711")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s2712")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s281")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + } else if (!strcmp(name, "1s281")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, one,unit); + set_1d_array(e, LEN_1D, one,unit); + set_1d_array(x, LEN_1D, one,unit); + } else if (!strcmp(name, "s291")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + } else if (!strcmp(name, "s292")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + } else if (!strcmp(name, "s293")) { + set_1d_array(a, LEN_1D, any,frac); + } else if (!strcmp(name, "s2101")) { + set_2d_array(aa, one,unit); + set_2d_array(bb, any,frac); + set_2d_array(cc, any,frac); + } else if (!strcmp(name, "s2102")) { + set_2d_array(aa,zero,unit); + } else if (!strcmp(name, "s2111")) { + set_2d_array(aa, small,unit); + } else if (!strcmp(name, "s311")) { + set_1d_array(a, LEN_1D, any,frac); + } else if (!strcmp(name, "s312")) { + set_1d_array(a, LEN_1D,1.000001,unit); + } else if (!strcmp(name, "s313")) { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D, any,frac); + } else if (!strcmp(name, "s314")) { + set_1d_array(a, LEN_1D, any,frac); + } else if (!strcmp(name, "s315")) { + set_1d_array(a, LEN_1D, any,frac); + } else if (!strcmp(name, "s316")) { + set_1d_array(a, LEN_1D, any,frac); + } else if (!strcmp(name, "s317")) { + } else if (!strcmp(name, "s318")) { + set_1d_array(a, LEN_1D, any,frac); + a[LEN_1D-1] = -two; + } else if (!strcmp(name, "s319")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D,zero,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s3110")) { + set_2d_array(aa, any,frac); + aa[LEN_2D-1][LEN_2D-1] = two; + } else if (!strcmp(name, "s3111")) { + set_1d_array(a, LEN_1D, any,frac); + } else if (!strcmp(name, "s3112")) { + set_1d_array(a, LEN_1D, any,frac2); + set_1d_array(b, LEN_1D,zero,unit); + } else if (!strcmp(name, "s3113")) { + set_1d_array(a, LEN_1D, any,frac); + a[LEN_1D-1] = -two; + } else if (!strcmp(name, "s321")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D,zero,unit); + } else if (!strcmp(name, "s322")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D,zero,unit); + set_1d_array(c, LEN_1D,zero,unit); + } else if (!strcmp(name, "s323")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s331")) { + set_1d_array(a, LEN_1D, any,frac); + a[LEN_1D-1] = -one; + } else if (!strcmp(name, "s332")) { + set_1d_array(a, LEN_1D, any,frac2); + a[LEN_1D-1] = two; + } else if (!strcmp(name, "s341")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, any,frac); + } else if (!strcmp(name, "s342")) { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D, any,frac); + } else if (!strcmp(name, "s343")) { + set_2d_array(aa, any,frac); + set_2d_array(bb, one,unit); + } else if (!strcmp(name, "s351")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + c[0] = 1.; + } else if (!strcmp(name, "s352")) { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D, any,frac); + } else if (!strcmp(name, "s353")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + c[0] = 1.; + } else if (!strcmp(name, "s411")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s412")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s413")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s414")) { + set_2d_array(aa, one,unit); + set_2d_array(bb, any,frac); + set_2d_array(cc, any,frac); + } else if (!strcmp(name, "s415")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + a[LEN_1D-1] = -one; + } else if (!strcmp(name, "s421")) { + set_1d_array(a, LEN_1D, any,frac2); + set_1d_array(flat_2d_array, LEN_1D, one, unit); + } else if (!strcmp(name, "s422")) { + set_1d_array(flat_2d_array, LEN_1D,one,unit); + set_1d_array(a, LEN_1D, any,frac2); + set_1d_array(flat_2d_array + LEN_1D, LEN_1D, zero, unit); + } else if (!strcmp(name, "s1421")) { + set_1d_array(b, LEN_1D, one, unit); + } else if (!strcmp(name, "s423")) { + set_1d_array(flat_2d_array, LEN_1D,zero,unit); + set_1d_array(a, LEN_1D, any,frac2); + set_1d_array(flat_2d_array + LEN_1D, LEN_1D, one, unit); + } else if (!strcmp(name, "s424")) { + set_1d_array(flat_2d_array, LEN_1D,one,unit); + set_1d_array(a, LEN_1D, any,frac2); + set_1d_array(flat_2d_array, LEN_1D, zero, unit); + } else if (!strcmp(name, "s431")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s432")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s441")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(&d[0], LEN_1D/3 , -one,unit); + set_1d_array(&d[LEN_1D/3], LEN_1D/3 , zero,unit); + set_1d_array(&d[(2*LEN_1D/3)], LEN_1D/3+1, one,unit); + } else if (!strcmp(name, "s442")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + } else if (!strcmp(name, "s443")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s451")) { + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s452")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D,small,unit); + } else if (!strcmp(name, "s453")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "s471")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, one,unit); + set_1d_array(d, LEN_1D, any,frac); + set_1d_array(e, LEN_1D, any,frac); + set_1d_array(x, LEN_1D, zero, unit); + } else if (!strcmp(name, "s481")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + } else if (!strcmp(name, "s482")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "s491")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + } else if (!strcmp(name, "s4112")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + } else if (!strcmp(name, "s4113")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac2); + } else if (!strcmp(name, "s4114")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + } else if (!strcmp(name, "s4115")) { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D, any,frac); + } else if (!strcmp(name, "s4116")) { + set_1d_array(a, LEN_1D, any,frac); + set_2d_array(aa, any,frac); + } else if (!strcmp(name, "s4117")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D, any,frac); + set_1d_array(d, LEN_1D, any,frac); + } else if (!strcmp(name, "s4121")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "va")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "vag")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "vas")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "vif")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "vpv")) { + set_1d_array(a, LEN_1D,zero,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "vtv")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, one,unit); + } else if (!strcmp(name, "vpvtv")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, any,frac); + } else if (!strcmp(name, "vpvts")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, any,frac2); + } else if (!strcmp(name, "vpvpv")) { + set_1d_array(a, LEN_1D, any,frac2); + set_1d_array(b, LEN_1D, one,unit); + set_1d_array(c, LEN_1D,-one,unit); + } else if (!strcmp(name, "vtvtv")) { + set_1d_array(a, LEN_1D, one,unit); + set_1d_array(b, LEN_1D, two,unit); + set_1d_array(c, LEN_1D,half,unit); + } else if (!strcmp(name, "vsumr")) { + set_1d_array(a, LEN_1D, any,frac); + } else if (!strcmp(name, "vdotr")) { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D, any,frac); + } else if (!strcmp(name, "vbor")) { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, one,frac); + set_1d_array(d, LEN_1D, two,frac); + set_1d_array(e, LEN_1D,half,frac); + set_2d_array(aa, any,frac); + } else { + set_1d_array(a, LEN_1D, any,frac); + set_1d_array(b, LEN_1D, any,frac); + set_1d_array(c, LEN_1D, one,frac); + set_1d_array(d, LEN_1D, two,frac); + set_1d_array(e, LEN_1D,half,frac); + set_2d_array(aa, half,frac); + set_2d_array(bb, one,frac); + set_2d_array(cc, any,frac); + } + + return 0; +} + +real_t calc_checksum(const char * name) +{ + if (!strcmp(name, "s000")) { + return sum_a(); + } else if (!strcmp(name, "s111")) { + return sum_a(); + } else if (!strcmp(name, "s1111")) { + return sum_a(); + } else if (!strcmp(name, "s112")) { + return sum_a(); + } else if (!strcmp(name, "s1112")) { + return sum_a(); + } else if (!strcmp(name, "s113")) { + return sum_a(); + } else if (!strcmp(name, "s1113")) { + return sum_a(); + } else if (!strcmp(name, "s114")) { + return sum_aa(); + } else if (!strcmp(name, "s115")) { + return sum_a(); + } else if (!strcmp(name, "s1115")) { + return sum_aa(); + } else if (!strcmp(name, "s116")) { + return sum_a(); + } else if (!strcmp(name, "s118")) { + return sum_a(); + } else if (!strcmp(name, "s119")) { + return sum_aa(); + } else if (!strcmp(name, "s1119")) { + return sum_aa(); + } else if (!strcmp(name, "s121")) { + return sum_a(); + } else if (!strcmp(name, "s122")) { + return sum_a(); + } else if (!strcmp(name, "s123")) { + return sum_a(); + } else if (!strcmp(name, "s124")) { + return sum_a(); + } else if (!strcmp(name, "s125")) { + return sum_flat_2d_array(); + } else if (!strcmp(name, "s126")) { + return sum_bb(); + } else if (!strcmp(name, "s127")) { + return sum_a(); + } else if (!strcmp(name, "s128")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s131")) { + return sum_a(); + } else if (!strcmp(name, "s132")) { + return sum_aa(); + } else if (!strcmp(name, "s141")) { + return sum_flat_2d_array(); + } else if (!strcmp(name, "s151")) { + return sum_a(); + } else if (!strcmp(name, "s152")) { + return sum_a(); + } else if (!strcmp(name, "s161")) { + return sum_a() + sum_c(); + } else if (!strcmp(name, "s1161")) { + return sum_a() + sum_c(); + } else if (!strcmp(name, "s162")) { + return sum_a(); + } else if (!strcmp(name, "s171")) { + return sum_a(); + } else if (!strcmp(name, "s172")) { + return sum_a(); + } else if (!strcmp(name, "s173")) { + return sum_a(); + } else if (!strcmp(name, "s174")) { + return sum_a(); + } else if (!strcmp(name, "s175")) { + return sum_a(); + } else if (!strcmp(name, "s176")) { + return sum_a(); + } else if (!strcmp(name, "s211")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s212")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s1213")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s221")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s1221")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s222")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s231")) { + return sum_aa(); + } else if (!strcmp(name, "s232")) { + return sum_aa(); + } else if (!strcmp(name, "s1232")) { + return sum_aa(); + } else if (!strcmp(name, "s233")) { + return sum_aa_bb(); + } else if (!strcmp(name, "s2233")) { + return sum_aa_bb(); + } else if (!strcmp(name, "s235")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s241")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s242")) { + return sum_a(); + } else if (!strcmp(name, "s243")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s244")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s1244")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s2244")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s251")) { + return sum_a(); + } else if (!strcmp(name, "s1251")) { + return sum_a(); + } else if (!strcmp(name, "s2251")) { + return sum_a(); + } else if (!strcmp(name, "s3251")) { + return sum_a(); + } else if (!strcmp(name, "s252")) { + return sum_a(); + } else if (!strcmp(name, "s253")) { + return sum_a() + sum_c(); + } else if (!strcmp(name, "s254")) { + return sum_a(); + } else if (!strcmp(name, "s255")) { + return sum_a(); + } else if (!strcmp(name, "s256")) { + return sum_a_aa(); + } else if (!strcmp(name, "s257")) { + return sum_a_aa(); + } else if (!strcmp(name, "s258")) { + return sum_b() + sum_e(); + } else if (!strcmp(name, "s261")) { + return sum_a() + sum_c(); + } else if (!strcmp(name, "s271")) { + return sum_a(); + } else if (!strcmp(name, "s272")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s273")) { + return sum_a() + sum_b() + sum_c(); + } else if (!strcmp(name, "s274")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s275")) { + return sum_aa(); + } else if (!strcmp(name, "s2275")) { + return sum_aa(); + } else if (!strcmp(name, "s276")) { + return sum_a(); + } else if (!strcmp(name, "s277")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s278")) { + return sum_a() + sum_b() + sum_c(); + } else if (!strcmp(name, "s279")) { + return sum_a() + sum_b() + sum_c(); + } else if (!strcmp(name, "s1279")) { + return sum_a() + sum_b() + sum_c(); + } else if (!strcmp(name, "s2710")) { + return sum_a() + sum_b() + sum_c(); + } else if (!strcmp(name, "s2711")) { + return sum_a(); + } else if (!strcmp(name, "s2712")) { + return sum_a(); + } else if (!strcmp(name, "s281")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s1281")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s291")) { + return sum_a(); + } else if (!strcmp(name, "s292")) { + return sum_a(); + } else if (!strcmp(name, "s293")) { + return sum_a(); + } else if (!strcmp(name, "s2101")) { + return sum_aa(); + } else if (!strcmp(name, "s2102")) { + return sum_aa(); + } else if (!strcmp(name, "s2111")) { + return sum_aa(); + } else if (!strcmp(name, "s311")) { + return sum_a(); + } else if (!strcmp(name, "s31111")) { + return sum_a(); + } else if (!strcmp(name, "s321")) { + return sum_a(); + } else if (!strcmp(name, "s322")) { + return sum_a(); + } else if (!strcmp(name, "s323")) { + return sum_a() + sum_b(); + } else if (!strcmp(name, "s341")) { + return sum_a(); + } else if (!strcmp(name, "s342")) { + return sum_a(); + } else if (!strcmp(name, "s343")) { + return sum_flat_2d_array(); + } else if (!strcmp(name, "s351")) { + return sum_a(); + } else if (!strcmp(name, "s1351")) { + return sum_a(); + } else if (!strcmp(name, "s353")) { + return sum_a(); + } else if (!strcmp(name, "s421")) { + return sum_xx(); + } else if (!strcmp(name, "s1421")) { + return sum_half_xx(); + } else if (!strcmp(name, "s422")) { + return sum_xx(); + } else if (!strcmp(name, "s423")) { + return sum_flat_2d_array(); + } else if (!strcmp(name, "s424")) { + return sum_xx(); + } else if (!strcmp(name, "s431")) { + return sum_a(); + } else if (!strcmp(name, "s441")) { + return sum_a(); + } else if (!strcmp(name, "s442")) { + return sum_a(); + } else if (!strcmp(name, "s443")) { + return sum_a(); + } else if (!strcmp(name, "s451")) { + return sum_a(); + } else if (!strcmp(name, "s452")) { + return sum_a(); + } else if (!strcmp(name, "s453")) { + return sum_a(); + } else if (!strcmp(name, "s471")) { + return sum_x() + sum_b(); + } else if (!strcmp(name, "s481")) { + return sum_a(); + } else if (!strcmp(name, "s482")) { + return sum_a(); + } else if (!strcmp(name, "s491")) { + return sum_a(); + } else if (!strcmp(name, "s4112")) { + return sum_a(); + } else if (!strcmp(name, "s4113")) { + return sum_a(); + } else if (!strcmp(name, "s4114")) { + return sum_a(); + } else if (!strcmp(name, "s4117")) { + return sum_a(); + } else if (!strcmp(name, "s4121")) { + return sum_a(); + } else if (!strcmp(name, "va")) { + return sum_a(); + } else if (!strcmp(name, "vag")) { + return sum_a(); + } else if (!strcmp(name, "vas")) { + return sum_a(); + } else if (!strcmp(name, "vif")) { + return sum_a(); + } else if (!strcmp(name, "vpv")) { + return sum_a(); + } else if (!strcmp(name, "vtv")) { + return sum_a(); + } else if (!strcmp(name, "vpvtv")) { + return sum_a(); + } else if (!strcmp(name, "vpvts")) { + return sum_a(); + } else if (!strcmp(name, "vpvpv")) { + return sum_a(); + } else if (!strcmp(name, "vtvtv")) { + return sum_a(); + } else if (!strcmp(name, "vsumr")) { + return sum_a(); + } else if (!strcmp(name, "vbor")) { + return sum_x(); + } else { + fprintf(stderr, "Unknown function name passed to calc_checksum: %s\n", name); + exit(1); + } +} + +real_t get_expected_result(const char * name) +{ + if (!strcmp(name, "s000")) { + return 512075584.f; + } else if (!strcmp(name, "s111")) { + return 32000.410156f; + } else if (!strcmp(name, "s1111")) { + return 13.352669f; + } else if (!strcmp(name, "s112")) { + return 81335.929688f; + } else if (!strcmp(name, "s1112")) { + return 32009.560547f; + } else if (!strcmp(name, "s113")) { + return 32000.642578f; + } else if (!strcmp(name, "s1113")) { + return 40010.613281f; + } else if (!strcmp(name, "s114")) { + return 919.856323f; + } else if (!strcmp(name, "s115")) { + return 31727.289062f; + } else if (!strcmp(name, "s1115")) { + return 25487.052734f; + } else if (!strcmp(name, "s116")) { + return 32000.f; + } else if (!strcmp(name, "s118")) { + return 32353.884766f; + } else if (!strcmp(name, "s119")) { + return 86338.984375f; + } else if (!strcmp(name, "s1119")) { + return 201466.421875f; + } else if (!strcmp(name, "s121")) { + return 32009.027344f; + } else if (!strcmp(name, "s122")) { + return 48446.664062f; + } else if (!strcmp(name, "s123")) { + return 32003.285156f; + } else if (!strcmp(name, "s124")) { + return 32001.642578f; + } else if (!strcmp(name, "s125")) { + return 131072.f; + } else if (!strcmp(name, "s126")) { + return 66955.132812f; + } else if (!strcmp(name, "s127")) { + return 32003.285156f; + } else if (!strcmp(name, "s128")) { + return 80000.f; + } else if (!strcmp(name, "s131")) { + return 32009.027344f; + } else if (!strcmp(name, "s132")) { + return 65538.5625f; + } else if (!strcmp(name, "s141")) { + return 3307351.5f; + } else if (!strcmp(name, "s151")) { + return 32009.027344f; + } else if (!strcmp(name, "s152")) { + return 44020.523438f; + } else if (!strcmp(name, "s161")) { + return 64002.054688f; + } else if (!strcmp(name, "s1161")) { + return 23.546331f; + } else if (!strcmp(name, "s162")) { + return 32009.023438f; + } else if (!strcmp(name, "s171")) { + return 48448.019531f; + } else if (!strcmp(name, "s172")) { + return 48448.019531f; + } else if (!strcmp(name, "s173")) { + return 32001.626953f; + } else if (!strcmp(name, "s174")) { + return 32001.626953f; + } else if (!strcmp(name, "s175")) { + return 32009.023438f; + } else if (!strcmp(name, "s176")) { + return 32063.902344f; + } else if (!strcmp(name, "s211")) { + return 63983.308594f; + } else if (!strcmp(name, "s212")) { + return 42008.136719f; + } else if (!strcmp(name, "s1213")) { + return 14.450508f; + } else if (!strcmp(name, "s221")) { + return 615418176.f; + } else if (!strcmp(name, "s1221")) { + return 79623.265625f; + } else if (!strcmp(name, "s222")) { + return 32000.f; + } else if (!strcmp(name, "s231")) { + return 119107.445312f; + } else if (!strcmp(name, "s232")) { + return 65536.f; + } else if (!strcmp(name, "s1232")) { + return 2885.801514f; + } else if (!strcmp(name, "s233")) { + return 504911.65625f; + } else if (!strcmp(name, "s2233")) { + return 337652.8125f; + } else if (!strcmp(name, "s235")) { + return 44810.886719f; + } else if (!strcmp(name, "s241")) { + return 64000.f; + } else if (!strcmp(name, "s242")) { + return 1535966208.f; + } else if (!strcmp(name, "s243")) { + return 138653.21875f; + } else if (!strcmp(name, "s244")) { + return 64623.015625f; + } else if (!strcmp(name, "s1244")) { + return 36.141911f; + } else if (!strcmp(name, "s2244")) { + return 32.852161f; + } else if (!strcmp(name, "s251")) { + return 32004.367188f; + } else if (!strcmp(name, "s1251")) { + return 39967.507812f; + } else if (!strcmp(name, "s2251")) { + return 2.635388f; + } else if (!strcmp(name, "s3251")) { + return 13.59558f; + } else if (!strcmp(name, "s252")) { + return 63999.f; + } else if (!strcmp(name, "s253")) { + return 320115936.f; + } else if (!strcmp(name, "s254")) { + return 32000.f; + } else if (!strcmp(name, "s255")) { + return 31953.501953f; + } else if (!strcmp(name, "s256")) { + return 66207.828125f; + } else if (!strcmp(name, "s257")) { + return 163072.f; + } else if (!strcmp(name, "s258")) { + return 14.65278f; + } else if (!strcmp(name, "s261")) { + return 54894.515625f; + } else if (!strcmp(name, "s271")) { + return 97793.570312f; + } else if (!strcmp(name, "s272")) { + return 64000.f; + } else if (!strcmp(name, "s273")) { + return 96311.546875f; + } else if (!strcmp(name, "s274")) { + return 320133920.f; + } else if (!strcmp(name, "s275")) { + return 65536.f; + } else if (!strcmp(name, "s2275")) { + return 1640158.5f; + } else if (!strcmp(name, "s276")) { + return 97793.570312f; + } else if (!strcmp(name, "s277")) { + return 32000.f; + } else if (!strcmp(name, "s278")) { + return 64012.589844f; + } else if (!strcmp(name, "s279")) { + return 64014.289062f; + } else if (!strcmp(name, "s1279")) { + return 32.852161f; + } else if (!strcmp(name, "s2710")) { + return 96003.28125f; + } else if (!strcmp(name, "s2711")) { + return 97793.570312f; + } else if (!strcmp(name, "s2712")) { + return 97793.570312f; + } else if (!strcmp(name, "s281")) { + return 32000.f; + } else if (!strcmp(name, "s1281")) { + return INFINITY; + } else if (!strcmp(name, "s291")) { + return 32000.f; + } else if (!strcmp(name, "s292")) { + return 31953.501953f; + } else if (!strcmp(name, "s293")) { + return 31999.998047f; + } else if (!strcmp(name, "s2101")) { + return 229657.921875f; + } else if (!strcmp(name, "s2102")) { + return 256.f; + } else if (!strcmp(name, "s2111")) { + return 34544940.f; + } else if (!strcmp(name, "s311")) { + return 10.950721f; + } else if (!strcmp(name, "s31111")) { + return 10.950721f; + } else if (!strcmp(name, "s312")) { + return 1.030869f; + } else if (!strcmp(name, "s313")) { + return 1.644824f; + } else if (!strcmp(name, "s314")) { + return 1.f; + } else if (!strcmp(name, "s315")) { + return 54857.f; + } else if (!strcmp(name, "s316")) { + return 0.000031f; + } else if (!strcmp(name, "s317")) { + return 0.f; + } else if (!strcmp(name, "s318")) { + return 32002.f; + } else if (!strcmp(name, "s319")) { + return 43.802898f; + } else if (!strcmp(name, "s3110")) { + return 514.f; + } else if (!strcmp(name, "s13110")) { + return 3.f; + } else if (!strcmp(name, "s3111")) { + return 10.950725f; + } else if (!strcmp(name, "s3112")) { + return 1.644725f; + } else if (!strcmp(name, "s3113")) { + return 2.f; + } else if (!strcmp(name, "s321")) { + return 32000.f; + } else if (!strcmp(name, "s322")) { + return 32000.f; + } else if (!strcmp(name, "s323")) { + return 146472.4375f; + } else if (!strcmp(name, "s331")) { + return 32000.f; + } else if (!strcmp(name, "s332")) { + return -1.f; + } else if (!strcmp(name, "s341")) { + return 10.950721f; + } else if (!strcmp(name, "s342")) { + return 10.950721f; + } else if (!strcmp(name, "s343")) { + return 1567.932129f; + } else if (!strcmp(name, "s351")) { + return 2560660224.f; + } else if (!strcmp(name, "s1351")) { + return 21.901442f; + } else if (!strcmp(name, "s352")) { + return 1.644808f; + } else if (!strcmp(name, "s353")) { + return 320084192.f; + } else if (!strcmp(name, "s421")) { + return 32009.023438f; + } else if (!strcmp(name, "s1421")) { + return 16000.f; + } else if (!strcmp(name, "s422")) { + return 3.737715f; + } else if (!strcmp(name, "s423")) { + return 64006.683594f; + } else if (!strcmp(name, "s424")) { + return 822.364014f; + } else if (!strcmp(name, "s431")) { + return 196500.265625f; + } else if (!strcmp(name, "s441")) { + return 48448.019531f; + } else if (!strcmp(name, "s442")) { + return 40224.117188f; + } else if (!strcmp(name, "s443")) { + return 64895.867188f; + } else if (!strcmp(name, "s451")) { + return 32007.898438f; + } else if (!strcmp(name, "s452")) { + return 32511.939453f; + } else if (!strcmp(name, "s453")) { + return 21.901442f; + } else if (!strcmp(name, "s471")) { + return 64004.925781f; + } else if (!strcmp(name, "s481")) { + return 48448.019531f; + } else if (!strcmp(name, "s482")) { + return 48448.019531f; + } else if (!strcmp(name, "s491")) { + return 32001.640625f; + } else if (!strcmp(name, "s4112")) { + return 141504.875f; + } else if (!strcmp(name, "s4113")) { + return 32001.640625f; + } else if (!strcmp(name, "s4114")) { + return 32000.f; + } else if (!strcmp(name, "s4115")) { + return 1.038636f; + } else if (!strcmp(name, "s4116")) { + return 0.753265f; + } else if (!strcmp(name, "s4117")) { + return 32002.205078f; + } else if (!strcmp(name, "s4121")) { + return 48448.019531f; + } else if (!strcmp(name, "va")) { + return 1.644725f; + } else if (!strcmp(name, "vag")) { + return 1.644725f; + } else if (!strcmp(name, "vas")) { + return 1.644725f; + } else if (!strcmp(name, "vif")) { + return 1.644725f; + } else if (!strcmp(name, "vpv")) { + return 164487.78125f; + } else if (!strcmp(name, "vtv")) { + return 32000.f; + } else if (!strcmp(name, "vpvtv")) { + return 97793.570312f; + } else if (!strcmp(name, "vpvts")) { + return 17522152701952.f; + } else if (!strcmp(name, "vpvpv")) { + return 1.644725f; + } else if (!strcmp(name, "vtvtv")) { + return 32000.f; + } else if (!strcmp(name, "vsumr")) { + return 10.950725f; + } else if (!strcmp(name, "vdotr")) { + return 1.644824f; + } else if (!strcmp(name, "vbor")) { + return 31924.046875f; + } else { + fprintf(stderr, "Unknown function name passed to expected_result: %s\n", name); + exit(1); + } +} + +typedef real_t(*test_function_t)(struct args_t *); + +static _Bool is_checksum_same(real_t expected, real_t value) +{ + if (expected == INFINITY) + return value == INFINITY; + else if(expected == 0.f) + return value <= 0.01f; + else { + real_t fraction = value / expected; + return 0.99f <= fraction && fraction <= 1.01f; + } +} + +void run(test_function_t vector_func, const char *fname, void * arg_info) +{ + struct args_t func_args = {.arg_info=arg_info}; + + double result = vector_func(&func_args); + double expected_result = get_expected_result(fname); + + if (!is_checksum_same(expected_result, result)) + { + fprintf (stderr, "value: %f, expected: %f\n", result, expected_result); + __builtin_abort(); + } +} + +int +__attribute__((noipa)) +dummy(float a[LEN_1D], float b[LEN_1D], float c[LEN_1D], float d[LEN_1D], float e[LEN_1D], float aa[LEN_2D][LEN_2D], float bb[LEN_2D][LEN_2D], float cc[LEN_2D][LEN_2D], float s){ + // -- called in each loop to make all computations appear required + return 0; +} + +#pragma GCC pop_options diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s000.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s000.c new file mode 100644 index 0000000000..b5d5faab52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s000.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s000(struct args_t * func_args) +{ +// linear dependence testing +// no dependence - vectorizable + + initialise_arrays(__func__); + + for (int nl = 0; nl < 2*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = b[i] + 1; + } + dummy((real_t*)a, (real_t*)b, (real_t*)c, (real_t*)d, (real_t*)e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s000, "s000", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s111.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s111.c new file mode 100644 index 0000000000..37e4684e1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s111.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s111(struct args_t * func_args) +{ +// linear dependence testing +// no dependence - vectorizable + + initialise_arrays(__func__); + + for (int nl = 0; nl < 2*iterations; nl++) { + for (int i = 1; i < LEN_1D; i += 2) { + a[i] = a[i - 1] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s111, "s111", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1111.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1111.c new file mode 100644 index 0000000000..cd7e84ebfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1111.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1111(struct args_t * func_args) +{ +// no dependence - vectorizable +// jump in data access + + initialise_arrays(__func__); + + for (int nl = 0; nl < 2*iterations; nl++) { + for (int i = 0; i < LEN_1D/2; i++) { + a[2*i] = c[i] * b[i] + d[i] * b[i] + c[i] * c[i] + d[i] * b[i] + d[i] * c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1111, "s1111", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1112.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1112.c new file mode 100644 index 0000000000..20cb346810 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1112.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1112(struct args_t * func_args) +{ +// linear dependence testing +// loop reversal + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations*3; nl++) { + for (int i = LEN_1D - 1; i >= 0; i--) { + a[i] = b[i] + (real_t) 1.; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1112, "s1112", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1113.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1113.c new file mode 100644 index 0000000000..55aa8edbdd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1113.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1113(struct args_t * func_args) +{ +// linear dependence testing +// one iteration dependency on a(LEN_1D/2) but still vectorizable + + initialise_arrays(__func__); + + for (int nl = 0; nl < 2*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = a[LEN_1D/2] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1113, "s1113", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1115.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1115.c new file mode 100644 index 0000000000..3eda9940e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1115.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1115(struct args_t * func_args) +{ +// linear dependence testing +// triangular saxpy loop + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) { + for (int i = 0; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + aa[i][j] = aa[i][j]*cc[j][i] + bb[i][j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1115, "s1115", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1119.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1119.c new file mode 100644 index 0000000000..16610fadd6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1119.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1119(struct args_t * func_args) +{ +// linear dependence testing +// no dependence - vectorizable + + initialise_arrays(__func__); + + for (int nl = 0; nl < 200*(iterations/(LEN_2D)); nl++) { + for (int i = 1; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + aa[i][j] = aa[i-1][j] + bb[i][j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1119, "s1119", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s112.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s112.c new file mode 100644 index 0000000000..c8afaf73f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s112.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s112(struct args_t * func_args) +{ +// linear dependence testing +// loop reversal + + initialise_arrays(__func__); + + for (int nl = 0; nl < 3*iterations; nl++) { + for (int i = LEN_1D - 2; i >= 0; i--) { + a[i+1] = a[i] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s112, "s112", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { ! powerpc*-*-* } || has_arch_pwr8 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s113.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s113.c new file mode 100644 index 0000000000..f22ab4c03b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s113.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s113(struct args_t * func_args) +{ +// linear dependence testing +// a(i)=a(1) but no actual dependence cycle + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 1; i < LEN_1D; i++) { + a[i] = a[0] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s113, "s113", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s114.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s114.c new file mode 100644 index 0000000000..6972565f28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s114.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s114(struct args_t * func_args) +{ +// linear dependence testing +// transpose vectorization +// Jump in data access - not vectorizable + + initialise_arrays(__func__); + + for (int nl = 0; nl < 200*(iterations/(LEN_2D)); nl++) { + for (int i = 0; i < LEN_2D; i++) { + for (int j = 0; j < i; j++) { + aa[i][j] = aa[j][i] + bb[i][j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s114, "s114", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s115.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s115.c new file mode 100644 index 0000000000..153cbf8aac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s115.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s115(struct args_t * func_args) +{ +// linear dependence testing +// triangular saxpy loop + + initialise_arrays(__func__); + + for (int nl = 0; nl < 1000*(iterations/LEN_2D); nl++) { + for (int j = 0; j < LEN_2D; j++) { + for (int i = j+1; i < LEN_2D; i++) { + a[i] -= aa[j][i] * a[j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s115, "s115", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s116.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s116.c new file mode 100644 index 0000000000..9702ec8f52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s116.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-timeout-factor 2 } */ + +#include "tsvc.h" + +real_t s116(struct args_t * func_args) +{ +// linear dependence testing + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations*10; nl++) { + for (int i = 0; i < LEN_1D - 5; i += 5) { + a[i] = a[i + 1] * a[i]; + a[i + 1] = a[i + 2] * a[i + 1]; + a[i + 2] = a[i + 3] * a[i + 2]; + a[i + 3] = a[i + 4] * a[i + 3]; + a[i + 4] = a[i + 5] * a[i + 4]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s116, "s116", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1161.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1161.c new file mode 100644 index 0000000000..9098beafad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1161.c @@ -0,0 +1,48 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1161(struct args_t * func_args) +{ +// control flow +// tests for recognition of loop independent dependences +// between statements in mutually exclusive regions. + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; ++i) { + if (c[i] < (real_t)0.) { + goto L20; + } + a[i] = c[i] + d[i] * e[i]; + goto L10; +L20: + b[i] = a[i] + d[i] * d[i]; +L10: + ; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1161, "s1161", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s118.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s118.c new file mode 100644 index 0000000000..3896a9a741 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s118.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s118(struct args_t * func_args) +{ +// linear dependence testing +// potential dot product recursion + + initialise_arrays(__func__); + + for (int nl = 0; nl < 200*(iterations/LEN_2D); nl++) { + for (int i = 1; i < LEN_2D; i++) { + for (int j = 0; j <= i - 1; j++) { + a[i] += bb[j][i] * a[i-j-1]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s118, "s118", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s119.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s119.c new file mode 100644 index 0000000000..43391c5e44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s119.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s119(struct args_t * func_args) +{ +// linear dependence testing +// no dependence - vectorizable + + initialise_arrays(__func__); + + for (int nl = 0; nl < 200*(iterations/(LEN_2D)); nl++) { + for (int i = 1; i < LEN_2D; i++) { + for (int j = 1; j < LEN_2D; j++) { + aa[i][j] = aa[i-1][j-1] + bb[i][j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s119, "s119", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s121.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s121.c new file mode 100644 index 0000000000..98a67ace81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s121.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s121(struct args_t * func_args) +{ +// induction variable recognition +// loop with possible ambiguity because of scalar store + + initialise_arrays(__func__); + + int j; + for (int nl = 0; nl < 3*iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i++) { + j = i + 1; + a[i] = a[j] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s121, "s121", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1213.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1213.c new file mode 100644 index 0000000000..f9f3beb38d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1213.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1213(struct args_t * func_args) +{ +// statement reordering +// dependency needing temporary + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 1; i < LEN_1D-1; i++) { + a[i] = b[i-1]+c[i]; + b[i] = a[i+1]*d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1213, "s1213", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s122.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s122.c new file mode 100644 index 0000000000..0aceeb721f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s122.c @@ -0,0 +1,48 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s122(struct args_t * func_args) +{ +// induction variable recognition +// variable lower and upper bound, and stride +// reverse data access and jump in data access + + struct{int a;int b;} * x = func_args->arg_info; + int n1 = x->a; + int n3 = x->b; + + initialise_arrays(__func__); + + int j, k; + for (int nl = 0; nl < iterations; nl++) { + j = 1; + k = 0; + for (int i = n1-1; i < LEN_1D; i += n3) { + k += j; + a[i] += b[LEN_1D - k]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s122, "s122", &(struct{int a;int b;}){n1, n3}); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1221.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1221.c new file mode 100644 index 0000000000..4ecccfd731 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1221.c @@ -0,0 +1,38 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1221(struct args_t * func_args) +{ +// run-time symbolic resolution + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 4; i < LEN_1D; i++) { + b[i] = b[i - 4] + a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1221, "s1221", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s123.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s123.c new file mode 100644 index 0000000000..adb4da80f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s123.c @@ -0,0 +1,47 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s123(struct args_t * func_args) +{ +// induction variable recognition +// induction variable under an if +// not vectorizable, the condition cannot be speculated + + initialise_arrays(__func__); + + int j; + for (int nl = 0; nl < iterations; nl++) { + j = -1; + for (int i = 0; i < (LEN_1D/2); i++) { + j++; + a[j] = b[i] + d[i] * e[i]; + if (c[i] > (real_t)0.) { + j++; + a[j] = c[i] + d[i] * e[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s123, "s123", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1232.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1232.c new file mode 100644 index 0000000000..66242bcb15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1232.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1232(struct args_t * func_args) +{ +// loop interchange +// interchanging of triangular loops + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) { + for (int j = 0; j < LEN_2D; j++) { + for (int i = j; i < LEN_2D; i++) { + aa[i][j] = bb[i][j] + cc[i][j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 1.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1232, "s1232", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s124.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s124.c new file mode 100644 index 0000000000..70c3790af0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s124.c @@ -0,0 +1,47 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s124(struct args_t * func_args) +{ +// induction variable recognition +// induction variable under both sides of if (same value) + + initialise_arrays(__func__); + + int j; + for (int nl = 0; nl < iterations; nl++) { + j = -1; + for (int i = 0; i < LEN_1D; i++) { + if (b[i] > (real_t)0.) { + j++; + a[j] = b[i] + d[i] * e[i]; + } else { + j++; + a[j] = c[i] + d[i] * e[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s124, "s124", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1244.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1244.c new file mode 100644 index 0000000000..94a30412df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1244.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1244(struct args_t * func_args) +{ +// node splitting +// cycle with ture and anti dependency + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i++) { + a[i] = b[i] + c[i] * c[i] + b[i]*b[i] + c[i]; + d[i] = a[i] + a[i+1]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1244, "s1244", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s125.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s125.c new file mode 100644 index 0000000000..679074300b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s125.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s125(struct args_t * func_args) +{ +// induction variable recognition +// induction variable in two loops; collapsing possible + + initialise_arrays(__func__); + + int k; + for (int nl = 0; nl < 100*(iterations/(LEN_2D)); nl++) { + k = -1; + for (int i = 0; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + k++; + flat_2d_array[k] = aa[i][j] + bb[i][j] * cc[i][j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s125, "s125", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1251.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1251.c new file mode 100644 index 0000000000..b2e099ccfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1251.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1251(struct args_t * func_args) +{ +// scalar and array expansion +// scalar expansion + + initialise_arrays(__func__); + + real_t s; + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + s = b[i]+c[i]; + b[i] = a[i]+d[i]; + a[i] = s*e[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1251, "s1251", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s126.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s126.c new file mode 100644 index 0000000000..a1c71b3178 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s126.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s126(struct args_t * func_args) +{ +// induction variable recognition +// induction variable in two loops; recurrence in inner loop + + initialise_arrays(__func__); + + int k; + for (int nl = 0; nl < 10*(iterations/LEN_2D); nl++) { + k = 1; + for (int i = 0; i < LEN_2D; i++) { + for (int j = 1; j < LEN_2D; j++) { + bb[j][i] = bb[j-1][i] + flat_2d_array[k-1] * cc[j][i]; + ++k; + } + ++k; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s126, "s126", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s127.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s127.c new file mode 100644 index 0000000000..6f9a821664 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s127.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s127(struct args_t * func_args) +{ +// induction variable recognition +// induction variable with multiple increments + + initialise_arrays(__func__); + + int j; + for (int nl = 0; nl < 2*iterations; nl++) { + j = -1; + for (int i = 0; i < LEN_1D/2; i++) { + j++; + a[j] = b[i] + c[i] * d[i]; + j++; + a[j] = b[i] + d[i] * e[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s127, "s127", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1279.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1279.c new file mode 100644 index 0000000000..ead646d6a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1279.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1279(struct args_t * func_args) +{ +// control flow +// vector if/gotos + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (a[i] < (real_t)0.) { + if (b[i] > a[i]) { + c[i] += d[i] * e[i]; + } + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1279, "s1279", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s128.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s128.c new file mode 100644 index 0000000000..7b8874acec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s128.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s128(struct args_t * func_args) +{ +// induction variables +// coupled induction variables +// jump in data access + + initialise_arrays(__func__); + + int j, k; + for (int nl = 0; nl < 2*iterations; nl++) { + j = -1; + for (int i = 0; i < LEN_1D/2; i++) { + k = j + 1; + a[i] = b[k] - d[i]; + j = k + 1; + b[k] = a[i] + c[k]; + } + dummy(a, b, c, d, e, aa, bb, cc, 1.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s128, "s128", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1281.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1281.c new file mode 100644 index 0000000000..dba95a8197 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1281.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1281(struct args_t * func_args) +{ +// crossing thresholds +// index set splitting +// reverse data access + + initialise_arrays(__func__); + + real_t x; + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + x = b[i]*c[i] + a[i]*d[i] + e[i]; + a[i] = x-(real_t)1.0; + b[i] = x; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1281, "s1281", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s131.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s131.c new file mode 100644 index 0000000000..73f58a7ff4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s131.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s131(struct args_t * func_args) +{ +// global data flow analysis +// forward substitution + + initialise_arrays(__func__); + + int m = 1; + for (int nl = 0; nl < 5*iterations; nl++) { + for (int i = 0; i < LEN_1D - 1; i++) { + a[i] = a[i + m] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s131, "s131", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s13110.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s13110.c new file mode 100644 index 0000000000..4d2ef4c092 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s13110.c @@ -0,0 +1,51 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s13110(struct args_t * func_args) +{ +// reductions +// if to max with index reductio 2 dimensions + + initialise_arrays(__func__); + + int xindex, yindex; + real_t max, chksum; + for (int nl = 0; nl < 100*(iterations/(LEN_2D)); nl++) { + max = aa[(0)][0]; + xindex = 0; + yindex = 0; + for (int i = 0; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + if (aa[i][j] > max) { + max = aa[i][j]; + xindex = i; + yindex = j; + } + } + } + chksum = max + (real_t) xindex + (real_t) yindex; + dummy(a, b, c, d, e, aa, bb, cc, chksum); + } + + return max + xindex+1 + yindex+1; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s13110, "s13110", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s132.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s132.c new file mode 100644 index 0000000000..c2f5c2f275 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s132.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s132(struct args_t * func_args) +{ +// global data flow analysis +// loop with multiple dimension ambiguous subscripts + + initialise_arrays(__func__); + + int m = 0; + int j = m; + int k = m+1; + for (int nl = 0; nl < 400*iterations; nl++) { + for (int i= 1; i < LEN_2D; i++) { + aa[j][i] = aa[k][i-1] + b[i] * c[1]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s132, "s132", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1351.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1351.c new file mode 100644 index 0000000000..d020f909c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1351.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1351(struct args_t * func_args) +{ +// induction pointer recognition + + initialise_arrays(__func__); + + for (int nl = 0; nl < 8*iterations; nl++) { + real_t* __restrict__ A = a; + real_t* __restrict__ B = b; + real_t* __restrict__ C = c; + for (int i = 0; i < LEN_1D; i++) { + *A = *B+*C; + A++; + B++; + C++; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1351, "s1351", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s141.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s141.c new file mode 100644 index 0000000000..b8ef6a6982 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s141.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s141(struct args_t * func_args) +{ +// nonlinear dependence testing +// walk a row in a symmetric packed array +// element a(i,j) for (int j>i) stored in location j*(j-1)/2+i + + initialise_arrays(__func__); + + int k; + for (int nl = 0; nl < 200*(iterations/LEN_2D); nl++) { + for (int i = 0; i < LEN_2D; i++) { + k = (i+1) * ((i+1) - 1) / 2 + (i+1)-1; + for (int j = i; j < LEN_2D; j++) { + flat_2d_array[k] += bb[j][i]; + k += j+1; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s141, "s141", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1421.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1421.c new file mode 100644 index 0000000000..043989fe4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s1421.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s1421(struct args_t * func_args) +{ +// storage classes and equivalencing +// equivalence- no overlap + + initialise_arrays(__func__); + + xx = &b[LEN_1D/2]; + + for (int nl = 0; nl < 8*iterations; nl++) { + for (int i = 0; i < LEN_1D/2; i++) { + b[i] = xx[i] + a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 1.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s1421, "s1421", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s151.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s151.c new file mode 100644 index 0000000000..46f71814ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s151.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +void s151s(real_t a[LEN_1D], real_t b[LEN_1D], int m) +{ + for (int i = 0; i < LEN_1D-1; i++) { + a[i] = a[i + m] + b[i]; + } +} + +real_t s151(struct args_t * func_args) +{ +// interprocedural data flow analysis +// passing parameter information into a subroutine + + initialise_arrays(__func__); + + for (int nl = 0; nl < 5*iterations; nl++) { + s151s(a, b, 1); + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s151, "s151", NULL); + + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s152.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s152.c new file mode 100644 index 0000000000..d9c4186ba7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s152.c @@ -0,0 +1,46 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +void s152s(real_t a[LEN_1D], real_t b[LEN_1D], real_t c[LEN_1D], int i) +{ + a[i] += b[i] * c[i]; +} + +real_t s152(struct args_t * func_args) +{ +// interprocedural data flow analysis +// collecting information from a subroutine + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + b[i] = d[i] * e[i]; + s152s(a, b, c, i); + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s152, "s152", NULL); + + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s161.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s161.c new file mode 100644 index 0000000000..596d0e8f51 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s161.c @@ -0,0 +1,48 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s161(struct args_t * func_args) +{ +// control flow +// tests for recognition of loop independent dependences +// between statements in mutually exclusive regions. + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 0; i < LEN_1D-1; ++i) { + if (b[i] < (real_t)0.) { + goto L20; + } + a[i] = c[i] + d[i] * e[i]; + goto L10; +L20: + c[i+1] = a[i] + d[i] * d[i]; +L10: + ; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s161, "s161", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s162.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s162.c new file mode 100644 index 0000000000..521363d66f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s162.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s162(struct args_t * func_args) +{ +// control flow +// deriving assertions + + int k = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + if (k > 0) { + for (int i = 0; i < LEN_1D-1; i++) { + a[i] = a[i + k] + b[i] * c[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s162, "s162", &n1); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s171.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s171.c new file mode 100644 index 0000000000..291ec0ad35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s171.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s171(struct args_t * func_args) +{ +// symbolics +// symbolic dependence tests + + int inc = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i * inc] += b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s171, "s171", &n1); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s172.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s172.c new file mode 100644 index 0000000000..077f6e3810 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s172.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s172(struct args_t * func_args) +{ +// symbolics +// vectorizable if n3 .ne. 0 + + struct{int a;int b;} * x = func_args->arg_info; + int n1 = x->a; + int n3 = x->b; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = n1-1; i < LEN_1D; i += n3) { + a[i] += b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s172, "s172", &(struct{int a;int b;}){n1, n3}); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s173.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s173.c new file mode 100644 index 0000000000..4bd166b9a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s173.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s173(struct args_t * func_args) +{ +// symbolics +// expression in loop bounds and subscripts + + initialise_arrays(__func__); + + int k = LEN_1D/2; + for (int nl = 0; nl < 10*iterations; nl++) { + for (int i = 0; i < LEN_1D/2; i++) { + a[i+k] = a[i] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s173, "s173", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s174.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s174.c new file mode 100644 index 0000000000..a4df4da265 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s174.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s174(struct args_t * func_args) +{ +// symbolics +// loop with subscript that may seem ambiguous + + int M = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < 10*iterations; nl++) { + for (int i = 0; i < M; i++) { + a[i+M] = a[i] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s174, "s174", &(struct{int a;}){LEN_1D/2}); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s175.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s175.c new file mode 100644 index 0000000000..4bfb854eb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s175.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s175(struct args_t * func_args) +{ +// symbolics +// symbolic dependence tests + + int inc = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i += inc) { + a[i] = a[i + inc] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s175, "s175", &n1); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s176.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s176.c new file mode 100644 index 0000000000..365e520598 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s176.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s176(struct args_t * func_args) +{ +// symbolics +// convolution + + initialise_arrays(__func__); + + int m = LEN_1D/2; + for (int nl = 0; nl < 4*(10*iterations/LEN_1D); nl++) { + for (int j = 0; j < (LEN_1D/2); j++) { + for (int i = 0; i < m; i++) { + a[i] += b[i+m-j-1] * c[j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s176, "s176", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2101.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2101.c new file mode 100644 index 0000000000..ad6e586a9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2101.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s2101(struct args_t * func_args) +{ +// diagonals +// main diagonal calculation +// jump in data access + + initialise_arrays(__func__); + + for (int nl = 0; nl < 10*iterations; nl++) { + for (int i = 0; i < LEN_2D; i++) { + aa[i][i] += bb[i][i] * cc[i][i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2101, "s2101", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2102.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2102.c new file mode 100644 index 0000000000..dd00eb83c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2102.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s2102(struct args_t * func_args) +{ +// diagonals +// identity matrix, best results vectorize both inner and outer loops + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) { + for (int i = 0; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + aa[j][i] = (real_t)0.; + } + aa[i][i] = (real_t)1.; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2102, "s2102", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s211.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s211.c new file mode 100644 index 0000000000..5053322390 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s211.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s211(struct args_t * func_args) +{ +// statement reordering +// statement reordering allows vectorization + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 1; i < LEN_1D-1; i++) { + a[i] = b[i - 1] + c[i] * d[i]; + b[i] = b[i + 1] - e[i] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s211, "s211", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2111.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2111.c new file mode 100644 index 0000000000..42ff35f3cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2111.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s2111(struct args_t * func_args) +{ +// wavefronts, it will make jump in data access + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/(LEN_2D)); nl++) { + for (int j = 1; j < LEN_2D; j++) { + for (int i = 1; i < LEN_2D; i++) { + aa[j][i] = (aa[j][i-1] + aa[j-1][i])/1.9; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2111, "s2111", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s212.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s212.c new file mode 100644 index 0000000000..366b6780b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s212.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s212(struct args_t * func_args) +{ +// statement reordering +// dependency needing temporary + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i++) { + a[i] *= c[i]; + b[i] += a[i + 1] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s212, "s212", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s221.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s221.c new file mode 100644 index 0000000000..7f42c24e0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s221.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s221(struct args_t * func_args) +{ +// loop distribution +// loop that is partially recursive + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 1; i < LEN_1D; i++) { + a[i] += c[i] * d[i]; + b[i] = b[i - 1] + a[i] + d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s221, "s221", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s222.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s222.c new file mode 100644 index 0000000000..0cdb8cd0fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s222.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s222(struct args_t * func_args) +{ +// loop distribution +// partial loop vectorizatio recurrence in middle + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 1; i < LEN_1D; i++) { + a[i] += b[i] * c[i]; + e[i] = e[i - 1] * e[i - 1]; + a[i] -= b[i] * c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s222, "s222", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2233.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2233.c new file mode 100644 index 0000000000..c367c214ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2233.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s2233(struct args_t * func_args) +{ +// loop interchange +// interchanging with one of two inner loops + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) { + for (int i = 1; i < LEN_2D; i++) { + for (int j = 1; j < LEN_2D; j++) { + aa[j][i] = aa[j-1][i] + cc[j][i]; + } + for (int j = 1; j < LEN_2D; j++) { + bb[i][j] = bb[i-1][j] + cc[i][j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2233, "s2233", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2244.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2244.c new file mode 100644 index 0000000000..9b0ca7447d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2244.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s2244(struct args_t * func_args) +{ +// node splitting +// cycle with ture and anti dependency + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i++) { + a[i+1] = b[i] + e[i]; + a[i] = b[i] + c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2244, "s2244", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2251.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2251.c new file mode 100644 index 0000000000..980696bf7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2251.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s2251(struct args_t * func_args) +{ +// scalar and array expansion +// scalar expansion + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + real_t s = (real_t)0.0; + for (int i = 0; i < LEN_1D; i++) { + a[i] = s*e[i]; + s = b[i]+c[i]; + b[i] = a[i]+d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2251, "s2251", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2275.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2275.c new file mode 100644 index 0000000000..e182b83089 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2275.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s2275(struct args_t * func_args) +{ +// loop distribution is needed to be able to interchange + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) { + for (int i = 0; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + aa[j][i] = aa[j][i] + bb[j][i] * cc[j][i]; + } + a[i] = b[i] + c[i] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2275, "s2275", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s231.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s231.c new file mode 100644 index 0000000000..da523343e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s231.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s231(struct args_t * func_args) +{ +// loop interchange +// loop with data dependency + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) { + for (int i = 0; i < LEN_2D; ++i) { + for (int j = 1; j < LEN_2D; j++) { + aa[j][i] = aa[j - 1][i] + bb[j][i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s231, "s231", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s232.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s232.c new file mode 100644 index 0000000000..37bb310c67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s232.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s232(struct args_t * func_args) +{ +// loop interchange +// interchanging of triangular loops + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/(LEN_2D)); nl++) { + for (int j = 1; j < LEN_2D; j++) { + for (int i = 1; i <= j; i++) { + aa[j][i] = aa[j][i-1]*aa[j][i-1]+bb[j][i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 1.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s232, "s232", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s233.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s233.c new file mode 100644 index 0000000000..10f003a5be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s233.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s233(struct args_t * func_args) +{ +// loop interchange +// interchanging with one of two inner loops + + initialise_arrays(__func__); + + for (int nl = 0; nl < 100*(iterations/LEN_2D); nl++) { + for (int i = 1; i < LEN_2D; i++) { + for (int j = 1; j < LEN_2D; j++) { + aa[j][i] = aa[j-1][i] + cc[j][i]; + } + for (int j = 1; j < LEN_2D; j++) { + bb[j][i] = bb[j][i-1] + cc[j][i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s233, "s233", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s235.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s235.c new file mode 100644 index 0000000000..1340b20cf8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s235.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s235(struct args_t * func_args) +{ +// loop interchanging +// imperfectly nested loops + + initialise_arrays(__func__); + + for (int nl = 0; nl < 200*(iterations/LEN_2D); nl++) { + for (int i = 0; i < LEN_2D; i++) { + a[i] += b[i] * c[i]; + for (int j = 1; j < LEN_2D; j++) { + aa[j][i] = aa[j-1][i] + bb[j][i] * a[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s235, "s235", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s241.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s241.c new file mode 100644 index 0000000000..95652d1415 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s241.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-timeout-factor 1.5 } */ + +#include "tsvc.h" + +real_t s241(struct args_t * func_args) +{ +// node splitting +// preloading necessary to allow vectorization + + initialise_arrays(__func__); + + for (int nl = 0; nl < 2*iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i++) { + a[i] = b[i] * c[i ] * d[i]; + b[i] = a[i] * a[i+1] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s241, "s241", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s242.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s242.c new file mode 100644 index 0000000000..924c679375 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s242.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s242(struct args_t * func_args) +{ +// node splitting + + struct{real_t a;real_t b;} * x = func_args->arg_info; + real_t s1 = x->a; + real_t s2 = x->b; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/5; nl++) { + for (int i = 1; i < LEN_1D; ++i) { + a[i] = a[i - 1] + s1 + s2 + b[i] + c[i] + d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s242, "s242", &(struct{real_t a;real_t b;}){s1, s2}); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s243.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s243.c new file mode 100644 index 0000000000..6eb0240da4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s243.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s243(struct args_t * func_args) +{ +// node splitting +// false dependence cycle breaking + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i++) { + a[i] = b[i] + c[i ] * d[i]; + b[i] = a[i] + d[i ] * e[i]; + a[i] = b[i] + a[i+1] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s243, "s243", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s244.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s244.c new file mode 100644 index 0000000000..8886876335 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s244.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s244(struct args_t * func_args) +{ +// node splitting +// false dependence cycle breaking + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; ++i) { + a[i] = b[i] + c[i] * d[i]; + b[i] = c[i] + b[i]; + a[i+1] = b[i] + a[i+1] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s244, "s244", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s251.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s251.c new file mode 100644 index 0000000000..a648f94834 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s251.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s251(struct args_t * func_args) +{ +// scalar and array expansion +// scalar expansion + + initialise_arrays(__func__); + + real_t s; + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + s = b[i] + c[i] * d[i]; + a[i] = s * s; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s251, "s251", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s252.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s252.c new file mode 100644 index 0000000000..83eaa7a8ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s252.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s252(struct args_t * func_args) +{ +// scalar and array expansion +// loop with ambiguous scalar temporary + + initialise_arrays(__func__); + + real_t t, s; + for (int nl = 0; nl < iterations; nl++) { + t = (real_t) 0.; + for (int i = 0; i < LEN_1D; i++) { + s = b[i] * c[i]; + a[i] = s + t; + t = s; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s252, "s252", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s253.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s253.c new file mode 100644 index 0000000000..805d9a46ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s253.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s253(struct args_t * func_args) +{ +// scalar and array expansion +// scalar expansio assigned under if + + initialise_arrays(__func__); + + real_t s; + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (a[i] > b[i]) { + s = a[i] - b[i] * d[i]; + c[i] += s; + a[i] = s; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s253, "s253", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s254.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s254.c new file mode 100644 index 0000000000..92f00d8af6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s254.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-timeout-factor 2 } */ + +#include "tsvc.h" + +real_t s254(struct args_t * func_args) +{ +// scalar and array expansion +// carry around variable + + initialise_arrays(__func__); + + real_t x; + for (int nl = 0; nl < 4*iterations; nl++) { + x = b[LEN_1D-1]; + for (int i = 0; i < LEN_1D; i++) { + a[i] = (b[i] + x) * (real_t).5; + x = b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s254, "s254", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s255.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s255.c new file mode 100644 index 0000000000..c680ee124b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s255.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s255(struct args_t * func_args) +{ +// scalar and array expansion +// carry around variables, 2 levels + + initialise_arrays(__func__); + + real_t x, y; + for (int nl = 0; nl < iterations; nl++) { + x = b[LEN_1D-1]; + y = b[LEN_1D-2]; + for (int i = 0; i < LEN_1D; i++) { + a[i] = (b[i] + x + y) * (real_t).333; + y = x; + x = b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s255, "s255", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s256.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s256.c new file mode 100644 index 0000000000..2e18fa8cd9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s256.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s256(struct args_t * func_args) +{ +// scalar and array expansion +// array expansion + + initialise_arrays(__func__); + + for (int nl = 0; nl < 10*(iterations/LEN_2D); nl++) { + for (int i = 0; i < LEN_2D; i++) { + for (int j = 1; j < LEN_2D; j++) { + a[j] = (real_t)1.0 - a[j - 1]; + aa[j][i] = a[j] + bb[j][i]*d[j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s256, "s256", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s257.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s257.c new file mode 100644 index 0000000000..51e3504d0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s257.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s257(struct args_t * func_args) +{ +// scalar and array expansion +// array expansion + + initialise_arrays(__func__); + + for (int nl = 0; nl < 10*(iterations/LEN_2D); nl++) { + for (int i = 1; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + a[i] = aa[j][i] - a[i-1]; + aa[j][i] = a[i] + bb[j][i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s257, "s257", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s258.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s258.c new file mode 100644 index 0000000000..34f16a09eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s258.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s258(struct args_t * func_args) +{ +// scalar and array expansion +// wrap-around scalar under an if + + initialise_arrays(__func__); + + real_t s; + for (int nl = 0; nl < iterations; nl++) { + s = 0.; + for (int i = 0; i < LEN_2D; ++i) { + if (a[i] > 0.) { + s = d[i] * d[i]; + } + b[i] = s * c[i] + d[i]; + e[i] = (s + (real_t)1.) * aa[0][i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s258, "s258", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s261.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s261.c new file mode 100644 index 0000000000..6edb1a5cb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s261.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s261(struct args_t * func_args) +{ +// scalar and array expansion +// wrap-around scalar under an if + + initialise_arrays(__func__); + + real_t t; + for (int nl = 0; nl < iterations; nl++) { + for (int i = 1; i < LEN_1D; ++i) { + t = a[i] + b[i]; + a[i] = t + c[i-1]; + t = c[i] * d[i]; + c[i] = t; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s261, "s261", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s271.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s271.c new file mode 100644 index 0000000000..90f6461cfd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s271.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-timeout-factor 2 } */ + +#include "tsvc.h" + +real_t s271(struct args_t * func_args) +{ +// control flow +// loop with singularity handling + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (b[i] > (real_t)0.) { + a[i] += b[i] * c[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s271, "s271", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2710.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2710.c new file mode 100644 index 0000000000..19d84841b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2710.c @@ -0,0 +1,55 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s2710(struct args_t * func_args) +{ +// control flow +// scalar and vector ifs + + int x = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (a[i] > b[i]) { + a[i] += b[i] * d[i]; + if (LEN_1D > 10) { + c[i] += d[i] * d[i]; + } else { + c[i] = d[i] * e[i] + (real_t)1.; + } + } else { + b[i] = a[i] + e[i] * e[i]; + if (x > (real_t)0.) { + c[i] = a[i] + d[i] * d[i]; + } else { + c[i] += e[i] * e[i]; + } + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2710, "s2710", &s1); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2711.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2711.c new file mode 100644 index 0000000000..ddc32e2250 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2711.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-timeout-factor 2 } */ + +#include "tsvc.h" + +real_t s2711(struct args_t * func_args) +{ +// control flow +// semantic if removal + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (b[i] != (real_t)0.0) { + a[i] += b[i] * c[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2711, "s2711", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2712.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2712.c new file mode 100644 index 0000000000..5750f9df1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s2712.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-timeout-factor 2 } */ + +#include "tsvc.h" + +real_t s2712(struct args_t * func_args) +{ +// control flow +// if to elemental min + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (a[i] >= b[i]) { + a[i] += b[i] * c[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s2712, "s2712", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s272.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s272.c new file mode 100644 index 0000000000..44ea7ec502 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s272.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s272(struct args_t * func_args) +{ +// control flow +// loop with independent conditional + + int t = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (e[i] >= t) { + a[i] += c[i] * d[i]; + b[i] += c[i] * c[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s272, "s272", &s1); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s273.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s273.c new file mode 100644 index 0000000000..84967223a9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s273.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s273(struct args_t * func_args) +{ +// control flow +// simple loop with dependent conditional + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] += d[i] * e[i]; + if (a[i] < (real_t)0.) + b[i] += d[i] * e[i]; + c[i] += a[i] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s273, "s273", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s274.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s274.c new file mode 100644 index 0000000000..a03971e993 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s274.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s274(struct args_t * func_args) +{ +// control flow +// complex loop with dependent conditional + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = c[i] + e[i] * d[i]; + if (a[i] > (real_t)0.) { + b[i] = a[i] + b[i]; + } else { + a[i] = d[i] * e[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s274, "s274", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s275.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s275.c new file mode 100644 index 0000000000..929cf11b75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s275.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s275(struct args_t * func_args) +{ +// control flow +// if around inner loop, interchanging needed + + initialise_arrays(__func__); + + for (int nl = 0; nl < 10*(iterations/LEN_2D); nl++) { + for (int i = 0; i < LEN_2D; i++) { + if (aa[0][i] > (real_t)0.) { + for (int j = 1; j < LEN_2D; j++) { + aa[j][i] = aa[j-1][i] + bb[j][i] * cc[j][i]; + } + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s275, "s275", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s276.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s276.c new file mode 100644 index 0000000000..d383cd0294 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s276.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-timeout-factor 2 } */ + +#include "tsvc.h" + +real_t s276(struct args_t * func_args) +{ +// control flow +// if test using loop index + + initialise_arrays(__func__); + + int mid = (LEN_1D/2); + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (i+1 < mid) { + a[i] += b[i] * c[i]; + } else { + a[i] += b[i] * d[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s276, "s276", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s277.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s277.c new file mode 100644 index 0000000000..5904b6384b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s277.c @@ -0,0 +1,49 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s277(struct args_t * func_args) +{ +// control flow +// test for dependences arising from guard variable computation. + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i++) { + if (a[i] >= (real_t)0.) { + goto L20; + } + if (b[i] >= (real_t)0.) { + goto L30; + } + a[i] += c[i] * d[i]; +L30: + b[i+1] = c[i] + d[i] * e[i]; +L20: +; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s277, "s277", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s278.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s278.c new file mode 100644 index 0000000000..cd9d28b64a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s278.c @@ -0,0 +1,47 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s278(struct args_t * func_args) +{ +// control flow +// if/goto to block if-then-else + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (a[i] > (real_t)0.) { + goto L20; + } + b[i] = -b[i] + d[i] * e[i]; + goto L30; +L20: + c[i] = -c[i] + d[i] * e[i]; +L30: + a[i] = b[i] + c[i] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s278, "s278", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s279.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s279.c new file mode 100644 index 0000000000..bb49437098 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s279.c @@ -0,0 +1,51 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s279(struct args_t * func_args) +{ +// control flow +// vector if/gotos + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (a[i] > (real_t)0.) { + goto L20; + } + b[i] = -b[i] + d[i] * d[i]; + if (b[i] <= a[i]) { + goto L30; + } + c[i] += d[i] * e[i]; + goto L30; +L20: + c[i] = -c[i] + e[i] * e[i]; +L30: + a[i] = b[i] + c[i] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s279, "s279", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s281.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s281.c new file mode 100644 index 0000000000..d60f2ea3f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s281.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s281(struct args_t * func_args) +{ +// crossing thresholds +// index set splitting +// reverse data access + + initialise_arrays(__func__); + + real_t x; + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + x = a[LEN_1D-i-1] + b[i] * c[i]; + a[i] = x-(real_t)1.0; + b[i] = x; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s281, "s281", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s291.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s291.c new file mode 100644 index 0000000000..91cdc12109 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s291.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s291(struct args_t * func_args) +{ +// loop peeling +// wrap around variable, 1 level + + initialise_arrays(__func__); + + int im1; + for (int nl = 0; nl < 2*iterations; nl++) { + im1 = LEN_1D-1; + for (int i = 0; i < LEN_1D; i++) { + a[i] = (b[i] + b[im1]) * (real_t).5; + im1 = i; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s291, "s291", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s292.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s292.c new file mode 100644 index 0000000000..174587563d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s292.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s292(struct args_t * func_args) +{ +// loop peeling +// wrap around variable, 2 levels +// similar to S291 + + initialise_arrays(__func__); + + int im1, im2; + for (int nl = 0; nl < iterations; nl++) { + im1 = LEN_1D-1; + im2 = LEN_1D-2; + for (int i = 0; i < LEN_1D; i++) { + a[i] = (b[i] + b[im1] + b[im2]) * (real_t).333; + im2 = im1; + im1 = i; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s292, "s292", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s293.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s293.c new file mode 100644 index 0000000000..321394811c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s293.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s293(struct args_t * func_args) +{ +// loop peeling +// a(i)=a(0) with actual dependence cycle, loop is vectorizable + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = a[0]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s293, "s293", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s311.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s311.c new file mode 100644 index 0000000000..11f5ee79fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s311.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s311(struct args_t * func_args) +{ +// reductions +// sum reduction + + initialise_arrays(__func__); + + real_t sum; + for (int nl = 0; nl < iterations*10; nl++) { + sum = (real_t)0.; + for (int i = 0; i < LEN_1D; i++) { + sum += a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, sum); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s311, "s311", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3110.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3110.c new file mode 100644 index 0000000000..b8b2fa8f00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3110.c @@ -0,0 +1,52 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s3110(struct args_t * func_args) +{ +// reductions +// if to max with index reductio 2 dimensions +// similar to S315 + + initialise_arrays(__func__); + + int xindex, yindex; + real_t max, chksum; + for (int nl = 0; nl < 100*(iterations/(LEN_2D)); nl++) { + max = aa[(0)][0]; + xindex = 0; + yindex = 0; + for (int i = 0; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + if (aa[i][j] > max) { + max = aa[i][j]; + xindex = i; + yindex = j; + } + } + } + chksum = max + (real_t) xindex + (real_t) yindex; + dummy(a, b, c, d, e, aa, bb, cc, chksum); + } + + return max + xindex+1 + yindex+1; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s3110, "s3110", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3111.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3111.c new file mode 100644 index 0000000000..4163dd8e42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3111.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s3111(struct args_t * func_args) +{ +// reductions +// conditional sum reduction + + initialise_arrays(__func__); + + real_t sum; + for (int nl = 0; nl < iterations/2; nl++) { + sum = 0.; + for (int i = 0; i < LEN_1D; i++) { + if (a[i] > (real_t)0.) { + sum += a[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, sum); + } + + return sum; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s3111, "s31111", NULL); + + return 0; +} + + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s31111.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s31111.c new file mode 100644 index 0000000000..ad2151357b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s31111.c @@ -0,0 +1,54 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t test(real_t* A){ + real_t s = (real_t)0.0; + for (int i = 0; i < 4; i++) + s += A[i]; + return s; +} + +real_t s31111(struct args_t * func_args) +{ +// reductions +// sum reduction + + initialise_arrays(__func__); + + real_t sum; + for (int nl = 0; nl < 2000*iterations; nl++) { + sum = (real_t)0.; + sum += test(a); + sum += test(&a[4]); + sum += test(&a[8]); + sum += test(&a[12]); + sum += test(&a[16]); + sum += test(&a[20]); + sum += test(&a[24]); + sum += test(&a[28]); + dummy(a, b, c, d, e, aa, bb, cc, sum); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s31111, "s31111", NULL); + + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3112.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3112.c new file mode 100644 index 0000000000..ec81ad8097 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3112.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s3112(struct args_t * func_args) +{ +// reductions +// sum reduction saving running sums + + initialise_arrays(__func__); + + real_t sum; + for (int nl = 0; nl < iterations; nl++) { + sum = (real_t)0.0; + for (int i = 0; i < LEN_1D; i++) { + sum += a[i]; + b[i] = sum; + } + dummy(a, b, c, d, e, aa, bb, cc, sum); + } + + return sum; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s3112, "s3112", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3113.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3113.c new file mode 100644 index 0000000000..bff35ca058 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3113.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s3113(struct args_t * func_args) +{ +// reductions +// maximum of absolute value + + initialise_arrays(__func__); + + real_t max; + for (int nl = 0; nl < iterations*4; nl++) { + max = ABS(a[0]); + for (int i = 0; i < LEN_1D; i++) { + if ((ABS(a[i])) > max) { + max = ABS(a[i]); + } + } + dummy(a, b, c, d, e, aa, bb, cc, max); + } + + return max; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s3113, "s3113", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s312.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s312.c new file mode 100644 index 0000000000..ab0571aedc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s312.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s312(struct args_t * func_args) +{ +// reductions +// product reduction + + initialise_arrays(__func__); + + real_t prod; + for (int nl = 0; nl < 10*iterations; nl++) { + prod = (real_t)1.; + for (int i = 0; i < LEN_1D; i++) { + prod *= a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, prod); + } + + return prod; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s312, "s312", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s313.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s313.c new file mode 100644 index 0000000000..e58a5391f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s313.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s313(struct args_t * func_args) +{ +// reductions +// dot product + + initialise_arrays(__func__); + + real_t dot; + for (int nl = 0; nl < iterations*5; nl++) { + dot = (real_t)0.; + for (int i = 0; i < LEN_1D; i++) { + dot += a[i] * b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, dot); + } + + return dot; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s313, "s313", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s314.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s314.c new file mode 100644 index 0000000000..87dd706e01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s314.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s314(struct args_t * func_args) +{ +// reductions +// if to max reduction + + initialise_arrays(__func__); + + real_t x; + for (int nl = 0; nl < iterations*5; nl++) { + x = a[0]; + for (int i = 0; i < LEN_1D; i++) { + if (a[i] > x) { + x = a[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, x); + } + + return x; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s314, "s314", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s315.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s315.c new file mode 100644 index 0000000000..8d734a0f7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s315.c @@ -0,0 +1,50 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s315(struct args_t * func_args) +{ +// reductions +// if to max with index reductio 1 dimension + + initialise_arrays(__func__); + + for (int i = 0; i < LEN_1D; i++) + a[i] = (i * 7) % LEN_1D; + + real_t x, chksum; + int index; + for (int nl = 0; nl < iterations; nl++) { + x = a[0]; + index = 0; + for (int i = 0; i < LEN_1D; ++i) { + if (a[i] > x) { + x = a[i]; + index = i; + } + } + chksum = x + (real_t) index; + dummy(a, b, c, d, e, aa, bb, cc, chksum); + } + + return index + x + 1; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s315, "s315", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s316.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s316.c new file mode 100644 index 0000000000..4a711bcc89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s316.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s316(struct args_t * func_args) +{ +// reductions +// if to min reduction + + initialise_arrays(__func__); + + real_t x; + for (int nl = 0; nl < iterations*5; nl++) { + x = a[0]; + for (int i = 1; i < LEN_1D; ++i) { + if (a[i] < x) { + x = a[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, x); + } + + return x; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s316, "s316", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s317.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s317.c new file mode 100644 index 0000000000..126b4521db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s317.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s317(struct args_t * func_args) +{ +// reductions +// product reductio vectorize with +// 1. scalar expansion of factor, and product reduction +// 2. closed form solution: q = factor**n + + initialise_arrays(__func__); + + real_t q; + for (int nl = 0; nl < 5*iterations; nl++) { + q = (real_t)1.; + for (int i = 0; i < LEN_1D/2; i++) { + q *= (real_t).99; + } + dummy(a, b, c, d, e, aa, bb, cc, q); + } + + return q; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s317, "s317", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s318.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s318.c new file mode 100644 index 0000000000..f4e1a4b484 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s318.c @@ -0,0 +1,54 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s318(struct args_t * func_args) +{ +// reductions +// isamax, max absolute value, increments not equal to 1 + + int inc = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + int k, index; + real_t max, chksum; + for (int nl = 0; nl < iterations/2; nl++) { + k = 0; + index = 0; + max = ABS(a[0]); + k += inc; + for (int i = 1; i < LEN_1D; i++) { + if (ABS(a[k]) <= max) { + goto L5; + } + index = i; + max = ABS(a[k]); +L5: + k += inc; + } + chksum = max + (real_t) index; + dummy(a, b, c, d, e, aa, bb, cc, chksum); + } + + return max + index + 1; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s318, "s318", &n1); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s319.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s319.c new file mode 100644 index 0000000000..dbb0bd3d5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s319.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s319(struct args_t * func_args) +{ +// reductions +// coupled reductions + + initialise_arrays(__func__); + + real_t sum; + for (int nl = 0; nl < 2*iterations; nl++) { + sum = 0.; + for (int i = 0; i < LEN_1D; i++) { + a[i] = c[i] + d[i]; + sum += a[i]; + b[i] = c[i] + e[i]; + sum += b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, sum); + } + + return sum; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s319, "s319", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s321.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s321.c new file mode 100644 index 0000000000..3011e56ad1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s321.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s321(struct args_t * func_args) +{ +// recurrences +// first order linear recurrence + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 1; i < LEN_1D; i++) { + a[i] += a[i-1] * b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s321, "s321", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s322.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s322.c new file mode 100644 index 0000000000..075e8117d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s322.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s322(struct args_t * func_args) +{ +// recurrences +// second order linear recurrence + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 2; i < LEN_1D; i++) { + a[i] = a[i] + a[i - 1] * b[i] + a[i - 2] * c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s322, "s322", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s323.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s323.c new file mode 100644 index 0000000000..c95345d561 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s323.c @@ -0,0 +1,40 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s323(struct args_t * func_args) +{ +// recurrences +// coupled recurrence + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 1; i < LEN_1D; i++) { + a[i] = b[i-1] + c[i] * d[i]; + b[i] = a[i] + c[i] * e[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s323, "s323", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3251.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3251.c new file mode 100644 index 0000000000..51ca17396b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s3251.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s3251(struct args_t * func_args) +{ +// scalar and array expansion +// scalar expansion + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D-1; i++){ + a[i+1] = b[i]+c[i]; + b[i] = c[i]*e[i]; + d[i] = a[i]*e[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s3251, "s3251", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s331.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s331.c new file mode 100644 index 0000000000..e580df75b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s331.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s331(struct args_t * func_args) +{ +// search loops +// if to last-1 + + initialise_arrays(__func__); + + int j; + real_t chksum; + for (int nl = 0; nl < iterations; nl++) { + j = -1; + for (int i = 0; i < LEN_1D; i++) { + if (a[i] < (real_t)0.) { + j = i; + } + } + chksum = (real_t) j; + dummy(a, b, c, d, e, aa, bb, cc, chksum); + } + + return j+1; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s331, "s331", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s332.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s332.c new file mode 100644 index 0000000000..0d55d0dd67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s332.c @@ -0,0 +1,53 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options vect_early_break } */ + +#include "tsvc.h" + +real_t s332(struct args_t * func_args) +{ +// search loops +// first value greater than threshold + + int t = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + int index; + real_t value; + real_t chksum; + for (int nl = 0; nl < iterations; nl++) { + index = -2; + value = -1.; + for (int i = 0; i < LEN_1D; i++) { + if (a[i] > t) { + index = i; + value = a[i]; + goto L20; + } + } +L20: + chksum = value + (real_t) index; + dummy(a, b, c, d, e, aa, bb, cc, chksum); + } + + return value; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s332, "s332", &s1); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { ! vect_early_break } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s341.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s341.c new file mode 100644 index 0000000000..2aa2fa5119 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s341.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s341(struct args_t * func_args) +{ +// packing +// pack positive values +// not vectorizable, value of j in unknown at each iteration + + initialise_arrays(__func__); + + int j; + for (int nl = 0; nl < iterations; nl++) { + j = -1; + for (int i = 0; i < LEN_1D; i++) { + if (b[i] > (real_t)0.) { + j++; + a[j] = b[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s341, "s341", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s342.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s342.c new file mode 100644 index 0000000000..a2af1c76b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s342.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s342(struct args_t * func_args) +{ +// packing +// unpacking +// not vectorizable, value of j in unknown at each iteration + + initialise_arrays(__func__); + + int j = 0; + for (int nl = 0; nl < iterations; nl++) { + j = -1; + for (int i = 0; i < LEN_1D; i++) { + if (a[i] > (real_t)0.) { + j++; + a[i] = b[j]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s342, "s342", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s343.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s343.c new file mode 100644 index 0000000000..d76c882796 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s343.c @@ -0,0 +1,47 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s343(struct args_t * func_args) +{ +// packing +// pack 2-d array into one dimension +// not vectorizable, value of k in unknown at each iteration + + initialise_arrays(__func__); + + int k; + for (int nl = 0; nl < 10*(iterations/LEN_2D); nl++) { + k = -1; + for (int i = 0; i < LEN_2D; i++) { + for (int j = 0; j < LEN_2D; j++) { + if (bb[j][i] > (real_t)0.) { + k++; + flat_2d_array[k] = aa[j][i]; + } + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s343, "s343", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s351.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s351.c new file mode 100644 index 0000000000..b5875d1803 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s351.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s351(struct args_t * func_args) +{ +// loop rerolling +// unrolled saxpy + + initialise_arrays(__func__); + + real_t alpha = c[0]; + for (int nl = 0; nl < 8*iterations; nl++) { + for (int i = 0; i < LEN_1D; i += 5) { + a[i] += alpha * b[i]; + a[i + 1] += alpha * b[i + 1]; + a[i + 2] += alpha * b[i + 2]; + a[i + 3] += alpha * b[i + 3]; + a[i + 4] += alpha * b[i + 4]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s351, "s351", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s352.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s352.c new file mode 100644 index 0000000000..11d2412a05 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s352.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s352(struct args_t * func_args) +{ +// loop rerolling +// unrolled dot product + + initialise_arrays(__func__); + + real_t dot; + for (int nl = 0; nl < 8*iterations; nl++) { + dot = (real_t)0.; + for (int i = 0; i < LEN_1D; i += 5) { + dot = dot + a[i] * b[i] + a[i + 1] * b[i + 1] + a[i + 2] + * b[i + 2] + a[i + 3] * b[i + 3] + a[i + 4] * b[i + 4]; + } + dummy(a, b, c, d, e, aa, bb, cc, dot); + } + + return dot; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s352, "s352", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s353.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s353.c new file mode 100644 index 0000000000..2c4fa3f599 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s353.c @@ -0,0 +1,47 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s353(struct args_t * func_args) +{ +// loop rerolling +// unrolled sparse saxpy +// gather is required + + int * __restrict__ ip = func_args->arg_info; + + initialise_arrays(__func__); + + real_t alpha = c[0]; + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i += 5) { + a[i] += alpha * b[ip[i]]; + a[i + 1] += alpha * b[ip[i + 1]]; + a[i + 2] += alpha * b[ip[i + 2]]; + a[i + 3] += alpha * b[ip[i + 3]]; + a[i + 4] += alpha * b[ip[i + 4]]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s353, "s353", ip); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4112.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4112.c new file mode 100644 index 0000000000..bca9a1b10c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4112.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s4112(struct args_t * func_args) +{ +// indirect addressing +// sparse saxpy +// gather is required + + struct{int * __restrict__ a;real_t b;} * x = func_args->arg_info; + int * __restrict__ ip = x->a; + real_t s = x->b; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] += b[ip[i]] * s; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s4112, "s4112", &(struct{int*a;real_t b;}){ip, s1}); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4113.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4113.c new file mode 100644 index 0000000000..ddb7e9dc0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4113.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s4113(struct args_t * func_args) +{ +// indirect addressing +// indirect addressing on rhs and lhs +// gather and scatter is required + + int * __restrict__ ip = func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[ip[i]] = b[ip[i]] + c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s4113, "s4113", ip); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4114.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4114.c new file mode 100644 index 0000000000..b305900e44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4114.c @@ -0,0 +1,47 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s4114(struct args_t * func_args) +{ +// indirect addressing +// mix indirect addressing with variable lower and upper bounds +// gather is required + + struct{int * __restrict__ a;int b;} * x = func_args->arg_info; + int * __restrict__ ip = x->a; + int n1 = x->b; + + initialise_arrays(__func__); + + int k; + for (int nl = 0; nl < iterations; nl++) { + for (int i = n1-1; i < LEN_1D; i++) { + k = ip[i]; + a[i] = b[i] + c[LEN_1D-k+1-2] * d[i]; + k += 5; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s4114, "s4114", &(struct{int*a;int b;}){ip, n1}); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4115.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4115.c new file mode 100644 index 0000000000..f85e75e471 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4115.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s4115(struct args_t * func_args) +{ +// indirect addressing +// sparse dot product +// gather is required + + int * __restrict__ ip = func_args->arg_info; + + initialise_arrays(__func__); + + real_t sum; + for (int nl = 0; nl < iterations; nl++) { + sum = 0.; + for (int i = 0; i < LEN_1D; i++) { + sum += a[i] * b[ip[i]]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return sum; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s4115, "s4115", ip); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4116.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4116.c new file mode 100644 index 0000000000..95a771ec0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4116.c @@ -0,0 +1,49 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s4116(struct args_t * func_args) +{ +// indirect addressing +// more complicated sparse sdot +// gather is required + + struct{int * __restrict__ a;int b;int c;} * x = func_args->arg_info; + int * __restrict__ ip = x->a; + int j = x->b; + int inc = x->c; + + initialise_arrays(__func__); + + real_t sum; + int off; + for (int nl = 0; nl < 100*iterations; nl++) { + sum = 0.; + for (int i = 0; i < LEN_2D-1; i++) { + off = inc + i; + sum += a[off] * aa[j-1][ip[i]]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return sum; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s4116, "s4116", &(struct{int * a; int b; int c;}){ip, LEN_2D/2, n1}); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4117.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4117.c new file mode 100644 index 0000000000..a1d757b7d0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4117.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s4117(struct args_t * func_args) +{ +// indirect addressing +// seq function + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = b[i] + c[i/2] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s4117, "s4117", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4121.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4121.c new file mode 100644 index 0000000000..54aa9d07c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s4121.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t f(real_t a, real_t b){ + return a*b; +} + +real_t s4121(struct args_t * func_args) +{ +// statement functions +// elementwise multiplication + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] += f(b[i],c[i]); + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s4121, "s4121", NULL); + + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s421.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s421.c new file mode 100644 index 0000000000..e6c00c5bde --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s421.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s421(struct args_t * func_args) +{ +// storage classes and equivalencing +// equivalence- no overlap + + initialise_arrays(__func__); + + xx = flat_2d_array; + + for (int nl = 0; nl < 4*iterations; nl++) { + yy = xx; + for (int i = 0; i < LEN_1D - 1; i++) { + xx[i] = yy[i+1] + a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 1.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s421, "s421", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s422.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s422.c new file mode 100644 index 0000000000..4d491da530 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s422.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s422(struct args_t * func_args) +{ +// storage classes and equivalencing +// common and equivalence statement +// anti-dependence, threshold of 4 + + initialise_arrays(__func__); + + xx = flat_2d_array + 4; + + for (int nl = 0; nl < 8*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + xx[i] = flat_2d_array[i + 8] + a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s422, "s422", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s423.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s423.c new file mode 100644 index 0000000000..7605f0575c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s423.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s423(struct args_t * func_args) +{ +// storage classes and equivalencing +// common and equivalenced variables - with anti-dependence + + // do this again here + int vl = 64; + xx = flat_2d_array + vl; + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D - 1; i++) { + flat_2d_array[i+1] = xx[i] + a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 1.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s423, "s423", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s424.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s424.c new file mode 100644 index 0000000000..211f2d4ab0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s424.c @@ -0,0 +1,44 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s424(struct args_t * func_args) +{ +// storage classes and equivalencing +// common and equivalenced variables - overlap +// vectorizeable in strips of 64 or less + + // do this again here + int vl = 63; + xx = flat_2d_array + vl; + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D - 1; i++) { + xx[i+1] = flat_2d_array[i] + a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 1.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s424, "s424", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s431.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s431.c new file mode 100644 index 0000000000..f2b03588db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s431.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s431(struct args_t * func_args) +{ +// parameters +// parameter statement + + int k1=1; + int k2=2; + int k=2*k1-k2; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations*10; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = a[i+k] + b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s431, "s431", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s441.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s441.c new file mode 100644 index 0000000000..480e5975a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s441.c @@ -0,0 +1,45 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s441(struct args_t * func_args) +{ +// non-logical if's +// arithmetic if + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (d[i] < (real_t)0.) { + a[i] += b[i] * c[i]; + } else if (d[i] == (real_t)0.) { + a[i] += b[i] * b[i]; + } else { + a[i] += c[i] * c[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s441, "s441", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s442.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s442.c new file mode 100644 index 0000000000..22fad600a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s442.c @@ -0,0 +1,57 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s442(struct args_t * func_args) +{ +// non-logical if's +// computed goto + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 0; i < LEN_1D; i++) { + switch (indx[i]) { + case 1: goto L15; + case 2: goto L20; + case 3: goto L30; + case 4: goto L40; + } +L15: + a[i] += b[i] * b[i]; + goto L50; +L20: + a[i] += c[i] * c[i]; + goto L50; +L30: + a[i] += d[i] * d[i]; + goto L50; +L40: + a[i] += e[i] * e[i]; +L50: + ; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s442, "s442", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s443.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s443.c new file mode 100644 index 0000000000..709413fa6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s443.c @@ -0,0 +1,50 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s443(struct args_t * func_args) +{ +// non-logical if's +// arithmetic if + + initialise_arrays(__func__); + + for (int nl = 0; nl < 2*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (d[i] <= (real_t)0.) { + goto L20; + } else { + goto L30; + } +L20: + a[i] += b[i] * c[i]; + goto L50; +L30: + a[i] += b[i] * b[i]; +L50: + ; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s443, "s443", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s451.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s451.c new file mode 100644 index 0000000000..ac0c9acc79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s451.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s451(struct args_t * func_args) +{ +// intrinsic functions +// intrinsics + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/5; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = sinf(b[i]) + cosf(c[i]); + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s451, "s451", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s452.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s452.c new file mode 100644 index 0000000000..fe97c4d40f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s452.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s452(struct args_t * func_args) +{ +// intrinsic functions +// seq function + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = b[i] + c[i] * (real_t) (i+1); + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s452, "s452", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s453.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s453.c new file mode 100644 index 0000000000..1fc1d66ea7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s453.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s453(struct args_t * func_args) +{ +// induction varibale recognition + + real_t s; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations*2; nl++) { + s = 0.; + for (int i = 0; i < LEN_1D; i++) { + s += (real_t)2.; + a[i] = s * b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s453, "s453", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s471.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s471.c new file mode 100644 index 0000000000..b842ddaeed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s471.c @@ -0,0 +1,49 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +int s471s(void) +{ +// -- dummy subroutine call made in s471 + return 0; +} + +real_t s471(struct args_t * func_args){ + +// call statements + + int m = LEN_1D; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations/2; nl++) { + for (int i = 0; i < m; i++) { + x[i] = b[i] + d[i] * d[i]; + s471s(); + b[i] = c[i] + d[i] * e[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s471, "s471", NULL); + + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s481.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s481.c new file mode 100644 index 0000000000..5539f0f084 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s481.c @@ -0,0 +1,43 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options vect_early_break } */ + +#include "tsvc.h" + +real_t s481(struct args_t * func_args) +{ +// non-local goto's +// stop statement + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (d[i] < (real_t)0.) { + exit (0); + } + a[i] += b[i] * c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s481, "s481", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { ! vect_early_break} } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s482.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s482.c new file mode 100644 index 0000000000..73bed5d4c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s482.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options vect_early_break } */ + +#include "tsvc.h" + +real_t s482(struct args_t * func_args) +{ +// non-local goto's +// other loop exit with code before exit + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] += b[i] * c[i]; + if (c[i] > b[i]) break; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s482, "s482", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { ! vect_early_break } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s491.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s491.c new file mode 100644 index 0000000000..29e90ff0af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-s491.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t s491(struct args_t * func_args) +{ +// vector semantics +// indirect addressing on lhs, store in sequence +// scatter is required + + int * __restrict__ ip = func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[ip[i]] = b[i] + c[i] * d[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&s491, "s491", ip); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-va.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-va.c new file mode 100644 index 0000000000..441b5bda21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-va.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t va(struct args_t * func_args) +{ +// control loops +// vector assignment + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations*10; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&va, "va", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vag.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vag.c new file mode 100644 index 0000000000..9213b2787b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vag.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vag(struct args_t * func_args) +{ +// control loops +// vector assignment, gather +// gather is required + + int * __restrict__ ip = func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < 2*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = b[ip[i]]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vag, "vag", ip); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vas.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vas.c new file mode 100644 index 0000000000..b72ee21a9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vas.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vas(struct args_t * func_args) +{ +// control loops +// vector assignment, scatter +// scatter is required + + int * __restrict__ ip = func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < 2*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[ip[i]] = b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vas, "vas", ip); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vbor.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vbor.c new file mode 100644 index 0000000000..801410db29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vbor.c @@ -0,0 +1,54 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vbor(struct args_t * func_args) +{ +// control loops +// basic operations rates, isolate arithmetic from memory traffic +// all combinations of three, 59 flops for 6 loads and 1 store. + + initialise_arrays(__func__); + + real_t a1, b1, c1, d1, e1, f1; + for (int nl = 0; nl < iterations*10; nl++) { + for (int i = 0; i < LEN_2D; i++) { + a1 = a[i]; + b1 = b[i]; + c1 = c[i]; + d1 = d[i]; + e1 = e[i]; + f1 = aa[0][i]; + a1 = a1 * b1 * c1 + a1 * b1 * d1 + a1 * b1 * e1 + a1 * b1 * f1 + + a1 * c1 * d1 + a1 * c1 * e1 + a1 * c1 * f1 + a1 * d1 * e1 + + a1 * d1 * f1 + a1 * e1 * f1; + b1 = b1 * c1 * d1 + b1 * c1 * e1 + b1 * c1 * f1 + b1 * d1 * e1 + + b1 * d1 * f1 + b1 * e1 * f1; + c1 = c1 * d1 * e1 + c1 * d1 * f1 + c1 * e1 * f1; + d1 = d1 * e1 * f1; + x[i] = a1 * b1 * c1 * d1; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vbor, "vbor", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vdotr.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vdotr.c new file mode 100644 index 0000000000..013d3f4473 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vdotr.c @@ -0,0 +1,42 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-timeout-factor 2 } */ + +#include "tsvc.h" + +real_t vdotr(struct args_t * func_args) +{ +// control loops +// vector dot product reduction + + initialise_arrays(__func__); + + real_t dot; + for (int nl = 0; nl < iterations*10; nl++) { + dot = 0.; + for (int i = 0; i < LEN_1D; i++) { + dot += a[i] * b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, dot); + } + + return dot; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vdotr, "vdotr", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vif.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vif.c new file mode 100644 index 0000000000..6eba46403b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vif.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vif(struct args_t * func_args) +{ +// control loops +// vector if + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + if (b[i] > (real_t)0.) { + a[i] = b[i]; + } + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vif, "vif", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail { { ! aarch64_sve } && { ! riscv_v } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpv.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpv.c new file mode 100644 index 0000000000..232904f887 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpv.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vpv(struct args_t * func_args) +{ +// control loops +// vector plus vector + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations*10; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] += b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vpv, "vpv", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvpv.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvpv.c new file mode 100644 index 0000000000..b4d085016f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvpv.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vpvpv(struct args_t * func_args) +{ +// control loops +// vector plus vector plus vector + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] += b[i] + c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vpvpv, "vpvpv", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvts.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvts.c new file mode 100644 index 0000000000..f193afa572 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvts.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vpvts(struct args_t * func_args) +{ +// control loops +// vector plus vector times scalar + + real_t s = *(int*)func_args->arg_info; + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] += b[i] * s; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vpvts, "vpvts", &s1); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvtv.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvtv.c new file mode 100644 index 0000000000..b726b27e5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vpvtv.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vpvtv(struct args_t * func_args) +{ +// control loops +// vector plus vector times vector + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] += b[i] * c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vpvtv, "vpvtv", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vsumr.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vsumr.c new file mode 100644 index 0000000000..0847eaed1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vsumr.c @@ -0,0 +1,41 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vsumr(struct args_t * func_args) +{ +// control loops +// vector sum reduction + + initialise_arrays(__func__); + + real_t sum; + for (int nl = 0; nl < iterations*10; nl++) { + sum = 0.; + for (int i = 0; i < LEN_1D; i++) { + sum += a[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, sum); + } + + return sum; +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vsumr, "vsumr", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vtv.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vtv.c new file mode 100644 index 0000000000..d3457d483d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vtv.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vtv(struct args_t * func_args) +{ +// control loops +// vector times vector + + initialise_arrays(__func__); + + for (int nl = 0; nl < iterations*10; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] *= b[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vtv, "vtv", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vtvtv.c b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vtvtv.c new file mode 100644 index 0000000000..32148ec4c4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/tsvc/vect-tsvc-vtvtv.c @@ -0,0 +1,39 @@ +/* This file is distributed under the University of Illinois Open Source + License. See license.txt for details. */ + +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float } */ + +#include "tsvc.h" + +real_t vtvtv(struct args_t * func_args) +{ +// control loops +// vector times vector times vector + + initialise_arrays(__func__); + + for (int nl = 0; nl < 4*iterations; nl++) { + for (int i = 0; i < LEN_1D; i++) { + a[i] = a[i] * b[i] * c[i]; + } + dummy(a, b, c, d, e, aa, bb, cc, 0.); + } + + return calc_checksum(__func__); +} + +int main (int argc, char **argv) +{ + int n1 = 1; + int n3 = 1; + int* ip; + real_t s1,s2; + init(&ip, &s1, &s2); + + run(&vtvtv, "vtvtv", NULL); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/unswitch-loops-pr26969.c b/SingleSource/Regression/C/gcc-dg/vect/unswitch-loops-pr26969.c new file mode 100644 index 0000000000..71538c4b18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/unswitch-loops-pr26969.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void +ruby_re_compile_fastmap (char *fastmap, int options) +{ + int j; + for (j = 0; j < (1 << 8); j++) + { + if (j != '\n' || (options & 4)) + fastmap[j] = 1; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt.c b/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt.c new file mode 100644 index 0000000000..64f628adf1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_int } */ + +#define vidx(type, vec, idx) (*((type *) &(vec) + idx)) +#define vector(elcount, type) \ +__attribute__((vector_size((elcount)*sizeof(type)))) type + +short k; + +int main (int argc, char *argv[]) { + k = argc; + vector(8, short) v0 = {argc,1,2,3,4,5,6,7}; + vector(8, short) v2 = {k, k,k,k,k,k,k,k}; + vector(8, short) r1; + + r1 = v0 >> v2; + + return vidx(short, r1, 0); +} + +/* { dg-final { scan-tree-dump-times ">> _\[0-9\]*" 1 "veclower21" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt1.c b/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt1.c new file mode 100644 index 0000000000..bd2c583fc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_int } */ + +#define vidx(type, vec, idx) (*((type *) &(vec) + idx)) +#define vector(elcount, type) \ +__attribute__((vector_size((elcount)*sizeof(type)))) type + +short k; + +int main (int argc, char *argv[]) { + vector(8, short) v0 = {argc,1,2,3,4,5,6,7}; + vector(8, short) r1; + + r1 = v0 >> (vector(8, short)){2,2,2,2,2,2,2,2}; + + return vidx(short, r1, 0); +} + +/* { dg-final { scan-tree-dump-times ">> 2" 1 "veclower21" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt2.c b/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt2.c new file mode 100644 index 0000000000..6de4064237 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vec-scal-opt2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_int } */ + +#define vidx(type, vec, idx) (*((type *) &(vec) + idx)) +#define vector(elcount, type) \ +__attribute__((vector_size((elcount)*sizeof(type)))) type + +int main (int argc, char *argv[]) { + vector(8, short) v0 = {argc,1,2,3,4,5,6,7}; + vector(8, short) v1 = {2,2,2,2,2,2,2,2}; + vector(8, short) r1; + + r1 = v0 >> v1; + + return vidx(short, r1, 0); +} + +/* { dg-final { scan-tree-dump-times ">> 2" 1 "veclower21" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-1-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-1-big-array.c new file mode 100644 index 0000000000..5ffbf1bf3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-1-big-array.c @@ -0,0 +1,92 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ + +#define N 128 + +void fbar (float *); +void ibar (int *); +void sbar (short *); + +/* multiple loops */ + +void +foo (int n) +{ + float a[N+1]; + float b[N]; + float c[N]; + float d[N]; + int ia[N]; + int ib[N]; + int ic[N]; + int i,j; + int diff = 0; + char cb[N]; + char cc[N]; + char image[N][N]; + char block[N][N]; + + /* Vectorizable. */ + diff = 0; + for (i = 0; i < N; i++) { + diff += (cb[i] - cc[i]); + } + ibar (&diff); + + + /* Vectorizable. */ + diff = 0; + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + diff += (image[i][j] - block[i][j]); + } + } + ibar (&diff); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i]; + } + fbar (a); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i] + d[i]; + } + fbar (a); + + + /* Strided access. Vectorizable on platforms that support load of strided + accesses (extract of even/odd vector elements). */ + for (i = 0; i < N/2; i++){ + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + fbar (a); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + d[i] = b[i] + c[i]; + ia[i] = ib[i] + ic[i]; + } + ibar (ia); + fbar (a); + fbar (d); + + /* Not vetorizable yet (too conservative dependence test). */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + a[i+1] = b[i] + c[i]; + } + fbar (a); +} + +/* { dg-final { scan-tree-dump-times "vectorized 6 loops" 1 "vect" { target vect_strided2 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 5 loops" 1 "vect" { xfail vect_strided2 } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-1.c new file mode 100644 index 0000000000..cba9ce076a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-1.c @@ -0,0 +1,92 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ + +#define N 16 + +void fbar (float *); +void ibar (int *); +void sbar (short *); + +/* multiple loops */ + +void +foo (int n) +{ + float a[N+1]; + float b[N]; + float c[N]; + float d[N]; + int ia[N]; + int ib[N]; + int ic[N]; + int i,j; + int diff = 0; + char cb[N]; + char cc[N]; + char image[N][N]; + char block[N][N]; + + /* Vectorizable. */ + diff = 0; + for (i = 0; i < N; i++) { + diff += (cb[i] - cc[i]); + } + ibar (&diff); + + + /* Vectorizable. */ + diff = 0; + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + diff += (image[i][j] - block[i][j]); + } + } + ibar (&diff); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i]; + } + fbar (a); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i] + d[i]; + } + fbar (a); + + + /* Strided access. Vectorizable on platforms that support load of strided + accesses (extract of even/odd vector elements). */ + for (i = 0; i < N/2; i++){ + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + fbar (a); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + d[i] = b[i] + c[i]; + ia[i] = ib[i] + ic[i]; + } + ibar (ia); + fbar (a); + fbar (d); + + /* Not vetorizable yet (too conservative dependence test). */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + a[i+1] = b[i] + c[i]; + } + fbar (a); +} + +/* { dg-final { scan-tree-dump-times "vectorized 6 loops" 1 "vect" { target vect_strided2 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 5 loops" 1 "vect" { xfail vect_strided2 } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-10-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-10-big-array.c new file mode 100644 index 0000000000..ac18f2bf2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-10-big-array.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +extern void abort (void); + +#define N 128 + +short a[N]; +short d[N]; + +int foo () +{ + int i; + short b[N]; + short c[N]; + for (i = 0; i < N/2; i++) + { + b[i] = i*3; + c[i] = i; + asm volatile ("" ::: "memory"); + } + + /* Strided access pattern. */ + for (i = 0; i < N/2; i++) + { + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { ! vect_strided2 } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-10.c new file mode 100644 index 0000000000..26c16c5d6f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-10.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#define N 16 + +short a[N]; +short d[N]; + +int foo () +{ + int i; + short b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + + /* Strided access pattern. */ + for (i = 0; i < N/2; i++) + { + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { ! vect_strided2 } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-100.c b/SingleSource/Regression/C/gcc-dg/vect/vect-100.c new file mode 100644 index 0000000000..dd4c2c0bec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-100.c @@ -0,0 +1,83 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include +#include "tree-vect.h" + +#define N 9 + +struct extraction +{ + int a[N]; + int b[N]; +}; + +static int a[N] = {1,2,3,4,5,6,7,8,9}; +static int b[N] = {2,3,4,5,6,7,8,9,0}; + +__attribute__ ((noinline)) +int main1 () { + int i; + struct extraction *p; + + p = (struct extraction *) malloc (sizeof (struct extraction)); + + /* Vectorizable: alias analysis determines that p can't point to a and/or b. */ + for (i = 0; i < N; i++) + { + p->a[i] = a[i]; + p->b[i] = b[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (p->a[i] != a[i] || p->b[i] != b[i]) + abort(); + } + + return 0; +} + +__attribute__ ((noinline)) +int main2 () { + int i; + int c[N] = {1,2,3,4,5,6,7,8,9}; + int d[N] = {2,3,4,5,6,7,8,9,0}; + struct extraction *p; + p = (struct extraction *) malloc (sizeof (struct extraction)); + + /* Vectorizable: c and d are local arrays. */ + for (i = 0; i < N; i++) + { + p->a[i] = c[i]; + p->b[i] = d[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (p->a[i] != c[i] || p->b[i] != d[i]) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + main2 (); + + return 0; +} + +/* Requires versioning. */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 0 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-103.c b/SingleSource/Regression/C/gcc-dg/vect/vect-103.c new file mode 100644 index 0000000000..72d71322aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-103.c @@ -0,0 +1,62 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks --param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 256 +#define NINTS (VECTOR_BITS / 32) +#else +#define NINTS 8 +#endif + +#define N (NINTS + 1) + +struct extraction +{ + int a[N]; + int b[N]; +}; + +static int a[N] = {1,2,3,4,5,6,7,8,9}; +static int b[N] = {17,24,7,0,2,3,4,31,82}; + +__attribute__ ((noinline)) +int main1 (int x, int y) { + int i; + struct extraction *p; + p = (struct extraction *) malloc (sizeof (struct extraction)); + + for (i = 0; i < N; i++) + { + p->a[i] = a[i]; + p->b[i] = b[i]; + asm volatile ("" ::: "memory"); + } + + /* Vectorizable: distance > VF. */ + for (i = 0; i < N; i++) + *((int *)p + x + i) = *((int *)p + x + i + NINTS); + + /* check results: */ + if (p->a[0] != a[N - 1]) + abort (); +#pragma GCC novector + for (i = 1; i < N; i++) + if (p->a[i] != b[i - 1]) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (0, N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-104.c b/SingleSource/Regression/C/gcc-dg/vect/vect-104.c new file mode 100644 index 0000000000..730efd39bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-104.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param max-completely-peel-times=1 -fdump-tree-optimized-details-blocks" } */ + +#include +#include +#include "tree-vect.h" + +#define N 3 + +struct extraction +{ + int a[N][N]; + int b[N][N]; +}; + +static int a[N][N] = {{1,2,3},{4,5,6},{7,8,9}}; +static int b[N][N] = {{17,24,7},{0,2,3},{4,31,82}}; +static int c[N][N] = {{1,2,3},{4,5,5},{5,5,5}}; + +__attribute__ ((noinline)) +int main1 (int x) { + int i,j; + struct extraction *p; + p = (struct extraction *) malloc (sizeof (struct extraction)); + + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + p->a[i][j] = a[i][j]; + p->b[i][j] = b[i][j]; + asm volatile ("" ::: "memory"); + } + } + + /* Not vectorizable: distance = 1. */ + for (i = 1; i < N; i++) + { + for (j = 0; j < N; j++) + { + *((int *)p + x + i + j + 1) = *((int *)p + x + i + j); + } + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + if (p->a[i][j] != c[i][j]) + abort(); + } + } + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" { target { ! vect_multiple_sizes } } } } */ +/* { dg-final { scan-tree-dump "possible dependence between data-refs" "vect" { target vect_multiple_sizes } } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-105-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-105-big-array.c new file mode 100644 index 0000000000..348b859a29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-105-big-array.c @@ -0,0 +1,100 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include +#include "tree-vect.h" + +#define N 16 + +struct extraction +{ + int a[N][N]; + int b[N][N]; +}; + +static int a[N][N]; +static int b[N][N]; +static int c[N][N]; + +__attribute__ ((noinline)) +int main1 (int x) { + int i,j, off; + struct extraction *p; + p = (struct extraction *) malloc (sizeof (struct extraction)); + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + a[i][j] = (i*7 + j*17)%53; + b[i][j] = (i*11+ j*13)%41; + asm volatile ("" ::: "memory"); + } + } + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + c[i][j] = a[i][j]; + asm volatile ("" ::: "memory"); + } + } + for (i = 1; i < N; i++) + { + for (j = 0; j < N; j++) + { + off = x + i + j + N+1; + if (x + i + j > N*N-1) + break; + if (off > N*N-1) + *(&c[0][0]+x+i+j) = *(&b[0][0] + off - N*N); + else + *(&c[0][0]+x+i+j) = *(&a[0][0] + off); + asm volatile ("" ::: "memory"); + } + } + + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + p->a[i][j] = a[i][j]; + p->b[i][j] = b[i][j]; + asm volatile ("" ::: "memory"); + } + } + + /* Vectorizable: distance > number of iterations. */ + for (i = 1; i < N; i++) + { + for (j = 0; j < N; j++) + { + *((int *)p + x + i + j) = *((int *)p + x + i + j + N+1); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (p->a[i][j] != c[i][j]) + abort (); + } + } + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 0 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-105.c b/SingleSource/Regression/C/gcc-dg/vect/vect-105.c new file mode 100644 index 0000000000..793f8e2c95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-105.c @@ -0,0 +1,70 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include +#include "tree-vect.h" + +#define N 4 + +struct extraction +{ + int a[N][N]; + int b[N][N]; +}; + +static int a[N][N] = {{1,2,3,11},{4,5,6,12},{7,8,9,13},{34,45,67,83}}; +static int b[N][N] = {{17,28,15,23},{0,2,3,24},{4,31,82,25},{29,31,432,256}}; +static int c[N][N] = {{1,2,3,11},{4,9,13,34},{45,67,83,13},{34,45,67,83}}; + +__attribute__ ((noinline)) +int main1 (int x) { + int i,j; + struct extraction *p; + p = (struct extraction *) malloc (sizeof (struct extraction)); + + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + p->a[i][j] = a[i][j]; + p->b[i][j] = b[i][j]; + asm volatile ("" ::: "memory"); + } + } + + /* Vectorizable: distance > number of iterations. */ + for (i = 1; i < N; i++) + { +#pragma GCC unroll 0 + for (j = 0; j < N; j++) + { + *((int *)p + x + i + j) = *((int *)p + x + i + j + 5); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (p->a[i][j] != c[i][j]) + abort(); + } + } + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 0 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-106.c b/SingleSource/Regression/C/gcc-dg/vect/vect-106.c new file mode 100644 index 0000000000..2687919989 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-106.c @@ -0,0 +1,76 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include +#include "tree-vect.h" + +#define N 9 + +static int a[N] = {1,2,3,4,5,6,7,8,9}; +static int b[N] = {2,3,4,5,6,7,8,9,0}; + +__attribute__ ((noinline)) +int main1 () { + int i; + int *p, *q, *p1, *q1; + p = (unsigned int *) malloc (sizeof (unsigned int) * N); + q = (unsigned int *) malloc (sizeof (unsigned int) * N); + + p1 = p; q1 = q; + + /* Vectorizable, before pointer plus we would get a redundant cast + (caused by pointer arithmetics), alias analysis fails to distinguish + between the pointers. */ + for (i = 0; i < N; i++) + { + *(q + i) = a[i]; + *(p + i) = b[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (*q != a[i] || *p != b[i]) + abort(); + q++; + p++; + } + + q = q1; + p = p1; + /* Vectorizable. */ + for (i = 0; i < N; i++) + { + *q = b[i]; + *p = a[i]; + q++; + p++; + } + + q = q1; + p = p1; + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (*q != b[i] || *p != a[i]) + abort(); + q++; + p++; + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-107.c b/SingleSource/Regression/C/gcc-dg/vect/vect-107.c new file mode 100644 index 0000000000..eee9d4b8be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-107.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + float a[N]; + + /* Strided access. Vectorizable on platforms that support load of strided + accesses (extract of even/odd vector elements). */ + for (i = 0; i < N/2; i++) + { + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (a[i] != b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i] + || d[i] != b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { xfail vect_strided2 } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-108.c b/SingleSource/Regression/C/gcc-dg/vect/vect-108.c new file mode 100644 index 0000000000..4f201f0d35 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-108.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int_mult } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ia[N]; + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + + /* This loop is vectorized on platforms that support vect_int_mult. */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i] * ic[i]; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i] * ic[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-109.c b/SingleSource/Regression/C/gcc-dg/vect/vect-109.c new file mode 100644 index 0000000000..63813dbdb3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-109.c @@ -0,0 +1,85 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-skip-if "" { vect_no_align } } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 32 + +short sa[N]; +short sc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +int ia[N]; +int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) +int main1 (int n) +{ + int i; + + /* Multiple types with different sizes, used in idependent + copmutations. Vectorizable. */ + for (i = 0; i < n; i++) + { + sa[i+2] = sb[i] + sc[i]; + ia[i+1] = ib[i] + ic[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (sa[i+2] != sb[i] + sc[i] || ia[i+1] != ib[i] + ic[i]) + abort (); + } + + return 0; +} + +int main2 (int n) +{ + int i; + + /* Multiple types with different sizes, used in idependent + copmutations. Vectorizable. */ + for (i = 0; i < n; i++) + { + ia[i+1] = ib[i] + ic[i]; + sa[i] = sb[i] + sc[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (sa[i] != sb[i] + sc[i] || ia[i+1] != ib[i] + ic[i]) + abort (); + } + + return 0; +} + + +int main (void) +{ + check_vect (); + + main1 (N-2); + main2 (N-1); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_element_align } } } */ +/* { dg-final { scan-tree-dump-times "unsupported unaligned access" 2 "vect" { xfail vect_element_align } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { target vect_element_align xfail { ! vect_unaligned_possible } } } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-11.c new file mode 100644 index 0000000000..296dae5ed8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-11.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_int_mult } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int ia[N]; +int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + /* Not vectorizable yet (integer mult). */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i] * ic[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i] * ic[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-110.c b/SingleSource/Regression/C/gcc-dg/vect/vect-110.c new file mode 100644 index 0000000000..a7df54d7d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-110.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +static __attribute__ ((noinline)) int +main1 (void) +{ + int i; + float a[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + + /* Too conservative dependence test. */ + for (i = 0; i < N - 1; i++){ + a[i] = b[i] + c[i]; + a[i+1] = b[i] + c[i]; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N - 1; i++){ + if (a[i] != b[i] + c[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" } } */ + + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-112-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-112-big-array.c new file mode 100644 index 0000000000..a673fc605d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-112-big-array.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +char cb[N]; +char cc[N]; + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + int diff = 0; + int check_diff = 0; + for (i = 0; i < N; i++) { + cb[i] = i + 2; + cc[i] = i + 1; + check_diff += (cb[i] - cc[i]); + asm volatile ("" ::: "memory"); + } + + /* Cross-iteration cycle. */ + diff = 0; + for (i = 0; i < N; i++) { + diff += (cb[i] - cc[i]); + } + + /* Check results. */ + if (diff != check_diff) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ + + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-112.c b/SingleSource/Regression/C/gcc-dg/vect/vect-112.c new file mode 100644 index 0000000000..6b18299c06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-112.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +char cb[N] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; +char cc[N] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + int diff = 0; + + /* Cross-iteration cycle. */ + diff = 0; + for (i = 0; i < N; i++) { + diff += (cb[i] - cc[i]); + } + + /* Check results. */ + if (diff != 16) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ + + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-113.c b/SingleSource/Regression/C/gcc-dg/vect/vect-113.c new file mode 100644 index 0000000000..89a94d822a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-113.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + float a[N]; + + /* Induction and type conversion. */ + for ( i = 0; i < N; i++) + { + a[i] = i; + } + +#pragma GCC novector + for ( i = 0; i < N; i++) + { + if (a[i] != i) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-114.c b/SingleSource/Regression/C/gcc-dg/vect/vect-114.c new file mode 100644 index 0000000000..22e1e8cf26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-114.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + float a[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + + /* Reverse access and forward access. */ + for (i = N; i > 0; i--) + { + a[N-i] = b[i-1]; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 16 + +struct s{ + int b[N]; + int c[N]; + int m; +}; + +struct t{ + struct s strc_s; + int m; +}; + +struct test1{ + struct t strc_t; + struct t *ptr_t; + int k; + int l; +}; + +int a[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + struct test1 tmp1; + struct t tmp2; + + tmp1.ptr_t = &tmp2; + + /* DR bases comparison: record and array. */ + for (i = 0; i < N; i++) + { + tmp1.strc_t.strc_s.b[i] = a[i]; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (tmp1.strc_t.strc_s.b[i] != a[i]) + abort(); + } + + /* DR bases comparison: record containing ptr and array. */ + for (i = 0; i < N; i++) + { + tmp1.ptr_t->strc_s.c[i] = a[i]; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (tmp1.ptr_t->strc_s.c[i] != a[i]) + abort(); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ + + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-116.c b/SingleSource/Regression/C/gcc-dg/vect/vect-116.c new file mode 100644 index 0000000000..dd926a0a87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-116.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* Assuming we can vectorize char multiplication, here's an execute test. */ + +#include +#include "tree-vect.h" + +extern void abort (void); + +__attribute__ ((noinline)) +void foo() +{ + static unsigned char A[256], B[256], C[256]; + int i; + + for (i = 0; i < 256; ++i) + A[i] = B[i] = i; + + for (i = 0; i < 256; ++i) + C[i] = A[i] * B[i]; + +#pragma GCC novector + for (i = 0; i < 256; ++i) + if (C[i] != (unsigned char)(i * i)) + abort (); +} + +int main() +{ + check_vect (); + foo(); + return 0; +} + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-117.c b/SingleSource/Regression/C/gcc-dg/vect/vect-117.c new file mode 100644 index 0000000000..4755e39f95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-117.c @@ -0,0 +1,64 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 5 + +static int a[N][N] = {{ 1, 2, 3, 4, 5}, + { 6, 7, 8, 9,10}, + {11,12,13,14,15}, + {16,17,18,19,20}, + {21,22,23,24,25}}; + +static int c[N][N] = {{ 1, 2, 3, 4, 5}, + { 7, 9,11, 13,15}, + {18,21,24,27,30}, + {34,38,42,46,50}, + {55,60,65,70,75}}; + +__attribute__ ((noinline)) +int main1 (int A[N][N], int n) +{ + + int i,j; + + /* vectorizable */ + for (i = 1; i < N; i++) + { + for (j = 0; j < n; j++) + { + A[i][j] = A[i-1][j] + A[i][j]; + } + } + + return 0; +} + +int main (void) +{ + int i,j; + + check_vect (); + + main1 (a, N); + + /* check results: */ + + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (a[i][j] != c[i][j]) + abort(); + } + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 0 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" { target { lp64 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-118.c b/SingleSource/Regression/C/gcc-dg/vect/vect-118.c new file mode 100644 index 0000000000..71201d1c59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-118.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +void f(short * __restrict__ a, short * __restrict__ b, short * __restrict__ x) +{ + int i; + for (i=0;i<1024;i++) + x[i] = a[i] + b[i]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-119.c b/SingleSource/Regression/C/gcc-dg/vect/vect-119.c new file mode 100644 index 0000000000..028804ae21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-119.c @@ -0,0 +1,31 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#define OUTER 32 +#define INNER 40 + +static unsigned int +bar (const unsigned int x[INNER][2], unsigned int sum) +{ + int i; + + for (i = 0; i < INNER; i++) + sum += x[i][0] * x[i][0] + x[i][1] * x[i][1]; + return sum; +} + +unsigned int foo (const unsigned int x[OUTER][INNER][2]) +{ + int i; + unsigned int sum; + + sum = 0.0f; + for (i = 0; i < OUTER; i++) + sum = bar (x[i], sum); + return sum; +} + +/* { dg-final { scan-tree-dump-times "Detected interleaving load of size 2" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-11a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-11a.c new file mode 100644 index 0000000000..2fdb49c531 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-11a.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_int_mult } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +extern void abort (void); + +unsigned int A[8] = {0x08000000,0xffffffff,0xff0000ff,0xf0000001, + 0x08000000,0xffffffff,0xff0000ff,0xf0000001}; +unsigned int B[8] = {0x08000000,0x08000001,0xff0000ff,0xf0000001, + 0x08000000,0x08000001,0xff0000ff,0xf0000001}; +unsigned int Answer[8] = {0,0xf7ffffff,0x0200fe01,0xe0000001, + 0,0xf7ffffff,0x0200fe01,0xe0000001}; +unsigned int C[8]; + +__attribute__ ((noinline)) +void u () +{ + int i, j; + + for (i=0; i<8; i++) + C[i] = A[i] * B[i]; +#pragma GCC novector + for (i=0; i<8; i++) + if (C[i] != Answer[i]) + abort (); +} + +signed int D[8] = {0x08000000,0xffffffff,0xff0000ff,0xf0000001, + 0x08000000,0xffffffff,0xff0000ff,0xf0000001}; +signed int E[8] = {0x08000000,0x08000001,0xff0000ff,0xf0000001, + 0x08000000,0x08000001,0xff0000ff,0xf0000001}; +signed int Dnswer[8] = {0,0xf7ffffff,0x0200fe01, 0xe0000001, + 0,0xf7ffffff,0x0200fe01, 0xe0000001}; +signed int F[8]; + +__attribute__ ((noinline)) +void s() +{ + int i, j; + + for (i=0; i<8; i++) + F[i] = D[i] * E[i]; +#pragma GCC novector + for (i=0; i<8; i++) + if (F[i] != Dnswer[i]) + abort (); +} + +__attribute__ ((noinline)) +int main1 () +{ + u(); + s(); + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-12.c new file mode 100644 index 0000000000..0270c91081 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-12.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + int i; + int ia[N]; + int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short sa[N]; + short sc[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short sb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + + /* Multiple types with different nunits in vector. */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i] + ic[i]; + sa[i] = sb[i] + sc[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i] + ic[i] || sa[i] != sb[i] + sc[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-120.c b/SingleSource/Regression/C/gcc-dg/vect/vect-120.c new file mode 100644 index 0000000000..e7ef76c7d4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-120.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_floatint_cvt } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +static inline float +i2f(int x) +{ + union { float f; int i; } tmp; + tmp.i=x; + return tmp.f; +} +static inline float +vect_ldexpf(float x, int n) +{ + n = (n+0x7f)<<23; + return x * i2f(n); +} + +float __attribute__ ((aligned(16))) a[1024]; +float __attribute__ ((aligned(16))) b[1024]; +float __attribute__ ((aligned(16))) c[1024]; + +void +tV() +{ + int i; + for (i=0; i!=1024; ++i) + { + float z = a[i]; + int n = b[i]; + c[i] = vect_ldexpf(z,n); + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-121.c b/SingleSource/Regression/C/gcc-dg/vect/vect-121.c new file mode 100644 index 0000000000..d820215ca6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-121.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +float *x; +float parm; +float +test (int start, int end) +{ + int i; + for (i = start; i < end; ++i) + { + float tem = x[i]; + x[i] = parm * tem; + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-122.c b/SingleSource/Regression/C/gcc-dg/vect/vect-122.c new file mode 100644 index 0000000000..7856c733a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-122.c @@ -0,0 +1,61 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +#include "tree-vect.h" + +#ifndef N +#define N 64 +#endif + +char a[N]; +float b[N]; +long long l[N], m[N]; + +__attribute__((noinline, noclone)) int +f1 (void) +{ + int i; + for (i = 0; i < N; i++) + a[i] = i; +} + +__attribute__((noinline, noclone)) int +f2 (void) +{ + int i; + for (i = 0; i < N; i++) + b[i] = (double) i; +} + +__attribute__((noinline, noclone)) int +f3 (void) +{ + int i; + for (i = 0; i < N; i++) + l[i] = (long long) i * (i + 7); +} + +__attribute__((noinline, noclone)) int +f4 (void) +{ + int i; + for (i = 0; i < N; i++) + m[i] = (long long) i * 7; +} + +int +main () +{ + int i; + + check_vect (); + f1 (); + f2 (); + f3 (); + f4 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i || b[i] != i || l[i] != i * (i + 7LL) || m[i] != i * 7LL) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-123.c b/SingleSource/Regression/C/gcc-dg/vect/vect-123.c new file mode 100644 index 0000000000..20edd7ba26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-123.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +int x[4092]; +int y[1024]; + +void foo (int s) +{ + int i, j; + for (i = 0, j = 0; j < 1023; i += s, j++) + y[j] += x[i]; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-124.c b/SingleSource/Regression/C/gcc-dg/vect/vect-124.c new file mode 100644 index 0000000000..bb08dfa99c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-124.c @@ -0,0 +1,32 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +#include "tree-vect.h" + +#ifndef N +#define N 64 +#endif + +int a[N]; + +__attribute__((noinline, noclone)) void +foo (int x) +{ + int i; + for (i = 0; i < N; i++, x += 3) + a[i] = x; +} + +int +main () +{ + int i; + + check_vect (); + foo (6); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * 3 + 6) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-125.c b/SingleSource/Regression/C/gcc-dg/vect/vect-125.c new file mode 100644 index 0000000000..4a3c0dc7a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-125.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_int_mult } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +void train(short *t, short *w, int n, int err) +{ + n=(n+7)&-8; + for (int i=0; i>16)+1>>1); + if (wt<-32768) wt=-32768; + if (wt>32767) wt=32767; + w[i]=wt; + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail vect_no_int_min_max } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-126.c b/SingleSource/Regression/C/gcc-dg/vect/vect-126.c new file mode 100644 index 0000000000..02d1f1e197 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-126.c @@ -0,0 +1,65 @@ +/* PR tree-optimization/66718 */ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +int *a[1024], b[1024]; +struct S { int u, v, w, x; }; +struct S c[1024]; +int d[1024][10]; + +void +f0 (void) +{ + for (int i = 0; i < 1024; i++) + a[i] = &b[0]; +} + +void +f1 (void) +{ + for (int i = 0; i < 1024; i++) + { + int *p = &b[0]; + a[i] = p + i; + } +} + +void +f2 (int *p) +{ + for (int i = 0; i < 1024; i++) + a[i] = &p[i]; +} + +void +f3 (void) +{ + for (int i = 0; i < 1024; i++) + a[i] = &b[i]; +} + +void +f4 (void) +{ + int *p = &c[0].v; + for (int i = 0; i < 1024; i++) + a[i] = &p[4 * i]; +} + +void +f5 (void) +{ + for (int i = 0; i < 1024; i++) + a[i] = &c[i].v; +} + +void +f6 (void) +{ + for (int i = 0; i < 1024; i++) + for (unsigned int j = 0; j < 10; j++) + a[i] = &d[i][j]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 7 "vect" { target { i?86-*-* x86_64-*-* } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-13.c new file mode 100644 index 0000000000..55904d4917 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-13.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int a[N]; +int results[N] = {0,1,2,3,0,0,0,0,0,0,0,0,12,13,14,15}; +int b[N] = {0,1,2,3,-4,-5,-6,-7,-8,-9,-10,-11,12,13,14,15}; + +__attribute__ ((noinline)) +int main1() +{ + int i; + + /* Max pattern. */ + for (i = 0; i < N; i++) + { + a[i] = (b[i] >= 0 ? b[i] : 0); + } + + /* Check results */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-14.c b/SingleSource/Regression/C/gcc-dg/vect/vect-14.c new file mode 100644 index 0000000000..1db41ee778 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-14.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + int i; + int ia[N]; + + /* Induction. */ + for ( i = 0; i < N; i++) { + ia[i] = i; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != i) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect(); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-15-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-15-big-array.c new file mode 100644 index 0000000000..69901c405a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-15-big-array.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) +int main1 () +{ + int i; + int a[N]; + int b[N]; + + for (i = 0; i 0; i--) + { + a[N-i] = b[i-1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + int i; + int a[N]; + int b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + + /* Not vectorizable yet (reverse access and forward access). */ + for (i = N; i > 0; i--) + { + a[N-i] = b[i-1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 64 + + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = ib[i] & ic[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 64 + + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = (ib[i] | ic[i]); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 64 + + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = ib[i] ^ ic[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 128 + +char cb[N]; +char ca[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + cb[i] = i*3; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + ca[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-2.c new file mode 100644 index 0000000000..2635f6cb29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-2.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +char ca[N] = {}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + ca[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-20.c b/SingleSource/Regression/C/gcc-dg/vect/vect-20.c new file mode 100644 index 0000000000..e3e6483701 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-20.c @@ -0,0 +1,105 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 64 + + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + signed char ca[N]; + signed char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = ~ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 64 + + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = !ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 64 + + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + signed char ca[N]; + signed char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + float fa[N]; + float fb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = -ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 64 + +__attribute__ ((noinline)) int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = ib[i] && ic[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 64 + +__attribute__ ((noinline)) int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = (ib[i] || ic[i]); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) +int main1 (int n, int *p) +{ + int i; + int ib[N]; + int ia[N]; + int k; + + for (i = 0; i < N; i++) + { + ia[i] = n; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != n) + abort (); + } + + k = *p; + for (i = 0; i < N; i++) + { + ib[i] = k; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ib[i] != k) + abort (); + } + + return 0; +} + +int main (void) +{ + int m = 8; + + check_vect (); + + return main1 (m, &m); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-26.c b/SingleSource/Regression/C/gcc-dg/vect/vect-26.c new file mode 100644 index 0000000000..84ae7af2a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-26.c @@ -0,0 +1,44 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +/* unaligned store. */ + +__attribute__ ((noinline)) +int main1 () +{ + int i; + int ia[N+1]; + + for (i = 1; i <= N; i++) + { + ia[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= N; i++) + { + if (ia[i] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { vect_element_align_preferred || { ! vect_align_stack_vars } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-27.c b/SingleSource/Regression/C/gcc-dg/vect/vect-27.c new file mode 100644 index 0000000000..1c97016860 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-27.c @@ -0,0 +1,54 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 128 + +/* unaligned load. */ + +int ia[N]; +int ib[N+1]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i=0; i <= N; i++) + { + ib[i] = i; + } + + for (i = 1; i <= N; i++) + { + ia[i-1] = ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= N; i++) + { + if (ia[i-1] != ib[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* The initialization induction loop (with aligned access) is also vectorized. */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-28.c b/SingleSource/Regression/C/gcc-dg/vect/vect-28.c new file mode 100644 index 0000000000..9a7bd8a721 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-28.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0 -fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 +#define OFF 3 + +/* unaligned store. */ + +__attribute__ ((noinline)) +int main1 (int off) +{ + int i; + int ia[N+OFF]; + + for (i = 0; i < N; i++) + { + ia[i+off] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i+off] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (0); /* aligned */ + main1 (OFF); /* unaligned */ + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { {! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-29.c b/SingleSource/Regression/C/gcc-dg/vect/vect-29.c new file mode 100644 index 0000000000..14d45e4540 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-29.c @@ -0,0 +1,60 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 128 +#define OFF 3 + +/* unaligned load. */ + +int ia[N]; +int ib[N+OFF]; + +__attribute__ ((noinline)) +int main1 (int off) +{ + int i; + + for (i = 0; i < N+OFF; i++) + { + ib[i] = i; + } + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (0); /* aligned */ + main1 (OFF); /* unaligned */ + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + (The store is aligned). */ + +/* The initialization induction loop (with aligned access) is also vectorized. */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" {target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-3.c new file mode 100644 index 0000000000..203bc3cb95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-3.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 20 + +float a[N]; +float e[N]; +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; +int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ia[N]; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + a[i] = b[i] + c[i] + d[i]; + e[i] = b[i] + c[i] + d[i]; + ia[i] = ib[i] + ic[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 16 + +float b[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; +float a[N]; +float c[N]; + +__attribute__ ((noinline)) +int main1 (int n) +{ + int i=0; + + /* Vectorized: unknown loop bound. */ + while (n--) { + a[i] = b[i]; + i++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (a[i] != b[i]) + abort (); + } + + return 0; +} + +__attribute__ ((noinline)) +int main2 (unsigned int n) +{ + int i=0; + int nn = n; + + /* Vectorized: unknown loop bound. */ + while (n--) { + c[i] = b[i]; + i++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < nn; i++) + { + if (c[i] != b[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N); + main2 (N); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-31-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-31-big-array.c new file mode 100644 index 0000000000..b05a6c21d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-31-big-array.c @@ -0,0 +1,95 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 256 + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + struct s tmp; + + /* unaligned */ + for (i = 0; i < N/2; i++) + { + tmp.b[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 32 + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + struct s tmp; + + /* unaligned */ + for (i = 0; i < N/2; i++) + { + tmp.b[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) +int main1 () +{ + struct { + char ca[N]; + } s; + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-32-chars.c b/SingleSource/Regression/C/gcc-dg/vect/vect-32-chars.c new file mode 100644 index 0000000000..c2e29b8fb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-32-chars.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-additional-options "-mavx512bw -mavx512vl" { target { i?86-*-* x86_64-*-* } } } */ + +char a[32]; +char b[32]; +char c[32]; + +void test() +{ + int i = 0; + for (i = 0; i < 32; i++) + if (b[i] > 0) + a[i] = c[i]; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { i?86-*-* x86_64-*-* } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-32.c b/SingleSource/Regression/C/gcc-dg/vect/vect-32.c new file mode 100644 index 0000000000..d359663aac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-32.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS / 8) +#else +#define N 16 +#endif + +__attribute__ ((noinline)) +int main1 () +{ + struct { + char ca[N]; + } s; + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-33-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-33-big-array.c new file mode 100644 index 0000000000..7c2d7c4d66 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-33-big-array.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0 -fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 +struct test { + char ca[N]; +}; + +extern struct test s; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { {! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-33.c b/SingleSource/Regression/C/gcc-dg/vect/vect-33.c new file mode 100644 index 0000000000..7a37339100 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-33.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 +struct test { + char ca[N]; +}; + +extern struct test s; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != 5) + abort (); + } + + return 0; +} + +int main (void) +{ + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump "Vectorizing an unaligned access" "vect" { target { { { ! powerpc*-*-* } && vect_hw_misalign } && { { ! vect64 } || vect_multiple_sizes } } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump "Alignment of access forced using peeling" "vect" { target { vector_alignment_reachable && { vect64 && {! vect_multiple_sizes} } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { { {! vector_alignment_reachable} || {! vect64} } && {! vect_hw_misalign} } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-34-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-34-big-array.c new file mode 100644 index 0000000000..e982c2accb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-34-big-array.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +struct { + char ca[N]; +} s; +char cb[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + cb[i] = i*3; + asm volatile ("" ::: "memory"); + } + for (i = 0; i < N; i++) + { + s.ca[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-34.c b/SingleSource/Regression/C/gcc-dg/vect/vect-34.c new file mode 100644 index 0000000000..514f20f44d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-34.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +struct { + char ca[N]; +} s; +char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-35-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-35-big-array.c new file mode 100644 index 0000000000..a35e233ce5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-35-big-array.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) +int main1 () +{ + union { + unsigned char a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + unsigned char b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + } s; + int i; + + /* Initialization. */ + for (i = 0; i < N; i++) + { + s.b[i] = i; + } + + for (i = 0; i < N; i++) + { + s.a[i] = s.b[i] + 1; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.a[i] != i + 1) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail { ia64-*-* sparc*-*-* } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-35.c b/SingleSource/Regression/C/gcc-dg/vect/vect-35.c new file mode 100644 index 0000000000..58835dfc3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-35.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + union { + unsigned char a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + unsigned char b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + } s; + int i; + + /* Initialization. */ + for (i = 0; i < N; i++) + { + s.b[i] = i; + } + + for (i = 0; i < N; i++) + { + s.a[i] = s.b[i] + 1; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.a[i] != i + 1) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail { ia64-*-* sparc*-*-* } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-36-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-36-big-array.c new file mode 100644 index 0000000000..fc2baaa40b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-36-big-array.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) +int main1 () +{ + int i; + struct { + char ca[N]; + char cb[N]; + } s; + + + for (i = 0; i < N; i++) + { + s.cb[i] = 3*i; + __asm__ volatile (""); + } + + for (i = 0; i < N; i++) + { + s.ca[i] = s.cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != s.cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-36.c b/SingleSource/Regression/C/gcc-dg/vect/vect-36.c new file mode 100644 index 0000000000..d1743100aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-36.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + int i; + struct { + char ca[N]; + char cb[N]; + } s; + + + for (i = 0; i < N; i++) + { + s.cb[i] = 3*i; + __asm__ volatile (""); + } + + for (i = 0; i < N; i++) + { + s.ca[i] = s.cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.ca[i] != s.cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-38.c b/SingleSource/Regression/C/gcc-dg/vect/vect-38.c new file mode 100644 index 0000000000..3ddac87f27 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-38.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_double } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +double cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +double ca[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + ca[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-4.c new file mode 100644 index 0000000000..1774718c1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-4.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 20 + +float a[N]; +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + a[i] = b[i] * c[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + +/* Aligned pointer accesses. + The loop bound is known and divisible by the vectorization factor. + No aliasing problems. + vect-46.c is similar to this one with one difference: + the loop bound is unknown. */ + +float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) + = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; +float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) + = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float *pa = a; + float *pb = b; + float *pc = c; + + for (i = 0; i < N; i++) + { + pa[i] = pb[i] * pc[i]; + } + + bar (pa,pb,pc); + + return 0; +} + +int main (void) +{ + check_vect (); + main1 (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"} } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-42.c b/SingleSource/Regression/C/gcc-dg/vect/vect-42.c new file mode 100644 index 0000000000..c95496d4ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-42.c @@ -0,0 +1,75 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options double_vectors } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + +/* Unaligned write access, aligned read accesses. + Since we are handling an unaligned store by peeling the loop, + the loads will become unaligned. + The loop bound is known and divisible by the vectorization factor. + No aliasing problems. */ + +__attribute__ ((noinline)) int +main1 (float * __restrict__ pa, float *pb, float *pc) +{ + float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + int i; + + /* We also vectorize this loop. */ + for (i = 0; i < N; i++) + { + b[i] = pb[i]; + c[i] = pc[i]; + } + + for (i = 0; i < N; i++) + { + pa[i] = b[i] * c[i]; + } + + return 0; +} + +int main (void) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (a,b,c); + bar (a,b,c); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { { ! vector_alignment_reachable } && { ! vect_element_align } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { xfail { vect_no_align || { { ! vector_alignment_reachable } || vect_element_align } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { target vect_element_align xfail { ! { vect_unaligned_possible && vect_align_stack_vars } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { vect_no_align || { { ! vector_alignment_reachable } || vect_element_align } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-44.c b/SingleSource/Regression/C/gcc-dg/vect/vect-44.c new file mode 100644 index 0000000000..0396aefb8f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-44.c @@ -0,0 +1,75 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0" } */ + +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + +/* Unaligned pointer accesses, with unknown alignment. + The loop bound is known and divisible by the vectorization factor. + No aliasing problems. + vect-50.c is similar to this one with one difference: + the loop bound is unknown. + vect-45.c is similar to this one with one difference: + can't prove that pointers don't alias. */ + +__attribute__ ((noinline)) int +main1 (float * __restrict__ pa, float * __restrict__ pb, float * __restrict__ pc) +{ + int i; + + for (i = 0; i < N; i++) + { + pa[i] = pb[i] * pc[i]; + } + + bar (pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + float a[N+4] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float b[N+4] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69}; + float c[N+4] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}; + + check_vect (); + + main1 (a,b,c); + main1 (&a[1],b,c); + main1 (a,&b[1],c); + main1 (&a[1],&b[1],&c[1]); + + return 0; +} + +/* For targets that don't support misaligned loads we version for the + all three accesses (peeling to align the store will not force the + two loads to be aligned). */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" { xfail { { vect_no_align && { ! vect_hw_misalign } } || {! vector_alignment_reachable} } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 3 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { {! vector_alignment_reachable} && {{! vect_no_align} && {! vect_hw_misalign} } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-46.c b/SingleSource/Regression/C/gcc-dg/vect/vect-46.c new file mode 100644 index 0000000000..fee60f3628 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-46.c @@ -0,0 +1,67 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options double_vectors } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort(); + } + + return; +} + +/* Aligned pointer accesses. + The loop bound is unknown. + No aliasing problems. + vect-40.c is similar to this one with one difference: + the loop bound is known. */ + +float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) + = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; +float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) + = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +__attribute__ ((noinline)) int +main1 (int n) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float *pa = a; + float *pb = b; + float *pc = c; + + for (i = 0; i < n; i++) + { + pa[i] = pb[i] * pc[i]; + } + + bar (pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + int n=N; + check_vect (); + main1 (n); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-48.c b/SingleSource/Regression/C/gcc-dg/vect/vect-48.c new file mode 100644 index 0000000000..d06a17901e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-48.c @@ -0,0 +1,65 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options double_vectors } */ + +#include +#include "tree-vect.h" + +#define N 256 + +/* Unaligned pointer read accesses, aligned write access. + The loop bound is known and divisible by the vectorization factor. + No aliasing problems. + vect-56.c is similar to this one with one difference: + the alignment of the read accesses is known. + vect-52.c is similar to this one with one difference: + the loop bound is unknown. + vect-49.c is similar to this one with one difference: + aliasing is a problem. */ + +__attribute__ ((noinline)) int +main1 (float *pb, float *pc) +{ + float pa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + int i; + + for (i = 0; i < N; i++) + { + pa[i] = pb[i] * pc[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + float b[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60}; + float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (b,c); + main1 (&b[1],c); + + return 0; +} + +/* For targets that don't support misaligned loads we version for the two loads. + (The store is aligned). */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { target { ! vect_align_stack_vars } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target vect_align_stack_vars xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-5.c new file mode 100644 index 0000000000..c6574ee6bd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-5.c @@ -0,0 +1,62 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float a[N]; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + i = 0; + j = 0; + while (i < 5*N) + { + a[j] = c[j]; + i += 5; + j++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i 0; i--) + { + a[N-i] = d[N-i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != d[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-50.c b/SingleSource/Regression/C/gcc-dg/vect/vect-50.c new file mode 100644 index 0000000000..88739b61dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-50.c @@ -0,0 +1,71 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0" } */ + +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return; +} + +__attribute__ ((noinline)) int +main1 (int n, float * __restrict__ pa, float * __restrict__ pb, float * __restrict__ pc) +{ + int i; + + for (i = 0; i < n; i++) + { + pa[i] = pb[i] * pc[i]; + } + + bar (pa,pb,pc); + + return 0; +} + +/* Unaligned pointer accesses, with unknown alignment. + The loop bound is unknown. + No aliasing problems. + vect-44.c is similar to this one with one difference: + the loop bound is known. + vect-51.c is similar to this one with one difference: + can't prove that pointers don't alias. */ + +int main (void) +{ + int i; + float a[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (N,a,b,c); + return 0; +} + +/* For targets that don't support misaligned loads and don't support + misaligned stores we version for the all three accesses (peeling to + align the store will not force the two loads to be aligned). */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" { xfail { { vect_no_align && { ! vect_hw_misalign } } || {! vector_alignment_reachable} } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 3 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { {! vector_alignment_reachable} && { {! vect_no_align } && {! vect_hw_misalign } } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-52.c b/SingleSource/Regression/C/gcc-dg/vect/vect-52.c new file mode 100644 index 0000000000..6a0cb37333 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-52.c @@ -0,0 +1,66 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options double_vectors } */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 256 + +/* Unaligned pointer read accesses, aligned write access. + The loop bound is unknown. + No aliasing problems. + vect-60.c is similar to this one with one difference: + the alignment of the read accesses is known. + vect-48.c is similar to this one with one difference: + the loop bound is known. + vect-53.c is similar to this one with one difference: + aliasing is a problem. */ + +__attribute__ ((noinline)) int +main1 (int n, float *pb, float *pc) +{ + float pa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + int i; + + for (i = 0; i < n; i++) + { + pa[i] = pb[i] * pc[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float b[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60}; + float c[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; + + check_vect (); + + main1 (N,&b[1],c); + main1 (N,&b[1],&c[1]); + + return 0; +} + +/* For targets that don't support misaligned loads we version for the two loads. + (The store is aligned). */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { target { ! vect_align_stack_vars } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target vect_align_stack_vars xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-54.c b/SingleSource/Regression/C/gcc-dg/vect/vect-54.c new file mode 100644 index 0000000000..807cdd0a1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-54.c @@ -0,0 +1,68 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-add-options double_vectors } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (pa[i+1] != (pb[i+1] * pc[i+1])) + abort (); + } + + return; +} + +/* Unaligned pointer accesses, with a known alignment. + The loop bound is known and divisible by the vectorization factor. + No aliasing problems. + vect-58.c is similar to this one with one difference: + the loop bound is unknown. */ + +float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; +float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float *pa = a; + float *pb = b; + float *pc = c; + + for (i = 0; i < N/2; i++) + { + pa[i+1] = pb[i+1] * pc[i+1]; + } + + bar (a,b,c); + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_element_align_preferred } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-56.c b/SingleSource/Regression/C/gcc-dg/vect/vect-56.c new file mode 100644 index 0000000000..d3a8e9eca8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-56.c @@ -0,0 +1,79 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (pa[i] != (pb[i+1] * pc[i+1])) + abort (); + } + + return; +} + +/* Unaligned pointer read accesses, aligned write access. + The loop bound is known and divisible by the vectorization factor. + No aliasing problems. + vect-48.c is similar to this one with one difference: + the alignment of the read accesses is unknown. + vect-60.c is similar to this one with one difference: + the loop bound is unknown. + vect-57.c is similar to this one with two differences: + aliasing is a problem, and the write access has unknown alignment. */ + +float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; +float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float *pa = a; + float *pb = b; + float *pc = c; + + for (i = 0; i < N/2; i++) + { + pa[i] = pb[i+1] * pc[i+1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (pa[i] != (pb[i+1] * pc[i+1])) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target { ! vect_element_align } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { vect_element_align } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" { target { { ! vect_element_align } || vect_element_align_preferred} } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { vect_element_align && { ! vect_element_align_preferred } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-58.c b/SingleSource/Regression/C/gcc-dg/vect/vect-58.c new file mode 100644 index 0000000000..83b9214015 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-58.c @@ -0,0 +1,66 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (pa[i+1] != (pb[i+1] * pc[i+1])) + abort (); + } + + return; +} + +/* Unaligned pointer accesses, with a known alignment. + The loop bound is unknown. + No aliasing problems. + vect-54.c is similar to this one with one difference: + the loop bound is known. */ + +float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +__attribute__ ((noinline)) int +main1 (int n) +{ + int i; + float *pa = a; + float *pb = b; + float *pc = c; + + for (i = 0; i < n/2; i++) + { + pa[i+1] = pb[i+1] * pc[i+1]; + } + + bar (a,b,c); + + return 0; +} + +int main (void) +{ + int i; + int n=N; + + check_vect (); + main1 (n); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_element_align_preferred } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-6-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-6-big-array.c new file mode 100644 index 0000000000..8acab07fac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-6-big-array.c @@ -0,0 +1,77 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +float results1[N]; +float results2[N]; +float a[N] = {0}; +float e[N] = {0}; +float b[N]; +float c[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 16 + +float results1[N] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,0.00}; +float results2[N] = {0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00}; +float a[N] = {0}; +float e[N] = {0}; +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N/2; i++) + { + a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i]; + e[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i]; + } + + /* check results: */ +#pragma GCC novector + for (i=0; i +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (pa[i] != (pb[i+1] * pc[i+1])) + abort (); + } + + return; +} + +/* Unaligned pointer read accesses, aligned write access. + The loop bound is unknown + No aliasing problems. + vect-52.c is similar to this one with one difference: + the alignment of the read accesses is unknown. + vect-56.c is similar to this one with one difference: + the loop bound is known. + vect-61.c is similar to this one with two differences: + aliasing is not a problem, and the write access has unknown alignment. */ + +float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; +float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +__attribute__ ((noinline)) int +main1 (int n) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float *pa = a; + float *pb = b; + float *pc = c; + + for (i = 0; i < n/2; i++) + { + pa[i] = pb[i+1] * pc[i+1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (pa[i] != (pb[i+1] * pc[i+1])) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + int n=N; + + check_vect (); + main1 (n); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target { ! vect_element_align } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { vect_element_align } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" { target { { ! vect_element_align } || vect_element_align_preferred } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { vect_element_align && { ! vect_element_align_preferred } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-62.c b/SingleSource/Regression/C/gcc-dg/vect/vect-62.c new file mode 100644 index 0000000000..e2a13244b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-62.c @@ -0,0 +1,72 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ia[N][4][N+8]; + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. Store. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][j+8] = ib[i]; + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[i][1][j+8] != ib[i]) + abort(); + } + } + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. The outer loop is + vectorizable after invariant/store motion. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][8] = ib[i]; + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[i][1][8] != ib[i]) + abort(); + } + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-63.c b/SingleSource/Regression/C/gcc-dg/vect/vect-63.c new file mode 100644 index 0000000000..2974059556 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-63.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ia[N*2][4][N]; + + /* Multidimensional array. Aligned. + The first dimension depends on j: use strided stores. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ia[i + j][1][j] = ib[i]; + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[i + j][1][j] != ib[i]) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-64.c b/SingleSource/Regression/C/gcc-dg/vect/vect-64.c new file mode 100644 index 0000000000..2513ba31d1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-64.c @@ -0,0 +1,90 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + int ia[N][4][N+1]; + int ic[N][N][3][N+1]; + int id[N][N][N+1]; + + /* Multidimensional array. Not aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][j] = ib[i]; + } + } + + /* Multidimensional array. Aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ic[i][1][1][j] = ib[i]; + } + } + + /* Multidimensional array. Not aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + id[i][1][j+1] = ib[i]; + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[i][1][j] != ib[i]) + abort(); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ic[i][1][1][j] != ib[i]) + abort(); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (id[i][1][j+1] != ib[i]) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-65.c b/SingleSource/Regression/C/gcc-dg/vect/vect-65.c new file mode 100644 index 0000000000..60176a95d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-65.c @@ -0,0 +1,86 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define M 4 + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + int ib[M][M][N] = {{{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}}; + int ia[M][M][N]; + int ic[N]; + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. Load and store. */ + for (i = 0; i < M; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][j] = ib[2][i][j]; + } + } + + /* check results: */ + for (i = 0; i < M; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[i][1][j] != ib[2][i][j]) + abort(); + } + } + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. Load. */ + for (i = 0; i < M; i++) + { + for (j = 0; j < N; j++) + { + ic[j] = ib[2][i][j]; + } + } + + /* check results: */ + for (i = 0; i < M; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ic[j] != ib[2][i][j]) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-66.c b/SingleSource/Regression/C/gcc-dg/vect/vect-66.c new file mode 100644 index 0000000000..f7a78ace7d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-66.c @@ -0,0 +1,100 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +void main1 () +{ + int i, j; + int ia[8][5][N+2]; + + /* Multidimensional array. Aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < N; j++) + { + ia[2][6][j] = 5; + } + } + + /* check results: */ + for (i = 0; i < 16; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[2][6][j] != 5) + abort(); + } + } +} + +__attribute__ ((noinline)) +void main2 () +{ + int i, j; + int ia[8][5][N+2]; + + /* Multidimensional array. Aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < N; j++) + ia[3][6][j+2] = 5; + } + + /* check results: */ + for (i = 0; i < 16; i++) + { +#pragma GCC novector + for (j = 2; j < N+2; j++) + { + if (ia[3][6][j] != 5) + abort(); + } + } +} + +__attribute__ ((noinline)) +void main3 () +{ + int i, j; + int ic[16][16][5][N+2]; + + /* Multidimensional array. Not aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < N; j++) + { + ic[2][1][6][j+1] = 5; + } + } + + /* check results: */ + for (i = 0; i < 16; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ic[2][1][6][j+1] != 5) + abort(); + } + } +} + +int main (void) +{ + check_vect (); + + main1 (); + main2 (); + main3 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-67.c b/SingleSource/Regression/C/gcc-dg/vect/vect-67.c new file mode 100644 index 0000000000..08e58f96b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-67.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 256 +#define NINTS (VECTOR_BITS / 32) +#else +#define NINTS 8 +#endif + +#define N (NINTS * 2) + +__attribute__ ((noinline)) +int main1 (int a, int b) +{ + int i, j; + int ia[N][4][N + NINTS]; + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. Store. + Not vectorizable: unsupported operation. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][j + NINTS] = (a == b); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { +#pragma GCC novector + for (j = 0; j < N; j++) + { + if (ia[i][1][j + NINTS] != (a == b)) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (2 ,7); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-68.c b/SingleSource/Regression/C/gcc-dg/vect/vect-68.c new file mode 100644 index 0000000000..e687338363 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-68.c @@ -0,0 +1,94 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 32 + +struct s{ + int m; + int n[N][N][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e; /* array e.n is aligned */ +}; + +__attribute__ ((noinline)) +int main1 () +{ + int i,j; + struct test1 tmp1; + + /* 1. unaligned */ + for (i = 0; i < N; i++) + { + tmp1.a.n[1][2][i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 128 + +short sa[N]; +short sb[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + sb[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (sb[i] != 5) + abort (); + } + + for (i = 0; i < N; i++) + { + sa[i] = sb[i] + 100; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (sa[i] != 105) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-70.c b/SingleSource/Regression/C/gcc-dg/vect/vect-70.c new file mode 100644 index 0000000000..b5e112d1f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-70.c @@ -0,0 +1,90 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0 -fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define NINTS (VECTOR_BITS / 32) +#else +#define NINTS 4 +#endif + +#define N (NINTS * 6) + +/* Keep execution time down. */ +#if N <= 24 +#define OUTERN N +#else +#define OUTERN NINTS +#endif + +struct s{ + int m; + int n[4][4][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e[N]; /* array e.n is aligned */ +}; + +/* Avoid big local temporaries. */ +#if NINTS > 8 +struct test1 tmp1; +#endif + +__attribute__ ((noinline)) +int main1 () +{ + int i,j; +#if NINTS <= 8 + struct test1 tmp1; +#endif + + for (i = 0; i < OUTERN; i++) + for (j = NINTS - 1; j < N - NINTS + 1; j++) + { + tmp1.e[i].n[1][2][j] = 8; + } + + /* check results: */ + for (i = 0; i < OUTERN; i++) +#pragma GCC novector + for (j = NINTS - 1; j < N - NINTS + 1; j++) + { + if (tmp1.e[i].n[1][2][j] != 8) + abort (); + } + + /* not consecutive, will use strided stores */ + for (i = 0; i < OUTERN; i++) + for (j = NINTS - 1; j < N - NINTS + 1; j++) + { + tmp1.e[j].n[1][2][j] = 8; + } + + /* check results: */ + for (i = 0; i < OUTERN; i++) +#pragma GCC novector + for (j = NINTS - 1; j < N - NINTS + 1; j++) + { + if (tmp1.e[j].n[1][2][j] != 8) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" {target {{! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-71.c b/SingleSource/Regression/C/gcc-dg/vect/vect-71.c new file mode 100644 index 0000000000..561cb62db2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-71.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +/* indirect access. */ + +__attribute__ ((noinline)) +int main1 () +{ + int i; + unsigned ia[N]; + unsigned ib[N+1] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2}; + + for (i = 2; i < N+1; i++) + { + ia[ib[i]] = 0; + } + + /* check results: */ +#pragma GCC novector + for (i = 2; i < N+1; i++) + { + if (ia[ib[i]] != 0) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-72.c b/SingleSource/Regression/C/gcc-dg/vect/vect-72.c new file mode 100644 index 0000000000..72052fd305 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-72.c @@ -0,0 +1,56 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 128 + +/* unaligned load. */ + +char ia[N]; +char ib[N+1]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i=0; i < N+1; i++) + { + ib[i] = i; + if (i%3 == 0) + ib[i] = 5; + /* Avoid vectorization. */ + __asm__ volatile ("" : : : "memory"); + } + + for (i = 1; i < N+1; i++) + { + ia[i-1] = ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= N; i++) + { + if (ia[i-1] != ib[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-73-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-73-big-array.c new file mode 100644 index 0000000000..2237fa544b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-73-big-array.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +int ic[N*2]; +int ib[N]; + +#define ia (ic+N) + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + for (i = 0; i < N; i++) + { + ib[i] = i*3; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + ia[i] = ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-73.c b/SingleSource/Regression/C/gcc-dg/vect/vect-73.c new file mode 100644 index 0000000000..ceb5b8355d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-73.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int ic[N*2]; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +#define ia (ic+N) + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i]) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-74-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-74-big-array.c new file mode 100644 index 0000000000..8ac85e2d07 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-74-big-array.c @@ -0,0 +1,66 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float b[N+4] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0}; +float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5}; + +__attribute__ ((noinline)) int +main1 (float *__restrict__ pa, float * __restrict__ pb, float * __restrict__ pc) +{ + int i; + float *q = pb + 4; + + for (i = 0; i < N; i++) + { + b[i] = i; + c[i] = 0.5 + i; + asm volatile ("" ::: "memory"); + } + for (; i < N+4; i++) + { + b[i] = i; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + pa[i] = q[i] * pc[i]; + } + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != q[i] * pc[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (a, b, c); + + return 0; +} + +/* Xfail until handling restrict is refined. See pr29145. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* Uncomment when this testcase gets vectorized again: + dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target vect_no_align } } + dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } + dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } +*/ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-74.c b/SingleSource/Regression/C/gcc-dg/vect/vect-74.c new file mode 100644 index 0000000000..8012bc80bf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-74.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float b[N+4] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0}; +float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5}; + +__attribute__ ((noinline)) int +main1 (float *__restrict__ pa, float * __restrict__ pb, float * __restrict__ pc) +{ + int i; + float *q = pb + 4; + + for (i = 0; i < N; i++) + { + pa[i] = q[i] * pc[i]; + } + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != q[i] * pc[i]) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (a, b, c); + + return 0; +} + +/* Xfail until handling restrict is refined. See pr29145 */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* Uncomment when this testcase gets vectorized again: + dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target vect_no_align } } + dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } + dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } +*/ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-75-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-75-big-array.c new file mode 100644 index 0000000000..f0914fa148 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-75-big-array.c @@ -0,0 +1,58 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 120 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17}; + +__attribute__ ((noinline)) +int main1 (int *ib) +{ + int i; + int ia[N]; + + for (i = OFF; i < N+OFF; i++) + { + ib[i] = ib[i%OFF]*(i/OFF); + asm volatile ("" ::: "memory"); + } + for (i = 0; i < N; i++) + { + ia[i] = ib[i+OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+OFF]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib); + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target { ! vect_align_stack_vars } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target vect_align_stack_vars xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-75.c b/SingleSource/Regression/C/gcc-dg/vect/vect-75.c new file mode 100644 index 0000000000..f2b2f3a0e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-75.c @@ -0,0 +1,58 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 32) +#define OFF (VECTOR_BITS / 32) +#else +#define N 8 +#define OFF 8 +#endif + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; + +__attribute__ ((noinline)) +int main1 (int *ib) +{ + int i; + int ia[N]; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+OFF]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib); + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target { ! vect_align_stack_vars } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target vect_align_stack_vars xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-76-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-76-big-array.c new file mode 100644 index 0000000000..7db7727a9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-76-big-array.c @@ -0,0 +1,84 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 124 +#define OFF 4 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17}; +int ic[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17}; + +__attribute__ ((noinline)) +int main1 (int *pib) +{ + int i; + int ia[N+OFF]; + for (i = OFF; i < N+OFF; i++) + { + ib[i] = ib[i%8]*(i/8); + ic[i] = ic[i%8]*(i/8); + asm volatile ("" ::: "memory"); + } + + for (i = OFF; i < N; i++) + { + ia[i] = pib[i - OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = OFF; i < N; i++) + { + if (ia[i] != pib[i - OFF]) + abort (); + } + + for (i = 0; i < N; i++) + { + ia[i] = pib[i - OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != pib[i - OFF]) + abort (); + } + + for (i = OFF; i < N; i++) + { + ia[i] = ic[i - OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = OFF; i < N; i++) + { + if (ia[i] != ic[i - OFF]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (&ib[OFF]); + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-76.c b/SingleSource/Regression/C/gcc-dg/vect/vect-76.c new file mode 100644 index 0000000000..2f6faaf7ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-76.c @@ -0,0 +1,78 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 24 +#define OFF 4 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10}; +int ic[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10}; + +__attribute__ ((noinline)) +int main1 (int *pib) +{ + int i; + int ia[N+OFF]; + + for (i = OFF; i < N; i++) + { + ia[i] = pib[i - OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = OFF; i < N; i++) + { + if (ia[i] != pib[i - OFF]) + abort (); + } + + for (i = 0; i < N; i++) + { + ia[i] = pib[i - OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != pib[i - OFF]) + abort (); + } + + for (i = OFF; i < N; i++) + { + ia[i] = ic[i - OFF]; + } + + + /* check results: */ +#pragma GCC novector + for (i = OFF; i < N; i++) + { + if (ia[i] != ic[i - OFF]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (&ib[OFF]); + return 0; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-77-alignchecks.c b/SingleSource/Regression/C/gcc-dg/vect/vect-77-alignchecks.c new file mode 100644 index 0000000000..612cbdb755 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-77-alignchecks.c @@ -0,0 +1,65 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 32) +#define OFF (VECTOR_BITS / 32) +#else +#define N 8 +#define OFF 8 +#endif + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; + +__attribute__ ((noinline)) +int main1 (int *ib, int off) +{ + int i; + int ia[N]; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib, 8); + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + The store is aligned if alignment can be forced on the stack. Otherwise, we need to + peel the loop in order to align the store. For targets that can't align variables + using peeling (don't guarantee natural alignment) versioning the loop is required + both for the load and the store. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target { ! vect_align_stack_vars } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target vect_align_stack_vars xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { {! vect_no_align} && { unaligned_stack && vector_alignment_reachable } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { { {! unaligned_stack} && { vect_no_align && { ! vect_hw_misalign } } } || {unaligned_stack && { {! vector_alignment_reachable} && {! vect_no_align } } } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 2 "vect" { target { { unaligned_stack && { vector_alignment_reachable && vect_no_align } } || {unaligned_stack && { {! vector_alignment_reachable} && vect_no_align } } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-77-global.c b/SingleSource/Regression/C/gcc-dg/vect/vect-77-global.c new file mode 100644 index 0000000000..d7e4642eb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-77-global.c @@ -0,0 +1,57 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 8 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; +int ia[N]; + +__attribute__ ((noinline)) +int main1 (int *ib, int off) +{ + int i; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib, 8); + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + (The store is aligned). */ +/* Requires versioning for aliasing. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-77.c b/SingleSource/Regression/C/gcc-dg/vect/vect-77.c new file mode 100644 index 0000000000..6702b0b9ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-77.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 8 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; + +__attribute__ ((noinline)) +int main1 (int *ib, int off) +{ + int i; + int ia[N]; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib, 8); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-78-alignchecks.c b/SingleSource/Regression/C/gcc-dg/vect/vect-78-alignchecks.c new file mode 100644 index 0000000000..1b3637afd6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-78-alignchecks.c @@ -0,0 +1,66 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 32) +#define OFF (VECTOR_BITS / 32) +#else +#define N 8 +#define OFF 8 +#endif + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; +int off = 8; + +__attribute__ ((noinline)) +int main1 (int *ib) +{ + int i; + int ia[N]; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib); + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + The store is aligned if alignment can be forced on the stack. Otherwise, we need to + peel the loop in order to align the store. For targets that can't align variables + using peeling (don't guarantee natural alignment) versioning the loop is required + both for the load and the store. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target vect_align_stack_vars xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target { ! vect_align_stack_vars } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { {! vect_no_align} && { unaligned_stack && vector_alignment_reachable } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { { {! unaligned_stack} && { vect_no_align && { ! vect_hw_misalign } } } || {unaligned_stack && { {! vector_alignment_reachable} && { ! vect_no_align } } } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 2 "vect" { target { { unaligned_stack && { vector_alignment_reachable && vect_no_align } } || {unaligned_stack && { {! vector_alignment_reachable} && vect_no_align } } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-78-global.c b/SingleSource/Regression/C/gcc-dg/vect/vect-78-global.c new file mode 100644 index 0000000000..5936cd9ff4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-78-global.c @@ -0,0 +1,57 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 8 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ia[N]; +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; +int off = 8; + +__attribute__ ((noinline)) +int main1 (int *ib) +{ + int i; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib); + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + (The store is aligned). */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-78.c b/SingleSource/Regression/C/gcc-dg/vect/vect-78.c new file mode 100644 index 0000000000..b30bf88bff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-78.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 8 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; +int off = 8; + +__attribute__ ((noinline)) +int main1 (int *ib) +{ + int i; + int ia[N]; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-8.c new file mode 100644 index 0000000000..20d3585125 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-8.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float b[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; +float a[N]; + +__attribute__ ((noinline)) +int main1 (int n) +{ + int i; + + /* Vectorized: unknown loop bound). */ + for (i = 0; i < n; i++){ + a[i] = b[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (a[i] != b[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-80-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-80-big-array.c new file mode 100644 index 0000000000..edc3da9163 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-80-big-array.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +float fa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float fb[N+4] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float fc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +__attribute__ ((noinline)) int +main1 (float * __restrict__ pa, float * __restrict__ pb, float *__restrict__ pc) +{ + int i; + float *q = pb + 4; + for (i = 0; i < N; i++) + { + fb[i] = i; + fc[i] = 0.5+i; + asm volatile ("" ::: "memory"); + } + for (; i < N+4; i++) + { + fb[i] = i; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + pa[i] = q[i] * pc[i]; + } + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != q[i] * pc[i]) + abort (); + } + + return 0; +} + + +int main (void) +{ + check_vect (); + + main1 (fa, fb, fc); + + return 0; +} + +/* For targets that don't support misaligned loads we version for the + all three accesses (peeling to align the store will not force the + two loads to be aligned). */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* Uncomment when this testcase gets vectorized again: + dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } + dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } + dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 3 "vect" { target vect_no_align } } +*/ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-80.c b/SingleSource/Regression/C/gcc-dg/vect/vect-80.c new file mode 100644 index 0000000000..e3245fea49 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-80.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float fa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float fb[N+4] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0}; +float fc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5}; + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +__attribute__ ((noinline)) int +main1 (float * __restrict__ pa, float * __restrict__ pb, float *__restrict__ pc) +{ + int i; + float *q = pb + 4; + + for (i = 0; i < N; i++) + { + pa[i] = q[i] * pc[i]; + } + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != q[i] * pc[i]) + abort(); + } + + return 0; +} + + +int main (void) +{ + check_vect (); + + main1 (fa, fb, fc); + + return 0; +} + +/* For targets that don't support misaligned loads we version for the + all three accesses (peeling to align the store will not force the + two loads to be aligned). */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* Uncomment when this testcase gets vectorized again: + dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } + dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } + dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 3 "vect" { target vect_no_align } } +*/ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-82.c b/SingleSource/Regression/C/gcc-dg/vect/vect-82.c new file mode 100644 index 0000000000..4b2d5a8a46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-82.c @@ -0,0 +1,39 @@ +/* { dg-skip-if "powerpc and integer vectorization only" { ! { powerpc*-*-* && vect_int } } } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + long long unsigned int ca[N]; + int i; + + for (i = 0; i < N; i++) + { + ca[i] = 0; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != 0) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-82_64.c b/SingleSource/Regression/C/gcc-dg/vect/vect-82_64.c new file mode 100644 index 0000000000..58fc50d474 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-82_64.c @@ -0,0 +1,41 @@ +/* { dg-do run { target { { powerpc*-*-* && lp64 } && powerpc_altivec_ok } } } */ +/* { dg-do compile { target { { powerpc*-*-* && ilp32 } && powerpc_altivec_ok } } } */ +/* { dg-additional-options "-mpowerpc64 -maltivec -fdump-tree-optimized-details-blocks" } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + long long unsigned int ca[N]; + int i; + + for (i = 0; i < N; i++) + { + ca[i] = 0; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != 0) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-83.c b/SingleSource/Regression/C/gcc-dg/vect/vect-83.c new file mode 100644 index 0000000000..1a173daa14 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-83.c @@ -0,0 +1,39 @@ +/* { dg-skip-if "powerpc and integer vectorization only" { ! { powerpc*-*-* && vect_int } } } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + long long unsigned int ca[N]; + int i; + + for (i = 0; i < N; i++) + { + ca[i] = 2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != 2) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-83_64.c b/SingleSource/Regression/C/gcc-dg/vect/vect-83_64.c new file mode 100644 index 0000000000..88128d34c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-83_64.c @@ -0,0 +1,41 @@ +/* { dg-do run { target { { powerpc*-*-* && lp64 } && powerpc_altivec_ok } } } */ +/* { dg-do compile { target { { powerpc*-*-* && ilp32 } && powerpc_altivec_ok } } } */ +/* { dg-additional-options "-mpowerpc64 -maltivec -fdump-tree-optimized-details-blocks" } */ +/* { dg-skip-if "" { powerpc-ibm-aix* } } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + long long unsigned int ca[N]; + int i; + + for (i = 0; i < N; i++) + { + ca[i] = 2; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != 2) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-85-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-85-big-array.c new file mode 100644 index 0000000000..1d9914371b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-85-big-array.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) +int main1 (int *a) +{ + int i, j, k; + int b[N]; + + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + k = i + N; + a[j] = k; + } + b[i] = k; + } + + +#pragma GCC novector + for (j = 0; j < N; j++) + if (a[j] != i + N - 1) + abort (); + +#pragma GCC novector + for (j = 0; j < N; j++) + if (b[j] != j + N) + abort (); + + return 0; +} + +int main (void) +{ + int a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + check_vect (); + + main1 (a); + + return 0; +} + +/* Fails for targets that don't vectorize PLUS (e.g alpha). */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-85.c b/SingleSource/Regression/C/gcc-dg/vect/vect-85.c new file mode 100644 index 0000000000..e91fb45d53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-85.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 (int *a) +{ + int i, j, k; + int b[N]; + + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + k = i + N; + a[j] = k; + } + b[i] = k; + } + + +#pragma GCC novector + for (j = 0; j < N; j++) + if (a[j] != i + N - 1) + abort(); + +#pragma GCC novector + for (j = 0; j < N; j++) + if (b[j] != j + N) + abort(); + + return 0; +} + +int main (void) +{ + int a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + check_vect (); + + main1 (a); + + return 0; +} + +/* Fails for targets that don't vectorize PLUS (e.g alpha). */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-86.c b/SingleSource/Regression/C/gcc-dg/vect/vect-86.c new file mode 100644 index 0000000000..83c0cd039b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-86.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int a[N]; + +__attribute__ ((noinline)) +int main1 (int n) +{ + int i, j, k; + int b[N]; + + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + k = i + n; + a[j] = k; + } + b[i] = k; + } + +#pragma GCC novector + for (j = 0; j < n; j++) + if (a[j] != i + n - 1) + abort(); + +#pragma GCC novector + for (i = 0; i < n; i++) + if (b[i] != i + n) + abort(); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N); + main1 (0); + main1 (1); + main1 (2); + main1 (N-1); + + return 0; +} + +/* Fails for targets that don't vectorize PLUS (e.g alpha). */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-87.c b/SingleSource/Regression/C/gcc-dg/vect/vect-87.c new file mode 100644 index 0000000000..3f368b6c87 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-87.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0 -fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 (int n, int *a) +{ + int i, j, k; + int b[N]; + + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + k = i + n; + a[j] = k; + } + b[i] = k; + } + + +#pragma GCC novector + for (j = 0; j < n; j++) + if (a[j] != i + n - 1) + abort(); + +#pragma GCC novector + for (j = 0; j < n; j++) + if (b[j] != j + n) + abort(); + + return 0; +} + +int main (void) +{ + int a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + check_vect (); + + main1 (N, a); + main1 (0, a); + main1 (1, a); + main1 (2, a); + main1 (N-1, a); + + return 0; +} + +/* Fails for targets that don't vectorize PLUS (e.g alpha). */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" {target { {! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-88.c b/SingleSource/Regression/C/gcc-dg/vect/vect-88.c new file mode 100644 index 0000000000..4071580e4b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-88.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0 -fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 (int n, int *a) +{ + int i, j, k; + int b[N]; + + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + k = i + n; + a[j] = k; + } + b[i] = k; + } + + +#pragma GCC novector + for (j = 0; j < n; j++) + if (a[j] != i + n - 1) + abort(); + +#pragma GCC novector + for (j = 0; j < n; j++) + if (b[j] != j + n) + abort(); + + return 0; +} + +int main (void) +{ + int a[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + check_vect (); + + main1 (N, a+1); + main1 (0, a+1); + main1 (1, a+1); + main1 (2, a+1); + main1 (N-1, a+1); + + return 0; +} + +/* Fails for targets that don't vectorize PLUS (e.g alpha). */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" {target { {! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-89-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-89-big-array.c new file mode 100644 index 0000000000..db09a65845 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-89-big-array.c @@ -0,0 +1,53 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +struct tmp_struct +{ + int x; + int y[N]; +}; + +__attribute__ ((noinline)) +int main1 () +{ + int i, *q; + struct tmp_struct tmp, *p; + + p = &tmp; + q = p->y; + + for (i = 0; i < N; i++) + { + *q++ = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (p->y[i] != 5) + { + abort (); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { vect_element_align_preferred || { ! vect_align_stack_vars } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-89.c b/SingleSource/Regression/C/gcc-dg/vect/vect-89.c new file mode 100644 index 0000000000..98b5fe4d9c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-89.c @@ -0,0 +1,57 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 256 +#define N (VECTOR_BITS * 2 / 32) +#else +#define N 16 +#endif + +struct tmp_struct +{ + int x; + int y[N]; +}; + +__attribute__ ((noinline)) +int main1 () +{ + int i, *q; + struct tmp_struct tmp, *p; + + p = &tmp; + q = p->y; + + for (i = 0; i < N; i++) + { + *q++ = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (p->y[i] != 5) + { + abort (); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { vect_element_align_preferred || { ! vect_align_stack_vars } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-9.c new file mode 100644 index 0000000000..01b2b47859 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-9.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +short sb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ia[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + /* Requires type promotion (vector unpacking) support. */ + for (i = 0; i < N; i++) + { + ia[i] = (int) sb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != (int) sb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-91.c b/SingleSource/Regression/C/gcc-dg/vect/vect-91.c new file mode 100644 index 0000000000..ee54953d71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-91.c @@ -0,0 +1,72 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-do compile } */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0" } */ + +#include +#include "tree-vect.h" + +#define N 256 + +/* Pick a value greater than the vector length. */ +#if VECTOR_BITS > 128 +#define OFF (VECTOR_BITS * 5 / 32) +#else +#define OFF 20 +#endif + +extern int a[N + OFF]; + +/* The alignment of 'pa' is unknown. + Yet we do know that both the read access and write access have + the same alignment. Peeling to align one of the accesses will + align the other. */ + +__attribute__ ((noinline)) int +main1 (int * pa) +{ + int i; + + for (i = 0; i < N; i++) + { + pa[i] = pa[i] + 1; + } + + return 0; +} + +/* The alignment of 'a' is unknown. + Yet we do know that both the read access and write access have + the same alignment. Peeling to align one of the accesses will + align the other. */ + +__attribute__ ((noinline)) int +main2 () +{ + int i; + + for (i = 0; i < N; i++) + { + a[i] = a[i] + 1; + } + + return 0; +} + +__attribute__ ((noinline)) int +main3 () +{ + int i; + + for (i = 0; i < N; i++) + { + a[i] = a[i + OFF]; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" { xfail vect_no_int_add } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" {target { {! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-92.c b/SingleSource/Regression/C/gcc-dg/vect/vect-92.c new file mode 100644 index 0000000000..beb3eeac74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-92.c @@ -0,0 +1,107 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 256 + +float pa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float pb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; +float pc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +/* Check handling of unaligned accesses when the misalignment is + known at compile time and different accesses have the same + misalignment (e.g. peeling to align one access will align all + accesses with the same misalignment. Also, the number of + peeled iterations is known in this case, and the vectorizer + can use this information (generate prolog and epilog loops + with known number of iterations, and only if needed). */ + +#if VECTOR_BITS > 128 +#define NITER (VECTOR_BITS * 3 / 32) +#else +#define NITER 12 +#endif + +__attribute__ ((noinline)) int +main1 () +{ + int i; + + for (i = 0; i < NITER - 2; i++) + { + pa[i+1] = pb[i+1] * pc[i+1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < 10; i++) + { + if (pa[i+1] != (pb[i+1] * pc[i+1])) + abort (); + } + + return 0; +} + +__attribute__ ((noinline)) int +main2 () +{ + int i; + + for (i = 0; i < NITER; i++) + { + pa[i+1] = pb[i+1] * pc[i+1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < 12; i++) + { + if (pa[i+1] != (pb[i+1] * pc[i+1])) + abort (); + } + + return 0; +} + +__attribute__ ((noinline)) int +main3 (int n) +{ + int i; + + for (i = 0; i < n; i++) + { + pa[i+1] = pb[i+1] * pc[i+1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (pa[i+1] != (pb[i+1] * pc[i+1])) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + main1 (); + main2 (); + main3 (N-1); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 3 "vect" { xfail vect_element_align_preferred } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-93.c b/SingleSource/Regression/C/gcc-dg/vect/vect-93.c new file mode 100644 index 0000000000..75af52d643 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-93.c @@ -0,0 +1,93 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "--param vect-max-peeling-for-alignment=0 -fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N1 3001 + +#if VECTOR_BITS > 256 +#define N2 (VECTOR_BITS / 32 + 2) +#else +#define N2 10 +#endif + +__attribute__ ((noinline)) int +main1 (float *pa) +{ + int i; + + for (i = 0; i < N1; i++) + { + pa[i] = 2.0; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N1; i++) + { + if (pa[i] != 2.0) + abort (); + } + +#pragma GCC unroll 0 + for (i = 1; i <= N2; i++) + { + pa[i] = 3.0; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= N2; i++) + { + if (pa[i] != 3.0) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + float a[N1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float b[N1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + + check_vect (); + + /* from bzip2: */ + for (i = 0; i < N1; i++) + b[i] = i; + a[0] = 0; + for (i = 1; i <= 256; i++) a[i] = b[i-1]; + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= 256; i++) + { + if (a[i] != i-1) + abort (); + } + if (a[0] != 0) + abort (); + + main1 (a); + + return 0; +} + +/* 2 loops vectorized in main1, 2 loops vectorized in main: + the first loop in main requires vectorization of conversions, + the second loop in main requires vectorization of misaligned load. */ + +/* main && main1 together: */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" { target powerpc*-*-* i?86-*-* x86_64-*-* } } } */ + +/* in main1: */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target !powerpc*-*-* !i?86-*-* !x86_64-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ + +/* in main: */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-95.c b/SingleSource/Regression/C/gcc-dg/vect/vect-95.c new file mode 100644 index 0000000000..e06503cccc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-95.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void bar (float *pd, float *pa, float *pb, float *pc) +{ + int i; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pa[i] != (pb[i] * pc[i])) + abort (); + if (pd[i] != 5.0) + abort (); + } + + return; +} + + +__attribute__ ((noinline)) int +main1 (int n, float * __restrict__ pd, float * __restrict__ pa, float * __restrict__ pb, float * __restrict__ pc) +{ + int i; + + for (i = 0; i < n; i++) + { + pa[i] = pb[i] * pc[i]; + pd[i] = 5.0; + } + + bar (pd,pa,pb,pc); + + return 0; +} + +int main (void) +{ + int i; + float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float d[N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + check_vect (); + + main1 (N,&d[1],a,b,c); + main1 (N-2,&d[1],a,b,c); + + return 0; +} + +/* For targets that support unaligned loads we version for the two unaligned + stores and generate misaligned accesses for the loads. For targets that + don't support unaligned loads we version for all four accesses. */ + +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail { vect_no_align || vect_element_align} } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { xfail { vect_no_align || vect_element_align } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 4 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-96.c b/SingleSource/Regression/C/gcc-dg/vect/vect-96.c new file mode 100644 index 0000000000..df1307a381 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-96.c @@ -0,0 +1,58 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options double_vectors } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 256 +#define N (VECTOR_BITS * 2 / 32) +#else +#define N 16 +#endif + +struct tmp +{ + int x; + int ia[N]; +}; + +__attribute__ ((noinline)) +int main1 (int off) +{ + struct tmp sb[N]; + struct tmp *pp = &sb[off]; + int i, ib[N]; + + for (i = 0; i < N; i++) + pp->ia[i] = ib[i]; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (pp->ia[i] != ib[i]) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (8); +} + +/* The store is unaligned, the load is aligned. For targets that support unaligned + loads, peel to align the store and generate an unaligned access for the load. + For targets that don't support unaligned loads, version for the store. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { target { { {! vect_no_align} && vector_alignment_reachable } && { ! vect_align_stack_vars } } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { { {! vect_no_align} && vector_alignment_reachable } && vect_align_stack_vars } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { { vect_no_align } || { { ! vector_alignment_reachable} || vect_element_align } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { { vect_no_align && { ! vect_hw_misalign } } || { {! vector_alignment_reachable} && {! vect_element_align} } } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-97-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-97-big-array.c new file mode 100644 index 0000000000..32b7d46711 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-97-big-array.c @@ -0,0 +1,73 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 128 + +char x[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +char cb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) +int main1 () +{ + struct { + char *p; + char *q; + } s; + int i; + for (i = 0; i < N; i++) + { + cb[i] = i*3; + asm volatile ("" ::: "memory"); + } + + /* Check that datarefs analysis can determine that the access via pointer + s.p is based off array x, which enables us to antialias this access from + the access to array cb. */ + s.p = x; + for (i = 0; i < N; i++) + { + s.p[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.p[i] != cb[i]) + abort (); + } + + /* Check that datarefs analysis can determine that the access via pointer + s.p is based off array x, and that the access via pointer s.q is based off + array cb, which enables us to antialias these two accesses. */ + s.q = cb; + for (i = 0; i < N; i++) + { + s.p[i] = s.q[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.p[i] != s.q[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-97.c b/SingleSource/Regression/C/gcc-dg/vect/vect-97.c new file mode 100644 index 0000000000..796361572f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-97.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 + +char x[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +char cb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 () +{ + struct { + char *p; + char *q; + } s; + int i; + + /* Check that datarefs analysis can determine that the access via pointer + s.p is based off array x, which enables us to antialias this access from + the access to array cb. */ + s.p = x; + for (i = 0; i < N; i++) + { + s.p[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.p[i] != cb[i]) + abort (); + } + + /* Check that datarefs analysis can determine that the access via pointer + s.p is based off array x, and that the access via pointer s.q is based off + array cb, which enables us to antialias these two accesses. */ + s.q = cb; + for (i = 0; i < N; i++) + { + s.p[i] = s.q[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (s.p[i] != s.q[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-98-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-98-big-array.c new file mode 100644 index 0000000000..b97a20701e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-98-big-array.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DOT16( a, b) ( a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + \ + a[4]*b[4] + a[5]*b[5] + a[6]*b[6] + a[7]*b[7] + \ + a[8]*b[8] + a[9]*b[9] + a[10]*b[10] + a[11]*b[11] + \ + a[12]*b[12] + a[13]*b[13] + a[14]*b[14] + a[15]*b[15]) + +__attribute__ ((noinline)) +int main1 (int ia[][N]) +{ + int i, j; + int ib[N] = {0,3,6,9}; + int ic[N][N]; + + for (i = 0; i < N; i++) + { + ic[0][i] = DOT16 (ia[i], ib); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ic[0][i] != DOT16 (ia[i], ib)) + abort (); + } + + return 0; +} + +int main (void) +{ + int ia[N][N]; + int i,j; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + ia[i][j] = i + j + 1; + asm volatile ("" ::: "memory"); + } + + check_vect (); + + return main1 (ia); +} + +/* Needs interleaving support. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided4 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { xfail vect_strided4 } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-98.c b/SingleSource/Regression/C/gcc-dg/vect/vect-98.c new file mode 100644 index 0000000000..472612745f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-98.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include +#include "tree-vect.h" + +#define M 8 +#define N 4 +#define DOT4( a, b ) ( a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3] ) + +__attribute__ ((noinline)) +int main1 (int ia[][N]) +{ + int i, j; + int ib[N] = {0,3,6,9}; + int ic[M][M]; + + for (i = 0; i < M; i++) + { + ic[0][i] = DOT4 (ia[i], ib); + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < M; i++) + { + if (ic[0][i] != DOT4 (ia[i], ib)) + abort(); + } + + return 0; +} + +int main (void) +{ + int ia[M][N] = {{1,2,3,4},{2,3,5,7},{2,4,6,8},{22,43,55,77}, + {13,17,19,23},{29,31,37,41},{3,7,2,1},{4,9,8,3}}; + + check_vect (); + + return main1 (ia); +} + +/* Needs interleaving support. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided4 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { xfail vect_strided4 } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-99.c b/SingleSource/Regression/C/gcc-dg/vect/vect-99.c new file mode 100644 index 0000000000..f6ac00adff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-99.c @@ -0,0 +1,34 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ + +#include "tree-vect.h" + +int ca[100]; + +__attribute__ ((noinline)) +void foo (int n) +{ + unsigned int i; + + for (i = 0; i < n; i++) + ca[i] = 2; +} + +int main (void) +{ + int i; + + check_vect (); + + foo(100); + +#pragma GCC novector + for (i = 0; i < 100; ++i) { + if (ca[i] != 2) + abort(); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-aggressive-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-aggressive-1.c new file mode 100644 index 0000000000..b18d2cbefa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-aggressive-1.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#include "tree-vect.h" + +#define N 64 +int a[N]; +int c[N]; + +__attribute__ ((noinline)) int +foo (void) +{ + int i, res = 0; +#pragma omp simd safelen(8) + for (i = 0; i < N; i++) + { + int t = a[i]; + if (c[i] != 0) + if (t != 100 & t > 5) + res += 1; + } + return res; +} + +__attribute__ ((noinline)) int +hundred (void) +{ + return 100; +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + c[i] = i & 1; + switch (i & 3) + { +case 0: + a[i] = hundred (); + break; +case 1: + a[i] = 1; + break; +default: + a[i] = i + 6; + break; + } + } + if (foo () != 16) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-1.c new file mode 100644 index 0000000000..6a2cef1586 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-Ofast" } */ + +int b, c = 1; +int a[6][5] = { {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 1, 0, 0, 0} }; + +void +fn1 () +{ + int d; + for (b = 0; b < 5; b++) + for (d = 4; d; d--) + a[c + 1][b] = a[d + 1][d]; +} + +/* { dg-final { scan-tree-dump "improved number of alias checks from \[0-9\]* to 1" "vect" } } */ +/* { dg-final { scan-tree-dump "using an address-based overlap test" "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-10.c new file mode 100644 index 0000000000..8fd3bf407e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-10.c @@ -0,0 +1,71 @@ +#define N 87 +#define M 6 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE(I) ((I) * 5 / 2) + +#define ADD_TEST(TYPE) \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (TYPE *a, int step) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + a[i * step + 0] = a[i * step + 0] + 1; \ + a[i * step + 1] = a[i * step + 1] + 2; \ + a[i * step + 2] = a[i * step + 2] + 4; \ + a[i * step + 3] = a[i * step + 3] + 8; \ + } \ + } \ + void __attribute__((noinline, noclone)) \ + ref_##TYPE (TYPE *a, int step) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + a[i * step + 0] = a[i * step + 0] + 1; \ + a[i * step + 1] = a[i * step + 1] + 2; \ + a[i * step + 2] = a[i * step + 2] + 4; \ + a[i * step + 3] = a[i * step + 3] + 8; \ + asm volatile (""); \ + } \ + } + +#define DO_TEST(TYPE) \ + _Pragma("GCC novector") \ + for (int j = -M; j <= M; ++j) \ + { \ + TYPE a[N * M], b[N * M]; \ + for (int i = 0; i < N * M; ++i) \ + a[i] = b[i] = TEST_VALUE (i); \ + int offset = (j < 0 ? N * M - 4 : 0); \ + test_##TYPE (a + offset, j); \ + ref_##TYPE (b + offset, j); \ + if (__builtin_memcmp (a, b, sizeof (a)) != 0) \ + __builtin_abort (); \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-11.c new file mode 100644 index 0000000000..5ecdc32507 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-11.c @@ -0,0 +1,101 @@ +#define N 87 +#define M 6 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE1(I) ((I) * 5 / 2) +#define TEST_VALUE2(I) ((I) * 11 / 5) + +#define ADD_TEST(TYPE) \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (TYPE *restrict a, TYPE *restrict b, \ + int step) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + TYPE r1 = a[i * step + 0] += 1; \ + a[i * step + 1] += 2; \ + a[i * step + 2] += 4; \ + a[i * step + 3] += 8; \ + b[i] += r1; \ + } \ + } \ + \ + void __attribute__((noinline, noclone)) \ + ref_##TYPE (TYPE *restrict a, TYPE *restrict b, \ + int step) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + TYPE r1 = a[i * step + 0] += 1; \ + a[i * step + 1] += 2; \ + a[i * step + 2] += 4; \ + a[i * step + 3] += 8; \ + b[i] += r1; \ + asm volatile (""); \ + } \ + } + +#define DO_TEST(TYPE) \ + _Pragma("GCC novector") \ + for (int j = -M; j <= M; ++j) \ + { \ + TYPE a1[N * M], a2[N * M], b1[N], b2[N]; \ + for (int i = 0; i < N * M; ++i) \ + a1[i] = a2[i] = TEST_VALUE1 (i); \ + for (int i = 0; i < N; ++i) \ + b1[i] = b2[i] = TEST_VALUE2 (i); \ + int offset = (j < 0 ? N * M - 4 : 0); \ + test_##TYPE (a1 + offset, b1, j); \ + ref_##TYPE (a2 + offset, b2, j); \ + if (__builtin_memcmp (a1, a2, sizeof (a1)) != 0) \ + __builtin_abort (); \ + if (__builtin_memcmp (b1, b2, sizeof (b1)) != 0) \ + __builtin_abort (); \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* is outside \(-2, 2\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* is outside \(-3, 3\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* is outside \(-4, 4\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {run-time check [^\n]* abs \([^*]*\) >= 4} "vect" { target vect_int } } } */ + +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 2[)]* is outside \(-4, 4\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 2[)]* is outside \(-6, 6\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 2[)]* is outside \(-8, 8\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {run-time check [^\n]* abs \([^*]* \* 2[)]* >= 8} "vect" { target vect_int } } } */ + +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 4[)]* is outside \(-8, 8\)} "vect" { target { vect_int || vect_float } } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 4[)]* is outside \(-12, 12\)} "vect" { target { vect_int || vect_float } } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 4[)]* is outside \(-16, 16\)} "vect" { target { vect_int || vect_float } } } } */ +/* { dg-final { scan-tree-dump {run-time check [^\n]* abs \([^*]* \* 4[)]* >= 16} "vect" { target { vect_int || vect_float } } } } */ + +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 8[)]* is outside \(-16, 16\)} "vect" { target vect_double } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 8[)]* is outside \(-24, 24\)} "vect" { target vect_double } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* step[^ ]* \* 8[)]* is outside \(-32, 32\)} "vect" { target vect_double } } } */ +/* { dg-final { scan-tree-dump {run-time check [^\n]* abs \([^*]* \* 8[)]* >= 32} "vect" { target vect_double } } } */ + +/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-12.c new file mode 100644 index 0000000000..23690c45b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-12.c @@ -0,0 +1,101 @@ +#define N 87 +#define M 7 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE1(I) ((I) * 5 / 2) +#define TEST_VALUE2(I) ((I) * 11 / 5) + +#define ADD_TEST(TYPE) \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (TYPE *restrict a, TYPE *restrict b, \ + int step) \ + { \ + step = step & M; \ + for (int i = 0; i < N; ++i) \ + { \ + TYPE r1 = a[i * step + 0] += 1; \ + a[i * step + 1] += 2; \ + a[i * step + 2] += 4; \ + a[i * step + 3] += 8; \ + b[i] += r1; \ + } \ + } \ + \ + void __attribute__((noinline, noclone)) \ + ref_##TYPE (TYPE *restrict a, TYPE *restrict b, \ + int step) \ + { \ + for (unsigned short i = 0; i < N; ++i) \ + { \ + TYPE r1 = a[i * step + 0] += 1; \ + a[i * step + 1] += 2; \ + a[i * step + 2] += 4; \ + a[i * step + 3] += 8; \ + b[i] += r1; \ + asm volatile (""); \ + } \ + } + +#define DO_TEST(TYPE) \ + _Pragma("GCC novector") \ + for (int j = 0; j <= M; ++j) \ + { \ + TYPE a1[N * M], a2[N * M], b1[N], b2[N]; \ + for (int i = 0; i < N * M; ++i) \ + a1[i] = a2[i] = TEST_VALUE1 (i); \ + for (int i = 0; i < N; ++i) \ + b1[i] = b2[i] = TEST_VALUE2 (i); \ + test_##TYPE (a1, b1, j); \ + ref_##TYPE (a2, b2, j); \ + if (__builtin_memcmp (a1, a2, sizeof (a1)) != 0) \ + __builtin_abort (); \ + if (__builtin_memcmp (b1, b2, sizeof (b1)) != 0) \ + __builtin_abort (); \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* is outside \[0, 2\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* is outside \[0, 3\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* is outside \[0, 4\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {run-time check [^\n]* unsigned \([^*]*\) >= 4} "vect" { target vect_int } } } */ + +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 2[)]* is outside \[0, 4\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 2[)]* is outside \[0, 6\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 2[)]* is outside \[0, 8\)} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump {run-time check [^\n]* unsigned \([^*]* \* 2[)]* >= 8} "vect" { target vect_int } } } */ + +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 4[)]* is outside \[0, 8\)} "vect" { target { vect_int || vect_float } }} } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 4[)]* is outside \[0, 12\)} "vect" { target { vect_int || vect_float } }} } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 4[)]* is outside \[0, 16\)} "vect" { target { vect_int || vect_float } }} } */ +/* { dg-final { scan-tree-dump {run-time check [^\n]* unsigned \([^*]* \* 4[)]* >= 16} "vect" { target { vect_int || vect_float } }} } */ + +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 8[)]* is outside \[0, 16\)} "vect" { target vect_double } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 8[)]* is outside \[0, 24\)} "vect" { target vect_double } } } */ +/* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 8[)]* is outside \[0, 32\)} "vect" { target vect_double } } } */ +/* { dg-final { scan-tree-dump {run-time check [^\n]* unsigned \([^*]* \* 8[)]* >= 32} "vect" { target vect_double } } } */ + +/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-13.c new file mode 100644 index 0000000000..812aa9027d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-13.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void +f1 (int *x, long step1, int n) +{ + for (int i = 0; i < n; ++i) + x[i * step1] += 1; +} + +void +f2 (int *x, long step2, int n) +{ +#pragma GCC ivdep + for (int i = 0; i < n; ++i) + x[i * step2] += 2; +} + +/* { dg-final { scan-tree-dump {need run-time check that [^\n]*step1[^\n]* is nonzero} "vect" } } */ +/* { dg-final { scan-tree-dump-not {need run-time check that [^\n]*step2[^\n]* is nonzero} "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ +/* { dg-final { scan-tree-dump-times {LOOP VECTORIZED} 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-14.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-14.c new file mode 100644 index 0000000000..b36ad11676 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-14.c @@ -0,0 +1,66 @@ +#define N 200 +#define M 4 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE(I) ((I) * 17 / 2) + +#define ADD_TEST(TYPE) \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (TYPE *a, TYPE *b) \ + { \ + for (int i = 0; i < N; i += 2) \ + { \ + TYPE b0 = b[i + 0]; \ + TYPE b1 = b[i + 1]; \ + a[i + 0] = b0 + 2; \ + a[i + 1] = b1 + 3; \ + } \ + } + +#define DO_TEST(TYPE) \ + for (int j = 0; j < M; ++j) \ + { \ + TYPE a[N + M]; \ + for (int i = 0; i < N + M; ++i) \ + a[i] = TEST_VALUE (i); \ + test_##TYPE (a + j, a); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; i += 2) \ + { \ + TYPE base1 = j == 0 ? TEST_VALUE (i) : a[i]; \ + TYPE base2 = j <= 1 ? TEST_VALUE (i + 1) : a[i + 1]; \ + if (a[i + j] != (TYPE) (base1 + 2) \ + || a[i + j + 1] != (TYPE) (base2 + 3)) \ + __builtin_abort (); \ + } \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: *WAR\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {flags: [^\n]*ARBITRARY\n} "vect" } } */ +/* { dg-final { scan-tree-dump "using an address-based WAR/WAW test" "vect" { target { ! vect_check_ptrs } } } } */ +/* { dg-final { scan-tree-dump "using an IFN_CHECK_WAR_PTRS test" "vect" { target vect_check_ptrs } } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-15.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-15.c new file mode 100644 index 0000000000..f7545e79d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-15.c @@ -0,0 +1,63 @@ +#define N 200 +#define DIST 32 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define ADD_TEST(TYPE) \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (TYPE *x, TYPE *y) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + x[i] = i; \ + y[i] = 42 - i * 2; \ + } \ + } + +#define DO_TEST(TYPE) \ + for (int i = 0; i < DIST * 2; ++i) \ + { \ + TYPE a[N + DIST * 2] = {}; \ + test_##TYPE (a + DIST, a + i); \ + _Pragma("GCC novector") \ + for (int j = 0; j < N + DIST * 2; ++j) \ + { \ + TYPE expected = 0; \ + if (i > DIST && j >= i && j < i + N) \ + expected = 42 - (j - i) * 2; \ + if (j >= DIST && j < DIST + N) \ + expected = j - DIST; \ + if (i <= DIST && j >= i && j < i + N) \ + expected = 42 - (j - i) * 2; \ + if (expected != a[j]) \ + __builtin_abort (); \ + } \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: *WAW\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "using an address-based WAR/WAW test" "vect" { target { ! vect_check_ptrs } } } } */ +/* { dg-final { scan-tree-dump "using an IFN_CHECK_WAR_PTRS test" "vect" { target vect_check_ptrs } } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-16.c new file mode 100644 index 0000000000..d90adc70e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-16.c @@ -0,0 +1,69 @@ +#define N 200 +#define DIST 32 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE(I) ((I) * 13 / 2) + +#define ADD_TEST(TYPE) \ + TYPE __attribute__((noinline, noclone)) \ + test_##TYPE (TYPE *x, TYPE *y) \ + { \ + TYPE res = 0; \ + for (int i = 0; i < N; ++i) \ + { \ + x[i] = i; \ + res += y[i]; \ + } \ + return res; \ + } + +#define DO_TEST(TYPE) \ + _Pragma("GCC novector") \ + for (int i = 0; i < DIST * 2; ++i) \ + { \ + TYPE a[N + DIST * 2]; \ + for (int j = 0; j < N + DIST * 2; ++j) \ + a[j] = TEST_VALUE (j); \ + TYPE res = test_##TYPE (a + DIST, a + i); \ + _Pragma("GCC novector") \ + for (int j = 0; j < N; ++j) \ + if (a[j + DIST] != (TYPE) j) \ + __builtin_abort (); \ + TYPE expected_res = 0; \ + for (int j = i; j < i + N; ++j) \ + if (i <= DIST && j >= DIST && j < DIST + N) \ + expected_res += j - DIST; \ + else \ + expected_res += TEST_VALUE (j); \ + if (expected_res != res) \ + __builtin_abort (); \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: *RAW\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "using an address-based overlap test" "vect" { target { ! vect_check_ptrs } } } } */ +/* { dg-final { scan-tree-dump "using an IFN_CHECK_RAW_PTRS test" "vect" { target vect_check_ptrs } } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-17.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-17.c new file mode 100644 index 0000000000..c49c497c2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-17.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_load_lanes } */ + +struct s { int x[100]; }; + +void +f (struct s *s1, int a, int b) +{ + for (int i = 0; i < 32; ++i) + s1->x[a + i] = s1->x[b + i * 2] + s1->x[b + i * 3]; +} + +/* { dg-final { scan-tree-dump {flags: *[^\n]*MIXED_STEPS} "vect" } } */ +/* { dg-final { scan-tree-dump "using an address-based overlap test" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-18.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-18.c new file mode 100644 index 0000000000..3b576a4dc4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-18.c @@ -0,0 +1,65 @@ +#define N 200 +#define DIST 32 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE(I) ((I) * 11 / 2) + +#define ADD_TEST(TYPE) \ + TYPE a_##TYPE[N * 2]; \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (int x, int y) \ + { \ + for (int i = 0; i < N; ++i) \ + a_##TYPE[x - i] += a_##TYPE[y - i]; \ + } + +#define DO_TEST(TYPE) \ + for (int i = 0; i < DIST * 2; ++i) \ + { \ + for (int j = 0; j < N + DIST * 2; ++j) \ + a_##TYPE[j] = TEST_VALUE (j); \ + test_##TYPE (i + N - 1, DIST + N - 1); \ + _Pragma("GCC novector") \ + for (int j = 0; j < N + DIST * 2; ++j) \ + { \ + TYPE expected; \ + if (j < i || j >= i + N) \ + expected = TEST_VALUE (j); \ + else if (i >= DIST) \ + expected = ((TYPE) TEST_VALUE (j) \ + + (TYPE) TEST_VALUE (j + DIST - i)); \ + else \ + expected = ((TYPE) TEST_VALUE (j) \ + + a_##TYPE[j + DIST - i]); \ + if (expected != a_##TYPE[j]) \ + __builtin_abort (); \ + } \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: *WAR\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "using an index-based WAR/WAW test" "vect" { target { vect_int && vect_perm } } } } */ +/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-19.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-19.c new file mode 100644 index 0000000000..36771b04ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-19.c @@ -0,0 +1,63 @@ +#define N 200 +#define DIST 32 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define ADD_TEST(TYPE) \ + TYPE a_##TYPE[N * 2]; \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (int x, int y) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + a_##TYPE[i + x] = i; \ + a_##TYPE[i + y] = 42 - i * 2; \ + } \ + } + +#define DO_TEST(TYPE) \ + for (int i = 0; i < DIST * 2; ++i) \ + { \ + __builtin_memset (a_##TYPE, 0, sizeof (a_##TYPE)); \ + test_##TYPE (DIST, i); \ + _Pragma("GCC novector") \ + for (int j = 0; j < N + DIST * 2; ++j) \ + { \ + TYPE expected = 0; \ + if (i > DIST && j >= i && j < i + N) \ + expected = 42 - (j - i) * 2; \ + if (j >= DIST && j < DIST + N) \ + expected = j - DIST; \ + if (i <= DIST && j >= i && j < i + N) \ + expected = 42 - (j - i) * 2; \ + if (expected != a_##TYPE[j]) \ + __builtin_abort (); \ + } \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: *WAW\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "using an index-based WAR/WAW test" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-2.c new file mode 100644 index 0000000000..1163314524 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int_mult } */ + +int a [128]; +int b[128] = {0}; + +int foo (void) +{ + int k; + + for(k=0; k<64; k++) + { + b[k] = 10 - b[127-k]; + a[k] = b[k] * 3; + a[127-k] = b[127-k] * 2; + } +} + +/* { dg-final { scan-tree-dump-not "versioning for alias checks." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-20.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-20.c new file mode 100644 index 0000000000..9658f8ce38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-20.c @@ -0,0 +1,68 @@ +#define N 200 +#define DIST 32 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE(I) ((I) * 11 / 2) + +#define ADD_TEST(TYPE) \ + TYPE a_##TYPE[N * 2]; \ + TYPE __attribute__((noinline, noclone)) \ + test_##TYPE (int x, int y) \ + { \ + TYPE res = 0; \ + for (int i = 0; i < N; ++i) \ + { \ + a_##TYPE[i + x] = i; \ + res += a_##TYPE[i + y]; \ + } \ + return res; \ + } + +#define DO_TEST(TYPE) \ + _Pragma("GCC novector") \ + for (int i = 0; i < DIST * 2; ++i) \ + { \ + for (int j = 0; j < N + DIST * 2; ++j) \ + a_##TYPE[j] = TEST_VALUE (j); \ + TYPE res = test_##TYPE (DIST, i); \ + _Pragma("GCC novector") \ + for (int j = 0; j < N; ++j) \ + if (a_##TYPE[j + DIST] != (TYPE) j) \ + __builtin_abort (); \ + TYPE expected_res = 0; \ + for (int j = i; j < i + N; ++j) \ + if (i <= DIST && j >= DIST && j < DIST + N) \ + expected_res += j - DIST; \ + else \ + expected_res += TEST_VALUE (j); \ + if (expected_res != res) \ + __builtin_abort (); \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: *RAW\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "using an index-based overlap test" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-3.c new file mode 100644 index 0000000000..10b4c3d2c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-3.c @@ -0,0 +1,120 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-version-for-alias-checks=0 -fopenmp-simd" } */ + +/* Intended to be larger than any VF. */ +#define GAP 128 +#define N (GAP * 3) + +struct s { int x[N + 1]; }; +struct t { struct s x[N + 1]; }; +struct u { int x[N + 1]; int y; }; +struct v { struct s s; }; + +void +f1 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a->x[i] += b->x[i]; +} + +void +f2 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a[1].x[i] += b[2].x[i]; +} + +void +f3 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a[1].x[i] += b[i].x[i]; +} + +void +f4 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a[i].x[i] += b[i].x[i]; +} + +void +f5 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a->x[i] += b->x[i + 1]; +} + +void +f6 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a[1].x[i] += b[2].x[i + 1]; +} + +void +f7 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a[1].x[i] += b[i].x[i + 1]; +} + +void +f8 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a[i].x[i] += b[i].x[i + 1]; +} + +void +f9 (struct s *a, struct t *b) +{ + for (int i = 0; i < N; ++i) + a->x[i] += b->x[1].x[i]; +} + +void +f10 (struct s *a, struct t *b) +{ + for (int i = 0; i < N; ++i) + a->x[i] += b->x[i].x[i]; +} + +void +f11 (struct u *a, struct u *b) +{ + for (int i = 0; i < N; ++i) + a->x[i] += b->x[i] + b[i].y; +} + +void +f12 (struct s *a, struct s *b) +{ + for (int i = 0; i < GAP; ++i) + a->x[i + GAP] += b->x[i]; +} + +void +f13 (struct s *a, struct s *b) +{ + for (int i = 0; i < GAP * 2; ++i) + a->x[i + GAP] += b->x[i]; +} + +void +f14 (struct v *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a->s.x[i] = b->x[i]; +} + +void +f15 (struct s *a, struct s *b) +{ + #pragma omp simd safelen(N) + for (int i = 0; i < N; ++i) + a->x[i + 1] += b->x[i]; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 15 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-4.c new file mode 100644 index 0000000000..750193e3cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-4.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param vect-max-version-for-alias-checks=0 -fopt-info-vec-all" } */ + +#define N 16 + +struct s1 { int a[N]; }; +struct s2 { struct s1 b; int c; }; +struct s3 { int d; struct s1 e; }; +union u { struct s2 f; struct s3 g; }; + +/* We allow a and b to overlap arbitrarily. */ + +void +f1 (int a[][N], int b[][N]) /* { dg-message "vectorized 0 loops in function" } */ +{ + for (int i = 0; i < N; ++i) /* { dg-missed "couldn't vectorize loop" } */ + a[0][i] += b[0][i]; + /* { dg-message "will not create alias checks, as --param vect-max-version-for-alias-checks == 0" "" { target *-*-* } .-2 } */ +} + +void +f2 (union u *a, union u *b) /* { dg-message "vectorized 0 loops in function" } */ +{ + for (int i = 0; i < N; ++i) /* { dg-missed "couldn't vectorize loop" } */ + a->f.b.a[i] += b->g.e.a[i]; + /* { dg-message "will not create alias checks, as --param vect-max-version-for-alias-checks == 0" "" { target *-*-* } .-2 } */ +} + +void +f3 (struct s1 *a, struct s1 *b) /* { dg-message "vectorized 0 loops in function" } */ +{ + for (int i = 0; i < N - 1; ++i) /* { dg-missed "couldn't vectorize loop" } */ + a->a[i + 1] += b->a[i]; /* { dg-missed "possible dependence between data-refs" } */ +} + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-5.c new file mode 100644 index 0000000000..e17c7150a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +/* Intended to be larger than any VF. */ +#define GAP 128 +#define N (GAP * 3) + +struct s { int x[N]; }; + +void +f1 (struct s *a, struct s *b) +{ + for (int i = 0; i < GAP * 2; ++i) + a->x[i + GAP] += b->x[i]; +} + +/* { dg-final { scan-tree-dump-times "consider run-time aliasing" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "improved number of alias checks from 1 to 0" 1 "vect" { xfail vect_variable_length } } } */ +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-6.c new file mode 100644 index 0000000000..5bb78f8ad5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-6.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#define N 16 + +struct s { int x[N]; }; + +void +f1 (struct s *a, struct s *b) +{ + for (int i = 0; i < N - 1; ++i) + a->x[i + 1] += b->x[i]; +} + +/* { dg-final { scan-tree-dump {checking that [^\n]* and [^\n]* have different addresses} "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-7.c new file mode 100644 index 0000000000..812349de91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-7.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#define N 16 + +struct s { int x[N]; }; + +void +f1 (struct s *a, struct s *b) +{ + for (int i = 0; i < N; ++i) + a->x[i] += b->x[N - i - 1]; +} + +/* { dg-final { scan-tree-dump {checking that [^\n]* and [^\n]* have different addresses} "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { vect_perm && vect_element_align } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-8.c new file mode 100644 index 0000000000..3bc78bed67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-8.c @@ -0,0 +1,65 @@ +#define N 200 +#define DIST 32 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE(I) ((I) * 5 / 2) + +#define ADD_TEST(TYPE) \ + TYPE a_##TYPE[N * 2]; \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (int x, int y) \ + { \ + for (int i = 0; i < N; ++i) \ + a_##TYPE[i + x] += a_##TYPE[i + y]; \ + } + +#define DO_TEST(TYPE) \ + _Pragma("GCC novector") \ + for (int i = 0; i < DIST * 2; ++i) \ + { \ + for (int j = 0; j < N + DIST * 2; ++j) \ + a_##TYPE[j] = TEST_VALUE (j); \ + test_##TYPE (i, DIST); \ + for (int j = 0; j < N + DIST * 2; ++j) \ + { \ + TYPE expected; \ + if (j < i || j >= i + N) \ + expected = TEST_VALUE (j); \ + else if (i <= DIST) \ + expected = ((TYPE) TEST_VALUE (j) \ + + (TYPE) TEST_VALUE (j - i + DIST)); \ + else \ + expected = ((TYPE) TEST_VALUE (j) \ + + a_##TYPE[j - i + DIST]); \ + if (expected != a_##TYPE[j]) \ + __builtin_abort (); \ + } \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: *WAR\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "using an index-based WAR/WAW test" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-9.c new file mode 100644 index 0000000000..c11c1d13e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check-9.c @@ -0,0 +1,58 @@ +#define N 200 +#define M 4 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE(I) ((I) * 17 / 2) + +#define ADD_TEST(TYPE) \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (TYPE *a, TYPE *b) \ + { \ + for (int i = 0; i < N; i += 2) \ + { \ + a[i + 0] = b[i + 0] + 2; \ + a[i + 1] = b[i + 1] + 3; \ + } \ + } + +#define DO_TEST(TYPE) \ + for (int j = 1; j < M; ++j) \ + { \ + TYPE a[N + M]; \ + for (int i = 0; i < N + M; ++i) \ + a[i] = TEST_VALUE (i); \ + test_##TYPE (a + j, a); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; i += 2) \ + if (a[i + j] != (TYPE) (a[i] + 2) \ + || a[i + j + 1] != (TYPE) (a[i + 1] + 3)) \ + __builtin_abort (); \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: [^\n]*ARBITRARY\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "using an address-based overlap test" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check.c b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check.c new file mode 100644 index 0000000000..ab90895192 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-alias-check.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "--param=vect-max-version-for-alias-checks=2" } */ + +/* A test case showing four potential alias checks between a[i] and b[0], b[1], + b[i+1] and b[i+2]. With alias check merging enabled, those four checks + can be merged into two, and the loop will be vectorized with + vect-max-version-for-alias-checks=2. */ + +void foo (int *a, int *b) +{ + int i; + for (i = 0; i < 1000; ++i) + a[i] = b[0] + b[1] + b[i+1] + b[i+2]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-align-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-align-1.c new file mode 100644 index 0000000000..9630fc0738 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-align-1.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include +#include "tree-vect.h" + +/* Compile time known misalignment. Cannot use loop peeling to align + the store. */ + +#define N 16 + +struct foo { + char x; + int y[N]; +} __attribute__((packed)); + +int x[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) int +main1 (struct foo * __restrict__ p) +{ + int i; + + for (i = 0; i < N; i++) + { + p->y[i] = x[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (p->y[i] != x[i]) + abort (); + } + return 0; +} + + +int main (void) +{ + int i; + struct foo *p = malloc (2*sizeof (struct foo)); + check_vect (); + + main1 (p); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { vect_hw_misalign && { arm_vect_no_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { vect_hw_misalign && arm_vect_no_misalign } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-align-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-align-2.c new file mode 100644 index 0000000000..98759c155d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-align-2.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +/* Compile time unknown misalignment. Cannot use loop peeling to align + the store. */ + +#define N 17 + +struct foo { + char x0; + int y[N][N]; +} __attribute__ ((packed)); + +struct foo f2; +int z[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; + +__attribute__ ((noinline)) +void fbar(struct foo *fp) +{ + int i,j; + for (i=0; i +#include "tree-vect.h" + +#define N 128 + +int iadd_results[N]; +float fadd_results[N]; +float fmul_results[N]; +float fresults1[N]; +float fresults2[N]; + +/****************************************************/ +__attribute__ ((noinline)) +void icheck_results (int *a, int *results) +{ + int i; +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } +} + +__attribute__ ((noinline)) +void fcheck_results (float *a, float *results) +{ + int i; +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } +} + +__attribute__ ((noinline)) void +fbar_mul (float *a) +{ + fcheck_results (a, fmul_results); +} + +__attribute__ ((noinline)) void +fbar_add (float *a) +{ + fcheck_results (a, fadd_results); +} + +__attribute__ ((noinline)) void +ibar_add (int *a) +{ + icheck_results (a, iadd_results); +} + +__attribute__ ((noinline)) void +fbar1 (float *a) +{ + fcheck_results (a, fresults1); +} + +__attribute__ ((noinline)) void +fbar2 (float *a) +{ + fcheck_results (a, fresults2); +} + +float a[N]; +float e[N]; +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; +int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ia[N]; +char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +char ca[N]; +short sa[N]; + +/* All of the loops below are currently vectorizable, except + initialization ones. */ + +__attribute__ ((noinline)) int +main1 () +{ + int i,j; + /* Initialization. */ + for (i = 0; i < N; i++) + { + b[i] = i*3; + c[i] = i; + d[i] = i*2; + ic[i] = i*3; + ib[i] = i*3; + cb[i] = i*3; + fadd_results[i] = b[i] + c[i] + d[i]; + iadd_results[i] = ib[i] + ic[i]; + fmul_results[i] = b[i] * c[i]; + fresults1[i] = 0; + fresults2[i] = 0; + asm volatile ("" ::: "memory"); + } + + /* Test 1: copy chars. */ + for (i = 0; i < N; i++) + { + ca[i] = cb[i]; + } + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != cb[i]) + abort (); + } + + + /* Test 2: fp mult. */ + for (i = 0; i < N; i++) + { + a[i] = b[i] * c[i]; + } + fbar_mul (a); + + + /* Test 3: mixed types (int, fp), same nunits in vector. */ + for (i = 0; i < N; i++) + { + a[i] = b[i] + c[i] + d[i]; + e[i] = b[i] + c[i] + d[i]; + ia[i] = ib[i] + ic[i]; + } + ibar_add (ia); + fbar_add (a); + fbar_add (e); + + /* Initialization. */ + for (i = 0; i < N; i++) + { + fresults1[i] = a[i]; + fresults2[i] = e[i]; + asm volatile ("" ::: "memory"); + } + for (i = 0; i < N/2; i++) + { + fresults1[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i]; + fresults2[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i]; + asm volatile ("" ::: "memory"); + } + /* Test 4: access with offset. */ + for (i = 0; i < N/2; i++) + { + a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i]; + e[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i]; + } + fbar1 (a); + fbar2 (e); + + + /* Test 5: access with offset. */ + for (i = 1; i <=N-4; i++) + { + a[i+3] = b[i-1]; + } + /* check results: */ +#pragma GCC novector + for (i = 1; i <=N-4; i++) + { + if (a[i+3] != b[i-1]) + abort (); + } + + + /* Test 6 - loop induction with stride != 1. */ + i = 0; + j = 0; + while (i < 5*N) + { + a[j] = c[j]; + i += 5; + j++; + } + /* check results: */ +#pragma GCC novector + for (i = 0; i 0; i--) + { + a[N-i] = d[N-i]; + } + /* check results: */ +#pragma GCC novector + for (i = 0; i +#include "tree-vect.h" + +#define N 16 + +int iadd_results[N] = {0,6,12,18,24,30,36,42,48,54,60,66,72,78,84,90}; +float fadd_results[N] = {0.0,6.0,12.0,18.0,24.0,30.0,36.0,42.0,48.0,54.0,60.0,66.0,72.0,78.0,84.0,90.0}; +float fmul_results[N] = {0.0,3.0,12.0,27.0,48.0,75.0,108.0,147.0,192.0,243.0,300.0,363.0,432.0,507.0,588.0,675.0}; +float fresults1[N] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,48.00,54.00,60.00,66.00,72.00,78.00,84.00,90.00}; +float fresults2[N] = {0.00,6.00,12.00,18.00,24.00,30.00,36.00,42.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00}; + +/****************************************************/ +__attribute__ ((noinline)) +void icheck_results (int *a, int *results) +{ + int i; +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } +} + +__attribute__ ((noinline)) +void fcheck_results (float *a, float *results) +{ + int i; +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } +} + +__attribute__ ((noinline)) void +fbar_mul (float *a) +{ + fcheck_results (a, fmul_results); +} + +__attribute__ ((noinline)) void +fbar_add (float *a) +{ + fcheck_results (a, fadd_results); +} + +__attribute__ ((noinline)) void +ibar_add (int *a) +{ + icheck_results (a, iadd_results); +} + +__attribute__ ((noinline)) void +fbar1 (float *a) +{ + fcheck_results (a, fresults1); +} + +__attribute__ ((noinline)) void +fbar2 (float *a) +{ + fcheck_results (a, fresults2); +} + +float a[N]; +float e[N]; +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; +int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ia[N]; +char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +char ca[N]; +short sa[N]; + +/* All of the loops below are currently vectorizable. */ + +__attribute__ ((noinline)) int +main1 () +{ + int i,j; + + /* Test 1: copy chars. */ + for (i = 0; i < N; i++) + { + ca[i] = cb[i]; + } + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ca[i] != cb[i]) + abort (); + } + + + /* Test 2: fp mult. */ + for (i = 0; i < N; i++) + { + a[i] = b[i] * c[i]; + } + fbar_mul (a); + + + /* Test 3: mixed types (int, fp), same nunits in vector. */ + for (i = 0; i < N; i++) + { + a[i] = b[i] + c[i] + d[i]; + e[i] = b[i] + c[i] + d[i]; + ia[i] = ib[i] + ic[i]; + } + ibar_add (ia); + fbar_add (a); + fbar_add (e); + + + /* Test 4: access with offset. */ + for (i = 0; i < N/2; i++) + { + a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i]; + e[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i]; + } + fbar1 (a); + fbar2 (e); + + + /* Test 5: access with offset */ + for (i = 1; i <=N-4; i++) + { + a[i+3] = b[i-1]; + } + /* check results: */ +#pragma GCC novector + for (i = 1; i <=N-4; i++) + { + if (a[i+3] != b[i-1]) + abort (); + } + + + /* Test 6 - loop induction with stride != 1. */ + i = 0; + j = 0; + while (i < 5*N) + { + a[j] = c[j]; + i += 5; + j++; + } + /* check results: */ +#pragma GCC novector + for (i = 0; i 0; i--) + { + a[N-i] = d[N-i]; + } + /* check results: */ +#pragma GCC novector + for (i = 0; i > 1; +} + +#define BASE1 ((SIGNEDNESS int) -1 < 0 ? -126 : 4) +#define BASE2 ((SIGNEDNESS int) -1 < 0 ? -101 : 26) + +int +main (void) +{ + check_vect (); + + SIGNEDNESS char a[N], b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE1 + i * 5; + c[i] = BASE2 + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != ((BASE1 + BASE2 + i * 9 + BIAS) >> 1)) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-10.c new file mode 100644 index 0000000000..2630aeab91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-10.c @@ -0,0 +1,8 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS signed +#define BIAS 2 + +#include "vect-avg-5.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_average_pattern: detected" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-11.c new file mode 100644 index 0000000000..0046f8ceb4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-11.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS +#define SIGNEDNESS unsigned +#endif +#ifndef BIAS +#define BIAS 0 +#endif + +void __attribute__ ((noipa)) +f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b, + SIGNEDNESS char *restrict c) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int tmp = b[i]; + tmp ^= 0x55; + tmp += BIAS; + tmp += c[i]; + tmp >>= 1; + tmp |= 0x40; + a[i] = tmp; + } +} + +#define BASE1 ((SIGNEDNESS int) -1 < 0 ? -126 : 4) +#define BASE2 ((SIGNEDNESS int) -1 < 0 ? -101 : 26) + +int +main (void) +{ + check_vect (); + + SIGNEDNESS char a[N], b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE1 + i * 5; + c[i] = BASE2 + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != (((((BASE1 + i * 5) ^ 0x55) + + (BASE2 + i * 4) + + BIAS) >> 1) | 0x40)) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-12.c new file mode 100644 index 0000000000..f40331ea1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-12.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS signed + +#include "vect-avg-11.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-13.c new file mode 100644 index 0000000000..7957c0e4ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-13.c @@ -0,0 +1,11 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS unsigned +#define BIAS 1 + +#include "vect-avg-11.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_CEIL} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-14.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-14.c new file mode 100644 index 0000000000..8ab11f74e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-14.c @@ -0,0 +1,11 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS signed +#define BIAS 1 + +#include "vect-avg-11.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_CEIL} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-15.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-15.c new file mode 100644 index 0000000000..57b6670cb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-15.c @@ -0,0 +1,53 @@ +/* { dg-additional-options "-O3" } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 80 + +void __attribute__ ((noipa)) +f (signed char *restrict a, signed char *restrict b, + signed char *restrict c, int n, int step) +{ + for (int j = 0; j < n; ++j) + { + for (int i = 0; i < 16; ++i) + a[i] = (b[i] + c[i]) >> 1; + a += step; + b += step; + c += step; + } +} + +#define BASE1 -126 +#define BASE2 -42 + +signed char a[N], b[N], c[N]; + +int +main (void) +{ + check_vect (); + + for (int i = 0; i < N; ++i) + { + a[i] = i; + b[i] = BASE1 + i * 3; + c[i] = BASE2 + i * 2; + asm volatile ("" ::: "memory"); + } + f (a, b, c, N / 20, 20); +#pragma GCC novector + for (int i = 0; i < N; ++i) + { + int d = (BASE1 + BASE2 + i * 5) >> 1; + if (a[i] != (i % 20 < 16 ? d : i)) + __builtin_abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-16.c new file mode 100644 index 0000000000..319edba1fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-16.c @@ -0,0 +1,53 @@ +/* { dg-additional-options "-O3" } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 80 + +void __attribute__ ((noipa)) +f (signed char *restrict a, signed char *restrict b, + signed char *restrict c, int n) +{ + for (int j = 0; j < n; ++j) + { + for (int i = 0; i < 16; ++i) + a[i] = (b[i] + c[i]) >> 1; + a += 20; + b += 20; + c += 20; + } +} + +#define BASE1 -126 +#define BASE2 -42 + +signed char a[N], b[N], c[N]; + +int +main (void) +{ + check_vect (); + + for (int i = 0; i < N; ++i) + { + a[i] = i; + b[i] = BASE1 + i * 3; + c[i] = BASE2 + i * 2; + asm volatile ("" ::: "memory"); + } + f (a, b, c, N / 20); +#pragma GCC novector + for (int i = 0; i < N; ++i) + { + int d = (BASE1 + BASE2 + i * 5) >> 1; + if (a[i] != (i % 20 < 16 ? d : i)) + __builtin_abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-2.c new file mode 100644 index 0000000000..b5586b5f01 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-2.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS signed + +#include "vect-avg-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-3.c new file mode 100644 index 0000000000..104fe96139 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-3.c @@ -0,0 +1,11 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS unsigned +#define BIAS 1 + +#include "vect-avg-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_CEIL} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-4.c new file mode 100644 index 0000000000..92181d7fc3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-4.c @@ -0,0 +1,11 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS signed +#define BIAS 1 + +#include "vect-avg-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_CEIL} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-5.c new file mode 100644 index 0000000000..6bdaeff0d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-5.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS +#define SIGNEDNESS unsigned +#endif +#ifndef BIAS +#define BIAS 0 +#endif + +void __attribute__ ((noipa)) +f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b, + SIGNEDNESS char *restrict c) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int tmp1 = b[i] + BIAS; + int tmp2 = tmp1 + c[i]; + a[i] = tmp2 >> 1; + } +} + +#define BASE1 ((SIGNEDNESS int) -1 < 0 ? -126 : 4) +#define BASE2 ((SIGNEDNESS int) -1 < 0 ? -101 : 26) + +int +main (void) +{ + check_vect (); + + SIGNEDNESS char a[N], b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE1 + i * 5; + c[i] = BASE2 + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != ((BASE1 + BASE2 + i * 9 + BIAS) >> 1)) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-6.c new file mode 100644 index 0000000000..efe97b8a5f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-6.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS signed + +#include "vect-avg-5.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-7.c new file mode 100644 index 0000000000..62a8474f69 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-7.c @@ -0,0 +1,11 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS unsigned +#define BIAS 1 + +#include "vect-avg-5.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_CEIL} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-8.c new file mode 100644 index 0000000000..cc7c4cde6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-8.c @@ -0,0 +1,11 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS signed +#define BIAS 1 + +#include "vect-avg-5.c" + +/* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.AVG_CEIL} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-not {vector\([^\n]*short} "vect" { target vect_avg_qi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-avg-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-9.c new file mode 100644 index 0000000000..80865b6661 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-avg-9.c @@ -0,0 +1,8 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS unsigned +#define BIAS 2 + +#include "vect-avg-5.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_average_pattern: detected" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-10.c new file mode 100644 index 0000000000..4e2c964ed2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-10.c @@ -0,0 +1,26 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(int32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(int32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +#define TYPE int32_t +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump {<=\s*.+\{ 255,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967290,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-11.c new file mode 100644 index 0000000000..7cbe993858 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-11.c @@ -0,0 +1,25 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) != 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) != 0; +} + +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump {>\s*.+\{ 255,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967290,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-12.c new file mode 100644 index 0000000000..36ec5a8b19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-12.c @@ -0,0 +1,18 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-do assemble } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +typedef unsigned int v4si __attribute__ ((vector_size (16))); + +__attribute__((noinline, noipa)) +void fun(v4si *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +/* { dg-final { scan-tree-dump {<=\s*.+\{ 255,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967290,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-2.c new file mode 100644 index 0000000000..4a8026bba3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-2.c @@ -0,0 +1,25 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {<=\s*.+\{ 255,.+\}} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-23.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-23.c new file mode 100644 index 0000000000..5b4c3b6e19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-23.c @@ -0,0 +1,17 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-do assemble } */ +/* { dg-additional-options "-O1 -fdump-tree-dce -w" } */ + +#include + +typedef unsigned int v4si __attribute__ ((vector_size (16))); + +__attribute__((noinline, noipa)) +v4si fun(v4si x) +{ + v4si mask = { 255, 15, 1, 0xFFFF }; + v4si zeros = {0}; + return (x & ~mask) == zeros; +} + +/* { dg-final { scan-tree-dump {<=\s*.+\{ 255, 15, 1, 65535 \}} dce7 { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-3.c new file mode 100644 index 0000000000..4a8026bba3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-3.c @@ -0,0 +1,25 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) == 0; +} + +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {<=\s*.+\{ 255,.+\}} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-4.c new file mode 100644 index 0000000000..907a13fd1f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-4.c @@ -0,0 +1,25 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) >= 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) >= 0; +} + +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {=\s*.+\{ 1,.+\}} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-5.c new file mode 100644 index 0000000000..1333efffc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-5.c @@ -0,0 +1,25 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) > 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) > 0; +} + +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {>\s*.+\{ 255,.+\}} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-6.c new file mode 100644 index 0000000000..6b8a45c75b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-6.c @@ -0,0 +1,25 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) <= 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~255)) <= 0; +} + +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {<=\s*.+\{ 255,.+\}} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967040,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-8.c new file mode 100644 index 0000000000..fd0314b4dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-8.c @@ -0,0 +1,25 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~1)) != 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~1)) != 0; +} + +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump-times {>\s*.+\{ 1,.+\}} 1 dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {&\s*.+\{ 4294967294,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-9.c new file mode 100644 index 0000000000..7a80b87572 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bic-bitmask-9.c @@ -0,0 +1,25 @@ +/* { dg-skip-if "missing optab for vectorization" { sparc*-*-* } } */ +/* { dg-additional-options "-O3 -fdump-tree-dce -w" } */ + +#include + +__attribute__((noinline, noipa)) +void fun1(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~5)) == 0; +} + +__attribute__((noinline, noipa, optimize("O1"))) +void fun2(uint32_t *x, int n) +{ + for (int i = 0; i < (n & -16); i++) + x[i] = (x[i]&(~5)) == 0; +} + +#include "../bic-bitmask.h" + +/* { dg-final { scan-tree-dump-not {<=\s*.+\{ 4294967289,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump {&\s*.+\{ 4294967290,.+\}} dce7 { target vect_int } } } */ +/* { dg-final { scan-tree-dump-not {\s+bic\s+} dce7 { target { aarch64*-*-* } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-1-not.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-1-not.c new file mode 100644 index 0000000000..0d91067ebb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-1-not.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_long_long } */ +/* { dg-additional-options { "-fdump-tree-ifcvt-all" } } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + char a : 4; +}; + +#define N 32 +#define ELT0 {0} +#define ELT1 {1} +#define ELT2 {2} +#define ELT3 {3} +#define RES 56 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + { + switch (ptr[i].a) + { + case 0: + res += ptr[i].a + 1; + break; + case 1: + case 2: + case 3: + res += ptr[i].a; + break; + default: + return 0; + } + } + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "Bitfield OK to lower." "ifcvt" } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-1.c new file mode 100644 index 0000000000..147c959568 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-1.c @@ -0,0 +1,43 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { int i : 31; }; + +#define ELT0 {0} +#define ELT1 {1} +#define ELT2 {2} +#define ELT3 {3} +#define N 32 +#define RES 48 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + res += ptr[i].i; + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-2-not.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-2-not.c new file mode 100644 index 0000000000..4ac7b3fc0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-2-not.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_long_long } */ +/* { dg-additional-options { "-fdump-tree-ifcvt-all" } } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + char a : 4; +}; + +#define N 32 +#define ELT0 {0} +#define ELT1 {1} +#define ELT2 {2} +#define ELT3 {3} +#define RES 48 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + { + asm volatile ("" ::: "memory"); + res += ptr[i].a; + } + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "Bitfield OK to lower." "ifcvt" } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-2.c new file mode 100644 index 0000000000..982e6a7967 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-2.c @@ -0,0 +1,46 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_long_long } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned i : 31; + char a : 4; +}; + +#define N 32 +#define ELT0 {0x7FFFFFFFUL, 0} +#define ELT1 {0x7FFFFFFFUL, 1} +#define ELT2 {0x7FFFFFFFUL, 2} +#define ELT3 {0x7FFFFFFFUL, 3} +#define RES 48 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + res += ptr[i].a; + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-3.c new file mode 100644 index 0000000000..f2a43c39f5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-3.c @@ -0,0 +1,47 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" +#include + +extern void abort(void); + +typedef struct { + int c; + int b; + bool a : 1; + int d : 31; +} struct_t; + +#define N 16 +#define ELT_F { 0xFFFFFFFF, 0xFFFFFFFF, 0, 0x7FFFFFFF } +#define ELT_T { 0xFFFFFFFF, 0xFFFFFFFF, 1, 0x7FFFFFFF } + +struct_t vect_false[N] = { ELT_F, ELT_F, ELT_F, ELT_F, ELT_F, ELT_F, ELT_F, ELT_F, + ELT_F, ELT_F, ELT_F, ELT_F, ELT_F, ELT_F, ELT_F, ELT_F }; +struct_t vect_true[N] = { ELT_F, ELT_F, ELT_T, ELT_F, ELT_F, ELT_F, ELT_F, ELT_F, + ELT_F, ELT_F, ELT_T, ELT_F, ELT_F, ELT_F, ELT_F, ELT_F }; +int main (void) +{ + unsigned ret = 0; + for (unsigned i = 0; i < N; i++) + { + ret |= vect_false[i].a; + } + if (ret) + abort (); + + for (unsigned i = 0; i < N; i++) + { + ret |= vect_true[i].a; + } + if (!ret) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-4.c new file mode 100644 index 0000000000..9f6f022066 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-4.c @@ -0,0 +1,48 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_long_long } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned i : 31; + char x : 2; + char a : 4; +}; + +#define N 32 +#define ELT0 {0x7FFFFFFFUL, 3, 0} +#define ELT1 {0x7FFFFFFFUL, 3, 1} +#define ELT2 {0x7FFFFFFFUL, 3, 2} +#define ELT3 {0x7FFFFFFFUL, 3, 3} +#define RES 48 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + res += ptr[i].a; + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-5.c new file mode 100644 index 0000000000..662aed104c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-5.c @@ -0,0 +1,45 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned a : 23; unsigned b : 9; +}; + +#define N 32 +#define ELT0 {0x7FFFFFUL, 0} +#define ELT1 {0x7FFFFFUL, 1} +#define ELT2 {0x7FFFFFUL, 2} +#define ELT3 {0x7FFFFFUL, 3} +#define RES 48 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + res += ptr[i].b; + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-6.c new file mode 100644 index 0000000000..9b315d6be8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-6.c @@ -0,0 +1,45 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned a : 23; unsigned b : 8; +}; + +#define N 32 +#define ELT0 {0x7FFFFFUL, 0} +#define ELT1 {0x7FFFFFUL, 1} +#define ELT2 {0x7FFFFFUL, 2} +#define ELT3 {0x7FFFFFUL, 3} +#define RES 48 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + res += ptr[i].b; + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-7.c new file mode 100644 index 0000000000..6d1043dd97 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-7.c @@ -0,0 +1,46 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned i : 8; + char a : 4; +}; + +#define N 32 +#define ELT0 {0xFUL, 0} +#define ELT1 {0xFUL, 1} +#define ELT2 {0xFUL, 2} +#define ELT3 {0xFUL, 3} +#define RES 48 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + res += ptr[i].a; + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-8.c new file mode 100644 index 0000000000..52cfd33d93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-8.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-additional-options { "-fdump-tree-ifcvt-all" } } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { int i : 31; }; + +#define ELT0 {0} +#define ELT1 {1} +#define ELT2 {2} +#define ELT3 {3} +#define ELT4 {4} +#define N 32 +#define RES 25 +struct s A[N] + = { ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT4, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + { + if (ptr[i].i == 4) + return res; + res += ptr[i].i; + } + + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Bitfield OK to lower." "ifcvt" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-9.c new file mode 100644 index 0000000000..ab81469813 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-read-9.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_long_long } */ +/* { dg-additional-options { "-fdump-tree-ifcvt-all" } } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned i : 31; + char a : 4; +}; + +#define N 32 +#define ELT0 {0x7FFFFFFFUL, 0} +#define ELT1 {0x7FFFFFFFUL, 1} +#define ELT2 {0x7FFFFFFFUL, 2} +#define ELT3 {0x7FFFFFFFUL, 3} +#define ELT4 {0x7FFFFFFFUL, 4} +#define RES 9 +struct s A[N] + = { ELT0, ELT4, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3, + ELT0, ELT1, ELT2, ELT3, ELT0, ELT1, ELT2, ELT3}; + +int __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + int res = 0; + for (int i = 0; i < n; ++i) + { + if (ptr[i].a) + return 9; + res += ptr[i].a; + } + return res; +} + +int main (void) +{ + check_vect (); + + if (f(&A[0], N) != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Bitfield OK to lower." "ifcvt" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-1.c new file mode 100644 index 0000000000..7c710cf5a5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-1.c @@ -0,0 +1,42 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { int i : 31; }; + +#define N 32 +#define V 5 +struct s A[N]; + +void __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + for (int i = 0; i < n; ++i) + ptr[i].i = V; +} + +void __attribute__ ((noipa)) +check_f(struct s *ptr) { +#pragma GCC novector + for (unsigned i = 0; i < N; ++i) + if (ptr[i].i != V) + abort (); +} + +int main (void) +{ + check_vect (); + __builtin_memset (&A[0], 0, sizeof(struct s) * N); + + f(&A[0], N); + check_f (&A[0]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-2.c new file mode 100644 index 0000000000..3b609183c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-2.c @@ -0,0 +1,46 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_long_long } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned i : 31; + char a : 4; +}; + +#define N 32 +#define V 5 +struct s A[N]; + +void __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + for (int i = 0; i < n; ++i) + ptr[i].a = V; +} + +void __attribute__ ((noipa)) +check_f(struct s *ptr) { +#pragma GCC novector + for (unsigned i = 0; i < N; ++i) + if (ptr[i].a != V) + abort (); +} + +int main (void) +{ + check_vect (); + __builtin_memset (&A[0], 0, sizeof(struct s) * N); + + f(&A[0], N); + check_f (&A[0]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-3.c new file mode 100644 index 0000000000..e96da82c21 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-3.c @@ -0,0 +1,47 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_long_long } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned i : 31; + char x : 2; + char a : 4; +}; + +#define N 32 +#define V 5 +struct s A[N]; + +void __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + for (int i = 0; i < n; ++i) + ptr[i].a = V; +} + +void __attribute__ ((noipa)) +check_f(struct s *ptr) { +#pragma GCC novector + for (unsigned i = 0; i < N; ++i) + if (ptr[i].a != V) + abort (); +} + +int main (void) +{ + check_vect (); + __builtin_memset (&A[0], 0, sizeof(struct s) * N); + + f(&A[0], N); + check_f (&A[0]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-4.c new file mode 100644 index 0000000000..66442213c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-4.c @@ -0,0 +1,45 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned b : 23; + unsigned a : 9; +}; + +#define N 32 +#define V 5 +struct s A[N]; + +void __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + for (int i = 0; i < n; ++i) + ptr[i].a = V; +} + +void __attribute__ ((noipa)) +check_f(struct s *ptr) { +#pragma GCC novector + for (unsigned i = 0; i < N; ++i) + if (ptr[i].a != V) + abort (); +} + +int main (void) +{ + check_vect (); + __builtin_memset (&A[0], 0, sizeof(struct s) * N); + + f(&A[0], N); + check_f (&A[0]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-5.c new file mode 100644 index 0000000000..386de504aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bitfield-write-5.c @@ -0,0 +1,45 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +extern void abort(void); + +struct s { + unsigned b : 23; + unsigned a : 8; +}; + +#define N 32 +#define V 5 +struct s A[N]; + +void __attribute__ ((noipa)) +f(struct s *ptr, unsigned n) { + for (int i = 0; i < n; ++i) + ptr[i].a = V; +} + +void __attribute__ ((noipa)) +check_f(struct s *ptr) { +#pragma GCC novector + for (unsigned i = 0; i < N; ++i) + if (ptr[i].a != V) + abort (); +} + +int main (void) +{ + check_vect (); + __builtin_memset (&A[0], 0, sizeof(struct s) * N); + + f(&A[0], N); + check_f (&A[0]); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bool-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bool-1.c new file mode 100644 index 0000000000..a91f9e2dd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bool-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +_Bool a[1024]; +_Bool b[1024]; +_Bool c[1024]; +void foo (void) +{ + unsigned i; + for (i = 0; i < 1024; ++i) + a[i] = b[i] | c[i]; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bool-cmp-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bool-cmp-2.c new file mode 100644 index 0000000000..1fb57ff945 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bool-cmp-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +void +f (_Bool *restrict x, _Bool *restrict y) +{ + for (int i = 0; i < 128; ++i) + x[i] = x[i] == y[i]; +} + +/* { dg-final { scan-tree-dump "loop vectorized" "vect" { target vect_bool_cmp } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bool-cmp.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bool-cmp.c new file mode 100644 index 0000000000..a1be711670 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bool-cmp.c @@ -0,0 +1,257 @@ +/* PR tree-optimization/71488 */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-additional-options "-msse4" { target sse4_runtime } } */ + +#include "tree-vect.h" + +int i1, i2; + +void __attribute__((noclone,noinline)) +fn1 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) > (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn2 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) > (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn3 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) > (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn4 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) >= (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn5 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) >= (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn6 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) >= (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn7 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) < (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn8 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) < (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn9 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) < (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn10 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) <= (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn11 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) <= (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn12 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) <= (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn13 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) == (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn14 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) == (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn15 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) == (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn16 (int * __restrict__ p1, int * __restrict__ p2, int * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) != (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn17 (int * __restrict__ p1, int * __restrict__ p2, short * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) != (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +void __attribute__((noclone,noinline)) +fn18 (int * __restrict__ p1, int * __restrict__ p2, long long * __restrict__ p3, int size) +{ + int i; + + for (i = 0; i < size; i++) + p1[i] = ((p2[i] == 0) != (unsigned)(p3[i] == 0)) + (p2[i] == 0); +} + +int eq (int i1, int i2) { return i1 == i2; } +int ne (int i1, int i2) { return i1 != i2; } +int lt (int i1, int i2) { return i1 < i2; } +int le (int i1, int i2) { return i1 <= i2; } +int gt (int i1, int i2) { return i1 > i2; } +int ge (int i1, int i2) { return i1 >= i2; } + +typedef int (*cmp_fn)(int, int); + +void +check (int *p, cmp_fn fn) +{ + int i; + +#pragma GCC novector + for (i = 0; i < 32; i++) + { + int t1 = ((i % 4) > 1) == 0; + int t2 = (i % 2) == 0; + int res = fn (t1, t2) + t1; + if (p[i] != res) + __builtin_abort (); + } +} + +int +main (int argc, char **argv) +{ + int i1[32], i2[32], res[32]; + short s2[32]; + long long l2[32]; + int i; + + check_vect (); + + for (i = 0; i < 32; i++) + { + l2[i] = i2[i] = s2[i] = i % 2; + i1[i] = (i % 4) > 1; + asm ("":::"memory"); + } + + fn1 (res, i1, i2, 32); + check (res, gt); + fn2 (res, i1, s2, 32); + check (res, gt); + fn3 (res, i1, l2, 32); + check (res, gt); + + fn4 (res, i1, i2, 32); + check (res, ge); + fn5 (res, i1, s2, 32); + check (res, ge); + fn6 (res, i1, l2, 32); + check (res, ge); + + fn7 (res, i1, i2, 32); + check (res, lt); + fn8 (res, i1, s2, 32); + check (res, lt); + fn9 (res, i1, l2, 32); + check (res, lt); + + fn10 (res, i1, i2, 32); + check (res, le); + fn11 (res, i1, s2, 32); + check (res, le); + fn12 (res, i1, l2, 32); + check (res, le); + + fn13 (res, i1, i2, 32); + check (res, eq); + fn14 (res, i1, s2, 32); + check (res, eq); + fn15 (res, i1, l2, 32); + check (res, eq); + + fn16 (res, i1, i2, 32); + check (res, ne); + fn17 (res, i1, s2, 32); + check (res, ne); + fn18 (res, i1, l2, 32); + check (res, ne); +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 18 "vect" { target sse4_runtime } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bswap16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bswap16.c new file mode 100644 index 0000000000..7d2cb29773 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bswap16.c @@ -0,0 +1,43 @@ +/* { dg-additional-options "-msse4" { target sse4_runtime } } */ + +#include "tree-vect.h" + +#define N 128 + +static inline void +vfoo16 (unsigned short int* a) +{ + int i = 0; + for (i = 0; i < N; ++i) + a[i] = __builtin_bswap16 (a[i]); +} + +int +main (void) +{ + unsigned short arr[N]; + unsigned short expect[N]; + int i; + + check_vect (); + + for (i = 0; i < N; ++i) + { + arr[i] = i; + expect[i] = __builtin_bswap16 (i); + asm volatile ("" ::: "memory"); + } + + vfoo16 (arr); + +#pragma GCC novector + for (i = 0; i < N; ++i) + { + if (arr[i] != expect[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_bswap || sse4_runtime } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bswap16a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bswap16a.c new file mode 100644 index 0000000000..730dc4e835 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bswap16a.c @@ -0,0 +1,5 @@ +/* { dg-additional-options "-msse2 -mno-sse3" { target sse2_runtime } } */ + +#include "vect-bswap16.c" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_shift } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bswap32.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bswap32.c new file mode 100644 index 0000000000..1139754bbf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bswap32.c @@ -0,0 +1,43 @@ +/* { dg-additional-options "-msse4" { target sse4_runtime } } */ + +#include "tree-vect.h" + +#define N 128 + +static inline void +vfoo32 (unsigned int* a) +{ + int i = 0; + for (i = 0; i < N; ++i) + a[i] = __builtin_bswap32 (a[i]); +} + +int +main (void) +{ + unsigned int arr[N]; + unsigned int expect[N]; + int i; + + check_vect (); + + for (i = 0; i < N; ++i) + { + arr[i] = i; + expect[i] = __builtin_bswap32 (i); + asm volatile ("" ::: "memory"); + } + + vfoo32 (arr); + +#pragma GCC novector + for (i = 0; i < N; ++i) + { + if (arr[i] != expect[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_bswap || sse4_runtime } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-bswap64.c b/SingleSource/Regression/C/gcc-dg/vect/vect-bswap64.c new file mode 100644 index 0000000000..38d598eba3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-bswap64.c @@ -0,0 +1,43 @@ +/* { dg-additional-options "-msse4" { target sse4_runtime } } */ + +#include "tree-vect.h" + +#define N 128 + +static inline void +vfoo64 (unsigned long long* a) +{ + int i = 0; + for (i = 0; i < N; ++i) + a[i] = __builtin_bswap64 (a[i]); +} + +int +main (void) +{ + unsigned long long arr[N]; + unsigned long long expect[N]; + int i; + + check_vect (); + + for (i = 0; i < N; ++i) + { + arr[i] = i; + expect[i] = __builtin_bswap64 (i); + asm volatile ("" ::: "memory"); + } + + vfoo64 (arr); + +#pragma GCC novector + for (i = 0; i < N; ++i) + { + if (arr[i] != expect[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_bswap || sse4_runtime } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-complex-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-complex-1.c new file mode 100644 index 0000000000..b3a02fe9c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-complex-1.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +_Complex float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + { 10.0F + 20.0iF, 11.0F + 21.0iF, 12.0F + 22.0iF, 13.0F + 23.0iF, + 14.0F + 24.0iF, 15.0F + 25.0iF, 16.0F + 26.0iF, 17.0F + 27.0iF, + 18.0F + 28.0iF, 19.0F + 29.0iF, 20.0F + 30.0iF, 21.0F + 31.0iF, + 22.0F + 32.0iF, 23.0F + 33.0iF, 24.0F + 34.0iF, 25.0F + 35.0iF }; +_Complex float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + { 30.0F + 40.0iF, 31.0F + 41.0iF, 32.0F + 42.0iF, 33.0F + 43.0iF, + 34.0F + 44.0iF, 35.0F + 45.0iF, 36.0F + 46.0iF, 37.0F + 47.0iF, + 38.0F + 48.0iF, 39.0F + 49.0iF, 40.0F + 50.0iF, 41.0F + 51.0iF, + 42.0F + 52.0iF, 43.0F + 53.0iF, 44.0F + 54.0iF, 45.0F + 55.0iF }; + +_Complex float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +_Complex float res[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + { 40.0F + 60.0iF, 42.0F + 62.0iF, 44.0F + 64.0iF, 46.0F + 66.0iF, + 48.0F + 68.0iF, 50.0F + 70.0iF, 52.0F + 72.0iF, 54.0F + 74.0iF, + 56.0F + 76.0iF, 58.0F + 78.0iF, 60.0F + 80.0iF, 62.0F + 82.0iF, + 64.0F + 84.0iF, 66.0F + 86.0iF, 68.0F + 88.0iF, 70.0F + 90.0iF }; + + +__attribute__ ((noinline)) void +foo (void) +{ + int i; + + for (i = 0; i < N; i++) + c[i] = a[i] + b[i]; + +} + +int +main (void) +{ + int i; + check_vect (); + + foo (); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (c[i] != res[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-complex-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-complex-2.c new file mode 100644 index 0000000000..7bbfdd95b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-complex-2.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_double } */ + +#include +#include "tree-vect.h" + +#define N 16 + +_Complex double a[N] = + { 10.0F + 20.0iF, 11.0F + 21.0iF, 12.0F + 22.0iF, 13.0F + 23.0iF, + 14.0F + 24.0iF, 15.0F + 25.0iF, 16.0F + 26.0iF, 17.0F + 27.0iF, + 18.0F + 28.0iF, 19.0F + 29.0iF, 20.0F + 30.0iF, 21.0F + 31.0iF, + 22.0F + 32.0iF, 23.0F + 33.0iF, 24.0F + 34.0iF, 25.0F + 35.0iF }; +_Complex double b[N] = + { 30.0F + 40.0iF, 31.0F + 41.0iF, 32.0F + 42.0iF, 33.0F + 43.0iF, + 34.0F + 44.0iF, 35.0F + 45.0iF, 36.0F + 46.0iF, 37.0F + 47.0iF, + 38.0F + 48.0iF, 39.0F + 49.0iF, 40.0F + 50.0iF, 41.0F + 51.0iF, + 42.0F + 52.0iF, 43.0F + 53.0iF, 44.0F + 54.0iF, 45.0F + 55.0iF }; + +_Complex double c[N]; +_Complex double res[N] = + { 40.0F + 60.0iF, 42.0F + 62.0iF, 44.0F + 64.0iF, 46.0F + 66.0iF, + 48.0F + 68.0iF, 50.0F + 70.0iF, 52.0F + 72.0iF, 54.0F + 74.0iF, + 56.0F + 76.0iF, 58.0F + 78.0iF, 60.0F + 80.0iF, 62.0F + 82.0iF, + 64.0F + 84.0iF, 66.0F + 86.0iF, 68.0F + 88.0iF, 70.0F + 90.0iF }; + + +__attribute__ ((noinline)) void +foo (void) +{ + int i; + + for (i = 0; i < N; i++) + c[i] = a[i] + b[i]; + +} + +int +main (void) +{ + int i; + check_vect (); + + foo (); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (c[i] != res[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-complex-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-complex-4.c new file mode 100644 index 0000000000..d5e50cc15d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-complex-4.c @@ -0,0 +1,108 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +struct foostr { + _Complex short f1; + _Complex short f2; +}; + +struct foostr a[16] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + { + 11 + 23i, 24 + 22i, + 11 + 26i, 24 + 35i, + 19 + 20i, 29 + 14i, + 23 + 31i, 26 + 30i, + 29 + 39i, 24 + 18i, + 20 + 32i, 16 + 23i, + 13 + 26i, 37 + 34i, + 12 + 23i, 26 + 14i, + 36 + 14i, 31 + 17i, + 35 + 17i, 17 + 36i, + 13 + 34i, 19 + 12i, + 27 + 34i, 36 + 19i, + 21 + 39i, 16 + 33i, + 28 + 18i, 39 + 26i, + 32 + 27i, 13 + 38i, + 35 + 36i, 34 + 28i, + }; + +struct foostr b[16] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + { + 37 + 12i, 23 + 15i, + 14 + 11i, 13 + 25i, + 35 + 29i, 22 + 34i, + 24 + 34i, 16 + 39i, + 34 + 32i, 26 + 21i, + 34 + 36i, 11 + 37i, + 25 + 21i, 10 + 39i, + 10 + 36i, 35 + 22i, + 39 + 29i, 23 + 21i, + 34 + 33i, 39 + 14i, + 16 + 31i, 32 + 33i, + 20 + 14i, 35 + 30i, + 26 + 24i, 36 + 37i, + 31 + 20i, 32 + 28i, + 25 + 27i, 15 + 30i, + 10 + 31i, 37 + 37i, + }; +struct foostr c[16] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +struct foostr res[N] = + { + 48 + 35i, 47 + 37i, + 25 + 37i, 37 + 60i, + 54 + 49i, 51 + 48i, + 47 + 65i, 42 + 69i, + 63 + 71i, 50 + 39i, + 54 + 68i, 27 + 60i, + 38 + 47i, 47 + 73i, + 22 + 59i, 61 + 36i, + 75 + 43i, 54 + 38i, + 69 + 50i, 56 + 50i, + 29 + 65i, 51 + 45i, + 47 + 48i, 71 + 49i, + 47 + 63i, 52 + 70i, + 59 + 38i, 71 + 54i, + 57 + 54i, 28 + 68i, + 45 + 67i, 71 + 65i, + }; + +__attribute__ ((noinline)) void +foo (void) +{ + int i; + + for (i = 0; i < N; i++) + { + c[i].f1 = a[i].f1 + b[i].f1; + c[i].f2 = a[i].f2 + b[i].f2; + } + +} + +int +main (void) +{ + int i; + check_vect (); + + foo (); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (c[i].f1 != res[i].f1) + abort (); + if (c[i].f2 != res[i].f2) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-complex-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-complex-5.c new file mode 100644 index 0000000000..addcf60438 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-complex-5.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +struct foostr { + _Complex short f1; + _Complex short f2; +}; + +_Complex short a1[64] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +_Complex short a2[64] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +_Complex short b1[64] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +_Complex short b2[64] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +struct foostr c[64] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo (void) +{ + int i; + + for (i = 0; i < N; i++) + { + c[i].f1 = a1[i] + b1[i]; + c[i].f2 = a2[i] + b2[i]; + } + +} + +int +main (void) +{ + int i; + check_vect (); + + foo (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target vect_load_lanes } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target { ! vect_load_lanes } xfail { ! vect_hw_misalign } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-1.c new file mode 100644 index 0000000000..e438cbb67e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-1.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +#define M 32 +#define N 16 + +int x_in[M]; +int x_out[M]; +int c[N] = {3,2,1,10,1,42,3,4,50,9,32,8,11,10,1,2}; +int a[N+1] = {0,16,32,48,64,128,256,512,0,16,32,48,64,128,256,512,1024}; +int check_result[M] = {1024,1024,1024,256,256,256,256,256,256,256,256,128,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48}; + +__attribute__ ((noinline)) void +foo () +{ + int j, i, x; + int curr_a, next_a; + + for (j = 0; j < M; j++) + { + x = x_in[j]; + curr_a = a[0]; + + for (i = 0; i < N; i++) + { + next_a = a[i+1]; + curr_a = x > c[i] ? curr_a : next_a; + } + + x_out[j] = curr_a; + } +} + +int main (void) +{ + int i,j; + + check_vect (); + + for (j = 0; j < M; j++) + x_in[j] = j; + + foo (); + +#pragma GCC novector + for (j = 0; j < M; j++) + if (x_out[j] != check_result[j]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-10.c new file mode 100644 index 0000000000..dbbe4877db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-10.c @@ -0,0 +1,174 @@ +/* { dg-require-effective-target vect_cond_mixed } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fno-ipa-icf" } */ + +#include "tree-vect.h" + +#define N 1024 +float a[N], b[N], c[N], d[N]; +_Bool k[N]; + +__attribute__((noinline, noclone)) void +f1 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + int x = a[i] < b[i]; + int y = c[i] < d[i]; + k[i] = x & y; + } +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + int i; + for (i = 0; i < N; ++i) + k[i] = (a[i] < b[i]) & (c[i] < d[i]); +} + +__attribute__((noinline, noclone)) void +f3 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + int x = a[i] < b[i]; + int y = c[i] < d[i]; + k[i] = x | y; + } +} + +__attribute__((noinline, noclone)) void +f4 (void) +{ + int i; + for (i = 0; i < N; ++i) + k[i] = (a[i] < b[i]) | (c[i] < d[i]); +} + +__attribute__((noinline, noclone)) void +f5 (_Bool *p) +{ + int i; + for (i = 0; i < N; ++i) + { + int x = a[i] < b[i]; + int y = c[i] < d[i]; + p[i] = x & y; + } +} + +__attribute__((noinline, noclone)) void +f6 (_Bool *p) +{ + int i; + for (i = 0; i < N; ++i) + p[i] = (a[i] < b[i]) & (c[i] < d[i]); +} + +__attribute__((noinline, noclone)) void +f7 (_Bool *p) +{ + int i; + for (i = 0; i < N; ++i) + { + int x = a[i] < b[i]; + int y = c[i] < d[i]; + p[i] = x | y; + } +} + +__attribute__((noinline, noclone)) void +f8 (_Bool *p) +{ + int i; + for (i = 0; i < N; ++i) + p[i] = (a[i] < b[i]) | (c[i] < d[i]); +} + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break; + case 1: a[i] = 0; b[i] = 0; break; + case 2: a[i] = i + 1; b[i] = - i - 1; break; + case 3: a[i] = i; b[i] = i + 7; break; + case 4: a[i] = i; b[i] = i; break; + case 5: a[i] = i + 16; b[i] = i + 3; break; + case 6: a[i] = - i - 5; b[i] = - i; break; + case 7: a[i] = - i; b[i] = - i; break; + case 8: a[i] = - i; b[i] = - i - 7; break; + } + } + for (i = 0; i < N; i++) + { + switch ((i / 9) % 3) + { + case 0: c[i] = a[i / 9]; d[i] = b[i / 9]; break; + case 1: c[i] = a[i / 9 + 3]; d[i] = b[i / 9 + 3]; break; + case 2: c[i] = a[i / 9 + 6]; d[i] = b[i / 9 + 6]; break; + } + } + f1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, 0, sizeof (k)); + f2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, 0, sizeof (k)); + f3 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, 0, sizeof (k)); + f4 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, 0, sizeof (k)); + f5 (k); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, 0, sizeof (k)); + f6 (k); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, 0, sizeof (k)); + f7 (k); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, 0, sizeof (k)); + f8 (k); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, 0, sizeof (k)); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 8 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-11.c new file mode 100644 index 0000000000..b1347bddbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-11.c @@ -0,0 +1,120 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +#include "tree-vect.h" + +#define N 1024 +typedef int V __attribute__((vector_size (4))); +unsigned int a[N * 2] __attribute__((aligned)); +unsigned int b[N * 2] __attribute__((aligned)); +V c[N]; + +__attribute__((noinline, noclone)) unsigned int +foo (unsigned int *a, unsigned int *b) +{ + int i; + unsigned int r = 0; + for (i = 0; i < N; i++) + { + unsigned int x = a[i], y = b[i]; + if (x < 32) + { + x = x + 127; + y = y * 2; + } + else + { + x = x - 16; + y = y + 1; + } + a[i] = x; + b[i] = y; + r += x; + } + return r; +} + +__attribute__((noinline, noclone)) unsigned int +bar (unsigned int *a, unsigned int *b) +{ + int i; + unsigned int r = 0; + for (i = 0; i < N; i++) + { + unsigned int x = a[i], y = b[i]; + if (x < 32) + { + x = x + 127; + y = y * 2; + } + else + { + x = x - 16; + y = y + 1; + } + a[i] = x; + b[i] = y; + c[i] = c[i] + 1; + r += x; + } + return r; +} + +void +baz (unsigned int *a, unsigned int *b, + unsigned int (*fn) (unsigned int *, unsigned int *)) +{ + int i; + for (i = -64; i < 0; i++) + { + a[i] = 19; + b[i] = 17; + } + for (; i < N; i++) + { + a[i] = i - 512; + b[i] = i; + } + for (; i < N + 64; i++) + { + a[i] = 27; + b[i] = 19; + } + if (fn (a, b) != -512U - (N - 32) * 16U + 32 * 127U) + __builtin_abort (); +#pragma GCC novector + for (i = -64; i < 0; i++) + if (a[i] != 19 || b[i] != 17) + __builtin_abort (); +#pragma GCC novector + for (; i < N; i++) + if (a[i] != (i - 512U < 32U ? i - 512U + 127 : i - 512U - 16) + || b[i] != (i - 512U < 32U ? i * 2U : i + 1U)) + __builtin_abort (); +#pragma GCC novector + for (; i < N + 64; i++) + if (a[i] != 27 || b[i] != 19) + __builtin_abort (); +} + +int +main () +{ + int i; + check_vect (); + baz (a + 512, b + 512, foo); + baz (a + 512, b + 512, bar); + baz (a + 512 + 1, b + 512 + 1, foo); + baz (a + 512 + 1, b + 512 + 1, bar); + baz (a + 512 + 31, b + 512 + 31, foo); + baz (a + 512 + 31, b + 512 + 31, bar); + baz (a + 512 + 1, b + 512, foo); + baz (a + 512 + 1, b + 512, bar); + baz (a + 512 + 31, b + 512, foo); + baz (a + 512 + 31, b + 512, bar); + baz (a + 512, b + 512 + 1, foo); + baz (a + 512, b + 512 + 1, bar); + baz (a + 512, b + 512 + 31, foo); + baz (a + 512, b + 512 + 31, bar); + return 0; +} + +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-12.c new file mode 100644 index 0000000000..1add96afe4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-12.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +int +f (int *x, short *y) +{ + int res = 100; + for (int i = 0; i < 40; ++i) + { + if (y[i] > 1) + res = x[i]; + x[i] += y[i]; + } + return res; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-13.c new file mode 100644 index 0000000000..addb2b7a28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-13.c @@ -0,0 +1,36 @@ +#include "tree-vect.h" + +int a[1024]; +int b[1024]; + +int +foo () +{ + int tem; + for (int i = 0; i < 1024; ++i) + { + if (a[i] < 0) + tem = -a[i] - 1; + else + tem = a[i]; + b[i] = tem + 10; + } + return tem; +} + +int main() +{ + check_vect (); + + for (int i = 0; i < 1024; ++i) + { + a[i] = i - 333; + __asm__ volatile ("" ::: "memory"); + } + int res = foo (); + if (res != 1023 - 333) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_condition } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-2.c new file mode 100644 index 0000000000..094cfe7670 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-2.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +#define N 16 + +int c[N] = {3,2,1,10,1,42,3,4,50,9,32,8,11,10,1,2}; +int a[N+1] = {0,16,32,48,64,128,256,512,0,16,32,48,64,128,256,512,1024}; + +__attribute__ ((noinline)) void +foo (int *x) +{ + int i; + int curr_a, flag, next_a; + + curr_a = a[0]; + + for (i = 0; i < N; i++) + { + flag = *x > c[i]; + next_a = a[i+1]; + curr_a = flag ? curr_a : next_a; + } + + *x = curr_a; +} + +int main (void) +{ + int x = 7; + + check_vect (); + + foo (&x); + + if (x != 256) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-3.c new file mode 100644 index 0000000000..1521fedd1b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-3.c @@ -0,0 +1,64 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +#define M 32 +#define N 16 + +int x_in[M]; +int x_out_a[M], x_out_b[M]; +int c[N] = {3,2,1,10,1,42,3,4,50,9,32,8,11,10,1,2}; +int a[N+1] = {0,16,32,48,64,128,256,512,0,16,32,48,64,128,256,512,1024}; +int b[N+1] = {17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; +int check_result_a[M] = {1024,1024,1024,256,256,256,256,256,256,256,256,128,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48}; +int check_result_b[M] = {17,17,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; + +__attribute__ ((noinline)) void +foo () +{ + int j, i, x; + int curr_a, flag, next_a, curr_b, next_b; + + for (j = 0; j < M; j++) + { + x = x_in[j]; + curr_a = a[0]; + curr_b = b[0]; + + for (i = 0; i < N; i++) + { + flag = x > c[i]; + next_a = a[i+1]; + next_b = b[i+1]; + curr_a = flag ? curr_a : next_a; + curr_b = flag ? next_b : curr_b; + } + + x_out_a[j] = curr_a; + x_out_b[j] = curr_b; + } +} + +int main (void) +{ + int i,j; + + check_vect (); + + for (j = 0; j < M; j++) + x_in[j] = j; + + foo (); + +#pragma GCC novector + for (j = 0; j < M; j++) + if (x_out_a[j] != check_result_a[j] + || x_out_b[j] != check_result_b[j]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-4.c new file mode 100644 index 0000000000..4057d14c70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-4.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +#define M 32 +#define N 16 + +int x_in[M]; +int x_out_a[M], x_out_b[M]; +int c[N] = {3,2,1,10,1,42,3,4,50,9,32,8,11,10,1,2}; +int a[N+1] = {0,16,32,48,64,128,256,512,0,16,32,48,64,128,256,512,1024}; +int b[N+1] = {17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; +int check_result_a[M] = {1024,1024,1024,256,256,256,256,256,256,256,256,128,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48}; +int check_result_b[M] = {17,17,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; + +__attribute__ ((noinline)) void +foo (int z) +{ + int j, i, x; + int curr_a, curr_b; + + for (j = 0; j < M; j++) + { + x = x_in[j]; + curr_a = a[0]; + curr_b = b[0]; + + for (i = 0; i < N; i++) + { + curr_a = x > c[i] ? curr_a : z; + curr_b = x > c[i] ? curr_b : 5; + } + + x_out_a[j] = curr_a; + x_out_b[j] = curr_b; + } +} + +int main (void) +{ + int i,j; + + check_vect (); + + for (j = 0; j < M; j++) + x_in[j] = j; + + foo (125); + +#pragma GCC novector + for (j = 0; j < M; j++) + if (x_out_a[j] != 125 + || x_out_b[j] != 5) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-5.c new file mode 100644 index 0000000000..f10feab71d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-5.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_condition } */ + +#include +#include "tree-vect.h" + +#define K 32 + +int cond_array[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int a[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; +int check_result[K] = {2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +__attribute__ ((noinline)) void +foo (int c) +{ + int res, i, j, k, next; + + for (k = 0; k < K; k++) + { + res = 0; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + { + next = a[i][j]; + res = c > cond_array[i+k][j] ? next : res; + } + + out[k] = res; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + cond_array[i][j] = i+j; + + for (i = 0; i < K; i++) + a[i][j] = i+2; + } + + foo(5); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} + +/* Double reduction with cond_expr is not supported, since even though the order + of computation is the same, but vector results should be reduced to scalar + result, which can'be done for cond_expr. */ +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-6.c new file mode 100644 index 0000000000..a46479a07e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-6.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_condition } */ + +#include +#include "tree-vect.h" + +#define K 32 + +int cond_array[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int a[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; + +__attribute__ ((noinline)) void +foo (int c) +{ + int res, i, j, k, next; + + for (k = 0; k < K; k++) + { + for (j = 0; j < K; j++) + { + res = 0; + for (i = 0; i < K; i++) + { + next = a[i][j]; + res = c > cond_array[i+k][j] ? next : res; + } + + out[j] = res; + } + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + cond_array[i][j] = i+j; + + for (i = 0; i < K; i++) + a[i][j] = i+2; + } + + foo(125); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != 33) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-7.c new file mode 100644 index 0000000000..ea11693ff2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-7.c @@ -0,0 +1,68 @@ +#include "tree-vect.h" + +extern void abort (void); +double ad[64], bd[64], cd[64], dd[64], ed[64]; +float af[64], bf[64], cf[64], df[64], ef[64]; +signed char ac[64], bc[64], cc[64], dc[64], ec[64]; +short as[64], bs[64], cs[64], ds[64], es[64]; +int ai[64], bi[64], ci[64], di[64], ei[64]; +long long all[64], bll[64], cll[64], dll[64], ell[64]; +unsigned char auc[64], buc[64], cuc[64], duc[64], euc[64]; +unsigned short aus[64], bus[64], cus[64], dus[64], eus[64]; +unsigned int au[64], bu[64], cu[64], du[64], eu[64]; +unsigned long long aull[64], bull[64], cull[64], dull[64], eull[64]; + +#define F(var) \ +__attribute__((noinline, noclone)) void \ +f##var (void) \ +{ \ + int i; \ + for (i = 0; i < 64; i++) \ + { \ + __typeof (a##var[0]) d = d##var[i], e = e##var[i]; \ + a##var[i] = b##var[i] > c##var[i] ? d : e; \ + } \ +} + +#define TESTS \ +F (d) F (f) F (c) F (s) F (i) F (ll) F (uc) F (us) F (u) F (ull) + +TESTS + +int +main () +{ + int i; + + check_vect (); + for (i = 0; i < 64; i++) + { +#undef F +#define F(var) \ + b##var[i] = i + 64; \ + switch (i % 3) \ + { \ + case 0: c##var[i] = i + 64; break; \ + case 1: c##var[i] = 127 - i; break; \ + case 2: c##var[i] = i; break; \ + } \ + d##var[i] = i / 2; \ + e##var[i] = i * 2; + TESTS + } +#undef F +#define F(var) f##var (); + TESTS +#pragma GCC novector + for (i = 0; i < 64; i++) + { + asm volatile ("" : : : "memory"); +#undef F +#define F(var) \ + if (a##var[i] != (b##var[i] > c##var[i] ? d##var[i] : e##var[i])) \ + abort (); + TESTS + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-8.c new file mode 100644 index 0000000000..88289018b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-8.c @@ -0,0 +1,127 @@ +/* { dg-require-effective-target vect_cond_mixed } */ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +#define N 1024 +float a[N], b[N], c[N]; +int d[N], e[N], f[N]; +unsigned char k[N]; + +__attribute__((noinline, noclone)) void +f1 (void) +{ + int i; + for (i = 0; i < N; ++i) + k[i] = a[i] < b[i] ? 17 : 0; +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + int i; + for (i = 0; i < N; ++i) + k[i] = a[i] < b[i] ? 0 : 24; +} + +__attribute__((noinline, noclone)) void +f3 (void) +{ + int i; + for (i = 0; i < N; ++i) + k[i] = a[i] < b[i] ? 51 : 12; +} + +__attribute__((noinline, noclone)) void +f4 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + int d2 = d[i], e2 = e[i]; + f[i] = a[i] < b[i] ? d2 : e2; + } +} + +__attribute__((noinline, noclone)) void +f5 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + float a2 = a[i], b2 = b[i]; + c[i] = d[i] < e[i] ? a2 : b2; + } +} + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break; + case 1: a[i] = 0; b[i] = 0; break; + case 2: a[i] = i + 1; b[i] = - i - 1; break; + case 3: a[i] = i; b[i] = i + 7; break; + case 4: a[i] = i; b[i] = i; break; + case 5: a[i] = i + 16; b[i] = i + 3; break; + case 6: a[i] = - i - 5; b[i] = - i; break; + case 7: a[i] = - i; b[i] = - i; break; + case 8: a[i] = - i; b[i] = - i - 7; break; + } + d[i] = i; + e[i] = 2 * i; + } + f1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 ? 17 : 0)) + abort (); + f2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 ? 0 : 24)) + abort (); + f3 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 ? 51 : 12)) + abort (); + f4 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (f[i] != ((i % 3) == 0 ? d[i] : e[i])) + abort (); + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: asm (""); d[i] = - i - 1; e[i] = i + 1; break; + case 1: d[i] = 0; e[i] = 0; break; + case 2: d[i] = i + 1; e[i] = - i - 1; break; + case 3: d[i] = i; e[i] = i + 7; break; + case 4: d[i] = i; e[i] = i; break; + case 5: d[i] = i + 16; e[i] = i + 3; break; + case 6: d[i] = - i - 5; e[i] = - i; break; + case 7: d[i] = - i; e[i] = - i; break; + case 8: d[i] = - i; e[i] = - i - 7; break; + } + a[i] = i; + b[i] = i / 2; + } + f5 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (c[i] != ((i % 3) == 0 ? a[i] : b[i])) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 5 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-9.c new file mode 100644 index 0000000000..87febca10e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-9.c @@ -0,0 +1,211 @@ +/* { dg-require-effective-target vect_cond_mixed } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fno-ipa-icf" } */ + +#include "tree-vect.h" + +#define N 1024 +float a[N], b[N], c[N], d[N]; +int j[N]; +unsigned char k[N]; + +__attribute__((noinline, noclone)) void +f1 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + unsigned int x = a[i] < b[i] ? -1 : 0; + unsigned int y = c[i] < d[i] ? -1 : 0; + j[i] = (x & y) >> 31; + } +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + int x = a[i] < b[i]; + int y = c[i] < d[i]; + j[i] = x & y; + } +} + +__attribute__((noinline, noclone)) void +f3 (void) +{ + int i; + for (i = 0; i < N; ++i) + j[i] = (a[i] < b[i]) & (c[i] < d[i]); +} + +__attribute__((noinline, noclone)) void +f4 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + int x = a[i] < b[i]; + int y = c[i] < d[i]; + k[i] = x & y; + } +} + +__attribute__((noinline, noclone)) void +f5 (void) +{ + int i; + for (i = 0; i < N; ++i) + k[i] = (a[i] < b[i]) & (c[i] < d[i]); +} + +__attribute__((noinline, noclone)) void +f6 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + unsigned int x = a[i] < b[i] ? -1 : 0; + unsigned int y = c[i] < d[i] ? -1 : 0; + j[i] = (x | y) >> 31; + } +} + +__attribute__((noinline, noclone)) void +f7 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + int x = a[i] < b[i]; + int y = c[i] < d[i]; + j[i] = x | y; + } +} + +__attribute__((noinline, noclone)) void +f8 (void) +{ + int i; + for (i = 0; i < N; ++i) + j[i] = (a[i] < b[i]) | (c[i] < d[i]); +} + +__attribute__((noinline, noclone)) void +f9 (void) +{ + int i; + for (i = 0; i < N; ++i) + { + int x = a[i] < b[i]; + int y = c[i] < d[i]; + k[i] = x | y; + } +} + +__attribute__((noinline, noclone)) void +f10 (void) +{ + int i; + for (i = 0; i < N; ++i) + k[i] = (a[i] < b[i]) | (c[i] < d[i]); +} + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + switch (i % 9) + { + case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break; + case 1: a[i] = 0; b[i] = 0; break; + case 2: a[i] = i + 1; b[i] = - i - 1; break; + case 3: a[i] = i; b[i] = i + 7; break; + case 4: a[i] = i; b[i] = i; break; + case 5: a[i] = i + 16; b[i] = i + 3; break; + case 6: a[i] = - i - 5; b[i] = - i; break; + case 7: a[i] = - i; b[i] = - i; break; + case 8: a[i] = - i; b[i] = - i - 7; break; + } + } + for (i = 0; i < N; i++) + { + switch ((i / 9) % 3) + { + case 0: c[i] = a[i / 9]; d[i] = b[i / 9]; break; + case 1: c[i] = a[i / 9 + 3]; d[i] = b[i / 9 + 3]; break; + case 2: c[i] = a[i / 9 + 6]; d[i] = b[i / 9 + 6]; break; + } + } + f1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (j, -6, sizeof (j)); + f2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (j, -6, sizeof (j)); + f3 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (j, -6, sizeof (j)); + f4 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, -6, sizeof (k)); + f5 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, -6, sizeof (k)); + f6 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (j, -6, sizeof (j)); + f7 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (j, -6, sizeof (j)); + f8 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (j, -6, sizeof (j)); + f9 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, -6, sizeof (k)); + f10 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0)) + abort (); + __builtin_memset (k, -6, sizeof (k)); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 10 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-1.c new file mode 100644 index 0000000000..5138712731 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-1.c @@ -0,0 +1,65 @@ +/* { dg-additional-options "-fdump-tree-optimized -fno-trapping-math -ffinite-math-only" } */ + +#include "tree-vect.h" + +#define N (VECTOR_BITS * 11 / 64 + 3) + +#define add(A, B) ((A) + (B)) +#define sub(A, B) ((A) - (B)) +#define mul(A, B) ((A) * (B)) +#define div(A, B) ((A) / (B)) + +#define DEF(OP) \ + void __attribute__ ((noipa)) \ + f_##OP (double *restrict a, double *restrict b, double x) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + double truev = OP (b[i], x); \ + a[i] = b[i] < 100 ? truev : b[i]; \ + } \ + } + +#define TEST(OP) \ + { \ + f_##OP (a, b, 10); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + { \ + int bval = (i % 17) * 10; \ + int truev = OP (bval, 10); \ + if (a[i] != (bval < 100 ? truev : bval)) \ + __builtin_abort (); \ + asm volatile ("" ::: "memory"); \ + } \ + } + +#define FOR_EACH_OP(T) \ + T (add) \ + T (sub) \ + T (mul) \ + T (div) \ + T (__builtin_fmax) \ + T (__builtin_fmin) + +FOR_EACH_OP (DEF) + +int +main (void) +{ + double a[N], b[N]; + for (int i = 0; i < N; ++i) + { + b[i] = (i % 17) * 10; + asm volatile ("" ::: "memory"); + } + FOR_EACH_OP (TEST) + return 0; +} + +/* { dg-final { scan-tree-dump { = \.COND_ADD} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_SUB} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_MUL} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_RDIV} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_MAX} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_MIN} "optimized" { target vect_double_cond_arith } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-2.c new file mode 100644 index 0000000000..7b3d73acb8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-2.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fgimple -fdump-tree-optimized -ffast-math" } */ +/* { dg-additional-options "-fno-vect-cost-model" { target { riscv_v } } } */ + +double __GIMPLE (ssa, startwith("loop")) +neg_xi (double *x) +{ + int i; + long unsigned int index; + long unsigned int offset; + double * xi_ptr; + double xi; + double neg_xi; + double res; + unsigned int ivtmp; + + __BB(5): + goto __BB2; + + __BB(2): + res_1 = __PHI (__BB5: 0.0, __BB3: res_2); + i_4 = __PHI (__BB5: 0, __BB3: i_5); + ivtmp_6 = __PHI (__BB5: 100U, __BB3: ivtmp_7); + index = (long unsigned int) i_4; + offset = index * 8UL; + xi_ptr = x_8(D) + offset; + xi = *xi_ptr; + neg_xi = -xi; + res_2 = neg_xi + res_1; + i_5 = i_4 + 1; + ivtmp_7 = ivtmp_6 - 1U; + if (ivtmp_7 != 0U) + goto __BB3; + else + goto __BB4; + + __BB(3): + goto __BB2; + + __BB(4): + res_3 = __PHI (__BB2: res_2); + return res_3; +} + +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?ADD} "vect" { target { vect_double_cond_arith && vect_fully_masked } } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?SUB} "optimized" { target { vect_double_cond_arith && vect_fully_masked } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-3.c new file mode 100644 index 0000000000..11a680061c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-3.c @@ -0,0 +1,64 @@ +/* { dg-require-effective-target scalar_all_fma } */ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N (VECTOR_BITS * 11 / 64 + 3) + +#define DEF(INV) \ + void __attribute__ ((noipa)) \ + f_##INV (double *restrict a, double *restrict b, \ + double *restrict c, double *restrict d) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + double mb = (INV & 1 ? -b[i] : b[i]); \ + double mc = c[i]; \ + double md = (INV & 2 ? -d[i] : d[i]); \ + double fma = __builtin_fma (mb, mc, md); \ + double truev = (INV & 4 ? -fma : fma); \ + a[i] = b[i] < 10 ? truev : 10.0; \ + } \ + } + +#define TEST(INV) \ + { \ + f_##INV (a, b, c, d); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + { \ + double mb = (INV & 1 ? -b[i] : b[i]); \ + double mc = c[i]; \ + double md = (INV & 2 ? -d[i] : d[i]); \ + double fma = __builtin_fma (mb, mc, md); \ + double truev = (INV & 4 ? -fma : fma); \ + if (a[i] != (i % 17 < 10 ? truev : 10.0)) \ + __builtin_abort (); \ + asm volatile ("" ::: "memory"); \ + } \ + } + +#define FOR_EACH_INV(T) \ + T (0) T (1) T (2) T (3) T (4) T (5) T (6) T (7) + +FOR_EACH_INV (DEF) + +int +main (void) +{ + double a[N], b[N], c[N], d[N]; + for (int i = 0; i < N; ++i) + { + b[i] = i % 17; + c[i] = i % 9 + 11; + d[i] = i % 13 + 14; + asm volatile ("" ::: "memory"); + } + FOR_EACH_INV (TEST) + return 0; +} + +/* { dg-final { scan-tree-dump-times { = \.COND_FMA } 2 "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump-times { = \.COND_FMS } 2 "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump-times { = \.COND_FNMA } 2 "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump-times { = \.COND_FNMS } 2 "optimized" { target vect_double_cond_arith } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-4.c new file mode 100644 index 0000000000..7d26dbedc5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-4.c @@ -0,0 +1,59 @@ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N (VECTOR_BITS * 11 / 64 + 3) + +#define add(A, B) ((A) + (B)) +#define sub(A, B) ((A) - (B)) +#define mul(A, B) ((A) * (B)) +#define div(A, B) ((A) / (B)) + +#define DEF(OP) \ + void __attribute__ ((noipa)) \ + f_##OP (double *restrict a, double *restrict b, double x) \ + { \ + for (int i = 0; i < N; ++i) \ + a[i] = b[i] < 100 ? OP (b[i], x) : b[i]; \ + } + +#define TEST(OP) \ + { \ + f_##OP (a, b, 10); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + { \ + int bval = (i % 17) * 10; \ + int truev = OP (bval, 10); \ + if (a[i] != (bval < 100 ? truev : bval)) \ + __builtin_abort (); \ + asm volatile ("" ::: "memory"); \ + } \ + } + +#define FOR_EACH_OP(T) \ + T (add) \ + T (sub) \ + T (mul) \ + T (div) + +FOR_EACH_OP (DEF) + +int +main (void) +{ + double a[N], b[N]; + for (int i = 0; i < N; ++i) + { + b[i] = (i % 17) * 10; + asm volatile ("" ::: "memory"); + } + FOR_EACH_OP (TEST) + return 0; +} + +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?ADD} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?SUB} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?MUL} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?RDIV} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump-not {VEC_COND_EXPR} "optimized" { target vect_double_cond_arith } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-5.c new file mode 100644 index 0000000000..f7daa13685 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-5.c @@ -0,0 +1,61 @@ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N (VECTOR_BITS * 11 / 64 + 3) + +#define add(A, B) ((A) + (B)) +#define sub(A, B) ((A) - (B)) +#define mul(A, B) ((A) * (B)) +#define div(A, B) ((A) / (B)) + +#define DEF(OP) \ + void __attribute__ ((noipa)) \ + f_##OP (double *restrict a, double *restrict b, double x) \ + { \ + for (int i = 0; i < N; ++i) \ + if (b[i] < 100) \ + a[i] = OP (b[i], x); \ + } + +#define TEST(OP) \ + { \ + f_##OP (a, b, 10); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + { \ + int bval = (i % 17) * 10; \ + int truev = OP (bval, 10); \ + if (a[i] != (bval < 100 ? truev : i * 3)) \ + __builtin_abort (); \ + asm volatile ("" ::: "memory"); \ + } \ + } + +#define FOR_EACH_OP(T) \ + T (add) \ + T (sub) \ + T (mul) \ + T (div) + +FOR_EACH_OP (DEF) + +int +main (void) +{ + double a[N], b[N]; + for (int i = 0; i < N; ++i) + { + a[i] = i * 3; + b[i] = (i % 17) * 10; + asm volatile ("" ::: "memory"); + } + FOR_EACH_OP (TEST) + return 0; +} + +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?ADD} "optimized" { target { vect_double_cond_arith && vect_masked_store } } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?SUB} "optimized" { target { vect_double_cond_arith && vect_masked_store } } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?MUL} "optimized" { target { vect_double_cond_arith && vect_masked_store } } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?RDIV} "optimized" { target { vect_double_cond_arith && vect_masked_store } } } } */ +/* { dg-final { scan-tree-dump-not {VEC_COND_EXPR} "optimized" { target { vect_double_cond_arith && vect_masked_store } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-6.c new file mode 100644 index 0000000000..a80c30a50b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-6.c @@ -0,0 +1,63 @@ +/* { dg-additional-options "-fdump-tree-optimized" } */ + +#include "tree-vect.h" + +#define N (VECTOR_BITS * 11 / 64 + 4) + +#define add(A, B) ((A) + (B)) +#define sub(A, B) ((A) - (B)) +#define mul(A, B) ((A) * (B)) +#define div(A, B) ((A) / (B)) + +#define DEF(OP) \ + void __attribute__ ((noipa)) \ + f_##OP (double *restrict a, double *restrict b, double x) \ + { \ + for (int i = 0; i < N; i += 2) \ + { \ + a[i] = b[i] < 100 ? OP (b[i], x) : b[i]; \ + a[i + 1] = b[i + 1] < 70 ? OP (b[i + 1], x) : b[i + 1]; \ + } \ + } + +#define TEST(OP) \ + { \ + f_##OP (a, b, 10); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + { \ + int bval = (i % 17) * 10; \ + int truev = OP (bval, 10); \ + if (a[i] != (bval < (i & 1 ? 70 : 100) ? truev : bval)) \ + __builtin_abort (); \ + asm volatile ("" ::: "memory"); \ + } \ + } + +#define FOR_EACH_OP(T) \ + T (add) \ + T (sub) \ + T (mul) \ + T (div) + +FOR_EACH_OP (DEF) + +int +main (void) +{ + double a[N], b[N]; + for (int i = 0; i < N; ++i) + { + b[i] = (i % 17) * 10; + asm volatile ("" ::: "memory"); + } + FOR_EACH_OP (TEST) + return 0; +} + +/* { dg-final { scan-tree-dump-times {vectorizing stmts using SLP} 4 "vect" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?ADD} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?SUB} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?MUL} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?RDIV} "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump-not {VEC_COND_EXPR} "optimized" { target vect_double_cond_arith } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-7.c new file mode 100644 index 0000000000..9d20f97788 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-7.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target scalar_all_fma } */ +/* { dg-additional-options "-fdump-tree-optimized -ffp-contract=fast" } */ + +#include "tree-vect.h" + +#define N (VECTOR_BITS * 11 / 64 + 3) + +#define DEF(INV) \ + void __attribute__ ((noipa)) \ + f_##INV (double *restrict a, double *restrict b, \ + double *restrict c, double *restrict d) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + double mb = (INV & 1 ? -b[i] : b[i]); \ + double mc = c[i]; \ + double md = (INV & 2 ? -d[i] : d[i]); \ + a[i] = b[i] < 10 ? mb * mc + md : 10.0; \ + } \ + } + +#define TEST(INV) \ + { \ + f_##INV (a, b, c, d); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + { \ + double mb = (INV & 1 ? -b[i] : b[i]); \ + double mc = c[i]; \ + double md = (INV & 2 ? -d[i] : d[i]); \ + double fma = __builtin_fma (mb, mc, md); \ + if (a[i] != (i % 17 < 10 ? fma : 10.0)) \ + __builtin_abort (); \ + asm volatile ("" ::: "memory"); \ + } \ + } + +#define FOR_EACH_INV(T) \ + T (0) T (1) T (2) T (3) + +FOR_EACH_INV (DEF) + +int +main (void) +{ + double a[N], b[N], c[N], d[N]; + for (int i = 0; i < N; ++i) + { + b[i] = i % 17; + c[i] = i % 9 + 11; + d[i] = i % 13 + 14; + asm volatile ("" ::: "memory"); + } + FOR_EACH_INV (TEST) + return 0; +} + +/* { dg-final { scan-tree-dump-times { = \.COND_FMA } 1 "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump-times { = \.COND_FMS } 1 "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump-times { = \.COND_FNMA } 1 "optimized" { target vect_double_cond_arith } } } */ +/* { dg-final { scan-tree-dump-times { = \.COND_FNMS } 1 "optimized" { target vect_double_cond_arith } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-8.c new file mode 100644 index 0000000000..e4b2abb737 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-arith-8.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +void +f (float *x, _Bool *cond, float *y) +{ + for (int i = 0; i < 100; ++i) + x[i] = cond[i] ? y[i] * 100 : y[i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cond-reduc-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-reduc-1.c new file mode 100644 index 0000000000..033aafa0f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cond-reduc-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_condition } */ + +#define N 512 +int a[N]; +int foo() +{ + int i, res = 0; + for (i=0; i + +#define N (VECTOR_BITS * 17) + +double __attribute__ ((noinline, noclone)) +reduc_plus_double (double *restrict a, double init, int *cond, int n) +{ + double res = init; + for (int i = 0; i < n; i++) + if (cond[i]) + res += a[i]; + return res; +} + +double __attribute__ ((noinline, noclone, optimize ("0"))) +reduc_plus_double_ref (double *restrict a, double init, int *cond, int n) +{ + double res = init; + for (int i = 0; i < n; i++) + if (cond[i]) + res += a[i]; + return res; +} + +double __attribute__ ((noinline, noclone)) +reduc_minus_double (double *restrict a, double init, int *cond, int n) +{ + double res = init; + for (int i = 0; i < n; i++) + if (cond[i]) + res -= a[i]; + return res; +} + +double __attribute__ ((noinline, noclone, optimize ("0"))) +reduc_minus_double_ref (double *restrict a, double init, int *cond, int n) +{ + double res = init; + for (int i = 0; i < n; i++) + if (cond[i]) + res -= a[i]; + return res; +} + +int __attribute__ ((optimize (1))) +main () +{ + int n = 19; + double a[N]; + int cond1[N], cond2[N]; + + for (int i = 0; i < N; i++) + { + a[i] = (i * 0.1) * (i & 1 ? 1 : -1); + cond1[i] = 0; + cond2[i] = i & 4 ? 1 : 0; + asm volatile ("" ::: "memory"); + } + + double res1 = reduc_plus_double (a, -0.0, cond1, n); + double ref1 = reduc_plus_double_ref (a, -0.0, cond1, n); + double res2 = reduc_minus_double (a, -0.0, cond1, n); + double ref2 = reduc_minus_double_ref (a, -0.0, cond1, n); + double res3 = reduc_plus_double (a, -0.0, cond1, n); + double ref3 = reduc_plus_double_ref (a, -0.0, cond1, n); + double res4 = reduc_minus_double (a, -0.0, cond1, n); + double ref4 = reduc_minus_double_ref (a, -0.0, cond1, n); + + if (res1 != ref1 || signbit (res1) != signbit (ref1)) + __builtin_abort (); + if (res2 != ref2 || signbit (res2) != signbit (ref2)) + __builtin_abort (); + if (res3 != ref3 || signbit (res3) != signbit (ref3)) + __builtin_abort (); + if (res4 != ref4 || signbit (res4) != signbit (ref4)) + __builtin_abort (); + + res1 = reduc_plus_double (a, 0.0, cond1, n); + ref1 = reduc_plus_double_ref (a, 0.0, cond1, n); + res2 = reduc_minus_double (a, 0.0, cond1, n); + ref2 = reduc_minus_double_ref (a, 0.0, cond1, n); + res3 = reduc_plus_double (a, 0.0, cond1, n); + ref3 = reduc_plus_double_ref (a, 0.0, cond1, n); + res4 = reduc_minus_double (a, 0.0, cond1, n); + ref4 = reduc_minus_double_ref (a, 0.0, cond1, n); + + if (res1 != ref1 || signbit (res1) != signbit (ref1)) + __builtin_abort (); + if (res2 != ref2 || signbit (res2) != signbit (ref2)) + __builtin_abort (); + if (res3 != ref3 || signbit (res3) != signbit (ref3)) + __builtin_abort (); + if (res4 != ref4 || signbit (res4) != signbit (ref4)) + __builtin_abort (); + + res1 = reduc_plus_double (a, -0.0, cond2, n); + ref1 = reduc_plus_double_ref (a, -0.0, cond2, n); + res2 = reduc_minus_double (a, -0.0, cond2, n); + ref2 = reduc_minus_double_ref (a, -0.0, cond2, n); + res3 = reduc_plus_double (a, -0.0, cond2, n); + ref3 = reduc_plus_double_ref (a, -0.0, cond2, n); + res4 = reduc_minus_double (a, -0.0, cond2, n); + ref4 = reduc_minus_double_ref (a, -0.0, cond2, n); + + if (res1 != ref1 || signbit (res1) != signbit (ref1)) + __builtin_abort (); + if (res2 != ref2 || signbit (res2) != signbit (ref2)) + __builtin_abort (); + if (res3 != ref3 || signbit (res3) != signbit (ref3)) + __builtin_abort (); + if (res4 != ref4 || signbit (res4) != signbit (ref4)) + __builtin_abort (); + + res1 = reduc_plus_double (a, 0.0, cond2, n); + ref1 = reduc_plus_double_ref (a, 0.0, cond2, n); + res2 = reduc_minus_double (a, 0.0, cond2, n); + ref2 = reduc_minus_double_ref (a, 0.0, cond2, n); + res3 = reduc_plus_double (a, 0.0, cond2, n); + ref3 = reduc_plus_double_ref (a, 0.0, cond2, n); + res4 = reduc_minus_double (a, 0.0, cond2, n); + ref4 = reduc_minus_double_ref (a, 0.0, cond2, n); + + if (res1 != ref1 || signbit (res1) != signbit (ref1)) + __builtin_abort (); + if (res2 != ref2 || signbit (res2) != signbit (ref2)) + __builtin_abort (); + if (res3 != ref3 || signbit (res3) != signbit (ref3)) + __builtin_abort (); + if (res4 != ref4 || signbit (res4) != signbit (ref4)) + __builtin_abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-1.c new file mode 100644 index 0000000000..0737da5d67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -ftree-vectorize -fvect-cost-model=cheap" } */ + +void +f (int *x, int *y) +{ + for (unsigned int i = 0; i < 1024; ++i) + x[i] += y[i]; +} + +/* { dg-final { scan-tree-dump {LOOP VECTORIZED} vect { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-2.c new file mode 100644 index 0000000000..fa9bdb607b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -ftree-vectorize -fvect-cost-model=very-cheap" } */ + +void +f (int *x, int *y) +{ + for (unsigned int i = 0; i < 1024; ++i) + x[i] += y[i]; +} + +/* { dg-final { scan-tree-dump-not {LOOP VECTORIZED} vect { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-3.c new file mode 100644 index 0000000000..d7c6cfd204 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -ftree-vectorize -fvect-cost-model=cheap" } */ + +void +f (int *restrict x, int *restrict y) +{ + for (unsigned int i = 0; i < 1024; ++i) + x[i] += y[i]; +} + +/* { dg-final { scan-tree-dump {LOOP VECTORIZED} vect { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-4.c new file mode 100644 index 0000000000..bb018ad99f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-4.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -ftree-vectorize -fvect-cost-model=very-cheap" } */ + +int x[1024], y[1024]; + +void +f (void) +{ + for (unsigned int i = 0; i < 1024; ++i) + x[i] += y[i]; +} + +/* { dg-final { scan-tree-dump {LOOP VECTORIZED} vect { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-5.c new file mode 100644 index 0000000000..536ec0a3cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-5.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -ftree-vectorize -fvect-cost-model=cheap" } */ + +void +f (int *restrict x, int *restrict y) +{ + for (unsigned int i = 0; i < 1023; ++i) + x[i] += y[i]; +} + +/* { dg-final { scan-tree-dump {LOOP VECTORIZED} vect { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-6.c new file mode 100644 index 0000000000..552febb5fe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cost-model-6.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -ftree-vectorize -fvect-cost-model=very-cheap" } */ + +void +f (int *restrict x, int *restrict y) +{ + for (unsigned int i = 0; i < 1023; ++i) + x[i] += y[i]; +} + +/* { dg-final { scan-tree-dump {LOOP VECTORIZED} vect { target { vect_int && vect_partial_vectors_usage_2 } } } } */ +/* { dg-final { scan-tree-dump-not {LOOP VECTORIZED} vect { target { vect_int && { ! vect_partial_vectors_usage_2 } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cselim-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cselim-1.c new file mode 100644 index 0000000000..faeccca865 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cselim-1.c @@ -0,0 +1,87 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 50 + +typedef struct { + short a; + short b; +} data; + +data in1[N], in2[N], out[N]; +short result[N*2] = {7,-7,9,-6,11,-5,13,-4,15,-3,17,-2,19,-1,21,0,23,1,25,2,27,3,29,4,31,5,33,6,35,7,37,8,39,9,41,10,43,11,45,12,47,13,49,14,51,15,53,16,55,17,57,18,59,19,61,20,63,21,65,22,67,23,69,24,71,25,73,26,75,27,77,28,79,29,81,30,83,31,85,32,87,33,89,34,91,35,93,36,95,37,97,38,99,39,101,40,103,41,105,42}; +short out1[N], out2[N]; + +__attribute__ ((noinline)) void +foo () +{ + int i; + short c, d; + + /* Vectorizable with conditional store sinking. */ + for (i = 0; i < N; i++) + { + c = in1[i].b; + d = in2[i].b; + + if (c >= d) + { + out[i].b = c; + out[i].a = d + 5; + } + else + { + out[i].b = d - 12; + out[i].a = c + d; + } + } + + /* Only vectorizable with masked stores. */ + for (i = 0; i < N; i++) + { + c = in1[i].b; + d = in2[i].b; + + if (c >= d) + { + out1[i] = c; + } + else + { + out2[i] = c + d; + } + } +} + +int +main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + in1[i].a = i; + in1[i].b = i + 2; + in2[i].a = 5; + in2[i].b = i + 5; + __asm__ volatile (""); + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (out[i].a != result[2*i] || out[i].b != result[2*i+1]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! vect_masked_store } xfail { { vect_no_align && { ! vect_hw_misalign } } || { ! vect_strided2 } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { vect_masked_store } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-cselim-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-cselim-2.c new file mode 100644 index 0000000000..f3b7db076e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-cselim-2.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ +/* We now if-convert the loop unconditonally as the memory locations + are always stored to. */ +/* { dg-additional-options "-fno-tree-loop-if-convert" } */ + +#include +#include "tree-vect.h" + +#define N 50 + +int a[N], b[N], in1[N], in2[N]; +int result[2*N] = {5,-7,7,-6,9,-5,11,-4,13,-3,15,-2,17,-1,19,0,21,1,23,2,25,3,27,4,29,5,31,6,33,7,35,8,37,9,39,10,41,11,43,12,45,13,47,14,49,15,51,16,53,17,55,18,57,19,59,20,61,21,63,22,65,23,67,24,69,25,71,26,73,27,75,28,77,29,79,30,81,31,83,32,85,33,87,34,89,35,91,36,93,37,95,38,97,39,99,40,101,41,103,42}; + +__attribute__ ((noinline)) void +foo (int *pa, int *pb) +{ + int i; + int c, d; + + /* Store sinking should not work here since the pointers may alias. */ + for (i = 0; i < N; i++) + { + c = in1[i]; + d = in2[i]; + + if (c >= d) + { + *pa = c; + *pb = d + 5; + } + else + { + *pb = d - 12; + *pa = c + d; + } + + pa++; + pb++; + } +} + +int +main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + in1[i] = i; + in2[i] = i + 5; + __asm__ volatile (""); + } + + foo (a, b); + +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != result[2*i] || b[i] != result[2*i+1]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ctor-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ctor-1.c new file mode 100644 index 0000000000..e050db1a2e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ctor-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target { i?86-*-* x86_64-*-* } } } */ + +typedef struct { + unsigned short mprr_2[5][16][16]; +} ImageParameters; +int s[16][2]; +void intrapred_luma_16x16(ImageParameters *img, int s0) +{ + for (int j=0; j < 16; j++) + for (int i=0; i < 16; i++) + { + img->mprr_2[1 ][j][i]=s[j][1]; + img->mprr_2[2 ][j][i]=s0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-debug-pr41926.c b/SingleSource/Regression/C/gcc-dg/vect/vect-debug-pr41926.c new file mode 100644 index 0000000000..b3c553bc2d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-debug-pr41926.c @@ -0,0 +1,20 @@ +/* PR debug/41926 */ +/* { dg-do compile } */ +/* { dg-additional-options "-g -ffast-math -funroll-loops" } */ + +void +foo (double (*__restrict p)[4], double (*__restrict q)[4], + double *__restrict prim, double scale, double pp, double pq) +{ + int md, mc, mb, ma, p_index = 0; + + for (md = 0; md < 1; md++) + for (mc = 0; mc < 1; mc++) + for (mb = 0; mb < 1; mb++) + for (ma = 0; ma < 4; ma++) + { + double tmp = scale * prim[p_index++]; + p[md][ma] = p[md][ma] - tmp * pp; + q[mc][ma] = q[mc][ma] - tmp * pq; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-1.c new file mode 100644 index 0000000000..472cd71053 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-1.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 50 +#define TYPE uint8_t + +__attribute__((noipa, noinline, optimize("O1"))) +void fun1(TYPE* restrict pixel, TYPE level, int n) +{ + for (int i = 0; i < n; i+=1) + pixel[i] = (pixel[i] * level) / 0xff; +} + +__attribute__((noipa, noinline, optimize("O3"))) +void fun2(TYPE* restrict pixel, TYPE level, int n) +{ + for (int i = 0; i < n; i+=1) + pixel[i] = (pixel[i] * level) / 0xff; +} + +#include "vect-div-bitmask.h" + +/* { dg-final { scan-tree-dump-not "vect_recog_divmod_pattern: detected" "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-2.c new file mode 100644 index 0000000000..e904a71885 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-2.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 50 +#define TYPE uint16_t + +__attribute__((noipa, noinline, optimize("O1"))) +void fun1(TYPE* restrict pixel, TYPE level, int n) +{ + for (int i = 0; i < n; i+=1) + pixel[i] = (pixel[i] * level) / 0xffffU; +} + +__attribute__((noipa, noinline, optimize("O3"))) +void fun2(TYPE* restrict pixel, TYPE level, int n) +{ + for (int i = 0; i < n; i+=1) + pixel[i] = (pixel[i] * level) / 0xffffU; +} + +#include "vect-div-bitmask.h" + +/* { dg-final { scan-tree-dump-not "vect_recog_divmod_pattern: detected" "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-3.c new file mode 100644 index 0000000000..a1418ebbf5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-3.c @@ -0,0 +1,26 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-vect-cost-model" { target aarch64*-*-* } } */ + +#include +#include "tree-vect.h" + +#define N 50 +#define TYPE uint32_t + +__attribute__((noipa, noinline, optimize("O1"))) +void fun1(TYPE* restrict pixel, TYPE level, int n) +{ + for (int i = 0; i < n; i+=1) + pixel[i] = (pixel[i] * (uint64_t)level) / 0xffffffffUL; +} + +__attribute__((noipa, noinline, optimize("O3"))) +void fun2(TYPE* restrict pixel, TYPE level, int n) +{ + for (int i = 0; i < n; i+=1) + pixel[i] = (pixel[i] * (uint64_t)level) / 0xffffffffUL; +} + +#include "vect-div-bitmask.h" + +/* { dg-final { scan-tree-dump-not "vect_recog_divmod_pattern: detected" "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-4.c new file mode 100644 index 0000000000..f02f98faf2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-4.c @@ -0,0 +1,26 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +typedef unsigned __attribute__((__vector_size__ (16))) V; + +static __attribute__((__noinline__)) __attribute__((__noclone__)) V +foo (V v, unsigned short i) +{ + v /= i; + return v; +} + +int +main (void) +{ + V v = foo ((V) { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }, 0xffff); +#pragma GCC novector + for (unsigned i = 0; i < sizeof (v) / sizeof (v[0]); i++) + if (v[i] != 0x00010001) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-not "vect_recog_divmod_pattern: detected" "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-5.c new file mode 100644 index 0000000000..80293e50bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask-5.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include +#include "tree-vect.h" + +#define N 50 +#define TYPE uint8_t + +#ifndef DEBUG +#define DEBUG 0 +#endif + +#define BASE ((TYPE) -1 < 0 ? -126 : 4) + + +__attribute__((noipa, noinline, optimize("O1"))) +void fun1(TYPE* restrict pixel, TYPE level, int n) +{ + for (int i = 0; i < n; i+=1) + pixel[i] = (pixel[i] + level) / 0xff; +} + +__attribute__((noipa, noinline, optimize("O3"))) +void fun2(TYPE* restrict pixel, TYPE level, int n) +{ + for (int i = 0; i < n; i+=1) + pixel[i] = (pixel[i] + level) / 0xff; +} + +int main () +{ + TYPE a[N]; + TYPE b[N]; + + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 13; + b[i] = BASE + i * 13; + if (DEBUG) + printf ("%d: 0x%x\n", i, a[i]); + } + + fun1 (a, N / 2, N); + fun2 (b, N / 2, N); + +#pragma GCC novector + for (int i = 0; i < N; ++i) + { + if (DEBUG) + printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]); + + if (a[i] != b[i]) + __builtin_abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump "divmod pattern recognized" "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask.h b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask.h new file mode 100644 index 0000000000..bfdc730fe5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-div-bitmask.h @@ -0,0 +1,44 @@ +#include + +#ifndef N +#define N 65 +#endif + +#ifndef TYPE +#define TYPE uint32_t +#endif + +#ifndef DEBUG +#define DEBUG 0 +#endif + +#define BASE ((TYPE) -1 < 0 ? -126 : 4) + +int main () +{ + TYPE a[N]; + TYPE b[N]; + + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 13; + b[i] = BASE + i * 13; + if (DEBUG) + printf ("%d: 0x%x\n", i, a[i]); + } + + fun1 (a, N / 2, N); + fun2 (b, N / 2, N); + +#pragma GCC novector + for (int i = 0; i < N; ++i) + { + if (DEBUG) + printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]); + + if (a[i] != b[i]) + __builtin_abort (); + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-1.c new file mode 100644 index 0000000000..6456b3aad8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-1.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int_mult } */ + +#include +#include "tree-vect.h" + +#define K 32 + +int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; +int check_result[K] = {642816,660736,678656,696576,714496,732416,750336,768256,786176,804096,822016,839936,857856,875776,893696,911616,929536,947456,965376,983296,1001216,1019136,1037056,1054976,1072896,1090816,1108736,1126656,1144576,1162496,1180416,1198336}; + +__attribute__ ((noinline)) void +foo () +{ + int sum = 0, i, j, k; + + for (k = 0; k < K; k++) + { + sum = 0; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + sum += in[i+k][j] * coeff[i][j]; + + out[k] = sum; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + in[i][j] = i+j; + + for (i = 0; i < K; i++) + coeff[i][j] = i+2; + } + + foo(); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-2.c new file mode 100644 index 0000000000..d5613e55eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-2.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int_mult } */ + +#include +#include "tree-vect.h" + +#define K 32 + +int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; +int check_result[K] = {357184,339264,321344,303424,285504,267584,249664,231744,213824,195904,177984,160064,142144,124224,106304,88384,70464,52544,34624,16704,-1216,-19136,-37056,-54976,-72896,-90816,-108736,-126656,-144576,-162496,-180416,-198336}; + +__attribute__ ((noinline)) void +foo () +{ + int res = 0, i, j, k; + + for (k = 0; k < K; k++) + { + res = 1000000; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + res -= in[i+k][j] * coeff[i][j]; + + out[k] = res; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + in[i][j] = i+j; + + for (i = 0; i < K; i++) + coeff[i][j] = i+2; + } + + foo(); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-3.c new file mode 100644 index 0000000000..239ddb0b44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-3.c @@ -0,0 +1,67 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define K 32 + +int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out_max[K], out_min[K]; +int check_max[K] = {62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93}; +int check_min[K] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; + +__attribute__ ((noinline)) void +foo (int x, int y) +{ + int max, min, i, j, k; + + for (k = 0; k < K; k++) + { + max = x; + min = y; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + { + max = max < in[i+k][j] ? in[i+k][j] : max; + min = min > in[i+k][j] ? in[i+k][j] : min; + } + out_max[k] = max; + out_min[k] = min; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + in[i][j] = i+j; + + for (i = 0; i < K; i++) + coeff[i][j] = i+2; + } + + foo(0, 0); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out_max[k] != check_max[k] || out_min[k] != 0) + abort (); + + foo(100, 45); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out_min[k] != check_min[k] || out_max[k] != 100) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail vect_no_int_min_max } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-4.c new file mode 100644 index 0000000000..5344c80741 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-4.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int_mult } */ + +#include +#include "tree-vect.h" + +#define K 32 + +int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; +int check_result[K] = {652816,670736,688656,706576,724496,742416,760336,778256,796176,814096,832016,849936,867856,885776,903696,921616,939536,957456,975376,993296,1011216,1029136,1047056,1064976,1082896,1100816,1118736,1136656,1154576,1172496,1190416,1208336}; + +__attribute__ ((noinline)) void +foo () +{ + int sum = 0, i, j, k; + + for (k = 0; k < K; k++) + { + sum = 10000; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + sum += in[i+k][j] * coeff[i][j]; + + out[k] = sum; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + in[i][j] = i+j; + + for (i = 0; i < K; i++) + coeff[i][j] = i+2; + } + + foo(); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-5.c new file mode 100644 index 0000000000..b990405745 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-5.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int_mult } */ + +#include +#include "tree-vect.h" + +#define K 32 + +signed short in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; +int check_result[K] = {642816,660736,678656,696576,714496,732416,750336,768256,786176,804096,822016,839936,857856,875776,893696,911616,929536,947456,965376,983296,1001216,1019136,1037056,1054976,1072896,1090816,1108736,1126656,1144576,1162496,1180416,1198336}; + +__attribute__ ((noinline)) void +foo () +{ + int sum = 0, i, j, k; + + for (k = 0; k < K; k++) + { + sum = 0; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + sum += in[i+k][j] * coeff[i][j]; + + out[k] = sum; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + in[i][j] = i+j; + + for (i = 0; i < K; i++) + coeff[i][j] = i+2; + } + + foo(); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} + +/* Vectorization of loops with multiple types and double reduction is not + supported yet. */ +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { ! { aarch64*-*-* riscv*-*-* } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-6-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-6-big-array.c new file mode 100644 index 0000000000..a032e33993 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-6-big-array.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target vect_int_mult } */ + +#include +#include "tree-vect.h" + +#define K 16 + +int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; +int check_result[K]; + +__attribute__ ((noinline)) void +foo () +{ + int sum; + int i, j, k; + + for (k = 0; k < K; k++) + { + sum = 1; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + { + sum *= in[i+k][j]; + asm volatile ("" ::: "memory"); + } + check_result[k] = sum; + } + + for (k = 0; k < K; k++) + { + sum = 1; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + sum *= in[i+k][j]; + out[k] = sum; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (i = 0; i < 2*K; i++) + for (j = 0; j < K; j++) + in[i][j] = (i+2)/3; + + foo (); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-6.c new file mode 100644 index 0000000000..d1d1faf7c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-6.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int_mult } */ + +#include +#include "tree-vect.h" + +#define K 4 + +int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; +int check_result[K] = {0,16,256,4096}; + +__attribute__ ((noinline)) void +foo () +{ + int sum; + int i, j, k; + + for (k = 0; k < K; k++) + { + sum = 1; + for (j = 0; j < K; j++) +#pragma GCC unroll 0 + for (i = 0; i < K; i++) + sum *= in[i+k][j]; + out[k] = sum; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (i = 0; i < 2*K; i++) + for (j = 0; j < K; j++) + in[i][j] = (i+2)/3; + + foo(); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-7.c new file mode 100644 index 0000000000..1ef7a2d19c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-double-reduc-7.c @@ -0,0 +1,64 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define K 32 + +int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int out[K]; +int check_result[K] = {63,63,191,191,127,127,191,191,127,127,191,191,127,127,191,191,127,127,191,191,127,127,191,191,127,127,191,191,127,127,191,191}; + +__attribute__ ((noinline)) void +foo () +{ + int res_or, res_and, res_xor, i, j, k; + + for (k = 0; k < K; k++) + { + res_or = 0; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + res_or = res_or | in[i+k][j]; + + res_and = 1; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + res_and = res_and & in[i+k][j]; + + res_xor = 0; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + res_xor = res_xor ^ in[i+k][j]; + + out[k] = res_or + res_and + res_xor; + } +} + +int main () +{ + int i, j, k; + + check_vect (); + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + in[i][j] = i+j; + + for (i = 0; i < K; i++) + out[i] = i+j; + } + + foo(); + +#pragma GCC novector + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 3 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-dv-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-dv-1.c new file mode 100644 index 0000000000..621e67df4c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-dv-1.c @@ -0,0 +1,21 @@ +/* Test compiler crash when dependence analyzer can not represent + dependence relation by distance vector. */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int x[199]; + +void foo() + +{ + int t,j; + + for (j=99;j>0;j--) + x [j+j]=x[j]; + + for (j=198;j>=100;j--) + if(x[j]) + { + x[j-63]=x[j-3]-x[j]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_1.c new file mode 100644 index 0000000000..fb8faea322 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_1.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 803 +#define P 0 +#include "vect-early-break-template_1.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_10.c new file mode 100644 index 0000000000..2fc8551db4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_10.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 800 +#define P 799 +#include "vect-early-break-template_2.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_2.c new file mode 100644 index 0000000000..8c6d4cebb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_2.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 803 +#define P 802 +#include "vect-early-break-template_1.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_3.c new file mode 100644 index 0000000000..ad25db4e6e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_3.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 803 +#define P 5 +#include "vect-early-break-template_1.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_4.c new file mode 100644 index 0000000000..804d640cd1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_4.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 803 +#define P 278 +#include "vect-early-break-template_1.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_5.c new file mode 100644 index 0000000000..fd8086aab0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_5.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 800 +#define P 799 +#include "vect-early-break-template_1.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_6.c new file mode 100644 index 0000000000..3b4490df0e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_6.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 803 +#define P 0 +#include "vect-early-break-template_2.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_7.c new file mode 100644 index 0000000000..ab9ff90c3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_7.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 803 +#define P 802 +#include "vect-early-break-template_2.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_8.c new file mode 100644 index 0000000000..c2ea839d71 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_8.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 803 +#define P 5 +#include "vect-early-break-template_2.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_9.c new file mode 100644 index 0000000000..a221c87938 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-run_9.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast -save-temps" } */ + +#define N 803 +#define P 278 +#include "vect-early-break-template_2.c" + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-template_1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-template_1.c new file mode 100644 index 0000000000..acc088282a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-template_1.c @@ -0,0 +1,50 @@ +#include "tree-vect.h" + +#ifndef N +#define N 803 +#endif + +#ifndef P +#define P 0 +#endif + +unsigned vect_a[N] = {0}; +unsigned vect_b[N] = {0}; + +__attribute__((noipa, noinline)) +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} + +extern void abort (); + +int main () +{ + check_vect (); + + int x = 1; + int idx = P; + vect_a[idx] = x + 1; + + test4(x); + + if (vect_b[idx] != (x + idx)) + abort (); + + if (vect_a[idx] != x + 1) + abort (); + + if (idx > 0 && vect_a[idx-1] != x) + abort (); + +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-template_2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-template_2.c new file mode 100644 index 0000000000..dce852e760 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break-template_2.c @@ -0,0 +1,53 @@ +#include "tree-vect.h" + +#ifndef N +#define N 803 +#endif + +#ifndef P +#define P 0 +#endif + +unsigned vect_a[N] = {0}; +unsigned vect_b[N] = {0}; + +__attribute__((noipa, noinline)) +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return i; + vect_a[i] = x; + + } + return ret; +} + +extern void abort (); + +int main () +{ + check_vect (); + + int x = 1; + int idx = P; + vect_a[idx] = x + 1; + + unsigned res = test4(x); + + if (res != idx) + abort (); + + if (vect_b[idx] != (x + idx)) + abort (); + + if (vect_a[idx] != x + 1) + abort (); + + if (idx > 0 && vect_a[idx-1] != x) + abort (); + +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_1.c new file mode 100644 index 0000000000..c1da23e691 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_1.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_10.c new file mode 100644 index 0000000000..49bae48496 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_10.c @@ -0,0 +1,29 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x,int y, int z) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + break; + vect_a[i] = x; + } + + ret = x + y * z; + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_11.c new file mode 100644 index 0000000000..8085383a56 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_11.c @@ -0,0 +1,32 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x, int y) +{ + unsigned ret = 0; +for (int o = 0; o < y; o++) +{ + ret += o; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } +} + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_12.c new file mode 100644 index 0000000000..8eeec820be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_12.c @@ -0,0 +1,32 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x, int y) +{ + unsigned ret = 0; +for (int o = 0; o < y; o++) +{ + ret += o; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return vect_a[i]; + vect_a[i] = x; + + } +} + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_13.c new file mode 100644 index 0000000000..58f5f0ae7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_13.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return vect_a[i] * x; + vect_a[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_14.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_14.c new file mode 100644 index 0000000000..3f0a61fe8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_14.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#define N 803 +unsigned vect_a[N]; +unsigned vect_b[N]; + +int test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return i; + vect_a[i] += x * vect_b[i]; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_15.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_15.c new file mode 100644 index 0000000000..08e7faf240 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_15.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#define N 803 +unsigned vect_a[N]; +unsigned vect_b[N]; + +int test4(unsigned x) +{ + int ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return i; + vect_a[i] += x * vect_b[i]; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_16.c new file mode 100644 index 0000000000..6bb71555be --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_16.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#define N 1024 +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return vect_a[i]; + vect_a[i] = x; + ret += vect_a[i] + vect_b[i]; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_17.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_17.c new file mode 100644 index 0000000000..264031874e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_17.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#define N 1024 +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return vect_a[i]; + vect_a[i] = x; + ret = vect_a[i] + vect_b[i]; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_18.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_18.c new file mode 100644 index 0000000000..babc79c74c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_18.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i+=2) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_19.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_19.c new file mode 100644 index 0000000000..9555c16a08 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_19.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x, unsigned step) +{ + unsigned ret = 0; + for (int i = 0; i < N; i+=step) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_2.c new file mode 100644 index 0000000000..5c32bf9440 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_2.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include + +#define N 1024 +complex double vect_a[N]; +complex double vect_b[N]; + +complex double test4(complex double x) +{ + complex double ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] += x + i; + if (vect_a[i] == x) + return i; + vect_a[i] += x * vect_b[i]; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_20.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_20.c new file mode 100644 index 0000000000..039aac7fd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_20.c @@ -0,0 +1,38 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include + +#ifndef N +#define N 803 +#endif +unsigned vect_b[N]; +struct testStruct { + long e; + long f; + bool a : 1; + bool b : 1; + int c : 14; + int d; +}; +struct testStruct vect_a[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i].a > x) + return true; + vect_a[i].e = x; + } + return ret; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_21.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_21.c new file mode 100644 index 0000000000..dbe3f82651 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_21.c @@ -0,0 +1,38 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include + +#ifndef N +#define N 803 +#endif +unsigned vect_b[N]; +struct testStruct { + long e; + long f; + bool a : 1; + bool b : 1; + int c : 14; + int d; +}; +struct testStruct vect_a[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i].a) + return true; + vect_a[i].e = x; + } + return ret; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_22.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_22.c new file mode 100644 index 0000000000..b3f5984f68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_22.c @@ -0,0 +1,45 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ +/* { dg-require-effective-target vect_early_break_hw } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (int * __restrict__ a, short * __restrict__ b, int * __restrict__ c) +{ + int t1 = *c; + int t2 = *c; + for (int i = 0; i < 64; i+=2) + { + b[i] = a[i] - t1; + t1 = a[i]; + b[i+1] = a[i+1] - t2; + t2 = a[i+1]; + } +} + +int a[64]; +short b[64]; + +int +main () +{ + check_vect (); + for (int i = 0; i < 64; ++i) + { + a[i] = i; + __asm__ volatile ("" ::: "memory"); + } + int c = 7; + foo (a, b, &c); + for (int i = 2; i < 64; i+=2) + if (b[i] != a[i] - a[i-2] + || b[i+1] != a[i+1] - a[i-1]) + abort (); + if (b[0] != -7 || b[1] != -6) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_23.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_23.c new file mode 100644 index 0000000000..3e435af444 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_23.c @@ -0,0 +1,65 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 200 +#define M 4 + +typedef signed char sc; +typedef unsigned char uc; +typedef signed short ss; +typedef unsigned short us; +typedef int si; +typedef unsigned int ui; +typedef signed long long sll; +typedef unsigned long long ull; + +#define FOR_EACH_TYPE(M) \ + M (sc) M (uc) \ + M (ss) M (us) \ + M (si) M (ui) \ + M (sll) M (ull) \ + M (float) M (double) + +#define TEST_VALUE(I) ((I) * 17 / 2) + +#define ADD_TEST(TYPE) \ + void __attribute__((noinline, noclone)) \ + test_##TYPE (TYPE *a, TYPE *b) \ + { \ + for (int i = 0; i < N; i += 2) \ + { \ + a[i + 0] = b[i + 0] + 2; \ + a[i + 1] = b[i + 1] + 3; \ + } \ + } + +#define DO_TEST(TYPE) \ + for (int j = 1; j < M; ++j) \ + { \ + TYPE a[N + M]; \ + for (int i = 0; i < N + M; ++i) \ + a[i] = TEST_VALUE (i); \ + test_##TYPE (a + j, a); \ + for (int i = 0; i < N; i += 2) \ + if (a[i + j] != (TYPE) (a[i] + 2) \ + || a[i + j + 1] != (TYPE) (a[i + 1] + 3)) \ + __builtin_abort (); \ + } + +FOR_EACH_TYPE (ADD_TEST) + +int +main (void) +{ + check_vect (); + + FOR_EACH_TYPE (DO_TEST) + return 0; +} + +/* { dg-final { scan-tree-dump {flags: [^\n]*ARBITRARY\n} "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "using an address-based overlap test" "vect" } } */ +/* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_24.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_24.c new file mode 100644 index 0000000000..fa2a17ed96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_24.c @@ -0,0 +1,46 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_early_break_hw } */ + +#include "tree-vect.h" + +extern void abort (void); +void __attribute__((noinline,noclone)) +foo (double *b, double *d, double *f) +{ + int i; + for (i = 0; i < 1024; i++) + { + d[2*i] = 2. * d[2*i]; + d[2*i+1] = 4. * d[2*i+1]; + b[i] = d[2*i] - 1.; + f[i] = d[2*i+1] + 2.; + } +} +int main() +{ + double b[1024], d[2*1024], f[1024]; + int i; + + check_vect (); + + for (i = 0; i < 2*1024; i++) + d[i] = 1.; + foo (b, d, f); + for (i = 0; i < 1024; i+= 2) + { + if (d[2*i] != 2.) + abort (); + if (d[2*i+1] != 4.) + abort (); + } + for (i = 0; i < 1024; i++) + { + if (b[i] != 1.) + abort (); + if (f[i] != 6.) + abort (); + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_25.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_25.c new file mode 100644 index 0000000000..4d8b47ed9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_25.c @@ -0,0 +1,11 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include "vect-peel-1-src.c" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_element_align_preferred } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_26.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_26.c new file mode 100644 index 0000000000..47d2a50218 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_26.c @@ -0,0 +1,44 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (int * __restrict__ a, int * __restrict__ b, int * __restrict__ c) +{ + int t1 = *c; + int t2 = *c; + for (int i = 0; i < 64; i+=2) + { + b[i] = a[i] - t1; + t1 = a[i]; + b[i+1] = a[i+1] - t2; + t2 = a[i+1]; + } +} + +int a[64], b[64]; + +int +main () +{ + check_vect (); + for (int i = 0; i < 64; ++i) + { + a[i] = i; + __asm__ volatile ("" ::: "memory"); + } + int c = 7; + foo (a, b, &c); + for (int i = 2; i < 64; i+=2) + if (b[i] != a[i] - a[i-2] + || b[i+1] != a[i+1] - a[i-1]) + abort (); + if (b[0] != -7 || b[1] != -6) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_27.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_27.c new file mode 100644 index 0000000000..ed7b31757a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_27.c @@ -0,0 +1,19 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +void abort (); +int a[128]; + +int main () +{ + int i; + for (i = 1; i < 128; i++) + if (a[i] != i%4 + 1) + abort (); + if (a[0] != 5) + abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_28.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_28.c new file mode 100644 index 0000000000..9c980b8453 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_28.c @@ -0,0 +1,16 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +void abort (); +int a[128]; +int main () +{ + int i; + for (i = 1; i < 128; i++) + if (a[i] != i%4 + 1) + abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_29.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_29.c new file mode 100644 index 0000000000..b66fe204ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_29.c @@ -0,0 +1,17 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +int in[100]; +int out[100 * 2]; + +int main (void) +{ + if (out[0] != in[100 - 1]) + for (int i = 1; i <= 100; ++i) + if (out[i] != 2) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_3.c new file mode 100644 index 0000000000..4afbc72667 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_3.c @@ -0,0 +1,21 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ + +unsigned test4(char x, char *vect, int n) +{ + unsigned ret = 0; + for (int i = 0; i < n; i++) + { + if (vect[i] > x) + return 1; + + vect[i] = x; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_30.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_30.c new file mode 100644 index 0000000000..3f6e802ae8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_30.c @@ -0,0 +1,29 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +int x[100]; +int choose1(int); +int choose2(); +void consume(int); +void f() { + for (int i = 0; i < 100; ++i) { + if (x[i] == 11) { + if (choose1(i)) + goto A; + else + goto B; + } + } + if (choose2()) + goto B; +A: + for (int i = 0; i < 100; ++i) + consume(i); +B: + for (int i = 0; i < 100; ++i) + consume(i * i); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_31.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_31.c new file mode 100644 index 0000000000..1eaf52aaa8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_31.c @@ -0,0 +1,30 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 1025 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return vect_a[i]; + vect_a[i] = x; + ret += vect_a[i] + vect_b[i]; + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_32.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_32.c new file mode 100644 index 0000000000..038be402c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_32.c @@ -0,0 +1,30 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 1024 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return vect_a[i]; + vect_a[i] = x; + ret = vect_a[i] + vect_b[i]; + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_33.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_33.c new file mode 100644 index 0000000000..74116143b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_33.c @@ -0,0 +1,29 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a2[N]; +unsigned vect_a1[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x, int z) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a1[i]*2 > x) + { + for (int y = 0; y < z; y++) + vect_a2 [y] *= vect_a1[i]; + break; + } + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 2 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_34.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_34.c new file mode 100644 index 0000000000..63f1bb4254 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_34.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif + +unsigned vect_a[N] __attribute__ ((aligned (4)));; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + + for (int i = 1; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i]*2 > x) + break; + vect_a[i] = x; + + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_35.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_35.c new file mode 100644 index 0000000000..4c0078fbc6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_35.c @@ -0,0 +1,29 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a2[N]; +unsigned vect_a1[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a1[i]*2 > x) + break; + vect_a1[i] = x; + if (vect_a2[i]*4 > x) + break; + vect_a2[i] = x*x; + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_36.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_36.c new file mode 100644 index 0000000000..a83994035b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_36.c @@ -0,0 +1,29 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a2[N]; +unsigned vect_a1[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a1[i]*2 > x) + break; + vect_a1[i] = x; + if (vect_a2[i]*4 > x) + return i; + vect_a2[i] = x*x; + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_37.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_37.c new file mode 100644 index 0000000000..b7559a9adc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_37.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 4 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i]*2 != x) + break; + vect_a[i] = x; + + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_38.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_38.c new file mode 100644 index 0000000000..8062fbbf64 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_38.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i+=2) + { + vect_b[i] = x + i; + if (vect_a[i]*2 > x) + break; + vect_a[i] = x; + + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_39.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_39.c new file mode 100644 index 0000000000..9d3c6a5dff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_39.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x, unsigned n) +{ + unsigned ret = 0; + for (int i = 0; i < N; i+= (N % 4)) + { + vect_b[i] = x + i; + if (vect_a[i]*2 > x) + break; + vect_a[i] = x; + + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_4.c new file mode 100644 index 0000000000..bd7107c173 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_4.c @@ -0,0 +1,24 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ + +#define N 1024 +unsigned vect[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + if (i > 16 && vect[i] > x) + break; + + vect[i] = x; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_40.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_40.c new file mode 100644 index 0000000000..428f6249fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_40.c @@ -0,0 +1,27 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i*=3) + { + vect_b[i] = x + i; + if (vect_a[i]*2 > x) + break; + vect_a[i] = x; + + } + return ret; +} + +/* SCEV can't currently analyze this loop bounds. */ +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { xfail *-*-* } } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_41.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_41.c new file mode 100644 index 0000000000..31a8ed2d3e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_41.c @@ -0,0 +1,25 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; +#pragma GCC novector +#pragma GCC unroll 4 + for (int i = 0; i < N; i++) + { + vect_b[i] += vect_a[i] + x; + } + return ret; +} + +/* novector should have blocked vectorization. */ +/* { dg-final { scan-tree-dump-not "vectorized \d loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_42.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_42.c new file mode 100644 index 0000000000..f1ee2f7e9a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_42.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 800 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i]*2 > x) + break; + vect_a[i] = x; + + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_43.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_43.c new file mode 100644 index 0000000000..7e9f635a0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_43.c @@ -0,0 +1,30 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 802 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i+=2) + { + vect_b[i] = x + i; + vect_b[i+1] = x + i + 1; + if (vect_a[i]*2 > x) + break; + if (vect_a[i+1]*2 > x) + break; + vect_a[i] = x; + vect_a[i+1] = x; + + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_44.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_44.c new file mode 100644 index 0000000000..7e9f635a0b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_44.c @@ -0,0 +1,30 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 802 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i+=2) + { + vect_b[i] = x + i; + vect_b[i+1] = x + i + 1; + if (vect_a[i]*2 > x) + break; + if (vect_a[i+1]*2 > x) + break; + vect_a[i] = x; + vect_a[i+1] = x; + + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_45.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_45.c new file mode 100644 index 0000000000..7031f237ec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_45.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i]*2 > x) + break; + vect_a[i] = x; + + } + return ret; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_46.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_46.c new file mode 100644 index 0000000000..c9aad909ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_46.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_float } */ + +#include + +#define N 1024 +complex double vect_a[N]; +complex double vect_b[N]; + +complex double test4(complex double x) +{ + complex double ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] += x + i; + if (vect_a[i] == x) + return i; + vect_a[i] += x * vect_b[i]; + + } + return ret; +} + +/* At -O2 we can't currently vectorize this because of the libcalls not being + lowered. */ +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { xfail *-*-* } } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_47.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_47.c new file mode 100644 index 0000000000..ef90380ea1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_47.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_float } */ + +void abort (); + +float results1[16] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,0.00}; +float results2[16] = {0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00}; +float a[16] = {0}; +float e[16] = {0}; +float b[16] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int main1 () +{ + int i; + for (i=0; i<16; i++) + { + if (a[i] != results1[i] || e[i] != results2[i]) + abort(); + } + + if (a[i+3] != b[i-1]) + abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_48.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_48.c new file mode 100644 index 0000000000..0efbb2836b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_48.c @@ -0,0 +1,14 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +int main (void) +{ + signed char a[50], b[50], c[50]; + for (int i = 0; i < 50; ++i) + if (a[i] != ((((signed int) -1 < 0 ? -126 : 4) + ((signed int) -1 < 0 ? -101 : 26) + i * 9 + 0) >> 1)) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_49.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_49.c new file mode 100644 index 0000000000..6c4ee40fd5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_49.c @@ -0,0 +1,25 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +void abort(); +struct foostr { + _Complex short f1; + _Complex short f2; +}; +struct foostr a[16] __attribute__ ((__aligned__(16))) = {}; +struct foostr c[16] __attribute__ ((__aligned__(16))); +struct foostr res[16] = {}; +void +foo (void) +{ + int i; + for (i = 0; i < 16; i++) + { + if (c[i].f1 != res[i].f1) + abort (); + if (c[i].f2 != res[i].f2) + abort (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_5.c new file mode 100644 index 0000000000..1468c795b6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_5.c @@ -0,0 +1,25 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#define N 1024 +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + return vect_a[i]; + vect_a[i] = x; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_50.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_50.c new file mode 100644 index 0000000000..b3cf2d7f05 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_50.c @@ -0,0 +1,18 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_float } */ + +extern void abort(); +float a[1024], b[1024], c[1024], d[1024]; +_Bool k[1024]; + +int main () +{ + int i; + for (i = 0; i < 1024; i++) + if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0)) + abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_51.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_51.c new file mode 100644 index 0000000000..c06eff5a38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_51.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +int x_in[32]; +int x_out_a[32], x_out_b[32]; +int c[16] = {3,2,1,10,1,42,3,4,50,9,32,8,11,10,1,2}; +int a[16 +1] = {0,16,32,48,64,128,256,512,0,16,32,48,64,128,256,512,1024}; +int b[16 +1] = {17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; + +void foo () +{ + int j, i, x; + int curr_a, flag, next_a, curr_b, next_b; + { + for (i = 0; i < 16; i++) + { + next_b = b[i+1]; + curr_b = flag ? next_b : curr_b; + } + x_out_b[j] = curr_b; + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ \ No newline at end of file diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_52.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_52.c new file mode 100644 index 0000000000..86a632f2a8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_52.c @@ -0,0 +1,21 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +void abort(); +int main1 (short X) +{ + unsigned char a[128]; + unsigned short b[128]; + unsigned int c[128]; + short myX = X; + int i; + for (i = 0; i < 128; i++) + { + if (a[i] != (unsigned char)myX || b[i] != myX || c[i] != (unsigned int)myX++) + abort (); + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_53.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_53.c new file mode 100644 index 0000000000..a02d5986ba --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_53.c @@ -0,0 +1,18 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +void abort (); +int a[64], b[64]; +int main () +{ + int c = 7; + for (int i = 1; i < 64; ++i) + if (b[i] != a[i] - a[i-1]) + abort (); + if (b[0] != -7) + abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_54.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_54.c new file mode 100644 index 0000000000..bfc78c2627 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_54.c @@ -0,0 +1,30 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + unsigned tmp[N]; + for (int i = 0; i < N; i++) + { + tmp[i] = x + i; + vect_b[i] = tmp[i]; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_55.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_55.c new file mode 100644 index 0000000000..c2a823bff7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_55.c @@ -0,0 +1,29 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + volatile unsigned tmp = x + i; + vect_b[i] = tmp; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_56.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_56.c new file mode 100644 index 0000000000..9096f66647 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_56.c @@ -0,0 +1,102 @@ +/* { dg-add-options vect_early_break } */ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-require-effective-target vect_early_break_hw } */ + +#include +#include "tree-vect.h" + +#define N 32 + +unsigned short sa[N]; +unsigned short sc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +unsigned short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +unsigned int ia[N]; +unsigned int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +unsigned int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Current peeling-for-alignment scheme will consider the 'sa[i+7]' + access for peeling, and therefore will examine the option of + using a peeling factor = VF-7%VF. This will result in a peeling factor 1, + which will also align the access to 'ia[i+3]', and the loop could be + vectorized on all targets that support unaligned loads. + Without cost model on targets that support misaligned stores, no peeling + will be applied since we want to keep the four loads aligned. */ + +__attribute__ ((noinline)) +int main1 () +{ + int i; + int n = N - 7; + + /* Multiple types with different sizes, used in independent + copmutations. Vectorizable. */ + for (i = 0; i < n; i++) + { + sa[i+7] = sb[i] + sc[i]; + ia[i+3] = ib[i] + ic[i]; + } + + /* check results: */ + for (i = 0; i < n; i++) + { + if (sa[i+7] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i]) + abort (); + } + + return 0; +} + +/* Current peeling-for-alignment scheme will consider the 'ia[i+3]' + access for peeling, and therefore will examine the option of + using a peeling factor = VF-3%VF. This will result in a peeling factor + 1 if VF=4,2. This will not align the access to 'sa[i+3]', for which we + need to peel 5,1 iterations for VF=4,2 respectively, so the loop can not + be vectorized. However, 'ia[i+3]' also gets aligned if we peel 5 + iterations, so the loop is vectorizable on all targets that support + unaligned loads. + Without cost model on targets that support misaligned stores, no peeling + will be applied since we want to keep the four loads aligned. */ + +__attribute__ ((noinline)) +int main2 () +{ + int i; + int n = N-3; + + /* Multiple types with different sizes, used in independent + copmutations. Vectorizable. */ + for (i = 0; i < n; i++) + { + ia[i+3] = ib[i] + ic[i]; + sa[i+3] = sb[i] + sc[i]; + } + + /* check results: */ + for (i = 0; i < n; i++) + { + if (sa[i+3] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + main2 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" { xfail { vect_early_break && { ! vect_hw_misalign } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_57.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_57.c new file mode 100644 index 0000000000..319bd125c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_57.c @@ -0,0 +1,32 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ +/* { dg-final { scan-tree-dump "epilog loop required" "vect" } } */ + +void abort (); + +unsigned short sa[32]; +unsigned short sc[32] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +unsigned short sb[32] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +unsigned int ia[32]; +unsigned int ic[32] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +unsigned int ib[32] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +int main2 (int n) +{ + int i; + for (i = 0; i < n; i++) + { + if (sa[i+3] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i]) + abort (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_58.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_58.c new file mode 100644 index 0000000000..5f18f06d42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_58.c @@ -0,0 +1,19 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_float } */ + +extern void abort(); +float a[1024], b[1024], c[1024], d[1024]; +_Bool k[1024]; + +int main () +{ + int i; + for (i = 0; i < 1024; i++) + if (k[i] != ((i % 3) == 0)) + abort (); +} + +/* Pattern didn't match inside gcond. */ +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_59.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_59.c new file mode 100644 index 0000000000..aec4ee457d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_59.c @@ -0,0 +1,18 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_float } */ + +extern void abort(); +float a[1024], b[1024], c[1024], d[1024]; +_Bool k[1024]; + +int main () +{ + int i; + for (i = 0; i < 1024; i++) + if (k[i] != (i == 0)) + abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_6.c new file mode 100644 index 0000000000..7b870e9c60 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_6.c @@ -0,0 +1,27 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#define N 1024 +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < (N/2); i+=2) + { + vect_b[i] = x + i; + vect_b[i+1] = x + i+1; + if (vect_a[i] > x || vect_a[i+1] > x) + break; + vect_a[i] += x * vect_b[i]; + vect_a[i+1] += x * vect_b[i+1]; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_60.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_60.c new file mode 100644 index 0000000000..75b35f8d42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_60.c @@ -0,0 +1,18 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_float } */ + +extern void abort(); +float a[1024], b[1024], c[1024], d[1024]; +_Bool k[1024]; + +int main () +{ + char i; + for (i = 0; i < 1024; i++) + if (k[i] != (i == 0)) + abort (); +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_61.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_61.c new file mode 100644 index 0000000000..c789ec01f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_61.c @@ -0,0 +1,18 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_float } */ + +typedef float real_t; +__attribute__((aligned(64))) real_t a[32000], b[32000], c[32000]; +real_t s482() +{ + for (int nl = 0; nl < 10000; nl++) { + for (int i = 0; i < 32000; i++) { + a[i] += b[i] * c[i]; + if (c[i] > b[i]) break; + } + } +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_62.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_62.c new file mode 100644 index 0000000000..aaad62ef8d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_62.c @@ -0,0 +1,21 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +int a, b; +int e() { + int d, c; + d = 0; + for (; d < b; d++) + a = 0; + d = 0; + for (; d < b; d++) + if (d) + c++; + for (;;) + if (c) + break; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_63.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_63.c new file mode 100644 index 0000000000..1d9ff4ad6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_63.c @@ -0,0 +1,29 @@ +/* { dg-add-options vect_early_break } */ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-do compile } */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_long } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-additional-options "-fno-tree-scev-cprop" } */ + +/* Statement used outside the loop. + NOTE: SCEV disabled to ensure the live operation is not removed before + vectorization. */ +__attribute__ ((noinline)) int +liveloop (int start, int n, int *x, int *y) +{ + int i = start; + int j; + int ret; + + for (j = 0; j < n; ++j) + { + i += 1; + x[j] = i; + ret = y[j]; + } + return ret; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vec_stmt_relevant_p: stmt live but not relevant" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_64.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_64.c new file mode 100644 index 0000000000..aaa2a46fb6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_64.c @@ -0,0 +1,18 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-vect-all" } */ + +int d(unsigned); + +void a() { + char b[8]; + unsigned c = 0; + while (c < 7 && b[c]) + ++c; + if (d(c)) + return; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_partial_vectors } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_65.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_65.c new file mode 100644 index 0000000000..23a8341b52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_65.c @@ -0,0 +1,20 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-options "-Ofast -fno-vect-cost-model -fdump-tree-vect-details" } */ + +enum a { b }; + +struct { + enum a c; +} d[10], *e; + +void f() { + int g; + for (g = 0, e = d; g < sizeof(1); g++, e++) + if (e->c) + return; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_66.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_66.c new file mode 100644 index 0000000000..e54cc5e126 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_66.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +int a[0]; +int b; + +void g(); + +void f() { + int d, e; + for (; e; e++) { + int c; + switch (b) + case '9': { + for (; d < 1; d++) + if (a[d]) + c = 1; + break; + case '<': + g(); + c = 0; + } + while (c) + ; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_67.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_67.c new file mode 100644 index 0000000000..e9da46439f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_67.c @@ -0,0 +1,42 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + + + +int main() +{ + int var6 = -1267827473; + do { + ++var6; + double s1_115[4], s2_108[4]; + int var8 = -161498264; + do { + ++var8; + int var12 = 1260960076; + for (; var12 <= 1260960080; ++var12) { + int var13 = 1960990937; + do { + ++var13; + int var14 = 2128638723; + for (; var14 <= 2128638728; ++var14) { + int var22 = -1141190839; + do { + ++var22; + if (s2_108 > s1_115) { + int var23 = -890798748; + do { + long long e_119[4]; + } while (var23 <= -890798746); + } + } while (var22 <= -1141190829); + } + } while (var13 <= 1960990946); + } + } while (var8 <= -161498254); + } while (var6 <= -1267827462); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_68.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_68.c new file mode 100644 index 0000000000..dfa90b557e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_68.c @@ -0,0 +1,42 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 800 +#endif +unsigned vect_a1[N]; +unsigned vect_b1[N]; +unsigned vect_c1[N]; +unsigned vect_d1[N]; + +unsigned vect_a2[N]; +unsigned vect_b2[N]; +unsigned vect_c2[N]; +unsigned vect_d2[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_b1[i] += x + i; + vect_c1[i] += x + i; + vect_d1[i] += x + i; + if (vect_a1[i]*2 != x) + break; + vect_a1[i] = x; + + vect_b2[i] += x + i; + vect_c2[i] += x + i; + vect_d2[i] += x + i; + if (vect_a2[i]*2 != x) + break; + vect_a2[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_69.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_69.c new file mode 100644 index 0000000000..916351a14a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_69.c @@ -0,0 +1,80 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include + +#include "tree-vect.h" + +# define BITSIZEOF_INT 32 +# define BITSIZEOF_LONG 64 +# define BITSIZEOF_LONG_LONG 64 + +#define MAKE_FUNS(suffix, type) \ +int my_ffs##suffix(type x) { \ + int i; \ + if (x == 0) \ + return 0; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + break; \ + return i + 1; \ +} \ + \ +int my_clz##suffix(type x) { \ + int i; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1))) \ + break; \ + return i; \ +} + + +MAKE_FUNS (, unsigned); + +extern void abort (void); +extern void exit (int); + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x00000001UL, \ + 0x80000000UL, \ + 0x00000002UL, \ + 0x40000000UL, \ + 0x00010000UL, \ + 0x00008000UL, \ + 0xa5a5a5a5UL, \ + 0x5a5a5a5aUL, \ + 0xcafe0000UL, \ + 0x00cafe00UL, \ + 0x0000cafeUL, \ + 0xffffffffUL \ + } + + +unsigned int ints[] = NUMS32; + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N(ints); i++) + { + if (__builtin_ffs (ints[i]) != my_ffs (ints[i])) + abort (); + if (ints[i] != 0 + && __builtin_clz (ints[i]) != my_clz (ints[i])) + abort (); + } + + exit (0); +} + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_7.c new file mode 100644 index 0000000000..8c86c5034d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_7.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include + +#define N 1024 +complex double vect_a[N]; +complex double vect_b[N]; + +complex double test4(complex double x) +{ + complex double ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] += x + i; + if (vect_a[i] == x) + break; + vect_a[i] += x * vect_b[i]; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_70.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_70.c new file mode 100644 index 0000000000..3dbedf6104 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_70.c @@ -0,0 +1,69 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include +#include + +#include "tree-vect.h" + +# define BITSIZEOF_INT 32 +# define BITSIZEOF_LONG 64 +# define BITSIZEOF_LONG_LONG 64 + +#define MAKE_FUNS(suffix, type) \ +__attribute__((noinline)) \ +int my_clz##suffix(type x) { \ + int i; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1))) \ + break; \ + return i; \ +} + + +MAKE_FUNS (, unsigned); + +extern void abort (void); +extern void exit (int); + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x00000001UL, \ + 0x80000000UL, \ + 0x00000002UL, \ + 0x40000000UL, \ + 0x00010000UL, \ + 0x00008000UL, \ + 0xa5a5a5a5UL, \ + 0x5a5a5a5aUL, \ + 0xcafe0000UL, \ + 0x00cafe00UL, \ + 0x0000cafeUL, \ + 0xffffffffUL \ + } + + +unsigned int ints[] = NUMS32; + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + for (i = 0; i < N(ints); i++) + { + if (ints[i] != 0 + && __builtin_clz (ints[i]) != my_clz (ints[i])) + abort (); + } + + exit (0); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_71.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_71.c new file mode 100644 index 0000000000..b15c8de3ed --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_71.c @@ -0,0 +1,71 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include +#include + +#include "tree-vect.h" + +# define BITSIZEOF_INT 32 +# define BITSIZEOF_LONG 64 +# define BITSIZEOF_LONG_LONG 64 + +#define MAKE_FUNS(suffix, type) \ +__attribute__((noinline)) \ +int my_ffs##suffix(type x) { \ + int i; \ + if (x == 0) \ + return 0; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + break; \ + return i + 1; \ +} + +MAKE_FUNS (, unsigned); + +extern void abort (void); +extern void exit (int); + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x00000001UL, \ + 0x80000000UL, \ + 0x00000002UL, \ + 0x40000000UL, \ + 0x00010000UL, \ + 0x00008000UL, \ + 0xa5a5a5a5UL, \ + 0x5a5a5a5aUL, \ + 0xcafe0000UL, \ + 0x00cafe00UL, \ + 0x0000cafeUL, \ + 0xffffffffUL \ + } + + +unsigned int ints[] = NUMS32; + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + check_vect (); + +#pragma GCC novector + for (i = 0; i < N(ints); i++) + { + if (__builtin_ffs (ints[i]) != my_ffs (ints[i])) + abort (); + } + + exit (0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_72.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_72.c new file mode 100644 index 0000000000..c6d1e9f5fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_72.c @@ -0,0 +1,151 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include +#include + +#include "tree-vect.h" + +#if __INT_MAX__ > 2147483647L +# if __INT_MAX__ >= 9223372036854775807L +# define BITSIZEOF_INT 64 +# else +# define BITSIZEOF_INT 32 +# endif +#else +# if __INT_MAX__ >= 2147483647L +# define BITSIZEOF_INT 32 +# else +# define BITSIZEOF_INT 16 +# endif +#endif + +#if __LONG_MAX__ > 2147483647L +# if __LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG 64 +# else +# define BITSIZEOF_LONG 32 +# endif +#else +# define BITSIZEOF_LONG 32 +#endif + +#if __LONG_LONG_MAX__ > 2147483647L +# if __LONG_LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG_LONG 64 +# else +# define BITSIZEOF_LONG_LONG 32 +# endif +#else +# define BITSIZEOF_LONG_LONG 32 +#endif + +#define MAKE_FUNS(suffix, type) \ +__attribute__((noinline)) \ +int my_ctz##suffix(type x) { \ + int i; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + break; \ + return i; \ +} + +MAKE_FUNS (, unsigned); + +extern void abort (void); +extern void exit (int); + +#define NUMS16 \ + { \ + 0x0000U, \ + 0x0001U, \ + 0x8000U, \ + 0x0002U, \ + 0x4000U, \ + 0x0100U, \ + 0x0080U, \ + 0xa5a5U, \ + 0x5a5aU, \ + 0xcafeU, \ + 0xffffU \ + } + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x00000001UL, \ + 0x80000000UL, \ + 0x00000002UL, \ + 0x40000000UL, \ + 0x00010000UL, \ + 0x00008000UL, \ + 0xa5a5a5a5UL, \ + 0x5a5a5a5aUL, \ + 0xcafe0000UL, \ + 0x00cafe00UL, \ + 0x0000cafeUL, \ + 0xffffffffUL \ + } + +#define NUMS64 \ + { \ + 0x0000000000000000ULL, \ + 0x0000000000000001ULL, \ + 0x8000000000000000ULL, \ + 0x0000000000000002ULL, \ + 0x4000000000000000ULL, \ + 0x0000000100000000ULL, \ + 0x0000000080000000ULL, \ + 0xa5a5a5a5a5a5a5a5ULL, \ + 0x5a5a5a5a5a5a5a5aULL, \ + 0xcafecafe00000000ULL, \ + 0x0000cafecafe0000ULL, \ + 0x00000000cafecafeULL, \ + 0xffffffffffffffffULL \ + } + +unsigned int ints[] = +#if BITSIZEOF_INT == 64 +NUMS64; +#elif BITSIZEOF_INT == 32 +NUMS32; +#else +NUMS16; +#endif + +unsigned long longs[] = +#if BITSIZEOF_LONG == 64 +NUMS64; +#else +NUMS32; +#endif + +unsigned long long longlongs[] = +#if BITSIZEOF_LONG_LONG == 64 +NUMS64; +#else +NUMS32; +#endif + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + check_vect (); + +#pragma GCC novector + for (i = 0; i < N(ints); i++) + { + if (ints[i] != 0 + && __builtin_ctz (ints[i]) != my_ctz (ints[i])) + abort (); + } + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_73.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_73.c new file mode 100644 index 0000000000..7f40dd07e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_73.c @@ -0,0 +1,71 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include +#include + +#include "tree-vect.h" + +# define BITSIZEOF_INT 32 +# define BITSIZEOF_LONG 64 +# define BITSIZEOF_LONG_LONG 64 + +#define MAKE_FUNS(suffix, type) \ +__attribute__((noinline)) \ +int my_clz##suffix(type x) { \ + int i; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1))) \ + break; \ + return i; \ +} + + +MAKE_FUNS (, unsigned); + +extern void abort (void); +extern void exit (int); + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x00000001UL, \ + 0x80000000UL, \ + 0x00000002UL, \ + 0x40000000UL, \ + 0x00010000UL, \ + 0x00008000UL, \ + 0xa5a5a5a5UL, \ + 0x5a5a5a5aUL, \ + 0xcafe0000UL, \ + 0x00cafe00UL, \ + 0x0000cafeUL, \ + 0xffffffffUL \ + } + + +unsigned int ints[] = NUMS32; + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + check_vect (); + +#pragma GCC novector + for (i = 0; i < N(ints); i++) + { + if (ints[i] != 0 + && __builtin_clz (ints[i]) != my_clz (ints[i])) + abort (); + } + + exit (0); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_74.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_74.c new file mode 100644 index 0000000000..afd238618b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_74.c @@ -0,0 +1,165 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include +#include + +#include "tree-vect.h" + +#if __INT_MAX__ > 2147483647L +# if __INT_MAX__ >= 9223372036854775807L +# define BITSIZEOF_INT 64 +# else +# define BITSIZEOF_INT 32 +# endif +#else +# if __INT_MAX__ >= 2147483647L +# define BITSIZEOF_INT 32 +# else +# define BITSIZEOF_INT 16 +# endif +#endif + +#if __LONG_MAX__ > 2147483647L +# if __LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG 64 +# else +# define BITSIZEOF_LONG 32 +# endif +#else +# define BITSIZEOF_LONG 32 +#endif + +#if __LONG_LONG_MAX__ > 2147483647L +# if __LONG_LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG_LONG 64 +# else +# define BITSIZEOF_LONG_LONG 32 +# endif +#else +# define BITSIZEOF_LONG_LONG 32 +#endif + +#define MAKE_FUNS(suffix, type) \ +int my_clrsb##suffix(type x) { \ + int i; \ + int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1; \ + for (i = 1; i < CHAR_BIT * sizeof (type); i++) \ + if (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1) \ + != leading) \ + break; \ + return i - 1; \ +} + +MAKE_FUNS (, unsigned); + +extern void abort (void); +extern void exit (int); + +#define NUMS16 \ + { \ + 0x0000U, \ + 0x0001U, \ + 0x8000U, \ + 0x0002U, \ + 0x4000U, \ + 0x0100U, \ + 0x0080U, \ + 0xa5a5U, \ + 0x5a5aU, \ + 0xcafeU, \ + 0xffffU \ + } + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x00000001UL, \ + 0x80000000UL, \ + 0x00000002UL, \ + 0x40000000UL, \ + 0x00010000UL, \ + 0x00008000UL, \ + 0xa5a5a5a5UL, \ + 0x5a5a5a5aUL, \ + 0xcafe0000UL, \ + 0x00cafe00UL, \ + 0x0000cafeUL, \ + 0xffffffffUL \ + } + +#define NUMS64 \ + { \ + 0x0000000000000000ULL, \ + 0x0000000000000001ULL, \ + 0x8000000000000000ULL, \ + 0x0000000000000002ULL, \ + 0x4000000000000000ULL, \ + 0x0000000100000000ULL, \ + 0x0000000080000000ULL, \ + 0xa5a5a5a5a5a5a5a5ULL, \ + 0x5a5a5a5a5a5a5a5aULL, \ + 0xcafecafe00000000ULL, \ + 0x0000cafecafe0000ULL, \ + 0x00000000cafecafeULL, \ + 0xffffffffffffffffULL \ + } + +unsigned int ints[] = +#if BITSIZEOF_INT == 64 +NUMS64; +#elif BITSIZEOF_INT == 32 +NUMS32; +#else +NUMS16; +#endif + +unsigned long longs[] = +#if BITSIZEOF_LONG == 64 +NUMS64; +#else +NUMS32; +#endif + +unsigned long long longlongs[] = +#if BITSIZEOF_LONG_LONG == 64 +NUMS64; +#else +NUMS32; +#endif + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + check_vect (); + + /* Test constant folding. */ + +#define TEST(x, suffix) \ + if (__builtin_clrsb##suffix (x) != my_clrsb##suffix (x)) \ + abort (); + +#if BITSIZEOF_INT == 32 + TEST(0x00000000UL,); + TEST(0x00000001UL,); + TEST(0x80000000UL,); + TEST(0x40000000UL,); + TEST(0x00010000UL,); + TEST(0x00008000UL,); + TEST(0xa5a5a5a5UL,); + TEST(0x5a5a5a5aUL,); + TEST(0xcafe0000UL,); + TEST(0x00cafe00UL,); + TEST(0x0000cafeUL,); + TEST(0xffffffffUL,); +#endif + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_75.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_75.c new file mode 100644 index 0000000000..ed27f86357 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_75.c @@ -0,0 +1,234 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-O3" } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include +#include + +#include "tree-vect.h" + +#if __INT_MAX__ > 2147483647L +# if __INT_MAX__ >= 9223372036854775807L +# define BITSIZEOF_INT 64 +# else +# define BITSIZEOF_INT 32 +# endif +#else +# if __INT_MAX__ >= 2147483647L +# define BITSIZEOF_INT 32 +# else +# define BITSIZEOF_INT 16 +# endif +#endif + +#if __LONG_MAX__ > 2147483647L +# if __LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG 64 +# else +# define BITSIZEOF_LONG 32 +# endif +#else +# define BITSIZEOF_LONG 32 +#endif + +#if __LONG_LONG_MAX__ > 2147483647L +# if __LONG_LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG_LONG 64 +# else +# define BITSIZEOF_LONG_LONG 32 +# endif +#else +# define BITSIZEOF_LONG_LONG 32 +#endif + +#define MAKE_FUNS(suffix, type) \ +__attribute__((noinline)) \ +int my_ffs##suffix(type x) { \ + int i; \ + if (x == 0) \ + return 0; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + break; \ + return i + 1; \ +} \ + \ +int my_ctz##suffix(type x) { \ + int i; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + break; \ + return i; \ +} \ + \ +__attribute__((noinline)) \ +int my_clz##suffix(type x) { \ + int i; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1))) \ + break; \ + return i; \ +} \ + \ +int my_clrsb##suffix(type x) { \ + int i; \ + int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1; \ + for (i = 1; i < CHAR_BIT * sizeof (type); i++) \ + if (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1) \ + != leading) \ + break; \ + return i - 1; \ +} \ + \ +__attribute__((noinline)) \ +int my_popcount##suffix(type x) { \ + int i; \ + int count = 0; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + count++; \ + return count; \ +} \ + \ +__attribute__((noinline)) \ +int my_parity##suffix(type x) { \ + int i; \ + int count = 0; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + count++; \ + return count & 1; \ +} + +MAKE_FUNS (ll, unsigned long long); + +extern void abort (void); +extern void exit (int); + +#define NUMS16 \ + { \ + 0x0000U, \ + 0x0001U, \ + 0x8000U, \ + 0x0002U, \ + 0x4000U, \ + 0x0100U, \ + 0x0080U, \ + 0xa5a5U, \ + 0x5a5aU, \ + 0xcafeU, \ + 0xffffU \ + } + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x00000001UL, \ + 0x80000000UL, \ + 0x00000002UL, \ + 0x40000000UL, \ + 0x00010000UL, \ + 0x00008000UL, \ + 0xa5a5a5a5UL, \ + 0x5a5a5a5aUL, \ + 0xcafe0000UL, \ + 0x00cafe00UL, \ + 0x0000cafeUL, \ + 0xffffffffUL \ + } + +#define NUMS64 \ + { \ + 0x0000000000000000ULL, \ + 0x0000000000000001ULL, \ + 0x8000000000000000ULL, \ + 0x0000000000000002ULL, \ + 0x4000000000000000ULL, \ + 0x0000000100000000ULL, \ + 0x0000000080000000ULL, \ + 0xa5a5a5a5a5a5a5a5ULL, \ + 0x5a5a5a5a5a5a5a5aULL, \ + 0xcafecafe00000000ULL, \ + 0x0000cafecafe0000ULL, \ + 0x00000000cafecafeULL, \ + 0xffffffffffffffffULL \ + } + +unsigned int ints[] = +#if BITSIZEOF_INT == 64 +NUMS64; +#elif BITSIZEOF_INT == 32 +NUMS32; +#else +NUMS16; +#endif + +unsigned long longs[] = +#if BITSIZEOF_LONG == 64 +NUMS64; +#else +NUMS32; +#endif + +unsigned long long longlongs[] = +#if BITSIZEOF_LONG_LONG == 64 +NUMS64; +#else +NUMS32; +#endif + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + check_vect (); + +#pragma GCC novector + for (i = 0; i < N(longlongs); i++) + { + if (__builtin_ffsll (longlongs[i]) != my_ffsll (longlongs[i])) + abort (); + if (longlongs[i] != 0 + && __builtin_clzll (longlongs[i]) != my_clzll (longlongs[i])) + abort (); + if (longlongs[i] != 0 + && __builtin_ctzll (longlongs[i]) != my_ctzll (longlongs[i])) + abort (); + if (__builtin_clrsbll (longlongs[i]) != my_clrsbll (longlongs[i])) + abort (); + if (__builtin_popcountll (longlongs[i]) != my_popcountll (longlongs[i])) + abort (); + if (__builtin_parityll (longlongs[i]) != my_parityll (longlongs[i])) + abort (); + } + + /* Test constant folding. */ + +#define TEST(x, suffix) \ + if (__builtin_ffs##suffix (x) != my_ffs##suffix (x)) \ + abort (); \ + +#if BITSIZEOF_LONG_LONG == 64 + TEST(0x0000000000000000ULL, ll); + TEST(0x0000000000000001ULL, ll); + TEST(0x8000000000000000ULL, ll); + TEST(0x0000000000000002ULL, ll); + TEST(0x4000000000000000ULL, ll); + TEST(0x0000000100000000ULL, ll); + TEST(0x0000000080000000ULL, ll); + TEST(0xa5a5a5a5a5a5a5a5ULL, ll); + TEST(0x5a5a5a5a5a5a5a5aULL, ll); + TEST(0xcafecafe00000000ULL, ll); + TEST(0x0000cafecafe0000ULL, ll); + TEST(0x00000000cafecafeULL, ll); + TEST(0xffffffffffffffffULL, ll); +#endif + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_76.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_76.c new file mode 100644 index 0000000000..a7d8e279c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_76.c @@ -0,0 +1,169 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-O3" } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include +#include + +#include "tree-vect.h" + +#if __INT_MAX__ > 2147483647L +# if __INT_MAX__ >= 9223372036854775807L +# define BITSIZEOF_INT 64 +# else +# define BITSIZEOF_INT 32 +# endif +#else +# if __INT_MAX__ >= 2147483647L +# define BITSIZEOF_INT 32 +# else +# define BITSIZEOF_INT 16 +# endif +#endif + +#if __LONG_MAX__ > 2147483647L +# if __LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG 64 +# else +# define BITSIZEOF_LONG 32 +# endif +#else +# define BITSIZEOF_LONG 32 +#endif + +#if __LONG_LONG_MAX__ > 2147483647L +# if __LONG_LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG_LONG 64 +# else +# define BITSIZEOF_LONG_LONG 32 +# endif +#else +# define BITSIZEOF_LONG_LONG 32 +#endif + +#define MAKE_FUNS(suffix, type) \ +int my_clrsb##suffix(type x) { \ + int i; \ + int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1; \ + for (i = 1; i < CHAR_BIT * sizeof (type); i++) \ + if (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1) \ + != leading) \ + break; \ + return i - 1; \ +} \ + \ + +MAKE_FUNS (, unsigned); +MAKE_FUNS (ll, unsigned long long); + +extern void abort (void); +extern void exit (int); + +#define NUMS16 \ + { \ + 0x0000U, \ + 0x0001U, \ + 0x8000U, \ + 0x0002U, \ + 0x4000U, \ + 0x0100U, \ + 0x0080U, \ + 0xa5a5U, \ + 0x5a5aU, \ + 0xcafeU, \ + 0xffffU \ + } + +#define NUMS32 \ + { \ + 0x00000000UL, \ + 0x00000001UL, \ + 0x80000000UL, \ + 0x00000002UL, \ + 0x40000000UL, \ + 0x00010000UL, \ + 0x00008000UL, \ + 0xa5a5a5a5UL, \ + 0x5a5a5a5aUL, \ + 0xcafe0000UL, \ + 0x00cafe00UL, \ + 0x0000cafeUL, \ + 0xffffffffUL \ + } + +#define NUMS64 \ + { \ + 0x0000000000000000ULL, \ + 0x0000000000000001ULL, \ + 0x8000000000000000ULL, \ + 0x0000000000000002ULL, \ + 0x4000000000000000ULL, \ + 0x0000000100000000ULL, \ + 0x0000000080000000ULL, \ + 0xa5a5a5a5a5a5a5a5ULL, \ + 0x5a5a5a5a5a5a5a5aULL, \ + 0xcafecafe00000000ULL, \ + 0x0000cafecafe0000ULL, \ + 0x00000000cafecafeULL, \ + 0xffffffffffffffffULL \ + } + +unsigned int ints[] = +#if BITSIZEOF_INT == 64 +NUMS64; +#elif BITSIZEOF_INT == 32 +NUMS32; +#else +NUMS16; +#endif + +unsigned long longs[] = +#if BITSIZEOF_LONG == 64 +NUMS64; +#else +NUMS32; +#endif + +unsigned long long longlongs[] = +#if BITSIZEOF_LONG_LONG == 64 +NUMS64; +#else +NUMS32; +#endif + +#define N(table) (sizeof (table) / sizeof (table[0])) + +int +main (void) +{ + int i; + + check_vect (); + +#pragma GCC novector + for (i = 0; i < N(ints); i++) + { + if (__builtin_clrsb (ints[i]) != my_clrsb (ints[i])) + abort (); + } + + /* Test constant folding. */ + +#define TEST(x, suffix) \ + if (__builtin_clrsb##suffix (x) != my_clrsb##suffix (x)) \ + abort (); + +#if BITSIZEOF_LONG_LONG == 64 + TEST(0xffffffffffffffffULL, ll); + TEST(0xffffffffffffffffULL, ll); + TEST(0xffffffffffffffffULL, ll); + TEST(0xffffffffffffffffULL, ll); + TEST(0xffffffffffffffffULL, ll); + TEST(0xffffffffffffffffULL, ll); +#endif + + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_77.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_77.c new file mode 100644 index 0000000000..225106aab0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_77.c @@ -0,0 +1,34 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-O3" } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +double x[1024]; +int a[1024]; +double __attribute__((noipa)) foo () +{ + double sum = 0.0; + for (int i = 0 ; i < 1023; ++i) + { + sum += x[i]; + if (a[i]) + break; + } + return sum; +} + +int main() +{ + check_vect (); + + for (int i = 0; i < 1024; ++i) + x[i] = i; + a[19] = 1; + if (foo () != 190.) + __builtin_abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_78.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_78.c new file mode 100644 index 0000000000..f93babc069 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_78.c @@ -0,0 +1,77 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-O3" } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include +#include + +#include "tree-vect.h" + +#if __INT_MAX__ > 2147483647L +# if __INT_MAX__ >= 9223372036854775807L +# define BITSIZEOF_INT 64 +# else +# define BITSIZEOF_INT 32 +# endif +#else +# if __INT_MAX__ >= 2147483647L +# define BITSIZEOF_INT 32 +# else +# define BITSIZEOF_INT 16 +# endif +#endif + +#if __LONG_MAX__ > 2147483647L +# if __LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG 64 +# else +# define BITSIZEOF_LONG 32 +# endif +#else +# define BITSIZEOF_LONG 32 +#endif + +#if __LONG_LONG_MAX__ > 2147483647L +# if __LONG_LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG_LONG 64 +# else +# define BITSIZEOF_LONG_LONG 32 +# endif +#else +# define BITSIZEOF_LONG_LONG 32 +#endif + +#define MAKE_FUNS(suffix, type) \ +int my_clrsb##suffix(type x) { \ + int i; \ + int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1; \ + for (i = 1; i < CHAR_BIT * sizeof (type); i++) \ + if (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1) \ + != leading) \ + break; \ + return i - 1; \ +} + +MAKE_FUNS (, unsigned); + +extern void abort (void); +extern void exit (int); + + +int +main (void) +{ + check_vect (); + +#define TEST(x, suffix) \ + if (__builtin_clrsb##suffix (x) != my_clrsb##suffix (x)) \ + abort (); + +#if BITSIZEOF_INT == 32 + TEST(0xffffffffUL,); +#endif + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_79.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_79.c new file mode 100644 index 0000000000..3f21be7625 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_79.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ + +#undef N +#define N 32 + +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < 1024; i++) + { + vect_b[i] = x + i; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_8.c new file mode 100644 index 0000000000..84e19423e2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_8.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ + +#include + +#define N 1024 +char vect_a[N]; +char vect_b[N]; + +char test4(char x, char * restrict res) +{ + char ret = 0; + for (int i = 0; i < N; i++) + { + vect_b[i] += x + i; + if (vect_a[i] > x) + break; + vect_a[i] += x * vect_b[i]; + res[i] *= vect_b[i]; + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_80.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_80.c new file mode 100644 index 0000000000..7f563b788a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_80.c @@ -0,0 +1,49 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +extern void abort (); + +int x; +__attribute__ ((noinline, noipa)) +void foo (int *a, int *b) +{ + int local_x = x; + for (int i = 0; i < 1024; ++i) + { + if (i + local_x == 13) + break; + a[i] = 2 * b[i]; + } +} + +int main () +{ + + check_vect (); + + int a[1024] = {0}; + int b[1024] = {0}; + + for (int i = 0; i < 1024; i++) + b[i] = i; + + x = -512; + foo (a, b); + + if (a[524] != 1048) + abort (); + + if (a[525] != 0) + abort (); + + if (a[1023] != 0) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_81.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_81.c new file mode 100644 index 0000000000..8a8c076ba9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_81.c @@ -0,0 +1,31 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ +/* { dg-final { scan-tree-dump "epilog loop required" "vect" } } */ +void abort (); + +unsigned short sa[32]; +unsigned short sc[32] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +unsigned short sb[32] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +unsigned int ia[32]; +unsigned int ic[32] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +unsigned int ib[32] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +int main2 (int n) +{ + int i; + for (i = 0; i < n - 3; i++) + { + if (sa[i+3] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i]) + abort (); + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_82.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_82.c new file mode 100644 index 0000000000..0e9b2d8d38 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_82.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include + +#define N 1024 +complex double vect_a[N]; +complex double vect_b[N]; + +complex double test4(complex double x, complex double t) +{ + complex double ret = 0; + for (int i = 0; i < N; i++) + { + vect_a[i] = t + i; + if (vect_a[i] == x) + return i; + vect_a[i] += x * vect_a[i]; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_83.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_83.c new file mode 100644 index 0000000000..8b0e3fd6c5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_83.c @@ -0,0 +1,29 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ + +#include + +#define N 1024 +complex double vect_a[N]; +complex double vect_b[N]; + +complex double test4(complex double x) +{ + complex double ret = 0; + for (int i = 0; i < N; i++) + { + volatile complex double z = vect_b[i]; + vect_b[i] = x + i + z; + if (vect_a[i] == x) + return i; + vect_a[i] += x * vect_b[i]; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_84.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_84.c new file mode 100644 index 0000000000..242ba45353 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_84.c @@ -0,0 +1,44 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include + +#include "tree-vect.h" + +#ifndef N +#define N 17 +#endif +bool vect_a[N] = { false, false, true, false, false, false, + false, false, false, false, false, false, + false, false, false, false, false }; +unsigned vect_b[N] = { 0 }; + +__attribute__ ((noinline, noipa)) +unsigned test4(bool x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + if (vect_a[i] == x) + return 1; + vect_a[i] = x; + + } + return ret; +} + +extern void abort (); + +int main () +{ + check_vect (); + + if (test4 (true) != 1) + abort (); + + if (vect_b[2] != 0 && vect_b[1] == 0) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_85.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_85.c new file mode 100644 index 0000000000..3df3769357 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_85.c @@ -0,0 +1,40 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 5 +#endif +int vect_a[N] = { 5, 4, 8, 4, 6 }; +unsigned vect_b[N] = { 0 }; + +__attribute__ ((noinline, noipa)) +unsigned test4(int x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + if (vect_a[i] > x) + return 1; + vect_a[i] = x; + + } + return ret; +} + +extern void abort (); + +int main () +{ + check_vect (); + + if (test4 (7) != 1) + abort (); + + if (vect_b[2] != 0 && vect_b[1] == 0) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_86.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_86.c new file mode 100644 index 0000000000..85c0d3a927 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_86.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-additional-options "-std=gnu89" } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include "tree-vect.h" + +extern void abort (); +extern void exit (int); + +__attribute__((noinline, noipa)) +int f(x) { + int i; + for (i = 0; i < 8 && (x & 1) == 1; i++) + x >>= 1; + return i; +} +main() { + check_vect (); + + if (f(4) != 0) + abort(); + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_87.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_87.c new file mode 100644 index 0000000000..3dce0c439b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_87.c @@ -0,0 +1,26 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-additional-options "-std=gnu89" } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */ + +#include "tree-vect.h" + +extern void abort (); +extern void exit (int); + +__attribute__((noinline, noipa)) +int f(x) { + int i; + for (i = 0; i < 8 && (x & 1) == 0; i++) + x >>= 1; + return i; +} +main() { + check_vect (); + + if (f(4) != 2) + abort(); + exit(0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_88.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_88.c new file mode 100644 index 0000000000..b392dd4655 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_88.c @@ -0,0 +1,41 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast --param vect-partial-vector-usage=2" } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 5 +#endif +float vect_a[N] = { 5.1f, 4.2f, 8.0f, 4.25f, 6.5f }; +unsigned vect_b[N] = { 0 }; + +__attribute__ ((noinline, noipa)) +unsigned test4(double x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} + +extern void abort (); + +int main () +{ + check_vect (); + + if (test4 (7.0) != 0) + abort (); + + if (vect_b[2] != 0 && vect_b[1] == 0) + abort (); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_89.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_89.c new file mode 100644 index 0000000000..39b6313b3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_89.c @@ -0,0 +1,21 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-w" } */ + +char *a; +extern void d(); +void b() { + int c = 0; + while (c < 16) { + switch (a[c]) { + case '"': + case '\'': + c++; + continue; + } + break; + } + if (c) + d(); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_9.c new file mode 100644 index 0000000000..12f09c61c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_9.c @@ -0,0 +1,28 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-additional-options "-Ofast" } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#ifndef N +#define N 803 +#endif +unsigned vect_a[N]; +unsigned vect_b[N]; + +unsigned test4(unsigned x) +{ + unsigned ret = 0; + for (int i = 0; i < N; i++) + { + vect_a[i] = x + i; + if (vect_a[i] > x) + break; + vect_a[i] = x; + + } + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_90.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_90.c new file mode 100644 index 0000000000..ac390b6ede --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_90.c @@ -0,0 +1,48 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 30 +#endif + +#ifndef IDX +#define IDX 1 +#endif + +int n_earlyclobbers; + +typedef void* rtx; +rtx reload_earlyclobbers[N] = {0}; + +rtx foo = (void*)0xbadf00d; + +int +__attribute__((noinline, noipa)) +earlyclobber_operand_p (rtx x) +{ + int i; + + for (i = 0; i < n_earlyclobbers; i++) + if (reload_earlyclobbers[i] == x) + return 1; + + return 0; +} + +extern void abort (); + +int main () +{ + check_vect (); + + n_earlyclobbers = IDX; + if (earlyclobber_operand_p (foo)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_91.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_91.c new file mode 100644 index 0000000000..4b1c558f8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_91.c @@ -0,0 +1,48 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 30 +#endif + +#ifndef IDX +#define IDX 0 +#endif + +int n_earlyclobbers; + +typedef void* rtx; +rtx reload_earlyclobbers[N] = {0}; + +rtx foo = (void*)0xbadf00d; + +int +__attribute__((noinline, noipa)) +earlyclobber_operand_p (rtx x) +{ + int i; + + for (i = 0; i < n_earlyclobbers; i++) + if (reload_earlyclobbers[i] == x) + return 1; + + return 0; +} + +extern void abort (); + +int main () +{ + check_vect (); + + n_earlyclobbers = IDX; + if (earlyclobber_operand_p (foo)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_92.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_92.c new file mode 100644 index 0000000000..1b2403b338 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_92.c @@ -0,0 +1,48 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 30 +#endif + +#ifndef IDX +#define IDX 15 +#endif + +int n_earlyclobbers; + +typedef void* rtx; +rtx reload_earlyclobbers[N] = {0}; + +rtx foo = (void*)0xbadf00d; + +int +__attribute__((noinline, noipa)) +earlyclobber_operand_p (rtx x) +{ + int i; + + for (i = 0; i < n_earlyclobbers; i++) + if (reload_earlyclobbers[i] == x) + return 1; + + return 0; +} + +extern void abort (); + +int main () +{ + check_vect (); + + n_earlyclobbers = IDX; + if (earlyclobber_operand_p (foo)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_93.c b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_93.c new file mode 100644 index 0000000000..656a778889 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-early-break_93.c @@ -0,0 +1,48 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 30 +#endif + +#ifndef IDX +#define IDX 29 +#endif + +int n_earlyclobbers; + +typedef void* rtx; +rtx reload_earlyclobbers[N] = {0}; + +rtx foo = (void*)0xbadf00d; + +int +__attribute__((noinline, noipa)) +earlyclobber_operand_p (rtx x) +{ + int i; + + for (i = 0; i < n_earlyclobbers; i++) + if (reload_earlyclobbers[i] == x) + return 1; + + return 0; +} + +extern void abort (); + +int main () +{ + check_vect (); + + n_earlyclobbers = IDX; + if (earlyclobber_operand_p (foo)) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-epilogues-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-epilogues-2.c new file mode 100644 index 0000000000..63c5e231f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-epilogues-2.c @@ -0,0 +1,59 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-do compile } */ + +int +f1 (int *x, int n) +{ + int res = 0; + for (int i = 0; i < n; ++i) + res += x[i * 2] == 1 ? 2 : 3; + return res; +} + +int +f2 (int *x) +{ + int res = 0; + for (int i = 0; i < 0x83; ++i) + res += x[i * 2] == 1 ? 2 : 3; + return res; +} + +int +f3 (int *x, int n) +{ + int res = 0; + for (int i = 0; i < n; ++i) + res += x[i * 2] == 1 ? 2 : 3; + return res + x[0x100]; +} + +int +f4 (int *x) +{ + int res = 0; + for (int i = 0; i < 0x83; ++i) + res += x[i * 2] == 1 ? 2 : 3; + return res + x[0x100]; +} + +int +f5 (int *x, int n, int a) +{ + int res = 0; + for (int i = 0; i < n; ++i) + res += x[i * 2] == 1 ? 2 : 3; + x[a] += 1; + return res; +} + +int +f6 (int *x, int a) +{ + int res = 0; + for (int i = 0; i < 0x83; ++i) + res += x[i * 2] == 1 ? 2 : 3; + x[a] += 1; + return res; +} +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-epilogues.c b/SingleSource/Regression/C/gcc-dg/vect/vect-epilogues.c new file mode 100644 index 0000000000..11b8c83b7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-epilogues.c @@ -0,0 +1,21 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-do compile } */ + +/* Copied from PR 88915. */ +void pixel_avg( unsigned char *dst, int i_dst_stride, + unsigned char *src1, int i_src1_stride, + unsigned char *src2, int i_src2_stride, + int i_width, int i_height ) + { + for( int y = 0; y < i_height; y++ ) + { + for( int x = 0; x < i_width; x++ ) + dst[x] = ( src1[x] + src2[x] + 1 ) >> 1; + dst += i_dst_stride; + src1 += i_src1_stride; + src2 += i_src2_stride; + } + } + +/* { dg-final { scan-tree-dump "LOOP EPILOGUE VECTORIZED" "vect" { target vect_multiple_sizes xfail { { arm32 && be } || vect_partial_vectors_usage_2 } } } } */ +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-float-extend-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-float-extend-1.c new file mode 100644 index 0000000000..603f48167d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-float-extend-1.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 32 + +float fb[N] = {0.4,3.5,6.6,9.4,12.5,15.6,18.4,21.5,24.6,27.4,30.5,33.6,36.4,39.5,42.6,45.4,0.5,3.6,6.4,9.5,12.6,15.4,18.5,21.6,24.4,27.5,30.6,33.4,36.5,39.6,42.4,45.5}; +double da[N]; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + + /* float -> double */ + for (i = 0; i < N; i++) + { + da[i] = (double) fb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (da[i] != (double) fb[i]) + abort (); + } + + return 0; +} + +int +main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-float-truncate-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-float-truncate-1.c new file mode 100644 index 0000000000..9f404f0e36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-float-truncate-1.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 32 + +__attribute__ ((noinline)) int +main1 () +{ + int i; + double db[N] = {0.4,3.5,6.6,9.4,12.5,15.6,18.4,21.5,24.6,27.4,30.5,33.6,36.4,39.5,42.6,45.4,0.5,3.6,6.4,9.5,12.6,15.4,18.5,21.6,24.4,27.5,30.6,33.4,36.5,39.6,42.4,45.5}; + float fa[N]; + + /* double -> float */ + for (i = 0; i < N; i++) + { + fa[i] = (float) db[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (fa[i] != (float) db[i]) + abort (); + } + + return 0; +} + +int +main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-floatint-conversion-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-floatint-conversion-1.c new file mode 100644 index 0000000000..f80da6a7ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-floatint-conversion-1.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 32 + +float fb[N] = {0.4,3.5,6.6,9.4,12.5,15.6,18.4,21.5,24.6,27.4,30.5,33.6,36.4,39.5,42.6,45.4,0.5,3.6,6.4,9.5,12.6,15.4,18.5,21.6,24.4,27.5,30.6,33.4,36.5,39.6,42.4,45.5}; +int ia[N]; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + + /* float -> int */ + for (i = 0; i < N; i++) + { + ia[i] = (int) fb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != (int) fb[i]) + abort (); + } + + return 0; +} + +int +main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_floatint_cvt } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-floatint-conversion-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-floatint-conversion-2.c new file mode 100644 index 0000000000..dc038857a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-floatint-conversion-2.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_double } */ + +#include +#include "tree-vect.h" + +#define N 32 + +__attribute__ ((noinline)) int +main1 () +{ + int i; + double db[N] = {0.4,3.5,6.6,9.4,12.5,15.6,18.4,21.5,24.6,27.4,30.5,33.6,36.4,39.5,42.6,45.4,0.5,3.6,6.4,9.5,12.6,15.4,18.5,21.6,24.4,27.5,30.6,33.4,36.5,39.6,42.4,45.5}; + int ia[N]; + + /* double -> int */ + for (i = 0; i < N; i++) + { + ia[i] = (int) db[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != (int) db[i]) + abort (); + } + + return 0; +} + +int +main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_doubleint_cvt } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fma-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fma-1.c new file mode 100644 index 0000000000..27d206d9fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fma-1.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target scalar_all_fma } */ + +#include "tree-vect.h" + +#define N (VECTOR_BITS * 11 / 64 + 3) + +#define DEF(INV) \ + void __attribute__ ((noipa)) \ + f_##INV (double *restrict a, double *restrict b, \ + double *restrict c, double *restrict d) \ + { \ + for (int i = 0; i < N; ++i) \ + { \ + double mb = (INV & 1 ? -b[i] : b[i]); \ + double mc = c[i]; \ + double md = (INV & 2 ? -d[i] : d[i]); \ + double fma = __builtin_fma (mb, mc, md); \ + a[i] = (INV & 4 ? -fma : fma); \ + } \ + } + +#define TEST(INV) \ + { \ + f_##INV (a, b, c, d); \ + _Pragma("GCC novector") \ + for (int i = 0; i < N; ++i) \ + { \ + double mb = (INV & 1 ? -b[i] : b[i]); \ + double mc = c[i]; \ + double md = (INV & 2 ? -d[i] : d[i]); \ + double fma = __builtin_fma (mb, mc, md); \ + double expected = (INV & 4 ? -fma : fma); \ + if (a[i] != expected) \ + __builtin_abort (); \ + asm volatile ("" ::: "memory"); \ + } \ + } + +#define FOR_EACH_INV(T) \ + T (0) T (1) T (2) T (3) T (4) T (5) T (6) T (7) + +FOR_EACH_INV (DEF) + +int +main (void) +{ + double a[N], b[N], c[N], d[N]; + for (int i = 0; i < N; ++i) + { + b[i] = i % 17; + c[i] = i % 9 + 11; + d[i] = i % 13 + 14; + asm volatile ("" ::: "memory"); + } + FOR_EACH_INV (TEST) + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 8 "vect" { target vect_double } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fma-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fma-2.c new file mode 100644 index 0000000000..20d1baff28 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fma-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-optimized -fassociative-math -fno-trapping-math -fno-signed-zeros" } */ + +#include "tree-vect.h" + +#define N (VECTOR_BITS * 11 / 64 + 3) + +double +dot_prod (double *x, double *y) +{ + double sum = 0; + for (int i = 0; i < N; ++i) + sum += x[i] * y[i]; + return sum; +} + +/* { dg-final { scan-tree-dump { = \.COND_FMA } "optimized" { target { vect_double && { vect_fully_masked && scalar_all_fma } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fma-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fma-3.c new file mode 100644 index 0000000000..b231a328fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fma-3.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/91723 */ +/* { dg-do compile { target { scalar_all_fma || { i?86-*-* x86_64-*-* } } } } */ +/* { dg-additional-options "-mfma" { target { i?86-*-* x86_64-*-* } } } */ + +void +foo (double *restrict r, const double *restrict a, + const double *restrict b, const double *restrict c) +{ + for (int i = 0; i < 1024; i++) + { + double x = __builtin_fma (a[i], b[i], c[i]); + x = __builtin_fma (a[i], b[i], x); + r[i] = x; + } +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target vect_double } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-1.c new file mode 100644 index 0000000000..d3aa5b06ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-1.c @@ -0,0 +1,85 @@ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +#ifndef TYPE +#define TYPE float +#define FN __builtin_fmaxf +#endif + +TYPE __attribute__((noipa)) +test (TYPE x, TYPE *ptr, int n) +{ + for (int i = 0; i < n; ++i) + x = FN (x, ptr[i]); + return x; +} + +#define N 128 +#define HALF (N / 2) + +int +main (void) +{ + check_vect (); + + TYPE a[N]; + + for (int i = 0; i < N; ++i) + a[i] = i; + + if (test (-1, a, 1) != 0) + __builtin_abort (); + if (test (-1, a, 64) != 63) + __builtin_abort (); + if (test (-1, a, 65) != 64) + __builtin_abort (); + if (test (-1, a, 66) != 65) + __builtin_abort (); + if (test (-1, a, 67) != 66) + __builtin_abort (); + if (test (-1, a, 128) != 127) + __builtin_abort (); + if (test (127, a, 128) != 127) + __builtin_abort (); + if (test (128, a, 128) != 128) + __builtin_abort (); + + for (int i = 0; i < N; ++i) + a[i] = -i; + + if (test (-60, a, 4) != 0) + __builtin_abort (); + if (test (0, a, 4) != 0) + __builtin_abort (); + if (test (1, a, 4) != 1) + __builtin_abort (); + + for (int i = 0; i < HALF; ++i) + { + a[i] = i; + a[HALF + i] = HALF - i; + } + + if (test (0, a, HALF - 16) != HALF - 17) + __builtin_abort (); + if (test (0, a, HALF - 2) != HALF - 3) + __builtin_abort (); + if (test (0, a, HALF - 1) != HALF - 2) + __builtin_abort (); + if (test (0, a, HALF) != HALF - 1) + __builtin_abort (); + if (test (0, a, HALF + 1) != HALF) + __builtin_abort (); + if (test (0, a, HALF + 2) != HALF) + __builtin_abort (); + if (test (0, a, HALF + 3) != HALF) + __builtin_abort (); + if (test (0, a, HALF + 16) != HALF) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-2.c new file mode 100644 index 0000000000..d455dd4f10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-2.c @@ -0,0 +1,9 @@ +/* { dg-require-effective-target vect_float } */ + +#define TYPE double +#define FN __builtin_fmax + +#include "vect-fmax-1.c" + +/* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-3.c new file mode 100644 index 0000000000..58e74e22ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fmax-3.c @@ -0,0 +1,85 @@ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +test (double x0, double x1, double *restrict res, double *restrict ptr, int n) +{ + for (int i = 0; i < n; i += 2) + { + x0 = __builtin_fmax (x0, ptr[i + 0]); + x1 = __builtin_fmax (x1, ptr[i + 1]); + } + res[0] = x0; + res[1] = x1; +} + +#define N 128 +#define HALF (N / 2) + +int +main (void) +{ + check_vect (); + + double res[2], a[N]; + + for (int i = 0; i < N; i += 2) + { + a[i] = i < HALF ? i : HALF; + a[i + 1] = i / 8; + } + + test (-1, -1, res, a, 2); + if (res[0] != 0 || res[1] != 0) + __builtin_abort (); + + test (-1, -1, res, a, 6); + if (res[0] != 4 || res[1] != 0) + __builtin_abort (); + + test (-1, -1, res, a, 8); + if (res[0] != 6 || res[1] != 0) + __builtin_abort (); + + test (-1, -1, res, a, 10); + if (res[0] != 8 || res[1] != 1) + __builtin_abort (); + + test (-1, -1, res, a, HALF - 2); + if (res[0] != HALF - 4 || res[1] != HALF / 8 - 1) + __builtin_abort (); + + test (-1, -1, res, a, HALF); + if (res[0] != HALF - 2 || res[1] != HALF / 8 - 1) + __builtin_abort (); + + test (-1, -1, res, a, HALF + 2); + if (res[0] != HALF || res[1] != HALF / 8) + __builtin_abort (); + + test (-1, -1, res, a, HALF + 8); + if (res[0] != HALF || res[1] != HALF / 8) + __builtin_abort (); + + test (-1, -1, res, a, HALF + 10); + if (res[0] != HALF || res[1] != HALF / 8 + 1) + __builtin_abort (); + + test (-1, -1, res, a, N); + if (res[0] != HALF || res[1] != N / 8 - 1) + __builtin_abort (); + + test (HALF + 1, -1, res, a, N); + if (res[0] != HALF + 1 || res[1] != N / 8 - 1) + __builtin_abort (); + + test (HALF + 1, N, res, a, N); + if (res[0] != HALF + 1 || res[1] != N) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-1.c new file mode 100644 index 0000000000..281fdf2bad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-1.c @@ -0,0 +1,88 @@ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +#ifndef TYPE +#define TYPE float +#define FN __builtin_fminf +#endif + +TYPE __attribute__((noipa)) +test (TYPE x, TYPE *ptr, int n) +{ + for (int i = 0; i < n; ++i) + x = FN (x, ptr[i]); + return x; +} + +#define N 128 +#define HALF (N / 2) + +int +main (void) +{ + check_vect (); + + TYPE a[N]; + + for (int i = 0; i < N; ++i) + a[i] = -i; + + if (test (1, a, 1) != 0) + __builtin_abort (); + if (test (1, a, 64) != -63) + __builtin_abort (); + if (test (1, a, 65) != -64) + __builtin_abort (); + if (test (1, a, 66) != -65) + __builtin_abort (); + if (test (1, a, 67) != -66) + __builtin_abort (); + if (test (1, a, 128) != -127) + __builtin_abort (); + if (test (-127, a, 128) != -127) + __builtin_abort (); + if (test (-128, a, 128) != -128) + __builtin_abort (); + + for (int i = 0; i < N; ++i) + a[i] = i; + + if (test (1, a, 4) != 0) + __builtin_abort (); + if (test (0, a, 4) != 0) + __builtin_abort (); + if (test (-1, a, 4) != -1) + __builtin_abort (); + + for (int i = 0; i < HALF; ++i) + { + a[i] = HALF - i; + a[HALF + i] = i; + } + + if (test (N, a, HALF - 16) != 17) + __builtin_abort (); + if (test (N, a, HALF - 2) != 3) + __builtin_abort (); + if (test (N, a, HALF - 1) != 2) + __builtin_abort (); + if (test (N, a, HALF) != 1) + __builtin_abort (); + if (test (N, a, HALF + 1) != 0) + __builtin_abort (); + if (test (N, a, HALF + 2) != 0) + __builtin_abort (); + if (test (N, a, HALF + 3) != 0) + __builtin_abort (); + if (test (N, a, HALF + 16) != 0) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */ + +/* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-2.c new file mode 100644 index 0000000000..ee9e134af6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-2.c @@ -0,0 +1,11 @@ +/* { dg-require-effective-target vect_float } */ + +#ifndef TYPE +#define TYPE double +#define FN __builtin_fmin +#endif + +#include "vect-fmin-1.c" + +/* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-3.c new file mode 100644 index 0000000000..2e282ba687 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fmin-3.c @@ -0,0 +1,85 @@ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +test (double x0, double x1, double *restrict res, double *restrict ptr, int n) +{ + for (int i = 0; i < n; i += 2) + { + x0 = __builtin_fmin (x0, ptr[i + 0]); + x1 = __builtin_fmin (x1, ptr[i + 1]); + } + res[0] = x0; + res[1] = x1; +} + +#define N 128 +#define HALF (N / 2) + +int +main (void) +{ + check_vect (); + + double res[2], a[N]; + + for (int i = 0; i < N; i += 2) + { + a[i] = i < HALF ? HALF - i : 0; + a[i + 1] = -i / 8; + } + + test (N, N, res, a, 2); + if (res[0] != HALF || res[1] != 0) + __builtin_abort (); + + test (N, N, res, a, 6); + if (res[0] != HALF - 4 || res[1] != 0) + __builtin_abort (); + + test (N, N, res, a, 8); + if (res[0] != HALF - 6 || res[1] != 0) + __builtin_abort (); + + test (N, N, res, a, 10); + if (res[0] != HALF - 8 || res[1] != -1) + __builtin_abort (); + + test (N, N, res, a, HALF - 2); + if (res[0] != 4 || res[1] != -HALF / 8 + 1) + __builtin_abort (); + + test (N, N, res, a, HALF); + if (res[0] != 2 || res[1] != -HALF / 8 + 1) + __builtin_abort (); + + test (N, N, res, a, HALF + 2); + if (res[0] != 0 || res[1] != -HALF / 8) + __builtin_abort (); + + test (N, N, res, a, HALF + 8); + if (res[0] != 0 || res[1] != -HALF / 8) + __builtin_abort (); + + test (N, N, res, a, HALF + 10); + if (res[0] != 0 || res[1] != -HALF / 8 - 1) + __builtin_abort (); + + test (N, N, res, a, N); + if (res[0] != 0 || res[1] != -N / 8 + 1) + __builtin_abort (); + + test (-1, N, res, a, N); + if (res[0] != -1 || res[1] != -N / 8 + 1) + __builtin_abort (); + + test (-1, -N / 8, res, a, N); + if (res[0] != -1 || res[1] != -N / 8) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Detected reduction" "vect" } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_max_reduc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-fold-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-fold-1.c new file mode 100644 index 0000000000..2bd21a47a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-fold-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ + +typedef unsigned char v4qi __attribute__ ((vector_size (4))); + +v4qi c; + +void foo() +{ + v4qi a = { 1, 2, 3, 4 }; + v4qi b = { 5, 6, 7, 8 }; + c = a + b; +} + +/* { dg-final { scan-tree-dump-times "c =.* { 6, 8, 10, 12 }" 1 "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-gather-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-1.c new file mode 100644 index 0000000000..5f6640d9ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-1.c @@ -0,0 +1,61 @@ +#include "tree-vect.h" + +#define N 16 + +void __attribute__((noipa)) +f (int *restrict y, int *restrict x, int *restrict indices) +{ + for (int i = 0; i < N; ++i) + { + y[i * 2] = x[indices[i * 2]] + 1; + y[i * 2 + 1] = x[indices[i * 2 + 1]] + 2; + } +} + +int y[N * 2]; +int x[N * 2] = { + 72704, 52152, 51301, 96681, + 57937, 60490, 34504, 60944, + 42225, 28333, 88336, 74300, + 29250, 20484, 38852, 91536, + 86917, 63941, 31590, 21998, + 22419, 26974, 28668, 13968, + 3451, 20247, 44089, 85521, + 22871, 87362, 50555, 85939 +}; +int indices[N * 2] = { + 15, 16, 9, 19, + 7, 22, 19, 1, + 22, 13, 15, 30, + 5, 12, 11, 11, + 10, 25, 5, 20, + 22, 24, 24, 28, + 30, 19, 6, 4, + 7, 12, 8, 21 +}; +int expected[N * 2] = { + 91537, 86919, 28334, 22000, + 60945, 28670, 21999, 52154, + 28669, 20486, 91537, 50557, + 60491, 29252, 74301, 74302, + 88337, 20249, 60491, 22421, + 28669, 3453, 3452, 22873, + 50556, 22000, 34505, 57939, + 60945, 29252, 42226, 26976 +}; + +int +main (void) +{ + check_vect (); + + f (y, x, indices); +#pragma GCC novector + for (int i = 0; i < 32; ++i) + if (y[i] != expected[i]) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-gather-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-2.c new file mode 100644 index 0000000000..4c23b80833 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-2.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ + +#define N 16 + +void +f1 (int *restrict y, int *restrict x1, int *restrict x2, + int *restrict indices) +{ + for (int i = 0; i < N; ++i) + { + /* Different base. */ + y[i * 2] = x1[indices[i * 2]] + 1; + y[i * 2 + 1] = x2[indices[i * 2 + 1]] + 2; + } +} + +void +f2 (int *restrict y, int *restrict x, int *restrict indices) +{ + for (int i = 0; i < N; ++i) + { + /* Different scale. */ + y[i * 2] = *(int *)((char *)x + (__UINTPTR_TYPE__)indices[i * 2] * 4) + 1; + y[i * 2 + 1] = *(int *)((char *)x + (__UINTPTR_TYPE__)indices[i * 2 + 1] * 2) + 2; + } +} + +void +f3 (int *restrict y, int *restrict x, int *restrict indices) +{ + for (int i = 0; i < N; ++i) + { + /* Different type. */ + y[i * 2] = x[indices[i * 2]] + 1; + y[i * 2 + 1] = x[((unsigned int *) indices)[i * 2 + 1]] + 2; + } +} + +/* { dg-final { scan-tree-dump-not "Loop contains only SLP stmts" vect } } */ +/* { dg-final { scan-tree-dump "different gather base" vect { target { ! vect_gather_load_ifn } } } } */ +/* { dg-final { scan-tree-dump "different gather scale" vect { target { ! vect_gather_load_ifn } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-gather-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-3.c new file mode 100644 index 0000000000..30ba6789e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-3.c @@ -0,0 +1,65 @@ +#include "tree-vect.h" + +#define N 16 + +void __attribute__((noipa)) +f (int *restrict y, int *restrict x, int *restrict indices) +{ + for (int i = 0; i < N; ++i) + { + y[i * 2] = (indices[i * 2] < N * 2 + ? x[indices[i * 2]] + 1 + : 1); + y[i * 2 + 1] = (indices[i * 2 + 1] < N * 2 + ? x[indices[i * 2 + 1]] + 2 + : 2); + } +} + +int y[N * 2]; +int x[N * 2] = { + 72704, 52152, 51301, 96681, + 57937, 60490, 34504, 60944, + 42225, 28333, 88336, 74300, + 29250, 20484, 38852, 91536, + 86917, 63941, 31590, 21998, + 22419, 26974, 28668, 13968, + 3451, 20247, 44089, 85521, + 22871, 87362, 50555, 85939 +}; +int indices[N * 2] = { + 15, 0x10000, 0xcafe0, 19, + 7, 22, 19, 1, + 0x20000, 0x70000, 15, 30, + 5, 12, 11, 11, + 10, 25, 5, 20, + 22, 24, 32, 28, + 30, 19, 6, 0xabcdef, + 7, 12, 8, 21 +}; +int expected[N * 2] = { + 91537, 2, 1, 22000, + 60945, 28670, 21999, 52154, + 1, 2, 91537, 50557, + 60491, 29252, 74301, 74302, + 88337, 20249, 60491, 22421, + 28669, 3453, 1, 22873, + 50556, 22000, 34505, 2, + 60945, 29252, 42226, 26976 +}; + +int +main (void) +{ + check_vect (); + + f (y, x, indices); +#pragma GCC novector + for (int i = 0; i < 32; ++i) + if (y[i] != expected[i]) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect { target { { vect_gather_load_ifn || avx2 } && vect_masked_load } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-gather-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-4.c new file mode 100644 index 0000000000..1ce63e6919 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-4.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ + +#define N 16 + +void +f1 (int *restrict y, int *restrict x1, int *restrict x2, + int *restrict indices) +{ + for (int i = 0; i < N; ++i) + { + y[i * 2] = (indices[i * 2] < N * 2 + ? x1[indices[i * 2]] + 1 + : 1); + y[i * 2 + 1] = (indices[i * 2 + 1] < N * 2 + ? x2[indices[i * 2 + 1]] + 2 + : 2); + } +} + +void +f2 (int *restrict y, int *restrict x, int *restrict indices) +{ + for (int i = 0; i < N; ++i) + { + y[i * 2] = (indices[i * 2] < N * 2 + ? x[indices[i * 2]] + 1 + : 1); + y[i * 2 + 1] = (indices[i * 2 + 1] < N * 2 + ? x[indices[i * 2 + 1] * 2] + 2 + : 2); + } +} + +void +f3 (int *restrict y, int *restrict x, int *restrict indices) +{ + for (int i = 0; i < N; ++i) + { + y[i * 2] = (indices[i * 2] < N * 2 + ? x[indices[i * 2]] + 1 + : 1); + y[i * 2 + 1] = (((unsigned int *)indices)[i * 2 + 1] < N * 2 + ? x[((unsigned int *) indices)[i * 2 + 1]] + 2 + : 2); + } +} + +/* { dg-final { scan-tree-dump-not "Loop contains only SLP stmts" vect } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-gather-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-5.c new file mode 100644 index 0000000000..8b5074bba8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-5.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +#ifdef __aarch64__ +#pragma GCC target "+sve" +#endif + +long a[100], b[100], c[100]; + +void g1 () +{ + for (int i = 0; i < 100; i += 2) + { + c[i] += a[b[i]] + 1; + c[i + 1] += a[b[i + 1]] + 2; + } +} + +long g2 () +{ + long res = 0; + for (int i = 0; i < 100; i += 2) + { + res += a[b[i + 1]]; + res += a[b[i]]; + } + return res; +} + +long g3 () +{ + long res = 0; + for (int i = 0; i < 100; i += 2) + { + res += a[b[i]]; + res += a[b[i + 1]]; + } + return res; +} + +/* { dg-final { scan-tree-dump-times {add new stmt[^\n]*GATHER_LOAD} 3 "vect" { target aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-not {add new stmt[^\n]*VEC_PERM_EXPR} "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-gather-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-6.c new file mode 100644 index 0000000000..ff55f32185 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-gather-6.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +void +f (int *restrict y, int *restrict x, int *restrict indices, int *restrict cond, int n) +{ + for (int i = 0; i < n; ++i) + { + if (cond[i * 2]) + y[i * 2] = x[indices[i * 2]] + 1; + if (cond[i * 2 + 1]) + y[i * 2 + 1] = x[indices[i * 2 + 1]] + 2; + } +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect { target vect_gather_load_ifn } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-10.c new file mode 100644 index 0000000000..0fbb97f515 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-10.c @@ -0,0 +1,11 @@ +/* PR 21272 */ +/* { dg-do compile } */ +double +foo (int j, double *v, double x) +{ + int i; + for (i = 0; i < j; i++) + if (v[i] < x) + x = v[i]; + return x; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-11.c new file mode 100644 index 0000000000..04d5fd0772 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-11.c @@ -0,0 +1,37 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 16 + +extern void abort (void); + +int A[N] = {36, 39, 42, 45, 43, 32, 21, 12, 23, 34, 45, 56, 67, 78, 81, 11}; +int B[N] = {144,195,210,225,172,128,105,60, 92, 136,225,280,268,390,324,55}; + +__attribute__((noinline)) +void foo () +{ + for (int i = 0; i < N; i++) + { + int m = (A[i] & i) ? 5 : 4; + A[i] = A[i] * m; + } +} + +int main () +{ + + check_vect (); + foo (); + /* check results: */ +#pragma GCC novector + for (int i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-16.c new file mode 100644 index 0000000000..0f752b716c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-16.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +extern void abort(void); + +float A[N] = {36,39,42,45,43,32,21,42,23,34,45,56,67,42,89,11}; +float B[N] = {42,42,0,42,42,42,42,0,42,42,42,42,42,0,42,42}; + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] != MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-17.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-17.c new file mode 100644 index 0000000000..8b028d7f75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-17.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,42,78,89,11}; +float B[N] = {42,42,0,42,42,42,42,42,42,42,42,42,0,42,42,42}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] == MAX ? 0 : MAX); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-18.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-18.c new file mode 100644 index 0000000000..c1d3c27d81 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-18.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-Ofast -mavx" { target avx_runtime } } */ + + +int A0[4] = {36,39,42,45}; +int B0[4] = {42,42,0,42}; +float A1[8] = {36,39,42,45,43,32,21,12}; +float B1[8] = {42,42,0,42,42,42,0,42}; +double A2[16] = {36,39,42,45,43,32,21,12,23,34,45,56,42,78,89,11}; +double B2[16] = {42,42,0,42,42,42,42,42,42,42,42,42,0,42,42,42}; + +int main () +{ + int i, j; + int res0 = 1; + float res1 = 1.0; + double res2 = 1.0; + + for (i = 0; i < 4; i++) + if (B0[i]) + res0 *= A0[i]; + + for (i = 0; i < 8; i++) + if (B1[i]) + res1 *= A1[i]; + + for (i = 0; i < 16; i++) + if (B2[i]) + res2 *= A2[i]; + /* check results: */ + if (res0 != 63180 || res1 != 1043228160.000000 + ||res2 != 3296728515318523101184.000000) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 3 loops" "vect" { target i?86-*-* x86_64-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-19.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-19.c new file mode 100644 index 0000000000..e34bfa907a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-19.c @@ -0,0 +1,63 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -Ofast -fdump-tree-ifcvt-raw" } */ + +void __GIMPLE (ssa,guessed_local(10737414), startwith ("fix_loops")) +foo (int * f, int d, int e) +{ + int t; + int a; + int i; + long unsigned int _1; + long unsigned int _2; + int * _3; + int _4; + + __BB(2,guessed_local(10737414)): + goto __BB3(guessed(134217728)); + + __BB(3,loop_header(1),guessed_local(1063004408)): + i_18 = __PHI (__BB8: i_15, __BB2: 0); + _1 = (long unsigned int) i_18; + _2 = _1 * 4ul; + _3 = f_9(D) + _2; + a_10 = __MEM (_3); + if (a_10 < 0) + goto __BB9(guessed(55029268)); + else + goto __BB4(guessed(79188460)); + + __BB(9,guessed_local(435831803)): + goto __BB6(precise(134217728)); + + __BB(4,guessed_local(627172605)): + if (a_10 < e_11(D)) + goto __BB5(guessed(67108864)); + else + goto __BB10(guessed(67108864)); + + __BB(10,guessed_local(313586303)): + goto __BB6(precise(134217728)); + + __BB(5,guessed_local(313586302)): + _4 = a_10 * d_12(D); + t_13 = 1 - _4; + goto __BB6(precise(134217728)); + + __BB(6,guessed_local(1063004410)): + t_6 = __PHI (__BB9: 1, __BB5: t_13, __BB10: 0); + __MEM (_3) = t_6; + i_15 = i_18 + 1; + if (i_15 != 1024) + goto __BB8(guessed(132875551)); + else + goto __BB7(guessed(1342177)); + + __BB(8,guessed_local(1052374368)): + goto __BB3(precise(134217728)); + + __BB(7,guessed_local(10737416)): + return; + +} + +/* { dg-final { scan-tree-dump-times { +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +int A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +int B[N] = {0,0,42,42,42,0,0,0,0,0,42,42,42,42,42,0}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] >= MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-20.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-20.c new file mode 100644 index 0000000000..96c5f5a929 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-20.c @@ -0,0 +1,62 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -fopenmp-simd -Ofast -fdump-tree-ifcvt-raw" } */ + +void foo (int * restrict p, int * restrict q, int * restrict r, int * restrict s, int * restrict t, int * restrict u) +{ +#pragma omp simd + for (int i = 0; i < 1024; i++) + { + int vp = p[i]; + int vq = q[i]; + int vr = r[i]; + int vs = s[i]; + int vt = t[i]; + int vu = u[i]; + int vw; + if (vp != 0) + { + if (vp > 100) + { + if (vq < 200) + vw = 1; + else if (vr) + vw = 2; + else + vw = 3; + } + else if (vs > 100) + { + if (vq < 180) + vw = 4; + else if (vr > 20) + vw = 5; + else + vw = 6; + } + else + { + if (vq < -100) + vw = 7; + else if (vr < -20) + vw = 8; + else + vw = 9; + } + } + else if (vt > 10) + { + if (vu > 100) + vw = 10; + else if (vu < -100) + vw = 11; + else + vw = 12; + } + else + vw = 13; + u[i] = vw; + } +} + +/* { dg-final { scan-tree-dump-times { +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +int A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +int B[N] = {0,0,0,42,42,0,0,0,0,0,42,42,42,42,42,0}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] > MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-4.c new file mode 100644 index 0000000000..63f53a4c4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-4.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +int A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +int B[N] = {42,42,42,0,0,42,42,42,42,42,0,0,0,0,0,42}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] <= MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-5.c new file mode 100644 index 0000000000..38b0143364 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-5.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +int A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +int B[N] = {42,42,0,0,0,42,42,42,42,42,0,0,0,0,0,42}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] < MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-6.c new file mode 100644 index 0000000000..56e0f71bc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-6.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +int A[N] = {36,39,42,45,43,32,21,42,23,34,45,56,67,42,89,11}; +int B[N] = {42,42,0,42,42,42,42,0,42,42,42,42,42,0,42,42}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] != MAX ? MAX : 0); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-7.c new file mode 100644 index 0000000000..879d88a5ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-7.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +int A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,42,78,89,11}; +int B[N] = {42,42,0,42,42,42,42,42,42,42,42,42,0,42,42,42}; + +extern void abort(void); + +int main () +{ + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] == MAX ? 0 : MAX); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-9.c new file mode 100644 index 0000000000..bbeccae0f2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ifcvt-9.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +extern void abort(void); + +int A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; +int B[N] = {0,0,42,42,42,0,0,0,0,0,42,42,42,42,42,0}; +inline void foo () __attribute__((always_inline)); +void foo () +{ + int i, j; + + for (i = 0; i < 16; i++) + A[i] = ( A[i] >= MAX ? MAX : 0); +} + +int main () +{ + + int i, j; + check_vect (); + foo (); + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-1.c new file mode 100644 index 0000000000..f75c0f5a1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-1.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 32 + +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float fa[N]; + +__attribute__ ((noinline)) int main1 () +{ + int i; + + /* int -> float */ + for (i = 0; i < N; i++) + { + fa[i] = (float) ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (fa[i] != (float) ib[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_intfloat_cvt } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-2.c new file mode 100644 index 0000000000..32df21fb52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-2.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 32 + +int int_arr[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float float_arr[N]; +char char_arr[N]; + +__attribute__ ((noinline)) int main1 () +{ + int i; + + for (i = 0; i < N; i++){ + float_arr[i] = (float) int_arr[i]; + char_arr[i] = 0; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (float_arr[i] != (float) int_arr[i]) + abort (); + if (char_arr[i] != 0) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_intfloat_cvt } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-3.c new file mode 100644 index 0000000000..db33a84b54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-3.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_double } */ + +#include +#include "tree-vect.h" + +#define N 32 + +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +double da[N]; + +__attribute__ ((noinline)) int main1 () +{ + int i; + + /* int -> double */ + for (i = 0; i < N; i++) + { + da[i] = (double) ib[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (da[i] != (double) ib[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_intdouble_cvt } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-4a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-4a.c new file mode 100644 index 0000000000..6fc23bb462 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-4a.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 32 + +short sb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,-3,-6,-9,-12,-15,-18,-21,-24,-27,-30,-33,-36,-39,-42,-45}; +float fa[N]; + +__attribute__ ((noinline)) int main1 () +{ + int i; + + /* short -> float */ + for (i = 0; i < N; i++) + { + fa[i] = (float) sb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (fa[i] != (float) sb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_intfloat_cvt } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-4b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-4b.c new file mode 100644 index 0000000000..b570db5dc9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-intfloat-conversion-4b.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 32 + +unsigned short usb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,65533,65530,65527,65524,65521,65518,65515,65512,65509,65506,65503,65500,65497,65494,65491}; +float fa[N]; + +__attribute__ ((noinline)) int main1 () +{ + int i; + + /* unsigned short -> float */ + for (i = 0; i < N; i++) + { + fa[i] = (float) usb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (fa[i] != (float) usb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_intfloat_cvt } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-1.c new file mode 100644 index 0000000000..e6dcf29ebe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-1.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +int result[N] = {8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38}; + +__attribute__ ((noinline)) int main1 (int X) +{ + int arr[N]; + int k = X; + int m, i=0; + + /* vectorization of induction. */ + + do { + m = k + 5; + arr[i] = m; + k = k + 2; + i++; + } while (i < N); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (arr[i] != result[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (3); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-10.c new file mode 100644 index 0000000000..83bc7805c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-10.c @@ -0,0 +1,36 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) +int main1 () +{ + int i,j; + int ia[N]; + + /* Induction. */ + for (j=0,i=N; j0; i--,j++) { + ia[j] = i; + } + + /* check results: */ +#pragma GCC novector + for (j=0,i=N; j0; i--,j++) { + if (ia[j] != i) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect(); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-11.c new file mode 100644 index 0000000000..7dc353f536 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-11.c @@ -0,0 +1,31 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +int __attribute__((noinline,noclone)) +main1 (int len) +{ + int s = 0; + int i = len; + + /* vectorization of induction with reduction. */ + for ( ; i > 1; i -=2) + s += i; + + return s; +} + +int main (void) +{ + int s; + check_vect (); + + s = main1 (26); + if (s != 182) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-2.c new file mode 100644 index 0000000000..d85bb3436b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-2.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int main1 () +{ + int arr1[N]; + int k = 0; + int m = 3, i = 0; + + /* Vectorization of induction that is used after the loop. + Currently vectorizable because scev_ccp disconnects the + use-after-the-loop from the iv def inside the loop. */ + + do { + k = k + 2; + arr1[i] = k; + m = m + k; + i++; + } while (i < N); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (arr1[i] != 2+2*i) + abort (); + } + + return m + k; +} + +int main (void) +{ + int res; + + check_vect (); + + res = main1 (); + if (res != 32 + 275) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-3.c new file mode 100644 index 0000000000..c0738ebc46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-3.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int main1 () +{ + int arr1[N]; + int arr2[N]; + int k = 0; + int m = 3, i = 0; + + /* vectorization of induction. + Peeling to align the store is also applied. */ + + do { + k = k + 2; + arr1[i] = k; + m = k + 3; + arr2[i] = m; + i++; + } while (i < N); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (arr1[i] != 2+2*i || arr2[i] != 5 + 2*i) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-4.c new file mode 100644 index 0000000000..2dd8ae3051 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-4.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int main1 () +{ + unsigned int arr1[N]; + unsigned short arr2[N]; + unsigned int k = 0; + unsigned short m = 3; + int i = 0; + + /* Vectorization of induction with multiple data types. */ + + do { + k = k + 2; + arr1[i] = k; + m = k + 3; + arr2[i] = m; + i++; + } while (i < N); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (arr1[i] != 2+2*i || arr2[i] != 5 + 2*i) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_pack_trunc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-5.c new file mode 100644 index 0000000000..c3c4735f03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-5.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int main1 () +{ + float arr[N]; + float f = 1.0; + int i; + + /* Vectorization of fp induction. */ + + for (i=0; i +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int main1 (int X) +{ + int arr1[N+1]; + int arr2[N+1]; + int k = X; + int m, i=0; + + /* Vectorization of induction with non-constant initial condition X. + Also we have here two uses of the induction-variable k as defined + by the loop-header phi (as opposed to the other uses of k that are + defined in the loop), in which case we exercise the fact that we + reuse the same vector def-use-cycle for both uses. + Peeling to align the store is also applied. This peeling also aligns + the load (as they have the same misalignment). */ + + do { + arr2[i+1] = 2*k; + k = k + 2; + arr1[i+1] = k; + k = k + 4; + i++; + } while (i < N); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (arr1[i+1] != X+6*i+2 + || arr2[i+1] != 2*(X+6*i)) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (3); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-7.c new file mode 100644 index 0000000000..f6d93360d8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-7.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +int result[N] = {8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38}; + +__attribute__ ((noinline, noclone)) int main1 (int X) +{ + int arr[N]; + int k = 3; + int m, i=0; + + /* Vectorization of induction with non-constant step X. */ + + do { + m = k + 5; + arr[i] = m; + k = k + X; + i++; + } while (i < N); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (arr[i] != result[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (2); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8-big-array.c new file mode 100644 index 0000000000..26e8c499ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8-big-array.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) int main1 (short X) +{ + unsigned char a[N]; + unsigned short b[N]; + unsigned int c[N]; + short myX = X; + int i; + + /* vectorization of induction with type conversions. */ + for (i = 0; i < N; i++) + { + a[i] = (unsigned char)X; + b[i] = X; + c[i] = (unsigned int)X; + X++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != (unsigned char)myX || b[i] != myX || c[i] != (unsigned int)myX++) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (3); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_pack_trunc && vect_unpack } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8.c new file mode 100644 index 0000000000..b4bb29d880 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 26 + +__attribute__ ((noinline)) int main1 (short X) +{ + unsigned char a[N]; + unsigned short b[N]; + unsigned int c[N]; + short myX = X; + int i; + + /* vectorization of induction with type conversions. */ + for (i = 0; i < N; i++) + { + a[i] = (unsigned char)X; + b[i] = X; + c[i] = (unsigned int)X; + X++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != (unsigned char)myX || b[i] != myX || c[i] != (unsigned int)myX++) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (3); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_pack_trunc && vect_unpack } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8a-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8a-big-array.c new file mode 100644 index 0000000000..dceae27bbb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8a-big-array.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +__attribute__ ((noinline)) int main1 (short X) +{ + signed char a[N]; + short b[N]; + int c[N]; + short myX = X; + int i; + + /* vectorization of induction with type conversions. */ + for (i = 0; i < N; i++) + { + a[i] = (signed char)X; + b[i] = X; + c[i] = (int)X; + X++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != (signed char)myX || b[i] != myX || c[i] != (int)myX++) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (3); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_pack_trunc && vect_unpack } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8a.c new file mode 100644 index 0000000000..dfe3a27f02 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-8a.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 26 + +__attribute__ ((noinline)) int main1 (short X) +{ + signed char a[N]; + short b[N]; + int c[N]; + short myX = X; + int i; + + /* vectorization of induction with type conversions. */ + for (i = 0; i < N; i++) + { + a[i] = (signed char)X; + b[i] = X; + c[i] = (int)X; + X++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (a[i] != (signed char)myX || b[i] != myX || c[i] != (int)myX++) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (3); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_pack_trunc && vect_unpack } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-iv-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-9.c new file mode 100644 index 0000000000..e548b81b92 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-iv-9.c @@ -0,0 +1,36 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 26 +int a[N]; + +__attribute__ ((noinline)) int main1 (int X) +{ + int s = X; + int i; + + /* vectorization of reduction with induction. */ + for (i = 0; i < N; i++) + s += (i + a[i]); + + return s; +} + +int main (void) +{ + int s, i; + check_vect (); + + for (i = 0; i < N; i++) + a[i] = 2*i; + + s = main1 (3); + if (s != 978) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ivdep-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ivdep-1.c new file mode 100644 index 0000000000..f32bc7a347 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ivdep-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-O3 -fopt-info-vec-optimized" } */ + +/* PR other/33426 */ +/* Testing whether #pragma ivdep is working. */ + +void foo(int n, int *a, int *b, int *c, int *d, int *e) { + int i, j; +#pragma GCC ivdep + for (i = 0; i < n; ++i) { + a[i] = b[i] + c[i]; + } +} + +/* { dg-message "loop vectorized" "" { target *-*-* } 0 } */ +/* { dg-bogus " version\[^\n\r]* alias" "" { target *-*-* } 0 } */ +/* { dg-prune-output " version\[^\n\r]* alignment" } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ivdep-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ivdep-2.c new file mode 100644 index 0000000000..e623b46ee8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ivdep-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-O3 -fopt-info-vec-optimized" } */ + +/* PR other/33426 */ +/* Testing whether #pragma ivdep is working. */ + +void foo(int n, int *a, int *b, int *c) { + int i; + i = 0; +#pragma GCC ivdep + while(i < n) + { + a[i] = b[i] + c[i]; + ++i; + } +} + +void bar(int n, int *a, int *b, int *c) { + int i; + i = 0; +#pragma GCC ivdep + do + { + a[i] = b[i] + c[i]; + ++i; + } + while(i < n); +} + + +/* { dg-message "loop vectorized" "" { target *-*-* } 0 } */ +/* { dg-bogus " version\[^\n\r]* alias" "" { target *-*-* } 0 } */ +/* { dg-prune-output " version\[^\n\r]* alignment" } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-live-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-live-1.c new file mode 100644 index 0000000000..e4a6433a89 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-live-1.c @@ -0,0 +1,51 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-tree-scev-cprop" } */ + +#include "tree-vect.h" + +/* Statement used outside the loop. + NOTE: SCEV disabled to ensure the live operation is not removed before + vectorization. */ +__attribute__ ((noinline)) int +liveloop (int start, int n, int *x) +{ + int i = start; + int j; + + for (j = 0; j < n; ++j) + { + i += 1; + x[j] = i; + } + return i; +} + +#define MAX 62 +#define START 27 + +int +main (void) +{ + int a[MAX]; + int i; + + check_vect (); + + int ret = liveloop (START, MAX, a); + + if (ret != MAX + START) + abort (); + +#pragma GCC novector + for (i=0; i> 1; + unsigned short b = (x[i] + 42) >> 2; + unsigned short cmp = y[i] == 0 ? a : b; + int res = cmp + 1; + x[i] = res; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-1.c new file mode 100644 index 0000000000..4df0581efe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-1.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" +#ifndef SIGNEDNESS +#define SIGNEDNESS signed +#endif +#ifndef BIAS +#define BIAS 0 +#endif + +#define HRS(x) ((((x) >> (15 - BIAS)) + BIAS) >> BIAS) + +void __attribute__ ((noipa)) +f (SIGNEDNESS short *restrict a, SIGNEDNESS short *restrict b, + SIGNEDNESS short *restrict c, __INTPTR_TYPE__ n) +{ + for (__INTPTR_TYPE__ i = 0; i < n; ++i) + a[i] = HRS((SIGNEDNESS int) b[i] * (SIGNEDNESS int) c[i]); +} + +#define N 50 +#define BASE1 ((SIGNEDNESS int) -1 < 0 ? -126 : 4) +#define BASE2 ((SIGNEDNESS int) -1 < 0 ? -101 : 26) +#define CONST1 0x01AB +#define CONST2 0x01CD + +int +main (void) +{ + check_vect (); + + SIGNEDNESS short a[N], b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE1 + i * CONST1; + c[i] = BASE2 + i * CONST2; + asm volatile ("" ::: "memory"); + } + f (a, b, c, N); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != HRS(BASE1 * BASE2 + i * i * (CONST1 * CONST2) + + i * (BASE1 * CONST2 + BASE2 * CONST1))) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vect_recog_mulhs_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.MULHS} "vect" { target vect_mulhrs_hi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_mulhrs_hi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-2.c new file mode 100644 index 0000000000..a16e71c6a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-2.c @@ -0,0 +1,9 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS unsigned + +#include "vect-mulhrs-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_mulhs_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.MULHS} "vect" { target vect_mulhrs_hi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_mulhrs_hi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-3.c new file mode 100644 index 0000000000..e7d44d75d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-3.c @@ -0,0 +1,9 @@ +/* { dg-require-effective-target vect_int } */ + +#define BIAS 1 + +#include "vect-mulhrs-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_mulhs_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.MULHRS} "vect" { target vect_mulhrs_hi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_mulhrs_hi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-4.c new file mode 100644 index 0000000000..e121763352 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-mulhrs-4.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS unsigned +#define BIAS 1 + +#include "vect-mulhrs-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_mulhs_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump {\.MULHRS} "vect" { target vect_mulhrs_hi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_mulhrs_hi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-mult-const-pattern-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-mult-const-pattern-1.c new file mode 100644 index 0000000000..1e90d19a68 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-mult-const-pattern-1.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) void +foo (long long *arr) +{ + for (int i = 0; i < N; i++) + arr[i] *= 123; +} + +int +main (void) +{ + check_vect (); + long long data[N]; + int i; + + for (i = 0; i < N; i++) + { + data[i] = i; + __asm__ volatile (""); + } + + foo (data); +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (data[i] / 123 != i) + __builtin_abort (); + __asm__ volatile (""); + } + + return 0; +} + +/* { dg-final { scan-tree-dump {vect_recog_mult_pattern: detected:[^\n]* \* 123} "vect" { target aarch64*-*-* xfail aarch64_sve } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-mult-const-pattern-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-mult-const-pattern-2.c new file mode 100644 index 0000000000..f19829b55a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-mult-const-pattern-2.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) void +foo (long long *arr) +{ + for (int i = 0; i < N; i++) + arr[i] *= -19594LL; +} + +int +main (void) +{ + check_vect (); + long long data[N]; + int i; + + for (i = 0; i < N; i++) + { + data[i] = i; + __asm__ volatile (""); + } + + foo (data); +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (data[i] / -19594LL != i) + __builtin_abort (); + __asm__ volatile (""); + } + + return 0; +} + +/* { dg-final { scan-tree-dump {vect_recog_mult_pattern: detected:[^\n]* \* -19594} "vect" { target aarch64*-*-* xfail aarch64_sve } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-mult-pattern-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-mult-pattern-1.c new file mode 100644 index 0000000000..764d0e34c3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-mult-pattern-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +unsigned long int __attribute__ ((aligned (64)))arr[100]; +int i; + +void test_for_vectorshifts_via_mul_with_power2_const () +{ + for (i=0; i<=99; i++) + arr[i] = arr[i] * 4; +} + +void test_for_vectorshifts_via_mul_with_negative_power2_const () +{ + for (i=0; i<=99; i++) + arr[i] = arr[i] * (-4); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" {target { ! { vect_int_mult } } } } } */ +/* { dg-final { scan-tree-dump-times "vect_recog_mult_pattern: detected" 2 "vect" {target { ! { vect_int_mult } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-mult-pattern-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-mult-pattern-2.c new file mode 100644 index 0000000000..77e8cff792 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-mult-pattern-2.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +unsigned long int __attribute__ ((aligned (64)))arr[100]; +int i; + +void negative_test_for_vectorshifts_via_mul_with_const () +{ + for (i=0; i<=99; i++) + arr[i] = arr[i] * 123; +} + +void negative_test_for_vectorshifts_via_mul_with_negative_const () +{ + for (i=0; i<=99; i++) + arr[i] = arr[i] * (-123); +} + +void negative_test_for_vectorshifts_via_mul_with_varable (int x) +{ + for (i=0; i<=99; i++) + arr[i] = arr[i] * x; +} + + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 3 "vect" {target { ! { vect_int_mult } } } } } */ +/* { dg-final { scan-tree-dump-not "vect_recog_mult_pattern: detected" "vect" {target { ! { vect_int_mult } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-multi-peel-gaps.c b/SingleSource/Regression/C/gcc-dg/vect/vect-multi-peel-gaps.c new file mode 100644 index 0000000000..7e7db3c7a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-multi-peel-gaps.c @@ -0,0 +1,63 @@ +/* For some targets we end up vectorizing the below loop such that the `sp` + single integer is loaded into a 4 integer vector. + While the writes are all safe, without 2 scalar loops being peeled into the + epilogue we would read past the end of the 31 integer array. This happens + because we load a 4 integer chunk to only use the first integer and + increment by 2 integers at a time, hence the last load needs s[30-33] and + the penultimate load needs s[28-31]. + This testcase ensures that we do not crash due to that behaviour. */ +/* { dg-require-effective-target mmap } */ +#include +#include +#include "tree-vect.h" + +#define MMAP_SIZE 0x20000 +#define ADDRESS 0x1122000000 + +#define MB_BLOCK_SIZE 16 +#define VERT_PRED_16 0 +#define HOR_PRED_16 1 +#define DC_PRED_16 2 +int *sptr; +extern void intrapred_luma_16x16(); +unsigned short mprr_2[5][16][16]; +void initialise_s(int *s) { } +int main() { + void *s_mapping; + void *end_s; + check_vect (); + s_mapping = mmap ((void *)ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (s_mapping == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + end_s = (s_mapping + MMAP_SIZE); + sptr = (int*)(end_s - sizeof(int[31])); + intrapred_luma_16x16(sptr); + return 0; +} + +void intrapred_luma_16x16(int * restrict sp) { + for (int j=0; j < MB_BLOCK_SIZE; j++) + { + mprr_2[VERT_PRED_16][j][0]=sp[j*2]; + mprr_2[VERT_PRED_16][j][1]=sp[j*2]; + mprr_2[VERT_PRED_16][j][2]=sp[j*2]; + mprr_2[VERT_PRED_16][j][3]=sp[j*2]; + mprr_2[VERT_PRED_16][j][4]=sp[j*2]; + mprr_2[VERT_PRED_16][j][5]=sp[j*2]; + mprr_2[VERT_PRED_16][j][6]=sp[j*2]; + mprr_2[VERT_PRED_16][j][7]=sp[j*2]; + mprr_2[VERT_PRED_16][j][8]=sp[j*2]; + mprr_2[VERT_PRED_16][j][9]=sp[j*2]; + mprr_2[VERT_PRED_16][j][10]=sp[j*2]; + mprr_2[VERT_PRED_16][j][11]=sp[j*2]; + mprr_2[VERT_PRED_16][j][12]=sp[j*2]; + mprr_2[VERT_PRED_16][j][13]=sp[j*2]; + mprr_2[VERT_PRED_16][j][14]=sp[j*2]; + mprr_2[VERT_PRED_16][j][15]=sp[j*2]; + } +} +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" {target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-1.c new file mode 100644 index 0000000000..06dbb427ea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-1.c @@ -0,0 +1,96 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define NSHORTS (VECTOR_BITS / 16) +#else +#define NSHORTS 8 +#endif + +#define NINTS (NSHORTS / 2) +#define N (NSHORTS * 4) + +short sa[N]; +short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +int ia[N]; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Current peeling-for-alignment scheme will consider the 'sa[i+7]' + access for peeling, and therefore will examine the option of + using a peeling factor = V-7%V = 1,3 for V=8,4 respectively, + which will also align the access to 'ia[i+3]', and the loop could be + vectorized on all targets that support unaligned loads. */ + +__attribute__ ((noinline)) int main1 (int n) +{ + int i; + + /* Multiple types with different sizes, used in idependent + copmutations. Vectorizable. */ + for (i = 0; i < n; i++) + { + sa[i + NSHORTS - 1] = sb[i]; + ia[i + NINTS - 1] = ib[i + 1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (sa[i + NSHORTS - 1] != sb[i] || ia[i + NINTS - 1] != ib[i + 1]) + abort (); + } + + return 0; +} + +/* Current peeling-for-alignment scheme will consider the 'ia[i+3]' + access for peeling, and therefore will examine the option of + using a peeling factor = (V-3)%V = 1 for V=2,4. + This will not align the access 'sa[i+3]' (for which we need to + peel 5 iterations). However, 'ia[i+3]' also gets aligned if we peel 5 + iterations, so the loop is vectorizable on all targets that support + unaligned loads. */ + +__attribute__ ((noinline)) int main2 (int n) +{ + int i; + + /* Multiple types with different sizes, used in independent + copmutations. */ + for (i = 0; i < n; i++) + { + ia[i + NINTS - 1] = ib[i]; + sa[i + NINTS - 1] = sb[i + 1]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (sa[i + NINTS - 1] != sb[i + 1] || ia[i + NINTS - 1] != ib[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N - NSHORTS + 1); + main2 (N - NINTS + 1); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail { { ! vect_unaligned_possible } || vect_sizes_32B_16B } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { target { vect_no_align && { { ! vect_hw_misalign } && vect_sizes_32B_16B } } }} } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-10.c new file mode 100644 index 0000000000..c47cf8c11d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-10.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +unsigned char uX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned short uY[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned int uresult[N]; +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int result[N]; + +/* Unsigned type promotion (hi->si) */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; isi) */ +__attribute__ ((noinline)) int +foo2(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +short x[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) int +foo (int len, int *z) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +char x[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) int +foo (int len, int *z) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char uX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned int uresult[N]; +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int result[N]; + +/* Unsigned type promotion (qi->si) */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; isi) */ +__attribute__ ((noinline)) int +foo2(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char uX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned char uresultX[N]; +unsigned int uY[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned char uresultY[N]; + +/* Unsigned type demotion (si->qi) */ + +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +#define DOT1 43680 +#define DOT2 -20832 + +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned char CX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo1(int len) { + int i; + int result1 = 0; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +char x[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; + +__attribute__ ((noinline)) int +foo (int len, long long *z) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char uX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; +unsigned char uresultX[N]; +unsigned long long uY[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; +unsigned char uresultY[N]; + +/* Unsigned type demotion (si->qi) */ + +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 32 + +int ia[N]; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +short sa[N]; +short sb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +char ca[N]; +char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) int main1 () +{ + int i; + + /* Multiple types with different sizes, used in independent + cmputations. Vectorizable. All accesses aligned. */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i]; + sa[i] = sb[i]; + ca[i] = cb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i] + || sa[i] != sb[i] + || ca[i] != cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-3.c new file mode 100644 index 0000000000..04b144c869 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-3.c @@ -0,0 +1,66 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options double_vectors } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 8) +#else +#define N 32 +#endif + +int ib[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +short sb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +char cb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 (int n, int * __restrict__ pib, + short * __restrict__ psb, + char * __restrict__ pcb) +{ + int i; + int ia[N]; + short sa[N]; + char ca[N]; + + /* Multiple types with different sizes, used in independent + computations. Vectorizable. The loads are misaligned. */ + for (i = 0; i < n; i++) + { + ia[i] = pib[i]; + sa[i] = psb[i]; + ca[i] = pcb[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (ia[i] != pib[i] + || sa[i] != psb[i] + || ca[i] != pcb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N, ib, sb, cb); + main1 (N-3, ib, sb, &cb[2]); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { xfail { ! { vect_unaligned_possible && vect_align_stack_vars } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-4.c new file mode 100644 index 0000000000..18ab953867 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-4.c @@ -0,0 +1,104 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 32 + +unsigned short sa[N]; +unsigned short sc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +unsigned short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; +unsigned int ia[N]; +unsigned int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +unsigned int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Current peeling-for-alignment scheme will consider the 'sa[i+7]' + access for peeling, and therefore will examine the option of + using a peeling factor = VF-7%VF. This will result in a peeling factor 1, + which will also align the access to 'ia[i+3]', and the loop could be + vectorized on all targets that support unaligned loads. + Without cost model on targets that support misaligned stores, no peeling + will be applied since we want to keep the four loads aligned. */ + +__attribute__ ((noinline)) +int main1 (int n) +{ + int i; + + /* Multiple types with different sizes, used in independent + copmutations. Vectorizable. */ + for (i = 0; i < n; i++) + { + sa[i+7] = sb[i] + sc[i]; + ia[i+3] = ib[i] + ic[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (sa[i+7] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i]) + abort (); + } + + return 0; +} + +/* Current peeling-for-alignment scheme will consider the 'ia[i+3]' + access for peeling, and therefore will examine the option of + using a peeling factor = VF-3%VF. This will result in a peeling factor + 1 if VF=4,2. This will not align the access to 'sa[i+3]', for which we + need to peel 5,1 iterations for VF=4,2 respectively, so the loop can not + be vectorized. However, 'ia[i+3]' also gets aligned if we peel 5 + iterations, so the loop is vectorizable on all targets that support + unaligned loads. + Without cost model on targets that support misaligned stores, no peeling + will be applied since we want to keep the four loads aligned. */ + +__attribute__ ((noinline)) +int main2 (int n) +{ + int i; + + /* Multiple types with different sizes, used in independent + copmutations. Vectorizable. */ + for (i = 0; i < n; i++) + { + ia[i+3] = ib[i] + ic[i]; + sa[i+3] = sb[i] + sc[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (sa[i+3] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N-7); + main2 (N-3); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" { target { vect_element_align} } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail { vect_no_align || vect_element_align } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 8 "vect" { target { ! vect_element_align } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { target { vect_element_align } xfail { ! vect_unaligned_possible } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-5.c new file mode 100644 index 0000000000..7c54479db1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-5.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +unsigned int ia[N]; +unsigned int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned short sa[N]; +unsigned short sc[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned short sb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned char ca[N]; +unsigned char cc[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + /* Multiple types with different sizes, used in independent + computations. Vectorizable. All accesses aligned. */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i] + ic[i]; + sa[i] = sb[i] + sc[i]; + ca[i] = cb[i] + cc[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i] + ic[i] + || sa[i] != sb[i] + sc[i] + || ca[i] != cb[i] + cc[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { sparc*-*-* && ilp32 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-6.c new file mode 100644 index 0000000000..73d3b30384 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-6.c @@ -0,0 +1,73 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options double_vectors } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 8) +#else +#define N 32 +#endif + +unsigned int ic[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned int ib[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned short sc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned short sb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned char cc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned char cb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 (int n, + unsigned int * __restrict__ pic, unsigned int * __restrict__ pib, + unsigned short * __restrict__ psc, unsigned short * __restrict__ psb, + unsigned char * __restrict__ pcc, unsigned char * __restrict__ pcb) +{ + int i; + unsigned int ia[N]; + unsigned short sa[N]; + unsigned char ca[N]; + + /* Multiple types with different sizes, used in independent + computations. Vectorizable. The loads are misaligned. */ + for (i = 0; i < n; i++) + { + ia[i] = pib[i] + pic[i]; + sa[i] = psb[i] + psc[i]; + ca[i] = pcb[i] + pcc[i]; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (ia[i] != pib[i] + pic[i] + || sa[i] != psb[i] + psc[i] + || ca[i] != pcb[i] + pcc[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N, ic, ib, sc, sb, cc, cb); + main1 (N-3, ic, ib, &sc[1], sb, cc, &cb[2]); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { sparc*-*-* && ilp32 } }} } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 6 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 6 "vect" { xfail { ! { vect_unaligned_possible && vect_align_stack_vars } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-7.c new file mode 100644 index 0000000000..c3ef4d4948 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-multitypes-7.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +#define DOT1 43680 +#define DOT2 -20832 + +signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned char CX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo1(int len) { + int i; + int result1 = 0; + short prod; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char uX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned char uresultX[N]; +unsigned int uY[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned short uresultY[N]; + +/* Unsigned type demotion (si->hi) */ + +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char uX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned short uresult[N]; +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +short result[N]; + +/* Unsigned type promotion (qi->hi) */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; ihi) */ +__attribute__ ((noinline)) int +foo2(int len) { + int i; + + for (i=0; i=0; i--) { + x[i] = 1234; + } +} + +int main (void) +{ + short x[128 + 32]; + int i; + + check_vect (); + + for (i = 0; i < 16; i ++) + { + asm (""); + x[i] = x[i + 144] = 5678; + } + + test1 (x + 16); + +#pragma GCC novector + for (i = 0; i < 128; i++) + if (x[i + 16] != 1234) + abort (); + +#pragma GCC novector + for (i = 0; i < 16; i++) + if (x[i] != 5678 + || x[i + 144] != 5678) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-neg-store-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-neg-store-2.c new file mode 100644 index 0000000000..95b1619600 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-neg-store-2.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +extern void abort (void); + +__attribute__((noinline, noclone)) +void test1(short x[128], short D) +{ + int i; + for (i=127; i>=0; i--) { + x[i] = D; + } +} + +int main (void) +{ + short x[128 + 32]; + int i; + + check_vect (); + + for (i = 0; i < 16; i ++) + { + asm (""); + x[i] = x[i + 144] = 5678; + } + + test1 (x + 16, 1234); + +#pragma GCC novector + for (i = 0; i < 128; i++) + if (x[i + 16] != 1234) + abort (); + +#pragma GCC novector + for (i = 0; i < 16; i++) + if (x[i] != 5678 + || x[i + 144] != 5678) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-1.c new file mode 100644 index 0000000000..129dab2ba1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-1.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float in[N] = {232,132,32,432,532,321,327,323,321,324,322,329,432,832,932,232}; +float out[N]; +float check_res[N] = {112,-4,-120,264,348,121,111,91,73,60,42,33,120,504,588,-128}; +float a[2*N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) void +foo () +{ + int i, j; + float res; + + for (i = 0; i < N; i++) + { + res = in[i]; + + for (j = 0; j < N; j++) + res = res - a[i+j]; + + out[i] = res; + } + +#pragma GCC novector + for (i = 0; i < N; i++) + if (out[i] != check_res[i]) + abort (); + +} + +int main () +{ + check_vect (); + + foo(); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-2.c new file mode 100644 index 0000000000..26ad6fa65c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-2.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float out[N]; +float check_res[N] = {880,864,848,832,816,800,784,768,752,736,720,704,688,672,656,640}; +float a[2*N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) void +foo () +{ + int i, j; + float res; + + for (i = 0; i < N; i++) + { + res = 1000; + + for (j = 0; j < N; j++) + res = res - a[i+j]; + + out[i] = res; + } + +#pragma GCC novector + for (i = 0; i < N; i++) + if (out[i] != check_res[i]) + abort (); + +} + +int main () +{ + check_vect (); + + foo(); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-3.c new file mode 100644 index 0000000000..4e3b8343ff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-nest-cycle-3.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 82 + +float c[N][N], b[N][N], a[N]; + +__attribute__ ((noinline)) int +main1 () +{ + int i, j; + float diff; + + /* In inner loop vectorization -funsafe-math-optimizations is needed to + vectorize the summation. But in outer loop vectorization the order of + calculation doesn't change, therefore, there is no need in that flag. */ + for (i = 0; i < N; i++) + { + diff = 2; + for (j = 0; j < N; j++) + diff += (b[j][i] - c[j][i]); + + a[i] = diff; + } + + /* Check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != DIFF) + abort (); + + return 0; +} + +int main (void) +{ + int i, j; + + check_vect (); + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + b[i][j] = i+j+5; + c[i][j] = i+j; + } + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-nop-move.c b/SingleSource/Regression/C/gcc-dg/vect/vect-nop-move.c new file mode 100644 index 0000000000..2b295ed052 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-nop-move.c @@ -0,0 +1,77 @@ +/* { dg-require-effective-target vect_float } */ + +#include "tree-vect.h" + +extern void abort (void); + +#define NOINLINE __attribute__((noinline)) + +typedef float float32x4_t __attribute__ ((__vector_size__ (16))); +typedef float float32x2_t __attribute__ ((__vector_size__ (8))); + +NOINLINE float +foo32x4_be (float32x4_t x) +{ + return x[3]; +} + +NOINLINE float +foo32x4_le (float32x4_t x) +{ + return x[0]; +} + +NOINLINE float +bar (float a) +{ + return a; +} + +NOINLINE float +foo32x2_be (float32x2_t x) +{ +#ifdef __i386__ + /* ix86 passes float32x2 vector arguments in mmx registers. We need to + emit emms to empty MMS state and reenable x87 stack before float value + can be loaded to and passed in x87 floating-point return register. */ + __builtin_ia32_emms (); +#endif + return bar (x[1]); +} + +NOINLINE float +foo32x2_le (float32x2_t x) +{ +#ifdef __i386__ + __builtin_ia32_emms (); +#endif + return bar (x[0]); +} + +NOINLINE int +test (void) +{ + float32x4_t a = { 0.0f, 1.0f, 2.0f, 3.0f }; + float32x2_t b = { 0.0f, 1.0f }; + + if (foo32x2_be (b) != 1.0f) + abort (); + + if (foo32x2_le (b) != 0.0f) + abort (); + + if (foo32x4_be (a) != 3.0f) + abort (); + + if (foo32x4_le (a) != 0.0f) + abort (); + + return 0; +} + +int +main () +{ + check_vect (); + return test (); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-novector-pragma.c b/SingleSource/Regression/C/gcc-dg/vect/vect-novector-pragma.c new file mode 100644 index 0000000000..3c0b8f5d2a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-novector-pragma.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void f1 (int * restrict a, int * restrict b, int n) +{ +#pragma GCC novector + for (int i = 0; i < (n & -8); i++) + a[i] += b[i]; +} + +void f2 (int * restrict a, int * restrict b, int n) +{ +#pragma GCC novector +#pragma GCC ivdep +#pragma GCC unroll 2 + for (int i = 0; i < (n & -8); i++) + a[i] += b[i]; +} + +void f3 (int * restrict a, int * restrict b, int n) +{ +#pragma GCC ivdep +#pragma GCC novector +#pragma GCC unroll 2 + for (int i = 0; i < (n & -8); i++) + a[i] += b[i]; +} + +void f4 (int * restrict a, int * restrict b, int n) +{ +#pragma GCC ivdep +#pragma GCC unroll 2 +#pragma GCC novector + for (int i = 0; i < (n & -8); i++) + a[i] += b[i]; +} + +void f5 (int * restrict a, int * restrict b, int n) +{ + int i = 0; +#pragma GCC novector + do + { + a[i] += b[i]; + i++; + } + while (i < (n & -8)); +} + +void f6 (int * restrict a, int * restrict b, int n) +{ + int i = 0; +#pragma GCC novector + while (i < (n & -8)) + { + a[i] += b[i]; + i++; + } +} + +/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-ooo-group-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-ooo-group-1.c new file mode 100644 index 0000000000..416198354f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-ooo-group-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +void +f (int *restrict a, int *restrict b, int *restrict c) +{ + for (int i = 0; i < 100; ++i) + if (c[i]) + { + a[i * 2] = b[i * 5 + 2]; + a[i * 2 + 1] = b[i * 5]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1-big-array.c new file mode 100644 index 0000000000..63918adfe2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1-big-array.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +#define N 256 +signed short image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short block[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short out[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* Can't do outer-loop vectorization because of non-consecutive access. */ + +void +foo (){ + int i,j; + int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j+=8) { + diff += (image[i][j] - block[i][j]); + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "grouped access in outer loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1.c new file mode 100644 index 0000000000..b1bcbc28dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +#define N 64 +signed short image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short block[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short out[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* Can't do outer-loop vectorization because of non-consecutive access. */ + +void +foo (){ + int i,j; + int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j+=8) { + diff += (image[i][j] - block[i][j]); + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "grouped access in outer loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1a-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1a-big-array.c new file mode 100644 index 0000000000..98dfcfbc10 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1a-big-array.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +#define N 256 +signed short image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short block[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* Can't do outer-loop vectorization because of non-consecutive access. */ + +int +foo (){ + int i,j; + int diff = 0; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j+=8) { + diff += (image[i][j] - block[i][j]); + } + } + return diff; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "grouped access in outer loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1a.c new file mode 100644 index 0000000000..0200fb45ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1a.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +#define N 64 +signed short image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short block[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* Can't do outer-loop vectorization because of non-consecutive access. */ + +int +foo (){ + int i,j; + int diff = 0; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j+=8) { + diff += (image[i][j] - block[i][j]); + } + } + return diff; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "grouped access in outer loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1b-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1b-big-array.c new file mode 100644 index 0000000000..fda70f7cb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1b-big-array.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +#define N 160 +signed short image[N][N]; +signed short block[N][N]; +signed short out[N]; + +/* Outer-loop cannot get vectorized because of non-consecutive access. */ + +void +foo (){ + int i,j; + int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j+=4) { + diff += (image[i][j] - block[i][j]); + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "grouped access in outer loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1b.c new file mode 100644 index 0000000000..e157f7395f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-1b.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +#define N 40 +signed short image[N][N]; +signed short block[N][N]; +signed short out[N]; + +/* Outer-loop cannot get vectorized because of non-consecutive access. */ + +void +foo (){ + int i,j; + int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j+=4) { + diff += (image[i][j] - block[i][j]); + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "grouped access in outer loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2-big-array.c new file mode 100644 index 0000000000..32c40fb76e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2-big-array.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_intfloat_cvt } */ +#include +#include "tree-vect.h" + +#define N 160 +float image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float out[N]; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + image[j][i] = j+i; + } + } +} + +int main (void) +{ + check_vect (); + int i, j; + + foo (); + + for (i = 0; i < N; i++) { +#pragma GCC novector + for (j = 0; j < N; j++) { + if (image[j][i] != j+i) + abort (); + } + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2.c new file mode 100644 index 0000000000..a0a419c154 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_intfloat_cvt } */ +#include +#include "tree-vect.h" + +#define N 40 +float image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float out[N]; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + image[j][i] = j+i; + } + } +} + +int main (void) +{ + check_vect (); + int i, j; + + foo (); + + for (i = 0; i < N; i++) { +#pragma GCC novector + for (j = 0; j < N; j++) { + if (image[j][i] != j+i) + abort (); + } + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2a-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2a-big-array.c new file mode 100644 index 0000000000..5ca835a2dd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-2a-big-array.c @@ -0,0 +1,42 @@ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_intfloat_cvt } */ +#include +#include "tree-vect.h" + +#define N 160 +float image[N][N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo (){ + int i,j,k; + + for (k=0; k +#include "tree-vect.h" + +#define N 40 +float image[N][N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo (){ + int i,j,k; + + for (k=0; k +#include "tree-vect.h" + +#define N 40 +float image[2*N][N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo (){ + int i,j,k; + + for (k=0; k +#include "tree-vect.h" + +#define N 160 +float image[2*N][2*N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo (){ + int i,j,k; + + for (k=0; k +#include "tree-vect.h" + +#define N 40 +float image[2*N][2*N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo (){ + int i,j,k; + + for (k=0; k +#include "tree-vect.h" + +#define N 40 +float image[N][N][N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +__attribute__ ((noinline)) void +foo (){ + int i,j,k; + + for (k=0; k +#include "tree-vect.h" + +#define N 320 +float image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float out[N]; + +/* Outer-loop vectoriation. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][i]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + image[i][j]=i+j; + } + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][i]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3.c new file mode 100644 index 0000000000..c51787fe57 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_float } */ +#include +#include "tree-vect.h" + +#define N 40 +float image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float out[N]; + +/* Outer-loop vectoriation. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][i]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + image[i][j]=i+j; + } + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][i]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3a-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3a-big-array.c new file mode 100644 index 0000000000..7ae931e39b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3a-big-array.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_float } */ +#include +#include "tree-vect.h" + +#define N 320 +float image[N][N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float out[N]; + +/* Outer-loop vectorization with misaliged accesses in the inner-loop. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][i]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + image[i][j]=i+j; + } + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][i]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "step doesn't divide the vector alignment" 1 "vect" { xfail vect_element_align_preferred } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3a.c new file mode 100644 index 0000000000..bfadac0c5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3a.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_float } */ +#include +#include "tree-vect.h" + +#define N 40 +float image[N][N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float out[N]; + +/* Outer-loop vectorization with misaliged accesses in the inner-loop. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][i]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + image[i][j]=i+j; + } + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][i]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "step doesn't divide the vector alignment" 1 "vect" { xfail vect_element_align_preferred } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3b.c new file mode 100644 index 0000000000..1e2bbf1e7b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3b.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_float } */ +#include +#include "tree-vect.h" + +#define N 40 +float image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float out[N]; + +/* Outer-loop vectorization with non-consecutive access. Not vectorized yet. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N/2; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][2*i]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + image[i][j]=i+j; + } + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N/2; i++) { + diff = 0; + for (j = 0; j < N; j++) { + diff += image[j][2*i]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "grouped access in outer loop" 2 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3c.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3c.c new file mode 100644 index 0000000000..952bba4d91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-3c.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_float } */ +#include +#include "tree-vect.h" + +#define N 40 +float image[N][N+1] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float out[N]; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j+=4) { + diff += image[j][i]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < N; i++) { + for (j = 0; j < N; j++) { + image[i][j]=i+j; + } + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < N; j+=4) { + diff += image[j][i]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4.c new file mode 100644 index 0000000000..8a803cd330 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 40 +#define M 128 +float in[N+M]; +float coeff[M]; +float out[N]; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=4) { + diff += in[j+i]*coeff[j]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < M; i++) + coeff[i] = i; + for (i = 0; i < N+M; i++) + in[i] = i; + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=4) { + diff += in[j+i]*coeff[j]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "zero step in outer loop." 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4a-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4a-big-array.c new file mode 100644 index 0000000000..b0d9a4bf74 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4a-big-array.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +#define N 512 +#define M 1024 +signed short in[N+M]; +signed short coeff[M]; +signed short out[N]; + +/* Outer-loop vectorization. */ + +void +foo (){ + int i,j; + int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]*coeff[j]; + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target { vect_widen_mult_hi_to_si && vect_pack_trunc } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4a.c new file mode 100644 index 0000000000..fedc23da48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4a.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +#define N 40 +#define M 128 +signed short in[N+M]; +signed short coeff[M]; +signed short out[N]; + +/* Outer-loop vectorization. */ + +void +foo (){ + int i,j; + int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]*coeff[j]; + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target { vect_widen_mult_hi_to_si && vect_pack_trunc } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4b-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4b-big-array.c new file mode 100644 index 0000000000..3c16fce829 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4b-big-array.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +#define N 320 +#define M 1024 +signed short in[N+M]; +signed short coeff[M]; +int out[N]; + +/* Outer-loop vectorization. */ + +void +foo (){ + int i,j; + int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]*coeff[j]; + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target vect_widen_mult_hi_to_si } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4b.c new file mode 100644 index 0000000000..df2528081d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4b.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +#define N 40 +#define M 128 +signed short in[N+M]; +signed short coeff[M]; +int out[N]; + +/* Outer-loop vectorization. */ + +void +foo (){ + int i,j; + int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]*coeff[j]; + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target vect_widen_mult_hi_to_si } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4c-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4c-big-array.c new file mode 100644 index 0000000000..5c3eea9547 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4c-big-array.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#define N 320 +#define M 1024 +unsigned short in[N+M]; +unsigned short coeff[M]; +unsigned int out[N]; + +/* Outer-loop vectorization. */ + +void +foo (){ + int i,j; + unsigned short diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]*coeff[j]; + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target { vect_short_mult && { ! vect_no_align } } } } } */ +/* { dg-final { scan-tree-dump-times "zero step in outer loop.(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4c.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4c.c new file mode 100644 index 0000000000..f30f251cbf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4c.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +#define N 40 +#define M 128 +unsigned short in[N+M]; +unsigned short coeff[M]; +unsigned int out[N]; + +/* Outer-loop vectorization. */ + +void +foo (){ + int i,j; + unsigned short diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]*coeff[j]; + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target { vect_short_mult && { ! vect_no_align } } } } } */ +/* { dg-final { scan-tree-dump "zero step in outer loop." "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4d-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4d-big-array.c new file mode 100644 index 0000000000..587eabaf00 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4d-big-array.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 320 +#define M 1024 +float in[N+M]; +float out[N]; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=4) { + diff += in[j+i]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < N; i++) + in[i] = i; + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=4) { + diff += in[j+i]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4d.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4d.c new file mode 100644 index 0000000000..0c9115f60a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4d.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 40 +#define M 128 +float in[N+M]; +float out[N]; + +/* Outer-loop vectorization. */ + +__attribute__ ((noinline)) void +foo (){ + int i,j; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=4) { + diff += in[j+i]; + } + out[i]=diff; + } +} + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < N; i++) + in[i] = i; + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=4) { + diff += in[j+i]; + } + if (out[i] != diff) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4e.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4e.c new file mode 100644 index 0000000000..cc9e96f5d5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4e.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +#define N 40 +#define M 128 +unsigned int in[N+M]; +unsigned short out[N]; + +/* Outer-loop vectorization. */ + +void +foo (){ + int i,j; + unsigned int diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + out[i]=(unsigned short)diff; + } + + return; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { ! { aarch64*-*-* riscv*-*-* } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4f.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4f.c new file mode 100644 index 0000000000..c903dc9bfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4f.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ +#include +#include "tree-vect.h" + +#define N 96 +#define M 128 +unsigned short in[N+M]; +unsigned int out[N]; +unsigned char arr[N]; + +/* Outer-loop vectorization. */ +/* Not vectorized due to multiple-types in the inner-loop. */ + +__attribute__ ((noinline)) unsigned int +foo (){ + int i,j; + unsigned int diff; + unsigned int s=0; + + for (i = 0; i < N; i++) { + arr[i] = 3; + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s+=diff; + } + return s; +} + +__attribute__ ((noinline)) unsigned int +bar (int i, unsigned int diff, unsigned short *in) +{ + int j; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + return diff; +} + +int main (void) +{ + int i, j; + unsigned int diff; + unsigned int s=0,sum=0; + + check_vect (); + + for (i = 0; i < N+M; i++) { + in[i] = i; + } + + sum=foo (); + + for (i = 0; i < N; i++) { + arr[i] = 3; + diff = 0; + diff = bar (i, diff, in); + s += diff; + } + + if (s != sum) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { ! { aarch64*-*-* riscv*-*-* } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4g.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4g.c new file mode 100644 index 0000000000..c903dc9bfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4g.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ +#include +#include "tree-vect.h" + +#define N 96 +#define M 128 +unsigned short in[N+M]; +unsigned int out[N]; +unsigned char arr[N]; + +/* Outer-loop vectorization. */ +/* Not vectorized due to multiple-types in the inner-loop. */ + +__attribute__ ((noinline)) unsigned int +foo (){ + int i,j; + unsigned int diff; + unsigned int s=0; + + for (i = 0; i < N; i++) { + arr[i] = 3; + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s+=diff; + } + return s; +} + +__attribute__ ((noinline)) unsigned int +bar (int i, unsigned int diff, unsigned short *in) +{ + int j; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + return diff; +} + +int main (void) +{ + int i, j; + unsigned int diff; + unsigned int s=0,sum=0; + + check_vect (); + + for (i = 0; i < N+M; i++) { + in[i] = i; + } + + sum=foo (); + + for (i = 0; i < N; i++) { + arr[i] = 3; + diff = 0; + diff = bar (i, diff, in); + s += diff; + } + + if (s != sum) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { ! { aarch64*-*-* riscv*-*-* } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4i.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4i.c new file mode 100644 index 0000000000..934eddb5d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4i.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 96 +#define M 128 +unsigned char in[N+M]; +unsigned short out[N]; + +/* Outer-loop vectorization. */ +/* Multiple-types in the inner-loop. */ + +__attribute__ ((noinline)) +unsigned short +foo (){ + int i,j; + unsigned short diff; + unsigned short s=0; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s+=diff; + } + return s; +} + +int main (void) +{ + check_vect (); + int i; + unsigned short s; + + for (i = 0; i < N+M; i++) + in[i] = (unsigned char)i; + + s = foo (); + + if (s != 34048) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target vect_unpack } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4j.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4j.c new file mode 100644 index 0000000000..fcfec3cf29 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4j.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +#define N 96 +#define M 128 +unsigned char in[N+M]; +unsigned short out[N]; + +/* Outer-loop vectorization. */ + +void +foo (){ + int i,j; + unsigned short diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + out[i]=diff; + } +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target vect_unpack } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4k.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4k.c new file mode 100644 index 0000000000..c903dc9bfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4k.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ +#include +#include "tree-vect.h" + +#define N 96 +#define M 128 +unsigned short in[N+M]; +unsigned int out[N]; +unsigned char arr[N]; + +/* Outer-loop vectorization. */ +/* Not vectorized due to multiple-types in the inner-loop. */ + +__attribute__ ((noinline)) unsigned int +foo (){ + int i,j; + unsigned int diff; + unsigned int s=0; + + for (i = 0; i < N; i++) { + arr[i] = 3; + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s+=diff; + } + return s; +} + +__attribute__ ((noinline)) unsigned int +bar (int i, unsigned int diff, unsigned short *in) +{ + int j; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + return diff; +} + +int main (void) +{ + int i, j; + unsigned int diff; + unsigned int s=0,sum=0; + + check_vect (); + + for (i = 0; i < N+M; i++) { + in[i] = i; + } + + sum=foo (); + + for (i = 0; i < N; i++) { + arr[i] = 3; + diff = 0; + diff = bar (i, diff, in); + s += diff; + } + + if (s != sum) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { ! { aarch64*-*-* riscv*-*-* } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4l.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4l.c new file mode 100644 index 0000000000..a63b9332af --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4l.c @@ -0,0 +1,68 @@ +/* { dg-require-effective-target vect_int } */ +#include +#include "tree-vect.h" + +#define N 96 +#define M 128 +unsigned short in[N+M]; +unsigned int out[N]; +unsigned char arr[N]; + +/* Outer-loop vectorization. */ +/* Not vectorized due to multiple-types in the inner-loop. */ + +__attribute__ ((noinline)) unsigned int +foo (){ + int i,j; + unsigned int diff; + unsigned int s=0; + + for (i = 0; i < N; i++) { + arr[i] = 3; + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s+=diff; + } + return s; +} + +__attribute__ ((noinline)) unsigned int +bar (int i, unsigned int diff, unsigned short *in) +{ + int j; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + return diff; +} + +int main (void) +{ + int i, j; + unsigned int diff; + unsigned int s=0,sum=0; + + check_vect (); + + for (i = 0; i < N+M; i++) { + in[i] = i; + } + + sum=foo (); + + for (i = 0; i < N; i++) { + arr[i] = 3; + diff = 0; + diff = bar (i, diff, in); + s += diff; + } + + if (s != sum) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { ! { aarch64*-*-* riscv*-*-* } } } } }*/ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4m-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4m-big-array.c new file mode 100644 index 0000000000..e99ce0f572 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4m-big-array.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ +#include +#include "tree-vect.h" + +#define N 320 +#define M 1024 +unsigned short in[N+M]; +unsigned int out[N]; + +/* Outer-loop vectorization. */ +/* Not vectorized due to multiple-types in the inner-loop. */ + +__attribute__ ((noinline)) unsigned int +foo (){ + int i,j; + unsigned int diff; + unsigned int s=0; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s+=((unsigned short)diff>>3); + } + return s; +} + +int main (void) +{ + int i, j; + unsigned int diff; + unsigned int s=0,sum=0; + + check_vect (); + + for (i = 0; i < N+M; i++) { + in[i] = i; + } + + sum=foo (); + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s += ((unsigned short)diff>>3); + } + + if (s != sum) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4m.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4m.c new file mode 100644 index 0000000000..d401acef3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-4m.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ +#include +#include "tree-vect.h" + +#define N 40 +#define M 128 +unsigned short in[N+M]; +unsigned int out[N]; + +/* Outer-loop vectorization. */ +/* Not vectorized due to multiple-types in the inner-loop. */ + +__attribute__ ((noinline)) unsigned int +foo (){ + int i,j; + unsigned int diff; + unsigned int s=0; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s+=((unsigned short)diff>>3); + } + return s; +} + +int main (void) +{ + int i, j; + unsigned int diff; + unsigned int s=0,sum=0; + + check_vect (); + + for (i = 0; i < N+M; i++) { + in[i] = i; + } + + sum=foo (); + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j+=8) { + diff += in[j+i]; + } + s += ((unsigned short)diff>>3); + } + + if (s != sum) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-5.c new file mode 100644 index 0000000000..67be075278 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-5.c @@ -0,0 +1,82 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define MAX 42 + +extern void abort(void); + +__attribute__ ((noinline)) +int main1 () +{ + float A[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float B[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float C[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float D[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + float E[4] = {0,480,960,1440}; + float s; + + int i, j; + + for (i = 0; i < N; i++) + { + A[i] = i; + B[i] = i; + C[i] = i; + D[i] = i; + } + + /* Outer-loop 1: Vectorizable with respect to dependence distance. */ + for (i = 0; i < N-20; i++) + { + s = 0; + for (j=0; j +#include "tree-vect.h" + +#define N 64 +#define MAX 42 + +float A[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float B[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float C[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +float D[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +extern void abort(void); + +__attribute__ ((noinline)) +int main1 () +{ + float s; + + int i, j; + + for (i = 0; i < N; i++) + { + s = 0; + for (j = 0; j < N; j += 4) + s += C[j]; + A[i] = s; + } + + return 0; +} + +int main () +{ + int i,j; + float s; + + check_vect (); + + for (i = 0; i < N; i++) + { + A[i] = i; + B[i] = i; + C[i] = i; + D[i] = i; + } + + main1(); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + s = 0; + for (j = 0; j < N; j += 4) + s += C[j]; + if (A[i] != s) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "zero step in outer loop." 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-call-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-call-1.c new file mode 100644 index 0000000000..f26d422053 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-call-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fno-math-errno" } */ + +void +foo (float * __restrict x, float *y, int n, int m) +{ + if (m > 0) + for (int i = 0; i < n; ++i) + { + float tem = x[i], tem1; + for (int j = 0; j < m; ++j) + { + tem += y[j]; + tem1 = tem; + tem = __builtin_sqrtf (tem); + } + x[i] = tem - tem1; + } +} + +/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" { target { vect_call_sqrtf } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-big-array.c new file mode 100644 index 0000000000..8114934ed0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-big-array.c @@ -0,0 +1,74 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 80 +#define M 256 +float in[N+M]; +float coeff[M]; +float out[N]; +float fir_out[N]; + +/* Should be vectorized. Fixed misaligment in the inner-loop. */ +__attribute__ ((noinline)) +void foo (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + out[i] = 0; + } + + for (k = 0; k < 4; k++) { + for (i = 0; i < N; i++) { + diff = 0; + for (j = k; j < M; j+=4) { + diff += in[j+i]*coeff[j]; + } + out[i] += diff; + } + } + +} + +/* Vectorized. Changing misalignment in the inner-loop. */ +__attribute__ ((noinline)) +void fir (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j++) { + diff += in[j+i]*coeff[j]; + } + fir_out[i] = diff; + } +} + + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < M; i++) + coeff[i] = i; + for (i = 0; i < N+M; i++) + in[i] = i; + + foo (); + fir (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + if (out[i] != fir_out[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-lb-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-lb-big-array.c new file mode 100644 index 0000000000..9c4be4b9f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-lb-big-array.c @@ -0,0 +1,78 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 80 +#define M 128 +float in[N+M]; +float coeff[M]; +float out[N]; +float fir_out[N]; + +/* Vectorized. Fixed misaligment in the inner-loop. */ +__attribute__ ((noinline)) +void foo (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + out[i] = 0; + } + + for (k = 0; k < 4; k++) { + for (i = 0; i < N; i++) { + diff = 0; + j = k; + + do { + diff += in[j+i]*coeff[j]; + j+=4; + } while (j < M); + + out[i] += diff; + } + } + +} + +/* Vectorized. Changing misalignment in the inner-loop. */ +__attribute__ ((noinline)) +void fir (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j++) { + diff += in[j+i]*coeff[j]; + } + fir_out[i] = diff; + } +} + + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < M; i++) + coeff[i] = i; + for (i = 0; i < N+M; i++) + in[i] = i; + + foo (); + fir (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + if (out[i] != fir_out[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-lb.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-lb.c new file mode 100644 index 0000000000..4f1ccfccfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir-lb.c @@ -0,0 +1,78 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 40 +#define M 64 +float in[N+M]; +float coeff[M]; +float out[N]; +float fir_out[N]; + +/* Vectorized. Fixed misaligment in the inner-loop. */ +__attribute__ ((noinline)) +void foo (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + out[i] = 0; + } + + for (k = 0; k < 4; k++) { + for (i = 0; i < N; i++) { + diff = 0; + j = k; + + do { + diff += in[j+i]*coeff[j]; + j+=4; + } while (j < M); + + out[i] += diff; + } + } + +} + +/* Vectorized. Changing misalignment in the inner-loop. */ +__attribute__ ((noinline)) +void fir (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j++) { + diff += in[j+i]*coeff[j]; + } + fir_out[i] = diff; + } +} + + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < M; i++) + coeff[i] = i; + for (i = 0; i < N+M; i++) + in[i] = i; + + foo (); + fir (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + if (out[i] != fir_out[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir.c new file mode 100644 index 0000000000..1c68c67385 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-fir.c @@ -0,0 +1,74 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 40 +#define M 128 +float in[N+M]; +float coeff[M]; +float out[N]; +float fir_out[N]; + +/* Should be vectorized. Fixed misaligment in the inner-loop. */ +__attribute__ ((noinline)) +void foo (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + out[i] = 0; + } + + for (k = 0; k < 4; k++) { + for (i = 0; i < N; i++) { + diff = 0; + for (j = k; j < M; j+=4) { + diff += in[j+i]*coeff[j]; + } + out[i] += diff; + } + } + +} + +/* Vectorized. Changing misalignment in the inner-loop. */ +__attribute__ ((noinline)) +void fir (){ + int i,j,k; + float diff; + + for (i = 0; i < N; i++) { + diff = 0; + for (j = 0; j < M; j++) { + diff += in[j+i]*coeff[j]; + } + fir_out[i] = diff; + } +} + + +int main (void) +{ + check_vect (); + int i, j; + float diff; + + for (i = 0; i < M; i++) + coeff[i] = i; + for (i = 0; i < N+M; i++) + in[i] = i; + + foo (); + fir (); + +#pragma GCC novector + for (i = 0; i < N; i++) { + if (out[i] != fir_out[i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-pr69720.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-pr69720.c new file mode 100644 index 0000000000..9ea18eef3f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-pr69720.c @@ -0,0 +1,31 @@ +#include "tree-vect.h" + +extern void abort (void); + +int a[128]; +double b[128] = { 1., 2., 3., 4. }; + +void __attribute__((noinline)) foo() +{ + int i; + for (i = 0; i < 128; ++i) + { + double tem1 = b[i]; + for (int j = 0; j < 32; ++j) + tem1 += 1; + b[i] = tem1; + a[i] = i; + } +} + +int main() +{ + check_vect (); + foo (); + if (b[0] != 33. || b[1] != 34. + || b[2] != 35. || b[3] != 36.) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { target { vect_double && vect_int } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-outer-simd-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-simd-1.c new file mode 100644 index 0000000000..795bff5f3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-outer-simd-1.c @@ -0,0 +1,75 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd -ffast-math" } */ +#include +#include "tree-vect.h" +#define N 64 + +float *px, *py; +float *tx, *ty; +float *x1, *z1, *t1, *t2; + +static void inline bar(const float cx, float cy, + float *vx, float *vy) +{ + int j; + for (j = 0; j < N; ++j) + { + const float dx = cx - px[j]; + const float dy = cy - py[j]; + *vx -= dx * tx[j]; + *vy -= dy * ty[j]; + } +} + +__attribute__((noinline, noclone)) void foo1 () +{ + int i; +#pragma omp simd + for (i=0; i +#include "tree-vect.h" +#define N 64 + +float *px, *py; +float *tx, *ty; +float *x1, *z1, *t1, *t2; + +static void inline bar (const float cx, float cy, + float *vx, float *vy) +{ + int j; + for (j = 0; j < N; ++j) + { + const float dx = cx - px[j]; + const float dy = cy - py[j]; + *vx -= dx * tx[j]; + *vy -= dy * ty[j]; + } +} + +__attribute__((noinline, noclone)) void foo1 (int n) +{ + int i; +#pragma omp simd + for (i=0; i +#include "tree-vect.h" +#define N 64 + +float *px, *py; +float *tx, *ty; +float *x1, *z1, *t1, *t2; +int bound[N]; + +static void inline bar(const float cx, float cy, + float *vx, float *vy, int n) +{ + int j; + for (j = 0; j < n; ++j) + { + const float dx = cx - px[j]; + const float dy = cy - py[j]; + *vx -= dx * tx[j]; + *vy -= dy * ty[j]; + } +} + +__attribute__((noinline, noclone)) void foo1 () +{ + int i; + int n = bound[63]; +#pragma omp simd + for (i=0; i +#include "tree-vect.h" + +#define N 512 + +/* Modified rgb to rgb conversion from FFmpeg. */ +__attribute__ ((noinline)) void +foo (unsigned char *src, unsigned char *dst) +{ + unsigned char *s = src; + unsigned short *d = (unsigned short *)dst; + int i; + + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + *d = ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)); + d++; + } + + s = src; + d = (unsigned short *)dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5))) + abort (); + d++; + } +} + +int main (void) +{ + int i; + unsigned char in[N], out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 5} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-1.c new file mode 100644 index 0000000000..21fbcf4ed7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-1.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 8 / 16) +#else +#define N 64 +#endif + +/* Modified rgb to rgb conversion from FFmpeg. */ +__attribute__ ((noinline)) void +foo (unsigned char *src, unsigned char *dst) +{ + unsigned char *s = src; + unsigned short *d = (unsigned short *)dst; + int i; + + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + *d = ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)); + d++; + } + + s = src; + d = (unsigned short *)dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5))) + abort (); + d++; + } +} + +int main (void) +{ + int i; + unsigned char in[N], out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 5} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-10.c new file mode 100644 index 0000000000..f0140e4ef6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-10.c @@ -0,0 +1,20 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#ifndef SIGNEDNESS +#define SIGNEDNESS unsigned +#define BASE_B 4 +#define BASE_C 40 +#endif + +#include "vect-over-widen-9.c" + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(unsigned char\)} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-11.c new file mode 100644 index 0000000000..1e48dab5cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-11.c @@ -0,0 +1,65 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#ifndef SIGNEDNESS +#define SIGNEDNESS signed +#define BASE_B -128 +#define BASE_C -100 +#endif + +#define N 50 + +/* Both range analysis and backward propagation from the truncation show + that these calculations can be done in SIGNEDNESS short, with "res" + being extended for the store to d[i]. */ +void __attribute__ ((noipa)) +f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b, + SIGNEDNESS char *restrict c, int *restrict d) +{ + for (int i = 0; i < N; ++i) + { + /* Deliberate use of signed >>. */ + int res = b[i] + c[i]; + a[i] = (res + (res >> 1)) >> 2; + d[i] = res; + } +} + +int +main (void) +{ + check_vect (); + + SIGNEDNESS char a[N], b[N], c[N]; + int d[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE_B + i * 5; + c[i] = BASE_C + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c, d); +#pragma GCC novector + for (int i = 0; i < N; ++i) + { + int res = BASE_B + BASE_C + i * 9; + if (a[i] != ((res + (res >> 1)) >> 2)) + __builtin_abort (); + if (d[i] != res) + __builtin_abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(signed char\)} "vect" } } */ +/* { dg-final { scan-tree-dump {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-12.c new file mode 100644 index 0000000000..ddb3bd8c0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-12.c @@ -0,0 +1,20 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#ifndef SIGNEDNESS +#define SIGNEDNESS unsigned +#define BASE_B 4 +#define BASE_C 40 +#endif + +#include "vect-over-widen-11.c" + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(unsigned char\)} "vect" } } */ +/* { dg-final { scan-tree-dump {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-13.c new file mode 100644 index 0000000000..08a65ea551 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-13.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#ifndef SIGNEDNESS +#define SIGNEDNESS signed +#define BASE_B -128 +#define BASE_C -120 +#endif + +#define N 50 + +/* We rely on range analysis to show that these calculations can be done + in SIGNEDNESS short. */ +void __attribute__ ((noipa)) +f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b, + SIGNEDNESS char *restrict c) +{ + for (int i = 0; i < N; ++i) + a[i] = (b[i] + c[i]) / 2; +} + +int +main (void) +{ + check_vect (); + + SIGNEDNESS char a[N], b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE_B + i * 5; + c[i] = BASE_C + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != (BASE_B + BASE_C + i * 9) / 2) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* / 2} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* = \(signed char\)} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-14.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-14.c new file mode 100644 index 0000000000..dfa09f5d2c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-14.c @@ -0,0 +1,19 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#ifndef SIGNEDNESS +#define SIGNEDNESS unsigned +#define BASE_B 4 +#define BASE_C 40 +#endif + +#include "vect-over-widen-13.c" + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* = \(unsigned char\)} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-15.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-15.c new file mode 100644 index 0000000000..bd7acbb613 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-15.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#ifndef SIGNEDNESS +#define SIGNEDNESS signed +#define BASE_B -128 +#define BASE_C -120 +#endif + +#define N 50 + +/* We rely on range analysis to show that these calculations can be done + in SIGNEDNESS short, with the result being extended to int for the + store. */ +void __attribute__ ((noipa)) +f (int *restrict a, SIGNEDNESS char *restrict b, + SIGNEDNESS char *restrict c) +{ + for (int i = 0; i < N; ++i) + a[i] = (b[i] + c[i]) / 2; +} + +int +main (void) +{ + check_vect (); + + int a[N]; + SIGNEDNESS char b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE_B + i * 5; + c[i] = BASE_C + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != (BASE_B + BASE_C + i * 9) / 2) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* / 2} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vect_recog_cast_forwprop_pattern: detected} "vect" } } */ +/* { dg-final { scan-tree-dump {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-16.c new file mode 100644 index 0000000000..4584c586da --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-16.c @@ -0,0 +1,19 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#ifndef SIGNEDNESS +#define SIGNEDNESS unsigned +#define BASE_B 4 +#define BASE_C 40 +#endif + +#include "vect-over-widen-15.c" + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vect_recog_cast_forwprop_pattern: detected} "vect" } } */ +/* { dg-final { scan-tree-dump {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-17.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-17.c new file mode 100644 index 0000000000..53fcfd0c06 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-17.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#define N 1024 + +/* This should not be treated as an over-widening pattern, even though + "(b[i] & 0xef) | 0x80)" could be done in unsigned chars. */ + +void __attribute__ ((noipa)) +f (unsigned short *restrict a, unsigned short *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + unsigned short foo = ((b[i] & 0xef) | 0x80) + (a[i] << 4); + a[i] = foo; + } +} + +int +main (void) +{ + check_vect (); + + unsigned short a[N], b[N]; + for (int i = 0; i < N; ++i) + { + a[i] = i; + b[i] = i * 3; + asm volatile ("" ::: "memory"); + } + f (a, b); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != ((((i * 3) & 0xef) | 0x80) + (i << 4))) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not {vect_recog_over_widening_pattern: detected} "vect" } } */ +/* On Power, if there is no vect_hw_misalign support, unaligned vector access + adopts realign_load scheme. It requires rs6000_builtin_mask_for_load to + generate mask whose return type is vector char. */ +/* { dg-final { scan-tree-dump-not {vector[^\n]*char} "vect" { target vect_hw_misalign } } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-18.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-18.c new file mode 100644 index 0000000000..aa58cd1c95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-18.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#define N 1024 + +/* This should be treated as an over-widening pattern: we can truncate + b to unsigned char after loading it and do all the computation in + unsigned char. */ + +void __attribute__ ((noipa)) +f (unsigned char *restrict a, unsigned short *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + unsigned short foo = ((b[i] & 0xef) | 0x80) + (a[i] << 4); + a[i] = foo; + } +} + +int +main (void) +{ + check_vect (); + + unsigned char a[N]; + unsigned short b[N]; + for (int i = 0; i < N; ++i) + { + a[i] = i; + b[i] = i * 3; + asm volatile ("" ::: "memory"); + } + f (a, b); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != (unsigned char) ((((i * 3) & 0xef) | 0x80) + (i << 4))) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* &} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* |} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* <<} "vect" } } */ +/* { dg-final { scan-tree-dump {vector[^\n]*char} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-19.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-19.c new file mode 100644 index 0000000000..c93cd4d09a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-19.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#define N 111 + +/* This shouldn't be treated as an over-widening operation: it's better + to reuse the extensions of di and ei for di + ei than to add them + as shorts and introduce a third extension. */ + +void __attribute__ ((noipa)) +f (unsigned int *restrict a, unsigned int *restrict b, + unsigned int *restrict c, unsigned char *restrict d, + unsigned char *restrict e) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + unsigned int di = d[i]; + unsigned int ei = e[i]; + a[i] = di; + b[i] = ei; + c[i] = di + ei; + } +} + +int +main (void) +{ + check_vect (); + + unsigned int a[N], b[N], c[N]; + unsigned char d[N], e[N]; + for (int i = 0; i < N; ++i) + { + d[i] = i * 2 + 3; + e[i] = i + 100; + asm volatile ("" ::: "memory"); + } + f (a, b, c, d, e); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != i * 2 + 3 + || b[i] != i + 100 + || c[i] != i * 3 + 103) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not {vect_recog_over_widening_pattern: detected} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-2-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-2-big-array.c new file mode 100644 index 0000000000..4bbb30ac8a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-2-big-array.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#define N 512 + +/* Modified rgb to rgb conversion from FFmpeg. */ +__attribute__ ((noinline)) void +foo (unsigned char *src, unsigned char *dst) +{ + unsigned char *s = src; + int *d = (int *)dst; + int i; + + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + *d = ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)); + d++; + } + + s = src; + d = (int *)dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5))) + abort (); + d++; + } +} + +int main (void) +{ + int i; + unsigned char in[N], out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* This is an over-widening even though the final result is still an int. + It's better to do one vector of ops on chars and then widen than to + widen and then do 4 vectors of ops on ints. */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* << 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* << 8} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 5} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-2.c new file mode 100644 index 0000000000..ad423f133c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-2.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#define N 64 + +/* Modified rgb to rgb conversion from FFmpeg. */ +__attribute__ ((noinline)) void +foo (unsigned char *src, unsigned char *dst) +{ + unsigned char *s = src; + int *d = (int *)dst; + int i; + + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + *d = ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)); + d++; + } + + s = src; + d = (int *)dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5))) + abort (); + d++; + } +} + +int main (void) +{ + int i; + unsigned char in[N], out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* This is an over-widening even though the final result is still an int. + It's better to do one vector of ops on chars and then widen than to + widen and then do 4 vectors of ops on ints. */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* << 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* << 8} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 5} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-20.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-20.c new file mode 100644 index 0000000000..81292d42f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-20.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#define N 111 + +/* This shouldn't be treated as an over-widening operation: it's better + to reuse the extensions of di and ei for di + ei than to add them + as shorts and introduce a third extension. */ + +void __attribute__ ((noipa)) +f (unsigned int *restrict a, unsigned int *restrict b, + unsigned int *restrict c, unsigned char *restrict d, + unsigned char *restrict e) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int di = d[i]; + int ei = e[i]; + a[i] = di; + b[i] = ei; + c[i] = di + ei; + } +} + +int +main (void) +{ + check_vect (); + + unsigned int a[N], b[N], c[N]; + unsigned char d[N], e[N]; + for (int i = 0; i < N; ++i) + { + d[i] = i * 2 + 3; + e[i] = i + 100; + asm volatile ("" ::: "memory"); + } + f (a, b, c, d, e); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != i * 2 + 3 + || b[i] != i + 100 + || c[i] != i * 3 + 103) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not {vect_recog_over_widening_pattern: detected} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-21.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-21.c new file mode 100644 index 0000000000..361f77081a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-21.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#define N 111 + +/* This shouldn't be treated as an over-widening operation: it's better + to reuse the extensions of di and ei for di + ei than to add them + as shorts and introduce a third extension. */ + +void __attribute__ ((noipa)) +f (unsigned int *restrict a, unsigned int *restrict b, + unsigned int *restrict c, unsigned char *restrict d, + unsigned char *restrict e) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + a[i] = d[i]; + b[i] = e[i]; + c[i] = d[i] + e[i]; + } +} + +int +main (void) +{ + check_vect (); + + unsigned int a[N], b[N], c[N]; + unsigned char d[N], e[N]; + for (int i = 0; i < N; ++i) + { + d[i] = i * 2 + 3; + e[i] = i + 100; + asm volatile ("" ::: "memory"); + } + f (a, b, c, d, e); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != i * 2 + 3 + || b[i] != i + 100 + || c[i] != i * 3 + 103) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not {vect_recog_over_widening_pattern: detected} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-22.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-22.c new file mode 100644 index 0000000000..830f221019 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-22.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#define N 111 + +/* The addition should be narrowed to short. */ + +void __attribute__ ((noipa)) +f (unsigned int *restrict a, unsigned int *restrict b, + unsigned short *restrict c, unsigned char *restrict d, unsigned int e) +{ + e &= 0xff; + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + unsigned int xor = d[i] ^ e; + a[i] = c[i] | xor; + b[i] = xor; + } +} + +int +main (void) +{ + check_vect (); + + unsigned int a[N], b[N]; + unsigned short c[N]; + unsigned char d[N]; + for (int i = 0; i < N; ++i) + { + c[i] = i * 11; + d[i] = i * 2 + 3; + asm volatile ("" ::: "memory"); + } + f (a, b, c, d, 0x73); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (b[i] != ((i * 2 + 3) ^ 0x73) + || a[i] != ((i * 11) | b[i])) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump {Splitting pattern statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \^} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \|} "vect" } } */ +/* { dg-final { scan-tree-dump {demoting [^\n]* to [^\n]*char} "vect" } } */ +/* { dg-final { scan-tree-dump {demoting [^\n]* to [^\n]*short} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-23.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-23.c new file mode 100644 index 0000000000..34ce512f37 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-23.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-forwprop -fno-tree-vrp" } +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS / 2) +#else +#define N 64 +#endif + +int a[N], b[N], c[N]; + +void +foo () +{ + int i; + for (i = 0; i < N; i++) + { + long long d = a[i]; + long long e = b[i]; + d += e; + c[i] = d; + } +} + +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+} "vect" } } */ +/* { dg-final { scan-tree-dump {VIEW_CONVERT_EXPR +#include "tree-vect.h" + +#define N VECTOR_BITS + +/* Modified rgb to rgb conversion from FFmpeg. */ +__attribute__ ((noinline)) void +foo (unsigned char *src, unsigned char *dst) +{ + unsigned char *s = src; + unsigned short *d = (unsigned short *)dst; + int i; + + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + *d = ((b>>3) | ((g&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9)); + d++; + } + + s = src; + d = (unsigned short *)dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + unsigned short expected + = ((b>>3) | ((g&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9)); + if (*d != expected) + abort (); + d++; + } +} + +int main (void) +{ + int i; + unsigned char in[N], out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 8} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-3.c new file mode 100644 index 0000000000..3d83356197 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-3.c @@ -0,0 +1,64 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#define N 64 + +/* Modified rgb to rgb conversion from FFmpeg. */ +__attribute__ ((noinline)) void +foo (unsigned char *src, unsigned char *dst) +{ + unsigned char *s = src; + unsigned short *d = (unsigned short *)dst; + int i; + + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + *d = ((b>>3) | ((g&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9)); + d++; + } + + s = src; + d = (unsigned short *)dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + if (*d != ((b>>3) | ((g&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9))) + abort (); + d++; + } +} + +int main (void) +{ + int i; + unsigned char in[N], out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 8} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-4-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-4-big-array.c new file mode 100644 index 0000000000..6b3a2b88ab --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-4-big-array.c @@ -0,0 +1,69 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#define N 512 + +/* Modified rgb to rgb conversion from FFmpeg. */ +__attribute__ ((noinline)) int +foo (unsigned char *src, unsigned char *dst) +{ + unsigned char *s = src; + unsigned short *d = (unsigned short *)dst, res; + int i, result = 0; + + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + res = ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)); + *d = res; + result += res; + d++; + } + + s = src; + d = (unsigned short *)dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5))) + abort (); + d++; + } + + return result; +} + +int main (void) +{ + int i; + unsigned char in[N], out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 5} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-4.c new file mode 100644 index 0000000000..60c9c2cc1e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-4.c @@ -0,0 +1,73 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 8 / 16) +#else +#define N 64 +#endif + +/* Modified rgb to rgb conversion from FFmpeg. */ +__attribute__ ((noinline)) int +foo (unsigned char *src, unsigned char *dst) +{ + unsigned char *s = src; + unsigned short *d = (unsigned short *)dst, res; + int i, result = 0; + + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + res = ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)); + *d = res; + result += res; + d++; + } + + s = src; + d = (unsigned short *)dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + const int b = *s++; + const int g = *s++; + const int r = *s++; + const int a = *s++; + if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5))) + abort (); + d++; + } + + return result; +} + +int main (void) +{ + int i; + unsigned char in[N], out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 5} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-5.c new file mode 100644 index 0000000000..c2ab11a9d3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-5.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#ifndef SIGNEDNESS +#define SIGNEDNESS signed +#define BASE_B -128 +#define BASE_C -100 +#endif + +#define N 50 + +/* Both range analysis and backward propagation from the truncation show + that these calculations can be done in SIGNEDNESS short. */ +void __attribute__ ((noipa)) +f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b, + SIGNEDNESS char *restrict c) +{ + /* Deliberate use of signed >>. */ + for (int i = 0; i < N; ++i) + a[i] = (b[i] + c[i]) >> 1; +} + +int +main (void) +{ + check_vect (); + + SIGNEDNESS char a[N], b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE_B + i * 5; + c[i] = BASE_C + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != (BASE_B + BASE_C + i * 9) >> 1) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(signed char\)} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-6.c new file mode 100644 index 0000000000..bda92c965e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-6.c @@ -0,0 +1,17 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#define SIGNEDNESS unsigned +#define BASE_B 4 +#define BASE_C 40 + +#include "vect-over-widen-5.c" + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(unsigned char\)} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-7.c new file mode 100644 index 0000000000..1d55e13fb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-7.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#ifndef SIGNEDNESS +#define SIGNEDNESS signed +#define BASE_B -128 +#define BASE_C -100 +#define D -120 +#endif + +#define N 50 + +/* Both range analysis and backward propagation from the truncation show + that these calculations can be done in SIGNEDNESS short. */ +void __attribute__ ((noipa)) +f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b, + SIGNEDNESS char *restrict c, SIGNEDNESS char d) +{ + int promoted_d = d; + for (int i = 0; i < N; ++i) + /* Deliberate use of signed >>. */ + a[i] = (b[i] + c[i] + promoted_d) >> 2; +} + +int +main (void) +{ + check_vect (); + + SIGNEDNESS char a[N], b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE_B + i * 5; + c[i] = BASE_C + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c, D); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != (BASE_B + BASE_C + D + i * 9) >> 2) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(signed char\)} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-8.c new file mode 100644 index 0000000000..553c0712a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-8.c @@ -0,0 +1,20 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#ifndef SIGNEDNESS +#define SIGNEDNESS unsigned +#define BASE_B 4 +#define BASE_C 40 +#define D 251 +#endif + +#include "vect-over-widen-7.c" + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(unsigned char\)} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-9.c new file mode 100644 index 0000000000..36bfc68e05 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-over-widen-9.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_pack_trunc } */ +/* { dg-require-effective-target vect_unpack } */ + +#include "tree-vect.h" + +#ifndef SIGNEDNESS +#define SIGNEDNESS signed +#define BASE_B -128 +#define BASE_C -100 +#endif + +#define N 50 + +/* Both range analysis and backward propagation from the truncation show + that these calculations can be done in SIGNEDNESS short. */ +void __attribute__ ((noipa)) +f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b, + SIGNEDNESS char *restrict c) +{ + for (int i = 0; i < N; ++i) + { + /* Deliberate use of signed >>. */ + int res = b[i] + c[i]; + a[i] = (res + (res >> 1)) >> 2; + } +} + +int +main (void) +{ + check_vect (); + + SIGNEDNESS char a[N], b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE_B + i * 5; + c[i] = BASE_C + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c); +#pragma GCC novector + for (int i = 0; i < N; ++i) + { + int res = BASE_B + BASE_C + i * 9; + if (a[i] != ((res + (res >> 1)) >> 2)) + __builtin_abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */ +/* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(signed char\)} "vect" } } */ +/* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1-epilogue.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1-epilogue.c new file mode 100644 index 0000000000..cc23c6b086 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1-epilogue.c @@ -0,0 +1,3 @@ +/* { dg-require-effective-target vect_int } */ + +#include "vect-peel-1-src.c" diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1-src.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1-src.c new file mode 100644 index 0000000000..717850a166 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1-src.c @@ -0,0 +1,49 @@ +#include +#include "tree-vect.h" + +#define N 128 + +int ib[N+7]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + int ia[N+1]; + + /* All the accesses are misaligned. With cost model disabled, we + count the number of aligned accesses for each peeling option, and + in this case we align the two loads if possible (i.e., if + misaligned stores are supported). */ + for (i = 1; i <= N; i++) + { + ia[i] = ib[i+2] + ib[i+6]; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= N; i++) + { + if (ia[i] != ib[i+2] + ib[i+6]) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i <= N+6; i++) + { + asm volatile ("" : "+r" (i)); + ib[i] = i; + } + + return main1 (); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1.c new file mode 100644 index 0000000000..a7660a381c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-1.c @@ -0,0 +1,9 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include "vect-peel-1-src.c" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { { vect_element_align } && { vect_aligned_arrays } } xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_element_align_preferred } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2-epilogues.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2-epilogues.c new file mode 100644 index 0000000000..c06fa442fa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2-epilogues.c @@ -0,0 +1,3 @@ +/* { dg-require-effective-target vect_int } */ + +#include "vect-peel-2-src.c" diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2-src.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2-src.c new file mode 100644 index 0000000000..5e5a358d34 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2-src.c @@ -0,0 +1,49 @@ +#include +#include "tree-vect.h" + +#define N 128 + +/* unaligned store. */ + +int ib[N+7]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + int ia[N+1]; + + /* The store is aligned and the loads are misaligned with the same + misalignment. Cost model is disabled. If misaligned stores are supported, + we peel according to the loads to align them. */ + for (i = 0; i <= N; i++) + { + ia[i] = ib[i+2] + ib[i+6]; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= N; i++) + { + if (ia[i] != ib[i+2] + ib[i+6]) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i <= N+6; i++) + { + asm volatile ("" : "+r" (i)); + ib[i] = i; + } + + return main1 (); +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2.c new file mode 100644 index 0000000000..65e70bd441 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-2.c @@ -0,0 +1,9 @@ +/* { dg-require-effective-target vect_int } */ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ + +#include "vect-peel-2-src.c" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { { vect_element_align } && { vect_aligned_arrays } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { { vect_element_align } && { vect_aligned_arrays } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3-epilogue.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3-epilogue.c new file mode 100644 index 0000000000..8af0fcdca0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3-epilogue.c @@ -0,0 +1,4 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include "vect-peel-3-src.c" diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3-src.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3-src.c new file mode 100644 index 0000000000..a21ce8c3d6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3-src.c @@ -0,0 +1,58 @@ +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define NINTS (VECTOR_BITS / 32) +#define EXTRA (NINTS * 2) +#else +#define NINTS 4 +#define EXTRA 10 +#endif + +#define N 128 + +#define RES_A (N * N / 4) +#define RES_B (N * (N + 1) / 2 + (NINTS + 3) * (N + 1)) +#define RES_C (N * (N + 1) / 2 + (N + 1)) +#define RES (RES_A + RES_B + RES_C) + +int ib[N + EXTRA]; +int ia[N + EXTRA]; +int ic[N + EXTRA]; + +__attribute__ ((noinline)) +int main1 () +{ + int i, suma = 0, sumb = 0, sumc = 0; + + /* ib and ic have same misalignment, we peel to align them. */ + for (i = 0; i <= N; i++) + { + suma += ia[i]; + sumb += ib[i + NINTS + 1]; + sumc += ic[i + 1]; + } + + /* check results: */ + if (suma + sumb + sumc != RES) + abort (); + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N + EXTRA; i++) + { + asm volatile ("" : "+r" (i)); + ib[i] = i; + ic[i] = i+2; + ia[i] = i/2; + } + + return main1 (); +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3.c new file mode 100644 index 0000000000..2cd99573fd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-3.c @@ -0,0 +1,10 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include "vect-peel-3-src.c" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { { ! vect_unaligned_possible } || vect_sizes_32B_16B } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { { ! vect_unaligned_possible } || vect_sizes_32B_16B } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4-epilogue.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4-epilogue.c new file mode 100644 index 0000000000..783982f04f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4-epilogue.c @@ -0,0 +1,4 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include "vect-peel-4-src.c" diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4-src.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4-src.c new file mode 100644 index 0000000000..1b85f14351 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4-src.c @@ -0,0 +1,46 @@ +#include +#include "tree-vect.h" + +#define N 128 + +int ib[N+7]; +int ia[N+1]; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + /* Don't peel keeping one load and the store aligned. */ + for (i = 0; i <= N; i++) + { + ia[i] = ib[i] + ib[i+5]; + } + + /* check results: */ +#pragma GCC novector + for (i = 1; i <= N; i++) + { + if (ia[i] != ib[i] + ib[i+5]) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i <= N+6; i++) + { + asm volatile ("" : "+r" (i)); + ib[i] = i; + } + + return main1 (); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4.c new file mode 100644 index 0000000000..3b5272f284 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-peel-4.c @@ -0,0 +1,10 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include "vect-peel-4-src.c" + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { ! vect_unaligned_possible } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-pr111779.c b/SingleSource/Regression/C/gcc-dg/vect/vect-pr111779.c new file mode 100644 index 0000000000..79b72aebc7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-pr111779.c @@ -0,0 +1,56 @@ +#include +#include "tree-vect.h" + +struct C +{ + int c; + int d; + bool f :1; + float e; +}; + +struct A +{ + unsigned int a; + unsigned char c1, c2; + bool b1 : 1; + bool b2 : 1; + bool b3 : 1; + struct C b4; +}; + +void __attribute__((noipa)) +foo (const struct A * __restrict x, int y) +{ + int s = 0, i = 0; + for (i = 0; i < y; ++i) + { + const struct A a = x[i]; + s += a.b4.f ? 1 : 0; + } + if (s != 0) + __builtin_abort (); +} + +int +main () +{ + struct A x[100]; + int i; + + check_vect (); + + __builtin_memset (x, -1, sizeof (x)); +#pragma GCC novect + for (i = 0; i < 100; i++) + { + x[i].b1 = false; + x[i].b2 = false; + x[i].b3 = false; + x[i].b4.f = false; + } + foo (x, 100); + return 0; +} + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_int } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-pr69848.c b/SingleSource/Regression/C/gcc-dg/vect/vect-pr69848.c new file mode 100644 index 0000000000..c08f1e2f5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-pr69848.c @@ -0,0 +1,37 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_condition } */ +#include +#include "tree-vect.h" + +#define N 256 +int a[N] = {0}; + +__attribute__ ((noinline)) +int foo () +{ + int i, res = 0; + for (i = 0; i < N; i++) + { + if (a[i] != 0) + res = 1; + } + return res; +} + +int main (void) +{ + int i, res; + + check_vect (); + + if ((res = foo ()) != 0) + abort (); + + a[34] = 101; + a[85] = 9; + if ((res = foo ()) != 1) + abort (); + + return 0; +} +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-pre-interact.c b/SingleSource/Regression/C/gcc-dg/vect/vect-pre-interact.c new file mode 100644 index 0000000000..5417f0c437 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-pre-interact.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +/* This checks that PRE doesn't create situations that prevent vectorization. + I.e. PR39300, PR35229. */ +float res[1024], data[1025]; + +void foo (void) +{ + int i; + for (i = 0; i < 1024; ++i) + res[i] = data[i] + data[i + 1]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-profile-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-profile-1.c new file mode 100644 index 0000000000..922f965806 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-profile-1.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fdump-tree-vect-details-blocks -fdisable-tree-cunrolli" } */ + +/* At least one of these should correspond to a full vector. */ + +void +f1 (int *x) +{ + for (int j = 0; j < 2; ++j) + x[j] += 1; +} + +void +f2 (int *x) +{ + for (int j = 0; j < 4; ++j) + x[j] += 1; +} + +void +f3 (int *x) +{ + for (int j = 0; j < 8; ++j) + x[j] += 1; +} + +void +f4 (int *x) +{ + for (int j = 0; j < 16; ++j) + x[j] += 1; +} + +/* { dg-final { scan-tree-dump {goto ; \[0+.0*%\]} vect } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-recip.c b/SingleSource/Regression/C/gcc-dg/vect/vect-recip.c new file mode 100644 index 0000000000..61c4f12171 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-recip.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +void f(float *__restrict__ qa, float *__restrict__ qb, + float *__restrict__ qc, float *__restrict__ rtrms) +{ + int i; + static float qam[600]; + static float qbm[600]; + static float qcm[600]; + for(i=0;i<600;i++) + { + float a = rtrms[i]; + qam[i] = qa[i]/a; + qbm[i] = qb[i]/a; + qcm[i] = qc[i]/a; + } +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-1.c new file mode 100644 index 0000000000..7b60df8275 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-1.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (int * __restrict__ a, int * __restrict__ b, int * __restrict__ c) +{ + int t = *c; + for (int i = 0; i < 64; ++i) + { + b[i] = a[i] - t; + t = a[i]; + } +} + +int a[64], b[64]; + +int +main () +{ + check_vect (); + for (int i = 0; i < 64; ++i) + { + a[i] = i; + __asm__ volatile ("" ::: "memory"); + } + int c = 7; + foo (a, b, &c); +#pragma GCC novector + for (int i = 1; i < 64; ++i) + if (b[i] != a[i] - a[i-1]) + abort (); + if (b[0] != -7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-2.c new file mode 100644 index 0000000000..66bbcd2ce3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-2.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (int * __restrict__ a, short * __restrict__ b, int * __restrict__ c) +{ + int t = *c; + for (int i = 0; i < 64; ++i) + { + b[i] = a[i] - t; + t = a[i]; + } +} + +int a[64]; +short b[64]; + +int +main () +{ + check_vect (); + for (int i = 0; i < 64; ++i) + { + a[i] = i; + __asm__ volatile ("" ::: "memory"); + } + int c = 7; + foo (a, b, &c); +#pragma GCC novector + for (int i = 1; i < 64; ++i) + if (b[i] != a[i] - a[i-1]) + abort (); + if (b[0] != -7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-3.c new file mode 100644 index 0000000000..62f26b9648 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-3.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (int * __restrict__ a, signed char * __restrict__ b, int * __restrict__ c) +{ + int t = *c; + for (int i = 0; i < 64; ++i) + { + b[i] = a[i] - t; + t = a[i]; + } +} + +int a[64]; +signed char b[64]; + +int +main () +{ + check_vect (); + for (int i = 0; i < 64; ++i) + { + a[i] = i; + __asm__ volatile ("" ::: "memory"); + } + int c = 7; + foo (a, b, &c); +#pragma GCC novector + for (int i = 1; i < 64; ++i) + if (b[i] != a[i] - a[i-1]) + abort (); + if (b[0] != -7) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-4.c new file mode 100644 index 0000000000..da2f248fc1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-4.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (int * __restrict__ a, int * __restrict__ b, int * __restrict__ c) +{ + int t1 = *c; + int t2 = *c; + for (int i = 0; i < 64; i+=2) + { + b[i] = a[i] - t1; + t1 = a[i]; + b[i+1] = a[i+1] - t2; + t2 = a[i+1]; + } +} + +int a[64], b[64]; + +int +main () +{ + check_vect (); + for (int i = 0; i < 64; ++i) + { + a[i] = i; + __asm__ volatile ("" ::: "memory"); + } + int c = 7; + foo (a, b, &c); +#pragma GCC novector + for (int i = 2; i < 64; i+=2) + if (b[i] != a[i] - a[i-2] + || b[i+1] != a[i+1] - a[i-1]) + abort (); + if (b[0] != -7 || b[1] != -6) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-5.c new file mode 100644 index 0000000000..c3dd8cbabc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-5.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (int * __restrict__ a, short * __restrict__ b, int * __restrict__ c) +{ + int t1 = *c; + int t2 = *c; + for (int i = 0; i < 64; i+=2) + { + b[i] = a[i] - t1; + t1 = a[i]; + b[i+1] = a[i+1] - t2; + t2 = a[i+1]; + } +} + +int a[64]; +short b[64]; + +int +main () +{ + check_vect (); + for (int i = 0; i < 64; ++i) + { + a[i] = i; + __asm__ volatile ("" ::: "memory"); + } + int c = 7; + foo (a, b, &c); +#pragma GCC novector + for (int i = 2; i < 64; i+=2) + if (b[i] != a[i] - a[i-2] + || b[i+1] != a[i+1] - a[i-1]) + abort (); + if (b[0] != -7 || b[1] != -6) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-6.c new file mode 100644 index 0000000000..3b9844d31b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-recurr-6.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_perm } */ + +#include "tree-vect.h" + +void __attribute__((noipa)) +foo (int * __restrict__ a, int * __restrict__ b, int * __restrict__ c, int n) +{ + int t = *c; + for (int i = 0; i < n; ++i) + { + b[i] = a[i] - t; + t = a[i]; + } +} + +int a[64], b[64]; + +int +main () +{ + check_vect (); + for (int i = 0; i < 64; ++i) + { + a[i] = i; + __asm__ volatile ("" ::: "memory"); + } + int c = 7; + foo (a, b, &c, 63); +#pragma GCC novector + for (int i = 1; i < 63; ++i) + if (b[i] != a[i] - a[i-1]) + abort (); + if (b[0] != -7) + abort (); + return 0; +} + +/* ??? We miss epilogue handling for first order recurrences. */ +/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target vect_fully_masked } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1.c new file mode 100644 index 0000000000..aafa9a2c96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1.c @@ -0,0 +1,55 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +unsigned int ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned int uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Test vectorization of reduction of unsigned-int. */ + +__attribute__ ((noinline)) +void main1 (unsigned int x, unsigned int max_result, unsigned int min_result) +{ + int i; + unsigned int udiff = 2; + unsigned int umax = x; + unsigned int umin = x; + + /* Summation. */ + for (i = 0; i < N; i++) { + udiff += (ub[i] - uc[i]); + } + + /* Maximum. */ + for (i = 0; i < N; i++) { + umax = umax < uc[i] ? uc[i] : umax; + } + + /* Minimum. */ + for (i = 0; i < N; i++) { + umin = umin > uc[i] ? uc[i] : umin; + } + + /* check results: */ + if (udiff != DIFF) + abort (); + if (umax != max_result) + abort (); + if (umin != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail { vect_no_int_add || vect_no_int_min_max } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-10.c new file mode 100644 index 0000000000..2d0dac8d3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-10.c @@ -0,0 +1,50 @@ +#include "tree-vect.h" + +extern void abort (void); +double ad[1024]; +float af[1024]; +short as[1024]; +int ai[1024]; +long long all[1024]; +unsigned short aus[1024]; +unsigned int au[1024]; +unsigned long long aull[1024]; + +#define F(var) \ +__attribute__((noinline, noclone)) __typeof (var[0]) \ +f##var (void) \ +{ \ + int i; \ + __typeof (var[0]) r = 0; \ + for (i = 0; i < 1024; i++) \ + r = r > var[i] ? r : var[i]; \ + return r; \ +} + +#define TESTS \ +F (ad) F (af) F (as) F (ai) F (all) F (aus) F (au) F (aull) + +TESTS + +int +main () +{ + int i; + + check_vect (); + + for (i = 0; i < 1024; i++) + { +#undef F +#define F(var) var[i] = i; + TESTS + } + for (i = 1023; i < 32 * 1024; i += 1024 + 271) + { +#undef F +#define F(var) var[i & 1023] = i; if (f##var () != i) abort (); + TESTS + } + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-11.c new file mode 100644 index 0000000000..5906f23690 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-11.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int x[1024], y[1024], z[1024]; + +int __attribute__((noinline,noclone)) +foo (int n) +{ + int sum = 0; + /* Can vectorize this. */ + for (int i = 0; i < n; ++i) + sum = (y[i] - (x[i] - sum)); + return sum; +} + +int __attribute__((noinline,noclone)) +bar (int n) +{ + int sum = 0; + /* Cannot vectorize this, sum is negated. */ + for (int i = 0; i < n; ++i) + sum = z[i] - (y[i] - (x[i] - sum)); + return sum; +} + +int +main() +{ + check_vect (); + for (int i = 0; i < 1024; ++i) + { + x[i] = i; + y[i] = i + 1; + z[i] = 0; + __asm__ volatile ("" : : : "memory"); + } + if (foo (1024) != 1024) + __builtin_abort (); + if (bar (1023) != -1 || bar (1024) != 0) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1char-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1char-big-array.c new file mode 100644 index 0000000000..e762f4890c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1char-big-array.c @@ -0,0 +1,66 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 256 + +unsigned char ub[N]; +unsigned char uc[N]; +unsigned char diff; + +__attribute__ ((noinline)) void +main1 (unsigned char x, unsigned char max_result, unsigned char min_result) +{ + int i; + unsigned char udiff = 2; + unsigned char umax = x; + unsigned char umin = x; + + diff = 2; + for (i = 0; i < N; i++) { + ub[i] = i; + uc[i] = i; + if (i%16 == 0) + { + ub[i] = i+2; + diff += 2; + } + if (uc[i] > max_result) + max_result = uc[i]; + if (uc[i] < min_result) + min_result = uc[i]; + + asm volatile ("" ::: "memory"); + } + for (i = 0; i < N; i++) { + udiff += (unsigned char) (ub[i] - uc[i]); + } + + for (i = 0; i < N; i++) { + umax = umax < uc[i] ? uc[i] : umax; + } + + for (i = 0; i < N; i++) { + umin = umin > uc[i] ? uc[i] : umin; + } + + /* check results: */ + if (udiff != diff) + abort (); + if (umax != max_result) + abort (); + if (umin != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1char.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1char.c new file mode 100644 index 0000000000..d5c62211d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1char.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +unsigned char ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) void +main1 (unsigned char x, unsigned char max_result, unsigned char min_result) +{ + int i; + unsigned char udiff = 2; + unsigned char umax = x; + unsigned char umin = x; + + for (i = 0; i < N; i++) { + udiff += (unsigned char)(ub[i] - uc[i]); + } + + for (i = 0; i < N; i++) { + umax = umax < uc[i] ? uc[i] : umax; + } + + for (i = 0; i < N; i++) { + umin = umin > uc[i] ? uc[i] : umin; + } + + /* check results: */ + if (udiff != DIFF) + abort (); + if (umax != max_result) + abort (); + if (umin != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1short.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1short.c new file mode 100644 index 0000000000..8bbc68c201 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-1short.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +unsigned short ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned short uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) void +main1 (unsigned short x, unsigned short max_result, unsigned short min_result) +{ + int i; + unsigned short udiff = 2; + unsigned short umax = x; + unsigned short umin = x; + + for (i = 0; i < N; i++) { + udiff += (unsigned short)(ub[i] - uc[i]); + } + + for (i = 0; i < N; i++) { + umax = umax < uc[i] ? uc[i] : umax; + } + + for (i = 0; i < N; i++) { + umin = umin > uc[i] ? uc[i] : umin; + } + + /* check results: */ + if (udiff != DIFF) + abort (); + if (umax != max_result) + abort (); + if (umin != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2.c new file mode 100644 index 0000000000..656e571949 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 240 + +int b[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Test vectorization of reduction of signed-int. */ + +__attribute__ ((noinline)) +void main1 (int x, int max_result, int min_result) +{ + int i; + int diff = 0; + int max = x; + int min = x; + + for (i = 0; i < N; i++) { + diff += (b[i] - c[i]); + } + + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail { vect_no_int_add || vect_no_int_min_max } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2char-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2char-big-array.c new file mode 100644 index 0000000000..f54bddb4c9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2char-big-array.c @@ -0,0 +1,65 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 256 + +__attribute__ ((noinline)) +void main1 (signed char x, signed char max_result, signed char min_result) +{ + int i; + signed char b[N]; + signed char c[N]; + signed char check_diff = 2; + signed char diff = 2; + signed char max = x; + signed char min = x; + + check_diff = 2; + for (i = 0; i < N; i++) { + b[i] = i; + c[i] = i; + if (i%16 == 0) + { + c[i] = i + 1; + check_diff += 1; + } + if (c[i] > max_result) + max_result = c[i]; + if (c[i] < min_result) + min_result = c[i]; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) { + diff += (signed char) (c[i] - b[i]); + } + + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != check_diff) + abort (); + if (max != max_result) + abort (); + if (min != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! vect_no_int_min_max } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2char.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2char.c new file mode 100644 index 0000000000..edbc74c41d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2char.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 121 + +__attribute__ ((noinline)) +void main1 (signed char x, signed char max_result, signed char min_result) +{ + int i; + signed char b[N] = {1,2,3,6,8,10,12,14,16,18,20,22,24,26,28,30}; + signed char c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + signed char diff = 2; + signed char max = x; + signed char min = x; + + for (i = 0; i < N; i++) { + diff += (signed char)(b[i] - c[i]); + } + + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! vect_no_int_min_max } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2short.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2short.c new file mode 100644 index 0000000000..0e78a3df5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-2short.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +__attribute__ ((noinline)) +void main1 (short x, short max_result, short min_result) +{ + int i; + short b[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + short diff = 2; + short max = x; + short min = x; + + for (i = 0; i < N; i++) { + diff += (short)(b[i] - c[i]); + } + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { target { ! vect_no_int_min_max } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-3.c new file mode 100644 index 0000000000..551a88c925 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-3.c @@ -0,0 +1,41 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +unsigned int ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +unsigned int uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +/* Test vectorization of reduction of unsigned-int in the presence + of unknown-loop-bound. */ + +__attribute__ ((noinline)) +int main1 (int n, int res) +{ + int i; + unsigned int udiff; + + udiff = 0; + for (i = 0; i < n; i++) { + udiff += (ub[i] - uc[i]); + } + + /* check results: */ + if (udiff != res) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (N, 240); + main1 (N-1, 210); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_add } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-6.c new file mode 100644 index 0000000000..cc0d9694a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-6.c @@ -0,0 +1,55 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_float_strict } */ +/* { dg-additional-options "-fno-fast-math" } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +__attribute__ ((noinline)) +int main1 (float x, float max_result) +{ + int i; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + float diff = 2; + float max = x; + float min = 10; + + for (i = 0; i < N; i++) { + diff += (b[i] - c[i]); + } + + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != 0) + abort (); + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (100 ,100); + main1 (0, 15); + return 0; +} + +/* { dg-final { scan-tree-dump-times {using an in-order \(fold-left\) reduction} 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-7.c new file mode 100644 index 0000000000..274f2124b0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-7.c @@ -0,0 +1,77 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 32 + +extern void abort (void); +typedef unsigned char T; + +__attribute__ ((noinline)) void +testmax (const T *c, T init, T result) +{ + T lc[N], accum = init; + int i; + + __builtin_memcpy (lc, c, sizeof(lc)); + + for (i = 0; i < N; i++) { + accum = accum < lc[i] ? lc[i] : accum; + } + + if (accum != result) + abort (); +} + +__attribute__ ((noinline)) void +testmin (const T *c, T init, T result) +{ + T lc[N], accum = init; + int i; + + __builtin_memcpy (lc, c, sizeof(lc)); + + for (i = 0; i < N; i++) { + accum = accum > lc[i] ? lc[i] : accum; + } + + if (accum != result) + abort (); +} + +int main (void) +{ + static unsigned char const A[N] = { + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f + }; + + static unsigned char const B[N] = { + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f + }; + + static unsigned char const C[N] = { + 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + }; + + check_vect (); + + testmin (A, 10, 1); + testmin (B, 0x7f, 0x70); + testmin (C, 0x7f, 0x09); + + testmax (A, 0, 0x7f); + testmax (B, 0, 0x8f); + testmax (C, 0, 0xff); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-8.c new file mode 100644 index 0000000000..527f4f3f3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-8.c @@ -0,0 +1,77 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 32 + +extern void abort (void); +typedef signed char T; + +__attribute__ ((noinline)) void +testmax (const T *c, T init, T result) +{ + T lc[N], accum = init; + int i; + + __builtin_memcpy (lc, c, sizeof(lc)); + + for (i = 0; i < N; i++) { + accum = accum < lc[i] ? lc[i] : accum; + } + + if (accum != result) + abort (); +} + +__attribute__ ((noinline)) void +testmin (const T *c, T init, T result) +{ + T lc[N], accum = init; + int i; + + __builtin_memcpy (lc, c, sizeof(lc)); + + for (i = 0; i < N; i++) { + accum = accum > lc[i] ? lc[i] : accum; + } + + if (accum != result) + abort (); +} + +int main (void) +{ + static signed char const A[N] = { + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f + }; + + static signed char const B[N] = { + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f + }; + + static signed char const C[N] = { + 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + }; + + check_vect (); + + testmin (A, 0, 0); + testmin (B, 0, 0x80); + testmin (C, 0, 0x80); + + testmax (A, 0, 0x7f); + testmax (B, 0, 0x7f); + testmax (C, 0, 0x77); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-9.c new file mode 100644 index 0000000000..8dc878711e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-9.c @@ -0,0 +1,77 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 32 + +extern void abort (void); +typedef unsigned short T; + +__attribute__ ((noinline)) void +testmax (const T *c, T init, T result) +{ + T lc[N], accum = init; + int i; + + __builtin_memcpy (lc, c, sizeof(lc)); + + for (i = 0; i < N; i++) { + accum = accum < lc[i] ? lc[i] : accum; + } + + if (accum != result) + abort (); +} + +__attribute__ ((noinline)) void +testmin (const T *c, T init, T result) +{ + T lc[N], accum = init; + int i; + + __builtin_memcpy (lc, c, sizeof(lc)); + + for (i = 0; i < N; i++) { + accum = accum > lc[i] ? lc[i] : accum; + } + + if (accum != result) + abort (); +} + +int main (void) +{ + static unsigned short const A[N] = { + 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, + 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, + 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700, + 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff + }; + + static unsigned short const B[N] = { + 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700, + 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff, + 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007, + 0x8008, 0x8009, 0x800a, 0x800b, 0x800c, 0x800d, 0x800e, 0x800f + }; + + static unsigned short const C[N] = { + 0xffff, 0xfffe, 0xfffd, 0xfffc, 0xfffb, 0xfffa, 0xfff9, 0xfff8, + 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, + 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007, + 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700, + }; + + check_vect (); + + testmin (A, 10, 1); + testmin (B, 0x7fff, 0x7000); + testmin (C, 0x7fff, 0x0009); + + testmax (A, 0, 0x7fff); + testmax (B, 0, 0x800f); + testmax (C, 0, 0xffff); + + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-1.c new file mode 100644 index 0000000000..4ee25f8d0f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-1.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 unsigned +#endif + +SIGNEDNESS_1 int __attribute__ ((noipa)) +f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a, + SIGNEDNESS_3 char *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + SIGNEDNESS_2 short mult = av * bv; + res += mult; + } + return res; +} + +#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 char a[N], b[N]; + int expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 5; + b[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + expected += (SIGNEDNESS_2 short) (a[i] * b[i]); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-10.c new file mode 100644 index 0000000000..34e25ab7fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-10.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 unsigned +#define SIGNEDNESS_4 signed + +#include "vect-reduc-dot-9.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-11.c new file mode 100644 index 0000000000..3af8df54cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-11.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 unsigned +#define SIGNEDNESS_4 signed + +#include "vect-reduc-dot-9.c" + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-12.c new file mode 100644 index 0000000000..77ceef3643 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-12.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned + +#include "vect-reduc-dot-9.c" + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-13.c new file mode 100644 index 0000000000..d3c0c86f52 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-13.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned + +#include "vect-reduc-dot-9.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-14.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-14.c new file mode 100644 index 0000000000..86a5c85753 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-14.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 unsigned +#define SIGNEDNESS_4 signed + +#include "vect-reduc-dot-9.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-15.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-15.c new file mode 100644 index 0000000000..25de0940a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-15.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 unsigned +#define SIGNEDNESS_4 signed + +#include "vect-reduc-dot-9.c" + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-16.c new file mode 100644 index 0000000000..4a1dec0677 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-16.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned + +#include "vect-reduc-dot-9.c" + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-17.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-17.c new file mode 100644 index 0000000000..90d21188b7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-17.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned +#endif + +SIGNEDNESS_1 int __attribute__ ((noipa)) +f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a, + SIGNEDNESS_4 char *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + SIGNEDNESS_2 int mult = av * bv; + res += mult; + } + return res; +} + +#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 char a[N]; + SIGNEDNESS_4 char b[N]; + SIGNEDNESS_1 int expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 5; + b[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + expected += (SIGNEDNESS_2 int) (a[i] * b[i]); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-18.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-18.c new file mode 100644 index 0000000000..81ecb158d2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-18.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned +#endif + +SIGNEDNESS_1 int __attribute__ ((noipa)) +f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a, + SIGNEDNESS_4 char *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + SIGNEDNESS_2 int mult = av * bv; + res += mult; + } + return res; +} + +#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 char a[N]; + SIGNEDNESS_4 char b[N]; + SIGNEDNESS_1 int expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 5; + b[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + expected += (SIGNEDNESS_2 int) (a[i] * b[i]); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-19.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-19.c new file mode 100644 index 0000000000..cbcd4f120a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-19.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned +#endif + +SIGNEDNESS_1 long long __attribute__ ((noipa)) +f (SIGNEDNESS_1 long long res, SIGNEDNESS_3 char *restrict a, + SIGNEDNESS_4 short *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + SIGNEDNESS_2 long long mult = av * bv; + res += mult; + } + return res; +} + +#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 char a[N]; + SIGNEDNESS_4 short b[N]; + SIGNEDNESS_1 long long expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 5; + b[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + expected += (SIGNEDNESS_2 int) (a[i] * b[i]); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-2.c new file mode 100644 index 0000000000..25757d2b67 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-2.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 signed + +#include "vect-reduc-dot-1.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-20.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-20.c new file mode 100644 index 0000000000..e81ed1da5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-20.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned +#endif + +SIGNEDNESS_1 long long __attribute__ ((noipa)) +f (SIGNEDNESS_1 long long res, SIGNEDNESS_3 short *restrict a, + SIGNEDNESS_4 char *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + SIGNEDNESS_2 long long mult = av * bv; + res += mult; + } + return res; +} + +#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 short a[N]; + SIGNEDNESS_4 char b[N]; + SIGNEDNESS_1 long long expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 5; + b[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + expected += (SIGNEDNESS_2 int) (a[i] * b[i]); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-21.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-21.c new file mode 100644 index 0000000000..81ce5cdaff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-21.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned +#endif + +SIGNEDNESS_1 long long __attribute__ ((noipa)) +f (SIGNEDNESS_1 long long res, SIGNEDNESS_3 char *restrict a, + SIGNEDNESS_4 short *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + SIGNEDNESS_2 int mult = av * bv; + res += mult; + } + return res; +} + +#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 char a[N]; + SIGNEDNESS_4 short b[N]; + SIGNEDNESS_1 long long expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 5; + b[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + expected += (SIGNEDNESS_2 int) (a[i] * b[i]); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-22.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-22.c new file mode 100644 index 0000000000..b8c9d3ca53 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-22.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned +#endif + +SIGNEDNESS_1 long long __attribute__ ((noipa)) +f (SIGNEDNESS_1 long long res, SIGNEDNESS_3 char *restrict a, + SIGNEDNESS_4 short *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + SIGNEDNESS_2 int mult = av * bv; + res += mult; + } + return res; +} + +#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 char a[N]; + SIGNEDNESS_4 short b[N]; + SIGNEDNESS_1 long long expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 5; + b[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + expected += (SIGNEDNESS_2 int) (a[i] * b[i]); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-3.c new file mode 100644 index 0000000000..b1deb64e18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-3.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 unsigned + +#include "vect-reduc-dot-1.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-4.c new file mode 100644 index 0000000000..c17aa7b897 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-4.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed + +#include "vect-reduc-dot-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-5.c new file mode 100644 index 0000000000..e4d2087942 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-5.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 unsigned + +#include "vect-reduc-dot-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-6.c new file mode 100644 index 0000000000..b690c9f2eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-6.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 signed + +#include "vect-reduc-dot-1.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-7.c new file mode 100644 index 0000000000..29e442e8bb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-7.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 unsigned + +#include "vect-reduc-dot-1.c" + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-8.c new file mode 100644 index 0000000000..dca784f8cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-8.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed + +#include "vect-reduc-dot-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_dot_prod_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-9.c new file mode 100644 index 0000000000..e0b132f6b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-9.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 signed +#define SIGNEDNESS_4 unsigned +#endif + +SIGNEDNESS_1 int __attribute__ ((noipa)) +f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a, + SIGNEDNESS_4 char *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + SIGNEDNESS_2 short mult = av * bv; + res += mult; + } + return res; +} + +#define BASE ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 char a[N]; + SIGNEDNESS_4 char b[N]; + SIGNEDNESS_1 int expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE + i * 5; + b[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + expected += (SIGNEDNESS_2 short) (a[i] * b[i]); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "vect_recog_dot_prod_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16a.c new file mode 100644 index 0000000000..d826828e3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16a.c @@ -0,0 +1,57 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define DOT 43680 + +signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* short->int->int dot product. + Detected as a dot-product pattern. + Vectorized on targets that support dot-product for signed shorts. */ + +__attribute__ ((noinline)) int +foo (int len) +{ + int i; + int result = 0; + + for (i = 0; i < len; i++) + { + result += (X[i] * Y[i]); + } + return result; +} + + +int +main (void) +{ + int i; + int dot; + + check_vect (); + + for (i = 0; i < N; i++) + { + X[i] = i; + Y[i] = N - i; + __asm__ volatile (""); + } + + dot = foo (N); + if (dot != DOT) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_hi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_mult_hi_to_si } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16b.c new file mode 100644 index 0000000000..e8b2564074 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16b.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +#define DOT 43680 + +signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* short->short->int dot product. Should be vectorized on architectures + supporting vectorized multiplication of two short args with short result, + e.g "mulv4hi3" and widenning sum */ +__attribute__ ((noinline)) int +foo (int len) +{ + int i; + int result = 0; + short prod; + + for (i = 0; i < len; i++) + { + prod = X[i] * Y[i]; + result += prod; + } + return result; +} + +int +main (void) +{ + int i, dot; + + check_vect (); + + for (i = 0; i < N; i++) + { + X[i] = i; + Y[i] = 64 - i; + __asm__ volatile (""); + } + + dot = foo (N); + if (dot != DOT) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_short_mult && { vect_widen_sum_hi_to_si || vect_unpack } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_short_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { { ! vect_widen_sum_hi_to_si } && { ! vect_unpack } } } } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16c.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16c.c new file mode 100644 index 0000000000..d6de426223 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s16c.c @@ -0,0 +1,72 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define DOT 43680 + +signed short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed int Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* (short, int)->int->int dot product. + Not detected as a dot-product pattern. */ + +__attribute__ ((noinline)) int +foo (int len) +{ + int i; + int result = 0; + + for (i = 0; i < len; i++) + { + result += (X[i] * Y[i]); + } + return result; +} + + +/* (int, short)->int->int dot product. + Not detected as a dot-product pattern. */ + +__attribute__ ((noinline)) int +bar (int len) +{ + int i; + int result = 0; + + for (i = 0; i < len; i++) + { + result += (Y[i] * X[i]); + } + return result; +} + +int +main (void) +{ + int i; + int dot; + + check_vect (); + + for (i = 0; i < N; i++) + { + X[i] = i; + Y[i] = N - i; + __asm__ volatile (""); + } + + dot = foo (N); + if (dot != DOT) + abort (); + + dot = bar (N); + if (dot != DOT) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_unpack } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s8a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s8a.c new file mode 100644 index 0000000000..4e1e0b234f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-dot-s8a.c @@ -0,0 +1,62 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target arm_v8_2a_dotprod_neon_hw { target { aarch64*-*-* || arm*-*-* } } } */ +/* { dg-additional-options "-march=armv8.2-a+dotprod" { target { aarch64*-*-* } } } */ +/* { dg-add-options arm_v8_2a_dotprod_neon } */ + +#include +#include "tree-vect.h" + +#define N 64 + +#define DOT1 43680 + +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* char->short->int dot product. + The dot-product pattern should be detected. + Vectorizable on vect_sdot_qi targets (targets that support dot-product of + signed chars). + + In the future could also be vectorized as widening-mult + widening-summation, + or with type-conversion support. + */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + int result = 0; + short prod; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +#define DOT2 -21856 + +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* char->short->short dot product. + The dot-product pattern should be detected. + + When the dot-product is detected, the loop should be vectorized on vect_sdot_qi + targets (targets that support dot-product of signed char). + This test would currently fail to vectorize on targets that support + dot-product of chars into an int accumulator. + Alternatively, the loop could also be vectorized as widening-mult + summation, + or with type-conversion support. + */ +__attribute__ ((noinline)) short +foo2(int len) { + int i; + short result = 0; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +#define DOT3 43680 + +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* char->int->int dot product. + Not detected as a dot-product pattern. */ +__attribute__ ((noinline)) int +foo3(int len) { + int i; + int result = 0; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +#define DOT1 43680 +#define DOT2 43680 + +unsigned short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* short->short->int dot product. + Not detected as a dot-product pattern. + Requires support for non-widneing multiplication and widening-summation. */ +__attribute__ ((noinline)) unsigned int +foo1(int len) { + int i; + unsigned int result = 0; + unsigned short prod; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +#define DOT2 43680 + +unsigned short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); + +/* ushort->int->uint dot product: the multiplication promotes the ushorts + to int, and then the product is converted to uint for the addition. */ +__attribute__ ((noinline)) unsigned int +foo2(int len) { + int i; + unsigned int result = 0; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +#define DOT 43680 + +unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; + +/* char->short->int dot product. + Detected as a dot-product pattern. + Should be vectorized on targets that support dot-product for unsigned chars + (vect_udot_qi), + and on targets that support widening-multiplication and widening-summation + (vect_widen_mult_qi && vec_widen_sum_qi_to_si). + Widening-multiplication can also be supported by type promotion and non-widening + multiplication (vect_unpack && vect_short_mult); + Widening summation can also be supported by type promotion and non-widening + summation (vect_unpack). + */ +__attribute__ ((noinline)) unsigned int +foo (int len) { + int i; + unsigned int result = 0; + unsigned short prod; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +#define DOT 43680 + +unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; + +/* char->short->short dot product. + Detected as a dot-product pattern. + Should be vectorized on targets that support dot-product for unsigned chars, + but currently this test cannot be vectorized as a dot-product on targets + that support char->short->int dot-product. + Alternatively, this test can be vectorized using vect_widen_mult_qi (or + vect_unpack and non-widening multplication: vect_unpack && vect_short_mult). + */ +__attribute__ ((noinline)) unsigned short +foo (int len) { + int i; + unsigned short result = 0; + + for (i=0; i 128 +#define N (VECTOR_BITS / 8) +#else +#define N 16 +#endif + +extern void abort(void); + +unsigned char in[N] __attribute__((__aligned__(16))); + +int +main (unsigned char argc, char **argv) +{ + unsigned char i = 0; + unsigned char sum = 1; + unsigned char expected = 1; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = (i + i + 1) & 0xfd; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + expected |= in[i]; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + sum |= in[i]; + + if (sum != expected) + { + __builtin_printf("Failed %d\n", sum); + abort(); + } + + return 0; +} + +/* { dg-final { scan-tree-dump "Reduce using vector shifts" "vect" { target { whole_vector_shift && { ! vect_logical_reduc } } } } } */ +/* { dg-final { scan-tree-dump "Reduce using direct vector reduction" "vect" { target vect_logical_reduc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-or_2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-or_2.c new file mode 100644 index 0000000000..5c67aa2dfe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-or_2.c @@ -0,0 +1,48 @@ +/* Write a reduction loop to be reduced using vector shifts and folded. */ + +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS / 8) +#else +#define N 16 +#endif + +extern void abort(void); + +int +main (unsigned char argc, char **argv) +{ + unsigned char in[N] __attribute__((aligned(16))); + unsigned char i = 0; + unsigned char sum = 1; + unsigned char expected = 1; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = (i + i + 1) & 0xfd; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + expected |= in[i]; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + sum |= in[i]; + + if (sum != expected) + { + __builtin_printf("Failed %d\n", sum); + abort(); + } + + return 0; +} + +/* { dg-final { scan-tree-dump "Reduce using vector shifts" "vect" { target { whole_vector_shift && { ! vect_logical_reduc } } } } } */ +/* { dg-final { scan-tree-dump "Reduce using direct vector reduction" "vect" { target vect_logical_reduc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1a.c new file mode 100644 index 0000000000..eef8b8d29b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1a.c @@ -0,0 +1,46 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 16) +#else +#define N 16 +#endif + +unsigned short udata_sh[N] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 }; +#define SUM 210 + +__attribute__ ((noinline)) int +foo () +{ + int i; + unsigned int intsum = 0; + + /* widenning sum: sum shorts into int. */ + for (i = 0; i < N; i++) + { + intsum += udata_sh[i]; + } + + /* check results: */ + if (intsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_hi_to_si } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1b-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1b-big-array.c new file mode 100644 index 0000000000..561ed00c77 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1b-big-array.c @@ -0,0 +1,46 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 +unsigned char udata_ch[N]; +#define SUM N*(N-1) + +__attribute__ ((noinline)) int +foo () +{ + int i; + unsigned int intsum = 0; + + for (i = 0; i < N; i++) + { + udata_ch[i] = i*2; + asm volatile ("" ::: "memory"); + } + + /* widenning sum: sum chars into int. */ + for (i = 0; i < N; i++) + { + intsum += udata_ch[i]; + } + + /* check results: */ + if (intsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_sum_qi_to_si || vect_unpack } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { { ! vect_widen_sum_qi_to_si } && { ! vect_unpack } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1b.c new file mode 100644 index 0000000000..96f8b740ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1b.c @@ -0,0 +1,44 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 16) +#else +#define N 16 +#endif + +unsigned char udata_ch[N] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 }; +#define SUM 210 + +__attribute__ ((noinline)) int +foo () +{ + int i; + unsigned int intsum = 0; + + /* widenning sum: sum chars into int. */ + for (i = 0; i < N; i++) + { + intsum += udata_ch[i]; + } + + /* check results: */ + if (intsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump "vect_recog_widen_sum_pattern: detected" "vect"} } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_sum_qi_to_si || vect_unpack } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { { ! vect_widen_sum_qi_to_si } && { ! vect_unpack } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1c-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1c-big-array.c new file mode 100644 index 0000000000..cdccd1a320 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1c-big-array.c @@ -0,0 +1,46 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 +unsigned char udata_ch[N]; +#define SUM N*(N-1) + +__attribute__ ((noinline)) int +foo () +{ + int i; + unsigned short shortsum = 0; + + for (i = 0; i < N; i++) + { + udata_ch[i] = i*2; + asm volatile ("" ::: "memory"); + } + + /* widenning sum: sum chars into short. */ + for (i = 0; i < N; i++) + { + shortsum += udata_ch[i]; + } + + /* check results: */ + if (shortsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_qi_to_hi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_hi } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1c.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1c.c new file mode 100644 index 0000000000..b7fe44cdbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-1c.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +unsigned char udata_ch[N] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 }; +#define SUM 210 + +__attribute__ ((noinline)) int +foo () +{ + int i; + unsigned short shortsum = 0; + + /* widenning sum: sum chars into short. */ + for (i = 0; i < N; i++) + { + shortsum += udata_ch[i]; + } + + /* check results: */ + if (shortsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump "vect_recog_widen_sum_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_qi_to_hi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_hi } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2a.c new file mode 100644 index 0000000000..3f23cb859e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2a.c @@ -0,0 +1,46 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#if VECTOR_BITS > 128 +#define N (VECTOR_BITS * 2 / 16) +#else +#define N 16 +#endif + +signed short data_sh[N] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 }; +#define SUM 210 + +__attribute__ ((noinline)) int +foo () +{ + int i; + signed int intsum = 0; + + /* widenning sum: sum shorts into int. */ + for (i = 0; i < N; i++) + { + intsum += data_sh[i]; + } + + /* check results: */ + if (intsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_hi_to_si } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2b-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2b-big-array.c new file mode 100644 index 0000000000..c69a8896e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2b-big-array.c @@ -0,0 +1,47 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 +signed char data_ch[N]; + +__attribute__ ((noinline)) int +foo () +{ + int i; + signed int intsum = 0; + signed int check_intsum = 0; + + for (i = 0; i < N; i++) + { + data_ch[i] = i*2; + check_intsum += data_ch[i]; + asm volatile ("" ::: "memory"); + } + + /* widenning sum: sum chars into int. */ + for (i = 0; i < N; i++) + { + intsum += data_ch[i]; + } + + /* check results: */ + if (intsum != check_intsum) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected(?:(?!failed)(?!Re-trying).)*succeeded" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_sum_qi_to_si && vect_unpack } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { { ! vect_widen_sum_qi_to_si } && { ! vect_unpack } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2b.c new file mode 100644 index 0000000000..c8b97b99bc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2b.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +signed char data_ch[N] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 }; +#define SUM 210 + +__attribute__ ((noinline)) int +foo () +{ + int i; + signed int intsum = 0; + + /* widenning sum: sum chars into int. */ + for (i = 0; i < N; i++) + { + intsum += data_ch[i]; + } + + /* check results: */ + if (intsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump "vect_recog_widen_sum_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_sum_qi_to_si && vect_unpack } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { { ! vect_widen_sum_qi_to_si } && { ! vect_unpack } } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2c.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2c.c new file mode 100644 index 0000000000..926b203653 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-2c.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +signed char data_ch[N] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 }; +#define SUM 210 + +__attribute__ ((noinline)) int +foo () +{ + int i; + signed short shortsum = 0; + + /* widenning sum: sum chars into short. + The widening-summation pattern is currently not detected because of this + patch: + + 2005-12-26 Kazu Hirata + + PR tree-optimization/25125 + + but we still handle the reduction. + */ + + for (i = 0; i < N; i++) + { + shortsum += data_ch[i]; + } + + /* check results: */ + if (shortsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_widen_sum_qi_to_hi } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-3.c new file mode 100644 index 0000000000..5dd2e504f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-pattern-3.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_int_mult } */ + +#include +#include "tree-vect.h" + +#define N 10 +#define RES 1024 + +/* A reduction pattern in which there is no data ref in + the loop and one operand is defined outside of the loop. */ + +__attribute__ ((noinline)) int +foo (int v) +{ + int i; + int result = 1; + + ++v; + for (i = 0; i < N; i++) + result *= v; + + return result; +} + +int +main (void) +{ + int res; + + check_vect (); + + res = foo (1); + if (res != RES) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-1.c new file mode 100644 index 0000000000..73a83b8faa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-1.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 unsigned +#endif + +SIGNEDNESS_1 int __attribute__ ((noipa)) +f (SIGNEDNESS_1 int res, SIGNEDNESS_3 char *restrict a, + SIGNEDNESS_3 char *restrict b) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int av = a[i]; + int bv = b[i]; + short diff = av - bv; + SIGNEDNESS_2 short abs = diff < 0 ? -diff : diff; + res += abs; + } + return res; +} + +#define BASE1 ((SIGNEDNESS_3 int) -1 < 0 ? -126 : 4) +#define BASE2 ((SIGNEDNESS_3 int) -1 < 0 ? 116 : 220) + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_3 char a[N], b[N]; + int expected = 0x12345; + for (int i = 0; i < N; ++i) + { + a[i] = BASE1 + i * 5; + b[i] = BASE1 - i * 4; + asm volatile ("" ::: "memory"); + int diff = a[i] - b[i]; + expected += (SIGNEDNESS_2 short) (diff < 0 ? -diff : diff); + } + if (f (0x12345, a, b) != expected) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_sdot_qi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-2.c new file mode 100644 index 0000000000..4c846ff905 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-2.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 signed + +#include "vect-reduc-sad-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-3.c new file mode 100644 index 0000000000..fbd8d8dab1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-3.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 unsigned + +#include "vect-reduc-sad-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-4.c new file mode 100644 index 0000000000..fbdaf4cd03 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-4.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed + +#include "vect-reduc-sad-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-5.c new file mode 100644 index 0000000000..56847c314b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-5.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 unsigned + +#include "vect-reduc-sad-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-6.c new file mode 100644 index 0000000000..f907528f6e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-6.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 unsigned +#define SIGNEDNESS_3 signed + +#include "vect-reduc-sad-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-7.c new file mode 100644 index 0000000000..2ab743914d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-7.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 unsigned + +#include "vect-reduc-sad-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-8.c new file mode 100644 index 0000000000..089583c661 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad-8.c @@ -0,0 +1,10 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 signed +#define SIGNEDNESS_3 signed + +#include "vect-reduc-sad-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad.c b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad.c new file mode 100644 index 0000000000..08f79874e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-reduc-sad.c @@ -0,0 +1,56 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_usad_char } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define SAD N*N/2 + +unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int abs (int); + +/* Sum of absolute differences between arrays of unsigned char types. + Detected as a sad pattern. + Vectorized on targets that support sad for unsigned chars. */ + +__attribute__ ((noinline)) int +foo (int len) +{ + int i; + int result = 0; + + for (i = 0; i < len; i++) + result += abs (X[i] - Y[i]); + + return result; +} + + +int +main (void) +{ + int i; + int sad; + + check_vect (); + + for (i = 0; i < N; i++) + { + X[i] = i; + Y[i] = N - i; + __asm__ volatile (""); + } + + sad = foo (N); + if (sad != SAD) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-btrunc.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-btrunc.c new file mode 100644 index 0000000000..f2687ba7cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-btrunc.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_btrunc } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_trunc (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_btrunc } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-btruncf.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-btruncf.c new file mode 100644 index 0000000000..e5d307641a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-btruncf.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_btruncf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_truncf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_btruncf } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-ceil.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-ceil.c new file mode 100644 index 0000000000..f5fce164f7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-ceil.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_ceil } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_ceil (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_ceil } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-ceilf.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-ceilf.c new file mode 100644 index 0000000000..9c731a1ade --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-ceilf.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_ceilf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_ceilf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_ceilf } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-floor.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-floor.c new file mode 100644 index 0000000000..4ed3be760e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-floor.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_floor } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_floor (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_floor } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-floorf.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-floorf.c new file mode 100644 index 0000000000..d66bb01ab3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-floorf.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_floorf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_floorf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_floorf } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-lceil.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-lceil.c new file mode 100644 index 0000000000..8b8daa3b5e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-lceil.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_lceil } */ + +#define N 32 + +void +foo (long *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_lceil (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_lceil } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-lfloor.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-lfloor.c new file mode 100644 index 0000000000..84fda19ae5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-lfloor.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_lfloor } */ + +#define N 32 + +void +foo (long *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_lfloor (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_lfloor } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-nearbyint.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-nearbyint.c new file mode 100644 index 0000000000..9c2847188c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-nearbyint.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_nearbyint } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_nearbyint (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_nearbyint } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-nearbyintf.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-nearbyintf.c new file mode 100644 index 0000000000..9f01dde34d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-nearbyintf.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_nearbyintf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_nearbyintf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_nearbyintf } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-round.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-round.c new file mode 100644 index 0000000000..017a0e4c5c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-round.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_call_round } */ + +#define N 32 + +void +foo (double *output, double *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_round (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_round } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-roundf.c b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-roundf.c new file mode 100644 index 0000000000..2f3f35caa4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-rounding-roundf.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-require-effective-target vect_call_roundf } */ + +#define N 32 + +void +foo (float *output, float *input) +{ + int i = 0; + /* Vectorizable. */ + for (i = 0; i < N; i++) + output[i] = __builtin_roundf (input[i]); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_call_roundf } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-sdiv-pow2-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-sdiv-pow2-1.c new file mode 100644 index 0000000000..49ecbe216f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-sdiv-pow2-1.c @@ -0,0 +1,83 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define DIV(x,y) ((x)/(y)) +#define MOD(x,y) ((x)%(y)) + +#define TEMPLATE(PO2,OP) \ +void __attribute__ ((noipa)) \ +f_##PO2##_##OP (int *restrict a, int *restrict b, __INTPTR_TYPE__ n) \ +{ \ + for (__INTPTR_TYPE__ i = 0; i < n; ++i) \ + a[i] = OP (b[i], (1 << PO2)); \ +} +#define TEMPLATES(PO2) \ +TEMPLATE (PO2,DIV); \ +TEMPLATE (PO2,MOD); + +TEMPLATES (1); +TEMPLATES (2); +TEMPLATES (3); +TEMPLATES (7); +TEMPLATES (8); +TEMPLATES (10); +TEMPLATES (15); +TEMPLATES (16); +TEMPLATES (20); + +typedef void (*func_t) (int *, int *, __INTPTR_TYPE__); +typedef struct { + int po2; + func_t div; + func_t mod; +} fn_t; +const fn_t fns[] = { +#define FN_PAIR(PO2) { PO2, f_##PO2##_DIV, f_##PO2##_MOD } + FN_PAIR (1), + FN_PAIR (2), + FN_PAIR (3), + FN_PAIR (7), + FN_PAIR (8), + FN_PAIR (10), + FN_PAIR (15), + FN_PAIR (16), + FN_PAIR (20), +}; + +int __attribute__ ((noipa, noinline)) +power2 (int x) +{ + return 1 << x; +} + +#define N 50 + +int +main (void) +{ + int a[N], b[N], c[N]; + + for (int i = 0; i < (sizeof(fns)/sizeof(fns[0])); i++) + { + int p = power2 (fns[i].po2); + for (int j = 0; j < N; j++) + { + a[j] = ((p << 4) * j) / (N - 1) - (p << 5); + asm volatile ("" ::: "memory"); + } + + fns[i].div (b, a, N); + fns[i].mod (c, a, N); + +#pragma GCC novector + for (int j = 0; j < N; j++) + if (a[j] != (b[j] * p + c[j])) + __builtin_abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump {\.DIV_POW2} "vect" { target vect_sdiv_pow2_si } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 18 "vect" { target vect_sdiv_pow2_si } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-sdivmod-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-sdivmod-1.c new file mode 100644 index 0000000000..0c4025abce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-sdivmod-1.c @@ -0,0 +1,98 @@ +#include "tree-vect.h" + +extern void abort (void); +int a[4096]; + +__attribute__((noinline, noclone)) void +f1 (int x) +{ + int i, j; + for (i = 1; i <= x; i++) + { + j = a[i] >> 8; + j = 1 + (j / 2); + a[i] = j << 8; + } +} + +__attribute__((noinline, noclone)) void +f2 (int x) +{ + int i, j; + for (i = 1; i <= x; i++) + { + j = a[i] >> 8; + j = 1 + (j / 16); + a[i] = j << 8; + } +} + +__attribute__((noinline, noclone)) void +f3 (int x) +{ + int i, j; + for (i = 1; i <= x; i++) + { + j = a[i] >> 8; + j = 1 + (j % 2); + a[i] = j << 8; + } +} + +__attribute__((noinline, noclone)) void +f4 (int x) +{ + int i, j; + for (i = 1; i <= x; i++) + { + j = a[i] >> 8; + j = 1 + (j % 16); + a[i] = j << 8; + } +} + +int +main () +{ + int i; + check_vect (); + for (i = 0; i < 4096; i++) + { + asm (""); + a[i] = (i - 2048) << 8; + } + f1 (4095); + if (a[0] != (-2048 << 8)) + abort (); + for (i = 1; i < 4096; i++) + if (a[i] != ((1 + ((i - 2048) / 2)) << 8)) + abort (); + else + a[i] = (i - 2048) << 8; + f2 (4095); + if (a[0] != (-2048 << 8)) + abort (); + for (i = 1; i < 4096; i++) + if (a[i] != ((1 + ((i - 2048) / 16)) << 8)) + abort (); + else + a[i] = (i - 2048) << 8; + f3 (4095); + if (a[0] != (-2048 << 8)) + abort (); + for (i = 1; i < 4096; i++) + if (a[i] != ((1 + ((i - 2048) % 2)) << 8)) + abort (); + else + a[i] = (i - 2048) << 8; + f4 (4095); + if (a[0] != (-2048 << 8)) + abort (); +#pragma GCC novector + for (i = 1; i < 4096; i++) + if (a[i] != ((1 + ((i - 2048) % 16)) << 8)) + abort (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" { target vect_condition } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-shift-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-1.c new file mode 100644 index 0000000000..d5fc474875 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-1.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 + +unsigned int A[N] = { 0x08000000, 0x08000001, 0x0ff0000ff, 0xf0000001, + 0x08000000, 0x08000001, 0x0ff0000ff, 0xf0000001 }; +unsigned int B[N] = { 0x01000000, 0x01000000, 0x01fe0001f, 0x1e000000, + 0x01000000, 0x01000000, 0x01fe0001f, 0x1e000000 }; + +int main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + A[i] = A[i] >> 3; + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-shift-2-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-2-big-array.c new file mode 100644 index 0000000000..682b319d22 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-2-big-array.c @@ -0,0 +1,190 @@ +/* { dg-additional-options "-Wno-shift-overflow" } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_int } */ +/* Check the standard integer types for left and right shifts to see if the + compiler replaced a scalar instruction with a vector instruction whether the + correct value is generated. */ + +#ifdef TRACE +#endif + +#include +#include "tree-vect.h" + +#ifndef ALIGN +#define ALIGN __attribute__((__aligned__(__BIGGEST_ALIGNMENT__))) +#endif + +#ifndef NOINLINE +#define NOINLINE __attribute__((__noinline__)) +#endif + +#ifdef TRACE +#define TRACE_FUNC(PREFIX, NAME) printf (#PREFIX #NAME "\n") +#define TRACE_DONE() printf ("done!\n") +#define TRACE_ABORT(I,E,G) \ +do { \ + printf ("Element %d, expected 0x%lx, got 0x%lx\n", \ + I, (long)(E), (long)(G)); \ + abort (); \ +} while (0) + +#else +#define TRACE_FUNC(PREFIX, A) +#define TRACE_DONE() +#define TRACE_ABORT(I,E,G) abort () +#endif + +#define NAME(A,B) A ## B + +#define VECT_TESTS(PREFIX, TYPE, N) \ + /* Restrict the optimizer from optimizing the setup loops. */ \ +volatile TYPE NAME (PREFIX, zero) = 0; \ + \ +TYPE NAME (PREFIX, a)[N] ALIGN; \ +TYPE NAME (PREFIX, b)[N] ALIGN; \ +TYPE NAME (PREFIX, c)[N] ALIGN; \ +TYPE NAME (PREFIX, d)[N] ALIGN; \ + \ +static void NOINLINE \ +NAME (PREFIX, lshift_2) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, lshift_2); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << 2; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, lshift_var) (int shift) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, lshift_var); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << shift; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, lshift_vect) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, lshift_vect); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << NAME (PREFIX, c)[i]; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, rshift_2) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, rshift_2); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> 2; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, rshift_var) (int shift) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, rshift_var); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> shift; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, rshift_vect) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, rshift_vect); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> NAME (PREFIX, c)[i]; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, check) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, check); \ + for (i = 0; i < N; i++) \ + if (NAME (PREFIX, a)[i] != NAME (PREFIX, d)[i]) \ + TRACE_ABORT (i, NAME (PREFIX, d)[i], NAME (PREFIX, a)[i]); \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, tests) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, tests); \ + for (i = 0; i < N; i++) \ + { \ + NAME (PREFIX, b)[i] = (i + NAME (PREFIX, zero)); \ + NAME (PREFIX, c)[i] = 2; \ + NAME (PREFIX, d)[i] = (i + NAME (PREFIX, zero)) << 2; \ + } \ + \ + NAME (PREFIX, lshift_2) (); \ + NAME (PREFIX, check) (); \ + \ + NAME (PREFIX, lshift_var) (2); \ + NAME (PREFIX, check) (); \ + \ + NAME (PREFIX, lshift_vect) (); \ + NAME (PREFIX, check) (); \ + \ + for (i = 0; i < N; i++) \ + { \ + NAME (PREFIX, b)[i] = ((i + NAME (PREFIX, zero)) << 4) \ + | (((TYPE)0x80) << ((sizeof (TYPE) * 8) - 8)); \ + NAME (PREFIX, c)[i] = 2; \ + NAME (PREFIX, d)[i] = (TYPE)((NAME (PREFIX, b)[i] \ + + NAME (PREFIX, zero)) >> 2); \ + } \ + \ + NAME (PREFIX, rshift_2) (); \ + NAME (PREFIX, check) (); \ + \ + NAME (PREFIX, rshift_var) (2); \ + NAME (PREFIX, check) (); \ + \ + NAME (PREFIX, rshift_vect) (); \ + NAME (PREFIX, check) (); \ +} + +VECT_TESTS (uc_, unsigned char, 128) +VECT_TESTS (us_, unsigned short, 256) +VECT_TESTS (ui_, unsigned int, 256) +VECT_TESTS (ul_, unsigned long, 256) + +VECT_TESTS (sc_, signed char, 128) +VECT_TESTS (ss_, short, 256) +VECT_TESTS (si_, int, 256) +VECT_TESTS (sl_, long, 256) + +int main () +{ + int i; + + check_vect (); + + uc_tests (); + us_tests (); + ui_tests (); + ul_tests (); + + sc_tests (); + ss_tests (); + si_tests (); + sl_tests (); + + TRACE_DONE (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-shift-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-2.c new file mode 100644 index 0000000000..ba8e7c1f7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-2.c @@ -0,0 +1,190 @@ +/* { dg-additional-options "-Wno-shift-overflow" } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_int } */ +/* Check the standard integer types for left and right shifts to see if the + compiler replaced a scalar instruction with a vector instruction whether the + correct value is generated. */ + +#ifdef TRACE +#endif + +#include +#include "tree-vect.h" + +#ifndef ALIGN +#define ALIGN __attribute__((__aligned__(__BIGGEST_ALIGNMENT__))) +#endif + +#ifndef NOINLINE +#define NOINLINE __attribute__((__noinline__)) +#endif + +#ifdef TRACE +#define TRACE_FUNC(PREFIX, NAME) printf (#PREFIX #NAME "\n") +#define TRACE_DONE() printf ("done!\n") +#define TRACE_ABORT(I,E,G) \ +do { \ + printf ("Element %d, expected 0x%lx, got 0x%lx\n", \ + I, (long)(E), (long)(G)); \ + abort (); \ +} while (0) + +#else +#define TRACE_FUNC(PREFIX, A) +#define TRACE_DONE() +#define TRACE_ABORT(I,E,G) abort () +#endif + +#define NAME(A,B) A ## B + +#define VECT_TESTS(PREFIX, TYPE, N) \ + /* Restrict the optimizer from optimizing the setup loops. */ \ +volatile TYPE NAME (PREFIX, zero) = 0; \ + \ +TYPE NAME (PREFIX, a)[N] ALIGN; \ +TYPE NAME (PREFIX, b)[N] ALIGN; \ +TYPE NAME (PREFIX, c)[N] ALIGN; \ +TYPE NAME (PREFIX, d)[N] ALIGN; \ + \ +static void NOINLINE \ +NAME (PREFIX, lshift_2) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, lshift_2); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << 2; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, lshift_var) (int shift) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, lshift_var); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << shift; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, lshift_vect) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, lshift_vect); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << NAME (PREFIX, c)[i]; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, rshift_2) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, rshift_2); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> 2; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, rshift_var) (int shift) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, rshift_var); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> shift; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, rshift_vect) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, rshift_vect); \ + for (i = 0; i < N; i++) \ + NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> NAME (PREFIX, c)[i]; \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, check) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, check); \ + for (i = 0; i < N; i++) \ + if (NAME (PREFIX, a)[i] != NAME (PREFIX, d)[i]) \ + TRACE_ABORT (i, NAME (PREFIX, d)[i], NAME (PREFIX, a)[i]); \ +} \ + \ +static void NOINLINE \ +NAME (PREFIX, tests) (void) \ +{ \ + int i; \ + \ + TRACE_FUNC (PREFIX, tests); \ + for (i = 0; i < N; i++) \ + { \ + NAME (PREFIX, b)[i] = (i + NAME (PREFIX, zero)); \ + NAME (PREFIX, c)[i] = 2; \ + NAME (PREFIX, d)[i] = (i + NAME (PREFIX, zero)) << 2; \ + } \ + \ + NAME (PREFIX, lshift_2) (); \ + NAME (PREFIX, check) (); \ + \ + NAME (PREFIX, lshift_var) (2); \ + NAME (PREFIX, check) (); \ + \ + NAME (PREFIX, lshift_vect) (); \ + NAME (PREFIX, check) (); \ + \ + for (i = 0; i < N; i++) \ + { \ + NAME (PREFIX, b)[i] = ((i + NAME (PREFIX, zero)) << 4) \ + | (((TYPE)0x80) << ((sizeof (TYPE) * 8) - 8)); \ + NAME (PREFIX, c)[i] = 2; \ + NAME (PREFIX, d)[i] = (TYPE)((NAME (PREFIX, b)[i] \ + + NAME (PREFIX, zero)) >> 2); \ + } \ + \ + NAME (PREFIX, rshift_2) (); \ + NAME (PREFIX, check) (); \ + \ + NAME (PREFIX, rshift_var) (2); \ + NAME (PREFIX, check) (); \ + \ + NAME (PREFIX, rshift_vect) (); \ + NAME (PREFIX, check) (); \ +} + +VECT_TESTS(uc_, unsigned char, 16) +VECT_TESTS(us_, unsigned short, 32) +VECT_TESTS(ui_, unsigned int, 32) +VECT_TESTS(ul_, unsigned long, 32) + +VECT_TESTS(sc_, signed char, 16) +VECT_TESTS(ss_, short, 32) +VECT_TESTS(si_, int, 32) +VECT_TESTS(sl_, long, 32) + +int main () +{ + int i; + + check_vect (); + + uc_tests (); + us_tests (); + ui_tests (); + ul_tests (); + + sc_tests (); + ss_tests (); + si_tests (); + sl_tests (); + + TRACE_DONE (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-shift-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-3.c new file mode 100644 index 0000000000..0a9d562feb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-3.c @@ -0,0 +1,37 @@ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 32 + +unsigned short dst[N] __attribute__((aligned(N))); +unsigned short src[N] __attribute__((aligned(N))); + +__attribute__ ((noinline)) +void array_shift(void) +{ + int i; + for (i = 0; i < N; i++) + dst[i] = src[i] >> 3; +} + +int main() +{ + volatile int i; + check_vect (); + + for (i = 0; i < N; i++) + src[i] = i << 3; + + array_shift (); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (dst[i] != i) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-shift-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-4.c new file mode 100644 index 0000000000..d53faa52ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-4.c @@ -0,0 +1,37 @@ +/* { dg-require-effective-target vect_shift_char } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 32 + +unsigned char dst[N] __attribute__((aligned(N))); +unsigned char src[N] __attribute__((aligned(N))); + +__attribute__ ((noinline)) +void array_shift(void) +{ + int i; + for (i = 0; i < N; i++) + dst[i] = src[i] >> 3; +} + +int main() +{ + volatile int i; + check_vect (); + + for (i = 0; i < N; i++) + src[i] = i << 3; + + array_shift (); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (dst[i] != i) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-shift-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-5.c new file mode 100644 index 0000000000..e47797f336 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-shift-5.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_shift } */ +/* { dg-require-effective-target vect_int } */ + +typedef unsigned int uint32_t; +typedef short unsigned int uint16_t; + +int foo (uint32_t arr[4][4]) +{ + int sum = 0; + for(int i = 0; i < 4; i++) + { + sum += ((arr[0][i] >> 10) * 20) + ((arr[1][i] >> 11) & 53) + + ((arr[2][i] >> 12) * 7) + ((arr[3][i] >> 13) ^ 43); + } + return (((uint16_t)sum) + ((uint32_t)sum >> 16)) >> 1; +} + +/* For a target that has a vector/scalar shift/rotate optab, check + that we are not adding the cost of creating a vector from the scalar + in the prologue. */ +/* { dg-final { scan-tree-dump {vectorizable_shift ===[\n\r][^\n]*prologue_cost = 0} "vect" { target { aarch64*-*-* x86_64-*-* } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-1.c new file mode 100644 index 0000000000..09722ae090 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-1.c @@ -0,0 +1,68 @@ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#define N 1024 +int a[N]; +int x; + +__attribute__((noipa)) int +bar (void) +{ + return x; +} + +__attribute__((noipa)) void +foo (void) +{ + #pragma omp simd if (bar ()) + for (int i = 0; i < N; ++i) + a[i] = a[i] + 1; +} + +__attribute__((noipa)) void +baz (void) +{ + int c = 0; + #pragma omp simd if (c) + for (int i = 0; i < N; ++i) + a[i] = a[i] + 1; +} + +__attribute__((noipa)) void +qux (void) +{ + int c = 1; + #pragma omp simd if (c) + for (int i = 0; i < N; ++i) + a[i] = a[i] + 1; +} + +int +main () +{ + check_vect (); + foo (); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != 1) + abort (); + x = 1; + foo (); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != 2) + abort (); + baz (); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != 3) + abort (); + qux (); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != 4) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-10.c new file mode 100644 index 0000000000..af0999a726 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-10.c @@ -0,0 +1,104 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#ifndef main +#include "tree-vect.h" +#endif + +#ifdef __FAST_MATH__ +#define FLT_MIN_VALUE (-__FLT_MAX__) +#else +#define FLT_MIN_VALUE (-__builtin_inff ()) +#endif + +float r = 1.0f, a[1024], b[1024]; + +__attribute__((noipa)) void +foo (float *a, float *b) +{ + #pragma omp simd reduction (inscan, *:r) + for (int i = 0; i < 1024; i++) + { + r *= a[i]; + #pragma omp scan inclusive(r) + b[i] = r; + } +} + +__attribute__((noipa)) float +bar (void) +{ + float s = FLT_MIN_VALUE; + #pragma omp simd reduction (inscan, max:s) + for (int i = 0; i < 1024; i++) + { + s = s > a[i] ? s : a[i]; + #pragma omp scan inclusive(s) + b[i] = s; + } + return s; +} + +int +main () +{ + float s = 1.0f; +#ifndef main + check_vect (); +#endif + for (int i = 0; i < 1024; ++i) + { + if (i < 80) + a[i] = (i & 1) ? 0.25f : 0.5f; + else if (i < 200) + a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f; + else if (i < 280) + a[i] = (i & 1) ? 0.25f : 0.5f; + else if (i < 380) + a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f; + else + switch (i % 6) + { + case 0: a[i] = 0.25f; break; + case 1: a[i] = 2.0f; break; + case 2: a[i] = -1.0f; break; + case 3: a[i] = -4.0f; break; + case 4: a[i] = 0.5f; break; + case 5: a[i] = 1.0f; break; + default: a[i] = 0.0f; break; + } + b[i] = -19.0f; + asm ("" : "+g" (i)); + } + foo (a, b); + if (r * 16384.0f != 0.125f) + abort (); + float m = -175.25f; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s *= a[i]; + if (b[i] != s) + abort (); + else + { + a[i] = m - ((i % 3) == 1 ? 2.0f : (i % 3) == 2 ? 4.0f : 0.0f); + b[i] = -231.75f; + m += 0.75f; + } + } + if (bar () != 592.0f) + abort (); + s = FLT_MIN_VALUE; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (s < a[i]) + s = a[i]; + if (b[i] != s) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-11.c new file mode 100644 index 0000000000..2620dfebbc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-11.c @@ -0,0 +1,190 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#ifndef main +#include "tree-vect.h" +#endif + +int r, a[1024], b[1024]; +unsigned short r2, b2[1024]; +unsigned char r3, b3[1024]; + +__attribute__((noipa)) void +foo (int *a, int *b, unsigned short *b2, unsigned char *b3) +{ + #pragma omp simd reduction (inscan, +:r, r2, r3) + for (int i = 0; i < 1024; i++) + { + { r += a[i]; r2 += a[i]; r3 += a[i]; } + #pragma omp scan inclusive(r, r2, r3) + { + b[i] = r; + b2[i] = r2; + b3[i] = r3; + } + } +} + +__attribute__((noipa)) int +bar (unsigned short *s2p, unsigned char *s3p) +{ + int s = 0; + unsigned short s2 = 0; + unsigned char s3 = 0; + #pragma omp simd reduction (inscan, +:s, s2, s3) + for (int i = 0; i < 1024; i++) + { + { + s += 2 * a[i]; + s2 += 2 * a[i]; + s3 += 2 * a[i]; + } + #pragma omp scan inclusive(s, s2, s3) + { b[i] = s; b2[i] = s2; b3[i] = s3; } + } + *s2p = s2; + *s3p = s3; + return s; +} + +__attribute__((noipa)) void +baz (int *a, int *b, unsigned short *b2, unsigned char *b3) +{ + #pragma omp simd reduction (inscan, +:r, r2, r3) if (simd: 0) + for (int i = 0; i < 1024; i++) + { + { + r += a[i]; + r2 += a[i]; + r3 += a[i]; + } + #pragma omp scan inclusive(r, r2, r3) + { + b[i] = r; + b2[i] = r2; + b3[i] = r3; + } + } +} + +__attribute__((noipa)) int +qux (unsigned short *s2p, unsigned char *s3p) +{ + int s = 0; + unsigned short s2 = 0; + unsigned char s3 = 0; + #pragma omp simd reduction (inscan, +:s, s2, s3) simdlen (1) + for (int i = 0; i < 1024; i++) + { + { s += 2 * a[i]; s2 += 2 * a[i]; s3 += 2 * a[i]; } + #pragma omp scan inclusive(s, s2, s3) + { b[i] = s; b2[i] = s2; b3[i] = s3; } + } + *s2p = s2; + *s3p = s3; + return s; +} + +int +main () +{ + int s = 0; + unsigned short s2; + unsigned char s3; +#ifndef main + check_vect (); +#endif + for (int i = 0; i < 1024; ++i) + { + a[i] = i; + b[i] = -1; + b2[i] = -1; + b3[i] = -1; + asm ("" : "+g" (i)); + } + foo (a, b, b2, b3); + if (r != 1024 * 1023 / 2 + || r2 != (unsigned short) r + || r3 != (unsigned char) r) + abort (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += i; + if (b[i] != s + || b2[i] != (unsigned short) s + || b3[i] != (unsigned char) s) + abort (); + else + { + b[i] = 25; + b2[i] = 24; + b3[i] = 26; + } + } + if (bar (&s2, &s3) != 1024 * 1023) + abort (); + if (s2 != (unsigned short) (1024 * 1023) + || s3 != (unsigned char) (1024 * 1023)) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += 2 * i; + if (b[i] != s + || b2[i] != (unsigned short) s + || b3[i] != (unsigned char) s) + abort (); + else + { + b[i] = -1; + b2[i] = -1; + b3[i] = -1; + } + } + r = 0; + r2 = 0; + r3 = 0; + baz (a, b, b2, b3); + if (r != 1024 * 1023 / 2 + || r2 != (unsigned short) r + || r3 != (unsigned char) r) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += i; + if (b[i] != s + || b2[i] != (unsigned short) s + || b3[i] != (unsigned char) s) + abort (); + else + { + b[i] = 25; + b2[i] = 24; + b3[i] = 26; + } + } + s2 = 0; + s3 = 0; + if (qux (&s2, &s3) != 1024 * 1023) + abort (); + if (s2 != (unsigned short) (1024 * 1023) + || s3 != (unsigned char) (1024 * 1023)) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += 2 * i; + if (b[i] != s + || b2[i] != (unsigned short) s + || b3[i] != (unsigned char) s) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-12.c new file mode 100644 index 0000000000..45b5538400 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-12.c @@ -0,0 +1,126 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#ifndef main +#include "tree-vect.h" +#endif + +int r, a[1024], b[1024]; + +__attribute__((noipa)) void +foo (int *a, int *b) +{ + #pragma omp simd reduction (inscan, +:r) + for (int i = 0; i < 1024; i++) + { + b[i] = r; + #pragma omp scan exclusive(r) + r += a[i]; + } +} + +__attribute__((noipa)) int +bar (void) +{ + int s = 0; + #pragma omp simd reduction (inscan, +:s) + for (int i = 0; i < 1024; i++) + { + b[i] = s; + #pragma omp scan exclusive(s) + s += 2 * a[i]; + } + return s; +} + +__attribute__((noipa)) void +baz (int *a, int *b) +{ + #pragma omp simd reduction (inscan, +:r) if (simd: 0) + for (int i = 0; i < 1024; i++) + { + b[i] = r; + #pragma omp scan exclusive(r) + r += a[i]; + } +} + +__attribute__((noipa)) int +qux (void) +{ + int s = 0; + #pragma omp simd reduction (inscan, +:s) simdlen (1) + for (int i = 0; i < 1024; i++) + { + b[i] = s; + #pragma omp scan exclusive(s) + s += 2 * a[i]; + } + return s; +} + +int +main () +{ + int s = 0; +#ifndef main + check_vect (); +#endif + for (int i = 0; i < 1024; ++i) + { + a[i] = i; + b[i] = -1; + asm ("" : "+g" (i)); + } + foo (a, b); + if (r != 1024 * 1023 / 2) + abort (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + else + b[i] = 25; + s += i; + } + if (bar () != 1024 * 1023) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + else + b[i] = -1; + s += 2 * i; + } + r = 0; + baz (a, b); + if (r != 1024 * 1023 / 2) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + else + b[i] = -25; + s += i; + } + if (qux () != 1024 * 1023) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + s += 2 * i; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-13.c new file mode 100644 index 0000000000..3ef4aa9a99 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-13.c @@ -0,0 +1,128 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#ifndef main +#include "tree-vect.h" +#endif + +int r, a[1024], b[1024]; + +#pragma omp declare reduction (foo: int: omp_out += omp_in) initializer (omp_priv = 0) + +__attribute__((noipa)) void +foo (int *a, int *b) +{ + #pragma omp simd reduction (inscan, foo:r) + for (int i = 0; i < 1024; i++) + { + b[i] = r; + #pragma omp scan exclusive(r) + r += a[i]; + } +} + +__attribute__((noipa)) int +bar (void) +{ + int s = 0; + #pragma omp simd reduction (inscan, foo:s) + for (int i = 0; i < 1024; i++) + { + b[i] = s; + #pragma omp scan exclusive(s) + s += 2 * a[i]; + } + return s; +} + +__attribute__((noipa)) void +baz (int *a, int *b) +{ + #pragma omp simd reduction (inscan, foo:r) if (simd: 0) + for (int i = 0; i < 1024; i++) + { + b[i] = r; + #pragma omp scan exclusive(r) + r += a[i]; + } +} + +__attribute__((noipa)) int +qux (void) +{ + int s = 0; + #pragma omp simd reduction (inscan, foo:s) simdlen (1) + for (int i = 0; i < 1024; i++) + { + b[i] = s; + #pragma omp scan exclusive(s) + s += 2 * a[i]; + } + return s; +} + +int +main () +{ + int s = 0; +#ifndef main + check_vect (); +#endif + for (int i = 0; i < 1024; ++i) + { + a[i] = i; + b[i] = -1; + asm ("" : "+g" (i)); + } + foo (a, b); + if (r != 1024 * 1023 / 2) + abort (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + else + b[i] = 25; + s += i; + } + if (bar () != 1024 * 1023) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + else + b[i] = -1; + s += 2 * i; + } + r = 0; + baz (a, b); + if (r != 1024 * 1023 / 2) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + else + b[i] = -25; + s += i; + } + if (qux () != 1024 * 1023) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + s += 2 * i; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-14.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-14.c new file mode 100644 index 0000000000..c8a38f85ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-14.c @@ -0,0 +1,102 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#ifndef main +#include "tree-vect.h" +#endif + +#ifdef __FAST_MATH__ +#define FLT_MIN_VALUE (-__FLT_MAX__) +#else +#define FLT_MIN_VALUE (-__builtin_inff ()) +#endif + +float r = 1.0f, a[1024], b[1024]; + +__attribute__((noipa)) void +foo (float *a, float *b) +{ + #pragma omp simd reduction (inscan, *:r) + for (int i = 0; i < 1024; i++) + { + b[i] = r; + #pragma omp scan exclusive(r) + r *= a[i]; + } +} + +__attribute__((noipa)) float +bar (void) +{ + float s = FLT_MIN_VALUE; + #pragma omp simd reduction (inscan, max:s) + for (int i = 0; i < 1024; i++) + { + b[i] = s; + #pragma omp scan exclusive(s) + s = s > a[i] ? s : a[i]; + } + return s; +} + +int +main () +{ + float s = 1.0f; +#ifndef main + check_vect (); +#endif + for (int i = 0; i < 1024; ++i) + { + if (i < 80) + a[i] = (i & 1) ? 0.25f : 0.5f; + else if (i < 200) + a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f; + else if (i < 280) + a[i] = (i & 1) ? 0.25f : 0.5f; + else if (i < 380) + a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f; + else + switch (i % 6) + { + case 0: a[i] = 0.25f; break; + case 1: a[i] = 2.0f; break; + case 2: a[i] = -1.0f; break; + case 3: a[i] = -4.0f; break; + case 4: a[i] = 0.5f; break; + case 5: a[i] = 1.0f; break; + default: a[i] = 0.0f; break; + } + b[i] = -19.0f; + asm ("" : "+g" (i)); + } + foo (a, b); + if (r * 16384.0f != 0.125f) + abort (); + float m = -175.25f; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + else + b[i] = -231.75f; + s *= a[i]; + a[i] = m - ((i % 3) == 1 ? 2.0f : (i % 3) == 2 ? 4.0f : 0.0f); + m += 0.75f; + } + if (bar () != 592.0f) + abort (); + s = FLT_MIN_VALUE; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s) + abort (); + if (s < a[i]) + s = a[i]; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-15.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-15.c new file mode 100644 index 0000000000..6982a59da7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-15.c @@ -0,0 +1,190 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#ifndef main +#include "tree-vect.h" +#endif + +int r, a[1024], b[1024]; +unsigned short r2, b2[1024]; +unsigned char r3, b3[1024]; + +__attribute__((noipa)) void +foo (int *a, int *b, unsigned short *b2, unsigned char *b3) +{ + #pragma omp simd reduction (inscan, +:r, r2, r3) + for (int i = 0; i < 1024; i++) + { + { + b[i] = r; + b2[i] = r2; + b3[i] = r3; + } + #pragma omp scan exclusive(r, r2, r3) + { r += a[i]; r2 += a[i]; r3 += a[i]; } + } +} + +__attribute__((noipa)) int +bar (unsigned short *s2p, unsigned char *s3p) +{ + int s = 0; + unsigned short s2 = 0; + unsigned char s3 = 0; + #pragma omp simd reduction (inscan, +:s, s2, s3) + for (int i = 0; i < 1024; i++) + { + { b[i] = s; b2[i] = s2; b3[i] = s3; } + #pragma omp scan exclusive(s, s2, s3) + { + s += 2 * a[i]; + s2 += 2 * a[i]; + s3 += 2 * a[i]; + } + } + *s2p = s2; + *s3p = s3; + return s; +} + +__attribute__((noipa)) void +baz (int *a, int *b, unsigned short *b2, unsigned char *b3) +{ + #pragma omp simd reduction (inscan, +:r, r2, r3) if (simd: 0) + for (int i = 0; i < 1024; i++) + { + { + b[i] = r; + b2[i] = r2; + b3[i] = r3; + } + #pragma omp scan exclusive(r, r2, r3) + { + r += a[i]; + r2 += a[i]; + r3 += a[i]; + } + } +} + +__attribute__((noipa)) int +qux (unsigned short *s2p, unsigned char *s3p) +{ + int s = 0; + unsigned short s2 = 0; + unsigned char s3 = 0; + #pragma omp simd reduction (inscan, +:s, s2, s3) simdlen (1) + for (int i = 0; i < 1024; i++) + { + { b[i] = s; b2[i] = s2; b3[i] = s3; } + #pragma omp scan exclusive(s, s2, s3) + { s += 2 * a[i]; s2 += 2 * a[i]; s3 += 2 * a[i]; } + } + *s2p = s2; + *s3p = s3; + return s; +} + +int +main () +{ + int s = 0; + unsigned short s2; + unsigned char s3; +#ifndef main + check_vect (); +#endif + for (int i = 0; i < 1024; ++i) + { + a[i] = i; + b[i] = -1; + b2[i] = -1; + b3[i] = -1; + asm ("" : "+g" (i)); + } + foo (a, b, b2, b3); + if (r != 1024 * 1023 / 2 + || r2 != (unsigned short) r + || r3 != (unsigned char) r) + abort (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s + || b2[i] != (unsigned short) s + || b3[i] != (unsigned char) s) + abort (); + else + { + b[i] = 25; + b2[i] = 24; + b3[i] = 26; + } + s += i; + } + if (bar (&s2, &s3) != 1024 * 1023) + abort (); + if (s2 != (unsigned short) (1024 * 1023) + || s3 != (unsigned char) (1024 * 1023)) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s + || b2[i] != (unsigned short) s + || b3[i] != (unsigned char) s) + abort (); + else + { + b[i] = -1; + b2[i] = -1; + b3[i] = -1; + } + s += 2 * i; + } + r = 0; + r2 = 0; + r3 = 0; + baz (a, b, b2, b3); + if (r != 1024 * 1023 / 2 + || r2 != (unsigned short) r + || r3 != (unsigned char) r) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s + || b2[i] != (unsigned short) s + || b3[i] != (unsigned char) s) + abort (); + else + { + b[i] = 25; + b2[i] = 24; + b3[i] = 26; + } + s += i; + } + s2 = 0; + s3 = 0; + if (qux (&s2, &s3) != 1024 * 1023) + abort (); + if (s2 != (unsigned short) (1024 * 1023) + || s3 != (unsigned char) (1024 * 1023)) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + if (b[i] != s + || b2[i] != (unsigned short) s + || b3[i] != (unsigned char) s) + abort (); + s += 2 * i; + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-16.c new file mode 100644 index 0000000000..1ac13a5c5b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-16.c @@ -0,0 +1,64 @@ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 3 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#include "tree-vect.h" + +__attribute__((noipa)) int +foo (int *a) +{ + int i; + #pragma omp simd lastprivate (i) + for (i = 0; i < 64; i++) + a[i] = i; + return i; +} + +__attribute__((noipa)) void +bar (int *a) +{ + int i; + #pragma omp simd private (i) + for (i = 0; i < 64; i++) + a[i] = i + 1; +} + +__attribute__((noipa)) int +baz (int *a) +{ + int i; + #pragma omp simd linear (i) + for (i = 0; i < 64; i++) + a[i] = i + 2; + return i; +} + +int +main () +{ + int i; + int a[64]; + check_vect (); + if (foo (a) != 64) + abort (); +#pragma GCC novector + for (i = 0; i < 64; ++i) + if (a[i] != i) + abort (); + else + a[i] = -8; + bar (a); +#pragma GCC novector + for (i = 0; i < 64; ++i) + if (a[i] != i + 1) + abort (); + else + a[i] = -8; + if (baz (a) != 64) + abort (); +#pragma GCC novector + for (i = 0; i < 64; ++i) + if (a[i] != i + 2) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-17.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-17.c new file mode 100644 index 0000000000..79b3602a6c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-17.c @@ -0,0 +1,314 @@ +/* { dg-additional-options "-fopenmp-simd -fno-tree-vectorize" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump "vectorized 1\[1-2] loops" "vect" { target i?86-*-* x86_64-*-* } } } */ + +#include "tree-vect.h" + +int x, i, j; +volatile int a, b, c, d, e, f, g, h; +int k[11][101]; + +__attribute__((noipa)) void +doit (void) +{ + int niters, err = 0; + for (i = 1; i <= 10; i++) + for (j = 1; j <= 10 * i; j++) + { + k[i][j] = 1; + asm volatile ("" : : : "memory"); + } + a = 1; b = 11; c = 1; d = 0; e = 1; f = 10; g = 1; h = 1; + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = 1; i <= 10; i++) + for (j = 1; j <= 10 * i; j++) + { + err |= (i < 1); + err |= (i > 10); + err |= (j < 1); + err |= (j > 10 * i); + err |= (k[i][j] != 1); + k[i][j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (i != 11 || j != 101 || x != 10340 || niters != 550 || err) + abort (); + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = a; i < b; i += c) + for (j = d * i + e; j < g + i * f; j += h) + { + err |= (i < 1); + err |= (i > 10); + err |= (j < 1); + err |= (j > 10 * i); + err |= (k[i][j] != 2); + k[i][j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (i != 11 || j != 101 || x != 10340 || niters != 550 || err) + abort (); + for (i = 1; i <= 10; i++) +#pragma GCC novector + for (j = 1; j <= 10 * i; j++) + if (k[i][j] == 3) + k[i][j] = 0; + else + abort (); + for (i = 0; i < 11; i++) +#pragma GCC novector + for (j = 0; j < 101; j++) + if (k[i][j] != 0) + abort (); + for (i = 0; i < 10; i++) + for (j = 0; j < 10 * i; j++) + { + k[i][j] = 1; + asm volatile ("" : : : "memory"); + } + a = 0; b = 10; c = 1; d = 0; e = 0; f = 10; g = 0; h = 1; + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = 0; i < 10; i++) + for (j = 0; j < 10 * i; j++) + { + err |= (i < 0); + err |= (i >= 10); + err |= (j < 0); + err |= (j >= 10 * i); + err |= (k[i][j] != 1); + k[i][j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (i != 10 || j != 90 || x != 9305 || niters != 450 || err) + abort (); + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = a; i < b; i += c) + for (j = d * i + e; j < g + i * f; j += h) + { + err |= (i < 0); + err |= (i >= 10); + err |= (j < 0); + err |= (j >= 10 * i); + err |= (k[i][j] != 2); + k[i][j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (i != 10 || j != 90 || x != 9305 || niters != 450 || err) + abort (); + for (i = 0; i < 10; i++) +#pragma GCC novector + for (j = 0; j < 10 * i; j++) + if (k[i][j] == 3) + k[i][j] = 0; + else + abort (); + for (i = 0; i < 11; i++) +#pragma GCC novector + for (j = 0; j < 101; j++) + if (k[i][j] != 0) + abort (); + for (i = 4; i < 10; i++) + for (j = -9 + 2 * i; j < i; j++) + { + k[i][j + 1] = 1; + asm volatile ("" : : : "memory"); + } + a = 4; b = 10; c = 1; d = 2; e = -9; f = 1; g = 0; h = 1; + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = 4; i < 10; i++) + for (j = -9 + 2 * i; j < i; j++) + { + err |= (i < 4); + err |= (i >= 10); + err |= (j < -9 + 2 * i); + err |= (j >= i); + err |= (k[i][j + 1] != 1); + k[i][j + 1]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (/*i != 10 || j != 9 || */x != 8199 || niters != 15 || err) + abort (); + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = a; i < b; i += c) + for (j = d * i + e; j < g + i * f; j += h) + { + err |= (i < 4); + err |= (i >= 10); + err |= (j < -9 + 2 * i); + err |= (j >= i); + err |= (k[i][j + 1] != 2); + k[i][j + 1]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (/*i != 10 || j != 9 || */x != 8199 || niters != 15 || err) + abort (); + for (i = 4; i < 10; i++) + for (j = -9 + 2 * i; j < i; j++) + if (k[i][j + 1] == 3) + k[i][j + 1] = 0; + else + abort (); + for (i = 0; i < 11; i++) +#pragma GCC novector + for (j = 0; j < 101; j++) + if (k[i][j] != 0) + abort (); + for (i = 1; i < 10; i += 2) + for (j = 1; j < i + 1; j++) + { + k[i][j] = 1; + asm volatile ("" : : : "memory"); + } + a = 1; b = 10; c = 2; d = 0; e = 1; f = 1; g = 1; h = 1; + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = 1; i < 10; i += 2) + for (j = 1; j < i + 1; j++) + { + err |= (i < 1); + err |= (i >= 10); + err |= (j < 1); + err |= (j >= i + 1); + err |= (k[i][j] != 1); + k[i][j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (i != 11 || j != 10 || x != 9225 || niters != 25 || err) + abort (); + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = a; i < b; i += c) + for (j = d * i + e; j < g + i * f; j += h) + { + err |= (i < 1); + err |= (i >= 10); + err |= (j < 1); + err |= (j >= i + 1); + err |= (k[i][j] != 2); + k[i][j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (i != 11 || j != 10 || x != 9225 || niters != 25 || err) + abort (); + for (i = 1; i < 10; i += 2) +#pragma GCC novector + for (j = 1; j < i + 1; j++) + if (k[i][j] == 3) + k[i][j] = 0; + else + abort (); + for (i = 0; i < 11; i++) +#pragma GCC novector + for (j = 0; j < 101; j++) + if (k[i][j] != 0) + abort (); + for (j = -11; j >= -41; j -= 15) + { + k[0][-j] = 1; + asm volatile ("" : : : "memory"); + } + a = 4; b = 8; c = 12; d = -8; e = -9; f = -3; g = 6; h = 15; + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = 4; i < 8; i += 12) + for (j = -8 * i - 9; j < i * -3 + 6; j += 15) + { + err |= (i != 4); + err |= (j < -41); + err |= (j > -11); + err |= (k[0][-j] != 1); + k[0][-j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (i != 16 || j != 4 || x != 5109 || niters != 3 || err) + abort (); + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = a; i < b; i += c) + for (j = d * i + e; j < g + i * f; j += h) + { + err |= (i != 4); + err |= (j < -41); + err |= (j > -11); + err |= (k[0][-j] != 2); + k[0][-j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (i != 16 || j != 4 || x != 5109 || niters != 3 || err) + abort (); +#pragma GCC novector + for (j = -11; j >= -41; j -= 15) + if (k[0][-j] == 3) + k[0][-j] = 0; + else + abort (); +#pragma GCC novector + for (j = -11; j >= -41; j--) + if (k[0][-j] != 0) + abort (); + for (j = -34; j <= -7; j++) + { + k[0][-j] = 1; + asm volatile ("" : : : "memory"); + } + a = -13; b = 7; c = 12; d = 3; e = 5; f = 0; g = -6; h = 1; + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = -13; i < 7; i += 12) + for (j = 3 * i + 5; j < -6; j++) + { + err |= (i != -13); + err |= (j < -34); + err |= (j > -7); + err |= (k[0][-j] != 1); + k[0][-j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (/*i != 11 || j != 2 || */x != -12295 || niters != 28 || err) + abort (); + niters = 0; i = -100; j = -100; x = -100; + #pragma omp simd collapse(2) lastprivate (i, j, x) reduction(+:niters) reduction(|:err) + for (i = a; i < b; i += c) + for (j = d * i + e; j < g + i * f; j += h) + { + err |= (i != -13); + err |= (j < -34); + err |= (j > -7); + err |= (k[0][-j] != 2); + k[0][-j]++; + x = i * 1024 + (j & 1023); + niters++; + } + if (/*i != 11 || j != 2 || */x != -12295 || niters != 28 || err) + abort (); +#pragma GCC novector + for (j = -34; j <= -7; j++) + if (k[0][-j] == 3) + k[0][-j] = 0; + else + abort (); +} + +int +main () +{ + check_vect (); + doit (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-18.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-18.c new file mode 100644 index 0000000000..e454abe880 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-18.c @@ -0,0 +1,42 @@ +/* { dg-additional-options "-fopenmp-simd -fno-tree-vectorize" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target i?86-*-* x86_64-*-* } } } */ + +#include "tree-vect.h" + +__attribute__((noipa)) int +foo (int s, int *p) +{ + int r = 0, l = 0, i; + #pragma omp simd reduction (+:r) linear(l) + for (i = 0; i < 10000; i += s) + { + p[l++] = i; + r += i * 3; + } + return r; +} + +int p[10000 / 78 + 1]; + +int +main () +{ + int i, r; + check_vect (); + r = foo (78, p); +#pragma GCC novector + for (i = 0; i < 10000 / 78; i++) + if (p[i] != 78 * i) + abort (); + if (r != (10000 / 78) * (10000 / 78 + 1) / 2 * 78 * 3) + abort (); + r = foo (87, p); +#pragma GCC novector + for (i = 0; i < 10000 / 87; i++) + if (p[i] != 87 * i) + abort (); + if (r != (10000 / 87) * (10000 / 87 + 1) / 2 * 87 * 3) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-19.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-19.c new file mode 100644 index 0000000000..4d25b43f5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-19.c @@ -0,0 +1,42 @@ +/* { dg-additional-options "-fopenmp-simd -fno-tree-vectorize" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target i?86-*-* x86_64-*-* } } } */ + +#include "tree-vect.h" + +__attribute__((noipa)) int +foo (int s, int m, int n, int *p) +{ + int r = 0, l = 0, i; + #pragma omp simd reduction (+:r) linear(l) + for (i = m; i < n; i += s) + { + p[l++] = i; + r += i * 3; + } + return r; +} + +int p[10000 / 78 + 1]; + +int +main () +{ + int i, r; + check_vect (); + r = foo (78, 0, 10000, p); +#pragma GCC novector + for (i = 0; i < 10000 / 78; i++) + if (p[i] != 78 * i) + abort (); + if (r != (10000 / 78) * (10000 / 78 + 1) / 2 * 78 * 3) + abort (); + r = foo (87, 0, 10000, p); +#pragma GCC novector + for (i = 0; i < 10000 / 87; i++) + if (p[i] != 87 * i) + abort (); + if (r != (10000 / 87) * (10000 / 87 + 1) / 2 * 87 * 3) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-2.c new file mode 100644 index 0000000000..42bb782a80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#define N 1024 +int a[N]; +int bar (void); + +void +foo (void) +{ + #pragma omp simd if (bar ()) + for (int i = 0; i < N; ++i) + a[i] = a[i] + 1; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "created versioning for simd if condition check" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-20.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-20.c new file mode 100644 index 0000000000..9ba7c3ce95 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-20.c @@ -0,0 +1,45 @@ +/* { dg-additional-options "-fopenmp-simd -fno-tree-vectorize" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target i?86-*-* x86_64-*-* } } } */ + +#include "tree-vect.h" + +__attribute__((noipa)) int +foo (int s, int m, int n, int *p) +{ + int r = 0, l = 0, i, j; + #pragma omp simd reduction (+:r) linear(l) collapse(2) + for (j = 0; j < 7; j++) + for (i = m; i < n; i += s) + { + p[l++] = i; + r += i * 3; + } + return r; +} + +int p[((10000 / 78) + 1) * 7]; + +int +main () +{ + int i, j, r; + check_vect (); + r = foo (78, 0, 10000, p); + for (j = 0; j < 7; j++) +#pragma GCC novector + for (i = 0; i < 10000 / 78; i++) + if (p[j * (10000 / 78 + 1) + i] != 78 * i) + abort (); + if (r != (10000 / 78) * (10000 / 78 + 1) / 2 * 78 * 3 * 7) + abort (); + r = foo (87, 0, 10000, p); + for (j = 0; j < 7; j++) +#pragma GCC novector + for (i = 0; i < 10000 / 87; i++) + if (p[j * (10000 / 87 + 1) + i] != 87 * i) + abort (); + if (r != (10000 / 87) * (10000 / 87 + 1) / 2 * 87 * 3 * 7) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-3.c new file mode 100644 index 0000000000..ff7f0dcc7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#define N 1024 +int a[N]; + +void +foo (void) +{ + int c = 0; + #pragma omp simd if (c) + for (int i = 0; i < N; ++i) + a[i] = a[i] + 1; +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-4.c new file mode 100644 index 0000000000..b78b7b1dbe --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#define N 1024 +int a[N]; + +void +foo (void) +{ + int c = 1; + #pragma omp simd if (c) + for (int i = 0; i < N; ++i) + a[i] = a[i] + 1; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-not "created versioning for simd if condition check" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-5.c new file mode 100644 index 0000000000..bacb2476e8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-5.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_condition } } } */ + +int x; + +void +foo (int *a) +{ + #pragma omp simd lastprivate (x) + for (int i = 0; i < 1024; ++i) + if (a[i]) + x = i; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-6.c new file mode 100644 index 0000000000..b7e951468b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-6.c @@ -0,0 +1,52 @@ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-final { scan-tree-dump-times "vectorized \[12] loops" 2 "vect" { target vect_condition } } } */ + +#include "tree-vect.h" + +int v; + +__attribute__((noipa)) int +foo (int *a) +{ + int x = 5; + #pragma omp simd lastprivate (conditional: x) + for (int i = 0; i < 128; i++) + if (a[i]) + x = a[i]; + return x; +} + +__attribute__((noipa)) int +bar (int *a, int *b) +{ + int x = 0; + #pragma omp simd lastprivate (conditional: x, v) + for (int i = 16; i < 128; ++i) + { + if (a[i]) + x = a[i]; + if (b[i]) + v = b[i] + 10; + } + return x; +} + +int +main () +{ + int a[128], b[128], i; + check_vect (); + for (i = 0; i < 128; i++) + { + a[i] = ((i % 11) == 2) ? i + 10 : 0; + asm volatile ("" : "+g" (i)); + b[i] = ((i % 13) == 5) ? i * 2 : 0; + } + if (foo (a) != 133) + abort (); + if (bar (b, a) != 244) + abort (); + if (v != 143) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-7.c new file mode 100644 index 0000000000..15e0c51bec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-7.c @@ -0,0 +1,51 @@ +/* { dg-additional-options "-fopenmp-simd" } */ + +#include "tree-vect.h" + +int v; + +__attribute__((noipa)) int +foo (int *a) +{ + int x = 5; + #pragma omp simd lastprivate (conditional: x) safelen (1) + for (int i = 0; i < 128; i++) + if (a[i]) + x = a[i]; + return x; +} + +__attribute__((noipa)) int +bar (int *a, int *b) +{ + int x = 0; + #pragma omp simd lastprivate (conditional: x, v) if (0) + for (int i = 16; i < 128; ++i) + { + if (a[i]) + x = a[i]; + if (b[i]) + v = b[i] + 10; + } + return x; +} + +int +main () +{ + int a[128], b[128], i; + check_vect (); + for (i = 0; i < 128; i++) + { + a[i] = ((i % 11) == 2) ? i + 10 : 0; + asm volatile ("" : "+g" (i)); + b[i] = ((i % 13) == 5) ? i * 2 : 0; + } + if (foo (a) != 133) + abort (); + if (bar (b, a) != 244) + abort (); + if (v != 143) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-8.c new file mode 100644 index 0000000000..a3c2decee2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-8.c @@ -0,0 +1,126 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#ifndef main +#include "tree-vect.h" +#endif + +int r, a[1024], b[1024]; + +__attribute__((noipa)) void +foo (int *a, int *b) +{ + #pragma omp simd reduction (inscan, +:r) + for (int i = 0; i < 1024; i++) + { + r += a[i]; + #pragma omp scan inclusive(r) + b[i] = r; + } +} + +__attribute__((noipa)) int +bar (void) +{ + int s = 0; + #pragma omp simd reduction (inscan, +:s) + for (int i = 0; i < 1024; i++) + { + s += 2 * a[i]; + #pragma omp scan inclusive(s) + b[i] = s; + } + return s; +} + +__attribute__((noipa)) void +baz (int *a, int *b) +{ + #pragma omp simd reduction (inscan, +:r) if (simd: 0) + for (int i = 0; i < 1024; i++) + { + r += a[i]; + #pragma omp scan inclusive(r) + b[i] = r; + } +} + +__attribute__((noipa)) int +qux (void) +{ + int s = 0; + #pragma omp simd reduction (inscan, +:s) simdlen (1) + for (int i = 0; i < 1024; i++) + { + s += 2 * a[i]; + #pragma omp scan inclusive(s) + b[i] = s; + } + return s; +} + +int +main () +{ + int s = 0; +#ifndef main + check_vect (); +#endif + for (int i = 0; i < 1024; ++i) + { + a[i] = i; + b[i] = -1; + asm ("" : "+g" (i)); + } + foo (a, b); + if (r != 1024 * 1023 / 2) + abort (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += i; + if (b[i] != s) + abort (); + else + b[i] = 25; + } + if (bar () != 1024 * 1023) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += 2 * i; + if (b[i] != s) + abort (); + else + b[i] = -1; + } + r = 0; + baz (a, b); + if (r != 1024 * 1023 / 2) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += i; + if (b[i] != s) + abort (); + else + b[i] = -25; + } + if (qux () != 1024 * 1023) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += 2 * i; + if (b[i] != s) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-9.c new file mode 100644 index 0000000000..b652759e5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-9.c @@ -0,0 +1,128 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#ifndef main +#include "tree-vect.h" +#endif + +int r, a[1024], b[1024]; + +#pragma omp declare reduction (foo: int: omp_out += omp_in) initializer (omp_priv = 0) + +__attribute__((noipa)) void +foo (int *a, int *b) +{ + #pragma omp simd reduction (inscan, foo:r) + for (int i = 0; i < 1024; i++) + { + r += a[i]; + #pragma omp scan inclusive(r) + b[i] = r; + } +} + +__attribute__((noipa)) int +bar (void) +{ + int s = 0; + #pragma omp simd reduction (inscan, foo:s) + for (int i = 0; i < 1024; i++) + { + s += 2 * a[i]; + #pragma omp scan inclusive(s) + b[i] = s; + } + return s; +} + +__attribute__((noipa)) void +baz (int *a, int *b) +{ + #pragma omp simd reduction (inscan, foo:r) if (simd: 0) + for (int i = 0; i < 1024; i++) + { + r += a[i]; + #pragma omp scan inclusive(r) + b[i] = r; + } +} + +__attribute__((noipa)) int +qux (void) +{ + int s = 0; + #pragma omp simd reduction (inscan, foo:s) simdlen (1) + for (int i = 0; i < 1024; i++) + { + s += 2 * a[i]; + #pragma omp scan inclusive(s) + b[i] = s; + } + return s; +} + +int +main () +{ + int s = 0; +#ifndef main + check_vect (); +#endif + for (int i = 0; i < 1024; ++i) + { + a[i] = i; + b[i] = -1; + asm ("" : "+g" (i)); + } + foo (a, b); + if (r != 1024 * 1023 / 2) + abort (); +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += i; + if (b[i] != s) + abort (); + else + b[i] = 25; + } + if (bar () != 1024 * 1023) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += 2 * i; + if (b[i] != s) + abort (); + else + b[i] = -1; + } + r = 0; + baz (a, b); + if (r != 1024 * 1023 / 2) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += i; + if (b[i] != s) + abort (); + else + b[i] = -25; + } + if (qux () != 1024 * 1023) + abort (); + s = 0; +#pragma GCC novector + for (int i = 0; i < 1024; ++i) + { + s += 2 * i; + if (b[i] != s) + abort (); + } + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-1.c new file mode 100644 index 0000000000..6bd4af3671 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-1.c @@ -0,0 +1,66 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int array[N]; + +#pragma omp declare simd simdlen(4) notinbranch +#pragma omp declare simd simdlen(4) notinbranch uniform(b) linear(c:3) +#ifdef __aarch64__ +#pragma omp declare simd simdlen(2) notinbranch +#pragma omp declare simd simdlen(2) notinbranch uniform(b) linear(c:3) +#else +#pragma omp declare simd simdlen(8) notinbranch +#pragma omp declare simd simdlen(8) notinbranch uniform(b) linear(c:3) +#endif +__attribute__((noinline)) int +foo (int a, int b, int c) +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */ +/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } .-2 } */ +{ + if (a < 30) + return 5; + return a + b + c; +} + +__attribute__((noinline, noclone)) void +bar () +{ + int i; +#pragma omp simd + for (i = 0; i < N; ++i) + array[i] = foo (i, 123, i * 3); +} + +__attribute__((noinline, noclone)) void +baz () +{ + int i; +#pragma omp simd + for (i = 0; i < N; ++i) + array[i] = foo (i, array[i], i * 3); +} + +int +main () +{ + int i; + check_vect (); + bar (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (array[i] != (i < 30 ? 5 : i * 4 + 123)) + abort (); + baz (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (array[i] != (i < 30 ? 5 : i * 8 + 123)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10.c new file mode 100644 index 0000000000..ed63ff59cc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10.c @@ -0,0 +1,85 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-additional-sources vect-simd-clone-10a.c } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int a[N], b[N]; +long int c[N]; +unsigned char d[N]; + +#include "vect-simd-clone-10.h" + +__attribute__((noinline)) void +fn1 (void) +{ + int i; + #pragma omp simd + for (i = 0; i < N; i++) + a[i] = foo (c[i], a[i], b[i]) + 6; + #pragma omp simd + for (i = 0; i < N; i++) + c[i] = bar (a[i], b[i], c[i]) * 2; +} + +__attribute__((noinline)) void +fn2 (void) +{ + int i; + #pragma omp simd + for (i = 0; i < N; i++) + { + a[i] = foo (c[i], a[i], b[i]) + 6; + d[i]++; + } + #pragma omp simd + for (i = 0; i < N; i++) + { + c[i] = bar (a[i], b[i], c[i]) * 2; + d[i] /= 2; + } +} + +__attribute__((noinline)) void +fn3 (void) +{ + int i; + for (i = 0; i < N; i++) + { + a[i] = i * 2; + b[i] = 17 + (i % 37); + c[i] = (i & 63); + d[i] = 16 + i; + } +} + +int +main () +{ + int i; + check_vect (); + fn3 (); + fn1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * 2 + 23 + (i % 37) + (i & 63) + || b[i] != 17 + (i % 37) + || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63)) + abort (); + fn3 (); + fn2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * 2 + 23 + (i % 37) + (i & 63) + || b[i] != 17 + (i % 37) + || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63) + || d[i] != ((unsigned char) (17 + i)) / 2) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10.h b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10.h new file mode 100644 index 0000000000..ac3b81f861 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10.h @@ -0,0 +1,4 @@ +#pragma omp declare simd notinbranch +extern int foo (long int a, int b, int c); +#pragma omp declare simd notinbranch +extern long int bar (int a, int b, long int c); diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10a.c new file mode 100644 index 0000000000..771b38ef1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-10a.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +#include "vect-simd-clone-10.h" + +#pragma omp declare simd notinbranch +int +foo (long int a, int b, int c) +{ + return a + b + c; +} + +#pragma omp declare simd notinbranch +long int +bar (int a, int b, long int c) +{ + return a + b + c; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-11.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-11.c new file mode 100644 index 0000000000..4974e5cc0c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-11.c @@ -0,0 +1,70 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int a[N] __attribute__((aligned (32))); + +#pragma omp declare simd linear(a) linear(b:3) linear(c:6) notinbranch +__attribute__((noinline)) int +foo (int a, int b, int c) +{ + return a ^ (b * 512) ^ (c * 512 * 512); +} + +__attribute__((noinline, noclone)) void +bar (int *d) +{ + int i, j, k; + for (i = 0, j = 0, k = 0; i < N / 2; i++, j++, k += 3) + d[i] = foo (j, i * 3, 2 * k + 2); +} + +#if 0 +__attribute__((noinline, noclone)) void +baz (int *d) +{ + long int i, j, k; + for (i = 0, j = 0, k = 0; i < N / 2; + i = (int) i + 1, j = (int) j + 1, k = (int) k + 3) + d[i] = foo (j, i * 3, 2 * k + 2); +} +#endif + +int +main () +{ + int i; + check_vect (); + if (sizeof (int) * __CHAR_BIT__ < 32) + return 0; + bar (a + 7); +#pragma GCC novector + for (i = 0; i < N / 2; i++) + if (a[i + 7] != (i ^ (i * 3 * 512) ^ (((i * 6) + 2) * 512 * 512))) + abort (); + bar (a); +#pragma GCC novector + for (i = 0; i < N / 2; i++) + if (a[i] != (i ^ (i * 3 * 512) ^ (((i * 6) + 2) * 512 * 512))) + abort (); +#if 0 + baz (a + 7); +#pragma GCC novector + for (i = 0; i < N / 2; i++) + if (a[i + 7] != (i ^ (i * 3 * 512) ^ (((i * 6) + 2) * 512 * 512))) + abort (); + baz (a); +#pragma GCC novector + for (i = 0; i < N / 2; i++) + if (a[i] != (i ^ (i * 3 * 512) ^ (((i * 6) + 2) * 512 * 512))) + abort (); +#endif + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-12.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-12.c new file mode 100644 index 0000000000..c44471e35b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-12.c @@ -0,0 +1,7 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-additional-sources vect-simd-clone-12a.c } */ + +#include "vect-simd-clone-10.c" + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-12a.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-12a.c new file mode 100644 index 0000000000..1c8fd1aecc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-12a.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +#include "vect-simd-clone-10.h" + +#pragma omp declare simd notinbranch +__attribute__((noinline)) int +foo (long int a, int b, int c) +{ + return a + b + c; +} + +#pragma omp declare simd notinbranch +__attribute__((noinline)) long int +bar (int a, int b, long int c) +{ + return a + b + c; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-13.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-13.c new file mode 100644 index 0000000000..9fe1eb4655 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-13.c @@ -0,0 +1,6 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd -fcommon" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "vect-simd-clone-6.c" + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-14.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-14.c new file mode 100644 index 0000000000..5d49f956e9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-14.c @@ -0,0 +1,6 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd -fcommon" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "vect-simd-clone-11.c" + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-15.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-15.c new file mode 100644 index 0000000000..866f1000f3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-15.c @@ -0,0 +1,40 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int array[N]; + +#pragma omp declare simd linear(val(b):-3), notinbranch +__attribute__((noinline)) int +foo (int a, int b) +{ + return a + b; +} + +__attribute__((noinline, noclone)) void +bar () +{ + int i; +#pragma omp simd + for (i = 0; i < N; ++i) + array[i] = foo (i >> 1, -i * 3); +} + +int +main () +{ + int i; + check_vect (); + bar (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (array[i] != ((i >> 1) + (-3 * i))) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16.c new file mode 100644 index 0000000000..125ff4f6c8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16.c @@ -0,0 +1,87 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +/* Test that simd inbranch clones work correctly. */ + +#ifndef TYPE +#define TYPE int +#endif + +/* A simple function that will be cloned. */ +#pragma omp declare simd inbranch +TYPE __attribute__((noinline)) +foo (TYPE a) +{ + return a + 1; +} + +/* Check that "inbranch" clones are called correctly. */ + +void __attribute__((noipa)) +masked (TYPE * __restrict a, TYPE * __restrict b, int size) +{ + #pragma omp simd + for (int i = 0; i < size; i++) + b[i] = a[i]<1 ? foo(a[i]) : a[i]; +} + +/* Check that "inbranch" works when there might be unrolling. */ + +void __attribute__((noipa)) +masked_fixed (TYPE * __restrict a, TYPE * __restrict b) +{ + #pragma omp simd + for (int i = 0; i < 128; i++) + b[i] = a[i]<1 ? foo(a[i]) : a[i]; +} + +/* Validate the outputs. */ + +void +check_masked (TYPE *b, int size) +{ + for (int i = 0; i < size; i++) + if (((TYPE)i < 1 && b[i] != (TYPE)(i + 1)) + || ((TYPE)i >= 1 && b[i] != (TYPE)i)) + { + __builtin_printf ("error at %d\n", i); + __builtin_exit (1); + } +} + +int +main () +{ + TYPE a[1024]; + TYPE b[1024]; + + for (int i = 0; i < 1024; i++) + a[i] = i; + + masked_fixed (a, b); + check_masked (b, 128); + + /* Test various sizes to cover machines with different vectorization + factors. */ + for (int size = 8; size <= 1024; size *= 2) + { + masked (a, b, size); + check_masked (b, size); + } + + /* Test sizes that might exercise the partial vector code-path. */ + for (int size = 8; size <= 1024; size *= 2) + { + masked (a, b, size-4); + check_masked (b, size-4); + } + + return 0; +} + +/* Ensure the the in-branch simd clones are used on targets that support them. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16b.c new file mode 100644 index 0000000000..af543b6573 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16b.c @@ -0,0 +1,14 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE float +#include "vect-simd-clone-16.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { avx_runtime || aarch64*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { avx_runtime || aarch64*-*-* } } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16c.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16c.c new file mode 100644 index 0000000000..677548a943 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16c.c @@ -0,0 +1,17 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE short +#include "vect-simd-clone-16.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { x86_64*-*-* || { i686*-*-* || aarch64*-*-* } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { aarch64*-*-* } } } } */ + +/* x86_64 fails to use in-branch clones for TYPE=short. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 0 "vect" { target x86_64*-*-* i686*-*-* } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16d.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16d.c new file mode 100644 index 0000000000..a9ae9932b3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16d.c @@ -0,0 +1,17 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE char +#include "vect-simd-clone-16.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { x86_64*-*-* || { i686*-*-* || aarch64*-*-* } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { aarch64*-*-* } } } } */ + +/* x86_64 fails to use in-branch clones for TYPE=char. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 0 "vect" { target x86_64*-*-* i686*-*-* } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16e.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16e.c new file mode 100644 index 0000000000..f80b0e0581 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16e.c @@ -0,0 +1,16 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE double +#include "vect-simd-clone-16.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. + Some targets use pairs of vectors and do twice the calls. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { { ! avx_runtime } && { ! { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { avx_runtime && { ! { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 4 "vect" { target { { ! avx_runtime } && { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16f.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16f.c new file mode 100644 index 0000000000..7cd29e894d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-16f.c @@ -0,0 +1,14 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ + +#define TYPE __INT64_TYPE__ +#include "vect-simd-clone-16.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17.c new file mode 100644 index 0000000000..3430d6f5aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17.c @@ -0,0 +1,87 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +/* Test that simd inbranch clones work correctly. */ + +#ifndef TYPE +#define TYPE int +#endif + +/* A simple function that will be cloned. */ +#pragma omp declare simd inbranch uniform(b) +TYPE __attribute__((noinline)) +foo (TYPE a, TYPE b) +{ + return a + b; +} + +/* Check that "inbranch" clones are called correctly. */ + +void __attribute__((noipa)) +masked (TYPE * __restrict a, TYPE * __restrict b, int size) +{ + #pragma omp simd + for (int i = 0; i < size; i++) + b[i] = a[i]<1 ? foo(a[i], 1) : a[i]; +} + +/* Check that "inbranch" works when there might be unrolling. */ + +void __attribute__((noipa)) +masked_fixed (TYPE * __restrict a, TYPE * __restrict b) +{ + #pragma omp simd + for (int i = 0; i < 128; i++) + b[i] = a[i]<1 ? foo(a[i], 1) : a[i]; +} + +/* Validate the outputs. */ + +void +check_masked (TYPE *b, int size) +{ + for (int i = 0; i < size; i++) + if (((TYPE)i < 1 && b[i] != (TYPE)(i + 1)) + || ((TYPE)i >= 1 && b[i] != (TYPE)i)) + { + __builtin_printf ("error at %d\n", i); + __builtin_exit (1); + } +} + +int +main () +{ + TYPE a[1024]; + TYPE b[1024]; + + for (int i = 0; i < 1024; i++) + a[i] = i; + + masked_fixed (a, b); + check_masked (b, 128); + + /* Test various sizes to cover machines with different vectorization + factors. */ + for (int size = 8; size <= 1024; size *= 2) + { + masked (a, b, size); + check_masked (b, size); + } + + /* Test sizes that might exercise the partial vector code-path. */ + for (int size = 8; size <= 1024; size *= 2) + { + masked (a, b, size-4); + check_masked (b, size-4); + } + + return 0; +} + +/* Ensure the the in-branch simd clones are used on targets that support them. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17b.c new file mode 100644 index 0000000000..8731c26864 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17b.c @@ -0,0 +1,14 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE float +#include "vect-simd-clone-17.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { avx_runtime || aarch64*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { avx_runtime || aarch64*-*-* } } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17c.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17c.c new file mode 100644 index 0000000000..6683d1a9cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17c.c @@ -0,0 +1,17 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE short +#include "vect-simd-clone-17.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { x86_64*-*-* || { i686*-*-* || aarch64*-*-* } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { aarch64*-*-* } } } } */ + +/* x86_64 fails to use in-branch clones for TYPE=short. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 0 "vect" { target x86_64*-*-* i686*-*-* } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17d.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17d.c new file mode 100644 index 0000000000..8a7e1e912f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17d.c @@ -0,0 +1,17 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE char +#include "vect-simd-clone-17.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { x86_64*-*-* || { i686*-*-* || aarch64*-*-* } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { aarch64*-*-* } } } } */ + +/* x86_64 fails to use in-branch clones for TYPE=char. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 0 "vect" { target x86_64*-*-* i686*-*-* } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17e.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17e.c new file mode 100644 index 0000000000..c7c510b8a6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17e.c @@ -0,0 +1,16 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE double +#include "vect-simd-clone-17.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. + Some targets use pairs of vectors and do twice the calls. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { { ! avx_runtime } && { ! { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { avx_runtime && { ! { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 4 "vect" { target { { ! avx_runtime } && { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17f.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17f.c new file mode 100644 index 0000000000..177521dc44 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-17f.c @@ -0,0 +1,14 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ + +#define TYPE __INT64_TYPE__ +#include "vect-simd-clone-17.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18.c new file mode 100644 index 0000000000..5324aee29c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18.c @@ -0,0 +1,87 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +/* Test that simd inbranch clones work correctly. */ + +#ifndef TYPE +#define TYPE int +#endif + +/* A simple function that will be cloned. */ +#pragma omp declare simd inbranch uniform(b) +TYPE __attribute__((noinline)) +foo (TYPE b, TYPE a) +{ + return a + b; +} + +/* Check that "inbranch" clones are called correctly. */ + +void __attribute__((noipa)) +masked (TYPE * __restrict a, TYPE * __restrict b, int size) +{ + #pragma omp simd + for (int i = 0; i < size; i++) + b[i] = a[i]<1 ? foo(1, a[i]) : a[i]; +} + +/* Check that "inbranch" works when there might be unrolling. */ + +void __attribute__((noipa)) +masked_fixed (TYPE * __restrict a, TYPE * __restrict b) +{ + #pragma omp simd + for (int i = 0; i < 128; i++) + b[i] = a[i]<1 ? foo(1, a[i]) : a[i]; +} + +/* Validate the outputs. */ + +void +check_masked (TYPE *b, int size) +{ + for (int i = 0; i < size; i++) + if (((TYPE)i < 1 && b[i] != (TYPE)(i + 1)) + || ((TYPE)i >= 1 && b[i] != (TYPE)i)) + { + __builtin_printf ("error at %d\n", i); + __builtin_exit (1); + } +} + +int +main () +{ + TYPE a[1024]; + TYPE b[1024]; + + for (int i = 0; i < 1024; i++) + a[i] = i; + + masked_fixed (a, b); + check_masked (b, 128); + + /* Test various sizes to cover machines with different vectorization + factors. */ + for (int size = 8; size <= 1024; size *= 2) + { + masked (a, b, size); + check_masked (b, size); + } + + /* Test sizes that might exercise the partial vector code-path. */ + for (int size = 8; size <= 1024; size *= 2) + { + masked (a, b, size-4); + check_masked (b, size-4); + } + + return 0; +} + +/* Ensure the the in-branch simd clones are used on targets that support them. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18b.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18b.c new file mode 100644 index 0000000000..120993e517 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18b.c @@ -0,0 +1,14 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE float +#include "vect-simd-clone-18.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { avx_runtime || aarch64*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { avx_runtime || aarch64*-*-* } } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18c.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18c.c new file mode 100644 index 0000000000..0d1fc6de4e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18c.c @@ -0,0 +1,17 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE short +#include "vect-simd-clone-18.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { x86_64*-*-* || { i686*-*-* || aarch64*-*-* } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { aarch64*-*-* } } } } */ + +/* x86_64 fails to use in-branch clones for TYPE=short. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 0 "vect" { target x86_64*-*-* i686*-*-* } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18d.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18d.c new file mode 100644 index 0000000000..1e6c028fc4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18d.c @@ -0,0 +1,17 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE char +#include "vect-simd-clone-18.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { ! { x86_64*-*-* || { i686*-*-* || aarch64*-*-* } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { aarch64*-*-* } } } } */ + +/* x86_64 fails to use in-branch clones for TYPE=char. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 0 "vect" { target x86_64*-*-* i686*-*-* } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18e.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18e.c new file mode 100644 index 0000000000..e00c3d7803 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18e.c @@ -0,0 +1,16 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#define TYPE double +#include "vect-simd-clone-18.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + Some targets use another call for the epilogue loops. + Some targets use pairs of vectors and do twice the calls. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { { ! avx_runtime } && { ! { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 3 "vect" { target { avx_runtime && { ! { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 4 "vect" { target { { ! avx_runtime } && { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18f.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18f.c new file mode 100644 index 0000000000..4dd51381d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-18f.c @@ -0,0 +1,14 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ + +#define TYPE __INT64_TYPE__ +#include "vect-simd-clone-18.c" + +/* Ensure the the in-branch simd clones are used on targets that support them. + */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-19.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-19.c new file mode 100644 index 0000000000..e7ed56ca75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-19.c @@ -0,0 +1,22 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-do compile } */ + +int __attribute__ ((__simd__, const)) fn (int); + +void test (int * __restrict__ a, int * __restrict__ b, int n) +{ + for (int i = 0; i < n; ++i) + { + int a_; + if (b[i] > 0) + a_ = fn (b[i]); + else + a_ = b[i] + 5; + a[i] = a_; + } +} + +/* { dg-final { scan-tree-dump-not {loop contains function calls or data references} "vect" } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-2.c new file mode 100644 index 0000000000..e31280ad15 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-2.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int array[N] __attribute__((aligned (32))); + +#pragma omp declare simd simdlen(4) notinbranch aligned(a:16) uniform(a) linear(b) +#pragma omp declare simd simdlen(4) notinbranch aligned(a:32) uniform(a) linear(b) +#ifdef __aarch64__ +#pragma omp declare simd simdlen(2) notinbranch aligned(a:16) uniform(a) linear(b) +#pragma omp declare simd simdlen(2) notinbranch aligned(a:32) uniform(a) linear(b) +#else +#pragma omp declare simd simdlen(8) notinbranch aligned(a:16) uniform(a) linear(b) +#pragma omp declare simd simdlen(8) notinbranch aligned(a:32) uniform(a) linear(b) +#endif +__attribute__((noinline)) void +foo (int *a, int b, int c) +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */ +/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } .-2 } */ +{ + a[b] = c; +} + +__attribute__((noinline, noclone)) void +bar () +{ + int i; +#pragma omp simd + for (i = 0; i < N; ++i) + foo (array, i, i * array[i]); +} + +__attribute__((noinline, noclone)) void +baz () +{ + int i; + for (i = 0; i < N; i++) + array[i] = 5 * (i & 7); +} + +int +main () +{ + int i; + check_vect (); + baz (); + bar (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (array[i] != 5 * (i & 7) * i) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-20.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-20.c new file mode 100644 index 0000000000..9f51a68f3a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-20.c @@ -0,0 +1,87 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +/* Test that simd inbranch clones work correctly. */ + +#ifndef TYPE +#define TYPE int +#endif + +/* A simple function that will be cloned. */ +#pragma omp declare simd inbranch +TYPE __attribute__((noinline)) +foo (TYPE a) +{ + return a + 1; +} + +/* Check that "inbranch" clones are called correctly. */ + +void __attribute__((noipa)) +masked (TYPE * __restrict a, TYPE * __restrict b, int size) +{ + #pragma omp simd + for (int i = 0; i < size; i++) + b[i] = foo(a[i]); +} + +/* Check that "inbranch" works when there might be unrolling. */ + +void __attribute__((noipa)) +masked_fixed (TYPE * __restrict a, TYPE * __restrict b) +{ + #pragma omp simd + for (int i = 0; i < 128; i++) + b[i] = foo(a[i]); +} + +/* Validate the outputs. */ + +void +check_masked (TYPE *b, int size) +{ + for (int i = 0; i < size; i++) + if (b[i] != (TYPE)(i + 1)) + { + __builtin_printf ("error at %d\n", i); + __builtin_exit (1); + } +} + +int +main () +{ + TYPE a[1024]; + TYPE b[1024]; + + for (int i = 0; i < 1024; i++) + a[i] = i; + + masked_fixed (a, b); + check_masked (b, 128); + + /* Test various sizes to cover machines with different vectorization + factors. */ + for (int size = 8; size <= 1024; size *= 2) + { + masked (a, b, size); + check_masked (b, size); + } + + /* Test sizes that might exercise the partial vector code-path. */ + for (int size = 8; size <= 1024; size *= 2) + { + masked (a, b, size-4); + check_masked (b, size-4); + } + + return 0; +} + +/* Ensure the the in-branch simd clones are used on targets that support them. */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { aarch64*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 4 "vect" { target { x86_64*-*-* } } } } */ + +/* The LTO test produces two dump files and we scan the wrong one. */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-3.c new file mode 100644 index 0000000000..45f0fb6125 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-3.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int d[N], e[N]; + +#pragma omp declare simd simdlen(4) notinbranch uniform(b) linear(c:3) +__attribute__((noinline)) int +foo (int a, int b, int c) +/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */ +{ + if (a < 30) + return 5; + return a + b + c; +} + +__attribute__((noinline, noclone)) void +bar () +{ + int i; +#pragma omp simd + for (i = 0; i < N; ++i) + { + d[i] = foo (i, 123, i * 3); + e[i] = e[i] + i; + } +} + +int +main () +{ + int i; + check_vect (); + bar (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (d[i] != (i < 30 ? 5 : i * 4 + 123) || e[i] != i) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-4.c new file mode 100644 index 0000000000..320ac7e6c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-4.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +float d[N]; +int e[N]; +unsigned short f[N]; + +#ifdef __aarch64__ +#pragma omp declare simd simdlen(4) notinbranch uniform(b) +#else +#pragma omp declare simd simdlen(8) notinbranch uniform(b) +#endif +__attribute__((noinline)) float +foo (float a, float b, float c) +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */ +{ + if (a < 30) + return 5.0f; + return a + b + c; +} + +__attribute__((noinline, noclone)) void +bar () +{ + int i; +#pragma omp simd + for (i = 0; i < N; ++i) + { + d[i] = foo (i, 123, i * 3); + e[i] = e[i] * 3; + f[i] = f[i] + 1; + } +} + +int +main () +{ + int i; + check_vect (); + bar (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (d[i] != (i < 30 ? 5.0f : i * 4 + 123.0f) || e[i] || f[i] != 1) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-5.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-5.c new file mode 100644 index 0000000000..b927f6e769 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-5.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int d[N], e[N]; + +#ifdef __aarch64__ +#pragma omp declare simd simdlen(2) notinbranch uniform(b) linear(c:3) +#else +#pragma omp declare simd simdlen(4) notinbranch uniform(b) linear(c:3) +#endif +__attribute__((noinline)) long long int +foo (int a, int b, int c) +/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */ +{ + return a + b + c; +} + +__attribute__((noinline, noclone)) void +bar () +{ + int i; +#pragma omp simd + for (i = 0; i < N; ++i) + { + d[i] = foo (i, 123, i * 3); + e[i] = e[i] + i; + } +} + +int +main () +{ + int i; + check_vect (); + bar (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (d[i] != i * 4 + 123 || e[i] != i) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-6.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-6.c new file mode 100644 index 0000000000..978cd4faa9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-6.c @@ -0,0 +1,86 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +#ifdef __aarch64__ +#define TYPE1 int +#define TYPE2 int +#define TYPE3 short +#else +#define TYPE1 int +#define TYPE2 long long int +#define TYPE3 short +#endif + +TYPE1 a[N]; +TYPE2 b[N]; +TYPE3 c[N]; + +#pragma omp declare simd +#pragma omp declare simd uniform(b) linear(c:3) +__attribute__((noinline)) TYPE3 +foo (TYPE1 a, TYPE2 b, TYPE3 c) +{ + return a + b + c; +} + +__attribute__((noinline, noclone)) void +bar (int x) +{ + int i; + if (x == 0) + { + #pragma omp simd + for (i = 0; i < N; i++) + c[i] = foo (a[i], b[i], c[i]); + } + else + { + #pragma omp simd + for (i = 0; i < N; i++) + c[i] = foo (a[i], x, i * 3); + } +} + +__attribute__((noinline, noclone)) void +baz (void) +{ + int i; + for (i = 0; i < N; i++) + { + a[i] = 2 * i; + b[i] = -7 * i + 6; + c[i] = (i & 31) << 4; + } +} + +int +main () +{ + int i; + check_vect (); + baz (); + bar (0); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != 2 * i || b[i] != 6 - 7 * i + || c[i] != 6 - 5 * i + ((i & 31) << 4)) + abort (); + else + a[i] = c[i]; + bar (17); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != 6 - 5 * i + ((i & 31) << 4) + || b[i] != 6 - 7 * i + || c[i] != 23 - 2 * i + ((i & 31) << 4)) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-7.c new file mode 100644 index 0000000000..68ea471696 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-7.c @@ -0,0 +1,86 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +#ifdef __aarch64__ +#define TYPE1 int +#define TYPE2 int +#define TYPE3 short +#else +#define TYPE1 int +#define TYPE2 long long int +#define TYPE3 short +#endif + +TYPE1 a[N]; +TYPE2 b[N]; +TYPE3 c[N]; + +#pragma omp declare simd +#pragma omp declare simd uniform(b) linear(c:3) +__attribute__((noinline)) TYPE3 +foo (TYPE1 a, TYPE2 b, TYPE1 c) +{ + return a + b + c; +} + +__attribute__((noinline, noclone)) void +bar (int x) +{ + int i; + if (x == 0) + { + #pragma omp simd + for (i = 0; i < N; i++) + c[i] = foo (a[i], b[i], c[i]); + } + else + { + #pragma omp simd + for (i = 0; i < N; i++) + c[i] = foo (a[i], x, i * 3); + } +} + +__attribute__((noinline, noclone)) void +baz (void) +{ + int i; + for (i = 0; i < N; i++) + { + a[i] = 2 * i; + b[i] = -7 * i + 6; + c[i] = (i & 31) << 4; + } +} + +int +main () +{ + int i; + check_vect (); + baz (); + bar (0); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != 2 * i || b[i] != 6 - 7 * i + || c[i] != 6 - 5 * i + ((i & 31) << 4)) + abort (); + else + a[i] = c[i]; + bar (17); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != 6 - 5 * i + ((i & 31) << 4) + || b[i] != 6 - 7 * i + || c[i] != 23 - 2 * i + ((i & 31) << 4)) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-8.c new file mode 100644 index 0000000000..8d7448f7cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-8.c @@ -0,0 +1,105 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int a[N], b[N]; +long int c[N]; +unsigned char d[N]; + +#ifdef __aarch64__ +#pragma omp declare simd simdlen(2) notinbranch +#else +#pragma omp declare simd simdlen(8) notinbranch +#endif +__attribute__((noinline)) int +foo (long int a, int b, int c) +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */ +{ + return a + b + c; +} + +#ifdef __aarch64__ +#pragma omp declare simd simdlen(2) notinbranch +#else +#pragma omp declare simd simdlen(8) notinbranch +#endif +__attribute__((noinline)) long int +bar (int a, int b, long int c) +/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */ +{ + return a + b + c; +} + +__attribute__((noinline)) void +fn1 (void) +{ + int i; + #pragma omp simd + for (i = 0; i < N; i++) + a[i] = foo (c[i], a[i], b[i]) + 6; + #pragma omp simd + for (i = 0; i < N; i++) + c[i] = bar (a[i], b[i], c[i]) * 2; +} + +__attribute__((noinline)) void +fn2 (void) +{ + int i; + #pragma omp simd + for (i = 0; i < N; i++) + { + a[i] = foo (c[i], a[i], b[i]) + 6; + d[i]++; + } + #pragma omp simd + for (i = 0; i < N; i++) + { + c[i] = bar (a[i], b[i], c[i]) * 2; + d[i] /= 2; + } +} + +__attribute__((noinline)) void +fn3 (void) +{ + int i; + for (i = 0; i < N; i++) + { + a[i] = i * 2; + b[i] = 17 + (i % 37); + c[i] = (i & 63); + d[i] = 16 + i; + } +} + +int +main () +{ + int i; + check_vect (); + fn3 (); + fn1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * 2 + 23 + (i % 37) + (i & 63) + || b[i] != 17 + (i % 37) + || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63)) + abort (); + fn3 (); + fn2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * 2 + 23 + (i % 37) + (i & 63) + || b[i] != 17 + (i % 37) + || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63) + || d[i] != ((unsigned char) (17 + i)) / 2) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-9.c b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-9.c new file mode 100644 index 0000000000..0112e553f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-simd-clone-9.c @@ -0,0 +1,96 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ + +#include "tree-vect.h" + +#ifndef N +#define N 1024 +#endif + +int a[N], b[N]; +long int c[N]; +unsigned char d[N]; + +#pragma omp declare simd notinbranch +__attribute__((noinline)) static int +foo (long int a, int b, int c) +{ + return a + b + c; +} + +#pragma omp declare simd notinbranch +__attribute__((noinline)) static long int +bar (int a, int b, long int c) +{ + return a + b + c; +} + +__attribute__((noinline)) void +fn1 (void) +{ + int i; + #pragma omp simd + for (i = 0; i < N; i++) + a[i] = foo (c[i], a[i], b[i]) + 6; + #pragma omp simd + for (i = 0; i < N; i++) + c[i] = bar (a[i], b[i], c[i]) * 2; +} + +__attribute__((noinline)) void +fn2 (void) +{ + int i; + #pragma omp simd + for (i = 0; i < N; i++) + { + a[i] = foo (c[i], a[i], b[i]) + 6; + d[i]++; + } + #pragma omp simd + for (i = 0; i < N; i++) + { + c[i] = bar (a[i], b[i], c[i]) * 2; + d[i] /= 2; + } +} + +__attribute__((noinline)) void +fn3 (void) +{ + int i; + for (i = 0; i < N; i++) + { + a[i] = i * 2; + b[i] = 17 + (i % 37); + c[i] = (i & 63); + d[i] = 16 + i; + } +} + +int +main () +{ + int i; + check_vect (); + fn3 (); + fn1 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * 2 + 23 + (i % 37) + (i & 63) + || b[i] != 17 + (i % 37) + || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63)) + abort (); + fn3 (); + fn2 (); +#pragma GCC novector + for (i = 0; i < N; i++) + if (a[i] != i * 2 + 23 + (i % 37) + (i & 63) + || b[i] != 17 + (i % 37) + || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63) + || d[i] != ((unsigned char) (17 + i)) / 2) + abort (); + return 0; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-singleton_1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-singleton_1.c new file mode 100644 index 0000000000..6c2ff49cda --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-singleton_1.c @@ -0,0 +1,38 @@ +/* PR target/59843 ICE on function taking/returning vector of one float64_t. */ + +/* { dg-do compile } */ +/* { dg-options "-Warray-bounds -O2 -fno-inline -std=c99" } */ + +#define TEST(BASETYPE, VECTYPE, SUFFIX) \ + typedef BASETYPE VECTYPE \ + __attribute__ ((__vector_size__ (sizeof (BASETYPE)))); \ + VECTYPE \ + test_vadd_##SUFFIX (VECTYPE a, VECTYPE b) \ + { \ + return a + b; \ + } \ + \ + void \ + test_##SUFFIX (BASETYPE val) \ + { \ + VECTYPE var = { val }; \ + BASETYPE v0 = var[0]; \ + BASETYPE v1 = var[1]; /* { dg-warning "index value is out of bound" } */ \ + } + +TEST (double, float64x1_t, f64) + +/* Original bug was for above type; + in a nod to completeness, test other types too. */ + +TEST (long long, int64x1_t, s64) + +TEST (float, float32x1_t, f32) + +TEST (long, longx1_t, l) + +TEST (int, intx1_t, i) + +TEST (short, int16x1_t, s16) + +TEST (char, int8x1_t, s8) diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-mult.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-mult.c new file mode 100644 index 0000000000..1531553651 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-mult.c @@ -0,0 +1,75 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; +} s; + +typedef struct { + unsigned int a; + unsigned int b; +} ii; + +__attribute__ ((noinline)) int +main1 () +{ + s arr[N]; + s *ptr = arr; + ii iarr[N]; + ii *iptr = iarr; + s res[N]; + ii ires[N]; + int i; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + iarr[i].a = i; + iarr[i].b = i * 3; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + ires[i].a = iptr->b - iptr->a; + ires[i].b = iptr->b + iptr->a; + res[i].b = ptr->b - ptr->a; + res[i].a = ptr->b + ptr->a; + iptr++; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].b != arr[i].b - arr[i].a + || ires[i].a != iarr[i].b - iarr[i].a + || res[i].a != arr[i].b + arr[i].a + || ires[i].b != iarr[i].b + iarr[i].a +) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-i2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-i2.c new file mode 100644 index 0000000000..b8d094723f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-i2.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + s arr[N]; + s *ptr = arr; + s res[N]; + int i; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + res[i].a = ptr->b - ptr->a; + res[i].b = ptr->b + ptr->a; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].b - arr[i].a + || res[i].b != arr[i].a + arr[i].b) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-i4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-i4.c new file mode 100644 index 0000000000..0f1344c420 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-i4.c @@ -0,0 +1,72 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; + unsigned short c; + unsigned short d; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + s arr[N]; + s *ptr = arr; + s res[N]; + int i; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + unsigned short x, y, z, w; + x = ptr->b - ptr->a; + y = ptr->d - ptr->c; + res[i].c = x + y; + z = ptr->a + ptr->c; + w = ptr->b + ptr->d; + res[i].a = z + w; + res[i].d = x + y; + res[i].b = x + y; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].a != arr[i].a + arr[i].c + arr[i].b + arr[i].d + || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].b != arr[i].b - arr[i].a + arr[i].d - arr[i].c) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided4 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-mult.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-mult.c new file mode 100644 index 0000000000..b0d3648671 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u16-mult.c @@ -0,0 +1,66 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + s arr[N]; + s *ptr = arr; + unsigned int iarr[N]; + unsigned int *iptr = iarr; + s res[N]; + unsigned int ires[N]; + int i; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + iarr[i] = i * 3; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + ires[i] = *iptr; + res[i].b = ptr->b - ptr->a; + res[i].a = ptr->b + ptr->a; + iptr++; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].b != arr[i].b - arr[i].a + || ires[i] != iarr[i] + || res[i].a != arr[i].b + arr[i].a) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u32-mult.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u32-mult.c new file mode 100644 index 0000000000..1c9906fa65 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u32-mult.c @@ -0,0 +1,66 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned int a; + unsigned int b; +} ii; + +__attribute__ ((noinline)) int +main1 () +{ + unsigned short arr[N]; + unsigned short *ptr = arr; + ii iarr[N]; + ii *iptr = iarr; + unsigned short res[N]; + ii ires[N]; + int i; + + for (i = 0; i < N; i++) + { + arr[i] = i; + iarr[i].a = i; + iarr[i].b = i * 3; + __asm__ volatile (""); + } + + for (i = 0; i < N; i++) + { + ires[i].a = iptr->b - iptr->a; + ires[i].b = iptr->b + iptr->a; + res[i] = *ptr; + iptr++; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i] != arr[i] + || ires[i].a != iarr[i].b - iarr[i].a + || ires[i].b != iarr[i].b + iarr[i].a) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i2-gap.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i2-gap.c new file mode 100644 index 0000000000..dc9ad168c7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i2-gap.c @@ -0,0 +1,75 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +typedef struct { + unsigned char a; + unsigned char b; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + s arr[N]; + s *ptr = arr; + s res[N]; + int i; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + res[i].a = ptr->a; + res[i].b = ptr->a; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].a + || res[i].b != arr[i].a) + abort (); + } + + ptr = arr; + /* gap in store, use strided stores */ + for (i = 0; i < N; i++) + { + res[i].a = ptr->b; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].b) + abort (); + } + + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_strided2 && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { vect_strided2 && vect_hw_misalign } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap2-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap2-big-array.c new file mode 100644 index 0000000000..d35e427996 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap2-big-array.c @@ -0,0 +1,91 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + s arr[N]; + s *ptr = arr; + s check_res[N]; + s res[N]; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i + 5; + arr[i].f = i * 2 + 2; + arr[i].g = i - 3; + arr[i].h = 56; + + check_res[i].c = arr[i].a; + check_res[i].a = arr[i].f + arr[i].a; + check_res[i].d = arr[i].f - arr[i].a; + check_res[i].b = arr[i].f; + check_res[i].f = arr[i].a; + check_res[i].e = arr[i].f - arr[i].a; + check_res[i].h = arr[i].f; + check_res[i].g = arr[i].f - arr[i].a; + + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + res[i].c = ptr->a; + res[i].a = ptr->f + ptr->a; + res[i].d = ptr->f - ptr->a; + res[i].b = ptr->f; + res[i].f = ptr->a; + res[i].e = ptr->f - ptr->a; + res[i].h = ptr->f; + res[i].g = ptr->f - ptr->a; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != check_res[i].a + || res[i].b != check_res[i].b + || res[i].c != check_res[i].c + || res[i].d != check_res[i].d + || res[i].e != check_res[i].e + || res[i].f != check_res[i].f + || res[i].g != check_res[i].g + || res[i].h != check_res[i].h) + abort (); + } +} + + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap2.c new file mode 100644 index 0000000000..a9524a9d8e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap2.c @@ -0,0 +1,80 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 24 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + s arr[N]; + s *ptr = arr; + s res[N]; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i + 5; + arr[i].f = i * 2 + 2; + arr[i].g = i - 3; + arr[i].h = 56; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + res[i].c = ptr->a; + res[i].a = ptr->f + ptr->a; + res[i].d = ptr->f - ptr->a; + res[i].b = ptr->f; + res[i].f = ptr->a; + res[i].e = ptr->f - ptr->a; + res[i].h = ptr->f; + res[i].g = ptr->f - ptr->a; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].a + || res[i].a != arr[i].f + arr[i].a + || res[i].d != arr[i].f - arr[i].a + || res[i].b != arr[i].f + || res[i].f != arr[i].a + || res[i].e != arr[i].f - arr[i].a + || res[i].h != arr[i].f + || res[i].g != arr[i].f - arr[i].a) + abort(); + } +} + + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap7-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap7-big-array.c new file mode 100644 index 0000000000..95ff41930d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap7-big-array.c @@ -0,0 +1,100 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + s arr[N]; + s *ptr = arr; + s check_res[N]; + s res[N]; + unsigned char u, t, s, x, z, w; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + arr[i].f = i * 5; + arr[i].g = i - 3; + arr[i].h = 67; + + u = arr[i].b - arr[i].a; + t = arr[i].d - arr[i].c; + check_res[i].c = u + t; + x = arr[i].b + arr[i].d; + check_res[i].a = arr[i].a + x; + check_res[i].d = u + t; + s = arr[i].h - arr[i].a; + check_res[i].b = s + t; + check_res[i].f = arr[i].f + arr[i].h; + check_res[i].e = arr[i].b + arr[i].e; + check_res[i].h = arr[i].d; + check_res[i].g = u + t; + + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + u = ptr->b - ptr->a; + t = ptr->d - ptr->c; + res[i].c = u + t; + x = ptr->b + ptr->d; + res[i].a = ptr->a + x; + res[i].d = u + t; + s = ptr->h - ptr->a; + res[i].b = s + t; + res[i].f = ptr->f + ptr->h; + res[i].e = ptr->b + ptr->e; + res[i].h = ptr->d; + res[i].g = u + t; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != check_res[i].a + || res[i].b != check_res[i].b + || res[i].c != check_res[i].c + || res[i].d != check_res[i].d + || res[i].e != check_res[i].e + || res[i].f != check_res[i].f + || res[i].g != check_res[i].g + || res[i].h != check_res[i].h) + abort (); + } +} + + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap7.c new file mode 100644 index 0000000000..b2dd1aee11 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-a-u8-i8-gap7.c @@ -0,0 +1,85 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + int i; + s arr[N]; + s *ptr = arr; + s res[N]; + unsigned char u, t, s, x, z, w; + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + arr[i].f = i * 5; + arr[i].g = i - 3; + arr[i].h = 67; + asm volatile ("" ::: "memory"); + } + + for (i = 0; i < N; i++) + { + u = ptr->b - ptr->a; + t = ptr->d - ptr->c; + res[i].c = u + t; + x = ptr->b + ptr->d; + res[i].a = ptr->a + x; + res[i].d = u + t; + s = ptr->h - ptr->a; + res[i].b = s + t; + res[i].f = ptr->f + ptr->h; + res[i].e = ptr->b + ptr->e; + res[i].h = ptr->d; + res[i].g = u + t; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].a != arr[i].a + arr[i].b + arr[i].d + || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].b != arr[i].h - arr[i].a + arr[i].d - arr[i].c + || res[i].f != arr[i].f + arr[i].h + || res[i].e != arr[i].b + arr[i].e + || res[i].h != arr[i].d + || res[i].g != arr[i].b - arr[i].a + arr[i].d - arr[i].c) + abort(); + } +} + + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-epilogue-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-epilogue-1.c new file mode 100644 index 0000000000..e316706204 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-epilogue-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +void +f (int *x, short *y, int z) +{ + for (int i = 0; i < 0x82; ++i) + x[-i] += x[z * i]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-float.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-float.c new file mode 100644 index 0000000000..716cce3eec --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-float.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +float b[N*2] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93}; +float c[N*2] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + float a[N*2]; + + /* Strided access pattern. */ + for (i = 0; i < N/2; i++) + { + a[i*2] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + a[i*2+1] = b[2*i+8] * c[2*i+9] + b[2*i+9] * c[2*i+8]; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (a[i*2] != b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i] + || a[i*2+1] != b[2*i+8] * c[2*i+9] + b[2*i+9] * c[2*i+8]) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* Needs interleaving support. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { xfail vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-mult-char-ls.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-mult-char-ls.c new file mode 100644 index 0000000000..5900849919 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-mult-char-ls.c @@ -0,0 +1,75 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +typedef struct { + unsigned char a; + unsigned char b; +} s; + +typedef struct { + unsigned int a; + unsigned int b; +} ii; + +__attribute__ ((noinline)) int +main1 (s *arr, ii *iarr) +{ + s *ptr = arr; + ii *iptr = iarr; + s res[N]; + ii ires[N]; + int i; + + for (i = 0; i < N; i++) + { + ires[i].a = iptr->b; + ires[i].b = iptr->a; + res[i].b = ptr->b - ptr->a; + res[i].a = ptr->b + ptr->a; + iptr++; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].b != arr[i].b - arr[i].a + || ires[i].a != iarr[i].b + || res[i].a != arr[i].b + arr[i].a + || ires[i].b != iarr[i].a +) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + s arr[N]; + ii iarr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + iarr[i].a = i; + iarr[i].b = i * 3; + asm volatile ("" ::: "memory"); + } + + main1 (arr, iarr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-mult.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-mult.c new file mode 100644 index 0000000000..350223fa23 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-mult.c @@ -0,0 +1,75 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; +} s; + +typedef struct { + unsigned int a; + unsigned int b; +} ii; + +__attribute__ ((noinline)) int +main1 (s *arr, ii *iarr) +{ + s *ptr = arr; + ii *iptr = iarr; + s res[N]; + ii ires[N]; + int i; + + for (i = 0; i < N; i++) + { + ires[i].a = iptr->b - iptr->a; + ires[i].b = iptr->b + iptr->a; + res[i].b = ptr->b - ptr->a; + res[i].a = ptr->b + ptr->a; + iptr++; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].b != arr[i].b - arr[i].a + || ires[i].a != iarr[i].b - iarr[i].a + || res[i].a != arr[i].b + arr[i].a + || ires[i].b != iarr[i].b + iarr[i].a +) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + s arr[N]; + ii iarr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + iarr[i].a = i; + iarr[i].b = i * 3; + asm volatile ("" ::: "memory"); + } + + main1 (arr, iarr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-same-dr.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-same-dr.c new file mode 100644 index 0000000000..e988c5c846 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-same-dr.c @@ -0,0 +1,75 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; +} s; + +s buffer1[N], buffer2[N]; + +__attribute__ ((noinline)) int +main1 (s * __restrict__ pIn, s* __restrict__ pOut) +{ + unsigned short i, x, y, d; + s *p, *q; + + p = pIn; + q = pOut; + + for (i = 0; i < N/2; i++) + { + x = pIn->a + 5; + y = pIn->a + 2; + pOut->a = x; + pOut->b = pIn->b; + pOut++; + pOut->a = y; + pOut->b = pIn->b; + pOut++; + pIn++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (q->a != p->a + 5 + || q->b != p->b) + abort (); + q++; + if (q->a != p->a + 2 + || q->b != p->b) + abort (); + q++; + p++; + } + + return 0; +} + +int main (void) +{ + short i; + + for (i = 0; i < N; i++) + { + buffer1[i].a = i; + buffer1[i].b = i + 8; + buffer2[i].a = i * 3; + buffer2[i].b = i * 2; + asm volatile ("" ::: "memory"); + } + + check_vect (); + + main1 (buffer1, buffer2); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-shift-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-shift-1.c new file mode 100644 index 0000000000..37b8eb80ce --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-shift-1.c @@ -0,0 +1,35 @@ +/* { dg-skip-if "Skip for mips -mpaired-single" { mips*-*-* } { "-mpaired-single" } } */ +/* PR tree-optimization/65963. */ +#include "tree-vect.h" + +#define N 512 + +int in[2*N], out[N]; + +__attribute__ ((noinline)) void +loop (void) +{ + for (int i = 0; i < N; i++) + out[i] = in[i << 1] + 7; +} + +int +main (int argc, char **argv) +{ + check_vect (); + for (int i = 0; i < 2*N; i++) + { + in[i] = i; + __asm__ volatile ("" : : : "memory"); + } + loop (); + __asm__ volatile ("" : : : "memory"); +#pragma GCC novector + for (int i = 0; i < N; i++) + { + if (out[i] != i*2 + 7) + abort (); + } + return 0; +} +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target { vect_strided2 } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-a-u8-i2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-a-u8-i2.c new file mode 100644 index 0000000000..a55cd32e58 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-a-u8-i2.c @@ -0,0 +1,62 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +typedef struct { + unsigned char a; + unsigned char b; +} s; + +__attribute__ ((noinline)) int +main1 () +{ + s arr[N]; + s *ptr = arr; + s res[N]; + int i; + unsigned char a[N], b[N]; + + + for (i = 0; i < N; i++) + { + a[i] = i; + b[i] = i * 2; + if (i%3 == 0) + a[i] = 10; + /* Prevent vectorization. */ + __asm__ volatile ("" : : : "memory"); + } + + for (i = 0; i < N; i++) + { + res[i].a = a[i] + 3; + res[i].b = a[i] + b[i]; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != a[i] + 3 + || res[i].b != a[i] + b[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_interleave || vect_strided2 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-u16-i4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-u16-i4.c new file mode 100644 index 0000000000..170f23472b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-u16-i4.c @@ -0,0 +1,72 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; + unsigned short c; + unsigned short d; +} s; + +unsigned short a[N]; +unsigned short b[N]; +unsigned short c[N]; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + unsigned short x, y, z, w; + + for (i = 0; i < N; i++) + { + res[i].c = a[i]; + res[i].a = b[i]; + res[i].d = c[i]; + res[i].b = a[i] + b [i]; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != a[i] + || res[i].a != b[i] + || res[i].d != c[i] + || res[i].b != a[i] + b[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = i; + b[i] = i * 2; + c[i] = 17; + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { { vect_interleave || vect_strided4 } && vect_pack_trunc } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { ! { vect_interleave || vect_strided4 } } && { vect_pack_trunc } } } } } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-u32-i2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-u32-i2.c new file mode 100644 index 0000000000..11c2f2c4df --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store-u32-i2.c @@ -0,0 +1,45 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int a[N*2]; +int b[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; +int c[N] = {1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31}; + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + + /* Strided access pattern. */ + for (i = 0; i < N/2; i++) + { + a[i*2] = b[i] + c[i]; + a[i*2+1] = b[i] * c[i]; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N/2; i++) + { + if (a[i*2] != b[i] + c[i] + || a[i*2+1] != b[i] * c[i]) + abort(); + } + + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* Needs interleaving support. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_interleave || vect_strided2 } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { xfail { vect_interleave || vect_strided2 } } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store.c new file mode 100644 index 0000000000..dfdafe8e8b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-store.c @@ -0,0 +1,37 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +void __attribute__((noinline)) +sumit (float * __restrict dest, + float * __restrict src, float * __restrict src2, + int stride, int n) +{ + int i; + for (i = 0; i < n; i++) + dest[i*stride] = src[i] + src2[i]; +} + +int main() +{ + int i, stride; + float src[] = {1, 2, 3, 4, 5, 6, 7, 8}; + float dest[64]; + check_vect (); +#pragma GCC novector + for (stride = 0; stride < 8; stride++) + { + sumit (dest, src, src, stride, 8); + if (!stride && dest[0] != 16) + abort(); + else if (stride) +#pragma GCC novector + for (i = 0; i < 8; i++) + if (2*src[i] != dest[i*stride]) + abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i2.c new file mode 100644 index 0000000000..004db4e1f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i2.c @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + s *ptr = arr; + s res[N]; + int i; + + for (i = 0; i < N; i++) + { + res[i].a = ptr->b - ptr->a; + res[i].b = ptr->b + ptr->a; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].b - arr[i].a + || res[i].b != arr[i].a + arr[i].b) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i3.c new file mode 100644 index 0000000000..5d94e8f49b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i3.c @@ -0,0 +1,115 @@ +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; + unsigned short c; +} s; + +#define A(I) (I) +#define B(I) ((I) * 2) +#define C(I) ((unsigned short) ~((I) ^ 0x18)) + +void __attribute__ ((noinline)) +check1 (s *res) +{ + int i; + +#pragma GCC novector + for (i = 0; i < N; i++) + if (res[i].a != C (i) + || res[i].b != A (i) + || res[i].c != B (i)) + abort (); +} + +void __attribute__ ((noinline)) +check2 (unsigned short *res) +{ + int i; + +#pragma GCC novector + for (i = 0; i < N; i++) + if (res[i] != (unsigned short) (A (i) + B (i) + C (i))) + abort (); +} + +void __attribute__ ((noinline)) +check3 (s *res) +{ + int i; + +#pragma GCC novector + for (i = 0; i < N; i++) + if (res[i].a != i + || res[i].b != i + || res[i].c != i) + abort (); +} + +void __attribute__ ((noinline)) +check4 (unsigned short *res) +{ + int i; + +#pragma GCC novector + for (i = 0; i < N; i++) + if (res[i] != (unsigned short) (A (i) + B (i))) + abort (); +} + +void __attribute__ ((noinline)) +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res1[N]; + unsigned short res2[N]; + + for (i = 0; i < N; i++) + { + res1[i].a = arr[i].c; + res1[i].b = arr[i].a; + res1[i].c = arr[i].b; + } + check1 (res1); + + for (i = 0; i < N; i++) + res2[i] = arr[i].a + arr[i].b + arr[i].c; + check2 (res2); + + for (i = 0; i < N; i++) + { + res1[i].a = i; + res1[i].b = i; + res1[i].c = i; + } + check3 (res1); + + for (i = 0; i < N; i++) + res2[i] = arr[i].a + arr[i].b; + check4 (res2); +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = A (i); + arr[i].b = B (i); + arr[i].c = C (i); + } + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_strided3 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i4.c new file mode 100644 index 0000000000..547ad9b9ee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u16-i4.c @@ -0,0 +1,72 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; + unsigned short c; + unsigned short d; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + unsigned short x, y, z, w; + + for (i = 0; i < N; i++) + { + x = ptr->b - ptr->a; + y = ptr->d - ptr->c; + res[i].c = x + y; + z = ptr->a + ptr->c; + w = ptr->b + ptr->d; + res[i].a = z + w; + res[i].d = x + y; + res[i].b = x + y; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].a != arr[i].a + arr[i].c + arr[i].b + arr[i].d + || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].b != arr[i].b - arr[i].a + arr[i].d - arr[i].c) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided4 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-i4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-i4.c new file mode 100644 index 0000000000..8f58e24c4a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-i4.c @@ -0,0 +1,67 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + int a; + int b; + int c; + int d; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + + for (i = 0; i < N; i++) + { + res[i].c = ptr->b - ptr->a + ptr->d - ptr->c; + res[i].a = ptr->a + ptr->c + ptr->b + ptr->d; + res[i].d = ptr->b - ptr->a + ptr->d - ptr->c; + res[i].b = ptr->b - ptr->a + ptr->d - ptr->c; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].a != arr[i].a + arr[i].c + arr[i].b + arr[i].d + || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].b != arr[i].b - arr[i].a + arr[i].d - arr[i].c) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided4 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-i8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-i8.c new file mode 100644 index 0000000000..edb13d1b26 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-i8.c @@ -0,0 +1,81 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + int a; + int b; + int c; + int d; + int e; + int f; + int g; + int h; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + + for (i = 0; i < N; i++) + { + res[i].c = ptr->b - ptr->a + ptr->d - ptr->c; + res[i].a = ptr->a + ptr->g + ptr->b + ptr->d; + res[i].d = ptr->b - ptr->a + ptr->d - ptr->c; + res[i].b = ptr->h - ptr->a + ptr->d - ptr->c; + res[i].f = ptr->f + ptr->h; + res[i].e = ptr->b - ptr->e; + res[i].h = ptr->d - ptr->g; + res[i].g = ptr->b - ptr->a + ptr->d - ptr->c; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].a != arr[i].a + arr[i].g + arr[i].b + arr[i].d + || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].b != arr[i].h - arr[i].a + arr[i].d - arr[i].c + || res[i].f != arr[i].f + arr[i].h + || res[i].e != arr[i].b - arr[i].e + || res[i].h != arr[i].d - arr[i].g + || res[i].g != arr[i].b - arr[i].a + arr[i].d - arr[i].c) + abort(); + } +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + arr[i].f = i * 5; + arr[i].g = i - 3; + arr[i].h = 56; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-mult.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-mult.c new file mode 100644 index 0000000000..0c2bd9d8cb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u32-mult.c @@ -0,0 +1,65 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned int a; + unsigned int b; +} ii; + +__attribute__ ((noinline)) int +main1 (unsigned short *arr, ii *iarr) +{ + unsigned short *ptr = arr; + ii *iptr = iarr; + unsigned short res[N]; + ii ires[N]; + int i; + + for (i = 0; i < N; i++) + { + ires[i].a = iptr->b - iptr->a; + ires[i].b = iptr->b + iptr->a; + res[i] = *ptr; + iptr++; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i] != arr[i] + || ires[i].a != iarr[i].b - iarr[i].a + || ires[i].b != iarr[i].b + iarr[i].a) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + unsigned short arr[N]; + ii iarr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i] = i; + iarr[i].a = i; + iarr[i].b = i * 3; + __asm__ volatile (""); + } + main1 (arr, iarr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i2-gap.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i2-gap.c new file mode 100644 index 0000000000..fd7920031d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i2-gap.c @@ -0,0 +1,76 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +typedef struct { + unsigned char a; + unsigned char b; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + s *ptr = arr; + s res[N]; + int i; + + for (i = 0; i < N; i++) + { + res[i].a = ptr->b; + res[i].b = ptr->b; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].b + || res[i].b != arr[i].b) + abort (); + } + + ptr = arr; + /* gap in store, use strided stores. */ + for (i = 0; i < N; i++) + { + res[i].a = ptr->b; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].b) + abort (); + } + + + return 0; +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i2.c new file mode 100644 index 0000000000..ae2345a978 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i2.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +typedef struct { + unsigned char a; + unsigned char b; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + s *ptr = arr; + s res[N]; + int i; + + for (i = 0; i < N; i++) + { + res[i].a = ptr->b - ptr->a; + res[i].b = ptr->b + ptr->a; + ptr++; + } + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].b - arr[i].a + || res[i].b != arr[i].a + arr[i].b) + abort (); + } + + return 0; +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap2-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap2-big-array.c new file mode 100644 index 0000000000..c7a1da534b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap2-big-array.c @@ -0,0 +1,94 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +s check_res[N]; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + + for (i = 0; i < N; i++) + { + res[i].c = ptr->b; + res[i].a = ptr->f + ptr->b; + res[i].d = ptr->f - ptr->b; + res[i].b = ptr->f; + res[i].f = ptr->b; + res[i].e = ptr->f - ptr->b; + res[i].h = ptr->f; + res[i].g = ptr->f - ptr->b; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != check_res[i].a + || res[i].b != check_res[i].b + || res[i].c != check_res[i].c + || res[i].d != check_res[i].d + || res[i].e != check_res[i].e + || res[i].f != check_res[i].f + || res[i].g != check_res[i].g + || res[i].h != check_res[i].h) + abort (); + } +} + + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i + 5; + arr[i].f = i * 2 + 2; + arr[i].g = i - 3; + arr[i].h = 56; + + check_res[i].c = arr[i].b; + check_res[i].a = arr[i].f + arr[i].b; + check_res[i].d = arr[i].f - arr[i].b; + check_res[i].b = arr[i].f; + check_res[i].f = arr[i].b; + check_res[i].e = arr[i].f - arr[i].b; + check_res[i].h = arr[i].f; + check_res[i].g = arr[i].f - arr[i].b; + + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap2.c new file mode 100644 index 0000000000..2a068d821a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap2.c @@ -0,0 +1,82 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 24 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + + for (i = 0; i < N; i++) + { + res[i].c = ptr->b; + res[i].a = ptr->f + ptr->b; + res[i].d = ptr->f - ptr->b; + res[i].b = ptr->f; + res[i].f = ptr->b; + res[i].e = ptr->f - ptr->b; + res[i].h = ptr->f; + res[i].g = ptr->f - ptr->b; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b + || res[i].a != arr[i].f + arr[i].b + || res[i].d != arr[i].f - arr[i].b + || res[i].b != arr[i].f + || res[i].f != arr[i].b + || res[i].e != arr[i].f - arr[i].b + || res[i].h != arr[i].f + || res[i].g != arr[i].f - arr[i].b) + abort(); + } +} + + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i + 5; + arr[i].f = i * 2 + 2; + arr[i].g = i - 3; + arr[i].h = 56; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4-big-array.c new file mode 100644 index 0000000000..ac7bf00019 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4-big-array.c @@ -0,0 +1,115 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +s check_res[N]; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + unsigned char x; + + for (i = 0; i < N; i++) + { + res[i].c = ptr->b + ptr->c; + x = ptr->c + ptr->f; + res[i].a = x + ptr->b; + res[i].d = ptr->b + ptr->c; + res[i].b = ptr->c; + res[i].f = ptr->f + ptr->e; + res[i].e = ptr->b + ptr->e; + res[i].h = ptr->c; + res[i].g = ptr->b + ptr->c; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != check_res[i].a + || res[i].b != check_res[i].b + || res[i].c != check_res[i].c + || res[i].d != check_res[i].d + || res[i].e != check_res[i].e + || res[i].f != check_res[i].f + || res[i].g != check_res[i].g + || res[i].h != check_res[i].h) + abort (); + } + + ptr = arr; + /* Vectorized as a strided SLP pair. */ + for (i = 0; i < N; i++) + { + res[i].a = ptr->b; + res[i].b = ptr->c; + ptr++; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].b + || res[i].b != arr[i].c) + abort (); + } + +} + + +int main (void) +{ + int i; + s arr[N]; + unsigned char x; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + arr[i].f = i * 5; + arr[i].g = i - 3; + arr[i].h = 56; + + check_res[i].c = arr[i].b + arr[i].c; + x = arr[i].c + arr[i].f; + check_res[i].a = x + arr[i].b; + check_res[i].d = arr[i].b + arr[i].c; + check_res[i].b = arr[i].c; + check_res[i].f = arr[i].f + arr[i].e; + check_res[i].e = arr[i].b + arr[i].e; + check_res[i].h = arr[i].c; + check_res[i].g = arr[i].b + arr[i].c; + + asm volatile ("" ::: "memory"); + } + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect_strided8 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4-unknown.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4-unknown.c new file mode 100644 index 0000000000..0a6050ae46 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4-unknown.c @@ -0,0 +1,115 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 160 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr, int n) +{ + int i; + s *ptr = arr; + s res[N]; + unsigned char x; + + for (i = 0; i < N; i++) + { + res[i].a = 0; + res[i].b = 0; + res[i].c = 0; + res[i].d = 0; + res[i].e = 0; + res[i].f = 0; + res[i].g = 0; + res[i].h = 0; + __asm__ volatile (""); + } + + /* Check peeling for gaps for unknown loop bound. */ + for (i = 0; i < n; i++) + { + res[i].c = ptr->b + ptr->c; + x = ptr->c + ptr->f; + res[i].a = x + ptr->b; + res[i].d = ptr->b + ptr->c; + res[i].b = ptr->c; + res[i].f = ptr->f + ptr->e; + res[i].e = ptr->b + ptr->e; + res[i].h = ptr->c; + res[i].g = ptr->b + ptr->c; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < n; i++) + { + if (res[i].c != arr[i].b + arr[i].c + || res[i].a != arr[i].c + arr[i].f + arr[i].b + || res[i].d != arr[i].b + arr[i].c + || res[i].b != arr[i].c + || res[i].f != arr[i].f + arr[i].e + || res[i].e != arr[i].b + arr[i].e + || res[i].h != arr[i].c + || res[i].g != arr[i].b + arr[i].c) + abort (); + } + + /* Check also that we don't do more iterations than needed. */ +#pragma GCC novector + for (i = n; i < N; i++) + { + if (res[i].c == arr[i].b + arr[i].c + || res[i].a == arr[i].c + arr[i].f + arr[i].b + || res[i].d == arr[i].b + arr[i].c + || res[i].b == arr[i].c + || res[i].f == arr[i].f + arr[i].e + || res[i].e == arr[i].b + arr[i].e + || res[i].h == arr[i].c + || res[i].g == arr[i].b + arr[i].c) + abort (); + } + + return 0; +} + + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = 5; + arr[i].b = 6; + arr[i].c = 17; + arr[i].d = 3; + arr[i].e = 16; + arr[i].f = 16; + arr[i].g = 3; + arr[i].h = 56; + asm volatile ("" ::: "memory"); + } + + main1 (arr, N-2); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4.c new file mode 100644 index 0000000000..9ead5a776d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap4.c @@ -0,0 +1,102 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 24 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + unsigned char x; + + for (i = 0; i < N; i++) + { + res[i].c = ptr->b + ptr->c; + x = ptr->c + ptr->f; + res[i].a = x + ptr->b; + res[i].d = ptr->b + ptr->c; + res[i].b = ptr->c; + res[i].f = ptr->f + ptr->e; + res[i].e = ptr->b + ptr->e; + res[i].h = ptr->c; + res[i].g = ptr->b + ptr->c; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b + arr[i].c + || res[i].a != arr[i].c + arr[i].f + arr[i].b + || res[i].d != arr[i].b + arr[i].c + || res[i].b != arr[i].c + || res[i].f != arr[i].f + arr[i].e + || res[i].e != arr[i].b + arr[i].e + || res[i].h != arr[i].c + || res[i].g != arr[i].b + arr[i].c) + abort (); + } + + ptr = arr; + /* Vectorized as a strided SLP pair. */ + for (i = 0; i < N; i++) + { + res[i].a = ptr->b; + res[i].b = ptr->c; + ptr++; + } + + /* Check results. */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != arr[i].b + || res[i].b != arr[i].c) + abort (); + } + +} + + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + arr[i].f = i * 5; + arr[i].g = i - 3; + arr[i].h = 56; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect_strided8 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap7-big-array.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap7-big-array.c new file mode 100644 index 0000000000..176c6a784b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap7-big-array.c @@ -0,0 +1,104 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +s check_res[N]; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + unsigned char u, t, s, x, z, w; + + for (i = 0; i < N; i++) + { + u = ptr->b - ptr->a; + t = ptr->d - ptr->c; + res[i].c = u + t; + x = ptr->b + ptr->d; + res[i].a = ptr->a + x; + res[i].d = u + t; + s = ptr->h - ptr->a; + res[i].b = s + t; + res[i].f = ptr->f + ptr->h; + res[i].e = ptr->b + ptr->e; + res[i].h = ptr->d; + res[i].g = u + t; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].a != check_res[i].a + || res[i].b != check_res[i].b + || res[i].c != check_res[i].c + || res[i].d != check_res[i].d + || res[i].e != check_res[i].e + || res[i].f != check_res[i].f + || res[i].g != check_res[i].g + || res[i].h != check_res[i].h) + abort (); + } +} + + +int main (void) +{ + int i; + s arr[N]; + unsigned char u, t, s, x, z, w; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + arr[i].f = i * 5; + arr[i].g = i - 3; + arr[i].h = 67; + + u = arr[i].b - arr[i].a; + t = arr[i].d - arr[i].c; + check_res[i].c = u + t; + x = arr[i].b + arr[i].d; + check_res[i].a = arr[i].a + x; + check_res[i].d = u + t; + s = arr[i].h - arr[i].a; + check_res[i].b = s + t; + check_res[i].f = arr[i].f + arr[i].h; + check_res[i].e = arr[i].b + arr[i].e; + check_res[i].h = arr[i].d; + check_res[i].g = u + t; + + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap7.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap7.c new file mode 100644 index 0000000000..cef88f6bf8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8-gap7.c @@ -0,0 +1,87 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + unsigned char u, t, s, x, y, z, w; + + for (i = 0; i < N; i++) + { + u = ptr->b - ptr->a; + t = ptr->d - ptr->c; + res[i].c = u + t; + x = ptr->b + ptr->d; + res[i].a = ptr->a + x; + res[i].d = u + t; + s = ptr->h - ptr->a; + res[i].b = s + t; + res[i].f = ptr->f + ptr->h; + res[i].e = ptr->b + ptr->e; + res[i].h = ptr->d; + res[i].g = u + t; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].a != arr[i].a + arr[i].b + arr[i].d + || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].b != arr[i].h - arr[i].a + arr[i].d - arr[i].c + || res[i].f != arr[i].f + arr[i].h + || res[i].e != arr[i].b + arr[i].e + || res[i].h != arr[i].d + || res[i].g != arr[i].b - arr[i].a + arr[i].d - arr[i].c) + abort(); + } +} + + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i * 3 + 5; + arr[i].f = i * 5; + arr[i].g = i - 3; + arr[i].h = 67; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8.c new file mode 100644 index 0000000000..c29c3ff6cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-strided-u8-i8.c @@ -0,0 +1,89 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +typedef struct { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} s; + +__attribute__ ((noinline)) int +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res[N]; + unsigned char u, t, s, x, y, z, w; + + for (i = 0; i < N; i++) + { + u = ptr->b - ptr->a; + t = ptr->d - ptr->c; + res[i].c = u + t; + s = ptr->a + ptr->g; + x = ptr->b + ptr->d; + res[i].a = s + x; + res[i].d = u + t; + s = ptr->h - ptr->a; + x = ptr->d - ptr->c; + res[i].b = s + x; + res[i].f = ptr->f + ptr->h; + res[i].e = ptr->b + ptr->e; + res[i].h = ptr->d - ptr->g; + res[i].g = u + t; + ptr++; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].a != arr[i].a + arr[i].g + arr[i].b + arr[i].d + || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c + || res[i].b != arr[i].h - arr[i].a + arr[i].d - arr[i].c + || res[i].f != arr[i].f + arr[i].h + || res[i].e != arr[i].b + arr[i].e + || res[i].h != arr[i].d - arr[i].g + || res[i].g != arr[i].b - arr[i].a + arr[i].d - arr[i].c + ) + abort(); + } +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = i; + arr[i].b = i * 2; + arr[i].c = 17; + arr[i].d = i+34; + arr[i].e = i; + arr[i].f = i + 5; + arr[i].g = i + 3; + arr[i].h = 67; + asm volatile ("" ::: "memory"); + } + + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-tail-nomask-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-tail-nomask-1.c new file mode 100644 index 0000000000..ee9ab2e9d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-tail-nomask-1.c @@ -0,0 +1,102 @@ +/* { dg-skip-if "No undefined weak" { ! { posix_memalign } } } */ +/* { dg-additional-options "--param vect-epilogues-nomask=1 -mavx2" { target avx2_runtime } } */ + +#define SIZE 1023 +#define ALIGN 64 + +extern int posix_memalign(void **memptr, __SIZE_TYPE__ alignment, __SIZE_TYPE__ size); +extern void free (void *); + +void __attribute__((noinline)) +test_citer (int * __restrict__ a, + int * __restrict__ b, + int * __restrict__ c) +{ + int i; + + a = (int *)__builtin_assume_aligned (a, ALIGN); + b = (int *)__builtin_assume_aligned (b, ALIGN); + c = (int *)__builtin_assume_aligned (c, ALIGN); + + for (i = 0; i < SIZE; i++) + c[i] = a[i] + b[i]; +} + +void __attribute__((noinline)) +test_viter (int * __restrict__ a, + int * __restrict__ b, + int * __restrict__ c, + int size) +{ + int i; + + a = (int *)__builtin_assume_aligned (a, ALIGN); + b = (int *)__builtin_assume_aligned (b, ALIGN); + c = (int *)__builtin_assume_aligned (c, ALIGN); + + for (i = 0; i < size; i++) + c[i] = a[i] + b[i]; +} + +void __attribute__((noinline)) +init_data (int * __restrict__ a, + int * __restrict__ b, + int * __restrict__ c, + int size) +{ + for (int i = 0; i < size; i++) + { + a[i] = i; + b[i] = -i; + c[i] = 0; + asm volatile("": : :"memory"); + } + a[size] = b[size] = c[size] = size; +} + + +void __attribute__((noinline)) +run_test () +{ + int *a; + int *b; + int *c; + int i; + + if (posix_memalign ((void **)&a, ALIGN, (SIZE + 1) * sizeof (int)) != 0) + return; + if (posix_memalign ((void **)&b, ALIGN, (SIZE + 1) * sizeof (int)) != 0) + return; + if (posix_memalign ((void **)&c, ALIGN, (SIZE + 1) * sizeof (int)) != 0) + return; + + init_data (a, b, c, SIZE); + test_citer (a, b, c); + for (i = 0; i < SIZE; i++) + if (c[i] != a[i] + b[i]) + __builtin_abort (); + if (a[SIZE] != SIZE || b[SIZE] != SIZE || c[SIZE] != SIZE) + __builtin_abort (); + + init_data (a, b, c, SIZE); + test_viter (a, b, c, SIZE); + for (i = 0; i < SIZE; i++) + if (c[i] != a[i] + b[i]) + __builtin_abort (); + if (a[SIZE] != SIZE || b[SIZE] != SIZE || c[SIZE] != SIZE) + __builtin_abort (); + + free (a); + free (b); + free (c); +} + +int +main (int argc, const char **argv) +{ + run_test (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target avx2_runtime } } } */ +/* { dg-final { scan-tree-dump-times "LOOP EPILOGUE VECTORIZED \\(MODE=V16QI\\)" 2 "vect" { target avx2_runtime } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-version-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-version-1.c new file mode 100644 index 0000000000..4540a11b36 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-version-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_condition } */ + +void foo (double *x, double *y, int m, int n, int o, int p) +{ + for (int i = 0; i < m; ++i) + for (int j = 0; j < n; ++j) + for (int k = 0; k < o; ++k) + for (int l = 0; l < p; ++l) + { + double tem = x[l] + y[l]; + if (tem != 0.) + y[l] = x[l]; + else + y[l] = 0.; + } +} + +/* { dg-final { scan-tree-dump "applying loop versioning to outer loop 1" "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-version-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-version-2.c new file mode 100644 index 0000000000..7d3fb722f4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-version-2.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_condition } */ + +void foo (double *x, double *y, int m, int n, int o, int p) +{ + for (int i = 0; i < m; ++i) + for (int j = 0; j < n; ++j) + for (int k = 0; k < o; ++k) + for (int l = 0; l < k; ++l) + { + double tem = x[l] + y[l]; + if (tem != 0.) + y[l] = x[l]; + else + y[l] = 0.; + } +} + +/* Vectorization using partial vectors has zero versioning_threshold with + either usage 1 or usage 2, the cond_expr replies on the computation in + outer loop, so it doesn't need to reuse the loop version created by if + conversion. */ +/* { dg-final { scan-tree-dump "reusing loop version created by if conversion" "vect" {target {! vect_partial_vectors } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-01.c b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-01.c new file mode 100644 index 0000000000..2d5c10a878 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-01.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +int result[N] = {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}; +int X[N] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}; +int Y[N] = {}; + +__attribute__ ((noinline)) void +foo (int *in, int *out) +{ + int i; + + for (i = 0; i < N; i++) + out[i] = in[i] + 2; +} + +int +main (void) +{ + int i; + + check_vect (); + + foo (X, Y); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (Y[i] != result[i]) + abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-02.c b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-02.c new file mode 100644 index 0000000000..4848215a7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-02.c @@ -0,0 +1,47 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +int resultY[N] = {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}; +int resultZ[N] = {13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28}; +int X[N] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}; +int Y[N] = {}; +int Z[N] = {}; + +__attribute__ ((noinline)) void +foo (int *in, int *out1, int *out2) +{ + int i; + + for (i = 0; i < N; i++) + { + out1[i] = in[i] + 2; + out2[i] = in[i] + 3; + } +} + +int +main (void) +{ + int i; + + check_vect (); + + foo (X, Y, Z); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (Y[i] != resultY[i]) + abort (); + + if (Z[i] != resultZ[i]) + abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-03.c b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-03.c new file mode 100644 index 0000000000..2a94c73907 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-03.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +struct S +{ + unsigned short a; + unsigned short b; +}; + +struct S result[N] = {20, 13, 22, 14, 24, 15, 26, 16, 28, 17, 30, 18, + 32, 19, 34, 20, 36, 21, 38, 22, 40, 23, 42, 24, + 44, 25, 46, 26, 48, 27, 50, 28}; +struct S X[N] = {10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, + 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, + 23, 23, 24, 24, 25, 25}; +struct S Y[N] = {}; + +__attribute__ ((noinline)) void +foo (struct S * in, struct S * out) +{ + int i; + + for (i = 0; i < N; i++) + { + out[i].a = in[i].a * 2; + out[i].b = in[i].b + 3; + } +} + +int +main (void) +{ + int i; + + check_vect (); + + foo (X, Y); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (Y[i].a != result[i].a) + abort (); + + if (Y[i].b != result[i].b) + abort (); + + } + return 0; +} + +/* Needs interleaving support. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { xfail vect_strided2 } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-04.c b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-04.c new file mode 100644 index 0000000000..b0e9d6f903 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-04.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +int result[] = {10, 11, 15, 16, 20, 21, 25, 26, 30, 31, 35, 36, 40, 41, 45, 46, 50, 51}; +int X[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0}; + +__attribute__ ((noinline)) void +foo (int *in, int *out) +{ + int i; + + for (i = 0; i < N; i++) + out[i] = in[i] + 5; +} + +int +main (void) +{ + int i; + + check_vect (); + + foo (X, &X[2]); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N+2; i++) + { + if (X[i] != result[i]) + abort (); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-slp.c b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-slp.c new file mode 100644 index 0000000000..27d7624909 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-vfa-slp.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +struct S +{ + unsigned short a; + unsigned short b; +}; + +struct S result[N] = {12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, + 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, + 24, 25, 25, 26, 26, 27, 27, 28}; +struct S X[N] = {10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, + 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, + 23, 23, 24, 24, 25, 25}; +struct S Y[N] = {}; + +__attribute__ ((noinline)) void +foo (struct S * in, struct S * out) +{ + int i; + + for (i = 0; i < N; i++) + { + out[i].a = in[i].a + 2; + out[i].b = in[i].b + 3; + } +} + +int +main (void) +{ + int i; + + check_vect (); + + foo (X, Y); + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (Y[i].a != result[i].a) + abort (); + + if (Y[i].b != result[i].b) + abort (); + + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-1.c new file mode 100644 index 0000000000..f3abc9407f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-1.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 50 + +#ifndef SIGNEDNESS_1 +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 signed +#endif + +void __attribute__ ((noipa)) +f (SIGNEDNESS_1 short *restrict a, SIGNEDNESS_2 char *restrict b, + SIGNEDNESS_2 char *restrict c) +{ + for (__INTPTR_TYPE__ i = 0; i < N; ++i) + { + int bv = (SIGNEDNESS_2 char) b[i]; + int cv = (SIGNEDNESS_2 char) c[i]; + a[i] = bv * cv; + } +} + +#define BASE ((SIGNEDNESS_2 int) -1 < 0 ? -126 : 4) +#define OFFSET 20 + +int +main (void) +{ + check_vect (); + + SIGNEDNESS_1 short a[N]; + SIGNEDNESS_2 char b[N], c[N]; + for (int i = 0; i < N; ++i) + { + b[i] = BASE + i * 5; + c[i] = BASE + OFFSET + i * 4; + asm volatile ("" ::: "memory"); + } + f (a, b, c); +#pragma GCC novector + for (int i = 0; i < N; ++i) + if (a[i] != (SIGNEDNESS_1 short) ((BASE + i * 5) + * (BASE + OFFSET + i * 4))) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump "vect_recog_widen_mult_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_widen_mult_qi_to_hi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-2.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-2.c new file mode 100644 index 0000000000..73ffe6ae42 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-2.c @@ -0,0 +1,9 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 unsigned +#define SIGNEDNESS_2 unsigned + +#include "vect-widen-mult-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_widen_mult_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_widen_mult_qi_to_hi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-3.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-3.c new file mode 100644 index 0000000000..fc4ca8f271 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-3.c @@ -0,0 +1,9 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 unsigned + +#include "vect-widen-mult-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_widen_mult_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_widen_mult_qi_to_hi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-4.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-4.c new file mode 100644 index 0000000000..315b55628b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-4.c @@ -0,0 +1,9 @@ +/* { dg-require-effective-target vect_int } */ + +#define SIGNEDNESS_1 signed +#define SIGNEDNESS_2 signed + +#include "vect-widen-mult-1.c" + +/* { dg-final { scan-tree-dump "vect_recog_widen_mult_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_widen_mult_qi_to_hi } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-const-s16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-const-s16.c new file mode 100644 index 0000000000..dfbb2171c0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-const-s16.c @@ -0,0 +1,65 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-ipa-icf" } */ + +#include "tree-vect.h" + +#define N 32 + +__attribute__ ((noinline)) void +foo (int *__restrict a, + short *__restrict b, + int n) +{ + int i; + + for (i = 0; i < n; i++) + a[i] = b[i] * 2333; + +#pragma GCC novector + for (i = 0; i < n; i++) + if (a[i] != b[i] * 2333) + abort (); +} + +__attribute__ ((noinline)) void +bar (int *__restrict a, + short *__restrict b, + int n) +{ + int i; + + for (i = 0; i < n; i++) + a[i] = b[i] * (short) 2333; + +#pragma GCC novector + for (i = 0; i < n; i++) + if (a[i] != b[i] * (short) 2333) + abort (); +} + +int main (void) +{ + int i; + int a[N]; + short b[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = 0; + b[i] = i; + __asm__ volatile (""); + } + + foo (a, b, N); + bar (a, b, N); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_widen_mult_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times {vect_recog_widen_mult_pattern: detected:[^\n]* 2333} 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ +/* { dg-final { scan-tree-dump-times {widen_mult pattern recognized:[^\n]* 2333} 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-const-u16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-const-u16.c new file mode 100644 index 0000000000..c2ad58f69e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-const-u16.c @@ -0,0 +1,82 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-ipa-icf" } */ + +#include "tree-vect.h" + +#define N 32 + +__attribute__ ((noinline)) void +foo (unsigned int *__restrict a, + unsigned short *__restrict b, + int n) +{ + int i; + + for (i = 0; i < n; i++) + a[i] = b[i] * 2333; + +#pragma GCC novector + for (i = 0; i < n; i++) + if (a[i] != b[i] * 2333) + abort (); +} + +__attribute__ ((noinline)) void +bar (unsigned int *__restrict a, + unsigned short *__restrict b, + int n) +{ + int i; + + for (i = 0; i < n; i++) + a[i] = (unsigned short) 2333 * b[i]; + +#pragma GCC novector + for (i = 0; i < n; i++) + if (a[i] != b[i] * (unsigned short) 2333) + abort (); +} + +__attribute__ ((noinline)) void +baz (unsigned int *__restrict a, + unsigned short *__restrict b, + int n) +{ + int i; + + for (i = 0; i < n; i++) + a[i] = b[i] * 233333333; + +#pragma GCC novector + for (i = 0; i < n; i++) + if (a[i] != b[i] * 233333333) + abort (); +} + + +int main (void) +{ + int i; + unsigned int a[N]; + unsigned short b[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = 0; + b[i] = i; + __asm__ volatile (""); + } + + foo (a, b, N); + bar (a, b, N); + baz (a, b, N); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" { target vect_widen_mult_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times {vect_recog_widen_mult_pattern: detected:[^\n]* 2333} 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ +/* { dg-final { scan-tree-dump-times {widen_mult pattern recognized:[^\n]* = \(int\)} 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-extern-1.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-extern-1.c new file mode 100644 index 0000000000..2df3c8f1cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-extern-1.c @@ -0,0 +1,17 @@ +/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ +/* { dg-do compile } */ + +#define N 1024 + +void +f (unsigned int *x1, unsigned int *x2, unsigned short *y, unsigned char z) +{ + unsigned short zu = z; + for (int i = 0; i < N; ++i) + { + unsigned short yi = y[i]; + x1[i] = x1[i] > 10 ? yi * zu : x1[i] + 1; + x2[i] += 1; + } +} +/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-half-u8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-half-u8.c new file mode 100644 index 0000000000..bfdcbaa09f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-half-u8.c @@ -0,0 +1,64 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fno-ipa-icf" } */ + +#include "tree-vect.h" + +#define N 32 +#define COEF 32470 + +unsigned char in[N]; +int out[N]; + +__attribute__ ((noinline)) void +foo () +{ + int i; + + for (i = 0; i < N; i++) + out[i] = in[i] * COEF; +} + +__attribute__ ((noinline)) void +bar () +{ + int i; + + for (i = 0; i < N; i++) + out[i] = COEF * in[i]; +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + __asm__ volatile (""); + } + + foo (); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (out[i] != in[i] * COEF) + abort (); + + bar (); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (out[i] != in[i] * COEF) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_widen_mult_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ +/* { dg-final { scan-tree-dump-times "pattern recognized" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-half.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-half.c new file mode 100644 index 0000000000..e46b0cc313 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-half.c @@ -0,0 +1,52 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +#define N 32 +#define COEF 32470 +#define COEF2 324700 + +unsigned char in[N]; +int out[N]; +int out2[N]; + +__attribute__ ((noinline)) void +foo (int a) +{ + int i; + + for (i = 0; i < N; i++) + { + out[i] = in[i] * COEF; + out2[i] = in[i] + a; + } +} + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + __asm__ volatile (""); + } + + foo (COEF2); + +#pragma GCC novector + for (i = 0; i < N; i++) + if (out[i] != in[i] * COEF || out2[i] != in[i] + COEF2) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_mult_hi_to_si } } } */ +/* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ +/* { dg-final { scan-tree-dump-times "pattern recognized" 1 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-s16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-s16.c new file mode 100644 index 0000000000..6b09486806 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-mult-s16.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int result[N]; + +/* short->int widening-mult */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +short result[N]; + +/* char->short widening-mult */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 +#define SUM 0 + +/* Require widening-mult or data-unpacking (for the type promotion). */ +__attribute__ ((noinline)) int +main1 (short *in, int off, short scale, int n) +{ + int i; + int sum = 0; + + for (i = 0; i < n; i++) { + sum += ((int) in[i] * (int) in[i+off]) >> scale; + } + + return sum; +} + +int main (void) +{ + int i; + int sum; + short X[N]; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned int result[N]; + +/* unsigned short->unsigned int widening-mult. */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +int result[N]; + +/* unsigned char * short -> int widening-mult. */ +__attribute__ ((noinline)) int +foo (int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned int result[N]; + +/* unsigned char-> unsigned int widening-mult. */ +__attribute__ ((noinline)) int +foo (int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 + +unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); +unsigned short result[N]; + +/* unsigned char-> unsigned short widening-mult. */ +__attribute__ ((noinline)) int +foo1(int len) { + int i; + + for (i=0; i +#include "tree-vect.h" + +#define N 64 +#define C 16 + +__attribute__ ((noinline)) void +foo (short *src, int *dst) +{ + int i; + short b, b0, b1, b2, b3, *s = src; + int *d = dst; + + for (i = 0; i < N/4; i++) + { + b0 = *s++; + b1 = *s++; + b2 = *s++; + b3 = *s++; + *d = b0 << C; + d++; + *d = b1 << C; + d++; + *d = b2 << C; + d++; + *d = b3 << C; + d++; + } + + s = src; + d = dst; +#pragma GCC novector + for (i = 0; i < N; i++) + { + b = *s++; + if (*d != b << C) + abort (); + d++; + } + + s = src; + d = dst; + for (i = 0; i < N/4; i++) + { + b0 = *s++; + b1 = *s++; + b2 = *s++; + b3 = *s++; + *d = b0 << C; + d++; + *d = b1 << C; + d++; + *d = b2 << C; + d++; + *d = b3 << 6; + d++; + } + + s = src; + d = dst; +#pragma GCC novector + for (i = 0; i < N/4; i++) + { + b = *s++; + if (*d != b << C) + abort (); + d++; + b = *s++; + if (*d != b << C) + abort (); + d++; + b = *s++; + if (*d != b << C) + abort (); + d++; + b = *s++; + if (*d != b << 6) + abort (); + d++; + } +} + +int main (void) +{ + int i; + short in[N]; + int out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 8 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-s8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-s8.c new file mode 100644 index 0000000000..7450d2aef7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-s8.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define C 12 + +__attribute__ ((noinline)) void +foo (char *src, int *dst) +{ + int i; + char b, *s = src; + int *d = dst; + + for (i = 0; i < N; i++) + { + b = *s++; + *d = b << C; + d++; + } + + s = src; + d = dst; +#pragma GCC novector + for (i = 0; i < N; i++) + { + b = *s++; + if (*d != b << C) + abort (); + d++; + } +} + +int main (void) +{ + int i; + char in[N]; + int out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 1 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-u16.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-u16.c new file mode 100644 index 0000000000..ae086b88e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-u16.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define C 7 + +__attribute__ ((noinline)) void +foo (unsigned short *src, unsigned int *dst) +{ + int i; + unsigned short b, *s = src; + unsigned int *d = dst; + + for (i = 0; i < N; i++) + { + b = *s++; + *d = b << C; + d++; + } + + s = src; + d = dst; +#pragma GCC novector + for (i = 0; i < N; i++) + { + b = *s++; + if (*d != b << C) + abort (); + d++; + } +} + +int main (void) +{ + int i; + unsigned short in[N]; + unsigned int out[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out[i] = 255; + __asm__ volatile (""); + } + + foo (in, out); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 1 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-u8.c b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-u8.c new file mode 100644 index 0000000000..a8e536adee --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect-widen-shift-u8.c @@ -0,0 +1,64 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_shift } */ + +#include +#include "tree-vect.h" + +#define N 64 +#define C1 10 +#define C2 5 + +__attribute__ ((noinline)) void +foo (unsigned char *src, unsigned int *dst1, unsigned int *dst2) +{ + int i; + unsigned char b, *s = src; + unsigned int *d1 = dst1, *d2 = dst2; + + for (i = 0; i < N; i++) + { + b = *s++; + *d1 = b << C1; + d1++; + *d2 = b << C2; + d2++; + } + + s = src; + d1 = dst1; + d2 = dst2; +#pragma GCC novector + for (i = 0; i < N; i++) + { + b = *s++; + if (*d1 != b << C1 || *d2 != b << C2) + abort (); + d1++; + d2++; + } +} + +int main (void) +{ + int i; + unsigned char in[N]; + unsigned int out1[N]; + unsigned int out2[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + in[i] = i; + out1[i] = 255; + out2[i] = 255; + __asm__ volatile (""); + } + + foo (in, out1, out2); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/vect.exp b/SingleSource/Regression/C/gcc-dg/vect/vect.exp new file mode 100644 index 0000000000..4566e904eb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/vect.exp @@ -0,0 +1,321 @@ +# Copyright (C) 1997-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp +load_lib clearcap.exp + +# Set up flags used for tests that don't specify options. +global DEFAULT_VECTCFLAGS +set DEFAULT_VECTCFLAGS "" + +# Set up a list of effective targets to run vector tests for all supported +# targets. +global EFFECTIVE_TARGETS +set EFFECTIVE_TARGETS "" + +# If the target system supports vector instructions, the default action +# for a test is 'run', otherwise it's 'compile'. Save current default. +# Executing vector instructions on a system without hardware vector support +# is also disabled by a call to check_vect, but disabling execution here is +# more efficient. +global dg-do-what-default +set save-dg-do-what-default ${dg-do-what-default} + +# Skip these tests for targets that do not support generating vector +# code. Set additional target-dependent vector flags, which can be +# overridden by using dg-options in individual tests. +if ![check_vect_support_and_set_flags] { + return +} + +# These flags are used for all targets. +lappend DEFAULT_VECTCFLAGS "-ftree-vectorize" "-fno-tree-loop-distribute-patterns" "-fno-vect-cost-model" "-fno-common" + +# Initialize `dg'. +dg-init +clearcap-init + +global VEC_FLAGS +set VEC_FLAGS $DEFAULT_VECTCFLAGS + +global O1_VECTCFLAGS +set O1_VECTCFLAGS $DEFAULT_VECTCFLAGS +lappend O1_VECTCFLAGS "-O1" +lappend O1_VECTCFLAGS "-fdump-tree-vect-details" + +global O_VECTCFLAGS +set O_VECTCFLAGS $DEFAULT_VECTCFLAGS +lappend O_VECTCFLAGS "-O" +lappend O_VECTCFLAGS "-fdump-tree-vect-details" + +lappend DEFAULT_VECTCFLAGS "-O2" + +# Tests that should be run without generating dump info +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/nodump-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# "-O -fdump-tree-veclower2" +lappend VEC_FLAGS "-O" "-fdump-tree-veclower2" +et-dg-runtest dg-runtest [lsort [glob -nocomplain \ + $srcdir/$subdir/vec-scal-*.\[cS\]]] \ + "" $VEC_FLAGS + +set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS + +lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" +lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details" + +# Main loop. +set VECT_ADDITIONAL_FLAGS [list ""] +if { [check_effective_target_lto] } { + lappend VECT_ADDITIONAL_FLAGS "-flto -ffat-lto-objects" +} +foreach flags $VECT_ADDITIONAL_FLAGS { + et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]] \ + $flags $DEFAULT_VECTCFLAGS + et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/vect-*.\[cS\]]] \ + $flags $DEFAULT_VECTCFLAGS + et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/tsvc/*.\[cS\]]] \ + $flags $DEFAULT_VECTCFLAGS + et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/slp-*.\[cS\]]] \ + $flags $DEFAULT_VECTCFLAGS + et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/bb-slp*.\[cS\]]] \ + $flags $VECT_SLP_CFLAGS +} + +#### Tests with special options +global SAVED_DEFAULT_VECTCFLAGS +set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS +set SAVED_VECT_SLP_CFLAGS $VECT_SLP_CFLAGS + +# --param vect-max-version-for-alias-checks=0 tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "--param" "vect-max-version-for-alias-checks=0" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-vfa-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -ffast-math tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-ffast-math" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/fast-math-\[ipsvc\]*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -ffast-math SLP tests +set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS +lappend VECT_SLP_CFLAGS "-ffast-math" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/fast-math-bb-slp-*.\[cS\]]] \ + "" $VECT_SLP_CFLAGS + +# -fno-fast-math tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-fast-math" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-fast-math-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-math-errno tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-math-errno" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-math-errno-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fwrapv tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fwrapv" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/wrapv-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -ftrapv tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-ftrapv" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/trapv-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-dce tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-dce" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-tree-dce-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fsection-anchors tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fsection-anchors" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/section-anchors-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# alignment-sensitive -fsection-anchors tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fsection-anchors" \ + "-fdump-ipa-increase_alignment-details" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/aligned-section-anchors-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-section-anchors tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-section-anchors" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-section-anchors-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -funswitch-loops tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-funswitch-loops" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/unswitch-loops-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-trapping-math tests +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-trapping-math" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-trapping-math-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-scev-cprop +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-scevccp-vect-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-scev-cprop +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-scevccp-pr*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-scev-cprop +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-scevccp-outer-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-scev-cprop -fno-tree-reassoc +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop" "-fno-tree-reassoc" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-scevccp-noreassoc-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-scev-cprop +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-scev-cprop" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-scevccp-slp-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-dominator-opts +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-dominator-opts" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-tree-dom-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-pre +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-pre" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-tree-pre-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# With -Os +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-Os" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/Os-vect-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# With --param ggc-min-expand=0 --param ggc-min-heapsize=0 +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "--param" "ggc-min-expand=0" "--param" "ggc-min-heapsize=0" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/ggc-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# With -O3. +# Don't allow IPA cloning, because it throws our counts out of whack. +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-O3" "-fno-ipa-cp-clone" + +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/O3-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# With -O1 +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/O1-*.\[cS\]]] \ + "" $O1_VECTCFLAGS + +# With -O +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/O-*.\[cS\]]] \ + "" $O_VECTCFLAGS + +# -fno-tree-reassoc +set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS +lappend VECT_SLP_CFLAGS "-fno-tree-reassoc" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-tree-reassoc-bb-slp-*.\[cS\]]] \ + "" $VECT_SLP_CFLAGS + +# -fno-tree-fre +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-fre" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-tree-fre-*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-fre -fno-tree-pre +set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS +lappend DEFAULT_VECTCFLAGS "-fno-tree-fre" "-fno-tree-pre" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-fre-pre*.\[cS\]]] \ + "" $DEFAULT_VECTCFLAGS + +# -fno-tree-sra +set VECT_SLP_CFLAGS $SAVED_VECT_SLP_CFLAGS +lappend VECT_SLP_CFLAGS "-fno-tree-sra" +et-dg-runtest dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/no-tree-sra-bb-slp-*.\[cS\]]] \ + "" $VECT_SLP_CFLAGS + + +# Clean up. +set dg-do-what-default ${save-dg-do-what-default} + +# All done. +clearcap-finish +dg-finish diff --git a/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-7.c b/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-7.c new file mode 100644 index 0000000000..414bd9d3e1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-7.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +#include +#include "tree-vect.h" + +#define N 128 + +short sa[N]; +short sb[N]; + +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + sb[i] = 5; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (sb[i] != 5) + abort (); + } + + for (i = 0; i < N; i++) + { + sa[i] = sb[i] + (short)100; + } + + /* check results: */ +#pragma GCC novector + for (i = 0; i < N; i++) + { + if (sa[i] != 105) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* Fails for 32-bit targets that don't vectorize PLUS. */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-2char.c b/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-2char.c new file mode 100644 index 0000000000..556c2a06dc --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-2char.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 121 + +signed char b[N] = {1,2,3,6,8,10,12,14,16,18,20,22,24,26,28,30}; +signed char c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) +void main1 (signed char x, signed char max_result, signed char min_result) +{ + int i; + signed char diff = 2; + signed char max = x; + signed char min = x; + + for (i = 0; i < N; i++) { + diff += (signed char)(b[i] - c[i]); + } + + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-2short.c b/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-2short.c new file mode 100644 index 0000000000..f9142173b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-2short.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define DIFF 242 + +short b[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +short c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + +__attribute__ ((noinline)) +void main1 (short x, short max_result, short min_result) +{ + int i; + short diff = 2; + short max = x; + short min = x; + + for (i = 0; i < N; i++) { + diff += (short)(b[i] - c[i]); + } + for (i = 0; i < N; i++) { + max = max < c[i] ? c[i] : max; + } + + for (i = 0; i < N; i++) { + min = min > c[i] ? c[i] : min; + } + + /* check results: */ + if (diff != DIFF) + abort (); + if (max != max_result) + abort (); + if (min != min_result) + abort (); +} + +int main (void) +{ + check_vect (); + + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-dot-s8b.c b/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-dot-s8b.c new file mode 100644 index 0000000000..751352649c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vect/wrapv-vect-reduc-dot-s8b.c @@ -0,0 +1,58 @@ +/* Disabling epilogues until we find a better way to deal with scans. */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 64 + +#define DOT -21856 + +signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; + +/* char->short->short dot product. + The dot-product pattern should be detected. + Should be vectorized on vect_sdot_qi targets (targets that support + dot-product of signed char). + This test currently fails to vectorize on targets that support + dot-product of chars into and int accumulator. + Can also be vectorized as widening-mult + summation, + or with type-conversion support. + */ +__attribute__ ((noinline)) short +foo(int len) { + int i; + short result = 0; + + for (i=0; i +#include "tree-vect.h" + +#define N 16 +signed char data_ch[N] = + { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 }; +#define SUM 210 + +__attribute__ ((noinline)) int +foo () +{ + int i; + signed short shortsum = 0; + + /* widenning sum: sum chars into short. */ + + for (i = 0; i < N; i++) + { + shortsum += data_ch[i]; + } + + /* check results: */ + if (shortsum != SUM) + abort (); + + return 0; +} + +int +main (void) +{ + check_vect (); + return foo (); +} + +/* { dg-final { scan-tree-dump "vect_recog_widen_sum_pattern: detected" "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_qi_to_hi } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_hi } } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vector-1.c b/SingleSource/Regression/C/gcc-dg/vector-1.c new file mode 100644 index 0000000000..a5eaa2a8c2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vector-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90" } */ + +typedef int V __attribute__ ((vector_size(4))); +void fn1 () +{ + (V){(1,0)}[0] = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vector-shift-2.c b/SingleSource/Regression/C/gcc-dg/vector-shift-2.c new file mode 100644 index 0000000000..8e37d9dbb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vector-shift-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-ccp1" } */ + +typedef unsigned vec __attribute__ ((vector_size (4*sizeof(int)))); +void +f (vec *a) +{ + vec s = { 5, 5, 5, 5 }; + *a = *a << s; +} + +/* { dg-final { scan-tree-dump "<< 5" "ccp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vector-shift.c b/SingleSource/Regression/C/gcc-dg/vector-shift.c new file mode 100644 index 0000000000..f71a1d75db --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vector-shift.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +typedef unsigned vec __attribute__ ((vector_size (4 * sizeof (int)))); + +void +f (vec *x) +{ + *x = (*x << 4) << 3; +} + +/* { dg-final { scan-tree-dump "<< 7" "original" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/verbose-asm-2.c b/SingleSource/Regression/C/gcc-dg/verbose-asm-2.c new file mode 100644 index 0000000000..747bff1875 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/verbose-asm-2.c @@ -0,0 +1,15 @@ +/* Ensure that the -fverbose-asm leads to source code information in the generated asm. */ +/* { dg-options "-fverbose-asm" } */ + +int test (int n) +{ + int i; + int total = 0; + + for (i = 0; i < n; i++) + total += i * i; + + return total; +} + +/* { dg-final { scan-assembler "total = 0" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/verbose-asm.c b/SingleSource/Regression/C/gcc-dg/verbose-asm.c new file mode 100644 index 0000000000..7d105d31cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/verbose-asm.c @@ -0,0 +1,27 @@ +/* Test whether -fverbose-asm works. */ +/* { dg-do compile } */ +/* { dg-options "-fverbose-asm" } */ + +void foo (int *x) +{ + (*x)++; +} + +int bar (int *y) +{ + int a, b; + b = 10; + a = 26; + foo (&a); + a += 10; + foo (&a); + *y--; + return b; +} + +int +main (int argc, char *argv []) +{ + bar (&argc); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-1.c b/SingleSource/Regression/C/gcc-dg/visibility-1.c new file mode 100644 index 0000000000..864b971dd6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-1.c @@ -0,0 +1,9 @@ +/* Test visibility attribute on function definition. */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" } } */ + +void +__attribute__((visibility ("hidden"))) +foo() +{ } diff --git a/SingleSource/Regression/C/gcc-dg/visibility-10.c b/SingleSource/Regression/C/gcc-dg/visibility-10.c new file mode 100644 index 0000000000..d86ce1b1a3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-10.c @@ -0,0 +1,19 @@ +/* Test that a definition marked with dllexport has default + visibility. */ +/* { dg-require-visibility "" } */ +/* { dg-require-dll "" } */ +/* { dg-options "-fvisibility=hidden" } */ +/* { dg-final { scan-not-hidden "g" } } */ +/* { dg-final { scan-not-hidden "h" } } */ +/* { dg-final { scan-not-hidden "k" } } */ +/* { dg-final { scan-not-hidden "l" } } */ + +__declspec(dllexport) void g() {} + +__declspec(dllexport) void h(); +void h() {} + +__declspec(dllexport) int k; + +__declspec(dllexport) extern int l; +int l; diff --git a/SingleSource/Regression/C/gcc-dg/visibility-11.c b/SingleSource/Regression/C/gcc-dg/visibility-11.c new file mode 100644 index 0000000000..1bcc4240e6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-11.c @@ -0,0 +1,26 @@ +/* PR middle-end/20297 */ +/* The memcpy FUNCTION_DECL built in the middle-end for block moves got + hidden visibility from the first push, so the call didn't use the PLT. */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-skip-if "" { *-*-darwin* } } */ +/* { dg-require-visibility "" } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-Os -fpic -mstringop-strategy=libcall" } */ +/* { dg-final { scan-assembler "memcpy@PLT" } } */ + +#pragma GCC visibility push(hidden) +#pragma GCC visibility push(default) +extern void* memcpy (void *, const void *, __SIZE_TYPE__); +#pragma GCC visibility pop + +struct a { int a[4096]; }; + +extern void *bar (struct a *, struct a *, int); + +void * +foo (struct a *a, struct a *b, int c) +{ + struct a cc = *b; + return bar (a, &cc, 4 * c); +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-12.c b/SingleSource/Regression/C/gcc-dg/visibility-12.c new file mode 100644 index 0000000000..6012bd9ce2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-12.c @@ -0,0 +1,10 @@ +/* Test that dllimport'd functions have default visibility. */ +/* { dg-require-visibility "" } */ +/* { dg-require-dll "" } */ +/* { dg-options "-fvisibility=hidden" } */ +/* { dg-final { scan-not-hidden "f1" } } */ + +extern void __attribute__((dllimport)) f1(); +void f2() { + f1(); +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-13.c b/SingleSource/Regression/C/gcc-dg/visibility-13.c new file mode 100644 index 0000000000..5f7a7c7a0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-13.c @@ -0,0 +1,19 @@ +/* { dg-require-visibility "" } */ +/* { dg-require-dll "" } */ + +extern void __attribute__((dllimport, visibility("hidden"))) + f1(); /* { dg-error "visibility" } */ +extern void __attribute__((visibility("hidden"), dllimport)) + f2(); /* { dg-error "visibility" } */ +extern void __attribute__((dllexport, visibility("hidden"))) + f3(); /* { dg-error "visibility" } */ +extern void __attribute__((visibility("hidden"), dllexport)) + f4(); /* { dg-error "visibility" } */ +extern void __attribute__((visibility("default"), dllimport)) + f5(); +extern void __attribute__((dllimport, visibility("default"))) + f6(); +extern void __attribute__((visibility("default"), dllexport)) + f7(); +extern void __attribute__((dllexport, visibility("default"))) + f8(); diff --git a/SingleSource/Regression/C/gcc-dg/visibility-14.c b/SingleSource/Regression/C/gcc-dg/visibility-14.c new file mode 100644 index 0000000000..9ec74471f0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-14.c @@ -0,0 +1,10 @@ +/* Test that called external functions are marked. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-darwin* } } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" { xfail *-*-aix* } } } */ + +extern void foo(void) __attribute__ ((visibility ("hidden"))); +int f () { + foo(); +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-15.c b/SingleSource/Regression/C/gcc-dg/visibility-15.c new file mode 100644 index 0000000000..db555884f9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-15.c @@ -0,0 +1,12 @@ +/* Test that accessed external functions are marked. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-darwin* } } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" { xfail *-*-aix* } } } */ + +extern void foo(void) __attribute__ ((visibility ("hidden"))); +typedef void (*foo_t)(void); + +foo_t g(void) { + return foo; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-16.c b/SingleSource/Regression/C/gcc-dg/visibility-16.c new file mode 100644 index 0000000000..595bcb9b96 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-16.c @@ -0,0 +1,10 @@ +/* Test that accessed external variables are marked. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-darwin* } } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" { xfail *-*-aix* } } } */ + +extern int foo __attribute__ ((visibility ("hidden"))); +int f () { + return foo; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-17.c b/SingleSource/Regression/C/gcc-dg/visibility-17.c new file mode 100644 index 0000000000..e8f68fe36d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-17.c @@ -0,0 +1,10 @@ +/* Test that external variable whose address is taken are marked. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-darwin* } } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" { xfail *-*-aix* } } } */ + +extern int foo __attribute__ ((visibility ("hidden"))); +int *f () { + return &foo; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-18.c b/SingleSource/Regression/C/gcc-dg/visibility-18.c new file mode 100644 index 0000000000..4b089f1cf2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-18.c @@ -0,0 +1,8 @@ +/* Test that external variable whose address is taken are marked. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-darwin* } } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" { xfail *-*-aix* } } } */ + +extern int foo __attribute__ ((visibility ("hidden"))); +int *test = &foo; diff --git a/SingleSource/Regression/C/gcc-dg/visibility-19.c b/SingleSource/Regression/C/gcc-dg/visibility-19.c new file mode 100644 index 0000000000..140294f493 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-19.c @@ -0,0 +1,9 @@ +/* Test that accessed external functions are marked. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-darwin* } } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" { xfail *-*-aix* } } } */ + +extern void foo(void) __attribute__ ((visibility ("hidden"))); +typedef void (*foo_t)(void); +foo_t test = foo; diff --git a/SingleSource/Regression/C/gcc-dg/visibility-2.c b/SingleSource/Regression/C/gcc-dg/visibility-2.c new file mode 100644 index 0000000000..0977abac2b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-2.c @@ -0,0 +1,10 @@ +/* Test that visibility attribute on declaration extends to definition. */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" } } */ + +void +__attribute__((visibility ("hidden"))) +foo(); + +void foo() { } diff --git a/SingleSource/Regression/C/gcc-dg/visibility-20.c b/SingleSource/Regression/C/gcc-dg/visibility-20.c new file mode 100644 index 0000000000..5fc7447f0d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-20.c @@ -0,0 +1,18 @@ +/* PR target/39175 */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-options "-O2 -fvisibility=hidden -fpic" { target fpic } } */ + +__attribute__((noinline)) int +foo (int x) +{ + return x; +} + +int foo (int x); + +int +bar (int x) +{ + return foo (x); +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-21.c b/SingleSource/Regression/C/gcc-dg/visibility-21.c new file mode 100644 index 0000000000..59d1b45674 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-21.c @@ -0,0 +1,14 @@ +/* Test visibility attribute on function definition. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsection-anchors" } */ +/* { dg-require-visibility "" } */ +/* { dg-require-weak "" } */ +/* { dg-require-effective-target section_anchors } */ +/* { dg-final { scan-assembler-not "ANCHOR" } } */ + +int __attribute__((weak, visibility("hidden"))) weak_hidden[3]; + +int *f_weak_hidden () +{ + return weak_hidden; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-22.c b/SingleSource/Regression/C/gcc-dg/visibility-22.c new file mode 100644 index 0000000000..9123b350b2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-22.c @@ -0,0 +1,15 @@ +/* PR target/32219 */ +/* { dg-do run } */ +/* { dg-require-visibility "" } */ +/* { dg-require-effective-target weak_undefined } */ +/* { dg-options "-O2 -fPIC" { target fpic } } */ +/* { dg-add-options weak_undefined } */ + +extern void foo () __attribute__((weak,visibility("hidden"))); +int +main() +{ + if (foo) + foo (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-23.c b/SingleSource/Regression/C/gcc-dg/visibility-23.c new file mode 100644 index 0000000000..2abb605acf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-23.c @@ -0,0 +1,15 @@ +/* PR target/32219 */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" } } */ +/* { dg-options "-O2 -fPIC" { target fpic } } */ +/* { dg-skip-if "" { "hppa*-*-hpux*" "*-*-aix*" "*-*-darwin*" } } */ + +extern void foo () __attribute__((weak,visibility("hidden"))); +int +main() +{ + if (foo) + foo (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-3.c b/SingleSource/Regression/C/gcc-dg/visibility-3.c new file mode 100644 index 0000000000..cb5a71524f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-3.c @@ -0,0 +1,8 @@ +/* Test visibility attribute on forward declaration of global variable */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "xyzzy" } } */ + +int +__attribute__((visibility ("hidden"))) +xyzzy = 5; diff --git a/SingleSource/Regression/C/gcc-dg/visibility-4.c b/SingleSource/Regression/C/gcc-dg/visibility-4.c new file mode 100644 index 0000000000..af0d461c3d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-4.c @@ -0,0 +1,10 @@ +/* Test visibility attribute on forward declaration of global variable */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "xyzzy" } } */ + +extern int +__attribute__((visibility ("hidden"))) +xyzzy; + +int xyzzy = 5; diff --git a/SingleSource/Regression/C/gcc-dg/visibility-5.c b/SingleSource/Regression/C/gcc-dg/visibility-5.c new file mode 100644 index 0000000000..0302768c91 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-5.c @@ -0,0 +1,12 @@ +/* Test visibility attribute on definition of a function that has + already had a forward declaration. */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" } } */ + +void foo(); + +void + __attribute__((visibility ("hidden"))) +foo() +{ } diff --git a/SingleSource/Regression/C/gcc-dg/visibility-6.c b/SingleSource/Regression/C/gcc-dg/visibility-6.c new file mode 100644 index 0000000000..4e9deebec3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-6.c @@ -0,0 +1,11 @@ +/* Test visibility attribute on definition of global variable that has + already had a forward declaration. */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "xyzzy" } } */ + +extern int xyzzy; + +int +__attribute__((visibility ("hidden"))) +xyzzy = 5; diff --git a/SingleSource/Regression/C/gcc-dg/visibility-7.c b/SingleSource/Regression/C/gcc-dg/visibility-7.c new file mode 100644 index 0000000000..8bf62d6e43 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-7.c @@ -0,0 +1,12 @@ +/* Test warning from conflicting visibility specifications. */ +/* { dg-do compile } */ +/* { dg-require-visibility "protected" } */ +/* { dg-final { scan-hidden "xyzzy" } } */ + +extern int +__attribute__((visibility ("hidden"))) +xyzzy; /* { dg-message "note: previous declaration" } */ + +int +__attribute__((visibility ("protected"))) +xyzzy = 5; /* { dg-warning "different visibility" } */ diff --git a/SingleSource/Regression/C/gcc-dg/visibility-8.c b/SingleSource/Regression/C/gcc-dg/visibility-8.c new file mode 100644 index 0000000000..89f89c0822 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-8.c @@ -0,0 +1,16 @@ +/* Test hidden visibility on built-in functions (for libc). PR 13856. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "__GI_fputs_unlocked" } } */ + +int fputs_unlocked (const char *restrict, int *restrict) + __asm__ ("__GI_fputs_unlocked") + __attribute__ ((visibility ("hidden"))); + +int +fputs_unlocked (str, fp) + const char *str; + int *fp; +{ +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-9.c b/SingleSource/Regression/C/gcc-dg/visibility-9.c new file mode 100644 index 0000000000..9d57516849 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-9.c @@ -0,0 +1,9 @@ +/* Test that -fvisibility works. */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-options "-fvisibility=hidden" } */ +/* { dg-final { scan-hidden "foo" } } */ + +void foo(); + +void foo() { } diff --git a/SingleSource/Regression/C/gcc-dg/visibility-a.c b/SingleSource/Regression/C/gcc-dg/visibility-a.c new file mode 100644 index 0000000000..23a51d7e5a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-a.c @@ -0,0 +1,10 @@ +/* Test that #pragma GCC visibility works. */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-hidden "foo" } } */ + +#pragma GCC visibility push(hidden) +void foo(); +#pragma GCC visibility pop + +void foo() { } diff --git a/SingleSource/Regression/C/gcc-dg/visibility-b.c b/SingleSource/Regression/C/gcc-dg/visibility-b.c new file mode 100644 index 0000000000..b1f15758aa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-b.c @@ -0,0 +1,13 @@ +/* { dg-do assemble { target *-*-darwin* } } */ + +#define __private_extern__ extern __attribute__((visibility ("hidden"))) + +__private_extern__ int n; + +int +mach_error_type(int sub) +{ + if (sub >= n) + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-c.c b/SingleSource/Regression/C/gcc-dg/visibility-c.c new file mode 100644 index 0000000000..22412e02b5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-c.c @@ -0,0 +1,10 @@ +/* Test that visibility works on common symbols also. */ +/* { dg-do assemble } */ +/* { dg-require-visibility "" } */ + +int options __attribute__((__visibility__("hidden"))); + +void f(void) +{ + options = 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/visibility-d.c b/SingleSource/Regression/C/gcc-dg/visibility-d.c new file mode 100644 index 0000000000..6f8851b621 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/visibility-d.c @@ -0,0 +1,205 @@ +/* PR middle-end/20303 */ +/* Test nesting of #pragma GCC visibility. */ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-not-hidden "foo00" } } */ +/* { dg-final { scan-hidden "foo01" } } */ +/* { dg-final { scan-not-hidden "foo02" } } */ +/* { dg-final { scan-hidden "foo03" } } */ +/* { dg-final { scan-not-hidden "foo04" } } */ +/* { dg-final { scan-not-hidden "foo05" } } */ +/* { dg-final { scan-not-hidden "foo06" } } */ +/* { dg-final { scan-hidden "foo07" } } */ +/* { dg-final { scan-not-hidden "foo08" } } */ +/* { dg-final { scan-hidden "foo09" } } */ +/* { dg-final { scan-not-hidden "foo10" } } */ +/* { dg-final { scan-hidden "foo11" } } */ +/* { dg-final { scan-hidden "foo12" } } */ +/* { dg-final { scan-hidden "foo13" } } */ +/* { dg-final { scan-not-hidden "foo14" } } */ +/* { dg-final { scan-hidden "foo15" } } */ +/* { dg-final { scan-not-hidden "foo16" } } */ +/* { dg-final { scan-hidden "foo17" } } */ +/* { dg-final { scan-not-hidden "foo18" } } */ +/* { dg-final { scan-hidden "foo19" } } */ +/* { dg-final { scan-not-hidden "foo20" } } */ +/* { dg-final { scan-hidden "foo21" } } */ +/* { dg-final { scan-not-hidden "foo22" } } */ +/* { dg-final { scan-hidden "foo23" } } */ +/* { dg-final { scan-not-hidden "foo24" } } */ +/* { dg-final { scan-hidden "foo25" } } */ +/* { dg-final { scan-not-hidden "foo26" } } */ +/* { dg-final { scan-hidden "foo27" } } */ +/* { dg-final { scan-not-hidden "foo28" } } */ +/* { dg-final { scan-hidden "foo29" } } */ +/* { dg-final { scan-not-hidden "foo30" } } */ +/* { dg-final { scan-hidden "foo31" } } */ +/* { dg-final { scan-not-hidden "foo32" } } */ +/* { dg-final { scan-hidden "foo33" } } */ +/* { dg-final { scan-not-hidden "foo34" } } */ +/* { dg-final { scan-hidden "foo35" } } */ +/* { dg-final { scan-not-hidden "foo36" } } */ +/* { dg-final { scan-hidden "foo37" } } */ +/* { dg-final { scan-not-hidden "foo38" } } */ +/* { dg-final { scan-hidden "foo39" } } */ +/* { dg-final { scan-not-hidden "foo40" } } */ +/* { dg-final { scan-hidden "foo41" } } */ +/* { dg-final { scan-not-hidden "foo42" } } */ +/* { dg-final { scan-hidden "foo43" } } */ +/* { dg-final { scan-not-hidden "foo44" } } */ +/* { dg-final { scan-hidden "foo45" } } */ +/* { dg-final { scan-hidden "foo46" } } */ +/* { dg-final { scan-hidden "foo47" } } */ +/* { dg-final { scan-not-hidden "foo48" } } */ +/* { dg-final { scan-hidden "foo49" } } */ +/* { dg-final { scan-not-hidden "foo50" } } */ +/* { dg-final { scan-hidden "foo51" } } */ +/* { dg-final { scan-not-hidden "foo52" } } */ +/* { dg-final { scan-not-hidden "foo53" } } */ +/* { dg-final { scan-not-hidden "foo54" } } */ +/* { dg-final { scan-hidden "foo55" } } */ +/* { dg-final { scan-not-hidden "foo56" } } */ +/* { dg-final { scan-hidden "foo57" } } */ +/* { dg-final { scan-not-hidden "foo58" } } */ +/* { dg-final { scan-hidden "foo59" } } */ + +#pragma GCC visibility push(default) +void foo00(); +#pragma GCC visibility push(hidden) +void foo01(); +#pragma GCC visibility push(default) +void foo02(); +#pragma GCC visibility push(hidden) +void foo03(); +#pragma GCC visibility push(default) +void foo04(); +#pragma GCC visibility push(default) +void foo05(); +#pragma GCC visibility push(default) +void foo06(); +#pragma GCC visibility push(hidden) +void foo07(); +#pragma GCC visibility push(default) +void foo08(); +#pragma GCC visibility push(hidden) +void foo09(); +#pragma GCC visibility push(default) +void foo10(); +#pragma GCC visibility push(hidden) +void foo11(); +#pragma GCC visibility push(hidden) +void foo12(); +#pragma GCC visibility push(hidden) +void foo13(); +#pragma GCC visibility push(default) +void foo14(); +#pragma GCC visibility push(hidden) +void foo15(); +#pragma GCC visibility push(default) +void foo16(); +#pragma GCC visibility push(hidden) +void foo17(); +#pragma GCC visibility push(default) +void foo18(); +#pragma GCC visibility push(hidden) +void foo19(); +#pragma GCC visibility push(default) +void foo20(); +#pragma GCC visibility push(hidden) +void foo21(); +#pragma GCC visibility push(default) +void foo22(); +#pragma GCC visibility push(hidden) +void foo23(); +#pragma GCC visibility push(default) +void foo24(); +#pragma GCC visibility push(hidden) +void foo25(); +#pragma GCC visibility push(default) +void foo26(); +#pragma GCC visibility push(hidden) +void foo27(); +#pragma GCC visibility push(default) +void foo28(); +#pragma GCC visibility push(hidden) +void foo29(); +#pragma GCC visibility pop +void foo30(); +#pragma GCC visibility pop +void foo31(); +#pragma GCC visibility pop +void foo32(); +#pragma GCC visibility pop +void foo33(); +#pragma GCC visibility pop +void foo34(); +#pragma GCC visibility pop +void foo35(); +#pragma GCC visibility pop +void foo36(); +#pragma GCC visibility pop +void foo37(); +#pragma GCC visibility pop +void foo38(); +#pragma GCC visibility pop +void foo39(); +#pragma GCC visibility pop +void foo40(); +#pragma GCC visibility pop +void foo41(); +#pragma GCC visibility pop +void foo42(); +#pragma GCC visibility pop +void foo43(); +#pragma GCC visibility pop +void foo44(); +#pragma GCC visibility pop +void foo45(); +#pragma GCC visibility pop +void foo46(); +#pragma GCC visibility pop +void foo47(); +#pragma GCC visibility pop +void foo48(); +#pragma GCC visibility pop +void foo49(); +#pragma GCC visibility pop +void foo50(); +#pragma GCC visibility pop +void foo51(); +#pragma GCC visibility pop +void foo52(); +#pragma GCC visibility pop +void foo53(); +#pragma GCC visibility pop +void foo54(); +#pragma GCC visibility pop +void foo55(); +#pragma GCC visibility pop +void foo56(); +#pragma GCC visibility pop +void foo57(); +#pragma GCC visibility pop +void foo58(); +#pragma GCC visibility push (hidden) +void foo59(); +#pragma GCC visibility pop +#pragma GCC visibility pop + +#define D(N) \ +void foo##N##0() { } \ +void foo##N##1() { } \ +void foo##N##2() { } \ +void foo##N##3() { } \ +void foo##N##4() { } \ +void foo##N##5() { } \ +void foo##N##6() { } \ +void foo##N##7() { } \ +void foo##N##8() { } \ +void foo##N##9() { } +D(0) +D(1) +D(2) +D(3) +D(4) +D(5) diff --git a/SingleSource/Regression/C/gcc-dg/vla-1.c b/SingleSource/Regression/C/gcc-dg/vla-1.c new file mode 100644 index 0000000000..902166cb18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-g -O3 -fdump-tree-optimized -fvar-tracking-assignments -fno-selective-scheduling -fno-selective-scheduling2" } */ + +int __attribute__((noinline)) +f1 (int i) +{ + char a[i + 1]; + char b[i + 2]; + b[1] = 3; + a[0] = 5; + return a[0] + b[1]; +} + +int +main () +{ + volatile int j; + int x = 5; + j = f1 (x); + return 0; +} + +/* One debug source bind is generated for the parameter, and one to describe the + sizes of a and b. */ +/* { dg-final { scan-tree-dump-times " s=> i" 2 "optimized" } } */ + diff --git a/SingleSource/Regression/C/gcc-dg/vla-10.c b/SingleSource/Regression/C/gcc-dg/vla-10.c new file mode 100644 index 0000000000..47dff47c55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-10.c @@ -0,0 +1,7 @@ +/* ICE with VLA in nested parameter declaration: should be treated + like [*] instead of the size being expanded. Bug 28504 from Volker + Reichelt . */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo(void (*p)(int n, int x[n])) {} diff --git a/SingleSource/Regression/C/gcc-dg/vla-11.c b/SingleSource/Regression/C/gcc-dg/vla-11.c new file mode 100644 index 0000000000..1504853a55 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-11.c @@ -0,0 +1,12 @@ +/* Further tests of [*] being rejected other that in declarations, as + per the consensus in DR#341 that the second example there should be + invalid (but warnings because the final wording appears to allow + these cases). */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +void foo11a(int x[sizeof(int *(*)[*])]); /* { dg-warning "not in a declaration" } */ +void foo11b(__SIZE_TYPE__ x, int y[(__UINTPTR_TYPE__)(int (*)[*])x]); /* { dg-warning "not in a declaration" } */ +void foo11c(struct s { int (*x)[*]; } *y); /* { dg-error "a member of a structure or union cannot have a variably modified type" "variably modified" } */ +/* { dg-warning "'struct s' declared inside parameter list" "struct decl" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-12.c b/SingleSource/Regression/C/gcc-dg/vla-12.c new file mode 100644 index 0000000000..604ea88dc2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-12.c @@ -0,0 +1,50 @@ +/* Test for typeof evaluation: should be at the appropriate point in + the containing expression rather than just adding a statement. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +extern void exit (int); +extern void abort (void); + +void *p; + +void +f1 (void) +{ + int i = 0, j = -1, k = -1; + /* typeof applied to expression with cast. */ + (j = ++i), (void)(typeof ((int (*)[(k = ++i)])p))p; + if (j != 1 || k != 2 || i != 2) + abort (); +} + +void +f2 (void) +{ + int i = 0, j = -1, k = -1; + /* typeof applied to type. */ + (j = ++i), (void)(typeof (int (*)[(k = ++i)]))p; + if (j != 1 || k != 2 || i != 2) + abort (); +} + +void +f3 (void) +{ + int i = 0, j = -1, k = -1; + void *q; + /* typeof applied to expression with cast that is used. */ + (j = ++i), (void)((typeof (1 + (int (*)[(k = ++i)])p))p); + if (j != 1 || k != 2 || i != 2) + abort (); +} + +int +main (void) +{ + f1 (); + f2 (); + f3 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-13.c b/SingleSource/Regression/C/gcc-dg/vla-13.c new file mode 100644 index 0000000000..70b63059d7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-13.c @@ -0,0 +1,99 @@ +/* Test for VLA size evaluation; see PR 35198. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +extern void exit (int); +extern void abort (void); + +int i; +void *p; + +void +f1 (void *x, int j) +{ + p = (int (*)[++i])x; + if (i != j) + abort (); +} + +void +f1c (void *x, int j) +{ + p = (int (*)[++i]){x}; + if (i != j) + abort (); +} + +void +f2 (void *x, int j) +{ + x = (void *)(int (*)[++i])p; + if (i != j) + abort (); +} + +void +f2c (void *x, int j) +{ + x = (void *)(int (*)[++i]){p}; + if (i != j) + abort (); +} + +void +f3 (void *x, int j) +{ + (void)(int (*)[++i])p; + if (i != j) + abort (); +} + +void +f3c (void *x, int j) +{ + (void)(int (*)[++i]){p}; + if (i != j) + abort (); +} + +void +f4 (void *x, int j) +{ + (int (*)[++i])p; + (int (*)[++i])p; + if (i != j) + abort (); +} + +void +f4c (void *x, int j) +{ + (int (*)[++i]){p}; + (int (*)[++i]){p}; + if (i != j) + abort (); +} + +void +f5c (void *x, int j, int k) +{ + (++i, f3c (x, j), (int (*)[++i]){p}); + if (i != k) + abort (); +} + +int +main (void) +{ + f1 (p, 1); + f2 (p, 2); + f3 (p, 3); + f4 (p, 5); + f1c (p, 6); + f2c (p, 7); + f3c (p, 8); + f4c (p, 10); + f5c (p, 12, 13); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-14.c b/SingleSource/Regression/C/gcc-dg/vla-14.c new file mode 100644 index 0000000000..3dbb11ed1a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-14.c @@ -0,0 +1,33 @@ +/* Test for VLA size evaluation in va_arg. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +#include + +extern void exit (int); +extern void abort (void); + +int a[10]; +int i = 9; + +void +f (int n, ...) +{ + va_list ap; + void *p; + va_start (ap, n); + p = va_arg (ap, typeof (int (*)[++i])); + if (p != a) + abort (); + if (i != n) + abort (); + va_end (ap); +} + +int +main (void) +{ + f (10, &a); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-15.c b/SingleSource/Regression/C/gcc-dg/vla-15.c new file mode 100644 index 0000000000..800163bc18 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-15.c @@ -0,0 +1,27 @@ +/* Test for VLA size evaluation in sizeof typeof. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +#include + +extern void exit (int); +extern void abort (void); + +char a[1]; + +void +f1 (void) +{ + int i = 0; + int j = sizeof (typeof (*(++i, (char (*)[i])a))); + if (i != 1 || j != 1) + abort (); +} + +int +main (void) +{ + f1 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-16.c b/SingleSource/Regression/C/gcc-dg/vla-16.c new file mode 100644 index 0000000000..05e751af7a --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-16.c @@ -0,0 +1,70 @@ +/* Test for modifying and taking addresses of compound literals whose + variably modified types involve typeof. */ +/* Origin: Joseph Myers */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ + +#include + +extern void exit (int); +extern void abort (void); + +int a[1]; + +void +f1 (void) +{ + int i = 0; + int (**p)[1] = &(typeof (++i, (int (*)[i])a)){&a}; + if (*p != &a) + abort (); + if (i != 1) + abort (); +} + +void +f2 (void) +{ + int i = 0; + (typeof (++i, (int (*)[i])a)){&a} = 0; + if (i != 1) + abort (); +} + +void +f3 (void) +{ + int i = 0; + (typeof (++i, (int (*)[i])a)){&a} += 1; + if (i != 1) + abort (); +} + +void +f4 (void) +{ + int i = 0; + --(typeof (++i, (int (*)[i])a)){&a + 1}; + if (i != 1) + abort (); +} + +void +f5 (void) +{ + int i = 0; + (typeof (++i, (int (*)[i])a)){&a}++; + if (i != 1) + abort (); +} + +int +main (void) +{ + f1 (); + f2 (); + f3 (); + f4 (); + f5 (); + exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-17.c b/SingleSource/Regression/C/gcc-dg/vla-17.c new file mode 100644 index 0000000000..07d3930041 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-17.c @@ -0,0 +1,9 @@ +/* Test diagnostics for VLA whose size folds to an integer constant at + file scope. PR 39605. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#define FIRST ((void*)0x80) +#define LAST ((void*)0x86) + +static int b[LAST-FIRST]; /* { dg-warning "variably modified 'b' at file scope" } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-18.c b/SingleSource/Regression/C/gcc-dg/vla-18.c new file mode 100644 index 0000000000..c60069cfd8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-18.c @@ -0,0 +1,9 @@ +/* Test diagnostics for VLA whose size folds to an integer constant at + file scope; the diagnostic should be a pedwarn. PR 39605. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +#define FIRST ((char*)0x80) +#define LAST ((char*)0x86) + +static int b[LAST-FIRST]; /* { dg-error "variably modified 'b' at file scope" } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-19.c b/SingleSource/Regression/C/gcc-dg/vla-19.c new file mode 100644 index 0000000000..83093c9291 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-19.c @@ -0,0 +1,32 @@ +/* Test diagnostics for variably modified function return types. PR + 39564. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +int a; + +void +f1 (void) +{ + typedef int T[a]; + extern T *g1 (void); /* { dg-error "non-nested function with variably modified type" } */ +} + +void +f2 (void) +{ + extern int (*g2 (void))[a]; /* { dg-error "non-nested function with variably modified type" } */ +} + +void +f3 (void) +{ + typedef int T[a]; + T *g3 (void); /* { dg-error "non-nested function with variably modified type" } */ +} + +void +f4 (void) +{ + int (*g4 (void))[a]; /* { dg-error "non-nested function with variably modified type" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-2.c b/SingleSource/Regression/C/gcc-dg/vla-2.c new file mode 100644 index 0000000000..e6ddcccfb4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-2.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-effective-target alloca } */ + +/* These are crash tests related to PR middle-end/6994; see also + g++.dg/ext/vla1.C. Note that at present A and C cannot be inlined. */ + +static inline void A (int i) +{ + struct S { int ar[1][i]; } s; + + s.ar[0][0] = 0; +} + +void B(void) +{ + A(23); +} + +static inline void C (int i) +{ + union U { int ar[1][i]; } u; + + u.ar[0][0] = 0; +} + +void D(void) +{ + C(23); +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-20.c b/SingleSource/Regression/C/gcc-dg/vla-20.c new file mode 100644 index 0000000000..831ed1b8cd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-20.c @@ -0,0 +1,12 @@ +/* Test use of sizeof with [*] in type name: should not refer to + zero-size array. PR 39582. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +void foo11d(int x[sizeof(int *[*])]); /* { dg-warning "not in a declaration" } */ + +/* Although the size is not constant, it may nevertheless appear in a + constant expression if not evaluated. */ + +void foo11e(int x[1 ? 0 : sizeof(int *[*])]); /* { dg-warning "not in a declaration" } */ +/* { dg-error "zero-size array" "correct zero size" { target *-*-* } .-1 } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-21.c b/SingleSource/Regression/C/gcc-dg/vla-21.c new file mode 100644 index 0000000000..a39ae0b426 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-21.c @@ -0,0 +1,7 @@ +/* Type names for VLAs should be allowed outside functions if the size + is not evaluated. PR 39581. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +int a; +int b = sizeof (int (*)[a]); diff --git a/SingleSource/Regression/C/gcc-dg/vla-22.c b/SingleSource/Regression/C/gcc-dg/vla-22.c new file mode 100644 index 0000000000..8025bae8f6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-22.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target alloca } */ + +extern void bar (int *); + +static inline __attribute__((always_inline)) +int +foo (int i) +{ + struct S { + int ar[1][i]; + } s; + + s.ar[0][0] = 0; + bar (&s.ar[0][0]); +} + +void +baz (int i) +{ + foo (i + 2); +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-23.c b/SingleSource/Regression/C/gcc-dg/vla-23.c new file mode 100644 index 0000000000..47be412330 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-23.c @@ -0,0 +1,17 @@ +/* PR rtl-optimization/50615 */ +/* Testcase by Zdenek Sojka */ + +/* { dg-do compile } */ +/* { dg-options "-O --param max-cse-insns=1" } */ + +int +foo (int a) +{ + if (!a) + return 1; + + { + int s[a]; + return 0; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-24.c b/SingleSource/Regression/C/gcc-dg/vla-24.c new file mode 100644 index 0000000000..8b7230584b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-24.c @@ -0,0 +1,32 @@ +/* PR middle-end/65958 */ + +/* { dg-do run } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-effective-target alloca } */ + +extern void abort (void); + +int foo (int n) +{ + char *p, *q; + + if (1) + { + char i[n]; + p = __builtin_alloca (8); + p[0] = 1; + } + + q = __builtin_alloca (64); + __builtin_memset (q, 0, 64); + + return !p[0]; +} + +int main (void) +{ + if (foo (48) != 0) + abort (); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-25.c b/SingleSource/Regression/C/gcc-dg/vla-25.c new file mode 100644 index 0000000000..f6041575a0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-25.c @@ -0,0 +1,9 @@ +/* Test [*] diagnosed on old-style parameter declaration. PR c/88704. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +void +f (x) + int x[*]; +{ /* { dg-error "not allowed in other than function prototype scope" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-26.c b/SingleSource/Regression/C/gcc-dg/vla-26.c new file mode 100644 index 0000000000..5d2fa3e280 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-26.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -O2" } */ + +void ed(int n, float s[3][n]) +{ + for (int i = 0; i < n; i++) + s[1][i]; +} + +void e(int n, float s[3][n]) +{ + ed(n, s); +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vla-3.c b/SingleSource/Regression/C/gcc-dg/vla-3.c new file mode 100644 index 0000000000..51dae42f7e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ +/* { dg-require-effective-target alloca } */ + +/* This used to crash as we did not preserve the correct type + for __SIZE_TYPE__. See PR22439. */ + +char foo(__SIZE_TYPE__ n) +{ + char c[1][n]; + return c[0][0]; +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-4.c b/SingleSource/Regression/C/gcc-dg/vla-4.c new file mode 100644 index 0000000000..c4a68fea9d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-4.c @@ -0,0 +1,49 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ +/* { dg-require-effective-target alloca } */ +/* PR c/18740 */ + +static int i; + +int foo(int n) +{ + int (*t)[n]; + i = 0; + int j = 0; + char b[1][n+3]; /* Variable length array. */ + int d[3][n]; /* Variable length array. */ + sizeof (b[i++ + sizeof(j++)]); /* Outer sizeof is evaluated for vla, but not the inner one. */ + if (i != 1 || j != 0) + return 1; + __typeof__(b[i++]) c1; /* typeof is evauluated when given a vm */ + if (i != 2) + return 1; + __typeof__(t + (i++,0)) c2; /* typeof is evauluated when given a vm */ + if (i != 3) + return 1; + __typeof__(i + (i++,0)) c3; /* typeof is not evauluated when not given a vm */ + if (i != 3) + return 1; + sizeof (d[i++]); /* sizeof is evaluated for vla. */ + if (i != 4) + return 1; + __alignof__(__typeof__(t + (i++,0))); /* typeof is not evauluated when given a vm inside alignof*/ + if (i != 4) + return 1; + sizeof(__typeof__(t + (i++,0))); /* typeof is not evauluated when given a vm inside sizeof*/ + if (i != 4) + return 1; + return 0; +} + +int foo6(int a, int b[a][a], int (*c)[sizeof(*b)]) { + return sizeof (*c); +} + +int main() { + int b[10][10]; + int (*c)[sizeof(int)*10]; + if (foo6(10, b, c) != 10*sizeof(int)*sizeof(int)) + return 1; + return foo(10); +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-5.c b/SingleSource/Regression/C/gcc-dg/vla-5.c new file mode 100644 index 0000000000..2c253b5075 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-5.c @@ -0,0 +1,24 @@ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +void foo1(int (*o)(int p[*])) { } + +void foo2(int o[*]); +void foo3(int o[4][*]); + +void foo4(int j, int a[j]); +void foo4(int, int a[*]); +void foo4(int, int a[]); +void foo4(int j, int a[j]) { +} + +int foo5(int a, int b[*][*], int c[static sizeof(*b)]); +int foo5(int a, int b[10][10], int c[400]) { + return sizeof (c); /* { dg-warning "on array function parameter" } */ +} + +int foo6(int a, int b[*][*], int c[static sizeof(*b)]); +int foo6(int a, int b[a][a], int c[sizeof(*b)]) { + return sizeof (c); /* { dg-warning "on array function parameter" } */ +} + +void foo7(__typeof__ (int (*)(int o[*])) i); diff --git a/SingleSource/Regression/C/gcc-dg/vla-6.c b/SingleSource/Regression/C/gcc-dg/vla-6.c new file mode 100644 index 0000000000..a7f5f05156 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-6.c @@ -0,0 +1,29 @@ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +int a[*]; /* { dg-error "not allowed in other than function prototype scope" } */ +void foo1() { int a[*]; } /* { dg-error "not allowed in other than function prototype scope" } */ +void foo2() { int a[*]; } /* { dg-error "not allowed in other than function prototype scope" } */ +int foo3(int i)[*]; /* { dg-error "not allowed in other than function prototype scope" } */ +void foo4(int o[*][4]) { } /* { dg-error "not allowed in other than function prototype scope" } */ +void foo5(int o[4][*]) { } /* { dg-error "not allowed in other than function prototype scope" } */ + +/* [*] can't be used in a type that's not a declaration (maybe, the + final wording for DR#341 would allow it although the first + discussed intent would not). */ +void foo11(int x[sizeof(int (*)[*])]); /* { dg-warning "not in a declaration" } */ +/* This case is allowed per DR#341. */ +void foo12(int [*]); + +extern int n; +int B[100]; +void foo10(int m) { + typedef int (*vla)[m]; + struct tag { + vla x; /* { dg-error "a member of a structure or union cannot have a variably modified type" } */ + /* PR c/7948 */ + int (*y)[n]; /* { dg-error "a member of a structure or union cannot have a variably modified type" } */ + int z[n]; /* { dg-error "a member of a structure or union cannot have a variably modified type" } */ + }; + /* PR c/25802 */ + extern int (*r)[m]; /* { dg-error "variably modified type must have no linkage" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-7.c b/SingleSource/Regression/C/gcc-dg/vla-7.c new file mode 100644 index 0000000000..e8c8cd455c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-7.c @@ -0,0 +1,3 @@ +/* { dg-options "-std=c99" } */ + +int (*foo)(int (*a)[*]); diff --git a/SingleSource/Regression/C/gcc-dg/vla-8.c b/SingleSource/Regression/C/gcc-dg/vla-8.c new file mode 100644 index 0000000000..fea2337cb0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-8.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ +/* Radar 4336222 */ + +int a; +struct s { void (*f)(int (*)[a]); }; + +static int i; +static int new_i() { i++; return i; } +static int bar1(int a[new_i()][new_i()]); + +void foo(int n) { + extern void bar(int i[n][n]); /* Since this isn't a VM type ensure we can have linkage. */ + extern int bar1(int a[new_i()][new_i()]); /* Since this isn't a VM type ensure we can have linkage. */ +} + +void foo1(int n) { + goto A; + void bar(int i[n][n]); /* Not a VM type, as VM arguments don't matter. */ + int bar1(int a[new_i()][new_i()]); /* Not a VM type, as VM arguments don't matter. */ + A: + ; +} + +void foo2(int n) { + goto A; /* { dg-error "jump into scope of identifier with variably modified type" } */ + int (*(*bar2)(void))[n]; + A: + ; +} + +/* Match extra informative notes. */ +/* { dg-message "note: label '\[^\n'\]*' defined here" "defined" { target *-*-* } 0 } */ +/* { dg-message "note: '\[^\n'\]*' declared here" "declared" { target *-*-* } 0 } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-9.c b/SingleSource/Regression/C/gcc-dg/vla-9.c new file mode 100644 index 0000000000..506a1a2eb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-9.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors -W -Wall" } */ +/* PR c/28280 */ + +void f(__SIZE_TYPE__ d) +{ + typedef int t[d]; + t *g = (__typeof (g)) d; + (void) g; +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-init-1.c b/SingleSource/Regression/C/gcc-dg/vla-init-1.c new file mode 100644 index 0000000000..3125b70345 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-init-1.c @@ -0,0 +1,13 @@ +/* Test for tree-checking error when initializing a variable-length array + (not allowed): constructor_max_index needs to be an INTEGER_CST. */ +/* Origin: Joseph Myers . */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int a; + +void +foo (void) +{ + int x[a] = { 1 }; /* { dg-error "variable-sized object may not be initialized" "VLA init" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-init-2.c b/SingleSource/Regression/C/gcc-dg/vla-init-2.c new file mode 100644 index 0000000000..f23630a365 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-init-2.c @@ -0,0 +1,9 @@ +/* Arrays of unknown size with element type a VLA type should not be + initialized (C99 isn't clear about whether such arrays are VLAs, + but this is the only reasonable interpretation). Bug 16409, first + testcase. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +const int i = 1; +void foo() { char a[][i] = {""}; } /* { dg-error "variable-sized object may not be initialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-init-3.c b/SingleSource/Regression/C/gcc-dg/vla-init-3.c new file mode 100644 index 0000000000..a854f1268e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-init-3.c @@ -0,0 +1,8 @@ +/* Arrays of unknown size with element type a VLA type should not be + initialized (C99 isn't clear about whether such arrays are VLAs, + but this is the only reasonable interpretation). Bug 16409, second + testcase. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo(int i) { char a[][i] = {""}; } /* { dg-error "variable-sized object may not be initialized" } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-init-4.c b/SingleSource/Regression/C/gcc-dg/vla-init-4.c new file mode 100644 index 0000000000..06351d04e0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-init-4.c @@ -0,0 +1,7 @@ +/* Test for ICE on VLA compound literal. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +const int i = 1; +void foo() { char *p = (char [i]){ "" }; } /* { dg-error "compound literal has variable size" } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-init-5.c b/SingleSource/Regression/C/gcc-dg/vla-init-5.c new file mode 100644 index 0000000000..aa9f4910ac --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-init-5.c @@ -0,0 +1,7 @@ +/* Test for ICE on incomplete-array-of-VLA compound literal. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +const int i = 1; +void foo() { void *p = (char [][i]){ "" }; } /* { dg-error "compound literal has variable size" } */ diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-1.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-1.c new file mode 100644 index 0000000000..baaad36eb1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-1.c @@ -0,0 +1,19 @@ +/* PR29970*/ +/* { dg-do run } */ +/* { dg-options "-Wall -O0" } */ +/* { dg-require-effective-target alloca } */ + +int foo(void) +{ + int n = 0; + return sizeof(*({ n = 10; struct foo { int x[n]; } x; &x; })); +} + + +int main() +{ + if (sizeof(struct foo { int x[10]; }) != foo()) + __builtin_abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-2.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-2.c new file mode 100644 index 0000000000..9f1512567f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-2.c @@ -0,0 +1,34 @@ +/* PR101838 */ +/* { dg-do run } */ +/* { dg-options "-Wpedantic -O0" } */ +/* { dg-require-effective-target alloca } */ + + +int bar0( + int (*a)[*], + int (*b)[sizeof(*a)] +); + + +int bar( + struct f { /* { dg-warning "will not be visible outside of this definition" } */ + int a[*]; } v, /* { dg-warning "variably modified type" } */ + int (*b)[sizeof(struct f)] // should not warn about zero size +); + +int foo(void) +{ + int n = 0; + return sizeof(typeof(*({ n = 10; struct foo { /* { dg-warning "braced-groups" } */ + int x[n]; /* { dg-warning "variably modified type" } */ + } x; &x; }))); +} + + +int main() +{ + if (sizeof(struct foo { int x[10]; }) != foo()) + __builtin_abort(); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-3.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-3.c new file mode 100644 index 0000000000..e663de1cd7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-3.c @@ -0,0 +1,11 @@ +/* PR91038 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + + +void bar(void) +{ + ({ int N = 2; int (*x)[9][N] = 0; x; })[1]; + ({ int N = 2; int (*x)[9][N] = 0; x; })[0]; // should not ice +} + diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-4.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-4.c new file mode 100644 index 0000000000..929768cd80 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-4.c @@ -0,0 +1,95 @@ +/* PR29970, PR91038 */ +/* { dg-do run } */ +/* { dg-options "-O0 -Wunused-variable" } */ +/* { dg-require-effective-target alloca } */ + +int foo3b(void) // should not return 0 +{ + int n = 0; + return sizeof *({ n = 10; int x[n]; &x; }); +} + +int foo4(void) // should not ICE +{ + return (*({ + int n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + x; + }))[12][1]; +} + +int foo5(void) // should return 1, returns 0 +{ + int n = 0; + return (*({ + n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + (*x)[0][1] = 0; + x; + }))[12][1]; +} + +int foo5c(void) // should return 400 +{ + int n = 0; + return sizeof(*({ + n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + (*x)[0][1] = 0; + x; + })); +} + +int foo5b(void) // should return 1, returns 0 +{ + int n = 0; /* { dg-warning "unused variable" } */ + return (*({ + int n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + (*x)[0][1] = 0; + x; + }))[12][1]; +} + +int foo5a(void) // should return 1, returns 0 +{ + return (*({ + int n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + (*x)[0][1] = 0; + x; + }))[12][1]; +} + + + + +int main() +{ + if (sizeof(int[10]) != foo3b()) + __builtin_abort(); + + if (1 != foo4()) + __builtin_abort(); + + if (400 != foo5c()) + __builtin_abort(); + + if (1 != foo5a()) + __builtin_abort(); + + if (1 != foo5b()) // -O0 + __builtin_abort(); + + if (1 != foo5()) + __builtin_abort(); + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-5.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-5.c new file mode 100644 index 0000000000..68614f2d6b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-5.c @@ -0,0 +1,31 @@ +/* PR29970 */ +/* { dg-do run } */ +/* { dg-options "-Wunused-variable" } */ +/* { dg-require-effective-target alloca } */ + + + + +int foo2a(void) // should not ICE +{ + return ({ int n = 20; struct { int x[n];} x; x.x[12] = 1; sizeof(x); }); +} + + +int foo2b(void) // should not ICE +{ + return sizeof *({ int n = 20; struct { int x[n];} x; x.x[12] = 1; &x; }); +} + +int main() +{ + if (sizeof(struct { int x[20]; }) != foo2a()) + __builtin_abort(); + + if (sizeof(struct { int x[20]; }) != foo2b()) + __builtin_abort(); + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-6.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-6.c new file mode 100644 index 0000000000..3d96d38898 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-6.c @@ -0,0 +1,94 @@ +/* PR29970, PR91038 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wunused-variable" } */ + +int foo3b(void) // should not return 0 +{ + int n = 0; + return sizeof *({ n = 10; int x[n]; &x; }); +} + +int foo4(void) // should not ICE +{ + return (*({ + int n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + x; + }))[12][1]; +} + +int foo5(void) // should return 1, returns 0 +{ + int n = 0; + return (*({ + n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + (*x)[0][1] = 0; + x; + }))[12][1]; +} + +int foo5c(void) // should return 400 +{ + int n = 0; + return sizeof(*({ + n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + (*x)[0][1] = 0; + x; + })); +} + +int foo5b(void) // should return 1, returns 0 +{ + int n = 0; /* { dg-warning "unused variable" } */ + return (*({ + int n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + (*x)[0][1] = 0; + x; + }))[12][1]; +} + +int foo5a(void) // should return 1, returns 0 +{ + return (*({ + int n = 20; + char (*x)[n][n] = __builtin_malloc(n * n); + (*x)[12][1] = 1; + (*x)[0][1] = 0; + x; + }))[12][1]; +} + + + + +int main() +{ + if (sizeof(int[10]) != foo3b()) + __builtin_abort(); + + if (1 != foo4()) + __builtin_abort(); + + if (400 != foo5c()) + __builtin_abort(); + + if (1 != foo5a()) + __builtin_abort(); + + if (1 != foo5b()) // -O0 + __builtin_abort(); + + if (1 != foo5()) + __builtin_abort(); + + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-7.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-7.c new file mode 100644 index 0000000000..3091b9184c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-7.c @@ -0,0 +1,44 @@ +/* PR91038 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wunused-variable" } */ + + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +struct lbm { + + int D; + const int* DQ; + +} D2Q9 = { 2, + (const int*)&(const int[9][2]){ + { 0, 0 }, + { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 }, + { 1, 1 }, { -1, 1 }, { -1, -1 }, { 1, -1 }, + } +}; + +void zouhe_left(void) +{ + __auto_type xx = (*({ int N = 2; struct lbm __x = D2Q9; ((const int(*)[9][N])__x.DQ); })); + + if (1 != xx[1][0]) + __builtin_abort(); + + if (2 != ARRAY_SIZE(xx[1])) + __builtin_abort(); + + if (1 != (*({ int N = 2; struct lbm __x = D2Q9; ((const int(*)[9][N])__x.DQ); }))[1][0]) + __builtin_abort(); + + if (2 != ARRAY_SIZE(*({ int N = 2; struct lbm __x = D2Q9; ((const int(*)[9][N])__x.DQ); })[1])) + __builtin_abort(); +} + +int main() +{ + zouhe_left(); + return 0; +} + + diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-8.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-8.c new file mode 100644 index 0000000000..5b475eb6cf --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-8.c @@ -0,0 +1,47 @@ +/* PR29970, PR91038 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wunused-variable" } */ + + +int foo0(void) +{ + int c = *(*(*({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }) + 5) + 5); + return c; +} + +int foo1(void) +{ + int c = *(5 + *(5 + *({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }))); + return c; +} + +int bar2(void) +{ + int c = (*({ int n = 10; struct { int y[n]; int z; }* x = __builtin_malloc(sizeof *x); x; })).z; + return c; +} + +int bar3(void) +{ + int n = 2; /* { dg-warning "unused variable" } */ + int c = (*({ int n = 3; /* { dg-warning "unused variable" } */ + ({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }); }))[5][5]; + return c; +} + +int bar3b(void) +{ + int n = 2; /* { dg-warning "unused variable" } */ + int c = (*({ int n = 3; /* { dg-warning "unused variable" } */ + ({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }); }))[0][0]; + return c; +} + +int bar4(void) +{ + int n = 2; /* { dg-warning "unused variable" } */ + int c = *(5 + *( 5 + *({ int n = 3; /* { dg-warning "unused variable" } */ + ({ int n = 10; int (*x)[n][n] = __builtin_malloc(sizeof *x); x; }); }))); + return c; +} + diff --git a/SingleSource/Regression/C/gcc-dg/vla-stexp-9.c b/SingleSource/Regression/C/gcc-dg/vla-stexp-9.c new file mode 100644 index 0000000000..3593a79078 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vla-stexp-9.c @@ -0,0 +1,53 @@ +/* PR91038 */ +/* { dg-do run } */ +/* { dg-options "-O2 -Wunused-variable" } */ + + + +void foo(void) +{ + if (2 * sizeof(int) != sizeof((*({ int N = 2; int (*x)[9][N] = 0; x; })[1]))) + __builtin_abort(); +} + +void bar(void) +{ + if (2 * sizeof(int) != sizeof((*({ int N = 2; int (*x)[9][N] = 0; x; })[0]))) + __builtin_abort(); +} + +void bar0(void) +{ + if (2 * 9 * sizeof(int) != sizeof((*({ int N = 2; int (*x)[9][N] = 0; x; })))) + __builtin_abort(); +} + +void bar11(void) +{ + sizeof(*((*({ int N = 2; int (*x)[9][N] = 0; x; }) + 0))); +} + +void bar12(void) +{ + if (2 * sizeof(int) != sizeof(*((*({ int N = 2; int (*x)[9][N] = 0; x; }) )))) + __builtin_abort(); +} + +void bar1(void) +{ + if (2 * sizeof(int) != sizeof(*((*({ int N = 2; int (*x)[9][N] = 0; x; }) + 0)))) + __builtin_abort(); +} + + + + +int main() +{ + foo(); + bar0(); + bar12(); + bar1(); + bar(); +} + diff --git a/SingleSource/Regression/C/gcc-dg/void-cast-1.c b/SingleSource/Regression/C/gcc-dg/void-cast-1.c new file mode 100644 index 0000000000..bd4e7b3bf7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/void-cast-1.c @@ -0,0 +1,11 @@ +/* Don't warn where the left-hand side of a comma expression is a + comma expression whose right-hand side is cast to void. Bug + 21159. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int a, b, c, d; +int e(void) { return (void)a, b; } +int f(void) { return (void)a, (void)b, c; } +int g(void) { return (void)a, (void)b, (void)c, d; } diff --git a/SingleSource/Regression/C/gcc-dg/void-cast-2.c b/SingleSource/Regression/C/gcc-dg/void-cast-2.c new file mode 100644 index 0000000000..7accebfb75 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/void-cast-2.c @@ -0,0 +1,8 @@ +/* Test further cases of warnings for comma expressions, with and + without casts to void. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ +int a, b, c, d; +int e(void) { return (char)a, b; } /* { dg-warning "left-hand operand of comma expression has no effect" } */ +int f(void) { return (a ? (void)b : (void)c), d; } /* { dg-warning "left-hand operand of comma expression has no effect" } */ diff --git a/SingleSource/Regression/C/gcc-dg/volatile-bitfields-1.c b/SingleSource/Regression/C/gcc-dg/volatile-bitfields-1.c new file mode 100644 index 0000000000..6adda27fea --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/volatile-bitfields-1.c @@ -0,0 +1,23 @@ +/* { dg-options "-fstrict-volatile-bitfields" } */ +/* { dg-do run } */ + +extern int puts(const char *); +extern void abort(void) __attribute__((noreturn)); + +typedef struct { + volatile unsigned short a:8, b:8; +} BitStruct; + +BitStruct bits = {1, 2}; + +void check(int i, int j) +{ + if (i != 1 || j != 2) puts("FAIL"), abort(); +} + +int main () +{ + check(bits.a, bits.b); + + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/volatile-bitfields-2.c b/SingleSource/Regression/C/gcc-dg/volatile-bitfields-2.c new file mode 100644 index 0000000000..a57cd74753 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/volatile-bitfields-2.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-fstrict-volatile-bitfields" } */ + +extern void abort(void); +struct thing { + volatile unsigned short a: 8; + volatile unsigned short b: 8; +} t = {1,2}; + +int main() +{ + t.a = 3; + if (t.a !=3 || t.b !=2) abort(); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/volatile1.c b/SingleSource/Regression/C/gcc-dg/volatile1.c new file mode 100644 index 0000000000..61a3979b70 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/volatile1.c @@ -0,0 +1,9 @@ +/* PR c/12553: we were erroneously setting TREE_SIDE_EFFECTS on &y, which + confused tree-ssa. */ + +void f() +{ + int x; + volatile int y; + &x == &y; +} diff --git a/SingleSource/Regression/C/gcc-dg/volatile2.c b/SingleSource/Regression/C/gcc-dg/volatile2.c new file mode 100644 index 0000000000..07f27947e5 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/volatile2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +struct GTeth_desc +{ + unsigned ed_cmdsts; +}; +struct GTeth_softc +{ + struct GTeth_desc txq_desc[32]; +}; + +void foo(struct GTeth_softc *sc) +{ + /* Verify that we retain the volatileness on the + store until after optimization. */ + volatile struct GTeth_desc *p = &sc->txq_desc[0]; + p->ed_cmdsts = 0; +} + +/* { dg-final { scan-tree-dump "{v}" "optimized" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/volatile3.c b/SingleSource/Regression/C/gcc-dg/volatile3.c new file mode 100644 index 0000000000..37394dd2e7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/volatile3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-ssa" } */ + +volatile int *q; +void foo(int i) +{ + volatile int a[2]; + volatile int *p = &a[i]; + q = p; +} + +/* { dg-final { scan-tree-dump-not "{v}" "ssa" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vrp-min-max-1.c b/SingleSource/Regression/C/gcc-dg/vrp-min-max-1.c new file mode 100644 index 0000000000..b9c8379c83 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vrp-min-max-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fdisable-tree-evrp -fdump-tree-mergephi2" } */ + +int bar (void); + +int foo1 (int x, int y) +{ + if (y < 10) return bar (); + if (x > 9) return bar (); + + return x < y ? x : y; +} + +int foo2 (int x, int y) +{ + if (y < 10) return bar (); + if (x > 9) return bar (); + + return x > y ? x : y; +} + +/* We expect to optimiz min/max in VRP*/ + +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "mergephi2" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "mergephi2" } } */ +/* { dg-final { scan-tree-dump-not "MIN_EXPR" "vrp1" } } */ +/* { dg-final { scan-tree-dump-not "MAX_EXPR" "vrp1" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vrp-min-max-2.c b/SingleSource/Regression/C/gcc-dg/vrp-min-max-2.c new file mode 100644 index 0000000000..3936088882 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vrp-min-max-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp2" } */ +/* { dg-require-effective-target int32plus } */ + +int Foo (int X) +{ + if (X < 0) + X = 0; + if (X > 191) + X = 191; + + return X << 23; +} + +/* We expect this min/max pair to survive. */ + +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "vrp2" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "vrp2" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vrp-min-max-3.c b/SingleSource/Regression/C/gcc-dg/vrp-min-max-3.c new file mode 100644 index 0000000000..1fffee7bbd --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vrp-min-max-3.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp -fdump-tree-fre1" } */ + +int bar (void); + +int foo1 (int x, int y) +{ + if (y < 10) return bar (); + if (x > 9) return bar (); + + return x < y ? x : y; +} + +int foo2 (int x, int y) +{ + if (y < 10) return bar (); + if (x > 9) return bar (); + + return x > y ? x : y; +} + +/* We expect to optimiz min/max in EVRP */ + +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "fre1" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "fre1" } } */ +/* { dg-final { scan-tree-dump-not "MIN_EXPR" "evrp" } } */ +/* { dg-final { scan-tree-dump-not "MAX_EXPR" "evrp" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/vrp-overflow-1.c b/SingleSource/Regression/C/gcc-dg/vrp-overflow-1.c new file mode 100644 index 0000000000..8e5794c77b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vrp-overflow-1.c @@ -0,0 +1,151 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-forwprop" } */ + +extern void __attribute__((noreturn)) unreachable (void); + +int fle22 (int a) +{ + unsigned i = a / 4; + unsigned j = i - 2; + + if (j == 7) /* A dynamic range excludes a value from j for the rest of f1. */ + return -1; + + if (i <= 2) /* This dynamic range cannot be combined or compared with that of j. */ + return 0; + + if (i <= j) /* And so we couldn't compute this result. */ + unreachable (); + + return 1; +} + +int fle32 (int a) +{ + unsigned i = a / 4; + unsigned j = i - 3; + + if (j == 7) /* A dynamic range excludes a value from j for the rest of f1. */ + return -1; + + if (i <= 2) /* This dynamic range cannot be combined or compared with that of j. */ + return 0; + + if (i <= j) /* And so we couldn't compute this result. */ + unreachable (); + + return 1; +} + +int flt22 (int a) +{ + unsigned i = a / 4; + unsigned j = i - 2; + + if (j == 7) + return -1; + + if (i <= 2) + return 0; + + if (i < j) + unreachable (); + + return 1; +} + +int flt32 (int a) +{ + unsigned i = a / 4; + unsigned j = i - 3; + + if (j == 7) + return -1; + + if (i <= 2) + return 0; + + if (i < j) + unreachable (); + + return 1; +} + +int fgt22 (int a) +{ + unsigned i = a / 4; + unsigned j = i + 2; + + if (j == -7) + return -1; + + if (i >= -3) + return 0; + + if (i > j) + unreachable (); + + return 1; +} + +int fgt32 (int a) +{ + unsigned i = a / 4; + unsigned j = i + 3; + + if (j == -7) + return -1; + + if (i >= -3) + return 0; + + if (i > j) + unreachable (); + + return 1; +} + +int fge22 (int a) +{ + unsigned i = a / 4; + unsigned j = i + 2; + + if (j == -7) + return -1; + + if (i >= -3) + return 0; + + if (i >= j) + unreachable (); + + return 1; +} + +int fge32 (int a) +{ + unsigned i = a / 4; + unsigned j = i + 3; + + if (j == -7) + return -1; + + if (i >= -3) + return 0; + + if (i >= j) + unreachable (); + + return 1; +} + +int main (int argc, char *argv[]) { + fle22 (argc); + fle32 (argc); + flt22 (argc); + flt32 (argc); + fgt22 (argc); + fgt32 (argc); + fge22 (argc); + fge32 (argc); +} diff --git a/SingleSource/Regression/C/gcc-dg/vshift-1.c b/SingleSource/Regression/C/gcc-dg/vshift-1.c new file mode 100644 index 0000000000..2220ad5a4f --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vshift-1.c @@ -0,0 +1,132 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +#include + +#define N 64 + +#ifndef TYPE1 +#define TYPE1 int +#define TYPE2 long long +#endif + +signed TYPE1 a[N], b[N], g[N]; +unsigned TYPE1 c[N], h[N]; +signed TYPE2 d[N], e[N], j[N]; +unsigned TYPE2 f[N], k[N]; + +__attribute__((noinline)) void +f1 (void) +{ + int i; + for (i = 0; i < N; i++) + g[i] = a[i] << b[i]; +} + +__attribute__((noinline)) void +f2 (void) +{ + int i; + for (i = 0; i < N; i++) + g[i] = a[i] >> b[i]; +} + +__attribute__((noinline)) void +f3 (void) +{ + int i; + for (i = 0; i < N; i++) + h[i] = c[i] >> b[i]; +} + +__attribute__((noinline)) void +f4 (void) +{ + int i; + for (i = 0; i < N; i++) + j[i] = d[i] << e[i]; +} + +__attribute__((noinline)) void +f5 (void) +{ + int i; + for (i = 0; i < N; i++) + j[i] = d[i] >> e[i]; +} + +__attribute__((noinline)) void +f6 (void) +{ + int i; + for (i = 0; i < N; i++) + k[i] = f[i] >> e[i]; +} + +__attribute__((noinline)) void +f7 (void) +{ + int i; + for (i = 0; i < N; i++) + j[i] = d[i] << b[i]; +} + +__attribute__((noinline)) void +f8 (void) +{ + int i; + for (i = 0; i < N; i++) + j[i] = d[i] >> b[i]; +} + +__attribute__((noinline)) void +f9 (void) +{ + int i; + for (i = 0; i < N; i++) + k[i] = f[i] >> b[i]; +} + +int +main () +{ + int i; + for (i = 0; i < N; i++) + { + asm (""); + c[i] = (rand () << 1) | (rand () & 1); + b[i] = (i * 85) & (sizeof (TYPE1) * __CHAR_BIT__ - 1); + a[i] = c[i]; + d[i] = (rand () << 1) | (rand () & 1); + d[i] |= (unsigned long long) c[i] << 32; + e[i] = (i * 85) & (sizeof (TYPE2) * __CHAR_BIT__ - 1); + f[i] = d[i]; + } + f1 (); + f3 (); + f4 (); + f6 (); + for (i = 0; i < N; i++) + if (g[i] != (signed TYPE1) (a[i] << b[i]) + || h[i] != (unsigned TYPE1) (c[i] >> b[i]) + || j[i] != (signed TYPE2) (d[i] << e[i]) + || k[i] != (unsigned TYPE2) (f[i] >> e[i])) + abort (); + f2 (); + f5 (); + f9 (); + for (i = 0; i < N; i++) + if (g[i] != (signed TYPE1) (a[i] >> b[i]) + || j[i] != (signed TYPE2) (d[i] >> e[i]) + || k[i] != (unsigned TYPE2) (f[i] >> b[i])) + abort (); + f7 (); + for (i = 0; i < N; i++) + if (j[i] != (signed TYPE2) (d[i] << b[i])) + abort (); + f8 (); + for (i = 0; i < N; i++) + if (j[i] != (signed TYPE2) (d[i] >> b[i])) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vshift-2.c b/SingleSource/Regression/C/gcc-dg/vshift-2.c new file mode 100644 index 0000000000..8f490d209d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vshift-2.c @@ -0,0 +1,7 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +#define TYPE1 char +#define TYPE2 short + +#include "vshift-1.c" diff --git a/SingleSource/Regression/C/gcc-dg/vshift-3.c b/SingleSource/Regression/C/gcc-dg/vshift-3.c new file mode 100644 index 0000000000..367e660655 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vshift-3.c @@ -0,0 +1,136 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +#include + +#define N 64 + +#ifndef TYPE1 +#define TYPE1 int +#define TYPE2 long long +#endif + +signed TYPE1 a[N], b, g[N]; +unsigned TYPE1 c[N], h[N]; +signed TYPE2 d[N], e, j[N]; +unsigned TYPE2 f[N], k[N]; + +#ifndef S +#define S(x) x +#endif + +__attribute__((noinline)) void +f1 (void) +{ + int i; + for (i = 0; i < N; i++) + g[i] = a[i] << S (b); +} + +__attribute__((noinline)) void +f2 (void) +{ + int i; + for (i = 0; i < N; i++) + g[i] = a[i] >> S (b); +} + +__attribute__((noinline)) void +f3 (void) +{ + int i; + for (i = 0; i < N; i++) + h[i] = c[i] >> S (b); +} + +__attribute__((noinline)) void +f4 (void) +{ + int i; + for (i = 0; i < N; i++) + j[i] = d[i] << S (e); +} + +__attribute__((noinline)) void +f5 (void) +{ + int i; + for (i = 0; i < N; i++) + j[i] = d[i] >> S (e); +} + +__attribute__((noinline)) void +f6 (void) +{ + int i; + for (i = 0; i < N; i++) + k[i] = f[i] >> S (e); +} + +__attribute__((noinline)) void +f7 (void) +{ + int i; + for (i = 0; i < N; i++) + j[i] = d[i] << S (b); +} + +__attribute__((noinline)) void +f8 (void) +{ + int i; + for (i = 0; i < N; i++) + j[i] = d[i] >> S (b); +} + +__attribute__((noinline)) void +f9 (void) +{ + int i; + for (i = 0; i < N; i++) + k[i] = f[i] >> S (b); +} + +int +main () +{ + int i; + b = 7; + e = 12; + for (i = 0; i < N; i++) + { + asm (""); + c[i] = (rand () << 1) | (rand () & 1); + a[i] = c[i]; + d[i] = (rand () << 1) | (rand () & 1); + d[i] |= (unsigned long long) c[i] << 32; + f[i] = d[i]; + } + f1 (); + f3 (); + f4 (); + f6 (); + for (i = 0; i < N; i++) + if (g[i] != (signed TYPE1) (a[i] << S (b)) + || h[i] != (unsigned TYPE1) (c[i] >> S (b)) + || j[i] != (signed TYPE2) (d[i] << S (e)) + || k[i] != (unsigned TYPE2) (f[i] >> S (e))) + abort (); + f2 (); + f5 (); + f9 (); + for (i = 0; i < N; i++) + if (g[i] != (signed TYPE1) (a[i] >> S (b)) + || j[i] != (signed TYPE2) (d[i] >> S (e)) + || k[i] != (unsigned TYPE2) (f[i] >> S (b))) + abort (); + f7 (); + for (i = 0; i < N; i++) + if (j[i] != (signed TYPE2) (d[i] << S (b))) + abort (); + f8 (); + for (i = 0; i < N; i++) + if (j[i] != (signed TYPE2) (d[i] >> S (b))) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vshift-4.c b/SingleSource/Regression/C/gcc-dg/vshift-4.c new file mode 100644 index 0000000000..c43fbcc196 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vshift-4.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +#define S(x) 3 + +#include "vshift-3.c" diff --git a/SingleSource/Regression/C/gcc-dg/vshift-5.c b/SingleSource/Regression/C/gcc-dg/vshift-5.c new file mode 100644 index 0000000000..62e6328cb2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vshift-5.c @@ -0,0 +1,125 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +extern void abort (void); +long long a[16]; + +__attribute__((noinline, noclone)) void +f1 (void) +{ + long long a0, a1, a2, a3; + a0 = a[0]; + a1 = a[1]; + a2 = a[2]; + a3 = a[3]; + a0 = a0 << 2; + a1 = a1 << 3; + a2 = a2 << 4; + a3 = a3 << 5; + a[0] = a0; + a[1] = a1; + a[2] = a2; + a[3] = a3; +} + +__attribute__((noinline, noclone)) void +f2 (void) +{ + long long a0, a1, a2, a3; + a0 = a[0]; + a1 = a[1]; + a2 = a[2]; + a3 = a[3]; + a0 = a0 << 2; + a1 = a1 << 2; + a2 = a2 << 2; + a3 = a3 << 2; + a[0] = a0; + a[1] = a1; + a[2] = a2; + a[3] = a3; +} + +__attribute__((noinline, noclone)) void +f2a (int x) +{ + long long a0, a1, a2, a3; + a0 = a[0]; + a1 = a[1]; + a2 = a[2]; + a3 = a[3]; + a0 = a0 << x; + a1 = a1 << 2; + a2 = a2 << 2; + a3 = a3 << 2; + a[0] = a0; + a[1] = a1; + a[2] = a2; + a[3] = a3; +} + +__attribute__((noinline, noclone)) void +f2b (int x) +{ + long long a0, a1, a2, a3; + a0 = a[0]; + a1 = a[1]; + a2 = a[2]; + a3 = a[3]; + a0 = a0 << 2; + a1 = a1 << 2; + a2 = a2 << x; + a3 = a3 << 2; + a[0] = a0; + a[1] = a1; + a[2] = a2; + a[3] = a3; +} + +__attribute__((noinline, noclone)) void +f3 (int x) +{ + long long a0, a1, a2, a3; + a0 = a[0]; + a1 = a[1]; + a2 = a[2]; + a3 = a[3]; + a0 = a0 << x; + a1 = a1 << x; + a2 = a2 << x; + a3 = a3 << x; + a[0] = a0; + a[1] = a1; + a[2] = a2; + a[3] = a3; +} + +int +main () +{ + a[0] = 4LL; + a[1] = 3LL; + a[2] = 2LL; + a[3] = 1LL; + f1 (); + if (a[0] != (4LL << 2) || a[1] != (3LL << 3) + || a[2] != (2LL << 4) || a[3] != (1LL << 5)) + abort (); + f2 (); + if (a[0] != (4LL << 4) || a[1] != (3LL << 5) + || a[2] != (2LL << 6) || a[3] != (1LL << 7)) + abort (); + f3 (3); + if (a[0] != (4LL << 7) || a[1] != (3LL << 8) + || a[2] != (2LL << 9) || a[3] != (1LL << 10)) + abort (); + f2a (3); + if (a[0] != (4LL << 10) || a[1] != (3LL << 10) + || a[2] != (2LL << 11) || a[3] != (1LL << 12)) + abort (); + f2b (3); + if (a[0] != (4LL << 12) || a[1] != (3LL << 12) + || a[2] != (2LL << 14) || a[3] != (1LL << 14)) + abort (); + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/vshift-6.c b/SingleSource/Regression/C/gcc-dg/vshift-6.c new file mode 100644 index 0000000000..6f7a0b05b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vshift-6.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-Wshift-count-negative -Wshift-count-overflow" } */ + +typedef unsigned int v1qi_t __attribute__((mode(QI), vector_size(1))); +typedef unsigned int v1hi_t __attribute__((mode(HI), vector_size(2))); +typedef unsigned int v1si_t __attribute__((mode(SI), vector_size(4))); + +v1qi_t test1qi(v1qi_t x, int c) { + switch(c) { + case 0: return x << -1; /* { dg-warning "shift count is negative" } */ + case 1: return x << 7; + case 2: return x << 8; /* { dg-warning "shift count >= width" } */ + case ~0: return x >> -1; /* { dg-warning "shift count is negative" } */ + case ~1: return x >> 7; + case ~2: return x >> 8; /* { dg-warning "shift count >= width" } */ + } + return c < 0 ? x >> -c : x << c; +} + +v1hi_t test1hi(v1hi_t x, int c) { + switch(c) { + case 0: return x << -1; /* { dg-warning "shift count is negative" } */ + case 1: return x << 15; + case 2: return x << 16; /* { dg-warning "shift count >= width" } */ + case ~0: return x >> -1; /* { dg-warning "shift count is negative" } */ + case ~1: return x >> 15; + case ~2: return x >> 16; /* { dg-warning "shift count >= width" } */ + } + return c < 0 ? x >> -c : x << c; +} + +v1si_t test1si(v1si_t x, int c) { + switch(c) { + case 0: return x << -1; /* { dg-warning "shift count is negative" } */ + case 1: return x << 31; + case 2: return x << 32; /* { dg-warning "shift count >= width" } */ + case ~0: return x >> -1; /* { dg-warning "shift count is negative" } */ + case ~1: return x >> 31; + case ~2: return x >> 32; /* { dg-warning "shift count >= width" } */ + } + return c < 0 ? x >> -c : x << c; +} diff --git a/SingleSource/Regression/C/gcc-dg/vshift-7.c b/SingleSource/Regression/C/gcc-dg/vshift-7.c new file mode 100644 index 0000000000..27321209de --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/vshift-7.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -Wshift-count-negative -Wshift-count-overflow" } */ + +typedef unsigned int v1qi_t __attribute__((mode(QI), vector_size(1))); +typedef unsigned int v1hi_t __attribute__((mode(HI), vector_size(2))); +typedef unsigned int v1si_t __attribute__((mode(SI), vector_size(4))); + +static const signed shift_neg = -1; +static const unsigned shift_qi = 8; +static const unsigned shift_hi = 16; +static const unsigned shift_si = 32; + +v1qi_t test1qi(v1qi_t x, int c) { + switch(c) { + case 0: return x << shift_neg; /* { dg-warning "shift count is negative" } */ + case 1: return x << (shift_qi - 1); + case 2: return x << shift_qi; /* { dg-warning "shift count >= width" } */ + case ~0: return x >> shift_neg; /* { dg-warning "shift count is negative" } */ + case ~1: return x >> (shift_qi - 1); + case ~2: return x >> shift_qi; /* { dg-warning "shift count >= width" } */ + } + return c < 0 ? x >> -c : x << c; +} + +v1hi_t test1hi(v1hi_t x, int c) { + switch(c) { + case 0: return x << shift_neg; /* { dg-warning "shift count is negative" } */ + case 1: return x << (shift_hi - 1); + case 2: return x << shift_hi; /* { dg-warning "shift count >= width" } */ + case ~0: return x >> shift_neg; /* { dg-warning "shift count is negative" } */ + case ~1: return x >> (shift_hi - 1); + case ~2: return x >> shift_hi; /* { dg-warning "shift count >= width" } */ + } + return c < 0 ? x >> -c : x << c; +} + +v1si_t test1si(v1si_t x, int c) { + switch(c) { + case 0: return x << shift_neg; /* { dg-warning "shift count is negative" } */ + case 1: return x << (shift_si - 1); + case 2: return x << shift_si; /* { dg-warning "shift count >= width" } */ + case ~0: return x >> shift_neg; /* { dg-warning "shift count is negative" } */ + case ~1: return x >> (shift_si - 1); + case ~2: return x >> shift_si; /* { dg-warning "shift count >= width" } */ + } + return c < 0 ? x >> -c : x << c; +} diff --git a/SingleSource/Regression/C/gcc-dg/warn-1.c b/SingleSource/Regression/C/gcc-dg/warn-1.c new file mode 100644 index 0000000000..6db4ae5cd6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-1.c @@ -0,0 +1,16 @@ +/* The compiler used to say passing arg 0 of, which is wrong. */ +/* Radar 3069179 */ + +/* { dg-options "-O3" } */ + +static void foo (p) + int p; +{ +} + +void bar (void) +{ + void *vp; + + foo (vp); /* { dg-bogus "passing argument 1 of" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/warn-abs-1.c b/SingleSource/Regression/C/gcc-dg/warn-abs-1.c new file mode 100644 index 0000000000..ccd61efbe1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-abs-1.c @@ -0,0 +1,66 @@ +/* { dg-do compile { target c99_runtime } } */ +/* { dg-options "-Wabsolute-value" } */ + +#include +#include +#include +#include + +void +tst_unsigned (unsigned *pu, unsigned long *pl, unsigned long long *pll, + uintmax_t *pm) +{ + *pu = abs (*pu); /* { dg-warning "taking the absolute value of unsigned type" } */ + *pl = labs (*pl); /* { dg-warning "taking the absolute value of unsigned type" } */ + *pll = llabs (*pll); /* { dg-warning "taking the absolute value of unsigned type" } */ + *pm = imaxabs (*pm); /* { dg-warning "taking the absolute value of unsigned type" } */ +} + +void +test_int_size (long long *pll) +{ + *pll = abs (*pll); /* { dg-warning "may cause truncation of value" } */ + *pll = abs ((int) *pll); +} + +void +tst_notint (float *pf, double *pd, _Complex double *pc) +{ + *pf = abs (*pf); /* { dg-warning "using integer absolute value function" } */ + *pd = labs (*pd); /* { dg-warning "using integer absolute value function" } */ + *pc = abs (*pc); /* { dg-warning "using integer absolute value function" } */ +} + +void +tst_notfloat (int *pi, long *pl, complex double *pc) +{ + *pi = fabsf (*pi); /* { dg-warning "using floating-point absolute value function" } */ + *pl = fabs (*pl); /* { dg-warning "using floating-point absolute value function" } */ + *pc = fabs (*pc); /* { dg-warning "using floating-point absolute value function" } */ +} + +void +tst_float_size (double *pd, long double *pld) +{ + *pd = fabsf (*pd); /* { dg-warning "may cause truncation of value" } */ + *pld = fabs (*pld); /* { dg-warning "may cause truncation of value" "fabs trunc" { target { large_long_double } } } */ + *pld = fabs ((double) *pld); +} + +void tst_notcomplex (int *pi, long *pl, long double *pld) +{ + *pi = cabs (*pi); /* { dg-warning "using complex absolute value function" } */ + *pl = cabs (*pl); /* { dg-warning "using complex absolute value function" } */ + *pld = cabsl (*pld);/* { dg-warning "using complex absolute value function" } */ +} + +void tst_cplx_size (complex double *pcd, complex long double *pcld) +{ + *pcd = cabsf (*pcd); /* { dg-warning "may cause truncation of value" } */ + *pcld = cabs (*pcld); /* { dg-warning "may cause truncation of value" "cabs trunc" { target { large_long_double } } } */ + *pcld = cabs ((complex double) *pcld); +} + + + + diff --git a/SingleSource/Regression/C/gcc-dg/warn-addr-cmp.c b/SingleSource/Regression/C/gcc-dg/warn-addr-cmp.c new file mode 100644 index 0000000000..07491d1bb9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-addr-cmp.c @@ -0,0 +1,79 @@ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ +/* { dg-options "-Waddress" } */ +/* Warning when addr convert to bool always gives known result. + Ada/Pascal programmers sometimes write 0-param functions without + (), and might as well warn on variables, too. */ + +int func (void); +extern int var; +int weak_func (void) __attribute__ ((weak)); +extern int weak_var __attribute__ ((weak)); + +int +test_func_cmp (void) +{ + if (func) /* { dg-warning "the address of 'func'" } */ + return 1; + if (!func) /* { dg-warning "the address of 'func'" } */ + return 1; + if (&var) /* { dg-warning "the address of 'var'" } */ + return 1; + if (!&var) /* { dg-warning "the address of 'var'" } */ + return 1; + if (weak_func) + return 1; + if (!weak_func) + return 1; + if (&weak_var) + return 1; + if (!&weak_var) + return 1; + return 0; +} + +/* Test equality with 0 on the right hand side. */ +int +test_func_cmp_rhs_zero (void) +{ + if (func == 0) /* { dg-warning "the comparison will always evaluate as 'false'" } */ + return 1; + if (func != 0) /* { dg-warning "the comparison will always evaluate as 'true'" } */ + return 1; + if (&var == 0) /* { dg-warning "the comparison will always evaluate as 'false'" } */ + return 1; + if (&var != 0) /* { dg-warning "the comparison will always evaluate as 'true'" } */ + return 1; + if (weak_func == 0) + return 1; + if (weak_func != 0) + return 1; + if (&weak_var == 0) + return 1; + if (&weak_var != 0) + return 1; + return 0; +} + +/* Test equality with 0 on the left hand side. */ +int +test_func_cmp_lhs_zero (void) +{ + if (0 == func) /* { dg-warning "the comparison will always evaluate as 'false'" } */ + return 1; + if (0 != func) /* { dg-warning "the comparison will always evaluate as 'true'" } */ + return 1; + if (0 == &var) /* { dg-warning "the comparison will always evaluate as 'false'" } */ + return 1; + if (0 != &var) /* { dg-warning "the comparison will always evaluate as 'true'" } */ + return 1; + if (0 == weak_func) + return 1; + if (0 != weak_func) + return 1; + if (0 == &weak_var) + return 1; + if (0 != &weak_var) + return 1; + return 0; +} diff --git a/SingleSource/Regression/C/gcc-dg/warn-nsstring.c b/SingleSource/Regression/C/gcc-dg/warn-nsstring.c new file mode 100644 index 0000000000..600ff34d93 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-nsstring.c @@ -0,0 +1,7 @@ +/* Check that the NSString format extension is rejected in c. */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ +extern void NSLog (void *fmt, ...) __attribute__((format(__NSString__, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */ +extern void NSLog1 (void *fmt, ...) __attribute__((format(NSString, 1, 2))); /* { dg-warning "is only allowed in Objective-C dialects" } */ + + diff --git a/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul-2.c b/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul-2.c new file mode 100644 index 0000000000..3372a8b99e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul-2.c @@ -0,0 +1,70 @@ +/* PR tree-optimization/87756 - missing unterminated argument warning + using address of a constant character + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +int sprintf (char*, const char*, ...); + +extern char* dest (void); +extern void sink (int, ...); + +#define D dest () +#define T(expr) sink (0, (expr)) + + +const char cnul = '\0'; +const char cnonul = 'a'; +const char str3[] = "123"; + +const struct +{ + char a, b, s[3]; +} s1 = { '\0', 'b', "123" }, + s2[2] = { + { '\0', 'c', "12" }, + { 'd', '\0', "123" } + }; + +void test_sprintf_s (void) +{ + T (sprintf (D, "%s", &cnul)); + T (sprintf (D, "%s", &cnonul)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.1s", &cnonul)); + T (sprintf (D, "%.2s", &cnonul)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%s", &s1.a)); + T (sprintf (D, "%s", &s1.b)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.1s", &s1.b)); + T (sprintf (D, "%.2s", &s1.b)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%s", s1.s)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.3s", s1.s)); + T (sprintf (D, "%.4s", s1.s)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%.2s", s1.s + 1)); + T (sprintf (D, "%.3s", s1.s + 1)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%s", &s2[0].a)); + T (sprintf (D, "%s", &s2[0].b)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.1s", &s2[0].b)); + T (sprintf (D, "%.2s", &s2[0].b)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%s", s2[0].s)); + T (sprintf (D, "%.3s", s2[0].s)); + T (sprintf (D, "%.4s", s2[0].s)); + + T (sprintf (D, "%.2s", s2[0].s + 1)); + T (sprintf (D, "%.3s", s2[0].s + 1)); + + T (sprintf (D, "%s", &s2[1].a)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.1s", &s2[1].a)); + T (sprintf (D, "%.2s", &s2[1].a)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%s", &s2[1].b)); + T (sprintf (D, "%s", s2[1].s)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.3s", s2[1].s)); + T (sprintf (D, "%.4s", s2[1].s)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%.2s", s2[1].s + 1)); + T (sprintf (D, "%.3s", s2[1].s + 1)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%s", &str3[3])); + T (sprintf (D, "%s", &str3[4])); /* { dg-warning "\\\[-Warray-bounds" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul-3.c b/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul-3.c new file mode 100644 index 0000000000..1cfbe62547 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul-3.c @@ -0,0 +1,71 @@ +/* PR tree-optimization/87756 - missing unterminated argument warning + using address of a constant character + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +typedef __WCHAR_TYPE__ wchar_t; + +int sprintf (char*, const char*, ...); + +extern char* dest (void); +extern void sink (int, ...); + +#define D dest () +#define T(expr) sink (0, (expr)) + +const wchar_t wnul = L'\0'; +const wchar_t wnonul = L'a'; +const wchar_t wcs3[] = L"123"; + +const struct +{ + wchar_t a, b, s[3]; +} w1 = { L'\0', L'b', L"123" }, + w2[2] = { + { L'\0', L'c', L"12" }, + { L'd', L'\0', L"123" } + }; + +void test_sprintf_ls (void) +{ + T (sprintf (D, "%ls", &wnul)); + T (sprintf (D, "%ls", &wnonul)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.1ls", &wnonul)); + T (sprintf (D, "%.2ls", &wnonul)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%ls", &w1.a)); + T (sprintf (D, "%ls", &w1.b)); /* { dg-warning "nul-terminated" "pr88211" { xfail *-*-* } } */ + T (sprintf (D, "%.1ls", &w1.b)); + T (sprintf (D, "%.2ls", &w1.b)); /* { dg-warning "nul-terminated" "pr88211" { xfail *-*-* } } */ + T (sprintf (D, "%ls", w1.s)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.3ls", w1.s)); + T (sprintf (D, "%.4ls", w1.s)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%.2ls", w1.s + 1)); + T (sprintf (D, "%.3ls", w1.s + 1)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%ls", &w2[0].a)); + T (sprintf (D, "%ls", &w2[0].b)); /* { dg-warning "nul-terminated" "pr88211" { xfail *-*-* } } */ + T (sprintf (D, "%.1ls", &w2[0].b)); + T (sprintf (D, "%.2ls", &w2[0].b)); /* { dg-warning "nul-terminated" "pr88211" { xfail *-*-* } } */ + T (sprintf (D, "%ls", w2[0].s)); + T (sprintf (D, "%.3ls", w2[0].s)); + T (sprintf (D, "%.4ls", w2[0].s)); + + T (sprintf (D, "%.2ls", w2[0].s + 1)); + T (sprintf (D, "%.3ls", w2[0].s + 1)); + + T (sprintf (D, "%ls", &w2[1].a)); /* { dg-warning "nul-terminated" "pr88211" { xfail *-*-* } } */ + T (sprintf (D, "%.1ls", &w2[1].a)); + T (sprintf (D, "%.2ls", &w2[1].a)); /* { dg-warning "nul-terminated" "pr88211" { xfail *-*-* } } */ + T (sprintf (D, "%ls", &w2[1].b)); + T (sprintf (D, "%ls", w2[1].s)); /* { dg-warning "nul-terminated" } */ + T (sprintf (D, "%.3ls", w2[1].s)); + T (sprintf (D, "%.4ls", w2[1].s)); /* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%.2ls", w2[1].s + 1)); + T (sprintf (D, "%.3ls", w2[1].s + 1));/* { dg-warning "nul-terminated" } */ + + T (sprintf (D, "%ls", &wcs3[3])); + T (sprintf (D, "%ls", &wcs3[4])); /* { dg-warning "\\\[-Warray-bounds" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul.c b/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul.c new file mode 100644 index 0000000000..a38679fa88 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-sprintf-no-nul.c @@ -0,0 +1,90 @@ +/* PR tree-optimization/86552 - missing warning for reading past the end + of non-string arrays + Exercise non-string detection in sprintf. + { dg-do compile } + { dg-options "-O2 -Wno-array-bounds -Wall -ftrack-macro-expansion=0" } */ + +#include "range.h" + +typedef __WCHAR_TYPE__ wchar_t; + +extern int sprintf (char*, const char*, ...); + +extern char *dst; + +int i0 = 0; +int i1 = 1; + +void sink (int, ...); + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT(a, b) + +#define T(fmt, ...) \ + sink (sprintf (dst, fmt, __VA_ARGS__)) + +const char a[5] = "12345"; /* { dg-message "declared here" } */ +const char b[6] = "123456"; /* { dg-message "declared here" } */ +const char a2[][3] = { + "", "1", "12", "123", "123\000" /* { dg-warning "initializer-string for array of 'char' is too long" } */ +}; + + +void test_narrow (void) +{ + /* Verify that precision suppresses the warning when it's less + than the size of the array. */ + T ("%.0s%.1s%.2s%.3s%.4s%.5s", a, a, a, a, a, a); + + T ("%s", a); /* { dg-warning ".%s. directive argument is not a nul-terminated string" } */ + T ("%.6s", a); /* { dg-warning ".%.6s. directive argument is not a nul-terminated string" } */ + + /* Exercise conditional expressions involving strings and non-strings. */ + const char *s0 = i0 < 0 ? a2[0] : a2[3]; + T ("%s", s0); /* { dg-warning ".%s. directive argument is not a nul-terminated string" } */ + s0 = i0 < 0 ? "123456" : a2[4]; + T ("%s", s0); /* { dg-warning ".%s. directive argument is not a nul-terminated string" } */ + + const char *s1 = i0 < 0 ? a2[3] : a2[0]; + T ("%s", s1); /* { dg-warning ".%s. directive argument is not a nul-terminated string" } */ + + const char *s2 = i0 < 0 ? a2[3] : a2[4]; + T ("%s", s2); /* { dg-warning ".%s. directive argument is not a nul-terminated string" } */ + + s0 = i0 < 0 ? a : b; + T ("%.5s", s0); + + /* Verify that the warning triggers even if precision prevents + reading past the end of one of the non-terminated arrays but + not the other. */ + T ("%.6s", s0); /* { dg-warning ".%.6s. directive argument is not a nul-terminated string" } */ + + s0 = i0 < 0 ? b : a; + T ("%.7s", s0); /* { dg-warning ".%.7s. directive argument is not a nul-terminated string" } */ + + /* Verify that at -Wformat-overflow=1 the lower bound of precision + given by a range is used to determine whether or not to warn. */ + int r = SR (4, 5); + + T ("%.*s", r, a); + T ("%.*s", r, b); + + r = SR (5, 6); + T ("%.*s", r, a); + T ("%.*s", r, b); + + r = SR (6, 7); + T ("%.*s", r, a); /* { dg-warning ".%.\\\*s. directive argument is not a nul-terminated string" } */ + T ("%.*s", r, b); +} + + +const wchar_t wa[5] = L"12345"; /* { dg-message "declared here" } */ + +void test_wide (void) +{ + T ("%.0ls%.1ls%.2ls%.3ls%.4ls%.5ls", wa, wa, wa, wa, wa, wa); + + T ("%ls", wa); /* { dg-warning ".%ls. directive argument is not a nul-terminated string" } */ + T ("%.6ls", wa); /* { dg-warning ".%.6ls. directive argument is not a nul-terminated string" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/warn-stpcpy-no-nul.c b/SingleSource/Regression/C/gcc-dg/warn-stpcpy-no-nul.c new file mode 100644 index 0000000000..e718010ec2 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-stpcpy-no-nul.c @@ -0,0 +1,324 @@ +/* PR tree-optimization/86552 - missing warning for reading past the end + of non-string arrays + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +extern char* stpcpy (char*, const char*); + +const char a[5] = "12345"; /* { dg-message "declared here" } */ + +int v0 = 0; +int v1 = 1; +int v2 = 1; +int v3 = 1; + +void sink (char*, ...); + +#define T(str) sink (stpcpy (d, str)) + +void test_one_dim_array (char *d) +{ + T (a); /* { dg-warning "argument missing terminating nul" } */ + T (&a[0]); /* { dg-warning "nul" } */ + T (&a[0] + 1); /* { dg-warning "nul" } */ + T (&a[1]); /* { dg-warning "nul" } */ + + int i0 = 0; + int i1 = i0 + 1; + + T (&a[i0]); /* { dg-warning "nul" } */ + T (&a[i0] + 1); /* { dg-warning "nul" } */ + T (&a[i1]); /* { dg-warning "nul" } */ + + T (&a[v0]); /* { dg-warning "nul" } */ + T (&a[v0] + 1); /* { dg-warning "nul" } */ + T (&a[v0] + v1); /* { dg-warning "nul" } */ +} + +const char b[][5] = { /* { dg-message "declared here" } */ + "12", "123", "1234", "54321" +}; + +void test_two_dim_array (char *d) +{ + int i0 = 0; + int i1 = i0 + 1; + int i2 = i1 + 1; + int i3 = i2 + 1; + + T (b[0]); + T (b[1]); + T (b[2]); + T (b[3]); /* { dg-warning "nul" } */ + T (b[i0]); + T (b[i1]); + T (b[i2]); + T (b[i3]); /* { dg-warning "nul" } */ + T (b[v0]); + T (b[v3]); + + T (&b[2][1]); + T (&b[2][1] + 1); + T (&b[2][v0]); + T (&b[2][1] + v0); + + T (&b[i2][i1]); + T (&b[i2][i1] + i1); + T (&b[i2][v0]); + T (&b[i2][i1] + v0); + + T (&b[3][1]); /* { dg-warning "nul" } */ + T (&b[3][1] + 1); /* { dg-warning "nul" } */ + T (&b[3][v0]); /* { dg-warning "nul" } */ + T (&b[3][1] + v0); /* { dg-warning "nul" } */ + T (&b[3][v0] + v1); /* { dg-warning "nul" } */ + + T (&b[i3][i1]); /* { dg-warning "nul" } */ + T (&b[i3][i1] + i1); /* { dg-warning "nul" } */ + T (&b[i3][v0]); /* { dg-warning "nul" } */ + T (&b[i3][i1] + v0); /* { dg-warning "nul" } */ + T (&b[i3][v0] + v1); /* { dg-warning "nul" } */ + + T (v0 ? "" : b[0]); + T (v0 ? "" : b[1]); + T (v0 ? "" : b[2]); + T (v0 ? "" : b[3]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? b[0] : ""); + T (v0 ? b[1] : ""); + T (v0 ? b[2] : ""); + T (v0 ? b[3] : ""); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + + T (v0 ? "1234" : b[3]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? b[3] : "1234"); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + + T (v0 ? a : b[3]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? b[0] : b[2]); + T (v0 ? b[2] : b[3]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? b[3] : b[2]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + + T (v0 ? b[0] : &b[3][0] + 1); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? b[1] : &b[3][1] + v0); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + + /* It's possible to detect the missing nul in the following two + expressions but GCC doesn't do it yet. */ + T (v0 ? &b[3][1] + v0 : b[2]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? &b[3][v0] : &b[3][v1]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ +} + +struct A { char a[5], b[5]; }; + +const struct A s = { "1234", "12345" }; + +void test_struct_member (char *d) +{ + int i0 = 0; + int i1 = i0 + 1; + + T (s.a); + T (&s.a[0]); + T (&s.a[0] + 1); + T (&s.a[0] + i0); + T (&s.a[1]); + T (&s.a[1] + 1); + T (&s.a[1] + i0); + + T (&s.a[i0]); + T (&s.a[i0] + 1); + T (&s.a[i0] + v0); + T (&s.a[i1]); + T (&s.a[i1] + 1); + T (&s.a[i1] + v0); + + T (s.a); + T (&s.a[0]); + T (&s.a[0] + 1); + T (&s.a[0] + v0); + T (&s.a[1]); + T (&s.a[1] + 1); + T (&s.a[1] + v0); + + T (&s.a[i0]); + T (&s.a[i0] + 1); + T (&s.a[i0] + v0); + T (&s.a[i1]); + T (&s.a[i1] + 1); + T (&s.a[i1] + v0); + + T (&s.a[v0]); + T (&s.a[v0] + 1); + T (&s.a[v0] + v0); + T (&s.a[v1]); + T (&s.a[v1] + 1); + T (&s.a[v1] + v0); + + T (s.b); /* { dg-warning "nul" } */ + T (&s.b[0]); /* { dg-warning "nul" } */ + T (&s.b[0] + 1); /* { dg-warning "nul" } */ + T (&s.b[0] + i0); /* { dg-warning "nul" } */ + T (&s.b[1]); /* { dg-warning "nul" } */ + T (&s.b[1] + 1); /* { dg-warning "nul" } */ + T (&s.b[1] + i0); /* { dg-warning "nul" } */ + + T (s.b); /* { dg-warning "nul" } */ + T (&s.b[0]); /* { dg-warning "nul" } */ + T (&s.b[0] + 1); /* { dg-warning "nul" } */ + T (&s.b[0] + v0); /* { dg-warning "nul" } */ + T (&s.b[1]); /* { dg-warning "nul" } */ + T (&s.b[1] + 1); /* { dg-warning "nul" } */ + T (&s.b[1] + v0); /* { dg-warning "nul" } */ + + T (s.b); /* { dg-warning "nul" } */ + T (&s.b[v0]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v0] + 1); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v0] + v0); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v1]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v1] + 1); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v1] + v0); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ +} + +struct B { struct A a[2]; }; + +const struct B ba[] = { + { { { "123", "12345" }, { "12345", "123" } } }, + { { { "12345", "123" }, { "123", "12345" } } }, + { { { "1", "12" }, { "123", "1234" } } }, + { { { "123", "1234" }, { "12345", "12" } } } +}; + +void test_array_of_structs (char *d) +{ + T (ba[0].a[0].a); + T (&ba[0].a[0].a[0]); + T (&ba[0].a[0].a[0] + 1); + T (&ba[0].a[0].a[0] + v0); + T (&ba[0].a[0].a[1]); + T (&ba[0].a[0].a[1] + 1); + T (&ba[0].a[0].a[1] + v0); + + T (ba[0].a[0].b); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[0]); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[0] + 1); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[0] + v0); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[1]); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[1] + 1); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[1] + v0); /* { dg-warning "nul" } */ + + T (ba[0].a[1].a); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[0]); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[0] + 1); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[0] + v0); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[1]); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[1] + 1); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[1] + v0); /* { dg-warning "nul" } */ + + T (ba[0].a[1].b); + T (&ba[0].a[1].b[0]); + T (&ba[0].a[1].b[0] + 1); + T (&ba[0].a[1].b[0] + v0); + T (&ba[0].a[1].b[1]); + T (&ba[0].a[1].b[1] + 1); + T (&ba[0].a[1].b[1] + v0); + + + T (ba[1].a[0].a); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[0]); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[0] + 1); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[0] + v0); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[1]); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[1] + 1); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[1] + v0); /* { dg-warning "nul" } */ + + T (ba[1].a[0].b); + T (&ba[1].a[0].b[0]); + T (&ba[1].a[0].b[0] + 1); + T (&ba[1].a[0].b[0] + v0); + T (&ba[1].a[0].b[1]); + T (&ba[1].a[0].b[1] + 1); + T (&ba[1].a[0].b[1] + v0); + + T (ba[1].a[1].a); + T (&ba[1].a[1].a[0]); + T (&ba[1].a[1].a[0] + 1); + T (&ba[1].a[1].a[0] + v0); + T (&ba[1].a[1].a[1]); + T (&ba[1].a[1].a[1] + 1); + T (&ba[1].a[1].a[1] + v0); + + T (ba[1].a[1].b); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[0]); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[0] + 1); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[0] + v0); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[1]); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[1] + 1); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[1] + v0); /* { dg-warning "nul" } */ + + + T (ba[2].a[0].a); + T (&ba[2].a[0].a[0]); + T (&ba[2].a[0].a[0] + 1); + T (&ba[2].a[0].a[0] + v0); + T (&ba[2].a[0].a[1]); + T (&ba[2].a[0].a[1] + 1); + T (&ba[2].a[0].a[1] + v0); + + T (ba[2].a[0].b); + T (&ba[2].a[0].b[0]); + T (&ba[2].a[0].b[0] + 1); + T (&ba[2].a[0].b[0] + v0); + T (&ba[2].a[0].b[1]); + T (&ba[2].a[0].b[1] + 1); + T (&ba[2].a[0].b[1] + v0); + + T (ba[2].a[1].a); + T (&ba[2].a[1].a[0]); + T (&ba[2].a[1].a[0] + 1); + T (&ba[2].a[1].a[0] + v0); + T (&ba[2].a[1].a[1]); + T (&ba[2].a[1].a[1] + 1); + T (&ba[2].a[1].a[1] + v0); + + + T (ba[3].a[0].a); + T (&ba[3].a[0].a[0]); + T (&ba[3].a[0].a[0] + 1); + T (&ba[3].a[0].a[0] + v0); + T (&ba[3].a[0].a[1]); + T (&ba[3].a[0].a[1] + 1); + T (&ba[3].a[0].a[1] + v0); + + T (ba[3].a[0].b); + T (&ba[3].a[0].b[0]); + T (&ba[3].a[0].b[0] + 1); + T (&ba[3].a[0].b[0] + v0); + T (&ba[3].a[0].b[1]); + T (&ba[3].a[0].b[1] + 1); + T (&ba[3].a[0].b[1] + v0); + + T (ba[3].a[1].a); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[0]); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[0] + 1); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[0] + v0); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[1]); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[1] + 1); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[1] + v0); /* { dg-warning "nul" } */ + + T (ba[3].a[1].b); + T (&ba[3].a[1].b[0]); + T (&ba[3].a[1].b[0] + 1); + T (&ba[3].a[1].b[0] + v0); + T (&ba[3].a[1].b[1]); + T (&ba[3].a[1].b[1] + 1); + T (&ba[3].a[1].b[1] + v0); + + + T (v0 ? ba[0].a[0].a : ba[0].a[0].b); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? ba[0].a[0].a : ba[0].a[0].b); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + + T (v0 ? &ba[0].a[0].a[0] : &ba[3].a[1].a[0]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? &ba[3].a[1].a[1] : ba[0].a[0].a); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + + T (v0 ? ba[0].a[0].a : ba[0].a[1].b); + T (v0 ? ba[0].a[1].b : ba[0].a[0].a); +} + +/* { dg-prune-output " reading \[1-9\]\[0-9\]? bytes from a region " } */ diff --git a/SingleSource/Regression/C/gcc-dg/warn-strcpy-no-nul.c b/SingleSource/Regression/C/gcc-dg/warn-strcpy-no-nul.c new file mode 100644 index 0000000000..b5ed21dc19 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-strcpy-no-nul.c @@ -0,0 +1,324 @@ +/* PR tree-optimization/86552 - missing warning for reading past the end + of non-string arrays + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds -ftrack-macro-expansion=0" } */ + +extern char* strcpy (char*, const char*); + +const char a[5] = "12345"; /* { dg-message "declared here" } */ + +int v0 = 0; +int v1 = 1; +int v2 = 1; +int v3 = 1; + +void sink (char*, ...); + +#define T(str) sink (strcpy (d, str)) + +void test_one_dim_array (char *d) +{ + T (a); /* { dg-warning "argument missing terminating nul" } */ + T (&a[0]); /* { dg-warning "nul" } */ + T (&a[0] + 1); /* { dg-warning "nul" } */ + T (&a[1]); /* { dg-warning "nul" } */ + + int i0 = 0; + int i1 = i0 + 1; + + T (&a[i0]); /* { dg-warning "nul" } */ + T (&a[i0] + 1); /* { dg-warning "nul" } */ + T (&a[i1]); /* { dg-warning "nul" } */ + + T (&a[v0]); /* { dg-warning "nul" } */ + T (&a[v0] + 1); /* { dg-warning "nul" } */ + T (&a[v0] + v1); /* { dg-warning "nul" } */ +} + +const char b[][5] = { /* { dg-message "declared here" } */ + "12", "123", "1234", "54321" +}; + +void test_two_dim_array (char *d) +{ + int i0 = 0; + int i1 = i0 + 1; + int i2 = i1 + 1; + int i3 = i2 + 1; + + T (b[0]); + T (b[1]); + T (b[2]); + T (b[3]); /* { dg-warning "nul" } */ + T (b[i0]); + T (b[i1]); + T (b[i2]); + T (b[i3]); /* { dg-warning "nul" } */ + T (b[v0]); + T (b[v3]); + + T (&b[2][1]); + T (&b[2][1] + 1); + T (&b[2][v0]); + T (&b[2][1] + v0); + + T (&b[i2][i1]); + T (&b[i2][i1] + i1); + T (&b[i2][v0]); + T (&b[i2][i1] + v0); + + T (&b[3][1]); /* { dg-warning "nul" } */ + T (&b[3][1] + 1); /* { dg-warning "nul" } */ + T (&b[3][v0]); /* { dg-warning "nul" } */ + T (&b[3][1] + v0); /* { dg-warning "nul" } */ + T (&b[3][v0] + v1); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + + T (&b[i3][i1]); /* { dg-warning "nul" } */ + T (&b[i3][i1] + i1); /* { dg-warning "nul" } */ + T (&b[i3][v0]); /* { dg-warning "nul" } */ + T (&b[i3][i1] + v0); /* { dg-warning "nul" } */ + T (&b[i3][v0] + v1); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + + T (v0 ? "" : b[0]); + T (v0 ? "" : b[1]); + T (v0 ? "" : b[2]); + T (v0 ? "" : b[3]); /* { dg-warning "nul" } */ + T (v0 ? b[0] : ""); + T (v0 ? b[1] : ""); + T (v0 ? b[2] : ""); + T (v0 ? b[3] : ""); /* { dg-warning "nul" } */ + + T (v0 ? "1234" : b[3]); /* { dg-warning "nul" } */ + T (v0 ? b[3] : "1234"); /* { dg-warning "nul" } */ + + T (v0 ? a : b[3]); /* { dg-warning "nul" } */ + T (v0 ? b[0] : b[2]); + T (v0 ? b[2] : b[3]); /* { dg-warning "nul" } */ + T (v0 ? b[3] : b[2]); /* { dg-warning "nul" } */ + + T (v0 ? b[0] : &b[3][0] + 1); /* { dg-warning "nul" } */ + T (v0 ? b[1] : &b[3][1] + v0); /* { dg-warning "nul" } */ + + /* It's possible to detect the missing nul in the following + expression but GCC doesn't do it yet. */ + T (v0 ? &b[3][1] + v0 : b[2]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (v0 ? &b[3][v0] : &b[3][v1]); /* { dg-warning "nul" } */ +} + +struct A { char a[5], b[5]; }; + +const struct A s = { "1234", "12345" }; + +void test_struct_member (char *d) +{ + int i0 = 0; + int i1 = i0 + 1; + + T (s.a); + T (&s.a[0]); + T (&s.a[0] + 1); + T (&s.a[0] + i0); + T (&s.a[1]); + T (&s.a[1] + 1); + T (&s.a[1] + i0); + + T (&s.a[i0]); + T (&s.a[i0] + 1); + T (&s.a[i0] + v0); + T (&s.a[i1]); + T (&s.a[i1] + 1); + T (&s.a[i1] + v0); + + T (s.a); + T (&s.a[0]); + T (&s.a[0] + 1); + T (&s.a[0] + v0); + T (&s.a[1]); + T (&s.a[1] + 1); + T (&s.a[1] + v0); + + T (&s.a[i0]); + T (&s.a[i0] + 1); + T (&s.a[i0] + v0); + T (&s.a[i1]); + T (&s.a[i1] + 1); + T (&s.a[i1] + v0); + + T (&s.a[v0]); + T (&s.a[v0] + 1); + T (&s.a[v0] + v0); + T (&s.a[v1]); + T (&s.a[v1] + 1); + T (&s.a[v1] + v0); + + T (s.b); /* { dg-warning "nul" } */ + T (&s.b[0]); /* { dg-warning "nul" } */ + T (&s.b[0] + 1); /* { dg-warning "nul" } */ + T (&s.b[0] + i0); /* { dg-warning "nul" } */ + T (&s.b[1]); /* { dg-warning "nul" } */ + T (&s.b[1] + 1); /* { dg-warning "nul" } */ + T (&s.b[1] + i0); /* { dg-warning "nul" } */ + + T (s.b); /* { dg-warning "nul" } */ + T (&s.b[0]); /* { dg-warning "nul" } */ + T (&s.b[0] + 1); /* { dg-warning "nul" } */ + T (&s.b[0] + v0); /* { dg-warning "nul" } */ + T (&s.b[1]); /* { dg-warning "nul" } */ + T (&s.b[1] + 1); /* { dg-warning "nul" } */ + T (&s.b[1] + v0); /* { dg-warning "nul" } */ + + T (s.b); /* { dg-warning "nul" } */ + T (&s.b[v0]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v0] + 1); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v0] + v0); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v1]); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v1] + 1); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ + T (&s.b[v1] + v0); /* { dg-warning "nul" "bug ???" { xfail *-*-* } } */ +} + +struct B { struct A a[2]; }; + +const struct B ba[] = { + { { { "123", "12345" }, { "12345", "123" } } }, + { { { "12345", "123" }, { "123", "12345" } } }, + { { { "1", "12" }, { "123", "1234" } } }, + { { { "123", "1234" }, { "12345", "12" } } } +}; + +void test_array_of_structs (char *d) +{ + T (ba[0].a[0].a); + T (&ba[0].a[0].a[0]); + T (&ba[0].a[0].a[0] + 1); + T (&ba[0].a[0].a[0] + v0); + T (&ba[0].a[0].a[1]); + T (&ba[0].a[0].a[1] + 1); + T (&ba[0].a[0].a[1] + v0); + + T (ba[0].a[0].b); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[0]); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[0] + 1); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[0] + v0); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[1]); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[1] + 1); /* { dg-warning "nul" } */ + T (&ba[0].a[0].b[1] + v0); /* { dg-warning "nul" } */ + + T (ba[0].a[1].a); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[0]); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[0] + 1); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[0] + v0); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[1]); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[1] + 1); /* { dg-warning "nul" } */ + T (&ba[0].a[1].a[1] + v0); /* { dg-warning "nul" } */ + + T (ba[0].a[1].b); + T (&ba[0].a[1].b[0]); + T (&ba[0].a[1].b[0] + 1); + T (&ba[0].a[1].b[0] + v0); + T (&ba[0].a[1].b[1]); + T (&ba[0].a[1].b[1] + 1); + T (&ba[0].a[1].b[1] + v0); + + + T (ba[1].a[0].a); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[0]); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[0] + 1); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[0] + v0); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[1]); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[1] + 1); /* { dg-warning "nul" } */ + T (&ba[1].a[0].a[1] + v0); /* { dg-warning "nul" } */ + + T (ba[1].a[0].b); + T (&ba[1].a[0].b[0]); + T (&ba[1].a[0].b[0] + 1); + T (&ba[1].a[0].b[0] + v0); + T (&ba[1].a[0].b[1]); + T (&ba[1].a[0].b[1] + 1); + T (&ba[1].a[0].b[1] + v0); + + T (ba[1].a[1].a); + T (&ba[1].a[1].a[0]); + T (&ba[1].a[1].a[0] + 1); + T (&ba[1].a[1].a[0] + v0); + T (&ba[1].a[1].a[1]); + T (&ba[1].a[1].a[1] + 1); + T (&ba[1].a[1].a[1] + v0); + + T (ba[1].a[1].b); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[0]); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[0] + 1); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[0] + v0); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[1]); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[1] + 1); /* { dg-warning "nul" } */ + T (&ba[1].a[1].b[1] + v0); /* { dg-warning "nul" } */ + + + T (ba[2].a[0].a); + T (&ba[2].a[0].a[0]); + T (&ba[2].a[0].a[0] + 1); + T (&ba[2].a[0].a[0] + v0); + T (&ba[2].a[0].a[1]); + T (&ba[2].a[0].a[1] + 1); + T (&ba[2].a[0].a[1] + v0); + + T (ba[2].a[0].b); + T (&ba[2].a[0].b[0]); + T (&ba[2].a[0].b[0] + 1); + T (&ba[2].a[0].b[0] + v0); + T (&ba[2].a[0].b[1]); + T (&ba[2].a[0].b[1] + 1); + T (&ba[2].a[0].b[1] + v0); + + T (ba[2].a[1].a); + T (&ba[2].a[1].a[0]); + T (&ba[2].a[1].a[0] + 1); + T (&ba[2].a[1].a[0] + v0); + T (&ba[2].a[1].a[1]); + T (&ba[2].a[1].a[1] + 1); + T (&ba[2].a[1].a[1] + v0); + + + T (ba[3].a[0].a); + T (&ba[3].a[0].a[0]); + T (&ba[3].a[0].a[0] + 1); + T (&ba[3].a[0].a[0] + v0); + T (&ba[3].a[0].a[1]); + T (&ba[3].a[0].a[1] + 1); + T (&ba[3].a[0].a[1] + v0); + + T (ba[3].a[0].b); + T (&ba[3].a[0].b[0]); + T (&ba[3].a[0].b[0] + 1); + T (&ba[3].a[0].b[0] + v0); + T (&ba[3].a[0].b[1]); + T (&ba[3].a[0].b[1] + 1); + T (&ba[3].a[0].b[1] + v0); + + T (ba[3].a[1].a); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[0]); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[0] + 1); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[0] + v0); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[1]); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[1] + 1); /* { dg-warning "nul" } */ + T (&ba[3].a[1].a[1] + v0); /* { dg-warning "nul" } */ + + T (ba[3].a[1].b); + T (&ba[3].a[1].b[0]); + T (&ba[3].a[1].b[0] + 1); + T (&ba[3].a[1].b[0] + v0); + T (&ba[3].a[1].b[1]); + T (&ba[3].a[1].b[1] + 1); + T (&ba[3].a[1].b[1] + v0); + + + T (v0 ? ba[0].a[0].a : ba[0].a[0].b); /* { dg-warning "nul" "bug ???" } */ + T (v0 ? ba[0].a[0].a : ba[0].a[0].b); /* { dg-warning "nul" "bug ???" } */ + + T (v0 ? &ba[0].a[0].a[0] : &ba[3].a[1].a[0]); /* { dg-warning "nul" "bug ???" } */ + T (v0 ? &ba[3].a[1].a[1] : ba[0].a[0].a); /* { dg-warning "nul" "bug ???" } */ + + T (v0 ? ba[0].a[0].a : ba[0].a[1].b); + T (v0 ? ba[0].a[1].b : ba[0].a[0].a); +} + +/* { dg-prune-output " reading \[1-9\]\[0-9\]? bytes from a region " } */ diff --git a/SingleSource/Regression/C/gcc-dg/warn-strlen-no-nul.c b/SingleSource/Regression/C/gcc-dg/warn-strlen-no-nul.c new file mode 100644 index 0000000000..b716aa4477 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-strlen-no-nul.c @@ -0,0 +1,304 @@ +/* PR tree-optimization/86552 - missing warning for reading past the end + of non-string arrays + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +extern __SIZE_TYPE__ strlen (const char*); + +const char a[5] = "12345"; /* { dg-message "declared here" } */ + +int v0 = 0; +int v1 = 1; +volatile int v2; + +void sink (int, ...); + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT(a, b) + +#define T(str) \ + __attribute__ ((noipa)) \ + void CAT (test_, __LINE__) (void) { \ + int i0 = 0, i1 = i0 + 1, i2 = i1 + 1, i3 = i2 + 1; \ + sink (strlen (str), i0, i1, i2, i3); \ + } typedef void dummy_type + +T (a); /* { dg-warning "argument missing terminating nul" } */ +T (&a[0]); /* { dg-warning "nul" } */ +T (&a[0] + 1); /* { dg-warning "nul" } */ +T (&a[1]); /* { dg-warning "nul" } */ +T (&a[v0]); /* { dg-warning "nul" } */ +T (&a[v0] + 1); /* { dg-warning "nul" } */ + + +const char b[][5] = { /* { dg-message "declared here" } */ + "12", "123", "1234", "54321" +}; + +T (b[0]); +T (b[1]); +T (b[2]); +T (b[3]); /* { dg-warning "nul" } */ + +T (b[i0]); +T (b[i1]); +T (b[i2]); +T (b[i3]); /* { dg-warning "nul" } */ + +T (b[v0]); + +T (&b[i2][i1]); +T (&b[i2][i1] + i1); +T (&b[i2][v0]); +T (&b[i2][i1] + v0); + +T (&b[2][1]); +T (&b[2][1] + i1); +T (&b[2][i0]); +T (&b[2][1] + i0); + +T (&b[2][1]); +T (&b[2][1] + v0); +T (&b[2][v0]); + +T (&b[3][1]); /* { dg-warning "nul" } */ +T (&b[3][1] + 1); /* { dg-warning "nul" } */ +T (&b[3][1] + i1); /* { dg-warning "nul" } */ +T (&b[3][v0]); /* { dg-warning "nul" } */ +T (&b[3][1] + v0); /* { dg-warning "nul" } */ +T (&b[3][v0] + v1); /* { dg-warning "nul" } */ + +T (&b[i3][i1]); /* { dg-warning "nul" } */ +T (&b[i3][i1] + 1); /* { dg-warning "nul" } */ +T (&b[i3][i1] + i1); /* { dg-warning "nul" } */ +T (&b[i3][v0]); /* { dg-warning "nul" } */ +T (&b[i3][i1] + v0); /* { dg-warning "nul" } */ +T (&b[i3][v0] + v1); /* { dg-warning "nul" } */ + +T (v0 ? "" : b[0]); +T (v0 ? "" : b[1]); +T (v0 ? "" : b[2]); +T (v0 ? "" : b[3]); /* { dg-warning "nul" } */ +T (v0 ? b[0] : ""); +T (v0 ? b[1] : ""); +T (v0 ? b[2] : ""); +T (v0 ? b[3] : ""); /* { dg-warning "nul" } */ + +T (v0 ? "" : b[i0]); +T (v0 ? "" : b[i1]); +T (v0 ? "" : b[i2]); +/* The following is diagnosed but the warning location is wrong + (the PRE pass loses it). */ +T (v0 ? "" : b[i3]); /* { dg-warning "nul" } */ +T (v0 ? b[i0] : ""); +T (v0 ? b[i1] : ""); +T (v0 ? b[i2] : ""); +T (v0 ? b[i3] : ""); /* { dg-warning "nul" } */ + +T (v0 ? "1234" : b[3]); /* { dg-warning "nul" } */ +T (v0 ? "1234" : b[i3]); /* { dg-warning "nul" } */ +T (v0 ? b[3] : "1234"); /* { dg-warning "nul" } */ +T (v0 ? b[i3] : "1234"); /* { dg-warning "nul" } */ + +T (v0 ? a : b[3]); /* { dg-warning "nul" } */ +T (v0 ? b[0] : b[2]); +T (v0 ? b[2] : b[3]); /* { dg-warning "nul" } */ +T (v0 ? b[3] : b[2]); /* { dg-warning "nul" } */ + +T (v0 ? a : b[i3]); /* { dg-warning "nul" } */ +T (v0 ? b[i0] : b[i2]); +T (v0 ? b[i2] : b[i3]); /* { dg-warning "nul" } */ +T (v0 ? b[i3] : b[i2]); /* { dg-warning "nul" } */ + +T (v0 ? b[0] : &b[3][0] + 1); /* { dg-warning "nul" } */ +T (v0 ? b[0] : &b[3][0] + i1); /* { dg-warning "nul" } */ +T (v0 ? b[1] : &b[3][1] + v0); /* { dg-warning "nul" } */ + +T (v0 ? b[i0] : &b[i3][i0] + i1); /* { dg-warning "nul" } */ +T (v0 ? b[i0] : &b[i3][i0] + i1); /* { dg-warning "nul" } */ +T (v0 ? b[i1] : &b[i3][i1] + v0); /* { dg-warning "nul" } */ + +T (v0 ? &b[3][1] + v0 : b[2]); /* { dg-warning "nul" } */ +T (v0 ? &b[3][v0] : &b[3][v1]); /* { dg-warning "nul" } */ + + +struct A { char a[5], b[5]; }; + +const struct A s = { "1234", "12345" }; + +T (s.a); +T (&s.a[0]); +T (&s.a[0] + 1); +T (&s.a[0] + v0); +T (&s.a[1]); +T (&s.a[1] + 1); +T (&s.a[1] + v0); + +T (&s.a[i0]); +T (&s.a[i0] + i1); +T (&s.a[i0] + v0); +T (&s.a[i1]); +T (&s.a[i1] + i1); +T (&s.a[i1] + v0); + +T (s.b); /* { dg-warning "nul" } */ +T (&s.b[0]); /* { dg-warning "nul" } */ +T (&s.b[0] + 1); /* { dg-warning "nul" } */ +T (&s.b[0] + v0); /* { dg-warning "nul" } */ +T (&s.b[1]); /* { dg-warning "nul" } */ +T (&s.b[1] + 1); /* { dg-warning "nul" } */ +T (&s.b[1] + i0); /* { dg-warning "nul" } */ +T (&s.b[1] + v0); /* { dg-warning "nul" } */ + +T (&s.b[i0]); /* { dg-warning "nul" } */ +T (&s.b[i0] + i1); /* { dg-warning "nul" } */ +T (&s.b[i0] + v0); /* { dg-warning "nul" } */ +T (&s.b[i1]); /* { dg-warning "nul" } */ +T (&s.b[i1] + i1); /* { dg-warning "nul" } */ +T (&s.b[i1] + v0); /* { dg-warning "nul" } */ + +struct B { struct A a[2]; }; + +const struct B ba[] = { + { { { "123", "12345" }, { "12345", "123" } } }, + { { { "12345", "123" }, { "123", "12345" } } }, + { { { "1", "12" }, { "123", "1234" } } }, + { { { "123", "1234" }, { "12345", "12" } } } +}; + +T (ba[0].a[0].a); +T (&ba[0].a[0].a[0]); +T (&ba[0].a[0].a[0] + 1); +T (&ba[0].a[0].a[0] + v0); +T (&ba[0].a[0].a[1]); +T (&ba[0].a[0].a[1] + 1); +T (&ba[0].a[0].a[1] + v0); + +T (ba[0].a[0].b); /* { dg-warning "nul" } */ +T (&ba[0].a[0].b[0]); /* { dg-warning "nul" } */ +T (&ba[0].a[0].b[0] + 1); /* { dg-warning "nul" } */ +T (&ba[0].a[0].b[0] + v0); /* { dg-warning "nul" } */ +T (&ba[0].a[0].b[1]); /* { dg-warning "nul" } */ +T (&ba[0].a[0].b[1] + 1); /* { dg-warning "nul" } */ +T (&ba[0].a[0].b[1] + v0); /* { dg-warning "nul" } */ + +T (ba[0].a[1].a); /* { dg-warning "nul" } */ +T (&ba[0].a[1].a[0]); /* { dg-warning "nul" } */ +T (&ba[0].a[1].a[0] + 1); /* { dg-warning "nul" } */ +T (&ba[0].a[1].a[0] + v0); /* { dg-warning "nul" } */ +T (&ba[0].a[1].a[1]); /* { dg-warning "nul" } */ +T (&ba[0].a[1].a[1] + 1); /* { dg-warning "nul" } */ +T (&ba[0].a[1].a[1] + v0); /* { dg-warning "nul" } */ + +T (ba[0].a[1].b); +T (&ba[0].a[1].b[0]); +T (&ba[0].a[1].b[0] + 1); +T (&ba[0].a[1].b[0] + v0); +T (&ba[0].a[1].b[1]); +T (&ba[0].a[1].b[1] + 1); +T (&ba[0].a[1].b[1] + v0); + + +T (ba[1].a[0].a); /* { dg-warning "nul" } */ +T (&ba[1].a[0].a[0]); /* { dg-warning "nul" } */ +T (&ba[1].a[0].a[0] + 1); /* { dg-warning "nul" } */ +T (&ba[1].a[0].a[0] + v0); /* { dg-warning "nul" } */ +T (&ba[1].a[0].a[1]); /* { dg-warning "nul" } */ +T (&ba[1].a[0].a[1] + 1); /* { dg-warning "nul" } */ +T (&ba[1].a[0].a[1] + v0); /* { dg-warning "nul" } */ + +T (ba[1].a[0].b); +T (&ba[1].a[0].b[0]); +T (&ba[1].a[0].b[0] + 1); +T (&ba[1].a[0].b[0] + v0); +T (&ba[1].a[0].b[1]); +T (&ba[1].a[0].b[1] + 1); +T (&ba[1].a[0].b[1] + v0); + +T (ba[1].a[1].a); +T (&ba[1].a[1].a[0]); +T (&ba[1].a[1].a[0] + 1); +T (&ba[1].a[1].a[0] + v0); +T (&ba[1].a[1].a[1]); +T (&ba[1].a[1].a[1] + 1); +T (&ba[1].a[1].a[1] + v0); + +T (ba[1].a[1].b); /* { dg-warning "nul" } */ +T (&ba[1].a[1].b[0]); /* { dg-warning "nul" } */ +T (&ba[1].a[1].b[0] + 1); /* { dg-warning "nul" } */ +T (&ba[1].a[1].b[0] + v0); /* { dg-warning "nul" } */ +T (&ba[1].a[1].b[1]); /* { dg-warning "nul" } */ +T (&ba[1].a[1].b[1] + 1); /* { dg-warning "nul" } */ +T (&ba[1].a[1].b[1] + v0); /* { dg-warning "nul" } */ + + +T (ba[2].a[0].a); +T (&ba[2].a[0].a[0]); +T (&ba[2].a[0].a[0] + 1); +T (&ba[2].a[0].a[0] + v0); +T (&ba[2].a[0].a[1]); +T (&ba[2].a[0].a[1] + 1); +T (&ba[2].a[0].a[1] + v0); + +T (ba[2].a[0].b); +T (&ba[2].a[0].b[0]); +T (&ba[2].a[0].b[0] + 1); +T (&ba[2].a[0].b[0] + v0); +T (&ba[2].a[0].b[1]); +T (&ba[2].a[0].b[1] + 1); +T (&ba[2].a[0].b[1] + v0); + +T (ba[2].a[1].a); +T (&ba[2].a[1].a[0]); +T (&ba[2].a[1].a[0] + 1); +T (&ba[2].a[1].a[0] + v0); +T (&ba[2].a[1].a[1]); +T (&ba[2].a[1].a[1] + 1); +T (&ba[2].a[1].a[1] + v0); + + +T (ba[3].a[0].a); +T (&ba[3].a[0].a[0]); +T (&ba[3].a[0].a[0] + 1); +T (&ba[3].a[0].a[0] + v0); +T (&ba[3].a[0].a[1]); +T (&ba[3].a[0].a[1] + 1); +T (&ba[3].a[0].a[1] + v0); + +T (ba[3].a[0].b); +T (&ba[3].a[0].b[0]); +T (&ba[3].a[0].b[0] + 1); +T (&ba[3].a[0].b[0] + v0); +T (&ba[3].a[0].b[1]); +T (&ba[3].a[0].b[1] + 1); +T (&ba[3].a[0].b[1] + v0); + +T (ba[3].a[1].a); /* { dg-warning "nul" } */ +T (&ba[3].a[1].a[0]); /* { dg-warning "nul" } */ +T (&ba[3].a[1].a[0] + 1); /* { dg-warning "nul" } */ +T (&ba[3].a[1].a[0] + v0); /* { dg-warning "nul" } */ +T (&ba[3].a[1].a[1]); /* { dg-warning "nul" } */ +T (&ba[3].a[1].a[1] + 1); /* { dg-warning "nul" } */ +T (&ba[3].a[1].a[1] + v0); /* { dg-warning "nul" } */ + +T (ba[3].a[1].b); +T (&ba[3].a[1].b[0]); +T (&ba[3].a[1].b[0] + 1); +T (&ba[3].a[1].b[0] + v0); +T (&ba[3].a[1].b[1]); +T (&ba[3].a[1].b[1] + 1); +T (&ba[3].a[1].b[1] + v0); + + +T (v0 ? ba[0].a[0].a : ba[0].a[0].b); /* { dg-warning "nul" } */ +T (v0 ? ba[0].a[0].a : ba[0].a[0].b); /* { dg-warning "nul" } */ + +T (v0 ? &ba[0].a[0].a[0] : &ba[3].a[1].a[0]); /* { dg-warning "nul" } */ +T (v0 ? &ba[3].a[1].a[1] : ba[0].a[0].a); /* { dg-warning "nul" } */ + +T (v0 ? ba[0].a[0].a : ba[0].a[1].b); +T (v0 ? ba[0].a[1].b : ba[0].a[0].a); + +T (v2 ? b[1] : &b[3][1] + v2); /* { dg-warning "nul" } */ +T (v2 ? &b[3][1] + v2 : b[2]); /* { dg-warning "nul" } */ +T (v2 ? &b[3][v2] : &b[2][v2]); /* { dg-warning "nul" } */ diff --git a/SingleSource/Regression/C/gcc-dg/warn-strnlen-no-nul-2.c b/SingleSource/Regression/C/gcc-dg/warn-strnlen-no-nul-2.c new file mode 100644 index 0000000000..76180a3f5d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-strnlen-no-nul-2.c @@ -0,0 +1,72 @@ +/* Verify that calls to strnlen with an unterminated array and + an excessive non-constant bound are diagnosed. + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#include "range.h" + +extern size_t strnlen (const char*, size_t); + +const char a[5] = "12345"; /* { dg-message "declared here" } */ +enum { asz = sizeof a }; + +int v0 = 0; +int v1 = 1; + +void sink (int, ...); + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT(a, b) + +#define T(str, n) \ + __attribute__ ((noipa)) \ + void CAT (test_, __LINE__) (void) { \ + int i0 = 0, i1 = i0 + 1, i2 = i1 + 1, i3 = i2 + 1; \ + sink (strnlen (str, n), i0, i1, i2, i3); \ + } typedef void dummy_type + + +T (a, UR (asz, -1)); +T (a, UR (asz - 1, -1)); +T (a, UR (asz - 2, -1)); +T (a, UR (asz - 5, -1)); +T (&a[0], UR (asz, -1)); +T (&a[0] + 1, UR (asz, asz + 1)); /* { dg-warning "specified bound \\\[5, 6] exceeds the size 4 of unterminated array" } */ +T (&a[1], UR (asz, 6)); /* { dg-warning "specified bound \\\[5, 6] exceeds the size 4 of unterminated array" } */ +T (&a[1], UR (asz - 1, 7)); +T (&a[v0], UR (asz, 8)); /* { dg-warning "specified bound \\\[5, 8] may exceed the size of at most 5 of unterminated array" } */ +T (&a[v0] + 1, UR (asz, 9)); /* { dg-warning "specified bound \\\[5, 9] may exceed the size of at most 5 of unterminated array" } */ + +T (a, UR (asz + 1, asz + 2)); /* { dg-warning "specified bound \\\[6, 7] exceeds the size 5 " } */ +T (&a[0], UR (asz + 1, 10)); /* { dg-warning "unterminated" } */ +T (&a[0] + 1, UR (asz - 1, 11)); +T (&a[0] + 1, UR (asz + 1, 12)); /* { dg-warning "unterminated" } */ +T (&a[1], UR (asz + 1, 13)); /* { dg-warning "unterminated" } */ +T (&a[v0], UR (asz + 1, 14)); /* { dg-warning "unterminated" } */ +T (&a[v0] + 1, UR (asz + 1, 15)); /* { dg-warning "unterminated" } */ + +T (&a[v0] + 1, UR (DIFF_MAX, SIZE_MAX)); /* { dg-warning "unterminated" } */ + +T (&a[v0] + 1, UR (DIFF_MAX + (size_t)1, SIZE_MAX)); /* { dg-warning "specified bound \\\[\[0-9\]+, \[0-9\]+] exceeds maximum object size " } */ + + +const char c[4] = "1234"; + +void test (int n0) +{ + char a[] = "123"; + + if (n0 < 4) + n0 = 4; + int n1 = __builtin_strlen (a); + + int n = n0 < n1 ? n1 : n0; + + /* N is at least 4 and c[4] is out-of-bounds. This could trigger + either -Warray-bounds or -Wstringop-overread. -Warray-bounds + only diagnoses past-the-end accesses by modifying functions + (in gimple-ssa-warn-restrict.c) and even for those, either + -Wstringop-overflow or -Wstringop-overread would be more + appropriate. */ + sink (strnlen (c + n, n + 1)); /* { dg-warning "specified bound \\\[5, \[0-9\]+] exceeds the size of at most 4 of unterminated array" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/warn-strnlen-no-nul.c b/SingleSource/Regression/C/gcc-dg/warn-strnlen-no-nul.c new file mode 100644 index 0000000000..70f6a432b9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/warn-strnlen-no-nul.c @@ -0,0 +1,362 @@ +/* PR tree-optimization/86552 - missing warning for reading past the end + of non-string arrays + { dg-do compile } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +typedef __SIZE_TYPE__ size_t; +extern size_t strnlen (const char*, size_t); + +const char a[5] = "12345"; /* { dg-message "declared here" } */ +enum { asz = sizeof a }; + +int v0 = 0; +int v1 = 1; + +void sink (int, ...); + +#define CONCAT(a, b) a ## b +#define CAT(a, b) CONCAT(a, b) + +#define T(str, n) \ + __attribute__ ((noipa)) \ + void CAT (test_, __LINE__) (void) { \ + int i0 = 0, i1 = i0 + 1, i2 = i1 + 1, i3 = i2 + 1; \ + sink (strnlen (str, n), i0, i1, i2, i3); \ + } typedef void dummy_type + +T (a, asz); +T (a, asz - 1); +T (a, asz - 2); +T (a, asz - 5); +T (&a[0], asz); +T (&a[0] + 1, asz); /* { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" } */ +T (&a[1], asz); /* { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" } */ +T (&a[1], asz - 1); +T (&a[v0], asz); /* { dg-warning "specified bound 5 may exceed the size of at most 5 of unterminated array" } */ +T (&a[v0] + 1, asz); /* { dg-warning "specified bound 5 may exceed the size of at most 5 of unterminated array" } */ + +T (a, asz + 1); /* { dg-warning "specified bound 6 exceeds the size 5 of unterminated array" } */ +T (&a[0], asz + 1); /* { dg-warning "unterminated" } */ +T (&a[0] + 1, asz - 1); +T (&a[0] + 1, asz + 1); /* { dg-warning "unterminated" } */ +T (&a[1], asz + 1); /* { dg-warning "unterminated" } */ +T (&a[v0], asz + 1); /* { dg-warning "unterminated" } */ +T (&a[v0] + 1, asz + 1); /* { dg-warning "unterminated" } */ + + +const char b[][5] = { /* { dg-message "declared here" } */ + "12", "123", "1234", "54321" +}; +enum { bsz = sizeof b[0] }; + +T (b[0], bsz); +T (b[1], bsz); +T (b[2], bsz); +T (b[3], bsz); + +T (b[0], bsz - 1); +T (b[1], bsz - 1); +T (b[2], bsz - 1); +T (b[3], bsz - 1); + +T (b[0], bsz + 1); +T (b[1], bsz + 1); +T (b[2], bsz + 1); +T (b[3], bsz + 1); /* { dg-warning "unterminated" } */ + +T (b[i0], bsz); +T (b[i1], bsz); +T (b[i2], bsz); +T (b[i3], bsz); + +T (b[i0], bsz + 1); +T (b[i1], bsz + 1); +T (b[i2], bsz + 1); +T (b[i3], bsz + 1); /* { dg-warning "unterminated" } */ + +T (b[v0], bsz); +T (b[v0], bsz + 1); + +T (&b[i2][i1], bsz); +T (&b[i2][i1] + i1, bsz); +T (&b[i2][v0], bsz); +T (&b[i2][i1] + v0, bsz); + +T (&b[i2][i1], bsz + 1); +T (&b[i2][i1] + i1, bsz + 1); +T (&b[i2][v0], bsz + 1); +T (&b[i2][i1] + v0, bsz + 1); + +T (&b[2][1], bsz); +T (&b[2][1] + i1, bsz); +T (&b[2][i0], bsz); +T (&b[2][1] + i0, bsz); +T (&b[2][1] + v0, bsz); +T (&b[2][v0], bsz); + +T (&b[2][1], bsz + 1); +T (&b[2][1] + i1, bsz + 1); +T (&b[2][i0], bsz + 1); +T (&b[2][1] + i0, bsz + 1); +T (&b[2][1] + v0, bsz + 1); +T (&b[2][v0], bsz + 1); + +T (&b[3][1], bsz); /* { dg-warning "unterminated" } */ +T (&b[3][1], bsz - 1); +T (&b[3][1] + 1, bsz); /* { dg-warning "unterminated" } */ +T (&b[3][1] + 1, bsz - 1); /* { dg-warning "unterminated" } */ +T (&b[3][1] + 1, bsz - 2); +T (&b[3][1] + i1, bsz); /* { dg-warning "unterminated" } */ +T (&b[3][1] + i1, bsz - i1); /* { dg-warning "unterminated" } */ +T (&b[3][1] + i1, bsz - i2); +T (&b[3][v0], bsz); +T (&b[3][1] + v0, bsz); /* { dg-warning "specified bound 5 exceeds the size of at most 4 of unterminated array" } */ +T (&b[3][v0] + v1, bsz); /* { dg-warning "specified bound 5 may exceed the size of at most 4 of unterminated array" "pr?????" { xfail *-*-* } } */ + +T (&b[3][1], bsz + 1); /* { dg-warning "unterminated" } */ +T (&b[3][1] + 1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&b[3][1] + i1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&b[3][v0], bsz + 1); /* { dg-warning "unterminated" "pr86936" { xfail *-*-* } } */ +T (&b[3][1] + v0, bsz + 1); /* { dg-warning "unterminated" } */ +T (&b[3][v0] + v1, bsz + 1); /* { dg-warning "unterminated" "pr86936" { xfail *-*-* } } */ + +T (&b[i3][i1], bsz); /* { dg-warning "unterminated" } */ +T (&b[i3][i1] + 1, bsz); /* { dg-warning "unterminated" } */ +T (&b[i3][i1] + i1, bsz); /* { dg-warning "specified bound 5 exceeds the size 3 of unterminated array" } */ +T (&b[i3][v0], bsz); +T (&b[i3][i1] + v0, bsz); /* { dg-warning "specified bound 5 exceeds the size of at most 4 of unterminated array" } */ +T (&b[i3][v0] + v1, bsz); + +T (&b[i3][i1], bsz + 1); /* { dg-warning "unterminated" } */ +T (&b[i3][i1] + 1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&b[i3][i1] + i1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&b[i3][v0], bsz + 1); /* { dg-warning "unterminated" "pr86919" { xfail *-*-* } } */ +T (&b[i3][i1] + v0, bsz + 1); /* { dg-warning "unterminated" } */ +T (&b[i3][v0] + v1, bsz + 1); /* { dg-warning "unterminated" "pr86919" { xfail *-*-* } } */ + +T (v0 ? "" : b[0], bsz); +T (v0 ? "" : b[1], bsz); +T (v0 ? "" : b[2], bsz); +T (v0 ? "" : b[3], bsz); +T (v0 ? b[0] : "", bsz); +T (v0 ? b[1] : "", bsz); +T (v0 ? b[2] : "", bsz); +T (v0 ? b[3] : "", bsz); + +/* Warning for the calls below would be strictly correct even though + the strnlen calls are safe because the reads are bounded by + the length of the constant arguments. Most of the calls are + not diagnosed anymore as a result of the fix for PR 103215. */ +T (v0 ? "" : b[0], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */ +T (v0 ? "" : b[1], bsz + 1); +T (v0 ? "" : b[2], bsz + 1); +T (v0 ? "" : b[3], bsz + 1); +T (v0 ? b[0] : "", bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" } */ +T (v0 ? b[1] : "", bsz + 1); +T (v0 ? b[2] : "", bsz + 1); +T (v0 ? b[3] : "", bsz + 1); + +T (v0 ? "" : b[i0], bsz); +T (v0 ? "" : b[i1], bsz); +T (v0 ? "" : b[i2], bsz); +T (v0 ? "" : b[i3], bsz); +T (v0 ? b[i0] : "", bsz); +T (v0 ? b[i1] : "", bsz); +T (v0 ? b[i2] : "", bsz); +T (v0 ? b[i3] : "", bsz); + +T (v0 ? "" : b[i0], bsz + 1); +T (v0 ? "" : b[i1], bsz + 1); +T (v0 ? "" : b[i2], bsz + 1); +T (v0 ? "" : b[i3], bsz + 1); +T (v0 ? b[i0] : "", bsz + 1); +T (v0 ? b[i1] : "", bsz + 1); +T (v0 ? b[i2] : "", bsz + 1); +T (v0 ? b[i3] : "", bsz + 1); + +T (v0 ? "1234" : b[3], bsz); +T (v0 ? "1234" : b[i3], bsz); +T (v0 ? b[3] : "1234", bsz); +T (v0 ? b[i3] : "1234", bsz); + +T (v0 ? a : b[3], bsz); +T (v0 ? b[0] : b[2], bsz); +T (v0 ? b[2] : b[3], bsz); +T (v0 ? b[3] : b[2], bsz); + +T (v0 ? "1234" : b[3], bsz + 1); +T (v0 ? "1234" : b[i3], bsz + 1); +T (v0 ? b[3] : "1234", bsz + 1); +T (v0 ? b[i3] : "1234", bsz + 1); + +/* That the following are not diagnosed is a bug/limitation resulting from + the fix for PR 103215. */ +T (v0 ? a : b[3], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" "pr103215" { xfail *-*-* } } */ +T (v0 ? b[0] : b[2], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" "pr103215" { xfail *-*-* } } */ +T (v0 ? b[2] : b[3], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" "pr103215" { xfail *-*-* } } */ +T (v0 ? b[3] : b[2], bsz + 1); /* { dg-warning "bound 6 exceeds source size 5" "pr103215" { xfail *-*-* } } */ + +struct A { char a[5], b[5]; }; + +const struct A s = { "1234", "12345" }; + +T (s.a, asz); +T (&s.a[0], asz); +T (&s.a[0] + 1, asz); +T (&s.a[0] + v0, asz); +T (&s.a[1], asz); +T (&s.a[1] + 1, asz); +T (&s.a[1] + v0, asz); + +T (&s.a[i0], asz); +T (&s.a[i0] + i1, asz); +T (&s.a[i0] + v0, asz); +T (&s.a[i1], asz); +T (&s.a[i1] + i1, asz); +T (&s.a[i1] + v0, asz); + +T (s.a, asz + 1); +T (&s.a[0], asz + 1); +T (&s.a[0] + 1, asz + 1); +T (&s.a[0] + v0, asz + 1); /* { dg-warning "specified bound 6 exceeds source size 5 " } */ +T (&s.a[1], asz + 1); +T (&s.a[1] + 1, asz + 1); +T (&s.a[1] + v0, asz + 1); /* { dg-bogus "specified bound 6 exceeds source size 5" "pr95794" { xfail *-*-* } } */ + +T (&s.a[i0], asz + 1); +T (&s.a[i0] + i1, asz + 1); +T (&s.a[i0] + v0, asz + 1); +T (&s.a[i1], asz + 1); +T (&s.a[i1] + i1, asz + 1); +T (&s.a[i1] + v0, asz + 1); + +T (s.b, bsz); +T (&s.b[0], bsz); +T (&s.b[0] + 1, bsz); /* { dg-warning "unterminated" } */ +T (&s.b[0] + v0, bsz); /* { dg-warning "unterminated" } */ +T (&s.b[1], bsz); /* { dg-warning "unterminated" } */ +T (&s.b[1] + 1, bsz); /* { dg-warning "unterminated" } */ +T (&s.b[1] + v0, bsz); /* { dg-warning "unterminated" } */ + +T (&s.b[i0], bsz); +T (&s.b[i0] + i1, bsz); /* { dg-warning "unterminated" } */ +T (&s.b[i0] + v0, bsz); /* { dg-warning "unterminated" } */ +T (&s.b[i1], bsz); /* { dg-warning "unterminated" } */ +T (&s.b[i1] + i1, bsz); /* { dg-warning "unterminated" } */ +T (&s.b[i1] + v0, bsz); /* { dg-warning "unterminated" } */ + +T (s.b, bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[0], bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[0] + 1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[0] + v0, bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[1], bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[1] + 1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[1] + v0, bsz + 1); /* { dg-warning "unterminated" } */ + +T (&s.b[i0], bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[i0] + i1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[i0] + v0, bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[i1], bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[i1] + i1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&s.b[i1] + v0, bsz + 1); /* { dg-warning "unterminated" } */ + +struct B { struct A a[2]; }; + +const struct B ba[] = { + { { { "123", "12345" }, { "12345", "123" } } }, + { { { "12345", "123" }, { "123", "12345" } } }, + { { { "1", "12" }, { "123", "1234" } } }, + { { { "123", "1234" }, { "12345", "12" } } } +}; + +T (ba[0].a[0].a, asz + 1); +T (&ba[0].a[0].a[0], asz + 1); +T (&ba[0].a[0].a[0] + 1, asz + 1); +T (&ba[0].a[0].a[0] + v0, asz + 1); /* { dg-bogus "specified bound 6 exceeds source size 5" pr95794" { xfail *-*-* } } */ +T (&ba[0].a[0].a[1], asz + 1); +T (&ba[0].a[0].a[1] + 1, asz + 1); +T (&ba[0].a[0].a[1] + v0, asz + 1); /* { dg-bogus "specified bound 6 exceeds source size 5" pr95794" { xfail *-*-* } } */ + +T (ba[0].a[0].b, bsz); +T (&ba[0].a[0].b[0], bsz); +T (&ba[0].a[0].b[0] + 1, bsz); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[0] + 1, bsz - 1); +T (&ba[0].a[0].b[0] + v0, bsz); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[1], bsz); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[1], bsz - 1); +T (&ba[0].a[0].b[1] + 1, bsz - 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[1] + 1, bsz - 2); +T (&ba[0].a[0].b[1] + 1, bsz); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[1] + v0, bsz); /* { dg-warning "unterminated" } */ + +T (ba[0].a[0].b, bsz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[0], bsz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[0] + 1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[0] + v0, bsz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[1], bsz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[1] + 1, bsz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[0].b[1] + v0, bsz + 1); /* { dg-warning "unterminated" } */ + +T (ba[0].a[1].a, asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[1].a[0], asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[1].a[0] + 1, asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[1].a[0] + v0, asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[1].a[1], asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[1].a[1] + 1, asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[0].a[1].a[1] + v0, asz + 1); /* { dg-warning "unterminated" } */ + +T (ba[0].a[1].b, bsz + 1); +T (&ba[0].a[1].b[0], bsz + 1); +T (&ba[0].a[1].b[0] + 1, bsz + 1); +T (&ba[0].a[1].b[0] + v0, bsz + 1); /* { dg-bogus "specified bound 6 exceeds source size 5" pr95794" { xfail *-*-* } } */ +T (&ba[0].a[1].b[1], bsz + 1); +T (&ba[0].a[1].b[1] + 1, bsz + 1); +T (&ba[0].a[1].b[1] + v0, bsz + 1); /* { dg-bogus "specified bound 6 exceeds source size 5" pr95794" { xfail *-*-* } } */ + +T (ba[1].a[0].a, asz); +T (&ba[1].a[0].a[0], asz); +T (&ba[1].a[0].a[0] + 1, asz); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[0] + v0, asz); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[1], asz); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[1] + 1, asz); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[1] + v0, asz); /* { dg-warning "unterminated" } */ + +T (ba[1].a[0].a, asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[0], asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[0] + 1, asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[0] + v0, asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[1], asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[1] + 1, asz + 1); /* { dg-warning "unterminated" } */ +T (&ba[1].a[0].a[1] + v0, asz + 1); /* { dg-warning "unterminated" } */ + +T (ba[1].a[0].b, bsz); +T (&ba[1].a[0].b[0], bsz); +T (&ba[1].a[0].b[0] + 1, bsz); +T (&ba[1].a[0].b[0] + v0, bsz); +T (&ba[1].a[0].b[1], bsz); +T (&ba[1].a[0].b[1] + 1, bsz); +T (&ba[1].a[0].b[1] + v0, bsz); + +T (ba[1].a[1].a, asz); +T (&ba[1].a[1].a[0], asz); +T (&ba[1].a[1].a[0] + 1, asz); +T (&ba[1].a[1].a[0] + v0, asz); +T (&ba[1].a[1].a[1], asz); +T (&ba[1].a[1].a[1] + 1, asz); +T (&ba[1].a[1].a[1] + v0, asz); + +T (ba[1].a[1].b, bsz); +T (&ba[1].a[1].b[0], bsz); +T (&ba[1].a[1].b[0] + 1, bsz); /* { dg-warning "unterminated" } */ +T (&ba[1].a[1].b[0] + 1, bsz - 1); +T (&ba[1].a[1].b[0] + v0, bsz); /* { dg-warning "unterminated" } */ +T (&ba[1].a[1].b[1], bsz); /* { dg-warning "unterminated" } */ +T (&ba[1].a[1].b[1], bsz - 1); +T (&ba[1].a[1].b[1] + 1, bsz); /* { dg-warning "unterminated" } */ +T (&ba[1].a[1].b[1] + 1, bsz - 1); /* { dg-warning "unterminated" } */ +T (&ba[1].a[1].b[1] + 1, bsz - 2); +T (&ba[1].a[1].b[1] + 1, bsz - i2); +T (&ba[1].a[1].b[1] + v0, bsz); /* { dg-warning "unterminated" } */ + +/* Prune out warnings with no location (pr?????). + { dg-prune-output "cc1:" } */ diff --git a/SingleSource/Regression/C/gcc-dg/wcaselabel-1.c b/SingleSource/Regression/C/gcc-dg/wcaselabel-1.c new file mode 100644 index 0000000000..6f673dfaf6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wcaselabel-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + + +int foo(int x) +{ + switch(x) + { + + case 0 % 0: /* { dg-error "case label does not reduce to an integer constant" } */ + return 1; + default: + return 2; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/wchar_t-1.c b/SingleSource/Regression/C/gcc-dg/wchar_t-1.c new file mode 100644 index 0000000000..8e22ece3c6 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wchar_t-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target wchar } } */ +/* { dg-options "-Wall" } */ + +/* Compile with -Wall to get a warning if built-in and system wchar_t don't + match. */ + +#define _STDDEF_H +#include + +__WCHAR_TYPE__ __wc_t__; +wchar_t *wc_t_p; + +void +wct (void) +{ + wc_t_p = &__wc_t__; +} diff --git a/SingleSource/Regression/C/gcc-dg/wchar_t-2.c b/SingleSource/Regression/C/gcc-dg/wchar_t-2.c new file mode 100644 index 0000000000..95ddca0e54 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wchar_t-2.c @@ -0,0 +1,6 @@ +/* { dg-options "-fshort-wchar" } */ +/* Check that "-fshort-wchar" makes wchar_t the same size as "unsigned + short". */ + +extern int i[sizeof (L'a')]; +int i[sizeof (unsigned short)]; diff --git a/SingleSource/Regression/C/gcc-dg/webizer.c b/SingleSource/Regression/C/gcc-dg/webizer.c new file mode 100644 index 0000000000..982fbca420 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/webizer.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -funroll-loops" } */ +typedef struct rowbox { + int startx ; + int endx ; + int endx1 ; + int startx2 ; + int ypos ; + int desiredL ; +} ROWBOX ; +ROWBOX rowArray1[3] ; +ROWBOX *rowArray = rowArray1; + +int numRows = 2; + +int row = 1; +int block = 0; +double ckt_size_factor ; + +__attribute__ ((noinline)) +int +configure2() +{ + block = 0 ; + for( row = 1 ; row <= numRows ; row++ ) { + block++ ; + if( rowArray[row].endx1 > 0 ) { + block++ ; + } + } +} + +int +main() +{ + configure2(); + __builtin_exit (0); +} diff --git a/SingleSource/Regression/C/gcc-dg/wide-shift-128.c b/SingleSource/Regression/C/gcc-dg/wide-shift-128.c new file mode 100644 index 0000000000..d769833af0 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wide-shift-128.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target aarch64*-*-* mips64*-*-* sparc64*-*-* } } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-O2 -fdump-rtl-combine" } */ + +__int128_t +load2 (int data) +{ + return (__int128_t) data << 50; +} + +/* { dg-final { scan-rtl-dump-not "ior" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/wide-shift-64.c b/SingleSource/Regression/C/gcc-dg/wide-shift-64.c new file mode 100644 index 0000000000..c1624c5cdb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wide-shift-64.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target mips*-*-* sparc*-*-* } } */ +/* { dg-options "-O2 -fdump-rtl-combine" } */ + +long long +load1 (int data) +{ + return (long long) data << 12; +} + +/* { dg-final { scan-rtl-dump-not "ior" "combine" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/winline-1.c b/SingleSource/Regression/C/gcc-dg/winline-1.c new file mode 100644 index 0000000000..ac2ae82427 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/winline-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-Winline -O2" } */ + +void q(void); +inline int t(void) +{ + int ret; + q(); + ret = t(); /* We define sane semantics for inline keyword on recursive + functions, so do not warn here. */ + q(); + return ret; +} diff --git a/SingleSource/Regression/C/gcc-dg/winline-10.c b/SingleSource/Regression/C/gcc-dg/winline-10.c new file mode 100644 index 0000000000..2df5addaeb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/winline-10.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Winline -fopt-info-optimized-inline=stderr" } */ + +struct s { int a; }; + +inline void f (x) + int x; +{ + asm (""); +} + +void g (struct s x) +{ + f (x); /* { dg-optimized "Inlining f.* into g" } */ +} + +void f (int x); /* { dg-warning "follows non-prototype definition" } */ diff --git a/SingleSource/Regression/C/gcc-dg/winline-2.c b/SingleSource/Regression/C/gcc-dg/winline-2.c new file mode 100644 index 0000000000..0d9114b043 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/winline-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Winline -O2 -fgnu89-inline" } */ + +inline int q(void); /* { dg-warning "body not available" } */ +inline int t(void) +{ + return q(); /* { dg-message "called from here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/winline-3.c b/SingleSource/Regression/C/gcc-dg/winline-3.c new file mode 100644 index 0000000000..7b7c8c5b9e --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/winline-3.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Winline -O2 --param max-inline-insns-single=1 --param inline-min-speedup=100 -fgnu89-inline" } */ + +void big (void); +inline int q(void) /* { dg-warning "max-inline-insns-single" } */ +{ + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); +} +inline int t (void) +{ + return q (); /* { dg-message "called from here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/winline-5.c b/SingleSource/Regression/C/gcc-dg/winline-5.c new file mode 100644 index 0000000000..a587e969ad --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/winline-5.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Winline -O2 --param inline-unit-growth=0 --param large-unit-insns=0 -fgnu89-inline" } */ + +void big (void); +inline int q(void) /* { dg-warning "inline-unit-growth" } */ +{ + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); +} +int t (void) +{ + return q (); /* { dg-message "called from here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/winline-6.c b/SingleSource/Regression/C/gcc-dg/winline-6.c new file mode 100644 index 0000000000..9e89976cff --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/winline-6.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Winline -O2 --param large-function-growth=0 --param large-function-insns=1 -fgnu89-inline" } */ + +void big (void); +inline int q(void) /* { dg-warning "large-function-growth" } */ +{ + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); + big(); +} +inline int t (void) +{ + return q () + 1; /* { dg-message "called from here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/winline-7.c b/SingleSource/Regression/C/gcc-dg/winline-7.c new file mode 100644 index 0000000000..239d748926 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/winline-7.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Winline -O2 -fgnu89-inline" } */ +/* { dg-require-effective-target alloca } */ + +extern void *alloca (__SIZE_TYPE__); + +void big (void); +inline void *q (void) /* { dg-warning "(function not inlinable|alloca)" } */ +{ + return alloca (10); +} +inline void *t (void) +{ + return q (); /* { dg-message "called from here" } */ +} + +/* { dg-prune-output "-Wreturn-local-addr" } */ diff --git a/SingleSource/Regression/C/gcc-dg/winline-9.c b/SingleSource/Regression/C/gcc-dg/winline-9.c new file mode 100644 index 0000000000..6d9cba39d9 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/winline-9.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Winline --param large-stack-frame=10 --param large-stack-frame-growth=2 -fgnu89-inline" } */ + +int a,b; +void test(char *); +static inline +int aa (void) +{ + char t[10]; + test(t); +} +static inline +int bb (void) /* { dg-warning "large-stack-frame" } */ +{ + char t[100]; + test(t); +} + +int +t() +{ + if (a) + aa(); + if (b) + bb(); /* { dg-message "called from here" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/wint_t-1.c b/SingleSource/Regression/C/gcc-dg/wint_t-1.c new file mode 100644 index 0000000000..0574fb9a48 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wint_t-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target wchar } } */ +/* { dg-options "-Wall" } */ + +/* Compile with -Wall to get a warning if built-in and system wint_t don't + match. */ + +#define _STDDEF_H +#include + +__WINT_TYPE__ __wi_t__; +wint_t *wi_t_p; + +void +wit (void) +{ + wi_t_p = &__wi_t__; +} diff --git a/SingleSource/Regression/C/gcc-dg/wmain.c b/SingleSource/Regression/C/gcc-dg/wmain.c new file mode 100644 index 0000000000..06fc26fd39 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wmain.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +int main; /* { dg-warning "'main' is usually a function" } */ + +int foo() +{ + int main = 1; /* { dg-bogus "'main' is usually a function" } */ + return main; +} diff --git a/SingleSource/Regression/C/gcc-dg/wmul-1.c b/SingleSource/Regression/C/gcc-dg/wmul-1.c new file mode 100644 index 0000000000..468a58db94 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wmul-1.c @@ -0,0 +1,18 @@ +/* Not to fuse widening multiply with accumulate if the multiply has more than + one uses. + Note that for targets where pointer and int are of the same size or + widening multiply-and-accumulate is not available, this test just passes. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-widening_mul" } */ + +typedef int ArrT [10][10]; + +void +foo (ArrT Arr, int Idx) +{ + Arr[Idx][Idx] = 1; + Arr[Idx + 10][Idx] = 2; +} + +/* { dg-final { scan-tree-dump-not "WIDEN_MULT_PLUS_EXPR" "widening_mul" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/wrapped-binop-simplify.c b/SingleSource/Regression/C/gcc-dg/wrapped-binop-simplify.c new file mode 100644 index 0000000000..706eed84b8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wrapped-binop-simplify.c @@ -0,0 +1,43 @@ +/* { dg-do compile { target { { i?86-*-* x86_64-*-* s390*-*-* } && lp64 } } } */ +/* { dg-options "-O2 -fdump-tree-vrp2-details" } */ +/* { dg-final { scan-tree-dump-times "gimple_simplified to" 1 "vrp2" } } */ + +void v1 (unsigned long *in, unsigned long *out, unsigned int n) +{ + int i; + + for (i = 0; i < n; i++) + { + out[i] = in[i]; + } +} + +void v2 (unsigned long *in, unsigned long *out, int n) +{ + int i; + + for (i = 0; i < n; i++) + { + out[i] = in[i]; + } +} + +void v3 (unsigned long *in, unsigned long *out, unsigned int n) +{ + unsigned int i; + + for (i = 0; i < n; i++) + { + out[i] = in[i]; + } +} + +void v4 (unsigned long *in, unsigned long *out, int n) +{ + unsigned int i; + + for (i = 0; i < n; i++) + { + out[i] = in[i]; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-aggr-init-1.c b/SingleSource/Regression/C/gcc-dg/wtr-aggr-init-1.c new file mode 100644 index 0000000000..f17531e8fb --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-aggr-init-1.c @@ -0,0 +1,48 @@ +/* Test for -Wtraditional warnings on automatic aggregate initialization. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +struct foo +{ + int i; + long l; +}; + +struct foo f0 = { 0, 0 }; +static struct foo f1 = { 0, 0 }; + +void +testfunc1 () +{ + struct foo f3 = { 0, 0 }; /* { dg-warning "traditional C rejects automatic" "automatic aggregate initialization" } */ + static struct foo f4 = { 0, 0 }; + + f3 = f4; + + __extension__ ({ + struct foo f5 = { 0, 0 }; /* { dg-bogus "traditional C rejects automatic" "__extension__ disables warnings" } */ + f5.i = 0; + }); + + { + struct foo f6 = { 0, 0 }; /* { dg-warning "traditional C rejects automatic" "__extension__ reenables warnings" } */ + f6.i = 0; + } +} + +# 35 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +struct foo f7 = { 0, 0 }; +static struct foo f8 = { 0, 0 }; + +void +testfunc2 () +{ + struct foo f9 = { 0, 0 }; + static struct foo f10 = { 0, 0 }; + + f9 = f10; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-conversion-1.c b/SingleSource/Regression/C/gcc-dg/wtr-conversion-1.c new file mode 100644 index 0000000000..9d2cd99993 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-conversion-1.c @@ -0,0 +1,66 @@ +/* Test for -Wtraditional warnings on conversions by prototypes. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 4/09/2001. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional-conversion" } */ + +extern void foo_i (int); +extern void foo_f (float); +extern void foo_ld (long double); +extern void foo_cd (__complex__ double); + +extern int i; +extern float f; +extern long double ld; +extern __complex__ double cd; + +void +testfunc1 () +{ + foo_i (i); + foo_i (f); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */ + foo_i (ld); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */ + foo_i (cd); /* { dg-warning "as integer rather than complex" "prototype conversion warning" } */ + + foo_f (i); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */ + foo_f (f); /* { dg-warning "as 'float' rather than 'double'" "prototype conversion warning" } */ + foo_f (ld); /* { dg-warning "as 'float' rather than 'double'" "prototype conversion warning" } */ + foo_f (cd); /* { dg-warning "as floating rather than complex" "prototype conversion warning" } */ + + foo_ld (i); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */ + foo_ld (f); /* { dg-warning "as 'float' rather than 'double'" "small double" { target { "avr-*-*" } } } */ + foo_ld (ld);/* { dg-warning "as 'float' rather than 'double'" "small long double" { target { "avr-*-*" } } } */ + foo_ld (cd);/* { dg-warning "as floating rather than complex" "prototype conversion warning" } */ + + foo_cd (i); /* { dg-warning "as complex rather than integer" "prototype conversion warning" } */ + foo_cd (f); /* { dg-warning "as complex rather than floating" "prototype conversion warning" } */ + foo_cd (ld); /* { dg-warning "as complex rather than floating" "prototype conversion warning" } */ + foo_cd (cd); +} + +# 54 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +void +testfunc2 () +{ + foo_i (i); + foo_i (f); + foo_i (ld); + foo_i (cd); + + foo_f (i); + foo_f (f); + foo_f (ld); + foo_f (cd); + + foo_ld (i); + foo_ld (f); + foo_ld (ld); + foo_ld (cd); + + foo_cd (i); + foo_cd (f); + foo_cd (ld); + foo_cd (cd); +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-escape-1.c b/SingleSource/Regression/C/gcc-dg/wtr-escape-1.c new file mode 100644 index 0000000000..7f48de5e8c --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-escape-1.c @@ -0,0 +1,22 @@ +/* Test for -Wtraditional warnings on escape characters. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc () +{ + char c; + + c = '\a'; /* { dg-warning "the meaning of" "escaped character warning " } */ + c = '\x2'; /* { dg-warning "the meaning of" "escaped character warning " } */ + c = '\n'; + +# 17 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + c = '\a'; + c = '\x2'; + c = '\n'; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-func-def-1.c b/SingleSource/Regression/C/gcc-dg/wtr-func-def-1.c new file mode 100644 index 0000000000..bc5a91b5f8 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-func-def-1.c @@ -0,0 +1,204 @@ +/* Test for -Wtraditional warnings on ISO C function definitions. + Note, gcc should omit these warnings in system header files. + Origin: Kaveh R. Ghazi 6/30/2002. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional -std=gnu89" } */ + +/* Test some simple cases. */ + +void f_void1 (void) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +void f_void2 () +{ + return; +} + +void f_int1 (int f) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +void f_int2 (f) + int f; +{ + return; +} + +/* Test that we don't ever warn about nested functions. */ + +void f_int3 (int f) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + void f3a (void) { return; } + void f3b () { return; } + void f3c (int f) { return; } + void f3d (f) int f; { return; } + void f3e (const char *f, ...) { return; } + return; +} + +void f_int4 (int f) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + void f4a (void) { return; } + void f4b () { return; } + void f4c (int f) { return; } + void f4d (f) int f; { return; } + void f4e (const char *f, ...) { return; } + auto f4f (void) { return 0; } + return; +} + +void f_int5 (f) + int f; +{ + void f5a (void) { return; } + void f5b () { return; } + void f5c (int f) { return; } + void f5d (f) int f; { return; } + void f5e (const char *f, ...) { return; } + return; +} + +void f_int6 (f) + int f; +{ + void f6a (void) { return; } + void f6b () { return; } + void f6c (int f) { return; } + void f6d (f) int f; { return; } + void f6e (const char *f, ...) { return; } + auto f6f (void) { return 0; } + return; +} + +/* Test that prototypes are silently accepted and function definitions + are still warned about. */ + +extern void f_int_p1 (int); +void f_int_p1 (int f) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +extern void f_int_p2 (int f); +void f_int_p2 (int f) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +extern void f_int_p3 (int); +void f_int_p3 (f) + int f; +{ + return; +} + +extern void f_int_p4 (int f); +void f_int_p4 (f) + int f; +{ + return; +} + +extern void f_void_p1 (); +void f_void_p1 (void) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +extern void f_void_p2 (void); +void f_void_p2 (void) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +extern void f_blank_p1 (); +void f_blank_p1 () +{ + return; +} + +extern void f_blank_p2 (void); +void f_blank_p2 () +{ + return; +} + +/* Test some implicit int functions. */ + +f_impl1() +{ + return 0; +} + +f_impl2(void) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return 0; +} + +f_impl3(int f) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return 0; +} + +/* Test stdarg functions. */ + +f_stdarg1(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return 0; +} + +void f_stdarg2(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +extern void f_stdarg3(const char *, ...); +void f_stdarg3(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +/* Test handling function pointer parameters. */ + +void f_fnptr1 (int f, int (*fp)(int)); +void f_fnptr1 (int f, int (*fp)(int)) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return; +} + +void f_fnptr2 (int f, int (*fp)(int)); +void f_fnptr2 (f, fp) + int f; + int (*fp)(int); +{ + return; +} + +/* Test for main. */ + +int +main (int argc, char **argv) /* { dg-warning "traditional C rejects ISO C style" } */ +{ + return 0; +} + +# 182 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +void fsys1 (void) +{ + return; +} + +void fsys2 (int f) +{ + return; +} + +void fsys3 (const char *f, ...) +{ + return; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-int-type-1.c b/SingleSource/Regression/C/gcc-dg/wtr-int-type-1.c new file mode 100644 index 0000000000..8a07930832 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-int-type-1.c @@ -0,0 +1,52 @@ +/* Test for -Wtraditional warnings on integer constant types. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Wtraditional" } */ + +void +testfunc () +{ + long long i; + + /* Octal and hex values shouldn't issue -Wtraditional warnings. */ + i = 0x80000000; + i = 0xFFFFFFFF; + i = 037777777777; + + i = 0x8000000000000000; + i = 0xFFFFFFFFFFFFFFFF; + i = 01777777777777777777777; + + /* Nor should values outside the range of (32-bit) unsigned long but + inside the range of long long. [since -traditional has no long long, + we can pretend it worked the way it does in C99.] */ + i = 9223372036854775807; + + /* But this one should, since it doesn't fit in long (long), but + does fit in unsigned long (long). */ + i = 18446744073709551615; /* { dg-warning "integer constant is so large that it is unsigned" "so large" } */ + /* { dg-warning "this decimal constant would be unsigned in ISO C90" "ISO C90" { target *-*-* } .-1 } */ + +# 29 "sys-header.h" 3 +} + +void +testfunc2( ) +{ + long long i; + +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + i = 0x80000000; + i = 0xFFFFFFFF; + i = 037777777777; + + i = 0x8000000000000000; + i = 0xFFFFFFFFFFFFFFFF; + i = 01777777777777777777777; + + i = 9223372036854775807; + i = 18446744073709551615; +} + diff --git a/SingleSource/Regression/C/gcc-dg/wtr-label-1.c b/SingleSource/Regression/C/gcc-dg/wtr-label-1.c new file mode 100644 index 0000000000..78a4d6b0a4 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-label-1.c @@ -0,0 +1,52 @@ +/* Test for -Wtraditional warnings on label conflicts with identifiers. + Note, gcc should omit these warnings in system header files. + Origin: Kaveh R. Ghazi 8/24/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +enum foo1 { a }; +struct foo2 { int i; }; +union foo3 { int j; }; +int foo4; +typedef int foo5; + +void +testfunc1 (foo6) + int foo6; +{ + int foo7; + + foo1: + foo2: + foo3: + foo4: /* { dg-warning "traditional C lacks" "label conflicts with identifier" } */ + foo5: /* { dg-warning "traditional C lacks" "label conflicts with identifier" } */ + foo6: /* { dg-warning "traditional C lacks" "label conflicts with identifier" } */ + foo7: /* { dg-warning "traditional C lacks" "label conflicts with identifier" } */ + testfunc1: /* { dg-warning "traditional C lacks" "label conflicts with identifier" } */ + a: /* { dg-warning "traditional C lacks" "label conflicts with identifier" } */ + i: + j: ; +} + +# 32 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +void +testfunc2 (foo6) + int foo6; +{ + int foo7; + + foo1: + foo2: + foo3: + foo4: + foo5: + foo6: + foo7: + testfunc2: + a: + i: + j: ; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-static-1.c b/SingleSource/Regression/C/gcc-dg/wtr-static-1.c new file mode 100644 index 0000000000..318b2f32ca --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-static-1.c @@ -0,0 +1,14 @@ +/* Test for -Wtraditional warnings on static/non-static mismatches. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +static void testfunc1(void); /* { dg-message "note: previous declaration" } */ +void testfunc1() {} /* { dg-warning "non-static.*follows static" "non-static follows static" } */ + +# 11 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + +static void testfunc2(void); +void testfunc2() {} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-strcat-1.c b/SingleSource/Regression/C/gcc-dg/wtr-strcat-1.c new file mode 100644 index 0000000000..730a929c59 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-strcat-1.c @@ -0,0 +1,18 @@ +/* Test for -Wtraditional warnings on string concatenation. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc () +{ + const char *foo; + + foo = "hello" "hello"; /* { dg-warning "concatenation" "string concatenation" } */ + +# 15 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + foo = "hello" "hello"; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-suffix-1.c b/SingleSource/Regression/C/gcc-dg/wtr-suffix-1.c new file mode 100644 index 0000000000..ed0b40ecf3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-suffix-1.c @@ -0,0 +1,35 @@ +/* Test for -Wtraditional warnings on integer constant suffixes. + Note, gcc should omit these warnings in system header files. + Origin: Kaveh R. Ghazi 8/24/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc () +{ + int i; + double f; + + i = 1L; + i = 1l; + i = 1U; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */ + i = 1u; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */ + f = 1.0; + f = 1.0F; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */ + f = 1.0f; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */ + f = 1.0L; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */ + f = 1.0l; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */ + +# 24 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + i = 1L; + i = 1l; + i = 1U; + i = 1u; + f = 1.0; + f = 1.0F; + f = 1.0f; + f = 1.0L; + f = 1.0l; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-switch-1.c b/SingleSource/Regression/C/gcc-dg/wtr-switch-1.c new file mode 100644 index 0000000000..f0381bc5e3 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-switch-1.c @@ -0,0 +1,25 @@ +/* Test for -Wtraditional warnings on switch operands of type long. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc (l) + long l; +{ + switch (l) /* { dg-warning "switch expression" "switch expression" } */ + { + default: + break; + } + +# 17 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + switch (l) + { + default: + break; + } +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-unary-plus-1.c b/SingleSource/Regression/C/gcc-dg/wtr-unary-plus-1.c new file mode 100644 index 0000000000..aee892c532 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-unary-plus-1.c @@ -0,0 +1,20 @@ +/* Test for -Wtraditional warnings on the unary plus operator. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +void +testfunc () +{ + int i; + + i = +1; /* { dg-warning "unary plus operator" "unary plus operator" } */ + i = +i; /* { dg-warning "unary plus operator" "unary plus operator" } */ + +# 16 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + i = +1; + i = +i; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-union-init-1.c b/SingleSource/Regression/C/gcc-dg/wtr-union-init-1.c new file mode 100644 index 0000000000..b6a814d7a1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-union-init-1.c @@ -0,0 +1,25 @@ +/* Test for -Wtraditional warnings on union initialization. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 8/22/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +union foo +{ + int i; + long l; +}; + +void +testfunc () +{ + /* Note we only warn for nonzero initializers. */ + static union foo f1 = { 0 }; + static union foo f2 = { 1 }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + +# 21 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + static union foo f3 = { 0 }; + static union foo f4 = { 1 }; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-union-init-2.c b/SingleSource/Regression/C/gcc-dg/wtr-union-init-2.c new file mode 100644 index 0000000000..bea26f1bfa --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-union-init-2.c @@ -0,0 +1,45 @@ +/* Test for -Wtraditional warnings on union initialization. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 9/11/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +union foo1 +{ + float f; + int i; + long l; +}; + +union foo2 +{ + int i; + float f; + long l; +}; + +void +testfunc () +{ + /* Note we only warn for nonzero initializers. */ + static union foo1 f1 = {0}; + static union foo2 f2 = {0}; + static union foo1 f3 = {1}; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + static union foo2 f4 = {1}; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + static union foo1 f5 = {0.0}; + static union foo2 f6 = {0.0}; + static union foo1 f7 = {1.0}; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + static union foo2 f8 = {1.0}; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + +# 35 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + static union foo1 b1 = {0}; + static union foo2 b2 = {0}; + static union foo1 b3 = {1}; + static union foo2 b4 = {1}; + static union foo1 b5 = {0.0}; + static union foo2 b6 = {0.0}; + static union foo1 b7 = {1.0}; + static union foo2 b8 = {1.0}; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtr-union-init-3.c b/SingleSource/Regression/C/gcc-dg/wtr-union-init-3.c new file mode 100644 index 0000000000..407554a9c1 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtr-union-init-3.c @@ -0,0 +1,64 @@ +/* Test for -Wtraditional warnings on union initialization. + Note, gcc should omit these warnings in system header files. + By Kaveh R. Ghazi 9/11/2000. */ +/* { dg-do compile } */ +/* { dg-options "-Wtraditional" } */ + +struct bar +{ + int i; + long j; +}; + +union foo +{ + struct bar b; + int i; + long l; +}; + +union foo2 +{ + int i; + long l; +}; + +struct baz +{ + int a; + double b; + union foo c; +}; + +struct baz2 +{ + int a; + double b; + union foo2 c; +}; + +void +testfunc () +{ + /* Note we only warn for nonzero initializers. Xfail on substructures. */ + static union foo f1 = {{0,0}}; /* { dg-bogus "traditional C rejects initialization of unions" "initialization of unions" { xfail *-*-* } } */ + static union foo f2 = {{1,1}}; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + + static struct baz f3 = { 1, 2, {{0,0}} }; /* { dg-bogus "traditional C rejects initialization of unions" "initialization of unions" { xfail *-*-* } } */ + static struct baz f4 = { 1, 2, {{1,1}} }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + + static struct baz2 f5 = { 1, 2, {0} }; + static struct baz2 f6 = { 1, 2, {1} }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */ + +# 54 "sys-header.h" 3 +/* We are in system headers now, no -Wtraditional warnings should issue. */ + + static union foo b1 = {{0,0}}; + static union foo b2 = {{1,1}}; + + static struct baz b3 = { 1, 2, {{0,0}} }; + static struct baz b4 = { 1, 2, {{1,1}} }; + + static struct baz2 b5 = { 1, 2, {0} }; + static struct baz2 b6 = { 1, 2, {1} }; +} diff --git a/SingleSource/Regression/C/gcc-dg/wtypequal.c b/SingleSource/Regression/C/gcc-dg/wtypequal.c new file mode 100644 index 0000000000..9a7189929d --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/wtypequal.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +int *__restrict *p; +void f(void) +{ + __typeof(*p) *q = p; /* { dg-bogus "discards qualifiers" } */ +} diff --git a/SingleSource/Regression/C/gcc-dg/zero_bits_compound-1.c b/SingleSource/Regression/C/gcc-dg/zero_bits_compound-1.c new file mode 100644 index 0000000000..e71594911b --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/zero_bits_compound-1.c @@ -0,0 +1,42 @@ +/* Test whether an AND mask or'ed with the know zero bits that equals a mode + mask is a candidate for zero extendion. */ + +/* Note: This test requires that char, int and long have different sizes and the + target has a way to do 32 -> 64 bit zero extension other than AND. */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* s390*-*-* } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O3 -dP" } */ + +unsigned long foo (unsigned char c) +{ + unsigned long l; + unsigned int i; + + i = ((unsigned int)c) << 8; + i |= ((unsigned int)c) << 20; + asm volatile ("":::); + i = i & 0x0ff0ff00; + asm volatile ("":::); + l = (unsigned long)i; + + return l; +} + +unsigned long bar (unsigned char c) +{ + unsigned long l; + unsigned int i; + + i = ((unsigned int)c) << 8; + i |= ((unsigned int)c) << 20; + asm volatile ("":::); + i = i & 0x0ffffff0; + asm volatile ("":::); + l = (unsigned long)i; + + return l; +} + +/* Check that no pattern containing an AND expression was used. */ +/* { dg-final { scan-assembler-not "\\(and:" } } */ diff --git a/SingleSource/Regression/C/gcc-dg/zero_bits_compound-2.c b/SingleSource/Regression/C/gcc-dg/zero_bits_compound-2.c new file mode 100644 index 0000000000..64e6744b79 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/zero_bits_compound-2.c @@ -0,0 +1,41 @@ +/* Test whether an AND mask or'ed with the know zero bits that equals a mode + mask is a candidate for zero extendion. */ + +/* { dg-do compile { target i?86-*-* x86_64-*-* s390*-*-* aarch64*-*-* } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O3 -dP -fdump-rtl-combine" } */ + +unsigned long foo (unsigned char c) +{ + unsigned long l; + unsigned int i; + + i = ((unsigned int)c) << 8; + i |= ((unsigned int)c) << 20; + asm volatile ("":::); + i = i & 0x0fe0fe00; + asm volatile ("":::); + l = (unsigned long)i; + + return l; +} + +unsigned long bar (unsigned char c) +{ + unsigned long l; + unsigned int i; + + i = ((unsigned int)c) << 8; + i |= ((unsigned int)c) << 20; + asm volatile ("":::); + i = i & 0x07f007f0; + asm volatile ("":::); + l = (unsigned long)i; + + return l; +} + +/* Check that an AND expression was used. */ +/* { dg-final { scan-assembler-times "\\(and:" 2 { target { ! aarch64*-*-* } } } } */ +/* { dg-final { scan-rtl-dump "\\(and:DI" "combine" { target aarch64*-*-* } } } */ +/* { dg-final { scan-rtl-dump "\\(and:SI" "combine" { target aarch64*-*-* } } } */ diff --git a/SingleSource/Regression/C/gcc-dg/zero_sign_ext_test.c b/SingleSource/Regression/C/gcc-dg/zero_sign_ext_test.c new file mode 100644 index 0000000000..ea2c59c0a7 --- /dev/null +++ b/SingleSource/Regression/C/gcc-dg/zero_sign_ext_test.c @@ -0,0 +1,137 @@ +extern void abort (void); + +/* { dg-options "-O2" } */ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +#define TYPE_MAX(type, sign) \ + ((!sign) ? ((1 << (sizeof (type) * 8 - 1)) - 1) : \ + ((1 << (sizeof (type) * 8)) - 1)) +#define TYPE_MIN(type, sign) \ + ((!sign) ? -(1 << (sizeof (type) * 8 - 1)) : 0) + +#define TEST_FN(NAME, ARG_TYPE, RET_TYPE, CAST_TYPE, VAL, VR_MIN, VR_MAX)\ + __attribute__((noinline, noclone)) RET_TYPE \ + NAME (ARG_TYPE arg){ \ + RET_TYPE ret = VAL; \ + if (arg + 1 < VR_MIN || arg + 1 > VR_MAX) return ret; \ + /* Value Range of arg at this point will be [VR_min, VR_max]. */\ + arg = arg + VAL; \ + ret = (CAST_TYPE)arg; \ + return arg; \ + } + +/* Signed to signed conversion with value in-range. */ +TEST_FN (foo1, short, short, char, 1, TYPE_MIN (char, 0), TYPE_MAX (char, 0)); +TEST_FN (foo2, short, short, char, 1, TYPE_MIN (char, 0) + 1,\ + TYPE_MAX (char, 0) - 1); + +/* Signed to signed conversion with value not in-range. */ +TEST_FN (foo3, short, short, char, -1, TYPE_MIN (short, 0) + 1, 100); +TEST_FN (foo4, short, short, char, 1, 12, TYPE_MAX (short, 0) + 1); + +/* Unsigned to unsigned conversion with value in-range. */ +TEST_FN (foo5, unsigned short, unsigned short, unsigned char, 1,\ + TYPE_MIN (char, 1) + 1, TYPE_MAX (char, 1) - 1); +TEST_FN (foo6, unsigned short, unsigned short, unsigned char, 1,\ + TYPE_MIN (char, 1), TYPE_MAX (char, 1)); + +/* Unsigned to unsigned conversion with value not in-range. */ +TEST_FN (foo7, unsigned short, unsigned short, unsigned char, 1,\ + TYPE_MIN (short, 1) + 1, TYPE_MAX (short, 1) - 1); +TEST_FN (foo8, unsigned short, unsigned short, unsigned char, 1,\ + TYPE_MIN (short, 1), TYPE_MAX (short, 1)); + +/* Signed to unsigned conversion with value range positive. */ +TEST_FN (foo9, short, short, unsigned char, -1, 1,\ + TYPE_MAX (char, 1) - 1); +TEST_FN (foo10, short, short, unsigned char, 1, 0,\ + TYPE_MAX (char, 1)); + +/* Signed to unsigned conversion with value range negative. */ +TEST_FN (foo11, short, short, unsigned char, 1,\ + TYPE_MIN (char, 0) + 1, TYPE_MAX (char, 0) - 1); +TEST_FN (foo12, short, short, unsigned char, 1,\ + TYPE_MIN (char, 0), TYPE_MAX (char, 0)); + +/* Unsigned to Signed conversion with value range in signed equiv range. */ +TEST_FN (foo13, unsigned short, unsigned short, char, 1,\ + TYPE_MIN (char, 1) + 1, TYPE_MAX (char, 0) - 1); +TEST_FN (foo14, unsigned short, unsigned short, char, 1,\ + TYPE_MIN (char, 1), TYPE_MAX (char, 0)); + +/* Unsigned to Signed conversion with value range not-in signed range. */ +TEST_FN (foo15, unsigned short, unsigned short, char, 1,\ + TYPE_MIN (char, 1) + 1, TYPE_MAX (char, 1) - 1); +TEST_FN (foo16, unsigned short, unsigned short, char, 1,\ + TYPE_MIN (char, 1), TYPE_MAX (char, 1)); + +int main () +{ + /* Signed to signed conversion with value in-range. */ + /* arg + 1. */ + if (foo1 (-32) != -31) + abort (); + /* arg + 1. */ + if (foo2 (32) != 33) + abort (); + + /* Signed to signed conversion with value not in-range. */ + /* arg - 1. */ + if (foo3 (-512) != -513) + abort (); + /* arg + 1. */ + if (foo4 (512) != 513) + abort (); + + /* Unsigned to unsigned conversion with value in-range. */ + /* arg + 1. */ + if (foo5 (64) != 65) + abort (); + /* arg + 1. */ + if (foo6 (64) != 65) + abort (); + + /* Unsigned to unsigned conversion with value not in-range. */ + /* arg + 1. */ + if (foo7 (512) != 513) + abort (); + /* arg + 1. */ + if (foo8 (512) != 513) + abort (); + + /* Signed to unsigned conversion with value range positive. */ + /* arg - 1. */ + if (foo9 (2) != 1) + abort (); + /* arg + 1. */ + if (foo10 (2) != 3) + abort (); + + /* Signed to unsigned conversion with value range negative. */ + /* arg + 1. */ + if (foo11 (-125) != -124) + abort (); + /* arg + 1. */ + if (foo12 (-125) != -124) + abort (); + + /* Unsigned to Signed conversion with value range in signed equiv range. */ + /* arg + 1. */ + if (foo13 (125) != 126) + abort (); + /* arg + 1. */ + if (foo14 (125) != 126) + abort (); + + /* Unsigned to Signed conversion with value range not-in signed range. */ + /* arg + 1. */ + if (foo15 (250) != 251) + abort (); + /* arg + 1. */ + if (foo16 (250) != 251) + abort (); + + return 0; +} + diff --git a/SingleSource/Regression/C/tree-vect.h b/SingleSource/Regression/C/tree-vect.h new file mode 100644 index 0000000000..c4b8144121 --- /dev/null +++ b/SingleSource/Regression/C/tree-vect.h @@ -0,0 +1,93 @@ +/* Check if system supports SIMD */ +#include + +#if defined(__i386__) || defined(__x86_64__) +# include "cpuid.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif +extern void abort (void); +extern void exit (int); +#ifdef __cplusplus +} +#endif + +static void +sig_ill_handler (int sig) +{ + exit(0); +} + +static void __attribute__((noinline)) +check_vect (void) +{ + signal(SIGILL, sig_ill_handler); +#if defined(__PAIRED__) + /* 750CL paired-single instruction, 'ps_mul %v0,%v0,%v0'. */ + asm volatile (".long 0x10000032"); +#elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__) || defined(powerpc) + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); +#elif defined(__i386__) || defined(__x86_64__) + { + unsigned int a, b, c, d, + want_level, want_b = 0, want_c = 0, want_d = 0; + + /* Determine what instruction set we've been compiled for, and detect + that we're running with it. This allows us to at least do a compile + check for, e.g. SSE4.1 when the machine only supports SSE2. */ +# if defined(__AVX2__) + want_level = 7, want_b = bit_AVX2; +# elif defined(__AVX__) + want_level = 1, want_c = bit_AVX; +# elif defined(__SSE4_2__) + want_level = 1, want_c = bit_SSE4_2; +# elif defined(__SSE4_1__) + want_level = 1, want_c = bit_SSE4_1; +# elif defined(__SSSE3__) + want_level = 1, want_c = bit_SSSE3; +# else + want_level = 1, want_d = bit_SSE2; +# endif + + if (!__get_cpuid_count (want_level, 0, &a, &b, &c, &d) + || ((b & want_b) | (c & want_c) | (d & want_d)) == 0) + exit (0); + } +#elif defined(__sparc__) + asm volatile (".word\t0x81b007c0"); +#elif defined(__arm__) + { + /* On some processors without NEON support, this instruction may + be a no-op, on others it may trap, so check that it executes + correctly. */ + long long a = 0, b = 1; + asm ("vorr %P0, %P1, %P2" + : "=w" (a) + : "0" (a), "w" (b)); + if (a != 1) + exit (0); + } +#elif defined(__mips_msa) + asm volatile ("or.v $w0,$w0,$w0"); +#endif + signal (SIGILL, SIG_DFL); +} + +#if defined (__ARM_FEATURE_SVE) +# if __ARM_FEATURE_SVE_BITS == 0 +# define VECTOR_BITS 1024 +# else +# define VECTOR_BITS __ARM_FEATURE_SVE_BITS +# endif +#else +# define VECTOR_BITS 128 +#endif + +/* Which most of our tests are going to #define for internal use, and + which might be exposed by system headers related to signal.h on some + targets, notably VxWorks. */ +#undef OFFSET + diff --git a/SingleSource/Regression/DgOptions.txt b/SingleSource/Regression/DgOptions.txt new file mode 100644 index 0000000000..010ddf9823 --- /dev/null +++ b/SingleSource/Regression/DgOptions.txt @@ -0,0 +1,324 @@ +# The following cause errors if they are passed to clang via CFLAGS +set(CLANG_ERRORING_CFLAGS + "-fdump-ipa-" + "-fdump-tree-" + "-fdump-rtl-" + "-fipa-" + "-fira-" + "-fopt-" + "-fno-ipa-" + "-fno-ira-" + "-ftree-loop-" + "-fno-tree-b" + "-fno-tree-c" + "-fno-tree-d" + "-fno-tree-f" + "-fno-tree-t" + "-fno-tree-p" + "-ftree-p" + "-fdisable-tree-" + "-fdisable-ipa-" + "-fcode-hoisting" + "-fcompare-debug" + "-fno-checking" + "-fno-dse" + "-fno-delayed-branch" + "-fno-early-inlining" + "-fno-rerun-cse-after-loop" + "-fno-guess-branch-probability" + "-fno-split-loops" + "-fno-tree-reassoc" + "-fno-tree-loop-im" + "-fno-tree-sink" + "-fno-tree-sra" + "-fno-tree-scev-cprop" + "-fno-toplevel-reorder" + "-fno-fp-int-builtin-inexact" + "-ftree-tail-merge" + "-fgimple" + "-fisolate-erroneous-paths-attribute" + "-flive-patching=inline-clone" + "-fdisable-rtl-init-regs" + "-fpredictive-commoning" + "-ftrack-macro-expansion=0" + "-fstrict-volatile-bitfields" + "-fvar-tracking-assignments" + "-fno-selective-scheduling" + "-fleading-underscore" + "-fopt-info-optimized-inline=stderr" + "-fdump-passes" + "-fno-dce" + "-fno-sched-pressure" + "-fno-tree-loop-distribute-patterns" + "-fenable-tree-cunrolli" + "-floop-unroll-and-jam" + "-fpeephole2" + "-fno-code-hoisting" + "-fno-finite-loops" + "--fast-math" + "--completion" + "--dump" + "-free" + "-fdiagnostics-show-caret" + "-fallow-parameterless-variadic-functions" + "-freorder-blocks-and-partition" + "-fstack-protector-explicit" + "-fno-var-tracking-assignments" + "-fno-strict-volatile-bitfields" + "-fprofile-exclude-files" + "-fprofile-filter-files" + "-fsched2-use-superblocks" + "-fno-forward-propagate" + "-frerun-cse-after-loop" + "-fsection-anchors" + "-fno-keep-inline-dllexport" + "-fcrossjumping" + "-ftree-coalesce-vars" + "-fselective-scheduling" + "-fsel-sched-pipelining" + "-fdiagnostics-generate-patch" + "-fstack-usage" + "-fno-split-wide-types" + "-fno-ssa-phiopt" + "-fno-tree-loop-ivcanon" + "-ftrack-macro-expansion" + "-fno-cprop-registers" + "-fno-optimize-strlen" + "-fno-if-conversion" + "-fno-peephole2" + "-flive-range-shrinkage" + "-fno-isolate-erroneous-paths-dereference" + "-fcse-follow-jumps" + "-freorder-blocks-algorithm" + "-fsplit-loops" + "-fno-gcse-lm" + "-fno-reorder-blocks-and-partition" + "-fno-move-loop-invariants" + "-fdbg-cnt" + "-fno-tree-loop-vectorize" + "-fsched-pressure" + "-ftree-cselim" + "-findirect-inlining" + "-fno-sched-critical-path-heuristic" + "-fno-sched-rank-heuristic" + "-fstack-check" + "-fno-tree-loop-optimize" + "-fself-test" + "-fguess-branch-probability" + "-fsplit-wide-types" + "-fno-inline-atomics" + "-finstrument-functions-exclude-function-list" + "-finstrument-functions-exclude-file-list" + "-fsched-stalled-insns" + "-gstabs" + "-flive-patching" + "-fplan9-extensions" + "-fif-conversion" + "-fno-crossjumping" + "-fkeep-inline-dllexport" + "-fthread-jumps" + "-fno-tree-slsr" + "--no-enum-size-warning" + "-ms" + "-mno-foobar" + "-m64" + "-mavx" + "-fkeep-static-functions" + "-fmove-loop-invariants" + "-fprofile-update" + "-fwrapv-pointer" + "-fno-foobar" + "-fhoist-adjacent-loads" + "-fno-partial-inlining" + "-fno-tree-switch-conversion" + "-floop-interchange" + "-fsplit-paths" + "-ftree-dominator-opts" + "-fno-wrapv-pointer" + "-fopenacc" + "-fvect-cost-model" + "-fprintf-return-value" + "-ffinite-loops" + "-fkeep-gc-roots-live" + "-fallow-store-data-races" + "-fgnu-tm" + "-floop-parallelize-all" + "-floop-nest-optimize" + "-fgraphite-identity" + "-fgraphite" + "-fstack-reuse" + "-floop-block" + "-floop-strip-mine" + "-fno-tree-loop-if-convert" + "-fno-version-loops-for-strides" + "-fno-reorder-functions" + "-fno-profile-reorder-functions" + "-flto-partition" + "-fno-allow-store-data-races" + "-fno-strict-flex-arrays" + "-fconserve-stack" + "-finstrument-functions-once" + "-fno-thread-jumps" + "-fpreprocessed" + "-fchecking" + "-fstrict-flex-arrays" + "-fbranch-probabilities" + "-fdelete-dead-exceptions" + "-fharden-compares" + "-gtoggle" + "-fabi-version" + "-fharden-conditional-branches" + "-fvar-tracking" + "-funreachable-traps" + "-fpartial-inlining" + "-foptimize-strlen" + "-fno-bit-tests" + "-fasan-shadow-offset" + "--disable-tree-evrp" + "-fprofile-info-section" + "-Wl,--no-enum-size-warning" +) + +# The following cause errors if they are passed to clang via LDFLAGS +set(CLANG_ERRORING_LDFLAGS + "-flinker-output" + "-flto-partition" +) + +# This pulls out options in dg-options into `${Variable}` and pulls +# dg-do "action" into DG_DO +# dg-additional-sources "*.c" into DG_SRC +function(gcc_torture_dg_options_cflags Variable DG_DO DG_SRC File) + # Some files have dg-options which we need to pick up. These should be in + # the first line but often aren't. + # + # We also need to be careful not to pick up target-specific dg-options. + set(DG_CFLAGS) + + file(STRINGS ${File} FileLines) + foreach(FileLine ${FileLines}) + if(FileLine MATCHES "dg-additional-sources \"?([^\" ]*)") + set(DG_SRC ${CMAKE_MATCH_1} PARENT_SCOPE) + endif() + if(FileLine MATCHES "dg-do ([^}\" ]*)(.*)") + set(DG_DO ${CMAKE_MATCH_1} PARENT_SCOPE) + endif() + # Skip dg-warning + if(FileLine MATCHES "dg-warning(.*)") + continue() + endif() + # Looking for `dg-options "..."` or `dg-additional-options "..."` without + # `{ target` afterwards (ignoring spaces). + if(FileLine MATCHES "dg-(additional-)?options ({ )?\"([^\"]*)\"( })?(.*)") + # This is needed to turn the string into a list of CFLAGS + separate_arguments(FILE_CFLAGS UNIX_COMMAND ${CMAKE_MATCH_3}) + # This does the negative lookahead for `{ target` anywhere in the rest of + # the line + if(NOT ${CMAKE_MATCH_5} MATCHES "{ +target") + list(APPEND DG_CFLAGS ${FILE_CFLAGS}) + endif() + endif() + endforeach() + + # Remove any flags that will make clang error + if (DG_CFLAGS) + foreach(ERROR_CFLAG ${CLANG_ERRORING_CFLAGS}) + list(FILTER DG_CFLAGS EXCLUDE REGEX "^${ERROR_CFLAG}.*") + endforeach() + endif() + + # Set the parent scope variable + set(${Variable} ${DG_CFLAGS} PARENT_SCOPE) +endfunction() + +function(gcc_torture_execute_test File) + cmake_parse_arguments(_TORTURE "" "PREFIX;DG_DO_DEFAULT" "CFLAGS;LDFLAGS" ${ARGN}) + # There are a few tests with duplicate filenames, and CMake wants all target + # names to be unique, so we add a disambiguator to the target name. The + # disambiguator is based upon the directory structure, swapping `/` for `-`. + get_filename_component(Name ${File} NAME_WE) + set(_target "${_TORTURE_PREFIX}_${Name}") + + gcc_torture_dg_options_cflags(DG_CFLAGS DG_DO DG_SRC ${File}) + + # Add any flags that were requested + list(APPEND CFLAGS ${DG_CFLAGS} ${_TORTURE_CFLAGS}) + list(APPEND LDFLAGS ${DG_CFLAGS} ${_TORTURE_LDFLAGS}) + + # Only compile the test case if there is no dg-do in the test case. + if(NOT DG_DO) + if(_TORTURE_DG_DO_DEFAULT STREQUAL "preprocess") + list(APPEND CFLAGS ${DG_CFLAGS} "-E") + llvm_test_library(${_target} OBJECT ${File}) + + elseif(_TORTURE_DG_DO_DEFAULT STREQUAL "assemble") + list(APPEND CFLAGS ${DG_CFLAGS} "-S") + llvm_test_library(${_target} OBJECT ${File}) + + elseif(_TORTURE_DG_DO_DEFAULT STREQUAL "compile") + llvm_test_library(${_target} OBJECT ${File}) + + elseif(_TORTURE_DG_DO_DEFAULT STREQUAL "link") + if(DG_SRC) + llvm_test_executable_no_test(${_target} ${File} ${DG_SRC}) + else() + llvm_test_executable_no_test(${_target} ${File}) + endif() + + elseif(_TORTURE_DG_DO_DEFAULT STREQUAL "run") + if(DG_SRC) + llvm_test_executable_no_test(${_target} ${File} ${DG_SRC}) + else() + llvm_test_executable_no_test(${_target} ${File}) + endif() + + llvm_test_run() + llvm_add_test_for_target(${_target}) + + elseif() + message(FATAL_ERROR "Unknown DG_DO_DEFAULT parameter: \"${_TORTURE_DG_DO_DEFAULT}\"") + endif() + + return() + endif() + + # Only compile the test case if specify with "dg-do compile" + if(DG_DO STREQUAL "compile") + llvm_test_library(${_target} OBJECT ${File}) + return() + endif() + + # Only assemble the test case if specify with "dg-do assemble" + if(DG_DO STREQUAL "assemble") + list(APPEND CFLAGS ${DG_CFLAGS} "-S") + llvm_test_library(${_target} OBJECT ${File}) + return() + endif() + + # Only assemble the test case if specify with "dg-do preprocess" + if(DG_DO STREQUAL "preprocess") + list(APPEND CFLAGS ${DG_CFLAGS} "-E") + llvm_test_library(${_target} OBJECT ${File}) + return() + endif() + + if(DG_SRC) + llvm_test_executable_no_test(${_target} ${File} ${DG_SRC}) + else() + llvm_test_executable_no_test(${_target} ${File}) + endif() + + # Only link the test case if specify with "dg-do link" + if(DG_DO STREQUAL "link") + return() + endif() + + llvm_test_run() + + llvm_add_test_for_target(${_target}) +endfunction() + + +# GCC C Torture Suite is conventionally run without warnings +list(APPEND CFLAGS "-w" "-Wno-implicit-function-declaration" "-Wno-implicit-int" + "-Wno-int-conversion")